UNPKG

bpmn-js

Version:

A bpmn 2.0 toolkit and web modeler

2 lines 163 kB
/*! bpmn-js - bpmn-viewer v6.0.2 | Copyright (c) 2014-present, camunda Services GmbH | bpmn.io/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 b=[].indexOf,E=function(e,t){if(b)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~E(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=E(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):!!~E(this.array(),e)};var C=Element.prototype,M=C.matchesSelector||C.webkitMatchesSelector||C.mozMatchesSelector||C.msMatchesSelector||C.oMatchesSelector,k=function(e,t){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,T=window.addEventListener?"addEventListener":"attachEvent",N=window.removeEventListener?"removeEventListener":"detachEvent",D="addEventListener"!==T?"on":"",O={bind:function(e,t,n,i){return e[T](D+t,n,i||!1),n},unbind:function(e,t,n,i){return e[N](D+t,n,i||!1),n}},B=["focus","blur"],L={bind:function(e,t,n,i,r){return-1!==B.indexOf(n)&&(r=!0),O.bind(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!==document;){if(k(i,t))return i;i=i.parentNode}}(r,t,!0),n.delegateTarget&&i.call(e,n)},r)},unbind:function(e,t,n,i){-1!==B.indexOf(t)&&(i=!0),O.unbind(e,t,n,i)}},I=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){var r=t.createElement("html");return r.innerHTML=e,r.removeChild(r.lastChild)}var a=j[i]||j._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},F=!1;"undefined"!=typeof document&&((P=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',F=!P.getElementsByTagName("link").length,P=void 0);var j={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:F?[1,"X<div>","</div>"]:[0,"",""]};j.td=j.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],j.option=j.optgroup=[1,'<select multiple="multiple">',"</select>"],j.thead=j.tbody=j.colgroup=j.caption=j.tfoot=[1,"<table>","</table>"],j.polyline=j.ellipse=j.polygon=j.circle=j.text=j.line=j.path=j.rect=j.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var V="undefined"!=typeof Element?Element.prototype:{};V.matches||V.matchesSelector||V.webkitMatchesSelector||V.mozMatchesSelector||V.msMatchesSelector||V.oMatchesSelector;function W(e,t){return(t=t||document).querySelector(e)}function z(e){e.parentNode&&e.parentNode.removeChild(e)}function G(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 G(t,e),e}var H=2,K={"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":H,"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":H,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function U(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=K[i];r?(r===H&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function q(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return K[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);U(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)U(e,i,t[i])}(e,t);return e}function Y(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 X=/\s+/,Z=Object.prototype.toString;function J(e){return void 0!==e}function Q(e){return new ee(e)}function ee(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function te(e){var t=e.parentNode;return t&&t.removeChild(e),e}ee.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~Y(t,e)||t.push(e),J(this.el.className.baseVal)?this.el.className.baseVal=t.join(" "):this.el.className=t.join(" "),this},ee.prototype.remove=function(e){if("[object RegExp]"===Z.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=Y(t,e);return~n&&t.splice(n,1),this.el.className.baseVal=t.join(" "),this},ee.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},ee.prototype.toggle=function(e,t){return this.list?(J(t)?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(J(t)?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},ee.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(X);return""===e[0]&&e.shift(),e},ee.prototype.has=ee.prototype.contains=function(e){return this.list?this.list.contains(e):!!~Y(this.array(),e)};var ne={svg:"http://www.w3.org/2000/svg"},ie='<svg xmlns="'+ne.svg+'"';function re(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(ne.svg)&&(e=ie+e.substring(4)):(e=ie+">"+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 ae(e,t){var n;return"<"===e.charAt(0)?(n=re(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(ne.svg,e),t&&q(n,t),n}var oe=ae("svg");function se(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}function pe(e){return e?oe.createSVGTransformFromMatrix(e):oe.createSVGTransform()}var le=/([&<>]{1})/g,ce=/([\n\r"]{1})/g,ue={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function he(e,t){return e.replace(t,function(e,t){return ue[t]||t})}function me(e,t){var n,i,r,a,o;switch(e.nodeType){case 3:t.push(he(e.textContent,le));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,'="',he(a.value,ce),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(o=e.childNodes).length;n<i;++n)me(o.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",he(e.nodeValue,le),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function fe(e,t){var n=re(t);if(function(e){for(var t;t=e.firstChild;)te(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++)G(r[a],e)}}function de(e,t){if(void 0!==t){try{fe(e,t)}catch(e){throw new Error("error parsing SVG: "+e.message)}return e}return function(e){for(var t=e.firstChild,n=[];t;)me(t,n),t=t.nextSibling;return n.join("")}(e)}function ye(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function ge(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(ye(e,i))}(n,t)),n.consolidate()}var ve=/^class /;function xe(e){return"[object Array]"===Object.prototype.toString.call(e)}function be(){var e=Array.prototype.slice.call(arguments);1===e.length&&xe(e[0])&&(e=e[0]);var t=e.pop();return t.$inject=e,t}var Ee=/constructor\s*[^(]*\(\s*([^)]*)\)/m,we=/^function\s*[^(]*\(\s*([^)]*)\)/m,Ae=/\/\*([^*]*)\*\//m;function _e(e){if("function"!=typeof e)throw new Error('Cannot annotate "'+e+'". Expected a function!');var t=e.toString().match(function(e){return ve.test(e.toString())}(e)?Ee:we);return t&&t[1]&&t[1].split(",").map(function(e){return(t=e.match(Ae))?t[1].trim():e.trim()})||[]}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(!xe(e))throw new Error('Cannot invoke "'+e+'". Expected a function!');e=be(e.slice())}var n=e.$inject||_e(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 be(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&&xe(t)&&(t=be(t.slice())),t}if(e instanceof function(){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)}})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=be(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){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}),Pe=1e3;function Te(e,t){var n=this;t=t||Pe,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 Ne(e){return e.join(",").replace(/,?([A-z]),?/g,"$1")}function De(e){for(var t,n="",i=0;t=e[i];i++)n+=t.x+","+t.y+" ";return n}function Oe(e,t){var n=ae("polyline");return q(n,{points:De(e)}),t&&q(n,t),n}function Be(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=Be(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 Le(e){return!(!e||!e.isFrame)}Te.prototype.canRender=function(){},Te.prototype.drawShape=function(){},Te.prototype.drawConnection=function(){},Te.prototype.getShapePath=function(){},Te.prototype.getConnectionPath=function(){};var Ie=1;function Fe(e,t){Te.call(this,e,Ie),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(Fe,Te),Fe.prototype.canRender=function(){return!0},Fe.prototype.drawShape=function(e,t){var n=ae("rect");return q(n,{x:0,y:0,width:t.width||0,height:t.height||0}),Le(t)?q(n,this.FRAME_STYLE):q(n,this.SHAPE_STYLE),$(e,n),n},Fe.prototype.drawConnection=function(e,t){var n=Oe(t.waypoints,this.CONNECTION_STYLE);return $(e,n),n},Fe.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return Ne([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},Fe.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 Ne(r)},Fe.$inject=["eventBus","styles"];var je={__init__:["defaultRenderer"],defaultRenderer:["type",Fe],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 Ve(e,t){return Math.round(e*t)/t}function We(e){return a(e)?e+"px":e}function ze(e,t,n){var i=ae("g");Q(i).add(t);var r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}var Ge={shape:["x","y","width","height"],connection:["waypoints"]};function $e(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._init(e||{})}function He(e,t){var n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}$e.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],$e.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:We(e.width),height:We(e.height)}),t.appendChild(n),n}(e),i=this._svg=ae("svg");q(i,{width:"100%",height:"100%"}),$(n,i);var r=this._viewport=ze(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)},$e.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},$e.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},$e.prototype.getDefaultLayer=function(){return this.getLayer("base",0)},$e.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},$e.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:ze(this._viewport,"layer-"+e,n),index:t}},$e.prototype.getContainer=function(){return this._container},$e.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?Q(e).add(t):Q(e).remove(t))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},$e.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},$e.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},$e.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),Q(this.getGraphics(e)).has(t)},$e.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},$e.prototype.getRootElement=function(){return this._rootElement||this.setRootElement({id:"__implicitroot",children:[]}),this._rootElement},$e.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},$e.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=Ge[e];if(!m(n,function(e){return void 0!==t[e]}))throw new Error("must supply { "+n.join(", ")+" } with "+e)},$e.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},$e.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},$e.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},$e.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},$e.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},$e.prototype.removeShape=function(e){return this._removeElement(e,"shape")},$e.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},$e.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},$e.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},$e.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},$e.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);ge(s,t)}),e):(t=this.getDefaultLayer().getBBox(),n=(i=ge(s))?i.matrix:function(e,t,n,i,r,a){var o=oe.createSVGMatrix();switch(arguments.length){case 0:return o;case 1:return se(o,e);case 6:return se(o,{a:e,b:t,c:n,d:i,e:r,f:a})}}(),r=Ve(n.a,1e3),a=Ve(-n.e||0,1e3),o=Ve(-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})},$e.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),He(t,n)}),{x:n.e,y:n.f}},$e.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)}),Ve(i.a,1e3)):this.viewbox(e).scale;var n,i},$e.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},$e.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),He(this._viewport,a),a},$e.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},$e.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}},$e.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var Ke="data-element-id";function Ue(e){this._elements={},this._eventBus=e}Ue.$inject=["eventBus"],Ue.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),q(t,Ke,i),n&&q(n,Ke,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},Ue.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(q(i.gfx,Ke,""),i.secondaryGfx&&q(i.secondaryGfx,Ke,""),delete t[n])},Ue.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)},Ue.prototype.get=function(e){var t;t="string"==typeof e?e:e&&q(e,Ke);var n=this._elements[t];return n&&n.element},Ue.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},Ue.prototype.getAll=function(){return this.filter(function(e){return e})},Ue.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)})},Ue.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},Ue.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 qe={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 Ye(e,t,n){var i=qe.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 Xe(e,t){if(!(this instanceof Xe))return new Xe(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}Xe.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?Ye(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)},Xe.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return qe.isExtended(n)||Ye(this,t,e),n},Xe.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},Xe.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},Xe.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Ze=Xe,Je=qe;Ze.Collection=Je;var Qe=new Ze({name:"children",enumerable:!0,collection:!0},{name:"parent"}),et=new Ze({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),tt=new Ze({name:"attachers",collection:!0},{name:"host"}),nt=new Ze({name:"outgoing",collection:!0},{name:"source"}),it=new Ze({name:"incoming",collection:!0},{name:"target"});function rt(){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)}}),Qe.bind(this,"parent"),et.bind(this,"labels"),nt.bind(this,"outgoing"),it.bind(this,"incoming")}function at(){rt.call(this),Qe.bind(this,"children"),tt.bind(this,"host"),tt.bind(this,"attachers")}function ot(){at.call(this)}function st(){at.call(this),et.bind(this,"labelTarget")}function pt(){rt.call(this),nt.bind(this,"source"),it.bind(this,"target")}ke(at,rt),ke(ot,at),ke(st,at),ke(pt,rt);var lt={connection:pt,shape:at,label:st,root:ot};function ct(){this._uid=12}ct.prototype.createRoot=function(e){return this.create("root",e)},ct.prototype.createLabel=function(e){return this.create("label",e)},ct.prototype.createShape=function(e){return this.create("shape",e)},ct.prototype.createConnection=function(e){return this.create("connection",e)},ct.prototype.create=function(e,t){return(t=x({},t||{})).id||(t.id=e+"_"+this._uid++),function(e,t){var n=lt[e];if(!n)throw new Error("unknown type: <"+e+">");return x(new n,t)}(e,t)};var ut=Array.prototype.slice;function ht(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}function mt(){}function ft(e,t,n){var i=pe();i.setTranslate(t,n),ge(e,i)}function dt(e,t){this._eventBus=e,this._elementRegistry=t}function yt(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}ht.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})})},ht.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)},ht.prototype.off=function(e,t){e=i(e)?e:[e];var n=this;e.forEach(function(e){n._removeListener(e,t)})},ht.prototype.createEvent=function(e){var t=new mt;return t.init(e),t},ht.prototype.fire=function(e,t){var n,i,r,a;if(a=ut.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 mt?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}},ht.prototype.handleError=function(e){return!1===this.fire("error",{error:e})},ht.prototype._destroy=function(){this._listeners={}},ht.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},ht.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},ht.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)},ht.prototype._getListeners=function(e){return this._listeners[e]},ht.prototype._setListeners=function(e,t){this._listeners[e]=t},ht.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)},mt.prototype.stopPropagation=function(){this.cancelBubble=!0},mt.prototype.preventDefault=function(){this.defaultPrevented=!0},mt.prototype.init=function(e){x(this,e||{})},dt.$inject=["eventBus","elementRegistry"],dt.prototype._getChildren=function(e){var t,n=this._elementRegistry.getGraphics(e);return e.parent?(t=function(e){return e.parentNode.childNodes[1]}(n))||(Q(t=ae("g")).add("djs-children"),$(n.parentNode,t)):t=n,t},dt.prototype._clear=function(e){var t=function(e){return e.childNodes[0]}(e);return R(t),t},dt.prototype._createContainer=function(e,t,n,i){var r=ae("g");Q(r).add("djs-group"),void 0!==n?yt(r,t,t.childNodes[n]):$(t,r);var a=ae("g");Q(a).add("djs-element"),Q(a).add("djs-"+e),i&&Q(a).add("djs-frame"),$(r,a);var o=ae("g");return Q(o).add("djs-visual"),$(a,o),a},dt.prototype.create=function(e,t,n){var i=this._getChildren(t.parent);return this._createContainer(e,i,n,Le(t))},dt.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._getChildren(e);u(i.slice().reverse(),function(e){yt(n.getGraphics(e).parentNode,r)})}})},dt.prototype.drawShape=function(e,t){return this._eventBus.fire("render.shape",{gfx:e,element:t})},dt.prototype.getShapePath=function(e){return this._eventBus.fire("render.getShapePath",e)},dt.prototype.drawConnection=function(e,t){return this._eventBus.fire("render.connection",{gfx:e,element:t})},dt.prototype.getConnectionPath=function(e){return this._eventBus.fire("render.getConnectionPath",e)},dt.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if("shape"===e)this.drawShape(i,t),ft(n,t.x,t.y);else{if("connection"!==e)throw new Error("unknown type: "+e);this.drawConnection(i,t)}t.hidden?q(n,"display","none"):q(n,"display","block")}},dt.prototype.remove=function(e){te(this._elementRegistry.getGraphics(e).parentNode)};var gt={__depends__:[je],__init__:["canvas"],canvas:["type",$e],elementRegistry:["type",Ue],elementFactory:["type",ct],eventBus:["type",ht],graphicsFactory:["type",dt]};function vt(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 xt(e,t){this.injector=t=t||function(e){return vt([{config:["value",e=e||{}]},gt].concat(e.modules||[]))}(e),this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("diagram.init")}function bt(){}function Et(e,t){this.model=e,this.properties=t}xt.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},xt.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")},bt.prototype.get=function(e){return this.$model.properties.get(this,e)},bt.prototype.set=function(e,t){this.$model.properties.set(this,e,t)},Et.prototype.createType=function(e){var t=this.model,n=this.properties,i=Object.create(bt.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 wt={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},At={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 _t(e,t){var n=At[e];return n?n(t):t}function St(e){return!!wt[e]}function Rt(e){return!!At[e]}function Ct(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 Mt(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}function kt(e,t){this.packageMap={},this.typeMap={},this.packages=[],this.properties=t,u(e,g(this.registerPackage,this))}function Pt(e,t,n){var i=t[n];if(i in e)throw new Error("package with "+n+" <"+i+"> already defined")}function Tt(e){this.model=e}function Nt(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function Dt(e){this.properties=new Tt(this),this.factory=new Et(this,this.properties),this.registry=new kt(e,this.properties),this.typeCache={}}Mt.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},Mt.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)},Mt.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},Mt.prototype.redefineProperty=function(e,t,n){var i=e.ns.prefix,r=t.split("#"),a=Ct(r[0],i),o=Ct(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},Mt.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},Mt.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]},Mt.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},Mt.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},Mt.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")},Mt.prototype.hasProperty=function(e){return this.propertiesByName[e]},Mt.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)},kt.prototype.getPackage=function(e){return this.packageMap[e]},kt.prototype.getPackages=function(){return this.packages},kt.prototype.registerPackage=function(e){e=x({},e);var t=this.packageMap;Pt(t,e,"prefix"),Pt(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)},kt.prototype.registerType=function(e,t){var n=Ct((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=Ct(e.name,n.prefix),i=t.name;St(e.type)||(e.type=Ct(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},kt.prototype.mapTypes=function(e,t,n){var i=St(e.name)?{name:e.name}:this.typeMap[e.name],r=this;function a(e){return o(e,!0)}function o(n,i){var a=Ct(n,St(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)},kt.prototype.getEffectiveDescriptor=function(e){var t=Ct(e),n=new Mt(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},kt.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})},Tt.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:Nt(e,i,n):e.$attrs[t]=n},Tt.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&&Nt(e,n,[]),e[i]},Tt.prototype.define=function(e,t,n){Object.defineProperty(e,t,n)},Tt.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})},Tt.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})},Dt.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)},Dt.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},Dt.prototype.createAny=function(e,t,n){var i=Ct(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},Dt.prototype.getPackage=function(e){return this.registry.getPackage(e)},Dt.prototype.getPackages=function(){return this.registry.getPackages()},Dt.prototype.getElementDescriptor=function(e){return e.$descriptor},Dt.prototype.hasType=function(e,t){return void 0===t&&(t=e,e=this),t in e.$model.getElementDescriptor(e).allTypesByName},Dt.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]},Dt.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};var Ot=String.fromCharCode,Bt=Object.prototype.hasOwnProperty,Lt=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/gi,It={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};function Ft(e,t,n,i){return i?Bt.call(It,i)?It[i]:"&"+i+";":Ot(t||parseInt(n,16))}function jt(e){return e.length>3&&-1!==e.indexOf("&")?e.replace(Lt,Ft):e}Object.keys(It).forEach(function(e){It[e.toUpperCase()]=It[e]});var Vt="http://www.w3.org/2001/XMLSchema-instance",Wt="xsi",zt="xsi:type",Gt="non-whitespace outside of root node";function $t(e){return new Error(e)}function Ht(e){return"missing namespace for prefix <"+e+">"}function Kt(e){return{get:e,enumerable:!0}}function Ut(e){var t,n={};for(t in e)n[t]=e[t];return n}function qt(e){return e+"$uri"}function Yt(){return{line:0,column:0}}function Xt(e){throw e}function Zt(e){if(!this)return new Zt(e);var t,n,i,r,a,o,s,p,l,c=e&&e.proxy,u=Xt,h=Yt,m=!1,f=!1,d=null,y=!1;function g(e){e instanceof Error||(e=$t(e)),d=e,u(e,h)}function v(e){a&&(e instanceof Error||(e=$t(e)),a(e,h))}this.on=function(e,l){if("function"!=typeof l)throw $t("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 $t("unsupported event: "+e)}return this},this.ns=function(e){if(void 0===e&&(e={}),"object"!=typeof e)throw $t("required args <nsMap={}>");var t,n={};for(t in e)n[t]=e[t];return n[Vt]=Wt,f=!0,l=n,this},this.parse=function(e){if("string"!=typeof e)throw $t("required args <xml=string>");return d=null,function(e){var a,u,d,x,b,E,w,A,_,S,R=f?[]:null,C=f?function(e){var t,n,i={};for(t in e)i[n=e[t]]=n,i[qt(n)]=t;return i}(l):null,M=[],k=0,P=!1,T=!1,N=0,D=0,O="",B=0;function L(){if(null!==S)return S;var e,t,n,i,r,a,o,s,p,c,u,h=f&&C.xmlns,d=f&&m?[]:null,y=B,g=O,x=g.length,b={},E={};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 E)v("attribute <"+s+"> already defined");else if(E[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=jt(a),t=qt(r),!(o=l[e])){if("xmlns"===r||t in C&&C[t]!==e)do{o="ns"+k++}while(void 0!==C[o]);else o=r;l[e]=o}C[r]!==o&&(i||(C=Ut(C),i=!0),C[r]=o,"xmlns"===r&&(C[qt(o)]=e,h=o),C[t]=e),b[s]=a;continue}d.push(s,a)}else-1!==(c=s.indexOf(":"))?(n=C[s.substring(0,c)])?((s=h===n?s.substr(c+1):n+s.substr(c))===zt&&(-1!==(c=a.indexOf(":"))?(n=a.substring(0,c),n=C[n]||n,a=n+a.substring(c)):a=h+":"+a),b[s]=a):v(Ht(s.substring(0,c))):b[s]=a;else b[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=C[s.substring(0,c)])){v(Ht(s.substring(0,c)));continue}(s=h===n?s.substr(c+1):n+s.substr(c))===zt&&(-1!==(c=a.indexOf(":"))?(n=a.substring(0,c),n=C[n]||n,a=n+a.substring(c)):a=h+":"+a)}b[s]=a}return S=b}h=function(){for(var t,n,i=/(\r\n|\r|\n)/g,r=0,a=0,o=0,s=D;N>=o&&(t=i.exec(e))&&!((s=t[0].length+t.index)>N);)r+=1,o=s;return-1==N?(a=s,n=e.substring(D)):0===D?(console.log(N-o),n=e.substring(D,N)):(a=N-o,n=-1==D?e.substring(N):e.substring(N,D+1)),{data:n,line:r,column:a}},c&&(_=Object.create({},{name:Kt(function(){return w}),originalName:Kt(function(){return A}),attrs:Kt(L),ns:Kt(function(){return C})}));for(;-1!==D;){if(-1===(N=60===e.charCodeAt(D)?D:e.indexOf("<",D)))return M.length?g("unexpected end of file"):0===D?g("missing start tag"):void(D<e.length&&e.substring(D).trim()&&v(Gt));if(D!==N)if(M.length){if(t&&(t(e.substring(D,N),jt,h),y))return}else if(e.substring(D,N).trim()&&(v(Gt),y))return;if(33!==(b=e.charCodeAt(N+1)))if(63!==b){if(-1==(D=e.indexOf(">",N+1)))return g("unclosed tag");if(S={},47===b){if(P=!1,T=!0,!M.length)return g("missing open tag");if(u=w=M.pop(),x=N+2+u.length,e.substring(N+2,x)!==u)return g("closing tag mismatch");for(;x<D;x++)if(!(32===(b=e.charCodeAt(x))||b>8&&b<14))return g("close tag")}else{if(47===e.charCodeAt(D-1)?(u=w=e.substring(N+1,D-1),P=!0,T=!0):(u=w=e.substring(N+1,D),P=!0,T=!1),!(b>96&&b<123||b>64&&b<91||95===b||58===b))return g("illegal first char nodeName");for(x=1,d=u.length;x<d;x++)if(!((b=u.charCodeAt(x))>96&&b<123||b>64&&b<91||b>47&&b<59||45===b||95===b||46==b)){if(32===b||b<14&&b>8){w=u.substring(0,x),S=null;break}return g("invalid nodeName")}T||M.push(w)}if(f){if(a=C,P&&(T||R.push(a),null===S&&(m=-1!==u.indexOf("xmlns",x))&&(B=x,O=u,L(),m=!1)),A=w,-1!==(b=w.indexOf(":"))){if(!(E=C[w.substring(0,b)]))return g("missing namespace on <"+A+">");w=w.substr(b+1)}else E=C.xmlns;E&&(w=E+":"+w)}if(P&&(B=x,O=u,n&&(c?n(_,jt,T,h):n(w,L,jt,T,h),y)))return;if(T){if(i&&(i(c?_:w,jt,P,h),y))return;f&&(C=P?a:R.pop())}D+=1}else{if(-1===(D=e.indexOf("?>",N)))return g("unclosed question");if(s&&(s(e.substring(N,D+2),h),y))return;D+=2}else{if(91===(b=e.charCodeAt(N+2))&&"CDATA["===e.substr(N+3,6)){if(-1===(D=e.indexOf("]]>",N)))return g("unclosed cdata");if(r&&(r(e.substring(N+9,D),h),y))return;D+=3;continue}if(45===b&&45===e.charCodeAt(N+3)){if(-1===(D=e.indexOf("--\x3e",N)))return g("unclosed comment");if(o&&(o(e.substring(N+4,D),jt,h),y))return;D+=3;continue}if(-1===(D=e.indexOf(">",N+1)))return g("unclosed tag");if(p&&(p(e.substring(N,D+1),jt,h),y))return;D+=1}}}(e),h=Yt,y=!1,d},this.stop=function(){y=!0}}function Jt(e){return e.xml&&"lowerCase"===e.xml.tagAlias}var Qt={xsi:"http://www.w3.org/2001/XMLSchema-instance"},en="xsi:type";function tn(e){return e.xml&&e.xml.serialize}function nn(e){return tn(e)===en}function rn(e,t){return Jt(t)?e.prefix+":"+((n=e.localName).charAt(0).toUpperCase()+n.slice(1)):e.name;var n}function an(e){return new Error(e)}function on(e){return e.$descriptor}function sn(e){x(this,e),this.elementsById={},this.references=[],this.