/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@lightweightform/xml-serializer@4.13.4/bundles/lightweightform-xml-serializer.umd.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@lightweightform/core"),require("@lightweightform/storage"),require("xml-js")):"function"==typeof define&&define.amd?define("@lightweightform/xml-serializer",["exports","@angular/core","@lightweightform/core","@lightweightform/storage","xml-js"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).lightweightform=e.lightweightform||{},e.lightweightform["xml-serializer"]={}),e.ng.core,e.lightweightform.core,e.lightweightform.storage,e.xmlJs)}(this,(function(e,t,r,a,n){"use strict";function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=i(t),l=i(r),c=function(e,t){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},c(e,t)};Object.create;function u(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],a=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&a>=e.length&&(e=void 0),{value:e&&e[a++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var a,n,i=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(a=i.next()).done;)o.push(a.value)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return o}function f(e,t,r){if(r||2===arguments.length)for(var a,n=0,i=t.length;n<i;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}Object.create;var m={compact:!0,declarationKey:"/declaration",instructionKey:"/instruction",attributesKey:"/attributes",textKey:"/text",cdataKey:"/cdata",doctypeKey:"/doctype",commentKey:"/comment",parentKey:"/parent"},d="http://www.w3.org/2001/XMLSchema-instance";function b(e,t,r){if(void 0===e[t])throw new Error("Unknown namespace: "+t);var a=e[t];return a?a+":"+r:r}function p(e,t,r){return void 0!==e.xmlElementName?e.xmlElementName:r.elementNames&&void 0!==r.elementNames[t]?r.elementNames[t]:void 0}function v(e,t,r,n,i,o){return void 0!==r.xmlElementName?r.xmlElementName:o.elementNames&&void 0!==o.elementNames[n]?o.elementNames[n]:a.isListSchema(t)?e+o.listElementSuffix:a.isMapSchema(t)?e+o.mapValueSuffix:a.isTableSchema(t)?e+o.tableRowSuffix:a.isRecordSchema(t)?""+i:e+i}function y(e,t){return e.xmlKeyAttributeName||t.mapValueKeyAttributeName}function h(e,t,r,a,i,o){var l={};o.emitDeclaration&&(l["/declaration"]={"/attributes":{version:o.declarationVersion,encoding:o.declarationEncoding,standalone:o.declarationStandalone}});var c,u=Object.assign({},o.namespaces),s=g(e,t,r,a,i,u,o);if(void 0!==s){var f=s["/attributes"]||{};s["/attributes"]=Object.assign((c=u,Object.keys(c).reduce((function(e,t){return e["xmlns"+(c[t]?":"+c[t]:"")]=t,e}),{})),f),l[t]=s}return n.js2xml(l,Object.assign(Object.assign({},m),{spaces:o.space,fullTagEmptyElement:!o.selfCloseEmptyElements}))}function g(e,t,n,i,o,l,c){var m,p,h;function S(e,r,a){return v(t,n,e,r,a,c)}function O(e,t,r,n,o){return g(e,t,r,a.appendToPath(i,o),n,l,c)}if(void 0!==e){h={};var x=function(e,t,r,a,n){var i,o,l,c,s;try{for(var f=u([n.elementAttributes&&n.elementAttributes[a],t.xmlElementAttributes]),m=f.next();!m.done;m=f.next()){var d=m.value;try{for(var b=(l=void 0,u(Object.keys(d||{}))),p=b.next();!p.done;p=b.next()){var v=p.value,y=d[v];if("string"==typeof y)(s||(s={}))[v]=y;else if("function"==typeof y||y.serialize){var h="function"==typeof y?y:y.serialize;(s||(s={}))[v]=h(e,t,r)}}}catch(e){l={error:e}}finally{try{p&&!p.done&&(c=b.return)&&c.call(b)}finally{if(l)throw l.error}}}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}return s}(e,n,i,o,c);if(x&&(h["/attributes"]=x),null===e){if("nilAttribute"===c.nullValueRepresentation)!function(e,t,r){if(void 0===e[t]){var a=Object.keys(e).reduce((function(t,r){return t[e[r]]=r,t}),{});if(void 0===a[r])e[t]=r;else for(var n=2;;++n)if(void 0===a[r+n]){e[t]=r+n;break}}}(l,d,"xsi"),(h["/attributes"]||(h["/attributes"]={}))[b(l,d,"nil")]="true"}else if(a.isSimpleSchema(n)){var w=function(e,t,a,n){var i,o,l=e;try{for(var c=u(f(f([],s(r.arrayfy(n.simpleTransform))),[t.xmlSimpleTransform])),m=c.next();!m.done;m=c.next()){var d=m.value,b=d&&d.serialize&&d.serialize(l,t,a);void 0!==b&&(l=b)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}return l}(e,n,i,c);e===w&&(w=a.isDateSchema(n)?e.toISOString():e.toString()),w&&(h["/text"]=w)}else if(a.isListSchema(n)||a.isTableSchema(n)){var j=a.isListSchema(n)?n.elementsSchema:n.rowsSchema,E=a.appendToPath(o,a.PATH_ID_PLACEHOLDER),P=S(j,E),T=e.reduce((function(e,t,r){var a=O(t,P,j,E,r);return void 0!==a&&e.push(a),e}),[]);T.length>0&&(h[P]=T)}else if(a.isMapSchema(n)){var A=n.valuesSchema,_=a.appendToPath(o,a.PATH_ID_PLACEHOLDER),N=S(A,_);T=Array.from(e.entries()).reduce((function(e,t){var r=s(t,2),a=r[0],i=O(r[1],N,A,_,a);void 0!==i&&((i["/attributes"]||(i["/attributes"]={}))[y(n,c)]=a,e.push(i));return e}),[]);T.length>0&&(h[N]=T)}else{var L=a.isRecordSchema(n)?n.fieldsSchemas:n.elementsSchemas;try{for(var R=u(Object.keys(L)),V=R.next();!V.done;V=R.next()){var D=V.value,I=L[D],C=a.appendToPath(o,D),z=S(I,C,D);if(!a.isClientOnlySchema(I)){var M=O(e[D],z,I,C,D);void 0!==M&&(h[z]=M)}}}catch(e){m={error:e}}finally{try{V&&!V.done&&(p=R.return)&&p.call(R)}finally{if(m)throw m.error}}}}return h=function(e,t,a,n){var i,o;try{for(var l=u(f(f([],s(r.arrayfy(n.transform))),[t.xmlTransform])),c=l.next();!c.done;c=l.next()){var m=c.value,d=m&&m.serialize;d&&(e=d(e,t,a))}}catch(e){i={error:e}}finally{try{c&&!c.done&&(o=l.return)&&o.call(l)}finally{if(i)throw i.error}}return e}(h,n,i,c),h}function S(e,t,r,a,i,o){var l,c=n.xml2js(e,Object.assign(Object.assign({},m),{trim:o.trim}))[t];return O(c,t,r,a,i,void 0===c?{}:(l=c["/attributes"]||{},Object.keys(l).reduce((function(e,t){return"xmlns"===t?e[l[t]]="":t.startsWith("xmlns:")&&(e[l[t]]=t.slice(6)),e}),{})),o)}function O(e,t,n,i,o,l,c){function m(e,r,a){return v(t,n,e,r,a,c)}function p(e,t,r,n,o){return O(e,t,r,a.appendToPath(i,o),n,l,c)}var h;if(e=function(e,t,a,n){var i,o;try{for(var l=u(f([t.xmlTransform],s(r.arrayfy(n.transform).reverse()))),c=l.next();!c.done;c=l.next()){var m=c.value,d=m&&m.deserialize;d&&(e=d(e,t,a))}}catch(e){i={error:e}}finally{try{c&&!c.done&&(o=l.return)&&o.call(l)}finally{if(i)throw i.error}}return e}(e,n,i,c),void 0!==e){if(a.isNullableSchema(n)&&("nilAttribute"===c.nullValueRepresentation&&l[d]&&e["/attributes"]&&"true"===e["/attributes"][b(l,d,"nil")]||"emptyElement"===c.nullValueRepresentation&&function(e){return!e["/text"]&&Object.keys(e).every((function(e){return"/"===e[0]}))}(e)))h=null;else if(a.isSimpleSchema(n)){var g=e["/text"]||"",S=function(e,t,a,n){var i,o,l=e;try{for(var c=u(f([t.xmlSimpleTransform],s(r.arrayfy(n.simpleTransform).reverse()))),m=c.next();!m.done;m=c.next()){var d=m.value,b=d&&d.deserialize&&d.deserialize(l,t,a);void 0!==b&&(l=b)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(o=c.return)&&o.call(c)}finally{if(i)throw i.error}}return l}(g,n,i,c);g===S&&(S=a.isBooleanSchema(n)?"true"===g||"1"===g:a.isDateSchema(n)?new Date(g):a.isNumberSchema(n)?+g:g),h=S}else if(a.isListSchema(n)||a.isTableSchema(n)){for(var x=a.isListSchema(n)?n.elementsSchema:n.rowsSchema,w=a.appendToPath(o,a.PATH_ID_PLACEHOLDER),j=m(x,w),E=r.arrayfy(e[j]),P=0;P<E.length;++P)E[P]=p(E[P],j,x,w,P);h=E}else if(a.isMapSchema(n)){var T=n.valuesSchema,A=a.appendToPath(o,a.PATH_ID_PLACEHOLDER),_=m(T,A);h=new Map(r.arrayfy(e[_]).map((function(e){var t=e["/attributes"][y(n,c)];return[t,p(e,_,T,A,t)]})))}else{var N=a.isRecordSchema(n)?n.fieldsSchemas:n.elementsSchemas;h=Object.keys(N).reduce((function(t,r){var i=N[r],l=a.appendToPath(o,r),c=m(i,l,r);return a.isClientOnlySchema(i)?a.isTupleSchema(n)&&(t[r]=void 0):t[r]=p(e[c],c,i,l,r),t}),a.isRecordSchema(n)?{}:[])}!function(e,t,r,a,n,i){var o,l,c,s;try{for(var f=u([r.xmlElementAttributes,i.elementAttributes&&i.elementAttributes[n]]),m=f.next();!m.done;m=f.next()){var d=m.value;try{for(var b=(c=void 0,u(Object.keys(d||{}))),p=b.next();!p.done;p=b.next()){var v=p.value,y=d[v];"object"==typeof y&&y.deserialize&&y.deserialize(e,t[v],r,a)}}catch(e){c={error:e}}finally{try{p&&!p.done&&(s=b.return)&&s.call(b)}finally{if(c)throw c.error}}}}catch(e){o={error:e}}finally{try{m&&!m.done&&(l=f.return)&&l.call(f)}finally{if(o)throw o.error}}}(h,e["/attributes"]||{},n,i,o,c)}return h}var x=new t.InjectionToken("LF_XML_SERIALIZER_OPTIONS"),w=function(e){function t(t,r){var a=e.call(this)||this;return Object.defineProperty(a,"lfStorage",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"charset",{enumerable:!0,configurable:!0,writable:!0,value:"utf-8"}),Object.defineProperty(a,"mimeType",{enumerable:!0,configurable:!0,writable:!0,value:"application/xml"}),Object.defineProperty(a,"accept",{enumerable:!0,configurable:!0,writable:!0,value:".xml,.txt,application/xml,text/plain"}),Object.defineProperty(a,"extension",{enumerable:!0,configurable:!0,writable:!0,value:"xml"}),Object.defineProperty(a,"autoBOM",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(a,"encode",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"space",{enumerable:!0,configurable:!0,writable:!0,value:"production"===process.env.NODE_ENV?0:"\t"}),Object.defineProperty(a,"trim",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(a,"emitDeclaration",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(a,"declarationVersion",{enumerable:!0,configurable:!0,writable:!0,value:"1.0"}),Object.defineProperty(a,"declarationEncoding",{enumerable:!0,configurable:!0,writable:!0,value:a.charset.toUpperCase()}),Object.defineProperty(a,"declarationStandalone",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"simpleTransform",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"transform",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"nullValueRepresentation",{enumerable:!0,configurable:!0,writable:!0,value:"nilAttribute"}),Object.defineProperty(a,"elementNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"elementAttributes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"namespaces",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"listElementSuffix",{enumerable:!0,configurable:!0,writable:!0,value:"Element"}),Object.defineProperty(a,"mapValueSuffix",{enumerable:!0,configurable:!0,writable:!0,value:"Value"}),Object.defineProperty(a,"tableRowSuffix",{enumerable:!0,configurable:!0,writable:!0,value:"Row"}),Object.defineProperty(a,"mapValueKeyAttributeName",{enumerable:!0,configurable:!0,writable:!0,value:"key"}),Object.defineProperty(a,"selfCloseEmptyElements",{enumerable:!0,configurable:!0,writable:!0,value:!0}),t&&a.setOptions(t),a}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.setOptions=function(e){void 0!==e.charset&&(this.charset=e.charset),void 0!==e.autoBOM&&(this.autoBOM=e.autoBOM),void 0!==e.encode&&(this.encode=e.encode),void 0!==e.space&&(this.space=e.space),void 0!==e.trim&&(this.trim=e.trim),void 0!==e.emitDeclaration&&(this.emitDeclaration=e.emitDeclaration),void 0!==e.declarationVersion&&(this.declarationVersion=e.declarationVersion),(void 0!==e.charset||void 0!==e.declarationEncoding)&&(this.declarationEncoding=void 0===e.declarationEncoding?e.charset.toUpperCase():e.declarationEncoding),void 0!==e.declarationStandalone&&(this.declarationStandalone=e.declarationStandalone),void 0!==e.simpleTransform&&(this.simpleTransform=e.simpleTransform),void 0!==e.transform&&(this.transform=e.transform),void 0!==e.nullValueRepresentation&&(this.nullValueRepresentation=e.nullValueRepresentation),void 0!==e.elementNames&&(this.elementNames=e.elementNames),void 0!==e.elementAttributes&&(this.elementAttributes=e.elementAttributes),void 0!==e.namespaces&&(this.namespaces=e.namespaces),void 0!==e.listElementSuffix&&(this.listElementSuffix=e.listElementSuffix),void 0!==e.mapValueSuffix&&(this.mapValueSuffix=e.mapValueSuffix),void 0!==e.tableRowSuffix&&(this.tableRowSuffix=e.tableRowSuffix),void 0!==e.mapValueKeyAttributeName&&(this.mapValueKeyAttributeName=e.mapValueKeyAttributeName),void 0!==e.selfCloseEmptyElements&&(this.selfCloseEmptyElements=e.selfCloseEmptyElements)},t.prototype.serialize=function(e,t,r){var a=this.pathWithPlaceholders(r);return h(e,this.elementName(t,a),t,r,a,this)},t.prototype.deserialize=function(e,t,r){var a=this.pathWithPlaceholders(r);return S(e,this.elementName(t,a),t,r,a,this)},t.prototype.pathWithPlaceholders=function(e){for(var t=this.lfStorage.pathInfo(e),r="/",n=1,i=t.length;n<i;++n)r=a.appendToPath(r,a.isCollectionSchema(t[n-1].schema)?a.PATH_ID_PLACEHOLDER:t[n].id);return r},t.prototype.elementName=function(e,t){var r=p(e,t,this);if(void 0!==r)return r;for(var a=this.lfStorage.pathInfo(t),n=a[0].schema,i=p(n,"/",this),o=void 0===i?"app":i,l=1,c=a.length;l<c;++l){var u=a[l],s=u.schema,f=u.id;o=v(o,n,s,u.path,f,this),n=s}return o},t}(r.LfSerializer);Object.defineProperty(w,"ɵfac",{enumerable:!0,configurable:!0,writable:!0,value:o.ɵɵngDeclareFactory({minVersion:"12.0.0",version:"12.2.16",ngImport:o,type:w,deps:[{token:x,optional:!0},{token:l.LfStorage}],target:o.ɵɵFactoryTarget.Injectable})}),Object.defineProperty(w,"ɵprov",{enumerable:!0,configurable:!0,writable:!0,value:o.ɵɵngDeclareInjectable({minVersion:"12.0.0",version:"12.2.16",ngImport:o,type:w})}),o.ɵɵngDeclareClassMetadata({minVersion:"12.0.0",version:"12.2.16",ngImport:o,type:w,decorators:[{type:t.Injectable}],ctorParameters:function(){return[{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[x]}]},{type:l.LfStorage}]}}),e.DEFAULT_ROOT_XML_ELEMENT_NAME="app",e.LF_XML_SERIALIZER_OPTIONS=x,e.LfXmlSerializer=w,e.libCollectionChildren=function(e){if(Array.isArray(e))return e;var t=Object.keys(e).find((function(e){return"/"!==e[0]}));return t?e[t]:[]},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=/sm/301e01dd2d95ee93c5135e1deb5a852f06baffeac11c2e4c3e664677972cf891.map