camunda-dmn-js
Version:
Embeddable Camunda modeling distributions based on dmn-js
1 lines • 1.18 MB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DmnModeler=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(e,t,n){return t=r(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,s()?Reflect.construct(t,n||[],r(e).constructor):t.apply(e,n))}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){return t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,h(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(s=function(){return!!e})()}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){o(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function u(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}const d=Object.prototype.toString,p=Object.prototype.hasOwnProperty;function f(e){return void 0===e}function g(e){return void 0!==e}function m(e){return null==e}function v(e){return"[object Array]"===d.call(e)}function y(e){return"[object Object]"===d.call(e)}function b(e){return"[object Number]"===d.call(e)}function _(e){const t=d.call(e);return"[object Function]"===t||"[object AsyncFunction]"===t||"[object GeneratorFunction]"===t||"[object AsyncGeneratorFunction]"===t||"[object Proxy]"===t}function x(e){return"[object String]"===d.call(e)}function w(e,t){return!m(e)&&p.call(e,t)}function C(e,t){const n=I(t);let i;return O(e,(function(e,t){if(n(e,t))return i=e,!1})),i}function k(e,t){const n=I(t);let i=[];return O(e,(function(e,t){n(e,t)&&i.push(e)})),i}function O(e,t){let n,i;if(f(e))return;const o=v(e)?N:j;for(let r in e)if(w(e,r)&&(n=e[r],i=t(n,o(r)),!1===i))return n}function E(e,t,n){return O(e,(function(e,i){n=t(n,e,i)})),n}function S(e,t){return!!E(e,(function(e,n,i){return e&&t(n,i)}),!0)}function P(e,t){return!!C(e,t)}function T(e,t){let n=[];return O(e,(function(e,i){n.push(t(e,i))})),n}function R(e){return e&&Object.keys(e)||[]}function M(e){return T(e,(e=>e))}function A(e,t,n={}){return t=B(t),O(e,(function(e){let i=t(e)||"_",o=n[i];o||(o=n[i]=[]),o.push(e)})),n}function D(e,...t){e=B(e);let n={};return O(t,(t=>A(t,e,n))),T(n,(function(e,t){return e[0]}))}function $(e,t){t=B(t);let n=[];return O(e,(function(e,i){let o=t(e,i),r={d:o,v:e};for(var s=0;s<n.length;s++){let{d:e}=n[s];if(o<e)return void n.splice(s,0,r)}n.push(r)})),T(n,(e=>e.v))}function L(e){return function(t){return S(e,(function(e,n){return t[n]===e}))}}function B(e){return _(e)?e:t=>t[e]}function I(e){return _(e)?e:t=>t===e}function j(e){return e}function N(e){return Number(e)}function q(e,t){let n,i,o,r;function s(n){let s=Date.now(),c=n?0:r+t-s;if(c>0)return a(c);e.apply(o,i),l()}function a(e){n=setTimeout(s,e)}function l(){n&&clearTimeout(n),n=r=i=o=void 0}function c(...e){r=Date.now(),i=e,o=this,n||a(t)}return c.flush=function(){n&&s(!0),l()},c.cancel=l,c}function V(e,t){return e.bind(t)}function F(e,...t){return Object.assign(e,...t)}function H(e,t){let n={},i=Object(e);return O(t,(function(t){t in i&&(n[t]=e[t])})),n}function z(e,t){let n={};return O(Object(e),(function(e,i){-1===t.indexOf(i)&&(n[i]=e)})),n}var Q="__fn",W=Array.prototype.slice;function U(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}function X(){}U.prototype.on=function(e,t,n,i){if(e=v(e)?e:[e],_(t)&&(i=n,n=t,t=1e3),!b(t))throw new Error("priority must be a number");var o=n;i&&((o=V(n,i))[Q]=n[Q]||n);var r=this;e.forEach((function(e){r._addListener(e,{priority:t,callback:o,next:null})}))},U.prototype.once=function(e,t,n,i){var o=this;if(_(t)&&(i=n,n=t,t=1e3),!b(t))throw new Error("priority must be a number");function r(){r.__isTomb=!0;var t=n.apply(i,arguments);return o.off(e,r),t}r[Q]=n,this.on(e,t,r)},U.prototype.off=function(e,t){e=v(e)?e:[e];var n=this;e.forEach((function(e){n._removeListener(e,t)}))},U.prototype.createEvent=function(e){var t=new X;return t.init(e),t},U.prototype.fire=function(e,t){var n,i,o,r;if(r=W.call(arguments),"object"==typeof e&&(e=(t=e).type),!e)throw new Error("no event type specified");if(i=this._listeners[e]){n=t instanceof X?t:this.createEvent(t),r[0]=n;var s=n.type;e!==s&&(n.type=e);try{o=this._invokeListeners(n,r,i)}finally{e!==s&&(n.type=s)}return void 0===o&&n.defaultPrevented&&(o=!1),o}},U.prototype.handleError=function(e){return!1===this.fire("error",{error:e})},U.prototype._destroy=function(){this._listeners={}},U.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},U.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{i=function(e,t){return e.apply(null,t)}(n.callback,t),void 0!==i&&(e.returnValue=i,e.stopPropagation()),!1===i&&e.preventDefault()}catch(e){if(!this.handleError(e))throw console.error("unhandled error in event listener",e),e}return i},U.prototype._addListener=function(e,t){var n,i=this._getListeners(e);if(i){for(;i;){if(i.priority<t.priority)return t.next=i,void(n?n.next=t:this._setListeners(e,t));n=i,i=i.next}n.next=t}else this._setListeners(e,t)},U.prototype._getListeners=function(e){return this._listeners[e]},U.prototype._setListeners=function(e,t){this._listeners[e]=t},U.prototype._removeListener=function(e,t){var n,i,o,r=this._getListeners(e);if(t)for(;r;)n=r.next,(o=r.callback)!==t&&o[Q]!==t||(i?i.next=n:this._setListeners(e,n)),i=r,r=n;else this._setListeners(e,null)},X.prototype.stopPropagation=function(){this.cancelBubble=!0},X.prototype.preventDefault=function(){this.defaultPrevented=!0},X.prototype.init=function(e){F(this,e||{})};var G=Object.prototype.toString;function K(){return K=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},K.apply(this,arguments)}function Y(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return K.apply(void 0,[e].concat(n))}var Z=Object.prototype.toString,J=Object.prototype.hasOwnProperty;function ee(e){return"[object String]"===Z.call(e)}function te(e,t){return J.call(e,t)}function ne(e,t){var n;if(void 0!==e){var i=function(e){return"[object Array]"===Z.call(e)}(e)?oe:ie;for(var o in e)if(te(e,o)&&!1===t(n=e[o],i(o)))return n}}function ie(e){return e}function oe(e){return Number(e)}function re(e,t){return e.bind(t)}function se(){return se=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},se.apply(this,arguments)}function ae(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return se.apply(void 0,[e].concat(n))}function le(){}function ce(e,t){this.model=e,this.properties=t}le.prototype.get=function(e){return this.$model.properties.get(this,e)},le.prototype.set=function(e,t){this.$model.properties.set(this,e,t)},ce.prototype.createType=function(e){var t=this.model,n=this.properties,i=Object.create(le.prototype);ne(e.properties,(function(e){e.isMany||void 0===e.default||(i[e.name]=e.default)})),n.defineModel(i,t),n.defineDescriptor(i,e);var o=e.ns.name;function r(e){n.define(this,"$type",{value:o,enumerable:!0}),n.define(this,"$attrs",{value:{}}),n.define(this,"$parent",{writable:!0}),ne(e,re((function(e,t){this.set(t,e)}),this))}return r.prototype=i,r.hasType=i.$instanceOf=this.model.hasType,n.defineModel(r,t),n.defineDescriptor(r,e),r};var ue={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},he={String:function(e){return e},Boolean:function(e){return"true"===e},Integer:function(e){return parseInt(e,10)},Real:function(e){return parseFloat(e)}};function de(e,t){var n=he[e];return n?n(t):t}function pe(e){return!!ue[e]}function fe(e){return!!he[e]}function ge(e,t){var n,i,o=e.split(/:/);if(1===o.length)n=e,i=t;else{if(2!==o.length)throw new Error("expected <prefix:localName> or <localName>, got "+e);n=o[1],i=o[0]}return{name:e=(i?i+":":"")+n,prefix:i,localName:n}}function me(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}function ve(e,t){this.packageMap={},this.typeMap={},this.packages=[],this.properties=t,ne(e,re(this.registerPackage,this))}function ye(e,t,n){var i=t[n];if(i in e)throw new Error("package with "+n+" <"+i+"> already defined")}function be(e){this.model=e}function _e(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function xe(e){this.properties=new be(this),this.factory=new ce(this,this.properties),this.registry=new ve(e,this.properties),this.typeCache={}}me.prototype.build=function(){return e=this,t=["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"],n={},i=Object(e),ne(t,(function(t){t in i&&(n[t]=e[t])})),n;var e,t,n,i},me.prototype.addProperty=function(e,t,n){"boolean"==typeof t&&(n=t,t=void 0),this.addNamedProperty(e,!1!==n);var i=this.properties;void 0!==t?i.splice(t,0,e):i.push(e)},me.prototype.replaceProperty=function(e,t,n){var i=e.ns,o=this.properties,r=this.propertiesByName,s=e.name!==t.name;if(e.isId){if(!t.isId)throw new Error("property <"+t.ns.name+"> must be id property to refine <"+e.ns.name+">");this.setIdProperty(t,!1)}if(e.isBody){if(!t.isBody)throw new Error("property <"+t.ns.name+"> must be body property to refine <"+e.ns.name+">");this.setBodyProperty(t,!1)}var a=o.indexOf(e);if(-1===a)throw new Error("property <"+i.name+"> not found in property list");o.splice(a,1),this.addProperty(t,n?void 0:a,s),r[i.name]=r[i.localName]=t},me.prototype.redefineProperty=function(e,t,n){var i=e.ns.prefix,o=t.split("#"),r=ge(o[0],i),s=ge(o[1],r.prefix).name,a=this.propertiesByName[s];if(!a)throw new Error("refined property <"+s+"> not found");this.replaceProperty(a,e,n),delete e.redefines},me.prototype.addNamedProperty=function(e,t){var n=e.ns,i=this.propertiesByName;t&&(this.assertNotDefined(e,n.name),this.assertNotDefined(e,n.localName)),i[n.name]=i[n.localName]=e},me.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]},me.prototype.setBodyProperty=function(e,t){if(t&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+e.ns.name+">)");this.bodyProperty=e},me.prototype.setIdProperty=function(e,t){if(t&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+e.ns.name+">)");this.idProperty=e},me.prototype.assertNotDefined=function(e,t){var n=e.name,i=this.propertiesByName[n];if(i)throw new Error("property <"+n+"> already defined; override of <"+i.definedBy.ns.name+"#"+i.ns.name+"> by <"+e.definedBy.ns.name+"#"+e.ns.name+"> not allowed without redefines")},me.prototype.hasProperty=function(e){return this.propertiesByName[e]},me.prototype.addTrait=function(e,t){var n=this.allTypesByName,i=this.allTypes,o=e.name;o in n||(ne(e.properties,re((function(n){n=ae({},n,{name:n.ns.localName,inherited:t}),Object.defineProperty(n,"definedBy",{value:e});var i=n.replaces,o=n.redefines;i||o?this.redefineProperty(n,i||o,i):(n.isBody&&this.setBodyProperty(n),n.isId&&this.setIdProperty(n),this.addProperty(n))}),this)),i.push(e),n[o]=e)},ve.prototype.getPackage=function(e){return this.packageMap[e]},ve.prototype.getPackages=function(){return this.packages},ve.prototype.registerPackage=function(e){e=ae({},e);var t=this.packageMap;ye(t,e,"prefix"),ye(t,e,"uri"),ne(e.types,re((function(t){this.registerType(t,e)}),this)),t[e.uri]=t[e.prefix]=e,this.packages.push(e)},ve.prototype.registerType=function(e,t){var n=ge((e=ae({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:ae(e.meta||{})})).name,t.prefix),i=n.name,o={};ne(e.properties,re((function(e){var t=ge(e.name,n.prefix),i=t.name;pe(e.type)||(e.type=ge(e.type,t.prefix).name),ae(e,{ns:t,name:i}),o[i]=e}),this)),ae(e,{ns:n,name:i,propertiesByName:o}),ne(e.extends,re((function(e){var t=this.typeMap[e];t.traits=t.traits||[],t.traits.push(i)}),this)),this.definePackage(e,t),this.typeMap[i]=e},ve.prototype.mapTypes=function(e,t,n){var i=pe(e.name)?{name:e.name}:this.typeMap[e.name],o=this;function r(e){return s(e,!0)}function s(n,i){var r=ge(n,pe(n)?"":e.prefix);o.mapTypes(r,t,i)}if(!i)throw new Error("unknown type <"+e.name+">");ne(i.superClass,n?r:s),t(i,!n),ne(i.traits,r)},ve.prototype.getEffectiveDescriptor=function(e){var t=ge(e),n=new me(t);this.mapTypes(t,(function(e,t){n.addTrait(e,t)}));var i=n.build();return this.definePackage(i,i.allTypes[i.allTypes.length-1].$pkg),i},ve.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})},be.prototype.set=function(e,t,n){if(!ee(t)||!t.length)throw new TypeError("property name must be a non-empty string");var i=this.model.getPropertyDescriptor(e,t),o=i&&i.name;void 0===n?i?delete e[o]:delete e.$attrs[t]:i?o in e?e[o]=n:_e(e,i,n):e.$attrs[t]=n},be.prototype.get=function(e,t){var n=this.model.getPropertyDescriptor(e,t);if(!n)return e.$attrs[t];var i=n.name;return!e[i]&&n.isMany&&_e(e,n,[]),e[i]},be.prototype.define=function(e,t,n){if(!n.writable){var i=n.value;delete(n=ae({},n,{get:function(){return i}})).value}Object.defineProperty(e,t,n)},be.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})},be.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})},xe.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)},xe.prototype.getType=function(e){var t=this.typeCache,n=ee(e)?e:e.ns.name,i=t[n];return i||(e=this.registry.getEffectiveDescriptor(n),i=t[n]=this.factory.createType(e)),i},xe.prototype.createAny=function(e,t,n){var i=ge(e),o={$type:e,$instanceOf:function(e){return e===this.$type}},r={name:e,isGeneric:!0,ns:{prefix:i.prefix,localName:i.localName,uri:t}};return this.properties.defineDescriptor(o,r),this.properties.defineModel(o,this),this.properties.define(o,"$parent",{enumerable:!1,writable:!0}),this.properties.define(o,"$instanceOf",{enumerable:!1,writable:!0}),ne(n,(function(e,t){var n;n=e,"[object Object]"===Z.call(n)&&void 0!==e.value?o[e.name]=e.value:o[t]=e})),o},xe.prototype.getPackage=function(e){return this.registry.getPackage(e)},xe.prototype.getPackages=function(){return this.registry.getPackages()},xe.prototype.getElementDescriptor=function(e){return e.$descriptor},xe.prototype.hasType=function(e,t){return void 0===t&&(t=e,e=this),t in e.$model.getElementDescriptor(e).allTypesByName},xe.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]},xe.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};var we=Object.prototype.toString,Ce=Object.prototype.hasOwnProperty;function ke(e){return"[object Array]"===we.call(e)}function Oe(e){return"[object String]"===we.call(e)}function Ee(e,t){return Ce.call(e,t)}function Se(e,t){var n;return t=Re(t),Te(e,(function(e,i){if(t(e,i))return n=e,!1})),n}function Pe(e,t){var n=[];return Te(e,(function(e,i){t(e,i)&&n.push(e)})),n}function Te(e,t){var n;if(void 0!==e){var i=ke(e)?Ae:Me;for(var o in e)if(Ee(e,o)&&!1===t(n=e[o],i(o)))return n}}function Re(e){return t=e,"[object Function]"===(n=we.call(t))||"[object AsyncFunction]"===n||"[object GeneratorFunction]"===n||"[object AsyncGeneratorFunction]"===n||"[object Proxy]"===n?e:function(t){return t===e};var t,n}function Me(e){return e}function Ae(e){return Number(e)}function De(){return De=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},De.apply(this,arguments)}function $e(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return De.apply(void 0,[e].concat(n))}var Le=String.fromCharCode,Be=Object.prototype.hasOwnProperty,Ie=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/gi,je={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};function Ne(e,t,n,i){return i?Be.call(je,i)?je[i]:"&"+i+";":Le(t||parseInt(n,16))}function qe(e){return e.length>3&&-1!==e.indexOf("&")?e.replace(Ie,Ne):e}Object.keys(je).forEach((function(e){je[e.toUpperCase()]=je[e]}));var Ve="xsi:type",Fe="non-whitespace outside of root node";function He(e){return new Error(e)}function ze(e){return"missing namespace for prefix <"+e+">"}function Qe(e){return{get:e,enumerable:!0}}function We(e){var t,n={};for(t in e)n[t]=e[t];return n}function Ue(e){return e+"$uri"}function Xe(){return{line:0,column:0}}function Ge(e){throw e}function Ke(e){if(!this)return new Ke(e);var t,n,i,o,r,s,a,l,c,u=e&&e.proxy,h=Ge,d=Xe,p=!1,f=!1,g=null,m=!1;function v(e){e instanceof Error||(e=He(e)),g=e,h(e,d)}function y(e){r&&(e instanceof Error||(e=He(e)),r(e,d))}this.on=function(e,c){if("function"!=typeof c)throw He("required args <name, cb>");switch(e){case"openTag":n=c;break;case"text":t=c;break;case"closeTag":i=c;break;case"error":h=c;break;case"warn":r=c;break;case"cdata":o=c;break;case"attention":l=c;break;case"question":a=c;break;case"comment":s=c;break;default:throw He("unsupported event: "+e)}return this},this.ns=function(e){if(void 0===e&&(e={}),"object"!=typeof e)throw He("required args <nsMap={}>");var t,n={};for(t in e)n[t]=e[t];return n["http://www.w3.org/2001/XMLSchema-instance"]="xsi",f=!0,c=n,this},this.parse=function(e){if("string"!=typeof e)throw He("required args <xml=string>");return g=null,function(e){var r,h,g,b,_,x,w,C,k,O,E,S=f?[]:null,P=f?function(e){var t,n,i={};for(t in e)i[n=e[t]]=n,i[Ue(n)]=t;return i}(c):null,T=[],R=0,M=!1,A=!1,D=0,$=0,L="",B=0;function I(){if(null!==E)return E;var e,t,n,i,o,r,s,a,l,u,h,d=f&&P.xmlns,g=f&&p?[]:null,m=B,v=L,b=v.length,_={},x={};e:for(;m<b;m++)if(l=!1,!(32===(u=v.charCodeAt(m))||u<14&&u>8)){for((u<65||u>122||u>90&&u<97)&&95!==u&&58!==u&&(y("illegal first char attribute name"),l=!0),h=m+1;h<b;h++)if(!((u=v.charCodeAt(h))>96&&u<123||u>64&&u<91||u>47&&u<59||46===u||45===u||95===u)){if(32===u||u<14&&u>8){y("missing attribute value"),m=h;continue e}if(61===u)break;y("illegal attribute name char"),l=!0}if("xmlns:xmlns"===(a=v.substring(m,h))&&(y("illegal declaration of xmlns"),l=!0),34===(u=v.charCodeAt(h+1)))-1===(h=v.indexOf('"',m=h+2))&&-1!==(h=v.indexOf("'",m))&&(y("attribute value quote missmatch"),l=!0);else if(39===u)-1===(h=v.indexOf("'",m=h+2))&&-1!==(h=v.indexOf('"',m))&&(y("attribute value quote missmatch"),l=!0);else for(y("missing attribute value quotes"),l=!0,h+=1;h<b&&!(32===(u=v.charCodeAt(h+1))||u<14&&u>8);h++);for(-1===h&&(y("missing closing quotes"),h=b,l=!0),l||(r=v.substring(m,h)),m=h;h+1<b&&!(32===(u=v.charCodeAt(h+1))||u<14&&u>8);h++)m===h&&(y("illegal character after attribute end"),l=!0);if(m=h+1,!l)if(a in x)y("attribute <"+a+"> already defined");else if(x[a]=!0,f)if(p){if(null!==(o="xmlns"===a?"xmlns":120===a.charCodeAt(0)&&"xmlns:"===a.substr(0,6)?a.substr(6):null)){if(e=qe(r),t=Ue(o),!(s=c[e])){if("xmlns"===o||t in P&&P[t]!==e)do{s="ns"+R++}while(void 0!==P[s]);else s=o;c[e]=s}P[o]!==s&&(i||(P=We(P),i=!0),P[o]=s,"xmlns"===o&&(P[Ue(s)]=e,d=s),P[t]=e),_[a]=r;continue}g.push(a,r)}else-1!==(u=a.indexOf(":"))?(n=P[a.substring(0,u)])?((a=d===n?a.substr(u+1):n+a.substr(u))===Ve&&(-1!==(u=r.indexOf(":"))?(n=r.substring(0,u),r=(n=P[n]||n)+r.substring(u)):r=d+":"+r),_[a]=r):y(ze(a.substring(0,u))):_[a]=r;else _[a]=r}if(p)for(m=0,b=g.length;m<b;m++){if(a=g[m++],r=g[m],-1!==(u=a.indexOf(":"))){if(!(n=P[a.substring(0,u)])){y(ze(a.substring(0,u)));continue}(a=d===n?a.substr(u+1):n+a.substr(u))===Ve&&(-1!==(u=r.indexOf(":"))?(n=r.substring(0,u),r=(n=P[n]||n)+r.substring(u)):r=d+":"+r)}_[a]=r}return E=_}function j(){for(var t,n,i=/(\r\n|\r|\n)/g,o=0,r=0,s=0,a=$;D>=s&&(t=i.exec(e))&&!((a=t[0].length+t.index)>D);)o+=1,s=a;return-1==D?(r=a,n=e.substring($)):0===$?n=e.substring($,D):(r=D-s,n=-1==$?e.substring(D):e.substring(D,$+1)),{data:n,line:o,column:r}}d=j,u&&(O=Object.create({},{name:Qe((function(){return C})),originalName:Qe((function(){return k})),attrs:Qe(I),ns:Qe((function(){return P}))}));for(;-1!==$;){if(-1===(D=60===e.charCodeAt($)?$:e.indexOf("<",$)))return T.length?v("unexpected end of file"):0===$?v("missing start tag"):void($<e.length&&e.substring($).trim()&&y(Fe));if($!==D)if(T.length){if(t&&(t(e.substring($,D),qe,d),m))return}else if(e.substring($,D).trim()&&(y(Fe),m))return;if(33===(_=e.charCodeAt(D+1))){if(91===(b=e.charCodeAt(D+2))&&"CDATA["===e.substr(D+3,6)){if(-1===($=e.indexOf("]]>",D)))return v("unclosed cdata");if(o&&(o(e.substring(D+9,$),d),m))return;$+=3;continue}if(45===b&&45===e.charCodeAt(D+3)){if(-1===($=e.indexOf("--\x3e",D)))return v("unclosed comment");if(s&&(s(e.substring(D+4,$),qe,d),m))return;$+=3;continue}}if(63!==_){for(h=D+1;;h++){if(x=e.charCodeAt(h),isNaN(x))return $=-1,v("unclosed tag");if(34===x)h=-1!==(b=e.indexOf('"',h+1))?b:h;else if(39===x)h=-1!==(b=e.indexOf("'",h+1))?b:h;else if(62===x){$=h;break}}if(33!==_){if(E={},47===_){if(M=!1,A=!0,!T.length)return v("missing open tag");if(h=C=T.pop(),b=D+2+h.length,e.substring(D+2,b)!==h)return v("closing tag mismatch");for(;b<$;b++)if(!(32===(_=e.charCodeAt(b))||_>8&&_<14))return v("close tag")}else{if(47===e.charCodeAt($-1)?(h=C=e.substring(D+1,$-1),M=!0,A=!0):(h=C=e.substring(D+1,$),M=!0,A=!1),!(_>96&&_<123||_>64&&_<91||95===_||58===_))return v("illegal first char nodeName");for(b=1,g=h.length;b<g;b++)if(!((_=h.charCodeAt(b))>96&&_<123||_>64&&_<91||_>47&&_<59||45===_||95===_||46==_)){if(32===_||_<14&&_>8){C=h.substring(0,b),E=null;break}return v("invalid nodeName")}A||T.push(C)}if(f){if(r=P,M&&(A||S.push(r),null===E&&(p=-1!==h.indexOf("xmlns",b))&&(B=b,L=h,I(),p=!1)),k=C,-1!==(_=C.indexOf(":"))){if(!(w=P[C.substring(0,_)]))return v("missing namespace on <"+k+">");C=C.substr(_+1)}else w=P.xmlns;w&&(C=w+":"+C)}if(M&&(B=b,L=h,n&&(u?n(O,qe,A,d):n(C,I,qe,A,d),m)))return;if(A){if(i&&(i(u?O:C,qe,M,d),m))return;f&&(P=M?r:S.pop())}$+=1}else{if(l&&(l(e.substring(D,$+1),qe,d),m))return;$+=1}}else{if(-1===($=e.indexOf("?>",D)))return v("unclosed question");if(a&&(a(e.substring(D,$+2),d),m))return;$+=2}}}(e),d=Xe,m=!1,g},this.stop=function(){m=!0}}function Ye(e){return e.xml&&"lowerCase"===e.xml.tagAlias}var Ze={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},Je="xsi:type";function et(e){return e.xml&&e.xml.serialize}function tt(e){return et(e)===Je}function nt(e,t){return Ye(t)?e.prefix+":"+((n=e.localName).charAt(0).toUpperCase()+n.slice(1)):e.name;var n}function it(e){return new Error(e)}function ot(e){return e.$descriptor}function rt(e){$e(this,e),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(e){this.references.push(e)},this.addElement=function(e){if(!e)throw it("expected element");var t,n=this.elementsById,i=ot(e).idProperty;if(i&&(t=e.get(i.name))){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(t))throw new Error("illegal ID <"+t+">");if(n[t])throw it("duplicate ID <"+t+">");n[t]=e}},this.addWarning=function(e){this.warnings.push(e)}}function st(){}function at(){}function lt(){}function ct(e,t){this.property=e,this.context=t}function ut(e,t){this.element=t,this.propertyDesc=e}function ht(){}function dt(e,t,n){this.model=e,this.type=e.getType(t),this.context=n}function pt(e,t,n){dt.call(this,e,t,n)}function ft(e,t,n){this.model=e,this.context=n}function gt(e){e instanceof xe&&(e={model:e}),$e(this,{lax:!1},e)}st.prototype.handleEnd=function(){},st.prototype.handleText=function(){},st.prototype.handleNode=function(){},at.prototype=Object.create(st.prototype),at.prototype.handleNode=function(){return this},lt.prototype=Object.create(st.prototype),lt.prototype.handleText=function(e){this.body=(this.body||"")+e},ct.prototype=Object.create(lt.prototype),ct.prototype.handleNode=function(e){if(this.element)throw it("expected no sub nodes");return this.element=this.createReference(e),this},ct.prototype.handleEnd=function(){this.element.id=this.body},ct.prototype.createReference=function(e){return{property:this.property.ns.name,id:""}},ut.prototype=Object.create(lt.prototype),ut.prototype.handleEnd=function(){var e=this.body||"",t=this.element,n=this.propertyDesc;e=de(n.type,e),n.isMany?t.get(n.name).push(e):t.set(n.name,e)},ht.prototype=Object.create(lt.prototype),ht.prototype.handleNode=function(e){var t=this,n=this.element;return n?t=this.handleChild(e):(n=this.element=this.createElement(e),this.context.addElement(n)),t},dt.prototype=Object.create(ht.prototype),dt.prototype.addReference=function(e){this.context.addReference(e)},dt.prototype.handleText=function(e){if(!ot(this.element).bodyProperty)throw it("unexpected body text <"+e+">");lt.prototype.handleText.call(this,e)},dt.prototype.handleEnd=function(){var e=this.body,t=this.element,n=ot(t).bodyProperty;n&&void 0!==e&&(e=de(n.type,e),t.set(n.name,e))},dt.prototype.createElement=function(e){var t,n=e.attributes,i=this.type,o=ot(i),r=this.context,s=new i({}),a=this.model;return Te(n,(function(e,n){var i=o.propertiesByName[n];i&&i.isReference?i.isMany?Te(e.split(" "),(function(e){r.addReference({element:s,property:i.ns.name,id:e})})):r.addReference({element:s,property:i.ns.name,id:e}):(i?e=de(i.type,e):"xmlns"!==n&&(t=ge(n,o.ns.prefix),a.getPackage(t.prefix)&&r.addWarning({message:"unknown attribute <"+n+">",element:s,property:n,value:e})),s.set(n,e))})),s},dt.prototype.getPropertyForNode=function(e){var t,n,i=ge(e.name),o=this.type,r=this.model,s=ot(o),a=i.name,l=s.propertiesByName[a];if(l&&!l.isAttr)return tt(l)&&(t=e.attributes[Je])?(t=function(e,t){var n=ge(e);return function(e,t){var n=e.name,i=e.localName,o=t.xml&&t.xml.typePrefix;return o&&0===i.indexOf(o)?e.prefix+":"+i.slice(o.length):n}(n,t.getPackage(n.prefix))}(t,r),$e({},l,{effectiveType:ot(n=r.getType(t)).name})):l;var c=r.getPackage(i.prefix);if(c){if(t=nt(i,c),n=r.getType(t),l=Se(s.properties,(function(e){return!e.isVirtual&&!e.isReference&&!e.isAttribute&&n.hasType(e.type)})),l)return $e({},l,{effectiveType:ot(n).name})}else if(l=Se(s.properties,(function(e){return!e.isReference&&!e.isAttribute&&"Element"===e.type})),l)return l;throw it("unrecognized element <"+i.name+">")},dt.prototype.toString=function(){return"ElementDescriptor["+ot(this.type).name+"]"},dt.prototype.valueHandler=function(e,t){return new ut(e,t)},dt.prototype.referenceHandler=function(e){return new ct(e,this.context)},dt.prototype.handler=function(e){return"Element"===e?new ft(this.model,e,this.context):new dt(this.model,e,this.context)},dt.prototype.handleChild=function(e){var t,n,i,o;if(t=this.getPropertyForNode(e),i=this.element,fe(n=t.effectiveType||t.type))return this.valueHandler(t,i);var r=(o=t.isReference?this.referenceHandler(t).handleNode(e):this.handler(n).handleNode(e)).element;return void 0!==r&&(t.isMany?i.get(t.name).push(r):i.set(t.name,r),t.isReference?($e(r,{element:i}),this.context.addReference(r)):r.$parent=i),o},pt.prototype=Object.create(dt.prototype),pt.prototype.createElement=function(e){var t=e.name,n=ge(t),i=this.model,o=this.type,r=i.getPackage(n.prefix),s=r&&nt(n,r)||t;if(!o.hasType(s))throw it("unexpected element <"+e.originalName+">");return dt.prototype.createElement.call(this,e)},ft.prototype=Object.create(ht.prototype),ft.prototype.createElement=function(e){var t=e.name,n=ge(t).prefix,i=e.ns[n+"$uri"],o=e.attributes;return this.model.createAny(t,i,o)},ft.prototype.handleChild=function(e){var t=new ft(this.model,"Element",this.context).handleNode(e),n=this.element,i=t.element;return void 0!==i&&((n.$children=n.$children||[]).push(i),i.$parent=n),t},ft.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)},gt.prototype.fromXML=function(e,t,n){var i=t.rootHandler;t instanceof dt?(i=t,t={}):"string"==typeof t?(i=this.handler(t),t={}):"string"==typeof i&&(i=this.handler(i));var o=this.model,r=this.lax,s=new rt($e({},t,{rootHandler:i})),a=new Ke({proxy:!0}),l=function(){var e=[];return Object.defineProperty(e,"peek",{value:function(){return this[this.length-1]}}),e}();function c(e,t,n){var i=t(),o=i.line,r=i.column,a=i.data;"<"===a.charAt(0)&&-1!==a.indexOf(" ")&&(a=a.slice(0,a.indexOf(" "))+">");var l="unparsable content "+(a?a+" ":"")+"detected\n\tline: "+o+"\n\tcolumn: "+r+"\n\tnested error: "+e.message;if(n)return s.addWarning({message:l,error:e}),!0;throw it(l)}function u(e,t){return c(e,t,!0)}i.context=s,l.push(i);var h=/^<\?xml /i,d=/ encoding="([^"]+)"/i,p=/^utf-8$/i;function f(e,t){try{l.peek().handleText(e)}catch(e){u(e,t)}}var g=o.getPackages().reduce((function(e,t){return e[t.uri]=t.prefix,e}),{"http://www.w3.org/XML/1998/namespace":"xml"});return a.ns(g).on("openTag",(function(e,t,n,i){var o=e.attrs||{},s=Object.keys(o).reduce((function(e,n){var i=t(o[n]);return e[n]=i,e}),{});!function(e,t){var n=l.peek();try{l.push(n.handleNode(e))}catch(e){c(e,t,r)&&l.push(new at)}}({name:e.name,originalName:e.originalName,attributes:s,ns:e.ns},i)})).on("question",(function(e){if(h.test(e)){var t=d.exec(e),n=t&&t[1];n&&!p.test(n)&&s.addWarning({message:"unsupported document encoding <"+n+">, falling back to UTF-8"})}})).on("closeTag",(function(){l.pop().handleEnd()})).on("cdata",f).on("text",(function(e,t,n){!function(e,t){e.trim()&&f(e,t)}(t(e),n)})).on("error",c).on("warn",u),new Promise((function(t,n){var o;try{a.parse(e),function(){var e,t,n=s.elementsById,i=s.references;for(e=0;t=i[e];e++){var o=t.element,r=n[t.id],a=ot(o).propertiesByName[t.property];if(r||s.addWarning({message:"unresolved reference <"+t.id+">",element:t.element,property:t.property,value:t.id}),a.isMany){var l=o.get(a.name),c=l.indexOf(t);-1===c&&(c=l.length),r?l[c]=r:l.splice(c,1)}else o.set(a.name,r)}}()}catch(e){o=e}var r=i.element;o||r||(o=it("failed to parse document as <"+i.type.$descriptor.name+">"));var l=s.warnings,c=s.references,u=s.elementsById;return o?(o.warnings=l,n(o)):t({rootElement:r,elementsById:u,references:c,warnings:l})}))},gt.prototype.handler=function(e){return new pt(this.model,e)};var mt=/<|>|'|"|&|\n\r|\n/g,vt=/<|>|&/g;function yt(e){var t={},n={},i={},o=[],r=[];this.byUri=function(t){return n[t]||e&&e.byUri(t)},this.add=function(e,t){n[e.uri]=e,t?o.push(e):r.push(e),this.mapPrefix(e.prefix,e.uri)},this.uriByPrefix=function(e){return t[e||"xmlns"]},this.mapPrefix=function(e,n){t[e||"xmlns"]=n},this.getNSKey=function(e){return void 0!==e.prefix?e.uri+"|"+e.prefix:e.uri},this.logUsed=function(t){var n=t.uri,o=this.getNSKey(t);i[o]=this.byUri(n),e&&e.logUsed(t)},this.getUsed=function(e){var t=this;return[].concat(o,r).filter((function(e){var n=t.getNSKey(e);return i[n]}))}}function bt(e,t){return Ye(t)?function(e){return e.charAt(0).toLowerCase()+e.slice(1)}(e):e}function _t(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function xt(e){return Oe(e)?e:(e.prefix?e.prefix+":":"")+e.localName}var wt={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},Ct={"<":"lt",">":"gt","&":"amp"};function kt(e,t,n){return(e=Oe(e)?e:""+e).replace(t,(function(e){return"&"+n[e]+";"}))}function Ot(e){this.tagName=e}function Et(){}function St(e){this.tagName=e}function Pt(e,t){this.body=[],this.attrs=[],this.parent=e,this.propertyDescriptor=t}function Tt(e,t){Pt.call(this,e,t)}function Rt(){this.value="",this.write=function(e){this.value+=e}}function Mt(e,t){var n=[""];this.append=function(t){return e.write(t),this},this.appendNewLine=function(){return t&&e.write("\n"),this},this.appendIndent=function(){return t&&e.write(n.join(" ")),this},this.indent=function(){return n.push(""),this},this.unindent=function(){return n.pop(),this}}function At(e){return e=$e({format:!1,preamble:!0},e||{}),{toXML:function(t,n){var i=n||new Rt,o=new Mt(i,e.format);if(e.preamble&&o.append('<?xml version="1.0" encoding="UTF-8"?>\n'),(new Pt).build(t).serializeTo(o),!n)return i.value}}}function Dt(e,t){xe.call(this,e,t)}Ot.prototype.build=function(e){return this.element=e,this},Ot.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"+this.element.id+"</"+this.tagName+">").appendNewLine()},Et.prototype.serializeValue=Et.prototype.serializeTo=function(e){e.append(this.escape?kt(this.value,vt,Ct):this.value)},Et.prototype.build=function(e,t){return this.value=t,"String"===e.type&&-1!==t.search(vt)&&(this.escape=!0),this},_t(St,Et),St.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"),this.serializeValue(e),e.append("</"+this.tagName+">").appendNewLine()},Pt.prototype.build=function(e){this.element=e;var t,n,i=e.$descriptor,o=this.propertyDescriptor,r=i.isGeneric;return t=r?this.parseGeneric(e):this.parseNsAttributes(e),this.ns=o?this.nsPropertyTagName(o):this.nsTagName(i),this.tagName=this.addTagName(this.ns),r||(n=function(e){return Pe(e.$descriptor.properties,(function(t){var n=t.name;if(t.isVirtual)return!1;if(!Ee(e,n))return!1;var i=e[n];return i!==t.default&&null!==i&&(!t.isMany||i.length)}))}(e),this.parseAttributes(function(e){return Pe(e,(function(e){return e.isAttr}))}(n)),this.parseContainments(function(e){return Pe(e,(function(e){return!e.isAttr}))}(n))),this.parseGenericAttributes(e,t),this},Pt.prototype.nsTagName=function(e){return function(e,t){return t.isGeneric?$e({localName:t.ns.localName},e):$e({localName:bt(t.ns.localName,t.$pkg)},e)}(this.logNamespaceUsed(e.ns),e)},Pt.prototype.nsPropertyTagName=function(e){return function(e,t){return $e({localName:t.ns.localName},e)}(this.logNamespaceUsed(e.ns),e)},Pt.prototype.isLocalNs=function(e){return e.uri===this.ns.uri},Pt.prototype.nsAttributeName=function(e){var t;if(t=Oe(e)?ge(e):e.ns,e.inherited)return{localName:t.localName};var n=this.logNamespaceUsed(t);return this.getNamespaces().logUsed(n),this.isLocalNs(n)?{localName:t.localName}:$e({localName:t.localName},n)},Pt.prototype.parseGeneric=function(e){var t=this,n=this.body,i=[];return Te(e,(function(o,r){"$body"===r?n.push((new Et).build({type:"String"},o)):"$children"===r?Te(o,(function(e){n.push(new Pt(t).build(e))})):0!==r.indexOf("$")&&t.parseNsAttribute(e,r,o)&&i.push({name:r,value:o})})),i},Pt.prototype.parseNsAttribute=function(e,t,n){var i,o=e.$model,r=ge(t);if("xmlns"===r.prefix&&(i={prefix:r.localName,uri:n}),r.prefix||"xmlns"!==r.localName||(i={uri:n}),!i)return{name:t,value:n};if(o&&o.getPackage(n))this.logNamespace(i,!0,!0);else{var s=this.logNamespaceUsed(i,!0);this.getNamespaces().logUsed(s)}},Pt.prototype.parseNsAttributes=function(e,t){var n=this,i=e.$attrs,o=[];return Te(i,(function(t,i){var r=n.parseNsAttribute(e,i,t);r&&o.push(r)})),o},Pt.prototype.parseGenericAttributes=function(e,t){var n=this;Te(t,(function(t){if(t.name!==Je)try{n.addAttribute(n.nsAttributeName(t.name),t.value)}catch(n){console.warn("missing namespace information for ",t.name,"=",t.value,"on",e,n)}}))},Pt.prototype.parseContainments=function(e){var t=this,n=this.body,i=this.element;Te(e,(function(e){var o=i.get(e.name),r=e.isReference;if(e.isMany||(o=[o]),e.isBody)n.push((new Et).build(e,o[0]));else if(fe(e.type))Te(o,(function(i){n.push(new St(t.addTagName(t.nsPropertyTagName(e))).build(e,i))}));else if(r)Te(o,(function(i){n.push(new Ot(t.addTagName(t.nsPropertyTagName(e))).build(i))}));else{var s=tt(e),a=function(e){return"property"===et(e)}(e);Te(o,(function(i){var o;o=s?new Tt(t,e):a?new Pt(t,e):new Pt(t),n.push(o.build(i))}))}}))},Pt.prototype.getNamespaces=function(e){var t,n=this.namespaces,i=this.parent;return n||(t=i&&i.getNamespaces(),e||!t?this.namespaces=n=new yt(t):n=t),n},Pt.prototype.logNamespace=function(e,t,n){var i=this.getNamespaces(n),o=e.uri,r=e.prefix;return i.byUri(o)&&!n||i.add(e,t),i.mapPrefix(r,o),e},Pt.prototype.logNamespaceUsed=function(e,t){var n,i,o,r=this.element.$model,s=this.getNamespaces(t),a=e.prefix,l=e.uri;if(!a&&!l)return{localName:e.localName};if(o=Ze[a]||r&&(r.getPackage(a)||{}).uri,!(l=l||o||s.uriByPrefix(a)))throw new Error("no namespace uri given for prefix <"+a+">");if(!(e=s.byUri(l))){for(n=a,i=1;s.uriByPrefix(n);)n=a+"_"+i++;e=this.logNamespace({prefix:n,uri:l},o===l)}return a&&s.mapPrefix(a,l),e},Pt.prototype.parseAttributes=function(e){var t=this,n=this.element;Te(e,(function(e){var i=n.get(e.name);if(e.isReference)if(e.isMany){var o=[];Te(i,(function(e){o.push(e.id)})),i=o.join(" ")}else i=i.id;t.addAttribute(t.nsAttributeName(e),i)}))},Pt.prototype.addTagName=function(e){var t=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(t),xt(e)},Pt.prototype.addAttribute=function(e,t){var n=this.attrs;Oe(t)&&(t=kt(t,mt,wt));var i=function(e,t){t=Re(t);var n=ke(e)?-1:void 0;return Te(e,(function(e,i){if(t(e,i))return n=i,!1})),n}(n,(function(t){return t.name.localName===e.localName&&t.name.uri===e.uri&&t.name.prefix===e.prefix})),o={name:e,value:t};-1!==i?n.splice(i,1,o):n.push(o)},Pt.prototype.serializeAttributes=function(e){var t=this.attrs,n=this.namespaces;n&&(t=function(e){return e.getUsed().filter((function(e){return"xml"!==e.prefix})).map((function(e){return{name:"xmlns"+(e.prefix?":"+e.prefix:""),value:e.uri}}))}(n).concat(t)),Te(t,(function(t){e.append(" ").append(xt(t.name)).append('="').append(t.value).append('"')}))},Pt.prototype.serializeTo=function(e){var t=this.body[0],n=t&&t.constructor!==Et;e.appendIndent().append("<"+this.tagName),this.serializeAttributes(e),e.append(t?">":" />"),t&&(n&&e.appendNewLine().indent(),Te(this.body,(function(t){t.serializeTo(e)})),n&&e.unindent().appendIndent(),e.append("</"+this.tagName+">")),e.appendNewLine()},_t(Tt,Pt),Tt.prototype.parseNsAttributes=function(e){var t=Pt.prototype.parseNsAttributes.call(this,e),n=e.$descriptor;if(n.name===this.propertyDescriptor.type)return t;var i=this.typeNs=this.nsTagName(n);this.getNamespaces().logUsed(this.typeNs);var o=e.$model.getPackage(i.uri),r=o.xml&&o.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(Je),(i.prefix?i.prefix+":":"")+r+n.ns.localName),t},Tt.prototype.isLocalNs=function(e){return e.uri===(this.typeNs||this.ns).uri},Dt.prototype=Object.create(xe.prototype),Dt.prototype.fromXML=function(e,t,n){var i;i=t,"[object String]"!==G.call(i)&&(n=t,t="dmn:Definitions");var o=new gt(Y({model:this,lax:!0},n)),r=o.handler(t);return o.fromXML(e,r)},Dt.prototype.toXML=function(e,t){var n=new At(t);return new Promise((function(t,i){try{return t({xml:n.toXML(e)})}catch(e){return i(e)}}))};var $t={dc:{name:"DC",prefix:"dc",uri:"http://www.omg.org/spec/DMN/20180521/DC/",types:[{name:"Dimension",properties:[{name:"width",isAttr:!0,type:"Real"},{name:"height",isAttr:!0,type:"Real"}]},{name:"Bounds",properties:[{name:"height",isAttr:!0,type:"Real"},{name:"width",isAttr:!0,type:"Real"},{name:"x",isAttr:!0,type:"Real"},{name:"y",isAttr:!0,type:"Real"}]},{name:"Point",properties:[{name:"x",isAttr:!0,type:"Real"},{name:"y",isAttr:!0,type:"Real"}]},{name:"Color",properties:[{name:"red",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"},{name:"green",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"},{name:"blue",type:"UML_Standard_Profile.mdzip:eee_1045467100323_917313_65"}]}],associations:[],enumerations:[{name:"AlignmentKind",literalValues:[{name:"start"},{name:"center"},{name:"end"}]}]},di:{name:"DI",prefix:"di",uri:"http://www.omg.org/spec/DMN/20180521/DI/",types:[{name:"DiagramElement",isAbstract:!0,properties:[{name:"extension",type:"Extension"},{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"style",isReference:!0,type:"Style",xml:{serialize:"property"}},{name:"sharedStyle",isReference:!0,isVirtual:!0,type:"Style"}]},{name:"Diagram",superClass:["DiagramElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"documentation",isAttr:!0,type:"String"},{name:"resolution",isAttr:!0,type:"Real"}]},{name:"Shape",isAbstract:!0,properties:[{name:"bounds",type:"dc:Bounds"}],superClass:["DiagramElement"]},{name:"Edge",isAbstract:!0,properties:[{name:"waypoint",type:"dc:Point",isMany:!0,xml:{serialize:"property"}}],superClass:["DiagramElement"]},{name:"Style",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"}]},{name:"Extension",properties:[{name:"values",isMany:!0,type:"Element"}]}],associations:[],enumerations:[],xml:{tagAlias:"lowerCase"}},dmn:{name:"DMN",prefix:"dmn",uri:"https://www.omg.org/spec/DMN/20191111/MODEL/",types:[{name:"AuthorityRequirement",superClass:["DMNElement"],properties:[{name:"requiredAuthority",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredDecision",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredInput",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"ItemDefinition",superClass:["NamedElement"],properties:[{name:"typeRef",type:"String"},{name:"allowedValues",type:"UnaryTests",xml:{serialize:"property"}},{name:"typeLanguage",type:"String",isAttr:!0},{name:"itemComponent",type:"ItemDefinition",isMany:!0,xml:{serialize:"property"}},{name:"functionItem",type:"FunctionItem"},{name:"isCollection",isAttr:!0,type:"Boolean"}]},{name:"Definitions",superClass:["NamedElement"],properties:[{name:"import",type:"Import",isMany:!0},{name:"itemDefinition",type:"ItemDefinition",isMany:!0},{name:"drgElement",type:"DRGElement",isMany:!0},{name:"artifact",type:"Artifact",isMany:!0},{name:"elementCollection",type:"ElementCollection",isMany:!0},{name:"businessContextElement",type:"BusinessContextElement",isMany:!0},{name:"namespace",type:"String",isAttr:!0},{name:"expressionLanguage",type:"String",isAttr:!0},{name:"typeLanguage",type:"String",isAttr:!0},{name:"exporter",isAttr:!0,type:"String"},{name:"exporterVersion",isAttr:!0,type:"String"},{name:"dmnDI",type:"dmndi:DMNDI"}]},{name:"KnowledgeSource",superClass:["DRGElement"],properties:[{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0},{name:"type",type:"String"},{name:"owner",type:"DMNElementReference",xml:{serialize:"property"}},{name:"locationURI",type:"String",isAttr:!0}]},{name:"DecisionRule",superClass:["DMNElement"],properties:[{name:"inputEntry",type:"UnaryTests",isMany:!0,xml:{serialize:"property"}},{name:"outputEntry",type:"LiteralExpression",isMany:!0,xml:{serialize:"property"}},{name:"annotationEntry",type:"RuleAnnotation",isMany:!0,xml:{serialize:"property"}}]},{name:"Expression",isAbstract:!0,superClass:["DMNElement"],properties:[{name:"typeRef",isAttr:!0,type:"String"}]},{name:"InformationItem",superClass:["NamedElement"],properties:[{name:"typeRef",isAttr:!0,type:"String"}]},{name:"Decision",superClass:["DRGElement"],properties:[{name:"question",type:"String",xml:{serialize:"property"}},{name:"allowedAnswers",type:"String",xml:{serialize:"property"}},{name:"variable",type:"InformationItem",xml:{serialize:"property"}},{name:"informationRequirement",type:"InformationRequirement",isMany:!0},{name:"knowledgeRequirement",type:"KnowledgeRequirement",isMany:!0},{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0},{name:"supportedObjective",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"impactedPerformanceIndicator",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"decisionMaker",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"decisionOwner",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}},{name:"usingProcess",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"usingTask",isMany:!0,type:"DMNElementReference",xml:{serialize:"property"}},{name:"decisionLogic",type:"Expression"}]},{name:"Invocation",superClass:["Expression"],properties:[{name:"calledFunction",type:"Expression"},{name:"binding",type:"Binding",isMany:!0}]},{name:"OrganisationalUnit",superClass:["BusinessContextElement"],properties:[{name:"decisionMade",type:"Decision",isReference:!0,isMany:!0},{name:"decisionOwned",type:"Decision",isReference:!0,isMany:!0}]},{name:"Import",superClass:["NamedElement"],properties:[{name:"importType",type:"String",isAttr:!0},{name:"locationURI",type:"String",isAttr:!0},{name:"namespace",type:"String",isAttr:!0}]},{name:"InformationRequirement",superClass:["DMNElement"],properties:[{name:"requiredDecision",type:"DMNElementReference",xml:{serialize:"property"}},{name:"requiredInput",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"ElementCollection",superClass:["NamedElement"],properties:[{name:"drgElement",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}}]},{name:"DRGElement",isAbstract:!0,superClass:["NamedElement"],properties:[]},{name:"InputData",superClass:["DRGElement"],properties:[{name:"variable",type:"InformationItem",xml:{serialize:"property"}}]},{name:"DMNElement",isAbstract:!0,properties:[{name:"description",type:"String"},{name:"extensionElements",type:"ExtensionElements"},{name:"id",type:"String",isAttr:!0,isId:!0},{name:"extensionAttribute",type:"ExtensionAttribute",isMany:!0},{name:"label",isAttr:!0,type:"String"}]},{name:"InputClause",superClass:["DMNElement"],properties:[{name:"inputExpression",type:"LiteralExpression",xml:{serialize:"property"}},{name:"inputValues",type:"UnaryTests",xml:{serialize:"property"}}]},{name:"DecisionTable",superClass:["Expression"],properties:[{name:"input",type:"InputClause",isMany:!0,xml:{serialize:"property"}},{name:"output",type:"OutputClause",isMany:!0,xml:{serialize:"property"}},{name:"annotation",type:"RuleAnnotationClause",isMany:!0,xml:{serialize:"property"}},{name:"rule",type:"DecisionRule",isMany:!0,xml:{serialize:"property"}},{name:"hitPolicy",type:"HitPolicy",isAttr:!0,default:"UNIQUE"},{name:"aggregation",type:"BuiltinAggregator",isAttr:!0},{name:"preferredOrientation",type:"DecisionTableOrientation",isAttr:!0},{name:"outputLabel",isAttr:!0,type:"String"}]},{name:"LiteralExpression",superClass:["Expression"],properties:[{name:"expressionLanguage",type:"String",isAttr:!0},{name:"text",type:"String"},{name:"importedValues",type:"ImportedValues"}]},{name:"Binding",properties:[{name:"parameter",type:"InformationItem",xml:{serialize:"property"}},{name:"bindingFormula",type:"Expression"}]},{name:"KnowledgeRequirement",superClass:["DMNElement"],properties:[{name:"requiredKnowledge",type:"DMNElementReference",xml:{serialize:"property"}}]},{name:"BusinessKnowledgeModel",superClass:["Invocable"],properties:[{name:"encapsulatedLogic",type:"FunctionDefinition",xml:{serialize:"property"}},{name:"knowledgeRequirement",type:"KnowledgeRequirement",isMany:!0},{name:"authorityRequirement",type:"AuthorityRequirement",isMany:!0}]},{name:"BusinessContextElement",isAbstract:!0,superClass:["NamedElement"],properties:[{name:"URI",type:"String",isAttr:!0}]},{name:"PerformanceIndicator",superClass:["BusinessContextElement"],properties:[{name:"impactingDecision",type:"DMNElementReference",isMany:!0,xml:{serialize:"property"}}]},{name:"FunctionDefinition",superClass:["Expression"],properties:[{name:"formalParameter",type:"InformationItem",isMany:!0,xml:{serialize:"property"}},{name:"body",type:"Expression"},{name:"kind",type:"FunctionKind",isAttr:!0}]},{name:"Context",superClass:["Expression"],properties:[{name:"contextEntry",type:"ContextEntry",isMany:!0}]},{name:"ContextEntry",superClass:["DMNElement"],properties:[{name:"variable",type:"InformationItem",xml:{serialize:"property"}},{name:"value",type:"Expression"}]},{name:"List",superClass:["Expression"],properties:[{name:"elements",isMany:!0,type:"Expression"}]},{name:"Relation",superClass:["Expression"],properties:[{name:"column",type:"InformationItem",isMany:!0,xml:{serialize:"property"}},{name:"row",type:"List",isMany:!0,xml:{serialize:"property"}}]},{name:"OutputClause",superClass:["DMNElement"],properties:[{name:"outputValues",type:"UnaryTests",xml:{serialize:"property"}},{name:"defaultOutputEntry",type:"LiteralExpression",xml:{serialize:"property"}},{name:"name",isAttr:!0,type:"String"},{name:"typeRef",isAttr:!0,type:"String"}]},{name:"UnaryTests",superClass:["Expression"],prop