var j={},tt;function kt(){return tt||(tt=1,function(et){(function(p,E){E(et)})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:j,function(p){Object.defineProperty(p,"__esModule",{value:!0}),p.toXML=p.default=void 0;function E(e){return at(e)||nt(e)||D(e)||rt()}function rt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nt(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function at(e){if(Array.isArray(e))return R(e)}function M(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?M(Object(r),!0).forEach(function(n){N(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):M(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function N(e,t,r){return t=ut(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ut(e){var t=it(e,"string");return d(t)=="symbol"?t:String(t)}function it(e,t){if(d(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(d(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ot(e,t){return ft(e)||st(e,t)||D(e,t)||ct()}function ct(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function D(e,t){if(e){if(typeof e=="string")return R(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return R(e,t)}}function R(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function st(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,a,i,o,c=[],l=!0,m=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(l=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);l=!0);}catch(v){m=!0,a=v}finally{try{if(!l&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(m)throw a}}return c}}function ft(e){if(Array.isArray(e))return e}function d(e){"@babel/helpers - typeof";return d=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(e)}var u={ARRAY:"array",BOOLEAN:"boolean",DATE:"date",FUNCTION:"function",JSTOXML_OBJECT:"jstoxml-object",NULL:"null",NUMBER:"number",OBJECT:"object",STRING:"string"},lt=[u.STRING,u.NUMBER,u.BOOLEAN],dt='<?xml version="1.0" encoding="UTF-8"?>',B=["_selfCloseTag","_attrs"],mt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return t.repeat(r)},S=function(t){return Array.isArray(t)&&u.ARRAY||d(t)===u.OBJECT&&t!==null&&t._name&&u.JSTOXML_OBJECT||t instanceof Date&&u.DATE||t===null&&u.NULL||d(t)},J=function(t){return t.startsWith("<![CDATA[")},F=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,a=t;if(d(t)===u.STRING){if(J(t))return t;var i=new RegExp("(".concat(Object.keys(r).join("|"),")(?!(\\w|#)*;)"),"g");a=String(t).replace(i,function(o,c){return r[c]||""})}return typeof n=="function"?n(a):a},gt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=Array.isArray(t)?t:Object.entries(t).map(function(o){var c=ot(o,2),l=c[0],m=c[1];return N({},l,m)});return i.reduce(function(o,c){var l=Object.keys(c)[0],m=c[l];if(d(n)===u.FUNCTION){var v=n(l,m);if(v)return o}var b=r?F(m,r):m,I=!a&&b===!0?"":'="'.concat(b,'"');return o.push("".concat(l).concat(I)),o},[])},pt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=gt(t,r,n,a);if(i.length===0)return"";var o=i.join(" ");return" ".concat(o)},vt=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return Object.keys(t).map(function(r){return{_name:r,_content:t[r]}})},bt=function(t){return lt.includes(S(t))},yt=function(t){return!t.match("<")},ht=function(t){var r=t.header,n=t.isOutputStart,a=r&&n;if(!a)return"";var i=d(r)===u.BOOLEAN;return i?dt:r},U={"<":"&lt;",">":"&gt;","&":"&amp;",'"':"&quot;"},Ot=p.toXML=function e(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=r.depth,a=n===void 0?0:n,i=r.indent,o=r._isFirstItem,c=r._isOutputStart,l=c===void 0?!0:c,m=r.header,v=r.attributeReplacements,b=v===void 0?{}:v,I=r.attributeFilter,X=r.attributeExplicitTrue,At=X===void 0?!1:X,x=r.contentReplacements,L=x===void 0?{}:x,H=r.contentMap,$=r.selfCloseTags,Tt=$===void 0?!0:$,St=typeof b=="boolean"&&!b,_t=St?{}:f(f({},U),b),jt=typeof L=="boolean"&&!L,Et=jt?{}:f(f({},U),L),k=typeof i=="string",C=mt(i,a),Rt=S(t),Y=ht({header:m,isOutputStart:l}),_=l&&!Y&&o&&a===0,K=k&&!_?`
`:"",g="";switch(Rt){case u.JSTOXML_OBJECT:{var y=t._name,h=t._content;if(h===null&&typeof H!="function"){g="".concat(K).concat(C).concat(y);break}var It=Array.isArray(h)&&h.every(bt);if(It){var Lt=h.map(function(s){return e({_name:y,_content:s},f(f({},r),{},{depth:a,_isOutputStart:!1}))});return Lt.join("")}if(B.includes(y))break;var O=e(h,f(f({},r),{},{depth:a+1,_isOutputStart:_})),Ct=S(O),Pt=yt(O),wt=J(O),q="".concat(K).concat(C);if(y==="_comment"){g+="".concat(q,"<!-- ").concat(h," -->");break}var G=Ct==="undefined"||O==="",Mt=Tt,W=t._selfCloseTag,V=d(W)===u.BOOLEAN?G&&W:G&&Mt,Nt=V?"/":"",Dt=pt(t._attrs,_t,I,At),Bt="<".concat(y).concat(Dt).concat(Nt,">"),Jt=k&&!Pt&&!wt?`
`.concat(C):"",Ft=V?"":"".concat(O).concat(Jt,"</").concat(y,">");g+="".concat(q).concat(Bt).concat(Ft);break}case u.OBJECT:{var z=Object.keys(t),Ut=z.map(function(s,A){var P=f(f({},r),{},{_isFirstItem:A===0,_isLastItem:A+1===z.length,_isOutputStart:_}),T={_name:s};if(S(t[s])===u.OBJECT){B.forEach(function(w){var Z=t[s][w];typeof Z<"u"&&(T[w]=Z,delete t[s][w])});var Ht=typeof t[s]._content<"u";if(Ht&&Object.keys(t[s]).length>1){var Q=Object.assign({},t[s]);delete Q._content,T._content=[].concat(E(vt(Q)),[t[s]._content])}}typeof T._content>"u"&&(T._content=t[s]);var $t=e(T,P);return $t},r);g=Ut.join("");break}case u.FUNCTION:{var Xt=t(r);g=e(Xt,r);break}case u.ARRAY:{var xt=t.map(function(s,A){var P=f(f({},r),{},{_isFirstItem:A===0,_isLastItem:A+1===t.length,_isOutputStart:_});return e(s,P)});g=xt.join("");break}default:{g=F(t,Et,H);break}}return"".concat(Y).concat(g)};p.default={toXML:Ot}})}(j)),j}export{kt as r};
