@quandis/qbo4.ui 4.0.1-CI-20240507-231949 → 4.0.1-CI-20240514-221435
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/qbo/qbo-form-edit.js +4 -5
- package/src/qbo/qbo-form-edit.ts +4 -5
- package/src/qbo/qbo-ssn.d.ts +7 -0
- package/src/qbo/qbo-ssn.js +43 -8
- package/src/qbo/qbo-ssn.ts +29 -8
- package/wwwroot/js/qbo4.ui-flowchart.js +37 -17
- package/wwwroot/js/qbo4.ui-flowchart.min.js +2 -2
- package/wwwroot/js/qbo4.ui-flowchart.min.js.map +1 -1
- package/wwwroot/js/qbo4.ui.js +150 -116
- package/wwwroot/js/qbo4.ui.min.js +8 -8
- package/wwwroot/js/qbo4.ui.min.js.map +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! For license information please see qbo4.ui-flowchart.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.qbo4=e():(t.qbo4=t.qbo4||{},t.qbo4["ui-flowchart"]=e())}(self,(()=>(()=>{var t={630:(t,e,n)=>{var i;!function(t){!function(e){var i="object"==typeof globalThis?globalThis:"object"==typeof n.g?n.g:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=o(t);function o(t,e){return function(n,i){Object.defineProperty(t,n,{configurable:!0,writable:!0,value:i}),e&&e(n,i)}}void 0!==i.Reflect&&(r=o(i.Reflect,r)),function(t,e){var n=Object.prototype.hasOwnProperty,i="function"==typeof Symbol,r=i&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=i&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",s="function"==typeof Object.create,a={__proto__:[]}instanceof Array,l=!s&&!a,c={create:s?function(){return $(Object.create(null))}:a?function(){return $({__proto__:null})}:function(){return $({})},has:l?function(t,e){return n.call(t,e)}:function(t,e){return e in t},get:l?function(t,e){return n.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},h=Object.getPrototypeOf(Function),u="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:function(){var t={},e=[],n=function(){function t(t,e,n){this._index=0,this._keys=t,this._values=e,this._selector=n}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var n=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}();return function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var n=this._find(t,!0);return this._values[n]=e,this},e.prototype.delete=function(e){var n=this._find(e,!1);if(n>=0){for(var i=this._keys.length,r=n+1;r<i;r++)this._keys[r-1]=this._keys[r],this._values[r-1]=this._values[r];return this._keys.length--,this._values.length--,R(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new n(this._keys,this._values,i)},e.prototype.values=function(){return new n(this._keys,this._values,r)},e.prototype.entries=function(){return new n(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!R(this._cacheKey,t)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(R(this._keys[n],t)){this._cacheIndex=n;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();function i(t,e){return t}function r(t,e){return e}function s(t,e){return[t,e]}}(),d="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:function(){function t(){this._map=new u}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[o]=function(){return this.keys()},t}(),f="function"==typeof WeakMap?WeakMap:function(){var t=16,e=c.create(),i=r();return function(){function t(){this._key=r()}return t.prototype.has=function(t){var e=o(t,!1);return void 0!==e&&c.has(e,this._key)},t.prototype.get=function(t){var e=o(t,!1);return void 0!==e?c.get(e,this._key):void 0},t.prototype.set=function(t,e){return o(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=o(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=r()},t}();function r(){var t;do{t="@@WeakMap@@"+a()}while(c.has(e,t));return e[t]=!0,t}function o(t,e){if(!n.call(t,i)){if(!e)return;Object.defineProperty(t,i,{value:c.create()})}return t[i]}function s(t,e){for(var n=0;n<e;++n)t[n]=255*Math.random()|0;return t}function a(){var e=function(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):s(e,t),e}return s(new Array(t),t)}(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var n="",i=0;i<t;++i){var r=e[i];4!==i&&6!==i&&8!==i||(n+="-"),r<16&&(n+="0"),n+=r.toString(16).toLowerCase()}return n}}(),p=i?Symbol.for("@reflect-metadata:registry"):void 0,g=function(){var t;return!S(p)&&_(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[p]),S(t)&&(t=function(){var t,n,i,r;S(p)||void 0===e.Reflect||p in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=function(t){var e=t.defineMetadata,n=t.hasOwnMetadata,i=t.getOwnMetadata,r=t.getOwnMetadataKeys,o=t.deleteMetadata,s=new f;return{isProviderFor:function(t,e){var n=s.get(t);return!(S(n)||!n.has(e))||!!r(t,e).length&&(S(n)&&(n=new d,s.set(t,n)),n.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:i,OrdinaryOwnMetadataKeys:r,OrdinaryDeleteMetadata:o}}(e.Reflect));var o=new f,s={registerProvider:a,getProvider:c,setProvider:g};return s;function a(e){if(!Object.isExtensible(s))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case S(n):n=e;break;case n===e:break;case S(i):i=e;break;case i===e:break;default:void 0===r&&(r=new d),r.add(e)}}function l(e,o){if(!S(n)){if(n.isProviderFor(e,o))return n;if(!S(i)){if(i.isProviderFor(e,o))return n;if(!S(r))for(var s=B(r);;){var a=D(s);if(!a)return;var l=I(a);if(l.isProviderFor(e,o))return V(s),l}}}if(!S(t)&&t.isProviderFor(e,o))return t}function c(t,e){var n,i=o.get(t);return S(i)||(n=i.get(e)),S(n)?(S(n=l(t,e))||(S(i)&&(i=new u,o.set(t,i)),i.set(e,n)),n):n}function h(t){if(S(t))throw new TypeError;return n===t||i===t||!S(r)&&r.has(t)}function g(t,e,n){if(!h(n))throw new Error("Metadata provider not registered.");var i=c(t,e);if(i!==n){if(!S(i))return!1;var r=o.get(t);S(r)&&(r=new u,o.set(t,r)),r.set(e,n)}return!0}}()),!S(p)&&_(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,p,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}(),m=function(t){var e=new f,n={isProviderFor:function(t,n){var i=e.get(t);return!S(i)&&i.has(n)},OrdinaryDefineOwnMetadata:function(t,e,n,r){i(n,r,!0).set(t,e)},OrdinaryHasOwnMetadata:function(t,e,n){var r=i(e,n,!1);return!S(r)&&L(r.has(t))},OrdinaryGetOwnMetadata:function(t,e,n){var r=i(e,n,!1);if(!S(r))return r.get(t)},OrdinaryOwnMetadataKeys:function(t,e){var n=[],r=i(t,e,!1);if(S(r))return n;for(var o=B(r.keys()),s=0;;){var a=D(o);if(!a)return n.length=s,n;var l=I(a);try{n[s]=l}catch(t){try{V(o)}finally{throw t}}s++}},OrdinaryDeleteMetadata:function(t,n,r){var o=i(n,r,!1);if(S(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var s=e.get(n);S(s)||(s.delete(r),0===s.size&&e.delete(s))}return!0}};return g.registerProvider(n),n;function i(i,r,o){var s=e.get(i),a=!1;if(S(s)){if(!o)return;s=new u,e.set(i,s),a=!0}var l=s.get(r);if(S(l)){if(!o)return;if(l=new u,s.set(r,l),!t.setProvider(i,r,n))throw s.delete(r),a&&e.delete(i),new Error("Wrong provider for target.")}return l}}(g);function v(t,e,n){if(y(t,e,n))return!0;var i=z(e);return!P(i)&&v(t,i,n)}function y(t,e,n){var i=j(e,n,!1);return!S(i)&&L(i.OrdinaryHasOwnMetadata(t,e,n))}function b(t,e,n){if(y(t,e,n))return w(t,e,n);var i=z(e);return P(i)?void 0:b(t,i,n)}function w(t,e,n){var i=j(e,n,!1);if(!S(i))return i.OrdinaryGetOwnMetadata(t,e,n)}function x(t,e,n,i){j(n,i,!0).OrdinaryDefineOwnMetadata(t,e,n,i)}function A(t,e){var n=T(t,e),i=z(t);if(null===i)return n;var r=A(i,e);if(r.length<=0)return n;if(n.length<=0)return r;for(var o=new d,s=[],a=0,l=n;a<l.length;a++){var c=l[a];o.has(c)||(o.add(c),s.push(c))}for(var h=0,u=r;h<u.length;h++)c=u[h],o.has(c)||(o.add(c),s.push(c));return s}function T(t,e){var n=j(t,e,!1);return n?n.OrdinaryOwnMetadataKeys(t,e):[]}function E(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function S(t){return void 0===t}function P(t){return null===t}function _(t){return"object"==typeof t?null!==t:"function"==typeof t}function k(t,e){switch(E(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var n=3===e?"string":5===e?"number":"default",i=F(t,r);if(void 0!==i){var o=i.call(t,n);if(_(o))throw new TypeError;return o}return function(t,e){if("string"===e){var n=t.toString;if(O(n)&&!_(r=n.call(t)))return r;if(O(i=t.valueOf)&&!_(r=i.call(t)))return r}else{var i;if(O(i=t.valueOf)&&!_(r=i.call(t)))return r;var r,o=t.toString;if(O(o)&&!_(r=o.call(t)))return r}throw new TypeError}(t,"default"===n?"number":n)}function L(t){return!!t}function C(t){var e=k(t,3);return"symbol"==typeof e?e:function(t){return""+t}(e)}function M(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function O(t){return"function"==typeof t}function N(t){return"function"==typeof t}function R(t,e){return t===e||t!=t&&e!=e}function F(t,e){var n=t[e];if(null!=n){if(!O(n))throw new TypeError;return n}}function B(t){var e=F(t,o);if(!O(e))throw new TypeError;var n=e.call(t);if(!_(n))throw new TypeError;return n}function I(t){return t.value}function D(t){var e=t.next();return!e.done&&e}function V(t){var e=t.return;e&&e.call(t)}function z(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===h)return e;if(e!==h)return e;var n=t.prototype,i=n&&Object.getPrototypeOf(n);if(null==i||i===Object.prototype)return e;var r=i.constructor;return"function"!=typeof r||r===t?e:r}function j(t,e,n){var i=g.getProvider(t,e);if(!S(i))return i;if(n){if(g.setProvider(t,e,m))return m;throw new Error("Illegal state.")}}function $(t){return t.__=void 0,delete t.__,t}t("decorate",(function(t,e,n,i){if(S(n)){if(!M(t))throw new TypeError;if(!N(e))throw new TypeError;return function(t,e){for(var n=t.length-1;n>=0;--n){var i=(0,t[n])(e);if(!S(i)&&!P(i)){if(!N(i))throw new TypeError;e=i}}return e}(t,e)}if(!M(t))throw new TypeError;if(!_(e))throw new TypeError;if(!_(i)&&!S(i)&&!P(i))throw new TypeError;return P(i)&&(i=void 0),function(t,e,n,i){for(var r=t.length-1;r>=0;--r){var o=(0,t[r])(e,n,i);if(!S(o)&&!P(o)){if(!_(o))throw new TypeError;i=o}}return i}(t,e,n=C(n),i)})),t("metadata",(function(t,e){return function(n,i){if(!_(n))throw new TypeError;if(!S(i)&&!function(t){switch(E(t)){case 3:case 4:return!0;default:return!1}}(i))throw new TypeError;x(t,e,n,i)}})),t("defineMetadata",(function(t,e,n,i){if(!_(n))throw new TypeError;return S(i)||(i=C(i)),x(t,e,n,i)})),t("hasMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return S(n)||(n=C(n)),v(t,e,n)})),t("hasOwnMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return S(n)||(n=C(n)),y(t,e,n)})),t("getMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return S(n)||(n=C(n)),b(t,e,n)})),t("getOwnMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return S(n)||(n=C(n)),w(t,e,n)})),t("getMetadataKeys",(function(t,e){if(!_(t))throw new TypeError;return S(e)||(e=C(e)),A(t,e)})),t("getOwnMetadataKeys",(function(t,e){if(!_(t))throw new TypeError;return S(e)||(e=C(e)),T(t,e)})),t("deleteMetadata",(function(t,e,n){if(!_(e))throw new TypeError;if(S(n)||(n=C(n)),!_(e))throw new TypeError;S(n)||(n=C(n));var i=j(e,n,!1);return!S(i)&&i.OrdinaryDeleteMetadata(t,e,n)}))}(r,i),void 0===i.Reflect&&(i.Reflect=t)}()}(i||(i={}))}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";n.r(i),n.d(i,{QboFlowchart:()=>yd});var t={};n.r(t),n.d(t,{ellipseWithEllipse:()=>He,ellipseWithLine:()=>qe,exists:()=>Ue,lineWithLine:()=>Ge,pathWithEllipse:()=>an,pathWithLine:()=>sn,pathWithPath:()=>un,pathWithPolygon:()=>hn,pathWithPolyline:()=>cn,pathWithRect:()=>ln,polygonWithEllipse:()=>en,polygonWithLine:()=>tn,polygonWithPolygon:()=>on,polygonWithPolyline:()=>rn,polygonWithRect:()=>nn,polylineWithEllipse:()=>Ke,polylineWithLine:()=>Ze,polylineWithPolyline:()=>Qe,polylineWithRect:()=>Je,rectWithEllipse:()=>Ye,rectWithLine:()=>We,rectWithRect:()=>Xe});var e={};n.r(e),n.d(e,{Curve:()=>_e,Ellipse:()=>ae,Line:()=>ne,Path:()=>Le,Point:()=>Jt,Polygon:()=>$e,Polyline:()=>xe,Rect:()=>me,bezier:()=>je,ellipse:()=>le,intersection:()=>wn,line:()=>ie,normalizeAngle:()=>Ct,point:()=>Qt,random:()=>Rt,rect:()=>ve,scale:()=>Lt,snapToGrid:()=>Mt,toDeg:()=>Ot,toRad:()=>Nt,types:()=>jt});var r={};n.r(r),n.d(r,{addClass:()=>hs,append:()=>ts,appendTo:()=>ns,children:()=>fs,clone:()=>Jo,closest:()=>ps,css:()=>ss,data:()=>as,detach:()=>Zo,empty:()=>Ko,hasClass:()=>ds,height:()=>bs,html:()=>Qo,off:()=>vs,offset:()=>xs,on:()=>gs,one:()=>ms,position:()=>ws,prepend:()=>es,prependTo:()=>is,remove:()=>Xo,removeClass:()=>cs,toggleClass:()=>us,width:()=>ys});var o={};n.r(o),n.d(o,{animate:()=>Es,stop:()=>Ps});var s={};n.r(s),n.d(s,{absolute:()=>fl,bottom:()=>bl,ellipse:()=>xl,ellipseSpread:()=>wl,fn:()=>pl,left:()=>ml,line:()=>gl,right:()=>vl,top:()=>yl});var a={};n.r(a),n.d(a,{bottom:()=>Ml,inside:()=>Fl,insideOriented:()=>Rl,left:()=>kl,manual:()=>_l,outside:()=>Nl,outsideOriented:()=>Ol,radial:()=>Bl,radialOriented:()=>Il,right:()=>Ll,top:()=>Cl});var l={};n.r(l),n.d(l,{BorderedImage:()=>Kl,Circle:()=>ql,Cylinder:()=>ec,DoubleLink:()=>oc,Ellipse:()=>Hl,EmbeddedImage:()=>Jl,HeaderedRectangle:()=>tc,Image:()=>Zl,InscribedImage:()=>Ql,Link:()=>rc,Path:()=>Wl,Polygon:()=>Yl,Polyline:()=>Xl,Rectangle:()=>Gl,ShadowLink:()=>sc,TextBlock:()=>ic});var c={};n.r(c),n.d(c,{standard:()=>l});var h={};n.r(h),n.d(h,{manhattan:()=>wh,metro:()=>Ah,normal:()=>zc,oneSide:()=>jc,orthogonal:()=>nh,rightAngle:()=>Dh});var u={};n.r(u),n.d(u,{curve:()=>ou,jumpover:()=>Jh,normal:()=>Qh,rounded:()=>eu,smooth:()=>nu,straight:()=>Uh});var d={};n.r(d),n.d(d,{addClass:()=>Eu,list:()=>Pu,mask:()=>xu,opacity:()=>Au,stroke:()=>bu});var f={};n.r(f),n.d(f,{connectionClosest:()=>Ou,connectionLength:()=>ku,connectionPerpendicular:()=>Mu,connectionRatio:()=>_u,resolveRef:()=>Lu});var p={};n.r(p),n.d(p,{anchor:()=>Du,bbox:()=>Vu,boundary:()=>ju,rectangle:()=>zu});var g={};n.r(g),n.d(g,{bottom:()=>qu,bottomLeft:()=>Zu,bottomRight:()=>Ku,center:()=>Uu,left:()=>Hu,midSide:()=>Qu,modelCenter:()=>td,perpendicular:()=>Ju,right:()=>Wu,top:()=>Gu,topLeft:()=>Yu,topRight:()=>Xu}),n(630);const m=globalThis,v=m.ShadowRoot&&(void 0===m.ShadyCSS||m.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,y=Symbol(),b=new WeakMap;class w{constructor(t,e,n){if(this._$cssResult$=!0,n!==y)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(v&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=b.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&b.set(e,t))}return t}toString(){return this.cssText}}const x=(t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,n,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[i+1]),t[0]);return new w(n,t,y)},A=v?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new w("string"==typeof t?t:t+"",void 0,y))(e)})(t):t,{is:T,defineProperty:E,getOwnPropertyDescriptor:S,getOwnPropertyNames:P,getOwnPropertySymbols:_,getPrototypeOf:k}=Object,L=globalThis,C=L.trustedTypes,M=C?C.emptyScript:"",O=L.reactiveElementPolyfillSupport,N=(t,e)=>t,R={toAttribute(t,e){switch(e){case Boolean:t=t?M:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},F=(t,e)=>!T(t,e),B={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:F};Symbol.metadata??=Symbol("metadata"),L.litPropertyMetadata??=new WeakMap;class I extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=B){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(t,n,e);void 0!==i&&E(this.prototype,t,i)}}static getPropertyDescriptor(t,e,n){const{get:i,set:r}=S(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return i?.call(this)},set(e){const o=i?.call(this);r.call(this,e),this.requestUpdate(t,o,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??B}static _$Ei(){if(this.hasOwnProperty(N("elementProperties")))return;const t=k(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(N("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(N("properties"))){const t=this.properties,e=[...P(t),..._(t)];for(const n of e)this.createProperty(n,t[n])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,n]of e)this.elementProperties.set(t,n)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const n=this._$Eu(t,e);void 0!==n&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(A(t))}else void 0!==t&&e.push(A(t));return e}static _$Eu(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const n of e.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(v)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const n of e){const e=document.createElement("style"),i=m.litNonce;void 0!==i&&e.setAttribute("nonce",i),e.textContent=n.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$EC(t,e){const n=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,n);if(void 0!==i&&!0===n.reflect){const r=(void 0!==n.converter?.toAttribute?n.converter:R).toAttribute(e,n.type);this._$Em=t,null==r?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(t,e){const n=this.constructor,i=n._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=n.getPropertyOptions(i),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:R;this._$Em=i,this[i]=r.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,n){if(void 0!==t){if(n??=this.constructor.getPropertyOptions(t),!(n.hasChanged??F)(this[t],e))return;this.P(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,n){this._$AL.has(t)||this._$AL.set(t,e),!0===n.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,n]of t)!0!==n.wrapped||this._$AL.has(e)||void 0===this[e]||this.P(e,this[e],n)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EU()}catch(e){throw t=!1,this._$EU(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU()}updated(t){}firstUpdated(t){}}I.elementStyles=[],I.shadowRootOptions={mode:"open"},I[N("elementProperties")]=new Map,I[N("finalized")]=new Map,O?.({ReactiveElement:I}),(L.reactiveElementVersions??=[]).push("2.0.4");const D=globalThis,V=D.trustedTypes,z=V?V.createPolicy("lit-html",{createHTML:t=>t}):void 0,j="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,U="?"+$,G=`<${U}>`,q=document,H=()=>q.createComment(""),W=t=>null===t||"object"!=typeof t&&"function"!=typeof t,Y=Array.isArray,X="[ \t\n\f\r]",Z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,K=/-->/g,J=/>/g,Q=RegExp(`>|${X}(?:([^\\s"'>=/]+)(${X}*=${X}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),tt=/'/g,et=/"/g,nt=/^(?:script|style|textarea|title)$/i,it=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),rt=it(1),ot=(it(2),Symbol.for("lit-noChange")),st=Symbol.for("lit-nothing"),at=new WeakMap,lt=q.createTreeWalker(q,129);function ct(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==z?z.createHTML(e):e}const ht=(t,e)=>{const n=t.length-1,i=[];let r,o=2===e?"<svg>":"",s=Z;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,h=0;for(;h<n.length&&(s.lastIndex=h,l=s.exec(n),null!==l);)h=s.lastIndex,s===Z?"!--"===l[1]?s=K:void 0!==l[1]?s=J:void 0!==l[2]?(nt.test(l[2])&&(r=RegExp("</"+l[2],"g")),s=Q):void 0!==l[3]&&(s=Q):s===Q?">"===l[0]?(s=r??Z,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?Q:'"'===l[3]?et:tt):s===et||s===tt?s=Q:s===K||s===J?s=Z:(s=Q,r=void 0);const u=s===Q&&t[e+1].startsWith("/>")?" ":"";o+=s===Z?n+G:c>=0?(i.push(a),n.slice(0,c)+j+n.slice(c)+$+u):n+$+(-2===c?e:u)}return[ct(t,o+(t[n]||"<?>")+(2===e?"</svg>":"")),i]};class ut{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let r=0,o=0;const s=t.length-1,a=this.parts,[l,c]=ht(t,e);if(this.el=ut.createElement(l,n),lt.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=lt.nextNode())&&a.length<s;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(j)){const e=c[o++],n=i.getAttribute(t).split($),s=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:s[2],strings:n,ctor:"."===s[1]?mt:"?"===s[1]?vt:"@"===s[1]?yt:gt}),i.removeAttribute(t)}else t.startsWith($)&&(a.push({type:6,index:r}),i.removeAttribute(t));if(nt.test(i.tagName)){const t=i.textContent.split($),e=t.length-1;if(e>0){i.textContent=V?V.emptyScript:"";for(let n=0;n<e;n++)i.append(t[n],H()),lt.nextNode(),a.push({type:2,index:++r});i.append(t[e],H())}}}else if(8===i.nodeType)if(i.data===U)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=i.data.indexOf($,t+1));)a.push({type:7,index:r}),t+=$.length-1}r++}}static createElement(t,e){const n=q.createElement("template");return n.innerHTML=t,n}}function dt(t,e,n=t,i){if(e===ot)return e;let r=void 0!==i?n._$Co?.[i]:n._$Cl;const o=W(e)?void 0:e._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),void 0===o?r=void 0:(r=new o(t),r._$AT(t,n,i)),void 0!==i?(n._$Co??=[])[i]=r:n._$Cl=r),void 0!==r&&(e=dt(t,r._$AS(t,e.values),r,i)),e}class ft{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,i=(t?.creationScope??q).importNode(e,!0);lt.currentNode=i;let r=lt.nextNode(),o=0,s=0,a=n[0];for(;void 0!==a;){if(o===a.index){let e;2===a.type?e=new pt(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new bt(r,this,t)),this._$AV.push(e),a=n[++s]}o!==a?.index&&(r=lt.nextNode(),o++)}return lt.currentNode=q,i}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class pt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,i){this.type=2,this._$AH=st,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=dt(this,t,e),W(t)?t===st||null==t||""===t?(this._$AH!==st&&this._$AR(),this._$AH=st):t!==this._$AH&&t!==ot&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>Y(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t))}_(t){this._$AH!==st&&W(this._$AH)?this._$AA.nextSibling.data=t:this.T(q.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,i="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=ut.createElement(ct(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new ft(i,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=at.get(t.strings);return void 0===e&&at.set(t.strings,e=new ut(t)),e}k(t){Y(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const r of t)i===e.length?e.push(n=new pt(this.S(H()),this.S(H()),this,this.options)):n=e[i],n._$AI(r),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class gt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,r){this.type=1,this._$AH=st,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=st}_$AI(t,e=this,n,i){const r=this.strings;let o=!1;if(void 0===r)t=dt(this,t,e,0),o=!W(t)||t!==this._$AH&&t!==ot,o&&(this._$AH=t);else{const i=t;let s,a;for(t=r[0],s=0;s<r.length-1;s++)a=dt(this,i[n+s],e,s),a===ot&&(a=this._$AH[s]),o||=!W(a)||a!==this._$AH[s],a===st?t=st:t!==st&&(t+=(a??"")+r[s+1]),this._$AH[s]=a}o&&!i&&this.j(t)}j(t){t===st?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class mt extends gt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===st?void 0:t}}class vt extends gt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==st)}}class yt extends gt{constructor(t,e,n,i,r){super(t,e,n,i,r),this.type=5}_$AI(t,e=this){if((t=dt(this,t,e,0)??st)===ot)return;const n=this._$AH,i=t===st&&n!==st||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,r=t!==st&&(n===st||i);i&&this.element.removeEventListener(this.name,this,n),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class bt{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){dt(this,t)}}const wt=D.litHtmlPolyfillSupport;wt?.(ut,pt),(D.litHtmlVersions??=[]).push("3.1.3");class xt extends I{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,n)=>{const i=n?.renderBefore??e;let r=i._$litPart$;if(void 0===r){const t=n?.renderBefore??null;i._$litPart$=r=new pt(e.insertBefore(H(),t),t,void 0,n??{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ot}}xt._$litElement$=!0,xt.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:xt});const At=globalThis.litElementPolyfillSupport;At?.({LitElement:xt}),(globalThis.litElementVersions??=[]).push("4.0.5");const Tt={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:F},Et=(t=Tt,e,n)=>{const{kind:i,metadata:r}=n;let o=globalThis.litPropertyMetadata.get(r);if(void 0===o&&globalThis.litPropertyMetadata.set(r,o=new Map),o.set(n.name,t),"accessor"===i){const{name:i}=n;return{set(n){const r=e.get.call(this);e.set.call(this,n),this.requestUpdate(i,r,t)},init(e){return void 0!==e&&this.P(i,void 0,t),e}}}if("setter"===i){const{name:i}=n;return function(n){const r=this[i];e.call(this,n),this.requestUpdate(i,r,t)}}throw Error("Unsupported decorator location: "+i)};function St(t){return(e,n)=>"object"==typeof n?Et(t,e,n):((t,e,n)=>{const i=e.hasOwnProperty(n);return e.constructor.createProperty(n,i?{...t,wrapped:!0}:t),i?Object.getOwnPropertyDescriptor(e,n):void 0})(t,e,n)}const{round:Pt,floor:_t,PI:kt}=Math,Lt={linear:function(t,e,n){var i=t[1]-t[0],r=e[1]-e[0];return(n-t[0])/i*r+e[0]||0}},Ct=function(t){return t%360+(t<0?360:0)},Mt=function(t,e){return e*Pt(t/e)},Ot=function(t){return 180*t/kt%360},Nt=function(t,e){return(t=(e=e||!1)?t:t%360)*kt/180},Rt=function(t,e){if(void 0===e)e=void 0===t?1:t,t=0;else if(e<t){const n=t;t=e,e=n}return _t(Math.random()*(e-t+1)+t)},{cos:Ft,sin:Bt,atan2:It}=Math,Dt=function(t,e){var n=Nt(t.y),i=Nt(e.y),r=t.x,o=e.x,s=Nt(o-r),a=Bt(s)*Ft(i),l=Ft(n)*Bt(i)-Bt(n)*Ft(i)*Ft(s),c=Ot(It(a,l))-22.5;return c<0&&(c+=360),["NE","E","SE","S","SW","W","NW","N"][c=parseInt(c/45)]},Vt=function(t,e){var n=t.x,i=t.y;return(n-=e.x)*n+(i-=e.y)*i},zt=function(t,e){return Math.sqrt(Vt(t,e))},jt={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:$t,cos:Ut,sin:Gt,sqrt:qt,min:Ht,max:Wt,atan2:Yt,round:Xt,pow:Zt,PI:Kt}=Math,Jt=function(t,e){if(!(this instanceof Jt))return new Jt(t,e);if("string"==typeof t){var n=t.split(-1===t.indexOf("@")?" ":"@");t=parseFloat(n[0]),e=parseFloat(n[1])}else Object(t)===t&&(e=t.y,t=t.x);this.x=void 0===t?0:t,this.y=void 0===e?0:e};Jt.fromPolar=function(t,e,n){n=new Jt(n);var i=$t(t*Ut(e)),r=$t(t*Gt(e)),o=Ct(Ot(e));return o<90?r=-r:o<180?(i=-i,r=-r):o<270&&(i=-i),new Jt(n.x+i,n.y+r)},Jt.random=function(t,e,n,i){return new Jt(Rt(t,e),Rt(n,i))},Jt.prototype={type:jt.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new Jt(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new Jt(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=Ht(Wt(this.x,t.x),t.x+t.width),this.y=Ht(Wt(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){var n=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return n<0&&(n+=360),n},bearing:function(t){return Dt(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new Jt(this)},cross:function(t,e){return t&&e?(e.x-this.x)*(t.y-this.y)-(e.y-this.y)*(t.x-this.x):NaN},difference:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),new Jt(this.x-(t||0),this.y-(e||0))},distance:function(t){return zt(this,t)},dot:function(t){return t?this.x*t.x+this.y*t.y:NaN},equals:function(t){return!!t&&this.x===t.x&&this.y===t.y},lerp:function(t,e){var n=this.x,i=this.y;return new Jt((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return qt(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return $t(t.x-this.x)+$t(t.y-this.y)},move:function(t,e){var n=Nt(new Jt(t).theta(this));return this.offset(Ut(n)*e,-Gt(n)*e)},normalize:function(t){var e=(t||1)/this.magnitude();return this.scale(e,e)},offset:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x+=t||0,this.y+=e||0,this},reflection:function(t){return new Jt(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new Jt(0,0),e=Nt(Ct(-e));var n=Ut(e),i=Gt(e),r=n*(this.x-t.x)-i*(this.y-t.y)+t.x,o=i*(this.x-t.x)+n*(this.y-t.y)+t.y;return this.x=r,this.y=o,this},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=Zt(10,t)}return this.x=Xt(this.x*e)/e,this.y=Xt(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new Jt(n)||new Jt(0,0),this.x=n.x+t*(this.x-n.x),this.y=n.y+e*(this.y-n.y),this},snapToGrid:function(t,e){return this.x=Mt(this.x,t),this.y=Mt(this.y,e||t),this},squaredDistance:function(t){return Vt(this,t)},theta:function(t){var e=-((t=new Jt(t)).y-this.y),n=t.x-this.x,i=Yt(e,n);return i<0&&(i=2*Kt+i),180*i/Kt},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new Jt(t)||new Jt(0,0);var e=this.x,n=this.y;return this.x=qt((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Nt(t.theta(new Jt(e,n))),this},toString:function(){return this.x+"@"+this.y},serialize:function(){return this.x+","+this.y},update:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x=t||0,this.y=e||0,this},vectorAngle:function(t){return new Jt(0,0).angleBetween(this,t)}},Jt.prototype.translate=Jt.prototype.offset;const Qt=Jt,{max:te,min:ee}=Math,ne=function(t,e){return this instanceof ne?t instanceof ne?new ne(t.start,t.end):(this.start=new Jt(t),void(this.end=new Jt(e))):new ne(t,e)};ne.prototype={type:jt.Line,angle:function(){var t=new Jt(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=ee(this.start.x,this.end.x),e=ee(this.start.y,this.end.y),n=te(this.start.x,this.end.x),i=te(this.start.y,this.end.y);return new me(t,e,n-t,i-e)},bearing:function(){return Dt(this.start,this.end)},clone:function(){return new ne(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){var e=this.vector().dot(new ne(this.start,t).vector()),n=ee(1,te(0,e/this.squaredLength()));return n!=n?0:n},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e=this.start,n=this.end;if(0!==e.cross(t,n))return!1;var i=this.length();return!(new ne(e,t).length()>i||new ne(t,n).length()>i)},divideAt:function(t){var e=this.pointAt(t);return[new ne(this.start,e),new ne(e,this.end)]},divideAtLength:function(t){var e=this.pointAtLength(t);return[new ne(this.start,e),new ne(e,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,e){if(t&&t.intersectionWithLine){var n=t.intersectionWithLine(this,e);return n&&t instanceof ne&&(n=n[0]),n}return null},intersectionWithLine:function(t){var e=new Jt(this.end.x-this.start.x,this.end.y-this.start.y),n=new Jt(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,r=new Jt(t.start.x-this.start.x,t.start.y-this.start.y),o=r.x*n.y-r.y*n.x,s=r.x*e.y-r.y*e.x;if(0===i||o*i<0||s*i<0)return null;if(i>0){if(o>i||s>i)return null}else if(o<i||s<i)return null;return[new Jt(this.start.x+o*e.x/i,this.start.y+o*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return zt(this.start,this.end)},midpoint:function(){return new Jt((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){const e=this.clone();if(!this.isDifferentiable())return e;const{start:n,end:i}=e,r=n.clone().rotate(i,270),o=i.clone().rotate(n,90);return n.move(o,t),i.move(r,t),e},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():t>=1?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0;t<0&&(i=!1,t=-t);var r=this.length();return t>=r?i?n.clone():e.clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new Jt(t);var e=this.start,n=this.end;return((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/this.length()},rotate:function(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.end.scale(t,e,n),this},setLength:function(t){var e=this.length();if(!e)return this;var n=t/e;return this.scale(n,n,this.start)},squaredLength:function(){return Vt(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAt(t),r=new ne(e,n);return r.translate(i.x-e.x,i.y-e.y),r},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAtLength(t),r=new ne(e,n);return r.translate(i.x-e.x,i.y-e.y),r},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,e){return this.start.translate(t,e),this.end.translate(t,e),this},vector:function(){return new Jt(this.end.x-this.start.x,this.end.y-this.start.y)}},ne.prototype.intersection=ne.prototype.intersect;const ie=ne,{sqrt:re,round:oe,pow:se}=Math,ae=function(t,e,n){return this instanceof ae?t instanceof ae?new ae(new Jt(t.x,t.y),t.a,t.b):(t=new Jt(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new ae(t,e,n)};ae.fromRect=function(t){return t=new me(t),new ae(t.center(),t.width/2,t.height/2)},ae.prototype={type:jt.Ellipse,bbox:function(){return new me(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new Jt(this.x,this.y)},clone:function(){return new ae(this)},containsPoint:function(t){return this.normalizedDistance(t)<=1},equals:function(t){return!!t&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.a+=2*t,this.b+=2*e,this},intersectionWithLine:function(t){var e=[],n=t.start,i=t.end,r=this.a,o=this.b,s=t.vector(),a=n.difference(new Jt(this)),l=new Jt(s.x/(r*r),s.y/(o*o)),c=new Jt(a.x/(r*r),a.y/(o*o)),h=s.dot(l),u=s.dot(c),d=u*u-h*(a.dot(c)-1);if(d<0)return null;if(d>0){var f=re(d),p=(-u-f)/h,g=(-u+f)/h;if((p<0||1<p)&&(g<0||1<g))return null;0<=p&&p<=1&&e.push(n.lerp(i,p)),0<=g&&g<=1&&e.push(n.lerp(i,g))}else{var m=-u/h;if(!(0<=m&&m<=1))return null;e.push(n.lerp(i,m))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new Jt(t),e&&t.rotate(new Jt(this.x,this.y),e);var n,i=t.x-this.x,r=t.y-this.y;if(0===i)return n=this.bbox().pointNearestToPoint(t),e?n.rotate(new Jt(this.x,this.y),-e):n;var o=r/i,s=o*o,a=this.a*this.a,l=this.b*this.b,c=re(1/(1/a+s/l)),h=o*(c=i<0?-c:c);return n=new Jt(this.x+c,this.y+h),e?n.rotate(new Jt(this.x,this.y),-e):n},normalizedDistance:function(t){var e=t.x,n=t.y,i=this.a,r=this.b,o=this.x,s=this.y;return(e-o)*(e-o)/(i*i)+(n-s)*(n-s)/(r*r)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=se(10,t)}return this.x=oe(this.x*e)/e,this.y=oe(this.y*e)/e,this.a=oe(this.a*e)/e,this.b=oe(this.b*e)/e,this},tangentTheta:function(t){var e,n,i=t.x,r=t.y,o=this.a,s=this.b,a=this.bbox().center(),l=a.x,c=a.y,h=i>a.x+o/2,u=i<a.x-o/2;return h||u?n=o*o/(i-l)-o*o*(r-c)*((e=i>a.x?r-30:r+30)-c)/(s*s*(i-l))+l:e=s*s/(r-c)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-c))+c,new Jt(n,e).theta(t)},toString:function(){return new Jt(this.x,this.y).toString()+" "+this.a+" "+this.b}};const le=ae,{abs:ce,cos:he,sin:ue,min:de,max:fe,round:pe,pow:ge}=Math,me=function(t,e,n,i){if(!(this instanceof me))return new me(t,e,n,i);Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e,this.width=void 0===n?0:n,this.height=void 0===i?0:i};me.fromEllipse=function(t){return t=new ae(t),new me(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},me.fromPointUnion=function(...t){if(0===t.length)return null;const e=new Jt;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let s=0;s<t.length;s++){e.update(t[s]);const a=e.x,l=e.y;a<n&&(n=a),a>r&&(r=a),l<i&&(i=l),l>o&&(o=l)}return new me(n,i,r-n,o-i)},me.fromRectUnion=function(...t){if(0===t.length)return null;const e=new me;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let s=0;s<t.length;s++){e.update(t[s]);const a=e.x,l=e.y,c=a+e.width,h=l+e.height;a<n&&(n=a),c>r&&(r=c),l<i&&(i=l),h>o&&(o=h)}return new me(n,i,r-n,o-i)},me.prototype={type:jt.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){if(!t)return this;const{width:e,height:n}=this,i=Nt(t),r=ce(ue(i)),o=ce(he(i)),s=e*o+n*r,a=e*r+n*o;return this.x+=(e-s)/2,this.y+=(n-a)/2,this.width=s,this.height=a,this},bottomLeft:function(){return new Jt(this.x,this.y+this.height)},bottomLine:function(){return new ne(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new Jt(this.x+this.width/2,this.y+this.height)},center:function(){return new Jt(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new me(this)},containsPoint:function(t){return t instanceof Jt||(t=new Jt(t)),t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},containsRect:function(t){var e=new me(this).normalize(),n=new me(t).normalize(),i=e.width,r=e.height,o=n.width,s=n.height;if(!(i&&r&&o&&s))return!1;var a=e.x,l=e.y,c=n.x,h=n.y;return o+=c,i+=a,s+=h,r+=l,a<=c&&o<=i&&l<=h&&s<=r},corner:function(){return new Jt(this.x+this.width,this.y+this.height)},equals:function(t){var e=new me(this).normalize(),n=new me(t).normalize();return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this},intersect:function(t){var e=this.origin(),n=this.corner(),i=t.origin(),r=t.corner();if(r.x<=e.x||r.y<=e.y||i.x>=n.x||i.y>=n.y)return null;var o=fe(e.x,i.x),s=fe(e.y,i.y);return new me(o,s,de(n.x,r.x)-o,de(n.y,r.y)-s)},intersectionWithLine:function(t){var e,n,i=this,r=[i.topLine(),i.rightLine(),i.bottomLine(),i.leftLine()],o=[],s=[],a=r.length;for(n=0;n<a;n++)null!==(e=t.intersect(r[n]))&&s.indexOf(e.toString())<0&&(o.push(e),s.push(e.toString()));return o.length>0?o:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new Jt(t);var n,i=new Jt(this.x+this.width/2,this.y+this.height/2);e&&t.rotate(i,e);for(var r=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],o=new ne(i,t),s=r.length-1;s>=0;--s){var a=r[s].intersection(o);if(null!==a){n=a;break}}return n&&e&&n.rotate(i,-e),n},leftLine:function(){return new ne(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new Jt(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){var n,i,r,o,s,a,l,c;t=new me(t),e||(e=t.center());var h=e.x,u=e.y;n=i=r=o=s=a=l=c=1/0;var d=t.topLeft();d.x<h&&(n=(this.x-h)/(d.x-h)),d.y<u&&(s=(this.y-u)/(d.y-u));var f=t.bottomRight();f.x>h&&(i=(this.x+this.width-h)/(f.x-h)),f.y>u&&(a=(this.y+this.height-u)/(f.y-u));var p=t.topRight();p.x>h&&(r=(this.x+this.width-h)/(p.x-h)),p.y<u&&(l=(this.y-u)/(p.y-u));var g=t.bottomLeft();return g.x<h&&(o=(this.x-h)/(g.x-h)),g.y>u&&(c=(this.y+this.height-u)/(g.y-u)),{sx:de(n,i,r,o),sy:de(s,a,l,c)}},maxRectUniformScaleToFit:function(t,e){var n=this.maxRectScaleToFit(t,e);return de(n.sx,n.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,e=this.y,n=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,i=-this.height),this.x=t,this.y=e,this.width=n,this.height=i,this},offset:function(t,e){return Jt.prototype.offset.call(this,t,e)},origin:function(){return new Jt(this.x,this.y)},pointNearestToPoint:function(t){if(t=new Jt(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new Jt(this.x+this.width,t.y);case"left":return new Jt(this.x,t.y);case"bottom":return new Jt(t.x,this.y+this.height);case"top":return new Jt(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new ne(this.topRight(),this.bottomRight())},rightMiddle:function(){return new Jt(this.x+this.width,this.y+this.height/2)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=ge(10,t)}return this.x=pe(this.x*e)/e,this.y=pe(this.y*e)/e,this.width=pe(this.width*e)/e,this.height=pe(this.height*e)/e,this},scale:function(t,e,n){return n=this.origin().scale(t,e,n),this.x=n.x,this.y=n.y,this.width*=t,this.height*=e,this},sideNearestToPoint:function(t){var e=(t=new Jt(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r=e,o="left";return n<r&&(r=n,o="right"),i<r&&(r=i,o="top"),this.y+this.height-t.y<r&&(o="bottom"),o},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),i=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=i.x-n.x,this.height=i.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new ne(this.topLeft(),this.topRight())},topMiddle:function(){return new Jt(this.x+this.width/2,this.y)},topRight:function(){return new Jt(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return me.fromRectUnion(this,t)},update:function(t,e,n,i){return Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=n||0,this.height=i||0,this}},me.prototype.bottomRight=me.prototype.corner,me.prototype.topLeft=me.prototype.origin,me.prototype.translate=me.prototype.offset;const ve=me;function ye(t){const e=t.trim();if(""===e)return[];const n=[],i=e.split(/\b\s*,\s*|,\s*|\s+/),r=i.length;for(let t=0;t<r;t+=2)n.push({x:+i[t],y:+i[t+1]});return n}function be(t){const e=t.length;if(0===e)return[];const n=[];for(let i=0;i<e;i++){const e=t[i].clone();n.push(e)}return n}function we(t){const{abs:e}=Math;var n,i,r,o=t.length;if(0===o)return[];for(n=0;n<o;n++)(void 0===r||t[n].y<r.y||t[n].y===r.y&&t[n].x>r.x)&&(r=t[n]);var s=[];for(n=0;n<o;n++){var a=r.theta(t[n]);0===a&&(a=360);var l=[t[n],n,a];s.push(l)}if(s.sort((function(t,e){var n=t[2]-e[2];return 0===n&&(n=e[1]-t[1]),n})),s.length>2){var c=s[s.length-1];s.unshift(c)}for(var h,u,d,f,p,g,m,v={},y=[];0!==s.length;)if(u=(h=s.pop())[0],!v.hasOwnProperty(h[0]+"@@"+h[1]))for(var b=!1;!b;)if(y.length<2)y.push(h),b=!0;else{f=(d=y.pop())[0];var w=(g=(p=y.pop())[0]).cross(f,u);if(w<0)y.push(p),y.push(d),y.push(h),b=!0;else if(0===w){var x=f.angleBetween(g,u);e(x-180)<1e-10||f.equals(u)||g.equals(f)?(v[d[0]+"@@"+d[1]]=f,y.push(p)):e((x+1)%360-1)<1e-10&&(y.push(p),s.push(d))}else v[d[0]+"@@"+d[1]]=f,y.push(p)}y.length>2&&y.pop();var A=-1;for(i=y.length,n=0;n<i;n++){var T=y[n][1];(void 0===m||T<m)&&(m=T,A=n)}var E=[];if(A>0){var S=y.slice(A),P=y.slice(0,A);E=S.concat(P)}else E=y;var _=[];for(i=E.length,n=0;n<i;n++)_.push(E[n][0]);return _}const xe=function(t){return this instanceof xe?"string"==typeof t?new xe.parse(t):void(this.points=Array.isArray(t)?t.map(Jt):[]):new xe(t)};xe.parse=function(t){return new xe(ye(t))},xe.fromRect=function(t){return new xe([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},xe.prototype={type:jt.Polyline,bbox:function(){var t=1/0,e=-1/0,n=1/0,i=-1/0,r=this.points,o=r.length;if(0===o)return null;for(var s=0;s<o;s++){var a=r[s],l=a.x,c=a.y;l<t&&(t=l),l>e&&(e=l),c<n&&(n=c),c>i&&(i=c)}return new me(t,n,e-t,i-n)},clone:function(){return new xe(be(this.points))},closestPoint:function(t){var e=this.closestPointLength(t);return this.pointAtLength(e)},closestPointLength:function(t){var e,n=this.lengthPoints(),i=n.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,o=0,s=i-1,a=0;a<s;a++){var l=new ne(n[a],n[a+1]),c=l.length(),h=l.closestPointNormalizedLength(t),u=l.pointAt(h).squaredDistance(t);u<r&&(r=u,e=o+h*c),o+=c}return e},closestPointNormalizedLength:function(t){var e=this.closestPointLength(t);if(0===e)return 0;var n=this.length();return 0===n?0:e/n},closestPointTangent:function(t){var e=this.closestPointLength(t);return this.tangentAtLength(e)},containsPoint:function(t){var e=this.points,n=e.length;if(0===n)return!1;for(var i=t.x,r=t.y,o=n-1,s=0,a=0,l=new ne,c=new ne,h=new Jt;s<n;s++){var u=e[o],d=e[s];if(t.equals(u))return!0;if(l.start=u,l.end=d,l.containsPoint(t))return!0;if(r<=u.y&&r>d.y||r>u.y&&r<=d.y){var f=u.x-i>d.x-i?u.x-i:d.x-i;f>=0&&(h.x=i+f,h.y=r,c.start=t,c.end=h,l.intersect(c)&&a++)}o=s}return a%2==1},close:function(){const{start:t,end:e,points:n}=this;return t&&e&&!t.equals(e)&&n.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new xe(we(this.points))},equals:function(t){if(!t)return!1;var e=this.points,n=t.points,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=t.points[r];if(!o.equals(s))return!1}return!0},intersectionWithLine:function(t){for(var e=new ne(t),n=[],i=this.lengthPoints(),r=new ne,o=0,s=i.length-1;o<s;o++){r.start=i[o],r.end=i[o+1];var a=e.intersectionWithLine(r);a&&n.push(a[0])}return n.length>0?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0===e)return!1;for(var n=new ne,i=e-1,r=0;r<i;r++)if(n.start=t[r],n.end=t[r+1],n.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),e=t.length;if(0===e)return 0;for(var n=0,i=e-1,r=0;r<i;r++)n+=t[r].distance(t[r+1]);return n},pointAt:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();if(t<=0)return e[0].clone();if(t>=1)return e[n-1].clone();var i=this.length()*t;return this.pointAtLength(i)},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();var i=!0;t<0&&(i=!1,t=-t);for(var r=0,o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],c=e[a+1],h=new ne(l,c),u=l.distance(c);if(t<=r+u)return h.pointAtLength((i?1:-1)*(t-r));r+=u}return(i?e[n-1]:e[0]).clone()},round:function(t){for(var e=this.points,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.points,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},simplify:function(t={}){const e=this.points;if(e.length<3)return this;const n=t.threshold||1e-10;let i=0;for(;e[i+2];){const t=i+1,r=i+2,o=e[i],s=e[t],a=e[r];new ne(o,a).closestPoint(s).distance(s)<=n?e.splice(t,1):i+=1}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;t<0&&(t=0),t>1&&(t=1);var n=this.length()*t;return this.tangentAtLength(n)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;var i,r=!0;t<0&&(r=!1,t=-t);for(var o=0,s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,c=e[l],h=e[l+1],u=new ne(c,h),d=c.distance(h);if(u.isDifferentiable()){if(t<=o+d)return u.tangentAtLength((r?1:-1)*(t-o));i=u}o+=d}if(i){var f=r?1:0;return i.tangentAt(f)}return null},toString:function(){return this.points+""},translate:function(t,e){for(var n=this.points,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var n="",i=0;i<e;i++){var r=t[i];n+=r.x+","+r.y+" "}return n.trim()}},Object.defineProperty(xe.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(xe.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});const{abs:Ae,sqrt:Te,min:Ee,max:Se,pow:Pe}=Math,_e=function(t,e,n,i){return this instanceof _e?t instanceof _e?new _e(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new Jt(t),this.controlPoint1=new Jt(e),this.controlPoint2=new Jt(n),void(this.end=new Jt(i))):new _e(t,e,n,i)};function ke(t){var e,n,i=[];for(n=arguments.length,e=1;e<n;e++)i.push(arguments[e]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=i.length,e=0;e<n;e++){var o,s,a=i[e];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}_e.throughPoints=function(){function t(t){var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}return function(e){if(!e||Array.isArray(e)&&e.length<2)throw new Error("At least 2 points are required");for(var n=function(e){var n,i=[],r=[],o=e.length-1;if(1==o)return i[0]=new Jt((2*e[0].x+e[1].x)/3,(2*e[0].y+e[1].y)/3),r[0]=new Jt(2*i[0].x-e[0].x,2*i[0].y-e[0].y),[i,r];var s=[];for(n=1;n<o-1;n++)s[n]=4*e[n].x+2*e[n+1].x;s[0]=e[0].x+2*e[1].x,s[o-1]=(8*e[o-1].x+e[o].x)/2;var a=t(s);for(n=1;n<o-1;++n)s[n]=4*e[n].y+2*e[n+1].y;s[0]=e[0].y+2*e[1].y,s[o-1]=(8*e[o-1].y+e[o].y)/2;var l=t(s);for(n=0;n<o;n++)i.push(new Jt(a[n],l[n])),n<o-1?r.push(new Jt(2*e[n+1].x-a[n+1],2*e[n+1].y-l[n+1])):r.push(new Jt((e[o].x+a[o-1])/2,(e[o].y+l[o-1])/2));return[i,r]}(e),i=[],r=n[0].length,o=0;o<r;o++){var s=new Jt(n[0][o].x,n[0][o].y),a=new Jt(n[1][o].x,n[1][o].y);i.push(new _e(e[o],s,a,e[o+1]))}return i}}(),_e.prototype={type:jt.Curve,bbox:function(){for(var t,e,n,i,r,o,s,a,l=this.start,c=this.controlPoint1,h=this.controlPoint2,u=this.end,d=l.x,f=l.y,p=c.x,g=c.y,m=h.x,v=h.y,y=u.x,b=u.y,w=new Array,x=new Array,A=[new Array,new Array],T=0;T<2;++T)if(0===T?(e=6*d-12*p+6*m,t=-3*d+9*p-9*m+3*y,n=3*p-3*d):(e=6*f-12*g+6*v,t=-3*f+9*g-9*v+3*b,n=3*g-3*f),Ae(t)<1e-12){if(Ae(e)<1e-12)continue;0<(i=-n/e)&&i<1&&x.push(i)}else a=Te(s=e*e-4*n*t),s<0||(0<(r=(-e+a)/(2*t))&&r<1&&x.push(r),0<(o=(-e-a)/(2*t))&&o<1&&x.push(o));for(var E,S,P,_=x.length,k=_;_--;)S=(E=1-(i=x[_]))*E*E*d+3*E*E*i*p+3*E*i*i*m+i*i*i*y,A[0][_]=S,P=E*E*E*f+3*E*E*i*g+3*E*i*i*v+i*i*i*b,A[1][_]=P,w[_]={X:S,Y:P};x[k]=0,x[k+1]=1,w[k]={X:d,Y:f},w[k+1]={X:y,Y:b},A[0][k]=d,A[1][k]=f,A[0][k+1]=y,A[1][k+1]=b,x.length=k+2,A[0].length=k+2,A[1].length=k+2,w.length=k+2;var L=Ee.apply(null,A[0]),C=Ee.apply(null,A[1]),M=Se.apply(null,A[0]),O=Se.apply(null,A[1]);return new me(L,C,M-L,O-C)},clone:function(){return new _e(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,i),i)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.closestPointLength(t,i);if(!r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){for(var n,i,r,o,s,a,l,c=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:c}):e.subdivisions,u=h.length,d=u?1/u:0,f=0;f<u;f++){var p=h[f],g=p.start.distance(t),m=p.end.distance(t),v=g+m;(!l||v<l)&&(n=p,i=f*d,r=(f+1)*d,o=g,s=m,a=p.start.distance(p.end),l=v)}for(var y=Pe(10,-c);;){var b=o?Ae(o-s)/o:0,w=s?Ae(o-s)/s:0;if(b<y||w<y||!o||o<a*y||!s||s<a*y)return o<=s?i:r;var x=n.divide(.5);d/=2;var A=x[0].start.distance(t),T=x[0].end.distance(t),E=A+T,S=x[1].start.distance(t),P=x[1].end.distance(t);E<=S+P?(n=x[0],r-=d,o=A,s=T):(n=x[1],i+=d,o=S,s=P)}},closestPointTangent:function(t,e){return this.tangentAtT(this.closestPointT(t,e))},containsPoint:function(t,e){return this.toPolyline(e).containsPoint(t)},divideAt:function(t,e){if(t<=0)return this.divideAtT(0);if(t>=1)return this.divideAtT(1);var n=this.tAt(t,e);return this.divideAtT(n)},divideAtLength:function(t,e){var n=this.tAtLength(t,e);return this.divideAtT(n)},divideAtT:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return[new _e(e,e,e,e),new _e(e,n,i,r)];if(t>=1)return[new _e(e,n,i,r),new _e(r,r,r,r)];var o=this.getSkeletonPoints(t),s=o.startControlPoint1,a=o.startControlPoint2,l=o.divider,c=o.dividerControlPoint1,h=o.dividerControlPoint2;return[new _e(e,s,a,l),new _e(l,c,h,r)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()};if(t>=1)return{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};var o=new ne(e,n).pointAt(t),s=new ne(n,i).pointAt(t),a=new ne(i,r).pointAt(t),l=new ne(o,s).pointAt(t),c=new ne(s,a).pointAt(t);return{startControlPoint1:o,startControlPoint2:l,divider:new ne(l,c).pointAt(t),dividerControlPoint1:c,dividerControlPoint2:a}},getSubdivisions:function(t){var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=this.start,i=this.controlPoint1,r=this.controlPoint2,o=this.end,s=[new _e(n,i,r,o)];if(0===e)return s;if(!this.isDifferentiable())return s;var a=this.endpointDistance(),l=Pe(10,-e),c=2;0===i.cross(n,o)&&0===r.cross(n,o)&&(c=2*e);for(var h=0;;){h+=1;for(var u=[],d=s.length,f=0;f<d;f++){var p=s[f].divide(.5);u.push(p[0],p[1])}for(var g=0,m=u.length,v=0;v<m;v++)g+=u[v].endpointDistance();if(h>=c&&(0!==g?(g-a)/g:0)<l)return u;s=u,a=g}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=0,r=n.length,o=0;o<r;o++)i+=n[o].endpointDistance();return i},lengthAtT:function(t,e){if(t<=0)return 0;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:n})},pointAt:function(t,e){if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();var n=this.tAt(t,e);return this.pointAtT(n)},pointAtLength:function(t,e){var n=this.tAtLength(t,e);return this.pointAtT(n)},pointAtT:function(t){return t<=0?this.start.clone():t>=1?this.end.clone():this.getSkeletonPoints(t).divider},PRECISION:3,round:function(t){return this.start.round(t),this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},tangentAt:function(t,e){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);var n=this.tAt(t,e);return this.tangentAtT(n)},tangentAtLength:function(t,e){if(!this.isDifferentiable())return null;var n=this.tAtLength(t,e);return this.tangentAtT(n)},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);var e=this.getSkeletonPoints(t),n=e.startControlPoint2,i=e.dividerControlPoint1,r=e.divider,o=new ne(n,i);return o.translate(r.x-n.x,r.y-n.y),o},tAt:function(t,e){if(t<=0)return 0;if(t>=1)return 1;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.length(i)*t;return this.tAtLength(r,i)},tAtLength:function(t,e){var n=!0;t<0&&(n=!1,t=-t);for(var i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,c=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,h={precision:l,subdivisions:c},u=0,d=c.length,f=1/d,p=0;p<d;p++){var g=n?p:d-1-p,m=c[p],v=m.endpointDistance();if(t<=u+v){i=m,r=g*f,o=(g+1)*f,s=n?t-u:v+u-t,a=n?v+u-t:t-u;break}u+=v}if(!i)return n?1:0;for(var y=this.length(h),b=Pe(10,-l);;){var w,x;if((0!==y?s/y:0)<b)return r;if((0!==y?a/y:0)<b)return o;var A=i.divide(.5);f/=2;var T=A[0].endpointDistance(),E=A[1].endpointDistance();s<=T?(i=A[0],o-=f,x=T-(w=s)):(i=A[1],r+=f,x=E-(w=s-T)),s=w,a=x}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=[n[0].start.clone()],r=n.length,o=0;o<r;o++){var s=n[o];i.push(s.end.clone())}return i},toPolyline:function(t){return new xe(this.toPoints(t))},toString:function(){return this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.start.translate(t,e),this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}},_e.prototype.divide=_e.prototype.divideAtT;const Le=function(t){if(!(this instanceof Le))return new Le(t);if("string"==typeof t)return new Le.parse(t);var e,n;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(n=(t=t.reduce((function(t,e){return t.concat(e)}),[])).length,t[0].isSegment)for(e=0;e<n;e++){var i=t[e];this.appendSegment(i)}else{var r=null;for(e=0;e<n;e++){var o=t[e];if(!(o instanceof ne||o instanceof _e))throw new Error("Cannot construct a path segment from the provided object.");0===e&&this.appendSegment(Le.createSegment("M",o.start)),r&&!r.end.equals(o.start)&&this.appendSegment(Le.createSegment("M",o.start)),o instanceof ne?this.appendSegment(Le.createSegment("L",o.end)):o instanceof _e&&this.appendSegment(Le.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),r=o}}else if(t.isSegment)this.appendSegment(t);else if(t instanceof ne)this.appendSegment(Le.createSegment("M",t.start)),this.appendSegment(Le.createSegment("L",t.end));else if(t instanceof _e)this.appendSegment(Le.createSegment("M",t.start)),this.appendSegment(Le.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof xe))throw new Error("Cannot construct a path from the provided object.");if(!t.points||0===t.points.length)return;for(n=t.points.length,e=0;e<n;e++){var s=t.points[e];0===e?this.appendSegment(Le.createSegment("M",s)):this.appendSegment(Le.createSegment("L",s))}}};function Ce(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}Le.parse=function(t){if(!t)return new Le;for(var e=new Le,n=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),i=n.length,r=0;r<i;r++){var o=n[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),s=Le.createSegment.apply(this,o);e.appendSegment(s)}return e},Le.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=Le.segmentTypes[t];if(!e)throw new Error(t+" is not a recognized path segment type.");for(var n=[],i=arguments.length,r=1;r<i;r++)n.push(arguments[r]);return Ce(e,n)},Le.prototype={type:jt.Path,appendSegment:function(t){var e,n=this.segments,i=n.length,r=0!==i?n[i-1]:null;if(Array.isArray(t)){if(!(t=t.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");for(var o=t.length,s=0;s<o;s++){var a=t[s];e=this.prepareSegment(a,r,null),n.push(e),r=e}}else{if(!t||!t.isSegment)throw new Error("Segment required.");e=this.prepareSegment(t,r,null),n.push(e)}},bbox:function(){var t,e=this.segments,n=e.length;if(0===n)return null;for(var i=0;i<n;i++){var r=e[i];if(r.isVisible){var o=r.bbox();t=t?t.union(o):o}}if(t)return t;var s=e[n-1];return new me(s.end.x,s.end.y,0,0)},clone:function(){for(var t=this.segments,e=t.length,n=new Le,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){var n=this.closestPointT(t,e);return n?this.pointAtT(n):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointT(t,i);return r?this.lengthAtT(r,i):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointLength(t,i);if(0===r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<i;l++){var c=n[l],h=s[l];if(c.isVisible){var u=c.closestPointT(t,{precision:o,subdivisions:h}),d=c.pointAtT(u),f=new ne(d,t).squaredLength();f<a&&(r={segmentIndex:l,value:u},a=f)}}return r||{segmentIndex:i-1,value:1}},closestPointTangent:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<i;l++){var c=n[l],h=s[l];if(c.isDifferentiable()){var u=c.closestPointT(t,{precision:o,subdivisions:h}),d=c.pointAtT(u),f=new ne(d,t).squaredLength();f<a&&(r=c.tangentAtT(u),a=f)}}return r||null},containsPoint:function(t,e){var n=this.toPolylines(e);if(!n)return!1;for(var i=n.length,r=0,o=0;o<i;o++)n[o].containsPoint(t)&&r++;return r%2==1},divideAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.divideAtLength(r,i)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;var i=!0;t<0&&(i=!1,t=-t);var r,o,s,a,l,c,h,u=void 0===(e=e||{}).precision?this.PRECISION:e.precision,d=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:u}):e.segmentSubdivisions,f=0;for(r=0;r<n;r++){var p=i?r:n-1-r;o=this.getSegment(p);var g=d[p],m=o.length({precision:u,subdivisions:g});if(o.isDifferentiable()&&(l=o,c=p,t<=f+m)){a=p,s=o.divideAtLength((i?1:-1)*(t-f),{precision:u,subdivisions:g});break}f+=m}if(!l)return null;s||(a=c,h=i?1:0,s=l.divideAtT(h));var v=this.clone();v.replaceSegment(a,s);var y=a,b=a+1,w=a+2;s[0].isDifferentiable()||(v.removeSegment(y),b-=1,w-=1);var x=v.getSegment(b).start;v.insertSegment(b,Le.createSegment("M",x)),w+=1,s[1].isDifferentiable()||(v.removeSegment(w-1),w-=1);var A=w-y-1;for(r=w;r<v.segments.length;r++){var T=this.getSegment(r-A);if("Z"===(o=v.getSegment(r)).type&&!T.subpathStartSegment.end.equals(o.subpathStartSegment.end)){var E=Le.createSegment("L",T.end);v.replaceSegment(r,E)}}return[new Le(v.segments.slice(0,b)),new Le(v.segments.slice(b))]},equals:function(t){if(!t)return!1;var e=this.segments,n=t.segments,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=n[r];if(o.type!==s.type||!o.equals(s))return!1}return!0},getSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),t>=n||t<0)throw new Error("Index out of range.");return e[t]},getSegmentSubdivisions:function(t){for(var e=this.segments,n=e.length,i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=[],o=0;o<n;o++){var s=e[o].getSubdivisions({precision:i});r.push(s)}return r},getSubpaths:function(){const t=this.clone().validate().segments,e=t.length,n=[];for(let i=0;i<e;i++){const e=t[i];e.isSubpathStart?n.push(new Le(e)):n[n.length-1].appendSegment(e)}return n},insertSegment:function(t,e){var n,i=this.segments,r=i.length;if(t<0&&(t=r+t+1),t>r||t<0)throw new Error("Index out of range.");var o=null,s=null;if(0!==r&&(s=t>=1?(o=i[t-1]).nextSegment:i[0]),Array.isArray(e)){if(!(e=e.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");for(var a=e.length,l=0;l<a;l++){var c=e[l];n=this.prepareSegment(c,o,s),i.splice(t+l,0,n),o=n}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,o,s),i.splice(t,0,n)}},intersectionWithLine:function(t,e){var n=null,i=this.toPolylines(e);if(!i)return null;for(var r=0,o=i.length;r<o;r++){var s=i[r],a=t.intersect(s);a&&(n||(n=[]),Array.isArray(a)?Array.prototype.push.apply(n,a):n.push(a))}return n},isDifferentiable:function(){for(var t=this.segments,e=t.length,n=0;n<e;n++)if(t[n].isDifferentiable())return!0;return!1},isValid:function(){var t=this.segments;return 0===t.length||"M"===t[0].type},length:function(t){var e=this.segments,n=e.length;if(0===n)return 0;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=0,s=0;s<n;s++){var a=e[s],l=r[s];o+=a.length({subdivisions:l})}return o},lengthAtT:function(t,e){var n=this.segments,i=n.length;if(0===i)return 0;var r=t.segmentIndex;if(r<0)return 0;var o=t.value;r>=i?(r=i-1,o=1):o<0?o=0:o>1&&(o=1);for(var s,a=void 0===(e=e||{}).precision?this.PRECISION:e.precision,l=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:a}):e.segmentSubdivisions,c=0,h=0;h<r;h++){var u=n[h];s=l[h],c+=u.length({precisison:a,subdivisions:s})}return u=n[r],s=l[r],c+u.lengthAtT(o,{precisison:a,subdivisions:s})},pointAt:function(t,e){if(0===this.segments.length)return null;if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.pointAtLength(r,i)},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();var r=!0;t<0&&(r=!1,t=-t);for(var o,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=a[h],f=u.length({precision:s,subdivisions:d});if(u.isVisible){if(t<=l+f)return u.pointAtLength((r?1:-1)*(t-l),{precision:s,subdivisions:d});o=u}l+=f}return o?r?o.end:o.start:n[i-1].end.clone()},pointAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].pointAtT(0);if(i>=n)return e[n-1].pointAtT(1);var r=t.value;return r<0?r=0:r>1&&(r=1),e[i].pointAtT(r)},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);var i=t;return t.isSubpathStart&&(t.subpathStartSegment=t,i=n),i&&this.updateSubpathStartSegment(i),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),t>=n||t<0)throw new Error("Index out of range.");var i=e.splice(t,1)[0],r=i.previousSegment,o=i.nextSegment;r&&(r.nextSegment=o),o&&(o.previousSegment=r),i.isSubpathStart&&o&&this.updateSubpathStartSegment(o)},replaceSegment:function(t,e){var n,i=this.segments,r=i.length;if(0===r)throw new Error("Path has no segments.");if(t<0&&(t=r+t),t>=r||t<0)throw new Error("Index out of range.");var o=i[t],s=o.previousSegment,a=o.nextSegment,l=o.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");i.splice(t,1);for(var c=e.length,h=0;h<c;h++){var u=e[h];n=this.prepareSegment(u,s,a),i.splice(t+h,0,n),s=n,l&&n.isSubpathStart&&(l=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,s,a),i.splice(t,1,n),l&&n.isSubpathStart&&(l=!1)}l&&a&&this.updateSubpathStartSegment(a)},round:function(t){for(var e=this.segments,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.segments,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},segmentAt:function(t,e){var n=this.segmentIndexAt(t,e);return n?this.getSegment(n):null},segmentAtLength:function(t,e){var n=this.segmentIndexAtLength(t,e);return n?this.getSegment(n):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.segmentIndexAtLength(r,i)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=s[h],f=u.length({precision:o,subdivisions:d});if(u.isVisible){if(t<=l+f)return h;a=h}l+=f}return a},serialize:function(){if(!this.isValid())throw new Error("Invalid path segments.");return this.toString()},tangentAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.tangentAtLength(r,i)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=a[h],f=u.length({precision:s,subdivisions:d});if(u.isDifferentiable()){if(t<=l+f)return u.tangentAtLength((r?1:-1)*(t-l),{precision:s,subdivisions:d});o=u}l+=f}if(o){var p=r?1:0;return o.tangentAtT(p)}return null},tangentAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].tangentAtT(0);if(i>=n)return e[n-1].tangentAtT(1);var r=t.value;return r<0?r=0:r>1&&(r=1),e[i].tangentAtT(r)},toPoints:function(t){var e=this.segments,n=e.length;if(0===n)return null;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=[],s=[],a=0;a<n;a++){var l=e[a];if(l.isVisible){var c=r[a];if(c.length>0){var h=c.map((function(t){return t.start}));Array.prototype.push.apply(s,h)}else s.push(l.start)}else s.length>0&&(s.push(e[a-1].end),o.push(s),s=[])}return s.length>0&&(s.push(this.end),o.push(s)),o},toPolylines:function(t){var e=[],n=this.toPoints(t);if(!n)return null;for(var i=0,r=n.length;i<r;i++)e.push(new xe(n[i]));return e},toString:function(){for(var t=this.segments,e=t.length,n="",i=0;i<e;i++)n+=t[i].serialize()+" ";return n.trim()},translate:function(t,e){for(var n=this.segments,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},updateSubpathStartSegment:function(t){for(var e=t.previousSegment;t&&!t.isSubpathStart;)t.subpathStartSegment=e?e.subpathStartSegment:null,e=t,t=t.nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,Le.createSegment("M",0,0)),this}},Object.defineProperty(Le.prototype,"start",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n=0;n<e;n++){var i=t[n];if(i.isVisible)return i.start}return t[e-1].end}}),Object.defineProperty(Le.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n=e-1;n>=0;n--){var i=t[n];if(i.isVisible)return i.end}return t[e-1].end}});var Me={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){if(t<=0)return 0;var e=this.length();return t>=1?e:e*t},nextSegment:null,pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},pointAtT:function(t){if(this.pointAt)return this.pointAt(t);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,round:function(){throw new Error("Declaration missing for virtual function.")},subpathStartSegment:null,scale:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},tangentAtT:function(t){if(this.tangentAt)return this.tangentAt(t);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},toString:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")}};Object.defineProperty(Me,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(Me,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(Me,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}});var Oe=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Oe))return Ce(Oe,n);if(0===i)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof ne){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+i+" lines provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===i)return this.end=new Jt(+n[0],+n[1]),this;if(i<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=2)o=n.slice(r,r+2),t.push(Ce(Oe,o));return t}if(1===i)return this.end=new Jt(n[0]),this;for(t=[],r=0;r<i;r+=1)e=n[r],t.push(new Oe(e));return t},Ne={clone:function(){return new Oe(this.end)},divideAt:function(t){var e=new ne(this.start,this.end).divideAt(t);return[new Oe(e[0]),new Oe(e[1])]},divideAtLength:function(t){var e=new ne(this.start,this.end).divideAtLength(t);return[new Oe(e[0]),new Oe(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(Ne,"type",{configurable:!0,enumerable:!0,value:"L"}),Oe.prototype=ke(Me,ne.prototype,Ne);var Re=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Re))return Ce(Re,n);if(0===i)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(n[0]instanceof _e){if(1===i)return this.controlPoint1=n[0].controlPoint1.clone(),this.controlPoint2=n[0].controlPoint2.clone(),this.end=n[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(6===i)return this.controlPoint1=new Jt(+n[0],+n[1]),this.controlPoint2=new Jt(+n[2],+n[3]),this.end=new Jt(+n[4],+n[5]),this;if(i<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=6)o=n.slice(r,r+6),t.push(Ce(Re,o));return t}if(3===i)return this.controlPoint1=new Jt(n[0]),this.controlPoint2=new Jt(n[1]),this.end=new Jt(n[2]),this;if(i<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" points provided).");for(t=[],r=0;r<i;r+=3)e=n.slice(r,r+3),t.push(Ce(Re,e));return t},Fe={clone:function(){return new Re(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){var n=new _e(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Re(n[0]),new Re(n[1])]},divideAtLength:function(t,e){var n=new _e(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Re(n[0]),new Re(n[1])]},divideAtT:function(t){var e=new _e(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Re(e[0]),new Re(e[1])]},isDifferentiable:function(){if(!this.previousSegment)return!1;var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},serialize:function(){var t=this.controlPoint1,e=this.controlPoint2,n=this.end;return this.type+" "+t.x+" "+t.y+" "+e.x+" "+e.y+" "+n.x+" "+n.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}};Object.defineProperty(Fe,"type",{configurable:!0,enumerable:!0,value:"C"}),Re.prototype=ke(Me,_e.prototype,Fe);var Be=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Be))return Ce(Be,n);if(0===i)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof ne){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" lines provided).")}if(n[0]instanceof _e){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===i)return this.end=new Jt(+n[0],+n[1]),this;if(i<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=2)o=n.slice(r,r+2),0===r?t.push(Ce(Be,o)):t.push(Ce(Oe,o));return t}if(1===i)return this.end=new Jt(n[0]),this;for(t=[],r=0;r<i;r+=1)e=n[r],0===r?t.push(new Be(e)):t.push(new Oe(e));return t},Ie={bbox:function(){return null},clone:function(){return new Be(this.end)},closestPoint:function(){return this.end.clone()},closestPointNormalizedLength:function(){return 0},closestPointLength:function(){return 0},closestPointT:function(){return 1},closestPointTangent:function(){return null},divideAt:function(){return[this.clone(),this.clone()]},divideAtLength:function(){return[this.clone(),this.clone()]},equals:function(t){return this.end.equals(t.end)},getSubdivisions:function(){return[]},isDifferentiable:function(){return!1},isSubpathStart:!0,isVisible:!1,length:function(){return 0},lengthAtT:function(){return 0},pointAt:function(){return this.end.clone()},pointAtLength:function(){return this.end.clone()},pointAtT:function(){return this.end.clone()},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},tangentAt:function(){return null},tangentAtLength:function(){return null},tangentAtT:function(){return null},toString:function(){return this.type+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(Ie,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(Ie,"type",{configurable:!0,enumerable:!0,value:"M"}),Be.prototype=ke(Me,Ie);var De=function(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof De))return Ce(De,t);if(e>0)throw new Error("Closepath constructor expects no arguments.");return this},Ve={clone:function(){return new De},divideAt:function(t){var e=new ne(this.start,this.end).divideAt(t);return[e[1].isDifferentiable()?new Oe(e[0]):this.clone(),new Oe(e[1])]},divideAtLength:function(t){var e=new ne(this.start,this.end).divideAtLength(t);return[e[1].isDifferentiable()?new Oe(e[0]):this.clone(),new Oe(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment||this.start.equals(this.end))},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}};Object.defineProperty(Ve,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),Object.defineProperty(Ve,"type",{configurable:!0,enumerable:!0,value:"Z"}),De.prototype=ke(Me,ne.prototype,Ve);var ze=Le.segmentTypes={L:Oe,C:Re,M:Be,Z:De,z:De};Le.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(ze).join("")+",.]*$"),Le.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)};const je={curveThroughPoints:function(t){return console.warn("deprecated"),new Le(_e.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e,n=[],i=[],r=t.length-1;if(1==r)return n[0]=new Jt((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new Jt(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,i];var o=[];for(e=1;e<r-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[r-1]=(8*t[r-1].x+t[r].x)/2;var s=this.getFirstControlPoints(o);for(e=1;e<r-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[r-1]=(8*t[r-1].y+t[r].y)/2;var a=this.getFirstControlPoints(o);for(e=0;e<r;e++)n.push(new Jt(s[e],a[e])),e<r-1?i.push(new Jt(2*t[e+1].x-s[e+1],2*t[e+1].y-a[e+1])):i.push(new Jt((t[r].x+s[r-1])/2,(t[r].y+a[r-1])/2));return[n,i]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new _e(t,e,n,i);return function(t){var e=r.divide(t);return[{p0:e[0].start,p1:e[0].controlPoint1,p2:e[0].controlPoint2,p3:e[0].end},{p0:e[1].start,p1:e[1].controlPoint1,p2:e[1].controlPoint2,p3:e[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n},getInversionSolver:function(t,e,n,i){console.warn("deprecated");var r=new _e(t,e,n,i);return function(t){return r.closestPointT(t)}}},$e=function(t){return this instanceof $e?"string"==typeof t?new $e.parse(t):void(this.points=Array.isArray(t)?t.map(Jt):[]):new $e(t)};function Ue(t,e,n,i){switch(t.type){case jt.Line:if(e.type===jt.Line)return Ge(t,e);break;case jt.Ellipse:switch(e.type){case jt.Line:return qe(t,e);case jt.Ellipse:return He(t,e)}break;case jt.Rect:switch(e.type){case jt.Line:return We(t,e);case jt.Ellipse:return Ye(t,e);case jt.Rect:return Xe(t,e)}break;case jt.Polyline:switch(e.type){case jt.Line:return Ze(t,e);case jt.Ellipse:return Ke(t,e);case jt.Rect:return Je(t,e);case jt.Polyline:return Qe(t,e)}break;case jt.Polygon:switch(e.type){case jt.Line:return tn(t,e);case jt.Ellipse:return en(t,e);case jt.Rect:return nn(t,e);case jt.Polyline:return rn(t,e);case jt.Polygon:return on(t,e)}break;case jt.Path:switch(e.type){case jt.Line:return sn(t,e,n);case jt.Ellipse:return an(t,e,n);case jt.Rect:return ln(t,e,n);case jt.Polyline:return cn(t,e,n);case jt.Polygon:return hn(t,e,n);case jt.Path:return un(t,e,n,i)}}switch(e.type){case jt.Ellipse:case jt.Rect:case jt.Polyline:case jt.Polygon:case jt.Path:return Ue(e,t,i,n);default:throw Error(`The intersection for ${t} and ${e} could not be found.`)}}function Ge(t,e){const n=t.start.x,i=t.start.y,r=t.end.x,o=t.end.y,s=e.start.x,a=e.start.y,l=r-n,c=o-i,h=e.end.x-s,u=e.end.y-a,d=n-s,f=i-a,p=l*u-h*c,g=(l*f-c*d)/p,m=(h*f-u*d)/p;return g>=0&&g<=1&&m>=0&&m<=1}function qe(t,e){const n=t.a,i=t.b,r=t.x,o=t.y,s=e.start.x-r,a=e.end.x-r,l=e.start.y-o,c=n*n,h=i*i,u=a-s,d=e.end.y-o-l,f=u*u/c+d*d/h,p=2*s*u/c+2*l*d/h,g=p*p-4*f*(s*s/c+l*l/h-1);if(0===g){const t=-p/2/f;return t>=0&&t<=1}if(g>0){const t=Math.sqrt(g),e=(-p+t)/2/f,n=(-p-t)/2/f;return e>=0&&e<=1||n>=0&&n<=1}return!1}function He(t,e){return function(t,e,n,i){const{cos:r,sin:o}=Math,s=o(0),a=r(0),l=o(0),c=r(0),h=s*s,u=a*a,d=s*a,f=l*l,p=c*c,g=l*c,m=t.a*t.a,v=t.b*t.b,y=n.a*n.a,b=n.b*n.b,w=m*h+v*u,x=y*f+b*p,A=m*u+v*h,T=y*p+b*f;let E=2*(v-m)*d,S=2*(b-y)*g,P=-2*w*t.x-E*t.y,_=-2*x*n.x-S*n.y,k=-E*t.x-2*A*t.y,L=-S*n.x-2*T*n.y;const C=w*t.x*t.x+A*t.y*t.y+E*t.x*t.y-m*v,M=x*n.x*n.x+T*n.y*n.y+S*n.x*n.y-y*b;E/=2,S/=2,P/=2,_/=2,k/=2,L/=2;const O=bn([[w,E,P],[E,A,k],[P,k,C]]),N=bn([[x,S,_],[S,T,L],[_,L,M]]),R=.33333333*(bn([[x,E,P],[S,A,k],[_,k,C]])+bn([[w,S,P],[E,T,k],[P,L,C]])+bn([[w,E,_],[E,A,L],[P,k,M]])),F=.33333333*(bn([[w,S,_],[E,T,L],[P,L,M]])+bn([[x,E,_],[S,A,L],[_,k,M]])+bn([[x,S,P],[S,T,k],[_,L,C]])),B=yn([[O,R],[R,F]]),I=yn([[O,F],[R,N]]),D=yn([[R,F],[F,N]]);return!(yn([[2*B,I],[I,2*D]])>0&&(F>0||R>0))}(t,0,e)}function We(t,e){const{start:n,end:i}=e,{x:r,y:o,width:s,height:a}=t;return!(n.x>r+s&&i.x>r+s||n.x<r&&i.x<r||n.y>o+a&&i.y>o+a||n.y<o&&i.y<o)&&(!(!t.containsPoint(e.start)&&!t.containsPoint(e.end))||Ge(t.topLine(),e)||Ge(t.rightLine(),e)||Ge(t.bottomLine(),e)||Ge(t.leftLine(),e))}function Ye(t,e){return!!Xe(t,me.fromEllipse(e))&&en($e.fromRect(t),e)}function Xe(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function Ze(t,e){return dn(t,e,{interior:!1})}function Ke(t,e){return fn(t,e,{interior:!1})}function Je(t,e){return pn(t,e,{interior:!1})}function Qe(t,e){return mn(t,e,{interior:!1})}function tn(t,e){return dn(t,e,{interior:!0})}function en(t,e){return fn(t,e,{interior:!0})}function nn(t,e){return pn(t,e,{interior:!0})}function rn(t,e){return mn(t,e,{interior:!0})}function on(t,e){return vn(t,e,{interior:!0})}function sn(t,e,n){return t.getSubpaths().some((t=>{const[i]=t.toPolylines(n),{type:r}=t.getSegment(-1);return"Z"===r?tn(i,e):Ze(i,e)}))}function an(t,e,n){return t.getSubpaths().some((t=>{const[i]=t.toPolylines(n),{type:r}=t.getSegment(-1);return"Z"===r?en(i,e):Ke(i,e)}))}function ln(t,e,n){return hn(t,$e.fromRect(e),n)}function cn(t,e,n){return gn(t,e,n,{interior:!1})}function hn(t,e,n){return gn(t,e,n,{interior:!0})}function un(t,e,n,i){return t.getSubpaths().some((t=>{const[r]=t.toPolylines(n),{type:o}=t.getSegment(-1);return"Z"===o?hn(e,r,i):cn(e,r,i)}))}function dn(t,e,n={}){const{interior:i=!1}=n;let r;if(i){if(t.containsPoint(e.start))return!0;const{start:n,end:i,points:o}=t;r=i.equals(n)?o:[...o,n]}else r=t.points;const{length:o}=r,s=new ne;for(let t=0;t<o-1;t++)if(s.start=r[t],s.end=r[t+1],Ge(e,s))return!0;return!1}function fn(t,e,n={}){const{start:i,end:r,points:o}=t;if(e.containsPoint(i))return!0;let s;const{interior:a=!1}=n;if(a){if(t.containsPoint(e.center()))return!0;s=r.equals(i)?o:[...o,i]}else s=o;const{length:l}=s,c=new ne;for(let t=0;t<l-1;t++)if(c.start=s[t],c.end=s[t+1],qe(e,c))return!0;return!1}function pn(t,e,n){return vn(t,$e.fromRect(e),n)}function gn(t,e,n,i){return t.getSubpaths().some((t=>{const[r]=t.toPolylines(n),{type:o}=t.getSegment(-1);return"Z"===o?vn(e,r,i):mn(e,r,i)}))}function mn(t,e,n={}){const{interior:i=!1}=n;let r;if(i){const{start:n}=e;if(t.containsPoint(n))return!0;r=t.clone().close()}else r=t;const o=e.points,{length:s}=o,a=new ne;for(let t=0;t<s-1;t++)if(a.start=o[t],a.end=o[t+1],Ze(r,a))return!0;return!1}function vn(t,e,n){return e.containsPoint(t.start)||mn(t,e.clone().close(),n)}function yn(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function bn(t){return t[0][0]*t[1][1]*t[2][2]-t[0][0]*t[1][2]*t[2][1]-t[0][1]*t[1][0]*t[2][2]+t[0][1]*t[1][2]*t[2][0]+t[0][2]*t[1][0]*t[2][1]-t[0][2]*t[1][1]*t[2][0]}$e.parse=function(t){return new $e(ye(t))},$e.fromRect=function(t){return new $e([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},$e.prototype=ke(xe.prototype,{type:jt.Polygon,clone:function(){return new $e(be(this.points))},convexHull:function(){return new $e(we(this.points))},lengthPoints:function(){const{start:t,end:e,points:n}=this;return n.length<=1||t.equals(e)?n:[...n,t.clone()]}});const wn=t,xn=function(){if("object"!=typeof window||!window.SVGAngle)return function(){throw new Error("SVG is required to use Vectorizer.")};var t={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},n=Math,i=n.PI,r=n.atan2,o=n.sqrt,s=n.min,a=n.max,l=n.cos,c=n.sin,h=function(e,n,i){if(!(this instanceof h))return h.apply(Object.create(h.prototype),arguments);if(e){if(h.isV(e)&&(e=e.node),n=n||{},h.isString(e)){if("svg"===(e=e.trim()).toLowerCase())e=h.createSvgDocument();else if("<"===e[0]){var r=h.createSvgDocument(e);if(r.childNodes.length>1){var o,s,a=[];for(o=0,s=r.childNodes.length;o<s;o++){var l=r.childNodes[o];a.push(new h(document.importNode(l,!0)))}return a}e=document.importNode(r.firstChild,!0)}else e=document.createElementNS(t.svg,e);h.ensureId(e)}return this.node=e,this.setAttributes(n),i&&this.append(i),this}},u=h.prototype;function d(t,e,n){n||(n={});for(var i=n.includeAnnotationIndices,r=n.eol,o=n.lineHeight,s=n.baseSize,a=0,l={},c=e.length-1,u=0;u<=c;u++){var d=e[u],f=null;if(h.isObject(d)){var p=d.attrs,g=h("tspan",p),m=g.node,v=d.t;r&&u===c&&(v+=r),m.textContent=v;var y=p.class;y&&g.addClass(y),i&&g.attr("annotations",d.annotations),f=parseFloat(p["font-size"]),isFinite(f)||(f=s),f&&f>a&&(a=f)}else r&&u===c&&(d+=r),m=document.createTextNode(d||" "),s&&s>a&&(a=s);t.appendChild(m)}return a&&(l.maxFontSize=a),o?l.lineHeight=o:a&&(l.lineHeight=1.2*a),l}Object.defineProperty(u,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),u.getTransformToElement=function(t){var e=this.node;if(h.isSVGGraphicsElement(t)&&h.isSVGGraphicsElement(e)){var n=h.toNode(t).getScreenCTM(),i=e.getScreenCTM();if(n&&i)return n.inverse().multiply(i)}return h.createSVGMatrix()},u.transform=function(t,e){var n=this.node;if(h.isUndefined(t))return h.transformStringToMatrix(this.attr("transform"));if(e&&e.absolute)return this.attr("transform",h.matrixToTransformString(t));var i=h.createSVGTransform(t);return n.transform.baseVal.appendItem(i),this},u.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=h.parseTransformString(i);if(i=r.value,h.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();var o="translate("+(n.absolute?t:r.translate.tx+t)+","+(n.absolute?e:r.translate.ty+e)+")";return this.attr("transform",(o+" "+i).trim()),this},u.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=h.parseTransformString(r);if(r=o.value,h.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;var s="rotate("+(i.absolute?t:o.rotate.angle+t)+(void 0!==e&&void 0!==n?","+e+","+n:"")+")";return this.attr("transform",(r+" "+s).trim()),this},u.scale=function(t,e){e=h.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=h.parseTransformString(n);if(n=i.value,h.isUndefined(t))return i.scale;n=n.replace(/scale\([^)]*\)/g,"").trim();var r="scale("+t+","+e+")";return this.attr("transform",(n+" "+r).trim()),this},u.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new me(0,0,0,0);try{n=i.getBBox()}catch(t){n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(t)return new me(n);var o=this.getTransformToElement(e||r);return h.transformRect(n,o)},u.getBBox=function(t){var e,n={},i=this.node;if(!i.ownerSVGElement||!h.isSVGGraphicsElement(i))return new me(0,0,0,0);if(t&&(t.target&&(n.target=h.toNode(t.target)),t.recursive&&(n.recursive=t.recursive)),n.recursive){var r=this.children(),o=r.length;if(0===o)return this.getBBox({target:n.target,recursive:!1});n.target||(n.target=this);for(var s=0;s<o;s++){var a,l=r[s];a=0===l.children().length?l.getBBox({target:n.target,recursive:!1}):l.getBBox({target:n.target,recursive:!0}),e=e?e.union(a):a}return e}try{e=i.getBBox()}catch(t){e={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(n.target){var c=this.getTransformToElement(n.target);return h.transformRect(e,c)}return new me(e)};var f=/em$/;function p(t,e){var n=parseFloat(t);return f.test(t)?n*e:n}u.text=function(e,n){if(e&&"string"!=typeof e)throw new Error("Vectorizer: text() expects the first argument to be a string.");e=h.sanitizeText(e),n||(n={});var i=n.displayEmpty,r=n.eol,o=n.textPath,s=n.textVerticalAnchor,a="middle"===s||"bottom"===s||"top"===s,l=n.x;void 0===l&&(l=this.attr("x")||0);var c=n.includeAnnotationIndices,u=n.annotations;u&&!h.isArray(u)&&(u=[u]);var g=n.lineHeight,m="auto"===g,v=m?"1.5em":g||"1em";this.empty(),this.attr({"xml:space":"preserve",display:e||i?null:"none"});var y=parseFloat(this.attr("font-size"));y||(y=16,(a||u)&&this.attr("font-size",y));var b,w=document;o?("string"==typeof o&&(o={d:o}),b=function(t,e){t||(t={});var n=h("textPath"),i=t.d;if(i&&void 0===t["xlink:href"]){var r=h("path").attr("d",i).appendTo(e.defs());n.attr("xlink:href","#"+r.id)}return h.isObject(t)&&n.attr(t),n.node}(o,this)):b=w.createDocumentFragment();for(var x,A=0,T=e.split("\n"),E=[],S=0,P=T.length-1;S<=P;S++){var _,k=v,L="v-line",C=w.createElementNS(t.svg,"tspan"),M=T[S];if(M)if(u){var O=h.annotateString(M,u,{offset:-A,includeAnnotationIndices:c}),N=(_=d(C,O,{includeAnnotationIndices:c,eol:S!==P&&r,lineHeight:m?null:v,baseSize:y})).lineHeight;N&&m&&0!==S&&(k=N),0===S&&(x=.8*_.maxFontSize)}else r&&S!==P&&(M+=r),C.textContent=M;else{C.textContent="-",L+=" v-empty-line";var R=C.style;if(R.fillOpacity=0,R.strokeOpacity=0,u){_={};let t=y;for(let e=(O=h.findAnnotationsAtIndex(u,A)).length;e>0;e--){const n=O[e-1].attrs;if(!n||!("font-size"in n))continue;const i=parseFloat(n["font-size"]);if(isFinite(i)){t=i;break}}m&&(S>0?k=1.2*t:x=.8*t),C.setAttribute("font-size",t),_.maxFontSize=t}}_&&E.push(_),S>0&&C.setAttribute("dy",k),(S>0||o)&&C.setAttribute("x",l),C.className.baseVal=L,b.appendChild(C),A+=M.length+1}if(a)if(u)k=function(t,e,n,i){if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=p(o.maxFontSize,n)||n,a=0,l=p(i,n),c=1;c<r;c++)a+=p((o=e[c]).lineHeight,n)||l;var h,u=p(o.maxFontSize,n)||n;switch(t){case"middle":h=s/2-.15*u-a/2;break;case"bottom":h=-.25*u-a;break;default:h=.8*s}return h}(s,E,y,v);else if("top"===s)k="0.8em";else{var F;switch(P>0?(F=parseFloat(v)||1,F*=P,f.test(v)||(F/=y)):F=0,s){case"middle":k=.3-F/2+"em";break;case"bottom":k=-F-.3+"em"}}else 0===s?k="0em":s?k=s:(k=0,null===this.attr("y")&&this.attr("y",x||"0.8em"));return b.firstChild.setAttribute("dy",k),this.append(b),this},u.removeAttr=function(t){const e=y[t],{ns:n,local:i}=h.qualifyAttr(e),r=this.node;return n?r.hasAttributeNS(n,i)&&r.removeAttributeNS(n,i):r.hasAttribute(e)&&r.removeAttribute(e),this},u.attr=function(t,e){if(h.isUndefined(t)){for(var n=this.node.attributes,i={},r=0;r<n.length;r++)i[n[r].name]=n[r].value;return i}if(h.isString(t)&&h.isUndefined(e))return this.node.getAttribute(y[t]);if("object"==typeof t)for(var o in t)t.hasOwnProperty(o)&&this.setAttribute(o,t[o]);else this.setAttribute(t,e);return this},u.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",h.normalizePathData(this.attr("d"))),this},u.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},u.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},u.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},u.append=function(t){h.isArray(t)||(t=[t]);for(var e=0,n=t.length;e<n;e++)this.node.appendChild(h.toNode(t[e]));return this},u.prepend=function(t){var e=this.node.firstChild;return e?h(e).before(t):this.append(t)},u.before=function(t){var e=this.node,n=e.parentNode;if(n){h.isArray(t)||(t=[t]);for(var i=0,r=t.length;i<r;i++)n.insertBefore(h.toNode(t[i]),e)}return this},u.appendTo=function(t){return h.toNode(t).appendChild(this.node),this},u.svg=function(){return this.node instanceof window.SVGSVGElement?this:h(this.node.ownerSVGElement)},u.tagName=function(){return this.node.tagName.toUpperCase()},u.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?h(e):h("defs").appendTo(t)},u.clone=function(){var t=h(this.node.cloneNode(!0));return t.node.id=h.uniqueId(),t},u.findOne=function(t){var e=this.node.querySelector(t);return e?h(e):void 0},u.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(h(n[i]));return e},u.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++)1===t[n].nodeType&&e.push(h(t[n]));return e},u.parent=function(){return h(this.node.parentNode)||null},u.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},u.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=h(i);if(r.hasClass(t))return r;i=i.parentNode}return null},u.contains=function(t){var e=this.node,n=h.toNode(t),i=n&&n.parentNode;return e===i||!!(i&&1===i.nodeType&&16&e.compareDocumentPosition(i))},u.toLocalPoint=function(t,e){var n=this.svg().node,i=n.createSVGPoint();i.x=t,i.y=e;try{var r=i.matrixTransform(n.getScreenCTM().inverse()),o=this.getTransformToElement(n).inverse()}catch(t){return i}return r.matrixTransform(o)},u.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},u.translateAndAutoOrient=function(t,e,n){t=new Jt(t),e=new Jt(e),n||(n=this.svg());var i=this.scale();this.attr("transform","");var r=this.getBBox({target:n}).scale(i.sx,i.sy),o=h.createSVGTransform();o.setTranslate(-r.x-r.width/2,-r.y-r.height/2);var s=h.createSVGTransform(),a=t.angleBetween(e,t.clone().offset(1,0));a&&s.setRotate(a,0,0);var l=h.createSVGTransform(),c=t.clone().move(e,r.width/2);l.setTranslate(2*t.x-c.x,2*t.y-c.y);var u=this.getTransformToElement(n),d=h.createSVGTransform();return d.setMatrix(l.matrix.multiply(s.matrix.multiply(o.matrix.multiply(u.scale(i.sx,i.sy))))),this.attr("transform",h.matrixToTransformString(d.matrix)),this},u.animateAlongPath=function(t,e){e=h.toNode(e);var n=h.ensureId(e),i=h("animateMotion",t),r=h("mpath",{"xlink:href":"#"+n});i.append(r),this.append(i);try{i.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling")){var o=i.node;o.animators=[];var s=o.getAttribute("id");s&&(id2anim[s]=o);for(var a=getTargets(o),l=0,c=a.length;l<c;l++){var u=a[l],d=new Animator(o,u,l);animators.push(d),o.animators[l]=d,d.register()}}}return this};const g=/[^\x20\t\r\n\f]+/g;function m(t){return h.isString(t)&&t.trim().match(g)||[]}u.hasClass=function(t){return!!h.isString(t)&&this.node.classList.contains(t.trim())},u.addClass=function(t){return this.node.classList.add(...m(t)),this},u.removeClass=function(t){return this.node.classList.remove(...m(t)),this},u.toggleClass=function(t,e){const n=m(t);for(let t=0;t<n.length;t++)this.node.classList.toggle(n[t],e);return this},u.sample=function(t){t=t||1;for(var e,n=this.node,i=n.getTotalLength(),r=[],o=0;o<i;)e=n.getPointAtLength(o),r.push({x:e.x,y:e.y,distance:o}),o+=t;return r},u.convertToPath=function(){var t=h("path");t.attr(this.attr());var e=this.convertToPathData();return e&&t.attr("d",e),t},u.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return h.convertLineToPathData(this.node);case"POLYGON":return h.convertPolygonToPathData(this.node);case"POLYLINE":return h.convertPolylineToPathData(this.node);case"ELLIPSE":return h.convertEllipseToPathData(this.node);case"CIRCLE":return h.convertCircleToPathData(this.node);case"RECT":return h.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},h.prototype.toGeometryShape=function(){var t,e,n,i,r,o,s,a,l,c,u,d,f,p,g;switch(this.tagName()){case"RECT":return t=parseFloat(this.attr("x"))||0,e=parseFloat(this.attr("y"))||0,n=parseFloat(this.attr("width"))||0,i=parseFloat(this.attr("height"))||0,new me(t,e,n,i);case"CIRCLE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("r"))||0,new ae({x:r,y:o},s,s);case"ELLIPSE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,a=parseFloat(this.attr("rx"))||0,l=parseFloat(this.attr("ry"))||0,new ae({x:r,y:o},a,l);case"POLYLINE":return c=h.getPointsFromSvgNode(this),new xe(c);case"POLYGON":return(c=h.getPointsFromSvgNode(this)).length>1&&c.push(c[0]),new xe(c);case"PATH":return u=this.attr("d"),Le.isDataSupported(u)||(u=h.normalizePathData(u)),new Le(u);case"LINE":return d=parseFloat(this.attr("x1"))||0,p=parseFloat(this.attr("y1"))||0,f=parseFloat(this.attr("x2"))||0,g=parseFloat(this.attr("y2"))||0,new ne({x:d,y:p},{x:f,y:g})}return this.getBBox()},u.findIntersection=function(t,e){var n=this.svg().node;e=e||n;var i=this.getBBox({target:e}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){var o,s=this.tagName();if("RECT"===s){var a=new me(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),l=this.getTransformToElement(e),c=h.decomposeMatrix(l),u=n.createSVGTransform();u.setRotate(-c.rotation,r.x,r.y);var d=h.transformRect(a,u.matrix.multiply(l));o=new me(d).intersectionWithLineFromCenterToPoint(t,c.rotation)}else if("PATH"===s||"POLYGON"===s||"POLYLINE"===s||"CIRCLE"===s||"ELLIPSE"===s){var f,p,g,m,v,y=("PATH"===s?this:this.convertToPath()).sample(),b=1/0,w=[];for(f=0;f<y.length;f++)p=y[f],g=(g=h.createSVGPoint(p.x,p.y)).matrixTransform(this.getTransformToElement(e)),(v=(p=new Jt(g)).distance(r)+(m=1.1*p.distance(t)))<b?(b=v,w=[{sample:p,refDistance:m}]):v<b+1&&w.push({sample:p,refDistance:m});w.sort((function(t,e){return t.refDistance-e.refDistance})),w[0]&&(o=w[0].sample)}return o}},u.setAttribute=function(t,e){const n=this.node;if(null===e)return this.removeAttr(t),this;const i=y[t],{ns:r}=h.qualifyAttr(i);return r?n.setAttributeNS(r,i,e):"id"===i?n.id=e:n.setAttribute(i,e),this},h.createSvgDocument=function(e){if(e){const n=`<svg xmlns="${t.svg}" xmlns:xlink="${t.xlink}" version="1.1">${e}</svg>`,{documentElement:i}=h.parseXML(n,{async:!1});return i}const n=document.createElementNS(t.svg,"svg");return n.setAttributeNS(t.xmlns,"xmlns:xlink",t.xlink),n.setAttribute("version","1.1"),n},h.createSVGStyle=function(t){const{node:e}=h("style",{type:"text/css"},[h.createCDATASection(t)]);return e},h.createCDATASection=function(t=""){return document.implementation.createDocument(null,"xml",null).createCDATASection(t)},h.idCounter=0,h.uniqueId=function(){return"v-"+ ++h.idCounter},h.toNode=function(t){return h.isV(t)?t.node:t.nodeName&&t||t[0]},h.ensureId=function(t){return(t=h.toNode(t)).id||(t.id=h.uniqueId())},h.sanitizeText=function(t){return(t||"").replace(/ /g," ")},h.isUndefined=function(t){return void 0===t},h.isString=function(t){return"string"==typeof t},h.isObject=function(t){return t&&"object"==typeof t},h.isArray=Array.isArray,h.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;h.isUndefined(e.async)||(i.async=e.async),n=i.parseFromString(t,"text/xml")}catch(t){n=void 0}if(!n||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return n};const v=Object.create(null);["baseFrequency","baseProfile","clipPathUnits","contentScriptType","contentStyleType","diffuseConstant","edgeMode","externalResourcesRequired","filterRes","filterUnits","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].forEach((t=>v[t]=t)),v.xlinkShow="xlink:show",v.xlinkRole="xlink:role",v.xlinkActuate="xlink:actuate",v.xlinkHref="xlink:href",v.xlinkType="xlink:type",v.xlinkTitle="xlink:title",v.xmlBase="xml:base",v.xmlLang="xml:lang",v.xmlSpace="xml:space";const y=new Proxy(v,{get:(t,e)=>h.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e});Object.defineProperty(h,"attributeNames",{enumerable:!0,value:y,writable:!1}),Object.defineProperty(h,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),h.qualifyAttr=function(e){if(-1!==e.indexOf(":")){var n=e.split(":");return{ns:t[n[0]],local:n[1]}}return{ns:null,local:e}},h.transformSeparatorRegex=/[ ,]+/,h.transformRegex=/\b\w+\([^()]+\)/g,h.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,h.transformTranslateRegex=/\btranslate\(([^()]+)\)/,h.transformRotateRegex=/\brotate\(([^()]+)\)/,h.transformScaleRegex=/\bscale\(([^()]+)\)/,h.transformStringToMatrix=function(t){let e=h.createSVGMatrix();const n=t&&t.match(h.transformRegex);if(!n)return e;const i=n.length;for(let t=0;t<i;t++){const i=n[t].match(h.transformFunctionRegex);if(i){let t,n,r,o,s,a=h.createSVGMatrix();const l=i[1].toLowerCase(),c=i[2].split(h.transformSeparatorRegex);switch(l){case"scale":t=parseFloat(c[0]),n=void 0===c[1]?t:parseFloat(c[1]),a=a.scaleNonUniform(t,n);break;case"translate":r=parseFloat(c[0]),o=parseFloat(c[1]),a=a.translate(r,o);break;case"rotate":s=parseFloat(c[0]),r=parseFloat(c[1])||0,o=parseFloat(c[2])||0,a=0!==r||0!==o?a.translate(r,o).rotate(s).translate(-r,-o):a.rotate(s);break;case"skewx":s=parseFloat(c[0]),a=a.skewX(s);break;case"skewy":s=parseFloat(c[0]),a=a.skewY(s);break;case"matrix":a.a=parseFloat(c[0]),a.b=parseFloat(c[1]),a.c=parseFloat(c[2]),a.d=parseFloat(c[3]),a.e=parseFloat(c[4]),a.f=parseFloat(c[5]);break;default:continue}e=e.multiply(a)}}return e},h.matrixToTransformString=function(t){return t||(t=!0),"matrix("+(void 0!==t.a?t.a:1)+","+(void 0!==t.b?t.b:0)+","+(void 0!==t.c?t.c:0)+","+(void 0!==t.d?t.d:1)+","+(void 0!==t.e?t.e:0)+","+(void 0!==t.f?t.f:0)+")"},h.parseTransformString=function(t){var e,n,i;if(t){var r=h.transformSeparatorRegex;if(t.trim().indexOf("matrix")>=0){var o=h.transformStringToMatrix(t),s=h.decomposeMatrix(o);e=[s.translateX,s.translateY],i=[s.scaleX,s.scaleY],n=[s.rotation];var a=[];0===e[0]&&0===e[1]||a.push("translate("+e+")"),1===i[0]&&1===i[1]||a.push("scale("+i+")"),0!==n[0]&&a.push("rotate("+n+")"),t=a.join(" ")}else{const o=t.match(h.transformTranslateRegex);o&&(e=o[1].split(r));const s=t.match(h.transformRotateRegex);s&&(n=s[1].split(r));const a=t.match(h.transformScaleRegex);a&&(i=a[1].split(r))}}var l=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:e&&e[0]?parseInt(e[0],10):0,ty:e&&e[1]?parseInt(e[1],10):0},rotate:{angle:n&&n[0]?parseInt(n[0],10):0,cx:n&&n[1]?parseInt(n[1],10):void 0,cy:n&&n[2]?parseInt(n[2],10):void 0},scale:{sx:l,sy:i&&i[1]?parseFloat(i[1]):l}}},h.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c+0,y:e.x*t.b+e.y*t.d+0}},h.decomposeMatrix=function(t){var e=h.deltaTransformPoint(t,{x:0,y:1}),n=h.deltaTransformPoint(t,{x:1,y:0}),s=180/i*r(e.y,e.x)-90,a=180/i*r(n.y,n.x);return{translateX:t.e,translateY:t.f,scaleX:o(t.a*t.a+t.b*t.b),scaleY:o(t.c*t.c+t.d*t.d),skewX:s,skewY:a,rotation:s}},h.matrixToScale=function(t){var e,n,i,r;return t?(e=h.isUndefined(t.a)?1:t.a,r=h.isUndefined(t.d)?1:t.d,n=t.b,i=t.c):e=r=1,{sx:n?o(e*e+n*n):e,sy:i?o(i*i+r*r):r}},h.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=h.deltaTransformPoint(t,e)),{angle:Ct(Ot(r(e.y,e.x))-90)}},h.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},h.isV=function(t){return t instanceof h},h.isVElement=h.isV,h.isSVGGraphicsElement=function(t){return!!t&&(t=h.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM};var b=h("svg").node;return h.createSVGMatrix=function(t){var e=b.createSVGMatrix();for(var n in t)e[n]=t[n];return e},h.createSVGTransform=function(t){return h.isUndefined(t)?b.createSVGTransform():(t instanceof SVGMatrix||(t=h.createSVGMatrix(t)),b.createSVGTransformFromMatrix(t))},h.createSVGPoint=function(t,e){var n=b.createSVGPoint();return n.x=t,n.y=e,n},h.transformRect=function(t,e){var n=b.createSVGPoint();n.x=t.x,n.y=t.y;var i=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y;var r=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y+t.height;var o=n.matrixTransform(e);n.x=t.x,n.y=t.y+t.height;var l=n.matrixTransform(e),c=s(i.x,r.x,o.x,l.x),h=a(i.x,r.x,o.x,l.x),u=s(i.y,r.y,o.y,l.y),d=a(i.y,r.y,o.y,l.y);return new me(c,u,h-c,d-u)},h.transformPoint=function(t,e){return new Jt(h.createSVGPoint(t.x,t.y).matrixTransform(e))},h.transformLine=function(t,e){return new ne(h.transformPoint(t.start,e),h.transformPoint(t.end,e))},h.transformPolyline=function(t,e){var n=t instanceof xe?t.points:t;h.isArray(n)||(n=[]);for(var i=[],r=0,o=n.length;r<o;r++)i[r]=h.transformPoint(n[r],e);return new xe(i)},h.styleToObject=function(t){for(var e={},n=t.split(";"),i=0;i<n.length;i++){var r=n[i].split("=");e[r[0].trim()]=r[1].trim()}return e},h.createSlicePathData=function(t,e,n,r){var o=2*i-1e-6,s=t,a=e,h=n,u=r,d=(u<h&&(d=h,h=u,u=d),u-h),f=d<i?"0":"1",p=l(h),g=c(h),m=l(u),v=c(u);return d>=o?s?"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"M0,"+s+"A"+s+","+s+" 0 1,0 0,"+-s+"A"+s+","+s+" 0 1,0 0,"+s+"Z":"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"Z":s?"M"+a*p+","+a*g+"A"+a+","+a+" 0 "+f+",1 "+a*m+","+a*v+"L"+s*m+","+s*v+"A"+s+","+s+" 0 "+f+",0 "+s*p+","+s*g+"Z":"M"+a*p+","+a*g+"A"+a+","+a+" 0 "+f+",1 "+a*m+","+a*v+"L0,0Z"},h.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?h.isObject(t[n])&&h.isObject(e[n])?t[n]=h.mergeAttrs(t[n],e[n]):h.isObject(t[n])?t[n]=h.mergeAttrs(t[n],h.styleToObject(e[n])):h.isObject(e[n])?t[n]=h.mergeAttrs(h.styleToObject(t[n]),e[n]):t[n]=h.mergeAttrs(h.styleToObject(t[n]),h.styleToObject(e[n])):t[n]=e[n];return t},h.annotateString=function(t,e,n){e=e||[];for(var i,r,o,s=(n=n||{}).offset||0,a=[],l=[],c=0;c<t.length;c++){r=l[c]=t[c];for(var u=0;u<e.length;u++){var d=e[u],f=d.start+s,p=d.end+s;c>=f&&c<p&&(h.isObject(r)?r.attrs=h.mergeAttrs(h.mergeAttrs({},r.attrs),d.attrs):r=l[c]={t:t[c],attrs:d.attrs},n.includeAnnotationIndices&&(r.annotations||(r.annotations=[])).push(u))}(o=l[c-1])?h.isObject(r)&&h.isObject(o)?JSON.stringify(r.attrs)===JSON.stringify(o.attrs)?i.t+=r.t:(a.push(i),i=r):h.isObject(r)||h.isObject(o)?(a.push(i),i=r):i=(i||"")+r:i=r}return i&&a.push(i),a},h.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach((function(t){t.start<e&&e<=t.end&&n.push(t)})),n},h.findAnnotationsBetweenIndexes=function(t,e,n){var i=[];return t&&t.forEach((function(t){(e>=t.start&&e<t.end||n>t.start&&n<=t.end||t.start>=e&&t.end<n)&&i.push(t)})),i},h.shiftAnnotations=function(t,e,n){return t&&t.forEach((function(t){t.start<e&&t.end>=e?t.end+=n:t.start>=e&&(t.start+=n,t.end+=n)})),t},h.convertLineToPathData=function(t){return["M",(t=h(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},h.convertPolygonToPathData=function(t){var e=h.getPointsFromSvgNode(t);return 0===e.length?null:h.svgPointsToPath(e)+" Z"},h.convertPolylineToPathData=function(t){var e=h.getPointsFromSvgNode(t);return 0===e.length?null:h.svgPointsToPath(e)},h.svgPointsToPath=function(t){for(var e=0,n=t.length;e<n;e++)t[e]=t[e].x+" "+t[e].y;return"M "+t.join(" L")},h.getPointsFromSvgNode=function(t){var e=[],n=(t=h.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},h.KAPPA=.551784,h.convertCircleToPathData=function(t){t=h(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("r")),r=i*h.KAPPA;return["M",e,n-i,"C",e+r,n-i,e+i,n-r,e+i,n,"C",e+i,n+r,e+r,n+i,e,n+i,"C",e-r,n+i,e-i,n+r,e-i,n,"C",e-i,n-r,e-r,n-i,e,n-i,"Z"].join(" ")},h.convertEllipseToPathData=function(t){t=h(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),r=parseFloat(t.attr("ry"))||i,o=i*h.KAPPA,s=r*h.KAPPA;return["M",e,n-r,"C",e+o,n-r,e+i,n-s,e+i,n,"C",e+i,n+s,e+o,n+r,e,n+r,"C",e-o,n+r,e-i,n+s,e-i,n,"C",e-i,n-s,e-o,n-r,e,n-r,"Z"].join(" ")},h.convertRectToPathData=function(t){return t=h(t),h.rectToPath({x:parseFloat(t.attr("x"))||0,y:parseFloat(t.attr("y"))||0,width:parseFloat(t.attr("width"))||0,height:parseFloat(t.attr("height"))||0,rx:parseFloat(t.attr("rx"))||0,ry:parseFloat(t.attr("ry"))||0})},h.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=s(t.rx||t["top-rx"]||0,i/2),a=s(t.rx||t["bottom-rx"]||0,i/2),l=s(t.ry||t["top-ry"]||0,r/2),c=s(t.ry||t["bottom-ry"]||0,r/2);return(o||a||l||c?["M",e,n+l,"v",r-l-c,"a",a,c,0,0,0,a,c,"h",i-2*a,"a",a,c,0,0,0,a,-c,"v",-(r-c-l),"a",o,l,0,0,0,-o,-l,"h",-(i-2*o),"a",o,l,0,0,0,-o,l,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"]).join(" ")},h.normalizePathData=function(){var t="\t\n\v\f\r \u2028\u2029",e=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),n=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),i=Math,r=i.PI,o=i.sin,s=i.cos,a=i.tan,l=i.asin,c=i.sqrt,h=i.abs;function u(t,e,n,i,r,o){var s=1/3,a=2/3;return[s*t+a*n,s*e+a*i,s*r+a*n,s*o+a*i,r,o]}function d(t,e,n){return{x:t*s(n)-e*o(n),y:t*o(n)+e*s(n)}}function f(t,e,n,i,u,p,g,m,v,y){var b,w=120*r/180,x=r/180*(+u||0),A=[];if(y)M=y[0],O=y[1],L=y[2],C=y[3];else{t=(b=d(t,e,-x)).x,e=b.y;var T=(t-(m=(b=d(m,v,-x)).x))/2,E=(e-(v=b.y))/2,S=T*T/(n*n)+E*E/(i*i);S>1&&(n*=S=c(S),i*=S);var P=n*n,_=i*i,k=(p==g?-1:1)*c(h((P*_-P*E*E-_*T*T)/(P*E*E+_*T*T)));if(!Number.isFinite(k))return[t,e,m,v,m,v];var L=k*n*E/i+(t+m)/2,C=k*-i*T/n+(e+v)/2,M=l(((e-C)/i).toFixed(9)),O=l(((v-C)/i).toFixed(9));(M=t<L?r-M:M)<0&&(M=2*r+M),(O=m<L?r-O:O)<0&&(O=2*r+O),g&&M>O&&(M-=2*r),!g&&O>M&&(O-=2*r)}var N=O-M;if(h(N)>w){var R=O,F=m,B=v;A=f(m=L+n*s(O=M+w*(g&&O>M?1:-1)),v=C+i*o(O),n,i,u,0,g,F,B,[O,R,L,C])}N=O-M;var I=s(M),D=o(M),V=s(O),z=o(O),j=a(N/4),$=4/3*(n*j),U=4/3*(i*j),G=[t,e],q=[t+$*D,e-U*I],H=[m+$*z,v-U*V],W=[m,v];if(q[0]=2*G[0]-q[0],q[1]=2*G[1]-q[1],y)return[q,H,W].concat(A);for(var Y=[],X=(A=[q,H,W].concat(A).join().split(",")).length,Z=0;Z<X;Z++)Y[Z]=Z%2?d(A[Z-1],A[Z],x).y:d(A[Z],A[Z+1],x).x;return Y}function p(t){var i=function(t){if(Array.isArray(t)&&Array.isArray(t&&t[0])||(t=function(t){if(!t)return null;var i={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=[];return String(t).replace(e,(function(t,e,o){var s=[],a=e.toLowerCase();for(o.replace(n,(function(t,e){e&&s.push(+e)})),"m"===a&&s.length>2&&(r.push([e].concat(s.splice(0,2))),a="l",e="m"===e?"l":"L");s.length>=i[a]&&(r.push([e].concat(s.splice(0,i[a]))),i[a]););})),r}(t)),!t||!t.length)return[["M",0,0]];for(var i,r=[],o=0,s=0,a=0,l=0,c=t.length,h=0;h<c;h++){var u=[];r.push(u);var d,f,p=t[h];if((i=p[0])!=i.toUpperCase())switch(u[0]=i.toUpperCase(),u[0]){case"A":u[1]=p[1],u[2]=p[2],u[3]=p[3],u[4]=p[4],u[5]=p[5],u[6]=+p[6]+o,u[7]=+p[7]+s;break;case"V":u[1]=+p[1]+s;break;case"H":u[1]=+p[1]+o;break;case"M":for(a=+p[1]+o,l=+p[2]+s,d=p.length,f=1;f<d;f++)u[f]=+p[f]+(f%2?o:s);break;default:for(d=p.length,f=1;f<d;f++)u[f]=+p[f]+(f%2?o:s)}else for(var g=p.length,m=0;m<g;m++)u[m]=p[m];switch(u[0]){case"Z":o=+a,s=+l;break;case"H":o=u[1];break;case"V":s=u[1];break;case"M":a=u[u.length-2],l=u[u.length-1],o=u[u.length-2],s=u[u.length-1];break;default:o=u[u.length-2],s=u[u.length-1]}}return r}(t),r={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function o(t,e,n){var i,r;if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(t[0]in{T:1,Q:1}||(e.qx=null,e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=0===parseFloat(t[1])||0===parseFloat(t[2])?["L",t[6],t[7]]:["C"].concat(f.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":"C"===n||"S"===n?(i=2*e.x-e.bx,r=2*e.y-e.by):(i=e.x,r=e.y),t=["C",i,r].concat(t.slice(1));break;case"T":"Q"===n||"T"===n?(e.qx=2*e.x-e.qx,e.qy=2*e.y-e.qy):(e.qx=e.x,e.qy=e.y),t=["C"].concat(u(e.x,e.y,e.qx,e.qy,t[1],t[2]));break;case"Q":e.qx=t[1],e.qy=t[2],t=["C"].concat(u(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"H":t=["L"].concat(t[1],e.y);break;case"V":t=["L"].concat(e.x,t[1])}return t}function s(t,e){if(t[e].length>7){t[e].shift();for(var n=t[e];n.length;)a[e]="A",t.splice(e++,0,["C"].concat(n.splice(0,6)));t.splice(e,1),h=i.length}}for(var a=[],l="",c="",h=i.length,d=0;d<h;d++){i[d]&&(l=i[d][0]),"C"!==l&&(a[d]=l,d>0&&(c=a[d-1])),i[d]=o(i[d],r,c),"A"!==a[d]&&"C"===l&&(a[d]="C"),s(i,d);var p=i[d],g=p.length;r.x=p[g-2],r.y=p[g-1],r.bx=parseFloat(p[g-4])||r.x,r.by=parseFloat(p[g-3])||r.y}return i[0][0]&&"M"===i[0][0]||i.unshift(["M",0,0]),i}return function(t){return p(t).join(",").split(",").join(" ")}}(),h.namespace=t,h.g=e,h}(),An=xn,Tn="[object Arguments]",En="[object Array]",Sn="[object Boolean]",Pn="[object Date]",_n="[object Error]",kn="[object Function]",Ln="[object Map]",Cn="[object Number]",Mn="[object Object]",On="[object RegExp]",Nn="[object Set]",Rn="[object String]",Fn="[object Symbol]",Bn="[object WeakMap]",In="[object ArrayBuffer]",Dn="[object DataView]",Vn="[object Float32Array]",zn="[object Float64Array]",jn="[object Int8Array]",$n="[object Int16Array]",Un="[object Int32Array]",Gn="[object Uint8Array]",qn="[object Uint8ClampedArray]",Hn="[object Uint16Array]",Wn="[object Uint32Array]",Yn={[Tn]:!0,[En]:!0,[In]:!0,[Dn]:!0,[Sn]:!0,[Pn]:!0,[Vn]:!0,[zn]:!0,[jn]:!0,[$n]:!0,[Un]:!0,[Ln]:!0,[Cn]:!0,[Mn]:!0,[On]:!0,[Nn]:!0,[Rn]:!0,[Fn]:!0,[Gn]:!0,[qn]:!0,[Hn]:!0,[Wn]:!0,[_n]:!1,[kn]:!1,[Bn]:!1},Xn="\\ud800-\\udfff",Zn="\\u2700-\\u27bf",Kn="a-z\\xdf-\\xf6\\xf8-\\xff",Jn="A-Z\\xc0-\\xd6\\xd8-\\xde",Qn="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ti="['’]",ei=`[${Qn}]`,ni="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",ii=`[${Zn}]`,ri=`[${Kn}]`,oi=`[^${Xn}${Qn+"\\d"+Zn+Kn+Jn}]`,si="\\ud83c[\\udffb-\\udfff]",ai=`[^${Xn}]`,li="(?:\\ud83c[\\udde6-\\uddff]){2}",ci="[\\ud800-\\udbff][\\udc00-\\udfff]",hi=`[${Jn}]`,ui=`(?:${ri}|${oi})`,di=`(?:${hi}|${oi})`,fi=`(?:${ti}(?:d|ll|m|re|s|t|ve))?`,pi=`(?:${ti}(?:D|LL|M|RE|S|T|VE))?`,gi=`(?:${ni}|${si})?`,mi="[\\ufe0e\\ufe0f]?",vi=mi+gi+`(?:\\u200d(?:${[ai,li,ci].join("|")})${mi+gi})*`,yi=`(?:${[ii,li,ci].join("|")})${vi}`,bi=RegExp([`${hi}?${ri}+${fi}(?=${[ei,hi,"$"].join("|")})`,`${di}+${pi}(?=${[ei,hi+ui,"$"].join("|")})`,`${hi}?${ui}+${fi}`,`${hi}+${pi}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",yi].join("|"),"g"),wi="__hash_undefined__",xi=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,Ai=`(?:${[`${ai}${ni}?`,ni,li,ci,`[${Xn}]`].join("|")})`,Ti=RegExp(`${si}(?=${si})|${Ai+vi}`,"g"),Ei=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Si=/^\w*$/,Pi=".".charCodeAt(0),_i=/\\(\\)?/g,ki=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),Li=/^(?:0|[1-9]\d*)$/,Ci=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),Mi=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Oi=t=>Ti.test(t),Ni=t=>Oi(t)?(t=>t.match(Ti)||[])(t):(t=>t.split(""))(t),Ri=t=>null==t?[]:Fi(t).map((e=>t[e])),Fi=t=>Gi(t)?Bi(t):Object.keys(Object(t)),Bi=(t,e)=>{const n=Array.isArray(t),i=!n&&Vi(t)&&Wi(t)===Tn,r=!n&&!i&&Ji(t),o=n||i||r,s=t.length,a=new Array(o?s:0);let l=o?-1:s;for(;++l<s;)a[l]=`${l}`;for(const n in t)!e&&!hasOwnProperty.call(t,n)||o&&("length"===n||Ar(n,s))||a.push(n);return a},Ii=(t,e)=>{let{length:n}=t;for(;n--;)if(Di(t[n][0],e))return n;return-1},Di=(t,e)=>t===e||t!=t&&e!=e,Vi=t=>null!=t&&"object"==typeof t,zi=(t,e,n)=>{if(!to(n))return!1;const i=typeof e;return!!("number"==i?Gi(n)&&e>-1&&e<n.length:"string"==i&&e in n)&&Di(n[e],t)},ji=t=>{const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},$i=(t,e,n)=>{const i=t[e];hasOwnProperty.call(t,e)&&Di(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Ui=(t,e,n)=>{let i=-1;const r=e.length;for(;++i<r;){const r=e[i];$i(n,r,t[r])}return n},Gi=t=>null!=t&&"function"!=typeof t&&"number"==typeof t.length&&t.length>-1&&t.length%1==0,qi=t=>"symbol"==typeof t||Vi(t)&&Wi(t)===Fn,Hi=(t,e)=>{let n=-1;const i=t.length;for(e||(e=new Array(i));++n<i;)e[n]=t[n];return e},Wi=t=>null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t),Yi=t=>{const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},Xi=(t,e)=>{const n=e?Yi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)},Zi=t=>"function"!=typeof t.constructor||ji(t)?{}:Object.create(Object.getPrototypeOf(t)),Ki=t=>null==t?[]:(t=Object(t),Object.getOwnPropertySymbols(t).filter((e=>propertyIsEnumerable.call(t,e)))),Ji=t=>Vi(t)&&xi.test(Wi(t)),Qi=t=>{const e=Object.keys(t);return Array.isArray(t)||null==t||e.push(...Ki(Object(t))),e},tr=t=>{const e=[];for(;t;)e.push(...Ki(t)),t=Object.getPrototypeOf(Object(t));return e},er=t=>{const e=[];for(const n in t)e.push(n);return Array.isArray(t)||e.push(...tr(t)),e},nr=({__data__:t},e)=>{const n=t;return Er(e)?n["string"==typeof e?"string":"hash"]:n.map},ir=(t,e,n)=>t===e||(null==t||null==e||!Vi(t)&&!Vi(e)?t!=t&&e!=e:rr(t,e,ir,n)),rr=(t,e,n,i)=>{let r=Array.isArray(t);const o=Array.isArray(e);let s=r?En:Wi(t),a=o?En:Wi(e);s=s==Tn?Mn:s,a=a==Tn?Mn:a;let l=s==Mn;const c=a==Mn,h=s==a;if(h&&!l)return i||(i=new Xr),r||Ji(t)?or(t,e,!1,n,i):cr(t,e,s,n,i);const u=l&&hasOwnProperty.call(t,"__wrapped__"),d=c&&hasOwnProperty.call(e,"__wrapped__");if(u||d){const r=u?t.value():t,o=d?e.value():e;return i||(i=new Xr),n(r,o,i)}return!!h&&(i||(i=new Xr),((t,e,n,i)=>{const r=Qi(t),o=r.length;if(o!=Qi(e).length)return!1;let s,a=o;for(;a--;)if(s=r[a],!hasOwnProperty.call(e,s))return!1;const l=i.get(t),c=i.get(e);if(l&&c)return l==e&&c==t;let h,u=!0;for(i.set(t,e),i.set(e,t);++a<o;){s=r[a];const o=t[s],l=e[s];if(o!==l&&!n(o,l,i)){u=!1;break}h||(h="constructor"==s)}if(u&&!h){const n=t.constructor,i=e.constructor;n==i||!("constructor"in t)||!("constructor"in e)||"function"==typeof n&&n instanceof n&&"function"==typeof i&&i instanceof i||(u=!1)}return i.delete(t),i.delete(e),u})(t,e,n,i))},or=(t,e,n,i,r)=>{const o=t.length;if(o!=e.length)return!1;const s=r.get(t),a=r.get(e);if(s&&a)return s==e&&a==t;let l=-1,c=!0;const h=n?new Qr:void 0;for(r.set(t,e),r.set(e,t);++l<o;){let n;const o=t[l],s=e[l];if(void 0!==n){if(n)continue;c=!1;break}if(h){if(!sr(e,((t,e)=>{if(!ar(h,e)&&(o===t||i(o,t,r)))return h.push(e)}))){c=!1;break}}else if(o!==s&&!i(o,s,r)){c=!1;break}}return r.delete(t),r.delete(e),c},sr=(t,e)=>{let n=-1;const i=null==t?0:t.length;for(;++n<i;)if(e(t[n],n,t))return!0;return!1},ar=(t,e)=>t.has(e),lr=(t,e,n,i)=>!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i)),cr=(t,e,n,i,r)=>{switch(n){case Dn:return t.byteLength==e.byteLength&&t.byteOffset==e.byteOffset&&(t=t.buffer,e=e.buffer,lr(t,e,i,r));case In:return lr(t,e,i,r);case Sn:case Pn:case Cn:return Di(+t,+e);case _n:return t.name==e.name&&t.message==e.message;case On:case Rn:return t==`${e}`;case Ln:let n=hr;case Nn:if(n||(n=ur),t.size!=e.size)return!1;const o=r.get(t);if(o)return o==e;r.set(t,e);const s=or(n(t),n(e),!0,i,r);return r.delete(t),s;case Fn:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},hr=t=>{let e=-1,n=Array(t.size);return t.forEach(((t,i)=>{n[++e]=[i,t]})),n},ur=t=>{let e=-1;const n=new Array(t.size);return t.forEach((t=>{n[++e]=t})),n},dr=(t,e)=>{if(Array.isArray(t))return!1;const n=typeof t;return!("number"!==n&&"boolean"!==n&&null!=t&&!qi(t))||Si.test(t)||!Ei.test(t)||null!=e&&t in Object(e)},fr=(t,e)=>Array.isArray(t)?t:dr(t,e)?[t]:(t=>{const e=[];return t.charCodeAt(0)===Pi&&e.push(""),t.replace(ki,((t,n,i,r)=>{let o=t;i?o=r.replace(_i,"$1"):n&&(o=n.trim()),e.push(o)})),e})(`${t}`),pr=(t,e)=>{let n=0;const i=(e=fr(e,t)).length;for(;null!=t&&n<i;)t=t[vr(e[n])],n++;return n&&n==i?t:void 0};function gr(t,e){if(t!==e){const n=void 0!==t,i=null===t,r=t==t,o=qi(t),s=void 0!==e,a=null===e,l=e==e,c=qi(e);if(!a&&!c&&!o&&t>e||o&&s&&l&&!a&&!c||i&&s&&l||!n&&l||!r)return 1;if(!i&&!o&&!c&&t<e||c&&n&&r&&!i&&!o||a&&n&&r||!s&&r||!l)return-1}return 0}const mr=(t,e)=>{let n=(t,e)=>!(null==t||!t.length)&&t.indexOf(e)>-1,i=!0;const r=[],o=e.length;if(!t.length)return r;e.length>=200&&(n=(t,e)=>t.has(e),i=!1,e=new Qr(e));t:for(let s in t){let a=t[s];const l=a;if(a=0!==a?a:0,i&&l==l){let t=o;for(;t--;)if(e[t]===l)continue t;r.push(a)}else n(e,l)||r.push(a)}return r},vr=t=>{if("string"==typeof t||qi(t))return t;const e=`${t}`;return"0"==e&&1/t==-1/0?"-0":e},yr=(t,e=!1,n=!1,i=!0,r,o,s,a)=>{let l;if(r&&(l=s?r(t,o,s,a):r(t)),void 0!==l)return l;if(!to(t))return t;const c=Array.isArray(t),h=Wi(t);if(c){if(l=(t=>{const e=t.length;let n=new t.constructor(e);return e&&"string"==typeof t[0]&&hasOwnProperty.call(t,"index")&&(n.index=t.index,n.input=t.input),n})(t),!e)return Hi(t,l)}else{const i="function"==typeof t;if(h===Mn||h===Tn||i&&!s){if(l=n||i?{}:Zi(t),!e)return n?br(t,Ui(t,Object.keys(t),l)):((t,e)=>Ui(t,Ki(t),e))(t,Object.assign(l,t))}else{if(i||!Yn[h])return s?t:{};l=((t,e,n)=>{const i=t.constructor;switch(e){case In:return Yi(t);case Sn:case Pn:return new i(+t);case Dn:return function(t,e){const n=e?Yi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case Vn:case zn:case jn:case $n:case Un:case Gn:case qn:case Hn:case Wn:return Xi(t,n);case Ln:case Cn:case Rn:return new i(t);case On:return(t=>{const e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e})(t);case Nn:return new i;case Fn:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}})(t,h,e)}}a||(a=new Xr);const u=a.get(t);if(u)return u;if(a.set(t,l),(t=>Vi(t)&&Wi(t)==Ln)(t))return t.forEach(((o,s)=>{l.set(s,yr(o,e,n,i,r,s,t,a))})),l;if((t=>Vi(t)&&Wi(t)==Nn)(t))return t.forEach((o=>{l.add(yr(o,e,n,i,r,o,t,a))})),l;if(Ji(t))return l;const d=c?void 0:(i?n?er:Qi:n?Sr:Fi)(t);return(d||t).forEach(((o,s)=>{d&&(o=t[s=o]),$i(l,s,yr(o,e,n,i,r,s,t,a))})),l},br=(t,e)=>Ui(t,tr(t),e),wr=(t,e)=>e.length<2?t:pr(t,e.slice(0,-1)),xr=(t,e,n)=>{if(!to(t))return t;const i=(e=fr(e,t)).length,r=i-1;let o=-1,s=t;for(;null!=s&&++o<i;){const t=vr(e[o]);let i=n;if(o!=r){const n=s[t];i=void 0,void 0===i&&(i=to(n)?n:Ar(e[o+1])?[]:{})}$i(s,t,i),s=s[t]}return t},Ar=(t,e)=>{const n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"===n||"symbol"!==n&&Li.test(t))&&t>-1&&t%1==0&&t<e},Tr=(t,e)=>{e=fr(e,t),t=wr(t,e);const n=e[e.length-1];return null==t||delete t[vr(n)]},Er=t=>{const e=typeof t;return"string"===e||"number"===e||"symbol"===e||"boolean"===e?"__proto__"!==t:null===t},Sr=t=>{const e=[];for(const n in t)e.push(n);return e},Pr=(t,e)=>{if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function _r(t,e=!1){return(n,...i)=>{let r=-1,o=i.length,s=o>1?i[o-1]:void 0;const a=o>2?i[2]:void 0;for(s=t.length>3&&"function"==typeof s?(o--,s):e?(t,e)=>{if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,a&&zi(i[0],i[1],a)&&(s=o<3?void 0:s,o=1),n=Object(n);++r<o;){const e=i[r];e&&t(n,e,r,s)}return n}}const kr=(t,e,n,i,r)=>{t!==e&&_o(e,((o,s)=>{if(to(o))r||(r=new Xr),Lr(t,e,s,n,kr,i,r);else{let n=i?i(t[s],o,`${s}`,t,e,r):void 0;void 0===n&&(n=o),Cr(t,s,n)}}),Sr)},Lr=(t,e,n,i,r,o,s)=>{const a=Pr(t,n),l=Pr(e,n),c=s.get(l);if(c)return void Cr(t,n,c);let h=o?o(a,l,`${n}`,t,e,s):void 0,u=void 0===h;if(u){const t=Array.isArray(l),e=!t&&Ji(l);h=l,t||e?Array.isArray(a)?h=a:Vi(a)&&Gi(a)?h=Hi(a):e?(u=!1,h=Xi(l,!0)):h=[]:mo(l)||qr(l)?(h=a,qr(a)?h=(t=>{t=Object(t);const e={};for(const n in t)e[n]=t[n];return e})(a):"function"!=typeof a&&to(a)||(h=Zi(l))):u=!1}u&&(s.set(l,h),r(h,l,i,o,s),s.delete(l)),Cr(t,n,h)},Cr=(t,e,n)=>{(void 0!==n&&!Di(t[e],n)||void 0===n&&!(e in t))&&$i(t,e,n)},Mr=(t,e)=>{if(null==t)return t;if(!Gi(t))return((t,e)=>t&&function(t,e,n){const i=Object(t),r=n(t);let{length:o}=r,s=-1;for(;o--;){const t=r[++s];if(!1===e(i[t],t,i))break}return t}(t,e,Fi))(t,e);const n=t.length,i=Object(t);let r=-1;for(;++r<n&&!1!==e(i[r],r,i););return t},Or=Set&&1/ur(new Set([void 0,-0]))[1]==1/0?t=>new Set(t):()=>{};function Nr(t,e,n,i,r,o){return to(t)&&to(e)&&(o.set(e,t),kr(t,e,void 0,Nr,o),o.delete(e)),t}function Rr(t,e,n){e=e.length?e.map((t=>Array.isArray(t)?e=>pr(e,1===t.length?t[0]:t):t)):[t=>t];let i=-1,r=-1;const o=Gi(t)?new Array(t.length):[];return Mr(t,(t=>{const n=e.map((e=>e(t)));o[++r]={criteria:n,index:++i,value:t}})),function(t,e){let{length:i}=t;for(t.sort(((t,e)=>function(t,e,n){let i=-1;const r=t.criteria,o=e.criteria,s=r.length,a=n.length;for(;++i<s;){const t=i<a?n[i]:null,e=(t&&"function"==typeof t?t:gr)(r[i],o[i]);if(e)return t&&"function"!=typeof t?e*("desc"==t?-1:1):e}return t.index-e.index}(t,e,n)));i--;)t[i]=t[i].value;return t}(o)}function Fr(t){return t==t&&!to(t)}function Br(t,e){return n=>null!=n&&n[t]===e&&(void 0!==e||t in Object(n))}function Ir(t,e){return null!=t&&Wr(t,e,Hr)}function Dr(t){const e=function(t){const e=Fi(t);let n=e.length;for(;n--;){const i=e[n],r=t[i];e[n]=[i,r,Fr(r)]}return e}(t);return 1===e.length&&e[0][2]?Br(e[0][0],e[0][1]):n=>n===t||function(t,e,n,i){let r=n.length;const o=r;if(null==t)return!o;let s,a;for(t=Object(t);r--;)if(s=n[r],s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1;for(;++r<o;){s=n[r];const e=s[0],i=t[e],o=s[1];if(s[2]){if(void 0===i&&!(e in t))return!1}else{const t=new Xr;if(!(void 0===a?ir(o,i,t):a))return!1}}return!0}(n,0,e)}function Vr(t){return"function"==typeof t?t:null==t?t=>t:"object"==typeof t?Array.isArray(t)?(e=t[0],n=t[1],dr(e)&&Fr(n)?Br(vr(e),n):t=>{const i=pr(t,e);return void 0===i&&i===n?Ir(t,e):ir(n,i)}):Dr(t):function(t){return dr(t)?(e=vr(t),t=>null==t?void 0:t[e]):function(t){return e=>pr(e,t)}(t);var e}(t);var e,n}function zr(){const t=Vr;return arguments.length?t(arguments[0],arguments[1]):t}const jr=(t,e,n,i)=>{let r=-1;const o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},$r=(t,e,n,i,r)=>(r(t,((t,r,o)=>{n=i?(i=!1,t):e(n,t,r,o)})),n),Ur=t=>Array.isArray(t)||qr(t)||!(!t||!t[Symbol.isConcatSpreadable]);function Gr(t,e,n,i,r){let o=-1;const s=t.length;for(n||(n=Ur),r||(r=[]);++o<s;){var a=t[o];e>0&&n(a)?e>1?Gr(a,e-1,n,i,r):r.push(...a):i||(r[r.length]=a)}return r}const qr=t=>Vi(t)&&"[object Arguments]"==Wi(t),Hr=(t,e)=>null!=t&&e in Object(t),Wr=(t,e,n)=>{for(var i,r=-1,o=(e=fr(e,t)).length,s=!1;++r<o;){var a=vr(e[r]);if(!(s=null!=t&&n(t,a)))break;t=t[a]}return s||++r!=o?s:!!(o=null==t?0:t.length)&&"number"==typeof(i=o)&&i>-1&&i%1==0&&i<=Number.MAX_SAFE_INTEGER&&Ar(a,o)&&(Array.isArray(t)||qr(t))},Yr=("toUpperCase",t=>{if(!t)return"";const e=Oi(t)?Ni(t):void 0,n=e?e[0]:t[0],i=e?((t,e,n)=>{const{length:i}=t;return n=void 0===n?i:n,t.slice(1,n)})(e).join(""):t.slice(1);return n.toUpperCase()+i});class Xr{constructor(t){const e=this.__data__=new Zr(t);this.size=e.size}clear(){this.__data__=new Zr,this.size=0}delete(t){const e=this.__data__,n=e.delete(t);return this.size=e.size,n}get(t){return this.__data__.get(t)}has(t){return this.__data__.has(t)}set(t,e){let n=this.__data__;if(n instanceof Zr){const i=n.__data__;if(i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Kr(i)}return n.set(t,e),this.size=n.size,this}}class Zr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.__data__=[],this.size=0}delete(t){const e=this.__data__,n=Ii(e,t);return!(n<0)&&(n==e.length-1?e.pop():e.splice(n,1),--this.size,!0)}get(t){const e=this.__data__,n=Ii(e,t);return n<0?void 0:e[n][1]}has(t){return Ii(this.__data__,t)>-1}set(t,e){const n=this.__data__,i=Ii(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}}class Kr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.size=0,this.__data__={hash:new Jr,map:new Map,string:new Jr}}delete(t){const e=nr(this,t).delete(t);return this.size-=e?1:0,e}get(t){return nr(this,t).get(t)}has(t){return nr(this,t).has(t)}set(t,e){const n=nr(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}}class Jr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.__data__=Object.create(null),this.size=0}delete(t){const e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}get(t){const e=this.__data__[t];return e===wi?void 0:e}has(t){return void 0!==this.__data__[t]}set(t,e){const n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?wi:e,this}}class Qr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.__data__=new Kr;++e<n;)this.add(t[e])}add(t){return this.__data__.set(t,wi),this}has(t){return this.__data__.has(t)}}Qr.prototype.push=Qr.prototype.add;const to=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},eo=function(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Cn},no=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Rn},io=_r(((t,e)=>{if(ji(e)||Gi(e))Ui(e,Fi(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&$i(t,n,e[n])})),ro=(t,...e)=>{let n=-1,i=e.length;const r=i>2?e[2]:void 0;for(r&&zi(e[0],e[1],r)&&(i=1);++n<i;){const i=e[n];if(null==i)continue;const r=Object.keys(i),o=r.length;let s=-1;for(;++s<o;){const e=r[s],n=t[e];(void 0===n||Di(n,Object.prototype[e])&&!hasOwnProperty.call(t,e))&&(t[e]=i[e])}}return t},oo=function(...t){return t.push(void 0,Nr),Mo.apply(void 0,t)},so=(t,e,...n)=>{let i=-1;const r="function"==typeof e,o=Gi(t)?new Array(t.length):[];return Mr(t,(t=>{o[++i]=r?e.apply(t,n):ao(t,e,...n)})),o},ao=(t,e,...n)=>{e=fr(e,t);const i=null==(t=wr(t,e))?t:t[vr(function(t){const e=null==t?0:t.length;return e?t[e-1]:void 0}(e))];return null==i?void 0:i.apply(t,n)},lo=(t,e,n)=>{let i=0,r=null==t?0:t.length;if(0==r)return 0;const o=(e=(n=zr(n,2))(e))!=e,s=null===e,a=qi(e),l=void 0===e;for(;i<r;){let c;const h=Math.floor((i+r)/2),u=n(t[h]),d=void 0!==u,f=null===u,p=u==u,g=qi(u);c=o?p:l?p&&d:s?p&&d&&!f:a?p&&d&&!f&&!g:!f&&!g&&u<e,c?i=h+1:r=h}return Math.min(r,4294967294)},co=(t,e)=>{let n=-1,i=(t,e)=>!(null==t||!t.length)&&t.indexOf(e)>-1;e=zr(e,2);let r=!0;const{length:o}=t,s=[];let a=s;if(o>=200){const n=e?null:Or(t);if(n)return ur(n);r=!1,i=(t,e)=>t.has(e),a=new Qr}else a=e?[]:s;t:for(;++n<o;){let o=t[n];const l=e?e(o):o;if(o=0!==o?o:0,r&&l==l){let t=a.length;for(;t--;)if(a[t]===l)continue t;e&&a.push(l),s.push(o)}else i(a,l)||(a!==s&&a.push(l),s.push(o))}return s},ho=t=>yr(t),uo=t=>yr(t,!0),fo=t=>{if(null==t)return!0;if(Gi(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||Ji(t)||qr(t)))return!t.length;const e=Wi(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(ji(t))return!(t=>{if(!ji(t))return Object.keys(t);var e=[];for(var n in Object(t))hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e})(t).length;for(const e in t)if(hasOwnProperty.call(t,e))return!1;return!0},po=(t,e)=>ir(t,e),go=t=>"function"==typeof t,mo=t=>{if(!Vi(t)||"[object Object]"!=Wi(t))return!1;if(null===Object.getPrototypeOf(t))return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},vo=t=>{if(!t)return[];if(Gi(t))return no(t)?Ni(t):Hi(t);if(Symbol.iterator&&Symbol.iterator in Object(t)){const e=t[Symbol.iterator]();let n;const i=[];for(;!(n=e.next()).done;)i.push(n.value);return i}const e=Wi(t);return(e==Ln?hr:e==Nn?ur:Ri)(t)},yo=(t,e=[])=>{if(null==t)return[];const n=e.length;return n>1&&zi(t,e[0],e[1])?e=[]:n>2&&zi(e[0],e[1],e[2])&&(e=[e[0]]),Array.isArray(e)||(e=[zr(e,2)]),Rr(t,e.flat(1),[])},bo=t=>null!=t&&t.length?Gr(t,1/0):[],wo=(t,...e)=>Gi(t)?mr(t,e):[],xo=(t,...e)=>Vi(t)&&Gi(t)?mr(t,e.flat(1)):[],Ao=(...t)=>{const e=t.flat(1);return co(e)},To=(t,e)=>{if(null==t)return!1;"string"==typeof e&&(e=e.split("."));let n=-1,i=t;for(;++n<e.length;){if(!i||!hasOwnProperty.call(i,e[n]))return!1;i=i[e[n]]}return!0},Eo=(t,e,n)=>{let i=-1,r=(e=fr(e,t)).length;for(r||(r=1,t=void 0);++i<r;){let o=null==t?void 0:t[vr(e[i])];void 0===o&&(i=r,o=n),t="function"==typeof o?o.call(t):o}return t},So=(t,...e)=>{let n={};if(null==t)return n;let i=!1;e=e.flat(1).map((e=>(e=fr(e,t),i||(i=e.length>1),e))),Ui(t,er(t),n),i&&(n=yr(n,!0,!0,!0,(t=>mo(t)?void 0:t)));let r=e.length;for(;r--;)Tr(n,e[r]);return n},Po=(t,...e)=>null==t?{}:((t,e)=>((t,e,n)=>{let i=-1;const r=e.length,o={};for(;++i<r;){const r=e[i],s=pr(t,r);n(s,r)&&xr(o,fr(r,t),s)}return o})(t,e,((e,n)=>Ir(t,n))))(t,e.flat(1/0)),_o=(t,e=(t=>t))=>{let n=-1;const i=Object(t),r=Gi(t)?Bi(t,!0):Sr(t);let o=r.length;for(;o--;){const t=r[++n];if(!1===e(i[t],t,i))break}},ko=(t="")=>((t,e)=>{if(void 0===e){const e=Ci(t)?(t=>t.match(bi))(t):(t=>t.match(Mi))(t);return e||[]}return t.match(e)||[]})(`${t}`.replace(/['\u2019]/g,"")).reduce(((t,e,n)=>(e=e.toLowerCase(),t+(n?Yr(e):e))),"");let Lo=0;const Co=(t="")=>`${t}`+ ++Lo,Mo=_r(((t,e,n,i)=>{kr(t,e,n,i)}),!0),Oo=class{constructor(){this.map=new WeakMap}has(t,e){return void 0===e?this.map.has(t):e in this.map.get(t)}create(t){return this.has(t)||this.map.set(t,Object.create(null)),this.get(t)}get(t,e){if(!this.has(t))return;const n=this.map.get(t);return void 0===e?n:n[e]}set(t,e,n){if(void 0===e)return;const i=this.create(t);"string"==typeof e?i[e]=n:Object.assign(i,e)}remove(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])}},No=new Oo,Ro=new Oo,Fo=function(t,e){if(!(this instanceof Fo))return new Fo(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?Bo:Io,this.target=t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget):this.type=t,e&&Object.assign(this,e),this.timeStamp=t&&t.timeStamp||Date.now(),this.envelope=!0};function Bo(){return!0}function Io(){return!1}Fo.prototype={constructor:Fo,isDefaultPrevented:Io,isPropagationStopped:Io,isImmediatePropagationStopped:Io,preventDefault:function(){const t=this.originalEvent;this.isDefaultPrevented=Bo,t&&t.preventDefault()},stopPropagation:function(){const t=this.originalEvent;this.isPropagationStopped=Bo,t&&t.stopPropagation()},stopImmediatePropagation:function(){const t=this.originalEvent;this.isImmediatePropagationStopped=Bo,t&&t.stopImmediatePropagation(),this.stopPropagation()}},["altKey","bubbles","cancelable","changedTouches","ctrlKey","detail","eventPhase","metaKey","pageX","pageY","shiftKey","view","char","code","charCode","key","keyCode","button","buttons","clientX","clientY","offsetX","offsetY","pointerId","pointerType","screenX","screenY","targetTouches","toElement","touches","which"].forEach((t=>function(t){Object.defineProperty(Fo.prototype,t,{enumerable:!0,configurable:!0,get:function(){return this.originalEvent?this.originalEvent[t]:void 0},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})}(t)));const Do="undefined"!=typeof window?window.document:null,Vo=Do&&Do.documentElement,zo=/^([^.]*)(?:\.(.+)|)/,jo=/[^\x20\t\r\n\f]+/g,$o=function(t){return new $o.Dom(t)};$o.fn=$o.prototype={constructor:$o,length:0},$o.guid=1,$o.data=Ro,$o.merge=function(t,e){let n=+e.length,i=t.length;for(let r=0;r<n;r++)t[i++]=e[r];return t.length=i,t},$o.parseHTML=function(t){const e=Do.implementation.createHTMLDocument(),n=e.createElement("base");n.href=Do.location.href,e.head.appendChild(n),e.body.innerHTML=t;const i=e.getElementsByTagName("script");for(let t=0;t<i.length;t++)i[t].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&($o.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),$o.fn.toArray=function(){return Array.from(this)},$o.fn.pushStack=function(t){const e=$o.merge(this.constructor(),t);return e.prevObject=this,e},$o.fn.find=function(t){const[e]=this,n=this.pushStack([]);if(!e)return n;const{nodeType:i}=e;return 1!==i&&9!==i&&11!==i||("string"!=typeof t?e!==t&&e.contains(t)&&$o.merge(n,[t]):$o.merge(n,e.querySelectorAll(t))),n},$o.fn.add=function(t,e){const n=$o(t,e).toArray(),i=this.toArray(),r=this.pushStack([]);return $o.merge(r,co(i.concat(n))),r},$o.fn.addBack=function(){return this.add(this.prevObject)},$o.fn.filter=function(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];i.matches(t)&&e.push(i)}return this.pushStack(e)};const Uo=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Go=function(t){if(!t)return this;if("function"==typeof t)throw new Error("function not supported");if(arguments.length>1)throw new Error("selector with context not supported");if(t.nodeType)return this[0]=t,this.length=1,this;let e;if("<"===(n=t+"")[0]&&">"===n[n.length-1]&&n.length>=3)e=[null,t,null];else{if("string"!=typeof t)return $o.merge(this,t);e=Uo.exec(t)}var n;if(!e||!e[1])return qo.find(t);if(e[1])return $o.merge(this,$o.parseHTML(e[1])),this;const i=Do.getElementById(e[2]);return i&&(this[0]=i,this.length=1),this};$o.Dom=Go,Go.prototype=$o.fn,$o.Event=Fo,$o.event={special:Object.create(null)},$o.event.has=function(t,e){const n=No.get(t,"events");return!!n&&(!e||Array.isArray(n[e])&&n[e].length>0)},$o.event.on=function(t,e,n,i,r,o){if("object"==typeof e){"string"!=typeof n&&(i=i||n,n=void 0);for(let r in e)$o.event.on(t,r,n,i,e[r],o);return t}if(null==i&&null==r?(r=n,i=n=void 0):null==r&&("string"==typeof n?(r=i,i=void 0):(r=i,i=n,n=void 0)),!r)return t;if(1===o){const t=r;r=function(e){return $o().off(e),t.apply(this,arguments)},r.guid=t.guid||(t.guid=$o.guid++)}for(let o=0;o<t.length;o++)$o.event.add(t[o],e,r,i,n)},$o.event.add=function(t,e,n,i,r){if("object"!=typeof t)return;const o=No.create(t);let s,a,l;n.handler&&(s=n,n=s.handler,r=s.selector),r&&Vo.matches(r),n.guid||(n.guid=$o.guid++),(a=o.events)||(a=o.events=Object.create(null)),(l=o.handle)||(l=o.handle=function(e){return void 0!==$o?$o.event.dispatch.apply(t,arguments):void 0});const c=(e||"").match(jo)||[""];let h=c.length;for(;h--;){const[,e,o=""]=zo.exec(c[h]);if(!e)continue;const u=o.split(".").sort();let d=$o.event.special[e];const f=d&&(r?d.delegateType:d.bindType)||e;d=$o.event.special[f];const p=Object.assign({type:f,origType:e,data:i,handler:n,guid:n.guid,selector:r,namespace:u.join(".")},s);let g;(g=a[f])||(g=a[f]=[],g.delegateCount=0,d&&d.setup&&!1!==d.setup.call(t,i,u,l)||t.addEventListener&&t.addEventListener(f,l)),d&&d.add&&(d.add.call(t,p),p.handler.guid||(p.handler.guid=n.guid)),r?g.splice(g.delegateCount++,0,p):g.push(p)}},$o.event.remove=function(t,e,n,i,r){const o=No.get(t);if(!o||!o.events)return;const s=o.events,a=(e||"").match(jo)||[""];let l=a.length;for(;l--;){const[,e,c=""]=zo.exec(a[l]);if(!e){for(const e in s)$o.event.remove(t,e+a[l],n,i,!0);continue}const h=$o.event.special[e],u=h&&(i?h.delegateType:h.bindType)||e,d=s[u];if(!d||0===d.length)continue;const f=c.split(".").sort(),p=c?new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,g=d.length;let m=g;for(;m--;){const o=d[m];!r&&e!==o.origType||n&&n.guid!==o.guid||p&&!p.test(o.namespace)||i&&i!==o.selector&&("**"!==i||!o.selector)||(d.splice(m,1),o.selector&&d.delegateCount--,h&&h.remove&&h.remove.call(t,o))}g&&0===d.length&&(h&&h.teardown&&!1!==h.teardown.call(t,f,o.handle)||t.removeEventListener&&t.removeEventListener(u,o.handle),delete s[u])}fo(s)&&(No.remove(t,"handle"),No.remove(t,"events"))},$o.event.dispatch=function(t){const e=this,n=$o.event.fix(t);n.delegateTarget=e;const i=Array.from(arguments);i[0]=n;const r=No.get(e,"events"),o=r&&r[n.type]||[],s=$o.event.special[n.type];if(s&&s.preDispatch&&!1===s.preDispatch.call(e,n))return;const a=$o.event.handlers.call(e,n,o);let l,c=0;for(;(l=a[c++])&&!n.isPropagationStopped();){n.currentTarget=l.elem;let t,e=0;for(;(t=l.handlers[e++])&&!n.isImmediatePropagationStopped();){n.handleObj=t,n.data=t.data;const e=$o.event.special[t.origType];let r;r=e&&e.handle?e.handle:t.handler;const o=r.apply(l.elem,i);void 0!==o&&!1===(n.result=o)&&(n.preventDefault(),n.stopPropagation())}}return s&&s.postDispatch&&s.postDispatch.call(e,n),n.result},$o.event.handlers=function(t,e){const n=e.delegateCount,i=[];if(n&&!("click"===t.type&&t.button>=1))for(let r=t.target;r!==this;r=r.parentNode||this)if(1===r.nodeType&&("click"!==t.type||!0!==r.disabled)){const t=[],o={};for(let i=0;i<n;i++){const n=e[i],s=n.selector+" ";void 0===o[s]&&(o[s]=r.matches(s)),o[s]&&t.push(n)}t.length&&i.push({elem:r,handlers:t})}return n<e.length&&i.push({elem:this,handlers:e.slice(n)}),i},$o.event.fix=function(t){return t.envelope?t:new Fo(t)};const qo=$o(Do);function Ho(t){let e=t.length;for(;e--;)Wo(t[e])}function Wo(t){$o.event.remove(t),No.remove(t),Ro.remove(t)}function Yo(t){for(let e=0;e<t.length;e++){const n=t[e];n.parentNode&&n.parentNode.removeChild(n)}}function Xo(){for(let t=0;t<this.length;t++){const e=this[t];Wo(e),Ho(e.getElementsByTagName("*"))}return Yo(this),this}function Zo(){return Yo(this),this}function Ko(){for(let t=0;t<this.length;t++){const e=this[t];1===e.nodeType&&(Ho(e.getElementsByTagName("*")),e.textContent="")}return this}function Jo(){const t=[];for(let e=0;e<this.length;e++)t.push(this[e].cloneNode(!0));return this.pushStack(t)}function Qo(t){const[e]=this;return e?0===arguments.length?e.innerHTML:void 0===t?this:(Ho(No,e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t?(e.innerHTML="",this.append(t)):(e.innerHTML=t,this)):null}function ts(...t){const[e]=this;return e?(t.forEach((t=>{t&&("string"==typeof t?e.append(...$o.parseHTML(t)):"[object Object]"===t.toString()?this.append(...Array.from(t)):Array.isArray(t)?this.append(...t):e.appendChild(t))})),this):this}function es(...t){const[e]=this;return e?(t.forEach((t=>{t&&("string"==typeof t?e.prepend(...$o.parseHTML(t)):"[object Object]"===t.toString()?this.prepend(...Array.from(t)):Array.isArray(t)?this.prepend(...t):e.insertBefore(t,e.firstChild))})),this):this}function ns(t){return $o(t).append(this),this}function is(t){return $o(t).prepend(this),this}const rs={};function os(t,e,n){"number"==typeof n&&rs[ko(e)]&&(n+="px"),t.style[e]=n}function ss(t,e){let n;if("string"==typeof t){if(void 0===e){const[e]=this;return e?e.style[t]:null}n={[t]:e}}else{if(!t)throw new Error("no styles provided");n=t}for(let t in n)if(n.hasOwnProperty(t))for(let e=0;e<this.length;e++)os(this[e],t,n[t]);return this}function as(t,e){if(arguments.length<2){const[e]=this;return e?void 0===t?e.dataset:e.dataset[t]:null}for(let n=0;n<this.length;n++)this[n].dataset[t]=e;return this}function ls(t,e,n){for(let i=0;i<e.length;i++){const r=e[i];An.prototype[t].apply({node:r},n)}}function cs(){return ls("removeClass",this,arguments),this}function hs(){return ls("addClass",this,arguments),this}function us(){return ls("toggleClass",this,arguments),this}function ds(){const[t]=this;return!!t&&An.prototype.hasClass.apply({node:t},arguments)}function fs(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];let r=Array.from(i.children);"string"==typeof t&&(r=r.filter((e=>e.matches(t)))),e.push(...r)}return this.pushStack(e)}function ps(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];if("string"==typeof t){const n=i.closest(t);n&&e.push(n)}else{const[n]=$o(t);n&&n.contains(i)&&e.push(n)}}return this.pushStack(e)}function gs(t,e,n,i){return $o.event.on(this,t,e,n,i),this}function ms(t,e,n,i){return $o.event.on(this,t,e,n,i,1),this}function vs(t,e,n){if(t&&t.preventDefault&&t.handleObj){const e=t.handleObj;return $o(t.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this}if("object"==typeof t){for(let n in t)this.off(n,e,t[n]);return this}!1!==e&&"function"!=typeof e||(n=e,e=void 0);for(let i=0;i<this.length;i++)$o.event.remove(this[i],t,n,e);return this}function ys(){const[t]=this;if(t===window)return t.document.documentElement.clientWidth;if(!t)return;const e=window.getComputedStyle(t),n=t.offsetWidth,i=parseFloat(e.borderTopWidth);return n-parseFloat(e.borderBottomWidth)-i-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)}function bs(){const[t]=this;if(t===window)return t.document.documentElement.clientHeight;if(!t)return;const e=window.getComputedStyle(t);return t.offsetHeight-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)}function ws(){const[t]=this;if(!t)return;let e,n,i,r=$o(t),o={top:0,left:0};if("fixed"===r.css("position"))n=t.getBoundingClientRect();else{n=r.offset(),i=t.ownerDocument,e=t.offsetParent||i.documentElement;const s=$o(e),a=s.css("position")||"static";for(;e&&(e===i.body||e===i.documentElement)&&"static"===a;)e=e.parentNode;if(e&&e!==t&&1===e.nodeType){const t=window.getComputedStyle(e),n=parseFloat(t.borderTopWidth)||0,i=parseFloat(t.borderLeftWidth)||0;o=s.offset(),o.top+=n,o.left+=i}}const s=parseFloat(window.getComputedStyle(t).marginTop)||0,a=parseFloat(window.getComputedStyle(t).marginLeft)||0;return{top:n.top-o.top-s,left:n.left-o.left-a}}function xs(t){const[e]=this;if(void 0===t){if(!e)return null;if(!e.getClientRects().length)return{top:0,left:0};const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}if(!e)return this;const n=window.getComputedStyle(e);"static"===n.position&&this.css("position","relative");const i=this.offset(),r=t.top-i.top,o=t.left-i.left;return this.css({top:(parseFloat(n.top)||0)+r+"px",left:(parseFloat(n.left)||0)+o+"px"}),this}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach((t=>{rs[t]=!0}));const As="animationFrameId",Ts={};function Es(t,e={}){this.stop();for(let n=0;n<this.length;n++)Ss(this[n],t,e);return this}function Ss(t,e,n={}){let{duration:i=400,easing:r="ease-in-out",delay:o=0,complete:s}=n;const a=setTimeout((function(){const n=$o(t);let a=!1,l="transitionend";i/=1e3,o/=1e3;const c={};if("string"==typeof e)c["animation-name"]=e,c["animation-duration"]=i+"s",c["animation-delay"]=o+"s",c["animation-timing-function"]=r,l="animationend";else{const t=[];for(var h in e)e.hasOwnProperty(h)&&(c[h]=e[h],t.push(h));i>0&&(c["transition-property"]=t.join(", "),c["transition-duration"]=i+"s",c["transition-delay"]=o+"s",c["transition-timing-function"]=r)}const u=function(e){if(e){if(e.target!==e.currentTarget)return;e.target.removeEventListener(l,u)}else t.removeEventListener(l,u);a=!0,n.css(Ts),s&&s.call(t)};if(i>0){t.addEventListener(l,u);const e=setTimeout((function(){a||u(null)}),1e3*(i+o)+25);No.set(t,As,{id:e,stop:()=>{clearTimeout(e),t.removeEventListener(l,u)}})}n.css(c),i<=0&&u(null)}));No.set(t,As,{stop:()=>clearTimeout(a)})}function Ps(){for(let t=0;t<this.length;t++){const e=this[t],n=No.get(e,As);n&&(n.stop(),No.remove(e,As))}return this.css(Ts),this}Ts["transition-property"]=Ts["transition-duration"]=Ts["transition-delay"]=Ts["transition-timing-function"]=Ts["animation-name"]=Ts["animation-duration"]=Ts["animation-delay"]=Ts["animation-timing-function"]="";const _s={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},ks={disabled:"disabled",value:"value",text:"textContent"},Ls={prop:function(t,e){if(!t)throw new Error("no property provided");if(1===arguments.length){const[e]=this;return e?e[t]:null}if(void 0===e)return this;for(let n=0;n<this.length;n++)this[n][t]=e;return this},attr:function(t,e){let n;if("string"==typeof t){if(void 0===e){const[e]=this;return e?e.getAttribute(t):null}n={[t]:e}}else{if(!t)throw new Error("no attributes provided");n=t}for(let t in n)if(n.hasOwnProperty(t)){const e=n[t];if(ks[t]){this.prop(ks[t],e);continue}for(let n=0;n<this.length;n++)null===e?this[n].removeAttribute(t):this[n].setAttribute(t,e)}return this}};Object.keys(_s).forEach((t=>{Ls[t]=function(...e){return this.prop(_s[t],...e)}}));const Cs=Ls,Ms="joint-",Os=Object.create(null),Ns=Os;Os.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach((([t,e])=>{Os[t]={delegateType:e,bindType:e,handle:function(t){const n=t.relatedTarget,i=t.handleObj;let r;return n&&this.contains(n)||(t.type=i.origType,r=i.handler.apply(this,arguments),t.type=e),r}}}));Os.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t,...e){const{handleObj:n,target:i}=t,r=$o.data.create(i),o=(new Date).getTime(),s="lastTouch"in r?o-r.lastTouch:0;s<300&&s>30?(r.lastTouch=null,t.type=n.origType,n.handler.call(this,t,...e)):r.lastTouch=o}},Object.assign($o.fn,r),Object.assign($o.fn,o),Object.assign($o.fn,Cs),Object.assign($o.event.special,Ns);const Rs=$o,Fs=function(t){return t?t.toString().split(" ").map((function(t){return t.substr(0,6)!==Ms&&(t=Ms+t),t})).join(" "):t},Bs=function(t,e){const n={},i={},r=An.namespace.svg,o=e||r,s=document.createDocumentFragment(),a=function(t,e,o){for(let s=0;s<t.length;s++){const l=t[s];if("string"==typeof l){const t=document.createTextNode(l);e.appendChild(t);continue}if(!l.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");const c=l.tagName;let h;l.hasOwnProperty("namespaceURI")&&(o=l.namespaceURI),h=document.createElementNS(o,c);const u=o===r,d=u?An(h):Rs(h),f=l.attributes;f&&d.attr(f);const p=l.style;if(p&&Rs(h).css(p),l.hasOwnProperty("className")){const t=l.className;u?h.className.baseVal=t:h.className=t}if(l.hasOwnProperty("textContent")&&(h.textContent=l.textContent),l.hasOwnProperty("selector")){const t=l.selector;if(n[t])throw new Error("json-dom-parser: selector must be unique");n[t]=h,d.attr("joint-selector",t)}if(l.hasOwnProperty("groupSelector")){let t=l.groupSelector;Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;e++){const n=t[e];let r=i[n];r||(r=i[n]=[]),r.push(h)}}e.appendChild(h);const g=l.children;Array.isArray(g)&&a(g,h,o)}};return a(t,s,o),{fragment:s,selectors:n,groupSelectors:i}},Is=function(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e},Ds=function(t,e,n){for(var i,r=Array.isArray(e)?e:e.split(n||"/"),o=0,s=r.length;o<s;){if(i=r[o++],Object(t)!==t||!(i in t))return;t=t[i]}return t},Vs=function(t,e){return"string"!=typeof e&&"number"!=typeof e&&(e=String(e)),("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!==e},zs=function(t,e,n,i){const r=Array.isArray(e)?e:e.split(i||"/"),o=r.length-1;let s=t,a=0;for(;a<o;a++){const e=r[a];if(!Vs(s,e))return t;s=s[e]||(s[e]={})}return s[r[o]]=n,t},js=function(t,e,n){const i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1;let o=t,s=0;for(;s<r;s++){const e=i[s];if(!Vs(o,e))return t;const n=o[e];if(!n)return t;o=n}return delete o[i[r]],t},$s=function(t){return $s.id=$s.id||1,void 0===t?"j_"+$s.id++:(t.id=void 0===t.id?"j_"+$s.id++:t.id,t.id)},Us=function(t){if(t.normalized)return t;const{originalEvent:e,target:n}=t,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(let e in i)void 0===t[e]&&(t[e]=i[e]);if(n){const e=n.correspondingUseElement;e&&(t.target=e)}return t.normalized=!0,t},Gs=function(){var t;if("undefined"!=typeof window&&(t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!t){var e=0;t=function(t){var n=(new Date).getTime(),i=Math.max(0,16-(n-e)),r=setTimeout((function(){t(n+i)}),i);return e=n+i,r}}return function(e,n,...i){return t(void 0!==n?e.bind(n,...i):e)}}(),qs=((Ws="undefined"!=typeof window)&&(Hs=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),Hs=Hs||clearTimeout,Ws?Hs.bind(window):Hs);var Hs,Ws;const Ys=function(t){return no(t)&&"%"===t.slice(-1)},Xs=function(t,e){var n=parseFloat(t);if(Number.isNaN(n))return null;var i,r={};if(r.value=n,null==e)i="[A-Za-z]*";else if(Array.isArray(e)){if(0===e.length)return null;i=e.join("|")}else no(e)&&(i=e);var o=function(e){var n=new RegExp("(?:\\d+(?:\\.\\d+)*)("+e+")$").exec(t);return n?n[1]:null}(i);return null===o?null:(r.unit=o,r)};function Zs(t,e){const n=t.split(e);let i=1;for(let t=0,r=n.length-1;t<r;t++){const o=[];(t>0||""!==n[0])&&o.push(0),o.push(e),(t<r-1||""!==n[r])&&o.push(0),n.splice(i,0,...o),i+=o.length+1}return n.filter((t=>""!==t))}function Ks(t,e){if(null===t)return e.getBBox().height;switch(t.unit){case"em":return e.getBBox().height*t.value;case"px":case"":return t.value}}const Js=function(t,e,n={},i={}){var r=e.width,o=e.height,s=i.svgDocument||An("svg").node,a=An("tspan").node,l=An("text").attr(n).append(a).node,c=document.createTextNode("");l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(c),s.appendChild(l),i.svgDocument||document.body.appendChild(s);const h=i.preserveSpaces,u=i.separator||""===i.separator?i.separator:" ",d="string"==typeof u?u:" ";var f=i.eol||"\n",p=i.hyphen?new RegExp(i.hyphen):/[^\w\d\u00C0-\u1FFF\u2800-\uFFFD]/,g=i.maxLineCount;eo(g)||(g=1/0);var m,v,y,b=t.split(u),w=[],x=[];h&&An(a).attr("xml:space","preserve");for(var A=0,T=0,E=b.length;A<E;A++){var S=b[A];if((S||h)&&"string"==typeof S){var P=!1;if(f&&S.indexOf(f)>=0){if(S.length>1){const t=Zs(b[A],f);b.splice(A,1,...t),A--,E=b.length;continue}if(h&&"string"==typeof b[A-1]){b.splice(A,0,"",0),E+=2,A--;continue}x[++T]=h&&"string"!=typeof b[A+1]?void 0:"",P=!0}if(!P){let t;if(t=h?void 0!==x[T]?x[T]+d+S:S:x[T]?x[T]+d+S:S,c.data=t,a.getComputedTextLength()<=r)x[T]=t,(m||v)&&(w[T++]=!0,m=0,v=0);else{if(!x[T]||m){var _=!!m;if(m=S.length-1,_||!m){if(!m){if(!x[T]){x=[];break}b.splice(A,2,S+b[A+1]),E--,w[T++]=!0,A--;continue}b[A]=S.substring(0,m);const t=b[A+1];b[A+1]=S.substring(m)+(void 0===t||0===t?"":t)}else{if(v)b.splice(A,2,b[A]+b[A+1]),v=0;else{var k=S.search(p);k>-1&&k!==S.length-1&&0!==k&&(v=k+1,m=0),b.splice(A,1,S.substring(0,v||m),S.substring(v||m)),E++}T&&!w[T-1]&&T--}h&&""===x[T]||A--;continue}T++,A--}}var L=null;if(x.length>g?L=g-1:void 0!==o&&(void 0===y&&""!==c.data&&(y="auto"===n.lineHeight?Ks({value:1.5,unit:"em"},l):Ks(Xs(n.lineHeight,["em","px",""]),l)),y*x.length>o&&(L=Math.floor(o/y)-1)),null!==L){x.splice(L+1);var C=i.ellipsis;if(!C||L<0)break;"string"!=typeof C&&(C="…");var M=x[L];if(!M&&!P)break;var O,N,R=M.length;do{if(N=M[R],O=M.substring(0,R),N?N.match(u)&&(O+=N):O+=d,O+=C,c.data=O,a.getComputedTextLength()<=r){x[L]=O;break}R--}while(R>=0);break}}}return i.svgDocument?s.removeChild(l):document.body.removeChild(s),x.join(f)},Qs=function(t){if(Object(t)!==t){var e=0;return isFinite(t)&&(e=+t),{top:e,right:e,bottom:e,left:e}}var n,i,r,o;return n=i=r=o=0,isFinite(t.vertical)&&(n=r=+t.vertical),isFinite(t.horizontal)&&(i=o=+t.horizontal),isFinite(t.top)&&(n=+t.top),isFinite(t.right)&&(i=+t.right),isFinite(t.bottom)&&(r=+t.bottom),isFinite(t.left)&&(o=+t.left),{top:n,right:i,bottom:r,left:o}},ta={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)},exponential:function(t){return Math.pow(2,10*(t-1))},bounce:function(t){for(var e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11){var i=(11-6*e-11*t)/4;return-i*i+n*n}},reverse:function(t){return function(e){return 1-t(1-e)}},reflect:function(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}},clamp:function(t,e,n){return e=e||0,n=n||1,function(i){var r=t(i);return r<e?e:r>n?n:r}},back:function(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}},elastic:function(t){return t||(t=1.5),function(e){return Math.pow(2,10*(e-1))*Math.cos(20*Math.PI*t/3*e)}}},ea={number:function(t,e){var n=e-t;return function(e){return t+n*e}},object:function(t,e){var n=Object.keys(t);return function(i){var r,o,s={};for(r=n.length-1;-1!=r;r--)s[o=n[r]]=t[o]+(e[o]-t[o])*i;return s}},hexColor:function(t,e){var n=parseInt(t.slice(1),16),i=parseInt(e.slice(1),16),r=255&n,o=(255&i)-r,s=65280&n,a=(65280&i)-s,l=16711680&n,c=(16711680&i)-l;return function(t){return"#"+(1<<24|r+o*t&255|s+a*t&65280|l+c*t&16711680).toString(16).slice(1)}},unit:function(t,e){var n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,i=n.exec(t),r=n.exec(e),o=r[1].indexOf("."),s=o>0?r[1].length-o-1:0;t=+i[1];var a=+r[1]-t,l=i[2];return function(e){return(t+a*e).toFixed(s)+l}}},na={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return ia('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology in="SourceAlpha" result="morphedOuter" operator="dilate" radius="${outerRadius}" /><feMorphology in="SourceAlpha" result="morphedInner" operator="dilate" radius="${innerRadius}" /><feComposite result="morphedOuterColored" in="colored" in2="morphedOuter" operator="in"/><feComposite operator="xor" in="morphedOuterColored" in2="morphedInner" result="outline"/><feMerge><feMergeNode in="outline"/><feMergeNode in="SourceGraphic"/></feMerge></filter>')({color:t.color||"blue",opacity:Number.isFinite(t.opacity)?t.opacity:1,outerRadius:e+n,innerRadius:e})},highlight:function(t){return ia('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology result="morphed" in="SourceGraphic" operator="dilate" radius="${width}"/><feComposite result="composed" in="colored" in2="morphed" operator="in"/><feGaussianBlur result="blured" in="composed" stdDeviation="${blur}"/><feBlend in="SourceGraphic" in2="blured" mode="normal"/></filter>')({color:t.color||"red",width:Number.isFinite(t.width)?t.width:1,blur:Number.isFinite(t.blur)?t.blur:0,opacity:Number.isFinite(t.opacity)?t.opacity:1})},blur:function(t){var e=Number.isFinite(t.x)?t.x:2;return ia('<filter><feGaussianBlur stdDeviation="${stdDeviation}"/></filter>')({stdDeviation:Number.isFinite(t.y)?[e,t.y]:e})},dropShadow:function(t){var e="SVGFEDropShadowElement"in window?'<filter><feDropShadow stdDeviation="${blur}" dx="${dx}" dy="${dy}" flood-color="${color}" flood-opacity="${opacity}"/></filter>':'<filter><feGaussianBlur in="SourceAlpha" stdDeviation="${blur}"/><feOffset dx="${dx}" dy="${dy}" result="offsetblur"/><feFlood flood-color="${color}"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="${opacity}"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge></filter>';return ia(e)({dx:t.dx||0,dy:t.dy||0,opacity:Number.isFinite(t.opacity)?t.opacity:1,color:t.color||"black",blur:Number.isFinite(t.blur)?t.blur:4})},grayscale:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>')({a:.2126+.7874*(1-e),b:.7152-.7152*(1-e),c:.0722-.0722*(1-e),d:.2126-.2126*(1-e),e:.7152+.2848*(1-e),f:.0722-.0722*(1-e),g:.2126-.2126*(1-e),h:.0722+.9278*(1-e)})},sepia:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${h} ${i} 0 0 0 0 0 1 0"/></filter>')({a:.393+.607*(1-e),b:.769-.769*(1-e),c:.189-.189*(1-e),d:.349-.349*(1-e),e:.686+.314*(1-e),f:.168-.168*(1-e),g:.272-.272*(1-e),h:.534-.534*(1-e),i:.131+.869*(1-e)})},saturate:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-e})},hueRotate:function(t){return ia('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:1-e})},brightness:function(t){return ia('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}"/><feFuncG type="linear" slope="${amount}"/><feFuncB type="linear" slope="${amount}"/></feComponentTransfer></filter>')({amount:Number.isFinite(t.amount)?t.amount:1})},contrast:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}" intercept="${amount2}"/><feFuncG type="linear" slope="${amount}" intercept="${amount2}"/><feFuncB type="linear" slope="${amount}" intercept="${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:.5-e/2})}},ia=function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(n){return n=n||{},t.replace(e,(function(t){for(var e=Array.from(arguments).slice(1,4).find((function(t){return!!t})).split("."),i=n[e.shift()];void 0!==i&&e.length;)i=i[e.shift()];return void 0!==i?i:""}))}};var ra,oa={},sa=/\s+/,aa=function(t,e,n,i,r){var o,s=0;if(n&&"object"==typeof n){void 0!==i&&"context"in r&&void 0===r.context&&(r.context=i);for(o=Object.keys(n);s<o.length;s++)e=aa(t,e,o[s],n[o[s]],r)}else if(n&&sa.test(n))for(o=n.split(sa);s<o.length;s++)e=t(e,o[s],i,r);else e=t(e,n,i,r);return e};oa.on=function(t,e,n){return this._events=aa(la,this._events||{},t,e,{context:n,ctx:this,listening:ra}),ra&&((this._listeners||(this._listeners={}))[ra.id]=ra,ra.interop=!1),this},oa.listenTo=function(t,e,n){if(!t)return this;var i=t._listenId||(t._listenId=Co("l")),r=this._listeningTo||(this._listeningTo={}),o=ra=r[i];o||(this._listenId||(this._listenId=Co("l")),o=ra=r[i]=new ga(this,t));var s=ca(t,e,n,this);if(ra=void 0,s)throw s;return o.interop&&o.on(e,n),this};var la=function(t,e,n,i){if(n){var r=t[e]||(t[e]=[]),o=i.context,s=i.ctx,a=i.listening;a&&a.count++,r.push({callback:n,context:o,ctx:o||s,listening:a})}return t},ca=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}};oa.off=function(t,e,n){return this._events?(this._events=aa(ha,this._events,t,e,{context:n,listeners:this._listeners}),this):this},oa.stopListening=function(t,e,n){var i=this._listeningTo;if(!i)return this;for(var r=t?[t._listenId]:Object.keys(i),o=0;o<r.length;o++){var s=i[r[o]];if(!s)break;s.obj.off(e,n,this),s.interop&&s.off(e,n)}return fo(i)&&(this._listeningTo=void 0),this};var ha=function(t,e,n,i){if(t){var r,o=i.context,s=i.listeners,a=0;if(e||o||n){for(r=e?[e]:Object.keys(t);a<r.length;a++){var l=t[e=r[a]];if(!l)break;for(var c=[],h=0;h<l.length;h++){var u=l[h];if(n&&n!==u.callback&&n!==u.callback._callback||o&&o!==u.context)c.push(u);else{var d=u.listening;d&&d.off(e,n)}}c.length?t[e]=c:delete t[e]}return t}if(null!=s)for(r=Object.keys(s);a<r.length;a++)s[r[a]].cleanup()}};oa.once=function(t,e,n){var i=aa(ua,{},t,e,this.off.bind(this));return"string"==typeof t&&null==n&&(e=void 0),this.on(i,e,n)},oa.listenToOnce=function(t,e,n){var i=aa(ua,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,i)};var ua=function(t,e,n,i){if(n){var r=t[e]=da((function(){i(e,r),n.apply(this,arguments)}));r._callback=n}return t},da=function(t){var e;if("function"!=typeof t)throw new TypeError("Expected a function");var n=2;return function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=void 0),e}};oa.trigger=function(t){if(!this._events)return this;for(var e=Math.max(0,arguments.length-1),n=Array(e),i=0;i<e;i++)n[i]=arguments[i+1];return aa(fa,this._events,t,void 0,n),this};var fa=function(t,e,n,i){if(t){var r=t[e],o=t.all;r&&o&&(o=o.slice()),r&&pa(r,i),o&&pa(o,[e].concat(i))}return t},pa=function(t,e){var n,i=-1,r=t.length,o=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++i<r;)(n=t[i]).callback.call(n.ctx);return;case 1:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o);return;case 2:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,s);return;case 3:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,s,a);return;default:for(;++i<r;)(n=t[i]).callback.apply(n.ctx,e);return}},ga=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0};ga.prototype.on=oa.on,ga.prototype.off=function(t,e){var n;this.interop?(this._events=aa(ha,this._events,t,e,{context:void 0,listeners:void 0}),n=!this._events):(this.count--,n=0===this.count),n&&this.cleanup()},ga.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},oa.bind=oa.on,oa.unbind=oa.off;var ma=function(t,e){var n,i=this;return n=t&&To(t,"constructor")?t.constructor:function(){return i.apply(this,arguments)},io(n,i,e),n.prototype=Object.assign(Object.create(i.prototype),t),n.prototype.constructor=n,n.__super__=i.prototype,n},va=function(t,e){return go(t)?t:to(t)&&!e._isModel(t)?ya(t):no(t)?function(e){return e.get(t)}:t},ya=function(t){var e=Dr(yr(t,!0));return function(t){return e(t.attributes)}},ba=function(t,e){var n=t||{};e||(e={}),this.preinitialize.apply(this,arguments),this.cid=Co(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection);var i=Eo(this,"defaults");n=ro(io({},i,n),i),this.set(n,e),this.changed={},this.initialize.apply(this,arguments)};function wa(t){t=co(t);const e=vo(t).reduce((function(t,e){return t[e.id]=e.clone(),t}),{});return vo(t).forEach((function(t){const n=e[t.id];if(n.isLink()){const t=n.source(),i=n.target();t.id&&e[t.id]&&n.prop("source/id",e[t.id].id),i.id&&e[i.id]&&n.prop("target/id",e[i.id].id)}const i=t.get("parent");i&&e[i]&&n.set("parent",e[i].id);const r=vo(t.get("embeds")).reduce((function(t,n){return e[n]&&t.push(e[n].id),t}),[]);fo(r)||n.set("embeds",r)})),e}io(ba.prototype,oa,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return ho(this.attributes)},get:function(t){return this.attributes[t]},has:function(t){return null!=this.get(t)},set:function(t,e,n){if(null==t)return this;var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,n||(n={}),!this._validate(i,n))return!1;var r=n.unset,o=n.silent,s=[],a=this._changing;this._changing=!0,a||(this._previousAttributes=ho(this.attributes),this.changed={});var l=this.attributes,c=this.changed,h=this._previousAttributes;for(var u in i)e=i[u],po(l[u],e)||s.push(u),po(h[u],e)?delete c[u]:c[u]=e,r?delete l[u]:l[u]=e;if(this.idAttribute in i){var d=this.id;this.id=this.get(this.idAttribute),this.trigger("changeId",this,d,n)}if(!o){s.length&&(this._pending=n);for(var f=0;f<s.length;f++)this.trigger("change:"+s[f],this,l[s[f]],n)}if(a)return this;if(!o)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);return this._pending=!1,this._changing=!1,this},unset:function(t,e){return this.set(t,void 0,io({},e,{unset:!0}))},clear:function(t){var e={};for(var n in this.attributes)e[n]=void 0;return this.set(e,io({},t,{unset:!0}))},hasChanged:function(t){return null==t?!fo(this.changed):To(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&ho(this.changed);var e,n=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var o=t[r];po(n[r],o)||(i[r]=o,e=!0)}return!!e&&i},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return ho(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},io({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=io({},this.attributes,t);var n=this.validationError=this.validate(t,e)||null;return!n||(this.trigger("invalid",this,n,io(e,{validationError:n})),!1)}}),ba.extend=ma;const xa=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce(((t,e)=>(t[e]=!0,t)),{}),Aa={qualify:function(t){return mo(t)},set:function(t,e,n){Object.keys(t).forEach((function(e){if(xa[e]&&e in n){const i=t[e];"SELECT"===n.tagName&&Array.isArray(i)?Array.from(n.options).forEach((function(t,e){t.selected=i.includes(t.value)})):n[e]=i}}))}};function Ta(t,e,n){return function(i,r){var o,s=Ys(i);if(i=parseFloat(i),s&&(i/=100),isFinite(i)){var a=r[n]();o=s||i>0&&i<1?a[t]+r[e]*i:a[t]+i}var l=Jt();return l[t]=o||0,l}}function Ea(t,e){return function(n,i){var r=Ys(n);n=parseFloat(n),r&&(n/=100);var o={};if(isFinite(n)){var s=r||n>=0&&n<=1?n*i[e]:Math.max(n+i[e],0);o[t]=s}return o}}const Sa={"ref-x":{position:Ta("x","width","origin")},"ref-y":{position:Ta("y","height","origin")},"ref-dx":{position:Ta("x","width","corner")},"ref-dy":{position:Ta("y","height","corner")},"ref-width":{set:Ea("width","width")},"ref-height":{set:Ea("height","height")},"ref-rx":{set:Ea("rx","width")},"ref-ry":{set:Ea("ry","height")},"ref-cx":{set:Ea("cx","width")},"ref-cy":{set:Ea("cy","height")},"ref-r-inscribed":{set:(Pa=Ea("r","width"),_a=Ea("r","height"),function(t,e){return(e.height>e.width?Pa:_a)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n=Ys(t);t=parseFloat(t),n&&(t/=100);var i,r=Math.sqrt(e.height*e.height+e.width*e.width);return isFinite(t)&&(i=n||t>=0&&t<=1?t*r:Math.max(t+r,0)),{r:i}}}};var Pa,_a;Sa.refX=Sa["ref-x"],Sa.refY=Sa["ref-y"],Sa["ref-x2"]=Sa["ref-x"],Sa["ref-y2"]=Sa["ref-y"],Sa["ref-width2"]=Sa["ref-width"],Sa["ref-height2"]=Sa["ref-height"],Sa["ref-r"]=Sa["ref-r-inscribed"];const ka=Sa,La={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},Ca=Object.keys(La).map((t=>La[t])).join(""),Ma="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",Oa=/\s/g,Na=new RegExp(`^(${Ma}\\*)?([${Ca}])(/${Ma})?([-+]{1,2}${Ma})?$`,"g");function Ra(t){throw new Error(`Invalid calc() expression: ${t}`)}function Fa(t,e){const n=Na.exec(t.replace(Oa,""));n||Ra(t),Na.lastIndex=0;const[,i,r,o,s]=n,{x:a,y:l,width:c,height:h}=e;let u=0;switch(r){case La.width:u=c;break;case La.height:u=h;break;case La.x:u=a;break;case La.y:u=l;break;case La.minimum:u=Math.min(h,c);break;case La.maximum:u=Math.max(h,c);break;case La.diagonal:u=Math.sqrt(h*h+c*c)}return i&&(u*=parseFloat(i)),o&&(u/=parseFloat(o.slice(1))),s&&(u+=function(t){if(!t)return 0;const[e]=t;switch(e){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)}(s)),u}function Ba(t){return"string"==typeof t&&t.includes("calc")}const Ia="calc(",Da=Ia.length;function Va(t,e){let n=t,i=0;for(;;){let t=n.indexOf(Ia,i);if(-1===t)return n;let r=t+Da,o=1;t:for(;;){switch(n[r]){case"(":o++;break;case")":if(o--,0===o)break t;break;case void 0:Ra(n)}r++}let s=n.slice(t+Da,r);Ba(s)&&(s=Va(s,e));const a=String(Fa(s,e));n=n.slice(0,t)+a+n.slice(r+1),i=t+a.length}}function za(t,e,n){return void 0!==n.text}const ja={"line-height":{qualify:za},"text-vertical-anchor":{qualify:za},"text-path":{qualify:za},annotations:{qualify:za},eol:{qualify:za},"display-empty":{qualify:za},text:{qualify:function(t,e,n){const i=n["text-wrap"];return!i||!mo(i)},set:function(t,e,n,i){const r="joint-text",o=Rs.data.get(n,r),s=i["line-height"],a=i["text-vertical-anchor"],l=i["display-empty"],c=i["font-size"],h=i.annotations,u=i.eol,d=i.x;let f=i["text-path"];const p=JSON.stringify([t,s,h,a,u,l,f,d,c]);if(void 0===o||o!==p){if(c&&n.setAttribute("font-size",c),to(f)){const t=f.selector;if("string"==typeof t){const e=this.findNode(t);e instanceof SVGPathElement&&(f=io({"xlink:href":"#"+e.id},f))}}An(n).text(""+t,{lineHeight:s,annotations:h,textPath:f,x:d,textVerticalAnchor:a,eol:u,displayEmpty:l}),Rs.data.set(n,r,p)}}},"text-wrap":{qualify:mo,set:function(t,e,n,i){var r={},o=t.width||0;Ys(o)?r.width=e.width*parseFloat(o)/100:Ba(o)?r.width=Number(Va(o,e)):null===t.width?r.width=1/0:r.width=o<=0?e.width+o:o;var s,a=t.height||0;Ys(a)?r.height=e.height*parseFloat(a)/100:Ba(a)?r.height=Number(Va(a,e)):null===t.height||(r.height=a<=0?e.height+a:a);var l=t.text;if(void 0===l&&(l=i.text),void 0!==l){const e=t.breakText||Js,o=getComputedStyle(n);s=e(""+l,r,{"font-weight":o.fontWeight,"font-family":o.fontFamily,"text-transform":o.textTransform,"font-size":o.fontSize,"letter-spacing":o.letterSpacing,lineHeight:i["line-height"]},{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,separator:t.separator,maxLineCount:t.maxLineCount,preserveSpaces:t.preserveSpaces})}else s="";ja.text.set.call(this,s,e,n,i)}},title:{qualify:function(t,e){return e instanceof SVGElement},set:function(t,e,n){var i="joint-title",r=Rs.data.get(n,i);if(void 0===r||r!==t){if(Rs.data.set(n,i,t),"title"===n.tagName)return void(n.textContent=t);var o=n.firstElementChild;if(o&&"title"===o.tagName)o.textContent=t;else{var s=document.createElementNS(n.namespaceURI,"title");s.textContent=t,n.insertBefore(s,o)}}}}},$a=ja;function Ua(t,e){var n=new Jt(1,0);return function(i){var r,o,s=this[t](i);return s?(o=e.rotate?s.vector().vectorAngle(n):0,r=s.start):(r=this.path.start,o=0),0===o?{transform:"translate("+r.x+","+r.y+")"}:{transform:"translate("+r.x+","+r.y+") rotate("+o+")"}}}function Ga(){return this.model.isLink()}const qa={connection:{qualify:Ga,set:function({stubs:t=0}){let e;if(isFinite(t)&&0!==t){let n;n=t<0?(this.getConnectionLength()+t)/2:t;const i=this.getConnection(),r=this.getConnectionSubdivisions(),o=i.divideAtLength(n,{segmentSubdivisions:r}),s=i.divideAtLength(-n,{segmentSubdivisions:r});o&&s&&(e=`${o[0].serialize()} ${s[1].serialize()}`)}return{d:e||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:Ga,set:Ua("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:Ga,set:Ua("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:Ga,set:Ua("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:Ga,set:Ua("getTangentAtRatio",{rotate:!1})}};qa["at-connection-length"]=qa["at-connection-length-keep-gradient"],qa["at-connection-ratio"]=qa["at-connection-ratio-keep-gradient"];const Ha=qa;function Wa(t,e){var n="joint-shape",i=e&&e.resetOffset;return function(e,r,o){var s=Rs.data.get(o,n);if(!s||s.value!==e){var a=t(e);s={value:e,shape:a,shapeBBox:a.bbox()},Rs.data.set(o,n,s)}var l=s.shape.clone(),c=s.shapeBBox.clone(),h=c.origin(),u=r.origin();c.x=u.x,c.y=u.y;var d=r.maxRectScaleToFit(c,u),f=0===c.width||0===r.width?1:d.sx,p=0===c.height||0===r.height?1:d.sy;return l.scale(f,p,h),i&&l.translate(-h.x,-h.y),l}}function Ya(t){var e=Wa((function(t){return new Le(An.normalizePathData(t))}),t);return function(t,n,i){return{d:e(t,n,i).serialize()}}}function Xa(t){var e=Wa(xe,t);return function(t,n,i){return{points:e(t,n,i).serialize()}}}const Za={"ref-d-reset-offset":{set:Ya({resetOffset:!0})},"ref-d-keep-offset":{set:Ya({resetOffset:!1})},"ref-points-reset-offset":{set:Xa({resetOffset:!0})},"ref-points-keep-offset":{set:Xa({resetOffset:!1})}};Za["ref-d"]=Za["ref-d-reset-offset"],Za["ref-points"]=Za["ref-points-reset-offset"];const Ka=Za;function Ja(t){var e={},n=t.stroke;"string"==typeof n&&(e.stroke=n,e.fill=n);var i=t["stroke-opacity"];return void 0===i&&(i=t.opacity),void 0!==i&&(e["stroke-opacity"]=i,e["fill-opacity"]=i),e}function Qa(t){const{paper:e}=this;return`url(#${"pattern"===t.type?e.definePattern(t):e.defineGradient(t)})`}const tl={"source-marker":{qualify:mo,set:function(t,e,n,i){return t=io(Ja(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:mo,set:function(t,e,n,i){return t=io(Ja(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:mo,set:function(t,e,n,i){return t=io(Ja(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:mo,set:Qa},stroke:{qualify:mo,set:Qa},filter:{qualify:mo,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}};function el(t,e,n){return function(i,r){var o;o="middle"===i?r[e]/2:i===n?r[e]:isFinite(i)?i>-1&&i<1?-r[e]*i:-i:Ys(i)?r[e]*parseFloat(i)/100:0;var s=new Jt;return s[t]=-(r[t]+o),s}}const nl={"x-alignment":{offset:el("x","width","right")},"y-alignment":{offset:el("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}};function il(t){return function(e,n,i){const r=An(i);r.attr(t)!==e&&r.attr(t,e)}}const rl={ref:{},href:{set:il("href")},"xlink:href":{set:il("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:mo,set:function(t,e,n){Rs(n).css(t)}},html:{set:function(t,e,n){Rs(n).html(t+"")}},props:Aa};io(rl,ka),io(rl,$a),io(rl,Ha),io(rl,Ka),io(rl,tl),io(rl,nl);const ol=rl,sl=function(t,e){if(Array.isArray(t))return e},al=ba.extend({constructor:function(t,e){var n,i=t||{};if("function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=Co("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(i=this.parse(i,e)||{}),n=Eo(this,"defaults")){const t=(!e||!0!==e.mergeArrays)&&sl;i=Mo({},n,i,t)}this.set(i,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(){const t=Eo(this.constructor.prototype,"defaults").attrs||{},e=this.attributes.attrs,n={};_o(e,(function(e,i){const r=t[i];_o(e,(function(t,e){to(t)&&!Array.isArray(t)?_o(t,(function(t,o){r&&r[e]&&po(r[e][o],t)||(n[i]=n[i]||{},(n[i][e]||(n[i][e]={}))[o]=t)})):r&&po(r[e],t)||(n[i]=n[i]||{},n[i][e]=t)}))}));const i=uo(So(this.attributes,"attrs"));return i.attrs=n,i},initialize:function(t){const e=this.getIdAttribute();t&&void 0!==t[e]||this.set(e,this.generateId(),{silent:!0}),this._transitionIds={},this._scheduledTransitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},getIdAttribute:function(){return this.idAttribute||"id"},generateId:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))},processPorts:function(){var t=this.ports,e={};_o(this.get("attrs"),(function(t,n){t&&t.port&&(void 0!==t.port.id?e[t.port.id]=t.port:e[t.port]={id:t.port})}));var n={};_o(t,(function(t,i){e[i]||(n[i]=!0)})),this.graph&&!fo(n)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach((function(t){n[t.get("target").port]&&t.remove()})),this.graph.getConnectedLinks(this,{outbound:!0}).forEach((function(t){n[t.get("source").port]&&t.remove()}))),this.ports=e},remove:function(t={}){const{graph:e,collection:n}=this;if(!e)return n&&n.remove(this,t),this;e.startBatch("remove");const i=this.getParentCell();i&&i.unembed(this,t);const r=this.getEmbeddedCells();for(let e=0,n=r.length;e<n;e++){const n=r[e];n&&n.remove(t)}return this.trigger("remove",this,e.attributes.cells,t),e.stopBatch("remove"),this},toFront:function(t){var e=this.graph;if(e){let n;(t=ro(t||{},{foregroundEmbeds:!0})).deep?(n=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==t.breadthFirst,sortSiblings:t.foregroundEmbeds}),n.unshift(this)):n=[this];const i=t.foregroundEmbeds?n:yo(n,(t=>t.z()));let r=e.maxZIndex()-n.length+1;const o=e.get("cells");let s=o.toArray().indexOf(i[0])!==o.length-n.length;s||(s=i.some((function(t,e){return t.z()!==r+e}))),s&&(this.startBatch("to-front"),r+=n.length,i.forEach((function(e,n){e.set("z",r+n,t)})),this.stopBatch("to-front"))}return this},toBack:function(t){var e=this.graph;if(e){let n;(t=ro(t||{},{foregroundEmbeds:!0})).deep?(n=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==t.breadthFirst,sortSiblings:t.foregroundEmbeds}),n.unshift(this)):n=[this];const i=t.foregroundEmbeds?n:yo(n,(t=>t.z()));let r=e.minZIndex(),o=0!==e.get("cells").toArray().indexOf(i[0]);o||(o=i.some((function(t,e){return t.z()!==r+e}))),o&&(this.startBatch("to-back"),r-=n.length,i.forEach((function(e,n){e.set("z",r+n,t)})),this.stopBatch("to-back"))}return this},parent:function(t,e){return void 0===t?this.get("parent"):this.set("parent",t,e)},embed:function(t,e){const n=Array.isArray(t)?t:[t];if(!this.canEmbed(n))throw new Error("Recursive embedding not allowed.");if(n.some((t=>t.isEmbedded()&&this.id!==t.parent())))throw new Error("Embedding of already embedded cells is not allowed.");return this._embedCells(n,e),this},unembed:function(t,e){const n=Array.isArray(t)?t:[t];return this._unembedCells(n,e),this},canEmbed:function(t){return(Array.isArray(t)?t:[t]).every((t=>this!==t&&!this.isEmbeddedIn(t)))},_embedCells:function(t,e){const n="embed";this.startBatch(n);const i=io([],this.get("embeds"));t.forEach((t=>{i[t.isLink()?"unshift":"push"](t.id),t.parent(this.id,e)})),this.set("embeds",co(i),e),this.stopBatch(n)},_unembedCells:function(t,e){const n="unembed";this.startBatch(n),t.forEach((t=>t.unset("parent",e))),this.set("embeds",wo(this.get("embeds"),...t.map((t=>t.id))),e),this.stopBatch(n)},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(!this.graph)return t;for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(t=t||{},!this.graph)return[];if(t.deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);const e=this.get("embeds");if(fo(e))return[];let n=e.map(this.graph.getCell,this.graph);return t.sortSiblings&&(n=yo(n,(t=>t.z()))),n},_getEmbeddedCellsBfs:function(t){const e=[],n=[];for(n.push(this);n.length>0;){const i=n.shift();e.push(i);const r=i.getEmbeddedCells({sortSiblings:t});n.push(...r)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){const e=[],n=[];for(n.push(this);n.length>0;){const i=n.pop();e.push(i);const r=i.getEmbeddedCells({sortSiblings:t});for(let t=r.length-1;t>=0;--t)n.push(r[t])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=no(t)?t:t.id,i=this.parent();if(e=io({deep:!0},e),this.graph&&e.deep){for(;i;){if(i===n)return!0;i=this.graph.getCell(i).parent()}return!1}return i===n},isEmbedded:function(){return!!this.parent()},clone:function(t){if((t=t||{}).deep)return vo(wa([this].concat(this.getEmbeddedCells({deep:!0}))));var e=ba.prototype.clone.apply(this,arguments);return e.set(this.getIdAttribute(),this.generateId()),e.unset("embeds"),e.unset("parent"),e},prop:function(t,e,n){var i=no(t);if(i||Array.isArray(t)){if(arguments.length>1){var r,o;i?o=(r=t).split("/"):(r=t.join("/"),o=t.slice());var s=o[0],a=o.length;const m=n||{};m.propertyPath=r,m.propertyValue=e,m.propertyPathArray=o,"rewrite"in m||(m.rewrite=!1);for(var l={},c=l,h=s,u=1;u<a;u++){var d=o[u],f=Number.isFinite(i?Number(d):d);c=c[h]=f?[]:{},h=d}l=zs(l,o,e,"/");var p=Mo({},this.attributes);m.rewrite&&js(p,r,"/");var g=Mo(p,l);return this.set(s,g[s],m)}return Ds(this.attributes,t,"/")}const m=e||{};m.propertyPath=null,m.propertyValue=t,m.propertyPathArray=[],"rewrite"in m||(m.rewrite=!1);const v={};for(const e in t){const{changedValue:n}=Mo({},{changedValue:this.attributes[e]},{changedValue:t[e]});v[e]=n}return this.set(v,m)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];if("attrs"===i&&(e.dirty=!0),1===n.length)return this.unset(t,e);var r=n.slice(1),o=this.get(i);return null==o?this:(o=uo(o),js(o,r,"/"),this.set(i,o,e))},attr:function(t,e,n){var i=Array.from(arguments);return 0===i.length?this.get("attrs"):(Array.isArray(t)?i[0]=["attrs"].concat(t):no(t)?i[0]="attrs/"+t:i[0]={attrs:t},this.prop.apply(this,i))},removeAttr:function(t,e){return Array.isArray(t)?this.removeProp(["attrs"].concat(t)):this.removeProp("attrs/"+t,e)},transition:function(t,e,n,i){i=i||"/",n=io({duration:100,delay:10,timingFunction:ta.linear,valueFunction:ea.number},n);var r,o=0,s=function(e){var i,a,l;(a=(e-=o=o||e)/n.duration)<1?this._transitionIds[t]=i=Gs(s):(a=1,delete this._transitionIds[t]),l=r(n.timingFunction(a)),n.transitionId=i,this.prop(t,l,n),i||this.trigger("transition:end",this,t)}.bind(this);const{_scheduledTransitionIds:a}=this;let l;return l=setTimeout((o=>{a[t]&&(a[t]=wo(a[t],l),0===a[t].length&&delete a[t]),this.stopPendingTransitions(t,i),r=n.valueFunction(Ds(this.attributes,t,i),e),this._transitionIds[t]=Gs(o),this.trigger("transition:start",this,t)}),n.delay,s),a[t]||(a[t]=[]),a[t].push(l),l},getTransitions:function(){return Ao(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,e="/"){const{_scheduledTransitionIds:n={}}=this;let i=Object.keys(n);if(t){const n=t.split(e);i=i.filter((t=>po(n,t.split(e).slice(0,n.length))))}return i.forEach((t=>{n[t].forEach((t=>clearTimeout(t))),delete n[t]})),this},stopPendingTransitions(t,e="/"){const{_transitionIds:n={}}=this;let i=Object.keys(n);if(t){const n=t.split(e);i=i.filter((t=>po(n,t.split(e).slice(0,n.length))))}i.forEach((t=>{const e=n[t];qs(e),delete n[t],this.trigger("transition:end",this,t)}))},stopTransitions:function(t,e="/"){return this.stopScheduledTransitions(t,e),this.stopPendingTransitions(t,e),this},addTo:function(t,e){return t.addCell(this,e),this},findView:function(t){return t.findViewByModel(this)},isElement:function(){return!1},isLink:function(){return!1},startBatch:function(t,e){return this.graph&&this.graph.startBatch(t,io({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,io({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(!t)return e;for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new Jt(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new Jt},getBBox:function(){return new me(0,0,0,0)},getPointRotatedAroundCenter(t,e,n){const i=new Jt(e,n);return t&&i.rotate(this.getBBox().center(),t),i},getAbsolutePointFromRelative(t,e){return this.getPointRotatedAroundCenter(-this.angle(),this.position().offset(t,e))},getRelativePointFromAbsolute(t,e){return this.getPointRotatedAroundCenter(this.angle(),t,e).difference(this.position())}},{getAttributeDefinition:function(t){var e=this.attributes,n=ol;return e&&e[t]||n[t]},define:function(t,e,n,i){n=io({defaults:oo({type:t},e,this.prototype.defaults)},n);var r=this.extend(n,i);return"undefined"!=typeof joint&&To(joint,"shapes")&&zs(joint.shapes,t,r,"."),r}});function ll(t,e,n){var i=t.toJSON();return i.angle=e||0,ro({},n,i)}function cl(t,e,n,i){return t.map((function(t,e,n){var r=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&r.offset(t.dx||0,t.dy||0),ll(r.round(),0,ul(i,t))}),ie(e,n))}function hl(t,e,n,i){var r=e.center(),o=e.width/e.height,s=e.topMiddle(),a=ae.fromRect(e);return t.map((function(t,l,c){var h=n+i(l,c.length),u=s.clone().rotate(r,-h).scale(o,1,r),d=t.compensateRotation?-a.tangentTheta(u):0;return(t.dx||t.dy)&&u.offset(t.dx||0,t.dy||0),t.dr&&u.move(r,t.dr),ll(u.round(),d,ul(e,t))}))}function ul(t,e){let{x:n,y:i,angle:r}=e;return Ys(n)?n=parseFloat(n)/100*t.width:Ba(n)&&(n=Number(Va(n,t))),Ys(i)?i=parseFloat(i)/100*t.height:Ba(i)&&(i=Number(Va(i,t))),{x:n,y:i,angle:r}}function dl(t,e){const{x:n,y:i}=ul(t,e);return new Jt(n||0,i||0)}const fl=function(t,e){return t.map((t=>{const n=dl(e,t).round().toJSON();return n.angle=t.angle||0,n}))},pl=function(t,e,n){return n.fn(t,e,n)},gl=function(t,e,n){return cl(t,dl(e,n.start||e.origin()),dl(e,n.end||e.corner()),e)},ml=function(t,e,n){return cl(t,e.origin(),e.bottomLeft(),e)},vl=function(t,e,n){return cl(t,e.topRight(),e.corner(),e)},yl=function(t,e,n){return cl(t,e.origin(),e.topRight(),e)},bl=function(t,e,n){return cl(t,e.bottomLeft(),e.corner(),e)},wl=function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return hl(t,e,i,(function(t){return t*r}))},xl=function(t,e,n){var i=n.startAngle||0,r=n.step||20;return hl(t,e,i,(function(t,e){return(t+.5-e/2)*r}))};function Al(t,e){return oo({},t,e,{x:0,y:0,angle:0,attrs:{}})}function Tl(t){var e=t.center(),n=e.theta(t.origin()),i=e.theta(t.bottomLeft()),r=e.theta(t.corner());return[n,e.theta(t.topRight()),r,i]}function El(t,e,n,i){i=ro({},i,{offset:15});var r,o,s,a,l=e.center().theta(t),c=i.offset,h=0;const[u,d,f,p]=Tl(e);l<d||l>f?(s=".3em",r=c,o=0,a="start"):l<u?(r=0,o=-c,n?(h=-90,a="start",s=".3em"):(a="middle",s="0")):l<p?(s=".3em",r=-c,o=0,a="end"):(r=0,o=c,n?(h=90,a="start",s=".3em"):(a="middle",s=".6em"));var g=Math.round;return Al(i,{x:g(r),y:g(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Sl(t,e,n,i){i=ro({},i,{offset:15});var r,o,s,a,l=e.center().theta(t),c=i.offset,h=0;const[u,d,f,p]=Tl(e);l<d||l>f?(s=".3em",r=-c,o=0,a="end"):l<u?(r=0,o=c,n?(h=90,a="start",s=".3em"):(a="middle",s=".6em")):l<p?(s=".3em",r=c,o=0,a="start"):(r=0,o=-c,n?(h=-90,a="start",s=".3em"):(a="middle",s="0"));var g=Math.round;return Al(i,{x:g(r),y:g(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Pl(t,e,n){n=ro({},n,{offset:20});var i,r=Qt(0,0),o=-t.theta(r),s=o,a=t.clone().move(r,n.offset).difference(t).round(),l=".3em";(o+90)%180==0?(i=e?"end":"middle",e||-270!==o||(l="0em")):o>-270&&o<-90?(i="start",s=o-180):i="end";var c=Math.round;return Al(n,{x:c(a.x),y:c(a.y),angle:e?s:0,attrs:{labelText:{y:l,textAnchor:i}}})}const _l=function(t,e,n){return Al(n)},kl=function(t,e,n){return Al(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},Ll=function(t,e,n){return Al(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},Cl=function(t,e,n){return Al(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})},Ml=function(t,e,n){return Al(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},Ol=function(t,e,n){return El(t,e,!0,n)},Nl=function(t,e,n){return El(t,e,!1,n)},Rl=function(t,e,n){return Sl(t,e,!0,n)},Fl=function(t,e,n){return Sl(t,e,!1,n)},Bl=function(t,e,n){return Pl(t.difference(e.center()),!1,n)},Il=function(t,e,n){return Pl(t.difference(e.center()),!0,n)};var Dl=function(t){var e=uo(t)||{};this.ports=[],this.groups={},this.portLayoutNamespace=s,this.portLabelLayoutNamespace=a,this._init(e)};Dl.prototype={getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(t){return this.ports.filter((function(e){return e.group===t}))},getGroupPortsMetrics:function(t,e){var n=this.getGroup(t),i=this.getPortsByGroup(t),r=n.position||{},o=r.name,s=this.portLayoutNamespace;s[o]||(o="left");var a=r.args||{},l=i.map((function(t){return t&&t.position&&t.position.args})),c=s[o](l,e,a),h={ports:i,result:[]};return vo(c).reduce(function(t,n,i){var r=t.ports[i];return t.result.push({portId:r.id,portTransformation:n,labelTransformation:this._getPortLabelLayout(r,Jt(n),e),portAttrs:r.attrs,portSize:r.size,labelSize:r.label.size}),t}.bind(this),h),h.result},_getPortLabelLayout:function(t,e,n){var i=this.portLabelLayoutNamespace,r=t.label.position.name||"left";return i[r]?i[r](e,n,t.label.position.args):null},_init:function(t){if(to(t.groups))for(var e=Object.keys(t.groups),n=0,i=e.length;n<i;n++){var r=e[n];this.groups[r]=this._evaluateGroup(t.groups[r])}for(var o=vo(t.items),s=0,a=o.length;s<a;s++)this.ports.push(this._evaluatePort(o[s]))},_evaluateGroup:function(t){return Mo(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=io({},t),n=this.getGroup(t.group);return e.markup=e.markup||n.markup,e.attrs=Mo({},n.attrs,e.attrs),e.position=this._createPositionNode(n,e),e.label=Mo({},n.label,this._getLabel(e)),e.z=this._getZIndex(n,e),e.size=io({},n.size,e.size),e},_getZIndex:function(t,e){return eo(e.z)?e.z:eo(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return Mo({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var n,i={};go(t)?(n="fn",i.fn=t):no(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):to(t)&&(n=t.name,io(i,t.args));var r={args:i};return n&&(r.name=n),r},_getLabel:function(t,e){var n=t.label||{},i=n;return i.position=this._getPosition(n.position,e),i}};const Vl={_initializePorts:function(){this._createPortData(),this.on("change:ports",(function(){this._processRemovedPort(),this._createPortData()}),this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={};vo(t.items).forEach((function(t){e[t.id]=!0}));var n=this.previous("ports")||{},i={};vo(n.items).forEach((function(t){e[t.id]||(i[t.id]=!0)}));var r=this.graph;r&&!fo(i)&&(r.getConnectedLinks(this,{inbound:!0}).forEach((function(t){i[t.get("target").port]&&t.remove()})),r.getConnectedLinks(this,{outbound:!0}).forEach((function(t){i[t.get("source").port]&&t.remove()})))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&t.length>0},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return uo(this.prop("ports/items"))||[]},getGroupPorts:function(t){const e=vo(this.prop(["ports","items"])).filter((e=>e.group===t));return uo(e)},getPort:function(t){return uo(vo(this.prop("ports/items")).find((function(e){return e.id&&e.id===t})))},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,me(this.size())).reduce((function(t,e){var n=e.portTransformation;return t[e.portId]={x:n.x,y:n.y,angle:n.angle},t}),{})},getPortIndex:function(t){var e=to(t)?t.id:t;return this._isValidPortId(e)?vo(this.prop("ports/items")).findIndex((function(t){return t.id===e})):-1},addPort:function(t,e){if(!to(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=io([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){const i="number"==typeof t?t:this.getPortIndex(t);if(!to(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");const r=io([],this.prop("ports/items"));return r.splice(i,0,e),this.prop("ports/items",r,n),this},portProp:function(t,e,n,i){var r=this.getPortIndex(t);if(-1===r)throw new Error("Element: unable to find port with id "+t);var o=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?o[0]=["ports","items",r].concat(e):no(e)?o[0]=["ports/items/",r,"/",e].join(""):(o=["ports/items/"+r],mo(e)&&(o.push(e),o.push(n))),this.prop.apply(this,o)},_validatePorts:function(){var t=this.get("ports")||{},e=[],n=vo((t=t||{}).items);return n.forEach((function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())}),this),co(n,"id").length!==n.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!to(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",io([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){const n=e||{},i=this.getPortIndex(t);if(-1!==i){const t=io([],this.prop(["ports","items"]));t.splice(i,1),n.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],t,n),this.stopBatch("port-remove")}return this},removePorts:function(t,e){let n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;i=io([],this.prop(["ports","items"])).filter((function(e){return!t.some((function(t){const n=to(t)?t.id:t;return e.id===n}))}))}else n=t||{},i=[];return this.startBatch("port-remove"),n.rewrite=!0,this.prop(["ports","items"],i,n),this.stopBatch("port-remove"),this},_createPortData:function(){var t,e=this._validatePorts();if(e.length>0)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new Dl(this.get("ports"));var n=this._portSettingsData.getPorts();if(t){var i=n.filter((function(e){if(!t.find((function(t){return t.id===e.id})))return e})),r=t.filter((function(t){if(!n.find((function(e){return e.id===t.id})))return t}));r.length>0&&this.trigger("ports:remove",this,r),i.length>0&&this.trigger("ports:add",this,i)}}},zl={portContainerMarkup:"g",portMarkup:[{tagName:"circle",selector:"circle",attributes:{r:10,fill:"#FFFFFF",stroke:"#000000"}}],portLabelMarkup:[{tagName:"text",selector:"text",attributes:{fill:"#000000"}}],_portElementsCache:null,_initializePorts:function(){this._cleanPortsCache()},_refreshPorts:function(){this._removePorts(),this._cleanPortsCache(),this._renderPorts()},_cleanPortsCache:function(){this._portElementsCache={}},_renderPorts:function(){for(var t=[],e=this._getContainerElement(),n=0,i=e.node.childNodes.length;n<i;n++)t.push(e.node.childNodes[n]);var r,o,s=(r=this.model._portSettingsData.getPorts(),o=zr(o="z",2),function(t,e,n){return(Array.isArray(t)?jr:$r)(t,e,n,arguments.length<3,Mr)}(r,((t,e,n)=>(n=o(e),hasOwnProperty.call(t,n)?t[n].push(e):$i(t,n,[e]),t)),{})),a="auto";vo(s[a]).forEach((function(n){var i=this._getPortElement(n);e.append(i),t.push(i)}),this);for(var l=Object.keys(s),c=0;c<l.length;c++){var h=l[c];if(h!==a){var u=parseInt(h,10);this._appendPorts(s[h],u,t)}}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),r=vo(t).map(this._getPortElement,this);n[e]||e<0?An(n[Math.max(e,0)]).before(r):i.append(r)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){const n=this._portElementsCache[t];if(!n)return[];if(!e)return[n.portContentElement.node];const i=n.portElement.node,r=n.portSelectors;return this.findBySelector(e,i,r)},findPortNode:function(t,e){const[n=null]=this.findPortNodes(t,e);return n},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){so(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){let e,n,i,r;var o=An(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t);if(Array.isArray(s)){var a=this.parseDOMJSON(s,o.node),l=a.fragment;e=l.childNodes.length>1?An("g").append(l):An(l.firstChild),r=a.selectors}else e=An(s),Array.isArray(e)&&(e=An("g").append(e));if(!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group});const c=this._getPortLabelMarkup(t.label);if(Array.isArray(c)){const{fragment:t,selectors:e}=this.parseDOMJSON(c,o.node),r=t.childNodes.length;r>0&&(i=e,n=1===r?An(t.firstChild):An("g").append(t))}else n=An(c),Array.isArray(n)&&(n=An("g").append(n));var h;if(r&&i){for(var u in i)if(r[u]&&u!==this.selector)throw new Error("ElementView: selectors within port must be unique.");h=io({},r,i)}else h=r||i||{};const d="portRoot",f="labelRoot",p="labelText";if(d in h||(h[d]=e.node),n){const t=n.node;if(f in h||(h[f]=t),!(p in h)){const e="TEXT"===n.tagName()?t:Array.from(t.querySelectorAll("text"));h[p]=e,i||(i={}),i[p]=e}}return o.append(e.addClass("joint-port-body")),n&&o.append(n.addClass("joint-port-label")),this._portElementsCache[t.id]={portElement:o,portLabelElement:n,portSelectors:h,portLabelSelectors:i,portContentElement:e,portContentSelectors:r},o},_updatePortGroup:function(t){for(var e=me(this.model.size()),n=this.model._portSettingsData.getGroupPortsMetrics(t,e),i=0,r=n.length;i<r;i++){var o=n[i],s=o.portId,a=this._portElementsCache[s]||{},l=o.portTransformation,c=o.labelTransformation;c&&a.portLabelElement&&(this.updateDOMSubtreeAttributes(a.portLabelElement.node,c.attrs,{rootBBox:new me(o.labelSize),selectors:a.portLabelSelectors}),this.applyPortTransform(a.portLabelElement,c,-l.angle||0)),this.updateDOMSubtreeAttributes(a.portElement.node,o.portAttrs,{rootBBox:new me(o.portSize),selectors:a.portSelectors}),this.applyPortTransform(a.portElement,l)}},applyPortTransform:function(t,e,n){var i=An.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(i,{absolute:!0})},_getPortMarkup:function(t){return t.markup||this.model.get("portMarkup")||this.model.portMarkup||this.portMarkup},_getPortLabelMarkup:function(t){return t.markup||this.model.get("portLabelMarkup")||this.model.portLabelMarkup||this.portLabelMarkup}},jl=al.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),al.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){const i=eo(e);n=(i?n:t)||{};const{parentRelative:r,deep:o,restrictedArea:s}=n;let a;if(r){if(!this.graph)throw new Error("Element must be part of a graph.");const t=this.getParentCell();t&&!t.isLink()&&(a=t.get("position"))}if(i){if(a&&(t+=a.x,e+=a.y),o||s){const{x:i,y:r}=this.get("position");this.translate(t-i,e-r,n)}else this.set("position",{x:t,y:e},n);return this}{const t=Jt(this.get("position"));return r?t.difference(a):t}},translate:function(t,e,n){if(e=e||0,0===(t=t||0)&&0===e)return this;(n=n||{}).translateBy=n.translateBy||this.id;var i=this.get("position")||{x:0,y:0},r=n.restrictedArea;if(r&&n.translateBy===this.id)if("function"==typeof r){var o=r.call(this,i.x+t,i.y+e,n);t=o.x-i.x,e=o.y-i.y}else{var s=this.getBBox({deep:!0}),a=i.x-s.x,l=i.y-s.y,c=Math.max(r.x+a,Math.min(r.x+r.width+a-s.width,i.x+t)),h=Math.max(r.y+l,Math.min(r.y+r.height+l-s.height,i.y+e));t=c-i.x,e=h-i.y}var u={x:i.x+t,y:i.y+e};return n.tx=t,n.ty=e,n.transition?(to(n.transition)||(n.transition={}),this.transition("position",u,io({},n.transition,{valueFunction:ea.object})),so(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",u,n),so(this.getEmbeddedCells(),"translate",t,e,n),this.stopBatch("translate",n)),this},size:function(t,e,n){var i=this.get("size");return void 0===t?{width:i.width,height:i.height}:(to(t)&&(n=e,e=eo(t.height)?t.height:i.height,t=eo(t.width)?t.width:i.width),this.resize(t,e,n))},resize:function(t,e,n){if(n=n||{},this.startBatch("resize",n),n.direction){var i=this.get("size");switch(n.direction){case"left":case"right":e=i.height;break;case"top":case"bottom":t=i.width}var r,o=Ct(this.get("angle")||0),s=this.getBBox();if(o){var a={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction];n.absolute&&(a+=Math.floor((o+45)/90),a%=4);var l=s[["bottomLeft","corner","topRight","origin"][a]](),c=Jt(l).rotate(s.center(),-o),h=Math.sqrt(t*t+e*e)/2,u=a*Math.PI/2;u+=Math.atan(a%2==0?e/t:t/e),u-=Nt(o);var d=Jt.fromPolar(h,u,c);r=Jt(d).offset(t/-2,e/-2)}else switch(r=s.topLeft(),n.direction){case"top":case"top-right":r.offset(0,s.height-e);break;case"left":case"bottom-left":r.offset(s.width-t,0);break;case"top-left":r.offset(s.width-t,s.height-e)}this.set("size",{width:t,height:e},n),this.position(r.x,r.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){var r=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(r.x,r.y,i),this.resize(r.width,r.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(t={}){const{graph:e}=this;if(!e)throw new Error("Element must be part of a graph.");const n=this.getEmbeddedCells().filter((t=>t.isElement()));return 0===n.length||(this.startBatch("fit-embeds",t),t.deep&&so(n,"fitToChildren",t),this._fitToElements(Object.assign({elements:n},t)),this.stopBatch("fit-embeds")),this},fitParent:function(t={}){const{graph:e}=this;if(!e)throw new Error("Element must be part of a graph.");if(t.deep&&t.terminator&&(t.terminator===this||t.terminator===this.id))return this;const n=this.getParentCell();if(!n||!n.isElement())return this;const i=n.getEmbeddedCells().filter((t=>t.isElement()));return 0===i.length||(this.startBatch("fit-parent",t),n._fitToElements(Object.assign({elements:i},t)),t.deep&&n.fitParent(t),this.stopBatch("fit-parent")),this},_fitToElements:function(t={}){const e=this.graph.getCellsBBox(t.elements);if(!e)return;const{expandOnly:n,shrinkOnly:i}=t;if(n&&i)return;let{x:r,y:o,width:s,height:a}=e;const{left:l,right:c,top:h,bottom:u}=Qs(t.padding);r-=l,o-=h,s+=l+c,a+=u+h;let d=new me(r,o,s,a);if(n)d=this.getBBox().union(d);else if(i){const t=this.getBBox().intersect(d);if(!t)return;d=t}this.set({position:{x:d.x,y:d.y},size:{width:d.width,height:d.height}},t)},rotate:function(t,e,n,i){if(n){var r=this.getBBox().center(),o=this.get("size"),s=this.get("position");r.rotate(n,this.get("angle")-t);var a=r.x-o.width/2-s.x,l=r.y-o.height/2-s.y;this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(s.x+a,s.y+l,i),this.rotate(t,e,null,i),this.stopBatch("rotate")}else this.set("angle",e?t:(this.get("angle")+t)%360,i);return this},angle:function(){return Ct(this.get("angle")||0)},getBBox:function(t={}){const{graph:e,attributes:n}=this,{deep:i,rotate:r}=t;if(i&&e){const n=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return n.push(this),e.getCellsBBox(n,t)}const{angle:o=0,position:{x:s,y:a},size:{width:l,height:c}}=n,h=new me(s,a,l,c);return r&&h.rotateAroundCenter(o),h},getPointFromConnectedLink:function(t,e){var n=this.getBBox(),i=n.center(),r=t.get(e);if(!r)return i;var o=r.port;if(!o||!this.hasPort(o))return i;var s=this.portProp(o,["group"]),a=this.getPortsPositions(s),l=new Jt(a[o]).offset(n.origin()),c=this.angle();return c&&l.rotate(i,-c),l}});io(jl.prototype,Vl);const $l=al.extend({defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",textVerticalAnchor:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,x:"calc(x)",y:"calc(y)",width:"calc(w)",height:"calc(h)"}},position:{distance:.5}}},defaults:{source:{},target:{}},isLink:function(){return!0},disconnect:function(t){return this.set({source:{x:0,y:0},target:{x:0,y:0}},t)},source:function(t,e,n){return void 0===t?ho(this.get("source")):t instanceof al?((i=ho(e)||{}).id=t.id,r=n,this.set("source",i,r)):mo(t)?(i=t,r=e,this.set("source",i,r)):((i=ho(e)||{}).x=t.x,i.y=t.y,r=n,this.set("source",i,r));var i,r},target:function(t,e,n){return void 0===t?ho(this.get("target")):t instanceof al?((i=ho(e)||{}).id=t.id,r=n,this.set("target",i,r)):mo(t)?(i=t,r=e,this.set("target",i,r)):((i=ho(e)||{}).x=t.x,i.y=t.y,r=n,this.set("target",i,r));var i,r},router:function(t,e,n){if(void 0===t){var i=this.get("router");return i?"object"==typeof i?ho(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},s=r?e:n;return this.set("router",o,s)},connector:function(t,e,n){if(void 0===t){var i=this.get("connector");return i?"object"==typeof i?ho(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},s=r?e:n;return this.set("connector",o,s)},label:function(t,e,n){var i=this.labels();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1?this.prop(["labels",t]):this.prop(["labels",t],e,n)},labels:function(t,e){return 0===arguments.length?(t=this.get("labels"),Array.isArray(t)?t.slice():[]):(Array.isArray(t)||(t=[]),this.set("labels",t,e))},hasLabels:function(){const{labels:t}=this.attributes;return Array.isArray(t)&&t.length>0},insertLabel:function(t,e,n){if(!e)throw new Error("dia.Link: no label provided");var i=this.labels(),r=i.length;return(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),i.splice(t,0,e),this.labels(i,n)},appendLabel:function(t,e){return this.insertLabel(-1,t,e)},removeLabel:function(t,e){var n=this.labels();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.labels(n,e)},vertex:function(t,e,n){var i=this.vertices();if((t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1)return this.prop(["vertices",t]);var r=this._normalizeVertex(e);return this.prop(["vertices",t],r,n)},vertices:function(t,e){if(0===arguments.length)return t=this.get("vertices"),Array.isArray(t)?t.slice():[];Array.isArray(t)||(t=[]);for(var n=[],i=0;i<t.length;i++){var r=t[i],o=this._normalizeVertex(r);n.push(o)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){if(!e)throw new Error("dia.Link: no vertex provided");var i=this.vertices(),r=i.length;(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1);var o=this._normalizeVertex(e);return i.splice(t,0,o),this.vertices(i,n)},removeVertex:function(t,e){var n=this.vertices();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.vertices(n,e)},_normalizeVertex:function(t){return mo(t)?t:{x:t.x,y:t.y}},translate:function(t,e,n){return(n=n||{}).translateBy=n.translateBy||this.id,n.tx=t,n.ty=e,this.applyToPoints((function(n){return{x:(n.x||0)+t,y:(n.y||0)+e}}),n)},scale:function(t,e,n,i){return this.applyToPoints((function(i){return Jt(i).scale(t,e,n).toJSON()}),i)},applyToPoints:function(t,e){if(!go(t))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var n={},{source:i,target:r}=this.attributes;i.id||(n.source=t(i)),r.id||(n.target=t(r));var o=this.vertices();return o.length>0&&(n.vertices=o.map(t)),this.set(n,e)},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new Jt(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new Jt(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){const t=[this.getSourcePoint(),...this.vertices().map(Jt),this.getTargetPoint()];return new xe(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e;if(this.graph){var n=this.getSourceElement(),i=this.getTargetElement(),r=this.getParentCell();n&&i&&(e=n===i||n.isEmbeddedIn(i)?i:i.isEmbeddedIn(n)?n:this.graph.getCommonAncestor(n,i)),!r||e&&e.id===r.id||r.unembed(this,t),e&&e.embed(this,t)}return e},hasLoop:function(t){t=t||{};var{source:e,target:n}=this.attributes,i=e.id,r=n.id;if(!i||!r)return!1;var o=i===r;if(!o&&t.deep&&this.graph){var s=this.getSourceCell(),a=this.getTargetCell();o=s.isEmbeddedIn(a)||a.isEmbeddedIn(s)}return o},getSourceCell:function(){const{graph:t,attributes:e}=this;var n=e.source;return n&&n.id&&t&&t.getCell(n.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getSourceCell()}while(t&&t.isLink());return t},getTargetCell:function(){const{graph:t,attributes:e}=this;var n=e.target;return n&&n.id&&t&&t.getCell(n.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getTargetCell()}while(t&&t.isLink());return t},getRelationshipAncestor:function(){var t;if(this.graph){var e=[this,this.getSourceElement(),this.getTargetElement()].filter((function(t){return!!t}));t=this.graph.getCommonAncestor.apply(this.graph,e)}return t||null},isRelationshipEmbeddedIn:function(t){var e=no(t)||eo(t)?t:t.id,n=this.getRelationshipAncestor();return!!n&&(n.id===e||n.isEmbeddedIn(e))},_getDefaultLabel:function(){var t=this.get("defaultLabel")||this.defaultLabel||{},e={};return e.markup=t.markup||this.get("labelMarkup")||this.labelMarkup,e.position=t.position,e.attrs=t.attrs,e.size=t.size,e}},{endsEqual:function(t,e){var n=t.port===e.port||!t.port&&!e.port;return t.id===e.id&&n}}),Ul={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(t,e){return this._tests[t]=e},test:function(t){var e=this._tests[t];if(!e)throw new Error('Test not defined ("'+t+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var n=this._results[t];if(void 0!==n)return n;try{n=e()}catch(t){n=!1}return this._results[t]=n,n}},Gl=jl.define("standard.Rectangle",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}]}),ql=jl.define("standard.Circle",{attrs:{root:{cursor:"move"},body:{cx:"calc(s/2)",cy:"calc(s/2)",r:"calc(s/2)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"circle",selector:"body"},{tagName:"text",selector:"label"}]}),Hl=jl.define("standard.Ellipse",{attrs:{root:{cursor:"move"},body:{cx:"calc(w/2)",cy:"calc(h/2)",rx:"calc(w/2)",ry:"calc(h/2)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"body"},{tagName:"text",selector:"label"}]}),Wl=jl.define("standard.Path",{attrs:{root:{cursor:"move"},body:{d:"M 0 0 H calc(w) V calc(h) H 0 Z",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}]}),Yl=jl.define("standard.Polygon",{attrs:{root:{cursor:"move"},body:{points:"0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"}]}),Xl=jl.define("standard.Polyline",{attrs:{root:{cursor:"move"},body:{points:"0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polyline",selector:"body"},{tagName:"text",selector:"label"}]}),Zl=jl.define("standard.Image",{attrs:{root:{cursor:"move"},image:{width:"calc(w)",height:"calc(h)"},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Kl=jl.define("standard.BorderedImage",{attrs:{root:{cursor:"move"},border:{width:"calc(w)",height:"calc(h)",stroke:"#333333",strokeWidth:2},background:{width:"calc(w-1)",height:"calc(h-1)",x:.5,y:.5,fill:"#FFFFFF"},image:{width:"calc(w-1)",height:"calc(h-1)",x:.5,y:.5},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"background",attributes:{stroke:"none"}},{tagName:"image",selector:"image"},{tagName:"rect",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),Jl=jl.define("standard.EmbeddedImage",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",stroke:"#333333",fill:"#FFFFFF",strokeWidth:2},image:{width:"calc(0.3*w)",height:"calc(h-20)",x:10,y:10,preserveAspectRatio:"xMidYMin"},label:{textVerticalAnchor:"top",textAnchor:"left",x:"calc(0.3*w+20)",y:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Ql=jl.define("standard.InscribedImage",{attrs:{root:{cursor:"move"},border:{rx:"calc(w/2)",ry:"calc(h/2)",cx:"calc(w/2)",cy:"calc(h/2)",stroke:"#333333",strokeWidth:2},background:{rx:"calc(w/2)",ry:"calc(h/2)",cx:"calc(w/2)",cy:"calc(h/2)",fill:"#FFFFFF"},image:{width:"calc(0.68*w)",height:"calc(0.68*h)",x:"calc(0.16*w)",y:"calc(0.16*h)",preserveAspectRatio:"xMidYMid"},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"background"},{tagName:"image",selector:"image"},{tagName:"ellipse",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),tc=jl.define("standard.HeaderedRectangle",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},header:{width:"calc(w)",height:30,strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},headerText:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:15,fontSize:16,fill:"#333333"},bodyText:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerText"},{tagName:"text",selector:"bodyText"}]}),ec=jl.define("standard.Cylinder",{attrs:{root:{cursor:"move"},body:{lateralArea:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{cx:"calc(w/2)",cy:10,rx:"calc(w/2)",ry:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(t,e){if(void 0===t)return this.attr("body/lateralArea");var n={lateralArea:t},i=Ys(t)?`calc(${parseFloat(t)/100}*h)`:t,r={cy:i,ry:i};return this.attr({body:n,top:r},e)}},{attributes:{"lateral-area":{set:function(t,e){var n=Ys(t);n&&(t=parseFloat(t)/100);var i=e.x,r=e.y,o=e.width,s=e.height,a=o/2,l=n?s*t:t,c=An.KAPPA,h=c*a,u=c*(n?s*t:t),d=i+o/2,f=i+o,p=r+l,g=p-l,m=r+s-l,v=r+s;return{d:["M",i,p,"L",i,m,"C",i,m+u,d-h,v,d,v,"C",d+h,v,f,m+u,f,m,"L",f,p,"C",f,p-u,d+h,g,d,g,"C",d-h,g,i,p-u,i,p,"Z"].join(" ")}}}}});var nc=Ul.test("svgforeignobject")?{tagName:"foreignObject",selector:"foreignObject",attributes:{overflow:"hidden"},children:[{tagName:"div",namespaceURI:"http://www.w3.org/1999/xhtml",selector:"label",style:{width:"100%",height:"100%",position:"static",backgroundColor:"transparent",textAlign:"center",margin:0,padding:"0px 5px",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center"}}]}:{tagName:"text",selector:"label",attributes:{"text-anchor":"middle"}};const ic=jl.define("standard.TextBlock",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",stroke:"#333333",fill:"#ffffff",strokeWidth:2},foreignObject:{width:"calc(w)",height:"calc(h)"},label:{style:{fontSize:14}}}},{markup:[{tagName:"rect",selector:"body"},nc]},{attributes:{text:{set:function(t,e,n,i){if(!(n instanceof HTMLElement)){var r=i.style||{},o={text:t,width:-5,height:"100%"},s=io({"text-vertical-anchor":"middle"},r);return ol["text-wrap"].set.call(this,o,e,n,s),{fill:r.color||null}}n.textContent=t},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),rc=$l.define("standard.Link",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 10 -5 0 0 10 5 z"}},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),oc=$l.define("standard.DoubleLink",{attrs:{line:{connection:!0,stroke:"#DDDDDD",strokeWidth:4,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"#000000",d:"M 10 -3 10 -10 -2 0 10 10 10 3"}},outline:{connection:!0,stroke:"#000000",strokeWidth:6,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"outline",attributes:{fill:"none",cursor:"pointer"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),sc=$l.define("standard.ShadowLink",{attrs:{line:{connection:!0,stroke:"#FF0000",strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"none",d:"M 0 -10 -10 0 0 10 z"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}},shadow:{connection:!0,transform:"translate(3,6)",stroke:"#000000",strokeOpacity:.2,strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 0 -10 -10 0 0 10 z",stroke:"none"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}}}},{markup:[{tagName:"path",selector:"shadow",attributes:{fill:"none","pointer-events":"none"}},{tagName:"path",selector:"line",attributes:{fill:"none",cursor:"pointer"}}]}),ac={TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left",TOP_LEFT:"top-left",TOP_RIGHT:"top-right",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",CENTER:"center"};function lc(t,e){const n=new me(t);switch(e){case void 0:throw new Error("Position required");case ac.LEFT:case"leftMiddle":return n.leftMiddle();case ac.RIGHT:case"rightMiddle":return n.rightMiddle();case ac.TOP:case"topMiddle":return n.topMiddle();case ac.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case ac.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case ac.TOP_RIGHT:case"topRight":return n.topRight();case ac.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case ac.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case ac.CENTER:return n.center();default:throw new Error(`Unknown position: ${e}`)}}var cc=function(t,e){e||(e={}),this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,io({silent:!0},e))},hc={add:!0,remove:!0,merge:!0},uc={add:!0,remove:!1},dc=function(t,e,n){n=Math.min(Math.max(n,0),t.length);var i,r=Array(t.length-n),o=e.length;for(i=0;i<r.length;i++)r[i]=t[i+n];for(i=0;i<o;i++)t[i+n]=e[i];for(i=0;i<r.length;i++)t[i+o+n]=r[i]};io(cc.prototype,oa,{model:ba,preinitialize:function(){},initialize:function(){},toJSON:function(t){return this.map((function(e){return e.toJSON(t)}))},add:function(t,e){return this.set(t,io({merge:!1},e,uc))},remove:function(t,e){e=io({},e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=this._removeModels(t,e);return!e.silent&&i.length&&(e.changes={added:[],merged:[],removed:i},this.trigger("update",this,e)),n?i[0]:i},set:function(t,e){if(null!=t){e=io({},hc,e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=e.at;null!=i&&(i=+i),i>this.length&&(i=this.length),i<0&&(i+=this.length+1);var r,o,s=[],a=[],l=[],c=[],h={},u=e.add,d=e.merge,f=e.remove,p=!1,g=this.comparator&&null==i&&!1!==e.sort,m=no(this.comparator)?this.comparator:null;for(o=0;o<t.length;o++){r=t[o];var v=this.get(r);if(v){if(d&&r!==v){var y=this._isModel(r)?r.attributes:r;v.set(y,e),l.push(v),g&&!p&&(p=v.hasChanged(m))}h[v.cid]||(h[v.cid]=!0,s.push(v)),t[o]=v}else u&&(r=t[o]=this._prepareModel(r,e))&&(a.push(r),this._addReference(r,e),h[r.cid]=!0,s.push(r))}if(f){for(o=0;o<this.length;o++)h[(r=this.models[o]).cid]||c.push(r);c.length&&this._removeModels(c,e)}var b=!1,w=!g&&u&&f;if(s.length&&w?(b=this.length!==s.length||this.models.some((function(t,e){return t!==s[e]})),this.models.length=0,dc(this.models,s,0),this.length=this.models.length):a.length&&(g&&(p=!0),dc(this.models,a,null==i?this.length:i),this.length=this.models.length),p&&this.sort({silent:!0}),!e.silent){for(o=0;o<a.length;o++)null!=i&&(e.index=i+o),(r=a[o]).trigger("add",r,this,e);(p||b)&&this.trigger("sort",this,e),(a.length||c.length||l.length)&&(e.changes={added:a,removed:c,merged:l},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?ho(e):{};for(var n=0;n<this.models.length;n++)this._removeReference(this.models[n],e);return e.previousModels=this.models,this._reset(),t=this.add(t,io({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,io({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);return this.remove(e,t)},unshift:function(t,e){return this.add(t,io({at:0},e))},shift:function(t){var e=this.at(0);return this.remove(e,t)},slice:function(){return Array.prototype.slice.apply(this.models,arguments)},get:function(t){if(null!=t)return this._byId[t]||this._byId[this.modelId(this._isModel(t)?t.attributes:t,t.idAttribute)]||t.cid&&this._byId[t.cid]},has:function(t){return null!=this.get(t)},at:function(t){return t<0&&(t+=this.length),this.models[t]},sort:function(t){var e=this.comparator;if(!e)throw new Error("Cannot sort a set without a comparator");t||(t={});var n=e.length;return go(e)&&(e=e.bind(this)),1===n||no(e)?this.models=this.sortBy(e):this.models.sort(e),t.silent||this.trigger("sort",this,t),this},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(t,e){return t[e||this.model.prototype.idAttribute||"id"]},values:function(){return new gc(this,mc)},keys:function(){return new gc(this,vc)},entries:function(){return new gc(this,yc)},each:function(t,e){this.models.forEach(t,e)},filter:function(t,e){return this.models.filter(t,e)},find:function(t,e){return this.models.find(t,e)},findIndex:function(t,e){return this.models.findIndex(t,e)},first:function(){return this.models[0]},includes:function(t){return this.models.includes(t)},last:function(){return this.models[this.models.length-1]},isEmpty:function(){return!this.models.length},map:function(t,e){return this.models.map(t,e)},reduce:function(t,e=this.first()){return this.models.reduce(t,e)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(t,e){return this._isModel(t)?(t.collection||(t.collection=this),t):((e=e?ho(e):{}).collection=this,(n=this.model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,n.validationError,e),!1):n);var n},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r=this.get(t[i]);if(r){var o=this.models.indexOf(r);this.models.splice(o,1),this.length--,delete this._byId[r.cid];var s=this.modelId(r.attributes,r.idAttribute);null!=s&&delete this._byId[s],e.silent||(e.index=o,r.trigger("remove",r,this,e)),n.push(r),this._removeReference(r,e)}}return t.length>0&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof ba},_addReference:function(t,e){this._byId[t.cid]=t;var n=this.modelId(t.attributes,t.idAttribute);null!=n&&(this._byId[n]=t),t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){delete this._byId[t.cid];var n=this.modelId(t.attributes,t.idAttribute);null!=n&&delete this._byId[n],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,n,i){if(e){if(("add"===t||"remove"===t)&&n!==this)return;if("changeId"===t){var r=this.modelId(e.previousAttributes(),e.idAttribute),o=this.modelId(e.attributes,e.idAttribute);null!=r&&delete this._byId[r],null!=o&&(this._byId[o]=e)}}this.trigger.apply(this,arguments)}});var fc="function"==typeof Symbol&&Symbol.iterator;fc&&(cc.prototype[fc]=cc.prototype.values);var pc,gc=function(t,e){this._collection=t,this._kind=e,this._index=0},mc=1,vc=2,yc=3;fc&&(gc.prototype[fc]=function(){return this}),gc.prototype.next=function(){if(this._collection){if(this._index<this._collection.length){var t,e=this._collection.at(this._index);if(this._index++,this._kind===mc)t=e;else{var n=this._collection.modelId(e.attributes,e.idAttribute);t=this._kind===vc?n:[n,e]}return{value:t,done:!1}}this._collection=void 0}return{value:void 0,done:!0}},function(t,e,n,i){_o(n,(function(n,r){e[r]&&(t.prototype[r]=function(t,e,n,i){switch(e){case 1:return function(){return t[n](this[i])};case 2:return function(e){return t[n](this[i],e)};case 3:return function(e,r){return t[n](this[i],va(e,this),r)};case 4:return function(e,r,o){return t[n](this[i],va(e,this),r,o)};default:return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(this[i]),t[n].apply(t,e)}}}(e,n,r,i))}))}((pc=[cc,{toArray:1,sortBy:3},"models"])[0],{sortBy:yo,toArray:vo},pc[1],pc[2]),cc.extend=ma;const bc={cells:function(t){return function(){var e=Array.from(arguments),n=e.length,i=n>0&&e[0]||[],r=n>1&&e[n-1]||{};return Array.isArray(i)||(r instanceof al?i=e:i instanceof al&&(e.length>1&&e.pop(),i=e)),r instanceof al&&(r={}),t.call(this,i,r)}}},wc=cc.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace="undefined"!=typeof joint&&To(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){const n=e.collection,i=n.cellNamespace,{type:r}=t,o=Ds(i,r,".");if(!o)throw new Error(`dia.Graph: Could not find cell constructor for type: '${r}'. Make sure to add the constructor to 'cellNamespace'.`);const s=new o(t,e);return e.dry||(s.graph=n.graph),s},comparator:function(t){return t.get("z")||0}}),xc=ba.extend({initialize:function(t,e){var n=new wc([],{model:(e=e||{}).cellModel,cellNamespace:e.cellNamespace,graph:this});ba.prototype.set.call(this,"cells",n),n.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},n.on("add",this._restructureOnAdd,this),n.on("remove",this._restructureOnRemove,this),n.on("reset",this._restructureOnReset,this),n.on("change:source",this._restructureOnChangeSource,this),n.on("change:target",this._restructureOnChangeTarget,this),n.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){if(t.isLink()){this._edges[t.id]=!0;var{source:e,target:n}=t.attributes;e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0),n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)}else this._nodes[t.id]=!0},_restructureOnRemove:function(t){if(t.isLink()){delete this._edges[t.id];var{source:e,target:n}=t.attributes;e.id&&this._out[e.id]&&this._out[e.id][t.id]&&delete this._out[e.id][t.id],n.id&&this._in[n.id]&&this._in[n.id][t.id]&&delete this._in[n.id][t.id]}else delete this._nodes[t.id]},_restructureOnReset:function(t){t=t.models,this._out={},this._in={},this._nodes={},this._edges={},t.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(t){var e=t.previous("source");e.id&&this._out[e.id]&&delete this._out[e.id][t.id];var n=t.attributes.source;n.id&&((this._out[n.id]||(this._out[n.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target");e.id&&this._in[e.id]&&delete this._in[e.id][t.id];var n=t.get("target");n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(){var t=ba.prototype.toJSON.apply(this,arguments);return t.cells=this.get("cells").toJSON(),t},fromJSON:function(t,e){if(!t.cells)throw new Error("Graph JSON must contain cells array.");return this.set(t,e)},set:function(t,e,n){var i;return"object"==typeof t?(i=t,n=e):(i={})[t]=e,i.hasOwnProperty("cells")&&(this.resetCells(i.cells,n),i=So(i,"cells")),ba.prototype.set.call(this,i,n)},clear:function(t){t=io({},t,{clear:!0});var e=this.get("cells");if(0===e.length)return this;this.startBatch("clear",t);var n=e.sortBy((function(t){return t.isLink()?1:2}));do{n.shift().remove(t)}while(n.length>0);return this.stopBatch("clear"),this},_prepareCell:function(t,e){var n;if(t instanceof ba?(n=t.attributes,t.graph||e&&e.dry||(t.graph=this)):n=t,!no(n.type))throw new TypeError("dia.Graph: cell type must be a string.");return t},minZIndex:function(){var t=this.get("cells").first();return t&&t.get("z")||0},maxZIndex:function(){var t=this.get("cells").last();return t&&t.get("z")||0},addCell:function(t,e){return Array.isArray(t)?this.addCells(t,e):(t instanceof ba?t.has("z")||t.set("z",this.maxZIndex()+1):void 0===t.z&&(t.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(t,e),e||{}),this)},addCells:function(t,e){return 0===t.length||(t=bo(t),e.maxPosition=e.position=t.length-1,this.startBatch("add",e),t.forEach((function(t){this.addCell(t,e),e.position--}),this),this.stopBatch("add",e)),this},resetCells:function(t,e){var n=vo(t).map((function(t){return this._prepareCell(t,e)}),this);return this.get("cells").reset(n,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),so(t,"remove",e),this.stopBatch("remove")),this},_removeCell:function(t,e,n){(n=n||{}).clear||(n.disconnectLinks?this.disconnectLinks(t,n):this.removeLinks(t,n)),this.get("cells").remove(t,{silent:!0}),t.graph===this&&(t.graph=null)},getCell:function(t){return this.get("cells").get(t)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return this.get("cells").toArray().filter((t=>t.isElement()))},getLinks:function(){return this.get("cells").toArray().filter((t=>t.isLink()))},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(t,e){var n=(e=e||{}).indirect,i=e.inbound,r=e.outbound;void 0===i&&void 0===r&&(i=r=!0);var o=[],s={};function a(t,e){if(_o(t.getOutboundEdges(e.id),function(e,c){if(!s[c]){var h=t.getCell(c);o.push(h),s[c]=!0,n&&(i&&l(t,h),r&&a(t,h))}}.bind(t)),n&&e.isLink()){var c=e.getTargetCell();c&&c.isLink()&&(s[c.id]||(o.push(c),a(t,c)))}}function l(t,e){if(_o(t.getInboundEdges(e.id),function(e,c){if(!s[c]){var h=t.getCell(c);o.push(h),s[c]=!0,n&&(i&&l(t,h),r&&a(t,h))}}.bind(t)),n&&e.isLink()){var c=e.getSourceCell();c&&c.isLink()&&(s[c.id]||(o.push(c),l(t,c)))}}if(r&&a(this,t),i&&l(this,t),e.deep){var c=t.getEmbeddedCells({deep:!0}),h={};c.forEach((function(t){t.isElement()&&(h[t.id]=!0)})),c.forEach((function(t){t.isLink()||(r&&_o(this.getOutboundEdges(t.id),function(t,n){if(!s[n]){var i=this.getCell(n),{source:r,target:a}=i.attributes,l=r.id,c=a.id;if(!e.includeEnclosed&&l&&h[l]&&c&&h[c])return;o.push(this.getCell(n)),s[n]=!0}}.bind(this)),i&&_o(this.getInboundEdges(t.id),function(t,n){if(!s[n]){var i=this.getCell(n),{source:r,target:a}=i.attributes,l=r.id,c=a.id;if(!e.includeEnclosed&&l&&h[l]&&c&&h[c])return;o.push(this.getCell(n)),s[n]=!0}}.bind(this)))}),this)}return o},getNeighbors:function(t,e){e||(e={});var n=e.inbound,i=e.outbound;void 0===n&&void 0===i&&(n=i=!0);var r=this.getConnectedLinks(t,e).reduce(function(r,o){var{source:s,target:a}=o.attributes,l=o.hasLoop(e);if(n&&To(s,"id")&&!r[s.id]){var c=this.getCell(s.id);c.isElement()&&(!l&&(!c||c===t||e.deep&&c.isEmbeddedIn(t))||(r[s.id]=c))}if(i&&To(a,"id")&&!r[a.id]){var h=this.getCell(a.id);h.isElement()&&(!l&&(!h||h===t||e.deep&&h.isEmbeddedIn(t))||(r[a.id]=h))}return r}.bind(this),{});if(t.isLink()){if(n){var o=t.getSourceCell();o&&o.isElement()&&!r[o.id]&&(r[o.id]=o)}if(i){var s=t.getTargetCell();s&&s.isElement()&&!r[s.id]&&(r[s.id]=s)}}return vo(r)},getCommonAncestor:function(){var t=Array.from(arguments).map((function(t){for(var e=[],n=t.get("parent");n;)e.push(n),n=this.getCell(n).get("parent");return e}),this);t=t.sort((function(t,e){return t.length-e.length}));var e=vo(t.shift()).find((function(e){return t.every((function(t){return t.includes(e)}))}));return this.getCell(e)},getSuccessors:function(t,e){e=e||{};var n=[];return this.search(t,(function(e){e!==t&&n.push(e)}),io({},e,{outbound:!0})),n},cloneCells:wa,cloneSubgraph:function(t,e){var n=this.getSubgraph(t,e);return this.cloneCells(n)},getSubgraph:function(t,e){e=e||{};var n=[],i={},r=[],o=[];return vo(t).forEach((function(t){i[t.id]||(n.push(t),i[t.id]=t,t.isLink()?o.push(t):r.push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach((function(t){i[t.id]||(n.push(t),i[t.id]=t,t.isLink()?o.push(t):r.push(t))}))})),o.forEach((function(t){var{source:e,target:o}=t.attributes;if(e.id&&!i[e.id]){var s=this.getCell(e.id);n.push(s),i[s.id]=s,r.push(s)}if(o.id&&!i[o.id]){var a=this.getCell(o.id);n.push(this.getCell(o.id)),i[a.id]=a,r.push(a)}}),this),r.forEach((function(t){this.getConnectedLinks(t,e).forEach((function(t){var{source:e,target:r}=t.attributes;!i[t.id]&&e.id&&i[e.id]&&r.id&&i[r.id]&&(n.push(t),i[t.id]=t)}))}),this),n},getPredecessors:function(t,e){e=e||{};var n=[];return this.search(t,(function(e){e!==t&&n.push(e)}),io({},e,{inbound:!0})),n},search:function(t,e,n){(n=n||{}).breadthFirst?this.bfs(t,e,n):this.dfs(t,e,n)},bfs:function(t,e,n={}){const i={},r={},o=[];for(o.push(t),r[t.id]=0;o.length>0;){var s=o.shift();if(i[s.id])continue;if(i[s.id]=!0,!1===e.call(this,s,r[s.id]))continue;const t=this.getNeighbors(s,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];r[n.id]=r[s.id]+1,o.push(n)}}},dfs:function(t,e,n={}){const i={},r={},o=[];for(o.push(t),r[t.id]=0;o.length>0;){const t=o.pop();if(i[t.id])continue;if(i[t.id]=!0,!1===e.call(this,t,r[t.id]))continue;const s=this.getNeighbors(t,n),a=o.length;for(let e=0,n=s.length;e<n;e++){const n=s[e];r[n.id]=r[t.id]+1,o.splice(a,0,n)}}},getSources:function(){var t=[];return _o(this._nodes,function(e,n){this._in[n]&&!fo(this._in[n])||t.push(this.getCell(n))}.bind(this)),t},getSinks:function(){var t=[];return _o(this._nodes,function(e,n){this._out[n]&&!fo(this._out[n])||t.push(this.getCell(n))}.bind(this)),t},isSource:function(t){return!this._in[t.id]||fo(this._in[t.id])},isSink:function(t){return!this._out[t.id]||fo(this._out[t.id])},isSuccessor:function(t,e){var n=!1;return this.search(t,(function(i){if(i===e&&i!==t)return n=!0,!1}),{outbound:!0}),n},isPredecessor:function(t,e){var n=!1;return this.search(t,(function(i){if(i===e&&i!==t)return n=!0,!1}),{inbound:!0}),n},isNeighbor:function(t,e,n){var i=(n=n||{}).inbound,r=n.outbound;void 0===i&&void 0===r&&(i=r=!0);var o=!1;return this.getConnectedLinks(t,n).forEach((function(t){var{source:n,target:s}=t.attributes;return i&&To(n,"id")&&n.id===e.id||r&&To(s,"id")&&s.id===e.id?(o=!0,!1):void 0})),o},disconnectLinks:function(t,e){this.getConnectedLinks(t).forEach((function(n){n.set(n.attributes.source.id===t.id?"source":"target",{x:0,y:0},e)}))},removeLinks:function(t,e){so(this.getConnectedLinks(t),"remove",e)},findModelsFromPoint:function(t){return this.getElements().filter((e=>e.getBBox({rotate:!0}).containsPoint(t)))},findModelsInArea:function(t,e={}){const n=new me(t),{strict:i=!1}=e,r=i?"containsRect":"intersect";return this.getElements().filter((t=>n[r](t.getBBox({rotate:!0}))))},findModelsUnderElement:function(t,e={}){const{searchBy:n="bbox"}=e,i=t.getBBox().rotateAroundCenter(t.angle());return("bbox"===n?this.findModelsInArea(i):this.findModelsFromPoint(lc(i,n))).filter((e=>t.id!==e.id&&!e.isEmbeddedIn(t)))},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e={}){const{rotate:n=!0}=e;return vo(t).reduce((function(t,e){const i=e.getBBox({rotate:n});return i?t?t.union(i):i:t}),null)},translate:function(t,e,n){var i=this.getCells().filter((function(t){return!t.isEmbedded()}));return so(i,"translate",t,e,n),this},resize:function(t,e,n){return this.resizeCells(t,e,this.getCells(),n)},resizeCells:function(t,e,n,i){var r=this.getCellsBBox(n);if(r){var o=Math.max(t/r.width,0),s=Math.max(e/r.height,0);so(n,"scale",o,s,r.origin(),i)}return this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",io({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",io({},e,{batchName:t}))},hasActiveBatch:function(t){const e=this._batches;let n;return n=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t],n.some((t=>e[t]>0))}},{validations:{multiLinks:function(t,e){var{source:n,target:i}=e.attributes;if(n.id&&i.id){var r=e.getSourceCell();if(r&&t.getConnectedLinks(r,{outbound:!0}).filter((function(t){var{source:e,target:r}=t.attributes;return e&&e.id===n.id&&(!e.port||e.port===n.port)&&r&&r.id===i.id&&(!r.port||r.port===i.port)})).length>1)return!1}return!0},linkPinning:function(t,e){var{source:n,target:i}=e.attributes;return n.id&&i.id}}});!function(t,e,n){if(no(n)){if(!bc[n])throw new Error('Unknown wrapper: "'+n+'"');n=bc[n]}if(!go(n))throw new Error("Wrapper must be a function.");vo(["resetCells","addCells","removeCells"]).forEach((function(e){t[e]=n(t[e])}))}(xc.prototype,0,bc.cells);var Ac=function(t){this.cid=Co("view"),this.preinitialize.apply(this,arguments),io(this,Po(t,Ec)),this._ensureElement(),this.initialize.apply(this,arguments)},Tc=/^(\S+)\s*(.*)$/,Ec=["model","collection","el","id","attributes","className","tagName","events"];io(Ac.prototype,oa,{tagName:"div",$:function(t){return this.$el.find(t)},preinitialize:function(){},initialize:function(){},render:function(){return this},remove:function(){return this._removeElement(),this.stopListening(),this},_removeElement:function(){this.$el.remove()},setElement:function(t){return this.undelegateEvents(),this._setElement(t),this.delegateEvents(),this},_setElement:function(t){this.$el=t instanceof Rs?t:Rs(t),this.el=this.$el[0]},delegateEvents:function(t){if(t||(t=Eo(this,"events")),!t)return this;for(var e in this.undelegateEvents(),t){var n=t[e];if(go(n)||(n=this[n]),n){var i=e.match(Tc);this.delegate(i[1],i[2],n.bind(this))}}return this},delegate:function(t,e,n){return this.$el.on(t+".delegateEvents"+this.cid,e,n),this},undelegateEvents:function(){return this.$el&&this.$el.off(".delegateEvents"+this.cid),this},undelegate:function(t,e,n){return this.$el.off(t+".delegateEvents"+this.cid,e,n),this},_createElement:function(t){return document.createElement(t)},_ensureElement:function(){if(this.el)this.setElement(Eo(this,"el"));else{var t=io({},Eo(this,"attributes"));this.id&&(t.id=Eo(this,"id")),this.className&&(t.class=Eo(this,"className")),this.setElement(this._createElement(Eo(this,"tagName"))),this._setAttributes(t)}},_setAttributes:function(t){this.$el.attr(t)}}),Ac.extend=ma;const Sc={},Pc=Ac.extend({options:{},theme:null,themeClassNamePrefix:Fs("theme-"),requireSetThemeOverride:!1,defaultTheme:"default",children:null,childNodes:null,DETACHABLE:!0,UPDATE_PRIORITY:2,FLAG_INSERT:1<<30,FLAG_REMOVE:1<<29,FLAG_INIT:1<<28,constructor:function(t){this.requireSetThemeOverride=t&&!!t.theme,this.options=io({},this.options,t),Ac.call(this,t)},initialize:function(){Sc[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){this.svgElement?this.vel.remove():this.$el.remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){if(t||(t=Eo(this,"children")),t){var e=this.svgElement,n=An.namespace[e?"svg":"xhtml"],i=Bs(t,n);(e?this.vel:this.$el).empty().append(i.fragment),this.childNodes=i.selectors}return this},findAttribute:function(t,e){for(var n=e;n&&1===n.nodeType;){var i=n.getAttribute(t);if(i)return i;if(n===this.el)return null;n=n.parentNode}return null},_ensureElement:function(){if(this.el)this.setElement(Eo(this,"el"));else{var t=Eo(this,"tagName"),e=io({},Eo(this,"attributes")),n=io({},Eo(this,"style"));this.id&&(e.id=Eo(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)}this._ensureElClassName()},_setAttributes:function(t){this.svgElement?this.vel.attr(t):this.$el.attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(An.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof Rs?t:Rs(t),this.el=this.$el[0],this.svgElement&&(this.vel=An(this.el))},_ensureElClassName:function(){var t=Eo(this,"className");if(t){var e=Fs(t);this.svgElement?this.vel.removeClass(t).addClass(e):this.$el.removeClass(t).addClass(e)}},init:function(){},onRender:function(){},confirmUpdate:function(){return 0},setTheme:function(t,e){return e=e||{},this.theme&&this.requireSetThemeOverride&&!e.override||(this.removeThemeClassName(),this.addThemeClassName(t),this.onSetTheme(this.theme,t),this.theme=t),this},addThemeClassName:function(t){if(!(t=t||this.theme))return this;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.addClass(e):this.$el.addClass(e),this},removeThemeClassName:function(t){t=t||this.theme;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.removeClass(e):this.$el.removeClass(e),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),Sc[this.cid]=null,Ac.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(!e)return this;n||(n={});var i=this.getEventNamespace();for(var r in e){var o=e[r];"function"!=typeof o&&(o=this[o]),o&&Rs(t).on(r+i,n,o.bind(this))}return this},undelegateElementEvents:function(t){return Rs(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t||(t=Eo(this,"documentEvents")),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){if(!t)throw new Error("eventData(): event object required.");var n=t.data,i="__"+this.cid+"__";return void 0===e?n&&n[i]||{}:(n||(n=t.data={}),n[i]||(n[i]={}),io(n[i],e),this)},stopPropagation:function(t){return this.eventData(t,{propagationStopped:!0}),this},isPropagationStopped:function(t){return!!this.eventData(t).propagationStopped}},{extend:function(){var t=Array.from(arguments),e=t[0]&&io({},t[0])||{},n=t[1]&&io({},t[1])||{},i=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof i&&i.apply(this,arguments),this.render.__render__===i&&this.onRender(),this},e.render.__render__=i,Ac.extend.call(this,e,n)}});function _c(t){return t?Array.isArray(t)?t:[t]:[]}const kc=Pc.extend({tagName:"g",svgElement:!0,className:"highlight",HIGHLIGHT_FLAG:1,UPDATE_PRIORITY:3,DETACHABLE:!1,UPDATABLE:!0,MOUNTABLE:!0,cellView:null,nodeSelector:null,node:null,updateRequested:!1,postponedUpdate:!1,transformGroup:null,detachedTransformGroup:null,requestUpdate(t,e){const{paper:n}=t;this.cellView=t,this.nodeSelector=e,n&&(this.updateRequested=!0,n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate(){this.updateRequested=!1;const{cellView:t,nodeSelector:e}=this;return t.isMounted()?(this.update(t,e),this.mount(),this.transform(),0):(this.postponedUpdate=!0,0)},findNode(t,e=null){let n;if("string"==typeof e)n=t.findNode(e);else if(mo(e)){const i=t.model.isLink(),{label:r=null,port:o,selector:s}=e;n=i&&null!==r?t.findLabelNode(r,s):!i&&o?t.findPortNode(o,s):t.findNode(s)}else e&&(n=An.toNode(e),n instanceof SVGElement||(n=null));return n||null},getNodeMatrix(t,e){const{options:n}=this,{layer:i}=n,{rotatableNode:r}=t,o=t.getNodeMatrix(e);return r?i?r.contains(e)?o:t.getRootRotateMatrix().inverse().multiply(o):t.getNodeRotateMatrix(e).multiply(o):o},mount(){const{MOUNTABLE:t,cellView:e,el:n,options:i,transformGroup:r,detachedTransformGroup:o,postponedUpdate:s,nodeSelector:a}=this;if(!t||r)return;if(s)return this.update(e,a),void this.transform();const{vel:l,paper:c}=e,{layer:h}=i;if(h){let t;o?(t=o,this.detachedTransformGroup=null):t=An("g").addClass("highlight-transform").append(n),this.transformGroup=t,c.getLayerView(h).insertSortedNode(t.node,i.z)}else n.parentNode&&!n.nextSibling||l.append(n)},unmount(){const{MOUNTABLE:t,transformGroup:e,vel:n}=this;t&&(e?(this.transformGroup=null,this.detachedTransformGroup=e,e.remove()):n.remove())},transform(){const{transformGroup:t,cellView:e,updateRequested:n}=this;if(!t||e.model.isLink()||n)return;const i=e.getRootTranslateMatrix(),r=e.getRootRotateMatrix(),o=i.multiply(r);t.attr("transform",An.matrixToTransformString(o))},update(){const{node:t,cellView:e,nodeSelector:n,updateRequested:i,id:r}=this;if(i)return;this.postponedUpdate=!1;const o=this.node=this.findNode(e,n);t&&this.unhighlight(e,t),o?(this.highlight(e,o),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this))},onRemove(){const{node:t,cellView:e,id:n,constructor:i}=this;t&&this.unhighlight(e,t),this.unmount(),i._removeRef(e,n)},highlight(t,e){},unhighlight(t,e){},listenToUpdateAttributes(t){const e=Eo(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange(){const{cellView:t}=this;if(!t)return;const{model:e,paper:n}=t;Eo(this,"UPDATE_ATTRIBUTES").some((t=>e.hasChanged(t)))&&n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY)}},{_views:{},highlight:function(t,e,n){const i=this.uniqueId(e,n);this.add(t,e,i,n)},unhighlight:function(t,e,n){const i=this.uniqueId(e,n);this.remove(t,i)},get(t,e=null){const{cid:n}=t,{_views:i}=this,r=i[n];if(null===e){const t=[];if(!r)return t;for(let e in r){const n=r[e];n instanceof this&&t.push(n)}return t}if(!r)return null;if(e in r){const t=r[e];if(t instanceof this)return t}return null},add(t,e,n,i={}){if(!n)throw new Error("dia.HighlighterView: An ID required.");const r=kc.get(t,n);r&&r.remove();const o=new this(i);return o.id=n,this._addRef(t,n,o),o.requestUpdate(t,e),o.listenToUpdateAttributes(t),o},_addRef(t,e,n){const{cid:i}=t,{_views:r}=this;let o=r[i];o||(o=r[i]={}),o[e]=n},_removeRef(t,e){const{cid:n}=t,{_views:i}=this,r=i[n];if(r){e&&delete r[e];for(let t in r)return;delete i[n]}},remove(t,e=null){_c(this.get(t,e)).forEach((t=>{t.remove()}))},removeAll(t,e=null){const{_views:n}=this;for(let i in n)for(let r in n[i]){const o=n[i][r];o.cellView.paper===t&&o instanceof this&&(null===e||r===e)&&o.remove()}},update(t,e=null,n=!1){_c(this.get(t,e)).forEach((t=>{(n||t.UPDATABLE)&&t.update()}))},transform(t,e=null){_c(this.get(t,e)).forEach((t=>{t.UPDATABLE&&t.transform()}))},unmount(t,e=null){_c(this.get(t,e)).forEach((t=>t.unmount()))},mount(t,e=null){_c(this.get(t,e)).forEach((t=>t.mount()))},uniqueId:(t,e="")=>An.ensureId(t)+JSON.stringify(e)}),Lc=["transform","x","y","cx","cy","dx","dy","x1","y1","x2","y2","points","d","r","rx","ry","width","height","stroke-width","font-size"].reduce(((t,e)=>(t[e]=!0,t)),{}),Cc=["r","rx","ry","width","height","stroke-width","font-size"].reduce(((t,e)=>(t[e]=!0,t)),{});function Mc(t,e){const n={};for(let i in t)t.hasOwnProperty(i)&&(n[i]=Oc(i,t[i],e));return n}function Oc(t,e,n){if(t in Lc&&Ba(e)){let i=Va(e,n);return t in Cc&&(i=Math.max(0,i)),i}return e}const Nc={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},Rc=Pc.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var t=["cell"],e=this.model.get("type");return e&&e.toLowerCase().split(".").forEach((function(e,n,i){t.push("type-"+i.slice(0,n+1).join("-"))})),t.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e,n,i={},r={},o=0,s=Eo(this,"presentationAttributes");for(var a in s)if(s.hasOwnProperty(a)){var l=s[a];for(Array.isArray(l)||(l=[l]),t=0,e=l.length;t<e;t++){var c=i[n=l[t]];c||(c=i[n]=1<<o++),r[a]|=c}}var h=Eo(this,"initFlag");for(Array.isArray(h)||(h=[h]),t=0,e=h.length;t<e;t++)i[n=h[t]]||(i[n]=1<<o++);if(o>25)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=i,this._presentationAttributes=r},hasFlag:function(t,e){return t&this.getFlag(e)},removeFlag:function(t,e){return t^t&this.getFlag(e)},getFlag:function(t){var e=this._flags;if(!e)return 0;var n=0;if(Array.isArray(t))for(var i=0,r=t.length;i<r;i++)n|=e[t[i]];else n|=e[t];return n},attributes:function(){var t=this.model;return{"model-id":t.id,"data-type":t.attributes.type}},constructor:function(t){t.id=t.id||$s(this),Pc.call(this,t)},initialize:function(){this.setFlags(),Pc.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){var n=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&n&&(e.dirty&&this.hasFlag(n,"UPDATE")&&(n|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(n,e))},requestUpdate:function(t,e){const{paper:n}=this;n&&t>0&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n=Bs(t),i=n.selectors,r=n.groupSelectors;for(var o in r){if(i[o])throw new Error("dia.CellView: ambiguous group selector");i[o]=r[o]}if(e){var s=this.selector;if(i[s])throw new Error("dia.CellView: ambiguous root selector.");i[s]=e}return{fragment:n.fragment,selectors:i}},can:function(t){var e,n,i=go(this.options.interactive)?this.options.interactive(this):this.options.interactive;return to(i)&&!1!==i[t]||(e=i,n=Object.prototype.toString,(!0===e||!1===e||!!e&&"object"==typeof e&&n.call(e)===Sn)&&!1!==i)},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){var i=n[t];if(i)return Array.isArray(i)?i:[i]}return this.useCSSSelectors?Rs(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){const[e=null]=this.findNodes(t);return e},notify:function(t){if(this.paper){var e=Array.prototype.slice.call(arguments,1);this.trigger.apply(this,[t].concat(e)),this.paper.trigger.apply(this.paper,[t,this].concat(e))}},getBBox:function(t){var e;if(t&&t.useModelGeometry){var n=this.model;e=n.getBBox().bbox(n.angle())}else e=this.getNodeBBox(this.el);return this.paper.localToPaperRect(e)},getNodeBBox:function(t){const e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),i=this.getNodeMatrix(t);return An.transformRect(e,n.multiply(i))},getNodeRotateMatrix(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():An.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getNodeMatrix(t),i=this.getRootTranslateMatrix();return An.transformRect(e,i.multiply(n))},getRootTranslateMatrix:function(){var t=this.model.position();return An.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t=An.createSVGMatrix(),e=this.model,n=e.angle();if(n){var i=e.getBBox(),r=i.width/2,o=i.height/2;t=t.translate(r,o).rotate(n).translate(-r,-o)}return t},_notifyHighlight:function(t,e,n={}){const{el:i}=this;let r;if("string"==typeof e?r=this.findNode(e)||i:[r=i]=this.$(e),n.partial=r!==i,void 0===n.type){let t;switch(!0){case n.embedding:t=Nc.EMBEDDING;break;case n.connecting:t=Nc.CONNECTING;break;case n.magnetAvailability:t=Nc.MAGNET_AVAILABILITY;break;case n.elementAvailability:t=Nc.ELEMENT_AVAILABILITY;break;default:t=Nc.DEFAULT}n.type=t}return this.notify(t,r,n),this},highlight:function(t,e){return this._notifyHighlight("cell:highlight",t,e)},unhighlight:function(t,e={}){return this._notifyHighlight("cell:unhighlight",t,e)},findMagnet:function(t){const e=this.el;let n=this.$(t)[0];n||(n=e);do{const t=n.getAttribute("magnet"),i=n===e;if((t||i)&&"false"!==t)return n;if(i)return;n=n.parentNode}while(n)},findProxyNode:function(t,e){t||(t=this.el);const n=t.getAttribute(`${e}-selector`);if(n){const t=this.findNode(n);if(t)return t}return t},getSelector:function(t,e){var n;if(t===this.el)return"string"==typeof e&&(n=":scope > "+e),n;if(t){var i=An(t).index()+1;n=t.tagName+":nth-child("+i+")",e&&(n+=" > "+e),n=this.getSelector(t.parentNode,n)}return n},addLinkFromMagnet:function(t,e,n){var i=this.paper,r=i.model,o=i.getDefaultLink(this,t);return o.set({source:this.getLinkEnd(t,e,n,o,"source"),target:{x:e,y:n}}).addTo(r,{async:!1,ui:!0}),o.findView(i)},getLinkEnd:function(t,...e){var n=this.model,i=n.id,r=this.findAttribute("port",t),o=t.getAttribute("joint-selector"),s={id:i};return null!=o&&(s.magnet=o),null!=r?(s.port=r,n.hasPort(r)||o||(s.selector=this.getSelector(t))):null==o&&this.el!==t&&(s.selector=this.getSelector(t)),this.customizeLinkEnd(s,t,...e)},customizeLinkEnd:function(t,e,n,i,r,o){const{paper:s}=this,{connectionStrategy:a}=s.options;if("function"==typeof a){var l=a.call(s,t,this,e,new Jt(n,i),r,o,s);if(l)return l}return t},getMagnetFromLinkEnd:function(t){var e,n=t.port,i=t.magnet,r=this.model;return null!=n&&r.isElement()&&r.hasPort(n)?e=this.findPortNode(n,i)||this.el:(i||(i=t.selector),i||null==n||(i='[port="'+n+'"]'),e=this.findNode(i)),this.findProxyNode(e,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");const r=this.addLinkFromMagnet(e,n,i);r.notifyPointerdown(t,n,i),r.eventData(t,r.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:r})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var o=this.paper,s=o.options.magnetThreshold,a=this.getEventTarget(t),l=i.targetMagnet;if("onleave"===s){if(l===a||An(l).contains(a))return}else if(o.eventData(t).mousemoved<=s)return;this.dragLinkStart(t,l,e,n)}},dragLinkEnd:function(t,e,n){var i=this.eventData(t).linkView;i&&(i.pointerup(t,e,n),this.model.stopBatch("add-link"))},getAttributeDefinition:function(t){return this.model.constructor.getAttributeDefinition(t)},setNodeAttributes:function(t,e){fo(e)||(t instanceof SVGElement?An(t).attr(e):Rs(t).attr(e))},processNodeAttributes:function(t,e){var n,i,r,o,s,a,l,c,h,u=[];const d={};for(n in e)e.hasOwnProperty(n)&&(d[An.attributeNames[n]]=e[n]);for(n in d)d.hasOwnProperty(n)&&(i=d[n],!(r=this.getAttributeDefinition(n))||go(r.qualify)&&!r.qualify.call(this,i,t,d,this)?(a||(a={}),a[n]=i):(no(r.set)&&(a||(a={}),a[r.set]=i),null!==i&&u.push(n,r)));for(o=0,s=u.length;o<s;o+=2)n=u[o],r=u[o+1],i=e[n],go(r.set)&&(l||(l={}),l[n]=i),go(r.position)&&(c||(c={}),c[n]=i),go(r.offset)&&(h||(h={}),h[n]=i);return{raw:d,normal:a,set:l,position:c,offset:h}},updateRelativeAttributes:function(t,e,n,i){var r,o;i||(i={});var s=Mc(e.raw||{},n),a=e.normal||{};for(const t in a)a[t]=s[t];var l=e.set,c=e.position,h=e.offset;for(r in l){o=s[r];var u=this.getAttributeDefinition(r).set.call(this,o,n.clone(),t,s,this);to(u)?io(a,u):void 0!==u&&(a[r]=u)}if(t instanceof HTMLElement)this.setNodeAttributes(t,a);else{var d,f,p,g=a.transform,m=An.transformStringToMatrix(g),v=Jt(m.e,m.f);if(g&&(a=So(a,"transform"),m.e=m.f=0),c||h){var y=this.getNodeScale(t,i.scalableNode);d=y.sx,f=y.sy}var b=!1;for(r in c)o=s[r],(p=this.getAttributeDefinition(r).position.call(this,o,n.clone(),t,s,this))&&(v.offset(Jt(p).scale(d,f)),b||(b=!0));this.setNodeAttributes(t,a);var w=!1;if(h){var x=this.getNodeBoundingRect(t);if(x.width>0&&x.height>0){var A=An.transformRect(x,m).scale(1/d,1/f);for(r in h)o=s[r],(p=this.getAttributeDefinition(r).offset.call(this,o,A,t,s,this))&&(v.offset(Jt(p).scale(d,f)),w||(w=!0))}}(void 0!==g||b||w)&&(v.round(1),m.e=v.x,m.f=v.y,t.setAttribute("transform",An.matrixToTransformString(m)))}},getNodeScale:function(t,e){var n,i;if(e&&e.contains(t)){var r=e.scale();n=1/r.sx,i=1/r.sy}else n=1,i=1;return{sx:n,sy:i}},cleanNodesCache:function(){this.metrics={}},nodeCache:function(t){var e=this.metrics;if(!e)return{};var n=An.ensureId(t),i=e[n];return i||(i=e[n]={}),i},getNodeData:function(t){var e=this.nodeCache(t);return e.data||(e.data={}),e.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=An(t).getBBox()),new me(e.boundingRect)},getNodeMatrix:function(t){const e=this.nodeCache(t);if(void 0===e.magnetMatrix){const{rotatableNode:n,el:i}=this;let r;r=n&&n.contains(t)?n:i,e.magnetMatrix=An(t).getTransformToElement(r)}return An.createSVGMatrix(e.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=An(t).toGeometryShape()),e.geometryShape.clone()},isNodeConnection:function(t){return this.model.isLink()&&(!t||t===this.el)},findNodesAttributes:function(t,e,n,i){var r,o,s,a,l={},c=[];for(var h in t)if(t.hasOwnProperty(h)&&(s=t[h],mo(s))){var u=n[h]=this.findBySelector(h,e,i);for(r=0,o=u.length;r<o;r++){var d=u[r];a=An.ensureId(d);var f=i&&i[h]===d,p=l[a];if(p){p.array||(c.push(a),p.array=!0,p.attributes=[p.attributes],p.selectedLength=[p.selectedLength]);var g=p.attributes,m=p.selectedLength;if(f)g.unshift(s),m.unshift(-1);else{var v=lo(m,o);g.splice(v,0,s),m.splice(v,0,o)}}else l[a]={attributes:s,selectedLength:f?-1:o,node:d,array:!1}}}for(r=0,o=c.length;r<o;r++)(s=l[a=c[r]]).attributes=Mo({},...s.attributes.reverse());return l},getEventTarget:function(t,e={}){const{target:n,type:i,clientX:r=0,clientY:o=0}=t;return e.fromPoint||"touchmove"===i||"touchend"===i||"pointerId"in t&&n.hasPointerCapture(t.pointerId)?document.elementFromPoint(r,o):n},updateDOMSubtreeAttributes:function(t,e,n){n||(n={}),n.rootBBox||(n.rootBBox=me()),n.selectors||(n.selectors=this.selectors);var i,r,o,s,a,l={},c={},h=[],u=[],d=n.roAttributes,f=this.findNodesAttributes(d||e,t,l,n.selectors),p=d?this.findNodesAttributes(e,t,l,n.selectors):f;for(var g in f)if(o=(s=f[g]).attributes,r=s.node,(a=this.processNodeAttributes(r,o)).set||a.position||a.offset||a.raw.ref){var m,v=p[g]&&p[g].attributes,y=v&&void 0===o.ref?v.ref:o.ref;if(y){if(!(m=(l[y]||this.findBySelector(y,t,n.selectors))[0]))throw new Error('dia.CellView: "'+y+'" reference does not exist.')}else m=null;if(i={node:r,refNode:m,processedAttributes:a,allAttributes:v},m){var b=u.findIndex((function(t){return t.refNode===r}));b>-1?u.splice(b,0,i):u.push(i)}else h.push(i)}else this.setNodeAttributes(r,Mc(a.normal,n.rootBBox));h.push(...u);for(let t=0,e=h.length;t<e;t++){i=h[t],r=i.node;const e=(m=i.refNode)?An.ensureId(m):"";let o=c[e];o||(o=c[e]=m?An(m).getBBox({target:Fc(r,m)}):n.rootBBox),d?(a=this.processNodeAttributes(r,i.allAttributes),this.mergeProcessedAttributes(a,i.processedAttributes)):a=i.processedAttributes,this.updateRelativeAttributes(r,a,o,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),io(t.set,e.set),io(t.position,e.position),io(t.offset,e.offset);var n=t.normal&&t.normal.transform;void 0!==n&&e.normal&&(e.normal.transform=n),t.normal=e.normal},onMount(t){t||(this.mountTools(),kc.mount(this))},onDetach(){this.unmountTools(),kc.unmount(this)},onRemove:function(){this.removeTools(),this.removeHighlighters()},_toolsView:null,hasTools:function(t){var e=this._toolsView;return!(!e||t&&e.getName()!==t)},addTools:function(t){return this.removeTools(),t&&(this._toolsView=t,t.configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},unmountTools(){const t=this._toolsView;return t&&t.unmount(),this},mountTools(){const t=this._toolsView;return t&&!t.isMounted()&&t.mount(),this},updateTools:function(t){var e=this._toolsView;return e&&e.update(t),this},removeTools:function(){var t=this._toolsView;return t&&(t.remove(),this._toolsView=null),this},hideTools:function(){var t=this._toolsView;return t&&t.hide(),this},showTools:function(){var t=this._toolsView;return t&&t.show(),this},onToolEvent:function(t){switch(t){case"remove":this.removeTools();break;case"hide":this.hideTools();break;case"show":this.showTools()}},removeHighlighters:function(){kc.remove(this)},updateHighlighters:function(t=!1){kc.update(this,null,t)},transformHighlighters:function(){kc.transform(this)},preventDefaultInteraction(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented(t){const{defaultInteractionPrevented:e=!1}=this.eventData(t);return e},pointerdblclick:function(t,e,n){this.notify("cell:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){this.notify("cell:pointerclick",t,e,n)},contextmenu:function(t,e,n){this.notify("cell:contextmenu",t,e,n)},pointerdown:function(t,e,n){const{model:i}=this,{graph:r}=i;r&&(i.startBatch("pointer"),this.eventData(t,{graph:r})),this.notify("cell:pointerdown",t,e,n)},pointermove:function(t,e,n){this.notify("cell:pointermove",t,e,n)},pointerup:function(t,e,n){const{graph:i}=this.eventData(t);this.notify("cell:pointerup",t,e,n),i&&i.stopBatch("pointer",{cell:this.model})},mouseover:function(t){this.notify("cell:mouseover",t)},mouseout:function(t){this.notify("cell:mouseout",t)},mouseenter:function(t){this.notify("cell:mouseenter",t)},mouseleave:function(t){this.notify("cell:mouseleave",t)},mousewheel:function(t,e,n,i){this.notify("cell:mousewheel",t,e,n,i)},onevent:function(t,e,n,i){this.notify(e,t,n,i)},onmagnet:function(){},magnetpointerdblclick:function(){},magnetcontextmenu:function(){},checkMouseleave(t){const{paper:e,model:n}=this;if(e.isAsync()){if(n.isLink()){const t=n.getSourceElement();if(t){const n=e.findViewByModel(t);n&&(e.dumpView(n),e.checkViewVisibility(n))}const i=n.getTargetElement();if(i){const t=e.findViewByModel(i);t&&(e.dumpView(t),e.checkViewVisibility(t))}}e.dumpView(this),e.checkViewVisibility(this)}const i=this.getEventTarget(t,{fromPoint:!0}),r=e.findView(i);r!==this&&(this.mouseleave(t),r&&r.mouseenter(t))},setInteractivity:function(t){this.options.interactive=t}},{Flags:{TOOLS:"TOOLS"},Highlighting:Nc,addPresentationAttributes:function(t){return Mo({},Eo(this.prototype,"presentationAttributes"),t,(function(t,e){if(t&&e)return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),Array.isArray(t)&&Array.isArray(e)?co(t.concat(e)):void 0}))},evalAttribute:Oc});function Fc(t,e){let n=t;do{if(n.contains(e))return n;n=n.parentNode}while(n);return null}Object.defineProperty(Rc.prototype,"useCSSSelectors",{get(){const t=this.model.useCSSSelectors;return void 0!==t&&t}});const Bc={TOOLS:Rc.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},Ic="move",Dc="magnet",Vc=Rc.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=Rc.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){Rc.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[Bc.UPDATE],position:[Bc.TRANSLATE,Bc.TOOLS],size:[Bc.RESIZE,Bc.PORTS,Bc.TOOLS],angle:[Bc.ROTATE,Bc.TOOLS],markup:[Bc.RENDER],ports:[Bc.PORTS]},initFlag:[Bc.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(t,e){const{useCSSSelectors:n}=this;this.hasFlag(t,Bc.PORTS)&&(this._removePorts(),this._cleanPortsCache());let i=!1;if(this.hasFlag(t,Bc.RENDER))this.render(),this.updateTools(e),this.updateHighlighters(!0),i=!0,t=this.removeFlag(t,[Bc.RENDER,Bc.UPDATE,Bc.RESIZE,Bc.TRANSLATE,Bc.ROTATE,Bc.PORTS,Bc.TOOLS]);else{let r=!1;this.hasFlag(t,Bc.RESIZE)&&(this.resize(e),r=!0,t=this.removeFlag(t,[Bc.RESIZE,Bc.UPDATE]),n&&(t=this.removeFlag(t,Bc.PORTS))),this.hasFlag(t,Bc.UPDATE)&&(this.update(this.model,null,e),t=this.removeFlag(t,Bc.UPDATE),r=!0,n&&(t=this.removeFlag(t,Bc.PORTS))),this.hasFlag(t,Bc.TRANSLATE)&&(this.translate(),t=this.removeFlag(t,Bc.TRANSLATE),i=!0),this.hasFlag(t,Bc.ROTATE)&&(this.rotate(),t=this.removeFlag(t,Bc.ROTATE),i=!0),this.hasFlag(t,Bc.PORTS)&&(this._renderPorts(),r=!0,t=this.removeFlag(t,Bc.PORTS)),r&&this.updateHighlighters(!1)}return i&&this.transformHighlighters(),this.hasFlag(t,Bc.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,Bc.TOOLS)),t},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();const{useCSSSelectors:n}=this;n&&this._removePorts();var i=this.model,r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new me(i.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:e===r?null:e}),n&&this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.ElementView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el),n=this.selectors=e.selectors;this.rotatableNode=An(n[this.rotatableSelector])||null,this.scalableNode=An(n[this.scalableSelector])||null,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(An(t)),this.rotatableNode=e.findOne(".rotatable"),this.scalableNode=e.findOne(".scalable"),(this.selectors={})[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate()):this.updateTransformation(),this.useCSSSelectors||this._renderPorts(),this},resize:function(t){if(this.scalableNode)return this.sgResize(t);this.model.attributes.angle&&this.rotate(),this.update()},translate:function(){if(this.rotatableNode)return this.rgTranslate();this.updateTransformation()},rotate:function(){if(this.rotatableNode)return this.rgRotate(),void this.update();this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var t=this.model.attributes.position;return"translate("+t.x+","+t.y+")"},getRotateString:function(){var t=this.model.attributes,e=t.angle;if(!e)return null;var n=t.size;return"rotate("+e+","+n.width/2+","+n.height/2+")"},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(t){var e=this.model,n=e.angle(),i=e.size(),r=this.scalableNode,o=!1;r.node.getElementsByTagName("path").length>0&&(o=!0);var s=r.getBBox({recursive:o}),a=i.width/(s.width||1),l=i.height/(s.height||1);r.attr("transform","scale("+a+","+l+")");var c=this.rotatableNode,h=c&&c.attr("transform");if(h){c.attr("transform",h+" rotate("+-n+","+i.width/2+","+i.height/2+")");var u=r.getBBox({target:this.paper.cells});e.set("position",{x:u.x,y:u.y},io({updateHandled:!0},t)),this.translate(),this.rotate()}this.update()},prepareEmbedding:function(t={}){const e=t.model||this.model,n=(t.paper||this.paper).model,i=t.initialZIndices={},r=e.getEmbeddedCells({deep:!0}),o=n.getConnectedLinks(e,{deep:!0,includeEnclosed:!0});[e,...r,...o].forEach((t=>i[t.id]=t.attributes.z)),e.startBatch("to-front"),e.toFront({deep:!0,ui:!0});const s=n.getElements().reduce(((t,e)=>Math.max(t,e.attributes.z||0)),0);o.forEach((t=>{t.attributes.z<=s&&t.set("z",s+1,{ui:!0})})),e.stopBatch("to-front");const a=e.parent();a?(n.getCell(a).unembed(e,{ui:!0}),t.initialParentId=a):t.initialParentId=null},processEmbedding:function(t={},e,n,i){const r=t.model||this.model,o=t.paper||this.paper,s=o.model,{findParentBy:a,frontParentOnly:l,validateEmbedding:c}=o.options;let h;h=go(a)?vo(a.call(s,this,e,n,i)):"pointer"===a?vo(s.findModelsFromPoint({x:n,y:i})):s.findModelsUnderElement(r,{searchBy:a}),h=h.filter((t=>t instanceof al&&r.id!==t.id&&!t.isEmbeddedIn(r))),l&&(h=h.slice(-1));let u=null;const d=t.candidateEmbedView;for(let t=h.length-1;t>=0;t--){const e=h[t];if(d&&d.model.id==e.id){u=d;break}{const t=e.findView(o);if(!go(c)||c.call(o,this,t)){u=t;break}}}u&&u!=d&&(this.clearEmbedding(t),t.candidateEmbedView=u.highlight(u.findProxyNode(null,"container"),{embedding:!0})),!u&&d&&this.clearEmbedding(t)},clearEmbedding:function(t){t||(t={});var e=t.candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t={}){const e=t.candidateEmbedView,n=t.model||this.model,i=t.paper||this.paper;if(e)e.model.embed(n,{ui:!0}),e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null;else{const{validateUnembedding:e}=i.options,{initialParentId:n}=t;if(n&&"function"==typeof e&&!e.call(i,this))return void this._disallowUnembed(t)}i.model.getConnectedLinks(n,{deep:!0}).forEach((t=>{t.reparent({ui:!0})}))},_disallowUnembed:function(t){const{model:e,whenNotAllowed:n="revert"}=t,i=e||this.model,r=(t.paper||this.paper).model;switch(n){case"remove":i.remove({ui:!0});break;case"revert":{const{initialParentId:e,initialPosition:n,initialZIndices:o}=t;if(n){const{x:t,y:e}=n;i.position(t,e,{deep:!0,ui:!0})}o&&Object.keys(o).forEach((t=>{const e=r.getCell(t);e&&e.set("z",o[t],{ui:!0})}));const s=r.getCell(e);s&&s.embed(i,{ui:!0});break}}},getDelegatedView:function(){for(var t=this,e=t.model,n=t.paper;t&&!e.isLink();){if(!e.isEmbedded()||t.can("stopDelegation"))return t;e=e.getParentCell(),t=n.findViewByModel(e)}return null},findProxyNode:function(t,e){t||(t=this.el);const n=t.getAttribute(`${e}-selector`);if(n){const e=this.findAttribute("port",t);if(e){const t=this.findPortNode(e,n);if(t)return t}else{const t=this.findNode(n);if(t)return t}}return t},notifyPointerdown(t,e,n){Rc.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove(t,e,n){Rc.prototype.pointermove.call(this,t,e,n),this.notify("element:pointermove",t,e,n)},notifyPointerup(t,e,n){this.notify("element:pointerup",t,e,n),Rc.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){Rc.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){Rc.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){Rc.prototype.contextmenu.apply(this,arguments),this.notify("element:contextmenu",t,e,n)},pointerdown:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragStart(t,e,n)},pointermove:function(t,e,n){const i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointermove(t,r,e,n),o){case Dc:this.dragMagnet(t,e,n);break;case Ic:(s||this).drag(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){const i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointerup(t,r,e,n),o){case Dc:this.dragMagnetEnd(t,e,n);break;case Ic:(s||this).dragEnd(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){Rc.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){Rc.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){Rc.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){Rc.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){Rc.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,n,i)},onmagnet:function(t,e,n){const{currentTarget:i}=t;this.magnetpointerdown(t,i,e,n),this.eventData(t,{targetMagnet:i}),this.dragMagnetStart(t,e,n)},magnetpointerdown:function(t,e,n,i){this.notify("element:magnet:pointerdown",t,e,n,i)},magnetpointermove:function(t,e,n,i){this.notify("element:magnet:pointermove",t,e,n,i)},magnetpointerup:function(t,e,n,i){this.notify("element:magnet:pointerup",t,e,n,i)},magnetpointerdblclick:function(t,e,n,i){this.notify("element:magnet:pointerdblclick",t,e,n,i)},magnetcontextmenu:function(t,e,n,i){this.notify("element:magnet:contextmenu",t,e,n,i)},dragStart:function(t,e,n){if(this.isDefaultInteractionPrevented(t))return;var i=this.getDelegatedView();if(!i||!i.can("elementMove"))return;this.eventData(t,{action:Ic,delegatedView:i});const r=i.model.position();i.eventData(t,{initialPosition:r,pointerOffset:r.difference(e,n),restrictedArea:this.paper.getRestrictedArea(i,e,n)})},dragMagnetStart:function(t,e,n){const{paper:i}=this,r=t.isPropagationStopped();if(r&&this.eventData(t,{preventPointerEvents:!0}),this.isDefaultInteractionPrevented(t)||!this.can("addLinkFromMagnet"))return;const{targetMagnet:o=t.currentTarget}=this.eventData(t);t.stopPropagation(),i.options.validateMagnet.call(i,this,o,t)?(i.options.magnetThreshold<=0&&this.dragLinkStart(t,o,e,n),this.eventData(t,{action:Dc})):r?this.dragStart(t,e,n):this.pointerdown(t,e,n)},drag:function(t,e,n){var i=this.paper,r=i.options.gridSize,o=this.model,s=this.eventData(t),{pointerOffset:a,restrictedArea:l,embedding:c}=s,h=Mt(e+a.x,r),u=Mt(n+a.y,r);o.position(h,u,{restrictedArea:l,deep:!0,ui:!0}),i.options.embeddingMode&&(c||(this.prepareEmbedding(s),c=!0),this.processEmbedding(s,t,e,n)),this.eventData(t,{embedding:c})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){var i=this.eventData(t);i.embedding&&this.finalizeEmbedding(i)},dragMagnetEnd:function(t,e,n){this.dragLinkEnd(t,e,n)},magnetpointerclick:function(t,e,n,i){var r=this.paper;r.eventData(t).mousemoved>r.options.clickThreshold||this.notify("element:magnet:pointerclick",t,e,n,i)}},{Flags:Bc});io(Vc.prototype,zl);const zc=function(t,e,n){return t},jc=function(t,e,n){var i,r,o,s=e.side||"bottom",a=Qs(e.padding||40),l=n.sourceBBox,c=n.targetBBox,h=l.center(),u=c.center();switch(s){case"bottom":o=1,i="y",r="height";break;case"top":o=-1,i="y",r="height";break;case"left":o=-1,i="x",r="width";break;case"right":o=1,i="x",r="width";break;default:throw new Error("Router: invalid side")}return h[i]+=o*(l[r]/2+a[s]),u[i]+=o*(c[r]/2+a[s]),o*(h[i]-u[i])>0?u[i]=h[i]:h[i]=u[i],[h].concat(t,u)};var $c={N:"S",S:"N",E:"W",W:"E"},Uc={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function Gc(t,e,n){var i=new Jt(t.x,e.y);return n.containsPoint(i)&&(i=new Jt(e.x,t.y)),i}function qc(t,e){return t["W"===e||"E"===e?"width":"height"]}function Hc(t,e){return t.x===e.x?t.y>e.y?"N":"S":t.y===e.y?t.x>e.x?"W":"E":null}function Wc(t){return new me(t.x,t.y,0,0)}function Yc(t){var e=Qs(t.padding||t.elementPadding||20);return{x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}function Xc(t,e){return t.sourceBBox.clone().moveAndExpand(Yc(e))}function Zc(t,e){return t.targetBBox.clone().moveAndExpand(Yc(e))}function Kc(t,e,n){var i=new Jt(t.x,e.y),r=new Jt(e.x,t.y),o=Hc(t,i),s=Hc(t,r),a=$c[n],l=o===n||o!==a&&(s===a||s!==n)?i:r;return{points:[l],direction:Hc(l,e)}}function Jc(t,e,n){var i=Gc(t,e,n);return{points:[i],direction:Hc(i,e)}}function Qc(t,e,n,i){var r,o={},s=[new Jt(t.x,e.y),new Jt(e.x,t.y)],a=s.filter((function(t){return!n.containsPoint(t)})),l=a.filter((function(e){return Hc(e,t)!==i}));if(l.length>0)r=(r=l.filter((function(e){return Hc(t,e)===i})).pop())||l[0],o.points=[r],o.direction=Hc(r,e);else{r=xo(s,a)[0];var c=new Jt(e).move(r,-qc(n,i)/2),h=Gc(c,t,n);o.points=[h,c],o.direction=Hc(c,e)}return o}function th(t,e,n,i){var r=Jc(e,t,i),o=r.points[0];if(n.containsPoint(o)){var s=(r=Jc(t,e,n)).points[0];if(i.containsPoint(s)){var a=new Jt(t).move(s,-qc(n,Hc(t,s))/2),l=new Jt(e).move(o,-qc(i,Hc(e,o))/2),c=new ne(a,l).midpoint(),h=Jc(t,c,n),u=Kc(c,e,h.direction);r.points=[h.points[0],u.points[0]],r.direction=u.direction}}return r}function eh(t,e,n,i,r){var o,s,a,l={},c=n.union(i).inflate(1),h=c.center().distance(e)>c.center().distance(t),u=h?e:t,d=h?t:e;return r?(o=Jt.fromPolar(c.width+c.height,Uc[r],u),o=c.pointNearestToPoint(o).move(o,-1)):o=c.pointNearestToPoint(u).move(u,1),s=Gc(o,d,c),o.round().equals(s.round())?(s=Jt.fromPolar(c.width+c.height,Nt(o.theta(u))+Math.PI/2,d),a=Gc(o,s=c.pointNearestToPoint(s).move(d,1).round(),c),l.points=h?[s,a,o]:[o,a,s]):l.points=h?[s,o]:[o,s],l.direction=Hc(h?o:s,e),l}function nh(t,e,n){var i,r=Xc(n,e),o=Zc(n,e),s=function(t,e){return t.sourceAnchor?t.sourceAnchor:Xc(t,e).center()}(n,e),a=function(t,e){return t.targetAnchor?t.targetAnchor:Zc(t,e).center()}(n,e);r=r.union(Wc(s)),o=o.union(Wc(a)),(t=vo(t).map(Jt)).unshift(s),t.push(a);for(var l=[],c=0,h=t.length-1;c<h;c++){var u=null,d=t[c],f=t[c+1],p=!!Hc(d,f);if(0===c)c+1===h?r.intersect(o.clone().inflate(1))?u=eh(d,f,r,o):p||(u=th(d,f,r,o)):r.containsPoint(f)?u=eh(d,f,r,Wc(f).moveAndExpand(Yc(e))):p||(u=Jc(d,f,r));else if(c+1===h){var g=p&&Hc(f,d)===i;o.containsPoint(d)||g?u=eh(d,f,Wc(d).moveAndExpand(Yc(e)),o,i):p||(u=Qc(d,f,o,i))}else p||(u=Kc(d,f,i));u?(Array.prototype.push.apply(l,u.points),i=u.direction):i=Hc(d,f),c+1<h&&l.push(f)}return l}var ih={step:10,maximumLoops:2e3,precision:1,maxAllowedDirectionChange:90,perpendicular:!0,excludeEnds:[],excludeTypes:[],startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}},cost:function(){return this.step},directions:function(){var t=this.step,e=this.cost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:-t,offsetY:0,cost:e},{offsetX:0,offsetY:t,cost:e},{offsetX:0,offsetY:-t,cost:e}]},penalties:function(){return{0:0,45:this.step/2,90:this.step/2}},paddingBox:function(){var t=this.step;return{x:-t,y:-t,width:2*t,height:2*t}},isPointObstacle:null,fallbackRouter:function(t,e,n){if(!go(nh))throw new Error("Manhattan requires the orthogonal router as default fallback.");return nh(t,io({},ih,e),n)},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function rh(t){this.map={},this.options=t,this.mapGridSize=100}function oh(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function sh(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function ah(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function lh(t,e){return t.sourceAnchor?t.sourceAnchor:sh(t,e).center()}function ch(t,e,n,i,r){var o=360/n,s=t.theta(function(t,e,n,i){var r=i.step,o=e.x-t.x,s=e.y-t.y,a=o/n.x*r,l=s/n.y*r;return new Jt(t.x+a,t.y+l)}(t,e,i,r)),a=Ct(s+o/2);return o*Math.floor(a/o)}function hh(t,e){var n=Math.abs(t-e);return n>180?360-n:n}function uh(t,e){if(!t)return e;var n=Math.abs(t),i=Math.round(n/e);return i?e+(n-i*e)/i:n}function dh(t,e){return t.round(e)}function fh(t,e,n){return dh(function(t,e){var n=e.source,i=Mt(t.x-n.x,e.x)+n.x,r=Mt(t.y-n.y,e.y)+n.y;return new Jt(i,r)}(t.clone(),e),n)}function ph(t){return t.clone().toString()}function gh(t){return new Jt(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function mh(t,e,n,i,r,o,s){for(var a,l=[],c=gh(r.difference(n)),h=ph(n),u=t[h];u;){var d=gh((a=e[h]).difference(u));d.equals(c)||(l.unshift(a),c=d),u=t[h=ph(u)]}var f=e[h];return gh(f.difference(i)).equals(c)||l.unshift(f),l}function vh(t,e){for(var n=1/0,i=0,r=e.length;i<r;i++){var o=t.manhattanDistance(e[i]);o<n&&(n=o)}return n}function yh(t,e,n,i,r){var o=r.precision,s=r.directionMap,a=t.difference(e.center()),l=to(s)?Object.keys(s):[],c=vo(n),h=l.reduce((function(n,r){if(c.includes(r)){for(var l,h=s[r],u=new Jt(t.x+h.x*(Math.abs(a.x)+e.width),t.y+h.y*(Math.abs(a.y)+e.height)),d=new ne(t,u).intersect(e)||[],f=d.length,p=null,g=0;g<f;g++){var m=d[g],v=t.squaredDistance(m);(void 0===l||v>l)&&(l=v,p=m)}if(p){var y=fh(p,i,o);e.containsPoint(y)&&(y=fh(y.offset(h.x*i.x,h.y*i.y),i,o)),n.push(y)}}return n}),[]);return e.containsPoint(t)||h.push(fh(t,i,o)),h}function bh(t,e,n,i){var r,o,s=i.precision;r=dh(t instanceof me?lh(this,i).clone():t.clone(),s),o=dh(e instanceof me?function(t,e){return t.targetAnchor?t.targetAnchor:ah(t,e).center()}(this,i).clone():e.clone(),s);var a,l,c,h,u,d,f,p=(a=i.step,c=o,{source:(l=r).clone(),x:uh(c.x-l.x,a),y:uh(c.y-l.y,a)});if(d=t instanceof me?yh(h=r,t,i.startDirections,p,i):[h=r],e instanceof me?(u=o,f=yh(o,e,i.endDirections,p,i)):f=[u=o],d=d.filter((t=>!n(t))),f=f.filter((t=>!n(t))),d.length>0&&f.length>0){for(var g=new oh,m={},v={},y={},b=0,w=d.length;b<w;b++){var x=d[b],A=ph(x);g.add(A,vh(x,f)),m[A]=x,y[A]=0}var T,E,S=i.previousDirectionAngle,P=void 0===S,_=i.directions;!function(t,e,n){var i=n.step;vo(n.directions).forEach((function(t){t.gridOffsetX=t.offsetX/i*e.x,t.gridOffsetY=t.offsetY/i*e.y}))}(0,p,i);for(var k=_.length,L=vo(f).reduce((function(t,e){var n=ph(e);return t.push(n),t}),[]),C=i.maximumLoops;!g.isEmpty()&&C>0;){var M,O=g.pop(),N=m[O],R=v[O],F=y[O],B=void 0===R,I=N.equals(h);M=B?P?I?null:ch(h,N,k,p,i):S:ch(R,N,k,p,i);var D=d.length===f.length;if(D)for(var V=0;V<d.length;V++)if(!d[V].equals(f[V])){D=!1;break}if((!B||!D)&&L.indexOf(O)>=0)return i.previousDirectionAngle=M,mh(v,m,N,h,u);for(b=0;b<k;b++){var z=(T=_[b]).angle;if(E=hh(M,z),P&&I||!(E>i.maxAllowedDirectionChange)){var j=fh(N.clone().offset(T.gridOffsetX,T.gridOffsetY),p,s),$=ph(j);if(!g.isClose($)&&!n(j)){if(L.indexOf($)>=0&&!j.equals(u)&&hh(z,ch(j,u,k,p,i))>i.maxAllowedDirectionChange)continue;var U=F+T.cost+(I?0:i.penalties[E]);(!g.isOpen($)||U<y[$])&&(m[$]=j,v[$]=N,y[$]=U,g.add($,U+vh(j,f)))}}}C--}}return i.fallbackRoute.call(this,h,u,i)}rh.prototype.build=function(t,e){var n=this.options,i=vo(n.excludeEnds).reduce((function(n,i){var r=e.get(i);if(r){var o=t.getCell(r.id);o&&n.push(o)}return n}),[]),r=[],o=t.getCell(e.get("source").id);o&&(r=Ao(r,o.getAncestors().map((function(t){return t.id}))));var s=t.getCell(e.get("target").id);s&&(r=Ao(r,s.getAncestors().map((function(t){return t.id}))));var a=this.mapGridSize;return t.getElements().reduce((function(t,e){var o=vo(n.excludeTypes).includes(e.get("type")),s=i.find((function(t){return t.id===e.id})),l=r.includes(e.id);if(!(o||s||l))for(var c=e.getBBox().moveAndExpand(n.paddingBox),h=c.origin().snapToGrid(a),u=c.corner().snapToGrid(a),d=h.x;d<=u.x;d+=a)for(var f=h.y;f<=u.y;f+=a){var p=d+"@"+f;t[p]=t[p]||[],t[p].push(c)}return t}),this.map),this},rh.prototype.isPointAccessible=function(t){var e=t.clone().snapToGrid(this.mapGridSize).toString();return vo(this.map[e]).every((function(e){return!e.containsPoint(t)}))},oh.prototype.add=function(t,e){this.hash[t]?this.items.splice(this.items.indexOf(t),1):this.hash[t]=this.OPEN,this.values[t]=e;var n=lo(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(n,0,t)},oh.prototype.remove=function(t){this.hash[t]=this.CLOSE},oh.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},oh.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},oh.prototype.isEmpty=function(){return 0===this.items.length},oh.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};const wh=function(t,e,n){return function(t,e,n){!function(t){if(t.directions=Eo(t,"directions"),t.penalties=Eo(t,"penalties"),t.paddingBox=Eo(t,"paddingBox"),t.padding=Eo(t,"padding"),t.padding){var e=Qs(t.padding);t.paddingBox={x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}vo(t.directions).forEach((function(t){var e=new Jt(0,0),n=new Jt(t.offsetX,t.offsetY);t.angle=Ct(e.theta(n))}))}(e),n.options.perpendicular=!!e.perpendicular;var i=sh(n,e),r=ah(n,e),o=lh(n,e);let s;if("function"==typeof e.isPointObstacle)s=e.isPointObstacle;else{const t=new rh(e);t.build(n.paper.model,n.model),s=e=>!t.isPointAccessible(e)}for(var a,l,c=vo(t).map(Jt),h=[],u=o,d=0,f=c.length;d<=f;d++){var p=null;if(l=a||i,!(a=c[d])&&(a=r,(!n.model.get("source").id||!n.model.get("target").id)&&go(e.draggingRoute))){var g=l===i?o:l,m=a.origin();p=e.draggingRoute.call(n,g,m,e)}if(null===(p=p||bh.call(n,l,a,s,e)))return e.fallbackRouter(t,e,n);var v=p[0];v&&v.equals(u)&&p.shift(),u=p[p.length-1]||u,Array.prototype.push.apply(h,p)}return h}(t,io({},ih,e),n)};var xh={maxAllowedDirectionChange:45,diagonalCost:function(){var t=this.step;return Math.ceil(Math.sqrt(t*t<<1))},directions:function(){var t=this.step,e=this.cost(),n=this.diagonalCost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:t,offsetY:t,cost:n},{offsetX:0,offsetY:t,cost:e},{offsetX:-t,offsetY:t,cost:n},{offsetX:-t,offsetY:0,cost:e},{offsetX:-t,offsetY:-t,cost:n},{offsetX:0,offsetY:-t,cost:e},{offsetX:t,offsetY:-t,cost:n}]},fallbackRoute:function(t,e,n){var i=t.theta(e),r=[],o={x:e.x,y:t.y},s={x:t.x,y:e.y};if(i%180>90){var a=o;o=s,s=a}var l=i%90<45?o:s,c=new ne(t,l),h=90*Math.ceil(i/90),u=Jt.fromPolar(c.squaredLength(),Nt(h+135),l),d=new ne(e,u),f=c.intersection(d),p=f||e,g=f?p:t,m=360/n.directions.length,v=g.theta(e),y=Ct(v+m/2),b=m*Math.floor(y/m);return n.previousDirectionAngle=b,p&&r.push(p.round()),r.push(e),r}};const Ah=function(t,e,n){if(!go(wh))throw new Error("Metro requires the manhattan router.");return wh(t,io({},xh,e),n)},Th={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},Eh=[Th.LEFT,Th.RIGHT,Th.TOP,Th.BOTTOM],Sh={[Th.LEFT]:Th.RIGHT,[Th.RIGHT]:Th.LEFT,[Th.TOP]:Th.BOTTOM,[Th.BOTTOM]:Th.TOP},Ph=[Th.TOP,Th.BOTTOM],_h={0:Th.RIGHT,180:Th.LEFT,270:Th.TOP,90:Th.BOTTOM};function kh(t){return t.angle()}function Lh(t){return new xe(t).simplify({threshold:1}).points}function Ch(t,e){const{point:n,x0:i,y0:r,view:o,bbox:s,direction:a}=t,{point:l,x0:c,y0:h,view:u,bbox:d,direction:f}=e;let p,g;if(o)p=o.model.isLink()?Mh(l,n,o):a===Th.ANCHOR_SIDE?s.sideNearestToPoint(n):a===Th.MAGNET_SIDE?o.model.getBBox().sideNearestToPoint(n):a;else{const t=new me(i,r,0,0);p=Eh.includes(a)?a:t.sideNearestToPoint(l)}if(u)g=u.model.isLink()?Mh(n,l,u):f===Th.ANCHOR_SIDE?d.sideNearestToPoint(l):f===Th.MAGNET_SIDE?u.model.getBBox().sideNearestToPoint(l):f;else{const t=new me(c,h,0,0);g=Eh.includes(f)?f:t.sideNearestToPoint(n)}return[p,g]}function Mh(t,e,n){const i=n.getTangentAtLength(n.getClosestPointLength(e)),r=90*Math.round(kh(i)/90);if(r%180==0&&t.y===e.y)return t.x<e.x?Th.LEFT:Th.RIGHT;if(t.x===e.x)return t.y<e.y?Th.TOP:Th.BOTTOM;switch(r){case 0:case 180:case 360:return t.y<e.y?Th.TOP:Th.BOTTOM;case 90:case 270:return t.x<e.x?Th.LEFT:Th.RIGHT}}function Oh(t,e,n,i,r,o,s){i===Th.AUTO&&(i=r?Th.MAGNET_SIDE:Th.ANCHOR_SIDE);const a=t&&t.model.isElement(),{x:l,y:c,width:h=0,height:u=0}=a?me.fromRectUnion(n,t.model.getBBox()):o;return{point:e,x0:l,y0:c,view:t,bbox:n,width:h,height:u,direction:i,margin:a?s:0}}function Nh({x:t,y:e}){const n=new Jt(t,e);return{point:n,x0:n.x,y0:n.y,view:null,bbox:new me(t,e,0,0),width:0,height:0,direction:null,margin:0}}function Rh(t,e,n){const i=e.point.clone(),{x0:r,y0:o,width:s,height:a}=e;switch(t){case"left":i.x=r-n;break;case"right":i.x=r+s+n;break;case"top":i.y=o-n;break;case"bottom":i.y=o+a+n}return i}function Fh(t,e,n={}){const{point:i,x0:r,y0:o,width:s,height:a,margin:l}=t,{point:c,x0:h,y0:u,width:d,height:f,margin:p}=e,{targetInSourceBBox:g=!1}=n,m=h+d,v=u+f,y=r+s,b=o+a,w=r-l,x=y+l,A=o-l,T=b+l,E=h-p,S=m+p,P=u-p,_=v+p,[k,L]=Ch(t,e),C=Rh(k,{point:i,x0:r,y0:o,width:s,height:a},l),M=Rh(L,{point:c,x0:h,y0:u,width:d,height:f},p),{x:O,y:N}=C,{x:R,y:F}=M,B=((r+y)/2<(h+m)/2?y+h:m+r)/2,I=((o+b)/2<(u+v)/2?b+u:v+o)/2,D=new me(r,o,s,a),V=new me(h,u,d,f),z=D.clone().inflate(l),j=V.clone().inflate(p);if("left"===k&&"right"===L){if(w<=S){let t=I;return O<=E&&(v>=A&&F<N?t=Math.min(P,A):u<=T&&F>=N&&(t=Math.max(_,T))),[{x:O,y:N},{x:O,y:t},{x:R,y:t},{x:R,y:F}]}const t=(O+R)/2;return[{x:t,y:N},{x:t,y:F}]}if("right"===k&&"left"===L){if(O>=E){let t=I;return O>m&&(v>=A&&F<N?t=Math.min(P,A):u<=T&&F>=N&&(t=Math.max(_,T))),[{x:O,y:N},{x:O,y:t},{x:R,y:t},{x:R,y:F}]}const t=(O+R)/2;return[{x:t,y:N},{x:t,y:F}]}if("top"===k&&"bottom"===L){const t=wn.rectWithRect(z,V);if(N<F){let e=B,n=N;return t&&(n=Math.min(n,P)),m>=w&&R<O?e=Math.min(E,w):h<=x&&R>=O&&(e=Math.max(S,x)),[{x:O,y:n},{x:e,y:n},{x:e,y:F},{x:R,y:F}]}const e=(N+F)/2;return[{x:O,y:e},{x:R,y:e}]}if("bottom"===k&&"top"===L){const t=wn.rectWithRect(z,V);if(N>F){let e=B,n=N;return t&&(n=Math.max(n,_)),m>=w&&R<O?e=Math.min(E,w):h<=x&&R>=O&&(e=Math.max(S,x)),[{x:O,y:n},{x:e,y:n},{x:e,y:F},{x:R,y:F}]}const e=(N+F)/2;return[{x:O,y:e},{x:R,y:e}]}if("top"===k&&"top"===L){if(g||wn.rectWithRect(z,V)||N<=u&&(z.bottomRight().x<=R||z.bottomLeft().x>=R)||N>=u&&(j.bottomRight().x<=O||j.bottomLeft().x>=O))return[{x:O,y:Math.min(N,F)},{x:R,y:Math.min(N,F)}];let t,e=Math.min((b+u)/2,F),n=Math.min((o+v)/2,N);return t=F<N?R>O?Math.min(O,E):Math.max(O,S):R>=O?Math.max(R,x):Math.min(R,w),[{x:O,y:n},{x:t,y:n},{x:t,y:e},{x:R,y:e}]}if("bottom"===k&&"bottom"===L){if(g||wn.rectWithRect(z,V)||N>=F&&(z.topRight().x<=R||z.topLeft().x>=R)||N<=F&&(j.topRight().x<=O||j.topLeft().x>=O))return[{x:O,y:Math.max(N,F)},{x:R,y:Math.max(N,F)}];let t,e=Math.max((o+v)/2,F),n=Math.max((b+u)/2,N);return t=F>N?R>O?Math.min(O,E):Math.max(O,S):R>=O?Math.max(R,x):Math.min(R,w),[{x:O,y:n},{x:t,y:n},{x:t,y:e},{x:R,y:e}]}if("left"===k&&"left"===L){if(g||wn.rectWithRect(z,V)||O<=R&&(z.bottomRight().y<=F||z.topRight().y>=F)||O>=R&&(j.bottomRight().y<=N||j.topRight().y>=N))return[{x:Math.min(O,R),y:N},{x:Math.min(O,R),y:F}];let t,e=Math.min((y+h)/2,R),n=Math.min((r+m)/2,O);return t=R>O?F<=N?Math.min(A,F):Math.max(T,F):F>=N?Math.min(P,N):Math.max(_,N),[{x:n,y:N},{x:n,y:t},{x:e,y:t},{x:e,y:F}]}if("right"===k&&"right"===L){if(g||wn.rectWithRect(z,V)||O>=R&&(z.bottomLeft().y<=F||z.topLeft().y>=F)||O<=R&&(j.bottomLeft().y<=N||j.topLeft().y>=N))return[{x:Math.max(O,R),y:N},{x:Math.max(O,R),y:F}];let t,e=Math.max((r+m)/2,R),n=Math.max((y+h)/2,O);return t=R<=O?F<=N?Math.min(A,F):Math.max(T,F):F>=N?Math.min(P,N):Math.max(_,N),[{x:n,y:N},{x:n,y:t},{x:e,y:t},{x:e,y:F}]}if("top"===k&&"right"===L){if(z.containsPoint(c)){if(O<=S){const t=Math.max(O+l,R),e=Math.min(A,P);return[{x:O,y:e},{x:t,y:e},{x:t,y:F}]}const t=(O-l+R)/2;return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if(A>F){if(O<R){let t=P;return _<=A&&S>=O&&(t=I),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.max(B,S);if(O>R&&b>=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t>w&&N<v){const t=Math.min(A,P),e=Math.max(x,S);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("top"===k&&"left"===L){if(z.containsPoint(c)){if(O>=E){const t=Math.min(O-l,R),e=Math.min(A,P);return[{x:O,y:e},{x:t,y:e},{x:t,y:F}]}const t=(O+l+R)/2;return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if(A>F){if(O>R){let t=P;return _<=A&&E<=O&&(t=I),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.min(E,B);if(O<R&&b>=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t<x&&N<v){const t=Math.min(A,P),e=Math.min(w,E);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("bottom"===k&&"right"===L){if(z.containsPoint(c)){if(O<=S){const t=Math.max(O+l,R),e=Math.max(T,_);return[{x:O,y:e},{x:t,y:e},{x:t,y:F}]}const t=(O-l+R)/2;return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if(T<F){if(O<R){let t=_;return P>=T&&S>=O&&(t=I),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.max(B,S);if(O>R&&o<=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t>w&&N>u){const t=Math.max(T,_),e=Math.max(x,S);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("bottom"===k&&"left"===L){if(z.containsPoint(c)){if(O>=E){const t=Math.min(O-l,R),e=Math.max(T,_);return[{x:O,y:e},{x:t,y:e},{x:t,y:F}]}const t=(O+l+R)/2;return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if(T<F){if(O>R){let t=_;return P>=T&&E<=O&&(t=I),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.min(E,B);if(O<R&&o<=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t<x&&N>u){const t=Math.max(T,_),e=Math.min(w,E);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("left"===k&&"bottom"===L){if(z.containsPoint(c)){if(N<=_){const t=Math.min(w,E),e=Math.max(N+l,F);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}const t=(N-l+F)/2;return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if(w>R){if(N<F){let t=E;return S<=w&&_>=N&&(t=B),[{x:t,y:N},{x:t,y:F},{x:R,y:F}]}return[{x:R,y:N}]}const t=Math.max(_,I);if(N>F&&y>=R)return[{x:O,y:N},{x:O,y:t},{x:R,y:t}];if(t>A&&O<m){const t=Math.min(w,E),e=Math.max(T,_);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if("left"===k&&"top"===L){if(z.containsPoint(c)){if(N>=P){const t=Math.min(N-l,F),e=Math.min(w,E);return[{x:e,y:N},{x:e,y:t},{x:R,y:t}]}const t=(N+l+F)/2;return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if(w>R){if(N>F){let t=E;return S<=w&&P<=N&&(t=B),[{x:t,y:N},{x:t,y:F},{x:R,y:F}]}return[{x:R,y:N}]}const t=Math.min(P,I);if(N<F&&y>=R)return[{x:O,y:N},{x:O,y:t},{x:R,y:t}];if(t<T&&O<m){const t=Math.min(w,E),e=Math.min(A,P);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if("right"===k&&"top"===L){if(z.containsPoint(c)){if(N>=P){const t=Math.max(x,S),e=Math.min(N-l,F);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}const t=(N+l+F)/2;return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if(x<R){if(N>F){let t=S;return E>=x&&P<=N&&(t=B),[{x:t,y:N},{x:t,y:F},{x:R,y:F}]}return[{x:R,y:N}]}const t=Math.min(P,I);if(N<F&&r<=R)return[{x:O,y:N},{x:O,y:t},{x:R,y:t}];if(t<T&&O>h){const t=Math.max(x,S),e=Math.min(A,P);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if("right"===k&&"bottom"===L){if(z.containsPoint(c)){if(N<=_){const t=Math.max(x,S),e=Math.max(N+l,F);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}const t=(N-l+F)/2;return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if(x<R){if(N<F){let t=S;return E>=x&&_>=N&&(t=B),[{x:t,y:N},{x:t,y:F},{x:R,y:F}]}return[{x:R,y:N}]}const t=Math.max(_,I);if(N>F&&r<=R)return[{x:O,y:N},{x:O,y:t},{x:R,y:t}];if(t>A&&O>h){const t=Math.max(x,S),e=Math.max(T,_);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}}function Bh(t,e,n){const{sourceDirection:i=Th.AUTO,targetDirection:r=Th.AUTO}=e,o=e.margin||20,s=e.useVertices||!1,a=!!n.model.source().port,l=Oh(n.sourceView,n.sourceAnchor,n.sourceBBox,i,a,n.sourceAnchor,o),c=!!n.model.target().port,h=Oh(n.targetView,n.targetAnchor,n.targetBBox,r,c,n.targetAnchor,o);let u=[];if(!s||0===t.length)return Lh(Fh(l,h));const d=t.map((t=>Nh(t))),[f]=d;if(l.view&&l.view.model.isElement()&&l.view.model.getBBox().inflate(o).containsPoint(f.point)){const[t]=Ch(l,f),e=t,n=Nh(l.point);n.margin=o,n.direction=t,f.direction=e,u.push(...Fh(n,f,{targetInSourceBBox:!0}),f.point)}else{const t=function(t,e,n){const[i]=Ch(t,e);switch(i){case Th.TOP:return function(t,e,n){const{x0:i,y0:r,width:o,height:s,point:a,margin:l}=t,c=r+s,h=i-l,u=i+o+l,d=r-l,{x:f}=a,{x0:p,y0:g}=e;return p===f&&g<r?Th.BOTTOM:p<f&&g<d?n.point.x===f?Th.BOTTOM:Th.RIGHT:p>f&&g<d?n.point.x===f?Th.BOTTOM:Th.LEFT:p<h&&g>=r||p>u&&g>=r?Th.TOP:p>=h&&p<=f&&g>c||p<=u&&p>=f&&g>c?n.point.x<p?Th.RIGHT:Th.LEFT:Th.TOP}(t,e,n);case Th.RIGHT:return function(t,e,n){const{y0:i,x0:r,width:o,height:s,point:a,margin:l}=t,c=r+o,h=c+l,u=i-l,d=i+s+l,{x:f,y:p}=a,{x0:g,y0:m}=e;return g>f&&m===p?Th.LEFT:g>=h&&m<p?Th.BOTTOM:g>=h&&m>p?Th.TOP:g<=c&&m<=u||g<=c&&m>=d?Th.RIGHT:g<r&&m>=u&&m<=p||g<r&&m<=d&&m>=p?n.point.y<m?Th.BOTTOM:Th.TOP:Th.RIGHT}(t,e,n);case Th.BOTTOM:return function(t,e,n){const{x0:i,y0:r,width:o,height:s,point:a,margin:l}=t,c=r+s,h=i-l,u=i+o+l,d=c+l,{x:f}=a,{x0:p,y0:g}=e;return p===f&&g>c?Th.TOP:p<f&&g>d?n.point.x===f?Th.TOP:Th.RIGHT:p>f&&g>d?n.point.x===f?Th.TOP:Th.LEFT:p<h&&g<=c||p>u&&g<=c?Th.BOTTOM:p>=h&&p<=f&&g<r||p<=u&&p>=f&&g<r?n.point.x<p?Th.RIGHT:Th.LEFT:Th.BOTTOM}(t,e,n);case Th.LEFT:return function(t,e,n){const{y0:i,x0:r,width:o,height:s,point:a,margin:l}=t,c=r+o,h=r-l,u=i-l,d=i+s+l,{x:f,y:p}=a,{x0:g,y0:m}=e;return g<f&&m===p?Th.RIGHT:g<=h&&m<p?Th.BOTTOM:g<=h&&m>p?Th.TOP:g>=r&&m<=u||g>=r&&m>=d?Th.LEFT:g>c&&m>=u&&m<=p||g>c&&m<=d&&m>=p?n.point.y<m?Th.BOTTOM:Th.TOP:Th.LEFT}(t,e,n)}}(l,f,d[1]||h);f.direction=t,u.push(...Fh(l,f),f.point)}for(let t=0;t<d.length-1;t++){const e=d[t],n=d[t+1],i=kh(new ne(e.point,n.point));if(i%90==0){const t=_h[i],r=Sh[t];if(t!==e.direction)u.push(e.point,n.point),n.direction=r;else{const t=Ct(i-90);let r=0,s=0;90===t?s=-o:180===t?r=-o:270===t?s=o:0===t&&(r=o);const a={x:e.point.x+r,y:e.point.y+s},l={x:n.point.x+r,y:n.point.y+s},c=new ne(n.point,l);n.direction=_h[kh(c)],u.push(e.point,a,l,n.point)}continue}const[r,s]=Ih(e,n);e.direction=r,n.direction=s,u.push(...Fh(e,n),n.point)}const p=d[d.length-1];if(h.view&&h.view.model.isElement())if(h.view.model.getBBox().inflate(o).containsPoint(p.point)){const[t]=Ih(p,h),e=Nh(h.point),[,n]=Ch(p,h);e.margin=o,e.direction=n,p.direction=t,u.push(...Fh(p,e))}else{const t=Lh(u),e=new ne(t[t.length-2],p.point),n=_h[Math.round(kh(e))];p.direction=n;let i=Fh(p,h);const[r,s]=Lh([...i,h.point]),a=new ne(r,s),l=Math.round(kh(a)),c=_h[l];c!==n&&n===Sh[c]&&(p.margin=o,i=Fh(p,h)),u.push(...i)}else{const[t]=Ih(p,h);p.direction=t,u.push(...Fh(p,h))}return Lh(u)}function Ih(t,e){const n=t.direction,i=Ph.includes(n);let r=t.direction,o=e.direction;if(i){const i=t.point.y>e.point.y,s=e.point.x-t.point.x;n===Th.BOTTOM?(r=i?Sh[n]:s>=0?Th.RIGHT:Th.LEFT,s>0?o=i?Th.LEFT:Th.TOP:s<0&&(o=i?Th.RIGHT:Th.TOP)):(r=i?s>=0?Th.RIGHT:Th.LEFT:Sh[n],s>0?o=i?Th.BOTTOM:Th.LEFT:s<0&&(o=i?Th.BOTTOM:Th.RIGHT))}else{const i=t.point.x>e.point.x,s=e.point.y-t.point.y;n===Th.RIGHT?(r=i?Sh[n]:s>=0?Th.BOTTOM:Th.TOP,s>0?o=i?Th.TOP:Th.LEFT:s<0&&(o=i?Th.BOTTOM:Th.LEFT)):(r=i?s>=0?Th.BOTTOM:Th.TOP:Sh[n],s>0?o=i?Th.RIGHT:Th.TOP:s<0&&(o=i?Th.RIGHT:Th.BOTTOM))}return[r,o]}Bh.Directions=Th;const Dh=Bh,Vh={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},zh=Object.values(Vh),jh=10,$h=1,Uh=function(t,e,n=[],i={}){const{cornerType:r=Vh.POINT,cornerRadius:o=jh,cornerPreserveAspectRatio:s=!1,precision:a=$h,raw:l=!1}=i;if(-1===zh.indexOf(r))throw new Error("Invalid `cornerType` provided to `straight` connector.");let c;if(r!==Vh.POINT&&o){let i;c=new Le,c.appendSegment(Le.createSegment("M",t));const l=n.length;for(let h=0;h<l;h++){const l=new Jt(n[h]),u=n[h-1]||t,d=n[h+1]||e,f=i||l.distance(u)/2;let p,g;i=l.distance(d)/2,s?p=g=-Math.min(o,f,i):(p=-Math.min(o,f),g=-Math.min(o,i));const m=l.clone().move(u,p).round(a),v=l.clone().move(d,g).round(a);switch(c.appendSegment(Le.createSegment("L",m)),r){case Vh.CUBIC:{const t=1/3,e=2/3,n=new Jt(t*m.x+e*l.x,e*l.y+t*m.y),i=new Jt(t*v.x+e*l.x,e*l.y+t*v.y);c.appendSegment(Le.createSegment("C",n,i,v));break}case Vh.LINE:c.appendSegment(Le.createSegment("L",v));break;case Vh.GAP:c.appendSegment(Le.createSegment("M",v))}}c.appendSegment(Le.createSegment("L",e))}else{const i=[t].concat(n).concat([e]),r=new xe(i);c=new Le(r)}return l?c:c.serialize()};var Gh=["arc","gap","cubic"],qh=["smooth"],Hh=1/3,Wh=2/3;function Yh(t,e){let{x:n,y:i}=t,{x:r,y:o}=e;if(n>r){let t=n;n=r,r=t,t=i,i=o,o=t}if(i>o){let t=n;n=r,r=t,t=i,i=o,o=t}return[new Jt(n,i),new Jt(r,o)]}function Xh(t,e,n){var i=[].concat(t,n,e);return i.reduce((function(t,e,n){var r=i[n+1];return null!=r&&(t[n]=ie(e,r)),t}),[])}function Zh(t,e){return ie(t,e).squaredLength()}function Kh(t,e,n,i){var r,o=new Le;return r=Le.createSegment("M",t[0].start),o.appendSegment(r),vo(t).forEach((function(s,a){if(s.isJump){var l,c,h,u;if("arc"===n){l=-90,c=s.start.difference(s.end);var d=Number(c.x<0||0===c.x&&c.y<0);d&&(l+=180);var f,p=s.midpoint(),g=new ne(p,s.end).rotate(p,l);h=(f=new ne(s.start,p)).pointAt(2/3).rotate(s.start,l),u=g.pointAt(1/3).rotate(g.end,-l),r=Le.createSegment("C",h,u,g.end),o.appendSegment(r),f=new ne(p,s.end),h=g.pointAt(1/3).rotate(g.end,l),u=f.pointAt(1/3).rotate(s.end,-l),r=Le.createSegment("C",h,u,s.end),o.appendSegment(r)}else if("gap"===n)r=Le.createSegment("M",s.end),o.appendSegment(r);else if("cubic"===n){l=s.start.theta(s.end);var m=.6*e,v=1.35*e;c=s.start.difference(s.end),(d=Number(c.x<0||0===c.x&&c.y<0))&&(v*=-1),h=Jt(s.start.x+m,s.start.y+v).rotate(s.start,l),u=Jt(s.end.x-m,s.end.y+v).rotate(s.end,l),r=Le.createSegment("C",h,u,s.end),o.appendSegment(r)}}else{var y=t[a+1];0==i||!y||y.isJump?(r=Le.createSegment("L",s.end),o.appendSegment(r)):function(t,e,n,i,r){var o,s=n.distance(i)/2,a=n.distance(r)/2,l=-Math.min(t,s),c=-Math.min(t,a),h=n.clone().move(i,l).round(),u=n.clone().move(r,c).round(),d=new Jt(Hh*h.x+Wh*n.x,Wh*n.y+Hh*h.y),f=new Jt(Hh*u.x+Wh*n.x,Wh*n.y+Hh*u.y);o=Le.createSegment("L",h),e.appendSegment(o),o=Le.createSegment("C",d,f,u),e.appendSegment(o)}(i,o,s.end,s.start,y.end)}})),o}const Jh=function(t,e,n,i){!function(t){var e=t.paper,n=e._jumpOverUpdateList;if(null==n){n=e._jumpOverUpdateList=[];var i=e.model;i.on("batch:stop",(function(){this.hasActiveBatch()||function(t){for(var e=t._jumpOverUpdateList,n=0;n<e.length;n++){const t=e[n],i=t.getFlag(t.constructor.Flags.CONNECTOR);t.requestUpdate(i)}}(e)})),i.on("reset",(function(){n=e._jumpOverUpdateList=[]}))}n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",(function(){n.splice(n.indexOf(t),1)})))}(this);var r=i.raw,o=i.size||5,s=i.jump&&(""+i.jump).toLowerCase(),a=i.radius||0,l=i.ignoreConnectors||qh;-1===Gh.indexOf(s)&&(s=Gh[0]);var c=this.paper,h=c.model.getLinks();if(1===h.length)return Kh(Xh(t,e,n),o,s,a);var u=this.model,d=h.indexOf(u),f=c.options.defaultConnector||{},p=h.filter((function(t,e){var n=t.get("connector")||f;return!(vo(l).includes(n.name)||e>d&&"jumpover"===n.name)})),g=p.map((function(t){return c.findViewByModel(t)})),m=Xh(t,e,n),v=g.map((function(t){return null==t?[]:t===this?m:Xh(t.sourcePoint,t.targetPoint,t.route)}),this),y=m.reduce((function(t,e){var n=p.reduce((function(t,n,i){if(n!==u){const n=v[i].slice(),r=n.findIndex((t=>function(t,e){const[{x:n,y:i},{x:r,y:o}]=Yh(t.start,t.end),[{x:s,y:a},{x:l,y:c}]=Yh(e.start,e.end);return n<=l&&s<=r&&i<=c&&a<=o}(e,t)));r>-1&&e.containsPoint(n[r].end)&&n.splice(r+1,1);const o=function(t,e){return vo(e).reduce((function(e,n){var i=t.intersection(n);return i&&e.push(i),e}),[])}(e,n);t.push.apply(t,o)}return t}),[]).sort((function(t,n){return Zh(e.start,t)-Zh(e.start,n)}));return n.length>0?t.push.apply(t,function(t,e,n){return e.reduce((function(i,r,o){if(!0===r.skip)return i;var s=i.pop()||t,a=Qt(r).move(s.start,-n),l=Qt(r).move(s.start,+n),c=e[o+1];if(null!=c){var h=l.distance(c);h<=n&&(l=c.move(s.start,h),c.skip=!0)}else if(a.distance(s.end)<2*n+1)return i.push(s),i;if(l.distance(s.start)<2*n+1)return i.push(s),i;var u=ie(a,l);return u.isJump=!0,i.push(ie(s.start,a),u,ie(l,s.end)),i}),[])}(e,n,o)):t.push(e),t}),[]),b=Kh(y,o,s,a);return r?b:b.serialize()},Qh=function(t,e,n=[],i={}){const{raw:r}=i;return Uh(t,e,n,{cornerType:"point",raw:r})},tu=10,eu=function(t,e,n=[],i={}){const{radius:r=tu,raw:o}=i;return Uh(t,e,n,{cornerType:"cubic",cornerRadius:r,precision:0,raw:o})},nu=function(t,e,n,i){var r,o=i&&i.raw;if(n&&0!==n.length){var s=[t].concat(n).concat([e]),a=_e.throughPoints(s);r=new Le(a)}else{var l;if(r=new Le,l=Le.createSegment("M",t),r.appendSegment(l),Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)){var c=(t.x+e.x)/2;l=Le.createSegment("C",c,t.y,c,e.y,e.x,e.y),r.appendSegment(l)}else{var h=(t.y+e.y)/2;l=Le.createSegment("C",t.x,h,e.x,h,e.x,e.y),r.appendSegment(l)}}return o?r:r.serialize()},iu={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},ru={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},ou=function(t,e,n=[],i={},r){const o=Boolean(i.raw),{direction:s=iu.AUTO,precision:a=3}=i,l={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new Jt(i.sourceTangent):null,targetTangent:i.targetTangent?new Jt(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?l.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?l.sourceDirection=new Jt(1,0).rotate(null,i.sourceDirection):l.sourceDirection=i.sourceDirection?new Jt(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?l.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?l.targetDirection=new Jt(1,0).rotate(null,i.targetDirection):l.targetDirection=i.targetDirection?new Jt(i.targetDirection).normalize():null;const c=[t,...n,e].map((t=>new Jt(t)));let h,u;if(l.sourceTangent)h=l.sourceTangent;else{const t=function(t,e,n,i){if(i.sourceDirection)switch(i.sourceDirection){case ru.UP:return new Jt(0,-1);case ru.DOWN:return new Jt(0,1);case ru.LEFT:return new Jt(-1,0);case ru.RIGHT:return new Jt(1,0);case ru.AUTO:return su(t,e,i);case ru.CLOSEST_POINT:return lu(0,e);case ru.OUTWARDS:return hu(t,e);default:return i.sourceDirection}switch(n){case iu.HORIZONTAL:return function(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.x>e[1].x?"right":"left";return s=new Jt("left"===r?-1:1,0),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case iu.VERTICAL:return function(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.y>e[1].y?"bottom":"top";return s=new Jt(0,"top"===r?-1:1),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case iu.CLOSEST_POINT:return lu(0,e);case iu.OUTWARDS:return hu(t,e);case iu.AUTO:default:return su(t,e,i)}}(r,c,s,l),e=c[0].distance(c[1])*l.coeff,n=fu(t,c[1].difference(c[0]).normalize());if(n>Math.PI/4){const i=e+(n-Math.PI/4)*l.angleTangentCoefficient;h=t.clone().scale(i,i)}else h=t.clone().scale(e,e)}if(l.targetTangent)u=l.targetTangent;else{const t=function(t,e,n,i){if(i.targetDirection)switch(i.targetDirection){case ru.UP:return new Jt(0,-1);case ru.DOWN:return new Jt(0,1);case ru.LEFT:return new Jt(-1,0);case ru.RIGHT:return new Jt(1,0);case ru.AUTO:return au(t,e,i);case ru.CLOSEST_POINT:return cu(0,e);case ru.OUTWARDS:return uu(t,e);default:return i.targetDirection}switch(n){case iu.HORIZONTAL:return function(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.x>e[e.length-2].x?"left":"right";return s=new Jt("left"===r?-1:1,0),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case iu.VERTICAL:return function(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.y>e[e.length-2].y?"top":"bottom";return s=new Jt(0,"top"===r?-1:1),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case iu.CLOSEST_POINT:return cu(0,e);case iu.OUTWARDS:return uu(t,e);case iu.AUTO:default:return au(t,e,i)}}(r,c,s,l),e=c.length-1,n=c[e-1].distance(c[e])*l.coeff,i=fu(t,c[e-1].difference(c[e]).normalize());if(i>Math.PI/4){const e=n+(i-Math.PI/4)*l.angleTangentCoefficient;u=t.clone().scale(e,e)}else u=t.clone().scale(n,n)}const d=function(t,e,n,i){const{tau:r,coeff:o}=i,s=[],a=[],l=[],c=t.length-1;for(let e=0;e<c;e++)s[e]=t[e].distance(t[e+1]);a[0]=e,a[c]=n;for(let e=1;e<c;e++){let n,i;n=1===e?t[e-1].clone().offset(a[e-1].x,a[e-1].y):t[e-1].clone(),i=e===c-1?t[e+1].clone().offset(a[e+1].x,a[e+1].y):t[e+1].clone();const r=n.difference(t[e]).normalize(),l=i.difference(t[e]).normalize(),h=fu(r,l);let u,d=(Math.PI-h)/2;const f=pu(r,l);let p;p=pu(t[e].difference(t[e+1]),t[e].difference(t[e-1])),f<0&&(d=-d),h<Math.PI/2&&(d<0&&p<0||d>0&&p>0)&&(d-=Math.PI),u=l.clone(),du(u,d);const g=u.clone(),m=u.clone(),v=s[e-1]*o,y=s[e]*o;g.scale(v,v),m.scale(y,y),a[e]=[g,m]}for(let e=0;e<c;e++){let n,i;n=0===e?t[e+1].difference(a[e].x/r,a[e].y/r):t[e+1].difference(a[e][1].x/r,a[e][1].y/r),i=e===c-1?t[e].clone().offset(a[e+1].x/r,a[e+1].y/r):t[e].difference(a[e+1][0].x/r,a[e+1][0].y/r),l[e]=[n,t[e],t[e+1],i]}return l}(c,h,u,l),f=d.map((t=>function(t,e){const{tau:n}=e,i=new Jt;i.x=t[1].x+(t[2].x-t[0].x)/(6*n),i.y=t[1].y+(t[2].y-t[0].y)/(6*n);const r=new Jt;return r.x=t[2].x+(t[3].x-t[1].x)/(6*n),r.y=t[2].y+(t[3].y-t[1].y)/(6*n),new _e(t[1],i,r,t[2])}(t,l))),p=new Le(f).round(a);return o?p:p.serialize()};function su(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.sideNearestToPoint(e[1]);switch(r){case"top":s=new Jt(0,-1);break;case"bottom":s=new Jt(0,1);break;case"right":s=new Jt(1,0);break;case"left":s=new Jt(-1,0)}return n.rotate&&o&&s.rotate(null,-o),s}function au(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.sideNearestToPoint(e[e.length-2]);switch(r){case"top":s=new Jt(0,-1);break;case"bottom":s=new Jt(0,1);break;case"right":s=new Jt(1,0);break;case"left":s=new Jt(-1,0)}return n.rotate&&o&&s.rotate(null,-o),s}function lu(t,e,n){return e[1].difference(e[0]).normalize()}function cu(t,e,n){const i=e.length-1;return e[i-1].difference(e[i]).normalize()}function hu(t,e,n){const{sourceBBox:i}=t,r=i.center();return e[0].difference(r).normalize()}function uu(t,e,n){const{targetBBox:i}=t,r=i.center();return e[e.length-1].difference(r).normalize()}function du(t,e){const n=Math.cos(e),i=Math.sin(e),r=n*t.x-i*t.y,o=i*t.x+n*t.y;t.x=r,t.y=o}function fu(t,e){let n=t.dot(e)/(t.magnitude()*e.magnitude());return n<-1&&(n=-1),n>1&&(n=1),Math.acos(n)}function pu(t,e){return t.x*e.y-t.y*e.x}ou.Directions=iu,ou.TangentDirections=ru;const gu={TOOLS:Rc.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"},mu=Rc.extend({className:function(){var t=Rc.prototype.className.apply(this).split(" ");return t.push("link"),t.join(" ")},_labelCache:null,_labelSelectors:null,_V:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(){Rc.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[gu.RENDER],attrs:[gu.UPDATE],router:[gu.UPDATE],connector:[gu.CONNECTOR],labels:[gu.LABELS],labelMarkup:[gu.LABELS],vertices:[gu.UPDATE],source:[gu.SOURCE,gu.UPDATE],target:[gu.TARGET,gu.UPDATE]},initFlag:[gu.RENDER,gu.SOURCE,gu.TARGET,gu.TOOLS],UPDATE_PRIORITY:1,confirmUpdate:function(t,e){if(e||(e={}),this.hasFlag(t,gu.SOURCE)){if(!this.updateEndProperties("source"))return t;t=this.removeFlag(t,gu.SOURCE)}if(this.hasFlag(t,gu.TARGET)){if(!this.updateEndProperties("target"))return t;t=this.removeFlag(t,gu.TARGET)}const{paper:n,sourceView:i,targetView:r}=this;if(n&&(i&&!n.isViewMounted(i)||r&&!n.isViewMounted(r)))return t;if(this.hasFlag(t,gu.RENDER))return this.render(),this.updateHighlighters(!0),this.updateTools(e),this.removeFlag(t,[gu.RENDER,gu.UPDATE,gu.LABELS,gu.TOOLS,gu.CONNECTOR]);let o=!1;const{model:s}=this,{attributes:a}=s;let l=this.hasFlag(t,gu.LABELS);l&&(this.onLabelsChange(s,a.labels,e),t=this.removeFlag(t,gu.LABELS),o=!0);const c=this.hasFlag(t,gu.UPDATE),h=this.hasFlag(t,gu.CONNECTOR);return(c||h)&&(c?e.translateBy&&s.isRelationshipEmbeddedIn(e.translateBy)?this.translate(e.tx,e.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(e),t=this.removeFlag(t,[gu.UPDATE,gu.TOOLS,gu.CONNECTOR]),l=!1,o=!0),l&&this.updateLabelPositions(),o&&this.updateHighlighters(),this.hasFlag(t,gu.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,gu.TOOLS)),t},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(gu.UPDATE),t)},isLabelsRenderRequired:function(t={}){const e=this.model.previous("labels");if(!e)return!0;if("propertyPathArray"in t&&"propertyValue"in t){var n=t.propertyPathArray||[],i=n.length;if(i>1&&e[n[1]]){if(2===i)return"markup"in Object(t.propertyValue);if("markup"!==n[2])return!1}}return!0},onLabelsChange:function(t,e,n){this.isLabelsRenderRequired(n)?this.renderLabels():this.updateLabels()},render:function(){return this.vel.empty(),this.unmountLabels(),this._V={},this.renderMarkup(),this.renderLabels(),this.update(),this},renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.LinkView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el);this.selectors=e.selectors,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=An(t);Array.isArray(e)||(e=[e]),this.vel.append(e)},_getLabelMarkup:function(t){if(t){if(Array.isArray(t))return this.parseDOMJSON(t,null);if("string"==typeof t)return this._getLabelStringMarkup(t);throw new Error("dia.linkView: invalid label markup")}},_getLabelStringMarkup:function(t){var e=An(t),n=document.createDocumentFragment();if(Array.isArray(e))for(var i=0,r=e.length;i<r;i++){var o=e[i].node;n.appendChild(o)}else n.appendChild(e.node);return{fragment:n,selectors:{}}},_normalizeLabelMarkup:function(t){if(t){var e,n=t.fragment;if(!(t.fragment instanceof DocumentFragment&&t.fragment.hasChildNodes()))throw new Error("dia.LinkView: invalid label markup.");var i=n.childNodes;return(e=i.length>1||"G"!==i[0].nodeName.toUpperCase()?An("g").append(n):An(i[0])).addClass("label"),{node:e.node,selectors:t.selectors}}},renderLabels:function(){var t=this._V,e=t.labels,n=this._labelCache={},i=this._labelSelectors={},r=this.model,o=r.attributes.labels||[],s=o.length;if(0===s)return e&&e.remove(),this;e?e.empty():(e=t.labels=An("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(Fs(Eo(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,c,h=o[a],u=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup));if(u)l=u.node,c=u.selectors;else{var d=r._builtins.defaultLabel,f=this._normalizeLabelMarkup(this._getLabelMarkup(d.markup)),p=r._getDefaultLabel(),g=this._normalizeLabelMarkup(this._getLabelMarkup(p.markup))||f;l=g.node,c=g.selectors}l.setAttribute("label-idx",a),e.append(l),n[a]=l;var m=this.selector;if(c[m])throw new Error("dia.LinkView: ambiguous label root selector.");c[m]=l,i[a]=c}return e.parent()||this.mountLabels(),this.updateLabels(),this},mountLabels:function(){const{el:t,paper:e,model:n,_V:i,options:r}=this,{labels:o}=i;if(!o||!n.hasLabels())return;const{node:s}=o;r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(s,n.get("z")):s.parentNode!==t&&t.appendChild(s)},unmountLabels:function(){const{options:t,_V:e}=this;if(!e)return;const{labels:n}=e;n&&t.labelsLayer&&n.remove()},findLabelNodes:function(t,e){const n=this._labelCache[t];if(!n)return[];const i=this._labelSelectors[t];return this.findBySelector(e,n,i)},findLabelNode:function(t,e){const[n=null]=this.findLabelNodes(t,e);return n},_mergeLabelAttrs:function(t,e,n,i){if(null===e)return null;if(void 0===e){if(null===n)return null;if(void 0===n){if(t)return;return i}return t?n:Mo({},i,n)}return t?Mo({},n,e):Mo({},i,n,e)},_mergeLabelSize:function(t,e){if(null===t)return null;if(void 0===t){if(null===e)return null;if(void 0===e)return;return e}return Mo({},e,t)},updateLabels:function(){if(!this._V.labels)return this;for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,r=t._getDefaultLabel(),o=r.markup,s=r.attrs,a=r.size,l=0,c=e.length;l<c;l++){var h=this._labelCache[l];h.setAttribute("cursor",n?"move":"default");var u=this._labelSelectors[l],d=e[l],f=d.markup,p=d.attrs,g=d.size,m=this._mergeLabelAttrs(f||o,p,s,i),v=this._mergeLabelSize(g,a);this.updateDOMSubtreeAttributes(h,m,{rootBBox:new me(v),selectors:u})}return this},removeRedundantLinearVertices:function(t){const e=this.model,n=e.vertices(),i=[this.sourceAnchor,...n,this.targetAnchor],r=i.length,o=new xe(i);o.simplify({threshold:.001});const s=o.points.map((t=>t.toJSON())),a=s.length;return r===a?0:(e.vertices(s.slice(1,a-1),t),r-a)},getEndView:function(t){switch(t){case"source":return this.sourceView||null;case"target":return this.targetView||null;default:throw new Error("dia.LinkView: type parameter required.")}},getEndAnchor:function(t){switch(t){case"source":return new Jt(this.sourceAnchor);case"target":return new Jt(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new Jt(this.sourcePoint);case"target":return new Jt(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(!e)break;return this.sourceMagnet||e.el;case"target":var n=this.targetView;if(!n)break;return this.targetMagnet||n.el;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(t=0,e=0){const{route:n,path:i}=this;if(!n||!i)return;const r=new xe(n);r.translate(t,e),this.route=r.points,this.sourcePoint.offset(t,e),this.targetPoint.offset(t,e),this.sourceAnchor.offset(t,e),this.targetAnchor.offset(t,e),i.translate(t,e),this.updateDOM()},updateDOM(){const{el:t,model:e,selectors:n}=this;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){const{model:t}=this,e=t.vertices(),n=this.findAnchors(e),i=this.sourceAnchor=n.source,r=this.targetAnchor=n.target,o=this.findRoute(e);this.route=o;var s=this.findConnectionPoints(o,i,r);this.sourcePoint=s.source,this.targetPoint=s.target},updatePath:function(){const{route:t,sourcePoint:e,targetPoint:n}=this,i=this.findPath(t,e.clone(),n.clone());this.path=i},findAnchorsOrdered:function(t,e,n,i){var r,o,s,a,l=this.model,c=l.get(t),h=l.get(n),u=this.getEndView(t),d=this.getEndView(n),f=this.getEndMagnet(t),p=this.getEndMagnet(n);u?(s=e?new Jt(e):d?p:new Jt(h),r=this.getAnchor(c.anchor,u,f,s,t)):r=new Jt(c),d?(a=new Jt(i||r),o=this.getAnchor(h.anchor,d,p,a,n)):o=new Jt(h);var g={};return g[t]=r,g[n]=o,g},findAnchors:function(t){var e=this.model,n=t[0],i=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",i,"source",n):this.findAnchorsOrdered("source",n,"target",i)},findConnectionPoints:function(t,e,n){var i,r,o,s,a=t[0],l=t[t.length-1],c=this.model,h=c.get("source"),u=c.get("target"),d=this.sourceView,f=this.targetView,p=this.paper.options;if(d&&!d.isNodeConnection(this.sourceMagnet)){i=this.sourceMagnet||d.el;var g=h.connectionPoint||p.defaultConnectionPoint,m=new ne(a||n,e);o=this.getConnectionPoint(g,d,i,m,"source")}else o=e;if(f&&!f.isNodeConnection(this.targetMagnet)){r=this.targetMagnet||f.el;var v=u.connectionPoint||p.defaultConnectionPoint,y=new ne(l||e,n);s=this.getConnectionPoint(v,f,r,y,"target")}else s=n;return{source:o,target:s}},getAnchor:function(t,e,n,i,r){var o,s=e.isNodeConnection(n),a=this.paper.options;if(t||(t=s?a.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:a.defaultAnchor),!t)throw new Error("Anchor required.");if("function"==typeof t)o=t;else{var l=t.name;if("function"!=typeof(o=a[s?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}var c=o.call(this,e,n,i,t.args||{},r,this);return c?c.round(this.decimalsRounding):new Jt},getConnectionPoint:function(t,e,n,i,r){var o,s,a=i.end,l=this.paper.options;if(!t)return a;if("function"==typeof t)s=t;else{var c=t.name;if("function"!=typeof(s=l.connectionPointNamespace[c]))throw new Error("Unknown connection point: "+c)}return(o=s.call(this,i,e,n,t.args||{},r,this))?o.round(this.decimalsRounding):a},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,n=t._getDefaultLabel(),i=this._normalizeLabelPosition(n.position);return Mo({},e,i)},_normalizeLabelPosition:function(t){return"number"==typeof t?{distance:t,offset:null,angle:0,args:null}:t},_mergeLabelPositionProperty:function(t,e){return null===t?null:void 0===t?null===e?null:e:Mo({},e,t)},updateLabelPositions:function(){if(!this._V.labels)return this;if(!this.path)return this;var t=this.model.get("labels")||[];if(!t.length)return this;for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r=this._labelCache[n];if(r){var o=t[n],s=this._normalizeLabelPosition(o.position),a=this._mergeLabelPositionProperty(s,e),l=this._getLabelTransformationMatrix(a);r.setAttribute("transform",An.matrixToTransformString(l)),this._cleanLabelMatrices(n)}}return this},_cleanLabelMatrices:function(t){const{metrics:e,_labelSelectors:n}=this,i=n[t];if(i)for(let t in i){const{id:n}=i[t];n&&n in e&&delete e[n].magnetMatrix}},updateEndProperties:function(t){const{model:e,paper:n}=this,i=`${t}View`,r=e.get(t),o=r&&r.id;if(!o)return this[i]=null,this.updateEndMagnet(t),!0;const s=n.getModelById(o);if(!s)throw new Error("LinkView: invalid "+t+" cell.");const a=s.findView(n);return!!a&&(this[i]=a,this.updateEndMagnet(t),!0)},updateEndMagnet:function(t){const e=`${t}Magnet`,n=this.getEndView(t);if(n){let i=n.getMagnetFromLinkEnd(this.model.get(t));i===n.el&&(i=null),this[e]=i}else this[e]=null},_getLabelPositionProperty:function(t){return this.model.label(t).position||{}},_getLabelPositionAngle:function(t){return this._getLabelPositionProperty(t).angle||0},_getLabelPositionArgs:function(t){return this._getLabelPositionProperty(t).args},_getDefaultLabelPositionArgs:function(){return(this.model._getDefaultLabel().position||{}).args},_mergeLabelPositionArgs:function(t,e){return null===t?null:void 0===t?null===e?null:e:Mo({},e,t)},addLabel:function(t,e,n,i){var r,o,s,a=0;"number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(a=e,s=n):s=e):(r=t,o=e,"number"==typeof n?(a=n,s=i):s=n);var l=this._getDefaultLabelPositionArgs(),c=s,h=this._mergeLabelPositionArgs(c,l),u={position:this.getLabelPosition(r,o,a,h)};return this.model.insertLabel(-1,u,s),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,o=i?t.y:e,s=i?e:n,a={x:r,y:o},l=this.getVertexIndex(r,o);return this.model.insertVertex(l,a,s),l},sendToken:function(t,e,n){var i,r,o;to(e)?(i=e.duration,r="reverse"===e.direction,o=e.connection):(i=e,r=!1,o=null);var s={dur:(i=i||1e3)+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};r&&(s.keyPoints="1;0",s.keyTimes="0;1");var a,l=An(t);if("string"==typeof o)a=this.findNode(o);else{var c=this._V;a=c.connection?c.connection.node:this.el.querySelector("path")}if(!(a instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");l.appendTo(this.paper.cells).animateAlongPath(s,a),setTimeout(function(t,e){return function(){t.remove(),"function"==typeof e&&e()}}(l,n),i)},findRoute:function(t){t||(t=[]);var e=this.paper.options.routerNamespace||h,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(Jt);n=i}var r=go(n)?n:e[n.name];if(!go(r))throw new Error('dia.LinkView: unknown router: "'+n.name+'".');var o=n.args||{};return r.call(this,t,o,this)||t.map(Jt)},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||u,r=this.model.connector(),o=this.paper.options.defaultConnector;r||(r=o||{});var s=go(r)?r:i[r.name];if(!go(s))throw new Error('dia.LinkView: unknown connector: "'+r.name+'".');var a=ho(r.args||{});a.raw=!0;var l=s.call(this,e,n,t,a,this);return"string"==typeof l&&(l=new Le(An.normalizePathData(l))),l},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("data"))return e.data;var n=t.serialize();return e.data=n,n},getConnectionSubdivisions:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("segmentSubdivisions"))return e.segmentSubdivisions;var n=t.getSegmentSubdivisions();return e.segmentSubdivisions=n,n},getConnectionLength:function(){var t=this.path;if(!t)return 0;var e=this.metrics;if(e.hasOwnProperty("length"))return e.length;var n=t.length({segmentSubdivisions:this.getConnectionSubdivisions()});return e.length=n,n},getPointAtLength:function(t){var e=this.path;return e?e.pointAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getPointAtRatio:function(t){var e=this.path;return e?(Ys(t)&&(t=parseFloat(t)/100),e.pointAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()})):null},getTangentAtLength:function(t){var e=this.path;return e?e.tangentAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getTangentAtRatio:function(t){var e=this.path;return e?e.tangentAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPoint:function(t){var e=this.path;return e?e.closestPoint(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointLength:function(t){var e=this.path;return e?e.closestPointLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointRatio:function(t){var e=this.path;return e?e.closestPointNormalizedLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getLabelPosition:function(t,e,n,i){var r,o={},s=0;"number"==typeof n?(s=n,r=i):r=n,r&&(o.args=r);var a,l,c=!(r&&r.absoluteDistance),h=r&&r.absoluteDistance&&r.reverseDistance,u=r&&r.absoluteOffset,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=new Jt(t,e),g=d.closestPointT(p,f),m=d.lengthAtT(g,f);if(c&&(m=m/this.getConnectionLength()||0),h&&(m=-1*(this.getConnectionLength()-m)||1),o.distance=m,u||(a=d.tangentAtT(g)),a)l=a.pointOffset(p);else{var v=d.pointAtT(g),y=p.difference(v);l={x:y.x,y:y.y}}return o.offset=l,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e,n=0,i={};if("number"==typeof t)e=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");i=t.args||{},e=t.distance,n=t.angle||0}var r=e>0&&e<=1,o=0,s={x:0,y:0};if(t.offset){var a=t.offset;"number"==typeof a&&(o=a),a.x&&(s.x=a.x),a.y&&(s.y=a.y)}var l,c=0!==s.x||0!==s.y||0===o,h=i.keepGradient,u=i.ensureLegibility,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=r?e*this.getConnectionLength():e,g=d.tangentAtLength(p,f),m=n;if(g){if(c)(l=g.start.clone()).offset(s);else{var v=g.clone();v.rotate(g.start,-90),v.setLength(o),l=v.end}h&&(m=g.angle()+n,u&&(m=Ct((m+90)%180-90)))}else l=d.start.clone(),c&&l.offset(s);return An.createSVGMatrix().translate(l.x,l.y).rotate(m)},getLabelCoordinates:function(t){var e=this._getLabelTransformationMatrix(t);return new Jt(e.e,e.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new Jt(t,e)),r=0,o=n.length;r<o;r++){var s=n[r];if(i<this.getClosestPointLength(s))break}return r},notifyPointerdown(t,e,n){Rc.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove(t,e,n){Rc.prototype.pointermove.call(this,t,e,n),this.notify("link:pointermove",t,e,n)},notifyPointerup(t,e,n){this.notify("link:pointerup",t,e,n),Rc.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){Rc.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){Rc.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){Rc.prototype.contextmenu.apply(this,arguments),this.notify("link:contextmenu",t,e,n)},pointerdown:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragStart(t,e,n)},pointermove:function(t,e,n){var i=this._dragData;switch(i&&this.eventData(t,i),this.eventData(t).action){case"label-move":this.dragLabel(t,e,n);break;case"arrowhead-move":this.dragArrowhead(t,e,n);break;case"move":this.drag(t,e,n)}i&&io(i,this.eventData(t)),this.notifyPointermove(t,e,n)},pointerup:function(t,e,n){var i=this._dragData;switch(i&&(this.eventData(t,i),this._dragData=null),this.eventData(t).action){case"label-move":this.dragLabelEnd(t,e,n);break;case"arrowhead-move":this.dragArrowheadEnd(t,e,n);break;case"move":this.dragEnd(t,e,n)}this.notifyPointerup(t,e,n),this.checkMouseleave(t)},mouseover:function(t){Rc.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){Rc.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){Rc.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){Rc.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){Rc.prototype.mousewheel.apply(this,arguments),this.notify("link:mousewheel",t,e,n,i)},onlabel:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragLabelStart(t,e,n),this.eventData(t).stopPropagation&&t.stopPropagation()},dragLabelStart:function(t,e,n){if(this.can("labelMove")){if(this.isDefaultInteractionPrevented(t))return;var i=t.currentTarget,r=parseInt(i.getAttribute("label-idx"),10),o=this._getDefaultLabelPositionProperty(),s=this._normalizeLabelPosition(this._getLabelPositionProperty(r)),a=this._mergeLabelPositionProperty(s,o),l=this.getLabelCoordinates(a),c=l.x-e,h=l.y-n,u=this._getLabelPositionAngle(r),d=this._getLabelPositionArgs(r),f=this._getDefaultLabelPositionArgs(),p=this._mergeLabelPositionArgs(d,f);this.eventData(t,{action:"label-move",labelIdx:r,dx:c,dy:h,positionAngle:u,positionArgs:p,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){if(this.can("arrowheadMove")){var i=t.target.getAttribute("end"),r=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0});this.eventData(t,r)}},dragStart:function(t,e,n){this.isDefaultInteractionPrevented(t)||this.can("linkMove")&&this.eventData(t,{action:"move",dx:e,dy:n})},dragLabel:function(t,e,n){var i=this.eventData(t),r={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)};this.paper.options.snapLabels&&delete r.position.offset;const o={ui:!0};this.paper.isAsync()&&"touchmove"===t.type&&(o.async=!1),this.model.label(i.labelIdx,r,o)},dragArrowhead:function(t,e,n){this.paper.options.snapLinks?!this._snapArrowhead(t,e,n)&&this.paper.options.snapLinksSelf&&this._snapArrowheadSelf(t,e,n):this.paper.options.snapLinksSelf?this._snapArrowheadSelf(t,e,n):this._connectArrowhead(this.getEventTarget(t),e,n,this.eventData(t))},drag:function(t,e,n){var i=this.eventData(t);this.model.translate(e-i.dx,n-i.dy,{ui:!0}),this.eventData(t,{dx:e,dy:n})},dragLabelEnd:function(){},dragArrowheadEnd:function(t,e,n){var i=this.eventData(t),r=this.paper;r.options.snapLinks?this._snapArrowheadEnd(i):this._connectArrowheadEnd(i,e,n),r.linkAllowed(this)?(this._finishEmbedding(i),this._notifyConnectEvent(i,t)):this._disallow(i),this._afterArrowheadMove(i)},dragEnd:function(){},_disallow:function(t){"remove"===t.whenNotAllowed?this.model.remove({ui:!0}):this.model.set(t.arrowhead,t.initialEnd,{ui:!0})},_finishEmbedding:function(t){this.paper.options.embeddingMode&&this.model.reparent()&&(t.z=null)},_notifyConnectEvent:function(t,e){var n=t.arrowhead,i=t.initialEnd,r=this.model.prop(n);if(r&&!$l.endsEqual(i,r)){var o=this.paper;i.id&&this.notify("link:disconnect",e,o.findViewByModel(i.id),t.initialMagnet,n),r.id&&this.notify("link:connect",e,o.findViewByModel(r.id),t.magnetUnderPointer,n)}},_snapToPoints:function(t,e,n){let i=null,r=1/0,o=null,s=1/0,a=t.x,l=t.y;for(let n=0;n<e.length;n++){const a=Math.abs(e[n].x-t.x);a<r&&(r=a,i=e[n]);const l=Math.abs(e[n].y-t.y);l<s&&(s=l,o=e[n])}return r<n&&(a=i.x),s<n&&(l=o.y),{x:a,y:l}},_snapArrowheadSelf:function(t,e,n){const{paper:i,model:r}=this,{snapLinksSelf:o}=i.options,s=this.eventData(t),a=o.radius||20,l=[this.getEndAnchor("source"===s.arrowhead?"target":"source"),...r.vertices()],c=this._snapToPoints({x:e,y:n},l,a),h=i.localToClientPoint(c);this._connectArrowhead(document.elementFromPoint(h.x,h.y),c.x,c.y,this.eventData(t))},_snapArrowhead:function(t,e,n){const{paper:i}=this,{snapLinks:r,connectionStrategy:o}=i.options,s=this.eventData(t);let a=!1;var l=r.radius||50,c=i.findViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l}),h=s.closestView||null,u=s.closestMagnet||null,d=s.magnetProxy||null;s.closestView=s.closestMagnet=s.magnetProxy=null;var f,p=Number.MAX_VALUE,g=new Jt(e,n);c.forEach((function(t){const e=[];"false"!==t.el.getAttribute("magnet")&&e.push({bbox:t.model.getBBox(),magnet:t.el}),t.$("[magnet]").toArray().forEach((n=>{e.push({bbox:t.getNodeBBox(n),magnet:n})})),e.forEach((e=>{const{magnet:n,bbox:r}=e,o=r.center().squaredDistance(g);o<p&&(u===n||i.options.validateConnection.apply(i,s.validateConnectionArgs(t,t.el===n?null:n)))&&(p=o,s.closestView=t,s.closestMagnet=n)}))}),this);var m=null,v=s.closestView,y=s.closestMagnet;y&&(m=s.magnetProxy=v.findProxyNode(y,"highlighter"));var b=s.arrowhead,w=u!==y;if(h&&w&&h.unhighlight(d,{connecting:!0,snapping:!0}),v){const{prevEnd:t,prevX:i,prevY:r}=s;if(s.prevX=e,s.prevY=n,a=!0,!w&&("function"!=typeof o||i===e&&r===n))return a;if(f=v.getLinkEnd(y,e,n,this.model,b),!w&&po(t,f))return a;s.prevEnd=f,w&&v.highlight(m,{connecting:!0,snapping:!0})}else f={x:e,y:n};return this.model.set(b,f||{x:e,y:n},{ui:!0}),h&&this.notify("link:snap:disconnect",t,h,u,b),v&&this.notify("link:snap:connect",t,v,y,b),a},_snapArrowheadEnd:function(t){var e=t.closestView,n=t.closestMagnet;e&&n&&(e.unhighlight(t.magnetProxy,{connecting:!0,snapping:!0}),t.magnetUnderPointer=e.findMagnet(n)),t.closestView=t.closestMagnet=null},_connectArrowhead:function(t,e,n,i){const{paper:r,model:o}=this;if(i.eventTarget!==t){i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0});const e=i.viewUnderPointer=r.findView(t);if(e){const n=i.magnetUnderPointer=e.findMagnet(t),o=i.magnetProxy=e.findProxyNode(n,"highlighter");n&&this.paper.options.validateConnection.apply(r,i.validateConnectionArgs(e,n))?o&&e.highlight(o,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)}else i.magnetUnderPointer=null,i.magnetProxy=null}i.eventTarget=t,o.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(t={},e,n){const{model:i}=this,{viewUnderPointer:r,magnetUnderPointer:o,magnetProxy:s,arrowhead:a}=t;if(!o||!s||!r)return;r.unhighlight(s,{connecting:!0});const l=r.getLinkEnd(o,e,n,i,a);i.set(a,l,{ui:!0})},_beforeArrowheadMove:function(t){t.z=this.model.get("z"),this.model.toFront();var e=this.el.style;t.pointerEvents=e.pointerEvents,e.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets(t)},_afterArrowheadMove:function(t){null!==t.z&&(this.model.set("z",t.z,{ui:!0}),t.z=null),this.el.style.pointerEvents=t.pointerEvents,this.paper.options.markAvailable&&this._unmarkAvailableMagnets(t)},_createValidateConnectionArgs:function(t){var e,n=[];n[4]=t,n[5]=this;var i=0,r=0;"source"===t?(i=2,e="target"):(r=2,e="source");var o=this.model.get(e);if(o.id){var s=n[i]=this.paper.findViewByModel(o.id),a=s.getMagnetFromLinkEnd(o);a===s.el&&(a=void 0),n[i+1]=a}return function(t,e){return n[r]=t,n[r+1]=t.el===e?void 0:e,n}},_markAvailableMagnets:function(t){function e(t,e){var n=t.paper;return n.options.validateConnection.apply(n,this.validateConnectionArgs(t,e))}var n=this.paper,i=n.model.getCells();t.marked={};for(var r=0,o=i.length;r<o;r++){var s=i[r].findView(n);if(s){var a=Array.prototype.slice.call(s.el.querySelectorAll("[magnet]"));"false"!==s.el.getAttribute("magnet")&&a.push(s.el);var l=a.filter(e.bind(t,s));if(l.length>0){for(var c=0,h=l.length;c<h;c++)s.highlight(l[c],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e,n,i=Object.keys(t.marked),r=0,o=i.length;r<o;r++){e=i[r],n=t.marked[e];var s=this.paper.findViewByModel(e);if(s){for(var a=0,l=n.length;a<l;a++)s.unhighlight(n[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){e||(e={});var n={action:"arrowhead-move",arrowhead:t,whenNotAllowed:e.whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:ho(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(n),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=n),n},onMount:function(){Rc.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){Rc.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){Rc.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:gu});Object.defineProperty(mu.prototype,"sourceBBox",{enumerable:!0,get:function(){var t=this.sourceView;if(!t){var e=this.model.source();return new me(e.x,e.y)}var n=this.sourceMagnet;return t.isNodeConnection(n)?new me(this.sourceAnchor):t.getNodeBBox(n||t.el)}}),Object.defineProperty(mu.prototype,"targetBBox",{enumerable:!0,get:function(){var t=this.targetView;if(!t){var e=this.model.target();return new me(e.x,e.y)}var n=this.targetMagnet;return t.isNodeConnection(n)?new me(this.targetAnchor):t.getNodeBBox(n||t.el)}});const vu={GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"},yu=Pc.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return Fs(`${this.options.name}-layer`)},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){const{el:e}=this;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(t){const{el:e,pivotNodes:n}=this;(t=+t)||(t=0);let i=n[t];if(i)return i;i=n[t]=document.createComment("z-index:"+(t+1));let r=-1/0;for(let e in n)e=+e,e<t&&e>r&&(r=e);if(r!==-1/0){const t=n[r];e.insertBefore(i,t.nextSibling)}else e.insertBefore(i,e.firstChild);return i},removePivots:function(){const{el:t,pivotNodes:e}=this;for(let n in e)t.removeChild(e[n]);this.pivotNodes={}}}),bu=kc.extend({tagName:"path",className:"highlight-stroke",attributes:{"pointer-events":"none",fill:"none"},options:{padding:3,rx:0,ry:0,useFirstSubpath:!1,attrs:{"stroke-width":3,stroke:"#FEB663"}},getPathData(t,e){const{options:n}=this,{useFirstSubpath:i}=n;let r;try{const t=An(e);if(r=t.convertToPathData().trim(),"PATH"===t.tagName()&&i){const t=r.search(/.M/i)+1;t>0&&(r=r.substr(0,t))}}catch(i){const o=t.getNodeBoundingRect(e);r=An.rectToPath(io({},n,o.toJSON()))}return r},highlightConnection(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode(t,e){const{vel:n,options:i}=this,{padding:r,layer:o}=i;let s=this.getNodeMatrix(t,e);if(r){o||e!==t.el||n.remove();let i=t.getNodeBoundingRect(e);const a=i.x+i.width/2,l=i.y+i.height/2;i=An.transformRect(i,s);const c=Math.max(i.width,1),h=Math.max(i.height,1),u=(c+r)/c,d=(h+r)/h,f=An.createSVGMatrix({a:u,b:0,c:0,d,e:a-u*a,f:l-d*l});s=s.multiply(f)}n.attr({d:this.getPathData(t,e),transform:An.matrixToTransformString(s)})},highlight(t,e){const{vel:n,options:i}=this;n.attr(i.attrs),i.nonScalingStroke&&n.attr("vector-effect","non-scaling-stroke"),t.isNodeConnection(e)?this.highlightConnection(t):this.highlightNode(t,e)}}),wu=20,xu=kc.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:wu,deep:!1,attrs:{stroke:"#FEB663","stroke-width":3,"stroke-linecap":"butt","stroke-linejoin":"miter"}},VISIBLE:"white",INVISIBLE:"black",MASK_ROOT_ATTRIBUTE_BLACKLIST:["marker-start","marker-end","marker-mid","transform","stroke-dasharray","class"],MASK_CHILD_ATTRIBUTE_BLACKLIST:["stroke","fill","stroke-width","stroke-opacity","stroke-dasharray","fill-opacity","marker-start","marker-end","marker-mid","class"],MASK_REPLACE_TAGS:["FOREIGNOBJECT","IMAGE","USE","TEXT","TSPAN","TEXTPATH"],MASK_REMOVE_TAGS:["TEXT","TSPAN","TEXTPATH"],transformMaskChild(t,e){const{MASK_CHILD_ATTRIBUTE_BLACKLIST:n,MASK_REPLACE_TAGS:i,MASK_REMOVE_TAGS:r}=this,o=e.tagName();if(!An.isSVGGraphicsElement(e)||r.includes(o))return e.remove(),!1;if(i.includes(o)){const n=t.vel.findOne(`#${e.id}`);if(n){const{node:i}=n;let r=t.getNodeBoundingRect(i);t.model.isElement()&&(r=An.transformRect(r,t.getNodeMatrix(i)));const o=An("rect",r.toJSON()),{x:s,y:a}=r.center(),{angle:l,cx:c=s,cy:h=a}=n.rotate();l&&o.rotate(l,c,h),e.parent().append(o)}return e.remove(),!1}return n.forEach((t=>{"fill"===t&&"none"===e.attr("fill")||e.removeAttr(t)})),!0},transformMaskRoot(t,e){const{MASK_ROOT_ATTRIBUTE_BLACKLIST:n}=this;n.forEach((t=>{e.removeAttr(t)}))},getMaskShape(t,e){const{options:n,MASK_REPLACE_TAGS:i}=this,{deep:r}=n,o=e.tagName();let s;if("G"===o){if(!r)return null;s=e.clone(),function(t,e){const n=t.children();for(;n.length>0;){const t=n.shift();e(t)&&n.push(...t.children())}}(s,(e=>this.transformMaskChild(t,e)))}else{if(i.includes(o))return null;s=e.clone()}return this.transformMaskRoot(t,s),s},getMaskId(){return`highlight-mask-${this.cid}`},getMask(t,e){const{VISIBLE:n,INVISIBLE:i,options:r}=this,{padding:o,attrs:s}=r,a=parseFloat(An("g").attr(s).attr("stroke-width")),l="none"!==e.attr("fill");let c=parseFloat(e.attr("stroke-width"));isNaN(c)&&(c=1);const h=c+2*o,u=h+2*a;let d=this.getMaskShape(t,e);if(!d){const n=t.getNodeBoundingRect(e.node);n.inflate(n.width?0:.5,n.height?0:.5),d=An("rect",n.toJSON())}return d.attr(s),An("mask",{id:this.getMaskId()}).append([d.clone().attr({fill:l?n:"none",stroke:n,"stroke-width":u}),d.clone().attr({fill:l?i:"none",stroke:i,"stroke-width":h})])},removeMask(t){const e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask(t,e){t.defs.appendChild(e.node)},highlight(t,e){const{options:n,vel:i}=this,{padding:r,attrs:o,maskClip:s=wu,layer:a}=n,l="stroke"in o?o.stroke:"#000000";a||e!==t.el||i.remove();const c=t.getNodeBoundingRect(e).inflate(r+s),h=this.getNodeMatrix(t,e),u=this.getMask(t,An(e));this.addMask(t.paper,u),i.attr(c.toJSON()),i.attr({transform:An.matrixToTransformString(h),mask:`url(#${u.id})`,fill:l})},unhighlight(t){this.removeMask(t.paper)}}),Au=kc.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){const{alphaValue:n=.3}=this.options;e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),Tu=Fs("highlighted"),Eu=kc.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:Tu},highlight:function(t,e){An(e).addClass(this.options.className)},unhighlight:function(t,e){An(e).removeClass(this.options.className)}},{className:Tu}),Su={ROW:"row",COLUMN:"column"},Pu=kc.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight(t,e){const n=t.model,{attribute:i,size:r=20,gap:o=5,direction:s=Su.ROW}=this.options;if(!i)throw new Error("List: attribute is required");const a="number"==typeof r?{width:r,height:r}:r,l=s===Su.ROW,c=l?a.width:a.height;let h=n.get(i);Array.isArray(h)||(h=[]);const u=this._prevItems||[],d=h.map(((t,e)=>po(u[e],h[e])));if(u.length!==h.length||d.some((t=>!t))){const t=this.vel.children(),e=h.map(((e,n)=>{const r=n in t?t[n].node:null;if(d[n])return r;const s=this.createListItem(e,a,r);if(!s)return null;if(!(s instanceof SVGElement))throw new Error("List: item must be an SVGElement");s.dataset.index=n,s.dataset.attribute=i;const h=n*(c+o);return s.setAttribute("transform",l?`translate(${h}, 0)`:`translate(0, ${h})`),s}));this.vel.empty().append(e),this._prevItems=h}const f=h.length,p=0===f?0:f*c+(f-1)*o,g=l?{width:p,height:a.height}:{width:a.width,height:p};this.position(n,g)},position(t,e){const{vel:n,options:i}=this,{margin:r=5,position:o="top-left"}=i,{width:s,height:a}=t.size(),{left:l,right:c,top:h,bottom:u}=Qs(r),d=new me(l,h,s-(l+c),a-(h+u));let{x:f,y:p}=lc(d,o);switch(o){case ac.CENTER:case ac.TOP:case ac.BOTTOM:f-=e.width/2;break;case ac.RIGHT:case ac.BOTTOM_RIGHT:case ac.TOP_RIGHT:f-=e.width}switch(o){case ac.CENTER:case ac.RIGHT:case ac.LEFT:p-=e.height/2;break;case ac.BOTTOM:case ac.BOTTOM_RIGHT:case ac.BOTTOM_LEFT:p-=e.height}n.attr("transform",`translate(${f}, ${p})`)}},{Directions:Su,Positions:ac});function _u(t,e,n,i){var r="ratio"in i?i.ratio:.5;return t.getPointAtRatio(r)}function ku(t,e,n,i){var r="length"in i?i.length:20;return t.getPointAtLength(r)}function Lu(t){return function(e,n,i,r){if(i instanceof Element){var o,s=this.paper.findView(i);return o=s?s.isNodeConnection(i)?Cu(s,"fixedAt"in r?r.fixedAt:"50%"):s.getNodeBBox(i).center():new Jt,t.call(this,e,n,o,r)}return t.apply(this,arguments)}}function Cu(t,e){var n=parseFloat(e);return Ys(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}const Mu=Lu((function(t,e,n,i){var r=1e6,o=t.getConnection(),s=t.getConnectionSubdivisions(),a=new ne(n.clone().offset(0,r),n.clone().offset(0,-r)),l=new ne(n.clone().offset(r,0),n.clone().offset(-r,0)),c=a.intersect(o,{segmentSubdivisions:s}),h=l.intersect(o,{segmentSubdivisions:s}),u=[];return c&&Array.prototype.push.apply(u,c),h&&Array.prototype.push.apply(u,h),u.length>0?n.chooseClosest(u):"fallbackAt"in i?Cu(t,i.fallbackAt):Ou(t,e,n,i)})),Ou=Lu((function(t,e,n,i){return t.getClosestPoint(n)||new Jt}));function Nu(t,e,n){if(mo(n)){const{x:i,y:r}=n;if(isFinite(r)){const n=new ne(e,t),{start:i,end:o}=n.parallel(r);e=i,t=o}n=i}if(!isFinite(n))return t;var i=t.distance(e);return 0===n&&i>0?t:t.move(e,-Math.min(n,i-1))}function Ru(t){var e=t.getAttribute("stroke-width");return null===e?0:parseFloat(e)||0}function Fu(t,e,n,i){var r=e.getNodeBBox(n);i.stroke&&r.inflate(Ru(n)/2);var o=t.intersect(r);return Nu(o?t.start.chooseClosest(o):t.end,t.start,i.offset)}var Bu="segmentSubdivisons",Iu="shapeBBox";const Du=function(t,e,n,i){let{offset:r,alignOffset:o,align:s}=i;return s&&function(t,e,n=0){let i,r,o,s;const{start:a,end:l}=t;switch(e){case"left":i="x",r=l,o=a,s=-1;break;case"right":i="x",r=a,o=l,s=1;break;case"top":i="y",r=l,o=a,s=-1;break;case"bottom":i="y",r=a,o=l,s=1;break;default:return}a[i]<l[i]?r[i]=o[i]:o[i]=r[i],isFinite(n)&&(r[i]+=s*n,o[i]+=s*n)}(t,s,o),Nu(t.end,t.start,r)},Vu=Fu,zu=function(t,e,n,i){var r=e.model.angle();if(0===r)return Fu(t,e,n,i);var o=e.getNodeUnrotatedBBox(n);i.stroke&&o.inflate(Ru(n)/2);var s=o.center(),a=t.clone().rotate(s,r),l=a.setLength(1e6).intersect(o);return Nu(l?a.start.chooseClosest(l).rotate(s,-r):t.end,t.start,i.offset)},ju=function(t,e,n,i){var r,o,s=i.selector,a=t.end;if(r="string"==typeof s?e.findNode(s):!1===s?n:Array.isArray(s)?Ds(n,s):function(t){if(!t)return null;var e=t;do{var n=e.tagName;if("string"!=typeof n)return null;if("G"===(n=n.toUpperCase()))e=e.firstElementChild;else{if("TITLE"!==n)break;e=e.nextElementSibling}}while(e);return e}(n),!An.isSVGGraphicsElement(r)){if(r===n||!An.isSVGGraphicsElement(n))return a;r=n}var l,c=e.getNodeShape(r),h=e.getNodeMatrix(r),u=e.getRootTranslateMatrix(),d=e.getRootRotateMatrix(),f=u.multiply(d).multiply(h),p=f.inverse(),g=An.transformLine(t,p),m=g.start.clone(),v=e.getNodeData(r);if(!1===i.insideout&&(v[Iu]||(v[Iu]=c.bbox()),v[Iu].containsPoint(m)))return a;if(c instanceof Le){var y=i.precision||2;v[Bu]||(v[Bu]=c.getSegmentSubdivisions({precision:y})),l={precision:y,segmentSubdivisions:v[Bu]}}!0===i.extrapolate&&g.setLength(1e6),(o=g.intersect(c,l))?An.isArray(o)&&(o=m.chooseClosest(o)):!0===i.sticky&&(o=c instanceof me?c.pointNearestToPoint(m):c instanceof ae?c.intersectionWithLineFromCenterToPoint(m):c.closestPoint(m,l));var b=o?An.transformPoint(o,f):a,w=i.offset||0;return i.stroke&&(w+=Ru(r)/2),Nu(b,t.start,w)};function $u(t){return function(e,n,i,r){var o=!!r.rotate,s=o?e.getNodeUnrotatedBBox(n):e.getNodeBBox(n),a=s[t](),l=r.dx;if(l){var c=Ys(l);l=parseFloat(l),isFinite(l)&&(c&&(l/=100,l*=s.width),a.x+=l)}var h=r.dy;if(h){var u=Ys(h);h=parseFloat(h),isFinite(h)&&(u&&(h/=100,h*=s.height),a.y+=h)}return o?a.rotate(e.model.getBBox().center(),-e.model.angle()):a}}const Uu=$u("center"),Gu=$u("topMiddle"),qu=$u("bottomMiddle"),Hu=$u("leftMiddle"),Wu=$u("rightMiddle"),Yu=$u("origin"),Xu=$u("topRight"),Zu=$u("bottomLeft"),Ku=$u("corner"),Ju=Lu((function(t,e,n,i){var r=t.model.angle(),o=t.getNodeBBox(e),s=o.center(),a=o.origin(),l=o.corner(),c=i.padding;if(isFinite(c)||(c=0),a.y+c<=n.y&&n.y<=l.y-c){var h=n.y-s.y;s.x+=0===r||180===r?0:1*h/Math.tan(Nt(r)),s.y+=h}else if(a.x+c<=n.x&&n.x<=l.x-c){var u=n.x-s.x;s.y+=90===r||270===r?0:u*Math.tan(Nt(r)),s.x+=u}return s})),Qu=Lu((function(t,e,n,i){var r,o,s,a=!!i.rotate;a?(r=t.getNodeUnrotatedBBox(e),s=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e);var l,c=i.padding;switch(isFinite(c)&&r.inflate(c),a&&n.rotate(s,o),r.sideNearestToPoint(n)){case"left":l=r.leftMiddle();break;case"right":l=r.rightMiddle();break;case"top":l=r.topMiddle();break;case"bottom":l=r.bottomMiddle()}return a?l.rotate(s,-o):l})),td=function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)},ed=yu.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init(){yu.prototype.init.apply(this,arguments);const{options:{paper:t}}=this;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings(t){const e=[];return t&&(Array.isArray(t)?t:[t||{}]).forEach((t=>{e.push(...this._resolveDrawGridOption(t))})),e},removeGrid(){const{_gridCache:t}=this;t&&(t.root.remove(),this._gridCache=null)},renderGrid(){const{options:{paper:t}}=this,{_gridSettings:e}=this;if(this.removeGrid(),0===e.length)return;const n=t.options.drawGridSize||t.options.gridSize;if(n<=1)return;const i=this._getGridRefs();e.forEach(((e,r)=>{const o="pattern_"+r,s=Mo({},e),{scaleFactor:a=1}=s;let l;s.width=n*a||1,s.height=n*a||1,i.exist(o)?l=i.get(o):(l=An("pattern",{id:o,patternUnits:"userSpaceOnUse"},An(s.markup)),i.add(o,l)),go(s.render)&&s.render(l.node.firstChild,s,t),l.attr({width:s.width,height:s.height})})),i.root.appendTo(this.el),this.updateGrid()},updateGrid(){const{_gridCache:t,_gridSettings:e,options:{paper:n}}=this;if(!t)return;const{root:i,patterns:r}=t,{x:o,y:s,width:a,height:l}=n.getArea();i.attr({x:o,y:s,width:a,height:l});for(const t in r)r[t].attr({x:-o,y:-s});e.forEach(((t,e)=>{if(go(t.update)){const i=r["pattern_"+e];t.update(i.node.firstChild,t,n)}}))},_getGridRefs(){let{_gridCache:t}=this;if(t)return t;const e=An("defs"),n=An("svg",{width:"100%",height:"100%"},[e]);return t=this._gridCache={root:n,patterns:{},add:function(t,i){const r=An("rect",{width:"100%",height:"100%",fill:`url(#${t})`});e.append(i),n.append(r),this.patterns[t]=i},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}},t},_resolveDrawGridOption(t){var e=this.options.patterns;if(no(t)&&Array.isArray(e[t]))return e[t].map((function(t){return io({},t)}));var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if(i||r||n.markup||(r="dot"),r&&Array.isArray(e[r])){var o=e[r].map((function(t){return io({},t)})),s=Array.isArray(n.args)?n.args:[n.args||{}];ro(s[0],So(t,"args"));for(var a=0;a<s.length;a++)o[a]&&io(o[a],s[a]);return o}return i?n:[n]}}),nd={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"},id=1/0,rd=9007199254740991,od=Rc.Highlighting,sd={[od.DEFAULT]:{name:"stroke",options:{padding:3}},[od.MAGNET_AVAILABILITY]:{name:"addClass",options:{className:"available-magnet"}},[od.ELEMENT_AVAILABILITY]:{name:"addClass",options:{className:"available-cell"}}},ad=[{name:vu.GRID},{name:vu.BACK},{name:vu.CELLS},{name:vu.LABELS},{name:vu.FRONT},{name:vu.TOOLS}],ld=Pc.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:Vc,linkView:mu,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:sd,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){const{cellNamespace:t}=this.model.get("cells"),e=Ds(t,["standard","Link"]);if(!e)throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.");return new e},defaultConnector:{name:"normal"},defaultRouter:{name:"normal"},defaultAnchor:{name:"center"},defaultLinkAnchor:{name:"connectionRatio"},defaultConnectionPoint:{name:"boundary"},connectionStrategy:null,validateMagnet:function(t,e,n){return"passive"!==e.getAttribute("magnet")},validateConnection:function(t,e,n,i,r,o){return("target"===r?n:t)instanceof Vc},embeddingMode:!1,validateEmbedding:function(t,e){return!0},validateUnembedding:function(t){return!0},findParentBy:"bbox",frontParentOnly:!0,interactive:{labelMove:!1},linkPinning:!0,allowLink:null,clickThreshold:0,moveThreshold:0,magnetThreshold:0,sorting:nd.APPROX,frozen:!1,autoFreeze:!1,onViewUpdate:function(t,e,n,i,r){e&(t.FLAG_INSERT|t.FLAG_REMOVE)||i.mounting||i.isolate||r.requestConnectedLinksUpdate(t,n,i)},onViewPostponed:function(t,e,n){return n.forcePostponedViewUpdate(t,e)},beforeRender:null,afterRender:null,viewport:null,cellViewNamespace:null,routerNamespace:null,connectorNamespace:null,highlighterNamespace:d,anchorNamespace:g,linkAnchorNamespace:f,connectionPointNamespace:p,overflow:!1},events:{dblclick:"pointerdblclick",dbltap:"pointerdblclick",contextmenu:"contextmenu",mousedown:"pointerdown",touchstart:"pointerdown",mouseover:"mouseover",mouseout:"mouseout",mouseenter:"mouseenter",mouseleave:"mouseleave",wheel:"mousewheel","mouseenter .joint-cell":"mouseenter","mouseleave .joint-cell":"mouseleave","mouseenter .joint-tools":"mouseenter","mouseleave .joint-tools":"mouseleave","dblclick .joint-cell [magnet]":"magnetpointerdblclick","contextmenu .joint-cell [magnet]":"magnetcontextmenu","mousedown .joint-link .label":"onlabel","touchstart .joint-link .label":"onlabel","dragstart .joint-cell image":"onImageDragStart"},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup",touchcancel:"pointerup"},stylesheet:"\n .joint-element .scalable * {\n vector-effect: non-scaling-stroke;\n }\n ",svg:null,viewport:null,defs:null,tools:null,layers:null,_viewportMatrix:null,_viewportTransformString:null,_updates:null,_layers:null,SORT_DELAYING_BATCHES:["add","to-front","to-back"],UPDATE_DELAYING_BATCHES:["translate"],FORM_CONTROL_TAG_NAMES:["TEXTAREA","INPUT","BUTTON","SELECT","OPTION"],GUARDED_TAG_NAMES:["SELECT"],MIN_SCALE:1e-6,init:function(){const{options:t}=this;t.cellViewNamespace||(t.cellViewNamespace="undefined"!=typeof joint&&To(joint,"shapes")?joint.shapes:null);const e=this.model=t.model||new xc;this._layers={},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(e.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates&&this._updates.id&&qs(this._updates.id),this._updates={id:null,priorities:[{},{},{}],unmountedCids:[],mountedCids:[],unmounted:{},mounted:{},count:0,keyFrozen:!1,freezeKey:null,sort:!1,disabled:!1,idle:!1}},startListening:function(){var t=this.model;this.listenTo(t,"add",this.onCellAdded).listenTo(t,"remove",this.onCellRemoved).listenTo(t,"change",this.onCellChange).listenTo(t,"reset",this.onGraphReset).listenTo(t,"sort",this.onGraphSort).listenTo(t,"batch:stop",this.onGraphBatchStop),this.on("cell:highlight",this.onCellHighlight).on("cell:unhighlight",this.onCellUnhighlight).on("transform",this.update)},onCellAdded:function(t,e,n){var i=n.position;this.isAsync()||!eo(i)?this.renderView(t,n):(n.maxPosition===i&&this.freeze({key:"addCells"}),this.renderView(t,n),0===i&&this.unfreeze({key:"addCells"}))},onCellRemoved:function(t,e,n){const i=this.findViewByModel(t);i&&this.requestViewUpdate(i,i.FLAG_REMOVE,i.UPDATE_PRIORITY,n)},onCellChange:function(t,e){if(t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===nd.APPROX){const n=this.findViewByModel(t);n&&this.requestViewUpdate(n,n.FLAG_INSERT,n.UPDATE_PRIORITY,e)}},onGraphReset:function(t,e){this.resetLayers(),this.resetViews(t.models,e)},onGraphSort:function(){this.model.hasActiveBatch(this.SORT_DELAYING_BATCHES)||this.sortViews()},onGraphBatchStop:function(t){if(!this.isFrozen()){var e=t&&t.batchName,n=this.model;if(!this.isAsync()){var i=this.UPDATE_DELAYING_BATCHES;i.includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t)}var r=this.SORT_DELAYING_BATCHES;r.includes(e)&&!n.hasActiveBatch(r)&&this.sortViews()}},cloneOptions:function(){const{options:t}=this,{defaultConnector:e,defaultRouter:n,defaultConnectionPoint:i,defaultAnchor:r,defaultLinkAnchor:o,highlighting:s,cellViewNamespace:a,interactive:l}=t;!a&&"undefined"!=typeof joint&&To(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),go(e)||(t.defaultConnector=uo(e)),go(n)||(t.defaultRouter=uo(n)),go(i)||(t.defaultConnectionPoint=uo(i)),go(r)||(t.defaultAnchor=uo(r)),go(o)||(t.defaultLinkAnchor=uo(o)),mo(l)&&(t.interactive=io({},l)),mo(s)&&(t.highlighting=oo({},s,sd))},children:function(){var t=An.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:Fs("paper-background"),selector:"background",style:{position:"absolute",inset:0}},{namespaceURI:t.svg,tagName:"svg",attributes:{width:"100%",height:"100%","xmlns:xlink":t.xlink},selector:"svg",style:{position:"absolute",inset:0},children:[{tagName:"defs",selector:"defs"},{tagName:"g",className:Fs("layers"),selector:"layers"}]}]},hasLayerView(t){return t in this._layers},getLayerView(t){const{_layers:e}=this;if(t in e)return e[t];throw new Error(`dia.Paper: Unknown layer "${t}"`)},getLayerNode(t){return this.getLayerView(t).el},render:function(){this.renderChildren();const{el:t,childNodes:e,options:n,stylesheet:i}=this,{svg:r,defs:o,layers:s}=e;return t.style.position="relative",r.style.overflow=n.overflow?"visible":"hidden",this.svg=r,this.defs=o,this.layers=s,this.renderLayers(),An.ensureId(r),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&An(this.svg).prepend(An.createSVGStyle(t))},createLayer(t){return t===vu.GRID?new ed({name:t,paper:this,patterns:this.constructor.gridPatterns}):new yu({name:t})},renderLayers:function(t=ad){this.removeLayers(),t.forEach((({name:t,sorted:e})=>{const n=this.createLayer(t);this.layers.appendChild(n.el),this._layers[t]=n}));const e=this.getLayerView(vu.CELLS),n=this.getLayerView(vu.TOOLS),i=this.getLayerView(vu.LABELS);this.tools=n.el,this.cells=this.viewport=e.el,e.vel.addClass(Fs("viewport")),i.vel.addClass(Fs("viewport")),e.el.style.webkitUserSelect="none",e.el.style.userSelect="none",i.el.style.webkitUserSelect="none",i.el.style.userSelect="none"},removeLayers:function(){const{_layers:t}=this;Object.keys(t).forEach((e=>{t[e].remove(),delete t[e]}))},resetLayers:function(){const{_layers:t}=this;Object.keys(t).forEach((e=>{t[e].removePivots()}))},update:function(){return this._background&&this.updateBackgroundImage(this._background),this},scale:function(t,e,n){const i=this.matrix();return void 0===t?An.matrixToScale(i):(void 0===e&&(e=t),t=Math.max(t||0,this.MIN_SCALE),e=Math.max(e||0,this.MIN_SCALE),i.a=t,i.d=e,this.matrix(i,n),this)},scaleUniformAtPoint:function(t,e,n){const{a:i,d:r,e:o,f:s}=this.matrix();if((t=Math.max(t||0,this.MIN_SCALE))===i&&t===r)return this;const a=An.createSVGMatrix().translate(o-e.x*(t-i),s-e.y*(t-r)).scale(t,t);return this.matrix(a,n),this},translate:function(t,e,n){const i=this.matrix();return void 0===t?An.matrixToTranslate(i):(t||(t=0),e||(e=0),i.e===t&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t,e={}){var n=this.layers;if(void 0===t){var i=n.getAttribute("transform");return(this._viewportTransformString||null)===i?t=this._viewportMatrix:(t=n.getCTM(),this._viewportMatrix=t,this._viewportTransformString=i),An.createSVGMatrix(t)}const r=this.matrix(),o=An.createSVGMatrix(t),s=this._viewportTransformString,a=An.matrixToTransformString(o);if(a===s)return this;if(!s&&An.matrixToTransformString()===a)return this;const{a:l,d:c,e:h,f:u}=o;return n.setAttribute("transform",a),this._viewportMatrix=o,this._viewportTransformString=n.getAttribute("transform"),l===r.a&&c===r.d||this.trigger("scale",l,c,e),h===r.e&&u===r.f||this.trigger("translate",h,u,e),this.trigger("transform",o,e),this},clientMatrix:function(){return An.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof Rc)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,s=r.length;o<s;o++){var a=r[o],l=this.findViewByModel(a);if(l){var c=["UPDATE"];a.getTargetCell()===i&&c.push("TARGET"),a.getSourceCell()===i&&c.push("SOURCE");var h=Math.max(e+1,l.UPDATE_PRIORITY);this.scheduleViewUpdate(l,l.getFlag(c),h,n)}}},forcePostponedViewUpdate:function(t,e){if(!(t&&t instanceof Rc))return!1;var n=t.model;if(n.isElement())return!1;if(!(e&t.getFlag(["SOURCE","TARGET"]))){var i={silent:!0},r=0,o=this.findViewByModel(n.getSourceCell());o&&!this.isViewMounted(o)&&(r=this.dumpView(o,i),t.updateEndMagnet("source"));var s=0,a=this.findViewByModel(n.getTargetCell());if(a&&!this.isViewMounted(a)&&(s=this.dumpView(a,i),t.updateEndMagnet("target")),0===r&&0===s)return!this.dumpView(t,i)}return!1},requestViewUpdate:function(t,e,n,i){i||(i={}),this.scheduleViewUpdate(t,e,n,i);var r=this.isAsync();if(!(this.isFrozen()||r&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES))){var o=this.updateViews(i);r&&this.notifyAfterRender(o,i)}},scheduleViewUpdate:function(t,e,n,i){const{_updates:r,options:o}=this;r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze());const{FLAG_REMOVE:s,FLAG_INSERT:a,UPDATE_PRIORITY:l,cid:c}=t;let h=r.priorities[n];if(h||(h=r.priorities[n]={}),n>l)for(let t=n-1;t>=l;t--){const e=r.priorities[t];e&&c in e&&(h[c]|=e[c],delete e[c])}let u=h[c]||0;if((u&e)===e)return;u||r.count++,e&s&&u&a?h[c]^=a:e&a&&u&s&&(h[c]^=s),h[c]|=e;const d=o.onViewUpdate;"function"==typeof d&&d.call(this,t,e,n,i||{},this)},dumpViewUpdate:function(t){if(!t)return 0;var e=this._updates,n=t.cid,i=e.priorities[t.UPDATE_PRIORITY],r=this.registerMountedView(t)|i[n];return delete i[n],r},dumpView:function(t,e={}){const n=this.dumpViewUpdate(t);if(!n)return 0;const i=!e.silent;i&&this.notifyBeforeRender(e);const r=this.updateView(t,n,e);if(i){const n={updated:1,priority:t.UPDATE_PRIORITY};this.notifyAfterRender(n,e)}return r},updateView:function(t,e,n){if(!t)return 0;const{FLAG_REMOVE:i,FLAG_INSERT:r,FLAG_INIT:o,model:s}=t;if(t instanceof Rc){if(e&i)return this.removeView(s),0;if(e&r){const n=!!(e&o);n&&(e^=o),this.insertView(t,n),e^=r}}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){var n=this.findViewByModel(t);return n?(this.dumpView(n,e),n):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;if(e in n.unmounted)return 0;var i=n.unmounted[e]|=t.FLAG_INSERT;return n.unmountedCids.push(e),delete n.mounted[e],i},registerMountedView:function(t){var e=t.cid,n=this._updates;if(e in n.mounted)return 0;n.mounted[e]=!0,n.mountedCids.push(e);var i=n.unmounted[e]||0;return delete n.unmounted[e],i},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){var e=ro({},t,{viewport:null});this.checkViewport(e),this.updateViews(e)},updateViews:function(t){let e;this.notifyBeforeRender(t);let n=0,i=0,r=rd;do{i++,e=this.updateViewsBatch(t),n+=e.updated,r=Math.min(e.priority,r)}while(!e.empty);const o={updated:n,batches:i,priority:r};return this.notifyAfterRender(o,t),o},hasScheduledUpdates:function(){const t=this._updates.priorities,e=Object.keys(t);let n=e.length;for(;n>0&&n--;)for(let i in t[e[n]])return!0;return!1},updateViewsAsync:function(t,e){t||(t={}),e||(e={processed:0,priority:rd});const{_updates:n,options:i}=this,r=n.id;if(r){qs(r),0===e.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(t);const o=this.updateViewsBatch(t),s=ro({},t,{mountBatchSize:1e3-o.mounted,unmountBatchSize:1e3-o.unmounted}),a=this.checkViewport(s),l=a.unmounted,c=a.mounted;let h=e.processed;const u=n.count;o.updated>0?(h+=o.updated+o.unmounted,o.processed=h,e.priority=Math.min(o.priority,e.priority),o.empty&&0===c?(o.unmounted+=l,o.mounted+=c,o.priority=e.priority,this.notifyAfterRender(o,t),e.processed=0,e.priority=rd,n.count=0):e.processed=h):n.idle||i.autoFreeze&&(this.freeze(),n.idle=!0,this.trigger("render:idle",t));const d=t.progress;if(u&&"function"==typeof d&&d.call(this,o.empty,h,u,o,this),n.id!==r)return}if(n.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");n.id=Gs(this.updateViewsAsync,this,t,e)},notifyBeforeRender:function(t={}){let e=t.beforeRender;"function"!=typeof e&&(e=this.options.beforeRender,"function"!=typeof e)||e.call(this,t,this)},notifyAfterRender:function(t,e={}){let n=e.afterRender;"function"!=typeof n&&(n=this.options.afterRender),"function"==typeof n&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){t||(t={});var e=t.batchSize||id,n=this._updates,i=0,r=0,o=0,s=0,a=rd,l=!0,c=this.options,h=n.priorities,u="viewport"in t?t.viewport:c.viewport;"function"!=typeof u&&(u=null);var d=c.onViewPostponed;"function"!=typeof d&&(d=null);var f=Object.keys(h);t:for(var p=0,g=f.length;p<g;p++){var m=+f[p],v=h[m];for(var y in v){if(i>=e){l=!1;break t}var b=Sc[y];if(b){var w=v[y];if(!(w&b.FLAG_REMOVE)){var x=y in n.unmounted;if(b.DETACHABLE&&u&&!u.call(this,b,!x,this)){x||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[y]|=w,delete v[y],o++;continue}x&&(w|=b.FLAG_INSERT,s++),w|=this.registerMountedView(b)}var A=this.updateView(b,w,t);A>0&&(v[y]=A,!d||!d.call(this,b,A,this)||v[y])?(r++,l=!1):(a>m&&(a=m),i++,delete v[y])}else delete v[y]}}return{priority:a,updated:i,postponed:r,unmounted:o,mounted:s,empty:l}},getUnmountedViews:function(){const t=this._updates,e=Object.keys(t.unmounted),n=e.length,i=new Array(n);for(var r=0;r<n;r++)i[r]=Sc[e[r]];return i},getMountedViews:function(){const t=this._updates,e=Object.keys(t.mounted),n=e.length,i=new Array(n);for(var r=0;r<n;r++)i[r]=Sc[e[r]];return i},checkUnmountedViews:function(t,e){e||(e={});var n=0;"function"!=typeof t&&(t=null);for(var i=("mountBatchSize"in e?e.mountBatchSize:1/0),r=this._updates,o=r.unmountedCids,s=r.unmounted,a=0,l=Math.min(o.length,i);a<l;a++){var c=o[a];if(c in s){var h=Sc[c];if(h)if(h.DETACHABLE&&t&&!t.call(this,h,!1,this))o.push(c);else{n++;var u=this.registerMountedView(h);u&&this.scheduleViewUpdate(h,u,h.UPDATE_PRIORITY,{mounting:!0})}}}return o.splice(0,a),n},checkMountedViews:function(t,e){e||(e={});var n=0;if("function"!=typeof t)return n;for(var i=("unmountBatchSize"in e?e.unmountBatchSize:1/0),r=this._updates,o=r.mountedCids,s=r.mounted,a=0,l=Math.min(o.length,i);a<l;a++){var c=o[a];if(c in s){var h=Sc[c];h&&(h.DETACHABLE&&!t.call(this,h,!0,this)?(n++,this.registerUnmountedView(h)&&this.detachView(h)):o.push(c))}}return o.splice(0,a),n},checkViewVisibility:function(t,e={}){let n="viewport"in e?e.viewport:this.options.viewport;"function"!=typeof n&&(n=null);const i=this._updates,{mounted:r,unmounted:o}=i,s=!t.DETACHABLE||!n||n.call(this,t,!1,this);let a=!1,l=!1;if(t.cid in r&&!s){this.registerUnmountedView(t)&&this.detachView(t);const e=i.mountedCids.indexOf(t.cid);i.mountedCids.splice(e,1),a=!0}if(!a&&t.cid in o&&s){const e=i.unmountedCids.indexOf(t.cid);i.unmountedCids.splice(e,1);var c=this.registerMountedView(t);c&&this.scheduleViewUpdate(t,c,t.UPDATE_PRIORITY,{mounting:!0}),l=!0}return{mounted:l?1:0,unmounted:a?1:0}},checkViewport:function(t){var e=ro({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n="viewport"in e?e.viewport:this.options.viewport,i=this.checkMountedViews(n,e);if(i>0){var r=this._updates.unmountedCids;e.mountBatchSize=Math.min(r.length-i,e.mountBatchSize)}return{mounted:this.checkUnmountedViews(n,e),unmounted:i}},freeze:function(t){t||(t={});var e=this._updates,n=t.key,i=this.options.frozen,r=e.freezeKey;if(n&&n!==r){if(i&&r)return;e.freezeKey=n,e.keyFrozen=i}this.options.frozen=!0;var o=e.id;e.id=null,this.isAsync()&&o&&qs(o)},unfreeze:function(t){t||(t={});var e=this._updates,n=t.key,i=e.freezeKey;n&&i&&n!==i||(e.freezeKey=null,n&&n===i&&e.keyFrozen||(this.isAsync()?(this.freeze(),this.updateViewsAsync(t)):this.updateViews(t),this.options.frozen=e.keyFrozen=!1,e.sort&&(this.sortViews(),e.sort=!1)))},isAsync:function(){return!!this.options.async},isFrozen:function(){return!!this.options.frozen},isExactSorting:function(){return this.options.sorting===nd.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,n=t.height;return eo(e)||(e=this.el.clientWidth),eo(n)||(n=this.el.clientHeight),{width:e,height:n}},setDimensions:function(t,e,n={}){const{options:i}=this,{width:r,height:o}=i;let s=void 0===t?r:t,a=void 0===e?o:e;if(r===s&&o===a)return;i.width=s,i.height=a,this._setDimensions();const l=this.getComputedSize();this.trigger("resize",l.width,l.height,n)},_setDimensions:function(){const{options:t}=this;let e=t.width,n=t.height;eo(e)&&(e=`${Math.round(e)}px`),eo(n)&&(n=`${Math.round(n)}px`),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=to(t)?t:io({gridWidth:t,gridHeight:e,padding:n},i);const{x:r,y:o,width:s,height:a}=this.getFitToContentArea(i),{sx:l,sy:c}=this.scale();return this.translate(-r*l,-o*c,i),this.setDimensions(s*l,a*c,i),new me(r,o,s,a)},getFitToContentArea:function(t={}){const e=t.gridWidth||1,n=t.gridHeight||1,i=Qs(t.padding||0),r=Math.max(t.minWidth||0,e),o=Math.max(t.minHeight||0,n),s=t.maxWidth||Number.MAX_VALUE,a=t.maxHeight||Number.MAX_VALUE,l=t.allowNewOrigin,c="contentArea"in t?new me(t.contentArea):this.getContentArea(t),{sx:h,sy:u}=this.scale();c.x*=h,c.y*=u,c.width*=h,c.height*=u;let d=Math.ceil((c.width+c.x)/e),f=Math.ceil((c.height+c.y)/n);t.allowNegativeBottomRight||(d=Math.max(d,1),f=Math.max(f,1)),d*=e,f*=n;let p=0;("negative"===l&&c.x<0||"positive"===l&&c.x>=0||"any"===l)&&(p=Math.ceil(-c.x/e)*e,p+=i.left,d+=p);let g=0;return("negative"===l&&c.y<0||"positive"===l&&c.y>=0||"any"===l)&&(g=Math.ceil(-c.y/n)*n,g+=i.top,f+=g),d+=i.right,f+=i.bottom,d=Math.max(d,r),f=Math.max(f,o),d=Math.min(d,s),f=Math.min(f,a),new me(-p/h,-g/u,d/h,f/u)},transformToFitContent:function(t){let e,n;if(t||(t={}),"contentArea"in t){const i=t.contentArea;e=this.localToPaperRect(i),n=new Jt(i)}else e=this.getContentBBox(t),n=this.paperToLocalPoint(e);if(!e.width||!e.height)return;ro(t,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});const i=Qs(t.padding),r=t.minScaleX||t.minScale,o=t.maxScaleX||t.maxScale,s=t.minScaleY||t.minScale,a=t.maxScaleY||t.maxScale;let l;if(t.fittingBBox)l=t.fittingBBox;else{const t=this.translate(),e=this.getComputedSize();l={x:t.tx,y:t.ty,width:e.width,height:e.height}}l=new me(l).moveAndExpand({x:i.left,y:i.top,width:-i.left-i.right,height:-i.top-i.bottom});const c=this.matrix(),{a:h,d:u,e:d,f}=c;let p=l.width/e.width*h,g=l.height/e.height*u;if(t.preserveAspectRatio&&(p=g=Math.min(p,g)),t.scaleGrid){const e=t.scaleGrid;p=e*Math.floor(p/e),g=e*Math.floor(g/e)}p=Math.min(o,Math.max(r,p)),g=Math.min(a,Math.max(s,g));const m=p/h,v=g/u;let y=l.x-n.x*p-d,b=l.y-n.y*g-f;switch(t.verticalAlign){case"middle":b+=(l.height-e.height*v)/2;break;case"bottom":b+=l.height-e.height*v}switch(t.horizontalAlign){case"middle":y+=(l.width-e.width*m)/2;break;case"right":y+=l.width-e.width*m}c.a=p,c.d=g,c.e=y,c.f=b,this.matrix(c,t)},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new me:An(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(...t){const{restrictTranslate:e}=this.options;let n;return n=go(e)?e.apply(this,t):!0===e?this.getArea():e?new me(e):null,n},createViewForModel:function(t){const{options:e}=this;var n,i,r=e.cellViewNamespace,o=t.get("type")+"View",s=Ds(r,o,".");return t.isLink()?(n=e.linkView,i=mu):(n=e.elementView,i=Vc),new(n.prototype instanceof Ac?s||n:n.call(this,t)||s||i)({model:t,interactive:e.interactive,labelsLayer:!0===e.labelsLayer?vu.LABELS:e.labelsLayer})},removeView:function(t){const{id:e}=t,{_views:n,_updates:i}=this,r=n[e];if(r){var{cid:o}=r;const{mounted:t,unmounted:s}=i;r.remove(),delete n[e],delete t[o],delete s[o]}return r},renderView:function(t,e){const{id:n}=t,i=this._views;let r,o,s=!0;return n in i&&(r=i[n],r.model===t?(o=r.FLAG_INSERT,s=!1):this.removeView(t)),s&&(r=i[n]=this.createViewForModel(t),r.paper=this,o=this.registerUnmountedView(r)|this.FLAG_INIT|r.getFlag(Eo(r,"initFlag"))),this.requestViewUpdate(r,o,r.UPDATE_PRIORITY,e),r},onImageDragStart:function(){return!1},resetViews:function(t,e){e||(e={}),t||(t=[]),this._resetUpdates(),this.removeViews();const n=this.options.autoFreeze?null:"reset";this.freeze({key:n});for(var i=0,r=t.length;i<r;i++)this.renderView(t[i],e);this.unfreeze({key:n}),this.sortViews()},removeViews:function(){so(this._views,"remove"),this._views={}},sortViews:function(){this.isExactSorting()&&(this.isFrozen()?this._updates.sort=!0:this.sortViewsExact())},sortViewsExact:function(){var t=Array.from(this.cells.childNodes).filter((t=>t.getAttribute("model-id"))),e=this.model.get("cells");!function(t,n){var i=(t=Rs(t).toArray()).map((function(t){var e=t.parentNode,n=e.insertBefore(document.createTextNode(""),t.nextSibling);return function(){if(e===this)throw new Error("You can't sort elements if any one is a descendant of another.");e.insertBefore(this,n),e.removeChild(n)}}));t.sort((function(t,n){var i=e.get(t.getAttribute("model-id")),r=e.get(n.getAttribute("model-id")),o=i.attributes.z||0,s=r.attributes.z||0;return o===s?0:o<s?-1:1}));for(var r=0;r<i.length;r++)i[r].call(t[r])}(t)},insertView:function(t,e){const n=this.getLayerView(vu.CELLS),{el:i,model:r}=t;this.options.sorting===nd.APPROX?n.insertSortedNode(i,r.get("z")):n.insertNode(i),t.onMount(e)},detachView(t){t.unmount(),t.onDetach()},findView:function(t){var e=no(t)?this.cells.querySelector(t):t instanceof Rs?t[0]:t,n=this.findAttribute("model-id",e);if(n)return this._views[n]},findViewByModel:function(t){var e=no(t)||eo(t)?t:t&&t.id;return this._views[e]},findViewsFromPoint:function(t){return t=new Jt(t),this.model.getElements().map(this.findViewByModel,this).filter((function(e){return e&&e.vel.getBBox({target:this.cells}).containsPoint(t)}),this)},findViewsInArea:function(t,e){e=ro(e||{},{strict:!1}),t=new me(t);var n=this.model.getElements().map(this.findViewByModel,this),i=e.strict?"containsRect":"intersect";return n.filter((function(e){return e&&t[i](e.vel.getBBox({target:this.cells}))}),this)},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t,...e){"string"==typeof t&&this.trigger("tools:event",t,...e)},getModelById:function(t){return this.model.getCell(t)},snapToGrid:function(t,e){return this.clientToLocalPoint(t,e).snapToGrid(this.options.gridSize)},localToPaperPoint:function(t,e){var n=new Jt(t,e);return An.transformPoint(n,this.matrix())},localToPaperRect:function(t,e,n,i){var r=new me(t,e,n,i);return An.transformRect(r,this.matrix())},paperToLocalPoint:function(t,e){var n=new Jt(t,e);return An.transformPoint(n,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){var r=new me(t,e,n,i);return An.transformRect(r,this.matrix().inverse())},localToClientPoint:function(t,e){var n=new Jt(t,e);return An.transformPoint(n,this.clientMatrix())},localToClientRect:function(t,e,n,i){var r=new me(t,e,n,i);return An.transformRect(r,this.clientMatrix())},clientToLocalPoint:function(t,e){var n=new Jt(t,e);return An.transformPoint(n,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){var r=new me(t,e,n,i);return An.transformRect(r,this.clientMatrix().inverse())},localToPagePoint:function(t,e){return this.localToPaperPoint(t,e).offset(this.pageOffset())},localToPageRect:function(t,e,n,i){return this.localToPaperRect(t,e,n,i).offset(this.pageOffset())},pageToLocalPoint:function(t,e){var n=new Jt(t,e).difference(this.pageOffset());return this.paperToLocalPoint(n)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),o=new me(t,e,n,i);return o.x-=r.x,o.y-=r.y,this.paperToLocalRect(o)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new Jt(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){if(!(t instanceof mu))throw new Error("Must provide a linkView.");var e=t.model,n=this.options,i=this.model,r=i.constructor.validations;return!(!n.multiLinks&&!r.multiLinks.call(this,i,e)||!n.linkPinning&&!r.linkPinning.call(this,i,e)||"function"==typeof n.allowLink&&!n.allowLink.call(this,t,this))},getDefaultLink:function(t,e){return go(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t={}){let{highlighter:e,type:n}=t;const{highlighting:i,highlighterNamespace:r}=this.options;if(void 0===e){if(!i)return!1;if(n&&(e=i[n],!1===e))return!1;e||(e=i.default)}if(!e)return!1;no(e)&&(e={name:e});const o=e.name,s=r[o];if(!s)throw new Error('Unknown highlighter ("'+o+'")');if("function"!=typeof s.highlight)throw new Error('Highlighter ("'+o+'") is missing required highlight() method');if("function"!=typeof s.unhighlight)throw new Error('Highlighter ("'+o+'") is missing required unhighlight() method');return{highlighter:s,options:e.options||{},name:o}},onCellHighlight:function(t,e,n){const i=this.resolveHighlighter(n);if(!i)return;const{highlighter:r,options:o}=i;r.highlight(t,e,o)},onCellUnhighlight:function(t,e,n){const i=this.resolveHighlighter(n);if(!i)return;const{highlighter:r,options:o}=i;r.unhighlight(t,e,o)},pointerdblclick:function(t){t.preventDefault(),t=Us(t);var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerdblclick(t,n.x,n.y):this.trigger("blank:pointerdblclick",t,n.x,n.y)}},pointerclick:function(t){if(this.eventData(t).mousemoved<=this.options.clickThreshold){t=Us(t);var e=this.findView(t.target);if(this.guard(t,e))return;var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerclick(t,n.x,n.y):this.trigger("blank:pointerclick",t,n.x,n.y)}},contextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.contextMenuFired?this.contextMenuFired=!1:(t=Us(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.contextmenu(t,n.x,n.y):this.trigger("blank:contextmenu",t,n.x,n.y)}},pointerdown:function(t){t=Us(t);const{target:e,button:n}=t,i=this.findView(e),r=2===n;if(i){if(!r&&this.guard(t,i))return;const n=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName);this.options.preventDefaultViewAction&&!n&&t.preventDefault(),n&&i.preventDefaultInteraction(t);const o=this.customEventTrigger(t,i);if(o){if(o.isPropagationStopped())return;t.data=o.data}const s=e.closest("[magnet]");if(s&&i.el!==s&&i.el.contains(s)){const e=Us(new Rs.Event(t.originalEvent,{data:t.data,currentTarget:s}));if(this.onmagnet(e),e.isDefaultPrevented()&&t.preventDefault(),e.isPropagationStopped()){if(r)return;return void this.delegateDragEvents(i,e.data)}t.data=e.data}}if(r){this.contextMenuFired=!0;const e=new Rs.Event(t.originalEvent,{type:"contextmenu",data:t.data});this.contextMenuTrigger(e)}else{const e=this.snapToGrid(t.clientX,t.clientY);i?i.pointerdown(t,e.x,e.y):(this.options.preventDefaultBlankAction&&t.preventDefault(),this.trigger("blank:pointerdown",t,e.x,e.y)),this.delegateDragEvents(i,t.data)}},pointermove:function(t){var e=this.eventData(t);if(e.mousemoved||(e.mousemoved=0,this.undelegateEvents()),!(++e.mousemoved<=this.options.moveThreshold)){t=Us(t);var n=this.snapToGrid(t.clientX,t.clientY),i=e.sourceView;i?i.pointermove(t,n.x,n.y):this.trigger("blank:pointermove",t,n.x,n.y),this.eventData(t,e)}},pointerup:function(t){this.undelegateDocumentEvents();var e=Us(t),n=this.snapToGrid(e.clientX,e.clientY),i=this.eventData(t).sourceView;i?i.pointerup(e,n.x,n.y):this.trigger("blank:pointerup",e,n.x,n.y),e.isPropagationStopped()||this.pointerclick(new Rs.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=Us(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseover(t);else{if(this.el===t.target)return;this.trigger("blank:mouseover",t)}},mouseout:function(t){t=Us(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseout(t);else{if(this.el===t.target)return;this.trigger("blank:mouseout",t)}},mouseenter:function(t){t=Us(t);const{target:e,relatedTarget:n,currentTarget:i}=t,r=this.findView(e);if(this.guard(t,r))return;const o=this.findView(n);if(r){if(o===r)return;if(r.mouseenter(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseenter",t)},mouseleave:function(t){t=Us(t);const{target:e,relatedTarget:n,currentTarget:i}=t,r=this.findView(e);if(this.guard(t,r))return;const o=this.findView(n);if(r){if(o===r)return;if(r.mouseleave(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseleave",t)},_processMouseWheelEvtBuf:function(t,e,n){if("function"!=typeof t)throw new TypeError("Expected a function");let i,r,o,s,a,l,c=0,h=!1,u=!1,d=!0;const f=!e&&0!==e&&window&&"function"==typeof window.requestAnimationFrame;function p(e){const n=i,o=r;return i=r=void 0,c=e,s=t.apply(o,n),s}function g(t,e){return f?(window.cancelAnimationFrame(a),window.requestAnimationFrame(t)):setTimeout(t,e)}function m(t){const n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=o}function v(){const t=Date.now();if(m(t))return y(t);a=g(v,function(t){const n=t-c,i=e-(t-l);return u?Math.min(i,o-n):i}(t))}function y(t){return a=void 0,d&&i?p(t):(i=r=void 0,s)}function b(...t){const n=Date.now(),o=m(n);if(i=t,r=this,l=n,o){if(void 0===a)return function(t){return c=t,a=g(v,e),h?p(t):s}(l);if(u)return a=g(v,e),p(l)}return void 0===a&&(a=g(v,e)),s}return e=+e||0,to(n)&&(h=!!n.leading,u="maxWait"in n,o=u?Math.max(+n.maxWait||0,e):o,d="trailing"in n?!!n.trailing:d),b.cancel=()=>{void 0!==a&&function(t){if(f)return window.cancelAnimationFrame(t);clearTimeout(t)}(a),c=0,i=l=r=a=void 0},b.flush=()=>void 0===a?s:y(Date.now()),b.pending=()=>void 0!==a,b}((function(){const{event:t,deltas:e}=this._mw_evt_buffer,n=e.reduce(((t,e)=>{return t+((n=e)>50?50:n<-50?-50:n);var n}),0),i=Math.pow(.995,n),{x:r,y:o}=this.clientToLocalPoint(t.clientX,t.clientY);this.trigger("paper:pinch",t,r,o,i),this._mw_evt_buffer={event:null,deltas:[]}}),20,{maxWait:20}),mousewheel:function(t){t=Us(t);const e=this.findView(t.target);if(this.guard(t,e))return;const n=t.originalEvent,i=this.snapToGrid(n.clientX,n.clientY),{deltaX:r,deltaY:o}=function(t){let e=0,n=0,i=0,r=0;return"detail"in t&&(n=t.detail),"wheelDelta"in t&&(n=-t.wheelDelta/120),"wheelDeltaY"in t&&(n=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=n,n=0),i="deltaX"in t?t.deltaX:10*e,r="deltaY"in t?t.deltaY:10*n,(i||r)&&t.deltaMode&&(1==t.deltaMode?(i*=40,r*=40):(i*=800,r*=800)),0===t.deltaX&&0!==t.deltaY&&t.shiftKey&&(i=r,r=0,e=n,n=0),i&&!e&&(e=i<1?-1:1),r&&!n&&(n=r<1?-1:1),{spinX:e,spinY:n,deltaX:i,deltaY:r}}(n),s=this._events["paper:pinch"];if(t.ctrlKey&&s&&s.length>0)n.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(o),this._processMouseWheelEvtBuf();else{const s=Math.max(-1,Math.min(1,n.wheelDelta));e?e.mousewheel(t,i.x,i.y,s):this.trigger("blank:mousewheel",t,i.x,i.y,s),this.trigger("paper:pan",t,r,o)}},onevent:function(t){var e=t.currentTarget,n=e.getAttribute("event");if(n){var i=this.findView(e);if(i){if(t=Us(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);i.onevent(t,n,r.x,r.y)}}},magnetEvent:function(t,e){var n=t.currentTarget;if(n.getAttribute("magnet")){var i=this.findView(n);if(i){if(t=Us(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);e.call(this,i,t,n,r.x,r.y)}}},onmagnet:function(t){if(2===t.button){this.contextMenuFired=!0,this.magnetContextMenuFired=!0;const e=new Rs.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget});this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()}else this.magnetEvent(t,(function(t,e,n,i,r){t.onmagnet(e,i,r)}))},magnetpointerdblclick:function(t){this.magnetEvent(t,(function(t,e,n,i,r){t.magnetpointerdblclick(e,n,i,r)}))},magnetcontextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.magnetContextMenuFired?this.magnetContextMenuFired=!1:this.magnetContextMenuTrigger(t)},magnetContextMenuTrigger:function(t){this.magnetEvent(t,(function(t,e,n,i,r){t.magnetcontextmenu(e,n,i,r)}))},onlabel:function(t){var e=t.currentTarget,n=this.findView(e);if(!n)return;if(t=Us(t),this.guard(t,n))return;const i=this.customEventTrigger(t,n,e);if(i){if(i.isPropagationStopped())return;t.data=i.data}var r=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,r.x,r.y)},getPointerArgs(t){const e=Us(t),{x:n,y:i}=this.snapToGrid(e.clientX,e.clientY);return[e,n,i]},delegateDragEvents:function(t,e){e||(e={}),this.eventData({data:e},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){if("mousedown"===t.type&&2===t.button)return!0;if(this.options.guard&&this.options.guard(t,e))return!0;if(t.data&&void 0!==t.data.guarded)return t.data.guarded;const{target:n}=t;return!!this.GUARDED_TAG_NAMES.includes(n.tagName)||!(e&&e.model&&e.model instanceof al)&&this.el!==n&&!this.svg.contains(n)},setGridSize:function(t){const{options:e}=this;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(vu.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(vu.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",n=t.size||"auto auto",i=this.scale(),r=this.translate();to(e)&&(e=r.tx+i.sx*(e.x||0)+"px "+(r.ty+i.sy*(e.y||0))+"px"),to(n)&&(n=(n=new me(n).scale(i.sx,i.sy)).width+"px "+n.height+"px");const{background:o}=this.childNodes;o.style.backgroundSize=n,o.style.backgroundPosition=e},drawBackgroundImage:function(t,e){if(t instanceof HTMLImageElement){if(this._background&&this._background.id===e.id){var n,i=(e=e||{}).size,r=e.repeat||"no-repeat",o=e.opacity||1,s=Math.abs(e.quality)||1,a=this.constructor.backgroundPatterns[ko(r)];if(go(a)){t.width*=s,t.height*=s;var l=a(t,e);if(!(l instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=l.toDataURL("image/png"),r="repeat",to(i)?(i.width*=l.width/t.width,i.height*=l.height/t.height):void 0===i&&(e.size={width:l.width/s,height:l.height/s})}else n=t.src,void 0===i&&(e.size={width:t.width,height:t.height});this.childNodes.background.style.opacity=o,this.childNodes.background.style.backgroundRepeat=r,this.childNodes.background.style.backgroundImage=`url(${n})`,this.updateBackgroundImage(e)}}else this.childNodes.background.style.backgroundImage=""},updateBackgroundColor:function(t){this.$el.css("backgroundColor",t||"")},drawBackground:function(t){if(t=t||{},this.updateBackgroundColor(t.color),t.image){t=this._background=uo(t),$s(t);var e=document.createElement("img");e.onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image}else this.drawBackgroundImage(null),this._background=null;return this},setInteractivity:function(t){this.options.interactive=t,so(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!to(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name;if(e||(e=n+this.svg.id+Is(JSON.stringify(t))),!this.isDefined(e)){var i=na,r=i[n]&&i[n](t.args||{});if(!r)throw new Error("Non-existing filter "+n);var o=io({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});An(r,o).appendTo(this.defs)}return e},defineGradient:function(t){if(!to(t))throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.");const{svg:e,defs:n}=this,{type:i,id:r=i+e.id+Is(JSON.stringify(t)),stops:o,attrs:s={}}=t;if(this.isDefined(r))return r;const a=vo(o).map((({offset:t,color:e,opacity:n})=>An("stop").attr({offset:t,"stop-color":e,"stop-opacity":Number.isFinite(n)?n:1}))),l=An(i,s,a);return l.id=r,l.appendTo(n),r},definePattern:function(t){if(!to(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");const{svg:e,defs:n}=this,{id:i=e.id+Is(JSON.stringify(t)),markup:r,attrs:o={}}=t;if(!r)throw new TypeError("dia.Paper: definePattern() requires markup.");if(this.isDefined(i))return i;const s=An("pattern",{patternUnits:"userSpaceOnUse"});if(s.id=i,s.attr(o),"string"==typeof r)s.append(An(r));else{const{fragment:t}=Bs(r);s.append(t)}return s.appendTo(n),i},defineMarker:function(t){if(!to(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");const{svg:e,defs:n}=this,{id:i=e.id+Is(JSON.stringify(t)),markup:r,attrs:o={},markerUnits:s="userSpaceOnUse"}=t;if(this.isDefined(i))return i;const a=An("marker",{orient:"auto",overflow:"visible",markerUnits:s});let l;if(a.id=i,a.attr(o),r){let t;if("string"==typeof r)t=An(r),t=Array.isArray(t)?t:[t];else{const{fragment:e}=Bs(r);t=An(e).children()}l=t.length>1?An("g").append(t):t[0]}else{const{type:e="path"}=t;l=An(e)}const c=So(t,"type","id","markup","attrs","markerUnits");return Object.keys(c).forEach((t=>{const e=c[t],n=l.attr(t);null==n?l.attr(t,e):"transform"===t&&l.attr(t,e+" "+n)})),l.appendTo(a),a.appendTo(n),i},customEventTrigger:function(t,e,n=e.el){const i=t.target.closest("[event]");if(i&&n!==i&&e.el.contains(i)){const e=Us(new Rs.Event(t.originalEvent,{data:t.data,currentTarget:i}));return this.onevent(e),e.isDefaultPrevented()&&t.preventDefault(),e}return null}},{sorting:nd,Layers:vu,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,-1,e.width,e.height),r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,1,e.width,0),r.drawImage(t,0,0,n,i),r.setTransform(1,0,0,-1,0,e.height),r.drawImage(t,0,0,n,i),e},flipX:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(2*n,0),r.scale(-1,1),r.drawImage(t,0,0,n,i),e},flipY:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(0,2*i),r.scale(1,-1),r.drawImage(t,0,0,n,i),e},watermark:function(t,e){e=e||{};var n=t.width,i=t.height,r=document.createElement("canvas");r.width=3*n,r.height=3*i;for(var o=r.getContext("2d"),s=eo(e.watermarkAngle)?-e.watermarkAngle:-20,a=Nt(s),l=r.width/4,c=r.height/4,h=0;h<4;h++)for(var u=0;u<4;u++)(h+u)%2>0&&(o.setTransform(1,0,0,1,(2*h-1)*l,(2*u-1)*c),o.rotate(a),o.drawImage(t,-n/2,-i/2,n,i));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){An(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){An(t).attr({fill:e.color})},update:function(t,e,n){const{sx:i,sy:r}=n.scale(),o=i<=1?e.thickness:e.thickness/i,s=r<=1?e.thickness:e.thickness/r;An(t).attr({width:o,height:s})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",An(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",An(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",An(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}]}}),cd=Pc.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var t=this.name;t&&this.vel.attr("data-tool-name",t)},configure:function(t,e){return this.relatedView=t,this.paper=t.paper,this.parentView=e,this.simulateRelatedView(this.el),this.delegateEvents(),this},simulateRelatedView:function(t){t&&t.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var t=this.options.focusOpacity;isFinite(t)&&(this.el.style.opacity=t),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){},guard:function(t){const{paper:e,relatedView:n}=this;return!e||!n||e.guard(t,n)}}),hd=Pc.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=io(this.options,t)).tools;if(!Array.isArray(e))return this;var n=t.relatedView;if(!(n instanceof Rc))return this;for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var s=e[r];s instanceof cd&&(s.configure(n,this),this.vel.append(s.el),i.push(s))}return this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS")),this},getName:function(){return this.options.name},update:function(t){t||(t={});var e=this.tools;if(!e)return this;for(var n=this.isRendered,i=0,r=e.length;i<r;i++){var o=e[i];n?t.tool!==o.cid&&o.isVisible()&&o.update():o.render()}return this.isMounted()||this.mount(),n||(this.blurTool(),this.isRendered=!0),this},focusTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];t===r?r.show():r.hide()}return this},blurTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isVisible()||(r.show(),r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null)},onRemove:function(){var t=this.tools;if(!t)return this;for(var e=0,n=t.length;e<n;e++)t[e].remove();this.tools=null},mount:function(){const{options:t,el:e}=this,{relatedView:n,layer:i=vu.TOOLS,z:r}=t;return n&&(i?n.paper.getLayerView(i).insertSortedNode(e,r):n.el.appendChild(e)),this}}),ud=cd.extend({name:"button",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},options:{distance:0,offset:0,scale:null,rotate:!1},onRender:function(){this.renderChildren(this.options.markup),this.update()},update:function(){return this.position(),this},position:function(){const{vel:t}=this;t.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix(){const{relatedView:t,options:e}=this;let{x:n=0,y:i=0,offset:r={},useModelGeometry:o,rotate:s,scale:a}=e,l=function(t,e){const{model:n}=t;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}(t,o);const c=t.model.angle();s||(l=l.bbox(c));const{x:h=0,y:u=0}=r;Ys(n)?n=parseFloat(n)/100*l.width:Ba(n)&&(n=Number(Va(n,l))),Ys(i)?i=parseFloat(i)/100*l.height:Ba(i)&&(i=Number(Va(i,l)));let d=An.createSVGMatrix().translate(l.x+l.width/2,l.y+l.height/2);return s&&(d=d.rotate(c)),d=d.translate(n+h-l.width/2,i+u-l.height/2),a&&(d=d.scale(a)),d},getLinkMatrix(){const{relatedView:t,options:e}=this,{offset:n=0,distance:i=0,rotate:r,scale:o}=e;let s,a,l;s=Ys(i)?t.getTangentAtRatio(parseFloat(i)/100):t.getTangentAtLength(i),s?(a=s.start,l=s.vector().vectorAngle(new Jt(1,0))||0):(a=t.getConnection().start,l=0);let c=An.createSVGMatrix().translate(a.x,a.y).rotate(l).translate(0,n);return r||(c=c.rotate(-l)),o&&(c=c.scale(o)),c},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.options.action;"function"==typeof e&&e.call(this.relatedView,t,this.relatedView,this)}}}),dd=ud.extend({name:"remove",children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#FF1D00",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -3 -3 3 3 M -3 3 3 -3",fill:"none",stroke:"#FFFFFF","stroke-width":2,"pointer-events":"none"}}],options:{distance:60,offset:0,action:function(t,e,n){e.model.remove({ui:!0,tool:n.cid})}}}),fd=cd.extend({tagName:"path",xAxisVector:new Jt(1,0),events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{scale:null},onRender:function(){this.update()},update:function(){var t,e,n=this.ratio,i=this.relatedView,r=i.getTangentAtRatio(n);if(r?(t=r.start,e=r.vector().vectorAngle(this.xAxisVector)||0):(t=i.getPointAtRatio(n),e=0),!t)return this;var o=An.createSVGMatrix().translate(t.x,t.y).rotate(e);const{scale:s}=this.options;return s&&(o=o.scale(s)),this.vel.transform(o,{absolute:!0}),this},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.relatedView;e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),this.delegateDocumentEvents(),e.paper.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none"}},onPointerMove:function(t){var e=Us(t),n=this.paper.snapToGrid(e.clientX,e.clientY);this.relatedView.pointermove(e,n.x,n.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,i=Us(t),r=n.snapToGrid(i.clientX,i.clientY);e.pointerup(i,r.x,r.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),pd=fd.extend({name:"target-arrowhead",ratio:1,arrowheadType:"target",attributes:{d:"M -10 -8 10 0 -10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"target-arrowhead"}}),gd=fd.extend({name:"source-arrowhead",ratio:0,arrowheadType:"source",attributes:{d:"M 10 -8 -10 0 10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"source-arrowhead"}});var md=function(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},vd=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};let yd=class extends xt{static{this.styles=x`
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.qbo4=e():(t.qbo4=t.qbo4||{},t.qbo4["ui-flowchart"]=e())}(self,(()=>(()=>{var t={630:(t,e,n)=>{var i;!function(t){!function(e){var i="object"==typeof globalThis?globalThis:"object"==typeof n.g?n.g:"object"==typeof self?self:"object"==typeof this?this:function(){try{return Function("return this;")()}catch(t){}}()||function(){try{return(0,eval)("(function() { return this; })()")}catch(t){}}(),r=o(t);function o(t,e){return function(n,i){Object.defineProperty(t,n,{configurable:!0,writable:!0,value:i}),e&&e(n,i)}}void 0!==i.Reflect&&(r=o(i.Reflect,r)),function(t,e){var n=Object.prototype.hasOwnProperty,i="function"==typeof Symbol,r=i&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=i&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",s="function"==typeof Object.create,a={__proto__:[]}instanceof Array,l=!s&&!a,c={create:s?function(){return $(Object.create(null))}:a?function(){return $({__proto__:null})}:function(){return $({})},has:l?function(t,e){return n.call(t,e)}:function(t,e){return e in t},get:l?function(t,e){return n.call(t,e)?t[e]:void 0}:function(t,e){return t[e]}},h=Object.getPrototypeOf(Function),u="function"==typeof Map&&"function"==typeof Map.prototype.entries?Map:function(){var t={},e=[],n=function(){function t(t,e,n){this._index=0,this._keys=t,this._values=e,this._selector=n}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var n=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}();return function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var n=this._find(t,!0);return this._values[n]=e,this},e.prototype.delete=function(e){var n=this._find(e,!1);if(n>=0){for(var i=this._keys.length,r=n+1;r<i;r++)this._keys[r-1]=this._keys[r],this._values[r-1]=this._values[r];return this._keys.length--,this._values.length--,R(e,this._cacheKey)&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new n(this._keys,this._values,i)},e.prototype.values=function(){return new n(this._keys,this._values,r)},e.prototype.entries=function(){return new n(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){if(!R(this._cacheKey,t)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(R(this._keys[n],t)){this._cacheIndex=n;break}}return this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();function i(t,e){return t}function r(t,e){return e}function s(t,e){return[t,e]}}(),d="function"==typeof Set&&"function"==typeof Set.prototype.entries?Set:function(){function t(){this._map=new u}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.keys()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[o]=function(){return this.keys()},t}(),f="function"==typeof WeakMap?WeakMap:function(){var t=16,e=c.create(),i=r();return function(){function t(){this._key=r()}return t.prototype.has=function(t){var e=o(t,!1);return void 0!==e&&c.has(e,this._key)},t.prototype.get=function(t){var e=o(t,!1);return void 0!==e?c.get(e,this._key):void 0},t.prototype.set=function(t,e){return o(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=o(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=r()},t}();function r(){var t;do{t="@@WeakMap@@"+a()}while(c.has(e,t));return e[t]=!0,t}function o(t,e){if(!n.call(t,i)){if(!e)return;Object.defineProperty(t,i,{value:c.create()})}return t[i]}function s(t,e){for(var n=0;n<e;++n)t[n]=255*Math.random()|0;return t}function a(){var e=function(t){if("function"==typeof Uint8Array){var e=new Uint8Array(t);return"undefined"!=typeof crypto?crypto.getRandomValues(e):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(e):s(e,t),e}return s(new Array(t),t)}(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var n="",i=0;i<t;++i){var r=e[i];4!==i&&6!==i&&8!==i||(n+="-"),r<16&&(n+="0"),n+=r.toString(16).toLowerCase()}return n}}(),p=i?Symbol.for("@reflect-metadata:registry"):void 0,g=function(){var t;return!P(p)&&_(e.Reflect)&&Object.isExtensible(e.Reflect)&&(t=e.Reflect[p]),P(t)&&(t=function(){var t,n,i,r;P(p)||void 0===e.Reflect||p in e.Reflect||"function"!=typeof e.Reflect.defineMetadata||(t=function(t){var e=t.defineMetadata,n=t.hasOwnMetadata,i=t.getOwnMetadata,r=t.getOwnMetadataKeys,o=t.deleteMetadata,s=new f;return{isProviderFor:function(t,e){var n=s.get(t);return!(P(n)||!n.has(e))||!!r(t,e).length&&(P(n)&&(n=new d,s.set(t,n)),n.add(e),!0)},OrdinaryDefineOwnMetadata:e,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:i,OrdinaryOwnMetadataKeys:r,OrdinaryDeleteMetadata:o}}(e.Reflect));var o=new f,s={registerProvider:a,getProvider:c,setProvider:g};return s;function a(e){if(!Object.isExtensible(s))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case t===e:break;case P(n):n=e;break;case n===e:break;case P(i):i=e;break;case i===e:break;default:void 0===r&&(r=new d),r.add(e)}}function l(e,o){if(!P(n)){if(n.isProviderFor(e,o))return n;if(!P(i)){if(i.isProviderFor(e,o))return n;if(!P(r))for(var s=B(r);;){var a=D(s);if(!a)return;var l=I(a);if(l.isProviderFor(e,o))return V(s),l}}}if(!P(t)&&t.isProviderFor(e,o))return t}function c(t,e){var n,i=o.get(t);return P(i)||(n=i.get(e)),P(n)?(P(n=l(t,e))||(P(i)&&(i=new u,o.set(t,i)),i.set(e,n)),n):n}function h(t){if(P(t))throw new TypeError;return n===t||i===t||!P(r)&&r.has(t)}function g(t,e,n){if(!h(n))throw new Error("Metadata provider not registered.");var i=c(t,e);if(i!==n){if(!P(i))return!1;var r=o.get(t);P(r)&&(r=new u,o.set(t,r)),r.set(e,n)}return!0}}()),!P(p)&&_(e.Reflect)&&Object.isExtensible(e.Reflect)&&Object.defineProperty(e.Reflect,p,{enumerable:!1,configurable:!1,writable:!1,value:t}),t}(),m=function(t){var e=new f,n={isProviderFor:function(t,n){var i=e.get(t);return!P(i)&&i.has(n)},OrdinaryDefineOwnMetadata:function(t,e,n,r){i(n,r,!0).set(t,e)},OrdinaryHasOwnMetadata:function(t,e,n){var r=i(e,n,!1);return!P(r)&&L(r.has(t))},OrdinaryGetOwnMetadata:function(t,e,n){var r=i(e,n,!1);if(!P(r))return r.get(t)},OrdinaryOwnMetadataKeys:function(t,e){var n=[],r=i(t,e,!1);if(P(r))return n;for(var o=B(r.keys()),s=0;;){var a=D(o);if(!a)return n.length=s,n;var l=I(a);try{n[s]=l}catch(t){try{V(o)}finally{throw t}}s++}},OrdinaryDeleteMetadata:function(t,n,r){var o=i(n,r,!1);if(P(o))return!1;if(!o.delete(t))return!1;if(0===o.size){var s=e.get(n);P(s)||(s.delete(r),0===s.size&&e.delete(s))}return!0}};return g.registerProvider(n),n;function i(i,r,o){var s=e.get(i),a=!1;if(P(s)){if(!o)return;s=new u,e.set(i,s),a=!0}var l=s.get(r);if(P(l)){if(!o)return;if(l=new u,s.set(r,l),!t.setProvider(i,r,n))throw s.delete(r),a&&e.delete(i),new Error("Wrong provider for target.")}return l}}(g);function v(t,e,n){if(y(t,e,n))return!0;var i=z(e);return!S(i)&&v(t,i,n)}function y(t,e,n){var i=j(e,n,!1);return!P(i)&&L(i.OrdinaryHasOwnMetadata(t,e,n))}function b(t,e,n){if(y(t,e,n))return w(t,e,n);var i=z(e);return S(i)?void 0:b(t,i,n)}function w(t,e,n){var i=j(e,n,!1);if(!P(i))return i.OrdinaryGetOwnMetadata(t,e,n)}function x(t,e,n,i){j(n,i,!0).OrdinaryDefineOwnMetadata(t,e,n,i)}function A(t,e){var n=T(t,e),i=z(t);if(null===i)return n;var r=A(i,e);if(r.length<=0)return n;if(n.length<=0)return r;for(var o=new d,s=[],a=0,l=n;a<l.length;a++){var c=l[a];o.has(c)||(o.add(c),s.push(c))}for(var h=0,u=r;h<u.length;h++)c=u[h],o.has(c)||(o.add(c),s.push(c));return s}function T(t,e){var n=j(t,e,!1);return n?n.OrdinaryOwnMetadataKeys(t,e):[]}function E(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function P(t){return void 0===t}function S(t){return null===t}function _(t){return"object"==typeof t?null!==t:"function"==typeof t}function k(t,e){switch(E(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var n=3===e?"string":5===e?"number":"default",i=F(t,r);if(void 0!==i){var o=i.call(t,n);if(_(o))throw new TypeError;return o}return function(t,e){if("string"===e){var n=t.toString;if(O(n)&&!_(r=n.call(t)))return r;if(O(i=t.valueOf)&&!_(r=i.call(t)))return r}else{var i;if(O(i=t.valueOf)&&!_(r=i.call(t)))return r;var r,o=t.toString;if(O(o)&&!_(r=o.call(t)))return r}throw new TypeError}(t,"default"===n?"number":n)}function L(t){return!!t}function C(t){var e=k(t,3);return"symbol"==typeof e?e:function(t){return""+t}(e)}function M(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function O(t){return"function"==typeof t}function N(t){return"function"==typeof t}function R(t,e){return t===e||t!=t&&e!=e}function F(t,e){var n=t[e];if(null!=n){if(!O(n))throw new TypeError;return n}}function B(t){var e=F(t,o);if(!O(e))throw new TypeError;var n=e.call(t);if(!_(n))throw new TypeError;return n}function I(t){return t.value}function D(t){var e=t.next();return!e.done&&e}function V(t){var e=t.return;e&&e.call(t)}function z(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===h)return e;if(e!==h)return e;var n=t.prototype,i=n&&Object.getPrototypeOf(n);if(null==i||i===Object.prototype)return e;var r=i.constructor;return"function"!=typeof r||r===t?e:r}function j(t,e,n){var i=g.getProvider(t,e);if(!P(i))return i;if(n){if(g.setProvider(t,e,m))return m;throw new Error("Illegal state.")}}function $(t){return t.__=void 0,delete t.__,t}t("decorate",(function(t,e,n,i){if(P(n)){if(!M(t))throw new TypeError;if(!N(e))throw new TypeError;return function(t,e){for(var n=t.length-1;n>=0;--n){var i=(0,t[n])(e);if(!P(i)&&!S(i)){if(!N(i))throw new TypeError;e=i}}return e}(t,e)}if(!M(t))throw new TypeError;if(!_(e))throw new TypeError;if(!_(i)&&!P(i)&&!S(i))throw new TypeError;return S(i)&&(i=void 0),function(t,e,n,i){for(var r=t.length-1;r>=0;--r){var o=(0,t[r])(e,n,i);if(!P(o)&&!S(o)){if(!_(o))throw new TypeError;i=o}}return i}(t,e,n=C(n),i)})),t("metadata",(function(t,e){return function(n,i){if(!_(n))throw new TypeError;if(!P(i)&&!function(t){switch(E(t)){case 3:case 4:return!0;default:return!1}}(i))throw new TypeError;x(t,e,n,i)}})),t("defineMetadata",(function(t,e,n,i){if(!_(n))throw new TypeError;return P(i)||(i=C(i)),x(t,e,n,i)})),t("hasMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return P(n)||(n=C(n)),v(t,e,n)})),t("hasOwnMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return P(n)||(n=C(n)),y(t,e,n)})),t("getMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return P(n)||(n=C(n)),b(t,e,n)})),t("getOwnMetadata",(function(t,e,n){if(!_(e))throw new TypeError;return P(n)||(n=C(n)),w(t,e,n)})),t("getMetadataKeys",(function(t,e){if(!_(t))throw new TypeError;return P(e)||(e=C(e)),A(t,e)})),t("getOwnMetadataKeys",(function(t,e){if(!_(t))throw new TypeError;return P(e)||(e=C(e)),T(t,e)})),t("deleteMetadata",(function(t,e,n){if(!_(e))throw new TypeError;if(P(n)||(n=C(n)),!_(e))throw new TypeError;P(n)||(n=C(n));var i=j(e,n,!1);return!P(i)&&i.OrdinaryDeleteMetadata(t,e,n)}))}(r,i),void 0===i.Reflect&&(i.Reflect=t)}()}(i||(i={}))}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";n.r(i),n.d(i,{QboFlowchart:()=>yd});var t={};n.r(t),n.d(t,{ellipseWithEllipse:()=>He,ellipseWithLine:()=>qe,exists:()=>Ue,lineWithLine:()=>Ge,pathWithEllipse:()=>an,pathWithLine:()=>sn,pathWithPath:()=>un,pathWithPolygon:()=>hn,pathWithPolyline:()=>cn,pathWithRect:()=>ln,polygonWithEllipse:()=>en,polygonWithLine:()=>tn,polygonWithPolygon:()=>on,polygonWithPolyline:()=>rn,polygonWithRect:()=>nn,polylineWithEllipse:()=>Ke,polylineWithLine:()=>Ze,polylineWithPolyline:()=>Qe,polylineWithRect:()=>Je,rectWithEllipse:()=>Ye,rectWithLine:()=>We,rectWithRect:()=>Xe});var e={};n.r(e),n.d(e,{Curve:()=>_e,Ellipse:()=>ae,Line:()=>ne,Path:()=>Le,Point:()=>Jt,Polygon:()=>$e,Polyline:()=>xe,Rect:()=>me,bezier:()=>je,ellipse:()=>le,intersection:()=>wn,line:()=>ie,normalizeAngle:()=>Ct,point:()=>Qt,random:()=>Rt,rect:()=>ve,scale:()=>Lt,snapToGrid:()=>Mt,toDeg:()=>Ot,toRad:()=>Nt,types:()=>jt});var r={};n.r(r),n.d(r,{addClass:()=>hs,append:()=>ts,appendTo:()=>ns,children:()=>fs,clone:()=>Jo,closest:()=>ps,css:()=>ss,data:()=>as,detach:()=>Zo,empty:()=>Ko,hasClass:()=>ds,height:()=>bs,html:()=>Qo,off:()=>vs,offset:()=>xs,on:()=>gs,one:()=>ms,position:()=>ws,prepend:()=>es,prependTo:()=>is,remove:()=>Xo,removeClass:()=>cs,toggleClass:()=>us,width:()=>ys});var o={};n.r(o),n.d(o,{animate:()=>Es,stop:()=>Ss});var s={};n.r(s),n.d(s,{absolute:()=>fl,bottom:()=>bl,ellipse:()=>xl,ellipseSpread:()=>wl,fn:()=>pl,left:()=>ml,line:()=>gl,right:()=>vl,top:()=>yl});var a={};n.r(a),n.d(a,{bottom:()=>Ml,inside:()=>Fl,insideOriented:()=>Rl,left:()=>kl,manual:()=>_l,outside:()=>Nl,outsideOriented:()=>Ol,radial:()=>Bl,radialOriented:()=>Il,right:()=>Ll,top:()=>Cl});var l={};n.r(l),n.d(l,{BorderedImage:()=>Kl,Circle:()=>ql,Cylinder:()=>ec,DoubleLink:()=>oc,Ellipse:()=>Hl,EmbeddedImage:()=>Jl,HeaderedRectangle:()=>tc,Image:()=>Zl,InscribedImage:()=>Ql,Link:()=>rc,Path:()=>Wl,Polygon:()=>Yl,Polyline:()=>Xl,Rectangle:()=>Gl,ShadowLink:()=>sc,TextBlock:()=>ic});var c={};n.r(c),n.d(c,{standard:()=>l});var h={};n.r(h),n.d(h,{manhattan:()=>wh,metro:()=>Ah,normal:()=>zc,oneSide:()=>jc,orthogonal:()=>nh,rightAngle:()=>Dh});var u={};n.r(u),n.d(u,{curve:()=>ou,jumpover:()=>Jh,normal:()=>Qh,rounded:()=>eu,smooth:()=>nu,straight:()=>Uh});var d={};n.r(d),n.d(d,{addClass:()=>Eu,list:()=>Su,mask:()=>xu,opacity:()=>Au,stroke:()=>bu});var f={};n.r(f),n.d(f,{connectionClosest:()=>Ou,connectionLength:()=>ku,connectionPerpendicular:()=>Mu,connectionRatio:()=>_u,resolveRef:()=>Lu});var p={};n.r(p),n.d(p,{anchor:()=>Du,bbox:()=>Vu,boundary:()=>ju,rectangle:()=>zu});var g={};n.r(g),n.d(g,{bottom:()=>qu,bottomLeft:()=>Zu,bottomRight:()=>Ku,center:()=>Uu,left:()=>Hu,midSide:()=>Qu,modelCenter:()=>td,perpendicular:()=>Ju,right:()=>Wu,top:()=>Gu,topLeft:()=>Yu,topRight:()=>Xu}),n(630);const m=globalThis,v=m.ShadowRoot&&(void 0===m.ShadyCSS||m.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,y=Symbol(),b=new WeakMap;class w{constructor(t,e,n){if(this._$cssResult$=!0,n!==y)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(v&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=b.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&b.set(e,t))}return t}toString(){return this.cssText}}const x=(t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,n,i)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[i+1]),t[0]);return new w(n,t,y)},A=v?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new w("string"==typeof t?t:t+"",void 0,y))(e)})(t):t,{is:T,defineProperty:E,getOwnPropertyDescriptor:P,getOwnPropertyNames:S,getOwnPropertySymbols:_,getPrototypeOf:k}=Object,L=globalThis,C=L.trustedTypes,M=C?C.emptyScript:"",O=L.reactiveElementPolyfillSupport,N=(t,e)=>t,R={toAttribute(t,e){switch(e){case Boolean:t=t?M:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},F=(t,e)=>!T(t,e),B={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:F};Symbol.metadata??=Symbol("metadata"),L.litPropertyMetadata??=new WeakMap;class I extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=B){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(t,n,e);void 0!==i&&E(this.prototype,t,i)}}static getPropertyDescriptor(t,e,n){const{get:i,set:r}=P(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return i?.call(this)},set(e){const o=i?.call(this);r.call(this,e),this.requestUpdate(t,o,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??B}static _$Ei(){if(this.hasOwnProperty(N("elementProperties")))return;const t=k(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(N("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(N("properties"))){const t=this.properties,e=[...S(t),..._(t)];for(const n of e)this.createProperty(n,t[n])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,n]of e)this.elementProperties.set(t,n)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const n=this._$Eu(t,e);void 0!==n&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(A(t))}else void 0!==t&&e.push(A(t));return e}static _$Eu(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const n of e.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(v)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const n of e){const e=document.createElement("style"),i=m.litNonce;void 0!==i&&e.setAttribute("nonce",i),e.textContent=n.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,n){this._$AK(t,n)}_$EC(t,e){const n=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,n);if(void 0!==i&&!0===n.reflect){const r=(void 0!==n.converter?.toAttribute?n.converter:R).toAttribute(e,n.type);this._$Em=t,null==r?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(t,e){const n=this.constructor,i=n._$Eh.get(t);if(void 0!==i&&this._$Em!==i){const t=n.getPropertyOptions(i),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:R;this._$Em=i,this[i]=r.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,n){if(void 0!==t){if(n??=this.constructor.getPropertyOptions(t),!(n.hasChanged??F)(this[t],e))return;this.P(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,e,n){this._$AL.has(t)||this._$AL.set(t,e),!0===n.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,n]of t)!0!==n.wrapped||this._$AL.has(e)||void 0===this[e]||this.P(e,this[e],n)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EU()}catch(e){throw t=!1,this._$EU(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU()}updated(t){}firstUpdated(t){}}I.elementStyles=[],I.shadowRootOptions={mode:"open"},I[N("elementProperties")]=new Map,I[N("finalized")]=new Map,O?.({ReactiveElement:I}),(L.reactiveElementVersions??=[]).push("2.0.4");const D=globalThis,V=D.trustedTypes,z=V?V.createPolicy("lit-html",{createHTML:t=>t}):void 0,j="$lit$",$=`lit$${Math.random().toFixed(9).slice(2)}$`,U="?"+$,G=`<${U}>`,q=document,H=()=>q.createComment(""),W=t=>null===t||"object"!=typeof t&&"function"!=typeof t,Y=Array.isArray,X="[ \t\n\f\r]",Z=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,K=/-->/g,J=/>/g,Q=RegExp(`>|${X}(?:([^\\s"'>=/]+)(${X}*=${X}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),tt=/'/g,et=/"/g,nt=/^(?:script|style|textarea|title)$/i,it=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),rt=it(1),ot=(it(2),Symbol.for("lit-noChange")),st=Symbol.for("lit-nothing"),at=new WeakMap,lt=q.createTreeWalker(q,129);function ct(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==z?z.createHTML(e):e}const ht=(t,e)=>{const n=t.length-1,i=[];let r,o=2===e?"<svg>":"",s=Z;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,h=0;for(;h<n.length&&(s.lastIndex=h,l=s.exec(n),null!==l);)h=s.lastIndex,s===Z?"!--"===l[1]?s=K:void 0!==l[1]?s=J:void 0!==l[2]?(nt.test(l[2])&&(r=RegExp("</"+l[2],"g")),s=Q):void 0!==l[3]&&(s=Q):s===Q?">"===l[0]?(s=r??Z,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?Q:'"'===l[3]?et:tt):s===et||s===tt?s=Q:s===K||s===J?s=Z:(s=Q,r=void 0);const u=s===Q&&t[e+1].startsWith("/>")?" ":"";o+=s===Z?n+G:c>=0?(i.push(a),n.slice(0,c)+j+n.slice(c)+$+u):n+$+(-2===c?e:u)}return[ct(t,o+(t[n]||"<?>")+(2===e?"</svg>":"")),i]};class ut{constructor({strings:t,_$litType$:e},n){let i;this.parts=[];let r=0,o=0;const s=t.length-1,a=this.parts,[l,c]=ht(t,e);if(this.el=ut.createElement(l,n),lt.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(i=lt.nextNode())&&a.length<s;){if(1===i.nodeType){if(i.hasAttributes())for(const t of i.getAttributeNames())if(t.endsWith(j)){const e=c[o++],n=i.getAttribute(t).split($),s=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:s[2],strings:n,ctor:"."===s[1]?mt:"?"===s[1]?vt:"@"===s[1]?yt:gt}),i.removeAttribute(t)}else t.startsWith($)&&(a.push({type:6,index:r}),i.removeAttribute(t));if(nt.test(i.tagName)){const t=i.textContent.split($),e=t.length-1;if(e>0){i.textContent=V?V.emptyScript:"";for(let n=0;n<e;n++)i.append(t[n],H()),lt.nextNode(),a.push({type:2,index:++r});i.append(t[e],H())}}}else if(8===i.nodeType)if(i.data===U)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=i.data.indexOf($,t+1));)a.push({type:7,index:r}),t+=$.length-1}r++}}static createElement(t,e){const n=q.createElement("template");return n.innerHTML=t,n}}function dt(t,e,n=t,i){if(e===ot)return e;let r=void 0!==i?n._$Co?.[i]:n._$Cl;const o=W(e)?void 0:e._$litDirective$;return r?.constructor!==o&&(r?._$AO?.(!1),void 0===o?r=void 0:(r=new o(t),r._$AT(t,n,i)),void 0!==i?(n._$Co??=[])[i]=r:n._$Cl=r),void 0!==r&&(e=dt(t,r._$AS(t,e.values),r,i)),e}class ft{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:n}=this._$AD,i=(t?.creationScope??q).importNode(e,!0);lt.currentNode=i;let r=lt.nextNode(),o=0,s=0,a=n[0];for(;void 0!==a;){if(o===a.index){let e;2===a.type?e=new pt(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new bt(r,this,t)),this._$AV.push(e),a=n[++s]}o!==a?.index&&(r=lt.nextNode(),o++)}return lt.currentNode=q,i}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class pt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,i){this.type=2,this._$AH=st,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=dt(this,t,e),W(t)?t===st||null==t||""===t?(this._$AH!==st&&this._$AR(),this._$AH=st):t!==this._$AH&&t!==ot&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>Y(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t))}_(t){this._$AH!==st&&W(this._$AH)?this._$AA.nextSibling.data=t:this.T(q.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,i="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=ut.createElement(ct(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===i)this._$AH.p(e);else{const t=new ft(i,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=at.get(t.strings);return void 0===e&&at.set(t.strings,e=new ut(t)),e}k(t){Y(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,i=0;for(const r of t)i===e.length?e.push(n=new pt(this.S(H()),this.S(H()),this,this.options)):n=e[i],n._$AI(r),i++;i<e.length&&(this._$AR(n&&n._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class gt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,i,r){this.type=1,this._$AH=st,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=r,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=st}_$AI(t,e=this,n,i){const r=this.strings;let o=!1;if(void 0===r)t=dt(this,t,e,0),o=!W(t)||t!==this._$AH&&t!==ot,o&&(this._$AH=t);else{const i=t;let s,a;for(t=r[0],s=0;s<r.length-1;s++)a=dt(this,i[n+s],e,s),a===ot&&(a=this._$AH[s]),o||=!W(a)||a!==this._$AH[s],a===st?t=st:t!==st&&(t+=(a??"")+r[s+1]),this._$AH[s]=a}o&&!i&&this.j(t)}j(t){t===st?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class mt extends gt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===st?void 0:t}}class vt extends gt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==st)}}class yt extends gt{constructor(t,e,n,i,r){super(t,e,n,i,r),this.type=5}_$AI(t,e=this){if((t=dt(this,t,e,0)??st)===ot)return;const n=this._$AH,i=t===st&&n!==st||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,r=t!==st&&(n===st||i);i&&this.element.removeEventListener(this.name,this,n),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class bt{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){dt(this,t)}}const wt=D.litHtmlPolyfillSupport;wt?.(ut,pt),(D.litHtmlVersions??=[]).push("3.1.3");class xt extends I{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,n)=>{const i=n?.renderBefore??e;let r=i._$litPart$;if(void 0===r){const t=n?.renderBefore??null;i._$litPart$=r=new pt(e.insertBefore(H(),t),t,void 0,n??{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return ot}}xt._$litElement$=!0,xt.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:xt});const At=globalThis.litElementPolyfillSupport;At?.({LitElement:xt}),(globalThis.litElementVersions??=[]).push("4.0.5");const Tt={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:F},Et=(t=Tt,e,n)=>{const{kind:i,metadata:r}=n;let o=globalThis.litPropertyMetadata.get(r);if(void 0===o&&globalThis.litPropertyMetadata.set(r,o=new Map),o.set(n.name,t),"accessor"===i){const{name:i}=n;return{set(n){const r=e.get.call(this);e.set.call(this,n),this.requestUpdate(i,r,t)},init(e){return void 0!==e&&this.P(i,void 0,t),e}}}if("setter"===i){const{name:i}=n;return function(n){const r=this[i];e.call(this,n),this.requestUpdate(i,r,t)}}throw Error("Unsupported decorator location: "+i)};function Pt(t){return(e,n)=>"object"==typeof n?Et(t,e,n):((t,e,n)=>{const i=e.hasOwnProperty(n);return e.constructor.createProperty(n,i?{...t,wrapped:!0}:t),i?Object.getOwnPropertyDescriptor(e,n):void 0})(t,e,n)}const{round:St,floor:_t,PI:kt}=Math,Lt={linear:function(t,e,n){var i=t[1]-t[0],r=e[1]-e[0];return(n-t[0])/i*r+e[0]||0}},Ct=function(t){return t%360+(t<0?360:0)},Mt=function(t,e){return e*St(t/e)},Ot=function(t){return 180*t/kt%360},Nt=function(t,e){return(t=(e=e||!1)?t:t%360)*kt/180},Rt=function(t,e){if(void 0===e)e=void 0===t?1:t,t=0;else if(e<t){const n=t;t=e,e=n}return _t(Math.random()*(e-t+1)+t)},{cos:Ft,sin:Bt,atan2:It}=Math,Dt=function(t,e){var n=Nt(t.y),i=Nt(e.y),r=t.x,o=e.x,s=Nt(o-r),a=Bt(s)*Ft(i),l=Ft(n)*Bt(i)-Bt(n)*Ft(i)*Ft(s),c=Ot(It(a,l))-22.5;return c<0&&(c+=360),["NE","E","SE","S","SW","W","NW","N"][c=parseInt(c/45)]},Vt=function(t,e){var n=t.x,i=t.y;return(n-=e.x)*n+(i-=e.y)*i},zt=function(t,e){return Math.sqrt(Vt(t,e))},jt={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:$t,cos:Ut,sin:Gt,sqrt:qt,min:Ht,max:Wt,atan2:Yt,round:Xt,pow:Zt,PI:Kt}=Math,Jt=function(t,e){if(!(this instanceof Jt))return new Jt(t,e);if("string"==typeof t){var n=t.split(-1===t.indexOf("@")?" ":"@");t=parseFloat(n[0]),e=parseFloat(n[1])}else Object(t)===t&&(e=t.y,t=t.x);this.x=void 0===t?0:t,this.y=void 0===e?0:e};Jt.fromPolar=function(t,e,n){n=new Jt(n);var i=$t(t*Ut(e)),r=$t(t*Gt(e)),o=Ct(Ot(e));return o<90?r=-r:o<180?(i=-i,r=-r):o<270&&(i=-i),new Jt(n.x+i,n.y+r)},Jt.random=function(t,e,n,i){return new Jt(Rt(t,e),Rt(n,i))},Jt.prototype={type:jt.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new Jt(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new Jt(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=Ht(Wt(this.x,t.x),t.x+t.width),this.y=Ht(Wt(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){var n=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return n<0&&(n+=360),n},bearing:function(t){return Dt(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new Jt(this)},cross:function(t,e){return t&&e?(e.x-this.x)*(t.y-this.y)-(e.y-this.y)*(t.x-this.x):NaN},difference:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),new Jt(this.x-(t||0),this.y-(e||0))},distance:function(t){return zt(this,t)},dot:function(t){return t?this.x*t.x+this.y*t.y:NaN},equals:function(t){return!!t&&this.x===t.x&&this.y===t.y},lerp:function(t,e){var n=this.x,i=this.y;return new Jt((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return qt(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return $t(t.x-this.x)+$t(t.y-this.y)},move:function(t,e){var n=Nt(new Jt(t).theta(this));return this.offset(Ut(n)*e,-Gt(n)*e)},normalize:function(t){var e=(t||1)/this.magnitude();return this.scale(e,e)},offset:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x+=t||0,this.y+=e||0,this},reflection:function(t){return new Jt(t).move(this,this.distance(t))},rotate:function(t,e){if(0===e)return this;t=t||new Jt(0,0),e=Nt(Ct(-e));var n=Ut(e),i=Gt(e),r=n*(this.x-t.x)-i*(this.y-t.y)+t.x,o=i*(this.x-t.x)+n*(this.y-t.y)+t.y;return this.x=r,this.y=o,this},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=Zt(10,t)}return this.x=Xt(this.x*e)/e,this.y=Xt(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new Jt(n)||new Jt(0,0),this.x=n.x+t*(this.x-n.x),this.y=n.y+e*(this.y-n.y),this},snapToGrid:function(t,e){return this.x=Mt(this.x,t),this.y=Mt(this.y,e||t),this},squaredDistance:function(t){return Vt(this,t)},theta:function(t){var e=-((t=new Jt(t)).y-this.y),n=t.x-this.x,i=Yt(e,n);return i<0&&(i=2*Kt+i),180*i/Kt},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new Jt(t)||new Jt(0,0);var e=this.x,n=this.y;return this.x=qt((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Nt(t.theta(new Jt(e,n))),this},toString:function(){return this.x+"@"+this.y},serialize:function(){return this.x+","+this.y},update:function(t,e){return Object(t)===t&&(e=t.y,t=t.x),this.x=t||0,this.y=e||0,this},vectorAngle:function(t){return new Jt(0,0).angleBetween(this,t)}},Jt.prototype.translate=Jt.prototype.offset;const Qt=Jt,{max:te,min:ee}=Math,ne=function(t,e){return this instanceof ne?t instanceof ne?new ne(t.start,t.end):(this.start=new Jt(t),void(this.end=new Jt(e))):new ne(t,e)};ne.prototype={type:jt.Line,angle:function(){var t=new Jt(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=ee(this.start.x,this.end.x),e=ee(this.start.y,this.end.y),n=te(this.start.x,this.end.x),i=te(this.start.y,this.end.y);return new me(t,e,n-t,i-e)},bearing:function(){return Dt(this.start,this.end)},clone:function(){return new ne(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){var e=this.vector().dot(new ne(this.start,t).vector()),n=ee(1,te(0,e/this.squaredLength()));return n!=n?0:n},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e=this.start,n=this.end;if(0!==e.cross(t,n))return!1;var i=this.length();return!(new ne(e,t).length()>i||new ne(t,n).length()>i)},divideAt:function(t){var e=this.pointAt(t);return[new ne(this.start,e),new ne(e,this.end)]},divideAtLength:function(t){var e=this.pointAtLength(t);return[new ne(this.start,e),new ne(e,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,e){if(t&&t.intersectionWithLine){var n=t.intersectionWithLine(this,e);return n&&t instanceof ne&&(n=n[0]),n}return null},intersectionWithLine:function(t){var e=new Jt(this.end.x-this.start.x,this.end.y-this.start.y),n=new Jt(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,r=new Jt(t.start.x-this.start.x,t.start.y-this.start.y),o=r.x*n.y-r.y*n.x,s=r.x*e.y-r.y*e.x;if(0===i||o*i<0||s*i<0)return null;if(i>0){if(o>i||s>i)return null}else if(o<i||s<i)return null;return[new Jt(this.start.x+o*e.x/i,this.start.y+o*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return zt(this.start,this.end)},midpoint:function(){return new Jt((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){const e=this.clone();if(!this.isDifferentiable())return e;const{start:n,end:i}=e,r=n.clone().rotate(i,270),o=i.clone().rotate(n,90);return n.move(o,t),i.move(r,t),e},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():t>=1?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0;t<0&&(i=!1,t=-t);var r=this.length();return t>=r?i?n.clone():e.clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new Jt(t);var e=this.start,n=this.end;return((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/this.length()},rotate:function(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.end.scale(t,e,n),this},setLength:function(t){var e=this.length();if(!e)return this;var n=t/e;return this.scale(n,n,this.start)},squaredLength:function(){return Vt(this.start,this.end)},tangentAt:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAt(t),r=new ne(e,n);return r.translate(i.x-e.x,i.y-e.y),r},tangentAtLength:function(t){if(!this.isDifferentiable())return null;var e=this.start,n=this.end,i=this.pointAtLength(t),r=new ne(e,n);return r.translate(i.x-e.x,i.y-e.y),r},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,e){return this.start.translate(t,e),this.end.translate(t,e),this},vector:function(){return new Jt(this.end.x-this.start.x,this.end.y-this.start.y)}},ne.prototype.intersection=ne.prototype.intersect;const ie=ne,{sqrt:re,round:oe,pow:se}=Math,ae=function(t,e,n){return this instanceof ae?t instanceof ae?new ae(new Jt(t.x,t.y),t.a,t.b):(t=new Jt(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new ae(t,e,n)};ae.fromRect=function(t){return t=new me(t),new ae(t.center(),t.width/2,t.height/2)},ae.prototype={type:jt.Ellipse,bbox:function(){return new me(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new Jt(this.x,this.y)},clone:function(){return new ae(this)},containsPoint:function(t){return this.normalizedDistance(t)<=1},equals:function(t){return!!t&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.a+=2*t,this.b+=2*e,this},intersectionWithLine:function(t){var e=[],n=t.start,i=t.end,r=this.a,o=this.b,s=t.vector(),a=n.difference(new Jt(this)),l=new Jt(s.x/(r*r),s.y/(o*o)),c=new Jt(a.x/(r*r),a.y/(o*o)),h=s.dot(l),u=s.dot(c),d=u*u-h*(a.dot(c)-1);if(d<0)return null;if(d>0){var f=re(d),p=(-u-f)/h,g=(-u+f)/h;if((p<0||1<p)&&(g<0||1<g))return null;0<=p&&p<=1&&e.push(n.lerp(i,p)),0<=g&&g<=1&&e.push(n.lerp(i,g))}else{var m=-u/h;if(!(0<=m&&m<=1))return null;e.push(n.lerp(i,m))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new Jt(t),e&&t.rotate(new Jt(this.x,this.y),e);var n,i=t.x-this.x,r=t.y-this.y;if(0===i)return n=this.bbox().pointNearestToPoint(t),e?n.rotate(new Jt(this.x,this.y),-e):n;var o=r/i,s=o*o,a=this.a*this.a,l=this.b*this.b,c=re(1/(1/a+s/l)),h=o*(c=i<0?-c:c);return n=new Jt(this.x+c,this.y+h),e?n.rotate(new Jt(this.x,this.y),-e):n},normalizedDistance:function(t){var e=t.x,n=t.y,i=this.a,r=this.b,o=this.x,s=this.y;return(e-o)*(e-o)/(i*i)+(n-s)*(n-s)/(r*r)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=se(10,t)}return this.x=oe(this.x*e)/e,this.y=oe(this.y*e)/e,this.a=oe(this.a*e)/e,this.b=oe(this.b*e)/e,this},tangentTheta:function(t){var e,n,i=t.x,r=t.y,o=this.a,s=this.b,a=this.bbox().center(),l=a.x,c=a.y,h=i>a.x+o/2,u=i<a.x-o/2;return h||u?n=o*o/(i-l)-o*o*(r-c)*((e=i>a.x?r-30:r+30)-c)/(s*s*(i-l))+l:e=s*s/(r-c)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-c))+c,new Jt(n,e).theta(t)},toString:function(){return new Jt(this.x,this.y).toString()+" "+this.a+" "+this.b}};const le=ae,{abs:ce,cos:he,sin:ue,min:de,max:fe,round:pe,pow:ge}=Math,me=function(t,e,n,i){if(!(this instanceof me))return new me(t,e,n,i);Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e,this.width=void 0===n?0:n,this.height=void 0===i?0:i};me.fromEllipse=function(t){return t=new ae(t),new me(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},me.fromPointUnion=function(...t){if(0===t.length)return null;const e=new Jt;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let s=0;s<t.length;s++){e.update(t[s]);const a=e.x,l=e.y;a<n&&(n=a),a>r&&(r=a),l<i&&(i=l),l>o&&(o=l)}return new me(n,i,r-n,o-i)},me.fromRectUnion=function(...t){if(0===t.length)return null;const e=new me;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let s=0;s<t.length;s++){e.update(t[s]);const a=e.x,l=e.y,c=a+e.width,h=l+e.height;a<n&&(n=a),c>r&&(r=c),l<i&&(i=l),h>o&&(o=h)}return new me(n,i,r-n,o-i)},me.prototype={type:jt.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){if(!t)return this;const{width:e,height:n}=this,i=Nt(t),r=ce(ue(i)),o=ce(he(i)),s=e*o+n*r,a=e*r+n*o;return this.x+=(e-s)/2,this.y+=(n-a)/2,this.width=s,this.height=a,this},bottomLeft:function(){return new Jt(this.x,this.y+this.height)},bottomLine:function(){return new ne(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new Jt(this.x+this.width/2,this.y+this.height)},center:function(){return new Jt(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new me(this)},containsPoint:function(t){return t instanceof Jt||(t=new Jt(t)),t.x>=this.x&&t.x<=this.x+this.width&&t.y>=this.y&&t.y<=this.y+this.height},containsRect:function(t){var e=new me(this).normalize(),n=new me(t).normalize(),i=e.width,r=e.height,o=n.width,s=n.height;if(!(i&&r&&o&&s))return!1;var a=e.x,l=e.y,c=n.x,h=n.y;return o+=c,i+=a,s+=h,r+=l,a<=c&&o<=i&&l<=h&&s<=r},corner:function(){return new Jt(this.x+this.width,this.y+this.height)},equals:function(t){var e=new me(this).normalize(),n=new me(t).normalize();return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height},inflate:function(t,e){return void 0===t&&(t=0),void 0===e&&(e=t),this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this},intersect:function(t){var e=this.origin(),n=this.corner(),i=t.origin(),r=t.corner();if(r.x<=e.x||r.y<=e.y||i.x>=n.x||i.y>=n.y)return null;var o=fe(e.x,i.x),s=fe(e.y,i.y);return new me(o,s,de(n.x,r.x)-o,de(n.y,r.y)-s)},intersectionWithLine:function(t){var e,n,i=this,r=[i.topLine(),i.rightLine(),i.bottomLine(),i.leftLine()],o=[],s=[],a=r.length;for(n=0;n<a;n++)null!==(e=t.intersect(r[n]))&&s.indexOf(e.toString())<0&&(o.push(e),s.push(e.toString()));return o.length>0?o:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new Jt(t);var n,i=new Jt(this.x+this.width/2,this.y+this.height/2);e&&t.rotate(i,e);for(var r=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],o=new ne(i,t),s=r.length-1;s>=0;--s){var a=r[s].intersection(o);if(null!==a){n=a;break}}return n&&e&&n.rotate(i,-e),n},leftLine:function(){return new ne(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new Jt(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){var n,i,r,o,s,a,l,c;t=new me(t),e||(e=t.center());var h=e.x,u=e.y;n=i=r=o=s=a=l=c=1/0;var d=t.topLeft();d.x<h&&(n=(this.x-h)/(d.x-h)),d.y<u&&(s=(this.y-u)/(d.y-u));var f=t.bottomRight();f.x>h&&(i=(this.x+this.width-h)/(f.x-h)),f.y>u&&(a=(this.y+this.height-u)/(f.y-u));var p=t.topRight();p.x>h&&(r=(this.x+this.width-h)/(p.x-h)),p.y<u&&(l=(this.y-u)/(p.y-u));var g=t.bottomLeft();return g.x<h&&(o=(this.x-h)/(g.x-h)),g.y>u&&(c=(this.y+this.height-u)/(g.y-u)),{sx:de(n,i,r,o),sy:de(s,a,l,c)}},maxRectUniformScaleToFit:function(t,e){var n=this.maxRectScaleToFit(t,e);return de(n.sx,n.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,e=this.y,n=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,i=-this.height),this.x=t,this.y=e,this.width=n,this.height=i,this},offset:function(t,e){return Jt.prototype.offset.call(this,t,e)},origin:function(){return new Jt(this.x,this.y)},pointNearestToPoint:function(t){if(t=new Jt(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new Jt(this.x+this.width,t.y);case"left":return new Jt(this.x,t.y);case"bottom":return new Jt(t.x,this.y+this.height);case"top":return new Jt(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new ne(this.topRight(),this.bottomRight())},rightMiddle:function(){return new Jt(this.x+this.width,this.y+this.height/2)},round:function(t){let e=1;if(t)switch(t){case 1:e=10;break;case 2:e=100;break;case 3:e=1e3;break;default:e=ge(10,t)}return this.x=pe(this.x*e)/e,this.y=pe(this.y*e)/e,this.width=pe(this.width*e)/e,this.height=pe(this.height*e)/e,this},scale:function(t,e,n){return n=this.origin().scale(t,e,n),this.x=n.x,this.y=n.y,this.width*=t,this.height*=e,this},sideNearestToPoint:function(t){var e=(t=new Jt(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r=e,o="left";return n<r&&(r=n,o="right"),i<r&&(r=i,o="top"),this.y+this.height-t.y<r&&(o="bottom"),o},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),i=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=i.x-n.x,this.height=i.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new ne(this.topLeft(),this.topRight())},topMiddle:function(){return new Jt(this.x+this.width/2,this.y)},topRight:function(){return new Jt(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return me.fromRectUnion(this,t)},update:function(t,e,n,i){return Object(t)===t&&(e=t.y,n=t.width,i=t.height,t=t.x),this.x=t||0,this.y=e||0,this.width=n||0,this.height=i||0,this}},me.prototype.bottomRight=me.prototype.corner,me.prototype.topLeft=me.prototype.origin,me.prototype.translate=me.prototype.offset;const ve=me;function ye(t){const e=t.trim();if(""===e)return[];const n=[],i=e.split(/\b\s*,\s*|,\s*|\s+/),r=i.length;for(let t=0;t<r;t+=2)n.push({x:+i[t],y:+i[t+1]});return n}function be(t){const e=t.length;if(0===e)return[];const n=[];for(let i=0;i<e;i++){const e=t[i].clone();n.push(e)}return n}function we(t){const{abs:e}=Math;var n,i,r,o=t.length;if(0===o)return[];for(n=0;n<o;n++)(void 0===r||t[n].y<r.y||t[n].y===r.y&&t[n].x>r.x)&&(r=t[n]);var s=[];for(n=0;n<o;n++){var a=r.theta(t[n]);0===a&&(a=360);var l=[t[n],n,a];s.push(l)}if(s.sort((function(t,e){var n=t[2]-e[2];return 0===n&&(n=e[1]-t[1]),n})),s.length>2){var c=s[s.length-1];s.unshift(c)}for(var h,u,d,f,p,g,m,v={},y=[];0!==s.length;)if(u=(h=s.pop())[0],!v.hasOwnProperty(h[0]+"@@"+h[1]))for(var b=!1;!b;)if(y.length<2)y.push(h),b=!0;else{f=(d=y.pop())[0];var w=(g=(p=y.pop())[0]).cross(f,u);if(w<0)y.push(p),y.push(d),y.push(h),b=!0;else if(0===w){var x=f.angleBetween(g,u);e(x-180)<1e-10||f.equals(u)||g.equals(f)?(v[d[0]+"@@"+d[1]]=f,y.push(p)):e((x+1)%360-1)<1e-10&&(y.push(p),s.push(d))}else v[d[0]+"@@"+d[1]]=f,y.push(p)}y.length>2&&y.pop();var A=-1;for(i=y.length,n=0;n<i;n++){var T=y[n][1];(void 0===m||T<m)&&(m=T,A=n)}var E=[];if(A>0){var P=y.slice(A),S=y.slice(0,A);E=P.concat(S)}else E=y;var _=[];for(i=E.length,n=0;n<i;n++)_.push(E[n][0]);return _}const xe=function(t){return this instanceof xe?"string"==typeof t?new xe.parse(t):void(this.points=Array.isArray(t)?t.map(Jt):[]):new xe(t)};xe.parse=function(t){return new xe(ye(t))},xe.fromRect=function(t){return new xe([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},xe.prototype={type:jt.Polyline,bbox:function(){var t=1/0,e=-1/0,n=1/0,i=-1/0,r=this.points,o=r.length;if(0===o)return null;for(var s=0;s<o;s++){var a=r[s],l=a.x,c=a.y;l<t&&(t=l),l>e&&(e=l),c<n&&(n=c),c>i&&(i=c)}return new me(t,n,e-t,i-n)},clone:function(){return new xe(be(this.points))},closestPoint:function(t){var e=this.closestPointLength(t);return this.pointAtLength(e)},closestPointLength:function(t){var e,n=this.lengthPoints(),i=n.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,o=0,s=i-1,a=0;a<s;a++){var l=new ne(n[a],n[a+1]),c=l.length(),h=l.closestPointNormalizedLength(t),u=l.pointAt(h).squaredDistance(t);u<r&&(r=u,e=o+h*c),o+=c}return e},closestPointNormalizedLength:function(t){var e=this.closestPointLength(t);if(0===e)return 0;var n=this.length();return 0===n?0:e/n},closestPointTangent:function(t){var e=this.closestPointLength(t);return this.tangentAtLength(e)},containsPoint:function(t){var e=this.points,n=e.length;if(0===n)return!1;for(var i=t.x,r=t.y,o=n-1,s=0,a=0,l=new ne,c=new ne,h=new Jt;s<n;s++){var u=e[o],d=e[s];if(t.equals(u))return!0;if(l.start=u,l.end=d,l.containsPoint(t))return!0;if(r<=u.y&&r>d.y||r>u.y&&r<=d.y){var f=u.x-i>d.x-i?u.x-i:d.x-i;f>=0&&(h.x=i+f,h.y=r,c.start=t,c.end=h,l.intersect(c)&&a++)}o=s}return a%2==1},close:function(){const{start:t,end:e,points:n}=this;return t&&e&&!t.equals(e)&&n.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new xe(we(this.points))},equals:function(t){if(!t)return!1;var e=this.points,n=t.points,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=t.points[r];if(!o.equals(s))return!1}return!0},intersectionWithLine:function(t){for(var e=new ne(t),n=[],i=this.lengthPoints(),r=new ne,o=0,s=i.length-1;o<s;o++){r.start=i[o],r.end=i[o+1];var a=e.intersectionWithLine(r);a&&n.push(a[0])}return n.length>0?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0===e)return!1;for(var n=new ne,i=e-1,r=0;r<i;r++)if(n.start=t[r],n.end=t[r+1],n.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),e=t.length;if(0===e)return 0;for(var n=0,i=e-1,r=0;r<i;r++)n+=t[r].distance(t[r+1]);return n},pointAt:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();if(t<=0)return e[0].clone();if(t>=1)return e[n-1].clone();var i=this.length()*t;return this.pointAtLength(i)},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();var i=!0;t<0&&(i=!1,t=-t);for(var r=0,o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],c=e[a+1],h=new ne(l,c),u=l.distance(c);if(t<=r+u)return h.pointAtLength((i?1:-1)*(t-r));r+=u}return(i?e[n-1]:e[0]).clone()},round:function(t){for(var e=this.points,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.points,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},simplify:function(t={}){const e=this.points;if(e.length<3)return this;const n=t.threshold||1e-10;let i=0;for(;e[i+2];){const t=i+1,r=i+2,o=e[i],s=e[t],a=e[r];new ne(o,a).closestPoint(s).distance(s)<=n?e.splice(t,1):i+=1}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;t<0&&(t=0),t>1&&(t=1);var n=this.length()*t;return this.tangentAtLength(n)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;var i,r=!0;t<0&&(r=!1,t=-t);for(var o=0,s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,c=e[l],h=e[l+1],u=new ne(c,h),d=c.distance(h);if(u.isDifferentiable()){if(t<=o+d)return u.tangentAtLength((r?1:-1)*(t-o));i=u}o+=d}if(i){var f=r?1:0;return i.tangentAt(f)}return null},toString:function(){return this.points+""},translate:function(t,e){for(var n=this.points,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},serialize:function(){var t=this.points,e=t.length;if(0===e)return"";for(var n="",i=0;i<e;i++){var r=t[i];n+=r.x+","+r.y+" "}return n.trim()}},Object.defineProperty(xe.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(xe.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});const{abs:Ae,sqrt:Te,min:Ee,max:Pe,pow:Se}=Math,_e=function(t,e,n,i){return this instanceof _e?t instanceof _e?new _e(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new Jt(t),this.controlPoint1=new Jt(e),this.controlPoint2=new Jt(n),void(this.end=new Jt(i))):new _e(t,e,n,i)};function ke(t){var e,n,i=[];for(n=arguments.length,e=1;e<n;e++)i.push(arguments[e]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=i.length,e=0;e<n;e++){var o,s,a=i[e];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}_e.throughPoints=function(){function t(t){var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}return function(e){if(!e||Array.isArray(e)&&e.length<2)throw new Error("At least 2 points are required");for(var n=function(e){var n,i=[],r=[],o=e.length-1;if(1==o)return i[0]=new Jt((2*e[0].x+e[1].x)/3,(2*e[0].y+e[1].y)/3),r[0]=new Jt(2*i[0].x-e[0].x,2*i[0].y-e[0].y),[i,r];var s=[];for(n=1;n<o-1;n++)s[n]=4*e[n].x+2*e[n+1].x;s[0]=e[0].x+2*e[1].x,s[o-1]=(8*e[o-1].x+e[o].x)/2;var a=t(s);for(n=1;n<o-1;++n)s[n]=4*e[n].y+2*e[n+1].y;s[0]=e[0].y+2*e[1].y,s[o-1]=(8*e[o-1].y+e[o].y)/2;var l=t(s);for(n=0;n<o;n++)i.push(new Jt(a[n],l[n])),n<o-1?r.push(new Jt(2*e[n+1].x-a[n+1],2*e[n+1].y-l[n+1])):r.push(new Jt((e[o].x+a[o-1])/2,(e[o].y+l[o-1])/2));return[i,r]}(e),i=[],r=n[0].length,o=0;o<r;o++){var s=new Jt(n[0][o].x,n[0][o].y),a=new Jt(n[1][o].x,n[1][o].y);i.push(new _e(e[o],s,a,e[o+1]))}return i}}(),_e.prototype={type:jt.Curve,bbox:function(){for(var t,e,n,i,r,o,s,a,l=this.start,c=this.controlPoint1,h=this.controlPoint2,u=this.end,d=l.x,f=l.y,p=c.x,g=c.y,m=h.x,v=h.y,y=u.x,b=u.y,w=new Array,x=new Array,A=[new Array,new Array],T=0;T<2;++T)if(0===T?(e=6*d-12*p+6*m,t=-3*d+9*p-9*m+3*y,n=3*p-3*d):(e=6*f-12*g+6*v,t=-3*f+9*g-9*v+3*b,n=3*g-3*f),Ae(t)<1e-12){if(Ae(e)<1e-12)continue;0<(i=-n/e)&&i<1&&x.push(i)}else a=Te(s=e*e-4*n*t),s<0||(0<(r=(-e+a)/(2*t))&&r<1&&x.push(r),0<(o=(-e-a)/(2*t))&&o<1&&x.push(o));for(var E,P,S,_=x.length,k=_;_--;)P=(E=1-(i=x[_]))*E*E*d+3*E*E*i*p+3*E*i*i*m+i*i*i*y,A[0][_]=P,S=E*E*E*f+3*E*E*i*g+3*E*i*i*v+i*i*i*b,A[1][_]=S,w[_]={X:P,Y:S};x[k]=0,x[k+1]=1,w[k]={X:d,Y:f},w[k+1]={X:y,Y:b},A[0][k]=d,A[1][k]=f,A[0][k+1]=y,A[1][k+1]=b,x.length=k+2,A[0].length=k+2,A[1].length=k+2,w.length=k+2;var L=Ee.apply(null,A[0]),C=Ee.apply(null,A[1]),M=Pe.apply(null,A[0]),O=Pe.apply(null,A[1]);return new me(L,C,M-L,O-C)},clone:function(){return new _e(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,e){return this.pointAtT(this.closestPointT(t,e))},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,i),i)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.closestPointLength(t,i);if(!r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){for(var n,i,r,o,s,a,l,c=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:c}):e.subdivisions,u=h.length,d=u?1/u:0,f=0;f<u;f++){var p=h[f],g=p.start.distance(t),m=p.end.distance(t),v=g+m;(!l||v<l)&&(n=p,i=f*d,r=(f+1)*d,o=g,s=m,a=p.start.distance(p.end),l=v)}for(var y=Se(10,-c);;){var b=o?Ae(o-s)/o:0,w=s?Ae(o-s)/s:0;if(b<y||w<y||!o||o<a*y||!s||s<a*y)return o<=s?i:r;var x=n.divide(.5);d/=2;var A=x[0].start.distance(t),T=x[0].end.distance(t),E=A+T,P=x[1].start.distance(t),S=x[1].end.distance(t);E<=P+S?(n=x[0],r-=d,o=A,s=T):(n=x[1],i+=d,o=P,s=S)}},closestPointTangent:function(t,e){return this.tangentAtT(this.closestPointT(t,e))},containsPoint:function(t,e){return this.toPolyline(e).containsPoint(t)},divideAt:function(t,e){if(t<=0)return this.divideAtT(0);if(t>=1)return this.divideAtT(1);var n=this.tAt(t,e);return this.divideAtT(n)},divideAtLength:function(t,e){var n=this.tAtLength(t,e);return this.divideAtT(n)},divideAtT:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return[new _e(e,e,e,e),new _e(e,n,i,r)];if(t>=1)return[new _e(e,n,i,r),new _e(r,r,r,r)];var o=this.getSkeletonPoints(t),s=o.startControlPoint1,a=o.startControlPoint2,l=o.divider,c=o.dividerControlPoint1,h=o.dividerControlPoint2;return[new _e(e,s,a,l),new _e(l,c,h,r)]},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()};if(t>=1)return{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};var o=new ne(e,n).pointAt(t),s=new ne(n,i).pointAt(t),a=new ne(i,r).pointAt(t),l=new ne(o,s).pointAt(t),c=new ne(s,a).pointAt(t);return{startControlPoint1:o,startControlPoint2:l,divider:new ne(l,c).pointAt(t),dividerControlPoint1:c,dividerControlPoint2:a}},getSubdivisions:function(t){var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=this.start,i=this.controlPoint1,r=this.controlPoint2,o=this.end,s=[new _e(n,i,r,o)];if(0===e)return s;if(!this.isDifferentiable())return s;var a=this.endpointDistance(),l=Se(10,-e),c=2;0===i.cross(n,o)&&0===r.cross(n,o)&&(c=2*e);for(var h=0;;){h+=1;for(var u=[],d=s.length,f=0;f<d;f++){var p=s[f].divide(.5);u.push(p[0],p[1])}for(var g=0,m=u.length,v=0;v<m;v++)g+=u[v].endpointDistance();if(h>=c&&(0!==g?(g-a)/g:0)<l)return u;s=u,a=g}},isDifferentiable:function(){var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},length:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=0,r=n.length,o=0;o<r;o++)i+=n[o].endpointDistance();return i},lengthAtT:function(t,e){if(t<=0)return 0;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:n})},pointAt:function(t,e){if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();var n=this.tAt(t,e);return this.pointAtT(n)},pointAtLength:function(t,e){var n=this.tAtLength(t,e);return this.pointAtT(n)},pointAtT:function(t){return t<=0?this.start.clone():t>=1?this.end.clone():this.getSkeletonPoints(t).divider},PRECISION:3,round:function(t){return this.start.round(t),this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.start.scale(t,e,n),this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},tangentAt:function(t,e){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);var n=this.tAt(t,e);return this.tangentAtT(n)},tangentAtLength:function(t,e){if(!this.isDifferentiable())return null;var n=this.tAtLength(t,e);return this.tangentAtT(n)},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);var e=this.getSkeletonPoints(t),n=e.startControlPoint2,i=e.dividerControlPoint1,r=e.divider,o=new ne(n,i);return o.translate(r.x-n.x,r.y-n.y),o},tAt:function(t,e){if(t<=0)return 0;if(t>=1)return 1;var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},r=this.length(i)*t;return this.tAtLength(r,i)},tAtLength:function(t,e){var n=!0;t<0&&(n=!1,t=-t);for(var i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,c=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,h={precision:l,subdivisions:c},u=0,d=c.length,f=1/d,p=0;p<d;p++){var g=n?p:d-1-p,m=c[p],v=m.endpointDistance();if(t<=u+v){i=m,r=g*f,o=(g+1)*f,s=n?t-u:v+u-t,a=n?v+u-t:t-u;break}u+=v}if(!i)return n?1:0;for(var y=this.length(h),b=Se(10,-l);;){var w,x;if((0!==y?s/y:0)<b)return r;if((0!==y?a/y:0)<b)return o;var A=i.divide(.5);f/=2;var T=A[0].endpointDistance(),E=A[1].endpointDistance();s<=T?(i=A[0],o-=f,x=T-(w=s)):(i=A[1],r+=f,x=E-(w=s-T)),s=w,a=x}},toPoints:function(t){for(var e=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=void 0===t.subdivisions?this.getSubdivisions({precision:e}):t.subdivisions,i=[n[0].start.clone()],r=n.length,o=0;o<r;o++){var s=n[o];i.push(s.end.clone())}return i},toPolyline:function(t){return new xe(this.toPoints(t))},toString:function(){return this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.start.translate(t,e),this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}},_e.prototype.divide=_e.prototype.divideAtT;const Le=function(t){if(!(this instanceof Le))return new Le(t);if("string"==typeof t)return new Le.parse(t);var e,n;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(n=(t=t.reduce((function(t,e){return t.concat(e)}),[])).length,t[0].isSegment)for(e=0;e<n;e++){var i=t[e];this.appendSegment(i)}else{var r=null;for(e=0;e<n;e++){var o=t[e];if(!(o instanceof ne||o instanceof _e))throw new Error("Cannot construct a path segment from the provided object.");0===e&&this.appendSegment(Le.createSegment("M",o.start)),r&&!r.end.equals(o.start)&&this.appendSegment(Le.createSegment("M",o.start)),o instanceof ne?this.appendSegment(Le.createSegment("L",o.end)):o instanceof _e&&this.appendSegment(Le.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),r=o}}else if(t.isSegment)this.appendSegment(t);else if(t instanceof ne)this.appendSegment(Le.createSegment("M",t.start)),this.appendSegment(Le.createSegment("L",t.end));else if(t instanceof _e)this.appendSegment(Le.createSegment("M",t.start)),this.appendSegment(Le.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof xe))throw new Error("Cannot construct a path from the provided object.");if(!t.points||0===t.points.length)return;for(n=t.points.length,e=0;e<n;e++){var s=t.points[e];0===e?this.appendSegment(Le.createSegment("M",s)):this.appendSegment(Le.createSegment("L",s))}}};function Ce(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}Le.parse=function(t){if(!t)return new Le;for(var e=new Le,n=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),i=n.length,r=0;r<i;r++){var o=n[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),s=Le.createSegment.apply(this,o);e.appendSegment(s)}return e},Le.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=Le.segmentTypes[t];if(!e)throw new Error(t+" is not a recognized path segment type.");for(var n=[],i=arguments.length,r=1;r<i;r++)n.push(arguments[r]);return Ce(e,n)},Le.prototype={type:jt.Path,appendSegment:function(t){var e,n=this.segments,i=n.length,r=0!==i?n[i-1]:null;if(Array.isArray(t)){if(!(t=t.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");for(var o=t.length,s=0;s<o;s++){var a=t[s];e=this.prepareSegment(a,r,null),n.push(e),r=e}}else{if(!t||!t.isSegment)throw new Error("Segment required.");e=this.prepareSegment(t,r,null),n.push(e)}},bbox:function(){var t,e=this.segments,n=e.length;if(0===n)return null;for(var i=0;i<n;i++){var r=e[i];if(r.isVisible){var o=r.bbox();t=t?t.union(o):o}}if(t)return t;var s=e[n-1];return new me(s.end.x,s.end.y,0,0)},clone:function(){for(var t=this.segments,e=t.length,n=new Le,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){var n=this.closestPointT(t,e);return n?this.pointAtT(n):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointT(t,i);return r?this.lengthAtT(r,i):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.closestPointLength(t,i);if(0===r)return 0;var o=this.length(i);return 0===o?0:r/o},closestPointT:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<i;l++){var c=n[l],h=s[l];if(c.isVisible){var u=c.closestPointT(t,{precision:o,subdivisions:h}),d=c.pointAtT(u),f=new ne(d,t).squaredLength();f<a&&(r={segmentIndex:l,value:u},a=f)}}return r||{segmentIndex:i-1,value:1}},closestPointTangent:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=1/0,l=0;l<i;l++){var c=n[l],h=s[l];if(c.isDifferentiable()){var u=c.closestPointT(t,{precision:o,subdivisions:h}),d=c.pointAtT(u),f=new ne(d,t).squaredLength();f<a&&(r=c.tangentAtT(u),a=f)}}return r||null},containsPoint:function(t,e){var n=this.toPolylines(e);if(!n)return!1;for(var i=n.length,r=0,o=0;o<i;o++)n[o].containsPoint(t)&&r++;return r%2==1},divideAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.divideAtLength(r,i)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;var i=!0;t<0&&(i=!1,t=-t);var r,o,s,a,l,c,h,u=void 0===(e=e||{}).precision?this.PRECISION:e.precision,d=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:u}):e.segmentSubdivisions,f=0;for(r=0;r<n;r++){var p=i?r:n-1-r;o=this.getSegment(p);var g=d[p],m=o.length({precision:u,subdivisions:g});if(o.isDifferentiable()&&(l=o,c=p,t<=f+m)){a=p,s=o.divideAtLength((i?1:-1)*(t-f),{precision:u,subdivisions:g});break}f+=m}if(!l)return null;s||(a=c,h=i?1:0,s=l.divideAtT(h));var v=this.clone();v.replaceSegment(a,s);var y=a,b=a+1,w=a+2;s[0].isDifferentiable()||(v.removeSegment(y),b-=1,w-=1);var x=v.getSegment(b).start;v.insertSegment(b,Le.createSegment("M",x)),w+=1,s[1].isDifferentiable()||(v.removeSegment(w-1),w-=1);var A=w-y-1;for(r=w;r<v.segments.length;r++){var T=this.getSegment(r-A);if("Z"===(o=v.getSegment(r)).type&&!T.subpathStartSegment.end.equals(o.subpathStartSegment.end)){var E=Le.createSegment("L",T.end);v.replaceSegment(r,E)}}return[new Le(v.segments.slice(0,b)),new Le(v.segments.slice(b))]},equals:function(t){if(!t)return!1;var e=this.segments,n=t.segments,i=e.length;if(n.length!==i)return!1;for(var r=0;r<i;r++){var o=e[r],s=n[r];if(o.type!==s.type||!o.equals(s))return!1}return!0},getSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),t>=n||t<0)throw new Error("Index out of range.");return e[t]},getSegmentSubdivisions:function(t){for(var e=this.segments,n=e.length,i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=[],o=0;o<n;o++){var s=e[o].getSubdivisions({precision:i});r.push(s)}return r},getSubpaths:function(){const t=this.clone().validate().segments,e=t.length,n=[];for(let i=0;i<e;i++){const e=t[i];e.isSubpathStart?n.push(new Le(e)):n[n.length-1].appendSegment(e)}return n},insertSegment:function(t,e){var n,i=this.segments,r=i.length;if(t<0&&(t=r+t+1),t>r||t<0)throw new Error("Index out of range.");var o=null,s=null;if(0!==r&&(s=t>=1?(o=i[t-1]).nextSegment:i[0]),Array.isArray(e)){if(!(e=e.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");for(var a=e.length,l=0;l<a;l++){var c=e[l];n=this.prepareSegment(c,o,s),i.splice(t+l,0,n),o=n}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,o,s),i.splice(t,0,n)}},intersectionWithLine:function(t,e){var n=null,i=this.toPolylines(e);if(!i)return null;for(var r=0,o=i.length;r<o;r++){var s=i[r],a=t.intersect(s);a&&(n||(n=[]),Array.isArray(a)?Array.prototype.push.apply(n,a):n.push(a))}return n},isDifferentiable:function(){for(var t=this.segments,e=t.length,n=0;n<e;n++)if(t[n].isDifferentiable())return!0;return!1},isValid:function(){var t=this.segments;return 0===t.length||"M"===t[0].type},length:function(t){var e=this.segments,n=e.length;if(0===n)return 0;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=0,s=0;s<n;s++){var a=e[s],l=r[s];o+=a.length({subdivisions:l})}return o},lengthAtT:function(t,e){var n=this.segments,i=n.length;if(0===i)return 0;var r=t.segmentIndex;if(r<0)return 0;var o=t.value;r>=i?(r=i-1,o=1):o<0?o=0:o>1&&(o=1);for(var s,a=void 0===(e=e||{}).precision?this.PRECISION:e.precision,l=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:a}):e.segmentSubdivisions,c=0,h=0;h<r;h++){var u=n[h];s=l[h],c+=u.length({precisison:a,subdivisions:s})}return u=n[r],s=l[r],c+u.lengthAtT(o,{precisison:a,subdivisions:s})},pointAt:function(t,e){if(0===this.segments.length)return null;if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.pointAtLength(r,i)},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();var r=!0;t<0&&(r=!1,t=-t);for(var o,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=a[h],f=u.length({precision:s,subdivisions:d});if(u.isVisible){if(t<=l+f)return u.pointAtLength((r?1:-1)*(t-l),{precision:s,subdivisions:d});o=u}l+=f}return o?r?o.end:o.start:n[i-1].end.clone()},pointAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].pointAtT(0);if(i>=n)return e[n-1].pointAtT(1);var r=t.value;return r<0?r=0:r>1&&(r=1),e[i].pointAtT(r)},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);var i=t;return t.isSubpathStart&&(t.subpathStartSegment=t,i=n),i&&this.updateSubpathStartSegment(i),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(t<0&&(t=n+t),t>=n||t<0)throw new Error("Index out of range.");var i=e.splice(t,1)[0],r=i.previousSegment,o=i.nextSegment;r&&(r.nextSegment=o),o&&(o.previousSegment=r),i.isSubpathStart&&o&&this.updateSubpathStartSegment(o)},replaceSegment:function(t,e){var n,i=this.segments,r=i.length;if(0===r)throw new Error("Path has no segments.");if(t<0&&(t=r+t),t>=r||t<0)throw new Error("Index out of range.");var o=i[t],s=o.previousSegment,a=o.nextSegment,l=o.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce((function(t,e){return t.concat(e)}),[]))[0].isSegment)throw new Error("Segments required.");i.splice(t,1);for(var c=e.length,h=0;h<c;h++){var u=e[h];n=this.prepareSegment(u,s,a),i.splice(t+h,0,n),s=n,l&&n.isSubpathStart&&(l=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");n=this.prepareSegment(e,s,a),i.splice(t,1,n),l&&n.isSubpathStart&&(l=!1)}l&&a&&this.updateSubpathStartSegment(a)},round:function(t){for(var e=this.segments,n=e.length,i=0;i<n;i++)e[i].round(t);return this},scale:function(t,e,n){for(var i=this.segments,r=i.length,o=0;o<r;o++)i[o].scale(t,e,n);return this},segmentAt:function(t,e){var n=this.segmentIndexAt(t,e);return n?this.getSegment(n):null},segmentAtLength:function(t,e){var n=this.segmentIndexAtLength(t,e);return n?this.getSegment(n):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.segmentIndexAtLength(r,i)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o=void 0===(e=e||{}).precision?this.PRECISION:e.precision,s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=s[h],f=u.length({precision:o,subdivisions:d});if(u.isVisible){if(t<=l+f)return h;a=h}l+=f}return a},serialize:function(){if(!this.isValid())throw new Error("Invalid path segments.");return this.toString()},tangentAt:function(t,e){if(0===this.segments.length)return null;t<0&&(t=0),t>1&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,i={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},r=this.length(i)*t;return this.tangentAtLength(r,i)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;var r=!0;t<0&&(r=!1,t=-t);for(var o,s=void 0===(e=e||{}).precision?this.PRECISION:e.precision,a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,c=0;c<i;c++){var h=r?c:i-1-c,u=n[h],d=a[h],f=u.length({precision:s,subdivisions:d});if(u.isDifferentiable()){if(t<=l+f)return u.tangentAtLength((r?1:-1)*(t-l),{precision:s,subdivisions:d});o=u}l+=f}if(o){var p=r?1:0;return o.tangentAtT(p)}return null},tangentAtT:function(t){var e=this.segments,n=e.length;if(0===n)return null;var i=t.segmentIndex;if(i<0)return e[0].tangentAtT(0);if(i>=n)return e[n-1].tangentAtT(1);var r=t.value;return r<0?r=0:r>1&&(r=1),e[i].tangentAtT(r)},toPoints:function(t){var e=this.segments,n=e.length;if(0===n)return null;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,o=[],s=[],a=0;a<n;a++){var l=e[a];if(l.isVisible){var c=r[a];if(c.length>0){var h=c.map((function(t){return t.start}));Array.prototype.push.apply(s,h)}else s.push(l.start)}else s.length>0&&(s.push(e[a-1].end),o.push(s),s=[])}return s.length>0&&(s.push(this.end),o.push(s)),o},toPolylines:function(t){var e=[],n=this.toPoints(t);if(!n)return null;for(var i=0,r=n.length;i<r;i++)e.push(new xe(n[i]));return e},toString:function(){for(var t=this.segments,e=t.length,n="",i=0;i<e;i++)n+=t[i].serialize()+" ";return n.trim()},translate:function(t,e){for(var n=this.segments,i=n.length,r=0;r<i;r++)n[r].translate(t,e);return this},updateSubpathStartSegment:function(t){for(var e=t.previousSegment;t&&!t.isSubpathStart;)t.subpathStartSegment=e?e.subpathStartSegment:null,e=t,t=t.nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,Le.createSegment("M",0,0)),this}},Object.defineProperty(Le.prototype,"start",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n=0;n<e;n++){var i=t[n];if(i.isVisible)return i.start}return t[e-1].end}}),Object.defineProperty(Le.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n=e-1;n>=0;n--){var i=t[n];if(i.isVisible)return i.end}return t[e-1].end}});var Me={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){if(t<=0)return 0;var e=this.length();return t>=1?e:e*t},nextSegment:null,pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},pointAtT:function(t){if(this.pointAt)return this.pointAt(t);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,round:function(){throw new Error("Declaration missing for virtual function.")},subpathStartSegment:null,scale:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},tangentAtT:function(t){if(this.tangentAt)return this.tangentAt(t);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},toString:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")}};Object.defineProperty(Me,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(Me,"start",{configurable:!0,enumerable:!0,get:function(){if(!this.previousSegment)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)");return this.previousSegment.end}}),Object.defineProperty(Me,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}});var Oe=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Oe))return Ce(Oe,n);if(0===i)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof ne){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+i+" lines provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===i)return this.end=new Jt(+n[0],+n[1]),this;if(i<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=2)o=n.slice(r,r+2),t.push(Ce(Oe,o));return t}if(1===i)return this.end=new Jt(n[0]),this;for(t=[],r=0;r<i;r+=1)e=n[r],t.push(new Oe(e));return t},Ne={clone:function(){return new Oe(this.end)},divideAt:function(t){var e=new ne(this.start,this.end).divideAt(t);return[new Oe(e[0]),new Oe(e[1])]},divideAtLength:function(t){var e=new ne(this.start,this.end).divideAtLength(t);return[new Oe(e[0]),new Oe(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(Ne,"type",{configurable:!0,enumerable:!0,value:"L"}),Oe.prototype=ke(Me,ne.prototype,Ne);var Re=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Re))return Ce(Re,n);if(0===i)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(n[0]instanceof _e){if(1===i)return this.controlPoint1=n[0].controlPoint1.clone(),this.controlPoint2=n[0].controlPoint2.clone(),this.end=n[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(6===i)return this.controlPoint1=new Jt(+n[0],+n[1]),this.controlPoint2=new Jt(+n[2],+n[3]),this.end=new Jt(+n[4],+n[5]),this;if(i<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=6)o=n.slice(r,r+6),t.push(Ce(Re,o));return t}if(3===i)return this.controlPoint1=new Jt(n[0]),this.controlPoint2=new Jt(n[1]),this.end=new Jt(n[2]),this;if(i<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+i+" points provided).");for(t=[],r=0;r<i;r+=3)e=n.slice(r,r+3),t.push(Ce(Re,e));return t},Fe={clone:function(){return new Re(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){var n=new _e(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Re(n[0]),new Re(n[1])]},divideAtLength:function(t,e){var n=new _e(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Re(n[0]),new Re(n[1])]},divideAtT:function(t){var e=new _e(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Re(e[0]),new Re(e[1])]},isDifferentiable:function(){if(!this.previousSegment)return!1;var t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(i))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,e,n){return this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this},serialize:function(){var t=this.controlPoint1,e=this.controlPoint2,n=this.end;return this.type+" "+t.x+" "+t.y+" "+e.x+" "+e.y+" "+n.x+" "+n.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,e){return this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e),this}};Object.defineProperty(Fe,"type",{configurable:!0,enumerable:!0,value:"C"}),Re.prototype=ke(Me,_e.prototype,Fe);var Be=function(){for(var t,e,n=[],i=arguments.length,r=0;r<i;r++)n.push(arguments[r]);if(!(this instanceof Be))return Ce(Be,n);if(0===i)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof ne){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" lines provided).")}if(n[0]instanceof _e){if(1===i)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===i)return this.end=new Jt(+n[0],+n[1]),this;if(i<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+i+" coordinates provided).");var o;for(t=[],r=0;r<i;r+=2)o=n.slice(r,r+2),0===r?t.push(Ce(Be,o)):t.push(Ce(Oe,o));return t}if(1===i)return this.end=new Jt(n[0]),this;for(t=[],r=0;r<i;r+=1)e=n[r],0===r?t.push(new Be(e)):t.push(new Oe(e));return t},Ie={bbox:function(){return null},clone:function(){return new Be(this.end)},closestPoint:function(){return this.end.clone()},closestPointNormalizedLength:function(){return 0},closestPointLength:function(){return 0},closestPointT:function(){return 1},closestPointTangent:function(){return null},divideAt:function(){return[this.clone(),this.clone()]},divideAtLength:function(){return[this.clone(),this.clone()]},equals:function(t){return this.end.equals(t.end)},getSubdivisions:function(){return[]},isDifferentiable:function(){return!1},isSubpathStart:!0,isVisible:!1,length:function(){return 0},lengthAtT:function(){return 0},pointAt:function(){return this.end.clone()},pointAtLength:function(){return this.end.clone()},pointAtT:function(){return this.end.clone()},round:function(t){return this.end.round(t),this},scale:function(t,e,n){return this.end.scale(t,e,n),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},tangentAt:function(){return null},tangentAtLength:function(){return null},tangentAtT:function(){return null},toString:function(){return this.type+" "+this.end},translate:function(t,e){return this.end.translate(t,e),this}};Object.defineProperty(Ie,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(Ie,"type",{configurable:!0,enumerable:!0,value:"M"}),Be.prototype=ke(Me,Ie);var De=function(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof De))return Ce(De,t);if(e>0)throw new Error("Closepath constructor expects no arguments.");return this},Ve={clone:function(){return new De},divideAt:function(t){var e=new ne(this.start,this.end).divideAt(t);return[e[1].isDifferentiable()?new Oe(e[0]):this.clone(),new Oe(e[1])]},divideAtLength:function(t){var e=new ne(this.start,this.end).divideAtLength(t);return[e[1].isDifferentiable()?new Oe(e[0]):this.clone(),new Oe(e[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment||this.start.equals(this.end))},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}};Object.defineProperty(Ve,"end",{configurable:!0,enumerable:!0,get:function(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)");return this.subpathStartSegment.end}}),Object.defineProperty(Ve,"type",{configurable:!0,enumerable:!0,value:"Z"}),De.prototype=ke(Me,ne.prototype,Ve);var ze=Le.segmentTypes={L:Oe,C:Re,M:Be,Z:De,z:De};Le.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(ze).join("")+",.]*$"),Le.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)};const je={curveThroughPoints:function(t){return console.warn("deprecated"),new Le(_e.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e,n=[],i=[],r=t.length-1;if(1==r)return n[0]=new Jt((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),i[0]=new Jt(2*n[0].x-t[0].x,2*n[0].y-t[0].y),[n,i];var o=[];for(e=1;e<r-1;e++)o[e]=4*t[e].x+2*t[e+1].x;o[0]=t[0].x+2*t[1].x,o[r-1]=(8*t[r-1].x+t[r].x)/2;var s=this.getFirstControlPoints(o);for(e=1;e<r-1;++e)o[e]=4*t[e].y+2*t[e+1].y;o[0]=t[0].y+2*t[1].y,o[r-1]=(8*t[r-1].y+t[r].y)/2;var a=this.getFirstControlPoints(o);for(e=0;e<r;e++)n.push(new Jt(s[e],a[e])),e<r-1?i.push(new Jt(2*t[e+1].x-s[e+1],2*t[e+1].y-a[e+1])):i.push(new Jt((t[r].x+s[r-1])/2,(t[r].y+a[r-1])/2));return[n,i]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new _e(t,e,n,i);return function(t){var e=r.divide(t);return[{p0:e[0].start,p1:e[0].controlPoint1,p2:e[0].controlPoint2,p3:e[0].end},{p0:e[1].start,p1:e[1].controlPoint1,p2:e[1].controlPoint2,p3:e[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var e=t.length,n=[],i=[],r=2;n[0]=t[0]/r;for(var o=1;o<e;o++)i[o]=1/r,r=(o<e-1?4:3.5)-i[o],n[o]=(t[o]-n[o-1])/r;for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n},getInversionSolver:function(t,e,n,i){console.warn("deprecated");var r=new _e(t,e,n,i);return function(t){return r.closestPointT(t)}}},$e=function(t){return this instanceof $e?"string"==typeof t?new $e.parse(t):void(this.points=Array.isArray(t)?t.map(Jt):[]):new $e(t)};function Ue(t,e,n,i){switch(t.type){case jt.Line:if(e.type===jt.Line)return Ge(t,e);break;case jt.Ellipse:switch(e.type){case jt.Line:return qe(t,e);case jt.Ellipse:return He(t,e)}break;case jt.Rect:switch(e.type){case jt.Line:return We(t,e);case jt.Ellipse:return Ye(t,e);case jt.Rect:return Xe(t,e)}break;case jt.Polyline:switch(e.type){case jt.Line:return Ze(t,e);case jt.Ellipse:return Ke(t,e);case jt.Rect:return Je(t,e);case jt.Polyline:return Qe(t,e)}break;case jt.Polygon:switch(e.type){case jt.Line:return tn(t,e);case jt.Ellipse:return en(t,e);case jt.Rect:return nn(t,e);case jt.Polyline:return rn(t,e);case jt.Polygon:return on(t,e)}break;case jt.Path:switch(e.type){case jt.Line:return sn(t,e,n);case jt.Ellipse:return an(t,e,n);case jt.Rect:return ln(t,e,n);case jt.Polyline:return cn(t,e,n);case jt.Polygon:return hn(t,e,n);case jt.Path:return un(t,e,n,i)}}switch(e.type){case jt.Ellipse:case jt.Rect:case jt.Polyline:case jt.Polygon:case jt.Path:return Ue(e,t,i,n);default:throw Error(`The intersection for ${t} and ${e} could not be found.`)}}function Ge(t,e){const n=t.start.x,i=t.start.y,r=t.end.x,o=t.end.y,s=e.start.x,a=e.start.y,l=r-n,c=o-i,h=e.end.x-s,u=e.end.y-a,d=n-s,f=i-a,p=l*u-h*c,g=(l*f-c*d)/p,m=(h*f-u*d)/p;return g>=0&&g<=1&&m>=0&&m<=1}function qe(t,e){const n=t.a,i=t.b,r=t.x,o=t.y,s=e.start.x-r,a=e.end.x-r,l=e.start.y-o,c=n*n,h=i*i,u=a-s,d=e.end.y-o-l,f=u*u/c+d*d/h,p=2*s*u/c+2*l*d/h,g=p*p-4*f*(s*s/c+l*l/h-1);if(0===g){const t=-p/2/f;return t>=0&&t<=1}if(g>0){const t=Math.sqrt(g),e=(-p+t)/2/f,n=(-p-t)/2/f;return e>=0&&e<=1||n>=0&&n<=1}return!1}function He(t,e){return function(t,e,n,i){const{cos:r,sin:o}=Math,s=o(0),a=r(0),l=o(0),c=r(0),h=s*s,u=a*a,d=s*a,f=l*l,p=c*c,g=l*c,m=t.a*t.a,v=t.b*t.b,y=n.a*n.a,b=n.b*n.b,w=m*h+v*u,x=y*f+b*p,A=m*u+v*h,T=y*p+b*f;let E=2*(v-m)*d,P=2*(b-y)*g,S=-2*w*t.x-E*t.y,_=-2*x*n.x-P*n.y,k=-E*t.x-2*A*t.y,L=-P*n.x-2*T*n.y;const C=w*t.x*t.x+A*t.y*t.y+E*t.x*t.y-m*v,M=x*n.x*n.x+T*n.y*n.y+P*n.x*n.y-y*b;E/=2,P/=2,S/=2,_/=2,k/=2,L/=2;const O=bn([[w,E,S],[E,A,k],[S,k,C]]),N=bn([[x,P,_],[P,T,L],[_,L,M]]),R=.33333333*(bn([[x,E,S],[P,A,k],[_,k,C]])+bn([[w,P,S],[E,T,k],[S,L,C]])+bn([[w,E,_],[E,A,L],[S,k,M]])),F=.33333333*(bn([[w,P,_],[E,T,L],[S,L,M]])+bn([[x,E,_],[P,A,L],[_,k,M]])+bn([[x,P,S],[P,T,k],[_,L,C]])),B=yn([[O,R],[R,F]]),I=yn([[O,F],[R,N]]),D=yn([[R,F],[F,N]]);return!(yn([[2*B,I],[I,2*D]])>0&&(F>0||R>0))}(t,0,e)}function We(t,e){const{start:n,end:i}=e,{x:r,y:o,width:s,height:a}=t;return!(n.x>r+s&&i.x>r+s||n.x<r&&i.x<r||n.y>o+a&&i.y>o+a||n.y<o&&i.y<o)&&(!(!t.containsPoint(e.start)&&!t.containsPoint(e.end))||Ge(t.topLine(),e)||Ge(t.rightLine(),e)||Ge(t.bottomLine(),e)||Ge(t.leftLine(),e))}function Ye(t,e){return!!Xe(t,me.fromEllipse(e))&&en($e.fromRect(t),e)}function Xe(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function Ze(t,e){return dn(t,e,{interior:!1})}function Ke(t,e){return fn(t,e,{interior:!1})}function Je(t,e){return pn(t,e,{interior:!1})}function Qe(t,e){return mn(t,e,{interior:!1})}function tn(t,e){return dn(t,e,{interior:!0})}function en(t,e){return fn(t,e,{interior:!0})}function nn(t,e){return pn(t,e,{interior:!0})}function rn(t,e){return mn(t,e,{interior:!0})}function on(t,e){return vn(t,e,{interior:!0})}function sn(t,e,n){return t.getSubpaths().some((t=>{const[i]=t.toPolylines(n),{type:r}=t.getSegment(-1);return"Z"===r?tn(i,e):Ze(i,e)}))}function an(t,e,n){return t.getSubpaths().some((t=>{const[i]=t.toPolylines(n),{type:r}=t.getSegment(-1);return"Z"===r?en(i,e):Ke(i,e)}))}function ln(t,e,n){return hn(t,$e.fromRect(e),n)}function cn(t,e,n){return gn(t,e,n,{interior:!1})}function hn(t,e,n){return gn(t,e,n,{interior:!0})}function un(t,e,n,i){return t.getSubpaths().some((t=>{const[r]=t.toPolylines(n),{type:o}=t.getSegment(-1);return"Z"===o?hn(e,r,i):cn(e,r,i)}))}function dn(t,e,n={}){const{interior:i=!1}=n;let r;if(i){if(t.containsPoint(e.start))return!0;const{start:n,end:i,points:o}=t;r=i.equals(n)?o:[...o,n]}else r=t.points;const{length:o}=r,s=new ne;for(let t=0;t<o-1;t++)if(s.start=r[t],s.end=r[t+1],Ge(e,s))return!0;return!1}function fn(t,e,n={}){const{start:i,end:r,points:o}=t;if(e.containsPoint(i))return!0;let s;const{interior:a=!1}=n;if(a){if(t.containsPoint(e.center()))return!0;s=r.equals(i)?o:[...o,i]}else s=o;const{length:l}=s,c=new ne;for(let t=0;t<l-1;t++)if(c.start=s[t],c.end=s[t+1],qe(e,c))return!0;return!1}function pn(t,e,n){return vn(t,$e.fromRect(e),n)}function gn(t,e,n,i){return t.getSubpaths().some((t=>{const[r]=t.toPolylines(n),{type:o}=t.getSegment(-1);return"Z"===o?vn(e,r,i):mn(e,r,i)}))}function mn(t,e,n={}){const{interior:i=!1}=n;let r;if(i){const{start:n}=e;if(t.containsPoint(n))return!0;r=t.clone().close()}else r=t;const o=e.points,{length:s}=o,a=new ne;for(let t=0;t<s-1;t++)if(a.start=o[t],a.end=o[t+1],Ze(r,a))return!0;return!1}function vn(t,e,n){return e.containsPoint(t.start)||mn(t,e.clone().close(),n)}function yn(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function bn(t){return t[0][0]*t[1][1]*t[2][2]-t[0][0]*t[1][2]*t[2][1]-t[0][1]*t[1][0]*t[2][2]+t[0][1]*t[1][2]*t[2][0]+t[0][2]*t[1][0]*t[2][1]-t[0][2]*t[1][1]*t[2][0]}$e.parse=function(t){return new $e(ye(t))},$e.fromRect=function(t){return new $e([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},$e.prototype=ke(xe.prototype,{type:jt.Polygon,clone:function(){return new $e(be(this.points))},convexHull:function(){return new $e(we(this.points))},lengthPoints:function(){const{start:t,end:e,points:n}=this;return n.length<=1||t.equals(e)?n:[...n,t.clone()]}});const wn=t,xn=function(){if("object"!=typeof window||!window.SVGAngle)return function(){throw new Error("SVG is required to use Vectorizer.")};var t={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},n=Math,i=n.PI,r=n.atan2,o=n.sqrt,s=n.min,a=n.max,l=n.cos,c=n.sin,h=function(e,n,i){if(!(this instanceof h))return h.apply(Object.create(h.prototype),arguments);if(e){if(h.isV(e)&&(e=e.node),n=n||{},h.isString(e)){if("svg"===(e=e.trim()).toLowerCase())e=h.createSvgDocument();else if("<"===e[0]){var r=h.createSvgDocument(e);if(r.childNodes.length>1){var o,s,a=[];for(o=0,s=r.childNodes.length;o<s;o++){var l=r.childNodes[o];a.push(new h(document.importNode(l,!0)))}return a}e=document.importNode(r.firstChild,!0)}else e=document.createElementNS(t.svg,e);h.ensureId(e)}return this.node=e,this.setAttributes(n),i&&this.append(i),this}},u=h.prototype;function d(t,e,n){n||(n={});for(var i=n.includeAnnotationIndices,r=n.eol,o=n.lineHeight,s=n.baseSize,a=0,l={},c=e.length-1,u=0;u<=c;u++){var d=e[u],f=null;if(h.isObject(d)){var p=d.attrs,g=h("tspan",p),m=g.node,v=d.t;r&&u===c&&(v+=r),m.textContent=v;var y=p.class;y&&g.addClass(y),i&&g.attr("annotations",d.annotations),f=parseFloat(p["font-size"]),isFinite(f)||(f=s),f&&f>a&&(a=f)}else r&&u===c&&(d+=r),m=document.createTextNode(d||" "),s&&s>a&&(a=s);t.appendChild(m)}return a&&(l.maxFontSize=a),o?l.lineHeight=o:a&&(l.lineHeight=1.2*a),l}Object.defineProperty(u,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),u.getTransformToElement=function(t){var e=this.node;if(h.isSVGGraphicsElement(t)&&h.isSVGGraphicsElement(e)){var n=h.toNode(t).getScreenCTM(),i=e.getScreenCTM();if(n&&i)return n.inverse().multiply(i)}return h.createSVGMatrix()},u.transform=function(t,e){var n=this.node;if(h.isUndefined(t))return h.transformStringToMatrix(this.attr("transform"));if(e&&e.absolute)return this.attr("transform",h.matrixToTransformString(t));var i=h.createSVGTransform(t);return n.transform.baseVal.appendItem(i),this},u.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=h.parseTransformString(i);if(i=r.value,h.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();var o="translate("+(n.absolute?t:r.translate.tx+t)+","+(n.absolute?e:r.translate.ty+e)+")";return this.attr("transform",(o+" "+i).trim()),this},u.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=h.parseTransformString(r);if(r=o.value,h.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;var s="rotate("+(i.absolute?t:o.rotate.angle+t)+(void 0!==e&&void 0!==n?","+e+","+n:"")+")";return this.attr("transform",(r+" "+s).trim()),this},u.scale=function(t,e){e=h.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=h.parseTransformString(n);if(n=i.value,h.isUndefined(t))return i.scale;n=n.replace(/scale\([^)]*\)/g,"").trim();var r="scale("+t+","+e+")";return this.attr("transform",(n+" "+r).trim()),this},u.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new me(0,0,0,0);try{n=i.getBBox()}catch(t){n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(t)return new me(n);var o=this.getTransformToElement(e||r);return h.transformRect(n,o)},u.getBBox=function(t){var e,n={},i=this.node;if(!i.ownerSVGElement||!h.isSVGGraphicsElement(i))return new me(0,0,0,0);if(t&&(t.target&&(n.target=h.toNode(t.target)),t.recursive&&(n.recursive=t.recursive)),n.recursive){var r=this.children(),o=r.length;if(0===o)return this.getBBox({target:n.target,recursive:!1});n.target||(n.target=this);for(var s=0;s<o;s++){var a,l=r[s];a=0===l.children().length?l.getBBox({target:n.target,recursive:!1}):l.getBBox({target:n.target,recursive:!0}),e=e?e.union(a):a}return e}try{e=i.getBBox()}catch(t){e={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}if(n.target){var c=this.getTransformToElement(n.target);return h.transformRect(e,c)}return new me(e)};var f=/em$/;function p(t,e){var n=parseFloat(t);return f.test(t)?n*e:n}u.text=function(e,n){if(e&&"string"!=typeof e)throw new Error("Vectorizer: text() expects the first argument to be a string.");e=h.sanitizeText(e),n||(n={});var i=n.displayEmpty,r=n.eol,o=n.textPath,s=n.textVerticalAnchor,a="middle"===s||"bottom"===s||"top"===s,l=n.x;void 0===l&&(l=this.attr("x")||0);var c=n.includeAnnotationIndices,u=n.annotations;u&&!h.isArray(u)&&(u=[u]);var g=n.lineHeight,m="auto"===g,v=m?"1.5em":g||"1em";this.empty(),this.attr({"xml:space":"preserve",display:e||i?null:"none"});var y=parseFloat(this.attr("font-size"));y||(y=16,(a||u)&&this.attr("font-size",y));var b,w=document;o?("string"==typeof o&&(o={d:o}),b=function(t,e){t||(t={});var n=h("textPath"),i=t.d;if(i&&void 0===t["xlink:href"]){var r=h("path").attr("d",i).appendTo(e.defs());n.attr("xlink:href","#"+r.id)}return h.isObject(t)&&n.attr(t),n.node}(o,this)):b=w.createDocumentFragment();for(var x,A=0,T=e.split("\n"),E=[],P=0,S=T.length-1;P<=S;P++){var _,k=v,L="v-line",C=w.createElementNS(t.svg,"tspan"),M=T[P];if(M)if(u){var O=h.annotateString(M,u,{offset:-A,includeAnnotationIndices:c}),N=(_=d(C,O,{includeAnnotationIndices:c,eol:P!==S&&r,lineHeight:m?null:v,baseSize:y})).lineHeight;N&&m&&0!==P&&(k=N),0===P&&(x=.8*_.maxFontSize)}else r&&P!==S&&(M+=r),C.textContent=M;else{C.textContent="-",L+=" v-empty-line";var R=C.style;if(R.fillOpacity=0,R.strokeOpacity=0,u){_={};let t=y;for(let e=(O=h.findAnnotationsAtIndex(u,A)).length;e>0;e--){const n=O[e-1].attrs;if(!n||!("font-size"in n))continue;const i=parseFloat(n["font-size"]);if(isFinite(i)){t=i;break}}m&&(P>0?k=1.2*t:x=.8*t),C.setAttribute("font-size",t),_.maxFontSize=t}}_&&E.push(_),P>0&&C.setAttribute("dy",k),(P>0||o)&&C.setAttribute("x",l),C.className.baseVal=L,b.appendChild(C),A+=M.length+1}if(a)if(u)k=function(t,e,n,i){if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=p(o.maxFontSize,n)||n,a=0,l=p(i,n),c=1;c<r;c++)a+=p((o=e[c]).lineHeight,n)||l;var h,u=p(o.maxFontSize,n)||n;switch(t){case"middle":h=s/2-.15*u-a/2;break;case"bottom":h=-.25*u-a;break;default:h=.8*s}return h}(s,E,y,v);else if("top"===s)k="0.8em";else{var F;switch(S>0?(F=parseFloat(v)||1,F*=S,f.test(v)||(F/=y)):F=0,s){case"middle":k=.3-F/2+"em";break;case"bottom":k=-F-.3+"em"}}else 0===s?k="0em":s?k=s:(k=0,null===this.attr("y")&&this.attr("y",x||"0.8em"));return b.firstChild.setAttribute("dy",k),this.append(b),this},u.removeAttr=function(t){const e=y[t],{ns:n,local:i}=h.qualifyAttr(e),r=this.node;return n?r.hasAttributeNS(n,i)&&r.removeAttributeNS(n,i):r.hasAttribute(e)&&r.removeAttribute(e),this},u.attr=function(t,e){if(h.isUndefined(t)){for(var n=this.node.attributes,i={},r=0;r<n.length;r++)i[n[r].name]=n[r].value;return i}if(h.isString(t)&&h.isUndefined(e))return this.node.getAttribute(y[t]);if("object"==typeof t)for(var o in t)t.hasOwnProperty(o)&&this.setAttribute(o,t[o]);else this.setAttribute(t,e);return this},u.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",h.normalizePathData(this.attr("d"))),this},u.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},u.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},u.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},u.append=function(t){h.isArray(t)||(t=[t]);for(var e=0,n=t.length;e<n;e++)this.node.appendChild(h.toNode(t[e]));return this},u.prepend=function(t){var e=this.node.firstChild;return e?h(e).before(t):this.append(t)},u.before=function(t){var e=this.node,n=e.parentNode;if(n){h.isArray(t)||(t=[t]);for(var i=0,r=t.length;i<r;i++)n.insertBefore(h.toNode(t[i]),e)}return this},u.appendTo=function(t){return h.toNode(t).appendChild(this.node),this},u.svg=function(){return this.node instanceof window.SVGSVGElement?this:h(this.node.ownerSVGElement)},u.tagName=function(){return this.node.tagName.toUpperCase()},u.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?h(e):h("defs").appendTo(t)},u.clone=function(){var t=h(this.node.cloneNode(!0));return t.node.id=h.uniqueId(),t},u.findOne=function(t){var e=this.node.querySelector(t);return e?h(e):void 0},u.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(h(n[i]));return e},u.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++)1===t[n].nodeType&&e.push(h(t[n]));return e},u.parent=function(){return h(this.node.parentNode)||null},u.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},u.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=h(i);if(r.hasClass(t))return r;i=i.parentNode}return null},u.contains=function(t){var e=this.node,n=h.toNode(t),i=n&&n.parentNode;return e===i||!!(i&&1===i.nodeType&&16&e.compareDocumentPosition(i))},u.toLocalPoint=function(t,e){var n=this.svg().node,i=n.createSVGPoint();i.x=t,i.y=e;try{var r=i.matrixTransform(n.getScreenCTM().inverse()),o=this.getTransformToElement(n).inverse()}catch(t){return i}return r.matrixTransform(o)},u.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},u.translateAndAutoOrient=function(t,e,n){t=new Jt(t),e=new Jt(e),n||(n=this.svg());var i=this.scale();this.attr("transform","");var r=this.getBBox({target:n}).scale(i.sx,i.sy),o=h.createSVGTransform();o.setTranslate(-r.x-r.width/2,-r.y-r.height/2);var s=h.createSVGTransform(),a=t.angleBetween(e,t.clone().offset(1,0));a&&s.setRotate(a,0,0);var l=h.createSVGTransform(),c=t.clone().move(e,r.width/2);l.setTranslate(2*t.x-c.x,2*t.y-c.y);var u=this.getTransformToElement(n),d=h.createSVGTransform();return d.setMatrix(l.matrix.multiply(s.matrix.multiply(o.matrix.multiply(u.scale(i.sx,i.sy))))),this.attr("transform",h.matrixToTransformString(d.matrix)),this},u.animateAlongPath=function(t,e){e=h.toNode(e);var n=h.ensureId(e),i=h("animateMotion",t),r=h("mpath",{"xlink:href":"#"+n});i.append(r),this.append(i);try{i.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling")){var o=i.node;o.animators=[];var s=o.getAttribute("id");s&&(id2anim[s]=o);for(var a=getTargets(o),l=0,c=a.length;l<c;l++){var u=a[l],d=new Animator(o,u,l);animators.push(d),o.animators[l]=d,d.register()}}}return this};const g=/[^\x20\t\r\n\f]+/g;function m(t){return h.isString(t)&&t.trim().match(g)||[]}u.hasClass=function(t){return!!h.isString(t)&&this.node.classList.contains(t.trim())},u.addClass=function(t){return this.node.classList.add(...m(t)),this},u.removeClass=function(t){return this.node.classList.remove(...m(t)),this},u.toggleClass=function(t,e){const n=m(t);for(let t=0;t<n.length;t++)this.node.classList.toggle(n[t],e);return this},u.sample=function(t){t=t||1;for(var e,n=this.node,i=n.getTotalLength(),r=[],o=0;o<i;)e=n.getPointAtLength(o),r.push({x:e.x,y:e.y,distance:o}),o+=t;return r},u.convertToPath=function(){var t=h("path");t.attr(this.attr());var e=this.convertToPathData();return e&&t.attr("d",e),t},u.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return h.convertLineToPathData(this.node);case"POLYGON":return h.convertPolygonToPathData(this.node);case"POLYLINE":return h.convertPolylineToPathData(this.node);case"ELLIPSE":return h.convertEllipseToPathData(this.node);case"CIRCLE":return h.convertCircleToPathData(this.node);case"RECT":return h.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},h.prototype.toGeometryShape=function(){var t,e,n,i,r,o,s,a,l,c,u,d,f,p,g;switch(this.tagName()){case"RECT":return t=parseFloat(this.attr("x"))||0,e=parseFloat(this.attr("y"))||0,n=parseFloat(this.attr("width"))||0,i=parseFloat(this.attr("height"))||0,new me(t,e,n,i);case"CIRCLE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("r"))||0,new ae({x:r,y:o},s,s);case"ELLIPSE":return r=parseFloat(this.attr("cx"))||0,o=parseFloat(this.attr("cy"))||0,a=parseFloat(this.attr("rx"))||0,l=parseFloat(this.attr("ry"))||0,new ae({x:r,y:o},a,l);case"POLYLINE":return c=h.getPointsFromSvgNode(this),new xe(c);case"POLYGON":return(c=h.getPointsFromSvgNode(this)).length>1&&c.push(c[0]),new xe(c);case"PATH":return u=this.attr("d"),Le.isDataSupported(u)||(u=h.normalizePathData(u)),new Le(u);case"LINE":return d=parseFloat(this.attr("x1"))||0,p=parseFloat(this.attr("y1"))||0,f=parseFloat(this.attr("x2"))||0,g=parseFloat(this.attr("y2"))||0,new ne({x:d,y:p},{x:f,y:g})}return this.getBBox()},u.findIntersection=function(t,e){var n=this.svg().node;e=e||n;var i=this.getBBox({target:e}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){var o,s=this.tagName();if("RECT"===s){var a=new me(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),l=this.getTransformToElement(e),c=h.decomposeMatrix(l),u=n.createSVGTransform();u.setRotate(-c.rotation,r.x,r.y);var d=h.transformRect(a,u.matrix.multiply(l));o=new me(d).intersectionWithLineFromCenterToPoint(t,c.rotation)}else if("PATH"===s||"POLYGON"===s||"POLYLINE"===s||"CIRCLE"===s||"ELLIPSE"===s){var f,p,g,m,v,y=("PATH"===s?this:this.convertToPath()).sample(),b=1/0,w=[];for(f=0;f<y.length;f++)p=y[f],g=(g=h.createSVGPoint(p.x,p.y)).matrixTransform(this.getTransformToElement(e)),(v=(p=new Jt(g)).distance(r)+(m=1.1*p.distance(t)))<b?(b=v,w=[{sample:p,refDistance:m}]):v<b+1&&w.push({sample:p,refDistance:m});w.sort((function(t,e){return t.refDistance-e.refDistance})),w[0]&&(o=w[0].sample)}return o}},u.setAttribute=function(t,e){const n=this.node;if(null===e)return this.removeAttr(t),this;const i=y[t],{ns:r}=h.qualifyAttr(i);return r?n.setAttributeNS(r,i,e):"id"===i?n.id=e:n.setAttribute(i,e),this},h.createSvgDocument=function(e){if(e){const n=`<svg xmlns="${t.svg}" xmlns:xlink="${t.xlink}" version="1.1">${e}</svg>`,{documentElement:i}=h.parseXML(n,{async:!1});return i}const n=document.createElementNS(t.svg,"svg");return n.setAttributeNS(t.xmlns,"xmlns:xlink",t.xlink),n.setAttribute("version","1.1"),n},h.createSVGStyle=function(t){const{node:e}=h("style",{type:"text/css"},[h.createCDATASection(t)]);return e},h.createCDATASection=function(t=""){return document.implementation.createDocument(null,"xml",null).createCDATASection(t)},h.idCounter=0,h.uniqueId=function(){return"v-"+ ++h.idCounter},h.toNode=function(t){return h.isV(t)?t.node:t.nodeName&&t||t[0]},h.ensureId=function(t){return(t=h.toNode(t)).id||(t.id=h.uniqueId())},h.sanitizeText=function(t){return(t||"").replace(/ /g," ")},h.isUndefined=function(t){return void 0===t},h.isString=function(t){return"string"==typeof t},h.isObject=function(t){return t&&"object"==typeof t},h.isArray=Array.isArray,h.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;h.isUndefined(e.async)||(i.async=e.async),n=i.parseFromString(t,"text/xml")}catch(t){n=void 0}if(!n||n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+t);return n};const v=Object.create(null);["baseFrequency","baseProfile","clipPathUnits","contentScriptType","contentStyleType","diffuseConstant","edgeMode","externalResourcesRequired","filterRes","filterUnits","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].forEach((t=>v[t]=t)),v.xlinkShow="xlink:show",v.xlinkRole="xlink:role",v.xlinkActuate="xlink:actuate",v.xlinkHref="xlink:href",v.xlinkType="xlink:type",v.xlinkTitle="xlink:title",v.xmlBase="xml:base",v.xmlLang="xml:lang",v.xmlSpace="xml:space";const y=new Proxy(v,{get:(t,e)=>h.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e});Object.defineProperty(h,"attributeNames",{enumerable:!0,value:y,writable:!1}),Object.defineProperty(h,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),h.qualifyAttr=function(e){if(-1!==e.indexOf(":")){var n=e.split(":");return{ns:t[n[0]],local:n[1]}}return{ns:null,local:e}},h.transformSeparatorRegex=/[ ,]+/,h.transformRegex=/\b\w+\([^()]+\)/g,h.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,h.transformTranslateRegex=/\btranslate\(([^()]+)\)/,h.transformRotateRegex=/\brotate\(([^()]+)\)/,h.transformScaleRegex=/\bscale\(([^()]+)\)/,h.transformStringToMatrix=function(t){let e=h.createSVGMatrix();const n=t&&t.match(h.transformRegex);if(!n)return e;const i=n.length;for(let t=0;t<i;t++){const i=n[t].match(h.transformFunctionRegex);if(i){let t,n,r,o,s,a=h.createSVGMatrix();const l=i[1].toLowerCase(),c=i[2].split(h.transformSeparatorRegex);switch(l){case"scale":t=parseFloat(c[0]),n=void 0===c[1]?t:parseFloat(c[1]),a=a.scaleNonUniform(t,n);break;case"translate":r=parseFloat(c[0]),o=parseFloat(c[1]),a=a.translate(r,o);break;case"rotate":s=parseFloat(c[0]),r=parseFloat(c[1])||0,o=parseFloat(c[2])||0,a=0!==r||0!==o?a.translate(r,o).rotate(s).translate(-r,-o):a.rotate(s);break;case"skewx":s=parseFloat(c[0]),a=a.skewX(s);break;case"skewy":s=parseFloat(c[0]),a=a.skewY(s);break;case"matrix":a.a=parseFloat(c[0]),a.b=parseFloat(c[1]),a.c=parseFloat(c[2]),a.d=parseFloat(c[3]),a.e=parseFloat(c[4]),a.f=parseFloat(c[5]);break;default:continue}e=e.multiply(a)}}return e},h.matrixToTransformString=function(t){return t||(t=!0),"matrix("+(void 0!==t.a?t.a:1)+","+(void 0!==t.b?t.b:0)+","+(void 0!==t.c?t.c:0)+","+(void 0!==t.d?t.d:1)+","+(void 0!==t.e?t.e:0)+","+(void 0!==t.f?t.f:0)+")"},h.parseTransformString=function(t){var e,n,i;if(t){var r=h.transformSeparatorRegex;if(t.trim().indexOf("matrix")>=0){var o=h.transformStringToMatrix(t),s=h.decomposeMatrix(o);e=[s.translateX,s.translateY],i=[s.scaleX,s.scaleY],n=[s.rotation];var a=[];0===e[0]&&0===e[1]||a.push("translate("+e+")"),1===i[0]&&1===i[1]||a.push("scale("+i+")"),0!==n[0]&&a.push("rotate("+n+")"),t=a.join(" ")}else{const o=t.match(h.transformTranslateRegex);o&&(e=o[1].split(r));const s=t.match(h.transformRotateRegex);s&&(n=s[1].split(r));const a=t.match(h.transformScaleRegex);a&&(i=a[1].split(r))}}var l=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:e&&e[0]?parseInt(e[0],10):0,ty:e&&e[1]?parseInt(e[1],10):0},rotate:{angle:n&&n[0]?parseInt(n[0],10):0,cx:n&&n[1]?parseInt(n[1],10):void 0,cy:n&&n[2]?parseInt(n[2],10):void 0},scale:{sx:l,sy:i&&i[1]?parseFloat(i[1]):l}}},h.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c+0,y:e.x*t.b+e.y*t.d+0}},h.decomposeMatrix=function(t){var e=h.deltaTransformPoint(t,{x:0,y:1}),n=h.deltaTransformPoint(t,{x:1,y:0}),s=180/i*r(e.y,e.x)-90,a=180/i*r(n.y,n.x);return{translateX:t.e,translateY:t.f,scaleX:o(t.a*t.a+t.b*t.b),scaleY:o(t.c*t.c+t.d*t.d),skewX:s,skewY:a,rotation:s}},h.matrixToScale=function(t){var e,n,i,r;return t?(e=h.isUndefined(t.a)?1:t.a,r=h.isUndefined(t.d)?1:t.d,n=t.b,i=t.c):e=r=1,{sx:n?o(e*e+n*n):e,sy:i?o(i*i+r*r):r}},h.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=h.deltaTransformPoint(t,e)),{angle:Ct(Ot(r(e.y,e.x))-90)}},h.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},h.isV=function(t){return t instanceof h},h.isVElement=h.isV,h.isSVGGraphicsElement=function(t){return!!t&&(t=h.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM};var b=h("svg").node;return h.createSVGMatrix=function(t){var e=b.createSVGMatrix();for(var n in t)e[n]=t[n];return e},h.createSVGTransform=function(t){return h.isUndefined(t)?b.createSVGTransform():(t instanceof SVGMatrix||(t=h.createSVGMatrix(t)),b.createSVGTransformFromMatrix(t))},h.createSVGPoint=function(t,e){var n=b.createSVGPoint();return n.x=t,n.y=e,n},h.transformRect=function(t,e){var n=b.createSVGPoint();n.x=t.x,n.y=t.y;var i=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y;var r=n.matrixTransform(e);n.x=t.x+t.width,n.y=t.y+t.height;var o=n.matrixTransform(e);n.x=t.x,n.y=t.y+t.height;var l=n.matrixTransform(e),c=s(i.x,r.x,o.x,l.x),h=a(i.x,r.x,o.x,l.x),u=s(i.y,r.y,o.y,l.y),d=a(i.y,r.y,o.y,l.y);return new me(c,u,h-c,d-u)},h.transformPoint=function(t,e){return new Jt(h.createSVGPoint(t.x,t.y).matrixTransform(e))},h.transformLine=function(t,e){return new ne(h.transformPoint(t.start,e),h.transformPoint(t.end,e))},h.transformPolyline=function(t,e){var n=t instanceof xe?t.points:t;h.isArray(n)||(n=[]);for(var i=[],r=0,o=n.length;r<o;r++)i[r]=h.transformPoint(n[r],e);return new xe(i)},h.styleToObject=function(t){for(var e={},n=t.split(";"),i=0;i<n.length;i++){var r=n[i].split("=");e[r[0].trim()]=r[1].trim()}return e},h.createSlicePathData=function(t,e,n,r){var o=2*i-1e-6,s=t,a=e,h=n,u=r,d=(u<h&&(d=h,h=u,u=d),u-h),f=d<i?"0":"1",p=l(h),g=c(h),m=l(u),v=c(u);return d>=o?s?"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"M0,"+s+"A"+s+","+s+" 0 1,0 0,"+-s+"A"+s+","+s+" 0 1,0 0,"+s+"Z":"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"Z":s?"M"+a*p+","+a*g+"A"+a+","+a+" 0 "+f+",1 "+a*m+","+a*v+"L"+s*m+","+s*v+"A"+s+","+s+" 0 "+f+",0 "+s*p+","+s*g+"Z":"M"+a*p+","+a*g+"A"+a+","+a+" 0 "+f+",1 "+a*m+","+a*v+"L0,0Z"},h.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?h.isObject(t[n])&&h.isObject(e[n])?t[n]=h.mergeAttrs(t[n],e[n]):h.isObject(t[n])?t[n]=h.mergeAttrs(t[n],h.styleToObject(e[n])):h.isObject(e[n])?t[n]=h.mergeAttrs(h.styleToObject(t[n]),e[n]):t[n]=h.mergeAttrs(h.styleToObject(t[n]),h.styleToObject(e[n])):t[n]=e[n];return t},h.annotateString=function(t,e,n){e=e||[];for(var i,r,o,s=(n=n||{}).offset||0,a=[],l=[],c=0;c<t.length;c++){r=l[c]=t[c];for(var u=0;u<e.length;u++){var d=e[u],f=d.start+s,p=d.end+s;c>=f&&c<p&&(h.isObject(r)?r.attrs=h.mergeAttrs(h.mergeAttrs({},r.attrs),d.attrs):r=l[c]={t:t[c],attrs:d.attrs},n.includeAnnotationIndices&&(r.annotations||(r.annotations=[])).push(u))}(o=l[c-1])?h.isObject(r)&&h.isObject(o)?JSON.stringify(r.attrs)===JSON.stringify(o.attrs)?i.t+=r.t:(a.push(i),i=r):h.isObject(r)||h.isObject(o)?(a.push(i),i=r):i=(i||"")+r:i=r}return i&&a.push(i),a},h.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach((function(t){t.start<e&&e<=t.end&&n.push(t)})),n},h.findAnnotationsBetweenIndexes=function(t,e,n){var i=[];return t&&t.forEach((function(t){(e>=t.start&&e<t.end||n>t.start&&n<=t.end||t.start>=e&&t.end<n)&&i.push(t)})),i},h.shiftAnnotations=function(t,e,n){return t&&t.forEach((function(t){t.start<e&&t.end>=e?t.end+=n:t.start>=e&&(t.start+=n,t.end+=n)})),t},h.convertLineToPathData=function(t){return["M",(t=h(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},h.convertPolygonToPathData=function(t){var e=h.getPointsFromSvgNode(t);return 0===e.length?null:h.svgPointsToPath(e)+" Z"},h.convertPolylineToPathData=function(t){var e=h.getPointsFromSvgNode(t);return 0===e.length?null:h.svgPointsToPath(e)},h.svgPointsToPath=function(t){for(var e=0,n=t.length;e<n;e++)t[e]=t[e].x+" "+t[e].y;return"M "+t.join(" L")},h.getPointsFromSvgNode=function(t){var e=[],n=(t=h.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},h.KAPPA=.551784,h.convertCircleToPathData=function(t){t=h(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("r")),r=i*h.KAPPA;return["M",e,n-i,"C",e+r,n-i,e+i,n-r,e+i,n,"C",e+i,n+r,e+r,n+i,e,n+i,"C",e-r,n+i,e-i,n+r,e-i,n,"C",e-i,n-r,e-r,n-i,e,n-i,"Z"].join(" ")},h.convertEllipseToPathData=function(t){t=h(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),r=parseFloat(t.attr("ry"))||i,o=i*h.KAPPA,s=r*h.KAPPA;return["M",e,n-r,"C",e+o,n-r,e+i,n-s,e+i,n,"C",e+i,n+s,e+o,n+r,e,n+r,"C",e-o,n+r,e-i,n+s,e-i,n,"C",e-i,n-s,e-o,n-r,e,n-r,"Z"].join(" ")},h.convertRectToPathData=function(t){return t=h(t),h.rectToPath({x:parseFloat(t.attr("x"))||0,y:parseFloat(t.attr("y"))||0,width:parseFloat(t.attr("width"))||0,height:parseFloat(t.attr("height"))||0,rx:parseFloat(t.attr("rx"))||0,ry:parseFloat(t.attr("ry"))||0})},h.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=s(t.rx||t["top-rx"]||0,i/2),a=s(t.rx||t["bottom-rx"]||0,i/2),l=s(t.ry||t["top-ry"]||0,r/2),c=s(t.ry||t["bottom-ry"]||0,r/2);return(o||a||l||c?["M",e,n+l,"v",r-l-c,"a",a,c,0,0,0,a,c,"h",i-2*a,"a",a,c,0,0,0,a,-c,"v",-(r-c-l),"a",o,l,0,0,0,-o,-l,"h",-(i-2*o),"a",o,l,0,0,0,-o,l,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"]).join(" ")},h.normalizePathData=function(){var t="\t\n\v\f\r \u2028\u2029",e=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),n=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),i=Math,r=i.PI,o=i.sin,s=i.cos,a=i.tan,l=i.asin,c=i.sqrt,h=i.abs;function u(t,e,n,i,r,o){var s=1/3,a=2/3;return[s*t+a*n,s*e+a*i,s*r+a*n,s*o+a*i,r,o]}function d(t,e,n){return{x:t*s(n)-e*o(n),y:t*o(n)+e*s(n)}}function f(t,e,n,i,u,p,g,m,v,y){var b,w=120*r/180,x=r/180*(+u||0),A=[];if(y)M=y[0],O=y[1],L=y[2],C=y[3];else{t=(b=d(t,e,-x)).x,e=b.y;var T=(t-(m=(b=d(m,v,-x)).x))/2,E=(e-(v=b.y))/2,P=T*T/(n*n)+E*E/(i*i);P>1&&(n*=P=c(P),i*=P);var S=n*n,_=i*i,k=(p==g?-1:1)*c(h((S*_-S*E*E-_*T*T)/(S*E*E+_*T*T)));if(!Number.isFinite(k))return[t,e,m,v,m,v];var L=k*n*E/i+(t+m)/2,C=k*-i*T/n+(e+v)/2,M=l(((e-C)/i).toFixed(9)),O=l(((v-C)/i).toFixed(9));(M=t<L?r-M:M)<0&&(M=2*r+M),(O=m<L?r-O:O)<0&&(O=2*r+O),g&&M>O&&(M-=2*r),!g&&O>M&&(O-=2*r)}var N=O-M;if(h(N)>w){var R=O,F=m,B=v;A=f(m=L+n*s(O=M+w*(g&&O>M?1:-1)),v=C+i*o(O),n,i,u,0,g,F,B,[O,R,L,C])}N=O-M;var I=s(M),D=o(M),V=s(O),z=o(O),j=a(N/4),$=4/3*(n*j),U=4/3*(i*j),G=[t,e],q=[t+$*D,e-U*I],H=[m+$*z,v-U*V],W=[m,v];if(q[0]=2*G[0]-q[0],q[1]=2*G[1]-q[1],y)return[q,H,W].concat(A);for(var Y=[],X=(A=[q,H,W].concat(A).join().split(",")).length,Z=0;Z<X;Z++)Y[Z]=Z%2?d(A[Z-1],A[Z],x).y:d(A[Z],A[Z+1],x).x;return Y}function p(t){var i=function(t){if(Array.isArray(t)&&Array.isArray(t&&t[0])||(t=function(t){if(!t)return null;var i={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=[];return String(t).replace(e,(function(t,e,o){var s=[],a=e.toLowerCase();for(o.replace(n,(function(t,e){e&&s.push(+e)})),"m"===a&&s.length>2&&(r.push([e].concat(s.splice(0,2))),a="l",e="m"===e?"l":"L");s.length>=i[a]&&(r.push([e].concat(s.splice(0,i[a]))),i[a]););})),r}(t)),!t||!t.length)return[["M",0,0]];for(var i,r=[],o=0,s=0,a=0,l=0,c=t.length,h=0;h<c;h++){var u=[];r.push(u);var d,f,p=t[h];if((i=p[0])!=i.toUpperCase())switch(u[0]=i.toUpperCase(),u[0]){case"A":u[1]=p[1],u[2]=p[2],u[3]=p[3],u[4]=p[4],u[5]=p[5],u[6]=+p[6]+o,u[7]=+p[7]+s;break;case"V":u[1]=+p[1]+s;break;case"H":u[1]=+p[1]+o;break;case"M":for(a=+p[1]+o,l=+p[2]+s,d=p.length,f=1;f<d;f++)u[f]=+p[f]+(f%2?o:s);break;default:for(d=p.length,f=1;f<d;f++)u[f]=+p[f]+(f%2?o:s)}else for(var g=p.length,m=0;m<g;m++)u[m]=p[m];switch(u[0]){case"Z":o=+a,s=+l;break;case"H":o=u[1];break;case"V":s=u[1];break;case"M":a=u[u.length-2],l=u[u.length-1],o=u[u.length-2],s=u[u.length-1];break;default:o=u[u.length-2],s=u[u.length-1]}}return r}(t),r={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function o(t,e,n){var i,r;if(!t)return["C",e.x,e.y,e.x,e.y,e.x,e.y];switch(t[0]in{T:1,Q:1}||(e.qx=null,e.qy=null),t[0]){case"M":e.X=t[1],e.Y=t[2];break;case"A":t=0===parseFloat(t[1])||0===parseFloat(t[2])?["L",t[6],t[7]]:["C"].concat(f.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":"C"===n||"S"===n?(i=2*e.x-e.bx,r=2*e.y-e.by):(i=e.x,r=e.y),t=["C",i,r].concat(t.slice(1));break;case"T":"Q"===n||"T"===n?(e.qx=2*e.x-e.qx,e.qy=2*e.y-e.qy):(e.qx=e.x,e.qy=e.y),t=["C"].concat(u(e.x,e.y,e.qx,e.qy,t[1],t[2]));break;case"Q":e.qx=t[1],e.qy=t[2],t=["C"].concat(u(e.x,e.y,t[1],t[2],t[3],t[4]));break;case"H":t=["L"].concat(t[1],e.y);break;case"V":t=["L"].concat(e.x,t[1])}return t}function s(t,e){if(t[e].length>7){t[e].shift();for(var n=t[e];n.length;)a[e]="A",t.splice(e++,0,["C"].concat(n.splice(0,6)));t.splice(e,1),h=i.length}}for(var a=[],l="",c="",h=i.length,d=0;d<h;d++){i[d]&&(l=i[d][0]),"C"!==l&&(a[d]=l,d>0&&(c=a[d-1])),i[d]=o(i[d],r,c),"A"!==a[d]&&"C"===l&&(a[d]="C"),s(i,d);var p=i[d],g=p.length;r.x=p[g-2],r.y=p[g-1],r.bx=parseFloat(p[g-4])||r.x,r.by=parseFloat(p[g-3])||r.y}return i[0][0]&&"M"===i[0][0]||i.unshift(["M",0,0]),i}return function(t){return p(t).join(",").split(",").join(" ")}}(),h.namespace=t,h.g=e,h}(),An=xn,Tn="[object Arguments]",En="[object Array]",Pn="[object Boolean]",Sn="[object Date]",_n="[object Error]",kn="[object Function]",Ln="[object Map]",Cn="[object Number]",Mn="[object Object]",On="[object RegExp]",Nn="[object Set]",Rn="[object String]",Fn="[object Symbol]",Bn="[object WeakMap]",In="[object ArrayBuffer]",Dn="[object DataView]",Vn="[object Float32Array]",zn="[object Float64Array]",jn="[object Int8Array]",$n="[object Int16Array]",Un="[object Int32Array]",Gn="[object Uint8Array]",qn="[object Uint8ClampedArray]",Hn="[object Uint16Array]",Wn="[object Uint32Array]",Yn={[Tn]:!0,[En]:!0,[In]:!0,[Dn]:!0,[Pn]:!0,[Sn]:!0,[Vn]:!0,[zn]:!0,[jn]:!0,[$n]:!0,[Un]:!0,[Ln]:!0,[Cn]:!0,[Mn]:!0,[On]:!0,[Nn]:!0,[Rn]:!0,[Fn]:!0,[Gn]:!0,[qn]:!0,[Hn]:!0,[Wn]:!0,[_n]:!1,[kn]:!1,[Bn]:!1},Xn="\\ud800-\\udfff",Zn="\\u2700-\\u27bf",Kn="a-z\\xdf-\\xf6\\xf8-\\xff",Jn="A-Z\\xc0-\\xd6\\xd8-\\xde",Qn="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ti="['’]",ei=`[${Qn}]`,ni="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",ii=`[${Zn}]`,ri=`[${Kn}]`,oi=`[^${Xn}${Qn+"\\d"+Zn+Kn+Jn}]`,si="\\ud83c[\\udffb-\\udfff]",ai=`[^${Xn}]`,li="(?:\\ud83c[\\udde6-\\uddff]){2}",ci="[\\ud800-\\udbff][\\udc00-\\udfff]",hi=`[${Jn}]`,ui=`(?:${ri}|${oi})`,di=`(?:${hi}|${oi})`,fi=`(?:${ti}(?:d|ll|m|re|s|t|ve))?`,pi=`(?:${ti}(?:D|LL|M|RE|S|T|VE))?`,gi=`(?:${ni}|${si})?`,mi="[\\ufe0e\\ufe0f]?",vi=mi+gi+`(?:\\u200d(?:${[ai,li,ci].join("|")})${mi+gi})*`,yi=`(?:${[ii,li,ci].join("|")})${vi}`,bi=RegExp([`${hi}?${ri}+${fi}(?=${[ei,hi,"$"].join("|")})`,`${di}+${pi}(?=${[ei,hi+ui,"$"].join("|")})`,`${hi}?${ui}+${fi}`,`${hi}+${pi}`,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",yi].join("|"),"g"),wi="__hash_undefined__",xi=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/,Ai=`(?:${[`${ai}${ni}?`,ni,li,ci,`[${Xn}]`].join("|")})`,Ti=RegExp(`${si}(?=${si})|${Ai+vi}`,"g"),Ei=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pi=/^\w*$/,Si=".".charCodeAt(0),_i=/\\(\\)?/g,ki=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),Li=/^(?:0|[1-9]\d*)$/,Ci=RegExp.prototype.test.bind(/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/),Mi=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Oi=t=>Ti.test(t),Ni=t=>Oi(t)?(t=>t.match(Ti)||[])(t):(t=>t.split(""))(t),Ri=t=>null==t?[]:Fi(t).map((e=>t[e])),Fi=t=>Gi(t)?Bi(t):Object.keys(Object(t)),Bi=(t,e)=>{const n=Array.isArray(t),i=!n&&Vi(t)&&Wi(t)===Tn,r=!n&&!i&&Ji(t),o=n||i||r,s=t.length,a=new Array(o?s:0);let l=o?-1:s;for(;++l<s;)a[l]=`${l}`;for(const n in t)!e&&!hasOwnProperty.call(t,n)||o&&("length"===n||Ar(n,s))||a.push(n);return a},Ii=(t,e)=>{let{length:n}=t;for(;n--;)if(Di(t[n][0],e))return n;return-1},Di=(t,e)=>t===e||t!=t&&e!=e,Vi=t=>null!=t&&"object"==typeof t,zi=(t,e,n)=>{if(!to(n))return!1;const i=typeof e;return!!("number"==i?Gi(n)&&e>-1&&e<n.length:"string"==i&&e in n)&&Di(n[e],t)},ji=t=>{const e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},$i=(t,e,n)=>{const i=t[e];hasOwnProperty.call(t,e)&&Di(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Ui=(t,e,n)=>{let i=-1;const r=e.length;for(;++i<r;){const r=e[i];$i(n,r,t[r])}return n},Gi=t=>null!=t&&"function"!=typeof t&&"number"==typeof t.length&&t.length>-1&&t.length%1==0,qi=t=>"symbol"==typeof t||Vi(t)&&Wi(t)===Fn,Hi=(t,e)=>{let n=-1;const i=t.length;for(e||(e=new Array(i));++n<i;)e[n]=t[n];return e},Wi=t=>null==t?void 0===t?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t),Yi=t=>{const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},Xi=(t,e)=>{const n=e?Yi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)},Zi=t=>"function"!=typeof t.constructor||ji(t)?{}:Object.create(Object.getPrototypeOf(t)),Ki=t=>null==t?[]:(t=Object(t),Object.getOwnPropertySymbols(t).filter((e=>propertyIsEnumerable.call(t,e)))),Ji=t=>Vi(t)&&xi.test(Wi(t)),Qi=t=>{const e=Object.keys(t);return Array.isArray(t)||null==t||e.push(...Ki(Object(t))),e},tr=t=>{const e=[];for(;t;)e.push(...Ki(t)),t=Object.getPrototypeOf(Object(t));return e},er=t=>{const e=[];for(const n in t)e.push(n);return Array.isArray(t)||e.push(...tr(t)),e},nr=({__data__:t},e)=>{const n=t;return Er(e)?n["string"==typeof e?"string":"hash"]:n.map},ir=(t,e,n)=>t===e||(null==t||null==e||!Vi(t)&&!Vi(e)?t!=t&&e!=e:rr(t,e,ir,n)),rr=(t,e,n,i)=>{let r=Array.isArray(t);const o=Array.isArray(e);let s=r?En:Wi(t),a=o?En:Wi(e);s=s==Tn?Mn:s,a=a==Tn?Mn:a;let l=s==Mn;const c=a==Mn,h=s==a;if(h&&!l)return i||(i=new Xr),r||Ji(t)?or(t,e,!1,n,i):cr(t,e,s,n,i);const u=l&&hasOwnProperty.call(t,"__wrapped__"),d=c&&hasOwnProperty.call(e,"__wrapped__");if(u||d){const r=u?t.value():t,o=d?e.value():e;return i||(i=new Xr),n(r,o,i)}return!!h&&(i||(i=new Xr),((t,e,n,i)=>{const r=Qi(t),o=r.length;if(o!=Qi(e).length)return!1;let s,a=o;for(;a--;)if(s=r[a],!hasOwnProperty.call(e,s))return!1;const l=i.get(t),c=i.get(e);if(l&&c)return l==e&&c==t;let h,u=!0;for(i.set(t,e),i.set(e,t);++a<o;){s=r[a];const o=t[s],l=e[s];if(o!==l&&!n(o,l,i)){u=!1;break}h||(h="constructor"==s)}if(u&&!h){const n=t.constructor,i=e.constructor;n==i||!("constructor"in t)||!("constructor"in e)||"function"==typeof n&&n instanceof n&&"function"==typeof i&&i instanceof i||(u=!1)}return i.delete(t),i.delete(e),u})(t,e,n,i))},or=(t,e,n,i,r)=>{const o=t.length;if(o!=e.length)return!1;const s=r.get(t),a=r.get(e);if(s&&a)return s==e&&a==t;let l=-1,c=!0;const h=n?new Qr:void 0;for(r.set(t,e),r.set(e,t);++l<o;){let n;const o=t[l],s=e[l];if(void 0!==n){if(n)continue;c=!1;break}if(h){if(!sr(e,((t,e)=>{if(!ar(h,e)&&(o===t||i(o,t,r)))return h.push(e)}))){c=!1;break}}else if(o!==s&&!i(o,s,r)){c=!1;break}}return r.delete(t),r.delete(e),c},sr=(t,e)=>{let n=-1;const i=null==t?0:t.length;for(;++n<i;)if(e(t[n],n,t))return!0;return!1},ar=(t,e)=>t.has(e),lr=(t,e,n,i)=>!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i)),cr=(t,e,n,i,r)=>{switch(n){case Dn:return t.byteLength==e.byteLength&&t.byteOffset==e.byteOffset&&(t=t.buffer,e=e.buffer,lr(t,e,i,r));case In:return lr(t,e,i,r);case Pn:case Sn:case Cn:return Di(+t,+e);case _n:return t.name==e.name&&t.message==e.message;case On:case Rn:return t==`${e}`;case Ln:let n=hr;case Nn:if(n||(n=ur),t.size!=e.size)return!1;const o=r.get(t);if(o)return o==e;r.set(t,e);const s=or(n(t),n(e),!0,i,r);return r.delete(t),s;case Fn:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},hr=t=>{let e=-1,n=Array(t.size);return t.forEach(((t,i)=>{n[++e]=[i,t]})),n},ur=t=>{let e=-1;const n=new Array(t.size);return t.forEach((t=>{n[++e]=t})),n},dr=(t,e)=>{if(Array.isArray(t))return!1;const n=typeof t;return!("number"!==n&&"boolean"!==n&&null!=t&&!qi(t))||Pi.test(t)||!Ei.test(t)||null!=e&&t in Object(e)},fr=(t,e)=>Array.isArray(t)?t:dr(t,e)?[t]:(t=>{const e=[];return t.charCodeAt(0)===Si&&e.push(""),t.replace(ki,((t,n,i,r)=>{let o=t;i?o=r.replace(_i,"$1"):n&&(o=n.trim()),e.push(o)})),e})(`${t}`),pr=(t,e)=>{let n=0;const i=(e=fr(e,t)).length;for(;null!=t&&n<i;)t=t[vr(e[n])],n++;return n&&n==i?t:void 0};function gr(t,e){if(t!==e){const n=void 0!==t,i=null===t,r=t==t,o=qi(t),s=void 0!==e,a=null===e,l=e==e,c=qi(e);if(!a&&!c&&!o&&t>e||o&&s&&l&&!a&&!c||i&&s&&l||!n&&l||!r)return 1;if(!i&&!o&&!c&&t<e||c&&n&&r&&!i&&!o||a&&n&&r||!s&&r||!l)return-1}return 0}const mr=(t,e)=>{let n=(t,e)=>!(null==t||!t.length)&&t.indexOf(e)>-1,i=!0;const r=[],o=e.length;if(!t.length)return r;e.length>=200&&(n=(t,e)=>t.has(e),i=!1,e=new Qr(e));t:for(let s in t){let a=t[s];const l=a;if(a=0!==a?a:0,i&&l==l){let t=o;for(;t--;)if(e[t]===l)continue t;r.push(a)}else n(e,l)||r.push(a)}return r},vr=t=>{if("string"==typeof t||qi(t))return t;const e=`${t}`;return"0"==e&&1/t==-1/0?"-0":e},yr=(t,e=!1,n=!1,i=!0,r,o,s,a)=>{let l;if(r&&(l=s?r(t,o,s,a):r(t)),void 0!==l)return l;if(!to(t))return t;const c=Array.isArray(t),h=Wi(t);if(c){if(l=(t=>{const e=t.length;let n=new t.constructor(e);return e&&"string"==typeof t[0]&&hasOwnProperty.call(t,"index")&&(n.index=t.index,n.input=t.input),n})(t),!e)return Hi(t,l)}else{const i="function"==typeof t;if(h===Mn||h===Tn||i&&!s){if(l=n||i?{}:Zi(t),!e)return n?br(t,Ui(t,Object.keys(t),l)):((t,e)=>Ui(t,Ki(t),e))(t,Object.assign(l,t))}else{if(i||!Yn[h])return s?t:{};l=((t,e,n)=>{const i=t.constructor;switch(e){case In:return Yi(t);case Pn:case Sn:return new i(+t);case Dn:return function(t,e){const n=e?Yi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}(t,n);case Vn:case zn:case jn:case $n:case Un:case Gn:case qn:case Hn:case Wn:return Xi(t,n);case Ln:case Cn:case Rn:return new i(t);case On:return(t=>{const e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e})(t);case Nn:return new i;case Fn:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}})(t,h,e)}}a||(a=new Xr);const u=a.get(t);if(u)return u;if(a.set(t,l),(t=>Vi(t)&&Wi(t)==Ln)(t))return t.forEach(((o,s)=>{l.set(s,yr(o,e,n,i,r,s,t,a))})),l;if((t=>Vi(t)&&Wi(t)==Nn)(t))return t.forEach((o=>{l.add(yr(o,e,n,i,r,o,t,a))})),l;if(Ji(t))return l;const d=c?void 0:(i?n?er:Qi:n?Pr:Fi)(t);return(d||t).forEach(((o,s)=>{d&&(o=t[s=o]),$i(l,s,yr(o,e,n,i,r,s,t,a))})),l},br=(t,e)=>Ui(t,tr(t),e),wr=(t,e)=>e.length<2?t:pr(t,e.slice(0,-1)),xr=(t,e,n)=>{if(!to(t))return t;const i=(e=fr(e,t)).length,r=i-1;let o=-1,s=t;for(;null!=s&&++o<i;){const t=vr(e[o]);let i=n;if(o!=r){const n=s[t];i=void 0,void 0===i&&(i=to(n)?n:Ar(e[o+1])?[]:{})}$i(s,t,i),s=s[t]}return t},Ar=(t,e)=>{const n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"===n||"symbol"!==n&&Li.test(t))&&t>-1&&t%1==0&&t<e},Tr=(t,e)=>{e=fr(e,t),t=wr(t,e);const n=e[e.length-1];return null==t||delete t[vr(n)]},Er=t=>{const e=typeof t;return"string"===e||"number"===e||"symbol"===e||"boolean"===e?"__proto__"!==t:null===t},Pr=t=>{const e=[];for(const n in t)e.push(n);return e},Sr=(t,e)=>{if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function _r(t,e=!1){return(n,...i)=>{let r=-1,o=i.length,s=o>1?i[o-1]:void 0;const a=o>2?i[2]:void 0;for(s=t.length>3&&"function"==typeof s?(o--,s):e?(t,e)=>{if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,a&&zi(i[0],i[1],a)&&(s=o<3?void 0:s,o=1),n=Object(n);++r<o;){const e=i[r];e&&t(n,e,r,s)}return n}}const kr=(t,e,n,i,r)=>{t!==e&&_o(e,((o,s)=>{if(to(o))r||(r=new Xr),Lr(t,e,s,n,kr,i,r);else{let n=i?i(t[s],o,`${s}`,t,e,r):void 0;void 0===n&&(n=o),Cr(t,s,n)}}),Pr)},Lr=(t,e,n,i,r,o,s)=>{const a=Sr(t,n),l=Sr(e,n),c=s.get(l);if(c)return void Cr(t,n,c);let h=o?o(a,l,`${n}`,t,e,s):void 0,u=void 0===h;if(u){const t=Array.isArray(l),e=!t&&Ji(l);h=l,t||e?Array.isArray(a)?h=a:Vi(a)&&Gi(a)?h=Hi(a):e?(u=!1,h=Xi(l,!0)):h=[]:mo(l)||qr(l)?(h=a,qr(a)?h=(t=>{t=Object(t);const e={};for(const n in t)e[n]=t[n];return e})(a):"function"!=typeof a&&to(a)||(h=Zi(l))):u=!1}u&&(s.set(l,h),r(h,l,i,o,s),s.delete(l)),Cr(t,n,h)},Cr=(t,e,n)=>{(void 0!==n&&!Di(t[e],n)||void 0===n&&!(e in t))&&$i(t,e,n)},Mr=(t,e)=>{if(null==t)return t;if(!Gi(t))return((t,e)=>t&&function(t,e,n){const i=Object(t),r=n(t);let{length:o}=r,s=-1;for(;o--;){const t=r[++s];if(!1===e(i[t],t,i))break}return t}(t,e,Fi))(t,e);const n=t.length,i=Object(t);let r=-1;for(;++r<n&&!1!==e(i[r],r,i););return t},Or=Set&&1/ur(new Set([void 0,-0]))[1]==1/0?t=>new Set(t):()=>{};function Nr(t,e,n,i,r,o){return to(t)&&to(e)&&(o.set(e,t),kr(t,e,void 0,Nr,o),o.delete(e)),t}function Rr(t,e,n){e=e.length?e.map((t=>Array.isArray(t)?e=>pr(e,1===t.length?t[0]:t):t)):[t=>t];let i=-1,r=-1;const o=Gi(t)?new Array(t.length):[];return Mr(t,(t=>{const n=e.map((e=>e(t)));o[++r]={criteria:n,index:++i,value:t}})),function(t,e){let{length:i}=t;for(t.sort(((t,e)=>function(t,e,n){let i=-1;const r=t.criteria,o=e.criteria,s=r.length,a=n.length;for(;++i<s;){const t=i<a?n[i]:null,e=(t&&"function"==typeof t?t:gr)(r[i],o[i]);if(e)return t&&"function"!=typeof t?e*("desc"==t?-1:1):e}return t.index-e.index}(t,e,n)));i--;)t[i]=t[i].value;return t}(o)}function Fr(t){return t==t&&!to(t)}function Br(t,e){return n=>null!=n&&n[t]===e&&(void 0!==e||t in Object(n))}function Ir(t,e){return null!=t&&Wr(t,e,Hr)}function Dr(t){const e=function(t){const e=Fi(t);let n=e.length;for(;n--;){const i=e[n],r=t[i];e[n]=[i,r,Fr(r)]}return e}(t);return 1===e.length&&e[0][2]?Br(e[0][0],e[0][1]):n=>n===t||function(t,e,n,i){let r=n.length;const o=r;if(null==t)return!o;let s,a;for(t=Object(t);r--;)if(s=n[r],s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1;for(;++r<o;){s=n[r];const e=s[0],i=t[e],o=s[1];if(s[2]){if(void 0===i&&!(e in t))return!1}else{const t=new Xr;if(!(void 0===a?ir(o,i,t):a))return!1}}return!0}(n,0,e)}function Vr(t){return"function"==typeof t?t:null==t?t=>t:"object"==typeof t?Array.isArray(t)?(e=t[0],n=t[1],dr(e)&&Fr(n)?Br(vr(e),n):t=>{const i=pr(t,e);return void 0===i&&i===n?Ir(t,e):ir(n,i)}):Dr(t):function(t){return dr(t)?(e=vr(t),t=>null==t?void 0:t[e]):function(t){return e=>pr(e,t)}(t);var e}(t);var e,n}function zr(){const t=Vr;return arguments.length?t(arguments[0],arguments[1]):t}const jr=(t,e,n,i)=>{let r=-1;const o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},$r=(t,e,n,i,r)=>(r(t,((t,r,o)=>{n=i?(i=!1,t):e(n,t,r,o)})),n),Ur=t=>Array.isArray(t)||qr(t)||!(!t||!t[Symbol.isConcatSpreadable]);function Gr(t,e,n,i,r){let o=-1;const s=t.length;for(n||(n=Ur),r||(r=[]);++o<s;){var a=t[o];e>0&&n(a)?e>1?Gr(a,e-1,n,i,r):r.push(...a):i||(r[r.length]=a)}return r}const qr=t=>Vi(t)&&"[object Arguments]"==Wi(t),Hr=(t,e)=>null!=t&&e in Object(t),Wr=(t,e,n)=>{for(var i,r=-1,o=(e=fr(e,t)).length,s=!1;++r<o;){var a=vr(e[r]);if(!(s=null!=t&&n(t,a)))break;t=t[a]}return s||++r!=o?s:!!(o=null==t?0:t.length)&&"number"==typeof(i=o)&&i>-1&&i%1==0&&i<=Number.MAX_SAFE_INTEGER&&Ar(a,o)&&(Array.isArray(t)||qr(t))},Yr=("toUpperCase",t=>{if(!t)return"";const e=Oi(t)?Ni(t):void 0,n=e?e[0]:t[0],i=e?((t,e,n)=>{const{length:i}=t;return n=void 0===n?i:n,t.slice(1,n)})(e).join(""):t.slice(1);return n.toUpperCase()+i});class Xr{constructor(t){const e=this.__data__=new Zr(t);this.size=e.size}clear(){this.__data__=new Zr,this.size=0}delete(t){const e=this.__data__,n=e.delete(t);return this.size=e.size,n}get(t){return this.__data__.get(t)}has(t){return this.__data__.has(t)}set(t,e){let n=this.__data__;if(n instanceof Zr){const i=n.__data__;if(i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Kr(i)}return n.set(t,e),this.size=n.size,this}}class Zr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.__data__=[],this.size=0}delete(t){const e=this.__data__,n=Ii(e,t);return!(n<0)&&(n==e.length-1?e.pop():e.splice(n,1),--this.size,!0)}get(t){const e=this.__data__,n=Ii(e,t);return n<0?void 0:e[n][1]}has(t){return Ii(this.__data__,t)>-1}set(t,e){const n=this.__data__,i=Ii(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}}class Kr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.size=0,this.__data__={hash:new Jr,map:new Map,string:new Jr}}delete(t){const e=nr(this,t).delete(t);return this.size-=e?1:0,e}get(t){return nr(this,t).get(t)}has(t){return nr(this,t).has(t)}set(t,e){const n=nr(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}}class Jr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.clear();++e<n;){const n=t[e];this.set(n[0],n[1])}}clear(){this.__data__=Object.create(null),this.size=0}delete(t){const e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}get(t){const e=this.__data__[t];return e===wi?void 0:e}has(t){return void 0!==this.__data__[t]}set(t,e){const n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?wi:e,this}}class Qr{constructor(t){let e=-1;const n=null==t?0:t.length;for(this.__data__=new Kr;++e<n;)this.add(t[e])}add(t){return this.__data__.set(t,wi),this}has(t){return this.__data__.has(t)}}Qr.prototype.push=Qr.prototype.add;const to=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},eo=function(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Cn},no=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Rn},io=_r(((t,e)=>{if(ji(e)||Gi(e))Ui(e,Fi(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&$i(t,n,e[n])})),ro=(t,...e)=>{let n=-1,i=e.length;const r=i>2?e[2]:void 0;for(r&&zi(e[0],e[1],r)&&(i=1);++n<i;){const i=e[n];if(null==i)continue;const r=Object.keys(i),o=r.length;let s=-1;for(;++s<o;){const e=r[s],n=t[e];(void 0===n||Di(n,Object.prototype[e])&&!hasOwnProperty.call(t,e))&&(t[e]=i[e])}}return t},oo=function(...t){return t.push(void 0,Nr),Mo.apply(void 0,t)},so=(t,e,...n)=>{let i=-1;const r="function"==typeof e,o=Gi(t)?new Array(t.length):[];return Mr(t,(t=>{o[++i]=r?e.apply(t,n):ao(t,e,...n)})),o},ao=(t,e,...n)=>{e=fr(e,t);const i=null==(t=wr(t,e))?t:t[vr(function(t){const e=null==t?0:t.length;return e?t[e-1]:void 0}(e))];return null==i?void 0:i.apply(t,n)},lo=(t,e,n)=>{let i=0,r=null==t?0:t.length;if(0==r)return 0;const o=(e=(n=zr(n,2))(e))!=e,s=null===e,a=qi(e),l=void 0===e;for(;i<r;){let c;const h=Math.floor((i+r)/2),u=n(t[h]),d=void 0!==u,f=null===u,p=u==u,g=qi(u);c=o?p:l?p&&d:s?p&&d&&!f:a?p&&d&&!f&&!g:!f&&!g&&u<e,c?i=h+1:r=h}return Math.min(r,4294967294)},co=(t,e)=>{let n=-1,i=(t,e)=>!(null==t||!t.length)&&t.indexOf(e)>-1;e=zr(e,2);let r=!0;const{length:o}=t,s=[];let a=s;if(o>=200){const n=e?null:Or(t);if(n)return ur(n);r=!1,i=(t,e)=>t.has(e),a=new Qr}else a=e?[]:s;t:for(;++n<o;){let o=t[n];const l=e?e(o):o;if(o=0!==o?o:0,r&&l==l){let t=a.length;for(;t--;)if(a[t]===l)continue t;e&&a.push(l),s.push(o)}else i(a,l)||(a!==s&&a.push(l),s.push(o))}return s},ho=t=>yr(t),uo=t=>yr(t,!0),fo=t=>{if(null==t)return!0;if(Gi(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||Ji(t)||qr(t)))return!t.length;const e=Wi(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(ji(t))return!(t=>{if(!ji(t))return Object.keys(t);var e=[];for(var n in Object(t))hasOwnProperty.call(t,n)&&"constructor"!=n&&e.push(n);return e})(t).length;for(const e in t)if(hasOwnProperty.call(t,e))return!1;return!0},po=(t,e)=>ir(t,e),go=t=>"function"==typeof t,mo=t=>{if(!Vi(t)||"[object Object]"!=Wi(t))return!1;if(null===Object.getPrototypeOf(t))return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e},vo=t=>{if(!t)return[];if(Gi(t))return no(t)?Ni(t):Hi(t);if(Symbol.iterator&&Symbol.iterator in Object(t)){const e=t[Symbol.iterator]();let n;const i=[];for(;!(n=e.next()).done;)i.push(n.value);return i}const e=Wi(t);return(e==Ln?hr:e==Nn?ur:Ri)(t)},yo=(t,e=[])=>{if(null==t)return[];const n=e.length;return n>1&&zi(t,e[0],e[1])?e=[]:n>2&&zi(e[0],e[1],e[2])&&(e=[e[0]]),Array.isArray(e)||(e=[zr(e,2)]),Rr(t,e.flat(1),[])},bo=t=>null!=t&&t.length?Gr(t,1/0):[],wo=(t,...e)=>Gi(t)?mr(t,e):[],xo=(t,...e)=>Vi(t)&&Gi(t)?mr(t,e.flat(1)):[],Ao=(...t)=>{const e=t.flat(1);return co(e)},To=(t,e)=>{if(null==t)return!1;"string"==typeof e&&(e=e.split("."));let n=-1,i=t;for(;++n<e.length;){if(!i||!hasOwnProperty.call(i,e[n]))return!1;i=i[e[n]]}return!0},Eo=(t,e,n)=>{let i=-1,r=(e=fr(e,t)).length;for(r||(r=1,t=void 0);++i<r;){let o=null==t?void 0:t[vr(e[i])];void 0===o&&(i=r,o=n),t="function"==typeof o?o.call(t):o}return t},Po=(t,...e)=>{let n={};if(null==t)return n;let i=!1;e=e.flat(1).map((e=>(e=fr(e,t),i||(i=e.length>1),e))),Ui(t,er(t),n),i&&(n=yr(n,!0,!0,!0,(t=>mo(t)?void 0:t)));let r=e.length;for(;r--;)Tr(n,e[r]);return n},So=(t,...e)=>null==t?{}:((t,e)=>((t,e,n)=>{let i=-1;const r=e.length,o={};for(;++i<r;){const r=e[i],s=pr(t,r);n(s,r)&&xr(o,fr(r,t),s)}return o})(t,e,((e,n)=>Ir(t,n))))(t,e.flat(1/0)),_o=(t,e=(t=>t))=>{let n=-1;const i=Object(t),r=Gi(t)?Bi(t,!0):Pr(t);let o=r.length;for(;o--;){const t=r[++n];if(!1===e(i[t],t,i))break}},ko=(t="")=>((t,e)=>{if(void 0===e){const e=Ci(t)?(t=>t.match(bi))(t):(t=>t.match(Mi))(t);return e||[]}return t.match(e)||[]})(`${t}`.replace(/['\u2019]/g,"")).reduce(((t,e,n)=>(e=e.toLowerCase(),t+(n?Yr(e):e))),"");let Lo=0;const Co=(t="")=>`${t}`+ ++Lo,Mo=_r(((t,e,n,i)=>{kr(t,e,n,i)}),!0),Oo=class{constructor(){this.map=new WeakMap}has(t,e){return void 0===e?this.map.has(t):e in this.map.get(t)}create(t){return this.has(t)||this.map.set(t,Object.create(null)),this.get(t)}get(t,e){if(!this.has(t))return;const n=this.map.get(t);return void 0===e?n:n[e]}set(t,e,n){if(void 0===e)return;const i=this.create(t);"string"==typeof e?i[e]=n:Object.assign(i,e)}remove(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])}},No=new Oo,Ro=new Oo,Fo=function(t,e){if(!(this instanceof Fo))return new Fo(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?Bo:Io,this.target=t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget):this.type=t,e&&Object.assign(this,e),this.timeStamp=t&&t.timeStamp||Date.now(),this.envelope=!0};function Bo(){return!0}function Io(){return!1}Fo.prototype={constructor:Fo,isDefaultPrevented:Io,isPropagationStopped:Io,isImmediatePropagationStopped:Io,preventDefault:function(){const t=this.originalEvent;this.isDefaultPrevented=Bo,t&&t.preventDefault()},stopPropagation:function(){const t=this.originalEvent;this.isPropagationStopped=Bo,t&&t.stopPropagation()},stopImmediatePropagation:function(){const t=this.originalEvent;this.isImmediatePropagationStopped=Bo,t&&t.stopImmediatePropagation(),this.stopPropagation()}},["altKey","bubbles","cancelable","changedTouches","ctrlKey","detail","eventPhase","metaKey","pageX","pageY","shiftKey","view","char","code","charCode","key","keyCode","button","buttons","clientX","clientY","offsetX","offsetY","pointerId","pointerType","screenX","screenY","targetTouches","toElement","touches","which"].forEach((t=>function(t){Object.defineProperty(Fo.prototype,t,{enumerable:!0,configurable:!0,get:function(){return this.originalEvent?this.originalEvent[t]:void 0},set:function(e){Object.defineProperty(this,t,{enumerable:!0,configurable:!0,writable:!0,value:e})}})}(t)));const Do="undefined"!=typeof window?window.document:null,Vo=Do&&Do.documentElement,zo=/^([^.]*)(?:\.(.+)|)/,jo=/[^\x20\t\r\n\f]+/g,$o=function(t){return new $o.Dom(t)};$o.fn=$o.prototype={constructor:$o,length:0},$o.guid=1,$o.data=Ro,$o.merge=function(t,e){let n=+e.length,i=t.length;for(let r=0;r<n;r++)t[i++]=e[r];return t.length=i,t},$o.parseHTML=function(t){const e=Do.implementation.createHTMLDocument(),n=e.createElement("base");n.href=Do.location.href,e.head.appendChild(n),e.body.innerHTML=t;const i=e.getElementsByTagName("script");for(let t=0;t<i.length;t++)i[t].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&($o.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),$o.fn.toArray=function(){return Array.from(this)},$o.fn.pushStack=function(t){const e=$o.merge(this.constructor(),t);return e.prevObject=this,e},$o.fn.find=function(t){const[e]=this,n=this.pushStack([]);if(!e)return n;const{nodeType:i}=e;return 1!==i&&9!==i&&11!==i||("string"!=typeof t?e!==t&&e.contains(t)&&$o.merge(n,[t]):$o.merge(n,e.querySelectorAll(t))),n},$o.fn.add=function(t,e){const n=$o(t,e).toArray(),i=this.toArray(),r=this.pushStack([]);return $o.merge(r,co(i.concat(n))),r},$o.fn.addBack=function(){return this.add(this.prevObject)},$o.fn.filter=function(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];i.matches(t)&&e.push(i)}return this.pushStack(e)};const Uo=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,Go=function(t){if(!t)return this;if("function"==typeof t)throw new Error("function not supported");if(arguments.length>1)throw new Error("selector with context not supported");if(t.nodeType)return this[0]=t,this.length=1,this;let e;if("<"===(n=t+"")[0]&&">"===n[n.length-1]&&n.length>=3)e=[null,t,null];else{if("string"!=typeof t)return $o.merge(this,t);e=Uo.exec(t)}var n;if(!e||!e[1])return qo.find(t);if(e[1])return $o.merge(this,$o.parseHTML(e[1])),this;const i=Do.getElementById(e[2]);return i&&(this[0]=i,this.length=1),this};$o.Dom=Go,Go.prototype=$o.fn,$o.Event=Fo,$o.event={special:Object.create(null)},$o.event.has=function(t,e){const n=No.get(t,"events");return!!n&&(!e||Array.isArray(n[e])&&n[e].length>0)},$o.event.on=function(t,e,n,i,r,o){if("object"==typeof e){"string"!=typeof n&&(i=i||n,n=void 0);for(let r in e)$o.event.on(t,r,n,i,e[r],o);return t}if(null==i&&null==r?(r=n,i=n=void 0):null==r&&("string"==typeof n?(r=i,i=void 0):(r=i,i=n,n=void 0)),!r)return t;if(1===o){const t=r;r=function(e){return $o().off(e),t.apply(this,arguments)},r.guid=t.guid||(t.guid=$o.guid++)}for(let o=0;o<t.length;o++)$o.event.add(t[o],e,r,i,n)},$o.event.add=function(t,e,n,i,r){if("object"!=typeof t)return;const o=No.create(t);let s,a,l;n.handler&&(s=n,n=s.handler,r=s.selector),r&&Vo.matches(r),n.guid||(n.guid=$o.guid++),(a=o.events)||(a=o.events=Object.create(null)),(l=o.handle)||(l=o.handle=function(e){return void 0!==$o?$o.event.dispatch.apply(t,arguments):void 0});const c=(e||"").match(jo)||[""];let h=c.length;for(;h--;){const[,e,o=""]=zo.exec(c[h]);if(!e)continue;const u=o.split(".").sort();let d=$o.event.special[e];const f=d&&(r?d.delegateType:d.bindType)||e;d=$o.event.special[f];const p=Object.assign({type:f,origType:e,data:i,handler:n,guid:n.guid,selector:r,namespace:u.join(".")},s);let g;(g=a[f])||(g=a[f]=[],g.delegateCount=0,d&&d.setup&&!1!==d.setup.call(t,i,u,l)||t.addEventListener&&t.addEventListener(f,l)),d&&d.add&&(d.add.call(t,p),p.handler.guid||(p.handler.guid=n.guid)),r?g.splice(g.delegateCount++,0,p):g.push(p)}},$o.event.remove=function(t,e,n,i,r){const o=No.get(t);if(!o||!o.events)return;const s=o.events,a=(e||"").match(jo)||[""];let l=a.length;for(;l--;){const[,e,c=""]=zo.exec(a[l]);if(!e){for(const e in s)$o.event.remove(t,e+a[l],n,i,!0);continue}const h=$o.event.special[e],u=h&&(i?h.delegateType:h.bindType)||e,d=s[u];if(!d||0===d.length)continue;const f=c.split(".").sort(),p=c?new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,g=d.length;let m=g;for(;m--;){const o=d[m];!r&&e!==o.origType||n&&n.guid!==o.guid||p&&!p.test(o.namespace)||i&&i!==o.selector&&("**"!==i||!o.selector)||(d.splice(m,1),o.selector&&d.delegateCount--,h&&h.remove&&h.remove.call(t,o))}g&&0===d.length&&(h&&h.teardown&&!1!==h.teardown.call(t,f,o.handle)||t.removeEventListener&&t.removeEventListener(u,o.handle),delete s[u])}fo(s)&&(No.remove(t,"handle"),No.remove(t,"events"))},$o.event.dispatch=function(t){const e=this,n=$o.event.fix(t);n.delegateTarget=e;const i=Array.from(arguments);i[0]=n;const r=No.get(e,"events"),o=r&&r[n.type]||[],s=$o.event.special[n.type];if(s&&s.preDispatch&&!1===s.preDispatch.call(e,n))return;const a=$o.event.handlers.call(e,n,o);let l,c=0;for(;(l=a[c++])&&!n.isPropagationStopped();){n.currentTarget=l.elem;let t,e=0;for(;(t=l.handlers[e++])&&!n.isImmediatePropagationStopped();){n.handleObj=t,n.data=t.data;const e=$o.event.special[t.origType];let r;r=e&&e.handle?e.handle:t.handler;const o=r.apply(l.elem,i);void 0!==o&&!1===(n.result=o)&&(n.preventDefault(),n.stopPropagation())}}return s&&s.postDispatch&&s.postDispatch.call(e,n),n.result},$o.event.handlers=function(t,e){const n=e.delegateCount,i=[];if(n&&!("click"===t.type&&t.button>=1))for(let r=t.target;r!==this;r=r.parentNode||this)if(1===r.nodeType&&("click"!==t.type||!0!==r.disabled)){const t=[],o={};for(let i=0;i<n;i++){const n=e[i],s=n.selector+" ";void 0===o[s]&&(o[s]=r.matches(s)),o[s]&&t.push(n)}t.length&&i.push({elem:r,handlers:t})}return n<e.length&&i.push({elem:this,handlers:e.slice(n)}),i},$o.event.fix=function(t){return t.envelope?t:new Fo(t)};const qo=$o(Do);function Ho(t){let e=t.length;for(;e--;)Wo(t[e])}function Wo(t){$o.event.remove(t),No.remove(t),Ro.remove(t)}function Yo(t){for(let e=0;e<t.length;e++){const n=t[e];n.parentNode&&n.parentNode.removeChild(n)}}function Xo(){for(let t=0;t<this.length;t++){const e=this[t];Wo(e),Ho(e.getElementsByTagName("*"))}return Yo(this),this}function Zo(){return Yo(this),this}function Ko(){for(let t=0;t<this.length;t++){const e=this[t];1===e.nodeType&&(Ho(e.getElementsByTagName("*")),e.textContent="")}return this}function Jo(){const t=[];for(let e=0;e<this.length;e++)t.push(this[e].cloneNode(!0));return this.pushStack(t)}function Qo(t){const[e]=this;return e?0===arguments.length?e.innerHTML:void 0===t?this:(Ho(No,e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t?(e.innerHTML="",this.append(t)):(e.innerHTML=t,this)):null}function ts(...t){const[e]=this;return e?(t.forEach((t=>{t&&("string"==typeof t?e.append(...$o.parseHTML(t)):"[object Object]"===t.toString()?this.append(...Array.from(t)):Array.isArray(t)?this.append(...t):e.appendChild(t))})),this):this}function es(...t){const[e]=this;return e?(t.forEach((t=>{t&&("string"==typeof t?e.prepend(...$o.parseHTML(t)):"[object Object]"===t.toString()?this.prepend(...Array.from(t)):Array.isArray(t)?this.prepend(...t):e.insertBefore(t,e.firstChild))})),this):this}function ns(t){return $o(t).append(this),this}function is(t){return $o(t).prepend(this),this}const rs={};function os(t,e,n){"number"==typeof n&&rs[ko(e)]&&(n+="px"),t.style[e]=n}function ss(t,e){let n;if("string"==typeof t){if(void 0===e){const[e]=this;return e?e.style[t]:null}n={[t]:e}}else{if(!t)throw new Error("no styles provided");n=t}for(let t in n)if(n.hasOwnProperty(t))for(let e=0;e<this.length;e++)os(this[e],t,n[t]);return this}function as(t,e){if(arguments.length<2){const[e]=this;return e?void 0===t?e.dataset:e.dataset[t]:null}for(let n=0;n<this.length;n++)this[n].dataset[t]=e;return this}function ls(t,e,n){for(let i=0;i<e.length;i++){const r=e[i];An.prototype[t].apply({node:r},n)}}function cs(){return ls("removeClass",this,arguments),this}function hs(){return ls("addClass",this,arguments),this}function us(){return ls("toggleClass",this,arguments),this}function ds(){const[t]=this;return!!t&&An.prototype.hasClass.apply({node:t},arguments)}function fs(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];let r=Array.from(i.children);"string"==typeof t&&(r=r.filter((e=>e.matches(t)))),e.push(...r)}return this.pushStack(e)}function ps(t){const e=[];for(let n=0;n<this.length;n++){const i=this[n];if("string"==typeof t){const n=i.closest(t);n&&e.push(n)}else{const[n]=$o(t);n&&n.contains(i)&&e.push(n)}}return this.pushStack(e)}function gs(t,e,n,i){return $o.event.on(this,t,e,n,i),this}function ms(t,e,n,i){return $o.event.on(this,t,e,n,i,1),this}function vs(t,e,n){if(t&&t.preventDefault&&t.handleObj){const e=t.handleObj;return $o(t.delegateTarget).off(e.namespace?e.origType+"."+e.namespace:e.origType,e.selector,e.handler),this}if("object"==typeof t){for(let n in t)this.off(n,e,t[n]);return this}!1!==e&&"function"!=typeof e||(n=e,e=void 0);for(let i=0;i<this.length;i++)$o.event.remove(this[i],t,n,e);return this}function ys(){const[t]=this;if(t===window)return t.document.documentElement.clientWidth;if(!t)return;const e=window.getComputedStyle(t),n=t.offsetWidth,i=parseFloat(e.borderTopWidth);return n-parseFloat(e.borderBottomWidth)-i-parseFloat(e.paddingTop)-parseFloat(e.paddingBottom)}function bs(){const[t]=this;if(t===window)return t.document.documentElement.clientHeight;if(!t)return;const e=window.getComputedStyle(t);return t.offsetHeight-parseFloat(e.borderLeftWidth)-parseFloat(e.borderRightWidth)-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight)}function ws(){const[t]=this;if(!t)return;let e,n,i,r=$o(t),o={top:0,left:0};if("fixed"===r.css("position"))n=t.getBoundingClientRect();else{n=r.offset(),i=t.ownerDocument,e=t.offsetParent||i.documentElement;const s=$o(e),a=s.css("position")||"static";for(;e&&(e===i.body||e===i.documentElement)&&"static"===a;)e=e.parentNode;if(e&&e!==t&&1===e.nodeType){const t=window.getComputedStyle(e),n=parseFloat(t.borderTopWidth)||0,i=parseFloat(t.borderLeftWidth)||0;o=s.offset(),o.top+=n,o.left+=i}}const s=parseFloat(window.getComputedStyle(t).marginTop)||0,a=parseFloat(window.getComputedStyle(t).marginLeft)||0;return{top:n.top-o.top-s,left:n.left-o.left-a}}function xs(t){const[e]=this;if(void 0===t){if(!e)return null;if(!e.getClientRects().length)return{top:0,left:0};const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX}}if(!e)return this;const n=window.getComputedStyle(e);"static"===n.position&&this.css("position","relative");const i=this.offset(),r=t.top-i.top,o=t.left-i.left;return this.css({top:(parseFloat(n.top)||0)+r+"px",left:(parseFloat(n.left)||0)+o+"px"}),this}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach((t=>{rs[t]=!0}));const As="animationFrameId",Ts={};function Es(t,e={}){this.stop();for(let n=0;n<this.length;n++)Ps(this[n],t,e);return this}function Ps(t,e,n={}){let{duration:i=400,easing:r="ease-in-out",delay:o=0,complete:s}=n;const a=setTimeout((function(){const n=$o(t);let a=!1,l="transitionend";i/=1e3,o/=1e3;const c={};if("string"==typeof e)c["animation-name"]=e,c["animation-duration"]=i+"s",c["animation-delay"]=o+"s",c["animation-timing-function"]=r,l="animationend";else{const t=[];for(var h in e)e.hasOwnProperty(h)&&(c[h]=e[h],t.push(h));i>0&&(c["transition-property"]=t.join(", "),c["transition-duration"]=i+"s",c["transition-delay"]=o+"s",c["transition-timing-function"]=r)}const u=function(e){if(e){if(e.target!==e.currentTarget)return;e.target.removeEventListener(l,u)}else t.removeEventListener(l,u);a=!0,n.css(Ts),s&&s.call(t)};if(i>0){t.addEventListener(l,u);const e=setTimeout((function(){a||u(null)}),1e3*(i+o)+25);No.set(t,As,{id:e,stop:()=>{clearTimeout(e),t.removeEventListener(l,u)}})}n.css(c),i<=0&&u(null)}));No.set(t,As,{stop:()=>clearTimeout(a)})}function Ss(){for(let t=0;t<this.length;t++){const e=this[t],n=No.get(e,As);n&&(n.stop(),No.remove(e,As))}return this.css(Ts),this}Ts["transition-property"]=Ts["transition-duration"]=Ts["transition-delay"]=Ts["transition-timing-function"]=Ts["animation-name"]=Ts["animation-duration"]=Ts["animation-delay"]=Ts["animation-timing-function"]="";const _s={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},ks={disabled:"disabled",value:"value",text:"textContent"},Ls={prop:function(t,e){if(!t)throw new Error("no property provided");if(1===arguments.length){const[e]=this;return e?e[t]:null}if(void 0===e)return this;for(let n=0;n<this.length;n++)this[n][t]=e;return this},attr:function(t,e){let n;if("string"==typeof t){if(void 0===e){const[e]=this;return e?e.getAttribute(t):null}n={[t]:e}}else{if(!t)throw new Error("no attributes provided");n=t}for(let t in n)if(n.hasOwnProperty(t)){const e=n[t];if(ks[t]){this.prop(ks[t],e);continue}for(let n=0;n<this.length;n++)null===e?this[n].removeAttribute(t):this[n].setAttribute(t,e)}return this}};Object.keys(_s).forEach((t=>{Ls[t]=function(...e){return this.prop(_s[t],...e)}}));const Cs=Ls,Ms="joint-",Os=Object.create(null),Ns=Os;Os.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach((([t,e])=>{Os[t]={delegateType:e,bindType:e,handle:function(t){const n=t.relatedTarget,i=t.handleObj;let r;return n&&this.contains(n)||(t.type=i.origType,r=i.handler.apply(this,arguments),t.type=e),r}}}));Os.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t,...e){const{handleObj:n,target:i}=t,r=$o.data.create(i),o=(new Date).getTime(),s="lastTouch"in r?o-r.lastTouch:0;s<300&&s>30?(r.lastTouch=null,t.type=n.origType,n.handler.call(this,t,...e)):r.lastTouch=o}},Object.assign($o.fn,r),Object.assign($o.fn,o),Object.assign($o.fn,Cs),Object.assign($o.event.special,Ns);const Rs=$o,Fs=function(t){return t?t.toString().split(" ").map((function(t){return t.substr(0,6)!==Ms&&(t=Ms+t),t})).join(" "):t},Bs=function(t,e){const n={},i={},r=An.namespace.svg,o=e||r,s=document.createDocumentFragment(),a=function(t,e,o){for(let s=0;s<t.length;s++){const l=t[s];if("string"==typeof l){const t=document.createTextNode(l);e.appendChild(t);continue}if(!l.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");const c=l.tagName;let h;l.hasOwnProperty("namespaceURI")&&(o=l.namespaceURI),h=document.createElementNS(o,c);const u=o===r,d=u?An(h):Rs(h),f=l.attributes;f&&d.attr(f);const p=l.style;if(p&&Rs(h).css(p),l.hasOwnProperty("className")){const t=l.className;u?h.className.baseVal=t:h.className=t}if(l.hasOwnProperty("textContent")&&(h.textContent=l.textContent),l.hasOwnProperty("selector")){const t=l.selector;if(n[t])throw new Error("json-dom-parser: selector must be unique");n[t]=h,d.attr("joint-selector",t)}if(l.hasOwnProperty("groupSelector")){let t=l.groupSelector;Array.isArray(t)||(t=[t]);for(let e=0;e<t.length;e++){const n=t[e];let r=i[n];r||(r=i[n]=[]),r.push(h)}}e.appendChild(h);const g=l.children;Array.isArray(g)&&a(g,h,o)}};return a(t,s,o),{fragment:s,selectors:n,groupSelectors:i}},Is=function(t){let e=0;if(0===t.length)return e;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e},Ds=function(t,e,n){for(var i,r=Array.isArray(e)?e:e.split(n||"/"),o=0,s=r.length;o<s;){if(i=r[o++],Object(t)!==t||!(i in t))return;t=t[i]}return t},Vs=function(t,e){return"string"!=typeof e&&"number"!=typeof e&&(e=String(e)),("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!==e},zs=function(t,e,n,i){const r=Array.isArray(e)?e:e.split(i||"/"),o=r.length-1;let s=t,a=0;for(;a<o;a++){const e=r[a];if(!Vs(s,e))return t;s=s[e]||(s[e]={})}return s[r[o]]=n,t},js=function(t,e,n){const i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1;let o=t,s=0;for(;s<r;s++){const e=i[s];if(!Vs(o,e))return t;const n=o[e];if(!n)return t;o=n}return delete o[i[r]],t},$s=function(t){return $s.id=$s.id||1,void 0===t?"j_"+$s.id++:(t.id=void 0===t.id?"j_"+$s.id++:t.id,t.id)},Us=function(t){if(t.normalized)return t;const{originalEvent:e,target:n}=t,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(let e in i)void 0===t[e]&&(t[e]=i[e]);if(n){const e=n.correspondingUseElement;e&&(t.target=e)}return t.normalized=!0,t},Gs=function(){var t;if("undefined"!=typeof window&&(t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame),!t){var e=0;t=function(t){var n=(new Date).getTime(),i=Math.max(0,16-(n-e)),r=setTimeout((function(){t(n+i)}),i);return e=n+i,r}}return function(e,n,...i){return t(void 0!==n?e.bind(n,...i):e)}}(),qs=((Ws="undefined"!=typeof window)&&(Hs=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame),Hs=Hs||clearTimeout,Ws?Hs.bind(window):Hs);var Hs,Ws;const Ys=function(t){return no(t)&&"%"===t.slice(-1)},Xs=function(t,e){var n=parseFloat(t);if(Number.isNaN(n))return null;var i,r={};if(r.value=n,null==e)i="[A-Za-z]*";else if(Array.isArray(e)){if(0===e.length)return null;i=e.join("|")}else no(e)&&(i=e);var o=function(e){var n=new RegExp("(?:\\d+(?:\\.\\d+)*)("+e+")$").exec(t);return n?n[1]:null}(i);return null===o?null:(r.unit=o,r)};function Zs(t,e){const n=t.split(e);let i=1;for(let t=0,r=n.length-1;t<r;t++){const o=[];(t>0||""!==n[0])&&o.push(0),o.push(e),(t<r-1||""!==n[r])&&o.push(0),n.splice(i,0,...o),i+=o.length+1}return n.filter((t=>""!==t))}function Ks(t,e){if(null===t)return e.getBBox().height;switch(t.unit){case"em":return e.getBBox().height*t.value;case"px":case"":return t.value}}const Js=function(t,e,n={},i={}){var r=e.width,o=e.height,s=i.svgDocument||An("svg").node,a=An("tspan").node,l=An("text").attr(n).append(a).node,c=document.createTextNode("");l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(c),s.appendChild(l),i.svgDocument||document.body.appendChild(s);const h=i.preserveSpaces,u=i.separator||""===i.separator?i.separator:" ",d="string"==typeof u?u:" ";var f=i.eol||"\n",p=i.hyphen?new RegExp(i.hyphen):/[^\w\d\u00C0-\u1FFF\u2800-\uFFFD]/,g=i.maxLineCount;eo(g)||(g=1/0);var m,v,y,b=t.split(u),w=[],x=[];h&&An(a).attr("xml:space","preserve");for(var A=0,T=0,E=b.length;A<E;A++){var P=b[A];if((P||h)&&"string"==typeof P){var S=!1;if(f&&P.indexOf(f)>=0){if(P.length>1){const t=Zs(b[A],f);b.splice(A,1,...t),A--,E=b.length;continue}if(h&&"string"==typeof b[A-1]){b.splice(A,0,"",0),E+=2,A--;continue}x[++T]=h&&"string"!=typeof b[A+1]?void 0:"",S=!0}if(!S){let t;if(t=h?void 0!==x[T]?x[T]+d+P:P:x[T]?x[T]+d+P:P,c.data=t,a.getComputedTextLength()<=r)x[T]=t,(m||v)&&(w[T++]=!0,m=0,v=0);else{if(!x[T]||m){var _=!!m;if(m=P.length-1,_||!m){if(!m){if(!x[T]){x=[];break}b.splice(A,2,P+b[A+1]),E--,w[T++]=!0,A--;continue}b[A]=P.substring(0,m);const t=b[A+1];b[A+1]=P.substring(m)+(void 0===t||0===t?"":t)}else{if(v)b.splice(A,2,b[A]+b[A+1]),v=0;else{var k=P.search(p);k>-1&&k!==P.length-1&&0!==k&&(v=k+1,m=0),b.splice(A,1,P.substring(0,v||m),P.substring(v||m)),E++}T&&!w[T-1]&&T--}h&&""===x[T]||A--;continue}T++,A--}}var L=null;if(x.length>g?L=g-1:void 0!==o&&(void 0===y&&""!==c.data&&(y="auto"===n.lineHeight?Ks({value:1.5,unit:"em"},l):Ks(Xs(n.lineHeight,["em","px",""]),l)),y*x.length>o&&(L=Math.floor(o/y)-1)),null!==L){x.splice(L+1);var C=i.ellipsis;if(!C||L<0)break;"string"!=typeof C&&(C="…");var M=x[L];if(!M&&!S)break;var O,N,R=M.length;do{if(N=M[R],O=M.substring(0,R),N?N.match(u)&&(O+=N):O+=d,O+=C,c.data=O,a.getComputedTextLength()<=r){x[L]=O;break}R--}while(R>=0);break}}}return i.svgDocument?s.removeChild(l):document.body.removeChild(s),x.join(f)},Qs=function(t){if(Object(t)!==t){var e=0;return isFinite(t)&&(e=+t),{top:e,right:e,bottom:e,left:e}}var n,i,r,o;return n=i=r=o=0,isFinite(t.vertical)&&(n=r=+t.vertical),isFinite(t.horizontal)&&(i=o=+t.horizontal),isFinite(t.top)&&(n=+t.top),isFinite(t.right)&&(i=+t.right),isFinite(t.bottom)&&(r=+t.bottom),isFinite(t.left)&&(o=+t.left),{top:n,right:i,bottom:r,left:o}},ta={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){if(t<=0)return 0;if(t>=1)return 1;var e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)},exponential:function(t){return Math.pow(2,10*(t-1))},bounce:function(t){for(var e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11){var i=(11-6*e-11*t)/4;return-i*i+n*n}},reverse:function(t){return function(e){return 1-t(1-e)}},reflect:function(t){return function(e){return.5*(e<.5?t(2*e):2-t(2-2*e))}},clamp:function(t,e,n){return e=e||0,n=n||1,function(i){var r=t(i);return r<e?e:r>n?n:r}},back:function(t){return t||(t=1.70158),function(e){return e*e*((t+1)*e-t)}},elastic:function(t){return t||(t=1.5),function(e){return Math.pow(2,10*(e-1))*Math.cos(20*Math.PI*t/3*e)}}},ea={number:function(t,e){var n=e-t;return function(e){return t+n*e}},object:function(t,e){var n=Object.keys(t);return function(i){var r,o,s={};for(r=n.length-1;-1!=r;r--)s[o=n[r]]=t[o]+(e[o]-t[o])*i;return s}},hexColor:function(t,e){var n=parseInt(t.slice(1),16),i=parseInt(e.slice(1),16),r=255&n,o=(255&i)-r,s=65280&n,a=(65280&i)-s,l=16711680&n,c=(16711680&i)-l;return function(t){return"#"+(1<<24|r+o*t&255|s+a*t&65280|l+c*t&16711680).toString(16).slice(1)}},unit:function(t,e){var n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,i=n.exec(t),r=n.exec(e),o=r[1].indexOf("."),s=o>0?r[1].length-o-1:0;t=+i[1];var a=+r[1]-t,l=i[2];return function(e){return(t+a*e).toFixed(s)+l}}},na={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return ia('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology in="SourceAlpha" result="morphedOuter" operator="dilate" radius="${outerRadius}" /><feMorphology in="SourceAlpha" result="morphedInner" operator="dilate" radius="${innerRadius}" /><feComposite result="morphedOuterColored" in="colored" in2="morphedOuter" operator="in"/><feComposite operator="xor" in="morphedOuterColored" in2="morphedInner" result="outline"/><feMerge><feMergeNode in="outline"/><feMergeNode in="SourceGraphic"/></feMerge></filter>')({color:t.color||"blue",opacity:Number.isFinite(t.opacity)?t.opacity:1,outerRadius:e+n,innerRadius:e})},highlight:function(t){return ia('<filter><feFlood flood-color="${color}" flood-opacity="${opacity}" result="colored"/><feMorphology result="morphed" in="SourceGraphic" operator="dilate" radius="${width}"/><feComposite result="composed" in="colored" in2="morphed" operator="in"/><feGaussianBlur result="blured" in="composed" stdDeviation="${blur}"/><feBlend in="SourceGraphic" in2="blured" mode="normal"/></filter>')({color:t.color||"red",width:Number.isFinite(t.width)?t.width:1,blur:Number.isFinite(t.blur)?t.blur:0,opacity:Number.isFinite(t.opacity)?t.opacity:1})},blur:function(t){var e=Number.isFinite(t.x)?t.x:2;return ia('<filter><feGaussianBlur stdDeviation="${stdDeviation}"/></filter>')({stdDeviation:Number.isFinite(t.y)?[e,t.y]:e})},dropShadow:function(t){var e="SVGFEDropShadowElement"in window?'<filter><feDropShadow stdDeviation="${blur}" dx="${dx}" dy="${dy}" flood-color="${color}" flood-opacity="${opacity}"/></filter>':'<filter><feGaussianBlur in="SourceAlpha" stdDeviation="${blur}"/><feOffset dx="${dx}" dy="${dy}" result="offsetblur"/><feFlood flood-color="${color}"/><feComposite in2="offsetblur" operator="in"/><feComponentTransfer><feFuncA type="linear" slope="${opacity}"/></feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge></filter>';return ia(e)({dx:t.dx||0,dy:t.dy||0,opacity:Number.isFinite(t.opacity)?t.opacity:1,color:t.color||"black",blur:Number.isFinite(t.blur)?t.blur:4})},grayscale:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>')({a:.2126+.7874*(1-e),b:.7152-.7152*(1-e),c:.0722-.0722*(1-e),d:.2126-.2126*(1-e),e:.7152+.2848*(1-e),f:.0722-.0722*(1-e),g:.2126-.2126*(1-e),h:.0722+.9278*(1-e)})},sepia:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${h} ${i} 0 0 0 0 0 1 0"/></filter>')({a:.393+.607*(1-e),b:.769-.769*(1-e),c:.189-.189*(1-e),d:.349-.349*(1-e),e:.686+.314*(1-e),f:.168-.168*(1-e),g:.272-.272*(1-e),h:.534-.534*(1-e),i:.131+.869*(1-e)})},saturate:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-e})},hueRotate:function(t){return ia('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:1-e})},brightness:function(t){return ia('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}"/><feFuncG type="linear" slope="${amount}"/><feFuncB type="linear" slope="${amount}"/></feComponentTransfer></filter>')({amount:Number.isFinite(t.amount)?t.amount:1})},contrast:function(t){var e=Number.isFinite(t.amount)?t.amount:1;return ia('<filter><feComponentTransfer><feFuncR type="linear" slope="${amount}" intercept="${amount2}"/><feFuncG type="linear" slope="${amount}" intercept="${amount2}"/><feFuncB type="linear" slope="${amount}" intercept="${amount2}"/></feComponentTransfer></filter>')({amount:e,amount2:.5-e/2})}},ia=function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(n){return n=n||{},t.replace(e,(function(t){for(var e=Array.from(arguments).slice(1,4).find((function(t){return!!t})).split("."),i=n[e.shift()];void 0!==i&&e.length;)i=i[e.shift()];return void 0!==i?i:""}))}};var ra,oa={},sa=/\s+/,aa=function(t,e,n,i,r){var o,s=0;if(n&&"object"==typeof n){void 0!==i&&"context"in r&&void 0===r.context&&(r.context=i);for(o=Object.keys(n);s<o.length;s++)e=aa(t,e,o[s],n[o[s]],r)}else if(n&&sa.test(n))for(o=n.split(sa);s<o.length;s++)e=t(e,o[s],i,r);else e=t(e,n,i,r);return e};oa.on=function(t,e,n){return this._events=aa(la,this._events||{},t,e,{context:n,ctx:this,listening:ra}),ra&&((this._listeners||(this._listeners={}))[ra.id]=ra,ra.interop=!1),this},oa.listenTo=function(t,e,n){if(!t)return this;var i=t._listenId||(t._listenId=Co("l")),r=this._listeningTo||(this._listeningTo={}),o=ra=r[i];o||(this._listenId||(this._listenId=Co("l")),o=ra=r[i]=new ga(this,t));var s=ca(t,e,n,this);if(ra=void 0,s)throw s;return o.interop&&o.on(e,n),this};var la=function(t,e,n,i){if(n){var r=t[e]||(t[e]=[]),o=i.context,s=i.ctx,a=i.listening;a&&a.count++,r.push({callback:n,context:o,ctx:o||s,listening:a})}return t},ca=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}};oa.off=function(t,e,n){return this._events?(this._events=aa(ha,this._events,t,e,{context:n,listeners:this._listeners}),this):this},oa.stopListening=function(t,e,n){var i=this._listeningTo;if(!i)return this;for(var r=t?[t._listenId]:Object.keys(i),o=0;o<r.length;o++){var s=i[r[o]];if(!s)break;s.obj.off(e,n,this),s.interop&&s.off(e,n)}return fo(i)&&(this._listeningTo=void 0),this};var ha=function(t,e,n,i){if(t){var r,o=i.context,s=i.listeners,a=0;if(e||o||n){for(r=e?[e]:Object.keys(t);a<r.length;a++){var l=t[e=r[a]];if(!l)break;for(var c=[],h=0;h<l.length;h++){var u=l[h];if(n&&n!==u.callback&&n!==u.callback._callback||o&&o!==u.context)c.push(u);else{var d=u.listening;d&&d.off(e,n)}}c.length?t[e]=c:delete t[e]}return t}if(null!=s)for(r=Object.keys(s);a<r.length;a++)s[r[a]].cleanup()}};oa.once=function(t,e,n){var i=aa(ua,{},t,e,this.off.bind(this));return"string"==typeof t&&null==n&&(e=void 0),this.on(i,e,n)},oa.listenToOnce=function(t,e,n){var i=aa(ua,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,i)};var ua=function(t,e,n,i){if(n){var r=t[e]=da((function(){i(e,r),n.apply(this,arguments)}));r._callback=n}return t},da=function(t){var e;if("function"!=typeof t)throw new TypeError("Expected a function");var n=2;return function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=void 0),e}};oa.trigger=function(t){if(!this._events)return this;for(var e=Math.max(0,arguments.length-1),n=Array(e),i=0;i<e;i++)n[i]=arguments[i+1];return aa(fa,this._events,t,void 0,n),this};var fa=function(t,e,n,i){if(t){var r=t[e],o=t.all;r&&o&&(o=o.slice()),r&&pa(r,i),o&&pa(o,[e].concat(i))}return t},pa=function(t,e){var n,i=-1,r=t.length,o=e[0],s=e[1],a=e[2];switch(e.length){case 0:for(;++i<r;)(n=t[i]).callback.call(n.ctx);return;case 1:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o);return;case 2:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,s);return;case 3:for(;++i<r;)(n=t[i]).callback.call(n.ctx,o,s,a);return;default:for(;++i<r;)(n=t[i]).callback.apply(n.ctx,e);return}},ga=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0};ga.prototype.on=oa.on,ga.prototype.off=function(t,e){var n;this.interop?(this._events=aa(ha,this._events,t,e,{context:void 0,listeners:void 0}),n=!this._events):(this.count--,n=0===this.count),n&&this.cleanup()},ga.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},oa.bind=oa.on,oa.unbind=oa.off;var ma=function(t,e){var n,i=this;return n=t&&To(t,"constructor")?t.constructor:function(){return i.apply(this,arguments)},io(n,i,e),n.prototype=Object.assign(Object.create(i.prototype),t),n.prototype.constructor=n,n.__super__=i.prototype,n},va=function(t,e){return go(t)?t:to(t)&&!e._isModel(t)?ya(t):no(t)?function(e){return e.get(t)}:t},ya=function(t){var e=Dr(yr(t,!0));return function(t){return e(t.attributes)}},ba=function(t,e){var n=t||{};e||(e={}),this.preinitialize.apply(this,arguments),this.cid=Co(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection);var i=Eo(this,"defaults");n=ro(io({},i,n),i),this.set(n,e),this.changed={},this.initialize.apply(this,arguments)};function wa(t){t=co(t);const e=vo(t).reduce((function(t,e){return t[e.id]=e.clone(),t}),{});return vo(t).forEach((function(t){const n=e[t.id];if(n.isLink()){const t=n.source(),i=n.target();t.id&&e[t.id]&&n.prop("source/id",e[t.id].id),i.id&&e[i.id]&&n.prop("target/id",e[i.id].id)}const i=t.get("parent");i&&e[i]&&n.set("parent",e[i].id);const r=vo(t.get("embeds")).reduce((function(t,n){return e[n]&&t.push(e[n].id),t}),[]);fo(r)||n.set("embeds",r)})),e}io(ba.prototype,oa,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return ho(this.attributes)},get:function(t){return this.attributes[t]},has:function(t){return null!=this.get(t)},set:function(t,e,n){if(null==t)return this;var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,n||(n={}),!this._validate(i,n))return!1;var r=n.unset,o=n.silent,s=[],a=this._changing;this._changing=!0,a||(this._previousAttributes=ho(this.attributes),this.changed={});var l=this.attributes,c=this.changed,h=this._previousAttributes;for(var u in i)e=i[u],po(l[u],e)||s.push(u),po(h[u],e)?delete c[u]:c[u]=e,r?delete l[u]:l[u]=e;if(this.idAttribute in i){var d=this.id;this.id=this.get(this.idAttribute),this.trigger("changeId",this,d,n)}if(!o){s.length&&(this._pending=n);for(var f=0;f<s.length;f++)this.trigger("change:"+s[f],this,l[s[f]],n)}if(a)return this;if(!o)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);return this._pending=!1,this._changing=!1,this},unset:function(t,e){return this.set(t,void 0,io({},e,{unset:!0}))},clear:function(t){var e={};for(var n in this.attributes)e[n]=void 0;return this.set(e,io({},t,{unset:!0}))},hasChanged:function(t){return null==t?!fo(this.changed):To(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&ho(this.changed);var e,n=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var o=t[r];po(n[r],o)||(i[r]=o,e=!0)}return!!e&&i},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return ho(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},io({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=io({},this.attributes,t);var n=this.validationError=this.validate(t,e)||null;return!n||(this.trigger("invalid",this,n,io(e,{validationError:n})),!1)}}),ba.extend=ma;const xa=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce(((t,e)=>(t[e]=!0,t)),{}),Aa={qualify:function(t){return mo(t)},set:function(t,e,n){Object.keys(t).forEach((function(e){if(xa[e]&&e in n){const i=t[e];"SELECT"===n.tagName&&Array.isArray(i)?Array.from(n.options).forEach((function(t,e){t.selected=i.includes(t.value)})):n[e]=i}}))}};function Ta(t,e,n){return function(i,r){var o,s=Ys(i);if(i=parseFloat(i),s&&(i/=100),isFinite(i)){var a=r[n]();o=s||i>0&&i<1?a[t]+r[e]*i:a[t]+i}var l=Jt();return l[t]=o||0,l}}function Ea(t,e){return function(n,i){var r=Ys(n);n=parseFloat(n),r&&(n/=100);var o={};if(isFinite(n)){var s=r||n>=0&&n<=1?n*i[e]:Math.max(n+i[e],0);o[t]=s}return o}}const Pa={"ref-x":{position:Ta("x","width","origin")},"ref-y":{position:Ta("y","height","origin")},"ref-dx":{position:Ta("x","width","corner")},"ref-dy":{position:Ta("y","height","corner")},"ref-width":{set:Ea("width","width")},"ref-height":{set:Ea("height","height")},"ref-rx":{set:Ea("rx","width")},"ref-ry":{set:Ea("ry","height")},"ref-cx":{set:Ea("cx","width")},"ref-cy":{set:Ea("cy","height")},"ref-r-inscribed":{set:(Sa=Ea("r","width"),_a=Ea("r","height"),function(t,e){return(e.height>e.width?Sa:_a)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n=Ys(t);t=parseFloat(t),n&&(t/=100);var i,r=Math.sqrt(e.height*e.height+e.width*e.width);return isFinite(t)&&(i=n||t>=0&&t<=1?t*r:Math.max(t+r,0)),{r:i}}}};var Sa,_a;Pa.refX=Pa["ref-x"],Pa.refY=Pa["ref-y"],Pa["ref-x2"]=Pa["ref-x"],Pa["ref-y2"]=Pa["ref-y"],Pa["ref-width2"]=Pa["ref-width"],Pa["ref-height2"]=Pa["ref-height"],Pa["ref-r"]=Pa["ref-r-inscribed"];const ka=Pa,La={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"},Ca=Object.keys(La).map((t=>La[t])).join(""),Ma="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?",Oa=/\s/g,Na=new RegExp(`^(${Ma}\\*)?([${Ca}])(/${Ma})?([-+]{1,2}${Ma})?$`,"g");function Ra(t){throw new Error(`Invalid calc() expression: ${t}`)}function Fa(t,e){const n=Na.exec(t.replace(Oa,""));n||Ra(t),Na.lastIndex=0;const[,i,r,o,s]=n,{x:a,y:l,width:c,height:h}=e;let u=0;switch(r){case La.width:u=c;break;case La.height:u=h;break;case La.x:u=a;break;case La.y:u=l;break;case La.minimum:u=Math.min(h,c);break;case La.maximum:u=Math.max(h,c);break;case La.diagonal:u=Math.sqrt(h*h+c*c)}return i&&(u*=parseFloat(i)),o&&(u/=parseFloat(o.slice(1))),s&&(u+=function(t){if(!t)return 0;const[e]=t;switch(e){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)}(s)),u}function Ba(t){return"string"==typeof t&&t.includes("calc")}const Ia="calc(",Da=Ia.length;function Va(t,e){let n=t,i=0;for(;;){let t=n.indexOf(Ia,i);if(-1===t)return n;let r=t+Da,o=1;t:for(;;){switch(n[r]){case"(":o++;break;case")":if(o--,0===o)break t;break;case void 0:Ra(n)}r++}let s=n.slice(t+Da,r);Ba(s)&&(s=Va(s,e));const a=String(Fa(s,e));n=n.slice(0,t)+a+n.slice(r+1),i=t+a.length}}function za(t,e,n){return void 0!==n.text}const ja={"line-height":{qualify:za},"text-vertical-anchor":{qualify:za},"text-path":{qualify:za},annotations:{qualify:za},eol:{qualify:za},"display-empty":{qualify:za},text:{qualify:function(t,e,n){const i=n["text-wrap"];return!i||!mo(i)},set:function(t,e,n,i){const r="joint-text",o=Rs.data.get(n,r),s=i["line-height"],a=i["text-vertical-anchor"],l=i["display-empty"],c=i["font-size"],h=i.annotations,u=i.eol,d=i.x;let f=i["text-path"];const p=JSON.stringify([t,s,h,a,u,l,f,d,c]);if(void 0===o||o!==p){if(c&&n.setAttribute("font-size",c),to(f)){const t=f.selector;if("string"==typeof t){const e=this.findNode(t);e instanceof SVGPathElement&&(f=io({"xlink:href":"#"+e.id},f))}}An(n).text(""+t,{lineHeight:s,annotations:h,textPath:f,x:d,textVerticalAnchor:a,eol:u,displayEmpty:l}),Rs.data.set(n,r,p)}}},"text-wrap":{qualify:mo,set:function(t,e,n,i){var r={},o=t.width||0;Ys(o)?r.width=e.width*parseFloat(o)/100:Ba(o)?r.width=Number(Va(o,e)):null===t.width?r.width=1/0:r.width=o<=0?e.width+o:o;var s,a=t.height||0;Ys(a)?r.height=e.height*parseFloat(a)/100:Ba(a)?r.height=Number(Va(a,e)):null===t.height||(r.height=a<=0?e.height+a:a);var l=t.text;if(void 0===l&&(l=i.text),void 0!==l){const e=t.breakText||Js,o=getComputedStyle(n);s=e(""+l,r,{"font-weight":o.fontWeight,"font-family":o.fontFamily,"text-transform":o.textTransform,"font-size":o.fontSize,"letter-spacing":o.letterSpacing,lineHeight:i["line-height"]},{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,separator:t.separator,maxLineCount:t.maxLineCount,preserveSpaces:t.preserveSpaces})}else s="";ja.text.set.call(this,s,e,n,i)}},title:{qualify:function(t,e){return e instanceof SVGElement},set:function(t,e,n){var i="joint-title",r=Rs.data.get(n,i);if(void 0===r||r!==t){if(Rs.data.set(n,i,t),"title"===n.tagName)return void(n.textContent=t);var o=n.firstElementChild;if(o&&"title"===o.tagName)o.textContent=t;else{var s=document.createElementNS(n.namespaceURI,"title");s.textContent=t,n.insertBefore(s,o)}}}}},$a=ja;function Ua(t,e){var n=new Jt(1,0);return function(i){var r,o,s=this[t](i);return s?(o=e.rotate?s.vector().vectorAngle(n):0,r=s.start):(r=this.path.start,o=0),0===o?{transform:"translate("+r.x+","+r.y+")"}:{transform:"translate("+r.x+","+r.y+") rotate("+o+")"}}}function Ga(){return this.model.isLink()}const qa={connection:{qualify:Ga,set:function({stubs:t=0}){let e;if(isFinite(t)&&0!==t){let n;n=t<0?(this.getConnectionLength()+t)/2:t;const i=this.getConnection(),r=this.getConnectionSubdivisions(),o=i.divideAtLength(n,{segmentSubdivisions:r}),s=i.divideAtLength(-n,{segmentSubdivisions:r});o&&s&&(e=`${o[0].serialize()} ${s[1].serialize()}`)}return{d:e||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:Ga,set:Ua("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:Ga,set:Ua("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:Ga,set:Ua("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:Ga,set:Ua("getTangentAtRatio",{rotate:!1})}};qa["at-connection-length"]=qa["at-connection-length-keep-gradient"],qa["at-connection-ratio"]=qa["at-connection-ratio-keep-gradient"];const Ha=qa;function Wa(t,e){var n="joint-shape",i=e&&e.resetOffset;return function(e,r,o){var s=Rs.data.get(o,n);if(!s||s.value!==e){var a=t(e);s={value:e,shape:a,shapeBBox:a.bbox()},Rs.data.set(o,n,s)}var l=s.shape.clone(),c=s.shapeBBox.clone(),h=c.origin(),u=r.origin();c.x=u.x,c.y=u.y;var d=r.maxRectScaleToFit(c,u),f=0===c.width||0===r.width?1:d.sx,p=0===c.height||0===r.height?1:d.sy;return l.scale(f,p,h),i&&l.translate(-h.x,-h.y),l}}function Ya(t){var e=Wa((function(t){return new Le(An.normalizePathData(t))}),t);return function(t,n,i){return{d:e(t,n,i).serialize()}}}function Xa(t){var e=Wa(xe,t);return function(t,n,i){return{points:e(t,n,i).serialize()}}}const Za={"ref-d-reset-offset":{set:Ya({resetOffset:!0})},"ref-d-keep-offset":{set:Ya({resetOffset:!1})},"ref-points-reset-offset":{set:Xa({resetOffset:!0})},"ref-points-keep-offset":{set:Xa({resetOffset:!1})}};Za["ref-d"]=Za["ref-d-reset-offset"],Za["ref-points"]=Za["ref-points-reset-offset"];const Ka=Za;function Ja(t){var e={},n=t.stroke;"string"==typeof n&&(e.stroke=n,e.fill=n);var i=t["stroke-opacity"];return void 0===i&&(i=t.opacity),void 0!==i&&(e["stroke-opacity"]=i,e["fill-opacity"]=i),e}function Qa(t){const{paper:e}=this;return`url(#${"pattern"===t.type?e.definePattern(t):e.defineGradient(t)})`}const tl={"source-marker":{qualify:mo,set:function(t,e,n,i){return t=io(Ja(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:mo,set:function(t,e,n,i){return t=io(Ja(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:mo,set:function(t,e,n,i){return t=io(Ja(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:mo,set:Qa},stroke:{qualify:mo,set:Qa},filter:{qualify:mo,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}};function el(t,e,n){return function(i,r){var o;o="middle"===i?r[e]/2:i===n?r[e]:isFinite(i)?i>-1&&i<1?-r[e]*i:-i:Ys(i)?r[e]*parseFloat(i)/100:0;var s=new Jt;return s[t]=-(r[t]+o),s}}const nl={"x-alignment":{offset:el("x","width","right")},"y-alignment":{offset:el("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}};function il(t){return function(e,n,i){const r=An(i);r.attr(t)!==e&&r.attr(t,e)}}const rl={ref:{},href:{set:il("href")},"xlink:href":{set:il("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:mo,set:function(t,e,n){Rs(n).css(t)}},html:{set:function(t,e,n){Rs(n).html(t+"")}},props:Aa};io(rl,ka),io(rl,$a),io(rl,Ha),io(rl,Ka),io(rl,tl),io(rl,nl);const ol=rl,sl=function(t,e){if(Array.isArray(t))return e},al=ba.extend({constructor:function(t,e){var n,i=t||{};if("function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=Co("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(i=this.parse(i,e)||{}),n=Eo(this,"defaults")){const t=(!e||!0!==e.mergeArrays)&&sl;i=Mo({},n,i,t)}this.set(i,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(){const t=Eo(this.constructor.prototype,"defaults").attrs||{},e=this.attributes.attrs,n={};_o(e,(function(e,i){const r=t[i];_o(e,(function(t,e){to(t)&&!Array.isArray(t)?_o(t,(function(t,o){r&&r[e]&&po(r[e][o],t)||(n[i]=n[i]||{},(n[i][e]||(n[i][e]={}))[o]=t)})):r&&po(r[e],t)||(n[i]=n[i]||{},n[i][e]=t)}))}));const i=uo(Po(this.attributes,"attrs"));return i.attrs=n,i},initialize:function(t){const e=this.getIdAttribute();t&&void 0!==t[e]||this.set(e,this.generateId(),{silent:!0}),this._transitionIds={},this._scheduledTransitionIds={},this.processPorts(),this.on("change:attrs",this.processPorts,this)},getIdAttribute:function(){return this.idAttribute||"id"},generateId:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))},processPorts:function(){var t=this.ports,e={};_o(this.get("attrs"),(function(t,n){t&&t.port&&(void 0!==t.port.id?e[t.port.id]=t.port:e[t.port]={id:t.port})}));var n={};_o(t,(function(t,i){e[i]||(n[i]=!0)})),this.graph&&!fo(n)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach((function(t){n[t.get("target").port]&&t.remove()})),this.graph.getConnectedLinks(this,{outbound:!0}).forEach((function(t){n[t.get("source").port]&&t.remove()}))),this.ports=e},remove:function(t={}){const{graph:e,collection:n}=this;if(!e)return n&&n.remove(this,t),this;e.startBatch("remove");const i=this.getParentCell();i&&i.unembed(this,t);const r=this.getEmbeddedCells();for(let e=0,n=r.length;e<n;e++){const n=r[e];n&&n.remove(t)}return this.trigger("remove",this,e.attributes.cells,t),e.stopBatch("remove"),this},toFront:function(t){var e=this.graph;if(e){let n;(t=ro(t||{},{foregroundEmbeds:!0})).deep?(n=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==t.breadthFirst,sortSiblings:t.foregroundEmbeds}),n.unshift(this)):n=[this];const i=t.foregroundEmbeds?n:yo(n,(t=>t.z()));let r=e.maxZIndex()-n.length+1;const o=e.get("cells");let s=o.toArray().indexOf(i[0])!==o.length-n.length;s||(s=i.some((function(t,e){return t.z()!==r+e}))),s&&(this.startBatch("to-front"),r+=n.length,i.forEach((function(e,n){e.set("z",r+n,t)})),this.stopBatch("to-front"))}return this},toBack:function(t){var e=this.graph;if(e){let n;(t=ro(t||{},{foregroundEmbeds:!0})).deep?(n=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==t.breadthFirst,sortSiblings:t.foregroundEmbeds}),n.unshift(this)):n=[this];const i=t.foregroundEmbeds?n:yo(n,(t=>t.z()));let r=e.minZIndex(),o=0!==e.get("cells").toArray().indexOf(i[0]);o||(o=i.some((function(t,e){return t.z()!==r+e}))),o&&(this.startBatch("to-back"),r-=n.length,i.forEach((function(e,n){e.set("z",r+n,t)})),this.stopBatch("to-back"))}return this},parent:function(t,e){return void 0===t?this.get("parent"):this.set("parent",t,e)},embed:function(t,e){const n=Array.isArray(t)?t:[t];if(!this.canEmbed(n))throw new Error("Recursive embedding not allowed.");if(n.some((t=>t.isEmbedded()&&this.id!==t.parent())))throw new Error("Embedding of already embedded cells is not allowed.");return this._embedCells(n,e),this},unembed:function(t,e){const n=Array.isArray(t)?t:[t];return this._unembedCells(n,e),this},canEmbed:function(t){return(Array.isArray(t)?t:[t]).every((t=>this!==t&&!this.isEmbeddedIn(t)))},_embedCells:function(t,e){const n="embed";this.startBatch(n);const i=io([],this.get("embeds"));t.forEach((t=>{i[t.isLink()?"unshift":"push"](t.id),t.parent(this.id,e)})),this.set("embeds",co(i),e),this.stopBatch(n)},_unembedCells:function(t,e){const n="unembed";this.startBatch(n),t.forEach((t=>t.unset("parent",e))),this.set("embeds",wo(this.get("embeds"),...t.map((t=>t.id))),e),this.stopBatch(n)},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(!this.graph)return t;for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(t=t||{},!this.graph)return[];if(t.deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);const e=this.get("embeds");if(fo(e))return[];let n=e.map(this.graph.getCell,this.graph);return t.sortSiblings&&(n=yo(n,(t=>t.z()))),n},_getEmbeddedCellsBfs:function(t){const e=[],n=[];for(n.push(this);n.length>0;){const i=n.shift();e.push(i);const r=i.getEmbeddedCells({sortSiblings:t});n.push(...r)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){const e=[],n=[];for(n.push(this);n.length>0;){const i=n.pop();e.push(i);const r=i.getEmbeddedCells({sortSiblings:t});for(let t=r.length-1;t>=0;--t)n.push(r[t])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=no(t)?t:t.id,i=this.parent();if(e=io({deep:!0},e),this.graph&&e.deep){for(;i;){if(i===n)return!0;i=this.graph.getCell(i).parent()}return!1}return i===n},isEmbedded:function(){return!!this.parent()},clone:function(t){if((t=t||{}).deep)return vo(wa([this].concat(this.getEmbeddedCells({deep:!0}))));var e=ba.prototype.clone.apply(this,arguments);return e.set(this.getIdAttribute(),this.generateId()),e.unset("embeds"),e.unset("parent"),e},prop:function(t,e,n){var i=no(t);if(i||Array.isArray(t)){if(arguments.length>1){var r,o;i?o=(r=t).split("/"):(r=t.join("/"),o=t.slice());var s=o[0],a=o.length;const m=n||{};m.propertyPath=r,m.propertyValue=e,m.propertyPathArray=o,"rewrite"in m||(m.rewrite=!1);for(var l={},c=l,h=s,u=1;u<a;u++){var d=o[u],f=Number.isFinite(i?Number(d):d);c=c[h]=f?[]:{},h=d}l=zs(l,o,e,"/");var p=Mo({},this.attributes);m.rewrite&&js(p,r,"/");var g=Mo(p,l);return this.set(s,g[s],m)}return Ds(this.attributes,t,"/")}const m=e||{};m.propertyPath=null,m.propertyValue=t,m.propertyPathArray=[],"rewrite"in m||(m.rewrite=!1);const v={};for(const e in t){const{changedValue:n}=Mo({},{changedValue:this.attributes[e]},{changedValue:t[e]});v[e]=n}return this.set(v,m)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];if("attrs"===i&&(e.dirty=!0),1===n.length)return this.unset(t,e);var r=n.slice(1),o=this.get(i);return null==o?this:(o=uo(o),js(o,r,"/"),this.set(i,o,e))},attr:function(t,e,n){var i=Array.from(arguments);return 0===i.length?this.get("attrs"):(Array.isArray(t)?i[0]=["attrs"].concat(t):no(t)?i[0]="attrs/"+t:i[0]={attrs:t},this.prop.apply(this,i))},removeAttr:function(t,e){return Array.isArray(t)?this.removeProp(["attrs"].concat(t)):this.removeProp("attrs/"+t,e)},transition:function(t,e,n,i){i=i||"/",n=io({duration:100,delay:10,timingFunction:ta.linear,valueFunction:ea.number},n);var r,o=0,s=function(e){var i,a,l;(a=(e-=o=o||e)/n.duration)<1?this._transitionIds[t]=i=Gs(s):(a=1,delete this._transitionIds[t]),l=r(n.timingFunction(a)),n.transitionId=i,this.prop(t,l,n),i||this.trigger("transition:end",this,t)}.bind(this);const{_scheduledTransitionIds:a}=this;let l;return l=setTimeout((o=>{a[t]&&(a[t]=wo(a[t],l),0===a[t].length&&delete a[t]),this.stopPendingTransitions(t,i),r=n.valueFunction(Ds(this.attributes,t,i),e),this._transitionIds[t]=Gs(o),this.trigger("transition:start",this,t)}),n.delay,s),a[t]||(a[t]=[]),a[t].push(l),l},getTransitions:function(){return Ao(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t,e="/"){const{_scheduledTransitionIds:n={}}=this;let i=Object.keys(n);if(t){const n=t.split(e);i=i.filter((t=>po(n,t.split(e).slice(0,n.length))))}return i.forEach((t=>{n[t].forEach((t=>clearTimeout(t))),delete n[t]})),this},stopPendingTransitions(t,e="/"){const{_transitionIds:n={}}=this;let i=Object.keys(n);if(t){const n=t.split(e);i=i.filter((t=>po(n,t.split(e).slice(0,n.length))))}i.forEach((t=>{const e=n[t];qs(e),delete n[t],this.trigger("transition:end",this,t)}))},stopTransitions:function(t,e="/"){return this.stopScheduledTransitions(t,e),this.stopPendingTransitions(t,e),this},addTo:function(t,e){return t.addCell(this,e),this},findView:function(t){return t.findViewByModel(this)},isElement:function(){return!1},isLink:function(){return!1},startBatch:function(t,e){return this.graph&&this.graph.startBatch(t,io({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,io({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(!t)return e;for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new Jt(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new Jt},getBBox:function(){return new me(0,0,0,0)},getPointRotatedAroundCenter(t,e,n){const i=new Jt(e,n);return t&&i.rotate(this.getBBox().center(),t),i},getAbsolutePointFromRelative(t,e){return this.getPointRotatedAroundCenter(-this.angle(),this.position().offset(t,e))},getRelativePointFromAbsolute(t,e){return this.getPointRotatedAroundCenter(this.angle(),t,e).difference(this.position())}},{getAttributeDefinition:function(t){var e=this.attributes,n=ol;return e&&e[t]||n[t]},define:function(t,e,n,i){n=io({defaults:oo({type:t},e,this.prototype.defaults)},n);var r=this.extend(n,i);return"undefined"!=typeof joint&&To(joint,"shapes")&&zs(joint.shapes,t,r,"."),r}});function ll(t,e,n){var i=t.toJSON();return i.angle=e||0,ro({},n,i)}function cl(t,e,n,i){return t.map((function(t,e,n){var r=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&r.offset(t.dx||0,t.dy||0),ll(r.round(),0,ul(i,t))}),ie(e,n))}function hl(t,e,n,i){var r=e.center(),o=e.width/e.height,s=e.topMiddle(),a=ae.fromRect(e);return t.map((function(t,l,c){var h=n+i(l,c.length),u=s.clone().rotate(r,-h).scale(o,1,r),d=t.compensateRotation?-a.tangentTheta(u):0;return(t.dx||t.dy)&&u.offset(t.dx||0,t.dy||0),t.dr&&u.move(r,t.dr),ll(u.round(),d,ul(e,t))}))}function ul(t,e){let{x:n,y:i,angle:r}=e;return Ys(n)?n=parseFloat(n)/100*t.width:Ba(n)&&(n=Number(Va(n,t))),Ys(i)?i=parseFloat(i)/100*t.height:Ba(i)&&(i=Number(Va(i,t))),{x:n,y:i,angle:r}}function dl(t,e){const{x:n,y:i}=ul(t,e);return new Jt(n||0,i||0)}const fl=function(t,e){return t.map((t=>{const n=dl(e,t).round().toJSON();return n.angle=t.angle||0,n}))},pl=function(t,e,n){return n.fn(t,e,n)},gl=function(t,e,n){return cl(t,dl(e,n.start||e.origin()),dl(e,n.end||e.corner()),e)},ml=function(t,e,n){return cl(t,e.origin(),e.bottomLeft(),e)},vl=function(t,e,n){return cl(t,e.topRight(),e.corner(),e)},yl=function(t,e,n){return cl(t,e.origin(),e.topRight(),e)},bl=function(t,e,n){return cl(t,e.bottomLeft(),e.corner(),e)},wl=function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return hl(t,e,i,(function(t){return t*r}))},xl=function(t,e,n){var i=n.startAngle||0,r=n.step||20;return hl(t,e,i,(function(t,e){return(t+.5-e/2)*r}))};function Al(t,e){return oo({},t,e,{x:0,y:0,angle:0,attrs:{}})}function Tl(t){var e=t.center(),n=e.theta(t.origin()),i=e.theta(t.bottomLeft()),r=e.theta(t.corner());return[n,e.theta(t.topRight()),r,i]}function El(t,e,n,i){i=ro({},i,{offset:15});var r,o,s,a,l=e.center().theta(t),c=i.offset,h=0;const[u,d,f,p]=Tl(e);l<d||l>f?(s=".3em",r=c,o=0,a="start"):l<u?(r=0,o=-c,n?(h=-90,a="start",s=".3em"):(a="middle",s="0")):l<p?(s=".3em",r=-c,o=0,a="end"):(r=0,o=c,n?(h=90,a="start",s=".3em"):(a="middle",s=".6em"));var g=Math.round;return Al(i,{x:g(r),y:g(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Pl(t,e,n,i){i=ro({},i,{offset:15});var r,o,s,a,l=e.center().theta(t),c=i.offset,h=0;const[u,d,f,p]=Tl(e);l<d||l>f?(s=".3em",r=-c,o=0,a="end"):l<u?(r=0,o=c,n?(h=90,a="start",s=".3em"):(a="middle",s=".6em")):l<p?(s=".3em",r=c,o=0,a="start"):(r=0,o=-c,n?(h=-90,a="start",s=".3em"):(a="middle",s="0"));var g=Math.round;return Al(i,{x:g(r),y:g(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Sl(t,e,n){n=ro({},n,{offset:20});var i,r=Qt(0,0),o=-t.theta(r),s=o,a=t.clone().move(r,n.offset).difference(t).round(),l=".3em";(o+90)%180==0?(i=e?"end":"middle",e||-270!==o||(l="0em")):o>-270&&o<-90?(i="start",s=o-180):i="end";var c=Math.round;return Al(n,{x:c(a.x),y:c(a.y),angle:e?s:0,attrs:{labelText:{y:l,textAnchor:i}}})}const _l=function(t,e,n){return Al(n)},kl=function(t,e,n){return Al(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},Ll=function(t,e,n){return Al(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},Cl=function(t,e,n){return Al(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})},Ml=function(t,e,n){return Al(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},Ol=function(t,e,n){return El(t,e,!0,n)},Nl=function(t,e,n){return El(t,e,!1,n)},Rl=function(t,e,n){return Pl(t,e,!0,n)},Fl=function(t,e,n){return Pl(t,e,!1,n)},Bl=function(t,e,n){return Sl(t.difference(e.center()),!1,n)},Il=function(t,e,n){return Sl(t.difference(e.center()),!0,n)};var Dl=function(t){var e=uo(t)||{};this.ports=[],this.groups={},this.portLayoutNamespace=s,this.portLabelLayoutNamespace=a,this._init(e)};Dl.prototype={getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(t){return this.ports.filter((function(e){return e.group===t}))},getGroupPortsMetrics:function(t,e){var n=this.getGroup(t),i=this.getPortsByGroup(t),r=n.position||{},o=r.name,s=this.portLayoutNamespace;s[o]||(o="left");var a=r.args||{},l=i.map((function(t){return t&&t.position&&t.position.args})),c=s[o](l,e,a),h={ports:i,result:[]};return vo(c).reduce(function(t,n,i){var r=t.ports[i];return t.result.push({portId:r.id,portTransformation:n,labelTransformation:this._getPortLabelLayout(r,Jt(n),e),portAttrs:r.attrs,portSize:r.size,labelSize:r.label.size}),t}.bind(this),h),h.result},_getPortLabelLayout:function(t,e,n){var i=this.portLabelLayoutNamespace,r=t.label.position.name||"left";return i[r]?i[r](e,n,t.label.position.args):null},_init:function(t){if(to(t.groups))for(var e=Object.keys(t.groups),n=0,i=e.length;n<i;n++){var r=e[n];this.groups[r]=this._evaluateGroup(t.groups[r])}for(var o=vo(t.items),s=0,a=o.length;s<a;s++)this.ports.push(this._evaluatePort(o[s]))},_evaluateGroup:function(t){return Mo(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=io({},t),n=this.getGroup(t.group);return e.markup=e.markup||n.markup,e.attrs=Mo({},n.attrs,e.attrs),e.position=this._createPositionNode(n,e),e.label=Mo({},n.label,this._getLabel(e)),e.z=this._getZIndex(n,e),e.size=io({},n.size,e.size),e},_getZIndex:function(t,e){return eo(e.z)?e.z:eo(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return Mo({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var n,i={};go(t)?(n="fn",i.fn=t):no(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):to(t)&&(n=t.name,io(i,t.args));var r={args:i};return n&&(r.name=n),r},_getLabel:function(t,e){var n=t.label||{},i=n;return i.position=this._getPosition(n.position,e),i}};const Vl={_initializePorts:function(){this._createPortData(),this.on("change:ports",(function(){this._processRemovedPort(),this._createPortData()}),this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={};vo(t.items).forEach((function(t){e[t.id]=!0}));var n=this.previous("ports")||{},i={};vo(n.items).forEach((function(t){e[t.id]||(i[t.id]=!0)}));var r=this.graph;r&&!fo(i)&&(r.getConnectedLinks(this,{inbound:!0}).forEach((function(t){i[t.get("target").port]&&t.remove()})),r.getConnectedLinks(this,{outbound:!0}).forEach((function(t){i[t.get("source").port]&&t.remove()})))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&t.length>0},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return uo(this.prop("ports/items"))||[]},getGroupPorts:function(t){const e=vo(this.prop(["ports","items"])).filter((e=>e.group===t));return uo(e)},getPort:function(t){return uo(vo(this.prop("ports/items")).find((function(e){return e.id&&e.id===t})))},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,me(this.size())).reduce((function(t,e){var n=e.portTransformation;return t[e.portId]={x:n.x,y:n.y,angle:n.angle},t}),{})},getPortIndex:function(t){var e=to(t)?t.id:t;return this._isValidPortId(e)?vo(this.prop("ports/items")).findIndex((function(t){return t.id===e})):-1},addPort:function(t,e){if(!to(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=io([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){const i="number"==typeof t?t:this.getPortIndex(t);if(!to(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");const r=io([],this.prop("ports/items"));return r.splice(i,0,e),this.prop("ports/items",r,n),this},portProp:function(t,e,n,i){var r=this.getPortIndex(t);if(-1===r)throw new Error("Element: unable to find port with id "+t);var o=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?o[0]=["ports","items",r].concat(e):no(e)?o[0]=["ports/items/",r,"/",e].join(""):(o=["ports/items/"+r],mo(e)&&(o.push(e),o.push(n))),this.prop.apply(this,o)},_validatePorts:function(){var t=this.get("ports")||{},e=[],n=vo((t=t||{}).items);return n.forEach((function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())}),this),co(n,"id").length!==n.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!to(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",io([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){const n=e||{},i=this.getPortIndex(t);if(-1!==i){const t=io([],this.prop(["ports","items"]));t.splice(i,1),n.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],t,n),this.stopBatch("port-remove")}return this},removePorts:function(t,e){let n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;i=io([],this.prop(["ports","items"])).filter((function(e){return!t.some((function(t){const n=to(t)?t.id:t;return e.id===n}))}))}else n=t||{},i=[];return this.startBatch("port-remove"),n.rewrite=!0,this.prop(["ports","items"],i,n),this.stopBatch("port-remove"),this},_createPortData:function(){var t,e=this._validatePorts();if(e.length>0)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new Dl(this.get("ports"));var n=this._portSettingsData.getPorts();if(t){var i=n.filter((function(e){if(!t.find((function(t){return t.id===e.id})))return e})),r=t.filter((function(t){if(!n.find((function(e){return e.id===t.id})))return t}));r.length>0&&this.trigger("ports:remove",this,r),i.length>0&&this.trigger("ports:add",this,i)}}},zl={portContainerMarkup:"g",portMarkup:[{tagName:"circle",selector:"circle",attributes:{r:10,fill:"#FFFFFF",stroke:"#000000"}}],portLabelMarkup:[{tagName:"text",selector:"text",attributes:{fill:"#000000"}}],_portElementsCache:null,_initializePorts:function(){this._cleanPortsCache()},_refreshPorts:function(){this._removePorts(),this._cleanPortsCache(),this._renderPorts()},_cleanPortsCache:function(){this._portElementsCache={}},_renderPorts:function(){for(var t=[],e=this._getContainerElement(),n=0,i=e.node.childNodes.length;n<i;n++)t.push(e.node.childNodes[n]);var r,o,s=(r=this.model._portSettingsData.getPorts(),o=zr(o="z",2),function(t,e,n){return(Array.isArray(t)?jr:$r)(t,e,n,arguments.length<3,Mr)}(r,((t,e,n)=>(n=o(e),hasOwnProperty.call(t,n)?t[n].push(e):$i(t,n,[e]),t)),{})),a="auto";vo(s[a]).forEach((function(n){var i=this._getPortElement(n);e.append(i),t.push(i)}),this);for(var l=Object.keys(s),c=0;c<l.length;c++){var h=l[c];if(h!==a){var u=parseInt(h,10);this._appendPorts(s[h],u,t)}}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),r=vo(t).map(this._getPortElement,this);n[e]||e<0?An(n[Math.max(e,0)]).before(r):i.append(r)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){const n=this._portElementsCache[t];if(!n)return[];if(!e)return[n.portContentElement.node];const i=n.portElement.node,r=n.portSelectors;return this.findBySelector(e,i,r)},findPortNode:function(t,e){const[n=null]=this.findPortNodes(t,e);return n},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){so(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){let e,n,i,r;var o=An(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t);if(Array.isArray(s)){var a=this.parseDOMJSON(s,o.node),l=a.fragment;e=l.childNodes.length>1?An("g").append(l):An(l.firstChild),r=a.selectors}else e=An(s),Array.isArray(e)&&(e=An("g").append(e));if(!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group}),eo(t.id)&&e.attr("port-id-type","number");const c=this._getPortLabelMarkup(t.label);if(Array.isArray(c)){const{fragment:t,selectors:e}=this.parseDOMJSON(c,o.node),r=t.childNodes.length;r>0&&(i=e,n=1===r?An(t.firstChild):An("g").append(t))}else n=An(c),Array.isArray(n)&&(n=An("g").append(n));var h;if(r&&i){for(var u in i)if(r[u]&&u!==this.selector)throw new Error("ElementView: selectors within port must be unique.");h=io({},r,i)}else h=r||i||{};const d="portRoot",f="labelRoot",p="labelText";if(d in h||(h[d]=e.node),n){const t=n.node;if(f in h||(h[f]=t),!(p in h)){const e="TEXT"===n.tagName()?t:Array.from(t.querySelectorAll("text"));h[p]=e,i||(i={}),i[p]=e}}return o.append(e.addClass("joint-port-body")),n&&o.append(n.addClass("joint-port-label")),this._portElementsCache[t.id]={portElement:o,portLabelElement:n,portSelectors:h,portLabelSelectors:i,portContentElement:e,portContentSelectors:r},o},_updatePortGroup:function(t){for(var e=me(this.model.size()),n=this.model._portSettingsData.getGroupPortsMetrics(t,e),i=0,r=n.length;i<r;i++){var o=n[i],s=o.portId,a=this._portElementsCache[s]||{},l=o.portTransformation,c=o.labelTransformation;c&&a.portLabelElement&&(this.updateDOMSubtreeAttributes(a.portLabelElement.node,c.attrs,{rootBBox:new me(o.labelSize),selectors:a.portLabelSelectors}),this.applyPortTransform(a.portLabelElement,c,-l.angle||0)),this.updateDOMSubtreeAttributes(a.portElement.node,o.portAttrs,{rootBBox:new me(o.portSize),selectors:a.portSelectors}),this.applyPortTransform(a.portElement,l)}},applyPortTransform:function(t,e,n){var i=An.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(i,{absolute:!0})},_getPortMarkup:function(t){return t.markup||this.model.get("portMarkup")||this.model.portMarkup||this.portMarkup},_getPortLabelMarkup:function(t){return t.markup||this.model.get("portLabelMarkup")||this.model.portLabelMarkup||this.portLabelMarkup}},jl=al.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),al.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){const i=eo(e);n=(i?n:t)||{};const{parentRelative:r,deep:o,restrictedArea:s}=n;let a;if(r){if(!this.graph)throw new Error("Element must be part of a graph.");const t=this.getParentCell();t&&!t.isLink()&&(a=t.get("position"))}if(i){if(a&&(t+=a.x,e+=a.y),o||s){const{x:i,y:r}=this.get("position");this.translate(t-i,e-r,n)}else this.set("position",{x:t,y:e},n);return this}{const t=Jt(this.get("position"));return r?t.difference(a):t}},translate:function(t,e,n){if(e=e||0,0===(t=t||0)&&0===e)return this;(n=n||{}).translateBy=n.translateBy||this.id;var i=this.get("position")||{x:0,y:0},r=n.restrictedArea;if(r&&n.translateBy===this.id)if("function"==typeof r){var o=r.call(this,i.x+t,i.y+e,n);t=o.x-i.x,e=o.y-i.y}else{var s=this.getBBox({deep:!0}),a=i.x-s.x,l=i.y-s.y,c=Math.max(r.x+a,Math.min(r.x+r.width+a-s.width,i.x+t)),h=Math.max(r.y+l,Math.min(r.y+r.height+l-s.height,i.y+e));t=c-i.x,e=h-i.y}var u={x:i.x+t,y:i.y+e};return n.tx=t,n.ty=e,n.transition?(to(n.transition)||(n.transition={}),this.transition("position",u,io({},n.transition,{valueFunction:ea.object})),so(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",u,n),so(this.getEmbeddedCells(),"translate",t,e,n),this.stopBatch("translate",n)),this},size:function(t,e,n){var i=this.get("size");return void 0===t?{width:i.width,height:i.height}:(to(t)&&(n=e,e=eo(t.height)?t.height:i.height,t=eo(t.width)?t.width:i.width),this.resize(t,e,n))},resize:function(t,e,n){if(n=n||{},this.startBatch("resize",n),n.direction){var i=this.get("size");switch(n.direction){case"left":case"right":e=i.height;break;case"top":case"bottom":t=i.width}var r,o=Ct(this.get("angle")||0),s=this.getBBox();if(o){var a={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction];n.absolute&&(a+=Math.floor((o+45)/90),a%=4);var l=s[["bottomLeft","corner","topRight","origin"][a]](),c=Jt(l).rotate(s.center(),-o),h=Math.sqrt(t*t+e*e)/2,u=a*Math.PI/2;u+=Math.atan(a%2==0?e/t:t/e),u-=Nt(o);var d=Jt.fromPolar(h,u,c);r=Jt(d).offset(t/-2,e/-2)}else switch(r=s.topLeft(),n.direction){case"top":case"top-right":r.offset(0,s.height-e);break;case"left":case"bottom-left":r.offset(s.width-t,0);break;case"top-left":r.offset(s.width-t,s.height-e)}this.set("size",{width:t,height:e},n),this.position(r.x,r.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){var r=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(r.x,r.y,i),this.resize(r.width,r.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(t={}){const{graph:e}=this;if(!e)throw new Error("Element must be part of a graph.");const n=this.getEmbeddedCells().filter((t=>t.isElement()));return 0===n.length||(this.startBatch("fit-embeds",t),t.deep&&so(n,"fitToChildren",t),this._fitToElements(Object.assign({elements:n},t)),this.stopBatch("fit-embeds")),this},fitParent:function(t={}){const{graph:e}=this;if(!e)throw new Error("Element must be part of a graph.");if(t.deep&&t.terminator&&(t.terminator===this||t.terminator===this.id))return this;const n=this.getParentCell();if(!n||!n.isElement())return this;const i=n.getEmbeddedCells().filter((t=>t.isElement()));return 0===i.length||(this.startBatch("fit-parent",t),n._fitToElements(Object.assign({elements:i},t)),t.deep&&n.fitParent(t),this.stopBatch("fit-parent")),this},_fitToElements:function(t={}){const e=this.graph.getCellsBBox(t.elements);if(!e)return;const{expandOnly:n,shrinkOnly:i}=t;if(n&&i)return;let{x:r,y:o,width:s,height:a}=e;const{left:l,right:c,top:h,bottom:u}=Qs(t.padding);r-=l,o-=h,s+=l+c,a+=u+h;let d=new me(r,o,s,a);if(n)d=this.getBBox().union(d);else if(i){const t=this.getBBox().intersect(d);if(!t)return;d=t}this.set({position:{x:d.x,y:d.y},size:{width:d.width,height:d.height}},t)},rotate:function(t,e,n,i){if(n){var r=this.getBBox().center(),o=this.get("size"),s=this.get("position");r.rotate(n,this.get("angle")-t);var a=r.x-o.width/2-s.x,l=r.y-o.height/2-s.y;this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(s.x+a,s.y+l,i),this.rotate(t,e,null,i),this.stopBatch("rotate")}else this.set("angle",e?t:(this.get("angle")+t)%360,i);return this},angle:function(){return Ct(this.get("angle")||0)},getBBox:function(t={}){const{graph:e,attributes:n}=this,{deep:i,rotate:r}=t;if(i&&e){const n=this.getEmbeddedCells({deep:!0,breadthFirst:!0});return n.push(this),e.getCellsBBox(n,t)}const{angle:o=0,position:{x:s,y:a},size:{width:l,height:c}}=n,h=new me(s,a,l,c);return r&&h.rotateAroundCenter(o),h},getPointFromConnectedLink:function(t,e){var n=this.getBBox(),i=n.center(),r=t.get(e);if(!r)return i;var o=r.port;if(!o||!this.hasPort(o))return i;var s=this.portProp(o,["group"]),a=this.getPortsPositions(s),l=new Jt(a[o]).offset(n.origin()),c=this.angle();return c&&l.rotate(i,-c),l}});io(jl.prototype,Vl);const $l=al.extend({defaultLabel:void 0,labelMarkup:void 0,_builtins:{defaultLabel:{markup:[{tagName:"rect",selector:"rect"},{tagName:"text",selector:"text"}],attrs:{text:{fill:"#000000",fontSize:14,textAnchor:"middle",textVerticalAnchor:"middle",pointerEvents:"none"},rect:{ref:"text",fill:"#ffffff",rx:3,ry:3,x:"calc(x)",y:"calc(y)",width:"calc(w)",height:"calc(h)"}},position:{distance:.5}}},defaults:{source:{},target:{}},isLink:function(){return!0},disconnect:function(t){return this.set({source:{x:0,y:0},target:{x:0,y:0}},t)},source:function(t,e,n){return void 0===t?ho(this.get("source")):t instanceof al?((i=ho(e)||{}).id=t.id,r=n,this.set("source",i,r)):mo(t)?(i=t,r=e,this.set("source",i,r)):((i=ho(e)||{}).x=t.x,i.y=t.y,r=n,this.set("source",i,r));var i,r},target:function(t,e,n){return void 0===t?ho(this.get("target")):t instanceof al?((i=ho(e)||{}).id=t.id,r=n,this.set("target",i,r)):mo(t)?(i=t,r=e,this.set("target",i,r)):((i=ho(e)||{}).x=t.x,i.y=t.y,r=n,this.set("target",i,r));var i,r},router:function(t,e,n){if(void 0===t){var i=this.get("router");return i?"object"==typeof i?ho(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},s=r?e:n;return this.set("router",o,s)},connector:function(t,e,n){if(void 0===t){var i=this.get("connector");return i?"object"==typeof i?ho(i):i:null}var r="object"==typeof t||"function"==typeof t,o=r?t:{name:t,args:e},s=r?e:n;return this.set("connector",o,s)},label:function(t,e,n){var i=this.labels();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1?this.prop(["labels",t]):this.prop(["labels",t],e,n)},labels:function(t,e){return 0===arguments.length?(t=this.get("labels"),Array.isArray(t)?t.slice():[]):(Array.isArray(t)||(t=[]),this.set("labels",t,e))},hasLabels:function(){const{labels:t}=this.attributes;return Array.isArray(t)&&t.length>0},insertLabel:function(t,e,n){if(!e)throw new Error("dia.Link: no label provided");var i=this.labels(),r=i.length;return(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),i.splice(t,0,e),this.labels(i,n)},appendLabel:function(t,e){return this.insertLabel(-1,t,e)},removeLabel:function(t,e){var n=this.labels();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.labels(n,e)},vertex:function(t,e,n){var i=this.vertices();if((t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1)return this.prop(["vertices",t]);var r=this._normalizeVertex(e);return this.prop(["vertices",t],r,n)},vertices:function(t,e){if(0===arguments.length)return t=this.get("vertices"),Array.isArray(t)?t.slice():[];Array.isArray(t)||(t=[]);for(var n=[],i=0;i<t.length;i++){var r=t[i],o=this._normalizeVertex(r);n.push(o)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){if(!e)throw new Error("dia.Link: no vertex provided");var i=this.vertices(),r=i.length;(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1);var o=this._normalizeVertex(e);return i.splice(t,0,o),this.vertices(i,n)},removeVertex:function(t,e){var n=this.vertices();return t=isFinite(t)&&null!==t?0|t:-1,n.splice(t,1),this.vertices(n,e)},_normalizeVertex:function(t){return mo(t)?t:{x:t.x,y:t.y}},translate:function(t,e,n){return(n=n||{}).translateBy=n.translateBy||this.id,n.tx=t,n.ty=e,this.applyToPoints((function(n){return{x:(n.x||0)+t,y:(n.y||0)+e}}),n)},scale:function(t,e,n,i){return this.applyToPoints((function(i){return Jt(i).scale(t,e,n).toJSON()}),i)},applyToPoints:function(t,e){if(!go(t))throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.");var n={},{source:i,target:r}=this.attributes;i.id||(n.source=t(i)),r.id||(n.target=t(r));var o=this.vertices();return o.length>0&&(n.vertices=o.map(t)),this.set(n,e)},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new Jt(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new Jt(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){const t=[this.getSourcePoint(),...this.vertices().map(Jt),this.getTargetPoint()];return new xe(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e;if(this.graph){var n=this.getSourceElement(),i=this.getTargetElement(),r=this.getParentCell();n&&i&&(e=n===i||n.isEmbeddedIn(i)?i:i.isEmbeddedIn(n)?n:this.graph.getCommonAncestor(n,i)),!r||e&&e.id===r.id||r.unembed(this,t),e&&e.embed(this,t)}return e},hasLoop:function(t){t=t||{};var{source:e,target:n}=this.attributes,i=e.id,r=n.id;if(!i||!r)return!1;var o=i===r;if(!o&&t.deep&&this.graph){var s=this.getSourceCell(),a=this.getTargetCell();o=s.isEmbeddedIn(a)||a.isEmbeddedIn(s)}return o},getSourceCell:function(){const{graph:t,attributes:e}=this;var n=e.source;return n&&n.id&&t&&t.getCell(n.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getSourceCell()}while(t&&t.isLink());return t},getTargetCell:function(){const{graph:t,attributes:e}=this;var n=e.target;return n&&n.id&&t&&t.getCell(n.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null;e[t.id]=!0,t=t.getTargetCell()}while(t&&t.isLink());return t},getRelationshipAncestor:function(){var t;if(this.graph){var e=[this,this.getSourceElement(),this.getTargetElement()].filter((function(t){return!!t}));t=this.graph.getCommonAncestor.apply(this.graph,e)}return t||null},isRelationshipEmbeddedIn:function(t){var e=no(t)||eo(t)?t:t.id,n=this.getRelationshipAncestor();return!!n&&(n.id===e||n.isEmbeddedIn(e))},_getDefaultLabel:function(){var t=this.get("defaultLabel")||this.defaultLabel||{},e={};return e.markup=t.markup||this.get("labelMarkup")||this.labelMarkup,e.position=t.position,e.attrs=t.attrs,e.size=t.size,e}},{endsEqual:function(t,e){var n=t.port===e.port||!t.port&&!e.port;return t.id===e.id&&n}}),Ul={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))}},addTest:function(t,e){return this._tests[t]=e},test:function(t){var e=this._tests[t];if(!e)throw new Error('Test not defined ("'+t+'"). Use `joint.env.addTest(name, fn) to add a new test.`');var n=this._results[t];if(void 0!==n)return n;try{n=e()}catch(t){n=!1}return this._results[t]=n,n}},Gl=jl.define("standard.Rectangle",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}]}),ql=jl.define("standard.Circle",{attrs:{root:{cursor:"move"},body:{cx:"calc(s/2)",cy:"calc(s/2)",r:"calc(s/2)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"circle",selector:"body"},{tagName:"text",selector:"label"}]}),Hl=jl.define("standard.Ellipse",{attrs:{root:{cursor:"move"},body:{cx:"calc(w/2)",cy:"calc(h/2)",rx:"calc(w/2)",ry:"calc(h/2)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"body"},{tagName:"text",selector:"label"}]}),Wl=jl.define("standard.Path",{attrs:{root:{cursor:"move"},body:{d:"M 0 0 H calc(w) V calc(h) H 0 Z",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}]}),Yl=jl.define("standard.Polygon",{attrs:{root:{cursor:"move"},body:{points:"0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polygon",selector:"body"},{tagName:"text",selector:"label"}]}),Xl=jl.define("standard.Polyline",{attrs:{root:{cursor:"move"},body:{points:"0 0 calc(w) 0 calc(w) calc(h) 0 calc(h)",strokeWidth:2,stroke:"#333333",fill:"#FFFFFF"},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"polyline",selector:"body"},{tagName:"text",selector:"label"}]}),Zl=jl.define("standard.Image",{attrs:{root:{cursor:"move"},image:{width:"calc(w)",height:"calc(h)"},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Kl=jl.define("standard.BorderedImage",{attrs:{root:{cursor:"move"},border:{width:"calc(w)",height:"calc(h)",stroke:"#333333",strokeWidth:2},background:{width:"calc(w-1)",height:"calc(h-1)",x:.5,y:.5,fill:"#FFFFFF"},image:{width:"calc(w-1)",height:"calc(h-1)",x:.5,y:.5},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"background",attributes:{stroke:"none"}},{tagName:"image",selector:"image"},{tagName:"rect",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),Jl=jl.define("standard.EmbeddedImage",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",stroke:"#333333",fill:"#FFFFFF",strokeWidth:2},image:{width:"calc(0.3*w)",height:"calc(h-20)",x:10,y:10,preserveAspectRatio:"xMidYMin"},label:{textVerticalAnchor:"top",textAnchor:"left",x:"calc(0.3*w+20)",y:10,fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"image",selector:"image"},{tagName:"text",selector:"label"}]}),Ql=jl.define("standard.InscribedImage",{attrs:{root:{cursor:"move"},border:{rx:"calc(w/2)",ry:"calc(h/2)",cx:"calc(w/2)",cy:"calc(h/2)",stroke:"#333333",strokeWidth:2},background:{rx:"calc(w/2)",ry:"calc(h/2)",cx:"calc(w/2)",cy:"calc(h/2)",fill:"#FFFFFF"},image:{width:"calc(0.68*w)",height:"calc(0.68*h)",x:"calc(0.16*w)",y:"calc(0.16*h)",preserveAspectRatio:"xMidYMid"},label:{textVerticalAnchor:"top",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+10)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"ellipse",selector:"background"},{tagName:"image",selector:"image"},{tagName:"ellipse",selector:"border",attributes:{fill:"none"}},{tagName:"text",selector:"label"}]}),tc=jl.define("standard.HeaderedRectangle",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},header:{width:"calc(w)",height:30,strokeWidth:2,stroke:"#000000",fill:"#FFFFFF"},headerText:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:15,fontSize:16,fill:"#333333"},bodyText:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h/2+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"rect",selector:"body"},{tagName:"rect",selector:"header"},{tagName:"text",selector:"headerText"},{tagName:"text",selector:"bodyText"}]}),ec=jl.define("standard.Cylinder",{attrs:{root:{cursor:"move"},body:{lateralArea:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},top:{cx:"calc(w/2)",cy:10,rx:"calc(w/2)",ry:10,fill:"#FFFFFF",stroke:"#333333",strokeWidth:2},label:{textVerticalAnchor:"middle",textAnchor:"middle",x:"calc(w/2)",y:"calc(h+15)",fontSize:14,fill:"#333333"}}},{markup:[{tagName:"path",selector:"body"},{tagName:"ellipse",selector:"top"},{tagName:"text",selector:"label"}],topRy:function(t,e){if(void 0===t)return this.attr("body/lateralArea");var n={lateralArea:t},i=Ys(t)?`calc(${parseFloat(t)/100}*h)`:t,r={cy:i,ry:i};return this.attr({body:n,top:r},e)}},{attributes:{"lateral-area":{set:function(t,e){var n=Ys(t);n&&(t=parseFloat(t)/100);var i=e.x,r=e.y,o=e.width,s=e.height,a=o/2,l=n?s*t:t,c=An.KAPPA,h=c*a,u=c*(n?s*t:t),d=i+o/2,f=i+o,p=r+l,g=p-l,m=r+s-l,v=r+s;return{d:["M",i,p,"L",i,m,"C",i,m+u,d-h,v,d,v,"C",d+h,v,f,m+u,f,m,"L",f,p,"C",f,p-u,d+h,g,d,g,"C",d-h,g,i,p-u,i,p,"Z"].join(" ")}}}}});var nc=Ul.test("svgforeignobject")?{tagName:"foreignObject",selector:"foreignObject",attributes:{overflow:"hidden"},children:[{tagName:"div",namespaceURI:"http://www.w3.org/1999/xhtml",selector:"label",style:{width:"100%",height:"100%",position:"static",backgroundColor:"transparent",textAlign:"center",margin:0,padding:"0px 5px",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center"}}]}:{tagName:"text",selector:"label",attributes:{"text-anchor":"middle"}};const ic=jl.define("standard.TextBlock",{attrs:{root:{cursor:"move"},body:{width:"calc(w)",height:"calc(h)",stroke:"#333333",fill:"#ffffff",strokeWidth:2},foreignObject:{width:"calc(w)",height:"calc(h)"},label:{style:{fontSize:14}}}},{markup:[{tagName:"rect",selector:"body"},nc]},{attributes:{text:{set:function(t,e,n,i){if(!(n instanceof HTMLElement)){var r=i.style||{},o={text:t,width:-5,height:"100%"},s=io({"text-vertical-anchor":"middle"},r);return ol["text-wrap"].set.call(this,o,e,n,s),{fill:r.color||null}}n.textContent=t},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),rc=$l.define("standard.Link",{attrs:{line:{connection:!0,stroke:"#333333",strokeWidth:2,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 10 -5 0 0 10 5 z"}},wrapper:{connection:!0,strokeWidth:10,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"wrapper",attributes:{fill:"none",cursor:"pointer",stroke:"transparent","stroke-linecap":"round"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),oc=$l.define("standard.DoubleLink",{attrs:{line:{connection:!0,stroke:"#DDDDDD",strokeWidth:4,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"#000000",d:"M 10 -3 10 -10 -2 0 10 10 10 3"}},outline:{connection:!0,stroke:"#000000",strokeWidth:6,strokeLinejoin:"round"}}},{markup:[{tagName:"path",selector:"outline",attributes:{fill:"none",cursor:"pointer"}},{tagName:"path",selector:"line",attributes:{fill:"none","pointer-events":"none"}}]}),sc=$l.define("standard.ShadowLink",{attrs:{line:{connection:!0,stroke:"#FF0000",strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",stroke:"none",d:"M 0 -10 -10 0 0 10 z"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}},shadow:{connection:!0,transform:"translate(3,6)",stroke:"#000000",strokeOpacity:.2,strokeWidth:20,strokeLinejoin:"round",targetMarker:{type:"path",d:"M 0 -10 -10 0 0 10 z",stroke:"none"},sourceMarker:{type:"path",stroke:"none",d:"M -10 -10 0 0 -10 10 0 10 0 -10 z"}}}},{markup:[{tagName:"path",selector:"shadow",attributes:{fill:"none","pointer-events":"none"}},{tagName:"path",selector:"line",attributes:{fill:"none",cursor:"pointer"}}]}),ac={TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left",TOP_LEFT:"top-left",TOP_RIGHT:"top-right",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right",CENTER:"center"};function lc(t,e){const n=new me(t);switch(e){case void 0:throw new Error("Position required");case ac.LEFT:case"leftMiddle":return n.leftMiddle();case ac.RIGHT:case"rightMiddle":return n.rightMiddle();case ac.TOP:case"topMiddle":return n.topMiddle();case ac.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case ac.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case ac.TOP_RIGHT:case"topRight":return n.topRight();case ac.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case ac.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case ac.CENTER:return n.center();default:throw new Error(`Unknown position: ${e}`)}}var cc=function(t,e){e||(e={}),this.preinitialize.apply(this,arguments),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,io({silent:!0},e))},hc={add:!0,remove:!0,merge:!0},uc={add:!0,remove:!1},dc=function(t,e,n){n=Math.min(Math.max(n,0),t.length);var i,r=Array(t.length-n),o=e.length;for(i=0;i<r.length;i++)r[i]=t[i+n];for(i=0;i<o;i++)t[i+n]=e[i];for(i=0;i<r.length;i++)t[i+o+n]=r[i]};io(cc.prototype,oa,{model:ba,preinitialize:function(){},initialize:function(){},toJSON:function(t){return this.map((function(e){return e.toJSON(t)}))},add:function(t,e){return this.set(t,io({merge:!1},e,uc))},remove:function(t,e){e=io({},e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=this._removeModels(t,e);return!e.silent&&i.length&&(e.changes={added:[],merged:[],removed:i},this.trigger("update",this,e)),n?i[0]:i},set:function(t,e){if(null!=t){e=io({},hc,e);var n=!Array.isArray(t);t=n?[t]:t.slice();var i=e.at;null!=i&&(i=+i),i>this.length&&(i=this.length),i<0&&(i+=this.length+1);var r,o,s=[],a=[],l=[],c=[],h={},u=e.add,d=e.merge,f=e.remove,p=!1,g=this.comparator&&null==i&&!1!==e.sort,m=no(this.comparator)?this.comparator:null;for(o=0;o<t.length;o++){r=t[o];var v=this.get(r);if(v){if(d&&r!==v){var y=this._isModel(r)?r.attributes:r;v.set(y,e),l.push(v),g&&!p&&(p=v.hasChanged(m))}h[v.cid]||(h[v.cid]=!0,s.push(v)),t[o]=v}else u&&(r=t[o]=this._prepareModel(r,e))&&(a.push(r),this._addReference(r,e),h[r.cid]=!0,s.push(r))}if(f){for(o=0;o<this.length;o++)h[(r=this.models[o]).cid]||c.push(r);c.length&&this._removeModels(c,e)}var b=!1,w=!g&&u&&f;if(s.length&&w?(b=this.length!==s.length||this.models.some((function(t,e){return t!==s[e]})),this.models.length=0,dc(this.models,s,0),this.length=this.models.length):a.length&&(g&&(p=!0),dc(this.models,a,null==i?this.length:i),this.length=this.models.length),p&&this.sort({silent:!0}),!e.silent){for(o=0;o<a.length;o++)null!=i&&(e.index=i+o),(r=a[o]).trigger("add",r,this,e);(p||b)&&this.trigger("sort",this,e),(a.length||c.length||l.length)&&(e.changes={added:a,removed:c,merged:l},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?ho(e):{};for(var n=0;n<this.models.length;n++)this._removeReference(this.models[n],e);return e.previousModels=this.models,this._reset(),t=this.add(t,io({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,io({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);return this.remove(e,t)},unshift:function(t,e){return this.add(t,io({at:0},e))},shift:function(t){var e=this.at(0);return this.remove(e,t)},slice:function(){return Array.prototype.slice.apply(this.models,arguments)},get:function(t){if(null!=t)return this._byId[t]||this._byId[this.modelId(this._isModel(t)?t.attributes:t,t.idAttribute)]||t.cid&&this._byId[t.cid]},has:function(t){return null!=this.get(t)},at:function(t){return t<0&&(t+=this.length),this.models[t]},sort:function(t){var e=this.comparator;if(!e)throw new Error("Cannot sort a set without a comparator");t||(t={});var n=e.length;return go(e)&&(e=e.bind(this)),1===n||no(e)?this.models=this.sortBy(e):this.models.sort(e),t.silent||this.trigger("sort",this,t),this},clone:function(){return new this.constructor(this.models,{model:this.model,comparator:this.comparator})},modelId:function(t,e){return t[e||this.model.prototype.idAttribute||"id"]},values:function(){return new gc(this,mc)},keys:function(){return new gc(this,vc)},entries:function(){return new gc(this,yc)},each:function(t,e){this.models.forEach(t,e)},filter:function(t,e){return this.models.filter(t,e)},find:function(t,e){return this.models.find(t,e)},findIndex:function(t,e){return this.models.findIndex(t,e)},first:function(){return this.models[0]},includes:function(t){return this.models.includes(t)},last:function(){return this.models[this.models.length-1]},isEmpty:function(){return!this.models.length},map:function(t,e){return this.models.map(t,e)},reduce:function(t,e=this.first()){return this.models.reduce(t,e)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(t,e){return this._isModel(t)?(t.collection||(t.collection=this),t):((e=e?ho(e):{}).collection=this,(n=this.model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,n.validationError,e),!1):n);var n},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r=this.get(t[i]);if(r){var o=this.models.indexOf(r);this.models.splice(o,1),this.length--,delete this._byId[r.cid];var s=this.modelId(r.attributes,r.idAttribute);null!=s&&delete this._byId[s],e.silent||(e.index=o,r.trigger("remove",r,this,e)),n.push(r),this._removeReference(r,e)}}return t.length>0&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof ba},_addReference:function(t,e){this._byId[t.cid]=t;var n=this.modelId(t.attributes,t.idAttribute);null!=n&&(this._byId[n]=t),t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){delete this._byId[t.cid];var n=this.modelId(t.attributes,t.idAttribute);null!=n&&delete this._byId[n],this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,n,i){if(e){if(("add"===t||"remove"===t)&&n!==this)return;if("changeId"===t){var r=this.modelId(e.previousAttributes(),e.idAttribute),o=this.modelId(e.attributes,e.idAttribute);null!=r&&delete this._byId[r],null!=o&&(this._byId[o]=e)}}this.trigger.apply(this,arguments)}});var fc="function"==typeof Symbol&&Symbol.iterator;fc&&(cc.prototype[fc]=cc.prototype.values);var pc,gc=function(t,e){this._collection=t,this._kind=e,this._index=0},mc=1,vc=2,yc=3;fc&&(gc.prototype[fc]=function(){return this}),gc.prototype.next=function(){if(this._collection){if(this._index<this._collection.length){var t,e=this._collection.at(this._index);if(this._index++,this._kind===mc)t=e;else{var n=this._collection.modelId(e.attributes,e.idAttribute);t=this._kind===vc?n:[n,e]}return{value:t,done:!1}}this._collection=void 0}return{value:void 0,done:!0}},function(t,e,n,i){_o(n,(function(n,r){e[r]&&(t.prototype[r]=function(t,e,n,i){switch(e){case 1:return function(){return t[n](this[i])};case 2:return function(e){return t[n](this[i],e)};case 3:return function(e,r){return t[n](this[i],va(e,this),r)};case 4:return function(e,r,o){return t[n](this[i],va(e,this),r,o)};default:return function(){var e=Array.prototype.slice.call(arguments);return e.unshift(this[i]),t[n].apply(t,e)}}}(e,n,r,i))}))}((pc=[cc,{toArray:1,sortBy:3},"models"])[0],{sortBy:yo,toArray:vo},pc[1],pc[2]),cc.extend=ma;const bc={cells:function(t){return function(){var e=Array.from(arguments),n=e.length,i=n>0&&e[0]||[],r=n>1&&e[n-1]||{};return Array.isArray(i)||(r instanceof al?i=e:i instanceof al&&(e.length>1&&e.pop(),i=e)),r instanceof al&&(r={}),t.call(this,i,r)}}},wc=cc.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace="undefined"!=typeof joint&&To(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){const n=e.collection,i=n.cellNamespace,{type:r}=t,o=Ds(i,r,".");if(!o)throw new Error(`dia.Graph: Could not find cell constructor for type: '${r}'. Make sure to add the constructor to 'cellNamespace'.`);const s=new o(t,e);return e.dry||(s.graph=n.graph),s},comparator:function(t){return t.get("z")||0}}),xc=ba.extend({initialize:function(t,e){var n=new wc([],{model:(e=e||{}).cellModel,cellNamespace:e.cellNamespace,graph:this});ba.prototype.set.call(this,"cells",n),n.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},n.on("add",this._restructureOnAdd,this),n.on("remove",this._restructureOnRemove,this),n.on("reset",this._restructureOnReset,this),n.on("change:source",this._restructureOnChangeSource,this),n.on("change:target",this._restructureOnChangeTarget,this),n.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){if(t.isLink()){this._edges[t.id]=!0;var{source:e,target:n}=t.attributes;e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0),n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)}else this._nodes[t.id]=!0},_restructureOnRemove:function(t){if(t.isLink()){delete this._edges[t.id];var{source:e,target:n}=t.attributes;e.id&&this._out[e.id]&&this._out[e.id][t.id]&&delete this._out[e.id][t.id],n.id&&this._in[n.id]&&this._in[n.id][t.id]&&delete this._in[n.id][t.id]}else delete this._nodes[t.id]},_restructureOnReset:function(t){t=t.models,this._out={},this._in={},this._nodes={},this._edges={},t.forEach(this._restructureOnAdd,this)},_restructureOnChangeSource:function(t){var e=t.previous("source");e.id&&this._out[e.id]&&delete this._out[e.id][t.id];var n=t.attributes.source;n.id&&((this._out[n.id]||(this._out[n.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target");e.id&&this._in[e.id]&&delete this._in[e.id][t.id];var n=t.get("target");n.id&&((this._in[n.id]||(this._in[n.id]={}))[t.id]=!0)},getOutboundEdges:function(t){return this._out&&this._out[t]||{}},getInboundEdges:function(t){return this._in&&this._in[t]||{}},toJSON:function(){var t=ba.prototype.toJSON.apply(this,arguments);return t.cells=this.get("cells").toJSON(),t},fromJSON:function(t,e){if(!t.cells)throw new Error("Graph JSON must contain cells array.");return this.set(t,e)},set:function(t,e,n){var i;return"object"==typeof t?(i=t,n=e):(i={})[t]=e,i.hasOwnProperty("cells")&&(this.resetCells(i.cells,n),i=Po(i,"cells")),ba.prototype.set.call(this,i,n)},clear:function(t){t=io({},t,{clear:!0});var e=this.get("cells");if(0===e.length)return this;this.startBatch("clear",t);var n=e.sortBy((function(t){return t.isLink()?1:2}));do{n.shift().remove(t)}while(n.length>0);return this.stopBatch("clear"),this},_prepareCell:function(t,e){var n;if(t instanceof ba?(n=t.attributes,t.graph||e&&e.dry||(t.graph=this)):n=t,!no(n.type))throw new TypeError("dia.Graph: cell type must be a string.");return t},minZIndex:function(){var t=this.get("cells").first();return t&&t.get("z")||0},maxZIndex:function(){var t=this.get("cells").last();return t&&t.get("z")||0},addCell:function(t,e){return Array.isArray(t)?this.addCells(t,e):(t instanceof ba?t.has("z")||t.set("z",this.maxZIndex()+1):void 0===t.z&&(t.z=this.maxZIndex()+1),this.get("cells").add(this._prepareCell(t,e),e||{}),this)},addCells:function(t,e){return 0===t.length||(t=bo(t),e.maxPosition=e.position=t.length-1,this.startBatch("add",e),t.forEach((function(t){this.addCell(t,e),e.position--}),this),this.stopBatch("add",e)),this},resetCells:function(t,e){var n=vo(t).map((function(t){return this._prepareCell(t,e)}),this);return this.get("cells").reset(n,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),so(t,"remove",e),this.stopBatch("remove")),this},_removeCell:function(t,e,n){(n=n||{}).clear||(n.disconnectLinks?this.disconnectLinks(t,n):this.removeLinks(t,n)),this.get("cells").remove(t,{silent:!0}),t.graph===this&&(t.graph=null)},getCell:function(t){return this.get("cells").get(t)},getCells:function(){return this.get("cells").toArray()},getElements:function(){return this.get("cells").toArray().filter((t=>t.isElement()))},getLinks:function(){return this.get("cells").toArray().filter((t=>t.isLink()))},getFirstCell:function(){return this.get("cells").first()},getLastCell:function(){return this.get("cells").last()},getConnectedLinks:function(t,e){var n=(e=e||{}).indirect,i=e.inbound,r=e.outbound;void 0===i&&void 0===r&&(i=r=!0);var o=[],s={};function a(t,e){if(_o(t.getOutboundEdges(e.id),function(e,c){if(!s[c]){var h=t.getCell(c);o.push(h),s[c]=!0,n&&(i&&l(t,h),r&&a(t,h))}}.bind(t)),n&&e.isLink()){var c=e.getTargetCell();c&&c.isLink()&&(s[c.id]||(o.push(c),a(t,c)))}}function l(t,e){if(_o(t.getInboundEdges(e.id),function(e,c){if(!s[c]){var h=t.getCell(c);o.push(h),s[c]=!0,n&&(i&&l(t,h),r&&a(t,h))}}.bind(t)),n&&e.isLink()){var c=e.getSourceCell();c&&c.isLink()&&(s[c.id]||(o.push(c),l(t,c)))}}if(r&&a(this,t),i&&l(this,t),e.deep){var c=t.getEmbeddedCells({deep:!0}),h={};c.forEach((function(t){t.isElement()&&(h[t.id]=!0)})),c.forEach((function(t){t.isLink()||(r&&_o(this.getOutboundEdges(t.id),function(t,n){if(!s[n]){var i=this.getCell(n),{source:r,target:a}=i.attributes,l=r.id,c=a.id;if(!e.includeEnclosed&&l&&h[l]&&c&&h[c])return;o.push(this.getCell(n)),s[n]=!0}}.bind(this)),i&&_o(this.getInboundEdges(t.id),function(t,n){if(!s[n]){var i=this.getCell(n),{source:r,target:a}=i.attributes,l=r.id,c=a.id;if(!e.includeEnclosed&&l&&h[l]&&c&&h[c])return;o.push(this.getCell(n)),s[n]=!0}}.bind(this)))}),this)}return o},getNeighbors:function(t,e){e||(e={});var n=e.inbound,i=e.outbound;void 0===n&&void 0===i&&(n=i=!0);var r=this.getConnectedLinks(t,e).reduce(function(r,o){var{source:s,target:a}=o.attributes,l=o.hasLoop(e);if(n&&To(s,"id")&&!r[s.id]){var c=this.getCell(s.id);c.isElement()&&(!l&&(!c||c===t||e.deep&&c.isEmbeddedIn(t))||(r[s.id]=c))}if(i&&To(a,"id")&&!r[a.id]){var h=this.getCell(a.id);h.isElement()&&(!l&&(!h||h===t||e.deep&&h.isEmbeddedIn(t))||(r[a.id]=h))}return r}.bind(this),{});if(t.isLink()){if(n){var o=t.getSourceCell();o&&o.isElement()&&!r[o.id]&&(r[o.id]=o)}if(i){var s=t.getTargetCell();s&&s.isElement()&&!r[s.id]&&(r[s.id]=s)}}return vo(r)},getCommonAncestor:function(){var t=Array.from(arguments).map((function(t){for(var e=[],n=t.get("parent");n;)e.push(n),n=this.getCell(n).get("parent");return e}),this);t=t.sort((function(t,e){return t.length-e.length}));var e=vo(t.shift()).find((function(e){return t.every((function(t){return t.includes(e)}))}));return this.getCell(e)},getSuccessors:function(t,e){e=e||{};var n=[];return this.search(t,(function(e){e!==t&&n.push(e)}),io({},e,{outbound:!0})),n},cloneCells:wa,cloneSubgraph:function(t,e){var n=this.getSubgraph(t,e);return this.cloneCells(n)},getSubgraph:function(t,e){e=e||{};var n=[],i={},r=[],o=[];return vo(t).forEach((function(t){i[t.id]||(n.push(t),i[t.id]=t,t.isLink()?o.push(t):r.push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach((function(t){i[t.id]||(n.push(t),i[t.id]=t,t.isLink()?o.push(t):r.push(t))}))})),o.forEach((function(t){var{source:e,target:o}=t.attributes;if(e.id&&!i[e.id]){var s=this.getCell(e.id);n.push(s),i[s.id]=s,r.push(s)}if(o.id&&!i[o.id]){var a=this.getCell(o.id);n.push(this.getCell(o.id)),i[a.id]=a,r.push(a)}}),this),r.forEach((function(t){this.getConnectedLinks(t,e).forEach((function(t){var{source:e,target:r}=t.attributes;!i[t.id]&&e.id&&i[e.id]&&r.id&&i[r.id]&&(n.push(t),i[t.id]=t)}))}),this),n},getPredecessors:function(t,e){e=e||{};var n=[];return this.search(t,(function(e){e!==t&&n.push(e)}),io({},e,{inbound:!0})),n},search:function(t,e,n){(n=n||{}).breadthFirst?this.bfs(t,e,n):this.dfs(t,e,n)},bfs:function(t,e,n={}){const i={},r={},o=[];for(o.push(t),r[t.id]=0;o.length>0;){var s=o.shift();if(i[s.id])continue;if(i[s.id]=!0,!1===e.call(this,s,r[s.id]))continue;const t=this.getNeighbors(s,n);for(let e=0,n=t.length;e<n;e++){const n=t[e];r[n.id]=r[s.id]+1,o.push(n)}}},dfs:function(t,e,n={}){const i={},r={},o=[];for(o.push(t),r[t.id]=0;o.length>0;){const t=o.pop();if(i[t.id])continue;if(i[t.id]=!0,!1===e.call(this,t,r[t.id]))continue;const s=this.getNeighbors(t,n),a=o.length;for(let e=0,n=s.length;e<n;e++){const n=s[e];r[n.id]=r[t.id]+1,o.splice(a,0,n)}}},getSources:function(){var t=[];return _o(this._nodes,function(e,n){this._in[n]&&!fo(this._in[n])||t.push(this.getCell(n))}.bind(this)),t},getSinks:function(){var t=[];return _o(this._nodes,function(e,n){this._out[n]&&!fo(this._out[n])||t.push(this.getCell(n))}.bind(this)),t},isSource:function(t){return!this._in[t.id]||fo(this._in[t.id])},isSink:function(t){return!this._out[t.id]||fo(this._out[t.id])},isSuccessor:function(t,e){var n=!1;return this.search(t,(function(i){if(i===e&&i!==t)return n=!0,!1}),{outbound:!0}),n},isPredecessor:function(t,e){var n=!1;return this.search(t,(function(i){if(i===e&&i!==t)return n=!0,!1}),{inbound:!0}),n},isNeighbor:function(t,e,n){var i=(n=n||{}).inbound,r=n.outbound;void 0===i&&void 0===r&&(i=r=!0);var o=!1;return this.getConnectedLinks(t,n).forEach((function(t){var{source:n,target:s}=t.attributes;return i&&To(n,"id")&&n.id===e.id||r&&To(s,"id")&&s.id===e.id?(o=!0,!1):void 0})),o},disconnectLinks:function(t,e){this.getConnectedLinks(t).forEach((function(n){n.set(n.attributes.source.id===t.id?"source":"target",{x:0,y:0},e)}))},removeLinks:function(t,e){so(this.getConnectedLinks(t),"remove",e)},findModelsFromPoint:function(t){return this.getElements().filter((e=>e.getBBox({rotate:!0}).containsPoint(t)))},findModelsInArea:function(t,e={}){const n=new me(t),{strict:i=!1}=e,r=i?"containsRect":"intersect";return this.getElements().filter((t=>n[r](t.getBBox({rotate:!0}))))},findModelsUnderElement:function(t,e={}){const{searchBy:n="bbox"}=e,i=t.getBBox().rotateAroundCenter(t.angle());return("bbox"===n?this.findModelsInArea(i):this.findModelsFromPoint(lc(i,n))).filter((e=>t.id!==e.id&&!e.isEmbeddedIn(t)))},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t,e={}){const{rotate:n=!0}=e;return vo(t).reduce((function(t,e){const i=e.getBBox({rotate:n});return i?t?t.union(i):i:t}),null)},translate:function(t,e,n){var i=this.getCells().filter((function(t){return!t.isEmbedded()}));return so(i,"translate",t,e,n),this},resize:function(t,e,n){return this.resizeCells(t,e,this.getCells(),n)},resizeCells:function(t,e,n,i){var r=this.getCellsBBox(n);if(r){var o=Math.max(t/r.width,0),s=Math.max(e/r.height,0);so(n,"scale",o,s,r.origin(),i)}return this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",io({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",io({},e,{batchName:t}))},hasActiveBatch:function(t){const e=this._batches;let n;return n=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t],n.some((t=>e[t]>0))}},{validations:{multiLinks:function(t,e){var{source:n,target:i}=e.attributes;if(n.id&&i.id){var r=e.getSourceCell();if(r&&t.getConnectedLinks(r,{outbound:!0}).filter((function(t){var{source:e,target:r}=t.attributes;return e&&e.id===n.id&&(!e.port||e.port===n.port)&&r&&r.id===i.id&&(!r.port||r.port===i.port)})).length>1)return!1}return!0},linkPinning:function(t,e){var{source:n,target:i}=e.attributes;return n.id&&i.id}}});!function(t,e,n){if(no(n)){if(!bc[n])throw new Error('Unknown wrapper: "'+n+'"');n=bc[n]}if(!go(n))throw new Error("Wrapper must be a function.");vo(["resetCells","addCells","removeCells"]).forEach((function(e){t[e]=n(t[e])}))}(xc.prototype,0,bc.cells);var Ac=function(t){this.cid=Co("view"),this.preinitialize.apply(this,arguments),io(this,So(t,Ec)),this._ensureElement(),this.initialize.apply(this,arguments)},Tc=/^(\S+)\s*(.*)$/,Ec=["model","collection","el","id","attributes","className","tagName","events"];io(Ac.prototype,oa,{tagName:"div",$:function(t){return this.$el.find(t)},preinitialize:function(){},initialize:function(){},render:function(){return this},remove:function(){return this._removeElement(),this.stopListening(),this},_removeElement:function(){this.$el.remove()},setElement:function(t){return this.undelegateEvents(),this._setElement(t),this.delegateEvents(),this},_setElement:function(t){this.$el=t instanceof Rs?t:Rs(t),this.el=this.$el[0]},delegateEvents:function(t){if(t||(t=Eo(this,"events")),!t)return this;for(var e in this.undelegateEvents(),t){var n=t[e];if(go(n)||(n=this[n]),n){var i=e.match(Tc);this.delegate(i[1],i[2],n.bind(this))}}return this},delegate:function(t,e,n){return this.$el.on(t+".delegateEvents"+this.cid,e,n),this},undelegateEvents:function(){return this.$el&&this.$el.off(".delegateEvents"+this.cid),this},undelegate:function(t,e,n){return this.$el.off(t+".delegateEvents"+this.cid,e,n),this},_createElement:function(t){return document.createElement(t)},_ensureElement:function(){if(this.el)this.setElement(Eo(this,"el"));else{var t=io({},Eo(this,"attributes"));this.id&&(t.id=Eo(this,"id")),this.className&&(t.class=Eo(this,"className")),this.setElement(this._createElement(Eo(this,"tagName"))),this._setAttributes(t)}},_setAttributes:function(t){this.$el.attr(t)}}),Ac.extend=ma;const Pc={},Sc=Ac.extend({options:{},theme:null,themeClassNamePrefix:Fs("theme-"),requireSetThemeOverride:!1,defaultTheme:"default",children:null,childNodes:null,DETACHABLE:!0,UPDATE_PRIORITY:2,FLAG_INSERT:1<<30,FLAG_REMOVE:1<<29,FLAG_INIT:1<<28,constructor:function(t){this.requireSetThemeOverride=t&&!!t.theme,this.options=io({},this.options,t),Ac.call(this,t)},initialize:function(){Pc[this.cid]=this,this.setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){this.svgElement?this.vel.remove():this.$el.remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){if(t||(t=Eo(this,"children")),t){var e=this.svgElement,n=An.namespace[e?"svg":"xhtml"],i=Bs(t,n);(e?this.vel:this.$el).empty().append(i.fragment),this.childNodes=i.selectors}return this},findAttributeNode:function(t,e){let n=e;for(;n&&1===n.nodeType;){if(n.getAttribute(t))return n;if(n===this.el)return null;n=n.parentNode}return null},findAttribute:function(t,e){const n=this.findAttributeNode(t,e);return n&&n.getAttribute(t)},_ensureElement:function(){if(this.el)this.setElement(Eo(this,"el"));else{var t=Eo(this,"tagName"),e=io({},Eo(this,"attributes")),n=io({},Eo(this,"style"));this.id&&(e.id=Eo(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)}this._ensureElClassName()},_setAttributes:function(t){this.svgElement?this.vel.attr(t):this.$el.attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(An.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof Rs?t:Rs(t),this.el=this.$el[0],this.svgElement&&(this.vel=An(this.el))},_ensureElClassName:function(){var t=Eo(this,"className");if(t){var e=Fs(t);this.svgElement?this.vel.removeClass(t).addClass(e):this.$el.removeClass(t).addClass(e)}},init:function(){},onRender:function(){},confirmUpdate:function(){return 0},setTheme:function(t,e){return e=e||{},this.theme&&this.requireSetThemeOverride&&!e.override||(this.removeThemeClassName(),this.addThemeClassName(t),this.onSetTheme(this.theme,t),this.theme=t),this},addThemeClassName:function(t){if(!(t=t||this.theme))return this;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.addClass(e):this.$el.addClass(e),this},removeThemeClassName:function(t){t=t||this.theme;var e=this.themeClassNamePrefix+t;return this.svgElement?this.vel.removeClass(e):this.$el.removeClass(e),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),Pc[this.cid]=null,Ac.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(!e)return this;n||(n={});var i=this.getEventNamespace();for(var r in e){var o=e[r];"function"!=typeof o&&(o=this[o]),o&&Rs(t).on(r+i,n,o.bind(this))}return this},undelegateElementEvents:function(t){return Rs(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t||(t=Eo(this,"documentEvents")),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){if(!t)throw new Error("eventData(): event object required.");var n=t.data,i="__"+this.cid+"__";return void 0===e?n&&n[i]||{}:(n||(n=t.data={}),n[i]||(n[i]={}),io(n[i],e),this)},stopPropagation:function(t){return this.eventData(t,{propagationStopped:!0}),this},isPropagationStopped:function(t){return!!this.eventData(t).propagationStopped}},{extend:function(){var t=Array.from(arguments),e=t[0]&&io({},t[0])||{},n=t[1]&&io({},t[1])||{},i=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof i&&i.apply(this,arguments),this.render.__render__===i&&this.onRender(),this},e.render.__render__=i,Ac.extend.call(this,e,n)}});function _c(t){return t?Array.isArray(t)?t:[t]:[]}const kc=Sc.extend({tagName:"g",svgElement:!0,className:"highlight",HIGHLIGHT_FLAG:1,UPDATE_PRIORITY:3,DETACHABLE:!1,UPDATABLE:!0,MOUNTABLE:!0,cellView:null,nodeSelector:null,node:null,updateRequested:!1,postponedUpdate:!1,transformGroup:null,detachedTransformGroup:null,requestUpdate(t,e){const{paper:n}=t;this.cellView=t,this.nodeSelector=e,n&&(this.updateRequested=!0,n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate(){this.updateRequested=!1;const{cellView:t,nodeSelector:e}=this;return t.isMounted()?(this.update(t,e),this.mount(),this.transform(),0):(this.postponedUpdate=!0,0)},findNode(t,e=null){let n;if("string"==typeof e)n=t.findNode(e);else if(mo(e)){const i=t.model.isLink(),{label:r=null,port:o,selector:s}=e;n=i&&null!==r?t.findLabelNode(r,s):!i&&o?t.findPortNode(o,s):t.findNode(s)}else e&&(n=An.toNode(e),n instanceof SVGElement||(n=null));return n||null},getNodeMatrix(t,e){const{options:n}=this,{layer:i}=n,{rotatableNode:r}=t,o=t.getNodeMatrix(e);return r?i?r.contains(e)?o:t.getRootRotateMatrix().inverse().multiply(o):t.getNodeRotateMatrix(e).multiply(o):o},mount(){const{MOUNTABLE:t,cellView:e,el:n,options:i,transformGroup:r,detachedTransformGroup:o,postponedUpdate:s,nodeSelector:a}=this;if(!t||r)return;if(s)return this.update(e,a),void this.transform();const{vel:l,paper:c}=e,{layer:h}=i;if(h){let t;o?(t=o,this.detachedTransformGroup=null):t=An("g").addClass("highlight-transform").append(n),this.transformGroup=t,c.getLayerView(h).insertSortedNode(t.node,i.z)}else n.parentNode&&!n.nextSibling||l.append(n)},unmount(){const{MOUNTABLE:t,transformGroup:e,vel:n}=this;t&&(e?(this.transformGroup=null,this.detachedTransformGroup=e,e.remove()):n.remove())},transform(){const{transformGroup:t,cellView:e,updateRequested:n}=this;if(!t||e.model.isLink()||n)return;const i=e.getRootTranslateMatrix(),r=e.getRootRotateMatrix(),o=i.multiply(r);t.attr("transform",An.matrixToTransformString(o))},update(){const{node:t,cellView:e,nodeSelector:n,updateRequested:i,id:r}=this;if(i)return;this.postponedUpdate=!1;const o=this.node=this.findNode(e,n);t&&this.unhighlight(e,t),o?(this.highlight(e,o),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this))},onRemove(){const{node:t,cellView:e,id:n,constructor:i}=this;t&&this.unhighlight(e,t),this.unmount(),i._removeRef(e,n)},highlight(t,e){},unhighlight(t,e){},listenToUpdateAttributes(t){const e=Eo(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange(){const{cellView:t}=this;if(!t)return;const{model:e,paper:n}=t;Eo(this,"UPDATE_ATTRIBUTES").some((t=>e.hasChanged(t)))&&n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY)}},{_views:{},highlight:function(t,e,n){const i=this.uniqueId(e,n);this.add(t,e,i,n)},unhighlight:function(t,e,n){const i=this.uniqueId(e,n);this.remove(t,i)},get(t,e=null){const{cid:n}=t,{_views:i}=this,r=i[n];if(null===e){const t=[];if(!r)return t;for(let e in r){const n=r[e];n instanceof this&&t.push(n)}return t}if(!r)return null;if(e in r){const t=r[e];if(t instanceof this)return t}return null},add(t,e,n,i={}){if(!n)throw new Error("dia.HighlighterView: An ID required.");const r=kc.get(t,n);r&&r.remove();const o=new this(i);return o.id=n,this._addRef(t,n,o),o.requestUpdate(t,e),o.listenToUpdateAttributes(t),o},_addRef(t,e,n){const{cid:i}=t,{_views:r}=this;let o=r[i];o||(o=r[i]={}),o[e]=n},_removeRef(t,e){const{cid:n}=t,{_views:i}=this,r=i[n];if(r){e&&delete r[e];for(let t in r)return;delete i[n]}},remove(t,e=null){_c(this.get(t,e)).forEach((t=>{t.remove()}))},removeAll(t,e=null){const{_views:n}=this;for(let i in n)for(let r in n[i]){const o=n[i][r];o.cellView.paper===t&&o instanceof this&&(null===e||r===e)&&o.remove()}},update(t,e=null,n=!1){_c(this.get(t,e)).forEach((t=>{(n||t.UPDATABLE)&&t.update()}))},transform(t,e=null){_c(this.get(t,e)).forEach((t=>{t.UPDATABLE&&t.transform()}))},unmount(t,e=null){_c(this.get(t,e)).forEach((t=>t.unmount()))},mount(t,e=null){_c(this.get(t,e)).forEach((t=>t.mount()))},uniqueId:(t,e="")=>An.ensureId(t)+JSON.stringify(e)}),Lc=["transform","x","y","cx","cy","dx","dy","x1","y1","x2","y2","points","d","r","rx","ry","width","height","stroke-width","font-size"].reduce(((t,e)=>(t[e]=!0,t)),{}),Cc=["r","rx","ry","width","height","stroke-width","font-size"].reduce(((t,e)=>(t[e]=!0,t)),{});function Mc(t,e){const n={};for(let i in t)t.hasOwnProperty(i)&&(n[i]=Oc(i,t[i],e));return n}function Oc(t,e,n){if(t in Lc&&Ba(e)){let i=Va(e,n);return t in Cc&&(i=Math.max(0,i)),i}return e}const Nc={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"},Rc=Sc.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var t=["cell"],e=this.model.get("type");return e&&e.toLowerCase().split(".").forEach((function(e,n,i){t.push("type-"+i.slice(0,n+1).join("-"))})),t.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e,n,i={},r={},o=0,s=Eo(this,"presentationAttributes");for(var a in s)if(s.hasOwnProperty(a)){var l=s[a];for(Array.isArray(l)||(l=[l]),t=0,e=l.length;t<e;t++){var c=i[n=l[t]];c||(c=i[n]=1<<o++),r[a]|=c}}var h=Eo(this,"initFlag");for(Array.isArray(h)||(h=[h]),t=0,e=h.length;t<e;t++)i[n=h[t]]||(i[n]=1<<o++);if(o>25)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=i,this._presentationAttributes=r},hasFlag:function(t,e){return t&this.getFlag(e)},removeFlag:function(t,e){return t^t&this.getFlag(e)},getFlag:function(t){var e=this._flags;if(!e)return 0;var n=0;if(Array.isArray(t))for(var i=0,r=t.length;i<r;i++)n|=e[t[i]];else n|=e[t];return n},attributes:function(){var t=this.model;return{"model-id":t.id,"data-type":t.attributes.type}},constructor:function(t){t.id=t.id||$s(this),Sc.call(this,t)},initialize:function(){this.setFlags(),Sc.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){var n=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&n&&(e.dirty&&this.hasFlag(n,"UPDATE")&&(n|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(n,e))},requestUpdate:function(t,e){const{paper:n}=this;n&&t>0&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n=Bs(t),i=n.selectors,r=n.groupSelectors;for(var o in r){if(i[o])throw new Error("dia.CellView: ambiguous group selector");i[o]=r[o]}if(e){var s=this.selector;if(i[s])throw new Error("dia.CellView: ambiguous root selector.");i[s]=e}return{fragment:n.fragment,selectors:i}},can:function(t){var e,n,i=go(this.options.interactive)?this.options.interactive(this):this.options.interactive;return to(i)&&!1!==i[t]||(e=i,n=Object.prototype.toString,(!0===e||!1===e||!!e&&"object"==typeof e&&n.call(e)===Pn)&&!1!==i)},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){var i=n[t];if(i)return Array.isArray(i)?i:[i]}return this.useCSSSelectors?Rs(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){const[e=null]=this.findNodes(t);return e},notify:function(t){if(this.paper){var e=Array.prototype.slice.call(arguments,1);this.trigger.apply(this,[t].concat(e)),this.paper.trigger.apply(this.paper,[t,this].concat(e))}},getBBox:function(t){var e;if(t&&t.useModelGeometry){var n=this.model;e=n.getBBox().bbox(n.angle())}else e=this.getNodeBBox(this.el);return this.paper.localToPaperRect(e)},getNodeBBox:function(t){const e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),i=this.getNodeMatrix(t);return An.transformRect(e,n.multiply(i))},getNodeRotateMatrix(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():An.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getNodeMatrix(t),i=this.getRootTranslateMatrix();return An.transformRect(e,i.multiply(n))},getRootTranslateMatrix:function(){var t=this.model.position();return An.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t=An.createSVGMatrix(),e=this.model,n=e.angle();if(n){var i=e.getBBox(),r=i.width/2,o=i.height/2;t=t.translate(r,o).rotate(n).translate(-r,-o)}return t},_notifyHighlight:function(t,e,n={}){const{el:i}=this;let r;if("string"==typeof e?r=this.findNode(e)||i:[r=i]=this.$(e),n.partial=r!==i,void 0===n.type){let t;switch(!0){case n.embedding:t=Nc.EMBEDDING;break;case n.connecting:t=Nc.CONNECTING;break;case n.magnetAvailability:t=Nc.MAGNET_AVAILABILITY;break;case n.elementAvailability:t=Nc.ELEMENT_AVAILABILITY;break;default:t=Nc.DEFAULT}n.type=t}return this.notify(t,r,n),this},highlight:function(t,e){return this._notifyHighlight("cell:highlight",t,e)},unhighlight:function(t,e={}){return this._notifyHighlight("cell:unhighlight",t,e)},findMagnet:function(t){const e=this.el;let n=this.$(t)[0];n||(n=e);do{const t=n.getAttribute("magnet"),i=n===e;if((t||i)&&"false"!==t)return n;if(i)return;n=n.parentNode}while(n)},findProxyNode:function(t,e){t||(t=this.el);const n=t.getAttribute(`${e}-selector`);if(n){const t=this.findNode(n);if(t)return t}return t},getSelector:function(t,e){var n;if(t===this.el)return"string"==typeof e&&(n=":scope > "+e),n;if(t){var i=An(t).index()+1;n=t.tagName+":nth-child("+i+")",e&&(n+=" > "+e),n=this.getSelector(t.parentNode,n)}return n},addLinkFromMagnet:function(t,e,n){var i=this.paper,r=i.model,o=i.getDefaultLink(this,t);return o.set({source:this.getLinkEnd(t,e,n,o,"source"),target:{x:e,y:n}}).addTo(r,{async:!1,ui:!0}),o.findView(i)},getLinkEnd:function(t,...e){const n=this.model,i=n.id,r=this.findAttributeNode("port",t),o=t.getAttribute("joint-selector"),s={id:i};if(null!=o&&(s.magnet=o),null!=r){let e=r.getAttribute("port");"number"===r.getAttribute("port-id-type")&&(e=parseInt(e,10)),s.port=e,n.hasPort(e)||o||(s.selector=this.getSelector(t))}else null==o&&this.el!==t&&(s.selector=this.getSelector(t));return this.customizeLinkEnd(s,t,...e)},customizeLinkEnd:function(t,e,n,i,r,o){const{paper:s}=this,{connectionStrategy:a}=s.options;if("function"==typeof a){var l=a.call(s,t,this,e,new Jt(n,i),r,o,s);if(l)return l}return t},getMagnetFromLinkEnd:function(t){var e,n=t.port,i=t.magnet,r=this.model;return null!=n&&r.isElement()&&r.hasPort(n)?e=this.findPortNode(n,i)||this.el:(i||(i=t.selector),i||null==n||(i='[port="'+n+'"]'),e=this.findNode(i)),this.findProxyNode(e,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");const r=this.addLinkFromMagnet(e,n,i);r.notifyPointerdown(t,n,i),r.eventData(t,r.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:r})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var o=this.paper,s=o.options.magnetThreshold,a=this.getEventTarget(t),l=i.targetMagnet;if("onleave"===s){if(l===a||An(l).contains(a))return}else if(o.eventData(t).mousemoved<=s)return;this.dragLinkStart(t,l,e,n)}},dragLinkEnd:function(t,e,n){var i=this.eventData(t).linkView;i&&(i.pointerup(t,e,n),this.model.stopBatch("add-link"))},getAttributeDefinition:function(t){return this.model.constructor.getAttributeDefinition(t)},setNodeAttributes:function(t,e){fo(e)||(t instanceof SVGElement?An(t).attr(e):Rs(t).attr(e))},processNodeAttributes:function(t,e){var n,i,r,o,s,a,l,c,h,u=[];const d={};for(n in e)e.hasOwnProperty(n)&&(d[An.attributeNames[n]]=e[n]);for(n in d)d.hasOwnProperty(n)&&(i=d[n],!(r=this.getAttributeDefinition(n))||go(r.qualify)&&!r.qualify.call(this,i,t,d,this)?(a||(a={}),a[n]=i):(no(r.set)&&(a||(a={}),a[r.set]=i),null!==i&&u.push(n,r)));for(o=0,s=u.length;o<s;o+=2)n=u[o],r=u[o+1],i=e[n],go(r.set)&&(l||(l={}),l[n]=i),go(r.position)&&(c||(c={}),c[n]=i),go(r.offset)&&(h||(h={}),h[n]=i);return{raw:d,normal:a,set:l,position:c,offset:h}},updateRelativeAttributes:function(t,e,n,i){var r,o;i||(i={});var s=Mc(e.raw||{},n),a=e.normal||{};for(const t in a)a[t]=s[t];var l=e.set,c=e.position,h=e.offset;for(r in l){o=s[r];var u=this.getAttributeDefinition(r).set.call(this,o,n.clone(),t,s,this);to(u)?io(a,u):void 0!==u&&(a[r]=u)}if(t instanceof HTMLElement)this.setNodeAttributes(t,a);else{var d,f,p,g=a.transform,m=An.transformStringToMatrix(g),v=Jt(m.e,m.f);if(g&&(a=Po(a,"transform"),m.e=m.f=0),c||h){var y=this.getNodeScale(t,i.scalableNode);d=y.sx,f=y.sy}var b=!1;for(r in c)o=s[r],(p=this.getAttributeDefinition(r).position.call(this,o,n.clone(),t,s,this))&&(v.offset(Jt(p).scale(d,f)),b||(b=!0));this.setNodeAttributes(t,a);var w=!1;if(h){var x=this.getNodeBoundingRect(t);if(x.width>0&&x.height>0){var A=An.transformRect(x,m).scale(1/d,1/f);for(r in h)o=s[r],(p=this.getAttributeDefinition(r).offset.call(this,o,A,t,s,this))&&(v.offset(Jt(p).scale(d,f)),w||(w=!0))}}(void 0!==g||b||w)&&(v.round(1),m.e=v.x,m.f=v.y,t.setAttribute("transform",An.matrixToTransformString(m)))}},getNodeScale:function(t,e){var n,i;if(e&&e.contains(t)){var r=e.scale();n=1/r.sx,i=1/r.sy}else n=1,i=1;return{sx:n,sy:i}},cleanNodesCache:function(){this.metrics={}},nodeCache:function(t){var e=this.metrics;if(!e)return{};var n=An.ensureId(t),i=e[n];return i||(i=e[n]={}),i},getNodeData:function(t){var e=this.nodeCache(t);return e.data||(e.data={}),e.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=An(t).getBBox()),new me(e.boundingRect)},getNodeMatrix:function(t){const e=this.nodeCache(t);if(void 0===e.magnetMatrix){const{rotatableNode:n,el:i}=this;let r;r=n&&n.contains(t)?n:i,e.magnetMatrix=An(t).getTransformToElement(r)}return An.createSVGMatrix(e.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=An(t).toGeometryShape()),e.geometryShape.clone()},isNodeConnection:function(t){return this.model.isLink()&&(!t||t===this.el)},findNodesAttributes:function(t,e,n,i){var r,o,s,a,l={},c=[];for(var h in t)if(t.hasOwnProperty(h)&&(s=t[h],mo(s))){var u=n[h]=this.findBySelector(h,e,i);for(r=0,o=u.length;r<o;r++){var d=u[r];a=An.ensureId(d);var f=i&&i[h]===d,p=l[a];if(p){p.array||(c.push(a),p.array=!0,p.attributes=[p.attributes],p.selectedLength=[p.selectedLength]);var g=p.attributes,m=p.selectedLength;if(f)g.unshift(s),m.unshift(-1);else{var v=lo(m,o);g.splice(v,0,s),m.splice(v,0,o)}}else l[a]={attributes:s,selectedLength:f?-1:o,node:d,array:!1}}}for(r=0,o=c.length;r<o;r++)(s=l[a=c[r]]).attributes=Mo({},...s.attributes.reverse());return l},getEventTarget:function(t,e={}){const{target:n,type:i,clientX:r=0,clientY:o=0}=t;return e.fromPoint||"touchmove"===i||"touchend"===i||"pointerId"in t&&n.hasPointerCapture(t.pointerId)?document.elementFromPoint(r,o):n},updateDOMSubtreeAttributes:function(t,e,n){n||(n={}),n.rootBBox||(n.rootBBox=me()),n.selectors||(n.selectors=this.selectors);var i,r,o,s,a,l={},c={},h=[],u=[],d=n.roAttributes,f=this.findNodesAttributes(d||e,t,l,n.selectors),p=d?this.findNodesAttributes(e,t,l,n.selectors):f;for(var g in f)if(o=(s=f[g]).attributes,r=s.node,(a=this.processNodeAttributes(r,o)).set||a.position||a.offset||a.raw.ref){var m,v=p[g]&&p[g].attributes,y=v&&void 0===o.ref?v.ref:o.ref;if(y){if(!(m=(l[y]||this.findBySelector(y,t,n.selectors))[0]))throw new Error('dia.CellView: "'+y+'" reference does not exist.')}else m=null;if(i={node:r,refNode:m,processedAttributes:a,allAttributes:v},m){var b=u.findIndex((function(t){return t.refNode===r}));b>-1?u.splice(b,0,i):u.push(i)}else h.push(i)}else this.setNodeAttributes(r,Mc(a.normal,n.rootBBox));h.push(...u);for(let t=0,e=h.length;t<e;t++){i=h[t],r=i.node;const e=(m=i.refNode)?An.ensureId(m):"";let o=c[e];o||(o=c[e]=m?An(m).getBBox({target:Fc(r,m)}):n.rootBBox),d?(a=this.processNodeAttributes(r,i.allAttributes),this.mergeProcessedAttributes(a,i.processedAttributes)):a=i.processedAttributes,this.updateRelativeAttributes(r,a,o,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),io(t.set,e.set),io(t.position,e.position),io(t.offset,e.offset);var n=t.normal&&t.normal.transform;void 0!==n&&e.normal&&(e.normal.transform=n),t.normal=e.normal},onMount(t){t||(this.mountTools(),kc.mount(this))},onDetach(){this.unmountTools(),kc.unmount(this)},onRemove:function(){this.removeTools(),this.removeHighlighters()},_toolsView:null,hasTools:function(t){var e=this._toolsView;return!(!e||t&&e.getName()!==t)},addTools:function(t){return this.removeTools(),t&&(this._toolsView=t,t.configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},unmountTools(){const t=this._toolsView;return t&&t.unmount(),this},mountTools(){const t=this._toolsView;return t&&!t.isMounted()&&t.mount(),this},updateTools:function(t){var e=this._toolsView;return e&&e.update(t),this},removeTools:function(){var t=this._toolsView;return t&&(t.remove(),this._toolsView=null),this},hideTools:function(){var t=this._toolsView;return t&&t.hide(),this},showTools:function(){var t=this._toolsView;return t&&t.show(),this},onToolEvent:function(t){switch(t){case"remove":this.removeTools();break;case"hide":this.hideTools();break;case"show":this.showTools()}},removeHighlighters:function(){kc.remove(this)},updateHighlighters:function(t=!1){kc.update(this,null,t)},transformHighlighters:function(){kc.transform(this)},preventDefaultInteraction(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented(t){const{defaultInteractionPrevented:e=!1}=this.eventData(t);return e},pointerdblclick:function(t,e,n){this.notify("cell:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){this.notify("cell:pointerclick",t,e,n)},contextmenu:function(t,e,n){this.notify("cell:contextmenu",t,e,n)},pointerdown:function(t,e,n){const{model:i}=this,{graph:r}=i;r&&(i.startBatch("pointer"),this.eventData(t,{graph:r})),this.notify("cell:pointerdown",t,e,n)},pointermove:function(t,e,n){this.notify("cell:pointermove",t,e,n)},pointerup:function(t,e,n){const{graph:i}=this.eventData(t);this.notify("cell:pointerup",t,e,n),i&&i.stopBatch("pointer",{cell:this.model})},mouseover:function(t){this.notify("cell:mouseover",t)},mouseout:function(t){this.notify("cell:mouseout",t)},mouseenter:function(t){this.notify("cell:mouseenter",t)},mouseleave:function(t){this.notify("cell:mouseleave",t)},mousewheel:function(t,e,n,i){this.notify("cell:mousewheel",t,e,n,i)},onevent:function(t,e,n,i){this.notify(e,t,n,i)},onmagnet:function(){},magnetpointerdblclick:function(){},magnetcontextmenu:function(){},checkMouseleave(t){const{paper:e,model:n}=this;if(e.isAsync()){if(n.isLink()){const t=n.getSourceElement();if(t){const n=e.findViewByModel(t);n&&(e.dumpView(n),e.checkViewVisibility(n))}const i=n.getTargetElement();if(i){const t=e.findViewByModel(i);t&&(e.dumpView(t),e.checkViewVisibility(t))}}e.dumpView(this),e.checkViewVisibility(this)}const i=this.getEventTarget(t,{fromPoint:!0}),r=e.findView(i);r!==this&&(this.mouseleave(t),r&&r.mouseenter(t))},setInteractivity:function(t){this.options.interactive=t}},{Flags:{TOOLS:"TOOLS"},Highlighting:Nc,addPresentationAttributes:function(t){return Mo({},Eo(this.prototype,"presentationAttributes"),t,(function(t,e){if(t&&e)return"string"==typeof t&&(t=[t]),"string"==typeof e&&(e=[e]),Array.isArray(t)&&Array.isArray(e)?co(t.concat(e)):void 0}))},evalAttribute:Oc});function Fc(t,e){let n=t;do{if(n.contains(e))return n;n=n.parentNode}while(n);return null}Object.defineProperty(Rc.prototype,"useCSSSelectors",{get(){const t=this.model.useCSSSelectors;return void 0!==t&&t}});const Bc={TOOLS:Rc.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},Ic="move",Dc="magnet",Vc=Rc.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=Rc.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){Rc.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[Bc.UPDATE],position:[Bc.TRANSLATE,Bc.TOOLS],size:[Bc.RESIZE,Bc.PORTS,Bc.TOOLS],angle:[Bc.ROTATE,Bc.TOOLS],markup:[Bc.RENDER],ports:[Bc.PORTS]},initFlag:[Bc.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(t,e){const{useCSSSelectors:n}=this;this.hasFlag(t,Bc.PORTS)&&(this._removePorts(),this._cleanPortsCache());let i=!1;if(this.hasFlag(t,Bc.RENDER))this.render(),this.updateTools(e),this.updateHighlighters(!0),i=!0,t=this.removeFlag(t,[Bc.RENDER,Bc.UPDATE,Bc.RESIZE,Bc.TRANSLATE,Bc.ROTATE,Bc.PORTS,Bc.TOOLS]);else{let r=!1;this.hasFlag(t,Bc.RESIZE)&&(this.resize(e),r=!0,t=this.removeFlag(t,[Bc.RESIZE,Bc.UPDATE]),n&&(t=this.removeFlag(t,Bc.PORTS))),this.hasFlag(t,Bc.UPDATE)&&(this.update(this.model,null,e),t=this.removeFlag(t,Bc.UPDATE),r=!0,n&&(t=this.removeFlag(t,Bc.PORTS))),this.hasFlag(t,Bc.TRANSLATE)&&(this.translate(),t=this.removeFlag(t,Bc.TRANSLATE),i=!0),this.hasFlag(t,Bc.ROTATE)&&(this.rotate(),t=this.removeFlag(t,Bc.ROTATE),i=!0),this.hasFlag(t,Bc.PORTS)&&(this._renderPorts(),r=!0,t=this.removeFlag(t,Bc.PORTS)),r&&this.updateHighlighters(!1)}return i&&this.transformHighlighters(),this.hasFlag(t,Bc.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,Bc.TOOLS)),t},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();const{useCSSSelectors:n}=this;n&&this._removePorts();var i=this.model,r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new me(i.size()),selectors:this.selectors,scalableNode:this.scalableNode,rotatableNode:this.rotatableNode,roAttributes:e===r?null:e}),n&&this._renderPorts()},rotatableSelector:"rotatable",scalableSelector:"scalable",scalableNode:null,rotatableNode:null,renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.ElementView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el),n=this.selectors=e.selectors;this.rotatableNode=An(n[this.rotatableSelector])||null,this.scalableNode=An(n[this.scalableSelector])||null,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(An(t)),this.rotatableNode=e.findOne(".rotatable"),this.scalableNode=e.findOne(".scalable"),(this.selectors={})[this.selector]=this.el},render:function(){return this.vel.empty(),this.renderMarkup(),this.scalableNode&&this.update(),this.resize(),this.rotatableNode?(this.rotate(),this.translate()):this.updateTransformation(),this.useCSSSelectors||this._renderPorts(),this},resize:function(t){if(this.scalableNode)return this.sgResize(t);this.model.attributes.angle&&this.rotate(),this.update()},translate:function(){if(this.rotatableNode)return this.rgTranslate();this.updateTransformation()},rotate:function(){if(this.rotatableNode)return this.rgRotate(),void this.update();this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var t=this.model.attributes.position;return"translate("+t.x+","+t.y+")"},getRotateString:function(){var t=this.model.attributes,e=t.angle;if(!e)return null;var n=t.size;return"rotate("+e+","+n.width/2+","+n.height/2+")"},rgRotate:function(){this.rotatableNode.attr("transform",this.getRotateString())},rgTranslate:function(){this.vel.attr("transform",this.getTranslateString())},sgResize:function(t){var e=this.model,n=e.angle(),i=e.size(),r=this.scalableNode,o=!1;r.node.getElementsByTagName("path").length>0&&(o=!0);var s=r.getBBox({recursive:o}),a=i.width/(s.width||1),l=i.height/(s.height||1);r.attr("transform","scale("+a+","+l+")");var c=this.rotatableNode,h=c&&c.attr("transform");if(h){c.attr("transform",h+" rotate("+-n+","+i.width/2+","+i.height/2+")");var u=r.getBBox({target:this.paper.cells});e.set("position",{x:u.x,y:u.y},io({updateHandled:!0},t)),this.translate(),this.rotate()}this.update()},prepareEmbedding:function(t={}){const e=t.model||this.model,n=(t.paper||this.paper).model,i=t.initialZIndices={},r=e.getEmbeddedCells({deep:!0}),o=n.getConnectedLinks(e,{deep:!0,includeEnclosed:!0});[e,...r,...o].forEach((t=>i[t.id]=t.attributes.z)),e.startBatch("to-front"),e.toFront({deep:!0,ui:!0});const s=n.getElements().reduce(((t,e)=>Math.max(t,e.attributes.z||0)),0);o.forEach((t=>{t.attributes.z<=s&&t.set("z",s+1,{ui:!0})})),e.stopBatch("to-front");const a=e.parent();a?(n.getCell(a).unembed(e,{ui:!0}),t.initialParentId=a):t.initialParentId=null},processEmbedding:function(t={},e,n,i){const r=t.model||this.model,o=t.paper||this.paper,s=o.model,{findParentBy:a,frontParentOnly:l,validateEmbedding:c}=o.options;let h;h=go(a)?vo(a.call(s,this,e,n,i)):"pointer"===a?vo(s.findModelsFromPoint({x:n,y:i})):s.findModelsUnderElement(r,{searchBy:a}),h=h.filter((t=>t instanceof al&&r.id!==t.id&&!t.isEmbeddedIn(r))),l&&(h=h.slice(-1));let u=null;const d=t.candidateEmbedView;for(let t=h.length-1;t>=0;t--){const e=h[t];if(d&&d.model.id==e.id){u=d;break}{const t=e.findView(o);if(!go(c)||c.call(o,this,t)){u=t;break}}}u&&u!=d&&(this.clearEmbedding(t),t.candidateEmbedView=u.highlight(u.findProxyNode(null,"container"),{embedding:!0})),!u&&d&&this.clearEmbedding(t)},clearEmbedding:function(t){t||(t={});var e=t.candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(t={}){const e=t.candidateEmbedView,n=t.model||this.model,i=t.paper||this.paper;if(e)e.model.embed(n,{ui:!0}),e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null;else{const{validateUnembedding:e}=i.options,{initialParentId:n}=t;if(n&&"function"==typeof e&&!e.call(i,this))return void this._disallowUnembed(t)}i.model.getConnectedLinks(n,{deep:!0}).forEach((t=>{t.reparent({ui:!0})}))},_disallowUnembed:function(t){const{model:e,whenNotAllowed:n="revert"}=t,i=e||this.model,r=(t.paper||this.paper).model;switch(n){case"remove":i.remove({ui:!0});break;case"revert":{const{initialParentId:e,initialPosition:n,initialZIndices:o}=t;if(n){const{x:t,y:e}=n;i.position(t,e,{deep:!0,ui:!0})}o&&Object.keys(o).forEach((t=>{const e=r.getCell(t);e&&e.set("z",o[t],{ui:!0})}));const s=r.getCell(e);s&&s.embed(i,{ui:!0});break}}},getDelegatedView:function(){for(var t=this,e=t.model,n=t.paper;t&&!e.isLink();){if(!e.isEmbedded()||t.can("stopDelegation"))return t;e=e.getParentCell(),t=n.findViewByModel(e)}return null},findProxyNode:function(t,e){t||(t=this.el);const n=t.getAttribute(`${e}-selector`);if(n){const e=this.findAttribute("port",t);if(e){const t=this.findPortNode(e,n);if(t)return t}else{const t=this.findNode(n);if(t)return t}}return t},notifyPointerdown(t,e,n){Rc.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove(t,e,n){Rc.prototype.pointermove.call(this,t,e,n),this.notify("element:pointermove",t,e,n)},notifyPointerup(t,e,n){this.notify("element:pointerup",t,e,n),Rc.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){Rc.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){Rc.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){Rc.prototype.contextmenu.apply(this,arguments),this.notify("element:contextmenu",t,e,n)},pointerdown:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragStart(t,e,n)},pointermove:function(t,e,n){const i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointermove(t,r,e,n),o){case Dc:this.dragMagnet(t,e,n);break;case Ic:(s||this).drag(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){const i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointerup(t,r,e,n),o){case Dc:this.dragMagnetEnd(t,e,n);break;case Ic:(s||this).dragEnd(t,e,n);default:if(i.preventPointerEvents)break;this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){Rc.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){Rc.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){Rc.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){Rc.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){Rc.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,n,i)},onmagnet:function(t,e,n){const{currentTarget:i}=t;this.magnetpointerdown(t,i,e,n),this.eventData(t,{targetMagnet:i}),this.dragMagnetStart(t,e,n)},magnetpointerdown:function(t,e,n,i){this.notify("element:magnet:pointerdown",t,e,n,i)},magnetpointermove:function(t,e,n,i){this.notify("element:magnet:pointermove",t,e,n,i)},magnetpointerup:function(t,e,n,i){this.notify("element:magnet:pointerup",t,e,n,i)},magnetpointerdblclick:function(t,e,n,i){this.notify("element:magnet:pointerdblclick",t,e,n,i)},magnetcontextmenu:function(t,e,n,i){this.notify("element:magnet:contextmenu",t,e,n,i)},dragStart:function(t,e,n){if(this.isDefaultInteractionPrevented(t))return;var i=this.getDelegatedView();if(!i||!i.can("elementMove"))return;this.eventData(t,{action:Ic,delegatedView:i});const r=i.model.position();i.eventData(t,{initialPosition:r,pointerOffset:r.difference(e,n),restrictedArea:this.paper.getRestrictedArea(i,e,n)})},dragMagnetStart:function(t,e,n){const{paper:i}=this,r=t.isPropagationStopped();if(r&&this.eventData(t,{preventPointerEvents:!0}),this.isDefaultInteractionPrevented(t)||!this.can("addLinkFromMagnet"))return;const{targetMagnet:o=t.currentTarget}=this.eventData(t);t.stopPropagation(),i.options.validateMagnet.call(i,this,o,t)?(i.options.magnetThreshold<=0&&this.dragLinkStart(t,o,e,n),this.eventData(t,{action:Dc})):r?this.dragStart(t,e,n):this.pointerdown(t,e,n)},drag:function(t,e,n){var i=this.paper,r=i.options.gridSize,o=this.model,s=this.eventData(t),{pointerOffset:a,restrictedArea:l,embedding:c}=s,h=Mt(e+a.x,r),u=Mt(n+a.y,r);o.position(h,u,{restrictedArea:l,deep:!0,ui:!0}),i.options.embeddingMode&&(c||(this.prepareEmbedding(s),c=!0),this.processEmbedding(s,t,e,n)),this.eventData(t,{embedding:c})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){var i=this.eventData(t);i.embedding&&this.finalizeEmbedding(i)},dragMagnetEnd:function(t,e,n){this.dragLinkEnd(t,e,n)},magnetpointerclick:function(t,e,n,i){var r=this.paper;r.eventData(t).mousemoved>r.options.clickThreshold||this.notify("element:magnet:pointerclick",t,e,n,i)}},{Flags:Bc});io(Vc.prototype,zl);const zc=function(t,e,n){return t},jc=function(t,e,n){var i,r,o,s=e.side||"bottom",a=Qs(e.padding||40),l=n.sourceBBox,c=n.targetBBox,h=l.center(),u=c.center();switch(s){case"bottom":o=1,i="y",r="height";break;case"top":o=-1,i="y",r="height";break;case"left":o=-1,i="x",r="width";break;case"right":o=1,i="x",r="width";break;default:throw new Error("Router: invalid side")}return h[i]+=o*(l[r]/2+a[s]),u[i]+=o*(c[r]/2+a[s]),o*(h[i]-u[i])>0?u[i]=h[i]:h[i]=u[i],[h].concat(t,u)};var $c={N:"S",S:"N",E:"W",W:"E"},Uc={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function Gc(t,e,n){var i=new Jt(t.x,e.y);return n.containsPoint(i)&&(i=new Jt(e.x,t.y)),i}function qc(t,e){return t["W"===e||"E"===e?"width":"height"]}function Hc(t,e){return t.x===e.x?t.y>e.y?"N":"S":t.y===e.y?t.x>e.x?"W":"E":null}function Wc(t){return new me(t.x,t.y,0,0)}function Yc(t){var e=Qs(t.padding||t.elementPadding||20);return{x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}function Xc(t,e){return t.sourceBBox.clone().moveAndExpand(Yc(e))}function Zc(t,e){return t.targetBBox.clone().moveAndExpand(Yc(e))}function Kc(t,e,n){var i=new Jt(t.x,e.y),r=new Jt(e.x,t.y),o=Hc(t,i),s=Hc(t,r),a=$c[n],l=o===n||o!==a&&(s===a||s!==n)?i:r;return{points:[l],direction:Hc(l,e)}}function Jc(t,e,n){var i=Gc(t,e,n);return{points:[i],direction:Hc(i,e)}}function Qc(t,e,n,i){var r,o={},s=[new Jt(t.x,e.y),new Jt(e.x,t.y)],a=s.filter((function(t){return!n.containsPoint(t)})),l=a.filter((function(e){return Hc(e,t)!==i}));if(l.length>0)r=(r=l.filter((function(e){return Hc(t,e)===i})).pop())||l[0],o.points=[r],o.direction=Hc(r,e);else{r=xo(s,a)[0];var c=new Jt(e).move(r,-qc(n,i)/2),h=Gc(c,t,n);o.points=[h,c],o.direction=Hc(c,e)}return o}function th(t,e,n,i){var r=Jc(e,t,i),o=r.points[0];if(n.containsPoint(o)){var s=(r=Jc(t,e,n)).points[0];if(i.containsPoint(s)){var a=new Jt(t).move(s,-qc(n,Hc(t,s))/2),l=new Jt(e).move(o,-qc(i,Hc(e,o))/2),c=new ne(a,l).midpoint(),h=Jc(t,c,n),u=Kc(c,e,h.direction);r.points=[h.points[0],u.points[0]],r.direction=u.direction}}return r}function eh(t,e,n,i,r){var o,s,a,l={},c=n.union(i).inflate(1),h=c.center().distance(e)>c.center().distance(t),u=h?e:t,d=h?t:e;return r?(o=Jt.fromPolar(c.width+c.height,Uc[r],u),o=c.pointNearestToPoint(o).move(o,-1)):o=c.pointNearestToPoint(u).move(u,1),s=Gc(o,d,c),o.round().equals(s.round())?(s=Jt.fromPolar(c.width+c.height,Nt(o.theta(u))+Math.PI/2,d),a=Gc(o,s=c.pointNearestToPoint(s).move(d,1).round(),c),l.points=h?[s,a,o]:[o,a,s]):l.points=h?[s,o]:[o,s],l.direction=Hc(h?o:s,e),l}function nh(t,e,n){var i,r=Xc(n,e),o=Zc(n,e),s=function(t,e){return t.sourceAnchor?t.sourceAnchor:Xc(t,e).center()}(n,e),a=function(t,e){return t.targetAnchor?t.targetAnchor:Zc(t,e).center()}(n,e);r=r.union(Wc(s)),o=o.union(Wc(a)),(t=vo(t).map(Jt)).unshift(s),t.push(a);for(var l=[],c=0,h=t.length-1;c<h;c++){var u=null,d=t[c],f=t[c+1],p=!!Hc(d,f);if(0===c)c+1===h?r.intersect(o.clone().inflate(1))?u=eh(d,f,r,o):p||(u=th(d,f,r,o)):r.containsPoint(f)?u=eh(d,f,r,Wc(f).moveAndExpand(Yc(e))):p||(u=Jc(d,f,r));else if(c+1===h){var g=p&&Hc(f,d)===i;o.containsPoint(d)||g?u=eh(d,f,Wc(d).moveAndExpand(Yc(e)),o,i):p||(u=Qc(d,f,o,i))}else p||(u=Kc(d,f,i));u?(Array.prototype.push.apply(l,u.points),i=u.direction):i=Hc(d,f),c+1<h&&l.push(f)}return l}var ih={step:10,maximumLoops:2e3,precision:1,maxAllowedDirectionChange:90,perpendicular:!0,excludeEnds:[],excludeTypes:[],startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}},cost:function(){return this.step},directions:function(){var t=this.step,e=this.cost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:-t,offsetY:0,cost:e},{offsetX:0,offsetY:t,cost:e},{offsetX:0,offsetY:-t,cost:e}]},penalties:function(){return{0:0,45:this.step/2,90:this.step/2}},paddingBox:function(){var t=this.step;return{x:-t,y:-t,width:2*t,height:2*t}},isPointObstacle:null,fallbackRouter:function(t,e,n){if(!go(nh))throw new Error("Manhattan requires the orthogonal router as default fallback.");return nh(t,io({},ih,e),n)},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function rh(t){this.map={},this.options=t,this.mapGridSize=100}function oh(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function sh(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function ah(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function lh(t,e){return t.sourceAnchor?t.sourceAnchor:sh(t,e).center()}function ch(t,e,n,i,r){var o=360/n,s=t.theta(function(t,e,n,i){var r=i.step,o=e.x-t.x,s=e.y-t.y,a=o/n.x*r,l=s/n.y*r;return new Jt(t.x+a,t.y+l)}(t,e,i,r)),a=Ct(s+o/2);return o*Math.floor(a/o)}function hh(t,e){var n=Math.abs(t-e);return n>180?360-n:n}function uh(t,e){if(!t)return e;var n=Math.abs(t),i=Math.round(n/e);return i?e+(n-i*e)/i:n}function dh(t,e){return t.round(e)}function fh(t,e,n){return dh(function(t,e){var n=e.source,i=Mt(t.x-n.x,e.x)+n.x,r=Mt(t.y-n.y,e.y)+n.y;return new Jt(i,r)}(t.clone(),e),n)}function ph(t){return t.clone().toString()}function gh(t){return new Jt(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function mh(t,e,n,i,r,o,s){for(var a,l=[],c=gh(r.difference(n)),h=ph(n),u=t[h];u;){var d=gh((a=e[h]).difference(u));d.equals(c)||(l.unshift(a),c=d),u=t[h=ph(u)]}var f=e[h];return gh(f.difference(i)).equals(c)||l.unshift(f),l}function vh(t,e){for(var n=1/0,i=0,r=e.length;i<r;i++){var o=t.manhattanDistance(e[i]);o<n&&(n=o)}return n}function yh(t,e,n,i,r){var o=r.precision,s=r.directionMap,a=t.difference(e.center()),l=to(s)?Object.keys(s):[],c=vo(n),h=l.reduce((function(n,r){if(c.includes(r)){for(var l,h=s[r],u=new Jt(t.x+h.x*(Math.abs(a.x)+e.width),t.y+h.y*(Math.abs(a.y)+e.height)),d=new ne(t,u).intersect(e)||[],f=d.length,p=null,g=0;g<f;g++){var m=d[g],v=t.squaredDistance(m);(void 0===l||v>l)&&(l=v,p=m)}if(p){var y=fh(p,i,o);e.containsPoint(y)&&(y=fh(y.offset(h.x*i.x,h.y*i.y),i,o)),n.push(y)}}return n}),[]);return e.containsPoint(t)||h.push(fh(t,i,o)),h}function bh(t,e,n,i){var r,o,s=i.precision;r=dh(t instanceof me?lh(this,i).clone():t.clone(),s),o=dh(e instanceof me?function(t,e){return t.targetAnchor?t.targetAnchor:ah(t,e).center()}(this,i).clone():e.clone(),s);var a,l,c,h,u,d,f,p=(a=i.step,c=o,{source:(l=r).clone(),x:uh(c.x-l.x,a),y:uh(c.y-l.y,a)});if(d=t instanceof me?yh(h=r,t,i.startDirections,p,i):[h=r],e instanceof me?(u=o,f=yh(o,e,i.endDirections,p,i)):f=[u=o],d=d.filter((t=>!n(t))),f=f.filter((t=>!n(t))),d.length>0&&f.length>0){for(var g=new oh,m={},v={},y={},b=0,w=d.length;b<w;b++){var x=d[b],A=ph(x);g.add(A,vh(x,f)),m[A]=x,y[A]=0}var T,E,P=i.previousDirectionAngle,S=void 0===P,_=i.directions;!function(t,e,n){var i=n.step;vo(n.directions).forEach((function(t){t.gridOffsetX=t.offsetX/i*e.x,t.gridOffsetY=t.offsetY/i*e.y}))}(0,p,i);for(var k=_.length,L=vo(f).reduce((function(t,e){var n=ph(e);return t.push(n),t}),[]),C=i.maximumLoops;!g.isEmpty()&&C>0;){var M,O=g.pop(),N=m[O],R=v[O],F=y[O],B=void 0===R,I=N.equals(h);M=B?S?I?null:ch(h,N,k,p,i):P:ch(R,N,k,p,i);var D=d.length===f.length;if(D)for(var V=0;V<d.length;V++)if(!d[V].equals(f[V])){D=!1;break}if((!B||!D)&&L.indexOf(O)>=0)return i.previousDirectionAngle=M,mh(v,m,N,h,u);for(b=0;b<k;b++){var z=(T=_[b]).angle;if(E=hh(M,z),S&&I||!(E>i.maxAllowedDirectionChange)){var j=fh(N.clone().offset(T.gridOffsetX,T.gridOffsetY),p,s),$=ph(j);if(!g.isClose($)&&!n(j)){if(L.indexOf($)>=0&&!j.equals(u)&&hh(z,ch(j,u,k,p,i))>i.maxAllowedDirectionChange)continue;var U=F+T.cost+(I?0:i.penalties[E]);(!g.isOpen($)||U<y[$])&&(m[$]=j,v[$]=N,y[$]=U,g.add($,U+vh(j,f)))}}}C--}}return i.fallbackRoute.call(this,h,u,i)}rh.prototype.build=function(t,e){var n=this.options,i=vo(n.excludeEnds).reduce((function(n,i){var r=e.get(i);if(r){var o=t.getCell(r.id);o&&n.push(o)}return n}),[]),r=[],o=t.getCell(e.get("source").id);o&&(r=Ao(r,o.getAncestors().map((function(t){return t.id}))));var s=t.getCell(e.get("target").id);s&&(r=Ao(r,s.getAncestors().map((function(t){return t.id}))));var a=this.mapGridSize;return t.getElements().reduce((function(t,e){var o=vo(n.excludeTypes).includes(e.get("type")),s=i.find((function(t){return t.id===e.id})),l=r.includes(e.id);if(!(o||s||l))for(var c=e.getBBox().moveAndExpand(n.paddingBox),h=c.origin().snapToGrid(a),u=c.corner().snapToGrid(a),d=h.x;d<=u.x;d+=a)for(var f=h.y;f<=u.y;f+=a){var p=d+"@"+f;t[p]=t[p]||[],t[p].push(c)}return t}),this.map),this},rh.prototype.isPointAccessible=function(t){var e=t.clone().snapToGrid(this.mapGridSize).toString();return vo(this.map[e]).every((function(e){return!e.containsPoint(t)}))},oh.prototype.add=function(t,e){this.hash[t]?this.items.splice(this.items.indexOf(t),1):this.hash[t]=this.OPEN,this.values[t]=e;var n=lo(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(n,0,t)},oh.prototype.remove=function(t){this.hash[t]=this.CLOSE},oh.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},oh.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},oh.prototype.isEmpty=function(){return 0===this.items.length},oh.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};const wh=function(t,e,n){return function(t,e,n){!function(t){if(t.directions=Eo(t,"directions"),t.penalties=Eo(t,"penalties"),t.paddingBox=Eo(t,"paddingBox"),t.padding=Eo(t,"padding"),t.padding){var e=Qs(t.padding);t.paddingBox={x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}vo(t.directions).forEach((function(t){var e=new Jt(0,0),n=new Jt(t.offsetX,t.offsetY);t.angle=Ct(e.theta(n))}))}(e),n.options.perpendicular=!!e.perpendicular;var i=sh(n,e),r=ah(n,e),o=lh(n,e);let s;if("function"==typeof e.isPointObstacle)s=e.isPointObstacle;else{const t=new rh(e);t.build(n.paper.model,n.model),s=e=>!t.isPointAccessible(e)}for(var a,l,c=vo(t).map(Jt),h=[],u=o,d=0,f=c.length;d<=f;d++){var p=null;if(l=a||i,!(a=c[d])&&(a=r,(!n.model.get("source").id||!n.model.get("target").id)&&go(e.draggingRoute))){var g=l===i?o:l,m=a.origin();p=e.draggingRoute.call(n,g,m,e)}if(null===(p=p||bh.call(n,l,a,s,e)))return e.fallbackRouter(t,e,n);var v=p[0];v&&v.equals(u)&&p.shift(),u=p[p.length-1]||u,Array.prototype.push.apply(h,p)}return h}(t,io({},ih,e),n)};var xh={maxAllowedDirectionChange:45,diagonalCost:function(){var t=this.step;return Math.ceil(Math.sqrt(t*t<<1))},directions:function(){var t=this.step,e=this.cost(),n=this.diagonalCost();return[{offsetX:t,offsetY:0,cost:e},{offsetX:t,offsetY:t,cost:n},{offsetX:0,offsetY:t,cost:e},{offsetX:-t,offsetY:t,cost:n},{offsetX:-t,offsetY:0,cost:e},{offsetX:-t,offsetY:-t,cost:n},{offsetX:0,offsetY:-t,cost:e},{offsetX:t,offsetY:-t,cost:n}]},fallbackRoute:function(t,e,n){var i=t.theta(e),r=[],o={x:e.x,y:t.y},s={x:t.x,y:e.y};if(i%180>90){var a=o;o=s,s=a}var l=i%90<45?o:s,c=new ne(t,l),h=90*Math.ceil(i/90),u=Jt.fromPolar(c.squaredLength(),Nt(h+135),l),d=new ne(e,u),f=c.intersection(d),p=f||e,g=f?p:t,m=360/n.directions.length,v=g.theta(e),y=Ct(v+m/2),b=m*Math.floor(y/m);return n.previousDirectionAngle=b,p&&r.push(p.round()),r.push(e),r}};const Ah=function(t,e,n){if(!go(wh))throw new Error("Metro requires the manhattan router.");return wh(t,io({},xh,e),n)},Th={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},Eh=[Th.LEFT,Th.RIGHT,Th.TOP,Th.BOTTOM],Ph={[Th.LEFT]:Th.RIGHT,[Th.RIGHT]:Th.LEFT,[Th.TOP]:Th.BOTTOM,[Th.BOTTOM]:Th.TOP},Sh=[Th.TOP,Th.BOTTOM],_h={0:Th.RIGHT,180:Th.LEFT,270:Th.TOP,90:Th.BOTTOM};function kh(t){return t.angle()}function Lh(t){return new xe(t).simplify({threshold:1}).points}function Ch(t,e){const{point:n,x0:i,y0:r,view:o,bbox:s,direction:a}=t,{point:l,x0:c,y0:h,view:u,bbox:d,direction:f}=e;let p,g;if(o)p=o.model.isLink()?Mh(l,n,o):a===Th.ANCHOR_SIDE?s.sideNearestToPoint(n):a===Th.MAGNET_SIDE?o.model.getBBox().sideNearestToPoint(n):a;else{const t=new me(i,r,0,0);p=Eh.includes(a)?a:t.sideNearestToPoint(l)}if(u)g=u.model.isLink()?Mh(n,l,u):f===Th.ANCHOR_SIDE?d.sideNearestToPoint(l):f===Th.MAGNET_SIDE?u.model.getBBox().sideNearestToPoint(l):f;else{const t=new me(c,h,0,0);g=Eh.includes(f)?f:t.sideNearestToPoint(n)}return[p,g]}function Mh(t,e,n){const i=n.getTangentAtLength(n.getClosestPointLength(e)),r=90*Math.round(kh(i)/90);if(r%180==0&&t.y===e.y)return t.x<e.x?Th.LEFT:Th.RIGHT;if(t.x===e.x)return t.y<e.y?Th.TOP:Th.BOTTOM;switch(r){case 0:case 180:case 360:return t.y<e.y?Th.TOP:Th.BOTTOM;case 90:case 270:return t.x<e.x?Th.LEFT:Th.RIGHT}}function Oh(t,e,n,i,r,o,s){i===Th.AUTO&&(i=r?Th.MAGNET_SIDE:Th.ANCHOR_SIDE);const a=t&&t.model.isElement(),{x:l,y:c,width:h=0,height:u=0}=a?me.fromRectUnion(n,t.model.getBBox()):o;return{point:e,x0:l,y0:c,view:t,bbox:n,width:h,height:u,direction:i,margin:a?s:0}}function Nh({x:t,y:e}){const n=new Jt(t,e);return{point:n,x0:n.x,y0:n.y,view:null,bbox:new me(t,e,0,0),width:0,height:0,direction:null,margin:0}}function Rh(t,e,n){const i=e.point.clone(),{x0:r,y0:o,width:s,height:a}=e;switch(t){case"left":i.x=r-n;break;case"right":i.x=r+s+n;break;case"top":i.y=o-n;break;case"bottom":i.y=o+a+n}return i}function Fh(t,e,n={}){const{point:i,x0:r,y0:o,width:s,height:a,margin:l}=t,{point:c,x0:h,y0:u,width:d,height:f,margin:p}=e,{targetInSourceBBox:g=!1}=n,m=h+d,v=u+f,y=r+s,b=o+a,w=r-l,x=y+l,A=o-l,T=b+l,E=h-p,P=m+p,S=u-p,_=v+p,[k,L]=Ch(t,e),C=Rh(k,{point:i,x0:r,y0:o,width:s,height:a},l),M=Rh(L,{point:c,x0:h,y0:u,width:d,height:f},p),{x:O,y:N}=C,{x:R,y:F}=M,B=((r+y)/2<(h+m)/2?y+h:m+r)/2,I=((o+b)/2<(u+v)/2?b+u:v+o)/2,D=new me(r,o,s,a),V=new me(h,u,d,f),z=D.clone().inflate(l),j=V.clone().inflate(p);if("left"===k&&"right"===L){if(w<=P){let t=I;return O<=E&&(v>=A&&F<N?t=Math.min(S,A):u<=T&&F>=N&&(t=Math.max(_,T))),[{x:O,y:N},{x:O,y:t},{x:R,y:t},{x:R,y:F}]}const t=(O+R)/2;return[{x:t,y:N},{x:t,y:F}]}if("right"===k&&"left"===L){if(O>=E){let t=I;return O>m&&(v>=A&&F<N?t=Math.min(S,A):u<=T&&F>=N&&(t=Math.max(_,T))),[{x:O,y:N},{x:O,y:t},{x:R,y:t},{x:R,y:F}]}const t=(O+R)/2;return[{x:t,y:N},{x:t,y:F}]}if("top"===k&&"bottom"===L){const t=wn.rectWithRect(z,V);if(N<F){let e=B,n=N;return t&&(n=Math.min(n,S)),m>=w&&R<O?e=Math.min(E,w):h<=x&&R>=O&&(e=Math.max(P,x)),[{x:O,y:n},{x:e,y:n},{x:e,y:F},{x:R,y:F}]}const e=(N+F)/2;return[{x:O,y:e},{x:R,y:e}]}if("bottom"===k&&"top"===L){const t=wn.rectWithRect(z,V);if(N>F){let e=B,n=N;return t&&(n=Math.max(n,_)),m>=w&&R<O?e=Math.min(E,w):h<=x&&R>=O&&(e=Math.max(P,x)),[{x:O,y:n},{x:e,y:n},{x:e,y:F},{x:R,y:F}]}const e=(N+F)/2;return[{x:O,y:e},{x:R,y:e}]}if("top"===k&&"top"===L){if(g||wn.rectWithRect(z,V)||N<=u&&(z.bottomRight().x<=R||z.bottomLeft().x>=R)||N>=u&&(j.bottomRight().x<=O||j.bottomLeft().x>=O))return[{x:O,y:Math.min(N,F)},{x:R,y:Math.min(N,F)}];let t,e=Math.min((b+u)/2,F),n=Math.min((o+v)/2,N);return t=F<N?R>O?Math.min(O,E):Math.max(O,P):R>=O?Math.max(R,x):Math.min(R,w),[{x:O,y:n},{x:t,y:n},{x:t,y:e},{x:R,y:e}]}if("bottom"===k&&"bottom"===L){if(g||wn.rectWithRect(z,V)||N>=F&&(z.topRight().x<=R||z.topLeft().x>=R)||N<=F&&(j.topRight().x<=O||j.topLeft().x>=O))return[{x:O,y:Math.max(N,F)},{x:R,y:Math.max(N,F)}];let t,e=Math.max((o+v)/2,F),n=Math.max((b+u)/2,N);return t=F>N?R>O?Math.min(O,E):Math.max(O,P):R>=O?Math.max(R,x):Math.min(R,w),[{x:O,y:n},{x:t,y:n},{x:t,y:e},{x:R,y:e}]}if("left"===k&&"left"===L){if(g||wn.rectWithRect(z,V)||O<=R&&(z.bottomRight().y<=F||z.topRight().y>=F)||O>=R&&(j.bottomRight().y<=N||j.topRight().y>=N))return[{x:Math.min(O,R),y:N},{x:Math.min(O,R),y:F}];let t,e=Math.min((y+h)/2,R),n=Math.min((r+m)/2,O);return t=R>O?F<=N?Math.min(A,F):Math.max(T,F):F>=N?Math.min(S,N):Math.max(_,N),[{x:n,y:N},{x:n,y:t},{x:e,y:t},{x:e,y:F}]}if("right"===k&&"right"===L){if(g||wn.rectWithRect(z,V)||O>=R&&(z.bottomLeft().y<=F||z.topLeft().y>=F)||O<=R&&(j.bottomLeft().y<=N||j.topLeft().y>=N))return[{x:Math.max(O,R),y:N},{x:Math.max(O,R),y:F}];let t,e=Math.max((r+m)/2,R),n=Math.max((y+h)/2,O);return t=R<=O?F<=N?Math.min(A,F):Math.max(T,F):F>=N?Math.min(S,N):Math.max(_,N),[{x:n,y:N},{x:n,y:t},{x:e,y:t},{x:e,y:F}]}if("top"===k&&"right"===L){if(z.containsPoint(c)){if(O<=P){const t=Math.max(O+l,R),e=Math.min(A,S);return[{x:O,y:e},{x:t,y:e},{x:t,y:F}]}const t=(O-l+R)/2;return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if(A>F){if(O<R){let t=S;return _<=A&&P>=O&&(t=I),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.max(B,P);if(O>R&&b>=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t>w&&N<v){const t=Math.min(A,S),e=Math.max(x,P);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("top"===k&&"left"===L){if(z.containsPoint(c)){if(O>=E){const t=Math.min(O-l,R),e=Math.min(A,S);return[{x:O,y:e},{x:t,y:e},{x:t,y:F}]}const t=(O+l+R)/2;return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if(A>F){if(O>R){let t=S;return _<=A&&E<=O&&(t=I),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.min(E,B);if(O<R&&b>=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t<x&&N<v){const t=Math.min(A,S),e=Math.min(w,E);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("bottom"===k&&"right"===L){if(z.containsPoint(c)){if(O<=P){const t=Math.max(O+l,R),e=Math.max(T,_);return[{x:O,y:e},{x:t,y:e},{x:t,y:F}]}const t=(O-l+R)/2;return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if(T<F){if(O<R){let t=_;return S>=T&&P>=O&&(t=I),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.max(B,P);if(O>R&&o<=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t>w&&N>u){const t=Math.max(T,_),e=Math.max(x,P);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("bottom"===k&&"left"===L){if(z.containsPoint(c)){if(O>=E){const t=Math.min(O-l,R),e=Math.max(T,_);return[{x:O,y:e},{x:t,y:e},{x:t,y:F}]}const t=(O+l+R)/2;return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if(T<F){if(O>R){let t=_;return S>=T&&E<=O&&(t=I),[{x:O,y:t},{x:R,y:t},{x:R,y:F}]}return[{x:O,y:F}]}const t=Math.min(E,B);if(O<R&&o<=F)return[{x:O,y:N},{x:t,y:N},{x:t,y:F}];if(t<x&&N>u){const t=Math.max(T,_),e=Math.min(w,E);return[{x:O,y:t},{x:e,y:t},{x:e,y:F}]}return[{x:O,y:N},{x:t,y:N},{x:t,y:F}]}if("left"===k&&"bottom"===L){if(z.containsPoint(c)){if(N<=_){const t=Math.min(w,E),e=Math.max(N+l,F);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}const t=(N-l+F)/2;return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if(w>R){if(N<F){let t=E;return P<=w&&_>=N&&(t=B),[{x:t,y:N},{x:t,y:F},{x:R,y:F}]}return[{x:R,y:N}]}const t=Math.max(_,I);if(N>F&&y>=R)return[{x:O,y:N},{x:O,y:t},{x:R,y:t}];if(t>A&&O<m){const t=Math.min(w,E),e=Math.max(T,_);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if("left"===k&&"top"===L){if(z.containsPoint(c)){if(N>=S){const t=Math.min(N-l,F),e=Math.min(w,E);return[{x:e,y:N},{x:e,y:t},{x:R,y:t}]}const t=(N+l+F)/2;return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if(w>R){if(N>F){let t=E;return P<=w&&S<=N&&(t=B),[{x:t,y:N},{x:t,y:F},{x:R,y:F}]}return[{x:R,y:N}]}const t=Math.min(S,I);if(N<F&&y>=R)return[{x:O,y:N},{x:O,y:t},{x:R,y:t}];if(t<T&&O<m){const t=Math.min(w,E),e=Math.min(A,S);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if("right"===k&&"top"===L){if(z.containsPoint(c)){if(N>=S){const t=Math.max(x,P),e=Math.min(N-l,F);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}const t=(N+l+F)/2;return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if(x<R){if(N>F){let t=P;return E>=x&&S<=N&&(t=B),[{x:t,y:N},{x:t,y:F},{x:R,y:F}]}return[{x:R,y:N}]}const t=Math.min(S,I);if(N<F&&r<=R)return[{x:O,y:N},{x:O,y:t},{x:R,y:t}];if(t<T&&O>h){const t=Math.max(x,P),e=Math.min(A,S);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if("right"===k&&"bottom"===L){if(z.containsPoint(c)){if(N<=_){const t=Math.max(x,P),e=Math.max(N+l,F);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}const t=(N-l+F)/2;return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}if(x<R){if(N<F){let t=P;return E>=x&&_>=N&&(t=B),[{x:t,y:N},{x:t,y:F},{x:R,y:F}]}return[{x:R,y:N}]}const t=Math.max(_,I);if(N>F&&r<=R)return[{x:O,y:N},{x:O,y:t},{x:R,y:t}];if(t>A&&O>h){const t=Math.max(x,P),e=Math.max(T,_);return[{x:t,y:N},{x:t,y:e},{x:R,y:e}]}return[{x:O,y:N},{x:O,y:t},{x:R,y:t}]}}function Bh(t,e,n){const{sourceDirection:i=Th.AUTO,targetDirection:r=Th.AUTO}=e,o=e.margin||20,s=e.useVertices||!1,a=!!n.model.source().port,l=Oh(n.sourceView,n.sourceAnchor,n.sourceBBox,i,a,n.sourceAnchor,o),c=!!n.model.target().port,h=Oh(n.targetView,n.targetAnchor,n.targetBBox,r,c,n.targetAnchor,o);let u=[];if(!s||0===t.length)return Lh(Fh(l,h));const d=t.map((t=>Nh(t))),[f]=d;if(l.view&&l.view.model.isElement()&&l.view.model.getBBox().inflate(o).containsPoint(f.point)){const[t]=Ch(l,f),e=t,n=Nh(l.point);n.margin=o,n.direction=t,f.direction=e,u.push(...Fh(n,f,{targetInSourceBBox:!0}),f.point)}else{const t=function(t,e,n){const[i]=Ch(t,e);switch(i){case Th.TOP:return function(t,e,n){const{x0:i,y0:r,width:o,height:s,point:a,margin:l}=t,c=r+s,h=i-l,u=i+o+l,d=r-l,{x:f}=a,{x0:p,y0:g}=e;return p===f&&g<r?Th.BOTTOM:p<f&&g<d?n.point.x===f?Th.BOTTOM:Th.RIGHT:p>f&&g<d?n.point.x===f?Th.BOTTOM:Th.LEFT:p<h&&g>=r||p>u&&g>=r?Th.TOP:p>=h&&p<=f&&g>c||p<=u&&p>=f&&g>c?n.point.x<p?Th.RIGHT:Th.LEFT:Th.TOP}(t,e,n);case Th.RIGHT:return function(t,e,n){const{y0:i,x0:r,width:o,height:s,point:a,margin:l}=t,c=r+o,h=c+l,u=i-l,d=i+s+l,{x:f,y:p}=a,{x0:g,y0:m}=e;return g>f&&m===p?Th.LEFT:g>=h&&m<p?Th.BOTTOM:g>=h&&m>p?Th.TOP:g<=c&&m<=u||g<=c&&m>=d?Th.RIGHT:g<r&&m>=u&&m<=p||g<r&&m<=d&&m>=p?n.point.y<m?Th.BOTTOM:Th.TOP:Th.RIGHT}(t,e,n);case Th.BOTTOM:return function(t,e,n){const{x0:i,y0:r,width:o,height:s,point:a,margin:l}=t,c=r+s,h=i-l,u=i+o+l,d=c+l,{x:f}=a,{x0:p,y0:g}=e;return p===f&&g>c?Th.TOP:p<f&&g>d?n.point.x===f?Th.TOP:Th.RIGHT:p>f&&g>d?n.point.x===f?Th.TOP:Th.LEFT:p<h&&g<=c||p>u&&g<=c?Th.BOTTOM:p>=h&&p<=f&&g<r||p<=u&&p>=f&&g<r?n.point.x<p?Th.RIGHT:Th.LEFT:Th.BOTTOM}(t,e,n);case Th.LEFT:return function(t,e,n){const{y0:i,x0:r,width:o,height:s,point:a,margin:l}=t,c=r+o,h=r-l,u=i-l,d=i+s+l,{x:f,y:p}=a,{x0:g,y0:m}=e;return g<f&&m===p?Th.RIGHT:g<=h&&m<p?Th.BOTTOM:g<=h&&m>p?Th.TOP:g>=r&&m<=u||g>=r&&m>=d?Th.LEFT:g>c&&m>=u&&m<=p||g>c&&m<=d&&m>=p?n.point.y<m?Th.BOTTOM:Th.TOP:Th.LEFT}(t,e,n)}}(l,f,d[1]||h);f.direction=t,u.push(...Fh(l,f),f.point)}for(let t=0;t<d.length-1;t++){const e=d[t],n=d[t+1],i=kh(new ne(e.point,n.point));if(i%90==0){const t=_h[i],r=Ph[t];if(t!==e.direction)u.push(e.point,n.point),n.direction=r;else{const t=Ct(i-90);let r=0,s=0;90===t?s=-o:180===t?r=-o:270===t?s=o:0===t&&(r=o);const a={x:e.point.x+r,y:e.point.y+s},l={x:n.point.x+r,y:n.point.y+s},c=new ne(n.point,l);n.direction=_h[kh(c)],u.push(e.point,a,l,n.point)}continue}const[r,s]=Ih(e,n);e.direction=r,n.direction=s,u.push(...Fh(e,n),n.point)}const p=d[d.length-1];if(h.view&&h.view.model.isElement())if(h.view.model.getBBox().inflate(o).containsPoint(p.point)){const[t]=Ih(p,h),e=Nh(h.point),[,n]=Ch(p,h);e.margin=o,e.direction=n,p.direction=t,u.push(...Fh(p,e))}else{const t=Lh(u),e=new ne(t[t.length-2],p.point),n=_h[Math.round(kh(e))];p.direction=n;let i=Fh(p,h);const[r,s]=Lh([...i,h.point]),a=new ne(r,s),l=Math.round(kh(a)),c=_h[l];c!==n&&n===Ph[c]&&(p.margin=o,i=Fh(p,h)),u.push(...i)}else{const[t]=Ih(p,h);p.direction=t,u.push(...Fh(p,h))}return Lh(u)}function Ih(t,e){const n=t.direction,i=Sh.includes(n);let r=t.direction,o=e.direction;if(i){const i=t.point.y>e.point.y,s=e.point.x-t.point.x;n===Th.BOTTOM?(r=i?Ph[n]:s>=0?Th.RIGHT:Th.LEFT,s>0?o=i?Th.LEFT:Th.TOP:s<0&&(o=i?Th.RIGHT:Th.TOP)):(r=i?s>=0?Th.RIGHT:Th.LEFT:Ph[n],s>0?o=i?Th.BOTTOM:Th.LEFT:s<0&&(o=i?Th.BOTTOM:Th.RIGHT))}else{const i=t.point.x>e.point.x,s=e.point.y-t.point.y;n===Th.RIGHT?(r=i?Ph[n]:s>=0?Th.BOTTOM:Th.TOP,s>0?o=i?Th.TOP:Th.LEFT:s<0&&(o=i?Th.BOTTOM:Th.LEFT)):(r=i?s>=0?Th.BOTTOM:Th.TOP:Ph[n],s>0?o=i?Th.RIGHT:Th.TOP:s<0&&(o=i?Th.RIGHT:Th.BOTTOM))}return[r,o]}Bh.Directions=Th;const Dh=Bh,Vh={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},zh=Object.values(Vh),jh=10,$h=1,Uh=function(t,e,n=[],i={}){const{cornerType:r=Vh.POINT,cornerRadius:o=jh,cornerPreserveAspectRatio:s=!1,precision:a=$h,raw:l=!1}=i;if(-1===zh.indexOf(r))throw new Error("Invalid `cornerType` provided to `straight` connector.");let c;if(r!==Vh.POINT&&o){let i;c=new Le,c.appendSegment(Le.createSegment("M",t));const l=n.length;for(let h=0;h<l;h++){const l=new Jt(n[h]),u=n[h-1]||t,d=n[h+1]||e,f=i||l.distance(u)/2;let p,g;i=l.distance(d)/2,s?p=g=-Math.min(o,f,i):(p=-Math.min(o,f),g=-Math.min(o,i));const m=l.clone().move(u,p).round(a),v=l.clone().move(d,g).round(a);switch(c.appendSegment(Le.createSegment("L",m)),r){case Vh.CUBIC:{const t=1/3,e=2/3,n=new Jt(t*m.x+e*l.x,e*l.y+t*m.y),i=new Jt(t*v.x+e*l.x,e*l.y+t*v.y);c.appendSegment(Le.createSegment("C",n,i,v));break}case Vh.LINE:c.appendSegment(Le.createSegment("L",v));break;case Vh.GAP:c.appendSegment(Le.createSegment("M",v))}}c.appendSegment(Le.createSegment("L",e))}else{const i=[t].concat(n).concat([e]),r=new xe(i);c=new Le(r)}return l?c:c.serialize()};var Gh=["arc","gap","cubic"],qh=["smooth"],Hh=1/3,Wh=2/3;function Yh(t,e){let{x:n,y:i}=t,{x:r,y:o}=e;if(n>r){let t=n;n=r,r=t,t=i,i=o,o=t}if(i>o){let t=n;n=r,r=t,t=i,i=o,o=t}return[new Jt(n,i),new Jt(r,o)]}function Xh(t,e,n){var i=[].concat(t,n,e);return i.reduce((function(t,e,n){var r=i[n+1];return null!=r&&(t[n]=ie(e,r)),t}),[])}function Zh(t,e){return ie(t,e).squaredLength()}function Kh(t,e,n,i){var r,o=new Le;return r=Le.createSegment("M",t[0].start),o.appendSegment(r),vo(t).forEach((function(s,a){if(s.isJump){var l,c,h,u;if("arc"===n){l=-90,c=s.start.difference(s.end);var d=Number(c.x<0||0===c.x&&c.y<0);d&&(l+=180);var f,p=s.midpoint(),g=new ne(p,s.end).rotate(p,l);h=(f=new ne(s.start,p)).pointAt(2/3).rotate(s.start,l),u=g.pointAt(1/3).rotate(g.end,-l),r=Le.createSegment("C",h,u,g.end),o.appendSegment(r),f=new ne(p,s.end),h=g.pointAt(1/3).rotate(g.end,l),u=f.pointAt(1/3).rotate(s.end,-l),r=Le.createSegment("C",h,u,s.end),o.appendSegment(r)}else if("gap"===n)r=Le.createSegment("M",s.end),o.appendSegment(r);else if("cubic"===n){l=s.start.theta(s.end);var m=.6*e,v=1.35*e;c=s.start.difference(s.end),(d=Number(c.x<0||0===c.x&&c.y<0))&&(v*=-1),h=Jt(s.start.x+m,s.start.y+v).rotate(s.start,l),u=Jt(s.end.x-m,s.end.y+v).rotate(s.end,l),r=Le.createSegment("C",h,u,s.end),o.appendSegment(r)}}else{var y=t[a+1];0==i||!y||y.isJump?(r=Le.createSegment("L",s.end),o.appendSegment(r)):function(t,e,n,i,r){var o,s=n.distance(i)/2,a=n.distance(r)/2,l=-Math.min(t,s),c=-Math.min(t,a),h=n.clone().move(i,l).round(),u=n.clone().move(r,c).round(),d=new Jt(Hh*h.x+Wh*n.x,Wh*n.y+Hh*h.y),f=new Jt(Hh*u.x+Wh*n.x,Wh*n.y+Hh*u.y);o=Le.createSegment("L",h),e.appendSegment(o),o=Le.createSegment("C",d,f,u),e.appendSegment(o)}(i,o,s.end,s.start,y.end)}})),o}const Jh=function(t,e,n,i){!function(t){var e=t.paper,n=e._jumpOverUpdateList;if(null==n){n=e._jumpOverUpdateList=[];var i=e.model;i.on("batch:stop",(function(){this.hasActiveBatch()||function(t){for(var e=t._jumpOverUpdateList,n=0;n<e.length;n++){const t=e[n],i=t.getFlag(t.constructor.Flags.CONNECTOR);t.requestUpdate(i)}}(e)})),i.on("reset",(function(){n=e._jumpOverUpdateList=[]}))}n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",(function(){n.splice(n.indexOf(t),1)})))}(this);var r=i.raw,o=i.size||5,s=i.jump&&(""+i.jump).toLowerCase(),a=i.radius||0,l=i.ignoreConnectors||qh;-1===Gh.indexOf(s)&&(s=Gh[0]);var c=this.paper,h=c.model.getLinks();if(1===h.length)return Kh(Xh(t,e,n),o,s,a);var u=this.model,d=h.indexOf(u),f=c.options.defaultConnector||{},p=h.filter((function(t,e){var n=t.get("connector")||f;return!(vo(l).includes(n.name)||e>d&&"jumpover"===n.name)})),g=p.map((function(t){return c.findViewByModel(t)})),m=Xh(t,e,n),v=g.map((function(t){return null==t?[]:t===this?m:Xh(t.sourcePoint,t.targetPoint,t.route)}),this),y=m.reduce((function(t,e){var n=p.reduce((function(t,n,i){if(n!==u){const n=v[i].slice(),r=n.findIndex((t=>function(t,e){const[{x:n,y:i},{x:r,y:o}]=Yh(t.start,t.end),[{x:s,y:a},{x:l,y:c}]=Yh(e.start,e.end);return n<=l&&s<=r&&i<=c&&a<=o}(e,t)));r>-1&&e.containsPoint(n[r].end)&&n.splice(r+1,1);const o=function(t,e){return vo(e).reduce((function(e,n){var i=t.intersection(n);return i&&e.push(i),e}),[])}(e,n);t.push.apply(t,o)}return t}),[]).sort((function(t,n){return Zh(e.start,t)-Zh(e.start,n)}));return n.length>0?t.push.apply(t,function(t,e,n){return e.reduce((function(i,r,o){if(!0===r.skip)return i;var s=i.pop()||t,a=Qt(r).move(s.start,-n),l=Qt(r).move(s.start,+n),c=e[o+1];if(null!=c){var h=l.distance(c);h<=n&&(l=c.move(s.start,h),c.skip=!0)}else if(a.distance(s.end)<2*n+1)return i.push(s),i;if(l.distance(s.start)<2*n+1)return i.push(s),i;var u=ie(a,l);return u.isJump=!0,i.push(ie(s.start,a),u,ie(l,s.end)),i}),[])}(e,n,o)):t.push(e),t}),[]),b=Kh(y,o,s,a);return r?b:b.serialize()},Qh=function(t,e,n=[],i={}){const{raw:r}=i;return Uh(t,e,n,{cornerType:"point",raw:r})},tu=10,eu=function(t,e,n=[],i={}){const{radius:r=tu,raw:o}=i;return Uh(t,e,n,{cornerType:"cubic",cornerRadius:r,precision:0,raw:o})},nu=function(t,e,n,i){var r,o=i&&i.raw;if(n&&0!==n.length){var s=[t].concat(n).concat([e]),a=_e.throughPoints(s);r=new Le(a)}else{var l;if(r=new Le,l=Le.createSegment("M",t),r.appendSegment(l),Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)){var c=(t.x+e.x)/2;l=Le.createSegment("C",c,t.y,c,e.y,e.x,e.y),r.appendSegment(l)}else{var h=(t.y+e.y)/2;l=Le.createSegment("C",t.x,h,e.x,h,e.x,e.y),r.appendSegment(l)}}return o?r:r.serialize()},iu={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},ru={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},ou=function(t,e,n=[],i={},r){const o=Boolean(i.raw),{direction:s=iu.AUTO,precision:a=3}=i,l={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new Jt(i.sourceTangent):null,targetTangent:i.targetTangent?new Jt(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?l.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?l.sourceDirection=new Jt(1,0).rotate(null,i.sourceDirection):l.sourceDirection=i.sourceDirection?new Jt(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?l.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?l.targetDirection=new Jt(1,0).rotate(null,i.targetDirection):l.targetDirection=i.targetDirection?new Jt(i.targetDirection).normalize():null;const c=[t,...n,e].map((t=>new Jt(t)));let h,u;if(l.sourceTangent)h=l.sourceTangent;else{const t=function(t,e,n,i){if(i.sourceDirection)switch(i.sourceDirection){case ru.UP:return new Jt(0,-1);case ru.DOWN:return new Jt(0,1);case ru.LEFT:return new Jt(-1,0);case ru.RIGHT:return new Jt(1,0);case ru.AUTO:return su(t,e,i);case ru.CLOSEST_POINT:return lu(0,e);case ru.OUTWARDS:return hu(t,e);default:return i.sourceDirection}switch(n){case iu.HORIZONTAL:return function(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.x>e[1].x?"right":"left";return s=new Jt("left"===r?-1:1,0),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case iu.VERTICAL:return function(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.y>e[1].y?"bottom":"top";return s=new Jt(0,"top"===r?-1:1),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case iu.CLOSEST_POINT:return lu(0,e);case iu.OUTWARDS:return hu(t,e);case iu.AUTO:default:return su(t,e,i)}}(r,c,s,l),e=c[0].distance(c[1])*l.coeff,n=fu(t,c[1].difference(c[0]).normalize());if(n>Math.PI/4){const i=e+(n-Math.PI/4)*l.angleTangentCoefficient;h=t.clone().scale(i,i)}else h=t.clone().scale(e,e)}if(l.targetTangent)u=l.targetTangent;else{const t=function(t,e,n,i){if(i.targetDirection)switch(i.targetDirection){case ru.UP:return new Jt(0,-1);case ru.DOWN:return new Jt(0,1);case ru.LEFT:return new Jt(-1,0);case ru.RIGHT:return new Jt(1,0);case ru.AUTO:return au(t,e,i);case ru.CLOSEST_POINT:return cu(0,e);case ru.OUTWARDS:return uu(t,e);default:return i.targetDirection}switch(n){case iu.HORIZONTAL:return function(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.x>e[e.length-2].x?"left":"right";return s=new Jt("left"===r?-1:1,0),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case iu.VERTICAL:return function(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.y>e[e.length-2].y?"top":"bottom";return s=new Jt(0,"top"===r?-1:1),n.rotate&&o&&s.rotate(null,-o),s}(t,e,i);case iu.CLOSEST_POINT:return cu(0,e);case iu.OUTWARDS:return uu(t,e);case iu.AUTO:default:return au(t,e,i)}}(r,c,s,l),e=c.length-1,n=c[e-1].distance(c[e])*l.coeff,i=fu(t,c[e-1].difference(c[e]).normalize());if(i>Math.PI/4){const e=n+(i-Math.PI/4)*l.angleTangentCoefficient;u=t.clone().scale(e,e)}else u=t.clone().scale(n,n)}const d=function(t,e,n,i){const{tau:r,coeff:o}=i,s=[],a=[],l=[],c=t.length-1;for(let e=0;e<c;e++)s[e]=t[e].distance(t[e+1]);a[0]=e,a[c]=n;for(let e=1;e<c;e++){let n,i;n=1===e?t[e-1].clone().offset(a[e-1].x,a[e-1].y):t[e-1].clone(),i=e===c-1?t[e+1].clone().offset(a[e+1].x,a[e+1].y):t[e+1].clone();const r=n.difference(t[e]).normalize(),l=i.difference(t[e]).normalize(),h=fu(r,l);let u,d=(Math.PI-h)/2;const f=pu(r,l);let p;p=pu(t[e].difference(t[e+1]),t[e].difference(t[e-1])),f<0&&(d=-d),h<Math.PI/2&&(d<0&&p<0||d>0&&p>0)&&(d-=Math.PI),u=l.clone(),du(u,d);const g=u.clone(),m=u.clone(),v=s[e-1]*o,y=s[e]*o;g.scale(v,v),m.scale(y,y),a[e]=[g,m]}for(let e=0;e<c;e++){let n,i;n=0===e?t[e+1].difference(a[e].x/r,a[e].y/r):t[e+1].difference(a[e][1].x/r,a[e][1].y/r),i=e===c-1?t[e].clone().offset(a[e+1].x/r,a[e+1].y/r):t[e].difference(a[e+1][0].x/r,a[e+1][0].y/r),l[e]=[n,t[e],t[e+1],i]}return l}(c,h,u,l),f=d.map((t=>function(t,e){const{tau:n}=e,i=new Jt;i.x=t[1].x+(t[2].x-t[0].x)/(6*n),i.y=t[1].y+(t[2].y-t[0].y)/(6*n);const r=new Jt;return r.x=t[2].x+(t[3].x-t[1].x)/(6*n),r.y=t[2].y+(t[3].y-t[1].y)/(6*n),new _e(t[1],i,r,t[2])}(t,l))),p=new Le(f).round(a);return o?p:p.serialize()};function su(t,e,n){const{sourceBBox:i}=t;let r,o,s;if(t.sourceView)if(o=t.sourceView.model.angle(),n.rotate&&o){const n=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),s=e[0].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[0]);else r=i.sideNearestToPoint(e[1]);switch(r){case"top":s=new Jt(0,-1);break;case"bottom":s=new Jt(0,1);break;case"right":s=new Jt(1,0);break;case"left":s=new Jt(-1,0)}return n.rotate&&o&&s.rotate(null,-o),s}function au(t,e,n){const{targetBBox:i}=t;let r,o,s;if(t.targetView)if(o=t.targetView.model.angle(),n.rotate&&o){const n=t.targetView.getNodeUnrotatedBBox(t.targetView.el),s=e[e.length-1].clone();s.rotate(i.center(),o),r=n.sideNearestToPoint(s)}else r=i.sideNearestToPoint(e[e.length-1]);else r=i.sideNearestToPoint(e[e.length-2]);switch(r){case"top":s=new Jt(0,-1);break;case"bottom":s=new Jt(0,1);break;case"right":s=new Jt(1,0);break;case"left":s=new Jt(-1,0)}return n.rotate&&o&&s.rotate(null,-o),s}function lu(t,e,n){return e[1].difference(e[0]).normalize()}function cu(t,e,n){const i=e.length-1;return e[i-1].difference(e[i]).normalize()}function hu(t,e,n){const{sourceBBox:i}=t,r=i.center();return e[0].difference(r).normalize()}function uu(t,e,n){const{targetBBox:i}=t,r=i.center();return e[e.length-1].difference(r).normalize()}function du(t,e){const n=Math.cos(e),i=Math.sin(e),r=n*t.x-i*t.y,o=i*t.x+n*t.y;t.x=r,t.y=o}function fu(t,e){let n=t.dot(e)/(t.magnitude()*e.magnitude());return n<-1&&(n=-1),n>1&&(n=1),Math.acos(n)}function pu(t,e){return t.x*e.y-t.y*e.x}ou.Directions=iu,ou.TangentDirections=ru;const gu={TOOLS:Rc.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"},mu=Rc.extend({className:function(){var t=Rc.prototype.className.apply(this).split(" ");return t.push("link"),t.join(" ")},_labelCache:null,_labelSelectors:null,_V:null,_dragData:null,metrics:null,decimalsRounding:2,initialize:function(){Rc.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[gu.RENDER],attrs:[gu.UPDATE],router:[gu.UPDATE],connector:[gu.CONNECTOR],labels:[gu.LABELS],labelMarkup:[gu.LABELS],vertices:[gu.UPDATE],source:[gu.SOURCE,gu.UPDATE],target:[gu.TARGET,gu.UPDATE]},initFlag:[gu.RENDER,gu.SOURCE,gu.TARGET,gu.TOOLS],UPDATE_PRIORITY:1,confirmUpdate:function(t,e){if(e||(e={}),this.hasFlag(t,gu.SOURCE)){if(!this.updateEndProperties("source"))return t;t=this.removeFlag(t,gu.SOURCE)}if(this.hasFlag(t,gu.TARGET)){if(!this.updateEndProperties("target"))return t;t=this.removeFlag(t,gu.TARGET)}const{paper:n,sourceView:i,targetView:r}=this;if(n&&(i&&!n.isViewMounted(i)||r&&!n.isViewMounted(r)))return t;if(this.hasFlag(t,gu.RENDER))return this.render(),this.updateHighlighters(!0),this.updateTools(e),this.removeFlag(t,[gu.RENDER,gu.UPDATE,gu.LABELS,gu.TOOLS,gu.CONNECTOR]);let o=!1;const{model:s}=this,{attributes:a}=s;let l=this.hasFlag(t,gu.LABELS);l&&(this.onLabelsChange(s,a.labels,e),t=this.removeFlag(t,gu.LABELS),o=!0);const c=this.hasFlag(t,gu.UPDATE),h=this.hasFlag(t,gu.CONNECTOR);return(c||h)&&(c?e.translateBy&&s.isRelationshipEmbeddedIn(e.translateBy)?this.translate(e.tx,e.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(e),t=this.removeFlag(t,[gu.UPDATE,gu.TOOLS,gu.CONNECTOR]),l=!1,o=!0),l&&this.updateLabelPositions(),o&&this.updateHighlighters(),this.hasFlag(t,gu.TOOLS)&&(this.updateTools(e),t=this.removeFlag(t,gu.TOOLS)),t},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(gu.UPDATE),t)},isLabelsRenderRequired:function(t={}){const e=this.model.previous("labels");if(!e)return!0;if("propertyPathArray"in t&&"propertyValue"in t){var n=t.propertyPathArray||[],i=n.length;if(i>1&&e[n[1]]){if(2===i)return"markup"in Object(t.propertyValue);if("markup"!==n[2])return!1}}return!0},onLabelsChange:function(t,e,n){this.isLabelsRenderRequired(n)?this.renderLabels():this.updateLabels()},render:function(){return this.vel.empty(),this.unmountLabels(),this._V={},this.renderMarkup(),this.renderLabels(),this.update(),this},renderMarkup:function(){var t=this.model,e=t.get("markup")||t.markup;if(!e)throw new Error("dia.LinkView: markup required");if(Array.isArray(e))return this.renderJSONMarkup(e);if("string"==typeof e)return this.renderStringMarkup(e);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){var e=this.parseDOMJSON(t,this.el);this.selectors=e.selectors,this.vel.append(e.fragment)},renderStringMarkup:function(t){var e=An(t);Array.isArray(e)||(e=[e]),this.vel.append(e)},_getLabelMarkup:function(t){if(t){if(Array.isArray(t))return this.parseDOMJSON(t,null);if("string"==typeof t)return this._getLabelStringMarkup(t);throw new Error("dia.linkView: invalid label markup")}},_getLabelStringMarkup:function(t){var e=An(t),n=document.createDocumentFragment();if(Array.isArray(e))for(var i=0,r=e.length;i<r;i++){var o=e[i].node;n.appendChild(o)}else n.appendChild(e.node);return{fragment:n,selectors:{}}},_normalizeLabelMarkup:function(t){if(t){var e,n=t.fragment;if(!(t.fragment instanceof DocumentFragment&&t.fragment.hasChildNodes()))throw new Error("dia.LinkView: invalid label markup.");var i=n.childNodes;return(e=i.length>1||"G"!==i[0].nodeName.toUpperCase()?An("g").append(n):An(i[0])).addClass("label"),{node:e.node,selectors:t.selectors}}},renderLabels:function(){var t=this._V,e=t.labels,n=this._labelCache={},i=this._labelSelectors={},r=this.model,o=r.attributes.labels||[],s=o.length;if(0===s)return e&&e.remove(),this;e?e.empty():(e=t.labels=An("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(Fs(Eo(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,c,h=o[a],u=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup));if(u)l=u.node,c=u.selectors;else{var d=r._builtins.defaultLabel,f=this._normalizeLabelMarkup(this._getLabelMarkup(d.markup)),p=r._getDefaultLabel(),g=this._normalizeLabelMarkup(this._getLabelMarkup(p.markup))||f;l=g.node,c=g.selectors}l.setAttribute("label-idx",a),e.append(l),n[a]=l;var m=this.selector;if(c[m])throw new Error("dia.LinkView: ambiguous label root selector.");c[m]=l,i[a]=c}return e.parent()||this.mountLabels(),this.updateLabels(),this},mountLabels:function(){const{el:t,paper:e,model:n,_V:i,options:r}=this,{labels:o}=i;if(!o||!n.hasLabels())return;const{node:s}=o;r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(s,n.get("z")):s.parentNode!==t&&t.appendChild(s)},unmountLabels:function(){const{options:t,_V:e}=this;if(!e)return;const{labels:n}=e;n&&t.labelsLayer&&n.remove()},findLabelNodes:function(t,e){const n=this._labelCache[t];if(!n)return[];const i=this._labelSelectors[t];return this.findBySelector(e,n,i)},findLabelNode:function(t,e){const[n=null]=this.findLabelNodes(t,e);return n},_mergeLabelAttrs:function(t,e,n,i){if(null===e)return null;if(void 0===e){if(null===n)return null;if(void 0===n){if(t)return;return i}return t?n:Mo({},i,n)}return t?Mo({},n,e):Mo({},i,n,e)},_mergeLabelSize:function(t,e){if(null===t)return null;if(void 0===t){if(null===e)return null;if(void 0===e)return;return e}return Mo({},e,t)},updateLabels:function(){if(!this._V.labels)return this;for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,r=t._getDefaultLabel(),o=r.markup,s=r.attrs,a=r.size,l=0,c=e.length;l<c;l++){var h=this._labelCache[l];h.setAttribute("cursor",n?"move":"default");var u=this._labelSelectors[l],d=e[l],f=d.markup,p=d.attrs,g=d.size,m=this._mergeLabelAttrs(f||o,p,s,i),v=this._mergeLabelSize(g,a);this.updateDOMSubtreeAttributes(h,m,{rootBBox:new me(v),selectors:u})}return this},removeRedundantLinearVertices:function(t){const e=this.model,n=e.vertices(),i=[this.sourceAnchor,...n,this.targetAnchor],r=i.length,o=new xe(i);o.simplify({threshold:.001});const s=o.points.map((t=>t.toJSON())),a=s.length;return r===a?0:(e.vertices(s.slice(1,a-1),t),r-a)},getEndView:function(t){switch(t){case"source":return this.sourceView||null;case"target":return this.targetView||null;default:throw new Error("dia.LinkView: type parameter required.")}},getEndAnchor:function(t){switch(t){case"source":return new Jt(this.sourceAnchor);case"target":return new Jt(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new Jt(this.sourcePoint);case"target":return new Jt(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(!e)break;return this.sourceMagnet||e.el;case"target":var n=this.targetView;if(!n)break;return this.targetMagnet||n.el;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(t=0,e=0){const{route:n,path:i}=this;if(!n||!i)return;const r=new xe(n);r.translate(t,e),this.route=r.points,this.sourcePoint.offset(t,e),this.targetPoint.offset(t,e),this.sourceAnchor.offset(t,e),this.targetAnchor.offset(t,e),i.translate(t,e),this.updateDOM()},updateDOM(){const{el:t,model:e,selectors:n}=this;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){const{model:t}=this,e=t.vertices(),n=this.findAnchors(e),i=this.sourceAnchor=n.source,r=this.targetAnchor=n.target,o=this.findRoute(e);this.route=o;var s=this.findConnectionPoints(o,i,r);this.sourcePoint=s.source,this.targetPoint=s.target},updatePath:function(){const{route:t,sourcePoint:e,targetPoint:n}=this,i=this.findPath(t,e.clone(),n.clone());this.path=i},findAnchorsOrdered:function(t,e,n,i){var r,o,s,a,l=this.model,c=l.get(t),h=l.get(n),u=this.getEndView(t),d=this.getEndView(n),f=this.getEndMagnet(t),p=this.getEndMagnet(n);u?(s=e?new Jt(e):d?p:new Jt(h),r=this.getAnchor(c.anchor,u,f,s,t)):r=new Jt(c),d?(a=new Jt(i||r),o=this.getAnchor(h.anchor,d,p,a,n)):o=new Jt(h);var g={};return g[t]=r,g[n]=o,g},findAnchors:function(t){var e=this.model,n=t[0],i=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",i,"source",n):this.findAnchorsOrdered("source",n,"target",i)},findConnectionPoints:function(t,e,n){var i,r,o,s,a=t[0],l=t[t.length-1],c=this.model,h=c.get("source"),u=c.get("target"),d=this.sourceView,f=this.targetView,p=this.paper.options;if(d&&!d.isNodeConnection(this.sourceMagnet)){i=this.sourceMagnet||d.el;var g=h.connectionPoint||p.defaultConnectionPoint,m=new ne(a||n,e);o=this.getConnectionPoint(g,d,i,m,"source")}else o=e;if(f&&!f.isNodeConnection(this.targetMagnet)){r=this.targetMagnet||f.el;var v=u.connectionPoint||p.defaultConnectionPoint,y=new ne(l||e,n);s=this.getConnectionPoint(v,f,r,y,"target")}else s=n;return{source:o,target:s}},getAnchor:function(t,e,n,i,r){var o,s=e.isNodeConnection(n),a=this.paper.options;if(t||(t=s?a.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:a.defaultAnchor),!t)throw new Error("Anchor required.");if("function"==typeof t)o=t;else{var l=t.name;if("function"!=typeof(o=a[s?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}var c=o.call(this,e,n,i,t.args||{},r,this);return c?c.round(this.decimalsRounding):new Jt},getConnectionPoint:function(t,e,n,i,r){var o,s,a=i.end,l=this.paper.options;if(!t)return a;if("function"==typeof t)s=t;else{var c=t.name;if("function"!=typeof(s=l.connectionPointNamespace[c]))throw new Error("Unknown connection point: "+c)}return(o=s.call(this,i,e,n,t.args||{},r,this))?o.round(this.decimalsRounding):a},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,n=t._getDefaultLabel(),i=this._normalizeLabelPosition(n.position);return Mo({},e,i)},_normalizeLabelPosition:function(t){return"number"==typeof t?{distance:t,offset:null,angle:0,args:null}:t},_mergeLabelPositionProperty:function(t,e){return null===t?null:void 0===t?null===e?null:e:Mo({},e,t)},updateLabelPositions:function(){if(!this._V.labels)return this;if(!this.path)return this;var t=this.model.get("labels")||[];if(!t.length)return this;for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r=this._labelCache[n];if(r){var o=t[n],s=this._normalizeLabelPosition(o.position),a=this._mergeLabelPositionProperty(s,e),l=this._getLabelTransformationMatrix(a);r.setAttribute("transform",An.matrixToTransformString(l)),this._cleanLabelMatrices(n)}}return this},_cleanLabelMatrices:function(t){const{metrics:e,_labelSelectors:n}=this,i=n[t];if(i)for(let t in i){const{id:n}=i[t];n&&n in e&&delete e[n].magnetMatrix}},updateEndProperties:function(t){const{model:e,paper:n}=this,i=`${t}View`,r=e.get(t),o=r&&r.id;if(!o)return this[i]=null,this.updateEndMagnet(t),!0;const s=n.getModelById(o);if(!s)throw new Error("LinkView: invalid "+t+" cell.");const a=s.findView(n);return!!a&&(this[i]=a,this.updateEndMagnet(t),!0)},updateEndMagnet:function(t){const e=`${t}Magnet`,n=this.getEndView(t);if(n){let i=n.getMagnetFromLinkEnd(this.model.get(t));i===n.el&&(i=null),this[e]=i}else this[e]=null},_getLabelPositionProperty:function(t){return this.model.label(t).position||{}},_getLabelPositionAngle:function(t){return this._getLabelPositionProperty(t).angle||0},_getLabelPositionArgs:function(t){return this._getLabelPositionProperty(t).args},_getDefaultLabelPositionArgs:function(){return(this.model._getDefaultLabel().position||{}).args},_mergeLabelPositionArgs:function(t,e){return null===t?null:void 0===t?null===e?null:e:Mo({},e,t)},addLabel:function(t,e,n,i){var r,o,s,a=0;"number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(a=e,s=n):s=e):(r=t,o=e,"number"==typeof n?(a=n,s=i):s=n);var l=this._getDefaultLabelPositionArgs(),c=s,h=this._mergeLabelPositionArgs(c,l),u={position:this.getLabelPosition(r,o,a,h)};return this.model.insertLabel(-1,u,s),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,o=i?t.y:e,s=i?e:n,a={x:r,y:o},l=this.getVertexIndex(r,o);return this.model.insertVertex(l,a,s),l},sendToken:function(t,e,n){var i,r,o;to(e)?(i=e.duration,r="reverse"===e.direction,o=e.connection):(i=e,r=!1,o=null);var s={dur:(i=i||1e3)+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"};r&&(s.keyPoints="1;0",s.keyTimes="0;1");var a,l=An(t);if("string"==typeof o)a=this.findNode(o);else{var c=this._V;a=c.connection?c.connection.node:this.el.querySelector("path")}if(!(a instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");l.appendTo(this.paper.cells).animateAlongPath(s,a),setTimeout(function(t,e){return function(){t.remove(),"function"==typeof e&&e()}}(l,n),i)},findRoute:function(t){t||(t=[]);var e=this.paper.options.routerNamespace||h,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(Jt);n=i}var r=go(n)?n:e[n.name];if(!go(r))throw new Error('dia.LinkView: unknown router: "'+n.name+'".');var o=n.args||{};return r.call(this,t,o,this)||t.map(Jt)},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||u,r=this.model.connector(),o=this.paper.options.defaultConnector;r||(r=o||{});var s=go(r)?r:i[r.name];if(!go(s))throw new Error('dia.LinkView: unknown connector: "'+r.name+'".');var a=ho(r.args||{});a.raw=!0;var l=s.call(this,e,n,t,a,this);return"string"==typeof l&&(l=new Le(An.normalizePathData(l))),l},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("data"))return e.data;var n=t.serialize();return e.data=n,n},getConnectionSubdivisions:function(){var t=this.path;if(!t)return null;var e=this.metrics;if(e.hasOwnProperty("segmentSubdivisions"))return e.segmentSubdivisions;var n=t.getSegmentSubdivisions();return e.segmentSubdivisions=n,n},getConnectionLength:function(){var t=this.path;if(!t)return 0;var e=this.metrics;if(e.hasOwnProperty("length"))return e.length;var n=t.length({segmentSubdivisions:this.getConnectionSubdivisions()});return e.length=n,n},getPointAtLength:function(t){var e=this.path;return e?e.pointAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getPointAtRatio:function(t){var e=this.path;return e?(Ys(t)&&(t=parseFloat(t)/100),e.pointAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()})):null},getTangentAtLength:function(t){var e=this.path;return e?e.tangentAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getTangentAtRatio:function(t){var e=this.path;return e?e.tangentAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPoint:function(t){var e=this.path;return e?e.closestPoint(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointLength:function(t){var e=this.path;return e?e.closestPointLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getClosestPointRatio:function(t){var e=this.path;return e?e.closestPointNormalizedLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()}):null},getLabelPosition:function(t,e,n,i){var r,o={},s=0;"number"==typeof n?(s=n,r=i):r=n,r&&(o.args=r);var a,l,c=!(r&&r.absoluteDistance),h=r&&r.absoluteDistance&&r.reverseDistance,u=r&&r.absoluteOffset,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=new Jt(t,e),g=d.closestPointT(p,f),m=d.lengthAtT(g,f);if(c&&(m=m/this.getConnectionLength()||0),h&&(m=-1*(this.getConnectionLength()-m)||1),o.distance=m,u||(a=d.tangentAtT(g)),a)l=a.pointOffset(p);else{var v=d.pointAtT(g),y=p.difference(v);l={x:y.x,y:y.y}}return o.offset=l,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e,n=0,i={};if("number"==typeof t)e=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");i=t.args||{},e=t.distance,n=t.angle||0}var r=e>0&&e<=1,o=0,s={x:0,y:0};if(t.offset){var a=t.offset;"number"==typeof a&&(o=a),a.x&&(s.x=a.x),a.y&&(s.y=a.y)}var l,c=0!==s.x||0!==s.y||0===o,h=i.keepGradient,u=i.ensureLegibility,d=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},p=r?e*this.getConnectionLength():e,g=d.tangentAtLength(p,f),m=n;if(g){if(c)(l=g.start.clone()).offset(s);else{var v=g.clone();v.rotate(g.start,-90),v.setLength(o),l=v.end}h&&(m=g.angle()+n,u&&(m=Ct((m+90)%180-90)))}else l=d.start.clone(),c&&l.offset(s);return An.createSVGMatrix().translate(l.x,l.y).rotate(m)},getLabelCoordinates:function(t){var e=this._getLabelTransformationMatrix(t);return new Jt(e.e,e.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new Jt(t,e)),r=0,o=n.length;r<o;r++){var s=n[r];if(i<this.getClosestPointLength(s))break}return r},notifyPointerdown(t,e,n){Rc.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove(t,e,n){Rc.prototype.pointermove.call(this,t,e,n),this.notify("link:pointermove",t,e,n)},notifyPointerup(t,e,n){this.notify("link:pointerup",t,e,n),Rc.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){Rc.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){Rc.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){Rc.prototype.contextmenu.apply(this,arguments),this.notify("link:contextmenu",t,e,n)},pointerdown:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragStart(t,e,n)},pointermove:function(t,e,n){var i=this._dragData;switch(i&&this.eventData(t,i),this.eventData(t).action){case"label-move":this.dragLabel(t,e,n);break;case"arrowhead-move":this.dragArrowhead(t,e,n);break;case"move":this.drag(t,e,n)}i&&io(i,this.eventData(t)),this.notifyPointermove(t,e,n)},pointerup:function(t,e,n){var i=this._dragData;switch(i&&(this.eventData(t,i),this._dragData=null),this.eventData(t).action){case"label-move":this.dragLabelEnd(t,e,n);break;case"arrowhead-move":this.dragArrowheadEnd(t,e,n);break;case"move":this.dragEnd(t,e,n)}this.notifyPointerup(t,e,n),this.checkMouseleave(t)},mouseover:function(t){Rc.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){Rc.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){Rc.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){Rc.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){Rc.prototype.mousewheel.apply(this,arguments),this.notify("link:mousewheel",t,e,n,i)},onlabel:function(t,e,n){this.notifyPointerdown(t,e,n),this.dragLabelStart(t,e,n),this.eventData(t).stopPropagation&&t.stopPropagation()},dragLabelStart:function(t,e,n){if(this.can("labelMove")){if(this.isDefaultInteractionPrevented(t))return;var i=t.currentTarget,r=parseInt(i.getAttribute("label-idx"),10),o=this._getDefaultLabelPositionProperty(),s=this._normalizeLabelPosition(this._getLabelPositionProperty(r)),a=this._mergeLabelPositionProperty(s,o),l=this.getLabelCoordinates(a),c=l.x-e,h=l.y-n,u=this._getLabelPositionAngle(r),d=this._getLabelPositionArgs(r),f=this._getDefaultLabelPositionArgs(),p=this._mergeLabelPositionArgs(d,f);this.eventData(t,{action:"label-move",labelIdx:r,dx:c,dy:h,positionAngle:u,positionArgs:p,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){if(this.can("arrowheadMove")){var i=t.target.getAttribute("end"),r=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0});this.eventData(t,r)}},dragStart:function(t,e,n){this.isDefaultInteractionPrevented(t)||this.can("linkMove")&&this.eventData(t,{action:"move",dx:e,dy:n})},dragLabel:function(t,e,n){var i=this.eventData(t),r={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)};this.paper.options.snapLabels&&delete r.position.offset;const o={ui:!0};this.paper.isAsync()&&"touchmove"===t.type&&(o.async=!1),this.model.label(i.labelIdx,r,o)},dragArrowhead:function(t,e,n){this.paper.options.snapLinks?!this._snapArrowhead(t,e,n)&&this.paper.options.snapLinksSelf&&this._snapArrowheadSelf(t,e,n):this.paper.options.snapLinksSelf?this._snapArrowheadSelf(t,e,n):this._connectArrowhead(this.getEventTarget(t),e,n,this.eventData(t))},drag:function(t,e,n){var i=this.eventData(t);this.model.translate(e-i.dx,n-i.dy,{ui:!0}),this.eventData(t,{dx:e,dy:n})},dragLabelEnd:function(){},dragArrowheadEnd:function(t,e,n){var i=this.eventData(t),r=this.paper;r.options.snapLinks?this._snapArrowheadEnd(i):this._connectArrowheadEnd(i,e,n),r.linkAllowed(this)?(this._finishEmbedding(i),this._notifyConnectEvent(i,t)):this._disallow(i),this._afterArrowheadMove(i)},dragEnd:function(){},_disallow:function(t){"remove"===t.whenNotAllowed?this.model.remove({ui:!0}):this.model.set(t.arrowhead,t.initialEnd,{ui:!0})},_finishEmbedding:function(t){this.paper.options.embeddingMode&&this.model.reparent()&&(t.z=null)},_notifyConnectEvent:function(t,e){var n=t.arrowhead,i=t.initialEnd,r=this.model.prop(n);if(r&&!$l.endsEqual(i,r)){var o=this.paper;i.id&&this.notify("link:disconnect",e,o.findViewByModel(i.id),t.initialMagnet,n),r.id&&this.notify("link:connect",e,o.findViewByModel(r.id),t.magnetUnderPointer,n)}},_snapToPoints:function(t,e,n){let i=null,r=1/0,o=null,s=1/0,a=t.x,l=t.y;for(let n=0;n<e.length;n++){const a=Math.abs(e[n].x-t.x);a<r&&(r=a,i=e[n]);const l=Math.abs(e[n].y-t.y);l<s&&(s=l,o=e[n])}return r<n&&(a=i.x),s<n&&(l=o.y),{x:a,y:l}},_snapArrowheadSelf:function(t,e,n){const{paper:i,model:r}=this,{snapLinksSelf:o}=i.options,s=this.eventData(t),a=o.radius||20,l=[this.getEndAnchor("source"===s.arrowhead?"target":"source"),...r.vertices()],c=this._snapToPoints({x:e,y:n},l,a),h=i.localToClientPoint(c);this._connectArrowhead(document.elementFromPoint(h.x,h.y),c.x,c.y,this.eventData(t))},_snapArrowhead:function(t,e,n){const{paper:i}=this,{snapLinks:r,connectionStrategy:o}=i.options,s=this.eventData(t);let a=!1;var l=r.radius||50,c=i.findViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l}),h=s.closestView||null,u=s.closestMagnet||null,d=s.magnetProxy||null;s.closestView=s.closestMagnet=s.magnetProxy=null;var f,p=Number.MAX_VALUE,g=new Jt(e,n);c.forEach((function(t){const e=[];"false"!==t.el.getAttribute("magnet")&&e.push({bbox:t.model.getBBox(),magnet:t.el}),t.$("[magnet]").toArray().forEach((n=>{e.push({bbox:t.getNodeBBox(n),magnet:n})})),e.forEach((e=>{const{magnet:n,bbox:r}=e,o=r.center().squaredDistance(g);o<p&&(u===n||i.options.validateConnection.apply(i,s.validateConnectionArgs(t,t.el===n?null:n)))&&(p=o,s.closestView=t,s.closestMagnet=n)}))}),this);var m=null,v=s.closestView,y=s.closestMagnet;y&&(m=s.magnetProxy=v.findProxyNode(y,"highlighter"));var b=s.arrowhead,w=u!==y;if(h&&w&&h.unhighlight(d,{connecting:!0,snapping:!0}),v){const{prevEnd:t,prevX:i,prevY:r}=s;if(s.prevX=e,s.prevY=n,a=!0,!w&&("function"!=typeof o||i===e&&r===n))return a;if(f=v.getLinkEnd(y,e,n,this.model,b),!w&&po(t,f))return a;s.prevEnd=f,w&&v.highlight(m,{connecting:!0,snapping:!0})}else f={x:e,y:n};return this.model.set(b,f||{x:e,y:n},{ui:!0}),h&&this.notify("link:snap:disconnect",t,h,u,b),v&&this.notify("link:snap:connect",t,v,y,b),a},_snapArrowheadEnd:function(t){var e=t.closestView,n=t.closestMagnet;e&&n&&(e.unhighlight(t.magnetProxy,{connecting:!0,snapping:!0}),t.magnetUnderPointer=e.findMagnet(n)),t.closestView=t.closestMagnet=null},_connectArrowhead:function(t,e,n,i){const{paper:r,model:o}=this;if(i.eventTarget!==t){i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0});const e=i.viewUnderPointer=r.findView(t);if(e){const n=i.magnetUnderPointer=e.findMagnet(t),o=i.magnetProxy=e.findProxyNode(n,"highlighter");n&&this.paper.options.validateConnection.apply(r,i.validateConnectionArgs(e,n))?o&&e.highlight(o,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)}else i.magnetUnderPointer=null,i.magnetProxy=null}i.eventTarget=t,o.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(t={},e,n){const{model:i}=this,{viewUnderPointer:r,magnetUnderPointer:o,magnetProxy:s,arrowhead:a}=t;if(!o||!s||!r)return;r.unhighlight(s,{connecting:!0});const l=r.getLinkEnd(o,e,n,i,a);i.set(a,l,{ui:!0})},_beforeArrowheadMove:function(t){t.z=this.model.get("z"),this.model.toFront();var e=this.el.style;t.pointerEvents=e.pointerEvents,e.pointerEvents="none",this.paper.options.markAvailable&&this._markAvailableMagnets(t)},_afterArrowheadMove:function(t){null!==t.z&&(this.model.set("z",t.z,{ui:!0}),t.z=null),this.el.style.pointerEvents=t.pointerEvents,this.paper.options.markAvailable&&this._unmarkAvailableMagnets(t)},_createValidateConnectionArgs:function(t){var e,n=[];n[4]=t,n[5]=this;var i=0,r=0;"source"===t?(i=2,e="target"):(r=2,e="source");var o=this.model.get(e);if(o.id){var s=n[i]=this.paper.findViewByModel(o.id),a=s.getMagnetFromLinkEnd(o);a===s.el&&(a=void 0),n[i+1]=a}return function(t,e){return n[r]=t,n[r+1]=t.el===e?void 0:e,n}},_markAvailableMagnets:function(t){function e(t,e){var n=t.paper;return n.options.validateConnection.apply(n,this.validateConnectionArgs(t,e))}var n=this.paper,i=n.model.getCells();t.marked={};for(var r=0,o=i.length;r<o;r++){var s=i[r].findView(n);if(s){var a=Array.prototype.slice.call(s.el.querySelectorAll("[magnet]"));"false"!==s.el.getAttribute("magnet")&&a.push(s.el);var l=a.filter(e.bind(t,s));if(l.length>0){for(var c=0,h=l.length;c<h;c++)s.highlight(l[c],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e,n,i=Object.keys(t.marked),r=0,o=i.length;r<o;r++){e=i[r],n=t.marked[e];var s=this.paper.findViewByModel(e);if(s){for(var a=0,l=n.length;a<l;a++)s.unhighlight(n[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){e||(e={});var n={action:"arrowhead-move",arrowhead:t,whenNotAllowed:e.whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:ho(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(n),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=n),n},onMount:function(){Rc.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){Rc.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){Rc.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:gu});Object.defineProperty(mu.prototype,"sourceBBox",{enumerable:!0,get:function(){var t=this.sourceView;if(!t){var e=this.model.source();return new me(e.x,e.y)}var n=this.sourceMagnet;return t.isNodeConnection(n)?new me(this.sourceAnchor):t.getNodeBBox(n||t.el)}}),Object.defineProperty(mu.prototype,"targetBBox",{enumerable:!0,get:function(){var t=this.targetView;if(!t){var e=this.model.target();return new me(e.x,e.y)}var n=this.targetMagnet;return t.isNodeConnection(n)?new me(this.targetAnchor):t.getNodeBBox(n||t.el)}});const vu={GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"},yu=Sc.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return Fs(`${this.options.name}-layer`)},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){const{el:e}=this;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(t){const{el:e,pivotNodes:n}=this;(t=+t)||(t=0);let i=n[t];if(i)return i;i=n[t]=document.createComment("z-index:"+(t+1));let r=-1/0;for(let e in n)e=+e,e<t&&e>r&&(r=e);if(r!==-1/0){const t=n[r];e.insertBefore(i,t.nextSibling)}else e.insertBefore(i,e.firstChild);return i},removePivots:function(){const{el:t,pivotNodes:e}=this;for(let n in e)t.removeChild(e[n]);this.pivotNodes={}}}),bu=kc.extend({tagName:"path",className:"highlight-stroke",attributes:{"pointer-events":"none",fill:"none"},options:{padding:3,rx:0,ry:0,useFirstSubpath:!1,attrs:{"stroke-width":3,stroke:"#FEB663"}},getPathData(t,e){const{options:n}=this,{useFirstSubpath:i}=n;let r;try{const t=An(e);if(r=t.convertToPathData().trim(),"PATH"===t.tagName()&&i){const t=r.search(/.M/i)+1;t>0&&(r=r.substr(0,t))}}catch(i){const o=t.getNodeBoundingRect(e);r=An.rectToPath(io({},n,o.toJSON()))}return r},highlightConnection(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode(t,e){const{vel:n,options:i}=this,{padding:r,layer:o}=i;let s=this.getNodeMatrix(t,e);if(r){o||e!==t.el||n.remove();let i=t.getNodeBoundingRect(e);const a=i.x+i.width/2,l=i.y+i.height/2;i=An.transformRect(i,s);const c=Math.max(i.width,1),h=Math.max(i.height,1),u=(c+r)/c,d=(h+r)/h,f=An.createSVGMatrix({a:u,b:0,c:0,d,e:a-u*a,f:l-d*l});s=s.multiply(f)}n.attr({d:this.getPathData(t,e),transform:An.matrixToTransformString(s)})},highlight(t,e){const{vel:n,options:i}=this;n.attr(i.attrs),i.nonScalingStroke&&n.attr("vector-effect","non-scaling-stroke"),t.isNodeConnection(e)?this.highlightConnection(t):this.highlightNode(t,e)}}),wu=20,xu=kc.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:wu,deep:!1,attrs:{stroke:"#FEB663","stroke-width":3,"stroke-linecap":"butt","stroke-linejoin":"miter"}},VISIBLE:"white",INVISIBLE:"black",MASK_ROOT_ATTRIBUTE_BLACKLIST:["marker-start","marker-end","marker-mid","transform","stroke-dasharray","class"],MASK_CHILD_ATTRIBUTE_BLACKLIST:["stroke","fill","stroke-width","stroke-opacity","stroke-dasharray","fill-opacity","marker-start","marker-end","marker-mid","class"],MASK_REPLACE_TAGS:["FOREIGNOBJECT","IMAGE","USE","TEXT","TSPAN","TEXTPATH"],MASK_REMOVE_TAGS:["TEXT","TSPAN","TEXTPATH"],transformMaskChild(t,e){const{MASK_CHILD_ATTRIBUTE_BLACKLIST:n,MASK_REPLACE_TAGS:i,MASK_REMOVE_TAGS:r}=this,o=e.tagName();if(!An.isSVGGraphicsElement(e)||r.includes(o))return e.remove(),!1;if(i.includes(o)){const n=t.vel.findOne(`#${e.id}`);if(n){const{node:i}=n;let r=t.getNodeBoundingRect(i);t.model.isElement()&&(r=An.transformRect(r,t.getNodeMatrix(i)));const o=An("rect",r.toJSON()),{x:s,y:a}=r.center(),{angle:l,cx:c=s,cy:h=a}=n.rotate();l&&o.rotate(l,c,h),e.parent().append(o)}return e.remove(),!1}return n.forEach((t=>{"fill"===t&&"none"===e.attr("fill")||e.removeAttr(t)})),!0},transformMaskRoot(t,e){const{MASK_ROOT_ATTRIBUTE_BLACKLIST:n}=this;n.forEach((t=>{e.removeAttr(t)}))},getMaskShape(t,e){const{options:n,MASK_REPLACE_TAGS:i}=this,{deep:r}=n,o=e.tagName();let s;if("G"===o){if(!r)return null;s=e.clone(),function(t,e){const n=t.children();for(;n.length>0;){const t=n.shift();e(t)&&n.push(...t.children())}}(s,(e=>this.transformMaskChild(t,e)))}else{if(i.includes(o))return null;s=e.clone()}return this.transformMaskRoot(t,s),s},getMaskId(){return`highlight-mask-${this.cid}`},getMask(t,e){const{VISIBLE:n,INVISIBLE:i,options:r}=this,{padding:o,attrs:s}=r,a=parseFloat(An("g").attr(s).attr("stroke-width")),l="none"!==e.attr("fill");let c=parseFloat(e.attr("stroke-width"));isNaN(c)&&(c=1);const h=c+2*o,u=h+2*a;let d=this.getMaskShape(t,e);if(!d){const n=t.getNodeBoundingRect(e.node);n.inflate(n.width?0:.5,n.height?0:.5),d=An("rect",n.toJSON())}return d.attr(s),An("mask",{id:this.getMaskId()}).append([d.clone().attr({fill:l?n:"none",stroke:n,"stroke-width":u}),d.clone().attr({fill:l?i:"none",stroke:i,"stroke-width":h})])},removeMask(t){const e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask(t,e){t.defs.appendChild(e.node)},highlight(t,e){const{options:n,vel:i}=this,{padding:r,attrs:o,maskClip:s=wu,layer:a}=n,l="stroke"in o?o.stroke:"#000000";a||e!==t.el||i.remove();const c=t.getNodeBoundingRect(e).inflate(r+s),h=this.getNodeMatrix(t,e),u=this.getMask(t,An(e));this.addMask(t.paper,u),i.attr(c.toJSON()),i.attr({transform:An.matrixToTransformString(h),mask:`url(#${u.id})`,fill:l})},unhighlight(t){this.removeMask(t.paper)}}),Au=kc.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){const{alphaValue:n=.3}=this.options;e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),Tu=Fs("highlighted"),Eu=kc.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:Tu},highlight:function(t,e){An(e).addClass(this.options.className)},unhighlight:function(t,e){An(e).removeClass(this.options.className)}},{className:Tu}),Pu={ROW:"row",COLUMN:"column"},Su=kc.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight(t,e){const n=t.model,{attribute:i,size:r=20,gap:o=5,direction:s=Pu.ROW}=this.options;if(!i)throw new Error("List: attribute is required");const a="number"==typeof r?{width:r,height:r}:r,l=s===Pu.ROW,c=l?a.width:a.height;let h=n.get(i);Array.isArray(h)||(h=[]);const u=this._prevItems||[],d=h.map(((t,e)=>po(u[e],h[e])));if(u.length!==h.length||d.some((t=>!t))){const t=this.vel.children(),e=h.map(((e,n)=>{const r=n in t?t[n].node:null;if(d[n])return r;const s=this.createListItem(e,a,r);if(!s)return null;if(!(s instanceof SVGElement))throw new Error("List: item must be an SVGElement");s.dataset.index=n,s.dataset.attribute=i;const h=n*(c+o);return s.setAttribute("transform",l?`translate(${h}, 0)`:`translate(0, ${h})`),s}));this.vel.empty().append(e),this._prevItems=h}const f=h.length,p=0===f?0:f*c+(f-1)*o,g=l?{width:p,height:a.height}:{width:a.width,height:p};this.position(n,g)},position(t,e){const{vel:n,options:i}=this,{margin:r=5,position:o="top-left"}=i,{width:s,height:a}=t.size(),{left:l,right:c,top:h,bottom:u}=Qs(r),d=new me(l,h,s-(l+c),a-(h+u));let{x:f,y:p}=lc(d,o);switch(o){case ac.CENTER:case ac.TOP:case ac.BOTTOM:f-=e.width/2;break;case ac.RIGHT:case ac.BOTTOM_RIGHT:case ac.TOP_RIGHT:f-=e.width}switch(o){case ac.CENTER:case ac.RIGHT:case ac.LEFT:p-=e.height/2;break;case ac.BOTTOM:case ac.BOTTOM_RIGHT:case ac.BOTTOM_LEFT:p-=e.height}n.attr("transform",`translate(${f}, ${p})`)}},{Directions:Pu,Positions:ac});function _u(t,e,n,i){var r="ratio"in i?i.ratio:.5;return t.getPointAtRatio(r)}function ku(t,e,n,i){var r="length"in i?i.length:20;return t.getPointAtLength(r)}function Lu(t){return function(e,n,i,r){if(i instanceof Element){var o,s=this.paper.findView(i);return o=s?s.isNodeConnection(i)?Cu(s,"fixedAt"in r?r.fixedAt:"50%"):s.getNodeBBox(i).center():new Jt,t.call(this,e,n,o,r)}return t.apply(this,arguments)}}function Cu(t,e){var n=parseFloat(e);return Ys(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}const Mu=Lu((function(t,e,n,i){var r=1e6,o=t.getConnection(),s=t.getConnectionSubdivisions(),a=new ne(n.clone().offset(0,r),n.clone().offset(0,-r)),l=new ne(n.clone().offset(r,0),n.clone().offset(-r,0)),c=a.intersect(o,{segmentSubdivisions:s}),h=l.intersect(o,{segmentSubdivisions:s}),u=[];return c&&Array.prototype.push.apply(u,c),h&&Array.prototype.push.apply(u,h),u.length>0?n.chooseClosest(u):"fallbackAt"in i?Cu(t,i.fallbackAt):Ou(t,e,n,i)})),Ou=Lu((function(t,e,n,i){return t.getClosestPoint(n)||new Jt}));function Nu(t,e,n){if(mo(n)){const{x:i,y:r}=n;if(isFinite(r)){const n=new ne(e,t),{start:i,end:o}=n.parallel(r);e=i,t=o}n=i}if(!isFinite(n))return t;var i=t.distance(e);return 0===n&&i>0?t:t.move(e,-Math.min(n,i-1))}function Ru(t){var e=t.getAttribute("stroke-width");return null===e?0:parseFloat(e)||0}function Fu(t,e,n,i){var r=e.getNodeBBox(n);i.stroke&&r.inflate(Ru(n)/2);var o=t.intersect(r);return Nu(o?t.start.chooseClosest(o):t.end,t.start,i.offset)}var Bu="segmentSubdivisons",Iu="shapeBBox";const Du=function(t,e,n,i){let{offset:r,alignOffset:o,align:s}=i;return s&&function(t,e,n=0){let i,r,o,s;const{start:a,end:l}=t;switch(e){case"left":i="x",r=l,o=a,s=-1;break;case"right":i="x",r=a,o=l,s=1;break;case"top":i="y",r=l,o=a,s=-1;break;case"bottom":i="y",r=a,o=l,s=1;break;default:return}a[i]<l[i]?r[i]=o[i]:o[i]=r[i],isFinite(n)&&(r[i]+=s*n,o[i]+=s*n)}(t,s,o),Nu(t.end,t.start,r)},Vu=Fu,zu=function(t,e,n,i){var r=e.model.angle();if(0===r)return Fu(t,e,n,i);var o=e.getNodeUnrotatedBBox(n);i.stroke&&o.inflate(Ru(n)/2);var s=o.center(),a=t.clone().rotate(s,r),l=a.setLength(1e6).intersect(o);return Nu(l?a.start.chooseClosest(l).rotate(s,-r):t.end,t.start,i.offset)},ju=function(t,e,n,i){var r,o,s=i.selector,a=t.end;if(r="string"==typeof s?e.findNode(s):!1===s?n:Array.isArray(s)?Ds(n,s):function(t){if(!t)return null;var e=t;do{var n=e.tagName;if("string"!=typeof n)return null;if("G"===(n=n.toUpperCase()))e=e.firstElementChild;else{if("TITLE"!==n)break;e=e.nextElementSibling}}while(e);return e}(n),!An.isSVGGraphicsElement(r)){if(r===n||!An.isSVGGraphicsElement(n))return a;r=n}var l,c=e.getNodeShape(r),h=e.getNodeMatrix(r),u=e.getRootTranslateMatrix(),d=e.getRootRotateMatrix(),f=u.multiply(d).multiply(h),p=f.inverse(),g=An.transformLine(t,p),m=g.start.clone(),v=e.getNodeData(r);if(!1===i.insideout&&(v[Iu]||(v[Iu]=c.bbox()),v[Iu].containsPoint(m)))return a;if(c instanceof Le){var y=i.precision||2;v[Bu]||(v[Bu]=c.getSegmentSubdivisions({precision:y})),l={precision:y,segmentSubdivisions:v[Bu]}}!0===i.extrapolate&&g.setLength(1e6),(o=g.intersect(c,l))?An.isArray(o)&&(o=m.chooseClosest(o)):!0===i.sticky&&(o=c instanceof me?c.pointNearestToPoint(m):c instanceof ae?c.intersectionWithLineFromCenterToPoint(m):c.closestPoint(m,l));var b=o?An.transformPoint(o,f):a,w=i.offset||0;return i.stroke&&(w+=Ru(r)/2),Nu(b,t.start,w)};function $u(t){return function(e,n,i,r){var o=!!r.rotate,s=o?e.getNodeUnrotatedBBox(n):e.getNodeBBox(n),a=s[t](),l=r.dx;if(l){var c=Ys(l);l=parseFloat(l),isFinite(l)&&(c&&(l/=100,l*=s.width),a.x+=l)}var h=r.dy;if(h){var u=Ys(h);h=parseFloat(h),isFinite(h)&&(u&&(h/=100,h*=s.height),a.y+=h)}return o?a.rotate(e.model.getBBox().center(),-e.model.angle()):a}}const Uu=$u("center"),Gu=$u("topMiddle"),qu=$u("bottomMiddle"),Hu=$u("leftMiddle"),Wu=$u("rightMiddle"),Yu=$u("origin"),Xu=$u("topRight"),Zu=$u("bottomLeft"),Ku=$u("corner"),Ju=Lu((function(t,e,n,i){var r=t.model.angle(),o=t.getNodeBBox(e),s=o.center(),a=o.origin(),l=o.corner(),c=i.padding;if(isFinite(c)||(c=0),a.y+c<=n.y&&n.y<=l.y-c){var h=n.y-s.y;s.x+=0===r||180===r?0:1*h/Math.tan(Nt(r)),s.y+=h}else if(a.x+c<=n.x&&n.x<=l.x-c){var u=n.x-s.x;s.y+=90===r||270===r?0:u*Math.tan(Nt(r)),s.x+=u}return s})),Qu=Lu((function(t,e,n,i){var r,o,s,a=!!i.rotate;a?(r=t.getNodeUnrotatedBBox(e),s=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e);var l,c=i.padding;switch(isFinite(c)&&r.inflate(c),a&&n.rotate(s,o),r.sideNearestToPoint(n)){case"left":l=r.leftMiddle();break;case"right":l=r.rightMiddle();break;case"top":l=r.topMiddle();break;case"bottom":l=r.bottomMiddle()}return a?l.rotate(s,-o):l})),td=function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)},ed=yu.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init(){yu.prototype.init.apply(this,arguments);const{options:{paper:t}}=this;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings(t){const e=[];return t&&(Array.isArray(t)?t:[t||{}]).forEach((t=>{e.push(...this._resolveDrawGridOption(t))})),e},removeGrid(){const{_gridCache:t}=this;t&&(t.root.remove(),this._gridCache=null)},renderGrid(){const{options:{paper:t}}=this,{_gridSettings:e}=this;if(this.removeGrid(),0===e.length)return;const n=t.options.drawGridSize||t.options.gridSize;if(n<=1)return;const i=this._getGridRefs();e.forEach(((e,r)=>{const o=this._getPatternId(r),s=Mo({},e),{scaleFactor:a=1}=s;let l;s.width=n*a||1,s.height=n*a||1,i.exist(o)?l=i.get(o):(l=An("pattern",{id:o,patternUnits:"userSpaceOnUse"},An(s.markup)),i.add(o,l)),go(s.render)&&s.render(l.node.firstChild,s,t),l.attr({width:s.width,height:s.height})})),i.root.appendTo(this.el),this.updateGrid()},updateGrid(){const{_gridCache:t,_gridSettings:e,options:{paper:n}}=this;if(!t)return;const{root:i,patterns:r}=t,{x:o,y:s,width:a,height:l}=n.getArea();i.attr({x:o,y:s,width:a,height:l});for(const t in r)r[t].attr({x:-o,y:-s});e.forEach(((t,e)=>{if(go(t.update)){const i=r[this._getPatternId(e)];t.update(i.node.firstChild,t,n)}}))},_getPatternId(t){return`pattern_${this.options.paper.cid}_${t}`},_getGridRefs(){let{_gridCache:t}=this;if(t)return t;const e=An("defs"),n=An("svg",{width:"100%",height:"100%"},[e]);return t=this._gridCache={root:n,patterns:{},add:function(t,i){const r=An("rect",{width:"100%",height:"100%",fill:`url(#${t})`});e.append(i),n.append(r),this.patterns[t]=i},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}},t},_resolveDrawGridOption(t){var e=this.options.patterns;if(no(t)&&Array.isArray(e[t]))return e[t].map((function(t){return io({},t)}));var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if(i||r||n.markup||(r="dot"),r&&Array.isArray(e[r])){var o=e[r].map((function(t){return io({},t)})),s=Array.isArray(n.args)?n.args:[n.args||{}];ro(s[0],Po(t,"args"));for(var a=0;a<s.length;a++)o[a]&&io(o[a],s[a]);return o}return i?n:[n]}}),nd={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"},id=1/0,rd=9007199254740991,od=Rc.Highlighting,sd={[od.DEFAULT]:{name:"stroke",options:{padding:3}},[od.MAGNET_AVAILABILITY]:{name:"addClass",options:{className:"available-magnet"}},[od.ELEMENT_AVAILABILITY]:{name:"addClass",options:{className:"available-cell"}}},ad=[{name:vu.GRID},{name:vu.BACK},{name:vu.CELLS},{name:vu.LABELS},{name:vu.FRONT},{name:vu.TOOLS}],ld=Sc.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:Vc,linkView:mu,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:sd,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){const{cellNamespace:t}=this.model.get("cells"),e=Ds(t,["standard","Link"]);if(!e)throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.");return new e},defaultConnector:{name:"normal"},defaultRouter:{name:"normal"},defaultAnchor:{name:"center"},defaultLinkAnchor:{name:"connectionRatio"},defaultConnectionPoint:{name:"boundary"},connectionStrategy:null,validateMagnet:function(t,e,n){return"passive"!==e.getAttribute("magnet")},validateConnection:function(t,e,n,i,r,o){return("target"===r?n:t)instanceof Vc},embeddingMode:!1,validateEmbedding:function(t,e){return!0},validateUnembedding:function(t){return!0},findParentBy:"bbox",frontParentOnly:!0,interactive:{labelMove:!1},linkPinning:!0,allowLink:null,clickThreshold:0,moveThreshold:0,magnetThreshold:0,sorting:nd.APPROX,frozen:!1,autoFreeze:!1,onViewUpdate:function(t,e,n,i,r){e&(t.FLAG_INSERT|t.FLAG_REMOVE)||i.mounting||i.isolate||r.requestConnectedLinksUpdate(t,n,i)},onViewPostponed:function(t,e,n){return n.forcePostponedViewUpdate(t,e)},beforeRender:null,afterRender:null,viewport:null,cellViewNamespace:null,routerNamespace:null,connectorNamespace:null,highlighterNamespace:d,anchorNamespace:g,linkAnchorNamespace:f,connectionPointNamespace:p,overflow:!1},events:{dblclick:"pointerdblclick",dbltap:"pointerdblclick",contextmenu:"contextmenu",mousedown:"pointerdown",touchstart:"pointerdown",mouseover:"mouseover",mouseout:"mouseout",mouseenter:"mouseenter",mouseleave:"mouseleave",wheel:"mousewheel","mouseenter .joint-cell":"mouseenter","mouseleave .joint-cell":"mouseleave","mouseenter .joint-tools":"mouseenter","mouseleave .joint-tools":"mouseleave","dblclick .joint-cell [magnet]":"magnetpointerdblclick","contextmenu .joint-cell [magnet]":"magnetcontextmenu","mousedown .joint-link .label":"onlabel","touchstart .joint-link .label":"onlabel","dragstart .joint-cell image":"onImageDragStart"},documentEvents:{mousemove:"pointermove",touchmove:"pointermove",mouseup:"pointerup",touchend:"pointerup",touchcancel:"pointerup"},stylesheet:"\n .joint-element .scalable * {\n vector-effect: non-scaling-stroke;\n }\n ",svg:null,viewport:null,defs:null,tools:null,layers:null,_viewportMatrix:null,_viewportTransformString:null,_updates:null,_layers:null,SORT_DELAYING_BATCHES:["add","to-front","to-back"],UPDATE_DELAYING_BATCHES:["translate"],FORM_CONTROL_TAG_NAMES:["TEXTAREA","INPUT","BUTTON","SELECT","OPTION"],GUARDED_TAG_NAMES:["SELECT"],MIN_SCALE:1e-6,init:function(){const{options:t}=this;t.cellViewNamespace||(t.cellViewNamespace="undefined"!=typeof joint&&To(joint,"shapes")?joint.shapes:null);const e=this.model=t.model||new xc;this._layers={},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(e.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates&&this._updates.id&&qs(this._updates.id),this._updates={id:null,priorities:[{},{},{}],unmountedCids:[],mountedCids:[],unmounted:{},mounted:{},count:0,keyFrozen:!1,freezeKey:null,sort:!1,disabled:!1,idle:!1}},startListening:function(){var t=this.model;this.listenTo(t,"add",this.onCellAdded).listenTo(t,"remove",this.onCellRemoved).listenTo(t,"change",this.onCellChange).listenTo(t,"reset",this.onGraphReset).listenTo(t,"sort",this.onGraphSort).listenTo(t,"batch:stop",this.onGraphBatchStop),this.on("cell:highlight",this.onCellHighlight).on("cell:unhighlight",this.onCellUnhighlight).on("transform",this.update)},onCellAdded:function(t,e,n){var i=n.position;this.isAsync()||!eo(i)?this.renderView(t,n):(n.maxPosition===i&&this.freeze({key:"addCells"}),this.renderView(t,n),0===i&&this.unfreeze({key:"addCells"}))},onCellRemoved:function(t,e,n){const i=this.findViewByModel(t);i&&this.requestViewUpdate(i,i.FLAG_REMOVE,i.UPDATE_PRIORITY,n)},onCellChange:function(t,e){if(t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===nd.APPROX){const n=this.findViewByModel(t);n&&this.requestViewUpdate(n,n.FLAG_INSERT,n.UPDATE_PRIORITY,e)}},onGraphReset:function(t,e){this.resetLayers(),this.resetViews(t.models,e)},onGraphSort:function(){this.model.hasActiveBatch(this.SORT_DELAYING_BATCHES)||this.sortViews()},onGraphBatchStop:function(t){if(!this.isFrozen()){var e=t&&t.batchName,n=this.model;if(!this.isAsync()){var i=this.UPDATE_DELAYING_BATCHES;i.includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t)}var r=this.SORT_DELAYING_BATCHES;r.includes(e)&&!n.hasActiveBatch(r)&&this.sortViews()}},cloneOptions:function(){const{options:t}=this,{defaultConnector:e,defaultRouter:n,defaultConnectionPoint:i,defaultAnchor:r,defaultLinkAnchor:o,highlighting:s,cellViewNamespace:a,interactive:l}=t;!a&&"undefined"!=typeof joint&&To(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),go(e)||(t.defaultConnector=uo(e)),go(n)||(t.defaultRouter=uo(n)),go(i)||(t.defaultConnectionPoint=uo(i)),go(r)||(t.defaultAnchor=uo(r)),go(o)||(t.defaultLinkAnchor=uo(o)),mo(l)&&(t.interactive=io({},l)),mo(s)&&(t.highlighting=oo({},s,sd))},children:function(){var t=An.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:Fs("paper-background"),selector:"background",style:{position:"absolute",inset:0}},{namespaceURI:t.svg,tagName:"svg",attributes:{width:"100%",height:"100%","xmlns:xlink":t.xlink},selector:"svg",style:{position:"absolute",inset:0},children:[{tagName:"defs",selector:"defs"},{tagName:"g",className:Fs("layers"),selector:"layers"}]}]},hasLayerView(t){return t in this._layers},getLayerView(t){const{_layers:e}=this;if(t in e)return e[t];throw new Error(`dia.Paper: Unknown layer "${t}"`)},getLayerNode(t){return this.getLayerView(t).el},render:function(){this.renderChildren();const{el:t,childNodes:e,options:n,stylesheet:i}=this,{svg:r,defs:o,layers:s}=e;return t.style.position="relative",r.style.overflow=n.overflow?"visible":"hidden",this.svg=r,this.defs=o,this.layers=s,this.renderLayers(),An.ensureId(r),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&An(this.svg).prepend(An.createSVGStyle(t))},createLayer(t){return t===vu.GRID?new ed({name:t,paper:this,patterns:this.constructor.gridPatterns}):new yu({name:t})},renderLayers:function(t=ad){this.removeLayers(),t.forEach((({name:t,sorted:e})=>{const n=this.createLayer(t);this.layers.appendChild(n.el),this._layers[t]=n}));const e=this.getLayerView(vu.CELLS),n=this.getLayerView(vu.TOOLS),i=this.getLayerView(vu.LABELS);this.tools=n.el,this.cells=this.viewport=e.el,e.vel.addClass(Fs("viewport")),i.vel.addClass(Fs("viewport")),e.el.style.webkitUserSelect="none",e.el.style.userSelect="none",i.el.style.webkitUserSelect="none",i.el.style.userSelect="none"},removeLayers:function(){const{_layers:t}=this;Object.keys(t).forEach((e=>{t[e].remove(),delete t[e]}))},resetLayers:function(){const{_layers:t}=this;Object.keys(t).forEach((e=>{t[e].removePivots()}))},update:function(){return this._background&&this.updateBackgroundImage(this._background),this},scale:function(t,e,n){const i=this.matrix();return void 0===t?An.matrixToScale(i):(void 0===e&&(e=t),t=Math.max(t||0,this.MIN_SCALE),e=Math.max(e||0,this.MIN_SCALE),i.a=t,i.d=e,this.matrix(i,n),this)},scaleUniformAtPoint:function(t,e,n){const{a:i,d:r,e:o,f:s}=this.matrix();if((t=Math.max(t||0,this.MIN_SCALE))===i&&t===r)return this;const a=An.createSVGMatrix().translate(o-e.x*(t-i),s-e.y*(t-r)).scale(t,t);return this.matrix(a,n),this},translate:function(t,e,n){const i=this.matrix();return void 0===t?An.matrixToTranslate(i):(t||(t=0),e||(e=0),i.e===t&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t,e={}){var n=this.layers;if(void 0===t){var i=n.getAttribute("transform");return(this._viewportTransformString||null)===i?t=this._viewportMatrix:(t=n.getCTM(),this._viewportMatrix=t,this._viewportTransformString=i),An.createSVGMatrix(t)}const r=this.matrix(),o=An.createSVGMatrix(t),s=this._viewportTransformString,a=An.matrixToTransformString(o);if(a===s)return this;if(!s&&An.matrixToTransformString()===a)return this;const{a:l,d:c,e:h,f:u}=o;return n.setAttribute("transform",a),this._viewportMatrix=o,this._viewportTransformString=n.getAttribute("transform"),l===r.a&&c===r.d||this.trigger("scale",l,c,e),h===r.e&&u===r.f||this.trigger("translate",h,u,e),this.trigger("transform",o,e),this},clientMatrix:function(){return An.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof Rc)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,s=r.length;o<s;o++){var a=r[o],l=this.findViewByModel(a);if(l){var c=["UPDATE"];a.getTargetCell()===i&&c.push("TARGET"),a.getSourceCell()===i&&c.push("SOURCE");var h=Math.max(e+1,l.UPDATE_PRIORITY);this.scheduleViewUpdate(l,l.getFlag(c),h,n)}}},forcePostponedViewUpdate:function(t,e){if(!(t&&t instanceof Rc))return!1;var n=t.model;if(n.isElement())return!1;if(!(e&t.getFlag(["SOURCE","TARGET"]))){var i={silent:!0},r=0,o=this.findViewByModel(n.getSourceCell());o&&!this.isViewMounted(o)&&(r=this.dumpView(o,i),t.updateEndMagnet("source"));var s=0,a=this.findViewByModel(n.getTargetCell());if(a&&!this.isViewMounted(a)&&(s=this.dumpView(a,i),t.updateEndMagnet("target")),0===r&&0===s)return!this.dumpView(t,i)}return!1},requestViewUpdate:function(t,e,n,i){i||(i={}),this.scheduleViewUpdate(t,e,n,i);var r=this.isAsync();if(!(this.isFrozen()||r&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES))){var o=this.updateViews(i);r&&this.notifyAfterRender(o,i)}},scheduleViewUpdate:function(t,e,n,i){const{_updates:r,options:o}=this;r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze());const{FLAG_REMOVE:s,FLAG_INSERT:a,UPDATE_PRIORITY:l,cid:c}=t;let h=r.priorities[n];if(h||(h=r.priorities[n]={}),n>l)for(let t=n-1;t>=l;t--){const e=r.priorities[t];e&&c in e&&(h[c]|=e[c],delete e[c])}let u=h[c]||0;if((u&e)===e)return;u||r.count++,e&s&&u&a?h[c]^=a:e&a&&u&s&&(h[c]^=s),h[c]|=e;const d=o.onViewUpdate;"function"==typeof d&&d.call(this,t,e,n,i||{},this)},dumpViewUpdate:function(t){if(!t)return 0;var e=this._updates,n=t.cid,i=e.priorities[t.UPDATE_PRIORITY],r=this.registerMountedView(t)|i[n];return delete i[n],r},dumpView:function(t,e={}){const n=this.dumpViewUpdate(t);if(!n)return 0;const i=!e.silent;i&&this.notifyBeforeRender(e);const r=this.updateView(t,n,e);if(i){const n={updated:1,priority:t.UPDATE_PRIORITY};this.notifyAfterRender(n,e)}return r},updateView:function(t,e,n){if(!t)return 0;const{FLAG_REMOVE:i,FLAG_INSERT:r,FLAG_INIT:o,model:s}=t;if(t instanceof Rc){if(e&i)return this.removeView(s),0;if(e&r){const n=!!(e&o);n&&(e^=o),this.insertView(t,n),e^=r}}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){var n=this.findViewByModel(t);return n?(this.dumpView(n,e),n):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;if(e in n.unmounted)return 0;var i=n.unmounted[e]|=t.FLAG_INSERT;return n.unmountedCids.push(e),delete n.mounted[e],i},registerMountedView:function(t){var e=t.cid,n=this._updates;if(e in n.mounted)return 0;n.mounted[e]=!0,n.mountedCids.push(e);var i=n.unmounted[e]||0;return delete n.unmounted[e],i},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){var e=ro({},t,{viewport:null});this.checkViewport(e),this.updateViews(e)},updateViews:function(t){let e;this.notifyBeforeRender(t);let n=0,i=0,r=rd;do{i++,e=this.updateViewsBatch(t),n+=e.updated,r=Math.min(e.priority,r)}while(!e.empty);const o={updated:n,batches:i,priority:r};return this.notifyAfterRender(o,t),o},hasScheduledUpdates:function(){const t=this._updates.priorities,e=Object.keys(t);let n=e.length;for(;n>0&&n--;)for(let i in t[e[n]])return!0;return!1},updateViewsAsync:function(t,e){t||(t={}),e||(e={processed:0,priority:rd});const{_updates:n,options:i}=this,r=n.id;if(r){qs(r),0===e.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(t);const o=this.updateViewsBatch(t),s=ro({},t,{mountBatchSize:1e3-o.mounted,unmountBatchSize:1e3-o.unmounted}),a=this.checkViewport(s),l=a.unmounted,c=a.mounted;let h=e.processed;const u=n.count;o.updated>0?(h+=o.updated+o.unmounted,o.processed=h,e.priority=Math.min(o.priority,e.priority),o.empty&&0===c?(o.unmounted+=l,o.mounted+=c,o.priority=e.priority,this.notifyAfterRender(o,t),e.processed=0,e.priority=rd,n.count=0):e.processed=h):n.idle||i.autoFreeze&&(this.freeze(),n.idle=!0,this.trigger("render:idle",t));const d=t.progress;if(u&&"function"==typeof d&&d.call(this,o.empty,h,u,o,this),n.id!==r)return}if(n.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");n.id=Gs(this.updateViewsAsync,this,t,e)},notifyBeforeRender:function(t={}){let e=t.beforeRender;"function"!=typeof e&&(e=this.options.beforeRender,"function"!=typeof e)||e.call(this,t,this)},notifyAfterRender:function(t,e={}){let n=e.afterRender;"function"!=typeof n&&(n=this.options.afterRender),"function"==typeof n&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){t||(t={});var e=t.batchSize||id,n=this._updates,i=0,r=0,o=0,s=0,a=rd,l=!0,c=this.options,h=n.priorities,u="viewport"in t?t.viewport:c.viewport;"function"!=typeof u&&(u=null);var d=c.onViewPostponed;"function"!=typeof d&&(d=null);var f=Object.keys(h);t:for(var p=0,g=f.length;p<g;p++){var m=+f[p],v=h[m];for(var y in v){if(i>=e){l=!1;break t}var b=Pc[y];if(b){var w=v[y];if(!(w&b.FLAG_REMOVE)){var x=y in n.unmounted;if(b.DETACHABLE&&u&&!u.call(this,b,!x,this)){x||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[y]|=w,delete v[y],o++;continue}x&&(w|=b.FLAG_INSERT,s++),w|=this.registerMountedView(b)}var A=this.updateView(b,w,t);A>0&&(v[y]=A,!d||!d.call(this,b,A,this)||v[y])?(r++,l=!1):(a>m&&(a=m),i++,delete v[y])}else delete v[y]}}return{priority:a,updated:i,postponed:r,unmounted:o,mounted:s,empty:l}},getUnmountedViews:function(){const t=this._updates,e=Object.keys(t.unmounted),n=e.length,i=new Array(n);for(var r=0;r<n;r++)i[r]=Pc[e[r]];return i},getMountedViews:function(){const t=this._updates,e=Object.keys(t.mounted),n=e.length,i=new Array(n);for(var r=0;r<n;r++)i[r]=Pc[e[r]];return i},checkUnmountedViews:function(t,e){e||(e={});var n=0;"function"!=typeof t&&(t=null);for(var i=("mountBatchSize"in e?e.mountBatchSize:1/0),r=this._updates,o=r.unmountedCids,s=r.unmounted,a=0,l=Math.min(o.length,i);a<l;a++){var c=o[a];if(c in s){var h=Pc[c];if(h)if(h.DETACHABLE&&t&&!t.call(this,h,!1,this))o.push(c);else{n++;var u=this.registerMountedView(h);u&&this.scheduleViewUpdate(h,u,h.UPDATE_PRIORITY,{mounting:!0})}}}return o.splice(0,a),n},checkMountedViews:function(t,e){e||(e={});var n=0;if("function"!=typeof t)return n;for(var i=("unmountBatchSize"in e?e.unmountBatchSize:1/0),r=this._updates,o=r.mountedCids,s=r.mounted,a=0,l=Math.min(o.length,i);a<l;a++){var c=o[a];if(c in s){var h=Pc[c];h&&(h.DETACHABLE&&!t.call(this,h,!0,this)?(n++,this.registerUnmountedView(h)&&this.detachView(h)):o.push(c))}}return o.splice(0,a),n},checkViewVisibility:function(t,e={}){let n="viewport"in e?e.viewport:this.options.viewport;"function"!=typeof n&&(n=null);const i=this._updates,{mounted:r,unmounted:o}=i,s=!t.DETACHABLE||!n||n.call(this,t,!1,this);let a=!1,l=!1;if(t.cid in r&&!s){this.registerUnmountedView(t)&&this.detachView(t);const e=i.mountedCids.indexOf(t.cid);i.mountedCids.splice(e,1),a=!0}if(!a&&t.cid in o&&s){const e=i.unmountedCids.indexOf(t.cid);i.unmountedCids.splice(e,1);var c=this.registerMountedView(t);c&&this.scheduleViewUpdate(t,c,t.UPDATE_PRIORITY,{mounting:!0}),l=!0}return{mounted:l?1:0,unmounted:a?1:0}},checkViewport:function(t){var e=ro({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n="viewport"in e?e.viewport:this.options.viewport,i=this.checkMountedViews(n,e);if(i>0){var r=this._updates.unmountedCids;e.mountBatchSize=Math.min(r.length-i,e.mountBatchSize)}return{mounted:this.checkUnmountedViews(n,e),unmounted:i}},freeze:function(t){t||(t={});var e=this._updates,n=t.key,i=this.options.frozen,r=e.freezeKey;if(n&&n!==r){if(i&&r)return;e.freezeKey=n,e.keyFrozen=i}this.options.frozen=!0;var o=e.id;e.id=null,this.isAsync()&&o&&qs(o)},unfreeze:function(t){t||(t={});var e=this._updates,n=t.key,i=e.freezeKey;n&&i&&n!==i||(e.freezeKey=null,n&&n===i&&e.keyFrozen||(this.isAsync()?(this.freeze(),this.updateViewsAsync(t)):this.updateViews(t),this.options.frozen=e.keyFrozen=!1,e.sort&&(this.sortViews(),e.sort=!1)))},isAsync:function(){return!!this.options.async},isFrozen:function(){return!!this.options.frozen},isExactSorting:function(){return this.options.sorting===nd.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,n=t.height;return eo(e)||(e=this.el.clientWidth),eo(n)||(n=this.el.clientHeight),{width:e,height:n}},setDimensions:function(t,e,n={}){const{options:i}=this,{width:r,height:o}=i;let s=void 0===t?r:t,a=void 0===e?o:e;if(r===s&&o===a)return;i.width=s,i.height=a,this._setDimensions();const l=this.getComputedSize();this.trigger("resize",l.width,l.height,n)},_setDimensions:function(){const{options:t}=this;let e=t.width,n=t.height;eo(e)&&(e=`${Math.round(e)}px`),eo(n)&&(n=`${Math.round(n)}px`),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=to(t)?t:io({gridWidth:t,gridHeight:e,padding:n},i);const{x:r,y:o,width:s,height:a}=this.getFitToContentArea(i),{sx:l,sy:c}=this.scale();return this.translate(-r*l,-o*c,i),this.setDimensions(s*l,a*c,i),new me(r,o,s,a)},getFitToContentArea:function(t={}){const e=t.gridWidth||1,n=t.gridHeight||1,i=Qs(t.padding||0),r=Math.max(t.minWidth||0,e),o=Math.max(t.minHeight||0,n),s=t.maxWidth||Number.MAX_VALUE,a=t.maxHeight||Number.MAX_VALUE,l=t.allowNewOrigin,c="contentArea"in t?new me(t.contentArea):this.getContentArea(t),{sx:h,sy:u}=this.scale();c.x*=h,c.y*=u,c.width*=h,c.height*=u;let d=Math.ceil((c.width+c.x)/e),f=Math.ceil((c.height+c.y)/n);t.allowNegativeBottomRight||(d=Math.max(d,1),f=Math.max(f,1)),d*=e,f*=n;let p=0;("negative"===l&&c.x<0||"positive"===l&&c.x>=0||"any"===l)&&(p=Math.ceil(-c.x/e)*e,p+=i.left,d+=p);let g=0;return("negative"===l&&c.y<0||"positive"===l&&c.y>=0||"any"===l)&&(g=Math.ceil(-c.y/n)*n,g+=i.top,f+=g),d+=i.right,f+=i.bottom,d=Math.max(d,r),f=Math.max(f,o),d=Math.min(d,s),f=Math.min(f,a),new me(-p/h,-g/u,d/h,f/u)},transformToFitContent:function(t){let e,n;if(t||(t={}),"contentArea"in t){const i=t.contentArea;e=this.localToPaperRect(i),n=new Jt(i)}else e=this.getContentBBox(t),n=this.paperToLocalPoint(e);if(!e.width||!e.height)return;ro(t,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});const i=Qs(t.padding),r=t.minScaleX||t.minScale,o=t.maxScaleX||t.maxScale,s=t.minScaleY||t.minScale,a=t.maxScaleY||t.maxScale;let l;if(t.fittingBBox)l=t.fittingBBox;else{const t=this.translate(),e=this.getComputedSize();l={x:t.tx,y:t.ty,width:e.width,height:e.height}}l=new me(l).moveAndExpand({x:i.left,y:i.top,width:-i.left-i.right,height:-i.top-i.bottom});const c=this.matrix(),{a:h,d:u,e:d,f}=c;let p=l.width/e.width*h,g=l.height/e.height*u;if(t.preserveAspectRatio&&(p=g=Math.min(p,g)),t.scaleGrid){const e=t.scaleGrid;p=e*Math.floor(p/e),g=e*Math.floor(g/e)}p=Math.min(o,Math.max(r,p)),g=Math.min(a,Math.max(s,g));const m=p/h,v=g/u;let y=l.x-n.x*p-d,b=l.y-n.y*g-f;switch(t.verticalAlign){case"middle":b+=(l.height-e.height*v)/2;break;case"bottom":b+=l.height-e.height*v}switch(t.horizontalAlign){case"middle":y+=(l.width-e.width*m)/2;break;case"right":y+=l.width-e.width*m}c.a=p,c.d=g,c.e=y,c.f=b,this.matrix(c,t)},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new me:An(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(...t){const{restrictTranslate:e}=this.options;let n;return n=go(e)?e.apply(this,t):!0===e?this.getArea():e?new me(e):null,n},createViewForModel:function(t){const{options:e}=this;var n,i,r=e.cellViewNamespace,o=t.get("type")+"View",s=Ds(r,o,".");return t.isLink()?(n=e.linkView,i=mu):(n=e.elementView,i=Vc),new(n.prototype instanceof Ac?s||n:n.call(this,t)||s||i)({model:t,interactive:e.interactive,labelsLayer:!0===e.labelsLayer?vu.LABELS:e.labelsLayer})},removeView:function(t){const{id:e}=t,{_views:n,_updates:i}=this,r=n[e];if(r){var{cid:o}=r;const{mounted:t,unmounted:s}=i;r.remove(),delete n[e],delete t[o],delete s[o]}return r},renderView:function(t,e){const{id:n}=t,i=this._views;let r,o,s=!0;return n in i&&(r=i[n],r.model===t?(o=r.FLAG_INSERT,s=!1):this.removeView(t)),s&&(r=i[n]=this.createViewForModel(t),r.paper=this,o=this.registerUnmountedView(r)|this.FLAG_INIT|r.getFlag(Eo(r,"initFlag"))),this.requestViewUpdate(r,o,r.UPDATE_PRIORITY,e),r},onImageDragStart:function(){return!1},resetViews:function(t,e){e||(e={}),t||(t=[]),this._resetUpdates(),this.removeViews();const n=this.options.autoFreeze?null:"reset";this.freeze({key:n});for(var i=0,r=t.length;i<r;i++)this.renderView(t[i],e);this.unfreeze({key:n}),this.sortViews()},removeViews:function(){so(this._views,"remove"),this._views={}},sortViews:function(){this.isExactSorting()&&(this.isFrozen()?this._updates.sort=!0:this.sortViewsExact())},sortViewsExact:function(){var t=Array.from(this.cells.childNodes).filter((t=>t.getAttribute("model-id"))),e=this.model.get("cells");!function(t,n){var i=(t=Rs(t).toArray()).map((function(t){var e=t.parentNode,n=e.insertBefore(document.createTextNode(""),t.nextSibling);return function(){if(e===this)throw new Error("You can't sort elements if any one is a descendant of another.");e.insertBefore(this,n),e.removeChild(n)}}));t.sort((function(t,n){var i=e.get(t.getAttribute("model-id")),r=e.get(n.getAttribute("model-id")),o=i.attributes.z||0,s=r.attributes.z||0;return o===s?0:o<s?-1:1}));for(var r=0;r<i.length;r++)i[r].call(t[r])}(t)},insertView:function(t,e){const n=this.getLayerView(vu.CELLS),{el:i,model:r}=t;this.options.sorting===nd.APPROX?n.insertSortedNode(i,r.get("z")):n.insertNode(i),t.onMount(e)},detachView(t){t.unmount(),t.onDetach()},findView:function(t){var e=no(t)?this.cells.querySelector(t):t instanceof Rs?t[0]:t,n=this.findAttribute("model-id",e);if(n)return this._views[n]},findViewByModel:function(t){var e=no(t)||eo(t)?t:t&&t.id;return this._views[e]},findViewsFromPoint:function(t){return t=new Jt(t),this.model.getElements().map(this.findViewByModel,this).filter((function(e){return e&&e.vel.getBBox({target:this.cells}).containsPoint(t)}),this)},findViewsInArea:function(t,e){e=ro(e||{},{strict:!1}),t=new me(t);var n=this.model.getElements().map(this.findViewByModel,this),i=e.strict?"containsRect":"intersect";return n.filter((function(e){return e&&t[i](e.vel.getBBox({target:this.cells}))}),this)},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t,...e){"string"==typeof t&&this.trigger("tools:event",t,...e)},getModelById:function(t){return this.model.getCell(t)},snapToGrid:function(t,e){return this.clientToLocalPoint(t,e).snapToGrid(this.options.gridSize)},localToPaperPoint:function(t,e){var n=new Jt(t,e);return An.transformPoint(n,this.matrix())},localToPaperRect:function(t,e,n,i){var r=new me(t,e,n,i);return An.transformRect(r,this.matrix())},paperToLocalPoint:function(t,e){var n=new Jt(t,e);return An.transformPoint(n,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){var r=new me(t,e,n,i);return An.transformRect(r,this.matrix().inverse())},localToClientPoint:function(t,e){var n=new Jt(t,e);return An.transformPoint(n,this.clientMatrix())},localToClientRect:function(t,e,n,i){var r=new me(t,e,n,i);return An.transformRect(r,this.clientMatrix())},clientToLocalPoint:function(t,e){var n=new Jt(t,e);return An.transformPoint(n,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){var r=new me(t,e,n,i);return An.transformRect(r,this.clientMatrix().inverse())},localToPagePoint:function(t,e){return this.localToPaperPoint(t,e).offset(this.pageOffset())},localToPageRect:function(t,e,n,i){return this.localToPaperRect(t,e,n,i).offset(this.pageOffset())},pageToLocalPoint:function(t,e){var n=new Jt(t,e).difference(this.pageOffset());return this.paperToLocalPoint(n)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),o=new me(t,e,n,i);return o.x-=r.x,o.y-=r.y,this.paperToLocalRect(o)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new Jt(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){if(!(t instanceof mu))throw new Error("Must provide a linkView.");var e=t.model,n=this.options,i=this.model,r=i.constructor.validations;return!(!n.multiLinks&&!r.multiLinks.call(this,i,e)||!n.linkPinning&&!r.linkPinning.call(this,i,e)||"function"==typeof n.allowLink&&!n.allowLink.call(this,t,this))},getDefaultLink:function(t,e){return go(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(t={}){let{highlighter:e,type:n}=t;const{highlighting:i,highlighterNamespace:r}=this.options;if(void 0===e){if(!i)return!1;if(n&&(e=i[n],!1===e))return!1;e||(e=i.default)}if(!e)return!1;no(e)&&(e={name:e});const o=e.name,s=r[o];if(!s)throw new Error('Unknown highlighter ("'+o+'")');if("function"!=typeof s.highlight)throw new Error('Highlighter ("'+o+'") is missing required highlight() method');if("function"!=typeof s.unhighlight)throw new Error('Highlighter ("'+o+'") is missing required unhighlight() method');return{highlighter:s,options:e.options||{},name:o}},onCellHighlight:function(t,e,n){const i=this.resolveHighlighter(n);if(!i)return;const{highlighter:r,options:o}=i;r.highlight(t,e,o)},onCellUnhighlight:function(t,e,n){const i=this.resolveHighlighter(n);if(!i)return;const{highlighter:r,options:o}=i;r.unhighlight(t,e,o)},pointerdblclick:function(t){t.preventDefault(),t=Us(t);var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerdblclick(t,n.x,n.y):this.trigger("blank:pointerdblclick",t,n.x,n.y)}},pointerclick:function(t){if(this.eventData(t).mousemoved<=this.options.clickThreshold){t=Us(t);var e=this.findView(t.target);if(this.guard(t,e))return;var n=this.snapToGrid(t.clientX,t.clientY);e?e.pointerclick(t,n.x,n.y):this.trigger("blank:pointerclick",t,n.x,n.y)}},contextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.contextMenuFired?this.contextMenuFired=!1:(t=Us(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e=this.findView(t.target);if(!this.guard(t,e)){var n=this.snapToGrid(t.clientX,t.clientY);e?e.contextmenu(t,n.x,n.y):this.trigger("blank:contextmenu",t,n.x,n.y)}},pointerdown:function(t){t=Us(t);const{target:e,button:n}=t,i=this.findView(e),r=2===n;if(i){if(!r&&this.guard(t,i))return;const n=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName);this.options.preventDefaultViewAction&&!n&&t.preventDefault(),n&&i.preventDefaultInteraction(t);const o=this.customEventTrigger(t,i);if(o){if(o.isPropagationStopped())return;t.data=o.data}const s=e.closest("[magnet]");if(s&&i.el!==s&&i.el.contains(s)){const e=Us(new Rs.Event(t.originalEvent,{data:t.data,currentTarget:s}));if(this.onmagnet(e),e.isDefaultPrevented()&&t.preventDefault(),e.isPropagationStopped()){if(r)return;return void this.delegateDragEvents(i,e.data)}t.data=e.data}}if(r){this.contextMenuFired=!0;const e=new Rs.Event(t.originalEvent,{type:"contextmenu",data:t.data});this.contextMenuTrigger(e)}else{const e=this.snapToGrid(t.clientX,t.clientY);i?i.pointerdown(t,e.x,e.y):(this.options.preventDefaultBlankAction&&t.preventDefault(),this.trigger("blank:pointerdown",t,e.x,e.y)),this.delegateDragEvents(i,t.data)}},pointermove:function(t){var e=this.eventData(t);if(e.mousemoved||(e.mousemoved=0,this.undelegateEvents()),!(++e.mousemoved<=this.options.moveThreshold)){t=Us(t);var n=this.snapToGrid(t.clientX,t.clientY),i=e.sourceView;i?i.pointermove(t,n.x,n.y):this.trigger("blank:pointermove",t,n.x,n.y),this.eventData(t,e)}},pointerup:function(t){this.undelegateDocumentEvents();var e=Us(t),n=this.snapToGrid(e.clientX,e.clientY),i=this.eventData(t).sourceView;i?i.pointerup(e,n.x,n.y):this.trigger("blank:pointerup",e,n.x,n.y),e.isPropagationStopped()||this.pointerclick(new Rs.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=Us(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseover(t);else{if(this.el===t.target)return;this.trigger("blank:mouseover",t)}},mouseout:function(t){t=Us(t);var e=this.findView(t.target);if(!this.guard(t,e))if(e)e.mouseout(t);else{if(this.el===t.target)return;this.trigger("blank:mouseout",t)}},mouseenter:function(t){t=Us(t);const{target:e,relatedTarget:n,currentTarget:i}=t,r=this.findView(e);if(this.guard(t,r))return;const o=this.findView(n);if(r){if(o===r)return;if(r.mouseenter(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseenter",t)},mouseleave:function(t){t=Us(t);const{target:e,relatedTarget:n,currentTarget:i}=t,r=this.findView(e);if(this.guard(t,r))return;const o=this.findView(n);if(r){if(o===r)return;if(r.mouseleave(t),this.el.contains(n))return}o||i===this.el&&this.trigger("paper:mouseleave",t)},_processMouseWheelEvtBuf:function(t,e,n){if("function"!=typeof t)throw new TypeError("Expected a function");let i,r,o,s,a,l,c=0,h=!1,u=!1,d=!0;const f=!e&&0!==e&&window&&"function"==typeof window.requestAnimationFrame;function p(e){const n=i,o=r;return i=r=void 0,c=e,s=t.apply(o,n),s}function g(t,e){return f?(window.cancelAnimationFrame(a),window.requestAnimationFrame(t)):setTimeout(t,e)}function m(t){const n=t-l;return void 0===l||n>=e||n<0||u&&t-c>=o}function v(){const t=Date.now();if(m(t))return y(t);a=g(v,function(t){const n=t-c,i=e-(t-l);return u?Math.min(i,o-n):i}(t))}function y(t){return a=void 0,d&&i?p(t):(i=r=void 0,s)}function b(...t){const n=Date.now(),o=m(n);if(i=t,r=this,l=n,o){if(void 0===a)return function(t){return c=t,a=g(v,e),h?p(t):s}(l);if(u)return a=g(v,e),p(l)}return void 0===a&&(a=g(v,e)),s}return e=+e||0,to(n)&&(h=!!n.leading,u="maxWait"in n,o=u?Math.max(+n.maxWait||0,e):o,d="trailing"in n?!!n.trailing:d),b.cancel=()=>{void 0!==a&&function(t){if(f)return window.cancelAnimationFrame(t);clearTimeout(t)}(a),c=0,i=l=r=a=void 0},b.flush=()=>void 0===a?s:y(Date.now()),b.pending=()=>void 0!==a,b}((function(){const{event:t,deltas:e}=this._mw_evt_buffer,n=e.reduce(((t,e)=>{return t+((n=e)>50?50:n<-50?-50:n);var n}),0),i=Math.pow(.995,n),{x:r,y:o}=this.clientToLocalPoint(t.clientX,t.clientY);this.trigger("paper:pinch",t,r,o,i),this._mw_evt_buffer={event:null,deltas:[]}}),20,{maxWait:20}),mousewheel:function(t){t=Us(t);const e=this.findView(t.target);if(this.guard(t,e))return;const n=t.originalEvent,i=this.snapToGrid(n.clientX,n.clientY),{deltaX:r,deltaY:o}=function(t){let e=0,n=0,i=0,r=0;return"detail"in t&&(n=t.detail),"wheelDelta"in t&&(n=-t.wheelDelta/120),"wheelDeltaY"in t&&(n=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=n,n=0),i="deltaX"in t?t.deltaX:10*e,r="deltaY"in t?t.deltaY:10*n,(i||r)&&t.deltaMode&&(1==t.deltaMode?(i*=40,r*=40):(i*=800,r*=800)),0===t.deltaX&&0!==t.deltaY&&t.shiftKey&&(i=r,r=0,e=n,n=0),i&&!e&&(e=i<1?-1:1),r&&!n&&(n=r<1?-1:1),{spinX:e,spinY:n,deltaX:i,deltaY:r}}(n),s=this._events["paper:pinch"];if(t.ctrlKey&&s&&s.length>0)n.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(o),this._processMouseWheelEvtBuf();else{const s=Math.max(-1,Math.min(1,n.wheelDelta));e?e.mousewheel(t,i.x,i.y,s):this.trigger("blank:mousewheel",t,i.x,i.y,s),this.trigger("paper:pan",t,r,o)}},onevent:function(t){var e=t.currentTarget,n=e.getAttribute("event");if(n){var i=this.findView(e);if(i){if(t=Us(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);i.onevent(t,n,r.x,r.y)}}},magnetEvent:function(t,e){var n=t.currentTarget;if(n.getAttribute("magnet")){var i=this.findView(n);if(i){if(t=Us(t),this.guard(t,i))return;var r=this.snapToGrid(t.clientX,t.clientY);e.call(this,i,t,n,r.x,r.y)}}},onmagnet:function(t){if(2===t.button){this.contextMenuFired=!0,this.magnetContextMenuFired=!0;const e=new Rs.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget});this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()}else this.magnetEvent(t,(function(t,e,n,i,r){t.onmagnet(e,i,r)}))},magnetpointerdblclick:function(t){this.magnetEvent(t,(function(t,e,n,i,r){t.magnetpointerdblclick(e,n,i,r)}))},magnetcontextmenu:function(t){this.options.preventContextMenu&&t.preventDefault(),this.magnetContextMenuFired?this.magnetContextMenuFired=!1:this.magnetContextMenuTrigger(t)},magnetContextMenuTrigger:function(t){this.magnetEvent(t,(function(t,e,n,i,r){t.magnetcontextmenu(e,n,i,r)}))},onlabel:function(t){var e=t.currentTarget,n=this.findView(e);if(!n)return;if(t=Us(t),this.guard(t,n))return;const i=this.customEventTrigger(t,n,e);if(i){if(i.isPropagationStopped())return;t.data=i.data}var r=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,r.x,r.y)},getPointerArgs(t){const e=Us(t),{x:n,y:i}=this.snapToGrid(e.clientX,e.clientY);return[e,n,i]},delegateDragEvents:function(t,e){e||(e={}),this.eventData({data:e},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){if("mousedown"===t.type&&2===t.button)return!0;if(this.options.guard&&this.options.guard(t,e))return!0;if(t.data&&void 0!==t.data.guarded)return t.data.guarded;const{target:n}=t;return!!this.GUARDED_TAG_NAMES.includes(n.tagName)||!(e&&e.model&&e.model instanceof al)&&this.el!==n&&!this.svg.contains(n)},setGridSize:function(t){const{options:e}=this;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(vu.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(vu.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",n=t.size||"auto auto",i=this.scale(),r=this.translate();to(e)&&(e=r.tx+i.sx*(e.x||0)+"px "+(r.ty+i.sy*(e.y||0))+"px"),to(n)&&(n=(n=new me(n).scale(i.sx,i.sy)).width+"px "+n.height+"px");const{background:o}=this.childNodes;o.style.backgroundSize=n,o.style.backgroundPosition=e},drawBackgroundImage:function(t,e){if(t instanceof HTMLImageElement){if(this._background&&this._background.id===e.id){var n,i=(e=e||{}).size,r=e.repeat||"no-repeat",o=e.opacity||1,s=Math.abs(e.quality)||1,a=this.constructor.backgroundPatterns[ko(r)];if(go(a)){t.width*=s,t.height*=s;var l=a(t,e);if(!(l instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=l.toDataURL("image/png"),r="repeat",to(i)?(i.width*=l.width/t.width,i.height*=l.height/t.height):void 0===i&&(e.size={width:l.width/s,height:l.height/s})}else n=t.src,void 0===i&&(e.size={width:t.width,height:t.height});this.childNodes.background.style.opacity=o,this.childNodes.background.style.backgroundRepeat=r,this.childNodes.background.style.backgroundImage=`url(${n})`,this.updateBackgroundImage(e)}}else this.childNodes.background.style.backgroundImage=""},updateBackgroundColor:function(t){this.$el.css("backgroundColor",t||"")},drawBackground:function(t){if(t=t||{},this.updateBackgroundColor(t.color),t.image){t=this._background=uo(t),$s(t);var e=document.createElement("img");e.onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image}else this.drawBackgroundImage(null),this._background=null;return this},setInteractivity:function(t){this.options.interactive=t,so(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!to(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name;if(e||(e=n+this.svg.id+Is(JSON.stringify(t))),!this.isDefined(e)){var i=na,r=i[n]&&i[n](t.args||{});if(!r)throw new Error("Non-existing filter "+n);var o=io({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});An(r,o).appendTo(this.defs)}return e},defineGradient:function(t){if(!to(t))throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.");const{svg:e,defs:n}=this,{type:i,id:r=i+e.id+Is(JSON.stringify(t)),stops:o,attrs:s={}}=t;if(this.isDefined(r))return r;const a=vo(o).map((({offset:t,color:e,opacity:n})=>An("stop").attr({offset:t,"stop-color":e,"stop-opacity":Number.isFinite(n)?n:1}))),l=An(i,s,a);return l.id=r,l.appendTo(n),r},definePattern:function(t){if(!to(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");const{svg:e,defs:n}=this,{id:i=e.id+Is(JSON.stringify(t)),markup:r,attrs:o={}}=t;if(!r)throw new TypeError("dia.Paper: definePattern() requires markup.");if(this.isDefined(i))return i;const s=An("pattern",{patternUnits:"userSpaceOnUse"});if(s.id=i,s.attr(o),"string"==typeof r)s.append(An(r));else{const{fragment:t}=Bs(r);s.append(t)}return s.appendTo(n),i},defineMarker:function(t){if(!to(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");const{svg:e,defs:n}=this,{id:i=e.id+Is(JSON.stringify(t)),markup:r,attrs:o={},markerUnits:s="userSpaceOnUse"}=t;if(this.isDefined(i))return i;const a=An("marker",{orient:"auto",overflow:"visible",markerUnits:s});let l;if(a.id=i,a.attr(o),r){let t;if("string"==typeof r)t=An(r),t=Array.isArray(t)?t:[t];else{const{fragment:e}=Bs(r);t=An(e).children()}l=t.length>1?An("g").append(t):t[0]}else{const{type:e="path"}=t;l=An(e)}const c=Po(t,"type","id","markup","attrs","markerUnits");return Object.keys(c).forEach((t=>{const e=c[t],n=l.attr(t);null==n?l.attr(t,e):"transform"===t&&l.attr(t,e+" "+n)})),l.appendTo(a),a.appendTo(n),i},customEventTrigger:function(t,e,n=e.el){const i=t.target.closest("[event]");if(i&&n!==i&&e.el.contains(i)){const e=Us(new Rs.Event(t.originalEvent,{data:t.data,currentTarget:i}));return this.onevent(e),e.isDefaultPrevented()&&t.preventDefault(),e}return null}},{sorting:nd,Layers:vu,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,-1,e.width,e.height),r.drawImage(t,0,0,n,i),r.setTransform(-1,0,0,1,e.width,0),r.drawImage(t,0,0,n,i),r.setTransform(1,0,0,-1,0,e.height),r.drawImage(t,0,0,n,i),e},flipX:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=2*n,e.height=i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(2*n,0),r.scale(-1,1),r.drawImage(t,0,0,n,i),e},flipY:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height;e.width=n,e.height=2*i;var r=e.getContext("2d");return r.drawImage(t,0,0,n,i),r.translate(0,2*i),r.scale(1,-1),r.drawImage(t,0,0,n,i),e},watermark:function(t,e){e=e||{};var n=t.width,i=t.height,r=document.createElement("canvas");r.width=3*n,r.height=3*i;for(var o=r.getContext("2d"),s=eo(e.watermarkAngle)?-e.watermarkAngle:-20,a=Nt(s),l=r.width/4,c=r.height/4,h=0;h<4;h++)for(var u=0;u<4;u++)(h+u)%2>0&&(o.setTransform(1,0,0,1,(2*h-1)*l,(2*u-1)*c),o.rotate(a),o.drawImage(t,-n/2,-i/2,n,i));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){An(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){An(t).attr({fill:e.color})},update:function(t,e,n){const{sx:i,sy:r}=n.scale(),o=i<=1?e.thickness:e.thickness/i,s=r<=1?e.thickness:e.thickness/r;An(t).attr({width:o,height:s})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",An(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",An(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n,i=e.width,r=e.height,o=e.thickness;n=i-o>=0&&r-o>=0?["M",i,0,"H0 M0 0 V0",r].join(" "):"M 0 0 0 0",An(t).attr({d:n,stroke:e.color,"stroke-width":e.thickness})}}]}}),cd=Sc.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,init:function(){var t=this.name;t&&this.vel.attr("data-tool-name",t)},configure:function(t,e){return this.relatedView=t,this.paper=t.paper,this.parentView=e,this.simulateRelatedView(this.el),this.delegateEvents(),this},simulateRelatedView:function(t){t&&t.setAttribute("model-id",this.relatedView.model.id)},getName:function(){return this.name},show:function(){this.el.style.display="",this._visible=!0},hide:function(){this.el.style.display="none",this._visible=!1},isVisible:function(){return!!this._visible},focus:function(){var t=this.options.focusOpacity;isFinite(t)&&(this.el.style.opacity=t),this.parentView.focusTool(this)},blur:function(){this.el.style.opacity="",this.parentView.blurTool(this)},update:function(){},guard:function(t){const{paper:e,relatedView:n}=this;return!e||!n||e.guard(t,n)}}),hd=Sc.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=io(this.options,t)).tools;if(!Array.isArray(e))return this;var n=t.relatedView;if(!(n instanceof Rc))return this;for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var s=e[r];s instanceof cd&&(s.configure(n,this),this.vel.append(s.el),i.push(s))}return this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS")),this},getName:function(){return this.options.name},update:function(t){t||(t={});var e=this.tools;if(!e)return this;for(var n=this.isRendered,i=0,r=e.length;i<r;i++){var o=e[i];n?t.tool!==o.cid&&o.isVisible()&&o.update():o.render()}return this.isMounted()||this.mount(),n||(this.blurTool(),this.isRendered=!0),this},focusTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];t===r?r.show():r.hide()}return this},blurTool:function(t){var e=this.tools;if(!e)return this;for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isVisible()||(r.show(),r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null)},onRemove:function(){var t=this.tools;if(!t)return this;for(var e=0,n=t.length;e<n;e++)t[e].remove();this.tools=null},mount:function(){const{options:t,el:e}=this,{relatedView:n,layer:i=vu.TOOLS,z:r}=t;return n&&(i?n.paper.getLayerView(i).insertSortedNode(e,r):n.el.appendChild(e)),this}}),ud=cd.extend({name:"button",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},options:{distance:0,offset:0,scale:null,rotate:!1},onRender:function(){this.renderChildren(this.options.markup),this.update()},update:function(){return this.position(),this},position:function(){const{vel:t}=this;t.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix(){const{relatedView:t,options:e}=this;let{x:n=0,y:i=0,offset:r={},useModelGeometry:o,rotate:s,scale:a}=e,l=function(t,e){const{model:n}=t;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}(t,o);const c=t.model.angle();s||(l=l.bbox(c));const{x:h=0,y:u=0}=r;Ys(n)?n=parseFloat(n)/100*l.width:Ba(n)&&(n=Number(Va(n,l))),Ys(i)?i=parseFloat(i)/100*l.height:Ba(i)&&(i=Number(Va(i,l)));let d=An.createSVGMatrix().translate(l.x+l.width/2,l.y+l.height/2);return s&&(d=d.rotate(c)),d=d.translate(n+h-l.width/2,i+u-l.height/2),a&&(d=d.scale(a)),d},getLinkMatrix(){const{relatedView:t,options:e}=this,{offset:n=0,distance:i=0,rotate:r,scale:o}=e;let s,a,l;s=Ys(i)?t.getTangentAtRatio(parseFloat(i)/100):t.getTangentAtLength(i),s?(a=s.start,l=s.vector().vectorAngle(new Jt(1,0))||0):(a=t.getConnection().start,l=0);let c=An.createSVGMatrix().translate(a.x,a.y).rotate(l).translate(0,n);return r||(c=c.rotate(-l)),o&&(c=c.scale(o)),c},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.options.action;"function"==typeof e&&e.call(this.relatedView,t,this.relatedView,this)}}}),dd=ud.extend({name:"remove",children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#FF1D00",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -3 -3 3 3 M -3 3 3 -3",fill:"none",stroke:"#FFFFFF","stroke-width":2,"pointer-events":"none"}}],options:{distance:60,offset:0,action:function(t,e,n){e.model.remove({ui:!0,tool:n.cid})}}}),fd=cd.extend({tagName:"path",xAxisVector:new Jt(1,0),events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{scale:null},onRender:function(){this.update()},update:function(){var t,e,n=this.ratio,i=this.relatedView,r=i.getTangentAtRatio(n);if(r?(t=r.start,e=r.vector().vectorAngle(this.xAxisVector)||0):(t=i.getPointAtRatio(n),e=0),!t)return this;var o=An.createSVGMatrix().translate(t.x,t.y).rotate(e);const{scale:s}=this.options;return s&&(o=o.scale(s)),this.vel.transform(o,{absolute:!0}),this},onPointerDown:function(t){if(!this.guard(t)){t.stopPropagation(),t.preventDefault();var e=this.relatedView,n=e.paper;e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),this.delegateDocumentEvents(),n.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none",e.notifyPointerdown(...n.getPointerArgs(t))}},onPointerMove:function(t){var e=Us(t),n=this.paper.snapToGrid(e.clientX,e.clientY);this.relatedView.pointermove(e,n.x,n.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,i=Us(t),r=n.snapToGrid(i.clientX,i.clientY);e.pointerup(i,r.x,r.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),pd=fd.extend({name:"target-arrowhead",ratio:1,arrowheadType:"target",attributes:{d:"M -10 -8 10 0 -10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"target-arrowhead"}}),gd=fd.extend({name:"source-arrowhead",ratio:0,arrowheadType:"source",attributes:{d:"M 10 -8 -10 0 10 8 Z",fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move",class:"source-arrowhead"}});var md=function(t,e,n,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s},vd=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)};let yd=class extends xt{static{this.styles=x`
|
|
3
3
|
.available-magnet {
|
|
4
4
|
fill: green;
|
|
5
5
|
}
|
|
6
6
|
.available-cell rect {
|
|
7
7
|
stroke-dasharray: 5, 2;
|
|
8
|
-
}`}createRenderRoot(){return this.renderInHost?this:super.createRenderRoot()}constructor(){super(),this.renderInHost=!0,this.paper=null,this.namespace=c,this.height="600px",this.width="100%",this.portRadius=3,this.router="manhattan",this.templateHeight=30,this.templateWidth=80,this.templateSpacing=20,this.gridSize=10,this.gridColor="lightgrey",this.draggedElement=null,this.shapeFactory={Rectangle:t=>new Gl(t),Polygon:t=>(t.transform={rotate:45},new Gl(t)),Ellipse:t=>new Hl(t),Circle:t=>new ql(t)},this.graph=this.createGraph()}firstUpdated(t){super.firstUpdated(t),this.paper=this.createPaper(this.renderRoot.querySelector("div")),document.addEventListener("keydown",(t=>{t.altKey&&"+"===t.key&&(t.preventDefault(),this.paper.scale(this.paper.scale().sx+.1,this.paper.scale().sy+.1))})),document.addEventListener("keydown",(t=>{t.altKey&&"-"===t.key&&(t.preventDefault(),this.paper.scale(this.paper.scale().sx-.1,this.paper.scale().sy-.1))})),document.addEventListener("keydown",(t=>{t.altKey&&"0"===t.key&&(t.preventDefault(),this.paper.scale())}));const e={label:"New",position:0,height:this.templateHeight,width:this.templateWidth,spacing:this.templateSpacing,color:"white",bgcolor:"blue",element:"Rectangle"};[{label:"Task",bgcolor:"#ADD8E6",color:"black"},{label:"Document",bgcolor:"#90EE90",color:"black"},{label:"Message",bgcolor:"#F08080",color:"black"},{label:"Score",bgcolor:"#E6E6FA",color:"black"},{label:"Ledger",bgcolor:"#FFA07A",color:"black"},{label:"Workflow",bgcolor:"#F5FFFA",color:"black"},{label:"Process",bgcolor:"#FFEBCD",color:"black"},{label:"If/Then",bgcolor:"#F0F8FF",element:"Ellipse",color:"black"},{label:"Poll",bgcolor:"#FFDAB9",element:"Ellipse",color:"black"},{label:"Advanced",bgcolor:"#F0FFF0",color:"black"}].forEach(((t,n)=>{const i=(n+1)*this.templateSpacing+n*this.templateHeight,r=Object.assign(e,{position:i},t);this.createTemplate(r)}))}createGraph(){return new xc({},{cellNamespace:this.namespace})}createPaper(t){const e=this,n=new ld({el:t,model:this.graph,width:e.width,height:e.height,gridSize:e.gridSize,drawGrid:!0,cellViewNamespace:this.namespace,background:{color:e.gridColor},defaultLink:()=>new rc({router:{name:e.router,args:{step:5}}}),interactive:{linkMove:!0},linkPinning:!1,markAvailable:!0,snapLinks:{radius:20},validateConnection:function(t,e,n,i,r,o){return t!==n&&null!==i}});return n.on("link:mouseenter",(t=>{this.showLinkTools(t)})),n.on("link:mouseleave",(t=>{t.removeTools()})),n.on("element:mouseenter",(t=>t.showTools())),n.on("element:mouseleave",(t=>t.hideTools())),n.on("selection:change",(function(t,n){e.graph.getCells().forEach((function(t){t.attr("body/stroke","none")})),t.forEach((function(t){t.attr("body/stroke","red"),t.attr("body/stroke-width",2)}))})),n}createStep(t){const e=this;t.on("element:pointerdown",(function(n){e.draggedElement=t.model.clone(),t.model.attr("body/fill","gray"),e.graph.addCell(e.draggedElement)})),t.on("element:pointerup",(function(){t.model.attr("body/fill",e.draggedElement.attr("body/fill"));var n=t.model.position(),i=e.draggedElement.position();t.model.position(i.x,i.y),e.draggedElement.position(n.x,n.y),e.draggedElement.addPorts([{group:"left"},{group:"top"},{group:"right"},{group:"bottom"}]),e.draggedElement.findView(e.paper).addTools(new hd({tools:[new dd]}))}))}createTemplate(t){const e=this.paper.el.clientWidth-t.spacing-t.width,n=this.shapeFactory[t.element??"Rectangle"]({position:{x:e,y:t.position},size:{width:t.width,height:t.height},attrs:{body:{fill:t.bgcolor??"blue"},label:{text:t.label,fill:t.color??"white"}},ports:{groups:{left:this.createPort("left"),top:this.createPort("top"),right:this.createPort("right"),bottom:this.createPort("bottom")}}});return this.graph.addCell(n),this.createStep(this.paper.findViewByModel(n)),n}createPort(t,e=this.portRadius,n="circle",i="orange",r="blue"){return{position:{name:t},attrs:{portBody:{magnet:!0,r:e,fill:i,stroke:r}},markup:[{tagName:n,selector:"portBody"}]}}showLinkTools(t){var e=new hd({tools:[new gd,new pd,new dd]});t.addTools(e)}render(){return rt`<slot><div></div></slot>`}};var bd;md([
|
|
8
|
+
}`}createRenderRoot(){return this.renderInHost?this:super.createRenderRoot()}constructor(){super(),this.renderInHost=!0,this.paper=null,this.namespace=c,this.height="600px",this.width="100%",this.portRadius=3,this.router="manhattan",this.templateHeight=30,this.templateWidth=80,this.templateSpacing=20,this.gridSize=10,this.gridColor="lightgrey",this.draggedElement=null,this.shapeFactory={Rectangle:t=>new Gl(t),Polygon:t=>(t.transform={rotate:45},new Gl(t)),Ellipse:t=>new Hl(t),Circle:t=>new ql(t)},this.graph=this.createGraph()}firstUpdated(t){super.firstUpdated(t),this.paper=this.createPaper(this.renderRoot.querySelector("div")),document.addEventListener("keydown",(t=>{t.altKey&&"+"===t.key&&(t.preventDefault(),this.paper.scale(this.paper.scale().sx+.1,this.paper.scale().sy+.1))})),document.addEventListener("keydown",(t=>{t.altKey&&"-"===t.key&&(t.preventDefault(),this.paper.scale(this.paper.scale().sx-.1,this.paper.scale().sy-.1))})),document.addEventListener("keydown",(t=>{t.altKey&&"0"===t.key&&(t.preventDefault(),this.paper.scale())}));const e={label:"New",position:0,height:this.templateHeight,width:this.templateWidth,spacing:this.templateSpacing,color:"white",bgcolor:"blue",element:"Rectangle"};[{label:"Task",bgcolor:"#ADD8E6",color:"black"},{label:"Document",bgcolor:"#90EE90",color:"black"},{label:"Message",bgcolor:"#F08080",color:"black"},{label:"Score",bgcolor:"#E6E6FA",color:"black"},{label:"Ledger",bgcolor:"#FFA07A",color:"black"},{label:"Workflow",bgcolor:"#F5FFFA",color:"black"},{label:"Process",bgcolor:"#FFEBCD",color:"black"},{label:"If/Then",bgcolor:"#F0F8FF",element:"Ellipse",color:"black"},{label:"Poll",bgcolor:"#FFDAB9",element:"Ellipse",color:"black"},{label:"Advanced",bgcolor:"#F0FFF0",color:"black"}].forEach(((t,n)=>{const i=(n+1)*this.templateSpacing+n*this.templateHeight,r=Object.assign(e,{position:i},t);this.createTemplate(r)}))}createGraph(){return new xc({},{cellNamespace:this.namespace})}createPaper(t){const e=this,n=new ld({el:t,model:this.graph,width:e.width,height:e.height,gridSize:e.gridSize,drawGrid:!0,cellViewNamespace:this.namespace,background:{color:e.gridColor},defaultLink:()=>new rc({router:{name:e.router,args:{step:5}}}),interactive:{linkMove:!0},linkPinning:!1,markAvailable:!0,snapLinks:{radius:20},validateConnection:function(t,e,n,i,r,o){return t!==n&&null!==i}});return n.on("link:mouseenter",(t=>{this.showLinkTools(t)})),n.on("link:mouseleave",(t=>{t.removeTools()})),n.on("element:mouseenter",(t=>t.showTools())),n.on("element:mouseleave",(t=>t.hideTools())),n.on("selection:change",(function(t,n){e.graph.getCells().forEach((function(t){t.attr("body/stroke","none")})),t.forEach((function(t){t.attr("body/stroke","red"),t.attr("body/stroke-width",2)}))})),n}createStep(t){const e=this;t.on("element:pointerdown",(function(n){e.draggedElement=t.model.clone(),t.model.attr("body/fill","gray"),e.graph.addCell(e.draggedElement)})),t.on("element:pointerup",(function(){t.model.attr("body/fill",e.draggedElement.attr("body/fill"));var n=t.model.position(),i=e.draggedElement.position();t.model.position(i.x,i.y),e.draggedElement.position(n.x,n.y),e.draggedElement.addPorts([{group:"left"},{group:"top"},{group:"right"},{group:"bottom"}]),e.draggedElement.findView(e.paper).addTools(new hd({tools:[new dd]}))}))}createTemplate(t){const e=this.paper.el.clientWidth-t.spacing-t.width,n=this.shapeFactory[t.element??"Rectangle"]({position:{x:e,y:t.position},size:{width:t.width,height:t.height},attrs:{body:{fill:t.bgcolor??"blue"},label:{text:t.label,fill:t.color??"white"}},ports:{groups:{left:this.createPort("left"),top:this.createPort("top"),right:this.createPort("right"),bottom:this.createPort("bottom")}}});return this.graph.addCell(n),this.createStep(this.paper.findViewByModel(n)),n}createPort(t,e=this.portRadius,n="circle",i="orange",r="blue"){return{position:{name:t},attrs:{portBody:{magnet:!0,r:e,fill:i,stroke:r}},markup:[{tagName:n,selector:"portBody"}]}}showLinkTools(t){var e=new hd({tools:[new gd,new pd,new dd]});t.addTools(e)}render(){return rt`<slot><div></div></slot>`}};var bd;md([Pt({type:Boolean}),vd("design:type",Object)],yd.prototype,"renderInHost",void 0),md([Pt({type:Object}),vd("design:type",Object)],yd.prototype,"paper",void 0),md([Pt({type:Object}),vd("design:type",xc)],yd.prototype,"graph",void 0),md([Pt({type:Object}),vd("design:type",Object)],yd.prototype,"namespace",void 0),md([Pt({type:String}),vd("design:type",String)],yd.prototype,"height",void 0),md([Pt({type:String}),vd("design:type",String)],yd.prototype,"width",void 0),md([Pt({type:Number}),vd("design:type",Number)],yd.prototype,"portRadius",void 0),md([Pt({type:String}),vd("design:type",Object)],yd.prototype,"router",void 0),md([Pt({type:Number}),vd("design:type",Number)],yd.prototype,"templateHeight",void 0),md([Pt({type:Number}),vd("design:type",Number)],yd.prototype,"templateWidth",void 0),md([Pt({type:Number}),vd("design:type",Number)],yd.prototype,"templateSpacing",void 0),md([Pt({type:Number}),vd("design:type",Number)],yd.prototype,"gridSize",void 0),md([Pt({type:String}),vd("design:type",String)],yd.prototype,"gridColor",void 0),yd=md([(bd="qbo-flowchart",(t,e)=>{void 0!==e?e.addInitializer((()=>{customElements.define(bd,t)})):customElements.define(bd,t)}),vd("design:paramtypes",[])],yd)})(),i})()));
|
|
9
9
|
//# sourceMappingURL=qbo4.ui-flowchart.min.js.map
|