bpmn-js
Version:
A bpmn 2.0 toolkit and web modeler
21 lines • 428 kB
JavaScript
/*! bpmn-js - bpmn-modeler v2.5.1 | 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.BpmnJS=t()}(this,function(){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e,t){return e(t={exports:{}},t.exports),t.exports}var n=t(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}}),i=t(function(e){var t=e.exports=function(e,n){if(n||(n=16),void 0===e&&(e=128),e<=0)return"0";for(var i=Math.log(Math.pow(2,e))/Math.log(n),r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,e/r))/Math.log(n)*r;var o=i-Math.floor(i),a="";for(r=0;r<Math.floor(i);r++){a=Math.floor(Math.random()*n).toString(n)+a}if(o){var s=Math.pow(n,o);a=Math.floor(Math.random()*s).toString(n)+a}var c=parseInt(a,n);return c!==1/0&&c>=Math.pow(2,e)?t(e,n):a};t.rack=function(e,n,i){var r=function(r){var a=0;do{if(a++>10){if(!i)throw new Error("too many ID collisions, use more bits");e+=i}var s=t(e,n)}while(Object.hasOwnProperty.call(o,s));return o[s]=r,s},o=r.hats={};return r.get=function(e){return r.hats[e]},r.set=function(e,t){return r.hats[e]=t,r},r.bits=e||128,r.base=n||16,r}});function r(e){if(!(this instanceof r))return new r(e);e=e||[128,36,1],this._seed=e.length?i.rack(e[0],e[1],e[2]):e}var o=r;function a(e){return Array.prototype.concat.apply([],e)}r.prototype.next=function(e){return this._seed(e||!0)},r.prototype.nextPrefixed=function(e,t){var n;do{n=e+this.next(!0)}while(this.assigned(n));return this.claim(n,t),n},r.prototype.claim=function(e,t){this._seed.set(e,t||!0)},r.prototype.assigned=function(e){return this._seed.get(e)||!1},r.prototype.unclaim=function(e){delete this._seed.hats[e]},r.prototype.clear=function(){var e,t=this._seed.hats;for(e in t)this.unclaim(e)};var s=Object.prototype.toString,c=Object.prototype.hasOwnProperty;function p(e){return null===e||void 0===e}function l(e){return"[object Array]"===s.call(e)}function u(e){return"[object Object]"===s.call(e)}function h(e){return"[object Number]"===s.call(e)}function d(e){return"[object Function]"===s.call(e)}function m(e){return"[object String]"===s.call(e)}function f(e,t){return c.call(e,t)}function y(e,t){var n;return t=N(t),b(e,function(e,i){if(t(e,i))return n=e,!1}),n}function v(e,t){t=N(t);var n=l(e)?-1:void 0;return b(e,function(e,i){if(t(e,i))return n=i,!1}),n}function g(e,t){var n=[];return b(e,function(e,i){t(e,i)&&n.push(e)}),n}function b(e,t){if(!p(e)){var n=l(e)?O:B;for(var i in e){if(f(e,i))if(!1===t(e[i],n(i)))return}}}function x(e,t){return p(e)?[]:(function(e){if(!l(e))throw new Error("must supply array")}(e),t=N(t),e.filter(function(e,n){return!t(e,n)}))}function _(e,t,n){return b(e,function(e,i){n=t(n,e,i)}),n}function E(e,t){return _(e,function(e,n,i){return e&&t(n,i)},!0)}function w(e,t){return!!y(e,t)}function S(e,t){var n=[];return b(e,function(e,i){n.push(t(e,i))}),n}function C(e){return e&&Object.keys(e)||[]}function T(e){return S(e,function(e){return e})}function R(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t=D(t),b(e,function(e){var i=t(e)||"_",r=n[i];r||(r=n[i]=[]),r.push(e)}),n}function A(e){e=D(e);for(var t={},n=arguments.length,i=Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return b(i,function(n){return R(n,e,t)}),S(t,function(e,t){return e[0]})}var P=A;function M(e,t){t=D(t);var n=[];return b(e,function(e,i){for(var r=t(e,i),o={d:r,v:e},a=0;a<n.length;a++){if(r<n[a].d)return void n.splice(a,0,o)}n.push(o)}),S(n,function(e){return e.v})}function k(e){return function(t){return E(e,function(e,n){return t[n]===e})}}function D(e){return d(e)?e:function(t){return t[e]}}function N(e){return d(e)?e:function(t){return t===e}}function B(e){return e}function O(e){return Number(e)}var L=Array.prototype.slice;function I(e,t){var n;return function(){var i=L.call(arguments);n&&clearTimeout(n),n=setTimeout(function(){e.apply(void 0,function(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)}(i))},t)}}function j(e,t){return e.bind(t)}var z=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};function F(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return z.apply(void 0,[e].concat(n))}function $(e,t){var n={},i=Object(e);return b(t,function(t){t in i&&(n[t]=e[t])}),n}function W(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}var H=[].indexOf,G=function(e,t){if(H)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},V=/\s+/,q=Object.prototype.toString;function U(e){return new Y(e)}function Y(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function K(e){for(var t;e.childNodes.length;)t=e.childNodes[0],e.removeChild(t);return e}Y.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~G(t,e)||t.push(e),this.el.className=t.join(" "),this},Y.prototype.remove=function(e){if("[object RegExp]"==q.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=G(t,e);return~n&&t.splice(n,1),this.el.className=t.join(" "),this},Y.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},Y.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)},Y.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(V);return""===e[0]&&e.shift(),e},Y.prototype.has=Y.prototype.contains=function(e){return this.list?this.list.contains(e):!!~G(this.array(),e)};var X=Element.prototype,Z=X.matchesSelector||X.webkitMatchesSelector||X.mozMatchesSelector||X.msMatchesSelector||X.oMatchesSelector,Q=function(e,t){if(Z)return Z.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 J,ee=function(e,t,n){for(var i=n?e:e.parentNode;i&&i!==document;){if(Q(i,t))return i;i=i.parentNode}},te=window.addEventListener?"addEventListener":"attachEvent",ne=window.removeEventListener?"removeEventListener":"detachEvent",ie="addEventListener"!==te?"on":"",re={bind:function(e,t,n,i){return e[te](ie+t,n,i||!1),n},unbind:function(e,t,n,i){return e[ne](ie+t,n,i||!1),n}},oe=["focus","blur"],ae={bind:function(e,t,n,i,r){return-1!==oe.indexOf(n)&&(r=!0),re.bind(e,n,function(n){var r=n.target||n.srcElement;n.delegateTarget=ee(r,t,!0,e),n.delegateTarget&&i.call(e,n)},r)},unbind:function(e,t,n,i){-1!==oe.indexOf(t)&&(i=!0),re.unbind(e,t,n,i)}},se=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 o=pe[i]||pe._default,a=o[0],s=o[1],c=o[2];(r=t.createElement("div")).innerHTML=s+e+c;for(;a--;)r=r.lastChild;if(r.firstChild==r.lastChild)return r.removeChild(r.firstChild);var p=t.createDocumentFragment();for(;r.firstChild;)p.appendChild(r.removeChild(r.firstChild));return p},ce=!1;"undefined"!=typeof document&&((J=document.createElement("div")).innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',ce=!J.getElementsByTagName("link").length,J=void 0);var pe={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:ce?[1,"X<div>","</div>"]:[0,"",""]};pe.td=pe.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],pe.option=pe.optgroup=[1,'<select multiple="multiple">',"</select>"],pe.thead=pe.tbody=pe.colgroup=pe.caption=pe.tfoot=[1,"<table>","</table>"],pe.polyline=pe.ellipse=pe.polygon=pe.circle=pe.text=pe.line=pe.path=pe.rect=pe.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];var le="undefined"!=typeof Element?Element.prototype:{},ue=le.matches||le.matchesSelector||le.webkitMatchesSelector||le.mozMatchesSelector||le.msMatchesSelector||le.oMatchesSelector,he=function(e,t){if(!e||1!==e.nodeType)return!1;if(ue)return ue.call(e,t);for(var n=e.parentNode.querySelectorAll(t),i=0;i<n.length;i++)if(n[i]==e)return!0;return!1};function de(e,t){return(t=t||document).querySelector(e)}function me(e,t){return(t=t||document).querySelectorAll(e)}function fe(e){e.parentNode&&e.parentNode.removeChild(e)}function ye(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)),e}function ve(e,t){return ye(t,e),e}var ge=2,be={"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":ge,"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":ge,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function xe(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=be[i];r?(r===ge&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function _e(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return be[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);xe(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)xe(e,i,t[i])}(e,t);return e}function Ee(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 we=/\s+/,Se=Object.prototype.toString;function Ce(e){return void 0!==e}function Te(e){return new Re(e)}function Re(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Ae(e){var t=e.parentNode;return t&&t.removeChild(e),e}function Pe(e){for(var t;t=e.firstChild;)Ae(t);return e}Re.prototype.add=function(e){if(this.list)return this.list.add(e),this;var t=this.array();return~Ee(t,e)||t.push(e),Ce(this.el.className.baseVal)?this.el.className.baseVal=t.join(" "):this.el.className=t.join(" "),this},Re.prototype.remove=function(e){if("[object RegExp]"===Se.call(e))return this.removeMatching(e);if(this.list)return this.list.remove(e),this;var t=this.array(),n=Ee(t,e);return~n&&t.splice(n,1),this.el.className.baseVal=t.join(" "),this},Re.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},Re.prototype.toggle=function(e,t){return this.list?(Ce(t)?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this):(Ce(t)?t?this.add(e):this.remove(e):this.has(e)?this.remove(e):this.add(e),this)},Re.prototype.array=function(){var e=(this.el.getAttribute("class")||"").replace(/^\s+|\s+$/g,"").split(we);return""===e[0]&&e.shift(),e},Re.prototype.has=Re.prototype.contains=function(e){return this.list?this.list.contains(e):!!~Ee(this.array(),e)};var Me={svg:"http://www.w3.org/2000/svg"},ke='<svg xmlns="'+Me.svg+'"';function De(e){return"<svg"===e.substring(0,4)?-1===e.indexOf(Me.svg)&&(e=ke+e.substring(4)):e=ke+">"+e+"</svg>",function(e){var t;return(t=new DOMParser).async=!1,t.parseFromString(e,"text/xml")}(e)}function Ne(e,t){var n;return"<"===e.charAt(0)?(n=De(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(Me.svg,e),t&&_e(n,t),n}var Be=Ne("svg");function Oe(e,t,n,i,r,o){var a=Be.createSVGMatrix();switch(arguments.length){case 0:return a;case 6:e={a:e,b:t,c:n,d:i,e:r,f:o}}return function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}(a,e)}function Le(e){return e?Be.createSVGTransformFromMatrix(e):Be.createSVGTransform()}var Ie=/([&<>]{1})/g,je=/([\n\r"]{1})/g,ze={"&":"&","<":"<",">":">",'"':"'"};function Fe(e,t){return e.replace(t,function(e,t){return ze[t]||t})}function $e(e,t){var n,i,r,o,a;switch(e.nodeType){case 3:t.push(Fe(e.textContent,Ie));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(n=0,i=(r=e.attributes).length;n<i;++n)o=r.item(n),t.push(" ",o.name,'="',Fe(o.value,je),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(a=e.childNodes).length;n<i;++n)$e(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",Fe(e.nodeValue,Ie),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function We(e,t){if(void 0!==t){try{!function(e,t){var n,i=De(t).documentElement;if(Pe(e),t)for(n=i.firstChild;n;)ye(n,e),n=n.nextSibling}(e,t)}catch(e){throw new Error("error parsing SVG: "+e.message)}return e}return function(e){for(var t=e.firstChild,n=[];t;)$e(t,n),t=t.nextSibling;return n.join("")}(e)}function He(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function Ge(e,t){var n=e.transform.baseVal;if(1===arguments.length)return n.consolidate();t.length?function(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(He(e,i));e.consolidate()}(n,t):n.initialize(He(n,t))}var Ve=/^class /;function qe(e){return"[object Array]"===Object.prototype.toString.call(e)}function Ue(){var e=Array.prototype.slice.call(arguments);1===e.length&&qe(e[0])&&(e=e[0]);var t=e.pop();return t.$inject=e,t}var Ye=/constructor\s*[^(]*\(\s*([^)]*)\)/m,Ke=/^function\s*[^(]*\(\s*([^)]*)\)/m,Xe=/\/\*([^*]*)\*\//m;function Ze(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)?Ye:Ke);return t&&t[1]&&t[1].split(",").map(function(e){return(t=e.match(Xe))?t[1].trim():e.trim()})||[]}var Qe="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 Je(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 et(e,t){return Object.hasOwnProperty.call(e,t)}var tt=1e3;function nt(e,t){var n=this;t=t||tt,e.on(["render.shape","render.connection"],t,function(e,t){var i=e.type,r=t.element,o=t.gfx;if(n.canRender(r))return"render.shape"===i?n.drawShape(o,r):n.drawConnection(o,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 it(e){return e.join(",").replace(/,?([A-z]),?/g,"$1")}function rt(e){for(var t,n="",i=0;t=e[i];i++)n+=t.x+","+t.y+" ";return n}function ot(e,t){var n=Ne("polyline");return _e(n,{points:rt(e)}),t&&_e(n,t),n}nt.prototype.canRender=function(){},nt.prototype.drawShape=function(){},nt.prototype.drawConnection=function(){},nt.prototype.getShapePath=function(){},nt.prototype.getConnectionPath=function(){};var at=1;function st(e,t){nt.call(this,e,at),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2})}n(st,nt),st.prototype.canRender=function(){return!0},st.prototype.drawShape=function(e,t){var n=Ne("rect");return _e(n,{x:0,y:0,width:t.width||0,height:t.height||0}),_e(n,this.SHAPE_STYLE),ve(e,n),n},st.prototype.drawConnection=function(e,t){var n=ot(t.waypoints,this.CONNECTION_STYLE);return ve(e,n),n},st.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return it([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},st.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 it(r)},st.$inject=["eventBus","styles"];var ct={__init__:["defaultRenderer"],defaultRenderer:["type",st],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 F(this.style(t,n),{class:e})},this.style=function(t,n){l(t)||n||(n=t,t=[]);var i=_(t,function(t,n){return F(t,e[n]||{})},{});return n?F(i,n):i},this.computeStyle=function(e,n,i){return l(n)||(i=n,n=[]),t.style(n||[],F({},i,e||{}))}}]};function pt(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return-1!==n&&e.splice(n,1),n}function lt(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)}}function ut(e,t){return e&&t?e.indexOf(t):-1}function ht(e,t,n){var i=!n||-1===e.indexOf(t);return i&&e.push(t),i}function dt(e,t,n){n=n||0,l(e)||(e=[e]),b(e,function(e,i){var r=t(e,i,n);l(r)&&r.length&&dt(r,t,n+1)})}function mt(e,t){return function(e,t,n){var i=[],r=[];return dt(e,function(e,o,a){ht(i,e,t);var s=e.children;if((-1===n||a<n)&&s&&ht(r,s,t))return s}),i}(e,!t,-1)}function ft(e,t){var n,i,r,o;return t=!!t,l(e)||(e=[e]),b(e,function(e){var a=e;e.waypoints&&!t&&(a=ft(e.waypoints,!0));var s=a.x,c=a.y,p=a.height||0,l=a.width||0;(s<n||void 0===n)&&(n=s),(c<i||void 0===i)&&(i=c),(s+l>r||void 0===r)&&(r=s+l),(c+p>o||void 0===o)&&(o=c+p)}),{x:n,y:i,height:o-i,width:r-n}}function yt(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function vt(e,t){return F({},e||{},t||{})}function gt(e,t){return Math.round(e*t)/t}function bt(e){return h(e)?e+"px":e}function xt(e,t,n){var i=Ne("g");Te(i).add(t);var r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}var _t={shape:["x","y","width","height"],connection:["waypoints"]};function Et(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._init(e||{})}function wt(e,t){var n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}Et.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],Et.prototype._init=function(e){var t=this._eventBus,n=this._container=function(e){var t=(e=F({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container"),F(n.style,{position:"relative",overflow:"hidden",width:bt(e.width),height:bt(e.height)}),t.appendChild(n),n}(e),i=this._svg=Ne("svg");_e(i,{width:"100%",height:"100%"}),ve(n,i);var r=this._viewport=xt(i,"viewport");this._layers={},!1!==e.deferUpdate&&(this._viewboxChanged=I(j(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)},Et.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},Et.prototype._clear=function(){var e=this;this._elementRegistry.getAll().forEach(function(t){var n=yt(t);"root"===n?e.setRootElement(null,!0):e._removeElement(t,n)}),delete this._cachedViewbox},Et.prototype.getDefaultLayer=function(){return this.getLayer("base",0)},Et.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},Et.prototype._createLayer=function(e,t){t||(t=0);var n=_(this._layers,function(e,n){return t>=n.index&&e++,e},0);return{group:xt(this._viewport,"layer-"+e,n),index:t}},Et.prototype.getContainer=function(){return this._container},Et.prototype._updateMarker=function(e,t,n){var i;e.id||(e=this._elementRegistry.get(e)),(i=this._elementRegistry._elements[e.id])&&(b([i.gfx,i.secondaryGfx],function(e){e&&(n?Te(e).add(t):Te(e).remove(t))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},Et.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},Et.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},Et.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),Te(this.getGraphics(e)).has(t)},Et.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},Et.prototype.getRootElement=function(){return this._rootElement||this.setRootElement({id:"__implicitroot",children:[]}),this._rootElement},Et.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 o=this.getDefaultLayer();r.fire("root.add",{element:e}),i.add(e,o,this._svg),r.fire("root.added",{element:e,gfx:o})}return this._rootElement=e,e},Et.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=_t[e];if(!E(n,function(e){return void 0!==t[e]}))throw new Error("must supply { "+n.join(", ")+" } with "+e)},Et.prototype._setParent=function(e,t,n){lt(t.children,e,n),e.parent=t},Et.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();var r=this._eventBus,o=this._graphicsFactory;this._ensureValid(e,t),r.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);var a=o.create(e,t,i);return this._elementRegistry.add(t,a),o.update(e,t,a),r.fire(e+".added",{element:t,gfx:a}),t},Et.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},Et.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},Et.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),pt(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},Et.prototype.removeShape=function(e){return this._removeElement(e,"shape")},Et.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},Et.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},Et.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},Et.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},Et.prototype.viewbox=function(e){if(void 0===e&&this._cachedViewbox)return this._cachedViewbox;var t,n,i,r,o,a,s=this._viewport,c=this.getSize();return e?(this._changeViewbox(function(){r=Math.min(c.width/e.width,c.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:Oe(),r=gt(n.a,1e3),o=gt(-n.e||0,1e3),a=gt(-n.f||0,1e3),e=this._cachedViewbox={x:o?o/r:0,y:a?a/r:0,width:c.width/r,height:c.height/r,scale:r,inner:{width:t.width,height:t.height,x:t.x,y:t.y},outer:c})},Et.prototype.scroll=function(e){var t=this._viewport,n=t.getCTM();return e&&this._changeViewbox(function(){e=F({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),wt(t,n)}),{x:n.e,y:n.f}},Et.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)}),gt(i.a,1e3)):this.viewbox(e).scale;var n,i},Et.prototype._fitViewport=function(e){var t,n,i=this.viewbox(),r=i.outer,o=i.inner;return o.x>=0&&o.y>=0&&o.x+o.width<=r.width&&o.y+o.height<=r.height&&!e?n={x:0,y:0,width:Math.max(o.width+o.x,r.width),height:Math.max(o.height+o.y,r.height)}:(t=Math.min(1,r.width/o.width,r.height/o.height),n={x:o.x+(e?o.width/2-r.width/t/2:0),y:o.y+(e?o.height/2-r.height/t/2:0),width:r.width/t,height:r.height/t}),this.viewbox(n),this.viewbox(!1).scale},Et.prototype._setZoom=function(e,t){var n,i,r,o,a=this._svg,s=this._viewport,c=a.createSVGMatrix(),p=a.createSVGPoint(),l=(i=s.getCTM()).a;return t?(n=F(p,t).matrixTransform(i.inverse()),r=c.translate(n.x,n.y).scale(1/l*e).translate(-n.x,-n.y),o=i.multiply(r)):o=c.scale(e),wt(this._viewport,o),o},Et.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},Et.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}},Et.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var St="data-element-id";function Ct(e){this._elements={},this._eventBus=e}Ct.$inject=["eventBus"],Ct.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),_e(t,St,i),n&&_e(n,St,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},Ct.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(_e(i.gfx,St,""),i.secondaryGfx&&_e(i.secondaryGfx,St,""),delete t[n])},Ct.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)},Ct.prototype.get=function(e){var t;t="string"==typeof e?e:e&&_e(e,St);var n=this._elements[t];return n&&n.element},Ct.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},Ct.prototype.getAll=function(){return this.filter(function(e){return e})},Ct.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach(function(n){var i=t[n],r=i.element,o=i.gfx;return e(r,o)})},Ct.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},Ct.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 Tt={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 o=this.indexOf(e);if(void 0===n){if(-1!==o)return;n=this.length}-1!==o&&this.splice(o,1),this.splice(n,0,e),-1===o&&t.set(e,r,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e},isExtended:function(e){return!0===e.__refs_collection}};function Rt(e,t,n){var i=Tt.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 At(e,t){if(!(this instanceof At))return new At(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}At.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?Rt(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 o=r;r=null,o&&e.unset(o,i,n),r=t,e.set(r,i,n)}}})}(this,t,e)},At.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return Tt.isExtended(n)||Rt(this,t,e),n},At.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},At.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},At.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Pt=At,Mt=Tt;Pt.Collection=Mt;var kt=new Pt({name:"children",enumerable:!0,collection:!0},{name:"parent"}),Dt=new Pt({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Nt=new Pt({name:"attachers",collection:!0},{name:"host"}),Bt=new Pt({name:"outgoing",collection:!0},{name:"source"}),Ot=new Pt({name:"incoming",collection:!0},{name:"target"});function Lt(){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)}}),kt.bind(this,"parent"),Dt.bind(this,"labels"),Bt.bind(this,"outgoing"),Ot.bind(this,"incoming")}function It(){Lt.call(this),kt.bind(this,"children"),Nt.bind(this,"host"),Nt.bind(this,"attachers")}function jt(){It.call(this)}function zt(){It.call(this),Dt.bind(this,"labelTarget")}function Ft(){Lt.call(this),Bt.bind(this,"source"),Ot.bind(this,"target")}n(It,Lt),n(jt,It),n(zt,It),n(Ft,Lt);var $t={connection:Ft,shape:It,label:zt,root:jt};function Wt(){this._uid=12}Wt.prototype.createRoot=function(e){return this.create("root",e)},Wt.prototype.createLabel=function(e){return this.create("label",e)},Wt.prototype.createShape=function(e){return this.create("shape",e)},Wt.prototype.createConnection=function(e){return this.create("connection",e)},Wt.prototype.create=function(e,t){return(t=F({},t||{})).id||(t.id=e+"_"+this._uid++),function(e,t){var n=$t[e];if(!n)throw new Error("unknown type: <"+e+">");return F(new n,t)}(e,t)};var Ht=Array.prototype.slice;function Gt(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}function Vt(){}function qt(e,t,n,i,r){var o=Le();o.setTranslate(t,n);var a=Le();a.setRotate(i,0,0);var s=Le();s.setScale(r||1,r||1),Ge(e,[o,a,s])}function Ut(e,t,n){var i=Le();i.setTranslate(t,n),Ge(e,i)}function Yt(e,t){var n=Le();n.setRotate(t,0,0),Ge(e,n)}function Kt(e,t){this._eventBus=e,this._elementRegistry=t}function Xt(e,t,n){t.insertBefore(e,n||t.firstChild)}Gt.prototype.on=function(e,t,n,i){if(e=l(e)?e:[e],d(t)&&(i=n,n=t,t=1e3),!h(t))throw new Error("priority must be a number");var r=n;i&&((r=j(n,i)).__fn=n.__fn||n);var o=this,a={priority:t,callback:r};e.forEach(function(e){o._addListener(e,a)})},Gt.prototype.once=function(e,t,n,i){var r=this;if(d(t)&&(i=n,n=t,t=1e3),!h(t))throw new Error("priority must be a number");function o(){return r.off(e,o),n.apply(i,arguments)}o.__fn=n,this.on(e,t,o)},Gt.prototype.off=function(e,t){var n=this;(e=l(e)?e:[e]).forEach(function(e){n._removeListener(e,t)})},Gt.prototype.createEvent=function(e){var t=new Vt;return t.init(e),t},Gt.prototype.fire=function(e,t){var n,i,r,o;if(o=Ht.call(arguments),"object"==typeof e&&(e=(n=e).type),!e)throw new Error("no event type specified");if(i=this._listeners[e]){n=t instanceof Vt?t:this.createEvent(t),o[0]=n;var a=n.type;e!==a&&(n.type=e);try{r=this._invokeListeners(n,o,i)}finally{e!==a&&(n.type=a)}return void 0===r&&n.defaultPrevented&&(r=!1),r}},Gt.prototype.handleError=function(e){return!1===this.fire("error",{error:e})},Gt.prototype._destroy=function(){this._listeners={}},Gt.prototype._invokeListeners=function(e,t,n){var i,r,o;for(i=0;(r=n[i])&&!e.cancelBubble;i++)o=this._invokeListener(e,t,r);return o},Gt.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},Gt.prototype._addListener=function(e,t){var n,i,r=this._getListeners(e);for(i=0;n=r[i];i++)if(n.priority<t.priority)return void r.splice(i,0,t);r.push(t)},Gt.prototype._getListeners=function(e){var t=this._listeners[e];return t||(this._listeners[e]=t=[]),t},Gt.prototype._removeListener=function(e,t){var n,i,r,o=this._getListeners(e);if(t)for(r=o.length-1;n=o[r];r--)(i=n.callback)!==t&&i.__fn!==t||o.splice(r,1);else o.length=0},Vt.prototype.stopPropagation=function(){this.cancelBubble=!0},Vt.prototype.preventDefault=function(){this.defaultPrevented=!0},Vt.prototype.init=function(e){F(this,e||{})},Kt.$inject=["eventBus","elementRegistry"],Kt.prototype._getChildren=function(e){var t,n=this._elementRegistry.getGraphics(e);return e.parent?(t=function(e){return e.parentNode.childNodes[1]}(n))||(Te(t=Ne("g")).add("djs-children"),ve(n.parentNode,t)):t=n,t},Kt.prototype._clear=function(e){var t=function(e){return de(".djs-visual",e)}(e);return K(t),t},Kt.prototype._createContainer=function(e,t,n){var i=Ne("g");Te(i).add("djs-group"),void 0!==n?Xt(i,t,t.childNodes[n]):ve(t,i);var r=Ne("g");Te(r).add("djs-element"),Te(r).add("djs-"+e),ve(i,r);var o=Ne("g");return Te(o).add("djs-visual"),ve(r,o),r},Kt.prototype.create=function(e,t,n){var i=this._getChildren(t.parent);return this._createContainer(e,i,n)},Kt.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry;b(_(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);b(i.slice().reverse(),function(e){Xt(n.getGraphics(e).parentNode,r)})}})},Kt.prototype.drawShape=function(e,t){return this._eventBus.fire("render.shape",{gfx:e,element:t})},Kt.prototype.getShapePath=function(e){return this._eventBus.fire("render.getShapePath",e)},Kt.prototype.drawConnection=function(e,t){return this._eventBus.fire("render.connection",{gfx:e,element:t})},Kt.prototype.getConnectionPath=function(e){return this._eventBus.fire("render.getConnectionPath",e)},Kt.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if("shape"===e)this.drawShape(i,t),Ut(n,t.x,t.y);else{if("connection"!==e)throw new Error("unknown type: "+e);this.drawConnection(i,t)}t.hidden?_e(n,"display","none"):_e(n,"display","block")}},Kt.prototype.remove=function(e){Ae(this._elementRegistry.getGraphics(e).parentNode)};var Zt={__depends__:[ct],__init__:["canvas"],canvas:["type",Et],elementRegistry:["type",Ct],elementFactory:["type",Wt],eventBus:["type",Gt],graphicsFactory:["type",Kt]};function Qt(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 function e(t,n){n=n||{get:function(e,t){if(i.push(e),!1===t)return null;throw s('No provider for "'+e+'"!')}};var i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),a=o.injector=this,s=function(e){var t=i.join(" -> ");return i.length=0,new Error(t?e+" (Resolving: "+t+")":e)},c=function e(t,a){if(!r[t]&&-1!==t.indexOf(".")){for(var c=t.split("."),p=e(c.shift());c.length;)p=p[c.shift()];return p}if(et(o,t))return o[t];if(et(r,t)){if(-1!==i.indexOf(t))throw i.push(t),s("Cannot resolve circular dependency!");return i.push(t),o[t]=r[t][0](r[t][1]),i.pop(),o[t]}return n.get(t,a)},p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("function"!=typeof e){if(!qe(e))throw new Error('Cannot invoke "'+e+'". Expected a function!');e=Ue(e.slice())}return{fn:e,dependencies:(e.$inject||Ze(e)).map(function(e){return et(t,e)?t[e]:c(e)})}},l=function(e){var t=p(e),n=t.dependencies,i=t.fn;return new(Function.prototype.bind.apply(i,[null].concat(Je(n))))},u=function(e,t,n){var i=p(e,n),r=i.dependencies,o=i.fn;return o.call.apply(o,[t].concat(Je(r)))},h=function(e){return Ue(function(t){return e.get(t)})},d={factory:u,type:l,value:function(e){return e}};t.forEach(function(t){function n(e,t){return"value"!==e&&qe(t)&&(t=Ue(t.slice())),t}if(t 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)}})t.forEach(function(e){var t=e[0],i=e[1],o=e[2];r[t]=[d[i],n(i,o),i]});else if("object"===(void 0===t?"undefined":Qe(t)))if(t.__exports__){var i=Object.keys(t).reduce(function(e,n){return"__"!==n.substring(0,2)&&(e[n]=t[n]),e},Object.create(null)),o=new e((t.__modules__||[]).concat([i]),a),s=Ue(function(e){return o.get(e)});t.__exports__.forEach(function(e){r[e]=[s,e,"private",o]})}else Object.keys(t).forEach(function(e){if("private"!==t[e][2]){var i=t[e][0],o=t[e][1];r[e]=[d[i],n(i,o),i]}else r[e]=t[e]})}),this.get=c,this.invoke=u,this.instantiate=l,this.createChild=function(t,n){if(n&&n.length){var i,o,s,c,p=Object.create(null),l=Object.create(null),u=[],d=[],m=[];for(var f in r)i=r[f],-1!==n.indexOf(f)&&("private"===i[2]?-1===(o=u.indexOf(i[3]))?(s=i[3].createChild([],n),c=h(s),u.push(i[3]),d.push(s),m.push(c),p[f]=[c,f,"private",s]):p[f]=[m[o],f,"private",d[o]]:p[f]=[i[2],i[1]],l[f]=!0),"factory"!==i[2]&&"type"!==i[2]||!i[1].$scope||n.forEach(function(e){-1!==i[1].$scope.indexOf(e)&&(p[f]=[i[2],i[1]],l[e]=!0)});n.forEach(function(e){if(!l[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')}),t.unshift(p)}return new e(t,a)}}(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 Jt(e,t){this.injector=t=t||function(e){return Qt([{config:["value",e=e||{}]},Zt].concat(e.modules||[]))}(e),this.get=t.get,this.invoke=t.invoke,this.get("eventBus").fire("diagram.init")}Jt.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},Jt.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};var en=Object.freeze({default:Jt}),tn=en&&Jt||en;function nn(){}function rn(e,t){this.model=e,this.properties=t}nn.prototype.get=function(e){return this.$model.properties.get(this,e)},nn.prototype.set=function(e,t){this.$model.properties.set(this,e,t)},rn.prototype.createType=function(e){var t=this.model,n=this.properties,i=Object.create(nn.prototype);b(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 o(e){n.define(this,"$type",{value:r,enumerable:!0}),n.define(this,"$attrs",{value:{}}),n.define(this,"$parent",{writable:!0}),b(e,j(function(e,t){this.set(t,e)},this))}return o.prototype=i,o.hasType=i.$instanceOf=this.model.hasType,n.defineModel(o,t),n.defineDescriptor(o,e),o};var on={String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0},an={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 sn(e,t){var n=an[e];return n?n(t):t}function cn(e){return!!on[e]}function pn(e){return!!an[e]}function ln(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 un(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName={},this.properties=[],this.propertiesByName={}}function hn(e,t){this.packageMap={},this.typeMap={},this.packages=[],this.properties=t,b(e,j(this.registerPackage,this))}function dn(e,t,n){var i=t[n];if(i in e)throw new Error("package with "+n+" <"+i+"> already defined")}function mn(e){this.model=e}function fn(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function yn(e){this.properties=new mn(this),this.factory=new rn(this,this.properties),this.registry=new hn(e,this.properties),this.typeCache={}}un.prototype.build=function(){return $(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])},un.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)},un.prototype.replaceProperty=function(e,t,n){var i=e.ns,r=this.properties,o=this.propertiesByName,a=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,a),o[i.name]=o[i.localName]=t},un.prototype.redefineProperty=function(e,t,n){var i=e.ns.prefix,r=t.split("#"),o=ln(r[0],i),a=ln(r[1],o.prefix).name,s=this.propertiesByName[a];if(!s)throw new Error("refined property <"+a+"> not found");this.replaceProperty(s,e,n),delete e.redefines},un.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},un.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]},un.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},un.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},un.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")},un.prototype.hasProperty=function(e){return this.propertiesByName[e]},un.prototype.addTrait=function(e,t){var n=this.allTypesByName,i=this.allTypes,r=e.name;r in n||(b(e.properties,j(function(n){n=F({},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)},hn.prototype.getPackage=function(e){return this.packageMap[e]},hn.prototype.getPackages=function(){return this.packages},hn.prototype.registerPackage=function(e){e=F({},e);var t=this.packageMap;dn(t,e,"prefix"),dn(t,e,"uri"),b(e.types,j(function(t){this.registerType(t,e)},this)),t[e.uri]=t[e.prefix]=e,this.packages.push(e)},hn.prototype.registerType=function(e,t){var n=ln((e=F({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:F(e.meta||{})})).name,t.prefix),i=n.name,r={};b(e.properties,j(function(e){var t=ln(e.name,n.prefix),i=t.name;cn(e.type)||(e.type=ln(e.type,t.prefix).name),F(e,{ns:t,name:i}),r[i]=e},this)),F(e,{ns:n,name:i,propertiesByName:r}),b(e.extends,j(function(e){var t=this.typeMap[e];t.traits=t.traits||[],t.traits.push(i)},this)),this.definePackage(e,t),this.typeMap[i]=e},hn.prototype.mapTypes=function(e,t,n){var i=cn(e.name)?{name:e.name}:this.typeMap[e.name],r=this;function o(e){return a(e,!0)}function a(n,i){var o=ln(n,cn(n)?"":e.prefix);r.mapTypes(o,t,i)}if(!i)throw new Error("unknown type <"+e.name+">");b(i.superClass,n?o:a),t(i,!n),b(i.traits,o)},hn.prototype.getEffectiveDescriptor=function(e){var t=ln(e),n=new un(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},hn.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})},mn.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:fn(e,i,n):e.$attrs[t]=n},mn.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&&fn(e,n,[]),e[i]},mn.prototype.define=function(e,t,n){Object.defineProperty(e,t,n)},mn.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})},mn.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})},yn.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)},yn.prototype.getType=function(e){var t=this.typeCache,n=m(e)?e:e.ns.name,i=t[n];return i||(e=this.registry.getEffectiveDescriptor(n),i=t[n]=this.factory.createType(e)),i},yn.prototype.createAny=function(e,t,n){var i=ln(e),r={$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(r,o),this.properties.defineModel(r,this),this.properties.define(r,"$parent",{enumerable:!1,writable:!0}),b(n,function(e,t){u(e)&&void 0!==e.value?r[e.name]=e.value:r[t]=e}),r},yn.prototype.getPackage=function(e){return this.registry.getPackage(e)},yn.prototype.getPackages=function(){return this.registry.getPackages()},yn.prototype.getElementDescriptor=function(e){return e.$descriptor},yn.prototype.hasType=function(e,t){return void 0===t&&(t=e,e=this),t in e.$model.getElementDescriptor(e).allTypesByName},yn.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]},yn.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};var vn=t(function(e,t){var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();
/**
* Tiny stack for browser or server
*
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2018
* @license BSD-3-Clause
* @link http://avoidwork.github.io/tiny-stack
* @version 1.1.0
*/
!function(t){var i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}
/**
* Tiny stack for browser or server
*
* @author Jason Mulligan <jason.mulligan@avoidwork.com>
* @copyright 2018
* @license BSD-3-Clause
* @link http://avoidwork.github.io/tiny-stack
* @version 1.1.0
*/(this,e);for(var t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];this.data=[null].concat(n),this.top=this.data.length-1}return n(e,[{key:"clear",value:function(){return this.data.length=1,this.top=0,this}},{key:"empty",value:function(){return 0===this.top}},{key:"length",value:function(){return this.top}},{key:"peek",value:function(){return this.data[this.top]}},{key:"pop",value:function(){var e=void 0;return this.top>0&&(e=this.data.pop(),this.top--),e}},{key:"push",value:function(e){return this.data[++this.top]=e,this}},{key:"search",value:function(e){var t=this.data.indexOf(e);return-1===t?-1:this.data.length-t}}]),e}();e.exports=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return new(Function.prototype.bind.apply(i,[null].concat(t)))}}("undefined"!=typeof window&&window)}),gn=String.fromCharCode,bn=Object.prototype.hasOwnProperty,xn=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/gi,_n={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};function En(e,t,n,i){return i?bn.call(_n,i)?_n[i]:"&"+i+";":gn(t||parseInt(n,16))}function wn(e){return e.length>3&&-1!==e.indexOf("&")?e.replace(xn,En):e}Object.keys(_n).forEach(function(e){_n[e.toUpperCase()]=_n[e]});var Sn="http://www.w3.org/2001/XMLSchema-instance",Cn="xsi",Tn="xsi:type";function Rn(e){return new Error(e)}function An(e){return"missing namespace for prefix <"+e+">"}function Pn(e){return{get:e,enumerable:!0}}function Mn(e){var t,n={};for(t in e)n[t]=e[t];return n}function kn(e){return e+"$uri"}function Dn(){return{line:0,column:0}}function Nn(e){throw e}function Bn(e){if(!this)return new Bn(e);var t,n,i,r,o,a,s,c,p,l=e&&e.proxy,u=Nn,h=Dn,d=!1,m=!1,f=null,y=!1;function v(e){e instanceof Error||(e=Rn(e)),f=e,u(e,h)}function g(e){o&&(e instanceof Error||(e=Rn(e)),o(e,h))}this.on=function(e,p){if("function"!=typeof p)throw Rn("required args <name, cb>");switch(e){case"openTag":n=p;break;case"text":t=p;break;case"closeTag":i=p;break;case"error":u=p;break;case"warn":o=p;break;case"cdata":r=p;break;case"attention":c=p;break;case"question":s=p;break;case"comment":a=p;break;default:throw Rn("unsupported event: "+e)}return this},this.ns=function(e){if(void 0===e&&(e={}),"object"!=typeof e)throw Rn("required args <nsMap={}>");var t,n={};for(t in e)n[t]=e[t];return n[Sn]=Cn,m=!0,p=n,this},this.parse=function(e){if("string"!=typeof e)throw Rn("required args <xml=string>");return f=null,function(e){var o,u,f,b,x,_,E,w,S,C,T=m?[]:null,R=m?function(e){var t,n,i={};for(t in e)i[n=e[t]]=n,i[kn(n)]=t;return i}(p):null,A=[],P=0,M=!1,k=!1,D=0,N=0,B="",O=0;function L(){if(null!==C)return C;var e,t,n,i,r,o,a,s,c,l,u,h=m&&R.xmlns,f=m&&d?[]:null,y=O,v=B,b=v.length,x={},_={};e:for(;y<b;y++)if(c=!1,!(32===(l=v.charCodeAt(y))||l<14&&l>8)){for((l<65||l>122||l>90&&l<97)&&95!==l&&58!==l&&(g("illegal first char attribute name"),c=!0),u=y+1;u<b;u++)if(!((l=v.charCodeAt(u))>96&&l<1