UNPKG

@gelight/xml2sml

Version:

XML2SML - The XML to SML converters

1 lines 36.4 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.XML2SML=t():e.XML2SML=t()}(self,(function(){return(()=>{var e={514:function(e,t,n){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,n,s){void 0===s&&(s=n),Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,s){void 0===s&&(s=n),e[s]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&s(t,e,n);return r(t,e),t},a=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function a(e){try{o(s.next(e))}catch(e){i(e)}}function u(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}o((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const u=n(64),o=i(n(759));t.default=class{static convert(e,t){return a(this,void 0,void 0,(function*(){return new Promise(((n,s)=>{n(u.Converter.convert(o.parseString(e,t)))}))}))}}},561:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Converter=void 0;const r=s(n(514));t.Converter=r.default},64:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Converter=void 0;const r=s(n(696));t.Converter=r.default},696:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(43),i=s(n(863));class a{static convert(e){const t=new r.SmlElement("SML"),n=new r.SmlDocument(t),s=new i.default;return 1===s.case?(n.setEndKeyword("end"),t.name="sml"):2===s.case&&n.setEndKeyword("END"),1===n.getRoot().nodes.length&&n.getRoot().nodes[0]instanceof r.SmlElement&&n.setRoot(n.getRoot().nodes[0]),a.convertObj(e,t,s),n}static convertObj(e,t,n){if(a.isValue(e))t.add(new r.SmlAttribute("Value",[String(e)]));else if(a.isSimpleArray(e))t.addAttribute("Value",a.getSimpleArrayValues(e));else if(a.isSimpleMatrix(e))t.addAttribute("Value",a.getSimpleMatrixValues(e));else if(a.isComplexArray(e)){const s=a.getItemName(null);a.convertComplexArray(e,t,s,n)}else a.isObject(e)&&a.convertObjProperties(e,t,n)}static convertObjProperties(e,t,n){const s=Object.keys(e);for(const i of s){n.scan(i);const s=e[i];if(a.isValue(s))t.add(new r.SmlAttribute(i,[s]));else if(a.isSimpleArray(s))t.addAttribute(i,a.getSimpleArrayValues(s));else if(a.isSimpleMatrix(s))t.addAttribute(i,a.getSimpleMatrixValues(s));else if(a.isComplexArray(s)){const e=t.addElement(i),r=a.getItemName(i);a.convertComplexArray(s,e,r,n)}else if(a.isObject(s)){const e=t.addElement(i);a.convertObjProperties(s,e,n)}}}static convertComplexArray(e,t,n,s){for(const i of e)if(a.isValue(i))t.add(new r.SmlAttribute(n,[i]));else if(a.isSimpleArray(i))t.addAttribute(n,a.getSimpleArrayValues(i));else if(a.isSimpleMatrix(i))t.addAttribute(n,a.getSimpleMatrixValues(i));else{const e=t.addElement(n);a.convertObj(i,e,s)}}static replaceLast(e,t,n){return e.substring(0,e.length-t)+n}static getItemName(e){if(null!=e&&e.length>0){if(e.endsWith("IES"))return a.replaceLast(e,3,"Y");if(e.endsWith("ies"))return a.replaceLast(e,3,"y");if(e.endsWith("S"))return a.replaceLast(e,1,"");if(e.endsWith("s"))return a.replaceLast(e,1,"")}return"item"}static getSimpleArrayValues(e){return 0===e.length?[null]:e.map((e=>a.valueToString(e)))}static getSimpleMatrixValues(e){const t=[];for(const n of e)if(a.isValue(n))t.push(a.valueToString(n));else{const e=a.getSimpleArrayValues(n);t.push(...e)}return t}static valueToString(e){return null===e?null:String(e)}static isValue(e){return null===e||"number"==typeof e||"string"==typeof e||"boolean"==typeof e}static isSimpleArray(e){if(!Array.isArray(e))return!1;for(const t of e)if(!a.isValue(t))return!1;return!0}static isSimpleMatrix(e){if(!Array.isArray(e))return!1;for(const t of e)if(!a.isSimpleArray(t))return!1;const t=e[0].length;for(const n of e)if(n.length!==t)return!1;return!0}static isComplexArray(e){return Array.isArray(e)&&!a.isSimpleArray(e)}static isObject(e){return null!=e&&!Array.isArray(e)&&"object"==typeof e}}t.default=a},863:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){this.case=0,this.alreadySet=!1}scan(e){if(!this.alreadySet){try{if(e.startsWith("2"))return this.alreadySet=!0,void(this.case=0);e===e.toUpperCase()?this.case=2:e[0]===e[0].toLowerCase()&&(this.case=1)}catch(e){}this.alreadySet=!0}}}},607:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends TypeError{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,n)}}t.default=n},810:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TypeGuard=t.NULLABLE_VALUE=t.NULLABLE=void 0;const r=s(n(607));t.NULLABLE="NULLABLE",t.NULLABLE_VALUE="NULLABLE_VALUE";class i{static assureBoolean(e,n=[]){if(n.includes(t.NULLABLE)&&null===e)return e;if("boolean"!=typeof e)throw new r.default(`The argument of the type '${typeof e}' must be a 'boolean'`);return e}static assureString(e,n=[]){if(n.includes(t.NULLABLE)&&null===e)return e;if("string"!=typeof e)throw new r.default(`The argument of the type '${typeof e}' must be an 'string'`);return e}static assureNumber(e,n=[]){if(n.includes(t.NULLABLE)&&null===e)return e;if(!Number.isInteger(e))throw new r.default(`The argument of the type '${typeof e}' must be an 'number'`);return e}static assureArray(e,n=[]){if(n.includes(t.NULLABLE)&&null===e)return e;if(!Array.isArray(e))throw new r.default("The argument type must be an 'array'");return e}static assureStringArray(e,n=[]){if(n.includes(t.NULLABLE)&&null===e)return e;if(!Array.isArray(e))throw new r.default(`The argument of the type '${typeof e}' must be an 'string array'`);for(const s of e)n.includes(t.NULLABLE_VALUE)?i.assureString(s,[t.NULLABLE]):i.assureString(s);return e}static assureNumberArray(e,n=[]){if(n.includes(t.NULLABLE)&&null===e)return e;if(!Array.isArray(e))throw new r.default(`The argument of the type '${typeof e}' must be an 'number array'`);for(const s of e)n.includes(t.NULLABLE_VALUE)?i.assureNumber(s,[t.NULLABLE]):i.assureNumber(s);return e}static assureInstanceOf(e,n,s=[]){if(s.includes(t.NULLABLE)&&null===e)return e;if(!(e instanceof n))throw new r.default(`The argument of the type '${typeof e}' must be an array of '${n}'`);return e}static assureArrayOfInstance(e,n,s=[]){if(s.includes(t.NULLABLE)&&null===e)return e;if(!Array.isArray(e))throw new r.default(`The argument of the type '${typeof e}' must be an instance of ${n}`);for(const r of e)s.includes(t.NULLABLE_VALUE)?i.assureInstanceOf(r,n,[t.NULLABLE]):i.assureInstanceOf(r,n);return e}}t.TypeGuard=i},43:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StringUtil=t.WsvParserException=t.WsvLine=t.WsvDocumentServer=t.WsvDocument=t.WsvChar=t.SmlRequest=t.SmlParserException=t.SmlNode=t.SmlNamedNode=t.SmlEmptyNode=t.SmlElement=t.SmlDocumentServer=t.SmlDocument=t.SmlAttribute=t.ReliableTxtFile=t.ReliableTxtException=t.ReliableTxtEncoding=t.ReliableTxtDocumentServer=t.ReliableTxtDocument=void 0;const r=s(n(51));t.ReliableTxtDocument=r.default;const i=s(n(721));t.ReliableTxtDocumentServer=i.default;const a=s(n(500));t.ReliableTxtEncoding=a.default;const u=s(n(492));t.ReliableTxtException=u.default;const o=s(n(452));t.ReliableTxtFile=o.default;const l=s(n(657));t.WsvChar=l.default;const d=s(n(782));t.WsvDocument=d.default;const c=s(n(544));t.WsvDocumentServer=c.default;const f=s(n(304));t.WsvLine=f.default;const h=s(n(334));t.WsvParserException=h.default;const p=s(n(355));t.SmlAttribute=p.default;const m=s(n(771));t.SmlDocument=m.default;const g=s(n(588));t.SmlDocumentServer=g.default;const y=s(n(597));t.SmlElement=y.default;const v=s(n(41));t.SmlEmptyNode=v.default;const _=s(n(555));t.SmlNamedNode=_.default;const E=s(n(899));t.SmlNode=E.default;const S=s(n(264));t.SmlParserException=S.default;const L=s(n(794));t.SmlRequest=L.default;const b=s(n(223));t.StringUtil=b.default},51:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(223)),i=n(810);class a{constructor(...e){return this.text="",i.TypeGuard.assureStringArray(e,[i.NULLABLE]),this.text=e.join("\n"),this}static join(e){return i.TypeGuard.assureStringArray(e,[i.NULLABLE]),new a(...e).toString()}setText(e){i.TypeGuard.assureString(e,[i.NULLABLE]),null!=e&&(this.text=e)}setTextByCodePoints(e){i.TypeGuard.assureNumberArray(e,[i.NULLABLE]),null!=e&&Array.isArray(e)&&(this.text=r.default.codePointsToString(e))}getText(){return this.text}getTextAsCodePoints(){return r.default.stringToCodePoints(this.text)}setLines(...e){i.TypeGuard.assureStringArray(e,[i.NULLABLE]),this.text=e.join("\n")}getLines(){return this.text.split("\n")}toString(){return this.text}}t.default=a},721:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(51)),i=s(n(500)),a=s(n(452));class u extends r.default{constructor(...e){return super(...e),this.encoding=i.default.UTF8,this}static load(e){const t=(new a.default).load(e),n=new u(t.getContent());return n.setEncoding(t.getEncoding()),n}setEncoding(e){return this.encoding=e,this}getEncoding(){return this.encoding}save(e){return new a.default(this.encoding).save(e,this.text),this}}t.default=u},500:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.UTF8="utf8",e.UTF16_REVERSED="utf16le"}(n||(n={})),t.default=n},492:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,n)}}t.default=n},452:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=n(862),i=s(n(500)),a=s(n(492));class u{constructor(e){return this.fileContent="",this.encoding=i.default.UTF8,this.setEncoding(e),this}static getEncodingFromBuffer(e){if(e.length<2)return null;const t=e.readInt8(0),n=e.readInt8(1);return-1===t&&-2===n?i.default.UTF16_REVERSED:-17===t&&-69===n&&e.length>=3&&-65===e.readInt8(2)?i.default.UTF8:null}save(e,t,n){this.setEncoding(n);try{(0,r.writeFileSync)(e,"\ufeff"+t,this.encoding)}catch(e){console.error(e)}return this}load(e){try{const t=(0,r.readFileSync)(e,Object.assign({flag:"r"})),n=u.getEncodingFromBuffer(t);if(null===n)throw new a.default("Document does not have a ReliableTXT preamble");this.setEncoding(n);const s=(0,r.readFileSync)(e,Object.assign({encoding:this.encoding,flag:"r"})).toString();return this.fileContent=s.slice(1),this}catch(e){throw Error(e.message)}}getEncoding(){return this.encoding}getContent(){return this.fileContent}setEncoding(e){return e&&(this.encoding=e),this}}t.default=u},355:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(555)),i=s(n(650));class a extends r.default{constructor(e,t){super(e),this.values=[],this.setValues(...t.map(String))}setValues(...e){if(null===e||0===e.length)throw new Error("Values must contain at least one value");this.values=e.map(String)}getValues(e){return e?this.values.slice(e):this.values}getNumberValues(e){return e?this.values.slice(e).map(Number):this.values.map(Number)}getString(e){return e?this.values[e]:this.values[0]}setString(e){this.values=[e]}toString(){return i.default.serializeAttribute(this)}toWsvLines(e,t,n,s){i.default.serializeAttributeInternal(this,e,t,n)}}t.default=a},771:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(223)),i=s(n(211)),a=s(n(650));class u{constructor(e){this.emptyNodesBefore=[],this.emptyNodesAfter=[],this.endKeyword="End",this.defaultIndentation=null,e&&(this.root=e)}static parse(e){const t=new u;return i.default.parseDocument(e,t)}setEndKeyword(e){this.endKeyword=e}getEndKeyword(){return this.endKeyword}setDefaultIndentation(e){if(!r.default.isWhitespaceOrEmpty(e))throw Error("Invalid indentation");this.defaultIndentation=e}getDefaultIndentation(){return this.defaultIndentation}getRoot(){return this.root}setRoot(e){this.root=e}toString(){return a.default.serializeDocument(this)}}t.default=u},588:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(721)),i=s(n(500)),a=s(n(771)),u=s(n(211));class o extends a.default{constructor(e){return super(e),this.encoding=i.default.UTF8,this}static parse(e){const t=new o;return u.default.parseDocument(e,t)}static load(e){const t=r.default.load(e),n=o.parse(t.getText());return n.setEncoding(t.getEncoding()),n}setEncoding(e){return this.encoding=e,this}getEncoding(){return this.encoding}save(e){return new r.default(this.toString()).setEncoding(this.getEncoding()).save(e),this}}t.default=o},597:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(355)),i=s(n(41)),a=s(n(555)),u=s(n(650)),o=s(n(304));class l extends a.default{constructor(e){super(e),this.nodes=[],this.endComment=null}setEndWhitespaces(...e){o.default.validateWhitespaces(e),this.endWhitespaces=e}getEndWhitespaces(){return this.endWhitespaces?[...this.endWhitespaces]:null}setEndComment(e){o.default.validateComment(e),this.endComment=e}getEndComment(){return this.endComment}setEndWhitespacesAndComment(e,t){this.endWhitespaces=e,this.endComment=t}add(e){return this.nodes.push(e),e}addAttribute(e,t){const n=t.map(String),s=new r.default(e,n);return this.add(s),s}addElement(e){const t=new l(e);return this.add(t),t}addEmptyNode(){const e=new i.default;return this.add(e),e}hasAttribute(e){return this.nodes.filter((e=>e instanceof r.default)).map((e=>e)).filter((t=>t.hasName(e))).length>0}getAttribute(e){const t=this.nodes.filter((e=>e instanceof r.default)).map((e=>e)).filter((t=>t.hasName(e))).shift();if(!t)throw Error(`No attribute with name '${e}'`);return t}getAttributes(e){let t=[];return t=e?this.nodes.filter((e=>e instanceof r.default)).map((e=>e)).filter((t=>t.hasName(e))):this.nodes.filter((e=>e instanceof r.default)).map((e=>e)),t}hasElement(e){return this.nodes.filter((e=>e instanceof l)).map((e=>e)).filter((t=>t.hasName(e))).length>0}getElement(e){const t=this.nodes.filter((e=>e instanceof l)).map((e=>e)).filter((t=>t.hasName(e))).shift();if(!t)throw Error(`No element with name '${e}'`);return t}getElements(e){let t=[];return t=e?this.nodes.filter((e=>e instanceof l)).map((e=>e)).filter((t=>t.hasName(e))):this.nodes.filter((e=>e instanceof l)).map((e=>e)),t}getBoolean(e){return Boolean(this.getAttribute(e).getString())}getNumber(e){return Number(this.getAttribute(e).getString())}getString(e){return this.getAttribute(e).getString()}getStringValues(e){return this.getAttribute(e).getValues()}getNumberValues(e){return this.getAttribute(e).getNumberValues()}toString(){return u.default.serializeElement(this)}toWsvLines(e,t,n,s){u.default.serializeElementInternal(this,e,t,n,s)}}t.default=l},41:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(899)),i=s(n(650));class a extends r.default{constructor(){super()}toString(){return i.default.serializeEmptyNode(this)}toWsvLines(e,t,n,s){i.default.serializeEmptyNodeInternal(this,e,t,n)}}t.default=a},555:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(223)),i=s(n(899));class a extends i.default{constructor(e){super(),this.name=e}hasName(e){return r.default.equalsIgnoreCase(this.name,e)}}t.default=a},899:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(304));t.default=class{constructor(){this.whitespaces=null,this.comment=null}setWhitespaces(...e){r.default.validateWhitespaces(e),this.whitespaces=e}getWhitespaces(){return this.whitespaces?[...this.whitespaces]:null}setComment(e){r.default.validateComment(e),this.comment=e}getComment(){return this.comment}setWhitespacesAndComment(e,t){this.whitespaces=e,this.comment=t}toWsvLines(e,t,n,s){}}},211:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(782)),i=s(n(635)),a=s(n(355)),u=s(n(597)),o=s(n(41)),l=s(n(264)),d=s(n(223));class c{static parseDocument(e,t){const n=r.default.parse(e),s=c.getEndKeyword(n),a=new i.default(n,s);t.setEndKeyword(s);const u=c.readRootElement(a,t.emptyNodesBefore);return t.setRoot(u),c.readElementContent(a,u),c.readEmptyNodes(t.emptyNodesAfter,a),t}static readRootElement(e,t){if(c.readEmptyNodes(t,e),!e.hasLine())throw new l.default("Root element expected");const n=e.getLine();if(!n.hasValues()||1!==n.getValues().length||d.default.equalsIgnoreCase(n.getValues()[0],e.getEndKeyword()))throw new l.default("Invalid root element start");const s=n.getValues()[0],r=new u.default(s);return r.setWhitespacesAndComment(n.getWhitespaces(),n.getComment()),r}static readNode(e,t){let n;const s=e.getLine();if(s.hasValues()){const r=s.getValues()[0];if(d.default.equalsIgnoreCase(r,e.getEndKeyword())){if(s.getValues().length>1)throw new l.default("Attribute with end keyword name is not allowed");return t.setEndWhitespacesAndComment(s.getWhitespaces(),s.getComment()),null}if(1===s.getValues().length){const t=new u.default(r);t.setWhitespacesAndComment(s.getWhitespaces(),s.getComment()),this.readElementContent(e,t),n=t}else{const e=s.getValues().slice(1),t=new a.default(r,e);t.setWhitespacesAndComment(s.getWhitespaces(),s.getComment()),n=t}}else{const e=new o.default;e.setWhitespacesAndComment(s.getWhitespaces(),s.getComment()),n=e}return n}static readElementContent(e,t){for(;;){if(!e.hasLine())throw new l.default("Element not closed");const n=c.readNode(e,t);if(null==n)break;t.add(n)}}static readEmptyNodes(e,t){for(;t.isEmptyLine();){const n=c.readEmptyNode(t);e.push(n)}}static readEmptyNode(e){const t=e.getLine(),n=new o.default;return n.setWhitespacesAndComment(t.getWhitespaces(),t.getComment()),n}static getEndKeyword(e){for(let t=e.getLines().length-1;t>=0;t--){const n=e.getLine(t).getValues();if(null!==n){if(1===n.length)return n[0];if(n.length>1)break}}throw new l.default("End keyword could not be detected")}}t.default=c},264:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e,...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,n),this.name="SmlParserException",this.message=`${e}`}}t.default=n},794:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(r,i){function a(e){try{o(s.next(e))}catch(e){i(e)}}function u(e){try{o(s.throw(e))}catch(e){i(e)}}function o(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}o((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),console.log("Experimental > SmlRequest: This feature is a work in progress. Don't depend on it yet. It may go through significant changes."),t.default=class{static get(e){return n(this,void 0,void 0,(function*(){return null}))}static post(e,t){return n(this,void 0,void 0,(function*(){return null}))}static delete(e){return n(this,void 0,void 0,(function*(){return null}))}static put(e,t){return n(this,void 0,void 0,(function*(){return null}))}static patch(e,t){return n(this,void 0,void 0,(function*(){return null}))}}},650:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(782));class i{static serializeDocument(e){const t=new r.default;return i.serialzeEmptyNodes(e.emptyNodesBefore,t),e.getRoot().toWsvLines(t,0,e.getDefaultIndentation(),e.getEndKeyword()),i.serialzeEmptyNodes(e.emptyNodesAfter,t),t.toString()}static serializeElement(e){const t=new r.default;return e.toWsvLines(t,0,null,"End"),t.toString()}static serializeAttribute(e){const t=new r.default;return e.toWsvLines(t,0,null,null),t.toString()}static serializeAttributeInternal(e,t,n,s){const r=i.getWhitespaces(e.getWhitespaces(),n,s),a=[e.name,...e.getValues()];t.addWsvLineBySet(a,r,e.getComment())}static serializeEmptyNode(e){const t=new r.default;return e.toWsvLines(t,0,null,null),t.toString()}static serializeEmptyNodeInternal(e,t,n,s){const r=i.getWhitespaces(e.getWhitespaces(),n,s);t.addWsvLineBySet(null,r,e.getComment())}static serializeElementInternal(e,t,n,s,r){const a=n+1,u=i.getWhitespaces(e.getWhitespaces(),n,s);t.addWsvLineBySet([e.name],u,e.getComment());for(const n of e.nodes)n.toWsvLines(t,a,s,r);const o=i.getWhitespaces(e.getEndWhitespaces(),n,s);t.addWsvLineBySet([r],o,e.getEndComment())}static getWhitespaces(e,t,n){return null!=e&&e.length>0?e:null==n?["\t".repeat(t)]:[n.repeat(t)]}static serialzeEmptyNodes(e,t){for(const n of e)n.toWsvLines(t,0,null,null)}}t.default=i},223:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(657)),i=n(810);class a{static isWhitespaceOrEmpty(e){const t=a.stringToCodePoints(e);for(const e of t)if(!r.default.isWhitespace(e))return!1;return!0}static getSubstr(e,t,n){return i.TypeGuard.assureNumberArray(e),i.TypeGuard.assureNumber(t),i.TypeGuard.assureNumber(n),e.slice(t,t+n).map((e=>String.fromCodePoint(e))).join("")}static stringToCodePoints(e){i.TypeGuard.assureString(e);const t=[];if(e)for(const n of e)t.push(n.codePointAt(0));return t}static codePointsToString(e){return i.TypeGuard.assureNumberArray(e),e.map((e=>String.fromCodePoint(e))).join("")}static equalsIgnoreCase(e,t){return i.TypeGuard.assureString(e),i.TypeGuard.assureString(t),"string"==typeof e&&"string"==typeof t?0===e.localeCompare(t,void 0,{sensitivity:"accent"}):e===t}}t.default=a,a.doubleQuote='"'.codePointAt(0),a.lineBreak="\n".codePointAt(0),a.slash="/".codePointAt(0),a.hash="#".codePointAt(0),a.minus="-".codePointAt(0)},841:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(223));t.default=class{constructor(){this.codePoints=[]}clear(){this.codePoints=[]}toString(){return r.default.codePointsToString(this.codePoints)}appendCodePoint(e){this.codePoints.push(e)}appendString(e){const t=r.default.stringToCodePoints(e);this.codePoints=[...this.codePoints,...t]}getLength(){return this.codePoints.length}}},657:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static isWhitespace(e){return e>=9&&e<=13||32===e||133===e||160===e||5760===e||e>=8192&&e<=8202||e>=8232&&e<=8233||8239===e||8287===e||12288===e}}},782:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(304)),i=s(n(851)),a=s(n(910));class u{constructor(){this.lines=[]}static parse(e){const t=new u;return i.default.parseDocument(e,t)}addWsvLines(...e){for(const t of e)this.lines.push(t);return this}addWsvLineByValues(...e){const t=new r.default;for(const n of e)t.addValue(n);return this.addWsvLines(t)}addWsvLineBySet(e,t,n){return this.addWsvLines((new r.default).set(e,t,n)),this}getLines(){return this.lines}getLine(e){return this.lines[e]}toArray(){const e=[];for(let t=0;t<this.lines.length;t++)e[t]=this.lines[t].getValues();return e}toString(){return a.default.serializeDocument(this)}}t.default=u},635:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(360));class i extends r.default{constructor(e,t){if(super(),this.index=0,null===t)throw Error("Endkeyword cannot be null");this.wsvDocument=e,this.endKeyword=t}getEndKeyword(){return this.endKeyword}hasLine(){return this.index<this.wsvDocument.getLines().length}isEmptyLine(){return this.hasLine()&&!this.wsvDocument.getLine(this.index).hasValues()}getLine(){const e=this.wsvDocument.getLine(this.index);return this.index++,e}toString(){let e="("+this.index+"): ";return this.hasLine()&&(e+=this.wsvDocument.getLine(this.index).toString()),e}}t.default=i},544:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(721)),i=s(n(500)),a=s(n(782)),u=s(n(851));class o extends a.default{constructor(){return super(),this.encoding=i.default.UTF8,this}static parse(e){const t=new o;return u.default.parseDocument(e,t)}static load(e){const t=r.default.load(e),n=o.parse(t.getText());return n.setEncoding(t.getEncoding()),n}setEncoding(e){return this.encoding=e,this}getEncoding(){return this.encoding}save(e){return new r.default(this.toString()).setEncoding(this.getEncoding()).save(e),this}}t.default=o},304:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(223)),i=s(n(841)),a=s(n(851)),u=s(n(910)),o=n(810);class l{constructor(...e){this.values=[],this.comment=null;for(const t of e)this.addValue(t);return this.whitespaces=null,this.comment=null,this}static parse(e){return a.default.parseLine(e)}static validateWhitespaces(e){if(o.TypeGuard.assureStringArray(e),null!==e)for(const t of e)if(null!==t&&!r.default.isWhitespaceOrEmpty(t))throw new Error("Whitespace value contains non whitespace character")}static validateComment(e){if(o.TypeGuard.assureString(e,[o.NULLABLE]),null!==e&&e.indexOf("\n")>=0)throw new Error("Line break in comment is not allowed")}addValue(e){o.TypeGuard.assureString(e,[o.NULLABLE]),this.values.push(e)}getValues(){return this.values}setValues(...e){o.TypeGuard.assureStringArray(e,[o.NULLABLE]),this.values=e}hasValues(){return null!==this.values&&this.values.length>0}setWhitespaces(e){l.validateWhitespaces(e),this.whitespaces=e}getWhitespaces(){return null===this.whitespaces?null:[...this.whitespaces]}setComment(e){return l.validateComment(e),this.comment=e,this}getComment(){return this.comment}set(e,t,n){return this.values=e,this.whitespaces=t,this.comment=n,this}toString(){const e=new i.default;return u.default.serializeLine(e,this),e.toString()}}t.default=l},360:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{constructor(){}hasLine(){return!1}isEmptyLine(){return!1}getLine(){return null}getEndKeyword(){return null}}},851:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(223)),i=s(n(304)),a=s(n(955)),u=s(n(334));class o{static parseLine(e){const t=new a.default(e),n=o.parseLineWithIterator(t);if(t.tryReadChar(r.default.lineBreak))throw new u.default(t,"Multiple WSV lines not allowed");if(!t.isEndOfText())throw new u.default(t,"WSV line not parsed completely");return n}static parseDocument(e,t){const n=new a.default(e);for(;;){const e=o.parseLineWithIterator(n);if(t.addWsvLines(e),n.isEndOfText())break;if(!n.tryReadChar(r.default.lineBreak))throw new u.default(n,"Invalid WSV document")}if(!n.isEndOfText())throw new u.default(n,"WSV document not parsed completely");return t}static parseLineWithIterator(e){const t=[],n=[];let s=e.readWhitespaceOrNull();for(n.push(s);!e.isChar(r.default.lineBreak)&&!e.isEndOfText();){let i="";if(e.isChar(r.default.hash))break;if(e.tryReadChar(r.default.doubleQuote)?i=e.readString():(i=e.readValue(),"-"===i&&(i=null)),t.push(i),s=e.readWhitespaceOrNull(),null==s)break;n.push(s)}let a=null;return e.tryReadChar(r.default.hash)&&(a=e.readCommentText(),null==s&&n.push(null)),(new i.default).set(t,n,a)}}t.default=o},955:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(223)),i=s(n(841)),a=s(n(657)),u=s(n(334));t.default=class{constructor(e){this.sb=new i.default,this.chars=[],this.index=0,this.chars=r.default.stringToCodePoints(e)}getText(){return r.default.codePointsToString(this.chars)}getLineInfoString(){const e=this.getLineInfo();return`(${e[1]+1}, ${e[2]+1})`}getLineInfo(){let e=0,t=0;for(let n=0;n<this.index;n++)this.chars[n]===r.default.lineBreak?(e++,t=0):t++;return[this.index,e,t]}isEndOfText(){return this.index>=this.chars.length}isChar(e){return!this.isEndOfText()&&this.chars[this.index]===e}tryReadChar(e){return!!this.isChar(e)&&(this.index++,!0)}readCommentText(){const e=this.index;for(;!this.isEndOfText()&&this.chars[this.index]!==r.default.lineBreak;)this.index++;return r.default.getSubstr(this.chars,e,this.index-e)}readWhitespaceOrNull(){const e=this.index;for(;!this.isEndOfText();){const e=this.chars[this.index];if(e===r.default.lineBreak)break;if(!a.default.isWhitespace(e))break;this.index++}return this.index===e?null:r.default.getSubstr(this.chars,e,this.index-e)}readString(){for(this.sb.clear();;){if(this.isEndOfText())throw new u.default(this,"String not closed");const e=this.chars[this.index];if(e===r.default.lineBreak)throw new u.default(this,"String not closed in starting line");if(e===r.default.doubleQuote)if(this.index++,this.tryReadChar(r.default.doubleQuote))this.sb.appendCodePoint(r.default.doubleQuote);else{if(!this.tryReadChar(r.default.slash))break;if(!this.tryReadChar(r.default.doubleQuote))throw new u.default(this,"String expected after linebreak slash");this.sb.appendCodePoint(r.default.lineBreak)}else this.sb.appendCodePoint(e),this.index++}return this.sb.toString()}readValue(){const e=this.index;for(;!this.isEndOfText();){const e=this.chars[this.index];if(a.default.isWhitespace(e)||e===r.default.hash)break;if(e===r.default.doubleQuote)throw new u.default(this,"String starting in value");this.index++}if(this.index===e)throw new u.default(this,"Invalid value");return r.default.getSubstr(this.chars,e,this.index-e)}}},334:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n extends Error{constructor(e,t){super(`${t} ${e.getLineInfoString()}`),Error.captureStackTrace&&Error.captureStackTrace(this,n);const s=e.getLineInfo();this.index=s[0],this.lineIndex=s[1],this.linePosition=s[2],this.text=e.getText()}}t.default=n},910:function(e,t,n){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=s(n(223)),i=s(n(841)),a=s(n(657));class u{static containsSpecialChars(e){const t=r.default.stringToCodePoints(e);for(const e of t)if(e===r.default.lineBreak||a.default.isWhitespace(e)||e===r.default.doubleQuote||e===r.default.hash)return!0;return!1}static serializeLine(e,t){null!==t.getWhitespaces()&&t.getWhitespaces().length>0?u.serializeValuesWithWhitespace(e,t):u.serializeValuesWithoutWhitespace(e,t),null!==t.getComment()&&(e.appendCodePoint(r.default.hash),e.appendString(t.getComment()))}static serializeDocument(e){const t=new i.default;let n=!0;for(const s of e.getLines())n?n=!1:t.appendCodePoint(r.default.lineBreak),u.serializeLine(t,s);return t.toString()}static serializeValue(e,t){if(null===t)e.appendString("-");else if(""===t)e.appendString('""');else if("-"===t)e.appendString('"-"');else if(u.containsSpecialChars(t)){e.appendCodePoint(r.default.doubleQuote);const n=r.default.stringToCodePoints(t);for(const t of n)t===r.default.lineBreak?e.appendString('"/"'):t===r.default.doubleQuote?e.appendString('""'):e.appendCodePoint(t);e.appendCodePoint(r.default.doubleQuote)}else e.appendString(t)}static serializeWhitespace(e,t,n){null!=t&&t.length>0?e.appendString(t):n&&e.appendString(" ")}static serializeValuesWithWhitespace(e,t){const n=t.getValues(),s=t.getWhitespaces(),r=t.getComment();if(null!==n){for(let t=0;t<n.length;t++){let r=null;t<s.length&&(r=s[t]),0===t?u.serializeWhitespace(e,r,!1):u.serializeWhitespace(e,r,!0),u.serializeValue(e,n[t])}if(s.length>=n.length+1){const t=s[n.length];u.serializeWhitespace(e,t,!1)}else null!=r&&n.length>0&&e.appendString(" ")}else{const t=s[0];u.serializeWhitespace(e,t,!1)}}static serializeValuesWithoutWhitespace(e,t){const n=t.getValues(),s=t.getComment();if(null===n)return;let r=!1;for(const t of n)r?e.appendString(" "):r=!0,u.serializeValue(e,t);null!=s&&n.length>0&&e.appendString(" ")}}t.default=u},759:(e,t,n)=>{var s;e=n.nmd(e);var r=function(){this.version="1.3.5";var e={mergeCDATA:!0,grokAttr:!0,grokText:!0,normalize:!0,xmlns:!0,namespaceKey:"_ns",textKey:"_text",valueKey:"_value",attrKey:"_attr",cdataKey:"_cdata",attrsAsObject:!0,stripAttrPrefix:!0,stripElemPrefix:!0,childrenAsArray:!0},t=new RegExp(/(?!xmlns)^.*:/),n=new RegExp(/^\s+|\s+$/g);return this.grokType=function(e){return/^\s*$/.test(e)?null:/^(?:true|false)$/i.test(e)?"true"===e.toLowerCase():isFinite(e)?parseFloat(e):e},this.parseString=function(e,t){return this.parseXML(this.stringToXML(e),t)},this.parseXML=function(s,i){for(var a in i)e[a]=i[a];var u={},o=0,l="";if(e.xmlns&&s.namespaceURI&&(u[e.namespaceKey]=s.namespaceURI),s.attributes&&s.attributes.length>0){for(var d={};o<s.attributes.length;o++){var c=s.attributes.item(o);m={};var f;f=e.stripAttrPrefix?c.name.replace(t,""):c.name,e.grokAttr?m[e.valueKey]=this.grokType(c.value.replace(n,"")):m[e.valueKey]=c.value.replace(n,""),e.xmlns&&c.namespaceURI&&(m[e.namespaceKey]=c.namespaceURI),e.attrsAsObject?d[f]=m:u[e.attrKey+f]=m}e.attrsAsObject&&(u[e.attrKey]=d)}if(s.hasChildNodes())for(var h,p,m,g=0;g<s.childNodes.length;g++)4===(h=s.childNodes.item(g)).nodeType?e.mergeCDATA?l+=h.nodeValue:u.hasOwnProperty(e.cdataKey)?(u[e.cdataKey].constructor!==Array&&(u[e.cdataKey]=[u[e.cdataKey]]),u[e.cdataKey].push(h.nodeValue)):e.childrenAsArray?(u[e.cdataKey]=[],u[e.cdataKey].push(h.nodeValue)):u[e.cdataKey]=h.nodeValue:3===h.nodeType?l+=h.nodeValue:1===h.nodeType&&(0===o&&(u={}),p=e.stripElemPrefix?h.nodeName.replace(t,""):h.nodeName,m=r.parseXML(h),u.hasOwnProperty(p)?(u[p].constructor!==Array&&(u[p]=[u[p]]),u[p].push(m)):(e.childrenAsArray?(u[p]=[],u[p].push(m)):u[p]=m,o++));else l||(e.childrenAsArray?(u[e.textKey]=[],u[e.textKey].push(null)):u[e.textKey]=null);if(l)if(e.grokText){var y=this.grokType(l.replace(n,""));null!=y&&(u[e.textKey]=y)}else e.normalize?u[e.textKey]=l.replace(n,"").replace(/\s+/g," "):u[e.textKey]=l.replace(n,"");return u},this.xmlToString=function(e){try{return e.xml?e.xml:(new XMLSerializer).serializeToString(e)}catch(e){return null}},this.stringToXML=function(e){try{var t=null;return window.DOMParser?t=(new DOMParser).parseFromString(e,"text/xml"):((t=new ActiveXObject("Microsoft.XMLDOM")).async=!1,t.loadXML(e),t)}catch(e){return null}},this}.call({});null!==e&&e.exports?e.exports=r:void 0===(s=function(){return r}.call(t,n,t,e))||(e.exports=s)},862:()=>{}},t={};function n(s){var r=t[s];if(void 0!==r)return r.exports;var i=t[s]={id:s,loaded:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),n(561)})()}));