UNPKG

vmes-flowable

Version:

ceshibao

2 lines 161 kB
/*! jeeplus工作流设计器 | Copyright (c) 2020| jeeplus.org/license */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).BpmnJS=t()}(this,(function(){"use strict";var e=Object.prototype.toString,t=Object.prototype.hasOwnProperty;function n(e){return void 0!==e}function i(t){return"[object Array]"===e.call(t)}function r(t){return"[object Object]"===e.call(t)}function a(t){return"[object Number]"===e.call(t)}function o(t){var n=e.call(t);return"[object Function]"===n||"[object AsyncFunction]"===n||"[object GeneratorFunction]"===n||"[object AsyncGeneratorFunction]"===n||"[object Proxy]"===n}function s(t){return"[object String]"===e.call(t)}function p(e,n){return t.call(e,n)}function l(e,t){var n;return t=function(e){return o(e)?e:function(t){return t===e}}(t),u(e,(function(e,i){if(t(e,i))return n=e,!1})),n}function c(e,t){var n=[];return u(e,(function(e,i){t(e,i)&&n.push(e)})),n}function u(e,t){var n;if(void 0!==e){var r=i(e)?y:d;for(var a in e)if(p(e,a)&&!1===t(n=e[a],r(a)))return n}}function h(e,t,n){return u(e,(function(e,i){n=t(n,e,i)})),n}function m(e,t){return!!h(e,(function(e,n,i){return e&&t(n,i)}),!0)}function f(e){return function(t){return m(e,(function(e,n){return t[n]===e}))}}function d(e){return e}function y(e){return Number(e)}function g(e,t){return e.bind(t)}function v(){return(v=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}).apply(this,arguments)}function x(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 v.apply(void 0,[e].concat(n))}var E=[].indexOf,b=function(e,t){if(E)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},w=/\s+/,A=Object.prototype.toString;function _(e){return new S(e)}function S(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function R(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e}S.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~b(t,e)||t.push(e),this.el.className=t.join(" "),this},S.prototype.remove=function(e){if("[object RegExp]"==A.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=b(t,e);return~n&&t.splice(n,1),this.el.className=t.join(" "),this},S.prototype.removeMatching=function(e){for(var t=this.array(),n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},S.prototype.toggle=function(e,t){return this.list?(void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(void 0!==t?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},S.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(w);return""===e[0]&&e.shift(),e},S.prototype.has=S.prototype.contains=function(e){return this.list?this.list.contains(e):!!~b(this.array(),e)};var C="undefined"!=typeof Element?Element.prototype:{},M=C.matches||C.matchesSelector||C.webkitMatchesSelector||C.mozMatchesSelector||C.msMatchesSelector||C.oMatchesSelector,k=function(e,t){if(!e||1!==e.nodeType)return!1;if(M)return M.call(e,t);for(var n=e.parentNode.querySelectorAll(t),i=0;i<n.length;i++)if(n[i]==e)return!0;return!1};var P=window.addEventListener?"addEventListener":"attachEvent",T=window.removeEventListener?"removeEventListener":"detachEvent",N="addEventListener"!==P?"on":"",D=function(e,t,n,i){return e[P](N+t,n,i||!1),n},O=function(e,t,n,i){return e[T](N+t,n,i||!1),n},B=["focus","blur"];var L,I={bind:function(e,t,n,i,r){return-1!==B.indexOf(n)&&(r=!0),D(e,n,(function(n){var r=n.target||n.srcElement;n.delegateTarget=function(e,t,n){for(var i=n?e:e.parentNode;i&&i.nodeType!==document.DOCUMENT_NODE&&i.nodeType!==document.DOCUMENT_FRAGMENT_NODE;){if(k(i,t))return i;i=i.parentNode}return k(i,t)?i:null}(r,t,!0),n.delegateTarget&&i.call(e,n)}),r)},unbind:function(e,t,n,i){return-1!==B.indexOf(t)&&(i=!0),O(e,t,n,i)}},F=function(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var i=n[1];if("body"==i){return(r=t.createElement("html")).innerHTML=e,r.removeChild(r.lastChild)}var r,a=V[i]||V._default,o=a[0],s=a[1],p=a[2];(r=t.createElement("div")).innerHTML=s+e+p;for(;o--;)r=r.lastChild;if(r.firstChild==r.lastChild)return r.removeChild(r.firstChild);var l=t.createDocumentFragment();for(;r.firstChild;)l.appendChild(r.removeChild(r.firstChild));return l},j=!1;"undefined"!=typeof document&&((L=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',j=!L.getElementsByTagName("link").length,L=void 0);var V={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:j?[1,"X<div>","</div>"]:[0,"",""]};function W(e,t){return(t=t||document).querySelector(e)}function G(e){e.parentNode&&e.parentNode.removeChild(e)}function z(e,t){return t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t))}function $(e,t){return z(t,e),e}V.td=V.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],V.option=V.optgroup=[1,'<select multiple="multiple">',"</select>"],V.thead=V.tbody=V.colgroup=V.caption=V.tfoot=[1,"<table>","</table>"],V.polyline=V.ellipse=V.polygon=V.circle=V.text=V.line=V.path=V.rect=V.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var H={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":2,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":2,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function K(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=H[i];r?(2===r&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function U(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return H[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);K(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)K(e,i,t[i])}(e,t);return e}function q(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1}var Y=/\s+/,X=Object.prototype.toString;function Z(e){return void 0!==e}function J(e){return new Q(e)}function Q(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function ee(e){var t=e.parentNode;return t&&t.removeChild(e),e}Q.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~q(t,e)||t.push(e),Z(this.el.className.baseVal)?this.el.className.baseVal=t.join(" "):this.el.className=t.join(" "),this},Q.prototype.remove=function(e){if("[object RegExp]"===X.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=q(t,e);return~n&&t.splice(n,1),this.el.className.baseVal=t.join(" "),this},Q.prototype.removeMatching=function(e){for(var t=this.array(),n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Q.prototype.toggle=function(e,t){return this.list?(Z(t)?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(Z(t)?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},Q.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(Y);return""===e[0]&&e.shift(),e},Q.prototype.has=Q.prototype.contains=function(e){return this.list?this.list.contains(e):!!~q(this.array(),e)};var te="http://www.w3.org/2000/svg",ne='<svg xmlns="'+te+'"';function ie(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(te)&&(e=ne+e.substring(4)):(e=ne+">"+e+"</svg>",t=!0);var n=function(e){var t;return(t=new DOMParser).async=!1,t.parseFromString(e,"text/xml")}(e);if(!t)return n;for(var i=document.createDocumentFragment(),r=n.firstChild;r.firstChild;)i.appendChild(r.firstChild);return i}function re(e,t){var n;return"<"===e.charAt(0)?(n=ie(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(te,e),t&&U(n,t),n}var ae=re("svg");function oe(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}function se(e){return e?ae.createSVGTransformFromMatrix(e):ae.createSVGTransform()}var pe=/([&<>]{1})/g,le=/([\n\r"]{1})/g,ce={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function ue(e,t){return e.replace(t,(function(e,t){return ce[t]||t}))}function he(e,t){var n,i,r,a,o;switch(e.nodeType){case 3:t.push(ue(e.textContent,pe));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(n=0,i=(r=e.attributes).length;n<i;++n)a=r.item(n),t.push(" ",a.name,'="',ue(a.value,le),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(o=e.childNodes).length;n<i;++n)he(o.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",ue(e.nodeValue,pe),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function me(e,t){var n=ie(t);if(function(e){for(var t;t=e.firstChild;)ee(t)}(e),t){(function(e){return"#document-fragment"===e.nodeName})(n)||(n=n.documentElement);for(var i,r=(i=n.childNodes,Array.prototype.slice.call(i)),a=0;a<r.length;a++)z(r[a],e)}}function fe(e,t){if(void 0!==t){try{me(e,t)}catch(e){throw new Error("error parsing SVG: "+e.message)}return e}return function(e){for(var t=e.firstChild,n=[];t;)he(t,n),t=t.nextSibling;return n.join("")}(e)}function de(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function ye(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),function(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(de(e,i))}(n,t)),n.consolidate()}var ge=/^class /;function ve(e){return"[object Array]"===Object.prototype.toString.call(e)}function xe(){var e=Array.prototype.slice.call(arguments);1===e.length&&ve(e[0])&&(e=e[0]);var t=e.pop();return t.$inject=e,t}var Ee=/constructor\s*[^(]*\(\s*([^)]*)\)/m,be=/^function\s*[^(]*\(\s*([^)]*)\)/m,we=/\/\*([^*]*)\*\//m;function Ae(e){if("function"!=typeof e)throw new Error('Cannot annotate "'+e+'". Expected a function!');var t=e.toString().match(function(e){return ge.test(e.toString())}(e)?Ee:be);return t&&t[1]&&t[1].split(",").map((function(e){return(t=e.match(we))?t[1].trim():e.trim()}))||[]}function _e(){var e=[];this.factory=function(t,n){return e.push([t,"factory",n]),this},this.value=function(t,n){return e.push([t,"value",n]),this},this.type=function(t,n){return e.push([t,"type",n]),this},this.forEach=function(t){e.forEach(t)}}var Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function Re(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function Ce(e,t){t=t||{get:function(e,t){if(n.push(e),!1===t)return null;throw o('No provider for "'+e+'"!')}};var n=[],i=this._providers=Object.create(t._providers||null),r=this._instances=Object.create(null),a=r.injector=this,o=function(e){var t=n.join(" -> ");return n.length=0,new Error(t?e+" (Resolving: "+t+")":e)},s=function e(a,s){if(!i[a]&&-1!==a.indexOf(".")){for(var p=a.split("."),l=e(p.shift());p.length;)l=l[p.shift()];return l}if(Me(r,a))return r[a];if(Me(i,a)){if(-1!==n.indexOf(a))throw n.push(a),o("Cannot resolve circular dependency!");return n.push(a),r[a]=i[a][0](i[a][1]),n.pop(),r[a]}return t.get(a,s)},p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("function"!=typeof e){if(!ve(e))throw new Error('Cannot invoke "'+e+'". Expected a function!');e=xe(e.slice())}var n=e.$inject||Ae(e),i=n.map((function(e){return Me(t,e)?t[e]:s(e)}));return{fn:e,dependencies:i}},l=function(e){var t=p(e),n=t.dependencies,i=t.fn;return new(Function.prototype.bind.apply(i,[null].concat(Re(n))))},c=function(e,t,n){var i=p(e,n),r=i.dependencies,a=i.fn;return a.call.apply(a,[t].concat(Re(r)))},u=function(e){return xe((function(t){return e.get(t)}))},h={factory:c,type:l,value:function(e){return e}};e.forEach((function(e){function t(e,t){return"value"!==e&&ve(t)&&(t=xe(t.slice())),t}if(e instanceof _e)e.forEach((function(e){var n=e[0],r=e[1],a=e[2];i[n]=[h[r],t(r,a),r]}));else if("object"===(void 0===e?"undefined":Se(e)))if(e.__exports__){var n=Object.keys(e).reduce((function(t,n){return"__"!==n.substring(0,2)&&(t[n]=e[n]),t}),Object.create(null)),r=new Ce((e.__modules__||[]).concat([n]),a),o=xe((function(e){return r.get(e)}));e.__exports__.forEach((function(e){i[e]=[o,e,"private",r]}))}else Object.keys(e).forEach((function(n){if("private"!==e[n][2]){var r=e[n][0],a=e[n][1];i[n]=[h[r],t(r,a),r]}else i[n]=e[n]}))})),this.get=s,this.invoke=c,this.instantiate=l,this.createChild=function(e,t){if(t&&t.length){var n,r,o,s,p=Object.create(null),l=Object.create(null),c=[],h=[],m=[];for(var f in i)n=i[f],-1!==t.indexOf(f)&&("private"===n[2]?-1===(r=c.indexOf(n[3]))?(o=n[3].createChild([],t),s=u(o),c.push(n[3]),h.push(o),m.push(s),p[f]=[s,f,"private",o]):p[f]=[m[r],f,"private",h[r]]:p[f]=[n[2],n[1]],l[f]=!0),"factory"!==n[2]&&"type"!==n[2]||!n[1].$scope||t.forEach((function(e){-1!==n[1].$scope.indexOf(e)&&(p[f]=[n[2],n[1]],l[e]=!0)}));t.forEach((function(e){if(!l[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')})),e.unshift(p)}return new Ce(e,a)}}function Me(e,t){return Object.hasOwnProperty.call(e,t)}var ke=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}}));function Pe(e,t){var n=this;t=t||1e3,e.on(["render.shape","render.connection"],t,(function(e,t){var i=e.type,r=t.element,a=t.gfx;if(n.canRender(r))return"render.shape"===i?n.drawShape(a,r):n.drawConnection(a,r)})),e.on(["render.getShapePath","render.getConnectionPath"],t,(function(e,t){if(n.canRender(t))return"render.getShapePath"===e.type?n.getShapePath(t):n.getConnectionPath(t)}))}function Te(e){return e.join(",").replace(/,?([A-z]),?/g,"$1")}function Ne(e){for(var t,n="",i=0;t=e[i];i++)n+=t.x+","+t.y+" ";return n}function De(e,t){var n=re("polyline");return U(n,{points:Ne(e)}),t&&U(n,t),n}function Oe(e,t){var n,r,a,o;return t=!!t,i(e)||(e=[e]),u(e,(function(e){var i=e;e.waypoints&&!t&&(i=Oe(e.waypoints,!0));var s=i.x,p=i.y,l=i.height||0,c=i.width||0;(s<n||void 0===n)&&(n=s),(p<r||void 0===r)&&(r=p),(s+c>a||void 0===a)&&(a=s+c),(p+l>o||void 0===o)&&(o=p+l)})),{x:n,y:r,height:o-r,width:a-n}}function Be(e){return!(!e||!e.isFrame)}Pe.prototype.canRender=function(){},Pe.prototype.drawShape=function(){},Pe.prototype.drawConnection=function(){},Pe.prototype.getShapePath=function(){},Pe.prototype.getConnectionPath=function(){};function Le(e,t){Pe.call(this,e,1),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}ke(Le,Pe),Le.prototype.canRender=function(){return!0},Le.prototype.drawShape=function(e,t){var n=re("rect");return U(n,{x:0,y:0,width:t.width||0,height:t.height||0}),Be(t)?U(n,this.FRAME_STYLE):U(n,this.SHAPE_STYLE),$(e,n),n},Le.prototype.drawConnection=function(e,t){var n=De(t.waypoints,this.CONNECTION_STYLE);return $(e,n),n},Le.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return Te([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},Le.prototype.getConnectionPath=function(e){var t,n,i=e.waypoints,r=[];for(t=0;n=i[t];t++)n=n.original||n,r.push([0===t?"M":"L",n.x,n.y]);return Te(r)},Le.$inject=["eventBus","styles"];var Ie={__init__:["defaultRenderer"],defaultRenderer:["type",Le],styles:["type",function(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(e,t,n){return x(this.style(t,n),{class:e})},this.style=function(t,n){i(t)||n||(n=t,t=[]);var r=h(t,(function(t,n){return x(t,e[n]||{})}),{});return n?x(r,n):r},this.computeStyle=function(e,n,r){return i(n)||(r=n,n=[]),t.style(n||[],x({},r,e||{}))}}]};function Fe(e,t){return Math.round(e*t)/t}function je(e){return a(e)?e+"px":e}function Ve(e,t,n){var i=re("g");J(i).add(t);var r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}var We={shape:["x","y","width","height"],connection:["waypoints"]};function Ge(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._init(e||{})}function ze(e,t){var n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}Ge.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],Ge.prototype._init=function(e){var t=this._eventBus,n=this._container=function(e){var t=(e=x({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container"),x(n.style,{position:"relative",overflow:"hidden",width:je(e.width),height:je(e.height)}),t.appendChild(n),n}(e),i=this._svg=re("svg");U(i,{width:"100%",height:"100%"}),$(n,i);var r=this._viewport=Ve(i,"viewport");this._layers={},!1!==e.deferUpdate&&(this._viewboxChanged=function(e,t){var n,i,r,a;function o(){var o=Date.now(),p=a+t-o;if(p>0)return s(p);e.apply(r,i),n=a=i=r=void 0}function s(e){n=setTimeout(o,e)}return function(){a=Date.now();for(var e=arguments.length,o=new Array(e),p=0;p<e;p++)o[p]=arguments[p];i=o,r=this,n||s(t)}}(g(this._viewboxChanged,this),300)),t.on("diagram.init",(function(){t.fire("canvas.init",{svg:i,viewport:r})}),this),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed"],(function(){delete this._cachedViewbox}),this),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},Ge.prototype._destroy=function(e){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});var t=this._container.parentNode;t&&t.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._rootElement,delete this._viewport},Ge.prototype._clear=function(){var e=this;this._elementRegistry.getAll().forEach((function(t){var n=function(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}(t);"root"===n?e.setRootElement(null,!0):e._removeElement(t,n)})),delete this._cachedViewbox},Ge.prototype.getDefaultLayer=function(){return this.getLayer("base",0)},Ge.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");var n=this._layers[e];if(n||(n=this._layers[e]=this._createLayer(e,t)),void 0!==t&&n.index!==t)throw new Error("layer <"+e+"> already created at index <"+t+">");return n.group},Ge.prototype._createLayer=function(e,t){t||(t=0);var n=h(this._layers,(function(e,n){return t>=n.index&&e++,e}),0);return{group:Ve(this._viewport,"layer-"+e,n),index:t}},Ge.prototype.getContainer=function(){return this._container},Ge.prototype._updateMarker=function(e,t,n){var i;e.id||(e=this._elementRegistry.get(e)),(i=this._elementRegistry._elements[e.id])&&(u([i.gfx,i.secondaryGfx],(function(e){e&&(n?J(e).add(t):J(e).remove(t))})),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},Ge.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},Ge.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},Ge.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),J(this.getGraphics(e)).has(t)},Ge.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},Ge.prototype.getRootElement=function(){return this._rootElement||this.setRootElement({id:"__implicitroot",children:[]}),this._rootElement},Ge.prototype.setRootElement=function(e,t){e&&this._ensureValid("root",e);var n=this._rootElement,i=this._elementRegistry,r=this._eventBus;if(n){if(!t)throw new Error("rootElement already set, need to specify override");r.fire("root.remove",{element:n}),r.fire("root.removed",{element:n}),i.remove(n)}if(e){var a=this.getDefaultLayer();r.fire("root.add",{element:e}),i.add(e,a,this._svg),r.fire("root.added",{element:e,gfx:a})}return this._rootElement=e,e},Ge.prototype._ensureValid=function(e,t){if(!t.id)throw new Error("element must have an id");if(this._elementRegistry.get(t.id))throw new Error("element with id "+t.id+" already exists");var n=We[e];if(!m(n,(function(e){return void 0!==t[e]})))throw new Error("must supply { "+n.join(", ")+" } with "+e)},Ge.prototype._setParent=function(e,t,n){!function(e,t,n){if(e&&t){"number"!=typeof n&&(n=-1);var i=e.indexOf(t);if(-1!==i){if(i===n)return;if(-1===n)return;e.splice(i,1)}-1!==n?e.splice(n,0,t):e.push(t)}}(t.children,e,n),e.parent=t},Ge.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();var r=this._eventBus,a=this._graphicsFactory;this._ensureValid(e,t),r.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);var o=a.create(e,t,i);return this._elementRegistry.add(t,o),a.update(e,t,o),r.fire(e+".added",{element:t,gfx:o}),t},Ge.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},Ge.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},Ge.prototype._removeElement=function(e,t){var n=this._elementRegistry,i=this._graphicsFactory,r=this._eventBus;if(e=n.get(e.id||e))return r.fire(t+".remove",{element:e}),i.remove(e),function(e,t){if(!e||!t)return-1;var n=e.indexOf(t);-1!==n&&e.splice(n,1)}(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},Ge.prototype.removeShape=function(e){return this._removeElement(e,"shape")},Ge.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},Ge.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},Ge.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},Ge.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},Ge.prototype.viewbox=function(e){if(void 0===e&&this._cachedViewbox)return this._cachedViewbox;var t,n,i,r,a,o,s=this._viewport,p=this.getSize();return e?(this._changeViewbox((function(){r=Math.min(p.width/e.width,p.height/e.height);var t=this._svg.createSVGMatrix().scale(r).translate(-e.x,-e.y);ye(s,t)})),e):(t=this.getDefaultLayer().getBBox(),n=(i=ye(s))?i.matrix:function(e,t,n,i,r,a){var o=ae.createSVGMatrix();switch(arguments.length){case 0:return o;case 1:return oe(o,e);case 6:return oe(o,{a:e,b:t,c:n,d:i,e:r,f:a})}}(),r=Fe(n.a,1e3),a=Fe(-n.e||0,1e3),o=Fe(-n.f||0,1e3),e=this._cachedViewbox={x:a?a/r:0,y:o?o/r:0,width:p.width/r,height:p.height/r,scale:r,inner:{width:t.width,height:t.height,x:t.x,y:t.y},outer:p})},Ge.prototype.scroll=function(e){var t=this._viewport,n=t.getCTM();return e&&this._changeViewbox((function(){e=x({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),ze(t,n)})),{x:n.e,y:n.f}},Ge.prototype.zoom=function(e,t){return e?"fit-viewport"===e?this._fitViewport(t):(this._changeViewbox((function(){"object"!=typeof t&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)})),Fe(i.a,1e3)):this.viewbox(e).scale;var n,i},Ge.prototype._fitViewport=function(e){var t,n,i=this.viewbox(),r=i.outer,a=i.inner;return a.x>=0&&a.y>=0&&a.x+a.width<=r.width&&a.y+a.height<=r.height&&!e?n={x:0,y:0,width:Math.max(a.width+a.x,r.width),height:Math.max(a.height+a.y,r.height)}:(t=Math.min(1,r.width/a.width,r.height/a.height),n={x:a.x+(e?a.width/2-r.width/t/2:0),y:a.y+(e?a.height/2-r.height/t/2:0),width:r.width/t,height:r.height/t}),this.viewbox(n),this.viewbox(!1).scale},Ge.prototype._setZoom=function(e,t){var n,i,r,a,o=this._svg,s=this._viewport,p=o.createSVGMatrix(),l=o.createSVGPoint(),c=(i=s.getCTM()).a;return t?(n=x(l,t).matrixTransform(i.inverse()),r=p.translate(n.x,n.y).scale(1/c*e).translate(-n.x,-n.y),a=i.multiply(r)):a=p.scale(e),ze(this._viewport,a),a},Ge.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},Ge.prototype.getAbsoluteBBox=function(e){var t,n=this.viewbox();e.waypoints?t=this.getGraphics(e).getBBox():t=e;return{x:t.x*n.scale-n.x*n.scale,y:t.y*n.scale-n.y*n.scale,width:t.width*n.scale,height:t.height*n.scale}},Ge.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var $e="data-element-id";function He(e){this._elements={},this._eventBus=e}He.$inject=["eventBus"],He.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),U(t,$e,i),n&&U(n,$e,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},He.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(U(i.gfx,$e,""),i.secondaryGfx&&U(i.secondaryGfx,$e,""),delete t[n])},He.prototype.updateId=function(e,t){this._validateId(t),"string"==typeof e&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t});var n=this.getGraphics(e),i=this.getGraphics(e,!0);this.remove(e),e.id=t,this.add(e,n,i)},He.prototype.get=function(e){var t;t="string"==typeof e?e:e&&U(e,$e);var n=this._elements[t];return n&&n.element},He.prototype.filter=function(e){var t=[];return this.forEach((function(n,i){e(n,i)&&t.push(n)})),t},He.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),i=0;i<n.length;i++){var r=t[n[i]],a=r.element;if(e(a,r.gfx))return a}},He.prototype.getAll=function(){return this.filter((function(e){return e}))},He.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach((function(n){var i=t[n],r=i.element,a=i.gfx;return e(r,a)}))},He.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},He.prototype._validateId=function(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")};var Ke={extend:function(e,t,n,i){var r=n.inverse;return Object.defineProperty(e,"remove",{value:function(e){var n=this.indexOf(e);return-1!==n&&(this.splice(n,1),t.unset(e,r,i)),e}}),Object.defineProperty(e,"contains",{value:function(e){return-1!==this.indexOf(e)}}),Object.defineProperty(e,"add",{value:function(e,n){var a=this.indexOf(e);if(void 0===n){if(-1!==a)return;n=this.length}-1!==a&&this.splice(a,1),this.splice(n,0,e),-1===a&&t.set(e,r,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e},isExtended:function(e){return!0===e.__refs_collection}};function Ue(e,t,n){var i=Ke.extend(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:i}),i.length&&i.forEach((function(i){e.set(i,t.inverse,n)}))}function qe(e,t){if(!(this instanceof qe))return new qe(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}qe.prototype.bind=function(e,t){if("string"==typeof t){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?Ue(this,t,e):function(e,t,n){var i=t.inverse,r=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return r},set:function(t){if(t!==r){var a=r;r=null,a&&e.unset(a,i,n),r=t,e.set(r,i,n)}}})}(this,t,e)},qe.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return Ke.isExtended(n)||Ue(this,t,e),n},qe.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},qe.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},qe.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Ye=qe,Xe=Ke;Ye.Collection=Xe;var Ze=new Ye({name:"children",enumerable:!0,collection:!0},{name:"parent"}),Je=new Ye({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Qe=new Ye({name:"attachers",collection:!0},{name:"host"}),et=new Ye({name:"outgoing",collection:!0},{name:"source"}),tt=new Ye({name:"incoming",collection:!0},{name:"target"});function nt(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(e){var t=this.label,n=this.labels;!e&&t?n.remove(t):n.add(e,0)}}),Ze.bind(this,"parent"),Je.bind(this,"labels"),et.bind(this,"outgoing"),tt.bind(this,"incoming")}function it(){nt.call(this),Ze.bind(this,"children"),Qe.bind(this,"host"),Qe.bind(this,"attachers")}function rt(){it.call(this)}function at(){it.call(this),Je.bind(this,"labelTarget")}function ot(){nt.call(this),et.bind(this,"source"),tt.bind(this,"target")}ke(it,nt),ke(rt,it),ke(at,it),ke(ot,nt);var st={connection:ot,shape:it,label:at,root:rt};function pt(){this._uid=12}pt.prototype.createRoot=function(e){return this.create("root",e)},pt.prototype.createLabel=function(e){return this.create("label",e)},pt.prototype.createShape=function(e){return this.create("shape",e)},pt.prototype.createConnection=function(e){return this.create("connection",e)},pt.prototype.create=function(e,t){return(t=x({},t||{})).id||(t.id=e+"_"+this._uid++),function(e,t){var n=st[e];if(!n)throw new Error("unknown type: <"+e+">");return x(new n,t)}(e,t)};var lt=Array.prototype.slice;function ct(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}function ut(){}function ht(e,t,n){var i=se();i.setTranslate(t,n),ye(e,i)}function mt(e,t){this._eventBus=e,this._elementRegistry=t}function ft(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}ct.prototype.on=function(e,t,n,r){if(e=i(e)?e:[e],o(t)&&(r=n,n=t,t=1e3),!a(t))throw new Error("priority must be a number");var s=n;r&&((s=g(n,r)).__fn=n.__fn||n);var p=this;e.forEach((function(e){p._addListener(e,{priority:t,callback:s,next:null})}))},ct.prototype.once=function(e,t,n,i){var r=this;if(o(t)&&(i=n,n=t,t=1e3),!a(t))throw new Error("priority must be a number");function s(){var t=n.apply(i,arguments);return r.off(e,s),t}s.__fn=n,this.on(e,t,s)},ct.prototype.off=function(e,t){e=i(e)?e:[e];var n=this;e.forEach((function(e){n._removeListener(e,t)}))},ct.prototype.createEvent=function(e){var t=new ut;return t.init(e),t},ct.prototype.fire=function(e,t){var n,i,r,a;if(a=lt.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 ut?t:this.createEvent(t),a[0]=n;var o=n.type;e!==o&&(n.type=e);try{r=this._invokeListeners(n,a,i)}finally{e!==o&&(n.type=o)}return void 0===r&&n.defaultPrevented&&(r=!1),r}},ct.prototype.handleError=function(e){return!1===this.fire("error",{error:e})},ct.prototype._destroy=function(){this._listeners={}},ct.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},ct.prototype._invokeListener=function(e,t,n){var i;try{void 0!==(i=function(e,t){return e.apply(null,t)}(n.callback,t))&&(e.returnValue=i,e.stopPropagation()),!1===i&&e.preventDefault()}catch(e){if(!this.handleError(e))throw console.error("unhandled error in event listener"),console.error(e.stack),e}return i},ct.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)},ct.prototype._getListeners=function(e){return this._listeners[e]},ct.prototype._setListeners=function(e,t){this._listeners[e]=t},ct.prototype._removeListener=function(e,t){var n,i,r,a=this._getListeners(e);if(t)for(;a;)n=a.next,(r=a.callback)!==t&&r.__fn!==t||(i?i.next=n:this._setListeners(e,n)),i=a,a=n;else this._setListeners(e,null)},ut.prototype.stopPropagation=function(){this.cancelBubble=!0},ut.prototype.preventDefault=function(){this.defaultPrevented=!0},ut.prototype.init=function(e){x(this,e||{})},mt.$inject=["eventBus","elementRegistry"],mt.prototype._getChildrenContainer=function(e){var t,n=this._elementRegistry.getGraphics(e);return e.parent?(t=function(e){return e.parentNode.childNodes[1]}(n))||(J(t=re("g")).add("djs-children"),$(n.parentNode,t)):t=n,t},mt.prototype._clear=function(e){var t=function(e){return e.childNodes[0]}(e);return R(t),t},mt.prototype._createContainer=function(e,t,n,i){var r=re("g");J(r).add("djs-group"),void 0!==n?ft(r,t,t.childNodes[n]):$(t,r);var a=re("g");J(a).add("djs-element"),J(a).add("djs-"+e),i&&J(a).add("djs-frame"),$(r,a);var o=re("g");return J(o).add("djs-visual"),$(a,o),a},mt.prototype.create=function(e,t,n){var i=this._getChildrenContainer(t.parent);return this._createContainer(e,i,n,Be(t))},mt.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry;u(h(e,(function(e,t){return t.parent&&(e[t.parent.id]=t.parent),e}),{}),(function(e){var i=e.children;if(i){var r=t._getChildrenContainer(e);u(i.slice().reverse(),(function(e){ft(n.getGraphics(e).parentNode,r)}))}}))},mt.prototype.drawShape=function(e,t){return this._eventBus.fire("render.shape",{gfx:e,element:t})},mt.prototype.getShapePath=function(e){return this._eventBus.fire("render.getShapePath",e)},mt.prototype.drawConnection=function(e,t){return this._eventBus.fire("render.connection",{gfx:e,element:t})},mt.prototype.getConnectionPath=function(e){return this._eventBus.fire("render.getConnectionPath",e)},mt.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if("shape"===e)this.drawShape(i,t),ht(n,t.x,t.y);else{if("connection"!==e)throw new Error("unknown type: "+e);this.drawConnection(i,t)}t.hidden?U(n,"display","none"):U(n,"display","block")}},mt.prototype.remove=function(e){ee(this._elementRegistry.getGraphics(e).parentNode)};var dt={__depends__:[Ie],__init__:["canvas"],canvas:["type",Ge],elementRegistry:["type",He],elementFactory:["type",pt],eventBus:["type",ct],graphicsFactory:["type",mt]};function yt(e){var t=[],n=[];function i(e){return t.indexOf(e)>=0}e.forEach((function e(r){i(r)||((r.__depends__||[]).forEach(e),i(r)||(!function(e){t.push(e)}(r),(r.__init__||[]).forEach((function(e){n.push(e)}))))}));var r=new Ce(t);return n.forEach((function(e){try{r["string"==typeof e?"get":"invoke"](e)}catch(e){throw console.error("Failed to instantiate component"),console.error(e.stack),e}})),r}function gt(e,t){this.injector=t=t||function(e){return yt([{config:["value",e=e||{}]},dt].concat(e.modules||[]))}(e),this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("diagram.init")}function vt(){}function xt(e,t){this.model=e,this.properties=t}gt.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},gt.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")},vt.prototype.get=function(e){return this.$model.properties.get(this,e)},vt.prototype.set=function(e,t){this.$model.properties.set(this,e,t)},xt.prototype.createType=function(e){var t=this.model,n=this.properties,i=Object.create(vt.prototype);u(e.properties,(function(e){e.isMany||void 0===e.default||(i[e.name]=e.default)})),n.defineModel(i,t),n.defineDescriptor(i,e);var r=e.ns.name;function a(e){n.define(this,"$type",{value:r,enumerable:!0}),n.define(this,"$attrs",{value:{}}),n.define(this,"$parent",{writable:!0}),u(e,g((function(e,t){this.set(t,e)}),this))}return a.prototype=i,a.hasType=i.$instanceOf=this.model.hasType,n.defineModel(a,t),n.defineDescriptor(a,e),a};var Et={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},bt={String:function(e){return e},Boolean:function(e){return"true"===e},Integer:function(e){return parseInt(e,10)},Real:function(e){return parseFloat(e,10)}};function wt(e,t){var n=bt[e];return n?n(t):t}function At(e){return!!Et[e]}function _t(e){return!!bt[e]}function St(e,t){var n,i,r=e.split(/:/);if(1===r.length)n=e,i=t;else{if(2!==r.length)throw new Error("expected <prefix:localName> or <localName>, got "+e);n=r[1],i=r[0]}return{name:e=(i?i+":":"")+n,prefix:i,localName:n}}function Rt(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}function Ct(e,t){this.packageMap={},this.typeMap={},this.packages=[],this.properties=t,u(e,g(this.registerPackage,this))}function Mt(e,t,n){var i=t[n];if(i in e)throw new Error("package with "+n+" <"+i+"> already defined")}function kt(e){this.model=e}function Pt(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function Tt(e){this.properties=new kt(this),this.factory=new xt(this,this.properties),this.registry=new Ct(e,this.properties),this.typeCache={}}Rt.prototype.build=function(){return e=this,t=["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"],n={},i=Object(e),u(t,(function(t){t in i&&(n[t]=e[t])})),n;var e,t,n,i},Rt.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)},Rt.prototype.replaceProperty=function(e,t,n){var i=e.ns,r=this.properties,a=this.propertiesByName,o=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 s=r.indexOf(e);if(-1===s)throw new Error("property <"+i.name+"> not found in property list");r.splice(s,1),this.addProperty(t,n?void 0:s,o),a[i.name]=a[i.localName]=t},Rt.prototype.redefineProperty=function(e,t,n){var i=e.ns.prefix,r=t.split("#"),a=St(r[0],i),o=St(r[1],a.prefix).name,s=this.propertiesByName[o];if(!s)throw new Error("refined property <"+o+"> not found");this.replaceProperty(s,e,n),delete e.redefines},Rt.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},Rt.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]},Rt.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},Rt.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},Rt.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")},Rt.prototype.hasProperty=function(e){return this.propertiesByName[e]},Rt.prototype.addTrait=function(e,t){var n=this.allTypesByName,i=this.allTypes,r=e.name;r in n||(u(e.properties,g((function(n){n=x({},n,{name:n.ns.localName,inherited:t}),Object.defineProperty(n,"definedBy",{value:e});var i=n.replaces,r=n.redefines;i||r?this.redefineProperty(n,i||r,i):(n.isBody&&this.setBodyProperty(n),n.isId&&this.setIdProperty(n),this.addProperty(n))}),this)),i.push(e),n[r]=e)},Ct.prototype.getPackage=function(e){return this.packageMap[e]},Ct.prototype.getPackages=function(){return this.packages},Ct.prototype.registerPackage=function(e){e=x({},e);var t=this.packageMap;Mt(t,e,"prefix"),Mt(t,e,"uri"),u(e.types,g((function(t){this.registerType(t,e)}),this)),t[e.uri]=t[e.prefix]=e,this.packages.push(e)},Ct.prototype.registerType=function(e,t){var n=St((e=x({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:x(e.meta||{})})).name,t.prefix),i=n.name,r={};u(e.properties,g((function(e){var t=St(e.name,n.prefix),i=t.name;At(e.type)||(e.type=St(e.type,t.prefix).name),x(e,{ns:t,name:i}),r[i]=e}),this)),x(e,{ns:n,name:i,propertiesByName:r}),u(e.extends,g((function(e){var t=this.typeMap[e];t.traits=t.traits||[],t.traits.push(i)}),this)),this.definePackage(e,t),this.typeMap[i]=e},Ct.prototype.mapTypes=function(e,t,n){var i=At(e.name)?{name:e.name}:this.typeMap[e.name],r=this;function a(e){return o(e,!0)}function o(n,i){var a=St(n,At(n)?"":e.prefix);r.mapTypes(a,t,i)}if(!i)throw new Error("unknown type <"+e.name+">");u(i.superClass,n?a:o),t(i,!n),u(i.traits,a)},Ct.prototype.getEffectiveDescriptor=function(e){var t=St(e),n=new Rt(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},Ct.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})},kt.prototype.set=function(e,t,n){var i=this.model.getPropertyDescriptor(e,t),r=i&&i.name;void 0===n?i?delete e[r]:delete e.$attrs[t]:i?r in e?e[r]=n:Pt(e,i,n):e.$attrs[t]=n},kt.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&&Pt(e,n,[]),e[i]},kt.prototype.define=function(e,t,n){Object.defineProperty(e,t,n)},kt.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})},kt.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})},Tt.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)},Tt.prototype.getType=function(e){var t=this.typeCache,n=s(e)?e:e.ns.name,i=t[n];return i||(e=this.registry.getEffectiveDescriptor(n),i=t[n]=this.factory.createType(e)),i},Tt.prototype.createAny=function(e,t,n){var i=St(e),a={$type:e,$instanceOf:function(e){return e===this.$type}},o={name:e,isGeneric:!0,ns:{prefix:i.prefix,localName:i.localName,uri:t}};return this.properties.defineDescriptor(a,o),this.properties.defineModel(a,this),this.properties.define(a,"$parent",{enumerable:!1,writable:!0}),u(n,(function(e,t){r(e)&&void 0!==e.value?a[e.name]=e.value:a[t]=e})),a},Tt.prototype.getPackage=function(e){return this.registry.getPackage(e)},Tt.prototype.getPackages=function(){return this.registry.getPackages()},Tt.prototype.getElementDescriptor=function(e){return e.$descriptor},Tt.prototype.hasType=function(e,t){return void 0===t&&(t=e,e=this),t in e.$model.getElementDescriptor(e).allTypesByName},Tt.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]},Tt.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};var Nt=String.fromCharCode,Dt=Object.prototype.hasOwnProperty,Ot=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/gi,Bt={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};function Lt(e,t,n,i){return i?Dt.call(Bt,i)?Bt[i]:"&"+i+";":Nt(t||parseInt(n,16))}function It(e){return e.length>3&&-1!==e.indexOf("&")?e.replace(Ot,Lt):e}Object.keys(Bt).forEach((function(e){Bt[e.toUpperCase()]=Bt[e]}));function Ft(e){return new Error(e)}function jt(e){return"missing namespace for prefix <"+e+">"}function Vt(e){return{get:e,enumerable:!0}}function Wt(e){var t,n={};for(t in e)n[t]=e[t];return n}function Gt(e){return e+"$uri"}function zt(){return{line:0,column:0}}function $t(e){throw e}function Ht(e){if(!this)return new Ht(e);var t,n,i,r,a,o,s,p,l,c=e&&e.proxy,u=$t,h=zt,m=!1,f=!1,d=null,y=!1;function g(e){e instanceof Error||(e=Ft(e)),d=e,u(e,h)}function v(e){a&&(e instanceof Error||(e=Ft(e)),a(e,h))}this.on=function(e,l){if("function"!=typeof l)throw Ft("required args <name, cb>");switch(e){case"openTag":n=l;break;case"text":t=l;break;case"closeTag":i=l;break;case"error":u=l;break;case"warn":a=l;break;case"cdata":r=l;break;case"attention":p=l;break;case"question":s=l;break;case"comment":o=l;break;default:throw Ft("unsupported event: "+e)}return this},this.ns=function(e){if(void 0===e&&(e={}),"object"!=typeof e)throw Ft("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,l=n,this},this.parse=function(e){if("string"!=typeof e)throw Ft("required args <xml=string>");return d=null,function(e){var a,u,d,x,E,b,w,A,_,S,R,C=f?[]:null,M=f?function(e){var t,n,i={};for(t in e)i[n=e[t]]=n,i[Gt(n)]=t;return i}(l):null,k=[],P=0,T=!1,N=!1,D=0,O=0,B="",L=0;function I(){if(null!==R)return R;var e,t,n,i,r,a,o,s,p,c,u,h=f&&M.xmlns,d=f&&m?[]:null,y=L,g=B,x=g.length,E={},b={};e:for(;y<x;y++)if(p=!1,!(32===(c=g.charCodeAt(y))||c<14&&c>8)){for((c<65||c>122||c>90&&c<97)&&95!==c&&58!==c&&(v("illegal first char attribute name"),p=!0),u=y+1;u<x;u++)if(!((c=g.charCodeAt(u))>96&&c<123||c>64&&c<91||c>47&&c<59||46===c||45===c||95===c)){if(32===c||c<14&&c>8){v("missing attribute value"),y=u;continue e}if(61===c)break;v("illegal attribute name char"),p=!0}if("xmlns:xmlns"===(s=g.substring(y,u))&&(v("illegal declaration of xmlns"),p=!0),34===(c=g.charCodeAt(u+1)))-1===(u=g.indexOf('"',y=u+2))&&-1!==(u=g.indexOf("'",y))&&(v("attribute value quote missmatch"),p=!0);else if(39===c)-1===(u=g.indexOf("'",y=u+2))&&-1!==(u=g.indexOf('"',y))&&(v("attribute value quote missmatch"),p=!0);else for(v("missing attribute value quotes"),p=!0,u+=1;u<x&&!(32===(c=g.charCodeAt(u+1))||c<14&&c>8);u++);for(-1===u&&(v("missing closing quotes"),u=x,p=!0),p||(a=g.substring(y,u)),y=u;u+1<x&&!(32===(c=g.charCodeAt(u+1))||c<14&&c>8);u++)y===u&&(v("illegal character after attribute end"),p=!0);if(y=u+1,!p)if(s in b)v("attribute <"+s+"> already defined");else if(b[s]=!0,f)if(m){if(null!==(r="xmlns"===s?"xmlns":120===s.charCodeAt(0)&&"xmlns:"===s.substr(0,6)?s.substr(6):null)){if(e=It(a),t=Gt(r),!(o=l[e])){if("xmlns"===r||t in M&&M[t]!==e)do{o="ns"+P++}while(void 0!==M[o]);else o=r;l[e]=o}M[r]!==o&&(i||(M=Wt(M),i=!0),M[r]=o,"xmlns"===r&&(M[Gt(o)]=e,h=o),M[t]=e),E[s]=a;continue}d.push(s,a)}else-1!==(c=s.indexOf(":"))?(n=M[s.substring(0,c)])?("xsi:type"===(s=h===n?s.substr(c+1):n+s.substr(c))&&(-1!==(c=a.indexOf(":"))?(n=a.substring(0,c),a=(n=M[n]||n)+a.substring(c)):a=h+":"+a),E[s]=a):v(jt(s.substring(0,c))):E[s]=a;else E[s]=a}if(m)for(y=0,x=d.length;y<x;y++){if(s=d[y++],a=d[y],-1!==(c=s.indexOf(":"))){if(!(n=M[s.substring(0,c)])){v(jt(s.substring(0,c)));continue}"xsi:type"===(s=h===n?s.substr(c+1):n+s.substr(c))&&(-1!==(c=a.indexOf(":"))?(n=a.substring(0,c),a=(n=M[n]||n)+a.substring(c)):a=h+":"+a)}E[s]=a}return R=E}function F(){for(var t,n,i=/(\r\n|\r|\n)/g,r=0,a=0,o=0,s=O;D>=o&&(t=i.exec(e))&&!((s=t[0].length+t.index)>D);)r+=1,o=s;return-1==D?(a=s,n=e.substring(O)):0===O?n=e.substring(O,D):(a=D-o,n=-1==O?e.substring(D):e.substring(D,O+1)),{data:n,line:r,column:a}}h=F,c&&(S=Object.create({},{name:Vt((function(){return A})),originalName:Vt((function(){return _})),attrs:Vt(I),ns:Vt((function(){return M}))}));for(;-1!==O;){if(-1===(D=60===e.charCodeAt(O)?O:e.indexOf("<",O)))return k.length?g("unexpected end of file"):0===O?g("missing start tag"):void(O<e.length&&e.substring(O).trim()&&v("non-whitespace outside of root node"));if(O!==D)if(k.length){if(t&&(t(e.substring(O,D),It,h),y))return}else if(e.substring(O,D).trim()&&(v("non-whitespace outside of root node"),y))return;if(33===(E=e.charCodeAt(D+1))){if(91===(x=e.charCodeAt(D+2))&&"CDATA["===e.substr(D+3,6)){if(-1===(O=e.indexOf("]]>",D)))return g("unclosed cdata");if(r&&(r(e.substring(D+9,O),h),y))return;O+=3;continue}if(45===x&&45===e.charCodeAt(D+3)){if(-1===(O=e.indexOf("--\x3e",D)))return g("unclosed comment");if(o&&(o(e.substring(D+4,O),It,h),y))return;O+=3;continue}}if(63!==E){for(u=D+1;;u++){if(b=e.charCodeAt(u),isNaN(b))return O=-1,g("unclosed tag");if(34===b)x=e.indexOf('"',u+1),u=-1!==x?x:u;else if(39===b)x=e.indexOf("'",u+1),u=-1!==x?x:u;else if(62===b){O=u;break}}if(33!==E){if(R={},47===E){if(T=!1,N=!0,!k.length)return g("missing open tag");if(u=A=k.pop(),x=D+2+u.length,e.substring(D+2,x)!==u)return g("closing tag mismatch");for(;x<O;x++)if(!(32===(E=e.charCodeAt(x))||E>8&&E<14))return g("close tag")}else{if(47===e.charCodeAt(O-1)?(u=A=e.substring(D+1,O-1),T=!0,N=!0):(u=A=e.substring(D+1,O),T=!0,N=!1),!(E>96&&E<123||E>64&&E<91||95===E||58===E))return g("illegal first char nodeName");for(x=1,d=u.length;x<d;x++)if(!((E=u.charCodeAt(x))>96&&E<123||E>64&&E<91||E>47&&E<59||45===E||95===E||46==E)){if(32===E||E<14&&E>8){A=u.substring(0,x),R=null;break}return g("invalid nodeName")}N||k.push(A)}if(f){if(a=M,T&&(N||C.push(a),null===R&&(m=-1!==u.indexOf("xmlns",x))&&(L=x,B=u,I(),m=!1)),_=A,-1!==(E=A.indexOf(":"))){if(!(w=M[A.substring(0,E)]))return g("missing namespace on <"+_+">");A=A.substr(E+1)}else w=M.xmlns;w&&(A=w+":"+A)}if(T&&(L=x,B=u,n&&(c?n(S,It,N,h):n(A,I,It,N,h),y)))return;if(N){if(i&&(i(c?S:A,It,T,h),y))return;f&&(M=T?a:C.pop())}O+=1}else{if(p&&(p(e.substring(D,O+1),It,h),y))return;O+=1}}else{if(-1===(O=e.indexOf("?>",D)))return g("unclosed question");if(s&&(s(e.substring(D,O+2),h),y))return;O+=2}}}(e),h=zt,y=!1,d},this.stop=function(){y=!0}}function Kt(e){return e.xml&&"lowerCase"===e.xml.tagAlias}var Ut={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"};function qt(e