@joint/core 4.1.0 → 4.1.2
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/dist/geometry.js +1 -1
- package/dist/geometry.min.js +1 -1
- package/dist/joint.d.ts +32 -30
- package/dist/joint.js +76 -46
- package/dist/joint.min.js +2 -2
- package/dist/joint.nowrap.js +76 -46
- package/dist/joint.nowrap.min.js +2 -2
- package/dist/vectorizer.js +2 -2
- package/dist/vectorizer.min.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +1 -1
- package/src/V/index.mjs +1 -1
- package/src/dia/ElementView.mjs +1 -1
- package/src/dia/HighlighterView.mjs +5 -5
- package/src/dia/ToolsView.mjs +22 -11
- package/src/mvc/Collection.mjs +6 -2
- package/src/mvc/Dom/Dom.mjs +2 -2
- package/src/mvc/Dom/methods.mjs +9 -7
- package/src/mvc/Listener.mjs +1 -2
- package/src/mvc/Model.mjs +6 -2
- package/src/mvc/ViewBase.mjs +6 -2
- package/src/util/util.mjs +5 -4
- package/src/util/utilHelpers.mjs +5 -5
- package/types/joint.d.ts +32 -29
package/dist/joint.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! JointJS v4.1.
|
|
1
|
+
/*! JointJS v4.1.2 (2025-01-16) - JavaScript diagramming library
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
5
5
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
6
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
7
|
*/
|
|
8
|
-
var g,V,Vectorizer;((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).joint={})})(this,function(t){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _(t,e){return t(e={exports:{}},e.exports),e.exports}function N(t){return t&&t.Math==Math&&t}function O(t){try{return!!t()}catch(t){return!0}}function F(t){return St(kt(t))}function I(e,n){try{jt(yt,e,n)}catch(t){yt[e]=n}return n}function D(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++qt+$t).toString(36)}function z(t){return Wt[t]||(Wt[t]=D(t))}function j(t){return"function"==typeof t?t:void 0}function G(t,e){return arguments.length<2?j(Jt[t])||j(yt[t]):Jt[t]&&Jt[t][e]||yt[t]&&yt[t][e]}function U(t){return 0<t?ee(te(t),9007199254740991):0}function H(a){return function(t,e,n){var i,r=F(t),o=U(r.length),s=((t,e)=>(t=te(t))<0?ne(t+e,0):ie(t,e))(n,o);if(a&&e!=e){for(;s<o;)if((i=r[s++])!=i)return!0}else for(;s<o;s++)if((a||s in r)&&r[s]===e)return a||s||0;return!a&&-1}}function q(t,e){var n,i=F(t),r=0,o=[];for(n in i)!_t(Yt,n)&&_t(i,n)&&o.push(n);for(;e.length>r;)!_t(i,n=e[r++])||~re(o,n)||o.push(n);return o}function $(t,e){return(t=de[ce(t)])==pe||t!=fe&&("function"==typeof e?O(e):!!e)}function W(t,e){var n,i,r,o=t.target,s=t.global,a=t.stat,l=s?yt:a?yt[o]||I(o,{}):(yt[o]||{}).prototype;if(l)for(n in e){if(i=e[n],r=t.noTargetGet?(r=me(l,n))&&r.value:l[n],!ge(s?n:o+(a?".":"#")+n,t.forced)&&void 0!==r){if(typeof i==typeof r)continue;g=p=f=d=c=u=h=void 0;for(var h=i,u=r,c=he(u),d=zt.f,f=Vt.f,p=0;p<c.length;p++){var g=c[p];_t(h,g)||d(h,g,f(u,g))}}(t.sham||r&&r.sham)&&jt(i,"sham",!0),Zt(l,n,i,t)}}function Y(t){return _t(ye,t)||(ve&&_t(be,t)?ye[t]=be[t]:ye[t]=xe("Symbol."+t)),ye[t]}function X(){}function Z(t){Ne[_e][t]=!0}function J(t){throw t}function K(t,e){var n,i,r,o;return _t(Re,t)?Re[t]:(n=[][t],i=!!_t(e=e||{},"ACCESSORS")&&e.ACCESSORS,r=_t(e,0)?e[0]:J,o=_t(e,1)?e[1]:void 0,Re[t]=!!n&&!O(function(){if(i&&!bt)return 1;var t={length:-1};i?Oe(t,1,{enumerable:!0,get:J}):t[1]=1,n.call(t,r,o)}))}function Q(i,r,t){if(Ie(i),void 0===r)return i;switch(t){case 0:return function(){return i.call(r)};case 1:return function(t){return i.call(r,t)};case 2:return function(t,e){return i.call(r,t,e)};case 3:return function(t,e,n){return i.call(r,t,e,n)}}return function(){return i.apply(r,arguments)}}function nt(t,e,n){return Q(Ve,yt[t].prototype[e],n)}function it(t){return Object(kt(t))}function rt(t,e){var n;return new(void 0===(n=Be(t)&&("function"==typeof(n=t.constructor)&&(n===Array||Be(n.prototype))||Lt(n)&&null===(n=n[De]))?void 0:n)?Array:n)(0===e?0:e)}function ot(d){var f=1==d,p=2==d,g=3==d,m=4==d,v=6==d,y=7==d,b=5==d||v;return function(t,e,n,i){for(var r,o,s=it(t),a=St(s),l=Q(e,n,3),h=U(a.length),u=0,e=i||rt,c=f?e(t,h):p||y?e(t,0):void 0;u<h;u++)if((b||u in a)&&(o=l(r=a[u],u,s),d))if(f)c[u]=o;else if(o)switch(d){case 3:return!0;case 5:return r;case 6:return u;case 2:ze.call(c,r)}else switch(d){case 4:return!1;case 7:ze.call(c,r)}return v?-1:g||m?m:c}}function st(r){return function(t,e){var n,t=String(kt(t)),e=te(e),i=t.length;return e<0||i<=e?r?"":void 0:(n=t.charCodeAt(e))<55296||56319<n||e+1===i||(i=t.charCodeAt(e+1))<56320||57343<i?r?t.charAt(e):n:r?t.slice(e,e+2):i-56320+(n-55296<<10)+65536}}function at(){return this}var lt,ht,ut,ct,dt,ft,pt,gt,mt,vt,yt=N("object"==typeof globalThis&&globalThis)||N("object"==typeof window&&window)||N("object"==typeof self&&self)||N("object"==typeof e&&e)||function(){return this}()||Function("return this")(),bt=!O(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),e={}.propertyIsEnumerable,xt=Object.getOwnPropertyDescriptor,wt={f:xt&&!e.call({1:2},1)?function(t){t=xt(this,t);return!!t&&t.enumerable}:e},At=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Pt={}.toString,Et=function(t){return Pt.call(t).slice(8,-1)},Tt="".split,St=O(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==Et(t)?Tt.call(t,""):Object(t)}:Object,kt=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},Lt=function(t){return"object"==typeof t?null!==t:"function"==typeof t},Ct=function(t,e){if(!Lt(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t))||"function"==typeof(n=t.valueOf)&&!Lt(i=n.call(t))||!e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},Mt={}.hasOwnProperty,_t=function(t,e){return Mt.call(t,e)},Nt=yt.document,Ot=Lt(Nt)&&Lt(Nt.createElement),Rt=function(t){return Ot?Nt.createElement(t):{}},Ft=!bt&&!O(function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a}),It=Object.getOwnPropertyDescriptor,Vt={f:bt?It:function(t,e){if(t=F(t),e=Ct(e,!0),Ft)try{return It(t,e)}catch(t){}if(_t(t,e))return At(!wt.f.call(t,e),t[e])}},Bt=function(t){if(Lt(t))return t;throw TypeError(String(t)+" is not an object")},Dt=Object.defineProperty,zt={f:bt?Dt:function(t,e,n){if(Bt(t),e=Ct(e,!0),Bt(n),Ft)try{return Dt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},jt=bt?function(t,e,n){return zt.f(t,e,At(1,n))}:function(t,e,n){return t[e]=n,t},e="__core-js_shared__",Gt=yt[e]||I(e,{}),Ut=Function.toString,Ht=("function"!=typeof Gt.inspectSource&&(Gt.inspectSource=function(t){return Ut.call(t)}),Gt.inspectSource),e=yt.WeakMap,e="function"==typeof e&&/native code/.test(Ht(e)),n=_(function(t){(t.exports=function(t,e){return Gt[t]||(Gt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),qt=0,$t=Math.random(),Wt=n("keys"),Yt={},i=yt.WeakMap,Xt=(pt=e?(lt=Gt.state||(Gt.state=new i),ht=lt.get,ut=lt.has,ct=lt.set,dt=function(t,e){return e.facade=t,ct.call(lt,t,e),e},ft=function(t){return ht.call(lt,t)||{}},function(t){return ut.call(lt,t)}):(gt=z("state"),Yt[gt]=!0,dt=function(t,e){return e.facade=t,jt(t,gt,e),e},ft=function(t){return _t(t,gt)?t[gt]:{}},function(t){return _t(t,gt)}),{set:dt,get:ft,has:pt,enforce:function(t){return pt(t)?ft(t):dt(t,{})},getterFor:function(e){return function(t){if(Lt(t)&&(t=ft(t)).type===e)return t;throw TypeError("Incompatible receiver, "+e+" required")}}}),Zt=_(function(t){var e=Xt.get,a=Xt.enforce,l=String(String).split("String");(t.exports=function(t,e,n,i){var r,o=!!i&&!!i.unsafe,s=!!i&&!!i.enumerable,i=!!i&&!!i.noTargetGet;"function"==typeof n&&("string"!=typeof e||_t(n,"name")||jt(n,"name",e),(r=a(n)).source||(r.source=l.join("string"==typeof e?e:""))),t===yt?s?t[e]=n:I(e,n):(o?!i&&t[e]&&(s=!0):delete t[e],s?t[e]=n:jt(t,e,n))})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||Ht(this)})}),Jt=yt,Kt=Math.ceil,Qt=Math.floor,te=function(t){return isNaN(t=+t)?0:(0<t?Qt:Kt)(t)},ee=Math.min,ne=Math.max,ie=Math.min,e={includes:H(!0),indexOf:H(!1)},re=e.indexOf,oe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],se=oe.concat("length","prototype"),ae={f:Object.getOwnPropertyNames||function(t){return q(t,se)}},le={f:Object.getOwnPropertySymbols},he=G("Reflect","ownKeys")||function(t){var e=ae.f(Bt(t)),n=le.f;return n?e.concat(n(t)):e},ue=/#|\.prototype\./,ce=$.normalize=function(t){return String(t).replace(ue,".").toLowerCase()},de=$.data={},fe=$.NATIVE="N",pe=$.POLYFILL="P",ge=$,me=Vt.f,ve=!!Object.getOwnPropertySymbols&&!O(function(){return!String(Symbol())}),i=ve&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ye=n("wks"),be=yt.Symbol,xe=i?be:be&&be.withoutSetter||D,we=Object.keys||function(t){return q(t,oe)},Ae=bt?Object.defineProperties:function(t,e){Bt(t);for(var n,i=we(e),r=i.length,o=0;o<r;)zt.f(t,n=i[o++],e[n]);return t},Pe=G("document","documentElement"),Ee=">",Te="<",Se="prototype",ke="script",Le=z("IE_PROTO"),Ce=function(t){return Te+ke+Ee+t+Te+"/"+ke+Ee},Me=function(){try{mt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}Me=mt?((t=mt).write(Ce("")),t.close(),e=t.parentWindow.Object,t=null,e):(t=Rt("iframe"),e="java"+ke+":",t.style.display="none",Pe.appendChild(t),t.src=String(e),(e=t.contentWindow.document).open(),e.write(Ce("document.F=Object")),e.close(),e.F);for(var t,e,n=oe.length;n--;)delete Me[Se][oe[n]];return Me()},n=(Yt[Le]=!0,Object.create||function(t,e){var n;return null!==t?(X[Se]=Bt(t),n=new X,X[Se]=null,n[Le]=t):n=Me(),void 0===e?n:Ae(n,e)}),_e=Y("unscopables"),Ne=Array.prototype,Oe=(null==Ne[_e]&&zt.f(Ne,_e,{configurable:!0,value:n(null)}),Object.defineProperty),Re={},Fe=e.includes,i=K("indexOf",{ACCESSORS:!0,1:0}),Ie=(W({target:"Array",proto:!0,forced:!i},{includes:function(t){return Fe(this,t,1<arguments.length?arguments[1]:void 0)}}),Z("includes"),function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}),Ve=Function.call,Be=(nt("Array","includes"),Array.isArray||function(t){return"Array"==Et(t)}),De=Y("species"),ze=[].push,e={forEach:ot(0),map:ot(1),filter:ot(2),some:ot(3),every:ot(4),find:ot(5),findIndex:ot(6),filterOut:ot(7)},je=e.find,i="find",Ge=!0,r=K(i),r=(i in[]&&Array(1)[i](function(){Ge=!1}),W({target:"Array",proto:!0,forced:Ge||!r},{find:function(t){return je(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(i),nt("Array","find"),{codeAt:st(!1),charAt:st(!0)}),i=!O(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Ue=z("IE_PROTO"),He=Object.prototype,i=i?Object.getPrototypeOf:function(t){return t=it(t),_t(t,Ue)?t[Ue]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?He:null},qe=Y("iterator"),$e=!1,We=([].keys&&("next"in(We=[].keys())?(We=i(i(We)))!==Object.prototype&&(vt=We):$e=!0),null==vt||O(function(){var t={};return vt[qe].call(t)!==t})),We=(_t(vt=We?{}:vt,qe)||jt(vt,qe,function(){return this}),{IteratorPrototype:vt,BUGGY_SAFARI_ITERATORS:$e}),Ye=zt.f,Xe=Y("toStringTag"),$e=function(t,e,n){t&&!_t(t=n?t:t.prototype,Xe)&&Ye(t,Xe,{configurable:!0,value:e})},Ze={},o=We.IteratorPrototype,Je=function(){return this},s=Object.setPrototypeOf||("__proto__"in{}?(()=>{var n,i=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),i=t instanceof Array}catch(t){}return function(t,e){return Bt(t),(t=>{if(Lt(t)||null===t)return;throw TypeError("Can't set "+String(t)+" as a prototype")})(e),i?n.call(t,e):t.__proto__=e,t}})():void 0),a=We.IteratorPrototype,Ke=We.BUGGY_SAFARI_ITERATORS,We=Y("iterator"),Qe="values",tn="entries",en=r.charAt,nn="String Iterator",rn=Xt.set,on=Xt.getterFor(nn),r=String,sn="String",an=function(t){rn(this,{type:nn,string:String(t),index:0})},l=function(){var t=on(this),e=t.string,n=t.index;return n>=e.length?{value:void 0,done:!0}:(e=en(e,n),t.index+=e.length,{value:e,done:!1})},ln=void 0,h=void 0,hn=void 0;function un(t){if(t===ln&&mn)return mn;if(!Ke&&t in pn)return pn[t];switch(t){case"keys":case Qe:case tn:return function(){return new an(this,t)}}return function(){return new an(this)}}c=sn,c+=" Iterator",(u=an).prototype=n(o,{next:At(1,l)}),$e(u,c,!1,!0),Ze[c]=Je;var cn,dn,l=sn+" Iterator",fn=!1,pn=r.prototype,gn=pn[We]||pn["@@iterator"]||ln&&pn[ln],mn=!Ke&&gn||un(ln),u="Array"==sn&&pn.entries||gn;if(u&&(c=i(u.call(new r)),a!==Object.prototype)&&c.next&&(i(c)!==a&&(s?s(c,a):"function"!=typeof c[We]&&jt(c,We,at)),$e(c,l,!0,!0)),ln==Qe&&gn&&gn.name!==Qe&&(fn=!0,mn=function(){return gn.call(this)}),pn[We]!==mn&&jt(pn,We,mn),Ze[sn]=mn,ln)if(cn={values:un(Qe),keys:h?mn:un("keys"),entries:un(tn)},hn)for(dn in cn)!Ke&&!fn&&dn in pn||Zt(pn,dn,cn[dn]);else W({target:sn,proto:!0,forced:Ke||fn},cn);function vn(t,e,n){(e=Ct(e))in t?zt.f(t,e,At(0,n)):t[e]=n}var yn=function(t){var e=t.return;if(void 0!==e)return Bt(e.call(t)).value},bn=Y("iterator"),xn=Array.prototype,n={},o=(n[Y("toStringTag")]="z","[object z]"===String(n)),wn=Y("toStringTag"),An="Arguments"==Et(function(){return arguments}()),Pn=o?Et:function(t){var e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=((t,e)=>{try{return t[e]}catch(t){}})(t=Object(t),wn))?e:An?Et(t):"Object"==(e=Et(t))&&"function"==typeof t.callee?"Arguments":e},En=Y("iterator"),Tn=Y("iterator"),Sn=!1;try{var kn=0,Ln={next:function(){return{done:!!kn++}},return:function(){Sn=!0}};Ln[Tn]=function(){return this},Array.from(Ln,function(){throw 2})}catch(t){}function Cn(t){if(Lt(e=t)&&(void 0!==(n=e[Rn])?!!n:"RegExp"==Et(e)))throw TypeError("The method doesn't accept regular expressions");var e,n;return t}function Mn(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[Fn]=!1,"/./"[e](n)}catch(t){}}return!1}var Je=!((t,e)=>{if(!e&&!Sn)return!1;var n=!1;try{var i={};i[Tn]=function(){return{next:function(){return{done:n=!0}}}},t(i)}catch(t){}return n})(function(t){Array.from(t)}),_n=(W({target:"Array",stat:!0,forced:Je},{from:function(t){var e,n,i,r,o,s,a=it(t),t="function"==typeof this?this:Array,l=arguments.length,h=1<l?arguments[1]:void 0,u=void 0!==h,c=(t=>{if(null!=t)return t[En]||t["@@iterator"]||Ze[Pn(t)]})(a),d=0;if(u&&(h=Q(h,2<l?arguments[2]:void 0,2)),null!=c&&(t!=Array||void 0===(l=c)||Ze.Array!==l&&xn[bn]!==l))for(o=(r=c.call(a)).next,n=new t;!(i=o.call(r)).done;d++)s=u?((e,t,n,i)=>{try{return i?t(Bt(n)[0],n[1]):t(n)}catch(t){throw yn(e),t}})(r,h,[i.value,d],!0):i.value,vn(n,d,s);else for(n=new t(e=U(a.length));d<e;d++)s=u?h(a[d],d):a[d],vn(n,d,s);return n.length=d,n}}),Jt.Array.from,e.findIndex),u="findIndex",Nn=!0,r=K(u),On=(u in[]&&Array(1)[u](function(){Nn=!1}),W({target:"Array",proto:!0,forced:Nn||!r},{findIndex:function(t){return _n(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(u),nt("Array","findIndex"),_(function(t,e){function a(t){this.message=t}var l;e=e,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",(a.prototype=new Error).name="InvalidCharacterError",e.btoa||(e.btoa=function(t){for(var e,n,i=String(t),r=0,o=l,s="";i.charAt(0|r)||(o="=",r%1);s+=o.charAt(63&e>>8-r%1*8)){if(255<(n=i.charCodeAt(r+=.75)))throw new a("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|n}return s}),e.atob||(e.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new a("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,o=0,s="";i=e.charAt(o++);~i&&(n=r%4?64*n+i:i,r++%4)&&(s+=String.fromCharCode(255&n>>(-2*r&6))))i=l.indexOf(i);return s})}),W({target:"Number",stat:!0},{isNaN:function(t){return t!=t}}),Jt.Number.isNaN,yt.isFinite),i=Number.isFinite||function(t){return"number"==typeof t&&On(t)},Rn=(W({target:"Number",stat:!0},{isFinite:i}),Jt.Number.isFinite,Y("match")),Fn=Y("match"),s=(W({target:"String",proto:!0,forced:!Mn("includes")},{includes:function(t){return!!~String(kt(this)).indexOf(Cn(t),1<arguments.length?arguments[1]:void 0)}}),nt("String","includes"),Vt.f),In="".startsWith,Vn=Math.min,a=Mn("startsWith"),c=!(a||!($e=s(String.prototype,"startsWith"))||$e.writable);W({target:"String",proto:!0,forced:!c&&!a},{startsWith:function(t){var e=String(kt(this)),n=(Cn(t),U(Vn(1<arguments.length?arguments[1]:void 0,e.length))),t=String(t);return In?In.call(e,t,n):e.slice(n,n+t.length)===t}}),nt("String","startsWith");function Bn(t,e){return this.slice(t,e)}function Dn(t,e){arguments.length<2&&(e=0);for(var n=0,i=t.length;n<i;++n,++e)this[e]=255&t[n]}function zn(t){if("number"==typeof t)for(var e=new Array(t),n=0;n<t;++n)e[n]=0;else e=t.slice(0);return e.subarray=Bn,(e.buffer=e).byteLength=e.length,e.set=Dn,"object"==typeof t&&t.buffer&&(e.buffer=t.buffer),e}"undefined"==typeof Uint8Array&&"undefined"!=typeof window&&(window.Int32Array=window.Uint32Array=window.Uint8Array=zn);let{round:jn,floor:Gn,PI:Un}=Math;function Hn(t){return 180*t/Un%360}function qn(t,e){var n;return void 0===e?(e=void 0===t?1:t,t=0):e<t&&(n=t,t=e,e=n),Gn(Math.random()*(e-t+1)+t)}function $n(t,e){var n=Jn(t.y),i=Jn(e.y),t=t.x,e=e.x,e=Jn(e-t),t=Qn(e)*Kn(i),n=Kn(n)*Qn(i)-Qn(n)*Kn(i)*Kn(e);return(i=Hn(ti(t,n))-22.5)<0&&(i+=360),["NE","E","SE","S","SW","W","NW","N"][i=parseInt(i/45)]}function Wn(t,e){var n=t.x,t=t.y;return(n-=e.x)*n+(t-=e.y)*t}function Yn(t,e){return Math.sqrt(Wn(t,e))}let Xn=function(t){return t%360+(t<0?360:0)},Zn=function(t,e){return e*jn(t/e)},Jn=function(t,e){return(t=(e=e||!1)?t:t%360)*Un/180},{cos:Kn,sin:Qn,atan2:ti}=Math,d={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:ei,cos:ni,sin:ii,sqrt:ri,min:oi,max:si,atan2:ai,round:li,pow:hi,PI:ui}=Math,A=function(t,e){if(!(this instanceof A))return new A(t,e);var n;"string"==typeof t?(n=t.split(-1===t.indexOf("@")?" ":"@"),t=parseFloat(n[0]),e=parseFloat(n[1])):Object(t)===t&&(e=t.y,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e},ci=(A.fromPolar=function(t,e,n){n=new A(n);var i=ei(t*ni(e)),t=ei(t*ii(e)),e=Xn(Hn(e));return e<90?t=-t:e<180?(i=-i,t=-t):e<270&&(i=-i),new A(n.x+i,n.y+t)},A.random=function(t,e,n,i){return new A(qn(t,e),qn(n,i))},A.prototype={type:d.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new A(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new A(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=oi(si(this.x,t.x),t.x+t.width),this.y=oi(si(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){e=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return e<0&&(e+=360),e},bearing:function(t){return $n(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new A(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 A(this.x-(t||0),this.y-(e||0))},distance:function(t){return Yn(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 A((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return ri(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return ei(t.x-this.x)+ei(t.y-this.y)},move:function(t,e){t=Jn(new A(t).theta(this));return this.offset(ni(t)*e,-ii(t)*e)},normalize:function(t){t=(t||1)/this.magnitude();return this.scale(t,t)},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 A(t).move(this,this.distance(t))},rotate:function(t,e){var n,i;return 0!==e&&(t=t||new A(0,0),e=Jn(Xn(-e)),n=ni(e),e=ii(e),i=n*(this.x-t.x)-e*(this.y-t.y)+t.x,e=e*(this.x-t.x)+n*(this.y-t.y)+t.y,this.x=i,this.y=e),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=hi(10,t)}return this.x=li(this.x*e)/e,this.y=li(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new A(n)||new A(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=Zn(this.x,t),this.y=Zn(this.y,e||t),this},squaredDistance:function(t){return Wn(this,t)},theta:function(t){var e=-((t=new A(t)).y-this.y),t=t.x-this.x,e=ai(e,t);return 180*(e=e<0?2*ui+e:e)/ui},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new A(t)||new A(0,0);var e=this.x,n=this.y;return this.x=ri((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Jn(t.theta(new A(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 A(0,0).angleBetween(this,t)}},A.prototype.translate=A.prototype.offset,A),{max:di,min:fi}=Math,P=function(t,e){return this instanceof P?t instanceof P?new P(t.start,t.end):(this.start=new A(t),void(this.end=new A(e))):new P(t,e)},pi=(P.prototype={type:d.Line,angle:function(){var t=new A(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=fi(this.start.x,this.end.x),e=fi(this.start.y,this.end.y),n=di(this.start.x,this.end.x),i=di(this.start.y,this.end.y);return new tt(t,e,n-t,i-e)},bearing:function(){return $n(this.start,this.end)},clone:function(){return new P(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){t=this.vector().dot(new P(this.start,t).vector()),t=fi(1,di(0,t/this.squaredLength()));return t!=t?0:t},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e,n=this.start,i=this.end;return 0===n.cross(t,i)&&(e=this.length(),!(new P(n,t).length()>e||new P(t,i).length()>e))},divideAt:function(t){t=this.pointAt(t);return[new P(this.start,t),new P(t,this.end)]},divideAtLength:function(t){t=this.pointAtLength(t);return[new P(this.start,t),new P(t,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){return t&&t.intersectionWithLine?(e=t.intersectionWithLine(this,e))&&t instanceof P?e[0]:e:null},intersectionWithLine:function(t){var e=new A(this.end.x-this.start.x,this.end.y-this.start.y),n=new A(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,t=new A(t.start.x-this.start.x,t.start.y-this.start.y),n=t.x*n.y-t.y*n.x,t=t.x*e.y-t.y*e.x;if(0==i||n*i<0||t*i<0)return null;if(0<i){if(i<n||i<t)return null}else if(n<i||t<i)return null;return[new A(this.start.x+n*e.x/i,this.start.y+n*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return Yn(this.start,this.end)},midpoint:function(){return new A((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var e,n,i,r,o=this.clone();return this.isDifferentiable()&&({start:e,end:n}=o,i=e.clone().rotate(n,270),r=n.clone().rotate(e,90),e.move(r,t),n.move(i,t)),o},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():1<=t?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0,r=(t<0&&(i=!1,t=-t),this.length());return r<=t?(i?n:e).clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new A(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();return e?this.scale(t=t/e,t,this.start):this},squaredLength:function(){return Wn(this.start,this.end)},tangentAt:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAt(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},tangentAtLength:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAtLength(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},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 A(this.end.x-this.start.x,this.end.y-this.start.y)}},P.prototype.intersection=P.prototype.intersect,P),{sqrt:gi,round:mi,pow:vi}=Math,yi=function(t,e,n){return this instanceof yi?t instanceof yi?new yi(new A(t.x,t.y),t.a,t.b):(t=new A(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new yi(t,e,n)};yi.fromRect=function(t){return t=new tt(t),new yi(t.center(),t.width/2,t.height/2)},yi.prototype={type:d.Ellipse,bbox:function(){return new tt(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new A(this.x,this.y)},clone:function(){return new yi(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,t=t.vector(),s=n.difference(new A(this)),a=new A(t.x/(r*r),t.y/(o*o)),r=new A(s.x/(r*r),s.y/(o*o)),o=t.dot(a),a=t.dot(r),t=a*a-o*(s.dot(r)-1);if(t<0)return null;if(0<t){s=gi(t),r=(-a-s)/o,t=(-a+s)/o;if((r<0||1<r)&&(t<0||1<t))return null;0<=r&&r<=1&&e.push(n.lerp(i,r)),0<=t&&t<=1&&e.push(n.lerp(i,t))}else{s=-a/o;if(!(0<=s&&s<=1))return null;e.push(n.lerp(i,s))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t),e&&t.rotate(new A(this.x,this.y),e);var n,i,r,o=t.x-this.x,s=t.y-this.y;return r=0==o?this.bbox().pointNearestToPoint(t):(s=(t=s/o)*t,i=this.a*this.a,n=this.b*this.b,i=gi(1/(1/i+s/n)),s=t*(i=o<0?-i:i),new A(this.x+i,this.y+s)),e?r.rotate(new A(this.x,this.y),-e):r},normalizedDistance:function(t){var e=t.x,t=t.y,n=this.a,i=this.b,r=this.x,o=this.y;return(e-r)*(e-r)/(n*n)+(t-o)*(t-o)/(i*i)},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=vi(10,t)}return this.x=mi(this.x*e)/e,this.y=mi(this.y*e)/e,this.a=mi(this.a*e)/e,this.b=mi(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,h=a.y;return a.x+o/2<i||i<a.x-o/2?n=o*o/(i-l)-o*o*(r-h)*((e=i>a.x?r-30:r+30)-h)/(s*s*(i-l))+l:e=s*s/(r-h)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-h))+h,new A(n,e).theta(t)},toString:function(){return new A(this.x,this.y).toString()+" "+this.a+" "+this.b}};l=yi;let{abs:bi,cos:xi,sin:wi,min:Ai,max:Pi,round:Ei,pow:Ti}=Math,tt=function(t,e,n,i){if(!(this instanceof tt))return new tt(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};tt.fromEllipse=function(t){return t=new yi(t),new tt(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},tt.fromPointUnion=function(){if(0===arguments.length)return null;var e=new A;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let t=0;t<arguments.length;t++){e.update(t<0||arguments.length<=t?void 0:arguments[t]);var s=e.x,a=e.y;s<n&&(n=s),s>r&&(r=s),a<i&&(i=a),a>o&&(o=a)}return new tt(n,i,r-n,o-i)},tt.fromRectUnion=function(){if(0===arguments.length)return null;var e=new tt;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let t=0;t<arguments.length;t++){e.update(t<0||arguments.length<=t?void 0:arguments[t]);var s=e.x,a=e.y,l=s+e.width,h=a+e.height;s<n&&(n=s),l>r&&(r=l),a<i&&(i=a),h>o&&(o=h)}return new tt(n,i,r-n,o-i)},tt.prototype={type:d.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){var e,n,i,r;return t&&({width:i,height:e}=this,t=Jn(t),r=i*(n=bi(wi(t)))+e*(t=bi(xi(t))),this.x+=(i-(i=i*t+e*n))/2,this.y+=(e-r)/2,this.width=i,this.height=r),this},bottomLeft:function(){return new A(this.x,this.y+this.height)},bottomLine:function(){return new P(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new A(this.x+this.width/2,this.y+this.height)},center:function(){return new A(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new tt(this)},containsPoint:function(t,e){let n,i;return t&&"string"!=typeof t?{x:n=0,y:i=0}=t:{x:n,y:i}=new A(t),e&&e.strict?n>this.x&&n<this.x+this.width&&i>this.y&&i<this.y+this.height:n>=this.x&&n<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},containsRect:function(t){var e,n,i=new tt(this).normalize(),t=new tt(t).normalize(),r=i.width,o=i.height,s=t.width,a=t.height;return!!(r&&o&&s&&a)&&(e=i.x,i=i.y,s+=n=t.x,r+=e,a+=t=t.y,o+=i,e<=n)&&s<=r&&i<=t&&a<=o},corner:function(){return new A(this.x+this.width,this.y+this.height)},equals:function(t){var e=new tt(this).normalize(),t=new tt(t).normalize();return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.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,n=this.origin(),i=this.corner(),r=t.origin(),t=t.corner();return t.x<=n.x||t.y<=n.y||r.x>=i.x||r.y>=i.y?null:(e=Pi(n.x,r.x),n=Pi(n.y,r.y),new tt(e,n,Ai(i.x,t.x)-e,Ai(i.y,t.y)-n))},intersectionWithLine:function(t){for(var e,n=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],i=[],r=[],o=n.length,s=0;s<o;s++)null!==(e=t.intersect(n[s]))&&r.indexOf(e.toString())<0&&(i.push(e),r.push(e.toString()));return 0<i.length?i:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t);for(var n,i=new A(this.x+this.width/2,this.y+this.height/2),r=(e&&t.rotate(i,e),[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()]),o=new P(i,t),s=r.length-1;0<=s;--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 P(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new A(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){t=new tt(t);var n,i,r,o,s,a,l,h=(e=e||t.center()).x,e=e.y,u=n=i=r=o=s=a=l=1/0,c=t.topLeft(),c=(c.x<h&&(u=(this.x-h)/(c.x-h)),c.y<e&&(o=(this.y-e)/(c.y-e)),t.bottomRight()),c=(c.x>h&&(n=(this.x+this.width-h)/(c.x-h)),e<c.y&&(s=(this.y+this.height-e)/(c.y-e)),t.topRight()),c=(c.x>h&&(i=(this.x+this.width-h)/(c.x-h)),c.y<e&&(a=(this.y-e)/(c.y-e)),t.bottomLeft());return c.x<h&&(r=(this.x-h)/(c.x-h)),e<c.y&&(l=(this.y+this.height-e)/(c.y-e)),{sx:Ai(u,n,i,r),sy:Ai(o,s,a,l)}},maxRectUniformScaleToFit:function(t,e){t=this.maxRectScaleToFit(t,e);return Ai(t.sx,t.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 A.prototype.offset.call(this,t,e)},origin:function(){return new A(this.x,this.y)},pointNearestToPoint:function(t){if(t=new A(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new A(this.x+this.width,t.y);case"left":return new A(this.x,t.y);case"bottom":return new A(t.x,this.y+this.height);case"top":return new A(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new P(this.topRight(),this.bottomRight())},rightMiddle:function(){return new A(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=Ti(10,t)}return this.x=Ei(this.x*e)/e,this.y=Ei(this.y*e)/e,this.width=Ei(this.width*e)/e,this.height=Ei(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 A(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r="left";return n<e&&(e=n,r="right"),i<e&&(e=i,r="top"),r=this.y+this.height-t.y<e?"bottom":r},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),t=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=t.x-n.x,this.height=t.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new P(this.topLeft(),this.topRight())},topMiddle:function(){return new A(this.x+this.width/2,this.y)},topRight:function(){return new A(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return tt.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}},tt.prototype.bottomRight=tt.prototype.corner,tt.prototype.topLeft=tt.prototype.origin,tt.prototype.translate=tt.prototype.offset;h=tt;function Si(t){t=t.trim();if(""===t)return[];var e=[],n=t.split(/\b\s*,\s*|,\s*|\s+/),i=n.length;for(let t=0;t<i;t+=2)e.push({x:+n[t],y:+n[t+1]});return e}function ki(e){var n=e.length;if(0===n)return[];var i=[];for(let t=0;t<n;t++){var r=e[t].clone();i.push(r)}return i}function Li(t){var e,n=Math.abs,i=t.length;if(0===i)return[];for(o=0;o<i;o++)(void 0===e||t[o].y<e.y||t[o].y===e.y&&t[o].x>e.x)&&(e=t[o]);for(var r=[],o=0;o<i;o++){var s=e.theta(t[o]),s=(0===s&&(s=360),[t[o],o,s]);r.push(s)}r.sort(function(t,e){var n=t[2]-e[2];return n=0===n?e[1]-t[1]:n}),2<r.length&&r.unshift(r[r.length-1]);for(var a,l,h,u={},c=[];0!==r.length;)if(l=(a=r.pop())[0],!u.hasOwnProperty(a[0]+"@@"+a[1]))for(var d,f,p,g,m,v=!1;!v;)c.length<2?(c.push(a),v=!0):(f=(d=c.pop())[0],(m=(g=(p=c.pop())[0]).cross(f,l))<0?(c.push(p),c.push(d),c.push(a),v=!0):0!==m||n((m=f.angleBetween(g,l))-180)<1e-10||f.equals(l)||g.equals(f)?(u[d[0]+"@@"+d[1]]=f,c.push(p)):n((m+1)%360-1)<1e-10&&(c.push(p),r.push(d)));2<c.length&&c.pop();var y=-1,b=c.length;for(o=0;o<b;o++){var x=c[o][1];(void 0===h||x<h)&&(h=x,y=o)}var w,A,P=[],E=[];for(b=(P=0<y?(w=c.slice(y),A=c.slice(0,y),w.concat(A)):c).length,o=0;o<b;o++)E.push(P[o][0]);return E}let x=function(t){return this instanceof x?"string"==typeof t?new x.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new x(t)},{abs:Ci,sqrt:Mi,min:_i,max:Ni,pow:Oi}=(x.parse=function(t){return new x(Si(t))},x.fromRect=function(t){return new x([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},x.prototype={type:d.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,a=a.y;l<t&&(t=l),e<l&&(e=l),a<n&&(n=a),i<a&&(i=a)}return new tt(t,n,e-t,i-n)},clone:function(){return new x(ki(this.points))},closestPoint:function(t){t=this.closestPointLength(t);return this.pointAtLength(t)},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 P(n[a],n[a+1]),h=l.length(),u=l.closestPointNormalizedLength(t),l=l.pointAt(u).squaredDistance(t);l<r&&(r=l,e=o+u*h),o+=h}return e},closestPointNormalizedLength:function(t){var e,t=this.closestPointLength(t);return 0===t||0===(e=this.length())?0:t/e},closestPointTangent:function(t){t=this.closestPointLength(t);return this.tangentAtLength(t)},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 P,h=new P,u=new A;s<n;s++){var c=e[o],d=e[s];if(t.equals(c))return!0;if(l.start=c,l.end=d,l.containsPoint(t))return!0;(r<=c.y&&r>d.y||r>c.y&&r<=d.y)&&0<=(c=c.x-i>d.x-i?c.x-i:d.x-i)&&(u.x=i+c,u.y=r,h.start=t,h.end=u,l.intersect(h))&&a++,o=s}return a%2==1},close:function(){var{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 x(Li(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 P(t),n=[],i=this.lengthPoints(),r=new P,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 0<n.length?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0!==e)for(var n=new P,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;return 0===n?null:1===n||t<=0?e[0].clone():1<=t?e[n-1].clone():(e=this.length(),this.pointAtLength(e*t))},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();for(var i=!0,r=(t<0&&(i=!1,t=-t),0),o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],a=e[a+1],h=new P(l,a),l=l.distance(a);if(t<=r+l)return h.pointAtLength((i?1:-1)*(t-r));r+=l}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(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=this.points;if(!(n.length<3)){var i=e.threshold||1e-10;let t=0;for(;n[t+2];){var r=t,o=t+1,s=t+2,r=n[r],a=n[o],s=n[s];new P(r,s).closestPoint(a).distance(a)<=i?n.splice(o,1):t+=1}}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;1<(t=t<0?0:t)&&(t=1);e=this.length();return this.tangentAtLength(e*t)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;for(var i,r=!0,o=(t<0&&(r=!1,t=-t),0),s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,h=e[l],l=e[l+1],u=new P(h,l),h=h.distance(l);if(u.isDifferentiable()){if(t<=o+h)return u.tangentAtLength((r?1:-1)*(t-o));i=u}o+=h}return i?i.tangentAt(r?1:0):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(x.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(x.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}}),Math),v=function(t,e,n,i){return this instanceof v?t instanceof v?new v(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new A(t),this.controlPoint1=new A(e),this.controlPoint2=new A(n),void(this.end=new A(i))):new v(t,e,n,i)};function Ri(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,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}function Fi(t){for(var e=[],n=arguments.length,i=1;i<n;i++)e.push(arguments[i]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=e.length,i=0;i<n;i++){var o,s,a=e[i];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}v.throughPoints=function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var e=(t=>{var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=Ri(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=Ri(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]})(t),n=[],i=e[0].length,r=0;r<i;r++){var o=new A(e[0][r].x,e[0][r].y),s=new A(e[1][r].x,e[1][r].y);n.push(new v(t[r],o,s,t[r+1]))}return n},v.prototype={type:d.Curve,bbox:function(){for(var t,e,n,i,r,o=this.start,s=this.controlPoint1,a=this.controlPoint2,l=this.end,h=o.x,u=o.y,c=s.x,d=s.y,f=a.x,p=a.y,g=l.x,m=l.y,v=new Array,y=new Array,b=[new Array,new Array],x=0;x<2;++x)i=0===x?(e=6*h-12*c+6*f,t=-3*h+9*c-9*f+3*g,3*c-3*h):(e=6*u-12*d+6*p,t=-3*u+9*d-9*p+3*m,3*d-3*u),Ci(t)<1e-12?Ci(e)<1e-12||0<(n=-i/e)&&n<1&&y.push(n):(i=e*e-4*i*t,r=Mi(i),i<0||(0<(i=(-e+r)/(2*t))&&i<1&&y.push(i),0<(i=(-e-r)/(2*t))&&i<1&&y.push(i)));for(var w,A,P=y.length,o=P;P--;)n=y[P],b[0][P]=w=(A=1-n)*A*A*h+3*A*A*n*c+3*A*n*n*f+n*n*n*g,b[1][P]=A=A*A*A*u+3*A*A*n*d+3*A*n*n*p+n*n*n*m,v[P]={X:w,Y:A};y[o]=0,y[o+1]=1,v[o]={X:h,Y:u},v[o+1]={X:g,Y:m},b[0][o]=h,b[1][o]=u,b[0][o+1]=g,b[1][o+1]=m,y.length=o+2,b[0].length=o+2,b[1].length=o+2,v.length=o+2;s=_i.apply(null,b[0]),a=_i.apply(null,b[1]),l=Ni.apply(null,b[0]),o=Ni.apply(null,b[1]);return new tt(s,a,l-s,o-a)},clone:function(){return new v(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,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,n),n)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.closestPointLength(t,n);return!e||0===(t=this.length(n))?0:e/t},closestPointT:function(t,e){for(var n,i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,u=h.length,c=u?1/u:0,d=0;d<u;d++){var f=h[d],p=f.start.distance(t),g=f.end.distance(t),m=p+g;(!a||m<a)&&(i=d*c,r=(d+1)*c,o=p,E=g,s=(n=f).start.distance(f.end),a=m)}for(var v=Oi(10,-l);;){var y=o?Ci(o-E)/o:0,b=E?Ci(o-E)/E:0;if(y<v||b<v||(!o||o<s*v||(!E||E<s*v)))return o<=E?i:r;var y=n.divide(.5),b=(c/=2,y[0].start.distance(t)),x=y[0].end.distance(t),w=b+x,A=y[1].start.distance(t),P=y[1].end.distance(t),E=w<=A+P?(n=y[0],r-=c,o=b,x):(n=y[1],i+=c,o=A,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){return t<=0?this.divideAtT(0):1<=t?this.divideAtT(1):(t=this.tAt(t,e),this.divideAtT(t))},divideAtLength:function(t,e){t=this.tAtLength(t,e);return this.divideAtT(t)},divideAtT:function(t){var e,n,i=this.start,r=this.controlPoint1,o=this.controlPoint2,s=this.end;return t<=0?[new v(i,i,i,i),new v(i,r,o,s)]:1<=t?[new v(i,r,o,s),new v(s,s,s,s)]:(o=(r=this.getSkeletonPoints(t)).startControlPoint1,t=r.startControlPoint2,e=r.divider,n=r.dividerControlPoint1,r=r.dividerControlPoint2,[new v(i,o,t,e),new v(e,n,r,s)])},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;return t<=0?{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()}:1<=t?{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()}:(e=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),i=new P(i,r).pointAt(t),r=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),{startControlPoint1:e,startControlPoint2:r,divider:new P(r,n).pointAt(t),dividerControlPoint1:n,dividerControlPoint2:i})},getSubdivisions:function(t){var t=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end,o=[new v(e,n,i,r)];if(0===t)return o;if(!this.isDifferentiable())return o;for(var s=this.endpointDistance(),a=Oi(10,-t),l=2,h=(0===n.cross(e,r)&&0===i.cross(e,r)&&(l=2*t),0);;){h+=1;for(var u=[],c=o.length,d=0;d<c;d++){var f=o[d].divide(.5);u.push(f[0],f[1])}for(var p=0,g=u.length,m=0;m<g;m++)p+=u[m].endpointDistance();if(l<=h)if((0!==p?(p-s)/p:0)<a)return u;o=u,s=p}},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){return t<=0?0:(e=void 0===(e=e||{}).precision?this.PRECISION:e.precision,this.divide(t)[0].length({precision:e}))},pointAt:function(t,e){return t<=0?this.start.clone():1<=t?this.end.clone():(t=this.tAt(t,e),this.pointAtT(t))},pointAtLength:function(t,e){t=this.tAtLength(t,e);return this.pointAtT(t)},pointAtT:function(t){return t<=0?this.start.clone():1<=t?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:1<t&&(t=1);t=this.tAt(t,e);return this.tangentAtT(t)},tangentAtLength:function(t,e){return this.isDifferentiable()?(t=this.tAtLength(t,e),this.tangentAtT(t)):null},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var t=this.getSkeletonPoints(t),e=t.startControlPoint2,n=t.dividerControlPoint1,t=t.divider,n=new P(e,n);return n.translate(t.x-e.x,t.y-e.y),n},tAt:function(t,e){var n;return t<=0?0:1<=t?1:(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.length(n),this.tAtLength(e*t,n))},tAtLength:function(t,e){for(var n,i,r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.subdivisions?this.getSubdivisions({precision:s}):e.subdivisions,e={precision:s,subdivisions:a},l=0,h=a.length,u=1/h,c=0;c<h;c++){var d=o?c:h-1-c,f=a[c],p=f.endpointDistance();if(t<=l+p){n=f,i=d*u,r=(d+1)*u,w=o?t-l:p+l-t,A=o?p+l-t:t-l;break}l+=p}if(!n)return o?1:0;for(var g=this.length(e),m=Oi(10,-s);;){var v,y=0!==g?w/g:0;if(y<m)return i;if((0!==g?A/g:0)<m)return r;var y=n.divide(.5),b=(u/=2,y[0].endpointDistance()),x=y[1].endpointDistance(),y=w<=b?(n=y[0],r-=u,b-(v=w)):(n=y[1],i+=u,x-(v=w-b)),w=v,A=y}},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 x(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}},v.prototype.divide=v.prototype.divideAtT;let V=function(t){if(!(this instanceof V))return new V(t);if("string"==typeof t)return new V.parse(t);var e;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(e=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(r=0;r<e;r++){var n=t[r];this.appendSegment(n)}else for(var i=null,r=0;r<e;r++){var o=t[r];if(!(o instanceof P||o instanceof v))throw new Error("Cannot construct a path segment from the provided object.");0===r&&this.appendSegment(V.createSegment("M",o.start)),i&&!i.end.equals(o.start)&&this.appendSegment(V.createSegment("M",o.start)),o instanceof P?this.appendSegment(V.createSegment("L",o.end)):o instanceof v&&this.appendSegment(V.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),i=o}else if(t.isSegment)this.appendSegment(t);else if(t instanceof P)this.appendSegment(V.createSegment("M",t.start)),this.appendSegment(V.createSegment("L",t.end));else if(t instanceof v)this.appendSegment(V.createSegment("M",t.start)),this.appendSegment(V.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof x))throw new Error("Cannot construct a path from the provided object.");if(t.points&&0!==t.points.length)for(e=t.points.length,r=0;r<e;r++){var s=t.points[r];0===r?this.appendSegment(V.createSegment("M",s)):this.appendSegment(V.createSegment("L",s))}}};function Ii(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}V.parse=function(t){if(!t)return new V;for(var e=new V,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),o=V.createSegment.apply(this,o);e.appendSegment(o)}return e},V.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=V.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 Ii(e,n)},V.prototype={type:d.Path,appendSegment:function(t){var e=this.segments,n=e.length,i=0!==n?e[n-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 r=t.length,o=0;o<r;o++){var s=t[o],a=this.prepareSegment(s,i,null);e.push(a),i=a}}else{if(!t||!t.isSegment)throw new Error("Segment required.");a=this.prepareSegment(t,i,null),e.push(a)}},bbox:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n,i=0;i<e;i++){var r,o=t[i];o.isVisible&&(o=o.bbox(),r=r?r.union(o):o)}return r||(n=t[e-1],new tt(n.end.x,n.end.y,0,0))},clone:function(){for(var t=this.segments,e=t.length,n=new V,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){t=this.closestPointT(t,e);return t?this.pointAtT(t):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointT(t,n);return e?this.lengthAtT(e,n):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointLength(t,n);return 0===e||0===(t=this.length(n))?0:e/t},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 h=n[l],u=s[l];h.isVisible&&(u=h.closestPointT(t,{precision:o,subdivisions:u}),h=h.pointAtT(u),(h=new P(h,t).squaredLength())<a)&&(r={segmentIndex:l,value:u},a=h)}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 h,u=n[l],c=s[l];u.isDifferentiable()&&(c=u.closestPointT(t,{precision:o,subdivisions:c}),h=u.pointAtT(c),(h=new P(h,t).squaredLength())<a)&&(r=u.tangentAtT(c),a=h)}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;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.divideAtLength(e*t,n)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;for(var i,r,o,s,a=!0,l=(t<0&&(a=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),h=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:l}):e.segmentSubdivisions,u=0,c=0;c<n;c++){var d=a?c:n-1-c,f=this.getSegment(d),p=h[d],g=f.length({precision:l,subdivisions:p});if(f.isDifferentiable()&&(o=f,s=d,t<=u+g)){r=d,i=f.divideAtLength((a?1:-1)*(t-u),{precision:l,subdivisions:p});break}u+=g}if(!o)return null;i||(r=s,i=o.divideAtT(a?1:0));var m=this.clone(),e=(m.replaceSegment(r,i),r),v=r+1,y=r+2,b=(i[0].isDifferentiable()||(m.removeSegment(e),--v,--y),m.getSegment(v).start),x=(m.insertSegment(v,V.createSegment("M",b)),y+=1,i[1].isDifferentiable()||(m.removeSegment(y-1),--y),y-e-1);for(c=y;c<m.segments.length;c++){var w=this.getSegment(c-x);"Z"!==(f=m.getSegment(c)).type||w.subpathStartSegment.end.equals(f.subpathStartSegment.end)||(w=V.createSegment("L",w.end),m.replaceSegment(c,w))}return[new V(m.segments.slice(0,v)),new V(m.segments.slice(v))]},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(n<=(t=t<0?n+t:t)||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(){var e=this.clone().validate().segments,n=e.length,i=[];for(let t=0;t<n;t++){var r=e[t];r.isSubpathStart?i.push(new V(r)):i[i.length-1].appendSegment(r)}return i},insertSegment:function(t,e){var n=this.segments,i=n.length;if(i<(t=t<0?i+t+1:t)||t<0)throw new Error("Index out of range.");var r=null,o=null;if(0!==i&&(o=1<=t?(r=n[t-1]).nextSegment:n[0]),Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var s=e.length,a=0;a<s;a++){var l=e[a],h=this.prepareSegment(l,r,o);n.splice(t+a,0,h),r=h}}else{if(!e||!e.isSegment)throw new Error("Segment required.");h=this.prepareSegment(e,r,o),n.splice(t,0,h)}},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],s=t.intersect(s);s&&(n=n||[],Array.isArray(s)?Array.prototype.push.apply(n,s):n.push(s))}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;for(var t=t.value,o=(i<=r?(r=i-1,t=1):t<0?t=0:1<t&&(t=1),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=0,l=0;l<r;l++){var h=n[l],u=s[l];a+=h.length({precisison:o,subdivisions:u})}return u=s[r],a+=(h=n[r]).lengthAtT(t,{precisison:o,subdivisions:u})},pointAt:function(t,e){var n;return 0===this.segments.length?null:t<=0?this.start.clone():1<=t?this.end.clone():(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n),this.pointAtLength(e*t,n))},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<i;h++){var u=o?h:i-1-h,c=n[u],u=a[u],d=c.length({precision:s,subdivisions:u});if(c.isVisible){if(t<=l+d)return c.pointAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:u});r=c}l+=d}return r?o?r.end:r.start:n[i-1].end.clone()},pointAtT:function(t){var e,n=this.segments,i=n.length;return 0===i?null:(e=t.segmentIndex)<0?n[0].pointAtT(0):i<=e?n[i-1].pointAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),n[e].pointAtT(i))},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);e=t;return t.isSubpathStart&&(t.subpathStartSegment=t,e=n),e&&this.updateSubpathStartSegment(e),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(n<=(t=t<0?n+t:t)||t<0)throw new Error("Index out of range.");n=e.splice(t,1)[0],e=n.previousSegment,t=n.nextSegment;e&&(e.nextSegment=t),t&&(t.previousSegment=e),n.isSubpathStart&&t&&this.updateSubpathStartSegment(t)},replaceSegment:function(t,e){var n=this.segments,i=n.length;if(0===i)throw new Error("Path has no segments.");if(i<=(t=t<0?i+t:t)||t<0)throw new Error("Index out of range.");var i=n[t],r=i.previousSegment,o=i.nextSegment,s=i.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");n.splice(t,1);for(var a=e.length,l=0;l<a;l++){var h=e[l],u=this.prepareSegment(h,r,o);n.splice(t+l,0,u),r=u,s&&u.isSubpathStart&&(s=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");u=this.prepareSegment(e,r,o),n.splice(t,1,u),s&&u.isSubpathStart&&(s=!1)}s&&o&&this.updateSubpathStartSegment(o)},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){t=this.segmentIndexAt(t,e);return t?this.getSegment(t):null},segmentAtLength:function(t,e){t=this.segmentIndexAtLength(t,e);return t?this.getSegment(t):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.segmentIndexAtLength(e*t,n)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r=!0,o=(t<0&&(r=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,h=0;h<i;h++){var u=r?h:i-1-h,c=n[u],d=s[u],d=c.length({precision:o,subdivisions:d});if(c.isVisible){if(t<=l+d)return u;a=u}l+=d}return a},serialize:function(){if(this.isValid())return this.toString();throw new Error("Invalid path segments.")},tangentAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.tangentAtLength(e*t,n)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<i;h++){var u=o?h:i-1-h,c=n[u],u=a[u],d=c.length({precision:s,subdivisions:u});if(c.isDifferentiable()){if(t<=l+d)return c.tangentAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:u});r=c}l+=d}return r?r.tangentAtT(o?1:0):null},tangentAtT:function(t){var e,n=this.segments,i=n.length;return 0===i?null:(e=t.segmentIndex)<0?n[0].tangentAtT(0):i<=e?n[i-1].tangentAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),n[e].tangentAtT(i))},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,h=e[a];h.isVisible?0<(l=r[a]).length?(l=l.map(function(t){return t.start}),Array.prototype.push.apply(s,l)):s.push(h.start):0<s.length&&(s.push(e[a-1].end),o.push(s),s=[])}return 0<s.length&&(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 x(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,t=(e=t).nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,V.createSegment("M",0,0)),this}},Object.defineProperty(V.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(V.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;0<=n;n--){var i=t[n];if(i.isVisible)return i.end}return t[e-1].end}});function Vi(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof Vi))return Ii(Vi,t);if(0===e)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(t[0]instanceof P){if(1===e)return this.end=t[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+e+" lines provided).")}if("string"==typeof t[0]||"number"==typeof t[0]){if(2===e)return this.end=new A(+t[0],+t[1]),this;if(e<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+e+" coordinates provided).");for(var i,r=[],n=0;n<e;n+=2)i=t.slice(n,n+2),r.push(Ii(Vi,i))}else{if(1===e)return this.end=new A(t[0]),this;for(r=[],n=0;n<e;n+=1)r.push(new Vi(t[n]))}return r}function Bi(){for(var t,e=[],n=arguments.length,i=0;i<n;i++)e.push(arguments[i]);if(!(this instanceof Bi))return Ii(Bi,e);if(0===n)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(e[0]instanceof v){if(1===n)return this.controlPoint1=e[0].controlPoint1.clone(),this.controlPoint2=e[0].controlPoint2.clone(),this.end=e[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" curves provided).")}if("string"==typeof e[0]||"number"==typeof e[0]){if(6===n)return this.controlPoint1=new A(+e[0],+e[1]),this.controlPoint2=new A(+e[2],+e[3]),this.end=new A(+e[4],+e[5]),this;if(n<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" coordinates provided).");for(var r,o=[],i=0;i<n;i+=6)r=e.slice(i,i+6),o.push(Ii(Bi,r))}else{if(3===n)return this.controlPoint1=new A(e[0]),this.controlPoint2=new A(e[1]),this.end=new A(e[2]),this;if(n<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" points provided).");for(o=[],i=0;i<n;i+=3)t=e.slice(i,i+3),o.push(Ii(Bi,t))}return o}function Di(){for(var t,e=[],n=arguments.length,i=0;i<n;i++)e.push(arguments[i]);if(!(this instanceof Di))return Ii(Di,e);if(0===n)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(e[0]instanceof P){if(1===n)return this.end=e[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" lines provided).")}if(e[0]instanceof v){if(1===n)return this.end=e[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" curves provided).")}if("string"==typeof e[0]||"number"==typeof e[0]){if(2===n)return this.end=new A(+e[0],+e[1]),this;if(n<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" coordinates provided).");for(var r,o=[],i=0;i<n;i+=2)r=e.slice(i,i+2),0===i?o.push(Ii(Di,r)):o.push(Ii(Vi,r))}else{if(1===n)return this.end=new A(e[0]),this;for(o=[],i=0;i<n;i+=1)t=e[i],0===i?o.push(new Di(t)):o.push(new Vi(t))}return o}function zi(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof zi))return Ii(zi,t);if(0<e)throw new Error("Closepath constructor expects no arguments.");return this}hn={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){var e;return t<=0?0:(e=this.length(),1<=t?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(hn,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(hn,"start",{configurable:!0,enumerable:!0,get:function(){if(this.previousSegment)return this.previousSegment.end;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.)")}}),Object.defineProperty(hn,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}}),sn={clone:function(){return new Vi(this.end)},divideAt:function(t){t=new P(this.start,this.end).divideAt(t);return[new Vi(t[0]),new Vi(t[1])]},divideAtLength:function(t){t=new P(this.start,this.end).divideAtLength(t);return[new Vi(t[0]),new Vi(t[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(sn,"type",{configurable:!0,enumerable:!0,value:"L"}),Vi.prototype=Fi(hn,P.prototype,sn),n={clone:function(){return new Bi(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Bi(t[0]),new Bi(t[1])]},divideAtLength:function(t,e){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Bi(t[0]),new Bi(t[1])]},divideAtT:function(t){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Bi(t[0]),new Bi(t[1])]},isDifferentiable:function(){var t,e,n,i;return!(!this.previousSegment||(t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end,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(n,"type",{configurable:!0,enumerable:!0,value:"C"}),Bi.prototype=Fi(hn,v.prototype,n),o={bbox:function(){return null},clone:function(){return new Di(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(o,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(o,"type",{configurable:!0,enumerable:!0,value:"M"}),Di.prototype=Fi(hn,o),Ln={clone:function(){return new zi},divideAt:function(t){t=new P(this.start,this.end).divideAt(t);return[t[1].isDifferentiable()?new Vi(t[0]):this.clone(),new Vi(t[1])]},divideAtLength:function(t){t=new P(this.start,this.end).divideAtLength(t);return[t[1].isDifferentiable()?new Vi(t[0]):this.clone(),new Vi(t[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(Ln,"end",{configurable:!0,enumerable:!0,get:function(){if(this.subpathStartSegment)return this.subpathStartSegment.end;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.)")}}),Object.defineProperty(Ln,"type",{configurable:!0,enumerable:!0,value:"Z"}),zi.prototype=Fi(hn,P.prototype,Ln),Je=V.segmentTypes={L:Vi,C:Bi,M:Di,Z:zi,z:zi},V.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(Je).join("")+",.]*$"),V.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)},e={curveThroughPoints:function(t){return console.warn("deprecated"),new V(v.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=this.getFirstControlPoints(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=this.getFirstControlPoints(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new v(t,e,n,i);return function(t){t=r.divide(t);return[{p0:t[0].start,p1:t[0].controlPoint1,p2:t[0].controlPoint2,p3:t[0].end},{p0:t[1].start,p1:t[1].controlPoint1,p2:t[1].controlPoint2,p3:t[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,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);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 v(t,e,n,i);return function(t){return r.closestPointT(t)}}};let ji=function(t){return this instanceof ji?"string"==typeof t?new ji.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new ji(t)};function Gi(t,e){var n=t.start.x,i=t.start.y,r=t.end.x,t=t.end.y,o=e.start.x,s=e.start.y,r=r-n,t=t-i,a=e.end.x-o,e=e.end.y-s,n=n-o,o=i-s,i=r*e-a*t,s=(r*o-t*n)/i,r=(a*o-e*n)/i;return 0<=s&&s<=1&&0<=r&&r<=1}function Ui(t,e){var n=t.a,i=t.b,r=t.x,t=t.y,o=e.start.x-r,r=e.end.x-r,s=e.start.y-t,n=n*n,i=i*i,r=r-o,e=e.end.y-t-s,t=r*r/n+e*e/i,r=2*o*r/n+2*s*e/i,e=r*r-4*t*(o*o/n+s*s/i-1);return 0==e?0<=(o=-r/2/t)&&o<=1:0<e&&(s=(-r-(n=Math.sqrt(e)))/2/t,0<=(i=(-r+n)/2/t)&&i<=1||0<=s&&s<=1)}function Hi(L,C){{var M=0,_=0;let{cos:t,sin:e}=Math,n=e(M),i=t(M),r=e(_),o=t(_),s=n*n,a=i*i,l=n*i,h=r*r,u=o*o,c=r*o,d=L.a*L.a,f=L.b*L.b,p=C.a*C.a,g=C.b*C.b,m=d*s+f*a,v=p*h+g*u,y=d*a+f*s,b=p*u+g*h,x=2*(f-d)*l,w=2*(g-p)*c,A=-2*m*L.x-x*L.y,P=-2*v*C.x-w*C.y,E=-x*L.x-2*y*L.y,T=-w*C.x-2*b*C.y,S=m*L.x*L.x+y*L.y*L.y+x*L.x*L.y-d*f,k=v*C.x*C.x+b*C.y*C.y+w*C.x*C.y-p*g;x/=2,w/=2,A/=2,P/=2,E/=2,T/=2;var M=mr([[m,x,A],[x,y,E],[A,E,S]]),_=mr([[v,w,P],[w,b,T],[P,T,k]]),L=.33333333*(mr([[v,x,A],[w,y,E],[P,E,S]])+mr([[m,w,A],[x,b,E],[A,T,S]])+mr([[m,x,P],[x,y,T],[A,E,k]])),C=.33333333*(mr([[m,w,P],[x,b,T],[A,T,k]])+mr([[v,x,P],[w,y,T],[P,E,k]])+mr([[v,w,A],[w,b,E],[P,T,S]])),N=gr([[M,L],[L,C]]),M=gr([[M,C],[L,_]]),_=gr([[L,C],[C,_]]);return!(0<(N=gr([[2*N,M],[M,2*_]]))&&(0<C||0<L))}}function qi(t,e){var{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))||Gi(t.topLine(),e)||Gi(t.rightLine(),e)||Gi(t.bottomLine(),e)||Gi(t.leftLine(),e))}function $i(t,e){return!!Wi(t,tt.fromEllipse(e))&&Qi(ji.fromRect(t),e)}function Wi(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 Yi(t,e){return hr(t,e,{interior:!1})}function Xi(t,e){return ur(t,e,{interior:!1})}function Zi(t,e){return cr(t,e,{interior:!1})}function Ji(t,e){return fr(t,e,{interior:!1})}function Ki(t,e){return hr(t,e,{interior:!0})}function Qi(t,e){return ur(t,e,{interior:!0})}function tr(t,e){return cr(t,e,{interior:!0})}function er(t,e){return fr(t,e,{interior:!0})}function nr(t,e){return pr(t,e,{interior:!0})}function ir(t,n,i){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Ki:Yi)(e,n)})}function rr(t,n,i){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Qi:Xi)(e,n)})}function or(t,e,n){return ar(t,ji.fromRect(e),n)}function sr(t,e,n){return dr(t,e,n,{interior:!1})}function ar(t,e,n){return dr(t,e,n,{interior:!0})}function lr(t,n,i,r){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?ar:sr)(n,e,r)})}function hr(t,e,n){var{interior:n=!1}=2<arguments.length&&void 0!==n?n:{};let i;if(n){if(t.containsPoint(e.start))return!0;var{start:n,end:r,points:o}=t;i=r.equals(n)?o:[...o,n]}else i=t.points;var s=i.length,a=new P;for(let t=0;t<s-1;t++)if(a.start=i[t],a.end=i[t+1],Gi(e,a))return!0;return!1}function ur(t,e,n){var n=2<arguments.length&&void 0!==n?n:{},{start:i,end:r,points:o}=t;if(e.containsPoint(i))return!0;let s;var{interior:n=!1}=n;if(n){if(t.containsPoint(e.center()))return!0;s=r.equals(i)?o:[...o,i]}else s=o;var a=s.length,l=new P;for(let t=0;t<a-1;t++)if(l.start=s[t],l.end=s[t+1],Ui(e,l))return!0;return!1}function cr(t,e,n){return pr(t,ji.fromRect(e),n)}function dr(t,n,i,r){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?pr:fr)(n,e,r)})}function fr(t,e,n){var{interior:n=!1}=2<arguments.length&&void 0!==n?n:{};let i;if(n){n=e.start;if(t.containsPoint(n))return!0;i=t.clone().close()}else i=t;var r=e.points,o=r.length,s=new P;for(let t=0;t<o-1;t++)if(s.start=r[t],s.end=r[t+1],Yi(i,s))return!0;return!1}function pr(t,e,n){return e.containsPoint(t.start)||fr(t,e.clone().close(),n)}function gr(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function mr(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]}ji.parse=function(t){return new ji(Si(t))},ji.fromRect=function(t){return new ji([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},ji.prototype=Fi(x.prototype,{type:d.Polygon,clone:function(){return new ji(ki(this.points))},convexHull:function(){return new ji(Li(this.points))},lengthPoints:function(){var{start:t,end:e,points:n}=this;return n.length<=1||t.equals(e)?n:[...n,t.clone()]}});let vr={exists:function t(e,n,i,r){switch(e.type){case d.Line:if(n.type===d.Line)return Gi(e,n);break;case d.Ellipse:switch(n.type){case d.Line:return Ui(e,n);case d.Ellipse:return Hi(e,n)}break;case d.Rect:switch(n.type){case d.Line:return qi(e,n);case d.Ellipse:return $i(e,n);case d.Rect:return Wi(e,n)}break;case d.Polyline:switch(n.type){case d.Line:return Yi(e,n);case d.Ellipse:return Xi(e,n);case d.Rect:return Zi(e,n);case d.Polyline:return Ji(e,n)}break;case d.Polygon:switch(n.type){case d.Line:return Ki(e,n);case d.Ellipse:return Qi(e,n);case d.Rect:return tr(e,n);case d.Polyline:return er(e,n);case d.Polygon:return nr(e,n)}break;case d.Path:switch(n.type){case d.Line:return ir(e,n,i);case d.Ellipse:return rr(e,n,i);case d.Rect:return or(e,n,i);case d.Polyline:return sr(e,n,i);case d.Polygon:return ar(e,n,i);case d.Path:return lr(e,n,i,r)}}switch(n.type){case d.Ellipse:case d.Rect:case d.Polyline:case d.Polygon:case d.Path:return t(n,e,r,i);default:throw Error(`The intersection for ${e} and ${n} could not be found.`)}},lineWithLine:Gi,ellipseWithLine:Ui,ellipseWithEllipse:Hi,rectWithLine:qi,rectWithEllipse:$i,rectWithRect:Wi,polylineWithLine:Yi,polylineWithEllipse:Xi,polylineWithRect:Zi,polylineWithPolyline:Ji,polygonWithLine:Ki,polygonWithEllipse:Qi,polygonWithRect:tr,polygonWithPolyline:er,polygonWithPolygon:nr,pathWithLine:ir,pathWithEllipse:rr,pathWithRect:or,pathWithPolyline:sr,pathWithPolygon:ar,pathWithPath:lr},yr=vr;var br={intersection:yr,scale:{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}},normalizeAngle:Xn,snapToGrid:Zn,toDeg:Hn,toRad:Jn,random:qn,bezier:e,Curve:v,Ellipse:yi,ellipse:l,Line:P,line:pi,Path:V,Point:A,point:ci,Polyline:x,Polygon:ji,Rect:tt,rect:h,types:d};let xr="[object Arguments]",wr="[object Array]",Ar="[object Boolean]",Pr="[object Date]",Er="[object Error]";let Tr="[object Map]",Sr="[object Number]",kr="[object Null]",Lr="[object Object]",Cr="[object RegExp]",Mr="[object Set]",_r="[object String]",Nr="[object Symbol]",Or="[object Undefined]";let Rr="[object ArrayBuffer]",Fr="[object DataView]",Ir="[object Float32Array]",Vr="[object Float64Array]",Br="[object Int8Array]",Dr="[object Int16Array]",zr="[object Int32Array]",jr="[object Uint8Array]",Gr="[object Uint8ClampedArray]",Ur="[object Uint16Array]",Hr="[object Uint32Array]",qr={[xr]:!0,[wr]:!0,[Rr]:!0,[Fr]:!0,[Ar]:!0,[Pr]:!0,[Ir]:!0,[Vr]:!0,[Br]:!0,[Dr]:!0,[zr]:!0,[Tr]:!0,[Sr]:!0,[Lr]:!0,[Cr]:!0,[Mr]:!0,[_r]:!0,[Nr]:!0,[jr]:!0,[Gr]:!0,[Ur]:!0,[Hr]:!0,[Er]:!1,"[object Function]":!1,"[object WeakMap]":!1};r="\\ud800-\\udfff",u="\\u2700-\\u27bf",i="a-z\\xdf-\\xf6\\xf8-\\xff",s="A-Z\\xc0-\\xd6\\xd8-\\xde",$e="\\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",c=`[${$e}]`,a="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",sn=`[${u}]`,n=`[${i}]`,o=`[^${r}${$e+"\\d"+u+i+s}]`,hn="\\ud83c[\\udffb-\\udfff]",Ln=`[^${r}]`,Je="(?:\\ud83c[\\udde6-\\uddff]){2}",e="[\\ud800-\\udbff][\\udc00-\\udfff]",l=`[${s}]`,h=`(?:${n}|${o})`,$e=`(?:${l}|${o})`,u="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",i="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",s="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",o="[\\ufe0e\\ufe0f]?",o=o+s+`(?:\\u200d(?:${[Ln,Je,e].join("|")})${o+s})*`,s=`(?:${[sn,Je,e].join("|")})`+o;let $r=RegExp([`${l}?${n}+${u}(?=${[c,l,"$"].join("|")})`,$e+`+${i}(?=${[c,l+h,"$"].join("|")})`,l+`?${h}+`+u,l+"+"+i,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",s].join("|"),"g"),Wr=200,Yr="__hash_undefined__",Xr=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;var Zr,sn=`(?:${[Ln+a+"?",a,Je,e,`[${r}]`].join("|")})`;let Jr=RegExp(hn+`(?=${hn})|`+sn+o,"g"),Kr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qr=/^\w*$/,to=".".charCodeAt(0),eo=/\\(\\)?/g,no=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),io=/^(?:0|[1-9]\d*)$/,ro=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 ]/),oo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,so=t=>Jr.test(t),ao=t=>t.match(Jr)||[],lo=t=>t.split(""),ho=t=>(so(t)?ao:lo)(t),uo=e=>null==e?[]:co(e).map(t=>e[t]),co=t=>Po(t)?fo(t):Object.keys(Object(t)),fo=(t,e)=>{var n,i=Array.isArray(t),r=!i&&mo(t)&&ko(t)===xr,o=!i&&!r&&Fo(t),s=i||r||o,a=t.length,l=new Array(s?a:0);let h=s?-1:a;for(;++h<a;)l[h]=""+h;for(n in t)!e&&!hasOwnProperty.call(t,n)||s&&("length"===n||as(n,a))||l.push(n);return l},po=(t,e)=>{let n=t.length;for(;n--;)if(go(t[n][0],e))return n;return-1},go=(t,e)=>t===e||t!=t&&e!=e,mo=t=>null!=t&&"object"==typeof t,vo=(t,e,n)=>{var i;return!!w(n)&&!!("number"==(i=typeof e)?Po(n)&&-1<e&&e<n.length:"string"==i&&e in n)&&go(n[e],t)},yo=t=>mo(t)&&ko(t)==Mr,bo=t=>mo(t)&&ko(t)==Tr,xo=t=>{var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},wo=(t,e,n)=>{var i=t[e];hasOwnProperty.call(t,e)&&go(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Ao=(t,e,n)=>{let i=-1;for(var r=e.length;++i<r;){var o=e[i];wo(n,o,t[o])}return n},Po=t=>null!=t&&"function"!=typeof t&&"number"==typeof t.length&&-1<t.length&&t.length%1==0,Eo=t=>"symbol"==typeof t||mo(t)&&ko(t)===Nr,To=t=>{var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&hasOwnProperty.call(t,"index")&&(n.index=t.index,n.input=t.input),n},So=(t,e)=>{let n=-1;var i=t.length;for(e=e||new Array(i);++n<i;)e[n]=t[n];return e},ko=t=>null==t?void 0===t?Or:kr:Object.prototype.toString.call(t),Lo=t=>{var e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},Co=(t,e)=>{e=e?Lo(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)},Mo=t=>{var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},_o=t=>"function"!=typeof t.constructor||xo(t)?{}:Object.create(Object.getPrototypeOf(t)),No=e=>null==e?[]:(e=Object(e),Object.getOwnPropertySymbols(e).filter(t=>propertyIsEnumerable.call(e,t))),Oo=(t,e)=>Ao(t,No(t),e);let Ro=(t,e,n)=>{var i,r,o=t.constructor;switch(e){case Rr:return Lo(t,n);case Ar:case Pr:return new o(+t);case Fr:return i=t,r=(r=n)?Lo(i.buffer):i.buffer,new i.constructor(r,i.byteOffset,i.byteLength);case Ir:case Vr:case Br:case Dr:case zr:case jr:case Gr:case Ur:case Hr:return Co(t,n);case Tr:return new o(t);case Sr:case _r:return new o(t);case Cr:return Mo(t);case Mr:return new o;case Nr:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}},Fo=t=>mo(t)&&Xr.test(ko(t)),Io=t=>{var e=Object.keys(t);return Array.isArray(t)||null==t||e.push(...No(Object(t))),e},Vo=t=>{for(var e=[];t;)e.push(...No(t)),t=Object.getPrototypeOf(Object(t));return e},Bo=t=>{var e,n=[];for(e in t)n.push(e);return Array.isArray(t)||n.push(...Vo(t)),n},Do=(t,e)=>{t=t.__data__;return(t=>{const e=typeof t;return e==="string"||e==="number"||e==="symbol"||e==="boolean"?t!=="__proto__":t===null})(e)?t["string"==typeof e?"string":"hash"]:t.map},zo=(t,e,n,i)=>{var r=Io(t),o=r.length;if(o!=Io(e).length)return!1;let s,a=o;for(;a--;)if(s=r[a],!hasOwnProperty.call(e,s))return!1;var l=i.get(t),h=i.get(e);if(l&&h)return l==e&&h==t;let u=!0;i.set(t,e),i.set(e,t);let c;for(;++a<o;){var d=t[s=r[a]],f=e[s];if(d!==f&&!n(d,f,i)){u=!1;break}c=c||"constructor"==s}return u&&!c&&(l=t.constructor)!=(h=e.constructor)&&"constructor"in t&&"constructor"in e&&!("function"==typeof l&&l instanceof l&&"function"==typeof h&&h instanceof h)&&(u=!1),i.delete(t),i.delete(e),u},jo=(t,e,n)=>t===e||(null==t||null==e||!mo(t)&&!mo(e)?t!=t&&e!=e:Go(t,e,jo,n)),Go=(t,e,n,i)=>{var r=Array.isArray(t),o=Array.isArray(e),s=r?wr:ko(t),o=o?wr:ko(e),s=s==xr?Lr:s,o=o==xr?Lr:o,a=s==Lr,l=o==Lr,o=s==o;return o&&!a?(i=i||new Ds,r||Fo(t)?Uo(t,e,!1,n,i):Wo(t,e,s,n,i)):(r=a&&hasOwnProperty.call(t,"__wrapped__"),s=l&&hasOwnProperty.call(e,"__wrapped__"),r||s?n(r?t.value():t,s?e.value():e,i=i||new Ds):o&&(i=i||new Ds,zo(t,e,n,i)))},Uo=(t,e,n,i,r)=>{var o=t.length,s=e.length;if(o!=s)return!1;var s=r.get(t),a=r.get(e);if(s&&a)return s==e&&a==t;let l=-1,h=!0,u=n?new Us:void 0;for(r.set(t,e),r.set(e,t);++l<o;){let n=t[l];var c=e[l];if(u){if(!Ho(e,(t,e)=>{if(!qo(u,e)&&(n===t||i(n,t,r)))return u.push(e)})){h=!1;break}}else if(n!==c&&!i(n,c,r)){h=!1;break}}return r.delete(t),r.delete(e),h},Ho=(t,e)=>{let n=-1;for(var i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1},qo=(t,e)=>t.has(e),$o=(t,e,n,i)=>!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i)),Wo=(t,e,n,i,r)=>{switch(n){case Fr:return t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset?!1:(t=t.buffer,e=e.buffer,$o(t,e,i,r));case Rr:return $o(t,e,i,r);case Ar:case Pr:case Sr:return go(+t,+e);case Er:return t.name==e.name&&t.message==e.message;case Cr:case _r:return t==""+e;case Tr:var o=Yo;case Mr:if(o=o||Xo,t.size!=e.size)return!1;var s=r.get(t);if(s)return s==e;r.set(t,e);s=Uo(o(t),o(e),!0,i,r);return r.delete(t),s;case Nr:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},Yo=t=>{let n=-1,i=Array(t.size);return t.forEach((t,e)=>{i[++n]=[e,t]}),i},Xo=t=>{let e=-1,n=new Array(t.size);return t.forEach(t=>{n[++e]=t}),n},Zo=(t,e)=>{var n;return!Array.isArray(t)&&(!("number"!=(n=typeof t)&&"boolean"!=n&&null!=t&&!Eo(t))||Qr.test(t)||!Kr.test(t)||null!=e&&t in Object(e))},Jo=t=>{let o=[];return t.charCodeAt(0)===to&&o.push(""),t.replace(no,(t,e,n,i)=>{let r=t;n?r=i.replace(eo,"$1"):e&&(r=e.trim()),o.push(r)}),o},Ko=(t,e)=>Array.isArray(t)?t:Zo(t,e)?[t]:Jo(""+t),Qo=(t,e)=>{let n=0;for(var i=(e=Ko(e,t)).length;null!=t&&n<i;)t=t[ns(e[n])],n++;return n&&n==i?t:void 0};function ts(t,e){if(t!==e){var n=void 0!==t,i=null===t,r=t==t,o=Eo(t),s=void 0!==e,a=null===e,l=e==e,h=Eo(e);if(!a&&!h&&!o&&e<t||o&&s&&l&&!a&&!h||i&&s&&l||!n&&l||!r)return 1;if(!i&&!o&&!h&&t<e||h&&n&&r&&!i&&!o||a&&n&&r||!s&&r||!l)return-1}return 0}let es=(t,e)=>{let n=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),i=!0;var r=[],o=e.length;if(t.length){e.length>=Wr&&(n=(t,e)=>t.has(e),i=!1,e=new Us(e));t:for(var s in t){var a=s=t[s],s=0!==s?s:0;if(i&&a==a){let t=o;for(;t--;)if(e[t]===a)continue t;r.push(s)}else n(e,a)||r.push(s)}}return r},ns=t=>{var e;return"string"==typeof t||Eo(t)?t:"0"==(e=""+t)&&1/t==-1/0?"-0":e},is=function(i){let r=1<arguments.length&&void 0!==arguments[1]&&arguments[1],o=2<arguments.length&&void 0!==arguments[2]&&arguments[2],s=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],a=4<arguments.length?arguments[4]:void 0;var t=5<arguments.length?arguments[5]:void 0,e=6<arguments.length?arguments[6]:void 0;let l=7<arguments.length?arguments[7]:void 0,h;if(void 0===(h=a?e?a(i,t,e,l):a(i):h)){if(!w(i))return i;var t=Array.isArray(i),n=ko(i);if(t){if(h=To(i),!r)return So(i,h)}else{var u="function"==typeof i;if(n===Lr||n===xr||u&&!e){if(h=o||u?{}:_o(i),!r)return o?rs(i,Ao(i,Object.keys(i),h)):Oo(i,Object.assign(h,i))}else{if(u||!qr[n])return e?i:{};h=Ro(i,n,r)}}u=(l=l||new Ds).get(i);if(u)return u;if(l.set(i,h),bo(i))i.forEach((t,e)=>{h.set(e,is(t,r,o,s,a,e,i,l))});else if(yo(i))i.forEach(t=>{h.add(is(t,r,o,s,a,t,i,l))});else if(!Fo(i)){e=s?o?Bo:Io:o?ls:co;let n=t?void 0:e(i);(n||i).forEach((t,e)=>{n&&(t=i[e=t]),wo(h,e,is(t,r,o,s,a,e,i,l))})}}return h},rs=(t,e)=>Ao(t,Vo(t),e),os=(t,e)=>e.length<2?t:Qo(t,e.slice(0,-1)),ss=(t,i,r)=>{if(w(t)){var o=(i=Ko(i,t)).length,s=o-1;let e=-1,n=t;for(;null!=n&&++e<o;){var a,l=ns(i[e]);let t=r;e!=s&&(a=n[l],(t=void 0)===t)&&(t=w(a)?a:as(i[e+1])?[]:{}),wo(n,l,t),n=n[l]}}return t},as=(t,e)=>{var n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"==n||"symbol"!=n&&io.test(t))&&-1<t&&t%1==0&&t<e},ls=t=>{var e,n=[];for(e in t)n.push(e);return n},hs=t=>{var e,n={};for(e in t=Object(t))n[e]=t[e];return n},us=(t,e)=>{if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function cs(s,t){let a=1<arguments.length&&void 0!==t&&t;return function(t){let e=-1,n=arguments.length<=1?0:arguments.length-1,i=!(1<n)||n-1+1<1||arguments.length<=n-1+1?void 0:arguments[n-1+1];var r=!(2<n)||arguments.length<=3?void 0:arguments[3];for(i=3<s.length&&"function"==typeof i?(n--,i):a?(t,e)=>{if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,r&&vo(arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],r)&&(i=n<3?void 0:i,n=1),t=Object(t);++e<n;){var o=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];o&&s(t,o,e,i)}return t}}let ds=(i,r,t,o,s)=>{i!==r&&pa(r,(e,n)=>{if(w(e))s=s||new Ds,fs(i,r,n,t,ds,o,s);else{let t=o?o(i[n],e,""+n,i,r,s):void 0;void 0===t&&(t=e),ps(i,n,t)}},ls)},fs=(n,i,r,o,s,a,l)=>{var h=us(n,r),u=us(i,r),c=l.get(u);if(c)ps(n,r,c);else{let t=a?a(h,u,""+r,n,i,l):void 0,e=void 0===t;e&&(i=!(c=Array.isArray(u))&&Fo(u),t=u,c||i?t=Array.isArray(h)?h:mo(h)&&Po(h)?So(h):i?(e=!1,Co(u,!0)):[]:y(u)||Ms(u)?(t=h,Ms(h)?t=hs(h):"function"!=typeof h&&w(h)||(t=_o(u))):e=!1),e&&(l.set(u,t),s(t,u,o,a,l),l.delete(u)),ps(n,r,t)}},ps=(t,e,n)=>{(void 0===n||go(t[e],n))&&(void 0!==n||e in t)||wo(t,e,n)};let gs=(t,e)=>t&&((t,e,n)=>{var i=Object(t),r=n(t);let o=r.length,s=-1;for(;o--;){var a=r[++s];if(!1===e(i[a],a,i))break}return t})(t,e,co),ms=(e,n)=>{if(null!=e){if(!Po(e))return gs(e,n);var i=e.length,r=Object(e);let t=-1;for(;++t<i&&!1!==n(r[t],t,r););}return e};let vs=Set&&1/Xo(new Set([void 0,-0]))[1]==1/0?t=>new Set(t):()=>{};function ys(t,e,n,i,r,o){return w(t)&&w(e)&&(o.set(e,t),ds(t,e,void 0,ys,o),o.delete(e)),t}function bs(e,n,u){n=n.length?n.map(e=>Array.isArray(e)?t=>Qo(t,1===e.length?e[0]:e):e):[t=>t];let i=-1,r=-1,o=Po(e)?new Array(e.length):[];ms(e,e=>{var t=n.map(t=>t(e));o[++r]={criteria:t,index:++i,value:e}});{var s=o;e=(e,n)=>{{var i=u;let t=-1;for(var r=e.criteria,o=n.criteria,s=r.length,a=i.length;++t<s;){var l=t<a?i[t]:null,h=(l&&"function"==typeof l?l:ts)(r[t],o[t]);if(h)return l&&"function"!=typeof l?h*("desc"==l?-1:1):h}return e.index-n.index}};let t=s.length;for(s.sort(e);t--;)s[t]=s[t].value;return s}}function xs(t){return t==t&&!w(t)}function ws(e,n){return t=>null!=t&&t[e]===n&&(void 0!==n||e in Object(t))}function As(t,e){return null!=t&&Rs(t,e,Os)}function Ps(e){let n=(t=>{let e=co(t),n=e.length;for(;n--;){var i=e[n],r=t[i];e[n]=[i,r,xs(r)]}return e})(e);return 1===n.length&&n[0][2]?ws(n[0][0],n[0][1]):t=>t===e||((t,e,n,i)=>{let r=n.length,o=r,s=!i;if(null==t)return!o;let a,l;for(t=Object(t);r--;)if(a=n[r],s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1;for(;++r<o;){var h=(a=n[r])[0],u=t[h],c=a[1];if(s&&a[2]){if(void 0===u&&!(h in t))return!1}else{var d=new Ds;if(!(void 0===(l=i?i(u,c,h,t,e,d):l)?jo(c,u,d):l))return!1}}return!0})(t,e,n)}function Es(t){return Zo(t)?(n=ns(t),t=>null==t?void 0:t[n]):(e=t,t=>Qo(t,e));var e,n}function Ts(t){var n,i;return"function"==typeof t?t:null==t?t=>t:"object"==typeof t?Array.isArray(t)?(n=t[0],i=t[1],Zo(n)&&xs(i)?ws(ns(n),i):t=>{var e=Qo(t,n);return void 0===e&&e===i?As(t,n):jo(i,e)}):Ps(t):Es(t)}function Ss(t,e){var n=Ts;return arguments.length?n(t,e):n}let ks=(t,e,n,i)=>{let r=-1;var o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},Ls=(t,i,r,o,e)=>(e(t,(t,e,n)=>{r=o?(o=!1,t):i(r,t,e,n)}),r);let Cs=t=>Array.isArray(t)||Ms(t)||!(!t||!t[Symbol.isConcatSpreadable]);let Ms=t=>mo(t)&&"[object Arguments]"==ko(t),_s=(t,e,n)=>{let i=-1;for(var r=e.length,o={};++i<r;){var s=e[i],a=Qo(t,s);n(a,s)&&ss(o,Ko(s,t),a)}return o},Ns=t=>"number"==typeof t&&-1<t&&t%1==0&&t<=Number.MAX_SAFE_INTEGER,Os=(t,e)=>null!=t&&e in Object(t),Rs=(t,e,n)=>{for(var i=-1,r=(e=Ko(e,t)).length,o=!1;++i<r;){var s=ns(e[i]);if(!(o=null!=t&&n(t,s)))break;t=t[s]}return o||++i!=r?o:!!(r=null==t?0:t.length)&&Ns(r)&&as(s,r)&&(Array.isArray(t)||Ms(t))},Fs=t=>t.match(oo),Is=t=>t.match($r),Vs=(t,e)=>void 0===e?(ro(t)?Is:Fs)(t)||[]:t.match(e)||[],Bs=(Zr="toUpperCase",t=>{var e,n,i,r,o;return t?(e=((n=so(t)?ho(t):void 0)||t)[0],o=n?(i=1,o=(n=n).length,r=void 0===r?o:r,(!i&&o<=r?n:n.slice(i,r)).join("")):t.slice(1),e[Zr]()+o):""});class Ds{constructor(t){t=this.__data__=new zs(t);this.size=t.size}clear(){this.__data__=new zs,this.size=0}delete(t){var e=this.__data__,t=e.delete(t);return this.size=e.size,t}get(t){return this.__data__.get(t)}has(t){return this.__data__.has(t)}set(t,e){let n=this.__data__;if(n instanceof zs){var i=n.__data__;if(i.length<Wr-1)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new js(i)}return n.set(t,e),this.size=n.size,this}}class zs{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.__data__=[],this.size=0}delete(t){var e=this.__data__,t=po(e,t);return!(t<0||(t==e.length-1?e.pop():e.splice(t,1),--this.size,0))}get(t){var e=this.__data__,t=po(e,t);return t<0?void 0:e[t][1]}has(t){return-1<po(this.__data__,t)}set(t,e){var n=this.__data__,i=po(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}}class js{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.size=0,this.__data__={hash:new Gs,map:new Map,string:new Gs}}delete(t){t=Do(this,t).delete(t);return this.size-=t?1:0,t}get(t){return Do(this,t).get(t)}has(t){return Do(this,t).has(t)}set(t,e){var n=Do(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}}class Gs{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.__data__=Object.create(null),this.size=0}delete(t){t=this.has(t)&&delete this.__data__[t];return this.size-=t?1:0,t}get(t){t=this.__data__[t];return t===Yr?void 0:t}has(t){return void 0!==this.__data__[t]}set(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?Yr:e,this}}class Us{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.__data__=new js;++e<n;)this.add(t[e])}add(t){return this.__data__.set(t,Yr),this}has(t){return this.__data__.has(t)}}Us.prototype.push=Us.prototype.add;function Hs(t){var e=Object.prototype.toString;return!0===t||!1===t||!!t&&"object"==typeof t&&e.call(t)===Ar}function qs(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Sr}let w=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},E=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===_r},T=cs((t,e)=>{if(xo(e)||Po(e))Ao(e,co(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&wo(t,n,e[n])});function $s(e){let t=-1,n=arguments.length<=1?0:arguments.length-1;var i=!(2<n)||arguments.length<=3?void 0:arguments[3];for(i&&vo(arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],i)&&(n=1);++t<n;){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];if(null!=r){var o=Object.keys(r),s=o.length;let t=-1;for(;++t<s;){var a=o[t],l=e[a];(void 0===l||go(l,Object.prototype[a])&&!hasOwnProperty.call(e,a))&&(e[a]=r[a])}}}return e}n=T,$e=n;let Ws=$s;function Ys(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.push(void 0,ys),k.apply(void 0,e)}function Xs(t,e){for(var n=arguments.length,i=new Array(2<n?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];let o=-1,s="function"==typeof e,a=Po(t)?new Array(t.length):[];return ms(t,t=>{a[++o]=s?e.apply(t,i):Zs(t,e,...i)}),a}function Zs(t,e){e=Ko(e,t);for(var n,e=null==(t=os(t,e))?t:t[ns((n=null==(e=e)?0:e.length)?e[n-1]:void 0)],i=arguments.length,r=new Array(2<i?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return null==e?void 0:e.apply(t,r)}let Js=Ys,Ks=(e,n,i)=>{let r=0,o=null==e?0:e.length;if(0==o)return 0;for(var s=(n=(i=Ss(i,2))(n))!=n,a=null===n,l=Eo(n),h=void 0===n;r<o;){let t;var u=Math.floor((r+o)/2),c=i(e[u]),d=void 0!==c,f=null===c,p=c==c,g=Eo(c);(t=s?p:h?p&&d:a?p&&d&&!f:l?p&&d&&!f&&!g:!f&&!g&&c<n)?r=u+1:o=u}return Math.min(o,4294967294)},Qs=(t,e)=>{let n=-1,i=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),r=(e=Ss(e,2),!0);var o=t.length,s=[];let a=s;if(o>=Wr){var l=e?null:vs(t);if(l)return Xo(l);r=!1,i=(t,e)=>t.has(e),a=new Us}else a=e?[]:s;t:for(;++n<o;){var h=t[n],u=e?e(h):h,h=0!==h?h:0;if(r&&u==u){let t=a.length;for(;t--;)if(a[t]===u)continue t;e&&a.push(u),s.push(h)}else i(a,u)||(a!==s&&a.push(u),s.push(h))}return s},f=t=>is(t),ta=t=>is(t,!0),ea=t=>{if(null!=t){if(Po(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||Fo(t)||Ms(t)))return!t.length;var e,n=ko(t);if("[object Map]"==n||"[object Set]"==n)return!t.size;if(xo(t))return!(t=>{if(!xo(t))return Object.keys(t);var e,n=[];for(e in Object(t))hasOwnProperty.call(t,e)&&"constructor"!=e&&n.push(e);return n})(t).length;for(e in t)if(hasOwnProperty.call(t,e))return!1}return!0},na=(t,e)=>jo(t,e),b=t=>"function"==typeof t,y=t=>{if(!mo(t)||"[object Object]"!=ko(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},et=t=>{if(!t)return[];if(Po(t))return(E(t)?ho:So)(t);if(Symbol.iterator&&Symbol.iterator in Object(t)){for(var e,n=t[Symbol.iterator](),i=[];!(e=n.next()).done;)i.push(e.value);return i}var r=ko(t);return(r==Tr?Yo:r==Mr?Xo:uo)(t)};function ia(i,o,t){if("function"!=typeof i)throw new TypeError("Expected a function");let s,a,n,l,h,u,c=0,d=!1,f=!1,e=!0,r=!o&&0!==o&&window&&"function"==typeof window.requestAnimationFrame;function p(t){var e=s,n=a;return s=a=void 0,c=t,l=i.apply(n,e)}function g(t,e){return r?(window.cancelAnimationFrame(h),window.requestAnimationFrame(t)):setTimeout(t,e)}function m(t){var e=t-u,t=t-c;return void 0===u||o<=e||e<0||f&&t>=n}function v(){var t,e=Date.now();if(m(e))return y(e);h=g(v,(t=(e=e)-u,e-=c,t=o-t,f?Math.min(t,n-e):t))}function y(t){return h=void 0,e&&s?p(t):(s=a=void 0,l)}function b(){for(var t=Date.now(),e=m(t),n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];if(s=i,a=this,u=t,e){if(void 0===h)return t=u,c=t,h=g(v,o),d?p(t):l;if(f)return h=g(v,o),p(u)}return void 0===h&&(h=g(v,o)),l}return o=+o||0,w(t)&&(d=!!t.leading,f="maxWait"in t,n=f?Math.max(+t.maxWait||0,o):n,e="trailing"in t?!!t.trailing:e),b.cancel=()=>{void 0!==h&&(t=>{if(r)return window.cancelAnimationFrame(t);clearTimeout(t)})(h),c=0,s=u=a=h=void 0},b.flush=()=>void 0===h?l:y(Date.now()),b.pending=()=>void 0!==h,b}function ra(t){let e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];var n;return null==t?[]:(1<(n=e.length)&&vo(t,e[0],e[1])?e=[]:2<n&&vo(e[0],e[1],e[2])&&(e=[e[0]]),bs(t,(e=Array.isArray(e)?e:[Ss(e,2)]).flat(1),[]))}function oa(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Po(t)?es(t,n):[]}let sa=(t,i)=>(i=Ss(i,2),function(t,e,n){return(Array.isArray(t)?ks:Ls)(t,e,n,arguments.length<3,ms)}(t,(t,e,n)=>(n=i(e),hasOwnProperty.call(t,n)?t[n].push(e):wo(t,n,[e]),t),{})),aa=t=>(null==t?0:t.length)?function t(e,n,i,r,o){let s=-1;var a=e.length;for(i=i||Cs,o=o||[];++s<a;){var l=e[s];0<n&&i(l)?1<n?t(l,n-1,i,r,o):o.push(...l):r||(o[o.length]=l)}return o}(t,1/0):[],la=function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return mo(t)&&Po(t)?es(t,n.flat(1)):[]};function ha(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.flat(1);return Qs(i)}function ua(n){for(var t=arguments.length,i=new Array(1<t?t-1:0),e=1;e<t;e++)i[e-1]=arguments[e];let r={};if(null!=n){let e=!1,t=(i=i.flat(1).map(t=>(t=Ko(t,n),e=e||1<t.length,t)),Ao(n,Bo(n),r),e&&(r=is(r,!0,!0,!0,t=>y(t)?void 0:t)),i.length);for(;t--;){s=o=void 0;var o=r,s=i[t];s=Ko(s,o),o=os(o,s),s=s[s.length-1],null!=o&&delete o[ns(s)]}}return r}function ca(t){for(var n,e=arguments.length,i=new Array(1<e?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];return null==t?{}:(n=t,t=i.flat(1/0),_s(n,t,(t,e)=>As(n,e)))}let da=(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},S=(e,n,i)=>{let r=-1,o=(n=Ko(n,e)).length;for(o||(o=1,e=void 0);++r<o;){let t=null==e?void 0:e[ns(n[r])];void 0===t&&(r=o,t=i),e="function"==typeof t?t.call(e):t}return e};function fa(){return""+(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"")+ ++ma}let pa=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t=>t;let n=-1;var i=Object(t),r=Po(t)?fo(t,!0):ls(t);let o=r.length;for(;o--;){var s=r[++n];if(!1===e(i[s],s,i))break}},ga=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return Vs((""+t).replace(/['\u2019]/g,"")).reduce((t,e,n)=>(e=e.toLowerCase(),t+(n?Bs(e):e)),"")},ma=0,k=cs((t,e,n,i)=>{ds(t,e,n,i)},!0);class va{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 t=this.map.get(t),void 0===e?t:t[e]}set(t,e,n){void 0!==e&&(t=this.create(t),"string"==typeof e?t[e]=n:Object.assign(t,e))}remove(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])}}function ya(t,e){if(!(this instanceof ya))return new ya(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?wa:Aa,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}let ba=new va,xa=new va;function wa(){return!0}function Aa(){return!1}ya.prototype={constructor:ya,isDefaultPrevented:Aa,isPropagationStopped:Aa,isImmediatePropagationStopped:Aa,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=wa,t&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=wa,t&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=wa,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=>{var e;e=t,Object.defineProperty(ya.prototype,e,{enumerable:!0,configurable:!0,get:function(){return this.originalEvent?this.originalEvent[e]:void 0},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})});let Pa="undefined"!=typeof window?window.document:null,Ea=Pa&&Pa.documentElement,Ta=/^([^.]*)(?:\.(.+)|)/,Sa=/[^\x20\t\r\n\f]+/g,L=function(t){return new L.Dom(t)},ka=(L.fn=L.prototype={constructor:L,length:0},L.guid=1,L.data=xa,L.merge=function(e,n){var i=+n.length;let r=e.length;for(let t=0;t<i;t++)e[r++]=n[t];return e.length=r,e},L.parseHTML=function(t){var e=Pa.implementation.createHTMLDocument(),n=e.createElement("base"),i=(n.href=Pa.location.href,e.head.appendChild(n),e.body.innerHTML=t,e.getElementsByTagName("script"));for(let t=0;t<i.length;t++)i[t].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&(L.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),L.fn.toArray=function(){return Array.from(this)},L.fn.pushStack=function(t){t=L.merge(this.constructor(),t);return t.prevObject=this,t},L.fn.find=function(t){var e,[n]=this,i=this.pushStack([]);return n&&(e=n.nodeType,1!==e&&9!==e&&11!==e||("string"!=typeof t?n!==t&&n.contains(t)&&L.merge(i,[t]):L.merge(i,n.querySelectorAll(t)))),i},L.fn.add=function(t,e){var t=L(t,e).toArray(),e=this.toArray(),n=this.pushStack([]);return L.merge(n,Qs(e.concat(t))),n},L.fn.addBack=function(){return this.add(this.prevObject)},L.fn.filter=function(e){var n=[];for(let t=0;t<this.length;t++){var i=this[t];i.matches(e)&&n.push(i)}return this.pushStack(n)},/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/);function La(e){if(e){if("function"==typeof e)throw new Error("function not supported");if(1<arguments.length)throw new Error("selector with context not supported");if(e.nodeType)this[0]=e,this.length=1;else{let t;if("<"===(n=e+"")[0]&&">"===n[n.length-1]&&3<=n.length)t=[null,e,null];else{if("string"!=typeof e)return L.merge(this,e);t=ka.exec(e)}var n;if(!t||!t[1])return Ca.find(e);t[1]?L.merge(this,L.parseHTML(t[1])):(n=Pa.getElementById(t[2]))&&(this[0]=n,this.length=1)}}return this}(L.Dom=La).prototype=L.fn,L.Event=ya,L.event={special:Object.create(null)},L.event.has=function(t,e){t=ba.get(t,"events");return!!t&&(!e||Array.isArray(t[e])&&0<t[e].length)},L.event.on=function(e,n,i,r,o,t){if("object"==typeof n){for(var s in"string"!=typeof i&&(r=r||i,i=void 0),n)L.event.on(e,s,i,r,n[s],t);return e}if(null==r&&null==o?(o=i,r=i=void 0):null==o&&("string"==typeof i?(o=r,r=void 0):(o=r,r=i,i=void 0)),!o)return e;if(1===t){let e=o;(o=function(t){return L().off(t),e.apply(this,arguments)}).guid=e.guid||(e.guid=L.guid++)}for(let t=0;t<e.length;t++)L.event.add(e[t],n,o,r,i)},L.event.add=function(r,o,s,a,l){if("object"==typeof r){var h=ba.create(r);let e;s.handler&&(s=(e=s).handler,l=e.selector),l&&Ea.matches(l),s.guid||(s.guid=L.guid++);let n;n=(n=h.events)||(h.events=Object.create(null));let i;i=(i=h.handle)||(h.handle=function(t){return void 0!==L?L.event.dispatch.apply(r,arguments):void 0});var u=(o||"").match(Sa)||[""];let t=u.length;for(;t--;){var[,c,d=""]=Ta.exec(u[t]);if(c){var d=d.split(".").sort(),f=(p=L.event.special[c])&&(l?p.delegateType:p.bindType)||c,p=L.event.special[f],c=Object.assign({type:f,origType:c,data:a,handler:s,guid:s.guid,selector:l,namespace:d.join(".")},e);let t;(t=n[f])||((t=n[f]=[]).delegateCount=0,p&&p.setup&&!1!==p.setup.call(r,a,d,i))||r.addEventListener&&r.addEventListener(f,i),p&&p.add&&(p.add.call(r,c),c.handler.guid||(c.handler.guid=s.guid)),l?t.splice(t.delegateCount++,0,c):t.push(c)}}}},L.event.remove=function(e,n,i,r,o){var s=ba.get(e);if(s&&s.events){var a=s.events,l=(n||"").match(Sa)||[""];let t=l.length;for(;t--;){var[,h,u=""]=Ta.exec(l[t]);if(h){var c=L.event.special[h],d=c&&(r?c.delegateType:c.bindType)||h,f=a[d];if(f&&0!==f.length){var p=u.split(".").sort(),g=u?new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,u=f.length;let t=u;for(;t--;){var m=f[t];!o&&h!==m.origType||i&&i.guid!==m.guid||g&&!g.test(m.namespace)||r&&r!==m.selector&&("**"!==r||!m.selector)||(f.splice(t,1),m.selector&&f.delegateCount--,c&&c.remove&&c.remove.call(e,m))}u&&0===f.length&&(c&&c.teardown&&!1!==c.teardown.call(e,p,s.handle)||e.removeEventListener&&e.removeEventListener(d,s.handle),delete a[d])}}else for(var v in a)L.event.remove(e,v+l[t],i,r,!0)}ea(a)&&(ba.remove(e,"handle"),ba.remove(e,"events"))}},L.event.dispatch=function(e){var n=L.event.fix(e),i=(n.delegateTarget=this,Array.from(arguments)),e=(i[0]=n,ba.get(this,"events")),e=e&&e[n.type]||[],r=L.event.special[n.type];if(!r||!r.preDispatch||!1!==r.preDispatch.call(this,n)){var o,s,a=L.event.handlers.call(this,n,e);let t=0;for(;(o=a[t++])&&!n.isPropagationStopped();){n.currentTarget=o.elem;let t=0;for(;(s=o.handlers[t++])&&!n.isImmediatePropagationStopped();){n.handleObj=s,n.data=s.data;var l=L.event.special[s.origType];let t;l=(t=l&&l.handle?l.handle:s.handler).apply(o.elem,i);void 0!==l&&!1===(n.result=l)&&(n.preventDefault(),n.stopPropagation())}}return r&&r.postDispatch&&r.postDispatch.call(this,n),n.result}},L.event.handlers=function(t,n){var i=n.delegateCount,r=[];if(i&&!("click"===t.type&&1<=t.button))for(let e=t.target;e!==this;e=e.parentNode||this)if(1===e.nodeType&&("click"!==t.type||!0!==e.disabled)){var o=[],s={};for(let t=0;t<i;t++){var a=n[t],l=a.selector+" ";void 0===s[l]&&(s[l]=e.matches(l)),s[l]&&o.push(a)}o.length&&r.push({elem:e,handlers:o})}return i<n.length&&r.push({elem:this,handlers:n.slice(i)}),r},L.event.fix=function(t){return t.envelope?t:new ya(t)};let Ca=L(Pa),R=(()=>{if(!("object"==typeof window&&!!window.SVGAngle))return function(){throw new Error("SVG is required to use Vectorizer.")};function N(t,e,n){if(!(this instanceof N))return N.apply(Object.create(N.prototype),arguments);if(t){if(N.isV(t)&&(t=t.node),e=e||{},N.isString(t)){if("svg"===(t=t.trim()).toLowerCase())t=N.createSvgDocument();else if("<"===t[0]){var i=N.createSvgDocument(t);if(1<i.childNodes.length){for(var r=[],o=0,s=i.childNodes.length;o<s;o++){var a=i.childNodes[o];r.push(new N(document.importNode(a,!0)))}return r}t=document.importNode(i.firstChild,!0)}else t=document.createElementNS(O.svg,t);N.ensureId(t)}return this.node=t,this.setAttributes(e),n&&this.append(n),this}}var O={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"},h=(t=Math).PI,i=t.atan2,o=t.sqrt,l=t.min,a=t.max,u=t.cos,c=t.sin,t=N.prototype,R=(Object.defineProperty(t,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),t.getTransformToElement=function(t){var e=this.node;if(N.isSVGGraphicsElement(t)&&N.isSVGGraphicsElement(e)){t=N.toNode(t).getScreenCTM(),e=e.getScreenCTM();if(t&&e)return t.inverse().multiply(e)}return N.createSVGMatrix()},t.transform=function(t,e){var n=this.node;return N.isUndefined(t)?N.transformStringToMatrix(this.attr("transform")):e&&e.absolute?this.attr("transform",N.matrixToTransformString(t)):(e=N.createSVGTransform(t),n.transform.baseVal.appendItem(e),this)},t.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=N.parseTransformString(i),i=r.value;if(N.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();t=n.absolute?t:r.translate.tx+t,n=n.absolute?e:r.translate.ty+e;return this.attr("transform",("translate("+t+","+n+")"+" "+i).trim()),this},t.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=N.parseTransformString(r),r=o.value;if(N.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;i=i.absolute?t:o.rotate.angle+t;return this.attr("transform",(r+" "+("rotate("+i+(void 0!==e&&void 0!==n?","+e+","+n:"")+")")).trim()),this},t.scale=function(t,e){e=N.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=N.parseTransformString(n),n=i.value;return N.isUndefined(t)?i.scale:(n=n.replace(/scale\([^)]*\)/g,"").trim(),this.attr("transform",(n+" "+("scale("+t+","+e+")")).trim()),this)},t.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new tt(0,0,0,0);try{n=i.getBBox()}catch(t){n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}return t?new tt(n):(i=this.getTransformToElement(e||r),N.transformRect(n,i))},t.getBBox=function(t){var e={},n=this.node;if(!n.ownerSVGElement||!N.isSVGGraphicsElement(n))return new tt(0,0,0,0);if(t&&(t.target&&(e.target=N.toNode(t.target)),t.recursive)&&(e.recursive=t.recursive),e.recursive){var i=this.children(),r=i.length;if(0===r)return this.getBBox({target:e.target,recursive:!1});e.target||(e.target=this);for(var o=0;o<r;o++)var s=i[o],s=0===s.children().length?s.getBBox({target:e.target,recursive:!1}):s.getBBox({target:e.target,recursive:!0}),a=a?a.union(s):s;return a}try{a=n.getBBox()}catch(t){a={x:n.clientLeft,y:n.clientTop,width:n.clientWidth,height:n.clientHeight}}return e.target?(t=this.getTransformToElement(e.target),N.transformRect(a,t)):new tt(a)},/em$/);function F(t,e){var n=parseFloat(t);return R.test(t)?n*e:n}t.text=function(t,e){if(t&&"string"!=typeof t)throw new Error("Vectorizer: text() expects the first argument to be a string.");t=N.sanitizeText(t);for(var n,i,r,o,s=(e=e||{}).displayEmpty,a=e.eol,l=e.textPath,h=e.textVerticalAnchor,u="middle"===h||"bottom"===h||"top"===h,c=e.x,d=(void 0===c&&(c=this.attr("x")||0),e.includeAnnotationIndices),f=e.annotations,e=(f&&!N.isArray(f)&&(f=[f]),e.lineHeight),p="auto"===e,g=p?"1.5em":e||"1em",m=(this.empty(),this.attr({"xml:space":"preserve",display:t||s?null:"none"}),parseFloat(this.attr("font-size"))),v=(!m&&(m=16,u||f)&&this.attr("font-size",m),document),y=l?(e=this,s=(s=l="string"==typeof l?{d:l}:l)||{},n=N("textPath"),(i=s.d)&&void 0===s["xlink:href"]&&(i=N("path").attr("d",i).appendTo(e.defs()),n.attr("xlink:href","#"+i.id)),N.isObject(s)&&n.attr(s),n.node):v.createDocumentFragment(),b=0,x=t.split("\n"),w=[],A=0,P=x.length-1;A<=P;A++){var E,T,S=g,k="v-line",L=v.createElementNS(O.svg,"tspan"),C=x[A];if(C)f?((M=(T=((t,e,n)=>{for(var i=(n=n||{}).includeAnnotationIndices,r=n.eol,o=n.lineHeight,s=n.baseSize,a=0,n={},l=e.length-1,h=0;h<=l;h++){var u,c,d,f,p=e[h],g=null;N.isObject(p)?(u=p.attrs,d=(c=N("tspan",u)).node,f=p.t,r&&h===l&&(f+=r),d.textContent=f,(f=u.class)&&c.addClass(f),i&&c.attr("annotations",p.annotations),g=parseFloat(u["font-size"]),(g=isFinite(g)?g:s)&&a<g&&(a=g)):(r&&h===l&&(p+=r),d=document.createTextNode(p||" "),s&&a<s&&(a=s)),t.appendChild(d)}return a&&(n.maxFontSize=a),o?n.lineHeight=o:a&&(n.lineHeight=1.2*a),n})(L,E=N.annotateString(C,f,{offset:-b,includeAnnotationIndices:d}),{includeAnnotationIndices:d,eol:A!==P&&a,lineHeight:p?null:g,baseSize:m})).lineHeight)&&p&&0!==A&&(S=M),0===A&&(r=.8*T.maxFontSize)):(a&&A!==P&&(C+=a),L.textContent=C);else{L.textContent="-",k+=" v-empty-line";var M=L.style;if(M.fillOpacity=0,M.strokeOpacity=0,f){T={};let e=m;for(let t=(E=N.findAnnotationsAtIndex(f,b)).length;0<t;t--){var _=E[t-1].attrs;if(_&&"font-size"in _){_=parseFloat(_["font-size"]);if(isFinite(_)){e=_;break}}}p&&(0<A?S=1.2*e:r=.8*e),L.setAttribute("font-size",e),T.maxFontSize=e}}T&&w.push(T),0<A&&L.setAttribute("dy",S),(0<A||l)&&L.setAttribute("x",c),L.className.baseVal=k,y.appendChild(L),b+=C.length+1}if(u)if(f)S=((t,e,n,i)=>{if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=F(o.maxFontSize,n)||n,a=0,l=F(i,n),h=1;h<r;h++)a+=F((o=e[h]).lineHeight,n)||l;var u,c=F(o.maxFontSize,n)||n;switch(t){case"middle":u=s/2-.15*c-a/2;break;case"bottom":u=-.25*c-a;break;default:u=.8*s}return u})(h,w,m,g);else if("top"===h)S="0.8em";else switch(0<P?(o=parseFloat(g)||1,o*=P,R.test(g)||(o/=m)):o=0,h){case"middle":S=.3-o/2+"em";break;case"bottom":S=-o-.3+"em"}else 0===h?S="0em":h?S=h:(S=0,null===this.attr("y")&&this.attr("y",r||"0.8em"));return y.firstChild.setAttribute("dy",S),this.append(y),this},t.removeAttr=function(t){var t=s[t],{ns:e,local:n}=N.qualifyAttr(t),i=this.node;return e?i.hasAttributeNS(e,n)&&i.removeAttributeNS(e,n):i.hasAttribute(t)&&i.removeAttribute(t),this},t.attr=function(t,e){if(N.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(N.isString(t)&&N.isUndefined(e))return this.node.getAttribute(s[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},t.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",N.normalizePathData(this.attr("d"))),this},t.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},t.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},t.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},t.append=function(t){for(var e=0,n=(t=N.isArray(t)?t:[t]).length;e<n;e++)this.node.appendChild(N.toNode(t[e]));return this},t.prepend=function(t){var e=this.node.firstChild;return e?N(e).before(t):this.append(t)},t.before=function(t){var e=this.node,n=e.parentNode;if(n)for(var i=0,r=(t=N.isArray(t)?t:[t]).length;i<r;i++)n.insertBefore(N.toNode(t[i]),e);return this},t.appendTo=function(t){return N.toNode(t).appendChild(this.node),this},t.svg=function(){return this.node instanceof window.SVGSVGElement?this:N(this.node.ownerSVGElement)},t.tagName=function(){return this.node.tagName.toUpperCase()},t.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?N(e):N("defs").appendTo(t)},t.clone=function(){var t=N(this.node.cloneNode(!0));return t.node.id=N.uniqueId(),t},t.findOne=function(t){t=this.node.querySelector(t);return t?N(t):void 0},t.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(N(n[i]));return e},t.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++)1===t[n].nodeType&&e.push(N(t[n]));return e},t.parent=function(){return N(this.node.parentNode)||null},t.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},t.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=N(i);if(r.hasClass(t))return r;i=i.parentNode}return null},t.contains=function(t){var e=this.node,t=N.toNode(t),t=t&&t.parentNode;return e===t||!!(t&&1===t.nodeType&&16&e.compareDocumentPosition(t))},t.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)},t.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},t.translateAndAutoOrient=function(t,e,n){t=new A(t),e=new A(e),n=n||this.svg();var i=this.scale(),r=(this.attr("transform",""),this.getBBox({target:n}).scale(i.sx,i.sy)),o=N.createSVGTransform(),s=(o.setTranslate(-r.x-r.width/2,-r.y-r.height/2),N.createSVGTransform()),a=t.angleBetween(e,t.clone().offset(1,0)),a=(a&&s.setRotate(a,0,0),N.createSVGTransform()),e=t.clone().move(e,r.width/2),r=(a.setTranslate(2*t.x-e.x,2*t.y-e.y),this.getTransformToElement(n)),t=N.createSVGTransform();return t.setMatrix(a.matrix.multiply(s.matrix.multiply(o.matrix.multiply(r.scale(i.sx,i.sy))))),this.attr("transform",N.matrixToTransformString(t.matrix)),this},t.animateAlongPath=function(e,n){n=N.toNode(n);n=N.ensureId(n),e=N("animateMotion",e),n=N("mpath",{"xlink:href":"#"+n});e.append(n),this.append(e);try{e.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling"))for(var i=e.node,n=(i.animators=[],i.getAttribute("id")),r=(n&&(id2anim[n]=i),getTargets(i)),o=0,s=r.length;o<s;o++){var a=r[o],a=new Animator(i,a,o);animators.push(a),(i.animators[o]=a).register()}}return this};let e=/[^\x20\t\r\n\f]+/g;function r(t){return N.isString(t)&&t.trim().match(e)||[]}t.hasClass=function(t){return!!N.isString(t)&&this.node.classList.contains(t.trim())},t.addClass=function(t){return this.node.classList.add(...r(t)),this},t.removeClass=function(t){return this.node.classList.remove(...r(t)),this},t.toggleClass=function(t,e){var n=r(t);for(let t=0;t<n.length;t++)this.node.classList.toggle(n[t],e);return this},t.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},t.convertToPath=function(){var t=N("path"),e=(t.attr(this.attr()),this.convertToPathData());return e&&t.attr("d",e),t},t.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return N.convertLineToPathData(this.node);case"POLYGON":return N.convertPolygonToPathData(this.node);case"POLYLINE":return N.convertPolylineToPathData(this.node);case"ELLIPSE":return N.convertEllipseToPathData(this.node);case"CIRCLE":return N.convertCircleToPathData(this.node);case"RECT":return N.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},N.prototype.toGeometryShape=function(){var t,e,n,i,r,o,s;switch(this.tagName()){case"RECT":return i=parseFloat(this.attr("x"))||0,s=parseFloat(this.attr("y"))||0,t=parseFloat(this.attr("width"))||0,n=parseFloat(this.attr("height"))||0,new tt(i,s,t,n);case"CIRCLE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,i=parseFloat(this.attr("r"))||0,new yi({x:o,y:r},i,i);case"ELLIPSE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("rx"))||0,t=parseFloat(this.attr("ry"))||0,new yi({x:o,y:r},s,t);case"POLYLINE":return e=N.getPointsFromSvgNode(this),new x(e);case"POLYGON":return 1<(e=N.getPointsFromSvgNode(this)).length&&e.push(e[0]),new x(e);case"PATH":return n=this.attr("d"),V.isDataSupported(n)||(n=N.normalizePathData(n)),new V(n);case"LINE":return i=parseFloat(this.attr("x1"))||0,o=parseFloat(this.attr("y1"))||0,r=parseFloat(this.attr("x2"))||0,s=parseFloat(this.attr("y2"))||0,new P({x:i,y:o},{x:r,y:s})}return this.getBBox()},t.findIntersection=function(t,e){var n=this.svg().node,i=this.getBBox({target:e=e||n}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){i=this.tagName();if("RECT"===i)var o=new tt(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),s=this.getTransformToElement(e),a=N.decomposeMatrix(s),n=n.createSVGTransform(),o=(n.setRotate(-a.rotation,r.x,r.y),N.transformRect(o,n.matrix.multiply(s))),s=new tt(o).intersectionWithLineFromCenterToPoint(t,a.rotation);else if("PATH"===i||"POLYGON"===i||"POLYLINE"===i||"CIRCLE"===i||"ELLIPSE"===i){for(var l,h,u,c=("PATH"===i?this:this.convertToPath()).sample(),d=1/0,f=[],p=0;p<c.length;p++)l=c[p],h=(h=N.createSVGPoint(l.x,l.y)).matrixTransform(this.getTransformToElement(e)),(u=(l=new A(h)).distance(r)+(h=1.1*l.distance(t)))<d?(d=u,f=[{sample:l,refDistance:h}]):u<d+1&&f.push({sample:l,refDistance:h});f.sort(function(t,e){return t.refDistance-e.refDistance}),f[0]&&(s=f[0].sample)}return s}},t.setAttribute=function(t,e){var n,i=this.node;return null===e?this.removeAttr(t):(t=s[t],n=N.qualifyAttr(t).ns,n?i.setAttributeNS(n,t,e):"id"===t?i.id=e:i.setAttribute(t,e)),this},N.createSvgDocument=function(t){return t?t=N.parseXML(`<svg xmlns="${O.svg}" xmlns:xlink="${O.xlink}" version="1.1">${t}</svg>`,{async:!1}).documentElement:((t=document.createElementNS(O.svg,"svg")).setAttributeNS(O.xmlns,"xmlns:xlink",O.xlink),t.setAttribute("version","1.1")),t},N.createSVGStyle=function(t){t=N("style",{type:"text/css"},[N.createCDATASection(t)]).node;return t},N.createCDATASection=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return document.implementation.createDocument(null,"xml",null).createCDATASection(t)},N.idCounter=0,N.uniqueId=function(){return"v-"+ ++N.idCounter},N.toNode=function(t){return N.isV(t)?t.node:t.nodeName&&t||t[0]},N.ensureId=function(t){return(t=N.toNode(t)).id||(t.id=N.uniqueId())},N.sanitizeText=function(t){return(t||"").replace(/ /g,"\xa0")},N.isUndefined=function(t){return void 0===t},N.isString=function(t){return"string"==typeof t},N.isObject=function(t){return t&&"object"==typeof t},N.isArray=Array.isArray,N.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;N.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};let n=Object.create(null),s=(["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=>n[t]=t),n.xlinkShow="xlink:show",n.xlinkRole="xlink:role",n.xlinkActuate="xlink:actuate",n.xlinkHref="xlink:href",n.xlinkType="xlink:type",n.xlinkTitle="xlink:title",n.xmlBase="xml:base",n.xmlLang="xml:lang",n.xmlSpace="xml:space",new Proxy(n,{get(t,e){return N.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e}}));Object.defineProperty(N,"attributeNames",{enumerable:!0,value:s,writable:!1}),Object.defineProperty(N,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),N.qualifyAttr=function(t){var e;return-1!==t.indexOf(":")?(e=t.split(":"),{ns:O[e[0]],local:e[1]}):{ns:null,local:t}},N.transformSeparatorRegex=/[ ,]+/,N.transformRegex=/\b\w+\([^()]+\)/g,N.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,N.transformTranslateRegex=/\btranslate\(([^()]+)\)/,N.transformRotateRegex=/\brotate\(([^()]+)\)/,N.transformScaleRegex=/\bscale\(([^()]+)\)/,N.transformStringToMatrix=function(t){let s=N.createSVGMatrix();var e=t&&t.match(N.transformRegex);if(e){var n=e.length;for(let t=0;t<n;t++){var a=e[t].match(N.transformFunctionRegex);if(a){let t,e,n,i,r,o=N.createSVGMatrix();var l=a[1].toLowerCase(),h=a[2].split(N.transformSeparatorRegex);switch(l){case"scale":t=parseFloat(h[0]),e=void 0===h[1]?t:parseFloat(h[1]),o=o.scaleNonUniform(t,e);break;case"translate":n=parseFloat(h[0]),i=parseFloat(h[1]),o=o.translate(n,i);break;case"rotate":r=parseFloat(h[0]),n=parseFloat(h[1])||0,i=parseFloat(h[2])||0,o=0!==n||0!==i?o.translate(n,i).rotate(r).translate(-n,-i):o.rotate(r);break;case"skewx":r=parseFloat(h[0]),o=o.skewX(r);break;case"skewy":r=parseFloat(h[0]),o=o.skewY(r);break;case"matrix":o.a=parseFloat(h[0]),o.b=parseFloat(h[1]),o.c=parseFloat(h[2]),o.d=parseFloat(h[3]),o.e=parseFloat(h[4]),o.f=parseFloat(h[5]);break;default:continue}s=s.multiply(o)}}}return s},N.matrixToTransformString=function(t){return"matrix("+(void 0!==(t=t||!0).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)+")"},N.parseTransformString=function(t){t&&(e=N.transformSeparatorRegex,0<=t.trim().indexOf("matrix")?(r=N.transformStringToMatrix(t),n=[(r=N.decomposeMatrix(r)).translateX,r.translateY],i=[r.scaleX,r.scaleY],r=[r.rotation],o=[],0===n[0]&&0===n[1]||o.push("translate("+n+")"),1===i[0]&&1===i[1]||o.push("scale("+i+")"),0!==r[0]&&o.push("rotate("+r+")"),t=o.join(" ")):((o=t.match(N.transformTranslateRegex))&&(n=o[1].split(e)),(o=t.match(N.transformRotateRegex))&&(r=o[1].split(e)),(o=t.match(N.transformScaleRegex))&&(i=o[1].split(e))));var e,n,i,r,o=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:n&&n[0]?parseInt(n[0],10):0,ty:n&&n[1]?parseInt(n[1],10):0},rotate:{angle:r&&r[0]?parseInt(r[0],10):0,cx:r&&r[1]?parseInt(r[1],10):void 0,cy:r&&r[2]?parseInt(r[2],10):void 0},scale:{sx:o,sy:i&&i[1]?parseFloat(i[1]):o}}},N.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c,y:e.x*t.b+e.y*t.d}},N.decomposeMatrix=function(t){var e=N.deltaTransformPoint(t,{x:0,y:1}),n=N.deltaTransformPoint(t,{x:1,y:0}),e=180/h*i(e.y,e.x)-90,n=180/h*i(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:e,skewY:n,rotation:e}},N.matrixToScale=function(t){var e,n,i,r;return t?(e=N.isUndefined(t.a)?1:t.a,r=N.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}},N.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=N.deltaTransformPoint(t,e)),{angle:Xn(Hn(i(e.y,e.x))-90)}},N.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},N.isVElement=N.isV=function(t){return t instanceof N},N.isSVGGraphicsElement=function(t){return!!t&&(t=N.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM};var y,b,E,T,S,k,L,C,M,d=N("svg").node;function f(t,e,n,i,r,o){return[1/3*t+2/3*n,1/3*e+2/3*i,1/3*r+2/3*n,1/3*o+2/3*i,r,o]}function _(t,e,n){return{x:t*S(n)-e*T(n),y:t*T(n)+e*S(n)}}function I(t,e,n,i,r,o,s,a,l,h){var u=120*E/180,c=E/180*(+r||0),d=[];if(h)b=h[0],x=h[1],v=h[2],y=h[3];else{t=(p=_(t,e,-c)).x,e=p.y;var f=(t-(a=(p=_(a,l,-c)).x))/2,p=(e-(l=p.y))/2,g=f*f/(n*n)+p*p/(i*i),g=(1<g&&(n*=g=C(g),i*=g),n*n),m=i*i,o=(o==s?-1:1)*C(M((g*m-g*p*p-m*f*f)/(g*p*p+m*f*f)));if(!Number.isFinite(o))return[t,e,a,l,a,l];var v=o*n*p/i+(t+a)/2,y=o*-i*f/n+(e+l)/2,b=L(((e-y)/i).toFixed(9)),x=L(((l-y)/i).toFixed(9));(b=t<v?E-b:b)<0&&(b=2*E+b),(x=a<v?E-x:x)<0&&(x=2*E+x),s&&x<b&&(b-=2*E),!s&&b<x&&(x-=2*E)}M(x-b)>u&&(g=x,m=a,p=l,d=I(a=v+n*S(x=b+u*(s&&b<x?1:-1)),l=y+i*T(x),n,i,r,0,s,m,p,[x,g,v,y])),o=x-b;f=S(b),u=T(b),r=S(x),s=T(x),m=k(o/4),p=4/3*(n*m),g=4/3*(i*m),v=[t,e],y=[t+p*u,e-g*f],b=[a+p*s,l-g*r],x=[a,l];if(y[0]=2*v[0]-y[0],y[1]=2*v[1]-y[1],h)return[y,b,x].concat(d);for(var w=[],A=(d=[y,b,x].concat(d).join().split(",")).length,P=0;P<A;P++)w[P]=P%2?_(d[P-1],d[P],c).y:_(d[P],d[P+1],c).x;return w}function p(t){var e,o,s;if(!(t=Array.isArray(t)&&Array.isArray(t&&t[0])?t:(e=t)?(o={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},s=[],String(e).replace(y,function(t,e,n){var i=[],r=e.toLowerCase();for(n.replace(b,function(t,e){e&&i.push(+e)}),"m"===r&&2<i.length&&(s.push([e].concat(i.splice(0,2))),r="l",e="m"===e?"l":"L");o[r]<=i.length&&(s.push([e].concat(i.splice(0,o[r]))),o[r]););}),s):null)||!t.length)return[["M",0,0]];for(var n=[],i=0,r=0,a=0,l=0,h=t.length,u=0;u<h;u++){var c,d,f=[],p=(n.push(f),t[u]),g=p[0];if(g!=g.toUpperCase())switch(f[0]=g.toUpperCase(),f[0]){case"A":f[1]=p[1],f[2]=p[2],f[3]=p[3],f[4]=p[4],f[5]=p[5],f[6]=+p[6]+i,f[7]=+p[7]+r;break;case"V":f[1]=+p[1]+r;break;case"H":f[1]=+p[1]+i;break;case"M":for(a=+p[1]+i,l=+p[2]+r,c=p.length,d=1;d<c;d++)f[d]=+p[d]+(d%2?i:r);break;default:for(c=p.length,d=1;d<c;d++)f[d]=+p[d]+(d%2?i:r)}else for(var m=p.length,v=0;v<m;v++)f[v]=p[v];switch(f[0]){case"Z":i=+a,r=+l;break;case"H":i=f[1];break;case"V":r=f[1];break;case"M":a=f[f.length-2],l=f[f.length-1],i=f[f.length-2],r=f[f.length-1];break;default:i=f[f.length-2],r=f[f.length-1]}}return n}function g(t){var e=p(t),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};for(var i=[],r="",o="",s=e.length,a=0;a<s;a++){"C"!==(r=e[a]?e[a][0]:r)&&(i[a]=r,0<a)&&(o=i[a-1]),e[a]=((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(I.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":r="C"===n||"S"===n?(i=2*e.x-e.bx,2*e.y-e.by):(i=e.x,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(f(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(f(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})(e[a],n,o),"A"!==i[a]&&"C"===r&&(i[a]="C"),u=h=l=void 0;var l=e,h=a;if(7<l[h].length){l[h].shift();for(var u=l[h];u.length;)i[h]="A",l.splice(h++,0,["C"].concat(u.splice(0,6)));l.splice(h,1),s=e.length}var c=e[a],d=c.length;n.x=c[d-2],n.y=c[d-1],n.bx=parseFloat(c[d-4])||n.x,n.by=parseFloat(c[d-3])||n.y}return e[0][0]&&"M"===e[0][0]||e.unshift(["M",0,0]),e}return N.createSVGMatrix=function(t){var e,n=d.createSVGMatrix();for(e in t)n[e]=t[e];return n},N.createSVGTransform=function(t){return N.isUndefined(t)?d.createSVGTransform():(t instanceof SVGMatrix||(t=N.createSVGMatrix(t)),d.createSVGTransformFromMatrix(t))},N.createSVGPoint=function(t,e){var n=d.createSVGPoint();return n.x=t,n.y=e,n},N.transformRect=function(t,e){var n=d.createSVGPoint(),i=(n.x=t.x,n.y=t.y,n.matrixTransform(e)),r=(n.x=t.x+t.width,n.y=t.y,n.matrixTransform(e)),o=(n.x=t.x+t.width,n.y=t.y+t.height,n.matrixTransform(e)),t=(n.x=t.x,n.y=t.y+t.height,n.matrixTransform(e)),n=l(i.x,r.x,o.x,t.x),e=a(i.x,r.x,o.x,t.x),s=l(i.y,r.y,o.y,t.y),i=a(i.y,r.y,o.y,t.y);return new tt(n,s,e-n,i-s)},N.transformPoint=function(t,e){return new A(N.createSVGPoint(t.x,t.y).matrixTransform(e))},N.transformLine=function(t,e){return new P(N.transformPoint(t.start,e),N.transformPoint(t.end,e))},N.transformPolyline=function(t,e){for(var n=t instanceof x?t.points:t,i=[],r=0,o=(n=N.isArray(n)?n:[]).length;r<o;r++)i[r]=N.transformPoint(n[r],e);return new x(i)},N.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},N.createSlicePathData=function(t,e,n,i){var r=2*h-1e-6,o=(i<n&&(o=n,n=i,i=o),i-n),s=o<h?"0":"1",a=u(n),n=c(n),l=u(i),i=c(i);return r<=o?t?"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"M0,"+t+"A"+t+","+t+" 0 1,0 0,"+-t+"A"+t+","+t+" 0 1,0 0,"+t+"Z":"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"Z":t?"M"+e*a+","+e*n+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*i+"L"+t*l+","+t*i+"A"+t+","+t+" 0 "+s+",0 "+t*a+","+t*n+"Z":"M"+e*a+","+e*n+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*i+"L0,0Z"},N.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?N.isObject(t[n])&&N.isObject(e[n])?t[n]=N.mergeAttrs(t[n],e[n]):N.isObject(t[n])?t[n]=N.mergeAttrs(t[n],N.styleToObject(e[n])):N.isObject(e[n])?t[n]=N.mergeAttrs(N.styleToObject(t[n]),e[n]):t[n]=N.mergeAttrs(N.styleToObject(t[n]),N.styleToObject(e[n])):t[n]=e[n];return t},N.annotateString=function(t,e,n){e=e||[];for(var i,r,o=(n=n||{}).offset||0,s=[],a=[],l=0;l<t.length;l++){for(var h=a[l]=t[l],u=0;u<e.length;u++){var c=e[u];c.start+o<=l&&l<c.end+o&&(N.isObject(h)?h.attrs=N.mergeAttrs(N.mergeAttrs({},h.attrs),c.attrs):h=a[l]={t:t[l],attrs:c.attrs},n.includeAnnotationIndices)&&(h.annotations||(h.annotations=[])).push(u)}(r=a[l-1])?N.isObject(h)&&N.isObject(r)?JSON.stringify(h.attrs)===JSON.stringify(r.attrs)?i.t+=h.t:(s.push(i),i=h):i=N.isObject(h)||N.isObject(r)?(s.push(i),h):(i||"")+h:i=h}return i&&s.push(i),s},N.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach(function(t){t.start<e&&e<=t.end&&n.push(t)}),n},N.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},N.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},N.convertLineToPathData=function(t){return["M",(t=N(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},N.convertPolygonToPathData=function(t){t=N.getPointsFromSvgNode(t);return 0===t.length?null:N.svgPointsToPath(t)+" Z"},N.convertPolylineToPathData=function(t){t=N.getPointsFromSvgNode(t);return 0===t.length?null:N.svgPointsToPath(t)},N.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")},N.getPointsFromSvgNode=function(t){var e=[],n=(t=N.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},N.KAPPA=.551784,N.convertCircleToPathData=function(t){t=N(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,t=parseFloat(t.attr("r")),i=t*N.KAPPA;return["M",e,n-t,"C",e+i,n-t,e+t,n-i,e+t,n,"C",e+t,n+i,e+i,n+t,e,n+t,"C",e-i,n+t,e-t,n+i,e-t,n,"C",e-t,n-i,e-i,n-t,e,n-t,"Z"].join(" ")},N.convertEllipseToPathData=function(t){t=N(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),t=parseFloat(t.attr("ry"))||i,r=i*N.KAPPA,o=t*N.KAPPA;return["M",e,n-t,"C",e+r,n-t,e+i,n-o,e+i,n,"C",e+i,n+o,e+r,n+t,e,n+t,"C",e-r,n+t,e-i,n+o,e-i,n,"C",e-i,n-o,e-r,n-t,e,n-t,"Z"].join(" ")},N.convertRectToPathData=function(t){return t=N(t),N.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})},N.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=l(t.rx||t["top-rx"]||0,i/2),s=l(t.rx||t["bottom-rx"]||0,i/2),a=l(t.ry||t["top-ry"]||0,r/2),t=l(t.ry||t["bottom-ry"]||0,r/2),s=o||s||a||t?["M",e,n+a,"v",r-a-t,"a",s,t,0,0,0,s,t,"h",i-2*s,"a",s,t,0,0,0,s,-t,"v",-(r-t-a),"a",o,a,0,0,0,-o,-a,"h",-(i-2*o),"a",o,a,0,0,0,-o,a,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"];return s.join(" ")},N.normalizePathData=(t="\t\n\v\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",y=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),b=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),t=Math,E=t.PI,T=t.sin,S=t.cos,k=t.tan,L=t.asin,C=t.sqrt,M=t.abs,function(t){return g(t).join(",").split(",").join(" ")}),N.namespace=O,N.g=br,N})();function Ma(t){let e=t.length;for(;e--;)_a(t[e])}function _a(t){L.event.remove(t),ba.remove(t),xa.remove(t)}function Na(e){for(let t=0;t<e.length;t++){var n=e[t];n.parentNode&&n.parentNode.removeChild(n)}}let Oa={};function Ra(e,n,i){for(let t=0;t<n.length;t++){var r=n[t];R.prototype[e].apply({node:r},i)}}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach(t=>{Oa[t]=!0});let Fa={remove:function(){for(let t=0;t<this.length;t++){var e=this[t];_a(e),Ma(e.getElementsByTagName("*"))}return Na(this),this},detach:function(){return Na(this),this},empty:function(){for(let t=0;t<this.length;t++){var e=this[t];1===e.nodeType&&(Ma(e.getElementsByTagName("*")),e.textContent="")}return this},clone:function(){var e=[];for(let t=0;t<this.length;t++)e.push(this[t].cloneNode(!0));return this.pushStack(e)},html:function(t){var[e]=this;if(!e)return null;if(0===arguments.length)return e.innerHTML;if(void 0!==t){if(Ma(ba,e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t)return e.innerHTML="",this.append(t);e.innerHTML=t}return this},append:function(){let[e]=this;if(e){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];n.forEach(t=>{t&&("string"==typeof t?e.append(...L.parseHTML(t)):"[object Object]"===t.toString()?this.append(...Array.from(t)):Array.isArray(t)?this.append(...t):e.appendChild(t))})}return this},prepend:function(){let[e]=this;if(e){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];n.forEach(t=>{t&&("string"==typeof t?e.prepend(...L.parseHTML(t)):"[object Object]"===t.toString()?this.prepend(...Array.from(t)):Array.isArray(t)?this.prepend(...t):e.insertBefore(t,e.firstChild))})}return this},appendTo:function(t){return L(t).append(this),this},prependTo:function(t){return L(t).prepend(this),this},css:function(t,e){let n;if("string"==typeof t){var i;if(void 0===e)return[i]=this,i?i.style[t]:null;n={[t]:e}}else{if(!t)throw new Error("no styles provided");n=t}for(let e in n)if(n.hasOwnProperty(e))for(let t=0;t<this.length;t++)r=this[t],o=e,"number"==typeof(s=n[e])&&Oa[ga(o)]&&(s+="px"),r.style[o]=s;var r,o,s;return this},data:function(e,n){var t;if(arguments.length<2)return[t]=this,t?void 0===e?t.dataset:t.dataset[e]:null;for(let t=0;t<this.length;t++)this[t].dataset[e]=n;return this},removeClass:function(){return Ra("removeClass",this,arguments),this},addClass:function(){return Ra("addClass",this,arguments),this},toggleClass:function(){return Ra("toggleClass",this,arguments),this},hasClass:function(){var[t]=this;return!!t&&R.prototype.hasClass.apply({node:t},arguments)},children:function(n){var i=[];for(let e=0;e<this.length;e++){var r=this[e];let t=Array.from(r.children);"string"==typeof n&&(t=t.filter(t=>t.matches(n))),i.push(...t)}return this.pushStack(i)},closest:function(e){var n=[];for(let t=0;t<this.length;t++){var i,r=this[t];"string"==typeof e?(i=r.closest(e))&&n.push(i):([i]=L(e),i&&i.contains(r)&&n.push(i))}return this.pushStack(n)},on:function(t,e,n,i){return L.event.on(this,t,e,n,i),this},one:function(t,e,n,i){return L.event.on(this,t,e,n,i,1),this},off:function(e,n,i){var t;if(e&&e.preventDefault&&e.handleObj)t=e.handleObj,L(e.delegateTarget).off(t.namespace?t.origType+"."+t.namespace:t.origType,t.selector,t.handler);else if("object"==typeof e)for(var r in e)this.off(r,n,e[r]);else{!1!==n&&"function"!=typeof n||(i=n,n=void 0);for(let t=0;t<this.length;t++)L.event.remove(this[t],e,i,n)}return this},width:function(){var t,e,[n]=this;return n===window?n.document.documentElement.clientWidth:n?(t=window.getComputedStyle(n),n=n.offsetWidth,e=parseFloat(t.borderTopWidth),n-parseFloat(t.borderBottomWidth)-e-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom)):void 0},height:function(){var t,[e]=this;return e===window?e.document.documentElement.clientHeight:e?(t=window.getComputedStyle(e),e.offsetHeight-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)):void 0},position:function(){var[i]=this;if(i){var r,o=L(i);let t,e,n={top:0,left:0};if("fixed"===o.css("position"))e=i.getBoundingClientRect();else{e=o.offset(),r=i.ownerDocument,t=i.offsetParent||r.documentElement;for(var s,o=L(t),a=o.css("position")||"static";t&&(t===r.body||t===r.documentElement)&&"static"===a;)t=t.parentNode;t&&t!==i&&1===t.nodeType&&(s=window.getComputedStyle(t),l=parseFloat(s.borderTopWidth)||0,s=parseFloat(s.borderLeftWidth)||0,(n=o.offset()).top+=l,n.left+=s)}var o=parseFloat(window.getComputedStyle(i).marginTop)||0,l=parseFloat(window.getComputedStyle(i).marginLeft)||0;return{top:e.top-n.top-o,left:e.left-n.left-l}}},offset:function(t){var e,n,[i]=this;return void 0===t?i?i.getClientRects().length?{top:(e=i.getBoundingClientRect()).top+window.scrollY,left:e.left+window.scrollX}:{top:0,left:0}:null:(i&&("static"===(e=window.getComputedStyle(i)).position&&this.css("position","relative"),i=this.offset(),n=t.top-i.top,t=t.left-i.left,this.css({top:(parseFloat(e.top)||0)+n+"px",left:(parseFloat(e.left)||0)+t+"px"})),this)}},Ia="animationFrameId",Va={};Va["transition-property"]=Va["transition-duration"]=Va["transition-delay"]=Va["transition-timing-function"]=Va["animation-name"]=Va["animation-duration"]=Va["animation-delay"]=Va["animation-timing-function"]="";let Ba={animate:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};this.stop();for(let t=0;t<this.length;t++)!function(a,l){let t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},{duration:h=400,easing:u="ease-in-out",delay:c=0,complete:d}=t,e=setTimeout(function(){let e=L(a),n=!1,i="transitionend";h/=1e3,c/=1e3;var t={};if("string"==typeof l)t["animation-name"]=l,t["animation-duration"]=h+"s",t["animation-delay"]=c+"s",t["animation-timing-function"]=u,i="animationend";else{var r,o=[];for(r in l)l.hasOwnProperty(r)&&(t[r]=l[r],o.push(r));0<h&&(t["transition-property"]=o.join(", "),t["transition-duration"]=h+"s",t["transition-delay"]=c+"s",t["transition-timing-function"]=u)}let s=function(t){if(t){if(t.target!==t.currentTarget)return;t.target.removeEventListener(i,s)}else a.removeEventListener(i,s);n=!0,e.css(Va),d&&d.call(a)};if(0<h){a.addEventListener(i,s);let t=setTimeout(function(){n||s(null)},1e3*(h+c)+25);ba.set(a,Ia,{id:t,stop:()=>{clearTimeout(t),a.removeEventListener(i,s)}})}e.css(t),h<=0&&s(null)});ba.set(a,Ia,{stop:()=>clearTimeout(e)})}(this[t],e,n);return this},stop:function(){for(let t=0;t<this.length;t++){var e=this[t],n=ba.get(e,Ia);n&&(n.stop(),ba.remove(e,Ia))}return this.css(Va),this}},Da={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},za={disabled:"disabled",value:"value",text:"textContent"};function ja(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,Ua.classNamePrefix.length)!==Ua.classNamePrefix?Ua.classNamePrefix+t:t}).join(" ")}let Ga={prop:function(e,n){if(!e)throw new Error("no property provided");var t;if(1===arguments.length)return[t]=this,t?t[e]:null;if(void 0!==n)for(let t=0;t<this.length;t++)this[t][e]=n;return this},attr:function(t,e){let n;if("string"==typeof t){var i;if(void 0===e)return[i]=this,i?i.getAttribute(t):null;n={[t]:e}}else{if(!t)throw new Error("no attributes provided");n=t}for(var r in n)if(n.hasOwnProperty(r)){let e=n[r];if(za[r])this.prop(za[r],e);else for(let t=0;t<this.length;t++)null===e?this[t].removeAttribute(r):this[t].setAttribute(r,e)}return this}},Ua=(Object.keys(Da).forEach(i=>{Ga[i]=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.prop(Da[i],...e)}}),{useCSSSelectors:!1,classNamePrefix:"joint-",defaultTheme:"default",doubleTapInterval:300}),Ha=Object.create(null),qa=(Ha.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach(t=>{let[e,r]=t;Ha[e]={delegateType:r,bindType:r,handle:function(t){var e=t.relatedTarget,n=t.handleObj;let i;return e&&this.contains(e)||(t.type=n.origType,i=n.handler.apply(this,arguments),t.type=r),i}}}),Ua.doubleTapInterval);Ha.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t){var{handleObj:e,target:n}=t,n=L.data.create(n),i=(new Date).getTime(),r="lastTouch"in n?i-n.lastTouch:0;if(r<qa&&30<r){n.lastTouch=null,t.type=e.origType;for(var o=arguments.length,s=new Array(1<o?o-1:0),a=1;a<o;a++)s[a-1]=arguments[a];e.handler.call(this,t,...s)}else n.lastTouch=i}},Object.assign(L.fn,Fa),Object.assign(L.fn,Ba),Object.assign(L.fn,Ga),Object.assign(L.event.special,Ha);function $a(t,e){let c={},d={},f=R.namespace.svg;var e=e||f,n=document.createDocumentFragment();function p(e,n,i){for(let t=0;t<e.length;t++){var r=e[t];if("string"==typeof r){var o=document.createTextNode(r);n.appendChild(o)}else{if(!r.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");var s,o=r.tagName,a=(r.hasOwnProperty("namespaceURI")&&(i=r.namespaceURI),s=document.createElementNS(i,o),i===f),l=(a?R:L)(s),h=r.attributes,h=(h&&l.attr(h),r.style);if(h&&L(s).css(h),r.hasOwnProperty("className")&&(h=r.className,a?s.className.baseVal=h:s.className=h),r.hasOwnProperty("textContent")&&(s.textContent=r.textContent),r.hasOwnProperty("selector")){a=r.selector;if(c[a])throw new Error("json-dom-parser: selector must be unique");c[a]=s,l.attr("joint-selector",a)}if(r.hasOwnProperty("groupSelector")){let n=r.groupSelector;Array.isArray(n)||(n=[n]);for(let e=0;e<n.length;e++){var u=n[e];let t=d[u];(t=t||(d[u]=[])).push(s)}}n.appendChild(s);h=r.children;Array.isArray(h)&&p(h,s,i)}}}return p(t,n,e),{fragment:n,selectors:c,groupSelectors:d}}function Wa(e){let n=0;if(0!==e.length)for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return n}function Ya(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}function Xa(t,e){return("constructor"!==(e="string"!=typeof e&&"number"!=typeof e?String(e):e)||"function"!=typeof t[e])&&"__proto__"!==e}function Za(e,t,n,i){var r=Array.isArray(t)?t:t.split(i||"/"),o=r.length-1;let s=e,a=0;for(;a<o;a++){var l=r[a];if(!Xa(s,l))return e;let t=s[l];s=t||(s[l]={})}return s[r[o]]=n,e}function Ja(t,e,n){var i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1;let o=t,s=0;for(;s<r;s++){var a=i[s];if(!Xa(o,a))return t;a=o[a];if(!a)return t;o=a}return delete o[i[r]],t}function Ka(t,e,n){e=e||"/";var i,r={};for(i in t)if(t.hasOwnProperty(i)){var o="object"==typeof t[i];if(o=o&&n&&n(t[i])?!1:o){var s,a=Ka(t[i],e,n);for(s in a)a.hasOwnProperty(s)&&(r[i+e+s]=a[s])}else r[i]=t[i]}return r}function Qa(){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)})}function tl(t){return tl.id=tl.id||1,void 0===t?"j_"+tl.id++:(t.id=void 0===t.id?"j_"+tl.id++:t.id,t.id)}var el,nl;function C(t){if(!t.normalized){var{originalEvent:e,target:n}=t,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(var r in i)void 0===t[r]&&(t[r]=i[r]);n&&(e=n.correspondingUseElement)&&(t.target=e),t.normalized=!0}return t}function il(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}}function rl(t,e){return e<t?e:t<-e?-e:t}function ol(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 E(e)&&(i=e);return n=i,null===(e=(n=new RegExp("(?:\\d+(?:\\.\\d+)*)("+n+")$").exec(t))?n[1]:null)?null:(r.unit=e,r)}(nl="undefined"!=typeof window?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame:nl)||(el=0,nl=function(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-el)),i=setTimeout(function(){t(e+n)},n);return el=e+n,i});let sl=function(t,e){for(var n=arguments.length,i=new Array(2<n?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return nl(void 0!==e?t.bind(e,...i):t)},al=(c="undefined"!=typeof window,Rh=(Rh=c?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame:Rh)||clearTimeout,c?Rh.bind(window):Rh),ll=function(t){return E(t)&&"%"===t.slice(-1)},hl=0;function ul(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}}function cl(t,e){var n,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=e.width,s=e.height,e=r.svgDocument||R("svg").node,a=R("tspan").node,l=R("text").attr(i).append(a).node,h=document.createTextNode(""),u=(l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(h),e.appendChild(l),r.svgDocument||document.body.appendChild(e),r.preserveSpaces),c=r.separator||""===r.separator?r.separator:" ",d="string"==typeof c?c:" ",f=r.eol||"\n",p=r.hyphen?new RegExp(r.hyphen):/[^\w\d\u00C0-\u1FFF\u2800-\uFFFD]/,g=r.maxLineCount,m=(qs(g)||(g=1/0),t.split(c)),v=[],y=[];u&&R(a).attr("xml:space","preserve");for(var b=0,x=0,w=m.length;b<w;b++){var A=m[b];if((A||u)&&"string"==typeof A){var P=!1;if(f&&0<=A.indexOf(f)){if(1<A.length){var E=((t,n)=>{var i=t.split(n);let r=1;for(let t=0,e=i.length-1;t<e;t++){var o=[];(0<t||""!==i[0])&&o.push(hl),o.push(n),(t<e-1||""!==i[e])&&o.push(hl),i.splice(r,0,...o),r+=o.length+1}return i.filter(t=>""!==t)})(m[b],f);m.splice(b,1,...E),b--,w=m.length;continue}if(u&&"string"==typeof m[b-1]){m.splice(b,hl,"",hl),w+=2,b--;continue}y[++x]=u&&"string"!=typeof m[b+1]?void 0:"",P=!0}if(!P){let t;if(t=u?void 0!==y[x]?y[x]+d+A:A:y[x]?y[x]+d+A:A,h.data=t,a.getComputedTextLength()<=o)y[x]=t,(T||n)&&(v[x++]=!0,n=T=0);else{if(!y[x]||T){var E=!!T,T=A.length-1;if(E||!T){if(!T){if(!y[x]){y=[];break}m.splice(b,2,A+m[b+1]),w--,v[x++]=!0,b--;continue}m[b]=A.substring(0,T);var S=m[b+1];m[b+1]=A.substring(T)+(void 0===S||S===hl?"":S)}else n?(m.splice(b,2,m[b]+m[b+1]),n=0):(-1<(S=A.search(p))&&S!==A.length-1&&0!==S&&(n=S+1,T=0),m.splice(b,1,A.substring(0,n||T),A.substring(n||T)),w++),x&&!v[x-1]&&x--;u&&""===y[x]||b--;continue}x++,b--}}var k,L=null;if(y.length>g?L=g-1:void 0!==s&&(k=void 0===k&&""!==h.data?"auto"===i.lineHeight?ul({value:1.5,unit:"em"},l):ul(ol(i.lineHeight,["em","px",""]),l):k)*y.length>s&&(L=Math.floor(s/k)-1),null!==L){y.splice(L+1);var C=r.ellipsis;if(!C||L<0)break;"string"!=typeof C&&(C="\u2026");var M=y[L];if(!M&&!P)break;var _,N,O=M.length;do{if(N=M[O],_=M.substring(0,O),N?N.match(c)&&(_+=N):_+=d,_+=C,h.data=_,a.getComputedTextLength()<=o){y[L]=_;break}}while(0<=--O);break}}}return r.svgDocument?e.removeChild(l):document.body.removeChild(e),y.join(f)}function dl(t,e){var n;window.navigator.msSaveBlob?window.navigator.msSaveBlob(t,e):(t=window.URL.createObjectURL(t),(n=document.createElement("a")).href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(t))}function fl(t){t=t.replace(/\s/g,"");for(var e=(t=decodeURIComponent(t)).indexOf(","),n=t.slice(0,e),i=n.split(":")[1].split(";")[0],t=t.slice(e+1),r=0<=n.indexOf("base64")?atob(t):unescape(encodeURIComponent(t)),o=new Uint8Array(r.length),s=0;s<r.length;s++)o[s]=r.charCodeAt(s);return new Blob([o],{type:i})}function pl(t,e){var n=(t=L(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(e);for(var i=0;i<n.length;i++)n[i].call(t[i]);return t}let gl=function(t){var e,n,i,r;return Object(t)!==t?(r=0,{top:r=isFinite(t)?+t:r,right:r,bottom:r,left:r}):(e=n=i=r=0,isFinite(t.vertical)&&(e=i=+t.vertical),isFinite(t.horizontal)&&(n=r=+t.horizontal),{top:e=isFinite(t.top)?+t.top:e,right:n=isFinite(t.right)?+t.right:n,bottom:i=isFinite(t.bottom)?+t.bottom:i,left:r=isFinite(t.left)?+t.left:r})},ml={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){var e,n;return t<=0?0:1<=t?1:(n=(e=t*t)*t,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,n=0,i=1;;n+=i,i/=2){1;if((7-4*n)/11<=t)return-(e=(11-6*n-11*t)/4)*e+i*i}},reverse:function(e){return function(t){return 1-e(1-t)}},reflect:function(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}},clamp:function(e,n,i){return n=n||0,i=i||1,function(t){t=e(t);return t<n?n:i<t?i:t}},back:function(e){return e=e||1.70158,function(t){return t*t*((e+1)*t-e)}},elastic:function(e){return e=e||1.5,function(t){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e/3*t)}}},vl={number:function(e,t){var n=t-e;return function(t){return e+n*t}},object:function(r,o){var s=Object.keys(r);return function(t){for(var e,n={},i=s.length-1;-1!=i;i--)n[e=s[i]]=r[e]+(o[e]-r[e])*t;return n}},hexColor:function(t,e){var t=parseInt(t.slice(1),16),e=parseInt(e.slice(1),16),n=255&t,i=(255&e)-n,r=65280&t,o=(65280&e)-r,s=16711680&t,a=(16711680&e)-s;return function(t){return"#"+(1<<24|n+i*t&255|r+o*t&65280|s+a*t&16711680).toString(16).slice(1)}},unit:function(e,t){var n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,i=n.exec(e),n=n.exec(t),t=n[1].indexOf("."),r=0<t?n[1].length-t-1:0,o=(e=+i[1],+n[1]-e),s=i[2];return function(t){return(e+o*t).toFixed(r)+s}}},yl={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return bl('<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 bl('<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 bl('<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 bl(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){t=Number.isFinite(t.amount)?t.amount:1;return bl('<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-t),b:.7152-.7152*(1-t),c:.0722-.0722*(1-t),d:.2126-.2126*(1-t),e:.7152+.2848*(1-t),f:.0722-.0722*(1-t),g:.2126-.2126*(1-t),h:.0722+.9278*(1-t)})},sepia:function(t){t=Number.isFinite(t.amount)?t.amount:1;return bl('<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-t),b:.769-.769*(1-t),c:.189-.189*(1-t),d:.349-.349*(1-t),e:.686+.314*(1-t),f:.168-.168*(1-t),g:.272-.272*(1-t),h:.534-.534*(1-t),i:.131+.869*(1-t)})},saturate:function(t){t=Number.isFinite(t.amount)?t.amount:1;return bl('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-t})},hueRotate:function(t){return bl('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){t=Number.isFinite(t.amount)?t.amount:1;return bl('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:t,amount2:1-t})},brightness:function(t){return bl('<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){t=Number.isFinite(t.amount)?t.amount:1;return bl('<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:t,amount2:.5-t/2})}};h={number:function(t,e,o){o=o||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var t=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i.exec(t),n=t[1]||" ",i=t[2]||">",r=t[3]||"",s=t[4]||"",a=t[5],l=+t[6],h=t[7],u=t[8],c=t[9],d=1,f="",p="",g=!1,u=u&&+u.substring(1);switch((a||"0"===n&&"="===i)&&(a=n="0",i="=",h)&&(l-=Math.floor((l-1)/4)),c){case"n":h=!0,c="g";break;case"%":d=100,p="%",c="f";break;case"p":d=100,p="%",c="r";break;case"b":case"o":case"x":case"X":"#"===s&&(f="0"+c.toLowerCase());break;case"c":case"d":g=!0,u=0;break;case"s":d=-1,c="r"}"$"===s&&(f=o.currency[0],p=o.currency[1]),"r"!=c||u||(c="g"),null!=u&&("g"==c?u=Math.max(1,Math.min(21,u)):"e"!=c&&"f"!=c||(u=Math.max(0,Math.min(20,u))));t=a&&h;if(g&&e%1)return"";var r=e<0||0===e&&1/e<0?(e=-e,"-"):r,m=p,v=(d<0?(e=(v=this.prefix(e,u)).scale(e),m=v.symbol+p):e*=d,(e=this.convert(c,e,u)).lastIndexOf(".")),y=v<0?e:e.substring(0,v),v=v<0?"":o.decimal+e.substring(v+1);function b(t){for(var e=t.length,n=[],i=0,r=o.grouping[0];0<e&&0<r;)n.push(t.substring(e-=r,e+r)),r=o.grouping[i=(i+1)%o.grouping.length];return n.reverse().join(o.thousands)}!a&&h&&o.grouping&&(y=b(y));a=f.length+y.length+v.length+(t?0:r.length),l=a<l?new Array(a=l-a+1).join(n):"";return r+=f,e=(y=t?b(l+y):y)+v,("<"===i?r+e+l:">"===i?l+r+e:"^"===i?l.substring(0,a>>=1)+r+e+l.substring(a):r+(t?e:l+e))+m},string:function(t,e){for(var n,i="{",r=!1,o=[];-1!==(n=t.indexOf(i));){if(l=t.slice(0,n),r){for(var s,a=(s=l.split(":")).shift().split("."),l=e,h=0;h<a.length;h++)l=l[a[h]];s.length&&(l=this.number(s,l))}o.push(l),t=t.slice(n+1),i=(r=!r)?"}":"{"}return o.push(t),o.join("")},convert:function(t,e,n){switch(t){case"b":return e.toString(2);case"c":return String.fromCharCode(e);case"o":return e.toString(8);case"x":return e.toString(16);case"X":return e.toString(16).toUpperCase();case"g":return e.toPrecision(n);case"e":return e.toExponential(n);case"f":return e.toFixed(n);case"r":return(e=this.round(e,this.precision(e,n))).toFixed(Math.max(0,Math.min(20,this.precision(e*(1+1e-15),n))));default:return e+""}},round:function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},precision:function(t,e){return e-(t?Math.ceil(Math.log(t)/Math.LN10):1)},prefix:function(t,e){var n=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(function(t,e){var n=Math.pow(10,3*Math.abs(8-e));return{scale:8<e?function(t){return t/n}:function(t){return t*n},symbol:t}}),i=0;return t&&(t<0&&(t*=-1),e&&(t=this.round(t,this.precision(t,e))),i=1+Math.floor(1e-12+Math.log(t)/Math.LN10),i=Math.max(-24,Math.min(24,3*Math.floor((i<=0?i+1:i-1)/3)))),n[8+i/3]}};let bl=function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(i){return i=i||{},t.replace(e,function(t){for(var e=Array.from(arguments).slice(1,4).find(function(t){return!!t}).split("."),n=i[e.shift()];void 0!==n&&e.length;)n=n[e.shift()];return void 0!==n?n:""})}};function xl(t,e,n){var{maxDepth:n=Number.POSITIVE_INFINITY}=n||{};return function o(s,a,l,h){if(l===h)return{};let u={};return Object.keys(s).forEach(t=>{var e,n,i=s[t],r=a[t];!Array.isArray(i)&&!Array.isArray(r)&&w(i)&&w(r)?(n=o(i,r,e=l+1,h),0<Object.keys(n).length?u[t]=n:0!==l&&e!==h||(u[t]={})):na(i,r)||(u[t]=i)}),u}(t,e,0,n)}function wl(){}function Al(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=Al(t,e,o[s],n[o[s]],r)}else if(n&&kl.test(n))for(o=n.split(kl);s<o.length;s++)e=t(e,o[s],i,r);else e=t(e,n,i,r);return e}function Pl(t,e){var n=this,i=t&&da(t,"constructor")?t.constructor:function(){return n.apply(this,arguments)};return T(i,n,e),i.prototype=Object.assign(Object.create(n.prototype),t),(i.prototype.constructor=i).__super__=n.prototype,i}function El(t,e){var t=t||{},n=(e=e||{},this.preinitialize.apply(this,arguments),this.cid=fa(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection),S(this,"defaults")),t=Ws(T({},n,t),n);this.set(t,e),this.changed={},this.initialize.apply(this,arguments)}var Tl,Sl={},kl=/\s+/,Ll=(Sl.on=function(t,e,n){return this._events=Al(Ll,this._events||{},t,e,{context:n,ctx:this,listening:Tl}),Tl&&(((this._listeners||(this._listeners={}))[Tl.id]=Tl).interop=!1),this},Sl.listenTo=function(t,e,n){if(t){var i=t._listenId||(t._listenId=fa("l")),r=this._listeningTo||(this._listeningTo={}),o=Tl=r[i],r=(o||(this._listenId||(this._listenId=fa("l")),o=Tl=r[i]=new Fl(this,t)),Cl(t,e,n,this));if(Tl=void 0,r)throw r;o.interop&&o.on(e,n)}return this},function(t,e,n,i){var r,o;return n&&(e=t[e]||(t[e]=[]),r=i.context,o=i.ctx,(i=i.listening)&&i.count++,e.push({callback:n,context:r,ctx:r||o,listening:i})),t}),Cl=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}},Ml=(Sl.off=function(t,e,n){return this._events&&(this._events=Al(Ml,this._events,t,e,{context:n,listeners:this._listeners})),this},Sl.stopListening=function(t,e,n){var i=this._listeningTo;if(i){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)}ea(i)&&(this._listeningTo=void 0)}return this},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 h=[],u=0;u<l.length;u++){var c=l[u];n&&n!==c.callback&&n!==c.callback._callback||o&&o!==c.context?h.push(c):(c=c.listening)&&c.off(e,n)}h.length?t[e]=h:delete t[e]}return t}if(null!=s)for(r=Object.keys(s);a<r.length;a++)s[r[a]].cleanup()}}),_l=(Sl.once=function(t,e,n){var i=Al(_l,{},t,e,this.off.bind(this));return this.on(i,e="string"==typeof t&&null==n?void 0:e,n)},Sl.listenToOnce=function(t,e,n){e=Al(_l,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,e)},function(t,e,n,i){var r;return n&&((r=t[e]=Nl(function(){i(e,r),n.apply(this,arguments)}))._callback=n),t}),Nl=function(t){var e;if("function"!=typeof t)throw new TypeError("Expected a function");var n=2;return function(){return 0<--n&&(e=t.apply(this,arguments)),n<=1&&(t=void 0),e}},Ol=(Sl.trigger=function(t){if(this._events){for(var e=Math.max(0,arguments.length-1),n=Array(e),i=0;i<e;i++)n[i]=arguments[i+1];Al(Ol,this._events,t,void 0,n)}return this},function(t,e,n,i){var r,o;return t&&(r=t[e],o=t.all,r&&(o=o&&o.slice()),r&&Rl(r,i),o)&&Rl(o,[e].concat(i)),t}),Rl=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}},Fl=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0},Il=(Fl.prototype.on=Sl.on,Fl.prototype.off=function(t,e){t=this.interop?(this._events=Al(Ml,this._events,t,e,{context:void 0,listeners:void 0}),!this._events):(this.count--,0===this.count);t&&this.cleanup()},Fl.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},Sl.bind=Sl.on,Sl.unbind=Sl.off,function(i,t,r,o){switch(t){case 1:return function(){return i[r](this[o])};case 2:return function(t){return i[r](this[o],t)};case 3:return function(t,e){return i[r](this[o],Vl(t,this),e)};case 4:return function(t,e,n){return i[r](this[o],Vl(t,this),e,n)};default:return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(this[o]),i[r].apply(i,t)}}}),Vl=function(e,t){return b(e)?e:w(e)&&!t._isModel(e)?Bl(e):E(e)?function(t){return t.get(e)}:e},Bl=function(t){t=t;var e=Ps(is(t,!0));return function(t){return e(t.attributes)}};function Dl(t){t=Qs(t);let r=et(t).reduce(function(t,e){return t[e.id]=e.clone(),t},{});return et(t).forEach(function(t){var e=r[t.id],n=(e.isLink()&&(n=e.source(),i=e.target(),n.id&&r[n.id]&&e.prop("source/id",r[n.id].id),i.id)&&r[i.id]&&e.prop("target/id",r[i.id].id),t.get("parent")),i=(n&&r[n]&&e.set("parent",r[n].id),et(t.get("embeds")).reduce(function(t,e){return r[e]&&t.push(r[e].id),t},[]));ea(i)||e.set("embeds",i)}),r}T(El.prototype,Sl,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return f(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){var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,!this._validate(i,n=n||{}))return!1;var r,o,s=n.unset,t=n.silent,a=[],l=this._changing,h=(this._changing=!0,l||(this._previousAttributes=f(this.attributes),this.changed={}),this.attributes),u=this.changed,c=this._previousAttributes;for(r in i)e=i[r],na(h[r],e)||a.push(r),na(c[r],e)?delete u[r]:u[r]=e,s?delete h[r]:h[r]=e;if(this.idAttribute in i&&(o=this.id,this.id=this.get(this.idAttribute),this.trigger("changeId",this,o,n)),!t){a.length&&(this._pending=n);for(var d=0;d<a.length;d++)this.trigger("change:"+a[d],this,h[a[d]],n)}if(!l){if(!t)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);this._pending=!1,this._changing=!1}}return this},unset:function(t,e){return this.set(t,void 0,T({},e,{unset:!0}))},clear:function(t){var e,n={};for(e in this.attributes)n[e]=void 0;return this.set(n,T({},t,{unset:!0}))},hasChanged:function(t){return null==t?!ea(this.changed):da(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&f(this.changed);var e,n,i=this._changing?this._previousAttributes:this.attributes,r={};for(n in t){var o=t[n];na(i[n],o)||(r[n]=o,e=!0)}return!!e&&r},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return f(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},T({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=T({},this.attributes,t);t=this.validationError=this.validate(t,e)||null;return!t||(this.trigger("invalid",this,t,T(e,{validationError:t})),!1)}}),El.extend=Pl;let zl=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce((t,e)=>(t[e]=!0,t),{});u={qualify:function(t){return y(t)},set:function(e,t,i){Object.keys(e).forEach(function(t){if(zl[t]&&t in i){let n=e[t];"SELECT"===i.tagName&&Array.isArray(n)?Array.from(i.options).forEach(function(t,e){t.selected=n.includes(t.value)}):i[t]=n}})}};function jl(r,o,s){return function(t,e){var n,i=ll(t),i=(t=parseFloat(t),i&&(t/=100),isFinite(t)&&(n=e[s](),n=i||0<t&&t<1?n[r]+e[o]*t:n[r]+t),A());return i[r]=n||0,i}}function Gl(r,o){return function(t,e){var n=ll(t),i=(t=parseFloat(t),n&&(t/=100),{});return isFinite(t)&&(n=n||0<=t&&t<=1?t*e[o]:Math.max(t+e[o],0),i[r]=n),i}}var Ul,Hl,l={"ref-x":{position:jl("x","width","origin")},"ref-y":{position:jl("y","height","origin")},"ref-dx":{position:jl("x","width","corner")},"ref-dy":{position:jl("y","height","corner")},"ref-width":{set:Gl("width","width")},"ref-height":{set:Gl("height","height")},"ref-rx":{set:Gl("rx","width")},"ref-ry":{set:Gl("ry","height")},"ref-cx":{set:Gl("cx","width")},"ref-cy":{set:Gl("cy","height")},"ref-r-inscribed":{set:(Ul=Gl("r","width"),Hl=Gl("r","height"),function(t,e){return(e.height>e.width?Ul:Hl)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n,i=ll(t),e=(t=parseFloat(t),i&&(t/=100),Math.sqrt(e.height*e.height+e.width*e.width));return{r:n=isFinite(t)?i||0<=t&&t<=1?t*e:Math.max(t+e,0):n}}}};l.refX=l["ref-x"],l.refY=l["ref-y"],l["ref-x2"]=l["ref-x"],l["ref-y2"]=l["ref-y"],l["ref-width2"]=l["ref-width"],l["ref-height2"]=l["ref-height"],l["ref-r"]=l["ref-r-inscribed"];let ql={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"};i=Object.keys(ql).map(t=>ql[t]).join(""),s="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?";let $l=/\s/g,Wl=new RegExp(`^(${s}\\*)?([${i}])(/${s})?([-+]{1,2}${s})?$`,"g");function Yl(t){throw new Error("Invalid calc() expression: "+t)}function Xl(t,e){var n=Wl.exec(t.replace($l,"")),[,t,n,i,r]=(n||Yl(t),Wl.lastIndex=0,n),{x:o,y:s,width:a,height:l}=e;let h=0;switch(n){case ql.width:h=a;break;case ql.height:h=l;break;case ql.x:h=o;break;case ql.y:h=s;break;case ql.minimum:h=Math.min(l,a);break;case ql.maximum:h=Math.max(l,a);break;case ql.diagonal:h=Math.sqrt(l*l+a*a)}return t&&(h*=parseFloat(t)),i&&(h/=parseFloat(i.slice(1))),r&&(h+=(t=>{if(!t)return 0;var[e]=t;switch(e){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)})(r)),h}function Zl(t){return"string"==typeof t&&t.includes("calc")}let Jl="calc(",Kl=Jl.length;function Ql(t,i){let r=t,o=0;for(;;){var s=r.indexOf(Jl,o);if(-1===s)return r;let t=s+Kl,e=1;t:for(;;){switch(r[t]){case"(":e++;break;case")":if(0===--e)break t;break;case void 0:Yl(r)}t++}let n=r.slice(s+Kl,t);Zl(n)&&(n=Ql(n,i));var a=String(Xl(n,i));r=r.slice(0,s)+a+r.slice(t+1),o=s+a.length}}function th(t,e,n){return void 0!==n.text}let eh=["font-weight","font-family","font-size","letter-spacing","text-transform"],nh={"line-height":{qualify:th},"text-vertical-anchor":{qualify:th},"text-path":{qualify:th},annotations:{qualify:th},eol:{qualify:th},"display-empty":{qualify:th},text:{qualify:function(t,e,n){n=n["text-wrap"];return!n||!y(n)},unset:function(t){t.textContent=""},set:function(t,e,n,i){var r="joint-text",o=L.data.get(n,r),s=i["line-height"],a=i["text-vertical-anchor"],l=i["display-empty"],h=i["font-size"],u=i.annotations,c=i.eol,d=i.x;let f=i["text-path"];i=JSON.stringify([t,s,u,a,c,l,f,d,h]);void 0!==o&&o===i||(h&&n.setAttribute("font-size",h),w(f)&&"string"==typeof(o=f.selector)&&(h=this.findNode(o))instanceof SVGPathElement&&(f=T({"xlink:href":"#"+h.id},f)),R(n).text(""+t,{lineHeight:s,annotations:u,textPath:f,x:d,textVerticalAnchor:a,eol:c,displayEmpty:l}),L.data.set(n,r,i))}},"text-wrap":{qualify:y,set:function(t,e,n,i){var r={},o=t.width||0,o=(ll(o)?r.width=e.width*parseFloat(o)/100:Zl(o)?r.width=Number(Ql(o,e)):null===t.width?r.width=1/0:r.width=o<=0?e.width+o:o,t.height||0),o=(ll(o)?r.height=e.height*parseFloat(o)/100:Zl(o)?r.height=Number(Ql(o,e)):null!==t.height&&(r.height=o<=0?e.height+o:o),t.text);if(void 0!==(o=void 0===o?i.text:o)){var s=t.breakText||cl,a=getComputedStyle(n),l={};for(let t=0;t<eh.length;t++){var h=eh[t];h in i&&n.setAttribute(h,i[h]),l[h]=a[h]}l.lineHeight=i["line-height"],s=s(""+o,r,l,{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,separator:t.separator,maxLineCount:t.maxLineCount,preserveSpaces:t.preserveSpaces})}else s="";nh.text.set.call(this,s,e,n,i)},FONT_ATTRIBUTES:eh},title:{qualify:function(t,e){return e instanceof SVGElement},unset:function(t){L.data.remove(t,"joint-title");t=t.firstElementChild;t&&t.remove()},set:function(t,e,n){var i="joint-title",r=L.data.get(n,i);void 0!==r&&r===t||(L.data.set(n,i,t),"title"===n.tagName?n.textContent=t:(r=n.firstElementChild)&&"title"===r.tagName?r.textContent=t:((i=document.createElementNS(n.namespaceURI,"title")).textContent=t,n.insertBefore(i,r)))}}};function ih(i,r){var o=new A(1,0);return function(t){var e,n,t=this[i](t);return t?(n=r.rotate?t.vector().vectorAngle(o):0,e=t.start):(e=this.path.start,n=0),0===n?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+n+")"}}}function rh(){return this.model.isLink()}Ln={connection:{qualify:rh,unset:"d",set:function(e){var{stubs:e=0}=e;let n;if(isFinite(e)&&0!==e){let t;t=e<0?(this.getConnectionLength()+e)/2:e;var e=this.getConnection(),i=this.getConnectionSubdivisions(),r=e.divideAtLength(t,{segmentSubdivisions:i}),e=e.divideAtLength(-t,{segmentSubdivisions:i});r&&e&&(n=r[0].serialize()+" "+e[1].serialize())}return{d:n||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:rh,unset:"transform",set:ih("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:rh,unset:"transform",set:ih("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:rh,unset:"transform",set:ih("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:rh,unset:"transform",set:ih("getTangentAtRatio",{rotate:!1})}};function oh(s,t){var a="joint-shape",l=t&&t.resetOffset;return function(t,e,n){var i=L.data.get(n,a),t=(i&&i.value===t||(i={value:t,shape:t=s(t),shapeBBox:t.bbox()},L.data.set(n,a,i)),i.shape.clone()),n=i.shapeBBox.clone(),i=n.origin(),r=e.origin(),r=(n.x=r.x,n.y=r.y,e.maxRectScaleToFit(n,r)),o=0===n.width||0===e.width?1:r.sx,n=0===n.height||0===e.height?1:r.sy;return t.scale(o,n,i),l&&t.translate(-i.x,-i.y),t}}function sh(t){var i=oh(function(t){return new V(R.normalizePathData(t))},t);return function(t,e,n){return{d:i(t,e,n).serialize()}}}function ah(t){var i=oh(x,t);return function(t,e,n){return{points:i(t,e,n).serialize()}}}Ln["at-connection-length"]=Ln["at-connection-length-keep-gradient"],Ln["at-connection-ratio"]=Ln["at-connection-ratio-keep-gradient"];a={"ref-d-reset-offset":{unset:"d",set:sh({resetOffset:!0})},"ref-d-keep-offset":{unset:"d",set:sh({resetOffset:!1})},"ref-points-reset-offset":{unset:"points",set:ah({resetOffset:!0})},"ref-points-keep-offset":{unset:"points",set:ah({resetOffset:!1})}};function lh(t){var e={},n=t.stroke,n=("string"==typeof n&&(e.stroke=n,e.fill=n),t["stroke-opacity"]);return void 0!==(n=void 0===n?t.opacity:n)&&(e["stroke-opacity"]=n,e["fill-opacity"]=n),e}function hh(t){var e=this.paper;return`url(#${"pattern"===t.type?e.definePattern(t):e.defineGradient(t)})`}a["ref-d"]=a["ref-d-reset-offset"],a["ref-points"]=a["ref-points-reset-offset"];Je={"source-marker":{qualify:y,unset:"marker-start",set:function(t,e,n,i){return t=T(lh(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:y,unset:"marker-end",set:function(t,e,n,i){return t=T(lh(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:y,unset:"marker-mid",set:function(t,e,n,i){return t=T(lh(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:y,set:hh},stroke:{qualify:y,set:hh},filter:{qualify:y,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}};function uh(i,r,o){return function(t,e){var t="middle"===t?e[r]/2:t===o?e[r]:isFinite(t)?-1<t&&t<1?-e[r]*t:-t:ll(t)?e[r]*parseFloat(t)/100:0,n=new A;return n[i]=-(e[i]+t),n}}e={"x-alignment":{offset:uh("x","width","right")},"y-alignment":{offset:uh("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}};function ch(i){return function(t,e,n){n=R(n);n.attr(i)!==t&&n.attr(i,t)}}r={ref:{},href:{set:ch("href")},"xlink:href":{set:ch("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:y,set:function(t,e,n){L(n).css(t)}},html:{unset:function(t){L(t).empty()},set:function(t,e,n){L(n).html(t+"")}},props:u};T(r,l),T(r,nh),T(r,Ln),T(r,a),T(r,Je),T(r,e);function dh(t,e){if(Array.isArray(t))return e}let fh=r;function ph(t){for(var e in t){var n=t[e];w(n)&&!Array.isArray(n)&&ea(n)&&delete t[e]}}let gh=El.extend({constructor:function(t,e){var n,i,t=t||{};"function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=fa("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(t=this.parse(t,e)||{}),(n=S(this,"defaults"))&&(i=(!e||!0!==e.mergeArrays)&&dh,t=k({},n,t,i)),this.set(t,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(t){var{ignoreDefaults:t,ignoreEmptyAttributes:e=!1}=t||{};let n=S(this.constructor.prototype,"defaults");if(!1===t){let t=ta(this.attributes);return e&&ph(t),t}let i={};var r=ta(this.attributes);!0===t?i=n:(Array.isArray(t)?t:["attrs"]).forEach(t=>{i[t]=n[t]||{}});let o=xl(r,ua(i,"id","type"),{maxDepth:4});return e&&ph(o),o},initialize:function(t){var 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:Qa,processPorts:function(){var t=this.ports,n={},i=(pa(this.get("attrs"),function(t,e){t&&t.port&&(void 0!==t.port.id?n[t.port.id]=t.port:n[t.port]={id:t.port})}),{});pa(t,function(t,e){n[e]||(i[e]=!0)}),this.graph&&!ea(i)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach(function(t){i[t.get("target").port]&&t.remove()}),this.graph.getConnectedLinks(this,{outbound:!0}).forEach(function(t){i[t.get("source").port]&&t.remove()})),this.ports=n},remove:function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},{graph:t,collection:e}=this;if(t){t.startBatch("remove");var i=this.getParentCell(),r=(i&&i.unembed(this,n),this.getEmbeddedCells());for(let t=0,e=r.length;t<e;t++){var o=r[t];o&&o.remove(n)}this.trigger("remove",this,t.attributes.cells,n),t.stopBatch("remove")}else e&&e.remove(this,n);return this},toFront:function(i){var r=this.graph;if(r){let t;(i=Ws(i||{},{foregroundEmbeds:!0})).deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==i.breadthFirst,sortSiblings:i.foregroundEmbeds})).unshift(this):t=[this];var o=i.foregroundEmbeds?t:ra(t,t=>t.z());let n=r.maxZIndex()-t.length+1;r=r.get("cells");let e=r.toArray().indexOf(o[0])!==r.length-t.length;(e=e||o.some(function(t,e){return t.z()!==n+e}))&&(this.startBatch("to-front"),n+=t.length,o.forEach(function(t,e){t.set("z",n+e,i)}),this.stopBatch("to-front"))}return this},toBack:function(r){var o=this.graph;if(o){let t;(r=Ws(r||{},{foregroundEmbeds:!0})).deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==r.breadthFirst,sortSiblings:r.foregroundEmbeds})).unshift(this):t=[this];var s=r.foregroundEmbeds?t:ra(t,t=>t.z());let n=o.minZIndex(),e=o.get("cells"),i=0!==e.toArray().indexOf(s[0]);(i=i||s.some(function(t,e){return t.z()!==n+e}))&&(this.startBatch("to-back"),n-=t.length,s.forEach(function(t,e){t.set("z",n+e,r)}),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){let e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=Array.isArray(t)?t:[t];if(!this.canEmbed(n))throw new Error("Recursive embedding not allowed.");if(e.reparent)Qs(n.map(t=>t.getParentCell())).forEach(t=>{t&&t._unembedCells(n,e)});else 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){t=Array.isArray(t)?t:[t];return this._unembedCells(t,e),this},canEmbed:function(t){return(Array.isArray(t)?t:[t]).every(t=>this!==t&&!this.isEmbeddedIn(t))},_embedCells:function(t,e){this.startBatch("embed");let n=T([],this.get("embeds"));t.forEach(t=>{n[t.isLink()?"unshift":"push"](t.id),t.parent(this.id,e)}),this.set("embeds",Qs(n),e),this.stopBatch("embed")},_unembedCells:function(t,e){this.startBatch("unembed"),t.forEach(t=>t.unset("parent",e)),this.set("embeds",oa(this.get("embeds"),...t.map(t=>t.id)),e),this.stopBatch("unembed")},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(this.graph)for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(!this.graph)return[];if((t=t||{}).deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);var e=this.get("embeds");if(ea(e))return[];let n=e.map(this.graph.getCell,this.graph);return n=t.sortSiblings?ra(n,t=>t.z()):n},_getEmbeddedCellsBfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.shift(),i=(e.push(i),i.getEmbeddedCells({sortSiblings:t}));n.push(...i)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.pop(),r=(e.push(i),i.getEmbeddedCells({sortSiblings:t}));for(let t=r.length-1;0<=t;--t)n.push(r[t])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=E(t)?t:t.id,i=this.parent();if(e=T({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){return(t=t||{}).deep?et(Dl([this].concat(this.getEmbeddedCells({deep:!0})))):((t=El.prototype.clone.apply(this,arguments)).set(this.getIdAttribute(),this.generateId()),t.unset("embeds"),t.unset("parent"),t)},prop:function(e,n,i){var r=E(e);if(r||Array.isArray(e)){if(1<arguments.length){var o=r?(p=e).split("/"):(p=e.join("/"),e.slice()),s=o[0],a=o.length;let t=i||{};t.propertyPath=p,t.propertyValue=n,t.propertyPathArray=o,"rewrite"in t||(t.rewrite=!1);for(var l=i={},h=s,u=1;u<a;u++)var c=o[u],d=Number.isFinite(r?Number(c):c),l=l[h]=d?[]:{},h=c;var i=Za(i,o,n,"/"),f=k({},this.attributes),p=(t.rewrite&&Ja(f,p,"/"),k(f,i));return this.set(s,p[s],t)}return Ya(this.attributes,e,"/")}let t=n||{};t.propertyPath=null,t.propertyValue=e,t.propertyPathArray=[],"rewrite"in t||(t.rewrite=!1);var g,m={};for(g in e){var v=k({},{changedValue:this.attributes[g]},{changedValue:e[g]}).changedValue;m[g]=v}return this.set(m,t)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];return"attrs"===i&&(e.dirty=!0),1===n.length?this.unset(t,e):(t=n.slice(1),null==(n=this.get(i))?this:(n=ta(n),Ja(n,t,"/"),this.set(i,n,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):E(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(n,e,i,r){r=r||"/";var o,t={duration:100,delay:10,timingFunction:ml.linear,valueFunction:vl.number},s=(i=T(t,i),0),a=function(t){var e;(t=(t-=s=s||t)/i.duration)<1?this._transitionIds[n]=e=sl(a):(t=1,delete this._transitionIds[n]),t=o(i.timingFunction(t)),i.transitionId=e,this.prop(n,t,i),e||this.trigger("transition:end",this,n)}.bind(this);let l=this._scheduledTransitionIds,h;return h=setTimeout(t=>{l[n]&&(l[n]=oa(l[n],h),0===l[n].length)&&delete l[n],this.stopPendingTransitions(n,r),o=i.valueFunction(Ya(this.attributes,n,r),e),this._transitionIds[n]=sl(t),this.trigger("transition:start",this,n)},i.delay,a),l[n]||(l[n]=[]),l[n].push(h),h},getTransitions:function(){return ha(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"/",{_scheduledTransitionIds:e={}}=this,i=Object.keys(e);if(t){let e=t.split(n);i=i.filter(t=>na(e,t.split(n).slice(0,e.length)))}return i.forEach(t=>{e[t].forEach(t=>clearTimeout(t)),delete e[t]}),this},stopPendingTransitions(t){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"/",{_transitionIds:i={}}=this,r=Object.keys(i);if(t){let e=t.split(n);r=r.filter(t=>na(e,t.split(n).slice(0,e.length)))}r.forEach(t=>{var e=i[t];al(e),delete i[t],this.trigger("transition:end",this,t)})},stopTransitions:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"/";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,T({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,T({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(t)for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new A(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new A},getBBox:function(){return new tt(0,0,0,0)},getPointRotatedAroundCenter(t,e,n){e=new A(e,n);return t&&e.rotate(this.getBBox().center(),t),e},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=fh;return e&&e[t]||n[t]},define:function(t,e,n,i){n=T({defaults:Js({type:t},e,this.prototype.defaults)},n);e=this.extend(n,i);return"undefined"!=typeof joint&&da(joint,"shapes")&&Za(joint.shapes,t,e,"."),e}});function mh(e,t,n){if(E(n)){if(!vh[n])throw new Error('Unknown wrapper: "'+n+'"');n=vh[n]}if(!b(n))throw new Error("Wrapper must be a function.");et(t).forEach(function(t){e[t]=n(e[t])})}let vh={cells:function(i){return function(){var t=Array.from(arguments),e=t.length,n=0<e&&t[0]||[],e=1<e&&t[e-1]||{};return Array.isArray(n)||(e instanceof gh?n=t:n instanceof gh&&(1<t.length&&t.pop(),n=t)),e instanceof gh&&(e={}),i.call(this,n,e)}}};let p={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 yh(t,e){var n=new tt(t);switch(e){case void 0:throw new Error("Position required");case p.LEFT:case"leftMiddle":return n.leftMiddle();case p.RIGHT:case"rightMiddle":return n.rightMiddle();case p.TOP:case"topMiddle":return n.topMiddle();case p.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case p.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case p.TOP_RIGHT:case"topRight":return n.topRight();case p.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case p.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case p.CENTER:return n.center();default:throw new Error("Unknown position: "+e)}}hn={getRectPoint:yh,wrapWith:mh,wrappers:vh,addClassNamePrefix:ja,removeClassNamePrefix:function(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,Ua.classNamePrefix.length)===Ua.classNamePrefix?t.substr(Ua.classNamePrefix.length):t}).join(" ")},parseDOMJSON:$a,hashCode:Wa,getByPath:Ya,setByPath:Za,unsetByPath:Ja,flattenObject:Ka,uuid:Qa,guid:tl,toKebabCase:function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},normalizeEvent:C,normalizeWheel:il,cap:rl,nextFrame:sl,cancelFrame:al,isPercentage:ll,parseCssNumeric:ol,breakText:cl,sanitizeHTML:function(t){var[t]=L.parseHTML("<div>"+t+"</div>");return Array.from(t.getElementsByTagName("*")).forEach(function(n){n.getAttributeNames().forEach(function(t){var e=n.getAttribute(t);(t.startsWith("on")||e.startsWith("javascript:"))&&n.removeAttribute(t)})}),t.innerHTML},downloadBlob:dl,downloadDataUri:function(t,e){t=fl(t);dl(t,e)},dataUriToBlob:fl,imageToDataUri:function(i,r){if(!i||"data:"===i.substr(0,"data:".length))return setTimeout(function(){r(null,i)},0);function o(t,e){var n;200===t.status?(t=new Uint8Array(t.response),e(null,"data:image/"+({svg:"svg+xml"}[n=i.split(".").pop()||"png"]||n)+";base64,"+btoa((t=>{for(var e=[],n=0;n<t.length;n+=32768)e.push(String.fromCharCode.apply(null,t.subarray(n,n+32768)));return e.join("")})(t)))):e(new Error("Failed to load image "+i))}var s=new XMLHttpRequest;s.open("GET",i,!0),s.addEventListener("error",function(){r(new Error("Failed to load image "+i))}),s.responseType=window.FileReader?"blob":"arraybuffer",s.addEventListener("load",function(){var t,e,n;window.FileReader?(e=r,200===(t=s).status?((n=new FileReader).onload=function(t){t=t.target.result;e(null,t)},n.onerror=function(){e(new Error("Failed to load image "+i))},n.readAsDataURL(t.response)):e(new Error("Failed to load image "+i))):o(s,r)}),s.send()},getElementBBox:function(t){t=L(t);if(0===t.length)throw new Error("Element not found");var t=t[0],e=t.ownerDocument,n=t.getBoundingClientRect(),i=0,r=0;return t.ownerSVGElement&&(t=(t=R(t)).getBBox({target:t.svg()}),i=n.width-t.width,r=n.height-t.height),{x:n.left+window.pageXOffset-e.documentElement.offsetLeft+i/2,y:n.top+window.pageYOffset-e.documentElement.offsetTop+r/2,width:n.width-i,height:n.height-r}},sortElements:pl,setAttributesBySelector:function(t,e){var n=L(t);pa(e,function(t,e){e=n.find(e).addBack().filter(e);da(t,"class")&&(e.addClass(t.class),t=ua(t,"class")),e.attr(t)})},normalizeSides:gl,timing:ml,interpolate:vl,filter:yl,format:h,template:bl,toggleFullScreen:function(t){var e=window.top.document;function n(t,e){for(var n=["webkit","moz","ms","o",""],i=0;i<n.length;i++){var r=n[i],r=r?r+e:e.substr(0,1).toLowerCase()+e.substr(1);if(void 0!==t[r])return b(t[r])?t[r]():t[r]}}t=t||e.body,n(e,"FullscreenElement")||n(e,"FullScreenElement")?n(e,"ExitFullscreen")||n(e,"CancelFullScreen"):n(t,"RequestFullscreen")||n(t,"RequestFullScreen")},objectDifference:xl,isBoolean:Hs,isObject:w,isNumber:qs,isString:E,mixin:n,deepMixin:$e,supplement:$s,defaults:Ws,deepSupplement:Ys,defaultsDeep:Js,assign:T,invoke:Xs,invokeProperty:Zs,sortedIndex:Ks,uniq:Qs,clone:f,cloneDeep:ta,isEmpty:ea,isEqual:na,isFunction:b,isPlainObject:y,toArray:et,debounce:ia,groupBy:sa,sortBy:ra,flattenDeep:aa,without:oa,difference:la,intersection:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.map(t=>mo(t)&&Po(t)?t:[]);return i.length&&i[0]===e[0]?(t=>{var e=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),n=(t,e)=>t.has(e),i=t[0].length,r=t.length,o=new Array(r),s=[];let a,l=1/0,h=r;for(;h--;)a=t[h],l=Math.min(a.length,l),o[h]=120<=i&&120<=a.length?new Us(h&&a):void 0;a=t[0];let u=-1;var c=o[0];t:for(;++u<i&&s.length<l;){var d=f=a[u],f=0!==f?f:0;if(!(c?n(c,d):e(s,d))){for(h=r;--h;){var p=o[h];if(!(p?n(p,d):e(t[h],d)))continue t}c&&c.push(d),s.push(f)}}return s})(i):[]},union:ha,has:da,result:S,omit:ua,pick:ca,bindAll:function(e){for(var t=arguments.length,n=new Array(1<t?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return n.flat(1).forEach(t=>{t=ns(t),wo(e,t,e[t].bind(e))}),e},forIn:pa,camelCase:ga,uniqueId:fa,merge:k,noop:wl,cloneCells:Dl,svg:function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];let r=[];t.forEach((t,e)=>{r.push(t),e in n&&r.push(n[e])});var t=r.join(""),o=new DOMParser,t=`<svg>${t.trim()}</svg>`,s=o.parseFromString(t.replace(/@/g,""),"application/xml");if(s.getElementsByTagName("parsererror")[0])throw new Error("Invalid SVG markup");o=(s=o.parseFromString(t,"text/html")).querySelector("svg");{t=o;let e=[];return Array.from(t.children).forEach(t=>{e.push(function t(e){let n={};let{tagName:i,attributes:r,namespaceURI:o,style:s,childNodes:a}=e;n.namespaceURI=o;n.tagName=o===R.namespace.xhtml?i.toLowerCase():i;let l={};for(var h=s.length;h--;){var u=s[h];l[u]=s.getPropertyValue(u)}n.style=l;let c=r.getNamedItem("@selector");c&&(n.selector=c.value,r.removeNamedItem("@selector"));let d=r.getNamedItem("@group-selector");if(d){let t=d.value.split(",");n.groupSelector=t.map(t=>t.trim()),r.removeNamedItem("@group-selector")}let f=r.getNamedItem("class");f&&(n.className=f.value);let p=[];a.forEach(e=>{switch(e.nodeType){case Node.TEXT_NODE:{let t=e.data.replace(/\s\s+/g," ");t.trim()&&p.push(t);break}case Node.ELEMENT_NODE:p.push(t(e))}});p.length&&(n.children=p);let g={};Array.from(r).forEach(t=>{let{name:e,value:n}=t;g[e]=n});0<Object.keys(g).length&&(n.attributes=g);return n}(t))}),e}},evalCalcFormula:Xl,isCalcExpression:Zl,evalCalcExpression:Ql};function bh(t,e,n){t=t.toJSON();return t.angle=e||0,Ws({},n,t)}function xh(t,e,n,i){return t.map(function(t,e,n){e=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&e.offset(t.dx||0,t.dy||0),bh(e.round(),0,Ah(i,t))},pi(e,n))}function wh(t,i,r,o){var s=i.center(),a=i.width/i.height,l=i.topMiddle(),h=yi.fromRect(i);return t.map(function(t,e,n){e=r+o(e,n.length),n=l.clone().rotate(s,-e).scale(a,1,s),e=t.compensateRotation?-h.tangentTheta(n):0;return(t.dx||t.dy)&&n.offset(t.dx||0,t.dy||0),t.dr&&n.move(s,t.dr),bh(n.round(),e,Ah(i,t))})}function Ah(t,e){let{x:n,y:i,angle:r}=e;return ll(n)?n=parseFloat(n)/100*t.width:Zl(n)&&(n=Number(Ql(n,t))),ll(i)?i=parseFloat(i)/100*t.height:Zl(i)&&(i=Number(Ql(i,t))),{x:n,y:i,angle:r}}function Ph(t,e){var{x:t,y:e}=Ah(t,e);return new A(t||0,e||0)}var Eh={absolute:function(t,n){return t.map(t=>{var e=Ph(n,t).round().toJSON();return e.angle=t.angle||0,e})},fn:function(t,e,n){return n.fn(t,e,n)},line:function(t,e,n){return xh(t,Ph(e,n.start||e.origin()),Ph(e,n.end||e.corner()),e)},left:function(t,e,n){return xh(t,e.origin(),e.bottomLeft(),e)},right:function(t,e,n){return xh(t,e.topRight(),e.corner(),e)},top:function(t,e,n){return xh(t,e.origin(),e.topRight(),e)},bottom:function(t,e,n){return xh(t,e.bottomLeft(),e.corner(),e)},ellipseSpread:function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return wh(t,e,i,function(t){return t*r})},ellipse:function(t,e,n){var i=n.startAngle||0,r=n.step||20;return wh(t,e,i,function(t,e){return(t+.5-e/2)*r})}};function Th(t,e){return Js({},t,e,{x:0,y:0,angle:0,attrs:{}})}function Sh(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 kh(t,e,n,i){i=Ws({},i,{offset:15});var r,o,s,a,t=e.center().theta(t),l=i.offset,h=0,[e,u,c,d]=Sh(e),u=(t<u||c<t?(s=".3em",r=l,o=0,a="start"):t<e?(r=0,o=-l,s=n?(h=-90,a="start",".3em"):(a="middle","0")):t<d?(s=".3em",r=-l,o=0,a="end"):(r=0,o=l,s=n?(h=90,a="start",".3em"):(a="middle",".6em")),Math.round);return Th(i,{x:u(r),y:u(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Lh(t,e,n,i){i=Ws({},i,{offset:15});var r,o,s,a,t=e.center().theta(t),l=i.offset,h=0,[e,u,c,d]=Sh(e),u=(t<u||c<t?(s=".3em",r=-l,o=0,a="end"):t<e?(r=0,o=l,s=n?(h=90,a="start",".3em"):(a="middle",".6em")):t<d?(s=".3em",r=l,o=0,a="start"):(r=0,o=-l,s=n?(h=-90,a="start",".3em"):(a="middle","0")),Math.round);return Th(i,{x:u(r),y:u(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Ch(t,e,n){n=Ws({},n,{offset:20});var i,r=ci(0,0),o=-t.theta(r),s=o,r=t.clone().move(r,n.offset).difference(t).round(),t=".3em",o=((90+o)%180==0?(i=e?"end":"middle",e||-270!=o||(t="0em")):-270<o&&o<-90?(i="start",s=o-180):i="end",Math.round);return Th(n,{x:o(r.x),y:o(r.y),angle:e?s:0,attrs:{labelText:{y:t,textAnchor:i}}})}function Mh(t){t=ta(t)||{},this.ports=[],this.groups={},this.portLayoutNamespace=Eh,this.portLabelLayoutNamespace=_h,this._init(t)}var _h={manual:function(t,e,n){return Th(n)},left:function(t,e,n){return Th(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},right:function(t,e,n){return Th(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},top:function(t,e,n){return Th(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})},bottom:function(t,e,n){return Th(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},outsideOriented:function(t,e,n){return kh(t,e,!0,n)},outside:function(t,e,n){return kh(t,e,!1,n)},insideOriented:function(t,e,n){return Lh(t,e,!0,n)},inside:function(t,e,n){return Lh(t,e,!1,n)},radial:function(t,e,n){return Ch(t.difference(e.center()),!1,n)},radialOriented:function(t,e,n){return Ch(t.difference(e.center()),!0,n)}},sn=(Mh.prototype={getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(e){return this.ports.filter(function(t){return t.group===e})},getGroupPortsMetrics:function(t,i){var e=this.getGroup(t),t=this.getPortsByGroup(t),e=e.position||{},n=e.name,r=this.portLayoutNamespace,e=(r[n]||(n="left"),e.args||{}),o=t.map(function(t){return t&&t.position&&t.position.args}),r=r[n](o,i,e),n={ports:t,result:[]};return et(r).reduce(function(t,e,n){n=t.ports[n];return t.result.push({portId:n.id,portTransformation:e,labelTransformation:this._getPortLabelLayout(n,A(e),i),portAttrs:n.attrs,portSize:n.size,labelSize:n.label.size}),t}.bind(this),n),n.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(w(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=et(t.items),s=0,a=o.length;s<a;s++)this.ports.push(this._evaluatePort(o[s]))},_evaluateGroup:function(t){return k(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=T({},t),t=this.getGroup(t.group);return e.markup=e.markup||t.markup,e.attrs=k({},t.attrs,e.attrs),e.position=this._createPositionNode(t,e),e.label=k({},t.label,this._getLabel(e)),e.z=this._getZIndex(t,e),e.size=T({},t.size,e.size),e},_getZIndex:function(t,e){return qs(e.z)?e.z:qs(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return k({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var n,i={},e=(b(t)?(n="fn",i.fn=t):E(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):w(t)&&(n=t.name,T(i,t.args)),{args:i});return n&&(e.name=n),e},_getLabel:function(t,e){var t=t.label||{},n=t;return n.position=this._getPosition(t.position,e),n}},{_initializePorts:function(){this._createPortData(),this.on("change:ports",function(){this._processRemovedPort(),this._createPortData()},this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={},t=(et(t.items).forEach(function(t){e[t.id]=!0}),this.previous("ports")||{}),n={},t=(et(t.items).forEach(function(t){e[t.id]||(n[t.id]=!0)}),this.graph);t&&!ea(n)&&(t.getConnectedLinks(this,{inbound:!0}).forEach(function(t){n[t.get("target").port]&&t.remove()}),t.getConnectedLinks(this,{outbound:!0}).forEach(function(t){n[t.get("source").port]&&t.remove()}))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&0<t.length},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return ta(this.prop("ports/items"))||[]},getGroupPorts:function(e){var t=et(this.prop(["ports","items"])).filter(t=>t.group===e);return ta(t)},getPort:function(e){return ta(et(this.prop("ports/items")).find(function(t){return t.id&&t.id===e}))},getPortGroupNames:function(){return Object.keys(this._portSettingsData.groups)},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,tt(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=w(t)?t.id:t;return this._isValidPortId(e)?et(this.prop("ports/items")).findIndex(function(t){return t.id===e}):-1},addPort:function(t,e){if(!w(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=T([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){t="number"==typeof t?t:this.getPortIndex(t);if(!w(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");var i=T([],this.prop("ports/items"));return i.splice(t,0,e),this.prop("ports/items",i,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);t=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?t[0]=["ports","items",r].concat(e):E(e)?t[0]=["ports/items/",r,"/",e].join(""):(t=["ports/items/"+r],y(e)&&(t.push(e),t.push(n))),this.prop.apply(this,t)},_validatePorts:function(){var t=this.get("ports")||{},e=[],t=t||{},t=et(t.items);return t.forEach(function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())},this),Qs(t,"id").length!==t.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!w(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",T([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){var n,e=e||{},t=this.getPortIndex(t);return-1!==t&&((n=T([],this.prop(["ports","items"]))).splice(t,1),e.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],n,e),this.stopBatch("port-remove")),this},removePorts:function(t,e){let n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;e=T([],this.prop(["ports","items"]));i=e.filter(function(e){return!t.some(function(t){t=w(t)?t.id:t;return e.id===t})})}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(0<e.length)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new Mh(this.get("ports"));var n,i=this._portSettingsData.getPorts();t&&(e=i.filter(function(e){if(!t.find(function(t){return t.id===e.id}))return e}),0<(n=t.filter(function(e){if(!i.find(function(t){return t.id===e.id}))return e})).length&&this.trigger("ports:remove",this,n),0<e.length)&&this.trigger("ports:add",this,e)}}),o={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 e=[],n=this._getContainerElement(),t=0,i=n.node.childNodes.length;t<i;t++)e.push(n.node.childNodes[t]);for(var r=sa(this.model._portSettingsData.getPorts(),"z"),o=(et(r.auto).forEach(function(t){t=this._getPortElement(t);n.append(t),e.push(t)},this),Object.keys(r)),s=0;s<o.length;s++){var a,l=o[s];"auto"!==l&&(a=parseInt(l,10),this._appendPorts(r[l],a,e))}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),t=et(t).map(this._getPortElement,this);n[e]||e<0?R(n[Math.max(e,0)]).before(t):i.append(t)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){var n,t=this._portElementsCache[t];return t?e?(n=t.portElement.node,this.findBySelector(e,n,t.portSelectors)):[t.portContentElement.node]:[]},findPortNode:function(t,e){var[t=null]=this.findPortNodes(t,e);return t},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){Xs(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){let e,n,i,r,o=R(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t),a,l;if(Array.isArray(s)?(l=(a=this.parseDOMJSON(s,o.node)).fragment,e=1<l.childNodes.length?R("g").append(l):R(l.firstChild),r=a.selectors):(e=R(s),Array.isArray(e)&&(e=R("g").append(e))),!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group}),qs(t.id)&&e.attr("port-id-type","number");var h,u=this._getPortLabelMarkup(t.label);if(Array.isArray(u)?({fragment:f,selectors:p}=this.parseDOMJSON(u,o.node),0<(d=f.childNodes.length)&&(i=p,n=1===d?R(f.firstChild):R("g").append(f))):(n=R(u),Array.isArray(n)&&(n=R("g").append(n))),r&&i){for(var c in i)if(r[c]&&c!==this.selector)throw new Error("ElementView: selectors within port must be unique.");h=T({},r,i)}else h=r||i||{};var d,f,p="labelText";return"portRoot"in h||(h.portRoot=e.node),n&&(d=n.node,"labelRoot"in h||(h.labelRoot=d),p in h||(f="TEXT"===n.tagName()?d:Array.from(d.querySelectorAll("text")),h[p]=f,(i=i||{})[p]=f)),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=tt(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,s=this._portElementsCache[s]||{},a=o.portTransformation,l=o.labelTransformation;l&&s.portLabelElement&&(this.updateDOMSubtreeAttributes(s.portLabelElement.node,l.attrs,{rootBBox:new tt(o.labelSize),selectors:s.portLabelSelectors}),this.applyPortTransform(s.portLabelElement,l,-a.angle||0)),this.updateDOMSubtreeAttributes(s.portElement.node,o.portAttrs,{rootBBox:new tt(o.portSize),selectors:s.portSelectors}),this.applyPortTransform(s.portElement,a)}},applyPortTransform:function(t,e,n){n=R.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(n,{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}},c=gh.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),gh.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){var i=qs(e),{parentRelative:r,deep:o,restrictedArea:s}=n=(i?n:t)||{};let a;if(r){if(!this.graph)throw new Error("Element must be part of a graph.");var l=this.getParentCell();l&&!l.isLink()&&(a=l.get("position"))}return i?(a&&(t+=a.x,e+=a.y),o||s?({x:l,y:i}=this.get("position"),this.translate(t-l,e-i,n)):this.set("position",{x:t,y:e},n),this):(o=A(this.get("position")),r?o.difference(a):o)},translate:function(t,e,n){var i,r,o,s,a;return e=e||0,0===(t=t||0)&&0===e||((n=n||{}).translateBy=n.translateBy||this.id,i=this.get("position")||{x:0,y:0},(s=n.restrictedArea)&&n.translateBy===this.id&&(e="function"==typeof s?(t=(r=s.call(this,i.x+t,i.y+e,n)).x-i.x,r.y-i.y):(r=this.getBBox({deep:!0}),o=i.x-r.x,a=i.y-r.y,o=Math.max(s.x+o,Math.min(s.x+s.width+o-r.width,i.x+t)),s=Math.max(s.y+a,Math.min(s.y+s.height+a-r.height,i.y+e)),t=o-i.x,s-i.y)),a={x:i.x+t,y:i.y+e},n.tx=t,n.ty=e,n.transition?(w(n.transition)||(n.transition={}),this.transition("position",a,T({},n.transition,{valueFunction:vl.object})),Xs(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",a,n),Xs(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}:(w(t)&&(n=e,e=(qs(t.height)?t:i).height,t=(qs(t.width)?t:i).width),this.resize(t,e,n))},resize:function(t,e,n){if(this.startBatch("resize",n=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=Xn(this.get("angle")||0),o=this.getBBox();if(r)var s={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction],a=o[["bottomLeft","corner","topRight","origin"][s=n.absolute?(s+Math.floor((r+45)/90))%4:s]](),a=A(a).rotate(o.center(),-r),l=Math.sqrt(t*t+e*e)/2,h=s*Math.PI/2,s=(h=(h+=Math.atan(s%2==0?e/t:t/e))-Jn(r),A.fromPolar(l,h,a)),u=A(s).offset(t/-2,e/-2);else switch(u=o.topLeft(),n.direction){case"top":case"top-right":u.offset(0,o.height-e);break;case"left":case"bottom-left":u.offset(o.width-t,0);break;case"top-left":u.offset(o.width-t,o.height-e)}this.set("size",{width:t,height:e},n),this.position(u.x,u.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){t=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(t.x,t.y,i),this.resize(t.width,t.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=this.graph;if(e)return 0!==(e=this.getEmbeddedCells().filter(t=>t.isElement())).length&&(this.startBatch("fit-embeds",t),t.deep&&Xs(e,"fitToChildren",t),this._fitToElements(Object.assign({elements:e},t)),this.stopBatch("fit-embeds")),this;throw new Error("Element must be part of a graph.")},fitParent:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=this.graph;if(n)return e.deep&&e.terminator&&(e.terminator===this||e.terminator===this.id)||(n=this.getParentCell())&&n.isElement()&&0!==(t=n.getEmbeddedCells().filter(t=>t.isElement())).length&&(this.startBatch("fit-parent",e),n._fitToElements(Object.assign({elements:t},e)),e.deep&&n.fitParent(e),this.stopBatch("fit-parent")),this;throw new Error("Element must be part of a graph.")},_fitToElements:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=this.graph.getCellsBBox(e.elements);if(n){var{expandOnly:i,shrinkOnly:r}=e;if(!i||!r){var{x:n,y:o,width:s,height:a}=n,{left:l,right:h,top:u,bottom:c}=gl(e.padding);n-=l,o-=u,s+=l+h,a+=c+u;let t=new tt(n,o,s,a);if(i)t=this.getBBox().union(t);else if(r){l=this.getBBox().intersect(t);if(!l)return;t=l}this.set({position:{x:t.x,y:t.y},size:{width:t.width,height:t.height}},e)}}},rotate:function(t,e,n,i){var r,o,s,a;return n?(a=this.getBBox().center(),r=this.get("size"),o=this.get("position"),a.rotate(n,this.get("angle")-t),s=a.x-r.width/2-o.x,a=a.y-r.height/2-o.y,this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(o.x+s,o.y+a,i),this.rotate(t,e,null,i),this.stopBatch("rotate")):this.set("angle",e?t:(this.get("angle")+t)%360,i),this},angle:function(){return Xn(this.get("angle")||0)},getBBox:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},{graph:n,attributes:i}=this,{deep:r,rotate:o}=e;return r&&n?((r=this.getEmbeddedCells({deep:!0,breadthFirst:!0})).push(this),n.getCellsBBox(r,e)):({angle:n=0,position:{x:r,y:e},size:{width:i,height:t}}=i,r=new tt(r,e,i,t),o&&r.rotateAroundCenter(n),r)},getPointFromConnectedLink:function(t,e){var n=this.getBBox(),i=n.center(),t=t.get(e);return t&&(e=t.port)&&this.hasPort(e)?(t=this.portProp(e,["group"]),t=this.getPortsPositions(t),t=new A(t[e]).offset(n.origin()),(e=this.angle())&&t.rotate(i,-e),t):i}});T(c.prototype,sn);let Nh=gh.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){var i;return void 0===t?f(this.get("source")):t instanceof gh?((i=f(e)||{}).id=t.id,this.set("source",i,n)):y(t)?this.set("source",i=t,e):((i=f(e)||{}).x=t.x,i.y=t.y,this.set("source",i,n))},target:function(t,e,n){var i;return void 0===t?f(this.get("target")):t instanceof gh?((i=f(e)||{}).id=t.id,this.set("target",i,n)):y(t)?this.set("target",i=t,e):((i=f(e)||{}).x=t.x,i.y=t.y,this.set("target",i,n))},router:function(t,e,n){var i;return void 0===t?(i=this.get("router"))?"object"==typeof i?f(i):i:null:this.set("router",(i="object"==typeof t||"function"==typeof t)?t:{name:t,args:e},i?e:n)},connector:function(t,e,n){var i;return void 0===t?(i=this.get("connector"))?"object"==typeof i?f(i):i:null:this.set("connector",(i="object"==typeof t||"function"==typeof t)?t:{name:t,args:e},i?e:n)},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(){var t=this.attributes.labels;return Array.isArray(t)&&0<t.length},insertLabel:function(t,e,n){var i,r;if(e)return r=(i=this.labels()).length,t=isFinite(t)&&null!==t?0|t:r,i.splice(t=t<0?r+t+1:t,0,e),this.labels(i,n);throw new Error("dia.Link: no label provided")},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();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1?this.prop(["vertices",t]):(i=this._normalizeVertex(e),this.prop(["vertices",t],i,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],r=this._normalizeVertex(r);n.push(r)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){var i,r;if(e)return r=(i=this.vertices()).length,(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),r=this._normalizeVertex(e),i.splice(t,0,r),this.vertices(i,n);throw new Error("dia.Link: no vertex provided")},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 y(t)?t:{x:t.x,y:t.y}},translate:function(e,n,t){return(t=t||{}).translateBy=t.translateBy||this.id,t.tx=e,t.ty=n,this.applyToPoints(function(t){return{x:(t.x||0)+e,y:(t.y||0)+n}},t)},scale:function(e,n,i,t){return this.applyToPoints(function(t){return A(t).scale(e,n,i).toJSON()},t)},applyToPoints:function(t,e){var n,i,r;if(b(t))return n={},{source:r,target:i}=this.attributes,r.id||(n.source=t(r)),i.id||(n.target=t(i)),0<(r=this.vertices()).length&&(n.vertices=r.map(t)),this.set(n,e);throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.")},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new A(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new A(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){var t=[this.getSourcePoint(),...this.vertices().map(A),this.getTargetPoint()];return new x(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e,n,i,r;return this.graph&&(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),e},hasLoop:function(t){t=t||{};var{source:e,target:n}=this.attributes,e=e.id,n=n.id;return!(!e||!n)&&(!(e=e===n)&&t.deep&&this.graph&&(n=this.getSourceCell(),t=this.getTargetCell(),e=n.isEmbeddedIn(t)||t.isEmbeddedIn(n)),e)},getSourceCell:function(){var{graph:t,attributes:e}=this,e=e.source;return e&&e.id&&t&&t.getCell(e.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getSourceCell())&&t.isLink());return t},getTargetCell:function(){var{graph:t,attributes:e}=this,e=e.target;return e&&e.id&&t&&t.getCell(e.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getTargetCell())&&t.isLink());return t},getRelationshipAncestor:function(){var t;return this.graph&&(t=[this,this.getSourceElement(),this.getTargetElement()].filter(function(t){return!!t}),t=this.graph.getCommonAncestor.apply(this.graph,t)),t||null},isRelationshipEmbeddedIn:function(t){var t=E(t)||qs(t)?t:t.id,e=this.getRelationshipAncestor();return!!e&&(e.id===t||e.isEmbeddedIn(t))},_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}}),Oh={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))},isSafari:function(){return/Safari/.test(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)}},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){try{n=e()}catch(t){n=!1}this._results[t]=n}return n}};var Rh=c.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"}]}),i=c.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"}]}),s=c.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"}]}),u=c.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"}]}),l=c.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"}]}),Ln=c.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"}]}),a=c.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"}]}),Je=c.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"}]}),e=c.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"}]}),r=c.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"}]}),h=c.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"}]}),n=c.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){var n;return void 0===t?this.attr("body/lateralArea"):(n={lateralArea:t},t=ll(t)?`calc(${parseFloat(t)/100}*h)`:t,this.attr({body:n,top:{cy:t,ry:t}},e))}},{attributes:{"lateral-area":{set:function(t,e){var n=ll(t),i=(n&&(t=parseFloat(t)/100),e.x),r=e.y,o=e.width,e=e.height,s=o/2,a=n?e*t:t,l=R.KAPPA,s=l*s,l=l*(n?e*t:t),n=i+o/2,t=i+o,o=r+a,h=o-a,a=r+e-a,r=r+e;return{d:["M",i,o,"L",i,a,"C",i,a+l,n-s,r,n,r,"C",n+s,r,t,a+l,t,a,"L",t,o,"C",t,o-l,n+s,h,n,h,"C",n-s,h,i,o-l,i,o,"Z"].join(" ")}},unset:"d"}}}),$e=Oh.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"}},sn={standard:{Rectangle:Rh,Circle:i,Ellipse:s,Path:u,Polygon:l,Polyline:Ln,Image:a,BorderedImage:Je,EmbeddedImage:e,InscribedImage:r,HeaderedRectangle:h,Cylinder:n,TextBlock:c.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"},$e]},{attributes:{text:{set:function(t,e,n,i){var r,o;if(!(n instanceof HTMLElement))return i=i.style||{},r={text:t,width:-5,height:"100%"},o=T({"text-vertical-anchor":"middle"},i),fh["text-wrap"].set.call(this,r,e,n,o),{fill:i.color||null};n.textContent=t},unset:function(t){if(t.textContent="",t instanceof SVGElement)return"fill"},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),Link:Nh.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"}}]}),DoubleLink:Nh.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"}}]}),ShadowLink:Nh.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"}}]})}};function Fh(r,o){var s=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],t=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},{cornerType:a=Ih.POINT,cornerRadius:l=10,cornerPreserveAspectRatio:h=!1,precision:u=1,raw:t=!1}=t;if(-1===Vh.indexOf(a))throw new Error("Invalid `cornerType` provided to `straight` connector.");let c;if(a!==Ih.POINT&&l){(c=new V).appendSegment(V.createSegment("M",r));let i;var e=s.length;for(let n=0;n<e;n++){var d=new A(s[n]),f=s[n-1]||r,p=s[n+1]||o,g=i||d.distance(f)/2;i=d.distance(p)/2;let t,e;h?t=e=-Math.min(l,g,i):(t=-Math.min(l,g),e=-Math.min(l,i));var m=d.clone().move(f,t).round(u),v=d.clone().move(p,e).round(u);switch(c.appendSegment(V.createSegment("L",m)),a){case Ih.CUBIC:var y=new A(1/3*m.x+2/3*d.x,2/3*d.y+1/3*m.y),b=new A(1/3*v.x+2/3*d.x,2/3*d.y+1/3*v.y);c.appendSegment(V.createSegment("C",y,b,v));break;case Ih.LINE:c.appendSegment(V.createSegment("L",v));break;case Ih.GAP:c.appendSegment(V.createSegment("M",v))}}c.appendSegment(V.createSegment("L",o))}else{var n=[r].concat(s).concat([o]),n=new x(n);c=new V(n)}return t?c:c.serialize()}let Ih={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},Vh=Object.values(Ih);var Bh=["arc","gap","cubic"],Dh=1,zh=["smooth"],jh=1/3,Gh=2/3;function Uh(t,e){let{x:n,y:i}=t,{x:r,y:o}=e;return n>r&&(t=n,n=r,r=t,t=i,i=o,o=t),i>o&&(e=n,n=r,r=e,e=i,i=o,o=e),[new A(n,i),new A(r,o)]}function Hh(t,e,n){var r=[].concat(t,n,e);return r.reduce(function(t,e,n){var i=r[n+1];return null!=i&&(t[n]=pi(e,i)),t},[])}function qh(t){var e,r=t.paper,n=r._jumpOverUpdateList;null==n&&(n=r._jumpOverUpdateList=[],(e=r.model).on("batch:stop",function(){if(!this.hasActiveBatch())for(var t=r._jumpOverUpdateList,e=0;e<t.length;e++){var n=t[e],i=n.getFlag(n.constructor.Flags.CONNECTOR);n.requestUpdate(i)}}),e.on("reset",function(){n=r._jumpOverUpdateList=[]})),n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",function(){n.splice(n.indexOf(t),1)}))}function $h(t,e){return pi(t,e).squaredLength()}function Wh(h,u,c,d){var f=new V,p=V.createSegment("M",h[0].start);return f.appendSegment(p),et(h).forEach(function(t,e){var n,i,r,o,s,a,l;t.isJump?"arc"===c?(s=-90,i=t.start.difference(t.end),Number(i.x<0||0===i.x&&i.y<0)&&(s+=180),r=t.midpoint(),o=new P(r,t.end).rotate(r,s),a=(n=new P(t.start,r)).pointAt(2/3).rotate(t.start,s),l=o.pointAt(1/3).rotate(o.end,-s),p=V.createSegment("C",a,l,o.end),f.appendSegment(p),n=new P(r,t.end),a=o.pointAt(1/3).rotate(o.end,s),l=n.pointAt(1/3).rotate(t.end,-s),p=V.createSegment("C",a,l,t.end),f.appendSegment(p)):"gap"===c?(p=V.createSegment("M",t.end),f.appendSegment(p)):"cubic"===c&&(s=t.start.theta(t.end),r=.6*u,o=1.35*u,i=t.start.difference(t.end),Number(i.x<0||0===i.x&&i.y<0)&&(o*=-1),a=A(t.start.x+r,t.start.y+o).rotate(t.start,s),l=A(t.end.x-r,t.end.y+o).rotate(t.end,s),p=V.createSegment("C",a,l,t.end),f.appendSegment(p)):(n=h[e+1],0==d||!n||n.isJump?(p=V.createSegment("L",t.end),f.appendSegment(p)):(i=d,r=f,o=t.end,s=t.start,a=n.end,l=o.distance(s)/2,e=o.distance(a)/2,l=-Math.min(i,l),i=-Math.min(i,e),e=o.clone().move(s,l).round(),s=o.clone().move(a,i).round(),l=new A(jh*e.x+Gh*o.x,Gh*o.y+jh*e.y),a=new A(jh*s.x+Gh*o.x,Gh*o.y+jh*s.y),i=V.createSegment("L",e),r.appendSegment(i),i=V.createSegment("C",l,a,s),r.appendSegment(i)))}),f}let Yh={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},Xh={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"};function Zh(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},r=4<arguments.length?arguments[4]:void 0,o=Boolean(i.raw),{direction:s=Yh.AUTO,precision:a=3}=i;let l={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new A(i.sourceTangent):null,targetTangent:i.targetTangent?new A(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?l.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?l.sourceDirection=new A(1,0).rotate(null,i.sourceDirection):l.sourceDirection=i.sourceDirection?new A(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?l.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?l.targetDirection=new A(1,0).rotate(null,i.targetDirection):l.targetDirection=i.targetDirection?new A(i.targetDirection).normalize():null,i=[t,...n,e].map(t=>new A(t));let h;h=l.sourceTangent||(t=((t,e,n,i)=>{if(i.sourceDirection)switch(i.sourceDirection){case Xh.UP:return new A(0,-1);case Xh.DOWN:return new A(0,1);case Xh.LEFT:return new A(-1,0);case Xh.RIGHT:return new A(1,0);case Xh.AUTO:return Jh(t,e,i);case Xh.CLOSEST_POINT:return Qh(0,e);case Xh.OUTWARDS:return eu(t,e);default:return i.sourceDirection}switch(n){case Yh.HORIZONTAL:return((t,e,n)=>{let i=t.sourceBBox,r,o;var s;r=t.sourceView?(o=t.sourceView.model.angle(),n.rotate&&o?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(s=e[0].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[0])):i.x>e[1].x?"right":"left";let a;return a="left"===r?new A(-1,0):new A(1,0),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case Yh.VERTICAL:return((t,e,n)=>{let i=t.sourceBBox,r,o;var s;r=t.sourceView?(o=t.sourceView.model.angle(),n.rotate&&o?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(s=e[0].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[0])):i.y>e[1].y?"bottom":"top";let a;return a="top"===r?new A(0,-1):new A(0,1),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case Yh.CLOSEST_POINT:return Qh(0,e);case Yh.OUTWARDS:return eu(t,e);default:Yh.AUTO;return Jh(t,e,i)}})(r,i,s,l),n=i[0].distance(i[1])*l.coeff,(e=iu(t,i[1].difference(i[0]).normalize()))>Math.PI/4?(e=n+(e-Math.PI/4)*l.angleTangentCoefficient,t.clone().scale(e,e)):t.clone().scale(n,n));let u;return u=l.targetTangent||(e=((t,e,n,i)=>{if(i.targetDirection)switch(i.targetDirection){case Xh.UP:return new A(0,-1);case Xh.DOWN:return new A(0,1);case Xh.LEFT:return new A(-1,0);case Xh.RIGHT:return new A(1,0);case Xh.AUTO:return Kh(t,e,i);case Xh.CLOSEST_POINT:return tu(0,e);case Xh.OUTWARDS:return nu(t,e);default:return i.targetDirection}switch(n){case Yh.HORIZONTAL:return((t,e,n)=>{let i=t.targetBBox,r,o;var s;r=t.targetView?(o=t.targetView.model.angle(),n.rotate&&o?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(s=e[e.length-1].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[e.length-1])):i.x>e[e.length-2].x?"left":"right";let a;return a="left"===r?new A(-1,0):new A(1,0),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case Yh.VERTICAL:return((t,e,n)=>{let i=t.targetBBox,r,o;var s;r=t.targetView?(o=t.targetView.model.angle(),n.rotate&&o?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(s=e[e.length-1].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[e.length-1])):i.y>e[e.length-2].y?"top":"bottom";let a;return a="top"===r?new A(0,-1):new A(0,1),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case Yh.CLOSEST_POINT:return tu(0,e);case Yh.OUTWARDS:return nu(t,e);default:Yh.AUTO;return Kh(t,e,i)}})(r,i,s,l),n=i[(t=i.length-1)-1].distance(i[t])*l.coeff,(r=iu(e,i[t-1].difference(i[t]).normalize()))>Math.PI/4?(s=n+(r-Math.PI/4)*l.angleTangentCoefficient,e.clone().scale(s,s)):e.clone().scale(n,n)),t=((r,t,e,n)=>{var{tau:i,coeff:o}=n,s=[],a=[],l=[],h=r.length-1;for(let t=0;t<h;t++)s[t]=r[t].distance(r[t+1]);a[0]=t,a[h]=e;for(let i=1;i<h;i++){let t,e;t=1===i?r[i-1].clone().offset(a[i-1].x,a[i-1].y):r[i-1].clone(),e=i===h-1?r[i+1].clone().offset(a[i+1].x,a[i+1].y):r[i+1].clone();var u=t.difference(r[i]).normalize(),c=e.difference(r[i]).normalize(),d=iu(u,c);let n=(Math.PI-d)/2;var u=ru(u,c),d=(f=ru(r[i].difference(r[i+1]),r[i].difference(r[i-1])),u<0&&(n=-n),d<Math.PI/2&&(n<0&&f<0||0<n&&0<f)&&(n-=Math.PI),((t,e)=>{var n=Math.cos(e),e=Math.sin(e),i=n*t.x-e*t.y,e=e*t.x+n*t.y;t.x=i,t.y=e})(u=c.clone(),n),u.clone()),f=u.clone(),c=s[i-1]*o,u=s[i]*o;d.scale(c,c),f.scale(u,u),a[i]=[d,f]}for(let n=0;n<h;n++){let t,e;t=0===n?r[n+1].difference(a[n].x/i,a[n].y/i):r[n+1].difference(a[n][1].x/i,a[n][1].y/i),e=n===h-1?r[n].clone().offset(a[n+1].x/i,a[n+1].y/i):r[n].difference(a[n+1][0].x/i,a[n+1][0].y/i),l[n]=[t,r[n],r[n+1],e]}return l})(i,h,u,l).map(t=>{return t=t,e=(e=l).tau,(n=new A).x=t[1].x+(t[2].x-t[0].x)/(6*e),n.y=t[1].y+(t[2].y-t[0].y)/(6*e),(i=new A).x=t[2].x+(t[3].x-t[1].x)/(6*e),i.y=t[2].y+(t[3].y-t[1].y)/(6*e),new v(t[1],n,i,t[2]);var e,n,i}),r=new V(t).round(a),o?r:r.serialize()}function Jh(t,e,n){var i,r=t.sourceBBox;let o,s,a;switch(o=t.sourceView?(s=t.sourceView.model.angle(),n.rotate&&s?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(i=e[0].clone()).rotate(r.center(),s),t.sideNearestToPoint(i)):r.sideNearestToPoint(e[0])):r.sideNearestToPoint(e[1])){case"top":a=new A(0,-1);break;case"bottom":a=new A(0,1);break;case"right":a=new A(1,0);break;case"left":a=new A(-1,0)}return n.rotate&&s&&a.rotate(null,-s),a}function Kh(t,e,n){var i,r=t.targetBBox;let o,s,a;switch(o=t.targetView?(s=t.targetView.model.angle(),n.rotate&&s?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(i=e[e.length-1].clone()).rotate(r.center(),s),t.sideNearestToPoint(i)):r.sideNearestToPoint(e[e.length-1])):r.sideNearestToPoint(e[e.length-2])){case"top":a=new A(0,-1);break;case"bottom":a=new A(0,1);break;case"right":a=new A(1,0);break;case"left":a=new A(-1,0)}return n.rotate&&s&&a.rotate(null,-s),a}function Qh(t,e){return e[1].difference(e[0]).normalize()}function tu(t,e){var n=e.length-1;return e[n-1].difference(e[n]).normalize()}function eu(t,e){t=t.sourceBBox,t=t.center();return e[0].difference(t).normalize()}function nu(t,e){t=t.targetBBox,t=t.center();return e[e.length-1].difference(t).normalize()}function iu(t,e){let n=t.dot(e)/(t.magnitude()*e.magnitude());return 1<(n=n<-1?-1:n)&&(n=1),Math.acos(n)}function ru(t,e){return t.x*e.y-t.y*e.x}Zh.Directions=Yh,Zh.TangentDirections=Xh;function ou(t){this.cid=fa("view"),this.preinitialize.apply(this,arguments),T(this,ca(t,lu)),this._ensureElement(),this.initialize.apply(this,arguments)}var su={straight:Fh,jumpover:function(t,e,n,i){qh(this);var r,o,s,u,a,c,l=i.raw,d=i.size||5,h=i.jump&&(""+i.jump).toLowerCase(),f=i.radius||0,p=i.ignoreConnectors||zh,g=(-1===Bh.indexOf(h)&&(h=Bh[0]),this.paper),i=g.model.getLinks();return 1===i.length?Wh(Hh(t,e,n),d,h,f):(r=this.model,o=i.indexOf(r),s=g.options.defaultConnector||{},i=(u=i.filter(function(t,e){t=t.get("connector")||s;return!(et(p).includes(t.name)||o<e&&"jumpover"===t.name)})).map(function(t){return g.findViewByModel(t)}),a=Hh(t,e,n),c=i.map(function(t){return null==t?[]:t===this?a:Hh(t.sourcePoint,t.targetPoint,t.route)},this),t=Wh(a.reduce(function(t,l){var s,a,h,e=u.reduce(function(t,e,n){var i;return e!==r&&(-1<(n=(e=c[n].slice()).findIndex(t=>{var[{x:e,y:n},{x:i,y:r}]=Uh((e=l).start,e.end),[{x:t,y:o},{x:s,y:a}]=Uh(t.start,t.end);return e<=s&&t<=i&&(n<=a&&o<=r)}))&&l.containsPoint(e[n].end)&&e.splice(n+1,1),i=l,n=e,e=et(n).reduce(function(t,e){e=i.intersection(e);return e&&t.push(e),t},[]),t.push.apply(t,e)),t},[]).sort(function(t,e){return $h(l.start,t)-$h(l.start,e)});return 0<e.length?t.push.apply(t,(s=l,h=d,(a=e).reduce(function(t,e,n){if(!0!==e.skip){var i=t.pop()||s,r=ci(e).move(i.start,-h),e=ci(e).move(i.start,+h),n=a[n+1];if(null!=n){var o=e.distance(n);o<=h&&(e=n.move(i.start,o),n.skip=!0)}else if(r.distance(i.end)<2*h+Dh)return t.push(i),t;e.distance(i.start)<2*h+Dh?t.push(i):((o=pi(r,e)).isJump=!0,t.push(pi(i.start,r),o,pi(e,i.end)))}return t},[]))):t.push(l),t},[]),d,h,f),l?t:t.serialize())},normal:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],i=(3<arguments.length&&void 0!==arguments[3]?arguments[3]:{}).raw,i={cornerType:"point",raw:i};return Fh(t,e,n,i)},rounded:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],{radius:i=10,raw:r}=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},i={cornerType:"cubic",cornerRadius:i,precision:0,raw:r};return Fh(t,e,n,i)},smooth:function(t,e,n,i){var r,o,i=i&&i.raw;return n&&0!==n.length?(n=[t].concat(n).concat([e]),n=v.throughPoints(n),r=new V(n)):(r=new V,n=V.createSegment("M",t),r.appendSegment(n),n=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?(o=(t.x+e.x)/2,V.createSegment("C",o,t.y,o,e.y,e.x,e.y)):(o=(t.y+e.y)/2,V.createSegment("C",t.x,o,e.x,o,e.x,e.y)),r.appendSegment(n)),i?r:r.serialize()},curve:Zh},au=/^(\S+)\s*(.*)$/,lu=["model","collection","el","id","attributes","className","tagName","events","style"];T(ou.prototype,Sl,{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 L?t:L(t),this.el=this.$el[0]},delegateEvents:function(t){if(t=t||S(this,"events"))for(var e in this.undelegateEvents(),t){var n=t[e];(n=b(n)?n:this[n])&&(e=e.match(au),this.delegate(e[1],e[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(){var t;this.el?this.setElement(S(this,"el")):(t=T({},S(this,"attributes")),this.id&&(t.id=S(this,"id")),this.className&&(t.class=S(this,"className")),this.setElement(this._createElement(S(this,"tagName"))),this._setAttributes(t))},_setAttributes:function(t){this.$el.attr(t)}}),ou.extend=Pl;let hu={},uu=ou.extend({options:{},theme:null,themeClassNamePrefix:ja("theme-"),requireSetThemeOverride:!1,defaultTheme:Ua.defaultTheme,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=T({},this.options,t),ou.call(this,t)},initialize:function(){(hu[this.cid]=this).setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){(this.svgElement?this.vel:this.$el).remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){var e,n;return(t=t||S(this,"children"))&&(e=this.svgElement,n=R.namespace[e?"svg":"xhtml"],t=$a(t,n),(e?this.vel:this.$el).empty().append(t.fragment),this.childNodes=t.selectors),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){e=this.findAttributeNode(t,e);return e&&e.getAttribute(t)},_ensureElement:function(){var t,e,n;this.el?this.setElement(S(this,"el")):(t=S(this,"tagName"),e=T({},S(this,"attributes")),n=T({},S(this,"style")),this.id&&(e.id=S(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)),this._ensureElClassName()},_setAttributes:function(t){(this.svgElement?this.vel:this.$el).attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(R.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof L?t:L(t),this.el=this.$el[0],this.svgElement&&(this.vel=R(this.el))},_ensureElClassName:function(){var t,e=S(this,"className");e&&(t=ja(e),(this.svgElement?this.vel:this.$el).removeClass(e).addClass(t))},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){return(t=t||this.theme)&&(t=this.themeClassNamePrefix+t,(this.svgElement?this.vel:this.$el).addClass(t)),this},removeThemeClassName:function(t){t=t||this.theme;t=this.themeClassNamePrefix+t;return(this.svgElement?this.vel:this.$el).removeClass(t),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),hu[this.cid]=null,ou.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(e){n=n||{};var i,r=this.getEventNamespace();for(i in e){var o=e[i];(o="function"!=typeof o?this[o]:o)&&L(t).on(i+r,n,o.bind(this))}}return this},undelegateElementEvents:function(t){return L(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t=t||S(this,"documentEvents"),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){var n,i;if(t)return n=t.data,i="__"+this.cid+"__",void 0===e?n&&n[i]||{}:((n=n||(t.data={}))[i]||(n[i]={}),T(n[i],e),this);throw new Error("eventData(): event object required.")},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]&&T({},t[0])||{},t=t[1]&&T({},t[1])||{},n=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof n&&n.apply(this,arguments),this.render.__render__===n&&this.onRender(),this},e.render.__render__=n,ou.extend.call(this,e,t)}});function cu(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,T({silent:!0},e))}function du(t,e,n){n=Math.min(Math.max(n,0),t.length);for(var i=Array(t.length-n),r=e.length,o=0;o<i.length;o++)i[o]=t[o+n];for(o=0;o<r;o++)t[o+n]=e[o];for(o=0;o<i.length;o++)t[o+r+n]=i[o]}var fu,pu,gu,mu={add:!0,remove:!0,merge:!0},vu={add:!0,remove:!1},Rh=(T(cu.prototype,Sl,{model:El,preinitialize:function(){},initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},add:function(t,e){return this.set(t,T({merge:!1},e,vu))},remove:function(t,e){e=T({},e);var n=!Array.isArray(t),t=(t=n?[t]:t.slice(),this._removeModels(t,e));return!e.silent&&t.length&&(e.changes={added:[],merged:[],removed:t},this.trigger("update",this,e)),n?t[0]:t},set:function(t,e){if(null!=t){e=T({},mu,e);for(var n=!Array.isArray(t),i=(t=n?[t]:t.slice(),e.at),r=((i=(i=null!=i?+i:i)>this.length?this.length:i)<0&&(i+=this.length+1),[]),o=[],s=[],a=[],l={},h=e.add,u=e.merge,c=e.remove,d=!1,f=this.comparator&&null==i&&!1!==e.sort,p=E(this.comparator)?this.comparator:null,g=0;g<t.length;g++){var m,v=t[g],y=this.get(v);y?(u&&v!==y&&(m=this._isModel(v)?v.attributes:v,y.set(m,e),s.push(y),f)&&!d&&(d=y.hasChanged(p)),l[y.cid]||(l[y.cid]=!0,r.push(y)),t[g]=y):h&&(v=t[g]=this._prepareModel(v,e))&&(o.push(v),this._addReference(v,e),l[v.cid]=!0,r.push(v))}if(c){for(g=0;g<this.length;g++)l[(v=this.models[g]).cid]||a.push(v);a.length&&this._removeModels(a,e)}var b=!1;if(r.length&&(!f&&h&&c)?(b=this.length!==r.length||this.models.some(function(t,e){return t!==r[e]}),this.models.length=0,du(this.models,r,0),this.length=this.models.length):o.length&&(f&&(d=!0),du(this.models,o,null==i?this.length:i),this.length=this.models.length),d&&this.sort({silent:!0}),!e.silent){for(g=0;g<o.length;g++)null!=i&&(e.index=i+g),(v=o[g]).trigger("add",v,this,e);(d||b)&&this.trigger("sort",this,e),(o.length||a.length||s.length)&&(e.changes={added:o,removed:a,merged:s},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?f(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,T({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,T({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,T({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 b(e)&&(e=e.bind(this)),1===n||E(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 yu(this,bu)},keys:function(){return new yu(this,xu)},entries:function(){return new yu(this,wu)},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){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]: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):(t=((e=e?f(e):{}).collection=this).model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,t.validationError,e),!1):t},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r,o,s=this.get(t[i]);s&&(r=this.models.indexOf(s),this.models.splice(r,1),this.length--,delete this._byId[s.cid],null!=(o=this.modelId(s.attributes,s.idAttribute))&&delete this._byId[o],e.silent||(e.index=r,s.trigger("remove",s,this,e)),n.push(s),this._removeReference(s,e))}return 0<t.length&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof El},_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;"changeId"===t&&(n=this.modelId(e.previousAttributes(),e.idAttribute),t=this.modelId(e.attributes,e.idAttribute),null!=n&&delete this._byId[n],null!=t)&&(this._byId[t]=e)}this.trigger.apply(this,arguments)}}),"function"==typeof Symbol&&Symbol.iterator),yu=(Rh&&(cu.prototype[Rh]=cu.prototype.values),function(t,e){this._collection=t,this._kind=e,this._index=0}),bu=1,xu=2,wu=3,i=(Rh&&(yu.prototype[Rh]=function(){return this}),yu.prototype.next=function(){if(this._collection){var t,e;if(this._index<this._collection.length)return t=this._collection.at(this._index),this._index++,{value:this._kind===bu?t:(e=this._collection.modelId(t.attributes,t.idAttribute),this._kind===xu?e:[e,t]),done:!1};this._collection=void 0}return{value:void 0,done:!0}},[cu,{toArray:1,sortBy:3},"models"]);u=(s=i)[0],s=i[2],l={sortBy:ra,toArray:et},fu=u,pu=l,u=i[1],gu=s,pa(u,function(t,e){pu[e]&&(fu.prototype[e]=Il(pu,t,e,gu))}),cu.extend=Pl;Ln={Data:va,$:L,views:hu,View:uu,Listener:class{constructor(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];this.callbackArguments=e}listenTo(r,n){let o=this.callbackArguments;for(var t=arguments.length,s=new Array(2<t?t-2:0),e=2;e<t;e++)s[e-2]=arguments[e];if(R.isObject(n)){let[i=null]=s;Object.entries(n).forEach(t=>{let[e,n]=t;"function"==typeof n&&((i||0<o.length)&&(n=n.bind(i,...o)),Sl.listenTo.call(this,r,e,n))})}else if("string"==typeof n&&"function"==typeof s[0]){let[t,e=null]=s;(e||0<o.length)&&(t=t.bind(e,...o)),Sl.listenTo.call(this,r,n,t)}}stopListening(){Sl.stopListening.call(this)}},Events:Sl,Collection:cu,Model:El,ViewBase:ou,Event:ya};function Au(t){return t?Array.isArray(t)?t:[t]:[]}let Pu=uu.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){var n=t.paper;this.cellView=t,this.nodeSelector=e,n&&(this.updateRequested=!0,n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate(){this.updateRequested=!1;var{cellView:t,nodeSelector:e}=this;return t.isMounted()?(this.update(t,e),this.mount(),this.transform()):this.postponedUpdate=!0,0},findNode(t){var e,n,i,r,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;let s;return"string"==typeof o?s=t.findNode(o):y(o)?(e=t.model.isLink(),{label:n=null,port:i,selector:r}=o,s=e&&null!==n?t.findLabelNode(n,r):!e&&i?t.findPortNode(i,r):t.findNode(r)):!o||(s=R.toNode(o))instanceof SVGElement||(s=null),s||null},getNodeMatrix(t,e){var n=this.options,n=n.layer,i=t.rotatableNode,r=t.getNodeMatrix(e);return i?n?i.contains(e)?r:t.getRootRotateMatrix().inverse().multiply(r):t.getNodeRotateMatrix(e).multiply(r):r},mount(){var{MOUNTABLE:t,cellView:e,el:n,options:i,transformGroup:r,detachedTransformGroup:o,postponedUpdate:s,nodeSelector:a}=this;if(t&&!r)if(s)this.update(e,a),this.transform();else{var{vel:t,paper:r}=e,s=i.layer;if(s){let t;o?(t=o,this.detachedTransformGroup=null):t=R("g").addClass("highlight-transform").append(n),this.transformGroup=t,r.getLayerView(s).insertSortedNode(t.node,i.z)}else n.parentNode&&!n.nextSibling||t.append(n)}},unmount(){var{MOUNTABLE:t,transformGroup:e,vel:n}=this;t&&(e?(this.transformGroup=null,this.detachedTransformGroup=e):n).remove()},transform(){var{transformGroup:t,cellView:e,updateRequested:n}=this;!t||e.model.isLink()||n||(n=e.getRootTranslateMatrix(),e=e.getRootRotateMatrix(),n=n.multiply(e),t.attr("transform",R.matrixToTransformString(n)))},update(){var{node:t,cellView:e,nodeSelector:n,updateRequested:i,id:r}=this;i||(this.postponedUpdate=!1,i=this.node=this.findNode(e,n),t&&this.unhighlight(e,t),i?(this.highlight(e,i),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this)))},onRemove(){var{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){var e=S(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange(){var n=this.cellView;if(n){let{model:e,paper:t}=n;S(this,"UPDATE_ATTRIBUTES").some(t=>e.hasChanged(t))&&t.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY)}}},{_views:{},highlight:function(t,e,n){var i=this.uniqueId(e,n);this.add(t,e,i,n)},unhighlight:function(t,e,n){e=this.uniqueId(e,n);this.remove(t,e)},get(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,t=t.cid,n=this._views,i=n[t];if(null===e){var r=[];if(i)for(var o in i){o=i[o];o instanceof this&&r.push(o)}return r}if(i&&e in i){n=i[e];if(n instanceof this)return n}return null},add(t,e,n){var i,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(n)return(i=Pu.get(t,n))&&i.remove(),(i=new this(r)).id=n,this._addRef(t,n,i),i.requestUpdate(t,e),i.listenToUpdateAttributes(t),i;throw new Error("dia.HighlighterView: An ID required.")},_addRef(t,e,n){var t=t.cid,i=this._views;let r=i[t];(r=r||(i[t]={}))[e]=n},_removeRef(t,e){var t=t.cid,n=this._views,i=n[t];if(i){for(var r in e&&delete i[e],i)return;delete n[t]}},remove(t){Au(this.get(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)).forEach(t=>{t.remove()})},getAll(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,i=[],r=this._views;for(e in r)for(var o in r[e]){var s=r[e][o];s.cellView.paper===t&&s instanceof this&&(null===n||o===n)&&i.push(s)}return i},removeAll(t){this.getAll(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null).forEach(t=>t.remove())},update(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;let n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];Au(this.get(t,e)).forEach(t=>{(n||t.UPDATABLE)&&t.update()})},transform(t){Au(this.get(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)).forEach(t=>{t.UPDATABLE&&t.transform()})},unmount(t){Au(this.get(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)).forEach(t=>t.unmount())},mount(t){Au(this.get(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)).forEach(t=>t.mount())},uniqueId(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";return R.ensureId(t)+JSON.stringify(e)}});a=Pu.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(e,n){var i=this.options,t=i.useFirstSubpath;let r;try{var o,s=R(n);r=s.convertToPathData().trim(),"PATH"===s.tagName()&&t&&0<(o=r.search(/.M/i)+1)&&(r=r.substr(0,o))}catch(t){s=e.getNodeBoundingRect(n);r=R.rectToPath(T({},i,s.toJSON()))}return r},highlightConnection(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode(t,e){var n,i,r,{vel:o,options:s}=this,{padding:s,layer:a}=s;let l=this.getNodeMatrix(t,e);s&&(a||e!==t.el||o.remove(),n=(a=t.getNodeBoundingRect(e)).x+a.width/2,i=a.y+a.height/2,a=R.transformRect(a,l),r=((r=Math.max(a.width,1))+s)/r,s=((a=Math.max(a.height,1))+s)/a,a=R.createSVGMatrix({a:r,b:0,c:0,d:s,e:n-r*n,f:i-s*i}),l=l.multiply(a)),o.attr({d:this.getPathData(t,e),transform:R.matrixToTransformString(l)})},highlight(t,e){var{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)}});Je=Pu.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:20,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(e,n){var{MASK_CHILD_ATTRIBUTE_BLACKLIST:t,MASK_REPLACE_TAGS:i,MASK_REMOVE_TAGS:r}=this,o=n.tagName();if(!R.isSVGGraphicsElement(n)||r.includes(o))return n.remove(),!1;if(i.includes(o)){r=e.vel.findOne("#"+n.id);if(r){i=r.node;let t=e.getNodeBoundingRect(i);e.model.isElement()&&(t=R.transformRect(t,e.getNodeMatrix(i)));var o=R("rect",t.toJSON()),{x:e,y:i}=t.center(),{angle:r,cx:e=e,cy:i=i}=r.rotate();r&&o.rotate(r,e,i),n.parent().append(o)}return n.remove(),!1}return t.forEach(t=>{"fill"===t&&"none"===n.attr("fill")||n.removeAttr(t)}),!0},transformMaskRoot(t,e){var n=this.MASK_ROOT_ATTRIBUTE_BLACKLIST;n.forEach(t=>{e.removeAttr(t)})},getMaskShape(e,t){var{options:n,MASK_REPLACE_TAGS:i}=this,n=n.deep,r=t.tagName();let o;if("G"===r){if(!n)return null;for(var n=o=t.clone(),s=t=>this.transformMaskChild(e,t),a=n.children();0<a.length;){var l=a.shift();s(l)&&a.push(...l.children())}}else{if(i.includes(r))return null;o=t.clone()}return this.transformMaskRoot(e,o),o},getMaskId(){return"highlight-mask-"+this.cid},getMask(t,e){var{VISIBLE:n,INVISIBLE:i,options:r}=this,{padding:r,attrs:o}=r,s=parseFloat(R("g").attr(o).attr("stroke-width")),a="none"!==e.attr("fill");let l=parseFloat(e.attr("stroke-width"));r=(l=isNaN(l)?1:l)+2*r,s=r+2*s;let h=this.getMaskShape(t,e);return h||((t=t.getNodeBoundingRect(e.node)).inflate(t.width?0:.5,t.height?0:.5),h=R("rect",t.toJSON())),h.attr(o),R("mask",{id:this.getMaskId()}).append([h.clone().attr({fill:a?n:"none",stroke:n,"stroke-width":s}),h.clone().attr({fill:a?i:"none",stroke:i,"stroke-width":r})])},removeMask(t){var e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask(t,e){t.defs.appendChild(e.node)},highlight(t,e){var{options:n,vel:i}=this,{padding:n,attrs:r,maskClip:o=20,layer:s}=n,r="stroke"in r?r.stroke:"#000000",s=(s||e!==t.el||i.remove(),t.getNodeBoundingRect(e).inflate(n+o)),n=this.getNodeMatrix(t,e),o=this.getMask(t,R(e));this.addMask(t.paper,o),i.attr(s.toJSON()),i.attr({transform:R.matrixToTransformString(n),mask:`url(#${o.id})`,fill:r})},unhighlight(t){this.removeMask(t.paper)}}),e=Pu.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){var{alphaValue:n=.3}=this.options;e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),r=ja("highlighted"),h=Pu.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:r},highlight:function(t,e){R(e).addClass(this.options.className)},unhighlight:function(t,e){R(e).removeClass(this.options.className)}},{className:r});let Eu={ROW:"row",COLUMN:"column"};n={stroke:a,mask:Je,opacity:e,addClass:h,list:Pu.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight(t,e){t=t.model;let{attribute:r,size:n=20,gap:o=5,direction:i=Eu.ROW}=this.options;if(!r)throw new Error("List: attribute is required");let s="number"==typeof n?{width:n,height:n}:n,a=i===Eu.ROW,l=a?s.width:s.height,h=t.get(r),u=(Array.isArray(h)||(h=[]),this._prevItems||[]),c=h.map((t,e)=>na(u[e],h[e]));if(u.length!==h.length||c.some(t=>!t)){let i=this.vel.children();var d=h.map((t,e)=>{var n=e in i?i[e].node:null;if(c[e])return n;t=this.createListItem(t,s,n);if(!t)return null;if(!(t instanceof SVGElement))throw new Error("List: item must be an SVGElement");t.dataset.index=e,t.dataset.attribute=r;n=e*(l+o);return t.setAttribute("transform",a?`translate(${n}, 0)`:`translate(0, ${n})`),t});this.vel.empty().append(d),this._prevItems=h}d=h.length,d=0===d?0:d*l+(d-1)*o,d=a?{width:d,height:s.height}:{width:s.width,height:d};this.position(t,d)},position(t,e){var{vel:n,options:i}=this,{margin:i=5,position:r="top-left"}=i,{width:t,height:o}=t.size(),{left:i,right:s,top:a,bottom:l}=gl(i);let{x:h,y:u}=yh(new tt(i,a,t-(i+s),o-(a+l)),r);switch(r){case p.CENTER:case p.TOP:case p.BOTTOM:h-=e.width/2;break;case p.RIGHT:case p.BOTTOM_RIGHT:case p.TOP_RIGHT:h-=e.width}switch(r){case p.CENTER:case p.RIGHT:case p.LEFT:u-=e.height/2;break;case p.BOTTOM:case p.BOTTOM_RIGHT:case p.BOTTOM_LEFT:u-=e.height}n.attr("transform",`translate(${h}, ${u})`)}},{Directions:Eu,Positions:p})};function Tu(t,e,n){var i,r,o;return y(n)&&({x:i,y:o}=n,isFinite(o)&&({start:o,end:r}=new P(e,t).parallel(o),e=o,t=r),n=i),!isFinite(n)||(o=t.distance(e),0===n&&0<o)?t:t.move(e,-Math.min(n,o-1))}function Su(t){t=t.getAttribute("stroke-width");return null!==t&&parseFloat(t)||0}function ku(t,e,n,i){e=e.getNodeBBox(n),i.stroke&&e.inflate(Su(n)/2),n=t.intersect(e);return Tu(n?t.start.chooseClosest(n):t.end,t.start,i.offset)}var Lu="segmentSubdivisons",Cu="shapeBBox";$e={anchor:function(t,e,n,i){var{offset:i,alignOffset:r,align:o}=i;return o&&function(t,e,n){n=2<arguments.length&&void 0!==n?n:0;let i,r,o,s;var{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,o,r),Tu(t.end,t.start,i)},bbox:ku,rectangle:function(t,e,n,i){var r,o=e.model.angle();return 0===o?ku(t,e,n,i):(e=e.getNodeUnrotatedBBox(n),i.stroke&&e.inflate(Su(n)/2),n=e.center(),Tu((e=(r=t.clone().rotate(n,o)).setLength(1e6).intersect(e))?r.start.chooseClosest(e).rotate(n,-o):t.end,t.start,i.offset))},boundary:function(t,e,n,i){var r=i.selector,o=t.end,r="string"==typeof r?e.findNode(r):!1===r?n:Array.isArray(r)?Ya(n,r):(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);if(!R.isSVGGraphicsElement(r)){if(r===n||!R.isSVGGraphicsElement(n))return o;r=n}var s,n=e.getNodeShape(r),a=e.getNodeMatrix(r),l=e.getRootTranslateMatrix(),h=e.getRootRotateMatrix(),h=(l=l.multiply(h).multiply(a)).inverse(),h=(a=R.transformLine(t,h)).start.clone(),e=e.getNodeData(r);return!1===i.insideout&&(e[Cu]||(e[Cu]=n.bbox()),e[Cu].containsPoint(h))?o:(n instanceof V&&(s=i.precision||2,e[Lu]||(e[Lu]=n.getSegmentSubdivisions({precision:s})),s={precision:s,segmentSubdivisions:e[Lu]}),!0===i.extrapolate&&a.setLength(1e6),(e=a.intersect(n,s))?R.isArray(e)&&(e=h.chooseClosest(e)):!0===i.sticky&&(e=n instanceof tt?n.pointNearestToPoint(h):n instanceof yi?n.intersectionWithLineFromCenterToPoint(h):n.closestPoint(h,s)),a=e?R.transformPoint(e,l):o,n=i.offset||0,i.stroke&&(n+=Su(r)/2),Tu(a,t.start,n))}};function Mu(t,e){return 0===e?"0%":Math.round(t/e*100*1e3)/1e3+"%"}function _u(r){return function(t,e,n,i){return(e.isNodeConnection(n)?Ou:Nu)(r,t,e,n,i)}}function Nu(t,e,n,i,r){var o=n.model.angle(),i=n.getNodeUnrotatedBBox(i),n=n.model.getBBox().center(),n=(r.rotate(n,o),r.x-i.x),o=r.y-i.y;return t&&(n=Mu(n,i.width),o=Mu(o,i.height)),e.anchor={name:"topLeft",args:{dx:n,dy:o,rotate:!0}},e}function Ou(t,e,n,i,r){n=n.getConnection();return n&&(r=n.closestPointLength(r),t?(t=n.length(),e.anchor={name:"connectionRatio",args:{ratio:r/t}}):e.anchor={name:"connectionLength",args:{length:r}}),e}Rh=_u(!1);let Ru=_u(!0),Fu={useDefaults:wl,pinAbsolute:Rh,pinRelative:Ru};var Iu={N:"S",S:"N",E:"W",W:"E"},Vu={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function Bu(t,e,n){var i=new A(t.x,e.y);return i=n.containsPoint(i)?new A(e.x,t.y):i}function Du(t,e){return t["W"===e||"E"===e?"width":"height"]}function zu(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 ju(t){return new tt(t.x,t.y,0,0)}function Gu(t){t=gl(t.padding||t.elementPadding||20);return{x:-t.left,y:-t.top,width:t.left+t.right,height:t.top+t.bottom}}function Uu(t,e){return t.sourceBBox.clone().moveAndExpand(Gu(e))}function Hu(t,e){return t.targetBBox.clone().moveAndExpand(Gu(e))}function qu(t,e,n){var i=new A(t.x,e.y),r=new A(e.x,t.y),o=zu(t,i),t=zu(t,r),s=Iu[n],o=o===n||o!==s&&(t===s||t!==n)?i:r;return{points:[o],direction:zu(o,e)}}function $u(t,e,n){t=Bu(t,e,n);return{points:[t],direction:zu(t,e)}}function Wu(t,e,n,i,r){var o={},n=n.union(i).inflate(1),i=n.center().distance(e)>n.center().distance(t),s=i?e:t,t=i?t:e,a=r?(a=A.fromPolar(n.width+n.height,Vu[r],s),n.pointNearestToPoint(a).move(a,-1)):n.pointNearestToPoint(s).move(s,1),r=Bu(a,t,n);return a.round().equals(r.round())?(r=A.fromPolar(n.width+n.height,Jn(a.theta(s))+Math.PI/2,t),s=Bu(a,r=n.pointNearestToPoint(r).move(t,1).round(),n),o.points=i?[r,s,a]:[a,s,r]):o.points=i?[r,a]:[a,r],o.direction=zu(i?a:r,e),o}function Yu(t,e,n){var i,r,o=Uu(n,e),s=Hu(n,e),a=(i=e,(a=n).sourceAnchor||Uu(a,i).center()),n=(i=e,(n=n).targetAnchor||Hu(n,i).center()),o=o.union(ju(a)),s=s.union(ju(n));(t=et(t).map(A)).unshift(a),t.push(n);for(var l,h,u,c,d,f,p=[],g=0,m=t.length-1;g<m;g++){var v,y=null,b=t[g],x=t[g+1],w=!!zu(b,x);0===g?g+1===m?o.intersect(s.clone().inflate(1))?y=Wu(b,x,o,s):w||(h=o,f=d=c=void 0,d=$u(v=x,l=b,u=s),f=d.points[0],h.containsPoint(f)&&(c=(d=$u(l,v,h)).points[0],u.containsPoint(c))&&(c=new A(l).move(c,-Du(h,zu(l,c))/2),u=new A(v).move(f,-Du(u,zu(v,f))/2),u=qu(f=new P(c,u).midpoint(),v,(c=$u(l,f,h)).direction),d.points=[c.points[0],u.points[0]],d.direction=u.direction),y=d):o.containsPoint(x)?y=Wu(b,x,o,ju(x).moveAndExpand(Gu(e))):w||(y=$u(b,x,o)):g+1===m?(v=w&&zu(x,b)===r,s.containsPoint(b)||v?y=Wu(b,x,ju(b).moveAndExpand(Gu(e)),s,r):w||(y=((e,t,n,i)=>{var r,o={},s=[new A(e.x,t.y),new A(t.x,e.y)],a=s.filter(function(t){return!n.containsPoint(t)}),l=a.filter(function(t){return zu(t,e)!==i});return 0<l.length?(r=(r=l.filter(function(t){return zu(e,t)===i}).pop())||l[0],o.points=[r],o.direction=zu(r,t)):(r=la(s,a)[0],s=Bu(l=new A(t).move(r,-Du(n,i)/2),e,n),o.points=[s,l],o.direction=zu(l,t)),o})(b,x,s,r))):w||(y=qu(b,x,r)),r=y?(Array.prototype.push.apply(p,y.points),y.direction):zu(b,x),g+1<m&&p.push(x)}return p}var Xu={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(b(Yu))return Yu(t,T({},Xu,e),n);throw new Error("Manhattan requires the orthogonal router as default fallback.")},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function Zu(t){this.map={},this.options=t,this.mapGridSize=100}function Ju(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function Ku(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function Qu(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function tc(t,e){return t.sourceAnchor||Ku(t,e).center()}function ec(t,e,n,i,r){var o,n=360/n,i=t.theta((t=t,e=e,r=(r=r).step,o=e.x-t.x,e=e.y-t.y,o=o/i.x*r,e=e/i.y*r,new A(t.x+o,t.y+e))),r=Xn(i+n/2);return n*Math.floor(r/n)}function nc(t,e){t=Math.abs(t-e);return 180<t?360-t:t}function ic(t,e){var n;return t?(t=Math.abs(t),(n=Math.round(t/e))?e+(t-n*e)/n:t):e}function rc(t,e){return t.round(e)}function oc(t,e,n){return rc((t=t.clone(),i=(e=e).source,r=Zn(t.x-i.x,e.x)+i.x,t=Zn(t.y-i.y,e.y)+i.y,new A(r,t)),n);var i,r}function sc(t){return t.clone().toString()}function ac(t){return new A(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function lc(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 hc(u,c,t,d,e){var f=e.precision,p=e.directionMap,g=u.difference(c.center()),e=w(p)?Object.keys(p):[],m=et(t),t=e.reduce(function(t,e){if(m.includes(e)){for(var n,e=p[e],i=new A(u.x+e.x*(Math.abs(g.x)+c.width),u.y+e.y*(Math.abs(g.y)+c.height)),r=new P(u,i).intersect(c)||[],o=r.length,s=null,a=0;a<o;a++){var l=r[a],h=u.squaredDistance(l);(void 0===n||n<h)&&(n=h,s=l)}s&&(i=oc(s,d,f),c.containsPoint(i)&&(i=oc(i.offset(e.x*d.x,e.y*d.y),d,f)),t.push(i))}return t},[]);return c.containsPoint(u)||t.push(oc(u,d,f)),t}function uc(t,e,n,i){var r,o,s,a,l,h,u,c=i.precision,d=t instanceof tt?rc(tc(this,i).clone(),c):rc(t.clone(),c),f=e instanceof tt?rc((r=i,((f=this).targetAnchor||Qu(f,r).center()).clone()),c):rc(e.clone(),c),p=(r=i.step,h=f,{source:(o=d).clone(),x:ic(h.x-o.x,r),y:ic(h.y-o.y,r)}),g=t instanceof tt?hc(s=d,t,i.startDirections,p,i):[s=d],m=e instanceof tt?hc(a=f,e,i.endDirections,p,i):[a=f];if(g=g.filter(t=>!n(t)),m=m.filter(t=>!n(t)),0<g.length&&0<m.length){for(var v=new Ju,y={},b={},x={},w=0,I=g.length;w<I;w++){var A=g[w],P=sc(A);v.add(P,lc(A,m)),y[P]=A,x[P]=0}for(var V=i.previousDirectionAngle,B=void 0===V,D=i.directions,E=(l=p,u=(h=i).step,et(h.directions).forEach(function(t){t.gridOffsetX=t.offsetX/u*l.x,t.gridOffsetY=t.offsetY/u*l.y}),D.length),z=et(m).reduce(function(t,e){e=sc(e);return t.push(e),t},[]),j=i.maximumLoops;!v.isEmpty()&&0<j;){var T=v.pop(),S=y[T],k=b[T],G=x[T],L=void 0===k,U=S.equals(s),H=L?B?U?null:ec(s,S,E,p,i):V:ec(k,S,E,p,i),q=g.length===m.length;if(q)for(var C=0;C<g.length;C++)if(!g[C].equals(m[C])){q=!1;break}if(!(L&&q)&&0<=z.indexOf(T)){i.previousDirectionAngle=H;for(var $=b,W=y,k=S,L=s,T=a,Y=[],X=ac(T.difference(k)),M=sc(k),_=$[M];_;){var Z,J=ac((Z=W[M]).difference(_));J.equals(X)||(Y.unshift(Z),X=J),_=$[M=sc(_)]}return ac((T=W[M]).difference(L)).equals(X)||Y.unshift(T),Y}for(w=0;w<E;w++){var N,K=(N=D[w]).angle,Q=nc(H,K);if(B&&U||!(Q>i.maxAllowedDirectionChange)){var O=oc(S.clone().offset(N.gridOffsetX,N.gridOffsetY),p,c),R=sc(O);if(!v.isClose(R)&&!n(O)){if(0<=z.indexOf(R)){var F=O.equals(a);if(!F)if(nc(K,ec(O,a,E,p,i))>i.maxAllowedDirectionChange)continue}F=G+N.cost+(U?0:i.penalties[Q]);(!v.isOpen(R)||F<x[R])&&(y[R]=O,b[R]=S,v.add(R,(x[R]=F)+lc(O,m)))}}}j--}}return i.fallbackRoute.call(this,s,a,i)}function cc(t,n,i){(e=n).directions=S(e,"directions"),e.penalties=S(e,"penalties"),e.paddingBox=S(e,"paddingBox"),e.padding=S(e,"padding"),e.padding&&(r=gl(e.padding),e.paddingBox={x:-r.left,y:-r.top,width:r.left+r.right,height:r.top+r.bottom}),et(e.directions).forEach(function(t){var e=new A(0,0),n=new A(t.offsetX,t.offsetY);t.angle=Xn(e.theta(n))}),i.options.perpendicular=!!n.perpendicular;var e,r,o=Ku(i,n),s=Qu(i,n),a=tc(i,n);let l;if("function"==typeof n.isPointObstacle)l=n.isPointObstacle;else{let e=new Zu(n);e.build(i.paper.model,i.model),l=t=>!e.isPointAccessible(t)}for(var h=et(t).map(A),u=[],c=a,d=0,f=h.length;d<=f;d++){var p,g,m=null,v=p||o;if((p=h[d])||(p=s,i.model.get("source").id&&i.model.get("target").id)||!b(n.draggingRoute)||(y=v===o?a:v,g=p.origin(),m=n.draggingRoute.call(i,y,g,n)),null===(m=m||uc.call(i,v,p,l,n)))return n.fallbackRouter(t,n,i);var y=m[0];y&&y.equals(c)&&m.shift(),c=m[m.length-1]||c,Array.prototype.push.apply(u,m)}return u}Zu.prototype.build=function(n,i){var c=this.options,d=et(c.excludeEnds).reduce(function(t,e){var e=i.get(e);return e&&(e=n.getCell(e.id))&&t.push(e),t},[]),f=[],t=n.getCell(i.get("source").id),t=(t&&(f=ha(f,t.getAncestors().map(function(t){return t.id}))),n.getCell(i.get("target").id)),p=(t&&(f=ha(f,t.getAncestors().map(function(t){return t.id}))),this.mapGridSize);return n.getElements().reduce(function(t,e){var n=et(c.excludeTypes).includes(e.get("type")),i=d.find(function(t){return t.id===e.id}),r=f.includes(e.id);if(!(n||i||r))for(var o=e.getBBox().moveAndExpand(c.paddingBox),s=o.origin().snapToGrid(p),a=o.corner().snapToGrid(p),l=s.x;l<=a.x;l+=p)for(var h=s.y;h<=a.y;h+=p){var u=l+"@"+h;t[u]=t[u]||[],t[u].push(o)}return t},this.map),this},Zu.prototype.isPointAccessible=function(e){var t=e.clone().snapToGrid(this.mapGridSize).toString();return et(this.map[t]).every(function(t){return!t.containsPoint(e)})},Ju.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;e=Ks(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(e,0,t)},Ju.prototype.remove=function(t){this.hash[t]=this.CLOSE},Ju.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},Ju.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},Ju.prototype.isEmpty=function(){return 0===this.items.length},Ju.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};function dc(t,e,n){return cc(t,T({},Xu,e),n)}var fc={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},a=(90<i%180&&(a=o,o=s,s=a),i%90<45?o:s),o=new P(t,a),s=90*Math.ceil(i/90),i=A.fromPolar(o.squaredLength(),Jn(135+s),a),s=new P(e,i),a=o.intersection(s),i=a||e,o=a?i:t,s=360/n.directions.length,a=o.theta(e),t=Xn(a+s/2),o=s*Math.floor(t/s);return n.previousDirectionAngle=o,i&&r.push(i.round()),r.push(e),r}};let B={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},pc=[B.LEFT,B.RIGHT,B.TOP,B.BOTTOM],gc={[B.LEFT]:B.RIGHT,[B.RIGHT]:B.LEFT,[B.TOP]:B.BOTTOM,[B.BOTTOM]:B.TOP},mc=[B.TOP,B.BOTTOM],vc={0:B.RIGHT,180:B.LEFT,270:B.TOP,90:B.BOTTOM};function yc(t){return t.angle()}function bc(t){return new x(t).simplify({threshold:1}).points}function xc(t,e){var{point:t,x0:n,y0:i,view:r,bbox:o,direction:s}=t,{point:e,x0:a,y0:l,view:h,bbox:u,direction:c}=e;let d;d=r?r.model.isLink()?Ac(e,t,r):s===B.ANCHOR_SIDE?o.sideNearestToPoint(t):s===B.MAGNET_SIDE?r.model.getBBox().sideNearestToPoint(t):s:(o=new tt(n,i,0,0),pc.includes(s)?s:o.sideNearestToPoint(e));let f;return f=h?h.model.isLink()?Ac(t,e,h):c===B.ANCHOR_SIDE?u.sideNearestToPoint(e):c===B.MAGNET_SIDE?h.model.getBBox().sideNearestToPoint(e):c:(r=new tt(a,l,0,0),pc.includes(c)?c:r.sideNearestToPoint(t)),[d,f]}function wc(t,e,n){var[i]=xc(t,e);switch(i){case B.TOP:var r=e,o=n,{x0:s,y0:a,width:l,height:h,point:u,margin:c}=s=t,h=a+h,d=s-c,s=s+l+c,l=a-c,c=u.x,{x0:u,y0:r}=r;return u===c&&r<a?B.BOTTOM:u<c&&r<l?o.point.x===c?B.BOTTOM:B.RIGHT:c<u&&r<l?o.point.x===c?B.BOTTOM:B.LEFT:u<d&&l<r||s<u&&l<r?B.TOP:d<=u&&u<=c&&h<r||u<=s&&c<=u&&h<r?o.point.x<u?B.RIGHT:B.LEFT:B.BOTTOM;case B.RIGHT:var a=e,l=n,{y0:d,x0:s,width:c,height:h,point:r,margin:o}=d=t,c=s+c+o,u=d-o,d=d+h+o,{x:h,y:o}=r,{x0:r,y0:a}=a;return h<r&&a===o?B.LEFT:c<=r&&a<o?B.BOTTOM:c<=r&&o<a?B.TOP:r<=c&&a<u||r<=c&&d<a?B.RIGHT:r<s&&u<=a&&a<=o||r<s&&a<=d&&o<=a?l.point.y<a?B.BOTTOM:B.TOP:B.LEFT;case B.BOTTOM:var f=e,p=n,{x0:g,y0:m,width:v,height:y,point:b,margin:x}=g=t,w=g-x,g=g+v+x,v=(y=m+y)+x,x=b.x,{x0:b,y0:f}=f;return b===x&&y<f?B.TOP:b<x&&v<f?p.point.x===x?B.TOP:B.RIGHT:x<b&&v<f?p.point.x===x?B.TOP:B.LEFT:b<w&&f<v||g<b&&f<v?B.BOTTOM:w<=b&&b<=x&&f<m||b<=g&&x<=b&&f<m?p.point.x<b?B.RIGHT:B.LEFT:B.TOP;case B.LEFT:var y=e,v=n,{y0:w,x0:g,width:x,height:f,point:m,margin:p}=w=t,x=g+x,g=g-p,b=w-p,w=w+f+p,{x:f,y:p}=m,{x0:m,y0:y}=y;return m<f&&y===p?B.RIGHT:m<=g&&y<p?B.BOTTOM:m<=g&&p<y?B.TOP:g<=m&&y<b||g<=m&&w<y?B.LEFT:x<m&&b<=y&&y<=p||x<m&&y<=w&&p<=y?v.point.y<y?B.BOTTOM:B.TOP:B.RIGHT}}function Ac(t,e,n){n=n.getTangentAtLength(n.getClosestPointLength(e)),n=90*Math.round(yc(n)/90);if(n%180==0&&t.y===e.y)return t.x<e.x?B.LEFT:B.RIGHT;if(t.x===e.x)return t.y<e.y?B.TOP:B.BOTTOM;switch(n){case 0:case 180:case 360:return t.y<e.y?B.TOP:B.BOTTOM;case 90:case 270:return t.x<e.x?B.LEFT:B.RIGHT}}function Pc(t,e,n,i,r,o,s){i===B.AUTO&&(i=r?B.MAGNET_SIDE:B.ANCHOR_SIDE);var r=t&&t.model.isElement(),{x:o,y:a,width:l=0,height:h=0}=r?tt.fromRectUnion(n,t.model.getBBox()):o;return{point:e,x0:o,y0:a,view:t,bbox:n,width:l,height:h,direction:i,margin:r?s:0}}function Ec(t,e,n){var 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 Tc(t,e,n){var{dx:n=0,dy:i=0}=n,r={x:t.point.x+n,y:t.point.y+i},n={x:e.point.x+n,y:e.point.y+i};return[t.point,r,n,e.point]}function Sc(t,e,n,i){n=Xn(n-90);let r=0,o=0;90===n?o=-i:180===n?r=-i:270===n?o=i:0===n&&(r=i);n=Tc(t,e,{dx:r,dy:o}),i=n[2],t=new P(e.point,i);return{loopRoute:n,continueDirection:vc[yc(t)]}}function kc(t,e,n){switch(e){case B.LEFT:t.inflate(0,n).moveAndExpand({x:-n,width:n});break;case B.RIGHT:t.inflate(0,n).moveAndExpand({width:n});break;case B.TOP:t.inflate(n,0).moveAndExpand({y:-n,height:n});break;case B.BOTTOM:t.inflate(n,0).moveAndExpand({height:n})}return t}function Lc(i,r,e){var{point:o,x0:s,y0:a,width:l,height:n,margin:t}=i,{point:I,x0:h,y0:u,width:c,height:d,margin:f}=r,{targetInSourceBBox:e=!1}=2<arguments.length&&void 0!==e?e:{},p=h+c,g=u+d,m=s+l,v=a+n,y=s-t,b=m+t,x=a-t,w=v+t,A=h-f,P=p+f,E=u-f,T=g+f,[S,k]=xc(i,r),o=Ec(S,{point:o,x0:s,y0:a,width:l,height:n},t),L=Ec(k,{point:I,x0:h,y0:u,width:c,height:d},f),{x:C,y:M}=o,{x:_,y:N}=L,O=((s+m)/2<(h+p)/2?m+h:p+s)/2,V=((a+v)/2<(u+g)/2?v+u:g+a)/2,l=new tt(s,a,l,n),n=new tt(h,u,c,d),c=l.clone().inflate(t),d=n.clone().inflate(f),l=Object.assign({},i,{x1:m,y1:v,outsidePoint:o,direction:S}),f=Object.assign({},r,{x1:p,y1:g,outsidePoint:L,direction:k}),[i,r]=((t,e)=>{var{x0:n,x1:i,outsidePoint:r}=t,{x0:o,x1:s,outsidePoint:a}=e;let l=Math.min(n,o),h=Math.max(i,s);return t.direction===e.direction&&(o=(n=t.y0<e.y0?t:e)===t?e:t,i=t.direction===B.TOP?n:o,l=i.x0,h=i.x1),s=r.x,e=a.x,[Math.abs(s-l)+Math.abs(e-l),Math.abs(s-h)+Math.abs(e-h)]})(l,f),[l,f]=((t,e)=>{var{y0:n,y1:i,outsidePoint:r}=t,{y0:o,y1:s,outsidePoint:a}=e;let l=Math.min(n,o),h=Math.max(i,s);return t.direction===e.direction&&(o=(n=t.x0<e.x0?t:e)===t?e:t,i=t.direction===B.LEFT?n:o,l=i.y0,h=i.y1),s=r.y,e=a.y,[Math.abs(s-l)+Math.abs(e-l),Math.abs(s-h)+Math.abs(e-h)]})(l,f);if("left"===S&&"right"===k){var R=c.containsPoint(L),F=d.containsPoint(o);if(R||F)return[{x:C,y:M},{x:C,y:R=(M+N)/2},{x:_,y:R},{x:_,y:N}];if(y<_){let t=V,e=C,n=_;var F=l<f;return(t>=x&&t<=w||t>=E&&t<=T)&&(E<=w&&F?t=Math.min(E,x):x<=T&&!F&&(t=Math.max(T,w)),e=Math.min(C,A),n=Math.max(_,b),F&&M<u||!F&&g<M?e=C:(F&&N<a||!F&&v<N)&&(n=_)),[{x:e,y:M},{x:e,y:t},{x:n,y:t},{x:n,y:N}]}var R=(C+_)/2;return[{x:R,y:M},{x:R,y:N}]}if("right"===S&&"left"===k){var F=c.containsPoint(L),R=d.containsPoint(o);if(F||R)return[{x:C,y:M},{x:C,y:F=(M+N)/2},{x:_,y:F},{x:_,y:N}];if(_<b){let t=V,e=C,n=_;var R=l<f;return(t>=x&&t<=w||t>=E&&t<=T)&&(E<=w&&R?t=Math.min(E,x):x<=T&&!R&&(t=Math.max(T,w)),e=Math.max(C,P),n=Math.min(_,y),R&&M<u||!R&&g<M?e=C:(R&&N<a||!R&&v<N)&&(n=_)),[{x:e,y:M},{x:e,y:t},{x:n,y:t},{x:n,y:N}]}var F=(C+_)/2;return[{x:F,y:M},{x:F,y:N}]}if("top"===S&&"bottom"===k){var R=c.containsPoint(L),F=d.containsPoint(o);if(R||F)return[{x:C,y:M},{x:R=(C+_)/2,y:M},{x:R,y:N},{x:_,y:N}];if(x<N){let t=O,e=M,n=N;F=i<r;return(t>=y&&t<=b||t>=A&&t<=P)&&(A<=b&&F?t=Math.min(A,y):y<=P&&!F&&(t=Math.max(P,b)),e=Math.min(M,E),n=Math.max(N,w),F&&C<h||!F&&p<C?e=M:(F&&_<s||!F&&m<_)&&(n=N)),[{x:C,y:e},{x:t,y:e},{x:t,y:n},{x:_,y:n}]}R=(M+N)/2;return[{x:C,y:R},{x:_,y:R}]}if("bottom"===S&&"top"===k){F=c.containsPoint(L),R=d.containsPoint(o);if(F||R)return[{x:C,y:M},{x:L=(C+_)/2,y:M},{x:L,y:N},{x:_,y:N}];if(N<w){let t=O,e=M,n=N;var o=i<r;return(t>=y&&t<=b||t>=A&&t<=P)&&(A<=b&&o?t=Math.min(A,y):y<=P&&!o&&(t=Math.max(P,b)),e=Math.max(M,T),n=Math.min(N,x),o&&C<h||!o&&p<C?e=M:(o&&_<s||!o&&m<_)&&(n=N)),[{x:C,y:e},{x:t,y:e},{x:t,y:n},{x:_,y:n}]}F=(M+N)/2;return[{x:C,y:F},{x:_,y:F}]}if("top"===S&&"top"===k){if((e||yr.rectWithRect(c,n)||M<=u&&(c.bottomRight().x<=_||c.bottomLeft().x>=_)||u<=M&&(d.bottomRight().x<=C||d.bottomLeft().x>=C))&&C!==_)return[{x:C,y:Math.min(M,N)},{x:_,y:Math.min(M,N)}];let t;var R=Math.min((v+u)/2,N),L=Math.min((a+g)/2,M);return[{x:C,y:L},{x:t=N<M?i<r?Math.min(C,A):Math.max(C,P):i<r?Math.min(_,y):Math.max(_,b),y:L},{x:t,y:R},{x:_,y:R}]}if("bottom"===S&&"bottom"===k){if((e||yr.rectWithRect(c,n)||N<=M&&(c.topRight().x<=_||c.topLeft().x>=_)||M<=N&&(d.topRight().x<=C||d.topLeft().x>=C))&&C!==_)return[{x:C,y:Math.max(M,N)},{x:_,y:Math.max(M,N)}];let t;o=Math.max((a+g)/2,N),F=Math.max((v+u)/2,M);return[{x:C,y:F},{x:t=M<N?i<r?Math.min(C,A):Math.max(C,P):i<r?Math.min(_,y):Math.max(_,b),y:F},{x:t,y:o},{x:_,y:o}]}if("left"===S&&"left"===k){if((e||yr.rectWithRect(c,n)||C<=_&&(c.bottomRight().y<=N||c.topRight().y>=N)||_<=C&&(d.bottomRight().y<=M||d.topRight().y>=M))&&M!==N)return[{x:Math.min(C,_),y:M},{x:Math.min(C,_),y:N}];let t;L=Math.min((m+h)/2,_),R=Math.min((s+p)/2,C);return[{x:R,y:M},{x:R,y:t=C<_?l<=f?Math.min(x,N):Math.max(w,N):l<=f?Math.min(E,M):Math.max(T,M)},{x:L,y:t},{x:L,y:N}]}if("right"===S&&"right"===k){if((e||yr.rectWithRect(c,n)||_<=C&&(c.bottomLeft().y<=N||c.topLeft().y>=N)||C<=_&&(d.bottomLeft().y<=M||d.topLeft().y>=M))&&M!==N)return[{x:Math.max(C,_),y:M},{x:Math.max(C,_),y:N}];let t;var i=Math.max((s+p)/2,_),r=Math.max((m+h)/2,C);return[{x:r,y:M},{x:r,y:t=_<=C?l<=f?Math.min(x,N):Math.max(w,N):l<=f?Math.min(E,M):Math.max(T,M)},{x:i,y:t},{x:i,y:N}]}if("top"===S&&"right"===k){if(c.containsPoint(I))return C<=P?(F=Math.max(C+t,_),[{x:C,y:o=Math.min(x,E)},{x:F,y:o},{x:F,y:N}]):[{x:C,y:M},{x:R=(C-t+_)/2,y:M},{x:R,y:N}];if(N<x){if(C<_){let t=T<=x&&C<=P?V:E;return[{x:C,y:t},{x:_,y:t},{x:_,y:N}]}return[{x:C,y:N}]}L=Math.max(O,P);return _<C&&N<=v?[{x:C,y:M},{x:L,y:M},{x:L,y:N}]:y<L&&M<g?[{x:C,y:e=Math.min(x,E)},{x:n=Math.max(b,P),y:e},{x:n,y:N}]:[{x:C,y:M},{x:L,y:M},{x:L,y:N}]}if("top"===S&&"left"===k){if(c.containsPoint(I))return A<=C?(d=Math.min(C-t,_),[{x:C,y:r=Math.min(x,E)},{x:d,y:r},{x:d,y:N}]):[{x:C,y:M},{x:l=(C+t+_)/2,y:M},{x:l,y:N}];if(N<x){if(_<C){let t=T<=x&&A<=C?V:E;return[{x:C,y:t},{x:_,y:t},{x:_,y:N}]}return[{x:C,y:N}]}f=Math.min(A,O);return C<_&&N<=v?[{x:C,y:M},{x:f,y:M},{x:f,y:N}]:f<b&&M<g?[{x:C,y:i=Math.min(x,E)},{x:o=Math.min(y,A),y:i},{x:o,y:N}]:[{x:C,y:M},{x:f,y:M},{x:f,y:N}]}if("bottom"===S&&"right"===k){if(c.containsPoint(I))return C<=P?(F=Math.max(C+t,_),[{x:C,y:R=Math.max(w,T)},{x:F,y:R},{x:F,y:N}]):[{x:C,y:M},{x:e=(C-t+_)/2,y:M},{x:e,y:N}];if(w<N){if(C<_){let t=w<=E&&C<=P?V:T;return[{x:C,y:t},{x:_,y:t},{x:_,y:N}]}return[{x:C,y:N}]}n=Math.max(O,P);return _<C&&a<=N?[{x:C,y:M},{x:n,y:M},{x:n,y:N}]:y<n&&u<M?[{x:C,y:L=Math.max(w,T)},{x:r=Math.max(b,P),y:L},{x:r,y:N}]:[{x:C,y:M},{x:n,y:M},{x:n,y:N}]}if("bottom"===S&&"left"===k){if(c.containsPoint(I))return A<=C?(d=Math.min(C-t,_),[{x:C,y:l=Math.max(w,T)},{x:d,y:l},{x:d,y:N}]):[{x:C,y:M},{x:v=(C+t+_)/2,y:M},{x:v,y:N}];if(w<N){if(_<C){let t=w<=E&&A<=C?V:T;return[{x:C,y:t},{x:_,y:t},{x:_,y:N}]}return[{x:C,y:N}]}var g=Math.min(A,O);return C<_&&a<=N?[{x:C,y:M},{x:g,y:M},{x:g,y:N}]:g<b&&u<M?[{x:C,y:i=Math.max(w,T)},{x:o=Math.min(y,A),y:i},{x:o,y:N}]:[{x:C,y:M},{x:g,y:M},{x:g,y:N}]}if("left"===S&&"bottom"===k){if(c.containsPoint(I))return M<=T?[{x:f=Math.min(y,A),y:M},{x:f,y:R=Math.max(M+t,N)},{x:_,y:R}]:[{x:C,y:M},{x:C,y:F=(M-t+N)/2},{x:_,y:F}];if(_<y){if(M<N){let t=P<=y&&M<=T?O:A;return[{x:t,y:M},{x:t,y:N},{x:_,y:N}]}return[{x:_,y:M}]}e=Math.max(T,V);return N<M&&_<=m?[{x:C,y:M},{x:C,y:e},{x:_,y:e}]:x<e&&C<p?[{x:L=Math.min(y,A),y:M},{x:L,y:r=Math.max(w,T)},{x:_,y:r}]:[{x:C,y:M},{x:C,y:e},{x:_,y:e}]}if("left"===S&&"top"===k){if(c.containsPoint(I))return E<=M?(n=Math.min(M-t,N),[{x:l=Math.min(y,A),y:M},{x:l,y:n},{x:_,y:n}]):[{x:C,y:M},{x:C,y:d=(M+t+N)/2},{x:_,y:d}];if(_<y){if(N<M){let t=P<=y&&E<=M?O:A;return[{x:t,y:M},{x:t,y:N},{x:_,y:N}]}return[{x:_,y:M}]}v=Math.min(E,V);return M<N&&_<=m?[{x:C,y:M},{x:C,y:v},{x:_,y:v}]:v<w&&C<p?[{x:a=Math.min(y,A),y:M},{x:a,y:u=Math.min(x,E)},{x:_,y:u}]:[{x:C,y:M},{x:C,y:v},{x:_,y:v}]}if("right"===S&&"top"===k){if(c.containsPoint(I))return E<=M?[{x:i=Math.max(b,P),y:M},{x:i,y:o=Math.min(M-t,N)},{x:_,y:o}]:[{x:C,y:M},{x:C,y:g=(M+t+N)/2},{x:_,y:g}];if(b<_){if(N<M){let t=b<=A&&E<=M?O:P;return[{x:t,y:M},{x:t,y:N},{x:_,y:N}]}return[{x:_,y:M}]}f=Math.min(E,V);return M<N&&s<=_?[{x:C,y:M},{x:C,y:f},{x:_,y:f}]:f<w&&h<C?[{x:R=Math.max(b,P),y:M},{x:R,y:F=Math.min(x,E)},{x:_,y:F}]:[{x:C,y:M},{x:C,y:f},{x:_,y:f}]}if("right"===S&&"bottom"===k){if(c.containsPoint(I))return M<=T?[{x:L=Math.max(b,P),y:M},{x:L,y:r=Math.max(M+t,N)},{x:_,y:r}]:[{x:C,y:M},{x:C,y:e=(M-t+N)/2},{x:_,y:e}];if(b<_){if(M<N){let t=b<=A&&M<=T?O:P;return[{x:t,y:M},{x:t,y:N},{x:_,y:N}]}return[{x:_,y:M}]}l=Math.max(T,V);return N<M&&s<=_?[{x:C,y:M},{x:C,y:l},{x:_,y:l}]:x<l&&h<C?[{x:n=Math.max(b,P),y:M},{x:n,y:d=Math.max(w,T)},{x:_,y:d}]:[{x:C,y:M},{x:C,y:l},{x:_,y:l}]}}function Cc(t,e,n){var i=t===B.LEFT||t===B.RIGHT;let r=0,o=0;switch(Xn(Math.round(e))){case 0:case 90:r=i?0:n,o=i?n:0;break;case 180:case 270:r=i?0:-n,o=i?-n:0}return{dx:r,dy:o}}function Mc(n,i,r){var{sourceDirection:o=B.AUTO,targetDirection:s=B.AUTO}=i,a=i.margin||20,i=i.useVertices||!1,l=!!r.model.source().port,o=Pc(r.sourceView,r.sourceAnchor,r.sourceBBox,o,l,r.sourceAnchor,a),l=!!r.model.target().port,s=Pc(r.targetView,r.targetAnchor,r.targetBBox,s,l,r.targetAnchor,a),h=[];if(!i||0===n.length)return bc(Lc(o,s));var e=n.map(t=>{var{x:t,y:e}=t,n=new A(t,e);return{point:n,x0:n.x,y0:n.y,view:null,bbox:new tt(t,e,0,0),width:0,height:0,direction:null,margin:0}}),[l]=e,[r]=xc(o,l),i=o.view&&o.view.model.isElement(),n=i?kc(o.view.model.getBBox(),r,a):null;let t=!!i&&n.containsPoint(l.point);t?(n=(i=Ec(r,o,a)).equals(l.point),y=o.point.x===l.point.x,v=o.point.y===l.point.y,y=y&&(r===B.TOP||r===B.BOTTOM),v=v&&(r===B.LEFT||r===B.RIGHT),g=(m=new P(o.point,i)).containsPoint(l.point),v=t&&(v||y),n?(h.push(o.point,l.point),l.direction=gc[r]):g||v?({dx:y,dy:n}=Cc(r,yc(g?m:new P(o.point,l.point)),a),g=(v=Tc({point:i},l,{dx:y,dy:n}))[2],m=new P(l.point,g),i=vc[yc(m)],l.direction=i,h.push(...v)):(l.direction=r,l.margin=a,h.push(...Lc(o,l,{targetInSourceBBox:!0}),l.point))):(y=wc(o,l,e[1]||s),l.direction=y,h.push(...Lc(o,l),l.point));for(let t=0;t<e.length-1;t++){var u,c,d=e[t],f=e[t+1],p=yc(new P(d.point,f.point));p%90==0?(c=vc[p],u=bc([...h,d.point]),u=new P(u[u.length-2],u[u.length-1]),u=vc[Math.round(yc(u))],c!==gc[u]?(h.push(d.point,f.point),[,c]=xc(d,f),f.direction=c):({loopRoute:u,continueDirection:c}=Sc(d,f,p,a),f.direction=c,h.push(...u))):([p,c]=_c(d,f),d.direction=p,f.direction=c,h.push(...Lc(d,f),f.point))}n=e[e.length-1];if(s.view&&s.view.model.isElement()){var[,g]=xc(n,s),m=Ec(g,s,a),i=bc([...h,n.point]),v=new P(i[i.length-2],i[i.length-1]),r=Math.round(yc(v)),y=vc[r],o=m.equals(n.point);if(!o||y===g){n.direction=y;let t=Lc(n,s);var[l,i]=bc([...t,s.point]),v=new P(l,i),l=Math.round(yc(v)),i=vc[l],v=kc(s.view.model.getBBox(),g,a),l=n.point.x===s.point.x,b=n.point.y===s.point.y;let e=v.containsPoint(n.point);v=l&&(g===B.TOP||g===B.BOTTOM),l=b&&(g===B.LEFT||g===B.RIGHT);!o&&e&&(l||v)?({dx:b,dy:o}=Cc(g,r,a),t=Tc(n,{point:m},{dx:b,dy:o})):e&&g!==gc[y]?(n.margin=a,n.direction=g,t=Lc(n,s)):i!==y&&y===gc[i]&&(n.margin=a,t=Lc(n,s)),h.push(...t)}}else{l=n,v=s,r=yc(new P(l.point,v.point));r%90==0?(m=vc[r],b=bc(h),o=new P(b[b.length-2],l.point),g=vc[Math.round(yc(o))],m!==gc[g]?h.push(l.point):(y=Sc(l,v,r,a).loopRoute,y.pop(),h.push(...y))):([i,n]=_c(l,v),l.direction=i,v.direction=n,h.push(...Lc(l,v)))}return bc(h)}function _c(t,e){var n,i=t.direction,r=mc.includes(i);let o=t.direction,s=e.direction;return r?(r=t.point.y>e.point.y,n=e.point.x-t.point.x,i===B.BOTTOM?(o=r?gc[i]:0<=n?B.RIGHT:B.LEFT,0<n?s=r?B.LEFT:B.TOP:n<0&&(s=r?B.RIGHT:B.TOP)):(o=r?0<=n?B.RIGHT:B.LEFT:gc[i],0<n?s=r?B.BOTTOM:B.LEFT:n<0&&(s=r?B.BOTTOM:B.RIGHT))):(n=t.point.x>e.point.x,r=e.point.y-t.point.y,i===B.RIGHT?(o=n?gc[i]:0<=r?B.BOTTOM:B.TOP,0<r?s=n?B.TOP:B.LEFT:r<0&&(s=n?B.BOTTOM:B.LEFT)):(o=n?0<=r?B.BOTTOM:B.TOP:gc[i],0<r?s=n?B.RIGHT:B.TOP:r<0&&(s=n?B.RIGHT:B.BOTTOM))),[o,s]}Mc.Directions=B;var Nc={normal:function(t,e,n){return t},oneSide:function(t,e,n){var i,r,o,s=e.side||"bottom",e=gl(e.padding||40),a=n.sourceBBox,n=n.targetBBox,l=a.center(),h=n.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 l[i]+=o*(a[r]/2+e[s]),h[i]+=o*(n[r]/2+e[s]),0<o*(l[i]-h[i])?h[i]=l[i]:l[i]=h[i],[l].concat(t,h)},orthogonal:Yu,manhattan:dc,metro:function(t,e,n){if(b(dc))return dc(t,T({},fc,e),n);throw new Error("Metro requires the manhattan router.")},rightAngle:Mc};function Oc(o){return function(t,e,n,i){var r;return n instanceof Element?(r=(r=this.paper.findView(n))?r.isNodeConnection(n)?Rc(r,"fixedAt"in i?i.fixedAt:"50%"):r.getNodeBBox(n).center():new A,o.call(this,t,e,r,i)):o.apply(this,arguments)}}function Rc(t,e){var n=parseFloat(e);return ll(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}l=Oc(function(t,e,n,i){var r=t.getConnection(),o=t.getConnectionSubdivisions(),s=new P(n.clone().offset(0,1e6),n.clone().offset(0,-1e6)),a=new P(n.clone().offset(1e6,0),n.clone().offset(-1e6,0)),s=s.intersect(r,{segmentSubdivisions:o}),a=a.intersect(r,{segmentSubdivisions:o}),r=[];return s&&Array.prototype.push.apply(r,s),a&&Array.prototype.push.apply(r,a),0<r.length?n.chooseClosest(r):"fallbackAt"in i?Rc(t,i.fallbackAt):Fc(t,e,n,i)});let Fc=Oc(function(t,e,n,i){return(t=t.getClosestPoint(n))||new A}),Ic={resolveRef:Oc,connectionRatio:function(t,e,n,i){return i="ratio"in i?i.ratio:.5,t.getPointAtRatio(i)},connectionLength:function(t,e,n,i){return i="length"in i?i.length:20,t.getPointAtLength(i)},connectionPerpendicular:l,connectionClosest:Fc};function Vc(l){return function(t,e,n,i){var r=!!i.rotate,e=r?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e),o=e[l](),s=i.dx,a=(s&&(a=ll(s),s=parseFloat(s),isFinite(s))&&(a&&(s=s/100*e.width),o.x+=s),i.dy);return a&&(s=ll(a),a=parseFloat(a),isFinite(a))&&(s&&(a=a/100*e.height),o.y+=a),r?o.rotate(t.model.getBBox().center(),-t.model.angle()):o}}i={center:Vc("center"),top:Vc("topMiddle"),bottom:Vc("bottomMiddle"),left:Vc("leftMiddle"),right:Vc("rightMiddle"),topLeft:Vc("origin"),topRight:Vc("topRight"),bottomLeft:Vc("bottomLeft"),bottomRight:Vc("corner"),perpendicular:Oc(function(t,e,n,i){var r,o=t.model.angle(),e=(t=t.getNodeBBox(e)).center(),s=t.origin(),t=t.corner(),i=i.padding;return isFinite(i)||(i=0),s.y+i<=n.y&&n.y<=t.y-i?(r=n.y-e.y,e.x+=0===o||180===o?0:r/Math.tan(Jn(o)),e.y+=r):s.x+i<=n.x&&n.x<=t.x-i&&(r=n.x-e.x,e.y+=90===o||270===o?0:r*Math.tan(Jn(o)),e.x+=r),e}),midSide:Oc(function(t,e,n,i){var r,o,s,a,l=!!i.rotate,t=(l?(r=t.getNodeUnrotatedBBox(e),s=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e),i.padding);switch(isFinite(t)&&r.inflate(t),l&&n.rotate(s,o),r.sideNearestToPoint(n)){case"left":a=r.leftMiddle();break;case"right":a=r.rightMiddle();break;case"top":a=r.topMiddle();break;case"bottom":a=r.bottomMiddle()}return l?a.rotate(s,-o):a}),modelCenter:function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)}};let Bc=cu.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace="undefined"!=typeof joint&&da(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){var n=e.collection.cellNamespace,i=t.type,n=Ya(n,i,".");if(n)return new n(t,e);throw new Error(`dia.Graph: Could not find cell constructor for type: '${i}'. Make sure to add the constructor to 'cellNamespace'.`)},_addReference:function(t,e){cu.prototype._addReference.apply(this,arguments),e.dry||t.graph||(t.graph=this.graph)},_removeReference:function(t,e){cu.prototype._removeReference.apply(this,arguments),e.dry||t.graph!==this.graph||(t.graph=null)},comparator:function(t){return t.get("z")||0}}),Dc=El.extend({initialize:function(t,e){e=e||{};e=new Bc([],{model:e.cellModel,cellNamespace:e.cellNamespace,graph:this});El.prototype.set.call(this,"cells",e),e.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},e.on("add",this._restructureOnAdd,this),e.on("remove",this._restructureOnRemove,this),e.on("reset",this._restructureOnReset,this),e.on("change:source",this._restructureOnChangeSource,this),e.on("change:target",this._restructureOnChangeTarget,this),e.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){var e,n;t.isLink()?(this._edges[t.id]=!0,{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)):this._nodes[t.id]=!0},_restructureOnRemove:function(t){var e,n;t.isLink()?(delete this._edges[t.id],{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]):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=(e.id&&this._out[e.id]&&delete this._out[e.id][t.id],t.attributes.source);e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target"),e=(e.id&&this._in[e.id]&&delete this._in[e.id][t.id],t.get("target"));e.id&&((this._in[e.id]||(this._in[e.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=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=El.prototype.toJSON.apply(this,arguments);return e.cells=this.get("cells").toJSON(t.cellAttributes),e},fromJSON:function(t,e){if(t.cells)return this.set(t,e);throw new Error("Graph JSON must contain cells array.")},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=ua(i,"cells")),El.prototype.set.call(this,i,n)},clear:function(t){t=T({},t,{clear:!0});var e=this.get("cells");if(0!==e.length){this.startBatch("clear",t);for(var n=e.sortBy(function(t){return t.isLink()?1:2});n.shift().remove(t),0<n.length;);this.stopBatch("clear")}return this},_prepareCell:function(t){let e;if(e=t instanceof El?t.attributes:t,E(e.type))return t;throw new TypeError("dia.Graph: cell type must be a string.")},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 El?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=aa(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){t=et(t).map(function(t){return this._prepareCell(t,e)},this);return this.get("cells").reset(t,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),Xs(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})},transferCellEmbeds:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i="transfer-embeds",t=(this.startBatch(i),t.getEmbeddedCells());e.embed(t,{...n,reparent:!0}),this.stopBatch(i)},transferCellConnectedLinks:function(e,n){let i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};var t="transfer-connected-links";this.startBatch(t),this.getConnectedLinks(e,i).forEach(t=>{t.getSourceCell()===e&&t.prop(["source","id"],n.id,i),t.getTargetCell()===e&&t.prop(["target","id"],n.id,i)}),this.stopBatch(t)},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,r){var o,s=(r=r||{}).indirect,a=r.inbound,l=r.outbound,h=(void 0===a&&void 0===l&&(a=l=!0),[]),u={};function c(i,t){pa(i.getOutboundEdges(t.id),function(t,e){var n;u[e]||(n=i.getCell(e),h.push(n),u[e]=!0,s&&(a&&d(i,n),l)&&c(i,n))}.bind(i)),s&&t.isLink()&&(t=t.getTargetCell())&&t.isLink()&&(u[t.id]||(h.push(t),c(i,t)))}function d(i,t){pa(i.getInboundEdges(t.id),function(t,e){var n;u[e]||(n=i.getCell(e),h.push(n),u[e]=!0,s&&(a&&d(i,n),l)&&c(i,n))}.bind(i)),s&&t.isLink()&&(t=t.getSourceCell())&&t.isLink()&&(u[t.id]||(h.push(t),d(i,t)))}return l&&c(this,t),a&&d(this,t),r.deep&&(t=t.getEmbeddedCells({deep:!0}),o={},t.forEach(function(t){t.isElement()&&(o[t.id]=!0)}),t.forEach(function(t){t.isLink()||(l&&pa(this.getOutboundEdges(t.id),function(t,e){var n,i;u[e]||({source:n,target:i}=this.getCell(e).attributes,n=n.id,i=i.id,!r.includeEnclosed&&n&&o[n]&&i&&o[i])||(h.push(this.getCell(e)),u[e]=!0)}.bind(this)),a&&pa(this.getInboundEdges(t.id),function(t,e){var n,i;u[e]||({source:n,target:i}=this.getCell(e).attributes,n=n.id,i=i.id,!r.includeEnclosed&&n&&o[n]&&i&&o[i])||(h.push(this.getCell(e)),u[e]=!0)}.bind(this)))},this)),h},getNeighbors:function(o,s){var t,a=(s=s||{}).inbound,l=s.outbound,e=(void 0===a&&void 0===l&&(a=l=!0),this.getConnectedLinks(o,s).reduce(function(t,e){var n,{source:i,target:r}=e.attributes,e=e.hasLoop(s);return a&&da(i,"id")&&!t[i.id]&&(n=this.getCell(i.id)).isElement()&&(e||!(!n||n===o||s.deep&&n.isEmbeddedIn(o)))&&(t[i.id]=n),l&&da(r,"id")&&!t[r.id]&&(i=this.getCell(r.id)).isElement()&&(e||!(!i||i===o||s.deep&&i.isEmbeddedIn(o)))&&(t[r.id]=i),t}.bind(this),{}));return o.isLink()&&(a&&(t=o.getSourceCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),l)&&(t=o.getTargetCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),et(e)},getCommonAncestor:function(){var t=(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)).sort(function(t,e){return t.length-e.length}),e=et(t.shift()).find(function(e){return t.every(function(t){return t.includes(e)})});return this.getCell(e)},getSuccessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},T({},t,{outbound:!0})),n},cloneCells:Dl,cloneSubgraph:function(t,e){t=this.getSubgraph(t,e);return this.cloneCells(t)},getSubgraph:function(t,e){e=e||{};var i=[],r={},n=[],o=[];return et(t).forEach(function(t){r[t.id]||(i.push(t),((r[t.id]=t).isLink()?o:n).push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach(function(t){r[t.id]||(i.push(t),((r[t.id]=t).isLink()?o:n).push(t))})}),o.forEach(function(t){var{source:t,target:e}=t.attributes;t.id&&!r[t.id]&&(t=this.getCell(t.id),i.push(t),r[t.id]=t,n.push(t)),e.id&&!r[e.id]&&(t=this.getCell(e.id),i.push(this.getCell(e.id)),r[t.id]=t,n.push(t))},this),n.forEach(function(t){this.getConnectedLinks(t,e).forEach(function(t){var{source:e,target:n}=t.attributes;!r[t.id]&&e.id&&r[e.id]&&n.id&&r[n.id]&&(i.push(t),r[t.id]=t)})},this),i},getPredecessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},T({},t,{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){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.shift();if(!i[s.id]&&!(i[s.id]=!0)!==e.call(this,s,r[s.id])){var a=this.getNeighbors(s,n);for(let t=0,e=a.length;t<e;t++){var l=a[t];r[l.id]=r[s.id]+1,o.push(l)}}}},dfs:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.pop();if(!i[s.id]&&!(i[s.id]=!0)!==e.call(this,s,r[s.id])){var a=this.getNeighbors(s,n),l=o.length;for(let t=0,e=a.length;t<e;t++){var h=a[t];r[h.id]=r[s.id]+1,o.splice(l,0,h)}}}},getSources:function(){var n=[];return pa(this._nodes,function(t,e){this._in[e]&&!ea(this._in[e])||n.push(this.getCell(e))}.bind(this)),n},getSinks:function(){var n=[];return pa(this._nodes,function(t,e){this._out[e]&&!ea(this._out[e])||n.push(this.getCell(e))}.bind(this)),n},isSource:function(t){return!this._in[t.id]||ea(this._in[t.id])},isSink:function(t){return!this._out[t.id]||ea(this._out[t.id])},isSuccessor:function(e,n){var i=!1;return this.search(e,function(t){if(t===n&&t!==e)return!(i=!0)},{outbound:!0}),i},isPredecessor:function(e,n){var i=!1;return this.search(e,function(t){if(t===n&&t!==e)return!(i=!0)},{inbound:!0}),i},isNeighbor:function(t,n,e){var i=(e=e||{}).inbound,r=e.outbound,o=(void 0===i&&void 0===r&&(i=r=!0),!1);return this.getConnectedLinks(t,e).forEach(function(t){var{source:t,target:e}=t.attributes;return i&&da(t,"id")&&t.id===n.id||r&&da(e,"id")&&e.id===n.id?!(o=!0):void 0}),o},disconnectLinks:function(e,n){this.getConnectedLinks(e).forEach(function(t){t.set(t.attributes.source.id===e.id?"source":"target",{x:0,y:0},n)})},removeLinks:function(t,e){Xs(this.getConnectedLinks(t),"remove",e)},findElementsAtPoint:function(t,e){return this._filterAtPoint(this.getElements(),t,e)},findLinksAtPoint:function(t,e){return this._filterAtPoint(this.getLinks(),t,e)},findCellsAtPoint:function(t,e){return this._filterAtPoint(this.getCells(),t,e)},_filterAtPoint:function(t,e){let n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return t.filter(t=>t.getBBox({rotate:!0}).containsPoint(e,n))},findElementsInArea:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this._filterInArea(this.getElements(),t,e)},findLinksInArea:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this._filterInArea(this.getLinks(),t,e)},findCellsInArea:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this._filterInArea(this.getCells(),t,e)},_filterInArea:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};let i=new tt(e);var{strict:e=!1}=n;let r=e?"containsRect":"intersect";return t.filter(t=>i[r](t.getBBox({rotate:!0})))},findElementsUnderElement:function(t,e){return this._filterCellsUnderElement(this.getElements(),t,e)},findLinksUnderElement:function(t,e){return this._filterCellsUnderElement(this.getLinks(),t,e)},findCellsUnderElement:function(t,e){return this._filterCellsUnderElement(this.getCells(),t,e)},_isValidElementUnderElement:function(t,e){return t.id!==e.id&&!t.isEmbeddedIn(e)},_isValidLinkUnderElement:function(t,e){return t.source().id!==e.id&&t.target().id!==e.id&&!t.isEmbeddedIn(e)},_validateCellsUnderElement:function(t,e){return t.filter(t=>t.isLink()?this._isValidLinkUnderElement(t,e):this._isValidElementUnderElement(t,e))},_getFindUnderElementGeometry:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"bbox",t=t.getBBox({rotate:!0});return"bbox"!==e?yh(t,e):t},_filterCellsUnderElement:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=this._getFindUnderElementGeometry(e,n.searchBy),t=i.type===d.Point?this._filterAtPoint(t,i):this._filterInArea(t,i,n);return this._validateCellsUnderElement(t,e)},findModelsInArea:function(t,e){return this.findElementsInArea(t,e)},findModelsFromPoint:function(t){return this.findElementsAtPoint(t)},findModelsUnderElement:function(t,e){return this.findElementsUnderElement(t,e)},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t){let{rotate:n=!0}=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return et(t).reduce(function(t,e){e=e.getBBox({rotate:n});return e?t?t.union(e):e:t},null)},translate:function(t,e,n){var i=this.getCells().filter(function(t){return!t.isEmbedded()});return Xs(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);return r&&(t=Math.max(t/r.width,0),e=Math.max(e/r.height,0),Xs(n,"scale",t,e,r.origin(),i)),this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",T({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",T({},e,{batchName:t}))},hasActiveBatch:function(t){let e=this._batches,n;return(n=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t]).some(t=>0<e[t])}},{validations:{multiLinks:function(t,e){var{source:n,target:i}=e.attributes;if(n.id&&i.id){e=e.getSourceCell();if(e)if(1<t.getConnectedLinks(e,{outbound:!0}).filter(function(t){var{source:t,target:e}=t.attributes;return t&&t.id===n.id&&(!t.port||t.port===n.port)&&e&&e.id===i.id&&(!e.port||e.port===i.port)}).length)return!1}return!0},linkPinning:function(t,e){var{source:e,target:n}=e.attributes;return e.id&&n.id}}}),zc=(mh(Dc.prototype,["resetCells","addCells","removeCells"],vh.cells),{GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"}),jc=uu.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return ja(this.options.name+"-layer")},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){var e=this.el;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(e){var{el:n,pivotNodes:i}=this,r=i[e=(e=+e)||0];if(!r){r=i[e]=document.createComment("z-index:"+(e+1));let t=-1/0;for(var o in i)(o=+o)<e&&o>t&&(t=o);t!==-1/0?(i=i[t],n.insertBefore(r,i.nextSibling)):n.insertBefore(r,n.firstChild)}return r},removePivots:function(){var t,{el:e,pivotNodes:n}=this;for(t in n)e.removeChild(n[t]);this.pivotNodes={}}});let Gc=["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),{}),Uc=["r","rx","ry","width","height","stroke-width","font-size"].reduce((t,e)=>(t[e]=!0,t),{});function Hc(t,e){var n,i={};for(n in t)t.hasOwnProperty(n)&&(i[n]=qc(n,t[n],e));return i}function qc(e,n,i){if(e in Gc&&Zl(n)){let t=Ql(n,i);return t=e in Uc?Math.max(0,t):t}return n}let $c={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"};let g=uu.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var i=["cell"],t=this.model.get("type");return t&&t.toLowerCase().split(".").forEach(function(t,e,n){i.push("type-"+n.slice(0,e+1).join("-"))}),i.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e={},n={},i=0,r=S(this,"presentationAttributes");for(t in r)if(r.hasOwnProperty(t))for(var o=r[t],s=0,a=(o=Array.isArray(o)?o:[o]).length;s<a;s++){var l,h=(h=e[l=o[s]])||(e[l]=1<<i++);n[t]|=h}var u=S(this,"initFlag");for(s=0,a=(u=Array.isArray(u)?u:[u]).length;s<a;s++)e[l=u[s]]||(e[l]=1<<i++);if(25<i)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=e,this._presentationAttributes=n},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||tl(this),uu.call(this,t)},initialize:function(){this.setFlags(),uu.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){t=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&t&&(e.dirty&&this.hasFlag(t,"UPDATE")&&(t|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(t,e))},requestUpdate:function(t,e){var n=this.paper;n&&0<t&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n,t=$a(t),i=t.selectors,r=t.groupSelectors;for(n in r){if(i[n])throw new Error("dia.CellView: ambiguous group selector");i[n]=r[n]}if(e){var o=this.selector;if(i[o])throw new Error("dia.CellView: ambiguous root selector.");i[o]=e}return{fragment:t.fragment,selectors:i}},can:function(t){var e=b(this.options.interactive)?this.options.interactive(this):this.options.interactive;return w(e)&&!1!==e[t]||Hs(e)&&!1!==e},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){n=n[t];if(n)return Array.isArray(n)?n:[n]}return this.useCSSSelectors?L(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){var[t=null]=this.findNodes(t);return t},notify:function(t){var e;this.paper&&(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){return t=t&&t.useModelGeometry?(t=this.model).getBBox().bbox(t.angle()):this.getNodeBBox(this.el),this.paper.localToPaperRect(t)},getNodeBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),t=this.getNodeMatrix(t);return R.transformRect(e,n.multiply(t))},getNodeRotateMatrix(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():R.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),t=this.getNodeMatrix(t),n=this.getRootTranslateMatrix();return R.transformRect(e,n.multiply(t))},getRootTranslateMatrix:function(){var t=this.model.position();return R.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t,e=R.createSVGMatrix(),n=this.model,i=n.angle();return i&&(t=(n=n.getBBox()).width/2,e=e.translate(t,n=n.height/2).rotate(i).translate(-t,-n)),e},_notifyHighlight:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=this.el;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=$c.EMBEDDING;break;case n.connecting:t=$c.CONNECTING;break;case n.magnetAvailability:t=$c.MAGNET_AVAILABILITY;break;case n.elementAvailability:t=$c.ELEMENT_AVAILABILITY;break;default:t=$c.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){return this._notifyHighlight("cell:unhighlight",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{})},findMagnet:function(t){var e=this.el;let n=this.$(t)[0];n=n||e;do{var i=n.getAttribute("magnet"),r=n===e;if((i||r)&&"false"!==i)return n;if(r)return}while(n=n.parentNode)},findProxyNode:function(t,e){e=(t=t||this.el).getAttribute(e+"-selector");if(e){e=this.findNode(e);if(e)return e}return t},getSelector:function(t,e){var n,i;return t===this.el?"string"==typeof e?":scope > "+e:i:(t&&(n=R(t).index()+1,i=t.tagName+":nth-child("+n+")",e&&(i+=" > "+e),i=this.getSelector(t.parentNode,i)),i)},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(e){var n=this.model,i=n.id,r=this.findAttributeNode("port",e),o=e.getAttribute("joint-selector"),i={id:i};if(null!=o&&(i.magnet=o),null!=r){let t=r.getAttribute("port");"number"===r.getAttribute("port-id-type")&&(t=parseInt(t,10)),i.port=t,n.hasPort(t)||o||(i.selector=this.getSelector(e))}else null==o&&this.el!==e&&(i.selector=this.getSelector(e));for(var t=arguments.length,s=new Array(1<t?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return this.customizeLinkEnd(i,e,...s)},customizeLinkEnd:function(t,e,n,i,r,o){var s=this.paper,a=s.options.connectionStrategy;if("function"==typeof a){a=a.call(s,t,this,e,new A(n,i),r,o,s);if(a)return a}return t},getMagnetFromLinkEnd:function(t){var e=t.port,n=t.magnet,i=this.model,i=null!=e&&i.isElement()&&i.hasPort(e)?this.findPortNode(e,n)||this.el:(n=n||t.selector,this.findNode(n=n||null==e?n:'[port="'+e+'"]'));return this.findProxyNode(i,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");e=this.addLinkFromMagnet(e,n,i);e.notifyPointerdown(t,n,i),e.eventData(t,e.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:e})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var r=this.paper,o=r.options.magnetThreshold,s=this.getEventTarget(t),i=i.targetMagnet;if("onleave"===o){if(i===s||R(i).contains(s))return}else if(r.eventData(t).mousemoved<=o)return;this.dragLinkStart(t,i,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){ea(e)||(t instanceof SVGElement?R:L)(t).attr(e)},processNodeAttributes:function(t,e){var n,i,r,o,s,a,l,h,u,c=[],d={};for(n in e)e.hasOwnProperty(n)&&(d[R.attributeNames[n]]=e[n]);for(n in d)if(d.hasOwnProperty(n))if(i=d[n],r=this.getAttributeDefinition(n))if(null===i){let e;if(e=(e=!(e=b(r.unset)?r.unset.call(this,t,d,this):r.unset)&&E(r.set)?r.set:e)||n,E(e)&&e)a=a||{},e in a||(a[e]=i);else if(Array.isArray(e)&&0<e.length)for(a=a||{},o=0,s=e.length;o<s;o++){let t=e[o];t in a||(a[t]=i)}}else!b(r.qualify)||r.qualify.call(this,i,t,d,this)?(E(r.set)&&((a=a||{})[r.set]=i),c.push(n,r)):(a=a||{})[n]=i;else(a=a||{})[n]=i;for(o=0,s=c.length;o<s;o+=2)r=c[o+1],i=e[n=c[o]],b(r.set)&&((l=l||{})[n]=i),b(r.position)&&((h=h||{})[n]=i),b(r.offset)&&((u=u||{})[n]=i);return{raw:d,normal:a,set:l,position:h,offset:u}},updateRelativeAttributes:function(t,e,n,i){i=i||{};var r,o,s=Hc(e.raw||{},n),a=e.normal||{};for(o in a)a[o]=s[o];var l=e.position,h=e.offset;for(r in e.set){var u=s[r],c=this.getAttributeDefinition(r).set.call(this,u,n.clone(),t,s,this);w(c)?T(a,c):void 0!==c&&(a[r]=c)}if(t instanceof HTMLElement)this.setNodeAttributes(t,a);else{var d,f,p,e=a.transform,g=R.transformStringToMatrix(e),m=A(g.e,g.f),v=(e&&(a=ua(a,"transform"),g.e=g.f=0),(l||h)&&(f=(i=this.getNodeScale(t,i.scalableNode)).sx,p=i.sy),!1);for(r in l)u=s[r],(d=this.getAttributeDefinition(r).position.call(this,u,n.clone(),t,s,this))&&(m.offset(A(d).scale(f,p)),v=v||!0);this.setNodeAttributes(t,a);var y=!1;if(h){i=this.getNodeBoundingRect(t);if(0<i.width&&0<i.height){var b=R.transformRect(i,g).scale(1/f,1/p);for(r in h)u=s[r],(d=this.getAttributeDefinition(r).offset.call(this,u,b,t,s,this))&&(m.offset(A(d).scale(f,p)),y=y||!0)}}(void 0!==e||v||y)&&(m.round(1),g.e=m.x,g.f=m.y,t.setAttribute("transform",R.matrixToTransformString(g)))}},getNodeScale:function(t,e){var n;return e=e&&e.contains(t)?(n=1/(t=e.scale()).sx,1/t.sy):n=1,{sx:n,sy:e}},cleanNodesCache:function(){this.metrics={}},cleanNodeCache:function(t){t=t.id;t&&delete this.metrics[t]},nodeCache:function(t){var e=this.metrics;return e?e[t=R.ensureId(t)]||(e[t]={}):{}},getNodeData:function(t){t=this.nodeCache(t);return t.data||(t.data={}),t.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=R(t).getBBox()),new tt(e.boundingRect)},getNodeMatrix:function(e){var n=this.nodeCache(e);if(void 0===n.magnetMatrix){var{rotatableNode:i,el:r}=this;let t;t=i&&i.contains(e)?i:r,n.magnetMatrix=R(e).getTransformToElement(t)}return R.createSVGMatrix(n.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=R(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=[];for(o in t)if(t.hasOwnProperty(o)&&(r=t[o],y(r)))for(var l=n[o]=this.findBySelector(o,e,i),h=0,u=l.length;h<u;h++){var c,d,f=l[h],p=R.ensureId(f),g=i&&i[o]===f,m=s[p];m?(m.array||(a.push(p),m.array=!0,m.attributes=[m.attributes],m.selectedLength=[m.selectedLength]),c=m.attributes,m=m.selectedLength,g?(c.unshift(r),m.unshift(-1)):(d=Ks(m,u),c.splice(d,0,r),m.splice(d,0,u))):s[p]={attributes:r,selectedLength:g?-1:u,node:f,array:!1}}for(h=0,u=a.length;h<u;h++)(r=s[p=a[h]]).attributes=k({},...r.attributes.reverse());return s},getEventTarget:function(t){var{target:e,type:n,clientX:i=0,clientY:r=0}=t;return(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).fromPoint||"touchmove"===n||"touchend"===n||"pointerId"in t&&e.hasPointerCapture(t.pointerId)?document.elementFromPoint(i,r):e},updateDOMSubtreeAttributes:function(t,e,n){(n=n||{}).rootBBox||(n.rootBBox=tt()),n.selectors||(n.selectors=this.selectors);var i,r,o={},s={},a=[],l=[],h=n.roAttributes,u=this.findNodesAttributes(h||e,t,o,n.selectors),c=h?this.findNodesAttributes(e,t,o,n.selectors):u;for(r in u)if(f=(d=u[r]).attributes,m=d.node,(i=this.processNodeAttributes(m,f)).set||i.position||i.offset||i.raw.ref){var d=c[r]&&c[r].attributes,f=(d&&void 0===f.ref?d:f).ref;if(f){if(!(g=(o[f]||this.findBySelector(f,t,n.selectors))[0]))throw new Error('dia.CellView: "'+f+'" reference does not exist.')}else g=null;p={node:m,refNode:g,processedAttributes:i,allAttributes:d},g?-1<(f=l.findIndex(function(t){return t.refNode===m}))?l.splice(f,0,p):l.push(p):a.push(p)}else this.setNodeAttributes(m,Hc(i.normal,n.rootBBox));a.push(...l);for(let e=0,t=a.length;e<t;e++){var p,g,m=(p=a[e]).node,v=(g=p.refNode)?R.ensureId(g):"";let t=s[v];t=t||(s[v]=g?R(g).getBBox({target:((t,e)=>{let n=t;do{if(n.contains(e))return n}while(n=n.parentNode);return null})(m,g)}):n.rootBBox),h?(i=this.processNodeAttributes(m,p.allAttributes),this.mergeProcessedAttributes(i,p.processedAttributes)):i=p.processedAttributes,this.updateRelativeAttributes(m,i,t,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),T(t.set,e.set),T(t.position,e.position),T(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(),Pu.mount(this))},onDetach(){this.unmountTools(),Pu.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).configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},unmountTools(){var t=this._toolsView;return t&&t.unmount(),this},mountTools(){var 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(){Pu.remove(this)},updateHighlighters:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];Pu.update(this,null,t)},transformHighlighters:function(){Pu.transform(this)},preventDefaultInteraction(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented(t){var{defaultInteractionPrevented:t=!1}=this.eventData(t);return t},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){var i=this.model,r=i.graph;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){var i=this.eventData(t).graph;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){var{paper:e,model:n}=this,i=(e.isAsync()&&(n.isLink()&&((i=n.getSourceElement())&&(i=e.findViewByModel(i))&&(e.dumpView(i),e.checkViewVisibility(i)),i=n.getTargetElement())&&(n=e.findViewByModel(i))&&(e.dumpView(n),e.checkViewVisibility(n)),e.dumpView(this),e.checkViewVisibility(this)),this.getEventTarget(t,{fromPoint:!0})),n=e.findView(i);n!==this&&(this.mouseleave(t),n)&&n.mouseenter(t)},setInteractivity:function(t){this.options.interactive=t},isIntersecting:function(t,e){return yr.exists(t,this.getNodeBBox(this.el),e)},isEnclosedIn:function(t){return t.containsRect(this.getNodeBBox(this.el))},isInArea:function(t){return(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).strict?this.isEnclosedIn(t):this.isIntersecting(t)},isAtPoint:function(t,e){return this.getNodeBBox(this.el).containsPoint(t,e)}},{Flags:{TOOLS:"TOOLS"},Highlighting:$c,addPresentationAttributes:function(t){return k({},S(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)?Qs(t.concat(e)):void 0})},evalAttribute:qc});Object.defineProperty(g.prototype,"useCSSSelectors",{get(){var t=this.model.useCSSSelectors;return void 0!==t?t:Ua.useCSSSelectors}});let m={TOOLS:g.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},Wc={MOVE:"move",MAGNET:"magnet"},Yc=g.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=g.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){g.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[m.UPDATE],position:[m.TRANSLATE,m.TOOLS],size:[m.RESIZE,m.PORTS,m.TOOLS],angle:[m.ROTATE,m.TOOLS],markup:[m.RENDER],ports:[m.PORTS]},initFlag:[m.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(e,n){var i=this.useCSSSelectors;this.hasFlag(e,m.PORTS)&&(this._removePorts(),this._cleanPortsCache());let r=!1;if(this.hasFlag(e,m.RENDER))this.render(),this.updateTools(n),this.updateHighlighters(!0),r=!0,e=this.removeFlag(e,[m.RENDER,m.UPDATE,m.RESIZE,m.TRANSLATE,m.ROTATE,m.PORTS,m.TOOLS]);else{let t=!1;this.hasFlag(e,m.RESIZE)&&(this.resize(n),t=!0,e=this.removeFlag(e,[m.RESIZE,m.UPDATE]),i)&&(e=this.removeFlag(e,m.PORTS)),this.hasFlag(e,m.UPDATE)&&(this.update(this.model,null,n),e=this.removeFlag(e,m.UPDATE),t=!0,i)&&(e=this.removeFlag(e,m.PORTS)),this.hasFlag(e,m.TRANSLATE)&&(this.translate(),e=this.removeFlag(e,m.TRANSLATE),r=!0),this.hasFlag(e,m.ROTATE)&&(this.rotate(),e=this.removeFlag(e,m.ROTATE),r=!0),this.hasFlag(e,m.PORTS)&&(this._renderPorts(),t=!0,e=this.removeFlag(e,m.PORTS)),t&&this.updateHighlighters(!1)}return r&&this.transformHighlighters(),this.hasFlag(e,m.TOOLS)&&(this.updateTools(n),e=this.removeFlag(e,m.TOOLS)),e},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();var n=this.useCSSSelectors,i=(n&&this._removePorts(),this.model),r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new tt(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,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.ElementView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var t=this.parseDOMJSON(t,this.el),e=this.selectors=t.selectors;this.rotatableNode=R(e[this.rotatableSelector])||null,this.scalableNode=R(e[this.scalableSelector])||null,this.vel.append(t.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(R(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(){this.rotatableNode?(this.rgRotate(),this.update()):this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var{x:t,y:e}=this.model.position();return`translate(${t},${e})`},getRotateString:function(){var t,e,n=this.model.angle();return n?({width:t,height:e}=this.model.size(),`rotate(${n},${t/2},${e/2})`):null},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,o=(0<r.node.getElementsByTagName("path").length&&(o=!0),r.getBBox({recursive:o})),s=i.width/(o.width||1),o=i.height/(o.height||1),s=(r.attr("transform","scale("+s+","+o+")"),this.rotatableNode),o=s&&s.attr("transform");o&&(s.attr("transform",o+" rotate("+-n+","+i.width/2+","+i.height/2+")"),s=r.getBBox({target:this.paper.cells}),e.set("position",{x:s.x,y:s.y},T({updateHandled:!0},t)),this.translate(),this.rotate()),this.update()},prepareEmbedding:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=t.model||this.model,n=(t.paper||this.paper).model;let i=t.initialZIndices={};var 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});let 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");r=e.parent();r?(n.getCell(r).unembed(e,{ui:!0}),t.initialParentId=r):t.initialParentId=null},processEmbedding:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=1<arguments.length?arguments[1]:void 0,n=2<arguments.length?arguments[2]:void 0,i=3<arguments.length?arguments[3]:void 0;let r=t.model||this.model;var o=t.paper||this.paper,s=o.model,{findParentBy:a,frontParentOnly:l,validateEmbedding:h}=o.options;let u,c=(u=(u=b(a)?et(a.call(s,this,e,n,i)):"pointer"===a?s.findElementsAtPoint({x:n,y:i}):s.findElementsUnderElement(r,{searchBy:a})).filter(t=>t instanceof gh&&r.id!==t.id&&!t.isEmbeddedIn(r)),l&&(u=u.slice(-1)),null);var d=t.candidateEmbedView;for(let t=u.length-1;0<=t;t--){var f=u[t];if(d&&d.model.id==f.id){c=d;break}f=f.findView(o);if(!b(h)||h.call(o,this,f)){c=f;break}}c&&c!=d&&(this.clearEmbedding(t),t.candidateEmbedView=c.highlight(c.findProxyNode(null,"container"),{embedding:!0})),!c&&d&&this.clearEmbedding(t)},clearEmbedding:function(t){var e=(t=t||{}).candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},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{var e=i.options.validateUnembedding,r=t.initialParentId;if(r&&"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(i){var{model:t,whenNotAllowed:e="revert"}=i,r=t||this.model;let o=(i.paper||this.paper).model;switch(e){case"remove":r.remove({ui:!0});break;case"revert":{let{initialParentId:t,initialPosition:e,initialZIndices:n}=i;e&&({x:a,y:s}=e,r.position(a,s,{deep:!0,ui:!0})),n&&Object.keys(n).forEach(t=>{var e=o.getCell(t);e&&e.set("z",n[t],{ui:!0})});var s,a=o.getCell(t);a&&a.embed(r,{ui:!0});break}}},getTargetParentView:function(t){var{candidateEmbedView:t=null}=this.eventData(t);return t},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){e=(t=t||this.el).getAttribute(e+"-selector");if(e){var n=this.findAttribute("port",t);if(n){n=this.findPortNode(n,e);if(n)return n}else{n=this.findNode(e);if(n)return n}}return t},notifyPointerdown(t,e,n){g.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove(t,e,n){g.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),g.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){g.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){g.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){g.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){var i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointermove(t,r,e,n),o){case Wc.MAGNET:this.dragMagnet(t,e,n);break;case Wc.MOVE:(s||this).drag(t,e,n);default:i.preventPointerEvents||this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){var i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointerup(t,r,e,n),o){case Wc.MAGNET:this.dragMagnetEnd(t,e,n);break;case Wc.MOVE:(s||this).dragEnd(t,e,n);default:i.preventPointerEvents||this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){g.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){g.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){g.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){g.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){g.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,n,i)},onmagnet:function(t,e,n){var i=t.currentTarget;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){var i,r;this.isDefaultInteractionPrevented(t)||(i=this.getDelegatedView())&&i.can("elementMove")&&(this.eventData(t,{action:Wc.MOVE,delegatedView:i}),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){var i,r=this.paper,o=t.isPropagationStopped();o&&this.eventData(t,{preventPointerEvents:!0}),!this.isDefaultInteractionPrevented(t)&&this.can("addLinkFromMagnet")&&({targetMagnet:i=t.currentTarget}=this.eventData(t),t.stopPropagation(),r.options.validateMagnet.call(r,this,i,t)?(r.options.magnetThreshold<=0&&this.dragLinkStart(t,i,e,n),this.eventData(t,{action:Wc.MAGNET})):o?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:h}=s,u=Zn(e+a.x,r),a=Zn(n+a.y,r);o.position(u,a,{restrictedArea:l,deep:!0,ui:!0}),i.options.embeddingMode&&(h||(this.prepareEmbedding(s),h=!0),this.processEmbedding(s,t,e,n)),this.eventData(t,{embedding:h})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){t=this.eventData(t);t.embedding&&this.finalizeEmbedding(t)},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:m}),M=(T(Yc.prototype,o),{TOOLS:g.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"}),Xc=g.extend({className:function(){var t=g.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(){g.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[M.RENDER],attrs:[M.UPDATE],router:[M.UPDATE],connector:[M.CONNECTOR],labels:[M.LABELS,M.TOOLS],labelMarkup:[M.LABELS],vertices:[M.UPDATE],source:[M.SOURCE,M.UPDATE],target:[M.TARGET,M.UPDATE]},initFlag:[M.RENDER,M.SOURCE,M.TARGET,M.TOOLS],UPDATE_PRIORITY:1,EPSILON:1e-6,confirmUpdate:function(n,i){if(i=i||{},this.hasFlag(n,M.SOURCE)){if(!this.updateEndProperties("source"))return n;n=this.removeFlag(n,M.SOURCE)}if(this.hasFlag(n,M.TARGET)){if(!this.updateEndProperties("target"))return n;n=this.removeFlag(n,M.TARGET)}var{paper:r,sourceView:o,targetView:s}=this;if(!r||!(o&&!r.isViewMounted(o)||s&&!r.isViewMounted(s)))if(this.hasFlag(n,M.RENDER))this.render(),this.updateHighlighters(!0),this.updateTools(i),n=this.removeFlag(n,[M.RENDER,M.UPDATE,M.LABELS,M.TOOLS,M.CONNECTOR]),Oh.test("isSafari")&&this.__fixSafariBug268376();else{let t=!1;o=this.model,r=o.attributes;let e=this.hasFlag(n,M.LABELS);e&&(this.onLabelsChange(o,r.labels,i),n=this.removeFlag(n,M.LABELS),t=!0);s=this.hasFlag(n,M.UPDATE),r=this.hasFlag(n,M.CONNECTOR);(s||r)&&(s?i.translateBy&&o.isRelationshipEmbeddedIn(i.translateBy)?this.translate(i.tx,i.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(i),n=this.removeFlag(n,[M.UPDATE,M.TOOLS,M.CONNECTOR]),e=!1,t=!0),e&&this.updateLabelPositions(),t&&this.updateHighlighters(),this.hasFlag(n,M.TOOLS)&&(this.updateTools(i),n=this.removeFlag(n,M.TOOLS))}return n},__fixSafariBug268376:function(){var n=this.el,i=Array.from(n.childNodes),r=document.createDocumentFragment();for(let t=0,e=i.length;t<e;t++)n.removeChild(i[t]),r.appendChild(i[t]);n.appendChild(r)},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(M.UPDATE),t)},isLabelsRenderRequired:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=this.model.previous("labels");if(e&&"propertyPathArray"in t&&"propertyValue"in t){var n=t.propertyPathArray||[],i=n.length;if(1<i)if(!!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,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.LinkView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){t=this.parseDOMJSON(t,this.el);this.selectors=t.selectors,this.vel.append(t.fragment)},renderStringMarkup:function(t){t=R(t);Array.isArray(t)||(t=[t]),this.vel.append(t)},_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=R(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())return(n=1<(e=n.childNodes).length||"G"!==e[0].nodeName.toUpperCase()?R("g").append(n):R(e[0])).addClass("label"),{node:n.node,selectors:t.selectors};throw new Error("dia.LinkView: invalid label markup.")}},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)e&&e.remove();else{e?e.empty():(e=t.labels=R("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(ja(S(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,h=o[a],h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),u=(h=(h?(l=h.node,h):(h=r._builtins.defaultLabel,h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),u=r._getDefaultLabel(),l=(u=this._normalizeLabelMarkup(this._getLabelMarkup(u.markup))||h).node,u)).selectors,l.setAttribute("label-idx",a),e.append(l),n[a]=l,this.selector);if(h[u])throw new Error("dia.LinkView: ambiguous label root selector.");h[u]=l,i[a]=h}e.parent()||this.mountLabels(),this.updateLabels()}return this},mountLabels:function(){var{el:t,paper:e,model:n,_V:i,options:r}=this,i=i.labels;i&&n.hasLabels()&&(i=i.node,r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(i,n.get("z")):i.parentNode!==t&&t.appendChild(i))},unmountLabels:function(){var{options:t,_V:e}=this;e&&(e=e.labels,e)&&t.labelsLayer&&e.remove()},findLabelNodes:function(t,e){var n=this._labelCache[t];return n?(t=this._labelSelectors[t],this.findBySelector(e,n,t)):[]},findLabelNode:function(t,e){var[t=null]=this.findLabelNodes(t,e);return t},_mergeLabelAttrs:function(t,e,n,i){return null===e?null:void 0===e?null===n?null:void 0===n?t?void 0:i:t?n:k({},i,n):t?k({},n,e):k({},i,n,e)},_mergeLabelSize:function(t,e){return null===t?null:void 0===t?null===e?null:void 0===e?void 0:e:k({},e,t)},updateLabels:function(){if(this._V.labels){this.paper.options.labelLayer||this.cleanNodeCache(this.el);for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,t=t._getDefaultLabel(),r=t.markup,o=t.attrs,s=t.size,a=0,l=e.length;a<l;a++){var h=this._labelCache[a],u=(h.setAttribute("cursor",n?"move":"default"),this._labelSelectors[a]),c=e[a],d=c.markup,f=c.size,d=this._mergeLabelAttrs(d||r,c.attrs,o,i),c=this._mergeLabelSize(f,s);this.updateDOMSubtreeAttributes(h,d,{rootBBox:new tt(c),selectors:u})}}return this},removeRedundantLinearVertices:function(t){var e=this.model,n=e.vertices(),n=[this.sourceAnchor,...n,this.targetAnchor],i=n.length,n=new x(n),n=(n.simplify({threshold:.001}),n.points.map(t=>t.toJSON())),r=n.length;return i===r?0:(e.vertices(n.slice(1,r-1),t),i-r)},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 A(this.sourceAnchor);case"target":return new A(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new A(this.sourcePoint);case"target":return new A(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(e)return this.sourceMagnet||e.el;break;case"target":e=this.targetView;if(e)return this.targetMagnet||e.el;break;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,{route:n,path:i}=this;n&&i&&((n=new x(n)).translate(t,e),this.route=n.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(){var{el:t,model:e,selectors:n}=this;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){var t=this.model,t=t.vertices(),e=this.findAnchors(t),n=this.sourceAnchor=e.source,e=this.targetAnchor=e.target,t=this.findRoute(t),t=(this.route=t,this.findConnectionPoints(t,n,e));this.sourcePoint=t.source,this.targetPoint=t.target},updatePath:function(){var{route:t,sourcePoint:e,targetPoint:n}=this,t=this.findPath(t,e.clone(),n.clone());this.path=t},findAnchorsOrdered:function(t,e,n,i){var r=this.model,o=r.get(t),r=r.get(n),s=this.getEndView(t),a=this.getEndView(n),l=this.getEndMagnet(t),h=this.getEndMagnet(n),s=s?(e=e?new A(e):a?h:new A(r),this.getAnchor(o.anchor,s,l,e,t)):new A(o),e=a?(l=new A(i||s),this.getAnchor(r.anchor,a,h,l,n)):new A(r),o={};return o[t]=s,o[n]=e,o},findAnchors:function(t){var e=this.model,n=t[0],t=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",t,"source",n):this.findAnchorsOrdered("source",n,"target",t)},findConnectionPoints:function(t,e,n){var i,r=t[0],t=t[t.length-1],o=this.model,s=o.get("source"),o=o.get("target"),a=this.sourceView,l=this.targetView,h=this.paper.options;return{source:a&&!a.isNodeConnection(this.sourceMagnet)?(i=this.sourceMagnet||a.el,s=s.connectionPoint||h.defaultConnectionPoint,r=r||n,r=new P(r,e),this.getConnectionPoint(s,a,i,r,"source")):e,target:l&&!l.isNodeConnection(this.targetMagnet)?(s=this.targetMagnet||l.el,a=o.connectionPoint||h.defaultConnectionPoint,i=t||e,r=new P(i,n),this.getConnectionPoint(a,l,s,r,"target")):n}},getAnchor:function(t,e,n,i,r){var o=e.isNodeConnection(n),s=this.paper.options;if(!(t=t||(o?s.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:s.defaultAnchor)))throw new Error("Anchor required.");if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s[o?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}s=a.call(this,e,n,i,t.args||{},r,this);return s?s.round(this.decimalsRounding):new A},getConnectionPoint:function(t,e,n,i,r){var o=i.end,s=this.paper.options;if(!t)return o;if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s.connectionPointNamespace[l]))throw new Error("Unknown connection point: "+l)}return(s=a.call(this,i,e,n,t.args||{},r,this))?s.round(this.decimalsRounding):o},isIntersecting:function(t,e){var n=this.getConnection();return!!n&&yr.exists(t,n,e,{segmentSubdivisions:this.getConnectionSubdivisions()})},isEnclosedIn:function(t){var e=this.getConnection();return!!e&&!!(e=e.bbox())&&t.containsRect(e)},isAtPoint:function(t){t=new tt(t);return t.inflate(this.EPSILON),this.isIntersecting(t)},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,t=t._getDefaultLabel(),t=this._normalizeLabelPosition(t.position);return k({},e,t)},_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:k({},e,t)},updateLabelPositions:function(){if(this._V.labels&&this.path){var t=this.model.get("labels")||[];if(t.length)for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r,o=this._labelCache[n];o&&(r=t[n],r=this._normalizeLabelPosition(r.position),r=this._mergeLabelPositionProperty(r,e),r=this._getLabelTransformationMatrix(r),o.setAttribute("transform",R.matrixToTransformString(r)),this._cleanLabelMatrices(n))}}return this},_cleanLabelMatrices:function(t){var{metrics:e,_labelSelectors:n}=this,i=n[t];if(i)for(var r in i){r=i[r].id;r&&r in e&&delete e[r].magnetMatrix}},updateEndProperties:function(t){var{model:e,paper:n}=this,i=t+"View",e=e.get(t),e=e&&e.id;if(e){if(!(e=n.getModelById(e)))throw new Error("LinkView: invalid "+t+" cell.");if(!(e=e.findView(n)))return!1;this[i]=e}else this[i]=null;return this.updateEndMagnet(t),!0},updateEndMagnet:function(e){var n=e+"Magnet",i=this.getEndView(e);if(i){let t=i.getMagnetFromLinkEnd(this.model.get(e));t===i.el&&(t=null),this[n]=t}else this[n]=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:k({},e,t)},addLabel:function(t,e,n,i){var r,o,s=0,t="number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(s=e,n):e):(r=t,o=e,"number"==typeof n?(s=n,i):n),e=this._getDefaultLabelPositionArgs(),i=t,n=this._mergeLabelPositionArgs(i,e),i={position:this.getLabelPosition(r,o,s,n)};return this.model.insertLabel(-1,i,t),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,t=i?t.y:e,i=i?e:n,e={x:r,y:t},n=this.getVertexIndex(r,t);return this.model.insertVertex(n,e,i),n},sendToken:function(t,e,n){var i,r,e=w(e)?(o=e.duration,a="reverse"===e.direction,e.connection):(o=e,a=!1,null),o=o||1e3,s={dur:o+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"},a=(a&&(s.keyPoints="1;0",s.keyTimes="0;1"),R(t));if(!((e="string"==typeof e?this.findNode(e):(t=this._V).connection?t.connection.node:this.el.querySelector("path"))instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");a.appendTo(this.paper.cells).animateAlongPath(s,e),setTimeout((i=a,r=n,function(){i.remove(),"function"==typeof r&&r()}),o)},findRoute:function(t){t=t||[];var e=this.paper.options.routerNamespace||Nc,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(A);n=i}i=b(n)?n:e[n.name];if(b(i))return e=n.args||{},i.call(this,t,e,this)||t.map(A);throw new Error('dia.LinkView: unknown router: "'+n.name+'".')},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||su,r=this.model.connector(),o=this.paper.options.defaultConnector,r=r||o||{},o=b(r)?r:i[r.name];if(b(o))return(i=f(r.args||{})).raw=!0,"string"==typeof(o=o.call(this,e,n,t,i,this))?new V(R.normalizePathData(o)):o;throw new Error('dia.LinkView: unknown connector: "'+r.name+'".')},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("data")?t.data:(e=e.serialize(),t.data=e):null},getConnectionSubdivisions:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("segmentSubdivisions")?t.segmentSubdivisions:(e=e.getSegmentSubdivisions(),t.segmentSubdivisions=e):null},getConnectionLength:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("length")?t.length:(e=e.length({segmentSubdivisions:this.getConnectionSubdivisions()}),t.length=e):0},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?(ll(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,i="number"==typeof n?(s=n,i):n,n=(i&&(o.args=i),!(i&&i.absoluteDistance)),a=i&&i.absoluteDistance&&i.reverseDistance,i=i&&i.absoluteOffset,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},t=new A(t,e),e=l.closestPointT(t,h),h=l.lengthAtT(e,h);return n&&(h=h/this.getConnectionLength()||0),a&&(h=-1*(this.getConnectionLength()-h)||1),o.distance=h,h=(r=i?r:l.tangentAtT(e))?r.pointOffset(t):(n=l.pointAtT(e),{x:(a=t.difference(n)).x,y:a.y}),o.offset=h,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e=0,n={};if("number"==typeof t)u=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");n=t.args||{},u=t.distance,e=t.angle||0}var i,r=0<u&&u<=1,o=0,s={x:0,y:0},t=(t.offset&&("number"==typeof(t=t.offset)&&(o=t),t.x&&(s.x=t.x),t.y)&&(s.y=t.y),0!==s.x||0!==s.y||0===o),a=n.keepGradient,n=n.ensureLegibility,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},r=r?u*this.getConnectionLength():u,u=l.tangentAtLength(r,h),r=e;return u?(t?(i=u.start.clone()).offset(s):((h=u.clone()).rotate(u.start,-90),h.setLength(o),i=h.end),a&&(r=u.angle()+e,n)&&(r=Xn((r+90)%180-90))):(i=l.start.clone(),t&&i.offset(s)),R.createSVGMatrix().translate(i.x,i.y).rotate(r)},getLabelCoordinates:function(t){t=this._getLabelTransformationMatrix(t);return new A(t.e,t.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new A(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){g.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove(t,e,n){g.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),g.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){g.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){g.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){g.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&&T(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){g.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){g.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){g.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){g.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){g.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,i=parseInt(i.getAttribute("label-idx"),10),r=this._getDefaultLabelPositionProperty(),o=this._normalizeLabelPosition(this._getLabelPositionProperty(i)),o=this._mergeLabelPositionProperty(o,r),r=this.getLabelCoordinates(o),o=r.x-e,e=r.y-n,r=this._getLabelPositionAngle(i),n=this._getLabelPositionArgs(i),s=this._getDefaultLabelPositionArgs(),n=this._mergeLabelPositionArgs(n,s);this.eventData(t,{action:"label-move",labelIdx:i,dx:o,dy:e,positionAngle:r,positionArgs:n,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){var i;this.can("arrowheadMove")&&(i=t.target.getAttribute("end"),i=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0}),this.eventData(t,i))},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),e={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)},n=(this.paper.options.snapLabels&&delete e.position.offset,{ui:!0});this.paper.isAsync()&&"touchmove"===t.type&&(n.async=!1),this.model.label(i.labelIdx,e,n)},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,i=t.arrowhead,r=t.initialEnd,o=this.model.prop(i);o&&!Nh.endsEqual(r,o)&&(n=this.paper,r.id&&this.notify("link:disconnect",e,n.findViewByModel(r.id),t.initialMagnet,i),o.id)&&this.notify("link:connect",e,n.findViewByModel(o.id),t.magnetUnderPointer,i)},_snapToPoints:function(e,n,t){let i=null,r=1/0,o=null,s=1/0,a=e.x,l=e.y;for(let t=0;t<n.length;t++){var h=Math.abs(n[t].x-e.x),h=(h<r&&(r=h,i=n[t]),Math.abs(n[t].y-e.y));h<s&&(s=h,o=n[t])}return r<t&&(a=i.x),s<t&&(l=o.y),{x:a,y:l}},_snapArrowheadSelf:function(t,e,n){var{paper:i,model:r}=this,o=i.options.snapLinksSelf,s=this.eventData(t),o=o.radius||20,s=[this.getEndAnchor("source"===s.arrowhead?"target":"source"),...r.vertices()],r=this._snapToPoints({x:e,y:n},s,o),e=i.localToClientPoint(r);this._connectArrowhead(document.elementFromPoint(e.x,e.y),r.x,r.y,this.eventData(t))},_snapArrowhead:function(t,e,n){let i=this.paper;var{snapLinks:r,connectionStrategy:o}=i.options;let s=this.eventData(t),a=!1,l=r.radius||50,h=i.findElementViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l},r.findInAreaOptions),u=s.closestView||null;var c=s.closestMagnet||null,r=s.magnetProxy||null,d=(s.closestView=s.closestMagnet=s.magnetProxy=null,Number.MAX_VALUE),f=new A(e,n),p=(h.forEach(function(n){let e=[];"false"!==n.el.getAttribute("magnet")&&e.push({bbox:n.model.getBBox(),magnet:n.el}),n.$("[magnet]").toArray().forEach(t=>{e.push({bbox:n.getNodeBBox(t),magnet:t})}),e.forEach(t=>{var{magnet:t,bbox:e}=t,e=e.center().squaredDistance(f);e<d&&(c===t||i.options.validateConnection.apply(i,s.validateConnectionArgs(n,n.el===t?null:t)))&&(d=e,s.closestView=n,s.closestMagnet=t)})},this),null),g=s.closestView,m=s.closestMagnet,v=(m&&(p=s.magnetProxy=g.findProxyNode(m,"highlighter")),s.arrowhead),y=c!==m;if(u&&y&&u.unhighlight(r,{connecting:!0,snapping:!0}),g){var{prevEnd:r,prevX:b,prevY:x}=s;if(s.prevX=e,s.prevY=n,a=!0,!y&&("function"!=typeof o||b===e&&x===n))return a;if(b=g.getLinkEnd(m,e,n,this.model,v),!y&&na(r,b))return a;s.prevEnd=b,y&&g.highlight(p,{connecting:!0,snapping:!0})}else b={x:e,y:n};return this.model.set(v,b||{x:e,y:n},{ui:!0}),u&&this.notify("link:snap:disconnect",t,u,c,v),g&&this.notify("link:snap:connect",t,g,m,v),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){var r,o,s,{paper:a,model:l}=this;i.eventTarget!==t&&(i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0}),(r=i.viewUnderPointer=a.findView(t))&&(o=i.magnetUnderPointer=r.findMagnet(t),s=i.magnetProxy=r.findProxyNode(o,"highlighter"),o)&&this.paper.options.validateConnection.apply(a,i.validateConnectionArgs(r,o))?s&&r.highlight(s,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)),i.eventTarget=t,l.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=1<arguments.length?arguments[1]:void 0,n=2<arguments.length?arguments[2]:void 0,i=this.model,{viewUnderPointer:t,magnetUnderPointer:r,magnetProxy:o,arrowhead:s}=t;r&&o&&t&&(t.unhighlight(o,{connecting:!0}),o=t.getLinkEnd(r,e,n,i,s),i.set(s,o,{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=[],i=(n[4]=t,0),r=0,t="source"===t?(i=2,"target"):(r=2,"source"),t=(n[5]=this).model.get(t);return t.id&&((t=(e=n[i]=this.paper.findViewByModel(t.id)).getMagnetFromLinkEnd(t))===e.el&&(t=void 0),n[i+1]=t),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]")),l=("false"!==s.el.getAttribute("magnet")&&a.push(s.el),a.filter(e.bind(t,s)));if(0<l.length){for(var h=0,u=l.length;h<u;h++)s.highlight(l[h],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e=Object.keys(t.marked),n=0,i=e.length;n<i;n++){var r=e[n],o=t.marked[r],s=this.paper.findViewByModel(r);if(s){for(var a=0,l=o.length;a<l;a++)s.unhighlight(o[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){t={action:"arrowhead-move",arrowhead:t,whenNotAllowed:(e=e||{}).whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:f(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(t),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=t),t},onMount:function(){g.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){g.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){g.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:M}),Zc=(Object.defineProperty(Xc.prototype,"sourceBBox",{enumerable:!0,get:function(){var t,e=this.sourceView;return e?(t=this.sourceMagnet,e.isNodeConnection(t)?new tt(this.sourceAnchor):e.getNodeBBox(t||e.el)):(t=this.model.source(),new tt(t.x,t.y))}}),Object.defineProperty(Xc.prototype,"targetBBox",{enumerable:!0,get:function(){var t,e=this.targetView;return e?(t=this.targetMagnet,e.isNodeConnection(t)?new tt(this.targetAnchor):e.getNodeBBox(t||e.el)):(t=this.model.target(),new tt(t.x,t.y))}}),jc.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init(){jc.prototype.init.apply(this,arguments);var{paper:t}=this.options;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings(t){let e=[];return t&&(Array.isArray(t)?t:[t||{}]).forEach(t=>{e.push(...this._resolveDrawGridOption(t))}),e},removeGrid(){var t=this._gridCache;t&&(t.root.remove(),this._gridCache=null)},renderGrid(){let{paper:s}=this.options;var t=this._gridSettings;if(this.removeGrid(),0!==t.length){let o=s.options.drawGridSize||s.options.gridSize;if(!(o<=1)){let r=this._getGridRefs();t.forEach((t,e)=>{var e=this._getPatternId(e),t=k({},t),{scaleFactor:n=1}=t;t.width=o*n||1,t.height=o*n||1;let i;r.exist(e)?i=r.get(e):(i=R("pattern",{id:e,patternUnits:"userSpaceOnUse"},R(t.markup)),r.add(e,i)),b(t.render)&&t.render(i.node.firstChild,t,s),i.attr({width:t.width,height:t.height})}),r.root.appendTo(this.el),this.updateGrid()}}},updateGrid(){let{_gridCache:e,_gridSettings:i,options:{paper:r}}=this;if(e){let{root:t,patterns:n}=e;var o,{x:s,y:a,width:l,height:h}=r.getArea();for(o in t.attr({x:s,y:a,width:l,height:h}),n)n[o].attr({x:-s,y:-a});i.forEach((t,e)=>{b(t.update)&&(e=n[this._getPatternId(e)],t.update(e.node.firstChild,t,r))})}},_getPatternId(t){return`pattern_${this.options.paper.cid}_`+t},_getGridRefs(){var t=this._gridCache;if(!t){let i=R("defs"),r=R("svg",{width:"100%",height:"100%"},[i]);t=this._gridCache={root:r,patterns:{},add:function(t,e){var n=R("rect",{width:"100%",height:"100%",fill:`url(#${t})`});i.append(e),r.append(n),this.patterns[t]=e},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}}}return t},_resolveDrawGridOption(t){var e=this.options.patterns;if(E(t)&&Array.isArray(e[t]))return e[t].map(function(t){return T({},t)});var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if((r=i||r||n.markup?r:"dot")&&Array.isArray(e[r])){var o=e[r].map(function(t){return T({},t)}),s=Array.isArray(n.args)?n.args:[n.args||{}];Ws(s[0],ua(t,"args"));for(var a=0;a<s.length;a++)o[a]&&T(o[a],s[a]);return o}return i?n:[n]}})),Jc={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"};let Kc=9007199254740991;s=g.Highlighting;let Qc={[s.DEFAULT]:{name:"stroke",options:{padding:3}},[s.MAGNET_AVAILABILITY]:{name:"addClass",options:{className:"available-magnet"}},[s.ELEMENT_AVAILABILITY]:{name:"addClass",options:{className:"available-cell"}}},td=[{name:zc.GRID},{name:zc.BACK},{name:zc.CELLS},{name:zc.LABELS},{name:zc.FRONT},{name:zc.TOOLS}];u=uu.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:Yc,linkView:Xc,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:Qc,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){var t=this.model.get("cells").cellNamespace,t=Ya(t,["standard","Link"]);if(t)return new t;throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.")},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 Yc},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:Jc.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:n,anchorNamespace:i,linkAnchorNamespace:Ic,connectionPointNamespace:$e,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,DEFAULT_FIND_BUFFER:200,init:function(){var t=this.options,t=(t.cellViewNamespace||(t.cellViewNamespace="undefined"!=typeof joint&&da(joint,"shapes")?joint.shapes:null),this.model=t.model||new Dc);this._layers={},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(t.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates&&this._updates.id&&al(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()||!qs(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){t=this.findViewByModel(t);t&&this.requestViewUpdate(t,t.FLAG_REMOVE,t.UPDATE_PRIORITY,n)},onCellChange:function(t,e){t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===Jc.APPROX&&(t=this.findViewByModel(t))&&this.requestViewUpdate(t,t.FLAG_INSERT,t.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){var e,n,i;this.isFrozen()||(e=t&&t.batchName,n=this.model,this.isAsync()||(i=this.UPDATE_DELAYING_BATCHES).includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t),(i=this.SORT_DELAYING_BATCHES).includes(e)&&!n.hasActiveBatch(i)&&this.sortViews())},cloneOptions:function(){var t=this.options,{defaultConnector:e,defaultRouter:n,defaultConnectionPoint:i,defaultAnchor:r,defaultLinkAnchor:o,highlighting:s,cellViewNamespace:a,interactive:l}=t;!a&&"undefined"!=typeof joint&&da(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),b(e)||(t.defaultConnector=ta(e)),b(n)||(t.defaultRouter=ta(n)),b(i)||(t.defaultConnectionPoint=ta(i)),b(r)||(t.defaultAnchor=ta(r)),b(o)||(t.defaultLinkAnchor=ta(o)),y(l)&&(t.interactive=T({},l)),y(s)&&(t.highlighting=Js({},s,Qc))},children:function(){var t=R.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:ja("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:ja("layers"),selector:"layers"}]}]},hasLayerView(t){return t in this._layers},getLayerView(t){var e=this._layers;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();var{el:t,childNodes:e,options:n,stylesheet:i}=this,{svg:e,defs:r,layers:o}=e;return t.style.position="relative",e.style.overflow=n.overflow?"visible":"hidden",this.svg=e,this.defs=r,this.layers=o,this.renderLayers(),R.ensureId(e),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&R(this.svg).prepend(R.createSVGStyle(t))},createLayer(t){return t!==zc.GRID?new jc({name:t}):new Zc({name:t,paper:this,patterns:this.constructor.gridPatterns})},renderLayers:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:td,t=(this.removeLayers(),t.forEach(t=>{var t=t.name,e=this.createLayer(t);this.layers.appendChild(e.el),this._layers[t]=e}),this.getLayerView(zc.CELLS)),e=this.getLayerView(zc.TOOLS),n=this.getLayerView(zc.LABELS);this.tools=e.el,this.cells=this.viewport=t.el,t.vel.addClass(ja("viewport")),n.vel.addClass(ja("viewport")),t.el.style.webkitUserSelect="none",t.el.style.userSelect="none",n.el.style.webkitUserSelect="none",n.el.style.userSelect="none"},removeLayers:function(){let e=this._layers;Object.keys(e).forEach(t=>{e[t].remove(),delete e[t]})},resetLayers:function(){let e=this._layers;Object.keys(e).forEach(t=>{e[t].removePivots()})},update:function(){return this._background&&this.updateBackgroundImage(this._background),this},scale:function(t,e,n){var i=this.matrix();return void 0===t?R.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){var{a:i,d:r,e:o,f:s}=this.matrix();return(t=Math.max(t||0,this.MIN_SCALE))===i&&t===r||(o=R.createSVGMatrix().translate(o-e.x*(t-i),s-e.y*(t-r)).scale(t,t),this.matrix(o,n)),this},translate:function(t,e,n){var i=this.matrix();return void 0===t?R.matrixToTranslate(i):(e=e||0,i.e===(t=t||0)&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t){var e,n,i,r,o,s,a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},l=this.layers;return void 0===t?(e=l.getAttribute("transform"),(this._viewportTransformString||null)===e?t=this._viewportMatrix:(t=l.getCTM(),this._viewportMatrix=t,this._viewportTransformString=e),R.createSVGMatrix(t)):(e=this.matrix(),t=R.createSVGMatrix(t),i=this._viewportTransformString,(n=R.matrixToTransformString(t))===i||!i&&R.matrixToTransformString()===n||({a:i,d:r,e:o,f:s}=t,l.setAttribute("transform",n),this._viewportMatrix=t,this._viewportTransformString=l.getAttribute("transform"),i===e.a&&r===e.d||this.trigger("scale",i,r,a),o===e.e&&s===e.f||this.trigger("translate",o,s,a),this.trigger("transform",t,a)),this)},clientMatrix:function(){return R.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof g)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,s=r.length;o<s;o++){var a,l=r[o],h=this.findViewByModel(l);h&&(a=["UPDATE"],l.getTargetCell()===i&&a.push("TARGET"),l.getSourceCell()===i&&a.push("SOURCE"),l=Math.max(e+1,h.UPDATE_PRIORITY),this.scheduleViewUpdate(h,h.getFlag(a),l,n))}},forcePostponedViewUpdate:function(t,e){if(t&&t instanceof g){var n=t.model;if(!n.isElement()&&0==(e&t.getFlag(["SOURCE","TARGET"]))){var e={silent:!0},i=0,r=this.findViewByModel(n.getSourceCell()),r=(r&&!this.isViewMounted(r)&&(i=this.dumpView(r,e),t.updateEndMagnet("source")),0),n=this.findViewByModel(n.getTargetCell());if(n&&!this.isViewMounted(n)&&(r=this.dumpView(n,e),t.updateEndMagnet("target")),0===i&&0===r)return!this.dumpView(t,e)}}return!1},requestViewUpdate:function(t,e,n,i){this.scheduleViewUpdate(t,e,n,i=i||{});t=this.isAsync();this.isFrozen()||t&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES)||(e=this.updateViews(i),t&&this.notifyAfterRender(e,i))},scheduleViewUpdate:function(t,e,n,i){var{_updates:r,options:o}=this,{FLAG_REMOVE:s,FLAG_INSERT:a,UPDATE_PRIORITY:l,cid:h}=(r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze()),t);let u=r.priorities[n];if(u=u||(r.priorities[n]={}),l<n)for(let t=n-1;t>=l;t--){var c=r.priorities[t];c&&h in c&&(u[h]|=c[h],delete c[h])}var d=u[h]||0;(d&e)!==e&&(d||r.count++,e&s&&d&a?u[h]^=a:e&a&&d&s&&(u[h]^=s),u[h]|=e,"function"==typeof(a=o.onViewUpdate))&&a.call(this,t,e,n,i||{},this)},dumpViewUpdate:function(t){var e,n;return t?(n=this._updates,e=t.cid,n=n.priorities[t.UPDATE_PRIORITY],t=this.registerMountedView(t)|n[e],delete n[e],t):0},dumpView:function(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=this.dumpViewUpdate(t);return i?((e=!n.silent)&&this.notifyBeforeRender(n),i=this.updateView(t,i,n),e&&(e={updated:1,priority:t.UPDATE_PRIORITY},this.notifyAfterRender(e,n)),i):0},updateView:function(t,e,n){if(!t)return 0;var{FLAG_REMOVE:i,FLAG_INSERT:r,FLAG_INIT:o,model:s}=t;if(t instanceof g){if(e&i)return this.removeView(s),0;e&r&&((i=!!(e&o))&&(e^=o),this.insertView(t,i),e^=r)}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){t=this.findViewByModel(t);return t?(this.dumpView(t,e),t):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;return e in n.unmounted?0:(t=n.unmounted[e]|=t.FLAG_INSERT,n.unmountedCids.push(e),delete n.mounted[e],t)},registerMountedView:function(t){var t=t.cid,e=this._updates;if(t in e.mounted)return 0;e.mounted[t]=!0,e.mountedCids.push(t);var n=e.unmounted[t]||0;return delete e.unmounted[t],n},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){t=Ws({},t,{viewport:null});this.checkViewport(t),this.updateViews(t)},updateViews:function(t){var e;this.notifyBeforeRender(t);let n=0,i=0,r=Kc;for(;i++,e=this.updateViewsBatch(t),n+=e.updated,r=Math.min(e.priority,r),!e.empty;);var o={updated:n,batches:i,priority:r};return this.notifyAfterRender(o,t),o},hasScheduledUpdates:function(){var t=this._updates.priorities,e=Object.keys(t);let n=e.length;for(;0<n&&n--;)for(var i in t[e[n]])return!0;return!1},updateViewsAsync:function(e,n){e=e||{},n=n||{processed:0,priority:Kc};var{_updates:i,options:r}=this,o=i.id;if(o){al(o),0===n.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(e);var s=this.updateViewsBatch(e),a=Ws({},e,{mountBatchSize:1e3-s.mounted,unmountBatchSize:1e3-s.unmounted}),a=this.checkViewport(a),l=a.unmounted,a=a.mounted;let t=n.processed;var h=i.count,l=(0<s.updated?(t+=s.updated+s.unmounted,s.processed=t,n.priority=Math.min(s.priority,n.priority),s.empty&&0===a?(s.unmounted+=l,s.mounted+=a,s.priority=n.priority,this.notifyAfterRender(s,e),n.processed=0,n.priority=Kc,i.count=0):n.processed=t):i.idle||r.autoFreeze&&(this.freeze(),i.idle=!0,this.trigger("render:idle",e)),e.progress);if(h&&"function"==typeof l&&l.call(this,s.empty,t,h,s,this),i.id!==o)return}if(i.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");i.id=sl(this.updateViewsAsync,this,e,n)},notifyBeforeRender:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};let e=t.beforeRender;"function"!=typeof e&&"function"!=typeof(e=this.options.beforeRender)||e.call(this,t,this)},notifyAfterRender:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};let n=e.afterRender;"function"==typeof(n="function"!=typeof n?this.options.afterRender:n)&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){var e=(t=t||{}).batchSize||1/0,n=this._updates,i=0,r=0,o=0,s=0,a=Kc,l=!0,h=this.options,u=n.priorities,c=("viewport"in t?t:h).viewport,d=("function"!=typeof c&&(c=null),h.onViewPostponed),f=("function"!=typeof d&&(d=null),Object.keys(u));t:for(var p=0,g=f.length;p<g;p++){var m,v=+f[p],y=u[v];for(m in y){if(e<=i){l=!1;break t}var b=hu[m];if(b){var x=y[m];if(0==(x&b.FLAG_REMOVE)){var w=m in n.unmounted;if(b.DETACHABLE&&c&&!c.call(this,b,!w,this)){w||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[m]|=x,delete y[m],o++;continue}w&&(x|=b.FLAG_INSERT,s++),x|=this.registerMountedView(b)}w=this.updateView(b,x,t);0<w&&(y[m]=w,!d||!d.call(this,b,w,this)||y[m])?(r++,l=!1):(v<a&&(a=v),i++,delete y[m])}else delete y[m]}}return{priority:a,updated:i,postponed:r,unmounted:o,mounted:s,empty:l}},getUnmountedViews:function(){for(var t=this._updates,e=Object.keys(t.unmounted),n=e.length,i=new Array(n),r=0;r<n;r++)i[r]=hu[e[r]];return i},getMountedViews:function(){for(var t=this._updates,e=Object.keys(t.mounted),n=e.length,i=new Array(n),r=0;r<n;r++)i[r]=hu[e[r]];return i},checkUnmountedViews:function(t,e){for(var n=0,e=("function"!=typeof t&&(t=null),"mountBatchSize"in(e=e||{})?e.mountBatchSize:1/0),i=this._updates,r=i.unmountedCids,o=i.unmounted,s=0,a=Math.min(r.length,e);s<a;s++){var l,h=r[s];h in o&&(l=hu[h])&&(l.DETACHABLE&&t&&!t.call(this,l,!1,this)?r.push(h):(n++,(h=this.registerMountedView(l))&&this.scheduleViewUpdate(l,h,l.UPDATE_PRIORITY,{mounting:!0})))}return r.splice(0,s),n},checkMountedViews:function(t,e){e=e||{};var n=0;if("function"==typeof t){for(var e=("unmountBatchSize"in e?e.unmountBatchSize:1/0),i=this._updates,r=i.mountedCids,o=i.mounted,s=0,a=Math.min(r.length,e);s<a;s++){var l,h=r[s];h in o&&(l=hu[h])&&(!l.DETACHABLE||t.call(this,l,!0,this)?r.push(h):(n++,this.registerUnmountedView(l)&&this.detachView(l)))}r.splice(0,s)}return n},checkViewVisibility:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};let t=("viewport"in n?n:this.options).viewport;"function"!=typeof t&&(t=null);var i,n=this._updates,{mounted:r,unmounted:o}=n,s=!e.DETACHABLE||!t||t.call(this,e,!1,this);let a=!1,l=!1;if(e.cid in r&&!s){let t=this.registerUnmountedView(e);t&&this.detachView(e);var r=n.mountedCids.indexOf(e.cid);n.mountedCids.splice(r,1),a=!0}return!a&&e.cid in o&&s&&(r=n.unmountedCids.indexOf(e.cid),n.unmountedCids.splice(r,1),(i=this.registerMountedView(e))&&this.scheduleViewUpdate(e,i,e.UPDATE_PRIORITY,{mounting:!0}),l=!0),{mounted:l?1:0,unmounted:a?1:0}},checkViewport:function(t){var e,t=Ws({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n=("viewport"in t?t:this.options).viewport,i=this.checkMountedViews(n,t);return 0<i&&(e=this._updates.unmountedCids,t.mountBatchSize=Math.min(e.length-i,t.mountBatchSize)),{mounted:this.checkUnmountedViews(n,t),unmounted:i}},freeze:function(t){var e=this._updates,t=(t=t||{}).key,n=this.options.frozen,i=e.freezeKey;if(t&&t!==i){if(n&&i)return;e.freezeKey=t,e.keyFrozen=n}this.options.frozen=!0;i=e.id;e.id=null,this.isAsync()&&i&&al(i)},unfreeze:function(t){var e=this._updates,n=(t=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===Jc.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,t=t.height;return{width:e=qs(e)?e:this.el.clientWidth,height:t=qs(t)?t:this.el.clientHeight}},setDimensions:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=this.options,{width:r,height:o}=i,t=void 0===t?r:t,e=void 0===e?o:e;r===t&&o===e||(i.width=t,i.height=e,this._setDimensions(),r=this.getComputedSize(),this.trigger("resize",r.width,r.height,n))},_setDimensions:function(){var t=this.options;let e=t.width,n=t.height;qs(e)&&(e=Math.round(e)+"px"),qs(n)&&(n=Math.round(n)+"px"),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=w(t)?t:T({gridWidth:t,gridHeight:e,padding:n},i);var{x:t,y:e,width:n,height:r}=this.getFitToContentArea(i),{sx:o,sy:s}=this.scale();return this.translate(-t*o,-e*s,i),this.setDimensions(n*o,r*s,i),new tt(t,e,n,r)},getFitToContentArea:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=t.gridWidth||1,n=t.gridHeight||1,i=gl(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,h="contentArea"in t?new tt(t.contentArea):this.getContentArea(t),{sx:u,sy:c}=this.scale();h.x*=u,h.y*=c,h.width*=u,h.height*=c;let d=Math.ceil((h.width+h.x)/e),f=Math.ceil((h.height+h.y)/n),p=(t.allowNegativeBottomRight||(d=Math.max(d,1),f=Math.max(f,1)),d*=e,f*=n,0),g=(("negative"===l&&h.x<0||"positive"===l&&0<=h.x||"any"===l)&&(p=Math.ceil(-h.x/e)*e,p+=i.left,d+=p),0);return("negative"===l&&h.y<0||"positive"===l&&0<=h.y||"any"===l)&&(g=Math.ceil(-h.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 tt(-p/u,-g/c,d/u,f/c)},transformToFitContent:function(o){o=o||{};let s,a;if(a="contentArea"in o?(l=o.contentArea,s=this.localToPaperRect(l),new A(l)):(s=this.getContentBBox(o),this.paperToLocalPoint(s)),s.width&&s.height){Ws(o,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});var l=gl(o.padding),h=o.minScaleX||o.minScale,u=o.maxScaleX||o.maxScale,c=o.minScaleY||o.minScale,d=o.maxScaleY||o.maxScale;let t;t=o.fittingBBox||(p=this.translate(),g=this.getComputedSize(),{x:p.tx,y:p.ty,width:g.width,height:g.height}),t=new tt(t).moveAndExpand({x:l.left,y:l.top,width:-l.left-l.right,height:-l.top-l.bottom});var f,p=this.matrix(),{a:g,d:l,e:m,f:v}=p;let e=t.width/s.width*g,n=t.height/s.height*l;o.preserveAspectRatio&&(e=n=Math.min(e,n)),o.scaleGrid&&(f=o.scaleGrid,e=f*Math.floor(e/f),n=f*Math.floor(n/f)),e=Math.min(u,Math.max(h,e)),n=Math.min(d,Math.max(c,n));const y=e/g,b=n/l;let i=t.x-a.x*e-m,r=t.y-a.y*n-v;switch(o.verticalAlign){case"middle":r+=(t.height-s.height*b)/2;break;case"bottom":r+=t.height-s.height*b}switch(o.horizontalAlign){case"middle":i+=(t.width-s.width*y)/2;break;case"right":i+=t.width-s.width*y}p.a=e,p.d=n,p.e=i,p.f=r,this.matrix(p,o)}},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new tt:R(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(){var t=this.options.restrictTranslate;let e;if(b(t)){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];e=t.apply(this,i)}else e=!0===t?this.getArea():t?new tt(t):null;return e},createViewForModel:function(t){var e,n=this.options,i=n.cellViewNamespace,r=t.get("type")+"View",i=Ya(i,r,"."),r=t.isLink()?(e=n.linkView,Xc):(e=n.elementView,Yc);return new(e.prototype instanceof ou?i||e:e.call(this,t)||i||r)({model:t,interactive:n.interactive,labelsLayer:!0===n.labelsLayer?zc.LABELS:n.labelsLayer})},removeView:function(t){var e,n,t=t.id,{_views:i,_updates:r}=this,o=i[t];return o&&(e=o.cid,{mounted:r,unmounted:n}=r,o.remove(),delete i[t],delete r[e],delete n[e]),o},renderView:function(t,e){var n=t.id,i=this._views;let r,o,s=!0;return n in i&&((r=i[n]).model===t?(o=r.FLAG_INSERT,s=!1):this.removeView(t)),s&&((r=i[n]=this.createViewForModel(t)).paper=this,o=this.registerUnmountedView(r)|this.FLAG_INIT|r.getFlag(S(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();var 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(){Xs(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")),n=this.model.get("cells");pl(t,function(t,e){t=n.get(t.getAttribute("model-id")),e=n.get(e.getAttribute("model-id")),t=t.attributes.z||0,e=e.attributes.z||0;return t===e?0:t<e?-1:1})},insertView:function(t,e){var n=this.getLayerView(zc.CELLS),{el:i,model:r}=t;this.options.sorting===Jc.APPROX?n.insertSortedNode(i,r.get("z")):(Jc,n.insertNode(i)),t.onMount(e)},detachView(t){t.unmount(),t.onDetach()},findView:function(t){t=E(t)?this.cells.querySelector(t):t instanceof L?t[0]:t,t=this.findAttribute("model-id",t);if(t)return this._views[t]},findViewByModel:function(t){t=E(t)||qs(t)?t:t&&t.id;return this._views[t]},findViewsFromPoint:function(e){return e=new A(e),this.model.getElements().map(this.findViewByModel,this).filter(function(t){return t&&t.vel.getBBox({target:this.cells}).containsPoint(e)},this)},findViewsInArea:function(e,t){t=Ws(t||{},{strict:!1}),e=new tt(e);var n=this.model.getElements().map(this.findViewByModel,this),i=t.strict?"containsRect":"intersect";return n.filter(function(t){return t&&e[i](t.vel.getBBox({target:this.cells}))},this)},findElementViewsInArea(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findElementsInArea(t,e),e)},findLinkViewsInArea:function(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findLinksInArea(t,e),e)},findCellViewsInArea:function(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findCellsInArea(t,e),e)},findElementViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findElementsInArea(t),e)},findLinkViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findLinksInArea(t),e)},findCellViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findCellsInArea(t),e)},_findInExtendedArea:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},{buffer:i=this.DEFAULT_FIND_BUFFER}=n;return e(new tt(t).inflate(i),n).map(t=>this.findViewByModel(t))},_filterViewsInArea:function(t,e){let n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=new tt(t);return this._findInExtendedArea(i,e,n).filter(t=>!!t&&t.isInArea(i,n))},_filterViewsAtPoint:function(e,t){let n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};var i=new tt(e);return this._findInExtendedArea(i,t,n).filter(t=>!!t&&t.isAtPoint(e,n))},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t){if("string"==typeof t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.trigger("tools:event",t,...n)}},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){t=new A(t,e);return R.transformPoint(t,this.matrix())},localToPaperRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.matrix())},paperToLocalPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.matrix().inverse())},localToClientPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.clientMatrix())},localToClientRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.clientMatrix())},clientToLocalPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,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){t=new A(t,e).difference(this.pageOffset());return this.paperToLocalPoint(t)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),t=new tt(t,e,n,i);return t.x-=r.x,t.y-=r.y,this.paperToLocalRect(t)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new A(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){var e,n,i,r;if(t instanceof Xc)return e=t.model,n=this.options,r=(i=this.model).constructor.validations,!(!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));throw new Error("Must provide a linkView.")},getDefaultLink:function(t,e){return b(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(){let{highlighter:t,type:e}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};var{highlighting:n,highlighterNamespace:i}=this.options;if(void 0===t){if(!n)return!1;if(e&&!1===(t=n[e]))return!1;t=t||n.default}if(!t)return!1;n=(t=E(t)?{name:t}:t).name,i=i[n];if(!i)throw new Error('Unknown highlighter ("'+n+'")');if("function"!=typeof i.highlight)throw new Error('Highlighter ("'+n+'") is missing required highlight() method');if("function"!=typeof i.unhighlight)throw new Error('Highlighter ("'+n+'") is missing required unhighlight() method');return{highlighter:i,options:t.options||{},name:n}},onCellHighlight:function(t,e,n){var i,n=this.resolveHighlighter(n);n&&({highlighter:n,options:i}=n,n.highlight(t,e,i))},onCellUnhighlight:function(t,e,n){var i,n=this.resolveHighlighter(n);n&&({highlighter:n,options:i}=n,n.unhighlight(t,e,i))},pointerdblclick:function(t){t.preventDefault(),t=C(t);var e,n=this.findView(t.target);this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n?n.pointerdblclick(t,e.x,e.y):this.trigger("blank:pointerdblclick",t,e.x,e.y))},pointerclick:function(t){var e,n;this.eventData(t).mousemoved<=this.options.clickThreshold&&(t=C(t),e=this.findView(t.target),this.guard(t,e)||(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=C(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e,n=this.findView(t.target);this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n?n.contextmenu(t,e.x,e.y):this.trigger("blank:contextmenu",t,e.x,e.y))},pointerdown:function(t){var{target:e,button:n}=t=C(t),i=this.findView(e),n=2===n;if(i){if(!n&&this.guard(t,i))return;var r=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName),r=(this.options.preventDefaultViewAction&&!r&&t.preventDefault(),r&&i.preventDefaultInteraction(t),this.customEventTrigger(t,i));if(r){if(r.isPropagationStopped())return;t.data=r.data}r=e.closest("[magnet]");if(r&&i.el!==r&&i.el.contains(r)){var e=C(new L.Event(t.originalEvent,{data:t.data,currentTarget:r}));if(this.onmagnet(e),e.isDefaultPrevented()&&t.preventDefault(),e.isPropagationStopped())return n?void 0:void this.delegateDragEvents(i,e.data);t.data=e.data}}n?(this.contextMenuFired=!0,r=new L.Event(t.originalEvent,{type:"contextmenu",data:t.data}),this.contextMenuTrigger(r)):(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,n,i=this.eventData(t);i.mousemoved||(i.mousemoved=0,this.undelegateEvents()),++i.mousemoved<=this.options.moveThreshold||(t=C(t),e=this.snapToGrid(t.clientX,t.clientY),(n=i.sourceView)?n.pointermove(t,e.x,e.y):this.trigger("blank:pointermove",t,e.x,e.y),this.eventData(t,i))},pointerup:function(t){this.undelegateDocumentEvents();var e=C(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 L.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=C(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseover(t):this.el!==t.target&&this.trigger("blank:mouseover",t))},mouseout:function(t){t=C(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseout(t):this.el!==t.target&&this.trigger("blank:mouseout",t))},mouseenter:function(t){var{target:e,relatedTarget:n,currentTarget:i}=t=C(t),e=this.findView(e);if(!this.guard(t,e)){var r=this.findView(n);if(e){if(r===e)return;if(e.mouseenter(t),this.el.contains(n))return}r||i===this.el&&this.trigger("paper:mouseenter",t)}},mouseleave:function(t){var{target:e,relatedTarget:n,currentTarget:i}=t=C(t),e=this.findView(e);if(!this.guard(t,e)){var r=this.findView(n);if(e){if(r===e)return;if(e.mouseleave(t),this.el.contains(n))return}r||i===this.el&&this.trigger("paper:mouseleave",t)}},_processMouseWheelEvtBuf:ia(function(){var{event:t,deltas:e}=this._mw_evt_buffer,e=e.reduce((t,e)=>t+rl(e,50),0),e=Math.pow(.995,e),{x:n,y:i}=this.clientToLocalPoint(t.clientX,t.clientY);this.trigger("paper:pinch",t,n,i,e),this._mw_evt_buffer={event:null,deltas:[]}},20,{maxWait:20}),mousewheel:function(t){t=C(t);var e,n,i,r,o,s=this.findView(t.target);this.guard(t,s)||(e=t.originalEvent,n=this.snapToGrid(e.clientX,e.clientY),{deltaX:i,deltaY:r}=il(e),o=this._events["paper:pinch"],t.ctrlKey&&o&&0<o.length?(e.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(r),this._processMouseWheelEvtBuf()):(o=Math.max(-1,Math.min(1,e.wheelDelta)),s?s.mousewheel(t,n.x,n.y,o):this.trigger("blank:mousewheel",t,n.x,n.y,o),this.trigger("paper:pan",t,i,r)))},onevent:function(t){var e,n=t.currentTarget,i=n.getAttribute("event");i&&(n=this.findView(n))&&(t=C(t),this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n.onevent(t,i,e.x,e.y)))},magnetEvent:function(t,e){var n,i,r=t.currentTarget;r.getAttribute("magnet")&&(n=this.findView(r))&&(t=C(t),this.guard(t,n)||(i=this.snapToGrid(t.clientX,t.clientY),e.call(this,n,t,r,i.x,i.y)))},onmagnet:function(t){var e;2===t.button?(this.contextMenuFired=!0,this.magnetContextMenuFired=!0,e=new L.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget}),this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()):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&&(t=C(t),!this.guard(t,n))){e=this.customEventTrigger(t,n,e);if(e){if(e.isPropagationStopped())return;t.data=e.data}e=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,e.x,e.y)}},getPointerArgs(t){var t=C(t),{x:e,y:n}=this.snapToGrid(t.clientX,t.clientY);return[t,e,n]},delegateDragEvents:function(t,e){this.eventData({data:e=e||{}},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){return"mousedown"===t.type&&2===t.button||!(!this.options.guard||!this.options.guard(t,e))||(t.data&&void 0!==t.data.guarded?t.data.guarded:(t=t.target,!!this.GUARDED_TAG_NAMES.includes(t.tagName)||!(e&&e.model&&e.model instanceof gh||this.el===t||this.svg.contains(t))))},setGridSize:function(t){var e=this.options;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(zc.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(zc.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",t=t.size||"auto auto",n=this.scale(),i=this.translate(),i=(w(e)&&(e=i.tx+n.sx*(e.x||0)+"px "+(i.ty+n.sy*(e.y||0))+"px"),w(t)&&(t=(t=new tt(t).scale(n.sx,n.sy)).width+"px "+t.height+"px"),this.childNodes).background;i.style.backgroundSize=t,i.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[ga(r)];if(b(a)){t.width*=s,t.height*=s;a=a(t,e);if(!(a instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=a.toDataURL("image/png"),r="repeat",w(i)?(i.width*=a.width/t.width,i.height*=a.height/t.height):void 0===i&&(e.size={width:a.width/s,height:a.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){var e;return this.updateBackgroundColor((t=t||{}).color),t.image?(t=this._background=ta(t),tl(t),(e=document.createElement("img")).onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image):(this.drawBackgroundImage(null),this._background=null),this},setInteractivity:function(t){this.options.interactive=t,Xs(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!w(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name,e=e||n+this.svg.id+Wa(JSON.stringify(t));if(!this.isDefined(e)){var i=yl,i=i[n]&&i[n](t.args||{});if(!i)throw new Error("Non-existing filter "+n);n=T({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});R(i,n).appendTo(this.defs)}return e},defineGradient:function(t){var e,n,i,r;if(w(t))return{svg:n,defs:e}=this,{type:r,id:n=r+n.id+Wa(JSON.stringify(t)),stops:t,attrs:i={}}=t,this.isDefined(n)||(t=et(t).map(t=>{var{offset:t,color:e,opacity:n}=t;return R("stop").attr({offset:t,"stop-color":e,"stop-opacity":Number.isFinite(n)?n:1})}),(r=R(r,i,t)).id=n,r.appendTo(e)),n;throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.")},definePattern:function(t){if(!w(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");var e,{svg:n,defs:i}=this,{id:n=n.id+Wa(JSON.stringify(t)),markup:t,attrs:r={}}=t;if(t)return this.isDefined(n)||((e=R("pattern",{patternUnits:"userSpaceOnUse"})).id=n,e.attr(r),"string"==typeof t?e.append(R(t)):(r=$a(t).fragment,e.append(r)),e.appendTo(i)),n;throw new TypeError("dia.Paper: definePattern() requires markup.")},defineMarker:function(t){if(!w(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");var{svg:e,defs:n}=this,{id:e=e.id+Wa(JSON.stringify(t)),markup:o,attrs:s={},markerUnits:a="userSpaceOnUse"}=t;if(!this.isDefined(e)){a=R("marker",{orient:"auto",overflow:"visible",markerUnits:a});a.id=e,a.attr(s);let i;if(o){let t;t="string"==typeof o?(t=R(o),Array.isArray(t)?t:[t]):(s=$a(o).fragment,R(s).children()),i=1<t.length?R("g").append(t):t[0]}else{var{type:o="path"}=t;i=R(o)}let r=ua(t,"type","id","markup","attrs","markerUnits");Object.keys(r).forEach(t=>{var e=r[t],n=i.attr(t);null==n?i.attr(t,e):"transform"===t&&i.attr(t,e+" "+n)}),i.appendTo(a),a.appendTo(n)}return e},customEventTrigger:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:e.el,i=t.target.closest("[event]");return i&&n!==i&&e.el.contains(i)?(n=C(new L.Event(t.originalEvent,{data:t.data,currentTarget:i})),this.onevent(n),n.isDefaultPrevented()&&t.preventDefault(),n):null}},{sorting:Jc,Layers:zc,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height,r=(e.width=2*n,e.height=2*i,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,r=(e.width=2*n,e.height=i,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,r=(e.width=n,e.height=2*i,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||{};for(var n=t.width,i=t.height,r=document.createElement("canvas"),o=(r.width=3*n,r.height=3*i,r.getContext("2d")),e=qs(e.watermarkAngle)?-e.watermarkAngle:-20,s=Jn(e),a=r.width/4,l=r.height/4,h=0;h<4;h++)for(var u=0;u<4;u++)0<(h+u)%2&&(o.setTransform(1,0,0,1,(2*h-1)*a,(2*u-1)*l),o.rotate(s),o.drawImage(t,-n/2,-i/2,n,i));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){R(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){R(t).attr({fill:e.color})},update:function(t,e,n){var{sx:n,sy:i}=n.scale(),n=n<=1?e.thickness:e.thickness/n,e=i<=1?e.thickness:e.thickness/i;R(t).attr({width:n,height:e})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}]}});let ed=uu.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,_visibleExplicit:!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},updateVisibility:function(){var t=this.computeVisibility();this.el.style.display=t?"":"none",this._visible=t},computeVisibility(){var t;return!!this.isExplicitlyVisible()&&(t=this.options.visibility,"function"!=typeof t||!!t.call(this,this.relatedView,this))},show:function(){this._visibleExplicit=!0,this.updateVisibility()},hide:function(){this._visibleExplicit=!1,this.updateVisibility()},isExplicitlyVisible:function(){return!!this._visibleExplicit},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){var{paper:e,relatedView:n}=this;return!e||!n||e.guard(t,n)}});r=uu.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=T(this.options,t)).tools;if(Array.isArray(e)){var n=t.relatedView;if(n instanceof g){for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var s=e[r];s instanceof ed&&(s.configure(n,this),this.vel.append(s.el),i.push(s))}this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS"))}}return this},getName:function(){return this.options.name},update:function(e){e=e||{};var n=this.tools;if(n){var i=n.length,t=this.isRendered;for(let t=0;t<i;t++){var r=n[t];r.updateVisibility(),r.isVisible()&&(this.isRendered||(this.isRendered=Array(i).fill(!1)),this.isRendered[t]?e.tool!==r.cid&&r.update():(r.render(),this.isRendered[t]=!0))}!this.isRendered&&0<i||(this.isMounted()||this.mount(),t)||this.blurTool()}return this},focusTool:function(t){var e=this.tools;if(e)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)for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isExplicitlyVisible()||(r.show(),r.isVisible()&&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(){var{options:t,el:e}=this,{relatedView:t,layer:n=zc.TOOLS,z:i}=t;return t&&(n?t.paper.getLayerView(n).insertSortedNode(e,i):t.el.appendChild(e)),this}}),a={Graph:Dc,attributes:fh,LayersNames:zc,PaperLayer:jc,Cell:gh,CellView:g,Element:c,ElementView:Yc,Link:Nh,LinkView:Xc,Paper:u,ToolView:ed,ToolsView:r,HighlighterView:Pu},Je=uu.extend({tagName:"circle",svgElement:!0,className:"marker-vertex",events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onDoubleClick",dbltap:"onDoubleClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},attributes:{r:6,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move"},position:function(t,e){var{vel:n,options:i}=this,i=i.scale;let r=R.createSVGMatrix().translate(t,e);i&&(r=r.scale(i)),n.transform(r,{absolute:!0})},onPointerDown:function(t){this.options.guard(t)||(t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.trigger("will-change",this,t))},onPointerMove:function(t){this.trigger("changing",this,t)},onDoubleClick:function(t){this.trigger("remove",this,t)},onPointerUp:function(t){this.trigger("changed",this,t),this.undelegateDocumentEvents(),this.options.paper.delegateEvents()}}),e=ed.extend({name:"vertices",options:{handleClass:Je,snapRadius:20,redundancyRemoval:!0,vertexAdding:!0,stopPropagation:!0,scale:null},children:[{tagName:"path",selector:"connection",className:"joint-vertices-path",attributes:{fill:"none",stroke:"transparent","stroke-width":10,cursor:"cell"}}],handles:null,interactiveLinkNode:null,events:{"mousedown .joint-vertices-path":"onPathPointerDown","touchstart .joint-vertices-path":"onPathPointerDown"},linkEvents:{mousedown:"onLinkPointerDown",touchstart:"onLinkPointerDown"},onRender:function(){var t=this.options.vertexAdding;return t&&({interactiveLinkNode:t=null}=t,t?this.delegateLinkEvents(t):(this.renderChildren(),this.updatePath())),this.resetHandles(),this.renderHandles(),this},delegateLinkEvents:function(t){this.undelegateLinkEvents();var e=this.relatedView.findNode(t);e?(e.classList.add("joint-vertices-path"),this.interactiveLinkNode=e,this.delegateElementEvents(e,this.linkEvents)):console.warn(`Interactive link node "${t}" not found.`)},undelegateLinkEvents:function(){var t=this.interactiveLinkNode;t&&(this.undelegateElementEvents(t),t.classList.remove("joint-vertices-path"),this.interactiveLinkNode=null)},update:function(){return this.relatedView.model.vertices().length===this.handles.length?this.updateHandles():(this.resetHandles(),this.renderHandles()),this.options.vertexAdding&&this.updatePath(),this},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,n=t.length;e<n;e++)t[e].remove()},renderHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,n=t.length;e<n;e++){var i=t[e],r=new this.options.handleClass({index:e,paper:this.paper,scale:this.options.scale,guard:t=>this.guard(t)});r.render(),r.position(i.x,i.y),this.simulateRelatedView(r.el),r.vel.appendTo(this.el),this.handles.push(r),this.startHandleListening(r)}},updateHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,n=t.length;e<n;e++){var i=t[e],r=this.handles[e];if(!r)return;r.position(i.x,i.y)}},updatePath:function(){var t;this.interactiveLinkNode||(t=this.childNodes.connection)&&t.setAttribute("d",this.relatedView.getSerializedConnection())},startHandleListening:function(t){var{vertexRemoving:e=!0,vertexMoving:n=!0}=this.options;n&&(this.listenTo(t,"will-change",this.onHandleWillChange),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"changed",this.onHandleChanged)),e&&this.listenTo(t,"remove",this.onHandleRemove)},getNeighborPoints:function(t){var e=this.relatedView,n=e.model.vertices(),i=0<t?n[t-1]:e.sourceAnchor,n=t<n.length-1?n[t+1]:e.targetAnchor;return{prev:new A(i),next:new A(n)}},onHandleWillChange:function(t,e){this.focus();var{relatedView:n,options:i}=this;n.model.startBatch("vertex-move",{ui:!0,tool:this.cid}),i.stopPropagation||n.notifyPointerdown(...n.paper.getPointerArgs(e))},onHandleChanging:function(t,e){var{options:n,relatedView:i}=this,r=t.options.index,[e,o,s]=i.paper.getPointerArgs(e),a={x:o,y:s};this.snapVertex(a,r),i.model.vertex(r,a,{ui:!0,tool:this.cid}),t.position(a.x,a.y),n.stopPropagation||i.notifyPointermove(e,o,s)},onHandleChanged:function(t,e){var n,i,r,{options:o,relatedView:s}=this;o.vertexAdding&&this.updatePath(),o.redundancyRemoval?([n,i,r]=(s.removeRedundantLinearVertices({ui:!0,tool:this.cid})&&this.render(),this.blur(),s.model.stopBatch("vertex-move",{ui:!0,tool:this.cid}),this.eventData(e).vertexAdded&&s.model.stopBatch("vertex-add",{ui:!0,tool:this.cid}),s.paper.getPointerArgs(e)),o.stopPropagation||s.notifyPointerup(n,i,r),s.checkMouseleave(n)):s.checkMouseleave(C(e))},snapVertex:function(t,e){var n,i,r=this.options.snapRadius;0<r&&(n=(e=this.getNeighborPoints(e)).prev,i=e.next,Math.abs(t.x-n.x)<r?t.x=n.x:Math.abs(t.x-i.x)<r&&(t.x=i.x),Math.abs(t.y-n.y)<r?t.y=e.prev.y:Math.abs(t.y-i.y)<r&&(t.y=i.y))},onHandleRemove:function(t,e){var t=t.options.index,n=this.relatedView;n.model.removeVertex(t,{ui:!0}),this.options.vertexAdding&&this.updatePath(),n.checkMouseleave(C(e))},onPathPointerDown:function(t){var e,n,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),t=C(t),e=this.paper.snapToGrid(t.clientX,t.clientY).toJSON(),(i=this.relatedView).model.startBatch("vertex-add",{ui:!0,tool:this.cid}),n=i.getVertexIndex(e.x,e.y),this.snapVertex(e,n),i.model.insertVertex(n,e,{ui:!0,tool:this.cid}),this.update(),i=this.handles[n],this.eventData(t,{vertexAdded:!0}),i.onPointerDown(t))},onLinkPointerDown:function(t){this.relatedView.preventDefaultInteraction(t),this.onPathPointerDown(t)},onRemove:function(){this.resetHandles(),this.undelegateLinkEvents()}},{VertexHandle:Je});function nd(t,e){var n=t.model;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}function id(t,e,n){return Ru.call(this.paper,{},e,n,t,this.model).anchor}h=uu.extend({tagName:"g",svgElement:!0,className:"marker-segment",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},children:[{tagName:"line",selector:"line",attributes:{stroke:"#33334F","stroke-width":2,fill:"none","pointer-events":"none"}},{tagName:"rect",selector:"handle",attributes:{width:20,height:8,x:-10,y:-4,rx:4,ry:4,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2}}],onRender:function(){this.renderChildren()},position:function(t,e,n,i){var r=this.options.scale;let o=R.createSVGMatrix().translate(t,e).rotate(n);r&&(o=o.scale(r));r=this.childNodes.handle,r.setAttribute("transform",R.matrixToTransformString(o)),r.setAttribute("cursor",n%180==0?"row-resize":"col-resize"),r=i.getClosestPoint(new A(t,e)),n=this.childNodes.line;n.setAttribute("x1",t),n.setAttribute("y1",e),n.setAttribute("x2",r.x),n.setAttribute("y2",r.y)},onPointerDown:function(t){this.options.guard(t)||(this.trigger("change:start",this,t),t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data))},onPointerMove:function(t){this.trigger("changing",this,t)},onPointerUp:function(t){this.undelegateDocumentEvents(),this.options.paper.delegateEvents(),this.trigger("change:end",this,t)},show:function(){this.el.style.display=""},hide:function(){this.el.style.display="none"}}),Rh=ed.extend({name:"segments",precision:.5,options:{handleClass:h,segmentLengthThreshold:40,redundancyRemoval:!0,anchor:id,snapRadius:10,snapHandle:!0,stopPropagation:!0},handles:null,onRender:function(){this.resetHandles();var t=this.relatedView,e=t.model.vertices();e.unshift(t.sourcePoint),e.push(t.targetPoint);for(var n=0,i=e.length;n<i-1;n++){var r=e[n],o=e[n+1],r=this.renderHandle(r,o);this.simulateRelatedView(r.el),this.handles.push(r),r.options.index=n}return this},renderHandle:function(t,e){var n=new this.options.handleClass({paper:this.paper,scale:this.options.scale,guard:t=>this.guard(t)});return n.render(),this.updateHandle(n,t,e),n.vel.appendTo(this.el),this.startHandleListening(n),n},update:function(){return this.render(),this},startHandleListening:function(t){this.listenTo(t,"change:start",this.onHandleChangeStart),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"change:end",this.onHandleChangeEnd)},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,n=t.length;e<n;e++)t[e].remove()},shiftHandleIndexes:function(t){for(var e=this.handles,n=0,i=e.length;n<i;n++)e[n].options.index+=t},resetAnchor:function(t,e){var n=this.relatedView.model;e?n.prop([t,"anchor"],e,{rewrite:!0,ui:!0,tool:this.cid}):n.removeProp([t,"anchor"],{ui:!0,tool:this.cid})},snapHandle:function(t,e,n){var i=t.options.index,r=this.relatedView.model.vertices(),t=t.options.axis,o=r[i-2]||n.sourceAnchor,r=r[i+1]||n.targetAnchor,i=this.options.snapRadius;return Math.abs(e[t]-o[t])<i?e[t]=o[t]:Math.abs(e[t]-r[t])<i&&(e[t]=r[t]),e},onHandleChanging:function(t,e){var n=this.options,i=this.eventData(e),r=this.relatedView,o=r.paper,s=t.options.index-1,e=C(e),o=o.snapToGrid(e.clientX,e.clientY),a=this.snapHandle(t,o.clone(),i),l=t.options.axis,h=this.options.snapHandle?0:o[l]-a[l],u=r.model,c=ta(u.vertices()),d=this.options.anchor,f=("function"!=typeof d&&(d=null),t.options.index),p=[r.sourcePoint.clone(),...c,r.targetPoint.clone()];let g=0;0<=f-1&&(m=p[f-1],v=p[f],new P(m,v).vector().theta()%90!=0)&&(c.splice(f-1,0,i.originalVertices[f-1]),g++,this.shiftHandleIndexes(1));var m=c[s+g],v=c[1+s+g],y=(f+2<p.length&&(b=p[f+1],p=p[f+2],new P(b,p).vector().theta()%90!=0)&&(b=1===i.originalVertices.length,p=i.firstHandleShifted&&!b?1:0,y=1+g,c.splice(f+y,0,i.originalVertices[(b?0:f)-p])),r.sourceView),b=r.sourceBBox,f=!1,p=!1,b=(m?0==s?b.containsPoint(m)?(c.shift(),this.shiftHandleIndexes(-1),f=!0):(m[l]=a[l],p=!0):m[l]=a[l]:((m=r.sourceAnchor.toJSON())[l]=a[l],b.containsPoint(m)?(m[l]=a[l],f=!0):(c.unshift(m),this.shiftHandleIndexes(1),p=i.firstHandleShifted=!0)),d&&y&&(f&&((b=i.sourceAnchor.clone())[l]=a[l],f=d.call(r,b,y,r.sourceMagnet||y.el,"source",r),this.resetAnchor("source",f)),p)&&this.resetAnchor("source",i.sourceAnchorDef),r.targetView),y=r.targetBBox,f=!1,p=!1;if(v?s==c.length-2?y.containsPoint(v)?(c.pop(),f=!0):(v[l]=a[l],p=!0):v[l]=a[l]:((v=r.targetAnchor.toJSON())[l]=a[l],y.containsPoint(v)?f=!0:(c.push(v),p=!0)),d&&b&&(f&&((s=i.targetAnchor.clone())[l]=a[l],y=d.call(r,s,b,r.targetMagnet||b.el,"target",r),this.resetAnchor("target",y)),p)&&this.resetAnchor("target",i.targetAnchorDef),c.some(t=>!t))throw new Error("Segments: incompatible router in use");u.vertices(c,{ui:!0,tool:this.cid}),this.updateHandle(t,m,v,h),n.stopPropagation||r.notifyPointermove(e,o.x,o.y)},onHandleChangeStart:function(t,e){var{options:n,handles:i,relatedView:r}=this,{model:o,paper:s}=r,a=t.options.index;if(Array.isArray(i)){for(var l=0,h=i.length;l<h;l++)l!==a&&i[l].hide();this.focus(),this.eventData(e,{sourceAnchor:r.sourceAnchor.clone(),targetAnchor:r.targetAnchor.clone(),sourceAnchorDef:f(o.prop(["source","anchor"])),targetAnchorDef:f(o.prop(["target","anchor"])),originalVertices:ta(o.vertices()),firstHandleShifted:!1}),o.startBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||r.notifyPointerdown(...s.getPointerArgs(e))}},onHandleChangeEnd:function(t,e){var{options:n,relatedView:i}=this,{paper:r,model:o}=i,e=(n.redundancyRemoval&&i.removeRedundantLinearVertices({ui:!0,tool:this.cid}),C(e)),r=r.snapToGrid(e.clientX,e.clientY);this.render(),this.blur(),o.stopBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||i.notifyPointerup(e,r.x,r.y),i.checkMouseleave(e)},updateHandle:function(t,e,n,i){var r=Math.abs(e.x-n.x)<this.precision,o=Math.abs(e.y-n.y)<this.precision;!r&&!o||(o=new P(e,n)).length()<this.options.segmentLengthThreshold?t.hide():((e=o.midpoint())[n=r?"x":"y"]+=i||0,r=o.vector().vectorAngle(new A(1,0)),t.position(e.x,e.y,r,this.relatedView),t.show(),t.options.axis=n)},onRemove:function(){this.resetHandles()}},{SegmentHandle:h}),l=ed.extend({tagName:"path",xAxisVector:new A(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=this.ratio,n=this.relatedView,i=n.getTangentAtRatio(e),i=i?(t=i.start,i.vector().vectorAngle(this.xAxisVector)||0):(t=n.getPointAtRatio(e),0);return t&&(n=R.createSVGMatrix().translate(t.x,t.y).rotate(i),e=this.options.scale,e&&(n=n.scale(e)),this.vel.transform(n,{absolute:!0})),this},onPointerDown:function(t){var e,n,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),n=(e=this.relatedView).paper,e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),i=t.data||(t.data={}),this.delegateDocumentEvents(null,i),n.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none",e.notifyPointerdown(...n.getPointerArgs(t)))},onPointerMove:function(t){var t=C(t),e=this.paper.snapToGrid(t.clientX,t.clientY);this.relatedView.pointermove(t,e.x,e.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,t=C(t),i=n.snapToGrid(t.clientX,t.clientY);e.pointerup(t,i.x,i.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),o=l.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"}}),s=l.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"}}),c=ed.extend({tagName:"g",type:null,children:[{tagName:"circle",selector:"anchor",attributes:{cursor:"pointer"}},{tagName:"rect",selector:"area",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{snap:function(t,e,n,i,r,o){return o=o.options.snapRadius,i="source"===i,(i=this.model.vertex(i?0:-1)||this.getEndAnchor(i?"target":"source"))&&(Math.abs(i.x-t.x)<o&&(t.x=i.x),Math.abs(i.y-t.y)<o)&&(t.y=i.y),t},anchor:id,scale:null,resetAnchor:!0,customAnchorAttributes:{"stroke-width":4,stroke:"#33334F",fill:"#FFFFFF",r:5},defaultAnchorAttributes:{"stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6},areaPadding:6,snapRadius:10,restrictArea:!0,redundancyRemoval:!0},onRender:function(){this.renderChildren(),this.toggleArea(!1),this.update()},update:function(){var t=this.type;return this.relatedView.getEndView(t)?(this.updateAnchor(),this.updateArea(),this.el.style.display=""):this.el.style.display="none",this},updateAnchor:function(){var t=this.childNodes;if(t){var s=t.anchor;if(s){let t=this.relatedView,e=this.type,n=t.getEndAnchor(e),i=this.options,r=t.model.prop([e,"anchor"]),o=`translate(${n.x},${n.y})`;i.scale&&(o+=` scale(${i.scale})`),s.setAttribute("transform",o);var a,l=r?i.customAnchorAttributes:i.defaultAnchorAttributes;for(a in l)s.setAttribute(a,l[a])}}},updateArea:function(){var t,e,n,i,r,o,s,a=this.childNodes;a&&(a=a.area)&&(n=this.relatedView,i=this.type,e=(t=n.getEndView(i)).model,n=n.getEndMagnet(i),i=this.options.areaPadding,isFinite(i)||(i=0),t.isNodeConnection(n)?(o=0,s=(r=t.getNodeBBox(n)).center()):(r=t.getNodeUnrotatedBBox(n),o=e.angle(),s=r.center(),o&&s.rotate(e.getBBox().center(),-o)),r.inflate(i),a.setAttribute("x",-r.width/2),a.setAttribute("y",-r.height/2),a.setAttribute("width",r.width),a.setAttribute("height",r.height),a.setAttribute("transform","translate("+s.x+","+s.y+") rotate("+o+")"))},toggleArea:function(t){var e=this.childNodes;e&&(e=e.area)&&(e.style.display=t?"":"none")},onPointerDown:function(t){this.guard(t)||(t.stopPropagation(),t.preventDefault(),this.paper.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleArea(this.options.restrictArea),this.relatedView.model.startBatch("anchor-move",{ui:!0,tool:this.cid}))},resetAnchor:function(t){var e=this.type,n=this.relatedView.model;t?n.prop([e,"anchor"],t,{rewrite:!0,ui:!0,tool:this.cid}):n.removeProp([e,"anchor"],{ui:!0,tool:this.cid})},onPointerMove:function(t){var e,n,i,r=this.relatedView,o=this.type,s=r.getEndView(o),a=s.model,l=r.getEndMagnet(o),t=C(t),t=this.paper.clientToLocalPoint(t.clientX,t.clientY),h=this.options.snap,h=("function"==typeof h&&(t=h.call(r,t,s,l,o,r,this),t=new A(t)),this.options.restrictArea&&(s.isNodeConnection(l)?(h=s.getClosestPoint(t))&&(t=h):(h=s.getNodeUnrotatedBBox(l),e=a.angle(),a=a.getBBox().center(),n=t.clone().rotate(a,e),h.containsPoint(n)||(t=h.pointNearestToPoint(n).rotate(a,-e)))),this.options.anchor);"function"==typeof h&&(i=h.call(r,t,s,l,o,r)),this.resetAnchor(i),this.update()},onPointerUp:function(t){var t=C(t),e=(this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleArea(!1),this.relatedView);this.options.redundancyRemoval&&e.removeRedundantLinearVertices({ui:!0,tool:this.cid}),e.checkMouseleave(t),e.model.stopBatch("anchor-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.options.resetAnchor;!1!==t&&(!0===t&&(t=null),this.resetAnchor(ta(t)),this.update())}}),u=c.extend({name:"source-anchor",type:"source"}),r=c.extend({name:"target-anchor",type:"target"});let rd=ed.extend({tagName:"g",children:[{tagName:"circle",selector:"handle",attributes:{cursor:"pointer","stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6}},{tagName:"rect",selector:"extras",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{handleAttributes:null,selector:"root",padding:6,scale:null},getPosition:function(){},setPosition:function(){},resetPosition:function(){},onRender:function(){this.renderChildren(),this.toggleExtras(!1),this.update()},update:function(){var{handle:t,extras:e}=this.childNodes;if(t)return this.updateHandle(t),e&&this.updateExtras(e),this;throw new Error("Control: markup selector `handle` is required")},updateHandle:function(t){var{relatedView:e,options:n}=this,i=e.model,e=this.getPosition(e,this),i=i.getAbsolutePointFromRelative(e),{handleAttributes:r,scale:e}=n;let o=`translate(${i.x},${i.y})`;if(e&&(o+=` scale(${e})`),t.setAttribute("transform",o),r)for(var s in r)t.setAttribute(s,r[s])},updateExtras:function(e){var{relatedView:n,options:i}=this,r=this.options.selector;if(r){r=n.findNode(r);if(!r)throw new Error("Control: invalid selector.");let t=i.padding;isFinite(t)||(t=0);var i=n.getNodeUnrotatedBBox(r),r=n.model,n=r.angle(),o=i.center();n&&o.rotate(r.getBBox().center(),-n),i.inflate(t),e.setAttribute("x",-i.width/2),e.setAttribute("y",-i.height/2),e.setAttribute("width",i.width),e.setAttribute("height",i.height),e.setAttribute("transform",`translate(${o.x},${o.y}) rotate(${n})`)}else this.toggleExtras(!1)},toggleExtras:function(t){var e=this.childNodes.extras;e&&(e.style.display=t?"":"none")},onPointerDown:function(t){var{relatedView:e,paper:n}=this;this.guard(t)||(t.stopPropagation(),t.preventDefault(),n.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleExtras(!0),e.model.startBatch("control-move",{ui:!0,tool:this.cid}))},onPointerMove:function(t){var{relatedView:e,paper:n}=this,i=e.model,{clientX:r,clientY:o}=C(t),n=n.clientToLocalPoint(r,o),r=i.getRelativePointFromAbsolute(n);this.setPosition(e,r,t),this.update()},onPointerUp:function(t){var{relatedView:e,paper:n}=this;n.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleExtras(!1),e.model.stopBatch("control-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(t){var e=this.relatedView;this.resetPosition(e,t),this.update()}});Je=rd.extend({xAxisVector:new A(1,0),children(){var{buttonColor:t="#333",iconColor:e="#fff",outlineColor:n="#fff"}=this.options;return[{selector:"handle",tagName:"g",attributes:{cursor:"grab"},children:[{tagName:"circle",attributes:{r:10,fill:t,stroke:n}},{tagName:"path",attributes:{d:"M -5 0 A 5 5 0 1 1 0 5",fill:"transparent",stroke:e,strokeWidth:2,strokeLinecap:"round"}},{tagName:"path",attributes:{d:"M -3 5 L 0 2.5 0 7.5 Z",fill:e,stroke:e,strokeWidth:1,transform:"rotate(-5, -3, 5)"}}]}]},getPosition(t){var{offset:e=0}=this.options,{x:e=0,y:n=0}="number"==typeof e?{x:0,y:e}:e,i=this.getLabel(),i=this.getLabelPosition(i),r=t.getLabelCoordinates(i);let{angle:o=0,args:s={}}=i;s.keepGradient&&(i=t.getTangentAtRatio(t.getClosestPointRatio(r)))&&(o+=i.vector().vectorAngle(this.xAxisVector)||0);t=(new DOMMatrix).translate(r.x,r.y).rotate(o).translate(e,n);return new A(t.e,t.f)},computeVisibility(){return rd.prototype.computeVisibility.apply(this,arguments)&&!!this.getLabel()},setPosition(t,e){var n=t.model,i=this.getLabel();i&&(i=this.getLabelPosition(i),t=90-t.getLabelCoordinates(i).theta(e),i=this.getLabelIndex(),n.prop(["labels",i,"position","angle"],t))},resetPosition(t){var t=t.model,e=this.getLabelIndex();t.prop(["labels",e,"position","angle"],0)},getLabelIndex(){return this.options.labelIndex||0},getLabel(){return this.relatedView.model.label(this.getLabelIndex())||null},getLabelPosition(t){var e=this.relatedView,t=e._normalizeLabelPosition(t.position);return e._mergeLabelPositionProperty(t,e._getDefaultLabelPositionProperty())}}),h=ed.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(){var t=this.vel;t.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix(){var{relatedView:t,options:e}=this;let{x:n=0,y:i=0,offset:r={},useModelGeometry:o,rotate:s,scale:a}=e,l=nd(t,o);var e=t.model.angle(),{x:t=0,y:h=0}=(s||(l=l.bbox(e)),r);ll(n)?n=parseFloat(n)/100*l.width:Zl(n)&&(n=Number(Ql(n,l))),ll(i)?i=parseFloat(i)/100*l.height:Zl(i)&&(i=Number(Ql(i,l)));let u=R.createSVGMatrix().translate(l.x+l.width/2,l.y+l.height/2);return u=(u=s?u.rotate(e):u).translate(n+t-l.width/2,i+h-l.height/2),u=a?u.scale(a):u},getLinkMatrix(){var{relatedView:t,options:e}=this,{offset:e=0,distance:n=0,rotate:i,scale:r}=e,n="function"==typeof n?n.call(this,t,this):n;let o,s,a,l=(o=ll(n)?t.getTangentAtRatio(parseFloat(n)/100):t.getTangentAtLength(n),a=o?(s=o.start,o.vector().vectorAngle(new A(1,0))||0):(s=t.getConnection().start,0),R.createSVGMatrix().translate(s.x,s.y).rotate(a).translate(0,e));return i||(l=l.rotate(-a)),l=r?l.scale(r):l},onPointerDown:function(t){var e;this.guard(t)||(t.stopPropagation(),t.preventDefault(),"function"==typeof(e=this.options.action)&&e.call(this.relatedView,t,this.relatedView,this))}}),l=h.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})}}}),c=ed.extend({name:"boundary",tagName:"rect",options:{padding:10,useModelGeometry:!1},attributes:{fill:"none",stroke:"#33334F","stroke-width":.5,"stroke-dasharray":"5, 5","pointer-events":"none"},onRender:function(){this.update()},update:function(){var{relatedView:t,options:e,vel:n}=this,{useModelGeometry:i,rotate:r}=e,e=gl(e.padding);let o=nd(t,i).moveAndExpand({x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}),s=t.model,a,l;return s.isElement()&&(a=s.angle())&&(r?(l=s.getBBox().center(),n.rotate(a,l.x,l.y,{absolute:!0})):o=o.bbox(a)),n.attr(o.toJSON()),this}});let od=h.extend({name:"connect",documentEvents:{mousemove:"drag",touchmove:"drag",mouseup:"dragend",touchend:"dragend",touchcancel:"dragend"},children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2,"pointer-events":"none"}}],options:{distance:80,offset:0,magnet:t=>t.el,action:(t,e,n)=>n.dragstart(t)},getMagnetNode:function(){var{options:t,relatedView:e}=this,n=t.magnet;let i;switch(typeof n){case"function":i=n.call(this,e,this);break;case"string":i=e.findNode(n);break;default:i=n}if((i=i||e.el)instanceof SVGElement)return i;throw new Error("Connect: magnet must be an SVGElement")},dragstart:function(t){var{paper:e,relatedView:n}=this,t=C(t),{x:i,y:r}=e.clientToLocalPoint(t.clientX,t.clientY);n.dragLinkStart(t,this.getMagnetNode(),i,r),e.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.focus()},drag:function(t){var{paper:e,relatedView:n}=this,t=C(t),{x:e,y:i}=e.snapToGrid(t.clientX,t.clientY);n.dragLink(t,e,i)},dragend:function(t){var{paper:e,relatedView:n}=this,t=C(t),{x:i,y:r}=e.snapToGrid(t.clientX,t.clientY);n.dragLinkEnd(t,i,r),this.undelegateDocumentEvents(),e.delegateEvents(),this.blur(),n.checkMouseleave(t)}});var sd=od.extend({name:"hover-connect",defaultMarkup:[{tagName:"circle",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2}}],children(){var{options:t,defaultMarkup:e}=this;return[{tagName:"path",selector:"track",attributes:{fill:"none",stroke:"transparent","stroke-width":t.trackWidth||15,cursor:"pointer"}},{tagName:"g",selector:"button",attributes:{"pointer-events":"none",display:"none"},children:t.markup||e}]},events:Object.assign({mousemove:"onMousemove",mouseenter:"onMouseenter",mouseleave:"onMouseleave"},od.prototype.events),onRender:function(){this.renderChildren(),this.update()},trackPath:null,update(){var t=this.childNodes;this.trackPath=this.getTrackPath(),od.prototype.update.apply(this,arguments),t.track.setAttribute("d",this.trackPath.serialize())},position(){var{el:t,childNodes:e}=this;e.button.setAttribute("transform",R.matrixToTransformString(this.getButtonMatrix())),t.setAttribute("transform",R.matrixToTransformString(this.getTrackMatrix()))},getButtonMatrix(){var{options:t,trackPath:e}=this,{offset:t=0,distance:n=0,rotate:i,scale:r}=t;let o,s,a,l=(o=ll(n)?e.tangentAtRatio(parseFloat(n)/100):e.tangentAtLength(n),a=o?(s=o.start,o.vector().vectorAngle(new A(1,0))||0):(s=e.start,0),R.createSVGMatrix().translate(s.x,s.y).rotate(a).translate(0,t));return i||(l=l.rotate(-a)),l=r?l.scale(r):l},getTrackPath(){return this.relatedView.getConnection()},getTrackMatrix(){return R.createSVGMatrix()},getTrackRatioFromEvent(t){var{relatedView:e,trackPath:n}=this,e=e.paper.clientToLocalPoint(t.clientX,t.clientY),t=R.transformPoint(e,this.getTrackMatrix().inverse());return n.closestPointLength(t)},canShowButton(){return L.event.has(this.paper.el)},showButton(){this.childNodes.button.style.display="block"},hideButton(){this.childNodes.button.style.display=""},onMousemove(t){var e=this.trackPath;e&&(e=this.options,e.distance=this.getTrackRatioFromEvent(t),this.position())},onMouseenter(){this.canShowButton()&&this.showButton()},onMouseleave(){this.hideButton()}}),e={Vertices:e,Segments:Rh,TargetArrowhead:o,SourceArrowhead:s,SourceAnchor:u,TargetAnchor:r,RotateLabel:Je,Button:h,Remove:l,Boundary:c,Connect:od,HoverConnect:sd,Control:rd},Rh={HoverConnect:sd.extend({getTrackPath(){var{relatedView:t,options:e}=this;let{useModelGeometry:n,trackPath:i="M 0 0 H calc(w) V calc(h) H 0 Z"}=e;return Zl(i="function"==typeof i?i.call(this,t):i)&&(e=nd(t,n),i=Ql(i,e)),new V(R.normalizePathData(i))},getTrackMatrix(){var{relatedView:t,options:e}=this,{useModelGeometry:e,rotate:n}=e;let i=nd(t,e);e=t.model.angle();n||(i=i.bbox(e));let r=R.createSVGMatrix().translate(i.x+i.width/2,i.y+i.height/2);return r=(r=n?r.rotate(e):r).translate(-i.width/2,-i.height/2)}}),Button:h,Remove:l,Connect:od,Boundary:c,Control:rd},o=R,s={PortLabel:_h,Port:Eh};t.V=R,t.Vectorizer=o,t.anchors=i,t.config=Ua,t.connectionPoints=$e,t.connectionStrategies=Fu,t.connectors=su,t.dia=a,t.elementTools=Rh,t.env=Oh,t.format={},t.g=br,t.highlighters=n,t.layout=s,t.linkAnchors=Ic,t.linkTools=e,t.mvc=Ln,t.routers=Nc,t.setTheme=function(t,e){e=e||{},Xs(hu,"setTheme",t,e),uu.prototype.defaultTheme=t},t.shapes=sn,t.ui={},t.util=hn,t.version="4.1.0",Object.defineProperty(t,"__esModule",{value:!0})}),"undefined"!=typeof joint&&(g=joint.g,Vectorizer=V=joint.V);
|
|
8
|
+
var g,V,Vectorizer;((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).joint={})})(this,function(t){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _(t,e){return t(e={exports:{}},e.exports),e.exports}function N(t){return t&&t.Math==Math&&t}function O(t){try{return!!t()}catch(t){return!0}}function F(t){return St(kt(t))}function I(e,n){try{jt(yt,e,n)}catch(t){yt[e]=n}return n}function D(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++qt+$t).toString(36)}function z(t){return Wt[t]||(Wt[t]=D(t))}function j(t){return"function"==typeof t?t:void 0}function G(t,e){return arguments.length<2?j(Jt[t])||j(yt[t]):Jt[t]&&Jt[t][e]||yt[t]&&yt[t][e]}function U(t){return 0<t?ee(te(t),9007199254740991):0}function H(a){return function(t,e,n){var i,r=F(t),o=U(r.length),s=((t,e)=>(t=te(t))<0?ne(t+e,0):ie(t,e))(n,o);if(a&&e!=e){for(;s<o;)if((i=r[s++])!=i)return!0}else for(;s<o;s++)if((a||s in r)&&r[s]===e)return a||s||0;return!a&&-1}}function q(t,e){var n,i=F(t),r=0,o=[];for(n in i)!_t(Yt,n)&&_t(i,n)&&o.push(n);for(;e.length>r;)!_t(i,n=e[r++])||~re(o,n)||o.push(n);return o}function $(t,e){return(t=de[ce(t)])==pe||t!=fe&&("function"==typeof e?O(e):!!e)}function W(t,e){var n,i,r,o=t.target,s=t.global,a=t.stat,l=s?yt:a?yt[o]||I(o,{}):(yt[o]||{}).prototype;if(l)for(n in e){if(i=e[n],r=t.noTargetGet?(r=me(l,n))&&r.value:l[n],!ge(s?n:o+(a?".":"#")+n,t.forced)&&void 0!==r){if(typeof i==typeof r)continue;g=p=f=d=c=u=h=void 0;for(var h=i,u=r,c=he(u),d=zt.f,f=Vt.f,p=0;p<c.length;p++){var g=c[p];_t(h,g)||d(h,g,f(u,g))}}(t.sham||r&&r.sham)&&jt(i,"sham",!0),Zt(l,n,i,t)}}function Y(t){return _t(ye,t)||(ve&&_t(be,t)?ye[t]=be[t]:ye[t]=xe("Symbol."+t)),ye[t]}function X(){}function Z(t){Ne[_e][t]=!0}function J(t){throw t}function K(t,e){var n,i,r,o;return _t(Re,t)?Re[t]:(n=[][t],i=!!_t(e=e||{},"ACCESSORS")&&e.ACCESSORS,r=_t(e,0)?e[0]:J,o=_t(e,1)?e[1]:void 0,Re[t]=!!n&&!O(function(){if(i&&!bt)return 1;var t={length:-1};i?Oe(t,1,{enumerable:!0,get:J}):t[1]=1,n.call(t,r,o)}))}function Q(i,r,t){if(Ie(i),void 0===r)return i;switch(t){case 0:return function(){return i.call(r)};case 1:return function(t){return i.call(r,t)};case 2:return function(t,e){return i.call(r,t,e)};case 3:return function(t,e,n){return i.call(r,t,e,n)}}return function(){return i.apply(r,arguments)}}function nt(t,e,n){return Q(Ve,yt[t].prototype[e],n)}function it(t){return Object(kt(t))}function rt(t,e){var n;return new(void 0===(n=Be(t)&&("function"==typeof(n=t.constructor)&&(n===Array||Be(n.prototype))||Lt(n)&&null===(n=n[De]))?void 0:n)?Array:n)(0===e?0:e)}function ot(d){var f=1==d,p=2==d,g=3==d,m=4==d,v=6==d,y=7==d,b=5==d||v;return function(t,e,n,i){for(var r,o,s=it(t),a=St(s),l=Q(e,n,3),h=U(a.length),u=0,e=i||rt,c=f?e(t,h):p||y?e(t,0):void 0;u<h;u++)if((b||u in a)&&(o=l(r=a[u],u,s),d))if(f)c[u]=o;else if(o)switch(d){case 3:return!0;case 5:return r;case 6:return u;case 2:ze.call(c,r)}else switch(d){case 4:return!1;case 7:ze.call(c,r)}return v?-1:g||m?m:c}}function st(r){return function(t,e){var n,t=String(kt(t)),e=te(e),i=t.length;return e<0||i<=e?r?"":void 0:(n=t.charCodeAt(e))<55296||56319<n||e+1===i||(i=t.charCodeAt(e+1))<56320||57343<i?r?t.charAt(e):n:r?t.slice(e,e+2):i-56320+(n-55296<<10)+65536}}function at(){return this}var lt,ht,ut,ct,dt,ft,pt,gt,mt,vt,yt=N("object"==typeof globalThis&&globalThis)||N("object"==typeof window&&window)||N("object"==typeof self&&self)||N("object"==typeof e&&e)||function(){return this}()||Function("return this")(),bt=!O(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),e={}.propertyIsEnumerable,xt=Object.getOwnPropertyDescriptor,wt={f:xt&&!e.call({1:2},1)?function(t){t=xt(this,t);return!!t&&t.enumerable}:e},At=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Pt={}.toString,Et=function(t){return Pt.call(t).slice(8,-1)},Tt="".split,St=O(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==Et(t)?Tt.call(t,""):Object(t)}:Object,kt=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},Lt=function(t){return"object"==typeof t?null!==t:"function"==typeof t},Ct=function(t,e){if(!Lt(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t))||"function"==typeof(n=t.valueOf)&&!Lt(i=n.call(t))||!e&&"function"==typeof(n=t.toString)&&!Lt(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value")},Mt={}.hasOwnProperty,_t=function(t,e){return Mt.call(t,e)},Nt=yt.document,Ot=Lt(Nt)&&Lt(Nt.createElement),Rt=function(t){return Ot?Nt.createElement(t):{}},Ft=!bt&&!O(function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a}),It=Object.getOwnPropertyDescriptor,Vt={f:bt?It:function(t,e){if(t=F(t),e=Ct(e,!0),Ft)try{return It(t,e)}catch(t){}if(_t(t,e))return At(!wt.f.call(t,e),t[e])}},Bt=function(t){if(Lt(t))return t;throw TypeError(String(t)+" is not an object")},Dt=Object.defineProperty,zt={f:bt?Dt:function(t,e,n){if(Bt(t),e=Ct(e,!0),Bt(n),Ft)try{return Dt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},jt=bt?function(t,e,n){return zt.f(t,e,At(1,n))}:function(t,e,n){return t[e]=n,t},e="__core-js_shared__",Gt=yt[e]||I(e,{}),Ut=Function.toString,Ht=("function"!=typeof Gt.inspectSource&&(Gt.inspectSource=function(t){return Ut.call(t)}),Gt.inspectSource),e=yt.WeakMap,e="function"==typeof e&&/native code/.test(Ht(e)),n=_(function(t){(t.exports=function(t,e){return Gt[t]||(Gt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.8.3",mode:"global",copyright:"\xa9 2021 Denis Pushkarev (zloirock.ru)"})}),qt=0,$t=Math.random(),Wt=n("keys"),Yt={},i=yt.WeakMap,Xt=(pt=e?(lt=Gt.state||(Gt.state=new i),ht=lt.get,ut=lt.has,ct=lt.set,dt=function(t,e){return e.facade=t,ct.call(lt,t,e),e},ft=function(t){return ht.call(lt,t)||{}},function(t){return ut.call(lt,t)}):(gt=z("state"),Yt[gt]=!0,dt=function(t,e){return e.facade=t,jt(t,gt,e),e},ft=function(t){return _t(t,gt)?t[gt]:{}},function(t){return _t(t,gt)}),{set:dt,get:ft,has:pt,enforce:function(t){return pt(t)?ft(t):dt(t,{})},getterFor:function(e){return function(t){if(Lt(t)&&(t=ft(t)).type===e)return t;throw TypeError("Incompatible receiver, "+e+" required")}}}),Zt=_(function(t){var e=Xt.get,a=Xt.enforce,l=String(String).split("String");(t.exports=function(t,e,n,i){var r,o=!!i&&!!i.unsafe,s=!!i&&!!i.enumerable,i=!!i&&!!i.noTargetGet;"function"==typeof n&&("string"!=typeof e||_t(n,"name")||jt(n,"name",e),(r=a(n)).source||(r.source=l.join("string"==typeof e?e:""))),t===yt?s?t[e]=n:I(e,n):(o?!i&&t[e]&&(s=!0):delete t[e],s?t[e]=n:jt(t,e,n))})(Function.prototype,"toString",function(){return"function"==typeof this&&e(this).source||Ht(this)})}),Jt=yt,Kt=Math.ceil,Qt=Math.floor,te=function(t){return isNaN(t=+t)?0:(0<t?Qt:Kt)(t)},ee=Math.min,ne=Math.max,ie=Math.min,e={includes:H(!0),indexOf:H(!1)},re=e.indexOf,oe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],se=oe.concat("length","prototype"),ae={f:Object.getOwnPropertyNames||function(t){return q(t,se)}},le={f:Object.getOwnPropertySymbols},he=G("Reflect","ownKeys")||function(t){var e=ae.f(Bt(t)),n=le.f;return n?e.concat(n(t)):e},ue=/#|\.prototype\./,ce=$.normalize=function(t){return String(t).replace(ue,".").toLowerCase()},de=$.data={},fe=$.NATIVE="N",pe=$.POLYFILL="P",ge=$,me=Vt.f,ve=!!Object.getOwnPropertySymbols&&!O(function(){return!String(Symbol())}),i=ve&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ye=n("wks"),be=yt.Symbol,xe=i?be:be&&be.withoutSetter||D,we=Object.keys||function(t){return q(t,oe)},Ae=bt?Object.defineProperties:function(t,e){Bt(t);for(var n,i=we(e),r=i.length,o=0;o<r;)zt.f(t,n=i[o++],e[n]);return t},Pe=G("document","documentElement"),Ee=">",Te="<",Se="prototype",ke="script",Le=z("IE_PROTO"),Ce=function(t){return Te+ke+Ee+t+Te+"/"+ke+Ee},Me=function(){try{mt=document.domain&&new ActiveXObject("htmlfile")}catch(t){}Me=mt?((t=mt).write(Ce("")),t.close(),e=t.parentWindow.Object,t=null,e):(t=Rt("iframe"),e="java"+ke+":",t.style.display="none",Pe.appendChild(t),t.src=String(e),(e=t.contentWindow.document).open(),e.write(Ce("document.F=Object")),e.close(),e.F);for(var t,e,n=oe.length;n--;)delete Me[Se][oe[n]];return Me()},n=(Yt[Le]=!0,Object.create||function(t,e){var n;return null!==t?(X[Se]=Bt(t),n=new X,X[Se]=null,n[Le]=t):n=Me(),void 0===e?n:Ae(n,e)}),_e=Y("unscopables"),Ne=Array.prototype,Oe=(null==Ne[_e]&&zt.f(Ne,_e,{configurable:!0,value:n(null)}),Object.defineProperty),Re={},Fe=e.includes,i=K("indexOf",{ACCESSORS:!0,1:0}),Ie=(W({target:"Array",proto:!0,forced:!i},{includes:function(t){return Fe(this,t,1<arguments.length?arguments[1]:void 0)}}),Z("includes"),function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}),Ve=Function.call,Be=(nt("Array","includes"),Array.isArray||function(t){return"Array"==Et(t)}),De=Y("species"),ze=[].push,e={forEach:ot(0),map:ot(1),filter:ot(2),some:ot(3),every:ot(4),find:ot(5),findIndex:ot(6),filterOut:ot(7)},je=e.find,i="find",Ge=!0,r=K(i),r=(i in[]&&Array(1)[i](function(){Ge=!1}),W({target:"Array",proto:!0,forced:Ge||!r},{find:function(t){return je(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(i),nt("Array","find"),{codeAt:st(!1),charAt:st(!0)}),i=!O(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),Ue=z("IE_PROTO"),He=Object.prototype,i=i?Object.getPrototypeOf:function(t){return t=it(t),_t(t,Ue)?t[Ue]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?He:null},qe=Y("iterator"),$e=!1,We=([].keys&&("next"in(We=[].keys())?(We=i(i(We)))!==Object.prototype&&(vt=We):$e=!0),null==vt||O(function(){var t={};return vt[qe].call(t)!==t})),We=(_t(vt=We?{}:vt,qe)||jt(vt,qe,function(){return this}),{IteratorPrototype:vt,BUGGY_SAFARI_ITERATORS:$e}),Ye=zt.f,Xe=Y("toStringTag"),$e=function(t,e,n){t&&!_t(t=n?t:t.prototype,Xe)&&Ye(t,Xe,{configurable:!0,value:e})},Ze={},o=We.IteratorPrototype,Je=function(){return this},s=Object.setPrototypeOf||("__proto__"in{}?(()=>{var n,i=!1,t={};try{(n=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(t,[]),i=t instanceof Array}catch(t){}return function(t,e){return Bt(t),(t=>{if(Lt(t)||null===t)return;throw TypeError("Can't set "+String(t)+" as a prototype")})(e),i?n.call(t,e):t.__proto__=e,t}})():void 0),a=We.IteratorPrototype,Ke=We.BUGGY_SAFARI_ITERATORS,We=Y("iterator"),Qe="values",tn="entries",en=r.charAt,nn="String Iterator",rn=Xt.set,on=Xt.getterFor(nn),r=String,sn="String",an=function(t){rn(this,{type:nn,string:String(t),index:0})},l=function(){var t=on(this),e=t.string,n=t.index;return n>=e.length?{value:void 0,done:!0}:(e=en(e,n),t.index+=e.length,{value:e,done:!1})},ln=void 0,h=void 0,hn=void 0;function un(t){if(t===ln&&mn)return mn;if(!Ke&&t in pn)return pn[t];switch(t){case"keys":case Qe:case tn:return function(){return new an(this,t)}}return function(){return new an(this)}}c=sn,c+=" Iterator",(u=an).prototype=n(o,{next:At(1,l)}),$e(u,c,!1,!0),Ze[c]=Je;var cn,dn,l=sn+" Iterator",fn=!1,pn=r.prototype,gn=pn[We]||pn["@@iterator"]||ln&&pn[ln],mn=!Ke&&gn||un(ln),u="Array"==sn&&pn.entries||gn;if(u&&(c=i(u.call(new r)),a!==Object.prototype)&&c.next&&(i(c)!==a&&(s?s(c,a):"function"!=typeof c[We]&&jt(c,We,at)),$e(c,l,!0,!0)),ln==Qe&&gn&&gn.name!==Qe&&(fn=!0,mn=function(){return gn.call(this)}),pn[We]!==mn&&jt(pn,We,mn),Ze[sn]=mn,ln)if(cn={values:un(Qe),keys:h?mn:un("keys"),entries:un(tn)},hn)for(dn in cn)!Ke&&!fn&&dn in pn||Zt(pn,dn,cn[dn]);else W({target:sn,proto:!0,forced:Ke||fn},cn);function vn(t,e,n){(e=Ct(e))in t?zt.f(t,e,At(0,n)):t[e]=n}var yn=function(t){var e=t.return;if(void 0!==e)return Bt(e.call(t)).value},bn=Y("iterator"),xn=Array.prototype,n={},o=(n[Y("toStringTag")]="z","[object z]"===String(n)),wn=Y("toStringTag"),An="Arguments"==Et(function(){return arguments}()),Pn=o?Et:function(t){var e;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=((t,e)=>{try{return t[e]}catch(t){}})(t=Object(t),wn))?e:An?Et(t):"Object"==(e=Et(t))&&"function"==typeof t.callee?"Arguments":e},En=Y("iterator"),Tn=Y("iterator"),Sn=!1;try{var kn=0,Ln={next:function(){return{done:!!kn++}},return:function(){Sn=!0}};Ln[Tn]=function(){return this},Array.from(Ln,function(){throw 2})}catch(t){}function Cn(t){if(Lt(e=t)&&(void 0!==(n=e[Rn])?!!n:"RegExp"==Et(e)))throw TypeError("The method doesn't accept regular expressions");var e,n;return t}function Mn(e){var n=/./;try{"/./"[e](n)}catch(t){try{return n[Fn]=!1,"/./"[e](n)}catch(t){}}return!1}var Je=!((t,e)=>{if(!e&&!Sn)return!1;var n=!1;try{var i={};i[Tn]=function(){return{next:function(){return{done:n=!0}}}},t(i)}catch(t){}return n})(function(t){Array.from(t)}),_n=(W({target:"Array",stat:!0,forced:Je},{from:function(t){var e,n,i,r,o,s,a=it(t),t="function"==typeof this?this:Array,l=arguments.length,h=1<l?arguments[1]:void 0,u=void 0!==h,c=(t=>{if(null!=t)return t[En]||t["@@iterator"]||Ze[Pn(t)]})(a),d=0;if(u&&(h=Q(h,2<l?arguments[2]:void 0,2)),null!=c&&(t!=Array||void 0===(l=c)||Ze.Array!==l&&xn[bn]!==l))for(o=(r=c.call(a)).next,n=new t;!(i=o.call(r)).done;d++)s=u?((e,t,n,i)=>{try{return i?t(Bt(n)[0],n[1]):t(n)}catch(t){throw yn(e),t}})(r,h,[i.value,d],!0):i.value,vn(n,d,s);else for(n=new t(e=U(a.length));d<e;d++)s=u?h(a[d],d):a[d],vn(n,d,s);return n.length=d,n}}),Jt.Array.from,e.findIndex),u="findIndex",Nn=!0,r=K(u),On=(u in[]&&Array(1)[u](function(){Nn=!1}),W({target:"Array",proto:!0,forced:Nn||!r},{findIndex:function(t){return _n(this,t,1<arguments.length?arguments[1]:void 0)}}),Z(u),nt("Array","findIndex"),_(function(t,e){function a(t){this.message=t}var l;e=e,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",(a.prototype=new Error).name="InvalidCharacterError",e.btoa||(e.btoa=function(t){for(var e,n,i=String(t),r=0,o=l,s="";i.charAt(0|r)||(o="=",r%1);s+=o.charAt(63&e>>8-r%1*8)){if(255<(n=i.charCodeAt(r+=.75)))throw new a("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");e=e<<8|n}return s}),e.atob||(e.atob=function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new a("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,r=0,o=0,s="";i=e.charAt(o++);~i&&(n=r%4?64*n+i:i,r++%4)&&(s+=String.fromCharCode(255&n>>(-2*r&6))))i=l.indexOf(i);return s})}),W({target:"Number",stat:!0},{isNaN:function(t){return t!=t}}),Jt.Number.isNaN,yt.isFinite),i=Number.isFinite||function(t){return"number"==typeof t&&On(t)},Rn=(W({target:"Number",stat:!0},{isFinite:i}),Jt.Number.isFinite,Y("match")),Fn=Y("match"),s=(W({target:"String",proto:!0,forced:!Mn("includes")},{includes:function(t){return!!~String(kt(this)).indexOf(Cn(t),1<arguments.length?arguments[1]:void 0)}}),nt("String","includes"),Vt.f),In="".startsWith,Vn=Math.min,a=Mn("startsWith"),c=!(a||!($e=s(String.prototype,"startsWith"))||$e.writable);W({target:"String",proto:!0,forced:!c&&!a},{startsWith:function(t){var e=String(kt(this)),n=(Cn(t),U(Vn(1<arguments.length?arguments[1]:void 0,e.length))),t=String(t);return In?In.call(e,t,n):e.slice(n,n+t.length)===t}}),nt("String","startsWith");function Bn(t,e){return this.slice(t,e)}function Dn(t,e){arguments.length<2&&(e=0);for(var n=0,i=t.length;n<i;++n,++e)this[e]=255&t[n]}function zn(t){if("number"==typeof t)for(var e=new Array(t),n=0;n<t;++n)e[n]=0;else e=t.slice(0);return e.subarray=Bn,(e.buffer=e).byteLength=e.length,e.set=Dn,"object"==typeof t&&t.buffer&&(e.buffer=t.buffer),e}"undefined"==typeof Uint8Array&&"undefined"!=typeof window&&(window.Int32Array=window.Uint32Array=window.Uint8Array=zn);let{round:jn,floor:Gn,PI:Un}=Math;function Hn(t){return 180*t/Un%360}function qn(t,e){var n;return void 0===e?(e=void 0===t?1:t,t=0):e<t&&(n=t,t=e,e=n),Gn(Math.random()*(e-t+1)+t)}function $n(t,e){var n=Jn(t.y),i=Jn(e.y),t=t.x,e=e.x,e=Jn(e-t),t=Qn(e)*Kn(i),n=Kn(n)*Qn(i)-Qn(n)*Kn(i)*Kn(e);return(i=Hn(ti(t,n))-22.5)<0&&(i+=360),["NE","E","SE","S","SW","W","NW","N"][i=parseInt(i/45)]}function Wn(t,e){var n=t.x,t=t.y;return(n-=e.x)*n+(t-=e.y)*t}function Yn(t,e){return Math.sqrt(Wn(t,e))}let Xn=function(t){return t%360+(t<0?360:0)},Zn=function(t,e){return e*jn(t/e)},Jn=function(t,e){return(t=(e=e||!1)?t:t%360)*Un/180},{cos:Kn,sin:Qn,atan2:ti}=Math,d={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:ei,cos:ni,sin:ii,sqrt:ri,min:oi,max:si,atan2:ai,round:li,pow:hi,PI:ui}=Math,A=function(t,e){if(!(this instanceof A))return new A(t,e);var n;"string"==typeof t?(n=t.split(-1===t.indexOf("@")?" ":"@"),t=parseFloat(n[0]),e=parseFloat(n[1])):Object(t)===t&&(e=t.y,t=t.x),this.x=void 0===t?0:t,this.y=void 0===e?0:e},ci=(A.fromPolar=function(t,e,n){n=new A(n);var i=ei(t*ni(e)),t=ei(t*ii(e)),e=Xn(Hn(e));return e<90?t=-t:e<180?(i=-i,t=-t):e<270&&(i=-i),new A(n.x+i,n.y+t)},A.random=function(t,e,n,i){return new A(qn(t,e),qn(n,i))},A.prototype={type:d.Point,chooseClosest:function(t){var e=t.length;if(1===e)return new A(t[0]);for(var n=null,i=1/0,r=0;r<e;r++){var o=new A(t[r]),s=this.squaredDistance(o);s<i&&(n=o,i=s)}return n},adhereToRect:function(t){return t.containsPoint(this)||(this.x=oi(si(this.x,t.x),t.x+t.width),this.y=oi(si(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,e){e=this.equals(t)||this.equals(e)?NaN:this.theta(e)-this.theta(t);return e<0&&(e+=360),e},bearing:function(t){return $n(this,t)},changeInAngle:function(t,e,n){return this.clone().offset(-t,-e).theta(n)-this.theta(n)},clone:function(){return new A(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 A(this.x-(t||0),this.y-(e||0))},distance:function(t){return Yn(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 A((1-e)*n+e*t.x,(1-e)*i+e*t.y)},magnitude:function(){return ri(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return ei(t.x-this.x)+ei(t.y-this.y)},move:function(t,e){t=Jn(new A(t).theta(this));return this.offset(ni(t)*e,-ii(t)*e)},normalize:function(t){t=(t||1)/this.magnitude();return this.scale(t,t)},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 A(t).move(this,this.distance(t))},rotate:function(t,e){var n,i;return 0!==e&&(t=t||new A(0,0),e=Jn(Xn(-e)),n=ni(e),e=ii(e),i=n*(this.x-t.x)-e*(this.y-t.y)+t.x,e=e*(this.x-t.x)+n*(this.y-t.y)+t.y,this.x=i,this.y=e),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=hi(10,t)}return this.x=li(this.x*e)/e,this.y=li(this.y*e)/e,this},scale:function(t,e,n){return n=n&&new A(n)||new A(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=Zn(this.x,t),this.y=Zn(this.y,e||t),this},squaredDistance:function(t){return Wn(this,t)},theta:function(t){var e=-((t=new A(t)).y-this.y),t=t.x-this.x,e=ai(e,t);return 180*(e=e<0?2*ui+e:e)/ui},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new A(t)||new A(0,0);var e=this.x,n=this.y;return this.x=ri((e-t.x)*(e-t.x)+(n-t.y)*(n-t.y)),this.y=Jn(t.theta(new A(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 A(0,0).angleBetween(this,t)}},A.prototype.translate=A.prototype.offset,A),{max:di,min:fi}=Math,P=function(t,e){return this instanceof P?t instanceof P?new P(t.start,t.end):(this.start=new A(t),void(this.end=new A(e))):new P(t,e)},pi=(P.prototype={type:d.Line,angle:function(){var t=new A(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=fi(this.start.x,this.end.x),e=fi(this.start.y,this.end.y),n=di(this.start.x,this.end.x),i=di(this.start.y,this.end.y);return new tt(t,e,n-t,i-e)},bearing:function(){return $n(this.start,this.end)},clone:function(){return new P(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){t=this.vector().dot(new P(this.start,t).vector()),t=fi(1,di(0,t/this.squaredLength()));return t!=t?0:t},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var e,n=this.start,i=this.end;return 0===n.cross(t,i)&&(e=this.length(),!(new P(n,t).length()>e||new P(t,i).length()>e))},divideAt:function(t){t=this.pointAt(t);return[new P(this.start,t),new P(t,this.end)]},divideAtLength:function(t){t=this.pointAtLength(t);return[new P(this.start,t),new P(t,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){return t&&t.intersectionWithLine?(e=t.intersectionWithLine(this,e))&&t instanceof P?e[0]:e:null},intersectionWithLine:function(t){var e=new A(this.end.x-this.start.x,this.end.y-this.start.y),n=new A(t.end.x-t.start.x,t.end.y-t.start.y),i=e.x*n.y-e.y*n.x,t=new A(t.start.x-this.start.x,t.start.y-this.start.y),n=t.x*n.y-t.y*n.x,t=t.x*e.y-t.y*e.x;if(0==i||n*i<0||t*i<0)return null;if(0<i){if(i<n||i<t)return null}else if(n<i||t<i)return null;return[new A(this.start.x+n*e.x/i,this.start.y+n*e.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return Yn(this.start,this.end)},midpoint:function(){return new A((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var e,n,i,r,o=this.clone();return this.isDifferentiable()&&({start:e,end:n}=o,i=e.clone().rotate(n,270),r=n.clone().rotate(e,90),e.move(r,t),n.move(i,t)),o},pointAt:function(t){var e=this.start,n=this.end;return t<=0?e.clone():1<=t?n.clone():e.lerp(n,t)},pointAtLength:function(t){var e=this.start,n=this.end,i=!0,r=(t<0&&(i=!1,t=-t),this.length());return r<=t?(i?n:e).clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new A(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();return e?this.scale(t=t/e,t,this.start):this},squaredLength:function(){return Wn(this.start,this.end)},tangentAt:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAt(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},tangentAtLength:function(t){var e,n;return this.isDifferentiable()?(e=this.start,n=this.end,t=this.pointAtLength(t),(n=new P(e,n)).translate(t.x-e.x,t.y-e.y),n):null},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 A(this.end.x-this.start.x,this.end.y-this.start.y)}},P.prototype.intersection=P.prototype.intersect,P),{sqrt:gi,round:mi,pow:vi}=Math,yi=function(t,e,n){return this instanceof yi?t instanceof yi?new yi(new A(t.x,t.y),t.a,t.b):(t=new A(t),this.x=t.x,this.y=t.y,this.a=e,void(this.b=n)):new yi(t,e,n)};yi.fromRect=function(t){return t=new tt(t),new yi(t.center(),t.width/2,t.height/2)},yi.prototype={type:d.Ellipse,bbox:function(){return new tt(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new A(this.x,this.y)},clone:function(){return new yi(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,t=t.vector(),s=n.difference(new A(this)),a=new A(t.x/(r*r),t.y/(o*o)),r=new A(s.x/(r*r),s.y/(o*o)),o=t.dot(a),a=t.dot(r),t=a*a-o*(s.dot(r)-1);if(t<0)return null;if(0<t){s=gi(t),r=(-a-s)/o,t=(-a+s)/o;if((r<0||1<r)&&(t<0||1<t))return null;0<=r&&r<=1&&e.push(n.lerp(i,r)),0<=t&&t<=1&&e.push(n.lerp(i,t))}else{s=-a/o;if(!(0<=s&&s<=1))return null;e.push(n.lerp(i,s))}return e},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t),e&&t.rotate(new A(this.x,this.y),e);var n,i,r,o=t.x-this.x,s=t.y-this.y;return r=0==o?this.bbox().pointNearestToPoint(t):(s=(t=s/o)*t,i=this.a*this.a,n=this.b*this.b,i=gi(1/(1/i+s/n)),s=t*(i=o<0?-i:i),new A(this.x+i,this.y+s)),e?r.rotate(new A(this.x,this.y),-e):r},normalizedDistance:function(t){var e=t.x,t=t.y,n=this.a,i=this.b,r=this.x,o=this.y;return(e-r)*(e-r)/(n*n)+(t-o)*(t-o)/(i*i)},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=vi(10,t)}return this.x=mi(this.x*e)/e,this.y=mi(this.y*e)/e,this.a=mi(this.a*e)/e,this.b=mi(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,h=a.y;return a.x+o/2<i||i<a.x-o/2?n=o*o/(i-l)-o*o*(r-h)*((e=i>a.x?r-30:r+30)-h)/(s*s*(i-l))+l:e=s*s/(r-h)-s*s*(i-l)*((n=r>a.y?i+30:i-30)-l)/(o*o*(r-h))+h,new A(n,e).theta(t)},toString:function(){return new A(this.x,this.y).toString()+" "+this.a+" "+this.b}};l=yi;let{abs:bi,cos:xi,sin:wi,min:Ai,max:Pi,round:Ei,pow:Ti}=Math,tt=function(t,e,n,i){if(!(this instanceof tt))return new tt(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};tt.fromEllipse=function(t){return t=new yi(t),new tt(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},tt.fromPointUnion=function(){if(0===arguments.length)return null;var e=new A;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let t=0;t<arguments.length;t++){e.update(t<0||arguments.length<=t?void 0:arguments[t]);var s=e.x,a=e.y;s<n&&(n=s),s>r&&(r=s),a<i&&(i=a),a>o&&(o=a)}return new tt(n,i,r-n,o-i)},tt.fromRectUnion=function(){if(0===arguments.length)return null;var e=new tt;let n,i,r,o;n=i=1/0,r=o=-1/0;for(let t=0;t<arguments.length;t++){e.update(t<0||arguments.length<=t?void 0:arguments[t]);var s=e.x,a=e.y,l=s+e.width,h=a+e.height;s<n&&(n=s),l>r&&(r=l),a<i&&(i=a),h>o&&(o=h)}return new tt(n,i,r-n,o-i)},tt.prototype={type:d.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){var e,n,i,r;return t&&({width:i,height:e}=this,t=Jn(t),r=i*(n=bi(wi(t)))+e*(t=bi(xi(t))),this.x+=(i-(i=i*t+e*n))/2,this.y+=(e-r)/2,this.width=i,this.height=r),this},bottomLeft:function(){return new A(this.x,this.y+this.height)},bottomLine:function(){return new P(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new A(this.x+this.width/2,this.y+this.height)},center:function(){return new A(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new tt(this)},containsPoint:function(t,e){let n,i;return t&&"string"!=typeof t?{x:n=0,y:i=0}=t:{x:n,y:i}=new A(t),e&&e.strict?n>this.x&&n<this.x+this.width&&i>this.y&&i<this.y+this.height:n>=this.x&&n<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},containsRect:function(t){var e,n,i=new tt(this).normalize(),t=new tt(t).normalize(),r=i.width,o=i.height,s=t.width,a=t.height;return!!(r&&o&&s&&a)&&(e=i.x,i=i.y,s+=n=t.x,r+=e,a+=t=t.y,o+=i,e<=n)&&s<=r&&i<=t&&a<=o},corner:function(){return new A(this.x+this.width,this.y+this.height)},equals:function(t){var e=new tt(this).normalize(),t=new tt(t).normalize();return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.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,n=this.origin(),i=this.corner(),r=t.origin(),t=t.corner();return t.x<=n.x||t.y<=n.y||r.x>=i.x||r.y>=i.y?null:(e=Pi(n.x,r.x),n=Pi(n.y,r.y),new tt(e,n,Ai(i.x,t.x)-e,Ai(i.y,t.y)-n))},intersectionWithLine:function(t){for(var e,n=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],i=[],r=[],o=n.length,s=0;s<o;s++)null!==(e=t.intersect(n[s]))&&r.indexOf(e.toString())<0&&(i.push(e),r.push(e.toString()));return 0<i.length?i:null},intersectionWithLineFromCenterToPoint:function(t,e){t=new A(t);for(var n,i=new A(this.x+this.width/2,this.y+this.height/2),r=(e&&t.rotate(i,e),[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()]),o=new P(i,t),s=r.length-1;0<=s;--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 P(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new A(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,e){t=new tt(t);var n,i,r,o,s,a,l,h=(e=e||t.center()).x,e=e.y,u=n=i=r=o=s=a=l=1/0,c=t.topLeft(),c=(c.x<h&&(u=(this.x-h)/(c.x-h)),c.y<e&&(o=(this.y-e)/(c.y-e)),t.bottomRight()),c=(c.x>h&&(n=(this.x+this.width-h)/(c.x-h)),e<c.y&&(s=(this.y+this.height-e)/(c.y-e)),t.topRight()),c=(c.x>h&&(i=(this.x+this.width-h)/(c.x-h)),c.y<e&&(a=(this.y-e)/(c.y-e)),t.bottomLeft());return c.x<h&&(r=(this.x-h)/(c.x-h)),e<c.y&&(l=(this.y+this.height-e)/(c.y-e)),{sx:Ai(u,n,i,r),sy:Ai(o,s,a,l)}},maxRectUniformScaleToFit:function(t,e){t=this.maxRectScaleToFit(t,e);return Ai(t.sx,t.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 A.prototype.offset.call(this,t,e)},origin:function(){return new A(this.x,this.y)},pointNearestToPoint:function(t){if(t=new A(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new A(this.x+this.width,t.y);case"left":return new A(this.x,t.y);case"bottom":return new A(t.x,this.y+this.height);case"top":return new A(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new P(this.topRight(),this.bottomRight())},rightMiddle:function(){return new A(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=Ti(10,t)}return this.x=Ei(this.x*e)/e,this.y=Ei(this.y*e)/e,this.width=Ei(this.width*e)/e,this.height=Ei(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 A(t)).x-this.x,n=this.x+this.width-t.x,i=t.y-this.y,r="left";return n<e&&(e=n,r="right"),i<e&&(e=i,r="top"),r=this.y+this.height-t.y<e?"bottom":r},snapToGrid:function(t,e){var n=this.origin().snapToGrid(t,e),t=this.corner().snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=t.x-n.x,this.height=t.y-n.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new P(this.topLeft(),this.topRight())},topMiddle:function(){return new A(this.x+this.width/2,this.y)},topRight:function(){return new A(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return tt.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}},tt.prototype.bottomRight=tt.prototype.corner,tt.prototype.topLeft=tt.prototype.origin,tt.prototype.translate=tt.prototype.offset;h=tt;function Si(t){t=t.trim();if(""===t)return[];var e=[],n=t.split(/\b\s*,\s*|,\s*|\s+/),i=n.length;for(let t=0;t<i;t+=2)e.push({x:+n[t],y:+n[t+1]});return e}function ki(e){var n=e.length;if(0===n)return[];var i=[];for(let t=0;t<n;t++){var r=e[t].clone();i.push(r)}return i}function Li(t){var e,n=Math.abs,i=t.length;if(0===i)return[];for(o=0;o<i;o++)(void 0===e||t[o].y<e.y||t[o].y===e.y&&t[o].x>e.x)&&(e=t[o]);for(var r=[],o=0;o<i;o++){var s=e.theta(t[o]),s=(0===s&&(s=360),[t[o],o,s]);r.push(s)}r.sort(function(t,e){var n=t[2]-e[2];return n=0===n?e[1]-t[1]:n}),2<r.length&&r.unshift(r[r.length-1]);for(var a,l,h,u={},c=[];0!==r.length;)if(l=(a=r.pop())[0],!u.hasOwnProperty(a[0]+"@@"+a[1]))for(var d,f,p,g,m,v=!1;!v;)c.length<2?(c.push(a),v=!0):(f=(d=c.pop())[0],(m=(g=(p=c.pop())[0]).cross(f,l))<0?(c.push(p),c.push(d),c.push(a),v=!0):0!==m||n((m=f.angleBetween(g,l))-180)<1e-10||f.equals(l)||g.equals(f)?(u[d[0]+"@@"+d[1]]=f,c.push(p)):n((m+1)%360-1)<1e-10&&(c.push(p),r.push(d)));2<c.length&&c.pop();var y=-1,b=c.length;for(o=0;o<b;o++){var x=c[o][1];(void 0===h||x<h)&&(h=x,y=o)}var w,A,P=[],E=[];for(b=(P=0<y?(w=c.slice(y),A=c.slice(0,y),w.concat(A)):c).length,o=0;o<b;o++)E.push(P[o][0]);return E}let x=function(t){return this instanceof x?"string"==typeof t?new x.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new x(t)},{abs:Ci,sqrt:Mi,min:_i,max:Ni,pow:Oi}=(x.parse=function(t){return new x(Si(t))},x.fromRect=function(t){return new x([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},x.prototype={type:d.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,a=a.y;l<t&&(t=l),e<l&&(e=l),a<n&&(n=a),i<a&&(i=a)}return new tt(t,n,e-t,i-n)},clone:function(){return new x(ki(this.points))},closestPoint:function(t){t=this.closestPointLength(t);return this.pointAtLength(t)},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 P(n[a],n[a+1]),h=l.length(),u=l.closestPointNormalizedLength(t),l=l.pointAt(u).squaredDistance(t);l<r&&(r=l,e=o+u*h),o+=h}return e},closestPointNormalizedLength:function(t){var e,t=this.closestPointLength(t);return 0===t||0===(e=this.length())?0:t/e},closestPointTangent:function(t){t=this.closestPointLength(t);return this.tangentAtLength(t)},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 P,h=new P,u=new A;s<n;s++){var c=e[o],d=e[s];if(t.equals(c))return!0;if(l.start=c,l.end=d,l.containsPoint(t))return!0;(r<=c.y&&r>d.y||r>c.y&&r<=d.y)&&0<=(c=c.x-i>d.x-i?c.x-i:d.x-i)&&(u.x=i+c,u.y=r,h.start=t,h.end=u,l.intersect(h))&&a++,o=s}return a%2==1},close:function(){var{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 x(Li(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 P(t),n=[],i=this.lengthPoints(),r=new P,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 0<n.length?n:null},isDifferentiable:function(){var t=this.points,e=t.length;if(0!==e)for(var n=new P,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;return 0===n?null:1===n||t<=0?e[0].clone():1<=t?e[n-1].clone():(e=this.length(),this.pointAtLength(e*t))},pointAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return e[0].clone();for(var i=!0,r=(t<0&&(i=!1,t=-t),0),o=n-1,s=0;s<o;s++){var a=i?s:o-1-s,l=e[a],a=e[a+1],h=new P(l,a),l=l.distance(a);if(t<=r+l)return h.pointAtLength((i?1:-1)*(t-r));r+=l}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(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=this.points;if(!(n.length<3)){var i=e.threshold||1e-10;let t=0;for(;n[t+2];){var r=t,o=t+1,s=t+2,r=n[r],a=n[o],s=n[s];new P(r,s).closestPoint(a).distance(a)<=i?n.splice(o,1):t+=1}}return this},tangentAt:function(t){var e=this.lengthPoints().length;if(0===e)return null;if(1===e)return null;1<(t=t<0?0:t)&&(t=1);e=this.length();return this.tangentAtLength(e*t)},tangentAtLength:function(t){var e=this.lengthPoints(),n=e.length;if(0===n)return null;if(1===n)return null;for(var i,r=!0,o=(t<0&&(r=!1,t=-t),0),s=n-1,a=0;a<s;a++){var l=r?a:s-1-a,h=e[l],l=e[l+1],u=new P(h,l),h=h.distance(l);if(u.isDifferentiable()){if(t<=o+h)return u.tangentAtLength((r?1:-1)*(t-o));i=u}o+=h}return i?i.tangentAt(r?1:0):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(x.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(x.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}}),Math),v=function(t,e,n,i){return this instanceof v?t instanceof v?new v(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new A(t),this.controlPoint1=new A(e),this.controlPoint2=new A(n),void(this.end=new A(i))):new v(t,e,n,i)};function Ri(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,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);for(o=1;o<e;o++)n[e-o-1]-=i[e-o]*n[e-o];return n}function Fi(t){for(var e=[],n=arguments.length,i=1;i<n;i++)e.push(arguments[i]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(n=e.length,i=0;i<n;i++){var o,s,a=e[i];for(s in a)a.hasOwnProperty(s)&&(delete r[s],o=Object.getOwnPropertyDescriptor(a,s),Object.defineProperty(r,s,o))}return r}v.throughPoints=function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var e=(t=>{var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=Ri(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=Ri(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]})(t),n=[],i=e[0].length,r=0;r<i;r++){var o=new A(e[0][r].x,e[0][r].y),s=new A(e[1][r].x,e[1][r].y);n.push(new v(t[r],o,s,t[r+1]))}return n},v.prototype={type:d.Curve,bbox:function(){for(var t,e,n,i,r,o=this.start,s=this.controlPoint1,a=this.controlPoint2,l=this.end,h=o.x,u=o.y,c=s.x,d=s.y,f=a.x,p=a.y,g=l.x,m=l.y,v=new Array,y=new Array,b=[new Array,new Array],x=0;x<2;++x)i=0===x?(e=6*h-12*c+6*f,t=-3*h+9*c-9*f+3*g,3*c-3*h):(e=6*u-12*d+6*p,t=-3*u+9*d-9*p+3*m,3*d-3*u),Ci(t)<1e-12?Ci(e)<1e-12||0<(n=-i/e)&&n<1&&y.push(n):(i=e*e-4*i*t,r=Mi(i),i<0||(0<(i=(-e+r)/(2*t))&&i<1&&y.push(i),0<(i=(-e-r)/(2*t))&&i<1&&y.push(i)));for(var w,A,P=y.length,o=P;P--;)n=y[P],b[0][P]=w=(A=1-n)*A*A*h+3*A*A*n*c+3*A*n*n*f+n*n*n*g,b[1][P]=A=A*A*A*u+3*A*A*n*d+3*A*n*n*p+n*n*n*m,v[P]={X:w,Y:A};y[o]=0,y[o+1]=1,v[o]={X:h,Y:u},v[o+1]={X:g,Y:m},b[0][o]=h,b[1][o]=u,b[0][o+1]=g,b[1][o+1]=m,y.length=o+2,b[0].length=o+2,b[1].length=o+2,v.length=o+2;s=_i.apply(null,b[0]),a=_i.apply(null,b[1]),l=Ni.apply(null,b[0]),o=Ni.apply(null,b[1]);return new tt(s,a,l-s,o-a)},clone:function(){return new v(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,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions};return this.lengthAtT(this.closestPointT(t,n),n)},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.closestPointLength(t,n);return!e||0===(t=this.length(n))?0:e/t},closestPointT:function(t,e){for(var n,i,r,o,s,a,l=void 0===(e=e||{}).precision?this.PRECISION:e.precision,h=void 0===e.subdivisions?this.getSubdivisions({precision:l}):e.subdivisions,u=h.length,c=u?1/u:0,d=0;d<u;d++){var f=h[d],p=f.start.distance(t),g=f.end.distance(t),m=p+g;(!a||m<a)&&(i=d*c,r=(d+1)*c,o=p,E=g,s=(n=f).start.distance(f.end),a=m)}for(var v=Oi(10,-l);;){var y=o?Ci(o-E)/o:0,b=E?Ci(o-E)/E:0;if(y<v||b<v||(!o||o<s*v||(!E||E<s*v)))return o<=E?i:r;var y=n.divide(.5),b=(c/=2,y[0].start.distance(t)),x=y[0].end.distance(t),w=b+x,A=y[1].start.distance(t),P=y[1].end.distance(t),E=w<=A+P?(n=y[0],r-=c,o=b,x):(n=y[1],i+=c,o=A,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){return t<=0?this.divideAtT(0):1<=t?this.divideAtT(1):(t=this.tAt(t,e),this.divideAtT(t))},divideAtLength:function(t,e){t=this.tAtLength(t,e);return this.divideAtT(t)},divideAtT:function(t){var e,n,i=this.start,r=this.controlPoint1,o=this.controlPoint2,s=this.end;return t<=0?[new v(i,i,i,i),new v(i,r,o,s)]:1<=t?[new v(i,r,o,s),new v(s,s,s,s)]:(o=(r=this.getSkeletonPoints(t)).startControlPoint1,t=r.startControlPoint2,e=r.divider,n=r.dividerControlPoint1,r=r.dividerControlPoint2,[new v(i,o,t,e),new v(e,n,r,s)])},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;return t<=0?{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:i.clone()}:1<=t?{startControlPoint1:n.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()}:(e=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),i=new P(i,r).pointAt(t),r=new P(e,n).pointAt(t),n=new P(n,i).pointAt(t),{startControlPoint1:e,startControlPoint2:r,divider:new P(r,n).pointAt(t),dividerControlPoint1:n,dividerControlPoint2:i})},getSubdivisions:function(t){var t=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=this.start,n=this.controlPoint1,i=this.controlPoint2,r=this.end,o=[new v(e,n,i,r)];if(0===t)return o;if(!this.isDifferentiable())return o;for(var s=this.endpointDistance(),a=Oi(10,-t),l=2,h=(0===n.cross(e,r)&&0===i.cross(e,r)&&(l=2*t),0);;){h+=1;for(var u=[],c=o.length,d=0;d<c;d++){var f=o[d].divide(.5);u.push(f[0],f[1])}for(var p=0,g=u.length,m=0;m<g;m++)p+=u[m].endpointDistance();if(l<=h)if((0!==p?(p-s)/p:0)<a)return u;o=u,s=p}},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){return t<=0?0:(e=void 0===(e=e||{}).precision?this.PRECISION:e.precision,this.divide(t)[0].length({precision:e}))},pointAt:function(t,e){return t<=0?this.start.clone():1<=t?this.end.clone():(t=this.tAt(t,e),this.pointAtT(t))},pointAtLength:function(t,e){t=this.tAtLength(t,e);return this.pointAtT(t)},pointAtT:function(t){return t<=0?this.start.clone():1<=t?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:1<t&&(t=1);t=this.tAt(t,e);return this.tangentAtT(t)},tangentAtLength:function(t,e){return this.isDifferentiable()?(t=this.tAtLength(t,e),this.tangentAtT(t)):null},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var t=this.getSkeletonPoints(t),e=t.startControlPoint2,n=t.dividerControlPoint1,t=t.divider,n=new P(e,n);return n.translate(t.x-e.x,t.y-e.y),n},tAt:function(t,e){var n;return t<=0?0:1<=t?1:(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,subdivisions:void 0===e.subdivisions?this.getSubdivisions({precision:n}):e.subdivisions},e=this.length(n),this.tAtLength(e*t,n))},tAtLength:function(t,e){for(var n,i,r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.subdivisions?this.getSubdivisions({precision:s}):e.subdivisions,e={precision:s,subdivisions:a},l=0,h=a.length,u=1/h,c=0;c<h;c++){var d=o?c:h-1-c,f=a[c],p=f.endpointDistance();if(t<=l+p){n=f,i=d*u,r=(d+1)*u,w=o?t-l:p+l-t,A=o?p+l-t:t-l;break}l+=p}if(!n)return o?1:0;for(var g=this.length(e),m=Oi(10,-s);;){var v,y=0!==g?w/g:0;if(y<m)return i;if((0!==g?A/g:0)<m)return r;var y=n.divide(.5),b=(u/=2,y[0].endpointDistance()),x=y[1].endpointDistance(),y=w<=b?(n=y[0],r-=u,b-(v=w)):(n=y[1],i+=u,x-(v=w-b)),w=v,A=y}},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 x(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}},v.prototype.divide=v.prototype.divideAtT;let V=function(t){if(!(this instanceof V))return new V(t);if("string"==typeof t)return new V.parse(t);var e;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(e=(t=t.reduce(function(t,e){return t.concat(e)},[])).length,t[0].isSegment)for(r=0;r<e;r++){var n=t[r];this.appendSegment(n)}else for(var i=null,r=0;r<e;r++){var o=t[r];if(!(o instanceof P||o instanceof v))throw new Error("Cannot construct a path segment from the provided object.");0===r&&this.appendSegment(V.createSegment("M",o.start)),i&&!i.end.equals(o.start)&&this.appendSegment(V.createSegment("M",o.start)),o instanceof P?this.appendSegment(V.createSegment("L",o.end)):o instanceof v&&this.appendSegment(V.createSegment("C",o.controlPoint1,o.controlPoint2,o.end)),i=o}else if(t.isSegment)this.appendSegment(t);else if(t instanceof P)this.appendSegment(V.createSegment("M",t.start)),this.appendSegment(V.createSegment("L",t.end));else if(t instanceof v)this.appendSegment(V.createSegment("M",t.start)),this.appendSegment(V.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof x))throw new Error("Cannot construct a path from the provided object.");if(t.points&&0!==t.points.length)for(e=t.points.length,r=0;r<e;r++){var s=t.points[r];0===r?this.appendSegment(V.createSegment("M",s)):this.appendSegment(V.createSegment("L",s))}}};function Ii(t,e){return e.unshift(null),new(Function.prototype.bind.apply(t,e))}V.parse=function(t){if(!t)return new V;for(var e=new V,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),o=V.createSegment.apply(this,o);e.appendSegment(o)}return e},V.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var e=V.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 Ii(e,n)},V.prototype={type:d.Path,appendSegment:function(t){var e=this.segments,n=e.length,i=0!==n?e[n-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 r=t.length,o=0;o<r;o++){var s=t[o],a=this.prepareSegment(s,i,null);e.push(a),i=a}}else{if(!t||!t.isSegment)throw new Error("Segment required.");a=this.prepareSegment(t,i,null),e.push(a)}},bbox:function(){var t=this.segments,e=t.length;if(0===e)return null;for(var n,i=0;i<e;i++){var r,o=t[i];o.isVisible&&(o=o.bbox(),r=r?r.union(o):o)}return r||(n=t[e-1],new tt(n.end.x,n.end.y,0,0))},clone:function(){for(var t=this.segments,e=t.length,n=new V,i=0;i<e;i++){var r=t[i].clone();n.appendSegment(r)}return n},closestPoint:function(t,e){t=this.closestPointT(t,e);return t?this.pointAtT(t):null},closestPointLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointT(t,n);return e?this.lengthAtT(e,n):0},closestPointNormalizedLength:function(t,e){var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.closestPointLength(t,n);return 0===e||0===(t=this.length(n))?0:e/t},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 h=n[l],u=s[l];h.isVisible&&(u=h.closestPointT(t,{precision:o,subdivisions:u}),h=h.pointAtT(u),(h=new P(h,t).squaredLength())<a)&&(r={segmentIndex:l,value:u},a=h)}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 h,u=n[l],c=s[l];u.isDifferentiable()&&(c=u.closestPointT(t,{precision:o,subdivisions:c}),h=u.pointAtT(c),(h=new P(h,t).squaredLength())<a)&&(r=u.tangentAtT(c),a=h)}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;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.divideAtLength(e*t,n)},divideAtLength:function(t,e){var n=this.segments.length;if(0===n)return null;for(var i,r,o,s,a=!0,l=(t<0&&(a=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),h=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:l}):e.segmentSubdivisions,u=0,c=0;c<n;c++){var d=a?c:n-1-c,f=this.getSegment(d),p=h[d],g=f.length({precision:l,subdivisions:p});if(f.isDifferentiable()&&(o=f,s=d,t<=u+g)){r=d,i=f.divideAtLength((a?1:-1)*(t-u),{precision:l,subdivisions:p});break}u+=g}if(!o)return null;i||(r=s,i=o.divideAtT(a?1:0));var m=this.clone(),e=(m.replaceSegment(r,i),r),v=r+1,y=r+2,b=(i[0].isDifferentiable()||(m.removeSegment(e),--v,--y),m.getSegment(v).start),x=(m.insertSegment(v,V.createSegment("M",b)),y+=1,i[1].isDifferentiable()||(m.removeSegment(y-1),--y),y-e-1);for(c=y;c<m.segments.length;c++){var w=this.getSegment(c-x);"Z"!==(f=m.getSegment(c)).type||w.subpathStartSegment.end.equals(f.subpathStartSegment.end)||(w=V.createSegment("L",w.end),m.replaceSegment(c,w))}return[new V(m.segments.slice(0,v)),new V(m.segments.slice(v))]},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(n<=(t=t<0?n+t:t)||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(){var e=this.clone().validate().segments,n=e.length,i=[];for(let t=0;t<n;t++){var r=e[t];r.isSubpathStart?i.push(new V(r)):i[i.length-1].appendSegment(r)}return i},insertSegment:function(t,e){var n=this.segments,i=n.length;if(i<(t=t<0?i+t+1:t)||t<0)throw new Error("Index out of range.");var r=null,o=null;if(0!==i&&(o=1<=t?(r=n[t-1]).nextSegment:n[0]),Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");for(var s=e.length,a=0;a<s;a++){var l=e[a],h=this.prepareSegment(l,r,o);n.splice(t+a,0,h),r=h}}else{if(!e||!e.isSegment)throw new Error("Segment required.");h=this.prepareSegment(e,r,o),n.splice(t,0,h)}},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],s=t.intersect(s);s&&(n=n||[],Array.isArray(s)?Array.prototype.push.apply(n,s):n.push(s))}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;for(var t=t.value,o=(i<=r?(r=i-1,t=1):t<0?t=0:1<t&&(t=1),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=0,l=0;l<r;l++){var h=n[l],u=s[l];a+=h.length({precisison:o,subdivisions:u})}return u=s[r],a+=(h=n[r]).lengthAtT(t,{precisison:o,subdivisions:u})},pointAt:function(t,e){var n;return 0===this.segments.length?null:t<=0?this.start.clone():1<=t?this.end.clone():(n={precision:n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n),this.pointAtLength(e*t,n))},pointAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;if(0===t)return this.start.clone();for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<i;h++){var u=o?h:i-1-h,c=n[u],u=a[u],d=c.length({precision:s,subdivisions:u});if(c.isVisible){if(t<=l+d)return c.pointAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:u});r=c}l+=d}return r?o?r.end:r.start:n[i-1].end.clone()},pointAtT:function(t){var e,n=this.segments,i=n.length;return 0===i?null:(e=t.segmentIndex)<0?n[0].pointAtT(0):i<=e?n[i-1].pointAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),n[e].pointAtT(i))},PRECISION:3,prepareSegment:function(t,e,n){t.previousSegment=e,t.nextSegment=n,e&&(e.nextSegment=t),n&&(n.previousSegment=t);e=t;return t.isSubpathStart&&(t.subpathStartSegment=t,e=n),e&&this.updateSubpathStartSegment(e),t},removeSegment:function(t){var e=this.segments,n=e.length;if(0===n)throw new Error("Path has no segments.");if(n<=(t=t<0?n+t:t)||t<0)throw new Error("Index out of range.");n=e.splice(t,1)[0],e=n.previousSegment,t=n.nextSegment;e&&(e.nextSegment=t),t&&(t.previousSegment=e),n.isSubpathStart&&t&&this.updateSubpathStartSegment(t)},replaceSegment:function(t,e){var n=this.segments,i=n.length;if(0===i)throw new Error("Path has no segments.");if(i<=(t=t<0?i+t:t)||t<0)throw new Error("Index out of range.");var i=n[t],r=i.previousSegment,o=i.nextSegment,s=i.isSubpathStart;if(Array.isArray(e)){if(!(e=e.reduce(function(t,e){return t.concat(e)},[]))[0].isSegment)throw new Error("Segments required.");n.splice(t,1);for(var a=e.length,l=0;l<a;l++){var h=e[l],u=this.prepareSegment(h,r,o);n.splice(t+l,0,u),r=u,s&&u.isSubpathStart&&(s=!1)}}else{if(!e||!e.isSegment)throw new Error("Segment required.");u=this.prepareSegment(e,r,o),n.splice(t,1,u),s&&u.isSubpathStart&&(s=!1)}s&&o&&this.updateSubpathStartSegment(o)},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){t=this.segmentIndexAt(t,e);return t?this.getSegment(t):null},segmentAtLength:function(t,e){t=this.segmentIndexAtLength(t,e);return t?this.getSegment(t):null},segmentIndexAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.segmentIndexAtLength(e*t,n)},segmentIndexAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r=!0,o=(t<0&&(r=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),s=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):e.segmentSubdivisions,a=null,l=0,h=0;h<i;h++){var u=r?h:i-1-h,c=n[u],d=s[u],d=c.length({precision:o,subdivisions:d});if(c.isVisible){if(t<=l+d)return u;a=u}l+=d}return a},serialize:function(){if(this.isValid())return this.toString();throw new Error("Invalid path segments.")},tangentAt:function(t,e){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var n=void 0===(e=e||{}).precision?this.PRECISION:e.precision,n={precision:n,segmentSubdivisions:void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:n}):e.segmentSubdivisions},e=this.length(n);return this.tangentAtLength(e*t,n)},tangentAtLength:function(t,e){var n=this.segments,i=n.length;if(0===i)return null;for(var r,o=!0,s=(t<0&&(o=!1,t=-t),void 0===(e=e||{}).precision?this.PRECISION:e.precision),a=void 0===e.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):e.segmentSubdivisions,l=0,h=0;h<i;h++){var u=o?h:i-1-h,c=n[u],u=a[u],d=c.length({precision:s,subdivisions:u});if(c.isDifferentiable()){if(t<=l+d)return c.tangentAtLength((o?1:-1)*(t-l),{precision:s,subdivisions:u});r=c}l+=d}return r?r.tangentAtT(o?1:0):null},tangentAtT:function(t){var e,n=this.segments,i=n.length;return 0===i?null:(e=t.segmentIndex)<0?n[0].tangentAtT(0):i<=e?n[i-1].tangentAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),n[e].tangentAtT(i))},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,h=e[a];h.isVisible?0<(l=r[a]).length?(l=l.map(function(t){return t.start}),Array.prototype.push.apply(s,l)):s.push(h.start):0<s.length&&(s.push(e[a-1].end),o.push(s),s=[])}return 0<s.length&&(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 x(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,t=(e=t).nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,V.createSegment("M",0,0)),this}},Object.defineProperty(V.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(V.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;0<=n;n--){var i=t[n];if(i.isVisible)return i.end}return t[e-1].end}});function Vi(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof Vi))return Ii(Vi,t);if(0===e)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(t[0]instanceof P){if(1===e)return this.end=t[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+e+" lines provided).")}if("string"==typeof t[0]||"number"==typeof t[0]){if(2===e)return this.end=new A(+t[0],+t[1]),this;if(e<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+e+" coordinates provided).");for(var i,r=[],n=0;n<e;n+=2)i=t.slice(n,n+2),r.push(Ii(Vi,i))}else{if(1===e)return this.end=new A(t[0]),this;for(r=[],n=0;n<e;n+=1)r.push(new Vi(t[n]))}return r}function Bi(){for(var t,e=[],n=arguments.length,i=0;i<n;i++)e.push(arguments[i]);if(!(this instanceof Bi))return Ii(Bi,e);if(0===n)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(e[0]instanceof v){if(1===n)return this.controlPoint1=e[0].controlPoint1.clone(),this.controlPoint2=e[0].controlPoint2.clone(),this.end=e[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" curves provided).")}if("string"==typeof e[0]||"number"==typeof e[0]){if(6===n)return this.controlPoint1=new A(+e[0],+e[1]),this.controlPoint2=new A(+e[2],+e[3]),this.end=new A(+e[4],+e[5]),this;if(n<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" coordinates provided).");for(var r,o=[],i=0;i<n;i+=6)r=e.slice(i,i+6),o.push(Ii(Bi,r))}else{if(3===n)return this.controlPoint1=new A(e[0]),this.controlPoint2=new A(e[1]),this.end=new A(e[2]),this;if(n<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+n+" points provided).");for(o=[],i=0;i<n;i+=3)t=e.slice(i,i+3),o.push(Ii(Bi,t))}return o}function Di(){for(var t,e=[],n=arguments.length,i=0;i<n;i++)e.push(arguments[i]);if(!(this instanceof Di))return Ii(Di,e);if(0===n)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(e[0]instanceof P){if(1===n)return this.end=e[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" lines provided).")}if(e[0]instanceof v){if(1===n)return this.end=e[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" curves provided).")}if("string"==typeof e[0]||"number"==typeof e[0]){if(2===n)return this.end=new A(+e[0],+e[1]),this;if(n<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+n+" coordinates provided).");for(var r,o=[],i=0;i<n;i+=2)r=e.slice(i,i+2),0===i?o.push(Ii(Di,r)):o.push(Ii(Vi,r))}else{if(1===n)return this.end=new A(e[0]),this;for(o=[],i=0;i<n;i+=1)t=e[i],0===i?o.push(new Di(t)):o.push(new Vi(t))}return o}function zi(){for(var t=[],e=arguments.length,n=0;n<e;n++)t.push(arguments[n]);if(!(this instanceof zi))return Ii(zi,t);if(0<e)throw new Error("Closepath constructor expects no arguments.");return this}hn={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){var e;return t<=0?0:(e=this.length(),1<=t?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(hn,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(hn,"start",{configurable:!0,enumerable:!0,get:function(){if(this.previousSegment)return this.previousSegment.end;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.)")}}),Object.defineProperty(hn,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}}),sn={clone:function(){return new Vi(this.end)},divideAt:function(t){t=new P(this.start,this.end).divideAt(t);return[new Vi(t[0]),new Vi(t[1])]},divideAtLength:function(t){t=new P(this.start,this.end).divideAtLength(t);return[new Vi(t[0]),new Vi(t[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(sn,"type",{configurable:!0,enumerable:!0,value:"L"}),Vi.prototype=Fi(hn,P.prototype,sn),n={clone:function(){return new Bi(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,e){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,e);return[new Bi(t[0]),new Bi(t[1])]},divideAtLength:function(t,e){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,e);return[new Bi(t[0]),new Bi(t[1])]},divideAtT:function(t){t=new v(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new Bi(t[0]),new Bi(t[1])]},isDifferentiable:function(){var t,e,n,i;return!(!this.previousSegment||(t=this.start,e=this.controlPoint1,n=this.controlPoint2,i=this.end,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(n,"type",{configurable:!0,enumerable:!0,value:"C"}),Bi.prototype=Fi(hn,v.prototype,n),o={bbox:function(){return null},clone:function(){return new Di(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(o,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(o,"type",{configurable:!0,enumerable:!0,value:"M"}),Di.prototype=Fi(hn,o),Ln={clone:function(){return new zi},divideAt:function(t){t=new P(this.start,this.end).divideAt(t);return[t[1].isDifferentiable()?new Vi(t[0]):this.clone(),new Vi(t[1])]},divideAtLength:function(t){t=new P(this.start,this.end).divideAtLength(t);return[t[1].isDifferentiable()?new Vi(t[0]):this.clone(),new Vi(t[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(Ln,"end",{configurable:!0,enumerable:!0,get:function(){if(this.subpathStartSegment)return this.subpathStartSegment.end;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.)")}}),Object.defineProperty(Ln,"type",{configurable:!0,enumerable:!0,value:"Z"}),zi.prototype=Fi(hn,P.prototype,Ln),Je=V.segmentTypes={L:Vi,C:Bi,M:Di,Z:zi,z:zi},V.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(Je).join("")+",.]*$"),V.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)},e={curveThroughPoints:function(t){return console.warn("deprecated"),new V(v.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var e=[],n=[],i=t.length-1;if(1==i)e[0]=new A((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),n[0]=new A(2*e[0].x-t[0].x,2*e[0].y-t[0].y);else{for(var r=[],o=1;o<i-1;o++)r[o]=4*t[o].x+2*t[o+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var s=this.getFirstControlPoints(r);for(o=1;o<i-1;++o)r[o]=4*t[o].y+2*t[o+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var a=this.getFirstControlPoints(r);for(o=0;o<i;o++)e.push(new A(s[o],a[o])),n.push(o<i-1?new A(2*t[o+1].x-s[o+1],2*t[o+1].y-a[o+1]):new A((t[i].x+s[i-1])/2,(t[i].y+a[i-1])/2))}return[e,n]},getCurveDivider:function(t,e,n,i){console.warn("deprecated");var r=new v(t,e,n,i);return function(t){t=r.divide(t);return[{p0:t[0].start,p1:t[0].controlPoint1,p2:t[0].controlPoint2,p3:t[0].end},{p0:t[1].start,p1:t[1].controlPoint1,p2:t[1].controlPoint2,p3:t[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,n[o]=(t[o]-n[o-1])/(r=(o<e-1?4:3.5)-i[o]);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 v(t,e,n,i);return function(t){return r.closestPointT(t)}}};let ji=function(t){return this instanceof ji?"string"==typeof t?new ji.parse(t):void(this.points=Array.isArray(t)?t.map(A):[]):new ji(t)};function Gi(t,e){var n=t.start.x,i=t.start.y,r=t.end.x,t=t.end.y,o=e.start.x,s=e.start.y,r=r-n,t=t-i,a=e.end.x-o,e=e.end.y-s,n=n-o,o=i-s,i=r*e-a*t,s=(r*o-t*n)/i,r=(a*o-e*n)/i;return 0<=s&&s<=1&&0<=r&&r<=1}function Ui(t,e){var n=t.a,i=t.b,r=t.x,t=t.y,o=e.start.x-r,r=e.end.x-r,s=e.start.y-t,n=n*n,i=i*i,r=r-o,e=e.end.y-t-s,t=r*r/n+e*e/i,r=2*o*r/n+2*s*e/i,e=r*r-4*t*(o*o/n+s*s/i-1);return 0==e?0<=(o=-r/2/t)&&o<=1:0<e&&(s=(-r-(n=Math.sqrt(e)))/2/t,0<=(i=(-r+n)/2/t)&&i<=1||0<=s&&s<=1)}function Hi(L,C){{var M=0,_=0;let{cos:t,sin:e}=Math,n=e(M),i=t(M),r=e(_),o=t(_),s=n*n,a=i*i,l=n*i,h=r*r,u=o*o,c=r*o,d=L.a*L.a,f=L.b*L.b,p=C.a*C.a,g=C.b*C.b,m=d*s+f*a,v=p*h+g*u,y=d*a+f*s,b=p*u+g*h,x=2*(f-d)*l,w=2*(g-p)*c,A=-2*m*L.x-x*L.y,P=-2*v*C.x-w*C.y,E=-x*L.x-2*y*L.y,T=-w*C.x-2*b*C.y,S=m*L.x*L.x+y*L.y*L.y+x*L.x*L.y-d*f,k=v*C.x*C.x+b*C.y*C.y+w*C.x*C.y-p*g;x/=2,w/=2,A/=2,P/=2,E/=2,T/=2;var M=mr([[m,x,A],[x,y,E],[A,E,S]]),_=mr([[v,w,P],[w,b,T],[P,T,k]]),L=.33333333*(mr([[v,x,A],[w,y,E],[P,E,S]])+mr([[m,w,A],[x,b,E],[A,T,S]])+mr([[m,x,P],[x,y,T],[A,E,k]])),C=.33333333*(mr([[m,w,P],[x,b,T],[A,T,k]])+mr([[v,x,P],[w,y,T],[P,E,k]])+mr([[v,w,A],[w,b,E],[P,T,S]])),N=gr([[M,L],[L,C]]),M=gr([[M,C],[L,_]]),_=gr([[L,C],[C,_]]);return!(0<(N=gr([[2*N,M],[M,2*_]]))&&(0<C||0<L))}}function qi(t,e){var{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))||Gi(t.topLine(),e)||Gi(t.rightLine(),e)||Gi(t.bottomLine(),e)||Gi(t.leftLine(),e))}function $i(t,e){return!!Wi(t,tt.fromEllipse(e))&&Qi(ji.fromRect(t),e)}function Wi(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 Yi(t,e){return hr(t,e,{interior:!1})}function Xi(t,e){return ur(t,e,{interior:!1})}function Zi(t,e){return cr(t,e,{interior:!1})}function Ji(t,e){return fr(t,e,{interior:!1})}function Ki(t,e){return hr(t,e,{interior:!0})}function Qi(t,e){return ur(t,e,{interior:!0})}function tr(t,e){return cr(t,e,{interior:!0})}function er(t,e){return fr(t,e,{interior:!0})}function nr(t,e){return pr(t,e,{interior:!0})}function ir(t,n,i){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Ki:Yi)(e,n)})}function rr(t,n,i){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Qi:Xi)(e,n)})}function or(t,e,n){return ar(t,ji.fromRect(e),n)}function sr(t,e,n){return dr(t,e,n,{interior:!1})}function ar(t,e,n){return dr(t,e,n,{interior:!0})}function lr(t,n,i,r){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?ar:sr)(n,e,r)})}function hr(t,e,n){var{interior:n=!1}=2<arguments.length&&void 0!==n?n:{};let i;if(n){if(t.containsPoint(e.start))return!0;var{start:n,end:r,points:o}=t;i=r.equals(n)?o:[...o,n]}else i=t.points;var s=i.length,a=new P;for(let t=0;t<s-1;t++)if(a.start=i[t],a.end=i[t+1],Gi(e,a))return!0;return!1}function ur(t,e,n){var n=2<arguments.length&&void 0!==n?n:{},{start:i,end:r,points:o}=t;if(e.containsPoint(i))return!0;let s;var{interior:n=!1}=n;if(n){if(t.containsPoint(e.center()))return!0;s=r.equals(i)?o:[...o,i]}else s=o;var a=s.length,l=new P;for(let t=0;t<a-1;t++)if(l.start=s[t],l.end=s[t+1],Ui(e,l))return!0;return!1}function cr(t,e,n){return pr(t,ji.fromRect(e),n)}function dr(t,n,i,r){return t.getSubpaths().some(t=>{var[e]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?pr:fr)(n,e,r)})}function fr(t,e,n){var{interior:n=!1}=2<arguments.length&&void 0!==n?n:{};let i;if(n){n=e.start;if(t.containsPoint(n))return!0;i=t.clone().close()}else i=t;var r=e.points,o=r.length,s=new P;for(let t=0;t<o-1;t++)if(s.start=r[t],s.end=r[t+1],Yi(i,s))return!0;return!1}function pr(t,e,n){return e.containsPoint(t.start)||fr(t,e.clone().close(),n)}function gr(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function mr(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]}ji.parse=function(t){return new ji(Si(t))},ji.fromRect=function(t){return new ji([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},ji.prototype=Fi(x.prototype,{type:d.Polygon,clone:function(){return new ji(ki(this.points))},convexHull:function(){return new ji(Li(this.points))},lengthPoints:function(){var{start:t,end:e,points:n}=this;return n.length<=1||t.equals(e)?n:[...n,t.clone()]}});let vr={exists:function t(e,n,i,r){switch(e.type){case d.Line:if(n.type===d.Line)return Gi(e,n);break;case d.Ellipse:switch(n.type){case d.Line:return Ui(e,n);case d.Ellipse:return Hi(e,n)}break;case d.Rect:switch(n.type){case d.Line:return qi(e,n);case d.Ellipse:return $i(e,n);case d.Rect:return Wi(e,n)}break;case d.Polyline:switch(n.type){case d.Line:return Yi(e,n);case d.Ellipse:return Xi(e,n);case d.Rect:return Zi(e,n);case d.Polyline:return Ji(e,n)}break;case d.Polygon:switch(n.type){case d.Line:return Ki(e,n);case d.Ellipse:return Qi(e,n);case d.Rect:return tr(e,n);case d.Polyline:return er(e,n);case d.Polygon:return nr(e,n)}break;case d.Path:switch(n.type){case d.Line:return ir(e,n,i);case d.Ellipse:return rr(e,n,i);case d.Rect:return or(e,n,i);case d.Polyline:return sr(e,n,i);case d.Polygon:return ar(e,n,i);case d.Path:return lr(e,n,i,r)}}switch(n.type){case d.Ellipse:case d.Rect:case d.Polyline:case d.Polygon:case d.Path:return t(n,e,r,i);default:throw Error(`The intersection for ${e} and ${n} could not be found.`)}},lineWithLine:Gi,ellipseWithLine:Ui,ellipseWithEllipse:Hi,rectWithLine:qi,rectWithEllipse:$i,rectWithRect:Wi,polylineWithLine:Yi,polylineWithEllipse:Xi,polylineWithRect:Zi,polylineWithPolyline:Ji,polygonWithLine:Ki,polygonWithEllipse:Qi,polygonWithRect:tr,polygonWithPolyline:er,polygonWithPolygon:nr,pathWithLine:ir,pathWithEllipse:rr,pathWithRect:or,pathWithPolyline:sr,pathWithPolygon:ar,pathWithPath:lr},yr=vr;var br={intersection:yr,scale:{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}},normalizeAngle:Xn,snapToGrid:Zn,toDeg:Hn,toRad:Jn,random:qn,bezier:e,Curve:v,Ellipse:yi,ellipse:l,Line:P,line:pi,Path:V,Point:A,point:ci,Polyline:x,Polygon:ji,Rect:tt,rect:h,types:d};let xr="[object Arguments]",wr="[object Array]",Ar="[object Boolean]",Pr="[object Date]",Er="[object Error]";let Tr="[object Map]",Sr="[object Number]",kr="[object Null]",Lr="[object Object]",Cr="[object RegExp]",Mr="[object Set]",_r="[object String]",Nr="[object Symbol]",Or="[object Undefined]";let Rr="[object ArrayBuffer]",Fr="[object DataView]",Ir="[object Float32Array]",Vr="[object Float64Array]",Br="[object Int8Array]",Dr="[object Int16Array]",zr="[object Int32Array]",jr="[object Uint8Array]",Gr="[object Uint8ClampedArray]",Ur="[object Uint16Array]",Hr="[object Uint32Array]",qr={[xr]:!0,[wr]:!0,[Rr]:!0,[Fr]:!0,[Ar]:!0,[Pr]:!0,[Ir]:!0,[Vr]:!0,[Br]:!0,[Dr]:!0,[zr]:!0,[Tr]:!0,[Sr]:!0,[Lr]:!0,[Cr]:!0,[Mr]:!0,[_r]:!0,[Nr]:!0,[jr]:!0,[Gr]:!0,[Ur]:!0,[Hr]:!0,[Er]:!1,"[object Function]":!1,"[object WeakMap]":!1};r="\\ud800-\\udfff",u="\\u2700-\\u27bf",i="a-z\\xdf-\\xf6\\xf8-\\xff",s="A-Z\\xc0-\\xd6\\xd8-\\xde",$e="\\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",c=`[${$e}]`,a="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]",sn=`[${u}]`,n=`[${i}]`,o=`[^${r}${$e+"\\d"+u+i+s}]`,hn="\\ud83c[\\udffb-\\udfff]",Ln=`[^${r}]`,Je="(?:\\ud83c[\\udde6-\\uddff]){2}",e="[\\ud800-\\udbff][\\udc00-\\udfff]",l=`[${s}]`,h=`(?:${n}|${o})`,$e=`(?:${l}|${o})`,u="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",i="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",s="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]|\\ud83c[\\udffb-\\udfff])?",o="[\\ufe0e\\ufe0f]?",o=o+s+`(?:\\u200d(?:${[Ln,Je,e].join("|")})${o+s})*`,s=`(?:${[sn,Je,e].join("|")})`+o;let $r=RegExp([`${l}?${n}+${u}(?=${[c,l,"$"].join("|")})`,$e+`+${i}(?=${[c,l+h,"$"].join("|")})`,l+`?${h}+`+u,l+"+"+i,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",s].join("|"),"g"),Wr=200,Yr="__hash_undefined__",Xr=/^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)Array\]$/;var Zr,sn=`(?:${[Ln+a+"?",a,Je,e,`[${r}]`].join("|")})`;let Jr=RegExp(hn+`(?=${hn})|`+sn+o,"g"),Kr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qr=/^\w*$/,to=".".charCodeAt(0),eo=/\\(\\)?/g,no=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),io=/^(?:0|[1-9]\d*)$/,ro=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 ]/),oo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,so=t=>Jr.test(t),ao=t=>t.match(Jr)||[],lo=t=>t.split(""),ho=t=>(so(t)?ao:lo)(t),uo=e=>null==e?[]:co(e).map(t=>e[t]),co=t=>Po(t)?fo(t):Object.keys(Object(t)),fo=(t,e)=>{var n,i=Array.isArray(t),r=!i&&mo(t)&&ko(t)===xr,o=!i&&!r&&Fo(t),s=i||r||o,a=t.length,l=new Array(s?a:0);let h=s?-1:a;for(;++h<a;)l[h]=""+h;for(n in t)!e&&!hasOwnProperty.call(t,n)||s&&("length"===n||as(n,a))||l.push(n);return l},po=(t,e)=>{let n=t.length;for(;n--;)if(go(t[n][0],e))return n;return-1},go=(t,e)=>t===e||t!=t&&e!=e,mo=t=>null!=t&&"object"==typeof t,vo=(t,e,n)=>{var i;return!!w(n)&&!!("number"==(i=typeof e)?Po(n)&&-1<e&&e<n.length:"string"==i&&e in n)&&go(n[e],t)},yo=t=>mo(t)&&ko(t)==Mr,bo=t=>mo(t)&&ko(t)==Tr,xo=t=>{var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Object.prototype)},wo=(t,e,n)=>{var i=t[e];hasOwnProperty.call(t,e)&&go(i,n)&&(void 0!==n||e in t)||(t[e]=n)},Ao=(t,e,n)=>{let i=-1;for(var r=e.length;++i<r;){var o=e[i];wo(n,o,t[o])}return n},Po=t=>null!=t&&"function"!=typeof t&&"number"==typeof t.length&&-1<t.length&&t.length%1==0,Eo=t=>"symbol"==typeof t||mo(t)&&ko(t)===Nr,To=t=>{var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&hasOwnProperty.call(t,"index")&&(n.index=t.index,n.input=t.input),n},So=(t,e)=>{let n=-1;var i=t.length;for(e=e||new Array(i);++n<i;)e[n]=t[n];return e},ko=t=>null==t?void 0===t?Or:kr:Object.prototype.toString.call(t),Lo=t=>{var e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e},Co=(t,e)=>{e=e?Lo(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)},Mo=t=>{var e=new t.constructor(t.source,/\w*$/.exec(t));return e.lastIndex=t.lastIndex,e},_o=t=>"function"!=typeof t.constructor||xo(t)?{}:Object.create(Object.getPrototypeOf(t)),No=e=>null==e?[]:(e=Object(e),Object.getOwnPropertySymbols(e).filter(t=>propertyIsEnumerable.call(e,t))),Oo=(t,e)=>Ao(t,No(t),e);let Ro=(t,e,n)=>{var i,r,o=t.constructor;switch(e){case Rr:return Lo(t);case Ar:case Pr:return new o(+t);case Fr:return i=t,r=(r=n)?Lo(i.buffer):i.buffer,new i.constructor(r,i.byteOffset,i.byteLength);case Ir:case Vr:case Br:case Dr:case zr:case jr:case Gr:case Ur:case Hr:return Co(t,n);case Tr:return new o(t);case Sr:case _r:return new o(t);case Cr:return Mo(t);case Mr:return new o;case Nr:return Symbol.prototype.valueOf?Object(Symbol.prototype.valueOf.call(t)):{}}},Fo=t=>mo(t)&&Xr.test(ko(t)),Io=t=>{var e=Object.keys(t);return Array.isArray(t)||null==t||e.push(...No(Object(t))),e},Vo=t=>{for(var e=[];t;)e.push(...No(t)),t=Object.getPrototypeOf(Object(t));return e},Bo=t=>{var e,n=[];for(e in t)n.push(e);return Array.isArray(t)||n.push(...Vo(t)),n},Do=(t,e)=>{t=t.__data__;return(t=>{const e=typeof t;return e==="string"||e==="number"||e==="symbol"||e==="boolean"?t!=="__proto__":t===null})(e)?t["string"==typeof e?"string":"hash"]:t.map},zo=(t,e,n,i)=>{var r=Io(t),o=r.length;if(o!=Io(e).length)return!1;let s,a=o;for(;a--;)if(s=r[a],!hasOwnProperty.call(e,s))return!1;var l=i.get(t),h=i.get(e);if(l&&h)return l==e&&h==t;let u=!0;i.set(t,e),i.set(e,t);let c;for(;++a<o;){var d=t[s=r[a]],f=e[s];if(d!==f&&!n(d,f,i)){u=!1;break}c=c||"constructor"==s}return u&&!c&&(l=t.constructor)!=(h=e.constructor)&&"constructor"in t&&"constructor"in e&&!("function"==typeof l&&l instanceof l&&"function"==typeof h&&h instanceof h)&&(u=!1),i.delete(t),i.delete(e),u},jo=(t,e,n)=>t===e||(null==t||null==e||!mo(t)&&!mo(e)?t!=t&&e!=e:Go(t,e,jo,n)),Go=(t,e,n,i)=>{var r=Array.isArray(t),o=Array.isArray(e),s=r?wr:ko(t),o=o?wr:ko(e),s=s==xr?Lr:s,o=o==xr?Lr:o,a=s==Lr,l=o==Lr,o=s==o;return o&&!a?(i=i||new Ds,r||Fo(t)?Uo(t,e,!1,n,i):Wo(t,e,s,n,i)):(r=a&&hasOwnProperty.call(t,"__wrapped__"),s=l&&hasOwnProperty.call(e,"__wrapped__"),r||s?n(r?t.value():t,s?e.value():e,i=i||new Ds):o&&(i=i||new Ds,zo(t,e,n,i)))},Uo=(t,e,n,i,r)=>{var o=t.length,s=e.length;if(o!=s)return!1;var s=r.get(t),a=r.get(e);if(s&&a)return s==e&&a==t;let l=-1,h=!0,u=n?new Us:void 0;for(r.set(t,e),r.set(e,t);++l<o;){let n=t[l];var c=e[l];if(u){if(!Ho(e,(t,e)=>{if(!qo(u,e)&&(n===t||i(n,t,r)))return u.push(e)})){h=!1;break}}else if(n!==c&&!i(n,c,r)){h=!1;break}}return r.delete(t),r.delete(e),h},Ho=(t,e)=>{let n=-1;for(var i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1},qo=(t,e)=>t.has(e),$o=(t,e,n,i)=>!(t.byteLength!=e.byteLength||!n(new Uint8Array(t),new Uint8Array(e),i)),Wo=(t,e,n,i,r)=>{switch(n){case Fr:return t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset?!1:(t=t.buffer,e=e.buffer,$o(t,e,i,r));case Rr:return $o(t,e,i,r);case Ar:case Pr:case Sr:return go(+t,+e);case Er:return t.name==e.name&&t.message==e.message;case Cr:case _r:return t==""+e;case Tr:var o=Yo;case Mr:if(o=o||Xo,t.size!=e.size)return!1;var s=r.get(t);if(s)return s==e;r.set(t,e);s=Uo(o(t),o(e),!0,i,r);return r.delete(t),s;case Nr:return Symbol.prototype.valueOf.call(t)==Symbol.prototype.valueOf.call(e)}return!1},Yo=t=>{let n=-1,i=Array(t.size);return t.forEach((t,e)=>{i[++n]=[e,t]}),i},Xo=t=>{let e=-1,n=new Array(t.size);return t.forEach(t=>{n[++e]=t}),n},Zo=(t,e)=>{var n;return!Array.isArray(t)&&(!("number"!=(n=typeof t)&&"boolean"!=n&&null!=t&&!Eo(t))||Qr.test(t)||!Kr.test(t)||null!=e&&t in Object(e))},Jo=t=>{let o=[];return t.charCodeAt(0)===to&&o.push(""),t.replace(no,(t,e,n,i)=>{let r=t;n?r=i.replace(eo,"$1"):e&&(r=e.trim()),o.push(r)}),o},Ko=(t,e)=>Array.isArray(t)?t:Zo(t,e)?[t]:Jo(""+t),Qo=(t,e)=>{let n=0;for(var i=(e=Ko(e,t)).length;null!=t&&n<i;)t=t[ns(e[n])],n++;return n&&n==i?t:void 0};function ts(t,e){if(t!==e){var n=void 0!==t,i=null===t,r=t==t,o=Eo(t),s=void 0!==e,a=null===e,l=e==e,h=Eo(e);if(!a&&!h&&!o&&e<t||o&&s&&l&&!a&&!h||i&&s&&l||!n&&l||!r)return 1;if(!i&&!o&&!h&&t<e||h&&n&&r&&!i&&!o||a&&n&&r||!s&&r||!l)return-1}return 0}let es=(t,e)=>{let n=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),i=!0;var r=[],o=e.length;if(t.length){e.length>=Wr&&(n=(t,e)=>t.has(e),i=!1,e=new Us(e));t:for(var s in t){var a=s=t[s],s=0!==s?s:0;if(i&&a==a){let t=o;for(;t--;)if(e[t]===a)continue t;r.push(s)}else n(e,a)||r.push(s)}}return r},ns=t=>{var e;return"string"==typeof t||Eo(t)?t:"0"==(e=""+t)&&1/t==-1/0?"-0":e},is=function(i){let r=1<arguments.length&&void 0!==arguments[1]&&arguments[1],o=2<arguments.length&&void 0!==arguments[2]&&arguments[2],s=!(3<arguments.length&&void 0!==arguments[3])||arguments[3],a=4<arguments.length?arguments[4]:void 0;var t=5<arguments.length?arguments[5]:void 0,e=6<arguments.length?arguments[6]:void 0;let l=7<arguments.length?arguments[7]:void 0,h;if(void 0===(h=a?e?a(i,t,e,l):a(i):h)){if(!w(i))return i;var t=Array.isArray(i),n=ko(i);if(t){if(h=To(i),!r)return So(i,h)}else{var u="function"==typeof i;if(n===Lr||n===xr||u&&!e){if(h=o||u?{}:_o(i),!r)return o?rs(i,Ao(i,Object.keys(i),h)):Oo(i,Object.assign(h,i))}else{if(u||!qr[n])return e?i:{};h=Ro(i,n,r)}}u=(l=l||new Ds).get(i);if(u)return u;if(l.set(i,h),bo(i))i.forEach((t,e)=>{h.set(e,is(t,r,o,s,a,e,i,l))});else if(yo(i))i.forEach(t=>{h.add(is(t,r,o,s,a,t,i,l))});else if(!Fo(i)){e=s?o?Bo:Io:o?ls:co;let n=t?void 0:e(i);(n||i).forEach((t,e)=>{n&&(t=i[e=t]),wo(h,e,is(t,r,o,s,a,e,i,l))})}}return h},rs=(t,e)=>Ao(t,Vo(t),e),os=(t,e)=>e.length<2?t:Qo(t,e.slice(0,-1)),ss=(t,i,r)=>{if(w(t)){var o=(i=Ko(i,t)).length,s=o-1;let e=-1,n=t;for(;null!=n&&++e<o;){var a,l=ns(i[e]);let t=r;e!=s&&(a=n[l],(t=void 0)===t)&&(t=w(a)?a:as(i[e+1])?[]:{}),wo(n,l,t),n=n[l]}}return t},as=(t,e)=>{var n=typeof t;return!!(e=null==e?Number.MAX_SAFE_INTEGER:e)&&("number"==n||"symbol"!=n&&io.test(t))&&-1<t&&t%1==0&&t<e},ls=t=>{var e,n=[];for(e in t)n.push(e);return n},hs=t=>{var e,n={};for(e in t=Object(t))n[e]=t[e];return n},us=(t,e)=>{if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};function cs(s,t){let a=1<arguments.length&&void 0!==t&&t;return function(t){let e=-1,n=arguments.length<=1?0:arguments.length-1,i=!(1<n)||n-1+1<1||arguments.length<=n-1+1?void 0:arguments[n-1+1];var r=!(2<n)||arguments.length<=3?void 0:arguments[3];for(i=3<s.length&&"function"==typeof i?(n--,i):a?(t,e)=>{if(Array.isArray(t)&&!Array.isArray(e))return e}:void 0,r&&vo(arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],r)&&(i=n<3?void 0:i,n=1),t=Object(t);++e<n;){var o=e+1<1||arguments.length<=e+1?void 0:arguments[e+1];o&&s(t,o,e,i)}return t}}let ds=(i,r,t,o,s)=>{i!==r&&pa(r,(e,n)=>{if(w(e))s=s||new Ds,fs(i,r,n,t,ds,o,s);else{let t=o?o(i[n],e,""+n,i,r,s):void 0;void 0===t&&(t=e),ps(i,n,t)}})},fs=(n,i,r,o,s,a,l)=>{var h=us(n,r),u=us(i,r),c=l.get(u);if(c)ps(n,r,c);else{let t=a?a(h,u,""+r,n,i,l):void 0,e=void 0===t;e&&(i=!(c=Array.isArray(u))&&Fo(u),t=u,c||i?t=Array.isArray(h)?h:mo(h)&&Po(h)?So(h):i?(e=!1,Co(u,!0)):[]:y(u)||Ms(u)?(t=h,Ms(h)?t=hs(h):"function"!=typeof h&&w(h)||(t=_o(u))):e=!1),e&&(l.set(u,t),s(t,u,o,a,l),l.delete(u)),ps(n,r,t)}},ps=(t,e,n)=>{(void 0===n||go(t[e],n))&&(void 0!==n||e in t)||wo(t,e,n)};let gs=(t,e)=>t&&((t,e,n)=>{var i=Object(t),r=n(t);let o=r.length,s=-1;for(;o--;){var a=r[++s];if(!1===e(i[a],a,i))break}return t})(t,e,co),ms=(e,n)=>{if(null!=e){if(!Po(e))return gs(e,n);var i=e.length,r=Object(e);let t=-1;for(;++t<i&&!1!==n(r[t],t,r););}return e};let vs=Set&&1/Xo(new Set([void 0,-0]))[1]==1/0?t=>new Set(t):()=>{};function ys(t,e,n,i,r,o){return w(t)&&w(e)&&(o.set(e,t),ds(t,e,void 0,ys,o),o.delete(e)),t}function bs(e,n,u){n=n.length?n.map(e=>Array.isArray(e)?t=>Qo(t,1===e.length?e[0]:e):e):[t=>t];let i=-1,r=-1,o=Po(e)?new Array(e.length):[];ms(e,e=>{var t=n.map(t=>t(e));o[++r]={criteria:t,index:++i,value:e}});{var s=o;e=(e,n)=>{{var i=u;let t=-1;for(var r=e.criteria,o=n.criteria,s=r.length,a=i.length;++t<s;){var l=t<a?i[t]:null,h=(l&&"function"==typeof l?l:ts)(r[t],o[t]);if(h)return l&&"function"!=typeof l?h*("desc"==l?-1:1):h}return e.index-n.index}};let t=s.length;for(s.sort(e);t--;)s[t]=s[t].value;return s}}function xs(t){return t==t&&!w(t)}function ws(e,n){return t=>null!=t&&t[e]===n&&(void 0!==n||e in Object(t))}function As(t,e){return null!=t&&Rs(t,e,Os)}function Ps(e){let n=(t=>{let e=co(t),n=e.length;for(;n--;){var i=e[n],r=t[i];e[n]=[i,r,xs(r)]}return e})(e);return 1===n.length&&n[0][2]?ws(n[0][0],n[0][1]):t=>t===e||((t,e,n,i)=>{let r=n.length,o=r,s=!i;if(null==t)return!o;let a,l;for(t=Object(t);r--;)if(a=n[r],s&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1;for(;++r<o;){var h=(a=n[r])[0],u=t[h],c=a[1];if(s&&a[2]){if(void 0===u&&!(h in t))return!1}else{var d=new Ds;if(!(void 0===(l=i?i(u,c,h,t,e,d):l)?jo(c,u,d):l))return!1}}return!0})(t,e,n)}function Es(t){return Zo(t)?(n=ns(t),t=>null==t?void 0:t[n]):(e=t,t=>Qo(t,e));var e,n}function Ts(t){var n,i;return"function"==typeof t?t:null==t?t=>t:"object"==typeof t?Array.isArray(t)?(n=t[0],i=t[1],Zo(n)&&xs(i)?ws(ns(n),i):t=>{var e=Qo(t,n);return void 0===e&&e===i?As(t,n):jo(i,e)}):Ps(t):Es(t)}function Ss(t,e){var n=Ts;return arguments.length?n(t,e):n}let ks=(t,e,n,i)=>{let r=-1;var o=null==t?0:t.length;for(i&&o&&(n=t[++r]);++r<o;)n=e(n,t[r],r,t);return n},Ls=(t,i,r,o,e)=>(e(t,(t,e,n)=>{r=o?(o=!1,t):i(r,t,e,n)}),r);let Cs=t=>Array.isArray(t)||Ms(t)||!(!t||!t[Symbol.isConcatSpreadable]);let Ms=t=>mo(t)&&"[object Arguments]"==ko(t),_s=(t,e,n)=>{let i=-1;for(var r=e.length,o={};++i<r;){var s=e[i],a=Qo(t,s);n(a,s)&&ss(o,Ko(s,t),a)}return o},Ns=t=>"number"==typeof t&&-1<t&&t%1==0&&t<=Number.MAX_SAFE_INTEGER,Os=(t,e)=>null!=t&&e in Object(t),Rs=(t,e,n)=>{for(var i=-1,r=(e=Ko(e,t)).length,o=!1;++i<r;){var s=ns(e[i]);if(!(o=null!=t&&n(t,s)))break;t=t[s]}return o||++i!=r?o:!!(r=null==t?0:t.length)&&Ns(r)&&as(s,r)&&(Array.isArray(t)||Ms(t))},Fs=t=>t.match(oo),Is=t=>t.match($r),Vs=(t,e)=>void 0===e?(ro(t)?Is:Fs)(t)||[]:t.match(e)||[],Bs=(Zr="toUpperCase",t=>{var e,n,i,r,o;return t?(e=((n=so(t)?ho(t):void 0)||t)[0],o=n?(i=1,o=(n=n).length,r=void 0===r?o:r,(!i&&o<=r?n:n.slice(i,r)).join("")):t.slice(1),e[Zr]()+o):""});class Ds{constructor(t){t=this.__data__=new zs(t);this.size=t.size}clear(){this.__data__=new zs,this.size=0}delete(t){var e=this.__data__,t=e.delete(t);return this.size=e.size,t}get(t){return this.__data__.get(t)}has(t){return this.__data__.has(t)}set(t,e){let n=this.__data__;if(n instanceof zs){var i=n.__data__;if(i.length<Wr-1)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new js(i)}return n.set(t,e),this.size=n.size,this}}class zs{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.__data__=[],this.size=0}delete(t){var e=this.__data__,t=po(e,t);return!(t<0||(t==e.length-1?e.pop():e.splice(t,1),--this.size,0))}get(t){var e=this.__data__,t=po(e,t);return t<0?void 0:e[t][1]}has(t){return-1<po(this.__data__,t)}set(t,e){var n=this.__data__,i=po(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}}class js{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.size=0,this.__data__={hash:new Gs,map:new Map,string:new Gs}}delete(t){t=Do(this,t).delete(t);return this.size-=t?1:0,t}get(t){return Do(this,t).get(t)}has(t){return Do(this,t).has(t)}set(t,e){var n=Do(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this}}class Gs{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}clear(){this.__data__=Object.create(null),this.size=0}delete(t){t=this.has(t)&&delete this.__data__[t];return this.size-=t?1:0,t}get(t){t=this.__data__[t];return t===Yr?void 0:t}has(t){return void 0!==this.__data__[t]}set(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=void 0===e?Yr:e,this}}class Us{constructor(t){let e=-1;var n=null==t?0:t.length;for(this.__data__=new js;++e<n;)this.add(t[e])}add(t){return this.__data__.set(t,Yr),this}has(t){return this.__data__.has(t)}}Us.prototype.push=Us.prototype.add;function Hs(t){var e=Object.prototype.toString;return!0===t||!1===t||!!t&&"object"==typeof t&&e.call(t)===Ar}function qs(t){var e=Object.prototype.toString;return"number"==typeof t||!!t&&"object"==typeof t&&e.call(t)===Sr}let w=function(t){return!!t&&("object"==typeof t||"function"==typeof t)},E=function(t){var e=Object.prototype.toString;return"string"==typeof t||!!t&&"object"==typeof t&&e.call(t)===_r},T=cs((t,e)=>{if(xo(e)||Po(e))Ao(e,co(e),t);else for(var n in e)hasOwnProperty.call(e,n)&&wo(t,n,e[n])});function $s(e){let t=-1,n=arguments.length<=1?0:arguments.length-1;var i=!(2<n)||arguments.length<=3?void 0:arguments[3];for(i&&vo(arguments.length<=1?void 0:arguments[1],arguments.length<=2?void 0:arguments[2],i)&&(n=1);++t<n;){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];if(null!=r){var o=Object.keys(r),s=o.length;let t=-1;for(;++t<s;){var a=o[t],l=e[a];(void 0===l||go(l,Object.prototype[a])&&!hasOwnProperty.call(e,a))&&(e[a]=r[a])}}}return e}n=T,$e=n;let Ws=$s;function Ys(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.push(void 0,ys),k.apply(void 0,e)}function Xs(t,e){for(var n=arguments.length,i=new Array(2<n?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];let o=-1,s="function"==typeof e,a=Po(t)?new Array(t.length):[];return ms(t,t=>{a[++o]=s?e.apply(t,i):Zs(t,e,...i)}),a}function Zs(t,e){e=Ko(e,t);for(var n,e=null==(t=os(t,e))?t:t[ns((n=null==(e=e)?0:e.length)?e[n-1]:void 0)],i=arguments.length,r=new Array(2<i?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return null==e?void 0:e.apply(t,r)}let Js=Ys,Ks=(e,n,i)=>{let r=0,o=null==e?0:e.length;if(0==o)return 0;for(var s=(n=(i=Ss(i,2))(n))!=n,a=null===n,l=Eo(n),h=void 0===n;r<o;){let t;var u=Math.floor((r+o)/2),c=i(e[u]),d=void 0!==c,f=null===c,p=c==c,g=Eo(c);(t=s?p:h?p&&d:a?p&&d&&!f:l?p&&d&&!f&&!g:!f&&!g&&c<n)?r=u+1:o=u}return Math.min(o,4294967294)},Qs=(t,e)=>{let n=-1,i=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),r=(e=Ss(e,2),!0);var o=t.length,s=[];let a=s;if(o>=Wr){var l=e?null:vs(t);if(l)return Xo(l);r=!1,i=(t,e)=>t.has(e),a=new Us}else a=e?[]:s;t:for(;++n<o;){var h=t[n],u=e?e(h):h,h=0!==h?h:0;if(r&&u==u){let t=a.length;for(;t--;)if(a[t]===u)continue t;e&&a.push(u),s.push(h)}else i(a,u)||(a!==s&&a.push(u),s.push(h))}return s},f=t=>is(t),ta=t=>is(t,!0),ea=t=>{if(null!=t){if(Po(t)&&(Array.isArray(t)||"string"==typeof t||"function"==typeof t.splice||Fo(t)||Ms(t)))return!t.length;var e,n=ko(t);if("[object Map]"==n||"[object Set]"==n)return!t.size;if(xo(t))return!(t=>{if(!xo(t))return Object.keys(t);var e,n=[];for(e in Object(t))hasOwnProperty.call(t,e)&&"constructor"!=e&&n.push(e);return n})(t).length;for(e in t)if(hasOwnProperty.call(t,e))return!1}return!0},na=(t,e)=>jo(t,e),b=t=>"function"==typeof t,y=t=>{if(!mo(t)||"[object Object]"!=ko(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},et=t=>{if(!t)return[];if(Po(t))return(E(t)?ho:So)(t);if(Symbol.iterator&&Symbol.iterator in Object(t)){for(var e,n=t[Symbol.iterator](),i=[];!(e=n.next()).done;)i.push(e.value);return i}var r=ko(t);return(r==Tr?Yo:r==Mr?Xo:uo)(t)};function ia(i,o,t){if("function"!=typeof i)throw new TypeError("Expected a function");let s,a,n,l,h,u,c=0,d=!1,f=!1,e=!0,r=!o&&0!==o&&window&&"function"==typeof window.requestAnimationFrame;function p(t){var e=s,n=a;return s=a=void 0,c=t,l=i.apply(n,e)}function g(t,e){return r?(window.cancelAnimationFrame(h),window.requestAnimationFrame(t)):setTimeout(t,e)}function m(t){var e=t-u,t=t-c;return void 0===u||o<=e||e<0||f&&t>=n}function v(){var t,e=Date.now();if(m(e))return y(e);h=g(v,(t=(e=e)-u,e-=c,t=o-t,f?Math.min(t,n-e):t))}function y(t){return h=void 0,e&&s?p(t):(s=a=void 0,l)}function b(){for(var t=Date.now(),e=m(t),n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];if(s=i,a=this,u=t,e){if(void 0===h)return t=u,c=t,h=g(v,o),d?p(t):l;if(f)return h=g(v,o),p(u)}return void 0===h&&(h=g(v,o)),l}return o=+o||0,w(t)&&(d=!!t.leading,f="maxWait"in t,n=f?Math.max(+t.maxWait||0,o):n,e="trailing"in t?!!t.trailing:e),b.cancel=()=>{void 0!==h&&(t=>{if(r)return window.cancelAnimationFrame(t);clearTimeout(t)})(h),c=0,s=u=a=h=void 0},b.flush=()=>void 0===h?l:y(Date.now()),b.pending=()=>void 0!==h,b}function ra(t){let e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];var n;return null==t?[]:(1<(n=e.length)&&vo(t,e[0],e[1])?e=[]:2<n&&vo(e[0],e[1],e[2])&&(e=[e[0]]),bs(t,(e=Array.isArray(e)?e:[Ss(e,2)]).flat(1),[]))}function oa(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return Po(t)?es(t,n):[]}let sa=(t,i)=>(i=Ss(i,2),function(t,e,n){return(Array.isArray(t)?ks:Ls)(t,e,n,arguments.length<3,ms)}(t,(t,e)=>{var n=i(e);return hasOwnProperty.call(t,n)?t[n].push(e):wo(t,n,[e]),t},{})),aa=t=>(null==t?0:t.length)?function t(e,n,i,r,o){let s=-1;var a=e.length;for(i=i||Cs,o=o||[];++s<a;){var l=e[s];0<n&&i(l)?1<n?t(l,n-1,i,r,o):o.push(...l):r||(o[o.length]=l)}return o}(t,1/0):[],la=function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return mo(t)&&Po(t)?es(t,n.flat(1)):[]};function ha(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.flat(1);return Qs(i)}function ua(n){for(var t=arguments.length,i=new Array(1<t?t-1:0),e=1;e<t;e++)i[e-1]=arguments[e];let r={};if(null!=n){let e=!1,t=(i=i.flat(1).map(t=>(t=Ko(t,n),e=e||1<t.length,t)),Ao(n,Bo(n),r),e&&(r=is(r,!0,!0,!0,t=>y(t)?void 0:t)),i.length);for(;t--;){s=o=void 0;var o=r,s=i[t];s=Ko(s,o),o=os(o,s),s=s[s.length-1],null!=o&&delete o[ns(s)]}}return r}function ca(t){for(var n,e=arguments.length,i=new Array(1<e?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];return null==t?{}:(n=t,t=i.flat(1/0),_s(n,t,(t,e)=>As(n,e)))}let da=(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},S=(e,n,i)=>{let r=-1,o=(n=Ko(n,e)).length;for(o||(o=1,e=void 0);++r<o;){let t=null==e?void 0:e[ns(n[r])];void 0===t&&(r=o,t=i),e="function"==typeof t?t.call(e):t}return e};function fa(){return""+(0<arguments.length&&void 0!==arguments[0]?arguments[0]:"")+ ++ma}let pa=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t=>t;let n=-1;var i=Object(t),r=Po(t)?fo(t,!0):ls(t);let o=r.length;for(;o--;){var s=r[++n];if(!1===e(i[s],s,i))break}},ga=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return Vs((""+t).replace(/['\u2019]/g,"")).reduce((t,e,n)=>(e=e.toLowerCase(),t+(n?Bs(e):e)),"")},ma=0,k=cs((t,e,n,i)=>{ds(t,e,n,i)},!0);class va{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 t=this.map.get(t),void 0===e?t:t[e]}set(t,e,n){void 0!==e&&(t=this.create(t),"string"==typeof e?t[e]=n:Object.assign(t,e))}remove(t,e){this.has(t)&&(void 0===e?this.map.delete(t):delete this.map.get(t)[e])}}function ya(t,e){if(!(this instanceof ya))return new ya(t,e);t&&t.type?(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?wa:Aa,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}let ba=new va,xa=new va;function wa(){return!0}function Aa(){return!1}ya.prototype={constructor:ya,isDefaultPrevented:Aa,isPropagationStopped:Aa,isImmediatePropagationStopped:Aa,preventDefault:function(){var t=this.originalEvent;this.isDefaultPrevented=wa,t&&t.preventDefault()},stopPropagation:function(){var t=this.originalEvent;this.isPropagationStopped=wa,t&&t.stopPropagation()},stopImmediatePropagation:function(){var t=this.originalEvent;this.isImmediatePropagationStopped=wa,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=>{var e;e=t,Object.defineProperty(ya.prototype,e,{enumerable:!0,configurable:!0,get:function(){return this.originalEvent?this.originalEvent[e]:void 0},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})});let Pa="undefined"!=typeof window?window.document:null,Ea=Pa&&Pa.documentElement,Ta=/^([^.]*)(?:\.(.+)|)/,Sa=/[^\x20\t\r\n\f]+/g,L=function(t){return new L.Dom(t)},ka=(L.fn=L.prototype={constructor:L,length:0},L.guid=1,L.data=xa,L.merge=function(e,n){var i=+n.length;let r=e.length;for(let t=0;t<i;t++)e[r++]=n[t];return e.length=r,e},L.parseHTML=function(t){var e=Pa.implementation.createHTMLDocument(),n=e.createElement("base"),i=(n.href=Pa.location.href,e.head.appendChild(n),e.body.innerHTML=t,e.getElementsByTagName("script"));for(let t=0;t<i.length;t++)i[t].remove();return Array.from(e.body.childNodes)},"function"==typeof Symbol&&(L.fn[Symbol.iterator]=Array.prototype[Symbol.iterator]),L.fn.toArray=function(){return Array.from(this)},L.fn.pushStack=function(t){t=L.merge(this.constructor(),t);return t.prevObject=this,t},L.fn.find=function(t){var e,[n]=this,i=this.pushStack([]);return n&&(e=n.nodeType,1!==e&&9!==e&&11!==e||("string"!=typeof t?n!==t&&n.contains(t)&&L.merge(i,[t]):L.merge(i,n.querySelectorAll(t)))),i},L.fn.add=function(t){var t=L(t).toArray(),e=this.toArray(),n=this.pushStack([]);return L.merge(n,Qs(e.concat(t))),n},L.fn.addBack=function(){return this.add(this.prevObject)},L.fn.filter=function(e){var n=[];for(let t=0;t<this.length;t++){var i=this[t];i.matches(e)&&n.push(i)}return this.pushStack(n)},/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/);function La(e){if(e){if("function"==typeof e)throw new Error("function not supported");if(1<arguments.length)throw new Error("selector with context not supported");if(e.nodeType)this[0]=e,this.length=1;else{let t;if("<"===(n=e+"")[0]&&">"===n[n.length-1]&&3<=n.length)t=[null,e,null];else{if("string"!=typeof e)return L.merge(this,e);t=ka.exec(e)}var n;if(!t||!t[1])return Ca.find(e);t[1]?L.merge(this,L.parseHTML(t[1])):(n=Pa.getElementById(t[2]))&&(this[0]=n,this.length=1)}}return this}(L.Dom=La).prototype=L.fn,L.Event=ya,L.event={special:Object.create(null)},L.event.has=function(t,e){t=ba.get(t,"events");return!!t&&(!e||Array.isArray(t[e])&&0<t[e].length)},L.event.on=function(e,n,i,r,o,t){if("object"==typeof n){for(var s in"string"!=typeof i&&(r=r||i,i=void 0),n)L.event.on(e,s,i,r,n[s],t);return e}if(null==r&&null==o?(o=i,r=i=void 0):null==o&&("string"==typeof i?(o=r,r=void 0):(o=r,r=i,i=void 0)),!o)return e;if(1===t){let e=o;(o=function(t){return L().off(t),e.apply(this,arguments)}).guid=e.guid||(e.guid=L.guid++)}for(let t=0;t<e.length;t++)L.event.add(e[t],n,o,r,i)},L.event.add=function(r,o,s,a,l){if("object"==typeof r){var h=ba.create(r);let e;s.handler&&(s=(e=s).handler,l=e.selector),l&&Ea.matches(l),s.guid||(s.guid=L.guid++);let n;n=(n=h.events)||(h.events=Object.create(null));let i;i=(i=h.handle)||(h.handle=function(t){return void 0!==L?L.event.dispatch.apply(r,arguments):void 0});var u=(o||"").match(Sa)||[""];let t=u.length;for(;t--;){var[,c,d=""]=Ta.exec(u[t]);if(c){var d=d.split(".").sort(),f=(p=L.event.special[c])&&(l?p.delegateType:p.bindType)||c,p=L.event.special[f],c=Object.assign({type:f,origType:c,data:a,handler:s,guid:s.guid,selector:l,namespace:d.join(".")},e);let t;(t=n[f])||((t=n[f]=[]).delegateCount=0,p&&p.setup&&!1!==p.setup.call(r,a,d,i))||r.addEventListener&&r.addEventListener(f,i),p&&p.add&&(p.add.call(r,c),c.handler.guid||(c.handler.guid=s.guid)),l?t.splice(t.delegateCount++,0,c):t.push(c)}}}},L.event.remove=function(e,n,i,r,o){var s=ba.get(e);if(s&&s.events){var a=s.events,l=(n||"").match(Sa)||[""];let t=l.length;for(;t--;){var[,h,u=""]=Ta.exec(l[t]);if(h){var c=L.event.special[h],d=c&&(r?c.delegateType:c.bindType)||h,f=a[d];if(f&&0!==f.length){var p=u.split(".").sort(),g=u?new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,u=f.length;let t=u;for(;t--;){var m=f[t];!o&&h!==m.origType||i&&i.guid!==m.guid||g&&!g.test(m.namespace)||r&&r!==m.selector&&("**"!==r||!m.selector)||(f.splice(t,1),m.selector&&f.delegateCount--,c&&c.remove&&c.remove.call(e,m))}u&&0===f.length&&(c&&c.teardown&&!1!==c.teardown.call(e,p,s.handle)||e.removeEventListener&&e.removeEventListener(d,s.handle),delete a[d])}}else for(var v in a)L.event.remove(e,v+l[t],i,r,!0)}ea(a)&&(ba.remove(e,"handle"),ba.remove(e,"events"))}},L.event.dispatch=function(e){var n=L.event.fix(e),i=(n.delegateTarget=this,Array.from(arguments)),e=(i[0]=n,ba.get(this,"events")),e=e&&e[n.type]||[],r=L.event.special[n.type];if(!r||!r.preDispatch||!1!==r.preDispatch.call(this,n)){var o,s,a=L.event.handlers.call(this,n,e);let t=0;for(;(o=a[t++])&&!n.isPropagationStopped();){n.currentTarget=o.elem;let t=0;for(;(s=o.handlers[t++])&&!n.isImmediatePropagationStopped();){n.handleObj=s,n.data=s.data;var l=L.event.special[s.origType];let t;l=(t=l&&l.handle?l.handle:s.handler).apply(o.elem,i);void 0!==l&&!1===(n.result=l)&&(n.preventDefault(),n.stopPropagation())}}return r&&r.postDispatch&&r.postDispatch.call(this,n),n.result}},L.event.handlers=function(t,n){var i=n.delegateCount,r=[];if(i&&!("click"===t.type&&1<=t.button))for(let e=t.target;e!==this;e=e.parentNode||this)if(1===e.nodeType&&("click"!==t.type||!0!==e.disabled)){var o=[],s={};for(let t=0;t<i;t++){var a=n[t],l=a.selector+" ";void 0===s[l]&&(s[l]=e.matches(l)),s[l]&&o.push(a)}o.length&&r.push({elem:e,handlers:o})}return i<n.length&&r.push({elem:this,handlers:n.slice(i)}),r},L.event.fix=function(t){return t.envelope?t:new ya(t)};let Ca=L(Pa),R=(()=>{if(!("object"==typeof window&&!!window.SVGAngle))return function(){throw new Error("SVG is required to use Vectorizer.")};function N(t,e,n){if(!(this instanceof N))return N.apply(Object.create(N.prototype),arguments);if(t){if(N.isV(t)&&(t=t.node),e=e||{},N.isString(t)){if("svg"===(t=t.trim()).toLowerCase())t=N.createSvgDocument();else if("<"===t[0]){var i=N.createSvgDocument(t);if(1<i.childNodes.length){for(var r=[],o=0,s=i.childNodes.length;o<s;o++){var a=i.childNodes[o];r.push(new N(document.importNode(a,!0)))}return r}t=document.importNode(i.firstChild,!0)}else t=document.createElementNS(O.svg,t);N.ensureId(t)}return this.node=t,this.setAttributes(e),n&&this.append(n),this}}var O={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"},h=(t=Math).PI,i=t.atan2,o=t.sqrt,l=t.min,a=t.max,u=t.cos,c=t.sin,t=N.prototype,R=(Object.defineProperty(t,"id",{enumerable:!0,get:function(){return this.node.id},set:function(t){this.node.id=t}}),t.getTransformToElement=function(t){var e=this.node;if(N.isSVGGraphicsElement(t)&&N.isSVGGraphicsElement(e)){t=N.toNode(t).getScreenCTM(),e=e.getScreenCTM();if(t&&e)return t.inverse().multiply(e)}return N.createSVGMatrix()},t.transform=function(t,e){var n=this.node;return N.isUndefined(t)?N.transformStringToMatrix(this.attr("transform")):e&&e.absolute?this.attr("transform",N.matrixToTransformString(t)):(e=N.createSVGTransform(t),n.transform.baseVal.appendItem(e),this)},t.translate=function(t,e,n){n=n||{},e=e||0;var i=this.attr("transform")||"",r=N.parseTransformString(i),i=r.value;if(N.isUndefined(t))return r.translate;i=i.replace(/translate\([^)]*\)/g,"").trim();t=n.absolute?t:r.translate.tx+t,n=n.absolute?e:r.translate.ty+e;return this.attr("transform",("translate("+t+","+n+")"+" "+i).trim()),this},t.rotate=function(t,e,n,i){i=i||{};var r=this.attr("transform")||"",o=N.parseTransformString(r),r=o.value;if(N.isUndefined(t))return o.rotate;r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;i=i.absolute?t:o.rotate.angle+t;return this.attr("transform",(r+" "+("rotate("+i+(void 0!==e&&void 0!==n?","+e+","+n:"")+")")).trim()),this},t.scale=function(t,e){e=N.isUndefined(e)?t:e;var n=this.attr("transform")||"",i=N.parseTransformString(n),n=i.value;return N.isUndefined(t)?i.scale:(n=n.replace(/scale\([^)]*\)/g,"").trim(),this.attr("transform",(n+" "+("scale("+t+","+e+")")).trim()),this)},t.bbox=function(t,e){var n,i=this.node,r=i.ownerSVGElement;if(!r)return new tt(0,0,0,0);try{n=i.getBBox()}catch(t){n={x:i.clientLeft,y:i.clientTop,width:i.clientWidth,height:i.clientHeight}}return t?new tt(n):(i=this.getTransformToElement(e||r),N.transformRect(n,i))},t.getBBox=function(t){var e={},n=this.node;if(!n.ownerSVGElement||!N.isSVGGraphicsElement(n))return new tt(0,0,0,0);if(t&&(t.target&&(e.target=N.toNode(t.target)),t.recursive)&&(e.recursive=t.recursive),e.recursive){var i=this.children(),r=i.length;if(0===r)return this.getBBox({target:e.target,recursive:!1});e.target||(e.target=this);for(var o=0;o<r;o++)var s=i[o],s=0===s.children().length?s.getBBox({target:e.target,recursive:!1}):s.getBBox({target:e.target,recursive:!0}),a=a?a.union(s):s;return a}try{a=n.getBBox()}catch(t){a={x:n.clientLeft,y:n.clientTop,width:n.clientWidth,height:n.clientHeight}}return e.target?(t=this.getTransformToElement(e.target),N.transformRect(a,t)):new tt(a)},/em$/);function F(t,e){var n=parseFloat(t);return R.test(t)?n*e:n}t.text=function(t,e){if(t&&"string"!=typeof t)throw new Error("Vectorizer: text() expects the first argument to be a string.");t=N.sanitizeText(t);for(var n,i,r,o,s=(e=e||{}).displayEmpty,a=e.eol,l=e.textPath,h=e.textVerticalAnchor,u="middle"===h||"bottom"===h||"top"===h,c=e.x,d=(void 0===c&&(c=this.attr("x")||0),e.includeAnnotationIndices),f=e.annotations,e=(f&&!N.isArray(f)&&(f=[f]),e.lineHeight),p="auto"===e,g=p?"1.5em":e||"1em",m=(this.empty(),this.attr({"xml:space":"preserve",display:t||s?null:"none"}),parseFloat(this.attr("font-size"))),v=(!m&&(m=16,u||f)&&this.attr("font-size",m),document),y=l?(e=this,s=(s=l="string"==typeof l?{d:l}:l)||{},n=N("textPath"),(i=s.d)&&void 0===s["xlink:href"]&&(i=N("path").attr("d",i).appendTo(e.defs()),n.attr("xlink:href","#"+i.id)),N.isObject(s)&&n.attr(s),n.node):v.createDocumentFragment(),b=0,x=t.split("\n"),w=[],A=0,P=x.length-1;A<=P;A++){var E,T,S=g,k="v-line",L=v.createElementNS(O.svg,"tspan"),C=x[A];if(C)f?((M=(T=((t,e,n)=>{for(var i=(n=n||{}).includeAnnotationIndices,r=n.eol,o=n.lineHeight,s=n.baseSize,a=0,n={},l=e.length-1,h=0;h<=l;h++){var u,c,d,f,p=e[h],g=null;N.isObject(p)?(u=p.attrs,d=(c=N("tspan",u)).node,f=p.t,r&&h===l&&(f+=r),d.textContent=f,(f=u.class)&&c.addClass(f),i&&c.attr("annotations",p.annotations),g=parseFloat(u["font-size"]),(g=isFinite(g)?g:s)&&a<g&&(a=g)):(r&&h===l&&(p+=r),d=document.createTextNode(p||" "),s&&a<s&&(a=s)),t.appendChild(d)}return a&&(n.maxFontSize=a),o?n.lineHeight=o:a&&(n.lineHeight=1.2*a),n})(L,E=N.annotateString(C,f,{offset:-b,includeAnnotationIndices:d}),{includeAnnotationIndices:d,eol:A!==P&&a,lineHeight:p?null:g,baseSize:m})).lineHeight)&&p&&0!==A&&(S=M),0===A&&(r=.8*T.maxFontSize)):(a&&A!==P&&(C+=a),L.textContent=C);else{L.textContent="-",k+=" v-empty-line";var M=L.style;if(M.fillOpacity=0,M.strokeOpacity=0,f){T={};let e=m;for(let t=(E=N.findAnnotationsAtIndex(f,b)).length;0<t;t--){var _=E[t-1].attrs;if(_&&"font-size"in _){_=parseFloat(_["font-size"]);if(isFinite(_)){e=_;break}}}p&&(0<A?S=1.2*e:r=.8*e),L.setAttribute("font-size",e),T.maxFontSize=e}}T&&w.push(T),0<A&&L.setAttribute("dy",S),(0<A||l)&&L.setAttribute("x",c),L.className.baseVal=k,y.appendChild(L),b+=C.length+1}if(u)if(f)S=((t,e,n,i)=>{if(!Array.isArray(e))return 0;var r=e.length;if(!r)return 0;for(var o=e[0],s=F(o.maxFontSize,n)||n,a=0,l=F(i,n),h=1;h<r;h++)a+=F((o=e[h]).lineHeight,n)||l;var u,c=F(o.maxFontSize,n)||n;switch(t){case"middle":u=s/2-.15*c-a/2;break;case"bottom":u=-.25*c-a;break;default:u=.8*s}return u})(h,w,m,g);else if("top"===h)S="0.8em";else switch(0<P?(o=parseFloat(g)||1,o*=P,R.test(g)||(o/=m)):o=0,h){case"middle":S=.3-o/2+"em";break;case"bottom":S=-o-.3+"em"}else 0===h?S="0em":h?S=h:(S=0,null===this.attr("y")&&this.attr("y",r||"0.8em"));return y.firstChild.setAttribute("dy",S),this.append(y),this},t.removeAttr=function(t){var t=s[t],{ns:e,local:n}=N.qualifyAttr(t),i=this.node;return e?i.hasAttributeNS(e,n)&&i.removeAttributeNS(e,n):i.hasAttribute(t)&&i.removeAttribute(t),this},t.attr=function(t,e){if(N.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(N.isString(t)&&N.isUndefined(e))return this.node.getAttribute(s[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},t.normalizePath=function(){return"PATH"===this.tagName()&&this.attr("d",N.normalizePathData(this.attr("d"))),this},t.remove=function(){return this.node.parentNode&&this.node.parentNode.removeChild(this.node),this},t.empty=function(){for(;this.node.firstChild;)this.node.removeChild(this.node.firstChild);return this},t.setAttributes=function(t){for(var e in t)t.hasOwnProperty(e)&&this.setAttribute(e,t[e]);return this},t.append=function(t){for(var e=0,n=(t=N.isArray(t)?t:[t]).length;e<n;e++)this.node.appendChild(N.toNode(t[e]));return this},t.prepend=function(t){var e=this.node.firstChild;return e?N(e).before(t):this.append(t)},t.before=function(t){var e=this.node,n=e.parentNode;if(n)for(var i=0,r=(t=N.isArray(t)?t:[t]).length;i<r;i++)n.insertBefore(N.toNode(t[i]),e);return this},t.appendTo=function(t){return N.toNode(t).appendChild(this.node),this},t.svg=function(){return this.node instanceof window.SVGSVGElement?this:N(this.node.ownerSVGElement)},t.tagName=function(){return this.node.tagName.toUpperCase()},t.defs=function(){var t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?N(e):N("defs").appendTo(t)},t.clone=function(){var t=N(this.node.cloneNode(!0));return t.node.id=N.uniqueId(),t},t.findOne=function(t){t=this.node.querySelector(t);return t?N(t):void 0},t.find=function(t){var e=[],n=this.node.querySelectorAll(t);if(n)for(var i=0;i<n.length;i++)e.push(N(n[i]));return e},t.children=function(){for(var t=this.node.childNodes,e=[],n=0;n<t.length;n++)1===t[n].nodeType&&e.push(N(t[n]));return e},t.parent=function(){return N(this.node.parentNode)||null},t.index=function(){for(var t=0,e=this.node.previousSibling;e;)1===e.nodeType&&t++,e=e.previousSibling;return t},t.findParentByClass=function(t,e){for(var n=this.node.ownerSVGElement,i=this.node.parentNode;i&&i!==e&&i!==n;){var r=N(i);if(r.hasClass(t))return r;i=i.parentNode}return null},t.contains=function(t){var e=this.node,t=N.toNode(t),t=t&&t.parentNode;return e===t||!!(t&&1===t.nodeType&&16&e.compareDocumentPosition(t))},t.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)},t.translateCenterToPoint=function(t){var e=this.getBBox({target:this.svg()}).center();return this.translate(t.x-e.x,t.y-e.y),this},t.translateAndAutoOrient=function(t,e,n){t=new A(t),e=new A(e),n=n||this.svg();var i=this.scale(),r=(this.attr("transform",""),this.getBBox({target:n}).scale(i.sx,i.sy)),o=N.createSVGTransform(),s=(o.setTranslate(-r.x-r.width/2,-r.y-r.height/2),N.createSVGTransform()),a=t.angleBetween(e,t.clone().offset(1,0)),a=(a&&s.setRotate(a,0,0),N.createSVGTransform()),e=t.clone().move(e,r.width/2),r=(a.setTranslate(2*t.x-e.x,2*t.y-e.y),this.getTransformToElement(n)),t=N.createSVGTransform();return t.setMatrix(a.matrix.multiply(s.matrix.multiply(o.matrix.multiply(r.scale(i.sx,i.sy))))),this.attr("transform",N.matrixToTransformString(t.matrix)),this},t.animateAlongPath=function(e,n){n=N.toNode(n);n=N.ensureId(n),e=N("animateMotion",e),n=N("mpath",{"xlink:href":"#"+n});e.append(n),this.append(e);try{e.node.beginElement()}catch(t){if("fake"===document.documentElement.getAttribute("smiling"))for(var i=e.node,n=(i.animators=[],i.getAttribute("id")),r=(n&&(id2anim[n]=i),getTargets(i)),o=0,s=r.length;o<s;o++){var a=r[o],a=new Animator(i,a,o);animators.push(a),(i.animators[o]=a).register()}}return this};let e=/[^\x20\t\r\n\f]+/g;function r(t){return N.isString(t)&&t.trim().match(e)||[]}t.hasClass=function(t){return!!N.isString(t)&&this.node.classList.contains(t.trim())},t.addClass=function(t){return this.node.classList.add(...r(t)),this},t.removeClass=function(t){return this.node.classList.remove(...r(t)),this},t.toggleClass=function(t,e){var n=r(t);for(let t=0;t<n.length;t++)this.node.classList.toggle(n[t],e);return this},t.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},t.convertToPath=function(){var t=N("path"),e=(t.attr(this.attr()),this.convertToPathData());return e&&t.attr("d",e),t},t.convertToPathData=function(){var t=this.tagName();switch(t){case"PATH":return this.attr("d");case"LINE":return N.convertLineToPathData(this.node);case"POLYGON":return N.convertPolygonToPathData(this.node);case"POLYLINE":return N.convertPolylineToPathData(this.node);case"ELLIPSE":return N.convertEllipseToPathData(this.node);case"CIRCLE":return N.convertCircleToPathData(this.node);case"RECT":return N.convertRectToPathData(this.node)}throw new Error(t+" cannot be converted to PATH.")},N.prototype.toGeometryShape=function(){var t,e,n,i,r,o,s;switch(this.tagName()){case"RECT":return i=parseFloat(this.attr("x"))||0,s=parseFloat(this.attr("y"))||0,t=parseFloat(this.attr("width"))||0,n=parseFloat(this.attr("height"))||0,new tt(i,s,t,n);case"CIRCLE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,i=parseFloat(this.attr("r"))||0,new yi({x:o,y:r},i,i);case"ELLIPSE":return o=parseFloat(this.attr("cx"))||0,r=parseFloat(this.attr("cy"))||0,s=parseFloat(this.attr("rx"))||0,t=parseFloat(this.attr("ry"))||0,new yi({x:o,y:r},s,t);case"POLYLINE":return e=N.getPointsFromSvgNode(this),new x(e);case"POLYGON":return 1<(e=N.getPointsFromSvgNode(this)).length&&e.push(e[0]),new x(e);case"PATH":return n=this.attr("d"),V.isDataSupported(n)||(n=N.normalizePathData(n)),new V(n);case"LINE":return i=parseFloat(this.attr("x1"))||0,o=parseFloat(this.attr("y1"))||0,r=parseFloat(this.attr("x2"))||0,s=parseFloat(this.attr("y2"))||0,new P({x:i,y:o},{x:r,y:s})}return this.getBBox()},t.findIntersection=function(t,e){var n=this.svg().node,i=this.getBBox({target:e=e||n}),r=i.center();if(i.intersectionWithLineFromCenterToPoint(t)){i=this.tagName();if("RECT"===i)var o=new tt(parseFloat(this.attr("x")||0),parseFloat(this.attr("y")||0),parseFloat(this.attr("width")),parseFloat(this.attr("height"))),s=this.getTransformToElement(e),a=N.decomposeMatrix(s),n=n.createSVGTransform(),o=(n.setRotate(-a.rotation,r.x,r.y),N.transformRect(o,n.matrix.multiply(s))),s=new tt(o).intersectionWithLineFromCenterToPoint(t,a.rotation);else if("PATH"===i||"POLYGON"===i||"POLYLINE"===i||"CIRCLE"===i||"ELLIPSE"===i){for(var l,h,u,c=("PATH"===i?this:this.convertToPath()).sample(),d=1/0,f=[],p=0;p<c.length;p++)l=c[p],h=(h=N.createSVGPoint(l.x,l.y)).matrixTransform(this.getTransformToElement(e)),(u=(l=new A(h)).distance(r)+(h=1.1*l.distance(t)))<d?(d=u,f=[{sample:l,refDistance:h}]):u<d+1&&f.push({sample:l,refDistance:h});f.sort(function(t,e){return t.refDistance-e.refDistance}),f[0]&&(s=f[0].sample)}return s}},t.setAttribute=function(t,e){var n,i=this.node;return null===e?this.removeAttr(t):(t=s[t],n=N.qualifyAttr(t).ns,n?i.setAttributeNS(n,t,e):"id"===t?i.id=e:i.setAttribute(t,e)),this},N.createSvgDocument=function(t){return t?t=N.parseXML(`<svg xmlns="${O.svg}" xmlns:xlink="${O.xlink}" version="1.1">${t}</svg>`,{async:!1}).documentElement:((t=document.createElementNS(O.svg,"svg")).setAttributeNS(O.xmlns,"xmlns:xlink",O.xlink),t.setAttribute("version","1.1")),t},N.createSVGStyle=function(t){t=N("style",{type:"text/css"},[N.createCDATASection(t)]).node;return t},N.createCDATASection=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"";return document.implementation.createDocument(null,"xml",null).createCDATASection(t)},N.idCounter=0,N.uniqueId=function(){return"v-"+ ++N.idCounter},N.toNode=function(t){return N.isV(t)?t.node:t.nodeName&&t||t[0]},N.ensureId=function(t){return(t=N.toNode(t)).id||(t.id=N.uniqueId())},N.sanitizeText=function(t){return(t||"").replace(/ /g,"\xa0")},N.isUndefined=function(t){return void 0===t},N.isString=function(t){return"string"==typeof t},N.isObject=function(t){return t&&"object"==typeof t},N.isArray=Array.isArray,N.parseXML=function(t,e){var n;e=e||{};try{var i=new DOMParser;N.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};let n=Object.create(null),s=(["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=>n[t]=t),n.xlinkShow="xlink:show",n.xlinkRole="xlink:role",n.xlinkActuate="xlink:actuate",n.xlinkHref="xlink:href",n.xlinkType="xlink:type",n.xlinkTitle="xlink:title",n.xmlBase="xml:base",n.xmlLang="xml:lang",n.xmlSpace="xml:space",new Proxy(n,{get(t,e){return N.supportCamelCaseAttributes?e in t?t[e]:t[e]=e.replace(/[A-Z]/g,"-$&").toLowerCase():e}}));Object.defineProperty(N,"attributeNames",{enumerable:!0,value:s,writable:!1}),Object.defineProperty(N,"supportCamelCaseAttributes",{enumerable:!0,value:!0,writable:!0}),N.qualifyAttr=function(t){var e;return-1!==t.indexOf(":")?(e=t.split(":"),{ns:O[e[0]],local:e[1]}):{ns:null,local:t}},N.transformSeparatorRegex=/[ ,]+/,N.transformRegex=/\b\w+\([^()]+\)/g,N.transformFunctionRegex=/\b(\w+)\(([^()]+)\)/,N.transformTranslateRegex=/\btranslate\(([^()]+)\)/,N.transformRotateRegex=/\brotate\(([^()]+)\)/,N.transformScaleRegex=/\bscale\(([^()]+)\)/,N.transformStringToMatrix=function(t){let s=N.createSVGMatrix();var e=t&&t.match(N.transformRegex);if(e){var n=e.length;for(let t=0;t<n;t++){var a=e[t].match(N.transformFunctionRegex);if(a){let t,e,n,i,r,o=N.createSVGMatrix();var l=a[1].toLowerCase(),h=a[2].split(N.transformSeparatorRegex);switch(l){case"scale":t=parseFloat(h[0]),e=void 0===h[1]?t:parseFloat(h[1]),o=o.scaleNonUniform(t,e);break;case"translate":n=parseFloat(h[0]),i=parseFloat(h[1]),o=o.translate(n,i);break;case"rotate":r=parseFloat(h[0]),n=parseFloat(h[1])||0,i=parseFloat(h[2])||0,o=0!==n||0!==i?o.translate(n,i).rotate(r).translate(-n,-i):o.rotate(r);break;case"skewx":r=parseFloat(h[0]),o=o.skewX(r);break;case"skewy":r=parseFloat(h[0]),o=o.skewY(r);break;case"matrix":o.a=parseFloat(h[0]),o.b=parseFloat(h[1]),o.c=parseFloat(h[2]),o.d=parseFloat(h[3]),o.e=parseFloat(h[4]),o.f=parseFloat(h[5]);break;default:continue}s=s.multiply(o)}}}return s},N.matrixToTransformString=function(t){return"matrix("+(void 0!==(t=t||!0).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)+")"},N.parseTransformString=function(t){t&&(e=N.transformSeparatorRegex,0<=t.trim().indexOf("matrix")?(r=N.transformStringToMatrix(t),n=[(r=N.decomposeMatrix(r)).translateX,r.translateY],i=[r.scaleX,r.scaleY],r=[r.rotation],o=[],0===n[0]&&0===n[1]||o.push("translate("+n+")"),1===i[0]&&1===i[1]||o.push("scale("+i+")"),0!==r[0]&&o.push("rotate("+r+")"),t=o.join(" ")):((o=t.match(N.transformTranslateRegex))&&(n=o[1].split(e)),(o=t.match(N.transformRotateRegex))&&(r=o[1].split(e)),(o=t.match(N.transformScaleRegex))&&(i=o[1].split(e))));var e,n,i,r,o=i&&i[0]?parseFloat(i[0]):1;return{value:t,translate:{tx:n&&n[0]?parseInt(n[0],10):0,ty:n&&n[1]?parseInt(n[1],10):0},rotate:{angle:r&&r[0]?parseInt(r[0],10):0,cx:r&&r[1]?parseInt(r[1],10):void 0,cy:r&&r[2]?parseInt(r[2],10):void 0},scale:{sx:o,sy:i&&i[1]?parseFloat(i[1]):o}}},N.deltaTransformPoint=function(t,e){return{x:e.x*t.a+e.y*t.c,y:e.x*t.b+e.y*t.d}},N.decomposeMatrix=function(t){var e=N.deltaTransformPoint(t,{x:0,y:1}),n=N.deltaTransformPoint(t,{x:1,y:0}),e=180/h*i(e.y,e.x)-90,n=180/h*i(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:e,skewY:n,rotation:e}},N.matrixToScale=function(t){var e,n,i,r;return t?(e=N.isUndefined(t.a)?1:t.a,r=N.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}},N.matrixToRotate=function(t){var e={x:0,y:1};return t&&(e=N.deltaTransformPoint(t,e)),{angle:Xn(Hn(i(e.y,e.x))-90)}},N.matrixToTranslate=function(t){return{tx:t&&t.e||0,ty:t&&t.f||0}},N.isVElement=N.isV=function(t){return t instanceof N},N.isSVGGraphicsElement=function(t){return!!t&&(t=N.toNode(t))instanceof SVGElement&&"function"==typeof t.getScreenCTM};var y,b,E,T,S,k,L,C,M,d=N("svg").node;function f(t,e,n,i,r,o){return[1/3*t+2/3*n,1/3*e+2/3*i,1/3*r+2/3*n,1/3*o+2/3*i,r,o]}function _(t,e,n){return{x:t*S(n)-e*T(n),y:t*T(n)+e*S(n)}}function I(t,e,n,i,r,o,s,a,l,h){var u=120*E/180,c=E/180*(+r||0),d=[];if(h)b=h[0],x=h[1],v=h[2],y=h[3];else{t=(p=_(t,e,-c)).x,e=p.y;var f=(t-(a=(p=_(a,l,-c)).x))/2,p=(e-(l=p.y))/2,g=f*f/(n*n)+p*p/(i*i),g=(1<g&&(n*=g=C(g),i*=g),n*n),m=i*i,o=(o==s?-1:1)*C(M((g*m-g*p*p-m*f*f)/(g*p*p+m*f*f)));if(!Number.isFinite(o))return[t,e,a,l,a,l];var v=o*n*p/i+(t+a)/2,y=o*-i*f/n+(e+l)/2,b=L(((e-y)/i).toFixed(9)),x=L(((l-y)/i).toFixed(9));(b=t<v?E-b:b)<0&&(b=2*E+b),(x=a<v?E-x:x)<0&&(x=2*E+x),s&&x<b&&(b-=2*E),!s&&b<x&&(x-=2*E)}M(x-b)>u&&(g=x,m=a,p=l,d=I(a=v+n*S(x=b+u*(s&&b<x?1:-1)),l=y+i*T(x),n,i,r,0,s,m,p,[x,g,v,y])),o=x-b;f=S(b),u=T(b),r=S(x),s=T(x),m=k(o/4),p=4/3*(n*m),g=4/3*(i*m),v=[t,e],y=[t+p*u,e-g*f],b=[a+p*s,l-g*r],x=[a,l];if(y[0]=2*v[0]-y[0],y[1]=2*v[1]-y[1],h)return[y,b,x].concat(d);for(var w=[],A=(d=[y,b,x].concat(d).join().split(",")).length,P=0;P<A;P++)w[P]=P%2?_(d[P-1],d[P],c).y:_(d[P],d[P+1],c).x;return w}function p(t){var e,o,s;if(!(t=Array.isArray(t)&&Array.isArray(t&&t[0])?t:(e=t)?(o={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},s=[],String(e).replace(y,function(t,e,n){var i=[],r=e.toLowerCase();for(n.replace(b,function(t,e){e&&i.push(+e)}),"m"===r&&2<i.length&&(s.push([e].concat(i.splice(0,2))),r="l",e="m"===e?"l":"L");o[r]<=i.length&&(s.push([e].concat(i.splice(0,o[r]))),o[r]););}),s):null)||!t.length)return[["M",0,0]];for(var n=[],i=0,r=0,a=0,l=0,h=t.length,u=0;u<h;u++){var c,d,f=[],p=(n.push(f),t[u]),g=p[0];if(g!=g.toUpperCase())switch(f[0]=g.toUpperCase(),f[0]){case"A":f[1]=p[1],f[2]=p[2],f[3]=p[3],f[4]=p[4],f[5]=p[5],f[6]=+p[6]+i,f[7]=+p[7]+r;break;case"V":f[1]=+p[1]+r;break;case"H":f[1]=+p[1]+i;break;case"M":for(a=+p[1]+i,l=+p[2]+r,c=p.length,d=1;d<c;d++)f[d]=+p[d]+(d%2?i:r);break;default:for(c=p.length,d=1;d<c;d++)f[d]=+p[d]+(d%2?i:r)}else for(var m=p.length,v=0;v<m;v++)f[v]=p[v];switch(f[0]){case"Z":i=+a,r=+l;break;case"H":i=f[1];break;case"V":r=f[1];break;case"M":a=f[f.length-2],l=f[f.length-1],i=f[f.length-2],r=f[f.length-1];break;default:i=f[f.length-2],r=f[f.length-1]}}return n}function g(t){var e=p(t),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};for(var i=[],r="",o="",s=e.length,a=0;a<s;a++){"C"!==(r=e[a]?e[a][0]:r)&&(i[a]=r,0<a)&&(o=i[a-1]),e[a]=((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(I.apply(0,[e.x,e.y].concat(t.slice(1))));break;case"S":r="C"===n||"S"===n?(i=2*e.x-e.bx,2*e.y-e.by):(i=e.x,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(f(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(f(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})(e[a],n,o),"A"!==i[a]&&"C"===r&&(i[a]="C"),u=h=l=void 0;var l=e,h=a;if(7<l[h].length){l[h].shift();for(var u=l[h];u.length;)i[h]="A",l.splice(h++,0,["C"].concat(u.splice(0,6)));l.splice(h,1),s=e.length}var c=e[a],d=c.length;n.x=c[d-2],n.y=c[d-1],n.bx=parseFloat(c[d-4])||n.x,n.by=parseFloat(c[d-3])||n.y}return e[0][0]&&"M"===e[0][0]||e.unshift(["M",0,0]),e}return N.createSVGMatrix=function(t){var e,n=d.createSVGMatrix();for(e in t)n[e]=t[e];return n},N.createSVGTransform=function(t){return N.isUndefined(t)?d.createSVGTransform():(t instanceof SVGMatrix||(t=N.createSVGMatrix(t)),d.createSVGTransformFromMatrix(t))},N.createSVGPoint=function(t,e){var n=d.createSVGPoint();return n.x=t,n.y=e,n},N.transformRect=function(t,e){var n=d.createSVGPoint(),i=(n.x=t.x,n.y=t.y,n.matrixTransform(e)),r=(n.x=t.x+t.width,n.y=t.y,n.matrixTransform(e)),o=(n.x=t.x+t.width,n.y=t.y+t.height,n.matrixTransform(e)),t=(n.x=t.x,n.y=t.y+t.height,n.matrixTransform(e)),n=l(i.x,r.x,o.x,t.x),e=a(i.x,r.x,o.x,t.x),s=l(i.y,r.y,o.y,t.y),i=a(i.y,r.y,o.y,t.y);return new tt(n,s,e-n,i-s)},N.transformPoint=function(t,e){return new A(N.createSVGPoint(t.x,t.y).matrixTransform(e))},N.transformLine=function(t,e){return new P(N.transformPoint(t.start,e),N.transformPoint(t.end,e))},N.transformPolyline=function(t,e){for(var n=t instanceof x?t.points:t,i=[],r=0,o=(n=N.isArray(n)?n:[]).length;r<o;r++)i[r]=N.transformPoint(n[r],e);return new x(i)},N.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},N.createSlicePathData=function(t,e,n,i){var r=2*h-1e-6,o=(i<n&&(o=n,n=i,i=o),i-n),s=o<h?"0":"1",a=u(n),n=c(n),l=u(i),i=c(i);return r<=o?t?"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"M0,"+t+"A"+t+","+t+" 0 1,0 0,"+-t+"A"+t+","+t+" 0 1,0 0,"+t+"Z":"M0,"+e+"A"+e+","+e+" 0 1,1 0,"+-e+"A"+e+","+e+" 0 1,1 0,"+e+"Z":t?"M"+e*a+","+e*n+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*i+"L"+t*l+","+t*i+"A"+t+","+t+" 0 "+s+",0 "+t*a+","+t*n+"Z":"M"+e*a+","+e*n+"A"+e+","+e+" 0 "+s+",1 "+e*l+","+e*i+"L0,0Z"},N.mergeAttrs=function(t,e){for(var n in e)"class"===n?t[n]=t[n]?t[n]+" "+e[n]:e[n]:"style"===n?N.isObject(t[n])&&N.isObject(e[n])?t[n]=N.mergeAttrs(t[n],e[n]):N.isObject(t[n])?t[n]=N.mergeAttrs(t[n],N.styleToObject(e[n])):N.isObject(e[n])?t[n]=N.mergeAttrs(N.styleToObject(t[n]),e[n]):t[n]=N.mergeAttrs(N.styleToObject(t[n]),N.styleToObject(e[n])):t[n]=e[n];return t},N.annotateString=function(t,e,n){e=e||[];for(var i,r,o=(n=n||{}).offset||0,s=[],a=[],l=0;l<t.length;l++){for(var h=a[l]=t[l],u=0;u<e.length;u++){var c=e[u];c.start+o<=l&&l<c.end+o&&(N.isObject(h)?h.attrs=N.mergeAttrs(N.mergeAttrs({},h.attrs),c.attrs):h=a[l]={t:t[l],attrs:c.attrs},n.includeAnnotationIndices)&&(h.annotations||(h.annotations=[])).push(u)}(r=a[l-1])?N.isObject(h)&&N.isObject(r)?JSON.stringify(h.attrs)===JSON.stringify(r.attrs)?i.t+=h.t:(s.push(i),i=h):i=N.isObject(h)||N.isObject(r)?(s.push(i),h):(i||"")+h:i=h}return i&&s.push(i),s},N.findAnnotationsAtIndex=function(t,e){var n=[];return t&&t.forEach(function(t){t.start<e&&e<=t.end&&n.push(t)}),n},N.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},N.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},N.convertLineToPathData=function(t){return["M",(t=N(t)).attr("x1"),t.attr("y1"),"L",t.attr("x2"),t.attr("y2")].join(" ")},N.convertPolygonToPathData=function(t){t=N.getPointsFromSvgNode(t);return 0===t.length?null:N.svgPointsToPath(t)+" Z"},N.convertPolylineToPathData=function(t){t=N.getPointsFromSvgNode(t);return 0===t.length?null:N.svgPointsToPath(t)},N.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")},N.getPointsFromSvgNode=function(t){var e=[],n=(t=N.toNode(t)).points;if(n)for(var i=0,r=n.numberOfItems;i<r;i++)e.push(n.getItem(i));return e},N.KAPPA=.551784,N.convertCircleToPathData=function(t){t=N(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,t=parseFloat(t.attr("r")),i=t*N.KAPPA;return["M",e,n-t,"C",e+i,n-t,e+t,n-i,e+t,n,"C",e+t,n+i,e+i,n+t,e,n+t,"C",e-i,n+t,e-t,n+i,e-t,n,"C",e-t,n-i,e-i,n-t,e,n-t,"Z"].join(" ")},N.convertEllipseToPathData=function(t){t=N(t);var e=parseFloat(t.attr("cx"))||0,n=parseFloat(t.attr("cy"))||0,i=parseFloat(t.attr("rx")),t=parseFloat(t.attr("ry"))||i,r=i*N.KAPPA,o=t*N.KAPPA;return["M",e,n-t,"C",e+r,n-t,e+i,n-o,e+i,n,"C",e+i,n+o,e+r,n+t,e,n+t,"C",e-r,n+t,e-i,n+o,e-i,n,"C",e-i,n-o,e-r,n-t,e,n-t,"Z"].join(" ")},N.convertRectToPathData=function(t){return t=N(t),N.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})},N.rectToPath=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=l(t.rx||t["top-rx"]||0,i/2),s=l(t.rx||t["bottom-rx"]||0,i/2),a=l(t.ry||t["top-ry"]||0,r/2),t=l(t.ry||t["bottom-ry"]||0,r/2),s=o||s||a||t?["M",e,n+a,"v",r-a-t,"a",s,t,0,0,0,s,t,"h",i-2*s,"a",s,t,0,0,0,s,-t,"v",-(r-t-a),"a",o,a,0,0,0,-o,-a,"h",-(i-2*o),"a",o,a,0,0,0,-o,a,"Z"]:["M",e,n,"H",e+i,"V",n+r,"H",e,"V",n,"Z"];return s.join(" ")},N.normalizePathData=(t="\t\n\v\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",y=new RegExp("([a-z])["+t+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+t+"]*,?["+t+"]*)+)","ig"),b=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+t+"]*,?["+t+"]*","ig"),t=Math,E=t.PI,T=t.sin,S=t.cos,k=t.tan,L=t.asin,C=t.sqrt,M=t.abs,function(t){return g(t).join(",").split(",").join(" ")}),N.namespace=O,N.g=br,N})();function Ma(t){let e=t.length;for(;e--;)_a(t[e])}function _a(t){L.event.remove(t),ba.remove(t),xa.remove(t)}function Na(e){for(let t=0;t<e.length;t++){var n=e[t];n.parentNode&&n.parentNode.removeChild(n)}}let Oa={};function Ra(e,n,i){for(let t=0;t<n.length;t++){var r=n[t];R.prototype[e].apply({node:r},i)}}["width","height","top","bottom","left","right","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","margin","marginTop","marginBottom","marginLeft","marginRight"].forEach(t=>{Oa[t]=!0});let Fa={remove:function(){for(let t=0;t<this.length;t++){var e=this[t];_a(e),Ma(e.getElementsByTagName("*"))}return Na(this),this},detach:function(){return Na(this),this},empty:function(){for(let t=0;t<this.length;t++){var e=this[t];1===e.nodeType&&(Ma(e.getElementsByTagName("*")),e.textContent="")}return this},clone:function(){var e=[];for(let t=0;t<this.length;t++)e.push(this[t].cloneNode(!0));return this.pushStack(e)},html:function(t){var[e]=this;if(!e)return null;if(0===arguments.length)return e.innerHTML;if(void 0!==t){if(Ma(e.getElementsByTagName("*")),"string"!=typeof t&&"number"!=typeof t)return e.innerHTML="",this.append(t);e.innerHTML=t}return this},append:function(){let[e]=this;if(e){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];n.forEach(t=>{t&&("string"==typeof t?e.append(...L.parseHTML(t)):"[object Object]"===t.toString()?this.append(...Array.from(t)):Array.isArray(t)?this.append(...t):e.appendChild(t))})}return this},prepend:function(){let[e]=this;if(e){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];n.forEach(t=>{t&&("string"==typeof t?e.prepend(...L.parseHTML(t)):"[object Object]"===t.toString()?this.prepend(...Array.from(t)):Array.isArray(t)?this.prepend(...t):e.insertBefore(t,e.firstChild))})}return this},appendTo:function(t){return L(t).append(this),this},prependTo:function(t){return L(t).prepend(this),this},css:function(t,e){let n;if("string"==typeof t){var i;if(void 0===e)return[i]=this,i?i.style[t]:null;n={[t]:e}}else{if(!t)throw new Error("no styles provided");n=t}for(let e in n)if(n.hasOwnProperty(e))for(let t=0;t<this.length;t++)r=this[t],o=e,"number"==typeof(s=n[e])&&Oa[ga(o)]&&(s+="px"),r.style[o]=s;var r,o,s;return this},data:function(e,n){var t;if(arguments.length<2)return[t]=this,t?void 0===e?t.dataset:t.dataset[e]:null;for(let t=0;t<this.length;t++)this[t].dataset[e]=n;return this},removeClass:function(){return Ra("removeClass",this,arguments),this},addClass:function(){return Ra("addClass",this,arguments),this},toggleClass:function(){return Ra("toggleClass",this,arguments),this},hasClass:function(){var[t]=this;return!!t&&R.prototype.hasClass.apply({node:t},arguments)},children:function(n){var i=[];for(let e=0;e<this.length;e++){var r=this[e];let t=Array.from(r.children);"string"==typeof n&&(t=t.filter(t=>t.matches(n))),i.push(...t)}return this.pushStack(i)},closest:function(e){var n=[];for(let t=0;t<this.length;t++){var i,r=this[t];"string"==typeof e?(i=r.closest(e))&&n.push(i):([i]=L(e),i&&i.contains(r)&&n.push(i))}return this.pushStack(n)},on:function(t,e,n,i){return L.event.on(this,t,e,n,i),this},one:function(t,e,n,i){return L.event.on(this,t,e,n,i,1),this},off:function(e,n,i){var t;if(e&&e.preventDefault&&e.handleObj)t=e.handleObj,L(e.delegateTarget).off(t.namespace?t.origType+"."+t.namespace:t.origType,t.selector,t.handler);else if("object"==typeof e)for(var r in e)this.off(r,n,e[r]);else{!1!==n&&"function"!=typeof n||(i=n,n=void 0);for(let t=0;t<this.length;t++)L.event.remove(this[t],e,i,n)}return this},width:function(){var t,e,[n]=this;return n===window?n.document.documentElement.clientWidth:n?(t=window.getComputedStyle(n),n=n.offsetWidth,e=parseFloat(t.borderTopWidth),n-parseFloat(t.borderBottomWidth)-e-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom)):void 0},height:function(){var t,[e]=this;return e===window?e.document.documentElement.clientHeight:e?(t=window.getComputedStyle(e),e.offsetHeight-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth)-parseFloat(t.paddingLeft)-parseFloat(t.paddingRight)):void 0},position:function(){var[i]=this;if(i){var r,o=L(i);let t,e,n={top:0,left:0};if("fixed"===o.css("position"))e=i.getBoundingClientRect();else{e=o.offset(),r=i.ownerDocument,t=i.offsetParent||r.documentElement;for(var s=t=>{t=t.style.position;return!t||"static"===t};t&&t!==r.documentElement&&s(t);)t=t.offsetParent||r.documentElement;t&&t!==i&&1===t.nodeType&&!s(t)&&(o=window.getComputedStyle(t),a=parseFloat(o.borderTopWidth)||0,o=parseFloat(o.borderLeftWidth)||0,(n=L(t).offset()).top+=a,n.left+=o)}var a=parseFloat(window.getComputedStyle(i).marginTop)||0,o=parseFloat(window.getComputedStyle(i).marginLeft)||0;return{top:e.top-n.top-a,left:e.left-n.left-o}}},offset:function(t){var e,n,[i]=this;return void 0===t?i?i.getClientRects().length?{top:(e=i.getBoundingClientRect()).top+window.scrollY,left:e.left+window.scrollX}:{top:0,left:0}:null:(i&&("static"===(e=window.getComputedStyle(i)).position&&this.css("position","relative"),i=this.offset(),n=t.top-i.top,t=t.left-i.left,this.css({top:(parseFloat(e.top)||0)+n+"px",left:(parseFloat(e.left)||0)+t+"px"})),this)}},Ia="animationFrameId",Va={};Va["transition-property"]=Va["transition-duration"]=Va["transition-delay"]=Va["transition-timing-function"]=Va["animation-name"]=Va["animation-duration"]=Va["animation-delay"]=Va["animation-timing-function"]="";let Ba={animate:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};this.stop();for(let t=0;t<this.length;t++)!function(a,l){let t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},{duration:h=400,easing:u="ease-in-out",delay:c=0,complete:d}=t,e=setTimeout(function(){let e=L(a),n=!1,i="transitionend";h/=1e3,c/=1e3;var t={};if("string"==typeof l)t["animation-name"]=l,t["animation-duration"]=h+"s",t["animation-delay"]=c+"s",t["animation-timing-function"]=u,i="animationend";else{var r,o=[];for(r in l)l.hasOwnProperty(r)&&(t[r]=l[r],o.push(r));0<h&&(t["transition-property"]=o.join(", "),t["transition-duration"]=h+"s",t["transition-delay"]=c+"s",t["transition-timing-function"]=u)}let s=function(t){if(t){if(t.target!==t.currentTarget)return;t.target.removeEventListener(i,s)}else a.removeEventListener(i,s);n=!0,e.css(Va),d&&d.call(a)};if(0<h){a.addEventListener(i,s);let t=setTimeout(function(){n||s(null)},1e3*(h+c)+25);ba.set(a,Ia,{id:t,stop:()=>{clearTimeout(t),a.removeEventListener(i,s)}})}e.css(t),h<=0&&s(null)});ba.set(a,Ia,{stop:()=>clearTimeout(e)})}(this[t],e,n);return this},stop:function(){for(let t=0;t<this.length;t++){var e=this[t],n=ba.get(e,Ia);n&&(n.stop(),ba.remove(e,Ia))}return this.css(Va),this}},Da={outerWidth:"offsetWidth",outerHeight:"offsetHeight",innerWidth:"clientWidth",innerHeight:"clientHeight",scrollLeft:"scrollLeft",scrollTop:"scrollTop",val:"value",text:"textContent"},za={disabled:"disabled",value:"value",text:"textContent"};function ja(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,Ua.classNamePrefix.length)!==Ua.classNamePrefix?Ua.classNamePrefix+t:t}).join(" ")}let Ga={prop:function(e,n){if(!e)throw new Error("no property provided");var t;if(1===arguments.length)return[t]=this,t?t[e]:null;if(void 0!==n)for(let t=0;t<this.length;t++)this[t][e]=n;return this},attr:function(t,e){let n;if("string"==typeof t){var i;if(void 0===e)return[i]=this,i?i.getAttribute(t):null;n={[t]:e}}else{if(!t)throw new Error("no attributes provided");n=t}for(var r in n)if(n.hasOwnProperty(r)){let e=n[r];if(za[r])this.prop(za[r],e);else for(let t=0;t<this.length;t++)null===e?this[t].removeAttribute(r):this[t].setAttribute(r,e)}return this}},Ua=(Object.keys(Da).forEach(i=>{Ga[i]=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return this.prop(Da[i],...e)}}),{useCSSSelectors:!1,classNamePrefix:"joint-",defaultTheme:"default",doubleTapInterval:300}),Ha=Object.create(null),qa=(Ha.load={noBubble:!0},[["mouseenter","mouseover"],["mouseleave","mouseout"],["pointerenter","pointerover"],["pointerleave","pointerout"]].forEach(t=>{let[e,r]=t;Ha[e]={delegateType:r,bindType:r,handle:function(t){var e=t.relatedTarget,n=t.handleObj;let i;return e&&this.contains(e)||(t.type=n.origType,i=n.handler.apply(this,arguments),t.type=r),i}}}),Ua.doubleTapInterval);Ha.dbltap={bindType:"touchend",delegateType:"touchend",handle:function(t){var{handleObj:e,target:n}=t,n=L.data.create(n),i=(new Date).getTime(),r="lastTouch"in n?i-n.lastTouch:0;if(r<qa&&30<r){n.lastTouch=null,t.type=e.origType;for(var o=arguments.length,s=new Array(1<o?o-1:0),a=1;a<o;a++)s[a-1]=arguments[a];e.handler.call(this,t,...s)}else n.lastTouch=i}},Object.assign(L.fn,Fa),Object.assign(L.fn,Ba),Object.assign(L.fn,Ga),Object.assign(L.event.special,Ha);function $a(t,e){let d={},f={},p=R.namespace.svg;var e=e||p,n=document.createDocumentFragment();function g(e,n,i){for(let t=0;t<e.length;t++){var r=e[t];if("string"==typeof r){var o=document.createTextNode(r);n.appendChild(o)}else{if(!r.hasOwnProperty("tagName"))throw new Error("json-dom-parser: missing tagName");var o=r.tagName,s=r.hasOwnProperty("namespaceURI")?r.namespaceURI:i,a=document.createElementNS(s,o),l=s===p,h=(l?R:L)(a),u=r.attributes,u=(u&&h.attr(u),r.style);if(u&&L(a).css(u),r.hasOwnProperty("className")&&(u=r.className,l?a.className.baseVal=u:a.className=u),r.hasOwnProperty("textContent")&&(a.textContent=r.textContent),r.hasOwnProperty("selector")){l=r.selector;if(d[l])throw new Error("json-dom-parser: selector must be unique");d[l]=a,h.attr("joint-selector",l)}if(r.hasOwnProperty("groupSelector")){let n=r.groupSelector;Array.isArray(n)||(n=[n]);for(let e=0;e<n.length;e++){var c=n[e];let t=f[c];(t=t||(f[c]=[])).push(a)}}n.appendChild(a);u=r.children;Array.isArray(u)&&g(u,a,s)}}}return g(t,n,e),{fragment:n,selectors:d,groupSelectors:f}}function Wa(e){let n=0;if(0!==e.length)for(let t=0;t<e.length;t++){var i=e.charCodeAt(t);n=(n<<5)-n+i,n&=n}return n}function Ya(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}function Xa(t,e){return("constructor"!==(e="string"!=typeof e&&"number"!=typeof e?String(e):e)||"function"!=typeof t[e])&&"__proto__"!==e}function Za(e,t,n,i){var r=Array.isArray(t)?t:t.split(i||"/"),o=r.length-1;let s=e,a=0;for(;a<o;a++){var l=r[a];if(!Xa(s,l))return e;let t=s[l];s=t||(s[l]={})}return s[r[o]]=n,e}function Ja(t,e,n){var i=Array.isArray(e)?e:e.split(n||"/"),r=i.length-1;let o=t,s=0;for(;s<r;s++){var a=i[s];if(!Xa(o,a))return t;a=o[a];if(!a)return t;o=a}return delete o[i[r]],t}function Ka(t,e,n){e=e||"/";var i,r={};for(i in t)if(t.hasOwnProperty(i)){var o="object"==typeof t[i];if(o=o&&n&&n(t[i])?!1:o){var s,a=Ka(t[i],e,n);for(s in a)a.hasOwnProperty(s)&&(r[i+e+s]=a[s])}else r[i]=t[i]}return r}function Qa(){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)})}function tl(t){return tl.id=tl.id||1,void 0===t?"j_"+tl.id++:(t.id=void 0===t.id?"j_"+tl.id++:t.id,t.id)}var el,nl;function C(t){if(!t.normalized){var{originalEvent:e,target:n}=t,i=e&&e.changedTouches&&e.changedTouches[0];if(i)for(var r in i)void 0===t[r]&&(t[r]=i[r]);n&&(e=n.correspondingUseElement)&&(t.target=e),t.normalized=!0}return t}function il(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}}function rl(t,e){return e<t?e:t<-e?-e:t}function ol(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 E(e)&&(i=e);return n=i,null===(e=(n=new RegExp("(?:\\d+(?:\\.\\d+)*)("+n+")$").exec(t))?n[1]:null)?null:(r.unit=e,r)}(nl="undefined"!=typeof window?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame:nl)||(el=0,nl=function(t){var e=(new Date).getTime(),n=Math.max(0,16-(e-el)),i=setTimeout(function(){t(e+n)},n);return el=e+n,i});let sl=function(t,e){for(var n=arguments.length,i=new Array(2<n?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return nl(void 0!==e?t.bind(e,...i):t)},al=(c="undefined"!=typeof window,Rh=(Rh=c?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.msCancelAnimationFrame||window.msCancelRequestAnimationFrame||window.oCancelAnimationFrame||window.oCancelRequestAnimationFrame||window.mozCancelAnimationFrame||window.mozCancelRequestAnimationFrame:Rh)||clearTimeout,c?Rh.bind(window):Rh),ll=function(t){return E(t)&&"%"===t.slice(-1)},hl=0;function ul(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}}function cl(t,e){var n,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},o=e.width,s=e.height,e=r.svgDocument||R("svg").node,a=R("tspan").node,l=R("text").attr(i).append(a).node,h=document.createTextNode(""),u=(l.style.opacity=0,l.style.display="block",a.style.display="block",a.appendChild(h),e.appendChild(l),r.svgDocument||document.body.appendChild(e),r.preserveSpaces),c=r.separator||""===r.separator?r.separator:" ",d="string"==typeof c?c:" ",f=r.eol||"\n",p=r.hyphen?new RegExp(r.hyphen):/[^\w\d\u00C0-\u1FFF\u2800-\uFFFD]/,g=r.maxLineCount,m=(qs(g)||(g=1/0),t.split(c)),v=[],y=[];u&&R(a).attr("xml:space","preserve");for(var b=0,x=0,w=m.length;b<w;b++){var A=m[b];if((A||u)&&"string"==typeof A){var P=!1;if(f&&0<=A.indexOf(f)){if(1<A.length){var E=((t,n)=>{var i=t.split(n);let r=1;for(let t=0,e=i.length-1;t<e;t++){var o=[];(0<t||""!==i[0])&&o.push(hl),o.push(n),(t<e-1||""!==i[e])&&o.push(hl),i.splice(r,0,...o),r+=o.length+1}return i.filter(t=>""!==t)})(m[b],f);m.splice(b,1,...E),b--,w=m.length;continue}if(u&&"string"==typeof m[b-1]){m.splice(b,hl,"",hl),w+=2,b--;continue}y[++x]=u&&"string"!=typeof m[b+1]?void 0:"",P=!0}if(!P){let t;if(t=u?void 0!==y[x]?y[x]+d+A:A:y[x]?y[x]+d+A:A,h.data=t,a.getComputedTextLength()<=o)y[x]=t,(T||n)&&(v[x++]=!0,n=T=0);else{if(!y[x]||T){var E=!!T,T=A.length-1;if(E||!T){if(!T){if(!y[x]){y=[];break}m.splice(b,2,A+m[b+1]),w--,v[x++]=!0,b--;continue}m[b]=A.substring(0,T);var S=m[b+1];m[b+1]=A.substring(T)+(void 0===S||S===hl?"":S)}else n?(m.splice(b,2,m[b]+m[b+1]),n=0):(-1<(S=A.search(p))&&S!==A.length-1&&0!==S&&(n=S+1,T=0),m.splice(b,1,A.substring(0,n||T),A.substring(n||T)),w++),x&&!v[x-1]&&x--;u&&""===y[x]||b--;continue}x++,b--}}var k,L=null;if(y.length>g?L=g-1:void 0!==s&&(k=void 0===k&&""!==h.data?"auto"===i.lineHeight?ul({value:1.5,unit:"em"},l):ul(ol(i.lineHeight,["em","px",""]),l):k)*y.length>s&&(L=Math.floor(s/k)-1),null!==L){y.splice(L+1);var C=r.ellipsis;if(!C||L<0)break;"string"!=typeof C&&(C="\u2026");var M=y[L];if(!M&&!P)break;var _,N,O=M.length;do{if(N=M[O],_=M.substring(0,O),N?N.match(c)&&(_+=N):_+=d,_+=C,h.data=_,a.getComputedTextLength()<=o){y[L]=_;break}}while(0<=--O);break}}}return r.svgDocument?e.removeChild(l):document.body.removeChild(e),y.join(f)}function dl(t,e){var n;window.navigator.msSaveBlob?window.navigator.msSaveBlob(t,e):(t=window.URL.createObjectURL(t),(n=document.createElement("a")).href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(t))}function fl(t){t=t.replace(/\s/g,"");for(var e=(t=decodeURIComponent(t)).indexOf(","),n=t.slice(0,e),i=n.split(":")[1].split(";")[0],t=t.slice(e+1),r=0<=n.indexOf("base64")?atob(t):unescape(encodeURIComponent(t)),o=new Uint8Array(r.length),s=0;s<r.length;s++)o[s]=r.charCodeAt(s);return new Blob([o],{type:i})}function pl(t,e){var n=(t=L(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(e);for(var i=0;i<n.length;i++)n[i].call(t[i]);return t}let gl=function(t){var e,n,i,r;return Object(t)!==t?(r=0,{top:r=isFinite(t)?+t:r,right:r,bottom:r,left:r}):(e=n=i=r=0,isFinite(t.vertical)&&(e=i=+t.vertical),isFinite(t.horizontal)&&(n=r=+t.horizontal),{top:e=isFinite(t.top)?+t.top:e,right:n=isFinite(t.right)?+t.right:n,bottom:i=isFinite(t.bottom)?+t.bottom:i,left:r=isFinite(t.left)?+t.left:r})},ml={linear:function(t){return t},quad:function(t){return t*t},cubic:function(t){return t*t*t},inout:function(t){var e,n;return t<=0?0:1<=t?1:(n=(e=t*t)*t,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,n=0,i=1;;n+=i,i/=2){1;if((7-4*n)/11<=t)return-(e=(11-6*n-11*t)/4)*e+i*i}},reverse:function(e){return function(t){return 1-e(1-t)}},reflect:function(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}},clamp:function(e,n,i){return n=n||0,i=i||1,function(t){t=e(t);return t<n?n:i<t?i:t}},back:function(e){return e=e||1.70158,function(t){return t*t*((e+1)*t-e)}},elastic:function(e){return e=e||1.5,function(t){return Math.pow(2,10*(t-1))*Math.cos(20*Math.PI*e/3*t)}}},vl={number:function(e,t){var n=t-e;return function(t){return e+n*t}},object:function(r,o){var s=Object.keys(r);return function(t){for(var e,n={},i=s.length-1;-1!=i;i--)n[e=s[i]]=r[e]+(o[e]-r[e])*t;return n}},hexColor:function(t,e){var t=parseInt(t.slice(1),16),e=parseInt(e.slice(1),16),n=255&t,i=(255&e)-n,r=65280&t,o=(65280&e)-r,s=16711680&t,a=(16711680&e)-s;return function(t){return"#"+(1<<24|n+i*t&255|r+o*t&65280|s+a*t&16711680).toString(16).slice(1)}},unit:function(e,t){var n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,i=n.exec(e),n=n.exec(t),t=n[1].indexOf("."),r=0<t?n[1].length-t-1:0,o=(e=+i[1],+n[1]-e),s=i[2];return function(t){return(e+o*t).toFixed(r)+s}}},yl={outline:function(t){var e=Number.isFinite(t.margin)?t.margin:2,n=Number.isFinite(t.width)?t.width:1;return bl('<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 bl('<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 bl('<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 bl(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){t=Number.isFinite(t.amount)?t.amount:1;return bl('<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-t),b:.7152-.7152*(1-t),c:.0722-.0722*(1-t),d:.2126-.2126*(1-t),e:.7152+.2848*(1-t),f:.0722-.0722*(1-t),g:.2126-.2126*(1-t),h:.0722+.9278*(1-t)})},sepia:function(t){t=Number.isFinite(t.amount)?t.amount:1;return bl('<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-t),b:.769-.769*(1-t),c:.189-.189*(1-t),d:.349-.349*(1-t),e:.686+.314*(1-t),f:.168-.168*(1-t),g:.272-.272*(1-t),h:.534-.534*(1-t),i:.131+.869*(1-t)})},saturate:function(t){t=Number.isFinite(t.amount)?t.amount:1;return bl('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>')({amount:1-t})},hueRotate:function(t){return bl('<filter><feColorMatrix type="hueRotate" values="${angle}"/></filter>')({angle:t.angle||0})},invert:function(t){t=Number.isFinite(t.amount)?t.amount:1;return bl('<filter><feComponentTransfer><feFuncR type="table" tableValues="${amount} ${amount2}"/><feFuncG type="table" tableValues="${amount} ${amount2}"/><feFuncB type="table" tableValues="${amount} ${amount2}"/></feComponentTransfer></filter>')({amount:t,amount2:1-t})},brightness:function(t){return bl('<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){t=Number.isFinite(t.amount)?t.amount:1;return bl('<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:t,amount2:.5-t/2})}};h={number:function(t,e,o){o=o||{currency:["$",""],decimal:".",thousands:",",grouping:[3]};var t=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i.exec(t),n=t[1]||" ",i=t[2]||">",r=t[3]||"",s=t[4]||"",a=t[5],l=+t[6],h=t[7],u=t[8],c=t[9],d=1,f="",p="",g=!1,u=u&&+u.substring(1);switch((a||"0"===n&&"="===i)&&(a=n="0",i="=",h)&&(l-=Math.floor((l-1)/4)),c){case"n":h=!0,c="g";break;case"%":d=100,p="%",c="f";break;case"p":d=100,p="%",c="r";break;case"b":case"o":case"x":case"X":"#"===s&&(f="0"+c.toLowerCase());break;case"c":case"d":g=!0,u=0;break;case"s":d=-1,c="r"}"$"===s&&(f=o.currency[0],p=o.currency[1]),"r"!=c||u||(c="g"),null!=u&&("g"==c?u=Math.max(1,Math.min(21,u)):"e"!=c&&"f"!=c||(u=Math.max(0,Math.min(20,u))));t=a&&h;if(g&&e%1)return"";var r=e<0||0===e&&1/e<0?(e=-e,"-"):r,m=p,v=(d<0?(e=(v=this.prefix(e,u)).scale(e),m=v.symbol+p):e*=d,(e=this.convert(c,e,u)).lastIndexOf(".")),y=v<0?e:e.substring(0,v),v=v<0?"":o.decimal+e.substring(v+1);function b(t){for(var e=t.length,n=[],i=0,r=o.grouping[0];0<e&&0<r;)n.push(t.substring(e-=r,e+r)),r=o.grouping[i=(i+1)%o.grouping.length];return n.reverse().join(o.thousands)}!a&&h&&o.grouping&&(y=b(y));a=f.length+y.length+v.length+(t?0:r.length),l=a<l?new Array(a=l-a+1).join(n):"";return r+=f,e=(y=t?b(l+y):y)+v,("<"===i?r+e+l:">"===i?l+r+e:"^"===i?l.substring(0,a>>=1)+r+e+l.substring(a):r+(t?e:l+e))+m},string:function(t,e){for(var n,i="{",r=!1,o=[];-1!==(n=t.indexOf(i));){if(l=t.slice(0,n),r){for(var s,a=(s=l.split(":")).shift().split("."),l=e,h=0;h<a.length;h++)l=l[a[h]];s.length&&(l=this.number(s,l))}o.push(l),t=t.slice(n+1),i=(r=!r)?"}":"{"}return o.push(t),o.join("")},convert:function(t,e,n){switch(t){case"b":return e.toString(2);case"c":return String.fromCharCode(e);case"o":return e.toString(8);case"x":return e.toString(16);case"X":return e.toString(16).toUpperCase();case"g":return e.toPrecision(n);case"e":return e.toExponential(n);case"f":return e.toFixed(n);case"r":return(e=this.round(e,this.precision(e,n))).toFixed(Math.max(0,Math.min(20,this.precision(e*(1+1e-15),n))));default:return e+""}},round:function(t,e){return e?Math.round(t*(e=Math.pow(10,e)))/e:Math.round(t)},precision:function(t,e){return e-(t?Math.ceil(Math.log(t)/Math.LN10):1)},prefix:function(t,e){var n=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(function(t,e){var n=Math.pow(10,3*Math.abs(8-e));return{scale:8<e?function(t){return t/n}:function(t){return t*n},symbol:t}}),i=0;return t&&(t<0&&(t*=-1),e&&(t=this.round(t,this.precision(t,e))),i=1+Math.floor(1e-12+Math.log(t)/Math.LN10),i=Math.max(-24,Math.min(24,3*Math.floor((i<=0?i+1:i-1)/3)))),n[8+i/3]}};let bl=function(t){var e=/<%= ([^ ]+) %>|\$\{ ?([^{} ]+) ?\}|\{\{([^{} ]+)\}\}/g;return function(i){return i=i||{},t.replace(e,function(t){for(var e=Array.from(arguments).slice(1,4).find(function(t){return!!t}).split("."),n=i[e.shift()];void 0!==n&&e.length;)n=n[e.shift()];return void 0!==n?n:""})}};function xl(t,e,n){var{maxDepth:n=Number.POSITIVE_INFINITY}=n||{};return function o(s,a,l,h){if(l===h)return{};let u={};return Object.keys(s).forEach(t=>{var e,n,i=s[t],r=a[t];!Array.isArray(i)&&!Array.isArray(r)&&w(i)&&w(r)?(n=o(i,r,e=l+1,h),0<Object.keys(n).length?u[t]=n:0!==l&&e!==h||(u[t]={})):na(i,r)||(u[t]=i)}),u}(t,e,0,n)}function wl(){}function Al(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=Al(t,e,o[s],n[o[s]],r)}else if(n&&kl.test(n))for(o=n.split(kl);s<o.length;s++)e=t(e,o[s],i,r);else e=t(e,n,i,r);return e}function Pl(t,e){var n=this,i=t&&da(t,"constructor")?t.constructor:function(){return n.apply(this,arguments)};return T(i,n,e),i.prototype=Object.assign(Object.create(n.prototype),t),(i.prototype.constructor=i).__super__=n.prototype,i}function El(t,e){var t=t||{},n=(e=e||{},this.preinitialize.apply(this,arguments),this.cid=fa(this.cidPrefix),this.attributes={},e.collection&&(this.collection=e.collection),S(this,"defaults")),t=Ws(T({},n,t),n);this.set(t,e),this.changed={},this.initialize.apply(this,arguments)}var Tl,Sl={},kl=/\s+/,Ll=(Sl.on=function(t,e,n){return this._events=Al(Ll,this._events||{},t,e,{context:n,ctx:this,listening:Tl}),Tl&&(((this._listeners||(this._listeners={}))[Tl.id]=Tl).interop=!1),this},Sl.listenTo=function(t,e,n){if(t){var i=t._listenId||(t._listenId=fa("l")),r=this._listeningTo||(this._listeningTo={}),o=Tl=r[i],r=(o||(this._listenId||(this._listenId=fa("l")),o=Tl=r[i]=new Fl(this,t)),Cl(t,e,n,this));if(Tl=void 0,r)throw r;o.interop&&o.on(e,n)}return this},function(t,e,n,i){var r,o;return n&&(e=t[e]||(t[e]=[]),r=i.context,o=i.ctx,(i=i.listening)&&i.count++,e.push({callback:n,context:r,ctx:r||o,listening:i})),t}),Cl=function(t,e,n,i){try{t.on(e,n,i)}catch(t){return t}},Ml=(Sl.off=function(t,e,n){return this._events&&(this._events=Al(Ml,this._events,t,e,{context:n,listeners:this._listeners})),this},Sl.stopListening=function(t,e,n){var i=this._listeningTo;if(i){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)}ea(i)&&(this._listeningTo=void 0)}return this},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 h=[],u=0;u<l.length;u++){var c=l[u];n&&n!==c.callback&&n!==c.callback._callback||o&&o!==c.context?h.push(c):(c=c.listening)&&c.off(e,n)}h.length?t[e]=h:delete t[e]}return t}if(null!=s)for(r=Object.keys(s);a<r.length;a++)s[r[a]].cleanup()}}),_l=(Sl.once=function(t,e,n){var i=Al(_l,{},t,e,this.off.bind(this));return this.on(i,e="string"==typeof t&&null==n?void 0:e,n)},Sl.listenToOnce=function(t,e,n){e=Al(_l,{},e,n,this.stopListening.bind(this,t));return this.listenTo(t,e)},function(t,e,n,i){var r;return n&&((r=t[e]=Nl(function(){i(e,r),n.apply(this,arguments)}))._callback=n),t}),Nl=function(t){var e;if("function"!=typeof t)throw new TypeError("Expected a function");var n=2;return function(){return 0<--n&&(e=t.apply(this,arguments)),n<=1&&(t=void 0),e}},Ol=(Sl.trigger=function(t){if(this._events){for(var e=Math.max(0,arguments.length-1),n=Array(e),i=0;i<e;i++)n[i]=arguments[i+1];Al(Ol,this._events,t,void 0,n)}return this},function(t,e,n,i){var r,o;return t&&(r=t[e],o=t.all,r&&(o=o&&o.slice()),r&&Rl(r,i),o)&&Rl(o,[e].concat(i)),t}),Rl=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}},Fl=function(t,e){this.id=t._listenId,this.listener=t,this.obj=e,this.interop=!0,this.count=0,this._events=void 0},Il=(Fl.prototype.on=Sl.on,Fl.prototype.off=function(t,e){t=this.interop?(this._events=Al(Ml,this._events,t,e,{context:void 0,listeners:void 0}),!this._events):(this.count--,0===this.count);t&&this.cleanup()},Fl.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},Sl.bind=Sl.on,Sl.unbind=Sl.off,function(i,t,r,o){switch(t){case 1:return function(){return i[r](this[o])};case 2:return function(t){return i[r](this[o],t)};case 3:return function(t,e){return i[r](this[o],Vl(t,this),e)};case 4:return function(t,e,n){return i[r](this[o],Vl(t,this),e,n)};default:return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(this[o]),i[r].apply(i,t)}}}),Vl=function(e,t){return b(e)?e:w(e)&&!t._isModel(e)?Bl(e):E(e)?function(t){return t.get(e)}:e},Bl=function(t){t=t;var e=Ps(is(t,!0));return function(t){return e(t.attributes)}};function Dl(t){t=Qs(t);let r=et(t).reduce(function(t,e){return t[e.id]=e.clone(),t},{});return et(t).forEach(function(t){var e=r[t.id],n=(e.isLink()&&(n=e.source(),i=e.target(),n.id&&r[n.id]&&e.prop("source/id",r[n.id].id),i.id)&&r[i.id]&&e.prop("target/id",r[i.id].id),t.get("parent")),i=(n&&r[n]&&e.set("parent",r[n].id),et(t.get("embeds")).reduce(function(t,e){return r[e]&&t.push(r[e].id),t},[]));ea(i)||e.set("embeds",i)}),r}T(El.prototype,Sl,{changed:null,validationError:null,idAttribute:"id",cidPrefix:"c",preinitialize:function(){},initialize:function(){},toJSON:function(t){return f(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){var i;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,!this._validate(i,n=n||{}))return!1;var r,o,s=n.unset,t=n.silent,a=[],l=this._changing,h=(this._changing=!0,l||(this._previousAttributes=f(this.attributes),this.changed={}),this.attributes),u=this.changed,c=this._previousAttributes;for(r in i)e=i[r],na(h[r],e)||a.push(r),na(c[r],e)?delete u[r]:u[r]=e,s?delete h[r]:h[r]=e;if(this.idAttribute in i&&(o=this.id,this.id=this.get(this.idAttribute),this.trigger("changeId",this,o,n)),!t){a.length&&(this._pending=n);for(var d=0;d<a.length;d++)this.trigger("change:"+a[d],this,h[a[d]],n)}if(!l){if(!t)for(;this._pending;)n=this._pending,this._pending=!1,this.trigger("change",this,n);this._pending=!1,this._changing=!1}}return this},unset:function(t,e){return this.set(t,void 0,T({},e,{unset:!0}))},clear:function(t){var e,n={};for(e in this.attributes)n[e]=void 0;return this.set(n,T({},t,{unset:!0}))},hasChanged:function(t){return null==t?!ea(this.changed):da(this.changed,t)},changedAttributes:function(t){if(!t)return!!this.hasChanged()&&f(this.changed);var e,n,i=this._changing?this._previousAttributes:this.attributes,r={};for(n in t){var o=t[n];na(i[n],o)||(r[n]=o,e=!0)}return!!e&&r},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return f(this._previousAttributes)},clone:function(){return new this.constructor(this.attributes)},isValid:function(t){return this._validate({},T({},t,{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=T({},this.attributes,t);t=this.validationError=this.validate(t,e)||null;return!t||(this.trigger("invalid",this,t,T(e,{validationError:t})),!1)}}),El.extend=Pl;let zl=["checked","selected","disabled","readOnly","contentEditable","value","indeterminate"].reduce((t,e)=>(t[e]=!0,t),{});u={qualify:function(t){return y(t)},set:function(e,t,i){Object.keys(e).forEach(function(t){if(zl[t]&&t in i){let n=e[t];"SELECT"===i.tagName&&Array.isArray(n)?Array.from(i.options).forEach(function(t,e){t.selected=n.includes(t.value)}):i[t]=n}})}};function jl(r,o,s){return function(t,e){var n,i=ll(t),i=(t=parseFloat(t),i&&(t/=100),isFinite(t)&&(n=e[s](),n=i||0<t&&t<1?n[r]+e[o]*t:n[r]+t),A());return i[r]=n||0,i}}function Gl(r,o){return function(t,e){var n=ll(t),i=(t=parseFloat(t),n&&(t/=100),{});return isFinite(t)&&(n=n||0<=t&&t<=1?t*e[o]:Math.max(t+e[o],0),i[r]=n),i}}var Ul,Hl,l={"ref-x":{position:jl("x","width","origin")},"ref-y":{position:jl("y","height","origin")},"ref-dx":{position:jl("x","width","corner")},"ref-dy":{position:jl("y","height","corner")},"ref-width":{set:Gl("width","width")},"ref-height":{set:Gl("height","height")},"ref-rx":{set:Gl("rx","width")},"ref-ry":{set:Gl("ry","height")},"ref-cx":{set:Gl("cx","width")},"ref-cy":{set:Gl("cy","height")},"ref-r-inscribed":{set:(Ul=Gl("r","width"),Hl=Gl("r","height"),function(t,e){return(e.height>e.width?Ul:Hl)(t,e)})},"ref-r-circumscribed":{set:function(t,e){var n,i=ll(t),e=(t=parseFloat(t),i&&(t/=100),Math.sqrt(e.height*e.height+e.width*e.width));return{r:n=isFinite(t)?i||0<=t&&t<=1?t*e:Math.max(t+e,0):n}}}};l.refX=l["ref-x"],l.refY=l["ref-y"],l["ref-x2"]=l["ref-x"],l["ref-y2"]=l["ref-y"],l["ref-width2"]=l["ref-width"],l["ref-height2"]=l["ref-height"],l["ref-r"]=l["ref-r-inscribed"];let ql={x:"x",y:"y",width:"w",height:"h",minimum:"s",maximum:"l",diagonal:"d"};i=Object.keys(ql).map(t=>ql[t]).join(""),s="[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?";let $l=/\s/g,Wl=new RegExp(`^(${s}\\*)?([${i}])(/${s})?([-+]{1,2}${s})?$`,"g");function Yl(t){throw new Error("Invalid calc() expression: "+t)}function Xl(t,e){var n=Wl.exec(t.replace($l,"")),[,t,n,i,r]=(n||Yl(t),Wl.lastIndex=0,n),{x:o,y:s,width:a,height:l}=e;let h=0;switch(n){case ql.width:h=a;break;case ql.height:h=l;break;case ql.x:h=o;break;case ql.y:h=s;break;case ql.minimum:h=Math.min(l,a);break;case ql.maximum:h=Math.max(l,a);break;case ql.diagonal:h=Math.sqrt(l*l+a*a)}return t&&(h*=parseFloat(t)),i&&(h/=parseFloat(i.slice(1))),r&&(h+=(t=>{if(!t)return 0;var[e]=t;switch(e){case"+":return parseFloat(t.substr(1));case"-":return-parseFloat(t.substr(1))}return parseFloat(t)})(r)),h}function Zl(t){return"string"==typeof t&&t.includes("calc")}let Jl="calc(",Kl=Jl.length;function Ql(t,i){let r=t,o=0;for(;;){var s=r.indexOf(Jl,o);if(-1===s)return r;let t=s+Kl,e=1;t:for(;;){switch(r[t]){case"(":e++;break;case")":if(0===--e)break t;break;case void 0:Yl(r)}t++}let n=r.slice(s+Kl,t);Zl(n)&&(n=Ql(n,i));var a=String(Xl(n,i));r=r.slice(0,s)+a+r.slice(t+1),o=s+a.length}}function th(t,e,n){return void 0!==n.text}let eh=["font-weight","font-family","font-size","letter-spacing","text-transform"],nh={"line-height":{qualify:th},"text-vertical-anchor":{qualify:th},"text-path":{qualify:th},annotations:{qualify:th},eol:{qualify:th},"display-empty":{qualify:th},text:{qualify:function(t,e,n){n=n["text-wrap"];return!n||!y(n)},unset:function(t){t.textContent=""},set:function(t,e,n,i){var r="joint-text",o=L.data.get(n,r),s=i["line-height"],a=i["text-vertical-anchor"],l=i["display-empty"],h=i["font-size"],u=i.annotations,c=i.eol,d=i.x;let f=i["text-path"];i=JSON.stringify([t,s,u,a,c,l,f,d,h]);void 0!==o&&o===i||(h&&n.setAttribute("font-size",h),w(f)&&"string"==typeof(o=f.selector)&&(h=this.findNode(o))instanceof SVGPathElement&&(f=T({"xlink:href":"#"+h.id},f)),R(n).text(""+t,{lineHeight:s,annotations:u,textPath:f,x:d,textVerticalAnchor:a,eol:c,displayEmpty:l}),L.data.set(n,r,i))}},"text-wrap":{qualify:y,set:function(t,e,n,i){var r={},o=t.width||0,o=(ll(o)?r.width=e.width*parseFloat(o)/100:Zl(o)?r.width=Number(Ql(o,e)):null===t.width?r.width=1/0:r.width=o<=0?e.width+o:o,t.height||0),o=(ll(o)?r.height=e.height*parseFloat(o)/100:Zl(o)?r.height=Number(Ql(o,e)):null!==t.height&&(r.height=o<=0?e.height+o:o),t.text);if(void 0!==(o=void 0===o?i.text:o)){var s=t.breakText||cl,a=getComputedStyle(n),l={};for(let t=0;t<eh.length;t++){var h=eh[t];h in i&&n.setAttribute(h,i[h]),l[h]=a[h]}l.lineHeight=i["line-height"],s=s(""+o,r,l,{svgDocument:this.paper.svg,ellipsis:t.ellipsis,hyphen:t.hyphen,separator:t.separator,maxLineCount:t.maxLineCount,preserveSpaces:t.preserveSpaces})}else s="";nh.text.set.call(this,s,e,n,i)},FONT_ATTRIBUTES:eh},title:{qualify:function(t,e){return e instanceof SVGElement},unset:function(t){L.data.remove(t,"joint-title");t=t.firstElementChild;t&&t.remove()},set:function(t,e,n){var i="joint-title",r=L.data.get(n,i);void 0!==r&&r===t||(L.data.set(n,i,t),"title"===n.tagName?n.textContent=t:(r=n.firstElementChild)&&"title"===r.tagName?r.textContent=t:((i=document.createElementNS(n.namespaceURI,"title")).textContent=t,n.insertBefore(i,r)))}}};function ih(i,r){var o=new A(1,0);return function(t){var e,n,t=this[i](t);return t?(n=r.rotate?t.vector().vectorAngle(o):0,e=t.start):(e=this.path.start,n=0),0===n?{transform:"translate("+e.x+","+e.y+")"}:{transform:"translate("+e.x+","+e.y+") rotate("+n+")"}}}function rh(){return this.model.isLink()}Ln={connection:{qualify:rh,unset:"d",set:function(e){var{stubs:e=0}=e;let n;if(isFinite(e)&&0!==e){let t;t=e<0?(this.getConnectionLength()+e)/2:e;var e=this.getConnection(),i=this.getConnectionSubdivisions(),r=e.divideAtLength(t,{segmentSubdivisions:i}),e=e.divideAtLength(-t,{segmentSubdivisions:i});r&&e&&(n=r[0].serialize()+" "+e[1].serialize())}return{d:n||this.getSerializedConnection()}}},"at-connection-length-keep-gradient":{qualify:rh,unset:"transform",set:ih("getTangentAtLength",{rotate:!0})},"at-connection-length-ignore-gradient":{qualify:rh,unset:"transform",set:ih("getTangentAtLength",{rotate:!1})},"at-connection-ratio-keep-gradient":{qualify:rh,unset:"transform",set:ih("getTangentAtRatio",{rotate:!0})},"at-connection-ratio-ignore-gradient":{qualify:rh,unset:"transform",set:ih("getTangentAtRatio",{rotate:!1})}};function oh(s,t){var a="joint-shape",l=t&&t.resetOffset;return function(t,e,n){var i=L.data.get(n,a),t=(i&&i.value===t||(i={value:t,shape:t=s(t),shapeBBox:t.bbox()},L.data.set(n,a,i)),i.shape.clone()),n=i.shapeBBox.clone(),i=n.origin(),r=e.origin(),r=(n.x=r.x,n.y=r.y,e.maxRectScaleToFit(n,r)),o=0===n.width||0===e.width?1:r.sx,n=0===n.height||0===e.height?1:r.sy;return t.scale(o,n,i),l&&t.translate(-i.x,-i.y),t}}function sh(t){var i=oh(function(t){return new V(R.normalizePathData(t))},t);return function(t,e,n){return{d:i(t,e,n).serialize()}}}function ah(t){var i=oh(x,t);return function(t,e,n){return{points:i(t,e,n).serialize()}}}Ln["at-connection-length"]=Ln["at-connection-length-keep-gradient"],Ln["at-connection-ratio"]=Ln["at-connection-ratio-keep-gradient"];a={"ref-d-reset-offset":{unset:"d",set:sh({resetOffset:!0})},"ref-d-keep-offset":{unset:"d",set:sh({resetOffset:!1})},"ref-points-reset-offset":{unset:"points",set:ah({resetOffset:!0})},"ref-points-keep-offset":{unset:"points",set:ah({resetOffset:!1})}};function lh(t){var e={},n=t.stroke,n=("string"==typeof n&&(e.stroke=n,e.fill=n),t["stroke-opacity"]);return void 0!==(n=void 0===n?t.opacity:n)&&(e["stroke-opacity"]=n,e["fill-opacity"]=n),e}function hh(t){var e=this.paper;return`url(#${"pattern"===t.type?e.definePattern(t):e.defineGradient(t)})`}a["ref-d"]=a["ref-d-reset-offset"],a["ref-points"]=a["ref-points-reset-offset"];Je={"source-marker":{qualify:y,unset:"marker-start",set:function(t,e,n,i){return t=T(lh(i),t),{"marker-start":"url(#"+this.paper.defineMarker(t)+")"}}},"target-marker":{qualify:y,unset:"marker-end",set:function(t,e,n,i){return t=T(lh(i),{transform:"rotate(180)"},t),{"marker-end":"url(#"+this.paper.defineMarker(t)+")"}}},"vertex-marker":{qualify:y,unset:"marker-mid",set:function(t,e,n,i){return t=T(lh(i),t),{"marker-mid":"url(#"+this.paper.defineMarker(t)+")"}}},fill:{qualify:y,set:hh},stroke:{qualify:y,set:hh},filter:{qualify:y,set:function(t){return"url(#"+this.paper.defineFilter(t)+")"}}};function uh(i,r,o){return function(t,e){var t="middle"===t?e[r]/2:t===o?e[r]:isFinite(t)?-1<t&&t<1?-e[r]*t:-t:ll(t)?e[r]*parseFloat(t)/100:0,n=new A;return n[i]=-(e[i]+t),n}}e={"x-alignment":{offset:uh("x","width","right")},"y-alignment":{offset:uh("y","height","bottom")},"reset-offset":{offset:function(t,e){return t?{x:-e.x,y:-e.y}:{x:0,y:0}}}};function ch(i){return function(t,e,n){n=R(n);n.attr(i)!==t&&n.attr(i,t)}}r={ref:{},href:{set:ch("href")},"xlink:href":{set:ch("xlink:href")},port:{set:function(t){return null===t||void 0===t.id?t:t.id}},style:{qualify:y,set:function(t,e,n){L(n).css(t)}},html:{unset:function(t){L(t).empty()},set:function(t,e,n){L(n).html(t+"")}},props:u};T(r,l),T(r,nh),T(r,Ln),T(r,a),T(r,Je),T(r,e);function dh(t,e){if(Array.isArray(t))return e}let fh=r;function ph(t){for(var e in t){var n=t[e];w(n)&&!Array.isArray(n)&&ea(n)&&delete t[e]}}let gh=El.extend({constructor:function(t,e){var n,i,t=t||{};"function"==typeof this.preinitialize&&this.preinitialize.apply(this,arguments),this.cid=fa("c"),this.attributes={},e&&e.collection&&(this.collection=e.collection),e&&e.parse&&(t=this.parse(t,e)||{}),(n=S(this,"defaults"))&&(i=(!e||!0!==e.mergeArrays)&&dh,t=k({},n,t,i)),this.set(t,e),this.changed={},this.initialize.apply(this,arguments)},translate:function(t,e,n){throw new Error("Must define a translate() method.")},toJSON:function(t){var{ignoreDefaults:t,ignoreEmptyAttributes:e=!1}=t||{};let n=S(this.constructor.prototype,"defaults");if(!1===t){let t=ta(this.attributes);return e&&ph(t),t}let i={};var r=ta(this.attributes);!0===t?i=n:(Array.isArray(t)?t:["attrs"]).forEach(t=>{i[t]=n[t]||{}});let o=xl(r,ua(i,"id","type"),{maxDepth:4});return e&&ph(o),o},initialize:function(t){var 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:Qa,processPorts:function(){var t=this.ports,n={},i=(pa(this.get("attrs"),function(t,e){t&&t.port&&(void 0!==t.port.id?n[t.port.id]=t.port:n[t.port]={id:t.port})}),{});pa(t,function(t,e){n[e]||(i[e]=!0)}),this.graph&&!ea(i)&&(this.graph.getConnectedLinks(this,{inbound:!0}).forEach(function(t){i[t.get("target").port]&&t.remove()}),this.graph.getConnectedLinks(this,{outbound:!0}).forEach(function(t){i[t.get("source").port]&&t.remove()})),this.ports=n},remove:function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},{graph:t,collection:e}=this;if(t){t.startBatch("remove");var i=this.getParentCell(),r=(i&&i.unembed(this,n),this.getEmbeddedCells());for(let t=0,e=r.length;t<e;t++){var o=r[t];o&&o.remove(n)}this.trigger("remove",this,t.attributes.cells,n),t.stopBatch("remove")}else e&&e.remove(this,n);return this},toFront:function(i){var r=this.graph;if(r){let t;(i=Ws(i||{},{foregroundEmbeds:!0})).deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==i.breadthFirst,sortSiblings:i.foregroundEmbeds})).unshift(this):t=[this];var o=i.foregroundEmbeds?t:ra(t,t=>t.z());let n=r.maxZIndex()-t.length+1;r=r.get("cells");let e=r.toArray().indexOf(o[0])!==r.length-t.length;(e=e||o.some(function(t,e){return t.z()!==n+e}))&&(this.startBatch("to-front"),n+=t.length,o.forEach(function(t,e){t.set("z",n+e,i)}),this.stopBatch("to-front"))}return this},toBack:function(r){var o=this.graph;if(o){let t;(r=Ws(r||{},{foregroundEmbeds:!0})).deep?(t=this.getEmbeddedCells({deep:!0,breadthFirst:!1!==r.breadthFirst,sortSiblings:r.foregroundEmbeds})).unshift(this):t=[this];var s=r.foregroundEmbeds?t:ra(t,t=>t.z());let n=o.minZIndex(),e=o.get("cells"),i=0!==e.toArray().indexOf(s[0]);(i=i||s.some(function(t,e){return t.z()!==n+e}))&&(this.startBatch("to-back"),n-=t.length,s.forEach(function(t,e){t.set("z",n+e,r)}),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){let e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=Array.isArray(t)?t:[t];if(!this.canEmbed(n))throw new Error("Recursive embedding not allowed.");if(e.reparent)Qs(n.map(t=>t.getParentCell())).forEach(t=>{t&&t._unembedCells(n,e)});else 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){t=Array.isArray(t)?t:[t];return this._unembedCells(t,e),this},canEmbed:function(t){return(Array.isArray(t)?t:[t]).every(t=>this!==t&&!this.isEmbeddedIn(t))},_embedCells:function(t,e){this.startBatch("embed");let n=T([],this.get("embeds"));t.forEach(t=>{n[t.isLink()?"unshift":"push"](t.id),t.parent(this.id,e)}),this.set("embeds",Qs(n),e),this.stopBatch("embed")},_unembedCells:function(t,e){this.startBatch("unembed"),t.forEach(t=>t.unset("parent",e)),this.set("embeds",oa(this.get("embeds"),...t.map(t=>t.id)),e),this.stopBatch("unembed")},getParentCell:function(){var t=this.parent(),e=this.graph;return t&&e&&e.getCell(t)||null},getAncestors:function(){var t=[];if(this.graph)for(var e=this.getParentCell();e;)t.push(e),e=e.getParentCell();return t},getEmbeddedCells:function(t){if(!this.graph)return[];if((t=t||{}).deep)return t.breadthFirst?this._getEmbeddedCellsBfs(t.sortSiblings):this._getEmbeddedCellsDfs(t.sortSiblings);var e=this.get("embeds");if(ea(e))return[];let n=e.map(this.graph.getCell,this.graph);return n=t.sortSiblings?ra(n,t=>t.z()):n},_getEmbeddedCellsBfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.shift(),i=(e.push(i),i.getEmbeddedCells({sortSiblings:t}));n.push(...i)}return e.shift(),e},_getEmbeddedCellsDfs:function(t){var e=[],n=[];for(n.push(this);0<n.length;){var i=n.pop(),r=(e.push(i),i.getEmbeddedCells({sortSiblings:t}));for(let t=r.length-1;0<=t;--t)n.push(r[t])}return e.shift(),e},isEmbeddedIn:function(t,e){var n=E(t)?t:t.id,i=this.parent();if(e=T({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){return(t=t||{}).deep?et(Dl([this].concat(this.getEmbeddedCells({deep:!0})))):((t=El.prototype.clone.apply(this,arguments)).set(this.getIdAttribute(),this.generateId()),t.unset("embeds"),t.unset("parent"),t)},prop:function(e,n,i){var r=E(e);if(r||Array.isArray(e)){if(1<arguments.length){var o=r?(p=e).split("/"):(p=e.join("/"),e.slice()),s=o[0],a=o.length;let t=i||{};t.propertyPath=p,t.propertyValue=n,t.propertyPathArray=o,"rewrite"in t||(t.rewrite=!1);for(var l=i={},h=s,u=1;u<a;u++)var c=o[u],d=Number.isFinite(r?Number(c):c),l=l[h]=d?[]:{},h=c;var i=Za(i,o,n,"/"),f=k({},this.attributes),p=(t.rewrite&&Ja(f,p,"/"),k(f,i));return this.set(s,p[s],t)}return Ya(this.attributes,e,"/")}let t=n||{};t.propertyPath=null,t.propertyValue=e,t.propertyPathArray=[],"rewrite"in t||(t.rewrite=!1);var g,m={};for(g in e){var v=k({},{changedValue:this.attributes[g]},{changedValue:e[g]}).changedValue;m[g]=v}return this.set(m,t)},removeProp:function(t,e){e=e||{};var n=Array.isArray(t)?t:t.split("/"),i=n[0];return"attrs"===i&&(e.dirty=!0),1===n.length?this.unset(t,e):(t=n.slice(1),null==(n=this.get(i))?this:(n=ta(n),Ja(n,t,"/"),this.set(i,n,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):E(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(n,e,i,r){r=r||"/";var o,t={duration:100,delay:10,timingFunction:ml.linear,valueFunction:vl.number},s=(i=T(t,i),0),a=function(t){var e;(t=(t-=s=s||t)/i.duration)<1?this._transitionIds[n]=e=sl(a):(t=1,delete this._transitionIds[n]),t=o(i.timingFunction(t)),i.transitionId=e,this.prop(n,t,i),e||this.trigger("transition:end",this,n)}.bind(this);let l=this._scheduledTransitionIds,h;return h=setTimeout(t=>{l[n]&&(l[n]=oa(l[n],h),0===l[n].length)&&delete l[n],this.stopPendingTransitions(n,r),o=i.valueFunction(Ya(this.attributes,n,r),e),this._transitionIds[n]=sl(t),this.trigger("transition:start",this,n)},i.delay,a),l[n]||(l[n]=[]),l[n].push(h),h},getTransitions:function(){return ha(Object.keys(this._transitionIds),Object.keys(this._scheduledTransitionIds))},stopScheduledTransitions:function(t){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"/",{_scheduledTransitionIds:e={}}=this,i=Object.keys(e);if(t){let e=t.split(n);i=i.filter(t=>na(e,t.split(n).slice(0,e.length)))}return i.forEach(t=>{e[t].forEach(t=>clearTimeout(t)),delete e[t]}),this},stopPendingTransitions(t){let n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"/",{_transitionIds:i={}}=this,r=Object.keys(i);if(t){let e=t.split(n);r=r.filter(t=>na(e,t.split(n).slice(0,e.length)))}r.forEach(t=>{var e=i[t];al(e),delete i[t],this.trigger("transition:end",this,t)})},stopTransitions:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"/";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,T({},e,{cell:this})),this},stopBatch:function(t,e){return this.graph&&this.graph.stopBatch(t,T({},e,{cell:this})),this},getChangeFlag:function(t){var e=0;if(t)for(var n in t)t.hasOwnProperty(n)&&this.hasChanged(n)&&(e|=t[n]);return e},angle:function(){return 0},position:function(){return new A(0,0)},z:function(){return this.get("z")||0},getPointFromConnectedLink:function(){return new A},getBBox:function(){return new tt(0,0,0,0)},getPointRotatedAroundCenter(t,e,n){e=new A(e,n);return t&&e.rotate(this.getBBox().center(),t),e},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=fh;return e&&e[t]||n[t]},define:function(t,e,n,i){n=T({defaults:Js({type:t},e,this.prototype.defaults)},n);e=this.extend(n,i);return"undefined"!=typeof joint&&da(joint,"shapes")&&Za(joint.shapes,t,e,"."),e}});function mh(e,t,n){if(E(n)){if(!vh[n])throw new Error('Unknown wrapper: "'+n+'"');n=vh[n]}if(!b(n))throw new Error("Wrapper must be a function.");et(t).forEach(function(t){e[t]=n(e[t])})}let vh={cells:function(i){return function(){var t=Array.from(arguments),e=t.length,n=0<e&&t[0]||[],e=1<e&&t[e-1]||{};return Array.isArray(n)||(e instanceof gh?n=t:n instanceof gh&&(1<t.length&&t.pop(),n=t)),e instanceof gh&&(e={}),i.call(this,n,e)}}};let p={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 yh(t,e){var n=new tt(t);switch(e){case void 0:throw new Error("Position required");case p.LEFT:case"leftMiddle":return n.leftMiddle();case p.RIGHT:case"rightMiddle":return n.rightMiddle();case p.TOP:case"topMiddle":return n.topMiddle();case p.BOTTOM:case"bottomMiddle":return n.bottomMiddle();case p.TOP_LEFT:case"topLeft":case"origin":return n.topLeft();case p.TOP_RIGHT:case"topRight":return n.topRight();case p.BOTTOM_LEFT:case"bottomLeft":return n.bottomLeft();case p.BOTTOM_RIGHT:case"bottomRight":case"corner":return n.bottomRight();case p.CENTER:return n.center();default:throw new Error("Unknown position: "+e)}}hn={getRectPoint:yh,wrapWith:mh,wrappers:vh,addClassNamePrefix:ja,removeClassNamePrefix:function(t){return t&&t.toString().split(" ").map(function(t){return t=t.substr(0,Ua.classNamePrefix.length)===Ua.classNamePrefix?t.substr(Ua.classNamePrefix.length):t}).join(" ")},parseDOMJSON:$a,hashCode:Wa,getByPath:Ya,setByPath:Za,unsetByPath:Ja,flattenObject:Ka,uuid:Qa,guid:tl,toKebabCase:function(t){return t.replace(/[A-Z]/g,"-$&").toLowerCase()},normalizeEvent:C,normalizeWheel:il,cap:rl,nextFrame:sl,cancelFrame:al,isPercentage:ll,parseCssNumeric:ol,breakText:cl,sanitizeHTML:function(t){var[t]=L.parseHTML("<div>"+t+"</div>");return Array.from(t.getElementsByTagName("*")).forEach(function(n){n.getAttributeNames().forEach(function(t){var e=n.getAttribute(t);(t.startsWith("on")||e.startsWith("javascript:"))&&n.removeAttribute(t)})}),t.innerHTML},downloadBlob:dl,downloadDataUri:function(t,e){t=fl(t);dl(t,e)},dataUriToBlob:fl,imageToDataUri:function(i,r){if(!i||"data:"===i.substr(0,"data:".length))return setTimeout(function(){r(null,i)},0);function o(t,e){var n;200===t.status?(t=new Uint8Array(t.response),e(null,"data:image/"+({svg:"svg+xml"}[n=i.split(".").pop()||"png"]||n)+";base64,"+btoa((t=>{for(var e=[],n=0;n<t.length;n+=32768)e.push(String.fromCharCode.apply(null,t.subarray(n,n+32768)));return e.join("")})(t)))):e(new Error("Failed to load image "+i))}var s=new XMLHttpRequest;s.open("GET",i,!0),s.addEventListener("error",function(){r(new Error("Failed to load image "+i))}),s.responseType=window.FileReader?"blob":"arraybuffer",s.addEventListener("load",function(){var t,e,n;window.FileReader?(e=r,200===(t=s).status?((n=new FileReader).onload=function(t){t=t.target.result;e(null,t)},n.onerror=function(){e(new Error("Failed to load image "+i))},n.readAsDataURL(t.response)):e(new Error("Failed to load image "+i))):o(s,r)}),s.send()},getElementBBox:function(t){t=L(t);if(0===t.length)throw new Error("Element not found");var t=t[0],e=t.ownerDocument,n=t.getBoundingClientRect(),i=0,r=0;return t.ownerSVGElement&&(t=(t=R(t)).getBBox({target:t.svg()}),i=n.width-t.width,r=n.height-t.height),{x:n.left+window.pageXOffset-e.documentElement.offsetLeft+i/2,y:n.top+window.pageYOffset-e.documentElement.offsetTop+r/2,width:n.width-i,height:n.height-r}},sortElements:pl,setAttributesBySelector:function(t,e){var n=L(t);pa(e,function(t,e){e=n.find(e).addBack().filter(e);da(t,"class")&&(e.addClass(t.class),t=ua(t,"class")),e.attr(t)})},normalizeSides:gl,timing:ml,interpolate:vl,filter:yl,format:h,template:bl,toggleFullScreen:function(t){var e=window.top.document;function n(t,e){for(var n=["webkit","moz","ms","o",""],i=0;i<n.length;i++){var r=n[i],r=r?r+e:e.substr(0,1).toLowerCase()+e.substr(1);if(void 0!==t[r])return b(t[r])?t[r]():t[r]}}t=t||e.body,n(e,"FullscreenElement")||n(e,"FullScreenElement")?n(e,"ExitFullscreen")||n(e,"CancelFullScreen"):n(t,"RequestFullscreen")||n(t,"RequestFullScreen")},objectDifference:xl,isBoolean:Hs,isObject:w,isNumber:qs,isString:E,mixin:n,deepMixin:$e,supplement:$s,defaults:Ws,deepSupplement:Ys,defaultsDeep:Js,assign:T,invoke:Xs,invokeProperty:Zs,sortedIndex:Ks,uniq:Qs,clone:f,cloneDeep:ta,isEmpty:ea,isEqual:na,isFunction:b,isPlainObject:y,toArray:et,debounce:ia,groupBy:sa,sortBy:ra,flattenDeep:aa,without:oa,difference:la,intersection:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.map(t=>mo(t)&&Po(t)?t:[]);return i.length&&i[0]===e[0]?(t=>{var e=(t,e)=>!!(null==t?0:t.length)&&-1<t.indexOf(e),n=(t,e)=>t.has(e),i=t[0].length,r=t.length,o=new Array(r),s=[];let a,l=1/0,h=r;for(;h--;)a=t[h],l=Math.min(a.length,l),o[h]=120<=i&&120<=a.length?new Us(h&&a):void 0;a=t[0];let u=-1;var c=o[0];t:for(;++u<i&&s.length<l;){var d=f=a[u],f=0!==f?f:0;if(!(c?n(c,d):e(s,d))){for(h=r;--h;){var p=o[h];if(!(p?n(p,d):e(t[h],d)))continue t}c&&c.push(d),s.push(f)}}return s})(i):[]},union:ha,has:da,result:S,omit:ua,pick:ca,bindAll:function(e){for(var t=arguments.length,n=new Array(1<t?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return n.flat(1).forEach(t=>{t=ns(t),wo(e,t,e[t].bind(e))}),e},forIn:pa,camelCase:ga,uniqueId:fa,merge:k,noop:wl,cloneCells:Dl,svg:function(t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];let r=[];t.forEach((t,e)=>{r.push(t),e in n&&r.push(n[e])});var t=r.join(""),o=new DOMParser,t=`<svg>${t.trim()}</svg>`,s=o.parseFromString(t.replace(/@/g,""),"application/xml");if(s.getElementsByTagName("parsererror")[0])throw new Error("Invalid SVG markup");o=(s=o.parseFromString(t,"text/html")).querySelector("svg");{t=o;let e=[];return Array.from(t.children).forEach(t=>{e.push(function t(e){let n={};let{tagName:i,attributes:r,namespaceURI:o,style:s,childNodes:a}=e;n.namespaceURI=o;n.tagName=o===R.namespace.xhtml?i.toLowerCase():i;let l={};for(var h=s.length;h--;){var u=s[h];l[u]=s.getPropertyValue(u)}n.style=l;let c=r.getNamedItem("@selector");c&&(n.selector=c.value,r.removeNamedItem("@selector"));let d=r.getNamedItem("@group-selector");if(d){let t=d.value.split(",");n.groupSelector=t.map(t=>t.trim()),r.removeNamedItem("@group-selector")}let f=r.getNamedItem("class");f&&(n.className=f.value);let p=[];a.forEach(e=>{switch(e.nodeType){case Node.TEXT_NODE:{let t=e.data.replace(/\s\s+/g," ");t.trim()&&p.push(t);break}case Node.ELEMENT_NODE:p.push(t(e))}});p.length&&(n.children=p);let g={};Array.from(r).forEach(t=>{let{name:e,value:n}=t;g[e]=n});0<Object.keys(g).length&&(n.attributes=g);return n}(t))}),e}},evalCalcFormula:Xl,isCalcExpression:Zl,evalCalcExpression:Ql};function bh(t,e,n){t=t.toJSON();return t.angle=e||0,Ws({},n,t)}function xh(t,e,n,i){return t.map(function(t,e,n){e=this.pointAt((e+.5)/n.length);return(t.dx||t.dy)&&e.offset(t.dx||0,t.dy||0),bh(e.round(),0,Ah(i,t))},pi(e,n))}function wh(t,i,r,o){var s=i.center(),a=i.width/i.height,l=i.topMiddle(),h=yi.fromRect(i);return t.map(function(t,e,n){e=r+o(e,n.length),n=l.clone().rotate(s,-e).scale(a,1,s),e=t.compensateRotation?-h.tangentTheta(n):0;return(t.dx||t.dy)&&n.offset(t.dx||0,t.dy||0),t.dr&&n.move(s,t.dr),bh(n.round(),e,Ah(i,t))})}function Ah(t,e){let{x:n,y:i,angle:r}=e;return ll(n)?n=parseFloat(n)/100*t.width:Zl(n)&&(n=Number(Ql(n,t))),ll(i)?i=parseFloat(i)/100*t.height:Zl(i)&&(i=Number(Ql(i,t))),{x:n,y:i,angle:r}}function Ph(t,e){var{x:t,y:e}=Ah(t,e);return new A(t||0,e||0)}var Eh={absolute:function(t,n){return t.map(t=>{var e=Ph(n,t).round().toJSON();return e.angle=t.angle||0,e})},fn:function(t,e,n){return n.fn(t,e,n)},line:function(t,e,n){return xh(t,Ph(e,n.start||e.origin()),Ph(e,n.end||e.corner()),e)},left:function(t,e,n){return xh(t,e.origin(),e.bottomLeft(),e)},right:function(t,e,n){return xh(t,e.topRight(),e.corner(),e)},top:function(t,e,n){return xh(t,e.origin(),e.topRight(),e)},bottom:function(t,e,n){return xh(t,e.bottomLeft(),e.corner(),e)},ellipseSpread:function(t,e,n){var i=n.startAngle||0,r=n.step||360/t.length;return wh(t,e,i,function(t){return t*r})},ellipse:function(t,e,n){var i=n.startAngle||0,r=n.step||20;return wh(t,e,i,function(t,e){return(t+.5-e/2)*r})}};function Th(t,e){return Js({},t,e,{x:0,y:0,angle:0,attrs:{}})}function Sh(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 kh(t,e,n,i){i=Ws({},i,{offset:15});var r,o,s,a,t=e.center().theta(t),l=i.offset,h=0,[e,u,c,d]=Sh(e),u=(t<u||c<t?(s=".3em",r=l,o=0,a="start"):t<e?(r=0,o=-l,s=n?(h=-90,a="start",".3em"):(a="middle","0")):t<d?(s=".3em",r=-l,o=0,a="end"):(r=0,o=l,s=n?(h=90,a="start",".3em"):(a="middle",".6em")),Math.round);return Th(i,{x:u(r),y:u(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Lh(t,e,n,i){i=Ws({},i,{offset:15});var r,o,s,a,t=e.center().theta(t),l=i.offset,h=0,[e,u,c,d]=Sh(e),u=(t<u||c<t?(s=".3em",r=-l,o=0,a="end"):t<e?(r=0,o=l,s=n?(h=90,a="start",".3em"):(a="middle",".6em")):t<d?(s=".3em",r=l,o=0,a="start"):(r=0,o=-l,s=n?(h=-90,a="start",".3em"):(a="middle","0")),Math.round);return Th(i,{x:u(r),y:u(o),angle:h,attrs:{labelText:{y:s,textAnchor:a}}})}function Ch(t,e,n){n=Ws({},n,{offset:20});var i,r=ci(0,0),o=-t.theta(r),s=o,r=t.clone().move(r,n.offset).difference(t).round(),t=".3em",o=((90+o)%180==0?(i=e?"end":"middle",e||-270!=o||(t="0em")):-270<o&&o<-90?(i="start",s=o-180):i="end",Math.round);return Th(n,{x:o(r.x),y:o(r.y),angle:e?s:0,attrs:{labelText:{y:t,textAnchor:i}}})}function Mh(t){t=ta(t)||{},this.ports=[],this.groups={},this.portLayoutNamespace=Eh,this.portLabelLayoutNamespace=_h,this._init(t)}var _h={manual:function(t,e,n){return Th(n)},left:function(t,e,n){return Th(n,{x:-15,attrs:{labelText:{y:".3em",textAnchor:"end"}}})},right:function(t,e,n){return Th(n,{x:15,attrs:{labelText:{y:".3em",textAnchor:"start"}}})},top:function(t,e,n){return Th(n,{y:-15,attrs:{labelText:{y:"0",textAnchor:"middle"}}})},bottom:function(t,e,n){return Th(n,{y:15,attrs:{labelText:{y:".6em",textAnchor:"middle"}}})},outsideOriented:function(t,e,n){return kh(t,e,!0,n)},outside:function(t,e,n){return kh(t,e,!1,n)},insideOriented:function(t,e,n){return Lh(t,e,!0,n)},inside:function(t,e,n){return Lh(t,e,!1,n)},radial:function(t,e,n){return Ch(t.difference(e.center()),!1,n)},radialOriented:function(t,e,n){return Ch(t.difference(e.center()),!0,n)}},sn=(Mh.prototype={getPorts:function(){return this.ports},getGroup:function(t){return this.groups[t]||{}},getPortsByGroup:function(e){return this.ports.filter(function(t){return t.group===e})},getGroupPortsMetrics:function(t,i){var e=this.getGroup(t),t=this.getPortsByGroup(t),e=e.position||{},n=e.name,r=this.portLayoutNamespace,e=(r[n]||(n="left"),e.args||{}),o=t.map(function(t){return t&&t.position&&t.position.args}),r=r[n](o,i,e),n={ports:t,result:[]};return et(r).reduce(function(t,e,n){n=t.ports[n];return t.result.push({portId:n.id,portTransformation:e,labelTransformation:this._getPortLabelLayout(n,A(e),i),portAttrs:n.attrs,portSize:n.size,labelSize:n.label.size}),t}.bind(this),n),n.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(w(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=et(t.items),s=0,a=o.length;s<a;s++)this.ports.push(this._evaluatePort(o[s]))},_evaluateGroup:function(t){return k(t,{position:this._getPosition(t.position,!0),label:this._getLabel(t,!0)})},_evaluatePort:function(t){var e=T({},t),t=this.getGroup(t.group);return e.markup=e.markup||t.markup,e.attrs=k({},t.attrs,e.attrs),e.position=this._createPositionNode(t,e),e.label=k({},t.label,this._getLabel(e)),e.z=this._getZIndex(t,e),e.size=T({},t.size,e.size),e},_getZIndex:function(t,e){return qs(e.z)?e.z:qs(t.z)||"auto"===t.z?t.z:"auto"},_createPositionNode:function(t,e){return k({name:"left",args:{}},t.position,{args:e.args})},_getPosition:function(t,e){var n,i={},e=(b(t)?(n="fn",i.fn=t):E(t)?n=t:void 0===t?n=e?"left":null:Array.isArray(t)?(n="absolute",i.x=t[0],i.y=t[1]):w(t)&&(n=t.name,T(i,t.args)),{args:i});return n&&(e.name=n),e},_getLabel:function(t,e){var t=t.label||{},n=t;return n.position=this._getPosition(t.position,e),n}},{_initializePorts:function(){this._createPortData(),this.on("change:ports",function(){this._processRemovedPort(),this._createPortData()},this)},_processRemovedPort:function(){var t=this.get("ports")||{},e={},t=(et(t.items).forEach(function(t){e[t.id]=!0}),this.previous("ports")||{}),n={},t=(et(t.items).forEach(function(t){e[t.id]||(n[t.id]=!0)}),this.graph);t&&!ea(n)&&(t.getConnectedLinks(this,{inbound:!0}).forEach(function(t){n[t.get("target").port]&&t.remove()}),t.getConnectedLinks(this,{outbound:!0}).forEach(function(t){n[t.get("source").port]&&t.remove()}))},hasPorts:function(){var t=this.prop("ports/items");return Array.isArray(t)&&0<t.length},hasPort:function(t){return-1!==this.getPortIndex(t)},getPorts:function(){return ta(this.prop("ports/items"))||[]},getGroupPorts:function(e){var t=et(this.prop(["ports","items"])).filter(t=>t.group===e);return ta(t)},getPort:function(e){return ta(et(this.prop("ports/items")).find(function(t){return t.id&&t.id===e}))},getPortGroupNames:function(){return Object.keys(this._portSettingsData.groups)},getPortsPositions:function(t){return this._portSettingsData.getGroupPortsMetrics(t,tt(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=w(t)?t.id:t;return this._isValidPortId(e)?et(this.prop("ports/items")).findIndex(function(t){return t.id===e}):-1},addPort:function(t,e){if(!w(t)||Array.isArray(t))throw new Error("Element: addPort requires an object.");var n=T([],this.prop("ports/items"));return n.push(t),this.prop("ports/items",n,e),this},insertPort:function(t,e,n){t="number"==typeof t?t:this.getPortIndex(t);if(!w(e)||Array.isArray(e))throw new Error("dia.Element: insertPort requires an object.");var i=T([],this.prop("ports/items"));return i.splice(t,0,e),this.prop("ports/items",i,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);t=Array.prototype.slice.call(arguments,1);return Array.isArray(e)?t[0]=["ports","items",r].concat(e):E(e)?t[0]=["ports/items/",r,"/",e].join(""):(t=["ports/items/"+r],y(e)&&(t.push(e),t.push(n))),this.prop.apply(this,t)},_validatePorts:function(){var t=this.get("ports")||{},e=[],t=t||{},t=et(t.items);return t.forEach(function(t){"object"!=typeof t&&e.push("Element: invalid port ",t),this._isValidPortId(t.id)||(t.id=this.generatePortId())},this),Qs(t,"id").length!==t.length&&e.push("Element: found id duplicities in ports."),e},generatePortId:function(){return this.generateId()},_isValidPortId:function(t){return null!=t&&!w(t)},addPorts:function(t,e){return t.length&&this.prop("ports/items",T([],this.prop("ports/items")).concat(t),e),this},removePort:function(t,e){var n,e=e||{},t=this.getPortIndex(t);return-1!==t&&((n=T([],this.prop(["ports","items"]))).splice(t,1),e.rewrite=!0,this.startBatch("port-remove"),this.prop(["ports","items"],n,e),this.stopBatch("port-remove")),this},removePorts:function(t,e){let n,i;if(Array.isArray(t)){if(n=e||{},0===t.length)return this.this;e=T([],this.prop(["ports","items"]));i=e.filter(function(e){return!t.some(function(t){t=w(t)?t.id:t;return e.id===t})})}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(0<e.length)throw this.set("ports",this.previous("ports")),new Error(e.join(" "));this._portSettingsData&&(t=this._portSettingsData.getPorts()),this._portSettingsData=new Mh(this.get("ports"));var n,i=this._portSettingsData.getPorts();t&&(e=i.filter(function(e){if(!t.find(function(t){return t.id===e.id}))return e}),0<(n=t.filter(function(e){if(!i.find(function(t){return t.id===e.id}))return e})).length&&this.trigger("ports:remove",this,n),0<e.length)&&this.trigger("ports:add",this,e)}}),o={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 e=[],n=this._getContainerElement(),t=0,i=n.node.childNodes.length;t<i;t++)e.push(n.node.childNodes[t]);for(var r=sa(this.model._portSettingsData.getPorts(),"z"),o=(et(r.auto).forEach(function(t){t=this._getPortElement(t);n.append(t),e.push(t)},this),Object.keys(r)),s=0;s<o.length;s++){var a,l=o[s];"auto"!==l&&(a=parseInt(l,10),this._appendPorts(r[l],a,e))}this._updatePorts()},_getContainerElement:function(){return this.rotatableNode||this.vel},_appendPorts:function(t,e,n){var i=this._getContainerElement(),t=et(t).map(this._getPortElement,this);n[e]||e<0?R(n[Math.max(e,0)]).before(t):i.append(t)},_getPortElement:function(t){return this._portElementsCache[t.id]?this._portElementsCache[t.id].portElement:this._createPortElement(t)},findPortNodes:function(t,e){var n,t=this._portElementsCache[t];return t?e?(n=t.portElement.node,this.findBySelector(e,n,t.portSelectors)):[t.portContentElement.node]:[]},findPortNode:function(t,e){var[t=null]=this.findPortNodes(t,e);return t},_updatePorts:function(){this._updatePortGroup(void 0),Object.keys(this.model._portSettingsData.groups).forEach(this._updatePortGroup,this)},_removePorts:function(){Xs(this._portElementsCache,"portElement.remove")},_createPortElement:function(t){let e,n,i,r,o=R(this.portContainerMarkup).addClass("joint-port"),s=this._getPortMarkup(t),a,l;if(Array.isArray(s)?(l=(a=this.parseDOMJSON(s,o.node)).fragment,e=1<l.childNodes.length?R("g").append(l):R(l.firstChild),r=a.selectors):(e=R(s),Array.isArray(e)&&(e=R("g").append(e))),!e)throw new Error("ElementView: Invalid port markup.");e.attr({port:t.id,"port-group":t.group}),qs(t.id)&&e.attr("port-id-type","number");var h,u=this._getPortLabelMarkup(t.label);if(Array.isArray(u)?({fragment:f,selectors:p}=this.parseDOMJSON(u,o.node),0<(d=f.childNodes.length)&&(i=p,n=1===d?R(f.firstChild):R("g").append(f))):(n=R(u),Array.isArray(n)&&(n=R("g").append(n))),r&&i){for(var c in i)if(r[c]&&c!==this.selector)throw new Error("ElementView: selectors within port must be unique.");h=T({},r,i)}else h=r||i||{};var d,f,p="labelText";return"portRoot"in h||(h.portRoot=e.node),n&&(d=n.node,"labelRoot"in h||(h.labelRoot=d),p in h||(f="TEXT"===n.tagName()?d:Array.from(d.querySelectorAll("text")),h[p]=f,(i=i||{})[p]=f)),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=tt(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,s=this._portElementsCache[s]||{},a=o.portTransformation,l=o.labelTransformation;l&&s.portLabelElement&&(this.updateDOMSubtreeAttributes(s.portLabelElement.node,l.attrs,{rootBBox:new tt(o.labelSize),selectors:s.portLabelSelectors}),this.applyPortTransform(s.portLabelElement,l,-a.angle||0)),this.updateDOMSubtreeAttributes(s.portElement.node,o.portAttrs,{rootBBox:new tt(o.portSize),selectors:s.portSelectors}),this.applyPortTransform(s.portElement,a)}},applyPortTransform:function(t,e,n){n=R.createSVGMatrix().rotate(n||0).translate(e.x||0,e.y||0).rotate(e.angle||0);t.transform(n,{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}},c=gh.extend({defaults:{position:{x:0,y:0},size:{width:1,height:1},angle:0},initialize:function(){this._initializePorts(),gh.prototype.initialize.apply(this,arguments)},_initializePorts:function(){},_refreshPorts:function(){},isElement:function(){return!0},position:function(t,e,n){var i=qs(e),{parentRelative:r,deep:o,restrictedArea:s}=n=(i?n:t)||{};let a;if(r){if(!this.graph)throw new Error("Element must be part of a graph.");var l=this.getParentCell();l&&!l.isLink()&&(a=l.get("position"))}return i?(a&&(t+=a.x,e+=a.y),o||s?({x:l,y:i}=this.get("position"),this.translate(t-l,e-i,n)):this.set("position",{x:t,y:e},n),this):(o=A(this.get("position")),r?o.difference(a):o)},translate:function(t,e,n){var i,r,o,s,a;return e=e||0,0===(t=t||0)&&0===e||((n=n||{}).translateBy=n.translateBy||this.id,i=this.get("position")||{x:0,y:0},(s=n.restrictedArea)&&n.translateBy===this.id&&(e="function"==typeof s?(t=(r=s.call(this,i.x+t,i.y+e,n)).x-i.x,r.y-i.y):(r=this.getBBox({deep:!0}),o=i.x-r.x,a=i.y-r.y,o=Math.max(s.x+o,Math.min(s.x+s.width+o-r.width,i.x+t)),s=Math.max(s.y+a,Math.min(s.y+s.height+a-r.height,i.y+e)),t=o-i.x,s-i.y)),a={x:i.x+t,y:i.y+e},n.tx=t,n.ty=e,n.transition?(w(n.transition)||(n.transition={}),this.transition("position",a,T({},n.transition,{valueFunction:vl.object})),Xs(this.getEmbeddedCells(),"translate",t,e,n)):(this.startBatch("translate",n),this.set("position",a,n),Xs(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}:(w(t)&&(n=e,e=(qs(t.height)?t:i).height,t=(qs(t.width)?t:i).width),this.resize(t,e,n))},resize:function(t,e,n){if(this.startBatch("resize",n=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=Xn(this.get("angle")||0),o=this.getBBox();if(r)var s={"top-right":0,right:0,"top-left":1,top:1,"bottom-left":2,left:2,"bottom-right":3,bottom:3}[n.direction],a=o[["bottomLeft","corner","topRight","origin"][s=n.absolute?(s+Math.floor((r+45)/90))%4:s]](),a=A(a).rotate(o.center(),-r),l=Math.sqrt(t*t+e*e)/2,h=s*Math.PI/2,s=(h=(h+=Math.atan(s%2==0?e/t:t/e))-Jn(r),A.fromPolar(l,h,a)),u=A(s).offset(t/-2,e/-2);else switch(u=o.topLeft(),n.direction){case"top":case"top-right":u.offset(0,o.height-e);break;case"left":case"bottom-left":u.offset(o.width-t,0);break;case"top-left":u.offset(o.width-t,o.height-e)}this.set("size",{width:t,height:e},n),this.position(u.x,u.y,n)}else this.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this},scale:function(t,e,n,i){t=this.getBBox().scale(t,e,n);return this.startBatch("scale",i),this.position(t.x,t.y,i),this.resize(t.width,t.height,i),this.stopBatch("scale"),this},fitEmbeds:function(t){return this.fitToChildren(t)},fitToChildren:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=this.graph;if(e)return 0!==(e=this.getEmbeddedCells().filter(t=>t.isElement())).length&&(this.startBatch("fit-embeds",t),t.deep&&Xs(e,"fitToChildren",t),this._fitToElements(Object.assign({elements:e},t)),this.stopBatch("fit-embeds")),this;throw new Error("Element must be part of a graph.")},fitParent:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=this.graph;if(n)return e.deep&&e.terminator&&(e.terminator===this||e.terminator===this.id)||(n=this.getParentCell())&&n.isElement()&&0!==(t=n.getEmbeddedCells().filter(t=>t.isElement())).length&&(this.startBatch("fit-parent",e),n._fitToElements(Object.assign({elements:t},e)),e.deep&&n.fitParent(e),this.stopBatch("fit-parent")),this;throw new Error("Element must be part of a graph.")},_fitToElements:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},n=this.graph.getCellsBBox(e.elements);if(n){var{expandOnly:i,shrinkOnly:r}=e;if(!i||!r){var{x:n,y:o,width:s,height:a}=n,{left:l,right:h,top:u,bottom:c}=gl(e.padding);n-=l,o-=u,s+=l+h,a+=c+u;let t=new tt(n,o,s,a);if(i)t=this.getBBox().union(t);else if(r){l=this.getBBox().intersect(t);if(!l)return;t=l}this.set({position:{x:t.x,y:t.y},size:{width:t.width,height:t.height}},e)}}},rotate:function(t,e,n,i){var r,o,s,a;return n?(a=this.getBBox().center(),r=this.get("size"),o=this.get("position"),a.rotate(n,this.get("angle")-t),s=a.x-r.width/2-o.x,a=a.y-r.height/2-o.y,this.startBatch("rotate",{angle:t,absolute:e,origin:n}),this.position(o.x+s,o.y+a,i),this.rotate(t,e,null,i),this.stopBatch("rotate")):this.set("angle",e?t:(this.get("angle")+t)%360,i),this},angle:function(){return Xn(this.get("angle")||0)},getBBox:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},{graph:n,attributes:i}=this,{deep:r,rotate:o}=e;return r&&n?((r=this.getEmbeddedCells({deep:!0,breadthFirst:!0})).push(this),n.getCellsBBox(r,e)):({angle:n=0,position:{x:r,y:e},size:{width:i,height:t}}=i,r=new tt(r,e,i,t),o&&r.rotateAroundCenter(n),r)},getPointFromConnectedLink:function(t,e){var n=this.getBBox(),i=n.center(),t=t.get(e);return t&&(e=t.port)&&this.hasPort(e)?(t=this.portProp(e,["group"]),t=this.getPortsPositions(t),t=new A(t[e]).offset(n.origin()),(e=this.angle())&&t.rotate(i,-e),t):i}});T(c.prototype,sn);let Nh=gh.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){var i;return void 0===t?f(this.get("source")):t instanceof gh?((i=f(e)||{}).id=t.id,this.set("source",i,n)):y(t)?this.set("source",i=t,e):((i=f(e)||{}).x=t.x,i.y=t.y,this.set("source",i,n))},target:function(t,e,n){var i;return void 0===t?f(this.get("target")):t instanceof gh?((i=f(e)||{}).id=t.id,this.set("target",i,n)):y(t)?this.set("target",i=t,e):((i=f(e)||{}).x=t.x,i.y=t.y,this.set("target",i,n))},router:function(t,e,n){var i;return void 0===t?(i=this.get("router"))?"object"==typeof i?f(i):i:null:this.set("router",(i="object"==typeof t||"function"==typeof t)?t:{name:t,args:e},i?e:n)},connector:function(t,e,n){var i;return void 0===t?(i=this.get("connector"))?"object"==typeof i?f(i):i:null:this.set("connector",(i="object"==typeof t||"function"==typeof t)?t:{name:t,args:e},i?e:n)},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(){var t=this.attributes.labels;return Array.isArray(t)&&0<t.length},insertLabel:function(t,e,n){var i,r;if(e)return r=(i=this.labels()).length,t=isFinite(t)&&null!==t?0|t:r,i.splice(t=t<0?r+t+1:t,0,e),this.labels(i,n);throw new Error("dia.Link: no label provided")},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();return(t=isFinite(t)&&null!==t?0|t:0)<0&&(t=i.length+t),arguments.length<=1?this.prop(["vertices",t]):(i=this._normalizeVertex(e),this.prop(["vertices",t],i,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],r=this._normalizeVertex(r);n.push(r)}return this.set("vertices",n,e)},insertVertex:function(t,e,n){var i,r;if(e)return r=(i=this.vertices()).length,(t=isFinite(t)&&null!==t?0|t:r)<0&&(t=r+t+1),r=this._normalizeVertex(e),i.splice(t,0,r),this.vertices(i,n);throw new Error("dia.Link: no vertex provided")},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 y(t)?t:{x:t.x,y:t.y}},translate:function(e,n,t){return(t=t||{}).translateBy=t.translateBy||this.id,t.tx=e,t.ty=n,this.applyToPoints(function(t){return{x:(t.x||0)+e,y:(t.y||0)+n}},t)},scale:function(e,n,i,t){return this.applyToPoints(function(t){return A(t).scale(e,n,i).toJSON()},t)},applyToPoints:function(t,e){var n,i,r;if(b(t))return n={},{source:r,target:i}=this.attributes,r.id||(n.source=t(r)),i.id||(n.target=t(i)),0<(r=this.vertices()).length&&(n.vertices=r.map(t)),this.set(n,e);throw new TypeError("dia.Link: applyToPoints expects its first parameter to be a function.")},getSourcePoint:function(){var t=this.getSourceCell();return t?t.getPointFromConnectedLink(this,"source"):new A(this.source())},getTargetPoint:function(){var t=this.getTargetCell();return t?t.getPointFromConnectedLink(this,"target"):new A(this.target())},getPointFromConnectedLink:function(){return this.getPolyline().pointAt(.5)},getPolyline:function(){var t=[this.getSourcePoint(),...this.vertices().map(A),this.getTargetPoint()];return new x(t)},getBBox:function(){return this.getPolyline().bbox()},reparent:function(t){var e,n,i,r;return this.graph&&(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),e},hasLoop:function(t){t=t||{};var{source:e,target:n}=this.attributes,e=e.id,n=n.id;return!(!e||!n)&&(!(e=e===n)&&t.deep&&this.graph&&(n=this.getSourceCell(),t=this.getTargetCell(),e=n.isEmbeddedIn(t)||t.isEmbeddedIn(n)),e)},getSourceCell:function(){var{graph:t,attributes:e}=this,e=e.source;return e&&e.id&&t&&t.getCell(e.id)||null},getSourceElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getSourceCell())&&t.isLink());return t},getTargetCell:function(){var{graph:t,attributes:e}=this,e=e.target;return e&&e.id&&t&&t.getCell(e.id)||null},getTargetElement:function(){var t=this,e={};do{if(e[t.id])return null}while(e[t.id]=!0,(t=t.getTargetCell())&&t.isLink());return t},getRelationshipAncestor:function(){var t;return this.graph&&(t=[this,this.getSourceElement(),this.getTargetElement()].filter(function(t){return!!t}),t=this.graph.getCommonAncestor.apply(this.graph,t)),t||null},isRelationshipEmbeddedIn:function(t){var t=E(t)||qs(t)?t:t.id,e=this.getRelationshipAncestor();return!!e&&(e.id===t||e.isEmbeddedIn(t))},_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}}),Oh={_results:{},_tests:{svgforeignobject:function(){return!!document.createElementNS&&/SVGForeignObject/.test({}.toString.call(document.createElementNS("http://www.w3.org/2000/svg","foreignObject")))},isSafari:function(){return/Safari/.test(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor)}},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){try{n=e()}catch(t){n=!1}this._results[t]=n}return n}};var Rh=c.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"}]}),i=c.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"}]}),s=c.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"}]}),u=c.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"}]}),l=c.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"}]}),Ln=c.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"}]}),a=c.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"}]}),Je=c.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"}]}),e=c.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"}]}),r=c.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"}]}),h=c.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"}]}),n=c.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){var n;return void 0===t?this.attr("body/lateralArea"):(n={lateralArea:t},t=ll(t)?`calc(${parseFloat(t)/100}*h)`:t,this.attr({body:n,top:{cy:t,ry:t}},e))}},{attributes:{"lateral-area":{set:function(t,e){var n=ll(t),i=(n&&(t=parseFloat(t)/100),e.x),r=e.y,o=e.width,e=e.height,s=o/2,a=n?e*t:t,l=R.KAPPA,s=l*s,l=l*(n?e*t:t),n=i+o/2,t=i+o,o=r+a,h=o-a,a=r+e-a,r=r+e;return{d:["M",i,o,"L",i,a,"C",i,a+l,n-s,r,n,r,"C",n+s,r,t,a+l,t,a,"L",t,o,"C",t,o-l,n+s,h,n,h,"C",n-s,h,i,o-l,i,o,"Z"].join(" ")}},unset:"d"}}}),$e=Oh.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"}},sn={standard:{Rectangle:Rh,Circle:i,Ellipse:s,Path:u,Polygon:l,Polyline:Ln,Image:a,BorderedImage:Je,EmbeddedImage:e,InscribedImage:r,HeaderedRectangle:h,Cylinder:n,TextBlock:c.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"},$e]},{attributes:{text:{set:function(t,e,n,i){var r,o;if(!(n instanceof HTMLElement))return i=i.style||{},r={text:t,width:-5,height:"100%"},o=T({"text-vertical-anchor":"middle"},i),fh["text-wrap"].set.call(this,r,e,n,o),{fill:i.color||null};n.textContent=t},unset:function(t){if(t.textContent="",t instanceof SVGElement)return"fill"},position:function(t,e,n){if(n instanceof SVGElement)return e.center()}}}}),Link:Nh.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"}}]}),DoubleLink:Nh.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"}}]}),ShadowLink:Nh.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"}}]})}};function Fh(r,o){var s=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],t=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},{cornerType:a=Ih.POINT,cornerRadius:l=10,cornerPreserveAspectRatio:h=!1,precision:u=1,raw:t=!1}=t;if(-1===Vh.indexOf(a))throw new Error("Invalid `cornerType` provided to `straight` connector.");let c;if(a!==Ih.POINT&&l){(c=new V).appendSegment(V.createSegment("M",r));let i;var e=s.length;for(let n=0;n<e;n++){var d=new A(s[n]),f=s[n-1]||r,p=s[n+1]||o,g=i||d.distance(f)/2;i=d.distance(p)/2;let t,e;h?t=e=-Math.min(l,g,i):(t=-Math.min(l,g),e=-Math.min(l,i));var m=d.clone().move(f,t).round(u),v=d.clone().move(p,e).round(u);switch(c.appendSegment(V.createSegment("L",m)),a){case Ih.CUBIC:var y=new A(1/3*m.x+2/3*d.x,2/3*d.y+1/3*m.y),b=new A(1/3*v.x+2/3*d.x,2/3*d.y+1/3*v.y);c.appendSegment(V.createSegment("C",y,b,v));break;case Ih.LINE:c.appendSegment(V.createSegment("L",v));break;case Ih.GAP:c.appendSegment(V.createSegment("M",v))}}c.appendSegment(V.createSegment("L",o))}else{var n=[r].concat(s).concat([o]),n=new x(n);c=new V(n)}return t?c:c.serialize()}let Ih={POINT:"point",CUBIC:"cubic",LINE:"line",GAP:"gap"},Vh=Object.values(Ih);var Bh=["arc","gap","cubic"],Dh=1,zh=["smooth"],jh=1/3,Gh=2/3;function Uh(t,e){let{x:n,y:i}=t,{x:r,y:o}=e;return n>r&&(t=n,n=r,r=t,t=i,i=o,o=t),i>o&&(e=n,n=r,r=e,e=i,i=o,o=e),[new A(n,i),new A(r,o)]}function Hh(t,e,n){var r=[].concat(t,n,e);return r.reduce(function(t,e,n){var i=r[n+1];return null!=i&&(t[n]=pi(e,i)),t},[])}function qh(t){var e,r=t.paper,n=r._jumpOverUpdateList;null==n&&(n=r._jumpOverUpdateList=[],(e=r.model).on("batch:stop",function(){if(!this.hasActiveBatch())for(var t=r._jumpOverUpdateList,e=0;e<t.length;e++){var n=t[e],i=n.getFlag(n.constructor.Flags.CONNECTOR);n.requestUpdate(i)}}),e.on("reset",function(){n=r._jumpOverUpdateList=[]})),n.indexOf(t)<0&&(n.push(t),t.listenToOnce(t.model,"change:connector remove",function(){n.splice(n.indexOf(t),1)}))}function $h(t,e){return pi(t,e).squaredLength()}function Wh(h,u,c,d){var f=new V,p=V.createSegment("M",h[0].start);return f.appendSegment(p),et(h).forEach(function(t,e){var n,i,r,o,s,a,l;t.isJump?"arc"===c?(s=-90,i=t.start.difference(t.end),Number(i.x<0||0===i.x&&i.y<0)&&(s+=180),r=t.midpoint(),o=new P(r,t.end).rotate(r,s),a=(n=new P(t.start,r)).pointAt(2/3).rotate(t.start,s),l=o.pointAt(1/3).rotate(o.end,-s),p=V.createSegment("C",a,l,o.end),f.appendSegment(p),n=new P(r,t.end),a=o.pointAt(1/3).rotate(o.end,s),l=n.pointAt(1/3).rotate(t.end,-s),p=V.createSegment("C",a,l,t.end),f.appendSegment(p)):"gap"===c?(p=V.createSegment("M",t.end),f.appendSegment(p)):"cubic"===c&&(s=t.start.theta(t.end),r=.6*u,o=1.35*u,i=t.start.difference(t.end),Number(i.x<0||0===i.x&&i.y<0)&&(o*=-1),a=A(t.start.x+r,t.start.y+o).rotate(t.start,s),l=A(t.end.x-r,t.end.y+o).rotate(t.end,s),p=V.createSegment("C",a,l,t.end),f.appendSegment(p)):(n=h[e+1],0==d||!n||n.isJump?(p=V.createSegment("L",t.end),f.appendSegment(p)):(i=d,r=f,o=t.end,s=t.start,a=n.end,l=o.distance(s)/2,e=o.distance(a)/2,l=-Math.min(i,l),i=-Math.min(i,e),e=o.clone().move(s,l).round(),s=o.clone().move(a,i).round(),l=new A(jh*e.x+Gh*o.x,Gh*o.y+jh*e.y),a=new A(jh*s.x+Gh*o.x,Gh*o.y+jh*s.y),i=V.createSegment("L",e),r.appendSegment(i),i=V.createSegment("C",l,a,s),r.appendSegment(i)))}),f}let Yh={AUTO:"auto",HORIZONTAL:"horizontal",VERTICAL:"vertical",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"},Xh={UP:"up",DOWN:"down",LEFT:"left",RIGHT:"right",AUTO:"auto",CLOSEST_POINT:"closest-point",OUTWARDS:"outwards"};function Zh(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},r=4<arguments.length?arguments[4]:void 0,o=Boolean(i.raw),{direction:s=Yh.AUTO,precision:a=3}=i;let l={coeff:i.distanceCoefficient||.6,angleTangentCoefficient:i.angleTangentCoefficient||80,tau:i.tension||.5,sourceTangent:i.sourceTangent?new A(i.sourceTangent):null,targetTangent:i.targetTangent?new A(i.targetTangent):null,rotate:Boolean(i.rotate)};"string"==typeof i.sourceDirection?l.sourceDirection=i.sourceDirection:"number"==typeof i.sourceDirection?l.sourceDirection=new A(1,0).rotate(null,i.sourceDirection):l.sourceDirection=i.sourceDirection?new A(i.sourceDirection).normalize():null,"string"==typeof i.targetDirection?l.targetDirection=i.targetDirection:"number"==typeof i.targetDirection?l.targetDirection=new A(1,0).rotate(null,i.targetDirection):l.targetDirection=i.targetDirection?new A(i.targetDirection).normalize():null,i=[t,...n,e].map(t=>new A(t));let h;h=l.sourceTangent||(t=((t,e,n,i)=>{if(i.sourceDirection)switch(i.sourceDirection){case Xh.UP:return new A(0,-1);case Xh.DOWN:return new A(0,1);case Xh.LEFT:return new A(-1,0);case Xh.RIGHT:return new A(1,0);case Xh.AUTO:return Jh(t,e,i);case Xh.CLOSEST_POINT:return Qh(0,e);case Xh.OUTWARDS:return eu(t,e);default:return i.sourceDirection}switch(n){case Yh.HORIZONTAL:return((t,e,n)=>{let i=t.sourceBBox,r,o;var s;r=t.sourceView?(o=t.sourceView.model.angle(),n.rotate&&o?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(s=e[0].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[0])):i.x>e[1].x?"right":"left";let a;return a="left"===r?new A(-1,0):new A(1,0),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case Yh.VERTICAL:return((t,e,n)=>{let i=t.sourceBBox,r,o;var s;r=t.sourceView?(o=t.sourceView.model.angle(),n.rotate&&o?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(s=e[0].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[0])):i.y>e[1].y?"bottom":"top";let a;return a="top"===r?new A(0,-1):new A(0,1),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case Yh.CLOSEST_POINT:return Qh(0,e);case Yh.OUTWARDS:return eu(t,e);default:Yh.AUTO;return Jh(t,e,i)}})(r,i,s,l),n=i[0].distance(i[1])*l.coeff,(e=iu(t,i[1].difference(i[0]).normalize()))>Math.PI/4?(e=n+(e-Math.PI/4)*l.angleTangentCoefficient,t.clone().scale(e,e)):t.clone().scale(n,n));let u;return u=l.targetTangent||(e=((t,e,n,i)=>{if(i.targetDirection)switch(i.targetDirection){case Xh.UP:return new A(0,-1);case Xh.DOWN:return new A(0,1);case Xh.LEFT:return new A(-1,0);case Xh.RIGHT:return new A(1,0);case Xh.AUTO:return Kh(t,e,i);case Xh.CLOSEST_POINT:return tu(0,e);case Xh.OUTWARDS:return nu(t,e);default:return i.targetDirection}switch(n){case Yh.HORIZONTAL:return((t,e,n)=>{let i=t.targetBBox,r,o;var s;r=t.targetView?(o=t.targetView.model.angle(),n.rotate&&o?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(s=e[e.length-1].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[e.length-1])):i.x>e[e.length-2].x?"left":"right";let a;return a="left"===r?new A(-1,0):new A(1,0),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case Yh.VERTICAL:return((t,e,n)=>{let i=t.targetBBox,r,o;var s;r=t.targetView?(o=t.targetView.model.angle(),n.rotate&&o?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(s=e[e.length-1].clone()).rotate(i.center(),o),t.sideNearestToPoint(s)):i.sideNearestToPoint(e[e.length-1])):i.y>e[e.length-2].y?"top":"bottom";let a;return a="top"===r?new A(0,-1):new A(0,1),n.rotate&&o&&a.rotate(null,-o),a})(t,e,i);case Yh.CLOSEST_POINT:return tu(0,e);case Yh.OUTWARDS:return nu(t,e);default:Yh.AUTO;return Kh(t,e,i)}})(r,i,s,l),n=i[(t=i.length-1)-1].distance(i[t])*l.coeff,(r=iu(e,i[t-1].difference(i[t]).normalize()))>Math.PI/4?(s=n+(r-Math.PI/4)*l.angleTangentCoefficient,e.clone().scale(s,s)):e.clone().scale(n,n)),t=((r,t,e,n)=>{var{tau:i,coeff:o}=n,s=[],a=[],l=[],h=r.length-1;for(let t=0;t<h;t++)s[t]=r[t].distance(r[t+1]);a[0]=t,a[h]=e;for(let i=1;i<h;i++){let t,e;t=1===i?r[i-1].clone().offset(a[i-1].x,a[i-1].y):r[i-1].clone(),e=i===h-1?r[i+1].clone().offset(a[i+1].x,a[i+1].y):r[i+1].clone();var u=t.difference(r[i]).normalize(),c=e.difference(r[i]).normalize(),d=iu(u,c);let n=(Math.PI-d)/2;var u=ru(u,c),d=(f=ru(r[i].difference(r[i+1]),r[i].difference(r[i-1])),u<0&&(n=-n),d<Math.PI/2&&(n<0&&f<0||0<n&&0<f)&&(n-=Math.PI),((t,e)=>{var n=Math.cos(e),e=Math.sin(e),i=n*t.x-e*t.y,e=e*t.x+n*t.y;t.x=i,t.y=e})(u=c.clone(),n),u.clone()),f=u.clone(),c=s[i-1]*o,u=s[i]*o;d.scale(c,c),f.scale(u,u),a[i]=[d,f]}for(let n=0;n<h;n++){let t,e;t=0===n?r[n+1].difference(a[n].x/i,a[n].y/i):r[n+1].difference(a[n][1].x/i,a[n][1].y/i),e=n===h-1?r[n].clone().offset(a[n+1].x/i,a[n+1].y/i):r[n].difference(a[n+1][0].x/i,a[n+1][0].y/i),l[n]=[t,r[n],r[n+1],e]}return l})(i,h,u,l).map(t=>{return t=t,e=(e=l).tau,(n=new A).x=t[1].x+(t[2].x-t[0].x)/(6*e),n.y=t[1].y+(t[2].y-t[0].y)/(6*e),(i=new A).x=t[2].x+(t[3].x-t[1].x)/(6*e),i.y=t[2].y+(t[3].y-t[1].y)/(6*e),new v(t[1],n,i,t[2]);var e,n,i}),r=new V(t).round(a),o?r:r.serialize()}function Jh(t,e,n){var i,r=t.sourceBBox;let o,s,a;switch(o=t.sourceView?(s=t.sourceView.model.angle(),n.rotate&&s?(t=t.sourceView.getNodeUnrotatedBBox(t.sourceView.el),(i=e[0].clone()).rotate(r.center(),s),t.sideNearestToPoint(i)):r.sideNearestToPoint(e[0])):r.sideNearestToPoint(e[1])){case"top":a=new A(0,-1);break;case"bottom":a=new A(0,1);break;case"right":a=new A(1,0);break;case"left":a=new A(-1,0)}return n.rotate&&s&&a.rotate(null,-s),a}function Kh(t,e,n){var i,r=t.targetBBox;let o,s,a;switch(o=t.targetView?(s=t.targetView.model.angle(),n.rotate&&s?(t=t.targetView.getNodeUnrotatedBBox(t.targetView.el),(i=e[e.length-1].clone()).rotate(r.center(),s),t.sideNearestToPoint(i)):r.sideNearestToPoint(e[e.length-1])):r.sideNearestToPoint(e[e.length-2])){case"top":a=new A(0,-1);break;case"bottom":a=new A(0,1);break;case"right":a=new A(1,0);break;case"left":a=new A(-1,0)}return n.rotate&&s&&a.rotate(null,-s),a}function Qh(t,e){return e[1].difference(e[0]).normalize()}function tu(t,e){var n=e.length-1;return e[n-1].difference(e[n]).normalize()}function eu(t,e){t=t.sourceBBox,t=t.center();return e[0].difference(t).normalize()}function nu(t,e){t=t.targetBBox,t=t.center();return e[e.length-1].difference(t).normalize()}function iu(t,e){let n=t.dot(e)/(t.magnitude()*e.magnitude());return 1<(n=n<-1?-1:n)&&(n=1),Math.acos(n)}function ru(t,e){return t.x*e.y-t.y*e.x}Zh.Directions=Yh,Zh.TangentDirections=Xh;function ou(t){this.cid=fa("view"),this.preinitialize.apply(this,arguments),T(this,ca(t,lu)),this._ensureElement(),this.initialize.apply(this,arguments)}var su={straight:Fh,jumpover:function(t,e,n,i){qh(this);var r,o,s,u,a,c,l=i.raw,d=i.size||5,h=i.jump&&(""+i.jump).toLowerCase(),f=i.radius||0,p=i.ignoreConnectors||zh,g=(-1===Bh.indexOf(h)&&(h=Bh[0]),this.paper),i=g.model.getLinks();return 1===i.length?Wh(Hh(t,e,n),d,h,f):(r=this.model,o=i.indexOf(r),s=g.options.defaultConnector||{},i=(u=i.filter(function(t,e){t=t.get("connector")||s;return!(et(p).includes(t.name)||o<e&&"jumpover"===t.name)})).map(function(t){return g.findViewByModel(t)}),a=Hh(t,e,n),c=i.map(function(t){return null==t?[]:t===this?a:Hh(t.sourcePoint,t.targetPoint,t.route)},this),t=Wh(a.reduce(function(t,l){var s,a,h,e=u.reduce(function(t,e,n){var i;return e!==r&&(-1<(n=(e=c[n].slice()).findIndex(t=>{var[{x:e,y:n},{x:i,y:r}]=Uh((e=l).start,e.end),[{x:t,y:o},{x:s,y:a}]=Uh(t.start,t.end);return e<=s&&t<=i&&(n<=a&&o<=r)}))&&l.containsPoint(e[n].end)&&e.splice(n+1,1),i=l,n=e,e=et(n).reduce(function(t,e){e=i.intersection(e);return e&&t.push(e),t},[]),t.push.apply(t,e)),t},[]).sort(function(t,e){return $h(l.start,t)-$h(l.start,e)});return 0<e.length?t.push.apply(t,(s=l,h=d,(a=e).reduce(function(t,e,n){if(!0!==e.skip){var i=t.pop()||s,r=ci(e).move(i.start,-h),e=ci(e).move(i.start,+h),n=a[n+1];if(null!=n){var o=e.distance(n);o<=h&&(e=n.move(i.start,o),n.skip=!0)}else if(r.distance(i.end)<2*h+Dh)return t.push(i),t;e.distance(i.start)<2*h+Dh?t.push(i):((o=pi(r,e)).isJump=!0,t.push(pi(i.start,r),o,pi(e,i.end)))}return t},[]))):t.push(l),t},[]),d,h,f),l?t:t.serialize())},normal:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],i=(3<arguments.length&&void 0!==arguments[3]?arguments[3]:{}).raw,i={cornerType:"point",raw:i};return Fh(t,e,n,i)},rounded:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],{radius:i=10,raw:r}=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},i={cornerType:"cubic",cornerRadius:i,precision:0,raw:r};return Fh(t,e,n,i)},smooth:function(t,e,n,i){var r,o,i=i&&i.raw;return n&&0!==n.length?(n=[t].concat(n).concat([e]),n=v.throughPoints(n),r=new V(n)):(r=new V,n=V.createSegment("M",t),r.appendSegment(n),n=Math.abs(t.x-e.x)>=Math.abs(t.y-e.y)?(o=(t.x+e.x)/2,V.createSegment("C",o,t.y,o,e.y,e.x,e.y)):(o=(t.y+e.y)/2,V.createSegment("C",t.x,o,e.x,o,e.x,e.y)),r.appendSegment(n)),i?r:r.serialize()},curve:Zh},au=/^(\S+)\s*(.*)$/,lu=["model","collection","el","id","attributes","className","tagName","events","style"];T(ou.prototype,Sl,{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 L?t:L(t),this.el=this.$el[0]},delegateEvents:function(t){if(t=t||S(this,"events"))for(var e in this.undelegateEvents(),t){var n=t[e];(n=b(n)?n:this[n])&&(e=e.match(au),this.delegate(e[1],e[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(){var t;this.el?this.setElement(S(this,"el")):(t=T({},S(this,"attributes")),this.id&&(t.id=S(this,"id")),this.className&&(t.class=S(this,"className")),this.setElement(this._createElement(S(this,"tagName"))),this._setAttributes(t))},_setAttributes:function(t){this.$el.attr(t)}}),ou.extend=Pl;let hu={},uu=ou.extend({options:{},theme:null,themeClassNamePrefix:ja("theme-"),requireSetThemeOverride:!1,defaultTheme:Ua.defaultTheme,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=T({},this.options,t),ou.call(this,t)},initialize:function(){(hu[this.cid]=this).setTheme(this.options.theme||this.defaultTheme),this.init()},unmount:function(){(this.svgElement?this.vel:this.$el).remove()},isMounted:function(){return null!==this.el.parentNode},renderChildren:function(t){var e,n;return(t=t||S(this,"children"))&&(e=this.svgElement,n=R.namespace[e?"svg":"xhtml"],t=$a(t,n),(e?this.vel:this.$el).empty().append(t.fragment),this.childNodes=t.selectors),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){e=this.findAttributeNode(t,e);return e&&e.getAttribute(t)},_ensureElement:function(){var t,e,n;this.el?this.setElement(S(this,"el")):(t=S(this,"tagName"),e=T({},S(this,"attributes")),n=T({},S(this,"style")),this.id&&(e.id=S(this,"id")),this.setElement(this._createElement(t)),this._setAttributes(e),this._setStyle(n)),this._ensureElClassName()},_setAttributes:function(t){(this.svgElement?this.vel:this.$el).attr(t)},_setStyle:function(t){this.$el.css(t)},_createElement:function(t){return this.svgElement?document.createElementNS(R.namespace.svg,t):document.createElement(t)},_setElement:function(t){this.$el=t instanceof L?t:L(t),this.el=this.$el[0],this.svgElement&&(this.vel=R(this.el))},_ensureElClassName:function(){var t,e=S(this,"className");e&&(t=ja(e),(this.svgElement?this.vel:this.$el).removeClass(e).addClass(t))},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){return(t=t||this.theme)&&(t=this.themeClassNamePrefix+t,(this.svgElement?this.vel:this.$el).addClass(t)),this},removeThemeClassName:function(t){t=t||this.theme;t=this.themeClassNamePrefix+t;return(this.svgElement?this.vel:this.$el).removeClass(t),this},onSetTheme:function(t,e){},remove:function(){return this.onRemove(),this.undelegateDocumentEvents(),hu[this.cid]=null,ou.prototype.remove.apply(this,arguments),this},onRemove:function(){},getEventNamespace:function(){return".joint-event-ns-"+this.cid},delegateElementEvents:function(t,e,n){if(e){n=n||{};var i,r=this.getEventNamespace();for(i in e){var o=e[i];(o="function"!=typeof o?this[o]:o)&&L(t).on(i+r,n,o.bind(this))}}return this},undelegateElementEvents:function(t){return L(t).off(this.getEventNamespace()),this},delegateDocumentEvents:function(t,e){return t=t||S(this,"documentEvents"),this.delegateElementEvents(document,t,e)},undelegateDocumentEvents:function(){return this.undelegateElementEvents(document)},eventData:function(t,e){var n,i;if(t)return n=t.data,i="__"+this.cid+"__",void 0===e?n&&n[i]||{}:((n=n||(t.data={}))[i]||(n[i]={}),T(n[i],e),this);throw new Error("eventData(): event object required.")},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]&&T({},t[0])||{},t=t[1]&&T({},t[1])||{},n=e.render||this.prototype&&this.prototype.render||null;return e.render=function(){return"function"==typeof n&&n.apply(this,arguments),this.render.__render__===n&&this.onRender(),this},e.render.__render__=n,ou.extend.call(this,e,t)}});function cu(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,T({silent:!0},e))}function du(t,e,n){n=Math.min(Math.max(n,0),t.length);for(var i=Array(t.length-n),r=e.length,o=0;o<i.length;o++)i[o]=t[o+n];for(o=0;o<r;o++)t[o+n]=e[o];for(o=0;o<i.length;o++)t[o+r+n]=i[o]}var fu,pu,gu,mu={add:!0,remove:!0,merge:!0},vu={add:!0,remove:!1},Rh=(T(cu.prototype,Sl,{model:El,preinitialize:function(){},initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},add:function(t,e){return this.set(t,T({merge:!1},e,vu))},remove:function(t,e){e=T({},e);var n=!Array.isArray(t),t=(t=n?[t]:t.slice(),this._removeModels(t,e));return!e.silent&&t.length&&(e.changes={added:[],merged:[],removed:t},this.trigger("update",this,e)),n?t[0]:t},set:function(t,e){if(null!=t){e=T({},mu,e);for(var n=!Array.isArray(t),i=(t=n?[t]:t.slice(),e.at),r=((i=(i=null!=i?+i:i)>this.length?this.length:i)<0&&(i+=this.length+1),[]),o=[],s=[],a=[],l={},h=e.add,u=e.merge,c=e.remove,d=!1,f=this.comparator&&null==i&&!1!==e.sort,p=E(this.comparator)?this.comparator:null,g=0;g<t.length;g++){var m,v=t[g],y=this.get(v);y?(u&&v!==y&&(m=this._isModel(v)?v.attributes:v,y.set(m,e),s.push(y),f)&&!d&&(d=y.hasChanged(p)),l[y.cid]||(l[y.cid]=!0,r.push(y)),t[g]=y):h&&(v=t[g]=this._prepareModel(v,e))&&(o.push(v),this._addReference(v,e),l[v.cid]=!0,r.push(v))}if(c){for(g=0;g<this.length;g++)l[(v=this.models[g]).cid]||a.push(v);a.length&&this._removeModels(a,e)}var b=!1;if(r.length&&(!f&&h&&c)?(b=this.length!==r.length||this.models.some(function(t,e){return t!==r[e]}),this.models.length=0,du(this.models,r,0),this.length=this.models.length):o.length&&(f&&(d=!0),du(this.models,o,null==i?this.length:i),this.length=this.models.length),d&&this.sort({silent:!0}),!e.silent){for(g=0;g<o.length;g++)null!=i&&(e.index=i+g),(v=o[g]).trigger("add",v,this,e);(d||b)&&this.trigger("sort",this,e),(o.length||a.length||s.length)&&(e.changes={added:o,removed:a,merged:s},this.trigger("update",this,e))}return n?t[0]:t}},reset:function(t,e){e=e?f(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,T({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,T({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,T({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 b(e)&&(e=e.bind(this)),1===n||E(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 yu(this,bu)},keys:function(){return new yu(this,xu)},entries:function(){return new yu(this,wu)},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){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]: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):(t=((e=e?f(e):{}).collection=this).model.prototype?new this.model(t,e):this.model(t,e)).validationError?(this.trigger("invalid",this,t.validationError,e),!1):t},_removeModels:function(t,e){for(var n=[],i=0;i<t.length;i++){var r,o,s=this.get(t[i]);s&&(r=this.models.indexOf(s),this.models.splice(r,1),this.length--,delete this._byId[s.cid],null!=(o=this.modelId(s.attributes,s.idAttribute))&&delete this._byId[o],e.silent||(e.index=r,s.trigger("remove",s,this,e)),n.push(s),this._removeReference(s,e))}return 0<t.length&&!e.silent&&delete e.index,n},_isModel:function(t){return t instanceof El},_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;"changeId"===t&&(n=this.modelId(e.previousAttributes(),e.idAttribute),t=this.modelId(e.attributes,e.idAttribute),null!=n&&delete this._byId[n],null!=t)&&(this._byId[t]=e)}this.trigger.apply(this,arguments)}}),"function"==typeof Symbol&&Symbol.iterator),yu=(Rh&&(cu.prototype[Rh]=cu.prototype.values),function(t,e){this._collection=t,this._kind=e,this._index=0}),bu=1,xu=2,wu=3,i=(Rh&&(yu.prototype[Rh]=function(){return this}),yu.prototype.next=function(){if(this._collection){var t,e;if(this._index<this._collection.length)return t=this._collection.at(this._index),this._index++,{value:this._kind===bu?t:(e=this._collection.modelId(t.attributes,t.idAttribute),this._kind===xu?e:[e,t]),done:!1};this._collection=void 0}return{value:void 0,done:!0}},[cu,{toArray:1,sortBy:3},"models"]);u=(s=i)[0],s=i[2],l={sortBy:ra,toArray:et},fu=u,pu=l,u=i[1],gu=s,pa(u,function(t,e){pu[e]&&(fu.prototype[e]=Il(pu,t,e,gu))}),cu.extend=Pl;Ln={Data:va,$:L,views:hu,View:uu,Listener:class{constructor(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];this.callbackArguments=e}listenTo(r,n){let o=this.callbackArguments;for(var t=arguments.length,s=new Array(2<t?t-2:0),e=2;e<t;e++)s[e-2]=arguments[e];if(n&&"object"==typeof n){let[i=null]=s;Object.entries(n).forEach(t=>{let[e,n]=t;"function"==typeof n&&((i||0<o.length)&&(n=n.bind(i,...o)),Sl.listenTo.call(this,r,e,n))})}else if("string"==typeof n&&"function"==typeof s[0]){let[t,e=null]=s;(e||0<o.length)&&(t=t.bind(e,...o)),Sl.listenTo.call(this,r,n,t)}}stopListening(){Sl.stopListening.call(this)}},Events:Sl,Collection:cu,Model:El,ViewBase:ou,Event:ya};function Au(t){return t?Array.isArray(t)?t:[t]:[]}let Pu=uu.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){var n=t.paper;this.cellView=t,this.nodeSelector=e,n&&(this.updateRequested=!0,n.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY))},confirmUpdate(){this.updateRequested=!1;var{cellView:t,nodeSelector:e}=this;return t.isMounted()?(this.update(t,e),this.mount(),this.transform()):this.postponedUpdate=!0,0},findNode(t){var e,n,i,r,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;let s;return"string"==typeof o?s=t.findNode(o):y(o)?(e=t.model.isLink(),{label:n=null,port:i,selector:r}=o,s=e&&null!==n?t.findLabelNode(n,r):!e&&i?t.findPortNode(i,r):t.findNode(r)):!o||(s=R.toNode(o))instanceof SVGElement||(s=null),s||null},getNodeMatrix(t,e){var n=this.options,n=n.layer,i=t.rotatableNode,r=t.getNodeMatrix(e);return i?n?i.contains(e)?r:t.getRootRotateMatrix().inverse().multiply(r):t.getNodeRotateMatrix(e).multiply(r):r},mount(){var{MOUNTABLE:t,cellView:e,el:n,options:i,transformGroup:r,detachedTransformGroup:o,postponedUpdate:s,nodeSelector:a}=this;if(t&&!r)if(s)this.update(e,a),this.transform();else{var{vel:t,paper:r}=e,s=i.layer;if(s){let t;o?(t=o,this.detachedTransformGroup=null):t=R("g").addClass("highlight-transform").append(n),this.transformGroup=t,r.getLayerView(s).insertSortedNode(t.node,i.z)}else n.parentNode&&!n.nextSibling||t.append(n)}},unmount(){var{MOUNTABLE:t,transformGroup:e,vel:n}=this;t&&(e?(this.transformGroup=null,this.detachedTransformGroup=e):n).remove()},transform(){var{transformGroup:t,cellView:e,updateRequested:n}=this;!t||e.model.isLink()||n||(n=e.getRootTranslateMatrix(),e=e.getRootRotateMatrix(),n=n.multiply(e),t.attr("transform",R.matrixToTransformString(n)))},update(){var{node:t,cellView:e,nodeSelector:n,updateRequested:i,id:r}=this;i||(this.postponedUpdate=!1,i=this.node=this.findNode(e,n),t&&this.unhighlight(e,t),i?(this.highlight(e,i),this.mount()):(this.unmount(),e.notify("cell:highlight:invalid",r,this)))},onRemove(){var{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){var e=S(this,"UPDATE_ATTRIBUTES");Array.isArray(e)&&0!==e.length&&this.listenTo(t.model,"change",this.onCellAttributeChange)},onCellAttributeChange(){var n=this.cellView;if(n){let{model:e,paper:t}=n;S(this,"UPDATE_ATTRIBUTES").some(t=>e.hasChanged(t))&&t.requestViewUpdate(this,this.HIGHLIGHT_FLAG,this.UPDATE_PRIORITY)}}},{_views:{},highlight:function(t,e,n){var i=this.uniqueId(e,n);this.add(t,e,i,n)},unhighlight:function(t,e,n){e=this.uniqueId(e,n);this.remove(t,e)},get(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,t=t.cid,n=this._views,i=n[t];if(null===e){var r=[];if(i)for(var o in i){o=i[o];o instanceof this&&r.push(o)}return r}if(i&&e in i){n=i[e];if(n instanceof this)return n}return null},add(t,e,n){var i,r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(n)return(i=Pu.get(t,n))&&i.remove(),(i=new this(r)).id=n,this._addRef(t,n,i),i.requestUpdate(t,e),i.listenToUpdateAttributes(t),i;throw new Error("dia.HighlighterView: An ID required.")},_addRef(t,e,n){var t=t.cid,i=this._views;let r=i[t];(r=r||(i[t]={}))[e]=n},_removeRef(t,e){var t=t.cid,n=this._views,i=n[t];if(i){for(var r in e&&delete i[e],i)return;delete n[t]}},remove(t){Au(this.get(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)).forEach(t=>{t.remove()})},getAll(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,i=[],r=this._views;for(e in r)for(var o in r[e]){var s=r[e][o];s.cellView.paper===t&&s instanceof this&&(null===n||o===n)&&i.push(s)}return i},removeAll(t){this.getAll(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null).forEach(t=>t.remove())},update(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;let n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];Au(this.get(t,e)).forEach(t=>{(n||t.UPDATABLE)&&t.update()})},transform(t){Au(this.get(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)).forEach(t=>{t.UPDATABLE&&t.transform()})},unmount(t){Au(this.get(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)).forEach(t=>t.unmount())},mount(t){Au(this.get(t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:null)).forEach(t=>t.mount())},uniqueId(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";return R.ensureId(t)+JSON.stringify(e)}});a=Pu.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(e,n){var i=this.options,t=i.useFirstSubpath;let r;try{var o,s=R(n);r=s.convertToPathData().trim(),"PATH"===s.tagName()&&t&&0<(o=r.search(/.M/i)+1)&&(r=r.substr(0,o))}catch(t){s=e.getNodeBoundingRect(n);r=R.rectToPath(T({},i,s.toJSON()))}return r},highlightConnection(t){this.vel.attr("d",t.getSerializedConnection())},highlightNode(t,e){var n,i,r,{vel:o,options:s}=this,{padding:s,layer:a}=s;let l=this.getNodeMatrix(t,e);s&&(a||e!==t.el||o.remove(),n=(a=t.getNodeBoundingRect(e)).x+a.width/2,i=a.y+a.height/2,a=R.transformRect(a,l),r=((r=Math.max(a.width,1))+s)/r,s=((a=Math.max(a.height,1))+s)/a,a=R.createSVGMatrix({a:r,b:0,c:0,d:s,e:n-r*n,f:i-s*i}),l=l.multiply(a)),o.attr({d:this.getPathData(t,e),transform:R.matrixToTransformString(l)})},highlight(t,e){var{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)}});Je=Pu.extend({tagName:"rect",className:"highlight-mask",attributes:{"pointer-events":"none"},options:{padding:3,maskClip:20,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(e,n){var{MASK_CHILD_ATTRIBUTE_BLACKLIST:t,MASK_REPLACE_TAGS:i,MASK_REMOVE_TAGS:r}=this,o=n.tagName();if(!R.isSVGGraphicsElement(n)||r.includes(o))return n.remove(),!1;if(i.includes(o)){r=e.vel.findOne("#"+n.id);if(r){i=r.node;let t=e.getNodeBoundingRect(i);e.model.isElement()&&(t=R.transformRect(t,e.getNodeMatrix(i)));var o=R("rect",t.toJSON()),{x:e,y:i}=t.center(),{angle:r,cx:e=e,cy:i=i}=r.rotate();r&&o.rotate(r,e,i),n.parent().append(o)}return n.remove(),!1}return t.forEach(t=>{"fill"===t&&"none"===n.attr("fill")||n.removeAttr(t)}),!0},transformMaskRoot(t,e){var n=this.MASK_ROOT_ATTRIBUTE_BLACKLIST;n.forEach(t=>{e.removeAttr(t)})},getMaskShape(e,t){var{options:n,MASK_REPLACE_TAGS:i}=this,n=n.deep,r=t.tagName();let o;if("G"===r){if(!n)return null;for(var n=o=t.clone(),s=t=>this.transformMaskChild(e,t),a=n.children();0<a.length;){var l=a.shift();s(l)&&a.push(...l.children())}}else{if(i.includes(r))return null;o=t.clone()}return this.transformMaskRoot(e,o),o},getMaskId(){return"highlight-mask-"+this.cid},getMask(t,e){var{VISIBLE:n,INVISIBLE:i,options:r}=this,{padding:r,attrs:o}=r,s=parseFloat(R("g").attr(o).attr("stroke-width")),a="none"!==e.attr("fill");let l=parseFloat(e.attr("stroke-width"));r=(l=isNaN(l)?1:l)+2*r,s=r+2*s;let h=this.getMaskShape(t,e);return h||((t=t.getNodeBoundingRect(e.node)).inflate(t.width?0:.5,t.height?0:.5),h=R("rect",t.toJSON())),h.attr(o),R("mask",{id:this.getMaskId()}).append([h.clone().attr({fill:a?n:"none",stroke:n,"stroke-width":s}),h.clone().attr({fill:a?i:"none",stroke:i,"stroke-width":r})])},removeMask(t){var e=t.svg.getElementById(this.getMaskId());e&&t.defs.removeChild(e)},addMask(t,e){t.defs.appendChild(e.node)},highlight(t,e){var{options:n,vel:i}=this,{padding:n,attrs:r,maskClip:o=20,layer:s}=n,r="stroke"in r?r.stroke:"#000000",s=(s||e!==t.el||i.remove(),t.getNodeBoundingRect(e).inflate(n+o)),n=this.getNodeMatrix(t,e),o=this.getMask(t,R(e));this.addMask(t.paper,o),i.attr(s.toJSON()),i.attr({transform:R.matrixToTransformString(n),mask:`url(#${o.id})`,fill:r})},unhighlight(t){this.removeMask(t.paper)}}),e=Pu.extend({UPDATABLE:!1,MOUNTABLE:!1,highlight:function(t,e){var{alphaValue:n=.3}=this.options;e.style.opacity=n},unhighlight:function(t,e){e.style.opacity=""}}),r=ja("highlighted"),h=Pu.extend({UPDATABLE:!1,MOUNTABLE:!1,options:{className:r},highlight:function(t,e){R(e).addClass(this.options.className)},unhighlight:function(t,e){R(e).removeClass(this.options.className)}},{className:r});let Eu={ROW:"row",COLUMN:"column"};n={stroke:a,mask:Je,opacity:e,addClass:h,list:Pu.extend({tagName:"g",MOUNTABLE:!0,UPDATE_ATTRIBUTES:function(){return[this.options.attribute]},_prevItems:null,highlight(t,e){t=t.model;let{attribute:r,size:n=20,gap:o=5,direction:i=Eu.ROW}=this.options;if(!r)throw new Error("List: attribute is required");let s="number"==typeof n?{width:n,height:n}:n,a=i===Eu.ROW,l=a?s.width:s.height,h=t.get(r),u=(Array.isArray(h)||(h=[]),this._prevItems||[]),c=h.map((t,e)=>na(u[e],h[e]));if(u.length!==h.length||c.some(t=>!t)){let i=this.vel.children();var d=h.map((t,e)=>{var n=e in i?i[e].node:null;if(c[e])return n;t=this.createListItem(t,s,n);if(!t)return null;if(!(t instanceof SVGElement))throw new Error("List: item must be an SVGElement");t.dataset.index=e,t.dataset.attribute=r;n=e*(l+o);return t.setAttribute("transform",a?`translate(${n}, 0)`:`translate(0, ${n})`),t});this.vel.empty().append(d),this._prevItems=h}d=h.length,d=0===d?0:d*l+(d-1)*o,d=a?{width:d,height:s.height}:{width:s.width,height:d};this.position(t,d)},position(t,e){var{vel:n,options:i}=this,{margin:i=5,position:r="top-left"}=i,{width:t,height:o}=t.size(),{left:i,right:s,top:a,bottom:l}=gl(i);let{x:h,y:u}=yh(new tt(i,a,t-(i+s),o-(a+l)),r);switch(r){case p.CENTER:case p.TOP:case p.BOTTOM:h-=e.width/2;break;case p.RIGHT:case p.BOTTOM_RIGHT:case p.TOP_RIGHT:h-=e.width}switch(r){case p.CENTER:case p.RIGHT:case p.LEFT:u-=e.height/2;break;case p.BOTTOM:case p.BOTTOM_RIGHT:case p.BOTTOM_LEFT:u-=e.height}n.attr("transform",`translate(${h}, ${u})`)}},{Directions:Eu,Positions:p})};function Tu(t,e,n){var i,r,o;return y(n)&&({x:i,y:o}=n,isFinite(o)&&({start:o,end:r}=new P(e,t).parallel(o),e=o,t=r),n=i),!isFinite(n)||(o=t.distance(e),0===n&&0<o)?t:t.move(e,-Math.min(n,o-1))}function Su(t){t=t.getAttribute("stroke-width");return null!==t&&parseFloat(t)||0}function ku(t,e,n,i){e=e.getNodeBBox(n),i.stroke&&e.inflate(Su(n)/2),n=t.intersect(e);return Tu(n?t.start.chooseClosest(n):t.end,t.start,i.offset)}var Lu="segmentSubdivisons",Cu="shapeBBox";$e={anchor:function(t,e,n,i){var{offset:i,alignOffset:r,align:o}=i;return o&&function(t,e,n){n=2<arguments.length&&void 0!==n?n:0;let i,r,o,s;var{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,o,r),Tu(t.end,t.start,i)},bbox:ku,rectangle:function(t,e,n,i){var r,o=e.model.angle();return 0===o?ku(t,e,n,i):(e=e.getNodeUnrotatedBBox(n),i.stroke&&e.inflate(Su(n)/2),n=e.center(),Tu((e=(r=t.clone().rotate(n,o)).setLength(1e6).intersect(e))?r.start.chooseClosest(e).rotate(n,-o):t.end,t.start,i.offset))},boundary:function(t,e,n,i){var r=i.selector,o=t.end,r="string"==typeof r?e.findNode(r):!1===r?n:Array.isArray(r)?Ya(n,r):(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);if(!R.isSVGGraphicsElement(r)){if(r===n||!R.isSVGGraphicsElement(n))return o;r=n}var s,n=e.getNodeShape(r),a=e.getNodeMatrix(r),l=e.getRootTranslateMatrix(),h=e.getRootRotateMatrix(),h=(l=l.multiply(h).multiply(a)).inverse(),h=(a=R.transformLine(t,h)).start.clone(),e=e.getNodeData(r);return!1===i.insideout&&(e[Cu]||(e[Cu]=n.bbox()),e[Cu].containsPoint(h))?o:(n instanceof V&&(s=i.precision||2,e[Lu]||(e[Lu]=n.getSegmentSubdivisions({precision:s})),s={precision:s,segmentSubdivisions:e[Lu]}),!0===i.extrapolate&&a.setLength(1e6),(e=a.intersect(n,s))?R.isArray(e)&&(e=h.chooseClosest(e)):!0===i.sticky&&(e=n instanceof tt?n.pointNearestToPoint(h):n instanceof yi?n.intersectionWithLineFromCenterToPoint(h):n.closestPoint(h,s)),a=e?R.transformPoint(e,l):o,n=i.offset||0,i.stroke&&(n+=Su(r)/2),Tu(a,t.start,n))}};function Mu(t,e){return 0===e?"0%":Math.round(t/e*100*1e3)/1e3+"%"}function _u(r){return function(t,e,n,i){return(e.isNodeConnection(n)?Ou:Nu)(r,t,e,n,i)}}function Nu(t,e,n,i,r){var o=n.model.angle(),i=n.getNodeUnrotatedBBox(i),n=n.model.getBBox().center(),n=(r.rotate(n,o),r.x-i.x),o=r.y-i.y;return t&&(n=Mu(n,i.width),o=Mu(o,i.height)),e.anchor={name:"topLeft",args:{dx:n,dy:o,rotate:!0}},e}function Ou(t,e,n,i,r){n=n.getConnection();return n&&(r=n.closestPointLength(r),t?(t=n.length(),e.anchor={name:"connectionRatio",args:{ratio:r/t}}):e.anchor={name:"connectionLength",args:{length:r}}),e}Rh=_u(!1);let Ru=_u(!0),Fu={useDefaults:wl,pinAbsolute:Rh,pinRelative:Ru};var Iu={N:"S",S:"N",E:"W",W:"E"},Vu={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function Bu(t,e,n){var i=new A(t.x,e.y);return i=n.containsPoint(i)?new A(e.x,t.y):i}function Du(t,e){return t["W"===e||"E"===e?"width":"height"]}function zu(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 ju(t){return new tt(t.x,t.y,0,0)}function Gu(t){t=gl(t.padding||t.elementPadding||20);return{x:-t.left,y:-t.top,width:t.left+t.right,height:t.top+t.bottom}}function Uu(t,e){return t.sourceBBox.clone().moveAndExpand(Gu(e))}function Hu(t,e){return t.targetBBox.clone().moveAndExpand(Gu(e))}function qu(t,e,n){var i=new A(t.x,e.y),r=new A(e.x,t.y),o=zu(t,i),t=zu(t,r),s=Iu[n],o=o===n||o!==s&&(t===s||t!==n)?i:r;return{points:[o],direction:zu(o,e)}}function $u(t,e,n){t=Bu(t,e,n);return{points:[t],direction:zu(t,e)}}function Wu(t,e,n,i,r){var o={},n=n.union(i).inflate(1),i=n.center().distance(e)>n.center().distance(t),s=i?e:t,t=i?t:e,a=r?(a=A.fromPolar(n.width+n.height,Vu[r],s),n.pointNearestToPoint(a).move(a,-1)):n.pointNearestToPoint(s).move(s,1),r=Bu(a,t,n);return a.round().equals(r.round())?(r=A.fromPolar(n.width+n.height,Jn(a.theta(s))+Math.PI/2,t),s=Bu(a,r=n.pointNearestToPoint(r).move(t,1).round(),n),o.points=i?[r,s,a]:[a,s,r]):o.points=i?[r,a]:[a,r],o.direction=zu(i?a:r,e),o}function Yu(t,e,n){var i,r,o=Uu(n,e),s=Hu(n,e),a=(i=e,(a=n).sourceAnchor||Uu(a,i).center()),n=(i=e,(n=n).targetAnchor||Hu(n,i).center()),o=o.union(ju(a)),s=s.union(ju(n));(t=et(t).map(A)).unshift(a),t.push(n);for(var l,h,u,c,d,f,p=[],g=0,m=t.length-1;g<m;g++){var v,y=null,b=t[g],x=t[g+1],w=!!zu(b,x);0===g?g+1===m?o.intersect(s.clone().inflate(1))?y=Wu(b,x,o,s):w||(h=o,f=d=c=void 0,d=$u(v=x,l=b,u=s),f=d.points[0],h.containsPoint(f)&&(c=(d=$u(l,v,h)).points[0],u.containsPoint(c))&&(c=new A(l).move(c,-Du(h,zu(l,c))/2),u=new A(v).move(f,-Du(u,zu(v,f))/2),u=qu(f=new P(c,u).midpoint(),v,(c=$u(l,f,h)).direction),d.points=[c.points[0],u.points[0]],d.direction=u.direction),y=d):o.containsPoint(x)?y=Wu(b,x,o,ju(x).moveAndExpand(Gu(e))):w||(y=$u(b,x,o)):g+1===m?(v=w&&zu(x,b)===r,s.containsPoint(b)||v?y=Wu(b,x,ju(b).moveAndExpand(Gu(e)),s,r):w||(y=((e,t,n,i)=>{var r,o={},s=[new A(e.x,t.y),new A(t.x,e.y)],a=s.filter(function(t){return!n.containsPoint(t)}),l=a.filter(function(t){return zu(t,e)!==i});return 0<l.length?(r=(r=l.filter(function(t){return zu(e,t)===i}).pop())||l[0],o.points=[r],o.direction=zu(r,t)):(r=la(s,a)[0],s=Bu(l=new A(t).move(r,-Du(n,i)/2),e,n),o.points=[s,l],o.direction=zu(l,t)),o})(b,x,s,r))):w||(y=qu(b,x,r)),r=y?(Array.prototype.push.apply(p,y.points),y.direction):zu(b,x),g+1<m&&p.push(x)}return p}var Xu={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(b(Yu))return Yu(t,T({},Xu,e),n);throw new Error("Manhattan requires the orthogonal router as default fallback.")},fallbackRoute:function(t,e,n){return null},draggingRoute:null};function Zu(t){this.map={},this.options=t,this.mapGridSize=100}function Ju(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}function Ku(t,e){return e&&e.paddingBox?t.sourceBBox.clone().moveAndExpand(e.paddingBox):t.sourceBBox.clone()}function Qu(t,e){return e&&e.paddingBox?t.targetBBox.clone().moveAndExpand(e.paddingBox):t.targetBBox.clone()}function tc(t,e){return t.sourceAnchor||Ku(t,e).center()}function ec(t,e,n,i,r){var o,n=360/n,i=t.theta((t=t,e=e,r=(r=r).step,o=e.x-t.x,e=e.y-t.y,o=o/i.x*r,e=e/i.y*r,new A(t.x+o,t.y+e))),r=Xn(i+n/2);return n*Math.floor(r/n)}function nc(t,e){t=Math.abs(t-e);return 180<t?360-t:t}function ic(t,e){var n;return t?(t=Math.abs(t),(n=Math.round(t/e))?e+(t-n*e)/n:t):e}function rc(t,e){return t.round(e)}function oc(t,e,n){return rc((t=t.clone(),i=(e=e).source,r=Zn(t.x-i.x,e.x)+i.x,t=Zn(t.y-i.y,e.y)+i.y,new A(r,t)),n);var i,r}function sc(t){return t.clone().toString()}function ac(t){return new A(0===t.x?0:Math.abs(t.x)/t.x,0===t.y?0:Math.abs(t.y)/t.y)}function lc(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 hc(u,c,t,d,e){var f=e.precision,p=e.directionMap,g=u.difference(c.center()),e=w(p)?Object.keys(p):[],m=et(t),t=e.reduce(function(t,e){if(m.includes(e)){for(var n,e=p[e],i=new A(u.x+e.x*(Math.abs(g.x)+c.width),u.y+e.y*(Math.abs(g.y)+c.height)),r=new P(u,i).intersect(c)||[],o=r.length,s=null,a=0;a<o;a++){var l=r[a],h=u.squaredDistance(l);(void 0===n||n<h)&&(n=h,s=l)}s&&(i=oc(s,d,f),c.containsPoint(i)&&(i=oc(i.offset(e.x*d.x,e.y*d.y),d,f)),t.push(i))}return t},[]);return c.containsPoint(u)||t.push(oc(u,d,f)),t}function uc(t,e,n,i){var r,o,s,a,l,h,u,c=i.precision,d=t instanceof tt?rc(tc(this,i).clone(),c):rc(t.clone(),c),f=e instanceof tt?rc((r=i,((f=this).targetAnchor||Qu(f,r).center()).clone()),c):rc(e.clone(),c),p=(r=i.step,h=f,{source:(o=d).clone(),x:ic(h.x-o.x,r),y:ic(h.y-o.y,r)}),g=t instanceof tt?hc(s=d,t,i.startDirections,p,i):[s=d],m=e instanceof tt?hc(a=f,e,i.endDirections,p,i):[a=f];if(g=g.filter(t=>!n(t)),m=m.filter(t=>!n(t)),0<g.length&&0<m.length){for(var v=new Ju,y={},b={},x={},w=0,I=g.length;w<I;w++){var A=g[w],P=sc(A);v.add(P,lc(A,m)),y[P]=A,x[P]=0}for(var V=i.previousDirectionAngle,B=void 0===V,D=i.directions,E=(l=p,u=(h=i).step,et(h.directions).forEach(function(t){t.gridOffsetX=t.offsetX/u*l.x,t.gridOffsetY=t.offsetY/u*l.y}),D.length),z=et(m).reduce(function(t,e){e=sc(e);return t.push(e),t},[]),j=i.maximumLoops;!v.isEmpty()&&0<j;){var T=v.pop(),S=y[T],k=b[T],G=x[T],L=void 0===k,U=S.equals(s),H=L?B?U?null:ec(s,S,E,p,i):V:ec(k,S,E,p,i),q=g.length===m.length;if(q)for(var C=0;C<g.length;C++)if(!g[C].equals(m[C])){q=!1;break}if(!(L&&q)&&0<=z.indexOf(T)){i.previousDirectionAngle=H;for(var $=b,W=y,k=S,L=s,T=a,Y=[],X=ac(T.difference(k)),M=sc(k),_=$[M];_;){var Z,J=ac((Z=W[M]).difference(_));J.equals(X)||(Y.unshift(Z),X=J),_=$[M=sc(_)]}return ac((T=W[M]).difference(L)).equals(X)||Y.unshift(T),Y}for(w=0;w<E;w++){var N,K=(N=D[w]).angle,Q=nc(H,K);if(B&&U||!(Q>i.maxAllowedDirectionChange)){var O=oc(S.clone().offset(N.gridOffsetX,N.gridOffsetY),p,c),R=sc(O);if(!v.isClose(R)&&!n(O)){if(0<=z.indexOf(R)){var F=O.equals(a);if(!F)if(nc(K,ec(O,a,E,p,i))>i.maxAllowedDirectionChange)continue}F=G+N.cost+(U?0:i.penalties[Q]);(!v.isOpen(R)||F<x[R])&&(y[R]=O,b[R]=S,v.add(R,(x[R]=F)+lc(O,m)))}}}j--}}return i.fallbackRoute.call(this,s,a,i)}function cc(t,n,i){(e=n).directions=S(e,"directions"),e.penalties=S(e,"penalties"),e.paddingBox=S(e,"paddingBox"),e.padding=S(e,"padding"),e.padding&&(r=gl(e.padding),e.paddingBox={x:-r.left,y:-r.top,width:r.left+r.right,height:r.top+r.bottom}),et(e.directions).forEach(function(t){var e=new A(0,0),n=new A(t.offsetX,t.offsetY);t.angle=Xn(e.theta(n))}),i.options.perpendicular=!!n.perpendicular;var e,r,o=Ku(i,n),s=Qu(i,n),a=tc(i,n);let l;if("function"==typeof n.isPointObstacle)l=n.isPointObstacle;else{let e=new Zu(n);e.build(i.paper.model,i.model),l=t=>!e.isPointAccessible(t)}for(var h=et(t).map(A),u=[],c=a,d=0,f=h.length;d<=f;d++){var p,g,m=null,v=p||o;if((p=h[d])||(p=s,i.model.get("source").id&&i.model.get("target").id)||!b(n.draggingRoute)||(y=v===o?a:v,g=p.origin(),m=n.draggingRoute.call(i,y,g,n)),null===(m=m||uc.call(i,v,p,l,n)))return n.fallbackRouter(t,n,i);var y=m[0];y&&y.equals(c)&&m.shift(),c=m[m.length-1]||c,Array.prototype.push.apply(u,m)}return u}Zu.prototype.build=function(n,i){var c=this.options,d=et(c.excludeEnds).reduce(function(t,e){var e=i.get(e);return e&&(e=n.getCell(e.id))&&t.push(e),t},[]),f=[],t=n.getCell(i.get("source").id),t=(t&&(f=ha(f,t.getAncestors().map(function(t){return t.id}))),n.getCell(i.get("target").id)),p=(t&&(f=ha(f,t.getAncestors().map(function(t){return t.id}))),this.mapGridSize);return n.getElements().reduce(function(t,e){var n=et(c.excludeTypes).includes(e.get("type")),i=d.find(function(t){return t.id===e.id}),r=f.includes(e.id);if(!(n||i||r))for(var o=e.getBBox().moveAndExpand(c.paddingBox),s=o.origin().snapToGrid(p),a=o.corner().snapToGrid(p),l=s.x;l<=a.x;l+=p)for(var h=s.y;h<=a.y;h+=p){var u=l+"@"+h;t[u]=t[u]||[],t[u].push(o)}return t},this.map),this},Zu.prototype.isPointAccessible=function(e){var t=e.clone().snapToGrid(this.mapGridSize).toString();return et(this.map[t]).every(function(t){return!t.containsPoint(e)})},Ju.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;e=Ks(this.items,t,function(t){return this.values[t]}.bind(this));this.items.splice(e,0,t)},Ju.prototype.remove=function(t){this.hash[t]=this.CLOSE},Ju.prototype.isOpen=function(t){return this.hash[t]===this.OPEN},Ju.prototype.isClose=function(t){return this.hash[t]===this.CLOSE},Ju.prototype.isEmpty=function(){return 0===this.items.length},Ju.prototype.pop=function(){var t=this.items.shift();return this.remove(t),t};function dc(t,e,n){return cc(t,T({},Xu,e),n)}var fc={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},a=(90<i%180&&(a=o,o=s,s=a),i%90<45?o:s),o=new P(t,a),s=90*Math.ceil(i/90),i=A.fromPolar(o.squaredLength(),Jn(135+s),a),s=new P(e,i),a=o.intersection(s),i=a||e,o=a?i:t,s=360/n.directions.length,a=o.theta(e),t=Xn(a+s/2),o=s*Math.floor(t/s);return n.previousDirectionAngle=o,i&&r.push(i.round()),r.push(e),r}};let B={AUTO:"auto",LEFT:"left",RIGHT:"right",TOP:"top",BOTTOM:"bottom",ANCHOR_SIDE:"anchor-side",MAGNET_SIDE:"magnet-side"},pc=[B.LEFT,B.RIGHT,B.TOP,B.BOTTOM],gc={[B.LEFT]:B.RIGHT,[B.RIGHT]:B.LEFT,[B.TOP]:B.BOTTOM,[B.BOTTOM]:B.TOP},mc=[B.TOP,B.BOTTOM],vc={0:B.RIGHT,180:B.LEFT,270:B.TOP,90:B.BOTTOM};function yc(t){return t.angle()}function bc(t){return new x(t).simplify({threshold:1}).points}function xc(t,e){var{point:t,x0:n,y0:i,view:r,bbox:o,direction:s}=t,{point:e,x0:a,y0:l,view:h,bbox:u,direction:c}=e;let d;d=r?r.model.isLink()?Ac(e,t,r):s===B.ANCHOR_SIDE?o.sideNearestToPoint(t):s===B.MAGNET_SIDE?r.model.getBBox().sideNearestToPoint(t):s:(o=new tt(n,i,0,0),pc.includes(s)?s:o.sideNearestToPoint(e));let f;return f=h?h.model.isLink()?Ac(t,e,h):c===B.ANCHOR_SIDE?u.sideNearestToPoint(e):c===B.MAGNET_SIDE?h.model.getBBox().sideNearestToPoint(e):c:(r=new tt(a,l,0,0),pc.includes(c)?c:r.sideNearestToPoint(t)),[d,f]}function wc(t,e,n){var[i]=xc(t,e);switch(i){case B.TOP:var r=e,o=n,{x0:s,y0:a,width:l,height:h,point:u,margin:c}=s=t,h=a+h,d=s-c,s=s+l+c,l=a-c,c=u.x,{x0:u,y0:r}=r;return u===c&&r<a?B.BOTTOM:u<c&&r<l?o.point.x===c?B.BOTTOM:B.RIGHT:c<u&&r<l?o.point.x===c?B.BOTTOM:B.LEFT:u<d&&l<r||s<u&&l<r?B.TOP:d<=u&&u<=c&&h<r||u<=s&&c<=u&&h<r?o.point.x<u?B.RIGHT:B.LEFT:B.BOTTOM;case B.RIGHT:var a=e,l=n,{y0:d,x0:s,width:c,height:h,point:r,margin:o}=d=t,c=s+c+o,u=d-o,d=d+h+o,{x:h,y:o}=r,{x0:r,y0:a}=a;return h<r&&a===o?B.LEFT:c<=r&&a<o?B.BOTTOM:c<=r&&o<a?B.TOP:r<=c&&a<u||r<=c&&d<a?B.RIGHT:r<s&&u<=a&&a<=o||r<s&&a<=d&&o<=a?l.point.y<a?B.BOTTOM:B.TOP:B.LEFT;case B.BOTTOM:var f=e,p=n,{x0:g,y0:m,width:v,height:y,point:b,margin:x}=g=t,w=g-x,g=g+v+x,v=(y=m+y)+x,x=b.x,{x0:b,y0:f}=f;return b===x&&y<f?B.TOP:b<x&&v<f?p.point.x===x?B.TOP:B.RIGHT:x<b&&v<f?p.point.x===x?B.TOP:B.LEFT:b<w&&f<v||g<b&&f<v?B.BOTTOM:w<=b&&b<=x&&f<m||b<=g&&x<=b&&f<m?p.point.x<b?B.RIGHT:B.LEFT:B.TOP;case B.LEFT:var y=e,v=n,{y0:w,x0:g,width:x,height:f,point:m,margin:p}=w=t,x=g+x,g=g-p,b=w-p,w=w+f+p,{x:f,y:p}=m,{x0:m,y0:y}=y;return m<f&&y===p?B.RIGHT:m<=g&&y<p?B.BOTTOM:m<=g&&p<y?B.TOP:g<=m&&y<b||g<=m&&w<y?B.LEFT:x<m&&b<=y&&y<=p||x<m&&y<=w&&p<=y?v.point.y<y?B.BOTTOM:B.TOP:B.RIGHT}}function Ac(t,e,n){n=n.getTangentAtLength(n.getClosestPointLength(e)),n=90*Math.round(yc(n)/90);if(n%180==0&&t.y===e.y)return t.x<e.x?B.LEFT:B.RIGHT;if(t.x===e.x)return t.y<e.y?B.TOP:B.BOTTOM;switch(n){case 0:case 180:case 360:return t.y<e.y?B.TOP:B.BOTTOM;case 90:case 270:return t.x<e.x?B.LEFT:B.RIGHT}}function Pc(t,e,n,i,r,o,s){i===B.AUTO&&(i=r?B.MAGNET_SIDE:B.ANCHOR_SIDE);var r=t&&t.model.isElement(),{x:o,y:a,width:l=0,height:h=0}=r?tt.fromRectUnion(n,t.model.getBBox()):o;return{point:e,x0:o,y0:a,view:t,bbox:n,width:l,height:h,direction:i,margin:r?s:0}}function Ec(t,e,n){var 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 Tc(t,e,n){var{dx:n=0,dy:i=0}=n,r={x:t.point.x+n,y:t.point.y+i},n={x:e.point.x+n,y:e.point.y+i};return[t.point,r,n,e.point]}function Sc(t,e,n,i){n=Xn(n-90);let r=0,o=0;90===n?o=-i:180===n?r=-i:270===n?o=i:0===n&&(r=i);n=Tc(t,e,{dx:r,dy:o}),i=n[2],t=new P(e.point,i);return{loopRoute:n,continueDirection:vc[yc(t)]}}function kc(t,e,n){switch(e){case B.LEFT:t.inflate(0,n).moveAndExpand({x:-n,width:n});break;case B.RIGHT:t.inflate(0,n).moveAndExpand({width:n});break;case B.TOP:t.inflate(n,0).moveAndExpand({y:-n,height:n});break;case B.BOTTOM:t.inflate(n,0).moveAndExpand({height:n})}return t}function Lc(i,r,e){var{point:o,x0:s,y0:a,width:l,height:n,margin:t}=i,{point:I,x0:h,y0:u,width:c,height:d,margin:f}=r,{targetInSourceBBox:e=!1}=2<arguments.length&&void 0!==e?e:{},p=h+c,g=u+d,m=s+l,v=a+n,y=s-t,b=m+t,x=a-t,w=v+t,A=h-f,P=p+f,E=u-f,T=g+f,[S,k]=xc(i,r),o=Ec(S,{point:o,x0:s,y0:a,width:l,height:n},t),L=Ec(k,{point:I,x0:h,y0:u,width:c,height:d},f),{x:C,y:M}=o,{x:_,y:N}=L,O=((s+m)/2<(h+p)/2?m+h:p+s)/2,V=((a+v)/2<(u+g)/2?v+u:g+a)/2,l=new tt(s,a,l,n),n=new tt(h,u,c,d),c=l.clone().inflate(t),d=n.clone().inflate(f),l=Object.assign({},i,{x1:m,y1:v,outsidePoint:o,direction:S}),f=Object.assign({},r,{x1:p,y1:g,outsidePoint:L,direction:k}),[i,r]=((t,e)=>{var{x0:n,x1:i,outsidePoint:r}=t,{x0:o,x1:s,outsidePoint:a}=e;let l=Math.min(n,o),h=Math.max(i,s);return t.direction===e.direction&&(o=(n=t.y0<e.y0?t:e)===t?e:t,i=t.direction===B.TOP?n:o,l=i.x0,h=i.x1),s=r.x,e=a.x,[Math.abs(s-l)+Math.abs(e-l),Math.abs(s-h)+Math.abs(e-h)]})(l,f),[l,f]=((t,e)=>{var{y0:n,y1:i,outsidePoint:r}=t,{y0:o,y1:s,outsidePoint:a}=e;let l=Math.min(n,o),h=Math.max(i,s);return t.direction===e.direction&&(o=(n=t.x0<e.x0?t:e)===t?e:t,i=t.direction===B.LEFT?n:o,l=i.y0,h=i.y1),s=r.y,e=a.y,[Math.abs(s-l)+Math.abs(e-l),Math.abs(s-h)+Math.abs(e-h)]})(l,f);if("left"===S&&"right"===k){var R=c.containsPoint(L),F=d.containsPoint(o);if(R||F)return[{x:C,y:M},{x:C,y:R=(M+N)/2},{x:_,y:R},{x:_,y:N}];if(y<_){let t=V,e=C,n=_;var F=l<f;return(t>=x&&t<=w||t>=E&&t<=T)&&(E<=w&&F?t=Math.min(E,x):x<=T&&!F&&(t=Math.max(T,w)),e=Math.min(C,A),n=Math.max(_,b),F&&M<u||!F&&g<M?e=C:(F&&N<a||!F&&v<N)&&(n=_)),[{x:e,y:M},{x:e,y:t},{x:n,y:t},{x:n,y:N}]}var R=(C+_)/2;return[{x:R,y:M},{x:R,y:N}]}if("right"===S&&"left"===k){var F=c.containsPoint(L),R=d.containsPoint(o);if(F||R)return[{x:C,y:M},{x:C,y:F=(M+N)/2},{x:_,y:F},{x:_,y:N}];if(_<b){let t=V,e=C,n=_;var R=l<f;return(t>=x&&t<=w||t>=E&&t<=T)&&(E<=w&&R?t=Math.min(E,x):x<=T&&!R&&(t=Math.max(T,w)),e=Math.max(C,P),n=Math.min(_,y),R&&M<u||!R&&g<M?e=C:(R&&N<a||!R&&v<N)&&(n=_)),[{x:e,y:M},{x:e,y:t},{x:n,y:t},{x:n,y:N}]}var F=(C+_)/2;return[{x:F,y:M},{x:F,y:N}]}if("top"===S&&"bottom"===k){var R=c.containsPoint(L),F=d.containsPoint(o);if(R||F)return[{x:C,y:M},{x:R=(C+_)/2,y:M},{x:R,y:N},{x:_,y:N}];if(x<N){let t=O,e=M,n=N;F=i<r;return(t>=y&&t<=b||t>=A&&t<=P)&&(A<=b&&F?t=Math.min(A,y):y<=P&&!F&&(t=Math.max(P,b)),e=Math.min(M,E),n=Math.max(N,w),F&&C<h||!F&&p<C?e=M:(F&&_<s||!F&&m<_)&&(n=N)),[{x:C,y:e},{x:t,y:e},{x:t,y:n},{x:_,y:n}]}R=(M+N)/2;return[{x:C,y:R},{x:_,y:R}]}if("bottom"===S&&"top"===k){F=c.containsPoint(L),R=d.containsPoint(o);if(F||R)return[{x:C,y:M},{x:L=(C+_)/2,y:M},{x:L,y:N},{x:_,y:N}];if(N<w){let t=O,e=M,n=N;var o=i<r;return(t>=y&&t<=b||t>=A&&t<=P)&&(A<=b&&o?t=Math.min(A,y):y<=P&&!o&&(t=Math.max(P,b)),e=Math.max(M,T),n=Math.min(N,x),o&&C<h||!o&&p<C?e=M:(o&&_<s||!o&&m<_)&&(n=N)),[{x:C,y:e},{x:t,y:e},{x:t,y:n},{x:_,y:n}]}F=(M+N)/2;return[{x:C,y:F},{x:_,y:F}]}if("top"===S&&"top"===k){if((e||yr.rectWithRect(c,n)||M<=u&&(c.bottomRight().x<=_||c.bottomLeft().x>=_)||u<=M&&(d.bottomRight().x<=C||d.bottomLeft().x>=C))&&C!==_)return[{x:C,y:Math.min(M,N)},{x:_,y:Math.min(M,N)}];let t;var R=Math.min((v+u)/2,N),L=Math.min((a+g)/2,M);return[{x:C,y:L},{x:t=N<M?i<r?Math.min(C,A):Math.max(C,P):i<r?Math.min(_,y):Math.max(_,b),y:L},{x:t,y:R},{x:_,y:R}]}if("bottom"===S&&"bottom"===k){if((e||yr.rectWithRect(c,n)||N<=M&&(c.topRight().x<=_||c.topLeft().x>=_)||M<=N&&(d.topRight().x<=C||d.topLeft().x>=C))&&C!==_)return[{x:C,y:Math.max(M,N)},{x:_,y:Math.max(M,N)}];let t;o=Math.max((a+g)/2,N),F=Math.max((v+u)/2,M);return[{x:C,y:F},{x:t=M<N?i<r?Math.min(C,A):Math.max(C,P):i<r?Math.min(_,y):Math.max(_,b),y:F},{x:t,y:o},{x:_,y:o}]}if("left"===S&&"left"===k){if((e||yr.rectWithRect(c,n)||C<=_&&(c.bottomRight().y<=N||c.topRight().y>=N)||_<=C&&(d.bottomRight().y<=M||d.topRight().y>=M))&&M!==N)return[{x:Math.min(C,_),y:M},{x:Math.min(C,_),y:N}];let t;L=Math.min((m+h)/2,_),R=Math.min((s+p)/2,C);return[{x:R,y:M},{x:R,y:t=C<_?l<=f?Math.min(x,N):Math.max(w,N):l<=f?Math.min(E,M):Math.max(T,M)},{x:L,y:t},{x:L,y:N}]}if("right"===S&&"right"===k){if((e||yr.rectWithRect(c,n)||_<=C&&(c.bottomLeft().y<=N||c.topLeft().y>=N)||C<=_&&(d.bottomLeft().y<=M||d.topLeft().y>=M))&&M!==N)return[{x:Math.max(C,_),y:M},{x:Math.max(C,_),y:N}];let t;var i=Math.max((s+p)/2,_),r=Math.max((m+h)/2,C);return[{x:r,y:M},{x:r,y:t=_<=C?l<=f?Math.min(x,N):Math.max(w,N):l<=f?Math.min(E,M):Math.max(T,M)},{x:i,y:t},{x:i,y:N}]}if("top"===S&&"right"===k){if(c.containsPoint(I))return C<=P?(F=Math.max(C+t,_),[{x:C,y:o=Math.min(x,E)},{x:F,y:o},{x:F,y:N}]):[{x:C,y:M},{x:R=(C-t+_)/2,y:M},{x:R,y:N}];if(N<x){if(C<_){let t=T<=x&&C<=P?V:E;return[{x:C,y:t},{x:_,y:t},{x:_,y:N}]}return[{x:C,y:N}]}L=Math.max(O,P);return _<C&&N<=v?[{x:C,y:M},{x:L,y:M},{x:L,y:N}]:y<L&&M<g?[{x:C,y:e=Math.min(x,E)},{x:n=Math.max(b,P),y:e},{x:n,y:N}]:[{x:C,y:M},{x:L,y:M},{x:L,y:N}]}if("top"===S&&"left"===k){if(c.containsPoint(I))return A<=C?(d=Math.min(C-t,_),[{x:C,y:r=Math.min(x,E)},{x:d,y:r},{x:d,y:N}]):[{x:C,y:M},{x:l=(C+t+_)/2,y:M},{x:l,y:N}];if(N<x){if(_<C){let t=T<=x&&A<=C?V:E;return[{x:C,y:t},{x:_,y:t},{x:_,y:N}]}return[{x:C,y:N}]}f=Math.min(A,O);return C<_&&N<=v?[{x:C,y:M},{x:f,y:M},{x:f,y:N}]:f<b&&M<g?[{x:C,y:i=Math.min(x,E)},{x:o=Math.min(y,A),y:i},{x:o,y:N}]:[{x:C,y:M},{x:f,y:M},{x:f,y:N}]}if("bottom"===S&&"right"===k){if(c.containsPoint(I))return C<=P?(F=Math.max(C+t,_),[{x:C,y:R=Math.max(w,T)},{x:F,y:R},{x:F,y:N}]):[{x:C,y:M},{x:e=(C-t+_)/2,y:M},{x:e,y:N}];if(w<N){if(C<_){let t=w<=E&&C<=P?V:T;return[{x:C,y:t},{x:_,y:t},{x:_,y:N}]}return[{x:C,y:N}]}n=Math.max(O,P);return _<C&&a<=N?[{x:C,y:M},{x:n,y:M},{x:n,y:N}]:y<n&&u<M?[{x:C,y:L=Math.max(w,T)},{x:r=Math.max(b,P),y:L},{x:r,y:N}]:[{x:C,y:M},{x:n,y:M},{x:n,y:N}]}if("bottom"===S&&"left"===k){if(c.containsPoint(I))return A<=C?(d=Math.min(C-t,_),[{x:C,y:l=Math.max(w,T)},{x:d,y:l},{x:d,y:N}]):[{x:C,y:M},{x:v=(C+t+_)/2,y:M},{x:v,y:N}];if(w<N){if(_<C){let t=w<=E&&A<=C?V:T;return[{x:C,y:t},{x:_,y:t},{x:_,y:N}]}return[{x:C,y:N}]}var g=Math.min(A,O);return C<_&&a<=N?[{x:C,y:M},{x:g,y:M},{x:g,y:N}]:g<b&&u<M?[{x:C,y:i=Math.max(w,T)},{x:o=Math.min(y,A),y:i},{x:o,y:N}]:[{x:C,y:M},{x:g,y:M},{x:g,y:N}]}if("left"===S&&"bottom"===k){if(c.containsPoint(I))return M<=T?[{x:f=Math.min(y,A),y:M},{x:f,y:R=Math.max(M+t,N)},{x:_,y:R}]:[{x:C,y:M},{x:C,y:F=(M-t+N)/2},{x:_,y:F}];if(_<y){if(M<N){let t=P<=y&&M<=T?O:A;return[{x:t,y:M},{x:t,y:N},{x:_,y:N}]}return[{x:_,y:M}]}e=Math.max(T,V);return N<M&&_<=m?[{x:C,y:M},{x:C,y:e},{x:_,y:e}]:x<e&&C<p?[{x:L=Math.min(y,A),y:M},{x:L,y:r=Math.max(w,T)},{x:_,y:r}]:[{x:C,y:M},{x:C,y:e},{x:_,y:e}]}if("left"===S&&"top"===k){if(c.containsPoint(I))return E<=M?(n=Math.min(M-t,N),[{x:l=Math.min(y,A),y:M},{x:l,y:n},{x:_,y:n}]):[{x:C,y:M},{x:C,y:d=(M+t+N)/2},{x:_,y:d}];if(_<y){if(N<M){let t=P<=y&&E<=M?O:A;return[{x:t,y:M},{x:t,y:N},{x:_,y:N}]}return[{x:_,y:M}]}v=Math.min(E,V);return M<N&&_<=m?[{x:C,y:M},{x:C,y:v},{x:_,y:v}]:v<w&&C<p?[{x:a=Math.min(y,A),y:M},{x:a,y:u=Math.min(x,E)},{x:_,y:u}]:[{x:C,y:M},{x:C,y:v},{x:_,y:v}]}if("right"===S&&"top"===k){if(c.containsPoint(I))return E<=M?[{x:i=Math.max(b,P),y:M},{x:i,y:o=Math.min(M-t,N)},{x:_,y:o}]:[{x:C,y:M},{x:C,y:g=(M+t+N)/2},{x:_,y:g}];if(b<_){if(N<M){let t=b<=A&&E<=M?O:P;return[{x:t,y:M},{x:t,y:N},{x:_,y:N}]}return[{x:_,y:M}]}f=Math.min(E,V);return M<N&&s<=_?[{x:C,y:M},{x:C,y:f},{x:_,y:f}]:f<w&&h<C?[{x:R=Math.max(b,P),y:M},{x:R,y:F=Math.min(x,E)},{x:_,y:F}]:[{x:C,y:M},{x:C,y:f},{x:_,y:f}]}if("right"===S&&"bottom"===k){if(c.containsPoint(I))return M<=T?[{x:L=Math.max(b,P),y:M},{x:L,y:r=Math.max(M+t,N)},{x:_,y:r}]:[{x:C,y:M},{x:C,y:e=(M-t+N)/2},{x:_,y:e}];if(b<_){if(M<N){let t=b<=A&&M<=T?O:P;return[{x:t,y:M},{x:t,y:N},{x:_,y:N}]}return[{x:_,y:M}]}l=Math.max(T,V);return N<M&&s<=_?[{x:C,y:M},{x:C,y:l},{x:_,y:l}]:x<l&&h<C?[{x:n=Math.max(b,P),y:M},{x:n,y:d=Math.max(w,T)},{x:_,y:d}]:[{x:C,y:M},{x:C,y:l},{x:_,y:l}]}}function Cc(t,e,n){var i=t===B.LEFT||t===B.RIGHT;let r=0,o=0;switch(Xn(Math.round(e))){case 0:case 90:r=i?0:n,o=i?n:0;break;case 180:case 270:r=i?0:-n,o=i?-n:0}return{dx:r,dy:o}}function Mc(n,i,r){var{sourceDirection:o=B.AUTO,targetDirection:s=B.AUTO}=i,a=i.margin||20,i=i.useVertices||!1,l=!!r.model.source().port,o=Pc(r.sourceView,r.sourceAnchor,r.sourceBBox,o,l,r.sourceAnchor,a),l=!!r.model.target().port,s=Pc(r.targetView,r.targetAnchor,r.targetBBox,s,l,r.targetAnchor,a),h=[];if(!i||0===n.length)return bc(Lc(o,s));var e=n.map(t=>{var{x:t,y:e}=t,n=new A(t,e);return{point:n,x0:n.x,y0:n.y,view:null,bbox:new tt(t,e,0,0),width:0,height:0,direction:null,margin:0}}),[l]=e,[r]=xc(o,l),i=o.view&&o.view.model.isElement(),n=i?kc(o.view.model.getBBox(),r,a):null;let t=!!i&&n.containsPoint(l.point);t?(n=(i=Ec(r,o,a)).equals(l.point),y=o.point.x===l.point.x,v=o.point.y===l.point.y,y=y&&(r===B.TOP||r===B.BOTTOM),v=v&&(r===B.LEFT||r===B.RIGHT),g=(m=new P(o.point,i)).containsPoint(l.point),v=t&&(v||y),n?(h.push(o.point,l.point),l.direction=gc[r]):g||v?({dx:y,dy:n}=Cc(r,yc(g?m:new P(o.point,l.point)),a),g=(v=Tc({point:i},l,{dx:y,dy:n}))[2],m=new P(l.point,g),i=vc[yc(m)],l.direction=i,h.push(...v)):(l.direction=r,l.margin=a,h.push(...Lc(o,l,{targetInSourceBBox:!0}),l.point))):(y=wc(o,l,e[1]||s),l.direction=y,h.push(...Lc(o,l),l.point));for(let t=0;t<e.length-1;t++){var u,c,d=e[t],f=e[t+1],p=yc(new P(d.point,f.point));p%90==0?(c=vc[p],u=bc([...h,d.point]),u=new P(u[u.length-2],u[u.length-1]),u=vc[Math.round(yc(u))],c!==gc[u]?(h.push(d.point,f.point),[,c]=xc(d,f),f.direction=c):({loopRoute:u,continueDirection:c}=Sc(d,f,p,a),f.direction=c,h.push(...u))):([p,c]=_c(d,f),d.direction=p,f.direction=c,h.push(...Lc(d,f),f.point))}n=e[e.length-1];if(s.view&&s.view.model.isElement()){var[,g]=xc(n,s),m=Ec(g,s,a),i=bc([...h,n.point]),v=new P(i[i.length-2],i[i.length-1]),r=Math.round(yc(v)),y=vc[r],o=m.equals(n.point);if(!o||y===g){n.direction=y;let t=Lc(n,s);var[l,i]=bc([...t,s.point]),v=new P(l,i),l=Math.round(yc(v)),i=vc[l],v=kc(s.view.model.getBBox(),g,a),l=n.point.x===s.point.x,b=n.point.y===s.point.y;let e=v.containsPoint(n.point);v=l&&(g===B.TOP||g===B.BOTTOM),l=b&&(g===B.LEFT||g===B.RIGHT);!o&&e&&(l||v)?({dx:b,dy:o}=Cc(g,r,a),t=Tc(n,{point:m},{dx:b,dy:o})):e&&g!==gc[y]?(n.margin=a,n.direction=g,t=Lc(n,s)):i!==y&&y===gc[i]&&(n.margin=a,t=Lc(n,s)),h.push(...t)}}else{l=n,v=s,r=yc(new P(l.point,v.point));r%90==0?(m=vc[r],b=bc(h),o=new P(b[b.length-2],l.point),g=vc[Math.round(yc(o))],m!==gc[g]?h.push(l.point):(y=Sc(l,v,r,a).loopRoute,y.pop(),h.push(...y))):([i,n]=_c(l,v),l.direction=i,v.direction=n,h.push(...Lc(l,v)))}return bc(h)}function _c(t,e){var n,i=t.direction,r=mc.includes(i);let o=t.direction,s=e.direction;return r?(r=t.point.y>e.point.y,n=e.point.x-t.point.x,i===B.BOTTOM?(o=r?gc[i]:0<=n?B.RIGHT:B.LEFT,0<n?s=r?B.LEFT:B.TOP:n<0&&(s=r?B.RIGHT:B.TOP)):(o=r?0<=n?B.RIGHT:B.LEFT:gc[i],0<n?s=r?B.BOTTOM:B.LEFT:n<0&&(s=r?B.BOTTOM:B.RIGHT))):(n=t.point.x>e.point.x,r=e.point.y-t.point.y,i===B.RIGHT?(o=n?gc[i]:0<=r?B.BOTTOM:B.TOP,0<r?s=n?B.TOP:B.LEFT:r<0&&(s=n?B.BOTTOM:B.LEFT)):(o=n?0<=r?B.BOTTOM:B.TOP:gc[i],0<r?s=n?B.RIGHT:B.TOP:r<0&&(s=n?B.RIGHT:B.BOTTOM))),[o,s]}Mc.Directions=B;var Nc={normal:function(t,e,n){return t},oneSide:function(t,e,n){var i,r,o,s=e.side||"bottom",e=gl(e.padding||40),a=n.sourceBBox,n=n.targetBBox,l=a.center(),h=n.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 l[i]+=o*(a[r]/2+e[s]),h[i]+=o*(n[r]/2+e[s]),0<o*(l[i]-h[i])?h[i]=l[i]:l[i]=h[i],[l].concat(t,h)},orthogonal:Yu,manhattan:dc,metro:function(t,e,n){if(b(dc))return dc(t,T({},fc,e),n);throw new Error("Metro requires the manhattan router.")},rightAngle:Mc};function Oc(o){return function(t,e,n,i){var r;return n instanceof Element?(r=(r=this.paper.findView(n))?r.isNodeConnection(n)?Rc(r,"fixedAt"in i?i.fixedAt:"50%"):r.getNodeBBox(n).center():new A,o.call(this,t,e,r,i)):o.apply(this,arguments)}}function Rc(t,e){var n=parseFloat(e);return ll(e)?t.getPointAtRatio(n/100):t.getPointAtLength(n)}l=Oc(function(t,e,n,i){var r=t.getConnection(),o=t.getConnectionSubdivisions(),s=new P(n.clone().offset(0,1e6),n.clone().offset(0,-1e6)),a=new P(n.clone().offset(1e6,0),n.clone().offset(-1e6,0)),s=s.intersect(r,{segmentSubdivisions:o}),a=a.intersect(r,{segmentSubdivisions:o}),r=[];return s&&Array.prototype.push.apply(r,s),a&&Array.prototype.push.apply(r,a),0<r.length?n.chooseClosest(r):"fallbackAt"in i?Rc(t,i.fallbackAt):Fc(t,e,n,i)});let Fc=Oc(function(t,e,n,i){return(t=t.getClosestPoint(n))||new A}),Ic={resolveRef:Oc,connectionRatio:function(t,e,n,i){return i="ratio"in i?i.ratio:.5,t.getPointAtRatio(i)},connectionLength:function(t,e,n,i){return i="length"in i?i.length:20,t.getPointAtLength(i)},connectionPerpendicular:l,connectionClosest:Fc};function Vc(l){return function(t,e,n,i){var r=!!i.rotate,e=r?t.getNodeUnrotatedBBox(e):t.getNodeBBox(e),o=e[l](),s=i.dx,a=(s&&(a=ll(s),s=parseFloat(s),isFinite(s))&&(a&&(s=s/100*e.width),o.x+=s),i.dy);return a&&(s=ll(a),a=parseFloat(a),isFinite(a))&&(s&&(a=a/100*e.height),o.y+=a),r?o.rotate(t.model.getBBox().center(),-t.model.angle()):o}}i={center:Vc("center"),top:Vc("topMiddle"),bottom:Vc("bottomMiddle"),left:Vc("leftMiddle"),right:Vc("rightMiddle"),topLeft:Vc("origin"),topRight:Vc("topRight"),bottomLeft:Vc("bottomLeft"),bottomRight:Vc("corner"),perpendicular:Oc(function(t,e,n,i){var r,o=t.model.angle(),e=(t=t.getNodeBBox(e)).center(),s=t.origin(),t=t.corner(),i=i.padding;return isFinite(i)||(i=0),s.y+i<=n.y&&n.y<=t.y-i?(r=n.y-e.y,e.x+=0===o||180===o?0:r/Math.tan(Jn(o)),e.y+=r):s.x+i<=n.x&&n.x<=t.x-i&&(r=n.x-e.x,e.y+=90===o||270===o?0:r*Math.tan(Jn(o)),e.x+=r),e}),midSide:Oc(function(t,e,n,i){var r,o,s,a,l=!!i.rotate,t=(l?(r=t.getNodeUnrotatedBBox(e),s=t.model.getBBox().center(),o=t.model.angle()):r=t.getNodeBBox(e),i.padding);switch(isFinite(t)&&r.inflate(t),l&&n.rotate(s,o),r.sideNearestToPoint(n)){case"left":a=r.leftMiddle();break;case"right":a=r.rightMiddle();break;case"top":a=r.topMiddle();break;case"bottom":a=r.bottomMiddle()}return l?a.rotate(s,-o):a}),modelCenter:function(t,e,n,i,r){return t.model.getPointFromConnectedLink(this.model,r).offset(i.dx,i.dy)}};let Bc=cu.extend({initialize:function(t,e){e.cellNamespace?this.cellNamespace=e.cellNamespace:this.cellNamespace="undefined"!=typeof joint&&da(joint,"shapes")?joint.shapes:null,this.graph=e.graph},model:function(t,e){var n=e.collection.cellNamespace,i=t.type,n=Ya(n,i,".");if(n)return new n(t,e);throw new Error(`dia.Graph: Could not find cell constructor for type: '${i}'. Make sure to add the constructor to 'cellNamespace'.`)},_addReference:function(t,e){cu.prototype._addReference.apply(this,arguments),e.dry||t.graph||(t.graph=this.graph)},_removeReference:function(t,e){cu.prototype._removeReference.apply(this,arguments),e.dry||t.graph!==this.graph||(t.graph=null)},comparator:function(t){return t.get("z")||0}}),Dc=El.extend({initialize:function(t,e){e=e||{};e=new Bc([],{model:e.cellModel,cellNamespace:e.cellNamespace,graph:this});El.prototype.set.call(this,"cells",e),e.on("all",this.trigger,this),this.on("change:z",this._sortOnChangeZ,this),this._out={},this._in={},this._nodes={},this._edges={},this._batches={},e.on("add",this._restructureOnAdd,this),e.on("remove",this._restructureOnRemove,this),e.on("reset",this._restructureOnReset,this),e.on("change:source",this._restructureOnChangeSource,this),e.on("change:target",this._restructureOnChangeTarget,this),e.on("remove",this._removeCell,this)},_sortOnChangeZ:function(){this.get("cells").sort()},_restructureOnAdd:function(t){var e,n;t.isLink()?(this._edges[t.id]=!0,{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)):this._nodes[t.id]=!0},_restructureOnRemove:function(t){var e,n;t.isLink()?(delete this._edges[t.id],{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]):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=(e.id&&this._out[e.id]&&delete this._out[e.id][t.id],t.attributes.source);e.id&&((this._out[e.id]||(this._out[e.id]={}))[t.id]=!0)},_restructureOnChangeTarget:function(t){var e=t.previous("target"),e=(e.id&&this._in[e.id]&&delete this._in[e.id][t.id],t.get("target"));e.id&&((this._in[e.id]||(this._in[e.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=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=El.prototype.toJSON.apply(this,arguments);return e.cells=this.get("cells").toJSON(t.cellAttributes),e},fromJSON:function(t,e){if(t.cells)return this.set(t,e);throw new Error("Graph JSON must contain cells array.")},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=ua(i,"cells")),El.prototype.set.call(this,i,n)},clear:function(t){t=T({},t,{clear:!0});var e=this.get("cells");if(0!==e.length){this.startBatch("clear",t);for(var n=e.sortBy(function(t){return t.isLink()?1:2});n.shift().remove(t),0<n.length;);this.stopBatch("clear")}return this},_prepareCell:function(t){let e;if(e=t instanceof El?t.attributes:t,E(e.type))return t;throw new TypeError("dia.Graph: cell type must be a string.")},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 El?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=aa(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){t=et(t).map(function(t){return this._prepareCell(t,e)},this);return this.get("cells").reset(t,e),this},removeCells:function(t,e){return t.length&&(this.startBatch("remove"),Xs(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})},transferCellEmbeds:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i="transfer-embeds",t=(this.startBatch(i),t.getEmbeddedCells());e.embed(t,{...n,reparent:!0}),this.stopBatch(i)},transferCellConnectedLinks:function(e,n){let i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};var t="transfer-connected-links";this.startBatch(t),this.getConnectedLinks(e,i).forEach(t=>{t.getSourceCell()===e&&t.prop(["source","id"],n.id,i),t.getTargetCell()===e&&t.prop(["target","id"],n.id,i)}),this.stopBatch(t)},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,r){var o,s=(r=r||{}).indirect,a=r.inbound,l=r.outbound,h=(void 0===a&&void 0===l&&(a=l=!0),[]),u={};function c(i,t){pa(i.getOutboundEdges(t.id),function(t,e){var n;u[e]||(n=i.getCell(e),h.push(n),u[e]=!0,s&&(a&&d(i,n),l)&&c(i,n))}.bind(i)),s&&t.isLink()&&(t=t.getTargetCell())&&t.isLink()&&(u[t.id]||(h.push(t),c(i,t)))}function d(i,t){pa(i.getInboundEdges(t.id),function(t,e){var n;u[e]||(n=i.getCell(e),h.push(n),u[e]=!0,s&&(a&&d(i,n),l)&&c(i,n))}.bind(i)),s&&t.isLink()&&(t=t.getSourceCell())&&t.isLink()&&(u[t.id]||(h.push(t),d(i,t)))}return l&&c(this,t),a&&d(this,t),r.deep&&(t=t.getEmbeddedCells({deep:!0}),o={},t.forEach(function(t){t.isElement()&&(o[t.id]=!0)}),t.forEach(function(t){t.isLink()||(l&&pa(this.getOutboundEdges(t.id),function(t,e){var n,i;u[e]||({source:n,target:i}=this.getCell(e).attributes,n=n.id,i=i.id,!r.includeEnclosed&&n&&o[n]&&i&&o[i])||(h.push(this.getCell(e)),u[e]=!0)}.bind(this)),a&&pa(this.getInboundEdges(t.id),function(t,e){var n,i;u[e]||({source:n,target:i}=this.getCell(e).attributes,n=n.id,i=i.id,!r.includeEnclosed&&n&&o[n]&&i&&o[i])||(h.push(this.getCell(e)),u[e]=!0)}.bind(this)))},this)),h},getNeighbors:function(o,s){var t,a=(s=s||{}).inbound,l=s.outbound,e=(void 0===a&&void 0===l&&(a=l=!0),this.getConnectedLinks(o,s).reduce(function(t,e){var n,{source:i,target:r}=e.attributes,e=e.hasLoop(s);return a&&da(i,"id")&&!t[i.id]&&(n=this.getCell(i.id)).isElement()&&(e||!(!n||n===o||s.deep&&n.isEmbeddedIn(o)))&&(t[i.id]=n),l&&da(r,"id")&&!t[r.id]&&(i=this.getCell(r.id)).isElement()&&(e||!(!i||i===o||s.deep&&i.isEmbeddedIn(o)))&&(t[r.id]=i),t}.bind(this),{}));return o.isLink()&&(a&&(t=o.getSourceCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),l)&&(t=o.getTargetCell())&&t.isElement()&&!e[t.id]&&(e[t.id]=t),et(e)},getCommonAncestor:function(){var t=(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)).sort(function(t,e){return t.length-e.length}),e=et(t.shift()).find(function(e){return t.every(function(t){return t.includes(e)})});return this.getCell(e)},getSuccessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},T({},t,{outbound:!0})),n},cloneCells:Dl,cloneSubgraph:function(t,e){t=this.getSubgraph(t,e);return this.cloneCells(t)},getSubgraph:function(t,e){e=e||{};var i=[],r={},n=[],o=[];return et(t).forEach(function(t){r[t.id]||(i.push(t),((r[t.id]=t).isLink()?o:n).push(t)),e.deep&&t.getEmbeddedCells({deep:!0}).forEach(function(t){r[t.id]||(i.push(t),((r[t.id]=t).isLink()?o:n).push(t))})}),o.forEach(function(t){var{source:t,target:e}=t.attributes;t.id&&!r[t.id]&&(t=this.getCell(t.id),i.push(t),r[t.id]=t,n.push(t)),e.id&&!r[e.id]&&(t=this.getCell(e.id),i.push(this.getCell(e.id)),r[t.id]=t,n.push(t))},this),n.forEach(function(t){this.getConnectedLinks(t,e).forEach(function(t){var{source:e,target:n}=t.attributes;!r[t.id]&&e.id&&r[e.id]&&n.id&&r[n.id]&&(i.push(t),r[t.id]=t)})},this),i},getPredecessors:function(e,t){t=t||{};var n=[];return this.search(e,function(t){t!==e&&n.push(t)},T({},t,{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){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.shift();if(!i[s.id]&&!(i[s.id]=!0)!==e.call(this,s,r[s.id])){var a=this.getNeighbors(s,n);for(let t=0,e=a.length;t<e;t++){var l=a[t];r[l.id]=r[s.id]+1,o.push(l)}}}},dfs:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i={},r={},o=[];for(o.push(t),r[t.id]=0;0<o.length;){var s=o.pop();if(!i[s.id]&&!(i[s.id]=!0)!==e.call(this,s,r[s.id])){var a=this.getNeighbors(s,n),l=o.length;for(let t=0,e=a.length;t<e;t++){var h=a[t];r[h.id]=r[s.id]+1,o.splice(l,0,h)}}}},getSources:function(){var n=[];return pa(this._nodes,function(t,e){this._in[e]&&!ea(this._in[e])||n.push(this.getCell(e))}.bind(this)),n},getSinks:function(){var n=[];return pa(this._nodes,function(t,e){this._out[e]&&!ea(this._out[e])||n.push(this.getCell(e))}.bind(this)),n},isSource:function(t){return!this._in[t.id]||ea(this._in[t.id])},isSink:function(t){return!this._out[t.id]||ea(this._out[t.id])},isSuccessor:function(e,n){var i=!1;return this.search(e,function(t){if(t===n&&t!==e)return!(i=!0)},{outbound:!0}),i},isPredecessor:function(e,n){var i=!1;return this.search(e,function(t){if(t===n&&t!==e)return!(i=!0)},{inbound:!0}),i},isNeighbor:function(t,n,e){var i=(e=e||{}).inbound,r=e.outbound,o=(void 0===i&&void 0===r&&(i=r=!0),!1);return this.getConnectedLinks(t,e).forEach(function(t){var{source:t,target:e}=t.attributes;return i&&da(t,"id")&&t.id===n.id||r&&da(e,"id")&&e.id===n.id?!(o=!0):void 0}),o},disconnectLinks:function(e,n){this.getConnectedLinks(e).forEach(function(t){t.set(t.attributes.source.id===e.id?"source":"target",{x:0,y:0},n)})},removeLinks:function(t,e){Xs(this.getConnectedLinks(t),"remove",e)},findElementsAtPoint:function(t,e){return this._filterAtPoint(this.getElements(),t,e)},findLinksAtPoint:function(t,e){return this._filterAtPoint(this.getLinks(),t,e)},findCellsAtPoint:function(t,e){return this._filterAtPoint(this.getCells(),t,e)},_filterAtPoint:function(t,e){let n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};return t.filter(t=>t.getBBox({rotate:!0}).containsPoint(e,n))},findElementsInArea:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this._filterInArea(this.getElements(),t,e)},findLinksInArea:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this._filterInArea(this.getLinks(),t,e)},findCellsInArea:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return this._filterInArea(this.getCells(),t,e)},_filterInArea:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};let i=new tt(e);var{strict:e=!1}=n;let r=e?"containsRect":"intersect";return t.filter(t=>i[r](t.getBBox({rotate:!0})))},findElementsUnderElement:function(t,e){return this._filterCellsUnderElement(this.getElements(),t,e)},findLinksUnderElement:function(t,e){return this._filterCellsUnderElement(this.getLinks(),t,e)},findCellsUnderElement:function(t,e){return this._filterCellsUnderElement(this.getCells(),t,e)},_isValidElementUnderElement:function(t,e){return t.id!==e.id&&!t.isEmbeddedIn(e)},_isValidLinkUnderElement:function(t,e){return t.source().id!==e.id&&t.target().id!==e.id&&!t.isEmbeddedIn(e)},_validateCellsUnderElement:function(t,e){return t.filter(t=>t.isLink()?this._isValidLinkUnderElement(t,e):this._isValidElementUnderElement(t,e))},_getFindUnderElementGeometry:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"bbox",t=t.getBBox({rotate:!0});return"bbox"!==e?yh(t,e):t},_filterCellsUnderElement:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=this._getFindUnderElementGeometry(e,n.searchBy),t=i.type===d.Point?this._filterAtPoint(t,i):this._filterInArea(t,i,n);return this._validateCellsUnderElement(t,e)},findModelsInArea:function(t,e){return this.findElementsInArea(t,e)},findModelsFromPoint:function(t){return this.findElementsAtPoint(t)},findModelsUnderElement:function(t,e){return this.findElementsUnderElement(t,e)},getBBox:function(){return this.getCellsBBox(this.getCells())},getCellsBBox:function(t){let{rotate:n=!0}=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return et(t).reduce(function(t,e){e=e.getBBox({rotate:n});return e?t?t.union(e):e:t},null)},translate:function(t,e,n){var i=this.getCells().filter(function(t){return!t.isEmbedded()});return Xs(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);return r&&(t=Math.max(t/r.width,0),e=Math.max(e/r.height,0),Xs(n,"scale",t,e,r.origin(),i)),this},startBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)+1,this.trigger("batch:start",T({},e,{batchName:t}))},stopBatch:function(t,e){return e=e||{},this._batches[t]=(this._batches[t]||0)-1,this.trigger("batch:stop",T({},e,{batchName:t}))},hasActiveBatch:function(t){let e=this._batches,n;return(n=0===arguments.length?Object.keys(e):Array.isArray(t)?t:[t]).some(t=>0<e[t])}},{validations:{multiLinks:function(t,e){var{source:n,target:i}=e.attributes;if(n.id&&i.id){e=e.getSourceCell();if(e)if(1<t.getConnectedLinks(e,{outbound:!0}).filter(function(t){var{source:t,target:e}=t.attributes;return t&&t.id===n.id&&(!t.port||t.port===n.port)&&e&&e.id===i.id&&(!e.port||e.port===i.port)}).length)return!1}return!0},linkPinning:function(t,e){var{source:e,target:n}=e.attributes;return e.id&&n.id}}}),zc=(mh(Dc.prototype,["resetCells","addCells","removeCells"],vh.cells),{GRID:"grid",CELLS:"cells",BACK:"back",FRONT:"front",TOOLS:"tools",LABELS:"labels"}),jc=uu.extend({tagName:"g",svgElement:!0,pivotNodes:null,defaultTheme:null,options:{name:""},className:function(){return ja(this.options.name+"-layer")},init:function(){this.pivotNodes={}},insertSortedNode:function(t,e){this.el.insertBefore(t,this.insertPivot(e))},insertNode:function(t){var e=this.el;t.parentNode!==e&&e.appendChild(t)},insertPivot:function(e){var{el:n,pivotNodes:i}=this,r=i[e=(e=+e)||0];if(!r){r=i[e]=document.createComment("z-index:"+(e+1));let t=-1/0;for(var o in i)(o=+o)<e&&o>t&&(t=o);t!==-1/0?(i=i[t],n.insertBefore(r,i.nextSibling)):n.insertBefore(r,n.firstChild)}return r},removePivots:function(){var t,{el:e,pivotNodes:n}=this;for(t in n)e.removeChild(n[t]);this.pivotNodes={}}});let Gc=["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),{}),Uc=["r","rx","ry","width","height","stroke-width","font-size"].reduce((t,e)=>(t[e]=!0,t),{});function Hc(t,e){var n,i={};for(n in t)t.hasOwnProperty(n)&&(i[n]=qc(n,t[n],e));return i}function qc(e,n,i){if(e in Gc&&Zl(n)){let t=Ql(n,i);return t=e in Uc?Math.max(0,t):t}return n}let $c={DEFAULT:"default",EMBEDDING:"embedding",CONNECTING:"connecting",MAGNET_AVAILABILITY:"magnetAvailability",ELEMENT_AVAILABILITY:"elementAvailability"};let g=uu.extend({tagName:"g",svgElement:!0,selector:"root",metrics:null,className:function(){var i=["cell"],t=this.model.get("type");return t&&t.toLowerCase().split(".").forEach(function(t,e,n){i.push("type-"+n.slice(0,e+1).join("-"))}),i.join(" ")},_presentationAttributes:null,_flags:null,setFlags:function(){var t,e={},n={},i=0,r=S(this,"presentationAttributes");for(t in r)if(r.hasOwnProperty(t))for(var o=r[t],s=0,a=(o=Array.isArray(o)?o:[o]).length;s<a;s++){var l,h=(h=e[l=o[s]])||(e[l]=1<<i++);n[t]|=h}var u=S(this,"initFlag");for(s=0,a=(u=Array.isArray(u)?u:[u]).length;s<a;s++)e[l=u[s]]||(e[l]=1<<i++);if(25<i)throw new Error("dia.CellView: Maximum number of flags exceeded.");this._flags=e,this._presentationAttributes=n},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||tl(this),uu.call(this,t)},initialize:function(){this.setFlags(),uu.prototype.initialize.apply(this,arguments),this.cleanNodesCache(),this.startListening()},startListening:function(){this.listenTo(this.model,"change",this.onAttributesChange)},onAttributesChange:function(t,e){t=t.getChangeFlag(this._presentationAttributes);!e.updateHandled&&t&&(e.dirty&&this.hasFlag(t,"UPDATE")&&(t|=this.getFlag("RENDER")),e.tool&&(e.async=!1),this.requestUpdate(t,e))},requestUpdate:function(t,e){var n=this.paper;n&&0<t&&n.requestViewUpdate(this,t,this.UPDATE_PRIORITY,e)},parseDOMJSON:function(t,e){var n,t=$a(t),i=t.selectors,r=t.groupSelectors;for(n in r){if(i[n])throw new Error("dia.CellView: ambiguous group selector");i[n]=r[n]}if(e){var o=this.selector;if(i[o])throw new Error("dia.CellView: ambiguous root selector.");i[o]=e}return{fragment:t.fragment,selectors:i}},can:function(t){var e=b(this.options.interactive)?this.options.interactive(this):this.options.interactive;return w(e)&&!1!==e[t]||Hs(e)&&!1!==e},findBySelector:function(t,e,n){if(!t||"."===t)return[e];if(n){n=n[t];if(n)return Array.isArray(n)?n:[n]}return this.useCSSSelectors?L(e).find(t).toArray():[]},findNodes:function(t){return this.findBySelector(t,this.el,this.selectors)},findNode:function(t){var[t=null]=this.findNodes(t);return t},notify:function(t){var e;this.paper&&(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){return t=t&&t.useModelGeometry?(t=this.model).getBBox().bbox(t.angle()):this.getNodeBBox(this.el),this.paper.localToPaperRect(t)},getNodeBBox:function(t){var e=this.getNodeBoundingRect(t),n=this.getRootTranslateMatrix().multiply(this.getNodeRotateMatrix(t)),t=this.getNodeMatrix(t);return R.transformRect(e,n.multiply(t))},getNodeRotateMatrix(t){return!this.rotatableNode||this.rotatableNode.contains(t)?this.getRootRotateMatrix():R.createSVGMatrix()},getNodeUnrotatedBBox:function(t){var e=this.getNodeBoundingRect(t),t=this.getNodeMatrix(t),n=this.getRootTranslateMatrix();return R.transformRect(e,n.multiply(t))},getRootTranslateMatrix:function(){var t=this.model.position();return R.createSVGMatrix().translate(t.x,t.y)},getRootRotateMatrix:function(){var t,e=R.createSVGMatrix(),n=this.model,i=n.angle();return i&&(t=(n=n.getBBox()).width/2,e=e.translate(t,n=n.height/2).rotate(i).translate(-t,-n)),e},_notifyHighlight:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=this.el;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=$c.EMBEDDING;break;case n.connecting:t=$c.CONNECTING;break;case n.magnetAvailability:t=$c.MAGNET_AVAILABILITY;break;case n.elementAvailability:t=$c.ELEMENT_AVAILABILITY;break;default:t=$c.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){return this._notifyHighlight("cell:unhighlight",t,1<arguments.length&&void 0!==arguments[1]?arguments[1]:{})},findMagnet:function(t){var e=this.el;let n=this.$(t)[0];n=n||e;do{var i=n.getAttribute("magnet"),r=n===e;if((i||r)&&"false"!==i)return n;if(r)return}while(n=n.parentNode)},findProxyNode:function(t,e){e=(t=t||this.el).getAttribute(e+"-selector");if(e){e=this.findNode(e);if(e)return e}return t},getSelector:function(t,e){var n,i;return t===this.el?"string"==typeof e?":scope > "+e:i:(t&&(n=R(t).index()+1,i=t.tagName+":nth-child("+n+")",e&&(i+=" > "+e),i=this.getSelector(t.parentNode,i)),i)},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(e){var n=this.model,i=n.id,r=this.findAttributeNode("port",e),o=e.getAttribute("joint-selector"),i={id:i};if(null!=o&&(i.magnet=o),null!=r){let t=r.getAttribute("port");"number"===r.getAttribute("port-id-type")&&(t=parseInt(t,10)),i.port=t,n.hasPort(t)||o||(i.selector=this.getSelector(e))}else null==o&&this.el!==e&&(i.selector=this.getSelector(e));for(var t=arguments.length,s=new Array(1<t?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return this.customizeLinkEnd(i,e,...s)},customizeLinkEnd:function(t,e,n,i,r,o){var s=this.paper,a=s.options.connectionStrategy;if("function"==typeof a){a=a.call(s,t,this,e,new A(n,i),r,o,s);if(a)return a}return t},getMagnetFromLinkEnd:function(t){var e=t.port,n=t.magnet,i=this.model,i=null!=e&&i.isElement()&&i.hasPort(e)?this.findPortNode(e,n)||this.el:(n=n||t.selector,this.findNode(n=n||null==e?n:'[port="'+e+'"]'));return this.findProxyNode(i,"magnet")},dragLinkStart:function(t,e,n,i){this.model.startBatch("add-link");e=this.addLinkFromMagnet(e,n,i);e.notifyPointerdown(t,n,i),e.eventData(t,e.startArrowheadMove("target",{whenNotAllowed:"remove"})),this.eventData(t,{linkView:e})},dragLink:function(t,e,n){var i=this.eventData(t),r=i.linkView;if(r)r.pointermove(t,e,n);else{var r=this.paper,o=r.options.magnetThreshold,s=this.getEventTarget(t),i=i.targetMagnet;if("onleave"===o){if(i===s||R(i).contains(s))return}else if(r.eventData(t).mousemoved<=o)return;this.dragLinkStart(t,i,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){ea(e)||(t instanceof SVGElement?R:L)(t).attr(e)},processNodeAttributes:function(t,e){var n,i,r,o,s,a,l,h,u,c=[],d={};for(n in e)e.hasOwnProperty(n)&&(d[R.attributeNames[n]]=e[n]);for(n in d)if(d.hasOwnProperty(n))if(i=d[n],r=this.getAttributeDefinition(n))if(null===i){let e;if(e=(e=!(e=b(r.unset)?r.unset.call(this,t,d,this):r.unset)&&E(r.set)?r.set:e)||n,E(e)&&e)a=a||{},e in a||(a[e]=i);else if(Array.isArray(e)&&0<e.length)for(a=a||{},o=0,s=e.length;o<s;o++){let t=e[o];t in a||(a[t]=i)}}else!b(r.qualify)||r.qualify.call(this,i,t,d,this)?(E(r.set)&&((a=a||{})[r.set]=i),c.push(n,r)):(a=a||{})[n]=i;else(a=a||{})[n]=i;for(o=0,s=c.length;o<s;o+=2)r=c[o+1],i=e[n=c[o]],b(r.set)&&((l=l||{})[n]=i),b(r.position)&&((h=h||{})[n]=i),b(r.offset)&&((u=u||{})[n]=i);return{raw:d,normal:a,set:l,position:h,offset:u}},updateRelativeAttributes:function(t,e,n,i){i=i||{};var r,o,s=Hc(e.raw||{},n),a=e.normal||{};for(o in a)a[o]=s[o];var l=e.position,h=e.offset;for(r in e.set){var u=s[r],c=this.getAttributeDefinition(r).set.call(this,u,n.clone(),t,s,this);w(c)?T(a,c):void 0!==c&&(a[r]=c)}if(t instanceof HTMLElement)this.setNodeAttributes(t,a);else{var d,f,p,e=a.transform,g=R.transformStringToMatrix(e),m=A(g.e,g.f),v=(e&&(a=ua(a,"transform"),g.e=g.f=0),(l||h)&&(f=(i=this.getNodeScale(t,i.scalableNode)).sx,p=i.sy),!1);for(r in l)u=s[r],(d=this.getAttributeDefinition(r).position.call(this,u,n.clone(),t,s,this))&&(m.offset(A(d).scale(f,p)),v=v||!0);this.setNodeAttributes(t,a);var y=!1;if(h){i=this.getNodeBoundingRect(t);if(0<i.width&&0<i.height){var b=R.transformRect(i,g).scale(1/f,1/p);for(r in h)u=s[r],(d=this.getAttributeDefinition(r).offset.call(this,u,b,t,s,this))&&(m.offset(A(d).scale(f,p)),y=y||!0)}}(void 0!==e||v||y)&&(m.round(1),g.e=m.x,g.f=m.y,t.setAttribute("transform",R.matrixToTransformString(g)))}},getNodeScale:function(t,e){var n;return e=e&&e.contains(t)?(n=1/(t=e.scale()).sx,1/t.sy):n=1,{sx:n,sy:e}},cleanNodesCache:function(){this.metrics={}},cleanNodeCache:function(t){t=t.id;t&&delete this.metrics[t]},nodeCache:function(t){var e=this.metrics;return e?e[t=R.ensureId(t)]||(e[t]={}):{}},getNodeData:function(t){t=this.nodeCache(t);return t.data||(t.data={}),t.data},getNodeBoundingRect:function(t){var e=this.nodeCache(t);return void 0===e.boundingRect&&(e.boundingRect=R(t).getBBox()),new tt(e.boundingRect)},getNodeMatrix:function(e){var n=this.nodeCache(e);if(void 0===n.magnetMatrix){var{rotatableNode:i,el:r}=this;let t;t=i&&i.contains(e)?i:r,n.magnetMatrix=R(e).getTransformToElement(t)}return R.createSVGMatrix(n.magnetMatrix)},getNodeShape:function(t){var e=this.nodeCache(t);return void 0===e.geometryShape&&(e.geometryShape=R(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=[];for(o in t)if(t.hasOwnProperty(o)&&(r=t[o],y(r)))for(var l=n[o]=this.findBySelector(o,e,i),h=0,u=l.length;h<u;h++){var c,d,f=l[h],p=R.ensureId(f),g=i&&i[o]===f,m=s[p];m?(m.array||(a.push(p),m.array=!0,m.attributes=[m.attributes],m.selectedLength=[m.selectedLength]),c=m.attributes,m=m.selectedLength,g?(c.unshift(r),m.unshift(-1)):(d=Ks(m,u),c.splice(d,0,r),m.splice(d,0,u))):s[p]={attributes:r,selectedLength:g?-1:u,node:f,array:!1}}for(h=0,u=a.length;h<u;h++)(r=s[p=a[h]]).attributes=k({},...r.attributes.reverse());return s},getEventTarget:function(t){var{target:e,type:n,clientX:i=0,clientY:r=0}=t;return(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).fromPoint||"touchmove"===n||"touchend"===n||"pointerId"in t&&e.hasPointerCapture(t.pointerId)?document.elementFromPoint(i,r):e},updateDOMSubtreeAttributes:function(t,e,n){(n=n||{}).rootBBox||(n.rootBBox=tt()),n.selectors||(n.selectors=this.selectors);var i,r,o={},s={},a=[],l=[],h=n.roAttributes,u=this.findNodesAttributes(h||e,t,o,n.selectors),c=h?this.findNodesAttributes(e,t,o,n.selectors):u;for(r in u)if(f=(d=u[r]).attributes,m=d.node,(i=this.processNodeAttributes(m,f)).set||i.position||i.offset||i.raw.ref){var d=c[r]&&c[r].attributes,f=(d&&void 0===f.ref?d:f).ref;if(f){if(!(g=(o[f]||this.findBySelector(f,t,n.selectors))[0]))throw new Error('dia.CellView: "'+f+'" reference does not exist.')}else g=null;p={node:m,refNode:g,processedAttributes:i,allAttributes:d},g?-1<(f=l.findIndex(function(t){return t.refNode===m}))?l.splice(f,0,p):l.push(p):a.push(p)}else this.setNodeAttributes(m,Hc(i.normal,n.rootBBox));a.push(...l);for(let e=0,t=a.length;e<t;e++){var p,g,m=(p=a[e]).node,v=(g=p.refNode)?R.ensureId(g):"";let t=s[v];t=t||(s[v]=g?R(g).getBBox({target:((t,e)=>{let n=t;do{if(n.contains(e))return n}while(n=n.parentNode);return null})(m,g)}):n.rootBBox),h?(i=this.processNodeAttributes(m,p.allAttributes),this.mergeProcessedAttributes(i,p.processedAttributes)):i=p.processedAttributes,this.updateRelativeAttributes(m,i,t,n)}},mergeProcessedAttributes:function(t,e){t.set||(t.set={}),t.position||(t.position={}),t.offset||(t.offset={}),T(t.set,e.set),T(t.position,e.position),T(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(),Pu.mount(this))},onDetach(){this.unmountTools(),Pu.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).configure({relatedView:this}),t.listenTo(this.paper,"tools:event",this.onToolEvent.bind(this))),this},unmountTools(){var t=this._toolsView;return t&&t.unmount(),this},mountTools(){var 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(){Pu.remove(this)},updateHighlighters:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];Pu.update(this,null,t)},transformHighlighters:function(){Pu.transform(this)},preventDefaultInteraction(t){this.eventData(t,{defaultInteractionPrevented:!0})},isDefaultInteractionPrevented(t){var{defaultInteractionPrevented:t=!1}=this.eventData(t);return t},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){var i=this.model,r=i.graph;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){var i=this.eventData(t).graph;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){var{paper:e,model:n}=this,i=(e.isAsync()&&(n.isLink()&&((i=n.getSourceElement())&&(i=e.findViewByModel(i))&&(e.dumpView(i),e.checkViewVisibility(i)),i=n.getTargetElement())&&(n=e.findViewByModel(i))&&(e.dumpView(n),e.checkViewVisibility(n)),e.dumpView(this),e.checkViewVisibility(this)),this.getEventTarget(t,{fromPoint:!0})),n=e.findView(i);n!==this&&(this.mouseleave(t),n)&&n.mouseenter(t)},setInteractivity:function(t){this.options.interactive=t},isIntersecting:function(t,e){return yr.exists(t,this.getNodeBBox(this.el),e)},isEnclosedIn:function(t){return t.containsRect(this.getNodeBBox(this.el))},isInArea:function(t){return(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).strict?this.isEnclosedIn(t):this.isIntersecting(t)},isAtPoint:function(t,e){return this.getNodeBBox(this.el).containsPoint(t,e)}},{Flags:{TOOLS:"TOOLS"},Highlighting:$c,addPresentationAttributes:function(t){return k({},S(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)?Qs(t.concat(e)):void 0})},evalAttribute:qc});Object.defineProperty(g.prototype,"useCSSSelectors",{get(){var t=this.model.useCSSSelectors;return void 0!==t?t:Ua.useCSSSelectors}});let m={TOOLS:g.Flags.TOOLS,UPDATE:"UPDATE",TRANSLATE:"TRANSLATE",RESIZE:"RESIZE",PORTS:"PORTS",ROTATE:"ROTATE",RENDER:"RENDER"},Wc={MOVE:"move",MAGNET:"magnet"},Yc=g.extend({_removePorts:function(){},_renderPorts:function(){},className:function(){var t=g.prototype.className.apply(this).split(" ");return t.push("element"),t.join(" ")},initialize:function(){g.prototype.initialize.apply(this,arguments),this._initializePorts()},presentationAttributes:{attrs:[m.UPDATE],position:[m.TRANSLATE,m.TOOLS],size:[m.RESIZE,m.PORTS,m.TOOLS],angle:[m.ROTATE,m.TOOLS],markup:[m.RENDER],ports:[m.PORTS]},initFlag:[m.RENDER],UPDATE_PRIORITY:0,confirmUpdate:function(e,n){var i=this.useCSSSelectors;this.hasFlag(e,m.PORTS)&&(this._removePorts(),this._cleanPortsCache());let r=!1;if(this.hasFlag(e,m.RENDER))this.render(),this.updateTools(n),this.updateHighlighters(!0),r=!0,e=this.removeFlag(e,[m.RENDER,m.UPDATE,m.RESIZE,m.TRANSLATE,m.ROTATE,m.PORTS,m.TOOLS]);else{let t=!1;this.hasFlag(e,m.RESIZE)&&(this.resize(n),t=!0,e=this.removeFlag(e,[m.RESIZE,m.UPDATE]),i)&&(e=this.removeFlag(e,m.PORTS)),this.hasFlag(e,m.UPDATE)&&(this.update(this.model,null,n),e=this.removeFlag(e,m.UPDATE),t=!0,i)&&(e=this.removeFlag(e,m.PORTS)),this.hasFlag(e,m.TRANSLATE)&&(this.translate(),e=this.removeFlag(e,m.TRANSLATE),r=!0),this.hasFlag(e,m.ROTATE)&&(this.rotate(),e=this.removeFlag(e,m.ROTATE),r=!0),this.hasFlag(e,m.PORTS)&&(this._renderPorts(),t=!0,e=this.removeFlag(e,m.PORTS)),t&&this.updateHighlighters(!1)}return r&&this.transformHighlighters(),this.hasFlag(e,m.TOOLS)&&(this.updateTools(n),e=this.removeFlag(e,m.TOOLS)),e},_initializePorts:function(){},update:function(t,e){this.cleanNodesCache();var n=this.useCSSSelectors,i=(n&&this._removePorts(),this.model),r=i.attr();this.updateDOMSubtreeAttributes(this.el,r,{rootBBox:new tt(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,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.ElementView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.ElementView: invalid markup")},renderJSONMarkup:function(t){var t=this.parseDOMJSON(t,this.el),e=this.selectors=t.selectors;this.rotatableNode=R(e[this.rotatableSelector])||null,this.scalableNode=R(e[this.scalableSelector])||null,this.vel.append(t.fragment)},renderStringMarkup:function(t){var e=this.vel;e.append(R(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(){this.rotatableNode?(this.rgRotate(),this.update()):this.updateTransformation()},updateTransformation:function(){var t=this.getTranslateString(),e=this.getRotateString();e&&(t+=" "+e),this.vel.attr("transform",t)},getTranslateString:function(){var{x:t,y:e}=this.model.position();return`translate(${t},${e})`},getRotateString:function(){var t,e,n=this.model.angle();return n?({width:t,height:e}=this.model.size(),`rotate(${n},${t/2},${e/2})`):null},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,o=(0<r.node.getElementsByTagName("path").length&&(o=!0),r.getBBox({recursive:o})),s=i.width/(o.width||1),o=i.height/(o.height||1),s=(r.attr("transform","scale("+s+","+o+")"),this.rotatableNode),o=s&&s.attr("transform");o&&(s.attr("transform",o+" rotate("+-n+","+i.width/2+","+i.height/2+")"),s=r.getBBox({target:this.paper.cells}),e.set("position",{x:s.x,y:s.y},T({updateHandled:!0},t)),this.translate(),this.rotate()),this.update()},prepareEmbedding:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=t.model||this.model,n=(t.paper||this.paper).model;let i=t.initialZIndices={};var 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});let 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");r=e.parent();r?(n.getCell(r).unembed(e,{ui:!0}),t.initialParentId=r):t.initialParentId=null},processEmbedding:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=1<arguments.length?arguments[1]:void 0,n=2<arguments.length?arguments[2]:void 0,i=3<arguments.length?arguments[3]:void 0;let r=t.model||this.model;var o=t.paper||this.paper,s=o.model,{findParentBy:a,frontParentOnly:l,validateEmbedding:h}=o.options;let u,c=(u=(u=b(a)?et(a.call(s,this,e,n,i)):"pointer"===a?s.findElementsAtPoint({x:n,y:i}):s.findElementsUnderElement(r,{searchBy:a})).filter(t=>t instanceof gh&&r.id!==t.id&&!t.isEmbeddedIn(r)),l&&(u=u.slice(-1)),null);var d=t.candidateEmbedView;for(let t=u.length-1;0<=t;t--){var f=u[t];if(d&&d.model.id==f.id){c=d;break}f=f.findView(o);if(!b(h)||h.call(o,this,f)){c=f;break}}c&&c!=d&&(this.clearEmbedding(t),t.candidateEmbedView=c.highlight(c.findProxyNode(null,"container"),{embedding:!0})),!c&&d&&this.clearEmbedding(t)},clearEmbedding:function(t){var e=(t=t||{}).candidateEmbedView;e&&(e.unhighlight(e.findProxyNode(null,"container"),{embedding:!0}),t.candidateEmbedView=null)},finalizeEmbedding:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},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{var e=i.options.validateUnembedding,r=t.initialParentId;if(r&&"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(i){var{model:t,whenNotAllowed:e="revert"}=i,r=t||this.model;let o=(i.paper||this.paper).model;switch(e){case"remove":r.remove({ui:!0});break;case"revert":{let{initialParentId:t,initialPosition:e,initialZIndices:n}=i;e&&({x:a,y:s}=e,r.position(a,s,{deep:!0,ui:!0})),n&&Object.keys(n).forEach(t=>{var e=o.getCell(t);e&&e.set("z",n[t],{ui:!0})});var s,a=o.getCell(t);a&&a.embed(r,{ui:!0});break}}},getTargetParentView:function(t){var{candidateEmbedView:t=null}=this.eventData(t);return t},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){e=(t=t||this.el).getAttribute(e+"-selector");if(e){var n=this.findAttribute("port",t);if(n){n=this.findPortNode(n,e);if(n)return n}else{n=this.findNode(e);if(n)return n}}return t},notifyPointerdown(t,e,n){g.prototype.pointerdown.call(this,t,e,n),this.notify("element:pointerdown",t,e,n)},notifyPointermove(t,e,n){g.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),g.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){g.prototype.pointerdblclick.apply(this,arguments),this.notify("element:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){g.prototype.pointerclick.apply(this,arguments),this.notify("element:pointerclick",t,e,n)},contextmenu:function(t,e,n){g.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){var i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointermove(t,r,e,n),o){case Wc.MAGNET:this.dragMagnet(t,e,n);break;case Wc.MOVE:(s||this).drag(t,e,n);default:i.preventPointerEvents||this.notifyPointermove(t,e,n)}this.eventData(t,i)},pointerup:function(t,e,n){var i=this.eventData(t),{targetMagnet:r,action:o,delegatedView:s}=i;switch(r&&this.magnetpointerup(t,r,e,n),o){case Wc.MAGNET:this.dragMagnetEnd(t,e,n);break;case Wc.MOVE:(s||this).dragEnd(t,e,n);default:i.preventPointerEvents||this.notifyPointerup(t,e,n)}r&&this.magnetpointerclick(t,r,e,n),this.checkMouseleave(t)},mouseover:function(t){g.prototype.mouseover.apply(this,arguments),this.notify("element:mouseover",t)},mouseout:function(t){g.prototype.mouseout.apply(this,arguments),this.notify("element:mouseout",t)},mouseenter:function(t){g.prototype.mouseenter.apply(this,arguments),this.notify("element:mouseenter",t)},mouseleave:function(t){g.prototype.mouseleave.apply(this,arguments),this.notify("element:mouseleave",t)},mousewheel:function(t,e,n,i){g.prototype.mousewheel.apply(this,arguments),this.notify("element:mousewheel",t,e,n,i)},onmagnet:function(t,e,n){var i=t.currentTarget;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){var i,r;this.isDefaultInteractionPrevented(t)||(i=this.getDelegatedView())&&i.can("elementMove")&&(this.eventData(t,{action:Wc.MOVE,delegatedView:i}),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){var i,r=this.paper,o=t.isPropagationStopped();o&&this.eventData(t,{preventPointerEvents:!0}),!this.isDefaultInteractionPrevented(t)&&this.can("addLinkFromMagnet")&&({targetMagnet:i=t.currentTarget}=this.eventData(t),t.stopPropagation(),r.options.validateMagnet.call(r,this,i,t)?(r.options.magnetThreshold<=0&&this.dragLinkStart(t,i,e,n),this.eventData(t,{action:Wc.MAGNET})):o?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:h}=s,u=Zn(e+a.x,r),a=Zn(n+a.y,r);o.position(u,a,{restrictedArea:l,deep:!0,ui:!0}),i.options.embeddingMode&&(h||(this.prepareEmbedding(s),h=!0),this.processEmbedding(s,t,e,n)),this.eventData(t,{embedding:h})},dragMagnet:function(t,e,n){this.dragLink(t,e,n)},dragEnd:function(t,e,n){t=this.eventData(t);t.embedding&&this.finalizeEmbedding(t)},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:m}),M=(T(Yc.prototype,o),{TOOLS:g.Flags.TOOLS,RENDER:"RENDER",UPDATE:"UPDATE",LABELS:"LABELS",SOURCE:"SOURCE",TARGET:"TARGET",CONNECTOR:"CONNECTOR"}),Xc=g.extend({className:function(){var t=g.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(){g.prototype.initialize.apply(this,arguments),this._labelCache={},this._labelSelectors={},this._V={},this.cleanNodesCache()},presentationAttributes:{markup:[M.RENDER],attrs:[M.UPDATE],router:[M.UPDATE],connector:[M.CONNECTOR],labels:[M.LABELS,M.TOOLS],labelMarkup:[M.LABELS],vertices:[M.UPDATE],source:[M.SOURCE,M.UPDATE],target:[M.TARGET,M.UPDATE]},initFlag:[M.RENDER,M.SOURCE,M.TARGET,M.TOOLS],UPDATE_PRIORITY:1,EPSILON:1e-6,confirmUpdate:function(n,i){if(i=i||{},this.hasFlag(n,M.SOURCE)){if(!this.updateEndProperties("source"))return n;n=this.removeFlag(n,M.SOURCE)}if(this.hasFlag(n,M.TARGET)){if(!this.updateEndProperties("target"))return n;n=this.removeFlag(n,M.TARGET)}var{paper:r,sourceView:o,targetView:s}=this;if(!r||!(o&&!r.isViewMounted(o)||s&&!r.isViewMounted(s)))if(this.hasFlag(n,M.RENDER))this.render(),this.updateHighlighters(!0),this.updateTools(i),n=this.removeFlag(n,[M.RENDER,M.UPDATE,M.LABELS,M.TOOLS,M.CONNECTOR]),Oh.test("isSafari")&&this.__fixSafariBug268376();else{let t=!1;o=this.model,r=o.attributes;let e=this.hasFlag(n,M.LABELS);e&&(this.onLabelsChange(o,r.labels,i),n=this.removeFlag(n,M.LABELS),t=!0);s=this.hasFlag(n,M.UPDATE),r=this.hasFlag(n,M.CONNECTOR);(s||r)&&(s?i.translateBy&&o.isRelationshipEmbeddedIn(i.translateBy)?this.translate(i.tx,i.ty):this.update():(this.updatePath(),this.updateDOM()),this.updateTools(i),n=this.removeFlag(n,[M.UPDATE,M.TOOLS,M.CONNECTOR]),e=!1,t=!0),e&&this.updateLabelPositions(),t&&this.updateHighlighters(),this.hasFlag(n,M.TOOLS)&&(this.updateTools(i),n=this.removeFlag(n,M.TOOLS))}return n},__fixSafariBug268376:function(){var n=this.el,i=Array.from(n.childNodes),r=document.createDocumentFragment();for(let t=0,e=i.length;t<e;t++)n.removeChild(i[t]),r.appendChild(i[t]);n.appendChild(r)},requestConnectionUpdate:function(t){this.requestUpdate(this.getFlag(M.UPDATE),t)},isLabelsRenderRequired:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=this.model.previous("labels");if(e&&"propertyPathArray"in t&&"propertyValue"in t){var n=t.propertyPathArray||[],i=n.length;if(1<i)if(!!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,t=t.get("markup")||t.markup;if(!t)throw new Error("dia.LinkView: markup required");if(Array.isArray(t))return this.renderJSONMarkup(t);if("string"==typeof t)return this.renderStringMarkup(t);throw new Error("dia.LinkView: invalid markup")},renderJSONMarkup:function(t){t=this.parseDOMJSON(t,this.el);this.selectors=t.selectors,this.vel.append(t.fragment)},renderStringMarkup:function(t){t=R(t);Array.isArray(t)||(t=[t]),this.vel.append(t)},_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=R(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())return(n=1<(e=n.childNodes).length||"G"!==e[0].nodeName.toUpperCase()?R("g").append(n):R(e[0])).addClass("label"),{node:n.node,selectors:t.selectors};throw new Error("dia.LinkView: invalid label markup.")}},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)e&&e.remove();else{e?e.empty():(e=t.labels=R("g").addClass("labels"),this.options.labelsLayer&&(e.addClass(ja(S(this,"className"))),e.attr("model-id",r.id)));for(var a=0;a<s;a++){var l,h=o[a],h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),u=(h=(h?(l=h.node,h):(h=r._builtins.defaultLabel,h=this._normalizeLabelMarkup(this._getLabelMarkup(h.markup)),u=r._getDefaultLabel(),l=(u=this._normalizeLabelMarkup(this._getLabelMarkup(u.markup))||h).node,u)).selectors,l.setAttribute("label-idx",a),e.append(l),n[a]=l,this.selector);if(h[u])throw new Error("dia.LinkView: ambiguous label root selector.");h[u]=l,i[a]=h}e.parent()||this.mountLabels(),this.updateLabels()}return this},mountLabels:function(){var{el:t,paper:e,model:n,_V:i,options:r}=this,i=i.labels;i&&n.hasLabels()&&(i=i.node,r.labelsLayer?e.getLayerView(r.labelsLayer).insertSortedNode(i,n.get("z")):i.parentNode!==t&&t.appendChild(i))},unmountLabels:function(){var{options:t,_V:e}=this;e&&(e=e.labels,e)&&t.labelsLayer&&e.remove()},findLabelNodes:function(t,e){var n=this._labelCache[t];return n?(t=this._labelSelectors[t],this.findBySelector(e,n,t)):[]},findLabelNode:function(t,e){var[t=null]=this.findLabelNodes(t,e);return t},_mergeLabelAttrs:function(t,e,n,i){return null===e?null:void 0===e?null===n?null:void 0===n?t?void 0:i:t?n:k({},i,n):t?k({},n,e):k({},i,n,e)},_mergeLabelSize:function(t,e){return null===t?null:void 0===t?null===e?null:void 0===e?void 0:e:k({},e,t)},updateLabels:function(){if(this._V.labels){this.paper.options.labelLayer||this.cleanNodeCache(this.el);for(var t=this.model,e=t.get("labels")||[],n=this.can("labelMove"),i=t._builtins.defaultLabel.attrs,t=t._getDefaultLabel(),r=t.markup,o=t.attrs,s=t.size,a=0,l=e.length;a<l;a++){var h=this._labelCache[a],u=(h.setAttribute("cursor",n?"move":"default"),this._labelSelectors[a]),c=e[a],d=c.markup,f=c.size,d=this._mergeLabelAttrs(d||r,c.attrs,o,i),c=this._mergeLabelSize(f,s);this.updateDOMSubtreeAttributes(h,d,{rootBBox:new tt(c),selectors:u})}}return this},removeRedundantLinearVertices:function(t){var e=this.model,n=e.vertices(),n=[this.sourceAnchor,...n,this.targetAnchor],i=n.length,n=new x(n),n=(n.simplify({threshold:.001}),n.points.map(t=>t.toJSON())),r=n.length;return i===r?0:(e.vertices(n.slice(1,r-1),t),i-r)},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 A(this.sourceAnchor);case"target":return new A(this.targetAnchor);default:throw new Error("dia.LinkView: type parameter required.")}},getEndConnectionPoint:function(t){switch(t){case"source":return new A(this.sourcePoint);case"target":return new A(this.targetPoint);default:throw new Error("dia.LinkView: type parameter required.")}},getEndMagnet:function(t){switch(t){case"source":var e=this.sourceView;if(e)return this.sourceMagnet||e.el;break;case"target":e=this.targetView;if(e)return this.targetMagnet||e.el;break;default:throw new Error("dia.LinkView: type parameter required.")}return null},update:function(){return this.updateRoute(),this.updatePath(),this.updateDOM(),this},translate:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,{route:n,path:i}=this;n&&i&&((n=new x(n)).translate(t,e),this.route=n.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(){var{el:t,model:e,selectors:n}=this;this.cleanNodesCache(),this.updateDOMSubtreeAttributes(t,e.attr(),{selectors:n}),this.updateLabelPositions(),this.options.perpendicular=null},updateRoute:function(){var t=this.model,t=t.vertices(),e=this.findAnchors(t),n=this.sourceAnchor=e.source,e=this.targetAnchor=e.target,t=this.findRoute(t),t=(this.route=t,this.findConnectionPoints(t,n,e));this.sourcePoint=t.source,this.targetPoint=t.target},updatePath:function(){var{route:t,sourcePoint:e,targetPoint:n}=this,t=this.findPath(t,e.clone(),n.clone());this.path=t},findAnchorsOrdered:function(t,e,n,i){var r=this.model,o=r.get(t),r=r.get(n),s=this.getEndView(t),a=this.getEndView(n),l=this.getEndMagnet(t),h=this.getEndMagnet(n),s=s?(e=e?new A(e):a?h:new A(r),this.getAnchor(o.anchor,s,l,e,t)):new A(o),e=a?(l=new A(i||s),this.getAnchor(r.anchor,a,h,l,n)):new A(r),o={};return o[t]=s,o[n]=e,o},findAnchors:function(t){var e=this.model,n=t[0],t=t[t.length-1];return e.target().priority&&!e.source().priority?this.findAnchorsOrdered("target",t,"source",n):this.findAnchorsOrdered("source",n,"target",t)},findConnectionPoints:function(t,e,n){var i,r=t[0],t=t[t.length-1],o=this.model,s=o.get("source"),o=o.get("target"),a=this.sourceView,l=this.targetView,h=this.paper.options;return{source:a&&!a.isNodeConnection(this.sourceMagnet)?(i=this.sourceMagnet||a.el,s=s.connectionPoint||h.defaultConnectionPoint,r=r||n,r=new P(r,e),this.getConnectionPoint(s,a,i,r,"source")):e,target:l&&!l.isNodeConnection(this.targetMagnet)?(s=this.targetMagnet||l.el,a=o.connectionPoint||h.defaultConnectionPoint,i=t||e,r=new P(i,n),this.getConnectionPoint(a,l,s,r,"target")):n}},getAnchor:function(t,e,n,i,r){var o=e.isNodeConnection(n),s=this.paper.options;if(!(t=t||(o?s.defaultLinkAnchor:this.options.perpendicular?{name:"perpendicular"}:s.defaultAnchor)))throw new Error("Anchor required.");if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s[o?"linkAnchorNamespace":"anchorNamespace"][l]))throw new Error("Unknown anchor: "+l)}s=a.call(this,e,n,i,t.args||{},r,this);return s?s.round(this.decimalsRounding):new A},getConnectionPoint:function(t,e,n,i,r){var o=i.end,s=this.paper.options;if(!t)return o;if("function"==typeof t)a=t;else{var a,l=t.name;if("function"!=typeof(a=s.connectionPointNamespace[l]))throw new Error("Unknown connection point: "+l)}return(s=a.call(this,i,e,n,t.args||{},r,this))?s.round(this.decimalsRounding):o},isIntersecting:function(t,e){var n=this.getConnection();return!!n&&yr.exists(t,n,e,{segmentSubdivisions:this.getConnectionSubdivisions()})},isEnclosedIn:function(t){var e=this.getConnection();return!!e&&!!(e=e.bbox())&&t.containsRect(e)},isAtPoint:function(t){t=new tt(t);return t.inflate(this.EPSILON),this.isIntersecting(t)},_getDefaultLabelPositionProperty:function(){var t=this.model,e=t._builtins.defaultLabel.position,t=t._getDefaultLabel(),t=this._normalizeLabelPosition(t.position);return k({},e,t)},_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:k({},e,t)},updateLabelPositions:function(){if(this._V.labels&&this.path){var t=this.model.get("labels")||[];if(t.length)for(var e=this._getDefaultLabelPositionProperty(),n=0,i=t.length;n<i;n++){var r,o=this._labelCache[n];o&&(r=t[n],r=this._normalizeLabelPosition(r.position),r=this._mergeLabelPositionProperty(r,e),r=this._getLabelTransformationMatrix(r),o.setAttribute("transform",R.matrixToTransformString(r)),this._cleanLabelMatrices(n))}}return this},_cleanLabelMatrices:function(t){var{metrics:e,_labelSelectors:n}=this,i=n[t];if(i)for(var r in i){r=i[r].id;r&&r in e&&delete e[r].magnetMatrix}},updateEndProperties:function(t){var{model:e,paper:n}=this,i=t+"View",e=e.get(t),e=e&&e.id;if(e){if(!(e=n.getModelById(e)))throw new Error("LinkView: invalid "+t+" cell.");if(!(e=e.findView(n)))return!1;this[i]=e}else this[i]=null;return this.updateEndMagnet(t),!0},updateEndMagnet:function(e){var n=e+"Magnet",i=this.getEndView(e);if(i){let t=i.getMagnetFromLinkEnd(this.model.get(e));t===i.el&&(t=null),this[n]=t}else this[n]=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:k({},e,t)},addLabel:function(t,e,n,i){var r,o,s=0,t="number"!=typeof t?(r=t.x,o=t.y,"number"==typeof e?(s=e,n):e):(r=t,o=e,"number"==typeof n?(s=n,i):n),e=this._getDefaultLabelPositionArgs(),i=t,n=this._mergeLabelPositionArgs(i,e),i={position:this.getLabelPosition(r,o,s,n)};return this.model.insertLabel(-1,i,t),-1},addVertex:function(t,e,n){var i="number"!=typeof t,r=i?t.x:t,t=i?t.y:e,i=i?e:n,e={x:r,y:t},n=this.getVertexIndex(r,t);return this.model.insertVertex(n,e,i),n},sendToken:function(t,e,n){var i,r,e=w(e)?(o=e.duration,a="reverse"===e.direction,e.connection):(o=e,a=!1,null),o=o||1e3,s={dur:o+"ms",repeatCount:1,calcMode:"linear",fill:"freeze"},a=(a&&(s.keyPoints="1;0",s.keyTimes="0;1"),R(t));if(!((e="string"==typeof e?this.findNode(e):(t=this._V).connection?t.connection.node:this.el.querySelector("path"))instanceof SVGPathElement))throw new Error("dia.LinkView: token animation requires a valid connection path.");a.appendTo(this.paper.cells).animateAlongPath(s,e),setTimeout((i=a,r=n,function(){i.remove(),"function"==typeof r&&r()}),o)},findRoute:function(t){t=t||[];var e=this.paper.options.routerNamespace||Nc,n=this.model.router(),i=this.paper.options.defaultRouter;if(!n){if(!i)return t.map(A);n=i}i=b(n)?n:e[n.name];if(b(i))return e=n.args||{},i.call(this,t,e,this)||t.map(A);throw new Error('dia.LinkView: unknown router: "'+n.name+'".')},findPath:function(t,e,n){var i=this.paper.options.connectorNamespace||su,r=this.model.connector(),o=this.paper.options.defaultConnector,r=r||o||{},o=b(r)?r:i[r.name];if(b(o))return(i=f(r.args||{})).raw=!0,"string"==typeof(o=o.call(this,e,n,t,i,this))?new V(R.normalizePathData(o)):o;throw new Error('dia.LinkView: unknown connector: "'+r.name+'".')},getConnection:function(){var t=this.path;return t?t.clone():null},getSerializedConnection:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("data")?t.data:(e=e.serialize(),t.data=e):null},getConnectionSubdivisions:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("segmentSubdivisions")?t.segmentSubdivisions:(e=e.getSegmentSubdivisions(),t.segmentSubdivisions=e):null},getConnectionLength:function(){var t,e=this.path;return e?(t=this.metrics).hasOwnProperty("length")?t.length:(e=e.length({segmentSubdivisions:this.getConnectionSubdivisions()}),t.length=e):0},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?(ll(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,i="number"==typeof n?(s=n,i):n,n=(i&&(o.args=i),!(i&&i.absoluteDistance)),a=i&&i.absoluteDistance&&i.reverseDistance,i=i&&i.absoluteOffset,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},t=new A(t,e),e=l.closestPointT(t,h),h=l.lengthAtT(e,h);return n&&(h=h/this.getConnectionLength()||0),a&&(h=-1*(this.getConnectionLength()-h)||1),o.distance=h,h=(r=i?r:l.tangentAtT(e))?r.pointOffset(t):(n=l.pointAtT(e),{x:(a=t.difference(n)).x,y:a.y}),o.offset=h,o.angle=s,o},_getLabelTransformationMatrix:function(t){var e=0,n={};if("number"==typeof t)u=t;else{if("number"!=typeof t.distance)throw new Error("dia.LinkView: invalid label position distance.");n=t.args||{},u=t.distance,e=t.angle||0}var i,r=0<u&&u<=1,o=0,s={x:0,y:0},t=(t.offset&&("number"==typeof(t=t.offset)&&(o=t),t.x&&(s.x=t.x),t.y)&&(s.y=t.y),0!==s.x||0!==s.y||0===o),a=n.keepGradient,n=n.ensureLegibility,l=this.path,h={segmentSubdivisions:this.getConnectionSubdivisions()},r=r?u*this.getConnectionLength():u,u=l.tangentAtLength(r,h),r=e;return u?(t?(i=u.start.clone()).offset(s):((h=u.clone()).rotate(u.start,-90),h.setLength(o),i=h.end),a&&(r=u.angle()+e,n)&&(r=Xn((r+90)%180-90))):(i=l.start.clone(),t&&i.offset(s)),R.createSVGMatrix().translate(i.x,i.y).rotate(r)},getLabelCoordinates:function(t){t=this._getLabelTransformationMatrix(t);return new A(t.e,t.f)},getVertexIndex:function(t,e){for(var n=this.model.vertices(),i=this.getClosestPointLength(new A(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){g.prototype.pointerdown.call(this,t,e,n),this.notify("link:pointerdown",t,e,n)},notifyPointermove(t,e,n){g.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),g.prototype.pointerup.call(this,t,e,n)},pointerdblclick:function(t,e,n){g.prototype.pointerdblclick.apply(this,arguments),this.notify("link:pointerdblclick",t,e,n)},pointerclick:function(t,e,n){g.prototype.pointerclick.apply(this,arguments),this.notify("link:pointerclick",t,e,n)},contextmenu:function(t,e,n){g.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&&T(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){g.prototype.mouseover.apply(this,arguments),this.notify("link:mouseover",t)},mouseout:function(t){g.prototype.mouseout.apply(this,arguments),this.notify("link:mouseout",t)},mouseenter:function(t){g.prototype.mouseenter.apply(this,arguments),this.notify("link:mouseenter",t)},mouseleave:function(t){g.prototype.mouseleave.apply(this,arguments),this.notify("link:mouseleave",t)},mousewheel:function(t,e,n,i){g.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,i=parseInt(i.getAttribute("label-idx"),10),r=this._getDefaultLabelPositionProperty(),o=this._normalizeLabelPosition(this._getLabelPositionProperty(i)),o=this._mergeLabelPositionProperty(o,r),r=this.getLabelCoordinates(o),o=r.x-e,e=r.y-n,r=this._getLabelPositionAngle(i),n=this._getLabelPositionArgs(i),s=this._getDefaultLabelPositionArgs(),n=this._mergeLabelPositionArgs(n,s);this.eventData(t,{action:"label-move",labelIdx:i,dx:o,dy:e,positionAngle:r,positionArgs:n,stopPropagation:!0})}else this.eventData(t,{stopPropagation:!0});this.paper.delegateDragEvents(this,t.data)},dragArrowheadStart:function(t,e,n){var i;this.can("arrowheadMove")&&(i=t.target.getAttribute("end"),i=this.startArrowheadMove(i,{ignoreBackwardsCompatibility:!0}),this.eventData(t,i))},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),e={position:this.getLabelPosition(e+i.dx,n+i.dy,i.positionAngle,i.positionArgs)},n=(this.paper.options.snapLabels&&delete e.position.offset,{ui:!0});this.paper.isAsync()&&"touchmove"===t.type&&(n.async=!1),this.model.label(i.labelIdx,e,n)},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,i=t.arrowhead,r=t.initialEnd,o=this.model.prop(i);o&&!Nh.endsEqual(r,o)&&(n=this.paper,r.id&&this.notify("link:disconnect",e,n.findViewByModel(r.id),t.initialMagnet,i),o.id)&&this.notify("link:connect",e,n.findViewByModel(o.id),t.magnetUnderPointer,i)},_snapToPoints:function(e,n,t){let i=null,r=1/0,o=null,s=1/0,a=e.x,l=e.y;for(let t=0;t<n.length;t++){var h=Math.abs(n[t].x-e.x),h=(h<r&&(r=h,i=n[t]),Math.abs(n[t].y-e.y));h<s&&(s=h,o=n[t])}return r<t&&(a=i.x),s<t&&(l=o.y),{x:a,y:l}},_snapArrowheadSelf:function(t,e,n){var{paper:i,model:r}=this,o=i.options.snapLinksSelf,s=this.eventData(t),o=o.radius||20,s=[this.getEndAnchor("source"===s.arrowhead?"target":"source"),...r.vertices()],r=this._snapToPoints({x:e,y:n},s,o),e=i.localToClientPoint(r);this._connectArrowhead(document.elementFromPoint(e.x,e.y),r.x,r.y,this.eventData(t))},_snapArrowhead:function(t,e,n){let i=this.paper;var{snapLinks:r,connectionStrategy:o}=i.options;let s=this.eventData(t),a=!1,l=r.radius||50,h=i.findElementViewsInArea({x:e-l,y:n-l,width:2*l,height:2*l},r.findInAreaOptions),u=s.closestView||null;var c=s.closestMagnet||null,r=s.magnetProxy||null,d=(s.closestView=s.closestMagnet=s.magnetProxy=null,Number.MAX_VALUE),f=new A(e,n),p=(h.forEach(function(n){let e=[];"false"!==n.el.getAttribute("magnet")&&e.push({bbox:n.model.getBBox(),magnet:n.el}),n.$("[magnet]").toArray().forEach(t=>{e.push({bbox:n.getNodeBBox(t),magnet:t})}),e.forEach(t=>{var{magnet:t,bbox:e}=t,e=e.center().squaredDistance(f);e<d&&(c===t||i.options.validateConnection.apply(i,s.validateConnectionArgs(n,n.el===t?null:t)))&&(d=e,s.closestView=n,s.closestMagnet=t)})},this),null),g=s.closestView,m=s.closestMagnet,v=(m&&(p=s.magnetProxy=g.findProxyNode(m,"highlighter")),s.arrowhead),y=c!==m;if(u&&y&&u.unhighlight(r,{connecting:!0,snapping:!0}),g){var{prevEnd:r,prevX:b,prevY:x}=s;if(s.prevX=e,s.prevY=n,a=!0,!y&&("function"!=typeof o||b===e&&x===n))return a;if(b=g.getLinkEnd(m,e,n,this.model,v),!y&&na(r,b))return a;s.prevEnd=b,y&&g.highlight(p,{connecting:!0,snapping:!0})}else b={x:e,y:n};return this.model.set(v,b||{x:e,y:n},{ui:!0}),u&&this.notify("link:snap:disconnect",t,u,c,v),g&&this.notify("link:snap:connect",t,g,m,v),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){var r,o,s,{paper:a,model:l}=this;i.eventTarget!==t&&(i.magnetProxy&&i.viewUnderPointer.unhighlight(i.magnetProxy,{connecting:!0}),(r=i.viewUnderPointer=a.findView(t))&&(o=i.magnetUnderPointer=r.findMagnet(t),s=i.magnetProxy=r.findProxyNode(o,"highlighter"),o)&&this.paper.options.validateConnection.apply(a,i.validateConnectionArgs(r,o))?s&&r.highlight(s,{connecting:!0}):(i.magnetUnderPointer=null,i.magnetProxy=null)),i.eventTarget=t,l.set(i.arrowhead,{x:e,y:n},{ui:!0})},_connectArrowheadEnd:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=1<arguments.length?arguments[1]:void 0,n=2<arguments.length?arguments[2]:void 0,i=this.model,{viewUnderPointer:t,magnetUnderPointer:r,magnetProxy:o,arrowhead:s}=t;r&&o&&t&&(t.unhighlight(o,{connecting:!0}),o=t.getLinkEnd(r,e,n,i,s),i.set(s,o,{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=[],i=(n[4]=t,0),r=0,t="source"===t?(i=2,"target"):(r=2,"source"),t=(n[5]=this).model.get(t);return t.id&&((t=(e=n[i]=this.paper.findViewByModel(t.id)).getMagnetFromLinkEnd(t))===e.el&&(t=void 0),n[i+1]=t),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]")),l=("false"!==s.el.getAttribute("magnet")&&a.push(s.el),a.filter(e.bind(t,s)));if(0<l.length){for(var h=0,u=l.length;h<u;h++)s.highlight(l[h],{magnetAvailability:!0});s.highlight(null,{elementAvailability:!0}),t.marked[s.model.id]=l}}}},_unmarkAvailableMagnets:function(t){for(var e=Object.keys(t.marked),n=0,i=e.length;n<i;n++){var r=e[n],o=t.marked[r],s=this.paper.findViewByModel(r);if(s){for(var a=0,l=o.length;a<l;a++)s.unhighlight(o[a],{magnetAvailability:!0});s.unhighlight(null,{elementAvailability:!0})}}t.marked=null},startArrowheadMove:function(t,e){t={action:"arrowhead-move",arrowhead:t,whenNotAllowed:(e=e||{}).whenNotAllowed||"revert",initialMagnet:this[t+"Magnet"]||(this[t+"View"]?this[t+"View"].el:null),initialEnd:f(this.model.get(t)),validateConnectionArgs:this._createValidateConnectionArgs(t)};return this._beforeArrowheadMove(t),!0!==e.ignoreBackwardsCompatibility&&(this._dragData=t),t},onMount:function(){g.prototype.onMount.apply(this,arguments),this.mountLabels()},onDetach:function(){g.prototype.onDetach.apply(this,arguments),this.unmountLabels()},onRemove:function(){g.prototype.onRemove.apply(this,arguments),this.unmountLabels()}},{Flags:M}),Zc=(Object.defineProperty(Xc.prototype,"sourceBBox",{enumerable:!0,get:function(){var t,e=this.sourceView;return e?(t=this.sourceMagnet,e.isNodeConnection(t)?new tt(this.sourceAnchor):e.getNodeBBox(t||e.el)):(t=this.model.source(),new tt(t.x,t.y))}}),Object.defineProperty(Xc.prototype,"targetBBox",{enumerable:!0,get:function(){var t,e=this.targetView;return e?(t=this.targetMagnet,e.isNodeConnection(t)?new tt(this.targetAnchor):e.getNodeBBox(t||e.el)):(t=this.model.target(),new tt(t.x,t.y))}}),jc.extend({style:{"pointer-events":"none"},_gridCache:null,_gridSettings:null,init(){jc.prototype.init.apply(this,arguments);var{paper:t}=this.options;this._gridCache=null,this._gridSettings=[],this.listenTo(t,"transform resize",this.updateGrid)},setGrid(t){this._gridSettings=this.getGridSettings(t),this.renderGrid()},getGridSettings(t){let e=[];return t&&(Array.isArray(t)?t:[t||{}]).forEach(t=>{e.push(...this._resolveDrawGridOption(t))}),e},removeGrid(){var t=this._gridCache;t&&(t.root.remove(),this._gridCache=null)},renderGrid(){let{paper:s}=this.options;var t=this._gridSettings;if(this.removeGrid(),0!==t.length){let o=s.options.drawGridSize||s.options.gridSize;if(!(o<=1)){let r=this._getGridRefs();t.forEach((t,e)=>{var e=this._getPatternId(e),t=k({},t),{scaleFactor:n=1}=t;t.width=o*n||1,t.height=o*n||1;let i;r.exist(e)?i=r.get(e):(i=R("pattern",{id:e,patternUnits:"userSpaceOnUse"},R(t.markup)),r.add(e,i)),b(t.render)&&t.render(i.node.firstChild,t,s),i.attr({width:t.width,height:t.height})}),r.root.appendTo(this.el),this.updateGrid()}}},updateGrid(){let{_gridCache:e,_gridSettings:i,options:{paper:r}}=this;if(e){let{root:t,patterns:n}=e;var o,{x:s,y:a,width:l,height:h}=r.getArea();for(o in t.attr({x:s,y:a,width:l,height:h}),n)n[o].attr({x:-s,y:-a});i.forEach((t,e)=>{b(t.update)&&(e=n[this._getPatternId(e)],t.update(e.node.firstChild,t,r))})}},_getPatternId(t){return`pattern_${this.options.paper.cid}_`+t},_getGridRefs(){var t=this._gridCache;if(!t){let i=R("defs"),r=R("svg",{width:"100%",height:"100%"},[i]);t=this._gridCache={root:r,patterns:{},add:function(t,e){var n=R("rect",{width:"100%",height:"100%",fill:`url(#${t})`});i.append(e),r.append(n),this.patterns[t]=e},get:function(t){return this.patterns[t]},exist:function(t){return void 0!==this.patterns[t]}}}return t},_resolveDrawGridOption(t){var e=this.options.patterns;if(E(t)&&Array.isArray(e[t]))return e[t].map(function(t){return T({},t)});var n=t||{args:[{}]},i=Array.isArray(n),r=n.name;if((r=i||r||n.markup?r:"dot")&&Array.isArray(e[r])){var o=e[r].map(function(t){return T({},t)}),s=Array.isArray(n.args)?n.args:[n.args||{}];Ws(s[0],ua(t,"args"));for(var a=0;a<s.length;a++)o[a]&&T(o[a],s[a]);return o}return i?n:[n]}})),Jc={NONE:"sorting-none",APPROX:"sorting-approximate",EXACT:"sorting-exact"};let Kc=9007199254740991;s=g.Highlighting;let Qc={[s.DEFAULT]:{name:"stroke",options:{padding:3}},[s.MAGNET_AVAILABILITY]:{name:"addClass",options:{className:"available-magnet"}},[s.ELEMENT_AVAILABILITY]:{name:"addClass",options:{className:"available-cell"}}},td=[{name:zc.GRID},{name:zc.BACK},{name:zc.CELLS},{name:zc.LABELS},{name:zc.FRONT},{name:zc.TOOLS}];u=uu.extend({className:"paper",options:{width:800,height:600,gridSize:1,drawGrid:!1,drawGridSize:null,background:!1,elementView:Yc,linkView:Xc,snapLabels:!1,snapLinks:!1,snapLinksSelf:!1,labelsLayer:!1,multiLinks:!0,guard:function(t,e){return!1},highlighting:Qc,preventContextMenu:!0,preventDefaultBlankAction:!0,preventDefaultViewAction:!0,restrictTranslate:!1,markAvailable:!1,defaultLink:function(){var t=this.model.get("cells").cellNamespace,t=Ya(t,["standard","Link"]);if(t)return new t;throw new Error("dia.Paper: no default link model found. Use `options.defaultLink` to specify a default link model.")},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 Yc},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:Jc.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:n,anchorNamespace:i,linkAnchorNamespace:Ic,connectionPointNamespace:$e,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,DEFAULT_FIND_BUFFER:200,init:function(){var t=this.options,t=(t.cellViewNamespace||(t.cellViewNamespace="undefined"!=typeof joint&&da(joint,"shapes")?joint.shapes:null),this.model=t.model||new Dc);this._layers={},this.cloneOptions(),this.render(),this._setDimensions(),this.startListening(),this._views={},this._mw_evt_buffer={event:null,deltas:[]},this.resetViews(t.attributes.cells.models),!this.isFrozen()&&this.isAsync()&&this.updateViewsAsync()},_resetUpdates:function(){return this._updates&&this._updates.id&&al(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()||!qs(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){t=this.findViewByModel(t);t&&this.requestViewUpdate(t,t.FLAG_REMOVE,t.UPDATE_PRIORITY,n)},onCellChange:function(t,e){t!==this.model.attributes.cells&&t.hasChanged("z")&&this.options.sorting===Jc.APPROX&&(t=this.findViewByModel(t))&&this.requestViewUpdate(t,t.FLAG_INSERT,t.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){var e,n,i;this.isFrozen()||(e=t&&t.batchName,n=this.model,this.isAsync()||(i=this.UPDATE_DELAYING_BATCHES).includes(e)&&!n.hasActiveBatch(i)&&this.updateViews(t),(i=this.SORT_DELAYING_BATCHES).includes(e)&&!n.hasActiveBatch(i)&&this.sortViews())},cloneOptions:function(){var t=this.options,{defaultConnector:e,defaultRouter:n,defaultConnectionPoint:i,defaultAnchor:r,defaultLinkAnchor:o,highlighting:s,cellViewNamespace:a,interactive:l}=t;!a&&"undefined"!=typeof joint&&da(joint,"shapes")&&(t.cellViewNamespace=joint.shapes),b(e)||(t.defaultConnector=ta(e)),b(n)||(t.defaultRouter=ta(n)),b(i)||(t.defaultConnectionPoint=ta(i)),b(r)||(t.defaultAnchor=ta(r)),b(o)||(t.defaultLinkAnchor=ta(o)),y(l)&&(t.interactive=T({},l)),y(s)&&(t.highlighting=Js({},s,Qc))},children:function(){var t=R.namespace;return[{namespaceURI:t.xhtml,tagName:"div",className:ja("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:ja("layers"),selector:"layers"}]}]},hasLayerView(t){return t in this._layers},getLayerView(t){var e=this._layers;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();var{el:t,childNodes:e,options:n,stylesheet:i}=this,{svg:e,defs:r,layers:o}=e;return t.style.position="relative",e.style.overflow=n.overflow?"visible":"hidden",this.svg=e,this.defs=r,this.layers=o,this.renderLayers(),R.ensureId(e),this.addStylesheet(i),n.background&&this.drawBackground(n.background),n.drawGrid&&this.setGrid(n.drawGrid),this},addStylesheet:function(t){t&&R(this.svg).prepend(R.createSVGStyle(t))},createLayer(t){return t!==zc.GRID?new jc({name:t}):new Zc({name:t,paper:this,patterns:this.constructor.gridPatterns})},renderLayers:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:td,t=(this.removeLayers(),t.forEach(t=>{var t=t.name,e=this.createLayer(t);this.layers.appendChild(e.el),this._layers[t]=e}),this.getLayerView(zc.CELLS)),e=this.getLayerView(zc.TOOLS),n=this.getLayerView(zc.LABELS);this.tools=e.el,this.cells=this.viewport=t.el,t.vel.addClass(ja("viewport")),n.vel.addClass(ja("viewport")),t.el.style.webkitUserSelect="none",t.el.style.userSelect="none",n.el.style.webkitUserSelect="none",n.el.style.userSelect="none"},removeLayers:function(){let e=this._layers;Object.keys(e).forEach(t=>{e[t].remove(),delete e[t]})},resetLayers:function(){let e=this._layers;Object.keys(e).forEach(t=>{e[t].removePivots()})},update:function(){return this._background&&this.updateBackgroundImage(this._background),this},scale:function(t,e,n){var i=this.matrix();return void 0===t?R.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){var{a:i,d:r,e:o,f:s}=this.matrix();return(t=Math.max(t||0,this.MIN_SCALE))===i&&t===r||(o=R.createSVGMatrix().translate(o-e.x*(t-i),s-e.y*(t-r)).scale(t,t),this.matrix(o,n)),this},translate:function(t,e,n){var i=this.matrix();return void 0===t?R.matrixToTranslate(i):(e=e||0,i.e===(t=t||0)&&i.f===e||(i.e=t,i.f=e,this.matrix(i,n)),this)},matrix:function(t){var e,n,i,r,o,s,a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},l=this.layers;return void 0===t?(e=l.getAttribute("transform"),(this._viewportTransformString||null)===e?t=this._viewportMatrix:(t=l.getCTM(),this._viewportMatrix=t,this._viewportTransformString=e),R.createSVGMatrix(t)):(e=this.matrix(),t=R.createSVGMatrix(t),i=this._viewportTransformString,(n=R.matrixToTransformString(t))===i||!i&&R.matrixToTransformString()===n||({a:i,d:r,e:o,f:s}=t,l.setAttribute("transform",n),this._viewportMatrix=t,this._viewportTransformString=l.getAttribute("transform"),i===e.a&&r===e.d||this.trigger("scale",i,r,a),o===e.e&&s===e.f||this.trigger("translate",o,s,a),this.trigger("transform",t,a)),this)},clientMatrix:function(){return R.createSVGMatrix(this.cells.getScreenCTM())},requestConnectedLinksUpdate:function(t,e,n){if(t instanceof g)for(var i=t.model,r=this.model.getConnectedLinks(i),o=0,s=r.length;o<s;o++){var a,l=r[o],h=this.findViewByModel(l);h&&(a=["UPDATE"],l.getTargetCell()===i&&a.push("TARGET"),l.getSourceCell()===i&&a.push("SOURCE"),l=Math.max(e+1,h.UPDATE_PRIORITY),this.scheduleViewUpdate(h,h.getFlag(a),l,n))}},forcePostponedViewUpdate:function(t,e){if(t&&t instanceof g){var n=t.model;if(!n.isElement()&&0==(e&t.getFlag(["SOURCE","TARGET"]))){var e={silent:!0},i=0,r=this.findViewByModel(n.getSourceCell()),r=(r&&!this.isViewMounted(r)&&(i=this.dumpView(r,e),t.updateEndMagnet("source")),0),n=this.findViewByModel(n.getTargetCell());if(n&&!this.isViewMounted(n)&&(r=this.dumpView(n,e),t.updateEndMagnet("target")),0===i&&0===r)return!this.dumpView(t,e)}}return!1},requestViewUpdate:function(t,e,n,i){this.scheduleViewUpdate(t,e,n,i=i||{});t=this.isAsync();this.isFrozen()||t&&!1!==i.async||this.model.hasActiveBatch(this.UPDATE_DELAYING_BATCHES)||(e=this.updateViews(i),t&&this.notifyAfterRender(e,i))},scheduleViewUpdate:function(t,e,n,i){var{_updates:r,options:o}=this,{FLAG_REMOVE:s,FLAG_INSERT:a,UPDATE_PRIORITY:l,cid:h}=(r.idle&&o.autoFreeze&&(r.idle=!1,this.unfreeze()),t);let u=r.priorities[n];if(u=u||(r.priorities[n]={}),l<n)for(let t=n-1;t>=l;t--){var c=r.priorities[t];c&&h in c&&(u[h]|=c[h],delete c[h])}var d=u[h]||0;(d&e)!==e&&(d||r.count++,e&s&&d&a?u[h]^=a:e&a&&d&s&&(u[h]^=s),u[h]|=e,"function"==typeof(a=o.onViewUpdate))&&a.call(this,t,e,n,i||{},this)},dumpViewUpdate:function(t){var e,n;return t?(n=this._updates,e=t.cid,n=n.priorities[t.UPDATE_PRIORITY],t=this.registerMountedView(t)|n[e],delete n[e],t):0},dumpView:function(t){var e,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},i=this.dumpViewUpdate(t);return i?((e=!n.silent)&&this.notifyBeforeRender(n),i=this.updateView(t,i,n),e&&(e={updated:1,priority:t.UPDATE_PRIORITY},this.notifyAfterRender(e,n)),i):0},updateView:function(t,e,n){if(!t)return 0;var{FLAG_REMOVE:i,FLAG_INSERT:r,FLAG_INIT:o,model:s}=t;if(t instanceof g){if(e&i)return this.removeView(s),0;e&r&&((i=!!(e&o))&&(e^=o),this.insertView(t,i),e^=r)}return e?t.confirmUpdate(e,n||{}):0},requireView:function(t,e){t=this.findViewByModel(t);return t?(this.dumpView(t,e),t):null},registerUnmountedView:function(t){var e=t.cid,n=this._updates;return e in n.unmounted?0:(t=n.unmounted[e]|=t.FLAG_INSERT,n.unmountedCids.push(e),delete n.mounted[e],t)},registerMountedView:function(t){var t=t.cid,e=this._updates;if(t in e.mounted)return 0;e.mounted[t]=!0,e.mountedCids.push(t);var n=e.unmounted[t]||0;return delete e.unmounted[t],n},isViewMounted:function(t){return!!t&&t.cid in this._updates.mounted},dumpViews:function(t){t=Ws({},t,{viewport:null});this.checkViewport(t),this.updateViews(t)},updateViews:function(t){var e;this.notifyBeforeRender(t);let n=0,i=0,r=Kc;for(;i++,e=this.updateViewsBatch(t),n+=e.updated,r=Math.min(e.priority,r),!e.empty;);var o={updated:n,batches:i,priority:r};return this.notifyAfterRender(o,t),o},hasScheduledUpdates:function(){var t=this._updates.priorities,e=Object.keys(t);let n=e.length;for(;0<n&&n--;)for(var i in t[e[n]])return!0;return!1},updateViewsAsync:function(e,n){e=e||{},n=n||{processed:0,priority:Kc};var{_updates:i,options:r}=this,o=i.id;if(o){al(o),0===n.processed&&this.hasScheduledUpdates()&&this.notifyBeforeRender(e);var s=this.updateViewsBatch(e),a=Ws({},e,{mountBatchSize:1e3-s.mounted,unmountBatchSize:1e3-s.unmounted}),a=this.checkViewport(a),l=a.unmounted,a=a.mounted;let t=n.processed;var h=i.count,l=(0<s.updated?(t+=s.updated+s.unmounted,s.processed=t,n.priority=Math.min(s.priority,n.priority),s.empty&&0===a?(s.unmounted+=l,s.mounted+=a,s.priority=n.priority,this.notifyAfterRender(s,e),n.processed=0,n.priority=Kc,i.count=0):n.processed=t):i.idle||r.autoFreeze&&(this.freeze(),i.idle=!0,this.trigger("render:idle",e)),e.progress);if(h&&"function"==typeof l&&l.call(this,s.empty,t,h,s,this),i.id!==o)return}if(i.disabled)throw new Error("dia.Paper: can not unfreeze the paper after it was removed");i.id=sl(this.updateViewsAsync,this,e,n)},notifyBeforeRender:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};let e=t.beforeRender;"function"!=typeof e&&"function"!=typeof(e=this.options.beforeRender)||e.call(this,t,this)},notifyAfterRender:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};let n=e.afterRender;"function"==typeof(n="function"!=typeof n?this.options.afterRender:n)&&n.call(this,t,e,this),this.trigger("render:done",t,e)},updateViewsBatch:function(t){var e=(t=t||{}).batchSize||1/0,n=this._updates,i=0,r=0,o=0,s=0,a=Kc,l=!0,h=this.options,u=n.priorities,c=("viewport"in t?t:h).viewport,d=("function"!=typeof c&&(c=null),h.onViewPostponed),f=("function"!=typeof d&&(d=null),Object.keys(u));t:for(var p=0,g=f.length;p<g;p++){var m,v=+f[p],y=u[v];for(m in y){if(e<=i){l=!1;break t}var b=hu[m];if(b){var x=y[m];if(0==(x&b.FLAG_REMOVE)){var w=m in n.unmounted;if(b.DETACHABLE&&c&&!c.call(this,b,!w,this)){w||(this.registerUnmountedView(b),this.detachView(b)),n.unmounted[m]|=x,delete y[m],o++;continue}w&&(x|=b.FLAG_INSERT,s++),x|=this.registerMountedView(b)}w=this.updateView(b,x,t);0<w&&(y[m]=w,!d||!d.call(this,b,w,this)||y[m])?(r++,l=!1):(v<a&&(a=v),i++,delete y[m])}else delete y[m]}}return{priority:a,updated:i,postponed:r,unmounted:o,mounted:s,empty:l}},getUnmountedViews:function(){for(var t=this._updates,e=Object.keys(t.unmounted),n=e.length,i=new Array(n),r=0;r<n;r++)i[r]=hu[e[r]];return i},getMountedViews:function(){for(var t=this._updates,e=Object.keys(t.mounted),n=e.length,i=new Array(n),r=0;r<n;r++)i[r]=hu[e[r]];return i},checkUnmountedViews:function(t,e){for(var n=0,e=("function"!=typeof t&&(t=null),"mountBatchSize"in(e=e||{})?e.mountBatchSize:1/0),i=this._updates,r=i.unmountedCids,o=i.unmounted,s=0,a=Math.min(r.length,e);s<a;s++){var l,h=r[s];h in o&&(l=hu[h])&&(l.DETACHABLE&&t&&!t.call(this,l,!1,this)?r.push(h):(n++,(h=this.registerMountedView(l))&&this.scheduleViewUpdate(l,h,l.UPDATE_PRIORITY,{mounting:!0})))}return r.splice(0,s),n},checkMountedViews:function(t,e){e=e||{};var n=0;if("function"==typeof t){for(var e=("unmountBatchSize"in e?e.unmountBatchSize:1/0),i=this._updates,r=i.mountedCids,o=i.mounted,s=0,a=Math.min(r.length,e);s<a;s++){var l,h=r[s];h in o&&(l=hu[h])&&(!l.DETACHABLE||t.call(this,l,!0,this)?r.push(h):(n++,this.registerUnmountedView(l)&&this.detachView(l)))}r.splice(0,s)}return n},checkViewVisibility:function(e){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};let t=("viewport"in n?n:this.options).viewport;"function"!=typeof t&&(t=null);var i,n=this._updates,{mounted:r,unmounted:o}=n,s=!e.DETACHABLE||!t||t.call(this,e,!1,this);let a=!1,l=!1;if(e.cid in r&&!s){let t=this.registerUnmountedView(e);t&&this.detachView(e);var r=n.mountedCids.indexOf(e.cid);n.mountedCids.splice(r,1),a=!0}return!a&&e.cid in o&&s&&(r=n.unmountedCids.indexOf(e.cid),n.unmountedCids.splice(r,1),(i=this.registerMountedView(e))&&this.scheduleViewUpdate(e,i,e.UPDATE_PRIORITY,{mounting:!0}),l=!0),{mounted:l?1:0,unmounted:a?1:0}},checkViewport:function(t){var e,t=Ws({},t,{mountBatchSize:1/0,unmountBatchSize:1/0}),n=("viewport"in t?t:this.options).viewport,i=this.checkMountedViews(n,t);return 0<i&&(e=this._updates.unmountedCids,t.mountBatchSize=Math.min(e.length-i,t.mountBatchSize)),{mounted:this.checkUnmountedViews(n,t),unmounted:i}},freeze:function(t){var e=this._updates,t=(t=t||{}).key,n=this.options.frozen,i=e.freezeKey;if(t&&t!==i){if(n&&i)return;e.freezeKey=t,e.keyFrozen=n}this.options.frozen=!0;i=e.id;e.id=null,this.isAsync()&&i&&al(i)},unfreeze:function(t){var e=this._updates,n=(t=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===Jc.EXACT},onRemove:function(){this.freeze(),this._updates.disabled=!0,this.removeLayers(),this.removeViews()},getComputedSize:function(){var t=this.options,e=t.width,t=t.height;return{width:e=qs(e)?e:this.el.clientWidth,height:t=qs(t)?t:this.el.clientHeight}},setDimensions:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=this.options,{width:r,height:o}=i,t=void 0===t?r:t,e=void 0===e?o:e;r===t&&o===e||(i.width=t,i.height=e,this._setDimensions(),r=this.getComputedSize(),this.trigger("resize",r.width,r.height,n))},_setDimensions:function(){var t=this.options;let e=t.width,n=t.height;qs(e)&&(e=Math.round(e)+"px"),qs(n)&&(n=Math.round(n)+"px"),this.$el.css({width:null===e?"":e,height:null===n?"":n})},fitToContent:function(t,e,n,i){i=w(t)?t:T({gridWidth:t,gridHeight:e,padding:n},i);var{x:t,y:e,width:n,height:r}=this.getFitToContentArea(i),{sx:o,sy:s}=this.scale();return this.translate(-t*o,-e*s,i),this.setDimensions(n*o,r*s,i),new tt(t,e,n,r)},getFitToContentArea:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=t.gridWidth||1,n=t.gridHeight||1,i=gl(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,h="contentArea"in t?new tt(t.contentArea):this.getContentArea(t),{sx:u,sy:c}=this.scale();h.x*=u,h.y*=c,h.width*=u,h.height*=c;let d=Math.ceil((h.width+h.x)/e),f=Math.ceil((h.height+h.y)/n),p=(t.allowNegativeBottomRight||(d=Math.max(d,1),f=Math.max(f,1)),d*=e,f*=n,0),g=(("negative"===l&&h.x<0||"positive"===l&&0<=h.x||"any"===l)&&(p=Math.ceil(-h.x/e)*e,p+=i.left,d+=p),0);return("negative"===l&&h.y<0||"positive"===l&&0<=h.y||"any"===l)&&(g=Math.ceil(-h.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 tt(-p/u,-g/c,d/u,f/c)},transformToFitContent:function(o){o=o||{};let s,a;if(a="contentArea"in o?(l=o.contentArea,s=this.localToPaperRect(l),new A(l)):(s=this.getContentBBox(o),this.paperToLocalPoint(s)),s.width&&s.height){Ws(o,{padding:0,preserveAspectRatio:!0,scaleGrid:null,minScale:0,maxScale:Number.MAX_VALUE,verticalAlign:"top",horizontalAlign:"left"});var l=gl(o.padding),h=o.minScaleX||o.minScale,u=o.maxScaleX||o.maxScale,c=o.minScaleY||o.minScale,d=o.maxScaleY||o.maxScale;let t;t=o.fittingBBox||(p=this.translate(),g=this.getComputedSize(),{x:p.tx,y:p.ty,width:g.width,height:g.height}),t=new tt(t).moveAndExpand({x:l.left,y:l.top,width:-l.left-l.right,height:-l.top-l.bottom});var f,p=this.matrix(),{a:g,d:l,e:m,f:v}=p;let e=t.width/s.width*g,n=t.height/s.height*l;o.preserveAspectRatio&&(e=n=Math.min(e,n)),o.scaleGrid&&(f=o.scaleGrid,e=f*Math.floor(e/f),n=f*Math.floor(n/f)),e=Math.min(u,Math.max(h,e)),n=Math.min(d,Math.max(c,n));const y=e/g,b=n/l;let i=t.x-a.x*e-m,r=t.y-a.y*n-v;switch(o.verticalAlign){case"middle":r+=(t.height-s.height*b)/2;break;case"bottom":r+=t.height-s.height*b}switch(o.horizontalAlign){case"middle":i+=(t.width-s.width*y)/2;break;case"right":i+=t.width-s.width*y}p.a=e,p.d=n,p.e=i,p.f=r,this.matrix(p,o)}},scaleContentToFit:function(t){this.transformToFitContent(t)},getContentArea:function(t){return t&&t.useModelGeometry?this.model.getBBox()||new tt:R(this.cells).getBBox()},getContentBBox:function(t){return this.localToPaperRect(this.getContentArea(t))},getArea:function(){return this.paperToLocalRect(this.getComputedSize())},getRestrictedArea:function(){var t=this.options.restrictTranslate;let e;if(b(t)){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];e=t.apply(this,i)}else e=!0===t?this.getArea():t?new tt(t):null;return e},createViewForModel:function(t){var e,n=this.options,i=n.cellViewNamespace,r=t.get("type")+"View",i=Ya(i,r,"."),r=t.isLink()?(e=n.linkView,Xc):(e=n.elementView,Yc);return new(e.prototype instanceof ou?i||e:e.call(this,t)||i||r)({model:t,interactive:n.interactive,labelsLayer:!0===n.labelsLayer?zc.LABELS:n.labelsLayer})},removeView:function(t){var e,n,t=t.id,{_views:i,_updates:r}=this,o=i[t];return o&&(e=o.cid,{mounted:r,unmounted:n}=r,o.remove(),delete i[t],delete r[e],delete n[e]),o},renderView:function(t,e){var n=t.id,i=this._views;let r,o,s=!0;return n in i&&((r=i[n]).model===t?(o=r.FLAG_INSERT,s=!1):this.removeView(t)),s&&((r=i[n]=this.createViewForModel(t)).paper=this,o=this.registerUnmountedView(r)|this.FLAG_INIT|r.getFlag(S(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();var 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(){Xs(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")),n=this.model.get("cells");pl(t,function(t,e){t=n.get(t.getAttribute("model-id")),e=n.get(e.getAttribute("model-id")),t=t.attributes.z||0,e=e.attributes.z||0;return t===e?0:t<e?-1:1})},insertView:function(t,e){var n=this.getLayerView(zc.CELLS),{el:i,model:r}=t;this.options.sorting===Jc.APPROX?n.insertSortedNode(i,r.get("z")):(Jc,n.insertNode(i)),t.onMount(e)},detachView(t){t.unmount(),t.onDetach()},findView:function(t){t=E(t)?this.cells.querySelector(t):t instanceof L?t[0]:t,t=this.findAttribute("model-id",t);if(t)return this._views[t]},findViewByModel:function(t){t=E(t)||qs(t)?t:t&&t.id;return this._views[t]},findViewsFromPoint:function(e){return e=new A(e),this.model.getElements().map(this.findViewByModel,this).filter(function(t){return t&&t.vel.getBBox({target:this.cells}).containsPoint(e)},this)},findViewsInArea:function(e,t){t=Ws(t||{},{strict:!1}),e=new tt(e);var n=this.model.getElements().map(this.findViewByModel,this),i=t.strict?"containsRect":"intersect";return n.filter(function(t){return t&&e[i](t.vel.getBBox({target:this.cells}))},this)},findElementViewsInArea(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findElementsInArea(t,e),e)},findLinkViewsInArea:function(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findLinksInArea(t,e),e)},findCellViewsInArea:function(t,e){return this._filterViewsInArea(t,(t,e)=>this.model.findCellsInArea(t,e),e)},findElementViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findElementsInArea(t),e)},findLinkViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findLinksInArea(t),e)},findCellViewsAtPoint:function(t,e){return this._filterViewsAtPoint(t,t=>this.model.findCellsInArea(t),e)},_findInExtendedArea:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},{buffer:i=this.DEFAULT_FIND_BUFFER}=n;return e(new tt(t).inflate(i),n).map(t=>this.findViewByModel(t))},_filterViewsInArea:function(t,e){let n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},i=new tt(t);return this._findInExtendedArea(i,e,n).filter(t=>!!t&&t.isInArea(i,n))},_filterViewsAtPoint:function(e,t){let n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};var i=new tt(e);return this._findInExtendedArea(i,t,n).filter(t=>!!t&&t.isAtPoint(e,n))},removeTools:function(){return this.dispatchToolsEvent("remove"),this},hideTools:function(){return this.dispatchToolsEvent("hide"),this},showTools:function(){return this.dispatchToolsEvent("show"),this},dispatchToolsEvent:function(t){if("string"==typeof t){for(var e=arguments.length,n=new Array(1<e?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];this.trigger("tools:event",t,...n)}},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){t=new A(t,e);return R.transformPoint(t,this.matrix())},localToPaperRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.matrix())},paperToLocalPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.matrix().inverse())},paperToLocalRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.matrix().inverse())},localToClientPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.clientMatrix())},localToClientRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,this.clientMatrix())},clientToLocalPoint:function(t,e){t=new A(t,e);return R.transformPoint(t,this.clientMatrix().inverse())},clientToLocalRect:function(t,e,n,i){t=new tt(t,e,n,i);return R.transformRect(t,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){t=new A(t,e).difference(this.pageOffset());return this.paperToLocalPoint(t)},pageToLocalRect:function(t,e,n,i){var r=this.pageOffset(),t=new tt(t,e,n,i);return t.x-=r.x,t.y-=r.y,this.paperToLocalRect(t)},clientOffset:function(){var t=this.svg.getBoundingClientRect();return new A(t.left,t.top)},pageOffset:function(){return this.clientOffset().offset(window.scrollX,window.scrollY)},linkAllowed:function(t){var e,n,i,r;if(t instanceof Xc)return e=t.model,n=this.options,r=(i=this.model).constructor.validations,!(!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));throw new Error("Must provide a linkView.")},getDefaultLink:function(t,e){return b(this.options.defaultLink)?this.options.defaultLink.call(this,t,e):this.options.defaultLink.clone()},resolveHighlighter:function(){let{highlighter:t,type:e}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};var{highlighting:n,highlighterNamespace:i}=this.options;if(void 0===t){if(!n)return!1;if(e&&!1===(t=n[e]))return!1;t=t||n.default}if(!t)return!1;n=(t=E(t)?{name:t}:t).name,i=i[n];if(!i)throw new Error('Unknown highlighter ("'+n+'")');if("function"!=typeof i.highlight)throw new Error('Highlighter ("'+n+'") is missing required highlight() method');if("function"!=typeof i.unhighlight)throw new Error('Highlighter ("'+n+'") is missing required unhighlight() method');return{highlighter:i,options:t.options||{},name:n}},onCellHighlight:function(t,e,n){var i,n=this.resolveHighlighter(n);n&&({highlighter:n,options:i}=n,n.highlight(t,e,i))},onCellUnhighlight:function(t,e,n){var i,n=this.resolveHighlighter(n);n&&({highlighter:n,options:i}=n,n.unhighlight(t,e,i))},pointerdblclick:function(t){t.preventDefault(),t=C(t);var e,n=this.findView(t.target);this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n?n.pointerdblclick(t,e.x,e.y):this.trigger("blank:pointerdblclick",t,e.x,e.y))},pointerclick:function(t){var e,n;this.eventData(t).mousemoved<=this.options.clickThreshold&&(t=C(t),e=this.findView(t.target),this.guard(t,e)||(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=C(t),this.contextMenuTrigger(t))},contextMenuTrigger:function(t){var e,n=this.findView(t.target);this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n?n.contextmenu(t,e.x,e.y):this.trigger("blank:contextmenu",t,e.x,e.y))},pointerdown:function(t){var{target:e,button:n}=t=C(t),i=this.findView(e),n=2===n;if(i){if(!n&&this.guard(t,i))return;var r=this.FORM_CONTROL_TAG_NAMES.includes(e.tagName),r=(this.options.preventDefaultViewAction&&!r&&t.preventDefault(),r&&i.preventDefaultInteraction(t),this.customEventTrigger(t,i));if(r){if(r.isPropagationStopped())return;t.data=r.data}r=e.closest("[magnet]");if(r&&i.el!==r&&i.el.contains(r)){var e=C(new L.Event(t.originalEvent,{data:t.data,currentTarget:r}));if(this.onmagnet(e),e.isDefaultPrevented()&&t.preventDefault(),e.isPropagationStopped())return n?void 0:void this.delegateDragEvents(i,e.data);t.data=e.data}}n?(this.contextMenuFired=!0,r=new L.Event(t.originalEvent,{type:"contextmenu",data:t.data}),this.contextMenuTrigger(r)):(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,n,i=this.eventData(t);i.mousemoved||(i.mousemoved=0,this.undelegateEvents()),++i.mousemoved<=this.options.moveThreshold||(t=C(t),e=this.snapToGrid(t.clientX,t.clientY),(n=i.sourceView)?n.pointermove(t,e.x,e.y):this.trigger("blank:pointermove",t,e.x,e.y),this.eventData(t,i))},pointerup:function(t){this.undelegateDocumentEvents();var e=C(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 L.Event(t.originalEvent,{type:"click",data:t.data})),this.delegateEvents()},mouseover:function(t){t=C(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseover(t):this.el!==t.target&&this.trigger("blank:mouseover",t))},mouseout:function(t){t=C(t);var e=this.findView(t.target);this.guard(t,e)||(e?e.mouseout(t):this.el!==t.target&&this.trigger("blank:mouseout",t))},mouseenter:function(t){var{target:e,relatedTarget:n,currentTarget:i}=t=C(t),e=this.findView(e);if(!this.guard(t,e)){var r=this.findView(n);if(e){if(r===e)return;if(e.mouseenter(t),this.el.contains(n))return}r||i===this.el&&this.trigger("paper:mouseenter",t)}},mouseleave:function(t){var{target:e,relatedTarget:n,currentTarget:i}=t=C(t),e=this.findView(e);if(!this.guard(t,e)){var r=this.findView(n);if(e){if(r===e)return;if(e.mouseleave(t),this.el.contains(n))return}r||i===this.el&&this.trigger("paper:mouseleave",t)}},_processMouseWheelEvtBuf:ia(function(){var{event:t,deltas:e}=this._mw_evt_buffer,e=e.reduce((t,e)=>t+rl(e,50),0),e=Math.pow(.995,e),{x:n,y:i}=this.clientToLocalPoint(t.clientX,t.clientY);this.trigger("paper:pinch",t,n,i,e),this._mw_evt_buffer={event:null,deltas:[]}},20,{maxWait:20}),mousewheel:function(t){t=C(t);var e,n,i,r,o,s=this.findView(t.target);this.guard(t,s)||(e=t.originalEvent,n=this.snapToGrid(e.clientX,e.clientY),{deltaX:i,deltaY:r}=il(e),o=this._events["paper:pinch"],t.ctrlKey&&o&&0<o.length?(e.preventDefault(),this._mw_evt_buffer.event=t,this._mw_evt_buffer.deltas.push(r),this._processMouseWheelEvtBuf()):(o=Math.max(-1,Math.min(1,e.wheelDelta)),s?s.mousewheel(t,n.x,n.y,o):this.trigger("blank:mousewheel",t,n.x,n.y,o),this.trigger("paper:pan",t,i,r)))},onevent:function(t){var e,n=t.currentTarget,i=n.getAttribute("event");i&&(n=this.findView(n))&&(t=C(t),this.guard(t,n)||(e=this.snapToGrid(t.clientX,t.clientY),n.onevent(t,i,e.x,e.y)))},magnetEvent:function(t,e){var n,i,r=t.currentTarget;r.getAttribute("magnet")&&(n=this.findView(r))&&(t=C(t),this.guard(t,n)||(i=this.snapToGrid(t.clientX,t.clientY),e.call(this,n,t,r,i.x,i.y)))},onmagnet:function(t){var e;2===t.button?(this.contextMenuFired=!0,this.magnetContextMenuFired=!0,e=new L.Event(t.originalEvent,{type:"contextmenu",data:t.data,currentTarget:t.currentTarget}),this.magnetContextMenuTrigger(e),e.isPropagationStopped()&&t.stopPropagation()):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&&(t=C(t),!this.guard(t,n))){e=this.customEventTrigger(t,n,e);if(e){if(e.isPropagationStopped())return;t.data=e.data}e=this.snapToGrid(t.clientX,t.clientY);n.onlabel(t,e.x,e.y)}},getPointerArgs(t){var t=C(t),{x:e,y:n}=this.snapToGrid(t.clientX,t.clientY);return[t,e,n]},delegateDragEvents:function(t,e){this.eventData({data:e=e||{}},{sourceView:t||null,mousemoved:0}),this.delegateDocumentEvents(null,e)},guard:function(t,e){return"mousedown"===t.type&&2===t.button||!(!this.options.guard||!this.options.guard(t,e))||(t.data&&void 0!==t.data.guarded?t.data.guarded:(t=t.target,!!this.GUARDED_TAG_NAMES.includes(t.tagName)||!(e&&e.model&&e.model instanceof gh||this.el===t||this.svg.contains(t))))},setGridSize:function(t){var e=this.options;return e.gridSize=t,e.drawGrid&&!e.drawGridSize&&this.getLayerView(zc.GRID).renderGrid(),this},setGrid:function(t){return this.getLayerView(zc.GRID).setGrid(t),this},updateBackgroundImage:function(t){var e=(t=t||{}).position||"center",t=t.size||"auto auto",n=this.scale(),i=this.translate(),i=(w(e)&&(e=i.tx+n.sx*(e.x||0)+"px "+(i.ty+n.sy*(e.y||0))+"px"),w(t)&&(t=(t=new tt(t).scale(n.sx,n.sy)).width+"px "+t.height+"px"),this.childNodes).background;i.style.backgroundSize=t,i.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[ga(r)];if(b(a)){t.width*=s,t.height*=s;a=a(t,e);if(!(a instanceof HTMLCanvasElement))throw new Error("dia.Paper: background pattern must return an HTML Canvas instance");n=a.toDataURL("image/png"),r="repeat",w(i)?(i.width*=a.width/t.width,i.height*=a.height/t.height):void 0===i&&(e.size={width:a.width/s,height:a.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){var e;return this.updateBackgroundColor((t=t||{}).color),t.image?(t=this._background=ta(t),tl(t),(e=document.createElement("img")).onload=this.drawBackgroundImage.bind(this,e,t),e.src=t.image):(this.drawBackgroundImage(null),this._background=null),this},setInteractivity:function(t){this.options.interactive=t,Xs(this._views,"setInteractivity",t)},isDefined:function(t){return!!this.svg.getElementById(t)},defineFilter:function(t){if(!w(t))throw new TypeError("dia.Paper: defineFilter() requires 1. argument to be an object.");var e=t.id,n=t.name,e=e||n+this.svg.id+Wa(JSON.stringify(t));if(!this.isDefined(e)){var i=yl,i=i[n]&&i[n](t.args||{});if(!i)throw new Error("Non-existing filter "+n);n=T({filterUnits:"userSpaceOnUse"},t.attrs,{id:e});R(i,n).appendTo(this.defs)}return e},defineGradient:function(t){var e,n,i,r;if(w(t))return{svg:n,defs:e}=this,{type:r,id:n=r+n.id+Wa(JSON.stringify(t)),stops:t,attrs:i={}}=t,this.isDefined(n)||(t=et(t).map(t=>{var{offset:t,color:e,opacity:n}=t;return R("stop").attr({offset:t,"stop-color":e,"stop-opacity":Number.isFinite(n)?n:1})}),(r=R(r,i,t)).id=n,r.appendTo(e)),n;throw new TypeError("dia.Paper: defineGradient() requires 1. argument to be an object.")},definePattern:function(t){if(!w(t))throw new TypeError("dia.Paper: definePattern() requires 1. argument to be an object.");var e,{svg:n,defs:i}=this,{id:n=n.id+Wa(JSON.stringify(t)),markup:t,attrs:r={}}=t;if(t)return this.isDefined(n)||((e=R("pattern",{patternUnits:"userSpaceOnUse"})).id=n,e.attr(r),"string"==typeof t?e.append(R(t)):(r=$a(t).fragment,e.append(r)),e.appendTo(i)),n;throw new TypeError("dia.Paper: definePattern() requires markup.")},defineMarker:function(t){if(!w(t))throw new TypeError("dia.Paper: defineMarker() requires the first argument to be an object.");var{svg:e,defs:n}=this,{id:e=e.id+Wa(JSON.stringify(t)),markup:o,attrs:s={},markerUnits:a="userSpaceOnUse"}=t;if(!this.isDefined(e)){a=R("marker",{orient:"auto",overflow:"visible",markerUnits:a});a.id=e,a.attr(s);let i;if(o){let t;t="string"==typeof o?(t=R(o),Array.isArray(t)?t:[t]):(s=$a(o).fragment,R(s).children()),i=1<t.length?R("g").append(t):t[0]}else{var{type:o="path"}=t;i=R(o)}let r=ua(t,"type","id","markup","attrs","markerUnits");Object.keys(r).forEach(t=>{var e=r[t],n=i.attr(t);null==n?i.attr(t,e):"transform"===t&&i.attr(t,e+" "+n)}),i.appendTo(a),a.appendTo(n)}return e},customEventTrigger:function(t,e){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:e.el,i=t.target.closest("[event]");return i&&n!==i&&e.el.contains(i)?(n=C(new L.Event(t.originalEvent,{data:t.data,currentTarget:i})),this.onevent(n),n.isDefaultPrevented()&&t.preventDefault(),n):null}},{sorting:Jc,Layers:zc,backgroundPatterns:{flipXy:function(t){var e=document.createElement("canvas"),n=t.width,i=t.height,r=(e.width=2*n,e.height=2*i,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,r=(e.width=2*n,e.height=i,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,r=(e.width=n,e.height=2*i,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||{};for(var n=t.width,i=t.height,r=document.createElement("canvas"),o=(r.width=3*n,r.height=3*i,r.getContext("2d")),e=qs(e.watermarkAngle)?-e.watermarkAngle:-20,s=Jn(e),a=r.width/4,l=r.height/4,h=0;h<4;h++)for(var u=0;u<4;u++)0<(h+u)%2&&(o.setTransform(1,0,0,1,(2*h-1)*a,(2*u-1)*l),o.rotate(s),o.drawImage(t,-n/2,-i/2,n,i));return r}},gridPatterns:{dot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){R(t).attr({width:e.thickness,height:e.thickness,fill:e.color})}}],fixedDot:[{color:"#AAAAAA",thickness:1,markup:"rect",render:function(t,e){R(t).attr({fill:e.color})},update:function(t,e,n){var{sx:n,sy:i}=n.scale(),n=n<=1?e.thickness:e.thickness/n,e=i<=1?e.thickness:e.thickness/i;R(t).attr({width:n,height:e})}}],mesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}],doubleMesh:[{color:"#AAAAAA",thickness:1,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}},{color:"#000000",thickness:3,scaleFactor:4,markup:"path",render:function(t,e){var n=e.width,i=e.height,r=e.thickness,r=0<=n-r&&0<=i-r?["M",n,0,"H0 M0 0 V0",i].join(" "):"M 0 0 0 0";R(t).attr({d:r,stroke:e.color,"stroke-width":e.thickness})}}]}});let ed=uu.extend({name:null,tagName:"g",className:"tool",svgElement:!0,_visible:!0,_visibleExplicit:!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},updateVisibility:function(){var t=this.computeVisibility();this.el.style.display=t?"":"none",this._visible=t},computeVisibility(){var t;return!!this.isExplicitlyVisible()&&(t=this.options.visibility,"function"!=typeof t||!!t.call(this,this.relatedView,this))},show:function(){this._visibleExplicit=!0,this.updateVisibility()},hide:function(){this._visibleExplicit=!1,this.updateVisibility()},isExplicitlyVisible:function(){return!!this._visibleExplicit},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){var{paper:e,relatedView:n}=this;return!e||!n||e.guard(t,n)}});r=uu.extend({tagName:"g",className:"tools",svgElement:!0,tools:null,isRendered:!1,options:{tools:null,relatedView:null,name:null},configure:function(t){var e=(t=T(this.options,t)).tools;if(Array.isArray(e)){var n=t.relatedView;if(n instanceof g){for(var i=this.tools=[],r=0,o=e.length;r<o;r++){var s=e[r];s instanceof ed&&(s.configure(n,this),this.vel.append(s.el),i.push(s))}this.isRendered=!1,n.requestUpdate(n.getFlag("TOOLS"))}}return this},getName:function(){return this.options.name},update:function(e){e=e||{};var n=this.tools;if(n){var i=n.length,t=this.isRendered;for(let t=0;t<i;t++){var r=n[t];r.updateVisibility(),r.isVisible()&&this.ensureToolRendered(n,t)&&e.tool!==r.cid&&r.update()}!this.isRendered&&0<i||(this.isMounted()||this.mount(),t)||this.blurTool()}return this},ensureToolRendered(t,e){return this.isRendered||(this.isRendered=Array(t.length).fill(!1)),!(!this.isRendered[e]&&(t[e].render(),this.isRendered[e]=!0))},focusTool:function(t){var e=this.tools;if(e)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)for(var n=0,i=e.length;n<i;n++){var r=e[n];r===t||r.isExplicitlyVisible()||(r.show(),r.isVisible()&&this.ensureToolRendered(e,n)&&r.update())}return this},hide:function(){return this.focusTool(null)},show:function(){return this.blurTool(null),this.isMounted()||this.mount(),this},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(){var{options:t,el:e}=this,{relatedView:t,layer:n=zc.TOOLS,z:i}=t;return t&&(n?t.paper.getLayerView(n).insertSortedNode(e,i):t.el.appendChild(e)),this}}),a={Graph:Dc,attributes:fh,LayersNames:zc,PaperLayer:jc,Cell:gh,CellView:g,Element:c,ElementView:Yc,Link:Nh,LinkView:Xc,Paper:u,ToolView:ed,ToolsView:r,HighlighterView:Pu},Je=uu.extend({tagName:"circle",svgElement:!0,className:"marker-vertex",events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onDoubleClick",dbltap:"onDoubleClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},attributes:{r:6,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2,cursor:"move"},position:function(t,e){var{vel:n,options:i}=this,i=i.scale;let r=R.createSVGMatrix().translate(t,e);i&&(r=r.scale(i)),n.transform(r,{absolute:!0})},onPointerDown:function(t){this.options.guard(t)||(t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.trigger("will-change",this,t))},onPointerMove:function(t){this.trigger("changing",this,t)},onDoubleClick:function(t){this.trigger("remove",this,t)},onPointerUp:function(t){this.trigger("changed",this,t),this.undelegateDocumentEvents(),this.options.paper.delegateEvents()}}),e=ed.extend({name:"vertices",options:{handleClass:Je,snapRadius:20,redundancyRemoval:!0,vertexAdding:!0,stopPropagation:!0,scale:null},children:[{tagName:"path",selector:"connection",className:"joint-vertices-path",attributes:{fill:"none",stroke:"transparent","stroke-width":10,cursor:"cell"}}],handles:null,interactiveLinkNode:null,events:{"mousedown .joint-vertices-path":"onPathPointerDown","touchstart .joint-vertices-path":"onPathPointerDown"},linkEvents:{mousedown:"onLinkPointerDown",touchstart:"onLinkPointerDown"},onRender:function(){var t=this.options.vertexAdding;return t&&({interactiveLinkNode:t=null}=t,t?this.delegateLinkEvents(t):(this.renderChildren(),this.updatePath())),this.resetHandles(),this.renderHandles(),this},delegateLinkEvents:function(t){this.undelegateLinkEvents();var e=this.relatedView.findNode(t);e?(e.classList.add("joint-vertices-path"),this.interactiveLinkNode=e,this.delegateElementEvents(e,this.linkEvents)):console.warn(`Interactive link node "${t}" not found.`)},undelegateLinkEvents:function(){var t=this.interactiveLinkNode;t&&(this.undelegateElementEvents(t),t.classList.remove("joint-vertices-path"),this.interactiveLinkNode=null)},update:function(){return this.relatedView.model.vertices().length===this.handles.length?this.updateHandles():(this.resetHandles(),this.renderHandles()),this.options.vertexAdding&&this.updatePath(),this},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,n=t.length;e<n;e++)t[e].remove()},renderHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,n=t.length;e<n;e++){var i=t[e],r=new this.options.handleClass({index:e,paper:this.paper,scale:this.options.scale,guard:t=>this.guard(t)});r.render(),r.position(i.x,i.y),this.simulateRelatedView(r.el),r.vel.appendTo(this.el),this.handles.push(r),this.startHandleListening(r)}},updateHandles:function(){for(var t=this.relatedView.model.vertices(),e=0,n=t.length;e<n;e++){var i=t[e],r=this.handles[e];if(!r)return;r.position(i.x,i.y)}},updatePath:function(){var t;this.interactiveLinkNode||(t=this.childNodes.connection)&&t.setAttribute("d",this.relatedView.getSerializedConnection())},startHandleListening:function(t){var{vertexRemoving:e=!0,vertexMoving:n=!0}=this.options;n&&(this.listenTo(t,"will-change",this.onHandleWillChange),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"changed",this.onHandleChanged)),e&&this.listenTo(t,"remove",this.onHandleRemove)},getNeighborPoints:function(t){var e=this.relatedView,n=e.model.vertices(),i=0<t?n[t-1]:e.sourceAnchor,n=t<n.length-1?n[t+1]:e.targetAnchor;return{prev:new A(i),next:new A(n)}},onHandleWillChange:function(t,e){this.focus();var{relatedView:n,options:i}=this;n.model.startBatch("vertex-move",{ui:!0,tool:this.cid}),i.stopPropagation||n.notifyPointerdown(...n.paper.getPointerArgs(e))},onHandleChanging:function(t,e){var{options:n,relatedView:i}=this,r=t.options.index,[e,o,s]=i.paper.getPointerArgs(e),a={x:o,y:s};this.snapVertex(a,r),i.model.vertex(r,a,{ui:!0,tool:this.cid}),t.position(a.x,a.y),n.stopPropagation||i.notifyPointermove(e,o,s)},onHandleChanged:function(t,e){var n,i,r,{options:o,relatedView:s}=this;o.vertexAdding&&this.updatePath(),o.redundancyRemoval?([n,i,r]=(s.removeRedundantLinearVertices({ui:!0,tool:this.cid})&&this.render(),this.blur(),s.model.stopBatch("vertex-move",{ui:!0,tool:this.cid}),this.eventData(e).vertexAdded&&s.model.stopBatch("vertex-add",{ui:!0,tool:this.cid}),s.paper.getPointerArgs(e)),o.stopPropagation||s.notifyPointerup(n,i,r),s.checkMouseleave(n)):s.checkMouseleave(C(e))},snapVertex:function(t,e){var n,i,r=this.options.snapRadius;0<r&&(n=(e=this.getNeighborPoints(e)).prev,i=e.next,Math.abs(t.x-n.x)<r?t.x=n.x:Math.abs(t.x-i.x)<r&&(t.x=i.x),Math.abs(t.y-n.y)<r?t.y=e.prev.y:Math.abs(t.y-i.y)<r&&(t.y=i.y))},onHandleRemove:function(t,e){var t=t.options.index,n=this.relatedView;n.model.removeVertex(t,{ui:!0}),this.options.vertexAdding&&this.updatePath(),n.checkMouseleave(C(e))},onPathPointerDown:function(t){var e,n,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),t=C(t),e=this.paper.snapToGrid(t.clientX,t.clientY).toJSON(),(i=this.relatedView).model.startBatch("vertex-add",{ui:!0,tool:this.cid}),n=i.getVertexIndex(e.x,e.y),this.snapVertex(e,n),i.model.insertVertex(n,e,{ui:!0,tool:this.cid}),this.update(),i=this.handles[n],this.eventData(t,{vertexAdded:!0}),i.onPointerDown(t))},onLinkPointerDown:function(t){this.relatedView.preventDefaultInteraction(t),this.onPathPointerDown(t)},onRemove:function(){this.resetHandles(),this.undelegateLinkEvents()}},{VertexHandle:Je});function nd(t,e){var n=t.model;return e?n.getBBox():n.isLink()?t.getConnection().bbox():t.getNodeUnrotatedBBox(t.el)}function id(t,e,n){return Ru.call(this.paper,{},e,n,t,this.model).anchor}h=uu.extend({tagName:"g",svgElement:!0,className:"marker-segment",events:{mousedown:"onPointerDown",touchstart:"onPointerDown"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},children:[{tagName:"line",selector:"line",attributes:{stroke:"#33334F","stroke-width":2,fill:"none","pointer-events":"none"}},{tagName:"rect",selector:"handle",attributes:{width:20,height:8,x:-10,y:-4,rx:4,ry:4,fill:"#33334F",stroke:"#FFFFFF","stroke-width":2}}],onRender:function(){this.renderChildren()},position:function(t,e,n,i){var r=this.options.scale;let o=R.createSVGMatrix().translate(t,e).rotate(n);r&&(o=o.scale(r));r=this.childNodes.handle,r.setAttribute("transform",R.matrixToTransformString(o)),r.setAttribute("cursor",n%180==0?"row-resize":"col-resize"),r=i.getClosestPoint(new A(t,e)),n=this.childNodes.line;n.setAttribute("x1",t),n.setAttribute("y1",e),n.setAttribute("x2",r.x),n.setAttribute("y2",r.y)},onPointerDown:function(t){this.options.guard(t)||(this.trigger("change:start",this,t),t.stopPropagation(),t.preventDefault(),this.options.paper.undelegateEvents(),this.delegateDocumentEvents(null,t.data))},onPointerMove:function(t){this.trigger("changing",this,t)},onPointerUp:function(t){this.undelegateDocumentEvents(),this.options.paper.delegateEvents(),this.trigger("change:end",this,t)},show:function(){this.el.style.display=""},hide:function(){this.el.style.display="none"}}),Rh=ed.extend({name:"segments",precision:.5,options:{handleClass:h,segmentLengthThreshold:40,redundancyRemoval:!0,anchor:id,snapRadius:10,snapHandle:!0,stopPropagation:!0},handles:null,onRender:function(){this.resetHandles();var t=this.relatedView,e=t.model.vertices();e.unshift(t.sourcePoint),e.push(t.targetPoint);for(var n=0,i=e.length;n<i-1;n++){var r=e[n],o=e[n+1],r=this.renderHandle(r,o);this.simulateRelatedView(r.el),this.handles.push(r),r.options.index=n}return this},renderHandle:function(t,e){var n=new this.options.handleClass({paper:this.paper,scale:this.options.scale,guard:t=>this.guard(t)});return n.render(),this.updateHandle(n,t,e),n.vel.appendTo(this.el),this.startHandleListening(n),n},update:function(){return this.render(),this},startHandleListening:function(t){this.listenTo(t,"change:start",this.onHandleChangeStart),this.listenTo(t,"changing",this.onHandleChanging),this.listenTo(t,"change:end",this.onHandleChangeEnd)},resetHandles:function(){var t=this.handles;if(this.handles=[],this.stopListening(),Array.isArray(t))for(var e=0,n=t.length;e<n;e++)t[e].remove()},shiftHandleIndexes:function(t){for(var e=this.handles,n=0,i=e.length;n<i;n++)e[n].options.index+=t},resetAnchor:function(t,e){var n=this.relatedView.model;e?n.prop([t,"anchor"],e,{rewrite:!0,ui:!0,tool:this.cid}):n.removeProp([t,"anchor"],{ui:!0,tool:this.cid})},snapHandle:function(t,e,n){var i=t.options.index,r=this.relatedView.model.vertices(),t=t.options.axis,o=r[i-2]||n.sourceAnchor,r=r[i+1]||n.targetAnchor,i=this.options.snapRadius;return Math.abs(e[t]-o[t])<i?e[t]=o[t]:Math.abs(e[t]-r[t])<i&&(e[t]=r[t]),e},onHandleChanging:function(t,e){var n=this.options,i=this.eventData(e),r=this.relatedView,o=r.paper,s=t.options.index-1,e=C(e),o=o.snapToGrid(e.clientX,e.clientY),a=this.snapHandle(t,o.clone(),i),l=t.options.axis,h=this.options.snapHandle?0:o[l]-a[l],u=r.model,c=ta(u.vertices()),d=this.options.anchor,f=("function"!=typeof d&&(d=null),t.options.index),p=[r.sourcePoint.clone(),...c,r.targetPoint.clone()];let g=0;0<=f-1&&(m=p[f-1],v=p[f],new P(m,v).vector().theta()%90!=0)&&(c.splice(f-1,0,i.originalVertices[f-1]),g++,this.shiftHandleIndexes(1));var m=c[s+g],v=c[1+s+g],y=(f+2<p.length&&(b=p[f+1],p=p[f+2],new P(b,p).vector().theta()%90!=0)&&(b=1===i.originalVertices.length,p=i.firstHandleShifted&&!b?1:0,y=1+g,c.splice(f+y,0,i.originalVertices[(b?0:f)-p])),r.sourceView),b=r.sourceBBox,f=!1,p=!1,b=(m?0==s?b.containsPoint(m)?(c.shift(),this.shiftHandleIndexes(-1),f=!0):(m[l]=a[l],p=!0):m[l]=a[l]:((m=r.sourceAnchor.toJSON())[l]=a[l],b.containsPoint(m)?(m[l]=a[l],f=!0):(c.unshift(m),this.shiftHandleIndexes(1),p=i.firstHandleShifted=!0)),d&&y&&(f&&((b=i.sourceAnchor.clone())[l]=a[l],f=d.call(r,b,y,r.sourceMagnet||y.el,"source",r),this.resetAnchor("source",f)),p)&&this.resetAnchor("source",i.sourceAnchorDef),r.targetView),y=r.targetBBox,f=!1,p=!1;if(v?s==c.length-2?y.containsPoint(v)?(c.pop(),f=!0):(v[l]=a[l],p=!0):v[l]=a[l]:((v=r.targetAnchor.toJSON())[l]=a[l],y.containsPoint(v)?f=!0:(c.push(v),p=!0)),d&&b&&(f&&((s=i.targetAnchor.clone())[l]=a[l],y=d.call(r,s,b,r.targetMagnet||b.el,"target",r),this.resetAnchor("target",y)),p)&&this.resetAnchor("target",i.targetAnchorDef),c.some(t=>!t))throw new Error("Segments: incompatible router in use");u.vertices(c,{ui:!0,tool:this.cid}),this.updateHandle(t,m,v,h),n.stopPropagation||r.notifyPointermove(e,o.x,o.y)},onHandleChangeStart:function(t,e){var{options:n,handles:i,relatedView:r}=this,{model:o,paper:s}=r,a=t.options.index;if(Array.isArray(i)){for(var l=0,h=i.length;l<h;l++)l!==a&&i[l].hide();this.focus(),this.eventData(e,{sourceAnchor:r.sourceAnchor.clone(),targetAnchor:r.targetAnchor.clone(),sourceAnchorDef:f(o.prop(["source","anchor"])),targetAnchorDef:f(o.prop(["target","anchor"])),originalVertices:ta(o.vertices()),firstHandleShifted:!1}),o.startBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||r.notifyPointerdown(...s.getPointerArgs(e))}},onHandleChangeEnd:function(t,e){var{options:n,relatedView:i}=this,{paper:r,model:o}=i,e=(n.redundancyRemoval&&i.removeRedundantLinearVertices({ui:!0,tool:this.cid}),C(e)),r=r.snapToGrid(e.clientX,e.clientY);this.render(),this.blur(),o.stopBatch("segment-move",{ui:!0,tool:this.cid}),n.stopPropagation||i.notifyPointerup(e,r.x,r.y),i.checkMouseleave(e)},updateHandle:function(t,e,n,i){var r=Math.abs(e.x-n.x)<this.precision,o=Math.abs(e.y-n.y)<this.precision;!r&&!o||(o=new P(e,n)).length()<this.options.segmentLengthThreshold?t.hide():((e=o.midpoint())[n=r?"x":"y"]+=i||0,r=o.vector().vectorAngle(new A(1,0)),t.position(e.x,e.y,r,this.relatedView),t.show(),t.options.axis=n)},onRemove:function(){this.resetHandles()}},{SegmentHandle:h}),l=ed.extend({tagName:"path",xAxisVector:new A(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=this.ratio,n=this.relatedView,i=n.getTangentAtRatio(e),i=i?(t=i.start,i.vector().vectorAngle(this.xAxisVector)||0):(t=n.getPointAtRatio(e),0);return t&&(n=R.createSVGMatrix().translate(t.x,t.y).rotate(i),e=this.options.scale,e&&(n=n.scale(e)),this.vel.transform(n,{absolute:!0})),this},onPointerDown:function(t){var e,n,i;this.guard(t)||(t.stopPropagation(),t.preventDefault(),n=(e=this.relatedView).paper,e.model.startBatch("arrowhead-move",{ui:!0,tool:this.cid}),e.startArrowheadMove(this.arrowheadType),i=t.data||(t.data={}),this.delegateDocumentEvents(null,i),n.undelegateEvents(),this.focus(),this.el.style.pointerEvents="none",e.notifyPointerdown(...n.getPointerArgs(t)))},onPointerMove:function(t){var t=C(t),e=this.paper.snapToGrid(t.clientX,t.clientY);this.relatedView.pointermove(t,e.x,e.y)},onPointerUp:function(t){this.undelegateDocumentEvents();var e=this.relatedView,n=e.paper,t=C(t),i=n.snapToGrid(t.clientX,t.clientY);e.pointerup(t,i.x,i.y),n.delegateEvents(),this.blur(),this.el.style.pointerEvents="",e.model.stopBatch("arrowhead-move",{ui:!0,tool:this.cid})}}),o=l.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"}}),s=l.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"}}),c=ed.extend({tagName:"g",type:null,children:[{tagName:"circle",selector:"anchor",attributes:{cursor:"pointer"}},{tagName:"rect",selector:"area",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{snap:function(t,e,n,i,r,o){return o=o.options.snapRadius,i="source"===i,(i=this.model.vertex(i?0:-1)||this.getEndAnchor(i?"target":"source"))&&(Math.abs(i.x-t.x)<o&&(t.x=i.x),Math.abs(i.y-t.y)<o)&&(t.y=i.y),t},anchor:id,scale:null,resetAnchor:!0,customAnchorAttributes:{"stroke-width":4,stroke:"#33334F",fill:"#FFFFFF",r:5},defaultAnchorAttributes:{"stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6},areaPadding:6,snapRadius:10,restrictArea:!0,redundancyRemoval:!0},onRender:function(){this.renderChildren(),this.toggleArea(!1),this.update()},update:function(){var t=this.type;return this.relatedView.getEndView(t)?(this.updateAnchor(),this.updateArea(),this.el.style.display=""):this.el.style.display="none",this},updateAnchor:function(){var t=this.childNodes;if(t){var s=t.anchor;if(s){let t=this.relatedView,e=this.type,n=t.getEndAnchor(e),i=this.options,r=t.model.prop([e,"anchor"]),o=`translate(${n.x},${n.y})`;i.scale&&(o+=` scale(${i.scale})`),s.setAttribute("transform",o);var a,l=r?i.customAnchorAttributes:i.defaultAnchorAttributes;for(a in l)s.setAttribute(a,l[a])}}},updateArea:function(){var t,e,n,i,r,o,s,a=this.childNodes;a&&(a=a.area)&&(n=this.relatedView,i=this.type,e=(t=n.getEndView(i)).model,n=n.getEndMagnet(i),i=this.options.areaPadding,isFinite(i)||(i=0),t.isNodeConnection(n)?(o=0,s=(r=t.getNodeBBox(n)).center()):(r=t.getNodeUnrotatedBBox(n),o=e.angle(),s=r.center(),o&&s.rotate(e.getBBox().center(),-o)),r.inflate(i),a.setAttribute("x",-r.width/2),a.setAttribute("y",-r.height/2),a.setAttribute("width",r.width),a.setAttribute("height",r.height),a.setAttribute("transform","translate("+s.x+","+s.y+") rotate("+o+")"))},toggleArea:function(t){var e=this.childNodes;e&&(e=e.area)&&(e.style.display=t?"":"none")},onPointerDown:function(t){this.guard(t)||(t.stopPropagation(),t.preventDefault(),this.paper.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleArea(this.options.restrictArea),this.relatedView.model.startBatch("anchor-move",{ui:!0,tool:this.cid}))},resetAnchor:function(t){var e=this.type,n=this.relatedView.model;t?n.prop([e,"anchor"],t,{rewrite:!0,ui:!0,tool:this.cid}):n.removeProp([e,"anchor"],{ui:!0,tool:this.cid})},onPointerMove:function(t){var e,n,i,r=this.relatedView,o=this.type,s=r.getEndView(o),a=s.model,l=r.getEndMagnet(o),t=C(t),t=this.paper.clientToLocalPoint(t.clientX,t.clientY),h=this.options.snap,h=("function"==typeof h&&(t=h.call(r,t,s,l,o,r,this),t=new A(t)),this.options.restrictArea&&(s.isNodeConnection(l)?(h=s.getClosestPoint(t))&&(t=h):(h=s.getNodeUnrotatedBBox(l),e=a.angle(),a=a.getBBox().center(),n=t.clone().rotate(a,e),h.containsPoint(n)||(t=h.pointNearestToPoint(n).rotate(a,-e)))),this.options.anchor);"function"==typeof h&&(i=h.call(r,t,s,l,o,r)),this.resetAnchor(i),this.update()},onPointerUp:function(t){var t=C(t),e=(this.paper.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleArea(!1),this.relatedView);this.options.redundancyRemoval&&e.removeRedundantLinearVertices({ui:!0,tool:this.cid}),e.checkMouseleave(t),e.model.stopBatch("anchor-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(){var t=this.options.resetAnchor;!1!==t&&(!0===t&&(t=null),this.resetAnchor(ta(t)),this.update())}}),u=c.extend({name:"source-anchor",type:"source"}),r=c.extend({name:"target-anchor",type:"target"});let rd=ed.extend({tagName:"g",children:[{tagName:"circle",selector:"handle",attributes:{cursor:"pointer","stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6}},{tagName:"rect",selector:"extras",attributes:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onPointerDown",touchstart:"onPointerDown",dblclick:"onPointerDblClick",dbltap:"onPointerDblClick"},documentEvents:{mousemove:"onPointerMove",touchmove:"onPointerMove",mouseup:"onPointerUp",touchend:"onPointerUp",touchcancel:"onPointerUp"},options:{handleAttributes:null,selector:"root",padding:6,scale:null},getPosition:function(){},setPosition:function(){},resetPosition:function(){},onRender:function(){this.renderChildren(),this.toggleExtras(!1),this.update()},update:function(){var{handle:t,extras:e}=this.childNodes;if(t)return this.updateHandle(t),e&&this.updateExtras(e),this;throw new Error("Control: markup selector `handle` is required")},updateHandle:function(t){var{relatedView:e,options:n}=this,i=e.model,e=this.getPosition(e,this),i=i.getAbsolutePointFromRelative(e),{handleAttributes:r,scale:e}=n;let o=`translate(${i.x},${i.y})`;if(e&&(o+=` scale(${e})`),t.setAttribute("transform",o),r)for(var s in r)t.setAttribute(s,r[s])},updateExtras:function(e){var{relatedView:n,options:i}=this,r=this.options.selector;if(r){r=n.findNode(r);if(!r)throw new Error("Control: invalid selector.");let t=i.padding;isFinite(t)||(t=0);var i=n.getNodeUnrotatedBBox(r),r=n.model,n=r.angle(),o=i.center();n&&o.rotate(r.getBBox().center(),-n),i.inflate(t),e.setAttribute("x",-i.width/2),e.setAttribute("y",-i.height/2),e.setAttribute("width",i.width),e.setAttribute("height",i.height),e.setAttribute("transform",`translate(${o.x},${o.y}) rotate(${n})`)}else this.toggleExtras(!1)},toggleExtras:function(t){var e=this.childNodes.extras;e&&(e.style.display=t?"":"none")},onPointerDown:function(t){var{relatedView:e,paper:n}=this;this.guard(t)||(t.stopPropagation(),t.preventDefault(),n.undelegateEvents(),this.delegateDocumentEvents(),this.focus(),this.toggleExtras(!0),e.model.startBatch("control-move",{ui:!0,tool:this.cid}))},onPointerMove:function(t){var{relatedView:e,paper:n}=this,i=e.model,{clientX:r,clientY:o}=C(t),n=n.clientToLocalPoint(r,o),r=i.getRelativePointFromAbsolute(n);this.setPosition(e,r,t),this.update()},onPointerUp:function(t){var{relatedView:e,paper:n}=this;n.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleExtras(!1),e.model.stopBatch("control-move",{ui:!0,tool:this.cid})},onPointerDblClick:function(t){var e=this.relatedView;this.resetPosition(e,t),this.update()}});Je=rd.extend({xAxisVector:new A(1,0),children(){var{buttonColor:t="#333",iconColor:e="#fff",outlineColor:n="#fff"}=this.options;return[{selector:"handle",tagName:"g",attributes:{cursor:"grab"},children:[{tagName:"circle",attributes:{r:10,fill:t,stroke:n}},{tagName:"path",attributes:{d:"M -5 0 A 5 5 0 1 1 0 5",fill:"transparent",stroke:e,strokeWidth:2,strokeLinecap:"round"}},{tagName:"path",attributes:{d:"M -3 5 L 0 2.5 0 7.5 Z",fill:e,stroke:e,strokeWidth:1,transform:"rotate(-5, -3, 5)"}}]}]},getPosition(t){var{offset:e=0}=this.options,{x:e=0,y:n=0}="number"==typeof e?{x:0,y:e}:e,i=this.getLabel(),i=this.getLabelPosition(i),r=t.getLabelCoordinates(i);let{angle:o=0,args:s={}}=i;s.keepGradient&&(i=t.getTangentAtRatio(t.getClosestPointRatio(r)))&&(o+=i.vector().vectorAngle(this.xAxisVector)||0);t=(new DOMMatrix).translate(r.x,r.y).rotate(o).translate(e,n);return new A(t.e,t.f)},computeVisibility(){return rd.prototype.computeVisibility.apply(this,arguments)&&!!this.getLabel()},setPosition(t,e){var n=t.model,i=this.getLabel();i&&(i=this.getLabelPosition(i),t=90-t.getLabelCoordinates(i).theta(e),i=this.getLabelIndex(),n.prop(["labels",i,"position","angle"],t))},resetPosition(t){var t=t.model,e=this.getLabelIndex();t.prop(["labels",e,"position","angle"],0)},getLabelIndex(){return this.options.labelIndex||0},getLabel(){return this.relatedView.model.label(this.getLabelIndex())||null},getLabelPosition(t){var e=this.relatedView,t=e._normalizeLabelPosition(t.position);return e._mergeLabelPositionProperty(t,e._getDefaultLabelPositionProperty())}}),h=ed.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(){var t=this.vel;t.transform(this.getCellMatrix(),{absolute:!0})},getCellMatrix(){return this.relatedView.model.isLink()?this.getLinkMatrix():this.getElementMatrix()},getElementMatrix(){var{relatedView:t,options:e}=this;let{x:n=0,y:i=0,offset:r={},useModelGeometry:o,rotate:s,scale:a}=e,l=nd(t,o);var e=t.model.angle(),{x:t=0,y:h=0}=(s||(l=l.bbox(e)),r);ll(n)?n=parseFloat(n)/100*l.width:Zl(n)&&(n=Number(Ql(n,l))),ll(i)?i=parseFloat(i)/100*l.height:Zl(i)&&(i=Number(Ql(i,l)));let u=R.createSVGMatrix().translate(l.x+l.width/2,l.y+l.height/2);return u=(u=s?u.rotate(e):u).translate(n+t-l.width/2,i+h-l.height/2),u=a?u.scale(a):u},getLinkMatrix(){var{relatedView:t,options:e}=this,{offset:e=0,distance:n=0,rotate:i,scale:r}=e,n="function"==typeof n?n.call(this,t,this):n;let o,s,a,l=(o=ll(n)?t.getTangentAtRatio(parseFloat(n)/100):t.getTangentAtLength(n),a=o?(s=o.start,o.vector().vectorAngle(new A(1,0))||0):(s=t.getConnection().start,0),R.createSVGMatrix().translate(s.x,s.y).rotate(a).translate(0,e));return i||(l=l.rotate(-a)),l=r?l.scale(r):l},onPointerDown:function(t){var e;this.guard(t)||(t.stopPropagation(),t.preventDefault(),"function"==typeof(e=this.options.action)&&e.call(this.relatedView,t,this.relatedView,this))}}),l=h.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})}}}),c=ed.extend({name:"boundary",tagName:"rect",options:{padding:10,useModelGeometry:!1},attributes:{fill:"none",stroke:"#33334F","stroke-width":.5,"stroke-dasharray":"5, 5","pointer-events":"none"},onRender:function(){this.update()},update:function(){var{relatedView:t,options:e,vel:n}=this,{useModelGeometry:i,rotate:r}=e,e=gl(e.padding);let o=nd(t,i).moveAndExpand({x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}),s=t.model,a,l;return s.isElement()&&(a=s.angle())&&(r?(l=s.getBBox().center(),n.rotate(a,l.x,l.y,{absolute:!0})):o=o.bbox(a)),n.attr(o.toJSON()),this}});let od=h.extend({name:"connect",documentEvents:{mousemove:"drag",touchmove:"drag",mouseup:"dragend",touchend:"dragend",touchcancel:"dragend"},children:[{tagName:"circle",selector:"button",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",selector:"icon",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2,"pointer-events":"none"}}],options:{distance:80,offset:0,magnet:t=>t.el,action:(t,e,n)=>n.dragstart(t)},getMagnetNode:function(){var{options:t,relatedView:e}=this,n=t.magnet;let i;switch(typeof n){case"function":i=n.call(this,e,this);break;case"string":i=e.findNode(n);break;default:i=n}if((i=i||e.el)instanceof SVGElement)return i;throw new Error("Connect: magnet must be an SVGElement")},dragstart:function(t){var{paper:e,relatedView:n}=this,t=C(t),{x:i,y:r}=e.clientToLocalPoint(t.clientX,t.clientY);n.dragLinkStart(t,this.getMagnetNode(),i,r),e.undelegateEvents(),this.delegateDocumentEvents(null,t.data),this.focus()},drag:function(t){var{paper:e,relatedView:n}=this,t=C(t),{x:e,y:i}=e.snapToGrid(t.clientX,t.clientY);n.dragLink(t,e,i)},dragend:function(t){var{paper:e,relatedView:n}=this,t=C(t),{x:i,y:r}=e.snapToGrid(t.clientX,t.clientY);n.dragLinkEnd(t,i,r),this.undelegateDocumentEvents(),e.delegateEvents(),this.blur(),n.checkMouseleave(t)}});var sd=od.extend({name:"hover-connect",defaultMarkup:[{tagName:"circle",attributes:{r:7,fill:"#333333",cursor:"pointer"}},{tagName:"path",attributes:{d:"M -4 -1 L 0 -1 L 0 -4 L 4 0 L 0 4 0 1 -4 1 z",fill:"#FFFFFF",stroke:"none","stroke-width":2}}],children(){var{options:t,defaultMarkup:e}=this;return[{tagName:"path",selector:"track",attributes:{fill:"none",stroke:"transparent","stroke-width":t.trackWidth||15,cursor:"pointer"}},{tagName:"g",selector:"button",attributes:{"pointer-events":"none",display:"none"},children:t.markup||e}]},events:Object.assign({mousemove:"onMousemove",mouseenter:"onMouseenter",mouseleave:"onMouseleave"},od.prototype.events),onRender:function(){this.renderChildren(),this.update()},trackPath:null,update(){var t=this.childNodes;this.trackPath=this.getTrackPath(),od.prototype.update.apply(this,arguments),t.track.setAttribute("d",this.trackPath.serialize())},position(){var{el:t,childNodes:e}=this;e.button.setAttribute("transform",R.matrixToTransformString(this.getButtonMatrix())),t.setAttribute("transform",R.matrixToTransformString(this.getTrackMatrix()))},getButtonMatrix(){var{options:t,trackPath:e}=this,{offset:t=0,distance:n=0,rotate:i,scale:r}=t;let o,s,a,l=(o=ll(n)?e.tangentAtRatio(parseFloat(n)/100):e.tangentAtLength(n),a=o?(s=o.start,o.vector().vectorAngle(new A(1,0))||0):(s=e.start,0),R.createSVGMatrix().translate(s.x,s.y).rotate(a).translate(0,t));return i||(l=l.rotate(-a)),l=r?l.scale(r):l},getTrackPath(){return this.relatedView.getConnection()},getTrackMatrix(){return R.createSVGMatrix()},getTrackRatioFromEvent(t){var{relatedView:e,trackPath:n}=this,e=e.paper.clientToLocalPoint(t.clientX,t.clientY),t=R.transformPoint(e,this.getTrackMatrix().inverse());return n.closestPointLength(t)},canShowButton(){return L.event.has(this.paper.el)},showButton(){this.childNodes.button.style.display="block"},hideButton(){this.childNodes.button.style.display=""},onMousemove(t){var e=this.trackPath;e&&(e=this.options,e.distance=this.getTrackRatioFromEvent(t),this.position())},onMouseenter(){this.canShowButton()&&this.showButton()},onMouseleave(){this.hideButton()}}),e={Vertices:e,Segments:Rh,TargetArrowhead:o,SourceArrowhead:s,SourceAnchor:u,TargetAnchor:r,RotateLabel:Je,Button:h,Remove:l,Boundary:c,Connect:od,HoverConnect:sd,Control:rd},Rh={HoverConnect:sd.extend({getTrackPath(){var{relatedView:t,options:e}=this;let{useModelGeometry:n,trackPath:i="M 0 0 H calc(w) V calc(h) H 0 Z"}=e;return Zl(i="function"==typeof i?i.call(this,t):i)&&(e=nd(t,n),i=Ql(i,e)),new V(R.normalizePathData(i))},getTrackMatrix(){var{relatedView:t,options:e}=this,{useModelGeometry:e,rotate:n}=e;let i=nd(t,e);e=t.model.angle();n||(i=i.bbox(e));let r=R.createSVGMatrix().translate(i.x+i.width/2,i.y+i.height/2);return r=(r=n?r.rotate(e):r).translate(-i.width/2,-i.height/2)}}),Button:h,Remove:l,Connect:od,Boundary:c,Control:rd},o=R,s={PortLabel:_h,Port:Eh};t.V=R,t.Vectorizer=o,t.anchors=i,t.config=Ua,t.connectionPoints=$e,t.connectionStrategies=Fu,t.connectors=su,t.dia=a,t.elementTools=Rh,t.env=Oh,t.format={},t.g=br,t.highlighters=n,t.layout=s,t.linkAnchors=Ic,t.linkTools=e,t.mvc=Ln,t.routers=Nc,t.setTheme=function(t,e){e=e||{},Xs(hu,"setTheme",t,e),uu.prototype.defaultTheme=t},t.shapes=sn,t.ui={},t.util=hn,t.version="4.1.2",Object.defineProperty(t,"__esModule",{value:!0})}),"undefined"!=typeof joint&&(g=joint.g,Vectorizer=V=joint.V);
|