You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

246 lines
412 KiB

import{c as pi}from"./_createCompounder-ed41a610.js";import{aS as bn,fN as lo,gc as Hn,gD as ao,dn as kn,fx as co,dm as ho,bc as ie,gE as uo,fw as fo,gF as go,ab as po,ek as mi,fy as mo,fz as yo,fD as bo,gG as xo,aa as wo,gH as vo,gI as Po,gJ as ge,gK as fs,dC as Gn,gL as Co,dD as Ao,el as yi,dJ as bi,gM as So,dI as Oo,f9 as zt,ah as K,cn as xi,H as It}from"./index-f4658ae7.js";import{b as wi,m as st}from"./merge-15067256.js";import{i as Kn,c as Mo}from"./_createAssigner-77c8874c.js";import{d as Eo}from"./difference-bddb49bc.js";import{c as To}from"./_createAggregator-c692fd07.js";import{b as No}from"./_baseMap-457e4262.js";import{i as Rs}from"./isNumber-0bc0d001.js";import{t as Lo}from"./throttle-35369e52.js";function jo(i){return bn(lo(i).toLowerCase())}var ko=pi(function(i,t,e){return t=t.toLowerCase(),i+(e?jo(t):t)});const Dn=ko;function Do(i,t,e){return i===i&&(e!==void 0&&(i=i<=e?i:e),t!==void 0&&(i=i>=t?i:t)),i}function vt(i,t,e){return e===void 0&&(e=t,t=void 0),e!==void 0&&(e=Hn(e),e=e===e?e:0),t!==void 0&&(t=Hn(t),t=t===t?t:0),Do(Hn(i),t,e)}var Io=4;function Qn(i){return ao(i,Io)}var vi=Object.prototype,Ro=vi.hasOwnProperty,Bo=kn(function(i,t){i=Object(i);var e=-1,n=t.length,s=n>2?t[2]:void 0;for(s&&Kn(t[0],t[1],s)&&(n=1);++e<n;)for(var r=t[e],o=co(r),l=-1,a=o.length;++l<a;){var c=o[l],h=i[c];(h===void 0||ho(h,vi[c])&&!Ro.call(i,c))&&(i[c]=r[c])}return i});const $o=Bo;function Pi(i,t,e,n,s,r){return ie(i)&&ie(t)&&(r.set(t,i),wi(i,t,void 0,Pi,r),r.delete(t)),i}var Vo=Mo(function(i,t,e,n){wi(i,t,e,n)});const zo=Vo;var Fo=kn(function(i){return i.push(void 0,Pi),uo(zo,void 0,i)});const Ci=Fo;var qo=Object.prototype,Ho=qo.hasOwnProperty,Go=To(function(i,t,e){Ho.call(i,e)?i[e].push(t):fo(i,e,[t])});const Bs=Go;function _o(i,t){return i>t}var Uo=Object.prototype,Wo=Uo.hasOwnProperty;function Xo(i,t){return i!=null&&Wo.call(i,t)}function hn(i,t){return i!=null&&go(i,t,Xo)}var Jo="[object Map]",Yo="[object Set]",Zo=Object.prototype,Ko=Zo.hasOwnProperty;function Ai(i){if(i==null)return!0;if(po(i)&&(mi(i)||typeof i=="string"||typeof i.splice=="function"||mo(i)||yo(i)||bo(i)))return!i.length;var t=xo(i);if(t==Jo||t==Yo)return!i.size;if(wo(i))return!vo(i).length;for(var e in i)if(Ko.call(i,e))return!1;return!0}var Qo=Po("toLowerCase");const tl=Qo;function el(i,t,e){for(var n=-1,s=i.length;++n<s;){var r=i[n],o=t(r);if(o!=null&&(l===void 0?o===o&&!ge(o):e(o,l)))var l=o,a=r}return a}function nl(i){return i&&i.length?el(i,fs,_o):void 0}function sl(i,t){var e=i.length;for(i.sort(t);e--;)i[e]=i[e].value;return i}function il(i,t){if(i!==t){var e=i!==void 0,n=i===null,s=i===i,r=ge(i),o=t!==void 0,l=t===null,a=t===t,c=ge(t);if(!l&&!c&&!r&&i>t||r&&o&&a&&!l&&!c||n&&o&&a||!e&&a||!s)return 1;if(!n&&!r&&!c&&i<t||c&&e&&s&&!n&&!r||l&&e&&s||!o&&s||!a)return-1}return 0}function rl(i,t,e){for(var n=-1,s=i.criteria,r=t.criteria,o=s.length,l=e.length;++n<o;){var a=il(s[n],r[n]);if(a){if(n>=l)return a;var c=e[n];return a*(c=="desc"?-1:1)}}return i.index-t.index}function ol(i,t,e){t.length?t=Gn(t,function(r){return mi(r)?function(o){return Co(o,r.length===1?r[0]:r)}:r}):t=[fs];var n=-1;t=Gn(t,Ao(yi));var s=No(i,function(r,o,l){var a=Gn(t,function(c){return c(r)});return{criteria:a,index:++n,value:r}});return sl(s,function(r,o){return rl(r,o,e)})}var ll=kn(function(i,t){if(i==null)return[];var e=t.length;return e>1&&Kn(i,t[0],t[1])?t=[]:e>2&&Kn(t[0],t[1],t[2])&&(t=[t[0]]),ol(i,bi(t,1),[])});const al=ll;var cl=4294967295,hl=cl-1,ul=Math.floor,fl=Math.min;function Si(i,t,e,n){var s=0,r=i==null?0:i.length;if(r===0)return 0;t=e(t);for(var o=t!==t,l=t===null,a=ge(t),c=t===void 0;s<r;){var h=ul((s+r)/2),u=e(i[h]),f=u!==void 0,d=u===null,g=u===u,p=ge(u);if(o)var m=n||g;else c?m=g&&(n||f):l?m=g&&f&&(n||!d):a?m=g&&f&&!d&&(n||!p):d||p?m=!1:m=n?u<=t:u<t;m?s=h+1:r=h}return fl(r,hl)}var dl=4294967295,gl=dl>>>1;function pl(i,t,e){var n=0,s=i==null?n:i.length;if(typeof t=="number"&&t===t&&s<=gl){for(;n<s;){var r=n+s>>>1,o=i[r];o!==null&&!ge(o)&&(e?o<=t:o<t)?n=r+1:s=r}return s}return Si(i,t,fs,e)}function ml(i,t){return pl(i,t)}function yl(i,t,e){return Si(i,t,yi(e))}var bl=pi(function(i,t,e){return i+(e?" ":"")+bn(t)});const xl=bl;var wl=kn(function(i){return So(bi(i,1,Oo,!0))});const $s=wl;typeof window=="object"&&window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);(function(i){i.forEach(t=>{Object.prototype.hasOwnProperty.call(t,"append")||Object.defineProperty(t,"append",{configurable:!0,enumerable:!0,writable:!0,value(...e){const n=document.createDocumentFragment();e.forEach(s=>{const r=s instanceof Node;n.appendChild(r?s:document.createTextNode(String(s)))}),this.appendChild(n)}})})})([Element.prototype,Document.prototype,DocumentFragment.prototype]);class Bt{get disposed(){return this._disposed===!0}dispose(){this._disposed=!0}}(function(i){function t(){return(e,n,s)=>{const r=s.value,o=e.__proto__;s.value=function(...l){this.disposed||(r.call(this,...l),o.dispose.call(this))}}}i.dispose=t})(Bt||(Bt={}));class Vs{constructor(){this.isDisposed=!1,this.items=new Set}get disposed(){return this.isDisposed}dispose(){this.isDisposed||(this.isDisposed=!0,this.items.forEach(t=>{t.dispose()}),this.items.clear())}contains(t){return this.items.has(t)}add(t){this.items.add(t)}remove(t){this.items.delete(t)}clear(){this.items.clear()}}(function(i){function t(e){const n=new i;return e.forEach(s=>{n.add(s)}),n}i.from=t})(Vs||(Vs={}));function Oi(i,t,e){if(e)switch(e.length){case 0:return i.call(t);case 1:return i.call(t,e[0]);case 2:return i.call(t,e[0],e[1]);case 3:return i.call(t,e[0],e[1],e[2]);case 4:return i.call(t,e[0],e[1],e[2],e[3]);case 5:return i.call(t,e[0],e[1],e[2],e[3],e[4]);case 6:return i.call(t,e[0],e[1],e[2],e[3],e[4],e[5]);default:return i.apply(t,e)}return i.call(t)}function R(i,t,...e){return Oi(i,t,e)}function vl(i){return typeof i=="object"&&i.then&&typeof i.then=="function"}function zs(i){return i!=null&&(i instanceof Promise||vl(i))}function ds(...i){const t=[];if(i.forEach(n=>{Array.isArray(n)?t.push(...n):t.push(n)}),t.some(n=>zs(n))){const n=t.map(s=>zs(s)?s:Promise.resolve(s!==!1));return Promise.all(n).then(s=>s.reduce((r,o)=>o!==!1&&r,!0))}return t.every(n=>n!==!1)}function Bf(...i){const t=ds(i);return typeof t=="boolean"?Promise.resolve(t):t}function _n(i,t){const e=[];for(let n=0;n<i.length;n+=2){const s=i[n],r=i[n+1],o=Array.isArray(t)?t:[t],l=Oi(s,r,o);e.push(l)}return ds(e)}class Pl{constructor(){this.listeners={}}on(t,e,n){return e==null?this:(this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e,n),this)}once(t,e,n){const s=(...r)=>(this.off(t,s),_n([e,n],r));return this.on(t,s,this)}off(t,e,n){if(!(t||e||n))return this.listeners={},this;const s=this.listeners;return(t?[t]:Object.keys(s)).forEach(o=>{const l=s[o];if(l){if(!(e||n)){delete s[o];return}for(let a=l.length-2;a>=0;a-=2)e&&l[a]!==e||n&&l[a+1]!==n||l.splice(a,2)}}),this}trigger(t,...e){let n=!0;if(t!=="*"){const r=this.listeners[t];r!=null&&(n=_n([...r],e))}const s=this.listeners["*"];return s!=null?ds([n,_n([...s],[t,...e])]):n}emit(t,...e){return this.trigger(t,...e)}}function Cl(i,...t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(n=>{n!=="constructor"&&Object.defineProperty(i.prototype,n,Object.getOwnPropertyDescriptor(e.prototype,n))})})}const Al=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,t){i.__proto__=t}||function(i,t){for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=t[e])};function Sl(i,t){Al(i,t);function e(){this.constructor=i}i.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}class Ol{}const Ml=/^\s*class\s+/.test(`${Ol}`)||/^\s*class\s*\{/.test(`${class{}}`);function gs(i,t){let e;return Ml?e=class extends t{}:(e=function(){return t.apply(this,arguments)},Sl(e,t)),Object.defineProperty(e,"name",{value:i}),e}function Fs(i){return i==="__proto__"}function ps(i,t,e="/"){let n;const s=Array.isArray(t)?t:t.split(e);if(s.length)for(n=i;s.length;){const r=s.shift();if(Object(n)===n&&r&&r in n)n=n[r];else return}return n}function ke(i,t,e,n="/"){const s=Array.isArray(t)?t:t.split(n),r=s.pop();if(r&&!Fs(r)){let o=i;s.forEach(l=>{Fs(l)||(o[l]==null&&(o[l]={}),o=o[l])}),o[r]=e}return i}function qs(i,t,e="/"){const n=Array.isArray(t)?t.slice():t.split(e),s=n.pop();if(s)if(n.length>0){const r=ps(i,n);r&&delete r[s]}else delete i[s];return i}var El=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class yt extends Pl{dispose(){this.off()}}El([Bt.dispose()],yt.prototype,"dispose",null);(function(i){i.dispose=Bt.dispose})(yt||(yt={}));Cl(yt,Bt);const Mi=i=>{const t=Object.create(null);return e=>t[e]||(t[e]=i(e))},Ei=Mi(i=>i.replace(/\B([A-Z])/g,"-$1").toLowerCase()),ms=Mi(i=>xl(Dn(i)).replace(/ /g,""));function Un(i){let t=2166136261,e=!1,n=i;for(let s=0,r=n.length;s<r;s+=1){let o=n.charCodeAt(s);o>127&&!e&&(n=unescape(encodeURIComponent(n)),o=n.charCodeAt(s),e=!0),t^=o,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24)}return t>>>0}function xn(){let i="";const t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";for(let e=0,n=t.length;e<n;e+=1){const s=t[e],r=Math.random()*16|0,o=s==="x"?r:s==="y"?r&3|8:s;i+=o.toString(16)}return i}function Tl(i,t,e){const n=Math.min(2,Math.floor(i.length*.34));let s=Math.floor(i.length*.4)+1,r,o=!1;const l=i.toLowerCase();for(const a of t){const c=e(a);if(c!==void 0&&Math.abs(c.length-l.length)<=n){const h=c.toLowerCase();if(h===l){if(c===i)continue;return a}if(o||c.length<3)continue;const u=Nl(l,h,s-1);if(u===void 0)continue;u<3?(o=!0,r=a):(s=u,r=a)}}return r}function Nl(i,t,e){let n=new Array(t.length+1),s=new Array(t.length+1);const r=e+1;for(let l=0;l<=t.length;l+=1)n[l]=l;for(let l=1;l<=i.length;l+=1){const a=i.charCodeAt(l-1),c=l>e?l-e:1,h=t.length>e+l?e+l:t.length;s[0]=l;let u=l;for(let d=1;d<c;d+=1)s[d]=r;for(let d=c;d<=h;d+=1){const g=a===t.charCodeAt(d-1)?n[d-1]:Math.min(n[d]+1,s[d-1]+1,n[d-1]+2);s[d]=g,u=Math.min(u,g)}for(let d=h+1;d<=t.length;d+=1)s[d]=r;if(u>e)return;const f=n;n=s,s=f}const o=n[t.length];return o>e?void 0:o}function $t(i){return typeof i=="string"&&i.slice(-1)==="%"}function Ct(i,t){if(i==null)return 0;let e;if(typeof i=="string"){if(e=parseFloat(i),$t(i)&&(e/=100,Number.isFinite(e)))return e*t}else e=i;return Number.isFinite(e)?e>0&&e<1?e*t:e:0}function ce(i){if(typeof i=="object"){let e=0,n=0,s=0,r=0;return i.vertical!=null&&Number.isFinite(i.vertical)&&(n=r=i.vertical),i.horizontal!=null&&Number.isFinite(i.horizontal)&&(s=e=i.horizontal),i.left!=null&&Number.isFinite(i.left)&&(e=i.left),i.top!=null&&Number.isFinite(i.top)&&(n=i.top),i.right!=null&&Number.isFinite(i.right)&&(s=i.right),i.bottom!=null&&Number.isFinite(i.bottom)&&(r=i.bottom),{top:n,right:s,bottom:r,left:e}}let t=0;return i!=null&&Number.isFinite(i)&&(t=i),{top:t,right:t,bottom:t,left:t}}let ys=!1,Ti=!1,Ni=!1,Li=!1,ji=!1,ki=!1,Di=!1,Ii=!1,Ri=!1,Bi=!1,$i=!1,Vi=!1,zi=!1,Fi=!1,qi=!1,Hi=!1;if(typeof navigator=="object"){const i=navigator.userAgent;ys=i.indexOf("Macintosh")>=0,Ti=!!i.match(/(iPad|iPhone|iPod)/g),Ni=i.indexOf("Windows")>=0,Li=i.indexOf("MSIE")>=0,ji=!!i.match(/Trident\/7\./),ki=!!i.match(/Edge\//),Di=i.indexOf("Mozilla/")>=0&&i.indexOf("MSIE")<0&&i.indexOf("Edge/")<0,Ri=i.indexOf("Chrome/")>=0&&i.indexOf("Edge/")<0,Bi=i.indexOf("Opera/")>=0||i.indexOf("OPR/")>=0,$i=i.indexOf("Firefox/")>=0,Vi=i.indexOf("AppleWebKit/")>=0&&i.indexOf("Chrome/")<0&&i.indexOf("Edge/")<0,typeof document=="object"&&(Hi=!document.createElementNS||`${document.createElementNS("http://www.w3.org/2000/svg","foreignObject")}`!="[object SVGForeignObjectElement]"||i.indexOf("Opera/")>=0)}typeof window=="object"&&(Ii=window.chrome!=null&&window.chrome.app!=null&&window.chrome.app.runtime!=null,Fi=window.PointerEvent!=null&&!ys);if(typeof document=="object"){zi="ontouchstart"in document.documentElement;try{const i=Object.defineProperty({},"passive",{get(){qi=!0}}),t=document.createElement("div");t.addEventListener&&t.addEventListener("click",()=>{},i)}catch(i){}}var Xt;(function(i){i.IS_MAC=ys,i.IS_IOS=Ti,i.IS_WINDOWS=Ni,i.IS_IE=Li,i.IS_IE11=ji,i.IS_EDGE=ki,i.IS_NETSCAPE=Di,i.IS_CHROME_APP=Ii,i.IS_CHROME=Ri,i.IS_OPERA=Bi,i.IS_FIREFOX=$i,i.IS_SAFARI=Vi,i.SUPPORT_TOUCH=zi,i.SUPPORT_POINTER=Fi,i.SUPPORT_PASSIVE=qi,i.NO_FOREIGNOBJECT=Hi,i.SUPPORT_FOREIGNOBJECT=!i.NO_FOREIGNOBJECT})(Xt||(Xt={}));(function(i){function t(){const r=window.module;return r!=null&&r.hot!=null&&r.hot.status!=null?r.hot.status():"unkonwn"}i.getHMRStatus=t;function e(){return t()==="apply"}i.isApplyingHMR=e;const n={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};function s(r){const o=document.createElement(n[r]||"div"),l=`on${r}`;let a=l in o;return a||(o.setAttribute(l,"return;"),a=typeof o[l]=="function"),a}i.isEventSupported=s})(Xt||(Xt={}));const bs=/[\t\r\n\f]/g,xs=/\S+/g,pe=i=>` ${i} `;function me(i){return i&&i.getAttribute&&i.getAttribute("class")||""}function De(i,t){if(i==null||t==null)return!1;const e=pe(me(i)),n=pe(t);return i.nodeType===1?e.replace(bs," ").includes(n):!1}function F(i,t){if(!(i==null||t==null)){if(typeof t=="function")return F(i,t(me(i)));if(typeof t=="string"&&i.nodeType===1){const e=t.match(xs)||[],n=pe(me(i)).replace(bs," ");let s=e.reduce((r,o)=>r.indexOf(pe(o))<0?`${r}${o} `:r,n);s=s.trim(),n!==s&&i.setAttribute("class",s)}}}function Pt(i,t){if(i!=null){if(typeof t=="function")return Pt(i,t(me(i)));if((!t||typeof t=="string")&&i.nodeType===1){const e=(t||"").match(xs)||[],n=pe(me(i)).replace(bs," ");let s=e.reduce((r,o)=>{const l=pe(o);return r.indexOf(l)>-1?r.replace(l," "):r},n);s=t?s.trim():"",n!==s&&i.setAttribute("class",s)}}}function Gi(i,t,e){if(!(i==null||t==null)){if(e!=null&&typeof t=="string"){e?F(i,t):Pt(i,t);return}if(typeof t=="function")return Gi(i,t(me(i),e),e);typeof t=="string"&&(t.match(xs)||[]).forEach(s=>{De(i,s)?Pt(i,s):F(i,s)})}}let Hs=0;function Ll(){return Hs+=1,`v${Hs}`}function ws(i){return(i.id==null||i.id==="")&&(i.id=Ll()),i.id}function Jt(i){return i==null?!1:typeof i.getScreenCTM=="function"&&i instanceof SVGElement}const at={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns/",xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml"},Gs="1.1";function _s(i,t=document){return t.createElement(i)}function vs(i,t=at.xhtml,e=document){return e.createElementNS(t,i)}function Ft(i,t=document){return vs(i,at.svg,t)}function wn(i){if(i){const e=`<svg xmlns="${at.svg}" xmlns:xlink="${at.xlink}" version="${Gs}">${i}</svg>`,{documentElement:n}=jl(e,{async:!1});return n}const t=document.createElementNS(at.svg,"svg");return t.setAttributeNS(at.xmlns,"xmlns:xlink",at.xlink),t.setAttribute("version",Gs),t}function jl(i,t={}){let e;try{const n=new DOMParser;if(t.async!=null){const s=n;s.async=t.async}e=n.parseFromString(i,t.mimeType||"text/xml")}catch(n){e=void 0}if(!e||e.getElementsByTagName("parsererror").length)throw new Error(`Invalid XML: ${i}`);return e}function kl(i,t=!0){const e=i.nodeName;return t?e.toLowerCase():e.toUpperCase()}function Ps(i){let t=0,e=i.previousSibling;for(;e;)e.nodeType===1&&(t+=1),e=e.previousSibling;return t}function Dl(i,t){return i.querySelectorAll(t)}function Il(i,t){return i.querySelector(t)}function _i(i,t,e){const n=i.ownerSVGElement;let s=i.parentNode;for(;s&&s!==e&&s!==n;){if(De(s,t))return s;s=s.parentNode}return null}function Ui(i,t){const e=t&&t.parentNode;return i===e||!!(e&&e.nodeType===1&&i.compareDocumentPosition(e)&16)}function ye(i){i&&(Array.isArray(i)?i:[i]).forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)})}function nn(i){for(;i.firstChild;)i.removeChild(i.firstChild)}function sn(i,t){(Array.isArray(t)?t:[t]).forEach(n=>{n!=null&&i.appendChild(n)})}function Rl(i,t){const e=i.firstChild;return e?Cs(e,t):sn(i,t)}function Cs(i,t){const e=i.parentNode;e&&(Array.isArray(t)?t:[t]).forEach(s=>{s!=null&&e.insertBefore(s,i)})}function Bl(i,t){t!=null&&t.appendChild(i)}function $f(i){return!!i&&i.nodeType===1}function Us(i){try{return i instanceof HTMLElement}catch(t){return typeof i=="object"&&i.nodeType===1&&typeof i.style=="object"&&typeof i.ownerDocument=="object"}}function Vf(i,t){const e=[];let n=i.firstChild;for(;n;n=n.nextSibling)n.nodeType===1&&(!t||De(n,t))&&e.push(n);return e}const Wi=["viewBox","attributeName","attributeType","repeatCount","textLength","lengthAdjust","gradientUnits"];function $l(i,t){return i.getAttribute(t)}function Xi(i,t){const e=Yi(t);e.ns?i.hasAttributeNS(e.ns,e.local)&&i.removeAttributeNS(e.ns,e.local):i.hasAttribute(t)&&i.removeAttribute(t)}function As(i,t,e){if(e==null)return Xi(i,t);const n=Yi(t);n.ns&&typeof e=="string"?i.setAttributeNS(n.ns,t,e):t==="id"?i.id=`${e}`:i.setAttribute(t,`${e}`)}function Ji(i,t){Object.keys(t).forEach(e=>{As(i,e,t[e])})}function G(i,t,e){if(t==null){const n=i.attributes,s={};for(let r=0;r<n.length;r+=1)s[n[r].name]=n[r].value;return s}if(typeof t=="string"&&e===void 0)return i.getAttribute(t);typeof t=="object"?Ji(i,t):As(i,t,e)}function Yi(i){if(i.indexOf(":")!==-1){const t=i.split(":");return{ns:at[t[0]],local:t[1]}}return{ns:null,local:i}}function Ue(i){const t={};return Object.keys(i).forEach(e=>{const n=Wi.includes(e)?e:Ei(e);t[n]=i[e]}),t}function un(i){const t={};return i.split(";").forEach(n=>{const s=n.trim();if(s){const r=s.split("=");r.length&&(t[r[0].trim()]=r[1]?r[1].trim():"")}}),t}function ts(i,t){return Object.keys(t).forEach(e=>{if(e==="class")i[e]=i[e]?`${i[e]} ${t[e]}`:t[e];else if(e==="style"){const n=typeof i[e]=="object",s=typeof t[e]=="object";let r,o;n&&s?(r=i[e],o=t[e]):n?(r=i[e],o=un(t[e])):s?(r=un(i[e]),o=t[e]):(r=un(i[e]),o=un(t[e])),i[e]=ts(r,o)}else i[e]=t[e]}),i}function Vl(i,t,e={}){const n=e.offset||0,s=[],r=[];let o,l,a=null;for(let c=0;c<i.length;c+=1){o=r[c]=i[c];for(let h=0,u=t.length;h<u;h+=1){const f=t[h],d=f.start+n,g=f.end+n;c>=d&&c<g&&(typeof o=="string"?o=r[c]={t:i[c],attrs:f.attrs}:o.attrs=ts(ts({},o.attrs),f.attrs),e.includeAnnotationIndices&&(o.annotations==null&&(o.annotations=[]),o.annotations.push(h)))}l=r[c-1],l?ie(o)&&ie(l)?(a=a,JSON.stringify(o.attrs)===JSON.stringify(l.attrs)?a.t+=o.t:(s.push(a),a=o)):ie(o)||ie(l)?(a=a,s.push(a),a=o):a=(a||"")+o:a=o}return a!=null&&s.push(a),s}function zl(i){return i.replace(/ /g,"\xA0")}var Ws;(function(i){function t(c){const h="data:";return c.substr(0,h.length)===h}i.isDataUrl=t;function e(c,h){if(!c||t(c)){setTimeout(()=>h(null,c));return}const u=()=>{h(new Error(`Failed to load image: ${c}`))},f=window.FileReader?g=>{if(g.status===200){const p=new FileReader;p.onload=m=>{const b=m.target.result;h(null,b)},p.onerror=u,p.readAsDataURL(g.response)}else u()}:g=>{const p=m=>{const x=[];for(let y=0;y<m.length;y+=32768)x.push(String.fromCharCode.apply(null,m.subarray(y,y+32768)));return x.join("")};if(g.status===200){let m=c.split(".").pop()||"png";m==="svg"&&(m="svg+xml");const b=`data:image/${m};base64,`,x=new Uint8Array(g.response),y=b+btoa(p(x));h(null,y)}else u()},d=new XMLHttpRequest;d.responseType=window.FileReader?"blob":"arraybuffer",d.open("GET",c,!0),d.addEventListener("error",u),d.addEventListener("load",()=>f(d)),d.send()}i.imageToDataUri=e;function n(c){let h=c.replace(/\s/g,"");h=decodeURIComponent(h);const u=h.indexOf(","),f=h.slice(0,u),d=f.split(":")[1].split(";")[0],g=h.slice(u+1);let p;f.indexOf("base64")>=0?p=atob(g):p=unescape(encodeURIComponent(g));const m=new Uint8Array(p.length);for(let b=0;b<p.length;b+=1)m[b]=p.charCodeAt(b);return new Blob([m],{type:d})}i.dataUriToBlob=n;function s(c,h){const u=window.navigator.msSaveBlob;if(u)u(c,h);else{const f=window.URL.createObjectURL(c),d=document.createElement("a");d.href=f,d.download=h,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(f)}}i.downloadBlob=s;function r(c,h){const u=n(c);s(u,h)}i.downloadDataUri=r;function o(c){const h=c.match(/<svg[^>]*viewBox\s*=\s*(["']?)(.+?)\1[^>]*>/i);return h&&h[2]?h[2].replace(/\s+/," ").split(" "):null}function l(c){const h=parseFloat(c);return Number.isNaN(h)?null:h}function a(c,h={}){let u=null;const f=y=>(u==null&&(u=o(c)),u!=null?l(u[y]):null),d=y=>{const v=c.match(y);return v&&v[2]?l(v[2]):null};let g=h.width;if(g==null&&(g=d(/<svg[^>]*width\s*=\s*(["']?)(.+?)\1[^>]*>/i)),g==null&&(g=f(2)),g==null)throw new Error("Can not parse width from svg string");let p=h.height;if(p==null&&(p=d(/<svg[^>]*height\s*=\s*(["']?)(.+?)\1[^>]*>/i)),p==null&&(p=f(3)),p==null)throw new Error("Can not parse height from svg string");return`data:image/svg+xml,${encodeURIComponent(c).replace(/'/g,"%27").replace(/"/g,"%22")}`}i.svgToDataUrl=a})(Ws||(Ws={}));let se;const Fl={px(i){return i},mm(i){return se*i},cm(i){return se*i*10},in(i){return se*i*25.4},pt(i){return se*(25.4*i/72)},pc(i){return se*(25.4*i/6)}};var Xs;(function(i){function t(n,s,r){const o=document.createElement("div"),l=o.style;l.display="inline-block",l.position="absolute",l.left="-15000px",l.top="-15000px",l.width=n+(r||"px"),l.height=s+(r||"px"),document.body.appendChild(o);const a=o.getBoundingClientRect(),c={width:a.width||0,height:a.height||0};return document.body.removeChild(o),c}i.measure=t;function e(n,s){se==null&&(se=t("1","1","mm").width);const r=s?Fl[s]:null;return r?r(n):n}i.toPx=e})(Xs||(Xs={}));const ql=/-(.)/g;function Hl(i){return i.replace(ql,(t,e)=>e.toUpperCase())}const Wn={},Js=["webkit","ms","moz","o"],Zi=document?document.createElement("div").style:{};function Gl(i){for(let t=0;t<Js.length;t+=1){const e=Js[t]+i;if(e in Zi)return e}return null}function _l(i){const t=Hl(i);if(Wn[t]==null){const e=t.charAt(0).toUpperCase()+t.slice(1);Wn[t]=t in Zi?t:Gl(e)}return Wn[t]}function Ys(i,t){const e=i.ownerDocument&&i.ownerDocument.defaultView&&i.ownerDocument.defaultView.opener?i.ownerDocument.defaultView.getComputedStyle(i,null):window.getComputedStyle(i,null);return e&&t?e.getPropertyValue(t)||e[t]:e}const Ul={animationIterationCount:!0,columnCount:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0};function Wl(i){return/^--/.test(i)}function Ki(i,t,e){const n=window.getComputedStyle(i,null);return e?n.getPropertyValue(t)||void 0:n[t]||i.style[t]}function zf(i,t){return parseInt(Ki(i,t),10)||0}function Xl(i,t){return!Ul[i]&&typeof t=="number"?`${t}px`:t}function rn(i,t,e){if(typeof t=="string"){const n=Wl(t);if(n||(t=_l(t)),e===void 0)return Ki(i,t,n);n||(e=Xl(t,e));const s=i.style;n?s.setProperty(t,e):s[t]=e;return}for(const n in t)rn(i,n,t[n])}const vn=new WeakMap;function Zs(i,t){const e=Dn(t),n=vn.get(i);if(n)return n[e]}function Jl(i,t,e){const n=Dn(t),s=vn.get(i);s?s[n]=e:vn.set(i,{[n]:e})}function he(i,t,e){if(!t){const n={};return Object.keys(vn).forEach(s=>{n[s]=Zs(i,s)}),n}if(typeof t=="string"){if(e===void 0)return Zs(i,t);Jl(i,t,e);return}for(const n in t)he(i,n,t[n])}class I{get[Symbol.toStringTag](){return I.toStringTag}get type(){return this.node.nodeName}get id(){return this.node.id}set id(t){this.node.id=t}constructor(t,e,n){if(!t)throw new TypeError("Invalid element to create vector");let s;if(I.isVector(t))s=t.node;else if(typeof t=="string")if(t.toLowerCase()==="svg")s=wn();else if(t[0]==="<"){const r=wn(t);s=document.importNode(r.firstChild,!0)}else s=document.createElementNS(at.svg,t);else s=t;this.node=s,e&&this.setAttributes(e),n&&this.append(n)}transform(t,e){return t==null?be(this.node):(be(this.node,t,e),this)}translate(t,e=0,n={}){return t==null?ti(this.node):(ti(this.node,t,e,n),this)}rotate(t,e,n,s={}){return t==null?ss(this.node):(ss(this.node,t,e,n,s),this)}scale(t,e){return t==null?is(this.node):(is(this.node,t,e),this)}getTransformToElement(t){const e=I.toNode(t);return qe(this.node,e)}removeAttribute(t){return Xi(this.node,t),this}getAttribute(t){return $l(this.node,t)}setAttribute(t,e){return As(this.node,t,e),this}setAttributes(t){return Ji(this.node,t),this}attr(t,e){return t==null?G(this.node):typeof t=="string"&&e===void 0?G(this.node,t):(typeof t=="object"?G(this.node,t):G(this.node,t,e),this)}svg(){return this.node instanceof SVGSVGElement?this:I.create(this.node.ownerSVGElement)}defs(){const t=this.svg()||this,e=t.node.getElementsByTagName("defs")[0];return e?I.create(e):I.create("defs").appendTo(t)}text(t,e={}){return tr(this.node,t,e),this}tagName(){return kl(this.node)}clone(){return I.create(this.node.cloneNode(!0))}remove(){return ye(this.node),this}empty(){return nn(this.node),this}append(t){return sn(this.node,I.toNodes(t)),this}appendTo(t){return Bl(this.node,I.isVector(t)?t.node:t),this}prepend(t){return Rl(this.node,I.toNodes(t)),this}before(t){return Cs(this.node,I.toNodes(t)),this}replace(t){return this.node.parentNode&&this.node.parentNode.replaceChild(I.toNode(t),this.node),I.create(t)}first(){return this.node.firstChild?I.create(this.node.firstChild):null}last(){return this.node.lastChild?I.create(this.node.lastChild):null}get(t){const e=this.node.childNodes[t];return e?I.create(e):null}indexOf(t){return Array.prototype.slice.call(this.node.childNodes).indexOf(I.toNode(t))}find(t){const e=[],n=Dl(this.node,t);if(n)for(let s=0,r=n.length;s<r;s+=1)e.push(I.create(n[s]));return e}findOne(t){const e=Il(this.node,t);return e?I.create(e):null}findParentByClass(t,e){const n=_i(this.node,t,e);return n?I.create(n):null}matches(t){const e=this.node;this.node.matches;const n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector||null;return n&&n.call(e,t)}contains(t){return Ui(this.node,I.isVector(t)?t.node:t)}wrap(t){const e=I.create(t),n=this.node.parentNode;return n!=null&&n.insertBefore(e.node,this.node),e.append(this)}parent(t){let e=this;if(e.node.parentNode==null)return null;if(e=I.create(e.node.parentNode),t==null)return e;do if(typeof t=="string"?e.matches(t):e instanceof t)return e;while(e=I.create(e.node.parentNode));return e}children(){const t=this.node.childNodes,e=[];for(let n=0;n<t.length;n+=1)t[n].nodeType===1&&e.push(I.create(t[n]));return e}eachChild(t,e){const n=this.children();for(let s=0,r=n.length;s<r;s+=1)t.call(n[s],n[s],s,n),e&&n[s].eachChild(t,e);return this}index(){return Ps(this.node)}hasClass(t){return De(this.node,t)}addClass(t){return F(this.node,t),this}removeClass(t){return Pt(this.node,t),this}toggleClass(t,e){return Gi(this.node,t,e),this}toLocalPoint(t,e){return pa(this.node,t,e)}sample(t=1){return this.node instanceof SVGPathElement?Ql(this.node,t):[]}toPath(){return I.create(oa(this.node))}toPathData(){return ir(this.node)}}(function(i){i.toStringTag=`X6.${i.name}`;function t(o){if(o==null)return!1;if(o instanceof i)return!0;const l=o[Symbol.toStringTag],a=o;return(l==null||l===i.toStringTag)&&a.node instanceof SVGElement&&typeof a.sample=="function"&&typeof a.toPath=="function"}i.isVector=t;function e(o,l,a){return new i(o,l,a)}i.create=e;function n(o){if(o[0]==="<"){const l=wn(o),a=[];for(let c=0,h=l.childNodes.length;c<h;c+=1){const u=l.childNodes[c];a.push(e(document.importNode(u,!0)))}return a}return[e(o)]}i.createVectors=n;function s(o){return t(o)?o.node:o}i.toNode=s;function r(o){return Array.isArray(o)?o.map(l=>s(l)):[s(o)]}i.toNodes=r})(I||(I={}));const Ks=document.createElement("canvas").getContext("2d");function Yl(i,t){const e=I.create(t),n=I.create("textPath"),s=i.d;if(s&&i["xlink:href"]===void 0){const r=I.create("path").attr("d",s).appendTo(e.defs());n.attr("xlink:href",`#${r.id}`)}return typeof i=="object"&&n.attr(i),n.node}function Zl(i,t,e){const n=e.eol,s=e.baseSize,r=e.lineHeight;let o=0,l;const a={},c=t.length-1;for(let h=0;h<=c;h+=1){let u=t[h],f=null;if(typeof u=="object"){const d=u.attrs,g=I.create("tspan",d);l=g.node;let p=u.t;n&&h===c&&(p+=n),l.textContent=p;const m=d.class;m&&g.addClass(m),e.includeAnnotationIndices&&g.attr("annotations",u.annotations.join(",")),f=parseFloat(d["font-size"]),f===void 0&&(f=s),f&&f>o&&(o=f)}else n&&h===c&&(u+=n),l=document.createTextNode(u||" "),s&&s>o&&(o=s);i.appendChild(l)}return o&&(a.maxFontSize=o),r?a.lineHeight=r:o&&(a.lineHeight=o*1.2),a}const Qi=/em$/;function fn(i,t){const e=parseFloat(i);return Qi.test(i)?e*t:e}function Kl(i,t,e,n){if(!Array.isArray(t))return 0;const s=t.length;if(!s)return 0;let r=t[0];const o=fn(r.maxFontSize,e)||e;let l=0;const a=fn(n,e);for(let u=1;u<s;u+=1){r=t[u];const f=fn(r.lineHeight,e)||a;l+=f}const c=fn(r.maxFontSize,e)||e;let h;switch(i){case"middle":h=o/2-.15*c-l/2;break;case"bottom":h=-(.25*c)-l;break;case"top":default:h=.8*o;break}return h}function tr(i,t,e={}){t=zl(t);const n=e.eol;let s=e.textPath;const r=e.textVerticalAnchor,o=r==="middle"||r==="bottom"||r==="top";let l=e.x;l===void 0&&(l=i.getAttribute("x")||0);const a=e.includeAnnotationIndices;let c=e.annotations;c&&!Array.isArray(c)&&(c=[c]);const h=e.lineHeight,u=h==="auto",f=u?"1.5em":h||"1em";let d=!0;const g=i.childNodes;if(g.length===1){const M=g[0];M&&M.tagName.toUpperCase()==="TITLE"&&(d=!1)}d&&nn(i),G(i,{"xml:space":"preserve",display:t||e.displayEmpty?null:"none"});const p=G(i,"font-size");let m=parseFloat(p);m||(m=16,(o||c)&&!p&&G(i,"font-size",`${m}`));let b;s?(typeof s=="string"&&(s={d:s}),b=Yl(s,i)):b=document.createDocumentFragment();let x,y=0,v;const P=t.split(`
`),C=[],O=P.length-1;for(let M=0;M<=O;M+=1){x=f;let j="v-line";const E=Ft("tspan");let D,_=P[M];if(_)if(c){const z=Vl(_,c,{offset:-y,includeAnnotationIndices:a});D=Zl(E,z,{eol:M!==O&&n,baseSize:m,lineHeight:u?null:f,includeAnnotationIndices:a});const A=D.lineHeight;A&&u&&M!==0&&(x=A),M===0&&(v=D.maxFontSize*.8)}else n&&M!==O&&(_+=n),E.textContent=_;else{E.textContent="-",j+=" v-empty-line";const z=E.style;z.fillOpacity=0,z.strokeOpacity=0,c&&(D={})}D&&C.push(D),M>0&&E.setAttribute("dy",x),(M>0||s)&&E.setAttribute("x",l),E.className.baseVal=j,b.appendChild(E),y+=_.length+1}if(o)if(c)x=Kl(r,C,m,f);else if(r==="top")x="0.8em";else{let M;switch(O>0?(M=parseFloat(f)||1,M*=O,Qi.test(f)||(M/=m)):M=0,r){case"middle":x=`${.3-M/2}em`;break;case"bottom":x=`${-M-.3}em`;break}}else r===0?x="0em":r?x=r:(x=0,i.getAttribute("y")==null&&i.setAttribute("y",`${v||"0.8em"}`));b.firstChild.setAttribute("dy",x),i.appendChild(b)}function Fe(i,t={}){if(!i)return{width:0};const e=[],n=t["font-size"]?`${parseFloat(t["font-size"])}px`:"14px";return e.push(t["font-style"]||"normal"),e.push(t["font-variant"]||"normal"),e.push(t["font-weight"]||400),e.push(n),e.push(t["font-family"]||"sans-serif"),Ks.font=e.join(" "),Ks.measureText(i)}function Qs(i,t,e,n={}){if(t>=e)return[i,""];const s=i.length,r={};let o=Math.round(t/e*s-1);for(o<0&&(o=0);o>=0&&o<s;){const l=i.slice(0,o),a=r[l]||Fe(l,n).width,c=i.slice(0,o+1),h=r[c]||Fe(c,n).width;if(r[l]=a,r[c]=h,a>t)o-=1;else if(h<=t)o+=1;else break}return[i.slice(0,o),i.slice(o)]}function er(i,t,e={},n={}){const s=t.width,r=t.height,o=n.eol||`
`,l=e.fontSize||14,a=e.lineHeight?parseFloat(e.lineHeight):Math.ceil(l*1.4),c=Math.floor(r/a);if(i.indexOf(o)>-1){const m=xn(),b=[];return i.split(o).map(x=>{const y=er(x,Object.assign(Object.assign({},t),{height:Number.MAX_SAFE_INTEGER}),e,Object.assign(Object.assign({},n),{eol:m}));y&&b.push(...y.split(m))}),b.slice(0,c).join(o)}const{width:h}=Fe(i,e);if(h<s)return i;const u=[];let f=i,d=h,g=n.ellipsis,p=0;g&&(typeof g!="string"&&(g="\u2026"),p=Fe(g,e).width);for(let m=0;m<c;m+=1)if(d>s)if(m===c-1){const[x]=Qs(f,s-p,d,e);u.push(g?`${x}${g}`:x)}else{const[x,y]=Qs(f,s,d,e);u.push(x),f=y,d=Fe(f,e).width}else{u.push(f);break}return u.join(o)}const es=.551784;function ft(i,t,e=NaN){const n=i.getAttribute(t);if(n==null)return e;const s=parseFloat(n);return Number.isNaN(s)?e:s}function Ql(i,t=1){const e=i.getTotalLength(),n=[];let s=0,r;for(;s<e;)r=i.getPointAtLength(s),n.push({distance:s,x:r.x,y:r.y}),s+=t;return n}function ta(i){return["M",ft(i,"x1"),ft(i,"y1"),"L",ft(i,"x2"),ft(i,"y2")].join(" ")}function ea(i){const t=Pn(i);return t.length===0?null:`${nr(t)} Z`}function na(i){const t=Pn(i);return t.length===0?null:nr(t)}function nr(i){return`M ${i.map(e=>`${e.x} ${e.y}`).join(" L")}`}function Pn(i){const t=[],e=i.points;if(e)for(let n=0,s=e.numberOfItems;n<s;n+=1)t.push(e.getItem(n));return t}function sa(i){const t=ft(i,"cx",0),e=ft(i,"cy",0),n=ft(i,"r"),s=n*es;return["M",t,e-n,"C",t+s,e-n,t+n,e-s,t+n,e,"C",t+n,e+s,t+s,e+n,t,e+n,"C",t-s,e+n,t-n,e+s,t-n,e,"C",t-n,e-s,t-s,e-n,t,e-n,"Z"].join(" ")}function ia(i){const t=ft(i,"cx",0),e=ft(i,"cy",0),n=ft(i,"rx"),s=ft(i,"ry")||n,r=n*es,o=s*es;return["M",t,e-s,"C",t+r,e-s,t+n,e-o,t+n,e,"C",t+n,e+o,t+r,e+s,t,e+s,"C",t-r,e+s,t-n,e+o,t-n,e,"C",t-n,e-o,t-r,e-s,t,e-s,"Z"].join(" ")}function ra(i){return sr({x:ft(i,"x",0),y:ft(i,"y",0),width:ft(i,"width",0),height:ft(i,"height",0),rx:ft(i,"rx",0),ry:ft(i,"ry",0)})}function sr(i){let t;const e=i.x,n=i.y,s=i.width,r=i.height,o=Math.min(i.rx||i["top-rx"]||0,s/2),l=Math.min(i.rx||i["bottom-rx"]||0,s/2),a=Math.min(i.ry||i["top-ry"]||0,r/2),c=Math.min(i.ry||i["bottom-ry"]||0,r/2);return o||l||a||c?t=["M",e,n+a,"v",r-a-c,"a",l,c,0,0,0,l,c,"h",s-2*l,"a",l,c,0,0,0,l,-c,"v",-(r-c-a),"a",o,a,0,0,0,-o,-a,"h",-(s-2*o),"a",o,a,0,0,0,-o,a,"Z"]:t=["M",e,n,"H",e+s,"V",n+r,"H",e,"V",n,"Z"],t.join(" ")}function oa(i){const t=Ft("path");G(t,G(i));const e=ir(i);return e&&t.setAttribute("d",e),t}function ir(i){const t=i.tagName.toLowerCase();switch(t){case"path":return i.getAttribute("d");case"line":return ta(i);case"polygon":return ea(i);case"polyline":return na(i);case"ellipse":return ia(i);case"circle":return sa(i);case"rect":return ra(i)}throw new Error(`"${t}" cannot be converted to svg path element.`)}const Cn=Ft("svg"),la=/(\w+)\(([^,)]+),?([^)]+)?\)/gi,rr=/[ ,]+/,aa=/^(\w+)\((.*)\)/;function ca(i,t){const e=Cn.createSVGPoint();return e.x=i,e.y=t,e}function ht(i){const t=Cn.createSVGMatrix();if(i!=null){const e=i,n=t;for(const s in e)n[s]=e[s]}return t}function Ve(i){return i!=null?(i instanceof DOMMatrix||(i=ht(i)),Cn.createSVGTransformFromMatrix(i)):Cn.createSVGTransform()}function We(i){let t=ht();const e=i!=null&&i.match(la);if(!e)return t;for(let n=0,s=e.length;n<s;n+=1){const o=e[n].match(aa);if(o){let l,a,c,h,u,f=ht();const d=o[2].split(rr);switch(o[1].toLowerCase()){case"scale":l=parseFloat(d[0]),a=d[1]===void 0?l:parseFloat(d[1]),f=f.scaleNonUniform(l,a);break;case"translate":c=parseFloat(d[0]),h=parseFloat(d[1]),f=f.translate(c,h);break;case"rotate":u=parseFloat(d[0]),c=parseFloat(d[1])||0,h=parseFloat(d[2])||0,c!==0||h!==0?f=f.translate(c,h).rotate(u).translate(-c,-h):f=f.rotate(u);break;case"skewx":u=parseFloat(d[0]),f=f.skewX(u);break;case"skewy":u=parseFloat(d[0]),f=f.skewY(u);break;case"matrix":f.a=parseFloat(d[0]),f.b=parseFloat(d[1]),f.c=parseFloat(d[2]),f.d=parseFloat(d[3]),f.e=parseFloat(d[4]),f.f=parseFloat(d[5]);break;default:continue}t=t.multiply(f)}}return t}function Ie(i){const t=i||{},e=t.a!=null?t.a:1,n=t.b!=null?t.b:0,s=t.c!=null?t.c:0,r=t.d!=null?t.d:1,o=t.e!=null?t.e:0,l=t.f!=null?t.f:0;return`matrix(${e},${n},${s},${r},${o},${l})`}function In(i){let t,e,n;if(i){const r=rr;if(i.trim().indexOf("matrix")>=0){const o=We(i),l=ha(o);t=[l.translateX,l.translateY],e=[l.rotation],n=[l.scaleX,l.scaleY];const a=[];(t[0]!==0||t[1]!==0)&&a.push(`translate(${t.join(",")})`),(n[0]!==1||n[1]!==1)&&a.push(`scale(${n.join(",")})`),e[0]!==0&&a.push(`rotate(${e[0]})`),i=a.join(" ")}else{const o=i.match(/translate\((.*?)\)/);o&&(t=o[1].split(r));const l=i.match(/rotate\((.*?)\)/);l&&(e=l[1].split(r));const a=i.match(/scale\((.*?)\)/);a&&(n=a[1].split(r))}}const s=n&&n[0]?parseFloat(n[0]):1;return{raw:i||"",translation:{tx:t&&t[0]?parseInt(t[0],10):0,ty:t&&t[1]?parseInt(t[1],10):0},rotation:{angle:e&&e[0]?parseInt(e[0],10):0,cx:e&&e[1]?parseInt(e[1],10):void 0,cy:e&&e[2]?parseInt(e[2],10):void 0},scale:{sx:s,sy:n&&n[1]?parseFloat(n[1]):s}}}function ns(i,t){const e=t.x*i.a+t.y*i.c+0,n=t.x*i.b+t.y*i.d+0;return{x:e,y:n}}function ha(i){const t=ns(i,{x:0,y:1}),e=ns(i,{x:1,y:0}),n=180/Math.PI*Math.atan2(t.y,t.x)-90,s=180/Math.PI*Math.atan2(e.y,e.x);return{skewX:n,skewY:s,translateX:i.e,translateY:i.f,scaleX:Math.sqrt(i.a*i.a+i.b*i.b),scaleY:Math.sqrt(i.c*i.c+i.d*i.d),rotation:n}}function ua(i){let t,e,n,s;return i?(t=i.a==null?1:i.a,s=i.d==null?1:i.d,e=i.b,n=i.c):t=s=1,{sx:e?Math.sqrt(t*t+e*e):t,sy:n?Math.sqrt(n*n+s*s):s}}function fa(i){let t={x:0,y:1};i&&(t=ns(i,t));const e=180*Math.atan2(t.y,t.x)/Math.PI%360-90;return{angle:e%360+(e<0?360:0)}}function da(i){return{tx:i&&i.e||0,ty:i&&i.f||0}}function be(i,t,e={}){if(t==null)return We(G(i,"transform"));if(e.absolute){i.setAttribute("transform",Ie(t));return}const n=i.transform,s=Ve(t);n.baseVal.appendItem(s)}function ti(i,t,e=0,n={}){let s=G(i,"transform");const r=In(s);if(t==null)return r.translation;s=r.raw,s=s.replace(/translate\([^)]*\)/g,"").trim();const o=n.absolute?t:r.translation.tx+t,l=n.absolute?e:r.translation.ty+e,a=`translate(${o},${l})`;i.setAttribute("transform",`${a} ${s}`.trim())}function ss(i,t,e,n,s={}){let r=G(i,"transform");const o=In(r);if(t==null)return o.rotation;r=o.raw,r=r.replace(/rotate\([^)]*\)/g,"").trim(),t%=360;const l=s.absolute?t:o.rotation.angle+t,a=e!=null&&n!=null?`,${e},${n}`:"",c=`rotate(${l}${a})`;i.setAttribute("transform",`${r} ${c}`.trim())}function is(i,t,e){let n=G(i,"transform");const s=In(n);if(t==null)return s.scale;e=e==null?t:e,n=s.raw,n=n.replace(/scale\([^)]*\)/g,"").trim();const r=`scale(${t},${e})`;i.setAttribute("transform",`${n} ${r}`.trim())}function qe(i,t){if(Jt(t)&&Jt(i)){const e=t.getScreenCTM(),n=i.getScreenCTM();if(e&&n)return e.inverse().multiply(n)}return ht()}function ga(i,t){let e=ht();if(Jt(t)&&Jt(i)){let n=i;const s=[];for(;n&&n!==t;){const r=n.getAttribute("transform")||null,o=We(r);s.push(o),n=n.parentNode}s.reverse().forEach(r=>{e=e.multiply(r)})}return e}function pa(i,t,e){const n=i instanceof SVGSVGElement?i:i.ownerSVGElement,s=n.createSVGPoint();s.x=t,s.y=e;try{const r=n.getScreenCTM(),o=s.matrixTransform(r.inverse()),l=qe(i,n).inverse();return o.matrixTransform(l)}catch(r){return s}}var wt;(function(i){const t={};function e(r){return t[r]||{}}i.get=e;function n(r,o){t[r]=o}i.register=n;function s(r){delete t[r]}i.unregister=s})(wt||(wt={}));var re;(function(i){const t=new WeakMap;function e(r){return t.has(r)||t.set(r,{events:Object.create(null)}),t.get(r)}i.ensure=e;function n(r){return t.get(r)}i.get=n;function s(r){return t.delete(r)}i.remove=s})(re||(re={}));var B;(function(i){i.returnTrue=()=>!0,i.returnFalse=()=>!1;function t(s){s.stopPropagation()}i.stopPropagationCallback=t;function e(s,r,o){s.addEventListener!=null&&s.addEventListener(r,o)}i.addEventListener=e;function n(s,r,o){s.removeEventListener!=null&&s.removeEventListener(r,o)}i.removeEventListener=n})(B||(B={}));(function(i){const t=/[^\x20\t\r\n\f]+/g,e=/^([^.]*)(?:\.(.+)|)/;function n(l){return(l||"").match(t)||[""]}i.splitType=n;function s(l){const a=e.exec(l)||[];return{originType:a[1]?a[1].trim():a[1],namespaces:a[2]?a[2].split(".").map(c=>c.trim()).sort():[]}}i.normalizeType=s;function r(l){return l.nodeType===1||l.nodeType===9||!+l.nodeType}i.isValidTarget=r;function o(l,a){if(a){const c=l;return c.querySelector!=null&&c.querySelector(a)!=null}return!0}i.isValidSelector=o})(B||(B={}));(function(i){let t=0;const e=new WeakMap;function n(l){return e.has(l)||(e.set(l,t),t+=1),e.get(l)}i.ensureHandlerId=n;function s(l){return e.get(l)}i.getHandlerId=s;function r(l){return e.delete(l)}i.removeHandlerId=r;function o(l,a){return e.set(l,a)}i.setHandlerId=o})(B||(B={}));(function(i){function t(e,n){const s=[],r=re.get(e),o=r&&r.events&&r.events[n.type],l=o&&o.handlers||[],a=o?o.delegateCount:0;if(a>0&&!(n.type==="click"&&typeof n.button=="number"&&n.button>=1)){for(let c=n.target;c!==e;c=c.parentNode||e)if(c.nodeType===1&&!(n.type==="click"&&c.disabled===!0)){const h=[],u={};for(let f=0;f<a;f+=1){const d=l[f],g=d.selector;if(g!=null&&u[g]==null){const p=e,m=[];p.querySelectorAll(g).forEach(b=>{m.push(b)}),u[g]=m.includes(c)}u[g]&&h.push(d)}h.length&&s.push({elem:c,handlers:h})}}return a<l.length&&s.push({elem:e,handlers:l.slice(a)}),s}i.getHandlerQueue=t})(B||(B={}));(function(i){function t(e){return e!=null&&e===e.window}i.isWindow=t})(B||(B={}));(function(i){function t(e,n){const s=e.nodeType===9?e.documentElement:e,r=n&&n.parentNode;return e===r||!!(r&&r.nodeType===1&&(s.contains?s.contains(r):e.compareDocumentPosition&&e.compareDocumentPosition(r)&16))}i.contains=t})(B||(B={}));class Et{constructor(t,e){this.isDefaultPrevented=B.returnFalse,this.isPropagationStopped=B.returnFalse,this.isImmediatePropagationStopped=B.returnFalse,this.isSimulated=!1,this.preventDefault=()=>{const n=this.originalEvent;this.isDefaultPrevented=B.returnTrue,n&&!this.isSimulated&&n.preventDefault()},this.stopPropagation=()=>{const n=this.originalEvent;this.isPropagationStopped=B.returnTrue,n&&!this.isSimulated&&n.stopPropagation()},this.stopImmediatePropagation=()=>{const n=this.originalEvent;this.isImmediatePropagationStopped=B.returnTrue,n&&!this.isSimulated&&n.stopImmediatePropagation(),this.stopPropagation()},typeof t=="string"?this.type=t:t.type&&(this.originalEvent=t,this.type=t.type,this.isDefaultPrevented=t.defaultPrevented?B.returnTrue:B.returnFalse,this.target=t.target,this.currentTarget=t.currentTarget,this.relatedTarget=t.relatedTarget,this.timeStamp=t.timeStamp),e&&Object.assign(this,e),this.timeStamp||(this.timeStamp=Date.now())}}(function(i){function t(e){return e instanceof i?e:new i(e)}i.create=t})(Et||(Et={}));(function(i){function t(e,n){Object.defineProperty(i.prototype,e,{enumerable:!0,configurable:!0,get:typeof n=="function"?function(){if(this.originalEvent)return n(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set(s){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:s})}})}i.addProperty=t})(Et||(Et={}));(function(i){const t={bubbles:!0,cancelable:!0,eventPhase:!0,detail:!0,view:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pageX:!0,pageY:!0,screenX:!0,screenY:!0,toElement:!0,pointerId:!0,pointerType:!0,char:!0,code:!0,charCode:!0,key:!0,keyCode:!0,touches:!0,changedTouches:!0,targetTouches:!0,which:!0,altKey:!0,ctrlKey:!0,metaKey:!0,shiftKey:!0};Object.keys(t).forEach(e=>i.addProperty(e,t[e]))})(Et||(Et={}));(function(i){wt.register("load",{noBubble:!0})})();(function(i){wt.register("beforeunload",{postDispatch(t,e){e.result!==void 0&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}})})();(function(i){wt.register("mouseenter",{delegateType:"mouseover",bindType:"mouseover",handle(t,e){let n;const s=e.relatedTarget,r=e.handleObj;return(!s||s!==t&&!B.contains(t,s))&&(e.type=r.originType,n=r.handler.call(t,e),e.type="mouseover"),n}}),wt.register("mouseleave",{delegateType:"mouseout",bindType:"mouseout",handle(t,e){let n;const s=e.relatedTarget,r=e.handleObj;return(!s||s!==t&&!B.contains(t,s))&&(e.type=r.originType,n=r.handler.call(t,e),e.type="mouseout"),n}})})();var ma=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e},Xe;(function(i){let t;function e(o,l,a,c,h){if(!B.isValidTarget(o))return;let u;if(typeof a!="function"){const{handler:p,selector:m}=a,b=ma(a,["handler","selector"]);a=p,h=m,u=b}const f=re.ensure(o);let d=f.handler;d==null&&(d=f.handler=function(p,...m){return t!==p.type?s(o,p,...m):void 0});const g=B.ensureHandlerId(a);B.splitType(l).forEach(p=>{const{originType:m,namespaces:b}=B.normalizeType(p);if(!m)return;let x=m,y=wt.get(x);x=(h?y.delegateType:y.bindType)||x,y=wt.get(x);const v=Object.assign({type:x,originType:m,data:c,selector:h,guid:g,handler:a,namespace:b.join(".")},u),P=f.events;let C=P[x];C||(C=P[x]={handlers:[],delegateCount:0},(!y.setup||y.setup(o,c,b,d)===!1)&&B.addEventListener(o,x,d)),y.add&&(B.removeHandlerId(v.handler),y.add(o,v),B.setHandlerId(v.handler,g)),h?(C.handlers.splice(C.delegateCount,0,v),C.delegateCount+=1):C.handlers.push(v)})}i.on=e;function n(o,l,a,c,h){const u=re.get(o);if(!u)return;const f=u.events;f&&(B.splitType(l).forEach(d=>{const{originType:g,namespaces:p}=B.normalizeType(d);if(!g){Object.keys(f).forEach(P=>{n(o,P+d,a,c,!0)});return}let m=g;const b=wt.get(m);m=(c?b.delegateType:b.bindType)||m;const x=f[m];if(!x)return;const y=p.length>0?new RegExp(`(^|\\.)${p.join("\\.(?:.*\\.|)")}(\\.|$)`):null,v=x.handlers.length;for(let P=x.handlers.length-1;P>=0;P-=1){const C=x.handlers[P];(h||g===C.originType)&&(!a||B.getHandlerId(a)===C.guid)&&(y==null||C.namespace&&y.test(C.namespace))&&(c==null||c===C.selector||c==="**"&&C.selector)&&(x.handlers.splice(P,1),C.selector&&(x.delegateCount-=1),b.remove&&b.remove(o,C))}v&&x.handlers.length===0&&((!b.teardown||b.teardown(o,p,u.handler)===!1)&&B.removeEventListener(o,m,u.handler),delete f[m])}),Object.keys(f).length===0&&re.remove(o))}i.off=n;function s(o,l,...a){const c=Et.create(l);c.delegateTarget=o;const h=wt.get(c.type);if(h.preDispatch&&h.preDispatch(o,c)===!1)return;const u=B.getHandlerQueue(o,c);for(let f=0,d=u.length;f<d&&!c.isPropagationStopped();f+=1){const g=u[f];c.currentTarget=g.elem;for(let p=0,m=g.handlers.length;p<m&&!c.isImmediatePropagationStopped();p+=1){const b=g.handlers[p];if(c.rnamespace==null||b.namespace&&c.rnamespace.test(b.namespace)){c.handleObj=b,c.data=b.data;const x=wt.get(b.originType).handle,y=x?x(g.elem,c,...a):b.handler.call(g.elem,c,...a);y!==void 0&&(c.result=y,y===!1&&(c.preventDefault(),c.stopPropagation()))}}}return h.postDispatch&&h.postDispatch(o,c),c.result}i.dispatch=s;function r(o,l,a,c){let h=o,u=typeof o=="string"?o:o.type,f=typeof o=="string"||h.namespace==null?[]:h.namespace.split(".");const d=a;if(d.nodeType===3||d.nodeType===8)return;u.indexOf(".")>-1&&(f=u.split("."),u=f.shift(),f.sort());const g=u.indexOf(":")<0&&`on${u}`;h=o instanceof Et?o:new Et(u,typeof o=="object"?o:null),h.namespace=f.join("."),h.rnamespace=h.namespace?new RegExp(`(^|\\.)${f.join("\\.(?:.*\\.|)")}(\\.|$)`):null,h.result=void 0,h.target||(h.target=d);const p=[h];Array.isArray(l)?p.push(...l):p.push(l);const m=wt.get(u);if(!c&&m.trigger&&m.trigger(d,h,l)===!1)return;let b;const x=[d];if(!c&&!m.noBubble&&!B.isWindow(d)){b=m.delegateType||u;let v=d,P=d.parentNode;for(;P!=null;)x.push(P),v=P,P=P.parentNode;const C=d.ownerDocument||document;if(v===C){const O=v.defaultView||v.parentWindow||window;x.push(O)}}let y=d;for(let v=0,P=x.length;v<P&&!h.isPropagationStopped();v+=1){const C=x[v];y=C,h.type=v>1?b:m.bindType||u;const O=re.get(C);O&&O.events[h.type]&&O.handler&&O.handler.call(C,...p);const N=g&&C[g]||null;N&&B.isValidTarget(C)&&(h.result=N.call(C,...p),h.result===!1&&h.preventDefault())}if(h.type=u,!c&&!h.isDefaultPrevented()){const v=m.preventDefault;if((v==null||v(x.pop(),h,l)===!1)&&B.isValidTarget(d)&&g&&typeof d[u]=="function"&&!B.isWindow(d)){const P=d[g];P&&(d[g]=null),t=u,h.isPropagationStopped()&&y.addEventListener(u,B.stopPropagationCallback),d[u](),h.isPropagationStopped()&&y.removeEventListener(u,B.stopPropagationCallback),t=void 0,P&&(d[g]=P)}}return h.result}i.trigger=r})(Xe||(Xe={}));var pt;(function(i){function t(r,o,l,a,c){return He.on(r,o,l,a,c),r}i.on=t;function e(r,o,l,a,c){return He.on(r,o,l,a,c,!0),r}i.once=e;function n(r,o,l,a){return He.off(r,o,l,a),r}i.off=n;function s(r,o,l,a){return Xe.trigger(o,l,r,a),r}i.trigger=s})(pt||(pt={}));var He;(function(i){function t(n,s,r,o,l,a){if(typeof s=="object"){typeof r!="string"&&(o=o||r,r=void 0),Object.keys(s).forEach(c=>t(n,c,r,o,s[c],a));return}if(o==null&&l==null?(l=r,o=r=void 0):l==null&&(typeof r=="string"?(l=o,o=void 0):(l=o,o=r,r=void 0)),l===!1)l=B.returnFalse;else if(!l)return;if(a){const c=l;l=function(h,...u){return i.off(n,h),c.call(this,h,...u)},B.setHandlerId(l,B.ensureHandlerId(c))}Xe.on(n,s,l,o,r)}i.on=t;function e(n,s,r,o){const l=s;if(l&&l.preventDefault!=null&&l.handleObj!=null){const a=l.handleObj;e(l.delegateTarget,a.namespace?`${a.originType}.${a.namespace}`:a.originType,a.selector,a.handler);return}if(typeof s=="object"){const a=s;Object.keys(a).forEach(c=>e(n,c,r,a[c]));return}(r===!1||typeof r=="function")&&(o=r,r=void 0),o===!1&&(o=B.returnFalse),Xe.off(n,s,o,r)}i.off=e})(He||(He={}));class or{constructor(t,e,n){this.animationFrameId=0,this.deltaX=0,this.deltaY=0,this.eventName=Xt.isEventSupported("wheel")?"wheel":"mousewheel",this.target=t,this.onWheelCallback=e,this.onWheelGuard=n,this.onWheel=this.onWheel.bind(this),this.didWheel=this.didWheel.bind(this)}enable(){this.target.addEventListener(this.eventName,this.onWheel,{passive:!1})}disable(){this.target.removeEventListener(this.eventName,this.onWheel)}onWheel(t){if(this.onWheelGuard!=null&&!this.onWheelGuard(t))return;this.deltaX+=t.deltaX,this.deltaY+=t.deltaY,t.preventDefault();let e;(this.deltaX!==0||this.deltaY!==0)&&(t.stopPropagation(),e=!0),e===!0&&this.animationFrameId===0&&(this.animationFrameId=requestAnimationFrame(()=>{this.didWheel(t)}))}didWheel(t){this.animationFrameId=0,this.onWheelCallback(t,this.deltaX,this.deltaY),this.deltaX=0,this.deltaY=0}}function lr(i,t=60){let e=null;return(...n)=>{e&&clearTimeout(e),e=window.setTimeout(()=>{i.apply(this,n)},t)}}function ya(i){let t=null,e=[];const n=()=>{if(getComputedStyle(i).position==="static"){const c=i.style;c.position="relative"}const a=document.createElement("object");return a.onload=()=>{a.contentDocument.defaultView.addEventListener("resize",s),s()},a.style.display="block",a.style.position="absolute",a.style.top="0",a.style.left="0",a.style.height="100%",a.style.width="100%",a.style.overflow="hidden",a.style.pointerEvents="none",a.style.zIndex="-1",a.style.opacity="0",a.setAttribute("tabindex","-1"),a.type="text/html",i.appendChild(a),a.data="about:blank",a},s=lr(()=>{e.forEach(a=>a(i))}),r=a=>{t||(t=n()),e.indexOf(a)===-1&&e.push(a)},o=()=>{t&&t.parentNode&&(t.contentDocument&&t.contentDocument.defaultView.removeEventListener("resize",s),t.parentNode.removeChild(t),t=null,e=[])};return{element:i,bind:r,destroy:o,unbind:a=>{const c=e.indexOf(a);c!==-1&&e.splice(c,1),e.length===0&&t&&o()}}}function ba(i){let t=null,e=[];const n=lr(()=>{e.forEach(a=>{a(i)})}),s=()=>{const a=new ResizeObserver(n);return a.observe(i),n(),a},r=a=>{t||(t=s()),e.indexOf(a)===-1&&e.push(a)},o=()=>{t&&(t.disconnect(),e=[],t=null)};return{element:i,bind:r,destroy:o,unbind:a=>{const c=e.indexOf(a);c!==-1&&e.splice(c,1),e.length===0&&t&&o()}}}const xa=typeof ResizeObserver!="undefined"?ba:ya;var An;(function(i){const t=new WeakMap;function e(s){let r=t.get(s);return r||(r=xa(s),t.set(s,r),r)}function n(s){s.destroy(),t.delete(s.element)}i.bind=(s,r)=>{const o=e(s);return o.bind(r),()=>o.unbind(r)},i.clear=s=>{const r=e(s);n(r)}})(An||(An={}));class Je{constructor(t={}){this.comparator=t.comparator||Je.defaultComparator,this.index={},this.data=t.data||[],this.heapify()}isEmpty(){return this.data.length===0}insert(t,e,n){const s={priority:t,value:e},r=this.data.length;return n&&(s.id=n,this.index[n]=r),this.data.push(s),this.bubbleUp(r),this}peek(){return this.data[0]?this.data[0].value:null}peekPriority(){return this.data[0]?this.data[0].priority:null}updatePriority(t,e){const n=this.index[t];if(typeof n=="undefined")throw new Error(`Node with id '${t}' was not found in the heap.`);const s=this.data,r=s[n].priority,o=this.comparator(e,r);o<0?(s[n].priority=e,this.bubbleUp(n)):o>0&&(s[n].priority=e,this.bubbleDown(n))}remove(){const t=this.data,e=t[0],n=t.pop();return e.id&&delete this.index[e.id],t.length>0&&(t[0]=n,n.id&&(this.index[n.id]=0),this.bubbleDown(0)),e?e.value:null}heapify(){for(let t=0;t<this.data.length;t+=1)this.bubbleUp(t)}bubbleUp(t){const e=this.data;let n,s,r=t;for(;r>0&&(s=r-1>>>1,this.comparator(e[r].priority,e[s].priority)<0);){n=e[s],e[s]=e[r];let o=e[r].id;o!=null&&(this.index[o]=s),e[r]=n,o=e[r].id,o!=null&&(this.index[o]=r),r=s}}bubbleDown(t){const e=this.data,n=e.length-1;let s=t;for(;;){const r=(s<<1)+1,o=r+1;let l=s;if(r<=n&&this.comparator(e[r].priority,e[l].priority)<0&&(l=r),o<=n&&this.comparator(e[o].priority,e[l].priority)<0&&(l=o),l!==s){const a=e[l];e[l]=e[s];let c=e[s].id;c!=null&&(this.index[c]=l),e[s]=a,c=e[s].id,c!=null&&(this.index[c]=s),s=l}else break}}}(function(i){i.defaultComparator=(t,e)=>t-e})(Je||(Je={}));var rs;(function(i){function t(e,n,s=(r,o)=>1){const r={},o={},l={},a=new Je;for(r[n]=0,Object.keys(e).forEach(c=>{c!==n&&(r[c]=1/0),a.insert(r[c],c,c)});!a.isEmpty();){const c=a.remove();l[c]=!0;const h=e[c]||[];for(let u=0;u<h.length;u+=1){const f=h[u];if(!l[f]){const d=r[c]+s(c,f);d<r[f]&&(r[f]=d,o[f]=c,a.updatePriority(f,d))}}}return o}i.run=t})(rs||(rs={}));class Dt{constructor(t,e,n,s){if(t==null)return this.set(255,255,255,1);if(typeof t=="number")return this.set(t,e,n,s);if(typeof t=="string")return Dt.fromString(t)||this;if(Array.isArray(t))return this.set(t);this.set(t.r,t.g,t.b,t.a==null?1:t.a)}blend(t,e,n){this.set(t.r+(e.r-t.r)*n,t.g+(e.g-t.g)*n,t.b+(e.b-t.b)*n,t.a+(e.a-t.a)*n)}lighten(t){const e=Dt.lighten(this.toArray(),t);this.r=e[0],this.g=e[1],this.b=e[2],this.a=e[3]}darken(t){this.lighten(-t)}set(t,e,n,s){const r=Array.isArray(t)?t[0]:t,o=Array.isArray(t)?t[1]:e,l=Array.isArray(t)?t[2]:n,a=Array.isArray(t)?t[3]:s;return this.r=Math.round(vt(r,0,255)),this.g=Math.round(vt(o,0,255)),this.b=Math.round(vt(l,0,255)),this.a=a==null?1:vt(a,0,1),this}toHex(){return`#${["r","g","b"].map(e=>{const n=this[e].toString(16);return n.length<2?`0${n}`:n}).join("")}`}toRGBA(){return this.toArray()}toHSLA(){return Dt.rgba2hsla(this.r,this.g,this.b,this.a)}toCSS(t){const e=`${this.r},${this.g},${this.b},`;return t?`rgb(${e})`:`rgba(${e},${this.a})`}toGrey(){return Dt.makeGrey(Math.round((this.r+this.g+this.b)/3),this.a)}toArray(){return[this.r,this.g,this.b,this.a]}toString(){return this.toCSS()}}(function(i){function t(y){return new i(y)}i.fromArray=t;function e(y){return new i([...g(y),1])}i.fromHex=e;function n(y){const v=y.toLowerCase().match(/^rgba?\(([\s.,0-9]+)\)/);if(v){const P=v[1].split(/\s*,\s*/).map(C=>parseInt(C,10));return new i(P)}return null}i.fromRGBA=n;function s(y,v,P){P<0&&++P,P>1&&--P;const C=6*P;return C<1?y+(v-y)*C:2*P<1?v:3*P<2?y+(v-y)*(2/3-P)*6:y}function r(y){const v=y.toLowerCase().match(/^hsla?\(([\s.,0-9]+)\)/);if(v){const P=v[2].split(/\s*,\s*/),C=(parseFloat(P[0])%360+360)%360/360,O=parseFloat(P[1])/100,N=parseFloat(P[2])/100,M=P[3]==null?1:parseInt(P[3],10);return new i(c(C,O,N,M))}return null}i.fromHSLA=r;function o(y){if(y.startsWith("#"))return e(y);if(y.startsWith("rgb"))return n(y);const v=i.named[y];return v?e(v):r(y)}i.fromString=o;function l(y,v){return i.fromArray([y,y,y,v])}i.makeGrey=l;function a(y,v,P,C){const O=Array.isArray(y)?y[0]:y,N=Array.isArray(y)?y[1]:v,M=Array.isArray(y)?y[2]:P,j=Array.isArray(y)?y[3]:C,E=Math.max(O,N,M),D=Math.min(O,N,M),_=(E+D)/2;let z=0,A=0;if(D!==E){const S=E-D;switch(A=_>.5?S/(2-E-D):S/(E+D),E){case O:z=(N-M)/S+(N<M?6:0);break;case N:z=(M-O)/S+2;break;case M:z=(O-N)/S+4;break}z/=6}return[z,A,_,j==null?1:j]}i.rgba2hsla=a;function c(y,v,P,C){const O=Array.isArray(y)?y[0]:y,N=Array.isArray(y)?y[1]:v,M=Array.isArray(y)?y[2]:P,j=Array.isArray(y)?y[3]:C,E=M<=.5?M*(N+1):M+N-M*N,D=2*M-E;return[s(D,E,O+1/3)*256,s(D,E,O)*256,s(D,E,O-1/3)*256,j==null?1:j]}i.hsla2rgba=c;function h(y){return new i(Math.round(Math.random()*256),Math.round(Math.random()*256),Math.round(Math.random()*256),y?void 0:parseFloat(Math.random().toFixed(2)))}i.random=h;function u(){const y="0123456789ABCDEF";let v="#";for(let P=0;P<6;P+=1)v+=y[Math.floor(Math.random()*16)];return v}i.randomHex=u;function f(y){return h(y).toString()}i.randomRGBA=f;function d(y,v){if(typeof y=="string"){const M=y[0]==="#",[j,E,D]=g(y);return v?j*.299+E*.587+D*.114>186?"#000000":"#ffffff":`${M?"#":""}${p(255-j,255-E,255-D)}`}const P=y[0],C=y[1],O=y[2],N=y[3];return v?P*.299+C*.587+O*.114>186?[0,0,0,N]:[255,255,255,N]:[255-P,255-C,255-O,N]}i.invert=d;function g(y){const v=y.indexOf("#")===0?y:`#${y}`;let P=+`0x${v.substr(1)}`;if(!(v.length===4||v.length===7)||Number.isNaN(P))throw new Error("Invalid hex color.");const C=v.length===4?4:8,O=(1<<C)-1,N=["b","g","r"].map(()=>{const M=P&O;return P>>=C,C===4?17*M:M});return[N[2],N[1],N[0]]}function p(y,v,P){const C=O=>O.length<2?`0${O}`:O;return`${C(y.toString(16))}${C(v.toString(16))}${C(P.toString(16))}`}function m(y,v){return x(y,v)}i.lighten=m;function b(y,v){return x(y,-v)}i.darken=b;function x(y,v){if(typeof y=="string"){const O=y[0]==="#",N=parseInt(O?y.substr(1):y,16),M=vt((N>>16)+v,0,255),j=vt((N>>8&255)+v,0,255),E=vt((N&255)+v,0,255);return`${O?"#":""}${(E|j<<8|M<<16).toString(16)}`}const P=p(y[0],y[1],y[2]),C=g(x(P,v));return[C[0],C[1],C[2],y[3]]}})(Dt||(Dt={}));(function(i){i.named={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",burntsienna:"#ea7e5d",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}})(Dt||(Dt={}));class os{constructor(){this.clear()}clear(){this.map=new WeakMap,this.arr=[]}has(t){return this.map.has(t)}get(t){return this.map.get(t)}set(t,e){this.map.set(t,e),this.arr.push(t)}delete(t){const e=this.arr.indexOf(t);e>=0&&this.arr.splice(e,1);const n=this.map.get(t);return this.map.delete(t),n}each(t){this.arr.forEach(e=>{const n=this.map.get(e);t(n,e)})}dispose(){this.clear()}}var xe;(function(i){function t(s){const r=[],o=[];return Array.isArray(s)?r.push(...s):s.split("|").forEach(l=>{l.indexOf("&")===-1?r.push(l):o.push(...l.split("&"))}),{or:r,and:o}}i.parse=t;function e(s,r){if(s!=null&&r!=null){const o=t(s),l=t(r),a=o.or.sort(),c=l.or.sort(),h=o.and.sort(),u=l.and.sort(),f=(d,g)=>d.length===g.length&&(d.length===0||d.every((p,m)=>p===g[m]));return f(a,c)&&f(h,u)}return s==null&&r==null}i.equals=e;function n(s,r,o){if(r==null||Array.isArray(r)&&r.length===0)return o?s.altKey!==!0&&s.ctrlKey!==!0&&s.metaKey!==!0&&s.shiftKey!==!0:!0;const{or:l,and:a}=t(r),c=h=>{const u=`${h.toLowerCase()}Key`;return s[u]===!0};return l.some(h=>c(h))&&a.every(h=>c(h))}i.isMatch=n})(xe||(xe={}));var ue;(function(i){i.linear=t=>t,i.quad=t=>t*t,i.cubic=t=>t*t*t,i.inout=t=>{if(t<=0)return 0;if(t>=1)return 1;const e=t*t,n=e*t;return 4*(t<.5?n:3*(t-e)+n-.75)},i.exponential=t=>Math.pow(2,10*(t-1)),i.bounce=t=>{for(let e=0,n=1;;e+=n,n/=2)if(t>=(7-4*e)/11){const s=(11-6*e-11*t)/4;return-s*s+n*n}}})(ue||(ue={}));(function(i){i.decorators={reverse(t){return e=>1-t(1-e)},reflect(t){return e=>.5*(e<.5?t(2*e):2-t(2-2*e))},clamp(t,e=0,n=1){return s=>{const r=t(s);return r<e?e:r>n?n:r}},back(t=1.70158){return e=>e*e*((t+1)*e-t)},elastic(t=1.5){return e=>Math.pow(2,10*(e-1))*Math.cos(20*Math.PI*t/3*e)}}})(ue||(ue={}));(function(i){function t(A){return-1*Math.cos(A*(Math.PI/2))+1}i.easeInSine=t;function e(A){return Math.sin(A*(Math.PI/2))}i.easeOutSine=e;function n(A){return-.5*(Math.cos(Math.PI*A)-1)}i.easeInOutSine=n;function s(A){return A*A}i.easeInQuad=s;function r(A){return A*(2-A)}i.easeOutQuad=r;function o(A){return A<.5?2*A*A:-1+(4-2*A)*A}i.easeInOutQuad=o;function l(A){return A*A*A}i.easeInCubic=l;function a(A){const S=A-1;return S*S*S+1}i.easeOutCubic=a;function c(A){return A<.5?4*A*A*A:(A-1)*(2*A-2)*(2*A-2)+1}i.easeInOutCubic=c;function h(A){return A*A*A*A}i.easeInQuart=h;function u(A){const S=A-1;return 1-S*S*S*S}i.easeOutQuart=u;function f(A){const S=A-1;return A<.5?8*A*A*A*A:1-8*S*S*S*S}i.easeInOutQuart=f;function d(A){return A*A*A*A*A}i.easeInQuint=d;function g(A){const S=A-1;return 1+S*S*S*S*S}i.easeOutQuint=g;function p(A){const S=A-1;return A<.5?16*A*A*A*A*A:1+16*S*S*S*S*S}i.easeInOutQuint=p;function m(A){return A===0?0:Math.pow(2,10*(A-1))}i.easeInExpo=m;function b(A){return A===1?1:-Math.pow(2,-10*A)+1}i.easeOutExpo=b;function x(A){if(A===0||A===1)return A;const S=A*2,$=S-1;return S<1?.5*Math.pow(2,10*$):.5*(-Math.pow(2,-10*$)+2)}i.easeInOutExpo=x;function y(A){const S=A/1;return-1*(Math.sqrt(1-S*A)-1)}i.easeInCirc=y;function v(A){const S=A-1;return Math.sqrt(1-S*S)}i.easeOutCirc=v;function P(A){const S=A*2,$=S-2;return S<1?-.5*(Math.sqrt(1-S*S)-1):.5*(Math.sqrt(1-$*$)+1)}i.easeInOutCirc=P;function C(A,S=1.70158){return A*A*((S+1)*A-S)}i.easeInBack=C;function O(A,S=1.70158){const $=A/1-1;return $*$*((S+1)*$+S)+1}i.easeOutBack=O;function N(A,S=1.70158){const $=A*2,J=$-2,Y=S*1.525;return $<1?.5*$*$*((Y+1)*$-Y):.5*(J*J*((Y+1)*J+Y)+2)}i.easeInOutBack=N;function M(A,S=.7){if(A===0||A===1)return A;const J=A/1-1,Y=1-S,rt=Y/(2*Math.PI)*Math.asin(1);return-(Math.pow(2,10*J)*Math.sin((J-rt)*(2*Math.PI)/Y))}i.easeInElastic=M;function j(A,S=.7){const $=1-S,J=A*2;if(A===0||A===1)return A;const Y=$/(2*Math.PI)*Math.asin(1);return Math.pow(2,-10*J)*Math.sin((J-Y)*(2*Math.PI)/$)+1}i.easeOutElastic=j;function E(A,S=.65){const $=1-S;if(A===0||A===1)return A;const J=A*2,Y=J-1,rt=$/(2*Math.PI)*Math.asin(1);return J<1?-.5*(Math.pow(2,10*Y)*Math.sin((Y-rt)*(2*Math.PI)/$)):Math.pow(2,-10*Y)*Math.sin((Y-rt)*(2*Math.PI)/$)*.5+1}i.easeInOutElastic=E;function D(A){const S=A/1;if(S<1/2.75)return 7.5625*S*S;if(S<2/2.75){const $=S-.5454545454545454;return 7.5625*$*$+.75}if(S<2.5/2.75){const $=S-.8181818181818182;return 7.5625*$*$+.9375}{const $=S-.9545454545454546;return 7.5625*$*$+.984375}}i.easeOutBounce=D;function _(A){return 1-D(1-A)}i.easeInBounce=_;function z(A){return A<.5?_(A*2)*.5:D(A*2-1)*.5+.5}i.easeInOutBounce=z})(ue||(ue={}));var oe;(function(i){i.number=(t,e)=>{const n=e-t;return s=>t+n*s},i.object=(t,e)=>{const n=Object.keys(t);return s=>{const r={};for(let o=n.length-1;o!==-1;o-=1){const l=n[o];r[l]=t[l]+(e[l]-t[l])*s}return r}},i.unit=(t,e)=>{const n=/(-?[0-9]*.[0-9]*)(px|em|cm|mm|in|pt|pc|%)/,s=n.exec(t),r=n.exec(e),o=r?r[1]:"",l=s?+s[1]:0,a=r?+r[1]:0,c=o.indexOf("."),h=c>0?o[1].length-c-1:0,u=a-l,f=s?s[2]:"";return d=>(l+u*d).toFixed(h)+f},i.color=(t,e)=>{const n=parseInt(t.slice(1),16),s=parseInt(e.slice(1),16),r=n&255,o=(s&255)-r,l=n&65280,a=(s&65280)-l,c=n&16711680,h=(s&16711680)-c;return u=>{const f=r+o*u&255,d=l+a*u&65280,g=c+h*u&16711680;return`#${(1<<24|f|d|g).toString(16).slice(1)}`}}})(oe||(oe={}));const Ge=[];function wa(i,t){const e=Ge.find(n=>n.name===i);if(!(e&&(e.loadTimes+=1,e.loadTimes>1))&&!Xt.isApplyingHMR()){const n=document.createElement("style");n.setAttribute("type","text/css"),n.textContent=t;const s=document.querySelector("head");s&&s.insertBefore(n,s.firstChild),Ge.push({name:i,loadTimes:1,styleElement:n})}}function va(i){const t=Ge.findIndex(e=>e.name===i);if(t>-1){const e=Ge[t];if(e.loadTimes-=1,e.loadTimes>0)return;let n=e.styleElement;n&&n.parentNode&&n.parentNode.removeChild(n),n=null,Ge.splice(t,1)}}var U;(function(i){function t(n){return 180*n/Math.PI%360}i.toDeg=t,i.toRad=function(n,s=!1){return(s?n:n%360)*Math.PI/180};function e(n){return n%360+(n<0?360:0)}i.normalize=e})(U||(U={}));var H;(function(i){function t(l,a=0){return Number.isInteger(l)?l:+l.toFixed(a)}i.round=t;function e(l,a){let c,h;if(a==null?(h=l==null?1:l,c=0):(h=a,c=l==null?0:l),h<c){const u=c;c=h,h=u}return Math.floor(Math.random()*(h-c+1)+c)}i.random=e;function n(l,a,c){return Number.isNaN(l)?NaN:Number.isNaN(a)||Number.isNaN(c)?0:a<c?l<a?a:l>c?c:l:l<c?c:l>a?a:l}i.clamp=n;function s(l,a){return a*Math.round(l/a)}i.snapToGrid=s;function r(l,a){return a!=null&&l!=null&&a.x>=l.x&&a.x<=l.x+l.width&&a.y>=l.y&&a.y<=l.y+l.height}i.containsPoint=r;function o(l,a){const c=l.x-a.x,h=l.y-a.y;return c*c+h*h}i.squaredLength=o})(H||(H={}));class te{valueOf(){return this.toJSON()}toString(){return JSON.stringify(this.toJSON())}}class w extends te{constructor(t,e){super(),this.x=t==null?0:t,this.y=e==null?0:e}round(t=0){return this.x=H.round(this.x,t),this.y=H.round(this.y,t),this}add(t,e){const n=w.create(t,e);return this.x+=n.x,this.y+=n.y,this}update(t,e){const n=w.create(t,e);return this.x=n.x,this.y=n.y,this}translate(t,e){const n=w.create(t,e);return this.x+=n.x,this.y+=n.y,this}rotate(t,e){const n=w.rotate(this,t,e);return this.x=n.x,this.y=n.y,this}scale(t,e,n=new w){const s=w.create(n);return this.x=s.x+t*(this.x-s.x),this.y=s.y+e*(this.y-s.y),this}closest(t){if(t.length===1)return w.create(t[0]);let e=null,n=1/0;return t.forEach(s=>{const r=this.squaredDistance(s);r<n&&(e=s,n=r)}),e?w.create(e):null}distance(t){return Math.sqrt(this.squaredDistance(t))}squaredDistance(t){const e=w.create(t),n=this.x-e.x,s=this.y-e.y;return n*n+s*s}manhattanDistance(t){const e=w.create(t);return Math.abs(e.x-this.x)+Math.abs(e.y-this.y)}magnitude(){return Math.sqrt(this.x*this.x+this.y*this.y)||.01}theta(t=new w){const e=w.create(t),n=-(e.y-this.y),s=e.x-this.x;let r=Math.atan2(n,s);return r<0&&(r=2*Math.PI+r),180*r/Math.PI}angleBetween(t,e){if(this.equals(t)||this.equals(e))return NaN;let n=this.theta(e)-this.theta(t);return n<0&&(n+=360),n}vectorAngle(t){return new w(0,0).angleBetween(this,t)}toPolar(t){return this.update(w.toPolar(this,t)),this}changeInAngle(t,e,n=new w){return this.clone().translate(-t,-e).theta(n)-this.theta(n)}adhereToRect(t){return H.containsPoint(t,this)||(this.x=Math.min(Math.max(this.x,t.x),t.x+t.width),this.y=Math.min(Math.max(this.y,t.y),t.y+t.height)),this}bearing(t){const e=w.create(t),n=U.toRad(this.y),s=U.toRad(e.y),r=this.x,o=e.x,l=U.toRad(o-r),a=Math.sin(l)*Math.cos(s),c=Math.cos(n)*Math.sin(s)-Math.sin(n)*Math.cos(s)*Math.cos(l),h=U.toDeg(Math.atan2(a,c)),u=["NE","E","SE","S","SW","W","NW","N"];let f=h-22.5;return f<0&&(f+=360),f=parseInt(f/45,10),u[f]}cross(t,e){if(t!=null&&e!=null){const n=w.create(t),s=w.create(e);return(s.x-this.x)*(n.y-this.y)-(s.y-this.y)*(n.x-this.x)}return NaN}dot(t){const e=w.create(t);return this.x*e.x+this.y*e.y}diff(t,e){if(typeof t=="number")return new w(this.x-t,this.y-e);const n=w.create(t);return new w(this.x-n.x,this.y-n.y)}lerp(t,e){const n=w.create(t);return new w((1-e)*this.x+e*n.x,(1-e)*this.y+e*n.y)}normalize(t=1){const e=t/this.magnitude();return this.scale(e,e)}move(t,e){const n=w.create(t),s=U.toRad(n.theta(this));return this.translate(Math.cos(s)*e,-Math.sin(s)*e)}reflection(t){return w.create(t).move(this,this.distance(t))}snapToGrid(t,e){return this.x=H.snapToGrid(this.x,t),this.y=H.snapToGrid(this.y,e==null?t:e),this}equals(t){const e=w.create(t);return e!=null&&e.x===this.x&&e.y===this.y}clone(){return w.clone(this)}toJSON(){return w.toJSON(this)}serialize(){return`${this.x} ${this.y}`}}(function(i){function t(e){return e!=null&&e instanceof i}i.isPoint=t})(w||(w={}));(function(i){function t(n){return n!=null&&typeof n=="object"&&typeof n.x=="number"&&typeof n.y=="number"}i.isPointLike=t;function e(n){return n!=null&&Array.isArray(n)&&n.length===2&&typeof n[0]=="number"&&typeof n[1]=="number"}i.isPointData=e})(w||(w={}));(function(i){function t(u,f){return u==null||typeof u=="number"?new i(u,f):e(u)}i.create=t;function e(u){return i.isPoint(u)?new i(u.x,u.y):Array.isArray(u)?new i(u[0],u[1]):new i(u.x,u.y)}i.clone=e;function n(u){return i.isPoint(u)?{x:u.x,y:u.y}:Array.isArray(u)?{x:u[0],y:u[1]}:{x:u.x,y:u.y}}i.toJSON=n;function s(u,f,d=new i){let g=Math.abs(u*Math.cos(f)),p=Math.abs(u*Math.sin(f));const m=e(d),b=U.normalize(U.toDeg(f));return b<90?p=-p:b<180?(g=-g,p=-p):b<270&&(g=-g),new i(m.x+g,m.y+p)}i.fromPolar=s;function r(u,f=new i){const d=e(u),g=e(f),p=d.x-g.x,m=d.y-g.y;return new i(Math.sqrt(p*p+m*m),U.toRad(g.theta(d)))}i.toPolar=r;function o(u,f){return u===f?!0:u!=null&&f!=null?u.x===f.x&&u.y===f.y:!1}i.equals=o;function l(u,f){if(u==null&&f!=null||u!=null&&f==null||u!=null&&f!=null&&u.length!==f.length)return!1;if(u!=null&&f!=null){for(let d=0,g=u.length;d<g;d+=1)if(!o(u[d],f[d]))return!1}return!0}i.equalPoints=l;function a(u,f,d,g){return new i(H.random(u,f),H.random(d,g))}i.random=a;function c(u,f,d){const g=U.toRad(U.normalize(-f)),p=Math.sin(g),m=Math.cos(g);return h(u,m,p,d)}i.rotate=c;function h(u,f,d,g=new i){const p=e(u),m=e(g),b=p.x-m.x,x=p.y-m.y,y=b*f-x*d,v=x*f+b*d;return new i(y+m.x,v+m.y)}i.rotateEx=h})(w||(w={}));class T extends te{get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get origin(){return new w(this.x,this.y)}get topLeft(){return new w(this.x,this.y)}get topCenter(){return new w(this.x+this.width/2,this.y)}get topRight(){return new w(this.x+this.width,this.y)}get center(){return new w(this.x+this.width/2,this.y+this.height/2)}get bottomLeft(){return new w(this.x,this.y+this.height)}get bottomCenter(){return new w(this.x+this.width/2,this.y+this.height)}get bottomRight(){return new w(this.x+this.width,this.y+this.height)}get corner(){return new w(this.x+this.width,this.y+this.height)}get rightMiddle(){return new w(this.x+this.width,this.y+this.height/2)}get leftMiddle(){return new w(this.x,this.y+this.height/2)}get topLine(){return new L(this.topLeft,this.topRight)}get rightLine(){return new L(this.topRight,this.bottomRight)}get bottomLine(){return new L(this.bottomLeft,this.bottomRight)}get leftLine(){return new L(this.topLeft,this.bottomLeft)}constructor(t,e,n,s){super(),this.x=t==null?0:t,this.y=e==null?0:e,this.width=n==null?0:n,this.height=s==null?0:s}getOrigin(){return this.origin}getTopLeft(){return this.topLeft}getTopCenter(){return this.topCenter}getTopRight(){return this.topRight}getCenter(){return this.center}getCenterX(){return this.x+this.width/2}getCenterY(){return this.y+this.height/2}getBottomLeft(){return this.bottomLeft}getBottomCenter(){return this.bottomCenter}getBottomRight(){return this.bottomRight}getCorner(){return this.corner}getRightMiddle(){return this.rightMiddle}getLeftMiddle(){return this.leftMiddle}getTopLine(){return this.topLine}getRightLine(){return this.rightLine}getBottomLine(){return this.bottomLine}getLeftLine(){return this.leftLine}bbox(t){if(!t)return this.clone();const e=U.toRad(t),n=Math.abs(Math.sin(e)),s=Math.abs(Math.cos(e)),r=this.width*s+this.height*n,o=this.width*n+this.height*s;return new T(this.x+(this.width-r)/2,this.y+(this.height-o)/2,r,o)}round(t=0){return this.x=H.round(this.x,t),this.y=H.round(this.y,t),this.width=H.round(this.width,t),this.height=H.round(this.height,t),this}add(t,e,n,s){const r=T.create(t,e,n,s),o=Math.min(this.x,r.x),l=Math.min(this.y,r.y),a=Math.max(this.x+this.width,r.x+r.width),c=Math.max(this.y+this.height,r.y+r.height);return this.x=o,this.y=l,this.width=a-o,this.height=c-l,this}update(t,e,n,s){const r=T.create(t,e,n,s);return this.x=r.x,this.y=r.y,this.width=r.width,this.height=r.height,this}inflate(t,e){const n=t,s=e!=null?e:t;return this.x-=n,this.y-=s,this.width+=2*n,this.height+=2*s,this}snapToGrid(t,e){const n=this.origin.snapToGrid(t,e),s=this.corner.snapToGrid(t,e);return this.x=n.x,this.y=n.y,this.width=s.x-n.x,this.height=s.y-n.y,this}translate(t,e){const n=w.create(t,e);return this.x+=n.x,this.y+=n.y,this}scale(t,e,n=new w){const s=this.origin.scale(t,e,n);return this.x=s.x,this.y=s.y,this.width*=t,this.height*=e,this}rotate(t,e=this.getCenter()){if(t!==0){const n=U.toRad(t),s=Math.cos(n),r=Math.sin(n);let o=this.getOrigin(),l=this.getTopRight(),a=this.getBottomRight(),c=this.getBottomLeft();o=w.rotateEx(o,s,r,e),l=w.rotateEx(l,s,r,e),a=w.rotateEx(a,s,r,e),c=w.rotateEx(c,s,r,e);const h=new T(o.x,o.y,0,0);h.add(l.x,l.y,0,0),h.add(a.x,a.y,0,0),h.add(c.x,c.y,0,0),this.update(h)}return this}rotate90(){const t=(this.width-this.height)/2;this.x+=t,this.y-=t;const e=this.width;return this.width=this.height,this.height=e,this}moveAndExpand(t){const e=T.clone(t);return this.x+=e.x||0,this.y+=e.y||0,this.width+=e.width||0,this.height+=e.height||0,this}getMaxScaleToFit(t,e=this.center){const n=T.clone(t),s=e.x,r=e.y;let o=1/0,l=1/0,a=1/0,c=1/0,h=1/0,u=1/0,f=1/0,d=1/0;const g=n.topLeft;g.x<s&&(o=(this.x-s)/(g.x-s)),g.y<r&&(h=(this.y-r)/(g.y-r));const p=n.bottomRight;p.x>s&&(l=(this.x+this.width-s)/(p.x-s)),p.y>r&&(u=(this.y+this.height-r)/(p.y-r));const m=n.topRight;m.x>s&&(a=(this.x+this.width-s)/(m.x-s)),m.y<r&&(f=(this.y-r)/(m.y-r));const b=n.bottomLeft;return b.x<s&&(c=(this.x-s)/(b.x-s)),b.y>r&&(d=(this.y+this.height-r)/(b.y-r)),{sx:Math.min(o,l,a,c),sy:Math.min(h,u,f,d)}}getMaxUniformScaleToFit(t,e=this.center){const n=this.getMaxScaleToFit(t,e);return Math.min(n.sx,n.sy)}containsPoint(t,e){return H.containsPoint(this,w.create(t,e))}containsRect(t,e,n,s){const r=T.create(t,e,n,s),o=this.x,l=this.y,a=this.width,c=this.height,h=r.x,u=r.y,f=r.width,d=r.height;return a===0||c===0||f===0||d===0?!1:h>=o&&u>=l&&h+f<=o+a&&u+d<=l+c}intersectsWithLine(t){const e=[this.topLine,this.rightLine,this.bottomLine,this.leftLine],n=[],s=[];return e.forEach(r=>{const o=t.intersectsWithLine(r);o!==null&&s.indexOf(o.toString())<0&&(n.push(o),s.push(o.toString()))}),n.length>0?n:null}intersectsWithLineFromCenterToPoint(t,e){const n=w.clone(t),s=this.center;let r=null;e!=null&&e!==0&&n.rotate(e,s);const o=[this.topLine,this.rightLine,this.bottomLine,this.leftLine],l=new L(s,n);for(let a=o.length-1;a>=0;a-=1){const c=o[a].intersectsWithLine(l);if(c!==null){r=c;break}}return r&&e!=null&&e!==0&&r.rotate(-e,s),r}intersectsWithRect(t,e,n,s){const r=T.create(t,e,n,s);if(!this.isIntersectWithRect(r))return null;const o=this.origin,l=this.corner,a=r.origin,c=r.corner,h=Math.max(o.x,a.x),u=Math.max(o.y,a.y);return new T(h,u,Math.min(l.x,c.x)-h,Math.min(l.y,c.y)-u)}isIntersectWithRect(t,e,n,s){const r=T.create(t,e,n,s),o=this.origin,l=this.corner,a=r.origin,c=r.corner;return!(c.x<=o.x||c.y<=o.y||a.x>=l.x||a.y>=l.y)}normalize(){let t=this.x,e=this.y,n=this.width,s=this.height;return this.width<0&&(t=this.x+this.width,n=-this.width),this.height<0&&(e=this.y+this.height,s=-this.height),this.x=t,this.y=e,this.width=n,this.height=s,this}union(t){const e=T.clone(t),n=this.origin,s=this.corner,r=e.origin,o=e.corner,l=Math.min(n.x,r.x),a=Math.min(n.y,r.y),c=Math.max(s.x,o.x),h=Math.max(s.y,o.y);return new T(l,a,c-l,h-a)}getNearestSideToPoint(t){const e=w.clone(t),n=e.x-this.x,s=this.x+this.width-e.x,r=e.y-this.y,o=this.y+this.height-e.y;let l=n,a="left";return s<l&&(l=s,a="right"),r<l&&(l=r,a="top"),o<l&&(a="bottom"),a}getNearestPointToPoint(t){const e=w.clone(t);if(this.containsPoint(e)){const n=this.getNearestSideToPoint(e);if(n==="left")return new w(this.x,e.y);if(n==="top")return new w(e.x,this.y);if(n==="right")return new w(this.x+this.width,e.y);if(n==="bottom")return new w(e.x,this.y+this.height)}return e.adhereToRect(this)}equals(t){return t!=null&&t.x===this.x&&t.y===this.y&&t.width===this.width&&t.height===this.height}clone(){return new T(this.x,this.y,this.width,this.height)}toJSON(){return{x:this.x,y:this.y,width:this.width,height:this.height}}serialize(){return`${this.x} ${this.y} ${this.width} ${this.height}`}}(function(i){function t(e){return e!=null&&e instanceof i}i.isRectangle=t})(T||(T={}));(function(i){function t(e){return e!=null&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number"&&typeof e.width=="number"&&typeof e.height=="number"}i.isRectangleLike=t})(T||(T={}));(function(i){function t(o,l,a,c){return o==null||typeof o=="number"?new i(o,l,a,c):e(o)}i.create=t;function e(o){return i.isRectangle(o)?o.clone():Array.isArray(o)?new i(o[0],o[1],o[2],o[3]):new i(o.x,o.y,o.width,o.height)}i.clone=e;function n(o){return new i(o.x-o.a,o.y-o.b,2*o.a,2*o.b)}i.fromEllipse=n;function s(o){return new i(0,0,o.width,o.height)}i.fromSize=s;function r(o,l){return new i(o.x,o.y,l.width,l.height)}i.fromPositionAndSize=r})(T||(T={}));class L extends te{get center(){return new w((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)}constructor(t,e,n,s){super(),typeof t=="number"&&typeof e=="number"?(this.start=new w(t,e),this.end=new w(n,s)):(this.start=w.create(t),this.end=w.create(e))}getCenter(){return this.center}round(t=0){return this.start.round(t),this.end.round(t),this}translate(t,e){return typeof t=="number"?(this.start.translate(t,e),this.end.translate(t,e)):(this.start.translate(t),this.end.translate(t)),this}rotate(t,e){return this.start.rotate(t,e),this.end.rotate(t,e),this}scale(t,e,n){return this.start.scale(t,e,n),this.end.scale(t,e,n),this}length(){return Math.sqrt(this.squaredLength())}squaredLength(){const t=this.start.x-this.end.x,e=this.start.y-this.end.y;return t*t+e*e}setLength(t){const e=this.length();if(!e)return this;const n=t/e;return this.scale(n,n,this.start)}parallel(t){const e=this.clone();if(!e.isDifferentiable())return e;const{start:n,end:s}=e,r=n.clone().rotate(270,s),o=s.clone().rotate(90,n);return n.move(o,t),s.move(r,t),e}vector(){return new w(this.end.x-this.start.x,this.end.y-this.start.y)}angle(){const t=new w(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)}bbox(){const t=Math.min(this.start.x,this.end.x),e=Math.min(this.start.y,this.end.y),n=Math.max(this.start.x,this.end.x),s=Math.max(this.start.y,this.end.y);return new T(t,e,n-t,s-e)}bearing(){return this.start.bearing(this.end)}closestPoint(t){return this.pointAt(this.closestPointNormalizedLength(t))}closestPointLength(t){return this.closestPointNormalizedLength(t)*this.length()}closestPointTangent(t){return this.tangentAt(this.closestPointNormalizedLength(t))}closestPointNormalizedLength(t){const e=this.vector().dot(new L(this.start,t).vector()),n=Math.min(1,Math.max(0,e/this.squaredLength()));return Number.isNaN(n)?0:n}pointAt(t){const e=this.start,n=this.end;return t<=0?e.clone():t>=1?n.clone():e.lerp(n,t)}pointAtLength(t){const e=this.start,n=this.end;let s=!0;t<0&&(s=!1,t=-t);const r=this.length();if(t>=r)return s?n.clone():e.clone();const o=(s?t:r-t)/r;return this.pointAt(o)}divideAt(t){const e=this.pointAt(t);return[new L(this.start,e),new L(e,this.end)]}divideAtLength(t){const e=this.pointAtLength(t);return[new L(this.start,e),new L(e,this.end)]}containsPoint(t){const e=this.start,n=this.end;if(e.cross(t,n)!==0)return!1;const s=this.length();return!(new L(e,t).length()>s||new L(t,n).length()>s)}intersect(t,e){const n=t.intersectsWithLine(this,e);return n?Array.isArray(n)?n:[n]:null}intersectsWithLine(t){const e=new w(this.end.x-this.start.x,this.end.y-this.start.y),n=new w(t.end.x-t.start.x,t.end.y-t.start.y),s=e.x*n.y-e.y*n.x,r=new w(t.start.x-this.start.x,t.start.y-this.start.y),o=r.x*n.y-r.y*n.x,l=r.x*e.y-r.y*e.x;if(s===0||o*s<0||l*s<0)return null;if(s>0){if(o>s||l>s)return null}else if(o<s||l<s)return null;return new w(this.start.x+o*e.x/s,this.start.y+o*e.y/s)}isDifferentiable(){return!this.start.equals(this.end)}pointOffset(t){const e=w.clone(t),n=this.start,s=this.end;return((s.x-n.x)*(e.y-n.y)-(s.y-n.y)*(e.x-n.x))/this.length()}pointSquaredDistance(t,e){const n=w.create(t,e);return this.closestPoint(n).squaredDistance(n)}pointDistance(t,e){const n=w.create(t,e);return this.closestPoint(n).distance(n)}tangentAt(t){if(!this.isDifferentiable())return null;const e=this.start,n=this.end,s=this.pointAt(t),r=new L(e,n);return r.translate(s.x-e.x,s.y-e.y),r}tangentAtLength(t){if(!this.isDifferentiable())return null;const e=this.start,n=this.end,s=this.pointAtLength(t),r=new L(e,n);return r.translate(s.x-e.x,s.y-e.y),r}relativeCcw(t,e){const n=w.create(t,e);let s=n.x-this.start.x,r=n.y-this.start.y;const o=this.end.x-this.start.x,l=this.end.y-this.start.y;let a=s*l-r*o;return a===0&&(a=s*o+r*l,a>0&&(s-=o,r-=l,a=s*o+r*l,a<0&&(a=0))),a<0?-1:a>0?1:0}equals(t){return t!=null&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y}clone(){return new L(this.start,this.end)}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}serialize(){return[this.start.serialize(),this.end.serialize()].join(" ")}}(function(i){function t(e){return e!=null&&e instanceof i}i.isLine=t})(L||(L={}));class St extends te{get center(){return new w(this.x,this.y)}constructor(t,e,n,s){super(),this.x=t==null?0:t,this.y=e==null?0:e,this.a=n==null?0:n,this.b=s==null?0:s}bbox(){return T.fromEllipse(this)}getCenter(){return this.center}inflate(t,e){const n=t,s=e!=null?e:t;return this.a+=2*n,this.b+=2*s,this}normalizedDistance(t,e){const n=w.create(t,e),s=n.x-this.x,r=n.y-this.y,o=this.a,l=this.b;return s*s/(o*o)+r*r/(l*l)}containsPoint(t,e){return this.normalizedDistance(t,e)<=1}intersectsWithLine(t){const e=[],n=this.a,s=this.b,r=t.start,o=t.end,l=t.vector(),a=r.diff(new w(this.x,this.y)),c=new w(l.x/(n*n),l.y/(s*s)),h=new w(a.x/(n*n),a.y/(s*s)),u=l.dot(c),f=l.dot(h),d=a.dot(h)-1,g=f*f-u*d;if(g<0)return null;if(g>0){const p=Math.sqrt(g),m=(-f-p)/u,b=(-f+p)/u;if((m<0||m>1)&&(b<0||b>1))return null;m>=0&&m<=1&&e.push(r.lerp(o,m)),b>=0&&b<=1&&e.push(r.lerp(o,b))}else{const p=-f/u;if(p>=0&&p<=1)e.push(r.lerp(o,p));else return null}return e}intersectsWithLineFromCenterToPoint(t,e=0){const n=w.clone(t);e&&n.rotate(e,this.getCenter());const s=n.x-this.x,r=n.y-this.y;let o;if(s===0)return o=this.bbox().getNearestPointToPoint(n),e?o.rotate(-e,this.getCenter()):o;const l=r/s,a=l*l,c=this.a*this.a,h=this.b*this.b;let u=Math.sqrt(1/(1/c+a/h));u=s<0?-u:u;const f=l*u;return o=new w(this.x+u,this.y+f),e?o.rotate(-e,this.getCenter()):o}tangentTheta(t){const e=w.clone(t),n=e.x,s=e.y,r=this.a,o=this.b,l=this.bbox().center,a=l.x,c=l.y,h=30,u=n>l.x+r/2,f=n<l.x-r/2;let d,g;return u||f?(g=n>l.x?s-h:s+h,d=r*r/(n-a)-r*r*(s-c)*(g-c)/(o*o*(n-a))+a):(d=s>l.y?n+h:n-h,g=o*o/(s-c)-o*o*(n-a)*(d-a)/(r*r*(s-c))+c),new w(d,g).theta(e)}scale(t,e){return this.a*=t,this.b*=e,this}rotate(t,e){const n=T.fromEllipse(this);n.rotate(t,e);const s=St.fromRect(n);return this.a=s.a,this.b=s.b,this.x=s.x,this.y=s.y,this}translate(t,e){const n=w.create(t,e);return this.x+=n.x,this.y+=n.y,this}equals(t){return t!=null&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b}clone(){return new St(this.x,this.y,this.a,this.b)}toJSON(){return{x:this.x,y:this.y,a:this.a,b:this.b}}serialize(){return`${this.x} ${this.y} ${this.a} ${this.b}`}}(function(i){function t(e){return e!=null&&e instanceof i}i.isEllipse=t})(St||(St={}));(function(i){function t(s,r,o,l){return s==null||typeof s=="number"?new i(s,r,o,l):e(s)}i.create=t;function e(s){return i.isEllipse(s)?s.clone():Array.isArray(s)?new i(s[0],s[1],s[2],s[3]):new i(s.x,s.y,s.a,s.b)}i.parse=e;function n(s){const r=s.center;return new i(r.x,r.y,s.width/2,s.height/2)}i.fromRect=n})(St||(St={}));const Pa=new RegExp("^[\\s\\dLMCZz,.]*$");function Ca(i){return typeof i!="string"?!1:Pa.test(i)}function Xn(i,t){return(i%t+t)%t}function Aa(i,t,e,n,s){const r=[],o=i[i.length-1],l=t!=null&&t>0,a=t||0;if(n&&l){i=i.slice();const u=i[0],f=new w(o.x+(u.x-o.x)/2,o.y+(u.y-o.y)/2);i.splice(0,0,f)}let c=i[0],h=1;for(e?r.push("M",c.x,c.y):r.push("L",c.x,c.y);h<(n?i.length:i.length-1);){let u=i[Xn(h,i.length)],f=c.x-u.x,d=c.y-u.y;if(l&&(f!==0||d!==0)&&(s==null||s.indexOf(h-1)<0)){let g=Math.sqrt(f*f+d*d);const p=f*Math.min(a,g/2)/g,m=d*Math.min(a,g/2)/g,b=u.x+p,x=u.y+m;r.push("L",b,x);let y=i[Xn(h+1,i.length)];for(;h<i.length-2&&Math.round(y.x-u.x)===0&&Math.round(y.y-u.y)===0;)y=i[Xn(h+2,i.length)],h+=1;f=y.x-u.x,d=y.y-u.y,g=Math.max(1,Math.sqrt(f*f+d*d));const v=f*Math.min(a,g/2)/g,P=d*Math.min(a,g/2)/g,C=u.x+v,O=u.y+P;r.push("Q",u.x,u.y,C,O),u=new w(C,O)}else r.push("L",u.x,u.y);c=u,h+=1}return n?r.push("Z"):r.push("L",o.x,o.y),r.map(u=>typeof u=="string"?u:+u.toFixed(3)).join(" ")}function ar(i,t={}){const e=[];return i&&i.length&&i.forEach(n=>{Array.isArray(n)?e.push({x:n[0],y:n[1]}):e.push({x:n.x,y:n.y})}),Aa(e,t.round,t.initialMove==null||t.initialMove,t.close,t.exclude)}function Sn(i,t,e,n,s=0,r=0,o=0,l,a){if(e===0||n===0)return[];l-=i,a-=t,e=Math.abs(e),n=Math.abs(n);const c=-l/2,h=-a/2,u=Math.cos(s*Math.PI/180),f=Math.sin(s*Math.PI/180),d=u*c+f*h,g=-1*f*c+u*h,p=d*d,m=g*g,b=e*e,x=n*n,y=p/b+m/x;let v;if(y>1)e=Math.sqrt(y)*e,n=Math.sqrt(y)*n,v=0;else{let jt=1;r===o&&(jt=-1),v=jt*Math.sqrt((b*x-b*m-x*p)/(b*m+x*p))}const P=v*e*g/n,C=-1*v*n*d/e,O=u*P-f*C+l/2,N=f*P+u*C+a/2;let M=Math.atan2((g-C)/n,(d-P)/e)-Math.atan2(0,1),j=M>=0?M:2*Math.PI+M;M=Math.atan2((-g-C)/n,(-d-P)/e)-Math.atan2((g-C)/n,(d-P)/e);let E=M>=0?M:2*Math.PI+M;o===0&&E>0?E-=2*Math.PI:o!==0&&E<0&&(E+=2*Math.PI);const D=E*2/Math.PI,_=Math.ceil(D<0?-1*D:D),z=E/_,A=8/3*Math.sin(z/4)*Math.sin(z/4)/Math.sin(z/2),S=u*e,$=u*n,J=f*e,Y=f*n;let rt=Math.cos(j),dt=Math.sin(j),an=-A*(S*dt+Y*rt),cn=-A*(J*dt-$*rt),Ht=0,$e=0;const Lt=[];for(let jt=0;jt<_;jt+=1){j+=z,rt=Math.cos(j),dt=Math.sin(j),Ht=S*rt-Y*dt+O,$e=J*rt+$*dt+N;const Ds=-A*(S*dt+Y*rt),Is=-A*(J*dt-$*rt),fe=jt*6;Lt[fe]=Number(an+i),Lt[fe+1]=Number(cn+t),Lt[fe+2]=Number(Ht-Ds+i),Lt[fe+3]=Number($e-Is+t),Lt[fe+4]=Number(Ht+i),Lt[fe+5]=Number($e+t),an=Ht+Ds,cn=$e+Is}return Lt.map(jt=>+jt.toFixed(2))}function Sa(i,t,e,n,s=0,r=0,o=0,l,a){const c=[],h=Sn(i,t,e,n,s,r,o,l,a);if(h!=null)for(let u=0,f=h.length;u<f;u+=6)c.push("C",h[u],h[u+1],h[u+2],h[u+3],h[u+4],h[u+5]);return c.join(" ")}class tt extends te{get start(){return this.points[0]||null}get end(){return this.points[this.points.length-1]||null}constructor(t){if(super(),t!=null){if(typeof t=="string")return tt.parse(t);this.points=t.map(e=>w.create(e))}else this.points=[]}scale(t,e,n=new w){return this.points.forEach(s=>s.scale(t,e,n)),this}rotate(t,e){return this.points.forEach(n=>n.rotate(t,e)),this}translate(t,e){const n=w.create(t,e);return this.points.forEach(s=>s.translate(n.x,n.y)),this}round(t=0){return this.points.forEach(e=>e.round(t)),this}bbox(){if(this.points.length===0)return new T;let t=1/0,e=-1/0,n=1/0,s=-1/0;const r=this.points;for(let o=0,l=r.length;o<l;o+=1){const a=r[o],c=a.x,h=a.y;c<t&&(t=c),c>e&&(e=c),h<n&&(n=h),h>s&&(s=h)}return new T(t,n,e-t,s-n)}closestPoint(t){const e=this.closestPointLength(t);return this.pointAtLength(e)}closestPointLength(t){const e=this.points,n=e.length;if(n===0||n===1)return 0;let s=0,r=0,o=1/0;for(let l=0,a=n-1;l<a;l+=1){const c=new L(e[l],e[l+1]),h=c.length(),u=c.closestPointNormalizedLength(t),d=c.pointAt(u).squaredDistance(t);d<o&&(o=d,r=s+u*h),s+=h}return r}closestPointNormalizedLength(t){const e=this.length();return e===0?0:this.closestPointLength(t)/e}closestPointTangent(t){const e=this.closestPointLength(t);return this.tangentAtLength(e)}containsPoint(t){if(this.points.length===0)return!1;const e=w.clone(t),n=e.x,s=e.y,r=this.points,o=r.length;let l=o-1,a=0;for(let c=0;c<o;c+=1){const h=r[l],u=r[c];if(e.equals(h))return!0;const f=new L(h,u);if(f.containsPoint(t))return!0;if(s<=h.y&&s>u.y||s>h.y&&s<=u.y){const d=h.x-n>u.x-n?h.x-n:u.x-n;if(d>=0){const g=new w(n+d,s),p=new L(t,g);f.intersectsWithLine(p)&&(a+=1)}}l=c}return a%2===1}intersectsWithLine(t){const e=[];for(let n=0,s=this.points.length-1;n<s;n+=1){const r=this.points[n],o=this.points[n+1],l=t.intersectsWithLine(new L(r,o));l&&e.push(l)}return e.length>0?e:null}isDifferentiable(){for(let t=0,e=this.points.length-1;t<e;t+=1){const n=this.points[t],s=this.points[t+1];if(new L(n,s).isDifferentiable())return!0}return!1}length(){let t=0;for(let e=0,n=this.points.length-1;e<n;e+=1){const s=this.points[e],r=this.points[e+1];t+=s.distance(r)}return t}pointAt(t){const e=this.points,n=e.length;if(n===0)return null;if(n===1||t<=0)return e[0].clone();if(t>=1)return e[n-1].clone();const r=this.length()*t;return this.pointAtLength(r)}pointAtLength(t){const e=this.points,n=e.length;if(n===0)return null;if(n===1)return e[0].clone();let s=!0;t<0&&(s=!1,t=-t);let r=0;for(let l=0,a=n-1;l<a;l+=1){const c=s?l:a-1-l,h=e[c],u=e[c+1],f=new L(h,u),d=h.distance(u);if(t<=r+d)return f.pointAtLength((s?1:-1)*(t-r));r+=d}return(s?e[n-1]:e[0]).clone()}tangentAt(t){const n=this.points.length;if(n===0||n===1)return null;t<0&&(t=0),t>1&&(t=1);const r=this.length()*t;return this.tangentAtLength(r)}tangentAtLength(t){const e=this.points,n=e.length;if(n===0||n===1)return null;let s=!0;t<0&&(s=!1,t=-t);let r,o=0;for(let l=0,a=n-1;l<a;l+=1){const c=s?l:a-1-l,h=e[c],u=e[c+1],f=new L(h,u),d=h.distance(u);if(f.isDifferentiable()){if(t<=o+d)return f.tangentAtLength((s?1:-1)*(t-o));r=f}o+=d}if(r){const l=s?1:0;return r.tangentAt(l)}return null}simplify(t={}){const e=this.points;if(e.length<3)return this;const n=t.threshold||0;let s=0;for(;e[s+2];){const r=s,o=s+1,l=s+2,a=e[r],c=e[o],h=e[l];new L(a,h).closestPoint(c).distance(c)<=n?e.splice(o,1):s+=1}return this}toHull(){const t=this.points,e=t.length;if(e===0)return new tt;let n=t[0];for(let f=1;f<e;f+=1)(t[f].y<n.y||t[f].y===n.y&&t[f].x>n.x)&&(n=t[f]);const s=[];for(let f=0;f<e;f+=1){let d=n.theta(t[f]);d===0&&(d=360),s.push([t[f],f,d])}if(s.sort((f,d)=>{let g=f[2]-d[2];return g===0&&(g=d[1]-f[1]),g}),s.length>2){const f=s[s.length-1];s.unshift(f)}const r={},o=[],l=f=>`${f[0].toString()}@${f[1]}`;for(;s.length!==0;){const f=s.pop(),d=f[0];if(r[l(f)])continue;let g=!1;for(;!g;)if(o.length<2)o.push(f),g=!0;else{const p=o.pop(),m=p[0],b=o.pop(),x=b[0],y=x.cross(m,d);if(y<0)o.push(b),o.push(p),o.push(f),g=!0;else if(y===0){const P=m.angleBetween(x,d);Math.abs(P-180)<1e-10||m.equals(d)||x.equals(m)?(r[l(p)]=m,o.push(b)):Math.abs((P+1)%360-1)<1e-10&&(o.push(b),s.push(p))}else r[l(p)]=m,o.push(b)}}o.length>2&&o.pop();let a,c=-1;for(let f=0,d=o.length;f<d;f+=1){const g=o[f][1];(a===void 0||g<a)&&(a=g,c=f)}let h=[];if(c>0){const f=o.slice(c),d=o.slice(0,c);h=f.concat(d)}else h=o;const u=[];for(let f=0,d=h.length;f<d;f+=1)u.push(h[f][0]);return new tt(u)}equals(t){return t==null||t.points.length!==this.points.length?!1:t.points.every((e,n)=>e.equals(this.points[n]))}clone(){return new tt(this.points.map(t=>t.clone()))}toJSON(){return this.points.map(t=>t.toJSON())}serialize(){return this.points.map(t=>`${t.serialize()}`).join(" ")}}(function(i){function t(e){return e!=null&&e instanceof i}i.isPolyline=t})(tt||(tt={}));(function(i){function t(e){const n=e.trim();if(n==="")return new i;const s=[],r=n.split(/\s*,\s*|\s+/);for(let o=0,l=r.length;o<l;o+=2)s.push({x:+r[o],y:+r[o+1]});return new i(s)}i.parse=t})(tt||(tt={}));class Z extends te{constructor(t,e,n,s){super(),this.PRECISION=3,this.start=w.create(t),this.controlPoint1=w.create(e),this.controlPoint2=w.create(n),this.end=w.create(s)}bbox(){const t=this.start,e=this.controlPoint1,n=this.controlPoint2,s=this.end,r=t.x,o=t.y,l=e.x,a=e.y,c=n.x,h=n.y,u=s.x,f=s.y,d=[],g=[[],[]];let p,m,b,x,y,v,P,C;for(let S=0;S<2;S+=1){if(S===0?(m=6*r-12*l+6*c,p=-3*r+9*l-9*c+3*u,b=3*l-3*r):(m=6*o-12*a+6*h,p=-3*o+9*a-9*h+3*f,b=3*a-3*o),Math.abs(p)<1e-12){if(Math.abs(m)<1e-12)continue;x=-b/m,x>0&&x<1&&d.push(x);continue}P=m*m-4*b*p,C=Math.sqrt(P),!(P<0)&&(y=(-m+C)/(2*p),y>0&&y<1&&d.push(y),v=(-m-C)/(2*p),v>0&&v<1&&d.push(v))}let O,N,M,j=d.length;const E=j;for(;j;)j-=1,x=d[j],M=1-x,O=M*M*M*r+3*M*M*x*l+3*M*x*x*c+x*x*x*u,g[0][j]=O,N=M*M*M*o+3*M*M*x*a+3*M*x*x*h+x*x*x*f,g[1][j]=N;d[E]=0,d[E+1]=1,g[0][E]=r,g[1][E]=o,g[0][E+1]=u,g[1][E+1]=f,d.length=E+2,g[0].length=E+2,g[1].length=E+2;const D=Math.min.apply(null,g[0]),_=Math.min.apply(null,g[1]),z=Math.max.apply(null,g[0]),A=Math.max.apply(null,g[1]);return new T(D,_,z-D,A-_)}closestPoint(t,e={}){return this.pointAtT(this.closestPointT(t,e))}closestPointLength(t,e={}){const n=this.getOptions(e);return this.lengthAtT(this.closestPointT(t,n),n)}closestPointNormalizedLength(t,e={}){const n=this.getOptions(e),s=this.closestPointLength(t,n);if(!s)return 0;const r=this.length(n);return r===0?0:s/r}closestPointT(t,e={}){const n=this.getPrecision(e),s=this.getDivisions(e),r=Math.pow(10,-n);let o=null,l=0,a=0,c=0,h=0,u=0,f=null;const d=s.length;let g=d>0?1/d:0;for(s.forEach((p,m)=>{const b=p.start.distance(t),x=p.end.distance(t),y=b+x;(f==null||y<f)&&(o=p,l=m*g,a=(m+1)*g,c=b,h=x,f=y,u=p.endpointDistance())});;){const p=c?Math.abs(c-h)/c:0,m=h!=null?Math.abs(c-h)/h:0,b=p<r||m<r,x=c?c<u*r:!0,y=h?h<u*r:!0;if(b||(x||y))return c<=h?l:a;const P=o.divide(.5);g/=2;const C=P[0].start.distance(t),O=P[0].end.distance(t),N=C+O,M=P[1].start.distance(t),j=P[1].end.distance(t),E=M+j;N<=E?(o=P[0],a-=g,c=C,h=O):(o=P[1],l+=g,c=M,h=j)}}closestPointTangent(t,e={}){return this.tangentAtT(this.closestPointT(t,e))}containsPoint(t,e={}){return this.toPolyline(e).containsPoint(t)}divideAt(t,e={}){if(t<=0)return this.divideAtT(0);if(t>=1)return this.divideAtT(1);const n=this.tAt(t,e);return this.divideAtT(n)}divideAtLength(t,e={}){const n=this.tAtLength(t,e);return this.divideAtT(n)}divide(t){return this.divideAtT(t)}divideAtT(t){const e=this.start,n=this.controlPoint1,s=this.controlPoint2,r=this.end;if(t<=0)return[new Z(e,e,e,e),new Z(e,n,s,r)];if(t>=1)return[new Z(e,n,s,r),new Z(r,r,r,r)];const o=this.getSkeletonPoints(t),l=o.startControlPoint1,a=o.startControlPoint2,c=o.divider,h=o.dividerControlPoint1,u=o.dividerControlPoint2;return[new Z(e,l,a,c),new Z(c,h,u,r)]}endpointDistance(){return this.start.distance(this.end)}getSkeletonPoints(t){const e=this.start,n=this.controlPoint1,s=this.controlPoint2,r=this.end;if(t<=0)return{startControlPoint1:e.clone(),startControlPoint2:e.clone(),divider:e.clone(),dividerControlPoint1:n.clone(),dividerControlPoint2:s.clone()};if(t>=1)return{startControlPoint1:n.clone(),startControlPoint2:s.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()};const o=new L(e,n).pointAt(t),l=new L(n,s).pointAt(t),a=new L(s,r).pointAt(t),c=new L(o,l).pointAt(t),h=new L(l,a).pointAt(t),u=new L(c,h).pointAt(t);return{startControlPoint1:o,startControlPoint2:c,divider:u,dividerControlPoint1:h,dividerControlPoint2:a}}getSubdivisions(t={}){const e=this.getPrecision(t);let n=[new Z(this.start,this.controlPoint1,this.controlPoint2,this.end)];if(e===0)return n;let s=this.endpointDistance();const r=Math.pow(10,-e);let o=0;for(;;){o+=1;const l=[];n.forEach(h=>{const u=h.divide(.5);l.push(u[0],u[1])});const a=l.reduce((h,u)=>h+u.endpointDistance(),0),c=a!==0?(a-s)/a:0;if(o>1&&c<r)return l;n=l,s=a}}length(t={}){return this.getDivisions(t).reduce((n,s)=>n+s.endpointDistance(),0)}lengthAtT(t,e={}){if(t<=0)return 0;const n=e.precision===void 0?this.PRECISION:e.precision;return this.divide(t)[0].length({precision:n})}pointAt(t,e={}){if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();const n=this.tAt(t,e);return this.pointAtT(n)}pointAtLength(t,e={}){const n=this.tAtLength(t,e);return this.pointAtT(n)}pointAtT(t){return t<=0?this.start.clone():t>=1?this.end.clone():this.getSkeletonPoints(t).divider}isDifferentiable(){const t=this.start,e=this.controlPoint1,n=this.controlPoint2,s=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(s))}tangentAt(t,e={}){if(!this.isDifferentiable())return null;t<0?t=0:t>1&&(t=1);const n=this.tAt(t,e);return this.tangentAtT(n)}tangentAtLength(t,e={}){if(!this.isDifferentiable())return null;const n=this.tAtLength(t,e);return this.tangentAtT(n)}tangentAtT(t){if(!this.isDifferentiable())return null;t<0&&(t=0),t>1&&(t=1);const e=this.getSkeletonPoints(t),n=e.startControlPoint2,s=e.dividerControlPoint1,r=e.divider,o=new L(n,s);return o.translate(r.x-n.x,r.y-n.y),o}getPrecision(t={}){return t.precision==null?this.PRECISION:t.precision}getDivisions(t={}){if(t.subdivisions!=null)return t.subdivisions;const e=this.getPrecision(t);return this.getSubdivisions({precision:e})}getOptions(t={}){const e=this.getPrecision(t),n=this.getDivisions(t);return{precision:e,subdivisions:n}}tAt(t,e={}){if(t<=0)return 0;if(t>=1)return 1;const n=this.getOptions(e),r=this.length(n)*t;return this.tAtLength(r,n)}tAtLength(t,e={}){let n=!0;t<0&&(n=!1,t=-t);const s=this.getPrecision(e),r=this.getDivisions(e),o={precision:s,subdivisions:r};let l=null,a,c,h=0,u=0,f=0;const d=r.length;let g=d>0?1/d:0;for(let b=0;b<d;b+=1){const x=n?b:d-1-b,y=r[b],v=y.endpointDistance();if(t<=f+v){l=y,a=x*g,c=(x+1)*g,h=n?t-f:v+f-t,u=n?v+f-t:t-f;break}f+=v}if(l==null)return n?1:0;const p=this.length(o),m=Math.pow(10,-s);for(;;){let b;if(b=p!==0?h/p:0,b<m)return a;if(b=p!==0?u/p:0,b<m)return c;let x,y;const v=l.divide(.5);g/=2;const P=v[0].endpointDistance(),C=v[1].endpointDistance();h<=P?(l=v[0],c-=g,x=h,y=P-x):(l=v[1],a+=g,x=h-P,y=C-x),h=x,u=y}}toPoints(t={}){const e=this.getDivisions(t),n=[e[0].start.clone()];return e.forEach(s=>n.push(s.end.clone())),n}toPolyline(t={}){return new tt(this.toPoints(t))}scale(t,e,n){return this.start.scale(t,e,n),this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this}rotate(t,e){return this.start.rotate(t,e),this.controlPoint1.rotate(t,e),this.controlPoint2.rotate(t,e),this.end.rotate(t,e),this}translate(t,e){return typeof t=="number"?(this.start.translate(t,e),this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e)):(this.start.translate(t),this.controlPoint1.translate(t),this.controlPoint2.translate(t),this.end.translate(t)),this}equals(t){return t!=null&&this.start.equals(t.start)&&this.controlPoint1.equals(t.controlPoint1)&&this.controlPoint2.equals(t.controlPoint2)&&this.end.equals(t.end)}clone(){return new Z(this.start,this.controlPoint1,this.controlPoint2,this.end)}toJSON(){return{start:this.start.toJSON(),controlPoint1:this.controlPoint1.toJSON(),controlPoint2:this.controlPoint2.toJSON(),end:this.end.toJSON()}}serialize(){return[this.start.serialize(),this.controlPoint1.serialize(),this.controlPoint2.serialize(),this.end.serialize()].join(" ")}}(function(i){function t(e){return e!=null&&e instanceof i}i.isCurve=t})(Z||(Z={}));(function(i){function t(s){const r=s.length,o=[],l=[];let a=2;o[0]=s[0]/a;for(let c=1;c<r;c+=1)l[c]=1/a,a=(c<r-1?4:3.5)-l[c],o[c]=(s[c]-o[c-1])/a;for(let c=1;c<r;c+=1)o[r-c-1]-=l[r-c]*o[r-c];return o}function e(s){const r=s.map(f=>w.clone(f)),o=[],l=[],a=r.length-1;if(a===1)return o[0]=new w((2*r[0].x+r[1].x)/3,(2*r[0].y+r[1].y)/3),l[0]=new w(2*o[0].x-r[0].x,2*o[0].y-r[0].y),[o,l];const c=[];for(let f=1;f<a-1;f+=1)c[f]=4*r[f].x+2*r[f+1].x;c[0]=r[0].x+2*r[1].x,c[a-1]=(8*r[a-1].x+r[a].x)/2;const h=t(c);for(let f=1;f<a-1;f+=1)c[f]=4*r[f].y+2*r[f+1].y;c[0]=r[0].y+2*r[1].y,c[a-1]=(8*r[a-1].y+r[a].y)/2;const u=t(c);for(let f=0;f<a;f+=1)o.push(new w(h[f],u[f])),f<a-1?l.push(new w(2*r[f+1].x-h[f+1],2*r[f+1].y-u[f+1])):l.push(new w((r[a].x+h[a-1])/2,(r[a].y+u[a-1])/2));return[o,l]}function n(s){if(s==null||Array.isArray(s)&&s.length<2)throw new Error("At least 2 points are required");const r=e(s),o=[];for(let l=0,a=r[0].length;l<a;l+=1){const c=new w(r[0][l].x,r[0][l].y),h=new w(r[1][l].x,r[1][l].y);o.push(new i(s[l],c,h,s[l+1]))}return o}i.throughPoints=n})(Z||(Z={}));class Rn extends te{constructor(){super(...arguments),this.isVisible=!0,this.isSegment=!0,this.isSubpathStart=!1}get end(){return this.endPoint}get start(){if(this.previousSegment==null)throw new Error("Missing previous segment. (This segment cannot be the first segment of a path, or segment has not yet been added to a path.)");return this.previousSegment.end}closestPointT(t,e){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither `closestPointT` nor `closestPointNormalizedLength` method is implemented.")}lengthAtT(t,e){if(t<=0)return 0;const n=this.length();return t>=1?n:n*t}divideAtT(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither `divideAtT` nor `divideAt` method is implemented.")}pointAtT(t){if(this.pointAt)return this.pointAt(t);throw new Error("Neither `pointAtT` nor `pointAt` method is implemented.")}tangentAtT(t){if(this.tangentAt)return this.tangentAt(t);throw new Error("Neither `tangentAtT` nor `tangentAt` method is implemented.")}}class gt extends Rn{constructor(t,e){super(),L.isLine(t)?this.endPoint=t.end.clone().round(2):this.endPoint=w.create(t,e).round(2)}get type(){return"L"}get line(){return new L(this.start,this.end)}bbox(){return this.line.bbox()}closestPoint(t){return this.line.closestPoint(t)}closestPointLength(t){return this.line.closestPointLength(t)}closestPointNormalizedLength(t){return this.line.closestPointNormalizedLength(t)}closestPointTangent(t){return this.line.closestPointTangent(t)}length(){return this.line.length()}divideAt(t){const e=this.line.divideAt(t);return[new gt(e[0]),new gt(e[1])]}divideAtLength(t){const e=this.line.divideAtLength(t);return[new gt(e[0]),new gt(e[1])]}getSubdivisions(){return[]}pointAt(t){return this.line.pointAt(t)}pointAtLength(t){return this.line.pointAtLength(t)}tangentAt(t){return this.line.tangentAt(t)}tangentAtLength(t){return this.line.tangentAtLength(t)}isDifferentiable(){return this.previousSegment==null?!1:!this.start.equals(this.end)}clone(){return new gt(this.end)}scale(t,e,n){return this.end.scale(t,e,n),this}rotate(t,e){return this.end.rotate(t,e),this}translate(t,e){return typeof t=="number"?this.end.translate(t,e):this.end.translate(t),this}equals(t){return this.type===t.type&&this.start.equals(t.start)&&this.end.equals(t.end)}toJSON(){return{type:this.type,start:this.start.toJSON(),end:this.end.toJSON()}}serialize(){const t=this.end;return`${this.type} ${t.x} ${t.y}`}}(function(i){function t(...e){const n=e.length,s=e[0];if(L.isLine(s))return new i(s);if(w.isPointLike(s))return n===1?new i(s):e.map(o=>new i(o));if(n===2)return new i(+e[0],+e[1]);const r=[];for(let o=0;o<n;o+=2){const l=+e[o],a=+e[o+1];r.push(new i(l,a))}return r}i.create=t})(gt||(gt={}));class we extends Rn{get end(){if(!this.subpathStartSegment)throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. MoveTo), or segment has not yet been added to a path.)");return this.subpathStartSegment.end}get type(){return"Z"}get line(){return new L(this.start,this.end)}bbox(){return this.line.bbox()}closestPoint(t){return this.line.closestPoint(t)}closestPointLength(t){return this.line.closestPointLength(t)}closestPointNormalizedLength(t){return this.line.closestPointNormalizedLength(t)}closestPointTangent(t){return this.line.closestPointTangent(t)}length(){return this.line.length()}divideAt(t){const e=this.line.divideAt(t);return[e[1].isDifferentiable()?new gt(e[0]):this.clone(),new gt(e[1])]}divideAtLength(t){const e=this.line.divideAtLength(t);return[e[1].isDifferentiable()?new gt(e[0]):this.clone(),new gt(e[1])]}getSubdivisions(){return[]}pointAt(t){return this.line.pointAt(t)}pointAtLength(t){return this.line.pointAtLength(t)}tangentAt(t){return this.line.tangentAt(t)}tangentAtLength(t){return this.line.tangentAtLength(t)}isDifferentiable(){return!this.previousSegment||!this.subpathStartSegment?!1:!this.start.equals(this.end)}scale(){return this}rotate(){return this}translate(){return this}equals(t){return this.type===t.type&&this.start.equals(t.start)&&this.end.equals(t.end)}clone(){return new we}toJSON(){return{type:this.type,start:this.start.toJSON(),end:this.end.toJSON()}}serialize(){return this.type}}(function(i){function t(){return new i}i.create=t})(we||(we={}));class ve extends Rn{constructor(t,e){super(),this.isVisible=!1,this.isSubpathStart=!0,L.isLine(t)||Z.isCurve(t)?this.endPoint=t.end.clone().round(2):this.endPoint=w.create(t,e).round(2)}get start(){throw new Error("Illegal access. Moveto segments should not need a start property.")}get type(){return"M"}bbox(){return null}closestPoint(){return this.end.clone()}closestPointLength(){return 0}closestPointNormalizedLength(){return 0}closestPointT(){return 1}closestPointTangent(){return null}length(){return 0}lengthAtT(){return 0}divideAt(){return[this.clone(),this.clone()]}divideAtLength(){return[this.clone(),this.clone()]}getSubdivisions(){return[]}pointAt(){return this.end.clone()}pointAtLength(){return this.end.clone()}pointAtT(){return this.end.clone()}tangentAt(){return null}tangentAtLength(){return null}tangentAtT(){return null}isDifferentiable(){return!1}scale(t,e,n){return this.end.scale(t,e,n),this}rotate(t,e){return this.end.rotate(t,e),this}translate(t,e){return typeof t=="number"?this.end.translate(t,e):this.end.translate(t),this}clone(){return new ve(this.end)}equals(t){return this.type===t.type&&this.end.equals(t.end)}toJSON(){return{type:this.type,end:this.end.toJSON()}}serialize(){const t=this.end;return`${this.type} ${t.x} ${t.y}`}}(function(i){function t(...e){const n=e.length,s=e[0];if(L.isLine(s))return new i(s);if(Z.isCurve(s))return new i(s);if(w.isPointLike(s)){if(n===1)return new i(s);const o=[];for(let l=0;l<n;l+=1)l===0?o.push(new i(e[l])):o.push(new gt(e[l]));return o}if(n===2)return new i(+e[0],+e[1]);const r=[];for(let o=0;o<n;o+=2){const l=+e[o],a=+e[o+1];o===0?r.push(new i(l,a)):r.push(new gt(l,a))}return r}i.create=t})(ve||(ve={}));class xt extends Rn{constructor(t,e,n,s,r,o){super(),Z.isCurve(t)?(this.controlPoint1=t.controlPoint1.clone().round(2),this.controlPoint2=t.controlPoint2.clone().round(2),this.endPoint=t.end.clone().round(2)):typeof t=="number"?(this.controlPoint1=new w(t,e).round(2),this.controlPoint2=new w(n,s).round(2),this.endPoint=new w(r,o).round(2)):(this.controlPoint1=w.create(t).round(2),this.controlPoint2=w.create(e).round(2),this.endPoint=w.create(n).round(2))}get type(){return"C"}get curve(){return new Z(this.start,this.controlPoint1,this.controlPoint2,this.end)}bbox(){return this.curve.bbox()}closestPoint(t){return this.curve.closestPoint(t)}closestPointLength(t){return this.curve.closestPointLength(t)}closestPointNormalizedLength(t){return this.curve.closestPointNormalizedLength(t)}closestPointTangent(t){return this.curve.closestPointTangent(t)}length(){return this.curve.length()}divideAt(t,e={}){const n=this.curve.divideAt(t,e);return[new xt(n[0]),new xt(n[1])]}divideAtLength(t,e={}){const n=this.curve.divideAtLength(t,e);return[new xt(n[0]),new xt(n[1])]}divideAtT(t){const e=this.curve.divideAtT(t);return[new xt(e[0]),new xt(e[1])]}getSubdivisions(){return[]}pointAt(t){return this.curve.pointAt(t)}pointAtLength(t){return this.curve.pointAtLength(t)}tangentAt(t){return this.curve.tangentAt(t)}tangentAtLength(t){return this.curve.tangentAtLength(t)}isDifferentiable(){if(!this.previousSegment)return!1;const t=this.start,e=this.controlPoint1,n=this.controlPoint2,s=this.end;return!(t.equals(e)&&e.equals(n)&&n.equals(s))}scale(t,e,n){return this.controlPoint1.scale(t,e,n),this.controlPoint2.scale(t,e,n),this.end.scale(t,e,n),this}rotate(t,e){return this.controlPoint1.rotate(t,e),this.controlPoint2.rotate(t,e),this.end.rotate(t,e),this}translate(t,e){return typeof t=="number"?(this.controlPoint1.translate(t,e),this.controlPoint2.translate(t,e),this.end.translate(t,e)):(this.controlPoint1.translate(t),this.controlPoint2.translate(t),this.end.translate(t)),this}equals(t){return this.start.equals(t.start)&&this.end.equals(t.end)&&this.controlPoint1.equals(t.controlPoint1)&&this.controlPoint2.equals(t.controlPoint2)}clone(){return new xt(this.controlPoint1,this.controlPoint2,this.end)}toJSON(){return{type:this.type,start:this.start.toJSON(),controlPoint1:this.controlPoint1.toJSON(),controlPoint2:this.controlPoint2.toJSON(),end:this.end.toJSON()}}serialize(){const t=this.controlPoint1,e=this.controlPoint2,n=this.end;return[this.type,t.x,t.y,e.x,e.y,n.x,n.y].join(" ")}}(function(i){function t(...e){const n=e.length,s=e[0];if(Z.isCurve(s))return new i(s);if(w.isPointLike(s)){if(n===3)return new i(e[0],e[1],e[2]);const o=[];for(let l=0;l<n;l+=3)o.push(new i(e[l],e[l+1],e[l+2]));return o}if(n===6)return new i(e[0],e[1],e[2],e[3],e[4],e[5]);const r=[];for(let o=0;o<n;o+=6)r.push(new i(e[o],e[o+1],e[o+2],e[o+3],e[o+4],e[o+5]));return r}i.create=t})(xt||(xt={}));function dn(i,t,e){return{x:i*Math.cos(e)-t*Math.sin(e),y:i*Math.sin(e)+t*Math.cos(e)}}function ei(i,t,e,n,s,r){const o=.3333333333333333,l=2/3;return[o*i+l*e,o*t+l*n,o*s+l*e,o*r+l*n,s,r]}function cr(i,t,e,n,s,r,o,l,a,c){const h=Math.PI*120/180,u=Math.PI/180*(+s||0);let f=[],d,g,p,m,b;if(c)g=c[0],p=c[1],m=c[2],b=c[3];else{d=dn(i,t,-u),i=d.x,t=d.y,d=dn(l,a,-u),l=d.x,a=d.y;const z=(i-l)/2,A=(t-a)/2;let S=z*z/(e*e)+A*A/(n*n);S>1&&(S=Math.sqrt(S),e=S*e,n=S*n);const $=e*e,J=n*n,Y=(r===o?-1:1)*Math.sqrt(Math.abs(($*J-$*A*A-J*z*z)/($*A*A+J*z*z)));m=Y*e*A/n+(i+l)/2,b=Y*-n*z/e+(t+a)/2,g=Math.asin((t-b)/n),p=Math.asin((a-b)/n),g=i<m?Math.PI-g:g,p=l<m?Math.PI-p:p,g<0&&(g=Math.PI*2+g),p<0&&(p=Math.PI*2+p),o&&g>p&&(g-=Math.PI*2),!o&&p>g&&(p-=Math.PI*2)}let x=p-g;if(Math.abs(x)>h){const z=p,A=l,S=a;p=g+h*(o&&p>g?1:-1),l=m+e*Math.cos(p),a=b+n*Math.sin(p),f=cr(l,a,e,n,s,0,o,A,S,[p,z,m,b])}x=p-g;const y=Math.cos(g),v=Math.sin(g),P=Math.cos(p),C=Math.sin(p),O=Math.tan(x/4),N=4/3*(e*O),M=4/3*(n*O),j=[i,t],E=[i+N*v,t-M*y],D=[l+N*C,a-M*P],_=[l,a];if(E[0]=2*j[0]-E[0],E[1]=2*j[1]-E[1],c)return[E,D,_].concat(f);{f=[E,D,_].concat(f).join().split(",");const z=[],A=f.length;for(let S=0;S<A;S+=1)z[S]=S%2?dn(+f[S-1],+f[S],u).y:dn(+f[S],+f[S+1],u).x;return z}}function Oa(i){if(!i)return null;const t=`
\v\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029`,e=new RegExp(`([a-z])[${t},]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[${t}]*,?[${t}]*)+)`,"ig"),n=new RegExp(`(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[${t}]*,?[${t}]*`,"ig"),s={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=[];return i.replace(e,(o,l,a)=>{const c=[];let h=l.toLowerCase();a.replace(n,(f,d)=>(d&&c.push(+d),f)),h==="m"&&c.length>2&&(r.push([l,...c.splice(0,2)]),h="l",l=l==="m"?"l":"L");const u=s[h];for(;c.length>=u&&(r.push([l,...c.splice(0,u)]),!!u););return o}),r}function Ma(i){const t=Oa(i);if(!t||!t.length)return[["M",0,0]];let e=0,n=0,s=0,r=0;const o=[];for(let l=0,a=t.length;l<a;l+=1){const c=[];o.push(c);const h=t[l],u=h[0];if(u!==u.toUpperCase())switch(c[0]=u.toUpperCase(),c[0]){case"A":c[1]=h[1],c[2]=h[2],c[3]=h[3],c[4]=h[4],c[5]=h[5],c[6]=+h[6]+e,c[7]=+h[7]+n;break;case"V":c[1]=+h[1]+n;break;case"H":c[1]=+h[1]+e;break;case"M":s=+h[1]+e,r=+h[2]+n;for(let f=1,d=h.length;f<d;f+=1)c[f]=+h[f]+(f%2?e:n);break;default:for(let f=1,d=h.length;f<d;f+=1)c[f]=+h[f]+(f%2?e:n);break}else for(let f=0,d=h.length;f<d;f+=1)c[f]=h[f];switch(c[0]){case"Z":e=+s,n=+r;break;case"H":e=c[1];break;case"V":n=c[1];break;case"M":s=c[c.length-2],r=c[c.length-1],e=c[c.length-2],n=c[c.length-1];break;default:e=c[c.length-2],n=c[c.length-1];break}}return o}function Ea(i){const t=Ma(i),e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function n(a,c,h){let u,f;if(!a)return["C",c.x,c.y,c.x,c.y,c.x,c.y];switch(a[0]in{T:1,Q:1}||(c.qx=null,c.qy=null),a[0]){case"M":c.X=a[1],c.Y=a[2];break;case"A":return parseFloat(a[1])===0||parseFloat(a[2])===0?["L",a[6],a[7]]:["C"].concat(cr.apply(0,[c.x,c.y].concat(a.slice(1))));case"S":return h==="C"||h==="S"?(u=c.x*2-c.bx,f=c.y*2-c.by):(u=c.x,f=c.y),["C",u,f].concat(a.slice(1));case"T":return h==="Q"||h==="T"?(c.qx=c.x*2-c.qx,c.qy=c.y*2-c.qy):(c.qx=c.x,c.qy=c.y),["C"].concat(ei(c.x,c.y,c.qx,c.qy,a[1],a[2]));case"Q":return c.qx=a[1],c.qy=a[2],["C"].concat(ei(c.x,c.y,a[1],a[2],a[3],a[4]));case"H":return["L"].concat(a[1],c.y);case"V":return["L"].concat(c.x,a[1])}return a}function s(a,c){if(a[c].length>7){a[c].shift();const h=a[c];for(;h.length;)r[c]="A",c+=1,a.splice(c,0,["C"].concat(h.splice(0,6)));a.splice(c,1),l=t.length}}const r=[];let o="",l=t.length;for(let a=0;a<l;a+=1){let c="";t[a]&&(c=t[a][0]),c!=="C"&&(r[a]=c,a>0&&(o=r[a-1])),t[a]=n(t[a],e,o),r[a]!=="A"&&c==="C"&&(r[a]="C"),s(t,a);const h=t[a],u=h.length;e.x=h[u-2],e.y=h[u-1],e.bx=parseFloat(h[u-4])||e.x,e.by=parseFloat(h[u-3])||e.y}return(!t[0][0]||t[0][0]!=="M")&&t.unshift(["M",0,0]),t}function Ta(i){return Ea(i).map(t=>t.map(e=>typeof e=="string"?e:H.round(e,2))).join(",").split(",").join(" ")}class k extends te{constructor(t){if(super(),this.PRECISION=3,this.segments=[],Array.isArray(t))if(L.isLine(t[0])||Z.isCurve(t[0])){let e=null;t.forEach((s,r)=>{r===0&&this.appendSegment(k.createSegment("M",s.start)),e!=null&&!e.end.equals(s.start)&&this.appendSegment(k.createSegment("M",s.start)),L.isLine(s)?this.appendSegment(k.createSegment("L",s.end)):Z.isCurve(s)&&this.appendSegment(k.createSegment("C",s.controlPoint1,s.controlPoint2,s.end)),e=s})}else t.forEach(n=>{n.isSegment&&this.appendSegment(n)});else t!=null&&(L.isLine(t)?(this.appendSegment(k.createSegment("M",t.start)),this.appendSegment(k.createSegment("L",t.end))):Z.isCurve(t)?(this.appendSegment(k.createSegment("M",t.start)),this.appendSegment(k.createSegment("C",t.controlPoint1,t.controlPoint2,t.end))):tt.isPolyline(t)?t.points&&t.points.length&&t.points.forEach((e,n)=>{const s=n===0?k.createSegment("M",e):k.createSegment("L",e);this.appendSegment(s)}):t.isSegment&&this.appendSegment(t))}get start(){const t=this.segments,e=t.length;if(e===0)return null;for(let n=0;n<e;n+=1){const s=t[n];if(s.isVisible)return s.start}return t[e-1].end}get end(){const t=this.segments,e=t.length;if(e===0)return null;for(let n=e-1;n>=0;n-=1){const s=t[n];if(s.isVisible)return s.end}return t[e-1].end}moveTo(...t){return this.appendSegment(ve.create.call(null,...t))}lineTo(...t){return this.appendSegment(gt.create.call(null,...t))}curveTo(...t){return this.appendSegment(xt.create.call(null,...t))}arcTo(t,e,n,s,r,o,l){const a=this.end||new w,c=typeof o=="number"?Sn(a.x,a.y,t,e,n,s,r,o,l):Sn(a.x,a.y,t,e,n,s,r,o.x,o.y);if(c!=null)for(let h=0,u=c.length;h<u;h+=6)this.curveTo(c[h],c[h+1],c[h+2],c[h+3],c[h+4],c[h+5]);return this}quadTo(t,e,n,s){const r=this.end||new w,o=["M",r.x,r.y];if(typeof t=="number")o.push("Q",t,e,n,s);else{const a=e;o.push("Q",t.x,t.y,a.x,a.y)}const l=k.parse(o.join(" "));return this.appendSegment(l.segments.slice(1)),this}close(){return this.appendSegment(we.create())}drawPoints(t,e={}){const n=ar(t,e),s=k.parse(n);s&&s.segments&&this.appendSegment(s.segments)}bbox(){const t=this.segments,e=t.length;if(e===0)return null;let n;for(let r=0;r<e;r+=1){const o=t[r];if(o.isVisible){const l=o.bbox();l!=null&&(n=n?n.union(l):l)}}if(n!=null)return n;const s=t[e-1];return new T(s.end.x,s.end.y,0,0)}appendSegment(t){const e=this.segments.length;let n=e!==0?this.segments[e-1]:null,s;const r=null;if(Array.isArray(t))for(let o=0,l=t.length;o<l;o+=1){const a=t[o];s=this.prepareSegment(a,n,r),this.segments.push(s),n=s}else t!=null&&t.isSegment&&(s=this.prepareSegment(t,n,r),this.segments.push(s));return this}insertSegment(t,e){const n=this.segments.length;if(t<0&&(t=n+t+1),t>n||t<0)throw new Error("Index out of range.");let s,r=null,o=null;if(n!==0&&(t>=1?(r=this.segments[t-1],o=r.nextSegment):(r=null,o=this.segments[0])),!Array.isArray(e))s=this.prepareSegment(e,r,o),this.segments.splice(t,0,s);else for(let l=0,a=e.length;l<a;l+=1){const c=e[l];s=this.prepareSegment(c,r,o),this.segments.splice(t+l,0,s),r=s}return this}removeSegment(t){const e=this.fixIndex(t),n=this.segments.splice(e,1)[0],s=n.previousSegment,r=n.nextSegment;return s&&(s.nextSegment=r),r&&(r.previousSegment=s),n.isSubpathStart&&r&&this.updateSubpathStartSegment(r),n}replaceSegment(t,e){const n=this.fixIndex(t);let s;const r=this.segments[n];let o=r.previousSegment;const l=r.nextSegment;let a=r.isSubpathStart;if(!Array.isArray(e))s=this.prepareSegment(e,o,l),this.segments.splice(n,1,s),a&&s.isSubpathStart&&(a=!1);else{this.segments.splice(t,1);for(let c=0,h=e.length;c<h;c+=1){const u=e[c];s=this.prepareSegment(u,o,l),this.segments.splice(t+c,0,s),o=s,a&&s.isSubpathStart&&(a=!1)}}a&&l&&this.updateSubpathStartSegment(l)}getSegment(t){const e=this.fixIndex(t);return this.segments[e]}fixIndex(t){const e=this.segments.length;if(e===0)throw new Error("Path has no segments.");let n=t;for(;n<0;)n=e+n;if(n>=e||n<0)throw new Error("Index out of range.");return n}segmentAt(t,e={}){const n=this.segmentIndexAt(t,e);return n?this.getSegment(n):null}segmentAtLength(t,e={}){const n=this.segmentIndexAtLength(t,e);return n?this.getSegment(n):null}segmentIndexAt(t,e={}){if(this.segments.length===0)return null;const n=H.clamp(t,0,1),s=this.getOptions(e),o=this.length(s)*n;return this.segmentIndexAtLength(o,s)}segmentIndexAtLength(t,e={}){const n=this.segments.length;if(n===0)return null;let s=!0;t<0&&(s=!1,t=-t);const r=this.getPrecision(e),o=this.getSubdivisions(e);let l=0,a=null;for(let c=0;c<n;c+=1){const h=s?c:n-1-c,u=this.segments[h],f=o[h],d=u.length({precision:r,subdivisions:f});if(u.isVisible){if(t<=l+d)return h;a=h}l+=d}return a}getSegmentSubdivisions(t={}){const e=this.getPrecision(t),n=[];for(let s=0,r=this.segments.length;s<r;s+=1){const l=this.segments[s].getSubdivisions({precision:e});n.push(l)}return n}updateSubpathStartSegment(t){let e=t.previousSegment,n=t;for(;n&&!n.isSubpathStart;)e!=null?n.subpathStartSegment=e.subpathStartSegment:n.subpathStartSegment=null,e=n,n=n.nextSegment}prepareSegment(t,e,n){t.previousSegment=e,t.nextSegment=n,e!=null&&(e.nextSegment=t),n!=null&&(n.previousSegment=t);let s=t;return t.isSubpathStart&&(t.subpathStartSegment=t,s=n),s!=null&&this.updateSubpathStartSegment(s),t}closestPoint(t,e={}){const n=this.closestPointT(t,e);return n?this.pointAtT(n):null}closestPointLength(t,e={}){const n=this.getOptions(e),s=this.closestPointT(t,n);return s?this.lengthAtT(s,n):0}closestPointNormalizedLength(t,e={}){const n=this.getOptions(e),s=this.closestPointLength(t,n);if(s===0)return 0;const r=this.length(n);return r===0?0:s/r}closestPointT(t,e={}){if(this.segments.length===0)return null;const n=this.getPrecision(e),s=this.getSubdivisions(e);let r,o=1/0;for(let l=0,a=this.segments.length;l<a;l+=1){const c=this.segments[l],h=s[l];if(c.isVisible){const u=c.closestPointT(t,{precision:n,subdivisions:h}),f=c.pointAtT(u),d=H.squaredLength(f,t);d<o&&(r={segmentIndex:l,value:u},o=d)}}return r||{segmentIndex:this.segments.length-1,value:1}}closestPointTangent(t,e={}){if(this.segments.length===0)return null;const n=this.getPrecision(e),s=this.getSubdivisions(e);let r,o=1/0;for(let l=0,a=this.segments.length;l<a;l+=1){const c=this.segments[l],h=s[l];if(c.isDifferentiable()){const u=c.closestPointT(t,{precision:n,subdivisions:h}),f=c.pointAtT(u),d=H.squaredLength(f,t);d<o&&(r=c.tangentAtT(u),o=d)}}return r||null}containsPoint(t,e={}){const n=this.toPolylines(e);if(!n)return!1;let s=0;for(let r=0,o=n.length;r<o;r+=1)n[r].containsPoint(t)&&(s+=1);return s%2===1}pointAt(t,e={}){if(this.segments.length===0)return null;if(t<=0)return this.start.clone();if(t>=1)return this.end.clone();const n=this.getOptions(e),r=this.length(n)*t;return this.pointAtLength(r,n)}pointAtLength(t,e={}){if(this.segments.length===0)return null;if(t===0)return this.start.clone();let n=!0;t<0&&(n=!1,t=-t);const s=this.getPrecision(e),r=this.getSubdivisions(e);let o,l=0;for(let c=0,h=this.segments.length;c<h;c+=1){const u=n?c:h-1-c,f=this.segments[u],d=r[u],g=f.length({precision:s,subdivisions:d});if(f.isVisible){if(t<=l+g)return f.pointAtLength((n?1:-1)*(t-l),{precision:s,subdivisions:d});o=f}l+=g}return o?n?o.end:o.start:this.segments[this.segments.length-1].end.clone()}pointAtT(t){const e=this.segments,n=e.length;if(n===0)return null;const s=t.segmentIndex;if(s<0)return e[0].pointAtT(0);if(s>=n)return e[n-1].pointAtT(1);const r=H.clamp(t.value,0,1);return e[s].pointAtT(r)}divideAt(t,e={}){if(this.segments.length===0)return null;const n=H.clamp(t,0,1),s=this.getOptions(e),o=this.length(s)*n;return this.divideAtLength(o,s)}divideAtLength(t,e={}){if(this.segments.length===0)return null;let n=!0;t<0&&(n=!1,t=-t);const s=this.getPrecision(e),r=this.getSubdivisions(e);let o=0,l,a,c,h,u;for(let P=0,C=this.segments.length;P<C;P+=1){const O=n?P:C-1-P,N=this.getSegment(O),M=r[O],j={precision:s,subdivisions:M},E=N.length(j);if(N.isDifferentiable()&&(c=N,h=O,t<=o+E)){a=O,l=N.divideAtLength((n?1:-1)*(t-o),j);break}o+=E}if(!c)return null;l||(a=h,u=n?1:0,l=c.divideAtT(u));const f=this.clone(),d=a;f.replaceSegment(d,l);const g=d;let p=d+1,m=d+2;l[0].isDifferentiable()||(f.removeSegment(g),p-=1,m-=1);const b=f.getSegment(p).start;f.insertSegment(p,k.createSegment("M",b)),m+=1,l[1].isDifferentiable()||(f.removeSegment(m-1),m-=1);const x=m-g-1;for(let P=m,C=f.segments.length;P<C;P+=1){const O=this.getSegment(P-x),N=f.getSegment(P);if(N.type==="Z"&&!O.subpathStartSegment.end.equals(N.subpathStartSegment.end)){const M=k.createSegment("L",O.end);f.replaceSegment(P,M)}}const y=new k(f.segments.slice(0,p)),v=new k(f.segments.slice(p));return[y,v]}intersectsWithLine(t,e={}){const n=this.toPolylines(e);if(n==null)return null;let s=null;for(let r=0,o=n.length;r<o;r+=1){const l=n[r],a=t.intersect(l);a&&(s==null&&(s=[]),Array.isArray(a)?s.push(...a):s.push(a))}return s}isDifferentiable(){for(let t=0,e=this.segments.length;t<e;t+=1)if(this.segments[t].isDifferentiable())return!0;return!1}isValid(){const t=this.segments;return t.length===0||t[0].type==="M"}length(t={}){if(this.segments.length===0)return 0;const e=this.getSubdivisions(t);let n=0;for(let s=0,r=this.segments.length;s<r;s+=1){const o=this.segments[s],l=e[s];n+=o.length({subdivisions:l})}return n}lengthAtT(t,e={}){const n=this.segments.length;if(n===0)return 0;let s=t.segmentIndex;if(s<0)return 0;let r=H.clamp(t.value,0,1);s>=n&&(s=n-1,r=1);const o=this.getPrecision(e),l=this.getSubdivisions(e);let a=0;for(let u=0;u<s;u+=1){const f=this.segments[u],d=l[u];a+=f.length({precision:o,subdivisions:d})}const c=this.segments[s],h=l[s];return a+=c.lengthAtT(r,{precision:o,subdivisions:h}),a}tangentAt(t,e={}){if(this.segments.length===0)return null;const n=H.clamp(t,0,1),s=this.getOptions(e),o=this.length(s)*n;return this.tangentAtLength(o,s)}tangentAtLength(t,e={}){if(this.segments.length===0)return null;let n=!0;t<0&&(n=!1,t=-t);const s=this.getPrecision(e),r=this.getSubdivisions(e);let o,l=0;for(let a=0,c=this.segments.length;a<c;a+=1){const h=n?a:c-1-a,u=this.segments[h],f=r[h],d=u.length({precision:s,subdivisions:f});if(u.isDifferentiable()){if(t<=l+d)return u.tangentAtLength((n?1:-1)*(t-l),{precision:s,subdivisions:f});o=u}l+=d}if(o){const a=n?1:0;return o.tangentAtT(a)}return null}tangentAtT(t){const e=this.segments.length;if(e===0)return null;const n=t.segmentIndex;if(n<0)return this.segments[0].tangentAtT(0);if(n>=e)return this.segments[e-1].tangentAtT(1);const s=H.clamp(t.value,0,1);return this.segments[n].tangentAtT(s)}getPrecision(t={}){return t.precision==null?this.PRECISION:t.precision}getSubdivisions(t={}){if(t.segmentSubdivisions==null){const e=this.getPrecision(t);return this.getSegmentSubdivisions({precision:e})}return t.segmentSubdivisions}getOptions(t={}){const e=this.getPrecision(t),n=this.getSubdivisions(t);return{precision:e,segmentSubdivisions:n}}toPoints(t={}){const e=this.segments,n=e.length;if(n===0)return null;const s=this.getSubdivisions(t),r=[];let o=[];for(let l=0;l<n;l+=1){const a=e[l];if(a.isVisible){const c=s[l];c.length>0?c.forEach(h=>o.push(h.start)):o.push(a.start)}else o.length>0&&(o.push(e[l-1].end),r.push(o),o=[])}return o.length>0&&(o.push(this.end),r.push(o)),r}toPolylines(t={}){const e=this.toPoints(t);return e?e.map(n=>new tt(n)):null}scale(t,e,n){return this.segments.forEach(s=>s.scale(t,e,n)),this}rotate(t,e){return this.segments.forEach(n=>n.rotate(t,e)),this}translate(t,e){return typeof t=="number"?this.segments.forEach(n=>n.translate(t,e)):this.segments.forEach(n=>n.translate(t)),this}clone(){const t=new k;return this.segments.forEach(e=>t.appendSegment(e.clone())),t}equals(t){if(t==null)return!1;const e=this.segments,n=t.segments,s=e.length;if(n.length!==s)return!1;for(let r=0;r<s;r+=1){const o=e[r],l=n[r];if(o.type!==l.type||!o.equals(l))return!1}return!0}toJSON(){return this.segments.map(t=>t.toJSON())}serialize(){if(!this.isValid())throw new Error("Invalid path segments.");return this.segments.map(t=>t.serialize()).join(" ")}toString(){return this.serialize()}}(function(i){function t(e){return e!=null&&e instanceof i}i.isPath=t})(k||(k={}));(function(i){function t(n){if(!n)return new i;const s=new i,r=/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g,o=i.normalize(n).match(r);if(o!=null)for(let l=0,a=o.length;l<a;l+=1){const c=o[l],h=/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g,u=c.match(h);if(u!=null){const f=u[0],d=u.slice(1).map(p=>+p),g=e.call(null,f,...d);s.appendSegment(g)}}return s}i.parse=t;function e(n,...s){if(n==="M")return ve.create.call(null,...s);if(n==="L")return gt.create.call(null,...s);if(n==="C")return xt.create.call(null,...s);if(n==="z"||n==="Z")return we.create();throw new Error(`Invalid path segment type "${n}"`)}i.createSegment=e})(k||(k={}));(function(i){i.normalize=Ta,i.isValid=Ca,i.drawArc=Sa,i.drawPoints=ar,i.arcToCurves=Sn})(k||(k={}));class nt{constructor(t){this.options=Object.assign({},t),this.data=this.options.data||{},this.register=this.register.bind(this),this.unregister=this.unregister.bind(this)}get names(){return Object.keys(this.data)}register(t,e,n=!1){if(typeof t=="object"){Object.entries(t).forEach(([o,l])=>{this.register(o,l,e)});return}this.exist(t)&&!n&&!Xt.isApplyingHMR()&&this.onDuplicated(t);const s=this.options.process,r=s?R(s,this,t,e):e;return this.data[t]=r,r}unregister(t){const e=t?this.data[t]:null;return delete this.data[t],e}get(t){return t?this.data[t]:null}exist(t){return t?this.data[t]!=null:!1}onDuplicated(t){try{throw this.options.onConflict&&R(this.options.onConflict,this,t),new Error(`${bn(this.options.type)} with name '${t}' already registered.`)}catch(e){throw e}}onNotFound(t,e){throw new Error(this.getSpellingSuggestion(t,e))}getSpellingSuggestion(t,e){const n=this.getSpellingSuggestionForName(t),s=e?`${e} ${tl(this.options.type)}`:this.options.type;return`${bn(s)} with name '${t}' does not exist.${n?` Did you mean '${n}'?`:""}`}getSpellingSuggestionForName(t){return Tl(t,Object.keys(this.data),e=>e)}}(function(i){function t(e){return new i(e)}i.create=t})(nt||(nt={}));const Na={color:"#aaaaaa",thickness:1,markup:"rect",update(i,t){const e=t.thickness*t.sx,n=t.thickness*t.sy;G(i,{width:e,height:n,rx:e,ry:n,fill:t.color})}},La={color:"#aaaaaa",thickness:1,markup:"rect",update(i,t){const e=t.sx<=1?t.thickness*t.sx:t.thickness;G(i,{width:e,height:e,rx:e,ry:e,fill:t.color})}},ja={color:"rgba(224,224,224,1)",thickness:1,markup:"path",update(i,t){let e;const n=t.width,s=t.height,r=t.thickness;n-r>=0&&s-r>=0?e=["M",n,0,"H0 M0 0 V0",s].join(" "):e="M 0 0 0 0",G(i,{d:e,stroke:t.color,"stroke-width":t.thickness})}},ka=[{color:"rgba(224,224,224,1)",thickness:1,markup:"path",update(i,t){let e;const n=t.width,s=t.height,r=t.thickness;n-r>=0&&s-r>=0?e=["M",n,0,"H0 M0 0 V0",s].join(" "):e="M 0 0 0 0",G(i,{d:e,stroke:t.color,"stroke-width":t.thickness})}},{color:"rgba(224,224,224,0.2)",thickness:3,factor:4,markup:"path",update(i,t){let e;const n=t.factor||1,s=t.width*n,r=t.height*n,o=t.thickness;s-o>=0&&r-o>=0?e=["M",s,0,"H0 M0 0 V0",r].join(" "):e="M 0 0 0 0",t.width=s,t.height=r,G(i,{d:e,stroke:t.color,"stroke-width":t.thickness})}}],Da=Object.freeze(Object.defineProperty({__proto__:null,dot:Na,doubleMesh:ka,fixedDot:La,mesh:ja},Symbol.toStringTag,{value:"Module"}));class Ut{constructor(){this.patterns={},this.root=I.create(wn(),{width:"100%",height:"100%"},[Ft("defs")]).node}add(t,e){const n=this.root.childNodes[0];n&&n.appendChild(e),this.patterns[t]=e,I.create("rect",{width:"100%",height:"100%",fill:`url(#${t})`}).appendTo(this.root)}get(t){return this.patterns[t]}has(t){return this.patterns[t]!=null}}(function(i){i.presets=Da,i.registry=nt.create({type:"grid"}),i.registry.register(i.presets,!0)})(Ut||(Ut={}));const hr=function(i){const t=document.createElement("canvas"),e=i.width,n=i.height;t.width=e*2,t.height=n;const s=t.getContext("2d");return s.drawImage(i,0,0,e,n),s.translate(2*e,0),s.scale(-1,1),s.drawImage(i,0,0,e,n),t},ur=function(i){const t=document.createElement("canvas"),e=i.width,n=i.height;t.width=e,t.height=n*2;const s=t.getContext("2d");return s.drawImage(i,0,0,e,n),s.translate(0,2*n),s.scale(1,-1),s.drawImage(i,0,0,e,n),t},fr=function(i){const t=document.createElement("canvas"),e=i.width,n=i.height;t.width=2*e,t.height=2*n;const s=t.getContext("2d");return s.drawImage(i,0,0,e,n),s.setTransform(-1,0,0,-1,t.width,t.height),s.drawImage(i,0,0,e,n),s.setTransform(-1,0,0,1,t.width,0),s.drawImage(i,0,0,e,n),s.setTransform(1,0,0,-1,0,t.height),s.drawImage(i,0,0,e,n),t},Ia=function(i,t){const e=i.width,n=i.height,s=document.createElement("canvas");s.width=e*3,s.height=n*3;const r=s.getContext("2d"),o=t.angle!=null?-t.angle:-20,l=U.toRad(o),a=s.width/4,c=s.height/4;for(let h=0;h<4;h+=1)for(let u=0;u<4;u+=1)(h+u)%2>0&&(r.setTransform(1,0,0,1,(2*h-1)*a,(2*u-1)*c),r.rotate(l),r.drawImage(i,-e/2,-n/2,e,n));return s},Ra=Object.freeze(Object.defineProperty({__proto__:null,flipX:hr,flipXY:fr,flipY:ur,watermark:Ia},Symbol.toStringTag,{value:"Module"}));var Ye;(function(i){i.presets=Object.assign({},Ra),i.presets["flip-x"]=hr,i.presets["flip-y"]=ur,i.presets["flip-xy"]=fr,i.registry=nt.create({type:"background pattern"}),i.registry.register(i.presets,!0)})(Ye||(Ye={}));function Ss(i,t){return i!=null?i:t}function ct(i,t){return i!=null&&Number.isFinite(i)?i:t}function Ba(i={}){const t=Ss(i.color,"blue"),e=ct(i.width,1),n=ct(i.margin,2),s=ct(i.opacity,1),r=n,o=n+e;return`
<filter>
<feFlood flood-color="${t}" flood-opacity="${s}" result="colored"/>
<feMorphology in="SourceAlpha" result="morphedOuter" operator="dilate" radius="${o}" />
<feMorphology in="SourceAlpha" result="morphedInner" operator="dilate" radius="${r}" />
<feComposite result="morphedOuterColored" in="colored" in2="morphedOuter" operator="in"/>
<feComposite operator="xor" in="morphedOuterColored" in2="morphedInner" result="outline"/>
<feMerge>
<feMergeNode in="outline"/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>
`.trim()}function $a(i={}){const t=Ss(i.color,"red"),e=ct(i.blur,0),n=ct(i.width,1),s=ct(i.opacity,1);return`
<filter>
<feFlood flood-color="${t}" flood-opacity="${s}" result="colored"/>
<feMorphology result="morphed" in="SourceGraphic" operator="dilate" radius="${n}"/>
<feComposite result="composed" in="colored" in2="morphed" operator="in"/>
<feGaussianBlur result="blured" in="composed" stdDeviation="${e}"/>
<feBlend in="SourceGraphic" in2="blured" mode="normal"/>
</filter>
`.trim()}function Va(i={}){const t=ct(i.x,2);return`
<filter>
<feGaussianBlur stdDeviation="${i.y!=null&&Number.isFinite(i.y)?[t,i.y]:t}"/>
</filter>
`.trim()}function za(i={}){const t=ct(i.dx,0),e=ct(i.dy,0),n=Ss(i.color,"black"),s=ct(i.blur,4),r=ct(i.opacity,1);return"SVGFEDropShadowElement"in window?`<filter>
<feDropShadow stdDeviation="${s}" dx="${t}" dy="${e}" flood-color="${n}" flood-opacity="${r}" />
</filter>`.trim():`<filter>
<feGaussianBlur in="SourceAlpha" stdDeviation="${s}" />
<feOffset dx="${t}" dy="${e}" result="offsetblur" />
<feFlood flood-color="${n}" />
<feComposite in2="offsetblur" operator="in" />
<feComponentTransfer>
<feFuncA type="linear" slope="${r}" />
</feComponentTransfer>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
</feMerge>
</filter>`.trim()}function Fa(i={}){const t=ct(i.amount,1),e=.2126+.7874*(1-t),n=.7152-.7152*(1-t),s=.0722-.0722*(1-t),r=.2126-.2126*(1-t),o=.7152+.2848*(1-t),l=.0722-.0722*(1-t),a=.2126-.2126*(1-t),c=.0722+.9278*(1-t);return`
<filter>
<feColorMatrix type="matrix" values="${e} ${n} ${s} 0 0 ${r} ${o} ${l} 0 0 ${a} ${n} ${c} 0 0 0 0 0 1 0"/>
</filter>
`.trim()}function qa(i={}){const t=ct(i.amount,1),e=.393+.607*(1-t),n=.769-.769*(1-t),s=.189-.189*(1-t),r=.349-.349*(1-t),o=.686+.314*(1-t),l=.168-.168*(1-t),a=.272-.272*(1-t),c=.534-.534*(1-t),h=.131+.869*(1-t);return`
<filter>
<feColorMatrix type="matrix" values="${e} ${n} ${s} 0 0 ${r} ${o} ${l} 0 0 ${a} ${c} ${h} 0 0 0 0 0 1 0"/>
</filter>
`.trim()}function Ha(i={}){return`
<filter>
<feColorMatrix type="saturate" values="${1-ct(i.amount,1)}"/>
</filter>
`.trim()}function Ga(i={}){return`
<filter>
<feColorMatrix type="hueRotate" values="${ct(i.angle,0)}"/>
</filter>
`.trim()}function _a(i={}){const t=ct(i.amount,1),e=1-t;return`
<filter>
<feComponentTransfer>
<feFuncR type="table" tableValues="${t} ${e}"/>
<feFuncG type="table" tableValues="${t} ${e}"/>
<feFuncB type="table" tableValues="${t} ${e}"/>
</feComponentTransfer>
</filter>
`.trim()}function Ua(i={}){const t=ct(i.amount,1);return`
<filter>
<feComponentTransfer>
<feFuncR type="linear" slope="${t}"/>
<feFuncG type="linear" slope="${t}"/>
<feFuncB type="linear" slope="${t}"/>
</feComponentTransfer>
</filter>
`.trim()}function Wa(i={}){const t=ct(i.amount,1),e=.5-t/2;return`
<filter>
<feComponentTransfer>
<feFuncR type="linear" slope="${t}" intercept="${e}"/>
<feFuncG type="linear" slope="${t}" intercept="${e}"/>
<feFuncB type="linear" slope="${t}" intercept="${e}"/>
</feComponentTransfer>
</filter>
`.trim()}const Xa=Object.freeze(Object.defineProperty({__proto__:null,blur:Va,brightness:Ua,contrast:Wa,dropShadow:za,grayScale:Fa,highlight:$a,hueRotate:Ga,invert:_a,outline:Ba,saturate:Ha,sepia:qa},Symbol.toStringTag,{value:"Module"}));var Pe;(function(i){i.presets=Xa,i.registry=nt.create({type:"filter"}),i.registry.register(i.presets,!0)})(Pe||(Pe={}));const Ja={xlinkHref:"xlink:href",xlinkShow:"xlink:show",xlinkRole:"xlink:role",xlinkType:"xlink:type",xlinkArcrole:"xlink:arcrole",xlinkTitle:"xlink:title",xlinkActuate:"xlink:actuate",xmlSpace:"xml:space",xmlBase:"xml:base",xmlLang:"xml:lang",preserveAspectRatio:"preserveAspectRatio",requiredExtension:"requiredExtension",requiredFeatures:"requiredFeatures",systemLanguage:"systemLanguage",externalResourcesRequired:"externalResourceRequired"},Ya={},dr={position:Bn("x","width","origin")},gr={position:Bn("y","height","origin")},Za={position:Bn("x","width","corner")},Ka={position:Bn("y","height","corner")},pr={set:Yt("width","width")},mr={set:Yt("height","height")},Qa={set:Yt("rx","width")},tc={set:Yt("ry","height")},yr={set:(i=>{const t=Yt(i,"width"),e=Yt(i,"height");return function(n,s){const r=s.refBBox,o=r.height>r.width?t:e;return R(o,this,n,s)}})("r")},ec={set(i,{refBBox:t}){let e=parseFloat(i);const n=$t(i);n&&(e/=100);const s=Math.sqrt(t.height*t.height+t.width*t.width);let r;return Number.isFinite(e)&&(n||e>=0&&e<=1?r=e*s:r=Math.max(e+s,0)),{r}}},nc={set:Yt("cx","width")},sc={set:Yt("cy","height")},br={set:vr({resetOffset:!0})},ic={set:vr({resetOffset:!1})},xr={set:Pr({resetOffset:!0})},rc={set:Pr({resetOffset:!1})},oc=yr,lc=br,ac=xr,cc=dr,hc=gr,uc=pr,fc=mr;function Bn(i,t,e){return(n,{refBBox:s})=>{if(n==null)return null;let r=parseFloat(n);const o=$t(n);o&&(r/=100);let l;if(Number.isFinite(r)){const c=s[e];o||r>0&&r<1?l=c[i]+s[t]*r:l=c[i]+r}const a=new w;return a[i]=l||0,a}}function Yt(i,t){return function(e,{refBBox:n}){let s=parseFloat(e);const r=$t(e);r&&(s/=100);const o={};if(Number.isFinite(s)){const l=r||s>=0&&s<=1?s*n[t]:Math.max(s+n[t],0);o[i]=l}return o}}function wr(i,t){const e="x6-shape",n=t&&t.resetOffset;return function(s,{elem:r,refBBox:o}){let l=he(r,e);if(!l||l.value!==s){const p=i(s);l={value:s,shape:p,shapeBBox:p.bbox()},he(r,e,l)}const a=l.shape.clone(),c=l.shapeBBox.clone(),h=c.getOrigin(),u=o.getOrigin();c.x=u.x,c.y=u.y;const f=o.getMaxScaleToFit(c,u),d=c.width===0||o.width===0?1:f.sx,g=c.height===0||o.height===0?1:f.sy;return a.scale(d,g,h),n&&a.translate(-h.x,-h.y),a}}function vr(i){function t(n){return k.parse(n)}const e=wr(t,i);return(n,s)=>({d:e(n,s).serialize()})}function Pr(i){const t=wr(e=>new tt(e),i);return(e,n)=>({points:t(e,n).serialize()})}const dc={qualify:zt,set(i,{view:t}){return`url(#${t.graph.defineGradient(i)})`}},gc={qualify:zt,set(i,{view:t}){const e=t.cell,n=Object.assign({},i);if(e.isEdge()&&n.type==="linearGradient"){const s=t,r=s.sourcePoint,o=s.targetPoint;n.id=`gradient-${n.type}-${e.id}`,n.attrs=Object.assign(Object.assign({},n.attrs),{x1:r.x,y1:r.y,x2:o.x,y2:o.y,gradientUnits:"userSpaceOnUse"}),t.graph.defs.remove(n.id)}return`url(#${t.graph.defineGradient(n)})`}},Cr={qualify(i,{attrs:t}){return t.textWrap==null||!zt(t.textWrap)},set(i,{view:t,elem:e,attrs:n}){const s="x6-text",r=he(e,s),o=h=>{try{return JSON.parse(h)}catch(u){return h}},l={x:n.x,eol:n.eol,annotations:o(n.annotations),textPath:o(n["text-path"]||n.textPath),textVerticalAnchor:n["text-vertical-anchor"]||n.textVerticalAnchor,displayEmpty:(n["display-empty"]||n.displayEmpty)==="true",lineHeight:n["line-height"]||n.lineHeight},a=n["font-size"]||n.fontSize,c=JSON.stringify([i,l]);if(a&&e.setAttribute("font-size",a),r==null||r!==c){const h=l.textPath;if(h!=null&&typeof h=="object"){const u=h.selector;if(typeof u=="string"){const f=t.find(u)[0];f instanceof SVGPathElement&&(ws(f),l.textPath=Object.assign({"xlink:href":`#${f.id}`},h))}}tr(e,`${i}`,l),he(e,s,c)}}},pc={qualify:zt,set(i,{view:t,elem:e,attrs:n,refBBox:s}){const r=i,o=r.width||0;$t(o)?s.width*=parseFloat(o)/100:o<=0?s.width+=o:s.width=o;const l=r.height||0;$t(l)?s.height*=parseFloat(l)/100:l<=0?s.height+=l:s.height=l;let a,c=r.text;c==null&&(c=n.text||(e==null?void 0:e.textContent)),c!=null?a=er(`${c}`,s,{"font-weight":n["font-weight"]||n.fontWeight,"font-size":n["font-size"]||n.fontSize,"font-family":n["font-family"]||n.fontFamily,lineHeight:n.lineHeight},{ellipsis:r.ellipsis}):a="",R(Cr.set,this,a,{view:t,elem:e,attrs:n,refBBox:s,cell:t.cell})}},Re=(i,{attrs:t})=>t.text!==void 0,mc={qualify:Re},yc={qualify:Re},bc={qualify:Re},xc={qualify:Re},wc={qualify:Re},vc={qualify:Re},Pc={qualify(i,{elem:t}){return t instanceof SVGElement},set(i,{elem:t}){const e="x6-title",n=`${i}`,s=he(t,e);if(s==null||s!==n){he(t,e,n);const r=t.firstChild;if(r&&r.tagName.toUpperCase()==="TITLE"){const o=r;o.textContent=n}else{const o=document.createElementNS(t.namespaceURI,"title");o.textContent=n,t.insertBefore(o,r)}}}},Cc={offset:Ar("x","width","right")},Ac={offset:Ar("y","height","bottom")},Sc={offset(i,{refBBox:t}){return i?{x:-t.x,y:-t.y}:{x:0,y:0}}};function Ar(i,t,e){return(n,{refBBox:s})=>{const r=new w;let o;return n==="middle"?o=s[t]/2:n===e?o=s[t]:typeof n=="number"&&Number.isFinite(n)?o=n>-1&&n<1?-s[t]*n:-n:$t(n)?o=s[t]*parseFloat(n)/100:o=0,r[i]=-(s[i]+o),r}}const Oc={qualify:zt,set(i,{elem:t}){rn(t,i)}},Mc={set(i,{elem:t}){t.innerHTML=`${i}`}},Ec={qualify:zt,set(i,{view:t}){return`url(#${t.graph.defineFilter(i)})`}},Tc={set(i){return i!=null&&typeof i=="object"&&i.id?i.id:i}};function ee(i,t,e){let n,s;typeof t=="object"?(n=t.x,s=t.y):(n=t,s=e);const r=k.parse(i),o=r.bbox();if(o){let l=-o.height/2-o.y,a=-o.width/2-o.x;typeof n=="number"&&(a-=n),typeof s=="number"&&(l-=s),r.translate(a,l)}return r.serialize()}var Sr=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};const Nc=i=>{var{size:t,width:e,height:n,offset:s,open:r}=i,o=Sr(i,["size","width","height","offset","open"]);return Or({size:t,width:e,height:n,offset:s},r===!0,!0,void 0,o)},Lc=i=>{var{size:t,width:e,height:n,offset:s,factor:r}=i,o=Sr(i,["size","width","height","offset","factor"]);return Or({size:t,width:e,height:n,offset:s},!1,!1,r,o)};function Or(i,t,e,n=3/4,s={}){const r=i.size||10,o=i.width||r,l=i.height||r,a=new k,c={};if(t)a.moveTo(o,0).lineTo(0,l/2).lineTo(o,l),c.fill="none";else{if(a.moveTo(0,l/2),a.lineTo(o,0),!e){const h=vt(n,0,1);a.lineTo(o*h,l/2)}a.lineTo(o,l),a.close()}return Object.assign(Object.assign(Object.assign({},c),s),{tagName:"path",d:ee(a.serialize(),{x:i.offset!=null?i.offset:-o/2})})}var jc=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};const kc=i=>{var{size:t,width:e,height:n,offset:s}=i,r=jc(i,["size","width","height","offset"]);const o=t||10,l=e||o,a=n||o,c=new k;return c.moveTo(0,a/2).lineTo(l/2,0).lineTo(l,a/2).lineTo(l/2,a).close(),Object.assign(Object.assign({},r),{tagName:"path",d:ee(c.serialize(),s==null?-l/2:s)})};var Dc=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};const Ic=i=>{var{d:t,offsetX:e,offsetY:n}=i,s=Dc(i,["d","offsetX","offsetY"]);return Object.assign(Object.assign({},s),{tagName:"path",d:ee(t,e,n)})};var Rc=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};const Bc=i=>{var{size:t,width:e,height:n,offset:s}=i,r=Rc(i,["size","width","height","offset"]);const o=t||10,l=e||o,a=n||o,c=new k;return c.moveTo(0,0).lineTo(l,a).moveTo(0,a).lineTo(l,0),Object.assign(Object.assign({},r),{tagName:"path",fill:"none",d:ee(c.serialize(),s||-l/2)})};var $c=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};const Vc=i=>{var{width:t,height:e,offset:n,open:s,flip:r}=i,o=$c(i,["width","height","offset","open","flip"]);let l=e||6;const a=t||10,c=s===!0,h=r===!0,u=Object.assign(Object.assign({},o),{tagName:"path"});h&&(l=-l);const f=new k;return f.moveTo(0,l).lineTo(a,0),c?u.fill="none":(f.lineTo(a,l),f.close()),u.d=ee(f.serialize(),{x:n||-a/2,y:l/2}),u};var Mr=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};const Er=i=>{var{r:t}=i,e=Mr(i,["r"]);const n=t||5;return Object.assign(Object.assign({cx:n},e),{tagName:"circle",r:n})},zc=i=>{var{r:t}=i,e=Mr(i,["r"]);const n=t||5,s=new k;return s.moveTo(n,0).lineTo(n,n*2),s.moveTo(0,n).lineTo(n*2,n),{children:[Object.assign(Object.assign({},Er({r:n})),{fill:"none"}),Object.assign(Object.assign({},e),{tagName:"path",d:ee(s.serialize(),-n)})]}};var Fc=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};const qc=i=>{var{rx:t,ry:e}=i,n=Fc(i,["rx","ry"]);const s=t||5,r=e||5;return Object.assign(Object.assign({cx:s},n),{tagName:"ellipse",rx:s,ry:r})},Hc=Object.freeze(Object.defineProperty({__proto__:null,async:Vc,block:Nc,circle:Er,circlePlus:zc,classic:Lc,cross:Bc,diamond:kc,ellipse:qc,path:Ic},Symbol.toStringTag,{value:"Module"}));var Zt;(function(i){i.presets=Hc,i.registry=nt.create({type:"marker"}),i.registry.register(i.presets,!0)})(Zt||(Zt={}));(function(i){i.normalize=ee})(Zt||(Zt={}));var Gc=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};function Os(i){return typeof i=="string"||zt(i)}const _c={qualify:Os,set(i,{view:t,attrs:e}){return Ms("marker-start",i,t,e)}},Uc={qualify:Os,set(i,{view:t,attrs:e}){return Ms("marker-end",i,t,e,{transform:"rotate(180)"})}},Wc={qualify:Os,set(i,{view:t,attrs:e}){return Ms("marker-mid",i,t,e)}};function Ms(i,t,e,n,s={}){const r=typeof t=="string"?{name:t}:t,{name:o,args:l}=r,a=Gc(r,["name","args"]);let c=a;if(o&&typeof o=="string"){const u=Zt.registry.get(o);if(u)c=u(Object.assign(Object.assign({},a),l));else return Zt.registry.onNotFound(o)}const h=Object.assign(Object.assign(Object.assign({},Xc(n,i)),s),c);return{[i]:`url(#${e.graph.defineMarker(h)})`}}function Xc(i,t){const e={},n=i.stroke;typeof n=="string"&&(e.stroke=n,e.fill=n);let s=i.strokeOpacity;if(s==null&&(s=i["stroke-opacity"]),s==null&&(s=i.opacity),s!=null&&(e["stroke-opacity"]=s,e["fill-opacity"]=s),t!=="marker-mid"){const r=parseFloat(i.strokeWidth||i["stroke-width"]);if(Number.isFinite(r)&&r>1){const o=Math.ceil(r/2);e.refX=t==="marker-start"?o:-o}}return e}const on=(i,{view:t})=>t.cell.isEdge(),Jc={qualify:on,set(i,t){var e,n,s,r;const o=t.view,l=i.reverse||!1,a=i.stubs||0;let c;if(Number.isFinite(a)&&a!==0)if(l){let h,u;const f=o.getConnectionLength()||0;a<0?(h=(f+a)/2,u=-a):(h=a,u=f-a*2);const d=o.getConnection();c=(r=(s=(n=(e=d==null?void 0:d.divideAtLength(h))===null||e===void 0?void 0:e[1])===null||n===void 0?void 0:n.divideAtLength(u))===null||s===void 0?void 0:s[0])===null||r===void 0?void 0:r.serialize()}else{let h;a<0?h=((o.getConnectionLength()||0)+a)/2:h=a;const u=o.getConnection();if(u){const f=u.divideAtLength(h),d=u.divideAtLength(-h);f&&d&&(c=`${f[0].serialize()} ${d[1].serialize()}`)}}return{d:c||o.getConnectionPathData()}}},Tr={qualify:on,set:$n("getTangentAtLength",{rotate:!0})},Yc={qualify:on,set:$n("getTangentAtLength",{rotate:!1})},Nr={qualify:on,set:$n("getTangentAtRatio",{rotate:!0})},Zc={qualify:on,set:$n("getTangentAtRatio",{rotate:!1})},Kc=Tr,Qc=Nr;function $n(i,t){const e={x:1,y:0};return(n,s)=>{let r,o;const l=s.view,a=l[i](Number(n));return a?(o=t.rotate?a.vector().vectorAngle(e):0,r=a.start):(r=l.path.start,o=0),o===0?{transform:`translate(${r.x},${r.y}')`}:{transform:`translate(${r.x},${r.y}') rotate(${o})`}}}const th=Object.freeze(Object.defineProperty({__proto__:null,annotations:xc,atConnectionLength:Kc,atConnectionLengthIgnoreGradient:Yc,atConnectionLengthKeepGradient:Tr,atConnectionRatio:Qc,atConnectionRatioIgnoreGradient:Zc,atConnectionRatioKeepGradient:Nr,connection:Jc,displayEmpty:vc,eol:wc,fill:dc,filter:Ec,html:Mc,lineHeight:mc,port:Tc,ref:Ya,refCx:nc,refCy:sc,refD:lc,refDKeepOffset:ic,refDResetOffset:br,refDx:Za,refDy:Ka,refHeight:mr,refHeight2:fc,refPoints:ac,refPointsKeepOffset:rc,refPointsResetOffset:xr,refR:oc,refRCircumscribed:ec,refRInscribed:yr,refRx:Qa,refRy:tc,refWidth:pr,refWidth2:uc,refX:dr,refX2:cc,refY:gr,refY2:hc,resetOffset:Sc,sourceMarker:_c,stroke:gc,style:Oc,targetMarker:Uc,text:Cr,textPath:bc,textVerticalAnchor:yc,textWrap:pc,title:Pc,vertexMarker:Wc,xAlign:Cc,yAlign:Ac},Symbol.toStringTag,{value:"Module"}));var Tt;(function(i){function t(e,n,s){return!!(e!=null&&(typeof e=="string"||typeof e.qualify!="function"||R(e.qualify,this,n,s)))}i.isValidDefinition=t})(Tt||(Tt={}));(function(i){i.presets=Object.assign(Object.assign({},Ja),th),i.registry=nt.create({type:"attribute definition"}),i.registry.register(i.presets,!0)})(Tt||(Tt={}));const Ot={prefixCls:"x6",autoInsertCSS:!0,useCSSSelector:!0,prefix(i){return`${Ot.prefixCls}-${i}`}},ni=Ot.prefix("highlighted"),eh={highlight(i,t,e){const n=e&&e.className||ni;F(t,n)},unhighlight(i,t,e){const n=e&&e.className||ni;Pt(t,n)}},si=Ot.prefix("highlight-opacity"),nh={highlight(i,t){F(t,si)},unhighlight(i,t){Pt(t,si)}};var q;(function(i){const t=Ft("svg");i.normalizeMarker=ee;function e(d,g){const p=ca(d.x,d.y).matrixTransform(g);return new w(p.x,p.y)}i.transformPoint=e;function n(d,g){return new L(e(d.start,g),e(d.end,g))}i.transformLine=n;function s(d,g){let p=d instanceof tt?d.points:d;return Array.isArray(p)||(p=[]),new tt(p.map(m=>e(m,g)))}i.transformPolyline=s;function r(d,g){const p=t.createSVGPoint();p.x=d.x,p.y=d.y;const m=p.matrixTransform(g);p.x=d.x+d.width,p.y=d.y;const b=p.matrixTransform(g);p.x=d.x+d.width,p.y=d.y+d.height;const x=p.matrixTransform(g);p.x=d.x,p.y=d.y+d.height;const y=p.matrixTransform(g),v=Math.min(m.x,b.x,x.x,y.x),P=Math.max(m.x,b.x,x.x,y.x),C=Math.min(m.y,b.y,x.y,y.y),O=Math.max(m.y,b.y,x.y,y.y);return new T(v,C,P-v,O-C)}i.transformRectangle=r;function o(d,g,p){let m;const b=d.ownerSVGElement;if(!b)return new T(0,0,0,0);try{m=d.getBBox()}catch(y){m={x:d.clientLeft,y:d.clientTop,width:d.clientWidth,height:d.clientHeight}}if(g)return T.create(m);const x=qe(d,p||b);return r(m,x)}i.bbox=o;function l(d,g={}){let p;if(!d.ownerSVGElement||!Jt(d)){if(Us(d)){const{left:y,top:v,width:P,height:C}=a(d);return new T(y,v,P,C)}return new T(0,0,0,0)}let b=g.target;if(!g.recursive){try{p=d.getBBox()}catch(v){p={x:d.clientLeft,y:d.clientTop,width:d.clientWidth,height:d.clientHeight}}if(!b)return T.create(p);const y=qe(d,b);return r(p,y)}{const y=d.childNodes,v=y.length;if(v===0)return l(d,{target:b});b||(b=d);for(let P=0;P<v;P+=1){const C=y[P];let O;C.childNodes.length===0?O=l(C,{target:b}):O=l(C,{target:b,recursive:!0}),p?p=p.union(O):p=O}return p}}i.getBBox=l;function a(d){let g=0,p=0,m=0,b=0;if(d){let x=d;for(;x;)g+=x.offsetLeft,p+=x.offsetTop,x=x.offsetParent,x&&(g+=parseInt(Ys(x,"borderLeft"),10),p+=parseInt(Ys(x,"borderTop"),10));m=d.offsetWidth,b=d.offsetHeight}return{left:g,top:p,width:m,height:b}}i.getBoundingOffsetRect=a;function c(d){const g=p=>{const m=d.getAttribute(p),b=m?parseFloat(m):0;return Number.isNaN(b)?0:b};switch(d instanceof SVGElement&&d.nodeName.toLowerCase()){case"rect":return new T(g("x"),g("y"),g("width"),g("height"));case"circle":return new St(g("cx"),g("cy"),g("r"),g("r"));case"ellipse":return new St(g("cx"),g("cy"),g("rx"),g("ry"));case"polyline":{const p=Pn(d);return new tt(p)}case"polygon":{const p=Pn(d);return p.length>1&&p.push(p[0]),new tt(p)}case"path":{let p=d.getAttribute("d");return k.isValid(p)||(p=k.normalize(p)),k.parse(p)}case"line":return new L(g("x1"),g("y1"),g("x2"),g("y2"))}return l(d)}i.toGeometryShape=c;function h(d,g,p,m){const b=w.create(g),x=w.create(p);m||(m=d instanceof SVGSVGElement?d:d.ownerSVGElement);const y=is(d);d.setAttribute("transform","");const v=l(d,{target:m}).scale(y.sx,y.sy),P=Ve();P.setTranslate(-v.x-v.width/2,-v.y-v.height/2);const C=Ve(),O=b.angleBetween(x,b.clone().translate(1,0));O&&C.setRotate(O,0,0);const N=Ve(),M=b.clone().move(x,v.width/2);N.setTranslate(2*b.x-M.x,2*b.y-M.y);const j=qe(d,m),E=Ve();E.setMatrix(N.matrix.multiply(C.matrix.multiply(P.matrix.multiply(j.scale(y.sx,y.sy))))),d.setAttribute("transform",Ie(E.matrix))}i.translateAndAutoOrient=h;function u(d){if(d==null)return null;let g=d;do{let p=g.tagName;if(typeof p!="string")return null;if(p=p.toUpperCase(),De(g,"x6-port"))g=g.nextElementSibling;else if(p==="G")g=g.firstElementChild;else if(p==="TITLE")g=g.nextElementSibling;else break}while(g);return g}i.findShapeNode=u;function f(d){const g=u(d);if(!Jt(g)){if(Us(d)){const{left:b,top:x,width:y,height:v}=a(d);return new T(b,x,y,v)}return new T(0,0,0,0)}return c(g).bbox()||T.create()}i.getBBoxV2=f})(q||(q={}));const sh={padding:3,rx:0,ry:0,attrs:{"stroke-width":3,stroke:"#FEB663"}},ih={highlight(i,t,e){const n=Gt.getHighlighterId(t,e);if(Gt.hasCache(n))return;e=Ci({},e,sh);const s=I.create(t);let r,o;try{r=s.toPathData()}catch(h){o=q.bbox(s.node,!0),r=sr(Object.assign(Object.assign({},e),o))}const l=Ft("path");if(G(l,Object.assign({d:r,"pointer-events":"none","vector-effect":"non-scaling-stroke",fill:"none"},e.attrs?Ue(e.attrs):null)),i.isEdgeElement(t))G(l,"d",i.getConnectionPathData());else{let h=s.getTransformToElement(i.container);const u=e.padding;if(u){o==null&&(o=q.bbox(s.node,!0));const f=o.x+o.width/2,d=o.y+o.height/2;o=q.transformRectangle(o,h);const g=Math.max(o.width,1),p=Math.max(o.height,1),m=(g+u)/g,b=(p+u)/p,x=ht({a:m,b:0,c:0,d:b,e:f-m*f,f:d-b*d});h=h.multiply(x)}be(l,h)}F(l,Ot.prefix("highlight-stroke"));const a=i.cell,c=()=>Gt.removeHighlighter(n);a.on("removed",c),a.model&&a.model.on("reseted",c),i.container.appendChild(l),Gt.setCache(n,l)},unhighlight(i,t,e){Gt.removeHighlighter(Gt.getHighlighterId(t,e))}};var Gt;(function(i){function t(o,l){return ws(o),o.id+JSON.stringify(l)}i.getHighlighterId=t;const e={};function n(o,l){e[o]=l}i.setCache=n;function s(o){return e[o]!=null}i.hasCache=s;function r(o){const l=e[o];l&&(ye(l),delete e[o])}i.removeHighlighter=r})(Gt||(Gt={}));const rh=Object.freeze(Object.defineProperty({__proto__:null,className:eh,opacity:nh,stroke:ih},Symbol.toStringTag,{value:"Module"}));var Rt;(function(i){function t(e,n){if(typeof n.highlight!="function")throw new Error(`Highlighter '${e}' is missing required \`highlight()\` method`);if(typeof n.unhighlight!="function")throw new Error(`Highlighter '${e}' is missing required \`unhighlight()\` method`)}i.check=t})(Rt||(Rt={}));(function(i){i.presets=rh,i.registry=nt.create({type:"highlighter"}),i.registry.register(i.presets,!0)})(Rt||(Rt={}));function ls(i,t={}){return new w(Ct(t.x,i.width),Ct(t.y,i.height))}function Es(i,t,e){return Object.assign({angle:t,position:i.toJSON()},e)}const oh=(i,t)=>i.map(({x:e,y:n,angle:s})=>Es(ls(t,{x:e,y:n}),s||0)),lh=(i,t,e)=>{const n=e.start||0,s=e.step||20;return Lr(i,t,n,(r,o)=>(r+.5-o/2)*s)},ah=(i,t,e)=>{const n=e.start||0,s=e.step||360/i.length;return Lr(i,t,n,r=>r*s)};function Lr(i,t,e,n){const s=t.getCenter(),r=t.getTopCenter(),o=t.width/t.height,l=St.fromRect(t),a=i.length;return i.map((c,h)=>{const u=e+n(h,a),f=r.clone().rotate(-u,s).scale(o,1,s),d=c.compensateRotate?-l.tangentTheta(f):0;return(c.dx||c.dy)&&f.translate(c.dx||0,c.dy||0),c.dr&&f.move(s,c.dr),Es(f.round(),d,c)})}var ch=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};const hh=(i,t,e)=>{const n=ls(t,e.start||t.getOrigin()),s=ls(t,e.end||t.getCorner());return ln(i,n,s,e)},uh=(i,t,e)=>ln(i,t.getTopLeft(),t.getBottomLeft(),e),fh=(i,t,e)=>ln(i,t.getTopRight(),t.getBottomRight(),e),dh=(i,t,e)=>ln(i,t.getTopLeft(),t.getTopRight(),e),gh=(i,t,e)=>ln(i,t.getBottomLeft(),t.getBottomRight(),e);function ln(i,t,e,n){const s=new L(t,e),r=i.length;return i.map((o,l)=>{var{strict:a}=o,c=ch(o,["strict"]);const h=a||n.strict?(l+1)/(r+1):(l+.5)/r,u=s.pointAt(h);return(c.dx||c.dy)&&u.translate(c.dx||0,c.dy||0),Es(u.round(),0,c)})}const ph=Object.freeze(Object.defineProperty({__proto__:null,absolute:oh,bottom:gh,ellipse:lh,ellipseSpread:ah,left:uh,line:hh,right:fh,top:dh},Symbol.toStringTag,{value:"Module"}));var le;(function(i){i.presets=ph,i.registry=nt.create({type:"port layout"}),i.registry.register(i.presets,!0)})(le||(le={}));const mh={position:{x:0,y:0},angle:0,attrs:{".":{y:"0","text-anchor":"start"}}};function ne(i,t){const{x:e,y:n,angle:s,attrs:r}=t||{};return Ci({},{angle:s,attrs:r,position:{x:e,y:n}},i,mh)}const yh=(i,t,e)=>ne({position:t.getTopLeft()},e),bh=(i,t,e)=>ne({position:{x:-15,y:0},attrs:{".":{y:".3em","text-anchor":"end"}}},e),xh=(i,t,e)=>ne({position:{x:15,y:0},attrs:{".":{y:".3em","text-anchor":"start"}}},e),wh=(i,t,e)=>ne({position:{x:0,y:-15},attrs:{".":{"text-anchor":"middle"}}},e),vh=(i,t,e)=>ne({position:{x:0,y:15},attrs:{".":{y:".6em","text-anchor":"middle"}}},e),Ph=(i,t,e)=>jr(i,t,!1,e),Ch=(i,t,e)=>jr(i,t,!0,e),Ah=(i,t,e)=>kr(i,t,!1,e),Sh=(i,t,e)=>kr(i,t,!0,e);function jr(i,t,e,n){const s=n.offset!=null?n.offset:15,r=t.getCenter().theta(i),o=Dr(t);let l,a,c,h,u=0;return r<o[1]||r>o[2]?(l=".3em",a=s,c=0,h="start"):r<o[0]?(l="0",a=0,c=-s,e?(u=-90,h="start"):h="middle"):r<o[3]?(l=".3em",a=-s,c=0,h="end"):(l=".6em",a=0,c=s,e?(u=90,h="start"):h="middle"),ne({position:{x:Math.round(a),y:Math.round(c)},angle:u,attrs:{".":{y:l,"text-anchor":h}}},n)}function kr(i,t,e,n){const s=n.offset!=null?n.offset:15,r=t.getCenter().theta(i),o=Dr(t);let l,a,c,h,u=0;return r<o[1]||r>o[2]?(l=".3em",a=-s,c=0,h="end"):r<o[0]?(l=".6em",a=0,c=s,e?(u=90,h="start"):h="middle"):r<o[3]?(l=".3em",a=s,c=0,h="start"):(l="0em",a=0,c=-s,e?(u=-90,h="start"):h="middle"),ne({position:{x:Math.round(a),y:Math.round(c)},angle:u,attrs:{".":{y:l,"text-anchor":h}}},n)}function Dr(i){const t=i.getCenter(),e=t.theta(i.getTopLeft()),n=t.theta(i.getBottomLeft()),s=t.theta(i.getBottomRight()),r=t.theta(i.getTopRight());return[e,r,s,n]}const Oh=(i,t,e)=>Ir(i.diff(t.getCenter()),!1,e),Mh=(i,t,e)=>Ir(i.diff(t.getCenter()),!0,e);function Ir(i,t,e){const n=e.offset!=null?e.offset:20,s=new w(0,0),r=-i.theta(s),o=i.clone().move(s,n).diff(i).round();let l=".3em",a,c=r;return(r+90)%180===0?(a=t?"end":"middle",!t&&r===-270&&(l="0em")):r>-270&&r<-90?(a="start",c=r-180):a="end",ne({position:o.round().toJSON(),angle:t?c:0,attrs:{".":{y:l,"text-anchor":a}}},e)}const Eh=Object.freeze(Object.defineProperty({__proto__:null,bottom:vh,inside:Ah,insideOriented:Sh,left:bh,manual:yh,outside:Ph,outsideOriented:Ch,radial:Oh,radialOriented:Mh,right:xh,top:wh},Symbol.toStringTag,{value:"Module"}));var Ce;(function(i){i.presets=Eh,i.registry=nt.create({type:"port label layout"}),i.registry.register(i.presets,!0)})(Ce||(Ce={}));var Th=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class X extends yt{get priority(){return 2}constructor(){super(),this.cid=as.uniqueId(),X.views[this.cid]=this}confirmUpdate(t,e){return 0}empty(t=this.container){return nn(t),this}unmount(t=this.container){return ye(t),this}remove(t=this.container){return t===this.container&&(this.removeEventListeners(document),this.onRemove(),delete X.views[this.cid]),this.unmount(t),this}onRemove(){}setClass(t,e=this.container){e.classList.value=Array.isArray(t)?t.join(" "):t}addClass(t,e=this.container){return F(e,Array.isArray(t)?t.join(" "):t),this}removeClass(t,e=this.container){return Pt(e,Array.isArray(t)?t.join(" "):t),this}setStyle(t,e=this.container){return rn(e,t),this}setAttrs(t,e=this.container){return t!=null&&e!=null&&G(e,t),this}findAttr(t,e=this.container){let n=e;for(;n&&n.nodeType===1;){const s=n.getAttribute(t);if(s!=null)return s;if(n===this.container)return null;n=n.parentNode}return null}find(t,e=this.container,n=this.selectors){return X.find(t,e,n).elems}findOne(t,e=this.container,n=this.selectors){const s=this.find(t,e,n);return s.length>0?s[0]:null}findByAttr(t,e=this.container){let n=e;for(;n&&n.getAttribute;){const s=n.getAttribute(t);if((s!=null||n===this.container)&&s!=="false")return n;n=n.parentNode}return null}getSelector(t,e){let n;if(t===this.container)return typeof e=="string"&&(n=`> ${e}`),n;if(t){const s=Ps(t)+1;n=`${t.tagName.toLowerCase()}:nth-child(${s})`,e&&(n+=` > ${e}`),n=this.getSelector(t.parentNode,n)}return n}prefixClassName(t){return Ot.prefix(t)}delegateEvents(t,e){if(t==null)return this;e||this.undelegateEvents();const n=/^(\S+)\s*(.*)$/;return Object.keys(t).forEach(s=>{const r=s.match(n);if(r==null)return;const o=this.getEventHandler(t[s]);typeof o=="function"&&this.delegateEvent(r[1],r[2],o)}),this}undelegateEvents(){return pt.off(this.container,this.getEventNamespace()),this}delegateDocumentEvents(t,e){return this.addEventListeners(document,t,e),this}undelegateDocumentEvents(){return this.removeEventListeners(document),this}delegateEvent(t,e,n){return pt.on(this.container,t+this.getEventNamespace(),e,n),this}undelegateEvent(t,e,n){const s=t+this.getEventNamespace();return e==null?pt.off(this.container,s):typeof e=="string"?pt.off(this.container,s,e,n):pt.off(this.container,s,e),this}addEventListeners(t,e,n){if(e==null)return this;const s=this.getEventNamespace();return Object.keys(e).forEach(r=>{const o=this.getEventHandler(e[r]);typeof o=="function"&&pt.on(t,r+s,n,o)}),this}removeEventListeners(t){return t!=null&&pt.off(t,this.getEventNamespace()),this}getEventNamespace(){return`.${Ot.prefixCls}-event-${this.cid}`}getEventHandler(t){let e;if(typeof t=="string"){const n=this[t];typeof n=="function"&&(e=(...s)=>n.call(this,...s))}else e=(...n)=>t.call(this,...n);return e}getEventTarget(t,e={}){const{target:n,type:s,clientX:r=0,clientY:o=0}=t;return e.fromPoint||s==="touchmove"||s==="touchend"?document.elementFromPoint(r,o):n}stopPropagation(t){return this.setEventData(t,{propagationStopped:!0}),this}isPropagationStopped(t){return this.getEventData(t).propagationStopped===!0}getEventData(t){return this.eventData(t)}setEventData(t,e){return this.eventData(t,e)}eventData(t,e){if(t==null)throw new TypeError("Event object required");let n=t.data;const s=`__${this.cid}__`;return e==null?n==null?{}:n[s]||{}:(n==null&&(n=t.data={}),n[s]==null?n[s]=Object.assign({},e):n[s]=Object.assign(Object.assign({},n[s]),e),n[s])}normalizeEvent(t){return X.normalizeEvent(t)}dispose(){this.remove()}}Th([X.dispose()],X.prototype,"dispose",null);(function(i){function t(s,r){return r?Ft(s||"g"):vs(s||"div")}i.createElement=t;function e(s,r,o){if(!s||s===".")return{elems:[r]};if(o){const l=o[s];if(l)return{elems:Array.isArray(l)?l:[l]}}{const l=s.includes(">")?`:scope ${s}`:s;return{isCSSSelector:!0,elems:Array.prototype.slice.call(r.querySelectorAll(l))}}}i.find=e;function n(s){let r=s;const o=s.originalEvent,l=o&&o.changedTouches&&o.changedTouches[0];if(l){for(const a in s)l[a]===void 0&&(l[a]=s[a]);r=l}return r}i.normalizeEvent=n})(X||(X={}));(function(i){i.views={};function t(e){return i.views[e]||null}i.getView=t})(X||(X={}));var as;(function(i){let t=0;function e(){const n=`v${t}`;return t+=1,n}i.uniqueId=e})(as||(as={}));class Nh{constructor(t){this.view=t,this.clean()}clean(){this.elemCache&&this.elemCache.dispose(),this.elemCache=new os,this.pathCache={}}get(t){return this.elemCache.has(t)||this.elemCache.set(t,{}),this.elemCache.get(t)}getData(t){const e=this.get(t);return e.data||(e.data={}),e.data}getMatrix(t){const e=this.get(t);if(e.matrix==null){const n=this.view.container;e.matrix=ga(t,n)}return ht(e.matrix)}getShape(t){const e=this.get(t);return e.shape==null&&(e.shape=q.toGeometryShape(t)),e.shape.clone()}getBoundingRect(t){const e=this.get(t);return e.boundingRect==null&&(e.boundingRect=q.getBBoxV2(t)),e.boundingRect.clone()}}var W;(function(i){function t(c){return c!=null&&!e(c)}i.isJSONMarkup=t;function e(c){return c!=null&&typeof c=="string"}i.isStringMarkup=e;function n(c){return c==null||e(c)?c:K(c)}i.clone=n;function s(c){return`${c}`.trim().replace(/[\r|\n]/g," ").replace(/>\s+</g,"><")}i.sanitize=s;function r(c,h={ns:at.svg}){const u=document.createDocumentFragment(),f={},d={},g=[{markup:Array.isArray(c)?c:[c],parent:u,ns:h.ns}];for(;g.length>0;){const p=g.pop();let m=p.ns||at.svg;const b=p.markup,x=p.parent;b.forEach(y=>{const v=y.tagName;if(!v)throw new TypeError("Invalid tagName");y.ns&&(m=y.ns);const P=m?vs(v,m):_s(v),C=y.attrs;C&&G(P,Ue(C));const O=y.style;O&&rn(P,O);const N=y.className;N!=null&&P.setAttribute("class",Array.isArray(N)?N.join(" "):N),y.textContent&&(P.textContent=y.textContent);const M=y.selector;if(M!=null){if(d[M])throw new TypeError("Selector must be unique");d[M]=P}if(y.groupSelector){let E=y.groupSelector;Array.isArray(E)||(E=[E]),E.forEach(D=>{f[D]||(f[D]=[]),f[D].push(P)})}x.appendChild(P);const j=y.children;Array.isArray(j)&&g.push({ns:m,markup:j,parent:P})})}return Object.keys(f).forEach(p=>{if(d[p])throw new Error("Ambiguous group selector");d[p]=f[p]}),{fragment:u,selectors:d,groups:f}}i.parseJSONMarkup=r;function o(c){return c instanceof SVGElement?Ft("g"):_s("div")}function l(c){if(e(c)){const d=I.createVectors(c),g=d.length;if(g===1)return{elem:d[0].node};if(g>1){const p=o(d[0].node);return d.forEach(m=>{p.appendChild(m.node)}),{elem:p}}return{}}const h=r(c),u=h.fragment;let f=null;return u.childNodes.length>1?(f=o(u.firstChild),f.appendChild(u)):f=u.firstChild,{elem:f,selectors:h.selectors}}i.renderMarkup=l;function a(c){const h=I.createVectors(c),u=document.createDocumentFragment();for(let f=0,d=h.length;f<d;f+=1){const g=h[f].node;u.appendChild(g)}return{fragment:u,selectors:{}}}i.parseLabelStringMarkup=a})(W||(W={}));(function(i){function t(e,n,s){if(e!=null){let r;const o=e.tagName.toLowerCase();if(e===n)return typeof s=="string"?r=`> ${o} > ${s}`:r=`> ${o}`,r;const l=e.parentNode;if(l&&l.childNodes.length>1){const a=Ps(e)+1;r=`${o}:nth-child(${a})`}else r=o;return s&&(r+=` > ${s}`),t(e.parentNode,n,r)}return s}i.getSelector=t})(W||(W={}));(function(i){function t(){return"g"}i.getPortContainerMarkup=t;function e(){return{tagName:"circle",selector:"circle",attrs:{r:10,fill:"#FFFFFF",stroke:"#000000"}}}i.getPortMarkup=e;function n(){return{tagName:"text",selector:"text",attrs:{fill:"#000000"}}}i.getPortLabelMarkup=n})(W||(W={}));(function(i){function t(){return[{tagName:"path",selector:"wrap",groupSelector:"lines",attrs:{fill:"none",cursor:"pointer",stroke:"transparent",strokeLinecap:"round"}},{tagName:"path",selector:"line",groupSelector:"lines",attrs:{fill:"none",pointerEvents:"none"}}]}i.getEdgeMarkup=t})(W||(W={}));(function(i){function t(e=!1){return{tagName:"foreignObject",selector:"fo",children:[{ns:at.xhtml,tagName:"body",selector:"foBody",attrs:{xmlns:at.xhtml},style:{width:"100%",height:"100%",background:"transparent"},children:e?[]:[{tagName:"div",selector:"foContent",style:{width:"100%",height:"100%"}}]}]}}i.getForeignObjectMarkup=t})(W||(W={}));class Rr{constructor(t){this.view=t}get cell(){return this.view.cell}getDefinition(t){return this.cell.getAttrDefinition(t)}processAttrs(t,e){let n,s,r,o;const l=[];return Object.keys(e).forEach(a=>{const c=e[a],h=this.getDefinition(a),u=R(Tt.isValidDefinition,this.view,h,c,{elem:t,attrs:e,cell:this.cell,view:this.view});if(h&&u)typeof h=="string"?(n==null&&(n={}),n[h]=c):c!==null&&l.push({name:a,definition:h});else{n==null&&(n={});const f=Wi.includes(a)?a:Ei(a);n[f]=c}}),l.forEach(({name:a,definition:c})=>{const h=e[a];typeof c.set=="function"&&(s==null&&(s={}),s[a]=h),typeof c.offset=="function"&&(r==null&&(r={}),r[a]=h),typeof c.position=="function"&&(o==null&&(o={}),o[a]=h)}),{raw:e,normal:n,set:s,offset:r,position:o}}mergeProcessedAttrs(t,e){t.set=Object.assign(Object.assign({},t.set),e.set),t.position=Object.assign(Object.assign({},t.position),e.position),t.offset=Object.assign(Object.assign({},t.offset),e.offset);const n=t.normal&&t.normal.transform;n!=null&&e.normal&&(e.normal.transform=n),t.normal=e.normal}findAttrs(t,e,n,s){const r=[],o=new os;return Object.keys(t).forEach(l=>{const a=t[l];if(!zt(a))return;const{isCSSSelector:c,elems:h}=X.find(l,e,s);n[l]=h;for(let u=0,f=h.length;u<f;u+=1){const d=h[u],g=s&&s[l]===d,p=o.get(d);if(p){p.array||(r.push(d),p.array=!0,p.attrs=[p.attrs],p.priority=[p.priority]);const m=p.attrs,b=p.priority;if(g)m.unshift(a),b.unshift(-1);else{const x=ml(b,c?-1:f);m.splice(x,0,a),b.splice(x,0,f)}}else o.set(d,{elem:d,attrs:a,priority:g?-1:f,array:!1})}}),r.forEach(l=>{const a=o.get(l),c=a.attrs;a.attrs=c.reduceRight((h,u)=>st(h,u),{})}),o}updateRelativeAttrs(t,e,n){const s=e.raw||{};let r=e.normal||{};const o=e.set,l=e.position,a=e.offset,c=()=>({elem:t,cell:this.cell,view:this.view,attrs:s,refBBox:n.clone()});if(o!=null&&Object.keys(o).forEach(m=>{const b=o[m],x=this.getDefinition(m);if(x!=null){const y=R(x.set,this.view,b,c());typeof y=="object"?r=Object.assign(Object.assign({},r),y):y!=null&&(r[m]=y)}}),t instanceof HTMLElement){this.view.setAttrs(r,t);return}const h=r.transform,u=h?`${h}`:null,f=We(u),d=new w(f.e,f.f);h&&(delete r.transform,f.e=0,f.f=0);let g=!1;l!=null&&Object.keys(l).forEach(m=>{const b=l[m],x=this.getDefinition(m);if(x!=null){const y=R(x.position,this.view,b,c());y!=null&&(g=!0,d.translate(w.create(y)))}}),this.view.setAttrs(r,t);let p=!1;if(a!=null){const m=this.view.getBoundingRectOfElement(t);if(m.width>0&&m.height>0){const b=q.transformRectangle(m,f);Object.keys(a).forEach(x=>{const y=a[x],v=this.getDefinition(x);if(v!=null){const P=R(v.offset,this.view,y,{elem:t,cell:this.cell,view:this.view,attrs:s,refBBox:b});P!=null&&(p=!0,d.translate(w.create(P)))}})}}(h!=null||g||p)&&(d.round(1),f.e=d.x,f.f=d.y,t.setAttribute("transform",Ie(f)))}update(t,e,n){const s={},r=this.findAttrs(n.attrs||e,t,s,n.selectors),o=n.attrs?this.findAttrs(e,t,s,n.selectors):r,l=[];r.each(h=>{const u=h.elem,f=h.attrs,d=this.processAttrs(u,f);if(d.set==null&&d.position==null&&d.offset==null)this.view.setAttrs(d.normal,u);else{const g=o.get(u),p=g?g.attrs:null,m=p&&f.ref==null?p.ref:f.ref;let b;if(m){if(b=(s[m]||this.view.find(m,t,n.selectors))[0],!b)throw new Error(`"${m}" reference does not exist.`)}else b=null;const x={node:u,refNode:b,attributes:p,processedAttributes:d},y=l.findIndex(v=>v.refNode===u);y>-1?l.splice(y,0,x):l.push(x)}});const a=new os;let c;l.forEach(h=>{const u=h.node,f=h.refNode;let d;const g=f!=null&&n.rotatableNode!=null&&Ui(n.rotatableNode,f);if(f&&(d=a.get(f)),!d){const b=g?n.rotatableNode:t;d=f?q.getBBox(f,{target:b}):n.rootBBox,f&&a.set(f,d)}let p;n.attrs&&h.attributes?(p=this.processAttrs(u,h.attributes),this.mergeProcessedAttrs(p,h.processedAttributes)):p=h.processedAttributes;let m=d;g&&n.rotatableNode!=null&&!n.rotatableNode.contains(u)&&(c||(c=We(G(n.rotatableNode,"transform"))),m=q.transformRectangle(d,c)),this.updateRelativeAttrs(u,p,m)})}}class Br{get cell(){return this.view.cell}constructor(t,e,n=[]){this.view=t;const s={},r={};let o=0;Object.keys(e).forEach(a=>{let c=e[a];Array.isArray(c)||(c=[c]),c.forEach(h=>{let u=s[h];u||(o+=1,u=s[h]=1<<o),r[a]|=u})});let l=n;if(Array.isArray(l)||(l=[l]),l.forEach(a=>{s[a]||(o+=1,s[a]=1<<o)}),o>25)throw new Error("Maximum number of flags exceeded.");this.flags=s,this.attrs=r,this.bootstrap=n}getFlag(t){const e=this.flags;return e==null?0:Array.isArray(t)?t.reduce((n,s)=>n|e[s],0):e[t]|0}hasAction(t,e){return t&this.getFlag(e)}removeAction(t,e){return t^t&this.getFlag(e)}getBootstrapFlag(){return this.getFlag(this.bootstrap)}getChangedFlag(){let t=0;return this.attrs&&Object.keys(this.attrs).forEach(e=>{this.cell.hasChanged(e)&&(t|=this.attrs[e])}),t}}var Lh=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r},jh=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};class et extends X{static getDefaults(){return this.defaults}static config(t){this.defaults=this.getOptions(t)}static getOptions(t){const e=(c,h)=>h!=null?xi([...Array.isArray(c)?c:[c],...Array.isArray(h)?h:[h]]):Array.isArray(c)?[...c]:[c],n=K(this.getDefaults()),{bootstrap:s,actions:r,events:o,documentEvents:l}=t,a=jh(t,["bootstrap","actions","events","documentEvents"]);return s&&(n.bootstrap=e(n.bootstrap,s)),r&&Object.entries(r).forEach(([c,h])=>{const u=n.actions[c];h&&u?n.actions[c]=e(u,h):h&&(n.actions[c]=e(h))}),o&&(n.events=Object.assign(Object.assign({},n.events),o)),t.documentEvents&&(n.documentEvents=Object.assign(Object.assign({},n.documentEvents),l)),st(n,a)}get[Symbol.toStringTag](){return et.toStringTag}constructor(t,e={}){super(),this.cell=t,this.options=this.ensureOptions(e),this.graph=this.options.graph,this.attr=new Rr(this),this.flag=new Br(this,this.options.actions,this.options.bootstrap),this.cache=new Nh(this),this.setContainer(this.ensureContainer()),this.setup(),this.init()}init(){}onRemove(){this.removeTools()}get priority(){return this.options.priority}get rootSelector(){return this.options.rootSelector}getConstructor(){return this.constructor}ensureOptions(t){return this.getConstructor().getOptions(t)}getContainerTagName(){return this.options.isSvgElement?"g":"div"}getContainerStyle(){}getContainerAttrs(){return{"data-cell-id":this.cell.id,"data-shape":this.cell.shape}}getContainerClassName(){return this.prefixClassName("cell")}ensureContainer(){return X.createElement(this.getContainerTagName(),this.options.isSvgElement)}setContainer(t){if(this.container!==t){this.undelegateEvents(),this.container=t,this.options.events!=null&&this.delegateEvents(this.options.events);const e=this.getContainerAttrs();e!=null&&this.setAttrs(e,t);const n=this.getContainerStyle();n!=null&&this.setStyle(n,t);const s=this.getContainerClassName();s!=null&&this.addClass(s,t)}return this}isNodeView(){return!1}isEdgeView(){return!1}render(){return this}confirmUpdate(t,e={}){return 0}getBootstrapFlag(){return this.flag.getBootstrapFlag()}getFlag(t){return this.flag.getFlag(t)}hasAction(t,e){return this.flag.hasAction(t,e)}removeAction(t,e){return this.flag.removeAction(t,e)}handleAction(t,e,n,s){if(this.hasAction(t,e)){n();const r=[e];return s&&(typeof s=="string"?r.push(s):r.push(...s)),this.removeAction(t,r)}return t}setup(){this.cell.on("changed",this.onCellChanged,this)}onCellChanged({options:t}){this.onAttrsChange(t)}onAttrsChange(t){let e=this.flag.getChangedFlag();t.updated||!e||(t.dirty&&this.hasAction(e,"update")&&(e|=this.getFlag("render")),t.toolId&&(t.async=!1),this.graph!=null&&this.graph.renderer.requestViewUpdate(this,e,t))}parseJSONMarkup(t,e){const n=W.parseJSONMarkup(t),s=n.selectors,r=this.rootSelector;if(e&&r){if(s[r])throw new Error("Invalid root selector");s[r]=e}return n}can(t){let e=this.graph.options.interacting;if(typeof e=="function"&&(e=R(e,this.graph,this)),typeof e=="object"){let n=e[t];return typeof n=="function"&&(n=R(n,this.graph,this)),n!==!1}return typeof e=="boolean"?e:!1}cleanCache(){return this.cache.clean(),this}getCache(t){return this.cache.get(t)}getDataOfElement(t){return this.cache.getData(t)}getMatrixOfElement(t){return this.cache.getMatrix(t)}getShapeOfElement(t){return this.cache.getShape(t)}getBoundingRectOfElement(t){return this.cache.getBoundingRect(t)}getBBoxOfElement(t){const e=this.getBoundingRectOfElement(t),n=this.getMatrixOfElement(t),s=this.getRootRotatedMatrix(),r=this.getRootTranslatedMatrix();return q.transformRectangle(e,r.multiply(s).multiply(n))}getUnrotatedBBoxOfElement(t){const e=this.getBoundingRectOfElement(t),n=this.getMatrixOfElement(t),s=this.getRootTranslatedMatrix();return q.transformRectangle(e,s.multiply(n))}getBBox(t={}){let e;if(t.useCellGeometry){const n=this.cell,s=n.isNode()?n.getAngle():0;e=n.getBBox().bbox(s)}else e=this.getBBoxOfElement(this.container);return this.graph.coord.localToGraphRect(e)}getRootTranslatedMatrix(){const t=this.cell,e=t.isNode()?t.getPosition():{x:0,y:0};return ht().translate(e.x,e.y)}getRootRotatedMatrix(){let t=ht();const e=this.cell,n=e.isNode()?e.getAngle():0;if(n){const s=e.getBBox(),r=s.width/2,o=s.height/2;t=t.translate(r,o).rotate(n).translate(-r,-o)}return t}findMagnet(t=this.container){return this.findByAttr("magnet",t)}updateAttrs(t,e,n={}){n.rootBBox==null&&(n.rootBBox=new T),n.selectors==null&&(n.selectors=this.selectors),this.attr.update(t,e,n)}isEdgeElement(t){return this.cell.isEdge()&&(t==null||t===this.container)}prepareHighlight(t,e={}){const n=t||this.container;return e.partial=n===this.container,n}highlight(t,e={}){const n=this.prepareHighlight(t,e);return this.notify("cell:highlight",{magnet:n,options:e,view:this,cell:this.cell}),this.isEdgeView()?this.notify("edge:highlight",{magnet:n,options:e,view:this,edge:this.cell,cell:this.cell}):this.isNodeView()&&this.notify("node:highlight",{magnet:n,options:e,view:this,node:this.cell,cell:this.cell}),this}unhighlight(t,e={}){const n=this.prepareHighlight(t,e);return this.notify("cell:unhighlight",{magnet:n,options:e,view:this,cell:this.cell}),this.isNodeView()?this.notify("node:unhighlight",{magnet:n,options:e,view:this,node:this.cell,cell:this.cell}):this.isEdgeView()&&this.notify("edge:unhighlight",{magnet:n,options:e,view:this,edge:this.cell,cell:this.cell}),this}notifyUnhighlight(t,e){}getEdgeTerminal(t,e,n,s,r){const o=this.cell,l=this.findAttr("port",t),a=t.getAttribute("data-selector"),c={cell:o.id};return a!=null&&(c.magnet=a),l!=null?(c.port=l,o.isNode()&&!o.hasPort(l)&&a==null&&(c.selector=this.getSelector(t))):a==null&&this.container!==t&&(c.selector=this.getSelector(t)),c}getMagnetFromEdgeTerminal(t){const e=this.cell,n=this.container,s=t.port;let r=t.magnet,o;return s!=null&&e.isNode()&&e.hasPort(s)?o=this.findPortElem(s,r)||n:(r||(r=t.selector),!r&&s!=null&&(r=`[port="${s}"]`),o=this.findOne(r,n,this.selectors)),o}hasTools(t){const e=this.tools;return e==null?!1:t==null?!0:e.name===t}addTools(t){if(this.removeTools(),t){if(!this.can("toolsAddable"))return this;const e=it.isToolsView(t)?t:new it(t);this.tools=e,e.config({view:this}),e.mount()}return this}updateTools(t={}){return this.tools&&this.tools.update(t),this}removeTools(){return this.tools&&(this.tools.remove(),this.tools=null),this}hideTools(){return this.tools&&this.tools.hide(),this}showTools(){return this.tools&&this.tools.show(),this}renderTools(){const t=this.cell.getTools();return this.addTools(t),this}notify(t,e){return this.trigger(t,e),this.graph.trigger(t,e),this}getEventArgs(t,e,n){const s=this,r=s.cell;return e==null||n==null?{e:t,view:s,cell:r}:{e:t,x:e,y:n,view:s,cell:r}}onClick(t,e,n){this.notify("cell:click",this.getEventArgs(t,e,n))}onDblClick(t,e,n){this.notify("cell:dblclick",this.getEventArgs(t,e,n))}onContextMenu(t,e,n){this.notify("cell:contextmenu",this.getEventArgs(t,e,n))}onMouseDown(t,e,n){this.cell.model&&(this.cachedModelForMouseEvent=this.cell.model,this.cachedModelForMouseEvent.startBatch("mouse")),this.notify("cell:mousedown",this.getEventArgs(t,e,n))}onMouseUp(t,e,n){this.notify("cell:mouseup",this.getEventArgs(t,e,n)),this.cachedModelForMouseEvent&&(this.cachedModelForMouseEvent.stopBatch("mouse",{cell:this.cell}),this.cachedModelForMouseEvent=null)}onMouseMove(t,e,n){this.notify("cell:mousemove",this.getEventArgs(t,e,n))}onMouseOver(t){this.notify("cell:mouseover",this.getEventArgs(t))}onMouseOut(t){this.notify("cell:mouseout",this.getEventArgs(t))}onMouseEnter(t){this.notify("cell:mouseenter",this.getEventArgs(t))}onMouseLeave(t){this.notify("cell:mouseleave",this.getEventArgs(t))}onMouseWheel(t,e,n,s){this.notify("cell:mousewheel",Object.assign({delta:s},this.getEventArgs(t,e,n)))}onCustomEvent(t,e,n,s){this.notify("cell:customevent",Object.assign({name:e},this.getEventArgs(t,n,s))),this.notify(e,Object.assign({},this.getEventArgs(t,n,s)))}onMagnetMouseDown(t,e,n,s){}onMagnetDblClick(t,e,n,s){}onMagnetContextMenu(t,e,n,s){}onLabelMouseDown(t,e,n){}checkMouseleave(t){const e=this.getEventTarget(t,{fromPoint:!0}),n=this.graph.findViewByElem(e);n!==this&&(this.onMouseLeave(t),n&&n.onMouseEnter(t))}dispose(){this.cell.off("changed",this.onCellChanged,this)}}et.defaults={isSvgElement:!0,rootSelector:"root",priority:0,bootstrap:[],actions:{}};Lh([et.dispose()],et.prototype,"dispose",null);(function(i){i.Flag=Br,i.Attr=Rr})(et||(et={}));(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag],s=e;return(n==null||n===i.toStringTag)&&typeof s.isNodeView=="function"&&typeof s.isEdgeView=="function"&&typeof s.confirmUpdate=="function"}i.isCellView=t})(et||(et={}));(function(i){function t(n){return function(s){s.config({priority:n})}}i.priority=t;function e(n){return function(s){s.config({bootstrap:n})}}i.bootstrap=e})(et||(et={}));(function(i){i.registry=nt.create({type:"view"})})(et||(et={}));class it extends X{get name(){return this.options.name}get graph(){return this.cellView.graph}get cell(){return this.cellView.cell}get[Symbol.toStringTag](){return it.toStringTag}constructor(t={}){super(),this.svgContainer=this.createContainer(!0,t),this.htmlContainer=this.createContainer(!1,t),this.config(t)}createContainer(t,e){const n=t?X.createElement("g",!0):X.createElement("div",!1);return F(n,this.prefixClassName("cell-tools")),e.className&&F(n,e.className),n}config(t){if(this.options=Object.assign(Object.assign({},this.options),t),!et.isCellView(t.view)||t.view===this.cellView)return this;this.cellView=t.view,this.cell.isEdge()?(F(this.svgContainer,this.prefixClassName("edge-tools")),F(this.htmlContainer,this.prefixClassName("edge-tools"))):this.cell.isNode()&&(F(this.svgContainer,this.prefixClassName("node-tools")),F(this.htmlContainer,this.prefixClassName("node-tools"))),this.svgContainer.setAttribute("data-cell-id",this.cell.id),this.htmlContainer.setAttribute("data-cell-id",this.cell.id),this.name&&(this.svgContainer.setAttribute("data-tools-name",this.name),this.htmlContainer.setAttribute("data-tools-name",this.name));const e=this.options.items;if(!Array.isArray(e))return this;this.tools=[];const n=[];e.forEach(s=>{it.ToolItem.isToolItem(s)?s.name==="vertices"?n.unshift(s):n.push(s):(typeof s=="object"?s.name:s)==="vertices"?n.unshift(s):n.push(s)});for(let s=0;s<n.length;s+=1){const r=n[s];let o;if(it.ToolItem.isToolItem(r))o=r;else{const l=typeof r=="object"?r.name:r,a=typeof r=="object"?r.args||{}:{};if(l){if(this.cell.isNode()){const c=Se.registry.get(l);if(c)o=new c(a);else return Se.registry.onNotFound(l)}else if(this.cell.isEdge()){const c=Oe.registry.get(l);if(c)o=new c(a);else return Oe.registry.onNotFound(l)}}}o&&(o.config(this.cellView,this),o.render(),(o.options.isSVGElement!==!1?this.svgContainer:this.htmlContainer).appendChild(o.container),this.tools.push(o))}return this}update(t={}){const e=this.tools;return e&&e.forEach(n=>{t.toolId!==n.cid&&n.isVisible()&&n.update()}),this}focus(t){const e=this.tools;return e&&e.forEach(n=>{t===n?n.show():n.hide()}),this}blur(t){const e=this.tools;return e&&e.forEach(n=>{n!==t&&!n.isVisible()&&(n.show(),n.update())}),this}hide(){return this.focus(null)}show(){return this.blur(null)}remove(){const t=this.tools;return t&&(t.forEach(e=>e.remove()),this.tools=null),ye(this.svgContainer),ye(this.htmlContainer),super.remove()}mount(){const t=this.tools,e=this.cellView;if(e&&t){const n=t.some(r=>r.options.isSVGElement!==!1),s=t.some(r=>r.options.isSVGElement===!1);n&&(this.options.local?e.container:e.graph.view.decorator).appendChild(this.svgContainer),s&&this.graph.container.appendChild(this.htmlContainer)}return this}}(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag],s=e;return(n==null||n===i.toStringTag)&&s.graph!=null&&s.cell!=null&&typeof s.config=="function"&&typeof s.update=="function"&&typeof s.focus=="function"&&typeof s.blur=="function"&&typeof s.show=="function"&&typeof s.hide=="function"}i.isToolsView=t})(it||(it={}));(function(i){class t extends X{static getDefaults(){return this.defaults}static config(n){this.defaults=this.getOptions(n)}static getOptions(n){return st(K(this.getDefaults()),n)}get graph(){return this.cellView.graph}get cell(){return this.cellView.cell}get name(){return this.options.name}get[Symbol.toStringTag](){return t.toStringTag}constructor(n={}){super(),this.visible=!0,this.options=this.getOptions(n),this.container=X.createElement(this.options.tagName||"g",this.options.isSVGElement!==!1),F(this.container,this.prefixClassName("cell-tool")),typeof this.options.className=="string"&&F(this.container,this.options.className),this.init()}init(){}getOptions(n){return this.constructor.getOptions(n)}delegateEvents(){return this.options.events&&super.delegateEvents(this.options.events),this}config(n,s){return this.cellView=n,this.parent=s,this.stamp(this.container),this.cell.isEdge()?F(this.container,this.prefixClassName("edge-tool")):this.cell.isNode()&&F(this.container,this.prefixClassName("node-tool")),this.name&&this.container.setAttribute("data-tool-name",this.name),this.delegateEvents(),this}render(){this.empty();const n=this.options.markup;if(n){const s=W.parseJSONMarkup(n);this.container.appendChild(s.fragment),this.childNodes=s.selectors}return this.onRender(),this}onRender(){}update(){return this}stamp(n){n&&n.setAttribute("data-cell-id",this.cellView.cell.id)}show(){return this.container.style.display="",this.visible=!0,this}hide(){return this.container.style.display="none",this.visible=!1,this}isVisible(){return this.visible}focus(){const n=this.options.focusOpacity;return n!=null&&Number.isFinite(n)&&(this.container.style.opacity=`${n}`),this.parent.focus(this),this}blur(){return this.container.style.opacity="",this.parent.blur(this),this}guard(n){return this.graph==null||this.cellView==null?!0:this.graph.view.guard(n,this.cellView)}}t.defaults={isSVGElement:!0,tagName:"g"},i.ToolItem=t,function(e){let n=0;function s(o){return o?ms(o):(n+=1,`CustomTool${n}`)}function r(o){const l=gs(s(o.name),this);return l.config(o),l}e.define=r}(t=i.ToolItem||(i.ToolItem={})),function(e){e.toStringTag=`X6.${e.name}`;function n(s){if(s==null)return!1;if(s instanceof e)return!0;const r=s[Symbol.toStringTag],o=s;return(r==null||r===e.toStringTag)&&o.graph!=null&&o.cell!=null&&typeof o.config=="function"&&typeof o.update=="function"&&typeof o.focus=="function"&&typeof o.blur=="function"&&typeof o.show=="function"&&typeof o.hide=="function"&&typeof o.isVisible=="function"}e.isToolItem=n}(t=i.ToolItem||(i.ToolItem={}))})(it||(it={}));const kh=i=>i;function ii(i,t){return t===0?"0%":`${Math.round(i/t*100)}%`}function $r(i){return(e,n,s,r)=>n.isEdgeElement(s)?Ih(i,e,n,s,r):Dh(i,e,n,s,r)}function Dh(i,t,e,n,s){const r=e.cell,o=r.getAngle(),l=e.getUnrotatedBBoxOfElement(n),a=r.getBBox().getCenter(),c=w.create(s).rotate(o,a);let h=c.x-l.x,u=c.y-l.y;return i&&(h=ii(h,l.width),u=ii(u,l.height)),t.anchor={name:"topLeft",args:{dx:h,dy:u,rotate:!0}},t}function Ih(i,t,e,n,s){const r=e.getConnection();if(!r)return t;const o=r.closestPointLength(s);if(i){const l=r.length();t.anchor={name:"ratio",args:{ratio:o/l}}}else t.anchor={name:"length",args:{length:o}};return t}const Rh=$r(!0),Bh=$r(!1),$h=Object.freeze(Object.defineProperty({__proto__:null,noop:kh,pinAbsolute:Bh,pinRelative:Rh},Symbol.toStringTag,{value:"Module"}));var cs;(function(i){i.presets=$h,i.registry=nt.create({type:"connection strategy"}),i.registry.register(i.presets,!0)})(cs||(cs={}));function Vr(i,t,e,n){return R(cs.presets.pinRelative,this.graph,{},t,e,i,this.cell,n,{}).anchor}function zr(i,t){return t?i.cell.getBBox():i.cell.isEdge()?i.getConnection().bbox():i.getUnrotatedBBoxOfElement(i.container)}class Kt extends it.ToolItem{onRender(){F(this.container,this.prefixClassName("cell-tool-button")),this.update()}update(){return this.updatePosition(),this}updatePosition(){const e=this.cellView.cell.isEdge()?this.getEdgeMatrix():this.getNodeMatrix();be(this.container,e,{absolute:!0})}getNodeMatrix(){const t=this.cellView,e=this.options;let{x:n=0,y:s=0}=e;const{offset:r,useCellGeometry:o,rotate:l}=e;let a=zr(t,o);const c=t.cell.getAngle();l||(a=a.bbox(c));let h=0,u=0;typeof r=="number"?(h=r,u=r):typeof r=="object"&&(h=r.x,u=r.y),n=Ct(n,a.width),s=Ct(s,a.height);let f=ht().translate(a.x+a.width/2,a.y+a.height/2);return l&&(f=f.rotate(c)),f=f.translate(n+h-a.width/2,s+u-a.height/2),f}getEdgeMatrix(){const t=this.cellView,e=this.options,{offset:n=0,distance:s=0,rotate:r}=e;let o,l,a;const c=Ct(s,1);c>=0&&c<=1?o=t.getTangentAtRatio(c):o=t.getTangentAtLength(c),o?(l=o.start,a=o.vector().vectorAngle(new w(1,0))||0):(l=t.getConnection().start,a=0);let h=ht().translate(l.x,l.y).rotate(a);return typeof n=="object"?h=h.translate(n.x||0,n.y||0):h=h.translate(0,n),r||(h=h.rotate(-a)),h}onMouseDown(t){if(this.guard(t))return;t.stopPropagation(),t.preventDefault();const e=this.options.onClick;typeof e=="function"&&R(e,this.cellView,{e:t,view:this.cellView,cell:this.cellView.cell,btn:this})}}(function(i){i.config({name:"button",useCellGeometry:!0,events:{mousedown:"onMouseDown",touchstart:"onMouseDown"}})})(Kt||(Kt={}));(function(i){i.Remove=i.define({name:"button-remove",markup:[{tagName:"circle",selector:"button",attrs:{r:7,fill:"#FF1D00",cursor:"pointer"}},{tagName:"path",selector:"icon",attrs:{d:"M -3 -3 3 3 M -3 3 3 -3",fill:"none",stroke:"#FFFFFF","stroke-width":2,"pointer-events":"none"}}],distance:60,offset:0,useCellGeometry:!0,onClick({view:t,btn:e}){e.parent.remove(),t.cell.remove({ui:!0,toolId:e.cid})}})})(Kt||(Kt={}));var Vh=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};class On extends it.ToolItem{onRender(){if(F(this.container,this.prefixClassName("cell-tool-boundary")),this.options.attrs){const t=this.options.attrs,{class:e}=t,n=Vh(t,["class"]);G(this.container,Ue(n)),e&&F(this.container,e)}this.update()}update(){const t=this.cellView,e=this.options,{useCellGeometry:n,rotate:s}=e,r=ce(e.padding);let o=zr(t,n).moveAndExpand({x:-r.left,y:-r.top,width:r.left+r.right,height:r.top+r.bottom});const l=t.cell;if(l.isNode()){const a=l.getAngle();if(a)if(s){const c=l.getBBox().getCenter();ss(this.container,a,c.x,c.y,{absolute:!0})}else o=o.bbox(a)}return G(this.container,o.toJSON()),this}}(function(i){i.config({name:"boundary",tagName:"rect",padding:10,useCellGeometry:!0,attrs:{fill:"none",stroke:"#333","stroke-width":.5,"stroke-dasharray":"5, 5","pointer-events":"none"}})})(On||(On={}));class Ze extends it.ToolItem{constructor(){super(...arguments),this.handles=[]}get vertices(){return this.cellView.cell.getVertices()}onRender(){return this.addClass(this.prefixClassName("edge-tool-vertices")),this.options.addable&&this.updatePath(),this.resetHandles(),this.renderHandles(),this}update(){return this.vertices.length===this.handles.length?this.updateHandles():(this.resetHandles(),this.renderHandles()),this.options.addable&&this.updatePath(),this}resetHandles(){const t=this.handles;this.handles=[],t&&t.forEach(e=>{this.stopHandleListening(e),e.remove()})}renderHandles(){const t=this.vertices;for(let e=0,n=t.length;e<n;e+=1){const s=t[e],r=this.options.createHandle,o=this.options.processHandle,l=r({index:e,graph:this.graph,guard:a=>this.guard(a),attrs:this.options.attrs||{}});o&&o(l),l.updatePosition(s.x,s.y),this.stamp(l.container),this.container.appendChild(l.container),this.handles.push(l),this.startHandleListening(l)}}updateHandles(){const t=this.vertices;for(let e=0,n=t.length;e<n;e+=1){const s=t[e],r=this.handles[e];r&&r.updatePosition(s.x,s.y)}}updatePath(){const t=this.childNodes.connection;t&&t.setAttribute("d",this.cellView.getConnectionPathData())}startHandleListening(t){const e=this.cellView;e.can("vertexMovable")&&(t.on("change",this.onHandleChange,this),t.on("changing",this.onHandleChanging,this),t.on("changed",this.onHandleChanged,this)),e.can("vertexDeletable")&&t.on("remove",this.onHandleRemove,this)}stopHandleListening(t){const e=this.cellView;e.can("vertexMovable")&&(t.off("change",this.onHandleChange,this),t.off("changing",this.onHandleChanging,this),t.off("changed",this.onHandleChanged,this)),e.can("vertexDeletable")&&t.off("remove",this.onHandleRemove,this)}getNeighborPoints(t){const e=this.cellView,n=this.vertices,s=t>0?n[t-1]:e.sourceAnchor,r=t<n.length-1?n[t+1]:e.targetAnchor;return{prev:w.create(s),next:w.create(r)}}getMouseEventArgs(t){const e=this.normalizeEvent(t),{x:n,y:s}=this.graph.snapToGrid(e.clientX,e.clientY);return{e,x:n,y:s}}onHandleChange({e:t}){this.focus();const e=this.cellView;if(e.cell.startBatch("move-vertex",{ui:!0,toolId:this.cid}),!this.options.stopPropagation){const{e:n,x:s,y:r}=this.getMouseEventArgs(t);this.eventData(n,{start:{x:s,y:r}}),e.notifyMouseDown(n,s,r)}}onHandleChanging({handle:t,e}){const n=this.cellView,s=t.options.index,{e:r,x:o,y:l}=this.getMouseEventArgs(e),a={x:o,y:l};this.snapVertex(a,s),n.cell.setVertexAt(s,a,{ui:!0,toolId:this.cid}),t.updatePosition(a.x,a.y),this.options.stopPropagation||n.notifyMouseMove(r,o,l)}stopBatch(t){this.cell.stopBatch("move-vertex",{ui:!0,toolId:this.cid}),t&&this.cell.stopBatch("add-vertex",{ui:!0,toolId:this.cid})}onHandleChanged({e:t}){const e=this.options,n=this.cellView;if(e.addable&&this.updatePath(),!e.removeRedundancies){this.stopBatch(this.eventData(t).vertexAdded);return}n.removeRedundantLinearVertices({ui:!0,toolId:this.cid})&&this.render(),this.blur(),this.stopBatch(this.eventData(t).vertexAdded);const{e:r,x:o,y:l}=this.getMouseEventArgs(t);if(!this.options.stopPropagation){n.notifyMouseUp(r,o,l);const{start:a}=this.eventData(r);if(a){const{x:c,y:h}=a;c===o&&h===l&&n.onClick(r,o,l)}}n.checkMouseleave(r),e.onChanged&&e.onChanged({edge:n.cell,edgeView:n})}snapVertex(t,e){const n=this.options.snapRadius||0;if(n>0){const s=this.getNeighborPoints(e),r=s.prev,o=s.next;Math.abs(t.x-r.x)<n?t.x=r.x:Math.abs(t.x-o.x)<n&&(t.x=o.x),Math.abs(t.y-r.y)<n?t.y=s.prev.y:Math.abs(t.y-o.y)<n&&(t.y=o.y)}}onHandleRemove({handle:t,e}){if(this.options.removable){const n=t.options.index,s=this.cellView;s.cell.removeVertexAt(n,{ui:!0}),this.options.addable&&this.updatePath(),s.checkMouseleave(this.normalizeEvent(e))}}allowAddVertex(t){const e=this.guard(t),n=this.options.addable&&this.cellView.can("vertexAddable"),s=this.options.modifiers?xe.isMatch(t,this.options.modifiers):!0;return!e&&n&&s}onPathMouseDown(t){const e=this.cellView;if(!this.allowAddVertex(t))return;t.stopPropagation(),t.preventDefault();const n=this.normalizeEvent(t),s=this.graph.snapToGrid(n.clientX,n.clientY).toJSON();e.cell.startBatch("add-vertex",{ui:!0,toolId:this.cid});const r=e.getVertexIndex(s.x,s.y);this.snapVertex(s,r),e.cell.insertVertex(s,r,{ui:!0,toolId:this.cid}),this.render();const o=this.handles[r];this.eventData(n,{vertexAdded:!0}),o.onMouseDown(n)}onRemove(){this.resetHandles()}}(function(i){class t extends X{get graph(){return this.options.graph}constructor(n){super(),this.options=n,this.render(),this.delegateEvents({mousedown:"onMouseDown",touchstart:"onMouseDown",dblclick:"onDoubleClick"})}render(){this.container=X.createElement("circle",!0);const n=this.options.attrs;if(typeof n=="function"){const s=i.getDefaults();this.setAttrs(Object.assign(Object.assign({},s.attrs),n(this)))}else this.setAttrs(n);this.addClass(this.prefixClassName("edge-tool-vertex"))}updatePosition(n,s){this.setAttrs({cx:n,cy:s})}onMouseDown(n){this.options.guard(n)||(n.stopPropagation(),n.preventDefault(),this.graph.view.undelegateEvents(),this.delegateDocumentEvents({mousemove:"onMouseMove",touchmove:"onMouseMove",mouseup:"onMouseUp",touchend:"onMouseUp",touchcancel:"onMouseUp"},n.data),this.emit("change",{e:n,handle:this}))}onMouseMove(n){this.emit("changing",{e:n,handle:this})}onMouseUp(n){this.emit("changed",{e:n,handle:this}),this.undelegateDocumentEvents(),this.graph.view.delegateEvents()}onDoubleClick(n){this.emit("remove",{e:n,handle:this})}}i.Handle=t})(Ze||(Ze={}));(function(i){const t=Ot.prefix("edge-tool-vertex-path");i.config({name:"vertices",snapRadius:20,addable:!0,removable:!0,removeRedundancies:!0,stopPropagation:!0,attrs:{r:6,fill:"#333",stroke:"#fff",cursor:"move","stroke-width":2},createHandle:e=>new i.Handle(e),markup:[{tagName:"path",selector:"connection",className:t,attrs:{fill:"none",stroke:"transparent","stroke-width":10,cursor:"pointer"}}],events:{[`mousedown .${t}`]:"onPathMouseDown",[`touchstart .${t}`]:"onPathMouseDown"}})})(Ze||(Ze={}));class Ke extends it.ToolItem{constructor(){super(...arguments),this.handles=[]}get vertices(){return this.cellView.cell.getVertices()}update(){return this.render(),this}onRender(){F(this.container,this.prefixClassName("edge-tool-segments")),this.resetHandles();const t=this.cellView,e=[...this.vertices];e.unshift(t.sourcePoint),e.push(t.targetPoint);for(let n=0,s=e.length;n<s-1;n+=1){const r=e[n],o=e[n+1],l=this.renderHandle(r,o,n);this.stamp(l.container),this.handles.push(l)}return this}renderHandle(t,e,n){const s=this.options.createHandle({index:n,graph:this.graph,guard:r=>this.guard(r),attrs:this.options.attrs||{}});return this.options.processHandle&&this.options.processHandle(s),this.updateHandle(s,t,e),this.container.appendChild(s.container),this.startHandleListening(s),s}startHandleListening(t){t.on("change",this.onHandleChange,this),t.on("changing",this.onHandleChanging,this),t.on("changed",this.onHandleChanged,this)}stopHandleListening(t){t.off("change",this.onHandleChange,this),t.off("changing",this.onHandleChanging,this),t.off("changed",this.onHandleChanged,this)}resetHandles(){const t=this.handles;this.handles=[],t&&t.forEach(e=>{this.stopHandleListening(e),e.remove()})}shiftHandleIndexes(t){const e=this.handles;for(let n=0,s=e.length;n<s;n+=1)e[n].options.index+=t}resetAnchor(t,e){const n=this.cellView.cell,s={ui:!0,toolId:this.cid};e?n.prop([t,"anchor"],e,s):n.removeProp([t,"anchor"],s)}snapHandle(t,e,n){const s=t.options.axis,r=t.options.index,a=this.cellView.cell.getVertices(),c=a[r-2]||n.sourceAnchor,h=a[r+1]||n.targetAnchor,u=this.options.snapRadius;return Math.abs(e[s]-c[s])<u?e[s]=c[s]:Math.abs(e[s]-h[s])<u&&(e[s]=h[s]),e}onHandleChanging({handle:t,e}){const n=this.graph,s=this.options,r=this.cellView,o=s.anchor,l=t.options.axis,a=t.options.index-1,c=this.getEventData(e),h=this.normalizeEvent(e),u=n.snapToGrid(h.clientX,h.clientY),f=this.snapHandle(t,u.clone(),c),d=K(this.vertices);let g=d[a],p=d[a+1];const m=r.sourceView,b=r.sourceBBox;let x=!1,y=!1;if(g?a===0?b.containsPoint(g)?(d.shift(),this.shiftHandleIndexes(-1),x=!0):(g[l]=f[l],y=!0):g[l]=f[l]:(g=r.sourceAnchor.toJSON(),g[l]=f[l],b.containsPoint(g)?x=!0:(d.unshift(g),this.shiftHandleIndexes(1),y=!0)),typeof o=="function"&&m){if(x){const N=c.sourceAnchor.clone();N[l]=f[l];const M=R(o,r,N,m,r.sourceMagnet||m.container,"source",r,this);this.resetAnchor("source",M)}y&&this.resetAnchor("source",c.sourceAnchorDef)}const v=r.targetView,P=r.targetBBox;let C=!1,O=!1;if(p?a===d.length-2?P.containsPoint(p)?(d.pop(),C=!0):(p[l]=f[l],O=!0):p[l]=f[l]:(p=r.targetAnchor.toJSON(),p[l]=f[l],P.containsPoint(p)?C=!0:(d.push(p),O=!0)),typeof o=="function"&&v){if(C){const N=c.targetAnchor.clone();N[l]=f[l];const M=R(o,r,N,v,r.targetMagnet||v.container,"target",r,this);this.resetAnchor("target",M)}O&&this.resetAnchor("target",c.targetAnchorDef)}w.equalPoints(d,this.vertices)||this.cellView.cell.setVertices(d,{ui:!0,toolId:this.cid}),this.updateHandle(t,g,p,0),s.stopPropagation||r.notifyMouseMove(h,u.x,u.y)}onHandleChange({handle:t,e}){const n=this.options,s=this.handles,r=this.cellView,o=t.options.index;if(Array.isArray(s)){for(let l=0,a=s.length;l<a;l+=1)l!==o&&s[l].hide();if(this.focus(),this.setEventData(e,{sourceAnchor:r.sourceAnchor.clone(),targetAnchor:r.targetAnchor.clone(),sourceAnchorDef:K(this.cell.prop(["source","anchor"])),targetAnchorDef:K(this.cell.prop(["target","anchor"]))}),this.cell.startBatch("move-segment",{ui:!0,toolId:this.cid}),!n.stopPropagation){const l=this.normalizeEvent(e),a=this.graph.snapToGrid(l.clientX,l.clientY);r.notifyMouseDown(l,a.x,a.y)}}}onHandleChanged({e:t}){const e=this.options,n=this.cellView;e.removeRedundancies&&n.removeRedundantLinearVertices({ui:!0,toolId:this.cid});const s=this.normalizeEvent(t),r=this.graph.snapToGrid(s.clientX,s.clientY);this.render(),this.blur(),this.cell.stopBatch("move-segment",{ui:!0,toolId:this.cid}),e.stopPropagation||n.notifyMouseUp(s,r.x,r.y),n.checkMouseleave(s),e.onChanged&&e.onChanged({edge:n.cell,edgeView:n})}updateHandle(t,e,n,s=0){const r=this.options.precision||0,o=Math.abs(e.x-n.x)<r,l=Math.abs(e.y-n.y)<r;if(o||l){const a=new L(e,n);if(a.length()<this.options.threshold)t.hide();else{const h=a.getCenter(),u=o?"x":"y";h[u]+=s||0;const f=a.vector().vectorAngle(new w(1,0));t.updatePosition(h.x,h.y,f,this.cellView),t.show(),t.options.axis=u}}else t.hide()}onRemove(){this.resetHandles()}}(function(i){class t extends X{constructor(n){super(),this.options=n,this.render(),this.delegateEvents({mousedown:"onMouseDown",touchstart:"onMouseDown"})}render(){this.container=X.createElement("rect",!0);const n=this.options.attrs;if(typeof n=="function"){const s=i.getDefaults();this.setAttrs(Object.assign(Object.assign({},s.attrs),n(this)))}else this.setAttrs(n);this.addClass(this.prefixClassName("edge-tool-segment"))}updatePosition(n,s,r,o){const l=o.getClosestPoint(new w(n,s))||new w(n,s);let a=ht().translate(l.x,l.y);if(l.equals({x:n,y:s}))a=a.rotate(r);else{let h=new L(n,s,l.x,l.y).vector().vectorAngle(new w(1,0));h!==0&&(h+=90),a=a.rotate(h)}this.setAttrs({transform:Ie(a),cursor:r%180===0?"row-resize":"col-resize"})}onMouseDown(n){this.options.guard(n)||(this.trigger("change",{e:n,handle:this}),n.stopPropagation(),n.preventDefault(),this.options.graph.view.undelegateEvents(),this.delegateDocumentEvents({mousemove:"onMouseMove",touchmove:"onMouseMove",mouseup:"onMouseUp",touchend:"onMouseUp",touchcancel:"onMouseUp"},n.data))}onMouseMove(n){this.emit("changing",{e:n,handle:this})}onMouseUp(n){this.emit("changed",{e:n,handle:this}),this.undelegateDocumentEvents(),this.options.graph.view.delegateEvents()}show(){this.container.style.display=""}hide(){this.container.style.display="none"}}i.Handle=t})(Ke||(Ke={}));(function(i){i.config({name:"segments",precision:.5,threshold:40,snapRadius:10,stopPropagation:!0,removeRedundancies:!0,attrs:{width:20,height:8,x:-10,y:-4,rx:4,ry:4,fill:"#333",stroke:"#fff","stroke-width":2},createHandle:t=>new i.Handle(t),anchor:Vr})})(Ke||(Ke={}));class Mn extends it.ToolItem{get type(){return this.options.type}onRender(){F(this.container,this.prefixClassName(`edge-tool-${this.type}-anchor`)),this.toggleArea(!1),this.update()}update(){const t=this.type;return this.cellView.getTerminalView(t)?(this.updateAnchor(),this.updateArea(),this.container.style.display=""):this.container.style.display="none",this}updateAnchor(){const t=this.childNodes;if(!t)return;const e=t.anchor;if(!e)return;const n=this.type,s=this.cellView,r=this.options,o=s.getTerminalAnchor(n),l=s.cell.prop([n,"anchor"]);e.setAttribute("transform",`translate(${o.x}, ${o.y})`);const a=l?r.customAnchorAttrs:r.defaultAnchorAttrs;a&&Object.keys(a).forEach(c=>{e.setAttribute(c,a[c])})}updateArea(){const t=this.childNodes;if(!t)return;const e=t.area;if(!e)return;const n=this.type,s=this.cellView,r=s.getTerminalView(n);if(r){const o=r.cell,l=s.getTerminalMagnet(n);let a=this.options.areaPadding||0;Number.isFinite(a)||(a=0);let c,h,u;r.isEdgeElement(l)?(c=r.getBBox(),h=0,u=c.getCenter()):(c=r.getUnrotatedBBoxOfElement(l),h=o.getAngle(),u=c.getCenter(),h&&u.rotate(-h,o.getBBox().getCenter())),c.inflate(a),G(e,{x:-c.width/2,y:-c.height/2,width:c.width,height:c.height,transform:`translate(${u.x}, ${u.y}) rotate(${h})`})}}toggleArea(t){if(this.childNodes){const e=this.childNodes.area;e&&(e.style.display=t?"":"none")}}onMouseDown(t){this.guard(t)||(t.stopPropagation(),t.preventDefault(),this.graph.view.undelegateEvents(),this.options.documentEvents&&this.delegateDocumentEvents(this.options.documentEvents),this.focus(),this.toggleArea(this.options.restrictArea),this.cell.startBatch("move-anchor",{ui:!0,toolId:this.cid}))}resetAnchor(t){const e=this.type,n=this.cell;t?n.prop([e,"anchor"],t,{rewrite:!0,ui:!0,toolId:this.cid}):n.removeProp([e,"anchor"],{ui:!0,toolId:this.cid})}onMouseMove(t){const e=this.type,n=this.cellView,s=n.getTerminalView(e);if(s==null)return;const r=this.normalizeEvent(t),o=s.cell,l=n.getTerminalMagnet(e);let a=this.graph.coord.clientToLocalPoint(r.clientX,r.clientY);const c=this.options.snap;if(typeof c=="function"){const f=R(c,n,a,s,l,e,n,this);a=w.create(f)}if(this.options.restrictArea)if(s.isEdgeElement(l)){const f=s.getClosestPoint(a);f&&(a=f)}else{const f=s.getUnrotatedBBoxOfElement(l),d=o.getAngle(),g=o.getBBox().getCenter(),p=a.clone().rotate(d,g);f.containsPoint(p)||(a=f.getNearestPointToPoint(p).rotate(-d,g))}let h;const u=this.options.anchor;typeof u=="function"&&(h=R(u,n,a,s,l,e,n,this)),this.resetAnchor(h),this.update()}onMouseUp(t){this.graph.view.delegateEvents(),this.undelegateDocumentEvents(),this.blur(),this.toggleArea(!1);const e=this.cellView;this.options.removeRedundancies&&e.removeRedundantLinearVertices({ui:!0,toolId:this.cid}),this.cell.stopBatch("move-anchor",{ui:!0,toolId:this.cid})}onDblClick(){const t=this.options.resetAnchor;t&&this.resetAnchor(t===!0?void 0:t),this.update()}}(function(i){i.config({tagName:"g",markup:[{tagName:"circle",selector:"anchor",attrs:{cursor:"pointer"}},{tagName:"rect",selector:"area",attrs:{"pointer-events":"none",fill:"none",stroke:"#33334F","stroke-dasharray":"2,4",rx:5,ry:5}}],events:{mousedown:"onMouseDown",touchstart:"onMouseDown",dblclick:"onDblClick"},documentEvents:{mousemove:"onMouseMove",touchmove:"onMouseMove",mouseup:"onMouseUp",touchend:"onMouseUp",touchcancel:"onMouseUp"},customAnchorAttrs:{"stroke-width":4,stroke:"#33334F",fill:"#FFFFFF",r:5},defaultAnchorAttrs:{"stroke-width":2,stroke:"#FFFFFF",fill:"#33334F",r:6},areaPadding:6,snapRadius:10,resetAnchor:!0,restrictArea:!0,removeRedundancies:!0,anchor:Vr,snap(t,e,n,s,r,o){const l=o.options.snapRadius||0,a=s==="source",c=a?0:-1,h=this.cell.getVertexAt(c)||this.getTerminalAnchor(a?"target":"source");return h&&(Math.abs(h.x-t.x)<l&&(t.x=h.x),Math.abs(h.y-t.y)<l&&(t.y=h.y)),t}})})(Mn||(Mn={}));const zh=Mn.define({name:"source-anchor",type:"source"}),Fh=Mn.define({name:"target-anchor",type:"target"});var qh=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};class En extends it.ToolItem{get type(){return this.options.type}get ratio(){return this.options.ratio}init(){if(this.options.attrs){const t=this.options.attrs,{class:e}=t,n=qh(t,["class"]);this.setAttrs(n,this.container),e&&F(this.container,e)}}onRender(){F(this.container,this.prefixClassName(`edge-tool-${this.type}-arrowhead`)),this.update()}update(){const t=this.ratio,e=this.cellView,n=e.getTangentAtRatio(t),s=n?n.start:e.getPointAtRatio(t),r=n&&n.vector().vectorAngle(new w(1,0))||0;if(!s)return this;const o=ht().translate(s.x,s.y).rotate(r);return be(this.container,o,{absolute:!0}),this}onMouseDown(t){if(this.guard(t))return;t.stopPropagation(),t.preventDefault();const e=this.cellView;if(e.can("arrowheadMovable")){e.cell.startBatch("move-arrowhead",{ui:!0,toolId:this.cid});const n=this.graph.snapToGrid(t.clientX,t.clientY),s=e.prepareArrowheadDragging(this.type,{x:n.x,y:n.y,options:Object.assign(Object.assign({},this.options),{toolId:this.cid})});this.cellView.setEventData(t,s),this.delegateDocumentEvents(this.options.documentEvents,t.data),e.graph.view.undelegateEvents(),this.container.style.pointerEvents="none"}this.focus()}onMouseMove(t){const e=this.normalizeEvent(t),n=this.graph.snapToGrid(e.clientX,e.clientY);this.cellView.onMouseMove(e,n.x,n.y),this.update()}onMouseUp(t){this.undelegateDocumentEvents();const e=this.normalizeEvent(t),n=this.cellView,s=this.graph.snapToGrid(e.clientX,e.clientY);n.onMouseUp(e,s.x,s.y),this.graph.view.delegateEvents(),this.blur(),this.container.style.pointerEvents="",n.cell.stopBatch("move-arrowhead",{ui:!0,toolId:this.cid})}}(function(i){i.config({tagName:"path",isSVGElement:!0,events:{mousedown:"onMouseDown",touchstart:"onMouseDown"},documentEvents:{mousemove:"onMouseMove",touchmove:"onMouseMove",mouseup:"onMouseUp",touchend:"onMouseUp",touchcancel:"onMouseUp"}})})(En||(En={}));const Hh=En.define({name:"source-arrowhead",type:"source",ratio:0,attrs:{d:"M 10 -8 -10 0 10 8 Z",fill:"#333",stroke:"#fff","stroke-width":2,cursor:"move"}}),Gh=En.define({name:"target-arrowhead",type:"target",ratio:1,attrs:{d:"M -10 -8 10 0 -10 8 Z",fill:"#333",stroke:"#fff","stroke-width":2,cursor:"move"}});class Ae extends it.ToolItem{constructor(){super(...arguments),this.labelIndex=-1,this.distance=.5,this.dblClick=this.onCellDblClick.bind(this)}onRender(){const t=this.cellView;t&&t.on("cell:dblclick",this.dblClick)}createElement(){const t=[this.prefixClassName(`${this.cell.isEdge()?"edge":"node"}-tool-editor`),this.prefixClassName("cell-tool-editor")];this.editor=it.createElement("div",!1),this.addClass(t,this.editor),this.editor.contentEditable="true",this.container.appendChild(this.editor)}removeElement(){this.undelegateDocumentEvents(),this.editor&&(this.container.removeChild(this.editor),this.editor=null)}updateEditor(){const{cell:t,editor:e}=this;if(!e)return;const{style:n}=e;t.isNode()?this.updateNodeEditorTransform():t.isEdge()&&this.updateEdgeEditorTransform();const{attrs:s}=this.options;n.fontSize=`${s.fontSize}px`,n.fontFamily=s.fontFamily,n.color=s.color,n.backgroundColor=s.backgroundColor;const r=this.getCellText()||"";return e.innerText=r,this.setCellText(""),this}updateNodeEditorTransform(){const{graph:t,cell:e,editor:n}=this;if(!n)return;let s=w.create(),r=20,o="",{x:l,y:a}=this.options;const{width:c,height:h}=this.options;if(typeof l!="undefined"&&typeof a!="undefined"){const d=e.getBBox();l=Ct(l,d.width),a=Ct(a,d.height),s=d.topLeft.translate(l,a),r=d.width-l*2}else{const d=e.getBBox();s=d.center,r=d.width-4,o="translate(-50%, -50%)"}const u=t.scale(),{style:f}=n;s=t.localToGraph(s),f.left=`${s.x}px`,f.top=`${s.y}px`,f.transform=`scale(${u.sx}, ${u.sy}) ${o}`,f.minWidth=`${r}px`,typeof c=="number"&&(f.width=`${c}px`),typeof h=="number"&&(f.height=`${h}px`)}updateEdgeEditorTransform(){if(!this.event)return;const{graph:t,editor:e}=this;if(!e)return;let n=w.create(),s=20;const{style:r}=e,o=this.event.target,l=o.parentElement;if(l&&De(l,this.prefixClassName("edge-label"))){const h=l.getAttribute("data-index")||"0";this.labelIndex=parseInt(h,10);const u=l.getAttribute("transform"),{translation:f}=In(u);n=new w(f.tx,f.ty),s=q.getBBox(o).width}else{if(!this.options.labelAddable)return this;n=t.clientToLocal(w.create(this.event.clientX,this.event.clientY));const u=this.cellView.path.closestPointLength(n);this.distance=u,this.labelIndex=-1}n=t.localToGraph(n);const c=t.scale();r.left=`${n.x}px`,r.top=`${n.y}px`,r.minWidth=`${s}px`,r.transform=`scale(${c.sx}, ${c.sy}) translate(-50%, -50%)`}onDocumentMouseUp(t){if(this.editor&&t.target!==this.editor){const e=this.editor.innerText.replace(/\n$/,"")||"";this.setCellText(e!==""?e:null),this.removeElement()}}onCellDblClick({e:t}){this.editor||(t.stopPropagation(),this.removeElement(),this.event=t,this.createElement(),this.updateEditor(),this.autoFocus(),this.delegateDocumentEvents(this.options.documentEvents))}onMouseDown(t){t.stopPropagation()}autoFocus(){setTimeout(()=>{this.editor&&(this.editor.focus(),this.selectText())})}selectText(){if(window.getSelection&&this.editor){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(this.editor),e.removeAllRanges(),e.addRange(t)}}getCellText(){const{getText:t}=this.options;if(typeof t=="function")return R(t,this.cellView,{cell:this.cell,index:this.labelIndex});if(typeof t=="string"){if(this.cell.isNode())return this.cell.attr(t);if(this.cell.isEdge()&&this.labelIndex!==-1)return this.cell.prop(`labels/${this.labelIndex}/attrs/${t}`)}}setCellText(t){const e=this.options.setText;if(typeof e=="function"){R(e,this.cellView,{cell:this.cell,value:t,index:this.labelIndex,distance:this.distance});return}if(typeof e=="string"){if(this.cell.isNode()){t!==null&&this.cell.attr(e,t);return}if(this.cell.isEdge()){const n=this.cell;if(this.labelIndex===-1){if(t){const s={position:{distance:this.distance},attrs:{}};ke(s,`attrs/${e}`,t),n.appendLabel(s)}}else t!==null?n.prop(`labels/${this.labelIndex}/attrs/${e}`,t):typeof this.labelIndex=="number"&&n.removeLabelAt(this.labelIndex)}}}onRemove(){const t=this.cellView;t&&t.off("cell:dblclick",this.dblClick),this.removeElement()}}(function(i){i.config({tagName:"div",isSVGElement:!1,events:{mousedown:"onMouseDown",touchstart:"onMouseDown"},documentEvents:{mouseup:"onDocumentMouseUp",touchend:"onDocumentMouseUp",touchcancel:"onDocumentMouseUp"}})})(Ae||(Ae={}));(function(i){i.NodeEditor=i.define({attrs:{fontSize:14,fontFamily:"Arial, helvetica, sans-serif",color:"#000",backgroundColor:"#fff"},getText:"text/text",setText:"text/text"}),i.EdgeEditor=i.define({attrs:{fontSize:14,fontFamily:"Arial, helvetica, sans-serif",color:"#000",backgroundColor:"#fff"},labelAddable:!0,getText:"label/text",setText:"label/text"})})(Ae||(Ae={}));var Fr=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e},Se;(function(i){i.presets={boundary:On,button:Kt,"button-remove":Kt.Remove,"node-editor":Ae.NodeEditor},i.registry=nt.create({type:"node tool",process(t,e){if(typeof e=="function")return e;let n=it.ToolItem;const{inherit:s}=e,r=Fr(e,["inherit"]);if(s){const o=this.get(s);o==null?this.onNotFound(s,"inherited"):n=o}return r.name==null&&(r.name=t),n.define.call(n,r)}}),i.registry.register(i.presets,!0)})(Se||(Se={}));var Oe;(function(i){i.presets={boundary:On,vertices:Ze,segments:Ke,button:Kt,"button-remove":Kt.Remove,"source-anchor":zh,"target-anchor":Fh,"source-arrowhead":Hh,"target-arrowhead":Gh,"edge-editor":Ae.EdgeEditor},i.registry=nt.create({type:"edge tool",process(t,e){if(typeof e=="function")return e;let n=it.ToolItem;const{inherit:s}=e,r=Fr(e,["inherit"]);if(s){const o=this.get(s);o==null?this.onNotFound(s,"inherited"):n=o}return r.name==null&&(r.name=t),n.define.call(n,r)}}),i.registry.register(i.presets,!0)})(Oe||(Oe={}));const _h=qt("center"),Uh=qt("topCenter"),Wh=qt("bottomCenter"),Xh=qt("leftMiddle"),Jh=qt("rightMiddle"),Yh=qt("topLeft"),Zh=qt("topRight"),Kh=qt("bottomLeft"),Qh=qt("bottomRight");function qt(i){return function(t,e,n,s={}){const r=s.rotate?t.getUnrotatedBBoxOfElement(e):t.getBBoxOfElement(e),o=r[i];o.x+=Ct(s.dx,r.width),o.y+=Ct(s.dy,r.height);const l=t.cell;return s.rotate?o.rotate(-l.getAngle(),l.getBBox().getCenter()):o}}function Vn(i){return function(t,e,n,s){if(n instanceof Element){const r=this.graph.findViewByElem(n);let o;if(r)if(r.isEdgeElement(n)){const l=s.fixedAt!=null?s.fixedAt:"50%";o=qr(r,l)}else o=r.getBBoxOfElement(n).getCenter();else o=new w;return i.call(this,t,e,o,s)}return i.apply(this,arguments)}}function qr(i,t){const e=$t(t),n=typeof t=="string"?parseFloat(t):t;return e?i.getPointAtRatio(n/100):i.getPointAtLength(n)}const tu=function(i,t,e,n){const s=i.cell.getAngle(),r=i.getBBoxOfElement(t),o=r.getCenter(),l=r.getTopLeft(),a=r.getBottomRight();let c=n.padding;if(Number.isFinite(c)||(c=0),l.y+c<=e.y&&e.y<=a.y-c){const h=e.y-o.y;o.x+=s===0||s===180?0:h*1/Math.tan(U.toRad(s)),o.y+=h}else if(l.x+c<=e.x&&e.x<=a.x-c){const h=e.x-o.x;o.y+=s===90||s===270?0:h*Math.tan(U.toRad(s)),o.x+=h}return o},eu=Vn(tu),nu=function(i,t,e,n,s){const r=i.cell.getConnectionPoint(this.cell,s);return(n.dx||n.dy)&&r.translate(n.dx||0,n.dy||0),r},su=function(i,t,e,n){let s,r=0,o;const l=i.cell;n.rotate?(s=i.getUnrotatedBBoxOfElement(t),o=l.getBBox().getCenter(),r=l.getAngle()):s=i.getBBoxOfElement(t);const a=n.padding;a!=null&&Number.isFinite(a)&&s.inflate(a),n.rotate&&e.rotate(r,o);const c=s.getNearestSideToPoint(e);let h;switch(c){case"left":h=s.getLeftMiddle();break;case"right":h=s.getRightMiddle();break;case"top":h=s.getTopCenter();break;case"bottom":h=s.getBottomCenter();break}const u=n.direction;return u==="H"?(c==="top"||c==="bottom")&&(e.x<=s.x+s.width?h=s.getLeftMiddle():h=s.getRightMiddle()):u==="V"&&(e.y<=s.y+s.height?h=s.getTopCenter():h=s.getBottomCenter()),n.rotate?h.rotate(-r,o):h},iu=Vn(su),ru=Object.freeze(Object.defineProperty({__proto__:null,bottom:Wh,bottomLeft:Kh,bottomRight:Qh,center:_h,left:Xh,midSide:iu,nodeCenter:nu,orth:eu,right:Jh,top:Uh,topLeft:Yh,topRight:Zh},Symbol.toStringTag,{value:"Module"}));var Me;(function(i){i.presets=ru,i.registry=nt.create({type:"node endpoint"}),i.registry.register(i.presets,!0)})(Me||(Me={}));const ou=function(i,t,e,n){let s=n.ratio!=null?n.ratio:.5;return s>1&&(s/=100),i.getPointAtRatio(s)},lu=function(i,t,e,n){const s=n.length!=null?n.length:20;return i.getPointAtLength(s)},Hr=function(i,t,e,n){const s=i.getClosestPoint(e);return s!=null?s:new w},au=Vn(Hr),cu=function(i,t,e,n){const r=i.getConnection(),o=i.getConnectionSubdivisions(),l=new L(e.clone().translate(0,1e6),e.clone().translate(0,-1e6)),a=new L(e.clone().translate(1e6,0),e.clone().translate(-1e6,0)),c=l.intersect(r,{segmentSubdivisions:o}),h=a.intersect(r,{segmentSubdivisions:o}),u=[];return c&&u.push(...c),h&&u.push(...h),u.length>0?e.closest(u):n.fallbackAt!=null?qr(i,n.fallbackAt):R(Hr,this,i,t,e,n)},hu=Vn(cu),uu=Object.freeze(Object.defineProperty({__proto__:null,closest:au,length:lu,orth:hu,ratio:ou},Symbol.toStringTag,{value:"Module"}));var Ee;(function(i){i.presets=uu,i.registry=nt.create({type:"edge endpoint"}),i.registry.register(i.presets,!0)})(Ee||(Ee={}));function zn(i,t,e){let n;if(typeof e=="object"){if(Number.isFinite(e.y)){const r=new L(t,i),{start:o,end:l}=r.parallel(e.y);t=o,i=l}n=e.x}else n=e;if(n==null||!Number.isFinite(n))return i;const s=i.distance(t);return n===0&&s>0?i:i.move(t,-Math.min(n,s-1))}function Tn(i){const t=i.getAttribute("stroke-width");return t===null?0:parseFloat(t)||0}function fu(i){if(i==null)return null;let t=i;do{let e=t.tagName;if(typeof e!="string")return null;if(e=e.toUpperCase(),e==="G")t=t.firstElementChild;else if(e==="TITLE")t=t.nextElementSibling;else break}while(t);return t}const Gr=function(i,t,e,n){const s=t.getBBoxOfElement(e);n.stroked&&s.inflate(Tn(e)/2);const r=i.intersect(s),o=r&&r.length?i.start.closest(r):i.end;return zn(o,i.start,n.offset)},du=function(i,t,e,n,s){const r=t.cell,o=r.isNode()?r.getAngle():0;if(o===0)return R(Gr,this,i,t,e,n,s);const l=t.getUnrotatedBBoxOfElement(e);n.stroked&&l.inflate(Tn(e)/2);const a=l.getCenter(),c=i.clone().rotate(o,a),h=c.setLength(1e6).intersect(l),u=h&&h.length?c.start.closest(h).rotate(-o,a):i.end;return zn(u,i.start,n.offset)},gu=function(i,t,e,n){let s,r;const o=i.end,l=n.selector;if(typeof l=="string"?s=t.findOne(l):Array.isArray(l)?s=ps(e,l):s=fu(e),!Jt(s)){if(s===e||!Jt(e))return o;s=e}const a=t.getShapeOfElement(s),c=t.getMatrixOfElement(s),h=t.getRootTranslatedMatrix(),u=t.getRootRotatedMatrix(),f=h.multiply(u).multiply(c),d=f.inverse(),g=q.transformLine(i,d),p=g.start.clone(),m=t.getDataOfElement(s);if(n.insideout===!1){m.shapeBBox==null&&(m.shapeBBox=a.bbox());const v=m.shapeBBox;if(v!=null&&v.containsPoint(p))return o}n.extrapolate===!0&&g.setLength(1e6);let b;if(k.isPath(a)){const v=n.precision||2;m.segmentSubdivisions==null&&(m.segmentSubdivisions=a.getSegmentSubdivisions({precision:v})),b={precision:v,segmentSubdivisions:m.segmentSubdivisions},r=g.intersect(a,b)}else r=g.intersect(a);r?Array.isArray(r)&&(r=p.closest(r)):n.sticky===!0&&(T.isRectangle(a)?r=a.getNearestPointToPoint(p):St.isEllipse(a)?r=a.intersectsWithLineFromCenterToPoint(p):r=a.closestPoint(p,b));const x=r?q.transformPoint(r,f):o;let y=n.offset||0;return n.stroked!==!1&&(typeof y=="object"?(y=Object.assign({},y),y.x==null&&(y.x=0),y.x+=Tn(s)/2):y+=Tn(s)/2),zn(x,i.start,y)};function pu(i,t,e=0){const{start:n,end:s}=i;let r,o,l,a;switch(t){case"left":a="x",r=s,o=n,l=-1;break;case"right":a="x",r=n,o=s,l=1;break;case"top":a="y",r=s,o=n,l=-1;break;case"bottom":a="y",r=n,o=s,l=1;break;default:return}n[a]<s[a]?r[a]=o[a]:o[a]=r[a],Number.isFinite(e)&&(r[a]+=l*e,o[a]+=l*e)}const mu=function(i,t,e,n){const{alignOffset:s,align:r}=n;return r&&pu(i,r,s),zn(i.end,i.start,n.offset)},yu=Object.freeze(Object.defineProperty({__proto__:null,anchor:mu,bbox:Gr,boundary:gu,rect:du},Symbol.toStringTag,{value:"Module"}));var Te;(function(i){i.presets=yu,i.registry=nt.create({type:"connection point"}),i.registry.register(i.presets,!0)})(Te||(Te={}));const bu=function(i){return[...i]},xu=function(i,t,e){const n=t.side||"bottom",s=ce(t.padding||40),r=e.sourceBBox,o=e.targetBBox,l=r.getCenter(),a=o.getCenter();let c,h,u;switch(n){case"top":u=-1,c="y",h="height";break;case"left":u=-1,c="x",h="width";break;case"right":u=1,c="x",h="width";break;case"bottom":default:u=1,c="y",h="height";break}return l[c]+=u*(r[h]/2+s[n]),a[c]+=u*(o[h]/2+s[n]),u*(l[c]-a[c])>0?a[c]=l[c]:l[c]=a[c],[l.toJSON(),...i,a.toJSON()]};function gn(i){return new T(i.x,i.y,0,0)}function Nn(i={}){const t=ce(i.padding||20);return{x:-t.left,y:-t.top,width:t.left+t.right,height:t.top+t.bottom}}function _r(i,t={}){return i.sourceBBox.clone().moveAndExpand(Nn(t))}function Ur(i,t={}){return i.targetBBox.clone().moveAndExpand(Nn(t))}function wu(i,t={}){return i.sourceAnchor?i.sourceAnchor:_r(i,t).getCenter()}function vu(i,t={}){return i.targetAnchor?i.targetAnchor:Ur(i,t).getCenter()}const Wr=function(i,t,e){let n=_r(e,t),s=Ur(e,t);const r=wu(e,t),o=vu(e,t);n=n.union(gn(r)),s=s.union(gn(o));const l=i.map(h=>w.create(h));l.unshift(r),l.push(o);let a=null;const c=[];for(let h=0,u=l.length-1;h<u;h+=1){let f=null;const d=l[h],g=l[h+1],p=bt.getBearing(d,g)!=null;if(h===0)h+1===u?n.intersectsWithRect(s.clone().inflate(1))?f=bt.insideNode(d,g,n,s):p||(f=bt.nodeToNode(d,g,n,s)):n.containsPoint(g)?f=bt.insideNode(d,g,n,gn(g).moveAndExpand(Nn(t))):p||(f=bt.nodeToVertex(d,g,n));else if(h+1===u){const m=p&&bt.getBearing(g,d)===a;s.containsPoint(d)||m?f=bt.insideNode(d,g,gn(d).moveAndExpand(Nn(t)),s,a):p||(f=bt.vertexToNode(d,g,s,a))}else p||(f=bt.vertexToVertex(d,g,a));f?(c.push(...f.points),a=f.direction):a=bt.getBearing(d,g),h+1<u&&c.push(g)}return c};var bt;(function(i){const t={N:"S",S:"N",E:"W",W:"E"},e={N:-Math.PI/2*3,S:-Math.PI/2,E:0,W:Math.PI};function n(u,f,d){let g=new w(u.x,f.y);return d.containsPoint(g)&&(g=new w(f.x,u.y)),g}function s(u,f){return u[f==="W"||f==="E"?"width":"height"]}i.getBBoxSize=s;function r(u,f){return u.x===f.x?u.y>f.y?"N":"S":u.y===f.y?u.x>f.x?"W":"E":null}i.getBearing=r;function o(u,f,d){const g=new w(u.x,f.y),p=new w(f.x,u.y),m=r(u,g),b=r(u,p),x=d?t[d]:null,y=m===d||m!==x&&(b===x||b!==d)?g:p;return{points:[y],direction:r(y,f)}}i.vertexToVertex=o;function l(u,f,d){const g=n(u,f,d);return{points:[g],direction:r(g,f)}}i.nodeToVertex=l;function a(u,f,d,g){const p=[new w(u.x,f.y),new w(f.x,u.y)],m=p.filter(y=>!d.containsPoint(y)),b=m.filter(y=>r(y,u)!==g);let x;if(b.length>0)return x=b.filter(y=>r(u,y)===g).pop(),x=x||b[0],{points:[x],direction:r(x,f)};{x=Eo(p,m)[0];const y=w.create(f).move(x,-s(d,g)/2);return{points:[n(y,u,d),y],direction:r(y,f)}}}i.vertexToNode=a;function c(u,f,d,g){let p=l(f,u,g);const m=p.points[0];if(d.containsPoint(m)){p=l(u,f,d);const b=p.points[0];if(g.containsPoint(b)){const x=w.create(u).move(b,-s(d,r(u,b))/2),y=w.create(f).move(m,-s(g,r(f,m))/2),v=new L(x,y).getCenter(),P=l(u,v,d),C=o(v,f,P.direction);p.points=[P.points[0],C.points[0]],p.direction=C.direction}}return p}i.nodeToNode=c;function h(u,f,d,g,p){const m=d.union(g).inflate(1),b=m.getCenter(),x=b.distance(f)>b.distance(u),y=x?f:u,v=x?u:f;let P,C,O;p?(P=w.fromPolar(m.width+m.height,e[p],y),P=m.getNearestPointToPoint(P).move(P,-1)):P=m.getNearestPointToPoint(y).move(y,1),C=n(P,v,m);let N;P.round().equals(C.round())?(C=w.fromPolar(m.width+m.height,U.toRad(P.theta(y))+Math.PI/2,v),C=m.getNearestPointToPoint(C).move(v,1).round(),O=n(P,C,m),N=x?[C,O,P]:[P,O,C]):N=x?[C,P]:[P,C];const M=r(x?P:C,f);return{points:N,direction:M}}i.insideNode=h})(bt||(bt={}));const Pu={step:10,maxLoopCount:2e3,precision:1,maxDirectionChange:90,perpendicular:!0,excludeTerminals:[],excludeNodes:[],excludeShapes:[],startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{top:{x:0,y:-1},right:{x:1,y:0},bottom:{x:0,y:1},left:{x:-1,y:0}},cost(){return _t(this.step,this)},directions(){const i=_t(this.step,this),t=_t(this.cost,this);return[{cost:t,offsetX:i,offsetY:0},{cost:t,offsetX:-i,offsetY:0},{cost:t,offsetX:0,offsetY:i},{cost:t,offsetX:0,offsetY:-i}]},penalties(){const i=_t(this.step,this);return{0:0,45:i/2,90:i/2}},paddingBox(){const i=_t(this.step,this);return{x:-i,y:-i,width:2*i,height:2*i}},fallbackRouter:Wr,draggingRouter:null,snapToGrid:!0};function _t(i,t){return typeof i=="function"?i.call(t):i}function Cu(i){const t=Object.keys(i).reduce((e,n)=>{const s=e;return n==="fallbackRouter"||n==="draggingRouter"||n==="fallbackRoute"?s[n]=i[n]:s[n]=_t(i[n],i),e},{});if(t.padding){const e=ce(t.padding);t.paddingBox={x:-e.left,y:-e.top,width:e.left+e.right,height:e.top+e.bottom}}return t.directions.forEach(e=>{const n=new w(0,0),s=new w(e.offsetX,e.offsetY);e.angle=U.normalize(n.theta(s))}),t}const ri=1,oi=2;class Au{constructor(){this.items=[],this.hash={},this.values={}}add(t,e){this.hash[t]?this.items.splice(this.items.indexOf(t),1):this.hash[t]=ri,this.values[t]=e;const n=yl(this.items,t,s=>this.values[s]);this.items.splice(n,0,t)}pop(){const t=this.items.shift();return t&&(this.hash[t]=oi),t}isOpen(t){return this.hash[t]===ri}isClose(t){return this.hash[t]===oi}isEmpty(){return this.items.length===0}}class Su{constructor(t){this.options=t,this.mapGridSize=100,this.map={}}build(t,e){const n=this.options,s=n.excludeTerminals.reduce((c,h)=>{const u=e[h];if(u){const f=t.getCell(u.cell);f&&c.push(f)}return c},[]);let r=[];const o=t.getCell(e.getSourceCellId());o&&(r=$s(r,o.getAncestors().map(c=>c.id)));const l=t.getCell(e.getTargetCellId());l&&(r=$s(r,l.getAncestors().map(c=>c.id)));const a=this.mapGridSize;return t.getNodes().reduce((c,h)=>{const u=s.some(m=>m.id===h.id),f=h.shape?n.excludeShapes.includes(h.shape):!1,d=n.excludeNodes.some(m=>typeof m=="string"?h.id===m:m===h),g=r.includes(h.id),p=f||u||d||g;if(h.isVisible()&&!p){const m=h.getBBox().moveAndExpand(n.paddingBox),b=m.getOrigin().snapToGrid(a),x=m.getCorner().snapToGrid(a);for(let y=b.x;y<=x.x;y+=a)for(let v=b.y;v<=x.y;v+=a){const P=new w(y,v).toString();c[P]==null&&(c[P]=[]),c[P].push(m)}}return c},this.map),this}isAccessible(t){const e=t.clone().snapToGrid(this.mapGridSize).toString(),n=this.map[e];return n?n.every(s=>!s.containsPoint(t)):!0}}function Xr(i,t){const e=i.sourceBBox.clone();return t&&t.paddingBox?e.moveAndExpand(t.paddingBox):e}function Jr(i,t){const e=i.targetBBox.clone();return t&&t.paddingBox?e.moveAndExpand(t.paddingBox):e}function Yr(i,t){return i.sourceAnchor?i.sourceAnchor:Xr(i,t).getCenter()}function Ou(i,t){return i.targetAnchor?i.targetAnchor:Jr(i,t).getCenter()}function Jn(i,t,e,n,s){const r=360/e,o=i.theta(Mu(i,t,n,s)),l=U.normalize(o+r/2);return r*Math.floor(l/r)}function Mu(i,t,e,n){const s=n.step,r=t.x-i.x,o=t.y-i.y,l=r/e.x,a=o/e.y,c=l*s,h=a*s;return new w(i.x+c,i.y+h)}function li(i,t){const e=Math.abs(i-t);return e>180?360-e:e}function Eu(i,t){const e=t.step;return t.directions.forEach(n=>{n.gridOffsetX=n.offsetX/e*i.x,n.gridOffsetY=n.offsetY/e*i.y}),t.directions}function Tu(i,t,e){return{source:t.clone(),x:ai(e.x-t.x,i),y:ai(e.y-t.y,i)}}function ai(i,t){if(!i)return t;const e=Math.abs(i),n=Math.round(e/t);if(!n)return e;const s=n*t,o=(e-s)/n;return t+o}function Nu(i,t){const e=t.source,n=H.snapToGrid(i.x-e.x,t.x)+e.x,s=H.snapToGrid(i.y-e.y,t.y)+e.y;return new w(n,s)}function ze(i,t){return i.round(t)}function yn(i,t,e){return ze(Nu(i.clone(),t),e)}function _e(i){return i.toString()}function Yn(i){return new w(i.x===0?0:Math.abs(i.x)/i.x,i.y===0?0:Math.abs(i.y)/i.y)}function ci(i,t){let e=1/0;for(let n=0,s=t.length;n<s;n+=1){const r=i.manhattanDistance(t[n]);r<e&&(e=r)}return e}function hi(i,t,e,n,s){const r=s.precision,o=s.directionMap,l=i.diff(t.getCenter()),a=Object.keys(o).reduce((c,h)=>{if(e.includes(h)){const u=o[h],f=new w(i.x+u.x*(Math.abs(l.x)+t.width),i.y+u.y*(Math.abs(l.y)+t.height)),g=new L(i,f).intersect(t)||[];let p,m=null;for(let b=0;b<g.length;b+=1){const x=g[b],y=i.squaredDistance(x);(p==null||y>p)&&(p=y,m=x)}if(m){let b=yn(m,n,r);t.containsPoint(b)&&(b=yn(b.translate(u.x*n.x,u.y*n.y),n,r)),c.push(b)}}return c},[]);return t.containsPoint(i)||a.push(yn(i,n,r)),a}function Lu(i,t,e,n,s){const r=[];let o=Yn(s.diff(e)),l=_e(e),a=i[l],c;for(;a;){c=t[l];const f=Yn(c.diff(a));f.equals(o)||(r.unshift(c),o=f),l=_e(a),a=i[l]}const h=t[l];return Yn(h.diff(n)).equals(o)||r.unshift(h),r}function ju(i,t,e,n,s){const r=s.precision;let o,l;T.isRectangle(t)?o=ze(Yr(i,s).clone(),r):o=ze(t.clone(),r),T.isRectangle(e)?l=ze(Ou(i,s).clone(),r):l=ze(e.clone(),r);const a=Tu(s.step,o,l),c=o,h=l;let u,f;if(T.isRectangle(t)?u=hi(c,t,s.startDirections,a,s):u=[c],T.isRectangle(e)?f=hi(l,e,s.endDirections,a,s):f=[h],u=u.filter(d=>n.isAccessible(d)),f=f.filter(d=>n.isAccessible(d)),u.length>0&&f.length>0){const d=new Au,g={},p={},m={};for(let j=0,E=u.length;j<E;j+=1){const D=u[j],_=_e(D);d.add(_,ci(D,f)),g[_]=D,m[_]=0}const b=s.previousDirectionAngle,x=b===void 0;let y,v;const P=Eu(a,s),C=P.length,O=f.reduce((j,E)=>{const D=_e(E);return j.push(D),j},[]),N=w.equalPoints(u,f);let M=s.maxLoopCount;for(;!d.isEmpty()&&M>0;){const j=d.pop(),E=g[j],D=p[j],_=m[j],z=E.equals(c),A=D==null;let S;if(A?x?z?S=null:S=Jn(c,E,C,a,s):S=b:S=Jn(D,E,C,a,s),!(A&&N)&&O.indexOf(j)>=0)return s.previousDirectionAngle=S,Lu(p,g,E,c,h);for(let J=0;J<C;J+=1){y=P[J];const Y=y.angle;if(v=li(S,Y),!(x&&z)&&v>s.maxDirectionChange)continue;const rt=yn(E.clone().translate(y.gridOffsetX||0,y.gridOffsetY||0),a,r),dt=_e(rt);if(d.isClose(dt)||!n.isAccessible(rt))continue;if(O.indexOf(dt)>=0&&!rt.equals(h)){const Lt=Jn(rt,h,C,a,s);if(li(Y,Lt)>s.maxDirectionChange)continue}const an=y.cost,cn=z?0:s.penalties[v],Ht=_+an+cn;(!d.isOpen(dt)||Ht<m[dt])&&(g[dt]=rt,p[dt]=E,m[dt]=Ht,d.add(dt,Ht+ci(rt,f)))}M-=1}}return s.fallbackRoute?R(s.fallbackRoute,this,c,h,s):null}function ku(i,t=10){if(i.length<=1)return i;for(let e=0,n=i.length;e<n-1;e+=1){const s=i[e],r=i[e+1];if(s.x===r.x){const o=t*Math.round(s.x/t);s.x!==o&&(s.x=o,r.x=o)}else if(s.y===r.y){const o=t*Math.round(s.y/t);s.y!==o&&(s.y=o,r.y=o)}}return i}const Du=function(i,t,e){const n=Cu(t),s=Xr(e,n),r=Jr(e,n),o=Yr(e,n),l=new Su(n).build(e.graph.model,e.cell),a=i.map(d=>w.create(d)),c=[];let h=o,u,f;for(let d=0,g=a.length;d<=g;d+=1){let p=null;if(u=f||s,f=a[d],f==null){f=r;const b=e.cell;if((b.getSourceCellId()==null||b.getTargetCellId()==null)&&typeof n.draggingRouter=="function"){const y=u===s?o:u,v=f.getOrigin();p=R(n.draggingRouter,e,y,v,n)}}if(p==null&&(p=ju(e,u,f,l,n)),p===null)return R(n.fallbackRouter,this,i,n,e);const m=p[0];m&&m.equals(h)&&p.shift(),h=p[p.length-1]||h,c.push(...p)}return n.snapToGrid?ku(c,e.graph.grid.getGridSize()):c},Zr=function(i,t,e){return R(Du,this,i,Object.assign(Object.assign({},Pu),t),e)},Iu={maxDirectionChange:45,directions(){const i=_t(this.step,this),t=_t(this.cost,this),e=Math.ceil(Math.sqrt(i*i<<1));return[{cost:t,offsetX:i,offsetY:0},{cost:e,offsetX:i,offsetY:i},{cost:t,offsetX:0,offsetY:i},{cost:e,offsetX:-i,offsetY:i},{cost:t,offsetX:-i,offsetY:0},{cost:e,offsetX:-i,offsetY:-i},{cost:t,offsetX:0,offsetY:-i},{cost:e,offsetX:i,offsetY:-i}]},fallbackRoute(i,t,e){const n=i.theta(t),s=[];let r={x:t.x,y:i.y},o={x:i.x,y:t.y};if(n%180>90){const y=r;r=o,o=y}const l=n%90<45?r:o,a=new L(i,l),c=90*Math.ceil(n/90),h=w.fromPolar(a.squaredLength(),U.toRad(c+135),l),u=new L(t,h),f=a.intersectsWithLine(u),d=f||t,g=f?d:i,p=360/e.directions.length,m=g.theta(t),b=U.normalize(m+p/2),x=p*Math.floor(b/p);return e.previousDirectionAngle=x,d&&s.push(d.round()),s.push(t),s}},Ru=function(i,t,e){return R(Zr,this,i,Object.assign(Object.assign({},Iu),t),e)},Bu=function(i,t,e){const n=t.offset||32,s=t.min==null?16:t.min;let r=0,o=t.direction;const l=e.sourceBBox,a=e.targetBBox,c=l.getCenter(),h=a.getCenter();if(typeof n=="number"&&(r=n),o==null){let b=a.left-l.right,x=a.top-l.bottom;b>=0&&x>=0?o=b>=x?"L":"T":b<=0&&x>=0?(b=l.left-a.right,b>=0?o=b>=x?"R":"T":o="T"):b>=0&&x<=0?(x=l.top-a.bottom,x>=0?o=b>=x?"L":"B":o="L"):(b=l.left-a.right,x=l.top-a.bottom,b>=0&&x>=0?o=b>=x?"R":"B":b<=0&&x>=0?o="B":b>=0&&x<=0?o="R":o=Math.abs(b)>Math.abs(x)?"R":"B")}o==="H"?o=h.x-c.x>=0?"L":"R":o==="V"&&(o=h.y-c.y>=0?"T":"B"),n==="center"&&(o==="L"?r=(a.left-l.right)/2:o==="R"?r=(l.left-a.right)/2:o==="T"?r=(a.top-l.bottom)/2:o==="B"&&(r=(l.top-a.bottom)/2));let u,f,d;const g=o==="L"||o==="R";if(g){if(h.y===c.y)return[...i];d=o==="L"?1:-1,u="x",f="width"}else{if(h.x===c.x)return[...i];d=o==="T"?1:-1,u="y",f="height"}const p=c.clone(),m=h.clone();if(p[u]+=d*(l[f]/2+r),m[u]-=d*(a[f]/2+r),g){const b=p.x,x=m.x,y=l.width/2+s,v=a.width/2+s;h.x>c.x?x<=b&&(p.x=Math.max(x,c.x+y),m.x=Math.min(b,h.x-v)):x>=b&&(p.x=Math.min(x,c.x-y),m.x=Math.max(b,h.x+v))}else{const b=p.y,x=m.y,y=l.height/2+s,v=a.height/2+s;h.y>c.y?x<=b&&(p.y=Math.max(x,c.y+y),m.y=Math.min(b,h.y-v)):x>=b&&(p.y=Math.min(x,c.y-y),m.y=Math.max(b,h.y+v))}return[p.toJSON(),...i,m.toJSON()]};function de(i,t){if(t!=null&&t!==!1){const e=typeof t=="boolean"?0:t;if(e>0){const n=w.create(i[1]).move(i[2],e),s=w.create(i[1]).move(i[0],e);return[n.toJSON(),...i,s.toJSON()]}{const n=i[1];return[Object.assign({},n),...i,Object.assign({},n)]}}return i}const $u=function(i,t,e){const n=t.width||50,r=(t.height||80)/2,o=t.angle||"auto",l=e.sourceAnchor,a=e.targetAnchor,c=e.sourceBBox,h=e.targetBBox;if(l.equals(a)){const u=b=>{const x=U.toRad(b),y=Math.sin(x),v=Math.cos(x),P=new w(l.x+v*n,l.y+y*n),C=new w(P.x-v*r,P.y-y*r),O=C.clone().rotate(-90,P),N=C.clone().rotate(90,P);return[O.toJSON(),P.toJSON(),N.toJSON()]},f=b=>{const x=l.clone().move(b,-1),y=new L(x,b);return!c.containsPoint(b)&&!c.intersectsWithLine(y)},d=[0,90,180,270,45,135,225,315];if(typeof o=="number")return de(u(o),t.merge);const g=c.getCenter();if(g.equals(l))return de(u(0),t.merge);const p=g.angleBetween(l,g.clone().translate(1,0));let m=u(p);if(f(m[1]))return de(m,t.merge);for(let b=1,x=d.length;b<x;b+=1)if(m=u(p+d[b]),f(m[1]))return de(m,t.merge);return de(m,t.merge)}{const u=new L(l,a);let f=u.parallel(-n),d=f.getCenter(),g=f.start.clone().move(f.end,r),p=f.end.clone().move(f.start,r);const m=u.parallel(-1),b=new L(m.start,d),x=new L(m.end,d);if((c.containsPoint(d)||h.containsPoint(d)||c.intersectsWithLine(b)||c.intersectsWithLine(x)||h.intersectsWithLine(b)||h.intersectsWithLine(x))&&(f=u.parallel(n),d=f.getCenter(),g=f.start.clone().move(f.end,r),p=f.end.clone().move(f.start,r)),t.merge){const y=new L(l,a),v=new L(d,y.center).setLength(Number.MAX_SAFE_INTEGER),P=c.intersectsWithLine(v),C=h.intersectsWithLine(v),O=P?Array.isArray(P)?P:[P]:[];C&&(Array.isArray(C)?O.push(...C):O.push(C));const N=y.center.closest(O);N?(e.sourceAnchor=N.clone(),e.targetAnchor=N.clone()):(e.sourceAnchor=y.center.clone(),e.targetAnchor=y.center.clone())}return de([g.toJSON(),d.toJSON(),p.toJSON()],t.merge)}},Vu=Object.freeze(Object.defineProperty({__proto__:null,er:Bu,loop:$u,manhattan:Zr,metro:Ru,normal:bu,oneSide:xu,orth:Wr},Symbol.toStringTag,{value:"Module"}));var Wt;(function(i){i.presets=Vu,i.registry=nt.create({type:"router"}),i.registry.register(i.presets,!0)})(Wt||(Wt={}));const zu=function(i,t,e,n={}){const s=[i,...e,t],r=new tt(s),o=new k(r);return n.raw?o:o.serialize()},Fu=function(i,t,e,n={}){const s=e.length===3?0:1,r=w.create(e[0+s]),o=w.create(e[2+s]),l=w.create(e[1+s]);if(!w.equals(i,t)){const c=new w((i.x+t.x)/2,(i.y+t.y)/2),h=c.angleBetween(w.create(i).rotate(90,c),l);h>1&&(r.rotate(180-h,c),o.rotate(180-h,c),l.rotate(180-h,c))}const a=`
M ${i.x} ${i.y}
Q ${r.x} ${r.y} ${l.x} ${l.y}
Q ${o.x} ${o.y} ${t.x} ${t.y}
`;return n.raw?k.parse(a):a},qu=function(i,t,e,n={}){const s=new k;s.appendSegment(k.createSegment("M",i));const r=1/3,o=2/3,l=n.radius||10;let a,c;for(let h=0,u=e.length;h<u;h+=1){const f=w.create(e[h]),d=e[h-1]||i,g=e[h+1]||t;a=c||f.distance(d)/2,c=f.distance(g)/2;const p=-Math.min(l,a),m=-Math.min(l,c),b=f.clone().move(d,p).round(),x=f.clone().move(g,m).round(),y=new w(r*b.x+o*f.x,o*f.y+r*b.y),v=new w(r*x.x+o*f.x,o*f.y+r*x.y);s.appendSegment(k.createSegment("L",b)),s.appendSegment(k.createSegment("C",y,v,x))}return s.appendSegment(k.createSegment("L",t)),n.raw?s:s.serialize()},Hu=function(i,t,e,n={}){let s,r=n.direction;if(e&&e.length!==0){const o=[i,...e,t],l=Z.throughPoints(o);s=new k(l)}else if(s=new k,s.appendSegment(k.createSegment("M",i)),r||(r=Math.abs(i.x-t.x)>=Math.abs(i.y-t.y)?"H":"V"),r==="H"){const o=(i.x+t.x)/2;s.appendSegment(k.createSegment("C",o,i.y,o,t.y,t.x,t.y))}else{const o=(i.y+t.y)/2;s.appendSegment(k.createSegment("C",i.x,o,t.x,o,t.x,t.y))}return n.raw?s:s.serialize()},ui=1,pn=1/3,mn=2/3;function Gu(i){let t=i.graph._jumpOverUpdateList;if(t==null&&(t=i.graph._jumpOverUpdateList=[],i.graph.on("cell:mouseup",()=>{const e=i.graph._jumpOverUpdateList;setTimeout(()=>{for(let n=0;n<e.length;n+=1)e[n].update()})}),i.graph.on("model:reseted",()=>{t=i.graph._jumpOverUpdateList=[]})),t.indexOf(i)<0){t.push(i);const e=()=>t.splice(t.indexOf(i),1);i.cell.once("change:connector",e),i.cell.once("removed",e)}}function Zn(i,t,e=[]){const n=[i,...e,t],s=[];return n.forEach((r,o)=>{const l=n[o+1];l!=null&&s.push(new L(r,l))}),s}function _u(i,t){const e=[];return t.forEach(n=>{const s=i.intersectsWithLine(n);s&&e.push(s)}),e}function fi(i,t){return new L(i,t).squaredLength()}function Uu(i,t,e){return t.reduce((n,s,r)=>{if(Ln.includes(s))return n;const o=n.pop()||i,l=w.create(s).move(o.start,-e);let a=w.create(s).move(o.start,+e);const c=t[r+1];if(c!=null){const f=a.distance(c);f<=e&&(a=c.move(o.start,f),Ln.push(c))}else if(l.distance(o.end)<e*2+ui)return n.push(o),n;if(a.distance(o.start)<e*2+ui)return n.push(o),n;const u=new L(l,a);return Qe.push(u),n.push(new L(o.start,l),u,new L(a,o.end)),n},[])}function di(i,t,e,n){const s=new k;let r;return r=k.createSegment("M",i[0].start),s.appendSegment(r),i.forEach((o,l)=>{if(Qe.includes(o)){let a,c,h,u;if(e==="arc"){a=-90,c=o.start.diff(o.end),(c.x<0||c.x===0&&c.y<0)&&(a+=180);const d=o.getCenter(),g=new L(d,o.end).rotate(a,d);let p;p=new L(o.start,d),h=p.pointAt(2/3).rotate(a,o.start),u=g.pointAt(1/3).rotate(-a,g.end),r=k.createSegment("C",h,u,g.end),s.appendSegment(r),p=new L(d,o.end),h=g.pointAt(1/3).rotate(a,g.end),u=p.pointAt(1/3).rotate(-a,o.end),r=k.createSegment("C",h,u,o.end),s.appendSegment(r)}else if(e==="gap")r=k.createSegment("M",o.end),s.appendSegment(r);else if(e==="cubic"){a=o.start.theta(o.end);const f=t*.6;let d=t*1.35;c=o.start.diff(o.end),(c.x<0||c.x===0&&c.y<0)&&(d*=-1),h=new w(o.start.x+f,o.start.y+d).rotate(a,o.start),u=new w(o.end.x-f,o.end.y+d).rotate(a,o.end),r=k.createSegment("C",h,u,o.end),s.appendSegment(r)}}else{const a=i[l+1];n===0||!a||Qe.includes(a)?(r=k.createSegment("L",o.end),s.appendSegment(r)):Wu(n,s,o.end,o.start,a.end)}}),s}function Wu(i,t,e,n,s){const r=e.distance(n)/2,o=e.distance(s)/2,l=-Math.min(i,r),a=-Math.min(i,o),c=e.clone().move(n,l).round(),h=e.clone().move(s,a).round(),u=new w(pn*c.x+mn*e.x,mn*e.y+pn*c.y),f=new w(pn*h.x+mn*e.x,mn*e.y+pn*h.y);let d;d=k.createSegment("L",c),t.appendSegment(d),d=k.createSegment("C",u,f,h),t.appendSegment(d)}let Qe,Ln;const Xu=function(i,t,e,n={}){Qe=[],Ln=[],Gu(this);const s=n.size||5,r=n.type||"arc",o=n.radius||0,l=n.ignoreConnectors||["smooth"],a=this.graph,h=a.model.getEdges();if(h.length===1)return di(Zn(i,t,e),s,r,o);const u=this.cell,f=h.indexOf(u),d=a.options.connecting.connector||{},g=h.filter((v,P)=>{const C=v.getConnector()||d;return l.includes(C.name)?!1:P>f?C.name!=="jumpover":!0}),p=g.map(v=>a.findViewByCell(v)),m=Zn(i,t,e),b=p.map(v=>v==null?[]:v===this?m:Zn(v.sourcePoint,v.targetPoint,v.routePoints)),x=[];m.forEach(v=>{const P=g.reduce((C,O,N)=>{if(O!==u){const M=_u(v,b[N]);C.push(...M)}return C},[]).sort((C,O)=>fi(v.start,C)-fi(v.start,O));P.length>0?x.push(...Uu(v,P,s)):x.push(v)});const y=di(x,s,r,o);return Qe=[],Ln=[],n.raw?y:y.serialize()},Ju=Object.freeze(Object.defineProperty({__proto__:null,jumpover:Xu,loop:Fu,normal:zu,rounded:qu,smooth:Hu},Symbol.toStringTag,{value:"Module"}));var ae;(function(i){i.presets=Ju,i.registry=nt.create({type:"connector"}),i.registry.register(i.presets,!0)})(ae||(ae={}));var Yu=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class Kr extends yt{constructor(t={}){super(),this.pending=!1,this.changing=!1,this.data={},this.mutate(K(t)),this.changed={}}mutate(t,e={}){const n=e.unset===!0,s=e.silent===!0,r=[],o=this.changing;this.changing=!0,o||(this.previous=K(this.data),this.changed={});const l=this.data,a=this.previous,c=this.changed;if(Object.keys(t).forEach(h=>{const u=h,f=t[u];It(l[u],f)||r.push(u),It(a[u],f)?delete c[u]:c[u]=f,n?delete l[u]:l[u]=f}),!s&&r.length>0&&(this.pending=!0,this.pendingOptions=e,r.forEach(h=>{this.emit("change:*",{key:h,options:e,store:this,current:l[h],previous:a[h]})})),o)return this;if(!s)for(;this.pending;)this.pending=!1,this.emit("changed",{current:l,previous:a,store:this,options:this.pendingOptions});return this.pending=!1,this.changing=!1,this.pendingOptions=null,this}get(t,e){if(t==null)return this.data;const n=this.data[t];return n==null?e:n}getPrevious(t){if(this.previous){const e=this.previous[t];return e==null?void 0:e}}set(t,e,n){return t!=null&&(typeof t=="object"?this.mutate(t,e):this.mutate({[t]:e},n)),this}remove(t,e){const s={};let r;if(typeof t=="string")s[t]=void 0,r=e;else if(Array.isArray(t))t.forEach(o=>s[o]=void 0),r=e;else{for(const o in this.data)s[o]=void 0;r=t}return this.mutate(s,Object.assign(Object.assign({},r),{unset:!0})),this}getByPath(t){return ps(this.data,t,"/")}setByPath(t,e,n={}){const s="/",r=Array.isArray(t)?[...t]:t.split(s),o=Array.isArray(t)?t.join(s):t,l=r[0],a=r.length;if(n.propertyPath=o,n.propertyValue=e,n.propertyPathArray=r,a===1)this.set(l,e,n);else{const c={};let h=c,u=l;for(let g=1;g<a;g+=1){const p=r[g],m=Number.isFinite(Number(p));h=h[u]=m?[]:{},u=p}ke(c,r,e,s);const f=K(this.data);n.rewrite&&qs(f,t,s);const d=st(f,c);this.set(l,d[l],n)}return this}removeByPath(t,e){const n=Array.isArray(t)?t:t.split("/"),s=n[0];if(n.length===1)this.remove(s,e);else{const r=n.slice(1),o=K(this.get(s));o&&qs(o,r),this.set(s,o,e)}return this}hasChanged(t){return t==null?Object.keys(this.changed).length>0:t in this.changed}getChanges(t){if(t==null)return this.hasChanged()?K(this.changed):null;const e=this.changing?this.previous:this.data,n={};let s;for(const r in t){const o=t[r];It(e[r],o)||(n[r]=o,s=!0)}return s?K(n):null}toJSON(){return K(this.data)}clone(){const t=this.constructor;return new t(this.data)}dispose(){this.off(),this.data={},this.previous={},this.changed={},this.pending=!1,this.changing=!1,this.pendingOptions=null,this.trigger("disposed",{store:this})}}Yu([yt.dispose()],Kr.prototype,"dispose",null);class tn{constructor(t){this.cell=t,this.ids={},this.cache={}}get(){return Object.keys(this.ids)}start(t,e,n={},s="/"){const r=this.cell.getPropByPath(t),o=$o(n,tn.defaultOptions),l=this.getTiming(o.timing),a=this.getInterp(o.interp,r,e);let c=0;const h=Array.isArray(t)?t.join(s):t,u=Array.isArray(t)?t:t.split(s),f=()=>{const d=new Date().getTime();c===0&&(c=d);let p=(d-c)/o.duration;p<1?this.ids[h]=requestAnimationFrame(f):p=1;const m=a(l(p));this.cell.setPropByPath(u,m),n.progress&&n.progress(Object.assign({progress:p,currentValue:m},this.getArgs(h))),p===1&&(this.cell.notify("transition:complete",this.getArgs(h)),n.complete&&n.complete(this.getArgs(h)),this.cell.notify("transition:finish",this.getArgs(h)),n.finish&&n.finish(this.getArgs(h)),this.clean(h))};return setTimeout(()=>{this.stop(t,void 0,s),this.cache[h]={startValue:r,targetValue:e,options:o},this.ids[h]=requestAnimationFrame(f),this.cell.notify("transition:start",this.getArgs(h)),n.start&&n.start(this.getArgs(h))},n.delay),this.stop.bind(this,t,s,n)}stop(t,e={},n="/"){const s=Array.isArray(t)?t:t.split(n);return Object.keys(this.ids).filter(r=>It(s,r.split(n).slice(0,s.length))).forEach(r=>{cancelAnimationFrame(this.ids[r]);const o=this.cache[r],l=this.getArgs(r),a=Object.assign(Object.assign({},o.options),e),c=a.jumpedToEnd;c&&o.targetValue!=null&&(this.cell.setPropByPath(r,o.targetValue),this.cell.notify("transition:end",Object.assign({},l)),this.cell.notify("transition:complete",Object.assign({},l)),a.complete&&a.complete(Object.assign({},l)));const h=Object.assign({jumpedToEnd:c},l);this.cell.notify("transition:stop",Object.assign({},h)),a.stop&&a.stop(Object.assign({},h)),this.cell.notify("transition:finish",Object.assign({},l)),a.finish&&a.finish(Object.assign({},l)),this.clean(r)}),this}clean(t){delete this.ids[t],delete this.cache[t]}getTiming(t){return typeof t=="string"?ue[t]:t}getInterp(t,e,n){return t?t(e,n):typeof n=="number"?oe.number(e,n):typeof n=="string"?n[0]==="#"?oe.color(e,n):oe.unit(e,n):oe.object(e,n)}getArgs(t){const e=this.cache[t];return{path:t,startValue:e.startValue,targetValue:e.targetValue,cell:this.cell}}}(function(i){i.defaultOptions={delay:10,duration:100,timing:"linear"}})(tn||(tn={}));var Zu=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r},Qr=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};class V extends yt{static config(t){const{markup:e,propHooks:n,attrHooks:s}=t,r=Qr(t,["markup","propHooks","attrHooks"]);e!=null&&(this.markup=e),n&&(this.propHooks=this.propHooks.slice(),Array.isArray(n)?this.propHooks.push(...n):typeof n=="function"?this.propHooks.push(n):Object.values(n).forEach(o=>{typeof o=="function"&&this.propHooks.push(o)})),s&&(this.attrHooks=Object.assign(Object.assign({},this.attrHooks),s)),this.defaults=st({},this.defaults,r)}static getMarkup(){return this.markup}static getDefaults(t){return t?this.defaults:K(this.defaults)}static getAttrHooks(){return this.attrHooks}static applyPropHooks(t,e){return this.propHooks.reduce((n,s)=>s?R(s,t,n):n,e)}get[Symbol.toStringTag](){return V.toStringTag}constructor(t={}){super();const n=this.constructor.getDefaults(!0),s=st({},this.preprocess(n),this.preprocess(t));this.id=s.id||xn(),this.store=new Kr(s),this.animation=new tn(this),this.setup(),this.init(),this.postprocess(t)}init(){}get model(){return this._model}set model(t){this._model!==t&&(this._model=t)}preprocess(t,e){const n=t.id,r=this.constructor.applyPropHooks(this,t);return n==null&&e!==!0&&(r.id=xn()),r}postprocess(t){}setup(){this.store.on("change:*",t=>{const{key:e,current:n,previous:s,options:r}=t;this.notify("change:*",{key:e,options:r,current:n,previous:s,cell:this}),this.notify(`change:${e}`,{options:r,current:n,previous:s,cell:this});const o=e;(o==="source"||o==="target")&&this.notify("change:terminal",{type:o,current:n,previous:s,options:r,cell:this})}),this.store.on("changed",({options:t})=>this.notify("changed",{options:t,cell:this}))}notify(t,e){this.trigger(t,e);const n=this.model;return n&&(n.notify(`cell:${t}`,e),this.isNode()?n.notify(`node:${t}`,Object.assign(Object.assign({},e),{node:this})):this.isEdge()&&n.notify(`edge:${t}`,Object.assign(Object.assign({},e),{edge:this}))),this}isNode(){return!1}isEdge(){return!1}isSameStore(t){return this.store===t.store}get view(){return this.store.get("view")}get shape(){return this.store.get("shape","")}getProp(t,e){return t==null?this.store.get():this.store.get(t,e)}setProp(t,e,n){if(typeof t=="string")this.store.set(t,e,n);else{const s=this.preprocess(t,!0);this.store.set(st({},this.getProp(),s),e),this.postprocess(t)}return this}removeProp(t,e){return typeof t=="string"||Array.isArray(t)?this.store.removeByPath(t,e):this.store.remove(e),this}hasChanged(t){return t==null?this.store.hasChanged():this.store.hasChanged(t)}getPropByPath(t){return this.store.getByPath(t)}setPropByPath(t,e,n={}){return this.model&&(t==="children"?this._children=e?e.map(s=>this.model.getCell(s)).filter(s=>s!=null):null:t==="parent"&&(this._parent=e?this.model.getCell(e):null)),this.store.setByPath(t,e,n),this}removePropByPath(t,e={}){const n=Array.isArray(t)?t:t.split("/");return n[0]==="attrs"&&(e.dirty=!0),this.store.removeByPath(n,e),this}prop(t,e,n){return t==null?this.getProp():typeof t=="string"||Array.isArray(t)?arguments.length===1?this.getPropByPath(t):e==null?this.removePropByPath(t,n||{}):this.setPropByPath(t,e,n||{}):this.setProp(t,e||{})}previous(t){return this.store.getPrevious(t)}get zIndex(){return this.getZIndex()}set zIndex(t){t==null?this.removeZIndex():this.setZIndex(t)}getZIndex(){return this.store.get("zIndex")}setZIndex(t,e={}){return this.store.set("zIndex",t,e),this}removeZIndex(t={}){return this.store.remove("zIndex",t),this}toFront(t={}){const e=this.model;if(e){let n=e.getMaxZIndex(),s;t.deep?(s=this.getDescendants({deep:!0,breadthFirst:!0}),s.unshift(this)):s=[this],n=n-s.length+1;const r=e.total();let o=e.indexOf(this)!==r-s.length;o||(o=s.some((l,a)=>l.getZIndex()!==n+a)),o&&this.batchUpdate("to-front",()=>{n+=s.length,s.forEach((l,a)=>{l.setZIndex(n+a,t)})})}return this}toBack(t={}){const e=this.model;if(e){let n=e.getMinZIndex(),s;t.deep?(s=this.getDescendants({deep:!0,breadthFirst:!0}),s.unshift(this)):s=[this];let r=e.indexOf(this)!==0;r||(r=s.some((o,l)=>o.getZIndex()!==n+l)),r&&this.batchUpdate("to-back",()=>{n-=s.length,s.forEach((o,l)=>{o.setZIndex(n+l,t)})})}return this}get markup(){return this.getMarkup()}set markup(t){t==null?this.removeMarkup():this.setMarkup(t)}getMarkup(){let t=this.store.get("markup");return t==null&&(t=this.constructor.getMarkup()),t}setMarkup(t,e={}){return this.store.set("markup",t,e),this}removeMarkup(t={}){return this.store.remove("markup",t),this}get attrs(){return this.getAttrs()}set attrs(t){t==null?this.removeAttrs():this.setAttrs(t)}getAttrs(){const t=this.store.get("attrs");return t?Object.assign({},t):{}}setAttrs(t,e={}){if(t==null)this.removeAttrs(e);else{const n=s=>this.store.set("attrs",s,e);if(e.overwrite===!0)n(t);else{const s=this.getAttrs();e.deep===!1?n(Object.assign(Object.assign({},s),t)):n(st({},s,t))}}return this}replaceAttrs(t,e={}){return this.setAttrs(t,Object.assign(Object.assign({},e),{overwrite:!0}))}updateAttrs(t,e={}){return this.setAttrs(t,Object.assign(Object.assign({},e),{deep:!1}))}removeAttrs(t={}){return this.store.remove("attrs",t),this}getAttrDefinition(t){if(!t)return null;const n=this.constructor.getAttrHooks()||{};let s=n[t]||Tt.registry.get(t);if(!s){const r=Dn(t);s=n[r]||Tt.registry.get(r)}return s||null}getAttrByPath(t){return t==null||t===""?this.getAttrs():this.getPropByPath(this.prefixAttrPath(t))}setAttrByPath(t,e,n={}){return this.setPropByPath(this.prefixAttrPath(t),e,n),this}removeAttrByPath(t,e={}){return this.removePropByPath(this.prefixAttrPath(t),e),this}prefixAttrPath(t){return Array.isArray(t)?["attrs"].concat(t):`attrs/${t}`}attr(t,e,n){return t==null?this.getAttrByPath():typeof t=="string"||Array.isArray(t)?arguments.length===1?this.getAttrByPath(t):e==null?this.removeAttrByPath(t,n||{}):this.setAttrByPath(t,e,n||{}):this.setAttrs(t,e||{})}get visible(){return this.isVisible()}set visible(t){this.setVisible(t)}setVisible(t,e={}){return this.store.set("visible",t,e),this}isVisible(){return this.store.get("visible")!==!1}show(t={}){return this.isVisible()||this.setVisible(!0,t),this}hide(t={}){return this.isVisible()&&this.setVisible(!1,t),this}toggleVisible(t,e={}){const n=typeof t=="boolean"?t:!this.isVisible(),s=typeof t=="boolean"?e:t;return n?this.show(s):this.hide(s),this}get data(){return this.getData()}set data(t){this.setData(t)}getData(){return this.store.get("data")}setData(t,e={}){if(t==null)this.removeData(e);else{const n=s=>this.store.set("data",s,e);if(e.overwrite===!0)n(t);else{const s=this.getData();e.deep===!1?n(typeof t=="object"?Object.assign(Object.assign({},s),t):t):n(st({},s,t))}}return this}replaceData(t,e={}){return this.setData(t,Object.assign(Object.assign({},e),{overwrite:!0}))}updateData(t,e={}){return this.setData(t,Object.assign(Object.assign({},e),{deep:!1}))}removeData(t={}){return this.store.remove("data",t),this}get parent(){return this.getParent()}get children(){return this.getChildren()}getParentId(){return this.store.get("parent")}getParent(){const t=this.getParentId();if(t&&this.model){const e=this.model.getCell(t);return this._parent=e,e}return null}getChildren(){const t=this.store.get("children");if(t&&t.length&&this.model){const e=t.map(n=>{var s;return(s=this.model)===null||s===void 0?void 0:s.getCell(n)}).filter(n=>n!=null);return this._children=e,[...e]}return null}hasParent(){return this.parent!=null}isParentOf(t){return t!=null&&t.getParent()===this}isChildOf(t){return t!=null&&this.getParent()===t}eachChild(t,e){return this.children&&this.children.forEach(t,e),this}filterChild(t,e){return this.children?this.children.filter(t,e):[]}getChildCount(){return this.children==null?0:this.children.length}getChildIndex(t){return this.children==null?-1:this.children.indexOf(t)}getChildAt(t){return this.children!=null&&t>=0?this.children[t]:null}getAncestors(t={}){const e=[];let n=this.getParent();for(;n;)e.push(n),n=t.deep!==!1?n.getParent():null;return e}getDescendants(t={}){if(t.deep!==!1){if(t.breadthFirst){const e=[],n=this.getChildren()||[];for(;n.length>0;){const s=n.shift(),r=s.getChildren();e.push(s),r&&n.push(...r)}return e}{const e=this.getChildren()||[];return e.forEach(n=>{e.push(...n.getDescendants(t))}),e}}return this.getChildren()||[]}isDescendantOf(t,e={}){if(t==null)return!1;if(e.deep!==!1){let n=this.getParent();for(;n;){if(n===t)return!0;n=n.getParent()}return!1}return this.isChildOf(t)}isAncestorOf(t,e={}){return t==null?!1:t.isDescendantOf(this,e)}contains(t){return this.isAncestorOf(t)}getCommonAncestor(...t){return V.getCommonAncestor(this,...t)}setParent(t,e={}){return this._parent=t,t?this.store.set("parent",t.id,e):this.store.remove("parent",e),this}setChildren(t,e={}){return this._children=t,t!=null?this.store.set("children",t.map(n=>n.id),e):this.store.remove("children",e),this}unembed(t,e={}){const n=this.children;if(n!=null&&t!=null){const s=this.getChildIndex(t);s!==-1&&(n.splice(s,1),t.setParent(null,e),this.setChildren(n,e))}return this}embed(t,e={}){return t.addTo(this,e),this}addTo(t,e={}){return V.isCell(t)?t.addChild(this,e):t.addCell(this,e),this}insertTo(t,e,n={}){return t.insertChild(this,e,n),this}addChild(t,e={}){return this.insertChild(t,void 0,e)}insertChild(t,e,n={}){if(t!=null&&t!==this){const s=t.getParent(),r=this!==s;let o=e;if(o==null&&(o=this.getChildCount(),r||(o-=1)),s){const a=s.getChildren();if(a){const c=a.indexOf(t);c>=0&&(t.setParent(null,n),a.splice(c,1),s.setChildren(a,n))}}let l=this.children;if(l==null?(l=[],l.push(t)):l.splice(o,0,t),t.setParent(this,n),this.setChildren(l,n),r&&this.model){const a=this.model.getIncomingEdges(this),c=this.model.getOutgoingEdges(this);a&&a.forEach(h=>h.updateParent(n)),c&&c.forEach(h=>h.updateParent(n))}this.model&&this.model.addCell(t,n)}return this}removeFromParent(t={}){const e=this.getParent();if(e!=null){const n=e.getChildIndex(this);e.removeChildAt(n,t)}return this}removeChild(t,e={}){const n=this.getChildIndex(t);return this.removeChildAt(n,e)}removeChildAt(t,e={}){const n=this.getChildAt(t);return this.children!=null&&n!=null&&(this.unembed(n,e),n.remove(e)),n}remove(t={}){return this.batchUpdate("remove",()=>{const e=this.getParent();e&&e.removeChild(this,t),t.deep!==!1&&this.eachChild(n=>n.remove(t)),this.model&&this.model.removeCell(this,t)}),this}transition(t,e,n={},s="/"){return this.animation.start(t,e,n,s)}stopTransition(t,e,n="/"){return this.animation.stop(t,e,n),this}getTransitions(){return this.animation.get()}translate(t,e,n){return this}scale(t,e,n,s){return this}addTools(t,e,n){const s=Array.isArray(t)?t:[t],r=typeof e=="string"?e:null,o=typeof e=="object"?e:typeof n=="object"?n:{};if(o.reset)return this.setTools({name:r,items:s,local:o.local},o);let l=K(this.getTools());if(l==null||r==null||l.name===r)return l==null&&(l={}),l.items||(l.items=[]),l.name=r,l.items=[...l.items,...s],this.setTools(Object.assign({},l),o)}setTools(t,e={}){return t==null?this.removeTools():this.store.set("tools",V.normalizeTools(t),e),this}getTools(){return this.store.get("tools")}removeTools(t={}){return this.store.remove("tools",t),this}hasTools(t){const e=this.getTools();return e==null?!1:t==null?!0:e.name===t}hasTool(t){const e=this.getTools();return e==null?!1:e.items.some(n=>typeof n=="string"?n===t:n.name===t)}removeTool(t,e={}){const n=K(this.getTools());if(n){let s=!1;const r=n.items.slice(),o=l=>{r.splice(l,1),s=!0};if(typeof t=="number")o(t);else for(let l=r.length-1;l>=0;l-=1){const a=r[l];(typeof a=="string"?a===t:a.name===t)&&o(l)}s&&(n.items=r,this.setTools(n,e))}return this}getBBox(t){return new T}getConnectionPoint(t,e){return new w}toJSON(t={}){const e=Object.assign({},this.store.get()),n=Object.prototype.toString,s=this.isNode()?"node":this.isEdge()?"edge":"cell";if(!e.shape){const g=this.constructor;throw new Error(`Unable to serialize ${s} missing "shape" prop, check the ${s} "${g.name||n.call(g)}"`)}const r=this.constructor,o=t.diff===!0,l=e.attrs||{},a=r.getDefaults(!0),c=o?this.preprocess(a,!0):a,h=c.attrs||{},u={};Object.entries(e).forEach(([g,p])=>{if(p!=null&&!Array.isArray(p)&&typeof p=="object"&&!zt(p))throw new Error(`Can only serialize ${s} with plain-object props, but got a "${n.call(p)}" type of key "${g}" on ${s} "${this.id}"`);if(g!=="attrs"&&g!=="shape"&&o){const m=c[g];It(p,m)&&delete e[g]}}),Object.keys(l).forEach(g=>{const p=l[g],m=h[g];Object.keys(p).forEach(b=>{const x=p[b],y=m?m[b]:null;x!=null&&typeof x=="object"&&!Array.isArray(x)?Object.keys(x).forEach(v=>{const P=x[v];if(m==null||y==null||!ie(y)||!It(y[v],P)){u[g]==null&&(u[g]={}),u[g][b]==null&&(u[g][b]={});const C=u[g][b];C[v]=P}}):(m==null||!It(y,x))&&(u[g]==null&&(u[g]={}),u[g][b]=x)})});const f=Object.assign(Object.assign({},e),{attrs:Ai(u)?void 0:u});f.attrs==null&&delete f.attrs;const d=f;return d.angle===0&&delete d.angle,K(d)}clone(t={}){if(!t.deep){const n=Object.assign({},this.store.get());t.keepId||delete n.id,delete n.parent,delete n.children;const s=this.constructor;return new s(n)}return V.deepClone(this)[this.id]}findView(t){return t.findViewByCell(this)}startBatch(t,e={},n=this.model){return this.notify("batch:start",{name:t,data:e,cell:this}),n&&n.startBatch(t,Object.assign(Object.assign({},e),{cell:this})),this}stopBatch(t,e={},n=this.model){return n&&n.stopBatch(t,Object.assign(Object.assign({},e),{cell:this})),this.notify("batch:stop",{name:t,data:e,cell:this}),this}batchUpdate(t,e,n){const s=this.model;this.startBatch(t,n,s);const r=e();return this.stopBatch(t,n,s),r}dispose(){this.removeFromParent(),this.store.dispose()}}V.defaults={};V.attrHooks={};V.propHooks=[];Zu([yt.dispose()],V.prototype,"dispose",null);(function(i){function t(e){return typeof e=="string"?{items:[e]}:Array.isArray(e)?{items:e}:e.items?e:{items:[e]}}i.normalizeTools=t})(V||(V={}));(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag],s=e;return(n==null||n===i.toStringTag)&&typeof s.isNode=="function"&&typeof s.isEdge=="function"&&typeof s.prop=="function"&&typeof s.attr=="function"}i.isCell=t})(V||(V={}));(function(i){function t(...r){const o=r.filter(a=>a!=null).map(a=>a.getAncestors()).sort((a,c)=>a.length-c.length);return o.shift().find(a=>o.every(c=>c.includes(a)))||null}i.getCommonAncestor=t;function e(r,o={}){let l=null;for(let a=0,c=r.length;a<c;a+=1){const h=r[a];let u=h.getBBox(o);if(u){if(h.isNode()){const f=h.getAngle();f!=null&&f!==0&&(u=u.bbox(f))}l=l==null?u:l.union(u)}}return l}i.getCellsBBox=e;function n(r){const o=[r,...r.getDescendants({deep:!0})];return i.cloneCells(o)}i.deepClone=n;function s(r){const o=xi(r),l=o.reduce((a,c)=>(a[c.id]=c.clone(),a),{});return o.forEach(a=>{const c=l[a.id];if(c.isEdge()){const f=c.getSourceCellId(),d=c.getTargetCellId();f&&l[f]&&c.setSource(Object.assign(Object.assign({},c.getSource()),{cell:l[f].id})),d&&l[d]&&c.setTarget(Object.assign(Object.assign({},c.getTarget()),{cell:l[d].id}))}const h=a.getParent();h&&l[h.id]&&c.setParent(l[h.id]);const u=a.getChildren();if(u&&u.length){const f=u.reduce((d,g)=>(l[g.id]&&d.push(l[g.id]),d),[]);f.length>0&&c.setChildren(f)}}),l}i.cloneCells=s})(V||(V={}));(function(i){i.config({propHooks(t){var{tools:e}=t,n=Qr(t,["tools"]);return e&&(n.tools=i.normalizeTools(e)),n}})})(V||(V={}));var Ne;(function(i){let t,e;function n(o,l){return l?t!=null&&t.exist(o):e!=null&&e.exist(o)}i.exist=n;function s(o){t=o}i.setEdgeRegistry=s;function r(o){e=o}i.setNodeRegistry=r})(Ne||(Ne={}));class Ku{constructor(t){this.ports=[],this.groups={},this.init(K(t))}getPorts(){return this.ports}getGroup(t){return t!=null?this.groups[t]:null}getPortsByGroup(t){return this.ports.filter(e=>e.group===t||e.group==null&&t==null)}getPortsLayoutByGroup(t,e){const n=this.getPortsByGroup(t),s=t?this.getGroup(t):null,r=s?s.position:null,o=r?r.name:null;let l;if(o!=null){const u=le.registry.get(o);if(u==null)return le.registry.onNotFound(o);l=u}else l=le.presets.left;const a=n.map(u=>u&&u.position&&u.position.args||{}),c=r&&r.args||{};return l(a,e,c).map((u,f)=>{const d=n[f];return{portLayout:u,portId:d.id,portSize:d.size,portAttrs:d.attrs,labelSize:d.label.size,labelLayout:this.getPortLabelLayout(d,w.create(u.position),e)}})}init(t){const{groups:e,items:n}=t;e!=null&&Object.keys(e).forEach(s=>{this.groups[s]=this.parseGroup(e[s])}),Array.isArray(n)&&n.forEach(s=>{this.ports.push(this.parsePort(s))})}parseGroup(t){return Object.assign(Object.assign({},t),{label:this.getLabel(t,!0),position:this.getPortPosition(t.position,!0)})}parsePort(t){const e=Object.assign({},t),n=this.getGroup(t.group)||{};return e.markup=e.markup||n.markup,e.attrs=st({},n.attrs,e.attrs),e.position=this.createPosition(n,e),e.label=st({},n.label,this.getLabel(e)),e.zIndex=this.getZIndex(n,e),e.size=Object.assign(Object.assign({},n.size),e.size),e}getZIndex(t,e){return typeof e.zIndex=="number"?e.zIndex:typeof t.zIndex=="number"||t.zIndex==="auto"?t.zIndex:"auto"}createPosition(t,e){return st({name:"left",args:{}},t.position,{args:e.args})}getPortPosition(t,e=!1){if(t==null){if(e)return{name:"left",args:{}}}else{if(typeof t=="string")return{name:t,args:{}};if(Array.isArray(t))return{name:"absolute",args:{x:t[0],y:t[1]}};if(typeof t=="object")return t}return{args:{}}}getPortLabelPosition(t,e=!1){if(t==null){if(e)return{name:"left",args:{}}}else{if(typeof t=="string")return{name:t,args:{}};if(typeof t=="object")return t}return{args:{}}}getLabel(t,e=!1){const n=t.label||{};return n.position=this.getPortLabelPosition(n.position,e),n}getPortLabelLayout(t,e,n){const s=t.label.position.name||"left",r=t.label.position.args||{},o=Ce.registry.get(s)||Ce.presets.left;return o?o(e,n,r):null}}var Fn=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};let lt=class to extends V{get[Symbol.toStringTag](){return to.toStringTag}constructor(t={}){super(t),this.initPorts()}preprocess(t,e){const{x:n,y:s,width:r,height:o}=t,l=Fn(t,["x","y","width","height"]);if(n!=null||s!=null){const a=l.position;l.position=Object.assign(Object.assign({},a),{x:n!=null?n:a?a.x:0,y:s!=null?s:a?a.y:0})}if(r!=null||o!=null){const a=l.size;l.size=Object.assign(Object.assign({},a),{width:r!=null?r:a?a.width:0,height:o!=null?o:a?a.height:0})}return super.preprocess(l,e)}isNode(){return!0}size(t,e,n){return t===void 0?this.getSize():typeof t=="number"?this.setSize(t,e,n):this.setSize(t,e)}getSize(){const t=this.store.get("size");return t?Object.assign({},t):{width:1,height:1}}setSize(t,e,n){return typeof t=="object"?this.resize(t.width,t.height,e):this.resize(t,e,n),this}resize(t,e,n={}){this.startBatch("resize",n);const s=n.direction;if(s){const r=this.getSize();switch(s){case"left":case"right":e=r.height;break;case"top":case"bottom":t=r.width;break}let l={right:0,"top-right":0,top:1,"top-left":1,left:2,"bottom-left":2,bottom:3,"bottom-right":3}[s];const a=U.normalize(this.getAngle()||0);n.absolute&&(l+=Math.floor((a+45)/90),l%=4);const c=this.getBBox();let h;l===0?h=c.getBottomLeft():l===1?h=c.getCorner():l===2?h=c.getTopRight():h=c.getOrigin();const u=h.clone().rotate(-a,c.getCenter()),f=Math.sqrt(t*t+e*e)/2;let d=l*Math.PI/2;d+=Math.atan(l%2===0?e/t:t/e),d-=U.toRad(a);const p=w.fromPolar(f,d,u).clone().translate(t/-2,e/-2);this.store.set("size",{width:t,height:e},n),this.setPosition(p.x,p.y,n)}else this.store.set("size",{width:t,height:e},n);return this.stopBatch("resize",n),this}scale(t,e,n,s={}){const r=this.getBBox().scale(t,e,n==null?void 0:n);return this.startBatch("scale",s),this.setPosition(r.x,r.y,s),this.resize(r.width,r.height,s),this.stopBatch("scale"),this}position(t,e,n){return typeof t=="number"?this.setPosition(t,e,n):this.getPosition(t)}getPosition(t={}){if(t.relative){const n=this.getParent();if(n!=null&&n.isNode()){const s=this.getPosition(),r=n.getPosition();return{x:s.x-r.x,y:s.y-r.y}}}const e=this.store.get("position");return e?Object.assign({},e):{x:0,y:0}}setPosition(t,e,n={}){let s,r,o;if(typeof t=="object"?(s=t.x,r=t.y,o=e||{}):(s=t,r=e,o=n||{}),o.relative){const l=this.getParent();if(l!=null&&l.isNode()){const a=l.getPosition();s+=a.x,r+=a.y}}if(o.deep){const l=this.getPosition();this.translate(s-l.x,r-l.y,o)}else this.store.set("position",{x:s,y:r},o);return this}translate(t=0,e=0,n={}){if(t===0&&e===0)return this;n.translateBy=n.translateBy||this.id;const s=this.getPosition();if(n.restrict!=null&&n.translateBy===this.id){const o=this.getBBox({deep:!0}),l=n.restrict,a=s.x-o.x,c=s.y-o.y,h=Math.max(l.x+a,Math.min(l.x+l.width+a-o.width,s.x+t)),u=Math.max(l.y+c,Math.min(l.y+l.height+c-o.height,s.y+e));t=h-s.x,e=u-s.y}const r={x:s.x+t,y:s.y+e};return n.tx=t,n.ty=e,n.transition?(typeof n.transition!="object"&&(n.transition={}),this.transition("position",r,Object.assign(Object.assign({},n.transition),{interp:oe.object})),this.eachChild(o=>{var l;((l=n.exclude)===null||l===void 0?void 0:l.includes(o))||o.translate(t,e,n)})):(this.startBatch("translate",n),this.store.set("position",r,n),this.eachChild(o=>{var l;((l=n.exclude)===null||l===void 0?void 0:l.includes(o))||o.translate(t,e,n)}),this.stopBatch("translate",n)),this}angle(t,e){return t==null?this.getAngle():this.rotate(t,e)}getAngle(){return this.store.get("angle",0)}rotate(t,e={}){const n=this.getAngle();if(e.center){const s=this.getSize(),r=this.getPosition(),o=this.getBBox().getCenter();o.rotate(n-t,e.center);const l=o.x-s.width/2-r.x,a=o.y-s.height/2-r.y;this.startBatch("rotate",{angle:t,options:e}),this.setPosition(r.x+l,r.y+a,e),this.rotate(t,Object.assign(Object.assign({},e),{center:null})),this.stopBatch("rotate")}else this.store.set("angle",e.absolute?t:(n+t)%360,e);return this}getBBox(t={}){if(t.deep){const e=this.getDescendants({deep:!0,breadthFirst:!0});return e.push(this),V.getCellsBBox(e)}return T.fromPositionAndSize(this.getPosition(),this.getSize())}getConnectionPoint(t,e){const n=this.getBBox(),s=n.getCenter(),r=t.getTerminal(e);if(r==null)return s;const o=r.port;if(!o||!this.hasPort(o))return s;const l=this.getPort(o);if(!l||!l.group)return s;const c=this.getPortsPosition(l.group)[o].position,h=w.create(c).translate(n.getOrigin()),u=this.getAngle();return u&&h.rotate(-u,s),h}fit(t={}){const n=(this.getChildren()||[]).filter(c=>c.isNode());if(n.length===0)return this;this.startBatch("fit-embeds",t),t.deep&&n.forEach(c=>c.fit(t));let{x:s,y:r,width:o,height:l}=V.getCellsBBox(n);const a=ce(t.padding);return s-=a.left,r-=a.top,o+=a.left+a.right,l+=a.bottom+a.top,this.store.set({position:{x:s,y:r},size:{width:o,height:l}},t),this.stopBatch("fit-embeds"),this}get portContainerMarkup(){return this.getPortContainerMarkup()}set portContainerMarkup(t){this.setPortContainerMarkup(t)}getDefaultPortContainerMarkup(){return this.store.get("defaultPortContainerMarkup")||W.getPortContainerMarkup()}getPortContainerMarkup(){return this.store.get("portContainerMarkup")||this.getDefaultPortContainerMarkup()}setPortContainerMarkup(t,e={}){return this.store.set("portContainerMarkup",W.clone(t),e),this}get portMarkup(){return this.getPortMarkup()}set portMarkup(t){this.setPortMarkup(t)}getDefaultPortMarkup(){return this.store.get("defaultPortMarkup")||W.getPortMarkup()}getPortMarkup(){return this.store.get("portMarkup")||this.getDefaultPortMarkup()}setPortMarkup(t,e={}){return this.store.set("portMarkup",W.clone(t),e),this}get portLabelMarkup(){return this.getPortLabelMarkup()}set portLabelMarkup(t){this.setPortLabelMarkup(t)}getDefaultPortLabelMarkup(){return this.store.get("defaultPortLabelMarkup")||W.getPortLabelMarkup()}getPortLabelMarkup(){return this.store.get("portLabelMarkup")||this.getDefaultPortLabelMarkup()}setPortLabelMarkup(t,e={}){return this.store.set("portLabelMarkup",W.clone(t),e),this}get ports(){const t=this.store.get("ports",{items:[]});return t.items==null&&(t.items=[]),t}getPorts(){return K(this.ports.items)}getPortsByGroup(t){return this.getPorts().filter(e=>e.group===t)}getPort(t){return K(this.ports.items.find(e=>e.id&&e.id===t))}getPortAt(t){return this.ports.items[t]||null}hasPorts(){return this.ports.items.length>0}hasPort(t){return this.getPortIndex(t)!==-1}getPortIndex(t){const e=typeof t=="string"?t:t.id;return e!=null?this.ports.items.findIndex(n=>n.id===e):-1}getPortsPosition(t){const e=this.getSize();return this.port.getPortsLayoutByGroup(t,new T(0,0,e.width,e.height)).reduce((s,r)=>{const o=r.portLayout;return s[r.portId]={position:Object.assign({},o.position),angle:o.angle||0},s},{})}getPortProp(t,e){return this.getPropByPath(this.prefixPortPath(t,e))}setPortProp(t,e,n,s){if(typeof e=="string"||Array.isArray(e)){const l=this.prefixPortPath(t,e),a=n;return this.setPropByPath(l,a,s)}const r=this.prefixPortPath(t),o=e;return this.setPropByPath(r,o,n)}removePortProp(t,e,n){return typeof e=="string"||Array.isArray(e)?this.removePropByPath(this.prefixPortPath(t,e),n):this.removePropByPath(this.prefixPortPath(t),e)}portProp(t,e,n,s){return e==null?this.getPortProp(t):typeof e=="string"||Array.isArray(e)?arguments.length===2?this.getPortProp(t,e):n==null?this.removePortProp(t,e,s):this.setPortProp(t,e,n,s):this.setPortProp(t,e,n)}prefixPortPath(t,e){const n=this.getPortIndex(t);if(n===-1)throw new Error(`Unable to find port with id: "${t}"`);return e==null||e===""?["ports","items",`${n}`]:Array.isArray(e)?["ports","items",`${n}`,...e]:`ports/items/${n}/${e}`}addPort(t,e){const n=[...this.ports.items];return n.push(t),this.setPropByPath("ports/items",n,e),this}addPorts(t,e){return this.setPropByPath("ports/items",[...this.ports.items,...t],e),this}insertPort(t,e,n){const s=[...this.ports.items];return s.splice(t,0,e),this.setPropByPath("ports/items",s,n),this}removePort(t,e={}){return this.removePortAt(this.getPortIndex(t),e)}removePortAt(t,e={}){if(t>=0){const n=[...this.ports.items];n.splice(t,1),e.rewrite=!0,this.setPropByPath("ports/items",n,e)}return this}removePorts(t,e){let n;if(Array.isArray(t)){if(n=e||{},t.length){n.rewrite=!0;const r=[...this.ports.items].filter(o=>!t.some(l=>{const a=typeof l=="string"?l:l.id;return o.id===a}));this.setPropByPath("ports/items",r,n)}}else n=t||{},n.rewrite=!0,this.setPropByPath("ports/items",[],n);return this}getParsedPorts(){return this.port.getPorts()}getParsedGroups(){return this.port.groups}getPortsLayoutByGroup(t,e){return this.port.getPortsLayoutByGroup(t,e)}initPorts(){this.updatePortData(),this.on("change:ports",()=>{this.processRemovedPort(),this.updatePortData()})}processRemovedPort(){const t=this.ports,e={};t.items.forEach(o=>{o.id&&(e[o.id]=!0)});const n={};(this.store.getPrevious("ports")||{items:[]}).items.forEach(o=>{o.id&&!e[o.id]&&(n[o.id]=!0)});const r=this.model;r&&!Ai(n)&&(r.getConnectedEdges(this,{incoming:!0}).forEach(a=>{const c=a.getTargetPortId();c&&n[c]&&a.remove()}),r.getConnectedEdges(this,{outgoing:!0}).forEach(a=>{const c=a.getSourcePortId();c&&n[c]&&a.remove()}))}validatePorts(){const t={},e=[];return this.ports.items.forEach(n=>{typeof n!="object"&&e.push(`Invalid port ${n}.`),n.id==null&&(n.id=this.generatePortId()),t[n.id]&&e.push("Duplicitied port id."),t[n.id]=!0}),e}generatePortId(){return xn()}updatePortData(){const t=this.validatePorts();if(t.length>0)throw this.store.set("ports",this.store.getPrevious("ports")),new Error(t.join(" "));const e=this.port?this.port.getPorts():null;this.port=new Ku(this.ports);const n=this.port.getPorts(),s=e?n.filter(o=>e.find(l=>l.id===o.id)?null:o):[...n],r=e?e.filter(o=>n.find(l=>l.id===o.id)?null:o):[];s.length>0&&this.notify("ports:added",{added:s,cell:this,node:this}),r.length>0&&this.notify("ports:removed",{removed:r,cell:this,node:this})}};lt.defaults={angle:0,position:{x:0,y:0},size:{width:1,height:1}};(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag],s=e;return(n==null||n===i.toStringTag)&&typeof s.isNode=="function"&&typeof s.isEdge=="function"&&typeof s.prop=="function"&&typeof s.attr=="function"&&typeof s.size=="function"&&typeof s.position=="function"}i.isNode=t})(lt||(lt={}));(function(i){i.config({propHooks(t){var{ports:e}=t,n=Fn(t,["ports"]);return e&&(n.ports=Array.isArray(e)?{items:e}:e),n}})})(lt||(lt={}));(function(i){i.registry=nt.create({type:"node",process(t,e){if(Ne.exist(t,!0))throw new Error(`Node with name '${t}' was registered by anthor Edge`);if(typeof e=="function")return e.config({shape:t}),e;let n=i;const{inherit:s}=e,r=Fn(e,["inherit"]);if(s)if(typeof s=="string"){const l=this.get(s);l==null?this.onNotFound(s,"inherited"):n=l}else n=s;r.constructorName==null&&(r.constructorName=t);const o=n.define.call(n,r);return o.config({shape:t}),o}}),Ne.setNodeRegistry(i.registry)})(lt||(lt={}));(function(i){let t=0;function e(r){return r?ms(r):(t+=1,`CustomNode${t}`)}function n(r){const{constructorName:o,overwrite:l}=r,a=Fn(r,["constructorName","overwrite"]),c=gs(e(o||a.shape),this);return c.config(a),a.shape&&i.registry.register(a.shape,c,l),c}i.define=n;function s(r){const o=r.shape||"rect",l=i.registry.get(o);return l?new l(r):i.registry.onNotFound(o)}i.create=s})(lt||(lt={}));var qn=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};let Q=class eo extends V{get[Symbol.toStringTag](){return eo.toStringTag}constructor(t={}){super(t)}preprocess(t,e){const{source:n,sourceCell:s,sourcePort:r,sourcePoint:o,target:l,targetCell:a,targetPort:c,targetPoint:h}=t,f=qn(t,["source","sourceCell","sourcePort","sourcePoint","target","targetCell","targetPort","targetPoint"]),d=g=>typeof g=="string"||typeof g=="number";if(n!=null)if(V.isCell(n))f.source={cell:n.id};else if(d(n))f.source={cell:n};else if(w.isPoint(n))f.source=n.toJSON();else if(Array.isArray(n))f.source={x:n[0],y:n[1]};else{const g=n.cell;V.isCell(g)?f.source=Object.assign(Object.assign({},n),{cell:g.id}):f.source=n}if(s!=null||r!=null){let g=f.source;if(s!=null){const p=d(s)?s:s.id;g?g.cell=p:g=f.source={cell:p}}r!=null&&g&&(g.port=r)}else o!=null&&(f.source=w.create(o).toJSON());if(l!=null)if(V.isCell(l))f.target={cell:l.id};else if(d(l))f.target={cell:l};else if(w.isPoint(l))f.target=l.toJSON();else if(Array.isArray(l))f.target={x:l[0],y:l[1]};else{const g=l.cell;V.isCell(g)?f.target=Object.assign(Object.assign({},l),{cell:g.id}):f.target=l}if(a!=null||c!=null){let g=f.target;if(a!=null){const p=d(a)?a:a.id;g?g.cell=p:g=f.target={cell:p}}c!=null&&g&&(g.port=c)}else h!=null&&(f.target=w.create(h).toJSON());return super.preprocess(f,e)}setup(){super.setup(),this.on("change:labels",t=>this.onLabelsChanged(t)),this.on("change:vertices",t=>this.onVertexsChanged(t))}isEdge(){return!0}disconnect(t={}){return this.store.set({source:{x:0,y:0},target:{x:0,y:0}},t),this}get source(){return this.getSource()}set source(t){this.setSource(t)}getSource(){return this.getTerminal("source")}getSourceCellId(){return this.source.cell}getSourcePortId(){return this.source.port}setSource(t,e,n={}){return this.setTerminal("source",t,e,n)}get target(){return this.getTarget()}set target(t){this.setTarget(t)}getTarget(){return this.getTerminal("target")}getTargetCellId(){return this.target.cell}getTargetPortId(){return this.target.port}setTarget(t,e,n={}){return this.setTerminal("target",t,e,n)}getTerminal(t){return Object.assign({},this.store.get(t))}setTerminal(t,e,n,s={}){if(V.isCell(e))return this.store.set(t,st({},n,{cell:e.id}),s),this;const r=e;return w.isPoint(e)||r.x!=null&&r.y!=null?(this.store.set(t,st({},n,{x:r.x,y:r.y}),s),this):(this.store.set(t,K(e),s),this)}getSourcePoint(){return this.getTerminalPoint("source")}getTargetPoint(){return this.getTerminalPoint("target")}getTerminalPoint(t){const e=this[t];if(w.isPointLike(e))return w.create(e);const n=this.getTerminalCell(t);return n?n.getConnectionPoint(this,t):new w}getSourceCell(){return this.getTerminalCell("source")}getTargetCell(){return this.getTerminalCell("target")}getTerminalCell(t){if(this.model){const e=t==="source"?this.getSourceCellId():this.getTargetCellId();if(e)return this.model.getCell(e)}return null}getSourceNode(){return this.getTerminalNode("source")}getTargetNode(){return this.getTerminalNode("target")}getTerminalNode(t){let e=this;const n={};for(;e&&e.isEdge();){if(n[e.id])return null;n[e.id]=!0,e=e.getTerminalCell(t)}return e&&e.isNode()?e:null}get router(){return this.getRouter()}set router(t){t==null?this.removeRouter():this.setRouter(t)}getRouter(){return this.store.get("router")}setRouter(t,e,n){return typeof t=="object"?this.store.set("router",t,e):this.store.set("router",{name:t,args:e},n),this}removeRouter(t={}){return this.store.remove("router",t),this}get connector(){return this.getConnector()}set connector(t){t==null?this.removeConnector():this.setConnector(t)}getConnector(){return this.store.get("connector")}setConnector(t,e,n){return typeof t=="object"?this.store.set("connector",t,e):this.store.set("connector",{name:t,args:e},n),this}removeConnector(t={}){return this.store.remove("connector",t)}getDefaultLabel(){const t=this.constructor,e=this.store.get("defaultLabel")||t.defaultLabel||{};return K(e)}get labels(){return this.getLabels()}set labels(t){this.setLabels(t)}getLabels(){return[...this.store.get("labels",[])].map(t=>this.parseLabel(t))}setLabels(t,e={}){return this.store.set("labels",Array.isArray(t)?t:[t],e),this}insertLabel(t,e,n={}){const s=this.getLabels(),r=s.length;let o=e!=null&&Number.isFinite(e)?e:r;return o<0&&(o=r+o+1),s.splice(o,0,this.parseLabel(t)),this.setLabels(s,n)}appendLabel(t,e={}){return this.insertLabel(t,-1,e)}getLabelAt(t){const e=this.getLabels();return t!=null&&Number.isFinite(t)?this.parseLabel(e[t]):null}setLabelAt(t,e,n={}){if(t!=null&&Number.isFinite(t)){const s=this.getLabels();s[t]=this.parseLabel(e),this.setLabels(s,n)}return this}removeLabelAt(t,e={}){const n=this.getLabels(),s=t!=null&&Number.isFinite(t)?t:-1,r=n.splice(s,1);return this.setLabels(n,e),r.length?r[0]:null}parseLabel(t){return typeof t=="string"?this.constructor.parseStringLabel(t):t}onLabelsChanged({previous:t,current:e}){const n=t&&e?e.filter(r=>t.find(o=>r===o||It(r,o))?null:r):e?[...e]:[],s=t&&e?t.filter(r=>e.find(o=>r===o||It(r,o))?null:r):t?[...t]:[];n.length>0&&this.notify("labels:added",{added:n,cell:this,edge:this}),s.length>0&&this.notify("labels:removed",{removed:s,cell:this,edge:this})}get vertices(){return this.getVertices()}set vertices(t){this.setVertices(t)}getVertices(){return[...this.store.get("vertices",[])]}setVertices(t,e={}){const n=Array.isArray(t)?t:[t];return this.store.set("vertices",n.map(s=>w.toJSON(s)),e),this}insertVertex(t,e,n={}){const s=this.getVertices(),r=s.length;let o=e!=null&&Number.isFinite(e)?e:r;return o<0&&(o=r+o+1),s.splice(o,0,w.toJSON(t)),this.setVertices(s,n)}appendVertex(t,e={}){return this.insertVertex(t,-1,e)}getVertexAt(t){return t!=null&&Number.isFinite(t)?this.getVertices()[t]:null}setVertexAt(t,e,n={}){if(t!=null&&Number.isFinite(t)){const s=this.getVertices();s[t]=e,this.setVertices(s,n)}return this}removeVertexAt(t,e={}){const n=this.getVertices(),s=t!=null&&Number.isFinite(t)?t:-1;return n.splice(s,1),this.setVertices(n,e)}onVertexsChanged({previous:t,current:e}){const n=t&&e?e.filter(r=>t.find(o=>w.equals(r,o))?null:r):e?[...e]:[],s=t&&e?t.filter(r=>e.find(o=>w.equals(r,o))?null:r):t?[...t]:[];n.length>0&&this.notify("vertexs:added",{added:n,cell:this,edge:this}),s.length>0&&this.notify("vertexs:removed",{removed:s,cell:this,edge:this})}getDefaultMarkup(){return this.store.get("defaultMarkup")||W.getEdgeMarkup()}getMarkup(){return super.getMarkup()||this.getDefaultMarkup()}translate(t,e,n={}){return n.translateBy=n.translateBy||this.id,n.tx=t,n.ty=e,this.applyToPoints(s=>({x:(s.x||0)+t,y:(s.y||0)+e}),n)}scale(t,e,n,s={}){return this.applyToPoints(r=>w.create(r).scale(t,e,n).toJSON(),s)}applyToPoints(t,e={}){const n={},s=this.getSource(),r=this.getTarget();w.isPointLike(s)&&(n.source=t(s)),w.isPointLike(r)&&(n.target=t(r));const o=this.getVertices();return o.length>0&&(n.vertices=o.map(t)),this.store.set(n,e),this}getBBox(){return this.getPolyline().bbox()}getConnectionPoint(){return this.getPolyline().pointAt(.5)}getPolyline(){const t=[this.getSourcePoint(),...this.getVertices().map(e=>w.create(e)),this.getTargetPoint()];return new tt(t)}updateParent(t){let e=null;const n=this.getSourceCell(),s=this.getTargetCell(),r=this.getParent();return n&&s&&(n===s||n.isDescendantOf(s)?e=s:s.isDescendantOf(n)?e=n:e=V.getCommonAncestor(n,s)),r&&e&&e.id!==r.id&&r.unembed(this,t),e&&(!r||r.id!==e.id)&&e.embed(this,t),e}hasLoop(t={}){const e=this.getSource(),n=this.getTarget(),s=e.cell,r=n.cell;if(!s||!r)return!1;let o=s===r;if(!o&&t.deep&&this._model){const l=this.getSourceCell(),a=this.getTargetCell();l&&a&&(o=l.isAncestorOf(a,t)||a.isAncestorOf(l,t))}return o}getFragmentAncestor(){const t=[this,this.getSourceNode(),this.getTargetNode()].filter(e=>e!=null);return this.getCommonAncestor(...t)}isFragmentDescendantOf(t){const e=this.getFragmentAncestor();return!!e&&(e.id===t.id||e.isDescendantOf(t))}};Q.defaults={};(function(i){function t(e,n){const s=e,r=n;return s.cell===r.cell?s.port===r.port||s.port==null&&r.port==null:!1}i.equalTerminals=t})(Q||(Q={}));(function(i){i.defaultLabel={markup:[{tagName:"rect",selector:"body"},{tagName:"text",selector:"label"}],attrs:{text:{fill:"#000",fontSize:14,textAnchor:"middle",textVerticalAnchor:"middle",pointerEvents:"none"},rect:{ref:"label",fill:"#fff",rx:3,ry:3,refWidth:1,refHeight:1,refX:0,refY:0}},position:{distance:.5}};function t(e){return{attrs:{label:{text:e}}}}i.parseStringLabel=t})(Q||(Q={}));(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag],s=e;return(n==null||n===i.toStringTag)&&typeof s.isNode=="function"&&typeof s.isEdge=="function"&&typeof s.prop=="function"&&typeof s.attr=="function"&&typeof s.disconnect=="function"&&typeof s.getSource=="function"&&typeof s.getTarget=="function"}i.isEdge=t})(Q||(Q={}));(function(i){i.registry=nt.create({type:"edge",process(t,e){if(Ne.exist(t,!1))throw new Error(`Edge with name '${t}' was registered by anthor Node`);if(typeof e=="function")return e.config({shape:t}),e;let n=i;const{inherit:s="edge"}=e,r=qn(e,["inherit"]);if(typeof s=="string"){const l=this.get(s||"edge");l==null&&s?this.onNotFound(s,"inherited"):n=l}else n=s;r.constructorName==null&&(r.constructorName=t);const o=n.define.call(n,r);return o.config({shape:t}),o}}),Ne.setEdgeRegistry(i.registry)})(Q||(Q={}));(function(i){let t=0;function e(r){return r?ms(r):(t+=1,`CustomEdge${t}`)}function n(r){const{constructorName:o,overwrite:l}=r,a=qn(r,["constructorName","overwrite"]),c=gs(e(o||a.shape),this);return c.config(a),a.shape&&i.registry.register(a.shape,c,l),c}i.define=n;function s(r){const o=r.shape||"edge",l=i.registry.get(o);return l?new l(r):i.registry.onNotFound(o)}i.create=s})(Q||(Q={}));(function(i){const t="basic.edge";i.config({shape:t,propHooks(e){const{label:n,vertices:s}=e,r=qn(e,["label","vertices"]);if(n){r.labels==null&&(r.labels=[]);const o=typeof n=="string"?i.parseStringLabel(n):n;r.labels.push(o)}return s&&Array.isArray(s)&&(r.vertices=s.map(o=>w.create(o).toJSON())),r}}),i.registry.register(t,i)})(Q||(Q={}));var Qu=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class hs extends yt{constructor(t,e={}){super(),this.length=0,this.comparator=e.comparator||"zIndex",this.clean(),t&&this.reset(t,{silent:!0})}toJSON(){return this.cells.map(t=>t.toJSON())}add(t,e,n){let s,r;typeof e=="number"?(s=e,r=Object.assign({merge:!1},n)):(s=this.length,r=Object.assign({merge:!1},e)),s>this.length&&(s=this.length),s<0&&(s+=this.length+1);const o=Array.isArray(t)?t:[t],l=this.comparator&&typeof e!="number"&&r.sort!==!1,a=this.comparator||null;let c=!1;const h=[],u=[];return o.forEach(f=>{const d=this.get(f);d?r.merge&&!f.isSameStore(d)&&(d.setProp(f.getProp(),n),u.push(d),l&&!c&&(a==null||typeof a=="function"?c=d.hasChanged():typeof a=="string"?c=d.hasChanged(a):c=a.some(g=>d.hasChanged(g)))):(h.push(f),this.reference(f))}),h.length&&(l&&(c=!0),this.cells.splice(s,0,...h),this.length=this.cells.length),c&&this.sort({silent:!0}),r.silent||(h.forEach((f,d)=>{const g={cell:f,index:s+d,options:r};this.trigger("added",g),r.dryrun||f.notify("added",Object.assign({},g))}),c&&this.trigger("sorted"),(h.length||u.length)&&this.trigger("updated",{added:h,merged:u,removed:[],options:r})),this}remove(t,e={}){const n=Array.isArray(t)?t:[t],s=this.removeCells(n,e);return!e.silent&&s.length>0&&this.trigger("updated",{options:e,removed:s,added:[],merged:[]}),Array.isArray(t)?s:s[0]}removeCells(t,e){const n=[];for(let s=0;s<t.length;s+=1){const r=this.get(t[s]);if(r==null)continue;const o=this.cells.indexOf(r);this.cells.splice(o,1),this.length-=1,delete this.map[r.id],n.push(r),this.unreference(r),e.dryrun||r.remove(),e.silent||(this.trigger("removed",{cell:r,index:o,options:e}),e.dryrun||r.notify("removed",{cell:r,index:o,options:e}))}return n}reset(t,e={}){const n=this.cells.slice();if(n.forEach(s=>this.unreference(s)),this.clean(),this.add(t,Object.assign({silent:!0},e)),!e.silent){const s=this.cells.slice();this.trigger("reseted",{options:e,previous:n,current:s});const r=[],o=[];s.forEach(l=>{n.some(c=>c.id===l.id)||r.push(l)}),n.forEach(l=>{s.some(c=>c.id===l.id)||o.push(l)}),this.trigger("updated",{options:e,added:r,removed:o,merged:[]})}return this}push(t,e){return this.add(t,this.length,e)}pop(t){const e=this.at(this.length-1);return this.remove(e,t)}unshift(t,e){return this.add(t,0,e)}shift(t){const e=this.at(0);return this.remove(e,t)}get(t){if(t==null)return null;const e=typeof t=="string"||typeof t=="number"?t:t.id;return this.map[e]||null}has(t){return this.get(t)!=null}at(t){return t<0&&(t+=this.length),this.cells[t]||null}first(){return this.at(0)}last(){return this.at(-1)}indexOf(t){return this.cells.indexOf(t)}toArray(){return this.cells.slice()}sort(t={}){return this.comparator!=null&&(this.cells=al(this.cells,this.comparator),t.silent||this.trigger("sorted")),this}clone(){const t=this.constructor;return new t(this.cells.slice(),{comparator:this.comparator})}reference(t){this.map[t.id]=t,t.on("*",this.notifyCellEvent,this)}unreference(t){t.off("*",this.notifyCellEvent,this),delete this.map[t.id]}notifyCellEvent(t,e){const n=e.cell;this.trigger(`cell:${t}`,e),n&&(n.isNode()?this.trigger(`node:${t}`,Object.assign(Object.assign({},e),{node:n})):n.isEdge()&&this.trigger(`edge:${t}`,Object.assign(Object.assign({},e),{edge:n})))}clean(){this.length=0,this.cells=[],this.map={}}dispose(){this.reset([])}}Qu([hs.dispose()],hs.prototype,"dispose",null);var tf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class At extends yt{get[Symbol.toStringTag](){return At.toStringTag}constructor(t=[]){super(),this.batches={},this.addings=new WeakMap,this.nodes={},this.edges={},this.outgoings={},this.incomings={},this.collection=new hs(t),this.setup()}notify(t,e){this.trigger(t,e);const n=this.graph;return n&&(t==="sorted"||t==="reseted"||t==="updated"?n.trigger(`model:${t}`,e):n.trigger(t,e)),this}setup(){const t=this.collection;t.on("sorted",()=>this.notify("sorted",null)),t.on("updated",e=>this.notify("updated",e)),t.on("cell:change:zIndex",()=>this.sortOnChangeZ()),t.on("added",({cell:e})=>{this.onCellAdded(e)}),t.on("removed",e=>{const n=e.cell;this.onCellRemoved(n,e.options),this.notify("cell:removed",e),n.isNode()?this.notify("node:removed",Object.assign(Object.assign({},e),{node:n})):n.isEdge()&&this.notify("edge:removed",Object.assign(Object.assign({},e),{edge:n}))}),t.on("reseted",e=>{this.onReset(e.current),this.notify("reseted",e)}),t.on("edge:change:source",({edge:e})=>this.onEdgeTerminalChanged(e,"source")),t.on("edge:change:target",({edge:e})=>{this.onEdgeTerminalChanged(e,"target")})}sortOnChangeZ(){this.collection.sort()}onCellAdded(t){const e=t.id;t.isEdge()?(t.updateParent(),this.edges[e]=!0,this.onEdgeTerminalChanged(t,"source"),this.onEdgeTerminalChanged(t,"target")):this.nodes[e]=!0}onCellRemoved(t,e){const n=t.id;if(t.isEdge()){delete this.edges[n];const s=t.getSource(),r=t.getTarget();if(s&&s.cell){const o=this.outgoings[s.cell],l=o?o.indexOf(n):-1;l>=0&&(o.splice(l,1),o.length===0&&delete this.outgoings[s.cell])}if(r&&r.cell){const o=this.incomings[r.cell],l=o?o.indexOf(n):-1;l>=0&&(o.splice(l,1),o.length===0&&delete this.incomings[r.cell])}}else delete this.nodes[n];e.clear||(e.disconnectEdges?this.disconnectConnectedEdges(t,e):this.removeConnectedEdges(t,e)),t.model===this&&(t.model=null)}onReset(t){this.nodes={},this.edges={},this.outgoings={},this.incomings={},t.forEach(e=>this.onCellAdded(e))}onEdgeTerminalChanged(t,e){const n=e==="source"?this.outgoings:this.incomings,s=t.previous(e);if(s&&s.cell){const o=V.isCell(s.cell)?s.cell.id:s.cell,l=n[o],a=l?l.indexOf(t.id):-1;a>=0&&(l.splice(a,1),l.length===0&&delete n[o])}const r=t.getTerminal(e);if(r&&r.cell){const o=V.isCell(r.cell)?r.cell.id:r.cell,l=n[o]||[];l.indexOf(t.id)===-1&&l.push(t.id),n[o]=l}}prepareCell(t,e){return!t.model&&(!e||!e.dryrun)&&(t.model=this),t.zIndex==null&&t.setZIndex(this.getMaxZIndex()+1,{silent:!0}),t}resetCells(t,e={}){return t.map(n=>this.prepareCell(n,Object.assign(Object.assign({},e),{dryrun:!0}))),this.collection.reset(t,e),t.map(n=>this.prepareCell(n,{options:e})),this}clear(t={}){const e=this.getCells();if(e.length===0)return this;const n=Object.assign(Object.assign({},t),{clear:!0});return this.batchUpdate("clear",()=>{const s=e.sort((r,o)=>{const l=r.isEdge()?1:2,a=o.isEdge()?1:2;return l-a});for(;s.length>0;){const r=s.shift();r&&r.remove(n)}},n),this}addNode(t,e={}){const n=lt.isNode(t)?t:this.createNode(t);return this.addCell(n,e),n}updateNode(t,e={}){const n=this.createNode(t),s=n.getProp();return n.dispose(),this.updateCell(s,e)}createNode(t){return lt.create(t)}addEdge(t,e={}){const n=Q.isEdge(t)?t:this.createEdge(t);return this.addCell(n,e),n}createEdge(t){return Q.create(t)}updateEdge(t,e={}){const n=this.createEdge(t),s=n.getProp();return n.dispose(),this.updateCell(s,e)}addCell(t,e={}){return Array.isArray(t)?this.addCells(t,e):(!this.collection.has(t)&&!this.addings.has(t)&&(this.addings.set(t,!0),this.collection.add(this.prepareCell(t,e),e),t.eachChild(n=>this.addCell(n,e)),this.addings.delete(t)),this)}addCells(t,e={}){const n=t.length;if(n===0)return this;const s=Object.assign(Object.assign({},e),{position:n-1,maxPosition:n-1});return this.startBatch("add",Object.assign(Object.assign({},s),{cells:t})),t.forEach(r=>{this.addCell(r,s),s.position-=1}),this.stopBatch("add",Object.assign(Object.assign({},s),{cells:t})),this}updateCell(t,e={}){const n=t.id&&this.getCell(t.id);return n?this.batchUpdate("update",()=>(Object.entries(t).forEach(([s,r])=>n.setProp(s,r,e)),!0),t):!1}removeCell(t,e={}){const n=typeof t=="string"?this.getCell(t):t;return n&&this.has(n)?this.collection.remove(n,e):null}updateCellId(t,e){if(t.id===e)return;this.startBatch("update",{id:e}),t.prop("id",e);const n=t.clone({keepId:!0});return this.addCell(n),this.getConnectedEdges(t).forEach(r=>{const o=r.getSourceCell(),l=r.getTargetCell();o===t&&r.setSource(Object.assign(Object.assign({},r.getSource()),{cell:e})),l===t&&r.setTarget(Object.assign(Object.assign({},r.getTarget()),{cell:e}))}),this.removeCell(t),this.stopBatch("update",{id:e}),n}removeCells(t,e={}){return t.length?this.batchUpdate("remove",()=>t.map(n=>this.removeCell(n,e))):[]}removeConnectedEdges(t,e={}){const n=this.getConnectedEdges(t);return n.forEach(s=>{s.remove(e)}),n}disconnectConnectedEdges(t,e={}){const n=typeof t=="string"?t:t.id;this.getConnectedEdges(t).forEach(s=>{const r=s.getSourceCellId(),o=s.getTargetCellId();r===n&&s.setSource({x:0,y:0},e),o===n&&s.setTarget({x:0,y:0},e)})}has(t){return this.collection.has(t)}total(){return this.collection.length}indexOf(t){return this.collection.indexOf(t)}getCell(t){return this.collection.get(t)}getCells(){return this.collection.toArray()}getFirstCell(){return this.collection.first()}getLastCell(){return this.collection.last()}getMinZIndex(){const t=this.collection.first();return t&&t.getZIndex()||0}getMaxZIndex(){const t=this.collection.last();return t&&t.getZIndex()||0}getCellsFromCache(t){return t?Object.keys(t).map(e=>this.getCell(e)).filter(e=>e!=null):[]}getNodes(){return this.getCellsFromCache(this.nodes)}getEdges(){return this.getCellsFromCache(this.edges)}getOutgoingEdges(t){const e=typeof t=="string"?t:t.id,n=this.outgoings[e];return n?n.map(s=>this.getCell(s)).filter(s=>s&&s.isEdge()):null}getIncomingEdges(t){const e=typeof t=="string"?t:t.id,n=this.incomings[e];return n?n.map(s=>this.getCell(s)).filter(s=>s&&s.isEdge()):null}getConnectedEdges(t,e={}){const n=[],s=typeof t=="string"?this.getCell(t):t;if(s==null)return n;const r={},o=e.indirect;let l=e.incoming,a=e.outgoing;l==null&&a==null&&(l=a=!0);const c=(h,u)=>{const f=u?this.getOutgoingEdges(h):this.getIncomingEdges(h);if(f!=null&&f.forEach(d=>{r[d.id]||(n.push(d),r[d.id]=!0,o&&(l&&c(d,!1),a&&c(d,!0)))}),o&&h.isEdge()){const d=u?h.getTargetCell():h.getSourceCell();d&&d.isEdge()&&(r[d.id]||(n.push(d),c(d,u)))}};if(a&&c(s,!0),l&&c(s,!1),e.deep){const h=s.getDescendants({deep:!0}),u={};h.forEach(d=>{d.isNode()&&(u[d.id]=!0)});const f=(d,g)=>{const p=g?this.getOutgoingEdges(d.id):this.getIncomingEdges(d.id);p!=null&&p.forEach(m=>{if(!r[m.id]){const b=m.getSourceCell(),x=m.getTargetCell();if(!e.enclosed&&b&&u[b.id]&&x&&u[x.id])return;n.push(m),r[m.id]=!0}})};h.forEach(d=>{d.isEdge()||(a&&f(d,!0),l&&f(d,!1))})}return n}isBoundary(t,e){const n=typeof t=="string"?this.getCell(t):t,s=e?this.getIncomingEdges(n):this.getOutgoingEdges(n);return s==null||s.length===0}getBoundaryNodes(t){const e=[];return Object.keys(this.nodes).forEach(n=>{if(this.isBoundary(n,t)){const s=this.getCell(n);s&&e.push(s)}}),e}getRoots(){return this.getBoundaryNodes(!0)}getLeafs(){return this.getBoundaryNodes(!1)}isRoot(t){return this.isBoundary(t,!0)}isLeaf(t){return this.isBoundary(t,!1)}getNeighbors(t,e={}){let n=e.incoming,s=e.outgoing;n==null&&s==null&&(n=s=!0);const o=this.getConnectedEdges(t,e).reduce((l,a)=>{const c=a.hasLoop(e),h=a.getSourceCell(),u=a.getTargetCell();return n&&h&&h.isNode()&&!l[h.id]&&(c||h!==t&&(!e.deep||!h.isDescendantOf(t)))&&(l[h.id]=h),s&&u&&u.isNode()&&!l[u.id]&&(c||u!==t&&(!e.deep||!u.isDescendantOf(t)))&&(l[u.id]=u),l},{});if(t.isEdge()){if(n){const l=t.getSourceCell();l&&l.isNode()&&!o[l.id]&&(o[l.id]=l)}if(s){const l=t.getTargetCell();l&&l.isNode()&&!o[l.id]&&(o[l.id]=l)}}return Object.keys(o).map(l=>o[l])}isNeighbor(t,e,n={}){let s=n.incoming,r=n.outgoing;return s==null&&r==null&&(s=r=!0),this.getConnectedEdges(t,n).some(o=>{const l=o.getSourceCell(),a=o.getTargetCell();return!!(s&&l&&l.id===e.id||r&&a&&a.id===e.id)})}getSuccessors(t,e={}){const n=[];return this.search(t,(s,r)=>{s!==t&&this.matchDistance(r,e.distance)&&n.push(s)},Object.assign(Object.assign({},e),{outgoing:!0})),n}isSuccessor(t,e,n={}){let s=!1;return this.search(t,(r,o)=>{if(r===e&&r!==t&&this.matchDistance(o,n.distance))return s=!0,!1},Object.assign(Object.assign({},n),{outgoing:!0})),s}getPredecessors(t,e={}){const n=[];return this.search(t,(s,r)=>{s!==t&&this.matchDistance(r,e.distance)&&n.push(s)},Object.assign(Object.assign({},e),{incoming:!0})),n}isPredecessor(t,e,n={}){let s=!1;return this.search(t,(r,o)=>{if(r===e&&r!==t&&this.matchDistance(o,n.distance))return s=!0,!1},Object.assign(Object.assign({},n),{incoming:!0})),s}matchDistance(t,e){return e==null?!0:typeof e=="function"?e(t):Array.isArray(e)&&e.includes(t)?!0:t===e}getCommonAncestor(...t){const e=[];return t.forEach(n=>{n&&(Array.isArray(n)?e.push(...n):e.push(n))}),V.getCommonAncestor(...e)}getSubGraph(t,e={}){const n=[],s={},r=[],o=[],l=a=>{s[a.id]||(n.push(a),s[a.id]=a,a.isEdge()&&o.push(a),a.isNode()&&r.push(a))};return t.forEach(a=>{l(a),e.deep&&a.getDescendants({deep:!0}).forEach(h=>l(h))}),o.forEach(a=>{const c=a.getSourceCell(),h=a.getTargetCell();c&&!s[c.id]&&(n.push(c),s[c.id]=c,c.isNode()&&r.push(c)),h&&!s[h.id]&&(n.push(h),s[h.id]=h,h.isNode()&&r.push(h))}),r.forEach(a=>{this.getConnectedEdges(a,e).forEach(h=>{const u=h.getSourceCell(),f=h.getTargetCell();!s[h.id]&&u&&s[u.id]&&f&&s[f.id]&&(n.push(h),s[h.id]=h)})}),n}cloneSubGraph(t,e={}){const n=this.getSubGraph(t,e);return this.cloneCells(n)}cloneCells(t){return V.cloneCells(t)}getNodesFromPoint(t,e){const n=typeof t=="number"?{x:t,y:e||0}:t;return this.getNodes().filter(s=>s.getBBox().containsPoint(n))}getNodesInArea(t,e,n,s,r){const o=typeof t=="number"?new T(t,e,n,s):T.create(t),l=typeof t=="number"?r:e,a=l&&l.strict;return this.getNodes().filter(c=>{const h=c.getBBox();return a?o.containsRect(h):o.isIntersectWithRect(h)})}getEdgesInArea(t,e,n,s,r){const o=typeof t=="number"?new T(t,e,n,s):T.create(t),l=typeof t=="number"?r:e,a=l&&l.strict;return this.getEdges().filter(c=>{const h=c.getBBox();return h.width===0?h.inflate(1,0):h.height===0&&h.inflate(0,1),a?o.containsRect(h):o.isIntersectWithRect(h)})}getNodesUnderNode(t,e={}){const n=t.getBBox();return(e.by==null||e.by==="bbox"?this.getNodesInArea(n):this.getNodesFromPoint(n[e.by])).filter(r=>t.id!==r.id&&!r.isDescendantOf(t))}getAllCellsBBox(){return this.getCellsBBox(this.getCells())}getCellsBBox(t,e={}){return V.getCellsBBox(t,e)}search(t,e,n={}){n.breadthFirst?this.breadthFirstSearch(t,e,n):this.depthFirstSearch(t,e,n)}breadthFirstSearch(t,e,n={}){const s=[],r={},o={};for(s.push(t),o[t.id]=0;s.length>0;){const l=s.shift();if(l==null||r[l.id]||(r[l.id]=!0,R(e,this,l,o[l.id])===!1))continue;this.getNeighbors(l,n).forEach(c=>{o[c.id]=o[l.id]+1,s.push(c)})}}depthFirstSearch(t,e,n={}){const s=[],r={},o={};for(s.push(t),o[t.id]=0;s.length>0;){const l=s.pop();if(l==null||r[l.id]||(r[l.id]=!0,R(e,this,l,o[l.id])===!1))continue;const a=this.getNeighbors(l,n),c=s.length;a.forEach(h=>{o[h.id]=o[l.id]+1,s.splice(c,0,h)})}}getShortestPath(t,e,n={}){const s={};this.getEdges().forEach(c=>{const h=c.getSourceCellId(),u=c.getTargetCellId();h&&u&&(s[h]||(s[h]=[]),s[u]||(s[u]=[]),s[h].push(u),n.directed||s[u].push(h))});const r=typeof t=="string"?t:t.id,o=rs.run(s,r,n.weight),l=[];let a=typeof e=="string"?e:e.id;for(o[a]&&l.push(a);a=o[a];)l.unshift(a);return l}translate(t,e,n){return this.getCells().filter(s=>!s.hasParent()).forEach(s=>s.translate(t,e,n)),this}resize(t,e,n){return this.resizeCells(t,e,this.getCells(),n)}resizeCells(t,e,n,s={}){const r=this.getCellsBBox(n);if(r){const o=Math.max(t/r.width,0),l=Math.max(e/r.height,0),a=r.getOrigin();n.forEach(c=>c.scale(o,l,a,s))}return this}toJSON(t={}){return At.toJSON(this.getCells(),t)}parseJSON(t){return At.fromJSON(t)}fromJSON(t,e={}){const n=this.parseJSON(t);return this.resetCells(n,e),this}startBatch(t,e={}){return this.batches[t]=(this.batches[t]||0)+1,this.notify("batch:start",{name:t,data:e}),this}stopBatch(t,e={}){return this.batches[t]=(this.batches[t]||0)-1,this.notify("batch:stop",{name:t,data:e}),this}batchUpdate(t,e,n={}){this.startBatch(t,n);const s=e();return this.stopBatch(t,n),s}hasActiveBatch(t=Object.keys(this.batches)){return(Array.isArray(t)?t:[t]).some(n=>this.batches[n]>0)}dispose(){this.collection.dispose()}}tf([At.dispose()],At.prototype,"dispose",null);(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag],s=e;return(n==null||n===i.toStringTag)&&typeof s.addNode=="function"&&typeof s.addEdge=="function"&&s.collection!=null}i.isModel=t})(At||(At={}));(function(i){function t(n,s={}){return{cells:n.map(r=>r.toJSON(s))}}i.toJSON=t;function e(n){const s=[];return Array.isArray(n)?s.push(...n):(n.cells&&s.push(...n.cells),n.nodes&&n.nodes.forEach(r=>{r.shape==null&&(r.shape="rect"),s.push(r)}),n.edges&&n.edges.forEach(r=>{r.shape==null&&(r.shape="edge"),s.push(r)})),s.map(r=>{const o=r.shape;if(o){if(lt.registry.exist(o))return lt.create(r);if(Q.registry.exist(o))return Q.create(r)}throw new Error("The `shape` should be specified when creating a node/edge instance")})}i.fromJSON=e})(At||(At={}));var ef=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};let Qt=class extends lt{get label(){return this.getLabel()}set label(t){this.setLabel(t)}getLabel(){return this.getAttrByPath("text/text")}setLabel(t,e){return t==null?this.removeLabel():this.setAttrByPath("text/text",t,e),this}removeLabel(){return this.removeAttrByPath("text/text"),this}};(function(i){i.bodyAttr={fill:"#ffffff",stroke:"#333333",strokeWidth:2},i.labelAttr={fontSize:14,fill:"#000000",refX:.5,refY:.5,textAnchor:"middle",textVerticalAnchor:"middle",fontFamily:"Arial, helvetica, sans-serif"},i.config({attrs:{text:Object.assign({},i.labelAttr)},propHooks(t){const{label:e}=t,n=ef(t,["label"]);return e&&ke(n,"attrs/text/text",e),n},visible:!0})})(Qt||(Qt={}));var nf=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};function sf(i,t="body"){return[{tagName:i,selector:t},{tagName:"text",selector:"label"}]}function rf(i="xlink:href"){return e=>{const{imageUrl:n,imageWidth:s,imageHeight:r}=e,o=nf(e,["imageUrl","imageWidth","imageHeight"]);if(n!=null||s!=null||r!=null){const l=()=>{if(o.attrs){const a=o.attrs.image;n!=null&&(a[i]=n),s!=null&&(a.width=s),r!=null&&(a.height=r),o.attrs.image=a}};o.attrs?(o.attrs.image==null&&(o.attrs.image={}),l()):(o.attrs={image:{}},l())}return o}}function Be(i,t,e={}){const n={constructorName:i,markup:sf(i,e.selector),attrs:{[i]:Object.assign({},Qt.bodyAttr)}};return(e.parent||Qt).define(st(n,t,{shape:i}))}Be("rect",{attrs:{body:{refWidth:"100%",refHeight:"100%"}}});const of=Q.define({shape:"edge",markup:[{tagName:"path",selector:"wrap",groupSelector:"lines",attrs:{fill:"none",cursor:"pointer",stroke:"transparent",strokeLinecap:"round"}},{tagName:"path",selector:"line",groupSelector:"lines",attrs:{fill:"none",pointerEvents:"none"}}],attrs:{lines:{connection:!0,strokeLinejoin:"round"},wrap:{strokeWidth:10},line:{stroke:"#333",strokeWidth:2,targetMarker:"classic"}}});Be("ellipse",{attrs:{body:{refCx:"50%",refCy:"50%",refRx:"50%",refRy:"50%"}}});var lf=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};class Le extends Qt{get points(){return this.getPoints()}set points(t){this.setPoints(t)}getPoints(){return this.getAttrByPath("body/refPoints")}setPoints(t,e){return t==null?this.removePoints():this.setAttrByPath("body/refPoints",Le.pointsToString(t),e),this}removePoints(){return this.removeAttrByPath("body/refPoints"),this}}(function(i){function t(e){return typeof e=="string"?e:e.map(n=>Array.isArray(n)?n.join(","):w.isPointLike(n)?`${n.x}, ${n.y}`:"").join(" ")}i.pointsToString=t,i.config({propHooks(e){const{points:n}=e,s=lf(e,["points"]);if(n){const r=t(n);r&&ke(s,"attrs/body/refPoints",r)}return s}})})(Le||(Le={}));Be("polygon",{},{parent:Le});Be("polyline",{},{parent:Le});var af=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};Qt.define({shape:"path",markup:[{tagName:"rect",selector:"bg"},{tagName:"path",selector:"body"},{tagName:"text",selector:"label"}],attrs:{bg:{refWidth:"100%",refHeight:"100%",fill:"none",stroke:"none",pointerEvents:"all"},body:{fill:"none",stroke:"#000",strokeWidth:2}},propHooks(i){const{path:t}=i,e=af(i,["path"]);return t&&ke(e,"attrs/body/refD",t),e}});var cf=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};Qt.define({shape:"text-block",markup:[{tagName:"rect",selector:"body"},Xt.SUPPORT_FOREIGNOBJECT?{tagName:"foreignObject",selector:"foreignObject",children:[{tagName:"div",ns:at.xhtml,selector:"label",style:{width:"100%",height:"100%",position:"static",backgroundColor:"transparent",textAlign:"center",margin:0,padding:"0px 5px",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center"}}]}:{tagName:"text",selector:"label",attrs:{textAnchor:"middle"}}],attrs:{body:Object.assign(Object.assign({},Qt.bodyAttr),{refWidth:"100%",refHeight:"100%"}),foreignObject:{refWidth:"100%",refHeight:"100%"},label:{style:{fontSize:14}}},propHooks(i){const{text:t}=i,e=cf(i,["text"]);return t&&ke(e,"attrs/label/text",t),e},attrHooks:{text:{set(i,{cell:t,view:e,refBBox:n,elem:s,attrs:r}){if(s instanceof HTMLElement)s.textContent=i;else{const o=r.style||{},l={text:i,width:-5,height:"100%"},a=Object.assign({textVerticalAnchor:"middle"},o),c=Tt.presets.textWrap;return R(c.set,this,l,{cell:t,view:e,elem:s,refBBox:n,attrs:a}),{fill:o.color||null}}},position(i,{refBBox:t,elem:e}){if(e instanceof SVGElement)return t.getCenter()}}}});Be("image",{attrs:{image:{refWidth:"100%",refHeight:"100%"}},propHooks:rf()},{selector:"image"});Be("circle",{attrs:{body:{refCx:"50%",refCy:"50%",refR:"50%"}}});class Mt extends et{constructor(){super(...arguments),this.portsCache={}}get[Symbol.toStringTag](){return Mt.toStringTag}getContainerClassName(){const t=[super.getContainerClassName(),this.prefixClassName("node")];return this.can("nodeMovable")||t.push(this.prefixClassName("node-immovable")),t.join(" ")}updateClassName(t){const e=t.target;if(e.hasAttribute("magnet")){const n=this.prefixClassName("port-unconnectable");this.can("magnetConnectable")?Pt(e,n):F(e,n)}else{const n=this.prefixClassName("node-immovable");this.can("nodeMovable")?this.removeClass(n):this.addClass(n)}}isNodeView(){return!0}confirmUpdate(t,e={}){let n=t;return this.hasAction(n,"ports")&&(this.removePorts(),this.cleanPortsCache()),this.hasAction(n,"render")?(this.render(),n=this.removeAction(n,["render","update","resize","translate","rotate","ports","tools"])):(n=this.handleAction(n,"resize",()=>this.resize(),"update"),n=this.handleAction(n,"update",()=>this.update(),"ports"),n=this.handleAction(n,"translate",()=>this.translate()),n=this.handleAction(n,"rotate",()=>this.rotate()),n=this.handleAction(n,"ports",()=>this.renderPorts()),n=this.handleAction(n,"tools",()=>{this.getFlag("tools")===t?this.renderTools():this.updateTools(e)})),n}update(t){this.cleanCache(),this.removePorts();const e=this.cell,n=e.getSize(),s=e.getAttrs();this.updateAttrs(this.container,s,{attrs:t===s?null:t,rootBBox:new T(0,0,n.width,n.height),selectors:this.selectors}),this.renderPorts()}renderMarkup(){const t=this.cell.markup;if(t){if(typeof t=="string")throw new TypeError("Not support string markup.");return this.renderJSONMarkup(t)}throw new TypeError("Invalid node markup.")}renderJSONMarkup(t){const e=this.parseJSONMarkup(t,this.container);this.selectors=e.selectors,this.container.appendChild(e.fragment)}render(){return this.empty(),this.renderMarkup(),this.resize(),this.updateTransform(),this.renderTools(),this}resize(){this.cell.getAngle()&&this.rotate(),this.update()}translate(){this.updateTransform()}rotate(){this.updateTransform()}getTranslationString(){const t=this.cell.getPosition();return`translate(${t.x},${t.y})`}getRotationString(){const t=this.cell.getAngle();if(t){const e=this.cell.getSize();return`rotate(${t},${e.width/2},${e.height/2})`}}updateTransform(){let t=this.getTranslationString();const e=this.getRotationString();e&&(t+=` ${e}`),this.container.setAttribute("transform",t)}findPortElem(t,e){const n=t?this.portsCache[t]:null;if(!n)return null;const s=n.portContentElement,r=n.portContentSelectors||{};return this.findOne(e,s,r)}cleanPortsCache(){this.portsCache={}}removePorts(){Object.values(this.portsCache).forEach(t=>{ye(t.portElement)})}renderPorts(){const t=this.container,e=[];t.childNodes.forEach(o=>{e.push(o)});const n=this.cell.getParsedPorts(),s=Bs(n,"zIndex"),r="auto";s[r]&&s[r].forEach(o=>{const l=this.getPortElement(o);t.append(l),e.push(l)}),Object.keys(s).forEach(o=>{if(o!==r){const l=parseInt(o,10);this.appendPorts(s[o],l,e)}}),this.updatePorts()}appendPorts(t,e,n){const s=t.map(r=>this.getPortElement(r));n[e]||e<0?Cs(n[Math.max(e,0)],s):sn(this.container,s)}getPortElement(t){const e=this.portsCache[t.id];return e?e.portElement:this.createPortElement(t)}createPortElement(t){let e=W.renderMarkup(this.cell.getPortContainerMarkup());const n=e.elem;if(n==null)throw new Error("Invalid port container markup.");e=W.renderMarkup(this.getPortMarkup(t));const s=e.elem,r=e.selectors;if(s==null)throw new Error("Invalid port markup.");this.setAttrs({port:t.id,"port-group":t.group},s);let o="x6-port";t.group&&(o+=` x6-port-${t.group}`),F(n,o),F(n,"x6-port"),F(s,"x6-port-body"),n.appendChild(s);let l=r,a,c;if(this.existPortLabel(t)){if(e=W.renderMarkup(this.getPortLabelMarkup(t.label)),a=e.elem,c=e.selectors,a==null)throw new Error("Invalid port label markup.");if(r&&c){for(const u in c)if(r[u]&&u!==this.rootSelector)throw new Error("Selectors within port must be unique.");l=Object.assign(Object.assign({},r),c)}F(a,"x6-port-label"),n.appendChild(a)}return this.portsCache[t.id]={portElement:n,portSelectors:l,portLabelElement:a,portLabelSelectors:c,portContentElement:s,portContentSelectors:r},this.graph.options.onPortRendered&&this.graph.options.onPortRendered({port:t,node:this.cell,container:n,selectors:l,labelContainer:a,labelSelectors:c,contentContainer:s,contentSelectors:r}),n}updatePorts(){const t=this.cell.getParsedGroups(),e=Object.keys(t);e.length===0?this.updatePortGroup():e.forEach(n=>this.updatePortGroup(n))}updatePortGroup(t){const e=T.fromSize(this.cell.getSize()),n=this.cell.getPortsLayoutByGroup(t,e);for(let s=0,r=n.length;s<r;s+=1){const o=n[s],l=o.portId,a=this.portsCache[l]||{},c=o.portLayout;if(this.applyPortTransform(a.portElement,c),o.portAttrs!=null){const u={selectors:a.portSelectors||{}};o.portSize&&(u.rootBBox=T.fromSize(o.portSize)),this.updateAttrs(a.portElement,o.portAttrs,u)}const h=o.labelLayout;if(h&&a.portLabelElement&&(this.applyPortTransform(a.portLabelElement,h,-(c.angle||0)),h.attrs)){const u={selectors:a.portLabelSelectors||{}};o.labelSize&&(u.rootBBox=T.fromSize(o.labelSize)),this.updateAttrs(a.portLabelElement,h.attrs,u)}}}applyPortTransform(t,e,n=0){const s=e.angle,r=e.position,o=ht().rotate(n).translate(r.x||0,r.y||0).rotate(s||0);be(t,o,{absolute:!0})}getPortMarkup(t){return t.markup||this.cell.portMarkup}getPortLabelMarkup(t){return t.markup||this.cell.portLabelMarkup}existPortLabel(t){return t.attrs&&t.attrs.text}getEventArgs(t,e,n){const s=this,r=s.cell,o=r;return e==null||n==null?{e:t,view:s,node:r,cell:o}:{e:t,x:e,y:n,view:s,node:r,cell:o}}getPortEventArgs(t,e,n){const s=this,r=s.cell,o=r;return n?{e:t,x:n.x,y:n.y,view:s,node:r,cell:o,port:e}:{e:t,view:s,node:r,cell:o,port:e}}notifyMouseDown(t,e,n){super.onMouseDown(t,e,n),this.notify("node:mousedown",this.getEventArgs(t,e,n))}notifyMouseMove(t,e,n){super.onMouseMove(t,e,n),this.notify("node:mousemove",this.getEventArgs(t,e,n))}notifyMouseUp(t,e,n){super.onMouseUp(t,e,n),this.notify("node:mouseup",this.getEventArgs(t,e,n))}notifyPortEvent(t,e,n){const s=this.findAttr("port",e.target);if(s){const r=e.type;t==="node:port:mouseenter"?e.type="mouseenter":t==="node:port:mouseleave"&&(e.type="mouseleave"),this.notify(t,this.getPortEventArgs(e,s,n)),e.type=r}}onClick(t,e,n){super.onClick(t,e,n),this.notify("node:click",this.getEventArgs(t,e,n)),this.notifyPortEvent("node:port:click",t,{x:e,y:n})}onDblClick(t,e,n){super.onDblClick(t,e,n),this.notify("node:dblclick",this.getEventArgs(t,e,n)),this.notifyPortEvent("node:port:dblclick",t,{x:e,y:n})}onContextMenu(t,e,n){super.onContextMenu(t,e,n),this.notify("node:contextmenu",this.getEventArgs(t,e,n)),this.notifyPortEvent("node:port:contextmenu",t,{x:e,y:n})}onMouseDown(t,e,n){this.isPropagationStopped(t)||(this.notifyMouseDown(t,e,n),this.notifyPortEvent("node:port:mousedown",t,{x:e,y:n}),this.startNodeDragging(t,e,n))}onMouseMove(t,e,n){const s=this.getEventData(t),r=s.action;if(r==="magnet")this.dragMagnet(t,e,n);else{if(r==="move"){const l=s.targetView||this;l.dragNode(t,e,n),l.notify("node:moving",{e:t,x:e,y:n,view:l,cell:l.cell,node:l.cell})}this.notifyMouseMove(t,e,n),this.notifyPortEvent("node:port:mousemove",t,{x:e,y:n})}this.setEventData(t,s)}onMouseUp(t,e,n){const s=this.getEventData(t),r=s.action;r==="magnet"?this.stopMagnetDragging(t,e,n):(this.notifyMouseUp(t,e,n),this.notifyPortEvent("node:port:mouseup",t,{x:e,y:n}),r==="move"&&(s.targetView||this).stopNodeDragging(t,e,n));const o=s.targetMagnet;o&&this.onMagnetClick(t,o,e,n),this.checkMouseleave(t)}onMouseOver(t){super.onMouseOver(t),this.notify("node:mouseover",this.getEventArgs(t)),this.notifyPortEvent("node:port:mouseenter",t),this.notifyPortEvent("node:port:mouseover",t)}onMouseOut(t){super.onMouseOut(t),this.notify("node:mouseout",this.getEventArgs(t)),this.notifyPortEvent("node:port:mouseleave",t),this.notifyPortEvent("node:port:mouseout",t)}onMouseEnter(t){this.updateClassName(t),super.onMouseEnter(t),this.notify("node:mouseenter",this.getEventArgs(t))}onMouseLeave(t){super.onMouseLeave(t),this.notify("node:mouseleave",this.getEventArgs(t))}onMouseWheel(t,e,n,s){super.onMouseWheel(t,e,n,s),this.notify("node:mousewheel",Object.assign({delta:s},this.getEventArgs(t,e,n)))}onMagnetClick(t,e,n,s){const r=this.graph;r.view.getMouseMovedCount(t)>r.options.clickThreshold||this.notify("node:magnet:click",Object.assign({magnet:e},this.getEventArgs(t,n,s)))}onMagnetDblClick(t,e,n,s){this.notify("node:magnet:dblclick",Object.assign({magnet:e},this.getEventArgs(t,n,s)))}onMagnetContextMenu(t,e,n,s){this.notify("node:magnet:contextmenu",Object.assign({magnet:e},this.getEventArgs(t,n,s)))}onMagnetMouseDown(t,e,n,s){this.startMagnetDragging(t,n,s)}onCustomEvent(t,e,n,s){this.notify("node:customevent",Object.assign({name:e},this.getEventArgs(t,n,s))),super.onCustomEvent(t,e,n,s)}prepareEmbedding(t){const e=this.graph,s=this.getEventData(t).cell||this.cell,r=e.findViewByCell(s),o=e.snapToGrid(t.clientX,t.clientY);this.notify("node:embed",{e:t,node:s,view:r,cell:s,x:o.x,y:o.y,currentParent:s.getParent()})}processEmbedding(t,e){const n=e.cell||this.cell,s=e.graph||this.graph,r=s.options.embedding,o=r.findParent;let l=typeof o=="function"?R(o,s,{view:this,node:this.cell}).filter(f=>V.isCell(f)&&this.cell.id!==f.id&&!f.isDescendantOf(this.cell)):s.model.getNodesUnderNode(n,{by:o});if(r.frontOnly&&l.length>0){const f=Bs(l,"zIndex"),d=nl(Object.keys(f).map(g=>parseInt(g,10)));d&&(l=f[d])}l=l.filter(f=>f.visible);let a=null;const c=e.candidateEmbedView,h=r.validate;for(let f=l.length-1;f>=0;f-=1){const d=l[f];if(c&&c.cell.id===d.id){a=c;break}else{const g=d.findView(s);if(h&&R(h,s,{child:this.cell,parent:g.cell,childView:this,parentView:g})){a=g;break}}}this.clearEmbedding(e),a&&a.highlight(null,{type:"embedding"}),e.candidateEmbedView=a;const u=s.snapToGrid(t.clientX,t.clientY);this.notify("node:embedding",{e:t,cell:n,node:n,view:s.findViewByCell(n),x:u.x,y:u.y,currentParent:n.getParent(),candidateParent:a?a.cell:null})}clearEmbedding(t){const e=t.candidateEmbedView;e&&(e.unhighlight(null,{type:"embedding"}),t.candidateEmbedView=null)}finalizeEmbedding(t,e){this.graph.startBatch("embedding");const n=e.cell||this.cell,s=e.graph||this.graph,r=s.findViewByCell(n),o=n.getParent(),l=e.candidateEmbedView;if(l?(l.unhighlight(null,{type:"embedding"}),e.candidateEmbedView=null,(o==null||o.id!==l.cell.id)&&l.cell.insertChild(n,void 0,{ui:!0})):o&&o.unembed(n,{ui:!0}),s.model.getConnectedEdges(n,{deep:!0}).forEach(a=>{a.updateParent({ui:!0})}),r&&l){const a=s.snapToGrid(t.clientX,t.clientY);r.notify("node:embedded",{e:t,cell:n,x:a.x,y:a.y,node:n,view:s.findViewByCell(n),previousParent:o,currentParent:n.getParent()})}this.graph.stopBatch("embedding")}getDelegatedView(){let t=this.cell,e=this;for(;e&&!t.isEdge();){if(!t.hasParent()||e.can("stopDelegateOnDragging"))return e;t=t.getParent(),e=this.graph.findViewByCell(t)}return null}validateMagnet(t,e,n){if(e.getAttribute("magnet")!=="passive"){const s=this.graph.options.connecting.validateMagnet;return s?R(s,this.graph,{e:n,magnet:e,view:t,cell:t.cell}):!0}return!1}startMagnetDragging(t,e,n){if(!this.can("magnetConnectable"))return;t.stopPropagation();const s=t.currentTarget,r=this.graph;this.setEventData(t,{targetMagnet:s}),this.validateMagnet(this,s,t)?(r.options.magnetThreshold<=0&&this.startConnectting(t,s,e,n),this.setEventData(t,{action:"magnet"}),this.stopPropagation(t)):this.onMouseDown(t,e,n),r.view.delegateDragEvents(t,this)}startConnectting(t,e,n,s){this.graph.model.startBatch("add-edge");const r=this.createEdgeFromMagnet(e,n,s);r.setEventData(t,r.prepareArrowheadDragging("target",{x:n,y:s,isNewEdge:!0,fallbackAction:"remove"})),this.setEventData(t,{edgeView:r}),r.notifyMouseDown(t,n,s)}getDefaultEdge(t,e){let n;const s=this.graph.options.connecting.createEdge;return s&&(n=R(s,this.graph,{sourceMagnet:e,sourceView:t,sourceCell:t.cell})),n}createEdgeFromMagnet(t,e,n){const s=this.graph,r=s.model,o=this.getDefaultEdge(this,t);return o.setSource(Object.assign(Object.assign({},o.getSource()),this.getEdgeTerminal(t,e,n,o,"source"))),o.setTarget(Object.assign(Object.assign({},o.getTarget()),{x:e,y:n})),o.addTo(r,{async:!1,ui:!0}),o.findView(s)}dragMagnet(t,e,n){const s=this.getEventData(t),r=s.edgeView;if(r)r.onMouseMove(t,e,n),this.autoScrollGraph(t.clientX,t.clientY);else{const o=this.graph,l=o.options.magnetThreshold,a=this.getEventTarget(t),c=s.targetMagnet;if(l==="onleave"){if(c===a||c.contains(a))return}else if(o.view.getMouseMovedCount(t)<=l)return;this.startConnectting(t,c,e,n)}}stopMagnetDragging(t,e,n){const r=this.eventData(t).edgeView;r&&(r.onMouseUp(t,e,n),this.graph.model.stopBatch("add-edge"))}notifyUnhandledMouseDown(t,e,n){this.notify("node:unhandled:mousedown",{e:t,x:e,y:n,view:this,cell:this.cell,node:this.cell})}notifyNodeMove(t,e,n,s,r){let o=[r];const l=this.graph.getPlugin("selection");if(l&&l.isSelectionMovable()){const a=l.getSelectedCells();a.includes(r)&&(o=a.filter(c=>c.isNode()))}o.forEach(a=>{this.notify(t,{e,x:n,y:s,cell:a,node:a,view:a.findView(this.graph)})})}getRestrictArea(t){const e=this.graph.options.translating.restrict,n=typeof e=="function"?R(e,this.graph,t):e;return typeof n=="number"?this.graph.transform.getGraphArea().inflate(n):n===!0?this.graph.transform.getGraphArea():n||null}startNodeDragging(t,e,n){const s=this.getDelegatedView();if(s==null||!s.can("nodeMovable"))return this.notifyUnhandledMouseDown(t,e,n);this.setEventData(t,{targetView:s,action:"move"});const r=w.create(s.cell.getPosition());s.setEventData(t,{moving:!1,offset:r.diff(e,n),restrict:this.getRestrictArea(s)})}dragNode(t,e,n){const s=this.cell,r=this.graph,o=r.getGridSize(),l=this.getEventData(t),a=l.offset,c=l.restrict;l.moving||(l.moving=!0,this.addClass("node-moving"),this.notifyNodeMove("node:move",t,e,n,this.cell)),this.autoScrollGraph(t.clientX,t.clientY);const h=H.snapToGrid(e+a.x,o),u=H.snapToGrid(n+a.y,o);s.setPosition(h,u,{restrict:c,deep:!0,ui:!0}),r.options.embedding.enabled&&(l.embedding||(this.prepareEmbedding(t),l.embedding=!0),this.processEmbedding(t,l))}stopNodeDragging(t,e,n){const s=this.getEventData(t);s.embedding&&this.finalizeEmbedding(t,s),s.moving&&(this.removeClass("node-moving"),this.notifyNodeMove("node:moved",t,e,n,this.cell)),s.moving=!1,s.embedding=!1}autoScrollGraph(t,e){const n=this.graph.getPlugin("scroller");n&&n.autoScroll(t,e)}}(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag],s=e;return(n==null||n===i.toStringTag)&&typeof s.isNodeView=="function"&&typeof s.isEdgeView=="function"&&typeof s.confirmUpdate=="function"&&typeof s.update=="function"&&typeof s.findPortElem=="function"&&typeof s.resize=="function"&&typeof s.rotate=="function"&&typeof s.translate=="function"}i.isNodeView=t})(Mt||(Mt={}));Mt.config({isSvgElement:!0,priority:0,bootstrap:["render"],actions:{view:["render"],markup:["render"],attrs:["update"],size:["resize","ports","tools"],angle:["rotate","tools"],position:["translate","tools"],ports:["ports"],tools:["tools"]}});Mt.registry.register("node",Mt,!0);class Vt extends et{constructor(){super(...arguments),this.POINT_ROUNDING=2}get[Symbol.toStringTag](){return Vt.toStringTag}getContainerClassName(){return[super.getContainerClassName(),this.prefixClassName("edge")].join(" ")}get sourceBBox(){const t=this.sourceView;if(!t){const n=this.cell.getSource();return new T(n.x,n.y)}const e=this.sourceMagnet;return t.isEdgeElement(e)?new T(this.sourceAnchor.x,this.sourceAnchor.y):t.getBBoxOfElement(e||t.container)}get targetBBox(){const t=this.targetView;if(!t){const n=this.cell.getTarget();return new T(n.x,n.y)}const e=this.targetMagnet;return t.isEdgeElement(e)?new T(this.targetAnchor.x,this.targetAnchor.y):t.getBBoxOfElement(e||t.container)}isEdgeView(){return!0}confirmUpdate(t,e={}){let n=t;if(this.hasAction(n,"source")){if(!this.updateTerminalProperties("source"))return n;n=this.removeAction(n,"source")}if(this.hasAction(n,"target")){if(!this.updateTerminalProperties("target"))return n;n=this.removeAction(n,"target")}return this.hasAction(n,"render")?(this.render(),n=this.removeAction(n,["render","update","labels","tools"]),n):(n=this.handleAction(n,"update",()=>this.update(e)),n=this.handleAction(n,"labels",()=>this.onLabelsChange(e)),n=this.handleAction(n,"tools",()=>this.renderTools()),n)}render(){return this.empty(),this.renderMarkup(),this.labelContainer=null,this.renderLabels(),this.update(),this.renderTools(),this}renderMarkup(){const t=this.cell.markup;if(t){if(typeof t=="string")throw new TypeError("Not support string markup.");return this.renderJSONMarkup(t)}throw new TypeError("Invalid edge markup.")}renderJSONMarkup(t){const e=this.parseJSONMarkup(t,this.container);this.selectors=e.selectors,this.container.append(e.fragment)}customizeLabels(){if(this.labelContainer){const t=this.cell,e=t.labels;for(let n=0,s=e.length;n<s;n+=1){const r=e[n],o=this.labelCache[n],l=this.labelSelectors[n],a=this.graph.options.onEdgeLabelRendered;a&&a({edge:t,label:r,container:o,selectors:l})}}}renderLabels(){const t=this.cell,e=t.getLabels(),n=e.length;let s=this.labelContainer;if(this.labelCache={},this.labelSelectors={},n<=0)return s&&s.parentNode&&s.parentNode.removeChild(s),this;s?this.empty(s):(s=Ft("g"),this.addClass(this.prefixClassName("edge-labels"),s),this.labelContainer=s);for(let r=0,o=e.length;r<o;r+=1){const l=e[r],a=this.normalizeLabelMarkup(this.parseLabelMarkup(l.markup));let c,h;if(a)c=a.node,h=a.selectors;else{const f=t.getDefaultLabel(),d=this.normalizeLabelMarkup(this.parseLabelMarkup(f.markup));c=d.node,h=d.selectors}c.setAttribute("data-index",`${r}`),s.appendChild(c);const u=this.rootSelector;if(h[u])throw new Error("Ambiguous label root selector.");h[u]=c,this.labelCache[r]=c,this.labelSelectors[r]=h}return s.parentNode==null&&this.container.appendChild(s),this.updateLabels(),this.customizeLabels(),this}onLabelsChange(t={}){this.shouldRerenderLabels(t)?this.renderLabels():this.updateLabels(),this.updateLabelPositions()}shouldRerenderLabels(t={}){const e=this.cell.previous("labels");if(e==null)return!0;if("propertyPathArray"in t&&"propertyValue"in t){const n=t.propertyPathArray||[],s=n.length;if(s>1){const r=n[1];if(e[r]){if(s===2)return typeof t.propertyValue=="object"&&hn(t.propertyValue,"markup");if(n[2]!=="markup")return!1}}}return!0}parseLabelMarkup(t){return t?typeof t=="string"?this.parseLabelStringMarkup(t):this.parseJSONMarkup(t):null}parseLabelStringMarkup(t){const e=I.createVectors(t),n=document.createDocumentFragment();for(let s=0,r=e.length;s<r;s+=1){const o=e[s].node;n.appendChild(o)}return{fragment:n,selectors:{}}}normalizeLabelMarkup(t){if(t==null)return;const e=t.fragment;if(!(e instanceof DocumentFragment)||!e.hasChildNodes())throw new Error("Invalid label markup.");let n;const s=e.childNodes;return s.length>1||s[0].nodeName.toUpperCase()!=="G"?n=I.create("g").append(e):n=I.create(s[0]),n.addClass(this.prefixClassName("edge-label")),{node:n.node,selectors:t.selectors}}updateLabels(){if(this.labelContainer){const t=this.cell,e=t.labels,n=this.can("edgeLabelMovable"),s=t.getDefaultLabel();for(let r=0,o=e.length;r<o;r+=1){const l=this.labelCache[r],a=this.labelSelectors[r];l.setAttribute("cursor",n?"move":"default");const c=e[r],h=st({},s.attrs,c.attrs);this.updateAttrs(l,h,{selectors:a,rootBBox:c.size?T.fromSize(c.size):void 0})}}}renderTools(){const t=this.cell.getTools();return this.addTools(t),this}update(t={}){this.cleanCache(),this.updateConnection(t);const e=this.cell.getAttrs();return e!=null&&this.updateAttrs(this.container,e,{selectors:this.selectors}),this.updateLabelPositions(),this.updateTools(t),this}removeRedundantLinearVertices(t={}){const e=this.cell,n=e.getVertices(),s=[this.sourceAnchor,...n,this.targetAnchor],r=s.length,o=new tt(s);o.simplify({threshold:.01});const l=o.points.map(c=>c.toJSON()),a=l.length;return r===a?0:(e.setVertices(l.slice(1,a-1),t),r-a)}getTerminalView(t){switch(t){case"source":return this.sourceView||null;case"target":return this.targetView||null;default:throw new Error(`Unknown terminal type '${t}'`)}}getTerminalAnchor(t){switch(t){case"source":return w.create(this.sourceAnchor);case"target":return w.create(this.targetAnchor);default:throw new Error(`Unknown terminal type '${t}'`)}}getTerminalConnectionPoint(t){switch(t){case"source":return w.create(this.sourcePoint);case"target":return w.create(this.targetPoint);default:throw new Error(`Unknown terminal type '${t}'`)}}getTerminalMagnet(t,e={}){switch(t){case"source":{if(e.raw)return this.sourceMagnet;const n=this.sourceView;return n?this.sourceMagnet||n.container:null}case"target":{if(e.raw)return this.targetMagnet;const n=this.targetView;return n?this.targetMagnet||n.container:null}default:throw new Error(`Unknown terminal type '${t}'`)}}updateConnection(t={}){const e=this.cell;if(t.translateBy&&e.isFragmentDescendantOf(t.translateBy)){const n=t.tx||0,s=t.ty||0;this.routePoints=new tt(this.routePoints).translate(n,s).points,this.translateConnectionPoints(n,s),this.path.translate(n,s)}else{const n=e.getVertices(),s=this.findAnchors(n);this.sourceAnchor=s.source,this.targetAnchor=s.target,this.routePoints=this.findRoutePoints(n);const r=this.findConnectionPoints(this.routePoints,this.sourceAnchor,this.targetAnchor);this.sourcePoint=r.source,this.targetPoint=r.target;const o=this.findMarkerPoints(this.routePoints,this.sourcePoint,this.targetPoint);this.path=this.findPath(this.routePoints,o.source||this.sourcePoint,o.target||this.targetPoint)}this.cleanCache()}findAnchors(t){const e=this.cell,n=e.source,s=e.target,r=t[0],o=t[t.length-1];return s.priority&&!n.priority?this.findAnchorsOrdered("target",o,"source",r):this.findAnchorsOrdered("source",r,"target",o)}findAnchorsOrdered(t,e,n,s){let r,o;const l=this.cell,a=l[t],c=l[n],h=this.getTerminalView(t),u=this.getTerminalView(n),f=this.getTerminalMagnet(t),d=this.getTerminalMagnet(n);if(h){let g;e?g=w.create(e):u?g=d:g=w.create(c),r=this.getAnchor(a.anchor,h,f,g,t)}else r=w.create(a);if(u){const g=w.create(s||r);o=this.getAnchor(c.anchor,u,d,g,n)}else o=w.isPointLike(c)?w.create(c):new w;return{[t]:r,[n]:o}}getAnchor(t,e,n,s,r){const o=e.isEdgeElement(n),l=this.graph.options.connecting;let a=typeof t=="string"?{name:t}:t;if(!a){const u=o?(r==="source"?l.sourceEdgeAnchor:l.targetEdgeAnchor)||l.edgeAnchor:(r==="source"?l.sourceAnchor:l.targetAnchor)||l.anchor;a=typeof u=="string"?{name:u}:u}if(!a)throw new Error("Anchor should be specified.");let c;const h=a.name;if(o){const u=Ee.registry.get(h);if(typeof u!="function")return Ee.registry.onNotFound(h);c=R(u,this,e,n,s,a.args||{},r)}else{const u=Me.registry.get(h);if(typeof u!="function")return Me.registry.onNotFound(h);c=R(u,this,e,n,s,a.args||{},r)}return c?c.round(this.POINT_ROUNDING):new w}findRoutePoints(t=[]){const e=this.graph.options.connecting.router||Wt.presets.normal,n=this.cell.getRouter()||e;let s;if(typeof n=="function")s=R(n,this,t,{},this);else{const r=typeof n=="string"?n:n.name,o=typeof n=="string"?{}:n.args||{},l=r?Wt.registry.get(r):Wt.presets.normal;if(typeof l!="function")return Wt.registry.onNotFound(r);s=R(l,this,t,o,this)}return s==null?t.map(r=>w.create(r)):s.map(r=>w.create(r))}findConnectionPoints(t,e,n){const s=this.cell,r=this.graph.options.connecting,o=s.getSource(),l=s.getTarget(),a=this.sourceView,c=this.targetView,h=t[0],u=t[t.length-1];let f;if(a&&!a.isEdgeElement(this.sourceMagnet)){const g=this.sourceMagnet||a.container,p=h||n,m=new L(p,e),b=o.connectionPoint||r.sourceConnectionPoint||r.connectionPoint;f=this.getConnectionPoint(b,a,g,m,"source")}else f=e;let d;if(c&&!c.isEdgeElement(this.targetMagnet)){const g=this.targetMagnet||c.container,p=l.connectionPoint||r.targetConnectionPoint||r.connectionPoint,m=u||e,b=new L(m,n);d=this.getConnectionPoint(p,c,g,b,"target")}else d=n;return{source:f,target:d}}getConnectionPoint(t,e,n,s,r){const o=s.end;if(t==null)return o;const l=typeof t=="string"?t:t.name,a=typeof t=="string"?{}:t.args,c=Te.registry.get(l);if(typeof c!="function")return Te.registry.onNotFound(l);const h=R(c,this,s,e,n,a||{},r);return h?h.round(this.POINT_ROUNDING):o}findMarkerPoints(t,e,n){const s=u=>{const f=this.cell.getAttrs(),d=Object.keys(f);for(let g=0,p=d.length;g<p;g+=1){const m=f[d[g]];if(m[`${u}Marker`]||m[`${u}-marker`]){const b=m.strokeWidth||m["stroke-width"];if(b)return parseFloat(b);break}}return null},r=t[0],o=t[t.length-1];let l,a;const c=s("source");c&&(l=e.clone().move(r||n,-c));const h=s("target");return h&&(a=n.clone().move(o||e,-h)),this.sourceMarkerPoint=l||e.clone(),this.targetMarkerPoint=a||n.clone(),{source:l,target:a}}findPath(t,e,n){const s=this.cell.getConnector()||this.graph.options.connecting.connector;let r,o,l;if(typeof s=="string"?r=s:(r=s.name,o=s.args),r){const c=ae.registry.get(r);if(typeof c!="function")return ae.registry.onNotFound(r);l=c}else l=ae.presets.normal;const a=R(l,this,e,n,t,Object.assign(Object.assign({},o),{raw:!0}),this);return typeof a=="string"?k.parse(a):a}translateConnectionPoints(t,e){this.sourcePoint.translate(t,e),this.targetPoint.translate(t,e),this.sourceAnchor.translate(t,e),this.targetAnchor.translate(t,e),this.sourceMarkerPoint.translate(t,e),this.targetMarkerPoint.translate(t,e)}updateLabelPositions(){if(this.labelContainer==null)return this;if(!this.path)return this;const e=this.cell,n=e.getLabels();if(n.length===0)return this;const s=e.getDefaultLabel(),r=this.normalizeLabelPosition(s.position);for(let o=0,l=n.length;o<l;o+=1){const a=n[o],c=this.labelCache[o];if(!c)continue;const h=this.normalizeLabelPosition(a.position),u=st({},r,h),f=this.getLabelTransformationMatrix(u);c.setAttribute("transform",Ie(f))}return this}updateTerminalProperties(t){const e=this.cell,n=this.graph,s=e[t],r=s&&s.cell,o=`${t}View`;if(!r)return this[o]=null,this.updateTerminalMagnet(t),!0;const l=n.getCellById(r);if(!l)throw new Error(`Edge's ${t} node with id "${r}" not exists`);const a=l.findView(n);return a?(this[o]=a,this.updateTerminalMagnet(t),!0):!1}updateTerminalMagnet(t){const e=`${t}Magnet`,n=this.getTerminalView(t);if(n){let s=n.getMagnetFromEdgeTerminal(this.cell[t]);s===n.container&&(s=null),this[e]=s}else this[e]=null}getLabelPositionAngle(t){const e=this.cell.getLabelAt(t);return e&&e.position&&typeof e.position=="object"&&e.position.angle||0}getLabelPositionArgs(t){const e=this.cell.getLabelAt(t);if(e&&e.position&&typeof e.position=="object")return e.position.options}getDefaultLabelPositionArgs(){const t=this.cell.getDefaultLabel();if(t&&t.position&&typeof t.position=="object")return t.position.options}mergeLabelPositionArgs(t,e){return t===null?null:t===void 0?e===null?null:e:st({},e,t)}getConnection(){return this.path!=null?this.path.clone():null}getConnectionPathData(){if(this.path==null)return"";const t=this.cache.pathCache;return hn(t,"data")||(t.data=this.path.serialize()),t.data||""}getConnectionSubdivisions(){if(this.path==null)return null;const t=this.cache.pathCache;return hn(t,"segmentSubdivisions")||(t.segmentSubdivisions=this.path.getSegmentSubdivisions()),t.segmentSubdivisions}getConnectionLength(){if(this.path==null)return 0;const t=this.cache.pathCache;return hn(t,"length")||(t.length=this.path.length({segmentSubdivisions:this.getConnectionSubdivisions()})),t.length}getPointAtLength(t){return this.path==null?null:this.path.pointAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()})}getPointAtRatio(t){return this.path==null?null:($t(t)&&(t=parseFloat(t)/100),this.path.pointAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()}))}getTangentAtLength(t){return this.path==null?null:this.path.tangentAtLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()})}getTangentAtRatio(t){return this.path==null?null:this.path.tangentAt(t,{segmentSubdivisions:this.getConnectionSubdivisions()})}getClosestPoint(t){return this.path==null?null:this.path.closestPoint(t,{segmentSubdivisions:this.getConnectionSubdivisions()})}getClosestPointLength(t){return this.path==null?null:this.path.closestPointLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()})}getClosestPointRatio(t){return this.path==null?null:this.path.closestPointNormalizedLength(t,{segmentSubdivisions:this.getConnectionSubdivisions()})}getLabelPosition(t,e,n,s){const r={distance:0};let o=0,l;typeof n=="number"?(o=n,l=s):l=n,l!=null&&(r.options=l);const a=l&&l.absoluteOffset,c=!(l&&l.absoluteDistance),h=l&&l.absoluteDistance&&l.reverseDistance,u=this.path,f={segmentSubdivisions:this.getConnectionSubdivisions()},d=new w(t,e),g=u.closestPointT(d,f),p=this.getConnectionLength()||0;let m=u.lengthAtT(g,f);c&&(m=p>0?m/p:0),h&&(m=-1*(p-m)||1),r.distance=m;let b;a||(b=u.tangentAtT(g));let x;if(b)x=b.pointOffset(d);else{const y=u.pointAtT(g),v=d.diff(y);x={x:v.x,y:v.y}}return r.offset=x,r.angle=o,r}normalizeLabelPosition(t){return typeof t=="number"?{distance:t}:t}getLabelTransformationMatrix(t){const e=this.normalizeLabelPosition(t),n=e.options||{},s=e.angle||0,r=e.distance,o=r>0&&r<=1;let l=0;const a={x:0,y:0},c=e.offset;c&&(typeof c=="number"?l=c:(c.x!=null&&(a.x=c.x),c.y!=null&&(a.y=c.y)));const h=a.x!==0||a.y!==0||l===0,u=n.keepGradient,f=n.ensureLegibility,d=this.path,g={segmentSubdivisions:this.getConnectionSubdivisions()},p=o?r*this.getConnectionLength():r,m=d.tangentAtLength(p,g);let b,x=s;if(m){if(h)b=m.start,b.translate(a);else{const y=m.clone();y.rotate(-90,m.start),y.setLength(l),b=y.end}u&&(x=m.angle()+s,f&&(x=U.normalize((x+90)%180-90)))}else b=d.start,h&&b.translate(a);return ht().translate(b.x,b.y).rotate(x)}getVertexIndex(t,e){const s=this.cell.getVertices(),r=this.getClosestPointLength(new w(t,e));let o=0;if(r!=null)for(const l=s.length;o<l;o+=1){const a=s[o],c=this.getClosestPointLength(a);if(c!=null&&r<c)break}return o}getEventArgs(t,e,n){const s=this,r=s.cell,o=r;return e==null||n==null?{e:t,view:s,edge:r,cell:o}:{e:t,x:e,y:n,view:s,edge:r,cell:o}}notifyUnhandledMouseDown(t,e,n){this.notify("edge:unhandled:mousedown",{e:t,x:e,y:n,view:this,cell:this.cell,edge:this.cell})}notifyMouseDown(t,e,n){super.onMouseDown(t,e,n),this.notify("edge:mousedown",this.getEventArgs(t,e,n))}notifyMouseMove(t,e,n){super.onMouseMove(t,e,n),this.notify("edge:mousemove",this.getEventArgs(t,e,n))}notifyMouseUp(t,e,n){super.onMouseUp(t,e,n),this.notify("edge:mouseup",this.getEventArgs(t,e,n))}onClick(t,e,n){super.onClick(t,e,n),this.notify("edge:click",this.getEventArgs(t,e,n))}onDblClick(t,e,n){super.onDblClick(t,e,n),this.notify("edge:dblclick",this.getEventArgs(t,e,n))}onContextMenu(t,e,n){super.onContextMenu(t,e,n),this.notify("edge:contextmenu",this.getEventArgs(t,e,n))}onMouseDown(t,e,n){this.notifyMouseDown(t,e,n),this.startEdgeDragging(t,e,n)}onMouseMove(t,e,n){const s=this.getEventData(t);switch(s.action){case"drag-label":{this.dragLabel(t,e,n);break}case"drag-arrowhead":{this.dragArrowhead(t,e,n);break}case"drag-edge":{this.dragEdge(t,e,n);break}}return this.notifyMouseMove(t,e,n),s}onMouseUp(t,e,n){const s=this.getEventData(t);switch(s.action){case"drag-label":{this.stopLabelDragging(t,e,n);break}case"drag-arrowhead":{this.stopArrowheadDragging(t,e,n);break}case"drag-edge":{this.stopEdgeDragging(t,e,n);break}}return this.notifyMouseUp(t,e,n),this.checkMouseleave(t),s}onMouseOver(t){super.onMouseOver(t),this.notify("edge:mouseover",this.getEventArgs(t))}onMouseOut(t){super.onMouseOut(t),this.notify("edge:mouseout",this.getEventArgs(t))}onMouseEnter(t){super.onMouseEnter(t),this.notify("edge:mouseenter",this.getEventArgs(t))}onMouseLeave(t){super.onMouseLeave(t),this.notify("edge:mouseleave",this.getEventArgs(t))}onMouseWheel(t,e,n,s){super.onMouseWheel(t,e,n,s),this.notify("edge:mousewheel",Object.assign({delta:s},this.getEventArgs(t,e,n)))}onCustomEvent(t,e,n,s){if(_i(t.target,"edge-tool",this.container)){if(t.stopPropagation(),this.can("useEdgeTools")){if(e==="edge:remove"){this.cell.remove({ui:!0});return}this.notify("edge:customevent",Object.assign({name:e},this.getEventArgs(t,n,s)))}this.notifyMouseDown(t,n,s)}else this.notify("edge:customevent",Object.assign({name:e},this.getEventArgs(t,n,s))),super.onCustomEvent(t,e,n,s)}onLabelMouseDown(t,e,n){this.notifyMouseDown(t,e,n),this.startLabelDragging(t,e,n),this.getEventData(t).stopPropagation&&t.stopPropagation()}startEdgeDragging(t,e,n){if(!this.can("edgeMovable")){this.notifyUnhandledMouseDown(t,e,n);return}this.setEventData(t,{x:e,y:n,moving:!1,action:"drag-edge"})}dragEdge(t,e,n){const s=this.getEventData(t);s.moving||(s.moving=!0,this.addClass("edge-moving"),this.notify("edge:move",{e:t,x:e,y:n,view:this,cell:this.cell,edge:this.cell})),this.cell.translate(e-s.x,n-s.y,{ui:!0}),this.setEventData(t,{x:e,y:n}),this.notify("edge:moving",{e:t,x:e,y:n,view:this,cell:this.cell,edge:this.cell})}stopEdgeDragging(t,e,n){const s=this.getEventData(t);s.moving&&(this.removeClass("edge-moving"),this.notify("edge:moved",{e:t,x:e,y:n,view:this,cell:this.cell,edge:this.cell})),s.moving=!1}prepareArrowheadDragging(t,e){const n=this.getTerminalMagnet(t),s={action:"drag-arrowhead",x:e.x,y:e.y,isNewEdge:e.isNewEdge===!0,terminalType:t,initialMagnet:n,initialTerminal:Qn(this.cell[t]),fallbackAction:e.fallbackAction||"revert",getValidateConnectionArgs:this.createValidateConnectionArgs(t),options:e.options};return this.beforeArrowheadDragging(s),s}createValidateConnectionArgs(t){const e=[];e[4]=t,e[5]=this;let n,s=0,r=0;t==="source"?(s=2,n="target"):(r=2,n="source");const o=this.cell[n],l=o.cell;if(l){let a;const c=e[s]=this.graph.findViewByCell(l);c&&(a=c.getMagnetFromEdgeTerminal(o),a===c.container&&(a=void 0)),e[s+1]=a}return(a,c)=>(e[r]=a,e[r+1]=a.container===c?void 0:c,e)}beforeArrowheadDragging(t){t.zIndex=this.cell.zIndex,this.cell.toFront();const e=this.container.style;t.pointerEvents=e.pointerEvents,e.pointerEvents="none",this.graph.options.connecting.highlight&&this.highlightAvailableMagnets(t)}afterArrowheadDragging(t){t.zIndex!=null&&(this.cell.setZIndex(t.zIndex,{ui:!0}),t.zIndex=null);const e=this.container;e.style.pointerEvents=t.pointerEvents||"",this.graph.options.connecting.highlight&&this.unhighlightAvailableMagnets(t)}validateConnection(t,e,n,s,r,o,l){const a=this.graph.options.connecting,c=a.allowLoop,h=a.allowNode,u=a.allowEdge,f=a.allowPort,d=a.allowMulti,g=a.validateConnection,p=o?o.cell:null,m=r==="target"?n:t,b=r==="target"?s:e;let x=!0;const y=v=>{const P=r==="source"?l?l.port:null:p?p.getSourcePortId():null,C=r==="target"?l?l.port:null:p?p.getTargetPortId():null;return R(v,this.graph,{edge:p,edgeView:o,sourceView:t,targetView:n,sourcePort:P,targetPort:C,sourceMagnet:e,targetMagnet:s,sourceCell:t?t.cell:null,targetCell:n?n.cell:null,type:r})};if(c!=null&&(typeof c=="boolean"?!c&&t===n&&(x=!1):x=y(c)),x&&f!=null&&(typeof f=="boolean"?!f&&b&&(x=!1):x=y(f)),x&&u!=null&&(typeof u=="boolean"?!u&&Vt.isEdgeView(m)&&(x=!1):x=y(u)),x&&h!=null&&b==null&&(typeof h=="boolean"?!h&&Mt.isNodeView(m)&&(x=!1):x=y(h)),x&&d!=null&&o){const v=o.cell,P=r==="source"?l:v.getSource(),C=r==="target"?l:v.getTarget(),O=l?this.graph.getCellById(l.cell):null;if(P&&C&&P.cell&&C.cell&&O)if(typeof d=="function")x=y(d);else{const N=this.graph.model.getConnectedEdges(O,{outgoing:r==="source",incoming:r==="target"});N.length&&(d==="withPort"?N.some(j=>{const E=j.getSource(),D=j.getTarget();return E&&D&&E.cell===P.cell&&D.cell===C.cell&&E.port!=null&&E.port===P.port&&D.port!=null&&D.port===C.port})&&(x=!1):d||N.some(j=>{const E=j.getSource(),D=j.getTarget();return E&&D&&E.cell===P.cell&&D.cell===C.cell})&&(x=!1))}}return x&&g!=null&&(x=y(g)),x}allowConnectToBlank(t){const e=this.graph,s=e.options.connecting.allowBlank;if(typeof s!="function")return!!s;const r=e.findViewByCell(t),o=t.getSourceCell(),l=t.getTargetCell(),a=e.findViewByCell(o),c=e.findViewByCell(l);return R(s,e,{edge:t,edgeView:r,sourceCell:o,targetCell:l,sourceView:a,targetView:c,sourcePort:t.getSourcePortId(),targetPort:t.getTargetPortId(),sourceMagnet:r.sourceMagnet,targetMagnet:r.targetMagnet})}validateEdge(t,e,n){const s=this.graph;if(!this.allowConnectToBlank(t)){const o=t.getSourceCellId(),l=t.getTargetCellId();if(!(o&&l))return!1}const r=s.options.connecting.validateEdge;return r?R(r,s,{edge:t,type:e,previous:n}):!0}arrowheadDragging(t,e,n,s){s.x=e,s.y=n,s.currentTarget!==t&&(s.currentMagnet&&s.currentView&&s.currentView.unhighlight(s.currentMagnet,{type:"magnetAdsorbed"}),s.currentView=this.graph.findViewByElem(t),s.currentView?(s.currentMagnet=s.currentView.findMagnet(t),s.currentMagnet&&this.validateConnection(...s.getValidateConnectionArgs(s.currentView,s.currentMagnet),s.currentView.getEdgeTerminal(s.currentMagnet,e,n,this.cell,s.terminalType))?s.currentView.highlight(s.currentMagnet,{type:"magnetAdsorbed"}):s.currentMagnet=null):s.currentMagnet=null),s.currentTarget=t,this.cell.prop(s.terminalType,{x:e,y:n},Object.assign(Object.assign({},s.options),{ui:!0}))}arrowheadDragged(t,e,n){const s=t.currentView,r=t.currentMagnet;if(!r||!s)return;s.unhighlight(r,{type:"magnetAdsorbed"});const o=t.terminalType,l=s.getEdgeTerminal(r,e,n,this.cell,o);this.cell.setTerminal(o,l,{ui:!0})}snapArrowhead(t,e,n){const s=this.graph,{snap:r,allowEdge:o}=s.options.connecting,l=typeof r=="object"&&r.radius||50,a=s.renderer.findViewsInArea({x:t-l,y:e-l,width:2*l,height:2*l},{nodeOnly:!0});if(o){const y=s.renderer.findEdgeViewsFromPoint({x:t,y:e},l).filter(v=>v!==this);a.push(...y)}const c=n.closestView||null,h=n.closestMagnet||null;n.closestView=null,n.closestMagnet=null;let u,f=Number.MAX_SAFE_INTEGER;const d=new w(t,e);a.forEach(y=>{if(y.container.getAttribute("magnet")!=="false"){if(y.isNodeView())u=y.cell.getBBox().getCenter().distance(d);else if(y.isEdgeView()){const v=y.getClosestPoint(d);v?u=v.distance(d):u=Number.MAX_SAFE_INTEGER}u<l&&u<f&&(h===y.container||this.validateConnection(...n.getValidateConnectionArgs(y,null),y.getEdgeTerminal(y.container,t,e,this.cell,n.terminalType)))&&(f=u,n.closestView=y,n.closestMagnet=y.container)}y.container.querySelectorAll("[magnet]").forEach(v=>{if(v.getAttribute("magnet")!=="false"){const P=y.getBBoxOfElement(v);u=d.distance(P.getCenter()),u<l&&u<f&&(h===v||this.validateConnection(...n.getValidateConnectionArgs(y,v),y.getEdgeTerminal(v,t,e,this.cell,n.terminalType)))&&(f=u,n.closestView=y,n.closestMagnet=v)}})});let g;const p=n.terminalType,m=n.closestView,b=n.closestMagnet,x=h!==b;if(c&&x&&c.unhighlight(h,{type:"magnetAdsorbed"}),m){if(!x)return;m.highlight(b,{type:"magnetAdsorbed"}),g=m.getEdgeTerminal(b,t,e,this.cell,p)}else g={x:t,y:e};this.cell.setTerminal(p,g,{},Object.assign(Object.assign({},n.options),{ui:!0}))}snapArrowheadEnd(t){const e=t.closestView,n=t.closestMagnet;e&&n&&(e.unhighlight(n,{type:"magnetAdsorbed"}),t.currentMagnet=e.findMagnet(n)),t.closestView=null,t.closestMagnet=null}finishEmbedding(t){this.graph.options.embedding.enabled&&this.cell.updateParent()&&(t.zIndex=null)}fallbackConnection(t){switch(t.fallbackAction){case"remove":this.cell.remove({ui:!0});break;case"revert":default:this.cell.prop(t.terminalType,t.initialTerminal,{ui:!0});break}}notifyConnectionEvent(t,e){const n=t.terminalType,s=t.initialTerminal,r=this.cell[n];if(r&&!Q.equalTerminals(s,r)){const l=this.graph,a=s,c=a.cell?l.getCellById(a.cell):null,h=a.port,u=c?l.findViewByCell(c):null,f=c||t.isNewEdge?null:w.create(s).toJSON(),d=r,g=d.cell?l.getCellById(d.cell):null,p=d.port,m=g?l.findViewByCell(g):null,b=g?null:w.create(r).toJSON();this.notify("edge:connected",{e,previousCell:c,previousPort:h,previousView:u,previousPoint:f,currentCell:g,currentView:m,currentPort:p,currentPoint:b,previousMagnet:t.initialMagnet,currentMagnet:t.currentMagnet,edge:this.cell,view:this,type:n,isNew:t.isNewEdge})}}highlightAvailableMagnets(t){const e=this.graph,n=e.model.getCells();t.marked={};for(let s=0,r=n.length;s<r;s+=1){const o=e.findViewByCell(n[s]);if(!o||o.cell.id===this.cell.id)continue;const l=Array.prototype.slice.call(o.container.querySelectorAll("[magnet]"));o.container.getAttribute("magnet")!=="false"&&l.push(o.container);const a=l.filter(c=>this.validateConnection(...t.getValidateConnectionArgs(o,c),o.getEdgeTerminal(c,t.x,t.y,this.cell,t.terminalType)));if(a.length>0){for(let c=0,h=a.length;c<h;c+=1)o.highlight(a[c],{type:"magnetAvailable"});o.highlight(null,{type:"nodeAvailable"}),t.marked[o.cell.id]=a}}}unhighlightAvailableMagnets(t){const e=t.marked||{};Object.keys(e).forEach(n=>{const s=this.graph.findViewByCell(n);s&&(e[n].forEach(o=>{s.unhighlight(o,{type:"magnetAvailable"})}),s.unhighlight(null,{type:"nodeAvailable"}))}),t.marked=null}startArrowheadDragging(t,e,n){if(!this.can("arrowheadMovable")){this.notifyUnhandledMouseDown(t,e,n);return}const r=t.target.getAttribute("data-terminal"),o=this.prepareArrowheadDragging(r,{x:e,y:n});this.setEventData(t,o)}dragArrowhead(t,e,n){const s=this.getEventData(t);this.graph.options.connecting.snap?this.snapArrowhead(e,n,s):this.arrowheadDragging(this.getEventTarget(t),e,n,s)}stopArrowheadDragging(t,e,n){const s=this.graph,r=this.getEventData(t);s.options.connecting.snap?this.snapArrowheadEnd(r):this.arrowheadDragged(r,e,n),this.validateEdge(this.cell,r.terminalType,r.initialTerminal)?(this.finishEmbedding(r),this.notifyConnectionEvent(r,t)):this.fallbackConnection(r),this.afterArrowheadDragging(r)}startLabelDragging(t,e,n){if(this.can("edgeLabelMovable")){const s=t.currentTarget,r=parseInt(s.getAttribute("data-index"),10),o=this.getLabelPositionAngle(r),l=this.getLabelPositionArgs(r),a=this.getDefaultLabelPositionArgs(),c=this.mergeLabelPositionArgs(l,a);this.setEventData(t,{index:r,positionAngle:o,positionArgs:c,stopPropagation:!0,action:"drag-label"})}else this.setEventData(t,{stopPropagation:!0});this.graph.view.delegateDragEvents(t,this)}dragLabel(t,e,n){const s=this.getEventData(t),r=this.cell.getLabelAt(s.index),o=st({},r,{position:this.getLabelPosition(e,n,s.positionAngle,s.positionArgs)});this.cell.setLabelAt(s.index,o)}stopLabelDragging(t,e,n){}}(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag],s=e;return(n==null||n===i.toStringTag)&&typeof s.isNodeView=="function"&&typeof s.isEdgeView=="function"&&typeof s.confirmUpdate=="function"&&typeof s.update=="function"&&typeof s.getConnection=="function"}i.isEdgeView=t})(Vt||(Vt={}));Vt.config({isSvgElement:!0,priority:1,bootstrap:["render","source","target"],actions:{view:["render"],markup:["render"],attrs:["update"],source:["source","update"],target:["target","update"],router:["update"],connector:["update"],labels:["labels"],defaultLabel:["labels"],tools:["tools"],vertices:["vertices","update"]}});Vt.registry.register("edge",Vt,!0);var hf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class Nt extends X{get options(){return this.graph.options}constructor(t){super(),this.graph=t;const{selectors:e,fragment:n}=W.parseJSONMarkup(Nt.markup);this.background=e.background,this.grid=e.grid,this.svg=e.svg,this.defs=e.defs,this.viewport=e.viewport,this.primer=e.primer,this.stage=e.stage,this.decorator=e.decorator,this.overlay=e.overlay,this.container=this.options.container,this.restore=Nt.snapshoot(this.container),F(this.container,this.prefixClassName("graph")),sn(this.container,n),this.delegateEvents()}delegateEvents(){const t=this.constructor;return super.delegateEvents(t.events),this}guard(t,e){return t.type==="mousedown"&&t.button===2||this.options.guard&&this.options.guard(t,e)?!0:t.data&&t.data.guarded!==void 0?t.data.guarded:!(e&&e.cell&&V.isCell(e.cell)||this.svg===t.target||this.container===t.target||this.svg.contains(t.target))}findView(t){return this.graph.findViewByElem(t)}onDblClick(t){this.options.preventDefaultDblClick&&t.preventDefault();const e=this.normalizeEvent(t),n=this.findView(e.target);if(this.guard(e,n))return;const s=this.graph.snapToGrid(e.clientX,e.clientY);n?n.onDblClick(e,s.x,s.y):this.graph.trigger("blank:dblclick",{e,x:s.x,y:s.y})}onClick(t){if(this.getMouseMovedCount(t)<=this.options.clickThreshold){const e=this.normalizeEvent(t),n=this.findView(e.target);if(this.guard(e,n))return;const s=this.graph.snapToGrid(e.clientX,e.clientY);n?n.onClick(e,s.x,s.y):this.graph.trigger("blank:click",{e,x:s.x,y:s.y})}}isPreventDefaultContextMenu(t){let e=this.options.preventDefaultContextMenu;return typeof e=="function"&&(e=R(e,this.graph,{view:t})),e}onContextMenu(t){const e=this.normalizeEvent(t),n=this.findView(e.target);if(this.isPreventDefaultContextMenu(n)&&t.preventDefault(),this.guard(e,n))return;const s=this.graph.snapToGrid(e.clientX,e.clientY);n?n.onContextMenu(e,s.x,s.y):this.graph.trigger("blank:contextmenu",{e,x:s.x,y:s.y})}delegateDragEvents(t,e){t.data==null&&(t.data={}),this.setEventData(t,{currentView:e||null,mouseMovedCount:0,startPosition:{x:t.clientX,y:t.clientY}});const n=this.constructor;this.delegateDocumentEvents(n.documentEvents,t.data),this.undelegateEvents()}getMouseMovedCount(t){return this.getEventData(t).mouseMovedCount||0}onMouseDown(t){const e=this.normalizeEvent(t),n=this.findView(e.target);if(this.guard(e,n))return;this.options.preventDefaultMouseDown&&t.preventDefault();const s=this.graph.snapToGrid(e.clientX,e.clientY);n?n.onMouseDown(e,s.x,s.y):(this.options.preventDefaultBlankAction&&["touchstart"].includes(e.type)&&t.preventDefault(),this.graph.trigger("blank:mousedown",{e,x:s.x,y:s.y})),this.delegateDragEvents(e,n)}onMouseMove(t){const e=this.getEventData(t),n=e.startPosition;if(n&&n.x===t.clientX&&n.y===t.clientY||(e.mouseMovedCount==null&&(e.mouseMovedCount=0),e.mouseMovedCount+=1,e.mouseMovedCount<=this.options.moveThreshold))return;const r=this.normalizeEvent(t),o=this.graph.snapToGrid(r.clientX,r.clientY),l=e.currentView;l?l.onMouseMove(r,o.x,o.y):this.graph.trigger("blank:mousemove",{e:r,x:o.x,y:o.y}),this.setEventData(r,e)}onMouseUp(t){this.undelegateDocumentEvents();const e=this.normalizeEvent(t),n=this.graph.snapToGrid(e.clientX,e.clientY),r=this.getEventData(t).currentView;if(r?r.onMouseUp(e,n.x,n.y):this.graph.trigger("blank:mouseup",{e,x:n.x,y:n.y}),!t.isPropagationStopped()){const o=new Et(t,{type:"click",data:t.data});this.onClick(o)}t.stopImmediatePropagation(),this.delegateEvents()}onMouseOver(t){const e=this.normalizeEvent(t),n=this.findView(e.target);if(!this.guard(e,n))if(n)n.onMouseOver(e);else{if(this.container===e.target)return;this.graph.trigger("blank:mouseover",{e})}}onMouseOut(t){const e=this.normalizeEvent(t),n=this.findView(e.target);if(!this.guard(e,n))if(n)n.onMouseOut(e);else{if(this.container===e.target)return;this.graph.trigger("blank:mouseout",{e})}}onMouseEnter(t){const e=this.normalizeEvent(t),n=this.findView(e.target);if(this.guard(e,n))return;const s=this.graph.findViewByElem(e.relatedTarget);if(n){if(s===n)return;n.onMouseEnter(e)}else{if(s)return;this.graph.trigger("graph:mouseenter",{e})}}onMouseLeave(t){const e=this.normalizeEvent(t),n=this.findView(e.target);if(this.guard(e,n))return;const s=this.graph.findViewByElem(e.relatedTarget);if(n){if(s===n)return;n.onMouseLeave(e)}else{if(s)return;this.graph.trigger("graph:mouseleave",{e})}}onMouseWheel(t){const e=this.normalizeEvent(t),n=this.findView(e.target);if(this.guard(e,n))return;const s=e.originalEvent,r=this.graph.snapToGrid(s.clientX,s.clientY),o=Math.max(-1,Math.min(1,s.wheelDelta||-s.detail));n?n.onMouseWheel(e,r.x,r.y,o):this.graph.trigger("blank:mousewheel",{e,delta:o,x:r.x,y:r.y})}onCustomEvent(t){const e=t.currentTarget,n=e.getAttribute("event")||e.getAttribute("data-event");if(n){const s=this.findView(e);if(s){const r=this.normalizeEvent(t);if(this.guard(r,s))return;const o=this.graph.snapToGrid(r.clientX,r.clientY);s.onCustomEvent(r,n,o.x,o.y)}}}handleMagnetEvent(t,e){const n=t.currentTarget,s=n.getAttribute("magnet");if(s&&s.toLowerCase()!=="false"){const r=this.findView(n);if(r){const o=this.normalizeEvent(t);if(this.guard(o,r))return;const l=this.graph.snapToGrid(o.clientX,o.clientY);R(e,this.graph,r,o,n,l.x,l.y)}}}onMagnetMouseDown(t){this.handleMagnetEvent(t,(e,n,s,r,o)=>{e.onMagnetMouseDown(n,s,r,o)})}onMagnetDblClick(t){this.handleMagnetEvent(t,(e,n,s,r,o)=>{e.onMagnetDblClick(n,s,r,o)})}onMagnetContextMenu(t){const e=this.findView(t.target);this.isPreventDefaultContextMenu(e)&&t.preventDefault(),this.handleMagnetEvent(t,(n,s,r,o,l)=>{n.onMagnetContextMenu(s,r,o,l)})}onLabelMouseDown(t){const e=t.currentTarget,n=this.findView(e);if(n){const s=this.normalizeEvent(t);if(this.guard(s,n))return;const r=this.graph.snapToGrid(s.clientX,s.clientY);n.onLabelMouseDown(s,r.x,r.y)}}onImageDragStart(){return!1}dispose(){this.undelegateEvents(),this.undelegateDocumentEvents(),this.restore(),this.restore=()=>{}}}hf([X.dispose()],Nt.prototype,"dispose",null);(function(i){const t=`${Ot.prefixCls}-graph`;i.markup=[{ns:at.xhtml,tagName:"div",selector:"background",className:`${t}-background`},{ns:at.xhtml,tagName:"div",selector:"grid",className:`${t}-grid`},{ns:at.svg,tagName:"svg",selector:"svg",className:`${t}-svg`,attrs:{width:"100%",height:"100%","xmlns:xlink":at.xlink},children:[{tagName:"defs",selector:"defs"},{tagName:"g",selector:"viewport",className:`${t}-svg-viewport`,children:[{tagName:"g",selector:"primer",className:`${t}-svg-primer`},{tagName:"g",selector:"stage",className:`${t}-svg-stage`},{tagName:"g",selector:"decorator",className:`${t}-svg-decorator`},{tagName:"g",selector:"overlay",className:`${t}-svg-overlay`}]}]}];function e(n){const s=n.cloneNode();return n.childNodes.forEach(r=>s.appendChild(r)),()=>{for(nn(n);n.attributes.length>0;)n.removeAttribute(n.attributes[0].name);for(let r=0,o=s.attributes.length;r<o;r+=1){const l=s.attributes[r];n.setAttribute(l.name,l.value)}s.childNodes.forEach(r=>n.appendChild(r))}}i.snapshoot=e})(Nt||(Nt={}));(function(i){const t=Ot.prefixCls;i.events={dblclick:"onDblClick",contextmenu:"onContextMenu",touchstart:"onMouseDown",mousedown:"onMouseDown",mouseover:"onMouseOver",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mousewheel:"onMouseWheel",DOMMouseScroll:"onMouseWheel",[`mouseenter .${t}-cell`]:"onMouseEnter",[`mouseleave .${t}-cell`]:"onMouseLeave",[`mouseenter .${t}-cell-tools`]:"onMouseEnter",[`mouseleave .${t}-cell-tools`]:"onMouseLeave",[`mousedown .${t}-cell [event]`]:"onCustomEvent",[`touchstart .${t}-cell [event]`]:"onCustomEvent",[`mousedown .${t}-cell [data-event]`]:"onCustomEvent",[`touchstart .${t}-cell [data-event]`]:"onCustomEvent",[`dblclick .${t}-cell [magnet]`]:"onMagnetDblClick",[`contextmenu .${t}-cell [magnet]`]:"onMagnetContextMenu",[`mousedown .${t}-cell [magnet]`]:"onMagnetMouseDown",[`touchstart .${t}-cell [magnet]`]:"onMagnetMouseDown",[`dblclick .${t}-cell [data-magnet]`]:"onMagnetDblClick",[`contextmenu .${t}-cell [data-magnet]`]:"onMagnetContextMenu",[`mousedown .${t}-cell [data-magnet]`]:"onMagnetMouseDown",[`touchstart .${t}-cell [data-magnet]`]:"onMagnetMouseDown",[`dragstart .${t}-cell image`]:"onImageDragStart",[`mousedown .${t}-edge .${t}-edge-label`]:"onLabelMouseDown",[`touchstart .${t}-edge .${t}-edge-label`]:"onLabelMouseDown"},i.documentEvents={mousemove:"onMouseMove",touchmove:"onMouseMove",mouseup:"onMouseUp",touchend:"onMouseUp",touchcancel:"onMouseUp"}})(Nt||(Nt={}));const uf=`.x6-graph {
position: relative;
overflow: hidden;
outline: none;
touch-action: none;
}
.x6-graph-background,
.x6-graph-grid,
.x6-graph-svg {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.x6-graph-background-stage,
.x6-graph-grid-stage,
.x6-graph-svg-stage {
user-select: none;
}
.x6-graph.x6-graph-pannable {
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
}
.x6-graph.x6-graph-panning {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
user-select: none;
}
.x6-node {
cursor: move;
/* stylelint-disable-next-line */
}
.x6-node.x6-node-immovable {
cursor: default;
}
.x6-node * {
-webkit-user-drag: none;
}
.x6-node .scalable * {
vector-effect: non-scaling-stroke;
}
.x6-node [magnet='true'] {
cursor: crosshair;
transition: opacity 0.3s;
}
.x6-node [magnet='true']:hover {
opacity: 0.7;
}
.x6-node foreignObject {
display: block;
overflow: visible;
background-color: transparent;
}
.x6-node foreignObject > body {
position: static;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: visible;
background-color: transparent;
}
.x6-edge .source-marker,
.x6-edge .target-marker {
vector-effect: non-scaling-stroke;
}
.x6-edge .connection {
stroke-linejoin: round;
fill: none;
}
.x6-edge .connection-wrap {
cursor: move;
opacity: 0;
fill: none;
stroke: #000;
stroke-width: 15;
stroke-linecap: round;
stroke-linejoin: round;
}
.x6-edge .connection-wrap:hover {
opacity: 0.4;
stroke-opacity: 0.4;
}
.x6-edge .vertices {
cursor: move;
opacity: 0;
}
.x6-edge .vertices .vertex {
fill: #1abc9c;
}
.x6-edge .vertices .vertex :hover {
fill: #34495e;
stroke: none;
}
.x6-edge .vertices .vertex-remove {
cursor: pointer;
fill: #fff;
}
.x6-edge .vertices .vertex-remove-area {
cursor: pointer;
opacity: 0.1;
}
.x6-edge .vertices .vertex-group:hover .vertex-remove-area {
opacity: 1;
}
.x6-edge .arrowheads {
cursor: move;
opacity: 0;
}
.x6-edge .arrowheads .arrowhead {
fill: #1abc9c;
}
.x6-edge .arrowheads .arrowhead :hover {
fill: #f39c12;
stroke: none;
}
.x6-edge .tools {
cursor: pointer;
opacity: 0;
}
.x6-edge .tools .tool-options {
display: none;
}
.x6-edge .tools .tool-remove circle {
fill: #f00;
}
.x6-edge .tools .tool-remove path {
fill: #fff;
}
.x6-edge:hover .vertices,
.x6-edge:hover .arrowheads,
.x6-edge:hover .tools {
opacity: 1;
}
.x6-highlight-opacity {
opacity: 0.3;
}
.x6-cell-tool-editor {
position: relative;
display: inline-block;
min-height: 1em;
margin: 0;
padding: 0;
line-height: 1;
white-space: normal;
text-align: center;
vertical-align: top;
overflow-wrap: normal;
outline: none;
transform-origin: 0 0;
-webkit-user-drag: none;
}
.x6-edge-tool-editor {
border: 1px solid #275fc5;
border-radius: 2px;
}
`;class ut extends Bt{get options(){return this.graph.options}get model(){return this.graph.model}get view(){return this.graph.view}constructor(t){super(),this.graph=t,this.init()}init(){}}var ff=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class us extends ut{init(){wa("core",uf)}dispose(){va("core")}}ff([us.dispose()],us.prototype,"dispose",null);var df=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e},en;(function(i){function t(e){const{grid:n,panning:s,mousewheel:r,embedding:o}=e,l=df(e,["grid","panning","mousewheel","embedding"]),a=e.container;if(a!=null)l.width==null&&(l.width=a.clientWidth),l.height==null&&(l.height=a.clientHeight);else throw new Error("Ensure the container of the graph is specified and valid");const c=st({},i.defaults,l),h={size:10,visible:!1};return typeof n=="number"?c.grid={size:n,visible:!1}:typeof n=="boolean"?c.grid=Object.assign(Object.assign({},h),{visible:n}):c.grid=Object.assign(Object.assign({},h),n),["panning","mousewheel","embedding"].forEach(f=>{const d=e[f];typeof d=="boolean"?c[f].enabled=d:c[f]=Object.assign(Object.assign({},c[f]),d)}),c}i.get=t})(en||(en={}));(function(i){i.defaults={x:0,y:0,scaling:{min:.01,max:16},grid:{size:10,visible:!1},background:!1,panning:{enabled:!1,eventTypes:["leftMouseDown"]},mousewheel:{enabled:!1,factor:1.2,zoomAtMousePosition:!0},highlighting:{default:{name:"stroke",args:{padding:3}},nodeAvailable:{name:"className",args:{className:Ot.prefix("available-node")}},magnetAvailable:{name:"className",args:{className:Ot.prefix("available-magnet")}}},connecting:{snap:!1,allowLoop:!0,allowNode:!0,allowEdge:!1,allowPort:!0,allowBlank:!0,allowMulti:!0,highlight:!1,anchor:"center",edgeAnchor:"ratio",connectionPoint:"boundary",router:"normal",connector:"normal",validateConnection({type:t,sourceView:e,targetView:n}){return(t==="target"?n:e)!=null},createEdge(){return new of}},translating:{restrict:!1},embedding:{enabled:!1,findParent:"bbox",frontOnly:!0,validate:()=>!0},moveThreshold:0,clickThreshold:0,magnetThreshold:0,preventDefaultDblClick:!0,preventDefaultMouseDown:!1,preventDefaultContextMenu:!0,preventDefaultBlankAction:!0,interacting:{edgeLabelMovable:!1},async:!0,virtual:!1,guard:()=>!1}})(en||(en={}));var gf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r},pf=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};class Ts extends ut{get elem(){return this.view.grid}get grid(){return this.options.grid}init(){this.startListening(),this.draw(this.grid)}startListening(){this.graph.on("scale",this.update,this),this.graph.on("translate",this.update,this)}stopListening(){this.graph.off("scale",this.update,this),this.graph.off("translate",this.update,this)}setVisible(t){this.grid.visible!==t&&(this.grid.visible=t,this.update())}getGridSize(){return this.grid.size}setGridSize(t){this.grid.size=Math.max(t,1),this.update()}show(){this.setVisible(!0),this.update()}hide(){this.setVisible(!1),this.update()}clear(){this.elem.style.backgroundImage=""}draw(t){this.clear(),this.instance=null,Object.assign(this.grid,t),this.patterns=this.resolveGrid(t),this.update()}update(t={}){const e=this.grid.size;if(e<=1||!this.grid.visible)return this.clear();const n=this.graph.matrix(),s=this.getInstance(),r=Array.isArray(t)?t:[t];this.patterns.forEach((a,c)=>{const h=`pattern_${c}`,u=n.a||1,f=n.d||1,{update:d,markup:g}=a,p=pf(a,["update","markup"]),m=Object.assign(Object.assign(Object.assign({},p),r[c]),{sx:u,sy:f,ox:n.e||0,oy:n.f||0,width:e*u,height:e*f});s.has(h)||s.add(h,I.create("pattern",{id:h,patternUnits:"userSpaceOnUse"},I.createVectors(g)).node);const b=s.get(h);typeof d=="function"&&d(b.childNodes[0],m);let x=m.ox%m.width;x<0&&(x+=m.width);let y=m.oy%m.height;y<0&&(y+=m.height),G(b,{x,y,width:m.width,height:m.height})});const o=new XMLSerializer().serializeToString(s.root),l=`url(data:image/svg+xml;base64,${btoa(o)})`;this.elem.style.backgroundImage=l}getInstance(){return this.instance||(this.instance=new Ut),this.instance}resolveGrid(t){if(!t)return[];const e=t.type;if(e==null)return[Object.assign(Object.assign({},Ut.presets.dot),t.args)];const n=Ut.registry.get(e);if(n){let s=t.args||[];return Array.isArray(s)||(s=[s]),Array.isArray(n)?n.map((r,o)=>Object.assign(Object.assign({},r),s[o])):[Object.assign(Object.assign({},n),s[0])]}return Ut.registry.onNotFound(e)}dispose(){this.stopListening(),this.clear()}}gf([ut.dispose()],Ts.prototype,"dispose",null);class no extends ut{get container(){return this.graph.view.container}get viewport(){return this.graph.view.viewport}get stage(){return this.graph.view.stage}init(){this.resize()}getMatrix(){const t=this.viewport.getAttribute("transform");return t!==this.viewportTransformString&&(this.viewportMatrix=this.viewport.getCTM(),this.viewportTransformString=t),ht(this.viewportMatrix)}setMatrix(t){const e=ht(t),n=Ie(e);this.viewport.setAttribute("transform",n),this.viewportMatrix=e,this.viewportTransformString=n}resize(t,e){let n=t===void 0?this.options.width:t,s=e===void 0?this.options.height:e;this.options.width=n,this.options.height=s,typeof n=="number"&&(n=Math.round(n)),typeof s=="number"&&(s=Math.round(s)),this.container.style.width=n==null?"":`${n}px`,this.container.style.height=s==null?"":`${s}px`;const r=this.getComputedSize();return this.graph.trigger("resize",Object.assign({},r)),this}getComputedSize(){let t=this.options.width,e=this.options.height;return Rs(t)||(t=this.container.clientWidth),Rs(e)||(e=this.container.clientHeight),{width:t,height:e}}getScale(){return ua(this.getMatrix())}scale(t,e=t,n=0,s=0){if(t=this.clampScale(t),e=this.clampScale(e),n||s){const o=this.getTranslation(),l=o.tx-n*(t-1),a=o.ty-s*(e-1);(l!==o.tx||a!==o.ty)&&this.translate(l,a)}const r=this.getMatrix();return r.a=t,r.d=e,this.setMatrix(r),this.graph.trigger("scale",{sx:t,sy:e,ox:n,oy:s}),this}clampScale(t){const e=this.graph.options.scaling;return vt(t,e.min||.01,e.max||16)}getZoom(){return this.getScale().sx}zoom(t,e){e=e||{};let n=t,s=t;const r=this.getScale(),o=this.getComputedSize();let l=o.width/2,a=o.height/2;if(e.absolute||(n+=r.sx,s+=r.sy),e.scaleGrid&&(n=Math.round(n/e.scaleGrid)*e.scaleGrid,s=Math.round(s/e.scaleGrid)*e.scaleGrid),e.maxScale&&(n=Math.min(e.maxScale,n),s=Math.min(e.maxScale,s)),e.minScale&&(n=Math.max(e.minScale,n),s=Math.max(e.minScale,s)),e.center&&(l=e.center.x,a=e.center.y),n=this.clampScale(n),s=this.clampScale(s),l||a){const c=this.getTranslation(),h=l-(l-c.tx)*(n/r.sx),u=a-(a-c.ty)*(s/r.sy);(h!==c.tx||u!==c.ty)&&this.translate(h,u)}return this.scale(n,s),this}getRotation(){return fa(this.getMatrix())}rotate(t,e,n){if(e==null||n==null){const r=q.getBBox(this.stage);e=r.width/2,n=r.height/2}const s=this.getMatrix().translate(e,n).rotate(t).translate(-e,-n);return this.setMatrix(s),this}getTranslation(){return da(this.getMatrix())}translate(t,e){const n=this.getMatrix();n.e=t||0,n.f=e||0,this.setMatrix(n);const s=this.getTranslation();return this.options.x=s.tx,this.options.y=s.ty,this.graph.trigger("translate",Object.assign({},s)),this}setOrigin(t,e){return this.translate(t||0,e||0)}fitToContent(t,e,n,s){if(typeof t=="object"){const y=t;t=y.gridWidth||1,e=y.gridHeight||1,n=y.padding||0,s=y}else t=t||1,e=e||1,n=n||0,s==null&&(s={});const r=ce(n),o=s.border||0,l=s.contentArea?T.create(s.contentArea):this.getContentArea(s);o>0&&l.inflate(o);const a=this.getScale(),c=this.getTranslation(),h=a.sx,u=a.sy;l.x*=h,l.y*=u,l.width*=h,l.height*=u;let f=Math.max(Math.ceil((l.width+l.x)/t),1)*t,d=Math.max(Math.ceil((l.height+l.y)/e),1)*e,g=0,p=0;(s.allowNewOrigin==="negative"&&l.x<0||s.allowNewOrigin==="positive"&&l.x>=0||s.allowNewOrigin==="any")&&(g=Math.ceil(-l.x/t)*t,g+=r.left,f+=g),(s.allowNewOrigin==="negative"&&l.y<0||s.allowNewOrigin==="positive"&&l.y>=0||s.allowNewOrigin==="any")&&(p=Math.ceil(-l.y/e)*e,p+=r.top,d+=p),f+=r.right,d+=r.bottom,f=Math.max(f,s.minWidth||0),d=Math.max(d,s.minHeight||0),f=Math.min(f,s.maxWidth||Number.MAX_SAFE_INTEGER),d=Math.min(d,s.maxHeight||Number.MAX_SAFE_INTEGER);const m=this.getComputedSize(),b=f!==m.width||d!==m.height;return(g!==c.tx||p!==c.ty)&&this.translate(g,p),b&&this.resize(f,d),new T(-g/h,-p/u,f/h,d/u)}scaleContentToFit(t={}){this.scaleContentToFitImpl(t)}scaleContentToFitImpl(t={},e=!0){let n,s;if(t.contentArea){const b=t.contentArea;n=this.graph.localToGraph(b),s=w.create(b)}else n=this.getContentBBox(t),s=this.graph.graphToLocal(n);if(!n.width||!n.height)return;const r=ce(t.padding),o=t.minScale||0,l=t.maxScale||Number.MAX_SAFE_INTEGER,a=t.minScaleX||o,c=t.maxScaleX||l,h=t.minScaleY||o,u=t.maxScaleY||l;let f;if(t.viewportArea)f=t.viewportArea;else{const b=this.getComputedSize(),x=this.getTranslation();f={x:x.tx,y:x.ty,width:b.width,height:b.height}}f=T.create(f).moveAndExpand({x:r.left,y:r.top,width:-r.left-r.right,height:-r.top-r.bottom});const d=this.getScale();let g=f.width/n.width*d.sx,p=f.height/n.height*d.sy;t.preserveAspectRatio!==!1&&(g=p=Math.min(g,p));const m=t.scaleGrid;if(m&&(g=m*Math.floor(g/m),p=m*Math.floor(p/m)),g=vt(g,a,c),p=vt(p,h,u),this.scale(g,p),e){const b=this.options,x=f.x-s.x*g-b.x,y=f.y-s.y*p-b.y;this.translate(x,y)}}getContentArea(t={}){return t.useCellGeometry!==!1?this.model.getAllCellsBBox()||new T:q.getBBox(this.stage)}getContentBBox(t={}){return this.graph.localToGraph(this.getContentArea(t))}getGraphArea(){const t=T.fromSize(this.getComputedSize());return this.graph.graphToLocal(t)}zoomToRect(t,e={}){const n=T.create(t),s=this.graph;e.contentArea=n,e.viewportArea==null&&(e.viewportArea={x:s.options.x,y:s.options.y,width:this.options.width,height:this.options.height}),this.scaleContentToFitImpl(e,!1);const r=n.getCenter();return this.centerPoint(r.x,r.y),this}zoomToFit(t={}){return this.zoomToRect(this.getContentArea(t),t)}centerPoint(t,e){const n=this.getComputedSize(),s=this.getScale(),r=this.getTranslation(),o=n.width/2,l=n.height/2;t=typeof t=="number"?t:o,e=typeof e=="number"?e:l,t=o-t*s.sx,e=l-e*s.sy,(r.tx!==t||r.ty!==e)&&this.translate(t,e)}centerContent(t){const n=this.graph.getContentArea(t).getCenter();this.centerPoint(n.x,n.y)}centerCell(t){return this.positionCell(t,"center")}positionPoint(t,e,n){const s=this.getComputedSize();e=Ct(e,Math.max(0,s.width)),e<0&&(e=s.width+e),n=Ct(n,Math.max(0,s.height)),n<0&&(n=s.height+n);const r=this.getTranslation(),o=this.getScale(),l=e-t.x*o.sx,a=n-t.y*o.sy;(r.tx!==l||r.ty!==a)&&this.translate(l,a)}positionRect(t,e){const n=T.create(t);switch(e){case"center":return this.positionPoint(n.getCenter(),"50%","50%");case"top":return this.positionPoint(n.getTopCenter(),"50%",0);case"top-right":return this.positionPoint(n.getTopRight(),"100%",0);case"right":return this.positionPoint(n.getRightMiddle(),"100%","50%");case"bottom-right":return this.positionPoint(n.getBottomRight(),"100%","100%");case"bottom":return this.positionPoint(n.getBottomCenter(),"50%","100%");case"bottom-left":return this.positionPoint(n.getBottomLeft(),0,"100%");case"left":return this.positionPoint(n.getLeftMiddle(),0,"50%");case"top-left":return this.positionPoint(n.getTopLeft(),0,0);default:return this}}positionCell(t,e){const n=t.getBBox();return this.positionRect(n,e)}positionContent(t,e){const n=this.graph.getContentArea(e);return this.positionRect(n,t)}}var mf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class Ns extends ut{get elem(){return this.view.background}init(){this.startListening(),this.options.background&&this.draw(this.options.background)}startListening(){this.graph.on("scale",this.update,this),this.graph.on("translate",this.update,this)}stopListening(){this.graph.off("scale",this.update,this),this.graph.off("translate",this.update,this)}updateBackgroundImage(t={}){let e=t.size||"auto auto",n=t.position||"center";const s=this.graph.transform.getScale(),r=this.graph.translate();if(typeof n=="object"){const o=r.tx+s.sx*(n.x||0),l=r.ty+s.sy*(n.y||0);n=`${o}px ${l}px`}typeof e=="object"&&(e=T.fromSize(e).scale(s.sx,s.sy),e=`${e.width}px ${e.height}px`),this.elem.style.backgroundSize=e,this.elem.style.backgroundPosition=n}drawBackgroundImage(t,e={}){if(!(t instanceof HTMLImageElement)){this.elem.style.backgroundImage="";return}const n=this.optionsCache;if(n&&n.image!==e.image)return;let s;const r=e.opacity,o=e.size;let l=e.repeat||"no-repeat";const a=Ye.registry.get(l);if(typeof a=="function"){const h=e.quality||1;t.width*=h,t.height*=h;const u=a(t,e);if(!(u instanceof HTMLCanvasElement))throw new Error("Background pattern must return an HTML Canvas instance");s=u.toDataURL("image/png"),e.repeat&&l!==e.repeat?l=e.repeat:l="repeat",typeof o=="object"?(o.width*=u.width/t.width,o.height*=u.height/t.height):o===void 0&&(e.size={width:u.width/h,height:u.height/h})}else s=t.src,o===void 0&&(e.size={width:t.width,height:t.height});n!=null&&typeof e.size=="object"&&e.image===n.image&&e.repeat===n.repeat&&e.quality===n.quality&&(n.size=Qn(e.size));const c=this.elem.style;c.backgroundImage=`url(${s})`,c.backgroundRepeat=l,c.opacity=r==null||r>=1?"":`${r}`,this.updateBackgroundImage(e)}updateBackgroundColor(t){this.elem.style.backgroundColor=t||""}updateBackgroundOptions(t){this.graph.options.background=t}update(){this.optionsCache&&this.updateBackgroundImage(this.optionsCache)}draw(t){const e=t||{};if(this.updateBackgroundOptions(t),this.updateBackgroundColor(e.color),e.image){this.optionsCache=Qn(e);const n=document.createElement("img");n.onload=()=>this.drawBackgroundImage(n,t),n.setAttribute("crossorigin","anonymous"),n.src=e.image}else this.drawBackgroundImage(null),this.optionsCache=null}clear(){this.draw()}dispose(){this.clear(),this.stopListening()}}mf([ut.dispose()],Ns.prototype,"dispose",null);var yf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class Ls extends ut{get widgetOptions(){return this.options.panning}get pannable(){return this.widgetOptions&&this.widgetOptions.enabled===!0}init(){this.onRightMouseDown=this.onRightMouseDown.bind(this),this.startListening(),this.updateClassName()}startListening(){this.graph.on("blank:mousedown",this.onMouseDown,this),this.graph.on("node:unhandled:mousedown",this.onMouseDown,this),this.graph.on("edge:unhandled:mousedown",this.onMouseDown,this),pt.on(this.graph.container,"mousedown",this.onRightMouseDown),this.mousewheelHandle=new or(this.graph.container,this.onMouseWheel.bind(this),this.allowMouseWheel.bind(this)),this.mousewheelHandle.enable()}stopListening(){this.graph.off("blank:mousedown",this.onMouseDown,this),this.graph.off("node:unhandled:mousedown",this.onMouseDown,this),this.graph.off("edge:unhandled:mousedown",this.onMouseDown,this),pt.off(this.graph.container,"mousedown",this.onRightMouseDown),this.mousewheelHandle&&this.mousewheelHandle.disable()}allowPanning(t,e){return this.pannable&&xe.isMatch(t,this.widgetOptions.modifiers,e)}startPanning(t){const e=this.view.normalizeEvent(t);this.clientX=e.clientX,this.clientY=e.clientY,this.panning=!0,this.updateClassName(),pt.on(document.body,{"mousemove.panning touchmove.panning":this.pan.bind(this),"mouseup.panning touchend.panning":this.stopPanning.bind(this),"mouseleave.panning":this.stopPanning.bind(this)}),pt.on(window,"mouseup.panning",this.stopPanning.bind(this))}pan(t){const e=this.view.normalizeEvent(t),n=e.clientX-this.clientX,s=e.clientY-this.clientY;this.clientX=e.clientX,this.clientY=e.clientY,this.graph.translateBy(n,s)}stopPanning(t){this.panning=!1,this.updateClassName(),pt.off(document.body,".panning"),pt.off(window,".panning")}updateClassName(){const t=this.view.container,e=this.view.prefixClassName("graph-panning"),n=this.view.prefixClassName("graph-pannable");this.pannable?this.panning?(F(t,e),Pt(t,n)):(Pt(t,e),F(t,n)):(Pt(t,e),Pt(t,n))}onMouseDown({e:t}){if(!this.allowBlankMouseDown(t))return;const e=this.graph.getPlugin("selection"),n=e&&e.allowRubberband(t,!0);(this.allowPanning(t,!0)||this.allowPanning(t)&&!n)&&this.startPanning(t)}onRightMouseDown(t){const e=this.widgetOptions.eventTypes;e!=null&&e.includes("rightMouseDown")&&t.button===2&&this.allowPanning(t,!0)&&this.startPanning(t)}onMouseWheel(t,e,n){const s=this.widgetOptions.eventTypes;s!=null&&s.includes("mouseWheel")&&(t.ctrlKey||this.graph.translateBy(-e,-n))}allowBlankMouseDown(t){const e=this.widgetOptions.eventTypes;return(e==null?void 0:e.includes("leftMouseDown"))&&t.button===0||(e==null?void 0:e.includes("mouseWheelDown"))&&t.button===1}allowMouseWheel(t){return this.pannable&&!t.ctrlKey}autoPanning(t,e){const s=this.graph.getGraphArea();let r=0,o=0;t<=s.left+10&&(r=-10),e<=s.top+10&&(o=-10),t>=s.right-10&&(r=10),e>=s.bottom-10&&(o=10),(r!==0||o!==0)&&this.graph.translateBy(-r,-o)}enablePanning(){this.pannable||(this.widgetOptions.enabled=!0,this.updateClassName())}disablePanning(){this.pannable&&(this.widgetOptions.enabled=!1,this.updateClassName())}dispose(){this.stopListening()}}yf([ut.dispose()],Ls.prototype,"dispose",null);var bf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class js extends ut{constructor(){super(...arguments),this.cumulatedFactor=1}get widgetOptions(){return this.options.mousewheel}init(){this.container=this.graph.container,this.target=this.widgetOptions.global?document:this.container,this.mousewheelHandle=new or(this.target,this.onMouseWheel.bind(this),this.allowMouseWheel.bind(this)),this.widgetOptions.enabled&&this.enable(!0)}get disabled(){return this.widgetOptions.enabled!==!0}enable(t){(this.disabled||t)&&(this.widgetOptions.enabled=!0,this.mousewheelHandle.enable())}disable(){this.disabled||(this.widgetOptions.enabled=!1,this.mousewheelHandle.disable())}allowMouseWheel(t){const e=this.widgetOptions.guard;return(e==null||e(t))&&xe.isMatch(t,this.widgetOptions.modifiers)}onMouseWheel(t){const e=this.widgetOptions.guard;if((e==null||e(t))&&xe.isMatch(t,this.widgetOptions.modifiers)){const n=this.widgetOptions.factor||1.2;this.currentScale==null&&(this.startPos={x:t.clientX,y:t.clientY},this.currentScale=this.graph.transform.getScale().sx),t.deltaY<0?this.currentScale<.15?this.cumulatedFactor=(this.currentScale+.01)/this.currentScale:(this.cumulatedFactor=Math.round(this.currentScale*n*20)/20/this.currentScale,this.cumulatedFactor===1&&(this.cumulatedFactor=1.05)):this.currentScale<=.15?this.cumulatedFactor=(this.currentScale-.01)/this.currentScale:(this.cumulatedFactor=Math.round(this.currentScale*(1/n)*20)/20/this.currentScale,this.cumulatedFactor===1&&(this.cumulatedFactor=.95)),this.cumulatedFactor=Math.max(.01,Math.min(this.currentScale*this.cumulatedFactor,160)/this.currentScale);const r=this.currentScale;let o=this.graph.transform.clampScale(r*this.cumulatedFactor);const l=this.widgetOptions.minScale||Number.MIN_SAFE_INTEGER,a=this.widgetOptions.maxScale||Number.MAX_SAFE_INTEGER;if(o=vt(o,l,a),o!==r)if(this.widgetOptions.zoomAtMousePosition){const h=!!this.graph.getPlugin("scroller")?this.graph.clientToLocal(this.startPos):this.graph.clientToGraph(this.startPos);this.graph.zoom(o,{absolute:!0,center:h.clone()})}else this.graph.zoom(o,{absolute:!0});this.currentScale=null,this.cumulatedFactor=1}}dispose(){this.disable()}}bf([Bt.dispose()],js.prototype,"dispose",null);var xf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class so extends ut{init(){this.resetRenderArea=Lo(this.resetRenderArea,200,{leading:!0}),this.resetRenderArea(),this.startListening()}startListening(){this.graph.on("translate",this.resetRenderArea,this),this.graph.on("scale",this.resetRenderArea,this),this.graph.on("resize",this.resetRenderArea,this)}stopListening(){this.graph.off("translate",this.resetRenderArea,this),this.graph.off("scale",this.resetRenderArea,this),this.graph.off("resize",this.resetRenderArea,this)}enableVirtualRender(){this.options.virtual=!0,this.resetRenderArea()}disableVirtualRender(){this.options.virtual=!1,this.graph.renderer.setRenderArea(void 0)}resetRenderArea(){if(this.options.virtual){const t=this.graph.getGraphArea();this.graph.renderer.setRenderArea(t)}}dispose(){this.stopListening()}}xf([ut.dispose()],so.prototype,"dispose",null);class wf{constructor(){this.isFlushing=!1,this.isFlushPending=!1,this.scheduleId=0,this.queue=[],this.frameInterval=33,this.initialTime=Date.now()}queueJob(t){if(t.priority&kt.PRIOR)t.cb();else{const e=this.findInsertionIndex(t);e>=0&&this.queue.splice(e,0,t)}}queueFlush(){!this.isFlushing&&!this.isFlushPending&&(this.isFlushPending=!0,this.scheduleJob())}queueFlushSync(){!this.isFlushing&&!this.isFlushPending&&(this.isFlushPending=!0,this.flushJobsSync())}clearJobs(){this.queue.length=0,this.isFlushing=!1,this.isFlushPending=!1,this.cancelScheduleJob()}flushJobs(){this.isFlushPending=!1,this.isFlushing=!0;const t=this.getCurrentTime();let e;for(;(e=this.queue.shift())&&(e.cb(),!(this.getCurrentTime()-t>=this.frameInterval)););this.isFlushing=!1,this.queue.length&&this.queueFlush()}flushJobsSync(){this.isFlushPending=!1,this.isFlushing=!0;let t;for(;t=this.queue.shift();)try{t.cb()}catch(e){}this.isFlushing=!1}findInsertionIndex(t){let e=0,n=this.queue.length,s=n-1;const r=t.priority;for(;e<=s;){const o=(s-e>>1)+e;r<=this.queue[o].priority?e=o+1:(n=o,s=o-1)}return n}scheduleJob(){"requestIdleCallback"in window?(this.scheduleId&&this.cancelScheduleJob(),this.scheduleId=window.requestIdleCallback(this.flushJobs.bind(this),{timeout:100})):(this.scheduleId&&this.cancelScheduleJob(),this.scheduleId=window.setTimeout(this.flushJobs.bind(this)))}cancelScheduleJob(){"cancelIdleCallback"in window?(this.scheduleId&&window.cancelIdleCallback(this.scheduleId),this.scheduleId=0):(this.scheduleId&&clearTimeout(this.scheduleId),this.scheduleId=0)}getCurrentTime(){return typeof performance=="object"&&typeof performance.now=="function"?performance.now():Date.now()-this.initialTime}}var kt;(function(i){i[i.Update=2]="Update",i[i.RenderEdge=4]="RenderEdge",i[i.RenderNode=8]="RenderNode",i[i.PRIOR=1048576]="PRIOR"})(kt||(kt={}));var vf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class ot extends Bt{get model(){return this.graph.model}get container(){return this.graph.view.stage}constructor(t){super(),this.views={},this.willRemoveViews={},this.queue=new wf,this.graph=t,this.init()}init(){this.startListening(),this.renderViews(this.model.getCells())}startListening(){this.model.on("reseted",this.onModelReseted,this),this.model.on("cell:added",this.onCellAdded,this),this.model.on("cell:removed",this.onCellRemoved,this),this.model.on("cell:change:zIndex",this.onCellZIndexChanged,this),this.model.on("cell:change:visible",this.onCellVisibleChanged,this)}stopListening(){this.model.off("reseted",this.onModelReseted,this),this.model.off("cell:added",this.onCellAdded,this),this.model.off("cell:removed",this.onCellRemoved,this),this.model.off("cell:change:zIndex",this.onCellZIndexChanged,this),this.model.off("cell:change:visible",this.onCellVisibleChanged,this)}onModelReseted({options:t}){this.queue.clearJobs(),this.removeZPivots(),this.resetViews();const e=this.model.getCells();this.renderViews(e,Object.assign(Object.assign({},t),{queue:e.map(n=>n.id)}))}onCellAdded({cell:t,options:e}){this.renderViews([t],e)}onCellRemoved({cell:t}){this.removeViews([t])}onCellZIndexChanged({cell:t,options:e}){const n=this.views[t.id];n&&this.requestViewUpdate(n.view,ot.FLAG_INSERT,e,kt.Update,!0)}onCellVisibleChanged({cell:t,current:e}){this.toggleVisible(t,!!e)}requestViewUpdate(t,e,n={},s=kt.Update,r=!0){const o=t.cell.id,l=this.views[o];if(!l)return;l.flag=e,l.options=n,(t.hasAction(e,["translate","resize","rotate"])||n.async===!1)&&(s=kt.PRIOR,r=!1),this.queue.queueJob({id:o,priority:s,cb:()=>{this.renderViewInArea(t,e,n);const h=n.queue;if(h){const u=h.indexOf(t.cell.id);u>=0&&h.splice(u,1),h.length===0&&this.graph.trigger("render:done")}}}),this.getEffectedEdges(t).forEach(h=>{this.requestViewUpdate(h.view,h.flag,n,s,!1)}),r&&this.flush()}setRenderArea(t){this.renderArea=t,this.flushWaitingViews()}isViewMounted(t){if(t==null)return!1;const e=this.views[t.cell.id];return e?e.state===ot.ViewState.MOUNTED:!1}renderViews(t,e={}){t.sort((n,s)=>n.isNode()&&s.isEdge()?-1:0),t.forEach(n=>{const s=n.id,r=this.views;let o=0,l=r[s];if(l)o=ot.FLAG_INSERT;else{const a=this.createCellView(n);a&&(a.graph=this.graph,o=ot.FLAG_INSERT|a.getBootstrapFlag(),l={view:a,flag:o,options:e,state:ot.ViewState.CREATED},this.views[s]=l)}l&&this.requestViewUpdate(l.view,o,e,this.getRenderPriority(l.view),!1)}),this.flush()}renderViewInArea(t,e,n={}){const s=t.cell,r=s.id,o=this.views[r];if(!o)return;let l=0;this.isUpdatable(t)?(l=this.updateView(t,e,n),o.flag=l):o.state===ot.ViewState.MOUNTED?(l=this.updateView(t,e,n),o.flag=l):o.state=ot.ViewState.WAITING,l&&s.isEdge()&&!(l&t.getFlag(["source","target"]))&&this.queue.queueJob({id:r,priority:kt.RenderEdge,cb:()=>{this.updateView(t,e,n)}})}removeViews(t){t.forEach(e=>{const n=e.id,s=this.views[n];s&&(this.willRemoveViews[n]=s,delete this.views[n],this.queue.queueJob({id:n,priority:this.getRenderPriority(s.view),cb:()=>{this.removeView(s.view)}}))}),this.flush()}flush(){this.graph.options.async?this.queue.queueFlush():this.queue.queueFlushSync()}flushWaitingViews(){Object.values(this.views).forEach(t=>{if(t&&t.state===ot.ViewState.WAITING){const{view:e,flag:n,options:s}=t;this.requestViewUpdate(e,n,s,this.getRenderPriority(e),!1)}}),this.flush()}updateView(t,e,n={}){if(t==null)return 0;if(et.isCellView(t)){if(e&ot.FLAG_REMOVE)return this.removeView(t.cell),0;e&ot.FLAG_INSERT&&(this.insertView(t),e^=ot.FLAG_INSERT)}return e?t.confirmUpdate(e,n):0}insertView(t){const e=this.views[t.cell.id];if(e){const n=t.cell.getZIndex(),s=this.addZPivot(n);this.container.insertBefore(t.container,s),t.cell.isVisible()||this.toggleVisible(t.cell,!1),e.state=ot.ViewState.MOUNTED,this.graph.trigger("view:mounted",{view:t})}}resetViews(){this.willRemoveViews=Object.assign(Object.assign({},this.views),this.willRemoveViews),Object.values(this.willRemoveViews).forEach(t=>{t&&this.removeView(t.view)}),this.views={},this.willRemoveViews={}}removeView(t){const e=t.cell,n=this.willRemoveViews[e.id];n&&t&&(n.view.remove(),delete this.willRemoveViews[e.id],this.graph.trigger("view:unmounted",{view:t}))}toggleVisible(t,e){const n=this.model.getConnectedEdges(t);for(let r=0,o=n.length;r<o;r+=1){const l=n[r];if(e){const a=l.getSourceCell(),c=l.getTargetCell();if(a&&!a.isVisible()||c&&!c.isVisible())continue;this.toggleVisible(l,!0)}else this.toggleVisible(l,!1)}const s=this.views[t.id];s&&rn(s.view.container,{display:e?"unset":"none"})}addZPivot(t=0){this.zPivots==null&&(this.zPivots={});const e=this.zPivots;let n=e[t];if(n)return n;n=e[t]=document.createComment(`z-index:${t+1}`);let s=-1/0;for(const o in e){const l=+o;l<t&&l>s&&(s=l,t-1)}const r=this.container;if(s!==-1/0){const o=e[s];r.insertBefore(n,o.nextSibling)}else r.insertBefore(n,r.firstChild);return n}removeZPivots(){this.zPivots&&Object.values(this.zPivots).forEach(t=>{t&&t.parentNode&&t.parentNode.removeChild(t)}),this.zPivots={}}createCellView(t){const e={graph:this.graph},n=this.graph.options.createCellView;if(n){const r=R(n,this.graph,t);if(r)return new r(t,e);if(r===null)return null}const s=t.view;if(s!=null&&typeof s=="string"){const r=et.registry.get(s);return r?new r(t,e):et.registry.onNotFound(s)}return t.isNode()?new Mt(t,e):t.isEdge()?new Vt(t,e):null}getEffectedEdges(t){const e=[],n=t.cell,s=this.model.getConnectedEdges(n);for(let r=0,o=s.length;r<o;r+=1){const l=s[r],a=this.views[l.id];if(!a)continue;const c=a.view;if(!this.isViewMounted(c))continue;const h=["update"];l.getTargetCell()===n&&h.push("target"),l.getSourceCell()===n&&h.push("source"),e.push({id:l.id,view:c,flag:c.getFlag(h)})}return e}isUpdatable(t){if(t.isNodeView())return this.renderArea?this.renderArea.isIntersectWithRect(t.cell.getBBox()):!0;if(t.isEdgeView()){const e=t.cell,n=e.getSourceCell(),s=e.getTargetCell();if(this.renderArea&&n&&s)return this.renderArea.isIntersectWithRect(n.getBBox())||this.renderArea.isIntersectWithRect(s.getBBox())}return!0}getRenderPriority(t){return t.cell.isNode()?kt.RenderNode:kt.RenderEdge}dispose(){this.stopListening(),Object.keys(this.views).forEach(t=>{this.views[t].view.dispose()}),this.views={}}}vf([Bt.dispose()],ot.prototype,"dispose",null);(function(i){i.FLAG_INSERT=1<<30,i.FLAG_REMOVE=1<<29,i.FLAG_RENDER=(1<<26)-1})(ot||(ot={}));(function(i){(function(t){t[t.CREATED=0]="CREATED",t[t.MOUNTED=1]="MOUNTED",t[t.WAITING=2]="WAITING"})(i.ViewState||(i.ViewState={}))})(ot||(ot={}));var Pf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class ks extends ut{constructor(){super(...arguments),this.schedule=new ot(this.graph)}requestViewUpdate(t,e,n={}){this.schedule.requestViewUpdate(t,e,n)}isViewMounted(t){return this.schedule.isViewMounted(t)}setRenderArea(t){this.schedule.setRenderArea(t)}findViewByElem(t){if(t==null)return null;const e=this.options.container,n=typeof t=="string"?e.querySelector(t):t instanceof Element?t:t[0];if(n){const s=this.graph.view.findAttr("data-cell-id",n);if(s){const r=this.schedule.views;if(r[s])return r[s].view}}return null}findViewByCell(t){if(t==null)return null;const e=V.isCell(t)?t.id:t,n=this.schedule.views;return n[e]?n[e].view:null}findViewsFromPoint(t){const e={x:t.x,y:t.y};return this.model.getCells().map(n=>this.findViewByCell(n)).filter(n=>n!=null?q.getBBox(n.container,{target:this.view.stage}).containsPoint(e):!1)}findEdgeViewsFromPoint(t,e=5){return this.model.getEdges().map(n=>this.findViewByCell(n)).filter(n=>{if(n!=null){const s=n.getClosestPoint(t);if(s)return s.distance(t)<=e}return!1})}findViewsInArea(t,e={}){const n=T.create(t);return this.model.getCells().map(s=>this.findViewByCell(s)).filter(s=>{if(s){if(e.nodeOnly&&!s.isNodeView())return!1;const r=q.getBBox(s.container,{target:this.view.stage});return r.width===0?r.inflate(1,0):r.height===0&&r.inflate(0,1),e.strict?n.containsRect(r):n.isIntersectWithRect(r)}return!1})}dispose(){this.schedule.dispose()}}Pf([ut.dispose()],ks.prototype,"dispose",null);var gi=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};class io extends ut{get cid(){return this.graph.view.cid}get svg(){return this.view.svg}get defs(){return this.view.defs}isDefined(t){return this.svg.getElementById(t)!=null}filter(t){let e=t.id;const n=t.name;if(e||(e=`filter-${n}-${this.cid}-${Un(JSON.stringify(t))}`),!this.isDefined(e)){const s=Pe.registry.get(n);if(s==null)return Pe.registry.onNotFound(n);const r=s(t.args||{}),o=Object.assign(Object.assign({x:-1,y:-1,width:3,height:3,filterUnits:"objectBoundingBox"},t.attrs),{id:e});I.create(W.sanitize(r),o).appendTo(this.defs)}return e}gradient(t){let e=t.id;const n=t.type;if(e||(e=`gradient-${n}-${this.cid}-${Un(JSON.stringify(t))}`),!this.isDefined(e)){const r=t.stops.map(a=>{const c=a.opacity!=null&&Number.isFinite(a.opacity)?a.opacity:1;return`<stop offset="${a.offset}" stop-color="${a.color}" stop-opacity="${c}"/>`}),o=`<${n}>${r.join("")}</${n}>`,l=Object.assign({id:e},t.attrs);I.create(o,l).appendTo(this.defs)}return e}marker(t){const{id:e,refX:n,refY:s,markerUnits:r,markerOrient:o,tagName:l,children:a}=t,c=gi(t,["id","refX","refY","markerUnits","markerOrient","tagName","children"]);let h=e;if(h||(h=`marker-${this.cid}-${Un(JSON.stringify(t))}`),!this.isDefined(h)){l!=="path"&&delete c.d;const u=I.create("marker",{refX:n,refY:s,id:h,overflow:"visible",orient:o!=null?o:"auto",markerUnits:r||"userSpaceOnUse"},a?a.map(f=>{var{tagName:d}=f,g=gi(f,["tagName"]);return I.create(`${d}`||"path",Ue(Object.assign(Object.assign({},c),g)))}):[I.create(l||"path",Ue(c))]);this.defs.appendChild(u.node)}return h}remove(t){const e=this.svg.getElementById(t);e&&e.parentNode&&e.parentNode.removeChild(e)}}class ro extends ut{getClientMatrix(){return ht(this.view.stage.getScreenCTM())}getClientOffset(){const t=this.view.svg.getBoundingClientRect();return new w(t.left,t.top)}getPageOffset(){return this.getClientOffset().translate(window.scrollX,window.scrollY)}snapToGrid(t,e){return(typeof t=="number"?this.clientToLocalPoint(t,e):this.clientToLocalPoint(t.x,t.y)).snapToGrid(this.graph.getGridSize())}localToGraphPoint(t,e){const n=w.create(t,e);return q.transformPoint(n,this.graph.matrix())}localToClientPoint(t,e){const n=w.create(t,e);return q.transformPoint(n,this.getClientMatrix())}localToPagePoint(t,e){return(typeof t=="number"?this.localToGraphPoint(t,e):this.localToGraphPoint(t)).translate(this.getPageOffset())}localToGraphRect(t,e,n,s){const r=T.create(t,e,n,s);return q.transformRectangle(r,this.graph.matrix())}localToClientRect(t,e,n,s){const r=T.create(t,e,n,s);return q.transformRectangle(r,this.getClientMatrix())}localToPageRect(t,e,n,s){return(typeof t=="number"?this.localToGraphRect(t,e,n,s):this.localToGraphRect(t)).translate(this.getPageOffset())}graphToLocalPoint(t,e){const n=w.create(t,e);return q.transformPoint(n,this.graph.matrix().inverse())}clientToLocalPoint(t,e){const n=w.create(t,e);return q.transformPoint(n,this.getClientMatrix().inverse())}clientToGraphPoint(t,e){const n=w.create(t,e);return q.transformPoint(n,this.graph.matrix().multiply(this.getClientMatrix().inverse()))}pageToLocalPoint(t,e){const s=w.create(t,e).diff(this.getPageOffset());return this.graphToLocalPoint(s)}graphToLocalRect(t,e,n,s){const r=T.create(t,e,n,s);return q.transformRectangle(r,this.graph.matrix().inverse())}clientToLocalRect(t,e,n,s){const r=T.create(t,e,n,s);return q.transformRectangle(r,this.getClientMatrix().inverse())}clientToGraphRect(t,e,n,s){const r=T.create(t,e,n,s);return q.transformRectangle(r,this.graph.matrix().multiply(this.getClientMatrix().inverse()))}pageToLocalRect(t,e,n,s){const r=T.create(t,e,n,s),o=this.getPageOffset();return r.x-=o.x,r.y-=o.y,this.graphToLocalRect(r)}}var Cf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class jn extends ut{constructor(){super(...arguments),this.highlights={}}init(){this.startListening()}startListening(){this.graph.on("cell:highlight",this.onCellHighlight,this),this.graph.on("cell:unhighlight",this.onCellUnhighlight,this)}stopListening(){this.graph.off("cell:highlight",this.onCellHighlight,this),this.graph.off("cell:unhighlight",this.onCellUnhighlight,this)}onCellHighlight({view:t,magnet:e,options:n={}}){const s=this.resolveHighlighter(n);if(!s)return;const r=this.getHighlighterId(e,s);if(!this.highlights[r]){const o=s.highlighter;o.highlight(t,e,Object.assign({},s.args)),this.highlights[r]={cellView:t,magnet:e,highlighter:o,args:s.args}}}onCellUnhighlight({magnet:t,options:e={}}){const n=this.resolveHighlighter(e);if(!n)return;const s=this.getHighlighterId(t,n);this.unhighlight(s)}resolveHighlighter(t){const e=this.options;let n=t.highlighter;if(n==null){const l=t.type;n=l&&e.highlighting[l]||e.highlighting.default}if(n==null)return null;const s=typeof n=="string"?{name:n}:n,r=s.name,o=Rt.registry.get(r);return o==null?Rt.registry.onNotFound(r):(Rt.check(r,o),{name:r,highlighter:o,args:s.args||{}})}getHighlighterId(t,e){return ws(t),e.name+t.id+JSON.stringify(e.args)}unhighlight(t){const e=this.highlights[t];e&&(e.highlighter.unhighlight(e.cellView,e.magnet,e.args),delete this.highlights[t])}dispose(){Object.keys(this.highlights).forEach(t=>this.unhighlight(t)),this.stopListening()}}Cf([jn.dispose()],jn.prototype,"dispose",null);var Af=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class oo extends ut{getScroller(){const t=this.graph.getPlugin("scroller");return t&&t.options.enabled?t:null}getContainer(){const t=this.getScroller();return t?t.container.parentElement:this.graph.container.parentElement}getSensorTarget(){const t=this.options.autoResize;if(t)return typeof t=="boolean"?this.getContainer():t}init(){if(this.options.autoResize){const e=this.getSensorTarget();e&&An.bind(e,()=>{const n=e.offsetWidth,s=e.offsetHeight;this.resize(n,s)})}}resize(t,e){const n=this.getScroller();n?n.resize(t,e):this.graph.transform.resize(t,e)}dispose(){An.clear(this.graph.container)}}Af([ut.dispose()],oo.prototype,"dispose",null);var Sf=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r};class mt extends yt{get container(){return this.options.container}get[Symbol.toStringTag](){return mt.toStringTag}constructor(t){super(),this.installedPlugins=new Set,this.options=en.get(t),this.css=new us(this),this.view=new Nt(this),this.defs=new io(this),this.coord=new ro(this),this.transform=new no(this),this.highlight=new jn(this),this.grid=new Ts(this),this.background=new Ns(this),this.options.model?this.model=this.options.model:(this.model=new At,this.model.graph=this),this.renderer=new ks(this),this.panning=new Ls(this),this.mousewheel=new js(this),this.virtualRender=new so(this),this.size=new oo(this)}isNode(t){return t.isNode()}isEdge(t){return t.isEdge()}resetCells(t,e={}){return this.model.resetCells(t,e),this}clearCells(t={}){return this.model.clear(t),this}toJSON(t={}){return this.model.toJSON(t)}parseJSON(t){return this.model.parseJSON(t)}fromJSON(t,e={}){return this.model.fromJSON(t,e),this}getCellById(t){return this.model.getCell(t)}addNode(t,e={}){return this.model.addNode(t,e)}addNodes(t,e={}){return this.addCell(t.map(n=>lt.isNode(n)?n:this.createNode(n)),e)}createNode(t){return this.model.createNode(t)}removeNode(t,e={}){return this.model.removeCell(t,e)}addEdge(t,e={}){return this.model.addEdge(t,e)}addEdges(t,e={}){return this.addCell(t.map(n=>Q.isEdge(n)?n:this.createEdge(n)),e)}removeEdge(t,e={}){return this.model.removeCell(t,e)}createEdge(t){return this.model.createEdge(t)}addCell(t,e={}){return this.model.addCell(t,e),this}removeCell(t,e={}){return this.model.removeCell(t,e)}removeCells(t,e={}){return this.model.removeCells(t,e)}removeConnectedEdges(t,e={}){return this.model.removeConnectedEdges(t,e)}disconnectConnectedEdges(t,e={}){return this.model.disconnectConnectedEdges(t,e),this}hasCell(t){return this.model.has(t)}getCells(){return this.model.getCells()}getCellCount(){return this.model.total()}getNodes(){return this.model.getNodes()}getEdges(){return this.model.getEdges()}getOutgoingEdges(t){return this.model.getOutgoingEdges(t)}getIncomingEdges(t){return this.model.getIncomingEdges(t)}getConnectedEdges(t,e={}){return this.model.getConnectedEdges(t,e)}getRootNodes(){return this.model.getRoots()}getLeafNodes(){return this.model.getLeafs()}isRootNode(t){return this.model.isRoot(t)}isLeafNode(t){return this.model.isLeaf(t)}getNeighbors(t,e={}){return this.model.getNeighbors(t,e)}isNeighbor(t,e,n={}){return this.model.isNeighbor(t,e,n)}getSuccessors(t,e={}){return this.model.getSuccessors(t,e)}isSuccessor(t,e,n={}){return this.model.isSuccessor(t,e,n)}getPredecessors(t,e={}){return this.model.getPredecessors(t,e)}isPredecessor(t,e,n={}){return this.model.isPredecessor(t,e,n)}getCommonAncestor(...t){return this.model.getCommonAncestor(...t)}getSubGraph(t,e={}){return this.model.getSubGraph(t,e)}cloneSubGraph(t,e={}){return this.model.cloneSubGraph(t,e)}cloneCells(t){return this.model.cloneCells(t)}getNodesFromPoint(t,e){return this.model.getNodesFromPoint(t,e)}getNodesInArea(t,e,n,s,r){return this.model.getNodesInArea(t,e,n,s,r)}getNodesUnderNode(t,e={}){return this.model.getNodesUnderNode(t,e)}searchCell(t,e,n={}){return this.model.search(t,e,n),this}getShortestPath(t,e,n={}){return this.model.getShortestPath(t,e,n)}getAllCellsBBox(){return this.model.getAllCellsBBox()}getCellsBBox(t,e={}){return this.model.getCellsBBox(t,e)}startBatch(t,e={}){this.model.startBatch(t,e)}stopBatch(t,e={}){this.model.stopBatch(t,e)}batchUpdate(t,e,n){const s=typeof t=="string"?t:"update",r=typeof t=="string"?e:t,o=typeof e=="function"?n:e;this.startBatch(s,o);const l=r();return this.stopBatch(s,o),l}updateCellId(t,e){return this.model.updateCellId(t,e)}findView(t){return V.isCell(t)?this.findViewByCell(t):this.findViewByElem(t)}findViews(t){return T.isRectangleLike(t)?this.findViewsInArea(t):w.isPointLike(t)?this.findViewsFromPoint(t):[]}findViewByCell(t){return this.renderer.findViewByCell(t)}findViewByElem(t){return this.renderer.findViewByElem(t)}findViewsFromPoint(t,e){const n=typeof t=="number"?{x:t,y:e}:t;return this.renderer.findViewsFromPoint(n)}findViewsInArea(t,e,n,s,r){const o=typeof t=="number"?{x:t,y:e,width:n,height:s}:t,l=typeof t=="number"?r:e;return this.renderer.findViewsInArea(o,l)}matrix(t){return typeof t=="undefined"?this.transform.getMatrix():(this.transform.setMatrix(t),this)}resize(t,e){const n=this.getPlugin("scroller");return n?n.resize(t,e):this.transform.resize(t,e),this}scale(t,e=t,n=0,s=0){return typeof t=="undefined"?this.transform.getScale():(this.transform.scale(t,e,n,s),this)}zoom(t,e){const n=this.getPlugin("scroller");if(n){if(typeof t=="undefined")return n.zoom();n.zoom(t,e)}else{if(typeof t=="undefined")return this.transform.getZoom();this.transform.zoom(t,e)}return this}zoomTo(t,e={}){const n=this.getPlugin("scroller");return n?n.zoom(t,Object.assign(Object.assign({},e),{absolute:!0})):this.transform.zoom(t,Object.assign(Object.assign({},e),{absolute:!0})),this}zoomToRect(t,e={}){const n=this.getPlugin("scroller");return n?n.zoomToRect(t,e):this.transform.zoomToRect(t,e),this}zoomToFit(t={}){const e=this.getPlugin("scroller");return e?e.zoomToFit(t):this.transform.zoomToFit(t),this}rotate(t,e,n){return typeof t=="undefined"?this.transform.getRotation():(this.transform.rotate(t,e,n),this)}translate(t,e){return typeof t=="undefined"?this.transform.getTranslation():(this.transform.translate(t,e),this)}translateBy(t,e){const n=this.translate(),s=n.tx+t,r=n.ty+e;return this.translate(s,r)}getGraphArea(){return this.transform.getGraphArea()}getContentArea(t={}){return this.transform.getContentArea(t)}getContentBBox(t={}){return this.transform.getContentBBox(t)}fitToContent(t,e,n,s){return this.transform.fitToContent(t,e,n,s)}scaleContentToFit(t={}){return this.transform.scaleContentToFit(t),this}center(t){return this.centerPoint(t)}centerPoint(t,e,n){const s=this.getPlugin("scroller");return s?s.centerPoint(t,e,n):this.transform.centerPoint(t,e),this}centerContent(t){const e=this.getPlugin("scroller");return e?e.centerContent(t):this.transform.centerContent(t),this}centerCell(t,e){const n=this.getPlugin("scroller");return n?n.centerCell(t,e):this.transform.centerCell(t),this}positionPoint(t,e,n,s={}){const r=this.getPlugin("scroller");return r?r.positionPoint(t,e,n,s):this.transform.positionPoint(t,e,n),this}positionRect(t,e,n){const s=this.getPlugin("scroller");return s?s.positionRect(t,e,n):this.transform.positionRect(t,e),this}positionCell(t,e,n){const s=this.getPlugin("scroller");return s?s.positionCell(t,e,n):this.transform.positionCell(t,e),this}positionContent(t,e){const n=this.getPlugin("scroller");return n?n.positionContent(t,e):this.transform.positionContent(t,e),this}snapToGrid(t,e){return this.coord.snapToGrid(t,e)}pageToLocal(t,e,n,s){return T.isRectangleLike(t)?this.coord.pageToLocalRect(t):typeof t=="number"&&typeof e=="number"&&typeof n=="number"&&typeof s=="number"?this.coord.pageToLocalRect(t,e,n,s):this.coord.pageToLocalPoint(t,e)}localToPage(t,e,n,s){return T.isRectangleLike(t)?this.coord.localToPageRect(t):typeof t=="number"&&typeof e=="number"&&typeof n=="number"&&typeof s=="number"?this.coord.localToPageRect(t,e,n,s):this.coord.localToPagePoint(t,e)}clientToLocal(t,e,n,s){return T.isRectangleLike(t)?this.coord.clientToLocalRect(t):typeof t=="number"&&typeof e=="number"&&typeof n=="number"&&typeof s=="number"?this.coord.clientToLocalRect(t,e,n,s):this.coord.clientToLocalPoint(t,e)}localToClient(t,e,n,s){return T.isRectangleLike(t)?this.coord.localToClientRect(t):typeof t=="number"&&typeof e=="number"&&typeof n=="number"&&typeof s=="number"?this.coord.localToClientRect(t,e,n,s):this.coord.localToClientPoint(t,e)}localToGraph(t,e,n,s){return T.isRectangleLike(t)?this.coord.localToGraphRect(t):typeof t=="number"&&typeof e=="number"&&typeof n=="number"&&typeof s=="number"?this.coord.localToGraphRect(t,e,n,s):this.coord.localToGraphPoint(t,e)}graphToLocal(t,e,n,s){return T.isRectangleLike(t)?this.coord.graphToLocalRect(t):typeof t=="number"&&typeof e=="number"&&typeof n=="number"&&typeof s=="number"?this.coord.graphToLocalRect(t,e,n,s):this.coord.graphToLocalPoint(t,e)}clientToGraph(t,e,n,s){return T.isRectangleLike(t)?this.coord.clientToGraphRect(t):typeof t=="number"&&typeof e=="number"&&typeof n=="number"&&typeof s=="number"?this.coord.clientToGraphRect(t,e,n,s):this.coord.clientToGraphPoint(t,e)}defineFilter(t){return this.defs.filter(t)}defineGradient(t){return this.defs.gradient(t)}defineMarker(t){return this.defs.marker(t)}getGridSize(){return this.grid.getGridSize()}setGridSize(t){return this.grid.setGridSize(t),this}showGrid(){return this.grid.show(),this}hideGrid(){return this.grid.hide(),this}clearGrid(){return this.grid.clear(),this}drawGrid(t){return this.grid.draw(t),this}updateBackground(){return this.background.update(),this}drawBackground(t,e){const n=this.getPlugin("scroller");return n!=null&&(this.options.background==null||!e)?n.drawBackground(t,e):this.background.draw(t),this}clearBackground(t){const e=this.getPlugin("scroller");return e!=null&&(this.options.background==null||!t)?e.clearBackground(t):this.background.clear(),this}enableVirtualRender(){return this.virtualRender.enableVirtualRender(),this}disableVirtualRender(){return this.virtualRender.disableVirtualRender(),this}isMouseWheelEnabled(){return!this.mousewheel.disabled}enableMouseWheel(){return this.mousewheel.enable(),this}disableMouseWheel(){return this.mousewheel.disable(),this}toggleMouseWheel(t){return t==null?this.isMouseWheelEnabled()?this.disableMouseWheel():this.enableMouseWheel():t?this.enableMouseWheel():this.disableMouseWheel(),this}isPannable(){const t=this.getPlugin("scroller");return t?t.isPannable():this.panning.pannable}enablePanning(){const t=this.getPlugin("scroller");return t?t.enablePanning():this.panning.enablePanning(),this}disablePanning(){const t=this.getPlugin("scroller");return t?t.disablePanning():this.panning.disablePanning(),this}togglePanning(t){return t==null?this.isPannable()?this.disablePanning():this.enablePanning():t!==this.isPannable()&&(t?this.enablePanning():this.disablePanning()),this}use(t,...e){return this.installedPlugins.has(t)||(this.installedPlugins.add(t),t.init(this,...e)),this}getPlugin(t){return Array.from(this.installedPlugins).find(e=>e.name===t)}getPlugins(t){return Array.from(this.installedPlugins).filter(e=>t.includes(e.name))}enablePlugins(t){let e=t;Array.isArray(e)||(e=[e]);const n=this.getPlugins(e);return n==null||n.forEach(s=>{var r;(r=s==null?void 0:s.enable)===null||r===void 0||r.call(s)}),this}disablePlugins(t){let e=t;Array.isArray(e)||(e=[e]);const n=this.getPlugins(e);return n==null||n.forEach(s=>{var r;(r=s==null?void 0:s.disable)===null||r===void 0||r.call(s)}),this}isPluginEnabled(t){var e;const n=this.getPlugin(t);return(e=n==null?void 0:n.isEnabled)===null||e===void 0?void 0:e.call(n)}disposePlugins(t){let e=t;Array.isArray(e)||(e=[e]);const n=this.getPlugins(e);return n==null||n.forEach(s=>{s.dispose(),this.installedPlugins.delete(s)}),this}dispose(t=!0){t&&this.model.dispose(),this.css.dispose(),this.defs.dispose(),this.grid.dispose(),this.coord.dispose(),this.transform.dispose(),this.highlight.dispose(),this.background.dispose(),this.mousewheel.dispose(),this.panning.dispose(),this.view.dispose(),this.renderer.dispose(),this.installedPlugins.forEach(e=>{e.dispose()})}}Sf([yt.dispose()],mt.prototype,"dispose",null);(function(i){i.View=Nt,i.Renderer=ks,i.MouseWheel=js,i.DefsManager=io,i.GridManager=Ts,i.CoordManager=ro,i.TransformManager=no,i.HighlightManager=jn,i.BackgroundManager=Ns,i.PanningManager=Ls})(mt||(mt={}));(function(i){i.toStringTag=`X6.${i.name}`;function t(e){if(e==null)return!1;if(e instanceof i)return!0;const n=e[Symbol.toStringTag];return n==null||n===i.toStringTag}i.isGraph=t})(mt||(mt={}));(function(i){function t(e,n){const s=e instanceof HTMLElement?new i({container:e}):new i(e);return n!=null&&s.fromJSON(n),s}i.render=t})(mt||(mt={}));(function(i){i.registerNode=lt.registry.register,i.registerEdge=Q.registry.register,i.registerView=et.registry.register,i.registerAttr=Tt.registry.register,i.registerGrid=Ut.registry.register,i.registerFilter=Pe.registry.register,i.registerNodeTool=Se.registry.register,i.registerEdgeTool=Oe.registry.register,i.registerBackground=Ye.registry.register,i.registerHighlighter=Rt.registry.register,i.registerPortLayout=le.registry.register,i.registerPortLabelLayout=Ce.registry.register,i.registerMarker=Zt.registry.register,i.registerRouter=Wt.registry.register,i.registerConnector=ae.registry.register,i.registerAnchor=Me.registry.register,i.registerEdgeAnchor=Ee.registry.register,i.registerConnectionPoint=Te.registry.register})(mt||(mt={}));(function(i){i.unregisterNode=lt.registry.unregister,i.unregisterEdge=Q.registry.unregister,i.unregisterView=et.registry.unregister,i.unregisterAttr=Tt.registry.unregister,i.unregisterGrid=Ut.registry.unregister,i.unregisterFilter=Pe.registry.unregister,i.unregisterNodeTool=Se.registry.unregister,i.unregisterEdgeTool=Oe.registry.unregister,i.unregisterBackground=Ye.registry.unregister,i.unregisterHighlighter=Rt.registry.unregister,i.unregisterPortLayout=le.registry.unregister,i.unregisterPortLabelLayout=Ce.registry.unregister,i.unregisterMarker=Zt.registry.unregister,i.unregisterRouter=Wt.registry.unregister,i.unregisterConnector=ae.registry.unregister,i.unregisterAnchor=Me.registry.unregister,i.unregisterEdgeAnchor=Ee.registry.unregister,i.unregisterConnectionPoint=Te.registry.unregister})(mt||(mt={}));var Of=globalThis&&globalThis.__decorate||function(i,t,e,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,e):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(i,t,e,n);else for(var l=i.length-1;l>=0;l--)(o=i[l])&&(r=(s<3?o(r):s>3?o(t,e,r):o(t,e))||r);return s>3&&r&&Object.defineProperty(t,e,r),r},Mf=globalThis&&globalThis.__rest||function(i,t){var e={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&t.indexOf(n)<0&&(e[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(i);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(i,n[s])&&(e[n[s]]=i[n[s]]);return e};class je extends lt{}(function(i){class t extends Mt{init(){super.init(),this.cell.on("change:*",this.onCellChangeAny,this)}onCellChangeAny({key:n}){const s=i.shapeMaps[this.cell.shape];if(s){const{effect:r}=s;(!r||r.includes(n))&&this.renderHTMLComponent()}}confirmUpdate(n){const s=super.confirmUpdate(n);return this.handleAction(s,t.action,()=>this.renderHTMLComponent())}renderHTMLComponent(){const n=this.selectors&&this.selectors.foContent;if(n){nn(n);const s=i.shapeMaps[this.cell.shape];if(!s)return;let{html:r}=s;typeof r=="function"&&(r=r(this.cell)),r&&(typeof r=="string"?n.innerHTML=r:sn(n,r))}}dispose(){this.cell.off("change:*",this.onCellChangeAny,this)}}Of([t.dispose()],t.prototype,"dispose",null),i.View=t,function(e){e.action="html",e.config({bootstrap:[e.action],actions:{html:e.action}}),Mt.registry.register("html-view",e,!0)}(t=i.View||(i.View={}))})(je||(je={}));(function(i){i.config({view:"html-view",markup:[{tagName:"rect",selector:"body"},Object.assign({},W.getForeignObjectMarkup()),{tagName:"text",selector:"label"}],attrs:{body:{fill:"none",stroke:"none",refWidth:"100%",refHeight:"100%"},fo:{refWidth:"100%",refHeight:"100%"}}}),lt.registry.register("html",i,!0)})(je||(je={}));(function(i){i.shapeMaps={};function t(e){const{shape:n,html:s,effect:r,inherit:o}=e,l=Mf(e,["shape","html","effect","inherit"]);if(!n)throw new Error("should specify shape in config");i.shapeMaps[n]={html:s,effect:r},mt.registerNode(n,Object.assign({inherit:o||"html"},l),!0)}i.register=t})(je||(je={}));export{U as A,yt as B,hs as C,Bt as D,of as E,pt as F,mt as G,je as H,At as M,lt as N,w as P,T as R,X as V,zf as a,F as b,Ki as c,sn as d,wa as e,Bl as f,rn as g,zs as h,$f as i,ye as j,H as k,va as l,De as m,G as n,Gi as o,R as p,vt as q,Pt as r,Vf as s,Bf as t,V as u,Xi as v,Rl as w,xe as x,I as y,al as z};