@esri/solutions-components 5.0.0 → 5.0.1
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/cdn/{J6Z7OGPT.js → 224I72SO.js} +1 -1
- package/dist/cdn/{JV3YKSCY.js → 2333JKXT.js} +1 -1
- package/dist/cdn/{3QLYSIKK.js → 243LX5NA.js} +1 -1
- package/dist/cdn/{G3RPEESM.js → 2SD4IYX3.js} +1 -1
- package/dist/cdn/{Z5H7S4UV.js → 2XLDIKUR.js} +1 -1
- package/dist/cdn/{PTPT75U6.js → 3RZAPX3S.js} +1 -1
- package/dist/cdn/{6OSOUHQD.js → 4JMP7ZE6.js} +1 -1
- package/dist/cdn/{S6XTVW2E.js → 4YJT24E5.js} +1 -1
- package/dist/cdn/{IW3HH57K.js → 5MTMSAKC.js} +1 -1
- package/dist/cdn/{LYMOZHWK.js → 5SHA3PGC.js} +1 -1
- package/dist/cdn/{SXOJTCOY.js → 6NMWB5NC.js} +1 -1
- package/dist/cdn/{C4M2JGW3.js → 6UJALA2L.js} +1 -1
- package/dist/cdn/{JRDWWNST.js → 6VKEW33C.js} +1 -1
- package/dist/cdn/{ONIWIJZN.js → 76M3UWJF.js} +1 -1
- package/dist/cdn/{R6DDGHRE.js → 7GQ24AKO.js} +1 -1
- package/dist/cdn/7PY2VM2S.js +2 -0
- package/dist/cdn/{ULPRAGHR.js → 7PZQ2MP7.js} +1 -1
- package/dist/cdn/{ASS5QC73.js → ARXWEJFK.js} +1 -1
- package/dist/cdn/{7JX6B3W3.js → AV3KXTWF.js} +1 -1
- package/dist/cdn/{QNT2CGG3.js → BXXYI7NG.js} +1 -1
- package/dist/cdn/{DJRQRVE7.js → BZVRRVNB.js} +1 -1
- package/dist/cdn/{KUYFIQG5.js → C5LZGCHH.js} +1 -1
- package/dist/cdn/CI66IACC.js +2 -0
- package/dist/cdn/DD3JC2L3.js +4 -0
- package/dist/cdn/{RGCDDZZ7.js → E7UFN5JY.js} +1 -1
- package/dist/cdn/{AS3OMVJG.js → EMSOP52X.js} +1 -1
- package/dist/cdn/{L4UMQNXD.js → ESOI3UW5.js} +1 -1
- package/dist/cdn/FMFUEICN.js +2 -0
- package/dist/cdn/{V3SPTOG3.js → FNGWQOMU.js} +1 -1
- package/dist/cdn/{QNSZUCGN.js → G2T6OYTB.js} +1 -1
- package/dist/cdn/{E4LHQX7P.js → GU77W2GF.js} +1 -1
- package/dist/cdn/HHKKBJCY.js +2 -0
- package/dist/cdn/{K3TXWVO2.js → HK7YZNM4.js} +1 -1
- package/dist/cdn/{QNTMCZAS.js → HTLJCLHR.js} +1 -1
- package/dist/cdn/{MGOL3BOX.js → HVE26GKL.js} +1 -1
- package/dist/cdn/{PRSBDD25.js → IQQXCY6C.js} +1 -1
- package/dist/cdn/{EVYF4Q4A.js → IZU7KP25.js} +1 -1
- package/dist/cdn/{PKLCCM5C.js → JAOKRCFG.js} +1 -1
- package/dist/cdn/{AELONRA2.js → JBJJMSR3.js} +1 -1
- package/dist/cdn/{7XSKL7BM.js → JUINWMBC.js} +1 -1
- package/dist/cdn/{4GUAHP55.js → K5Z5A2RY.js} +1 -1
- package/dist/cdn/{Q36LSOV4.js → M5MCA232.js} +1 -1
- package/dist/cdn/{HUTJQTEN.js → MBVWXJW7.js} +1 -1
- package/dist/cdn/{EUQ4JO3K.js → NCTVUAXT.js} +1 -1
- package/dist/cdn/{GPHDOTEY.js → NHKAOTFM.js} +1 -1
- package/dist/cdn/{DBPLH4RV.js → NNOOCMHD.js} +1 -1
- package/dist/cdn/{74XBLQLQ.js → NU2NW3YW.js} +1 -1
- package/dist/cdn/{56MHO3UY.js → O7AZMIQX.js} +1 -1
- package/dist/cdn/{Z5GWY442.js → OIFBNDN7.js} +1 -1
- package/dist/cdn/{V7JWKNPI.js → OLLLVTHU.js} +1 -1
- package/dist/cdn/{GRJZORJP.js → P6NSLBDS.js} +1 -1
- package/dist/cdn/{RLTX5S5V.js → P77GI3QL.js} +1 -1
- package/dist/cdn/{NVYKJK26.js → PAKIDHHK.js} +1 -1
- package/dist/cdn/{ENW2DF2D.js → PCG2HRKC.js} +1 -1
- package/dist/cdn/{M2KUCUL3.js → PQ7PCKL4.js} +1 -1
- package/dist/cdn/PSXEKRGH.js +2 -0
- package/dist/cdn/{EJJFSS5C.js → QRUCDIZO.js} +1 -1
- package/dist/cdn/QXSUDN7A.js +21 -0
- package/dist/cdn/{C7UAPXZR.js → RA35CIMF.js} +1 -1
- package/dist/cdn/{NPPIBUUP.js → RUU2LTYJ.js} +1 -1
- package/dist/cdn/{ZJZBIHZ5.js → S4WGAHIV.js} +1 -1
- package/dist/cdn/{2CMRI2B3.js → S7XOHDIW.js} +1 -1
- package/dist/cdn/{V7FXM6DJ.js → SLXAZV5B.js} +1 -1
- package/dist/cdn/{EYFR4JQP.js → SNN6XXHG.js} +1 -1
- package/dist/cdn/SPBICIV2.js +2 -0
- package/dist/cdn/SS7F2SZ4.js +2 -0
- package/dist/cdn/{5S7OJL7F.js → SSL3U5CO.js} +1 -1
- package/dist/cdn/{GVGTMXTG.js → SU77ODY2.js} +1 -1
- package/dist/cdn/TAHIBODN.js +2 -0
- package/dist/cdn/TE7VJ4KH.js +2 -0
- package/dist/cdn/{YHW6JKYZ.js → TOLNZKKL.js} +1 -1
- package/dist/cdn/{5KV6KCRT.js → UAUP4JQ4.js} +1 -1
- package/dist/cdn/{PDNBP4EL.js → VCZPVG3A.js} +1 -1
- package/dist/cdn/{QEZPZGBW.js → VGC3RHQQ.js} +1 -1
- package/dist/cdn/VLIHU4DD.js +2 -0
- package/dist/cdn/{6A5SBI3R.js → VWDJZ7HA.js} +1 -1
- package/dist/cdn/{RSLHX62X.js → WCGF6MFJ.js} +1 -1
- package/dist/cdn/WGKOKVQY.js +2 -0
- package/dist/cdn/WNOPX4X3.js +2 -0
- package/dist/cdn/WPV4X3NK.js +2 -0
- package/dist/cdn/{QMRCHKSO.js → XY5MX7TV.js} +1 -1
- package/dist/cdn/{HA5W44KL.js → Y3XY5BXI.js} +1 -1
- package/dist/cdn/{C5YQOXHX.js → YCLEJLXQ.js} +1 -1
- package/dist/cdn/{T6AL47LF.js → ZIPMI556.js} +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/runtime.js +1 -1
- package/dist/components/public-notification/customElement.js +3 -3
- package/dist/components/solutions-all-panel/customElement.js +8 -8
- package/dist/components/solutions-all-shell/customElement.js +9 -9
- package/dist/components/solutions-deployed-shell/customElement.js +2 -2
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/solutions-components_commit.txt +4 -4
- package/package.json +3 -3
- package/dist/cdn/4SZGXI37.js +0 -2
- package/dist/cdn/52QNBNIL.js +0 -2
- package/dist/cdn/AHXBPG3X.js +0 -2
- package/dist/cdn/BF6WA5U4.js +0 -2
- package/dist/cdn/CBVAXYAC.js +0 -2
- package/dist/cdn/D6VGQMIK.js +0 -2
- package/dist/cdn/ETEJ4PIB.js +0 -2
- package/dist/cdn/GSRMKEUC.js +0 -2
- package/dist/cdn/H74UJR3L.js +0 -2
- package/dist/cdn/HATDZAP6.js +0 -2
- package/dist/cdn/JJUJVV7A.js +0 -2
- package/dist/cdn/LHCWS2RN.js +0 -4
- package/dist/cdn/PLHWBWIG.js +0 -2
- package/dist/cdn/U4QFXUX2.js +0 -33
- package/dist/cdn/WNQD3BKN.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import{a as un}from"./ULPRAGHR.js";import"./RSLHX62X.js";import{a as ln}from"./HA5W44KL.js";import"./36I27Q5R.js";import"./GDPFKW75.js";import{b as hn}from"./2CMRI2B3.js";import{F as ms,G as ps,H as an,h as on,i as rn}from"./46DQNAMV.js";import"./OR4HXHSY.js";(function(){let K=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};K.requestAnimationFrame===void 0&&(K.setImmediate===void 0?K.requestAnimationFrame=x=>K.setTimeout(x,0):K.requestAnimationFrame=K.setImmediate);class m{static hr=K.navigator!==void 0&&K.navigator.platform!==void 0&&K.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static SP(t,e,i){let s=-1;return function(){let n=this,o=arguments;s!==-1&&m.wc(s),s=m.un(()=>{s=-1,i||t.apply(n,o)},e),i&&!s&&t.apply(n,o)}}static un(t,e){return K.setTimeout(t,e)}static wc(t){K.clearTimeout(t)}static Ni(t){return K.document.createElement(t)}static o(t){throw new Error(t)}static L(t,e){let i="The object is frozen, so its properties cannot be set: "+t.toString();e!==void 0&&(i+=" to value: "+e),m.o(i)}static se(t,e,i,s){}static s(t,e,i,s){}static NU(t,e,i){}static xc(t,e,i){if(t===null||typeof t!="object"){let s=m.LL(e);i!==void 0&&(s+="."+i),m.si(t,"object",s)}}static S(t,e,i){m.s(t,"function",e,i)}static CU(t,e,i){}static si(t,e,i,s){}static J(t,e,i,s){let n=m.LL(i);s!==void 0&&(n+="."+s),m.o(n+" is not in the range "+e+": "+t)}static Xi(t){}static cr(t,e){}static ne(t){K.console&&K.console.log(t)}static $(t){return t!==null&&typeof t=="object"}static it(t){return typeof t=="function"}static MP=[];static st(){let t=m.MP.pop();return t===void 0?[]:t}static Z(t){t.length=0,m.MP.push(t)}static LU=Object.freeze([]);static LL(t){return t===null?"*":typeof t=="string"?t:m.it(t)?t.name:""}static Gn(t){return m.it(t)?t.className?t.className:t.name:m.$(t)&&t.constructor?m.Gn(t.constructor):typeof t}static $a(t,e){return e==null||e===""?null:m.$(t)&&e in t||t[e]?t[e]:null}static toString(t){let e=t;return m.$(t)&&(t.text?e=t.text:t.name?e=t.name:t.key!==void 0?e=t.key:t.id!==void 0?e=t.id:t.constructor===Object&&(t.Text?e=t.Text:t.Name?e=t.Name:t.Key!==void 0?e=t.Key:t.Id!==void 0?e=t.Id:t.ID!==void 0&&(e=t.ID))),e===void 0?"undefined":e===null?"null":e.toString()}static Yw(t,e){if(t.hasOwnProperty(e))return!0;let i=Object.getPrototypeOf(t);for(;i&&i!==Function;){if(i.hasOwnProperty(e))return!0;let s=i.AU;if(s&&s[e])return!0;i=Object.getPrototypeOf(i)}return!1}static zF(t){let e=[],i=0;for(i=0;i<256;i++)e[i]=i;let s=0,n=0;for(i=0;i<256;i++)s=(s+e[i]+119)%256,n=e[i],e[i]=e[s],e[s]=n;i=0,s=0;let o="";for(let r=0;r<t.length;r++)i=(i+1)%256,s=(s+e[i])%256,n=e[i],e[i]=e[s],e[s]=n,o+=String.fromCharCode(t.charCodeAt(r)^e[(e[i]+e[s])%256]);return o}static XF(t){let e="0123456789abcdef",i=[];for(let r=0;r<256;r++)i[e.charAt(r>>4)+e.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);let s=[],n=0;for(let r=0;r<t.length;r+=2)s[n++]=i[t.substring(r,r+2)];let o=s.join("");return o===""?"0":o}static We(t){return m.zF(m.XF(t))}static color1="@COLOR1";static color2="@COLOR2";static Kw="32ab5ff3b26f42dc0ed90f21422913b5"}m.vfo="29e647fdb5";class rt{NP;constructor(){this.NP=[]}toString(){return this.NP.join("")}add(t){t!==""&&this.NP.push(t)}}class bt{}class Pt{g;constructor(){this.g=[]}[Symbol.iterator](){return this.g.values()}key;value;get iterator(){return this}reset(){}next(){return!1}hasNext(){return!1}first(){return null}any(){return!1}all(){return!0}each(){return this}map(t){return this}filter(){return this}get count(){return 0}Ml(){}toString(){return"EmptyIterator"}static instance=new Pt}class dt{constructor(t){this.key=-1,this.value=t}[Symbol.iterator](){return[this.value].values()}key;value;get iterator(){return this}reset(){this.key=-1}next(){return this.key===-1?(this.key=0,!0):!1}hasNext(){return this.next()}first(){return this.key=0,this.value}any(t){return this.key=-1,t(this.value)}all(t){return this.key=-1,t(this.value)}each(t){return this.key=-1,t(this.value),this}map(t){return new dt(t(this.value))}filter(t){return t(this.value)?new dt(this.value):Pt.instance}get count(){return 1}Ml(){this.value=null}toString(){return"SingletonIterator("+this.value+")"}}class gt{qt;zs;Gt;Tt;constructor(t){this.qt=t,this.zs=null,t.fr=null,this.Gt=t.rt,this.Tt=-1}[Symbol.iterator](){return this.zs===null?this.qt.r.values():this.qt.r.filter(this.zs).values()}key;value;get iterator(){return this}get predicate(){return this.zs}set predicate(t){this.zs=t}reset(){let t=this.qt;t.fr=null,this.Gt=t.rt,this.Tt=-1}next(){let t=this.qt;if(t.rt!==this.Gt){if(this.key<0)return!1;m.Xi(t)}let e=t.r,i=e.length,s=++this.Tt,n=this.zs;if(n!==null)for(;s<i;){let o=e[s];if(n(o))return this.Tt=s,this.key=s,this.value=o,!0;s++}else{if(s<i)return this.key=s,this.value=e[s],!0;this.Ml()}return!1}hasNext(){return this.next()}first(){let t=this.qt;this.Gt=t.rt,this.Tt=0;let e=t.r,i=e.length,s=this.zs;if(s!==null){let n=0;for(;n<i;){let o=e[n];if(s(o))return this.Tt=n,this.key=n,this.value=o,o;n++}return null}else if(i>0){let n=e[0];return this.key=0,this.value=n,n}else return null}any(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.zs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(t(a))return!0;e.rt!==i&&m.Xi(e)}}return!1}all(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.zs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(!t(a))return!1;e.rt!==i&&m.Xi(e)}}return!0}each(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.zs;for(let r=0;r<n;r++){let a=s[r];o!==null&&!o(a)||(t(a),e.rt!==i&&m.Xi(e))}return this}map(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.zs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(s.push(t(l)),e.rt!==i&&m.Xi(e))}let a=new q;return a.r=s,a.Gi(),a.iterator}filter(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.zs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(t(l)&&s.push(l),e.rt!==i&&m.Xi(e))}let a=new q;return a.r=s,a.Gi(),a.iterator}get count(){let t=this.zs;if(t!==null){let e=0,i=this.qt.r,s=i.length;for(let n=0;n<s;n++)t(i[n])&&e++;return e}else return this.qt.r.length}Ml(){this.key=-1,this.value=null,this.Gt=-1,this.zs=null,this.qt.fr=this}toString(){return"ListIterator@"+this.Tt+"/"+this.qt.count}}class kt{qt;Gt;Tt;constructor(t){this.qt=t,t.ur=null,this.Gt=t.rt,this.Tt=t.r.length}[Symbol.iterator](){return this.qt.r.reverse().values()}key;value;get iterator(){return this}reset(){let t=this.qt;t.ur=null,this.Gt=t.rt,this.Tt=t.r.length}next(){let t=this.qt;if(t.rt!==this.Gt){if(this.key<0)return!1;m.Xi(t)}let e=--this.Tt;return e>=0?(this.key=e,this.value=t.r[e],!0):(this.Ml(),!1)}hasNext(){return this.next()}first(){let t=this.qt;this.Gt=t.rt;let e=t.r,i=e.length-1;if(this.Tt=i,i>=0){let s=e[i];return this.key=i,this.value=s,s}else return null}any(t){let e=this.qt;e.ur=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(t(r))return!0;e.rt!==i&&m.Xi(e)}return!1}all(t){let e=this.qt;e.ur=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(!t(r))return!1;e.rt!==i&&m.Xi(e)}return!0}each(t){let e=this.qt;e.ur=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];t(r),e.rt!==i&&m.Xi(e)}return this}map(t){let e=this.qt;e.ur=null;let i=e.rt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];s.push(t(h)),e.rt!==i&&m.Xi(e)}let r=new q;return r.r=s,r.Gi(),r.iterator}filter(t){let e=this.qt;e.ur=null;let i=e.rt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];t(h)&&s.push(h),e.rt!==i&&m.Xi(e)}let r=new q;return r.r=s,r.Gi(),r.iterator}get count(){return this.qt.r.length}Ml(){this.key=-1,this.value=null,this.Gt=-1,this.qt.ur=this}toString(){return"ListIteratorBackwards("+this.Tt+"/"+this.qt.count+")"}}class q{u;r;rt;fr;ur;constructor(t){V.Je(this),this.u=!1,this.r=[],this.rt=0,this.fr=null,this.ur=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Gi(){let t=this.rt;t++,t>999999999&&(t=0),this.rt=t}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"List()#"+V.xs(this)}add(t){return this.u&&m.L(this,t),this.r.push(t),this.Gi(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.u&&m.L(this);let e=this.r;if(t.first){let i=t.iterator;for(;i.next();)e.push(i.value)}else for(let i of t)e.push(i);return this.Gi(),this}clear(){this.u&&m.L(this),this.r.length=0,this.Gi()}contains(t){return this.has(t)}has(t){return t===null?!1:this.r.indexOf(t)!==-1}indexOf(t){return t===null?-1:this.r.indexOf(t)}elt(t){let e=this.r;return(t<0||t>=e.length)&&m.J(t,"0 <= i < length",q,"elt:i"),e[t]}get(t){return this.elt(t)}setElt(t,e){let i=this.r;(t<0||t>=i.length)&&m.J(t,"0 <= i < length",q,"setElt:i"),this.u&&m.L(this,t),i[t]=e}set(t,e){this.setElt(t,e)}first(){let t=this.r;return t.length===0?null:t[0]}last(){let t=this.r,e=t.length;return e>0?t[e-1]:null}pop(){this.u&&m.L(this);let t=this.r;if(t.length>0){let e=t.pop();return e===void 0?null:e}return null}any(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++){if(t(e[n]))return!0;this.rt!==i&&m.Xi(this)}return!1}all(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++){if(!t(e[n]))return!1;this.rt!==i&&m.Xi(this)}return!0}each(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++)t(e[n]),this.rt!==i&&m.Xi(this);return this}map(t){let e=new q,i=[],s=this.r,n=this.rt,o=s.length;for(let r=0;r<o;r++)i.push(t(s[r])),this.rt!==n&&m.Xi(this);return e.r=i,e.Gi(),e}filter(t){let e=new q,i=[],s=this.r,n=this.rt,o=s.length;for(let r=0;r<o;r++){let a=s[r];t(a)&&i.push(a),this.rt!==n&&m.Xi(this)}return e.r=i,e.Gi(),e}insertAt(t,e){t<0&&m.J(t,">= 0",q,"insertAt:i"),this.u&&m.L(this,t);let i=this.r;t>=i.length?i.push(e):i.splice(t,0,e),this.Gi()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.u&&m.L(this,t);let e=this.r,i=e.indexOf(t);return i===-1?!1:(i===e.length-1?e.pop():e.splice(i,1),this.Gi(),!0)}removeAt(t){let e=this.r;(t<0||t>=e.length)&&m.J(t,"0 <= i < length",q,"removeAt:i"),this.u&&m.L(this,t),t===e.length-1?e.pop():e.splice(t,1),this.Gi()}removeRange(t,e){let i=this.r,s=i.length;if(t<0)t=0;else if(t>=s)return this;if(e<0)return this;if(e>=s&&(e=s-1),t>e)return this;this.u&&m.L(this);let n=t,o=e+1;for(;o<s;)i[n++]=i[o++];return i.length=s-(e-t+1),this.Gi(),this}copy(){let t=new q,e=this.r;return e.length>0&&(t.r=Array.prototype.slice.call(e)),t}toArray(){let t=this.r,e=this.count,i=new Array(e);for(let s=0;s<e;s++)i[s]=t[s];return i}get AL(){return this.r}toSet(){let t=new V,e=this.r,i=this.count;for(let s=0;s<i;s++)t.add(e[s]);return t}sort(t){return this.u&&m.L(this),this.r.sort(t),this.Gi(),this}sortRange(t,e,i){let s=this.r,n=s.length;e===void 0&&(e=0),i===void 0&&(i=n),this.u&&m.L(this);let o=i-e;if(o<=1)return this;if((e<0||e>=n-1)&&m.J(e,"0 <= from < length",q,"sortRange:from"),o===2){let r=s[e],a=s[e+1];return t(r,a)>0&&(s[e]=a,s[e+1]=r,this.Gi()),this}if(e===0)if(i>=n)s.sort(t);else{let r=s.slice(0,i);r.sort(t);for(let a=0;a<i;a++)s[a]=r[a]}else if(i>=n){let r=s.slice(e);r.sort(t);for(let a=e;a<n;a++)s[a]=r[a-e]}else{let r=s.slice(e,i);r.sort(t);for(let a=e;a<i;a++)s[a]=r[a-e]}return this.Gi(),this}reverse(){return this.u&&m.L(this),this.r.reverse(),this.Gi(),this}get count(){return this.r.length}get size(){return this.r.length}get length(){return this.r.length}get iterator(){if(this.r.length<=0)return Pt.instance;let t=this.fr;return t!==null?(t.reset(),t):new gt(this)}get iteratorBackwards(){if(this.r.length<=0)return Pt.instance;let t=this.ur;return t!==null?(t.reset(),t):new kt(this)}}class Zt{Lo;oe;constructor(t){this.Lo=t,this.oe=t.g.values()}[Symbol.iterator](){return this.Lo.g.values()}key;value;get iterator(){return this}reset(){let t=this.Lo;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Lo.g.size===0?null:(this.oe=this.Lo.g.values(),this.oe.next().value)}any(t){return this.Lo.any(t)}all(t){return this.Lo.all(t)}each(t){return this.Lo.each(t),this}map(t){let e=new q;return this.Lo.g.forEach(i=>e.add(t(i))),e.iterator}filter(t){let e=new q;return this.Lo.g.forEach(i=>{t(i)&&e.add(i)}),e.iterator}get count(){return this.Lo.count}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"SetIterator"}}class V{u;g;constructor(t){this.u=!1,this.g=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.values()}values(){return this.g.values()}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"Set()#"+V.xs(this)}add(t){return t===null?this:(this.g.add(t),this)}addAll(t){if(t===null)return this;if(this.u&&m.L(this),t.first){let e=t.iterator;for(;e.next();)this.g.add(e.value)}else for(let e of t)this.g.add(e);return this}has(t){return this.g.has(t)}contains(t){return this.has(t)}containsAll(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(!this.has(e.value))return!1}else for(let e of t)if(!this.has(e))return!1;return!0}containsAny(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(this.has(e.value))return!0}else for(let e of t)if(this.has(e))return!0;return!1}first(){return this.g.size===0?null:this.g.values().next().value}any(t){for(let e of this.g)if(t(e))return!0;return!1}all(t){for(let e of this.g)if(!t(e))return!1;return!0}each(t){for(let e of this.g)t(e);return this}map(t){let e=new V;for(let i of this.g)e.add(t(i));return e}filter(t){let e=new V;for(let i of this.g)t(i)&&e.add(i);return e}delete(t){return this.u&&m.L(this),this.g.delete(t)}remove(t){return this.delete(t)}removeAll(t){if(t===null)return this;if(this.u&&m.L(this),t.first){let e=t.iterator;for(;e.next();)this.delete(e.value)}else for(let e of t)this.delete(e);return this}retainAll(t){if(t===null)return this;if(this.count===0)return this;this.u&&m.L(this);let e=new V;e.addAll(t);let i=[];if(t.first){let s=t.iterator;for(;s.next();){let n=s.value;e.has(n)||i.push(n)}}else for(let s of t)e.has(s)||i.push(s);return this.removeAll(i),this}clear(){this.u&&m.L(this),this.g.clear()}copy(){let t=new V;return this.g.forEach(e=>t.add(e)),t}toArray(){return Array.from(this.g)}toList(){let t=new q;return this.g.forEach(e=>t.add(e)),t}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?Pt.instance:new Zt(this)}entries(){return this.g.entries()}keys(){return this.g.keys()}forEach(t,e){return this.g.forEach(t,e)}static Hw=1;static Je(t){t.__gohashid=V.Hw++}static xs(t){return t.__gohashid}}class We{j;oe;constructor(t){this.j=t,this.oe=t.g.keys()}[Symbol.iterator](){return this.j.g.keys()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.keys()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.j.g.size===0?null:(this.oe=this.j.g.keys(),this.oe.next().value)}any(t){for(let e of this.j.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.j.g)t(e[0]);return this}map(t){let e=this.j,i=new q;for(let s of e.g)i.add(t(s[0]));return i.iterator}filter(t){let e=this.j,i=new q;for(let s of e.g){let n=s[0];t(n)&&i.add(n)}return i.iterator}get count(){return this.j.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapKeySetIterator"}}class Oi extends V{j;constructor(t){super(),V.Je(this),this.u=!0,this.j=t}[Symbol.iterator](){return this.g.keys()}values(){return this.g.keys()}k(){return this}ce(){return this}toString(){return"MapKeySet("+this.j.toString()+")"}add(t){m.o("This Set is read-only: "+this.toString())}has(t){return this.j.has(t)}contains(t){return this.has(t)}delete(t){m.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){m.o("This Set is read-only: "+this.toString())}first(){return this.j.g.size===0?null:this.j.g.keys().next().value}any(t){for(let e of this.j.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.j.g)t(e[0]);return this}map(t){let e=new V;for(let i of this.j.g)e.add(t(i[0]));return e}filter(t){let e=new V;for(let i of this.j.g){let s=i[0];t(s)&&e.add(s)}return e}copy(){return new Oi(this.j)}toSet(){let t=new V,e=this.j.g;for(let i of e)t.add(i[0]);return t}toArray(){let t=this.j.g,e=new Array(t.size),i=0;for(let s of t)e[i]=s[0],i++;return e}toList(){let t=new q,e=this.j.g;for(let i of e)t.add(i[0]);return t}get count(){return this.j.size}get size(){return this.j.size}get iterator(){return this.j.size<=0?Pt.instance:new We(this.j)}}class Tn{j;oe;constructor(t){this.j=t,this.oe=t.g.values()}[Symbol.iterator](){return this.j.g.values()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.j.g.size===0?null:(this.oe=this.j.g.values(),this.oe.next().value)}any(t){for(let e of this.j.g)if(t(e[1]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[1]))return!1;return!0}each(t){for(let e of this.j.g)t(e[1]);return this}map(t){let e=this.j,i=new q;for(let s of e.g)i.add(t(s[1]));return i.iterator}filter(t){let e=this.j,i=new q;for(let s of e.g){let n=s[1];t(n)&&i.add(n)}return i.iterator}get count(){return this.j.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapValueSetIterator"}}class pe{constructor(t,e){this.key=t,this.value=e}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class Ln{j;oe;constructor(t){this.j=t,this.oe=t.g.entries()}[Symbol.iterator](){return this.j.g.entries()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.entries()}next(){let t=this.oe.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.j.g.size===0)return null;this.oe=this.j.g.entries();let t=this.oe.next().value;return this.key=t[0],this.value=t[1],new pe(t[0],t[1])}any(t){return this.j.any(t)}all(t){return this.j.all(t)}each(t){return this.j.each(t),this}map(t){let e=new q,i=null;return this.j.g.forEach((s,n)=>{i===null?i=new pe(n,s):(i.key=n,i.value=s),e.add(t(i))}),e.iterator}filter(t){let e=new q,i=null;return this.j.g.forEach((s,n)=>{i===null?i=new pe(n,s):(i.key=n,i.value=s),t(i)&&(e.add(i),i=null)}),e.iterator}get count(){return this.j.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapIterator"}}class Mt{u;g;constructor(t){V.Je(this),this.u=!1,this.g=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.entries()}entries(){return this.g.entries()}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"Map()#"+V.xs(this)}set(t,e){return this.u&&m.L(this,t),this.g.set(t,e),this}add(t,e){return this.set(t,e)}addAll(t){if(t===null)return this;if(this.u&&m.L(this),t instanceof Mt){let e=t.iterator;for(;e.next();)this.g.set(e.key,e.value)}else if(t.first){let e=t.iterator;for(;e.next();){let i=e.value;this.g.set(i.key,i.value)}}else for(let e of t){let i=e;Array.isArray(i)?this.g.set(i[0],i[1]):this.g.set(i.key,i.value)}return this}first(){if(this.g.size===0)return null;let t=this.g.entries().next().value;return t?new pe(t[0],t[1]):null}any(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new pe(i,s):(e.key=i,e.value=s),t(e))return!0;return!1}all(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new pe(i,s):(e.key=i,e.value=s),!t(e))return!1;return!0}each(t){let e=null;for(let[i,s]of this.g)e===null?e=new pe(i,s):(e.key=i,e.value=s),t(e);return this}map(t){let e=new Mt,i=null;for(let[s,n]of this.g)i===null?i=new pe(s,n):(i.key=s,i.value=n),e.set(s,t(i));return e}filter(t){let e=new Mt,i=null;for(let[s,n]of this.g)i===null?i=new pe(s,n):(i.key=s,i.value=n),t(i)&&e.set(s,n);return e}has(t){return this.g.has(t)}contains(t){return this.has(t)}get(t){let e=this.g.get(t);return e===void 0?null:e}getValue(t){return this.get(t)}delete(t){return t===null?!1:(this.u&&m.L(this,t),this.g.delete(t))}remove(t){return this.delete(t)}clear(){this.u&&m.L(this),this.g.clear()}copy(){let t=new Mt;return t.g=new Map(this.g),t}toArray(){let t=this.g,e=new Array(t.size),i=0;for(let s of t)e[i]=new pe(s[0],s[1]),i++;return e}toKeySet(){return new Oi(this)}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?Pt.instance:new Ln(this)}get iteratorKeys(){return this.count<=0?Pt.instance:new We(this)}keys(){return this.g.keys()}get iteratorValues(){return this.count<=0?Pt.instance:new Tn(this)}values(){return this.g.values()}forEach(t,e){return this.g.forEach(t,e)}}class P{px;py;u;constructor(t,e){t===void 0?(this.px=0,this.py=0):typeof t=="number"&&typeof e=="number"?(this.px=t,this.py=e):m.o("Invalid arguments to Point constructor: "+t+", "+e),this.u=!1}h(t){return this.px=t.px,this.py=t.py,this}e(t,e){return this.px=t,this.py=e,this}setTo(t,e){return this.px=t,this.py=e,this}set(t){return this.px=t.px,this.py=t.py,this}copy(){let t=new P;return t.px=this.px,t.py=this.py,t}kt(){return this.u=!0,Object.freeze(this),this}N(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}qw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new P(s,o)}else return new P}static stringify(t){return t.x.toString()+" "+t.y.toString()}static stringifyFixed(t){return m.s(t,"number",P,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof P?this.px===t.x&&this.py===t.y:!1}equalTo(t,e){return this.px===t&&this.py===e}equalsApprox(t){return C.c(this.px,t.x)&&C.c(this.py,t.y)}add(t){return this.px+=t.x,this.py+=t.y,this}subtract(t){return this.px-=t.x,this.py-=t.y,this}offset(t,e){return this.px+=t,this.py+=e,this}rotate(t){if(t===0)return this;let e=this.px,i=this.py;if(e===0&&i===0)return this;let s=0,n=0;if(t=C.Ee(t),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.px=s*e-n*i,this.py=n*e+s*i,this}scale(t,e){return this.px*=t,this.py*=e,this}distanceSquaredPoint(t){let e=t.x-this.px,i=t.y-this.py;return e*e+i*i}distanceSquared(t,e){let i=t-this.px,s=e-this.py;return i*i+s*s}normalize(){let t=this.px,e=this.py,i=Math.sqrt(t*t+e*e);return i>0&&(this.px=t/i,this.py=e/i),this}directionPoint(t){return this.TL(t.x-this.px,t.y-this.py)}direction(t,e){return this.TL(t-this.px,e-this.py)}TL(t,e){if(t===0)return e>0?90:e<0?270:0;if(e===0)return t>0?0:180;{if(isNaN(t)||isNaN(e))return 0;let i=Math.atan(Math.abs(e/t))*180/Math.PI;return t<0?e<0?i+=180:i=180-i:e<0&&(i=360-i),i}}static compareWithLineSegment(t,e,i,s,n,o){return C.ku(t,e,i,s,n,o)}compareWithLineSegmentPoint(t,e){return C.ku(t.x,t.y,e.x,e.y,this.x,this.y)}static intersectingLineSegments(t,e,i,s,n,o,r,a){return C.Pu(t,e,i,s,n,o,r,a)}projectOntoLineSegment(t,e,i,s){return C.Nl(t,e,i,s,this.px,this.py,this),this}projectOntoLineSegmentPoint(t,e){return C.Nl(t.x,t.y,e.x,e.y,this.px,this.py,this),this}snapToGrid(t,e,i,s){return C._g(this.px,this.py,t,e,i,s,this),this}snapToGridPoint(t,e){return C._g(this.px,this.py,t.x,t.y,e.width,e.height,this),this}setRectSpot(t,e){return this.px=t.x+e.x*t.width+e.offsetX,this.py=t.y+e.y*t.height+e.offsetY,this}setSpot(t,e,i,s,n){return this.px=t+n.x*i+n.offsetX,this.py=e+n.y*s+n.offsetY,this}v(t){return t.gt(this),this}Yi(t){return t.Ci(this),this}static distanceLineSegmentSquared(t,e,i,s,n,o){let r=n-i,a=o-s,h=r*r+a*a,l=i-t,u=s-e,c=-l*r-u*a;if(c<=0||c>=h)return r=n-t,a=o-e,Math.min(l*l+u*u,r*r+a*a);{let d=r*u-a*l;return d*d/h}}static distanceSquared(t,e,i,s){let n=i-t,o=s-e;return n*n+o*o}static direction(t,e,i,s){let n=i-t,o=s-e;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.px}set x(t){this.px=t}get y(){return this.py}set y(t){this.py=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static dn=new P(0,0).kt();static DL=new P(-1/0,-1/0).kt();static vL=new P(1/0,1/0).kt();static FL=new P(6,6).kt();static gn=new P(NaN,NaN).kt();static jw=[];static l(){let t=P.jw.pop();return t===void 0?new P:t}static bs(t){let e=P.jw.pop();return e===void 0?t.copy():e.h(t)}static z(t,e){let i=P.jw.pop();return i===void 0?new P(t,e):(i.x=t,i.y=e,i)}static i(t){P.jw.push(t)}}class st{sw;sh;u;constructor(t,e){t===void 0?(this.sw=0,this.sh=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof e=="number"&&(e>=0||isNaN(e))?(this.sw=t,this.sh=e):m.o("Invalid arguments to Size constructor: "+t+", "+e),this.u=!1}h(t){return this.sw=t.sw,this.sh=t.sh,this}e(t,e){return this.sw=t,this.sh=e,this}setTo(t,e){return this.sw=t,this.sh=e,this}set(t){return this.sw=t.sw,this.sh=t.sh,this}copy(){let t=new st;return t.sw=this.sw,t.sh=this.sh,t}kt(){return this.u=!0,Object.freeze(this),this}N(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}qw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new st(s,o)}else return new st}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return m.s(t,"number",st,"stringifyFixed:digits"),e=>e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof st?this.sw===t.width&&this.sh===t.height:!1}equalTo(t,e){return this.sw===t&&this.sh===e}equalsApprox(t){return C.c(this.sw,t.width)&&C.c(this.sh,t.height)}inflate(t,e){let i=this.width+t;this.sw=i>=0?i:0;let s=this.height+e;return this.sh=s>=0?s:0,this}get width(){return this.sw}set width(t){t<0&&m.J(t,">= 0",st,"width"),this.sw=t}get height(){return this.sh}set height(t){t<0&&m.J(t,">= 0",st,"height"),this.sh=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static bc=new st(0,0).kt();static CP=new st(1,1).kt();static RL=new st(6,6).kt();static Su=new st(8,8).kt();static OL=new st(10,10).kt();static LP=new st(1/0,1/0).kt();static Ww=new st(NaN,NaN).kt();static IL=[];static l(){let t=st.IL.pop();return t===void 0?new st:t}static i(t){st.IL.push(t)}}class I{rx;ry;rw;rh;u;constructor(t,e,i,s){if(t===void 0)this.rx=0,this.ry=0,this.rw=0,this.rh=0;else if(typeof t=="number"&&typeof e=="number"&&typeof i=="number"&&(i>=0||isNaN(i))&&typeof s=="number"&&(s>=0||isNaN(s)))this.rx=t,this.ry=e,this.rw=i,this.rh=s;else if(t instanceof P){let n=t.x,o=t.y;if(e instanceof P){let r=e.x,a=e.y;this.rx=Math.min(n,r),this.ry=Math.min(o,a),this.rw=Math.abs(n-r),this.rh=Math.abs(o-a)}else e instanceof st?(this.rx=n,this.ry=o,this.rw=e.width,this.rh=e.height):m.o("Incorrect second argument supplied to Rect constructor "+e)}else m.o("Invalid arguments to Rect constructor: "+t+", "+e+", "+i+", "+s);this.u=!1}h(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}e(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}Yn(t,e){return this.rw=t,this.rh=e,this}setTo(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}set(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}setPoint(t){return this.rx=t.x,this.ry=t.y,this}setSize(t){return this.rw=t.width,this.rh=t.height,this}copy(){let t=new I;return t.rx=this.rx,t.ry=this.ry,t.rw=this.rw,t.rh=this.rh,t}kt(){return this.u=!0,Object.freeze(this),this}N(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}ce(){return this.u&&(Object.isFrozen(this)&&m.o("cannot thaw constant: "+this),this.u=!1),this}qw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),new I(s,o,r,a)}else return new I}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return m.s(t,"number",I,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof I?this.rx===t.x&&this.ry===t.y&&this.rw===t.width&&this.rh===t.height:!1}equalTo(t,e,i,s){return this.rx===t&&this.ry===e&&this.rw===i&&this.rh===s}equalsApprox(t){return C.c(this.rx,t.x)&&C.c(this.ry,t.y)&&C.c(this.rw,t.width)&&C.c(this.rh,t.height)}equalsApproxTo(t,e,i,s){return C.c(this.rx,t)&&C.c(this.ry,e)&&C.c(this.rw,i)&&C.c(this.rh,s)}equalsApproxClose(t){return C.X(this.rx,t.x)&&C.X(this.ry,t.y)&&C.X(this.rw,t.width)&&C.X(this.rh,t.height)}containsPoint(t){return this.rx<=t.x&&this.rx+this.rw>=t.x&&this.ry<=t.y&&this.ry+this.rh>=t.y}containsRect(t){return this.rx<=t.x&&t.x+t.width<=this.rx+this.rw&&this.ry<=t.y&&t.y+t.height<=this.ry+this.rh}contains(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.rx<=t&&t+i<=this.rx+this.rw&&this.ry<=e&&e+s<=this.ry+this.rh}offset(t,e){return this.rx+=t,this.ry+=e,this}inflate(t,e){return this.Jw(e,t,e,t)}addMargin(t){return this.Jw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.Jw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,e,i,s){return this.Jw(t,e,i,s)}Jw(t,e,i,s){let n=this.rw;e+s<=-n?(this.rx+=n/2,this.rw=0):(this.rx-=s,this.rw+=e+s);let o=this.rh;return t+i<=-o?(this.ry+=o/2,this.rh=0):(this.ry-=t,this.rh+=t+i),this}intersectRect(t){return this.EL(t.x,t.y,t.width,t.height)}intersect(t,e,i,s){return this.EL(t,e,i,s)}EL(t,e,i,s){let n=Math.max(this.rx,t),o=Math.max(this.ry,e),r=Math.min(this.rx+this.rw,t+i),a=Math.min(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=Math.max(0,r-n),this.rh=Math.max(0,a-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,e,i,s){let n=this.rw,o=this.rx;if(n!==1/0&&i!==1/0&&(n+=o,i+=t,isNaN(i)||isNaN(n)||o>i||t>n))return!1;let r=this.rh,a=this.ry;return!(r!==1/0&&s!==1/0&&(r+=a,s+=e,isNaN(s)||isNaN(r)||a>s||e>r))}UL(t,e){let i=this.rw,s=t.width+e+e,n=this.rx,o=t.x-e;if(i+=n,s+=o,n>s||o>i)return!1;let r=this.rh,a=t.height+e+e,h=this.ry,l=t.y-e;return r+=h,a+=l,!(h>a||l>r)}unionPoint(t){return this.re(t.x,t.y,0,0)}unionRect(t){return this.re(t.rx,t.ry,t.rw,t.rh)}union(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.re(t,e,i,s)}re(t,e,i,s){let n=Math.min(this.rx,t),o=Math.min(this.ry,e),r=Math.max(this.rx+this.rw,t+i),a=Math.max(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=r-n,this.rh=a-o,this}setSpot(t,e,i){return this.rx=t-i.offsetX-i.x*this.rw,this.ry=e-i.offsetY-i.y*this.rh,this}nearestSideDirection(t,e){return C.$w(this,t,e,!0)}nearestSideDirectionPoint(t){return C.$w(this,t.x,t.y,!0)}static contains(t,e,i,s,n,o,r,a){return r===void 0&&(r=0),a===void 0&&(a=0),t<=n&&n+r<=t+i&&e<=o&&o+a<=e+s}static intersects(t,e,i,s,n,o,r,a){let h=i,l=r,u=t,c=n;if(h+=u,l+=c,u>l||c>h)return!1;let d=s,f=a,p=e,g=o;return d+=p,f+=g,!(p>f||g>d)}static intersectsLineSegment(t,e,i,s,n,o,r,a){return C.VL(t,e,i,s,n,o,r,a)}get x(){return this.rx}set x(t){this.rx=t}get y(){return this.ry}set y(t){this.ry=t}get width(){return this.rw}set width(t){t<0&&m.J(t,">= 0",I,"width"),this.rw=t}get height(){return this.rh}set height(t){t<0&&m.J(t,">= 0",I,"height"),this.rh=t}get left(){return this.rx}set left(t){this.rx=t}get top(){return this.ry}set top(t){this.ry=t}get right(){return this.rx+this.rw}set right(t){this.rx+=t-(this.rx+this.rw)}get bottom(){return this.ry+this.rh}set bottom(t){this.ry+=t-(this.ry+this.rh)}get position(){return new P(this.rx,this.ry)}set position(t){this.rx=t.x,this.ry=t.y}get size(){return new st(this.rw,this.rh)}set size(t){this.rw=t.width,this.rh=t.height}get center(){return new P(this.rx+this.rw/2,this.ry+this.rh/2)}set center(t){this.rx=t.x-this.rw/2,this.ry=t.y-this.rh/2}get centerX(){return this.rx+this.rw/2}set centerX(t){this.rx=t-this.rw/2}get centerY(){return this.ry+this.rh/2}set centerY(t){this.ry=t-this.rh/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static tm=new I(0,0,0,0).kt();static GF=new I(NaN,NaN,NaN,NaN).kt();static Zw=[];static l(){let t=I.Zw.pop();return t===void 0?new I:t}static bs(t){let e=I.Zw.pop();return e===void 0?t.copy():e.h(t)}static z(t,e,i,s){let n=I.Zw.pop();return n===void 0?new I(t,e,i,s):n.e(t,e,i,s)}static i(t){I.Zw.push(t)}}class Dt{mt;mr;mb;ml;constructor(t,e,i,s){t===void 0?(this.mt=0,this.mr=0,this.mb=0,this.ml=0):e===void 0?(e=t,i=t,s=t,this.mt=t,this.mr=e,this.mb=i,this.ml=s):i===void 0?(i=t,s=e,this.mt=t,this.mr=e,this.mb=i,this.ml=s):s!==void 0?(this.mt=t,this.mr=e,this.mb=i,this.ml=s):m.o("Invalid arguments to Margin constructor: "+t+", "+e+", "+i+", "+s)}setTo(t,e,i,s){return this.mt=t,this.mr=e,this.mb=i,this.ml=s,this}set(t){return this.mt=t.mt,this.mr=t.mr,this.mb=t.mb,this.ml=t.ml,this}copy(){let t=new Dt;return t.mt=this.mt,t.mr=this.mr,t.mb=this.mb,t.ml=this.ml,t}kt(){return Object.freeze(this),this}N(){return Object.isFrozen(this)?this:this.copy().kt()}qw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=NaN;for(;e[i]==="";)i++;let n=e[i++];if(n&&(s=parseFloat(n)),isNaN(s))return new Dt;let o=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(o=parseFloat(n)),isNaN(o))return new Dt(s);let r=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(r=parseFloat(n)),isNaN(r))return new Dt(s,o);let a=NaN;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),isNaN(a)?new Dt(s,o):new Dt(s,o,r,a)}else return new Dt}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return m.s(t,"number",Dt,"stringifyFixed:digits"),e=>e.top.toFixed(t)+" "+e.right.toFixed(t)+" "+e.bottom.toFixed(t)+" "+e.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Dt?this.mt===t.top&&this.mr===t.right&&this.mb===t.bottom&&this.ml===t.left:!1}equalTo(t,e,i,s){return this.mt===t&&this.mr===e&&this.mb===i&&this.ml===s}equalsApprox(t){return C.c(this.mt,t.top)&&C.c(this.mr,t.right)&&C.c(this.mb,t.bottom)&&C.c(this.ml,t.left)}get top(){return this.mt}set top(t){this.mt=t}get right(){return this.mr}set right(t){this.mr=t}get bottom(){return this.mb}set bottom(t){this.mb=t}get left(){return this.ml}set left(t){this.ml=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static em=new Dt(0,0,0,0).kt();static BL=new Dt(2,2,2,2).kt()}class T{sx;sy;ox;oy;constructor(t,e,i,s){t===void 0?(this.sx=0,this.sy=0,this.ox=0,this.oy=0):(e===void 0&&(e=0),i===void 0&&(i=0),s===void 0&&(s=0),this.sx=t,this.sy=e,this.ox=i,this.oy=s)}setTo(t,e,i,s){return this.sx=t,this.sy=e,this.ox=i,this.oy=s,this}set(t){return this.sx=t.sx,this.sy=t.sy,this.ox=t.ox,this.oy=t.oy,this}copy(){let t=new T;return t.sx=this.sx,t.sy=this.sy,t.ox=this.ox,t.oy=this.oy,t}kt(){return Object.freeze(this),this}N(){return Object.isFrozen(this)?this:this.copy().kt()}qw(t){}Ki(t){return this.sx=NaN,this.sy=NaN,this.ox=t,this.kt()}TU(t,e){(isNaN(t)||t>1||t<0)&&m.J(t,"0 <= "+e+" <= 1",T,e)}DU(t,e){(isNaN(t)||t===1/0||t===-1/0)&&m.J(t,"real number, not NaN or Infinity",T,e)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return T.None;if(t==="TopLeft")return T.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return T.TopCenter;if(t==="TopRight")return T.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return T.LeftCenter;if(t==="Center")return T.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return T.RightCenter;if(t==="BottomLeft")return T.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return T.BottomCenter;if(t==="BottomRight")return T.BottomRight;if(t==="TopSide")return T.TopSide;if(t==="LeftSide")return T.LeftSide;if(t==="RightSide")return T.RightSide;if(t==="BottomSide")return T.BottomSide;if(t==="TopBottomSides")return T.TopBottomSides;if(t==="LeftRightSides")return T.LeftRightSides;if(t==="TopLeftSides")return T.TopLeftSides;if(t==="TopRightSides")return T.TopRightSides;if(t==="BottomLeftSides")return T.BottomLeftSides;if(t==="BottomRightSides")return T.BottomRightSides;if(t==="NotTopSide")return T.NotTopSide;if(t==="NotLeftSide")return T.NotLeftSide;if(t==="NotRightSide")return T.NotRightSide;if(t==="NotBottomSide")return T.NotBottomSide;if(t==="AllSides")return T.AllSides;if(t==="Default")return T.Default;let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n!==void 0&&n.length>0&&(a=parseFloat(n)),new T(s,o,r,a)}else return new T}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return m.s(t,"number",T,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.offsetX.toFixed(t)+" "+e.offsetY.toFixed(t)}toString(){return this.isSpot()?this.ox===0&&this.oy===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(T.None)?"None":this.equals(T.TopLeft)?"TopLeft":this.equals(T.TopCenter)?"Top":this.equals(T.TopRight)?"TopRight":this.equals(T.LeftCenter)?"Left":this.equals(T.Center)?"Center":this.equals(T.RightCenter)?"Right":this.equals(T.BottomLeft)?"BottomLeft":this.equals(T.BottomCenter)?"Bottom":this.equals(T.BottomRight)?"BottomRight":this.equals(T.TopSide)?"TopSide":this.equals(T.LeftSide)?"LeftSide":this.equals(T.RightSide)?"RightSide":this.equals(T.BottomSide)?"BottomSide":this.equals(T.TopBottomSides)?"TopBottomSides":this.equals(T.LeftRightSides)?"LeftRightSides":this.equals(T.TopLeftSides)?"TopLeftSides":this.equals(T.TopRightSides)?"TopRightSides":this.equals(T.BottomLeftSides)?"BottomLeftSides":this.equals(T.BottomRightSides)?"BottomRightSides":this.equals(T.NotTopSide)?"NotTopSide":this.equals(T.NotLeftSide)?"NotLeftSide":this.equals(T.NotRightSide)?"NotRightSide":this.equals(T.NotBottomSide)?"NotBottomSide":this.equals(T.AllSides)?"AllSides":this.equals(T.Default)?"Default":"None"}equals(t){return t instanceof T?(this.sx===t.x||isNaN(this.sx)&&isNaN(t.x))&&(this.sy===t.y||isNaN(this.sy)&&isNaN(t.y))&&this.ox===t.offsetX&&this.oy===t.offsetY:!1}opposite(){return new T(.5-(this.sx-.5),.5-(this.sy-.5),-this.ox,-this.oy)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(T.Left))t=T.LeftSide;else if(t.equals(T.Right))t=T.RightSide;else if(t.equals(T.Top))t=T.TopSide;else if(t.equals(T.Bottom))t=T.BottomSide;else return!1;let e=this.oy,i=t.offsetY;return(e&i)===i}get x(){return this.sx}set x(t){this.sx=t}get y(){return this.sy}set y(t){this.sy=t}get offsetX(){return this.ox}set offsetX(t){this.ox=t}get offsetY(){return this.oy}set offsetY(t){this.oy=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new T(0,0,0,0).Ki(0);static Default=new T(0,0,-1,0).Ki(-1);static TopLeft=new T(0,0,0,0).kt();static TopCenter=new T(.5,0,0,0).kt();static TopRight=new T(1,0,0,0).kt();static LeftCenter=new T(0,.5,0,0).kt();static Center=new T(.5,.5,0,0).kt();static RightCenter=new T(1,.5,0,0).kt();static BottomLeft=new T(0,1,0,0).kt();static BottomCenter=new T(.5,1,0,0).kt();static BottomRight=new T(1,1,0,0).kt();static MiddleTop=T.TopCenter;static MiddleLeft=T.LeftCenter;static MiddleRight=T.RightCenter;static MiddleBottom=T.BottomCenter;static Top=T.TopCenter;static Left=T.LeftCenter;static Right=T.RightCenter;static Bottom=T.BottomCenter;static TopSide=new T(0,0,1,1).Ki(1);static LeftSide=new T(0,0,1,2).Ki(1);static RightSide=new T(0,0,1,4).Ki(1);static BottomSide=new T(0,0,1,8).Ki(1);static TopBottomSides=new T(0,0,1,9).Ki(1);static LeftRightSides=new T(0,0,1,6).Ki(1);static TopLeftSides=new T(0,0,1,3).Ki(1);static TopRightSides=new T(0,0,1,5).Ki(1);static BottomLeftSides=new T(0,0,1,10).Ki(1);static BottomRightSides=new T(0,0,1,12).Ki(1);static NotTopSide=new T(0,0,1,14).Ki(1);static NotLeftSide=new T(0,0,1,13).Ki(1);static NotRightSide=new T(0,0,1,11).Ki(1);static NotBottomSide=new T(0,0,1,7).Ki(1);static AllSides=new T(0,0,1,15).Ki(1);static AP=new T(.156,.156).kt();static TP=new T(.844,.844).kt()}class Nt{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,e,i,s,n,o){return this.m11=t,this.m12=e,this.m21=i,this.m22=s,this.dx=n,this.dy=o,this}copy(){let t=new Nt;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}DP(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ue(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}kc(t){let e=this.m11*t.m11+this.m21*t.m12,i=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=e,this.m12=i,this.m21=s,this.m22=n,this}zL(t){let e=1/(t.m11*t.m22-t.m12*t.m21),i=t.m22*e,s=-t.m12*e,n=-t.m21*e,o=t.m11*e,r=e*(t.m21*t.dy-t.m22*t.dx),a=e*(t.m12*t.dx-t.m11*t.dy),h=this.m11*i+this.m21*s,l=this.m12*i+this.m22*s,u=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*a+this.dx,this.dy=this.m12*r+this.m22*a+this.dy,this.m11=h,this.m12=l,this.m21=u,this.m22=c,this}Qw(){let t=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*t,i=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=e,this.m12=i,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ks(t,e,i){if(t=C.Ee(t),t===0)return this;this.Xs(e,i);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let l=t*Math.PI/180;s=Math.cos(l),n=Math.sin(l)}let o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,a=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=a,this.m22=h,this.Xs(-e,-i),this}Xs(t,e){return this.dx+=this.m11*t+this.m21*e,this.dy+=this.m12*t+this.m22*e,this}et(t,e){return e===void 0&&(e=t),this.m11*=t,this.m12*=t,this.m21*=e,this.m22*=e,this}YF(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}gt(t){let e=t.x,i=t.y;return t.e(e*this.m11+i*this.m21+this.dx,e*this.m12+i*this.m22+this.dy)}Ci(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=t.x-this.dx,a=t.y-this.dy;return t.e(r*i+a*n,r*s+a*o)}Mu(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=e*(this.m21*this.dy-this.m22*this.dx),a=e*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,l=t.y*1.2;return t.e(h*i+l*n+r,h*s+l*o+a)}im(t){let e=t.x,i=t.y,s=e+t.width,n=i+t.height,o=this.m11,r=this.m12,a=this.m21,h=this.m22,l=this.dx,u=this.dy,c=e*o+i*a+l,d=e*r+i*h+u,f=s*o+i*a+l,p=s*r+i*h+u,g=e*o+n*a+l,y=e*r+n*h+u,b=s*o+n*a+l,v=s*r+n*h+u,w=c,k=c,S=d,N=d;return w=Math.min(w,f),k=Math.max(k,f),S=Math.min(S,p),N=Math.max(N,p),w=Math.min(w,g),k=Math.max(k,g),S=Math.min(S,y),N=Math.max(N,y),w=Math.min(w,b),k=Math.max(k,b),S=Math.min(S,v),N=Math.max(N,v),t.e(w,S,k-w,N-S),t}static XL=[];static l(){let t=Nt.XL.pop();return t===void 0?new Nt:t}static i(t){Nt.XL.push(t)}static vP="54a702f3e53909c447824c6706603faf4c"}let C={KF:"7da71ca0ad381e90",Kn:4*((Math.sqrt(2)-1)/3),GL:[],_w:x=>{if(x<=0)return 0;let t=C.GL;if(t===null){t=[];for(let e=0;e<=2e3;e++)t[e]=Math.sqrt(e);C.GL=t}if(x<1){let e=1/x;return e<=2e3?1/t[e|0]:Math.sqrt(x)}else return x<=2e3?t[x|0]:Math.sqrt(x)},c:(x,t)=>{let e=x-t;return e<.5&&e>-.5},X:(x,t)=>{let e=x-t;return e<5e-8&&e>-5e-8},Ve:(x,t,e,i,s,n,o)=>{s<=0&&(s=1e-6);let r=0,a=0,h=0,l=0;if(x<e?(a=x,r=e):(a=e,r=x),t<i?(l=t,h=i):(l=i,h=t),x===e)return l<=o&&o<=h&&x-s<=n&&n<=x+s;if(t===i)return a<=n&&n<=r&&t-s<=o&&o<=t+s;let u=r+s,c=a-s;if(c<=n&&n<=u){let d=h+s,f=l-s;if(f<=o&&o<=d)if(u-c>d-f)if(x-e>s||e-x>s){let p=(i-t)/(e-x)*(n-x)+t;if(p-s<=o&&o<=p+s)return!0}else return!0;else if(t-i>s||i-t>s){let p=(e-x)/(i-t)*(o-t)+x;if(p-s<=n&&n<=p+s)return!0}else return!0}return!1},tx:(x,t,e,i,s,n,o,r,a,h,l,u)=>{if(!C.Ve(x,t,o,r,u,e,i)||!C.Ve(x,t,o,r,u,s,n)){let c=(x+e)/2,d=(t+i)/2,f=(e+s)/2,p=(i+n)/2,g=(s+o)/2,y=(n+r)/2,b=(c+f)/2,v=(d+p)/2,w=(f+g)/2,k=(p+y)/2,S=(b+w)/2,N=(v+k)/2;return C.tx(x,t,c,d,b,v,S,N,a,h,l,u)||C.tx(S,N,w,k,g,y,o,r,a,h,l,u)}else return C.Ve(x,t,o,r,u,h,l)},YL:(x,t,e,i,s,n,o,r,a)=>{let h=(x+e)/2,l=(t+i)/2,u=(e+s)/2,c=(i+n)/2,d=(s+o)/2,f=(n+r)/2,p=(h+u)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2;return a.e((p+y)/2,(g+b)/2),a},HF:(x,t,e,i,s,n,o,r)=>{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(s+o)/2,d=(n+r)/2,f=(a+l)/2,p=(h+u)/2,g=(l+c)/2,y=(u+d)/2;return P.direction(f,p,g,y)},Nu:(x,t,e,i,s,n,o,r,a,h)=>{if(!C.Ve(x,t,o,r,a,e,i)||!C.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2,v=(d+p)/2,w=(g+b)/2,k=(y+v)/2;C.Nu(x,t,l,u,g,y,w,k,a,h),C.Nu(w,k,b,v,f,p,o,r,a,h)}else h.re(x,t,0,0),h.re(o,r,0,0);return h},Hn:(x,t,e,i,s,n,o,r,a,h)=>{if(!C.Ve(x,t,o,r,a,e,i)||!C.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2,v=(d+p)/2,w=(g+b)/2,k=(y+v)/2;C.Hn(x,t,l,u,g,y,w,k,a,h),C.Hn(w,k,b,v,f,p,o,r,a,h)}else h.length===0&&(h.push(x),h.push(t)),h.push(o),h.push(r);return h},FP:(x,t,e,i,s,n,o,r,a,h)=>{if(C.Ve(x,t,s,n,h,e,i))return C.Ve(x,t,s,n,h,r,a);{let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(l+c)/2,p=(u+d)/2;return C.FP(x,t,l,u,f,p,o,r,a,h)||C.FP(f,p,c,d,s,n,o,r,a,h)}},RP:(x,t,e,i,s,n,o,r)=>{if(C.Ve(x,t,s,n,o,e,i))r.re(x,t,0,0),r.re(s,n,0,0);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(a+l)/2,d=(h+u)/2;C.RP(x,t,a,h,c,d,o,r),C.RP(c,d,l,u,s,n,o,r)}return r},sm:(x,t,e,i,s,n,o,r)=>{if(C.Ve(x,t,s,n,o,e,i))r.length===0&&(r.push(x),r.push(t)),r.push(s),r.push(n);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(a+l)/2,d=(h+u)/2;C.sm(x,t,a,h,c,d,o,r),C.sm(c,d,l,u,s,n,o,r)}return r},nm:(x,t,e,i,s,n,o,r,a,h,l,u,c,d)=>{if(!C.Ve(x,t,o,r,c,e,i)||!C.Ve(x,t,o,r,c,s,n)){let f=(x+e)/2,p=(t+i)/2,g=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+g)/2,k=(p+y)/2,S=(g+b)/2,N=(y+v)/2,D=(w+S)/2,L=(k+N)/2,M=1/0,A=!1,F=0,O=0;if(C.nm(x,t,f,p,w,k,D,L,a,h,l,u,c,d)){let E=(d.x-a)**2+(d.y-h)**2;E<M&&(M=E,A=!0,F=d.x,O=d.y)}if(C.nm(D,L,S,N,b,v,o,r,a,h,l,u,c,d)){let E=(d.x-a)**2+(d.y-h)**2;E<M&&(M=E,A=!0,F=d.x,O=d.y)}return A&&(d.x=F,d.y=O),A}else{if(!C.Pu(x,t,o,r,a,h,l,u))return!1;let f=(x-o)*(h-u)-(t-r)*(a-l);if(f===0)return!1;let p=((x*r-t*o)*(a-l)-(x-o)*(a*u-h*l))/f,g=((x*r-t*o)*(h-u)-(t-r)*(a*u-h*l))/f;return d.e(p,g),!0}},om:(x,t,e,i,s,n,o,r,a,h,l,u,c)=>{let d=0;if(!C.Ve(x,t,o,r,c,e,i)||!C.Ve(x,t,o,r,c,s,n)){let f=(x+e)/2,p=(t+i)/2,g=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+g)/2,k=(p+y)/2,S=(g+b)/2,N=(y+v)/2,D=(w+S)/2,L=(k+N)/2;d+=C.om(x,t,f,p,w,k,D,L,a,h,l,u,c),d+=C.om(D,L,S,N,b,v,o,r,a,h,l,u,c)}else{let f=(x-o)*(h-u)-(t-r)*(a-l);if(f===0)return d;let p=((x*r-t*o)*(a-l)-(x-o)*(a*u-h*l))/f,g=((x*r-t*o)*(h-u)-(t-r)*(a*u-h*l))/f;if(p>=l)return d;let y=0,b=0;if((a>l?a-l:l-a)<(h>u?h-u:u-h)){if(t<r?(y=t,b=r):(y=r,b=t),g<y||g>b)return d}else if(x<o?(y=x,b=o):(y=o,b=x),p<y||p>b)return d;f>0?d++:f<0&&d--}return d},Nl:(x,t,e,i,s,n,o)=>{if(C.X(x,e)){let r=0,a=0;t<i?(r=t,a=i):(r=i,a=t);let h=n;return h<r?(o.e(x,r),!1):h>a?(o.e(x,a),!1):(o.e(x,h),!0)}else if(C.X(t,i)){let r=0,a=0;x<e?(r=x,a=e):(r=e,a=x);let h=s;return h<r?(o.e(r,t),!1):h>a?(o.e(a,t),!1):(o.e(h,t),!0)}else{let r=(e-x)**2+(i-t)**2,a=((x-s)*(x-e)+(t-n)*(t-i))/r;if(a<-5e-6)return o.e(x,t),!1;if(a>1.000005)return o.e(e,i),!1;{let h=x+a*(e-x),l=t+a*(i-t);return o.e(h,l),!0}}},Ao:(x,t,e,i,s,n,o,r,a)=>{if(C.c(x,e)&&C.c(t,i))return a.e(x,t),!1;if(C.X(s,o)){if(C.X(x,e))return C.Nl(x,t,e,i,s,n,a),!1;{let h=(i-t)/(e-x)*(s-x)+t;return C.Nl(x,t,e,i,s,h,a)}}else{let h=(r-n)/(o-s);if(C.X(x,e)){let l=h*(x-s)+n,u=0,c=0;return t<i?(u=t,c=i):(u=i,c=t),l<u?(a.e(x,u),!1):l>c?(a.e(x,c),!1):(a.e(x,l),!0)}else{let l=(i-t)/(e-x);if(C.X(h,l))return C.Nl(x,t,e,i,s,n,a),!1;{let u=(l*x-h*s+n-t)/(l-h);if(C.X(l,0)){let c=0,d=0;return x<e?(c=x,d=e):(c=e,d=x),u<c?(a.e(c,t),!1):u>d?(a.e(d,t),!1):(a.e(u,t),!0)}else{let c=l*(u-x)+t;return C.Nl(x,t,e,i,u,c,a)}}}}},Cl:(x,t,e,i,s,n,o,r,a)=>{let h=1e21,l=x,u=t;if(C.Ao(x,t,x,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Ao(e,t,e,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Ao(x,t,e,t,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Ao(x,i,e,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}return a.e(l,u),h<1e21},ex:(x,t,e)=>C.VL(x.x,x.y,x.width,x.height,t.x,t.y,e.x,e.y),VL:(x,t,e,i,s,n,o,r)=>{let a=x,h=x+e,l=t,u=t+i;if(s===o){let c=0,d=0;return n<r?(c=n,d=r):(c=r,d=n),a<=s&&s<=h&&c<=u&&d>=l}if(n===r){let c=0,d=0;return s<o?(c=s,d=o):(c=o,d=s),l<=n&&n<=u&&c<=h&&d>=a}return!!(I.contains(x,t,e,i,s,n)||I.contains(x,t,e,i,o,r)||C.Pu(a,l,h,l,s,n,o,r)||C.Pu(h,l,h,u,s,n,o,r)||C.Pu(h,u,a,u,s,n,o,r)||C.Pu(a,u,a,l,s,n,o,r))},Pu:(x,t,e,i,s,n,o,r)=>x===e&&t===i&&s===o&&n===r?x===s&&t===n:C.ku(x,t,e,i,s,n)*C.ku(x,t,e,i,o,r)<=0&&C.ku(s,n,o,r,x,t)*C.ku(s,n,o,r,e,i)<=0,ku:(x,t,e,i,s,n)=>{let o=e-x,r=i-t,a=s-x,h=n-t,l=a*r-h*o;return l===0&&(l=a*o+h*r,l>0&&(a-=o,h-=r,l=a*o+h*r,l<0&&(l=0))),l},$w(x,t,e,i){i===void 0&&(i=!1);let s=0,n=x===null?t:(t-x.x)/(x.width>0?x.width:1),o=x===null?e:(e-x.y)/(x.height>0?x.height:1);return n>o?n>1-o||(i||n<1-o?s=270:s=315):i||n<o?n>1-o?s=90:i||n<1-o?s=180:s=135:n<.5?s=225:n>.5&&(s=45),s},Ee:x=>(x>=360?x-=360:x<0&&(x+=360),x),qF:(x,t)=>x>t?Math.min(x-t,Math.abs(x-360-t)):t>x?Math.min(t-x,Math.abs(x-(t-360))):0,KL:(x,t,e,i,s,n)=>{let o=Math.PI;n||(i=i*(o/180),s=s*(o/180));let r=i>s?-1:1,a=1e-5,h=o*2,l=[],u=o/2,c=i,d=Math.min(h,Math.abs(s-i));if(d<a){let f=c+r*Math.min(d,u),p=x+e*Math.cos(c),g=t+e*Math.sin(c),y=x+e*Math.cos(f),b=t+e*Math.sin(f),v=(p+y)/2,w=(g+b)/2;return l.push([p,g,v,w,v,w,y,b]),l}for(;d>a;){let f=c+r*Math.min(d,u);l.push(C.jF(e,c,f,x,t)),d-=Math.abs(f-c),c=f}return l},jF:(x,t,e,i,s)=>{let n=(e-t)/2,o=x*Math.cos(n),r=x*Math.sin(n),a=o,h=-r,l=a*a+h*h,u=l+a*o+h*r,c=4/3*(Math.sqrt(2*l*u)-u)/(a*r-h*o),d=a-c*h,f=h+c*a,p=d,g=-f,y=n+t,b=Math.cos(y),v=Math.sin(y);return[i+x*Math.cos(t),s+x*Math.sin(t),i+d*b-f*v,s+d*v+f*b,i+p*b-g*v,s+p*v+g*b,i+x*Math.cos(e),s+x*Math.sin(e)]},_g:(x,t,e,i,s,n,o)=>{let r=s,a=n,h=Math.floor((x-e)/r)*r+e,l=Math.floor((t-i)/a)*a+i,u=h;h+r-x<r/2&&(u=h+r);let c=l;return l+a-t<a/2&&(c=l+a),o.e(u,c),o},HL:(x,t)=>{let e=Math.max(x,t),i=Math.min(x,t),s=1,n=1;do s=e%i,n=i,e=i,i=s;while(s>0);return n},WF:(x,t,e,i)=>{let s=e<0,n=i<0,o=0,r=0,a=0;x<t?(r=1,a=0):(r=0,a=1);let h=0,l=0,u=0,c=0;return o=r,h=o===0?x:t,u=o===0?e:i,(o===0?s:n)&&(u=-u),o=a,l=o===0?x:t,c=o===0?e:i,(o===0?s:n)&&(c=-c),C.JF(h,l,u,c,0,0)},JF:(x,t,e,i,s,n)=>{let o=0;if(i>0)if(e>0){let r=x*x,a=t*t,h=x*e,l=t*i,u=-a+l,c=-a+Math.sqrt(h*h+l*l),d=u,f=9999999999;for(let y=0;y<f&&(d=.5*(u+c),!(d===u||d===c));++y){let b=h/(d+r),v=l/(d+a),w=b*b+v*v-1;if(w>0)u=d;else if(w<0)c=d;else break}s=r*e/(d+r),n=a*i/(d+a);let p=s-e,g=n-i;o=Math.sqrt(p*p+g*g)}else s=0,n=t,o=Math.abs(i-t);else{let r=x*x-t*t,a=x*e;if(a<r){let h=a/r,l=h*h;s=x*h,n=t*Math.sqrt(Math.abs(1-l));let u=s-e;o=Math.sqrt(u*u+n*n)}else s=x,n=0,o=Math.abs(e-x)}return o},qn:{},rm:new bt,dr:new bt,gr:0,lm:100};C.za=C.KF;var ze=(x=>(x[x.Line=1]="Line",x[x.Rectangle=2]="Rectangle",x[x.Ellipse=3]="Ellipse",x[x.Path=4]="Path",x))(ze||{}),Ri=(x=>(x[x.None=0]="None",x[x.Default=1]="Default",x[x.Fill=2]="Fill",x[x.Uniform=6]="Uniform",x))(Ri||{});class wt{n;am;hm;Pc;Cu;Lu;jn;Wn;Jn;W;Li;Ai;ni;oi;Gs;Sc;Mc;constructor(t,e){V.Je(this),this.n=2,t===void 0&&(t=4),this.W=t,this.Li=0,this.Ai=0,this.ni=0,this.oi=0,t===4?this.Gs=new q:this.Gs=wt.ix,this.am=this.Gs.rt,this.hm=new I,this.Pc=null,this.Cu=null,this.Lu=NaN,this.jn=T.TopLeft,this.Wn=T.BottomRight,this.Sc=NaN,this.Mc=NaN,this.Jn=2,e&&Object.assign(this,e)}copy(){let t=new wt;if(t.n=this.n&-2,t.W=this.W,t.Li=this.Li,t.Ai=this.Ai,t.ni=this.ni,t.oi=this.oi,this.W===4){let e=this.Gs.r,i=t.Gs;for(let s=0;s<e.length;s++){let n=e[s];i.add(n.copy())}t.Gs=i}else t.Gs=this.Gs;return t.am=this.am,t.hm.h(this.hm),t.Pc=this.Pc,t.Cu=this.Cu,t.Lu=this.Lu,t.jn=this.jn.N(),t.Wn=this.Wn.N(),t.Sc=this.Sc,t.Mc=this.Mc,t.Jn=this.Jn,t}static Line=1;static Rectangle=2;static Ellipse=3;static Path=4;static ix=new q().k();get u(){return(this.n&1)!==0}set u(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}k(){if(this.u=!0,this.type!==4)return this;let t=this.figures;t.k();for(let e of t)e.k();return this}equalsApprox(t){if(!(t instanceof wt))return!1;if(this.type!==t.type)return this.type===1&&t.type===4?this.qL(t):t.type===1&&this.type===4?t.qL(this):!1;if(this.type===4){let e=this.figures.r,i=t.figures.r,s=e.length;if(s!==i.length)return!1;for(let n=0;n<s;n++){let o=e[n],r=i[n];if(!o.equalsApprox(r))return!1}return!0}else return C.c(this.startX,t.startX)&&C.c(this.startY,t.startY)&&C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)}qL(t){if(this.type!==1||t.type!==4)return!1;if(t.figures.count===1){let e=t.figures.elt(0);if(e.segments.count===1&&C.c(this.startX,e.startX)&&C.c(this.startY,e.startY)){let i=e.segments.elt(0);if(i.type===2&&C.c(this.endX,i.endX)&&C.c(this.endY,i.endY))return!0}}return!1}static stringify(t){return t.toString()}static stringifyFixed(t){return m.s(t,"number",wt,"stringifyFixed:digits"),e=>e.toString(t)}fe(t){t in ze?this.type=t:m.cr(this,t)}toString(t){t===void 0&&(t=-1);let e=s=>s===0?"0":s.toFixed(t),i;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+e(this.startX)+" "+e(this.startY)+"L"+e(this.endX)+" "+e(this.endY);case 2:return i=new I(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0?"M"+i.x.toString()+" "+i.y.toString()+"H"+i.right.toString()+"V"+i.bottom.toString()+"H"+i.left.toString()+"z":"M"+e(i.x)+" "+e(i.y)+"H"+e(i.right)+"V"+e(i.bottom)+"H"+e(i.left)+"z";case 3:if(i=new I(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0){let r=i.left.toString()+" "+(i.y+i.height/2).toString(),a=i.right.toString()+" "+(i.y+i.height/2).toString();return"M"+r+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+a+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+r}else{let r=e(i.left)+" "+e(i.y+i.height/2),a=e(i.right)+" "+e(i.y+i.height/2);return"M"+r+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+a+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+r}case 4:let s="",n=this.figures.r,o=n.length;for(let r=0;r<o;r++){let a=n[r];r>0&&(s+=" x "),a.isFilled&&(s+="F "),s+=a.toString(t)}return s;default:return ze[this.type]}}static fillPath(t){typeof t!="string"&&m.si(t,"string",wt,"fillPath:str");let e=t.split(/[Xx]/),i=e.length,s="";for(let n=0;n<i;n++){let o=e[n];if(o.match(/[Ff]/)!==null){n===0?s+=o:s+="X"+(o[0]===" "?"":" ")+o;continue}s+=(n===0?"":"X ")+"F"+(o[0]===" "?"":" ")+o}return s}static cm="UuBbMmZzLlHhVvCcSsQqTtAaFfXx";static parse(t,e){e===void 0&&(e=!1),typeof t!="string"&&m.si(t,"string",wt,"parse:str");let i=new RegExp("(["+wt.cm+"])(["+wt.cm+"])","gm"),s=new RegExp("(["+wt.cm+"])([^s])","gm"),n=new RegExp("([^s])(["+wt.cm+"])","gm");t=t.replace(/,/gm," "),t=t.replace(i,"$1 $2"),t=t.replace(i,"$1 $2"),t=t.replace(s,"$1 $2"),t=t.replace(n,"$1 $2"),t=t.replace(/([0-9])([+\-])/gm,"$1 $2"),t=t.replace(/[\s\r\t\n]+/gm," "),t=t.replace(/^\s+|\s+$/g,"");let o=t.split(" ");for(let F=0;F<o.length;F++){let O=o[F];if(O.match(/(\.[0-9]*)(\.)/gm)!==null){let E=m.st(),B="",X=!1;for(let z=0;z<O.length;z++){let U=O[z];U==="."&&!X?(X=!0,B+=U):U==="."?(E.push(B),B="."):B+=U}E.push(B),o.splice(F,1);for(let z=0;z<E.length;z++)o.splice(F+z,0,E[z]);F+=E.length-1,m.Z(E)}}let r=-1,a="",h="",l=new P(0,0),u=new P(0,0),c=new P(0,0),d=!0;function f(){return r>=w-1||o[r+1].match(M)!==null?!0:(d=!1,!1)}function p(){return r++,o[r]}function g(F){let O=parseFloat(p()),E=parseFloat(p());a===a.toLowerCase()&&(O=c.x+O,E=c.y+E),F.e(O,E)}function y(){return g(c),c}function b(){return g(u),u}function v(){let F=h.toLowerCase();return F==="c"||F==="s"||F==="q"||F==="t"?new P(2*c.x-u.x,2*c.y-u.y):new P(c.x,c.y)}let w=o.length,k=Ce.jL(null),S=!1,N=!1,D=!1,L=!0,M=new RegExp("["+wt.cm+"]");for(;!(r>=w-1);){if(h=a,a=p(),a==="")continue;d=!0;let F=!1;switch(a.toUpperCase()){case"X":L=!0,S=!1,N=!1;break;case"M":let O=y();for(k.Ne===null||L===!0?(k.Au(O.x,O.y,S,!1,!N,D),L=!1):k.$F(O.x,O.y),l.h(c);!f();){let E=y();k.Ys(E.x,E.y)}break;case"L":for(;!f();){let E=y();k.Ys(E.x,E.y)}d&&(F=!0);break;case"H":for(;!f();)c.e((a===a.toLowerCase()?c.x:0)+parseFloat(p()),c.y),k.Ys(c.x,c.y);break;case"V":for(;!f();)c.e(c.x,(a===a.toLowerCase()?c.y:0)+parseFloat(p())),k.Ys(c.x,c.y);d&&(F=!0);break;case"C":for(;!f();){let E=new P;g(E);let B=b(),X=y();k.pr(E.x,E.y,B.x,B.y,X.x,X.y)}d&&(F=!0);break;case"S":for(;!f();){let E=v(),B=b(),X=y();k.pr(E.x,E.y,B.x,B.y,X.x,X.y)}d&&(F=!0);break;case"Q":for(;!f();){let E=b(),B=y();k.Tu(E.x,E.y,B.x,B.y)}d&&(F=!0);break;case"T":for(;!f();){let E=v();u.h(E);let B=y();k.Tu(E.x,E.y,B.x,B.y),u.h(B)}d&&(F=!0);break;case"B":for(;!f();){let E=parseFloat(p()),B=parseFloat(p()),X=parseFloat(p()),z=parseFloat(p()),U=parseFloat(p()),tt=U,nt=!1;f()||(tt=parseFloat(p()),f()||(nt=parseFloat(p())!==0)),a===a.toLowerCase()&&(X+=c.x,z+=c.y),k.ZF(E,B,X,z,U,tt,nt)}d&&(F=!0);break;case"A":for(;!f();){let E=Math.abs(parseFloat(p())),B=Math.abs(parseFloat(p())),X=parseFloat(p()),z=!1,U=!1,tt=0,nt=0,Z=p();Z.length===1?(z=!!parseFloat(Z),U=!!parseFloat(p()),tt=parseFloat(p()),nt=parseFloat(p())):Z.length===2?(z=!!parseFloat(Z[0]),U=!!parseFloat(Z[1]),tt=parseFloat(p()),nt=parseFloat(p())):(z=!!parseFloat(Z[0]),U=!!parseFloat(Z[1]),tt=parseFloat(Z.slice(2)),nt=parseFloat(p())),a===a.toLowerCase()&&(tt=c.x+tt,nt=c.y+nt),c.e(tt,nt),k.QF(E,B,X,z,U,tt,nt)}d&&(F=!0);break;case"Z":k._F(),c.h(l);break;case"F":{let E="",B=1;for(;o[r+B];){if(o[r+B]==="0"){D=!0,B++;continue}if(o[r+B].match(/[Uu]/)!==null){B++;continue}if(o[r+B].match(M)===null){B++;continue}E=o[r+B];break}E.match(/[Mm]/)?S=!0:k.tR();break}case"U":{let E="",B=1;for(;o[r+B];){if(o[r+B].match(/[Ff]/)!==null){B++;continue}if(o[r+B].match(M)===null){B++;continue}E=o[r+B];break}E.match(/[Mm]/)?N=!0:k.eR(!1);break}default:if(a==="0"||a==="1")break;m.ne("Unknown geometry command: "+a);break}if(F){m.ne(`Bad geometry command: ${a}, next token: ${p()},
|
|
2
|
+
import{a as un}from"./7PZQ2MP7.js";import"./WCGF6MFJ.js";import{a as ln}from"./Y3XY5BXI.js";import"./36I27Q5R.js";import"./GDPFKW75.js";import{b as hn}from"./S7XOHDIW.js";import{F as ms,G as ps,H as an,h as on,i as rn}from"./46DQNAMV.js";import"./OR4HXHSY.js";(function(){let K=typeof globalThis=="object"&&globalThis||typeof global=="object"&&global.global===global&&global||typeof self=="object"&&self.self===self&&self||{};K.requestAnimationFrame===void 0&&(K.setImmediate===void 0?K.requestAnimationFrame=x=>K.setTimeout(x,0):K.requestAnimationFrame=K.setImmediate);class m{static hr=K.navigator!==void 0&&K.navigator.platform!==void 0&&K.navigator.platform.match(/(iPhone|iPod|iPad|Mac)/i)!==null;static SP(t,e,i){let s=-1;return function(){let n=this,o=arguments;s!==-1&&m.wc(s),s=m.un(()=>{s=-1,i||t.apply(n,o)},e),i&&!s&&t.apply(n,o)}}static un(t,e){return K.setTimeout(t,e)}static wc(t){K.clearTimeout(t)}static Ni(t){return K.document.createElement(t)}static o(t){throw new Error(t)}static L(t,e){let i="The object is frozen, so its properties cannot be set: "+t.toString();e!==void 0&&(i+=" to value: "+e),m.o(i)}static se(t,e,i,s){}static s(t,e,i,s){}static NU(t,e,i){}static xc(t,e,i){if(t===null||typeof t!="object"){let s=m.LL(e);i!==void 0&&(s+="."+i),m.si(t,"object",s)}}static S(t,e,i){m.s(t,"function",e,i)}static CU(t,e,i){}static si(t,e,i,s){}static J(t,e,i,s){let n=m.LL(i);s!==void 0&&(n+="."+s),m.o(n+" is not in the range "+e+": "+t)}static Xi(t){}static cr(t,e){}static ne(t){K.console&&K.console.log(t)}static $(t){return t!==null&&typeof t=="object"}static it(t){return typeof t=="function"}static MP=[];static st(){let t=m.MP.pop();return t===void 0?[]:t}static Z(t){t.length=0,m.MP.push(t)}static LU=Object.freeze([]);static LL(t){return t===null?"*":typeof t=="string"?t:m.it(t)?t.name:""}static Gn(t){return m.it(t)?t.className?t.className:t.name:m.$(t)&&t.constructor?m.Gn(t.constructor):typeof t}static $a(t,e){return e==null||e===""?null:m.$(t)&&e in t||t[e]?t[e]:null}static toString(t){let e=t;return m.$(t)&&(t.text?e=t.text:t.name?e=t.name:t.key!==void 0?e=t.key:t.id!==void 0?e=t.id:t.constructor===Object&&(t.Text?e=t.Text:t.Name?e=t.Name:t.Key!==void 0?e=t.Key:t.Id!==void 0?e=t.Id:t.ID!==void 0&&(e=t.ID))),e===void 0?"undefined":e===null?"null":e.toString()}static Yw(t,e){if(t.hasOwnProperty(e))return!0;let i=Object.getPrototypeOf(t);for(;i&&i!==Function;){if(i.hasOwnProperty(e))return!0;let s=i.AU;if(s&&s[e])return!0;i=Object.getPrototypeOf(i)}return!1}static zF(t){let e=[],i=0;for(i=0;i<256;i++)e[i]=i;let s=0,n=0;for(i=0;i<256;i++)s=(s+e[i]+119)%256,n=e[i],e[i]=e[s],e[s]=n;i=0,s=0;let o="";for(let r=0;r<t.length;r++)i=(i+1)%256,s=(s+e[i])%256,n=e[i],e[i]=e[s],e[s]=n,o+=String.fromCharCode(t.charCodeAt(r)^e[(e[i]+e[s])%256]);return o}static XF(t){let e="0123456789abcdef",i=[];for(let r=0;r<256;r++)i[e.charAt(r>>4)+e.charAt(r&15)]=String.fromCharCode(r);t.length%2&&(t="0"+t);let s=[],n=0;for(let r=0;r<t.length;r+=2)s[n++]=i[t.substring(r,r+2)];let o=s.join("");return o===""?"0":o}static We(t){return m.zF(m.XF(t))}static color1="@COLOR1";static color2="@COLOR2";static Kw="32ab5ff3b26f42dc0ed90f21422913b5"}m.vfo="29e647fdb5";class rt{NP;constructor(){this.NP=[]}toString(){return this.NP.join("")}add(t){t!==""&&this.NP.push(t)}}class bt{}class Pt{g;constructor(){this.g=[]}[Symbol.iterator](){return this.g.values()}key;value;get iterator(){return this}reset(){}next(){return!1}hasNext(){return!1}first(){return null}any(){return!1}all(){return!0}each(){return this}map(t){return this}filter(){return this}get count(){return 0}Ml(){}toString(){return"EmptyIterator"}static instance=new Pt}class dt{constructor(t){this.key=-1,this.value=t}[Symbol.iterator](){return[this.value].values()}key;value;get iterator(){return this}reset(){this.key=-1}next(){return this.key===-1?(this.key=0,!0):!1}hasNext(){return this.next()}first(){return this.key=0,this.value}any(t){return this.key=-1,t(this.value)}all(t){return this.key=-1,t(this.value)}each(t){return this.key=-1,t(this.value),this}map(t){return new dt(t(this.value))}filter(t){return t(this.value)?new dt(this.value):Pt.instance}get count(){return 1}Ml(){this.value=null}toString(){return"SingletonIterator("+this.value+")"}}class gt{qt;zs;Gt;Tt;constructor(t){this.qt=t,this.zs=null,t.fr=null,this.Gt=t.rt,this.Tt=-1}[Symbol.iterator](){return this.zs===null?this.qt.r.values():this.qt.r.filter(this.zs).values()}key;value;get iterator(){return this}get predicate(){return this.zs}set predicate(t){this.zs=t}reset(){let t=this.qt;t.fr=null,this.Gt=t.rt,this.Tt=-1}next(){let t=this.qt;if(t.rt!==this.Gt){if(this.key<0)return!1;m.Xi(t)}let e=t.r,i=e.length,s=++this.Tt,n=this.zs;if(n!==null)for(;s<i;){let o=e[s];if(n(o))return this.Tt=s,this.key=s,this.value=o,!0;s++}else{if(s<i)return this.key=s,this.value=e[s],!0;this.Ml()}return!1}hasNext(){return this.next()}first(){let t=this.qt;this.Gt=t.rt,this.Tt=0;let e=t.r,i=e.length,s=this.zs;if(s!==null){let n=0;for(;n<i;){let o=e[n];if(s(o))return this.Tt=n,this.key=n,this.value=o,o;n++}return null}else if(i>0){let n=e[0];return this.key=0,this.value=n,n}else return null}any(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.zs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(t(a))return!0;e.rt!==i&&m.Xi(e)}}return!1}all(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.zs;for(let r=0;r<n;r++){let a=s[r];if(!(o!==null&&!o(a))){if(!t(a))return!1;e.rt!==i&&m.Xi(e)}}return!0}each(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=e.r,n=s.length,o=this.zs;for(let r=0;r<n;r++){let a=s[r];o!==null&&!o(a)||(t(a),e.rt!==i&&m.Xi(e))}return this}map(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.zs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(s.push(t(l)),e.rt!==i&&m.Xi(e))}let a=new q;return a.r=s,a.Gi(),a.iterator}filter(t){let e=this.qt;e.fr=null;let i=e.rt;this.Tt=-1;let s=[],n=e.r,o=n.length,r=this.zs;for(let h=0;h<o;h++){let l=n[h];r!==null&&!r(l)||(t(l)&&s.push(l),e.rt!==i&&m.Xi(e))}let a=new q;return a.r=s,a.Gi(),a.iterator}get count(){let t=this.zs;if(t!==null){let e=0,i=this.qt.r,s=i.length;for(let n=0;n<s;n++)t(i[n])&&e++;return e}else return this.qt.r.length}Ml(){this.key=-1,this.value=null,this.Gt=-1,this.zs=null,this.qt.fr=this}toString(){return"ListIterator@"+this.Tt+"/"+this.qt.count}}class kt{qt;Gt;Tt;constructor(t){this.qt=t,t.ur=null,this.Gt=t.rt,this.Tt=t.r.length}[Symbol.iterator](){return this.qt.r.reverse().values()}key;value;get iterator(){return this}reset(){let t=this.qt;t.ur=null,this.Gt=t.rt,this.Tt=t.r.length}next(){let t=this.qt;if(t.rt!==this.Gt){if(this.key<0)return!1;m.Xi(t)}let e=--this.Tt;return e>=0?(this.key=e,this.value=t.r[e],!0):(this.Ml(),!1)}hasNext(){return this.next()}first(){let t=this.qt;this.Gt=t.rt;let e=t.r,i=e.length-1;if(this.Tt=i,i>=0){let s=e[i];return this.key=i,this.value=s,s}else return null}any(t){let e=this.qt;e.ur=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(t(r))return!0;e.rt!==i&&m.Xi(e)}return!1}all(t){let e=this.qt;e.ur=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];if(!t(r))return!1;e.rt!==i&&m.Xi(e)}return!0}each(t){let e=this.qt;e.ur=null;let i=e.rt,s=e.r,n=s.length;this.Tt=n;for(let o=n-1;o>=0;o--){let r=s[o];t(r),e.rt!==i&&m.Xi(e)}return this}map(t){let e=this.qt;e.ur=null;let i=e.rt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];s.push(t(h)),e.rt!==i&&m.Xi(e)}let r=new q;return r.r=s,r.Gi(),r.iterator}filter(t){let e=this.qt;e.ur=null;let i=e.rt,s=[],n=e.r,o=n.length;this.Tt=o;for(let a=o-1;a>=0;a--){let h=n[a];t(h)&&s.push(h),e.rt!==i&&m.Xi(e)}let r=new q;return r.r=s,r.Gi(),r.iterator}get count(){return this.qt.r.length}Ml(){this.key=-1,this.value=null,this.Gt=-1,this.qt.ur=this}toString(){return"ListIteratorBackwards("+this.Tt+"/"+this.qt.count+")"}}class q{u;r;rt;fr;ur;constructor(t){V.Je(this),this.u=!1,this.r=[],this.rt=0,this.fr=null,this.ur=null,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.r.values()}Gi(){let t=this.rt;t++,t>999999999&&(t=0),this.rt=t}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"List()#"+V.xs(this)}add(t){return this.u&&m.L(this,t),this.r.push(t),this.Gi(),this}push(t){this.add(t)}addAll(t){if(t===null)return this;this.u&&m.L(this);let e=this.r;if(t.first){let i=t.iterator;for(;i.next();)e.push(i.value)}else for(let i of t)e.push(i);return this.Gi(),this}clear(){this.u&&m.L(this),this.r.length=0,this.Gi()}contains(t){return this.has(t)}has(t){return t===null?!1:this.r.indexOf(t)!==-1}indexOf(t){return t===null?-1:this.r.indexOf(t)}elt(t){let e=this.r;return(t<0||t>=e.length)&&m.J(t,"0 <= i < length",q,"elt:i"),e[t]}get(t){return this.elt(t)}setElt(t,e){let i=this.r;(t<0||t>=i.length)&&m.J(t,"0 <= i < length",q,"setElt:i"),this.u&&m.L(this,t),i[t]=e}set(t,e){this.setElt(t,e)}first(){let t=this.r;return t.length===0?null:t[0]}last(){let t=this.r,e=t.length;return e>0?t[e-1]:null}pop(){this.u&&m.L(this);let t=this.r;if(t.length>0){let e=t.pop();return e===void 0?null:e}return null}any(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++){if(t(e[n]))return!0;this.rt!==i&&m.Xi(this)}return!1}all(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++){if(!t(e[n]))return!1;this.rt!==i&&m.Xi(this)}return!0}each(t){let e=this.r,i=this.rt,s=e.length;for(let n=0;n<s;n++)t(e[n]),this.rt!==i&&m.Xi(this);return this}map(t){let e=new q,i=[],s=this.r,n=this.rt,o=s.length;for(let r=0;r<o;r++)i.push(t(s[r])),this.rt!==n&&m.Xi(this);return e.r=i,e.Gi(),e}filter(t){let e=new q,i=[],s=this.r,n=this.rt,o=s.length;for(let r=0;r<o;r++){let a=s[r];t(a)&&i.push(a),this.rt!==n&&m.Xi(this)}return e.r=i,e.Gi(),e}insertAt(t,e){t<0&&m.J(t,">= 0",q,"insertAt:i"),this.u&&m.L(this,t);let i=this.r;t>=i.length?i.push(e):i.splice(t,0,e),this.Gi()}remove(t){return this.delete(t)}delete(t){if(t===null)return!1;this.u&&m.L(this,t);let e=this.r,i=e.indexOf(t);return i===-1?!1:(i===e.length-1?e.pop():e.splice(i,1),this.Gi(),!0)}removeAt(t){let e=this.r;(t<0||t>=e.length)&&m.J(t,"0 <= i < length",q,"removeAt:i"),this.u&&m.L(this,t),t===e.length-1?e.pop():e.splice(t,1),this.Gi()}removeRange(t,e){let i=this.r,s=i.length;if(t<0)t=0;else if(t>=s)return this;if(e<0)return this;if(e>=s&&(e=s-1),t>e)return this;this.u&&m.L(this);let n=t,o=e+1;for(;o<s;)i[n++]=i[o++];return i.length=s-(e-t+1),this.Gi(),this}copy(){let t=new q,e=this.r;return e.length>0&&(t.r=Array.prototype.slice.call(e)),t}toArray(){let t=this.r,e=this.count,i=new Array(e);for(let s=0;s<e;s++)i[s]=t[s];return i}get AL(){return this.r}toSet(){let t=new V,e=this.r,i=this.count;for(let s=0;s<i;s++)t.add(e[s]);return t}sort(t){return this.u&&m.L(this),this.r.sort(t),this.Gi(),this}sortRange(t,e,i){let s=this.r,n=s.length;e===void 0&&(e=0),i===void 0&&(i=n),this.u&&m.L(this);let o=i-e;if(o<=1)return this;if((e<0||e>=n-1)&&m.J(e,"0 <= from < length",q,"sortRange:from"),o===2){let r=s[e],a=s[e+1];return t(r,a)>0&&(s[e]=a,s[e+1]=r,this.Gi()),this}if(e===0)if(i>=n)s.sort(t);else{let r=s.slice(0,i);r.sort(t);for(let a=0;a<i;a++)s[a]=r[a]}else if(i>=n){let r=s.slice(e);r.sort(t);for(let a=e;a<n;a++)s[a]=r[a-e]}else{let r=s.slice(e,i);r.sort(t);for(let a=e;a<i;a++)s[a]=r[a-e]}return this.Gi(),this}reverse(){return this.u&&m.L(this),this.r.reverse(),this.Gi(),this}get count(){return this.r.length}get size(){return this.r.length}get length(){return this.r.length}get iterator(){if(this.r.length<=0)return Pt.instance;let t=this.fr;return t!==null?(t.reset(),t):new gt(this)}get iteratorBackwards(){if(this.r.length<=0)return Pt.instance;let t=this.ur;return t!==null?(t.reset(),t):new kt(this)}}class Zt{Lo;oe;constructor(t){this.Lo=t,this.oe=t.g.values()}[Symbol.iterator](){return this.Lo.g.values()}key;value;get iterator(){return this}reset(){let t=this.Lo;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.Lo.g.size===0?null:(this.oe=this.Lo.g.values(),this.oe.next().value)}any(t){return this.Lo.any(t)}all(t){return this.Lo.all(t)}each(t){return this.Lo.each(t),this}map(t){let e=new q;return this.Lo.g.forEach(i=>e.add(t(i))),e.iterator}filter(t){let e=new q;return this.Lo.g.forEach(i=>{t(i)&&e.add(i)}),e.iterator}get count(){return this.Lo.count}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"SetIterator"}}class V{u;g;constructor(t){this.u=!1,this.g=new Set,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.values()}values(){return this.g.values()}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"Set()#"+V.xs(this)}add(t){return t===null?this:(this.g.add(t),this)}addAll(t){if(t===null)return this;if(this.u&&m.L(this),t.first){let e=t.iterator;for(;e.next();)this.g.add(e.value)}else for(let e of t)this.g.add(e);return this}has(t){return this.g.has(t)}contains(t){return this.has(t)}containsAll(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(!this.has(e.value))return!1}else for(let e of t)if(!this.has(e))return!1;return!0}containsAny(t){if(t===null)return!0;if(t.first){let e=t.iterator;for(;e.next();)if(this.has(e.value))return!0}else for(let e of t)if(this.has(e))return!0;return!1}first(){return this.g.size===0?null:this.g.values().next().value}any(t){for(let e of this.g)if(t(e))return!0;return!1}all(t){for(let e of this.g)if(!t(e))return!1;return!0}each(t){for(let e of this.g)t(e);return this}map(t){let e=new V;for(let i of this.g)e.add(t(i));return e}filter(t){let e=new V;for(let i of this.g)t(i)&&e.add(i);return e}delete(t){return this.u&&m.L(this),this.g.delete(t)}remove(t){return this.delete(t)}removeAll(t){if(t===null)return this;if(this.u&&m.L(this),t.first){let e=t.iterator;for(;e.next();)this.delete(e.value)}else for(let e of t)this.delete(e);return this}retainAll(t){if(t===null)return this;if(this.count===0)return this;this.u&&m.L(this);let e=new V;e.addAll(t);let i=[];if(t.first){let s=t.iterator;for(;s.next();){let n=s.value;e.has(n)||i.push(n)}}else for(let s of t)e.has(s)||i.push(s);return this.removeAll(i),this}clear(){this.u&&m.L(this),this.g.clear()}copy(){let t=new V;return this.g.forEach(e=>t.add(e)),t}toArray(){return Array.from(this.g)}toList(){let t=new q;return this.g.forEach(e=>t.add(e)),t}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?Pt.instance:new Zt(this)}entries(){return this.g.entries()}keys(){return this.g.keys()}forEach(t,e){return this.g.forEach(t,e)}static Hw=1;static Je(t){t.__gohashid=V.Hw++}static xs(t){return t.__gohashid}}class We{j;oe;constructor(t){this.j=t,this.oe=t.g.keys()}[Symbol.iterator](){return this.j.g.keys()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.keys()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.j.g.size===0?null:(this.oe=this.j.g.keys(),this.oe.next().value)}any(t){for(let e of this.j.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.j.g)t(e[0]);return this}map(t){let e=this.j,i=new q;for(let s of e.g)i.add(t(s[0]));return i.iterator}filter(t){let e=this.j,i=new q;for(let s of e.g){let n=s[0];t(n)&&i.add(n)}return i.iterator}get count(){return this.j.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapKeySetIterator"}}class Oi extends V{j;constructor(t){super(),V.Je(this),this.u=!0,this.j=t}[Symbol.iterator](){return this.g.keys()}values(){return this.g.keys()}k(){return this}ce(){return this}toString(){return"MapKeySet("+this.j.toString()+")"}add(t){m.o("This Set is read-only: "+this.toString())}has(t){return this.j.has(t)}contains(t){return this.has(t)}delete(t){m.o("This Set is read-only: "+this.toString())}remove(t){return this.delete(t)}clear(){m.o("This Set is read-only: "+this.toString())}first(){return this.j.g.size===0?null:this.j.g.keys().next().value}any(t){for(let e of this.j.g)if(t(e[0]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[0]))return!1;return!0}each(t){for(let e of this.j.g)t(e[0]);return this}map(t){let e=new V;for(let i of this.j.g)e.add(t(i[0]));return e}filter(t){let e=new V;for(let i of this.j.g){let s=i[0];t(s)&&e.add(s)}return e}copy(){return new Oi(this.j)}toSet(){let t=new V,e=this.j.g;for(let i of e)t.add(i[0]);return t}toArray(){let t=this.j.g,e=new Array(t.size),i=0;for(let s of t)e[i]=s[0],i++;return e}toList(){let t=new q,e=this.j.g;for(let i of e)t.add(i[0]);return t}get count(){return this.j.size}get size(){return this.j.size}get iterator(){return this.j.size<=0?Pt.instance:new We(this.j)}}class Tn{j;oe;constructor(t){this.j=t,this.oe=t.g.values()}[Symbol.iterator](){return this.j.g.values()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.values()}next(){let t=this.oe.next();return this.value=t.value,this.key=t.value,!t.done}hasNext(){return this.next()}first(){return this.j.g.size===0?null:(this.oe=this.j.g.values(),this.oe.next().value)}any(t){for(let e of this.j.g)if(t(e[1]))return!0;return!1}all(t){for(let e of this.j.g)if(!t(e[1]))return!1;return!0}each(t){for(let e of this.j.g)t(e[1]);return this}map(t){let e=this.j,i=new q;for(let s of e.g)i.add(t(s[1]));return i.iterator}filter(t){let e=this.j,i=new q;for(let s of e.g){let n=s[1];t(n)&&i.add(n)}return i.iterator}get count(){return this.j.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapValueSetIterator"}}class pe{constructor(t,e){this.key=t,this.value=e}toString(){return"{"+this.key+":"+this.value+"}"}key;value}class Ln{j;oe;constructor(t){this.j=t,this.oe=t.g.entries()}[Symbol.iterator](){return this.j.g.entries()}key;value;get iterator(){return this}reset(){let t=this.j;this.oe=t.g.entries()}next(){let t=this.oe.next();return t.done?(this.key=null,this.value=null,!1):(this.key=t.value[0],this.value=t.value[1],!0)}hasNext(){return this.next()}first(){if(this.j.g.size===0)return null;this.oe=this.j.g.entries();let t=this.oe.next().value;return this.key=t[0],this.value=t[1],new pe(t[0],t[1])}any(t){return this.j.any(t)}all(t){return this.j.all(t)}each(t){return this.j.each(t),this}map(t){let e=new q,i=null;return this.j.g.forEach((s,n)=>{i===null?i=new pe(n,s):(i.key=n,i.value=s),e.add(t(i))}),e.iterator}filter(t){let e=new q,i=null;return this.j.g.forEach((s,n)=>{i===null?i=new pe(n,s):(i.key=n,i.value=s),t(i)&&(e.add(i),i=null)}),e.iterator}get count(){return this.j.size}Ml(){this.key=null,this.value=null,this.oe=null}toString(){return"MapIterator"}}class Mt{u;g;constructor(t){V.Je(this),this.u=!1,this.g=new Map,t!==void 0&&this.addAll(t)}[Symbol.iterator](){return this.g.entries()}entries(){return this.g.entries()}k(){return this.u=!0,this}ce(){return this.u=!1,this}toString(){return"Map()#"+V.xs(this)}set(t,e){return this.u&&m.L(this,t),this.g.set(t,e),this}add(t,e){return this.set(t,e)}addAll(t){if(t===null)return this;if(this.u&&m.L(this),t instanceof Mt){let e=t.iterator;for(;e.next();)this.g.set(e.key,e.value)}else if(t.first){let e=t.iterator;for(;e.next();){let i=e.value;this.g.set(i.key,i.value)}}else for(let e of t){let i=e;Array.isArray(i)?this.g.set(i[0],i[1]):this.g.set(i.key,i.value)}return this}first(){if(this.g.size===0)return null;let t=this.g.entries().next().value;return t?new pe(t[0],t[1]):null}any(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new pe(i,s):(e.key=i,e.value=s),t(e))return!0;return!1}all(t){let e=null;for(let[i,s]of this.g)if(e===null?e=new pe(i,s):(e.key=i,e.value=s),!t(e))return!1;return!0}each(t){let e=null;for(let[i,s]of this.g)e===null?e=new pe(i,s):(e.key=i,e.value=s),t(e);return this}map(t){let e=new Mt,i=null;for(let[s,n]of this.g)i===null?i=new pe(s,n):(i.key=s,i.value=n),e.set(s,t(i));return e}filter(t){let e=new Mt,i=null;for(let[s,n]of this.g)i===null?i=new pe(s,n):(i.key=s,i.value=n),t(i)&&e.set(s,n);return e}has(t){return this.g.has(t)}contains(t){return this.has(t)}get(t){let e=this.g.get(t);return e===void 0?null:e}getValue(t){return this.get(t)}delete(t){return t===null?!1:(this.u&&m.L(this,t),this.g.delete(t))}remove(t){return this.delete(t)}clear(){this.u&&m.L(this),this.g.clear()}copy(){let t=new Mt;return t.g=new Map(this.g),t}toArray(){let t=this.g,e=new Array(t.size),i=0;for(let s of t)e[i]=new pe(s[0],s[1]),i++;return e}toKeySet(){return new Oi(this)}get count(){return this.g.size}get size(){return this.g.size}get iterator(){return this.g.size<=0?Pt.instance:new Ln(this)}get iteratorKeys(){return this.count<=0?Pt.instance:new We(this)}keys(){return this.g.keys()}get iteratorValues(){return this.count<=0?Pt.instance:new Tn(this)}values(){return this.g.values()}forEach(t,e){return this.g.forEach(t,e)}}class P{px;py;u;constructor(t,e){t===void 0?(this.px=0,this.py=0):typeof t=="number"&&typeof e=="number"?(this.px=t,this.py=e):m.o("Invalid arguments to Point constructor: "+t+", "+e),this.u=!1}h(t){return this.px=t.px,this.py=t.py,this}e(t,e){return this.px=t,this.py=e,this}setTo(t,e){return this.px=t,this.py=e,this}set(t){return this.px=t.px,this.py=t.py,this}copy(){let t=new P;return t.px=this.px,t.py=this.py,t}kt(){return this.u=!0,Object.freeze(this),this}N(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}qw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new P(s,o)}else return new P}static stringify(t){return t.x.toString()+" "+t.y.toString()}static stringifyFixed(t){return m.s(t,"number",P,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)}toString(){return"Point("+this.x+","+this.y+")"}equals(t){return t instanceof P?this.px===t.x&&this.py===t.y:!1}equalTo(t,e){return this.px===t&&this.py===e}equalsApprox(t){return C.c(this.px,t.x)&&C.c(this.py,t.y)}add(t){return this.px+=t.x,this.py+=t.y,this}subtract(t){return this.px-=t.x,this.py-=t.y,this}offset(t,e){return this.px+=t,this.py+=e,this}rotate(t){if(t===0)return this;let e=this.px,i=this.py;if(e===0&&i===0)return this;let s=0,n=0;if(t=C.Ee(t),t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let o=t*Math.PI/180;s=Math.cos(o),n=Math.sin(o)}return this.px=s*e-n*i,this.py=n*e+s*i,this}scale(t,e){return this.px*=t,this.py*=e,this}distanceSquaredPoint(t){let e=t.x-this.px,i=t.y-this.py;return e*e+i*i}distanceSquared(t,e){let i=t-this.px,s=e-this.py;return i*i+s*s}normalize(){let t=this.px,e=this.py,i=Math.sqrt(t*t+e*e);return i>0&&(this.px=t/i,this.py=e/i),this}directionPoint(t){return this.TL(t.x-this.px,t.y-this.py)}direction(t,e){return this.TL(t-this.px,e-this.py)}TL(t,e){if(t===0)return e>0?90:e<0?270:0;if(e===0)return t>0?0:180;{if(isNaN(t)||isNaN(e))return 0;let i=Math.atan(Math.abs(e/t))*180/Math.PI;return t<0?e<0?i+=180:i=180-i:e<0&&(i=360-i),i}}static compareWithLineSegment(t,e,i,s,n,o){return C.ku(t,e,i,s,n,o)}compareWithLineSegmentPoint(t,e){return C.ku(t.x,t.y,e.x,e.y,this.x,this.y)}static intersectingLineSegments(t,e,i,s,n,o,r,a){return C.Pu(t,e,i,s,n,o,r,a)}projectOntoLineSegment(t,e,i,s){return C.Nl(t,e,i,s,this.px,this.py,this),this}projectOntoLineSegmentPoint(t,e){return C.Nl(t.x,t.y,e.x,e.y,this.px,this.py,this),this}snapToGrid(t,e,i,s){return C._g(this.px,this.py,t,e,i,s,this),this}snapToGridPoint(t,e){return C._g(this.px,this.py,t.x,t.y,e.width,e.height,this),this}setRectSpot(t,e){return this.px=t.x+e.x*t.width+e.offsetX,this.py=t.y+e.y*t.height+e.offsetY,this}setSpot(t,e,i,s,n){return this.px=t+n.x*i+n.offsetX,this.py=e+n.y*s+n.offsetY,this}v(t){return t.gt(this),this}Yi(t){return t.Ci(this),this}static distanceLineSegmentSquared(t,e,i,s,n,o){let r=n-i,a=o-s,h=r*r+a*a,l=i-t,u=s-e,c=-l*r-u*a;if(c<=0||c>=h)return r=n-t,a=o-e,Math.min(l*l+u*u,r*r+a*a);{let d=r*u-a*l;return d*d/h}}static distanceSquared(t,e,i,s){let n=i-t,o=s-e;return n*n+o*o}static direction(t,e,i,s){let n=i-t,o=s-e;if(n===0)return o>0?90:o<0?270:0;if(o===0)return n>0?0:180;{if(isNaN(n)||isNaN(o))return 0;let r=Math.atan(Math.abs(o/n))*180/Math.PI;return n<0?o<0?r+=180:r=180-r:o<0&&(r=360-r),r}}get x(){return this.px}set x(t){this.px=t}get y(){return this.py}set y(t){this.py=t}isReal(){return isFinite(this.x)&&isFinite(this.y)}static dn=new P(0,0).kt();static DL=new P(-1/0,-1/0).kt();static vL=new P(1/0,1/0).kt();static FL=new P(6,6).kt();static gn=new P(NaN,NaN).kt();static jw=[];static l(){let t=P.jw.pop();return t===void 0?new P:t}static bs(t){let e=P.jw.pop();return e===void 0?t.copy():e.h(t)}static z(t,e){let i=P.jw.pop();return i===void 0?new P(t,e):(i.x=t,i.y=e,i)}static i(t){P.jw.push(t)}}class st{sw;sh;u;constructor(t,e){t===void 0?(this.sw=0,this.sh=0):typeof t=="number"&&(t>=0||isNaN(t))&&typeof e=="number"&&(e>=0||isNaN(e))?(this.sw=t,this.sh=e):m.o("Invalid arguments to Size constructor: "+t+", "+e),this.u=!1}h(t){return this.sw=t.sw,this.sh=t.sh,this}e(t,e){return this.sw=t,this.sh=e,this}setTo(t,e){return this.sw=t,this.sh=e,this}set(t){return this.sw=t.sw,this.sh=t.sh,this}copy(){let t=new st;return t.sw=this.sw,t.sh=this.sh,t}kt(){return this.u=!0,Object.freeze(this),this}N(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}qw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;return n=e[i++],n&&(o=parseFloat(n)),new st(s,o)}else return new st}static stringify(t){return t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return m.s(t,"number",st,"stringifyFixed:digits"),e=>e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Size("+this.width+","+this.height+")"}equals(t){return t instanceof st?this.sw===t.width&&this.sh===t.height:!1}equalTo(t,e){return this.sw===t&&this.sh===e}equalsApprox(t){return C.c(this.sw,t.width)&&C.c(this.sh,t.height)}inflate(t,e){let i=this.width+t;this.sw=i>=0?i:0;let s=this.height+e;return this.sh=s>=0?s:0,this}get width(){return this.sw}set width(t){t<0&&m.J(t,">= 0",st,"width"),this.sw=t}get height(){return this.sh}set height(t){t<0&&m.J(t,">= 0",st,"height"),this.sh=t}isReal(){return isFinite(this.width)&&isFinite(this.height)}static bc=new st(0,0).kt();static CP=new st(1,1).kt();static RL=new st(6,6).kt();static Su=new st(8,8).kt();static OL=new st(10,10).kt();static LP=new st(1/0,1/0).kt();static Ww=new st(NaN,NaN).kt();static IL=[];static l(){let t=st.IL.pop();return t===void 0?new st:t}static i(t){st.IL.push(t)}}class I{rx;ry;rw;rh;u;constructor(t,e,i,s){if(t===void 0)this.rx=0,this.ry=0,this.rw=0,this.rh=0;else if(typeof t=="number"&&typeof e=="number"&&typeof i=="number"&&(i>=0||isNaN(i))&&typeof s=="number"&&(s>=0||isNaN(s)))this.rx=t,this.ry=e,this.rw=i,this.rh=s;else if(t instanceof P){let n=t.x,o=t.y;if(e instanceof P){let r=e.x,a=e.y;this.rx=Math.min(n,r),this.ry=Math.min(o,a),this.rw=Math.abs(n-r),this.rh=Math.abs(o-a)}else e instanceof st?(this.rx=n,this.ry=o,this.rw=e.width,this.rh=e.height):m.o("Incorrect second argument supplied to Rect constructor "+e)}else m.o("Invalid arguments to Rect constructor: "+t+", "+e+", "+i+", "+s);this.u=!1}h(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}e(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}Yn(t,e){return this.rw=t,this.rh=e,this}setTo(t,e,i,s){return this.rx=t,this.ry=e,this.rw=i,this.rh=s,this}set(t){return this.rx=t.rx,this.ry=t.ry,this.rw=t.rw,this.rh=t.rh,this}setPoint(t){return this.rx=t.x,this.ry=t.y,this}setSize(t){return this.rw=t.width,this.rh=t.height,this}copy(){let t=new I;return t.rx=this.rx,t.ry=this.ry,t.rw=this.rw,t.rh=this.rh,t}kt(){return this.u=!0,Object.freeze(this),this}N(){return this.u||Object.isFrozen(this)?this:this.copy().k()}k(){return this.u||(this.u=!0),this}ce(){return this.u&&(Object.isFrozen(this)&&m.o("cannot thaw constant: "+this),this.u=!1),this}qw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),new I(s,o,r,a)}else return new I}static stringify(t){return t.x.toString()+" "+t.y.toString()+" "+t.width.toString()+" "+t.height.toString()}static stringifyFixed(t){return m.s(t,"number",I,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.width.toFixed(t)+" "+e.height.toFixed(t)}toString(){return"Rect("+this.x+","+this.y+","+this.width+","+this.height+")"}equals(t){return t instanceof I?this.rx===t.x&&this.ry===t.y&&this.rw===t.width&&this.rh===t.height:!1}equalTo(t,e,i,s){return this.rx===t&&this.ry===e&&this.rw===i&&this.rh===s}equalsApprox(t){return C.c(this.rx,t.x)&&C.c(this.ry,t.y)&&C.c(this.rw,t.width)&&C.c(this.rh,t.height)}equalsApproxTo(t,e,i,s){return C.c(this.rx,t)&&C.c(this.ry,e)&&C.c(this.rw,i)&&C.c(this.rh,s)}equalsApproxClose(t){return C.X(this.rx,t.x)&&C.X(this.ry,t.y)&&C.X(this.rw,t.width)&&C.X(this.rh,t.height)}containsPoint(t){return this.rx<=t.x&&this.rx+this.rw>=t.x&&this.ry<=t.y&&this.ry+this.rh>=t.y}containsRect(t){return this.rx<=t.x&&t.x+t.width<=this.rx+this.rw&&this.ry<=t.y&&t.y+t.height<=this.ry+this.rh}contains(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.rx<=t&&t+i<=this.rx+this.rw&&this.ry<=e&&e+s<=this.ry+this.rh}offset(t,e){return this.rx+=t,this.ry+=e,this}inflate(t,e){return this.Jw(e,t,e,t)}addMargin(t){return this.Jw(t.top,t.right,t.bottom,t.left)}subtractMargin(t){return this.Jw(-t.top,-t.right,-t.bottom,-t.left)}grow(t,e,i,s){return this.Jw(t,e,i,s)}Jw(t,e,i,s){let n=this.rw;e+s<=-n?(this.rx+=n/2,this.rw=0):(this.rx-=s,this.rw+=e+s);let o=this.rh;return t+i<=-o?(this.ry+=o/2,this.rh=0):(this.ry-=t,this.rh+=t+i),this}intersectRect(t){return this.EL(t.x,t.y,t.width,t.height)}intersect(t,e,i,s){return this.EL(t,e,i,s)}EL(t,e,i,s){let n=Math.max(this.rx,t),o=Math.max(this.ry,e),r=Math.min(this.rx+this.rw,t+i),a=Math.min(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=Math.max(0,r-n),this.rh=Math.max(0,a-o),this}intersectsRect(t){return this.intersects(t.x,t.y,t.width,t.height)}intersects(t,e,i,s){let n=this.rw,o=this.rx;if(n!==1/0&&i!==1/0&&(n+=o,i+=t,isNaN(i)||isNaN(n)||o>i||t>n))return!1;let r=this.rh,a=this.ry;return!(r!==1/0&&s!==1/0&&(r+=a,s+=e,isNaN(s)||isNaN(r)||a>s||e>r))}UL(t,e){let i=this.rw,s=t.width+e+e,n=this.rx,o=t.x-e;if(i+=n,s+=o,n>s||o>i)return!1;let r=this.rh,a=t.height+e+e,h=this.ry,l=t.y-e;return r+=h,a+=l,!(h>a||l>r)}unionPoint(t){return this.re(t.x,t.y,0,0)}unionRect(t){return this.re(t.rx,t.ry,t.rw,t.rh)}union(t,e,i,s){return i===void 0&&(i=0),s===void 0&&(s=0),this.re(t,e,i,s)}re(t,e,i,s){let n=Math.min(this.rx,t),o=Math.min(this.ry,e),r=Math.max(this.rx+this.rw,t+i),a=Math.max(this.ry+this.rh,e+s);return this.rx=n,this.ry=o,this.rw=r-n,this.rh=a-o,this}setSpot(t,e,i){return this.rx=t-i.offsetX-i.x*this.rw,this.ry=e-i.offsetY-i.y*this.rh,this}nearestSideDirection(t,e){return C.$w(this,t,e,!0)}nearestSideDirectionPoint(t){return C.$w(this,t.x,t.y,!0)}static contains(t,e,i,s,n,o,r,a){return r===void 0&&(r=0),a===void 0&&(a=0),t<=n&&n+r<=t+i&&e<=o&&o+a<=e+s}static intersects(t,e,i,s,n,o,r,a){let h=i,l=r,u=t,c=n;if(h+=u,l+=c,u>l||c>h)return!1;let d=s,f=a,p=e,g=o;return d+=p,f+=g,!(p>f||g>d)}static intersectsLineSegment(t,e,i,s,n,o,r,a){return C.VL(t,e,i,s,n,o,r,a)}get x(){return this.rx}set x(t){this.rx=t}get y(){return this.ry}set y(t){this.ry=t}get width(){return this.rw}set width(t){t<0&&m.J(t,">= 0",I,"width"),this.rw=t}get height(){return this.rh}set height(t){t<0&&m.J(t,">= 0",I,"height"),this.rh=t}get left(){return this.rx}set left(t){this.rx=t}get top(){return this.ry}set top(t){this.ry=t}get right(){return this.rx+this.rw}set right(t){this.rx+=t-(this.rx+this.rw)}get bottom(){return this.ry+this.rh}set bottom(t){this.ry+=t-(this.ry+this.rh)}get position(){return new P(this.rx,this.ry)}set position(t){this.rx=t.x,this.ry=t.y}get size(){return new st(this.rw,this.rh)}set size(t){this.rw=t.width,this.rh=t.height}get center(){return new P(this.rx+this.rw/2,this.ry+this.rh/2)}set center(t){this.rx=t.x-this.rw/2,this.ry=t.y-this.rh/2}get centerX(){return this.rx+this.rw/2}set centerX(t){this.rx=t-this.rw/2}get centerY(){return this.ry+this.rh/2}set centerY(t){this.ry=t-this.rh/2}isReal(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)}isEmpty(){return this.width===0&&this.height===0}static tm=new I(0,0,0,0).kt();static GF=new I(NaN,NaN,NaN,NaN).kt();static Zw=[];static l(){let t=I.Zw.pop();return t===void 0?new I:t}static bs(t){let e=I.Zw.pop();return e===void 0?t.copy():e.h(t)}static z(t,e,i,s){let n=I.Zw.pop();return n===void 0?new I(t,e,i,s):n.e(t,e,i,s)}static i(t){I.Zw.push(t)}}class Dt{mt;mr;mb;ml;constructor(t,e,i,s){t===void 0?(this.mt=0,this.mr=0,this.mb=0,this.ml=0):e===void 0?(e=t,i=t,s=t,this.mt=t,this.mr=e,this.mb=i,this.ml=s):i===void 0?(i=t,s=e,this.mt=t,this.mr=e,this.mb=i,this.ml=s):s!==void 0?(this.mt=t,this.mr=e,this.mb=i,this.ml=s):m.o("Invalid arguments to Margin constructor: "+t+", "+e+", "+i+", "+s)}setTo(t,e,i,s){return this.mt=t,this.mr=e,this.mb=i,this.ml=s,this}set(t){return this.mt=t.mt,this.mr=t.mr,this.mb=t.mb,this.ml=t.ml,this}copy(){let t=new Dt;return t.mt=this.mt,t.mr=this.mr,t.mb=this.mb,t.ml=this.ml,t}kt(){return Object.freeze(this),this}N(){return Object.isFrozen(this)?this:this.copy().kt()}qw(t){}static parse(t){if(typeof t=="string"){let e=t.split(" "),i=0,s=NaN;for(;e[i]==="";)i++;let n=e[i++];if(n&&(s=parseFloat(n)),isNaN(s))return new Dt;let o=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(o=parseFloat(n)),isNaN(o))return new Dt(s);let r=NaN;for(;e[i]==="";)i++;if(n=e[i++],n&&(r=parseFloat(n)),isNaN(r))return new Dt(s,o);let a=NaN;for(;e[i]==="";)i++;return n=e[i++],n&&(a=parseFloat(n)),isNaN(a)?new Dt(s,o):new Dt(s,o,r,a)}else return new Dt}static stringify(t){return t.top.toString()+" "+t.right.toString()+" "+t.bottom.toString()+" "+t.left.toString()}static stringifyFixed(t){return m.s(t,"number",Dt,"stringifyFixed:digits"),e=>e.top.toFixed(t)+" "+e.right.toFixed(t)+" "+e.bottom.toFixed(t)+" "+e.left.toFixed(t)}toString(){return"Margin("+this.top+","+this.right+","+this.bottom+","+this.left+")"}equals(t){return t instanceof Dt?this.mt===t.top&&this.mr===t.right&&this.mb===t.bottom&&this.ml===t.left:!1}equalTo(t,e,i,s){return this.mt===t&&this.mr===e&&this.mb===i&&this.ml===s}equalsApprox(t){return C.c(this.mt,t.top)&&C.c(this.mr,t.right)&&C.c(this.mb,t.bottom)&&C.c(this.ml,t.left)}get top(){return this.mt}set top(t){this.mt=t}get right(){return this.mr}set right(t){this.mr=t}get bottom(){return this.mb}set bottom(t){this.mb=t}get left(){return this.ml}set left(t){this.ml=t}isReal(){return isFinite(this.top)&&isFinite(this.right)&&isFinite(this.bottom)&&isFinite(this.left)}static em=new Dt(0,0,0,0).kt();static BL=new Dt(2,2,2,2).kt()}class T{sx;sy;ox;oy;constructor(t,e,i,s){t===void 0?(this.sx=0,this.sy=0,this.ox=0,this.oy=0):(e===void 0&&(e=0),i===void 0&&(i=0),s===void 0&&(s=0),this.sx=t,this.sy=e,this.ox=i,this.oy=s)}setTo(t,e,i,s){return this.sx=t,this.sy=e,this.ox=i,this.oy=s,this}set(t){return this.sx=t.sx,this.sy=t.sy,this.ox=t.ox,this.oy=t.oy,this}copy(){let t=new T;return t.sx=this.sx,t.sy=this.sy,t.ox=this.ox,t.oy=this.oy,t}kt(){return Object.freeze(this),this}N(){return Object.isFrozen(this)?this:this.copy().kt()}qw(t){}Ki(t){return this.sx=NaN,this.sy=NaN,this.ox=t,this.kt()}TU(t,e){(isNaN(t)||t>1||t<0)&&m.J(t,"0 <= "+e+" <= 1",T,e)}DU(t,e){(isNaN(t)||t===1/0||t===-1/0)&&m.J(t,"real number, not NaN or Infinity",T,e)}static parse(t){if(typeof t=="string"){if(t=t.trim(),t==="None")return T.None;if(t==="TopLeft")return T.TopLeft;if(t==="Top"||t==="TopCenter"||t==="MiddleTop")return T.TopCenter;if(t==="TopRight")return T.TopRight;if(t==="Left"||t==="LeftCenter"||t==="MiddleLeft")return T.LeftCenter;if(t==="Center")return T.Center;if(t==="Right"||t==="RightCenter"||t==="MiddleRight")return T.RightCenter;if(t==="BottomLeft")return T.BottomLeft;if(t==="Bottom"||t==="BottomCenter"||t==="MiddleBottom")return T.BottomCenter;if(t==="BottomRight")return T.BottomRight;if(t==="TopSide")return T.TopSide;if(t==="LeftSide")return T.LeftSide;if(t==="RightSide")return T.RightSide;if(t==="BottomSide")return T.BottomSide;if(t==="TopBottomSides")return T.TopBottomSides;if(t==="LeftRightSides")return T.LeftRightSides;if(t==="TopLeftSides")return T.TopLeftSides;if(t==="TopRightSides")return T.TopRightSides;if(t==="BottomLeftSides")return T.BottomLeftSides;if(t==="BottomRightSides")return T.BottomRightSides;if(t==="NotTopSide")return T.NotTopSide;if(t==="NotLeftSide")return T.NotLeftSide;if(t==="NotRightSide")return T.NotRightSide;if(t==="NotBottomSide")return T.NotBottomSide;if(t==="AllSides")return T.AllSides;if(t==="Default")return T.Default;let e=t.split(" "),i=0,s=0;for(;e[i]==="";)i++;let n=e[i++];n!==void 0&&n.length>0&&(s=parseFloat(n));let o=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(o=parseFloat(n));let r=0;for(;e[i]==="";)i++;n=e[i++],n!==void 0&&n.length>0&&(r=parseFloat(n));let a=0;for(;e[i]==="";)i++;return n=e[i++],n!==void 0&&n.length>0&&(a=parseFloat(n)),new T(s,o,r,a)}else return new T}static stringify(t){return t.isSpot()?t.x.toString()+" "+t.y.toString()+" "+t.offsetX.toString()+" "+t.offsetY.toString():t.toString()}static stringifyFixed(t){return m.s(t,"number",T,"stringifyFixed:digits"),e=>e.x.toFixed(t)+" "+e.y.toFixed(t)+" "+e.offsetX.toFixed(t)+" "+e.offsetY.toFixed(t)}toString(){return this.isSpot()?this.ox===0&&this.oy===0?"Spot("+this.x+","+this.y+")":"Spot("+this.x+","+this.y+","+this.offsetX+","+this.offsetY+")":this.equals(T.None)?"None":this.equals(T.TopLeft)?"TopLeft":this.equals(T.TopCenter)?"Top":this.equals(T.TopRight)?"TopRight":this.equals(T.LeftCenter)?"Left":this.equals(T.Center)?"Center":this.equals(T.RightCenter)?"Right":this.equals(T.BottomLeft)?"BottomLeft":this.equals(T.BottomCenter)?"Bottom":this.equals(T.BottomRight)?"BottomRight":this.equals(T.TopSide)?"TopSide":this.equals(T.LeftSide)?"LeftSide":this.equals(T.RightSide)?"RightSide":this.equals(T.BottomSide)?"BottomSide":this.equals(T.TopBottomSides)?"TopBottomSides":this.equals(T.LeftRightSides)?"LeftRightSides":this.equals(T.TopLeftSides)?"TopLeftSides":this.equals(T.TopRightSides)?"TopRightSides":this.equals(T.BottomLeftSides)?"BottomLeftSides":this.equals(T.BottomRightSides)?"BottomRightSides":this.equals(T.NotTopSide)?"NotTopSide":this.equals(T.NotLeftSide)?"NotLeftSide":this.equals(T.NotRightSide)?"NotRightSide":this.equals(T.NotBottomSide)?"NotBottomSide":this.equals(T.AllSides)?"AllSides":this.equals(T.Default)?"Default":"None"}equals(t){return t instanceof T?(this.sx===t.x||isNaN(this.sx)&&isNaN(t.x))&&(this.sy===t.y||isNaN(this.sy)&&isNaN(t.y))&&this.ox===t.offsetX&&this.oy===t.offsetY:!1}opposite(){return new T(.5-(this.sx-.5),.5-(this.sy-.5),-this.ox,-this.oy)}includesSide(t){if(!this.isSide())return!1;if(!t.isSide())if(t.equals(T.Left))t=T.LeftSide;else if(t.equals(T.Right))t=T.RightSide;else if(t.equals(T.Top))t=T.TopSide;else if(t.equals(T.Bottom))t=T.BottomSide;else return!1;let e=this.oy,i=t.offsetY;return(e&i)===i}get x(){return this.sx}set x(t){this.sx=t}get y(){return this.sy}set y(t){this.sy=t}get offsetX(){return this.ox}set offsetX(t){this.ox=t}get offsetY(){return this.oy}set offsetY(t){this.oy=t}isSpot(){return!isNaN(this.x)&&!isNaN(this.y)}isNoSpot(){return isNaN(this.x)||isNaN(this.y)}isSide(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===1&&this.offsetY!==0}isNone(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===0&&this.offsetY===0}isDefault(){return isNaN(this.x)&&isNaN(this.y)&&this.offsetX===-1&&this.offsetY===0}static None=new T(0,0,0,0).Ki(0);static Default=new T(0,0,-1,0).Ki(-1);static TopLeft=new T(0,0,0,0).kt();static TopCenter=new T(.5,0,0,0).kt();static TopRight=new T(1,0,0,0).kt();static LeftCenter=new T(0,.5,0,0).kt();static Center=new T(.5,.5,0,0).kt();static RightCenter=new T(1,.5,0,0).kt();static BottomLeft=new T(0,1,0,0).kt();static BottomCenter=new T(.5,1,0,0).kt();static BottomRight=new T(1,1,0,0).kt();static MiddleTop=T.TopCenter;static MiddleLeft=T.LeftCenter;static MiddleRight=T.RightCenter;static MiddleBottom=T.BottomCenter;static Top=T.TopCenter;static Left=T.LeftCenter;static Right=T.RightCenter;static Bottom=T.BottomCenter;static TopSide=new T(0,0,1,1).Ki(1);static LeftSide=new T(0,0,1,2).Ki(1);static RightSide=new T(0,0,1,4).Ki(1);static BottomSide=new T(0,0,1,8).Ki(1);static TopBottomSides=new T(0,0,1,9).Ki(1);static LeftRightSides=new T(0,0,1,6).Ki(1);static TopLeftSides=new T(0,0,1,3).Ki(1);static TopRightSides=new T(0,0,1,5).Ki(1);static BottomLeftSides=new T(0,0,1,10).Ki(1);static BottomRightSides=new T(0,0,1,12).Ki(1);static NotTopSide=new T(0,0,1,14).Ki(1);static NotLeftSide=new T(0,0,1,13).Ki(1);static NotRightSide=new T(0,0,1,11).Ki(1);static NotBottomSide=new T(0,0,1,7).Ki(1);static AllSides=new T(0,0,1,15).Ki(1);static AP=new T(.156,.156).kt();static TP=new T(.844,.844).kt()}class Nt{m11;m12;m21;m22;dx;dy;constructor(){this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0}set(t){return this.m11=t.m11,this.m12=t.m12,this.m21=t.m21,this.m22=t.m22,this.dx=t.dx,this.dy=t.dy,this}setTo(t,e,i,s,n,o){return this.m11=t,this.m12=e,this.m21=i,this.m22=s,this.dx=n,this.dy=o,this}copy(){let t=new Nt;return t.m11=this.m11,t.m12=this.m12,t.m21=this.m21,t.m22=this.m22,t.dx=this.dx,t.dy=this.dy,t}toString(){return"Transform("+this.m11+","+this.m12+","+this.m21+","+this.m22+","+this.dx+","+this.dy+")"}equals(t){return this.m11===t.m11&&this.m12===t.m12&&this.m21===t.m21&&this.m22===t.m22&&this.dx===t.dx&&this.dy===t.dy}DP(){return this.dx===0&&this.dy===0&&this.m11===1&&this.m12===0&&this.m21===0&&this.m22===1}Ue(){return this.m11=1,this.m12=0,this.m21=0,this.m22=1,this.dx=0,this.dy=0,this}kc(t){let e=this.m11*t.m11+this.m21*t.m12,i=this.m12*t.m11+this.m22*t.m12,s=this.m11*t.m21+this.m21*t.m22,n=this.m12*t.m21+this.m22*t.m22;return this.dx=this.m11*t.dx+this.m21*t.dy+this.dx,this.dy=this.m12*t.dx+this.m22*t.dy+this.dy,this.m11=e,this.m12=i,this.m21=s,this.m22=n,this}zL(t){let e=1/(t.m11*t.m22-t.m12*t.m21),i=t.m22*e,s=-t.m12*e,n=-t.m21*e,o=t.m11*e,r=e*(t.m21*t.dy-t.m22*t.dx),a=e*(t.m12*t.dx-t.m11*t.dy),h=this.m11*i+this.m21*s,l=this.m12*i+this.m22*s,u=this.m11*n+this.m21*o,c=this.m12*n+this.m22*o;return this.dx=this.m11*r+this.m21*a+this.dx,this.dy=this.m12*r+this.m22*a+this.dy,this.m11=h,this.m12=l,this.m21=u,this.m22=c,this}Qw(){let t=1/(this.m11*this.m22-this.m12*this.m21),e=this.m22*t,i=-this.m12*t,s=-this.m21*t,n=this.m11*t,o=t*(this.m21*this.dy-this.m22*this.dx),r=t*(this.m12*this.dx-this.m11*this.dy);return this.m11=e,this.m12=i,this.m21=s,this.m22=n,this.dx=o,this.dy=r,this}ks(t,e,i){if(t=C.Ee(t),t===0)return this;this.Xs(e,i);let s=0,n=0;if(t===90)s=0,n=1;else if(t===180)s=-1,n=0;else if(t===270)s=0,n=-1;else{let l=t*Math.PI/180;s=Math.cos(l),n=Math.sin(l)}let o=this.m11*s+this.m21*n,r=this.m12*s+this.m22*n,a=this.m11*-n+this.m21*s,h=this.m12*-n+this.m22*s;return this.m11=o,this.m12=r,this.m21=a,this.m22=h,this.Xs(-e,-i),this}Xs(t,e){return this.dx+=this.m11*t+this.m21*e,this.dy+=this.m12*t+this.m22*e,this}et(t,e){return e===void 0&&(e=t),this.m11*=t,this.m12*=t,this.m21*=e,this.m22*=e,this}YF(){if(this.m11===1&&this.m12===0)return 0;let t=Math.atan2(this.m12,this.m11)*180/Math.PI;return t<0&&(t+=360),t}gt(t){let e=t.x,i=t.y;return t.e(e*this.m11+i*this.m21+this.dx,e*this.m12+i*this.m22+this.dy)}Ci(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=t.x-this.dx,a=t.y-this.dy;return t.e(r*i+a*n,r*s+a*o)}Mu(t){let e=1/(this.m11*this.m22-this.m12*this.m21),i=this.m22*e,s=-this.m12*e,n=-this.m21*e,o=this.m11*e,r=e*(this.m21*this.dy-this.m22*this.dx),a=e*(this.m12*this.dx-this.m11*this.dy),h=t.x*1.25,l=t.y*1.2;return t.e(h*i+l*n+r,h*s+l*o+a)}im(t){let e=t.x,i=t.y,s=e+t.width,n=i+t.height,o=this.m11,r=this.m12,a=this.m21,h=this.m22,l=this.dx,u=this.dy,c=e*o+i*a+l,d=e*r+i*h+u,f=s*o+i*a+l,p=s*r+i*h+u,g=e*o+n*a+l,y=e*r+n*h+u,b=s*o+n*a+l,v=s*r+n*h+u,w=c,k=c,S=d,N=d;return w=Math.min(w,f),k=Math.max(k,f),S=Math.min(S,p),N=Math.max(N,p),w=Math.min(w,g),k=Math.max(k,g),S=Math.min(S,y),N=Math.max(N,y),w=Math.min(w,b),k=Math.max(k,b),S=Math.min(S,v),N=Math.max(N,v),t.e(w,S,k-w,N-S),t}static XL=[];static l(){let t=Nt.XL.pop();return t===void 0?new Nt:t}static i(t){Nt.XL.push(t)}static vP="54a702f3e53909c447824c6706603faf4c"}let C={KF:"7da71ca0ad381e90",Kn:4*((Math.sqrt(2)-1)/3),GL:[],_w:x=>{if(x<=0)return 0;let t=C.GL;if(t===null){t=[];for(let e=0;e<=2e3;e++)t[e]=Math.sqrt(e);C.GL=t}if(x<1){let e=1/x;return e<=2e3?1/t[e|0]:Math.sqrt(x)}else return x<=2e3?t[x|0]:Math.sqrt(x)},c:(x,t)=>{let e=x-t;return e<.5&&e>-.5},X:(x,t)=>{let e=x-t;return e<5e-8&&e>-5e-8},Ve:(x,t,e,i,s,n,o)=>{s<=0&&(s=1e-6);let r=0,a=0,h=0,l=0;if(x<e?(a=x,r=e):(a=e,r=x),t<i?(l=t,h=i):(l=i,h=t),x===e)return l<=o&&o<=h&&x-s<=n&&n<=x+s;if(t===i)return a<=n&&n<=r&&t-s<=o&&o<=t+s;let u=r+s,c=a-s;if(c<=n&&n<=u){let d=h+s,f=l-s;if(f<=o&&o<=d)if(u-c>d-f)if(x-e>s||e-x>s){let p=(i-t)/(e-x)*(n-x)+t;if(p-s<=o&&o<=p+s)return!0}else return!0;else if(t-i>s||i-t>s){let p=(e-x)/(i-t)*(o-t)+x;if(p-s<=n&&n<=p+s)return!0}else return!0}return!1},tx:(x,t,e,i,s,n,o,r,a,h,l,u)=>{if(!C.Ve(x,t,o,r,u,e,i)||!C.Ve(x,t,o,r,u,s,n)){let c=(x+e)/2,d=(t+i)/2,f=(e+s)/2,p=(i+n)/2,g=(s+o)/2,y=(n+r)/2,b=(c+f)/2,v=(d+p)/2,w=(f+g)/2,k=(p+y)/2,S=(b+w)/2,N=(v+k)/2;return C.tx(x,t,c,d,b,v,S,N,a,h,l,u)||C.tx(S,N,w,k,g,y,o,r,a,h,l,u)}else return C.Ve(x,t,o,r,u,h,l)},YL:(x,t,e,i,s,n,o,r,a)=>{let h=(x+e)/2,l=(t+i)/2,u=(e+s)/2,c=(i+n)/2,d=(s+o)/2,f=(n+r)/2,p=(h+u)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2;return a.e((p+y)/2,(g+b)/2),a},HF:(x,t,e,i,s,n,o,r)=>{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(s+o)/2,d=(n+r)/2,f=(a+l)/2,p=(h+u)/2,g=(l+c)/2,y=(u+d)/2;return P.direction(f,p,g,y)},Nu:(x,t,e,i,s,n,o,r,a,h)=>{if(!C.Ve(x,t,o,r,a,e,i)||!C.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2,v=(d+p)/2,w=(g+b)/2,k=(y+v)/2;C.Nu(x,t,l,u,g,y,w,k,a,h),C.Nu(w,k,b,v,f,p,o,r,a,h)}else h.re(x,t,0,0),h.re(o,r,0,0);return h},Hn:(x,t,e,i,s,n,o,r,a,h)=>{if(!C.Ve(x,t,o,r,a,e,i)||!C.Ve(x,t,o,r,a,s,n)){let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(s+o)/2,p=(n+r)/2,g=(l+c)/2,y=(u+d)/2,b=(c+f)/2,v=(d+p)/2,w=(g+b)/2,k=(y+v)/2;C.Hn(x,t,l,u,g,y,w,k,a,h),C.Hn(w,k,b,v,f,p,o,r,a,h)}else h.length===0&&(h.push(x),h.push(t)),h.push(o),h.push(r);return h},FP:(x,t,e,i,s,n,o,r,a,h)=>{if(C.Ve(x,t,s,n,h,e,i))return C.Ve(x,t,s,n,h,r,a);{let l=(x+e)/2,u=(t+i)/2,c=(e+s)/2,d=(i+n)/2,f=(l+c)/2,p=(u+d)/2;return C.FP(x,t,l,u,f,p,o,r,a,h)||C.FP(f,p,c,d,s,n,o,r,a,h)}},RP:(x,t,e,i,s,n,o,r)=>{if(C.Ve(x,t,s,n,o,e,i))r.re(x,t,0,0),r.re(s,n,0,0);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(a+l)/2,d=(h+u)/2;C.RP(x,t,a,h,c,d,o,r),C.RP(c,d,l,u,s,n,o,r)}return r},sm:(x,t,e,i,s,n,o,r)=>{if(C.Ve(x,t,s,n,o,e,i))r.length===0&&(r.push(x),r.push(t)),r.push(s),r.push(n);else{let a=(x+e)/2,h=(t+i)/2,l=(e+s)/2,u=(i+n)/2,c=(a+l)/2,d=(h+u)/2;C.sm(x,t,a,h,c,d,o,r),C.sm(c,d,l,u,s,n,o,r)}return r},nm:(x,t,e,i,s,n,o,r,a,h,l,u,c,d)=>{if(!C.Ve(x,t,o,r,c,e,i)||!C.Ve(x,t,o,r,c,s,n)){let f=(x+e)/2,p=(t+i)/2,g=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+g)/2,k=(p+y)/2,S=(g+b)/2,N=(y+v)/2,D=(w+S)/2,L=(k+N)/2,M=1/0,A=!1,F=0,O=0;if(C.nm(x,t,f,p,w,k,D,L,a,h,l,u,c,d)){let E=(d.x-a)**2+(d.y-h)**2;E<M&&(M=E,A=!0,F=d.x,O=d.y)}if(C.nm(D,L,S,N,b,v,o,r,a,h,l,u,c,d)){let E=(d.x-a)**2+(d.y-h)**2;E<M&&(M=E,A=!0,F=d.x,O=d.y)}return A&&(d.x=F,d.y=O),A}else{if(!C.Pu(x,t,o,r,a,h,l,u))return!1;let f=(x-o)*(h-u)-(t-r)*(a-l);if(f===0)return!1;let p=((x*r-t*o)*(a-l)-(x-o)*(a*u-h*l))/f,g=((x*r-t*o)*(h-u)-(t-r)*(a*u-h*l))/f;return d.e(p,g),!0}},om:(x,t,e,i,s,n,o,r,a,h,l,u,c)=>{let d=0;if(!C.Ve(x,t,o,r,c,e,i)||!C.Ve(x,t,o,r,c,s,n)){let f=(x+e)/2,p=(t+i)/2,g=(e+s)/2,y=(i+n)/2,b=(s+o)/2,v=(n+r)/2,w=(f+g)/2,k=(p+y)/2,S=(g+b)/2,N=(y+v)/2,D=(w+S)/2,L=(k+N)/2;d+=C.om(x,t,f,p,w,k,D,L,a,h,l,u,c),d+=C.om(D,L,S,N,b,v,o,r,a,h,l,u,c)}else{let f=(x-o)*(h-u)-(t-r)*(a-l);if(f===0)return d;let p=((x*r-t*o)*(a-l)-(x-o)*(a*u-h*l))/f,g=((x*r-t*o)*(h-u)-(t-r)*(a*u-h*l))/f;if(p>=l)return d;let y=0,b=0;if((a>l?a-l:l-a)<(h>u?h-u:u-h)){if(t<r?(y=t,b=r):(y=r,b=t),g<y||g>b)return d}else if(x<o?(y=x,b=o):(y=o,b=x),p<y||p>b)return d;f>0?d++:f<0&&d--}return d},Nl:(x,t,e,i,s,n,o)=>{if(C.X(x,e)){let r=0,a=0;t<i?(r=t,a=i):(r=i,a=t);let h=n;return h<r?(o.e(x,r),!1):h>a?(o.e(x,a),!1):(o.e(x,h),!0)}else if(C.X(t,i)){let r=0,a=0;x<e?(r=x,a=e):(r=e,a=x);let h=s;return h<r?(o.e(r,t),!1):h>a?(o.e(a,t),!1):(o.e(h,t),!0)}else{let r=(e-x)**2+(i-t)**2,a=((x-s)*(x-e)+(t-n)*(t-i))/r;if(a<-5e-6)return o.e(x,t),!1;if(a>1.000005)return o.e(e,i),!1;{let h=x+a*(e-x),l=t+a*(i-t);return o.e(h,l),!0}}},Ao:(x,t,e,i,s,n,o,r,a)=>{if(C.c(x,e)&&C.c(t,i))return a.e(x,t),!1;if(C.X(s,o)){if(C.X(x,e))return C.Nl(x,t,e,i,s,n,a),!1;{let h=(i-t)/(e-x)*(s-x)+t;return C.Nl(x,t,e,i,s,h,a)}}else{let h=(r-n)/(o-s);if(C.X(x,e)){let l=h*(x-s)+n,u=0,c=0;return t<i?(u=t,c=i):(u=i,c=t),l<u?(a.e(x,u),!1):l>c?(a.e(x,c),!1):(a.e(x,l),!0)}else{let l=(i-t)/(e-x);if(C.X(h,l))return C.Nl(x,t,e,i,s,n,a),!1;{let u=(l*x-h*s+n-t)/(l-h);if(C.X(l,0)){let c=0,d=0;return x<e?(c=x,d=e):(c=e,d=x),u<c?(a.e(c,t),!1):u>d?(a.e(d,t),!1):(a.e(u,t),!0)}else{let c=l*(u-x)+t;return C.Nl(x,t,e,i,u,c,a)}}}}},Cl:(x,t,e,i,s,n,o,r,a)=>{let h=1e21,l=x,u=t;if(C.Ao(x,t,x,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Ao(e,t,e,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Ao(x,t,e,t,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}if(C.Ao(x,i,e,i,s,n,o,r,a)){let c=(a.x-s)**2+(a.y-n)**2;c<h&&(h=c,l=a.x,u=a.y)}return a.e(l,u),h<1e21},ex:(x,t,e)=>C.VL(x.x,x.y,x.width,x.height,t.x,t.y,e.x,e.y),VL:(x,t,e,i,s,n,o,r)=>{let a=x,h=x+e,l=t,u=t+i;if(s===o){let c=0,d=0;return n<r?(c=n,d=r):(c=r,d=n),a<=s&&s<=h&&c<=u&&d>=l}if(n===r){let c=0,d=0;return s<o?(c=s,d=o):(c=o,d=s),l<=n&&n<=u&&c<=h&&d>=a}return!!(I.contains(x,t,e,i,s,n)||I.contains(x,t,e,i,o,r)||C.Pu(a,l,h,l,s,n,o,r)||C.Pu(h,l,h,u,s,n,o,r)||C.Pu(h,u,a,u,s,n,o,r)||C.Pu(a,u,a,l,s,n,o,r))},Pu:(x,t,e,i,s,n,o,r)=>x===e&&t===i&&s===o&&n===r?x===s&&t===n:C.ku(x,t,e,i,s,n)*C.ku(x,t,e,i,o,r)<=0&&C.ku(s,n,o,r,x,t)*C.ku(s,n,o,r,e,i)<=0,ku:(x,t,e,i,s,n)=>{let o=e-x,r=i-t,a=s-x,h=n-t,l=a*r-h*o;return l===0&&(l=a*o+h*r,l>0&&(a-=o,h-=r,l=a*o+h*r,l<0&&(l=0))),l},$w(x,t,e,i){i===void 0&&(i=!1);let s=0,n=x===null?t:(t-x.x)/(x.width>0?x.width:1),o=x===null?e:(e-x.y)/(x.height>0?x.height:1);return n>o?n>1-o||(i||n<1-o?s=270:s=315):i||n<o?n>1-o?s=90:i||n<1-o?s=180:s=135:n<.5?s=225:n>.5&&(s=45),s},Ee:x=>(x>=360?x-=360:x<0&&(x+=360),x),qF:(x,t)=>x>t?Math.min(x-t,Math.abs(x-360-t)):t>x?Math.min(t-x,Math.abs(x-(t-360))):0,KL:(x,t,e,i,s,n)=>{let o=Math.PI;n||(i=i*(o/180),s=s*(o/180));let r=i>s?-1:1,a=1e-5,h=o*2,l=[],u=o/2,c=i,d=Math.min(h,Math.abs(s-i));if(d<a){let f=c+r*Math.min(d,u),p=x+e*Math.cos(c),g=t+e*Math.sin(c),y=x+e*Math.cos(f),b=t+e*Math.sin(f),v=(p+y)/2,w=(g+b)/2;return l.push([p,g,v,w,v,w,y,b]),l}for(;d>a;){let f=c+r*Math.min(d,u);l.push(C.jF(e,c,f,x,t)),d-=Math.abs(f-c),c=f}return l},jF:(x,t,e,i,s)=>{let n=(e-t)/2,o=x*Math.cos(n),r=x*Math.sin(n),a=o,h=-r,l=a*a+h*h,u=l+a*o+h*r,c=4/3*(Math.sqrt(2*l*u)-u)/(a*r-h*o),d=a-c*h,f=h+c*a,p=d,g=-f,y=n+t,b=Math.cos(y),v=Math.sin(y);return[i+x*Math.cos(t),s+x*Math.sin(t),i+d*b-f*v,s+d*v+f*b,i+p*b-g*v,s+p*v+g*b,i+x*Math.cos(e),s+x*Math.sin(e)]},_g:(x,t,e,i,s,n,o)=>{let r=s,a=n,h=Math.floor((x-e)/r)*r+e,l=Math.floor((t-i)/a)*a+i,u=h;h+r-x<r/2&&(u=h+r);let c=l;return l+a-t<a/2&&(c=l+a),o.e(u,c),o},HL:(x,t)=>{let e=Math.max(x,t),i=Math.min(x,t),s=1,n=1;do s=e%i,n=i,e=i,i=s;while(s>0);return n},WF:(x,t,e,i)=>{let s=e<0,n=i<0,o=0,r=0,a=0;x<t?(r=1,a=0):(r=0,a=1);let h=0,l=0,u=0,c=0;return o=r,h=o===0?x:t,u=o===0?e:i,(o===0?s:n)&&(u=-u),o=a,l=o===0?x:t,c=o===0?e:i,(o===0?s:n)&&(c=-c),C.JF(h,l,u,c,0,0)},JF:(x,t,e,i,s,n)=>{let o=0;if(i>0)if(e>0){let r=x*x,a=t*t,h=x*e,l=t*i,u=-a+l,c=-a+Math.sqrt(h*h+l*l),d=u,f=9999999999;for(let y=0;y<f&&(d=.5*(u+c),!(d===u||d===c));++y){let b=h/(d+r),v=l/(d+a),w=b*b+v*v-1;if(w>0)u=d;else if(w<0)c=d;else break}s=r*e/(d+r),n=a*i/(d+a);let p=s-e,g=n-i;o=Math.sqrt(p*p+g*g)}else s=0,n=t,o=Math.abs(i-t);else{let r=x*x-t*t,a=x*e;if(a<r){let h=a/r,l=h*h;s=x*h,n=t*Math.sqrt(Math.abs(1-l));let u=s-e;o=Math.sqrt(u*u+n*n)}else s=x,n=0,o=Math.abs(e-x)}return o},qn:{},rm:new bt,dr:new bt,gr:0,lm:100};C.za=C.KF;var ze=(x=>(x[x.Line=1]="Line",x[x.Rectangle=2]="Rectangle",x[x.Ellipse=3]="Ellipse",x[x.Path=4]="Path",x))(ze||{}),Ri=(x=>(x[x.None=0]="None",x[x.Default=1]="Default",x[x.Fill=2]="Fill",x[x.Uniform=6]="Uniform",x))(Ri||{});class wt{n;am;hm;Pc;Cu;Lu;jn;Wn;Jn;W;Li;Ai;ni;oi;Gs;Sc;Mc;constructor(t,e){V.Je(this),this.n=2,t===void 0&&(t=4),this.W=t,this.Li=0,this.Ai=0,this.ni=0,this.oi=0,t===4?this.Gs=new q:this.Gs=wt.ix,this.am=this.Gs.rt,this.hm=new I,this.Pc=null,this.Cu=null,this.Lu=NaN,this.jn=T.TopLeft,this.Wn=T.BottomRight,this.Sc=NaN,this.Mc=NaN,this.Jn=2,e&&Object.assign(this,e)}copy(){let t=new wt;if(t.n=this.n&-2,t.W=this.W,t.Li=this.Li,t.Ai=this.Ai,t.ni=this.ni,t.oi=this.oi,this.W===4){let e=this.Gs.r,i=t.Gs;for(let s=0;s<e.length;s++){let n=e[s];i.add(n.copy())}t.Gs=i}else t.Gs=this.Gs;return t.am=this.am,t.hm.h(this.hm),t.Pc=this.Pc,t.Cu=this.Cu,t.Lu=this.Lu,t.jn=this.jn.N(),t.Wn=this.Wn.N(),t.Sc=this.Sc,t.Mc=this.Mc,t.Jn=this.Jn,t}static Line=1;static Rectangle=2;static Ellipse=3;static Path=4;static ix=new q().k();get u(){return(this.n&1)!==0}set u(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}k(){if(this.u=!0,this.type!==4)return this;let t=this.figures;t.k();for(let e of t)e.k();return this}equalsApprox(t){if(!(t instanceof wt))return!1;if(this.type!==t.type)return this.type===1&&t.type===4?this.qL(t):t.type===1&&this.type===4?t.qL(this):!1;if(this.type===4){let e=this.figures.r,i=t.figures.r,s=e.length;if(s!==i.length)return!1;for(let n=0;n<s;n++){let o=e[n],r=i[n];if(!o.equalsApprox(r))return!1}return!0}else return C.c(this.startX,t.startX)&&C.c(this.startY,t.startY)&&C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)}qL(t){if(this.type!==1||t.type!==4)return!1;if(t.figures.count===1){let e=t.figures.elt(0);if(e.segments.count===1&&C.c(this.startX,e.startX)&&C.c(this.startY,e.startY)){let i=e.segments.elt(0);if(i.type===2&&C.c(this.endX,i.endX)&&C.c(this.endY,i.endY))return!0}}return!1}static stringify(t){return t.toString()}static stringifyFixed(t){return m.s(t,"number",wt,"stringifyFixed:digits"),e=>e.toString(t)}fe(t){t in ze?this.type=t:m.cr(this,t)}toString(t){t===void 0&&(t=-1);let e=s=>s===0?"0":s.toFixed(t),i;switch(this.type){case 1:return t<0?"M"+this.startX.toString()+" "+this.startY.toString()+"L"+this.endX.toString()+" "+this.endY.toString():"M"+e(this.startX)+" "+e(this.startY)+"L"+e(this.endX)+" "+e(this.endY);case 2:return i=new I(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0?"M"+i.x.toString()+" "+i.y.toString()+"H"+i.right.toString()+"V"+i.bottom.toString()+"H"+i.left.toString()+"z":"M"+e(i.x)+" "+e(i.y)+"H"+e(i.right)+"V"+e(i.bottom)+"H"+e(i.left)+"z";case 3:if(i=new I(this.startX,this.startY,0,0),i.union(this.endX,this.endY,0,0),t<0){let r=i.left.toString()+" "+(i.y+i.height/2).toString(),a=i.right.toString()+" "+(i.y+i.height/2).toString();return"M"+r+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+a+"A"+(i.width/2).toString()+" "+(i.height/2).toString()+" 0 0 1 "+r}else{let r=e(i.left)+" "+e(i.y+i.height/2),a=e(i.right)+" "+e(i.y+i.height/2);return"M"+r+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+a+"A"+e(i.width/2)+" "+e(i.height/2)+" 0 0 1 "+r}case 4:let s="",n=this.figures.r,o=n.length;for(let r=0;r<o;r++){let a=n[r];r>0&&(s+=" x "),a.isFilled&&(s+="F "),s+=a.toString(t)}return s;default:return ze[this.type]}}static fillPath(t){typeof t!="string"&&m.si(t,"string",wt,"fillPath:str");let e=t.split(/[Xx]/),i=e.length,s="";for(let n=0;n<i;n++){let o=e[n];if(o.match(/[Ff]/)!==null){n===0?s+=o:s+="X"+(o[0]===" "?"":" ")+o;continue}s+=(n===0?"":"X ")+"F"+(o[0]===" "?"":" ")+o}return s}static cm="UuBbMmZzLlHhVvCcSsQqTtAaFfXx";static parse(t,e){e===void 0&&(e=!1),typeof t!="string"&&m.si(t,"string",wt,"parse:str");let i=new RegExp("(["+wt.cm+"])(["+wt.cm+"])","gm"),s=new RegExp("(["+wt.cm+"])([^s])","gm"),n=new RegExp("([^s])(["+wt.cm+"])","gm");t=t.replace(/,/gm," "),t=t.replace(i,"$1 $2"),t=t.replace(i,"$1 $2"),t=t.replace(s,"$1 $2"),t=t.replace(n,"$1 $2"),t=t.replace(/([0-9])([+\-])/gm,"$1 $2"),t=t.replace(/[\s\r\t\n]+/gm," "),t=t.replace(/^\s+|\s+$/g,"");let o=t.split(" ");for(let F=0;F<o.length;F++){let O=o[F];if(O.match(/(\.[0-9]*)(\.)/gm)!==null){let E=m.st(),B="",X=!1;for(let z=0;z<O.length;z++){let U=O[z];U==="."&&!X?(X=!0,B+=U):U==="."?(E.push(B),B="."):B+=U}E.push(B),o.splice(F,1);for(let z=0;z<E.length;z++)o.splice(F+z,0,E[z]);F+=E.length-1,m.Z(E)}}let r=-1,a="",h="",l=new P(0,0),u=new P(0,0),c=new P(0,0),d=!0;function f(){return r>=w-1||o[r+1].match(M)!==null?!0:(d=!1,!1)}function p(){return r++,o[r]}function g(F){let O=parseFloat(p()),E=parseFloat(p());a===a.toLowerCase()&&(O=c.x+O,E=c.y+E),F.e(O,E)}function y(){return g(c),c}function b(){return g(u),u}function v(){let F=h.toLowerCase();return F==="c"||F==="s"||F==="q"||F==="t"?new P(2*c.x-u.x,2*c.y-u.y):new P(c.x,c.y)}let w=o.length,k=Ce.jL(null),S=!1,N=!1,D=!1,L=!0,M=new RegExp("["+wt.cm+"]");for(;!(r>=w-1);){if(h=a,a=p(),a==="")continue;d=!0;let F=!1;switch(a.toUpperCase()){case"X":L=!0,S=!1,N=!1;break;case"M":let O=y();for(k.Ne===null||L===!0?(k.Au(O.x,O.y,S,!1,!N,D),L=!1):k.$F(O.x,O.y),l.h(c);!f();){let E=y();k.Ys(E.x,E.y)}break;case"L":for(;!f();){let E=y();k.Ys(E.x,E.y)}d&&(F=!0);break;case"H":for(;!f();)c.e((a===a.toLowerCase()?c.x:0)+parseFloat(p()),c.y),k.Ys(c.x,c.y);break;case"V":for(;!f();)c.e(c.x,(a===a.toLowerCase()?c.y:0)+parseFloat(p())),k.Ys(c.x,c.y);d&&(F=!0);break;case"C":for(;!f();){let E=new P;g(E);let B=b(),X=y();k.pr(E.x,E.y,B.x,B.y,X.x,X.y)}d&&(F=!0);break;case"S":for(;!f();){let E=v(),B=b(),X=y();k.pr(E.x,E.y,B.x,B.y,X.x,X.y)}d&&(F=!0);break;case"Q":for(;!f();){let E=b(),B=y();k.Tu(E.x,E.y,B.x,B.y)}d&&(F=!0);break;case"T":for(;!f();){let E=v();u.h(E);let B=y();k.Tu(E.x,E.y,B.x,B.y),u.h(B)}d&&(F=!0);break;case"B":for(;!f();){let E=parseFloat(p()),B=parseFloat(p()),X=parseFloat(p()),z=parseFloat(p()),U=parseFloat(p()),tt=U,nt=!1;f()||(tt=parseFloat(p()),f()||(nt=parseFloat(p())!==0)),a===a.toLowerCase()&&(X+=c.x,z+=c.y),k.ZF(E,B,X,z,U,tt,nt)}d&&(F=!0);break;case"A":for(;!f();){let E=Math.abs(parseFloat(p())),B=Math.abs(parseFloat(p())),X=parseFloat(p()),z=!1,U=!1,tt=0,nt=0,Z=p();Z.length===1?(z=!!parseFloat(Z),U=!!parseFloat(p()),tt=parseFloat(p()),nt=parseFloat(p())):Z.length===2?(z=!!parseFloat(Z[0]),U=!!parseFloat(Z[1]),tt=parseFloat(p()),nt=parseFloat(p())):(z=!!parseFloat(Z[0]),U=!!parseFloat(Z[1]),tt=parseFloat(Z.slice(2)),nt=parseFloat(p())),a===a.toLowerCase()&&(tt=c.x+tt,nt=c.y+nt),c.e(tt,nt),k.QF(E,B,X,z,U,tt,nt)}d&&(F=!0);break;case"Z":k._F(),c.h(l);break;case"F":{let E="",B=1;for(;o[r+B];){if(o[r+B]==="0"){D=!0,B++;continue}if(o[r+B].match(/[Uu]/)!==null){B++;continue}if(o[r+B].match(M)===null){B++;continue}E=o[r+B];break}E.match(/[Mm]/)?S=!0:k.tR();break}case"U":{let E="",B=1;for(;o[r+B];){if(o[r+B].match(/[Ff]/)!==null){B++;continue}if(o[r+B].match(M)===null){B++;continue}E=o[r+B];break}E.match(/[Mm]/)?N=!0:k.eR(!1);break}default:if(a==="0"||a==="1")break;m.ne("Unknown geometry command: "+a);break}if(F){m.ne(`Bad geometry command: ${a}, next token: ${p()},
|
|
3
3
|
string: ${t}`);break}}let A=k.fm;if(Ce.WL(k),e){let F=A.figures.iterator;for(;F.next();){let O=F.value;O.isFilled=!0}}return A}static JL(t,e){let i=t.length,s=P.l();for(let n=0;n<i;n++){let o=t[n];s.x=o[0],s.y=o[1],e.gt(s),o[0]=s.x,o[1]=s.y,s.x=o[2],s.y=o[3],e.gt(s),o[2]=s.x,o[3]=s.y,s.x=o[4],s.y=o[5],e.gt(s),o[4]=s.x,o[5]=s.y,s.x=o[6],s.y=o[7],e.gt(s),o[6]=s.x,o[7]=s.y}P.i(s)}OP(){if(this.yt)return!0;if(this.type===4){let t=this.figures;if(this.am!==t.rt)return!0;let e=this.figures.r,i=e.length;for(let s=0;s<i;s++)if(e[s].OP())return!0}return!1}nx(){if(this.yt=!1,this.Pc=null,this.Cu=null,this.Lu=NaN,this.type===4){let e=this.figures;this.am=e.rt;let i=this.figures.r,s=i.length;for(let n=0;n<s;n++)i[n].iR()}let t=this.hm;isNaN(this.Sc)||isNaN(this.Mc)?t.e(0,0,0,0):t.e(0,0,this.Sc,this.Mc),this.$L(t,!1),t.re(0,0,0,0)}computeBoundsWithoutOrigin(){let t=new I;return this.$L(t,!0),t}$L(t,e){switch(this.type){case 1:case 2:case 3:e?t.e(this.Li,this.Ai,0,0):t.re(this.Li,this.Ai,0,0),t.re(this.ni,this.oi,0,0);break;case 4:let i=this.figures,s=i.r,n=i.length;for(let o=0;o<n;o++){let r=s[o];e&&o===0?t.e(r.startX,r.startY,0,0):t.re(r.startX,r.startY,0,0);let a=r.segments.r,h=a.length,l=r.startX,u=r.startY;for(let c=0;c<h;c++){let d=a[c];switch(d.type){case 2:case 1:l=d.endX,u=d.endY,t.re(l,u,0,0);break;case 3:C.Nu(l,u,d.point1X,d.point1Y,d.point2X,d.point2Y,d.endX,d.endY,.5,t),l=d.endX,u=d.endY;break;case 4:C.RP(l,u,d.point1X,d.point1Y,d.endX,d.endY,.5,t),l=d.endX,u=d.endY;break;case 5:case 6:let f=d.type===5?d.To(r):d.Za(r,l,u),p=f.length;if(p===0){l=d.type===5?d.centerX:d.endX,u=d.type===5?d.centerY:d.endY,t.re(l,u,0,0);break}let g=null;for(let y=0;y<p;y++)g=f[y],C.Nu(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],.5,t);g!==null&&(l=g[6],u=g[7]);break;default:m.o("Unknown Segment type: "+d.type)}}}break;default:m.o("Unknown Geometry type: "+this.type)}}sR(t,e){let i=this.bounds,s=t/i.width,n=e/i.height;return isFinite(s)||(s=1),isFinite(n)||(n=1),s===1&&n===1?this:this.copy().scale(s,n)}normalize(){this.u&&m.L(this);let t=this.computeBoundsWithoutOrigin();return this.offset(-t.x,-t.y),new P(-t.x,-t.y)}offset(t,e){return this.u&&m.L(this),this.v(1,0,0,1,t,e),this}scale(t,e){return this.u&&m.L(this),this.v(t,0,0,e,0,0),this}rotate(t,e,i){this.u&&m.L(this),e===void 0&&(e=0),i===void 0&&(i=0);let s=Nt.l();return s.Ue(),s.ks(t,e,i),this.v(s.m11,s.m12,s.m21,s.m22,s.dx,s.dy),Nt.i(s),this}v(t,e,i,s,n,o){let r=0,a=0;switch(this.type){case 1:case 2:case 3:r=this.Li,a=this.Ai,this.Li=r*t+a*i+n,this.Ai=r*e+a*s+o,r=this.ni,a=this.oi,this.ni=r*t+a*i+n,this.oi=r*e+a*s+o;break;case 4:let h=this.figures.r,l=h.length;for(let u=0;u<l;u++){let c=h[u];r=c.startX,a=c.startY,c.startX=r*t+a*i+n,c.startY=r*e+a*s+o;let d=c.segments.r,f=d.length;for(let p=0;p<f;p++){let g=d[p];switch(g.type){case 2:case 1:r=g.endX,a=g.endY,g.endX=r*t+a*i+n,g.endY=r*e+a*s+o;break;case 3:r=g.point1X,a=g.point1Y,g.point1X=r*t+a*i+n,g.point1Y=r*e+a*s+o,r=g.point2X,a=g.point2Y,g.point2X=r*t+a*i+n,g.point2Y=r*e+a*s+o,r=g.endX,a=g.endY,g.endX=r*t+a*i+n,g.endY=r*e+a*s+o;break;case 4:r=g.point1X,a=g.point1Y,g.point1X=r*t+a*i+n,g.point1Y=r*e+a*s+o,r=g.endX,a=g.endY,g.endX=r*t+a*i+n,g.endY=r*e+a*s+o;break;case 5:if(r=g.centerX,a=g.centerY,g.centerX=r*t+a*i+n,g.centerY=r*e+a*s+o,e!==0){let y=Math.atan2(e,t)*180/Math.PI;y<0&&(y+=360),g.startAngle+=y}t<0&&(g.startAngle=180-g.startAngle,g.sweepAngle=-g.sweepAngle),s<0&&(g.startAngle=-g.startAngle,g.sweepAngle=-g.sweepAngle),g.radiusX*=Math.sqrt(t*t+i*i),g.radiusY!==void 0&&(g.radiusY*=Math.sqrt(e*e+s*s));break;case 6:if(r=g.endX,a=g.endY,g.endX=r*t+a*i+n,g.endY=r*e+a*s+o,g.radiusX===0||g.radiusY===0)break;if(e!==0){let y=Math.atan2(e,t)*180/Math.PI;y<0&&(y+=360),g.xAxisRotation+=y}t<0&&(g.xAxisRotation=180-g.xAxisRotation,g.isClockwiseArc=!g.isClockwiseArc),s<0&&(g.xAxisRotation=-g.xAxisRotation,g.isClockwiseArc=!g.isClockwiseArc),g.radiusX*=Math.sqrt(t*t+i*i),g.radiusY*=Math.sqrt(e*e+s*s);break;default:m.o("Unknown Segment type: "+g.type)}}}break}return this.yt=!0,this}containsPoint(t,e){e===void 0&&(e=0);let i=this.Li,s=this.Ai,n=this.ni,o=this.oi;switch(this.type){case 1:return C.Ve(i,s,n,o,e,t.x,t.y);case 2:{let r=Math.min(i,n)-e,a=Math.min(s,o)-e,h=Math.abs(n-i)+e*2,l=Math.abs(o-s)+e*2,u=I.z(r,a,h,l),c=u.containsPoint(t);return I.i(u),c}case 3:{let r=Math.min(i,n)-e,a=Math.min(s,o)-e,h=Math.abs(n-i)+e*2,l=Math.abs(o-s)+e*2,u=h/2,c=l/2;return u<=0||c<=0?!1:(r=t.x-(r+u),a=t.y-(a+c),r*r/(u*u)+a*a/(c*c)<=1)}case 4:return this.IP(t,e,!0,!1);default:return!1}}IP(t,e,i,s){let n=t.x,o=t.y,r=this.bounds.x-20,a=o,h=0,l=0,u=0,c=0,d=0,f=0,p=this.figures.r,g=p.length;for(let y=0;y<g;y++){let b=p[y],v=!b.isEvenOdd;if(b.isFilled){if(i&&b.EP(n,o,e))return!0}else{if(b.EP(n,o,s?e:e+2))return!0;continue}let w=b.segments;l=b.startX,u=b.startY;let k=l,S=u,N=w.r,D=N[0];for(let L=0;L<=w.length;L++){let M;switch(L!==w.length?(D=N[L],M=D.type,d=D.endX,f=D.endY):(M=2,d=k,f=S),M){case 1:{let A=this.lx(n,o,r,a,l,u,k,S);if(isNaN(A))return!0;h+=A,k=d,S=f;break}case 2:{let A=this.lx(n,o,r,a,l,u,d,f);if(isNaN(A))return!0;h+=A;break}case 3:c=C.om(l,u,D.point1X,D.point1Y,D.point2X,D.point2Y,d,f,r,a,n,o,.5),h+=c;break;case 4:{let A=(l+2*D.point1X)/3,F=(u+2*D.point1Y)/3,O=(D.point1X*2+d)/3,E=(D.point1Y*2+f)/3;c=C.om(l,u,A,F,O,E,d,f,r,a,n,o,.5),h+=c;break}case 5:case 6:{let A=D.type===5?D.To(b):D.Za(b,l,u),F=A.length;if(F===0){let E=this.lx(n,o,r,a,l,u,D.type===5?D.centerX:D.endX,D.type===5?D.centerY:D.endY);if(isNaN(E))return!0;h+=E;break}let O=null;for(let E=0;E<F;E++){if(O=A[E],E===0){let B=this.lx(n,o,r,a,l,u,O[0],O[1]);if(isNaN(B))return!0;h+=B}c=C.om(O[0],O[1],O[2],O[3],O[4],O[5],O[6],O[7],r,a,n,o,.5),h+=c}O!==null&&(d=O[6],f=O[7]);break}default:m.o("Unknown Segment type: "+D.type)}l=d,u=f}if(v){if(h!==0)return!0}else if(h%2!==0)return!0;h=0}return!1}lx(t,e,i,s,n,o,r,a){if(C.Ve(n,o,r,a,.05,t,e))return NaN;let h=(t-i)*(o-a);if(h===0)return 0;let l=((t*s-e*i)*(n-r)-(t-i)*(n*a-o*r))/h,u=(t*s-e*i)*(o-a)/h;if(l>=t)return 0;if((n>r?n-r:r-n)<(o>a?o-a:a-o)){if(o<a){if(u<o||u>a)return 0}else if(u<a||u>o)return 0}else if(n<r){if(l<n||l>r)return 0}else if(l<r||l>n)return 0;return h>0?1:-1}ZL(t,e,i){let s=this.figures.r,n=s.length;for(let o=0;o<n;o++)if(s[o].EP(t,e,i))return!0;return!1}getPointAlongPath(t,e){if(t<0?t=0:t>1&&(t=1),e===void 0&&(e=new P),this.type===1)return e.e(this.startX+t*(this.endX-this.startX),this.startY+t*(this.endY-this.startY)),e;let i=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=i.length,r=n*t,a=0;for(let h=0;h<o;h++){let l=s[h],u=l.length;for(let c=0;c<u;c++){let d=l[c];if(a+d>=r){let f=r-a,p=d===0?0:f/d,g=i[h],y=g[c*2],b=g[c*2+1],v=g[c*2+2],w=g[c*2+3];return e.e(y+(v-y)*p,b+(w-b)*p),e}a+=d}}return e}getAngleAlongPath(t){if(t<0?t=0:t>1&&(t=1),this.type===1)return Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI;let e=this.flattenedSegments,i=this.flattenedLengths,s=this.flattenedTotalLength,n=e.length,o=s*t,r=0;for(let a=0;a<n;a++){let h=i[a],l=h.length;for(let u=0;u<l;u++){let c=h[u];if(r+c>=o){let d=e[a],f=d[u*2],p=d[u*2+1],g=d[u*2+2],y=d[u*2+3];return Math.abs(g-f)<1&&Math.abs(y-p)<1?0:Math.abs(g-f)<1?y-p>=0?90:270:Math.abs(y-p)<1?g-f>=0?0:180:Math.atan2(y-p,g-f)*180/Math.PI}r+=c}}return NaN}getPointAndAngleAlongPath(t,e){if(t<0?t=0:t>1&&(t=1),e===void 0&&(e=[]),e.length=3,this.type===1)return e[0]=this.startX+t*(this.endX-this.startX),e[1]=this.startY+t*(this.endY-this.startY),e[2]=Math.atan2(this.endY-this.startY,this.endX-this.startX)*180/Math.PI,e;let i=this.flattenedSegments,s=this.flattenedLengths,n=this.flattenedTotalLength,o=i.length,r=n*t,a=0;for(let h=0;h<o;h++){let l=s[h],u=l.length;for(let c=0;c<u;c++){let d=l[c];if(a+d>=r){let f=r-a,p=d===0?0:f/d,g=i[h],y=g[c*2],b=g[c*2+1],v=g[c*2+2],w=g[c*2+3];e[0]=y+(v-y)*p,e[1]=b+(w-b)*p;let k;return Math.abs(v-y)<1&&Math.abs(w-b)<1?k=0:Math.abs(v-y)<1?k=w-b>=0?90:270:Math.abs(w-b)<1?k=v-y>=0?0:180:k=Math.atan2(w-b,v-y)*180/Math.PI,e[2]=k,e}a+=d}}return e}getFractionForPoint(t){if(this.type===1){let e=this.startX,i=this.startY,s=this.endX,n=this.endY;if(e===s&&i===n)return 0;{let o=t.x,r=t.y,a=0,h=0;if(e===s)return i<n?(a=i,h=n):(a=n,h=i),r<=a?a===i?0:1:r>=h?h===i?0:1:Math.abs(r-i)/(h-a);if(i===n)return e<s?(a=e,h=s):(a=s,h=e),o<=a?a===e?0:1:o>=h?h===e?0:1:Math.abs(o-e)/(h-a);{let l=(s-e)**2+(n-i)**2,u=P.l();C.Nl(e,i,s,n,o,r,u);let c=u.x,d=u.y;return P.i(u),Math.sqrt(((c-e)**2+(d-i)**2)/l)}}}else if(this.type===2){let e=this.startX,i=this.startY,s=this.endX,n=this.endY;if(e===s&&i===n)return 0;{let o=s-e,r=n-i,a=o*2+r*2,h=t.x,l=t.y;h=Math.min(Math.max(h,e),s),l=Math.min(Math.max(l,i),n);let u=Math.abs(h-e),c=Math.abs(h-s),d=Math.abs(l-i),f=Math.abs(l-n),p=Math.min(u,c,d,f);if(p===d)return h/a;if(p===c)return(o+l)/a;if(p===f)return(o*2+r-h)/a;if(p===u)return(o*2+r*2-l)/a}}else{let e=this.flattenedSegments,i=this.flattenedLengths,s=this.flattenedTotalLength,n=P.l(),o=1/0,r=0,a=0,h=e.length,l=0,u=0;for(let d=0;d<h;d++){let f=e[d],p=i[d],g=f.length;for(let y=0;y<g;y+=2){let b=f[y],v=f[y+1];if(y===0){l=b,u=v;continue}C.Nl(l,u,b,v,t.x,t.y,n);let w=(n.x-t.x)**2+(n.y-t.y)**2;w<o&&(o=w,r=a,r+=Math.sqrt((n.x-l)**2+(n.y-u)**2)),a+=p[(y-2)/2],l=b,u=v}}P.i(n);let c=r/s;return c<0?0:c>1?1:c}return 0}get flattenedSegments(){return this.QL(),this.Pc}QL(){if(this.Pc===null){let t=this.Pc=[],e=this.Cu=[];this.nR(t,e)}}get flattenedLengths(){return this.QL(),this.Cu}get flattenedTotalLength(){let t=this.Lu;if(isNaN(t)){if(this.type===1){let e=Math.abs(this.endX-this.startX),i=Math.abs(this.endY-this.startY);t=Math.sqrt(e*e+i*i)}else if(this.type===2){let e=Math.abs(this.endX-this.startX),i=Math.abs(this.endY-this.startY);t=e*2+i*2}else{let e=this.flattenedLengths,i=e.length;t=0;for(let s=0;s<i;s++){let n=e[s],o=n.length;for(let r=0;r<o;r++)t+=n[r]}}this.Lu=t}return t}UP(t){let e=[],i=0,s=0,n=t.length;for(let o=0;o<n;o+=2){let r=t[o],a=t[o+1];if(o===0){i=r,s=a;continue}let h=Math.sqrt(P.distanceSquared(i,s,r,a));e.push(h),i=r,s=a}return e}nR(t,e){let i=[],s=[];if(this.type===1)i.push(this.startX),i.push(this.startY),i.push(this.endX),i.push(this.endY),t.push(i),s.push(Math.sqrt((this.startX-this.endX)**2+(this.startY-this.endY)**2)),e.push(s);else if(this.type===2)i.push(this.startX),i.push(this.startY),i.push(this.endX),i.push(this.startY),i.push(this.endX),i.push(this.endY),i.push(this.startX),i.push(this.endY),i.push(this.startX),i.push(this.startY),t.push(i),s.push(Math.abs(this.startX-this.endX)),s.push(Math.abs(this.startY-this.endY)),s.push(Math.abs(this.startX-this.endX)),s.push(Math.abs(this.startY-this.endY)),e.push(s);else if(this.type===3){let n=new zt;n.startX=this.endX,n.startY=(this.startY+this.endY)/2;let o=new mt(5);o.startAngle=0,o.sweepAngle=360,o.centerX=(this.startX+this.endX)/2,o.centerY=(this.startY+this.endY)/2,o.radiusX=Math.abs(this.startX-this.endX)/2,o.radiusY=Math.abs(this.startY-this.endY)/2,n.add(o);let r=o.To(n),a=r.length;if(a===0)i.push(o.centerX),i.push(o.centerY);else{let h=n.startX,l=n.startY;for(let u=0;u<a;u++){let c=r[u];C.Hn(h,l,c[2],c[3],c[4],c[5],c[6],c[7],.5,i),h=c[6],l=c[7]}}t.push(i),e.push(this.UP(i))}else{let n=this.figures.iterator;for(;n.next();){let o=n.value;i=[],i.push(o.startX),i.push(o.startY);let r=o.startX,a=o.startY,h=r,l=a,u=o.segments.r,c=u.length;for(let d=0;d<c;d++){let f=u[d];switch(f.type){case 1:i.length>=4&&(t.push(i),e.push(this.UP(i))),i=[],i.push(f.endX),i.push(f.endY),r=f.endX,a=f.endY,h=r,l=a;break;case 2:i.push(f.endX),i.push(f.endY),r=f.endX,a=f.endY;break;case 3:C.Hn(r,a,f.point1X,f.point1Y,f.point2X,f.point2Y,f.endX,f.endY,.5,i),r=f.endX,a=f.endY;break;case 4:C.sm(r,a,f.point1X,f.point1Y,f.endX,f.endY,.5,i),r=f.endX,a=f.endY;break;case 5:{let p=f.To(o),g=p.length;if(g===0){i.push(f.centerX),i.push(f.centerY),r=f.centerX,a=f.centerY;break}for(let y=0;y<g;y++){let b=p[y];C.Hn(r,a,b[2],b[3],b[4],b[5],b[6],b[7],.5,i),r=b[6],a=b[7]}break}case 6:{let p=f.Za(o,r,a),g=p.length,y=f.endX,b=f.endY;if(g===0){i.push(y),i.push(b),r=y,a=b;break}for(let v=0;v<g;v++){let w=p[v];C.Hn(r,a,w[2],w[3],w[4],w[5],w[6],w[7],.5,i),r=w[6],a=w[7]}break}default:m.o("Segment not of valid type: "+f.type)}f.isClosed&&(i.push(h),i.push(l))}i.length>=4&&(t.push(i),e.push(this.UP(i)))}}}get type(){return this.W}set type(t){this.W!==t&&(this.u&&m.L(this,t),this.W=t,t===4?this.Gs=new q:(wt.ix===null&&(wt.ix=new q().k()),this.Gs=wt.ix),this.yt=!0)}get startX(){return this.Li}set startX(t){this.Li!==t&&(this.u&&m.L(this,t),this.Li=t,this.yt=!0)}get startY(){return this.Ai}set startY(t){this.Ai!==t&&(this.u&&m.L(this,t),this.Ai=t,this.yt=!0)}get endX(){return this.ni}set endX(t){this.ni!==t&&(this.u&&m.L(this,t),this.ni=t,this.yt=!0)}get endY(){return this.oi}set endY(t){this.oi!==t&&(this.u&&m.L(this,t),this.oi=t,this.yt=!0)}get figures(){return this.Gs}set figures(t){this.Gs!==t&&(this.u&&m.L(this,t),this.Gs=t,this.yt=!0)}add(t){return this.Gs.add(t),this}setSpots(t,e,i,s,n,o,r,a){return this.u&&m.L(this),this.jn=new T(t,e,n,o),this.Wn=new T(i,s,r,a),this}get spot1(){return this.jn}set spot1(t){this.u&&m.L(this,t),this.jn=t.N()}get spot2(){return this.Wn}set spot2(t){this.u&&m.L(this,t),this.Wn=t.N()}get defaultStretch(){return this.Jn}set defaultStretch(t){this.Jn=t}get bounds(){return this.OP()&&this.nx(),this.hm}polygonClosestSegment(t,e){if(e===void 0&&(e=10),this.type!==4)return null;let i=t.x,s=t.y,n=1/0,o=0,r=0,a=0,h=0,l=0,u=0,c=0,d=0;return this.figures.each(f=>{let p=f.startX,g=f.startY;f.segments.each(y=>{let b=y.endX,v=y.endY,w=0;if(y.type===2)w=P.distanceLineSegmentSquared(i,s,p,g,b,v);else{p=y.endX,g=y.endY;return}w<n&&(n=w,o=a,r=h,l=p,u=g,c=b,d=v),p=b,g=v,h++,y.isClosed&&(b=f.startX,v=f.startY,w=P.distanceLineSegmentSquared(i,s,p,g,b,v),w<n&&(n=w,o=a,r=h,l=p,u=g,c=b,d=v),h++)}),a++,h=0}),n<e*e?{figi:o,segi:r,ax:l,ay:u,bx:c,by:d}:null}get polygonArea(){if(this.type===4){let t=this.figures.iterator,e=0,i=0,s=0,n=0,o=0;for(;t.next();){let r=t.value;if(!r.isFilled)continue;e=r.startX,i=r.startY;let a=r.segments.iterator;for(;a.next();){let h=a.value;s=h.endX,n=h.endY,h.type===1||h.type!==5&&(o+=e*n-i*s),e=s,i=n}o+=e*r.startY-i*r.startX}return Math.abs(o)/2}else if(this.type===2){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return t*e}else if(this.type===3){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return Math.PI*t/2*e/2}else return 0}get polygonLength(){if(this.type===4){let t=this.figures.iterator,e=0,i=0,s=0,n=0,o=0;for(;t.next();){let r=t.value;e=r.startX,i=r.startY;let a=r.segments.iterator;for(;a.next();){let l=a.value;s=l.endX,n=l.endY,l.type===1||l.type!==5&&(o+=Math.sqrt((s-e)*(s-e)+(n-i)*(n-i))),e=s,i=n}let h=r.segments.last();h&&h.isClosed&&(s=r.startX,n=r.startY,o+=Math.sqrt((s-e)*(s-e)+(n-i)*(n-i)))}return o}else if(this.type===2){let t=Math.abs(this.startX-this.endX),e=Math.abs(this.startY-this.endY);return t*2+e*2}else if(this.type===3){let t=Math.abs(this.startX-this.endX)/2,e=Math.abs(this.startY-this.endY)/2;if(t+e===0)return 0;let i=(t-e)*(t-e)/((t+e)*(t+e)),s=i,n=1+s/4;return s*=i,n+=s/64,s*=i,n+=s/256,s*=i,n+=s*25/16384,s*=i,n+=s*49/65536,s*=i,n+=s*441/1048576,Math.PI*(t+e)*n}else{let t=this.startX,e=this.startY,i=this.endX,s=this.endY;return Math.sqrt((i-t)*(i-t)+(s-e)*(s-e))}}static computeConvexHull(t){t.sort((s,n)=>s.x===n.x?n.y-s.y:n.x-s.x);let e=[];for(let s=0;s<t.length;s++){for(;e.length>=2&&t[s].compareWithLineSegmentPoint(e[e.length-2],e[e.length-1])>=0;)e.pop();e.push(t[s])}e.pop();let i=[];for(let s=t.length-1;s>=0;s--){for(;i.length>=2&&t[s].compareWithLineSegmentPoint(i[i.length-2],i[i.length-1])>=0;)i.pop();i.push(t[s])}return i.pop(),e.concat(i)}static generatePolygon(t,e,i){e===void 0&&(e=0),i===void 0&&(i=!0);let s=new wt;if(t.length>1)if(e>0)if(i){t.push(t[0]),t.push(t[1]);let n=!0,o=new zt(0,0,i,!1);for(let a=1;a<t.length;a++){let h=(t[a-1].x+t[a].x)/2,l=(t[a-1].y+t[a].y)/2,u=t[a-1].distanceSquaredPoint(t[a]),c=.5*e/Math.sqrt(u);if(c<.5){let d=t[a-1].x+(t[a].x-t[a-1].x)*c,f=t[a-1].y+(t[a].y-t[a-1].y)*c;if(n?(n=!1,o.startX=d,o.startY=f):o.add(new mt(3,d,f,t[a-1].x,t[a-1].y,t[a-1].x,t[a-1].y)),a<t.length-1){let p=t[a].x+(t[a-1].x-t[a].x)*c,g=t[a].y+(t[a-1].y-t[a].y)*c;o.add(new mt(2,p,g))}}else n?(n=!1,o.startX=h,o.startY=l):o.add(new mt(3,h,l,t[a-1].x,t[a-1].y,t[a-1].x,t[a-1].y))}let r=o.segments.last();r&&r.close(),s.add(o)}else{let n=new zt(t[0].x,t[0].y,!1,!1);for(let o=1;o<t.length;o++){let r=(t[o-1].x+t[o].x)/2,a=(t[o-1].y+t[o].y)/2,h=t[o-1].distanceSquaredPoint(t[o]),l=.5*e/Math.sqrt(h);if(l<.5){if(o>1){let d=t[o-1].x+(t[o].x-t[o-1].x)*l,f=t[o-1].y+(t[o].y-t[o-1].y)*l;n.add(new mt(3,d,f,t[o-1].x,t[o-1].y,t[o-1].x,t[o-1].y))}let u=t[o].x+(t[o-1].x-t[o].x)*l,c=t[o].y+(t[o-1].y-t[o].y)*l;n.add(new mt(2,u,c))}else o>1&&n.add(new mt(3,r,a,t[o-1].x,t[o-1].y,t[o-1].x,t[o-1].y));o===t.length-1&&n.add(new mt(2,t[o].x,t[o].y))}s.add(n)}else{let n=new zt(t[0].x,t[0].y,i,!1);for(let o=1;o<t.length;o++)n.add(new mt(2,t[o].x,t[o].y));if(i){let o=n.segments.last();o&&o.close()}s.add(n)}return s}}wt.stringify=wt.stringify,wt.stringifyFixed=wt.stringifyFixed,wt.fillPath=wt.fillPath,wt.parse=wt.parse;class zt{n;Li;Ai;Nc;um;Hi;constructor(t,e,i,s,n){i===void 0&&(i=!0),s===void 0&&(s=!0),n===void 0&&(n=!1),this.n=2|(i?4:0)|(s?8:0)|(n?16:0),t!==void 0?this.Li=t:this.Li=0,e!==void 0?this.Ai=e:this.Ai=0,this.Nc=new q,this.um=this.Nc.rt,this.Hi=null}copy(){let t=new zt;t.n=this.n&-2,t.Li=this.Li,t.Ai=this.Ai;let e=this.Nc.r,i=e.length,s=t.Nc;for(let n=0;n<i;n++){let o=e[n].copy();s.add(o)}return t.um=this.um,t.Hi=this.Hi,t}equalsApprox(t){if(!(t instanceof zt)||!C.c(this.startX,t.startX)||!C.c(this.startY,t.startY))return!1;let e=this.segments.r,i=t.segments.r,s=e.length;if(s!==i.length)return!1;for(let n=0;n<s;n++){let o=e[n],r=i[n];if(!o.equalsApprox(r))return!1}return!0}toString(t){t===void 0&&(t=-1);let e="";if(t<0)e="M"+this.startX.toString()+" "+this.startY.toString();else{let n=o=>o===0?"0":o.toFixed(t);e="M"+n(this.startX)+" "+n(this.startY)}let i=this.segments.r,s=i.length;for(let n=0;n<s;n++){let o=i[n];e+=" "+o.toString(t)}return e}get u(){return(this.n&1)!==0}set u(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}k(){this.u=!0;let t=this.segments;t.k();let e=t.r,i=t.length;for(let s=0;s<i;s++)e[s].k();return this}OP(){if(this.yt)return!0;let t=this.segments;if(this.um!==t.rt)return!0;for(let e of t)if(e.yt)return!0;return!1}iR(){this.yt=!1,this.Hi=null;let t=this.segments;this.um=t.rt;for(let e of t)e.yt=!1,e.Ks=null}get isFilled(){return(this.n&4)!==0}set isFilled(t){this.u&&m.L(this,t),t?this.n|=4:this.n&=-5}get isShadowed(){return(this.n&8)!==0}set isShadowed(t){this.u&&m.L(this,t),t?this.n|=8:this.n&=-9}get isEvenOdd(){return(this.n&16)!==0}set isEvenOdd(t){this.u&&m.L(this,t),t?this.n|=16:this.n&=-17}get startX(){return this.Li}set startX(t){this.u&&m.L(this,t),this.Li=t,this.Hi=null,this.yt=!0}get startY(){return this.Ai}set startY(t){this.u&&m.L(this,t),this.Ai=t,this.Hi=null,this.yt=!0}get segments(){return this.Nc}set segments(t){this.u&&m.L(this,t),this.Nc=t,this.Hi=null,this.yt=!0}add(t){return this.Nc.add(t),this.Hi=null,this}EP(t,e,i){let s=this,n=s.startX,o=s.startY,r=n,a=o,h=s.segments.r,l=h.length;for(let u=0;u<l;u++){let c=h[u];switch(c.type){case 1:r=c.endX,a=c.endY,n=c.endX,o=c.endY;break;case 2:if(C.Ve(n,o,c.endX,c.endY,i,t,e))return!0;n=c.endX,o=c.endY;break;case 3:if(C.tx(n,o,c.point1X,c.point1Y,c.point2X,c.point2Y,c.endX,c.endY,.5,t,e,i))return!0;n=c.endX,o=c.endY;break;case 4:if(C.FP(n,o,c.point1X,c.point1Y,c.endX,c.endY,.5,t,e,i))return!0;n=c.endX,o=c.endY;break;case 5:case 6:let d=c.type===5?c.To(s):c.Za(s,n,o),f=d.length,p=c.type===5?c.centerX:c.endX,g=c.type===5?c.centerY:c.endY;if(f===0){if(C.Ve(n,o,p,g,i,t,e))return!0;n=p,o=g;break}let y=null;for(let b=0;b<f;b++)if(y=d[b],b===0&&C.Ve(n,o,y[0],y[1],i,t,e)||C.tx(y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7],.5,t,e,i))return!0;y!==null&&(n=y[6],o=y[7]);break;default:m.o("Unknown Segment type: "+c.type)}if(c.isClosed&&(n!==r||o!==a)&&C.Ve(n,o,r,a,i,t,e))return!0}return!1}}var ni=(x=>(x[x.Move=1]="Move",x[x.Line=2]="Line",x[x.Bezier=3]="Bezier",x[x.QuadraticBezier=4]="QuadraticBezier",x[x.Arc=5]="Arc",x[x.SvgArc=6]="SvgArc",x))(ni||{});class mt{W;n;ni;oi;mn;Ll;Al;yr;Ks;constructor(t,e,i,s,n,o,r,a){if(V.Je(this),t===void 0&&(t=2),this.W=t,this.n=2,e!==void 0?this.ni=e:this.ni=0,i!==void 0?this.oi=i:this.oi=0,s===void 0&&(s=0),n===void 0&&(n=0),o===void 0&&(o=0),r===void 0&&(r=0),t===6){let h=o;h=h%360,h<0&&(h+=360),this.mn=h,this.Ll=0,this.Al=Math.max(s,0),this.yr=Math.max(n,0),typeof r=="boolean"?r&&(this.isLargeArc=!0):typeof r=="number"&&r&&(this.isLargeArc=!0),a&&(this.isClockwiseArc=!0)}else this.mn=s,this.Ll=n,t===5&&(o=Math.max(o,0)),this.Al=o,typeof r=="number"?(t===5&&(r=Math.max(r,0)),this.yr=r):this.yr=0;this.Ks=null}copy(){let t=new mt;return t.W=this.W,t.n=this.n&-2,t.ni=this.ni,t.oi=this.oi,t.mn=this.mn,t.Ll=this.Ll,t.Al=this.Al,t.yr=this.yr,t}equalsApprox(t){if(!(t instanceof mt)||this.type!==t.type||this.isClosed!==t.isClosed)return!1;switch(this.type){case 1:case 2:return C.c(this.endX,t.endX)&&C.c(this.endY,t.endY);case 3:return C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)&&C.c(this.point1X,t.point1X)&&C.c(this.point1Y,t.point1Y)&&C.c(this.point2X,t.point2X)&&C.c(this.point2Y,t.point2Y);case 4:return C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)&&C.c(this.point1X,t.point1X)&&C.c(this.point1Y,t.point1Y);case 5:return C.c(this.startAngle,t.startAngle)&&C.c(this.sweepAngle,t.sweepAngle)&&C.c(this.centerX,t.centerX)&&C.c(this.centerY,t.centerY)&&C.c(this.radiusX,t.radiusX)&&C.c(this.radiusY,t.radiusY);case 6:return this.isClockwiseArc===t.isClockwiseArc&&this.isLargeArc===t.isLargeArc&&C.c(this.xAxisRotation,t.xAxisRotation)&&C.c(this.endX,t.endX)&&C.c(this.endY,t.endY)&&C.c(this.radiusX,t.radiusX)&&C.c(this.radiusY,t.radiusY);default:return!1}}fe(t){t in ni?this.type=t:m.cr(this,t)}toString(t){t===void 0&&(t=-1);let e=s=>s===0?"0":s.toFixed(t),i="";switch(this.type){case 1:t<0?i="M"+this.endX.toString()+" "+this.endY.toString():i="M"+e(this.endX)+" "+e(this.endY);break;case 2:t<0?i="L"+this.endX.toString()+" "+this.endY.toString():i="L"+e(this.endX)+" "+e(this.endY);break;case 3:t<0?i="C"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.point2X.toString()+" "+this.point2Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():i="C"+e(this.point1X)+" "+e(this.point1Y)+" "+e(this.point2X)+" "+e(this.point2Y)+" "+e(this.endX)+" "+e(this.endY);break;case 4:t<0?i="Q"+this.point1X.toString()+" "+this.point1Y.toString()+" "+this.endX.toString()+" "+this.endY.toString():i="Q"+e(this.point1X)+" "+e(this.point1Y)+" "+e(this.endX)+" "+e(this.endY);break;case 5:t<0?i="B"+this.startAngle.toString()+" "+this.sweepAngle.toString()+" "+this.centerX.toString()+" "+this.centerY.toString()+" "+this.radiusX.toString()+" "+this.radiusY.toString():i="B"+e(this.startAngle)+" "+e(this.sweepAngle)+" "+e(this.centerX)+" "+e(this.centerY)+" "+e(this.radiusX)+" "+e(this.radiusY);break;case 6:t<0?i="A"+this.radiusX.toString()+" "+this.radiusY.toString()+" "+this.xAxisRotation.toString()+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+this.endX.toString()+" "+this.endY.toString():i="A"+e(this.radiusX)+" "+e(this.radiusY)+" "+e(this.xAxisRotation)+" "+(this.isLargeArc?1:0)+" "+(this.isClockwiseArc?1:0)+" "+e(this.endX)+" "+e(this.endY);break;default:i=ni[this.type]}return i+(this.isClosed?"z":"")}static Move=1;static Line=2;static Bezier=3;static QuadraticBezier=4;static Arc=5;static SvgArc=6;get u(){return(this.n&1)!==0}set u(t){t?this.n|=1:this.n&=-2}get yt(){return(this.n&2)!==0}set yt(t){t?this.n|=2:this.n&=-3}k(){return this.u=!0,this}close(){return this.isClosed=!0,this}To(t){if(this.Ks!==null&&t.yt===!1)return this.Ks;let e=this.radiusX,i=this.radiusY;if(i===void 0&&(i=e),e===0||i===0)return this.Ks=[],this.Ks;let s=this.mn,n=this.Ll,o=C.KL(0,0,e<i?e:i,this.startAngle,this.startAngle+this.sweepAngle,!1);if(e!==i){let a=Nt.l();a.Ue(),e<i?a.et(1,i/e):a.et(e/i,1),wt.JL(o,a),Nt.i(a)}let r=o.length;for(let a=0;a<r;a++){let h=o[a];h[0]+=s,h[1]+=n,h[2]+=s,h[3]+=n,h[4]+=s,h[5]+=n,h[6]+=s,h[7]+=n}return this.Ks=o,this.Ks}Za(t,e,i){if(this.Ks!==null&&t.yt===!1)return this.Ks;if(this.radiusX===0||this.radiusY===0)return this.Ks=[],this.Ks;let s=e,n=i,o=this.Al,r=this.yr;o===0&&(o=1e-4),r===0&&(r=1e-4);let a=this.mn*(Math.PI/180),h=this.isLargeArc,l=this.isClockwiseArc,u=this.ni,c=this.oi,d=Math.cos(a),f=Math.sin(a),p=d*(s-u)/2+f*(n-c)/2,g=-f*(s-u)/2+d*(n-c)/2,y=p*p/(o*o)+g*g/(r*r);y>1&&(o*=Math.sqrt(y),r*=Math.sqrt(y));let b=(h===l?-1:1)*Math.sqrt((o*o*r*r-o*o*g*g-r*r*p*p)/(o*o*g*g+r*r*p*p));isNaN(b)&&(b=0);let v=b*o*g/r,w=b*-r*p/o;isNaN(v)&&(v=0),isNaN(w)&&(w=0);let k=(s+u)/2+d*v-f*w,S=(n+c)/2+f*v+d*w,N=(it,_)=>Math.sqrt(it*it+_*_),D=(it,_,at,ct)=>(it*at+_*ct)/(N(it,_)*N(at,ct)),L=(it,_,at,ct)=>(it*ct<_*at?-1:1)*Math.acos(D(it,_,at,ct)),M=L(1,0,(p-v)/o,(g-w)/r),A=(p-v)/o,F=(g-w)/r,O=(-p-v)/o,E=(-g-w)/r,B=L(A,F,O,E),X=D(A,F,O,E);X<=-1?B=Math.PI:X>=1&&(B=0),!l&&B>0&&(B=B-2*Math.PI),l&&B<0&&(B=B+2*Math.PI);let z=o>r?o:r,U=o>r?1:o/r,tt=o>r?r/o:1,nt=C.KL(0,0,z,M,M+B,!0),Z=Nt.l();return Z.Ue(),Z.Xs(k,S),Z.ks(this.mn,0,0),Z.et(U,tt),wt.JL(nt,Z),Nt.i(Z),this.Ks=nt,this.Ks}get isClosed(){return(this.n&8)!==0}set isClosed(t){this.isClosed!==t&&(t?this.n|=8:this.n&=-9,this.yt=!0)}get type(){return this.W}set type(t){this.u&&m.L(this,t),this.W=t,this.yt=!0}get endX(){return this.ni}set endX(t){this.u&&m.L(this,t),this.ni=t,this.yt=!0}get endY(){return this.oi}set endY(t){this.u&&m.L(this,t),this.oi=t,this.yt=!0}get point1X(){return this.mn}set point1X(t){this.u&&m.L(this,t),this.mn=t,this.yt=!0}get point1Y(){return this.Ll}set point1Y(t){this.u&&m.L(this,t),this.Ll=t,this.yt=!0}get point2X(){return this.Al}set point2X(t){this.u&&m.L(this,t),this.Al=t,this.yt=!0}get point2Y(){return this.yr}set point2Y(t){this.u&&m.L(this,t),this.yr=t,this.yt=!0}get centerX(){return this.mn}set centerX(t){this.u&&m.L(this,t),this.mn=t,this.yt=!0}get centerY(){return this.Ll}set centerY(t){this.u&&m.L(this,t),this.Ll=t,this.yt=!0}get radiusX(){return this.Al}set radiusX(t){t<0&&m.J(t,">= zero",mt,"radiusX"),this.u&&m.L(this,t),this.Al=t,this.yt=!0}get radiusY(){return this.yr}set radiusY(t){t<0&&m.J(t,">= zero",mt,"radiusY"),this.u&&m.L(this,t),this.yr=t,this.yt=!0}get startAngle(){return this.ni}set startAngle(t){this.u&&m.L(this,t),t=t%360,t<0&&(t+=360),this.ni=t,this.yt=!0}get sweepAngle(){return this.oi}set sweepAngle(t){this.u&&m.L(this,t),t>360&&(t=360),t<-360&&(t=-360),this.oi=t,this.yt=!0}get isClockwiseArc(){return(this.n&4)!==0}set isClockwiseArc(t){this.u&&m.L(this,t),t?this.n|=4:this.n&=-5,this.yt=!0}get isLargeArc(){return(this.n&16)!==0}set isLargeArc(t){this.u&&m.L(this,t),t?this.n|=16:this.n&=-17,this.yt=!0}get xAxisRotation(){return this.mn}set xAxisRotation(t){this.u&&m.L(this,t),t=t%360,t<0&&(t+=360),this.mn=t,this.yt=!0}}class Qt{a;hx;cx;dm;gm;mm;pm;ym;wm;xm;bm;km;Pm;Sm;Do;Mm;Nm;Ps;Ti;constructor(){this.a=null,this.hx=new P(0,0).k(),this.cx=new P(0,0).k(),this.dm=0,this.gm=0,this.mm=1,this.pm="",this.ym="",this.wm=!1,this.xm=!1,this.bm=0,this.km=0,this.Pm=!1,this.Sm=!1,this.Do=!1,this.Mm=null,this.Nm=0,this.Ps=null,this.Ti=null}copy(){let t=new Qt;return this.clone(t)}clone(t){return t.a=this.a,t.hx.h(this.viewPoint),t.cx.h(this.documentPoint),t.dm=this.dm,t.gm=this.gm,t.mm=this.mm,t.pm=this.pm,t.ym=this.ym,t.wm=this.wm,t.xm=this.xm,t.bm=this.bm,t.km=this.km,t.Pm=this.Pm,t.Sm=this.Sm,t.Do=this.Do,t.Mm=this.Mm,t.Nm=this.Nm,t.Ps=this.Ps,t.Ti=this.Ti,t}toString(){let t="^";return this.modifiers!==0&&(t+="M:"+this.modifiers),this.button!==0&&(t+="B:"+this.button),this.key!==""&&(t+="K:"+this.key),this.clickCount!==0&&(t+="C:"+this.clickCount),this.delta!==0&&(t+="D:"+this.delta),this.handled&&(t+="h"),this.bubbles&&(t+="b"),this.documentPoint!==null&&(t+="@"+this.documentPoint.toString()),t}get diagram(){return this.a}set diagram(t){this.a=t}get viewPoint(){return this.hx}set viewPoint(t){this.hx.h(t)}get documentPoint(){return this.cx}set documentPoint(t){this.cx.h(t)}getMultiTouchViewPoint(t,e){let i=this.diagram;return i===null||i._L(this.event,t,e),e}getMultiTouchDocumentPoint(t,e){let i=this.diagram;return i===null||(i._L(this.event,t,e),e.h(i.transformViewToDoc(e))),e}get modifiers(){return this.dm}set modifiers(t){this.dm=t}get button(){return this.gm}set button(t){if(this.gm=t,this.event===null)switch(t){case 0:this.buttons=1;return;case 1:this.buttons=4;return;case 2:this.buttons=2;return}}get buttons(){return this.mm}set buttons(t){this.mm=t}get key(){return this.pm}set key(t){this.pm=t}get code(){return this.ym}set code(t){this.ym=t}get down(){return this.wm}set down(t){this.wm=t}get up(){return this.xm}set up(t){this.xm=t}get clickCount(){return this.bm}set clickCount(t){this.bm=t}get delta(){return this.km}set delta(t){this.km=t}get isMultiTouch(){return this.Pm}set isMultiTouch(t){this.Pm=t}get handled(){return this.Sm}set handled(t){this.Sm=t}get bubbles(){return this.Do}set bubbles(t){this.Do=t}get event(){return this.Mm}set event(t){this.Mm=t}get isTouchEvent(){let t=this.event;return t===null?!1:t.pointerType==="touch"||t.pointerType==="pen"}get timestamp(){return this.Nm}set timestamp(t){this.Nm=t}get targetDiagram(){return this.Ps}set targetDiagram(t){this.Ps=t}get targetObject(){return this.Ti}set targetObject(t){this.Ti=t}get control(){return(this.modifiers&1)!==0}set control(t){this.modifiers=t?this.modifiers|1:this.modifiers&-2}get shift(){return(this.modifiers&4)!==0}set shift(t){this.modifiers=t?this.modifiers|4:this.modifiers&-5}get alt(){return(this.modifiers&2)!==0}set alt(t){this.modifiers=t?this.modifiers|2:this.modifiers&-3}get meta(){return(this.modifiers&8)!==0}set meta(t){this.modifiers=t?this.modifiers|8:this.modifiers&-9}get left(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===0:(this.buttons&1)!==0}set left(t){t?this.buttons|=1:this.buttons&=-2}get right(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===2:(this.buttons&2)!==0}set right(t){t?this.buttons|=2:this.buttons&=-3}get middle(){let t=this.event;return t!==null&&(t.type==="mousedown"||t.type==="mouseup"||t.type==="pointerdown"||t.type==="pointerup")?this.button===1:(this.buttons&4)!==0}set middle(t){t?this.buttons|=4:this.buttons&=-5}get commandKey(){let t=this.code,e=this.key;return"cxvyzagCXVYZAG".includes(e)?e.toLowerCase():t==="KeyC"?"c":t==="KeyX"?"x":t==="KeyV"?"v":t==="KeyY"?"y":t==="KeyZ"?"z":t==="KeyA"?"a":t==="KeyG"?"g":t!==""?t:e}}class wi{a;Pt;Cm;Lm;constructor(){this.a=null,this.Pt="",this.Cm=null,this.Lm=null}copy(){let t=new wi;return t.a=this.a,t.Pt=this.Pt,t.Cm=this.Cm,t.Lm=this.Lm,t}toString(){let t="*"+this.name;return this.subject!==null&&(t+=":"+this.subject.toString()),this.parameter!==null&&(t+="("+this.parameter.toString()+")"),t}get diagram(){return this.a}set diagram(t){this.a=t}get name(){return this.Pt}set name(t){this.Pt=t}get subject(){return this.Cm}set subject(t){this.Cm=t}get parameter(){return this.Lm}set parameter(t){this.Lm=t}}var Ei=(x=>(x[x.Transaction=1]="Transaction",x[x.Property=2]="Property",x[x.Insert=3]="Insert",x[x.Remove=4]="Remove",x))(Ei||{});class Xe{Du;Am;pn;Ce;a;vu;Cc;Lc;Ac;Tc;constructor(){this.Du=2,this.Am="",this.pn="",this.Ce=null,this.a=null,this.vu=null,this.Cc=null,this.Lc=null,this.Ac=null,this.Tc=null}static Transaction=1;static Property=2;static Insert=3;static Remove=4;clear(){this.Ce=null,this.a=null,this.vu=null,this.Cc=null,this.Lc=null,this.Ac=null,this.Tc=null}copy(){let t=new Xe;t.Du=this.Du,t.Am=this.Am,t.pn=this.pn,t.Ce=this.Ce,t.a=this.a,t.vu=this.vu;let e=this.Cc;return m.$(e)&&m.it(e.copyFrozen)?t.Cc=e.copyFrozen():t.Cc=e,e=this.Lc,m.$(e)&&m.it(e.copyFrozen)?t.Lc=e.copyFrozen():t.Lc=e,e=this.Ac,m.$(e)&&m.it(e.copyFrozen)?t.Ac=e.copyFrozen():t.Ac=e,e=this.Tc,m.$(e)&&m.it(e.copyFrozen)?t.Tc=e.copyFrozen():t.Tc=e,t}fe(t){t in Ei?this.change=t:m.cr(this,t)}toString(){let t="";return this.change===1?t+="* ":this.change===2?t+=this.model!==null?"!m":"!d":t+=(this.model!==null?"!m":"!d")+this.change,this.propertyName&&typeof this.propertyName=="string"&&(t+=" "+this.propertyName),this.modelChange&&this.modelChange!==this.propertyName&&(t+=" "+this.modelChange),t+=": ",this.change===1?this.oldValue!==null&&(t+=" "+this.oldValue):(this.object!==null&&(t+=m.toString(this.object)),this.oldValue!==null&&(t+=" old: "+m.toString(this.oldValue)),this.oldParam!==null&&(t+=" "+this.oldParam),this.newValue!==null&&(t+=" new: "+m.toString(this.newValue)),this.newParam!==null&&(t+=" "+this.newParam)),t}getValue(t){return t?this.oldValue:this.newValue}getParam(t){return t?this.oldParam:this.newParam}canUndo(){return this.model!==null||this.diagram!==null}undo(){this.canUndo()&&(this.model!==null?this.model.changeState(this,!0):this.diagram!==null&&this.diagram.tA(this,!0))}canRedo(){return this.model!==null||this.diagram!==null}redo(){this.canRedo()&&(this.model!==null?this.model.changeState(this,!1):this.diagram!==null&&this.diagram.tA(this,!1))}get model(){return this.Ce}set model(t){this.Ce=t}get diagram(){return this.a}set diagram(t){this.a=t}get change(){return this.Du}set change(t){this.Du=t}get modelChange(){return this.Am}set modelChange(t){this.Am=t}get propertyName(){return this.pn}set propertyName(t){this.pn=t}get isTransactionFinished(){return this.Du===1&&(this.pn==="CommittedTransaction"||this.pn==="FinishedUndo"||this.pn==="FinishedRedo")}get object(){return this.vu}set object(t){this.vu=t}get oldValue(){return this.Cc}set oldValue(t){this.Cc=t}get oldParam(){return this.Lc}set oldParam(t){this.Lc=t}get newValue(){return this.Ac}set newValue(t){this.Ac=t}get newParam(){return this.Tc}set newParam(t){this.Tc=t}}class oi{eA;Pt;VP;constructor(){this.eA=new q().k(),this.Pt="",this.VP=!1}toString(t){let e="Transaction: "+this.name+" "+this.changes.count.toString()+(this.isComplete?"":", incomplete");if(t!==void 0&&t>0){let i=this.changes.count;for(let s=0;s<i;s++){let n=this.changes.elt(s);n!==null&&(e+=`
|
|
4
4
|
`+n.toString())}}return e}clear(){let t=this.changes;t.ce();for(let e=t.count-1;e>=0;e--){let i=t.elt(e);i!==null&&i.clear()}t.clear(),t.k()}canUndo(){return this.isComplete}undo(){if(this.canUndo())for(let t=this.changes.count-1;t>=0;t--){let e=this.changes.elt(t);e!==null&&e.undo()}}canRedo(){return this.isComplete}redo(){if(!this.canRedo())return;let t=this.changes.count;for(let e=0;e<t;e++){let i=this.changes.elt(e);i!==null&&i.redo()}}oR(t){let e=this.changes;for(let i=e.count-1;i>=t;i--){let s=e.elt(i);s!==null&&s.undo(),e.ce(),e.removeAt(i)}e.k()}thaw(){this.changes.ce()}optimize(){if(!this.isComplete)return;let t=this.changes;t.ce();let e=new Map;for(let s=0;s<t.count;s++){let n=t.elt(s);if(n===null||n.change!==2||!n.object)continue;let o=e.get(n.object);o||(o=new Map,e.set(n.object,o));let r=o.get(n.propertyName);r===void 0?o.set(n.propertyName,-1):(r>0&&t.setElt(r,null),o.set(n.propertyName,s))}let i=0;for(let s=0;s<t.count;s++){let n=t.elt(s);n!==null&&(s>i&&t.setElt(i,n),i++)}for(;t.length>i;)t.pop();t.k()}get changes(){return this.eA}get name(){return this.Pt}set name(t){this.Pt=t}get isComplete(){return this.VP}set isComplete(t){this.VP=t}}class vi{fx;Be;iA;Hs;BP;Tm;Tl;zP;XP;yn;Dc;ux;qs;gx;mx;Dm;yx;constructor(t){this.fx=new V,this.Be=!1,this.iA=new q().k(),this.Hs=-1,this.BP=999,this.qs=!1,this.Tm=null,this.Tl=0,this.zP=!1,this.XP=23,this.yn=new q().k(),this.Dc=new q,this.ux=!0,this.gx=!1,this.mx=!1,this.Dm=!1,this.yx=!1,t&&Object.assign(this,t)}toString(t){let e="UndoManager "+this.historyIndex+"<"+this.history.count+"<="+this.maxHistoryLength;e+="[";let i=this.nestedTransactionNames.count;for(let s=0;s<i;s++)s>0&&(e+=" "),e+=this.nestedTransactionNames.elt(s);if(e+="]",t!==void 0&&t>0){i=this.history.count;for(let s=0;s<i;s++)e+=`
|
|
5
5
|
`+this.history.elt(s).toString(t-1)}return e}clear(){let t=this.history;t.ce();for(let e=t.count-1;e>=0;e--){let i=t.elt(e);i!==null&&i.clear()}t.clear(),this.Hs=-1,t.k(),this.qs=!1,this.Tm=null,this.Tl=0,this.yn.ce(),this.yn.clear(),this.yn.k(),this.Dc.clear(),this.gx=!1,this.mx=!1,this.Dm=!1,this.yx=!1}copyProperties(t){this.isEnabled=t.isEnabled,this.maxHistoryLength=t.maxHistoryLength,this.vm=t.vm}addModel(t){this.fx.add(t)}removeModel(t){this.fx.delete(t)}startTransaction(t){if(t===void 0&&(t=""),t===null&&(t=""),this.isUndoingRedoing)return!1;this.ux===!0&&(this.ux=!1,this.Tl++,this.Dl||this.vl("StartingFirstTransaction",t,this.currentTransaction),this.Tl>0&&this.Tl--),this.isEnabled&&(this.yn.ce(),this.yn.add(t),this.yn.k(),this.currentTransaction===null?this.Dc.add(0):this.Dc.add(this.currentTransaction.changes.count)),this.Tl++;let e=this.transactionLevel===1;return e&&(this.Dl||this.vl("StartedTransaction",t,this.currentTransaction)),e}commitTransaction(t){return t===void 0&&(t=""),this.sA(!0,t)}rollbackTransaction(){return this.sA(!1,"")}sA(t,e){if(this.isUndoingRedoing)return!1;this.vm&&this.transactionLevel<1&&m.ne("Ending transaction without having started a transaction: "+e);let i=this.transactionLevel===1,s=this.currentTransaction;i&&t&&(this.Dl||this.vl("CommittingTransaction",e,s));let n=0;if(this.transactionLevel>0&&(this.Tl--,this.isEnabled)){let o=this.yn.count;o>0&&(e===""&&(e=this.yn.elt(0)),this.yn.ce(),this.yn.removeAt(o-1),this.yn.k());let r=this.Dc.count;r>0&&(n=this.Dc.elt(r-1),this.Dc.removeAt(r-1))}if(i){if(t){if(this.Dm=!1,s===null&&e!==""&&(s=this.currentTransaction),this.isEnabled&&s!==null){let o=s;o.isComplete||(o.isComplete=!0,o.name=e),this.discardHistoryAfterIndex();let r=this.history;r.ce();let a=this.maxHistoryLength;if(a>=0){if(a===0)r.clear();else if(r.count>=a){let h=r.elt(0);h!==null&&h.clear(),r.removeAt(0),this.Hs--}}a!==0&&(r.count===0||r.get(r.count-1)!==o)&&(r.add(o),this.Hs++),r.k(),s=o}this.Dl||this.vl("CommittedTransaction",e,s)}else{this.qs=!0;try{this.isEnabled&&s!==null&&(s.isComplete=!0,s.undo())}finally{this.Dl||this.vl("RolledBackTransaction",e,s),this.qs=!1}s!==null&&s.clear()}return this.Tm=null,this.wx&&this.clear(),this.wx=!1,this.xx=!1,!0}else return this.isEnabled&&!t&&s!==null&&s.oR(n),!1}discardHistoryAfterIndex(){if(this.isUndoingRedoing||!this.canRedo())return;let t=this.history;t.ce();for(let e=t.count-1;e>this.historyIndex;e--){let i=t.elt(e);i!==null&&i.clear(),t.removeAt(e),this.Dm=!0}t.k()}thaw(){this.history.ce()}canUndo(){if(!this.isEnabled||this.transactionLevel>0)return!1;let t=this.transactionToUndo;return!!(t!==null&&t.canUndo())}undo(){if(!this.canUndo())return;let t=this.transactionToUndo;if(t!==null)try{this.qs=!0,this.vl("StartingUndo","Undo",t),this.Hs--,t.undo()}catch(e){m.ne("undo error: "+e.toString())}finally{this.vl("FinishedUndo","Undo",t),this.qs=!1}}canRedo(){if(!this.isEnabled||this.transactionLevel>0)return!1;let t=this.transactionToRedo;return!!(t!==null&&t.canRedo())}redo(){if(!this.canRedo())return;let t=this.transactionToRedo;if(t!==null)try{this.qs=!0,this.vl("StartingRedo","Redo",t),this.Hs++,t.redo()}catch(e){m.ne("redo error: "+e.toString())}finally{this.vl("FinishedRedo","Redo",t),this.qs=!1}}vl(t,e,i){let s=new Xe;s.change=1,s.propertyName=t,s.object=i,s.oldValue=e;let n=this.models;for(;n.next();){let o=n.value;s.model=o,o.rR(s)}}handleChanged(t){if(this.isEnabled&&!this.isUndoingRedoing&&!this.skipsEvent(t)){let e=this.currentTransaction;e===null&&(e=new oi,this.Tm=e);let i=t.copy(),s=e.changes;if(s.ce(),s.add(i),s.k(),this.vm&&this.XP>0&&this.transactionLevel<=0&&!this.ux){let n=t.diagram;if(n!==null&&n.Qa===!1)return;m.ne("Change not within a transaction: "+i.toString()),this.XP--}}}skipsEvent(t){if(t===null||t.change===1)return!0;let e=t.object;if(e===null)return!1;if(e.layer!==void 0){let i=e.layer;if(i!==null&&i.isTemporary)return!0}else if(e.isTemporary)return!0;return!1}get models(){return this.fx.iterator}get isEnabled(){return this.Be}set isEnabled(t){this.Be=t}get transactionToUndo(){return this.historyIndex>=0&&this.historyIndex<=this.history.count-1?this.history.elt(this.historyIndex):null}get transactionToRedo(){return this.historyIndex<this.history.count-1?this.history.elt(this.historyIndex+1):null}get isUndoingRedoing(){return this.qs}get history(){return this.iA}get maxHistoryLength(){return this.BP}set maxHistoryLength(t){this.BP=t}get historyIndex(){return this.Hs}get currentTransaction(){return this.Tm}get transactionLevel(){return this.Tl}get isInTransaction(){return this.Tl>0}get vm(){return this.zP}set vm(t){this.zP=t}get nestedTransactionNames(){return this.yn}get wx(){return this.gx}set wx(t){this.gx=t}get xx(){return this.mx}set xx(t){this.mx=t}get Dl(){return this.yx}set Dl(t){this.yx=t}get isJustDiscarded(){return this.Dm}}class $t{a;Pt;Be;GP;YP;Fm;nA;constructor(){V.Je(this),this.a=Y.Rm(),this.Pt="",this.Be=!0,this.GP=!1,this.YP=null,this.nA=new Qt,this.Fm=-1}get diagram(){return this.a}set diagram(t){t instanceof Y&&(this.a=t)}toString(){return this.name!==""?this.name+" Tool":m.Gn(this.constructor)}updateAdornments(t){}canStart(){return this.isEnabled}doStart(){}doActivate(){this.isActive=!0}doDeactivate(){this.isActive=!1}doStop(){}doCancel(){this.transactionResult=null,this.stopTool()}stopTool(){let t=this.diagram;t.currentTool===this&&(t.currentTool=null,t.currentCursor="")}doMouseDown(){!this.isActive&&this.canStart()&&this.doActivate()}doMouseMove(){}doMouseUp(){this.stopTool()}doMouseWheel(){}canStartMultiTouch(){return!0}standardPinchZoomStart(){let t=this.diagram,e=t.lastInput,i=e.getMultiTouchViewPoint(0,P.z(NaN,NaN)),s=e.getMultiTouchViewPoint(1,P.z(NaN,NaN));if(!i.isReal()||!s.isReal()){P.i(i),P.i(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){t.KP=t.scale;let n=s.x-i.x,o=s.y-i.y,r=Math.sqrt(n*n+o*o);t.HP=r,e.bubbles=!1}P.i(i),P.i(s)}standardPinchZoomMove(){let t=this.diagram,e=t.lastInput,i=e.getMultiTouchViewPoint(0,P.z(NaN,NaN)),s=e.getMultiTouchViewPoint(1,P.z(NaN,NaN));if(!i.isReal()||!s.isReal()){P.i(i),P.i(s);return}if(this.doCancel(),t.getInputOption("hasGestureZoom")){let n=s.x-i.x,o=s.y-i.y,r=Math.sqrt(n*n+o*o)/t.HP,a=new P((Math.min(s.x,i.x)+Math.max(s.x,i.x))/2,(Math.min(s.y,i.y)+Math.max(s.y,i.y))/2),h=t.KP*r,l=t.commandHandler;if(h!==t.scale&&l.canResetZoom(h)){let u=t.zoomPoint;t.zoomPoint=a,l.resetZoom(h),t.zoomPoint=u}e.bubbles=!1}P.i(i),P.i(s)}doKeyDown(){this.diagram.lastInput.code==="Escape"&&this.doCancel()}doKeyUp(){}startTransaction(t){return t===void 0&&(t=this.name),this.transactionResult=null,this.diagram.startTransaction(t)}stopTransaction(){let t=this.diagram;return this.transactionResult===null?t.rollbackTransaction():t.commitTransaction(this.transactionResult)}standardMouseSelect(){let t=this.diagram;if(!t.allowSelect)return;let e=t.lastInput,i=t.findPartAt(e.documentPoint,!1);if(i!==null){if(m.hr?e.meta:e.control){t.T("ChangingSelection",t.selection);let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!s.isSelected),t.T("ChangedSelection",t.selection)}else if(e.shift){if(!i.isSelected){t.T("ChangingSelection",t.selection);let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&(s.isSelected=!0),t.T("ChangedSelection",t.selection)}}else if(!i.isSelected){let s=i;for(;s!==null&&!s.canSelect();)s=s.containingGroup;s!==null&&t.select(s)}}else e.left&&!(m.hr?e.meta:e.control)&&!e.shift&&t.clearSelection()}standardMouseClick(t,e){t===void 0&&(t=null),e===void 0&&(e=o=>!o.layer?.isTemporary);let i=this.diagram,s=i.lastInput,n=i.findObjectAt(s.documentPoint,t,e);return s.targetObject=n,this.oA(n,s,i)}oA(t,e,i){if(e.handled=!1,t!==null&&!t.isEnabledObject())return!1;let s=0;e.left?e.clickCount===1?s=1:e.clickCount===2?s=2:s=1:e.right&&e.clickCount===1&&(s=3);let n="ObjectSingleClicked";if(t!==null){switch(s){case 1:n="ObjectSingleClicked";break;case 2:n="ObjectDoubleClicked";break;case 3:n="ObjectContextClicked";break}s!==0&&i.T(n,t)}else{switch(s){case 1:n="BackgroundSingleClicked";break;case 2:n="BackgroundDoubleClicked";break;case 3:n="BackgroundContextClicked";break}s!==0&&i.T(n)}if(t!==null)for(;t!==null;){let o=null;switch(s){case 1:o=t.click;break;case 2:o=t.doubleClick?t.doubleClick:t.click;break;case 3:o=t.contextClick;break}if(o!==null&&(o(e,t),e.handled))break;t=t.panel}else{let o=null;switch(s){case 1:o=i.click;break;case 2:o=i.doubleClick?i.doubleClick:i.click;break;case 3:o=i.contextClick;break}o!==null&&o(e)}return e.handled}standardMouseOver(){let t=this.diagram,e=t.lastInput;if(t.animationManager.ke===!0)return;let i=t.skipsUndoManager;t.skipsUndoManager=!0;let s=t.viewportBounds.containsPoint(e.documentPoint)?t.findObjectAt(e.documentPoint,null,null):null;e.event&&(e.event.type==="pointercancel"||e.event.type==="pointerout")&&(s=null),e.targetObject=s;let n=!1;if(s!==t.vc){let o=t.vc,r=o;for(t.vc=s,this.rA(o,s),e.handled=!1;o!==null;){let a=o.mouseLeave;if(a!==null&&(s===o||s!==null&&s.isContainedBy(o)||(a(e,o,s),n=!0,e.handled)))break;o=o.panel}for(o=r,e.handled=!1;s!==null;){let a=s.mouseEnter;if(a!==null&&(o===s||o!==null&&o.isContainedBy(s)||(a(e,s,o),n=!0,e.handled)))break;s=s.panel}s=t.vc}if(s!==null){let o=s,r="";for(;o!==null&&(r=o.cursor,r==="");)o=o.panel;for(t.currentCursor=r,e.handled=!1,o=s;o!==null;){let a=o.mouseOver;if(a!==null&&(a(e,o),n=!0,e.handled))break;o=o.panel}}else{this.doUpdateCursor(null);let o=t.mouseOver;o!==null&&(o(e),n=!0)}n&&t.requestUpdate(),t.skipsUndoManager=i}doUpdateCursor(t){let e=this.diagram;e&&(e.currentCursor="")}rA(t,e){}standardMouseWheel(){let t=this.diagram,e=t.lastInput,i=e.delta;if(i===0||!t.documentBounds.isReal())return;let s=t.commandHandler,n=t.toolManager.mouseWheelBehavior;if(s!==null&&(n===2&&!e.shift||n===1&&e.control)){if(i>0?s.canIncreaseZoom():s.canDecreaseZoom()){let o=t.zoomPoint;t.zoomPoint=e.viewPoint,i>0?s.increaseZoom():s.decreaseZoom(),t.zoomPoint=o}e.bubbles=!1}else if(n===2&&e.shift||n===1&&!e.control){let o=t.position.copy(),r=e.event,a=r.deltaMode,h=r.deltaX,l=r.deltaY,u="pixel";if((h!==0||l!==0)&&!e.shift){switch(a){case 0:u="pixel";break;case 1:u="line";break;case 2:u="page";break}if(h!==0&&t.allowHorizontalScroll){let c=t.scrollHorizontalLineChange;h=h*(c/16),t.scroll(u,h>0?"right":"left",Math.abs(h))}if(l!==0&&t.allowVerticalScroll){let c=t.scrollVerticalLineChange;l=l*(c/16),t.scroll(u,l>0?"down":"up",Math.abs(l))}}else!e.shift&&t.allowVerticalScroll?(i=i*3*t.scrollVerticalLineChange,t.scroll(u,i>0?"up":"down",Math.abs(i))):e.shift&&t.allowHorizontalScroll&&(i=i*3*t.scrollHorizontalLineChange,t.scroll(u,i>0?"left":"right",Math.abs(i)));this.doWheelChange(t,o,e)}}doWheelChange(t,e,i){(!t.position.equals(e)||i.event.wheelDeltaX!==0)&&(i.bubbles=!1)}standardWaitAfter(t,e){e===void 0&&(e=this.diagram.lastInput),this.cancelWaitAfter();let i=this,s=e.clone(this.nA);this.Fm=m.un(()=>i.doWaitAfter(s),t)}cancelWaitAfter(){this.Fm!==-1&&m.wc(this.Fm),this.Fm=-1}doWaitAfter(t){}findToolHandleAt(t,e){let i=this.diagram.findObjectAt(t,s=>{for(;s!==null&&!(s.panel instanceof vt);)s=s.panel;return s});return i===null?null:i.part.category===e?i:null}isBeyondDragSize(t,e){let i=this.diagram;t===void 0&&(t=i.firstInput.viewPoint),e===void 0&&(e=i.lastInput.viewPoint);let s=i.toolManager.dragSize,n=s.width,o=s.height;return i.firstInput.isTouchEvent&&(n+=6,o+=6),Math.abs(e.x-t.x)>n||Math.abs(e.y-t.y)>o}get name(){return this.Pt}set name(t){m.s(t,"string",$t,"name"),this.Pt=t}get isEnabled(){return this.Be}set isEnabled(t){m.s(t,"boolean",$t,"isEnabled"),this.Be=t}get isActive(){return this.GP}set isActive(t){m.s(t,"boolean",$t,"isActive"),this.GP=t}get transactionResult(){return this.YP}set transactionResult(t){t!==null&&m.s(t,"string",$t,"transactionResult"),this.YP=t}}var Cs=(x=>(x[x.Scroll=1]="Scroll",x[x.Zoom=2]="Zoom",x[x.None=3]="None",x))(Cs||{}),As=(x=>(x[x.Zoom=1]="Zoom",x[x.Cancel=2]="Cancel",x[x.None=3]="None",x))(As||{});class ne extends $t{lA;aA;hA;qP;jP;WP;JP;$P;ZP;QP;Om;_a;constructor(t){super(),this.name="ToolManager",this.lA=new q,this.aA=new q,this.hA=new q,this.qP=850,this.jP=850,this.WP=new st(2,2).kt(),this.JP=5e3,this.$P=1,this.ZP=1,this.QP=null,this.Om=null,this._a=-1,t&&Object.assign(this,t)}static WheelScroll=1;static WheelZoom=2;static WheelNone=3;static GestureZoom=1;static GestureCancel=2;static GestureNone=3;get mouseWheelBehavior(){return this.$P}set mouseWheelBehavior(t){this.$P=t}get gestureBehavior(){return this.ZP}set gestureBehavior(t){this.ZP=t}initializeStandardTools(){return this}updateAdornments(t){let e=this.currentToolTip;if(e instanceof vt&&this.Om===t){let i=e.adornedObject;(t!==null?i!==null&&i.part===t:i===null)?this.showToolTip(e,i):this.hideToolTip()}}doMouseDown(){let t=this.diagram,e=t.lastInput;if(e.isTouchEvent&&this.gestureBehavior===2&&(e.bubbles=!1),e.isMultiTouch){if(this.cancelWaitAfter(),this.gestureBehavior===3){e.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomStart();return}}let i=t.undoManager,s=this.mouseDownTools.length;for(let n=0;n<s;n++){let o=this.mouseDownTools.elt(n);if(o.diagram=this.diagram,o.canStart()){t.doFocus(),t.currentTool=o,t.currentTool===o&&(o.isActive||o.doActivate(),o.doMouseDown());return}}t.lastInput.button===1&&(this.mouseWheelBehavior===1?this.mouseWheelBehavior=2:this.mouseWheelBehavior===2&&(this.mouseWheelBehavior=1)),this.doActivate(),this.standardWaitAfter(this.holdDelay,e)}doMouseMove(){let t=this.diagram,e=t.lastInput;if(e.isMultiTouch){if(this.gestureBehavior===3){e.bubbles=!0;return}if(this.gestureBehavior===2)return;if(t.currentTool.canStartMultiTouch()){t.currentTool.standardPinchZoomMove();return}}if(this.isActive){let s=this.mouseMoveTools.length;for(let n=0;n<s;n++){let o=this.mouseMoveTools.elt(n);if(o.diagram=this.diagram,o.canStart()){t.doFocus(),t.currentTool=o,t.currentTool===o&&(o.isActive||o.doActivate(),o.doMouseMove());return}}}this.cA(t);let i=e.event;i!==null&&(i.type==="pointermove"||!i.cancelable)&&(e.bubbles=!0)}cA(t){this.standardMouseOver(),this.isBeyondDragSize()&&this.standardWaitAfter(this.isActive?this.holdDelay:this.hoverDelay,t.lastInput)}rA(t,e){let i=this.currentToolTip;i!==null&&(e!==null&&i instanceof vt&&(e===i||e.isContainedBy(i))||this.hideToolTip())}doWaitAfter(t){let e=this.diagram;if(!e.lR())return;let i=e.lastInput;if(e.lastInput=t,this.doMouseHover(),this.isActive||this.doToolTip(),t.isTouchEvent&&!e.lastInput.handled){let s=t.copy();s.button=2,e.lastInput=s,e.kx=!0,e.doMouseUp()}e.lastInput=i}doMouseHover(){let t=this.diagram,e=t.lastInput;e.targetObject===null&&(e.targetObject=t.findObjectAt(e.documentPoint,null,null));let i=e.targetObject;if(i!==null)for(e.handled=!1;i!==null;){let s=this.isActive?i.mouseHold:i.mouseHover;if(s!==null&&(s(e,i),e.handled))break;i=i.panel}else{let s=this.isActive?t.mouseHold:t.mouseHover;s!==null&&s(e)}}doToolTip(){let t=this.diagram,e=t.lastInput;e.targetObject===null&&(e.targetObject=t.findObjectAt(e.documentPoint,null,null));let i=e.targetObject;if(i!==null){let s=this.currentToolTip;if(s instanceof vt&&(i===s||i.isContainedBy(s)))return;for(;i!==null;){let n=i.toolTip;if(n!==null){this.showToolTip(n,i);return}i=i.panel}this.hideToolTip()}else{let s=t.toolTip;s!==null?this.showToolTip(s,null):this.hideToolTip()}}showToolTip(t,e){e!==null&&m.se(e,J,ne,"showToolTip:obj");let i=this.diagram;if(t!==this.currentToolTip&&this.hideToolTip(),t instanceof vt){t.layerName="Tool",t.selectable=!1,t.scale=1/i.scale,t.category="ToolTip",t.hasPlaceholder()&&(t.placeholder.scale=i.scale);let s=t.diagram;s!==null&&s!==i&&s.remove(t),i.add(t),e!==null?t.adornedObject=e:t.data=i.model,t.ensureBounds(),this.positionToolTip(t,e)}else t instanceof fe&&t!==this.currentToolTip&&t.show!==null&&t.show(e,i,this);this.currentToolTip=t,this.extendToolTip(this.toolTipDuration)}positionToolTip(t,e){if(t.hasPlaceholder())return;let i=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=i.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.x<r.x&&(n.x=r.x),n.y+20/s.scale+o.height>r.bottom?n.y-=o.height+5/s.scale:n.y+=20/s.scale,n.y<r.y&&(n.y=r.y),i.position=n}extendToolTip(t){t===void 0&&(t=3e3),this.currentToolTip!==null&&(this._a!==-1&&(m.wc(this._a),this._a=-1),t>0&&t!==1/0&&(this._a=m.un(()=>this.hideToolTip(),t)))}hideToolTip(){this._a!==-1&&(m.wc(this._a),this._a=-1);let t=this.diagram,e=this.currentToolTip;e!==null&&(e instanceof vt?(t.remove(e),this.Om!==null&&this.Om.removeAdornment(e.category),e.data=null,e.adornedObject=null):e instanceof fe&&e.hide!==null&&e.hide(t,this),this.currentToolTip=null)}get currentToolTip(){return this.QP}set currentToolTip(t){this.QP=t,this.Om=t!==null&&t instanceof vt?t.adornedPart:null}doMouseUp(){this.cancelWaitAfter();let t=this.diagram;if(this.isActive){let e=this.mouseUpTools.length;for(let i=0;i<e;i++){let s=this.mouseUpTools.elt(i);if(s.diagram=this.diagram,s.canStart()){t.doFocus(),t.currentTool=s,t.currentTool===s&&(s.isActive||s.doActivate(),s.doMouseUp());return}}}t.doFocus(),this.doDeactivate()}doMouseWheel(){this.standardMouseWheel()}doKeyDown(){let t=this.diagram;t.commandHandler!==null&&t.commandHandler.doKeyDown()}doKeyUp(){let t=this.diagram;t.commandHandler!==null&&t.commandHandler.doKeyUp()}findTool(t){m.s(t,"string",ne,"findTool:name");let e=this.mouseDownTools.length;for(let i=0;i<e;i++){let s=this.mouseDownTools.elt(i);if(s.name===t)return s}e=this.mouseMoveTools.length;for(let i=0;i<e;i++){let s=this.mouseMoveTools.elt(i);if(s.name===t)return s}e=this.mouseUpTools.length;for(let i=0;i<e;i++){let s=this.mouseUpTools.elt(i);if(s.name===t)return s}return null}replaceTool(t,e){m.s(t,"string",ne,"replaceTool:name"),e!==null&&(e.diagram=this.diagram);let i=this.mouseDownTools.length;for(let s=0;s<i;s++){let n=this.mouseDownTools.elt(s);if(n.name===t)return e!==null?this.mouseDownTools.setElt(s,e):this.mouseDownTools.removeAt(s),n}i=this.mouseMoveTools.length;for(let s=0;s<i;s++){let n=this.mouseMoveTools.elt(s);if(n.name===t)return e!==null?this.mouseMoveTools.setElt(s,e):this.mouseMoveTools.removeAt(s),n}i=this.mouseUpTools.length;for(let s=0;s<i;s++){let n=this.mouseUpTools.elt(s);if(n.name===t)return e!==null?this.mouseUpTools.setElt(s,e):this.mouseUpTools.removeAt(s),n}return null}replaceStandardTool(t,e,i){this.Jt(t,e,i)}Jt(t,e,i){m.s(t,"string",ne,"replaceStandardTool:name"),e!==null&&(e.name=t,e.diagram=this.diagram),this.findTool(t)?this.replaceTool(t,e):e!==null&&i.add(e)}get mouseDownTools(){return this.lA}get mouseMoveTools(){return this.aA}get mouseUpTools(){return this.hA}get hoverDelay(){return this.qP}set hoverDelay(t){m.s(t,"number",ne,"hoverDelay"),this.qP=t}get holdDelay(){return this.jP}set holdDelay(t){m.s(t,"number",ne,"holdDelay"),this.jP=t}get dragSize(){return this.WP}set dragSize(t){this.WP=t.N()}get toolTipDuration(){return this.JP}set toolTipDuration(t){m.s(t,"number",ne,"toolTipDuration"),this.JP=t}get actionTool(){return this.findTool("Action")}set actionTool(t){this.Jt("Action",t,this.mouseDownTools)}get relinkingTool(){return this.findTool("Relinking")}set relinkingTool(t){this.Jt("Relinking",t,this.mouseDownTools)}get linkReshapingTool(){return this.findTool("LinkReshaping")}set linkReshapingTool(t){this.Jt("LinkReshaping",t,this.mouseDownTools)}get resizingTool(){return this.findTool("Resizing")}set resizingTool(t){this.Jt("Resizing",t,this.mouseDownTools)}get rotatingTool(){return this.findTool("Rotating")}set rotatingTool(t){this.Jt("Rotating",t,this.mouseDownTools)}get linkingTool(){return this.findTool("Linking")}set linkingTool(t){this.Jt("Linking",t,this.mouseMoveTools)}get draggingTool(){return this.findTool("Dragging")}set draggingTool(t){this.Jt("Dragging",t,this.mouseMoveTools)}get dragSelectingTool(){return this.findTool("DragSelecting")}set dragSelectingTool(t){this.Jt("DragSelecting",t,this.mouseMoveTools)}get panningTool(){return this.findTool("Panning")}set panningTool(t){this.Jt("Panning",t,this.mouseMoveTools)}get contextMenuTool(){return this.findTool("ContextMenu")}set contextMenuTool(t){this.Jt("ContextMenu",t,this.mouseUpTools)}get textEditingTool(){return this.findTool("TextEditing")}set textEditingTool(t){this.Jt("TextEditing",t,this.mouseUpTools)}get clickCreatingTool(){return this.findTool("ClickCreating")}set clickCreatingTool(t){this.Jt("ClickCreating",t,this.mouseUpTools)}get clickSelectingTool(){return this.findTool("ClickSelecting")}set clickSelectingTool(t){this.Jt("ClickSelecting",t,this.mouseUpTools)}}class Tt extends $t{_P;tS;wn;eS;iS;sS;nS;Fc;Im;oS;th;wr;fA;rS;Fu;Ru;lS;aS;hS;cS;static Px=new q;static le=null;static eh=null;constructor(t){super(),this.name="Dragging",this._P=!0,this.cS=!0,this.tS=!0,this.wn=null,this.eS=null,this.iS=null,this.sS=null,this.nS=!1,this.Fu=!1,this.Fc=new P(NaN,NaN),this.Im=new P,this.oS=!0,this.th=100,this.wr=[],this.fA=new V().k(),this.rS=new Pi,this.Ru=null,this.lS="copy",this.aS="",this.hS="no-drop",t&&Object.assign(this,t)}get isCopyEnabled(){return this._P}set isCopyEnabled(t){m.s(t,"boolean",Tt,"isCopyEnabled"),this._P=t}get copiesEffectiveCollection(){return this.tS}set copiesEffectiveCollection(t){m.s(t,"boolean",Tt,"copiesEffectiveCollection"),this.tS=t}get dragOptions(){return this.rS}set dragOptions(t){this.rS=t}get isGridSnapEnabled(){return this.dragOptions.isGridSnapEnabled}set isGridSnapEnabled(t){m.s(t,"boolean",Tt,"isGridSnapEnabled"),this.dragOptions.isGridSnapEnabled=t}get isComplexRoutingRealtime(){return this.oS}set isComplexRoutingRealtime(t){this.oS=t;let e=this.diagram.findRouter("AvoidsLinks");e!==null&&(e.isRealtime=t)}get isGridSnapRealtime(){return this.dragOptions.isGridSnapRealtime}set isGridSnapRealtime(t){m.s(t,"boolean",Tt,"isGridSnapRealtime"),this.dragOptions.isGridSnapRealtime=t}get gridSnapCellSize(){return this.dragOptions.gridSnapCellSize}set gridSnapCellSize(t){this.dragOptions.gridSnapCellSize.equals(t)||(t=t.N(),this.dragOptions.gridSnapCellSize=t)}get gridSnapCellSpot(){return this.dragOptions.gridSnapCellSpot}set gridSnapCellSpot(t){this.dragOptions.gridSnapCellSpot.equals(t)||(t=t.N(),this.dragOptions.gridSnapCellSpot=t)}get gridSnapOrigin(){return this.dragOptions.gridSnapOrigin}set gridSnapOrigin(t){this.dragOptions.gridSnapOrigin.equals(t)||(t=t.N(),this.dragOptions.gridSnapOrigin=t)}get dragsLink(){return this.dragOptions.dragsLink}set dragsLink(t){m.s(t,"boolean",Tt,"dragsLink"),this.dragOptions.dragsLink=t}get dragsTree(){return this.dragOptions.dragsTree}set dragsTree(t){m.s(t,"boolean",Tt,"dragsTree"),this.dragOptions.dragsTree=t}get copyCursor(){return this.lS}set copyCursor(t){this.lS=t}get moveCursor(){return this.aS}set moveCursor(t){this.aS=t}get nodropCursor(){return this.hS}set nodropCursor(t){this.hS=t}get currentPart(){return this.eS}set currentPart(t){t!==null&&m.se(t,pt,Tt,"currentPart"),this.eS=t}get copiedParts(){return this.sS}set copiedParts(t){this.sS=t}get draggedParts(){return this.iS}set draggedParts(t){this.iS=t}get draggingParts(){return this.copiedParts!==null?this.copiedParts.toKeySet():this.draggedParts!==null?this.draggedParts.toKeySet():this.fA}get draggedLink(){return this.diagram.draggedLink}set draggedLink(t){t!==null&&m.se(t,j,Tt,"draggedLink"),this.diagram.draggedLink=t}get isDragOutStarted(){return this.nS}set isDragOutStarted(t){this.nS=t}get startPoint(){return this.Im}set startPoint(t){this.Im.equals(t)||this.Im.h(t)}get delay(){return this.th}set delay(t){m.s(t,"number",Tt,"delay"),this.th=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||t.isReadOnly&&!t.allowDragOut||!t.allowMove&&!t.allowCopy&&!t.allowDragOut||!t.allowSelect)return!1;let e=t.lastInput;return!e.left||t.currentTool!==this&&(!this.isBeyondDragSize()||e.isTouchEvent&&e.timestamp-t.firstInput.timestamp<this.th)?!1:this.findDraggablePart()!==null}findDraggablePart(){let t=this.diagram,e=t.findPartAt(t.firstInput.documentPoint,!1);if(e===null)return null;for(;e!==null&&!e.canSelect();)e=e.containingGroup;return e!==null&&(e.canMove()||e.canCopy())?e:null}standardMouseSelect(){let t=this.diagram;if(!t.allowSelect)return;let e=t.findPartAt(t.firstInput.documentPoint,!1);if(e!==null){for(;e!==null&&!e.canSelect();)e=e.containingGroup;if(this.currentPart=e,this.currentPart!==null&&!this.currentPart.isSelected){t.T("ChangingSelection",t.selection);let i=t.lastInput;!(m.hr?i.meta:i.control)&&!i.shift&&t.clearSelection(!0),this.currentPart.isSelected=!0,t.T("ChangedSelection",t.selection)}}}doActivate(){let t=this.diagram;this.Ru=null,this.currentPart===null&&this.standardMouseSelect();let e=this.currentPart;if(e===null||!e.canMove()&&!e.canCopy())return;t.cacheGroupExternalLinks(!0),Tt.le=null,this.isActive=!0,this.Fc.set(t.position),this.fS(t.selection),this.wr.length=0,t.animationManager.stopAnimation();let i=this.computeEffectiveCollection(t.selection,this.dragOptions);this.draggedParts=i,this.cS=!!this.diagram.layout.isRealtime,this.diagram.layout.isRealtime=!1,t.Ou=!0,t.getRenderingHint("temporaryPixelRatio")===!0&&t.avgSpf>30&&t.Sx(),t.uA(this.draggedParts),t.Iu=!0,this.startTransaction("Drag"),this.startPoint=t.firstInput.documentPoint,t.isMouseCaptured=!0,t.allowDragOut&&this.aR()}fS(t){if(!this.dragsLink)return;let e=this.diagram,i=e.model.uS(),s=t.first();i&&t.count===1&&s instanceof j&&this.mayDragLink(s)?(this.draggedLink=s,this.draggedLink.canRelinkFrom()&&this.draggedLink.canRelinkTo()&&this.draggedLink.clearAdornments(),this.wn=e.toolManager.findTool("Relinking"),this.wn===null&&(this.wn=new $e,this.wn.diagram=e),this.wn.originalLink=this.draggedLink):(this.draggedLink=null,this.wn=null)}mayDragLink(t){let e=this.diagram;return e!==null&&e.allowRelink}computeEffectiveCollection(t,e){return this.diagram.commandHandler.computeEffectiveCollection(t,e)}js(t){return t===void 0?new Ke(P.dn):this.isGridSnapEnabled?new Ke(new P(Math.round(t.x*1e3)/1e3,Math.round(t.y*1e3)/1e3)):new Ke(t.copy())}doDeactivate(){this.isActive=!1;let t=this.diagram;this.diagram.layout.isRealtime=this.cS,t.Iu=!1,t.Fl=!0,t.cacheGroupExternalLinks(!1),t.stopAutoScroll(),this.dS(),t.gS(this.draggedParts),this.Ru=null,this.currentPart=null,this.draggedParts=null,this.isDragOutStarted=!1,this.Fu=!1,Tt.hR(),this.dA(),this.Fc.e(NaN,NaN),Tt.eh!==null&&(Tt.eh.currentCursor=""),Tt.eh=null,Tt.le=null,this.Rl(),t.isMouseCaptured=!1,t.currentCursor="",t.Ou=!1,this.stopTransaction(),t.mS(!0)}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}dS(){let t=this.diagram,e=t.skipsUndoManager;t.skipsUndoManager=!0;let i=t.lastInput;this.gA(i,null),t.skipsUndoManager=e,this.wr.length=0}mA(){this.Rl(),this.pS();let t=this.diagram;this.Fc.isReal()&&(t.position=this.Fc),t.stopAutoScroll()}doCancel(){this.Rl(),this.pS();let t=this.diagram;this.Fc.isReal()&&(t.position=this.Fc),this.stopTool()}doKeyDown(){let t=this.diagram;if(!this.isActive)return;let e=t.lastInput,i=t.previousInput;e.code==="Escape"?this.doCancel():(e.code!==i.code||e.modifiers!==i.modifiers)&&this.doMouseMove()}doKeyUp(){this.isActive&&this.doMouseMove()}cR(t,e){let i=1/0,s=1/0,n=-1/0,o=-1/0,r=t.iterator;for(;r.next();){let a=r.value;if(!a.isVisible())continue;let h=a.location,l=h.x,u=h.y;isNaN(l)||isNaN(u)||(l<i&&(i=l),u<s&&(s=u),l>n&&(n=l),u>o&&(o=u))}return i===1/0?e.e(0,0,0,0):e.e(i,s,n-i,o-s),e}yS(t){if(this.copiedParts!==null)return;let e=this.diagram;if(t&&(e.isReadOnly||e.isModelReadOnly)||this.draggedParts===null)return;let i=e.undoManager;i.isEnabled&&i.isInTransaction?i.currentTransaction!==null&&i.currentTransaction.changes.count>0&&(e.undoManager.rollbackTransaction(),e.startTransaction("Drag")):this.pS(),e.skipsUndoManager=!t,e.partManager.addsToTemporaryLayer=!t,this.startPoint=e.firstInput.documentPoint;let s=this.copiesEffectiveCollection?this.draggedParts.toKeySet():e.selection,n=e.copyParts(s,e,!0);e.commandHandler.Rc(n);let o=new Mt,r=this.draggedParts.iterator;for(;r.next();){let h=r.key;if(h.Di()&&h.canCopy()){let l=n.get(h);if(l===null)continue;l.location=h.location,l.ensureBounds(),o.set(l,this.js(l.location))}}let a=n.iterator;for(;a.next();){let h=a.value;h instanceof j&&h.canCopy()&&o.set(h,this.js())}if(this.copiedParts=o,this.fS(o.toKeySet()),this.draggedLink!==null){let h=this.draggedLink,l=h.routeBounds;h.xr(this.startPoint.x-(l.x+l.width/2),this.startPoint.y-(l.y+l.height/2))}this.doUpdateCursor(null)}Rl(){let t=this.diagram;if(this.copiedParts!==null){if(t.removeParts(this.copiedParts.toKeySet(),!1),this.copiedParts=null,this.draggedParts!==null){let e=this.draggedParts.iterator;for(;e.next();)if(e.key instanceof j){let i=e.value;i.point=new P(0,0)}}this.doUpdateCursor(null)}t.skipsUndoManager=!1,t.partManager.addsToTemporaryLayer=!1,this.startPoint=t.firstInput.documentPoint}dA(){this.draggedLink!==null&&(this.dragsLink&&this.wn!==null&&(this.wn.stopDraggingMouseMove(),this.wn.originalLink=null),this.draggedLink=null,this.wn=null)}Oc(t,e){if(t===null)return;let i=this.diagram,s=this.startPoint,n=P.l();n.h(i.lastInput.documentPoint),this.moveParts(t,n.subtract(s),e),P.i(n),i.getRenderingHint("temporaryPixelRatio")===!0&&i.Ol===null&&i.avgSpf>30&&(i.Sx(),i.Eu())}moveParts(t,e,i){i===void 0&&(i=!1);let s=this.diagram;s!==null&&s.Mx(t,e,this.dragOptions,i)}pS(){if(this.draggedParts===null)return;let t=this.diagram,e=this.draggedParts.iterator;for(;e.next();){let i=e.key;i.Di()&&(i.location=e.value.point)}for(e=this.draggedParts.iterator;e.next();){let i=e.key;if(i instanceof j&&i.suspendsRouting){let s=e.value.point;this.draggedParts.set(i,this.js()),i.xr(-s.x,-s.y)}}t.maybeUpdate()}fR(t){if(t===null)return!0;let e=t.part;return!!(e===null||e instanceof vt||e.layer?.isTemporary||this.draggedParts&&this.draggedParts.has(e)||this.copiedParts&&this.copiedParts.has(e))}wS(t){let e=this.diagram;this.dragsLink&&(this.draggedLink!==null&&(this.draggedLink.fromNode=null,this.draggedLink.toNode=null),this.pA(!1));let i=this.findDragOverObject(t),s=e.lastInput;s.targetObject=i,this.doUpdateCursor(i);let n=e.skipsUndoManager,o=!1;try{if(e.skipsUndoManager=!0,o=this.gA(s,i),!this.isActive&&Tt.le===null)return;let r=i!==null?i.part:null;if(r===null||e.handlesDragDropForTopLevelParts&&r.isTopLevel&&!(r instanceof ht)){let a=e.mouseDragOver;a!==null&&(a(s),o=!0)}if(!this.isActive&&Tt.le===null||(this.doDragOver(t,i),!this.isActive&&Tt.le===null))return}finally{e.skipsUndoManager=n,o&&e.maybeUpdate()}this.Ru=i,!e.isReadOnly&&(e.allowMove||e.allowCopy)&&(e.allowHorizontalScroll||e.allowVerticalScroll)&&e.doAutoScroll(s.viewPoint)}findDragOverObject(t){return this.diagram.xS(t,null,e=>!this.fR(e))}doUpdateCursor(t){let e=this.diagram;(t===null||this.Ru!==t)&&(!this.diagram.currentTool.isActive||this.mayCopy()?e.currentCursor=this.copyCursor:this.mayMove()?e.currentCursor=this.moveCursor:this.mayDragOut()&&(e.currentCursor=this.nodropCursor))}gA(t,e){let i=!1,s=this.wr.length,n=s>0?this.wr[0]:null;if(e===n)return!1;t.handled=!1;for(let r=0;r<s;r++){let a=this.wr[r],h=a.mouseDragLeave;if(h!==null&&(h(t,a,e),i=!0,t.handled))break}if(this.wr.length=0,!this.isActive&&Tt.le===null||e===null)return i;t.handled=!1;let o=e;for(;o!==null;)this.wr.push(o),o=this.yA(o);s=this.wr.length;for(let r=0;r<s;r++){let a=this.wr[r],h=a.mouseDragEnter;if(h!==null&&(h(t,a,n),i=!0,t.handled))break}return i}vU(t,e){return t===null?!1:!!(t===e||t.isContainedBy(e)||e instanceof ht&&!(t instanceof ht)&&e.handlesDragDropForMembers&&t.part?.isMemberOf(e))}yA(t){let e=t.panel;if(e!==null)return e;if(t instanceof pt&&!(t instanceof ht)){let i=t.containingGroup;if(i!==null&&i.handlesDragDropForMembers)return i}return null}wA(t,e){let i=this.diagram,s=this.wn;if(s===null)return null;let n=s.portGravity,o=i.findObjectsNear(t,n,l=>s.findValidLinkablePort(l,e)),r=P.l(),a=1/0,h=null;for(let l=o.iterator;l.next();){let u=l.value;if(u.part===null)continue;let c=u.getDocumentPoint(T.Center,r),d=t.distanceSquaredPoint(c);d<a&&(h=u,a=d)}return P.i(r),h}pA(t){let e=this.draggedLink;if(e!==null){if(e.pointsCount<2)return;let i=this.diagram;if(i.isReadOnly)return;let s=this.wn;if(s===null)return;let n=null,o=null;e.fromNode===null&&(n=this.wA(e.getPoint(0),!1),n!==null&&(o=n.part));let r=null,a=null;e.toNode===null&&(r=this.wA(e.getPoint(e.pointsCount-1),!0),r!==null&&(a=r.part)),s.isValidLink(o,n,a,r)?t?(e.defaultFromPoint=e.getPoint(0),e.defaultToPoint=e.getPoint(e.pointsCount-1),e.suspendsRouting=!1,e.fromNode=o,n!==null&&(e.fromPortId=n.portId),e.toNode=a,r!==null&&(e.toPortId=r.portId),e.fromPort!==i.bS&&i.T("LinkRelinked",e,i.bS),e.toPort!==i.kS&&i.T("LinkRelinked",e,i.kS)):s.doDraggingMouseMove(o,n,a,r):s.doDraggingMouseMove(null,null,null,null)}}doDragOver(t,e){}xA(t){let e=this.diagram;this.dragsLink&&this.pA(!0),this.dS();let i=this.findDragOverObject(t),s=e.lastInput;if(s.targetObject=i,i!==null){s.handled=!1;let a=i;for(;a!==null;){let h=a.mouseDrop;if(h!==null&&(h(s,a),s.handled))break;this.uR(s,a),a=this.yA(a)}}else{let a=e.mouseDrop;a!==null&&a(s)}if(!this.isActive&&Tt.le===null)return;let n=this.copiedParts||this.draggedParts;if(n!==null){let a=n.iterator;for(;a.next();){let h=a.key;h instanceof $&&h.linksConnected.each(l=>l.suspendsRouting=!1)}}if(this.doDropOnto(t,i),!this.isActive&&Tt.le===null)return;let o=I.l(),r=e.selection.iterator;for(;r.next();){let a=r.value;a instanceof $&&this.dR(e,a,o)}I.i(o)}uR(t,e){let i=this.diagram,s=e.part;if(i.handlesDragDropForTopLevelParts&&s!==null&&s.isTopLevel&&!(s instanceof ht)){let n=i.mouseDrop;n!==null&&n(t)}}dR(t,e,i){if(!e.canAvoid())return;let s=!1;i=e.getAvoidableRect(i),t.viewportBounds.containsRect(i)&&(s=!0);let n=this.copiedParts||this.draggedParts;if(n===null)return;let o=t.PS(i,a=>a.part,a=>a instanceof j,!0,a=>a instanceof j,s);if(o.count===0)return;let r=o.iterator;for(;r.next();){let a=r.value;n.has(a)&&n.has(e)||!a.isMemberOf(e)&&a.isAvoiding&&a.$t()}}doDropOnto(t,e){}doMouseMove(){if(!this.isActive)return;let t=this.diagram,e=t.lastInput;this.simulatedMouseMove(e.event,e.documentPoint,e.targetDiagram)||this.currentPart!==null&&this.draggedParts!==null&&(this.mayCopy()?(this.yS(!1),this.Oc(this.copiedParts,!1)):this.mayMove()?(this.Rl(),this.Oc(this.draggedParts,!0)):this.mayDragOut()?(this.yS(!1),this.Oc(this.copiedParts,!1)):this.Rl(),this.wS(t.lastInput.documentPoint))}doMouseUp(){if(!this.isActive)return;let t=this.diagram,e=t.lastInput;if(this.simulatedMouseUp(e.event,e.documentPoint,e.targetDiagram))return;let i=!1,s=this.mayCopy();if(s&&this.copiedParts!==null?(this.Rl(),this.yS(!0),this.Oc(this.copiedParts,!1),this.copiedParts!==null&&(t.T("ChangingSelection",t.selection),t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0}))):(i=!0,this.Rl(),this.mayMove()&&(this.Oc(this.draggedParts,!0),this.wS(t.lastInput.documentPoint))),this.Fu=!0,this.xA(t.lastInput.documentPoint),this.isActive){let n=s&&this.copiedParts,o=n?this.copiedParts?.toKeySet():this.draggedParts?this.draggedParts.toKeySet():null;this.copiedParts=null,i&&this.gR(),t.invalidateDocumentBounds(),t.gS(this.draggedParts),this.transactionResult=n?"Copy":"Move",t.T(n?"SelectionCopied":"SelectionMoved",o)}this.stopTool(),s&&t.T("ChangedSelection",t.selection)}simulatedMouseMove(t,e,i){if(Tt.le===null)return!1;let s=Tt.le.diagram;i instanceof Y||(i=null);let n=Tt.eh;if(i!==n){if(n!==null&&n!==s){n.stopAutoScroll(),Tt.le.isDragOutStarted=!1;let r=n.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDragLeave()}if(Tt.eh=i,i!==null&&i!==s){Tt.le.mA();let r=i.toolManager.findTool("Dragging");r!==null&&(r.bA(),r.doSimulatedDragEnter())}this.doUpdateCursor(null)}if(i===null||i===s||!i.allowDrop||i.isReadOnly||!i.allowInsert)return!1;let o=i.toolManager.findTool("Dragging");if(o!==null){let r=e;t!==null&&(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),r=i.getMouse(t)),i.lastInput.documentPoint=r,i.lastInput.viewPoint=i.transformDocToView(r),i.lastInput.down=!1,i.lastInput.up=!1,o.doSimulatedDragOver()}return!0}simulatedMouseUp(t,e,i){if(Tt.le===null)return!1;let s=Tt.eh,n=Tt.le.diagram;if(i===null)return Tt.le.doCancel(),!0;if(i!==s){if(s!==null){let r=s.toolManager.findTool("Dragging");if(s!==null&&s!==n&&r!==null)return s.stopAutoScroll(),Tt.le.isDragOutStarted=!1,r.doSimulatedDragLeave(),!1}Tt.eh=i;let o=i.toolManager.findTool("Dragging");o!==null&&(Tt.le.mA(),o.bA(),o.doSimulatedDragEnter())}if(i!==this.diagram){let o=e;t!==null?(t.targetTouches!==void 0&&(t.targetTouches.length>0?t=t.targetTouches[0]:t.changedTouches.length>0&&(t=t.changedTouches[0])),o=i.getMouse(t)):o===null&&(o=new P),i.lastInput.documentPoint=o,i.lastInput.viewPoint=i.transformDocToView(o),i.lastInput.down=!1,i.lastInput.up=!0;let r=i.toolManager.findTool("Dragging");r!==null&&r.doSimulatedDrop();let a=Tt.le;if(a!==null){let h=a.mayCopy();a.transactionResult=h?"Copy":"Move",a.stopTool()}return!0}return!1}gR(){if(this.draggedParts===null)return;let t=this.draggedParts.iterator;for(;t.next();){let e=t.key;if(e instanceof $){let i=e.containingGroup;i!==null&&i.hasPlaceholder()&&!this.draggedParts.has(i)&&i.placeholder.f()}}}mayCopy(){if(!this.isCopyEnabled)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.allowCopy||!(m.hr?t.lastInput.alt:t.lastInput.control))return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayDragOut(){if(!this.isCopyEnabled)return!1;let t=this.diagram;if(!t.allowDragOut||!t.allowCopy||t.allowMove)return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canCopy())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canCopy())}mayMove(){let t=this.diagram;if(t.isReadOnly||!t.allowMove)return!1;let e=t.selection.iterator;for(;e.next();)if(e.value.canMove())return!0;return!!(this.draggedLink!==null&&this.dragsLink&&this.draggedLink.canMove())}bA(){Tt.Px.has(this)||Tt.Px.add(this)}static hR(){if(Tt.Px.count>0){let t=Tt.Px,e=t.length;for(let i=0;i<e;i++){let s=t.elt(i);s.dA(),s.Rl(),s.dS(),s.diagram.stopAutoScroll()}t.clear()}}mR(t,e,i){return!this.Fu&&this.draggedParts!==null&&!this.draggedParts.has(t)?(i.h(e),!0):!1}get draggingSource(){return Tt.le}mayDragIn(){let t=this.diagram;if(!t.allowDrop||t.isReadOnly||t.isModelReadOnly||!t.allowInsert)return!1;let e=Tt.le;return!(e===null||e.diagram.model.dataFormat!==t.model.dataFormat)}doSimulatedDragEnter(){if(!this.mayDragIn())return;let t=this.diagram;t.animationManager.stopAnimation(),t.br(),t.animationManager.stopAnimation();let e=Tt.le;e!==null&&(this.diagram.Ou=!0,t.lastInput.event===null&&(t.lastInput.event=e.diagram.lastInput.event)),this.doUpdateCursor(null)}doSimulatedDragLeave(){let t=Tt.le;t!==null&&t.doSimulatedDragOut(),this.diagram.Ou=!1,this.doCancel()}doSimulatedDragOver(){let t=this.diagram;t.animationManager.Uu=!0;let e=Tt.le;if(e!==null&&e.draggedParts!==null){if(!this.mayDragIn())return;this.kA(e.draggedParts.toKeySet(),!1,t.firstInput),this.Oc(this.copiedParts,!1),this.wS(t.lastInput.documentPoint)}t.animationManager.Uu=!1}doSimulatedDrop(){let t=this.diagram,e=Tt.le;if(e!==null){let i=e.diagram;if(e.Fu=!0,this.Rl(),e.draggedParts===null||!this.mayDragIn())return;t.animationManager.Uu=!0,t.T("ChangingSelection",t.selection),this.startTransaction("Drop"),this.kA(e.draggedParts.toKeySet(),!0,t.lastInput),this.Oc(this.copiedParts,!1);let s=new V;this.copiedParts!==null&&(t.clearSelection(!0),this.copiedParts.iteratorKeys.each(n=>{n.isSelected=!0,s.add(n)})),this.xA(t.lastInput.documentPoint),t.invalidateDocumentBounds(),this.copiedParts!==null&&(this.transactionResult="ExternalCopy"),this.copiedParts=null,t.doFocus(),t.Ou=!1,t.T("ExternalObjectsDropped",s,i),this.stopTransaction(),t.T("ChangedSelection",t.selection)}t.animationManager.Uu=!1}kA(t,e,i){if(this.copiedParts!==null)return;let s=this.diagram;if(s.isReadOnly||s.isModelReadOnly)return;s.skipsUndoManager=!e,s.partManager.addsToTemporaryLayer=!e,this.startPoint=i.documentPoint;let n=s.copyParts(t,s,!0);s.commandHandler.Rc(n);let o=I.l();this.cR(t,o);let r=o.x+o.width/2,a=o.y+o.height/2;I.i(o);let h=this.Im,l=new Mt,u=P.l(),c=t.iterator;for(;c.next();){let f=c.value;if(f instanceof j&&f.canCopy()){let p=n.get(f);if(p===null)continue;p.points=f.points,p.xr(h.x-r,h.y-a),p.suspendsRouting=!0,l.set(p,this.js())}}let d=t.iterator;for(;d.next();){let f=d.value;if(f.Di()&&f.canCopy()){let p=n.get(f);if(p===null)continue;let g=f.location;u.e(h.x-(r-g.x),h.y-(a-g.y)),p.location=u,p.ensureBounds(),l.set(p,this.js(u))}}if(P.i(u),this.copiedParts=l,this.fS(l.toKeySet()),this.draggedLink!==null){let f=this.draggedLink,p=f.routeBounds;f.xr(this.startPoint.x-(p.x+p.width/2),this.startPoint.y-(p.y+p.height/2))}this.doUpdateCursor(null)}aR(){this.isDragOutStarted=!0,this.Fu=!1,Tt.le=this,Tt.eh=this.diagram,this.doSimulatedDragOut()}doSimulatedDragOut(){let t=this.diagram;!this.mayCopy()&&!this.mayMove()?t.currentCursor=this.nodropCursor:t.currentCursor="",this.Ru=null}computeMove(t,e,i,s){let n=this.diagram;return n!==null?n.computeMove(t,e,this.dragOptions,s):new P}}ne.prototype.doCancel=function(){Tt.le!==null&&Tt.le.doCancel(),$t.prototype.doCancel.call(this)};class ae extends $t{SS;MS;Il;NS;CS;ih;LS;nh;AS;TS;DS;vS;FS;RS;PA;OS;El;IS;constructor(){super(),this.SS=100,this.MS=!1,this.Il="pointer",this.NS=new j({layerName:"Tool"}).add(new et({isPanelMain:!0,stroke:"blue"}).theme("stroke","tempLink"),new et({toArrow:"Standard",fill:"blue",stroke:"blue"}).theme("fill","tempLink").theme("stroke","tempLink")).It(),this.ih=new et("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:st.CP}).theme("stroke","tempPort"),this.CS=new $({selectable:!1,layerName:"Tool"}).add(this.ih).It(),this.nh=new et("Rectangle",{portId:"",fill:null,stroke:"magenta",strokeWidth:2,desiredSize:st.CP}).theme("stroke","tempPort"),this.LS=new $({selectable:!1,layerName:"Tool"}).add(this.nh).It(),this.AS=null,this.TS=null,this.DS=null,this.vS=null,this.FS=null,this.RS=!0,this.PA=new Mt,this.OS=null,this.El=null,this.IS=null}doStop(){this.diagram.stopAutoScroll(),this.originalLink=null,this.originalFromNode=null,this.originalFromPort=null,this.originalToNode=null,this.originalToPort=null,this.validPortsCache.clear(),this.targetPort=null}get portGravity(){return this.SS}set portGravity(t){m.s(t,"number",ae,"portGravity"),t>=0&&(this.SS=t)}get isUnconnectedLinkValid(){return this.MS}set isUnconnectedLinkValid(t){m.s(t,"boolean",ae,"isUnconnectedLinkValid"),this.MS=t}get linkingCursor(){return this.Il}set linkingCursor(t){this.Il=t}get temporaryLink(){return this.NS}set temporaryLink(t){t.It(),this.NS=t}get temporaryFromNode(){return this.CS}set temporaryFromNode(t){t.It(),this.CS=t,t&&(this.ih=t.port)}get temporaryFromPort(){return this.ih}set temporaryFromPort(t){if(this.ih!==null){let e=this.ih.panel;if(e!==null){let i=e.D.indexOf(this.ih);e.removeAt(i),e.insertAt(i,t)}}this.ih=t}get temporaryToNode(){return this.LS}set temporaryToNode(t){t.It(),this.LS=t,t&&(this.nh=t.port)}get temporaryToPort(){return this.nh}set temporaryToPort(t){if(this.nh!==null){let e=this.nh.panel;if(e!==null){let i=e.D.indexOf(this.nh);e.removeAt(i),e.insertAt(i,t)}}this.nh=t}get originalLink(){return this.AS}set originalLink(t){t!==null&&m.se(t,j,ae,"originalLink"),this.AS=t}get originalFromNode(){return this.TS}set originalFromNode(t){t!==null&&m.se(t,$,ae,"originalFromNode"),this.TS=t}get originalFromPort(){return this.DS}set originalFromPort(t){t!==null&&m.se(t,J,ae,"originalFromPort"),this.DS=t}get originalToNode(){return this.vS}set originalToNode(t){t!==null&&m.se(t,$,ae,"originalToNode"),this.vS=t}get originalToPort(){return this.FS}set originalToPort(t){t!==null&&m.se(t,J,ae,"originalToPort"),this.FS=t}get isForwards(){return this.RS}set isForwards(t){this.RS=t}get validPortsCache(){return this.PA}get targetPort(){return this.OS}set targetPort(t){t!==null&&m.se(t,J,ae,"targetPort"),this.OS=t}copyPortProperties(t,e,i,s,n){if(t===null||e===null||i===null||s===null)return;let o=e.getDocumentScale(),r=st.l();r.width=e.naturalBounds.width*o,r.height=e.naturalBounds.height*o,s.desiredSize=r,st.i(r),n?(s.toSpot=e.toSpot,s.toEndSegmentLength=e.toEndSegmentLength):(s.fromSpot=e.fromSpot,s.fromEndSegmentLength=e.fromEndSegmentLength),i.locationSpot=T.Center;let a=P.l();i.location=e.getDocumentPoint(T.Center,a),P.i(a),s.angle=e.getDocumentAngle(),this.portTargeted!==null&&this.portTargeted(t,e,i,s,n)}setNoTargetPortProperties(t,e,i){e!==null&&(e.desiredSize=st.CP,e.fromSpot=T.None,e.toSpot=T.None),t!==null&&(t.location=this.diagram.lastInput.documentPoint),this.portTargeted!==null&&this.portTargeted(null,null,t,e,i)}doMouseDown(){this.isActive&&this.doMouseMove()}doMouseMove(){if(this.isActive){let t=this.diagram;if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null&&this.targetPort.part instanceof $){let e=this.targetPort.part;this.isForwards?this.copyPortProperties(e,this.targetPort,this.temporaryToNode,this.temporaryToPort,!0):this.copyPortProperties(e,this.targetPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else this.isForwards?this.setNoTargetPortProperties(this.temporaryToNode,this.temporaryToPort,!0):this.setNoTargetPortProperties(this.temporaryFromNode,this.temporaryFromPort,!1);(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}findValidLinkablePort(t,e){if(t===null)return null;let i=t.part;if(!(i instanceof $))return null;for(;t!==null;){let s=e?t.toLinkable:t.fromLinkable;if(s===!0&&(t.portId!==null||t instanceof $)&&(e?this.isValidTo(i,t):this.isValidFrom(i,t)))return t;if(s===!1)return null;t=t.panel}return null}findTargetPort(t){let e=this.diagram,i=e.lastInput.documentPoint,s=this.portGravity,n=e.findObjectsNear(i,s,h=>this.findValidLinkablePort(h,t),null,!0),o=1/0,r=null,a=n.iterator;for(;a.next();){let h=a.value,l=h.part;if(!(l instanceof $))continue;let u=h.getDocumentPoint(T.Center,P.l()),c=i.x-u.x,d=i.y-u.y;P.i(u);let f=c*c+d*d;if(f<o){let p=this.validPortsCache.get(h);p!==null?p&&(r=h,o=f):t&&this.isValidLink(this.originalFromNode,this.originalFromPort,l,h)||!t&&this.isValidLink(l,h,this.originalToNode,this.originalToPort)?(this.validPortsCache.set(h,!0),r=h,o=f):this.validPortsCache.set(h,!1)}}if(r!==null){let h=r.part;if(h instanceof $&&(h.layer===null||h.layer.allowLink))return r}return null}isValidFrom(t,e){if(t===null||e===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||e.fromLinkable!==!0))return!1;let i=e.fromMaxLinks;if(i<1/0){if(this.originalLink!==null&&t===this.originalFromNode&&e===this.originalFromPort)return!0;let s=e.portId;if(s===null&&(s=""),t.findLinksOutOf(s).count>=i)return!1}return!0}isValidTo(t,e){if(t===null||e===null)return this.isUnconnectedLinkValid;if(this.diagram.currentTool===this&&(t.layer!==null&&!t.layer.allowLink||e.toLinkable!==!0))return!1;let i=e.toMaxLinks;if(i<1/0){if(this.originalLink!==null&&t===this.originalToNode&&e===this.originalToPort)return!0;let s=e.portId;if(s===null&&(s=""),t.findLinksInto(s).count>=i)return!1}return!0}isInSameNode(t,e){if(t===null||e===null)return!1;if(t===e)return!0;let i=t.part,s=e.part;return i!==null&&i===s}isLinked(t,e){if(t===null||e===null)return!1;let i=t.part;if(!(i instanceof $))return!1;let s=t.portId;s===null&&(s="");let n=e.part;if(!(n instanceof $))return!1;let o=e.portId;o===null&&(o="");let r=n.findLinksInto(o);for(;r.next();){let a=r.value;if(a.fromNode===i&&a.fromPortId===s)return!0}return!1}isValidLink(t,e,i,s){if(!this.isValidFrom(t,e)||!this.isValidTo(i,s)||e!==null&&s!==null&&(!(e.fromLinkableSelfNode&&s.toLinkableSelfNode)&&this.isInSameNode(e,s)||!(e.fromLinkableDuplicates&&s.toLinkableDuplicates)&&this.isLinked(e,s))||this.originalLink!==null&&(t!==null&&this.isLabelDependentOnLink(t,this.originalLink)||i!==null&&this.isLabelDependentOnLink(i,this.originalLink))||t!==null&&i!==null&&(t.data===null&&i.data!==null||t.data!==null&&i.data===null)||!this.isValidCycle(t,i,this.originalLink))return!1;let n;return t!==null&&e!==null&&(n=t.linkValidation,n!==null&&!n(t,e,i,s,this.originalLink))||i!==null&&s!==null&&(n=i.linkValidation,n!==null&&!n(t,e,i,s,this.originalLink))?!1:(n=this.linkValidation,n!==null?n(t,e,i,s,this.originalLink):!0)}isLabelDependentOnLink(t,e){if(t===null)return!1;let i=t.labeledLink;if(i===null)return!1;if(i===e)return!0;let s=new V;return s.add(t),this.ES(i,e,s)}ES(t,e,i){if(t===e)return!0;let s=t.fromNode;if(s!==null&&s.labeledLink&&(i.add(s),this.ES(s.labeledLink,e,i)))return!0;let n=t.toNode;return!!(n!==null&&n.labeledLink&&(i.add(n),this.ES(n.labeledLink,e,i)))}isValidCycle(t,e,i){if(i===void 0&&(i=null),t===null||e===null)return this.isUnconnectedLinkValid;let s=this.diagram,n=1;if(s&&(s.model.Nx()?n=s.isTreePathToChildren?5:6:n=s.validCycle),n===1)return!0;if(n===5){let o=i||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;let r=e.linksConnected;for(;r.next();){let a=r.value;if(a!==i&&a.isTreeLink&&a.toNode===e)return!1}return!this.Vu(t,e,i,!0)}else if(n===6){let o=i||this.temporaryLink;if(o!==null&&!o.isTreeLink)return!0;let r=t.linksConnected;for(;r.next();){let a=r.value;if(a!==i&&a.isTreeLink&&a.fromNode===t)return!1}return!this.Vu(t,e,i,!0)}else{if(n===2)return!this.pR(t,e,i);if(n===3)return!this.Vu(t,e,i,!1);if(n===4)return!this.yR(t,e,i)}return!0}Vu(t,e,i,s){if(t===e)return!0;if(t===null||e===null)return!1;let n=t.linksConnected;for(;n.next();){let o=n.value;if(o===i||s&&!o.isTreeLink||o.toNode!==t)continue;let r=o.fromNode;if(!(r===t||r===null)&&this.Vu(r,e,i,s))return!0}return!1}pR(t,e,i){if(t===e)return!0;let s=new Set;return s.add(e),this.SA(s,t,e,i)}SA(t,e,i,s){if(e===i)return!0;if(e===null||i===null||t.has(e))return!1;t.add(e);let n=e.linksConnected;for(;n.next();){let o=n.value;if(o===s||o.toNode!==e)continue;let r=o.fromNode;if(!(r===e||r===null)&&this.SA(t,r,i,s))return!0}return!1}yR(t,e,i){if(t===e)return!0;let s=new Set;return s.add(e),this.MA(s,t,e,i)}MA(t,e,i,s){if(e===i)return!0;if(e===null||i===null||t.has(e))return!1;t.add(e);let n=e.linksConnected;for(;n.next();){let o=n.value;if(o===s)continue;let r=o.fromNode,a=o.toNode,h=r===e?a:r;if(!(h===e||h===null)&&this.MA(t,h,i,s))return!0}return!1}get linkValidation(){return this.El}set linkValidation(t){t!==null&&m.S(t,ae,"linkValidation"),this.El=t}get portTargeted(){return this.IS}set portTargeted(t){t!==null&&m.S(t,ae,"portTargeted"),this.IS=t}}var Ts=(x=>(x[x.Either=1]="Either",x[x.ForwardsOnly=2]="ForwardsOnly",x[x.BackwardsOnly=3]="BackwardsOnly",x))(Ts||{});class Le extends ae{US;VS;P;BS;constructor(t){super(),this.name="Linking",this.US={},this.VS=null,this.P=1,this.BS=null,t&&Object.assign(this,t)}static Either=1;static ForwardsOnly=2;static BackwardsOnly=3;get archetypeLinkData(){return this.US}set archetypeLinkData(t){t!==null&&m.xc(t,Le,"archetypeLinkData"),t instanceof J&&m.se(t,j,Le,"archetypeLinkData"),this.US=t}get archetypeLabelNodeData(){return this.VS}set archetypeLabelNodeData(t){t!==null&&m.xc(t,Le,"archetypeLabelNodeData"),t instanceof J&&m.se(t,$,Le,"archetypeLabelNodeData"),this.VS=t}get direction(){return this.P}set direction(t){this.P=t}get startObject(){return this.BS}set startObject(t){t!==null&&m.se(t,J,Le,"startObject"),this.BS=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||t.isModelReadOnly||!t.allowLink||!t.model.Cx()||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize()?!1:this.findLinkablePort()!==null}findLinkablePort(){let t=this.diagram,e=this.startObject;if(e===null&&(e=t.findObjectAt(t.firstInput.documentPoint,null,null)),e===null)return null;let i=e.part;if(!(i instanceof $))return null;let s=this.direction;if(s===1||s===2){let n=this.findValidLinkablePort(e,!1);if(n!==null)return this.isForwards=!0,n;if(this.startObject===i){let o=i.port;if(this.findValidLinkablePort(o,!1))return this.isForwards=!0,o}}if(s===1||s===3){let n=this.findValidLinkablePort(e,!0);if(n!==null)return this.isForwards=!1,n;if(this.startObject===i){let o=i.port;if(this.findValidLinkablePort(o,!0))return this.isForwards=!1,o}}return null}doActivate(){let t=this.diagram,e=this.findLinkablePort();if(e===null){this.stopTool();return}if(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.isForwards){this.temporaryToNode!==null&&(this.temporaryToNode.location=t.lastInput.documentPoint),this.originalFromPort=e;let i=this.originalFromPort.part;i instanceof $&&(this.originalFromNode=i),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1)}else{this.temporaryFromNode!==null&&(this.temporaryFromNode.location=t.lastInput.documentPoint),this.originalToPort=e;let i=this.originalToPort.part;i instanceof $&&(this.originalToNode=i),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0)}t.add(this.temporaryFromNode),this.temporaryFromNode&&this.temporaryFromNode.ensureBounds(),t.add(this.temporaryToNode),this.temporaryToNode&&this.temporaryToNode.ensureBounds(),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.temporaryLink.isTreeLink=this.isNewTreeLink(),this.temporaryLink.$t(),t.add(this.temporaryLink)),this.isActive=!0}doDeactivate(){this.isActive=!1;let t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.startObject=null}doMouseUp(){if(this.isActive){let t=this.diagram;this.transactionResult=null;let e=null,i=null,s=null,n=null,o=null;try{this.targetPort=this.findTargetPort(this.isForwards);let r=this.targetPort;if(r!==null){let a=r.part;a instanceof $&&(this.isForwards?(this.originalFromNode!==null&&(e=this.originalFromNode,i=this.originalFromPort),s=a,n=r):(e=a,i=r,this.originalToNode!==null&&(s=this.originalToNode,n=this.originalToPort)))}else this.isForwards?this.originalFromNode!==null&&this.isUnconnectedLinkValid&&(e=this.originalFromNode,i=this.originalFromPort):this.originalToNode!==null&&this.isUnconnectedLinkValid&&(s=this.originalToNode,n=this.originalToPort);e!==null||s!==null?(o=this.insertLink(e,i,s,n),o!==null?(r===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint),t.allowSelect&&(t.T("ChangingSelection",t.selection),t.clearSelection(!0),o.isSelected=!0),this.transactionResult=this.name,t.T("LinkDrawn",o)):this.doNoLink(e,i,s,n)):this.isForwards?this.doNoLink(this.originalFromNode,this.originalFromPort,null,null):this.doNoLink(null,null,this.originalToNode,this.originalToPort)}finally{this.stopTool(),o&&t.allowSelect&&t.T("ChangedSelection",t.selection)}}}isNewTreeLink(){let t=this.archetypeLinkData;if(t===null)return!0;if(t instanceof j)return t.isTreeLink;let e=this.diagram;if(e===null)return!0;let i=e.partManager.getLinkCategoryForData(t),s=e.partManager.findLinkTemplateForCategory(i);return s!==null?s.isTreeLink:!0}insertLink(t,e,i,s){return this.diagram.partManager.insertLink(t,e,i,s)}doNoLink(t,e,i,s){}}class $e extends ae{NA=null;CA=null;zS=null;XS=null;Ss;GS;constructor(t){super(),this.name="Relinking",this.fromHandleArchetype=new et("Diamond",{desiredSize:st.Su,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:0}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.toHandleArchetype=new et("Diamond",{desiredSize:st.Su,fill:"lightblue",stroke:"dodgerblue",cursor:this.linkingCursor,segmentIndex:-1}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.GS=new I,t&&Object.assign(this,t)}updateAdornments(t){if(t===null||!(t instanceof j))return;let e="RelinkFrom",i=null;if(t.isSelected&&!this.diagram.isReadOnly){let s=t.selectionObject;s!==null&&t.canRelinkFrom()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(i=t.findAdornment(e),i===null&&(i=this.makeAdornment(s,!1),t.addAdornment(e,i)))}if(i===null&&t.removeAdornment(e),e="RelinkTo",i=null,t.isSelected&&!this.diagram.isReadOnly){let s=t.selectionObject;s!==null&&t.canRelinkTo()&&t.actualBounds.isReal()&&t.isVisible()&&s.actualBounds.isReal()&&s.isVisibleObject()&&(i=t.findAdornment(e),i===null?(i=this.makeAdornment(s,!0),t.addAdornment(e,i)):i.f())}i===null&&t.removeAdornment(e)}makeAdornment(t,e){let i=e?this.XS:this.zS;return i&&(i=i.copy(),i.adornedObject=t),i}get fromHandleArchetype(){return this.NA}set fromHandleArchetype(t){t!==null&&m.se(t,J,$e,"fromHandleArchetype"),this.NA=t,t!==null?this.zS=new vt(G.Link).add(t).It():this.zS=null}get toHandleArchetype(){return this.CA}set toHandleArchetype(t){t!==null&&m.se(t,J,$e,"toHandleArchetype"),this.CA=t,t!==null?this.XS=new vt(G.Link).add(t).It():this.XS=null}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof vt||m.o("new handle is not in an Adornment: "+t)),this.Ss=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowRelink||!t.model.Cx()||!t.lastInput.left)return!1;let e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom");return e===null&&(e=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo")),e!==null}doActivate(){let t=this.diagram;if(this.originalLink===null){let i=this.handle;if(i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkFrom"),i===null&&(i=this.findToolHandleAt(t.firstInput.documentPoint,"RelinkTo"))),i===null)return;let s=i.part;if(!(s instanceof vt)||!(s.adornedPart instanceof j))return;this.handle=i,this.isForwards=s===null||s.category==="RelinkTo",this.originalLink=s.adornedPart}let e=this.originalLink;e!==null&&(this.startTransaction(this.name),t.isMouseCaptured=!0,t.currentCursor=this.linkingCursor,this.originalFromPort=e.fromPort,this.originalFromNode=e.fromNode,this.originalToPort=e.toPort,this.originalToNode=e.toNode,this.GS.set(e.actualBounds),e.pointsCount>0&&(e.fromNode===null&&(this.temporaryFromPort!==null&&(this.temporaryFromPort.desiredSize=st.bc),this.temporaryFromNode!==null&&(this.temporaryFromNode.location=e.getPoint(0))),e.toNode===null&&(this.temporaryToPort!==null&&(this.temporaryToPort.desiredSize=st.bc),this.temporaryToNode!==null&&(this.temporaryToNode.location=e.getPoint(e.pointsCount-1)))),this.copyPortProperties(this.originalFromNode,this.originalFromPort,this.temporaryFromNode,this.temporaryFromPort,!1),this.copyPortProperties(this.originalToNode,this.originalToPort,this.temporaryToNode,this.temporaryToPort,!0),t.add(this.temporaryFromNode),t.add(this.temporaryToNode),this.temporaryLink!==null&&(this.temporaryFromNode!==null&&(this.temporaryLink.fromNode=this.temporaryFromNode),this.temporaryToNode!==null&&(this.temporaryLink.toNode=this.temporaryToNode),this.copyLinkProperties(e,this.temporaryLink),this.temporaryLink.$t(),t.add(this.temporaryLink)),this.isActive=!0)}copyLinkProperties(t,e){if(t===null||e===null)return;e.adjusting=t.adjusting,e.corner=t.corner;let i=t.curve;(i===11||i===10)&&(i=0),e.curve=i,e.curviness=t.curviness,e.isTreeLink=t.isTreeLink,e.points=t.points,e.routing=t.routing,e.smoothness=t.smoothness,e.fromSpot=t.fromSpot,e.fromEndSegmentLength=t.fromEndSegmentLength,e.fromShortLength=t.fromShortLength,e.toSpot=t.toSpot,e.toEndSegmentLength=t.toEndSegmentLength,e.toShortLength=t.toShortLength}doDeactivate(){this.isActive=!1;let t=this.diagram;t.remove(this.temporaryLink),t.remove(this.temporaryFromNode),t.remove(this.temporaryToNode),t.isMouseCaptured=!1,t.currentCursor="",this.stopTransaction()}doStop(){super.doStop(),this.handle=null}doMouseUp(){if(this.isActive){let t=this.diagram;this.transactionResult=null;let e=this.originalFromNode,i=this.originalFromPort,s=this.originalToNode,n=this.originalToPort,o=this.originalLink;try{if(this.targetPort=this.findTargetPort(this.isForwards),this.targetPort!==null){let r=this.targetPort.part;r instanceof $&&(this.isForwards?(s=r,n=this.targetPort):(e=r,i=this.targetPort))}else this.isUnconnectedLinkValid?this.isForwards?(s=null,n=null):(e=null,i=null):o=null;o!==null?(this.reconnectLink(o,this.isForwards?s:e,this.isForwards?n:i,this.isForwards),this.targetPort===null&&(this.isForwards?o.defaultToPoint=t.lastInput.documentPoint:o.defaultFromPoint=t.lastInput.documentPoint,o.$t()),this.transactionResult=this.name,t.T("LinkRelinked",o,this.isForwards?this.originalToPort:this.originalFromPort)):this.originalLink!==null&&this.doNoRelink(this.originalLink,this.isForwards),this.originalLink!==null&&this.originalLink.invalidateOtherJumpOvers(this.GS)}finally{this.stopTool()}}}reconnectLink(t,e,i,s){let n=i!==null&&i.portId!==null?i.portId:"";return s?(t.toNode=e,t.toPortId=n):(t.fromNode=e,t.fromPortId=n),!0}doNoRelink(t,e){}doDraggingMouseMove(t,e,i,s){t!==null?(this.copyPortProperties(t,e,this.temporaryFromNode,this.temporaryFromPort,!1),this.diagram.add(this.temporaryFromNode)):this.diagram.remove(this.temporaryFromNode),i!==null?(this.copyPortProperties(i,s,this.temporaryToNode,this.temporaryToPort,!0),this.diagram.add(this.temporaryToNode)):this.diagram.remove(this.temporaryToNode)}stopDraggingMouseMove(){this.diagram.remove(this.temporaryFromNode),this.diagram.remove(this.temporaryToNode)}}var Ls=(x=>(x[x.None=0]="None",x[x.Horizontal=1]="Horizontal",x[x.Vertical=2]="Vertical",x[x.All=3]="All",x))(Ls||{});class Je extends $t{kr;YS;KS;Ss;Lx;HS;Em;constructor(t){super(),this.name="LinkReshaping",this.kr=new et("Rectangle",{desiredSize:st.RL,fill:"lightblue",stroke:"dodgerblue"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.YS=new et("Diamond",{desiredSize:st.Su,fill:"lightblue",stroke:"dodgerblue",cursor:"move"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.KS=3,this.Ss=null,this.Lx=null,this.HS=new P,this.Em=new q,t&&Object.assign(this,t)}static None=0;static Horizontal=1;static Vertical=2;static All=3;getReshapingBehavior(t){return t?t.Pr:0}setReshapingBehavior(t,e){t.Pr=e}updateAdornments(t){if(t===null||!(t instanceof j))return;let e=null;if(t.isSelected&&!this.diagram.isReadOnly){let i=t.path;i!==null&&t.canReshape()&&t.actualBounds.isReal()&&t.isVisible()&&i.actualBounds.isReal()&&i.isVisibleObject()&&(e=t.findAdornment(this.name),(e===null||e.qS!==t.pointsCount||e.jS!==t.resegmentable)&&(e=this.makeAdornment(i),e!==null&&(e.qS=t.pointsCount,e.jS=t.resegmentable,t.addAdornment(this.name,e))))}e===null&&t.removeAdornment(this.name)}makeAdornment(t){let e=t.part,i=e.points,s=e.pointsCount,n=e.isOrthogonal,o=null;if(i!==null&&s>1){o=new vt,o.type=G.Link;let r=e.firstPickIndex,a=e.lastPickIndex,h=n?1:0;if(e.resegmentable&&(e.computeCurve()!==9||e.isOrthogonal))for(let c=r+h;c<a-h;c++){let d=this.makeResegmentHandle(t,c);d!==null&&(d.segmentIndex=c,d.segmentFraction=.5,d.fromMaxLinks=999,o.add(d))}let l=r+1,u=a-1;for(;l<=u;)if(l<u)this.WS(t,o,r,a,l),this.WS(t,o,r,a,u),l++,u--;else if(l===u){this.WS(t,o,r,a,l);break}o.adornedObject=t}return o}WS(t,e,i,s,n){let o=t.part,r=o.isOrthogonal,a=this.makeHandle(t,n);if(a!==null){if(a.segmentIndex=n,n!==i)if(n===i+1&&r){let h=o.getPoint(i),l=o.getPoint(i+1);C.c(h.x,l.x)&&C.c(h.y,l.y)?(l=o.getPoint(i-1),C.c(h.x,l.x)?(this.setReshapingBehavior(a,2),a.cursor="n-resize"):C.c(h.y,l.y)&&(this.setReshapingBehavior(a,1),a.cursor="w-resize")):C.c(h.x,l.x)?(this.setReshapingBehavior(a,2),a.cursor="n-resize"):C.c(h.y,l.y)&&(this.setReshapingBehavior(a,1),a.cursor="w-resize")}else if(n===s-1&&r){let h=o.getPoint(s-1),l=o.getPoint(s);C.c(h.x,l.x)&&C.c(h.y,l.y)?(h=o.getPoint(s+1),C.c(h.x,l.x)?(this.setReshapingBehavior(a,2),a.cursor="n-resize"):C.c(h.y,l.y)&&(this.setReshapingBehavior(a,1),a.cursor="w-resize")):C.c(h.x,l.x)?(this.setReshapingBehavior(a,2),a.cursor="n-resize"):C.c(h.y,l.y)&&(this.setReshapingBehavior(a,1),a.cursor="w-resize")}else n===s||(this.setReshapingBehavior(a,3),a.cursor="move");e.add(a)}}makeHandle(t,e){let i=this.handleArchetype;return i===null?null:i.copy().JS()}get handleArchetype(){return this.kr}set handleArchetype(t){t!==null&&m.se(t,J,Je,"handleArchetype"),this.kr=t}makeResegmentHandle(t,e){let i=this.midHandleArchetype;return i===null?null:i.copy().JS()}get midHandleArchetype(){return this.YS}set midHandleArchetype(t){t!==null&&m.se(t,J,Je,"midHandleArchetype"),this.YS=t}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof vt||m.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedLink(){return this.Lx}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowReshape||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;let e=this.handle.part.adornedPart;if(e instanceof j){if(this.Lx=e,t.isMouseCaptured=!0,this.startTransaction(this.name),e.resegmentable&&this.handle.fromMaxLinks===999){let i=e.points.copy(),s=this.getResegmentingPoint();if(i.insertAt(this.handle.segmentIndex+1,s),e.isOrthogonal&&i.insertAt(this.handle.segmentIndex+1,s),e.points=i,e.invalidateAdornments(),e.updateAdornments(),this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name),this.handle===null){this.doDeactivate();return}}this.HS=e.getPoint(this.handle.segmentIndex),this.Em=e.points.copy(),this.isActive=!0}}doDeactivate(){this.stopTransaction(),this.handle=null,this.Lx=null;let t=this.diagram;t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){let t=this.adornedLink;t!==null&&(t.points=this.Em),this.stopTool()}getResegmentingPoint(){return this.handle===null?this.diagram.lastInput.documentPoint:this.handle.getDocumentPoint(T.Center)}doMouseMove(){let t=this.diagram;if(this.isActive){let e=this.computeReshape(t.lastInput.documentPoint);this.reshape(e)}}doMouseUp(){let t=this.diagram;if(this.isActive){let e=this.computeReshape(t.lastInput.documentPoint);this.reshape(e);let i=this.adornedLink;if(i!==null&&i.resegmentable&&this.handle!==null&&(i.computeCurve()!==9||i.isOrthogonal)){let s=this.handle.segmentIndex,n=i.getPoint(s-1),o=i.getPoint(s),r=i.getPoint(s+1);if(i.isOrthogonal){if(s>i.firstPickIndex+1&&s<i.lastPickIndex-1){let a=i.getPoint(s-2);if(this.isWithinResegmentingDistance(n,o)&&(this.isInLineOrtho(a,n,o,r,!0)||this.isInLineOrtho(a,n,o,r,!1))){let h=i.points.copy();this.isInLineOrtho(a,n,o,r,!0)?(h.setElt(s-2,new P(a.x,(r.y+a.y)/2)),h.setElt(s+1,new P(r.x,(r.y+a.y)/2))):(h.setElt(s-2,new P((r.x+a.x)/2,a.y)),h.setElt(s+1,new P((r.x+a.x)/2,r.y))),h.removeAt(s),h.removeAt(s-1),i.points=h,i.invalidateAdornments()}else if(a=i.getPoint(s+2),this.isWithinResegmentingDistance(o,r)&&(this.isInLineOrtho(n,o,r,a,!0)||this.isInLineOrtho(n,o,r,a,!1))){let h=i.points.copy();this.isInLineOrtho(n,o,r,a,!0)?(h.setElt(s-1,new P(n.x,(n.y+a.y)/2)),h.setElt(s+2,new P(a.x,(n.y+a.y)/2))):(h.setElt(s-1,new P((n.x+a.x)/2,n.y)),h.setElt(s+2,new P((n.x+a.x)/2,a.y))),h.removeAt(s+1),h.removeAt(s),i.points=h,i.invalidateAdornments()}}}else{let a=P.l();if(C.Nl(n.x,n.y,r.x,r.y,o.x,o.y,a)&&a.distanceSquaredPoint(o)<this.resegmentingDistance*this.resegmentingDistance){let h=i.points.copy();h.removeAt(s),i.points=h,i.invalidateAdornments()}P.i(a)}}t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("LinkReshaped",this.adornedLink,this.Em)}this.stopTool()}isWithinResegmentingDistance(t,e){return Math.abs(t.x-e.x)<this.resegmentingDistance&&Math.abs(t.y-e.y)<this.resegmentingDistance}isInLineOrtho(t,e,i,s,n){return n?Math.abs(t.y-e.y)<this.resegmentingDistance&&Math.abs(e.y-i.y)<this.resegmentingDistance&&Math.abs(i.y-s.y)<this.resegmentingDistance:Math.abs(t.x-e.x)<this.resegmentingDistance&&Math.abs(e.x-i.x)<this.resegmentingDistance&&Math.abs(i.x-s.x)<this.resegmentingDistance}get resegmentingDistance(){return this.KS}set resegmentingDistance(t){m.s(t,"number",Je,"resegmentingDistance"),this.KS=t}reshape(t){let e=this.adornedLink;if(e===null)return;let i=this.handle;if(i===null)return;e.startRoute();let s=i.segmentIndex,n=this.getReshapingBehavior(i);if(e.isOrthogonal)if(s===e.firstPickIndex+1){let o=e.firstPickIndex+1;n===2?(e.setPointAt(o,e.getPoint(o-1).x,t.y),e.setPointAt(o+1,e.getPoint(o+2).x,t.y)):n===1&&(e.setPointAt(o,t.x,e.getPoint(o-1).y),e.setPointAt(o+1,t.x,e.getPoint(o+2).y))}else if(s===e.lastPickIndex-1){let o=e.lastPickIndex-1;n===2?(e.setPointAt(o-1,e.getPoint(o-2).x,t.y),e.setPointAt(o,e.getPoint(o+1).x,t.y)):n===1&&(e.setPointAt(o-1,t.x,e.getPoint(o-2).y),e.setPointAt(o,t.x,e.getPoint(o+1).y))}else{let o=s,r=e.getPoint(o);if(!t.equalsApprox(r)){let a=e.getPoint(o-2),h=e.getPoint(o-1),l=e.getPoint(o+1),u=e.getPoint(o+2);C.c(h.x,r.x)&&C.c(r.y,l.y)?(C.c(h.x,a.x)&&!C.c(h.y,a.y)&&!C.c(t.x,r.x)?(e.insertPointAt(o,t.x,h.y),s++,o++):e.setPointAt(o-1,t.x,h.y),C.c(l.y,u.y)&&!C.c(l.x,u.x)&&!C.c(t.y,r.y)?e.insertPointAt(o+1,l.x,t.y):e.setPointAt(o+1,l.x,t.y)):C.c(h.y,r.y)&&C.c(r.x,l.x)?(C.c(h.y,a.y)&&!C.c(h.x,a.x)&&!C.c(t.y,r.y)?(e.insertPointAt(o,h.x,t.y),s++,o++):e.setPointAt(o-1,h.x,t.y),C.c(l.x,u.x)&&!C.c(l.y,u.y)&&!C.c(t.x,r.x)?e.insertPointAt(o+1,t.x,l.y):e.setPointAt(o+1,t.x,l.y)):C.c(h.x,r.x)&&C.c(r.x,l.x)?(C.c(h.x,a.x)&&!C.c(h.y,a.y)&&!C.c(t.x,r.x)?(e.insertPointAt(o,t.x,h.y),s++,o++):e.setPointAt(o-1,t.x,h.y),C.c(l.x,u.x)&&!C.c(l.y,u.y)&&!C.c(t.x,r.x)?e.insertPointAt(o+1,t.x,l.y):e.setPointAt(o+1,t.x,l.y)):C.c(h.y,r.y)&&C.c(r.y,l.y)&&(C.c(h.y,a.y)&&!C.c(h.x,a.x)&&!C.c(t.y,r.y)?(e.insertPointAt(o,h.x,t.y),s++,o++):e.setPointAt(o-1,h.x,t.y),C.c(l.y,u.y)&&!C.c(l.x,u.x)&&!C.c(t.y,r.y)?e.insertPointAt(o+1,l.x,t.y):e.setPointAt(o+1,l.x,t.y)),e.setPointAt(s,t.x,t.y)}}else{e.setPointAt(s,t.x,t.y);let o=e.fromNode,r=e.fromPort;if(o!==null){let l=o.findVisibleNode();l!==null&&l!==o&&(o=l,r=o.port)}if(s===1&&r!==null&&e.computeSpot(!0,r).isNoSpot()){let l=r.getDocumentPoint(T.Center,P.l()),u=e.getLinkPointFromPoint(o,r,l,t,!0,P.l());e.setPointAt(0,u.x,u.y),P.i(l),P.i(u)}let a=e.toNode,h=e.toPort;if(a!==null){let l=a.findVisibleNode();l!==null&&l!==a&&(a=l,h=a.port)}if(s===e.pointsCount-2&&h!==null&&e.computeSpot(!1,h).isNoSpot()){let l=h.getDocumentPoint(T.Center,P.l()),u=e.getLinkPointFromPoint(a,h,l,t,!1,P.l());e.setPointAt(e.pointsCount-1,u.x,u.y),P.i(l),P.i(u)}}e.commitRoute()}computeReshape(t){let e=this.adornedLink;if(e===null)return t;let i=this.handle;if(i===null)return t;let s=i.segmentIndex;switch(this.getReshapingBehavior(i)){case 3:return t;case 2:{let n=e.getPoint(s);return new P(n.x,t.y)}case 1:{let n=e.getPoint(s);return new P(t.x,n.y)}default:case 0:return e.getPoint(s)}}get originalPoint(){return this.HS}get originalPoints(){return this.Em}}class Ze extends $t{Sr;Mr;vo;Ic;$S;Ms;kr;Ss;Um;ZS;Ec;Ax;Tx;Dx;constructor(t){super(),this.name="Resizing",this.Sr=new st(1,1).k(),this.Mr=new st(9999,9999).k(),this.vo=new st(NaN,NaN).k(),this.Ic=!1,this.$S=!0,this.Ms=null,this.kr=new et("Rectangle",{alignmentFocus:T.Center,desiredSize:st.RL,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.Um=new P,this.ZS=new st,this.Ec=new P,this.Ax=new st(0,0),this.Tx=new st(1/0,1/0),this.Dx=new st(1,1),t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Nr()){let e=t.rotateObject;if(e===t||e===t.path||e.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){let e=t.resizeObject,i=t.findAdornment(this.name);if(e!==null&&t.canResize()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()&&((i===null||i.adornedObject!==e)&&(i=this.makeAdornment(e)),i!==null)){let s=e.getDocumentAngle();t.Ul()&&this.updateResizeHandles(i,s),t.addAdornment(this.name,i);return}}t.removeAdornment(this.name)}}makeAdornment(t){let e=null,i=t.part?.resizeAdornmentTemplate;if(i){if(e=i.copy(),e===null)return null}else{e=new vt,e.type=G.Spot,e.locationSpot=T.Center;let s=new le;s.isPanelMain=!0,e.add(s);let n=this.makeHandle(t,T.TopLeft);n!==null&&e.add(n),n=this.makeHandle(t,T.TopRight),n!==null&&e.add(n),n=this.makeHandle(t,T.BottomRight),n!==null&&e.add(n),n=this.makeHandle(t,T.BottomLeft),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleTop),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleRight),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleBottom),n!==null&&e.add(n),n=this.makeHandle(t,T.MiddleLeft),n!==null&&e.add(n)}return e.adornedObject=t,e}makeHandle(t,e){let i=this.handleArchetype;if(i===null)return null;let s=i.copy().JS();return s.alignment=e,s}updateResizeHandles(t,e){if(t!==null){if(!t.alignment.isDefault()&&(t.cursor==="pointer"||t.cursor.indexOf("resize")>0))this.wR(t,e);else if(t instanceof G){let i=t.elements;for(;i.next();){let s=i.value;this.updateResizeHandles(s,e)}}}}wR(t,e){let i=t.alignment;i.isNoSpot()&&(i=T.Center);let s=e;if(i.x<=0)i.y<=0?s+=225:i.y>=1?s+=135:s+=180;else if(i.x>=1)i.y<=0?s+=315:i.y>=1&&(s+=45);else if(i.y<=0)s+=270;else if(i.y>=1)s+=90;else return;s=C.Ee(s),s<22.5?t.cursor="e-resize":s<67.5?t.cursor="se-resize":s<112.5?t.cursor="s-resize":s<157.5?t.cursor="sw-resize":s<202.5?t.cursor="w-resize":s<247.5?t.cursor="nw-resize":s<292.5?t.cursor="n-resize":s<337.5?t.cursor="ne-resize":t.cursor="e-resize"}get handleArchetype(){return this.kr}set handleArchetype(t){t!==null&&m.se(t,J,Ze,"handleArchetype"),this.kr=t}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof vt||m.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedObject(){return this.Ms}set adornedObject(t){t!==null&&t.part instanceof vt&&m.o("new handle must not be in an Adornment: "+t),this.Ms=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowResize||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle!==null&&(this.adornedObject=this.handle.part.adornedObject,this.adornedObject!==null&&this.adornedObject.part!==null&&(t.isMouseCaptured=!0,t.animationManager.stopAnimation(),t.Iu=!0,this.startTransaction(this.name),this.Um.set(this.adornedObject.getDocumentPoint(this.handle.alignment.opposite())),this.Ec.set(this.adornedObject.part.location),this.ZS.set(this.adornedObject.desiredSize),this.Dx=this.computeCellSize(),this.Ax=this.computeMinSize(),this.Tx=this.computeMaxSize(),this.isActive=!0))}doDeactivate(){let t=this.diagram;t.Iu=!1,t.Fl=!0,this.stopTransaction(),this.handle=null,this.Ms=null,t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){this.adornedObject!==null&&this.adornedObject.part!==null&&(this.adornedObject.desiredSize=this.originalDesiredSize,this.adornedObject.part.location=this.originalLocation),this.stopTool()}doMouseMove(){let t=this.diagram;if(!this.isActive||this.adornedObject===null||this.handle===null)return;let e=this.Ax,i=this.Tx,s=this.Dx,n=t.lastInput.documentPoint,o=this.adornedObject.getLocalPoint(n,P.l()),r=this.computeReshape(),a=this.computeResize(o,this.handle.alignment,e,i,s,r);this.resize(a),t.maybeUpdate(),P.i(o)}doMouseUp(){let t=this.diagram;if(this.isActive&&this.adornedObject!==null&&this.handle!==null){let e=this.Ax,i=this.Tx,s=this.Dx,n=this.adornedObject.getLocalPoint(t.lastInput.documentPoint,P.l()),o=this.computeReshape(),r=this.computeResize(n,this.handle.alignment,e,i,s,o);this.resize(r),P.i(n),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("PartResized",this.adornedObject,this.originalDesiredSize)}this.stopTool()}resize(t){let e=this.diagram,i=this.adornedObject;if(i===null)return;i.desiredSize=t.size;let s=i.part;if(s===null||this.handle===null)return;s.ensureBounds();let n=i.getDocumentPoint(this.handle.alignment.opposite());if(s instanceof ht){let o=new q;o.add(s);let r;!this.dragsMembers&&!s.hasPlaceholder()&&(r=new Pi,r.dragsMembers=!1),e.moveParts(o,this.oppositePoint.copy().subtract(n),!0,r)}else s.location=s.location.copy().subtract(n).add(this.oppositePoint);e.maybeUpdate()}computeResize(t,e,i,s,n,o){if(this.adornedObject===null)return I.tm;e.isNoSpot()&&(e=T.Center);let r=this.adornedObject.naturalBounds,a=r.x,h=r.y,l=r.x+r.width,u=r.y+r.height,c=1;if(!o){let p=r.width,g=r.height;p<=0&&(p=1),g<=0&&(g=1),c=g/p}let d=P.l();C._g(t.x,t.y,a,h,n.width,n.height,d);let f=r.copy();return e.x<=0?e.y<=0?(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=Math.max(l-f.x,i.width),f.y=Math.max(d.y,u-s.height),f.y=Math.min(f.y,u-i.height),f.height=Math.max(u-f.y,i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c):(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width),f.x=l-f.width,f.y=u-f.height)):e.y>=1?(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=Math.max(l-f.x,i.width),f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c):(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width),f.x=l-f.width)):(f.x=Math.max(d.x,l-s.width),f.x=Math.min(f.x,l-i.width),f.width=l-f.x,o||(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c,f.y=h+.5*(u-h-f.height))):e.x>=1?e.y<=0?(f.width=Math.max(Math.min(d.x-a,s.width),i.width),f.y=Math.max(d.y,u-s.height),f.y=Math.min(f.y,u-i.height),f.height=Math.max(u-f.y,i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c):(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width),f.y=u-f.height)):e.y>=1?(f.width=Math.max(Math.min(d.x-a,s.width),i.width),f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.height/f.width>=1?(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c):(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width))):(f.width=Math.max(Math.min(d.x-a,s.width),i.width),o||(f.height=Math.max(Math.min(c*f.width,s.height),i.height),f.width=f.height/c,f.y=h+.5*(u-h-f.height))):e.y<=0?(f.y=Math.max(d.y,u-s.height),f.y=Math.min(f.y,u-i.height),f.height=u-f.y,o||(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width,f.x=a+.5*(l-a-f.width))):e.y>=1&&(f.height=Math.max(Math.min(d.y-h,s.height),i.height),o||(f.width=Math.max(Math.min(f.height/c,s.width),i.width),f.height=c*f.width,f.x=a+.5*(l-a-f.width))),P.i(d),f}computeReshape(){let t=0;return this.adornedObject instanceof et&&(t=this.adornedObject.QS()),!(t===6||this.diagram.lastInput.shift)}computeMinSize(){if(this.adornedObject===null)return st.bc;let t=this.adornedObject.minSize.copy(),e=this.minSize;return!isNaN(e.width)&&e.width>t.width&&(t.width=e.width),!isNaN(e.height)&&e.height>t.height&&(t.height=e.height),t}computeMaxSize(){if(this.adornedObject===null)return st.LP;let t=this.adornedObject.maxSize.copy(),e=this.maxSize;return!isNaN(e.width)&&e.width<t.width&&(t.width=e.width),!isNaN(e.height)&&e.height<t.height&&(t.height=e.height),t}computeCellSize(){let t=new st(NaN,NaN),e=this.adornedObject?.part;if(e){let n=e.resizeCellSize;!isNaN(n.width)&&n.width>0&&(t.width=n.width),!isNaN(n.height)&&n.height>0&&(t.height=n.height)}let i=this.cellSize;isNaN(t.width)&&!isNaN(i.width)&&i.width>0&&(t.width=i.width),isNaN(t.height)&&!isNaN(i.height)&&i.height>0&&(t.height=i.height);let s=this.diagram;if((isNaN(t.width)||isNaN(t.height))&&s){let n=s.grid;n!==null&&n.visible&&this.isGridSnapEnabled&&(i=n.gridCellSize,isNaN(t.width)&&!isNaN(i.width)&&i.width>0&&(t.width=i.width),isNaN(t.height)&&!isNaN(i.height)&&i.height>0&&(t.height=i.height))}return(isNaN(t.width)||t.width===0||t.width===1/0)&&(t.width=1),(isNaN(t.height)||t.height===0||t.height===1/0)&&(t.height=1),t}get minSize(){return this.Sr}set minSize(t){if(!this.Sr.equals(t)){let e=t.width;isNaN(e)&&(e=0);let i=t.height;isNaN(i)&&(i=0),this.Sr.e(e,i)}}get maxSize(){return this.Mr}set maxSize(t){if(!this.Mr.equals(t)){let e=t.width;isNaN(e)&&(e=1/0);let i=t.height;isNaN(i)&&(i=1/0),this.Mr.e(e,i)}}get cellSize(){return this.vo}set cellSize(t){this.vo.equals(t)||this.vo.h(t)}get isGridSnapEnabled(){return this.Ic}set isGridSnapEnabled(t){m.s(t,"boolean",Ze,"isGridSnapEnabled"),this.Ic=t}get dragsMembers(){return this.$S}set dragsMembers(t){m.s(t,"boolean",Ze,"dragsMembers"),this.$S=t}get oppositePoint(){return this.Um}set oppositePoint(t){this.Um.equals(t)||this.Um.h(t)}get originalDesiredSize(){return this.ZS}get originalLocation(){return this.Ec}}class De extends $t{_S;tM;Ms=null;kr=null;vx=null;Ss=null;eM;Vm;Ec;iM;sM;constructor(t){super(),this.name="Rotating",this._S=45,this.tM=2,this.Ec=new P,this.Ms=null,this.handleArchetype=new et("Ellipse",{desiredSize:st.Su,fill:"lightblue",stroke:"dodgerblue",strokeWidth:1,cursor:"pointer"}).theme("fill","adornmentFill").theme("stroke","adornmentStroke"),this.Ss=null,this.eM=0,this.Vm=new P(NaN,NaN),this.iM=0,this.sM=50,t&&Object.assign(this,t)}updateAdornments(t){if(t!==null){if(t.Nr()){let e=t.rotateObject;if(e===t||e===t.path||e.isPanelMain)return}if(t.isSelected&&!this.diagram.isReadOnly){let e=t.rotateObject;if(e!==null&&t.canRotate()&&t.actualBounds.isReal()&&t.isVisible()&&e.actualBounds.isReal()&&e.isVisibleObject()){let i=t.findAdornment(this.name);if((i===null||i.adornedObject!==e)&&(i=this.makeAdornment(e)),i!==null){i.angle=e.getDocumentAngle(),i.hasPlaceholder()||(i.location=this.computeAdornmentLocation(e)),t.addAdornment(this.name,i);return}}}t.removeAdornment(this.name)}}makeAdornment(t){let e=null,i=t.part?.rotateAdornmentTemplate;return i?e=i.copy():this.vx!==null&&(e=this.vx.copy()),e===null?null:(e.adornedObject=t,e)}get handleArchetype(){return this.kr}set handleArchetype(t){t!==null&&m.se(t,J,De,"handleArchetype"),this.kr=t,t!==null?this.vx=new vt(G.Position,{locationSpot:T.Center}).add(t).It():this.vx=null}get handle(){return this.Ss}set handle(t){t!==null&&(t.part instanceof vt||m.o("new handle is not in an Adornment: "+t)),this.Ss=t}get adornedObject(){return this.Ms}set adornedObject(t){t!==null&&t.part instanceof vt&&m.o("new handle must not be in an Adornment: "+t),this.Ms=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return t.isReadOnly||!t.allowRotate||!t.lastInput.left?!1:this.findToolHandleAt(t.firstInput.documentPoint,this.name)!==null}doActivate(){let t=this.diagram;if(this.adornedObject===null){if(this.handle===null&&(this.handle=this.findToolHandleAt(t.firstInput.documentPoint,this.name)),this.handle===null)return;this.adornedObject=this.handle.part.adornedObject}this.adornedObject===null||this.adornedObject.part===null||(t.isMouseCaptured=!0,t.delaysLayout=!0,this.startTransaction(this.name),this.eM=this.adornedObject.angle,this.Vm=this.computeRotationPoint(this.adornedObject),this.Ec=this.adornedObject.part.location.copy(),this.isActive=!0)}computeRotationPoint(t){let e=t.part;if(e!==null){let i=e.locationObject;if(e.rotationSpot.isSpot())return t.getDocumentPoint(e.rotationSpot);if(t===e||t===i)return i.getDocumentPoint(e.locationSpot)}return t.getDocumentPoint(T.Center)}computeAdornmentLocation(t){let e=this.rotationPoint;e.isReal()||(e=this.computeRotationPoint(t));let i=t.getLocalPoint(e),s=this.handleAngle;s=C.Ee(s),s=Math.round(Math.round(s/45)*45);let n=this.handleDistance;return s===0?i.x=t.naturalBounds.width+n:s===45?(i.x=t.naturalBounds.width+n,i.y=t.naturalBounds.height+n):s===90?i.y=t.naturalBounds.height+n:s===135?(i.x=-n,i.y=t.naturalBounds.height+n):s===180?i.x=-n:s===225?(i.x=-n,i.y=-n):s===270?i.y=-n:s===315&&(i.x=t.naturalBounds.width+n,i.y=-n),t.getDocumentPoint(i)}doDeactivate(){let t=this.diagram;this.stopTransaction(),this.handle=null,this.Ms=null,this.Vm=new P(NaN,NaN),t.isMouseCaptured=!1,this.isActive=!1}stopTransaction(){let t=this.diagram,e=super.stopTransaction();return e&&t.undoManager.transactionToUndo!==null&&t.undoManager.transactionToUndo.optimize(),e}doCancel(){let t=this.diagram;t.delaysLayout=!1,this.rotate(this.originalAngle),this.stopTool()}doMouseMove(){let t=this.diagram;if(this.isActive){let e=this.computeRotate(t.lastInput.documentPoint);this.rotate(e)}}doMouseUp(){let t=this.diagram;if(this.isActive){t.delaysLayout=!1;let e=this.computeRotate(t.lastInput.documentPoint);this.rotate(e),t.invalidateDocumentBounds(),this.transactionResult=this.name,t.T("PartRotated",this.adornedObject,this.originalAngle)}this.stopTool()}rotate(t){let e=this.adornedObject;if(e===null||e.part===null)return;e.angle=t;let i=e.part;i.ensureBounds();let s=i.locationObject,n=i.rotateObject;if(s===n||s.isContainedBy(n)){let o=this.Ec.copy();i.location=o.subtract(this.rotationPoint).rotate(t-this.originalAngle).add(this.rotationPoint)}this.diagram.maybeUpdate()}computeRotate(t){let e=this.rotationPoint.directionPoint(t)-this.handleAngle,i=this.adornedObject?.panel;i&&(e-=i.getDocumentAngle()),e=C.Ee(e);let s=Math.min(Math.abs(this.snapAngleMultiple),180),n=Math.min(Math.abs(this.snapAngleEpsilon),s/2);return!this.diagram.lastInput.shift&&s>0&&n>0&&(e%s<n?e=Math.floor(e/s)*s:e%s>s-n&&(e=(Math.floor(e/s)+1)*s)),C.Ee(e)}get snapAngleMultiple(){return this._S}set snapAngleMultiple(t){m.s(t,"number",De,"snapAngleMultiple"),this._S=t}get snapAngleEpsilon(){return this.tM}set snapAngleEpsilon(t){m.s(t,"number",De,"snapAngleEpsilon"),this.tM=t}get originalAngle(){return this.eM}get rotationPoint(){return this.Vm}set rotationPoint(t){this.Vm=t.copy()}get handleAngle(){return this.iM}set handleAngle(t){m.s(t,"number",De,"handleAngle"),this.iM=t}get handleDistance(){return this.sM}set handleDistance(t){m.s(t,"number",De,"handleDistance"),this.sM=t}}class Ds extends $t{constructor(t){super(),this.name="ClickSelecting",t&&Object.assign(this,t)}canStart(){return!(!this.isEnabled||this.isBeyondDragSize())}doMouseUp(){this.isActive&&(this.standardMouseSelect(),this.standardMouseClick()||this.diagram.lastInput.isTouchEvent&&this.diagram.toolManager.doToolTip()),this.stopTool()}}class Fs extends $t{Uc;constructor(t){super(),this.name="Action",this.Uc=null,t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram,e=t.lastInput,i=t.findObjectAt(e.documentPoint,s=>{for(;s.panel!==null;){if(s.isActionable)return s;s=s.panel}return s});return i!==null&&i.isActionable?(this.Uc=i,t.vc=t.findObjectAt(e.documentPoint,null,null),!0):!1}doMouseDown(){if(!this.isActive)this.canStart()&&this.doActivate();else{let t=this.diagram.lastInput,e=this.Uc;if(e===null)return;t.targetObject=e,e.actionDown!==null&&e.actionDown(t,e)}}doMouseMove(){if(this.isActive){let t=this.diagram.lastInput,e=this.Uc;if(e===null)return;t.targetObject=e,e.actionMove!==null&&e.actionMove(t,e)}}doMouseUp(){if(this.isActive){let t=this.diagram.lastInput,e=this.Uc;if(e===null)return;t.targetObject=e,e.actionUp!==null&&e.actionUp(t,e),this.standardMouseClick(i=>{for(;i.panel!==null;){if(i.isActionable&&i===e)return i;i=i.panel}return i},i=>i===e)}this.stopTool()}doCancel(){let t=this.diagram.lastInput,e=this.Uc;e!==null&&(t.targetObject=e,e.actionCancel!==null&&e.actionCancel(t,e),this.stopTool())}doStop(){this.Uc=null}}class Qe extends $t{Vl;nM;Ic;oM;constructor(t){super(),this.name="ClickCreating",this.Vl=null,this.nM=!0,this.Ic=!1,this.oM=new P(0,0),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled||this.archetypeNodeData===null)return!1;let t=this.diagram;if(t.isReadOnly||t.isModelReadOnly||!t.allowInsert||!t.lastInput.left||this.isBeyondDragSize())return!1;if(this.isDoubleClick){if(t.lastInput.clickCount===1&&(this.oM=t.lastInput.viewPoint.copy()),t.lastInput.clickCount!==2||this.isBeyondDragSize(this.oM))return!1}else if(t.lastInput.clickCount!==1)return!1;return!(t.currentTool!==this&&t.findPartAt(t.lastInput.documentPoint,!0)!==null)}doMouseUp(){let t=this.diagram;this.isActive&&this.insertPart(t.lastInput.documentPoint),this.stopTool()}insertPart(t){let e=this.diagram,i=this.archetypeNodeData;if(i===null)return null;let s=null;try{if(e.T("ChangingSelection",e.selection),this.startTransaction(this.name),i instanceof pt)i.Di()&&(i.It(),s=i.copy(),s!==null&&e.add(s));else if(i!==null){let n=e.model.copyNodeData(i);e.model.addNodeData(n),s=e.findPartForData(n)}if(s!==null){let n=P.z(t.x,t.y);this.isGridSnapEnabled&&this.diagram.rM(s,t,n),s.location=n,e.allowSelect&&(e.clearSelection(!0),s.isSelected=!0),P.i(n)}e.invalidateDocumentBounds(),this.transactionResult=this.name,e.T("PartCreated",s)}finally{this.stopTransaction(),e.T("ChangedSelection",e.selection)}return s}get archetypeNodeData(){return this.Vl}set archetypeNodeData(t){t!==null&&m.xc(t,Qe,"archetypeNodeData"),this.Vl=t}get isDoubleClick(){return this.nM}set isDoubleClick(t){m.s(t,"boolean",Qe,"isDoubleClick"),this.nM=t}get isGridSnapEnabled(){return this.Ic}set isGridSnapEnabled(t){m.s(t,"boolean",Qe,"isGridSnapEnabled"),this.Ic=t}}class ri extends $t{th;lM;Bl;constructor(t){super(),this.name="DragSelecting",this.th=175,this.lM=!1,this.Bl=new pt({layerName:"Tool",selectable:!1}).add(new et("Rectangle",{name:"SHAPE",fill:null,stroke:"magenta"}).theme("stroke","dragSelect")).It(),t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(!t.allowSelect)return!1;let e=t.lastInput;return!(!e.left||t.currentTool!==this&&(!this.isBeyondDragSize()||e.timestamp-t.firstInput.timestamp<this.delay||t.findPartAt(e.documentPoint,!0)!==null))}doActivate(){let t=this.diagram;this.isActive=!0,t.isMouseCaptured=!0,t.skipsUndoManager=!0,this.box&&t.add(this.box),this.doMouseMove()}doDeactivate(){let t=this.diagram;t.stopAutoScroll(),this.box&&t.remove(this.box),t.skipsUndoManager=!1,t.isMouseCaptured=!1,this.isActive=!1}doMouseMove(){let t=this.diagram;if(this.isActive&&this.box!==null){let e=this.computeBoxBounds(),i=this.box.findObject("SHAPE");i===null&&(i=this.box.findMainElement());let s=st.l().e(e.width,e.height);i!==null&&(i.desiredSize=s),this.box.Vc(e.x,e.y,!1),st.i(s),(t.allowHorizontalScroll||t.allowVerticalScroll)&&t.doAutoScroll(t.lastInput.viewPoint)}}doMouseUp(){if(this.isActive){let t=this.diagram;this.box&&t.remove(this.box);try{t.currentCursor="wait",t.T("ChangingSelection",t.selection),this.selectInRect(this.computeBoxBounds()),t.T("ChangedSelection",t.selection)}finally{t.currentCursor=""}}this.stopTool()}computeBoxBounds(){let t=this.diagram;return new I(t.firstInput.documentPoint,t.lastInput.documentPoint)}selectInRect(t){let e=this.diagram,i=e.lastInput,s=e.findPartsIn(t,this.isPartialInclusion);if(m.hr?i.meta:i.control)if(i.shift){let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected&&(o.isSelected=!1)}}else{let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected=!o.isSelected}}else if(i.shift){let n=s.iterator;for(;n.next();){let o=n.value;o.isSelected||(o.isSelected=!0)}}else{let n=new q,o=e.selection.iterator;for(;o.next();){let h=o.value;s.has(h)||n.add(h)}let r=n.iterator;for(;r.next();){let h=r.value;h.isSelected=!1}let a=s.iterator;for(;a.next();){let h=a.value;h.isSelected||(h.isSelected=!0)}}}get delay(){return this.th}set delay(t){m.s(t,"number",ri,"delay"),this.th=t}get isPartialInclusion(){return this.lM}set isPartialInclusion(t){m.s(t,"boolean",ri,"isPartialInclusion"),this.lM=t}get box(){return this.Bl}set box(t){t!==null&&t.It(),this.Bl=t}}class ki extends $t{Fx;LA;Do;aM;constructor(t){super(),this.name="Panning",this.Fx=new P,this.LA=new P,this.Do=!1;let e=this;this.aM=()=>{let i=e.diagram;i!==null&&i.Le(K.document,"scroll",e.aM,!1),e.stopTool()},t&&Object.assign(this,t)}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return!(!t.allowHorizontalScroll&&!t.allowVerticalScroll||!t.lastInput.left||t.currentTool!==this&&!this.isBeyondDragSize())}doActivate(){let t=this.diagram;this.Do?(t.lastInput.bubbles=!0,t.Et(K.document,"scroll",this.aM,!1)):(t.currentCursor="move",t.isMouseCaptured=!0,this.Fx.h(t.position)),this.isActive=!0}doDeactivate(){let t=this.diagram;t.currentCursor="",t.isMouseCaptured=!1,this.isActive=!1}doCancel(){let t=this.diagram;t.position=this.Fx,t.isMouseCaptured=!1,this.stopTool()}doMouseMove(){this.AA()}doMouseUp(){this.AA(),this.stopTool()}AA(){let t=this.diagram;if(this.isActive&&t){if(this.Do){t.lastInput.bubbles=!0;return}let e=t.position,i=t.firstInput.documentPoint,s=t.lastInput.documentPoint,n=e.x+i.x-s.x,o=e.y+i.y-s.y;t.allowHorizontalScroll||(n=e.x),t.allowVerticalScroll||(o=e.y),t.position=this.LA.e(n,o)}}get bubbles(){return this.Do}set bubbles(t){m.s(t,"boolean",ki,"bubbles"),this.Do=t}get originalPosition(){return this.Fx}}class fe{Rx;Ox;hM;cM;constructor(t){this.Rx=null,this.Ox=null,this.hM=null,this.cM=null,t&&Object.assign(this,t)}get mainElement(){return this.hM}set mainElement(t){t!==null&&m.se(t,HTMLElement,fe,"mainElement"),this.hM=t}get show(){return this.Rx}set show(t){this.Rx!==t&&(t!==null&&m.S(t,fe,"show"),this.Rx=t)}get hide(){return this.Ox}set hide(t){this.Ox!==t&&(t!==null&&m.S(t,fe,"hide"),this.Ox=t)}get valueFunction(){return this.cM}set valueFunction(t){this.cM=t}}class ce{ue;Ix;Bc;constructor(t,e,i){this.ue=t,this.Ix=e,this.Bc=i}}class It extends $t{fM;Ex;uM;dM;Ux;Vx;Bm;constructor(t){super(),this.name="ContextMenu",this.fM=null,this.Ex=null,this.uM=null,this.dM=new P,this.Ux=null,this.Bm=!1;let e=this;this.Vx=()=>e.stopTool(),t&&Object.assign(this,t)}xR(){let t=new fe;t.show=(r,a,h)=>h.showDefaultContextMenu(),t.hide=(r,a)=>a.hideDefaultContextMenu(),It.Bu=t;let e=this;this.Vx=()=>e.stopTool();let i=m.Ni("div"),s=m.Ni("div");i.style.cssText="top: 0px;z-index:10002;position: fixed;display: none;text-align: center;left: 25%;width: 50%;background-color: #F5F5F5;padding: 16px;border: 16px solid #444;border-radius: 10px;margin-top: 10px",s.style.cssText="z-index:10001;position: fixed;display: none;top: 0;left: 0;width: 100%;height: 100%;background-color: black;opacity: 0.8;";let n=m.Ni("style");K.document.getElementsByTagName("head")[0].appendChild(n),n.sheet.insertRule(".goCXul { list-style: none; }",0),n.sheet.insertRule(".goCXli {font:700 1.5em Helvetica, Arial, sans-serif;position: relative;min-width: 60px; }",0),n.sheet.insertRule(".goCXa {color: #444;display: inline-block;padding: 4px;text-decoration: none;margin: 2px;border: 1px solid gray;border-radius: 10px; }",0);let o=this.diagram;o!==null&&(o.Et(i,"contextmenu",It.oh,!1),o.Et(i,"selectstart",It.oh,!1),o.Et(s,"contextmenu",It.oh,!1)),i.className="goCXforeground",s.className="goCXbackground",K.document.body&&(K.document.body.appendChild(i),K.document.body.appendChild(s)),It.zm=i,It.Xm=s,It.gM=!0}static Bu=null;static gM=!1;static Xm;static zm;static oh(t){return t.preventDefault(),!1}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;return this.isBeyondDragSize()||!t.lastInput.right||t.lastInput.clickCount>1?!1:!!(t.lastInput.isTouchEvent&&this.defaultTouchContextMenu!==null||this.findObjectWithContextMenu()!==null)}doStart(){let t=this.diagram;this.dM.set(t.firstInput.documentPoint)}doStop(){this.hideContextMenu(),this.currentObject=null,this.Bm=!1}findObjectWithContextMenu(t){t===void 0&&(t=null);let e=this.diagram,i=e.lastInput,s=null;if(t instanceof Y||(t instanceof J?s=t:s=e.findObjectAt(i.documentPoint,null,n=>!n.layer?.isTemporary)),s!==null){let n=s;for(;n!==null;){if(n.contextMenu!==null)return n;n=n.panel}if(e.lastInput.isTouchEvent&&this.defaultTouchContextMenu)return s.part}else if(e.contextMenu!==null)return e;return null}doActivate(){}doMouseDown(){if(super.doMouseDown(),this.isActive&&this.currentContextMenu instanceof vt){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doMouseDown(),t.doDeactivate())}this.diagram.toolManager.mouseDownTools.has(this)&&this.doContextClick()}doMouseUp(){if(this.isActive&&this.currentContextMenu instanceof vt){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.canStart()&&(t.doActivate(),t.doCancel(),t.doDeactivate())}this.doContextClick()}doContextClick(){let t=this.diagram;if(!this.isActive)this.canStart()&&(this.openMenu(!0),this.isActive||this.stopTool());else{let e=this.currentContextMenu;if(e===null)return;let i=null;e instanceof fe||(i=t.findObjectAt(t.lastInput.documentPoint,null,null),i!==null&&i.isContainedBy(e)&&this.standardMouseClick(null,null)),this.maybeStopTool(i)}}maybeStopTool(t){this.stopTool(),this.canStart()&&(this.diagram.currentTool=this,this.doMouseUp())}openMenu(t,e){if(e===void 0&&(e=null),this.Bm)return;this.Bm=!0;let i=!1;if(e instanceof Y){let s=this.diagram.lastInput;s.targetObject=null,i=this.oA(null,s,this.diagram)}else t&&this.standardMouseSelect(),i=this.standardMouseClick();if(this.Bm=!1,!i){this.isActive=!0;let s=It.Bu;if(e===null&&(e=this.findObjectWithContextMenu()),e!==null){let n=e.contextMenu;n!==null?(this.currentObject=e instanceof J?e:null,this.showContextMenu(n,this.currentObject)):s!==null&&this.showContextMenu(s,this.currentObject)}else s!==null&&this.showContextMenu(s,null);this.currentContextMenu instanceof vt&&!this.currentContextMenu.visible&&this.stopTool()}}doMouseMove(){let t=this.diagram.toolManager.findTool("Action");t!==null&&t.doMouseMove(),this.isActive&&this.diagram.toolManager.doMouseMove()}showContextMenu(t,e){e!==null&&m.se(e,J,It,"showContextMenu:obj");let i=this.diagram;if(t!==this.currentContextMenu&&this.hideContextMenu(),t instanceof vt){let s=t;s.layerName="Tool",s.selectable=!1,s.scale=1/i.scale,s.category=this.name,s.hasPlaceholder()&&(s.placeholder.scale=i.scale);let n=s.diagram;n!==null&&n!==i&&n.remove(s),i.add(s),e!==null?s.adornedObject=e:s.data=i.model,s.ensureBounds(),this.positionContextMenu(s,e)}else t instanceof fe&&t.show!==null&&t.show(e,i,this);this.currentContextMenu=t}positionContextMenu(t,e){if(t.hasPlaceholder())return;let i=t,s=this.diagram,n=s.lastInput.documentPoint.copy(),o=i.measuredBounds,r=s.viewportBounds;s.lastInput.isTouchEvent&&(n.x-=o.width),n.x+o.width>r.right&&(n.x-=o.width+5/s.scale),n.x<r.x&&(n.x=r.x),n.y+o.height>r.bottom&&(n.y-=o.height+5/s.scale),n.y<r.y&&(n.y=r.y),i.position=n}hideContextMenu(){let t=this.diagram,e=this.currentContextMenu;e!==null&&(e instanceof vt?(t.remove(e),this.Ex!==null&&this.Ex.removeAdornment(e.category),e.data=null,e.adornedObject=null):e instanceof fe&&(e.hide!==null?e.hide(t,this):e.mainElement!==null&&(e.mainElement.style.display="none")),this.currentContextMenu=null,this.standardMouseOver())}bR(){let t=this,e=new q;return e.add(new ce("Copy",i=>i.commandHandler.copySelection(),i=>i.commandHandler.canCopySelection())),e.add(new ce("Cut",i=>i.commandHandler.cutSelection(),i=>i.commandHandler.canCutSelection())),e.add(new ce("Delete",i=>i.commandHandler.deleteSelection(),i=>i.commandHandler.canDeleteSelection())),e.add(new ce("Paste",i=>i.commandHandler.pasteSelection(t.mouseDownPoint),i=>i.commandHandler.canPasteSelection(t.mouseDownPoint))),e.add(new ce("Select All",i=>i.commandHandler.selectAll(),i=>i.commandHandler.canSelectAll())),e.add(new ce("Undo",i=>i.commandHandler.undo(),i=>i.commandHandler.canUndo())),e.add(new ce("Redo",i=>i.commandHandler.redo(),i=>i.commandHandler.canRedo())),e.add(new ce("Scroll To Part",i=>i.commandHandler.scrollToPart(),i=>i.commandHandler.canScrollToPart())),e.add(new ce("Zoom To Fit",i=>i.commandHandler.zoomToFit(),i=>i.commandHandler.canZoomToFit())),e.add(new ce("Reset Zoom",i=>i.commandHandler.resetZoom(),i=>i.commandHandler.canResetZoom())),e.add(new ce("Group Selection",i=>i.commandHandler.groupSelection(),i=>i.commandHandler.canGroupSelection())),e.add(new ce("Ungroup Selection",i=>i.commandHandler.ungroupSelection(),i=>i.commandHandler.canUngroupSelection())),e.add(new ce("Edit Text",i=>i.commandHandler.editTextBlock(),i=>i.commandHandler.canEditTextBlock())),e}showDefaultContextMenu(){let t=this.diagram;this.Ux===null&&(this.Ux=this.bR()),It.zm.innerHTML="",It.Xm.addEventListener("pointerdown",this.Vx,!1);let e=this,i=m.Ni("ul");i.className="goCXul",It.zm.appendChild(i),i.innerHTML="";let s=this.Ux.iterator;for(;s.next();){let n=s.value,o=n.Ix,r=n.Bc;if(!m.it(o)||m.it(r)&&!r(t))continue;let a=m.Ni("li");a.className="goCXli";let h=m.Ni("a");h.className="goCXa",h.href="#",h.Ix=o,h.addEventListener("pointerdown",function(l){return this.Ix(t),e.stopTool(),l.preventDefault(),!1},!1),h.textContent=n.ue,a.appendChild(h),i.appendChild(a)}It.zm.style.display="block",It.Xm.style.display="block"}hideDefaultContextMenu(){if(this.currentContextMenu===null||this.currentContextMenu!==It.Bu)return;It.zm.style.display="none",It.Xm.style.display="none";let t=this.diagram;t!==null&&t.Le(It.Xm,"pointerdown",this.Vx,!1),this.currentContextMenu=null}doMouseWheel(){this.standardMouseWheel()}get currentContextMenu(){return this.fM}set currentContextMenu(t){this.fM=t,this.Ex=t instanceof vt?t.adornedPart:null}get defaultTouchContextMenu(){return It.gM===!1&&It.Bu===null&&Y.isUsingDOM()&&this.xR(),It.Bu}set defaultTouchContextMenu(t){t===null&&(It.gM=!0),It.Bu=t}get currentObject(){return this.uM}set currentObject(t){t!==null&&m.se(t,J,It,"currentObject"),this.uM=t}get mouseDownPoint(){return this.dM}}var Os=(x=>(x[x.LostFocus=1]="LostFocus",x[x.MouseDown=2]="MouseDown",x[x.Tab=3]="Tab",x[x.Enter=4]="Enter",x))(Os||{}),Rs=(x=>(x[x.SingleClick=1]="SingleClick",x[x.SingleClickSelected=2]="SingleClickSelected",x[x.DoubleClick=3]="DoubleClick",x))(Rs||{}),Es=(x=>(x[x.None=1]="None",x[x.Active=2]="Active",x[x.Editing=3]="Editing",x[x.Validating=4]="Validating",x[x.Invalid=5]="Invalid",x[x.Validated=6]="Validated",x))(Es||{});class oe extends $t{vi;mM;pM;zl;Gt;yM;wM;xM;Bx;zx;constructor(t){super(),this.name="TextEditing",this.vi=new lt,this.mM=null,this.pM=2,this.zl=null,this.Gt=1,this.yM=1,this.wM=!0,this.xM=null,this.Bx=new fe,this.zx=null,this.kR(this.Bx),t&&Object.assign(this,t)}static LostFocus=1;static MouseDown=2;static Tab=3;static Enter=4;static SingleClick=1;static SingleClickSelected=2;static DoubleClick=3;static StateNone=1;static StateActive=2;static StateEditing=3;static StateValidating=4;static StateInvalid=5;static StateValidated=6;kR(t){if(!Y.isUsingDOM())return;let e=m.Ni("textarea");this.zx=e;let i=this;e.addEventListener("input",function(s){if(i.textBlock===null)return;let n=i.measureTemporaryTextBlock(this.value),o=this.textScale;this.style.width=20+Math.max(i.textBlock.measuredBounds.width,n.measuredBounds.width)*o+"px",this.rows=Math.max(i.textBlock.lineCount,n.lineCount)},!1),e.addEventListener("keydown",function(s){if(s.isComposing||i.textBlock===null)return;let n=s.key;if(n==="Enter"){i.textBlock.isMultiline===!1&&s.preventDefault(),i.acceptText(4);return}else if(n==="Tab"){i.acceptText(3),s.preventDefault();return}else n==="Escape"&&(i.doCancel(),i.diagram!==null&&i.diagram.doFocus())},!1),e.addEventListener("focus",function(s){i.PR(s)},!1),e.addEventListener("blur",function(s){i.SR(s)},!1),t.valueFunction=()=>e.value,t.mainElement=e,t.show=(s,n,o)=>{if(!(s instanceof lt)||!n||!n.div||!(o instanceof oe))return;if(o.state===5){e.style.border="3px solid red",e.focus();return}let r=s.getDocumentPoint(T.Center),a=n.position,h=n.scale,l=s.getDocumentScale()*h;l<o.minimumEditorScale&&(l=o.minimumEditorScale);let u=s.naturalBounds.width*l+6,c=s.naturalBounds.height*l+2,d=(r.x-a.x)*h,f=(r.y-a.y)*h,p=s.verticalAlignment,g=(s.lineHeight+s.spacingAbove+s.spacingBelow)*s.lineCount*l,y=.5*c-.5*g,b=p.y*c-p.y*g+p.offsetY-y-g/2;e.value=s.text,n.div.style.font=s.font;let v=1;e.style.position="absolute",e.style.zIndex="100",e.style.font="inherit",e.style.fontSize=l*100+"%",e.style.lineHeight="normal",e.style.width=u+"px",e.style.left=(d-u/2|0)-v+"px",e.style.top=(f+b|0)-v+"px",e.style.textAlign=s.textAlign,e.style.margin="0",e.style.padding=v+"px",e.style.border="0",e.style.outline="none",e.style.whiteSpace="pre-wrap",e.style.overflow="hidden",e.rows=s.lineCount,e.textScale=l,e.className="goTXarea",n.div.appendChild(e),e.focus(),o.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))},t.hide=(s,n)=>{s.div&&s.div.removeChild(e)}}get textBlock(){return this.mM}set textBlock(t){t!==null&&m.se(t,lt,oe,"textBlock"),this.mM=t}get currentTextEditor(){return this.xM}set currentTextEditor(t){this.xM=t}get defaultTextEditor(){return this.Bx}set defaultTextEditor(t){this.Bx=t}get starting(){return this.pM}set starting(t){this.pM=t}canStart(){if(!this.isEnabled)return!1;let t=this.diagram;if(t===null||t.isReadOnly||oe.zc&&oe.zc!==this&&(oe.zc.acceptText(2),oe.zc&&oe.zc!==this)||!t.lastInput.left||this.isBeyondDragSize())return!1;let e=t.lastInput.documentPoint,i=t.findObjectAt(e);if(i===null||!(i instanceof lt)||!i.editable||i.part===null||!i.part.canEdit())return!1;let s=i.part;return!(s===null||this.starting===2&&!s.isSelected||this.starting===3&&t.lastInput.clickCount<2)}doStart(){oe.zc=this,this.textBlock!==null&&this.doActivate()}doActivate(){if(this.isActive)return;let t=this.diagram;if(t===null)return;let e=this.textBlock;if(e===null&&(e=t.findObjectAt(t.lastInput.documentPoint)),e===null||!(e instanceof lt)||(this.textBlock=e,e.part===null))return;t.animationManager.stopAnimation(),this.isActive=!0,this.Gt=2;let i=this.defaultTextEditor;e.textEditor!==null&&(i=e.textEditor),this.vi=this.textBlock.copy();let s=new I(this.textBlock.getDocumentPoint(T.TopLeft),this.textBlock.getDocumentPoint(T.BottomRight));t.scrollToRect(s),i!==null&&i.show!==null&&i.show(e,t,this),this.currentTextEditor=i}doCancel(){this.stopTool()}doMouseUp(){this.canStart()&&this.doActivate()}doMouseDown(){this.isActive&&this.acceptText(2)}acceptText(t){switch(t){case 2:this.Gt===6?this.currentTextEditor instanceof HTMLElement&&this.currentTextEditor.focus():(this.Gt===2||this.Gt===5||this.Gt===3)&&(this.Gt=4,this.TA());break;case 1:case 4:case 3:if(t===4&&this.textBlock!==null&&this.textBlock.isMultiline===!0)return;(this.Gt===2||this.Gt===5||this.Gt===3)&&(this.Gt=4,this.TA());break}}TA(){let t=this.textBlock,e=this.diagram,i=this.currentTextEditor;if(t!==null&&i!==null){let s=t.text,n="";if(i.valueFunction!==null&&(n=i.valueFunction()),!this.isValidText(t,s,n)){this.Gt=5,this.doError(s,n);return}this.startTransaction(this.name),this.Gt=6,this.transactionResult=this.name,t.text=n,this.doSuccess(s,n),e!==null&&e.T("TextEdited",t,s),this.stopTransaction(),this.stopTool(),e!==null&&e.doFocus()}}doError(t,e){let i=this.textBlock;if(i===null)return;i.errorFunction!==null&&i.errorFunction(this,t,e);let s=this.currentTextEditor;s!==null&&s.show!==null&&s.show(i,this.diagram,this)}doSuccess(t,e){let i=this.textBlock;i!==null&&i.textEdited!==null&&i.textEdited(i,t,e)}doDeactivate(){let t=this.diagram;if(t!==null){if(this.Gt=1,this.currentTextEditor!==null){let e=this.currentTextEditor;e!==null&&e.hide!==null&&e.hide(t,this)}this.textBlock=null,this.isActive=!1}}doStop(){oe.zc=null}PR(t){if(this.currentTextEditor===null||this.state===1)return;let e=this.zx;this.Gt===2&&(this.Gt=3),m.it(e.select)&&this.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))}SR(t){if(this.currentTextEditor===null||this.state===1)return;let e=this.zx;m.it(e.focus)&&e.focus(),m.it(e.select)&&this.selectsTextOnActivate&&(e.select(),e.setSelectionRange(0,9999))}isValidText(t,e,i){let s=this.textValidation;if(s!==null&&!s(t,e,i))return!1;let n=t.textValidation;return!(n!==null&&!n(t,e,i))}get textValidation(){return this.zl}set textValidation(t){t!==null&&m.S(t,oe,"textValidation"),this.zl=t}get minimumEditorScale(){return this.yM}set minimumEditorScale(t){t!==null&&m.s(t,"number",oe,"minimumEditorScale"),this.yM=t}get selectsTextOnActivate(){return this.wM}set selectsTextOnActivate(t){t!==null&&m.s(t,"boolean",oe,"selectsTextOnActivate"),this.wM=t}get state(){return this.Gt}set state(t){this.Gt!==t&&(this.Gt=t)}measureTemporaryTextBlock(t){let e=this.vi;return e.text=t,this.textBlock!==null&&e.ht(this.textBlock.Xl,1/0),e}static zc=null}var Is=(x=>(x[x.Default=1]="Default",x[x.AnimateLocations=2]="AnimateLocations",x[x.None=3]="None",x))(Is||{});class he{a;Ae;Be;Cr;$n;Fo;bM;kM;Gm;Xx;ke;Xc;xn;Ym;lh;Gx;Km;Yx;Gc;Uu;Hm;constructor(t){this.a=Y.Rm(),this.Ae=!1,this.Gm=!1,this.Xx=!1,this.ke=!1,this.Xc=!1,this.Yx=!0,this.Gc=1,this.Uu=!1,this.Be=!0,this.Cr=!0,this.Fo=600,this.bM=!1,this.kM=!1,this.$n=new V,this.xn=new ye,this.Ym=new ye,this.xn.Ns=this,this.lh=new V,this.Gx=new V,this.Km=new V,this.Hm=new V,t&&Object.assign(this,t)}Ro(t){this.a=t}FU(){return this.a}canStart(t){return!0}Gl(t){return!this.Be||!this.canStart(t)?!1:(this.$n.add(t),this.defaultAnimation.isAnimating&&this.stopAnimation(),this.a.Te(),this.ke=!0,!0)}getBundleAnimation(){return this.Ym}PM(){if(!this.Be||(this.Ym.yi.count>0&&this.Ym.start(),!this.ke))return;let t=this.xn,e=this.a,i=this.$n.has("Model");if(i&&(this.Xc=!0,this.Gc===1?(t.isViewportUnconstrained=!0,t.yi.clear(),t.add(e,"position",e.position.copy().offset(0,-200),e.position),t.add(e,"opacity",0,1)):this.Gc===3&&t.yi.clear(),this.Gc===2&&e.Kx.equals(e.ct)?this.Yx=!0:this.Yx=!1,e.T("InitialAnimationStarting",this)),i&&!this.Cr||t.yi.count===0){this.$n.clear(),this.ke=!1,t.yi.clear(),t.Hx(e),this.Xc=!1,e.C();return}this.$n.clear(),e.Lr=!1;let s=t.yi.get(e);e.autoScale!==1&&s!==null&&(delete s.ae.scale,delete s.Cs.scale);let n=this;K.requestAnimationFrame(()=>{n.ke===!1||t.Ae||(e.getRenderingHint("temporaryPixelRatio")&&e.Sx(),e.SM(),n.ke=!1,t.start(),t.Ae&&(n.zu(),e.invalidateDocumentBounds(),t.DA(0),e.br(!0),n.Xu(),e.T("AnimationStarting",n)))})}MM(){return this.$n.has("Trigger")&&this.$n.count===1}vA(t,e,i,s){this.isTicking||this.MM()||t instanceof j&&(t.fromNode!==null||t.toNode!==null)||this.xn.add(t,"position",e,i,s)}qx(t){return this.xn.qx(t)}NM(t){return this.xn.NM(t)}MR(t){let e=this.lh,i=this;function s(){if(i.Km.count>0&&(e.addAll(i.Km),i.Km.clear(),i.Ae=!0),i.Ae===!1||e.count===0){i.Xx=!1;return}i.Gx.addAll(e);let n=i.Gx.iterator;for(;n.next();){let o=n.value;o.Ae!==!1&&(o.NR()?o.FA(!1):o.Yc=!0)}if(i.Gx.clear(),i.Ae===!1){K.requestAnimationFrame(s);return}i.zu(),i.a.br(),i.Xu(),K.requestAnimationFrame(s)}this.Ae?this.RA(t):(this.Ae=!0,this.Xx?this.RA(t):(this.Xx=!0,e.add(t),K.requestAnimationFrame(()=>s())))}RA(t){this.Km.add(t)}CR(){let t=this.lh.iterator;for(;t.next();)t.value.Yc=!1}zu(){if(this.Gm)return;let t=this.a;this.bM=t.skipsUndoManager,this.kM=t.wi,t.skipsUndoManager=!0,t.wi=!0,this.Gm=!0}Xu(){let t=this.a;t.skipsUndoManager=this.bM,t.wi=this.kM,this.Gm=!1}stopAnimation(t){let e=this.xn;if(this.ke===!0&&(this.ke=!1,this.Xc=!1,this.$n.clear(),e.LR()&&this.a.requestUpdate()),!this.Ae){e.yi.clear(),e.Hx(this.a);return}if(e.Gu(!0),e.Hx(null),t===!0){let i=this.lh.toArray();for(let s=0;s<i.length;s++)i[s].Gu(!0)}}Gu(t){this.lh.delete(t),this.lh.count===0&&(this.Ae=!1,this.a.requestUpdate()),t===this.defaultAnimation&&this.a.T("AnimationFinished",this)}Kc(t,e){this.ke&&(!this.$n.has("Expand Tree")&&!this.$n.has("Expand SubGraph")||(this.xn.Kc(t,e),this.OA(t)))}Hc(t,e){this.ke&&(!this.$n.has("Collapse Tree")&&!this.$n.has("Collapse SubGraph")||(this.xn.Hc(t,e),this.xn.CM(e,"position",e.position,e.position),this.OA(t)))}IA(t,e){!this.ke||t.equals(e)||this.MM()||(this.a.Qa||(t=e.copy()),this.xn.CM(this.a,"position",t,e))}EA(t,e){this.ke&&(this.MM()||this.xn.add(this.a,"scale",t,e))}LM(t,e){t.Fi&&(t.Ar=e,this.Hm.add(t))}OA(t){let e=t.findLinksConnected();for(;e.next();){let i=e.value;i.Fi&&(i.Ar=i.points.copy(),this.Hm.add(i))}}get isEnabled(){return this.Be}set isEnabled(t){m.s(t,"boolean",he,"isEnabled"),this.Be=t,t&&this.lh.each(e=>{!e.isAnimating&&e.runCount===1/0&&e.start()})}get duration(){return this.Fo}set duration(t){m.s(t,"number",he,"duration"),t<1&&m.J(t,">= 1",he,"duration"),this.Fo=t}get isAnimating(){return this.Ae}get isTicking(){return this.Gm}get isInitial(){return this.Cr}set isInitial(t){m.s(t,"boolean",he,"isInitial"),this.Cr=t}get defaultAnimation(){return this.xn}get activeAnimations(){return this.lh}get initialAnimationStyle(){return this.Gc}set initialAnimationStyle(t){this.Gc=t}static jx=new Mt;static defineAnimationEffect(t,e){he.jx.set(t,e)}static AM(t,e,i,s,n){t===null&&(t=[0,0,0,0]),e===null&&(e=[0,0,0,0]);let o=t[0],r=t[1],a=t[2],h=t[3],l=e[0],u=e[1],c=e[2],d=e[3];a===0||a===100?(o=l,r=u):(c===0||c===100)&&(l=o,u=r),Math.abs(l-o)>180&&(l>o?o+=360:l+=360);let f=n(i,o,l-o,s)%360,p=n(i,r,u-r,s),g=n(i,a,c-a,s),y=n(i,h,d-h,s);return"hsla("+f+", "+p+"%, "+g+"%, "+y+")"}static Default=1;static AnimateLocations=2;static None=3}{let x=he.jx,t=(e,i,s,n,o,r)=>{e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))};x.set("position:diagram",t),x.set("position",t),x.set("position:part",(e,i,s,n,o,r)=>{o<r?e.Vc(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!1):e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("location",(e,i,s,n,o,r)=>{o<r?e.Vc(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!0):e.location=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("position:placeholder",(e,i,s,n,o,r)=>{o<r?e.Vc(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r),!1):e.position=new P(n(o,i.x,s.x-i.x,r),n(o,i.y,s.y-i.y,r))}),x.set("position:nodeCollapse",(e,i,s,n,o,r)=>{let a=e.actualBounds,h=s.actualBounds,l=h.x+h.width/2-a.width/2,u=h.y+h.height/2-a.height/2;o<r?e.Vc(n(o,i.x,l-i.x,r),n(o,i.y,u-i.y,r),!1):e.position=new P(n(o,i.x,l-i.x,r),n(o,i.y,u-i.y,r))}),x.set("desiredSize",(e,i,s,n,o,r)=>{e.desiredSize=new st(n(o,i.width,s.width-i.width,r),n(o,i.height,s.height-i.height,r))}),x.set("width",(e,i,s,n,o,r)=>{e.width=n(o,i,s-i,r)}),x.set("height",(e,i,s,n,o,r)=>{e.height=n(o,i,s-i,r)}),x.set("fill",(e,i,s,n,o,r)=>{e.fill=he.AM(i,s,o,r,n)}),x.set("stroke",(e,i,s,n,o,r)=>{e.stroke=he.AM(i,s,o,r,n)}),x.set("strokeWidth",(e,i,s,n,o,r)=>{e.strokeWidth=n(o,i,s-i,r)}),x.set("strokeDashOffset",(e,i,s,n,o,r)=>{e.strokeDashOffset=n(o,i,s-i,r)}),x.set("background",(e,i,s,n,o,r)=>{e.background=he.AM(i,s,o,r,n)}),x.set("opacity",(e,i,s,n,o,r)=>{e.opacity=n(o,i,s-i,r)}),x.set("scale",(e,i,s,n,o,r)=>{e.scale=n(o,i,s-i,r)}),x.set("angle",(e,i,s,n,o,r)=>{e.angle=n(o,i,s-i,r)})}class ye{Wx;qm;Ae;Yu;Fo;Ls;UA;qc;yi;Jx;ae;Zn;Ku;jc;$x;Zx;Yc;TM;Qx;Ns;a;DM;vM;FM;constructor(t){this.a=null,this.Ns=null,this.TM=null,this.Qx=null,this.DM=!1,this.Ae=!1,this.Yc=!1,this.ae=0,this.Zn=0,this.Wx=ye.EaseInOutQuad,this.qm=ye.EaseInOutQuad,this.Ku=!1,this.jc=!1,this.$x=1,this.Zx=0,this.Fo=NaN,this.Ls=NaN,this.vM=0,this.Yu=null,this.UA=P.dn,this.yi=new Mt,this.Jx=new Mt,this.qc=new V,this.FM=1,t&&Object.assign(this,t)}suspend(){this.Yc=!0}advanceTo(t,e){e&&(this.Yc=!1),this.Ku&&t>=this.Ls&&(this.jc=!0,t=t-this.Ls),this.vM=t,this.FA(!0),this.Ns.zu(),this.a.br(),this.Ns.Xu(),this.a.redraw()}Hx(t){if(this.Jx.clear(),this.jc=!1,this.Zx=0,this.Ls=NaN,this.qc.count>0&&this.qc.clear(),t!==null){let e=t.links;for(;e.next();)e.value.Ar=null}}LR(){return this.yi.count>0}start(){if(this.yi.count===0)return this;if(this.Ae)return this;let t=this.a,e=this.yi.iterator;for(;e.next();){let s=e.key;t===null&&(s instanceof Y?t=s:s instanceof J&&(t=s.diagram))}if(t!==null)this.a=t,this.Ns=t.animationManager;else return this;let i=this.Ns;return i.isEnabled===!1?this:(this.Ls=isNaN(this.Fo)?i.duration:this.Fo,this.qm=this.Wx,i.Xc&&i.Gc===1&&this===i.defaultAnimation&&(this.qm=ye.EaseOutExpo,this.Ls=isNaN(this.Fo)?i.duration===600?900:i.duration:this.Fo),this.FM=t.scrollMode,this.isViewportUnconstrained&&(t.ah=2),i.zu(),this.qc.each(s=>{s.data=null,t.add(s)}),i.Xu(),this.Ae=!0,this.ae=+new Date,this.Zn=this.ae+this.Ls,i.MR(this),this)}addTemporaryPart(t,e){return t.Di()?(this.qc.add(t),this.a=e,this):this}add(t,e,i,s,n){if(this.a===null&&(t instanceof Y?this.a=t:t instanceof J&&t.diagram!==null&&(this.a=t.diagram)),t instanceof pt){if(!t.isAnimated)return this;e==="position"&&(e="position:part")}return this.CM(t,e,i,s,n),this}CM(t,e,i,s,n){let o=this.yi,r,a,h;if(t instanceof Y&&e==="position"&&(e="position:diagram"),(e==="fill"||e==="stroke"||e==="background")&&(R.Oo(i),R.RM(),i=[R.ze.n0,R.ze.n1,R.ze.n2,R.ze.n3],R.Oo(s),R.RM(),s=[R.ze.n0,R.ze.n1,R.ze.n2,R.ze.n3]),o.has(t))r=o.get(t),a=r.ae,h=r.Cs,a[e]===void 0&&(a[e]=this.Hu(i)),h[e]=this.Hu(s);else{if(e==="position"&&i.equalsApprox(s))return;a={},h={},a[e]=this.Hu(i),h[e]=this.Hu(s),r=new Dn(a,h,n),o.set(t,r)}let l=a[e];l instanceof P&&!l.isReal()&&l.h(this.UA),n&&e.indexOf("position:")===0&&t instanceof pt?r._x.location=this.Hu(t.location):n&&(r._x[e]=this.Hu(i))}Hu(t){return t instanceof P||t instanceof st?t.copy():t}AR(t){let e=this.yi;if(e.has(t)){let i=e.get(t);i.tb=!0}}qx(t){if(!this.Ae)return!1;let e=this.yi.get(t);return e!==null&&e.tb}NM(t){if(!this.Ae)return!1;let e=this.yi.get(t);return e!==null&&!!(e.ae.position||e.ae["position:part"]||e.ae.location)}NR(){if(this.qc.count>0)return!0;let t=this.yi.iterator;for(;t.next();){let e=t.key;if(e instanceof J&&e.diagram!==null||e instanceof Y)return!0}return!1}FA(t){if(this.Yc&&!t)return;let e=this.Ns;if(this.Ae===!1)return;let i=+new Date,s=i>this.Zn?this.Ls:i-this.ae;t&&(s=this.vM,s<this.Ls?(this.ae=+new Date-s,this.Zn=this.ae+this.Ls):s=this.Ls),e.zu(),this.DA(s),this.a.br(!0),e.Xu(),i>this.Zn&&(this.Ku&&!this.jc?(this.ae=+new Date,this.Zn=this.ae+this.Ls,this.jc=!0):this.Gu(!1))}DA(t){let e=this.Ls,i=this.yi.iterator,s=this.jc;for(;i.next();){let n=i.key;if(n instanceof J&&n.diagram===null)continue;let o=i.value,r=s?o.Cs:o.ae,a=s?o.ae:o.Cs,h=he.jx;for(let l in a)l==="position"&&(a["position:placeholder"]||a["position:nodeCollapse"])||h.get(l)!==null&&h.get(l)(n,r[l],a[l],this.qm,t,e,this)}}stop(){return this.Ae?(this.Gu(!0),this):this}Gu(t){if(this.Qx!==null&&this.Qx.TR(this.TM),!this.Ae)return;let e=this.a,i=this.Ns;i.Xc=!1,this.Ae=!1,this.Yc=!1,i.zu();let s=this.yi,n=this.qc.iterator;for(;n.next();)e.remove(n.value);let o=this.Ku,r=s.iterator,a=he.jx;for(;r.next();){let l=r.key,u=r.value,c=o?u.Cs:u.ae,d=o?u.ae:u.Cs,f=u._x;for(let p in d)if(a.get(p)!==null){let g=p;u.eb&&(g==="position:nodeCollapse"||g==="position:placeholder")&&(g="position"),a.get(g)(l,c[p],f[p]!==void 0?f[p]:u.eb?c[p]:d[p],this.qm,this.Ls,this.Ls,this)}u.eb&&f.location!==void 0&&l instanceof pt&&(l.location=f.location),u.tb&&l instanceof pt&&l.Xe(!1)}this.Zx++;let h=!t&&this.$x>this.Zx;if(!h&&(this===i.Ym||this===i.defaultAnimation)&&this.yi.clear(),e.ib.clear(),e.mS(!1),e.invalidateDocumentBounds(),e.C(),e.br(!0),i.defaultAnimation===this){let l=i.Hm.iterator;for(;l.next();)l.value.DR();i.Hm.clear()}if(e.br(!0),this.isViewportUnconstrained&&(e.scrollMode=this.FM),i.Xu(),h){this.jc=!1,this.start();return}this.Hx(null),e.VA(),i.Gu(this),this.Yu&&this.Yu(this),e.requestUpdate()}Kc(t,e){let i=e.actualBounds,s=null;if(e instanceof ht&&(s=e.placeholder),s!==null&&s.visible){let n=s.getDocumentPoint(T.TopLeft),o=s.padding;n.x+=o.left,n.y+=o.top,this.add(t,"position",n,t.position,!1)}else this.add(t,"position",new P(i.x+i.width/2,i.y+i.height/2),t.position,!1);this.add(t,"scale",.01,t.scale,!1),t instanceof ht&&this.vR(t,e)}vR(t,e){let i=t.memberParts;for(;i.next();){let s=i.value;s instanceof $&&this.Kc(s,e)}}Hc(t,e){if(!t.isVisible())return;let i=null;if(e instanceof ht&&(i=e.placeholder),i!==null&&i.visible){let s=i.getDocumentPoint(T.TopLeft),n=i.padding;s.x+=n.left,s.y+=n.top,this.add(t,"position:placeholder",t.position,s,!0)}else this.add(t,"position:nodeCollapse",t.position,e,!0);this.add(t,"scale",t.scale,.01,!0),this.AR(t),t instanceof ht&&this.FR(t,e)}FR(t,e){let i=t.memberParts;for(;i.next();){let s=i.value;s instanceof $&&this.Hc(s,e)}}get duration(){return this.Fo}set duration(t){m.s(t,"number",ye,"duration"),t<1&&m.J(t,">= 1",ye,"duration"),this.Fo=t}get reversible(){return this.Ku}set reversible(t){this.Ku=t}get runCount(){return this.$x}set runCount(t){t>0?this.$x=t:m.o("Animation.runCount value must be a positive integer.")}get finished(){return this.Yu}set finished(t){this.Yu!==t&&(t!==null&&m.S(t,ye,"finished"),this.Yu=t)}get easing(){return this.Wx}set easing(t){this.Wx=t}get isViewportUnconstrained(){return this.DM}set isViewportUnconstrained(t){this.DM=t}get isAnimating(){return this.Ae}getTemporaryState(t){let e=this.Jx.get(t);return e===null&&(e={},this.Jx.set(t,e)),e}static EaseLinear=(t,e,i,s)=>i*t/s+e;static EaseInOutQuad=(t,e,i,s)=>(t/=s/2,t<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e);static EaseInQuad=(t,e,i,s)=>i*(t/=s)*t+e;static EaseOutQuad=(t,e,i,s)=>-i*(t/=s)*(t-2)+e;static EaseInExpo=(t,e,i,s)=>t===0?e:i*Math.pow(2,10*(t/s-1))+e;static EaseOutExpo=(t,e,i,s)=>t===s?e+i:i*(-Math.pow(2,-10*t/s)+1)+e}class Dn{ae;Cs;_x;eb;tb;constructor(t,e,i){this.ae=t,this.Cs=e,this._x={},this.eb=i,this.tb=!1}}var Bs=(x=>(x[x.Default=1]="Default",x[x.Immediate=2]="Immediate",x[x.Bundled=3]="Bundled",x))(Bs||{});class ai{Ti;pn;qu;Wc;constructor(t,e,i){this.Ti=null,this.pn=t,this.qu=i||1,this.Wc=null,e!==void 0&&(this.Wc=e,i===void 0&&(this.qu=2))}copy(){let t=new ai(this.pn);t.qu=this.qu;let e=this.Wc;if(e!==null){let i={};e.duration!==void 0&&(i.duration=e.duration),e.finished!==void 0&&(i.finished=e.finished),e.easing!==void 0&&(i.easing=e.easing),t.Wc=i}return t}get propertyName(){return this.pn}set propertyName(t){this.pn=t}get animationSettings(){return this.Wc}set animationSettings(t){this.Wc=t}RR(t){let e=this.Wc;e!==null&&(e.duration&&(t.duration=e.duration),e.finished&&(t.finished=e.finished),e.easing&&(t.easing=e.easing))}get startCondition(){return this.qu}set startCondition(t){this.qu=t}static Default=1;static Immediate=2;static Bundled=3}class Et{a;Pt;Zt;Tr;Yl;Kl;Hl;ql;jl;Wl;Jl;$l;Zl;Ql;_l;ta;Bc;ea;sb;jm;ju;Nt;constructor(t){V.Je(this),this.a=null,this.Nt=new q,this.Pt="",this.Zt=1,this.Tr=!1,this.Yl=!0,this.Kl=!0,this.Hl=!0,this.ql=!0,this.jl=!0,this.Wl=!0,this.Jl=!0,this.$l=!0,this.Zl=!0,this.Ql=!0,this._l=!0,this.ta=!0,this.Bc=!0,this.ea=!0,this.sb=!0,this.jm=!1,this.ju=[],t&&Object.assign(this,t)}OR(){let t=this.Nt;for(let e=0;e<t.length;e++)t.r[e].OM(null);t.clear(),this.ju.length=0}Ro(t){this.a=t}toString(t){t===void 0&&(t=0);let e='Layer "'+this.name+'"';if(t<=0)return e;let i=0,s=0,n=0,o=0,r=0,a=this.Nt.iterator;for(;a.next();){let l=a.value;l instanceof ht?n++:l instanceof $?s++:l instanceof j?o++:l instanceof vt?r++:i++}let h="";if(i>0&&(h+=i+" Parts "),s>0&&(h+=s+" Nodes "),n>0&&(h+=n+" Groups "),o>0&&(h+=o+" Links "),r>0&&(h+=r+" Adornments "),t>1){let l=this.Nt.iterator;for(;l.next();){let u=l.value;h+=`
|