bpmn-js
Version:
A bpmn 2.0 toolkit and web modeler
7 lines • 555 kB
JavaScript
/*! bpmn-js - bpmn-modeler v18.16.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="undefined"!=typeof globalThis?globalThis:e||self).BpmnJS=t()}(this,(function(){"use strict";function e(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,i={exports:{}};var r=function(){if(n)return i.exports;n=1;var e=i.exports=function(t,n){if(n||(n=16),void 0===t&&(t=128),t<=0)return"0";for(var i=Math.log(Math.pow(2,t))/Math.log(n),r=2;i===1/0;r*=2)i=Math.log(Math.pow(2,t/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,t)?e(t,n):a};return e.rack=function(t,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");t+=i}var s=e(t,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=t||128,r.base=n||16,r},i.exports}(),o=t(r);function a(e){if(!(this instanceof a))return new a(e);e=e||[128,36,1],this._seed=e.length?o.rack(e[0],e[1],e[2]):e}function s(e){return Array.prototype.concat.apply([],e)}a.prototype.next=function(e){return this._seed(e||!0)},a.prototype.nextPrefixed=function(e,t){var n;do{n=e+this.next(!0)}while(this.assigned(n));return this.claim(n,t),n},a.prototype.claim=function(e,t){this._seed.set(e,t||!0)},a.prototype.assigned=function(e){return this._seed.get(e)||!1},a.prototype.unclaim=function(e){delete this._seed.hats[e]},a.prototype.clear=function(){var e,t=this._seed.hats;for(e in t)this.unclaim(e)};const c=Object.prototype.toString,p=Object.prototype.hasOwnProperty;function l(e){return void 0===e}function u(e){return void 0!==e}function h(e){return null==e}function d(e){return"[object Array]"===c.call(e)}function f(e){return"[object Object]"===c.call(e)}function m(e){return"[object Number]"===c.call(e)}function g(e){const t=c.call(e);return"[object Function]"===t||"[object AsyncFunction]"===t||"[object GeneratorFunction]"===t||"[object AsyncGeneratorFunction]"===t||"[object Proxy]"===t}function v(e){return"[object String]"===c.call(e)}function y(e,t){return!h(e)&&p.call(e,t)}function b(e,t){const n=O(t);let i;return w(e,(function(e,t){if(n(e,t))return i=e,!1})),i}function _(e,t){const n=O(t);let i=d(e)?-1:void 0;return w(e,(function(e,t){if(n(e,t))return i=t,!1})),i}function x(e,t){const n=O(t);let i=[];return w(e,(function(e,t){n(e,t)&&i.push(e)})),i}function w(e,t){let n,i;if(l(e))return;const r=d(e)?$:L;for(let o in e)if(y(e,o)&&(n=e[o],i=t(n,r(o)),!1===i))return n}function E(e,t){if(l(e))return[];!function(e){if(!d(e))throw new Error("must supply array")}(e);const n=O(t);return e.filter((function(e,t){return!n(e,t)}))}function S(e,t,n){return w(e,(function(e,i){n=t(n,e,i)})),n}function C(e,t){return!!S(e,(function(e,n,i){return e&&t(n,i)}),!0)}function k(e,t){return!!b(e,t)}function R(e,t){let n=[];return w(e,(function(e,i){n.push(t(e,i))})),n}function P(e){return e&&Object.keys(e)||[]}function A(e){return R(e,(e=>e))}function M(e,t,n={}){return t=j(t),w(e,(function(e){let i=t(e)||"_",r=n[i];r||(r=n[i]=[]),r.push(e)})),n}function T(e,...t){e=j(e);let n={};return w(t,(t=>M(t,e,n))),R(n,(function(e,t){return e[0]}))}const D=T;function B(e,t){t=j(t);let n=[];return w(e,(function(e,i){let r=t(e,i),o={d:r,v:e};for(var a=0;a<n.length;a++){let{d:e}=n[a];if(r<e)return void n.splice(a,0,o)}n.push(o)})),R(n,(e=>e.v))}function N(e){return function(t){return C(e,(function(e,n){return t[n]===e}))}}function j(e){return g(e)?e:t=>t[e]}function O(e){return g(e)?e:t=>t===e}function L(e){return e}function $(e){return Number(e)}function I(e,t){let n,i,r,o;function a(n){let a=Date.now(),p=n?0:o+t-a;if(p>0)return s(p);e.apply(r,i),c()}function s(e){n=setTimeout(a,e)}function c(){n&&clearTimeout(n),n=o=i=r=void 0}function p(...e){o=Date.now(),i=e,r=this,n||s(t)}return p.flush=function(){n&&a(!0),c()},p.cancel=c,p}function F(e,t){return e.bind(t)}function z(e,...t){return Object.assign(e,...t)}function H(e,t){let n={},i=Object(e);return w(t,(function(t){t in i&&(n[t]=e[t])})),n}function V(e,t){let n={};return w(Object(e),(function(e,i){-1===t.indexOf(i)&&(n[i]=e)})),n}const G={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};function W(e,t=globalThis.document){if("string"!=typeof e)throw new TypeError("String expected");const n=/^<!--(.*?)-->$/s.exec(e);if(n)return t.createComment(n[1]);const i=/<([\w:]+)/.exec(e)?.[1];if(!i)return t.createTextNode(e);if(e=e.trim(),"body"===i){const n=t.createElement("html");n.innerHTML=e;const{lastChild:i}=n;return i.remove(),i}let[r,o,a]=Object.hasOwn(G,i)?G[i]:G._default,s=t.createElement("div");for(s.innerHTML=o+e+a;r--;)s=s.lastChild;if(s.firstChild===s.lastChild){const{firstChild:e}=s;return e.remove(),e}const c=t.createDocumentFragment();return c.append(...s.childNodes),c}function U(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}function q(e,...t){const n=e.style;return w(t,(function(e){e&&w(e,(function(e,t){n[t]=e}))})),e}function K(e,t,n){return 2==arguments.length?e.getAttribute(t):null===n?e.removeAttribute(t):(e.setAttribute(t,n),e)}G.td=G.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],G.option=G.optgroup=[1,'<select multiple="multiple">',"</select>"],G.thead=G.tbody=G.colgroup=G.caption=G.tfoot=[1,"<table>","</table>"],G.polyline=G.ellipse=G.polygon=G.circle=G.text=G.line=G.path=G.rect=G.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];const Y=Object.prototype.toString;function X(e){return new Z(e)}function Z(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function Q(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function J(e,t,n){var i=n?e:e.parentNode;return i&&"function"==typeof i.closest&&i.closest(t)||null}function ee(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Z.prototype.add=function(e){return this.list.add(e),this},Z.prototype.remove=function(e){return"[object RegExp]"==Y.call(e)?this.removeMatching(e):(this.list.remove(e),this)},Z.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Z.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Z.prototype.array=function(){return Array.from(this.list)},Z.prototype.has=Z.prototype.contains=function(e){return this.list.contains(e)};var te,ne={};var ie=function(){if(te)return ne;var e,t,n;function i(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n="addEventListener"!==e?"on":""}return te=1,ne.bind=function(t,r,o,a){return e||i(),t[e](n+r,o,a||!1),o},ne.unbind=function(e,r,o,a){return t||i(),e[t](n+r,o,a||!1),o},ne}(),re=U({__proto__:null,default:ee(ie)},[ie]),oe=["focus","blur"];var 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=J(r,t,!0),n.delegateTarget&&i.call(e,n)}),r)},unbind:function(e,t,n,i){return-1!==oe.indexOf(t)&&(i=!0),re.unbind(e,t,n,i)}};function se(e,t){return e&&"function"==typeof e.matches&&e.matches(t)||!1}function ce(e,t){return(t=t||document).querySelector(e)}function pe(e,t){return(t=t||document).querySelectorAll(e)}function le(e){e.parentNode&&e.parentNode.removeChild(e)}function ue(e,t){return function(e,t){t.appendChild(function(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch(e){}return e}(e,t))}(t,e),e}var he={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":2,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":2,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function de(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),r=he[i];r?(2===r&&"number"==typeof n&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function fe(e,t,n){if("string"==typeof t){if(void 0===n)return function(e,t){return he[t]?e.style[t]:e.getAttributeNS(null,t)}(e,t);de(e,t,n)}else!function(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)de(e,i,t[i])}(e,t);return e}const me=Object.prototype.toString;function ge(e){return new ve(e)}function ve(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}function ye(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function be(e){return e.cloneNode(!0)}ve.prototype.add=function(e){return this.list.add(e),this},ve.prototype.remove=function(e){return"[object RegExp]"==me.call(e)?this.removeMatching(e):(this.list.remove(e),this)},ve.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},ve.prototype.toggle=function(e,t){return void 0!==t?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},ve.prototype.array=function(){return Array.from(this.list)},ve.prototype.has=ve.prototype.contains=function(e){return this.list.contains(e)};var _e="http://www.w3.org/2000/svg",xe='<svg xmlns="'+_e+'"';function we(e){var t=!1;"<svg"===e.substring(0,4)?-1===e.indexOf(_e)&&(e=xe+e.substring(4)):(e=xe+">"+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 Ee(e,t){var n;return"<"===(e=e.trim()).charAt(0)?(n=we(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS(_e,e),t&&fe(n,t),n}var Se=null;function Ce(){return null===Se&&(Se=Ee("svg")),Se}function ke(e,t){var n,i,r=Object.keys(t);for(n=0;i=r[n];n++)e[i]=t[i];return e}function Re(e){return Ce().createSVGTransform()}var Pe=/([&<>]{1})/g,Ae=/([&<>\n\r"]{1})/g,Me={"&":"&","<":"<",">":">",'"':"'"};function Te(e,t){return e.replace(t,(function(e,t){return Me[t]||t}))}function De(e,t){var n,i,r,o,a;switch(e.nodeType){case 3:t.push(Te(e.textContent,Pe));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,'="',Te(o.value,Ae),'"');if(e.hasChildNodes()){for(t.push(">"),n=0,i=(a=e.childNodes).length;n<i;++n)De(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("\x3c!--",Te(e.nodeValue,Pe),"--\x3e");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function Be(e,t){return function(e){for(var t=e.firstChild,n=[];t;)De(t,n),t=t.nextSibling;return n.join("")}(e)}function Ne(e){var t=e.parentNode;return t&&t.removeChild(e),e}function je(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function Oe(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(je(e,i))}(n,t)),n.consolidate()}const Le=/^class[ {]/;function $e(e){return Array.isArray(e)}function Ie(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Fe(...e){1===e.length&&$e(e[0])&&(e=e[0]);const t=(e=[...e]).pop();return t.$inject=e,t}const ze=/constructor\s*[^(]*\(\s*([^)]*)\)/m,He=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,Ve=/\/\*([^*]*)\*\//m;function Ge(e){if("function"!=typeof e)throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(function(e){return Le.test(e.toString())}(e)?ze:He);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map((e=>{const t=e.match(Ve);return(t&&t[1]||e).trim()}))||[]}function We(e,t){const n=t||{get:function(e,t){if(i.push(e),!1===t)return null;throw s(`No provider for "${e}"!`)}},i=[],r=this._providers=Object.create(n._providers||null),o=this._instances=Object.create(null),a=o.injector=this,s=function(e){const t=i.join(" -> ");return i.length=0,new Error(t?`${e} (Resolving: ${t})`:e)};function c(e,t){if(!r[e]&&e.includes(".")){const t=e.split(".");let n=c(t.shift());for(;t.length;)n=n[t.shift()];return n}if(Ie(o,e))return o[e];if(Ie(r,e)){if(-1!==i.indexOf(e))throw i.push(e),s("Cannot resolve circular dependency!");return i.push(e),o[e]=r[e][0](r[e][1]),i.pop(),o[e]}return n.get(e,t)}function p(e,t){if(void 0===t&&(t={}),"function"!=typeof e){if(!$e(e))throw s(`Cannot invoke "${e}". Expected a function!`);e=Fe(e.slice())}return{fn:e,dependencies:(e.$inject||Ge(e)).map((e=>Ie(t,e)?t[e]:c(e)))}}function l(e){const{fn:t,dependencies:n}=p(e);return new(Function.prototype.bind.call(t,null,...n))}function u(e,t,n){const{fn:i,dependencies:r}=p(e,n);return i.apply(t,r)}function h(e){return Fe((t=>e.get(t)))}function d(e,t){if(t&&t.length){const n=Object.create(null),i=Object.create(null),o=[],a=[],s=[];let c,p,l,u;for(let e in r)c=r[e],-1!==t.indexOf(e)&&("private"===c[2]?(p=o.indexOf(c[3]),-1===p?(l=c[3].createChild([],t),u=h(l),o.push(c[3]),a.push(l),s.push(u),n[e]=[u,e,"private",l]):n[e]=[s[p],e,"private",a[p]]):n[e]=[c[2],c[1]],i[e]=!0),"factory"!==c[2]&&"type"!==c[2]||!c[1].$scope||t.forEach((t=>{-1!==c[1].$scope.indexOf(t)&&(n[e]=[c[2],c[1]],i[t]=!0)}));t.forEach((e=>{if(!i[e])throw new Error('No provider for "'+e+'". Cannot use provider from the parent!')})),e.unshift(n)}return new We(e,a)}const f={factory:u,type:l,value:function(e){return e}};function m(e,t){const n=e.__init__||[];return function(){n.forEach((e=>{"string"==typeof e?t.get(e):t.invoke(e)}))}}function g(e){const t=e.__exports__;if(t){const n=e.__modules__,i=Object.keys(e).reduce(((t,n)=>("__exports__"!==n&&"__modules__"!==n&&"__init__"!==n&&"__depends__"!==n&&(t[n]=e[n]),t)),Object.create(null)),o=d((n||[]).concat(i)),a=Fe((function(e){return o.get(e)}));t.forEach((function(e){r[e]=[a,e,"private",o]}));const s=(e.__init__||[]).slice();return s.unshift((function(){o.init()})),m(e=Object.assign({},e,{__init__:s}),o)}return Object.keys(e).forEach((function(t){if("__init__"===t||"__depends__"===t)return;const n=e[t];if("private"===n[2])return void(r[t]=n);const i=n[0],o=n[1];r[t]=[f[i],Ue(i,o),i]})),m(e,a)}function v(e,t){return-1!==e.indexOf(t)||-1!==(e=(t.__depends__||[]).reduce(v,e)).indexOf(t)?e:e.concat(t)}this.get=c,this.invoke=u,this.instantiate=l,this.createChild=d,this.init=function(e){const t=e.reduce(v,[]).map(g);let n=!1;return function(){n||(n=!0,t.forEach((e=>e())))}}(e)}function Ue(e,t){return"value"!==e&&$e(t)&&(t=Fe(t.slice())),t}function qe(e,t){var n=this;t=t||1e3,e.on(["render.shape","render.connection"],t,(function(e,t){var i=e.type,r=t.element,o=t.gfx,a=t.attrs;if(n.canRender(r))return"render.shape"===i?n.drawShape(o,r,a):n.drawConnection(o,r,a)})),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 Ke(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function Ye(e){return["L",e.x,e.y]}function Xe(e,t){const n=e.length,i=[(r=e[0],["M",r.x,r.y])];var r,o,a,s;for(let r=1;r<n;r++){const n=e[r-1],c=e[r],p=e[r+1];if(!p||!t){i.push(Ye(c));continue}const l=Math.min(t,Qe(c.x-n.x,c.y-n.y),Qe(p.x-c.x,p.y-c.y));if(!l){i.push(Ye(c));continue}const u=Ze(c,n,l),h=Ze(c,n,.5*l),d=Ze(c,p,l),f=Ze(c,p,.5*l);i.push(Ye(u)),i.push((a=f,s=d,["C",(o=h).x,o.y,a.x,a.y,s.x,s.y]))}return i}function Ze(e,t,n){const i=t.x-e.x,r=t.y-e.y,o=n/Qe(i,r);return{x:e.x+i*o,y:e.y+r*o}}function Qe(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function Je(e,t,n){m(t)&&(n=t,t=null),t||(t={});const i=Ee("path",t);return m(n)&&(i.dataset.cornerRadius=String(n)),et(i,e)}function et(e,t){return fe(e,{d:Ke(Xe(t,parseInt(e.dataset.cornerRadius,10)||0))}),e}function tt(e){return x(e,(function(t){return!b(e,(function(e){return e!==t&&nt(t,e)}))}))}function nt(e,t){if(t){if(e===t)return t;if(e.parent)return nt(e.parent,t)}}function it(e,t,n){var i=!n||-1===e.indexOf(t);return i&&e.push(t),i}function rt(e,t,n){n=n||0,d(e)||(e=[e]),w(e,(function(e,i){var r=t(e,i,n);d(r)&&r.length&&rt(r,t,n+1)}))}function ot(e,t,n){var i=[],r=[];return rt(e,(function(e,n,o){it(i,e,t);var a=e.children;if(a&&it(r,a,t))return a})),i}function at(e,t){return ot(e,!t)}function st(e,t){var n,i,r,o;return t=!!t,d(e)||(e=[e]),w(e,(function(e){var a=e;e.waypoints&&!t&&(a=st(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 ct(e,t){var n={};return w(e,(function(e){var i=e;i.waypoints&&(i=st(i)),!m(t.y)&&i.x>t.x&&(n[e.id]=e),!m(t.x)&&i.y>t.y&&(n[e.id]=e),i.x>t.x&&i.y>t.y&&(m(t.width)&&m(t.height)&&i.width+i.x<t.width+t.x&&i.height+i.y<t.height+t.y?n[e.id]=e:m(t.width)&&m(t.height)||(n[e.id]=e))})),n}function pt(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function lt(e){return!(!e||!e.isFrame)}function ut(e,t){return z({},e||{},t||{})}qe.prototype.canRender=function(e){},qe.prototype.drawShape=function(e,t){},qe.prototype.drawConnection=function(e,t){},qe.prototype.getShapePath=function(e){},qe.prototype.getConnectionPath=function(e){};function ht(e,t){qe.call(this,e,1),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}e(ht,qe),ht.prototype.canRender=function(){return!0},ht.prototype.drawShape=function(e,t,n){var i=Ee("rect");return fe(i,{x:0,y:0,width:t.width||0,height:t.height||0}),lt(t)?fe(i,z({},this.FRAME_STYLE,n||{})):fe(i,z({},this.SHAPE_STYLE,n||{})),ue(e,i),i},ht.prototype.drawConnection=function(e,t,n){var i=Je(t.waypoints,z({},this.CONNECTION_STYLE,n||{}));return ue(e,i),i},ht.prototype.getShapePath=function(e){var t=e.x,n=e.y,i=e.width;return Ke([["M",t,n],["l",i,0],["l",0,e.height],["l",-i,0],["z"]])},ht.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 Ke(r)},ht.$inject=["eventBus","styles"];var dt={__init__:["defaultRenderer"],defaultRenderer:["type",ht],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 z(this.style(t,n),{class:e})},this.style=function(t,n){d(t)||n||(n=t,t=[]);var i=S(t,(function(t,n){return z(t,e[n]||{})}),{});return n?z(i,n):i},this.computeStyle=function(e,n,i){return d(n)||(i=n,n=[]),t.style(n||[],z({},i,e||{}))}}]};function ft(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return-1!==n&&e.splice(n,1),n}function mt(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 gt(e,t){return e&&t?e.indexOf(t):-1}function vt(e,t){return e&&t?Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)):-1}function yt(e,t,n,i){if(void 0===i&&(i=5),!e||!t||!n)return!1;var r=(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),o=vt(e,t);return Math.abs(r/o)<=i}function bt(e,t){var n=Array.from(arguments).flat();const i={x:"v",y:"h"};for(const[e,t]of Object.entries(i))if(_t(e,n))return t;return!1}function _t(e,t){const n=t[0];return C(t,(function(t){return Math.abs(n[e]-t[e])<=2}))}function xt(e,t,n){return n=n||0,e.x>t.x-n&&e.y>t.y-n&&e.x<t.x+t.width+n&&e.y<t.y+t.height+n}function wt(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}
/**
* This file contains source code adapted from Snap.svg (licensed Apache-2.0).
*
* @see https://github.com/adobe-webplatform/Snap.svg/blob/master/src/path.js
*/var Et=/,?([a-z]),?/gi,St=parseFloat,Ct=Math,kt=Ct.PI,Rt=Ct.min,Pt=Ct.max,At=Ct.pow,Mt=Ct.abs,Tt=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/gi,Dt=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/gi,Bt=Array.isArray||function(e){return e instanceof Array};function Nt(e){return function t(){var n,i,r=Array.prototype.slice.call(arguments,0).join("␀"),o=t.cache=t.cache||{},a=t.count=t.count||[];return n=o,i=r,Object.prototype.hasOwnProperty.call(n,i)?(function(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return e.push(e.splice(n,1)[0])}(a,r),o[r]):(a.length>=1e3&&delete o[a.shift()],a.push(r),o[r]=e(...arguments),o[r])}}function jt(e){if(!e)return null;var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},n=[];return String(e).replace(Tt,(function(e,i,r){var o=[],a=i.toLowerCase();for(r.replace(Dt,(function(e,t){t&&o.push(+t)})),"m"==a&&o.length>2&&(n.push([i,...o.splice(0,2)]),a="l",i="m"==i?"l":"L");o.length>=t[a]&&(n.push([i,...o.splice(0,t[a])]),t[a]););})),n.toString=Lt,n}function Ot(e,t,n,i){return 1===arguments.length&&(t=e.y,n=e.width,i=e.height,e=e.x),{x:e,y:t,width:n,height:i,x2:e+n,y2:t+i}}function Lt(){return this.join(",").replace(Et,"$1")}function $t(e,t,n,i,r,o,a,s,c){var p=1-c,l=At(p,3),u=At(p,2),h=c*c*c,d=l*t+3*u*c*i+3*p*c*c*o+h*s;return{x:Gt(l*e+3*u*c*n+3*p*c*c*r+h*a),y:Gt(d)}}function It(e){var t=function(e,t,n,i,r,o,a,s){for(var c,p,l,u,h,d,f,m,g=[],v=[[],[]],y=0;y<2;++y)if(0==y?(p=6*e-12*n+6*r,c=-3*e+9*n-9*r+3*a,l=3*n-3*e):(p=6*t-12*i+6*o,c=-3*t+9*i-9*o+3*s,l=3*i-3*t),Mt(c)<1e-12){if(Mt(p)<1e-12)continue;0<(u=-l/p)&&u<1&&g.push(u)}else f=p*p-4*l*c,m=Ct.sqrt(f),f<0||(0<(h=(-p+m)/(2*c))&&h<1&&g.push(h),0<(d=(-p-m)/(2*c))&&d<1&&g.push(d));var b,_=g.length,x=_;for(;_--;)b=1-(u=g[_]),v[0][_]=b*b*b*e+3*b*b*u*n+3*b*u*u*r+u*u*u*a,v[1][_]=b*b*b*t+3*b*b*u*i+3*b*u*u*o+u*u*u*s;return v[0][x]=e,v[1][x]=t,v[0][x+1]=a,v[1][x+1]=s,v[0].length=v[1].length=x+2,{x0:Rt(...v[0]),y0:Rt(...v[1]),x1:Pt(...v[0]),y1:Pt(...v[1])}}(...e);return Ot(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function Ft(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function zt(e,t,n,i,r){return e*(e*(-3*t+9*n-9*i+3*r)+6*t-12*n+6*i)-3*t+3*n}function Ht(e,t,n,i,r,o,a,s,c){null==c&&(c=1);for(var p=(c=c>1?1:c<0?0:c)/2,l=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],u=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],h=0,d=0;d<12;d++){var f=p*l[d]+p,m=zt(f,e,n,r,a),g=zt(f,t,i,o,s),v=m*m+g*g;h+=u[d]*Ct.sqrt(v)}return p*h}function Vt(e,t,n,i,r,o,a,s){if(!(Pt(e,n)<Rt(r,a)||Rt(e,n)>Pt(r,a)||Pt(t,i)<Rt(o,s)||Rt(t,i)>Pt(o,s))){var c=(e*i-t*n)*(o-s)-(t-i)*(r*s-o*a),p=(e-n)*(o-s)-(t-i)*(r-a);if(p){var l=Gt(((e*i-t*n)*(r-a)-(e-n)*(r*s-o*a))/p),u=Gt(c/p),h=+l.toFixed(2),d=+u.toFixed(2);if(!(h<+Rt(e,n).toFixed(2)||h>+Pt(e,n).toFixed(2)||h<+Rt(r,a).toFixed(2)||h>+Pt(r,a).toFixed(2)||d<+Rt(t,i).toFixed(2)||d>+Pt(t,i).toFixed(2)||d<+Rt(o,s).toFixed(2)||d>+Pt(o,s).toFixed(2)))return{x:l,y:u}}}}function Gt(e){return Math.round(1e11*e)/1e11}function Wt(e,t,n){if(!function(e,t){return e=Ot(e),Ft(t=Ot(t),e.x,e.y)||Ft(t,e.x2,e.y)||Ft(t,e.x,e.y2)||Ft(t,e.x2,e.y2)||Ft(e,t.x,t.y)||Ft(e,t.x2,t.y)||Ft(e,t.x,t.y2)||Ft(e,t.x2,t.y2)||(e.x<t.x2&&e.x>t.x||t.x<e.x2&&t.x>e.x)&&(e.y<t.y2&&e.y>t.y||t.y<e.y2&&t.y>e.y)}(It(e),It(t)))return[];var i,r,o=Ht(...e),a=Ht(...t),s=qt(e)?1:~~(o/5)||1,c=qt(t)?1:~~(a/5)||1,p=new Array(s+1),l=new Array(c+1),u={},h=[];for(i=0;i<s+1;i++){var d=$t(...e,i/s);p[i]={x:d.x,y:d.y,t:i/s}}for(i=0;i<c+1;i++)d=$t(...t,i/c),l[i]={x:d.x,y:d.y,t:i/c};for(i=0;i<s;i++)for(r=0;r<c;r++){var f,m=p[i],g=p[i+1],v=l[r],y=l[r+1],b=Mt(g.x-m.x)<.01?"y":"x",_=Mt(y.x-v.x)<.01?"y":"x",x=Vt(m.x,m.y,g.x,g.y,v.x,v.y,y.x,y.y);if(x){if(u[f=x.x.toFixed(9)+"#"+x.y.toFixed(9)])continue;u[f]=!0;var w=m.t+Mt((x[b]-m[b])/(g[b]-m[b]))*(g.t-m.t),E=v.t+Mt((x[_]-v[_])/(y[_]-v[_]))*(y.t-v.t);w>=0&&w<=1&&E>=0&&E<=1&&h.push({x:x.x,y:x.y,t1:w,t2:E})}}return h}function Ut(e,t,n){e=Zt(e),t=Zt(t);for(var i,r,o,a,s,c,p,l,u,h,d=n?0:[],f=0,m=e.length;f<m;f++){var g=e[f];if("M"==g[0])i=s=g[1],r=c=g[2];else{"C"==g[0]?(i=(u=[i,r,...g.slice(1)])[6],r=u[7]):(u=[i,r,i,r,s,c,s,c],i=s,r=c);for(var v=0,y=t.length;v<y;v++){var b=t[v];if("M"==b[0])o=p=b[1],a=l=b[2];else{"C"==b[0]?(o=(h=[o,a,...b.slice(1)])[6],a=h[7]):(h=[o,a,o,a,p,l,p,l],o=p,a=l);for(var _=Wt(u,h),x=0,w=_.length;x<w;x++)_[x].segment1=f,_[x].segment2=v,_[x].bez1=u,_[x].bez2=h;d=d.concat(_)}}}}return d}function qt(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function Kt(e,t,n,i){return[e,t,n,i,n,i]}function Yt(e,t,n,i,r,o){var a=1/3,s=2/3;return[a*e+s*n,a*t+s*i,a*r+s*n,a*o+s*i,r,o]}function Xt(e,t,n,i,r,o,a,s,c,p){var l,u=120*kt/180,h=kt/180*(+r||0),d=[],f=Nt((function(e,t,n){return{x:e*Ct.cos(n)-t*Ct.sin(n),y:e*Ct.sin(n)+t*Ct.cos(n)}}));if(p)E=p[0],S=p[1],x=p[2],w=p[3];else{e=(l=f(e,t,-h)).x,t=l.y;var m=(e-(s=(l=f(s,c,-h)).x))/2,g=(t-(c=l.y))/2,v=m*m/(n*n)+g*g/(i*i);v>1&&(n*=v=Ct.sqrt(v),i*=v);var y=n*n,b=i*i,_=(o==a?-1:1)*Ct.sqrt(Mt((y*b-y*g*g-b*m*m)/(y*g*g+b*m*m))),x=_*n*g/i+(e+s)/2,w=_*-i*m/n+(t+c)/2,E=Ct.asin(((t-w)/i).toFixed(9)),S=Ct.asin(((c-w)/i).toFixed(9));(E=e<x?kt-E:E)<0&&(E=2*kt+E),(S=s<x?kt-S:S)<0&&(S=2*kt+S),a&&E>S&&(E-=2*kt),!a&&S>E&&(S-=2*kt)}var C=S-E;if(Mt(C)>u){var k=S,R=s,P=c;S=E+u*(a&&S>E?1:-1),d=Xt(s=x+n*Ct.cos(S),c=w+i*Ct.sin(S),n,i,r,0,a,R,P,[S,k,x,w])}C=S-E;var A=Ct.cos(E),M=Ct.sin(E),T=Ct.cos(S),D=Ct.sin(S),B=Ct.tan(C/4),N=4/3*n*B,j=4/3*i*B,O=[e,t],L=[e+N*M,t-j*A],$=[s+N*D,c-j*T],I=[s,c];if(L[0]=2*O[0]-L[0],L[1]=2*O[1]-L[1],p)return[L,$,I].concat(d);for(var F=[],z=0,H=(d=[L,$,I].concat(d).join().split(",")).length;z<H;z++)F[z]=z%2?f(d[z-1],d[z],h).y:f(d[z],d[z+1],h).x;return F}function Zt(e){if(function(e){return Bt(e)&&Bt(e[0])}(e)||(e=jt(e)),function(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if("M"!==i&&"C"!==i)return!1}return!0}(e))return e;for(var t=function(e){for(var t=new Array(e.length),n=0,i=e.length;n<i;n++)for(var r=e[n],o=t[n]=new Array(r.length),a=0,s=r.length;a<s;a++)o[a]=r[a];return t.toString=Lt,t}(function(e){if(function(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if("string"==typeof i&&i!==i.toUpperCase())return!1}return!0}(e))return e;var t,n=new Array(e.length),i=0,r=0,o=0,a=0,s=0;"M"==e[0][0]&&(o=i=+e[0][1],a=r=+e[0][2],s++,n[0]=["M",i,r]);for(var c,p,l=s,u=e.length;l<u;l++){if(t=(p=e[l])[0],n[l]=c=new Array(p.length),t!=t.toUpperCase())switch(c[0]=t.toUpperCase(),c[0]){case"A":c[1]=p[1],c[2]=p[2],c[3]=p[3],c[4]=p[4],c[5]=p[5],c[6]=+p[6]+i,c[7]=+p[7]+r;break;case"V":c[1]=+p[1]+r;break;case"H":c[1]=+p[1]+i;break;case"M":o=+p[1]+i,a=+p[2]+r;default:for(var h=1,d=p.length;h<d;h++)c[h]=+p[h]+(h%2?i:r)}else for(var f=0,m=p.length;f<m;f++)c[f]=p[f];switch(t=t.toUpperCase(),c[0]){case"Z":i=+o,r=+a;break;case"H":i=c[1];break;case"V":r=c[1];break;case"M":o=c[c.length-2],a=c[c.length-1];default:i=c[c.length-2],r=c[c.length-1]}}return n.toString=Lt,n}(e)),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=function(e,t,n){var i,r;if(!e)return["C",t.x,t.y,t.x,t.y,t.x,t.y];switch(!(e[0]in{T:1,Q:1})&&(t.qx=t.qy=null),e[0]){case"M":t.X=e[1],t.Y=e[2];break;case"A":e=["C",...Xt(t.x,t.y,...e.slice(1))];break;case"S":"C"==n||"S"==n?(i=2*t.x-t.bx,r=2*t.y-t.by):(i=t.x,r=t.y),e=["C",i,r,...e.slice(1)];break;case"T":"Q"==n||"T"==n?(t.qx=2*t.x-t.qx,t.qy=2*t.y-t.qy):(t.qx=t.x,t.qy=t.y),e=["C",...Yt(t.x,t.y,t.qx,t.qy,e[1],e[2])];break;case"Q":t.qx=e[1],t.qy=e[2],e=["C",...Yt(t.x,t.y,e[1],e[2],e[3],e[4])];break;case"L":e=["C",...Kt(t.x,t.y,e[1],e[2])];break;case"H":e=["C",...Kt(t.x,t.y,e[1],t.y)];break;case"V":e=["C",...Kt(t.x,t.y,t.x,e[1])];break;case"Z":e=["C",...Kt(t.x,t.y,t.X,t.Y)]}return e},r=function(e,n){if(e[n].length>7){e[n].shift();for(var i=e[n];i.length;)o[n]="A",e.splice(n++,0,["C",...i.splice(0,6)]);e.splice(n,1),p=t.length}},o=[],a="",s="",c=0,p=t.length;c<p;c++){t[c]&&(a=t[c][0]),"C"!=a&&(o[c]=a,c&&(s=o[c-1])),t[c]=i(t[c],n,s),"A"!=o[c]&&"C"==a&&(o[c]="C"),r(t,c);var l=t[c],u=l.length;n.x=l[u-2],n.y=l[u-1],n.bx=St(l[u-4])||n.x,n.by=St(l[u-3])||n.y}return t}function Qt(e){return f(e)&&y(e,"waypoints")}function Jt(e){return f(e)&&y(e,"labelTarget")}function en(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function tn(e){return{x:Math.round(e.x),y:Math.round(e.y)}}function nn(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function rn(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function on(e){for(var t=e.waypoints,n=t.reduce((function(e,n,i){var r=t[i-1];if(r){var o=e[e.length-1],a=o&&o.endLength||0,s=function(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}(r,n);e.push({start:r,end:n,startLength:a,endLength:a+s,length:s})}return e}),[]),i=n.reduce((function(e,t){return e+t.length}),0),r=i/2,o=0,a=n[o];a.endLength<r;)a=n[++o];var s=(r-a.startLength)/a.length;return{x:a.start.x+(a.end.x-a.start.x)*s,y:a.start.y+(a.end.y-a.start.y)*s}}function an(e){return Qt(e)?on(e):tn({x:(t=e).x+(t.width||0)/2,y:t.y+(t.height||0)/2});var t}function sn(e,t,n){f(n=n||0)||(n={x:n,y:n});var i=nn(e),r=nn(t),o=i.bottom+n.y<=r.top,a=i.left-n.x>=r.right,s=i.top-n.y>=r.bottom,c=o?"top":s?"bottom":null,p=i.right+n.x<=r.left?"left":a?"right":null;return p&&c?c+"-"+p:p||c||"intersect"}function cn(e,t,n){var i=function(e,t){return Ut(e,t)}(e,t);return 1===i.length||2===i.length&&vt(i[0],i[1])<1?tn(i[0]):i.length>1?(i=B(i,(function(e){var t=Math.floor(100*e.t2)||1;return t=((t=100-t)<10?"0":"")+t,e.segment2+"#"+t})),tn(i[n?0:i.length-1])):null}function pn(e,t){return Math.round(e*t)/t}function ln(e){return m(e)?e+"px":e}function un(e,t,n){const i=Ee("g");ge(i).add(t);const r=void 0!==n?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[r]||null),i}const hn={shape:["x","y","width","height"],connection:["waypoints"]};function dn(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(e||{})}function fn(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}dn.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],dn.prototype._init=function(e){const t=this._eventBus,n=this._container=function(e){const t=(e=z({},{width:"100%",height:"100%"},e)).container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),q(n,{position:"relative",overflow:"hidden",width:ln(e.width),height:ln(e.height)}),t.appendChild(n),n}(e),i=this._svg=Ee("svg");fe(i,{width:"100%",height:"100%"}),K(i,"tabindex",0),e.autoFocus&&t.on("element.hover",(()=>{this.restoreFocus()})),t.on("element.mousedown",500,(e=>{this.focus()})),i.addEventListener("focusin",(()=>{this._setFocused(!0)})),i.addEventListener("focusout",(()=>{this._setFocused(!1)})),i.addEventListener("mouseover",(()=>{this._eventBus.fire("canvas.mouseover")})),i.addEventListener("mouseout",(()=>{this._eventBus.fire("canvas.mouseout")})),ue(n,i);const r=this._viewport=un(i,"viewport");e.deferUpdate&&(this._viewboxChanged=I(F(this._viewboxChanged,this),300)),t.on("diagram.init",(()=>{t.fire("canvas.init",{svg:i,viewport:r})})),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],(()=>{delete this._cachedViewbox})),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},dn.prototype._destroy=function(){this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});const e=this._container.parentNode;e&&e.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport},dn.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},dn.prototype._clear=function(){this._elementRegistry.getAll().forEach((e=>{const t=pt(e);"root"===t?this.removeRootElement(e):this._removeElement(e,t)})),this._planes=[],this._rootElement=null,delete this._cachedViewbox},dn.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},dn.prototype.restoreFocus=function(){document.activeElement===document.body&&this.focus()},dn.prototype.isFocused=function(){return this._focused},dn.prototype.getDefaultLayer=function(){return this.getLayer("base",0)},dn.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");let 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},dn.prototype._getChildIndex=function(e){return S(this._layers,(function(t,n){return n.visible&&e>=n.index&&t++,t}),0)},dn.prototype._createLayer=function(e,t){void 0===t&&(t=1);const n=this._getChildIndex(t);return{group:un(this._viewport,"layer-"+e,n),index:t,visible:!0}},dn.prototype.showLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=this._viewport,i=t.group,r=t.index;if(t.visible)return i;const o=this._getChildIndex(r);return n.insertBefore(i,n.childNodes[o]||null),t.visible=!0,i},dn.prototype.hideLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=t.group;return t.visible?(Ne(n),t.visible=!1,n):n},dn.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],Ne(t.group))},dn.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},dn.prototype.findRoot=function(e){if("string"==typeof e&&(e=this._elementRegistry.get(e)),!e)return;const t=this._findPlaneForRoot(function(e){for(;e.parent;)e=e.parent;return e}(e))||{};return t.rootElement},dn.prototype.getRootElements=function(){return this._planes.map((function(e){return e.rootElement}))},dn.prototype._findPlaneForRoot=function(e){return b(this._planes,(function(t){return t.rootElement===e}))},dn.prototype.getContainer=function(){return this._container},dn.prototype._updateMarker=function(e,t,n){let i;e.id||(e=this._elementRegistry.get(e)),e.markers=e.markers||new Set,i=this._elementRegistry._elements[e.id],i&&(w([i.gfx,i.secondaryGfx],(function(i){i&&(n?(e.markers.add(t),ge(i).add(t)):(e.markers.delete(t),ge(i).remove(t)))})),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},dn.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},dn.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},dn.prototype.hasMarker=function(e,t){return e.id||(e=this._elementRegistry.get(e)),!!e.markers&&e.markers.has(t)},dn.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},dn.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},dn.prototype.addRootElement=function(e){const t=this._rootsIdx++;e||(e={id:"__implicitroot_"+t,children:[],isImplicit:!0});const n=e.layer="root-"+t;this._ensureValid("root",e);const i=this.getLayer(n,0);return this.hideLayer(n),this._addRoot(e,i),this._planes.push({rootElement:e,layer:i}),e},dn.prototype.removeRootElement=function(e){"string"==typeof e&&(e=this._elementRegistry.get(e));if(this._findPlaneForRoot(e))return this._removeRoot(e),this._removeLayer(e.layer),this._planes=this._planes.filter((function(t){return t.rootElement!==e})),this._rootElement===e&&(this._rootElement=null),e},dn.prototype.setRootElement=function(e){if(e===this._rootElement)return e;let t;if(!e)throw new Error("rootElement required");return t=this._findPlaneForRoot(e),t||(e=this.addRootElement(e)),this._setRoot(e),e},dn.prototype._removeRoot=function(e){const t=this._elementRegistry,n=this._eventBus;n.fire("root.remove",{element:e}),n.fire("root.removed",{element:e}),t.remove(e)},dn.prototype._addRoot=function(e,t){const n=this._elementRegistry,i=this._eventBus;i.fire("root.add",{element:e}),n.add(e,t),i.fire("root.added",{element:e,gfx:t})},dn.prototype._setRoot=function(e,t){const n=this._rootElement;n&&(this._elementRegistry.updateGraphics(n,null,!0),this.hideLayer(n.layer)),e&&(t||(t=this._findPlaneForRoot(e).layer),this._elementRegistry.updateGraphics(e,this._svg,!0),this.showLayer(e.layer)),this._rootElement=e,this._eventBus.fire("root.set",{element:e})},dn.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 <"+t.id+"> already exists");const n=hn[e],i=C(n,(function(e){return void 0!==t[e]}));if(!i)throw new Error("must supply { "+n.join(", ")+" } with "+e)},dn.prototype._setParent=function(e,t,n){mt(t.children,e,n),e.parent=t},dn.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();const r=this._eventBus,o=this._graphicsFactory;this._ensureValid(e,t),r.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);const 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},dn.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},dn.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},dn.prototype._removeElement=function(e,t){const 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),ft(e.parent&&e.parent.children,e),e.parent=null,r.fire(t+".removed",{element:e}),n.remove(e),e},dn.prototype.removeShape=function(e){return this._removeElement(e,"shape")},dn.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},dn.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},dn.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},dn.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},dn.prototype.viewbox=function(e){if(void 0===e&&this._cachedViewbox)return structuredClone(this._cachedViewbox);const t=this._viewport,n=this.getSize();let i,r,o,a,s,c,p;return e?(this._changeViewbox((function(){s=Math.min(n.width/e.width,n.height/e.height);const i=this._svg.createSVGMatrix().scale(s).translate(-e.x,-e.y);Oe(t,i)})),e):(o=this._rootElement?this.getActiveLayer():null,i=o&&o.getBBox()||{},a=Oe(t),r=a?a.matrix:function(e,t,n,i,r,o){var a=Ce().createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return ke(a,e);case 6:return ke(a,{a:e,b:t,c:n,d:i,e:r,f:o})}}(),s=pn(r.a,1e3),c=pn(-r.e||0,1e3),p=pn(-r.f||0,1e3),e=this._cachedViewbox={x:c?c/s:0,y:p?p/s:0,width:n.width/s,height:n.height/s,scale:s,inner:{width:i.width||0,height:i.height||0,x:i.x||0,y:i.y||0},outer:n})},dn.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox((function(){e=z({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),fn(t,n)})),{x:n.e,y:n.f}},dn.prototype.scrollToElement=function(e,t){let n=100;"string"==typeof e&&(e=this._elementRegistry.get(e));const i=this.findRoot(e);if(i!==this.getRootElement()&&this.setRootElement(i),i===e)return;t||(t={}),"number"==typeof t&&(n=t),t={top:t.top||n,right:t.right||n,bottom:t.bottom||n,left:t.left||n};const r=st(e),o=nn(r),a=this.viewbox(),s=this.zoom();let c,p;a.y+=t.top/s,a.x+=t.left/s,a.width-=(t.right+t.left)/s,a.height-=(t.bottom+t.top)/s;const l=nn(a);if(r.width<a.width&&r.height<a.height){const e=Math.max(0,o.right-l.right),t=Math.min(0,o.left-l.left),n=Math.max(0,o.bottom-l.bottom),i=Math.min(0,o.top-l.top);c=e||t,p=n||i}else c=r.x-a.x,p=r.y-a.y;this.scroll({dx:-c*s,dy:-p*s})},dn.prototype.zoom=function(e,t){if(!e)return this.viewbox(e).scale;if("fit-viewport"===e)return this._fitViewport(t);let n,i;return this._changeViewbox((function(){"object"!=typeof t&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)})),pn(i.a,1e3)},dn.prototype._fitViewport=function(e){const t=this.viewbox(),n=t.outer,i=t.inner;let r,o;return i.x>=0&&i.y>=0&&i.x+i.width<=n.width&&i.y+i.height<=n.height&&!e?o={x:0,y:0,width:Math.max(i.width+i.x,n.width),height:Math.max(i.height+i.y,n.height)}:(r=Math.min(1,n.width/i.width,n.height/i.height),o={x:i.x+(e?i.width/2-n.width/r/2:0),y:i.y+(e?i.height/2-n.height/r/2:0),width:n.width/r,height:n.height/r}),this.viewbox(o),this.viewbox(!1).scale},dn.prototype._setZoom=function(e,t){const n=this._svg,i=this._viewport,r=n.createSVGMatrix(),o=n.createSVGPoint();let a,s,c,p,l;c=i.getCTM();const u=c.a;return t?(a=z(o,t),s=a.matrixTransform(c.inverse()),p=r.translate(s.x,s.y).scale(1/u*e).translate(-s.x,-s.y),l=c.multiply(p)):l=r.scale(e),fn(this._viewport,l),l},dn.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},dn.prototype.getAbsoluteBBox=function(e){const t=this.viewbox();let n;if(e.waypoints){n=this.getGraphics(e).getBBox()}else n=e;return{x:n.x*t.scale-t.x*t.scale,y:n.y*t.scale-t.y*t.scale,width:n.width*t.scale,height:n.height*t.scale}},dn.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var mn="data-element-id";function gn(e){this._elements={},this._eventBus=e}function vn(e,t,n){var i=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}(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 yn(e,t){if(!(this instanceof yn))return new yn(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}gn.$inject=["eventBus"],gn.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),fe(t,mn,i),n&&fe(n,mn,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},gn.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(fe(i.gfx,mn,""),i.secondaryGfx&&fe(i.secondaryGfx,mn,""),delete t[n])},gn.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)},gn.prototype.updateGraphics=function(e,t,n){var i=e.id||e,r=this._elements[i];return n?r.secondaryGfx=t:r.gfx=t,t&&fe(t,mn,i),t},gn.prototype.get=function(e){var t;t="string"==typeof e?e:e&&fe(e,mn);var n=this._elements[t];return n&&n.element},gn.prototype.filter=function(e){var t=[];return this.forEach((function(n,i){e(n,i)&&t.push(n)})),t},gn.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),i=0;i<n.length;i++){var r=t[n[i]],o=r.element;if(e(o,r.gfx))return o}},gn.prototype.getAll=function(){return this.filter((function(e){return e}))},gn.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)}))},gn.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},gn.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")},yn.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?vn(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)},yn.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return function(e){return!0===e.__refs_collection}(n)||vn(this,t,e),n},yn.prototype.ensureBound=function(e,t){(function(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)})(e,t)||this.bind(e,t)},yn.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},yn.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var bn=new yn({name:"children",enumerable:!0,collection:!0},{name:"parent"}),_n=new yn({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),xn=new yn({name:"attachers",collection:!0},{name:"host"}),wn=new yn({name:"outgoing",collection:!0},{name:"source"}),En=new yn({name:"incoming",collection:!0},{name:"target"});function Sn(){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)}}),bn.bind(this,"parent"),_n.bind(this,"labels"),wn.bind(this,"outgoing"),En.bind(this,"incoming")}function Cn(){Sn.call(this),bn.bind(this,"children"),xn.bind(this,"host"),xn.bind(this,"attachers")}function kn(){Sn.call(this),bn.bind(this,"children")}function Rn(){Cn.call(this),_n.bind(this,"labelTarget")}function Pn(){Sn.call(this),wn.bind(this,"source"),En.bind(this,"target")}e(Cn,Sn),e(kn,Cn),e(Rn,Cn),e(Pn,Sn);var An={connection:Pn,shape:Cn,label:Rn,root:kn};function Mn(){this._uid=12}Mn.prototype.createRoot=function(e){return this.create("root",e)},Mn.prototype.createLabel=function(e){return this.create("label",e)},Mn.prototype.createShape=function(e){return this.create("shape",e)},Mn.prototype.createConnection=function(e){return this.create("connection",e)},Mn.prototype.create=function(e,t){return(t=z({},t||{})).id||(t.id=e+"_"+this._uid++),function(e,t){var n=An[e];if(!n)throw new Error("unknown type: <"+e+">");return z(new n,t)}(e,t)};var Tn="__fn",Dn=Array.prototype.slice;function Bn(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}function Nn(){}function jn(e){return e.childNodes[0]}function On(e,t,n,i,r){var o=Re();o.setTranslate(t,n);var a=Re();a.setRotate(i||0,0,0);var s=Re();s.setScale(1,1),Oe(e,[o,a,s])}function Ln(e,t,n){var i=Re();i.setTranslate(t,n),Oe(e,i)}function $n(e,t){var n=Re();n.setRotate(t,0,0),Oe(e,n)}function In(e,t){this._eventBus=e,this._elementRegistry=t}function Fn(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}Bn.prototype.on=function(e,t,n,i){if(e=d(e)?e:[e],g(t)&&(i=n,n=t,t=1e3),!m(t))throw new Error("priority must be a number");var r=n;i&&((r=F(n,i))[Tn]=n[Tn]||n);var o=this;e.forEach((function(e){o._addListener(e,{priority:t,callback:r,next:null})}))},Bn.prototype.once=function(e,t,n,i){var r=this;if(g(t)&&(i=n,n=t,t=1e3),!m(t))throw new Error("priority must be a number");function o(){o.__isTomb=!0;var t=n.apply(i,arguments);return r.off(e,o),t}o[Tn]=n,this.on(e,t,o)},Bn.prototype.off=function(e,t){e=d(e)?e:[e];var n=this;e.forEach((function(e){n._removeListener(e,t)}))},Bn.prototype.createEvent=function(e){var t=new Nn;return t.init(e),t},Bn.prototype.fire=function(e,t){var n,i,r,o;if(o=Dn.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 Nn?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}},Bn.prototype.handleError=function(e){return!1===this.fire("error",{error:e})},Bn.prototype._destroy=function(){this._listeners={}},Bn.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},Bn.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{i=function(e,t){return e.apply(null,t)}(n.callback,t),void 0!==i&&(e.returnValue=i,e.stopPropagation()),!1===i&&e.preventDefault()}catch(e){if(!this.handleError(e))throw console.error("unhandled error in event listener",e),e}return i},Bn.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)},Bn.prototype._getListeners=function(e){return this._listeners[e]},Bn.prototype._setListeners=function(e,t){this._listeners[e]=t},Bn.prototype._removeListener=function(e,t){var n,i,r,o=this._getListeners(e);if(t)for(;o;)n=o