UNPKG

camunda-bpmn-js

Version:

Embeddable Camunda modeling distributions based on bpmn-js

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