!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).G6={})}(this,function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,n);if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==e(n)?n:n+""}function r(t,e,r){return(e=n(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function o(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=Array(e);n0?(p=2*Math.sqrt(g+1),t[3]=.25*p,t[0]=(u-d)/p,t[1]=(h-a)/p,t[2]=(s-c)/p):A>l&&A>f?(p=2*Math.sqrt(1+A-l-f),t[3]=(u-d)/p,t[0]=.25*p,t[1]=(s+c)/p,t[2]=(h+a)/p):l>f?(p=2*Math.sqrt(1+l-A-f),t[3]=(h-a)/p,t[0]=(s+c)/p,t[1]=.25*p,t[2]=(u+d)/p):(p=2*Math.sqrt(1+f-A-l),t[3]=(s-c)/p,t[0]=(h+a)/p,t[1]=(u+d)/p,t[2]=.25*p),t}function X(t,e,n,r,i){var o=e[0],A=e[1],s=e[2],a=e[3],c=o+o,l=A+A,u=s+s,h=o*c,d=o*l,f=o*u,g=A*l,p=A*u,v=s*u,m=a*c,y=a*l,w=a*u,b=r[0],B=r[1],E=r[2],x=i[0],C=i[1],M=i[2],F=(1-(g+v))*b,k=(d+w)*b,S=(f-y)*b,Q=(d-w)*B,U=(1-(h+v))*B,N=(p+m)*B,T=(f+y)*E,O=(p-m)*E,I=(1-(h+g))*E;return t[0]=F,t[1]=k,t[2]=S,t[3]=0,t[4]=Q,t[5]=U,t[6]=N,t[7]=0,t[8]=T,t[9]=O,t[10]=I,t[11]=0,t[12]=n[0]+x-(F*x+Q*C+T*M),t[13]=n[1]+C-(k*x+U*C+O*M),t[14]=n[2]+M-(S*x+N*C+I*M),t[15]=1,t}function q(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],A=n+n,s=r+r,a=i+i,c=n*A,l=r*A,u=r*s,h=i*A,d=i*s,f=i*a,g=o*A,p=o*s,v=o*a;return t[0]=1-u-f,t[1]=l+v,t[2]=h-p,t[3]=0,t[4]=l-v,t[5]=1-c-f,t[6]=d+g,t[7]=0,t[8]=h+p,t[9]=d-g,t[10]=1-c-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function $(t,e,n,r,i){var o=1/Math.tan(e/2);if(t[0]=o/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0){var A=1/(r-i);t[10]=(i+r)*A,t[14]=2*i*r*A}else t[10]=-1,t[14]=-2*r;return t}var Z=$;function J(t,e,n,r,i,o,A){var s=1/(e-n),a=1/(r-i),c=1/(o-A);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*a,t[14]=(A+o)*c,t[15]=1,t}var tt=J;function et(t,e,n,r,i,o,A){var s=1/(e-n),a=1/(r-i),c=1/(o-A);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=c,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*a,t[14]=o*c,t[15]=1,t}function nt(t,e,n,r){var i,o,A,s,a,c,l,u,h,d,f=e[0],g=e[1],p=e[2],v=r[0],m=r[1],y=r[2],w=n[0],b=n[1],E=n[2];return Math.abs(f-w)0?(M=2*Math.sqrt(C+1),t[3]=.25*M,t[0]=(b-E)/M,t[1]=(B-m)/M,t[2]=(v-y)/M):p>w&&p>x?(M=2*Math.sqrt(1+p-w-x),t[3]=(b-E)/M,t[0]=.25*M,t[1]=(v+y)/M,t[2]=(B+m)/M):w>x?(M=2*Math.sqrt(1+w-p-x),t[3]=(B-m)/M,t[0]=(v+y)/M,t[1]=.25*M,t[2]=(b+E)/M):(M=2*Math.sqrt(1+x-p-w),t[3]=(v-y)/M,t[0]=(B+m)/M,t[1]=(b+E)/M,t[2]=.25*M),t},determinant:T,equals:function(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],A=t[4],s=t[5],a=t[6],c=t[7],l=t[8],u=t[9],h=t[10],d=t[11],f=t[12],g=t[13],p=t[14],v=t[15],m=e[0],y=e[1],w=e[2],b=e[3],E=e[4],x=e[5],C=e[6],M=e[7],F=e[8],k=e[9],S=e[10],Q=e[11],U=e[12],N=e[13],T=e[14],O=e[15];return Math.abs(n-m)<=B*Math.max(1,Math.abs(n),Math.abs(m))&&Math.abs(r-y)<=B*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(i-w)<=B*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(o-b)<=B*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(A-E)<=B*Math.max(1,Math.abs(A),Math.abs(E))&&Math.abs(s-x)<=B*Math.max(1,Math.abs(s),Math.abs(x))&&Math.abs(a-C)<=B*Math.max(1,Math.abs(a),Math.abs(C))&&Math.abs(c-M)<=B*Math.max(1,Math.abs(c),Math.abs(M))&&Math.abs(l-F)<=B*Math.max(1,Math.abs(l),Math.abs(F))&&Math.abs(u-k)<=B*Math.max(1,Math.abs(u),Math.abs(k))&&Math.abs(h-S)<=B*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(d-Q)<=B*Math.max(1,Math.abs(d),Math.abs(Q))&&Math.abs(f-U)<=B*Math.max(1,Math.abs(f),Math.abs(U))&&Math.abs(g-N)<=B*Math.max(1,Math.abs(g),Math.abs(N))&&Math.abs(p-T)<=B*Math.max(1,Math.abs(p),Math.abs(T))&&Math.abs(v-O)<=B*Math.max(1,Math.abs(v),Math.abs(O))},exactEquals:it,frob:function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])},fromQuat:q,fromQuat2:function(t,e){var n=new E(3),r=-e[0],i=-e[1],o=-e[2],A=e[3],s=e[4],a=e[5],c=e[6],l=e[7],u=r*r+i*i+o*o+A*A;return u>0?(n[0]=2*(s*A+l*r+a*o-c*i)/u,n[1]=2*(a*A+l*i+c*r-s*o)/u,n[2]=2*(c*A+l*o+s*i-a*r)/u):(n[0]=2*(s*A+l*r+a*o-c*i),n[1]=2*(a*A+l*i+c*r-s*o),n[2]=2*(c*A+l*o+s*i-a*r)),z(t,e,n),t},fromRotation:_,fromRotationTranslation:z,fromRotationTranslationScale:function(t,e,n,r){var i=e[0],o=e[1],A=e[2],s=e[3],a=i+i,c=o+o,l=A+A,u=i*a,h=i*c,d=i*l,f=o*c,g=o*l,p=A*l,v=s*a,m=s*c,y=s*l,w=r[0],b=r[1],B=r[2];return t[0]=(1-(f+p))*w,t[1]=(h+y)*w,t[2]=(d-m)*w,t[3]=0,t[4]=(h-y)*b,t[5]=(1-(u+p))*b,t[6]=(g+v)*b,t[7]=0,t[8]=(d+m)*B,t[9]=(g-v)*B,t[10]=(1-(u+f))*B,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:X,fromScaling:H,fromTranslation:R,fromValues:k,fromXRotation:G,fromYRotation:K,fromZRotation:j,frustum:function(t,e,n,r,i,o,A){var s=1/(n-e),a=1/(i-r),c=1/(o-A);return t[0]=2*o*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*a,t[6]=0,t[7]=0,t[8]=(n+e)*s,t[9]=(i+r)*a,t[10]=(A+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=A*o*2*c,t[15]=0,t},getRotation:Y,getScaling:W,getTranslation:V,identity:Q,invert:N,lookAt:nt,mul:ot,multiply:O,multiplyScalar:function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12]*n,t[13]=e[13]*n,t[14]=e[14]*n,t[15]=e[15]*n,t},multiplyScalarAndAdd:function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t[9]=e[9]+n[9]*r,t[10]=e[10]+n[10]*r,t[11]=e[11]+n[11]*r,t[12]=e[12]+n[12]*r,t[13]=e[13]+n[13]*r,t[14]=e[14]+n[14]*r,t[15]=e[15]+n[15]*r,t},ortho:tt,orthoNO:J,orthoZO:et,perspective:Z,perspectiveFromFieldOfView:function(t,e,n,r){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),A=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),a=2/(A+s),c=2/(i+o);return t[0]=a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(A-s)*a*.5,t[9]=(i-o)*c*.5,t[10]=r/(n-r),t[11]=-1,t[12]=0,t[13]=0,t[14]=r*n/(n-r),t[15]=0,t},perspectiveNO:$,perspectiveZO:function(t,e,n,r,i){var o=1/Math.tan(e/2);if(t[0]=o/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0){var A=1/(r-i);t[10]=i*A,t[14]=i*r*A}else t[10]=-1,t[14]=-r;return t},rotate:function(t,e,n,r){var i,o,A,s,a,c,l,u,h,d,f,g,p,v,m,y,w,b,E,x,C,M,F,k,S=r[0],Q=r[1],U=r[2],N=Math.sqrt(S*S+Q*Q+U*U);return N0&&(l*=d=1/Math.sqrt(d),u*=d,h*=d);var f=a*h-c*u,g=c*l-s*h,p=s*u-a*l;return(d=f*f+g*g+p*p)>0&&(f*=d=1/Math.sqrt(d),g*=d,p*=d),t[0]=f,t[1]=g,t[2]=p,t[3]=0,t[4]=u*p-h*g,t[5]=h*f-l*p,t[6]=l*g-u*f,t[7]=0,t[8]=l,t[9]=u,t[10]=h,t[11]=0,t[12]=i,t[13]=o,t[14]=A,t[15]=1,t},translate:I,transpose:U});function at(){var t=new E(3);return E!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function ct(t){var e=new E(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function lt(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function ut(t,e,n){var r=new E(3);return r[0]=t,r[1]=e,r[2]=n,r}function ht(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function dt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function ft(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function gt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function pt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function vt(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function mt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function yt(t,e,n){var r=e[0],i=e[1],o=e[2],A=n[0],s=n[1],a=n[2];return t[0]=i*a-o*s,t[1]=o*A-r*a,t[2]=r*s-i*A,t}function wt(t,e,n,r){var i=e[0],o=e[1],A=e[2];return t[0]=i+r*(n[0]-i),t[1]=o+r*(n[1]-o),t[2]=A+r*(n[2]-A),t}function bt(t,e,n){var r=e[0],i=e[1],o=e[2],A=n[3]*r+n[7]*i+n[11]*o+n[15];return A=A||1,t[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/A,t[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/A,t[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/A,t}function Bt(t,e){var n=t[0],r=t[1],i=t[2],o=e[0],A=e[1],s=e[2];return Math.abs(n-o)<=B*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-A)<=B*Math.max(1,Math.abs(r),Math.abs(A))&&Math.abs(i-s)<=B*Math.max(1,Math.abs(i),Math.abs(s))}var Et=gt,xt=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(n*n+r*r+i*i)},Ct=lt;function Mt(){var t=new E(4);return E!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function Ft(t,e,n,r){var i=new E(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i}function kt(t,e,n){var r=e[0],i=e[1],o=e[2],A=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*A,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*A,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*A,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*A,t}function St(){var t=new E(4);return E!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Qt(t,e,n){n*=.5;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t}function Ut(t,e,n){var r=e[0],i=e[1],o=e[2],A=e[3],s=n[0],a=n[1],c=n[2],l=n[3];return t[0]=r*l+A*s+i*c-o*a,t[1]=i*l+A*a+o*s-r*c,t[2]=o*l+A*c+r*a-i*s,t[3]=A*l-r*s-i*a-o*c,t}function Nt(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],A=n*n+r*r+i*i+o*o,s=A?1/A:0;return t[0]=-n*s,t[1]=-r*s,t[2]=-i*s,t[3]=o*s,t}function Tt(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",o=Math.PI/360;e*=o,r*=o,n*=o;var A=Math.sin(e),s=Math.cos(e),a=Math.sin(n),c=Math.cos(n),l=Math.sin(r),u=Math.cos(r);switch(i){case"xyz":t[0]=A*c*u+s*a*l,t[1]=s*a*u-A*c*l,t[2]=s*c*l+A*a*u,t[3]=s*c*u-A*a*l;break;case"xzy":t[0]=A*c*u-s*a*l,t[1]=s*a*u-A*c*l,t[2]=s*c*l+A*a*u,t[3]=s*c*u+A*a*l;break;case"yxz":t[0]=A*c*u+s*a*l,t[1]=s*a*u-A*c*l,t[2]=s*c*l-A*a*u,t[3]=s*c*u+A*a*l;break;case"yzx":t[0]=A*c*u+s*a*l,t[1]=s*a*u+A*c*l,t[2]=s*c*l-A*a*u,t[3]=s*c*u-A*a*l;break;case"zxy":t[0]=A*c*u-s*a*l,t[1]=s*a*u+A*c*l,t[2]=s*c*l+A*a*u,t[3]=s*c*u-A*a*l;break;case"zyx":t[0]=A*c*u-s*a*l,t[1]=s*a*u+A*c*l,t[2]=s*c*l-A*a*u,t[3]=s*c*u+A*a*l;break;default:throw new Error("Unknown angle order "+i)}return t}at(),function(){var t=Mt()}();var Ot=Ft,It=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Lt=function(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t},Pt=Ut,Dt=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],A=n*n+r*r+i*i+o*o;return A>0&&(A=1/Math.sqrt(A)),t[0]=n*A,t[1]=r*A,t[2]=i*A,t[3]=o*A,t};function Rt(){var t=new E(2);return E!=Float32Array&&(t[0]=0,t[1]=0),t}at(),ut(1,0,0),ut(0,1,0),St(),St(),x(),function(){var t=Rt()}();var Ht=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},_t=function(t,e){return void 0===e&&(e=[]),function(t,e){if(!Ht(t))return t;for(var n=[],r=0;r-1}(e,t)})};function Gt(t){return"function"==typeof t}function Kt(t){return null==t}function jt(t){return Array.isArray(t)}var zt=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Vt(t,e){if(t)if(jt(t))for(var n=0,r=t.length;nn?n:t};function re(t){return"number"==typeof t}function ie(t,e,n){return void 0===n&&(n=1e-5),t===e||Math.abs(t-e)r&&(n=o,r=A)}return n}},Ae=function(t,e){if(jt(t)){for(var n,r=1/0,i=0;ii&&(r=n,A(1),++e),n[t]=o}function A(t){e=0,n=Object.create(null),t||(r=Object.create(null))}return A(),{clear:A,has:function(t){return void 0!==n[t]||void 0!==r[t]},get:function(t){var e=n[t];return void 0!==e?e:void 0!==(e=r[t])?(o(t,e),e):void 0},set:function(t,e){void 0!==n[t]?n[t]=e:o(t,e)}}}(n));var A=ve.get(t);if(A.has(o))return A.get(o);var s=t.apply(this,r);return A.set(o,s),s}}function ye(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function we(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(ye(e,i)){var o=e[i];null!==o&&qt(o)?(qt(t[i])||(t[i]={}),ne?(r&&(clearTimeout(r),r=null),s=c,A=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(a,l)),A};return c.cancel=function(){clearTimeout(r),s=0,r=i=o=null},c},Ue={},Ne=function(){},Te=function(t){return t},Oe=function(t,e){return Oe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},Oe(t,e)};function Ie(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}Oe(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var Le=function(){return Le=Object.assign||function(t){for(var e,n=1,r=arguments.length;n=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function He(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),A=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)A.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return A}function _e(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i7){t[n].shift();for(var r=t[n],i=n;r.length;)e[n]="A",t.splice(i+=1,0,["C"].concat(r.splice(0,6)));t.splice(n,1)}}var ze={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function Ve(t){return Array.isArray(t)&&t.every(function(t){var e=t[0].toLowerCase();return ze[e]===t.length-1&&"achlmqstvz".includes(e)})}function We(t){return Ve(t)&&t.every(function(t){var e=t[0];return e===e.toUpperCase()})}function Ye(t){return We(t)&&t.every(function(t){var e=t[0];return"ACLMQZ".includes(e)})}function Xe(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=ze[n]&&("m"===n&&r.length>2?(t.segments.push([e].concat(r.splice(0,2))),n="l",e="m"===e?"l":"L"):t.segments.push([e].concat(r.splice(0,ze[n]))),ze[n]););}function qe(t){var e=t.index,n=t.pathValue,r=n.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='[path-util]: invalid Arc flag "'.concat(n[e],'", expecting 0 or 1 at index ').concat(e))}function $e(t){return t>=48&&t<=57||43===t||45===t||46===t}function Ze(t){return t>=48&&t<=57}function Je(t){var e,n=t.max,r=t.pathValue,i=t.index,o=i,A=!1,s=!1,a=!1,c=!1;if(o>=n)t.err="[path-util]: Invalid path value at index ".concat(o,', "pathValue" is missing param');else if(43!==(e=r.charCodeAt(o))&&45!==e||(o+=1,e=r.charCodeAt(o)),Ze(e)||46===e){if(46!==e){if(A=48===e,o+=1,e=r.charCodeAt(o),A&&o=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(t)}function en(t){for(var e=t.pathValue,n=t.max;t.index0;A-=1){if(!nn(i)||3!==A&&4!==A?Je(t):qe(t),t.err.length)return;t.data.push(t.param),en(t),t.index=t.max)break;if(!$e(n.charCodeAt(t.index)))break}Xe(t)}else Xe(t);else t.err='[path-util]: Invalid path value "'.concat(n[r],'" is not a path command')}var on=function(t){this.pathValue=t,this.segments=[],this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""};function An(t){if(We(t))return[].concat(t);var e=function(t){if(Ve(t))return[].concat(t);var e=new on(t);for(en(e);e.index1&&(v*=M=Math.sqrt(M),m*=M);var F=v*v,k=m*m,S=(o===A?-1:1)*Math.sqrt(Math.abs((F*k-F*C*C-k*x*x)/(F*C*C+k*x*x)));d=S*v*C/m+(g+y)/2,f=S*-m*x/v+(p+w)/2,u=Math.asin(((p-f)/m*Math.pow(10,9)|0)/Math.pow(10,9)),h=Math.asin(((w-f)/m*Math.pow(10,9)|0)/Math.pow(10,9)),u=gh&&(u-=2*Math.PI),!A&&h>u&&(h-=2*Math.PI)}var Q=h-u;if(Math.abs(Q)>b){var U=h,N=y,T=w;h=u+b*(A&&h>u?1:-1),E=ln(y=d+v*Math.cos(h),w=f+m*Math.sin(h),v,m,i,0,A,N,T,[h,U,d,f])}Q=h-u;var O=Math.cos(u),I=Math.sin(u),L=Math.cos(h),P=Math.sin(h),D=Math.tan(Q/4),R=4/3*v*D,H=4/3*m*D,_=[g,p],G=[g+R*I,p-H*O],K=[y+R*P,w-H*L],j=[y,w];if(G[0]=2*_[0]-G[0],G[1]=2*_[1]-G[1],c)return G.concat(K,j,E);for(var z=[],V=0,W=(E=G.concat(K,j,E)).length;V=o)A={x:n,y:r};else{var s=un([t,e],[n,r],i/o);A={x:s[0],y:s[1]}}return{length:o,point:A,min:{x:Math.min(t,n),y:Math.min(e,r)},max:{x:Math.max(t,n),y:Math.max(e,r)}}}function vn(t,e){var n=t.x,r=t.y,i=e.x,o=e.y,A=n*i+r*o,s=Math.sqrt((Math.pow(n,2)+Math.pow(r,2))*(Math.pow(i,2)+Math.pow(o,2)));return(n*o-r*i<0?-1:1)*Math.acos(A/s)}function mn(t,e,n,r,i,o,A,s,a,c){var l=Math.abs,u=Math.sin,h=Math.cos,d=Math.sqrt,f=Math.PI,g=l(n),p=l(r),v=(i%360+360)%360*(f/180);if(t===s&&e===a)return{x:t,y:e};if(0===g||0===p)return pn(t,e,s,a,c).point;var m=(t-s)/2,y=(e-a)/2,w={x:h(v)*m+u(v)*y,y:-u(v)*m+h(v)*y},b=Math.pow(w.x,2)/Math.pow(g,2)+Math.pow(w.y,2)/Math.pow(p,2);b>1&&(g*=d(b),p*=d(b));var B=(Math.pow(g,2)*Math.pow(p,2)-Math.pow(g,2)*Math.pow(w.y,2)-Math.pow(p,2)*Math.pow(w.x,2))/(Math.pow(g,2)*Math.pow(w.y,2)+Math.pow(p,2)*Math.pow(w.x,2)),E=(o!==A?1:-1)*d(B=B<0?0:B),x=E*(g*w.y/p),C=E*(-p*w.x/g),M=h(v)*x-u(v)*C+(t+s)/2,F=u(v)*x+h(v)*C+(e+a)/2,k={x:(w.x-x)/g,y:(w.y-C)/p},S=vn({x:1,y:0},k),Q=vn(k,{x:(-w.x-x)/g,y:(-w.y-C)/p});!A&&Q>0?Q-=2*f:A&&Q<0&&(Q+=2*f);var U=S+(Q%=2*f)*c,N=g*h(U),T=p*u(U);return{x:h(v)*N-u(v)*T+M,y:u(v)*N+h(v)*T+F}}function yn(t,e,n,r,i,o,A,s,a,c,l){var u,h=l.bbox,d=void 0===h||h,f=l.length,g=void 0===f||f,p=l.sampleSize,v=void 0===p?30:p,m="number"==typeof c,y=t,w=e,b=0,B=[y,w,b],E=[y,w],x={x:0,y:0},C=[{x:y,y:w}];m&&c<=0&&(x={x:y,y:w});for(var M=0;M<=v;M+=1){if(y=(u=mn(t,e,n,r,i,o,A,s,a,M/v)).x,w=u.y,d&&C.push({x:y,y:w}),g&&(b+=gn(E,[y,w])),E=[y,w],m&&b>=c&&c>B[2]){var F=(b-c)/(b-B[2]);x={x:E[0]*(1-F)+B[0]*F,y:E[1]*(1-F)+B[1]*F}}B=[y,w,b]}return m&&c>=b&&(x={x:s,y:a}),{length:b,point:x,min:{x:Math.min.apply(null,C.map(function(t){return t.x})),y:Math.min.apply(null,C.map(function(t){return t.y}))},max:{x:Math.max.apply(null,C.map(function(t){return t.x})),y:Math.max.apply(null,C.map(function(t){return t.y}))}}}function wn(t,e,n,r,i,o,A,s,a){var c=1-a;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*a*n+3*c*Math.pow(a,2)*i+Math.pow(a,3)*A,y:Math.pow(c,3)*e+3*Math.pow(c,2)*a*r+3*c*Math.pow(a,2)*o+Math.pow(a,3)*s}}function bn(t,e,n,r,i,o,A,s,a,c){var l,u=c.bbox,h=void 0===u||u,d=c.length,f=void 0===d||d,g=c.sampleSize,p=void 0===g?10:g,v="number"==typeof a,m=t,y=e,w=0,b=[m,y,w],B=[m,y],E={x:0,y:0},x=[{x:m,y:y}];v&&a<=0&&(E={x:m,y:y});for(var C=0;C<=p;C+=1){if(m=(l=wn(t,e,n,r,i,o,A,s,C/p)).x,y=l.y,h&&x.push({x:m,y:y}),f&&(w+=gn(B,[m,y])),B=[m,y],v&&w>=a&&a>b[2]){var M=(w-a)/(w-b[2]);E={x:B[0]*(1-M)+b[0]*M,y:B[1]*(1-M)+b[1]*M}}b=[m,y,w]}return v&&a>=w&&(E={x:A,y:s}),{length:w,point:E,min:{x:Math.min.apply(null,x.map(function(t){return t.x})),y:Math.min.apply(null,x.map(function(t){return t.y}))},max:{x:Math.max.apply(null,x.map(function(t){return t.x})),y:Math.max.apply(null,x.map(function(t){return t.y}))}}}function Bn(t,e,n,r,i,o,A){var s=1-A;return{x:Math.pow(s,2)*t+2*s*A*n+Math.pow(A,2)*i,y:Math.pow(s,2)*e+2*s*A*r+Math.pow(A,2)*o}}function En(t,e,n,r,i,o,A,s){var a,c=s.bbox,l=void 0===c||c,u=s.length,h=void 0===u||u,d=s.sampleSize,f=void 0===d?10:d,g="number"==typeof A,p=t,v=e,m=0,y=[p,v,m],w=[p,v],b={x:0,y:0},B=[{x:p,y:v}];g&&A<=0&&(b={x:p,y:v});for(var E=0;E<=f;E+=1){if(p=(a=Bn(t,e,n,r,i,o,E/f)).x,v=a.y,l&&B.push({x:p,y:v}),h&&(m+=gn(w,[p,v])),w=[p,v],g&&m>=A&&A>y[2]){var x=(m-A)/(m-y[2]);b={x:w[0]*(1-x)+y[0]*x,y:w[1]*(1-x)+y[1]*x}}y=[p,v,m]}return g&&A>=m&&(b={x:i,y:o}),{length:m,point:b,min:{x:Math.min.apply(null,B.map(function(t){return t.x})),y:Math.min.apply(null,B.map(function(t){return t.y}))},max:{x:Math.max.apply(null,B.map(function(t){return t.x})),y:Math.max.apply(null,B.map(function(t){return t.y}))}}}function xn(t,e,n){for(var r,i,o,A,s,a,c,l,u,h=an(t),d="number"==typeof e,f=[],g=0,p=0,v=0,m=0,y=[],w=[],b=0,B={x:0,y:0},E=B,x=B,C=B,M=0,F=0,k=h.length;F=e&&(C=x),w.push(E),y.push(B),M+=b,g=(a="Z"!==l?u.slice(-2):[v,m])[0],p=a[1];return d&&e>=M&&(C={x:g,y:p}),{length:M,point:C,min:{x:Math.min.apply(null,y.map(function(t){return t.x})),y:Math.min.apply(null,y.map(function(t){return t.y}))},max:{x:Math.max.apply(null,w.map(function(t){return t.x})),y:Math.max.apply(null,w.map(function(t){return t.y}))}}}function Cn(t,e){var n=t.length-1,r=[],i=0,o=function(t){var e=t.length,n=e-1;return t.map(function(r,i){return t.map(function(r,o){var A,s=i+o;return 0===o||t[s]&&"M"===t[s][0]?(A=t[s],["M"].concat(A.slice(-2))):(s>=e&&(s-=n),t[s])})})}(t);return o.forEach(function(o,A){t.slice(1).forEach(function(r,o){i+=gn(t[(A+o)%n].slice(-2),e[o%n].slice(-2))}),r[A]=i,i=0}),o[r.indexOf(Math.min.apply(null,r))]}function Mn(t){return function(t){var e=0,n=0,r=0;return fn(t).map(function(t){var i;if("M"===t[0])return e=t[1],n=t[2],0;var o=t.slice(1),A=o[0],s=o[1],a=o[2],c=o[3],l=o[4],u=o[5];return r=function(t,e,n,r,i,o,A,s){return 3*((s-e)*(n+i)-(A-t)*(r+o)+r*(t-i)-n*(e-o)+s*(i+t/3)-A*(o+e/3))/20}(e,n,A,s,a,c,l,u),i=t.slice(-2),e=i[0],n=i[1],r}).reduce(function(t,e){return t+e},0)}(t)>=0}function Fn(t){return t.map(function(t,e,n){var r,i=e&&n[e-1].slice(-2).concat(t.slice(1)),o=e?bn(i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],{bbox:!1}).length:0;return r=e?o?function(t,e){void 0===e&&(e=.5);var n=t.slice(0,2),r=t.slice(2,4),i=t.slice(4,6),o=t.slice(6,8),A=un(n,r,e),s=un(r,i,e),a=un(i,o,e),c=un(A,s,e),l=un(s,a,e),u=un(c,l,e);return[["C"].concat(A,c,u),["C"].concat(l,a,o)]}(i):[t,t]:[t],{s:t,ss:r,l:o}})}function kn(t,e,n,r){if(void 0===r&&(r=0),r>50)return console.warn("Maximum recursion depth reached in equalizeSegments"),[t,e];var i=Fn(t),o=Fn(e),A=i.length,s=o.length,a=i.filter(function(t){return t.l}).length,c=o.filter(function(t){return t.l}).length,l=i.filter(function(t){return t.l}).reduce(function(t,e){return t+e.l},0)/a||0,u=o.filter(function(t){return t.l}).reduce(function(t,e){return t+e.l},0)/c||0,h=n||Math.max(A,s),d=[l,u],f=[h-A,h-s],g=0,p=[i,o].map(function(t,e){return t.l===h?t.map(function(t){return t.s}):t.map(function(t,n){return g=n&&f[e]&&t.l>=d[e],f[e]-=g?1:0,g?t.ss:[t.s]}).flat()});return p[0].length===p[1].length?p:kn(p[0],p[1],h,r+1)}function Sn(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}function Qn(){return Qn="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}(t,e);if(r){var i=Object.getOwnPropertyDescriptor(r,e);return i.get?i.get.call(arguments.length<3?t:n):i.value}},Qn.apply(null,arguments)}function Un(t,e,n,r){var i=Qn(h(t.prototype),e,n);return"function"==typeof i?function(t){return i.apply(n,t)}:i} /*! * @antv/g-math * @description Geometry util * @version 3.1.0 * @date 12/22/2025, 3:02:36 AM * @author AntVis * @docs https://g.antv.antgroup.com/ */function Nn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function Tn(t,e){var n=Math.min.apply(Math,u(t)),r=Math.min.apply(Math,u(e));return{x:n,y:r,width:Math.max.apply(Math,u(t))-n,height:Math.max.apply(Math,u(e))-r}}function On(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function In(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function Ln(t,e,n,r,i,o,A){for(var s=function(t,e,n){return Math.atan(-e/t*Math.tan(n))}(n,r,i),a=1/0,c=-1/0,l=[o,A],u=2*-Math.PI;u<=2*Math.PI;u+=Math.PI){var h=s+u;oc&&(c=f)}for(var g=function(t,e,n){return Math.atan(e/(t*Math.tan(n)))}(n,r,i),p=1/0,v=-1/0,m=[o,A],y=2*-Math.PI;y<=2*Math.PI;y+=Math.PI){var w=g+y;ov&&(v=B)}return{x:a,y:p,width:c-a,height:v-p}}function Pn(t,e,n,r,i,o){var A=-1,s=1/0,a=[n,r],c=20;o&&o>200&&(c=o/10);for(var l=1/c,h=l/10,d=0;d<=c;d++){var f=d*l,g=[i.apply(void 0,u(t.concat([f]))),i.apply(void 0,u(e.concat([f])))],p=Nn(a[0],a[1],g[0],g[1]);p=0&&B0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s);var a=[i-t,o-e];return Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}(a,s))}function _n(t,e,n,r,i){var o=1-i;return o*o*o*t+3*e*i*o*o+3*n*i*i*o+r*i*i*i}function Gn(t,e,n,r){var i,o,A,s=-3*t+9*e-9*n+3*r,a=6*t-12*e+6*n,c=3*e-3*t,l=[];if(ie(s,0))ie(a,0)||(i=-c/a)>=0&&i<=1&&l.push(i);else{var u=a*a-4*s*c;ie(u,0)?l.push(-a/(2*s)):u>0&&(o=(-a-(A=Math.sqrt(u)))/(2*s),(i=(-a+A)/(2*s))>=0&&i<=1&&l.push(i),o>=0&&o<=1&&l.push(o))}return l}function Kn(t,e,n,r,i,o,A,s){for(var a=[t,A],c=[e,s],l=Gn(t,n,i,A),u=Gn(e,r,o,s),h=0;h=0?[i]:[]}function Yn(t,e,n,r,i,o){var A=Wn(t,n,i)[0],s=Wn(e,r,o)[0],a=[t,i],c=[e,o];return void 0!==A&&a.push(Vn(t,n,i,A)),void 0!==s&&c.push(Vn(e,r,o,s)),Tn(a,c)}function Xn(t,e,n,r,i,o,A,s){var a=function(t,e,n,r,i,o,A,s){return Pn([t,n,i],[e,r,o],A,s,Vn)}(t,e,n,r,i,o,A,s);return Nn(a.x,a.y,A,s)}function qn(t,e){this.v=t,this.k=e}function $n(t,e,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(t){i=0}$n=function(t,e,n,r){function o(e,n){$n(t,e,function(t){return this._invoke(e,n,t)})}e?i?i(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(o("next",0),o("throw",1),o("return",2))},$n(t,e,n,r)}function Zn(){ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function o(n,r,i,o){var a=r&&r.prototype instanceof s?r:s,c=Object.create(a.prototype);return $n(c,"_invoke",function(n,r,i){var o,s,a,c=0,l=i||[],u=!1,h={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,n){return o=e,s=0,a=t,h.n=n,A}};function d(n,r){for(s=n,a=r,e=0;!u&&c&&!i&&e3?(i=f===r)&&(a=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=t):o[0]<=d&&((i=n<2&&dr||r>f)&&(o[4]=n,o[5]=r,h.n=f,s=0))}if(i||n>1)return A;throw u=!0,r}return function(i,l,f){if(c>1)throw TypeError("Generator is already running");for(u&&1===l&&d(l,f),s=l,a=f;(e=s<2?t:a)||!u;){o||(s?s<3?(s>1&&(h.n=-1),d(s,a)):h.n=a:h.v=a);try{if(c=2,o){if(s||(i="next"),e=o[i]){if(!(e=e.call(o,a)))throw TypeError("iterator result is not an object");if(!e.done)return e;a=e.value,s<2&&(s=0)}else 1===s&&(e=o.return)&&e.call(o),s<2&&(a=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=t}else if((e=(u=h.n<0)?a:n.call(r,h))!==A)break}catch(e){o=t,s=1,a=e}finally{c=1}}return{value:e,done:u}}}(n,i,o),!0),c}var A={};function s(){}function a(){}function c(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):($n(e={},r,function(){return this}),e),u=c.prototype=s.prototype=Object.create(l);function h(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,c):(t.__proto__=c,$n(t,i,"GeneratorFunction")),t.prototype=Object.create(u),t}return a.prototype=c,$n(u,"constructor",c),$n(c,"constructor",a),a.displayName="GeneratorFunction",$n(c,i,"GeneratorFunction"),$n(u),$n(u,i,"Generator"),$n(u,r,function(){return this}),$n(u,"toString",function(){return"[object Generator]"}),(Zn=function(){return{w:o,m:h}})()}function Jn(t,e){function n(r,i,o,A){try{var s=t[r](i),a=s.value;return a instanceof qn?e.resolve(a.v).then(function(t){n("next",t,o,A)},function(t){n("throw",t,o,A)}):e.resolve(a).then(function(t){s.value=t,o(s)},function(t){return n("throw",t,o,A)})}catch(t){A(t)}}var r;this.next||($n(Jn.prototype),$n(Jn.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),$n(this,"_invoke",function(t,i,o){function A(){return new e(function(e,r){n(t,o,e,r)})}return r=r?r.then(A,A):A()},!0)}function tr(t,e,n,r,i){return new Jn(Zn().w(t,e,n,r),i||Promise)}function er(t,e,n,r,i){var o=tr(t,e,n,r,i);return o.next().then(function(t){return t.done?t.value:o.next()})}function nr(t){var e=Object(t),n=[];for(var r in e)n.unshift(r);return function t(){for(;n.length;)if((r=n.pop())in e)return t.value=r,t.done=!1,t;return t.done=!0,t}}function rr(t){if(null!=t){var n=t["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length))return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}throw new TypeError(e(t)+" is not iterable")}function ir(){var t=Zn(),e=t.m(ir),n=(Object.getPrototypeOf?Object.getPrototypeOf(e):e.__proto__).constructor;function r(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===n||"GeneratorFunction"===(e.displayName||e.name))}var i={throw:1,return:2,break:3,continue:3};function o(t){var e,n;return function(r){e||(e={stop:function(){return n(r.a,2)},catch:function(){return r.v},abrupt:function(t,e){return n(r.a,i[t],e)},delegateYield:function(t,i,o){return e.resultName=i,n(r.d,rr(t),o)},finish:function(t){return n(r.f,t)}},n=function(t,n,i){r.p=e.prev,r.n=e.next;try{return t(n,i)}finally{e.next=r.n}}),e.resultName&&(e[e.resultName]=r.v,e.resultName=void 0),e.sent=r.v,e.next=r.n;try{return t.call(this,e)}finally{r.p=e.prev,r.n=e.next}}}return(ir=function(){return{wrap:function(e,n,r,i){return t.w(o(e),n,r,i&&i.reverse())},isGeneratorFunction:r,mark:t.m,awrap:function(t,e){return new qn(t,e)},AsyncIterator:Jn,async:function(t,e,n,i,A){return(r(e)?tr:er)(o(t),e,n,i,A)},keys:nr,values:rr}})()}function or(t,e,n,r,i,o,A){try{var s=t[o](A),a=s.value}catch(t){return void n(t)}s.done?e(a):Promise.resolve(a).then(r,i)}function Ar(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var o=t.apply(e,n);function A(t){or(o,r,i,A,s,"next",t)}function s(t){or(o,r,i,A,s,"throw",t)}A(void 0)})}}function sr(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=l(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,A=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return A=t.done,t},e:function(t){s=!0,o=t},f:function(){try{A||null==n.return||n.return()}finally{if(s)throw o}}}}function ar(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;n[r]=t[r]}return n}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r=0&&t.context.renderingPlugins.splice(n,1)})}}])}(),hr=function(){return a(function t(e){A(this,t),this.clipSpaceNearZ=lr.NEGATIVE_ONE,this.plugins=[],this.config=o({enableDirtyCheck:!0,enableCulling:!1,enableAutoRendering:!0,enableDirtyRectangleRendering:!0,enableDirtyRectangleRenderingDebug:!1,enableSizeAttenuation:!0,enableRenderingOptimization:!1},e)},[{key:"registerPlugin",value:function(t){var e=this.plugins.findIndex(function(e){return e===t});-1===e&&this.plugins.push(t)}},{key:"unregisterPlugin",value:function(t){var e=this.plugins.findIndex(function(e){return e===t});e>-1&&this.plugins.splice(e,1)}},{key:"getPlugins",value:function(){return this.plugins}},{key:"getPlugin",value:function(t){return this.plugins.find(function(e){return e.name===t})}},{key:"getConfig",value:function(){return this.config}},{key:"setConfig",value:function(t){Object.assign(this.config,t)}}])}(),dr=ft,fr=ht,gr=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t},pr=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t},vr=pt,mr=Et,yr=function(){function t(){A(this,t),this.center=[0,0,0],this.halfExtents=[0,0,0],this.min=[0,0,0],this.max=[0,0,0]}return a(t,[{key:"update",value:function(t,e){fr(this.center,t),fr(this.halfExtents,e),mr(this.min,this.center,this.halfExtents),dr(this.max,this.center,this.halfExtents)}},{key:"setMinMax",value:function(t,e){dr(this.center,e,t),vr(this.center,this.center,.5),mr(this.halfExtents,e,t),vr(this.halfExtents,this.halfExtents,.5),fr(this.min,t),fr(this.max,e)}},{key:"getMin",value:function(){return this.min}},{key:"getMax",value:function(){return this.max}},{key:"add",value:function(e){if(!t.isEmpty(e))if(t.isEmpty(this))this.setMinMax(e.getMin(),e.getMax());else{var n=this.center,r=n[0],i=n[1],o=n[2],A=this.halfExtents,s=A[0],a=A[1],c=A[2],l=r-s,u=r+s,h=i-a,d=i+a,f=o-c,g=o+c,p=e.center,v=p[0],m=p[1],y=p[2],w=e.halfExtents,b=w[0],B=w[1],E=w[2],x=v-b,C=v+b,M=m-B,F=m+B,k=y-E,S=y+E;xu&&(u=C),Md&&(d=F),kg&&(g=S),n[0]=.5*(l+u),n[1]=.5*(h+d),n[2]=.5*(f+g),A[0]=.5*(u-l),A[1]=.5*(d-h),A[2]=.5*(g-f),this.min[0]=l,this.min[1]=h,this.min[2]=f,this.max[0]=u,this.max[1]=d,this.max[2]=g}}},{key:"setFromTransformedAABB",value:function(t,e){var n=this.center,r=this.halfExtents,i=t.center,o=t.halfExtents,A=e[0],s=e[4],a=e[8],c=e[1],l=e[5],u=e[9],h=e[2],d=e[6],f=e[10],g=Math.abs(A),p=Math.abs(s),v=Math.abs(a),m=Math.abs(c),y=Math.abs(l),w=Math.abs(u),b=Math.abs(h),B=Math.abs(d),E=Math.abs(f);n[0]=e[12]+A*i[0]+s*i[1]+a*i[2],n[1]=e[13]+c*i[0]+l*i[1]+u*i[2],n[2]=e[14]+h*i[0]+d*i[1]+f*i[2],r[0]=g*o[0]+p*o[1]+v*o[2],r[1]=m*o[0]+y*o[1]+w*o[2],r[2]=b*o[0]+B*o[1]+E*o[2],mr(this.min,n,r),dr(this.max,n,r)}},{key:"intersects",value:function(t){var e=this.getMax(),n=this.getMin(),r=t.getMax(),i=t.getMin();return n[0]<=r[0]&&e[0]>=i[0]&&n[1]<=r[1]&&e[1]>=i[1]&&n[2]<=r[2]&&e[2]>=i[2]}},{key:"intersection",value:function(e){if(!this.intersects(e))return null;var n=new t,r=gr([0,0,0],this.getMin(),e.getMin()),i=pr([0,0,0],this.getMax(),e.getMax());return n.setMinMax(r,i),n}},{key:"getNegativeFarPoint",value:function(t){return 273===t.pnVertexFlag?fr([0,0,0],this.min):272===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:257===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:256===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:17===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:16===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:1===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:[this.max[0],this.max[1],this.max[2]]}},{key:"getPositiveFarPoint",value:function(t){return 273===t.pnVertexFlag?fr([0,0,0],this.max):272===t.pnVertexFlag?[this.max[0],this.max[1],this.min[2]]:257===t.pnVertexFlag?[this.max[0],this.min[1],this.max[2]]:256===t.pnVertexFlag?[this.max[0],this.min[1],this.min[2]]:17===t.pnVertexFlag?[this.min[0],this.max[1],this.max[2]]:16===t.pnVertexFlag?[this.min[0],this.max[1],this.min[2]]:1===t.pnVertexFlag?[this.min[0],this.min[1],this.max[2]]:[this.min[0],this.min[1],this.min[2]]}}],[{key:"isEmpty",value:function(t){return!t||0===t.halfExtents[0]&&0===t.halfExtents[1]&&0===t.halfExtents[2]}}])}(),wr=function(){return a(function t(e,n){A(this,t),this.distance=e||0,this.normal=n||ut(0,1,0),this.updatePNVertexFlag()},[{key:"updatePNVertexFlag",value:function(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0)}},{key:"distanceToPoint",value:function(t){return mt(t,this.normal)-this.distance}},{key:"normalize",value:function(){var t=1/Ct(this.normal);pt(this.normal,this.normal,t),this.distance*=t}},{key:"intersectsLine",value:function(t,e,n){var r=this.distanceToPoint(t),i=r/(r-this.distanceToPoint(e)),o=i>=0&&i<=1;return o&&n&&wt(n,t,e,i),o}}])}(),br=function(t){return t[t.OUTSIDE=4294967295]="OUTSIDE",t[t.INSIDE=0]="INSIDE",t[t.INDETERMINATE=2147483647]="INDETERMINATE",t}({}),Br=function(){return a(function t(e){if(A(this,t),this.planes=[],e)this.planes=e;else for(var n=0;n<6;n++)this.planes.push(new wr)},[{key:"extractFromVPMatrix",value:function(t){var e=m(t,16),n=e[0],r=e[1],i=e[2],o=e[3],A=e[4],s=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],g=e[13],p=e[14],v=e[15];dt(this.planes[0].normal,o-n,c-A,d-l),this.planes[0].distance=v-f,dt(this.planes[1].normal,o+n,c+A,d+l),this.planes[1].distance=v+f,dt(this.planes[2].normal,o+r,c+s,d+u),this.planes[2].distance=v+g,dt(this.planes[3].normal,o-r,c-s,d-u),this.planes[3].distance=v-g,dt(this.planes[4].normal,o-i,c-a,d-h),this.planes[4].distance=v-p,dt(this.planes[5].normal,o+i,c+a,d+h),this.planes[5].distance=v+p,this.planes.forEach(function(t){t.normalize(),t.updatePNVertexFlag()})}}])}(),Er=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;A(this,t),this.x=0,this.y=0,this.x=e,this.y=n}return a(t,[{key:"clone",value:function(){return new t(this.x,this.y)}},{key:"copyFrom",value:function(t){this.x=t.x,this.y=t.y}}])}(),xr=function(){function t(e,n,r,i){A(this,t),this.x=e,this.y=n,this.width=r,this.height=i,this.left=e,this.right=e+r,this.top=n,this.bottom=n+i}return a(t,[{key:"toJSON",value:function(){}}],[{key:"fromRect",value:function(e){return new t(e.x,e.y,e.width,e.height)}},{key:"applyTransform",value:function(e,n){var r=Ft(e.x,e.y,0,1),i=Ft(e.x+e.width,e.y,0,1),o=Ft(e.x,e.y+e.height,0,1),A=Ft(e.x+e.width,e.y+e.height,0,1),s=Mt(),a=Mt(),c=Mt(),l=Mt();kt(s,r,n),kt(a,i,n),kt(c,o,n),kt(l,A,n);var u=Math.min(s[0],a[0],c[0],l[0]),h=Math.min(s[1],a[1],c[1],l[1]),d=Math.max(s[0],a[0],c[0],l[0]),f=Math.max(s[1],a[1],c[1],l[1]);return t.fromRect({x:u,y:h,width:d-u,height:f-h})}}])}(),Cr="Method not implemented.",Mr="Use document.documentElement instead.";function Fr(t){return void 0===t?0:t>360||t<-360?t%360:t}var kr=at();function Sr(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];return Array.isArray(t)&&3===t.length?r?ct(t):ht(kr,t):re(t)?r?ut(t,e,n):dt(kr,t,e,n):r?ut(t[0],t[1]||e,t[2]||n):dt(kr,t[0],t[1]||e,t[2]||n)}var Qr=Math.PI/180;function Ur(t){return t*Qr}var Nr=180/Math.PI;function Tr(t){return t*Nr}var Or=Math.PI/2;function Ir(t,e){return 16===e.length?function(t,e){var n,r,i=m(W(at(),e),3),o=i[0],A=i[1],s=i[2],a=Math.asin(-e[2]/o);return a-Or?(n=Math.atan2(e[6]/A,e[10]/s),r=Math.atan2(e[1]/o,e[0]/o)):(r=0,n=-Math.atan2(e[4]/A,e[5]/A)):(r=0,n=Math.atan2(e[4]/A,e[5]/A)),t[0]=n,t[1]=a,t[2]=r,t}(t,e):function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],A=r*r,s=i*i,a=o*o,c=n*n+A+s+a,l=n*o-r*i;return l>.499995*c?(t[0]=Or,t[1]=2*Math.atan2(r,n),t[2]=0):l<-.499995*c?(t[0]=-Or,t[1]=2*Math.atan2(r,n),t[2]=0):(t[0]=Math.asin(2*(n*i-o*r)),t[1]=Math.atan2(2*(n*o+r*i),1-2*(s+a)),t[2]=Math.atan2(2*(n*r+i*o),1-2*(A+s))),t}(t,e)}function Lr(t,e,n,r,i){var o,A,s,a,c,l,u,h,d,f,g=Math.cos(t),p=Math.sin(t);return o=r*g,A=i*p,s=0,a=-r*p,c=i*g,l=0,u=e,h=n,d=1,(f=new E(9))[0]=o,f[1]=A,f[2]=s,f[3]=a,f[4]=c,f[5]=l,f[6]=u,f[7]=h,f[8]=d,f}function Pr(t){var e=t[0],n=t[1],r=t[3],i=t[4],o=Math.sqrt(e*e+n*n),A=Math.sqrt(r*r+i*i);if(e*i-n*r<0&&(e7&&void 0!==arguments[7]&&arguments[7]?(s=-A/p,a=-v/p):(s=-(A+o)/p,a=-2*v/p),t[0]=h,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=d,t[6]=0,t[7]=0,t[8]=f,t[9]=g,t[10]=s,t[11]=-1,t[12]=0,t[13]=0,t[14]=a,t[15]=0}(this.projectionMatrix,a,a+s,o-A,o,t,this.far,this.clipSpaceNearZ===lr.ZERO),N(this.projectionMatrixInverse,this.projectionMatrix),this.triggerUpdate(),this}},{key:"setOrthographic",value:function(t,e,n,r,i,o){var A;this.projectionMode=Vr.ORTHOGRAPHIC,this.rright=e,this.left=t,this.top=n,this.bottom=r,this.near=i,this.far=o;var s=(this.rright-this.left)/(2*this.zoom),a=(this.top-this.bottom)/(2*this.zoom),c=(this.rright+this.left)/2,l=(this.top+this.bottom)/2,u=c-s,h=c+s,d=l+a,f=l-a;if(null!==(A=this.view)&&void 0!==A&&A.enabled){var g=(this.rright-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;h=(u+=g*this.view.offsetX)+g*this.view.width,f=(d-=p*this.view.offsetY)-p*this.view.height}return this.clipSpaceNearZ===lr.NEGATIVE_ONE?tt(this.projectionMatrix,u,h,d,f,i,o):et(this.projectionMatrix,u,h,d,f,i,o),N(this.projectionMatrixInverse,this.projectionMatrix),this._getOrthoMatrix(),this.triggerUpdate(),this}},{key:"setPosition",value:function(t){var e=Sr(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.position[1],arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.position[2]);return this._setPosition(e),this.setFocalPoint(this.focalPoint),this.triggerUpdate(),this}},{key:"setFocalPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.focalPoint[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.focalPoint[2],r=ut(0,1,0);if(this.focalPoint=Sr(t,e,n),this.trackingMode===zr.CINEMATIC){var i=gt(at(),this.focalPoint,this.position);t=i[0],e=i[1],n=i[2];var o=lt(i),A=Tr(Math.asin(e/o)),s=90+Tr(Math.atan2(n,t)),a=C();D(a,a,Ur(s)),P(a,a,Ur(A)),r=bt(at(),[0,1,0],a)}return N(this.matrix,nt(C(),this.position,this.focalPoint,r)),this._getAxes(),this._getDistance(),this._getAngles(),this.triggerUpdate(),this}},{key:"getDistance",value:function(){return this.distance}},{key:"getDistanceVector",value:function(){return this.distanceVector}},{key:"setDistance",value:function(t){if(this.distance===t||t<0)return this;this.distance=t,this.distance>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?xi(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?xi(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=di.exec(t))?new Ci(e[1],e[2],e[3],1):(e=fi.exec(t))?new Ci(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=gi.exec(t))?xi(e[1],e[2],e[3],e[4]):(e=pi.exec(t))?xi(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=vi.exec(t))?Ui(e[1],e[2]/100,e[3]/100,1):(e=mi.exec(t))?Ui(e[1],e[2]/100,e[3]/100,e[4]):yi.hasOwnProperty(t)?Ei(yi[t]):"transparent"===t?new Ci(NaN,NaN,NaN,0):null}function Ei(t){return new Ci(t>>16&255,t>>8&255,255&t,1)}function xi(t,e,n,r){return r<=0&&(t=e=n=NaN),new Ci(t,e,n,r)}function Ci(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Mi(){return`#${Qi(this.r)}${Qi(this.g)}${Qi(this.b)}`}function Fi(){const t=ki(this.opacity);return`${1===t?"rgb(":"rgba("}${Si(this.r)}, ${Si(this.g)}, ${Si(this.b)}${1===t?")":`, ${t})`}`}function ki(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Si(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Qi(t){return((t=Si(t))<16?"0":"")+t.toString(16)}function Ui(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Ti(t,e,n,r)}function Ni(t){if(t instanceof Ti)return new Ti(t.h,t.s,t.l,t.opacity);if(t instanceof Ai||(t=Bi(t)),!t)return new Ti;if(t instanceof Ti)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),A=NaN,s=o-i,a=(o+i)/2;return s?(A=e===o?(n-r)/s+6*(n0&&a<1?0:A,new Ti(A,s,a,t.opacity)}function Ti(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function Oi(t){return(t=(t||0)%360)<0?t+360:t}function Ii(t){return Math.max(0,Math.min(1,t||0))}function Li(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function Pi(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){for(var r=arguments.length,i=new Array(r),o=0;o=240?t-240:t+120,i,r),Li(t,i,r),Li(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Ti(Oi(this.h),Ii(this.s),Ii(this.l),ki(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ki(this.opacity);return`${1===t?"hsl(":"hsla("}${Oi(this.h)}, ${100*Ii(this.s)}%, ${100*Ii(this.l)}%${1===t?")":`, ${t})`}`}})),Pi.Cache=Map,Pi.cacheList=[],Pi.clearCache=function(){Pi.cacheList.forEach(function(t){return t.clear()})};var Di=function(t){return t[t.kUnknown=0]="kUnknown",t[t.kNumber=1]="kNumber",t[t.kPercentage=2]="kPercentage",t[t.kEms=3]="kEms",t[t.kPixels=4]="kPixels",t[t.kRems=5]="kRems",t[t.kDegrees=6]="kDegrees",t[t.kRadians=7]="kRadians",t[t.kGradians=8]="kGradians",t[t.kTurns=9]="kTurns",t[t.kMilliseconds=10]="kMilliseconds",t[t.kSeconds=11]="kSeconds",t[t.kInteger=12]="kInteger",t}({}),Ri=function(t){return t[t.kUNumber=0]="kUNumber",t[t.kUPercent=1]="kUPercent",t[t.kULength=2]="kULength",t[t.kUAngle=3]="kUAngle",t[t.kUTime=4]="kUTime",t[t.kUOther=5]="kUOther",t}({}),Hi=function(t){return t[t.kYes=0]="kYes",t[t.kNo=1]="kNo",t}({}),_i=function(t){return t[t.kYes=0]="kYes",t[t.kNo=1]="kNo",t}({}),Gi=[{name:"em",unit_type:Di.kEms},{name:"px",unit_type:Di.kPixels},{name:"deg",unit_type:Di.kDegrees},{name:"rad",unit_type:Di.kRadians},{name:"grad",unit_type:Di.kGradians},{name:"ms",unit_type:Di.kMilliseconds},{name:"s",unit_type:Di.kSeconds},{name:"rem",unit_type:Di.kRems},{name:"turn",unit_type:Di.kTurns}],Ki=function(t){return t[t.kUnknownType=0]="kUnknownType",t[t.kUnparsedType=1]="kUnparsedType",t[t.kKeywordType=2]="kKeywordType",t[t.kUnitType=3]="kUnitType",t[t.kSumType=4]="kSumType",t[t.kProductType=5]="kProductType",t[t.kNegateType=6]="kNegateType",t[t.kInvertType=7]="kInvertType",t[t.kMinType=8]="kMinType",t[t.kMaxType=9]="kMaxType",t[t.kClampType=10]="kClampType",t[t.kTransformType=11]="kTransformType",t[t.kPositionType=12]="kPositionType",t[t.kURLImageType=13]="kURLImageType",t[t.kColorType=14]="kColorType",t[t.kUnsupportedColorType=15]="kUnsupportedColorType",t}({}),ji=function(t){return t?"number"===t?Di.kNumber:"percent"===t||"%"===t?Di.kPercentage:function(t){return Gi.find(function(e){return e.name===t}).unit_type}(t):Di.kUnknown},zi=function(t){var e=1;switch(t){case Di.kPixels:case Di.kDegrees:case Di.kSeconds:break;case Di.kMilliseconds:e=.001;break;case Di.kRadians:e=180/Math.PI;break;case Di.kGradians:e=.9;break;case Di.kTurns:e=360}return e},Vi=function(t){switch(t){case Di.kNumber:case Di.kInteger:return"";case Di.kPercentage:return"%";case Di.kEms:return"em";case Di.kRems:return"rem";case Di.kPixels:return"px";case Di.kDegrees:return"deg";case Di.kRadians:return"rad";case Di.kGradians:return"grad";case Di.kMilliseconds:return"ms";case Di.kSeconds:return"s";case Di.kTurns:return"turn"}return""},Wi=function(){return a(function t(){A(this,t)},[{key:"toString",value:function(){return this.buildCSSText(Hi.kNo,_i.kNo,"")}},{key:"isNumericValue",value:function(){return this.getType()>=Ki.kUnitType&&this.getType()<=Ki.kClampType}}],[{key:"isAngle",value:function(t){return t===Di.kDegrees||t===Di.kRadians||t===Di.kGradians||t===Di.kTurns}},{key:"isLength",value:function(t){return t>=Di.kEms&&t1&&void 0!==arguments[1]?arguments[1]:Di.kNumber;return A(this,e),n=g(this,e),r="string"==typeof i?ji(i):i,n.unit=r,n.value=t,n}return v(e,t),a(e,[{key:"clone",value:function(){return new e(this.value,this.unit)}},{key:"equals",value:function(t){var e=t;return this.value===e.value&&this.unit===e.unit}},{key:"getType",value:function(){return Ki.kUnitType}},{key:"convertTo",value:function(t){if(this.unit===t)return new e(this.value,this.unit);var n=Zi(this.unit);if(n!==Zi(t)||n===Di.kUnknown)return null;var r=zi(this.unit)/zi(t);return new e(this.value*r,t)}},{key:"buildCSSText",value:function(t,e,n){var r;switch(this.unit){case Di.kUnknown:break;case Di.kInteger:r=Number(this.value).toFixed(0);break;case Di.kNumber:case Di.kPercentage:case Di.kEms:case Di.kRems:case Di.kPixels:case Di.kDegrees:case Di.kRadians:case Di.kGradians:case Di.kMilliseconds:case Di.kSeconds:case Di.kTurns:var i=this.value,o=Vi(this.unit);if(i<-999999||i>999999){var A=Vi(this.unit);r=!Number.isFinite(i)||Number.isNaN(i)?function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return(Number.isFinite(t)?"NaN":t>0?"infinity":"-infinity")+e}(i,A):i+(A||"")}else r="".concat(i).concat(o)}return n+=r}}])}(Wi),to=new Ji(0,"px");new Ji(1,"px");var eo=new Ji(0,"deg"),no=function(t){function e(t,n,r){var i,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return A(this,e),(i=g(this,e,["rgb"])).r=t,i.g=n,i.b=r,i.alpha=o,i.isNone=s,i}return v(e,t),a(e,[{key:"clone",value:function(){return new e(this.r,this.g,this.b,this.alpha)}},{key:"buildCSSText",value:function(t,e,n){return"".concat(n,"rgba(").concat(this.r,",").concat(this.g,",").concat(this.b,",").concat(this.alpha,")")}}])}(Yi),ro=new $i("unset"),io={"":ro,unset:ro,initial:new $i("initial"),inherit:new $i("inherit")},oo=new no(0,0,0,0,!0),Ao=new no(0,0,0,0),so=Pi(function(t,e,n,r){return new no(t,e,n,r)},function(t,e,n,r){return"rgba(".concat(t,",").concat(e,",").concat(n,",").concat(r,")")}),ao=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Di.kNumber;return new Ji(t,e)};function co(t){var e=t.type,n=t.value;return"hex"===e?"#".concat(n):"literal"===e?n:"rgb"===e?"rgb(".concat(n.join(","),")"):"rgba(".concat(n.join(","),")")}new Ji(50,"%");var lo=function(){var t=/^(linear\-gradient)/i,e=/^(repeating\-linear\-gradient)/i,n=/^(radial\-gradient)/i,r=/^(repeating\-radial\-gradient)/i,i=/^(conic\-gradient)/i,o=/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,A=/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,s=/^(left|center|right|top|bottom)/i,a=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,c=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,l=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,u=/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,h=/^\(/,d=/^\)/,f=/^,/,g=/^\#([0-9a-fA-F]+)/,p=/^([a-zA-Z]+)/,v=/^rgb/i,m=/^rgba/i,y=/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/,w="";function b(t){throw new Error("".concat(w,": ").concat(t))}function B(){var t=N(E);return w.length>0&&b("Invalid input not EOF"),t}function E(){return x("linear-gradient",t,M)||x("repeating-linear-gradient",e,M)||x("radial-gradient",n,F)||x("repeating-radial-gradient",r,F)||x("conic-gradient",i,F)}function x(t,e,n){return C(e,function(e){var r=n();return r&&(D(f)||b("Missing comma before color stops")),{type:t,orientation:r,colorStops:N(T)}})}function C(t,e){var n=D(t);if(n){D(h)||b("Missing (");var r=e(n);return D(d)||b("Missing )"),r}}function M(){return P("directional",o,1)||P("angular",u,1)}function F(){var t,e,n=k();return n&&((t=[]).push(n),e=w,D(f)&&((n=k())?t.push(n):w=e)),t}function k(){var t=function(){var t=P("shape",/^(circle)/i,0);t&&(t.style=L()||S());return t}()||function(){var t=P("shape",/^(ellipse)/i,0);t&&(t.style=I()||S());return t}();if(t)t.at=Q();else{var e=S();if(e){t=e;var n=Q();n&&(t.at=n)}else{var r=U();r&&(t={type:"default-radial",at:r})}}return t}function S(){return P("extent-keyword",A,1)}function Q(){if(P("position",/^at/,0)){var t=U();return t||b("Missing positioning value"),t}}function U(){var t={x:I(),y:I()};if(t.x||t.y)return{type:"position",value:t}}function N(t){var e=t(),n=[];if(e)for(n.push(e);D(f);)(e=t())?n.push(e):b("One extra comma");return n}function T(){var t=P("hex",g,1)||C(m,function(){return{type:"rgba",value:N(O)}})||C(v,function(){return{type:"rgb",value:N(O)}})||P("literal",p,0);return t||b("Expected color definition"),t.length=I(),t}function O(){return D(y)[1]}function I(){return P("%",c,1)||P("position-keyword",s,1)||L()}function L(){return P("px",a,1)||P("em",l,1)}function P(t,e,n){var r=D(e);if(r)return{type:t,value:r[n]}}function D(t){var e=/^[\n\r\t\s]+/.exec(w);e&&R(e[0].length);var n=t.exec(w);return n&&R(n[0].length),n}function R(t){w=w.substring(t)}return function(t){return w=t,B()}}();var uo=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,ho=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,fo=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,go=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;var po={left:180,top:-90,bottom:90,right:0,"left top":225,"top left":225,"left bottom":135,"bottom left":135,"right top":-45,"top right":-45,"right bottom":45,"bottom right":45},vo=Pi(function(t){var e;return e="angular"===t.type?Number(t.value):po[t.value]||0,ao(e,"deg")}),mo=Pi(function(t){var e=50,n=50,r="%",i="%";if("position"===(null==t?void 0:t.type)){var o=t.value,A=o.x,s=o.y;"position-keyword"===(null==A?void 0:A.type)&&("left"===A.value?e=0:"center"===A.value?e=50:"right"===A.value?e=100:"top"===A.value?n=0:"bottom"===A.value&&(n=100)),"position-keyword"===(null==s?void 0:s.type)&&("left"===s.value?e=0:"center"===s.value?n=50:"right"===s.value?e=100:"top"===s.value?n=0:"bottom"===s.value&&(n=100)),"px"!==(null==A?void 0:A.type)&&"%"!==(null==A?void 0:A.type)&&"em"!==(null==A?void 0:A.type)||(r=null==A?void 0:A.type,e=Number(A.value)),"px"!==(null==s?void 0:s.type)&&"%"!==(null==s?void 0:s.type)&&"em"!==(null==s?void 0:s.type)||(i=null==s?void 0:s.type,n=Number(s.value))}return{cx:ao(e,r),cy:ao(n,i)}}),yo=Pi(function(t){if(t.indexOf("linear")>-1||t.indexOf("radial")>-1)return lo(t).map(function(t){var e=t.type,n=t.orientation,r=t.colorStops;!function(t){var e,n,r=t.length;t[r-1].length=null!==(e=t[r-1].length)&&void 0!==e?e:{type:"%",value:"100"},r>1&&(t[0].length=null!==(n=t[0].length)&&void 0!==n?n:{type:"%",value:"0"});for(var i=0,o=Number(t[0].length.value),A=1;A=0)return ao(Number(e),"px");if("deg".search(t)>=0)return ao(Number(e),"deg")}var n=[];e=e.replace(t,function(t){return n.push(t),"U".concat(t)});var r="U(".concat(t.source,")");return n.map(function(t){return ao(Number(e.replace(new RegExp("U".concat(t),"g"),"").replace(new RegExp(r,"g"),"*0")),t)})[0]}var Co=function(t){return xo(new RegExp("px","g"),t)},Mo=Pi(Co);Pi(function(t){return xo(new RegExp("%","g"),t)});var Fo=function(t){return re(t)||isFinite(Number(t))?ao(Number(t)||0,"px"):xo(new RegExp("px|%|em|rem","g"),t)},ko=Pi(Fo),So=function(t){return xo(new RegExp("deg|rad|grad|turn","g"),t)},Qo=Pi(So);function Uo(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o="",A=t.value||0,s=e.value||0,a=Zi(t.unit),c=t.convertTo(a),l=e.convertTo(a);return c&&l?(A=c.value,s=l.value,o=Vi(t.unit)):(Ji.isLength(t.unit)||Ji.isLength(e.unit))&&(A=Oo(t,i,n),s=Oo(e,i,n),o="px"),[A,s,function(t){return t+o}]}function No(t){var e=0;return t.unit===Di.kDegrees?e=t.value:t.unit===Di.kRadians?e=Tr(Number(t.value)):t.unit===Di.kTurns?e=360*Number(t.value):t.value&&(e=t.value),e}function To(t,e){var n;return Array.isArray(t)?n=t.map(function(t){return Number(t)}):Jt(t)?n=t.split(" ").map(function(t){return Number(t)}):re(t)&&(n=[t]),2===e?1===n.length?[n[0],n[0]]:[n[0],n[1]]:4===e?1===n.length?[n[0],n[0],n[0],n[0]]:2===n.length?[n[0],n[1],n[0],n[1]]:3===n.length?[n[0],n[1],n[2],n[1]]:[n[0],n[1],n[2],n[3]]:"even"===e&&n.length%2==1?[].concat(u(n),u(n)):n}function Oo(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(t.unit===Di.kPixels)return Number(t.value);if(t.unit===Di.kPercentage&&n){var i=n.nodeName===cr.GROUP?n.getLocalBounds():n.getGeometryBounds();return(r?i.min[e]:0)+t.value/100*i.halfExtents[e]*2}return 0}var Io=["blur","brightness","drop-shadow","contrast","grayscale","sepia","saturate","hue-rotate","invert"];function Lo(t){return t.toString()}var Po=function(t){return"number"==typeof t?ao(t):/^\s*[-+]?(\d*\.)?\d+\s*$/.test(t)?ao(Number(t)):ao(0)},Do=Pi(Po);function Ro(t,e){return[t,e,Lo]}function Ho(t,e){return function(n,r){return[n,r,function(n){return Lo(ne(n,t,e))}]}}function _o(t,e){if(t.length===e.length)return[t,e,function(t){return t}]}function Go(t){var e;return 0===t.parsedStyle.d.totalLength&&(t.parsedStyle.d.totalLength=xn(t.parsedStyle.d.absolutePath,void 0,Le(Le({},e),{bbox:!1,length:!0})).length),t.parsedStyle.d.totalLength}function Ko(t,e){return t[0]===e[0]&&t[1]===e[1]}function jo(t,e){var n=t.prePoint,r=t.currentPoint,i=t.nextPoint,o=Math.pow(r[0]-n[0],2)+Math.pow(r[1]-n[1],2),A=Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2),s=Math.pow(n[0]-i[0],2)+Math.pow(n[1]-i[1],2),a=Math.acos((o+A-s)/(2*Math.sqrt(o)*Math.sqrt(A)));if(!a||0===Math.sin(a)||ie(a,0))return{xExtra:0,yExtra:0};var c=Math.abs(Math.atan2(i[1]-r[1],i[0]-r[0])),l=Math.abs(Math.atan2(i[0]-r[0],i[1]-r[1]));return c=c>Math.PI/2?Math.PI-c:c,l=l>Math.PI/2?Math.PI-l:l,{xExtra:Math.cos(a/2-c)*(e/2*(1/Math.sin(a/2)))-e/2||0,yExtra:Math.cos(l-a/2)*(e/2*(1/Math.sin(a/2)))-e/2||0}}function zo(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}Pi(function(t){return Jt(t)?t.split(" ").map(Do):t.map(Do)});var Vo=function(t,e){var n=t.x*e.x+t.y*e.y,r=Math.sqrt((Math.pow(t.x,2)+Math.pow(t.y,2))*(Math.pow(e.x,2)+Math.pow(e.y,2)));return(t.x*e.y-t.y*e.x<0?-1:1)*Math.acos(n/r)},Wo=function(t,e,n,r,i,o,A,s){e=Math.abs(e),n=Math.abs(n);var a=Ur(r=se(r,360));if(t.x===A.x&&t.y===A.y)return{x:t.x,y:t.y,ellipticalArcAngle:0};if(0===e||0===n)return{x:0,y:0,ellipticalArcAngle:0};var c=(t.x-A.x)/2,l=(t.y-A.y)/2,u={x:Math.cos(a)*c+Math.sin(a)*l,y:-Math.sin(a)*c+Math.cos(a)*l},h=Math.pow(u.x,2)/Math.pow(e,2)+Math.pow(u.y,2)/Math.pow(n,2);h>1&&(e*=Math.sqrt(h),n*=Math.sqrt(h));var d=(Math.pow(e,2)*Math.pow(n,2)-Math.pow(e,2)*Math.pow(u.y,2)-Math.pow(n,2)*Math.pow(u.x,2))/(Math.pow(e,2)*Math.pow(u.y,2)+Math.pow(n,2)*Math.pow(u.x,2));d=d<0?0:d;var f=(i!==o?1:-1)*Math.sqrt(d),g=f*(e*u.y/n),p=f*(-n*u.x/e),v={x:Math.cos(a)*g-Math.sin(a)*p+(t.x+A.x)/2,y:Math.sin(a)*g+Math.cos(a)*p+(t.y+A.y)/2},m={x:(u.x-g)/e,y:(u.y-p)/n},y=Vo({x:1,y:0},m),w=Vo(m,{x:(-u.x-g)/e,y:(-u.y-p)/n});!o&&w>0?w-=2*Math.PI:o&&w<0&&(w+=2*Math.PI);var b=y+(w%=2*Math.PI)*s,B=e*Math.cos(b),E=n*Math.sin(b);return{x:Math.cos(a)*B-Math.sin(a)*E+v.x,y:Math.sin(a)*B+Math.cos(a)*E+v.y,ellipticalArcStartAngle:y,ellipticalArcEndAngle:y+w,ellipticalArcAngle:b,ellipticalArcCenter:v,resultantRx:e,resultantRy:n}};function Yo(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=t.arcParams,i=r.rx,o=void 0===i?0:i,A=r.ry,s=void 0===A?0:A,a=r.xRotation,c=r.arcFlag,l=r.sweepFlag,u=Wo({x:t.prePoint[0],y:t.prePoint[1]},o,s,a,!!c,!!l,{x:t.currentPoint[0],y:t.currentPoint[1]},e),h=Wo({x:t.prePoint[0],y:t.prePoint[1]},o,s,a,!!c,!!l,{x:t.currentPoint[0],y:t.currentPoint[1]},n?e+.005:e-.005),d=h.x-u.x,f=h.y-u.y,g=Math.sqrt(d*d+f*f);return{x:-d/g,y:-f/g}}function Xo(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function qo(t,e){return Xo(t)*Xo(e)?(t[0]*e[0]+t[1]*e[1])/(Xo(t)*Xo(e)):1}function $o(t,e){return(t[0]*e[1]1&&(n*=Math.sqrt(d),r*=Math.sqrt(d));var f=n*n*(h*h)+r*r*(u*u),g=f?Math.sqrt((n*n*(r*r)-f)/f):1;o===A&&(g*=-1),isNaN(g)&&(g=0);var p=r?g*n*h/r:0,v=n?g*-r*u/n:0,m=(s+c)/2+Math.cos(i)*p-Math.sin(i)*v,y=(a+l)/2+Math.sin(i)*p+Math.cos(i)*v,w=[(u-p)/n,(h-v)/r],b=[(-1*u-p)/n,(-1*h-v)/r],B=$o([1,0],w),E=$o(w,b);return qo(w,b)<=-1&&(E=Math.PI),qo(w,b)>=1&&(E=0),0===A&&E>0&&(E-=2*Math.PI),1===A&&E<0&&(E+=2*Math.PI),{cx:m,cy:y,rx:Ko(t,[c,l])?0:n,ry:Ko(t,[c,l])?0:r,startAngle:B,endAngle:B+E,xRotation:i,arcFlag:o,sweepFlag:A}}var Jo=function(t){if(""===t||Array.isArray(t)&&0===t.length)return{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:{x:0,y:0,width:0,height:0}};var e;try{e=an(t)}catch(n){e=an(""),console.error("[g]: Invalid SVG Path definition: ".concat(t))}!function(t){for(var e=0;e0&&n.push(r),{polygons:e,polylines:n}}(e),i=r.polygons,o=r.polylines,A=function(t){for(var e=[],n=null,r=null,i=null,o=0,A=t.length,s=0;s_r[1][2]&&(o[0]=-o[0]),_r[0][2]>_r[2][0]&&(o[1]=-o[1]),_r[1][0]>_r[0][1]&&(o[2]=-o[2])}(function(t){return 0===t.length?[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]:t.map(hA).reduce(dA)}(t),e,n,r,i,o),[[e,n,r,o,i]]}var gA=function(){function t(t,e){for(var n=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],r=0;r<4;r++)for(var i=0;i<4;i++)for(var o=0;o<4;o++)n[r][i]+=e[r][o]*t[o][i];return n}return function(e,n,r,i,o){for(var A=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],s=0;s<4;s++)A[s][3]=o[s];for(var a=0;a<3;a++)for(var c=0;c<3;c++)A[3][a]+=e[c]*A[c][a];var l=i[0],u=i[1],h=i[2],d=i[3],f=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];f[0][0]=1-2*(u*u+h*h),f[0][1]=2*(l*u-h*d),f[0][2]=2*(l*h+u*d),f[1][0]=2*(l*u+h*d),f[1][1]=1-2*(l*l+h*h),f[1][2]=2*(u*h-l*d),f[2][0]=2*(l*h-u*d),f[2][1]=2*(u*h+l*d),f[2][2]=1-2*(l*l+u*u),A=t(A,f);var g=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];r[2]&&(g[2][1]=r[2],A=t(A,g)),r[1]&&(g[2][1]=0,g[2][0]=r[0],A=t(A,g)),r[0]&&(g[2][0]=0,g[1][0]=r[0],A=t(A,g));for(var p=0;p<3;p++)for(var v=0;v<3;v++)A[p][v]*=n[p];return function(t){return 0===t[0][2]&&0===t[0][3]&&0===t[1][2]&&0===t[1][3]&&0===t[2][0]&&0===t[2][1]&&1===t[2][2]&&0===t[2][3]&&0===t[3][2]&&1===t[3][3]}(A)?[A[0][0],A[0][1],A[1][0],A[1][1],A[3][0],A[3][1]]:A[0].concat(A[1],A[2],A[3])}}();function pA(t){return t.toFixed(6).replace(".000000","")}function vA(t,e){var n,r;return t.decompositionPair!==e&&(t.decompositionPair=e,n=fA(t)),e.decompositionPair!==t&&(e.decompositionPair=t,r=fA(e)),null===n[0]||null===r[0]?[[!1],[!0],function(n){return n?e[0].d:t[0].d}]:(n[0].push(0),r[0].push(1),[n,r,function(t){var e=function(t,e,n){var r=function(t,e){for(var n=0,r=0;r2&&void 0!==arguments[2]?arguments[2]:{forceUpdateGeometry:!1};Object.assign(t.attributes,e);var r=t.parsedStyle.clipPath,i=t.parsedStyle.offsetPath;!function(t,e){var n=kA(t);for(var r in e)n.has(r)&&(t.parsedStyle[r]=e[r])}(t,e);var A=!!n.forceUpdateGeometry;if(!A)for(var s in e)if(CA.has(s)){A=!0;break}var a,c,l=kA(t);l.has("fill")&&e.fill&&(t.parsedStyle.fill=Bo(e.fill)),l.has("stroke")&&e.stroke&&(t.parsedStyle.stroke=Bo(e.stroke)),l.has("shadowColor")&&e.shadowColor&&(t.parsedStyle.shadowColor=Bo(e.shadowColor)),l.has("filter")&&e.filter&&(t.parsedStyle.filter=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";if("none"===(t=t.toLowerCase().trim()))return[];for(var e,n=/\s*([\w-]+)\(([^)]*)\)/g,r=[],i=0;e=n.exec(t);){if(e.index!==i)return[];if(i=e.index+e[0].length,Io.indexOf(e[1])>-1&&r.push({name:e[1],params:e[2].split(" ").map(function(t){return xo(/deg|rad|grad|turn|px|%/g,t)||Bo(t)})}),n.lastIndex===t.length)return r}return[]}(e.filter)),l.has("radius")&&!Kt(e.radius)&&(t.parsedStyle.radius=To(e.radius,4)),l.has("lineDash")&&!Kt(e.lineDash)&&(t.parsedStyle.lineDash=To(e.lineDash,"even")),l.has("points")&&e.points&&(t.parsedStyle.points=(a=e.points,c=Jt(a)?a.split(" ").map(function(t){var e=m(t.split(","),2),n=e[0],r=e[1];return[Number(n),Number(r)]}):a,{points:c,totalLength:0,segments:[]})),l.has("d")&&""===e.d&&(t.parsedStyle.d=o({},ni)),l.has("d")&&e.d&&(t.parsedStyle.d=eA(e.d)),l.has("textTransform")&&e.textTransform&&this.runtime.CSSPropertySyntaxFactory[ri.TEXT_TRANSFORM].calculator(null,null,{value:e.textTransform},t,null),l.has("clipPath")&&!de(e.clipPath)&&this.runtime.CSSPropertySyntaxFactory[ri.DEFINED_PATH].calculator("clipPath",r,e.clipPath,t,this.runtime),l.has("offsetPath")&&e.offsetPath&&this.runtime.CSSPropertySyntaxFactory[ri.DEFINED_PATH].calculator("offsetPath",i,e.offsetPath,t,this.runtime),l.has("transform")&&e.transform&&(t.parsedStyle.transform=lA(e.transform)),l.has("transformOrigin")&&e.transformOrigin&&(t.parsedStyle.transformOrigin=BA(e.transformOrigin)),l.has("markerStart")&&e.markerStart&&(t.parsedStyle.markerStart=this.runtime.CSSPropertySyntaxFactory[ri.MARKER].calculator(null,e.markerStart,e.markerStart,null,null)),l.has("markerEnd")&&e.markerEnd&&(t.parsedStyle.markerEnd=this.runtime.CSSPropertySyntaxFactory[ri.MARKER].calculator(null,e.markerEnd,e.markerEnd,null,null)),l.has("markerMid")&&e.markerMid&&(t.parsedStyle.markerMid=this.runtime.CSSPropertySyntaxFactory[ri.MARKER].calculator("",e.markerMid,e.markerMid,null,null)),l.has("zIndex")&&!Kt(e.zIndex)&&this.runtime.CSSPropertySyntaxFactory[ri.Z_INDEX].postProcessor(t),l.has("offsetDistance")&&!Kt(e.offsetDistance)&&this.runtime.CSSPropertySyntaxFactory[ri.OFFSET_DISTANCE].postProcessor(t),l.has("transform")&&e.transform&&this.runtime.CSSPropertySyntaxFactory[ri.TRANSFORM].postProcessor(t),l.has("transformOrigin")&&e.transformOrigin&&this.runtime.CSSPropertySyntaxFactory[ri.TRANSFORM_ORIGIN].postProcessor(t),A&&(t.dirty(!0,!0),n.forceUpdateGeometry||this.runtime.sceneGraphService.dirtyToRoot(t))}},{key:"updateGeometry",value:function(t){var e=t.nodeName,n=this.runtime.geometryUpdaterFactory[e];if(n){var r=t.geometry;r.contentBounds||(r.contentBounds=new yr),r.renderBounds||(r.renderBounds=new yr);var i=t.parsedStyle,o=n.update(i,t),A=o.cx,s=void 0===A?0:A,a=o.cy,c=void 0===a?0:a,l=o.cz,u=void 0===l?0:l,h=o.hwidth,d=void 0===h?0:h,f=o.hheight,g=void 0===f?0:f,p=o.hdepth,v=void 0===p?0:p,m=[Math.abs(d),Math.abs(g),v],y=i.stroke,w=i.lineWidth,b=void 0===w?1:w,B=i.increasedLineWidthForHitTesting,E=void 0===B?0:B,x=i.shadowType,C=void 0===x?"outer":x,M=i.shadowColor,F=i.filter,k=void 0===F?[]:F,S=i.transformOrigin,Q=[s,c,u];r.contentBounds.update(Q,m);var U=e===cr.POLYLINE||e===cr.POLYGON||e===cr.PATH?Math.SQRT2:.5;if(y&&!y.isNone){var N=((b||0)+(E||0))*U;m[0]+=N,m[1]+=N}if(r.renderBounds.update(Q,m),M&&C&&"inner"!==C){var T=r.renderBounds,O=T.min,I=T.max,L=i.shadowBlur||0,P=i.shadowOffsetX||0,D=i.shadowOffsetY||0,R=O[0]-L+P,H=I[0]+L+P,_=O[1]-L+D,G=I[1]+L+D;O[0]=Math.min(O[0],R),I[0]=Math.max(I[0],H),O[1]=Math.min(O[1],_),I[1]=Math.max(I[1],G),r.renderBounds.setMinMax(O,I)}k.forEach(function(t){var e=t.name,n=t.params;if("blur"===e){var i=n[0].value;r.renderBounds.update(r.renderBounds.center,ft(r.renderBounds.halfExtents,r.renderBounds.halfExtents,[i,i,0]))}else if("drop-shadow"===e){var o=n[0].value,A=n[1].value,s=n[2].value,a=r.renderBounds,c=a.min,l=a.max,u=c[0]-s+o,h=l[0]+s+o,d=c[1]-s+A,f=l[1]+s+A;c[0]=Math.min(c[0],u),l[0]=Math.max(l[0],h),c[1]=Math.min(c[1],d),l[1]=Math.max(l[1],f),r.renderBounds.setMinMax(c,l)}}),t.geometry.dirty=!1;var K=g<0,j=(d<0?-1:1)*(S?Oo(S[0],0,t,!0):0),z=(K?-1:1)*(S?Oo(S[1],1,t,!0):0);(j||z)&&t.setOrigin(j,z)}}},{key:"updateSizeAttenuation",value:function(t,e){t.style.isSizeAttenuation?(t.style.rawLineWidth||(t.style.rawLineWidth=t.style.lineWidth),t.style.lineWidth=(t.style.rawLineWidth||1)/e,t.nodeName===cr.CIRCLE&&(t.style.rawR||(t.style.rawR=t.style.r),t.style.r=(t.style.rawR||1)/e)):(t.style.rawLineWidth&&(t.style.lineWidth=t.style.rawLineWidth,delete t.style.rawLineWidth),t.nodeName===cr.CIRCLE&&t.style.rawR&&(t.style.r=t.style.rawR,delete t.style.rawR))}}])}();function kA(t){return t.constructor.PARSED_STYLE_LIST}var SA=function(){return a(function t(){A(this,t),this.mixer=Ro},[{key:"calculator",value:function(t,e,n,r){return No(n)}}])}(),QA=function(){return a(function t(){A(this,t)},[{key:"calculator",value:function(t,e,n,r,i){return n instanceof $i&&(n=null),i.sceneGraphService.updateDisplayObjectDependency(t,e,n,r),"clipPath"===t&&r.forEach(function(t){0===t.childNodes.length&&i.sceneGraphService.dirtyToRoot(t)}),n}}])}(),UA=function(){return a(function t(){A(this,t),this.parser=Bo,this.mixer=Eo},[{key:"calculator",value:function(t,e,n,r){return n instanceof $i?"none"===n.value?oo:Ao:n}}])}(),NA=function(){return a(function t(){A(this,t)},[{key:"calculator",value:function(t,e,n){return n instanceof $i?[]:n}}])}();function TA(t){var e=t.parsedStyle.fontSize;return Kt(e)?null:e}var OA=function(){return a(function t(){A(this,t),this.mixer=Ro},[{key:"calculator",value:function(t,e,n,r,i){if(re(n))return n;if(!Ji.isRelativeUnit(n.unit))return n.value;if(n.unit===Di.kPercentage)return 0;if(n.unit===Di.kEms){if(r.parentNode){var o=TA(r.parentNode);if(o)return o*=n.value}return 0}if(n.unit===Di.kRems){var A;if(null!=r&&null!==(A=r.ownerDocument)&&void 0!==A&&A.documentElement){var s=TA(r.ownerDocument.documentElement);if(s)return s*=n.value}return 0}}}])}(),IA=function(){return a(function t(){A(this,t),this.mixer=_o},[{key:"calculator",value:function(t,e,n){return n.map(function(t){return t.value})}}])}(),LA=function(){return a(function t(){A(this,t),this.mixer=_o},[{key:"calculator",value:function(t,e,n){return n.map(function(t){return t.value})}}])}(),PA=function(){return a(function t(){A(this,t)},[{key:"calculator",value:function(t,e,n,r){var i;n instanceof $i&&(n=null);var o=null===(i=n)||void 0===i?void 0:i.cloneNode(!0);return o&&(o.style.isMarker=!0),o}}])}(),DA=function(){return a(function t(){A(this,t),this.mixer=Ro},[{key:"calculator",value:function(t,e,n){return n.value}}])}(),RA=function(){return a(function t(){A(this,t),this.mixer=Ho(0,1)},[{key:"calculator",value:function(t,e,n){return n.value}},{key:"postProcessor",value:function(t){var e=t.parsedStyle,n=e.offsetPath,r=e.offsetDistance;if(n){var i=n.nodeName;if(i===cr.LINE||i===cr.PATH||i===cr.POLYLINE){var o=n.getPoint(r);o&&t.setLocalPosition(o.x,o.y)}}}}])}(),HA=function(){return a(function t(){A(this,t),this.mixer=Ho(0,1)},[{key:"calculator",value:function(t,e,n){return n.value}}])}(),_A=function(){return a(function t(){A(this,t),this.parser=eA,this.mixer=nA},[{key:"calculator",value:function(t,e,n){return n instanceof $i&&"unset"===n.value?{absolutePath:[],hasArc:!1,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new xr(0,0,0,0)}:n}}])}(),GA=a(function t(){A(this,t),this.mixer=rA}),KA=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i0&&void 0!==arguments[0]?arguments[0]:"auto",e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=!1,i=!1,o=!!e&&!e.isNone,A=!!n&&!n.isNone;return"visiblepainted"===t||"painted"===t||"auto"===t?(r=o,i=A):"visiblefill"===t||"fill"===t?r=!0:"visiblestroke"===t||"stroke"===t?i=!0:"visible"!==t&&"all"!==t||(r=!0,i=!0),[r,i]}var ns=1,rs="object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:{},is=Date.now(),os={},As=Date.now(),ss=function(t){if("function"!=typeof t)throw new TypeError("".concat(t," is not a function"));var e=Date.now(),n=e-As,r=n>16?0:16-n,i=ns++;return os[i]=t,Object.keys(os).length>1||setTimeout(function(){As=e;var t=os;os={},Object.keys(t).forEach(function(e){return t[e](rs.performance&&"function"==typeof rs.performance.now?rs.performance.now():Date.now()-is)})},r),i},as=function(t){delete os[t]},cs=function(t){return"string"!=typeof t?ss:""===t?rs.requestAnimationFrame:rs["".concat(t,"RequestAnimationFrame")]},ls=function(t,e){for(var n=0;void 0!==t[n];){if(e(t[n]))return t[n];n+=1}}(["","webkit","moz","ms","o"],function(t){return!!cs(t)}),us=cs(ls),hs=function(t){return"string"!=typeof t?as:""===t?rs.cancelAnimationFrame:rs["".concat(t,"CancelAnimationFrame")]||rs["".concat(t,"CancelRequestAnimationFrame")]}(ls);rs.requestAnimationFrame=us,rs.cancelAnimationFrame=hs;var ds=function(){return a(function t(){A(this,t),this.callbacks=[]},[{key:"getCallbacksNum",value:function(){return this.callbacks.length}},{key:"tapPromise",value:function(t,e){this.callbacks.push(e)}},{key:"promise",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n=0;c--){var l=a[c].trim();!ms.test(l)&&vs.indexOf(l)<0&&(l='"'.concat(l,'"')),a[c]=l}return"".concat(i," ").concat(o," ").concat(A," ").concat(s," ").concat(a.join(","))},function(t){var e=ys(t),n=e.fontSize,r=e.fontFamily,i=e.fontStyle,o=e.fontVariant,A=e.fontWeight;return"".concat(i,"_").concat(o,"_").concat(A,"_").concat(n,"_").concat(r)}),bs=function(t){return Math.max(t,1e-6)};function Bs(t,e,n){return Q(t),t[4]=Math.tan(e),t[1]=Math.tan(n),t}var Es=C(),xs=C(),Cs={scale:function(t){H(Es,[t[0].value,t[1].value,1].map(function(t){return bs(t)}))},scaleX:function(t){H(Es,[t[0].value,1,1].map(function(t){return bs(t)}))},scaleY:function(t){H(Es,[1,t[0].value,1].map(function(t){return bs(t)}))},scaleZ:function(t){H(Es,[1,1,t[0].value].map(function(t){return bs(t)}))},scale3d:function(t){H(Es,[t[0].value,t[1].value,t[2].value].map(function(t){return bs(t)}))},translate:function(t){R(Es,[t[0].value,t[1].value,0])},translateX:function(t){R(Es,[t[0].value,0,0])},translateY:function(t){R(Es,[0,t[0].value,0])},translateZ:function(t){R(Es,[0,0,t[0].value])},translate3d:function(t){R(Es,[t[0].value,t[1].value,t[2].value])},rotate:function(t){j(Es,Ur(No(t[0])))},rotateX:function(t){G(Es,Ur(No(t[0])))},rotateY:function(t){K(Es,Ur(No(t[0])))},rotateZ:function(t){j(Es,Ur(No(t[0])))},rotate3d:function(t){_(Es,Ur(No(t[3])),[t[0].value,t[1].value,t[2].value])},skew:function(t){Bs(Es,Ur(t[0].value),Ur(t[1].value))},skewX:function(t){Bs(Es,Ur(t[0].value),0)},skewY:function(t){Bs(Es,0,Ur(t[0].value))},matrix:function(t){S(Es,t[0].value,t[1].value,0,0,t[2].value,t[3].value,0,0,0,0,1,0,t[4].value,t[5].value,0,1)},matrix3d:function(t){S.apply(st,[Es].concat(u(t.map(function(t){return t.value}))))}},Ms=ut(1,1,1),Fs=at(),ks={translate:function(t,e){Ua.sceneGraphService.setLocalScale(t,Ms,!1),Ua.sceneGraphService.setLocalEulerAngles(t,Fs,void 0,void 0,!1),Ua.sceneGraphService.setLocalPosition(t,[e[0].value,e[1].value,0],!1),Ua.sceneGraphService.dirtyLocalTransform(t,t.transformable)}};function Ss(t,e){if(t.length){if(1===t.length&&ks[t[0].t])return void ks[t[0].t](e,t[0].d);for(var n=Q(xs),r=0;r1&&void 0!==arguments[1]&&arguments[1];if(arguments.length>2?arguments[2]:void 0)return this.dispatchEventToSelf(t),!0;if(this.document)e=this;else if(this.defaultView)e=this.defaultView;else{var r;e=null===(r=this.ownerDocument)||void 0===r?void 0:r.defaultView}if(e){if(t.manager=e.getEventService(),!t.manager)return!1;t.defaultPrevented=!1,t.path?t.path.length=0:t.page=[],n||(t.target=this),t.manager.dispatchEvent(t,t.type,n)}else this.dispatchEventToSelf(t);return!t.defaultPrevented}}])}(),Ys=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i0&&void 0!==arguments[0]?arguments[0]:{};return this.parentNode?this.parentNode.getRootNode(t):t.composed&&this.host?this.host.getRootNode(t):this}},{key:"hasChildNodes",value:function(){return this.childNodes.length>0}},{key:"isDefaultNamespace",value:function(t){throw new Error(Cr)}},{key:"lookupNamespaceURI",value:function(t){throw new Error(Cr)}},{key:"lookupPrefix",value:function(t){throw new Error(Cr)}},{key:"normalize",value:function(){throw new Error(Cr)}},{key:"isEqualNode",value:function(t){return this===t}},{key:"isSameNode",value:function(t){return this.isEqualNode(t)}},{key:"parent",get:function(){return this.parentNode}},{key:"parentElement",get:function(){return null}},{key:"nextSibling",get:function(){return null}},{key:"previousSibling",get:function(){return null}},{key:"firstChild",get:function(){return this.childNodes.length>0?this.childNodes[0]:null}},{key:"lastChild",get:function(){return this.childNodes.length>0?this.childNodes[this.childNodes.length-1]:null}},{key:"compareDocumentPosition",value:function(t){if(t===this)return 0;for(var n=t,r=this,i=[n],o=[r];null!==(A=n.parentNode)&&void 0!==A?A:r.parentNode;){var A;n=n.parentNode?(i.push(n.parentNode),n.parentNode):n,r=r.parentNode?(o.push(r.parentNode),r.parentNode):r}if(n!==r)return e.DOCUMENT_POSITION_DISCONNECTED|e.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC|e.DOCUMENT_POSITION_PRECEDING;var s=i.length>o.length?i:o,a=s===i?o:i;if(s[s.length-a.length]===a[0])return s===i?e.DOCUMENT_POSITION_CONTAINED_BY|e.DOCUMENT_POSITION_FOLLOWING:e.DOCUMENT_POSITION_CONTAINS|e.DOCUMENT_POSITION_PRECEDING;for(var c=s.length-a.length,l=a.length-1;l>=0;l--){var u=a[l],h=s[c+l];if(h!==u){var d=u.parentNode.childNodes;return d.indexOf(u)0&&e;)e=e.parentNode,t--;return e}},{key:"forEach",value:function(t){for(var e=[this];e.length>0;){var n=e.pop();if(!1===t(n))break;for(var r=n.childNodes.length-1;r>=0;r--)e.push(n.childNodes[r])}}}],[{key:"isNode",value:function(t){return!!t.childNodes}}])}(Ws);Ys.DOCUMENT_POSITION_DISCONNECTED=1,Ys.DOCUMENT_POSITION_PRECEDING=2,Ys.DOCUMENT_POSITION_FOLLOWING=4,Ys.DOCUMENT_POSITION_CONTAINS=8,Ys.DOCUMENT_POSITION_CONTAINED_BY=16,Ys.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32;var Xs=function(){return a(function t(e,n){var r=this;A(this,t),this.nativeHTMLMap=new WeakMap,this.cursor="default",this.mappingTable={},this.mappingState={trackingData:{}},this.eventPool=new Map,this.tmpMatrix=C(),this.tmpVec3=at(),this.onPointerDown=function(t){var e=r.createPointerEvent(t);if(r.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)r.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){var n=2===e.button;r.dispatchEvent(e,n?"rightdown":"mousedown")}r.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),r.freeEvent(e)},this.onPointerUp=function(t){var e=JA.now(),n=r.createPointerEvent(t,void 0,void 0,r.context.config.alwaysTriggerPointerEventOnCanvas?r.rootTarget:void 0);if(r.dispatchEvent(n,"pointerup"),"touch"===n.pointerType)r.dispatchEvent(n,"touchend");else if("mouse"===n.pointerType||"pen"===n.pointerType){var i=2===n.button;r.dispatchEvent(n,i?"rightup":"mouseup")}var o=r.trackingData(t.pointerId),A=r.findMountedTarget(o.pressTargetsByButton[t.button]),s=A;if(A&&!n.composedPath().includes(A)){for(var a=A;a&&!n.composedPath().includes(a);){if(n.currentTarget=a,r.notifyTarget(n,"pointerupoutside"),"touch"===n.pointerType)r.notifyTarget(n,"touchendoutside");else if("mouse"===n.pointerType||"pen"===n.pointerType){var c=2===n.button;r.notifyTarget(n,c?"rightupoutside":"mouseupoutside")}Ys.isNode(a)&&(a=a.parentNode)}delete o.pressTargetsByButton[t.button],s=a}if(s){var l,u=r.clonePointerEvent(n,"click");u.target=s,u.path=[],o.clicksByButton[t.button]||(o.clicksByButton[t.button]={clickCount:0,target:u.target,timeStamp:e});var h=r.context.renderingContext.root.ownerDocument.defaultView,d=o.clicksByButton[t.button];d.target===u.target&&e-d.timeStamp=1;r--)if(t.currentTarget=n[r],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return;if(t.eventPhase=t.AT_TARGET,t.currentTarget=t.target,this.notifyTarget(t,e),!t.propagationStopped&&!t.propagationImmediatelyStopped){var i=n.indexOf(t.currentTarget);t.eventPhase=t.BUBBLING_PHASE;for(var o=i+1;oi||n>o?null:!A&&this.pickHandler(t)||this.rootTarget||null}},{key:"isNativeEventFromCanvas",value:function(t,e){var n,r=null==e?void 0:e.target;if(null!==(n=r)&&void 0!==n&&n.shadowRoot&&(r=e.composedPath()[0]),r){if(r===t)return!0;if(t&&t.contains)return t.contains(r)}return!(null==e||!e.composedPath)&&e.composedPath().indexOf(t)>-1}},{key:"getExistedHTML",value:function(t){if(t.nativeEvent.composedPath)for(var e=0,n=t.nativeEvent.composedPath();e=0;n--){var r=t[n];if(!(r===this.rootTarget||Ys.isNode(r)&&r.parentNode===e))break;e=t[n]}return e}},{key:"getCursor",value:function(t){for(var e=t;e;){var n=YA(e)&&e.getAttribute("cursor");if(n)return n;e=Ys.isNode(e)&&e.parentNode}}}])}(),qs=function(){return a(function t(){A(this,t)},[{key:"getOrCreateCanvas",value:function(t,e){if(this.canvas)return this.canvas;if(t||Ua.offscreenCanvas)this.canvas=t||Ua.offscreenCanvas,this.context=this.canvas.getContext("2d",o({willReadFrequently:!0},e));else try{this.canvas=new window.OffscreenCanvas(0,0),this.context=this.canvas.getContext("2d",o({willReadFrequently:!0},e)),this.context&&this.context.measureText||(this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"))}catch(t){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d",o({willReadFrequently:!0},e))}return this.canvas.width=10,this.canvas.height=10,this.canvas}},{key:"getOrCreateContext",value:function(t,e){return this.context||this.getOrCreateCanvas(t,e),this.context}}],[{key:"createCanvas",value:function(){try{return new window.OffscreenCanvas(0,0)}catch(t){}try{return document.createElement("canvas")}catch(t){}return null}}])}(),$s=function(t){return t[t.CAMERA_CHANGED=0]="CAMERA_CHANGED",t[t.DISPLAY_OBJECT_CHANGED=1]="DISPLAY_OBJECT_CHANGED",t[t.NONE=2]="NONE",t}({}),Zs=function(){return a(function t(e,n){A(this,t),this.inited=!1,this.stats={total:0,rendered:0},this.zIndexCounter=0,this.hooks={init:new gs,initAsync:new ds,dirtycheck:new ps,cull:new ps,beginFrame:new gs,beforeRender:new gs,render:new gs,afterRender:new gs,endFrame:new gs,destroy:new gs,pick:new fs,pickSync:new ps,pointerDown:new gs,pointerUp:new gs,pointerMove:new gs,pointerOut:new gs,pointerOver:new gs,pointerWheel:new gs,pointerCancel:new gs,click:new gs},this.globalRuntime=e,this.context=n},[{key:"init",value:function(t){var e=this,n=o(o({},this.globalRuntime),this.context);this.context.renderingPlugins.forEach(function(t){t.apply(n,e.globalRuntime)}),this.hooks.init.call(),0===this.hooks.initAsync.getCallbacksNum()?(this.inited=!0,t()):this.hooks.initAsync.promise().then(function(){e.inited=!0,t()}).catch(function(t){})}},{key:"getStats",value:function(){return this.stats}},{key:"disableDirtyRectangleRendering",value:function(){return!this.context.config.renderer.getConfig().enableDirtyRectangleRendering||this.context.renderingContext.renderReasons.has($s.CAMERA_CHANGED)}},{key:"render",value:function(t,e,n){var r=this,i=t.getConfig(),o=this.context.renderingContext;if(this.stats.total=0,this.stats.rendered=0,this.zIndexCounter=0,this.globalRuntime.sceneGraphService.syncHierarchy(o.root),this.globalRuntime.sceneGraphService.notifyMutationObservers(t),o.renderReasons.size&&this.inited){o.dirtyRectangleRenderingDisabled=this.disableDirtyRectangleRendering();var A=1===o.renderReasons.size&&o.renderReasons.has($s.CAMERA_CHANGED),s=!i.disableRenderHooks||!A;s&&this.renderDisplayObject(o.root,i,o),this.hooks.beginFrame.call(e),s&&o.renderListCurrentFrame.forEach(function(t){r.hooks.beforeRender.call(t),r.hooks.render.call(t),r.hooks.afterRender.call(t)}),this.hooks.endFrame.call(e),o.renderListCurrentFrame=[],o.renderReasons.clear(),n()}}},{key:"renderDisplayObject",value:function(t,e,n){var r=this,i=e.renderer.getConfig(),o=i.enableDirtyCheck,A=i.enableCulling;function s(t){var e=t.renderable,i=t.sortable,s=o?e.dirty||n.dirtyRectangleRenderingDisabled?t:null:t,a=null;s&&(a=A?r.hooks.cull.call(s,r.context.camera):s)&&(r.stats.rendered+=1,n.renderListCurrentFrame.push(a)),t.dirty(!1),i.renderOrder=r.zIndexCounter,r.zIndexCounter+=1,r.stats.total+=1,i.dirty&&(r.sort(t,i),i.dirty=!1,i.dirtyChildren=[],i.dirtyReason=void 0)}for(var a=[t];a.length>0;){var c,l=a.pop();s(l);for(var u=(null===(c=l.sortable)||void 0===c||null===(c=c.sorted)||void 0===c?void 0:c.length)>0?l.sortable.sorted:l.childNodes,h=u.length-1;h>=0;h--)a.push(u[h])}}},{key:"sort",value:function(t,e){var n,r;(null==e||null===(n=e.sorted)||void 0===n?void 0:n.length)>0&&e.dirtyReason!==$r.Z_INDEX_CHANGED?e.dirtyChildren.forEach(function(n){var r=e.sorted.indexOf(n);if(r>-1&&e.sorted.splice(r,1),t.childNodes.indexOf(n)>-1)if(0===e.sorted.length)e.sorted.push(n);else{var i=function(t,e){for(var n=0,r=t.length;n>>1;XA(t[i],e)<0?n=i+1:r=i}return n}(e.sorted,n);e.sorted.splice(i,0,n)}}):e.sorted=t.childNodes.slice().sort(XA),(null===(r=e.sorted)||void 0===r?void 0:r.length)>0&&0===t.childNodes.filter(function(t){return t.parsedStyle.zIndex}).length&&(e.sorted=[])}},{key:"destroy",value:function(){this.inited=!1,this.hooks.destroy.call()}},{key:"dirty",value:function(){this.context.renderingContext.renderReasons.add($s.DISPLAY_OBJECT_CHANGED)}}])}(),Js=/\[\s*(.*)=(.*)\s*\]/,ta=function(){return a(function t(){A(this,t)},[{key:"selectOne",value:function(t,e){var n=this;if(t.startsWith("."))return e.find(function(e){return((null==e?void 0:e.classList)||[]).indexOf(n.getIdOrClassname(t))>-1});if(t.startsWith("#"))return e.find(function(e){return e.id===n.getIdOrClassname(t)});if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.find(function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)}):null}return e.find(function(n){return e!==n&&n.nodeName===t})}},{key:"selectAll",value:function(t,e){var n=this;if(t.startsWith("."))return e.findAll(function(r){return e!==r&&((null==r?void 0:r.classList)||[]).indexOf(n.getIdOrClassname(t))>-1});if(t.startsWith("#"))return e.findAll(function(r){return e!==r&&r.id===n.getIdOrClassname(t)});if(t.startsWith("[")){var r=this.getAttribute(t),i=r.name,o=r.value;return i?e.findAll(function(t){return e!==t&&("name"===i?t.name===o:n.attributeToString(t,i)===o)}):[]}return e.findAll(function(n){return e!==n&&n.nodeName===t})}},{key:"is",value:function(t,e){if(t.startsWith("."))return e.className===this.getIdOrClassname(t);if(t.startsWith("#"))return e.id===this.getIdOrClassname(t);if(t.startsWith("[")){var n=this.getAttribute(t),r=n.name,i=n.value;return"name"===r?e.name===i:this.attributeToString(e,r)===i}return e.nodeName===t}},{key:"getIdOrClassname",value:function(t){return t.substring(1)}},{key:"getAttribute",value:function(t){var e=t.match(Js),n="",r="";return e&&e.length>2&&(n=e[1].replace(/"/g,""),r=e[2].replace(/"/g,"")),{name:n,value:r}}},{key:"attributeToString",value:function(t,e){if(!t.getAttribute)return"";var n=t.getAttribute(e);return Kt(n)?"":n.toString?n.toString():""}}])}(),ea=function(t){return t.ATTR_MODIFIED="DOMAttrModified",t.INSERTED="DOMNodeInserted",t.MOUNTED="DOMNodeInsertedIntoDocument",t.REMOVED="removed",t.UNMOUNTED="DOMNodeRemovedFromDocument",t.REPARENT="reparent",t.DESTROY="destroy",t.BOUNDS_CHANGED="bounds-changed",t.CULLED="culled",t}({}),na=function(t){function e(t,n,r,i,o,s,a,c){var l;return A(this,e),(l=g(this,e,[null])).relatedNode=n,l.prevValue=r,l.newValue=i,l.attrName=o,l.attrChange=s,l.prevParsedValue=a,l.newParsedValue=c,l.type=t,l}return v(e,t),a(e)}(Gs);na.ADDITION=2,na.MODIFICATION=1,na.REMOVAL=3;var ra,ia,oa,Aa=new na(ea.REPARENT,null,"","","",0,"",""),sa=Rt(),aa=at(),ca=ut(1,1,1),la=C(),ua=Rt(),ha=at(),da=C(),fa=St(),ga=at(),pa=St(),va=at(),ma=at(),ya=at(),wa=C(),ba=St(),Ba=St(),Ea=St(),xa=function(){return a(function t(e){A(this,t),this.displayObjectDependencyMap=new WeakMap,this.runtime=e},[{key:"matches",value:function(t,e){return this.runtime.sceneGraphSelector.is(t,e)}},{key:"querySelector",value:function(t,e){return this.runtime.sceneGraphSelector.selectOne(t,e)}},{key:"querySelectorAll",value:function(t,e){return this.runtime.sceneGraphSelector.selectAll(t,e)}},{key:"attach",value:function(t,e,n){var r,i=!1;t.parentNode&&(i=t.parentNode!==e,this.detach(t));var o=t.nodeName===cr.FRAGMENT,A=ts(e);t.parentNode=e;var s=o?t.childNodes:[t];re(n)?s.forEach(function(t){e.childNodes.splice(n,0,t),t.parentNode=e}):s.forEach(function(t){e.childNodes.push(t),t.parentNode=e});var a=e.sortable;if((null!=a&&null!==(r=a.sorted)&&void 0!==r&&r.length||a.dirty||t.parsedStyle.zIndex)&&(-1===a.dirtyChildren.indexOf(t)&&a.dirtyChildren.push(t),a.dirty=!0,a.dirtyReason=$r.ADDED),!A){if(o)this.dirtyFragment(t);else{var c=t.transformable;c&&this.dirtyWorldTransform(t,c)}if(i){var l,u=!0===(null===(l=e.ownerDocument)||void 0===l||null===(l=l.defaultView)||void 0===l||null===(l=l.getConfig())||void 0===l||null===(l=l.future)||void 0===l?void 0:l.experimentalCancelEventPropagation);t.dispatchEvent(Aa,u,u)}}}},{key:"detach",value:function(t){var e,n;if(t.parentNode){var r=t.transformable,i=t.parentNode.sortable;(null!=i&&null!==(e=i.sorted)&&void 0!==e&&e.length||null!==(n=t.style)&&void 0!==n&&n.zIndex)&&(-1===i.dirtyChildren.indexOf(t)&&i.dirtyChildren.push(t),i.dirty=!0,i.dirtyReason=$r.REMOVED);var o=t.parentNode.childNodes.indexOf(t);o>-1&&t.parentNode.childNodes.splice(o,1),r&&this.dirtyWorldTransform(t,r),t.parentNode=null}}},{key:"getLocalPosition",value:function(t){return t.transformable.localPosition}},{key:"getLocalRotation",value:function(t){return t.transformable.localRotation}},{key:"getLocalScale",value:function(t){return t.transformable.localScale}},{key:"getLocalSkew",value:function(t){return t.transformable.localSkew}},{key:"getLocalTransform",value:function(t){var e=t.transformable;return ei(e),e.localTransform}},{key:"setLocalPosition",value:function(t,e){var n,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=t.transformable;ma[0]=e[0],ma[1]=e[1],ma[2]=null!==(n=e[2])&&void 0!==n?n:0,Bt(i.localPosition,ma)||(ht(i.localPosition,ma),r&&this.dirtyLocalTransform(t,i))}},{key:"translateLocal",value:function(t,e){"number"==typeof e&&(e=ut(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:0));var n=t.transformable;Bt(e,aa)||(!function(t,e,n){var r=n[0],i=n[1],o=n[2],A=n[3],s=e[0],a=e[1],c=e[2],l=i*c-o*a,u=o*s-r*c,h=r*a-i*s;l+=l,u+=u,h+=h,t[0]=s+A*l+i*h-o*u,t[1]=a+A*u+o*l-r*h,t[2]=c+A*h+r*u-i*l}(e,e,n.localRotation),ft(n.localPosition,n.localPosition,e),this.dirtyLocalTransform(t,n))}},{key:"setLocalRotation",value:function(t,e,n,r,i){var o=!(arguments.length>5&&void 0!==arguments[5])||arguments[5];"number"==typeof e&&(e=Lt(fa,e,n,r,i));var A=t.transformable;It(A.localRotation,e),o&&this.dirtyLocalTransform(t,A)}},{key:"rotateLocal",value:function(t,e){"number"==typeof e&&(e=ut(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:0));var n=t.transformable;Tt(Ba,e[0],e[1],e[2]),Pt(n.localRotation,n.localRotation,Ba),this.dirtyLocalTransform(t,n)}},{key:"setLocalScale",value:function(t,e){var n,r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=t.transformable;dt(ha,e[0],e[1],null!==(n=e[2])&&void 0!==n?n:i.localScale[2]),Bt(ha,i.localScale)||(ht(i.localScale,ha),r&&this.dirtyLocalTransform(t,i))}},{key:"scaleLocal",value:function(t,e){var n,r=t.transformable;!function(t,e,n){t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2]}(r.localScale,r.localScale,dt(ha,e[0],e[1],null!==(n=e[2])&&void 0!==n?n:1)),this.dirtyLocalTransform(t,r)}},{key:"setLocalSkew",value:function(t,e,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];"number"==typeof e&&(e=function(t,e,n){return t[0]=e,t[1]=n,t}(ua,e,n));var i=t.transformable;!function(t,e){t[0]=e[0],t[1]=e[1]}(i.localSkew,e),r&&this.dirtyLocalTransform(t,i)}},{key:"setLocalEulerAngles",value:function(t,e){var n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];"number"==typeof e&&(e=ut(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:0));var r=t.transformable;Tt(r.localRotation,e[0],e[1],e[2]),n&&this.dirtyLocalTransform(t,r)}},{key:"setLocalTransform",value:function(t,e){var n=V(ga,e),r=Y(pa,e),i=W(va,e);this.setLocalScale(t,i,!1),this.setLocalPosition(t,n,!1),this.setLocalRotation(t,r,void 0,void 0,void 0,!1),this.dirtyLocalTransform(t,t.transformable)}},{key:"resetLocalTransform",value:function(t){this.setLocalScale(t,ca,!1),this.setLocalPosition(t,aa,!1),this.setLocalEulerAngles(t,aa,void 0,void 0,!1),this.setLocalSkew(t,sa,void 0,!1),this.dirtyLocalTransform(t,t.transformable)}},{key:"getPosition",value:function(t){var e=t.transformable;return V(e.position,this.getWorldTransform(t,e))}},{key:"getRotation",value:function(t){var e=t.transformable;return Y(e.rotation,this.getWorldTransform(t,e))}},{key:"getScale",value:function(t){var e=t.transformable;return W(e.scaling,this.getWorldTransform(t,e))}},{key:"getOrigin",value:function(t){return t.getGeometryBounds(),t.transformable.origin}},{key:"getWorldTransform",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.transformable;return e.localDirtyFlag||e.dirtyFlag?(t.parentNode&&t.parentNode.transformable&&this.getWorldTransform(t.parentNode),this.internalUpdateTransform(t),e.worldTransform):e.worldTransform}},{key:"setPosition",value:function(t,e){var n,r=t.transformable;if(ya[0]=e[0],ya[1]=e[1],ya[2]=null!==(n=e[2])&&void 0!==n?n:0,!Bt(this.getPosition(t),ya)){if(ht(r.position,ya),null!==t.parentNode&&t.parentNode.transformable){var i=t.parentNode.transformable;F(wa,i.worldTransform),N(wa,wa),bt(r.localPosition,ya,wa)}else ht(r.localPosition,ya);this.dirtyLocalTransform(t,r)}}},{key:"translate",value:function(t,e){"number"==typeof e&&(e=dt(ha,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:0)),Bt(e,aa)||(ft(ha,this.getPosition(t),e),this.setPosition(t,ha))}},{key:"setRotation",value:function(t,e,n,r,i){var o=t.transformable;if("number"==typeof e&&(e=Ot(e,n,r,i)),null!==t.parentNode&&t.parentNode.transformable){var A=this.getRotation(t.parentNode);It(fa,A),Nt(fa,fa),Ut(o.localRotation,fa,e),Dt(o.localRotation,o.localRotation),this.dirtyLocalTransform(t,o)}else this.setLocalRotation(t,e)}},{key:"rotate",value:function(t,e){"number"==typeof e&&(e=ut(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:0));var n=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){var r=fa;Tt(r,e[0],e[1],e[2]);var i=this.getRotation(t),o=this.getRotation(t.parentNode);It(Ea,o),Nt(Ea,Ea),Ut(r,Ea,r),Ut(n.localRotation,r,i),Dt(n.localRotation,n.localRotation),this.dirtyLocalTransform(t,n)}else this.rotateLocal(t,e)}},{key:"setOrigin",value:function(t,e){"number"==typeof e&&(e=[e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:0]);var n=t.transformable;if(e[0]!==n.origin[0]||e[1]!==n.origin[1]||e[2]!==n.origin[2]){var r=n.origin;r[0]=e[0],r[1]=e[1],r[2]=e[2]||0,this.dirtyLocalTransform(t,n)}}},{key:"setEulerAngles",value:function(t,e){"number"==typeof e&&(e=ut(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:0));var n=t.transformable;if(null!==t.parentNode&&t.parentNode.transformable){Tt(n.localRotation,e[0],e[1],e[2]);var r=this.getRotation(t.parentNode);It(ba,Nt(fa,r)),Pt(n.localRotation,n.localRotation,ba),this.dirtyLocalTransform(t,n)}else this.setLocalEulerAngles(t,e)}},{key:"getGeometryBounds",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t.geometry;return n.dirty&&Ua.styleValueRegistry.updateGeometry(t),(e?n.renderBounds:n.contentBounds||null)||new yr}},{key:"getTransformedGeometryBounds",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=this.getGeometryBounds(t,e);if(!yr.isEmpty(r)){var i=n||new yr;return i.setFromTransformedAABB(r,this.getWorldTransform(t)),i}return null}},{key:"getBounds",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.renderable;if(!r.boundsDirty&&!n&&r.bounds)return r.bounds;if(!r.renderBoundsDirty&&n&&r.renderBounds)return r.renderBounds;var i=n?r.renderBounds:r.bounds,o=this.getTransformedGeometryBounds(t,n,i);if(t.childNodes.forEach(function(t){var r=e.getBounds(t,n);r&&(o?o.add(r):(o=i||new yr).update(r.center,r.halfExtents))}),o||(o=new yr),n){var A=qA(t);if(A){var s=A.parsedStyle.clipPath.getBounds(n);o?s&&(o=s.intersection(o)):o.update(s.center,s.halfExtents)}}return n?(r.renderBounds=o,r.renderBoundsDirty=!1):(r.bounds=o,r.boundsDirty=!1),o}},{key:"getLocalBounds",value:function(t){if(t.parentNode){var e=la;t.parentNode.transformable&&(e=N(da,this.getWorldTransform(t.parentNode)));var n=this.getBounds(t);if(!yr.isEmpty(n)){var r=new yr;return r.setFromTransformedAABB(n,e),r}}return this.getBounds(t)}},{key:"getBoundingClientRect",value:function(t){var e,n,r=this.getGeometryBounds(t);yr.isEmpty(r)||(n=new yr).setFromTransformedAABB(r,this.getWorldTransform(t));var i=null===(e=t.ownerDocument)||void 0===e||null===(e=e.defaultView)||void 0===e?void 0:e.getContextService().getBoundingClientRect();if(n){var o=m(n.getMin(),2),A=o[0],s=o[1],a=m(n.getMax(),2),c=a[0],l=a[1];return new xr(A+((null==i?void 0:i.left)||0),s+((null==i?void 0:i.top)||0),c-A,l-s)}return new xr((null==i?void 0:i.left)||0,(null==i?void 0:i.top)||0,0,0)}},{key:"internalUpdateTransform",value:function(t){var e,n=null===(e=t.parentNode)||void 0===e?void 0:e.transformable;ei(t.transformable),function(t,e){t.dirtyFlag&&(e?O(t.worldTransform,e.worldTransform,t.localTransform):F(t.worldTransform,t.localTransform),t.dirtyFlag=!1)}(t.transformable,n)}},{key:"internalUpdateElement",value:function(t,e){var n,r,i,o,A,s,a=!0===(null===(n=t.ownerDocument)||void 0===n||null===(n=n.defaultView)||void 0===n||null===(n=n.getConfig())||void 0===n||null===(n=n.future)||void 0===n?void 0:n.experimentalAttributeUpdateOptimization),c=e[e.length-1],l=(null==c?void 0:c.transformDirty)||(null===(r=t.transformable)||void 0===r?void 0:r.localDirtyFlag);t.transformable&&((A=t.transformable).dirtyFlag||(A.dirtyFlag=l));(this.internalUpdateTransform(t),l)&&(null===(s=t.dirty)||void 0===s||s.call(t,!0,!0));var u=(null===(i=t.renderable)||void 0===i?void 0:i.boundsDirty)||(null===(o=t.renderable)||void 0===o?void 0:o.renderBoundsDirty);if((l||u)&&!1===(null==c?void 0:c.shapeUpdated)&&a)for(var h=e.length-1;h>=0;){var d,f,g=e[h];if(g.shapeUpdated)break;null===(d=(f=g.node).dirty)||void 0===d||d.call(f,!0,!0),g.shapeUpdated=!0,h-=1}return l}},{key:"syncHierarchy",value:function(t){for(var e,n,r=[t],i=t.parentNode?[{node:t.parentNode,transformDirty:(null===(e=t.parentNode.transformable)||void 0===e?void 0:e.localDirtyFlag)||(null===(n=t.parentNode.transformable)||void 0===n?void 0:n.dirtyFlag),shapeUpdated:!1}]:[];r.length>0;){for(var o=r.pop(),A=i[i.length-1];i.length>0&&o.parentNode!==A.node;)A=i.pop();var s=this.internalUpdateElement(o,i);if(o.childNodes.length>0){for(var a=o.childNodes.length-1;a>=0;a--)r.push(o.childNodes[a]);i.push({node:o,transformDirty:s,shapeUpdated:!1})}}}},{key:"dirtyLocalTransform",value:function(t,e){ts(t)||e.localDirtyFlag||(e.localDirtyFlag=!0,e.dirtyFlag||this.dirtyWorldTransform(t,e))}},{key:"dirtyWorldTransform",value:function(t,e){this.dirtyWorldInternal(t,e),this.dirtyToRoot(t,!0)}},{key:"dirtyWorldInternal",value:function(t,e){var n,r=this,i=!0===(null===(n=t.ownerDocument)||void 0===n||null===(n=n.defaultView)||void 0===n||null===(n=n.getConfig())||void 0===n||null===(n=n.future)||void 0===n?void 0:n.experimentalAttributeUpdateOptimization);e.dirtyFlag||(e.dirtyFlag=!0,t.dirty(!0,!0),i||t.childNodes.forEach(function(t){var e=t.transformable;r.dirtyWorldInternal(t,e)}))}},{key:"dirtyToRoot",value:function(t){for(var e,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t,i=!0===(null===(e=t.ownerDocument)||void 0===e||null===(e=e.defaultView)||void 0===e||null===(e=e.getConfig())||void 0===e||null===(e=e.future)||void 0===e?void 0:e.experimentalAttributeUpdateOptimization);r;){var o,A;if(null===(o=(A=r).dirty)||void 0===o||o.call(A,!0,!0),i)break;r=r.parentNode}n&&t.forEach(function(t){var e;null===(e=t.dirty)||void 0===e||e.call(t,!0,!0)}),this.informDependentDisplayObjects(t);var s=t.mutations||[],a=s.find(function(t){return"attributes"===t.type&&t._boundsChangeData});a?a._boundsChangeData={affectChildren:a._boundsChangeData.affectChildren||n}:(a={type:"attributes",target:t,_boundsChangeData:{affectChildren:n}},s.push(a)),t.mutations=s}},{key:"dirtyFragment",value:function(t){var e,n,r=t.transformable;r&&(r.dirtyFlag=!0,r.localDirtyFlag=!0),null===(e=(n=t).dirty)||void 0===e||e.call(n,!0,!0);for(var i=t.childNodes.length,o=0;o0){var n=new Vs(ea.BOUNDS_CHANGED,{detail:Array.from(e)});t.dispatchEvent(n,!0,!0)}}},{key:"updateDisplayObjectDependency",value:function(t,e,n,r){if(e&&e!==n){var i=this.displayObjectDependencyMap.get(e);if(i&&i[t]){var o=i[t].indexOf(r);i[t].splice(o,1)}}if(n){var A=this.displayObjectDependencyMap.get(n);A||(this.displayObjectDependencyMap.set(n,{}),A=this.displayObjectDependencyMap.get(n)),A[t]||(A[t]=[]),A[t].push(r)}}},{key:"informDependentDisplayObjects",value:function(t){var e,n=this,r=this.displayObjectDependencyMap.get(t);if(r){var i=null===(e=t.ownerDocument)||void 0===e||null===(e=e.defaultView)||void 0===e||null===(e=e.getConfig())||void 0===e||null===(e=e.future)||void 0===e?void 0:e.experimentalCancelEventPropagation;Object.keys(r).forEach(function(t){r[t].forEach(function(e){n.dirtyToRoot(e,!0),e.dispatchEvent(new na(ea.ATTR_MODIFIED,e,n,n,t,na.MODIFICATION,n,n),i,i),e.isCustomElement&&e.isConnected&&e.attributeChangedCallback&&e.attributeChangedCallback(t,n,n)})})}}}])}(),Ca=function(){return a(function t(e){if(A(this,t),e<=0)throw new Error("LRU capacity must be a positive number.");this.capacity=e,this.cache=new Map},[{key:"get",value:function(t){if(this.cache.has(t)){var e=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,e),e}}},{key:"put",value:function(t,e){if(this.cache.has(t)&&this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.capacity){var n=this.cache.keys().next().value;this.cache.delete(n)}}},{key:"len",value:function(){return this.cache.size}},{key:"clear",value:function(){this.cache.clear()}}])}(),Ma={MetricsString:"|ÉqÅ",BaselineSymbol:"M",BaselineMultiplier:1.4,HeightMultiplier:2,Newlines:[10,13],BreakingSpaces:[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288]},Fa=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/,ka=new RegExp("".concat(/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/.source,"|").concat(/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹓﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/.source,"|").concat(/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/.source,"|").concat(/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/.source)),Sa=new RegExp("".concat(/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/.source,"|").concat(/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/.source,"|").concat(/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/.source,"|").concat(/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/.source)),Qa=function(){return a(function t(e){var n=this;A(this,t),this.fontMetricsCache={},this.shouldBreakByKinsokuShorui=function(t,e){return!n.isBreakingSpace(e)&&!(!t||!Sa.exec(e)&&!ka.exec(t))},this.trimByKinsokuShorui=function(t){var e=u(t),n=e[e.length-2];if(!n)return t;var r=n[n.length-1];return e[e.length-2]=n.slice(0,-1),e[e.length-1]=r+e[e.length-1],e},this.runtime=e,this.charWidthCache=new Ca(100)},[{key:"measureFont",value:function(t,e){if(this.fontMetricsCache[t])return this.fontMetricsCache[t];var n={ascent:0,descent:0,fontSize:0},r=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(e),i=this.runtime.offscreenCanvasCreator.getOrCreateContext(e,{willReadFrequently:!0});i.font=t;var o=Ma.MetricsString+Ma.BaselineSymbol,A=Math.ceil(i.measureText(o).width),s=Math.ceil(i.measureText(Ma.BaselineSymbol).width),a=Ma.HeightMultiplier*s;s=s*Ma.BaselineMultiplier|0,r.width=A,r.height=a,i.fillStyle="#f00",i.fillRect(0,0,A,a),i.font=t,i.textBaseline="alphabetic",i.fillStyle="#000",i.fillText(o,0,s);var c=i.getImageData(0,0,A||1,a||1).data,l=c.length,u=4*A,h=0,d=0,f=!1;for(h=0;hs;--h){for(var p=0;pr&&e>=n;)e-=1,t=t.slice(0,-1);return{lineTxt:t,txtLastCharIndex:e}}function C(t,e){if(!(E<=0||E>f))if(p[t]){var n=x(p[t],e,y+1,f-E);p[t]=n.lineTxt+g}else p[t]=g}for(var M=0;M=u){Mf){C(v,M-1),e.isOverflowing=!0;break}if(m>0&&m+Q>f){var U=x(p[v],M-1,y+1,f);if(U.txtLastCharIndex!==M-1){if(p[v]=U.lineTxt,U.txtLastCharIndex===i.length-1)break;M=U.txtLastCharIndex+1,F=i[M],k=i[M-1],S=i[M+1],Q=B(F)}if(v+1>=u){C(v,M-1),e.isOverflowing=!0;break}if(y=M-1,m=0,p[v+=1]="",this.isBreakingSpace(F))continue;this.canBreakInLastChar(F)||(p=this.trimToBreakable(p),m=this.sumTextWidthByCache(p[v]||"",B)),this.shouldBreakByKinsokuShorui(F,S)&&(p=this.trimByKinsokuShorui(p),m+=B(k||""))}m+=Q,p[v]+=F}}return p.join("\n")}},{key:"isBreakingSpace",value:function(t){return"string"==typeof t&&Ma.BreakingSpaces.indexOf(t.charCodeAt(0))>=0}},{key:"isNewline",value:function(t){return"string"==typeof t&&Ma.Newlines.indexOf(t.charCodeAt(0))>=0}},{key:"trimToBreakable",value:function(t){var e=u(t),n=e[e.length-2],r=this.findBreakableIndex(n);if(-1===r||!n)return e;var i=n.slice(r,r+1),o=r+1,A=r+(this.isBreakingSpace(i)?0:1);return e[e.length-1]+=n.slice(o,n.length),e[e.length-2]=n.slice(0,A),e}},{key:"canBreakInLastChar",value:function(t){return!t||!Fa.test(t)}},{key:"sumTextWidthByCache",value:function(t,e){return t.split("").reduce(function(t,n){return t+e(n)},0)}},{key:"findBreakableIndex",value:function(t){for(var e=t.length-1;e>=0;e--)if(!Fa.test(t[e]))return e;return-1}},{key:"getFromCache",value:function(t,e,n,r){var i=n.get(t);if("number"!=typeof i){var o=t.length*e;i=r.measureText(t).width+o,n.put(t,i)}return i}},{key:"clearCache",value:function(){this.fontMetricsCache={},this.charWidthCache.clear()}}])}(),Ua={},Na=(ia=new Ds,oa=new Ps,r(r(r(r(r(r(r(r(r(r(ra={},cr.FRAGMENT,null),cr.CIRCLE,new Ts),cr.ELLIPSE,new Os),cr.RECT,ia),cr.IMAGE,ia),cr.GROUP,new Hs),cr.LINE,new Is),cr.TEXT,new Rs(Ua)),cr.POLYLINE,oa),cr.POLYGON,oa),r(r(r(ra,cr.PATH,new Ls),cr.HTML,new _s),cr.MESH,null)),Ta=function(t){var e=new UA,n=new OA;return r(r(r(r(r(r(r(r(r(r(t={},ri.PERCENTAGE,null),ri.NUMBER,new DA),ri.ANGLE,new SA),ri.DEFINED_PATH,new QA),ri.PAINT,e),ri.COLOR,e),ri.FILTER,new NA),ri.LENGTH,n),ri.LENGTH_PERCENTAGE,n),ri.LENGTH_PERCENTAGE_12,new IA),r(r(r(r(r(r(r(r(r(r(t,ri.LENGTH_PERCENTAGE_14,new LA),ri.COORDINATE,new OA),ri.OFFSET_DISTANCE,new RA),ri.OPACITY_VALUE,new HA),ri.PATH,new _A),ri.LIST_OF_POINTS,new GA),ri.SHADOW_BLUR,new KA),ri.TEXT,new jA),ri.TEXT_TRANSFORM,new zA),ri.TRANSFORM,new Qs),r(r(r(t,ri.TRANSFORM_ORIGIN,new Us),ri.Z_INDEX,new Ns),ri.MARKER,new PA)}();Ua.CameraContribution=Xr,Ua.AnimationTimeline=null,Ua.EasingFunction=null,Ua.offscreenCanvasCreator=new qs,Ua.sceneGraphSelector=new ta,Ua.sceneGraphService=new xa(Ua),Ua.textService=new Qa(Ua),Ua.geometryUpdaterFactory=Na,Ua.CSSPropertySyntaxFactory=Ta,Ua.styleValueRegistry=new FA(Ua),Ua.layoutRegistry=null,Ua.globalThis="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Ua.enableStyleSyntax=!0,Ua.enableSizeAttenuation=!1;var Oa=0,Ia=new na(ea.INSERTED,null,"","","",0,"",""),La=new na(ea.REMOVED,null,"","","",0,"",""),Pa=new Vs(ea.DESTROY),Da=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i0&&void 0!==arguments[0])||arguments[0],e=arguments.length>1?arguments[1]:void 0;this.renderable.dirty=t,void 0!==e&&(this.renderable.boundsDirty=e,this.renderable.renderBoundsDirty=e,this.geometry.dirty=e)}},{key:"className",get:function(){return this.getAttribute("class")||""},set:function(t){this.setAttribute("class",t)}},{key:"classList",get:function(){return this.className.split(" ").filter(function(t){return""!==t})}},{key:"tagName",get:function(){return this.nodeName}},{key:"children",get:function(){return this.childNodes}},{key:"childElementCount",get:function(){return this.childNodes.length}},{key:"firstElementChild",get:function(){return this.firstChild}},{key:"lastElementChild",get:function(){return this.lastChild}},{key:"parentElement",get:function(){return this.parentNode}},{key:"nextSibling",get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t+1]||null}return null}},{key:"previousSibling",get:function(){if(this.parentNode){var t=this.parentNode.childNodes.indexOf(this);return this.parentNode.childNodes[t-1]||null}return null}},{key:"cloneNode",value:function(t){throw new Error(Cr)}},{key:"appendChild",value:function(t,e){var n;if(t.destroyed)throw new Error("Cannot append a destroyed element.");return Ua.sceneGraphService.attach(t,this,e),null!==(n=this.ownerDocument)&&void 0!==n&&n.defaultView&&(ts(this)||t.nodeName!==cr.FRAGMENT?this.ownerDocument.defaultView.mountChildren(t):this.ownerDocument.defaultView.mountFragment(t)),this.isMutationObserved&&(Ia.relatedNode=this,t.dispatchEvent(Ia)),t}},{key:"insertBefore",value:function(t,e){if(e){t.parentElement&&t.parentElement.removeChild(t);var n=this.childNodes.indexOf(e);-1===n?this.appendChild(t):this.appendChild(t,n)}else this.appendChild(t);return t}},{key:"replaceChild",value:function(t,e){var n=this.childNodes.indexOf(e);return this.removeChild(e),this.appendChild(t,n),e}},{key:"removeChild",value:function(t){var e,n,r=!0===(null===(e=this.ownerDocument)||void 0===e||null===(e=e.defaultView)||void 0===e||null===(e=e.getConfig().future)||void 0===e?void 0:e.experimentalCancelEventPropagation);return La.relatedNode=this,t.dispatchEvent(La,r,r),null!==(n=t.ownerDocument)&&void 0!==n&&n.defaultView&&t.ownerDocument.defaultView.unmountChildren(t),Ua.sceneGraphService.detach(t),t}},{key:"removeChildren",value:function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];this.removeChild(e)}}},{key:"destroyChildren",value:function(){for(var t=this.childNodes.length-1;t>=0;t--){var e=this.childNodes[t];e.childNodes.length>0&&e.destroyChildren(),e.destroy()}}},{key:"matches",value:function(t){return Ua.sceneGraphService.matches(t,this)}},{key:"getElementById",value:function(t){return Ua.sceneGraphService.querySelector("#".concat(t),this)}},{key:"getElementsByName",value:function(t){return Ua.sceneGraphService.querySelectorAll('[name="'.concat(t,'"]'),this)}},{key:"getElementsByClassName",value:function(t){return Ua.sceneGraphService.querySelectorAll(".".concat(t),this)}},{key:"getElementsByTagName",value:function(t){return Ua.sceneGraphService.querySelectorAll(t,this)}},{key:"querySelector",value:function(t){return Ua.sceneGraphService.querySelector(t,this)}},{key:"querySelectorAll",value:function(t){return Ua.sceneGraphService.querySelectorAll(t,this)}},{key:"closest",value:function(t){var e=this;do{if(Ua.sceneGraphService.matches(t,e))return e;e=e.parentElement}while(null!==e);return null}},{key:"find",value:function(t){var e=this,n=null;return this.forEach(function(r){return r===e||!t(r)||(n=r,!1)}),n}},{key:"findAll",value:function(t){var e=this,n=[];return this.forEach(function(r){r!==e&&t(r)&&n.push(r)}),n}},{key:"after",value:function(){var t=this;if(this.parentNode){for(var e=this.parentNode.childNodes.indexOf(this),n=arguments.length,r=new Array(n),i=0;i0&&void 0!==arguments[0]&&arguments[0];return Ua.sceneGraphService.getGeometryBounds(this,t)}},{key:"getTransformedGeometryBounds",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Ua.sceneGraphService.getTransformedGeometryBounds(this,t)}},{key:"getBounds",value:function(){return Ua.sceneGraphService.getBounds(this)}},{key:"getRenderBounds",value:function(){return Ua.sceneGraphService.getBounds(this,!0)}},{key:"getLocalBounds",value:function(){return Ua.sceneGraphService.getLocalBounds(this)}},{key:"getBoundingClientRect",value:function(){return Ua.sceneGraphService.getBoundingClientRect(this)}},{key:"getClientRects",value:function(){return[this.getBoundingClientRect()]}},{key:"computedStyleMap",value:function(){return new Map(Object.entries(this.computedStyle))}},{key:"getAttributeNames",value:function(){return Object.keys(this.attributes)}},{key:"getAttribute",value:function(t){if("symbol"!=typeof t){var e=this.attributes[t];return e}}},{key:"hasAttribute",value:function(t){return this.getAttributeNames().includes(t)}},{key:"hasAttributes",value:function(){return!!this.getAttributeNames().length}},{key:"removeAttribute",value:function(t){this.setAttribute(t,null),delete this.attributes[t]}},{key:"setAttribute",value:function(t,e){this.attributes[t]=e}},{key:"getAttributeNS",value:function(t,e){throw new Error(Cr)}},{key:"getAttributeNode",value:function(t){throw new Error(Cr)}},{key:"getAttributeNodeNS",value:function(t,e){throw new Error(Cr)}},{key:"hasAttributeNS",value:function(t,e){throw new Error(Cr)}},{key:"removeAttributeNS",value:function(t,e){throw new Error(Cr)}},{key:"removeAttributeNode",value:function(t){throw new Error(Cr)}},{key:"setAttributeNS",value:function(t,e,n){throw new Error(Cr)}},{key:"setAttributeNode",value:function(t){throw new Error(Cr)}},{key:"setAttributeNodeNS",value:function(t){throw new Error(Cr)}},{key:"toggleAttribute",value:function(t,e){throw new Error(Cr)}}])}(Ys);function Ra(t){return!(null==t||!t.nodeName)}var Ha=Ua.globalThis.Proxy?Ua.globalThis.Proxy:function(){},_a=new na(ea.ATTR_MODIFIED,null,null,null,null,na.MODIFICATION,null,null),Ga=at(),Ka=St(),ja=function(t){function e(t){var n;return A(this,e),(n=g(this,e)).isCustomElement=!1,n.isMutationObserved=!1,n.activeAnimations=[],n.config=t,n.id=t.id||"",n.name=t.name||"",(t.className||t.class)&&(n.className=t.className||t.class),n.nodeName=t.type||cr.GROUP,t.initialParsedStyle&&Object.assign(n.parsedStyle,t.initialParsedStyle),n.initAttributes(t.style),Ua.enableStyleSyntax&&(n.style=new Ha({setProperty:function(t,e){n.setAttribute(t,e)},getPropertyValue:function(t){return n.getAttribute(t)},removeProperty:function(t){n.removeAttribute(t)},item:function(){return""}},{get:function(t,e){return void 0!==t[e]?t[e]:n.getAttribute(e)},set:function(t,e,r){return n.setAttribute(e,r),!0}})),n}return v(e,t),a(e,[{key:"destroy",value:function(){Un(e,"destroy",this)([]),this.getAnimations().forEach(function(t){t.cancel()})}},{key:"cloneNode",value:function(t,e){var n=o({},this.attributes);for(var r in n){var i=n[r];Ra(i)&&"clipPath"!==r&&"offsetPath"!==r&&"textPath"!==r&&(n[r]=i.cloneNode(t)),e&&(n[r]=e(r,i))}var A=new this.constructor(o(o({},this.config),{},{style:n}));return A.setLocalTransform(this.getLocalTransform()),t&&this.children.forEach(function(e){if(!e.style.isMarker){var n=e.cloneNode(t);A.appendChild(n)}}),A}},{key:"initAttributes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ua.styleValueRegistry.processProperties(this,t,{forceUpdateGeometry:!0}),this.dirty()}},{key:"setAttribute",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];de(n)||(r||n!==this.attributes[t])&&(this.internalSetAttribute(t,n,{memoize:i}),Un(e,"setAttribute",this)([t,n]))}},{key:"setAttributes",value:function(t){var e,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=r.skipDispatchAttrModifiedEvent,A=void 0!==i&&i;if(A||(e=o({},this.attributes),n=o({},this.parsedStyle)),Ua.styleValueRegistry.processProperties(this,t,r),this.dirty(),!A)for(var s in t)this.dispatchAttrModifiedEvent(s,e[s],t[s],n[s])}},{key:"internalSetAttribute",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.attributes[t],o=this.parsedStyle[t];Ua.styleValueRegistry.processProperties(this,r({},t,e),n),this.dirty(),this.dispatchAttrModifiedEvent(t,i,e,o)}},{key:"dispatchAttrModifiedEvent",value:function(t,e,n,r){var i,o=this.parsedStyle[t];if(this.isConnected)if(_a.relatedNode=this,_a.prevValue=e,_a.newValue=n,_a.attrName=t,_a.prevParsedValue=r,_a.newParsedValue=o,this.isMutationObserved)this.dispatchEvent(_a);else{var A,s=!0===(null===(A=this.ownerDocument.defaultView.getConfig().future)||void 0===A?void 0:A.experimentalCancelEventPropagation);_a.target=this,this.ownerDocument.defaultView.dispatchEvent(_a,!0,s)}(this.isCustomElement&&this.isConnected||!this.isCustomElement)&&(null===(i=this.attributeChangedCallback)||void 0===i||i.call(this,t,e,n,r,o))}},{key:"getBBox",value:function(){var t=this.getBounds(),e=m(t.getMin(),2),n=e[0],r=e[1],i=m(t.getMax(),2),o=i[0],A=i[1];return new xr(n,r,o-n,A-r)}},{key:"setOrigin",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Ua.sceneGraphService.setOrigin(this,Sr(t,e,n,!1)),this}},{key:"getOrigin",value:function(){return Ua.sceneGraphService.getOrigin(this)}},{key:"setPosition",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Ua.sceneGraphService.setPosition(this,Sr(t,e,n,!1)),this}},{key:"setLocalPosition",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Ua.sceneGraphService.setLocalPosition(this,Sr(t,e,n,!1)),this}},{key:"translate",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Ua.sceneGraphService.translate(this,Sr(t,e,n,!1)),this}},{key:"translateLocal",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Ua.sceneGraphService.translateLocal(this,Sr(t,e,n,!1)),this}},{key:"getPosition",value:function(){return Ua.sceneGraphService.getPosition(this)}},{key:"getLocalPosition",value:function(){return Ua.sceneGraphService.getLocalPosition(this)}},{key:"scale",value:function(t,e,n){return this.scaleLocal(t,e,n)}},{key:"scaleLocal",value:function(t,e,n){return"number"==typeof t&&(t=Sr(t,e=e||t,n=n||t,!1)),Ua.sceneGraphService.scaleLocal(this,t),this}},{key:"setLocalScale",value:function(t,e,n){return"number"==typeof t&&(t=Sr(t,e=e||t,n=n||t,!1)),Ua.sceneGraphService.setLocalScale(this,t),this}},{key:"getLocalScale",value:function(){return Ua.sceneGraphService.getLocalScale(this)}},{key:"getScale",value:function(){return Ua.sceneGraphService.getScale(this)}},{key:"getEulerAngles",value:function(){return Tr(m(Ir(Ga,Ua.sceneGraphService.getWorldTransform(this)),3)[2])}},{key:"getLocalEulerAngles",value:function(){return Tr(m(Ir(Ga,Ua.sceneGraphService.getLocalRotation(this)),3)[2])}},{key:"setEulerAngles",value:function(t){return Ua.sceneGraphService.setEulerAngles(this,0,0,t),this}},{key:"setLocalEulerAngles",value:function(t){return Ua.sceneGraphService.setLocalEulerAngles(this,0,0,t),this}},{key:"rotateLocal",value:function(t,e,n){return Kt(e)&&Kt(n)?Ua.sceneGraphService.rotateLocal(this,0,0,t):Ua.sceneGraphService.rotateLocal(this,t,e,n),this}},{key:"rotate",value:function(t,e,n){return Kt(e)&&Kt(n)?Ua.sceneGraphService.rotate(this,0,0,t):Ua.sceneGraphService.rotate(this,t,e,n),this}},{key:"setRotation",value:function(t,e,n,r){return Ua.sceneGraphService.setRotation(this,t,e,n,r),this}},{key:"setLocalRotation",value:function(t,e,n,r){return Ua.sceneGraphService.setLocalRotation(this,t,e,n,r),this}},{key:"setLocalSkew",value:function(t,e){return Ua.sceneGraphService.setLocalSkew(this,t,e),this}},{key:"getRotation",value:function(){return Ua.sceneGraphService.getRotation(this)}},{key:"getLocalRotation",value:function(){return Ua.sceneGraphService.getLocalRotation(this)}},{key:"getLocalSkew",value:function(){return Ua.sceneGraphService.getLocalSkew(this)}},{key:"getLocalTransform",value:function(){return Ua.sceneGraphService.getLocalTransform(this)}},{key:"getWorldTransform",value:function(){return Ua.sceneGraphService.getWorldTransform(this)}},{key:"setLocalTransform",value:function(t){return Ua.sceneGraphService.setLocalTransform(this,t),this}},{key:"resetLocalTransform",value:function(){Ua.sceneGraphService.resetLocalTransform(this)}},{key:"getAnimations",value:function(){return this.activeAnimations}},{key:"animate",value:function(t,e){var n,r=null===(n=this.ownerDocument)||void 0===n?void 0:n.timeline;return r?r.play(this,t,e):null}},{key:"isVisible",value:function(){var t;return"hidden"!==(null===(t=this.parsedStyle)||void 0===t?void 0:t.visibility)}},{key:"interactive",get:function(){return this.isInteractive()},set:function(t){this.style.pointerEvents=t?"auto":"none"}},{key:"isInteractive",value:function(){var t;return"none"!==(null===(t=this.parsedStyle)||void 0===t?void 0:t.pointerEvents)}},{key:"isCulled",value:function(){return!(!this.cullable||!this.cullable.enable||this.cullable.visible)}},{key:"toFront",value:function(){return this.parentNode&&(this.style.zIndex=Math.max.apply(Math,u(this.parentNode.children.map(function(t){return Number(t.style.zIndex)})))+1),this}},{key:"toBack",value:function(){return this.parentNode&&(this.style.zIndex=Math.min.apply(Math,u(this.parentNode.children.map(function(t){return Number(t.style.zIndex)})))-1),this}},{key:"getConfig",value:function(){return this.config}},{key:"attr",value:function(){for(var t=this,e=arguments.length,n=new Array(e),r=0;r1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.setPosition(t,e,n),this}},{key:"move",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return this.setPosition(t,e,n),this}},{key:"setZIndex",value:function(t){return this.style.zIndex=t,this}}])}(Da);ja.PARSED_STYLE_LIST=new Set(["class","className","clipPath","cursor","display","draggable","droppable","fill","fillOpacity","fillRule","filter","increasedLineWidthForHitTesting","lineCap","lineDash","lineDashOffset","lineJoin","lineWidth","miterLimit","hitArea","offsetDistance","offsetPath","offsetX","offsetY","opacity","pointerEvents","shadowColor","shadowType","shadowBlur","shadowOffsetX","shadowOffsetY","stroke","strokeOpacity","strokeWidth","strokeLinecap","strokeLineJoin","strokeDasharray","strokeDashoffset","transform","transformOrigin","textTransform","visibility","zIndex"]);var za=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),g(this,e,[o({type:cr.CIRCLE},t)])}return v(e,t),a(e)}(ja);za.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["cx","cy","cz","r","isBillboard","isSizeAttenuation"]));var Va=["style"],Wa=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.style,i=ar(n,Va);return A(this,e),(t=g(this,e,[o({style:r},i)])).isCustomElement=!0,t}return v(e,t),a(e)}(ja);Wa.PARSED_STYLE_LIST=new Set(["class","className","clipPath","cursor","draggable","droppable","opacity","pointerEvents","transform","transformOrigin","zIndex","visibility"]);var Ya=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),g(this,e,[o({type:cr.ELLIPSE},t)])}return v(e,t),a(e)}(ja);Ya.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["cx","cy","cz","rx","ry","isBillboard","isSizeAttenuation"])),(function(t){function e(){return A(this,e),g(this,e,[{type:cr.FRAGMENT}])}return v(e,t),a(e)}(ja)).PARSED_STYLE_LIST=new Set(["class","className"]);var Xa=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),g(this,e,[o({type:cr.GROUP},t)])}return v(e,t),a(e)}(ja);Xa.PARSED_STYLE_LIST=new Set(["class","className","clipPath","cursor","draggable","droppable","opacity","pointerEvents","transform","transformOrigin","zIndex","visibility"]);var qa=["style"],$a=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.style,i=ar(n,qa);return A(this,e),(t=g(this,e,[o({type:cr.HTML,style:r},i)])).cullable.enable=!1,t}return v(e,t),a(e,[{key:"getDomElement",value:function(){return this.parsedStyle.$el}},{key:"getClientRects",value:function(){return[this.getBoundingClientRect()]}},{key:"getLocalBounds",value:function(){if(this.parentNode){var t=N(C(),this.parentNode.getWorldTransform()),e=this.getBounds();if(!yr.isEmpty(e)){var n=new yr;return n.setFromTransformedAABB(e,t),n}}return this.getBounds()}}])}(ja);$a.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["x","y","$el","innerHTML","width","height"]));var Za=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),g(this,e,[o({type:cr.IMAGE},t)])}return v(e,t),a(e)}(ja);Za.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["x","y","z","src","width","height","isBillboard","billboardRotation","isSizeAttenuation","keepAspectRatio"]));var Ja=["style"],tc=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.style,i=ar(n,Ja);A(this,e),(t=g(this,e,[o({type:cr.LINE,style:o({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0},r)},i)])).markerStartAngle=0,t.markerEndAngle=0;var s=t.parsedStyle,a=s.markerStart,c=s.markerEnd;return a&&Ra(a)&&(t.markerStartAngle=a.getLocalEulerAngles(),t.appendChild(a)),c&&Ra(c)&&(t.markerEndAngle=c.getLocalEulerAngles(),t.appendChild(c)),t.transformMarker(!0),t.transformMarker(!1),t}return v(e,t),a(e,[{key:"attributeChangedCallback",value:function(t,e,n,r,i){"x1"===t||"y1"===t||"x2"===t||"y2"===t||"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Ra(r)&&(this.markerStartAngle=0,r.remove()),i&&Ra(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t&&(r&&Ra(r)&&(this.markerEndAngle=0,r.remove()),i&&Ra(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1)))}},{key:"transformMarker",value:function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,A=e.x1,s=e.x2,a=e.y1,c=e.y2,l=t?n:r;if(l&&Ra(l)){var u,h,d,f,g,p,v;t?(f=A,g=a,h=s-A,d=c-a,p=i||0,v=this.markerStartAngle):(f=s,g=c,h=A-s,d=a-c,p=o||0,v=this.markerEndAngle),u=Math.atan2(d,h),l.setLocalEulerAngles(180*u/Math.PI+v),l.setLocalPosition(f+Math.cos(u)*p,g+Math.sin(u)*p)}}},{key:"getPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.parsedStyle,r=Rn(n.x1,n.y1,n.x2,n.y2,t),i=r.x,o=r.y,A=bt(at(),ut(i,o,0),e?this.getWorldTransform():this.getLocalTransform());return new Er(A[0],A[1])}},{key:"getPointAtLength",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.getPoint(t/this.getTotalLength(),e)}},{key:"getTotalLength",value:function(){var t=this.parsedStyle;return Dn(t.x1,t.y1,t.x2,t.y2)}}])}(ja);tc.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["x1","y1","x2","y2","z1","z2","isBillboard","isSizeAttenuation","markerStart","markerEnd","markerStartOffset","markerEndOffset"]));var ec=["style"],nc=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.style,i=ar(n,ec);A(this,e),(t=g(this,e,[o({type:cr.PATH,style:r,initialParsedStyle:{miterLimit:4,d:o({},ni)}},i)])).markerStartAngle=0,t.markerEndAngle=0,t.markerMidList=[];var s=t.parsedStyle,a=s.markerStart,c=s.markerEnd,l=s.markerMid;return a&&Ra(a)&&(t.markerStartAngle=a.getLocalEulerAngles(),t.appendChild(a)),l&&Ra(l)&&t.placeMarkerMid(l),c&&Ra(c)&&(t.markerEndAngle=c.getLocalEulerAngles(),t.appendChild(c)),t.transformMarker(!0),t.transformMarker(!1),t}return v(e,t),a(e,[{key:"attributeChangedCallback",value:function(t,e,n,r,i){"d"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Ra(r)&&(this.markerStartAngle=0,r.remove()),i&&Ra(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&Ra(r)&&(this.markerEndAngle=0,r.remove()),i&&Ra(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)}},{key:"transformMarker",value:function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,A=t?n:r;if(A&&Ra(A)){var s,a,c,l,u,h,d;if(t){var f=m(this.getStartTangent(),2),g=f[0],p=f[1];l=p[0],u=p[1],a=g[0]-p[0],c=g[1]-p[1],h=i||0,d=this.markerStartAngle}else{var v=m(this.getEndTangent(),2),y=v[0],w=v[1];l=w[0],u=w[1],a=y[0]-w[0],c=y[1]-w[1],h=o||0,d=this.markerEndAngle}s=Math.atan2(c,a),A.setLocalEulerAngles(180*s/Math.PI+d),A.setLocalPosition(l+Math.cos(s)*h,u+Math.sin(s)*h)}}},{key:"placeMarkerMid",value:function(t){var e=this.parsedStyle.d.segments;if(this.markerMidList.forEach(function(t){t.remove()}),t&&Ra(t))for(var n=1;n1&&void 0!==arguments[1]&&arguments[1],n=function(t,e,n){return xn(t,e,Le(Le({},n),{bbox:!1,length:!0})).point}(this.parsedStyle.d.absolutePath,t),r=n.x,i=n.y,o=bt(at(),ut(r,i,0),e?this.getWorldTransform():this.getLocalTransform());return new Er(o[0],o[1])}},{key:"getPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.getPointAtLength(t*Go(this),e)}},{key:"getStartTangent",value:function(){var t=this.parsedStyle.d.segments,e=[];if(t.length>1){var n=t[0].currentPoint,r=t[1].currentPoint,i=t[1].startTangent;e=[],i?(e.push([n[0]-i[0],n[1]-i[1]]),e.push([n[0],n[1]])):(e.push([r[0],r[1]]),e.push([n[0],n[1]]))}return e}},{key:"getEndTangent",value:function(){var t=this.parsedStyle.d.segments,e=t.length,n=[];if(e>1){var r=t[e-2].currentPoint,i=t[e-1].currentPoint,o=t[e-1].endTangent;n=[],o?(n.push([i[0]-o[0],i[1]-o[1]]),n.push([i[0],i[1]])):(n.push([r[0],r[1]]),n.push([i[0],i[1]]))}return n}}])}(ja);nc.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["d","markerStart","markerMid","markerEnd","markerStartOffset","markerEndOffset","isBillboard","isSizeAttenuation"]));var rc=["style"],ic=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.style,i=ar(n,rc);A(this,e),(t=g(this,e,[o({type:cr.POLYGON,style:r,initialParsedStyle:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!0}},i)])).markerStartAngle=0,t.markerEndAngle=0,t.markerMidList=[];var s=t.parsedStyle,a=s.markerStart,c=s.markerEnd,l=s.markerMid;return a&&Ra(a)&&(t.markerStartAngle=a.getLocalEulerAngles(),t.appendChild(a)),l&&Ra(l)&&t.placeMarkerMid(l),c&&Ra(c)&&(t.markerEndAngle=c.getLocalEulerAngles(),t.appendChild(c)),t.transformMarker(!0),t.transformMarker(!1),t}return v(e,t),a(e,[{key:"attributeChangedCallback",value:function(t,e,n,r,i){"points"===t?(this.transformMarker(!0),this.transformMarker(!1),this.placeMarkerMid(this.parsedStyle.markerMid)):"markerStartOffset"===t||"markerEndOffset"===t?(this.transformMarker(!0),this.transformMarker(!1)):"markerStart"===t?(r&&Ra(r)&&(this.markerStartAngle=0,r.remove()),i&&Ra(i)&&(this.markerStartAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!0))):"markerEnd"===t?(r&&Ra(r)&&(this.markerEndAngle=0,r.remove()),i&&Ra(i)&&(this.markerEndAngle=i.getLocalEulerAngles(),this.appendChild(i),this.transformMarker(!1))):"markerMid"===t&&this.placeMarkerMid(i)}},{key:"transformMarker",value:function(t){var e=this.parsedStyle,n=e.markerStart,r=e.markerEnd,i=e.markerStartOffset,o=e.markerEndOffset,A=(e.points||{}).points,s=t?n:r;if(s&&Ra(s)&&A){var a,c,l,u,h,d,f;if(u=A[0][0],h=A[0][1],t)c=A[1][0]-A[0][0],l=A[1][1]-A[0][1],d=i||0,f=this.markerStartAngle;else{var g=A.length;this.parsedStyle.isClosed?(c=A[g-1][0]-A[0][0],l=A[g-1][1]-A[0][1]):(u=A[g-1][0],h=A[g-1][1],c=A[g-2][0]-A[g-1][0],l=A[g-2][1]-A[g-1][1]),d=o||0,f=this.markerEndAngle}a=Math.atan2(l,c),s.setLocalEulerAngles(180*a/Math.PI+f),s.setLocalPosition(u+Math.cos(a)*d,h+Math.sin(a)*d)}}},{key:"placeMarkerMid",value:function(t){var e=(this.parsedStyle.points||{}).points;if(this.markerMidList.forEach(function(t){t.remove()}),this.markerMidList=[],t&&Ra(t)&&e)for(var n=1;n<(this.parsedStyle.isClosed?e.length:e.length-1);n++){var r=e[n][0],i=e[n][1],o=1===n?t:t.cloneNode(!0);this.markerMidList.push(o),this.appendChild(o),o.setLocalPosition(r,i)}}}])}(ja);ic.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["points","markerStart","markerMid","markerEnd","markerStartOffset","markerEndOffset","isClosed","isBillboard","isSizeAttenuation"]));var oc=["style"],Ac=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.style,r=ar(t,oc);return A(this,e),g(this,e,[o({type:cr.POLYLINE,style:n,initialParsedStyle:{points:{points:[],totalLength:0,segments:[]},miterLimit:4,isClosed:!1}},r)])}return v(e,t),a(e,[{key:"getTotalLength",value:function(){return 0===(t=this).parsedStyle.points.totalLength&&(t.parsedStyle.points.totalLength=zn(t.parsedStyle.points.points)),t.parsedStyle.points.totalLength;var t}},{key:"getPointAtLength",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.getPoint(t/this.getTotalLength(),e)}},{key:"getPoint",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=this.parsedStyle.points.points;if(0===this.parsedStyle.points.segments.length){var r,i,o=[],A=0,s=this.getTotalLength();n.forEach(function(t,e){n[e+1]&&((r=[0,0])[0]=A/s,i=Dn(t[0],t[1],n[e+1][0],n[e+1][1]),A+=i,r[1]=A/s,o.push(r))}),this.parsedStyle.points.segments=o}var a=0,c=0;this.parsedStyle.points.segments.forEach(function(e,n){t>=e[0]&&t<=e[1]&&(a=(t-e[0])/(e[1]-e[0]),c=n)});var l=Rn(n[c][0],n[c][1],n[c+1][0],n[c+1][1],a),u=l.x,h=l.y,d=bt(at(),ut(u,h,0),e?this.getWorldTransform():this.getLocalTransform());return new Er(d[0],d[1])}},{key:"getStartTangent",value:function(){var t=this.parsedStyle.points.points,e=[];return e.push([t[1][0],t[1][1]]),e.push([t[0][0],t[0][1]]),e}},{key:"getEndTangent",value:function(){var t=this.parsedStyle.points.points,e=t.length-1,n=[];return n.push([t[e-1][0],t[e-1][1]]),n.push([t[e][0],t[e][1]]),n}}])}(ic);Ac.PARSED_STYLE_LIST=new Set([].concat(u(ic.PARSED_STYLE_LIST),["points","markerStart","markerMid","markerEnd","markerStartOffset","markerEndOffset","isBillboard"]));var sc=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),g(this,e,[o({type:cr.RECT},t)])}return v(e,t),a(e)}(ja);sc.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["x","y","z","width","height","isBillboard","isSizeAttenuation","radius"]));var ac=["style"],cc=function(t){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.style,r=ar(t,ac);return A(this,e),g(this,e,[o({type:cr.TEXT,style:o({fill:"black"},n)},r)])}return v(e,t),a(e,[{key:"getComputedTextLength",value:function(){var t;return this.getGeometryBounds(),(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.maxLineWidth)||0}},{key:"getLineBoundingRects",value:function(){var t;return this.getGeometryBounds(),(null===(t=this.parsedStyle.metrics)||void 0===t?void 0:t.lineMetrics)||[]}},{key:"isOverflowing",value:function(){return this.getGeometryBounds(),!!this.parsedStyle.isOverflowing}}])}(ja);cc.PARSED_STYLE_LIST=new Set([].concat(u(ja.PARSED_STYLE_LIST),["x","y","z","isBillboard","billboardRotation","isSizeAttenuation","text","textAlign","textBaseline","fontStyle","fontSize","fontFamily","fontWeight","fontVariant","lineHeight","letterSpacing","leading","wordWrap","wordWrapWidth","maxLines","textOverflow","isOverflowing","textPath","textDecorationLine","textDecorationColor","textDecorationStyle","textDecorationThickness","textPathSide","textPathStartOffset","metrics","dx","dy"]));var lc=function(){return a(function t(){A(this,t),this.registry={},this.define(cr.CIRCLE,za),this.define(cr.ELLIPSE,Ya),this.define(cr.RECT,sc),this.define(cr.IMAGE,Za),this.define(cr.LINE,tc),this.define(cr.GROUP,Xa),this.define(cr.PATH,nc),this.define(cr.POLYGON,ic),this.define(cr.POLYLINE,Ac),this.define(cr.TEXT,cc),this.define(cr.HTML,$a)},[{key:"define",value:function(t,e){this.registry[t]=e}},{key:"get",value:function(t){return this.registry[t]}}])}(),uc=function(t){var e=t.name,n=t.inherits,r=t.interpolable,i=t.initialValue,o=t.syntax;Ua.styleValueRegistry.registerMetadata({n:e,inh:n,int:r,d:i,syntax:o})},hc=function(t){function e(){var t;A(this,e),(t=g(this,e)).defaultView=null,t.ownerDocument=null,t.nodeName="document";try{t.timeline=new Ua.AnimationTimeline(t)}catch(t){}var n={};return xA.forEach(function(t){var e=t.n,r=t.inh,i=t.d;r&&i&&(n[e]=Gt(i)?i(cr.GROUP):i)}),t.documentElement=new Xa({id:"g-root",style:n}),t.documentElement.ownerDocument=t,t.documentElement.parentNode=t,t.childNodes=[t.documentElement],t}return v(e,t),a(e,[{key:"children",get:function(){return this.childNodes}},{key:"childElementCount",get:function(){return this.childNodes.length}},{key:"firstElementChild",get:function(){return this.firstChild}},{key:"lastElementChild",get:function(){return this.lastChild}},{key:"createElement",value:function(t,e){if("svg"===t)return this.documentElement;var n=this.defaultView.customElements.get(t);n||(console.warn("Unsupported tagName: ",t),n="tspan"===t?cc:Xa);var r=new n(e);return r.ownerDocument=this,r}},{key:"createElementNS",value:function(t,e,n){return this.createElement(e,n)}},{key:"cloneNode",value:function(t){throw new Error(Cr)}},{key:"destroy",value:function(){try{this.documentElement.destroyChildren(),this.timeline.destroy()}catch(t){}}},{key:"elementsFromBBox",value:function(t,e,n,r){var i=[],o=function(A){if(A.isInteractive()&&!A.isCulled()){var s=A.parsedStyle.pointerEvents;if(!["auto","visiblepainted","visiblefill","visiblestroke","visible"].includes(void 0===s?"auto":s)||A.isVisible()){var a=A.getTransformedGeometryBounds(!0);a&&!yr.isEmpty(a)&&a.max[0]>=t&&a.min[0]<=n&&a.max[1]>=e&&a.min[1]<=r&&i.push(A)}A.childNodes&&A.childNodes.forEach(function(t){t instanceof ja&&o(t)})}};return o(this.documentElement),i.sort(function(t,e){return e.sortable.renderOrder-t.sortable.renderOrder}),i}},{key:"elementFromPointSync",value:function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),A=o.width,s=o.height;if(r<0||i<0||r>A||i>s)return null;var a=this.defaultView.viewport2Client({x:r,y:i}),c=a.x,l=a.y,u=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!0,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:c,clientY:l},picked:[]}).picked;return u&&u[0]||this.documentElement}},{key:"elementFromPoint",value:(r=Ar(ir().mark(function t(e,n){var r,i,o,A,s,a,c,l,u,h,d;return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.defaultView.canvas2Viewport({x:e,y:n}),i=r.x,o=r.y,A=this.defaultView.getConfig(),s=A.width,a=A.height,!(i<0||o<0||i>s||o>a)){t.next=1;break}return t.abrupt("return",null);case 1:return c=this.defaultView.viewport2Client({x:i,y:o}),l=c.x,u=c.y,t.next=2,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!0,position:{x:e,y:n,viewportX:i,viewportY:o,clientX:l,clientY:u},picked:[]});case 2:return h=t.sent,d=h.picked,t.abrupt("return",d&&d[0]||this.documentElement);case 3:case"end":return t.stop()}},t,this)})),function(t,e){return r.apply(this,arguments)})},{key:"elementsFromPointSync",value:function(t,e){var n=this.defaultView.canvas2Viewport({x:t,y:e}),r=n.x,i=n.y,o=this.defaultView.getConfig(),A=o.width,s=o.height;if(r<0||i<0||r>A||i>s)return[];var a=this.defaultView.viewport2Client({x:r,y:i}),c=a.x,l=a.y,u=this.defaultView.getRenderingService().hooks.pickSync.call({topmost:!1,position:{x:t,y:e,viewportX:r,viewportY:i,clientX:c,clientY:l},picked:[]}).picked;return u[u.length-1]!==this.documentElement&&u.push(this.documentElement),u}},{key:"elementsFromPoint",value:(n=Ar(ir().mark(function t(e,n){var r,i,o,A,s,a,c,l,u,h,d;return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=this.defaultView.canvas2Viewport({x:e,y:n}),i=r.x,o=r.y,A=this.defaultView.getConfig(),s=A.width,a=A.height,!(i<0||o<0||i>s||o>a)){t.next=1;break}return t.abrupt("return",[]);case 1:return c=this.defaultView.viewport2Client({x:i,y:o}),l=c.x,u=c.y,t.next=2,this.defaultView.getRenderingService().hooks.pick.promise({topmost:!1,position:{x:e,y:n,viewportX:i,viewportY:o,clientX:l,clientY:u},picked:[]});case 2:return h=t.sent,(d=h.picked)[d.length-1]!==this.documentElement&&d.push(this.documentElement),t.abrupt("return",d);case 3:case"end":return t.stop()}},t,this)})),function(t,e){return n.apply(this,arguments)})},{key:"appendChild",value:function(t,e){throw new Error(Mr)}},{key:"insertBefore",value:function(t,e){throw new Error(Mr)}},{key:"removeChild",value:function(t,e){throw new Error(Mr)}},{key:"replaceChild",value:function(t,e,n){throw new Error(Mr)}},{key:"append",value:function(){throw new Error(Mr)}},{key:"prepend",value:function(){throw new Error(Mr)}},{key:"getElementById",value:function(t){return this.documentElement.getElementById(t)}},{key:"getElementsByName",value:function(t){return this.documentElement.getElementsByName(t)}},{key:"getElementsByTagName",value:function(t){return this.documentElement.getElementsByTagName(t)}},{key:"getElementsByClassName",value:function(t){return this.documentElement.getElementsByClassName(t)}},{key:"querySelector",value:function(t){return this.documentElement.querySelector(t)}},{key:"querySelectorAll",value:function(t){return this.documentElement.querySelectorAll(t)}},{key:"find",value:function(t){return this.documentElement.find(t)}},{key:"findAll",value:function(t){return this.documentElement.findAll(t)}}]);var n,r}(Ys),dc=function(){function t(e){A(this,t),this.strategies=e}return a(t,[{key:"apply",value:function(e){var n=e.config,r=e.camera,i=e.renderingService,o=e.renderingContext,A=this.strategies;i.hooks.cull.tap(t.tag,function(t){if(t){var e,i=t.cullable;if(0===A.length?i.visible=o.unculledEntities.indexOf(t.entity)>-1:i.visible=A.every(function(e){return e.isVisible(r,t)}),!t.isCulled()&&t.isVisible())return t;var s=!0===(null===(e=n.future)||void 0===e?void 0:e.experimentalCancelEventPropagation);return t.dispatchEvent(new Vs(ea.CULLED),s,s),null}return t}),i.hooks.afterRender.tap(t.tag,function(t){t.cullable.visibilityPlaneMask=-1})}}])}();dc.tag="Culling";var fc=function(){function t(){var e=this;A(this,t),this.autoPreventDefault=!1,this.rootPointerEvent=new js(null),this.rootWheelEvent=new zs(null),this.onPointerMove=function(t){var n,r=null===(n=e.context.renderingContext.root)||void 0===n||null===(n=n.ownerDocument)||void 0===n?void 0:n.defaultView;if(!r.supportsTouchEvents||"touch"!==t.pointerType){var i,o=sr(e.normalizeToPointerEvent(t,r));try{for(o.s();!(i=o.n()).done;){var A=i.value,s=e.bootstrapEvent(e.rootPointerEvent,A,r,t);e.context.eventService.mapEvent(s)}}catch(t){o.e(t)}finally{o.f()}e.setCursor(e.context.eventService.cursor)}},this.onClick=function(t){var n,r,i=null===(n=e.context.renderingContext.root)||void 0===n||null===(n=n.ownerDocument)||void 0===n?void 0:n.defaultView,o=sr(e.normalizeToPointerEvent(t,i));try{for(o.s();!(r=o.n()).done;){var A=r.value,s=e.bootstrapEvent(e.rootPointerEvent,A,i,t);e.context.eventService.mapEvent(s)}}catch(t){o.e(t)}finally{o.f()}e.setCursor(e.context.eventService.cursor)}}return a(t,[{key:"apply",value:function(e){var n=this;this.context=e;var r=e.renderingService,i=this.context.renderingContext.root.ownerDocument.defaultView;this.context.eventService.setPickHandler(function(t){return n.context.renderingService.hooks.pickSync.call({position:t,picked:[],topmost:!0}).picked[0]||null}),r.hooks.pointerWheel.tap(t.tag,function(t){var e=n.normalizeWheelEvent(t);n.context.eventService.mapEvent(e)}),r.hooks.pointerDown.tap(t.tag,function(t){if(!i.supportsTouchEvents||"touch"!==t.pointerType){var e=n.normalizeToPointerEvent(t,i);if(n.autoPreventDefault&&e[0].isNormalized)(t.cancelable||!("cancelable"in t))&&t.preventDefault();var r,o=sr(e);try{for(o.s();!(r=o.n()).done;){var A=r.value,s=n.bootstrapEvent(n.rootPointerEvent,A,i,t);n.context.eventService.mapEvent(s)}}catch(t){o.e(t)}finally{o.f()}n.setCursor(n.context.eventService.cursor)}}),r.hooks.pointerUp.tap(t.tag,function(t){if(!i.supportsTouchEvents||"touch"!==t.pointerType){var e,r=n.context.contextService.getDomElement(),o=n.context.eventService.isNativeEventFromCanvas(r,t)?"":"outside",A=sr(n.normalizeToPointerEvent(t,i));try{for(A.s();!(e=A.n()).done;){var s=e.value,a=n.bootstrapEvent(n.rootPointerEvent,s,i,t);a.type+=o,n.context.eventService.mapEvent(a)}}catch(t){A.e(t)}finally{A.f()}n.setCursor(n.context.eventService.cursor)}}),r.hooks.pointerMove.tap(t.tag,this.onPointerMove),r.hooks.pointerOver.tap(t.tag,this.onPointerMove),r.hooks.pointerOut.tap(t.tag,this.onPointerMove),r.hooks.click.tap(t.tag,this.onClick),r.hooks.pointerCancel.tap(t.tag,function(t){var e,r=sr(n.normalizeToPointerEvent(t,i));try{for(r.s();!(e=r.n()).done;){var o=e.value,A=n.bootstrapEvent(n.rootPointerEvent,o,i,t);n.context.eventService.mapEvent(A)}}catch(t){r.e(t)}finally{r.f()}n.setCursor(n.context.eventService.cursor)})}},{key:"bootstrapEvent",value:function(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);var i=this.context.eventService.client2Viewport({x:e.clientX,y:e.clientY}),o=i.x,A=i.y;t.viewport.x=o,t.viewport.y=A;var s=this.context.eventService.viewport2Canvas(t.viewport),a=s.x,c=s.y;return t.canvas.x=a,t.canvas.y=c,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=ZA[t.type]||t.type),t}},{key:"normalizeWheelEvent",value:function(t){var e=this.rootWheelEvent;this.transferMouseData(e,t),e.deltaMode=t.deltaMode,e.deltaX=t.deltaX,e.deltaY=t.deltaY,e.deltaZ=t.deltaZ;var n=this.context.eventService.client2Viewport({x:t.clientX,y:t.clientY}),r=n.x,i=n.y;e.viewport.x=r,e.viewport.y=i;var o=this.context.eventService.viewport2Canvas(e.viewport),A=o.x,s=o.y;return e.canvas.x=A,e.canvas.y=s,e.global.copyFrom(e.canvas),e.offset.copyFrom(e.canvas),e.nativeEvent=t,e.type=t.type,e}},{key:"transferMouseData",value:function(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=JA.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}},{key:"setCursor",value:function(t){this.context.contextService.applyCursorStyle(t||this.context.config.cursor||"default")}},{key:"normalizeToPointerEvent",value:function(t,e){var n=[];if(e.isTouchEvent(t))for(var r=0;r-1,A=0,s=r.length;A=1?Math.ceil(k):1,i&&(M=a||function(t){var e=$A(t,"width");return"auto"===e?t.offsetWidth:parseFloat(e)}(i)||i.width/k,F=c||function(t){var e=$A(t,"height");return"auto"===e?t.offsetHeight:parseFloat(e)}(i)||i.height/k),n.customElements=new lc,n.devicePixelRatio=k,n.requestAnimationFrame=null!=m?m:us.bind(Ua.globalThis),n.cancelAnimationFrame=null!=y?y:hs.bind(Ua.globalThis),n.createImage=null!=w?w:function(){return new window.Image},n.supportsTouchEvents=null!=b?b:"ontouchstart"in Ua.globalThis,n.supportsPointerEvents=null!=B?B:!!Ua.globalThis.PointerEvent,n.isTouchEvent=null!=E?E:function(t){return n.supportsTouchEvents&&t instanceof Ua.globalThis.TouchEvent},n.isMouseEvent=null!=x?x:function(t){return!Ua.globalThis.MouseEvent||t instanceof Ua.globalThis.MouseEvent&&(!n.supportsPointerEvents||!(t instanceof Ua.globalThis.PointerEvent))},p&&(Ua.offscreenCanvas=p),n.document=new hc,n.document.defaultView=n,h||function(t,e,n){if(t){var r="string"==typeof t?document.getElementById(t):t;VA.has(r)&&VA.get(r).destroy(n),VA.set(r,e)}}(r,n,f),n.initRenderingContext(o(o({},t),{},{width:M,height:F,background:null!=l?l:"transparent",cursor:null!=u?u:"default",cleanUpOnDestroy:f,devicePixelRatio:k,requestAnimationFrame:n.requestAnimationFrame,cancelAnimationFrame:n.cancelAnimationFrame,createImage:n.createImage,supportsTouchEvents:n.supportsTouchEvents,supportsPointerEvents:n.supportsPointerEvents,isTouchEvent:n.isTouchEvent,isMouseEvent:n.isMouseEvent,dblClickSpeed:null!=C?C:200})),n.initDefaultCamera(M,F,s.clipSpaceNearZ),n.initRenderer(s,!0),n}return v(e,t),a(e,[{key:"initRenderingContext",value:function(t){this.context.config=t,this.context.renderingContext={root:this.document.documentElement,unculledEntities:[],renderListCurrentFrame:[],renderReasons:new Set,force:!1,dirty:!1}}},{key:"initDefaultCamera",value:function(t,e,n){var r=this,i=new Ua.CameraContribution;i.clipSpaceNearZ=n,i.setType(jr.EXPLORING,zr.DEFAULT).setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0).setOrthographic(t/-2,t/2,e/2,e/-2,.1,1e3),i.canvas=this,i.eventEmitter.on(Wr,function(){r.context.renderingContext.renderReasons.add($s.CAMERA_CHANGED),Ua.enableSizeAttenuation&&r.getConfig().renderer.getConfig().enableSizeAttenuation&&r.updateSizeAttenuation()}),this.context.camera=i}},{key:"updateSizeAttenuation",value:function(){var t=this.getCamera().getZoom();this.document.documentElement.forEach(function(e){Ua.styleValueRegistry.updateSizeAttenuation(e,t)})}},{key:"getConfig",value:function(){return this.context.config}},{key:"getRoot",value:function(){return this.document.documentElement}},{key:"getCamera",value:function(){return this.context.camera}},{key:"getContextService",value:function(){return this.context.contextService}},{key:"getEventService",value:function(){return this.context.eventService}},{key:"getRenderingService",value:function(){return this.context.renderingService}},{key:"getRenderingContext",value:function(){return this.context.renderingContext}},{key:"getStats",value:function(){return this.getRenderingService().getStats()}},{key:"ready",get:function(){var t=this;return this.readyPromise||(this.readyPromise=new Promise(function(e){t.resolveReadyPromise=function(){e(t)}}),this.inited&&this.resolveReadyPromise()),this.readyPromise}},{key:"destroy",value:function(){var t,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=arguments.length>1?arguments[1]:void 0;Pi.clearCache();var r=!0===(null===(t=this.getConfig().future)||void 0===t?void 0:t.experimentalCancelEventPropagation);n||this.dispatchEvent(new Vs(mc.BEFORE_DESTROY),r,r),this.frameId&&this.cancelAnimationFrame(this.frameId);var i=this.getRoot();e&&(this.unmountChildren(i),this.document.destroy(),this.getEventService().destroy()),this.getRenderingService().destroy(),this.getContextService().destroy(),n||this.dispatchEvent(new Vs(mc.AFTER_DESTROY),r,r);var o=function(t){t.currentTarget=null,t.manager=null,t.target=null,t.relatedNode=null};o(yc),o(wc),o(bc),o(Bc),o(Ec),o(_a),o(Ia),o(La),o(Pa),Ua.textService.clearCache()}},{key:"changeSize",value:function(t,e){this.resize(t,e)}},{key:"resize",value:function(t,e){var n,r=this.context.config;r.width=t,r.height=e,this.getContextService().resize(t,e);var i=this.context.camera,o=i.getProjectionMode();i.setPosition(t/2,e/2,500).setFocalPoint(t/2,e/2,0),o===Vr.ORTHOGRAPHIC?i.setOrthographic(t/-2,t/2,e/2,e/-2,i.getNear(),i.getFar()):i.setAspect(t/e);var A=!0===(null===(n=r.future)||void 0===n?void 0:n.experimentalCancelEventPropagation);this.dispatchEvent(new Vs(mc.RESIZE,{width:t,height:e}),A,A)}},{key:"appendChild",value:function(t,e){return this.document.documentElement.appendChild(t,e)}},{key:"insertBefore",value:function(t,e){return this.document.documentElement.insertBefore(t,e)}},{key:"removeChild",value:function(t){return this.document.documentElement.removeChild(t)}},{key:"removeChildren",value:function(){this.document.documentElement.removeChildren()}},{key:"destroyChildren",value:function(){this.document.documentElement.destroyChildren()}},{key:"render",value:function(t){var e,n=this;t&&(bc.detail=t,Ec.detail=t);var r=!0===(null===(e=this.getConfig().future)||void 0===e?void 0:e.experimentalCancelEventPropagation);this.dispatchEvent(bc,r,r),this.getRenderingService().render(this,t,function(){n.dispatchEvent(Bc,r,r)}),this.dispatchEvent(Ec,r,r)}},{key:"run",value:function(){var t=this,e=function(n,r){t.render(r),t.frameId=t.requestAnimationFrame(e)};e()}},{key:"initRenderer",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!t)throw new Error("Renderer is required.");this.inited=!1,this.readyPromise=void 0,this.context.renderingPlugins=[],this.context.renderingPlugins.push(new fc,new vc,new dc([new pc])),this.loadRendererContainerModule(t),this.context.contextService=new this.context.ContextService(o(o({},Ua),this.context)),this.context.renderingService=new Zs(Ua,this.context),this.context.eventService=new Xs(Ua,this.context),this.context.eventService.init(),this.context.contextService.init?(this.context.contextService.init(),this.initRenderingService(t,n,!0)):this.context.contextService.initAsync().then(function(){e.initRenderingService(t,n)}).catch(function(t){console.error(t)})}},{key:"initRenderingService",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.context.renderingService.init(function(){var i;e.inited=!0;var o=!0===(null===(i=e.getConfig().future)||void 0===i?void 0:i.experimentalCancelEventPropagation);n?r?e.requestAnimationFrame(function(){e.dispatchEvent(new Vs(mc.READY),o,o)}):e.dispatchEvent(new Vs(mc.READY),o,o):e.dispatchEvent(new Vs(mc.RENDERER_CHANGED),o,o),e.readyPromise&&e.resolveReadyPromise(),n||e.getRoot().forEach(function(t){var e,n;null===(e=(n=t).dirty)||void 0===e||e.call(n,!0,!0)}),e.mountChildren(e.getRoot()),t.getConfig().enableAutoRendering&&e.run()})}},{key:"loadRendererContainerModule",value:function(t){var e=this;t.getPlugins().forEach(function(t){t.context=e.context,t.init(Ua)})}},{key:"setRenderer",value:function(t){var e=this.getConfig();if(e.renderer!==t){var n=e.renderer;e.renderer=t,this.destroy(!1,!0),u((null==n?void 0:n.getPlugins())||[]).reverse().forEach(function(t){t.destroy(Ua)}),this.initRenderer(t)}}},{key:"setCursor",value:function(t){this.getConfig().cursor=t,this.getContextService().applyCursorStyle(t)}},{key:"unmountChildren",value:function(t){var e=this;if(t.childNodes.forEach(function(t){e.unmountChildren(t)}),this.inited){if(t.isMutationObserved)t.dispatchEvent(wc);else{var n,r=!0===(null===(n=this.getConfig().future)||void 0===n?void 0:n.experimentalCancelEventPropagation);wc.target=t,this.dispatchEvent(wc,!0,r)}t!==this.document.documentElement&&(t.ownerDocument=null),t.isConnected=!1}t.isCustomElement&&t.disconnectedCallback&&t.disconnectedCallback()}},{key:"mountChildren",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ts(t);if(this.inited){if(!t.isConnected&&(t.ownerDocument=this.document,t.isConnected=!0,!n))if(t.isMutationObserved)t.dispatchEvent(yc);else{var r,i=!0===(null===(r=this.getConfig().future)||void 0===r?void 0:r.experimentalCancelEventPropagation);yc.target=t,this.dispatchEvent(yc,!0,i)}}else console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.","appended child: ",t.nodeName);t.childNodes.forEach(function(t){e.mountChildren(t,n)}),t.isCustomElement&&t.connectedCallback&&t.connectedCallback()}},{key:"mountFragment",value:function(t){this.mountChildren(t,!1)}},{key:"client2Viewport",value:function(t){return this.getEventService().client2Viewport(t)}},{key:"viewport2Client",value:function(t){return this.getEventService().viewport2Client(t)}},{key:"viewport2Canvas",value:function(t){return this.getEventService().viewport2Canvas(t)}},{key:"canvas2Viewport",value:function(t){return this.getEventService().canvas2Viewport(t)}},{key:"getPointByClient",value:function(t,e){return this.client2Viewport({x:t,y:e})}},{key:"getClientByPoint",value:function(t,e){return this.viewport2Client({x:t,y:e})}}])}(Ws),Cc=function(){return a(function t(){A(this,t),this.cacheStore=new Map},[{key:"onRefAdded",value:function(t){}},{key:"has",value:function(t){return this.cacheStore.has(t)}},{key:"put",value:function(t,e,n){return!this.cacheStore.has(t)&&(this.cacheStore.set(t,{value:e,counter:new Set([n.entity])}),this.onRefAdded(n),!0)}},{key:"get",value:function(t,e){var n=this.cacheStore.get(t);return n?(n.counter.has(e.entity)||(n.counter.add(e.entity),this.onRefAdded(e)),n.value):null}},{key:"update",value:function(t,e,n){var r=this.cacheStore.get(t);return!!r&&(r.value=o(o({},r.value),e),r.counter.has(n.entity)||(r.counter.add(n.entity),this.onRefAdded(n)),!0)}},{key:"release",value:function(t,e){var n=this.cacheStore.get(t);return!!n&&(n.counter.delete(e.entity),n.counter.size<=0&&this.cacheStore.delete(t),!0)}},{key:"releaseRef",value:function(t){var e=this;Array.from(this.cacheStore.keys()).forEach(function(n){e.release(n,t)})}},{key:"getSize",value:function(){return this.cacheStore.size}},{key:"clear",value:function(){this.cacheStore.clear()}}])}(),Mc=[],Fc=[],kc=function(){function t(){A(this,t)}return a(t,null,[{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t.api;t.rafId&&(e.cancelAnimationFrame(t.rafId),t.rafId=null)}},{key:"executeTask",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t.api;Mc.length<=0&&Fc.length<=0||(Fc.forEach(function(t){return t()}),Fc=Mc.splice(0,t.TASK_NUM_PER_FRAME),t.rafId=e.requestAnimationFrame(function(){t.executeTask(e)}))}},{key:"sliceImage",value:function(e,n,r,i){for(var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,A=arguments.length>5&&void 0!==arguments[5]?arguments[5]:t.api,s=e.naturalWidth||e.width,a=e.naturalHeight||e.height,c=n-o,l=r-o,u=Math.ceil(s/c),h=Math.ceil(a/l),d={tileSize:[n,r],gridSize:[h,u],tiles:Array(h).fill(null).map(function(){return Array(u).fill(null)})},f=function(t){for(var o=function(o){Mc.push(function(){var u=o*c,h=t*l,f=[Math.min(n,s-u),Math.min(r,a-h)],g=f[0],p=f[1],v=A.createCanvas();v.width=n,v.height=r,v.getContext("2d").drawImage(e,u,h,g,p,0,0,g,p),d.tiles[t][o]={x:u,y:h,tileX:o,tileY:t,data:v},i()})},h=0;h1&&void 0!==arguments[1]?arguments[1]:[0,0,0];return"matrix(".concat([t[0],t[1],t[4],t[5],t[12]+e[0],t[13]+e[1]].join(","),")")}},{key:"apply",value:function(e,n){var r=this,i=e.camera,o=e.renderingContext,A=e.renderingService;this.context=e;var s=o.root.ownerDocument.defaultView,a=s.context.eventService.nativeHTMLMap,c=function(t,e){e.style.transform=r.joinTransformMatrix(t.getWorldTransform(),t.getOrigin())},l=function(t){var e=t.target;if(e.nodeName===cr.HTML){r.$camera||(r.$camera=r.createCamera(i));var n=r.getOrCreateEl(e);r.$camera.appendChild(n),Object.keys(e.attributes).forEach(function(t){r.updateAttribute(t,e)}),c(e,n),a.set(n,e)}},u=function(t){var e=t.target;if(e.nodeName===cr.HTML&&r.$camera){var n=r.getOrCreateEl(e);n&&(n.remove(),a.delete(n))}},h=function(t){var e=t.target;if(e.nodeName===cr.HTML){var n=t.attrName;r.updateAttribute(n,e)}},d=function(t){for(var e=t.detail,n=0;n * Copyright (c) 2022 Niklas von Hertzen * Released under MIT License */ /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ var _c=function(t,e){return _c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},_c(t,e)};function Gc(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}_c(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function Kc(t,e,n,r){return new(n||(n=Promise))(function(e,i){function o(t){try{s(r.next(t))}catch(t){i(t)}}function A(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(t){t(r)})).then(o,A)}s((r=r.apply(t,[])).next())})}function jc(t,e){var n,r,i,o,A={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;A;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return A.label++,{value:o[1],done:!1};case 5:A.label++,r=o[1],o=[0];continue;case 7:o=A.ops.pop(),A.trys.pop();continue;default:if(!(i=A.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){A=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=55296&&i<=56319&&n>10),A%1024+56320)),(i+1===n||r.length>16384)&&(o+=String.fromCharCode.apply(String,r),r.length=0)}return o},Xc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",qc="undefined"==typeof Uint8Array?[]:new Uint8Array(256),$c=0;$c<64;$c++)qc[Xc.charCodeAt($c)]=$c;for(var Zc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Jc="undefined"==typeof Uint8Array?[]:new Uint8Array(256),tl=0;tl<64;tl++)Jc[Zc.charCodeAt(tl)]=tl;for(var el=function(t,e,n){return t.slice?t.slice(e,n):new Uint16Array(Array.prototype.slice.call(t,e,n))},nl=function(){function t(t,e,n,r,i,o){this.initialValue=t,this.errorValue=e,this.highStart=n,this.highValueIndex=r,this.index=i,this.data=o}return t.prototype.get=function(t){var e;if(t>=0){if(t<55296||t>56319&&t<=65535)return e=((e=this.index[t>>5])<<2)+(31&t),this.data[e];if(t<=65535)return e=((e=this.index[2048+(t-55296>>5)])<<2)+(31&t),this.data[e];if(t>11),e=this.index[e],e+=t>>5&63,e=((e=this.index[e])<<2)+(31&t),this.data[e];if(t<=1114111)return this.data[this.highValueIndex]}return this.errorValue},t}(),rl="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",il="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ol=0;ol<64;ol++)il[rl.charCodeAt(ol)]=ol;var Al=10,sl=13,al=15,cl=17,ll=18,ul=19,hl=20,dl=21,fl=22,gl=24,pl=25,vl=26,ml=27,yl=28,wl=30,bl=32,Bl=33,El=34,xl=35,Cl=37,Ml=38,Fl=39,kl=40,Sl=42,Ql=[9001,65288],Ul="×",Nl="÷",Tl=function(t){var e,n,r,i=function(t){var e,n,r,i,o,A=.75*t.length,s=t.length,a=0;"="===t[t.length-1]&&(A--,"="===t[t.length-2]&&A--);var c="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(A):new Array(A),l=Array.isArray(c)?c:new Uint8Array(c);for(e=0;e>4,l[a++]=(15&r)<<4|i>>2,l[a++]=(3&i)<<6|63&o;return c}(t),o=Array.isArray(i)?function(t){for(var e=t.length,n=[],r=0;r0;){var A=r[--o];if(Array.isArray(t)?-1!==t.indexOf(A):t===A)for(var s=n;s<=r.length;){var a;if((a=r[++s])===e)return!0;if(a!==Al)break}if(A!==Al)break}return!1},Gl=function(t,e){for(var n=t;n>=0;){var r=e[n];if(r!==Al)return r;n--}return 0},Kl=function(t,e,n,r,i){if(0===n[r])return Ul;var o=r-1;if(Array.isArray(i)&&!0===i[o])return Ul;var A=o-1,s=o+1,a=e[o],c=A>=0?e[A]:0,l=e[s];if(2===a&&3===l)return Ul;if(-1!==Il.indexOf(a))return"!";if(-1!==Il.indexOf(l))return Ul;if(-1!==Ll.indexOf(l))return Ul;if(8===Gl(o,e))return Nl;if(11===Tl.get(t[o]))return Ul;if((a===bl||a===Bl)&&11===Tl.get(t[s]))return Ul;if(7===a||7===l)return Ul;if(9===a)return Ul;if(-1===[Al,sl,al].indexOf(a)&&9===l)return Ul;if(-1!==[cl,ll,ul,gl,yl].indexOf(l))return Ul;if(Gl(o,e)===fl)return Ul;if(_l(23,fl,o,e))return Ul;if(_l([cl,ll],dl,o,e))return Ul;if(_l(12,12,o,e))return Ul;if(a===Al)return Nl;if(23===a||23===l)return Ul;if(16===l||16===a)return Nl;if(-1!==[sl,al,dl].indexOf(l)||14===a)return Ul;if(36===c&&-1!==Hl.indexOf(a))return Ul;if(a===yl&&36===l)return Ul;if(l===hl)return Ul;if(-1!==Ol.indexOf(l)&&a===pl||-1!==Ol.indexOf(a)&&l===pl)return Ul;if(a===ml&&-1!==[Cl,bl,Bl].indexOf(l)||-1!==[Cl,bl,Bl].indexOf(a)&&l===vl)return Ul;if(-1!==Ol.indexOf(a)&&-1!==Pl.indexOf(l)||-1!==Pl.indexOf(a)&&-1!==Ol.indexOf(l))return Ul;if(-1!==[ml,vl].indexOf(a)&&(l===pl||-1!==[fl,al].indexOf(l)&&e[s+1]===pl)||-1!==[fl,al].indexOf(a)&&l===pl||a===pl&&-1!==[pl,yl,gl].indexOf(l))return Ul;if(-1!==[pl,yl,gl,cl,ll].indexOf(l))for(var u=o;u>=0;){if((h=e[u])===pl)return Ul;if(-1===[yl,gl].indexOf(h))break;u--}if(-1!==[ml,vl].indexOf(l))for(u=-1!==[cl,ll].indexOf(a)?A:o;u>=0;){var h;if((h=e[u])===pl)return Ul;if(-1===[yl,gl].indexOf(h))break;u--}if(Ml===a&&-1!==[Ml,Fl,El,xl].indexOf(l)||-1!==[Fl,El].indexOf(a)&&-1!==[Fl,kl].indexOf(l)||-1!==[kl,xl].indexOf(a)&&l===kl)return Ul;if(-1!==Rl.indexOf(a)&&-1!==[hl,vl].indexOf(l)||-1!==Rl.indexOf(l)&&a===ml)return Ul;if(-1!==Ol.indexOf(a)&&-1!==Ol.indexOf(l))return Ul;if(a===gl&&-1!==Ol.indexOf(l))return Ul;if(-1!==Ol.concat(pl).indexOf(a)&&l===fl&&-1===Ql.indexOf(t[s])||-1!==Ol.concat(pl).indexOf(l)&&a===ll)return Ul;if(41===a&&41===l){for(var d=n[o],f=1;d>0&&41===e[--d];)f++;if(f%2!=0)return Ul}return a===bl&&l===Bl?Ul:Nl},jl=function(t,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var n=function(t,e){void 0===e&&(e="strict");var n=[],r=[],i=[];return t.forEach(function(t,o){var A=Tl.get(t);if(A>50?(i.push(!0),A-=50):i.push(!1),-1!==["normal","auto","loose"].indexOf(e)&&-1!==[8208,8211,12316,12448].indexOf(t))return r.push(o),n.push(16);if(4===A||11===A){if(0===o)return r.push(o),n.push(wl);var s=n[o-1];return-1===Dl.indexOf(s)?(r.push(r[o-1]),n.push(s)):(r.push(o),n.push(wl))}return r.push(o),31===A?n.push("strict"===e?dl:Cl):A===Sl||29===A?n.push(wl):43===A?t>=131072&&t<=196605||t>=196608&&t<=262141?n.push(Cl):n.push(wl):void n.push(A)}),[r,n,i]}(t,e.lineBreak),r=n[0],i=n[1],o=n[2];"break-all"!==e.wordBreak&&"break-word"!==e.wordBreak||(i=i.map(function(t){return-1!==[pl,wl,Sl].indexOf(t)?Cl:t}));var A="keep-all"===e.wordBreak?o.map(function(e,n){return e&&t[n]>=19968&&t[n]<=40959}):void 0;return[r,i,A]},zl=function(){function t(t,e,n,r){this.codePoints=t,this.required="!"===e,this.start=n,this.end=r}return t.prototype.slice=function(){return Yc.apply(void 0,this.codePoints.slice(this.start,this.end))},t}(),Vl=45,Wl=43,Yl=-1,Xl=function(t){return t>=48&&t<=57},ql=function(t){return Xl(t)||t>=65&&t<=70||t>=97&&t<=102},$l=function(t){return 10===t||9===t||32===t},Zl=function(t){return function(t){return function(t){return t>=97&&t<=122}(t)||function(t){return t>=65&&t<=90}(t)}(t)||function(t){return t>=128}(t)||95===t},Jl=function(t){return Zl(t)||Xl(t)||t===Vl},tu=function(t){return t>=0&&t<=8||11===t||t>=14&&t<=31||127===t},eu=function(t,e){return 92===t&&10!==e},nu=function(t,e,n){return t===Vl?Zl(e)||eu(e,n):!!Zl(t)||!(92!==t||!eu(t,e))},ru=function(t,e,n){return t===Wl||t===Vl?!!Xl(e)||46===e&&Xl(n):Xl(46===t?e:t)},iu=function(t){var e=0,n=1;t[e]!==Wl&&t[e]!==Vl||(t[e]===Vl&&(n=-1),e++);for(var r=[];Xl(t[e]);)r.push(t[e++]);var i=r.length?parseInt(Yc.apply(void 0,r),10):0;46===t[e]&&e++;for(var o=[];Xl(t[e]);)o.push(t[e++]);var A=o.length,s=A?parseInt(Yc.apply(void 0,o),10):0;69!==t[e]&&101!==t[e]||e++;var a=1;t[e]!==Wl&&t[e]!==Vl||(t[e]===Vl&&(a=-1),e++);for(var c=[];Xl(t[e]);)c.push(t[e++]);var l=c.length?parseInt(Yc.apply(void 0,c),10):0;return n*(i+s*Math.pow(10,-A))*Math.pow(10,a*l)},ou={type:2},Au={type:3},su={type:4},au={type:13},cu={type:8},lu={type:21},uu={type:9},hu={type:10},du={type:11},fu={type:12},gu={type:14},pu={type:23},vu={type:1},mu={type:25},yu={type:24},wu={type:26},bu={type:27},Bu={type:28},Eu={type:29},xu={type:31},Cu={type:32},Mu=function(){function t(){this._value=[]}return t.prototype.write=function(t){this._value=this._value.concat(Wc(t))},t.prototype.read=function(){for(var t=[],e=this.consumeToken();e!==Cu;)t.push(e),e=this.consumeToken();return t},t.prototype.consumeToken=function(){var t=this.consumeCodePoint();switch(t){case 34:return this.consumeStringToken(34);case 35:var e=this.peekCodePoint(0),n=this.peekCodePoint(1),r=this.peekCodePoint(2);if(Jl(e)||eu(n,r)){var i=nu(e,n,r)?2:1;return{type:5,value:this.consumeName(),flags:i}}break;case 36:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),au;break;case 39:return this.consumeStringToken(39);case 40:return ou;case 41:return Au;case 42:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),gu;break;case Wl:if(ru(t,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(t),this.consumeNumericToken();break;case 44:return su;case Vl:var o=t,A=this.peekCodePoint(0),s=this.peekCodePoint(1);if(ru(o,A,s))return this.reconsumeCodePoint(t),this.consumeNumericToken();if(nu(o,A,s))return this.reconsumeCodePoint(t),this.consumeIdentLikeToken();if(A===Vl&&62===s)return this.consumeCodePoint(),this.consumeCodePoint(),yu;break;case 46:if(ru(t,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(t),this.consumeNumericToken();break;case 47:if(42===this.peekCodePoint(0))for(this.consumeCodePoint();;){var a=this.consumeCodePoint();if(42===a&&47===(a=this.consumeCodePoint()))return this.consumeToken();if(a===Yl)return this.consumeToken()}break;case 58:return wu;case 59:return bu;case 60:if(33===this.peekCodePoint(0)&&this.peekCodePoint(1)===Vl&&this.peekCodePoint(2)===Vl)return this.consumeCodePoint(),this.consumeCodePoint(),mu;break;case 64:var c=this.peekCodePoint(0),l=this.peekCodePoint(1),u=this.peekCodePoint(2);if(nu(c,l,u))return{type:7,value:this.consumeName()};break;case 91:return Bu;case 92:if(eu(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),this.consumeIdentLikeToken();break;case 93:return Eu;case 61:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),cu;break;case 123:return du;case 125:return fu;case 117:case 85:var h=this.peekCodePoint(0),d=this.peekCodePoint(1);return h!==Wl||!ql(d)&&63!==d||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(t),this.consumeIdentLikeToken();case 124:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),uu;if(124===this.peekCodePoint(0))return this.consumeCodePoint(),lu;break;case 126:if(61===this.peekCodePoint(0))return this.consumeCodePoint(),hu;break;case Yl:return Cu}return $l(t)?(this.consumeWhiteSpace(),xu):Xl(t)?(this.reconsumeCodePoint(t),this.consumeNumericToken()):Zl(t)?(this.reconsumeCodePoint(t),this.consumeIdentLikeToken()):{type:6,value:Yc(t)}},t.prototype.consumeCodePoint=function(){var t=this._value.shift();return void 0===t?-1:t},t.prototype.reconsumeCodePoint=function(t){this._value.unshift(t)},t.prototype.peekCodePoint=function(t){return t>=this._value.length?-1:this._value[t]},t.prototype.consumeUnicodeRangeToken=function(){for(var t=[],e=this.consumeCodePoint();ql(e)&&t.length<6;)t.push(e),e=this.consumeCodePoint();for(var n=!1;63===e&&t.length<6;)t.push(e),e=this.consumeCodePoint(),n=!0;if(n)return{type:30,start:parseInt(Yc.apply(void 0,t.map(function(t){return 63===t?48:t})),16),end:parseInt(Yc.apply(void 0,t.map(function(t){return 63===t?70:t})),16)};var r=parseInt(Yc.apply(void 0,t),16);if(this.peekCodePoint(0)===Vl&&ql(this.peekCodePoint(1))){this.consumeCodePoint(),e=this.consumeCodePoint();for(var i=[];ql(e)&&i.length<6;)i.push(e),e=this.consumeCodePoint();return{type:30,start:r,end:parseInt(Yc.apply(void 0,i),16)}}return{type:30,start:r,end:r}},t.prototype.consumeIdentLikeToken=function(){var t=this.consumeName();return"url"===t.toLowerCase()&&40===this.peekCodePoint(0)?(this.consumeCodePoint(),this.consumeUrlToken()):40===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:19,value:t}):{type:20,value:t}},t.prototype.consumeUrlToken=function(){var t=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Yl)return{type:22,value:""};var e=this.peekCodePoint(0);if(39===e||34===e){var n=this.consumeStringToken(this.consumeCodePoint());return 0===n.type&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Yl||41===this.peekCodePoint(0))?(this.consumeCodePoint(),{type:22,value:n.value}):(this.consumeBadUrlRemnants(),pu)}for(;;){var r=this.consumeCodePoint();if(r===Yl||41===r)return{type:22,value:Yc.apply(void 0,t)};if($l(r))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Yl||41===this.peekCodePoint(0)?(this.consumeCodePoint(),{type:22,value:Yc.apply(void 0,t)}):(this.consumeBadUrlRemnants(),pu);if(34===r||39===r||40===r||tu(r))return this.consumeBadUrlRemnants(),pu;if(92===r){if(!eu(r,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),pu;t.push(this.consumeEscapedCodePoint())}else t.push(r)}},t.prototype.consumeWhiteSpace=function(){for(;$l(this.peekCodePoint(0));)this.consumeCodePoint()},t.prototype.consumeBadUrlRemnants=function(){for(;;){var t=this.consumeCodePoint();if(41===t||t===Yl)return;eu(t,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},t.prototype.consumeStringSlice=function(t){for(var e="";t>0;){var n=Math.min(5e4,t);e+=Yc.apply(void 0,this._value.splice(0,n)),t-=n}return this._value.shift(),e},t.prototype.consumeStringToken=function(t){for(var e="",n=0;;){var r=this._value[n];if(r===Yl||void 0===r||r===t)return{type:0,value:e+=this.consumeStringSlice(n)};if(10===r)return this._value.splice(0,n),vu;if(92===r){var i=this._value[n+1];i!==Yl&&void 0!==i&&(10===i?(e+=this.consumeStringSlice(n),n=-1,this._value.shift()):eu(r,i)&&(e+=this.consumeStringSlice(n),e+=Yc(this.consumeEscapedCodePoint()),n=-1))}n++}},t.prototype.consumeNumber=function(){var t=[],e=4,n=this.peekCodePoint(0);for(n!==Wl&&n!==Vl||t.push(this.consumeCodePoint());Xl(this.peekCodePoint(0));)t.push(this.consumeCodePoint());n=this.peekCodePoint(0);var r=this.peekCodePoint(1);if(46===n&&Xl(r))for(t.push(this.consumeCodePoint(),this.consumeCodePoint()),e=8;Xl(this.peekCodePoint(0));)t.push(this.consumeCodePoint());n=this.peekCodePoint(0),r=this.peekCodePoint(1);var i=this.peekCodePoint(2);if((69===n||101===n)&&((r===Wl||r===Vl)&&Xl(i)||Xl(r)))for(t.push(this.consumeCodePoint(),this.consumeCodePoint()),e=8;Xl(this.peekCodePoint(0));)t.push(this.consumeCodePoint());return[iu(t),e]},t.prototype.consumeNumericToken=function(){var t=this.consumeNumber(),e=t[0],n=t[1],r=this.peekCodePoint(0),i=this.peekCodePoint(1),o=this.peekCodePoint(2);return nu(r,i,o)?{type:15,number:e,flags:n,unit:this.consumeName()}:37===r?(this.consumeCodePoint(),{type:16,number:e,flags:n}):{type:17,number:e,flags:n}},t.prototype.consumeEscapedCodePoint=function(){var t=this.consumeCodePoint();if(ql(t)){for(var e=Yc(t);ql(this.peekCodePoint(0))&&e.length<6;)e+=Yc(this.consumeCodePoint());$l(this.peekCodePoint(0))&&this.consumeCodePoint();var n=parseInt(e,16);return 0===n||function(t){return t>=55296&&t<=57343}(n)||n>1114111?65533:n}return t===Yl?65533:t},t.prototype.consumeName=function(){for(var t="";;){var e=this.consumeCodePoint();if(Jl(e))t+=Yc(e);else{if(!eu(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),t;t+=Yc(this.consumeEscapedCodePoint())}}},t}(),Fu=function(){function t(t){this._tokens=t}return t.create=function(e){var n=new Mu;return n.write(e),new t(n.read())},t.parseValue=function(e){return t.create(e).parseComponentValue()},t.parseValues=function(e){return t.create(e).parseComponentValues()},t.prototype.parseComponentValue=function(){for(var t=this.consumeToken();31===t.type;)t=this.consumeToken();if(32===t.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(t);var e=this.consumeComponentValue();do{t=this.consumeToken()}while(31===t.type);if(32===t.type)return e;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},t.prototype.parseComponentValues=function(){for(var t=[];;){var e=this.consumeComponentValue();if(32===e.type)return t;t.push(e),t.push()}},t.prototype.consumeComponentValue=function(){var t=this.consumeToken();switch(t.type){case 11:case 28:case 2:return this.consumeSimpleBlock(t.type);case 19:return this.consumeFunction(t)}return t},t.prototype.consumeSimpleBlock=function(t){for(var e={type:t,values:[]},n=this.consumeToken();;){if(32===n.type||Ou(n,t))return e;this.reconsumeToken(n),e.values.push(this.consumeComponentValue()),n=this.consumeToken()}},t.prototype.consumeFunction=function(t){for(var e={name:t.value,values:[],type:18};;){var n=this.consumeToken();if(32===n.type||3===n.type)return e;this.reconsumeToken(n),e.values.push(this.consumeComponentValue())}},t.prototype.consumeToken=function(){var t=this._tokens.shift();return void 0===t?Cu:t},t.prototype.reconsumeToken=function(t){this._tokens.unshift(t)},t}(),ku=function(t){return 15===t.type},Su=function(t){return 17===t.type},Qu=function(t){return 20===t.type},Uu=function(t,e){return Qu(t)&&t.value===e},Nu=function(t){return 31!==t.type&&4!==t.type},Tu=function(t){var e=[],n=[];return t.forEach(function(t){if(4===t.type){if(0===n.length)throw new Error("Error parsing function args, zero tokens for arg");return e.push(n),void(n=[])}31!==t.type&&n.push(t)}),n.length&&e.push(n),e},Ou=function(t,e){return 11===e&&12===t.type||(28===e&&29===t.type||2===e&&3===t.type)},Iu=function(t){return 17===t.type||15===t.type},Lu=function(t){return 16===t.type||Iu(t)},Pu=function(t){return t.length>1?[t[0],t[1]]:[t[0]]},Du={type:17,number:0,flags:4},Ru={type:16,number:50,flags:4},Hu={type:16,number:100,flags:4},_u=function(t,e,n){var r=t[0],i=t[1];return[Gu(r,e),Gu(void 0!==i?i:r,n)]},Gu=function(t,e){if(16===t.type)return t.number/100*e;if(ku(t))switch(t.unit){case"rem":case"em":return 16*t.number;default:return t.number}return t.number},Ku="grad",ju="turn",zu=function(t,e){if(15===e.type)switch(e.unit){case"deg":return Math.PI*e.number/180;case Ku:return Math.PI/200*e.number;case"rad":return e.number;case ju:return 2*Math.PI*e.number}throw new Error("Unsupported angle type")},Vu=function(t){return 15===t.type&&("deg"===t.unit||t.unit===Ku||"rad"===t.unit||t.unit===ju)},Wu=function(t){switch(t.filter(Qu).map(function(t){return t.value}).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[Du,Du];case"to top":case"bottom":return Yu(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[Du,Hu];case"to right":case"left":return Yu(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[Hu,Hu];case"to bottom":case"top":return Yu(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[Hu,Du];case"to left":case"right":return Yu(270)}return 0},Yu=function(t){return Math.PI*t/180},Xu=function(t,e){if(18===e.type){var n=rh[e.name];if(void 0===n)throw new Error('Attempting to parse an unsupported color function "'+e.name+'"');return n(t,e.values)}if(5===e.type){if(3===e.value.length){var r=e.value.substring(0,1),i=e.value.substring(1,2),o=e.value.substring(2,3);return Zu(parseInt(r+r,16),parseInt(i+i,16),parseInt(o+o,16),1)}if(4===e.value.length){r=e.value.substring(0,1),i=e.value.substring(1,2),o=e.value.substring(2,3);var A=e.value.substring(3,4);return Zu(parseInt(r+r,16),parseInt(i+i,16),parseInt(o+o,16),parseInt(A+A,16)/255)}if(6===e.value.length){r=e.value.substring(0,2),i=e.value.substring(2,4),o=e.value.substring(4,6);return Zu(parseInt(r,16),parseInt(i,16),parseInt(o,16),1)}if(8===e.value.length){r=e.value.substring(0,2),i=e.value.substring(2,4),o=e.value.substring(4,6),A=e.value.substring(6,8);return Zu(parseInt(r,16),parseInt(i,16),parseInt(o,16),parseInt(A,16)/255)}}if(20===e.type){var s=oh[e.value.toUpperCase()];if(void 0!==s)return s}return oh.TRANSPARENT},qu=function(t){return!(255&t)},$u=function(t){var e=255&t,n=255&t>>8,r=255&t>>16,i=255&t>>24;return e<255?"rgba("+i+","+r+","+n+","+e/255+")":"rgb("+i+","+r+","+n+")"},Zu=function(t,e,n,r){return(t<<24|e<<16|n<<8|Math.round(255*r))>>>0},Ju=function(t,e){if(17===t.type)return t.number;if(16===t.type){var n=3===e?1:255;return 3===e?t.number/100*n:Math.round(t.number/100*n)}return 0},th=function(t,e){var n=e.filter(Nu);if(3===n.length){var r=n.map(Ju),i=r[0],o=r[1],A=r[2];return Zu(i,o,A,1)}if(4===n.length){var s=n.map(Ju),a=(i=s[0],o=s[1],A=s[2],s[3]);return Zu(i,o,A,a)}return 0};function eh(t,e,n){return n<0&&(n+=1),n>=1&&(n-=1),n<1/6?(e-t)*n*6+t:n<.5?e:n<2/3?6*(e-t)*(2/3-n)+t:t}var nh=function(t,e){var n=e.filter(Nu),r=n[0],i=n[1],o=n[2],A=n[3],s=(17===r.type?Yu(r.number):zu(t,r))/(2*Math.PI),a=Lu(i)?i.number/100:0,c=Lu(o)?o.number/100:0,l=void 0!==A&&Lu(A)?Gu(A,1):1;if(0===a)return Zu(255*c,255*c,255*c,1);var u=c<=.5?c*(a+1):c+a-c*a,h=2*c-u,d=eh(h,u,s+1/3),f=eh(h,u,s),g=eh(h,u,s-1/3);return Zu(255*d,255*f,255*g,l)},rh={hsl:nh,hsla:nh,rgb:th,rgba:th},ih=function(t,e){return Xu(t,Fu.create(e).parseComponentValue())},oh={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},Ah={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(t,e){return e.map(function(t){if(Qu(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},sh={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},ah=function(t,e){var n=Xu(t,e[0]),r=e[1];return r&&Lu(r)?{color:n,stop:r}:{color:n,stop:null}},ch=function(t,e){var n=t[0],r=t[t.length-1];null===n.stop&&(n.stop=Du),null===r.stop&&(r.stop=Hu);for(var i=[],o=0,A=0;Ao?i.push(a):i.push(o),o=a}else i.push(null)}var c=null;for(A=0;At.optimumDistance)?{optimumCorner:e,optimumDistance:s}:t},{optimumDistance:i?1/0:-1/0,optimumCorner:null}).optimumCorner},dh=function(t,e){var n=Yu(180),r=[];return Tu(e).forEach(function(e,i){if(0===i){var o=e[0];if(20===o.type&&-1!==["top","left","right","bottom"].indexOf(o.value))return void(n=Wu(e));if(Vu(o))return void(n=(zu(t,o)+Yu(270))%Yu(360))}var A=ah(t,e);r.push(A)}),{angle:n,stops:r,type:1}},fh="closest-side",gh="farthest-side",ph="closest-corner",vh="farthest-corner",mh="circle",yh="ellipse",wh="cover",bh="contain",Bh=function(t,e){var n=0,r=3,i=[],o=[];return Tu(e).forEach(function(e,A){var s=!0;if(0===A?s=e.reduce(function(t,e){if(Qu(e))switch(e.value){case"center":return o.push(Ru),!1;case"top":case"left":return o.push(Du),!1;case"right":case"bottom":return o.push(Hu),!1}else if(Lu(e)||Iu(e))return o.push(e),!1;return t},s):1===A&&(s=e.reduce(function(t,e){if(Qu(e))switch(e.value){case mh:return n=0,!1;case yh:return n=1,!1;case bh:case fh:return r=0,!1;case gh:return r=1,!1;case ph:return r=2,!1;case wh:case vh:return r=3,!1}else if(Iu(e)||Lu(e))return Array.isArray(r)||(r=[]),r.push(e),!1;return t},s)),s){var a=ah(t,e);i.push(a)}}),{size:r,shape:n,stops:i,position:o,type:2}},Eh=function(t,e){if(22===e.type){var n={url:e.value,type:0};return t.cache.addImage(e.value),n}if(18===e.type){var r=Ch[e.name];if(void 0===r)throw new Error('Attempting to parse an unsupported image function "'+e.name+'"');return r(t,e.values)}throw new Error("Unsupported image type "+e.type)};var xh,Ch={"linear-gradient":function(t,e){var n=Yu(180),r=[];return Tu(e).forEach(function(e,i){if(0===i){var o=e[0];if(20===o.type&&"to"===o.value)return void(n=Wu(e));if(Vu(o))return void(n=zu(t,o))}var A=ah(t,e);r.push(A)}),{angle:n,stops:r,type:1}},"-moz-linear-gradient":dh,"-ms-linear-gradient":dh,"-o-linear-gradient":dh,"-webkit-linear-gradient":dh,"radial-gradient":function(t,e){var n=0,r=3,i=[],o=[];return Tu(e).forEach(function(e,A){var s=!0;if(0===A){var a=!1;s=e.reduce(function(t,e){if(a)if(Qu(e))switch(e.value){case"center":return o.push(Ru),t;case"top":case"left":return o.push(Du),t;case"right":case"bottom":return o.push(Hu),t}else(Lu(e)||Iu(e))&&o.push(e);else if(Qu(e))switch(e.value){case mh:return n=0,!1;case yh:return n=1,!1;case"at":return a=!0,!1;case fh:return r=0,!1;case wh:case gh:return r=1,!1;case bh:case ph:return r=2,!1;case vh:return r=3,!1}else if(Iu(e)||Lu(e))return Array.isArray(r)||(r=[]),r.push(e),!1;return t},s)}if(s){var c=ah(t,e);i.push(c)}}),{size:r,shape:n,stops:i,position:o,type:2}},"-moz-radial-gradient":Bh,"-ms-radial-gradient":Bh,"-o-radial-gradient":Bh,"-webkit-radial-gradient":Bh,"-webkit-gradient":function(t,e){var n=Yu(180),r=[],i=1;return Tu(e).forEach(function(e,n){var o=e[0];if(0===n){if(Qu(o)&&"linear"===o.value)return void(i=1);if(Qu(o)&&"radial"===o.value)return void(i=2)}if(18===o.type)if("from"===o.name){var A=Xu(t,o.values[0]);r.push({stop:Du,color:A})}else if("to"===o.name){A=Xu(t,o.values[0]);r.push({stop:Hu,color:A})}else if("color-stop"===o.name){var s=o.values.filter(Nu);if(2===s.length){A=Xu(t,s[1]);var a=s[0];Su(a)&&r.push({stop:{type:16,number:100*a.number,flags:a.flags},color:A})}}}),1===i?{angle:(n+Yu(180))%Yu(360),stops:r,type:i}:{size:3,shape:0,stops:r,position:[],type:i}}},Mh={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(t,e){if(0===e.length)return[];var n=e[0];return 20===n.type&&"none"===n.value?[]:e.filter(function(t){return Nu(t)&&function(t){return!(20===t.type&&"none"===t.value||18===t.type&&!Ch[t.name])}(t)}).map(function(e){return Eh(t,e)})}},Fh={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(t,e){return e.map(function(t){if(Qu(t))switch(t.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},kh={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(t,e){return Tu(e).map(function(t){return t.filter(Lu)}).map(Pu)}},Sh={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(t,e){return Tu(e).map(function(t){return t.filter(Qu).map(function(t){return t.value}).join(" ")}).map(Qh)}},Qh=function(t){switch(t){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(t){t.AUTO="auto",t.CONTAIN="contain",t.COVER="cover"}(xh||(xh={}));var Uh,Nh={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(t,e){return Tu(e).map(function(t){return t.filter(Th)})}},Th=function(t){return Qu(t)||Lu(t)},Oh=function(t){return{name:"border-"+t+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},Ih=Oh("top"),Lh=Oh("right"),Ph=Oh("bottom"),Dh=Oh("left"),Rh=function(t){return{name:"border-radius-"+t,initialValue:"0 0",prefix:!1,type:1,parse:function(t,e){return Pu(e.filter(Lu))}}},Hh=Rh("top-left"),_h=Rh("top-right"),Gh=Rh("bottom-right"),Kh=Rh("bottom-left"),jh=function(t){return{name:"border-"+t+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(t,e){switch(e){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},zh=jh("top"),Vh=jh("right"),Wh=jh("bottom"),Yh=jh("left"),Xh=function(t){return{name:"border-"+t+"-width",initialValue:"0",type:0,prefix:!1,parse:function(t,e){return ku(e)?e.number:0}}},qh=Xh("top"),$h=Xh("right"),Zh=Xh("bottom"),Jh=Xh("left"),td={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},ed={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(t,e){return"rtl"===e?1:0}},nd={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(t,e){return e.filter(Qu).reduce(function(t,e){return t|rd(e.value)},0)}},rd=function(t){switch(t){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},id={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(t,e){switch(e){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},od={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(t,e){return 20===e.type&&"normal"===e.value?0:17===e.type||15===e.type?e.number:0}};!function(t){t.NORMAL="normal",t.STRICT="strict"}(Uh||(Uh={}));var Ad,sd={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(t,e){return"strict"===e?Uh.STRICT:Uh.NORMAL}},ad={name:"line-height",initialValue:"normal",prefix:!1,type:4},cd=function(t,e){return Qu(t)&&"normal"===t.value?1.2*e:17===t.type?e*t.number:Lu(t)?Gu(t,e):e},ld={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(t,e){return 20===e.type&&"none"===e.value?null:Eh(t,e)}},ud={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(t,e){return"inside"===e?0:1}},hd={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(t,e){switch(e){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},dd=function(t){return{name:"margin-"+t,initialValue:"0",prefix:!1,type:4}},fd=dd("top"),gd=dd("right"),pd=dd("bottom"),vd=dd("left"),md={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(t,e){return e.filter(Qu).map(function(t){switch(t.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}})}},yd={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(t,e){return"break-word"===e?"break-word":"normal"}},wd=function(t){return{name:"padding-"+t,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},bd=wd("top"),Bd=wd("right"),Ed=wd("bottom"),xd=wd("left"),Cd={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(t,e){switch(e){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Md={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(t,e){switch(e){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},Fd={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(t,e){return 1===e.length&&Uu(e[0],"none")?[]:Tu(e).map(function(e){for(var n={color:oh.TRANSPARENT,offsetX:Du,offsetY:Du,blur:Du},r=0,i=0;i1?1:0],this.overflowWrap=Jd(t,yd,e.overflowWrap),this.paddingTop=Jd(t,bd,e.paddingTop),this.paddingRight=Jd(t,Bd,e.paddingRight),this.paddingBottom=Jd(t,Ed,e.paddingBottom),this.paddingLeft=Jd(t,xd,e.paddingLeft),this.paintOrder=Jd(t,Xd,e.paintOrder),this.position=Jd(t,Md,e.position),this.textAlign=Jd(t,Cd,e.textAlign),this.textDecorationColor=Jd(t,Rd,null!==(n=e.textDecorationColor)&&void 0!==n?n:e.color),this.textDecorationLine=Jd(t,Hd,null!==(r=e.textDecorationLine)&&void 0!==r?r:e.textDecoration),this.textShadow=Jd(t,Fd,e.textShadow),this.textTransform=Jd(t,kd,e.textTransform),this.transform=Jd(t,Sd,e.transform),this.transformOrigin=Jd(t,Td,e.transformOrigin),this.visibility=Jd(t,Od,e.visibility),this.webkitTextStrokeColor=Jd(t,qd,e.webkitTextStrokeColor),this.webkitTextStrokeWidth=Jd(t,$d,e.webkitTextStrokeWidth),this.wordBreak=Jd(t,Id,e.wordBreak),this.zIndex=Jd(t,Ld,e.zIndex)}return t.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},t.prototype.isTransparent=function(){return qu(this.backgroundColor)},t.prototype.isTransformed=function(){return null!==this.transform},t.prototype.isPositioned=function(){return 0!==this.position},t.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},t.prototype.isFloating=function(){return 0!==this.float},t.prototype.isInlineLevel=function(){return Vd(this.display,4)||Vd(this.display,33554432)||Vd(this.display,268435456)||Vd(this.display,536870912)||Vd(this.display,67108864)||Vd(this.display,134217728)},t}(),Jd=function(t,e,n){var r=new Mu,i=null!=n?n.toString():e.initialValue;r.write(i);var o=new Fu(r.read());switch(e.type){case 2:var A=o.parseComponentValue();return e.parse(t,Qu(A)?A.value:e.initialValue);case 0:return e.parse(t,o.parseComponentValue());case 1:return e.parse(t,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(e.format){case"angle":return zu(t,o.parseComponentValue());case"color":return Xu(t,o.parseComponentValue());case"image":return Eh(t,o.parseComponentValue());case"length":var s=o.parseComponentValue();return Iu(s)?s:Du;case"length-percentage":var a=o.parseComponentValue();return Lu(a)?a:Du;case"time":return Pd(t,o.parseComponentValue())}}},tf=function(t,e){var n=function(t){switch(t.getAttribute("data-html2canvas-debug")){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}}(t);return 1===n||e===n},ef=function(t,e){this.context=t,this.textNodes=[],this.elements=[],this.flags=0,tf(e,3),this.styles=new Zd(t,window.getComputedStyle(e,null)),Ag(e)&&(this.styles.animationDuration.some(function(t){return t>0})&&(e.style.animationDuration="0s"),null!==this.styles.transform&&(e.style.transform="none")),this.bounds=Vc(this.context,e),tf(e,4)&&(this.flags|=16)},nf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",rf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),of=0;of<64;of++)rf[nf.charCodeAt(of)]=of;for(var Af=function(t,e,n){return t.slice?t.slice(e,n):new Uint16Array(Array.prototype.slice.call(t,e,n))},sf=function(){function t(t,e,n,r,i,o){this.initialValue=t,this.errorValue=e,this.highStart=n,this.highValueIndex=r,this.index=i,this.data=o}return t.prototype.get=function(t){var e;if(t>=0){if(t<55296||t>56319&&t<=65535)return e=((e=this.index[t>>5])<<2)+(31&t),this.data[e];if(t<=65535)return e=((e=this.index[2048+(t-55296>>5)])<<2)+(31&t),this.data[e];if(t>11),e=this.index[e],e+=t>>5&63,e=((e=this.index[e])<<2)+(31&t),this.data[e];if(t<=1114111)return this.data[this.highValueIndex]}return this.errorValue},t}(),af="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",cf="undefined"==typeof Uint8Array?[]:new Uint8Array(256),lf=0;lf<64;lf++)cf[af.charCodeAt(lf)]=lf;var uf,hf=8,df=9,ff=11,gf=12,pf=function(){for(var t=[],e=0;e>10),A%1024+56320)),(i+1===n||r.length>16384)&&(o+=String.fromCharCode.apply(String,r),r.length=0)}return o},vf=function(t){var e,n,r,i=function(t){var e,n,r,i,o,A=.75*t.length,s=t.length,a=0;"="===t[t.length-1]&&(A--,"="===t[t.length-2]&&A--);var c="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&void 0!==Uint8Array.prototype.slice?new ArrayBuffer(A):new Array(A),l=Array.isArray(c)?c:new Uint8Array(c);for(e=0;e>4,l[a++]=(15&r)<<4|i>>2,l[a++]=(3&i)<<6|63&o;return c}(t),o=Array.isArray(i)?function(t){for(var e=t.length,n=[],r=0;r=55296&&i<=56319&&n=n)return{done:!0,value:null};for(var t=mf;rA.x||i.y>A.y;return A=i,0===e||s});return t.body.removeChild(e),s}(document);return Object.defineProperty(Cf,"SUPPORT_WORD_BREAKING",{value:t}),t},get SUPPORT_SVG_DRAWING(){var t=function(t){var e=new Image,n=t.createElement("canvas"),r=n.getContext("2d");if(!r)return!1;e.src="data:image/svg+xml,";try{r.drawImage(e,0,0),n.toDataURL()}catch(t){return!1}return!0}(document);return Object.defineProperty(Cf,"SUPPORT_SVG_DRAWING",{value:t}),t},get SUPPORT_FOREIGNOBJECT_DRAWING(){var t="function"==typeof Array.from&&"function"==typeof window.fetch?function(t){var e=t.createElement("canvas"),n=100;e.width=n,e.height=n;var r=e.getContext("2d");if(!r)return Promise.reject(!1);r.fillStyle="rgb(0, 255, 0)",r.fillRect(0,0,n,n);var i=new Image,o=e.toDataURL();i.src=o;var A=Ef(n,n,0,0,i);return r.fillStyle="red",r.fillRect(0,0,n,n),xf(A).then(function(e){r.drawImage(e,0,0);var i=r.getImageData(0,0,n,n).data;r.fillStyle="red",r.fillRect(0,0,n,n);var A=t.createElement("div");return A.style.backgroundImage="url("+o+")",A.style.height=n+"px",Bf(i)?xf(Ef(n,n,0,0,A)):Promise.reject(!1)}).then(function(t){return r.drawImage(t,0,0),Bf(r.getImageData(0,0,n,n).data)}).catch(function(){return!1})}(document):Promise.resolve(!1);return Object.defineProperty(Cf,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:t}),t},get SUPPORT_CORS_IMAGES(){var t=void 0!==(new Image).crossOrigin;return Object.defineProperty(Cf,"SUPPORT_CORS_IMAGES",{value:t}),t},get SUPPORT_RESPONSE_TYPE(){var t="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(Cf,"SUPPORT_RESPONSE_TYPE",{value:t}),t},get SUPPORT_CORS_XHR(){var t="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Cf,"SUPPORT_CORS_XHR",{value:t}),t},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var t=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(Cf,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:t}),t}},Mf=function(t,e){this.text=t,this.bounds=e},Ff=function(t,e){var n=e.ownerDocument;if(n){var r=n.createElement("html2canvaswrapper");r.appendChild(e.cloneNode(!0));var i=e.parentNode;if(i){i.replaceChild(r,e);var o=Vc(t,r);return r.firstChild&&i.replaceChild(r.firstChild,r),o}}return zc.EMPTY},kf=function(t,e,n){var r=t.ownerDocument;if(!r)throw new Error("Node has no owner document");var i=r.createRange();return i.setStart(t,e),i.setEnd(t,e+n),i},Sf=function(t){if(Cf.SUPPORT_NATIVE_TEXT_SEGMENTATION){var e=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(e.segment(t)).map(function(t){return t.segment})}return function(t){for(var e,n=bf(t),r=[];!(e=n.next()).done;)e.value&&r.push(e.value.slice());return r}(t)},Qf=function(t,e){return 0!==e.letterSpacing?Sf(t):function(t,e){if(Cf.SUPPORT_NATIVE_TEXT_SEGMENTATION){var n=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(n.segment(t)).map(function(t){return t.segment})}return Nf(t,e)}(t,e)},Uf=[32,160,4961,65792,65793,4153,4241],Nf=function(t,e){for(var n,r=function(t,e){var n=Wc(t),r=jl(n,e),i=r[0],o=r[1],A=r[2],s=n.length,a=0,c=0;return{next:function(){if(c>=s)return{done:!0,value:null};for(var t=Ul;c0)if(Cf.SUPPORT_RANGE_BOUNDS){var i=kf(r,A,e.length).getClientRects();if(i.length>1){var s=Sf(e),a=0;s.forEach(function(e){o.push(new Mf(e,zc.fromDOMRectList(t,kf(r,a+A,e.length).getClientRects()))),a+=e.length})}else o.push(new Mf(e,zc.fromDOMRectList(t,i)))}else{var c=r.splitText(e.length);o.push(new Mf(e,Ff(t,r))),r=c}else Cf.SUPPORT_RANGE_BOUNDS||(r=r.splitText(e.length));A+=e.length}),o}(t,this.text,n,e)},Of=function(t,e){switch(e){case 1:return t.toLowerCase();case 3:return t.replace(If,Lf);case 2:return t.toUpperCase();default:return t}},If=/(^|\s|:|-|\(|\))([a-z])/g,Lf=function(t,e,n){return t.length>0?e+n.toUpperCase():t},Pf=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.src=n.currentSrc||n.src,r.intrinsicWidth=n.naturalWidth,r.intrinsicHeight=n.naturalHeight,r.context.cache.addImage(r.src),r}return Gc(e,t),e}(ef),Df=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.canvas=n,r.intrinsicWidth=n.width,r.intrinsicHeight=n.height,r}return Gc(e,t),e}(ef),Rf=function(t){function e(e,n){var r=t.call(this,e,n)||this,i=new XMLSerializer,o=Vc(e,n);return n.setAttribute("width",o.width+"px"),n.setAttribute("height",o.height+"px"),r.svg="data:image/svg+xml,"+encodeURIComponent(i.serializeToString(n)),r.intrinsicWidth=n.width.baseVal.value,r.intrinsicHeight=n.height.baseVal.value,r.context.cache.addImage(r.svg),r}return Gc(e,t),e}(ef),Hf=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.value=n.value,r}return Gc(e,t),e}(ef),_f=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.start=n.start,r.reversed="boolean"==typeof n.reversed&&!0===n.reversed,r}return Gc(e,t),e}(ef),Gf=[{type:15,flags:0,unit:"px",number:3}],Kf=[{type:16,flags:0,number:50}],jf="checkbox",zf="radio",Vf="password",Wf=707406591,Yf=function(t){function e(e,n){var r,i,o,A=t.call(this,e,n)||this;switch(A.type=n.type.toLowerCase(),A.checked=n.checked,A.value=0===(i=(r=n).type===Vf?new Array(r.value.length+1).join("•"):r.value).length?r.placeholder||"":i,A.type!==jf&&A.type!==zf||(A.styles.backgroundColor=3739148031,A.styles.borderTopColor=A.styles.borderRightColor=A.styles.borderBottomColor=A.styles.borderLeftColor=2779096575,A.styles.borderTopWidth=A.styles.borderRightWidth=A.styles.borderBottomWidth=A.styles.borderLeftWidth=1,A.styles.borderTopStyle=A.styles.borderRightStyle=A.styles.borderBottomStyle=A.styles.borderLeftStyle=1,A.styles.backgroundClip=[0],A.styles.backgroundOrigin=[0],A.bounds=(o=A.bounds).width>o.height?new zc(o.left+(o.width-o.height)/2,o.top,o.height,o.height):o.width0)n.textNodes.push(new Tf(t,i,n.styles));else if(og(i))if(mg(i)&&i.assignedNodes)i.assignedNodes().forEach(function(e){return Jf(t,e,n,r)});else{var A=tg(t,i);A.styles.isVisible()&&(ng(i,A,r)?A.flags|=4:rg(A.styles)&&(A.flags|=2),-1!==Zf.indexOf(i.tagName)&&(A.flags|=8),n.elements.push(A),i.slot,i.shadowRoot?Jf(t,i.shadowRoot,A,r):pg(i)||ug(i)||vg(i)||Jf(t,i,A,r))}},tg=function(t,e){return fg(e)?new Pf(t,e):dg(e)?new Df(t,e):ug(e)?new Rf(t,e):ag(e)?new Hf(t,e):cg(e)?new _f(t,e):lg(e)?new Yf(t,e):vg(e)?new Xf(t,e):pg(e)?new qf(t,e):gg(e)?new $f(t,e):new ef(t,e)},eg=function(t,e){var n=tg(t,e);return n.flags|=4,Jf(t,e,n,n),n},ng=function(t,e,n){return e.styles.isPositionedWithZIndex()||e.styles.opacity<1||e.styles.isTransformed()||hg(t)&&n.styles.isTransparent()},rg=function(t){return t.isPositioned()||t.isFloating()},ig=function(t){return t.nodeType===Node.TEXT_NODE},og=function(t){return t.nodeType===Node.ELEMENT_NODE},Ag=function(t){return og(t)&&void 0!==t.style&&!sg(t)},sg=function(t){return"object"==typeof t.className},ag=function(t){return"LI"===t.tagName},cg=function(t){return"OL"===t.tagName},lg=function(t){return"INPUT"===t.tagName},ug=function(t){return"svg"===t.tagName},hg=function(t){return"BODY"===t.tagName},dg=function(t){return"CANVAS"===t.tagName},fg=function(t){return"IMG"===t.tagName},gg=function(t){return"IFRAME"===t.tagName},pg=function(t){return"TEXTAREA"===t.tagName},vg=function(t){return"SELECT"===t.tagName},mg=function(t){return"SLOT"===t.tagName},yg={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},wg={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},bg={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},Bg={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},Eg=function(t,e,n,r,i,o){return tn?Ng(t,i,o.length>0):r.integers.reduce(function(e,n,i){for(;t>=n;)t-=n,e+=r.values[i];return e},"")+o},xg=function(t,e,n,r){var i="";do{n||t--,i=r(t)+i,t/=e}while(t*e>=e);return i},Cg=function(t,e,n,r,i){var o=n-e+1;return(t<0?"-":"")+(xg(Math.abs(t),o,r,function(t){return Yc(Math.floor(t%o)+e)})+i)},Mg=function(t,e,n){void 0===n&&(n=". ");var r=e.length;return xg(Math.abs(t),r,!1,function(t){return e[Math.floor(t%r)]})+n},Fg=function(t,e,n,r,i,o){if(t<-9999||t>9999)return Ng(t,4,i.length>0);var A=Math.abs(t),s=i;if(0===A)return e[0]+s;for(var a=0;A>0&&a<=4;a++){var c=A%10;0===c&&Vd(o,1)&&""!==s?s=e[c]+s:c>1||1===c&&0===a||1===c&&1===a&&Vd(o,2)||1===c&&1===a&&Vd(o,4)&&t>100||1===c&&a>1&&Vd(o,8)?s=e[c]+(a>0?n[a-1]:"")+s:1===c&&a>0&&(s=n[a-1]+s),A=Math.floor(A/10)}return(t<0?r:"")+s},kg="十百千萬",Sg="拾佰仟萬",Qg="マイナス",Ug="마이너스",Ng=function(t,e,n){var r=n?". ":"",i=n?"、":"",o=n?", ":"",A=n?" ":"";switch(e){case 0:return"•"+A;case 1:return"◦"+A;case 2:return"◾"+A;case 5:var s=Cg(t,48,57,!0,r);return s.length<4?"0"+s:s;case 4:return Mg(t,"〇一二三四五六七八九",i);case 6:return Eg(t,1,3999,yg,3,r).toLowerCase();case 7:return Eg(t,1,3999,yg,3,r);case 8:return Cg(t,945,969,!1,r);case 9:return Cg(t,97,122,!1,r);case 10:return Cg(t,65,90,!1,r);case 11:return Cg(t,1632,1641,!0,r);case 12:case 49:return Eg(t,1,9999,wg,3,r);case 35:return Eg(t,1,9999,wg,3,r).toLowerCase();case 13:return Cg(t,2534,2543,!0,r);case 14:case 30:return Cg(t,6112,6121,!0,r);case 15:return Mg(t,"子丑寅卯辰巳午未申酉戌亥",i);case 16:return Mg(t,"甲乙丙丁戊己庚辛壬癸",i);case 17:case 48:return Fg(t,"零一二三四五六七八九",kg,"負",i,14);case 47:return Fg(t,"零壹貳參肆伍陸柒捌玖",Sg,"負",i,15);case 42:return Fg(t,"零一二三四五六七八九",kg,"负",i,14);case 41:return Fg(t,"零壹贰叁肆伍陆柒捌玖",Sg,"负",i,15);case 26:return Fg(t,"〇一二三四五六七八九","十百千万",Qg,i,0);case 25:return Fg(t,"零壱弐参四伍六七八九","拾百千万",Qg,i,7);case 31:return Fg(t,"영일이삼사오육칠팔구","십백천만",Ug,o,7);case 33:return Fg(t,"零一二三四五六七八九","十百千萬",Ug,o,0);case 32:return Fg(t,"零壹貳參四五六七八九","拾百千",Ug,o,7);case 18:return Cg(t,2406,2415,!0,r);case 20:return Eg(t,1,19999,Bg,3,r);case 21:return Cg(t,2790,2799,!0,r);case 22:return Cg(t,2662,2671,!0,r);case 22:return Eg(t,1,10999,bg,3,r);case 23:return Mg(t,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return Mg(t,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return Cg(t,3302,3311,!0,r);case 28:return Mg(t,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",i);case 29:return Mg(t,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",i);case 34:return Cg(t,3792,3801,!0,r);case 37:return Cg(t,6160,6169,!0,r);case 38:return Cg(t,4160,4169,!0,r);case 39:return Cg(t,2918,2927,!0,r);case 40:return Cg(t,1776,1785,!0,r);case 43:return Cg(t,3046,3055,!0,r);case 44:return Cg(t,3174,3183,!0,r);case 45:return Cg(t,3664,3673,!0,r);case 46:return Cg(t,3872,3881,!0,r);default:return Cg(t,48,57,!0,r)}};!function(t){t[t.BEFORE=0]="BEFORE",t[t.AFTER=1]="AFTER"}(uf||(uf={}));var Tg,Og=function(){function t(){}return t.getOrigin=function(e){var n=t._link;return n?(n.href=e,n.href=n.href,n.protocol+n.hostname+n.port):"about:blank"},t.isSameOrigin=function(e){return t.getOrigin(e)===t._origin},t.setContext=function(e){t._link=e.document.createElement("a"),t._origin=t.getOrigin(e.location.href)},t._origin="about:blank",t}(),Ig=function(){function t(t,e){this.type=0,this.x=t,this.y=e}return t.prototype.add=function(e,n){return new t(this.x+e,this.y+n)},t}(),Lg=function(t,e,n){return new Ig(t.x+(e.x-t.x)*n,t.y+(e.y-t.y)*n)},Pg=function(){function t(t,e,n,r){this.type=1,this.start=t,this.startControl=e,this.endControl=n,this.end=r}return t.prototype.subdivide=function(e,n){var r=Lg(this.start,this.startControl,e),i=Lg(this.startControl,this.endControl,e),o=Lg(this.endControl,this.end,e),A=Lg(r,i,e),s=Lg(i,o,e),a=Lg(A,s,e);return n?new t(this.start,r,A,a):new t(a,s,o,this.end)},t.prototype.add=function(e,n){return new t(this.start.add(e,n),this.startControl.add(e,n),this.endControl.add(e,n),this.end.add(e,n))},t.prototype.reverse=function(){return new t(this.end,this.endControl,this.startControl,this.start)},t}(),Dg=function(t){return 1===t.type},Rg=function(t){var e=t.styles,n=t.bounds,r=_u(e.borderTopLeftRadius,n.width,n.height),i=r[0],o=r[1],A=_u(e.borderTopRightRadius,n.width,n.height),s=A[0],a=A[1],c=_u(e.borderBottomRightRadius,n.width,n.height),l=c[0],u=c[1],h=_u(e.borderBottomLeftRadius,n.width,n.height),d=h[0],f=h[1],g=[];g.push((i+s)/n.width),g.push((d+l)/n.width),g.push((o+f)/n.height),g.push((a+u)/n.height);var p=Math.max.apply(Math,g);p>1&&(i/=p,o/=p,s/=p,a/=p,l/=p,u/=p,d/=p,f/=p);var v=n.width-s,m=n.height-u,y=n.width-l,w=n.height-f,b=e.borderTopWidth,B=e.borderRightWidth,E=e.borderBottomWidth,x=e.borderLeftWidth,C=Gu(e.paddingTop,t.bounds.width),M=Gu(e.paddingRight,t.bounds.width),F=Gu(e.paddingBottom,t.bounds.width),k=Gu(e.paddingLeft,t.bounds.width);this.topLeftBorderDoubleOuterBox=i>0||o>0?Hg(n.left+x/3,n.top+b/3,i-x/3,o-b/3,Tg.TOP_LEFT):new Ig(n.left+x/3,n.top+b/3),this.topRightBorderDoubleOuterBox=i>0||o>0?Hg(n.left+v,n.top+b/3,s-B/3,a-b/3,Tg.TOP_RIGHT):new Ig(n.left+n.width-B/3,n.top+b/3),this.bottomRightBorderDoubleOuterBox=l>0||u>0?Hg(n.left+y,n.top+m,l-B/3,u-E/3,Tg.BOTTOM_RIGHT):new Ig(n.left+n.width-B/3,n.top+n.height-E/3),this.bottomLeftBorderDoubleOuterBox=d>0||f>0?Hg(n.left+x/3,n.top+w,d-x/3,f-E/3,Tg.BOTTOM_LEFT):new Ig(n.left+x/3,n.top+n.height-E/3),this.topLeftBorderDoubleInnerBox=i>0||o>0?Hg(n.left+2*x/3,n.top+2*b/3,i-2*x/3,o-2*b/3,Tg.TOP_LEFT):new Ig(n.left+2*x/3,n.top+2*b/3),this.topRightBorderDoubleInnerBox=i>0||o>0?Hg(n.left+v,n.top+2*b/3,s-2*B/3,a-2*b/3,Tg.TOP_RIGHT):new Ig(n.left+n.width-2*B/3,n.top+2*b/3),this.bottomRightBorderDoubleInnerBox=l>0||u>0?Hg(n.left+y,n.top+m,l-2*B/3,u-2*E/3,Tg.BOTTOM_RIGHT):new Ig(n.left+n.width-2*B/3,n.top+n.height-2*E/3),this.bottomLeftBorderDoubleInnerBox=d>0||f>0?Hg(n.left+2*x/3,n.top+w,d-2*x/3,f-2*E/3,Tg.BOTTOM_LEFT):new Ig(n.left+2*x/3,n.top+n.height-2*E/3),this.topLeftBorderStroke=i>0||o>0?Hg(n.left+x/2,n.top+b/2,i-x/2,o-b/2,Tg.TOP_LEFT):new Ig(n.left+x/2,n.top+b/2),this.topRightBorderStroke=i>0||o>0?Hg(n.left+v,n.top+b/2,s-B/2,a-b/2,Tg.TOP_RIGHT):new Ig(n.left+n.width-B/2,n.top+b/2),this.bottomRightBorderStroke=l>0||u>0?Hg(n.left+y,n.top+m,l-B/2,u-E/2,Tg.BOTTOM_RIGHT):new Ig(n.left+n.width-B/2,n.top+n.height-E/2),this.bottomLeftBorderStroke=d>0||f>0?Hg(n.left+x/2,n.top+w,d-x/2,f-E/2,Tg.BOTTOM_LEFT):new Ig(n.left+x/2,n.top+n.height-E/2),this.topLeftBorderBox=i>0||o>0?Hg(n.left,n.top,i,o,Tg.TOP_LEFT):new Ig(n.left,n.top),this.topRightBorderBox=s>0||a>0?Hg(n.left+v,n.top,s,a,Tg.TOP_RIGHT):new Ig(n.left+n.width,n.top),this.bottomRightBorderBox=l>0||u>0?Hg(n.left+y,n.top+m,l,u,Tg.BOTTOM_RIGHT):new Ig(n.left+n.width,n.top+n.height),this.bottomLeftBorderBox=d>0||f>0?Hg(n.left,n.top+w,d,f,Tg.BOTTOM_LEFT):new Ig(n.left,n.top+n.height),this.topLeftPaddingBox=i>0||o>0?Hg(n.left+x,n.top+b,Math.max(0,i-x),Math.max(0,o-b),Tg.TOP_LEFT):new Ig(n.left+x,n.top+b),this.topRightPaddingBox=s>0||a>0?Hg(n.left+Math.min(v,n.width-B),n.top+b,v>n.width+B?0:Math.max(0,s-B),Math.max(0,a-b),Tg.TOP_RIGHT):new Ig(n.left+n.width-B,n.top+b),this.bottomRightPaddingBox=l>0||u>0?Hg(n.left+Math.min(y,n.width-x),n.top+Math.min(m,n.height-E),Math.max(0,l-B),Math.max(0,u-E),Tg.BOTTOM_RIGHT):new Ig(n.left+n.width-B,n.top+n.height-E),this.bottomLeftPaddingBox=d>0||f>0?Hg(n.left+x,n.top+Math.min(w,n.height-E),Math.max(0,d-x),Math.max(0,f-E),Tg.BOTTOM_LEFT):new Ig(n.left+x,n.top+n.height-E),this.topLeftContentBox=i>0||o>0?Hg(n.left+x+k,n.top+b+C,Math.max(0,i-(x+k)),Math.max(0,o-(b+C)),Tg.TOP_LEFT):new Ig(n.left+x+k,n.top+b+C),this.topRightContentBox=s>0||a>0?Hg(n.left+Math.min(v,n.width+x+k),n.top+b+C,v>n.width+x+k?0:s-x+k,a-(b+C),Tg.TOP_RIGHT):new Ig(n.left+n.width-(B+M),n.top+b+C),this.bottomRightContentBox=l>0||u>0?Hg(n.left+Math.min(y,n.width-(x+k)),n.top+Math.min(m,n.height+b+C),Math.max(0,l-(B+M)),u-(E+F),Tg.BOTTOM_RIGHT):new Ig(n.left+n.width-(B+M),n.top+n.height-(E+F)),this.bottomLeftContentBox=d>0||f>0?Hg(n.left+x+k,n.top+w,Math.max(0,d-(x+k)),f-(E+F),Tg.BOTTOM_LEFT):new Ig(n.left+x+k,n.top+n.height-(E+F))};!function(t){t[t.TOP_LEFT=0]="TOP_LEFT",t[t.TOP_RIGHT=1]="TOP_RIGHT",t[t.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",t[t.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(Tg||(Tg={}));var Hg=function(t,e,n,r,i){var o=(Math.sqrt(2)-1)/3*4,A=n*o,s=r*o,a=t+n,c=e+r;switch(i){case Tg.TOP_LEFT:return new Pg(new Ig(t,c),new Ig(t,c-s),new Ig(a-A,e),new Ig(a,e));case Tg.TOP_RIGHT:return new Pg(new Ig(t,e),new Ig(t+A,e),new Ig(a,c-s),new Ig(a,c));case Tg.BOTTOM_RIGHT:return new Pg(new Ig(a,e),new Ig(a,e+s),new Ig(t+A,c),new Ig(t,c));case Tg.BOTTOM_LEFT:default:return new Pg(new Ig(a,c),new Ig(a-A,c),new Ig(t,e+s),new Ig(t,e))}},_g=function(t){return[t.topLeftBorderBox,t.topRightBorderBox,t.bottomRightBorderBox,t.bottomLeftBorderBox]},Gg=function(t){return[t.topLeftPaddingBox,t.topRightPaddingBox,t.bottomRightPaddingBox,t.bottomLeftPaddingBox]},Kg=function(t,e,n){this.offsetX=t,this.offsetY=e,this.matrix=n,this.type=0,this.target=6},jg=function(t,e){this.path=t,this.target=e,this.type=1},zg=function(t){this.opacity=t,this.type=2,this.target=6},Vg=function(t){return 1===t.type},Wg=function(t,e){return t.length===e.length&&t.some(function(t,n){return t===e[n]})},Yg=function(t){this.element=t,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]},Xg=function(){function t(t,e){if(this.container=t,this.parent=e,this.effects=[],this.curves=new Rg(this.container),this.container.styles.opacity<1&&this.effects.push(new zg(this.container.styles.opacity)),null!==this.container.styles.transform){var n=this.container.bounds.left+this.container.styles.transformOrigin[0].number,r=this.container.bounds.top+this.container.styles.transformOrigin[1].number,i=this.container.styles.transform;this.effects.push(new Kg(n,r,i))}if(0!==this.container.styles.overflowX){var o=_g(this.curves),A=Gg(this.curves);Wg(o,A)?this.effects.push(new jg(o,6)):(this.effects.push(new jg(o,2)),this.effects.push(new jg(A,4)))}}return t.prototype.getEffects=function(t){for(var e=-1===[2,3].indexOf(this.container.styles.position),n=this.parent,r=this.effects.slice(0);n;){var i=n.effects.filter(function(t){return!Vg(t)});if(e||0!==n.container.styles.position||!n.parent){if(r.unshift.apply(r,i),e=-1===[2,3].indexOf(n.container.styles.position),0!==n.container.styles.overflowX){var o=_g(n.curves),A=Gg(n.curves);Wg(o,A)||r.unshift(new jg(A,6))}}else r.unshift.apply(r,i);n=n.parent}return r.filter(function(e){return Vd(e.target,t)})},t}(),qg=function(t,e,n,r){t.container.elements.forEach(function(i){var o=Vd(i.flags,4),A=Vd(i.flags,2),s=new Xg(i,t);Vd(i.styles.display,2048)&&r.push(s);var a=Vd(i.flags,8)?[]:r;if(o||A){var c=o||i.styles.isPositioned()?n:e,l=new Yg(s);if(i.styles.isPositioned()||i.styles.opacity<1||i.styles.isTransformed()){var u=i.styles.zIndex.order;if(u<0){var h=0;c.negativeZIndex.some(function(t,e){return u>t.element.container.styles.zIndex.order?(h=e,!1):h>0}),c.negativeZIndex.splice(h,0,l)}else if(u>0){var d=0;c.positiveZIndex.some(function(t,e){return u>=t.element.container.styles.zIndex.order?(d=e+1,!1):d>0}),c.positiveZIndex.splice(d,0,l)}else c.zeroOrAutoZIndexOrTransformedOrOpacity.push(l)}else i.styles.isFloating()?c.nonPositionedFloats.push(l):c.nonPositionedInlineLevel.push(l);qg(s,l,o?l:n,a)}else i.styles.isInlineLevel()?e.inlineLevel.push(s):e.nonInlineLevel.push(s),qg(s,e,n,a);Vd(i.flags,8)&&$g(i,a)})},$g=function(t,e){for(var n=t instanceof _f?t.start:1,r=t instanceof _f&&t.reversed,i=0;i0&&t.intrinsicHeight>0){var r=np(t),i=Gg(e);this.path(i),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(n,0,0,t.intrinsicWidth,t.intrinsicHeight,r.left,r.top,r.width,r.height),this.ctx.restore()}},e.prototype.renderNodeContent=function(t){return Kc(this,0,void 0,function(){var n,r,i,o,A,s,a,c,l,u,h,d,f,g,p,v,m,y;return jc(this,function(w){switch(w.label){case 0:this.applyEffects(t.getEffects(4)),n=t.container,r=t.curves,i=n.styles,o=0,A=n.textNodes,w.label=1;case 1:return o0&&E>0&&(v=r.ctx.createPattern(f,"repeat"),r.renderRepeat(y,v,C,M))):function(t){return 2===t.type}(n)&&(m=rp(t,e,[null,null,null]),y=m[0],w=m[1],b=m[2],B=m[3],E=m[4],x=0===n.position.length?[Ru]:n.position,C=Gu(x[0],B),M=Gu(x[x.length-1],E),F=function(t,e,n,r,i){var o=0,A=0;switch(t.size){case 0:0===t.shape?o=A=Math.min(Math.abs(e),Math.abs(e-r),Math.abs(n),Math.abs(n-i)):1===t.shape&&(o=Math.min(Math.abs(e),Math.abs(e-r)),A=Math.min(Math.abs(n),Math.abs(n-i)));break;case 2:if(0===t.shape)o=A=Math.min(uh(e,n),uh(e,n-i),uh(e-r,n),uh(e-r,n-i));else if(1===t.shape){var s=Math.min(Math.abs(n),Math.abs(n-i))/Math.min(Math.abs(e),Math.abs(e-r)),a=hh(r,i,e,n,!0),c=a[0],l=a[1];A=s*(o=uh(c-e,(l-n)/s))}break;case 1:0===t.shape?o=A=Math.max(Math.abs(e),Math.abs(e-r),Math.abs(n),Math.abs(n-i)):1===t.shape&&(o=Math.max(Math.abs(e),Math.abs(e-r)),A=Math.max(Math.abs(n),Math.abs(n-i)));break;case 3:if(0===t.shape)o=A=Math.max(uh(e,n),uh(e,n-i),uh(e-r,n),uh(e-r,n-i));else if(1===t.shape){s=Math.max(Math.abs(n),Math.abs(n-i))/Math.max(Math.abs(e),Math.abs(e-r));var u=hh(r,i,e,n,!1);c=u[0],l=u[1],A=s*(o=uh(c-e,(l-n)/s))}}return Array.isArray(t.size)&&(o=Gu(t.size[0],r),A=2===t.size.length?Gu(t.size[1],i):o),[o,A]}(n,C,M,B,E),k=F[0],S=F[1],k>0&&S>0&&(Q=r.ctx.createRadialGradient(w+C,b+M,0,w+C,b+M,k),ch(n.stops,2*k).forEach(function(t){return Q.addColorStop(t.stop,$u(t.color))}),r.path(y),r.ctx.fillStyle=Q,k!==S?(U=t.bounds.left+.5*t.bounds.width,N=t.bounds.top+.5*t.bounds.height,O=1/(T=S/k),r.ctx.save(),r.ctx.translate(U,N),r.ctx.transform(1,0,0,T,0,0),r.ctx.translate(-U,-N),r.ctx.fillRect(w,O*(b-N)+N,B,E*O),r.ctx.restore()):r.ctx.fill())),I.label=6;case 6:return e--,[2]}})},r=this,i=0,o=t.styles.backgroundImage.slice(0).reverse(),s.label=1;case 1:return i0?2!==a.style?[3,5]:[4,this.renderDashedDottedBorder(a.color,a.width,o,t.curves,2)]:[3,11]:[3,13];case 4:return l.sent(),[3,11];case 5:return 3!==a.style?[3,7]:[4,this.renderDashedDottedBorder(a.color,a.width,o,t.curves,3)];case 6:return l.sent(),[3,11];case 7:return 4!==a.style?[3,9]:[4,this.renderDoubleBorder(a.color,a.width,o,t.curves)];case 8:return l.sent(),[3,11];case 9:return[4,this.renderSolidBorder(a.color,o,t.curves)];case 10:l.sent(),l.label=11;case 11:o++,l.label=12;case 12:return A++,[3,3];case 13:return[2]}})})},e.prototype.renderDashedDottedBorder=function(t,e,n,r,i){return Kc(this,0,void 0,function(){var o,A,s,a,c,l,u,h,d,f,g,p,v,m,y,w;return jc(this,function(b){return this.ctx.save(),o=function(t,e){switch(e){case 0:return Jg(t.topLeftBorderStroke,t.topRightBorderStroke);case 1:return Jg(t.topRightBorderStroke,t.bottomRightBorderStroke);case 2:return Jg(t.bottomRightBorderStroke,t.bottomLeftBorderStroke);default:return Jg(t.bottomLeftBorderStroke,t.topLeftBorderStroke)}}(r,n),A=Zg(r,n),2===i&&(this.path(A),this.ctx.clip()),Dg(A[0])?(s=A[0].start.x,a=A[0].start.y):(s=A[0].x,a=A[0].y),Dg(A[1])?(c=A[1].end.x,l=A[1].end.y):(c=A[1].x,l=A[1].y),u=0===n||2===n?Math.abs(s-c):Math.abs(a-l),this.ctx.beginPath(),3===i?this.formatPath(o):this.formatPath(A.slice(0,2)),h=e<3?3*e:2*e,d=e<3?2*e:e,3===i&&(h=e,d=e),f=!0,u<=2*h?f=!1:u<=2*h+d?(h*=g=u/(2*h+d),d*=g):(p=Math.floor((u+d)/(h+d)),v=(u-p*h)/(p-1),d=(m=(u-(p+1)*h)/p)<=0||Math.abs(d-v)0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)}},{key:"totalDuration",get:function(){return this._totalDuration}},{key:"_needsTick",get:function(){return this.pending||"running"===this.playState||!this._finishedFlag}},{key:"updatePromises",value:function(){var t;if(null!==(t=this.effect.target)&&void 0!==t&&t.destroyed)return this.readyPromise=void 0,this.finishedPromise=void 0,!1;var e=this.oldPlayState,n=this.pending?"pending":this.playState;return this.readyPromise&&n!==e&&("idle"===n?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===e?this.resolveReadyPromise():"pending"===n&&(this.readyPromise=void 0)),this.finishedPromise&&n!==e&&("idle"===n?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===n?this.resolveFinishedPromise():"finished"===e&&(this.finishedPromise=void 0)),this.oldPlayState=n,this.readyPromise||this.finishedPromise}},{key:"play",value:function(){this.updatePromises(),this._paused=!1,(this._isFinished||this._idle)&&(this.rewind(),this._startTime=null),this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this),-1===this.timeline.animations.indexOf(this)&&this.timeline.animations.push(this),this.updatePromises()}},{key:"pause",value:function(){this.updatePromises(),this.currentTime&&(this._holdTime=this.currentTime),this._isFinished||this._paused||this._idle?this._idle&&(this.rewind(),this._idle=!1):this.currentTimePending=!0,this._startTime=null,this._paused=!0,this.updatePromises()}},{key:"finish",value:function(){this.updatePromises(),this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this.currentTimePending=!1,this.timeline.applyDirtiedAnimation(this),this.updatePromises())}},{key:"cancel",value:function(){var t=this;if(this.updatePromises(),this._inEffect&&(this._inEffect=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=null,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new mp(null,this,this.currentTime,null);setTimeout(function(){t.oncancel(e)})}}},{key:"reverse",value:function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()}},{key:"updatePlaybackRate",value:function(t){this.playbackRate=t}},{key:"targetAnimations",value:function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()}},{key:"markTarget",value:function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)}},{key:"unmarkTarget",value:function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)}},{key:"tick",value:function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))}},{key:"rewind",value:function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}}},{key:"persist",value:function(){throw new Error(Cr)}},{key:"addEventListener",value:function(t,e,n){throw new Error(Cr)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(Cr)}},{key:"dispatchEvent",value:function(t){throw new Error(Cr)}},{key:"commitStyles",value:function(){throw new Error(Cr)}},{key:"ensureAlive",value:function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!(null===(t=this.effect)||void 0===t||!t.update(-1)):this._inEffect=!(null===(e=this.effect)||void 0===e||!e.update(this.currentTime));this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))}},{key:"tickCurrentTime",value:function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())}},{key:"fireEvents",value:function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new mp(null,this,this.currentTime,t);setTimeout(function(){e.onfinish&&e.onfinish(n)})}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new mp(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),bp=.1,Bp="function"==typeof Float32Array,Ep=function(t,e){return 1-3*e+3*t},xp=function(t,e){return 3*e-6*t},Cp=function(t){return 3*t},Mp=function(t,e,n){return((Ep(e,n)*t+xp(e,n))*t+Cp(e))*t},Fp=function(t,e,n){return 3*Ep(e,n)*t*t+2*xp(e,n)*t+Cp(e)},kp=function(t,e,n,r){if(!(t>=0&&t<=1&&n>=0&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=Bp?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Mp(o*bp,t,n);var A=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=bp;--o;var A=r+(e-i[o])/(i[o+1]-i[o])*bp,s=Fp(A,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=Fp(e,n,r);if(0===o)return e;e-=(Mp(e,n,r)-t)/o}return e}(e,A,t,n):0===s?A:function(t,e,n,r,i){var o,A,s=0;do{(o=Mp(A=e+(n-e)/2,r,i)-t)>0?n=A:e=A}while(Math.abs(o)>1e-7&&++s<10);return A}(e,r,r+bp,t,n)};return function(t){return 0===t||1===t?t:Mp(A(t),e,r)}},Sp=function(t){return Math.pow(t,2)},Qp=function(t){return Math.pow(t,3)},Up=function(t){return Math.pow(t,4)},Np=function(t){return Math.pow(t,5)},Tp=function(t){return Math.pow(t,6)},Op=function(t){return 1-Math.cos(t*Math.PI/2)},Ip=function(t){return 1-Math.sqrt(1-t*t)},Lp=function(t){return t*t*(3*t-2)},Pp=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},Dp=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?1:n,i=e[1],o=void 0===i?.5:i,A=ne(Number(r),1,10),s=ne(Number(o),.1,2);return 0===t||1===t?t:-A*Math.pow(2,10*(t-1))*Math.sin((t-1-s/(2*Math.PI)*Math.asin(1/A))*(2*Math.PI)/s)},Rp=function(t){var e=arguments.length>2?arguments[2]:void 0,n=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),r=n[0],i=void 0===r?1:r,o=n[1],A=void 0===o?100:o,s=n[2],a=void 0===s?10:s,c=n[3],l=void 0===c?0:c;i=ne(i,.1,1e3),A=ne(A,.1,1e3),a=ne(a,.1,1e3),l=ne(l,.1,1e3);var u=Math.sqrt(A/i),h=a/(2*Math.sqrt(A*i)),d=h<1?u*Math.sqrt(1-h*h):0,f=h<1?(h*u-l)/d:-l+u,g=e?e*t/1e3:t;return g=h<1?Math.exp(-g*h*u)*(1*Math.cos(d*g)+f*Math.sin(d*g)):(1+f*g)*Math.exp(-g*u),0===t||1===t?t:1-g},Hp=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?10:n;return("start"===e[1]?Math.ceil:Math.floor)(ne(t,0,1)*r)/r},_p=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return kp(n,r,i,o)(t)},Gp=kp(.42,0,1,1),Kp=function(t){return function(e){return 1-t(1-e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],arguments.length>2?arguments[2]:void 0)}},jp=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},zp=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Vp={steps:Hp,"step-start":function(t){return Hp(t,[1,"start"])},"step-end":function(t){return Hp(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":_p,ease:function(t){return _p(t,[.25,.1,.25,1])},in:Gp,out:Kp(Gp),"in-out":jp(Gp),"out-in":zp(Gp),"in-quad":Sp,"out-quad":Kp(Sp),"in-out-quad":jp(Sp),"out-in-quad":zp(Sp),"in-cubic":Qp,"out-cubic":Kp(Qp),"in-out-cubic":jp(Qp),"out-in-cubic":zp(Qp),"in-quart":Up,"out-quart":Kp(Up),"in-out-quart":jp(Up),"out-in-quart":zp(Up),"in-quint":Np,"out-quint":Kp(Np),"in-out-quint":jp(Np),"out-in-quint":zp(Np),"in-expo":Tp,"out-expo":Kp(Tp),"in-out-expo":jp(Tp),"out-in-expo":zp(Tp),"in-sine":Op,"out-sine":Kp(Op),"in-out-sine":jp(Op),"out-in-sine":zp(Op),"in-circ":Ip,"out-circ":Kp(Ip),"in-out-circ":jp(Ip),"out-in-circ":zp(Ip),"in-back":Lp,"out-back":Kp(Lp),"in-out-back":jp(Lp),"out-in-back":zp(Lp),"in-bounce":Pp,"out-bounce":Kp(Pp),"in-out-bounce":jp(Pp),"out-in-bounce":zp(Pp),"in-elastic":Dp,"out-elastic":Kp(Dp),"in-out-elastic":jp(Dp),"out-in-elastic":zp(Dp),spring:Rp,"spring-in":Rp,"spring-out":Kp(Rp),"spring-in-out":jp(Rp),"spring-out-in":zp(Rp)},Wp=function(t){return t};function Yp(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Xp="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",qp=new RegExp("cubic-bezier\\(".concat(Xp,",").concat(Xp,",").concat(Xp,",").concat(Xp,"\\)")),$p=/steps\(\s*(\d+)\s*\)/,Zp=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Jp(t){var e=qp.exec(t);if(e)return kp.apply(void 0,u(e.slice(1).map(Number)));var n=$p.exec(t);if(n)return Yp(Number(n[1]),0);var r=Zp.exec(t);return r?Yp(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Vp[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,function(t){return"-".concat(t.toLowerCase())})).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||Vp.linear}function tv(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}function ev(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e=Math.min(n.delay+t+n.endDelay,r)?2:3}(t,e,n),i=function(t,e,n,r,i){switch(r){case 1:return"backwards"===e||"both"===e?0:null;case 3:return n-i;case 2:return"forwards"===e||"both"===e?t:null;case 0:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,A=function(t,e,n,r,i){var o=i;return 0===t?1!==e&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var A=t===1/0?e%1:t%1;return 0!==A||2!==n||0===r||0===i&&0!==o||(A=1),A}(A,n.iterationStart,r,n.iterations,i,o),a=function(t,e,n,r){return 2===t&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,A),c=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,a,s);return n.currentIteration=a,n.progress=c,n.easingFunction(c)}function nv(t,e,n){var r=function(t,e){for(var n={},r=0;r=t.applyFrom&&e1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n}),r=!0,i=-1/0,o=0;o=0&&Number(t.offset)<=1}),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),A=1;A90)return this;this.computeMatrix()}return this._getAxes(),this.type===jr.ORBITING||this.type===jr.EXPLORING?this._getPosition():this.type===jr.TRACKING&&this._getFocalPoint(),this._update(),this}},{key:"pan",value:function(t,e){var n=Sr(t,e,0),r=ct(this.position);return ft(r,r,pt(at(),this.right,n[0])),ft(r,r,pt(at(),this.up,n[1])),this._setPosition(r),this.triggerUpdate(),this}},{key:"dolly",value:function(t){var e=this.forward,n=ct(this.position),r=this.dollyingStep,i=this.distance+t*this.dollyingStep;return r=Math.max(Math.min(i,this.maxDistance),this.minDistance)-this.distance,n[0]+=r*e[0],n[1]+=r*e[1],n[2]+=r*e[2],this._setPosition(n),this.type===jr.ORBITING||this.type===jr.EXPLORING?this._getDistance():this.type===jr.TRACKING&&ft(this.focalPoint,n,this.distanceVector),this.triggerUpdate(),this}},{key:"cancelLandmarkAnimation",value:function(){void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID)}},{key:"createLandmark",value:function(t){var e,n,r,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},A=o.position,s=void 0===A?this.position:A,a=o.focalPoint,c=void 0===a?this.focalPoint:a,l=o.roll,u=o.zoom,h=new Ua.CameraContribution;h.setType(this.type,void 0),h.setPosition(s[0],null!==(e=s[1])&&void 0!==e?e:this.position[1],null!==(n=s[2])&&void 0!==n?n:this.position[2]),h.setFocalPoint(c[0],null!==(r=c[1])&&void 0!==r?r:this.focalPoint[1],null!==(i=c[2])&&void 0!==i?i:this.focalPoint[2]),h.setRoll(null!=l?l:this.roll),h.setZoom(null!=u?u:this.zoom);var d={name:t,matrix:M(h.getWorldTransform()),right:ct(h.right),up:ct(h.up),forward:ct(h.forward),position:ct(h.getPosition()),focalPoint:ct(h.getFocalPoint()),distanceVector:ct(h.getDistanceVector()),distance:h.getDistance(),dollyingStep:h.getDollyingStep(),azimuth:h.getAzimuth(),elevation:h.getElevation(),roll:h.getRoll(),relAzimuth:h.relAzimuth,relElevation:h.relElevation,relRoll:h.relRoll,zoom:h.getZoom()};return this.landmarks.push(d),d}},{key:"gotoLandmark",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Jt(t)?this.landmarks.find(function(e){return e.name===t}):t;if(r){var i=re(n)?{duration:n}:n,o=i.easing,A=void 0===o?"linear":o,s=i.duration,a=void 0===s?100:s,c=i.easingFunction,l=void 0===c?void 0:c,u=i.onfinish,h=void 0===u?void 0:u,d=i.onframe,f=void 0===d?void 0:d;this.cancelLandmarkAnimation();var g,p=r.position,v=r.focalPoint,m=r.zoom,y=r.roll,w=l||Ua.EasingFunction(A),b=function(){e.setFocalPoint(v),e.setPosition(p),e.setRoll(y),e.setZoom(m),e.computeMatrix(),e.triggerUpdate(),null==h||h()};if(0===a)return b();var B=function(t){void 0===g&&(g=t);var n=t-g;if(n>=a)b();else{var r,i,o=w(n/a),A=at(),s=at();if(wt(A,e.focalPoint,v,o),wt(s,e.position,p,o),i=e.roll*(1-o)+y*o,r=e.zoom*(1-o)+m*o,e.setFocalPoint(A),e.setPosition(s),e.setRoll(i),e.setZoom(r),xt(A,v)+xt(s,p)<=.01&&void 0===m&&void 0===y)return b();e.computeMatrix(),e.triggerUpdate(),nQ*Q+U*U&&(x=M,C=F),{cx:x,cy:C,x0:-l,y0:-u,x1:x*(i/b-1),y1:C*(i/b-1)}}function Nv(t,e){return(e=e<0&&t>=0?e+bv:e)-t<=wv?0:1}var Tv=function(t){function e(t){var n;return A(this,e),(n=g(this,e,[t])).updatePath(),n}return v(e,t),a(e,[{key:"setAttribute",value:function(t,n,r){Un(e,"setAttribute",this)([t,n,r]),["startAngle","endAngle","sr","sr0","radius"].indexOf(t)>-1&&this.updatePath()}},{key:"updatePath",value:function(){var t=this.parsedStyle,n=t.x,r=t.y,i=t.startAngle,o=t.endAngle,A=t.sr,s=t.sr0,a=t.radius,c=this.createPath(n,r,i?Ur(i):0,o?Ur(o):2*Math.PI,A||0,s||0,a||[0,0,0,0]);Un(e,"setAttribute",this)(["d",c])}},{key:"createPath",value:function(t,e,n,r,i,o,A){if(!(i<=0)){var s=Qv(t,e,i,n),a=Qv(t,e,i,r),c=Qv(t,e,o,n),l=Qv(t,e,o,r);if(ie(r-n,2*Math.PI)){var u=Qv(t,e,i,n+Math.PI),h=Qv(t,e,o,n+Math.PI),d=[["M",s.x,s.y],["A",i,i,0,1,1,u.x,u.y],["A",i,i,0,1,1,a.x,a.y],["M",c.x,c.y]];return o&&(d.push(["A",o,o,0,1,0,h.x,h.y]),d.push(["A",o,o,0,1,0,l.x,l.y])),d.push(["M",s.x,s.y]),d.push(["Z"]),d}var f=r-n,g=i*Ev(n),p=i*Bv(n),v=o*Ev(r),y=o*Bv(r),w=i*Ev(r),b=i*Bv(r),B=o*Ev(n),E=o*Bv(n),x=m(A,4),C=x[0],M=x[1],F=x[2],k=x[3],S=(i-o)/2,Q=kv(S,C),U=kv(S,M),N=kv(S,F),T=kv(S,k),O=Fv(Q,U),I=Fv(N,T),L=O,P=I;if((O>Sv||I>Sv)&&fSv){var W=kv(C,L),Y=kv(M,L),X=Uv(B,E,g,p,i,W),q=Uv(w,b,v,y,i,Y);if(V.push(["M",t+X.cx+X.x0,e+X.cy+X.y0]),L0){var J=Cv(X.y0,X.x0),tt=Cv(X.y1,X.x1),et=Qv(t,e,i,tt);V.push(["A",W,W,0,Nv(J,tt),1,et.x,et.y])}var nt=Cv(X.cy+X.y1,X.cx+X.x1),rt=Cv(q.cy+q.y1,q.cx+q.x1),it=Qv(t,e,i,rt);if(V.push(["A",i,i,0,Nv(nt,rt),1,it.x,it.y]),Y>0){var ot=Cv(q.y1,q.x1),At=Cv(q.y0,q.x0);V.push(["A",Y,Y,0,Nv(ot,At),1,t+q.cx+q.x0,e+q.cy+q.y0])}}}else V.push(["M",s.x,s.y]),V.push(["A",i,i,0,z,1,a.x,a.y]);if(oSv){var st=kv(k,P),at=kv(F,P),ct=Uv(v,y,0,0,o-i,at),lt=Uv(0,0,B,E,o-i,st);if(V.push(["L",t+ct.cx+ct.x0,e+ct.cy+ct.y0]),P0){var ft=Cv(ct.y0,ct.x0),gt=Cv(ct.y1,ct.x1),pt=Qv(t,e,o-i,gt);V.push(["A",at,at,0,Nv(ft,gt),1,pt.x,pt.y])}var vt=Cv(ct.cy+ct.y1,ct.cx+ct.x1),mt=Cv(lt.cy+lt.y1,lt.cx+lt.x1),yt=Qv(t,e,o,mt);if(V.push(["A",o,o,0,Nv(mt,vt),0,yt.x,yt.y]),V.push(["L",yt.x,yt.y]),st>0){var wt=Cv(lt.y1,lt.x1),bt=Cv(lt.y0,lt.x0);V.push(["A",st,st,0,Nv(wt,bt),1,t+lt.cx+lt.x0,e+lt.cy+lt.y0])}}}else V.push(["L",l.x,l.y]),V.push(["A",o,o,0,z,0,c.x,c.y]);return V.push(["Z"]),V}}}])}(nc);Tv.PARSED_STYLE_LIST=new Set([].concat(u(nc.PARSED_STYLE_LIST),["x","y","sr","sr0","radius","startAngle","endAngle"]));const Ov={duration:500},Iv={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var Lv,Pv,Dv,Rv,Hv,_v,Gv,Kv,jv;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(Lv||(Lv={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(Pv||(Pv={})),t.CanvasEvent=void 0,function(t){t.CLICK="canvas:click",t.DBLCLICK="canvas:dblclick",t.POINTER_OVER="canvas:pointerover",t.POINTER_LEAVE="canvas:pointerleave",t.POINTER_ENTER="canvas:pointerenter",t.POINTER_MOVE="canvas:pointermove",t.POINTER_OUT="canvas:pointerout",t.POINTER_DOWN="canvas:pointerdown",t.POINTER_UP="canvas:pointerup",t.CONTEXT_MENU="canvas:contextmenu",t.DRAG_START="canvas:dragstart",t.DRAG="canvas:drag",t.DRAG_END="canvas:dragend",t.DRAG_ENTER="canvas:dragenter",t.DRAG_OVER="canvas:dragover",t.DRAG_LEAVE="canvas:dragleave",t.DROP="canvas:drop",t.WHEEL="canvas:wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.ComboEvent=void 0,(Dv=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",Dv.DBLCLICK="combo:dblclick",Dv.POINTER_OVER="combo:pointerover",Dv.POINTER_LEAVE="combo:pointerleave",Dv.POINTER_ENTER="combo:pointerenter",Dv.POINTER_MOVE="combo:pointermove",Dv.POINTER_OUT="combo:pointerout",Dv.POINTER_DOWN="combo:pointerdown",Dv.POINTER_UP="combo:pointerup",Dv.CONTEXT_MENU="combo:contextmenu",Dv.DRAG_START="combo:dragstart",Dv.DRAG="combo:drag",Dv.DRAG_END="combo:dragend",Dv.DRAG_ENTER="combo:dragenter",Dv.DRAG_OVER="combo:dragover",Dv.DRAG_LEAVE="combo:dragleave",Dv.DROP="combo:drop",t.CommonEvent=void 0,(Rv=t.CommonEvent||(t.CommonEvent={})).CLICK="click",Rv.DBLCLICK="dblclick",Rv.POINTER_OVER="pointerover",Rv.POINTER_LEAVE="pointerleave",Rv.POINTER_ENTER="pointerenter",Rv.POINTER_MOVE="pointermove",Rv.POINTER_OUT="pointerout",Rv.POINTER_DOWN="pointerdown",Rv.POINTER_UP="pointerup",Rv.CONTEXT_MENU="contextmenu",Rv.DRAG_START="dragstart",Rv.DRAG="drag",Rv.DRAG_END="dragend",Rv.DRAG_ENTER="dragenter",Rv.DRAG_OVER="dragover",Rv.DRAG_LEAVE="dragleave",Rv.DROP="drop",Rv.KEY_DOWN="keydown",Rv.KEY_UP="keyup",Rv.WHEEL="wheel",Rv.PINCH="pinch",t.ContainerEvent=void 0,(Hv=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",Hv.KEY_UP="keyup",t.EdgeEvent=void 0,(_v=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",_v.DBLCLICK="edge:dblclick",_v.POINTER_OVER="edge:pointerover",_v.POINTER_LEAVE="edge:pointerleave",_v.POINTER_ENTER="edge:pointerenter",_v.POINTER_MOVE="edge:pointermove",_v.POINTER_OUT="edge:pointerout",_v.POINTER_DOWN="edge:pointerdown",_v.POINTER_UP="edge:pointerup",_v.CONTEXT_MENU="edge:contextmenu",_v.DRAG_ENTER="edge:dragenter",_v.DRAG_OVER="edge:dragover",_v.DRAG_LEAVE="edge:dragleave",_v.DROP="edge:drop",t.GraphEvent=void 0,(Gv=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",Gv.AFTER_CANVAS_INIT="aftercanvasinit",Gv.BEFORE_SIZE_CHANGE="beforesizechange",Gv.AFTER_SIZE_CHANGE="aftersizechange",Gv.BEFORE_ELEMENT_CREATE="beforeelementcreate",Gv.AFTER_ELEMENT_CREATE="afterelementcreate",Gv.BEFORE_ELEMENT_UPDATE="beforeelementupdate",Gv.AFTER_ELEMENT_UPDATE="afterelementupdate",Gv.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",Gv.AFTER_ELEMENT_DESTROY="afterelementdestroy",Gv.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",Gv.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",Gv.BEFORE_DRAW="beforedraw",Gv.AFTER_DRAW="afterdraw",Gv.BEFORE_RENDER="beforerender",Gv.AFTER_RENDER="afterrender",Gv.BEFORE_ANIMATE="beforeanimate",Gv.AFTER_ANIMATE="afteranimate",Gv.BEFORE_LAYOUT="beforelayout",Gv.AFTER_LAYOUT="afterlayout",Gv.BEFORE_STAGE_LAYOUT="beforestagelayout",Gv.AFTER_STAGE_LAYOUT="afterstagelayout",Gv.BEFORE_TRANSFORM="beforetransform",Gv.AFTER_TRANSFORM="aftertransform",Gv.BATCH_START="batchstart",Gv.BATCH_END="batchend",Gv.BEFORE_DESTROY="beforedestroy",Gv.AFTER_DESTROY="afterdestroy",Gv.BEFORE_RENDERER_CHANGE="beforerendererchange",Gv.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(Kv=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",Kv.REDO="redo",Kv.CANCEL="cancel",Kv.ADD="add",Kv.CLEAR="clear",Kv.CHANGE="change",t.NodeEvent=void 0,(jv=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",jv.DBLCLICK="node:dblclick",jv.POINTER_OVER="node:pointerover",jv.POINTER_LEAVE="node:pointerleave",jv.POINTER_ENTER="node:pointerenter",jv.POINTER_MOVE="node:pointermove",jv.POINTER_OUT="node:pointerout",jv.POINTER_DOWN="node:pointerdown",jv.POINTER_UP="node:pointerup",jv.CONTEXT_MENU="node:contextmenu",jv.DRAG_START="node:dragstart",jv.DRAG="node:drag",jv.DRAG_END="node:dragend",jv.DRAG_ENTER="node:dragenter",jv.DRAG_OVER="node:dragover",jv.DRAG_LEAVE="node:dragleave",jv.DROP="node:drop";const zv="combo",Vv="tree";var Wv;t.ExtensionCategory=void 0,(Wv=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",Wv.EDGE="edge",Wv.COMBO="combo",Wv.THEME="theme",Wv.PALETTE="palette",Wv.LAYOUT="layout",Wv.BEHAVIOR="behavior",Wv.PLUGIN="plugin",Wv.ANIMATION="animation",Wv.TRANSFORM="transform",Wv.SHAPE="shape";const Yv={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Xv(t,e){var n;const r=null===(n=Yv[t])||void 0===n?void 0:n[e];if(r)return r}const qv="5.1.1";function $v(t){return`[G6 v${qv}] ${t}`}const Zv=t=>{console.warn($v(t))};function Jv(e){const{theme:n}=e;if(!n)return{};const r=Xv(t.ExtensionCategory.THEME,n);return r||(Zv(`The theme of ${n} is not registered.`),{})}function tm(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map(t=>t.finished)]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach(t=>{var r;return null===(r=t[e])||void 0===r?void 0:r.call(t,...n)})},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach(t=>{t[e]=n}),Reflect.set(t,e,n))})}function em(t){const e=t.reduce((t,e)=>(Object.entries(e).forEach(([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)}),t),{});Object.entries(e).forEach(([n,r])=>{(r.length!==t.length||r.some(t=>Kt(t))||r.every(t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&xe(t,r[0])))&&delete e[n]});const n=Object.entries(e).reduce((t,[e,n])=>(n.forEach((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}}),t),[]);return 0!==t.length&&0===n.length&&n.push({_:0},{_:0}),n}function nm(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function rm(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},Ov);return zt(n)&&Object.assign(r,n),zt(e)&&Object.assign(r,e),r}function im(e,n,r,i){var o,A;const{animation:s}=e;if(!1===s||!1===i)return[];const a=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===a)return[];const c=null==a?void 0:a[r];if(!1===c)return[];const l=null===(A=Jv(e)[n])||void 0===A?void 0:A.animation,u=(e=[])=>function(e){if("string"==typeof e){return Xv(t.ExtensionCategory.ANIMATION,e)||(Zv(`The animation of ${e} is not registered.`),[])}return e}(e).map(t=>Object.assign(Object.assign(Object.assign(Object.assign({},Iv),zt(s)&&s),t),zt(i)&&i));if(c)return u(c);if(!l)return[];const h=l[r];return!1===h?[]:u(h)}function om(t,e,n,r=[]){if(!r&&0===t&&0===e&&0===n)return null;if(Array.isArray(r)){let i=-1;const o=[];for(let A=0;A{if(!n.length)return null;const[r,i]=e;let o;const A=n.map(e=>{var{fields:n,shape:A,states:s}=e,a=Pe(e,["fields","shape","states"]);const c=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const A=`get${ce(e)}Style`,s=(null===(n=null==t?void 0:t[A])||void 0===n?void 0:n.bind(t))||(t=>t);return{shape:o,fromStyle:(null==s?void 0:s(r))||{},toStyle:(null==s?void 0:s(i))||{}}}return{shape:t,fromStyle:r,toStyle:i}})(A);if(!c)return null;const{shape:l,fromStyle:u,toStyle:h}=c,d=[{},{}];if(n.forEach(t=>{var e,n;Object.assign(d[0],{[t]:null!==(e=u[t])&&void 0!==e?e:nm(t)}),Object.assign(d[1],{[t]:null!==(n=h[t])&&void 0!==n?n:nm(t)})}),d.some(t=>Object.keys(t).some(t=>["x","y","z"].includes(t)))){const{x:t=0,y:e=0,z:n,transform:r=""}=l.attributes||{};d.forEach(i=>{var o,A,s;i.transform=om(null!==(o=i.x)&&void 0!==o?o:t,null!==(A=i.y)&&void 0!==A?A:e,null!==(s=i.z)&&void 0!==s?s:n,r)})}const f=l.animate(em(d),a);return void 0===A&&(o=f),f}).filter(Boolean),s=o||(null==A?void 0:A[0]);return s?tm(s,A.filter(t=>t!=t)):null},sm=[{fields:["x","y"]}],am=sm,cm=[{fields:["sourceNode","targetNode"]}],lm=cm,um=[{fields:["childrenNode","x","y"]}],hm=um;function dm(t){return 3===t.length}function fm(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every(t=>"number"==typeof t)}function gm(t,e,n){return t>=e&&t<=n}function pm(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function vm(t=0){const e=pm(t);return e[0]+e[2]}function mm(t){return t.max[0]-t.min[0]}function ym(t){return t.max[1]-t.min[1]}function wm(t){return[mm(t),ym(t)]}function bm(t,e){const n=fm(t)?Bm(t):t.getShape("key").getBounds();return e?Em(n,e):n}function Bm(t){const[e,n,r=0]=t,i=new yr;return i.setMinMax([e,n,r],[e,n,r]),i}function Em(t,e){const[n,r,i,o]=pm(e),[A,s,a]=t.min,[c,l,u]=t.max,h=new yr;return h.setMinMax([A-o,s-n,a],[c+r,l+i,u]),h}function xm(t){if(0===t.length)return new yr;if(1===t.length)return t[0];const e=new yr;e.setMinMax(t[0].min,t[0].max);for(let n=1;nc[e.id]+s?(c[A]=c[e.id]+s,l[A]=[e.id]):c[A]===c[e.id]+s&&l[A].push(e.id)})},d=0;d=this.maxStep},t.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},t.prototype.push=function(t){this.linkedList.prepend(t),this.length>this.maxStep&&this.linkedList.deleteTail()},t.prototype.pop=function(){var t=this.linkedList.deleteHead();return t?t.value:null},t.prototype.toArray=function(){return this.linkedList.toArray().map(function(t){return t.value})},t.prototype.clear=function(){for(;!this.isEmpty();)this.pop()}}();const Vm=(t,e,n)=>{var r;switch(n.type){case"degree":{const i=new Map;return null===(r=t.nodes)||void 0===r||r.forEach(t=>{const r=e(Km(t),n.direction).length;i.set(Km(t),r)}),i}case"betweenness":return Ym(t,n.directed,n.weightPropertyName);case"closeness":return Xm(t,n.directed,n.weightPropertyName);case"eigenvector":return $m(t,n.directed);case"pagerank":return qm(t,n.epsilon,n.linkProb);default:return Wm(t)}},Wm=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach(t=>{n.set(Km(t),0)}),n},Ym=(t,e,n)=>{const r=Wm(t),{nodes:i=[]}=t;return i.forEach(o=>{i.forEach(i=>{if(o!==i){const{allPath:A}=Gm(t,Km(o),Km(i),e,n),s=A.length;A.flat().forEach(t=>{t!==Km(o)&&t!==Km(i)&&r.set(t,r.get(t)+1/s)})}})}),r},Xm=(t,e,n)=>{const r=new Map,{nodes:i=[]}=t;return i.forEach(o=>{const A=i.reduce((r,i)=>{if(o!==i){const{length:A}=Gm(t,Km(o),Km(i),e,n);r+=A}return r},0);r.set(Km(o),1/A)}),r},qm=(t,e,n)=>{var r;const i=new Map,o=function(t,e,n){"number"!=typeof e&&(e=1e-6),"number"!=typeof n&&(n=.85);for(var r,i=1,o=0,A=1e3,s=t.nodes,a=void 0===s?[]:s,c=t.edges,l=void 0===c?[]:c,u=a.length,h={},d={},f=0;f0&&i>e;){for(o=0,f=0;f0&&(r+=d[y]/w)}h[p]=n*r,o+=h[p]}}for(o=(1-o)/u,i=0,f=0;f{i.set(Km(t),o[Km(t)])}),i},$m=(t,e)=>{const{nodes:n=[]}=t,r=Zm(t,e),i=Jm(r,n.length),o=new Map;return n.forEach((t,e)=>{o.set(Km(t),i[e])}),o},Zm=(t,e)=>{const{nodes:n=[],edges:r=[]}=t,i=Array(n.length).fill(null).map(()=>Array(n.length).fill(0));return r.forEach(({source:t,target:r})=>{const o=n.findIndex(e=>Km(e)===t),A=n.findIndex(t=>Km(t)===r);e?i[o][A]=1:(i[o][A]=1,i[A][o]=1)}),i},Jm=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let A=0;Ar;A++){const n=Array(e).fill(0);for(let r=0;rt+e*e,0));for(let t=0;tt+(e-i[n])*e,0)),i=n}return i};function ty(t,e,n,r=xe){const i=new Map(t.map(t=>[n(t),t])),o=new Map(e.map(t=>[n(t),t])),A=new Set(i.keys()),s=new Set(o.keys()),a=[],c=[],l=[],u=[];return s.forEach(t=>{A.has(t)?r(i.get(t),o.get(t))?u.push(o.get(t)):c.push(o.get(t)):a.push(o.get(t))}),A.forEach(t=>{s.has(t)||l.push(i.get(t))}),{enter:a,exit:l,keep:u,update:c}}function ey(t,e,n){t.forEach(t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)})}class ny{constructor(t){this.extensions=[],this.extensionMap={},this.context=t}setExtensions(t){const e=function(t,e,n){const r={},i=t=>(t in r||(r[t]=0),`${e}-${t}-${r[t]++}`);return n.map(e=>"string"==typeof e?{type:e,key:i(e)}:"function"==typeof e?e.call(t):e.key?e:Object.assign(Object.assign({},e),{key:i(e.type)}))}(this.context.graph,this.category,t),{enter:n,update:r,exit:i,keep:o}=ty(this.extensions,e,t=>t.key);this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=Xv(e,r);if(!i)return Zv(`The extension ${r} of ${e} is not registered.`);const o=new i(this.context,t);o.initialized=!0,this.extensionMap[n]=o}createExtensions(t){t.forEach(t=>this.createExtension(t))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach(t=>this.updateExtension(t))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.initialized&&!e.destroyed&&e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach(({key:t})=>this.destroyExtension(t))}destroy(){this.destroyExtensions(this.extensions),this.context={},this.extensions=[],this.extensionMap={}}}class ry{constructor(t,e){this.events=[],this.initialized=!1,this.destroyed=!1,this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class iy extends ry{}class oy extends iy{constructor(t,e){super(t,Object.assign({},oy.defaultOptions,e)),this.isOverlapping=(t,e)=>e.some(e=>t.intersects(e)),this.occupiedBounds=[],this.detectLabelCollision=t=>{const e=this.context.viewport,n={show:[],hide:[]};return this.occupiedBounds=[],t.forEach(t=>{const r=t.getShape("label").getRenderBounds();e.isInViewport(r,!0)&&!this.isOverlapping(r,this.occupiedBounds)?(n.show.push(t),this.occupiedBounds.push(Em(r,this.options.padding))):n.hide.push(t)}),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=ty(t,e,t=>t.id);null==n||n.forEach(this.hideLabel)},this.nodeCentralities=new Map,this.sortNodesByCentrality=(t,e)=>{const{model:n}=this.context,r=n.getData(),i=n.getRelatedEdgesData.bind(n);return t.map(t=>(this.nodeCentralities.has(t.id)||(this.nodeCentralities=Vm(r,i,e)),{node:t,centrality:this.nodeCentralities.get(t.id)})).sort((t,e)=>e.centrality-t.centrality).map(t=>t.node)},this.sortLabelElementsInView=t=>{const{sort:e,sortNode:n,sortCombo:r,sortEdge:i}=this.options,{model:o}=this.context;if(Gt(e))return t.sort((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id)));const{node:A=[],edge:s=[],combo:a=[]}=ee(t,t=>t.type),c=Gt(r)?a.sort((t,e)=>r(...o.getComboData([t.id,e.id]))):a,l=Gt(n)?A.sort((t,e)=>n(...o.getNodeData([t.id,e.id]))):this.sortNodesByCentrality(A,n),u=Gt(i)?s.sort((t,e)=>i(...o.getEdgeData([t.id,e.id]))):s;return[...c,...l,...u]},this.labelElementsInView=[],this.isFirstRender=!0,this.onToggleVisibility=t=>{var e;if("zIndex"===(null===(e=t.data)||void 0===e?void 0:e.stage))return;if(!this.validate(t))return void(this.hiddenElements.size>0&&(this.hiddenElements.forEach(this.showLabel),this.hiddenElements.clear()));const n=this.isFirstRender?this.getLabelElements():this.getLabelElementsInView();this.hideLabelIfExceedViewport(this.labelElementsInView,n),this.labelElementsInView=n;const r=this.sortLabelElementsInView(this.labelElementsInView),{show:i,hide:o}=this.detectLabelCollision(r);for(let t=i.length-1;t>=0;t--)this.showLabel(i[t]);o.forEach(this.hideLabel)},this.hiddenElements=new Map,this.hideLabel=t=>{const e=t.getShape("label");e&&ey(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&ey(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Qe(this.onToggleVisibility,this.options.throttle,{leading:!0}),this.enableToggle=!0,this.toggle=t=>{this.enableToggle&&this.onToggleVisibility(t)},this.onBeforeRender=()=>{this.enableToggle=!1},this.onAfterRender=t=>{this.onToggleVisibility(t),this.enableToggle=!0},this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents(),this.onToggleVisibility({})}getLabelElements(){const{elementMap:t}=this.context.element,e=[];for(const n in t){const r=t[n];r.isVisible()&&r.getShape("label")&&e.push(r)}return e}getLabelElementsInView(){const t=this.context.viewport;return this.getLabelElements().filter(e=>t.isInViewport(e.getShape("key").getRenderBounds()))}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.on(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.on(t.GraphEvent.AFTER_DRAW,this.toggle),e.on(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.off(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.off(t.GraphEvent.AFTER_DRAW,this.toggle),e.off(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}oy.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const Ay=[0,0,0];function sy(t,e){if(t.length==e.length)return[t,e];if(dm(t)&&0!==t[2]||dm(e)&&0!==e[2])throw new Error($v("Vectors could not operate due to different dimensions."));return[yy(t),yy(e)]}function ay(t,e){return[t,e]=sy(t,e),t.map((t,n)=>t+e[n])}function cy(t,e){return[t,e]=sy(t,e),t.map((t,n)=>t-e[n])}function ly(t,e){return"number"==typeof e?t.map(t=>t*e):([t,e]=sy(t,e),t.map((t,n)=>t*e[n]))}function uy(t,e){return"number"==typeof e?t.map(t=>t/e):([t,e]=sy(t,e),t.map((t,n)=>{if(0==e[n])throw new Error($v("Vector could not be divided by zero"));return t/e[n]}))}function hy(t,e){return t.map(t=>t*e)}function dy(t,e){return[t,e]=sy(t,e),Math.sqrt(t.reduce((t,n,r)=>t+Math.pow(n-e[r],2),0))}function fy(t,e){return[t,e]=sy(t,e),t.reduce((t,n,r)=>t+Math.abs(n-e[r]),0)}function gy(t){const e=t.reduce((t,e)=>t+Math.pow(e,2),0);return t.map(t=>t/Math.sqrt(e))}function py(t,e,n=!1){[t,e]=sy(t,e);const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(ly(t,e).reduce((t,e)=>t+e,0)/(dy(t,Ay)*dy(e,Ay)));return n&&r<0&&(i=2*Math.PI-i),i}function vy(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function my(t,e){return t.map(t=>t%e)}function yy(t){return[t[0],t[1]]}function wy(t){return 2===t.length?[t[0],t[1],0]:t}function by(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function By(t,e){const[n,r]=t;if(e%360==0)return[n,r];const i=e*Math.PI/180,o=Math.cos(i),A=Math.sin(i);return[n*o-r*A,n*A+r*o]}function Ey(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=wy(t),r=wy(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(cy(n,r),cy(i,o)).every(t=>0===t)}function xy(t,e,n=!1){if(Ey(t,e))return;const[r,i]=t,[o,A]=e,s=((r[0]-o[0])*(o[1]-A[1])-(r[1]-o[1])*(o[0]-A[0]))/((r[0]-i[0])*(o[1]-A[1])-(r[1]-i[1])*(o[0]-A[0])),a=A[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(A[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(A[1]-o[1]);return n||gm(s,0,1)&&gm(a,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Cy(t){if(Array.isArray(t))return gm(t[0],0,1)&&gm(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}function My(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Fy(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function ky(t,e="center"){return function(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}(t,Cy(e))}function Sy(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function Qy(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function Uy(t,e=0){return t.map(t=>parseFloat(t.toFixed(e)))}function Ny(t,e,n,r=!1){if(xe(t,e))return t;const i=gy(r?cy(t,e):cy(e,t)),o=[i[0]*n,i[1]*n];return ay(yy(t),o)}function Ty(t,e){return t[1]===e[1]}function Oy(t,e){return Ty(t,e)||function(t,e){return t[0]===e[0]}(t,e)}function Iy(t,e,n){return Ey([t,e],[e,n])}function Ly(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function Py(t,e,n,r=!0,i=!1){for(let o=0;o{const i=function(t,e){const n=Hy(t,e);return dy(t,n)}(t,e);i1?l=1:l<0&&(l=0);return[n+l*a,r+l*c]}function _y(t,e=!0){const n=function(t){const e=t.reduce((t,e)=>ay(t,e),[0,0]);return uy(e,t.length)}(t);return t.sort(([t,r],[i,o])=>{const A=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-A:A-s})}function Gy(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}class Ky{constructor(t,e,n){if(this.phase=e,this.pointerByTouch=[],this.initialDistance=null,this.emitter=t,Ky.instance)return Ky.callbacks[this.phase].push(n),Ky.instance;this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.bindEvents(),Ky.instance=this,Ky.callbacks[this.phase].push(n)}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp)}updatePointerPosition(t,e,n){const r=this.pointerByTouch.findIndex(e=>e.pointerId===t);r>=0&&(this.pointerByTouch[r]={x:e,y:n,pointerId:t})}onPointerDown(t){const{x:e,y:n}=t.client||{};if(void 0!==e&&void 0!==n&&(this.pointerByTouch.push({x:e,y:n,pointerId:t.pointerId}),"touch"===t.pointerType&&2===this.pointerByTouch.length)){Ky.isPinching=!0;const e=this.pointerByTouch[0].x-this.pointerByTouch[1].x,n=this.pointerByTouch[0].y-this.pointerByTouch[1].y;this.initialDistance=Math.sqrt(e*e+n*n),Ky.callbacks.pinchstart.forEach(e=>e(t,{scale:0}))}}onPointerMove(t){if(2!==this.pointerByTouch.length||null===this.initialDistance)return;const{x:e,y:n}=t.client||{};if(void 0===e||void 0===n)return;this.updatePointerPosition(t.pointerId,e,n);const r=this.pointerByTouch[0].x-this.pointerByTouch[1].x,i=this.pointerByTouch[0].y-this.pointerByTouch[1].y,o=Math.sqrt(r*r+i*i)/this.initialDistance;Ky.callbacks.pinchmove.forEach(e=>e(t,{scale:5*(o-1)}))}onPointerUp(t){var e;Ky.callbacks.pinchend.forEach(e=>e(t,{scale:0})),Ky.isPinching=!1,this.initialDistance=null,this.pointerByTouch=[],null===(e=Ky.instance)||void 0===e||e.tryDestroy()}destroy(){this.emitter.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),this.emitter.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),this.emitter.off(t.CommonEvent.POINTER_UP,this.onPointerUp),Ky.instance=null}off(t,e){const n=Ky.callbacks[t].indexOf(e);n>-1&&Ky.callbacks[t].splice(n,1),this.tryDestroy()}tryDestroy(){Object.values(Ky.callbacks).every(t=>0===t.length)&&this.destroy()}}Ky.isPinching=!1,Ky.instance=null,Ky.callbacks={pinchstart:[],pinchmove:[],pinchend:[]};const jy=new Set(["Control","Alt","Meta","Shift"]);function zy(t){return jy.has(t)}const Vy=t=>t.map(t=>Jt(t)?t.toLocaleLowerCase():t);class Wy{constructor(e){this.map=new Map,this.boundHandlePinch=()=>{},this.recordKey=new Set,this.onKeyDown=t=>{(null==t?void 0:t.key)&&(this.recordKey.add(t.key),this.trigger(t))},this.onKeyUp=t=>{(null==t?void 0:t.key)&&this.recordKey.delete(t.key)},this.onKeyDownWindow=t=>{zy(t.key)&&this.recordKey.add(t.key)},this.onKeyUpWindow=t=>{zy(t.key)&&this.recordKey.delete(t.key)},this.onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)},this.onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)},this.handlePinch=(e,n)=>{this.triggerExtendKey(t.CommonEvent.PINCH,Object.assign(Object.assign({},e),n))},this.onFocus=()=>{this.recordKey.clear()},this.emitter=e,this.bindEvents()}bind(e,n){0!==e.length&&(e.includes(t.CommonEvent.PINCH)&&!this.pinchHandler&&(this.boundHandlePinch=this.handlePinch.bind(this),this.pinchHandler=new Ky(this.emitter,"pinchmove",this.boundHandlePinch)),this.map.set(e,n))}unbind(t,e){this.map.forEach((n,r)=>{xe(r,t)&&(e&&e!==n||this.map.delete(r))})}unbindAll(){this.map.clear()}match(t){const e=Vy(Array.from(this.recordKey)).sort(),n=Vy(t).sort();return xe(e,n)}bindEvents(){var e;const{emitter:n}=this;window.addEventListener(t.CommonEvent.KEY_DOWN,this.onKeyDownWindow),window.addEventListener(t.CommonEvent.KEY_UP,this.onKeyUpWindow),n.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),n.on(t.CommonEvent.KEY_UP,this.onKeyUp),n.on(t.CommonEvent.WHEEL,this.onWheel),n.on(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"focus",this.onFocus)}trigger(t){this.map.forEach((e,n)=>{this.match(n)&&e(t)})}triggerExtendKey(t,e){this.map.forEach((n,r)=>{r.includes(t)&&xe(Array.from(this.recordKey),r.filter(e=>e!==t))&&n(e)})}destroy(){var e,n;this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),window.removeEventListener(t.CommonEvent.KEY_DOWN,this.onKeyDownWindow),window.removeEventListener(t.CommonEvent.KEY_UP,this.onKeyUpWindow),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag),null===(e=this.pinchHandler)||void 0===e||e.off("pinchmove",this.boundHandlePinch),null===(n=globalThis.removeEventListener)||void 0===n||n.call(globalThis,"focus",this.onFocus)}}class Yy extends iy{constructor(t,e){super(t,be({},Yy.defaultOptions,e)),this.shortcut=new Wy(t.graph),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.clearStates=this.clearStates.bind(this),this.bindEvents()}onPointerDown(t){if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{canvas:e,graph:n}=this.context,r=Object.assign({},this.options.style);this.options.style.lineWidth&&(r.lineWidth=+this.options.style.lineWidth/n.getZoom()),this.rectShape=new sc({id:"g6-brush-select",style:r}),e.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]}onPointerMove(t){var e;if(!this.startPoint)return;const{immediately:n,mode:r}=this.options;this.endPoint=Xy(t,this.context.graph),null===(e=this.rectShape)||void 0===e||e.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),n&&"default"===r&&this.updateElementsStates(Gy(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=Xy(t,this.context.graph),this.updateElementsStates(Gy(this.startPoint,this.endPoint)),this.clearBrush()):this.clearBrush())}clearStates(){this.endPoint||this.clearElementsStates()}clearElementsStates(){const{graph:t}=this.context,e=Object.values(t.getData()).reduce((t,e)=>Object.assign({},t,e.reduce((t,e)=>{var n;const r=null===(n=e.states||[])||void 0===n?void 0:n.filter(t=>t!==this.options.state);return t[Km(e)]=r,t},{})),{});t.setElementState(e,this.options.animation)}updateElementsStates(t){const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,A=this.selector(e,t,n),s={};switch(i){case"union":A.forEach(t=>{s[t]=[...e.getElementState(t),r]});break;case"diff":A.forEach(t=>{const n=e.getElementState(t);s[t]=n.includes(r)?n.filter(t=>t!==r):[...n,r]});break;case"intersect":A.forEach(t=>{const n=e.getElementState(t);s[t]=n.includes(r)?[r]:[]});break;default:A.forEach(t=>{s[t]=[r]})}Gt(o)&&o(s),e.setElementState(s,this.options.animation)}selector(t,e,n){if(!n||0===n.length)return[];const r=[],i=t.getData();if(n.forEach(n=>{i[`${n}s`].forEach(n=>{const i=Km(n);"hidden"!==t.getElementVisibility(i)&&function(t,e,n,r){const i=t[0],o=t[1];let A=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);const s=r-n;for(let t=0,r=s-1;to!=l>o&&i<(c-s)*(o-a)/(l-a)+s&&(A=!A)}return A}(t.getElementPosition(i),e)&&r.push(i)})}),n.includes("edge")){const t=i.edges;null==t||t.forEach(t=>{const{source:e,target:n}=t;r.includes(e)&&r.includes(n)&&r.push(Km(t))})}return r}clearBrush(){var t;null===(t=this.rectShape)||void 0===t||t.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0}isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return this.shortcut.match(e.filter(t=>"drag"!==t))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp),e.on(t.CanvasEvent.CLICK,this.clearStates)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.off(t.CommonEvent.POINTER_UP,this.onPointerUp),e.off(t.CanvasEvent.CLICK,this.clearStates)}update(t){this.unbindEvents(),this.options=be(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}Yy.defaultOptions={animation:!1,enable:!0,enableElements:["node","combo","edge"],immediately:!1,mode:"default",state:"selected",trigger:["shift"],style:{width:0,height:0,lineWidth:1,fill:"#1677FF",stroke:"#1677FF",fillOpacity:.1,zIndex:2,pointerEvents:"none"}};const Xy=(t,e)=>{if(!("node"!==t.targetType&&"combo"!==t.targetType||t.nativeEvent.target instanceof HTMLCanvasElement)){const[n,r]=e.getCanvasByClient([t.client.x,t.client.y]);return[n,r]}return[t.canvas.x,t.canvas.y]},qy=.8,$y=["node","edge","combo"];function Zy(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)Zy(t,e,n,r,i+1);"BT"===r&&e(t,i)}function Jy(t,e,n,r,i="both"){if("combo"===e||"node"===e)return tw(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const A=tw(t,o.source,r-1,i),s=tw(t,o.target,r-1,i);return Array.from(new Set([...A,...s,n]))}function tw(t,e,n,r="both"){const i=new Set,o=new Set,A=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,(e,i)=>{i>n||(A.add(e),t.getRelatedEdgesData(e,r).forEach(t=>{const e=Km(t);!o.has(e)&&it.getRelatedEdgesData(e,r).map(t=>t.source===e?t.target:t.source).filter(t=>!i.has(t)&&(i.add(t),!0))),Array.from(A)}function ew(t){return t.states||[]}class nw extends iy{constructor(t,e){super(t,Object.assign({},nw.defaultOptions,e)),this.onClickSelect=t=>De(this,void 0,void 0,function*(){var e,n;this.validate(t)&&(yield this.updateState(t),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))}),this.onClickCanvas=t=>De(this,void 0,void 0,function*(){var e,n;this.validate(t)&&(yield this.clearState(),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))}),this.shortcut=new Wy(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)}),e.on(t.CanvasEvent.CLICK,this.onClickCanvas)}get isMultipleSelect(){const{multiple:t,trigger:e}=this.options;return t&&this.shortcut.match(e)}getNeighborIds(t){const{target:e,targetType:n}=t,{graph:r}=this.context,{degree:i}=this.options;return Jy(r,n,e.id,"function"==typeof i?i(t):i).filter(t=>t!==e.id)}updateState(t){return De(this,void 0,void 0,function*(){const{state:e,unselectedState:n,neighborState:r,animation:i}=this.options;if(!e&&!r&&!n)return;const{target:o}=t,{graph:A}=this.context,s=ew(A.getElementData(o.id)).includes(e)?"unselect":"select",a={},c=this.isMultipleSelect,l=[o.id],u=this.getNeighborIds(t);if(c)if(Object.assign(a,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach(t=>{const r=new Set(A.getElementState(t));r.add(e),r.delete(n),a[t]=Array.from(r)})};t(l,e),t(u,r),n&&Object.keys(a).forEach(t=>{const i=a[t];i.includes(e)||i.includes(r)||i.includes(n)||a[t].push(n)})}else{const t=a[o.id];a[o.id]=t.filter(t=>t!==e&&t!==r),t.includes(n)||a[o.id].push(n),u.forEach(t=>{a[t]=a[t].filter(t=>t!==r),a[t].includes(e)||a[t].push(n)})}else if("select"===s){Object.assign(a,this.getClearStates(!!n));const t=(t,e)=>{t.forEach(t=>{a[t]||(a[t]=A.getElementState(t)),a[t].push(e)})};t(l,e),t(u,r),n&&Object.keys(a).forEach(t=>{l.includes(t)||u.includes(t)||a[t].push(n)})}else Object.assign(a,this.getClearStates());yield A.setElementState(a,i)})}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach(t=>{i[Km(t)]=ew(t)}),i}getClearStates(t=!1){const{graph:e}=this.context,{state:n,unselectedState:r,neighborState:i}=this.options,o=new Set([n,r,i]),{nodes:A,edges:s,combos:a}=e.getData(),c={};return[...A,...s,...a].forEach(e=>{const n=ew(e),r=n.filter(t=>!o.has(t));(t||r.length!==n.length)&&(c[Km(e)]=r)}),c}clearState(){return De(this,void 0,void 0,function*(){const{graph:t}=this.context;yield t.setElementState(this.getClearStates(),this.options.animation)})}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)}),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function rw(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function iw(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function ow(t,e,n=!0){if(!e)return t;if(!iw(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=ae(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Aw(t,e){const n=Object.entries(t).reduce((t,[n,r])=>("className"===n||"class"===n||iw(n,e)&&Object.assign(t,{[ow(n,e)]:r}),t),{});if("opacity"in t){const r=function(t,e){return`${e}${ce(t)}`}("opacity",e),i=t.opacity;if(r in t){const e=t[r];Object.assign(n,{opacity:i*e})}else Object.assign(n,{opacity:i})}return n}function sw(t,e){const n=e.length;return Object.keys(t).reduce((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r},{})}function aw(t,e){const n="string"==typeof e?[e]:e,r={};return Object.keys(t).forEach(e=>{n.find(t=>e.startsWith(t))||(r[e]=t[e])}),r}function cw(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function lw(t,e){const{datum:n,graph:r}=e;return"function"==typeof t?t.call(r,n):Object.fromEntries(Object.entries(t).map(([t,e])=>"function"==typeof e?[t,e.call(r,n)]:[t,e]))}function uw(t,e){const n=(null==t?void 0:t.style)||{},r=(null==e?void 0:e.style)||{};for(const t in n)t in r||(r[t]=n[t]);return Object.assign({},t,e,{style:r})}function hw(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function dw(t){const e="string"==typeof t?Xv("palette",t):t;if("function"!=typeof e)return e}function fw(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function gw(t,e,n=1,r=!1){const i=r?n:1;return fw((t.max[0]-t.min[0])*i,e)}nw.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class pw extends Wa{constructor(t){mw(t.style),super(t),this.shapeMap={},this.animateMap={},this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}upsert(e,n,r,i,o){var A,s,a,c,l,u,h,d;const f=this.shapeMap[e];if(!1===r)return void(f&&(null===(A=null==o?void 0:o.beforeDestroy)||void 0===A||A.call(o,f),i.removeChild(f),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,f)));const g="string"==typeof n?Xv(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error($v(`Shape ${n} not found`));if(!f||f.destroyed||!(f instanceof g)){f&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,f),null==f||f.destroy(),null===(c=null==o?void 0:o.afterDestroy)||void 0===c||c.call(o,f)),null===(l=null==o?void 0:o.beforeCreate)||void 0===l||l.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(u=null==o?void 0:o.afterCreate)||void 0===u||u.call(o,t),t}return null===(h=null==o?void 0:o.beforeUpdate)||void 0===h||h.call(o,f),tE(f,r),null===(d=null==o?void 0:o.afterUpdate)||void 0===d||d.call(o,f),f}update(t={}){const e=Object.assign({},this.attributes,t);mw(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:A,clipPath:s,component:a}=e,c=Pe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,c),r&&t.setAttribute("transform",r);re(n)&&t.setAttribute("zIndex",n);i&&t.setAttribute("transformOrigin",i);o&&t.setAttribute("visibility",o);A&&t.setAttribute("cursor",A);s&&t.setAttribute("clipPath",s);a&&t.setAttribute("component",a)}(this,e),this.render(e,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){return function(t){const{x:e,y:n,z:r,class:i,className:o,transform:A,transformOrigin:s,zIndex:a,visibility:c}=t;return Pe(t,["x","y","z","class","className","transform","transformOrigin","zIndex","visibility"])}(t)}get compositeShapes(){return[["badges","badge-"],["ports","port-"]]}animate(t,e){if(0===t.length)return null;const n=[];if(void 0!==t[0].x||void 0!==t[0].y||void 0!==t[0].z){const{x:e=0,y:n=0,z:r=0}=this.attributes;t.forEach(t=>{const{x:i=e,y:o=n,z:A=r}=t;Object.assign(t,{transform:A?[["translate3d",i,o,A]]:[["translate",i,o]]})})}const r=super.animate(t,e);if(r&&(vw(this,r),n.push(r)),Array.isArray(t)&&t.length>0){const r=["transform","transformOrigin","x","y","z","zIndex"];if(Object.keys(t[0]).some(t=>!r.includes(t))){Object.entries(this.shapeMap).forEach(([r,i])=>{const o=this[`get${ce(r)}Style`];if(Gt(o)){const r=t.map(t=>o.call(this,Object.assign(Object.assign({},this.attributes),t))),A=i.animate(em(r),e);A&&(vw(i,A),n.push(A))}});const r=(r,i)=>{if(!Ee(r)){const o=this[`get${ce(i)}Style`];if(Gt(o)){const i=t.map(t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)));Object.entries(i[0]).map(([t])=>{const o=i.map(e=>e[t]),A=r[t];if(A){const t=A.animate(em(o),e);t&&(vw(A,t),n.push(t))}})}}};this.compositeShapes.forEach(([t,e])=>{const n=sw(this.shapeMap,e);r(n,t)})}}return tm(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;ey(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function vw(t,e){null==e||e.finished.then(()=>{const n=t.activeAnimations.findIndex(t=>t===e);n>-1&&t.activeAnimations.splice(n,1)})}function mw(t){if(!t)return{};if("x"in t||"y"in t||"z"in t){const{x:e=0,y:n=0,z:r,transform:i}=t,o=om(e,n,r,i);o&&(t.transform=o)}return t}class yw extends pw{constructor(t){super(uw({style:yw.defaultStyleProps},t))}isTextStyle(t){return iw(t,"label")}isBackgroundStyle(t){return iw(t,"background")}getTextStyle(t){const e=this.getGraphicStyle(t),{padding:n}=e;return aw(Pe(e,["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Aw(e,"background"),{min:[A,s],center:[a,c],halfExtents:[l,u]}=this.shapeMap.text.getGeometryBounds(),[h,d,f,g]=pm(i),p=2*l+g+d,{width:v,height:m}=o;v&&m?Object.assign(o,{x:a-Number(v)/2,y:c-Number(m)/2}):Object.assign(o,{x:A-g,y:s-h,width:n?Math.min(p,r+g+d):p,height:2*u+h+f});const{radius:y}=o;if("string"==typeof y&&y.endsWith("%")){const t=Number(y.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",cc,this.getTextStyle(t),e),this.upsert("background",sc,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}yw.defaultStyleProps={padding:0,fontSize:12,fontFamily:"system-ui, sans-serif",wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};class ww extends pw{constructor(t){super(uw({style:ww.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",yw,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}ww.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const bw={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function Bw(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in bw?r=t:e.unshift(t),i={type:r},bw[r].forEach(n=>{t=e.shift(),i[n]=t}),"M"===r?r="L":"m"===r&&(r="l");const[o,...A]=Object.values(i);n.push([o,...A.map(Number)])}return n}(t):t;return n.forEach(t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e{const n=t,r=l[(e+1)%l.length];return xe(n,r)?null:[n,r]}).filter(Boolean),h=Ry([s,a],u),d=Hy([s,a],h);if(d&&h&&(c.transform=[["translate",d[0]+n,d[1]+r]],A)){const t=Math.atan((h[0][1]-h[1][1])/(h[0][0]-h[1][0]));c.transform.push(["rotate",t/Math.PI*180]),c.textAlign="center","right"!==e&&"left"!==e||(c.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return c}(l,A,r,i,s,t.d,o),{wordWrapWidth:gw(l,n)},a)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",nc,this.getKeyStyle(t),e),this.upsert("label",yw,this.getLabelStyle(t),e)}}xw.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let Cw=class extends Za{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Fw=this,this.isMutationObserved=!0,this.addEventListener(ea.MOUNTED,this.onMounted),this.addEventListener(ea.ATTR_MODIFIED,this.onAttrModified)}handleRadius(){const{radius:t,clipPath:e,width:n=0,height:r=0}=this.attributes;if(t&&n&&r){const[i,o]=this.getBounds().min,A={x:i,y:o,radius:t,width:n,height:r};if(e)Object.assign(this.parsedStyle.clipPath.style,A);else{const t=new sc({style:A});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const Mw=new WeakMap;let Fw=null;const kw=t=>{if(Fw&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Fw).includes(t)){const e=Mw.get(t);e?e.includes(Fw)||e.push(Fw):Mw.set(t,[Fw])}},Sw=t=>{const e=Mw.get(t);e&&e.forEach(t=>t.handleRadius())};class Qw extends pw{constructor(t){super(t)}isImage(){const{src:t}=this.attributes;return!!t}getIconStyle(t=this.attributes){const{width:e=0,height:n=0}=t,r=this.getGraphicStyle(t);return this.isImage()?Object.assign({x:-e/2,y:-n/2},r):Object.assign({textBaseline:"middle",textAlign:"center"},r)}render(t=this.attributes,e=this){this.upsert("icon",this.isImage()?Cw:cc,this.getIconStyle(t),e)}}class Uw extends pw{get context(){return this.config.context}get parsedAttributes(){return this.attributes}onframe(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>this.onframe(),n.finished.then(()=>this.onframe())),n}}class Nw extends Uw{constructor(t){super(uw({style:Nw.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return cw(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(aw(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Aw(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,A=Pe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(ZB(s,n,i,o),{wordWrapWidth:gw(s,r)},A)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Pe(e,["fill"]),i=Aw(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign(Object.assign({},r),{stroke:n}),i)}getIconStyle(t){if(!1===t.icon||!t.iconText&&!t.iconSrc)return!1;const e=Aw(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=cw(t);let r={};return e.text&&!e.fontSize&&(r={fontSize:.5*Math.min(...n)}),!e.src||e.width&&e.height||(r={width:.5*n[0],height:.5*n[1]}),r}(t.size,e),e)}getBadgesStyle(t){var e;const n=sw(this.shapeMap,"badge-"),r={};if(Object.keys(n).forEach(t=>{r[t]=!1}),!1===t.badge||!(null===(e=t.badges)||void 0===e?void 0:e.length))return r;const{badges:i=[],badgePalette:o,opacity:A=1}=t,s=Pe(t,["badges","badgePalette","opacity"]),a=dw(o),c=Aw(this.getGraphicStyle(s),"badge");return i.forEach((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:a?a[e%(null==a?void 0:a.length)]:void 0,opacity:A},c),this.getBadgeStyle(t))}),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Pe(t,["placement","offsetX","offsetY"]),A=ZB(e.getLocalBounds(),n,r,i,!0);return Object.assign(Object.assign({},A),o)}getPortsStyle(t){var e;const n=this.getPorts(),r={};if(Object.keys(n).forEach(t=>{r[t]=!1}),!1===t.port||!(null===(e=t.ports)||void 0===e?void 0:e.length))return r;const i=Aw(this.getGraphicStyle(t),"port"),{ports:o=[]}=t;return o.forEach((e,n)=>{const o=e.key||n,A=Object.assign(Object.assign({},i),e);if(VB(A))r[o]=!1;else{const[n,i]=this.getPortXY(t,e);r[o]=Object.assign({transform:[["translate",n,i]]},A)}}),r}getPortXY(t,e){const{placement:n="left"}=e,r=this.getShape("key");return jB(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();ey(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return sw(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return Py(t,ky(e,"center"),[ky(e,"left-top"),ky(e,"right-top"),ky(e,"right-bottom"),ky(e,"left-bottom")],!1,n).point}(t,this.getShape("key").getBounds(),e)}drawHaloShape(t,e){const n=this.getHaloStyle(t),r=this.getShape("key");this.upsert("halo",r.constructor,n,e)}drawIconShape(t,e){const n=this.getIconStyle(t);this.upsert("icon",Qw,n,e),kw(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach(t=>{const r=n[t];this.upsert(`badge-${t}`,ww,r,e)})}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach(t=>{const r=n[t],i=`port-${t}`;this.upsert(i,za,r,e)})}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",yw,n,e)}_drawKeyShape(t,e){return this.drawKeyShape(t,e)}render(t=this.parsedAttributes,e=this){this._drawKeyShape(t,e),this.getShape("key")&&(this.drawHaloShape(t,e),this.drawIconShape(t,e),this.drawBadgeShapes(t,e),this.drawLabelShape(t,e),this.drawPortShapes(t,e))}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Sw(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}Nw.defaultStyleProps={x:0,y:0,size:32,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};let Tw=class t extends Nw{constructor(e){super(uw({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",za,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{r:Math.min(...this.getSize(t))/2})}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getShape("key").attributes,r=2*n*qy;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}};Tw.defaultStyleProps={size:32};class Ow extends Nw{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",ic,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{points:this.getPoints(t)})}getIntersectPoint(t,e=!1){var n,r;const{points:i}=this.getShape("key").attributes;return Py(t,[+((null===(n=this.attributes)||void 0===n?void 0:n.x)||0),+((null===(r=this.attributes)||void 0===r?void 0:r.y)||0)],i,!0,e).point}}class Iw extends Ow{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}}class Lw extends Tw{constructor(t){super(uw({style:Lw.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...cw(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return Jt(t)?parseInt(t)/100*this.parseOuterR():t}drawDonutShape(t,e){const{donuts:n}=t;if(!(null==n?void 0:n.length))return;const r=n.map(t=>re(t)?{value:t}:t),i=Aw(this.getGraphicStyle(t),"donut"),o=dw(t.donutPalette);if(!o)return;const A=r.reduce((t,e)=>{var n;return t+(null!==(n=e.value)&&void 0!==n?n:0)},0),s=this.parseOuterR(),a=this.parseInnerR();let c=0;r.forEach((t,n)=>{const{value:l=0,color:u=o[n%o.length]}=t,h=Pe(t,["value","color"]),d=360*(0===A?1/r.length:l/A);this.upsert(`round${n}`,nc,Object.assign(Object.assign(Object.assign({},i),{d:Dw(s,a,c,c+d),fill:u}),h),e),c+=d})}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}Lw.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const Pw=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],Dw=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[A,s]=[i/360*2*Math.PI,o/360*2*Math.PI],a=[Pw(t,e,r,A),Pw(t,e,n,A),Pw(t,e,n,s),Pw(t,e,r,s)],c=s-A>Math.PI?1:0;return[["M",a[0][0],a[0][1]],["L",a[1][0],a[1][1]],["A",n,n,0,c,1,a[2][0],a[2][1]],["L",a[3][0],a[3][1]],["A",r,r,0,c,0,a[0][0],a[0][1]],["Z"]]})(i,o,t,e,n,r)};class Rw extends Nw{constructor(t){super(uw({style:Rw.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ya,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return Object.assign(Object.assign({},e),{rx:n/2,ry:r/2})}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getShape("key").attributes,i=2*Math.min(+n,+r)*qy;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}}Rw.defaultStyleProps={size:[45,35]};class Hw extends Ow{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*qy;return!!e&&Object.assign({width:n,height:n},e)}}function _w(t,e){if(!{}.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var Gw=0;function Kw(t){return"__private_"+Gw+++"_"+t} /*! * @antv/g-canvas * @description A renderer implemented by Canvas 2D API * @version 2.2.0 * @date 12/24/2025, 11:55:53 AM * @author AntVis * @docs https://g.antv.antgroup.com/ */var jw=Kw("renderState"),zw=function(){function t(e){A(this,t),this.renderQueue=[],Object.defineProperty(this,jw,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=C(),this.dprMatrix=C(),this.tmpMat4=C(),this.vec3a=at(),this.vec3b=at(),this.vec3c=at(),this.vec3d=at(),this.canvasRendererPluginOptions=e}return a(t,[{key:"apply",value:function(e,n){var r=this;this.context=e;var i=this.context,o=i.config,A=i.camera,s=i.renderingService,a=i.renderingContext,c=i.pathGeneratorFactory,l=o.renderer.getConfig().enableRenderingOptimization;o.renderer.getConfig().enableDirtyCheck=!1,o.renderer.getConfig().enableDirtyRectangleRendering=!1,this.pathGeneratorFactory=c;var u=e.contextService,h=a.root.ownerDocument.defaultView;s.hooks.init.tap(t.tag,function(){var t=u.getDPR(),e=o.width,n=o.height,i=u.getContext();r.clearRect(i,0,0,e*t,n*t,o.background)}),s.hooks.destroy.tap(t.tag,function(){r.renderQueue=[],_w(r,jw)[jw]={restoreStack:[],prevObject:null,currentContext:null}});var d=function(t,e){for(var i=[t];i.length>0;){var o,A=i.pop();A.isVisible()&&!A.isCulled()&&(l?r.renderDisplayObjectOptimized(A,e,r.context,_w(r,jw)[jw],n):r.renderDisplayObject(A,e,r.context,_w(r,jw)[jw],n));for(var s=(null===(o=A.sortable)||void 0===o||null===(o=o.sorted)||void 0===o?void 0:o.length)>0?A.sortable.sorted:A.childNodes,a=s.length-1;a>=0;a--)i.push(s[a])}};s.hooks.endFrame.tap(t.tag,function(){if(function(){var t,e=u.getContext(),n=u.getDPR(),i=o.width,A=o.height,a=r.canvasRendererPluginOptions,c=a.dirtyObjectNumThreshold,l=a.dirtyObjectRatioThreshold,d=s.getStats(),f=d.total,g=d.rendered,p=g/f;r.clearFullScreen=r.clearFullScreenLastFrame||!(null!==(t=h.context.renderingPlugins[1])&&void 0!==t&&t.isFirstTimeRenderingFinished)||s.disableDirtyRectangleRendering()||g>c&&p>l,e&&("function"==typeof e.resetTransform?e.resetTransform():e.setTransform(1,0,0,1,0,0),r.clearFullScreen&&r.clearRect(e,0,0,i*n,A*n,o.background))}(),0!==a.root.childNodes.length){l=o.renderer.getConfig().enableRenderingOptimization,_w(r,jw)[jw]={restoreStack:[],prevObject:null,currentContext:_w(r,jw)[jw].currentContext},_w(r,jw)[jw].currentContext.clear(),r.clearFullScreenLastFrame=!1;var t=u.getContext(),e=u.getDPR();if(H(r.dprMatrix,[e,e,1]),O(r.vpMatrix,r.dprMatrix,A.getOrthoMatrix()),r.clearFullScreen)l?(t.save(),d(a.root,t),t.restore()):d(a.root,t);else{var i=r.safeMergeAABB(r.mergeDirtyAABBs(r.renderQueue));if(yr.isEmpty(i))return void(r.renderQueue=[]);var c=r.convertAABB2Rect(i),f=c.x,g=c.y,p=c.width,v=c.height,y=bt(r.vec3a,[f,g,0],r.vpMatrix),w=bt(r.vec3b,[f+p,g,0],r.vpMatrix),b=bt(r.vec3c,[f,g+v,0],r.vpMatrix),B=bt(r.vec3d,[f+p,g+v,0],r.vpMatrix),E=Math.min(y[0],w[0],B[0],b[0]),x=Math.min(y[1],w[1],B[1],b[1]),C=Math.max(y[0],w[0],B[0],b[0]),M=Math.max(y[1],w[1],B[1],b[1]),F=Math.floor(E),k=Math.floor(x),S=Math.ceil(C-E),Q=Math.ceil(M-x);t.save(),r.clearRect(t,F,k,S,Q,o.background),t.beginPath(),t.rect(F,k,S,Q),t.clip(),t.setTransform(r.vpMatrix[0],r.vpMatrix[1],r.vpMatrix[4],r.vpMatrix[5],r.vpMatrix[12],r.vpMatrix[13]),o.renderer.getConfig().enableDirtyRectangleRenderingDebug&&h.dispatchEvent(new Vs(mc.DIRTY_RECTANGLE,{dirtyRect:{x:F,y:k,width:S,height:Q}}));var U=m(i.getMin(),2),N=U[0],T=U[1],I=m(i.getMax(),2),L=I[0],P=I[1];a.root.ownerDocument.elementsFromBBox(N,T,L,P).sort(function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder}).forEach(function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t,r.context,_w(r,jw)[jw],n)}),t.restore(),r.renderQueue.forEach(function(t){r.saveDirtyAABB(t)}),r.renderQueue=[]}_w(r,jw)[jw].restoreStack.forEach(function(){t.restore()}),_w(r,jw)[jw].restoreStack=[]}else r.clearFullScreenLastFrame=!0}),s.hooks.render.tap(t.tag,function(t){r.clearFullScreen||r.renderQueue.push(t)})}},{key:"clearRect",value:function(t,e,n,r,i,o){t.clearRect(e,n,r,i),o&&(t.fillStyle=o,t.fillRect(e,n,r,i))}},{key:"renderDisplayObjectOptimized",value:function(t,e,n,r,i){var o=t.nodeName,A=!1,s=this.context.styleRendererFactory[o],a=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){(!r.prevObject||!it(c.getWorldTransform(),r.prevObject.getWorldTransform()))&&(this.applyWorldTransform(e,c),r.prevObject=null);var l=this.pathGeneratorFactory[c.nodeName];l&&(e.save(),A=!0,e.beginPath(),l(e,c.parsedStyle),e.closePath(),e.clip())}if(s){(!r.prevObject||!it(t.getWorldTransform(),r.prevObject.getWorldTransform()))&&this.applyWorldTransform(e,t);var u=!r.prevObject;if(!u){var h=r.prevObject.nodeName;u=o===cr.TEXT?h!==cr.TEXT:o===cr.IMAGE?h!==cr.IMAGE:h===cr.TEXT||h===cr.IMAGE}s.applyStyleToContext(e,t,u,r),r.prevObject=t}a&&(e.beginPath(),a(e,t.parsedStyle),o!==cr.LINE&&o!==cr.PATH&&o!==cr.POLYLINE&&e.closePath()),s&&s.drawToContext(e,t,_w(this,jw)[jw],this,i),A&&e.restore(),t.dirty(!1)}},{key:"renderDisplayObject",value:function(t,e,n,r,i){var o=t.nodeName,A=r.restoreStack[r.restoreStack.length-1];!A||t.compareDocumentPosition(A)&Ys.DOCUMENT_POSITION_CONTAINS||(e.restore(),r.restoreStack.pop());var s=this.context.styleRendererFactory[o],a=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){this.applyWorldTransform(e,c);var l=this.pathGeneratorFactory[c.nodeName];l&&(e.save(),r.restoreStack.push(t),e.beginPath(),l(e,c.parsedStyle),e.closePath(),e.clip())}s&&(this.applyWorldTransform(e,t),e.save(),this.applyAttributesToContext(e,t)),a&&(e.beginPath(),a(e,t.parsedStyle),o!==cr.LINE&&o!==cr.PATH&&o!==cr.POLYLINE&&e.closePath()),s&&(s.render(e,t.parsedStyle,t,n,this,i),e.restore()),t.dirty(!1)}},{key:"applyAttributesToContext",value:function(t,e){var n=e.parsedStyle,r=n.stroke,i=n.fill,o=n.opacity,A=n.lineDash,s=n.lineDashOffset;A&&t.setLineDash(A),Kt(s)||(t.lineDashOffset=s),Kt(o)||(t.globalAlpha*=o),Kt(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),Kt(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)}},{key:"convertAABB2Rect",value:function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}}},{key:"mergeDirtyAABBs",value:function(t){var e=new yr;return t.forEach(function(t){var n=t.getRenderBounds();e.add(n);var r=t.renderable.dirtyRenderBounds;r&&e.add(r)}),e}},{key:"saveDirtyAABB",value:function(t){var e=t.renderable;e.dirtyRenderBounds||(e.dirtyRenderBounds=new yr);var n=t.getRenderBounds();n&&e.dirtyRenderBounds.update(n.center,n.halfExtents)}},{key:"applyWorldTransform",value:function(t,e,n){n?(F(this.tmpMat4,e.getLocalTransform()),O(this.tmpMat4,n,this.tmpMat4),O(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(F(this.tmpMat4,e.getWorldTransform()),O(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])}},{key:"safeMergeAABB",value:function(){for(var t=new yr,e=arguments.length,n=new Array(e),r=0;r0){if(n||e.attributes.stroke!==r.prevObject.attributes.stroke)Zw(t,"strokeStyle",Kt(o.stroke)||Array.isArray(o.stroke)||o.stroke.isNone?qw.strokeStyle:e.attributes.stroke,r.currentContext);(n||o.lineWidth!==i.lineWidth)&&Zw(t,"lineWidth",Kt(o.lineWidth)?qw.lineWidth:o.lineWidth,r.currentContext),(n||o.lineDash!==i.lineDash)&&Zw(t,"lineDash",o.lineDash||qw.lineDash,r.currentContext),(n||o.lineDashOffset!==i.lineDashOffset)&&Zw(t,"lineDashOffset",Kt(o.lineDashOffset)?qw.lineDashOffset:o.lineDashOffset,r.currentContext);for(var c=0;c4&&void 0!==arguments[4]&&arguments[4];if(e){Zw(t,"shadowColor",qw.shadowColor,r.currentContext);for(var o=0;o-1&&Zw(t,"filter",s.replace(/drop-shadow\([^)]*\)/,"").trim()||qw.filter,r.currentContext)}else Zw(t,"filter",qw.filter,r.currentContext)}},{key:"fillToContext",value:function(t,e,n,r,i){var o=this,A=e.parsedStyle,s=A.fill,a=A.fillRule,c=null;if(Array.isArray(s)&&s.length>0)s.forEach(function(r){var i=Zw(t,"fillStyle",Ww(r,e,t,o.imagePool),n.currentContext);c=null!=c?c:i,a?t.fill(a):t.fill()});else{if(wo(s)){var l=Vw(s,e,t,e.ownerDocument.defaultView.context,r,i,this.imagePool);l&&(t.fillStyle=l,c=!0)}a?t.fill(a):t.fill()}null!==c&&Zw(t,"fillStyle",c,n.currentContext)}},{key:"strokeToContext",value:function(t,e,n,r,i){var o=this,A=e.parsedStyle.stroke,s=null;if(Array.isArray(A)&&A.length>0)A.forEach(function(r){var i=Zw(t,"strokeStyle",Ww(r,e,t,o.imagePool),n.currentContext);s=null!=s?s:i,t.stroke()});else{if(wo(A)){var a=Vw(A,e,t,e.ownerDocument.defaultView.context,r,i,this.imagePool);if(a){var c=Zw(t,"strokeStyle",a,n.currentContext);s=null!=s?s:c}}t.stroke()}null!==s&&Zw(t,"strokeStyle",s,n.currentContext)}},{key:"drawToContext",value:function(t,e,n,r,i){var o,A=e.nodeName,s=e.parsedStyle,a=s.opacity,c=void 0===a?qw.globalAlpha:a,l=s.fillOpacity,u=void 0===l?qw.fillOpacity:l,h=s.strokeOpacity,d=void 0===h?qw.strokeOpacity:h,f=s.lineWidth,g=void 0===f?qw.lineWidth:f,p=s.fill&&!s.fill.isNone,v=s.stroke&&!s.stroke.isNone&&g>0;if(p||v){var m=!Kt(s.shadowColor)&&s.shadowBlur>0,y="inner"===s.shadowType,w=0===(null===(o=s.fill)||void 0===o?void 0:o.alpha),b=!(!s.filter||!s.filter.length),B=m&&v&&(A===cr.PATH||A===cr.LINE||A===cr.POLYLINE||w||y),E=null;if(p)B||this.applyShadowAndFilterStyleToContext(t,e,m,n),E=Zw(t,"globalAlpha",c*u,n.currentContext),this.fillToContext(t,e,n,r,i),B||this.clearShadowAndFilterStyleForContext(t,m,b,n);if(v){var x=!1,C=Zw(t,"globalAlpha",c*d,n.currentContext);if(E=p?E:C,B&&(this.applyShadowAndFilterStyleToContext(t,e,m,n),x=!0,y)){var M=t.globalCompositeOperation;t.globalCompositeOperation="source-atop",this.strokeToContext(t,e,n,r,i),t.globalCompositeOperation=M,this.clearShadowAndFilterStyleForContext(t,m,b,n,!0)}this.strokeToContext(t,e,n,r,i),x&&this.clearShadowAndFilterStyleForContext(t,m,b,n)}null!==E&&Zw(t,"globalAlpha",E,n.currentContext)}}}])}(),tb=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"render",value:function(t,e,n,r,i,o){var A=e.fill,s=e.fillRule,a=e.opacity,c=void 0===a?1:a,l=e.fillOpacity,u=void 0===l?1:l,h=e.stroke,d=e.strokeOpacity,f=void 0===d?1:d,g=e.lineWidth,p=void 0===g?1:g,v=e.lineCap,m=e.lineJoin,y=e.shadowType,w=e.shadowColor,b=e.shadowBlur,B=e.filter,E=e.miterLimit,x=A&&!A.isNone,C=h&&!h.isNone&&p>0,M=0===(null==A?void 0:A.alpha),F=!(!B||!B.length),k=!Kt(w)&&b>0,S=n.nodeName,Q="inner"===y,U=C&&k&&(S===cr.PATH||S===cr.LINE||S===cr.POLYLINE||M||Q);x&&(t.globalAlpha=c*u,U||eb(n,t,k),nb(t,n,A,s,r,i,o,this.imagePool),U||this.clearShadowAndFilter(t,F,k)),C&&(t.globalAlpha=c*f,t.lineWidth=p,Kt(E)||(t.miterLimit=E),Kt(v)||(t.lineCap=v),Kt(m)||(t.lineJoin=m),U&&(Q&&(t.globalCompositeOperation="source-atop"),eb(n,t,!0),Q&&(rb(t,n,h,r,i,o,this.imagePool),t.globalCompositeOperation=qw.globalCompositeOperation,this.clearShadowAndFilter(t,F,!0))),rb(t,n,h,r,i,o,this.imagePool))}},{key:"clearShadowAndFilter",value:function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!Kt(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}}}])}(Jw);function eb(t,e,n){var r=t.parsedStyle,i=r.filter,o=r.shadowColor,A=r.shadowBlur,s=r.shadowOffsetX,a=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=o.toString(),e.shadowBlur=A||0,e.shadowOffsetX=s||0,e.shadowOffsetY=a||0)}function nb(t,e,n,r,i,o,A,s){var a=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Array.isArray(n)?n.forEach(function(n){t.fillStyle=Ww(n,e,t,s),a||(r?t.fill(r):t.fill())}):(wo(n)&&(t.fillStyle=Vw(n,e,t,i,o,A,s)),a||(r?t.fill(r):t.fill()))}function rb(t,e,n,r,i,o,A){var s=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Array.isArray(n)?n.forEach(function(n){t.strokeStyle=Ww(n,e,t,A),s||t.stroke()}):(wo(n)&&(t.strokeStyle=Vw(n,e,t,r,i,o,A)),s||t.stroke())}var ib=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"renderDownSampled",value:function(t,e,n,r){var i=r.src,o=r.imageCache;o.downSampled?t.drawImage(o.downSampled,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3])):this.imagePool.createDownSampledImage(i,n).then(function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())}).catch(function(t){console.error(t)})}},{key:"renderTile",value:function(t,e,n,r){var i=r.src,o=r.imageCache,A=r.imageRect,s=r.drawRect,a=o.size,c=t.getTransform(),l=c.a,u=c.b,h=c.c,d=c.d,f=c.e,g=c.f;if(t.resetTransform(),null!=o&&o.gridSize){for(var p=[a[0]/A[2],a[1]/A[3]],v=[o.tileSize[0]/p[0],o.tileSize[1]/p[1]],m=[Math.floor((s[0]-A[0])/v[0]),Math.ceil((s[0]+s[2]-A[0])/v[0])],y=m[0],w=m[1],b=[Math.floor((s[1]-A[1])/v[1]),Math.ceil((s[1]+s[3]-A[1])/v[1])],B=b[1],E=b[0];E<=B;E++)for(var x=y;x<=w;x++){var C=o.tiles[E][x];if(C){var M=[Math.floor(A[0]+C.tileX*v[0]),Math.floor(A[1]+C.tileY*v[1]),Math.ceil(v[0]),Math.ceil(v[1])];t.drawImage(C.data,M[0],M[1],M[2],M[3])}}t.setTransform(l,u,h,d,f,g)}else this.imagePool.createImageTiles(i,[],function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())},n).catch(function(t){console.error(t)})}},{key:"render",value:function(t,n,r){var i=n.x,o=void 0===i?0:i,A=n.y,s=void 0===A?0:A,a=n.width,c=n.height,l=n.src,u=n.shadowColor,h=n.shadowBlur,d=this.imagePool.getImageSync(l,r),f=null==d?void 0:d.img,g=a,p=c;if(f){var v,y,w,b,B,E,x,C,M,F,S,Q,U,N,T;g||(g=f.width),p||(p=f.height),eb(r,t,!Kt(u)&&h>0);try{var O=r.ownerDocument.defaultView.getContextService().getDomElement(),I=O.width,L=O.height,P=t.getTransform(),D=P.a,R=P.b,H=function(t,e){var n=bt(at(),[t[0],t[1],0],e),r=bt(at(),[t[0]+t[2],t[1],0],e),i=bt(at(),[t[0],t[1]+t[3],0],e),o=bt(at(),[t[0]+t[2],t[1]+t[3],0],e);return[Math.min(n[0],r[0],i[0],o[0]),Math.min(n[1],r[1],i[1],o[1]),Math.max(n[0],r[0],i[0],o[0])-Math.min(n[0],r[0],i[0],o[0]),Math.max(n[1],r[1],i[1],o[1])-Math.min(n[1],r[1],i[1],o[1])]}([o,s,g,p],k(D,P.c,0,0,R,P.d,0,0,0,0,1,0,P.e,P.f,0,1)),_=(v=H,y=m([0,0,I,L],4),w=y[0],b=y[1],B=y[2],E=y[3],x=m(v,4),C=x[0],M=x[1],F=x[2],S=x[3],Q=Math.max(w,C),U=Math.max(b,M),N=Math.min(w+B,C+F),T=Math.min(b+E,M+S),N<=Q||T<=U?null:[Q,U,N-Q,T-U]);if(!_)return;if(!r.ownerDocument.defaultView.getConfig().enableLargeImageOptimization)return void e.renderFull(t,n,r,{image:f,drawRect:[o,s,g,p]});if(H[2]/d.size[0]<(d.downSamplingRate||.5))return void this.renderDownSampled(t,n,r,{src:l,imageCache:d,drawRect:[o,s,g,p]});if(!ImagePool.isSupportTile)return void e.renderFull(t,n,r,{image:f,drawRect:[o,s,g,p]});this.renderTile(t,n,r,{src:l,imageCache:d,imageRect:H,drawRect:_})}catch(t){}}}},{key:"drawToContext",value:function(t,e,n,r,i){this.render(t,e.parsedStyle,e)}}],[{key:"renderFull",value:function(t,e,n,r){t.drawImage(r.image,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3]))}}])}(tb),ob=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"render",value:function(t,e,n,r,i,o){n.getBounds();var A=e.lineWidth,s=void 0===A?1:A,a=e.textAlign,c=void 0===a?"start":a,l=e.textBaseline,u=void 0===l?"alphabetic":l,h=e.lineJoin,d=void 0===h?"miter":h,f=e.miterLimit,g=void 0===f?10:f,p=e.letterSpacing,v=void 0===p?0:p,m=e.stroke,y=e.fill,w=e.fillRule,b=e.fillOpacity,B=void 0===b?1:b,E=e.strokeOpacity,x=void 0===E?1:E,C=e.opacity,M=void 0===C?1:C,F=e.metrics,k=e.x,S=void 0===k?0:k,Q=e.y,U=void 0===Q?0:Q,N=e.dx,T=e.dy,O=e.shadowColor,I=e.shadowBlur,L=e.textDecorationLine,P=F.font,D=F.lines,R=F.height,H=F.lineHeight,_=F.lineMetrics;t.font=P,t.lineWidth=s,t.textAlign="middle"===c?"center":c;var G=u;"alphabetic"===G&&(G="bottom"),t.lineJoin=d,Kt(g)||(t.miterLimit=g);var K=U;"middle"===u?K+=-R/2-H/2:"bottom"===u||"alphabetic"===u||"ideographic"===u?K+=-R:"top"!==u&&"hanging"!==u||(K+=-H);var j=S+(N||0);K+=T||0,1===D.length&&("bottom"===G?(G="middle",K-=.5*R):"top"===G&&(G="middle",K+=.5*R)),t.textBaseline=G,eb(n,t,!Kt(O)&&I>0);for(var z=0;z0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),(t=g(this,e)).name="canvas-renderer",t.options=n,t}return v(e,t),a(e,[{key:"init",value:function(){var t,e=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new tb(n),A=(r(r(r(r(r(r(r(r(r(r(t={},cr.CIRCLE,i),cr.ELLIPSE,i),cr.RECT,i),cr.IMAGE,new ib(n)),cr.TEXT,new ob(n)),cr.LINE,i),cr.POLYLINE,i),cr.POLYGON,i),cr.PATH,i),cr.GROUP,void 0),r(r(r(t,cr.HTML,void 0),cr.MESH,void 0),cr.FRAGMENT,void 0));this.context.defaultStyleRendererFactory=A,this.context.styleRendererFactory=A,this.addRenderingPlugin(new zw(e))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory}}])}(ur),sb=at(),ab=at(),cb=at(),lb=C(),ub=function(){function t(){var e=this;A(this,t),this.isHit=function(t,n,r,i){var o=e.context.pointInPathPickerFactory[t.nodeName];if(o){var A=N(lb,r),s=bt(ab,dt(cb,n[0],n[1],0),A);if(o(t,new Er(s[0],s[1]),i,e.isPointInPath,e.context,e.runtime))return!0}return!1},this.isPointInPath=function(t,n){var r=e.runtime.offscreenCanvasCreator.getOrCreateContext(e.context.config.offscreenCanvas),i=e.context.pathGeneratorFactory[t.nodeName];return i&&(r.beginPath(),i(r,t.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return a(t,[{key:"apply",value:function(e,n){var r,i=this,o=e.renderingService,A=e.renderingContext;this.context=e,this.runtime=n;var s=null===(r=A.root)||void 0===r?void 0:r.ownerDocument;o.hooks.pick.tapPromise(t.tag,function(){var t=Ar(ir().mark(function t(e){return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i.pick(s,e));case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),o.hooks.pickSync.tap(t.tag,function(t){return i.pick(s,t)})}},{key:"pick",value:function(t,e){var n,r=e.topmost,i=e.position,o=i.x,A=i.y,s=dt(sb,o,A,0),a=[],c=sr(t.elementsFromBBox(s[0],s[1],s[0],s[1]));try{for(c.s();!(n=c.n()).done;){var l=n.value,u=l.getWorldTransform();if(this.isHit(l,s,u,!1)){var h=qA(l);if(h){var d=h.parsedStyle.clipPath;if(this.isHit(d,s,d.getWorldTransform(),!0)){if(r)return e.picked=[l],e;a.push(l)}}else{if(r)return e.picked=[l],e;a.push(l)}}}}catch(t){c.e(t)}finally{c.f()}return e.picked=a,e}}])}();function hb(t,e,n){var r=t.parsedStyle,i=r.cx,o=void 0===i?0:i,A=r.cy,s=void 0===A?0:A,a=r.r,c=r.fill,l=r.stroke,u=r.lineWidth,h=void 0===u?1:u,d=r.increasedLineWidthForHitTesting,f=void 0===d?0:d,g=r.pointerEvents,p=void 0===g?"auto":g,v=(h+f)/2,y=Nn(o,s,e.x,e.y),w=m(es(p,c,l),2),b=w[0],B=w[1];return b&&B||n?y<=a+v:b?y<=a:!!B&&(y>=a-v&&y<=a+v)}function db(t,e,n,r){return t/(n*n)+e/(r*r)}function fb(t,e,n){var r=t.parsedStyle,i=r.cx,o=void 0===i?0:i,A=r.cy,s=void 0===A?0:A,a=r.rx,c=r.ry,l=r.fill,u=r.stroke,h=r.lineWidth,d=void 0===h?1:h,f=r.increasedLineWidthForHitTesting,g=void 0===f?0:f,p=r.pointerEvents,v=void 0===p?"auto":p,y=e.x,w=e.y,b=m(es(v,l,u),2),B=b[0],E=b[1],x=(d+g)/2,C=(y-o)*(y-o),M=(w-s)*(w-s);return B&&E||n?db(C,M,a+x,c+x)<=1:B?db(C,M,a,c)<=1:!!E&&(db(C,M,a-x,c-x)>=1&&db(C,M,a+x,c+x)<=1)}function gb(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function pb(t,e,n,r,i,o,A,s){var a=(Math.atan2(s-e,A-t)+2*Math.PI)%(2*Math.PI),c={x:t+n*Math.cos(a),y:e+n*Math.sin(a)};return Nn(c.x,c.y,A,s)<=o/2}function vb(t,e,n,r,i,o,A){var s=Math.min(t,n),a=Math.max(t,n),c=Math.min(e,r),l=Math.max(e,r),u=i/2;return o>=s-u&&o<=a+u&&A>=c-u&&A<=l+u&&Hn(t,e,n,r,o,A)<=i/2}function mb(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var A=0;A0!=yb(s[1]-n)>0&&yb(e-(n-A[1])*(A[0]-s[0])/(A[1]-s[1])-A[0])<0&&(r=!r)}return r}function Bb(t,e,n){for(var r=!1,i=0;i=i.min[0]&&e.y>=i.min[1]&&e.x<=i.max[0]&&e.y<=i.max[1]}var Qb=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;is?A:s,c=A>s?1:A/s,l=A>s?s/A:1;t.save(),t.scale(c,l),t.arc(r,o,a,0,2*Math.PI)}}function Tb(t,e){var n,r,i=e.x1,o=e.y1,A=e.x2,s=e.y2,a=e.markerStart,c=e.markerEnd,l=e.markerStartOffset,u=e.markerEndOffset,h=0,d=0,f=0,g=0,p=0;a&&Ra(a)&&l&&(n=A-i,r=s-o,p=Math.atan2(r,n),h=Math.cos(p)*(l||0),d=Math.sin(p)*(l||0)),c&&Ra(c)&&u&&(n=i-A,r=o-s,p=Math.atan2(r,n),f=Math.cos(p)*(u||0),g=Math.sin(p)*(u||0)),t.moveTo(i+h,o+d),t.lineTo(A+f,s+g)}function Ob(t,e){var n,r,i=e.markerStart,o=e.markerEnd,A=e.markerStartOffset,s=e.markerEndOffset,a=e.d,c=a.absolutePath,l=a.segments,u=0,h=0,d=0,f=0,g=0;if(i&&Ra(i)&&A){var p=m(i.parentNode.getStartTangent(),2),v=p[0],y=p[1];n=v[0]-y[0],r=v[1]-y[1],g=Math.atan2(r,n),u=Math.cos(g)*(A||0),h=Math.sin(g)*(A||0)}if(o&&Ra(o)&&s){var w=m(o.parentNode.getEndTangent(),2),b=w[0],B=w[1];n=b[0]-B[0],r=b[1]-B[1],g=Math.atan2(r,n),d=Math.cos(g)*(s||0),f=Math.sin(g)*(s||0)}for(var E=0;ER?D:R,z=D>R?1:D/R,V=D>R?R/D:1;t.translate(L,P),t.rotate(G),t.scale(z,V),t.arc(0,0,j,H,_,!!(1-K)),t.scale(1/z,1/V),t.rotate(-G),t.translate(-L,-P)}k&&t.lineTo(x[6]+d,x[7]+f);break;case"Z":t.closePath()}}}function Ib(t,e){var n,r,i=e.markerStart,o=e.markerEnd,A=e.markerStartOffset,s=e.markerEndOffset,a=e.points.points,c=a.length,l=a[0][0],u=a[0][1],h=a[c-1][0],d=a[c-1][1],f=0,g=0,p=0,v=0,m=0;i&&Ra(i)&&A&&(n=a[1][0]-a[0][0],r=a[1][1]-a[0][1],m=Math.atan2(r,n),f=Math.cos(m)*(A||0),g=Math.sin(m)*(A||0)),o&&Ra(o)&&s&&(n=a[c-1][0]-a[0][0],r=a[c-1][1]-a[0][1],m=Math.atan2(r,n),p=Math.cos(m)*(s||0),v=Math.sin(m)*(s||0)),t.moveTo(l+(f||p),u+(g||v));for(var y=1;y0?1:-1,d=a>0?1:-1,f=h+d===0,g=A.map(function(t){return ne(t,0,Math.min(Math.abs(c)/2,Math.abs(l)/2))}),p=m(g,4),v=p[0],y=p[1],w=p[2],b=p[3];t.moveTo(h*v+r,o),t.lineTo(c-h*y+r,o),0!==y&&t.arc(c-h*y+r,d*y+o,y,-d*Math.PI/2,h>0?0:Math.PI,f),t.lineTo(c+r,l-d*w+o),0!==w&&t.arc(c-h*w+r,l-d*w+o,w,h>0?0:Math.PI,d>0?Math.PI/2:1.5*Math.PI,f),t.lineTo(h*b+r,l+o),0!==b&&t.arc(h*b+r,l-d*b+o,b,d>0?Math.PI/2:-Math.PI/2,h>0?Math.PI:0,f),t.lineTo(r,d*v+o),0!==v&&t.arc(h*v+r,d*v+o,v,h>0?Math.PI:0,d>0?1.5*Math.PI:Math.PI/2,f)}else t.rect(r,o,c,l)}var Db=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i0&&void 0!==i[0]?i[0]:{}).type,r=e.encoderOptions,t.abrupt("return",this.context.canvas.toDataURL(n,r));case 1:case"end":return t.stop()}},t,this)})),function(){return t.apply(this,arguments)})}]);var t}(),Hb=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i{const e=this.context.canvas,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach(r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);Me(e.context.eventService,"mappingTable.pointerupoutside",[]),e.context.eventService.mapEvent(i)})}}get eventService(){return this.context.canvas.context.eventService}get events(){return[t.CommonEvent.CLICK,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_UP,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE]}getDomElement(){return this.getShape("key").getDomElement()}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.drawPortShapes(t,e)}getKeyStyle(t){const e=ke(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Pe(e,["dx","dy"]),[o,A]=this.getSize(t);return Object.assign(Object.assign({x:n,y:r},i),{width:o,height:A})}drawKeyShape(t,e){const n=this.getKeyStyle(t),{x:r,y:i,width:o=0,height:A=0}=n,s=this.upsert("key-container",sc,{x:r,y:i,width:o,height:A,opacity:0},e);return this.upsert("key",$a,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof _b))return;const t=this.getDomElement();this.events.forEach(e=>{t.addEventListener(e,this.forwardEvents)})}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}destroy(){const t=this.getDomElement();this.events.forEach(e=>{t.removeEventListener(e,this.forwardEvents)}),super.destroy()}normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;ethis.context.element.getElement(t)).filter(Boolean);if(0===r.length){const e=new yr,{x:n=0,y:r=0,size:i}=t,[o,A]=cw(i);return e.setMinMax([n-o/2,r-A/2,0],[n+o/2,r+A/2,0]),e}const i=xm(r.map(t=>t.getBounds()));return n?Em(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",Qw,n,e),kw(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Aw(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Pe(e,["type"]),i=this.getShape("key"),[o,A]=ky(i.getLocalBounds(),"center"),s=Object.assign(Object.assign({},r),{x:o,y:A});if(n){const e=this.getCollapsedMarkerText(n,t);Object.assign(s,{text:e})}return s}getCollapsedMarkerText(t,e){const{childrenData:n=[]}=e,{model:r}=this.context;return"descendant-count"===t?r.getDescendantsData(this.id).length.toString():"child-count"===t?n.length.toString():"node-count"===t?r.getDescendantsData(this.id).filter(t=>"node"===r.getElementType(Km(t))).length.toString():Gt(t)?t(n):""}getComboPosition(t){const{x:e=0,y:n=0,collapsed:r,childrenData:i=[]}=t;if(0===i.length)return[+e,+n,0];if(r){const{model:t}=this.context,r=t.getDescendantsData(this.id).filter(e=>!t.isCombo(Km(e)));if(r.length>0&&r.some(Fy)){return uy(r.reduce((t,e)=>ay(t,My(e)),[0,0,0]),r.length)}return[+e,+n,0]}return this.getContentBBox(t).center}getComboStyle(t){const[e,n]=this.getComboPosition(t);return{x:e,y:n,transform:[["translate",e,n]]}}updateComboPosition(t){const e=this.getComboStyle(t);Object.assign(this.style,e);const{x:n,y:r}=e;this.context.model.syncNodeLikeDatum({id:this.id,style:{x:n,y:r}}),Sw(this)}render(t,e=this){super.render(t,e),this.drawCollapsedMarkerShape(t,e)}update(t={}){super.update(t),this.updateComboPosition(this.parsedAttributes)}onframe(){super.onframe(),this.attributes.collapsed||this.updateComboPosition(this.parsedAttributes),this.drawKeyShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(this.attributes.collapsed?t:t.map(t=>{var{x:e,y:n,z:r,transform:i}=t;return Pe(t,["x","y","z","transform"])}),e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then(()=>this.onframe()),Reflect.set(t,e,n))}):n}}Wb.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Yb extends Wb{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",za,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),[r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},n),e&&Aw(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=cw(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=wm(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}}class Xb extends Wb{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",sc,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},e),t.collapsed&&Aw(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const qb={padding:10};function $b(t,e,n,r,i,o){const{padding:A}=Object.assign(qb,o),s=bm(n,A),a=bm(r,A),c=[t,...i,e];let l=null;const u=[];for(let t=0,e=c.length;to?"N":"S":r===o?n>i?"W":"E":null}function eB(t,e){return"N"===e||"S"===e?ym(t):mm(t)}function nB(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=tB(t,r),A=tB(t,i),s=n?Zb[n]:null,a=o===n||o!==s&&A!==n?r:i;return{points:[a],direction:tB(a,e)}}function rB(t,e,n){if(Fm(t,n)){const r=sB(t,e,n);return{points:[r],direction:tB(r,e)}}{const r=Sm(t,n),i=["left","right"].includes(km(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:tB(i,e)}}}function iB(t,e,n,r){const i=Fm(e,n)?e:Sm(e,n),o=[[i[0],t[1]],[t[0],i[1]]],A=o.filter(t=>function(t,e){return!Cm(t,e)}(t,n)&&!Mm(t,n,!0)),s=A.filter(e=>tB(e,t)!==r);if(s.length>0){const n=s.find(e=>tB(t,e)===r)||s[0];return{points:[n],direction:tB(n,e)}}{const i=Ny(e,_t(o,A)[0],eB(n,r)/2);return{points:[sB(i,t,n),i],direction:tB(i,e)}}}function oB(t,e,n,r){let i=rB(t,e,n);const o=wy(i.points[0]);if(Cm(o,r)){i=rB(e,t,r);const A=wy(i.points[0]);if(Cm(A,n)){const s=Ny(t,o,eB(n,tB(t,o))/2),a=Ny(e,A,eB(r,tB(e,A))/2),c=[(s[0]+a[0])/2,(s[1]+a[1])/2],l=rB(t,c,n),u=iB(c,e,r,l.direction);i.points=[l.points[0],u.points[0]],i.direction=u.direction}}return i}function AB(t,e,n,r,i){const o=.01,A=xm([n,r]),s=dy(e,A.center)>dy(t,A.center),[a,c]=s?[e,t]:[t,e],l=ym(A)+mm(A);let u;if(i){const t=[a[0]+l*Math.cos(Jb[i]),a[1]+l*Math.sin(Jb[i])];u=Ny(Sm(t,A),t,o)}else u=Ny(Sm(a,A),a,-.01);let h=sB(u,c,A),d=[Uy(u,2),Uy(h,2)];if(xe(Uy(u),Uy(h))){const t=py(cy(u,a),[1,0,0])+Math.PI/2;h=[c[0]+l*Math.cos(t),c[1]+l*Math.sin(t),0],h=Uy(Ny(Sm(h,A),c,-.01),2);d=[u,sB(u,h,A),h]}return{points:s?d.reverse():d,direction:tB(s?u:h,e)}}function sB(t,e,n){let r=[t[0],e[1]];return Cm(r,n)&&(r=[e[0],t[1]]),r}const aB={top:0,bottom:0,left:Math.PI/2,right:Math.PI/2,"top-right":Math.PI/4,"right-top":Math.PI/4,"bottom-left":Math.PI/4,"left-bottom":Math.PI/4,"right-bottom":-Math.PI/4,"bottom-right":-Math.PI/4,"left-top":-Math.PI/4,"top-left":-Math.PI/4};function cB(t,e,n,r,i,o,A){var s;let a="number"==typeof e?e:.5;if("start"===e&&(a=0),"end"===e&&(a=.99),o&&A){a=.5,r=0,i=0;let e=null!==(s=aB[A])&&void 0!==s?s:0;Math.cos(e)<-1e-6&&(e+=Math.PI);const o=n&&0!==e,[c,l]=lB(t,a,r,i,o?e:void 0),u=[["translate",c,l]];return o&&u.push(["rotate",e/Math.PI*180]),{textAlign:"center",transform:u}}const c=Sy(t.getPoint(a)),l=Sy(t.getPoint(a+.01));let u="start"===e?"left":"end"===e?"right":"center";if(Ty(c,l)||!n){const[e,n]=lB(t,a,r,i);return{transform:[["translate",e,n]],textAlign:u}}let h=Math.atan2(l[1]-c[1],l[0]-c[0]);l[0]{const r=A[n-1]||i,a=A[n+1]||o;if(!Iy(r,t,a)&&e){const[n,i]=function(t,e,n,r){const i=fy(t,e),o=fy(n,e),A=Math.min(r,Math.min(i,o)/2),s=[e[0]-A/i*(e[0]-t[0]),e[1]-A/i*(e[1]-t[1])],a=[e[0]-A/o*(e[0]-n[0]),e[1]-A/o*(e[1]-n[1])];return[s,a]}(r,t,a,e);s.push(["L",n[0],n[1]],["Q",t[0],t[1],i[0],i[1]],["L",i[0],i[1]])}else s.push(["L",t[0],t[1]])}),s.push(["L",o[0],o[1]]),n&&s.push(["Z"]),s}function fB(t,e,n,r,i){const o=bm(t),A=t.getCenter();let s=r&&WB(r),a=i&&WB(i);if(!s||!a){const r=(t=>{const e=Math.PI/2,n=ym(t)/2,r=mm(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}})(o),i=r[e][0],c=r[e][1],[l,u]=wm(o),h=Math.max(l,u),d=ay(A,[h*Math.cos(i),h*Math.sin(i),0]),f=ay(A,[h*Math.cos(c),h*Math.sin(c),0]);s=$B(t,d),a=$B(t,f),n||([s,a]=[a,s])}return[s,a]}function gB(t,e,n,r){const i=t.getCenter();if(xe(e,n)){const t=cy(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[ay(e,o),ay(n,ly(o,[1,-1,1]))]}return[Ny(i,e,dy(i,e)+r),Ny(i,n,dy(i,n)+r)]}function pB(t,e,n,r,i,o,A){const s=zB(t),a=s[o||A],c=s[A||o];let[l,u]=fB(t,n,r,a,c);const h=function(t,e,n,r){const i=[],o=bm(t);if(xe(e,n)){switch(km(e,o)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=km(e,o),A=km(n,o);if(t===A){let o,A;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":A=Math.min(e[1],n[1])-r,i.push([e[0],A]),i.push([n[0],A]);break;case"bottom":A=Math.max(e[1],n[1])+r,i.push([e[0],A]),i.push([n[0],A])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),a=s(t,e),c=s(A,n),l=sB(a,c,o);i.push(a,l,c)}}return i}(t,l,u,i);return a&&(l=qB(a,h[0])),c&&(u=qB(c,h.at(-1))),dB([l,...h,u],e)}function vB(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach(o=>{e(o).forEach(e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)})}),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}function mB(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(Km(r));if(!t)break;r=t}if(n.some(t=>{var e;return null===(e=t.style)||void 0===e?void 0:e.collapsed})){const t=n.reverse().findIndex(rw);return n[t]||n.at(-1)}return t}const yB=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var wB=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",-t/2,0],["A",n,n,0,1,0,2*n-t/2,0],["A",n,n,0,1,0,-t/2,0],["Z"]]},diamond:(t,e)=>[["M",-t/2,0],["L",0,-e/2],["L",t/2,0],["L",0,e/2],["Z"]],rect:(t,e)=>[["M",-t/2,-e/2],["L",t/2,-e/2],["L",t/2,e/2],["L",-t/2,e/2],["Z"]],simple:(t,e)=>[["M",t/2,-e/2],["L",-t/2,0],["L",t/2,0],["L",-t/2,0],["L",t/2,e/2]],triangle:yB,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",-n,0],["L",0,-e/2],["L",0,e/2],["Z"],["M",i-n,-e/2],["L",i+r-n,-e/2],["L",i+r-n,e/2],["L",i-n,e/2],["Z"]]},vee:(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",4*t/5-t/2,0],["L",t/2,e/2],["Z"]]});class bB extends Uw{constructor(t){super(uw({style:bB.defaultStyleProps},t)),this.type="edge"}get sourceNode(){const{sourceNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}get targetNode(){const{targetNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}getKeyStyle(t){const e=this.getGraphicStyle(t),{loop:n}=e,r=Pe(e,["loop"]),{sourceNode:i,targetNode:o}=this,A={d:n&&GB(i,o)?this.getLoopPath(t):this.getKeyPath(t)};return nc.PARSED_STYLE_LIST.forEach(t=>{t in r&&(A[t]=r[t])}),A}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=bm(r),o=Math.max(mm(i),ym(i)),{type:A,placement:s,clockwise:a,dist:c=o}=Aw(this.getGraphicStyle(t),"loop");return"arc"===A?function(t,e,n,r,i,o){const A=t.getPorts()[i||o],s=t.getPorts()[o||i];let[a,c]=fB(t,e,n,A,s);if(xe(a,c)){const e=gB(t,a,c,r);return A&&(a=qB(A,e[0])),s&&(c=qB(s,e.at(-1))),hB(a,c,e)}const l=t.getCenter(),u=[(a[0]+c[0])/2,(a[1]+c[1])/2,0],h=dy(l,u)>1e-6?gy(cy(u,l)):[0,-1,0],d=dy(a,c),f=Math.max(Math.abs(r),.01),g=(d*d+4*f*f)/(8*f),p=[u[0]+h[0]*f,u[1]+h[1]*f,0],v=[u[0]+h[0]*(f-g),u[1]+h[1]*(f-g),0],m=2*Math.PI,y=Math.atan2(a[1]-v[1],a[0]-v[0]),w=((Math.atan2(c[1]-v[1],c[0]-v[0])-y)%m+m)%m,b=((Math.atan2(p[1]-v[1],p[0]-v[0])-y)%m+m)%m<=w+1e-6,B=b?1:0,E=(b?w:m-w)>Math.PI?1:0;if(A){const t=[a[0]-v[0],a[1]-v[1],0];a=qB(A,ay(a,1===B?[-t[1],t[0],0]:[t[1],-t[0],0]))}if(s){const t=[c[0]-v[0],c[1]-v[1],0];c=qB(s,ay(c,1===B?[t[1],-t[0],0]:[-t[1],t[0],0]))}return[["M",a[0],a[1]],["A",g,g,0,E,B,c[0],c[1]]]}(r,s,a,c,e,n):function(t,e,n,r,i,o){const A=t.getPorts()[i||o],s=t.getPorts()[o||i];let[a,c]=fB(t,e,n,A,s);const l=gB(t,a,c,r);return A&&(a=qB(A,l[0])),s&&(c=qB(s,l.at(-1))),hB(a,c,l)}(r,s,a,c,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:A}=this,[s,a]=function(t,e,n,r){const i=YB(t,e,n,r),o=YB(e,t,r,n);return[i,o]}(o,A,r,i);if(!e){return[s?WB(s):o.getCenter(),a?WB(a):A.getCenter()]}const c="function"==typeof n?n():n;return[XB(s||o,c[0]||a||A),XB(a||A,c[c.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Aw(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Aw(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:A}=e,s=Pe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),a=t.loop&&GB(this.sourceNode,this.targetNode),{placement:c}=Aw(this.getGraphicStyle(t),"loop"),l=cB(this.shapeMap.key,n,o,r,i,a,c),u=this.shapeMap.key.getLocalBounds(),h=function(t,e,n=1){return fw(dy(t[0],t[1])*n,e)}([u.min,u.max],A);return Object.assign({wordWrapWidth:h},l,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Aw(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Pe(e,["offsetX","offsetY","placement"]);return Object.assign(o,function(t,e,n,r,i){var o,A;const s=2*(null===(o=t.badge)||void 0===o?void 0:o.getGeometryBounds().halfExtents[0])||0,a=2*(null===(A=t.label)||void 0===A?void 0:A.getGeometryBounds().halfExtents[0])||0;return cB(t.key,n,!0,(a?(a/2+s/2)*("suffix"===e?1:-1):0)+r,i)}(this.shapeMap,i,t.labelPlacement,n,r))}drawArrow(t,e){var n;const r="start"===e,i=t["start"===e?"startArrow":"endArrow"],o=this.shapeMap.key;if(i){const e=this.getArrowStyle(t,r),[n,i,A]=r?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],s=o.parsedStyle[n];if(s)s.attr(e);else{const t=new(e.src?Za:nc)({style:e});o.style[n]=t}o.style[i]=t[A]||e.width/2+ +e.lineWidth}else{const t=r?"markerStart":"markerEnd";null===(n=o.style[t])||void 0===n||n.destroy(),o.style[t]=null}}getArrowStyle(t,e){const n=this.getShape("key").attributes,r=e?"startArrow":"endArrow",i=Aw(this.getGraphicStyle(t),r),{size:o,type:A}=i,s=Pe(i,["size","type"]),[a,c]=cw(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),l=(Gt(A)?A:wB[A]||yB)(a,c);return Object.assign(ke(n,["stroke","strokeOpacity","fillOpacity"]),{width:a,height:c},Object.assign({},l&&{d:l,fill:"simple"===A?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",yw,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",nc,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",ww,n,e)}drawSourceArrow(t){this.drawArrow(t,"start")}drawTargetArrow(t){this.drawArrow(t,"end")}drawKeyShape(t,e){const n=this.getKeyStyle(t);return this.upsert("key",nc,n,e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.getShape("key")&&(this.drawSourceArrow(t),this.drawTargetArrow(t),this.drawLabelShape(t,e),this.drawHaloShape(t,e),this.drawBadgeShape(t,e))}onframe(){this.drawKeyShape(this.parsedAttributes,this),this.drawSourceArrow(this.parsedAttributes),this.drawTargetArrow(this.parsedAttributes),this.drawHaloShape(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this),this.drawBadgeShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(t,e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then(()=>this.onframe()),Reflect.set(t,e,n))}):n}}bB.defaultStyleProps={badge:!0,badgeOffsetX:0,badgeOffsetY:0,badgePlacement:"suffix",isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,loop:!0,startArrow:!1,startArrowLineDash:0,startArrowLineJoin:"round",startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"vee",endArrow:!1,endArrowLineDash:0,endArrowLineJoin:"round",endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"vee",loopPlacement:"top",loopClockwise:!0};class BB extends bB{constructor(t){super(uw({style:BB.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,A=this.getControlPoints(e,n,function(t){return re(t)?[t,1-t]:t}(i),function(t){return re(t)?[t,-t]:t}(o),r);return hB(e,n,A)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[uB(t,e,n[0],r[0]),uB(t,e,n[1],r[1])]}}BB.defaultStyleProps={curvePosition:.5,curveOffset:20};class EB extends BB{constructor(t){super(uw({style:EB.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}EB.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class xB extends BB{constructor(t){super(uw({style:xB.defaultStyleProps},t))}get ref(){return this.context.model.getRootsData()[0]}getEndpoints(t){if(this.sourceNode.id===this.ref.id)return super.getEndpoints(t);const e=My(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=My(this.ref);return[dy(t,e),by(cy(t,e))]}getControlPoints(t,e,n,r){const[i,o]=this.toRadialCoordinate(t),[A]=this.toRadialCoordinate(e),s=A-i;return[[t[0]+(s*n[0]+r[0])*Math.cos(o),t[1]+(s*n[0]+r[0])*Math.sin(o)],[e[0]-(s*n[1]-r[0])*Math.cos(o),e[1]-(s*n[1]-r[0])*Math.sin(o)]]}}xB.defaultStyleProps={curvePosition:.5,curveOffset:20};class CB extends BB{constructor(t){super(uw({style:CB.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}CB.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let MB=class t extends bB{constructor(e){super(uw({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};MB.defaultStyleProps={};const FB={enableObstacleAvoidance:!1,offset:10,maxAllowedDirectionChange:Math.PI/2,maximumLoops:3e3,gridSize:5,startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{right:{stepX:1,stepY:0},left:{stepX:-1,stepY:0},bottom:{stepX:0,stepY:1},top:{stepX:0,stepY:-1}},penalties:{0:0,90:0},distFunc:fy},kB=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function SB(t,e){const n=t=>Math.round(t/e);return re(t)?n(t):t.map(n)}function QB(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function UB(t,e,n,r){const i=QB(t,e),o=n[kB(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(QB(o||r,t),i)}function NB(t,e,n){return Math.min(...e.map(e=>n(t,e)))}const TB=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,A=Em(e.getRenderBounds(),o),s=Object.keys(i).reduce((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=wm(A),a=[t[0]+n.stepX*o,t[1]+n.stepY*s],c=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],A=[r,i],s=[r,n],a=[e,n];return[[o,A],[A,s],[s,a],[a,o]]}(A);for(let n=0;nSB(t,r.gridSize))},OB=(t,e,n,r,i,o,A)=>{const s=[];let a=[o[0]===r[0]?r[0]:t[0]*A,o[1]===r[1]?r[1]:t[1]*A];s.unshift(a);let c=t,l=e[kB(c)];for(;l;){const t=l,r=c;UB(t,r,e,n)&&(a=[t[0]===r[0]?a[0]:t[0]*A,t[1]===r[1]?a[1]:t[1]*A],s.unshift(a)),l=e[kB(t)],c=t}const u=i.map(t=>[t[0]*A,t[1]*A]),h=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o{const{offset:n,gridSize:r}=e,i={};return t.forEach(t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Em(t.getRenderBounds(),n);for(let t=SB(e.min[0],r);t<=SB(e.max[0],r);t+=1)for(let n=SB(e.min[1],r);n<=SB(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0}),i})(A.enableObstacleAvoidance?n:[t,e],A),c=SB(i,s),l=SB(o,s),u=TB(i,t,A.startDirections,A),h=TB(o,e,A.endDirections,A);u.forEach(t=>delete a[kB(t)]),h.forEach(t=>delete a[kB(t)]);const d={},f={},g={},p={},v={},m=new LB;for(let t=0;tkB(t));let w,b=A.maximumLoops,B=1/0;for(const[t,e]of Object.entries(d))v[t]<=B&&(B=v[t],w=e);for(;Object.keys(d).length>0&&b>0;){const t=m.minId(!1);if(!t)break;w=d[t];const e=kB(w);if(y.includes(e))return OB(w,g,c,o,u,l,s);delete d[e],m.remove(e),f[e]=!0;for(const t of Object.values(A.directionMap)){const n=ay(w,[t.stepX,t.stepY]),r=kB(n);if(f[r])continue;const i=UB(w,n,g,c);if(i>A.maxAllowedDirectionChange)continue;if(a[r])continue;d[r]||(d[r]=n);const o=A.penalties[i],l=A.distFunc(w,n)+(isNaN(o)?s:o),u=p[e]+l,y=p[r];y&&u>=y||(g[r]=w,p[r]=u,v[r]=u+NB(n,h,A.distFunc),m.add({id:r,value:v[r]}))}b-=1}return[]}class LB{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){let n=0,r=e-1;for(;r-n>1;){const e=Math.floor((n+r)/2);if(this.arr[e].value>t.value)r=e;else{if(!(this.arr[e].value=0;e--)this.map[this.arr[e].id]?t=this.arr[e].id:this.arr.splice(e,1);return t}_findFirstId(){for(;this.arr.length;){const t=this.arr.shift();if(this.map[t.id])return t.id}}minId(t){return t?this._clearAndGetMinId():this._findFirstId()}}class PB extends bB{constructor(t){super(uw({style:PB.defaultStyleProps},t))}getControlPoints(t){const{router:e}=t,{sourceNode:n,targetNode:r}=this,[i,o]=this.getEndpoints(t,!1);let A=[];if(e)if("shortest-path"===e.type){A=IB(n,r,this.context.element.getNodes(),e),A.length||(A=$b(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(A=$b(i,o,n,r,t.controlPoints,e));else A=t.controlPoints;return A}getPoints(t){const e=this.getControlPoints(t),[n,r]=this.getEndpoints(t,!0,e);return[n,...e,r]}getKeyPath(t){return dB(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=bm(i),A=Math.max(mm(o),ym(o))/4,{placement:s,clockwise:a,dist:c=A}=Aw(this.getGraphicStyle(t),"loop");return pB(i,r,s,a,c,e,n)}}PB.defaultStyleProps={radius:0,controlPoints:[],router:!1};class DB extends bB{constructor(t){super(uw({style:DB.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||uB(r,i,e,n))}}function RB(t){return t instanceof Nw&&"node"===t.type}function HB(t){return t instanceof bB}function _B(t){return t instanceof Wb}function GB(t,e){return!(!t||!e)&&t===e}DB.defaultStyleProps={curvePosition:.5,curveOffset:30};const KB={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],"left-top":[0,0],"top-left":[0,0],"left-bottom":[0,1],"bottom-left":[0,1],"right-top":[1,0],"top-right":[1,0],"right-bottom":[1,1],"bottom-right":[1,1],default:[.5,.5]};function jB(t,e,n=KB,r=!0){const i=[.5,.5],o=Jt(e)?Ce(n,e.toLocaleLowerCase(),i):e;if(!r&&Jt(e))return o;const[A,s]=o||i;return[t.min[0]+mm(t)*A,t.min[1]+ym(t)*s]}function zB(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach((n,r)=>{var i;const{key:o,placement:A}=n;VB(n)&&(e[i=o||r]||(e[i]=ky(t.getShape("key").getBounds(),A)))}),e}function VB(t){const{r:e}=t;return!e||0===Number(e)}function WB(t){return fm(t)?t:t.getPosition()}function YB(t,e,n,r){const i=zB(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const A=o.map(t=>WB(t)),s=function(t,e){const n=zB(t);if(e)return[WB(n[e])];const r=Object.values(n);return r.length>0?r.map(t=>WB(t)):[t.getCenter()]}(e,r),[a]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach(t=>{e.forEach(e=>{const i=dy(t,e);iWB(t)===a)}function XB(t,e){return _B(t)||RB(t)?$B(t,e):qB(t,e)}function qB(t,e){if(!t||!e)return[0,0,0];if(fm(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return Dy(fm(e)?e:RB(e)?e.getCenter():e.getPosition(),t.getBounds())}function $B(t,e){if(!t||!e)return[0,0,0];const n=fm(e)?e:RB(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function ZB(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[A,s]=ky(t,e),[a,c]=i?["bottom","top"]:["top","bottom"];return{transform:[["translate",A+n,s+r]],textBaseline:o.includes("top")?c:o.includes("bottom")?a:"middle",textAlign:o.includes("left")?"right":o.includes("right")?"left":"center"}}function JB(t){return"hidden"!==Ce(t,["style","visibility"])}function tE(t,e){"update"in t?t.update(e):t.attr(e)}function eE(t){return Ce(t,"__to_be_destroyed__",!1)}class nE extends iy{constructor(t,e){super(t,Object.assign({},nE.defaultOptions,e)),this.onCollapseExpand=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{target:e}=t;if(!(RB(n=e)||HB(n)||_B(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,A=i.getElementDataById(r);if(!A)return!1;const{onCollapse:s,onExpand:a,animation:c,align:l}=this.options;rw(A)?(yield o.expandElement(r,{animation:c,align:l}),null==a||a(r)):(yield o.collapseElement(r,{animation:c,align:l}),null==s||s(r))}),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`node:${e}`,this.onCollapseExpand),t.on(`combo:${e}`,this.onCollapseExpand)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`node:${e}`,this.onCollapseExpand),t.off(`combo:${e}`,this.onCollapseExpand)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}function rE(t,e){const{data:n,style:r}=t,i=Pe(t,["data","style"]),{data:o,style:A}=e,s=Pe(e,["data","style"]),a=Object.assign(Object.assign({},i),s);return(n||o)&&Object.assign(a,{data:Object.assign(Object.assign({},n),o)}),(r||A)&&Object.assign(a,{style:Object.assign(Object.assign({},r),A)}),a}function iE(t){const{data:e,style:n}=t,r=Pe(t,["data","style"]);return e&&(r.data=Object.assign({},e)),n&&(r.style=Object.assign({},n)),r}function oE(t={},e={}){const{states:n=[],data:r={},style:i={},children:o=[]}=t,A=Pe(t,["states","data","style","children"]),{states:s=[],data:a={},style:c={},children:l=[]}=e,u=(t,e)=>t.length===e.length&&t.every((t,n)=>t===e[n]),h=(t,e)=>{const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(n=>t[n]===e[n])};return!!h(A,Pe(e,["states","data","style","children"]))&&(!!u(o,l)&&(!!u(n,s)&&(!!h(r,a)&&!!h(i,c))))}nE.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const AE="__internal_override__";function sE(t){return!1!==t[AE]}const aE="g6-create-edge-assist-node-id";class cE extends iy{constructor(t,e){super(t,Object.assign({},cE.defaultOptions,e)),this.drop=t=>De(this,void 0,void 0,function*(){const{targetType:e}=t;["combo","node"].includes(e)&&this.source?yield this.handleCreateEdge(t):yield this.cancelEdge()}),this.handleCreateEdge=t=>De(this,void 0,void 0,function*(){var e,n,r;if(!this.validate(t))return;const{graph:i,canvas:o,batch:A,element:s}=this.context,{style:a}=this.options;if(this.source)return this.createEdge(t),void(yield this.cancelEdge());A.startBatch(),o.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0];const c=i.getElementData(this.source);i.addNodeData([{id:aE,type:"circle",[AE]:!1,style:{size:1,visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=c.style)||void 0===e?void 0:e.x,y:null===(n=c.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:aE,style:Object.assign({pointerEvents:"none"},a)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished}),this.updateAssistEdge=t=>De(this,void 0,void 0,function*(){var e;if(!this.source)return;const{model:n,element:r,graph:i}=this.context,[o,A]=i.getCanvasByClient([t.client.x,t.client.y]);n.translateNodeTo(aE,[o,A]),yield null===(e=r.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished}),this.createEdge=t=>{var e,n;const{graph:r}=this.context,{style:i,onFinish:o,onCreate:A}=this.options;if(void 0===(null===(e=t.target)||void 0===e?void 0:e.id)||void 0===this.source)return;const s=null===(n=this.getSelectedNodeIDs([t.target.id]))||void 0===n?void 0:n[0];var a;const c=A({id:`${this.source}-${s}-${Ue[a=a||"g"]?Ue[a]+=1:Ue[a]=1,a+Ue[a]}`,source:this.source,target:s,style:i});c&&(r.addEdgeData([c]),o(c))},this.cancelEdge=()=>De(this,void 0,void 0,function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([aE]),this.source=void 0,yield null===(t=n.draw({animation:!1}))||void 0===t?void 0:t.finished,r.endBatch()}),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(t.NodeEvent.CLICK,this.handleCreateEdge),e.on(t.ComboEvent.CLICK,this.handleCreateEdge),e.on(t.CanvasEvent.CLICK,this.cancelEdge),e.on(t.EdgeEvent.CLICK,this.cancelEdge)):(e.on(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.on(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map(t=>t.id).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.CLICK,this.handleCreateEdge),e.off(t.ComboEvent.CLICK,this.handleCreateEdge),e.off(t.CanvasEvent.CLICK,this.cancelEdge),e.off(t.EdgeEvent.CLICK,this.cancelEdge),e.off(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.off(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}cE.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class lE extends iy{constructor(t,e){super(t,Object.assign({},lE.defaultOptions,e)),this.isDragging=!1,this.onDragStart=t=>{this.validate(t)&&(this.isDragging=!0,this.context.canvas.setCursor("grabbing"))},this.onDrag=t=>{var e,n,r,i;if(!this.isDragging||Ky.isPinching)return;const o=null!==(n=null===(e=t.movement)||void 0===e?void 0:e.x)&&void 0!==n?n:t.dx,A=null!==(i=null===(r=t.movement)||void 0===r?void 0:r.y)&&void 0!==i?i:t.dy;0!==(o|A)&&this.translate([o,A],!1)},this.onDragEnd=()=>{var t,e;this.isDragging=!1,this.context.canvas.setCursor(this.defaultCursor),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)},this.invokeOnFinish=pe(()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)},300),this.shortcut=new Wy(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(zt(e)){const{up:t=[],down:n=[],left:r=[],right:i=[]}=e;this.shortcut.bind(t,t=>this.onTranslate([0,1],t)),this.shortcut.bind(n,t=>this.onTranslate([0,-1],t)),this.shortcut.bind(r,t=>this.onTranslate([1,0],t)),this.shortcut.bind(i,t=>this.onTranslate([-1,0],t))}else{const{graph:e}=this.context;e.on(t.CommonEvent.DRAG_START,this.onDragStart),e.on(t.CommonEvent.DRAG,this.onDrag),e.on(t.CommonEvent.DRAG_END,this.onDragEnd)}}onTranslate(t,e){return De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(ly(t,r),this.options.animation),this.invokeOnFinish()})}translate(t,e){return De(this,void 0,void 0,function*(){t=this.clampByDirection(t),t=this.clampByRange(t),t=this.clampByRotation(t),yield this.context.graph.translateBy(t,e)})}clampByRotation([t,e]){return By([t,e],this.context.graph.getRotation())}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[A,s,a,c]=pm(this.options.range),l=[o*A,i*s,o*a,i*c],u=Em(Bm(n.getCanvasCenter()),l),h=cy(n.getViewportCenter(),[t,e,0]);if(!Cm(h,u)){const{min:[n,r],max:[i,o]}=u;(h[0]0||h[0]>i&&t<0)&&(t=0),(h[1]0||h[1]>o&&e<0)&&(e=0)}return[t,e]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return"function"==typeof e?e(t):!!e}unbindEvents(){this.shortcut.unbindAll();const{graph:e}=this.context;e.off(t.CommonEvent.DRAG_START,this.onDragStart),e.off(t.CommonEvent.DRAG,this.onDrag),e.off(t.CommonEvent.DRAG_END,this.onDragEnd)}destroy(){this.shortcut.destroy(),this.unbindEvents(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}lE.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class uE extends iy{constructor(e,n){super(e,Object.assign({},uE.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>De(this,void 0,void 0,function*(){var e;if("link"!==this.options.dropEffect)return;const{model:n,element:r}=this.context,i=t.target.id;this.target.forEach(t=>{const e=n.getParentData(t,zv);e&&Km(e)===i&&n.refreshComboData(i),n.setParent(t,i,zv)}),yield null===(e=null==r?void 0:r.draw({animation:!0}))||void 0===e?void 0:e.finished}),this.setCursor=e=>{if(this.isDragging)return;const{type:n}=e,{canvas:r}=this.context,{cursor:i}=this.options;n===t.CommonEvent.POINTER_ENTER?r.setCursor((null==i?void 0:i.grab)||"grab"):r.setCursor((null==i?void 0:i.default)||"default")},this.shortcut=new Wy(e.graph),this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.addEventListener("blur",this.onDragEnd),r.addEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach(n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)}),["link"].includes(this.options.dropEffect)&&(e.on(t.ComboEvent.DROP,this.onDrop),e.on(t.CanvasEvent.DROP,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map(t=>t.id).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return uy([t.dx,t.dy],e)}onDragStart(t){var e;if(this.enable=this.validate(t),!this.enable)return;const{batch:n,canvas:r,graph:i}=this.context;r.setCursor((null===(e=this.options.cursor)||void 0===e?void 0:e.grabbing)||"grabbing"),this.isDragging=!0,n.startBatch();const o=t.target.id;i.getElementState(o).includes(this.options.state)?this.target=this.getSelectedNodeIDs([o]):this.target=[o],this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target)}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){var t,e,n;if(!this.enable)return;if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=cy([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t,this.target);const{batch:r,canvas:i}=this.context;r.endBatch(),i.setCursor((null===(n=this.options.cursor)||void 0===n?void 0:n.grab)||"grab"),this.isDragging=!1,this.target=[]}isKeydown(){const{trigger:t}=this.options;return!(null==t?void 0:t.length)||this.shortcut.match(t)}validate(t){if(this.destroyed||eE(t.target)||this.context.graph.isCollapsingExpanding||!this.isKeydown())return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}clampByRotation([t,e]){return By([t,e],this.context.graph.getRotation())}moveElement(t,e){return De(this,void 0,void 0,function*(){const{graph:n,model:r}=this.context,{dropEffect:i}=this.options;"move"===i&&t.forEach(t=>r.refreshComboData(t)),n.translateElementBy(Object.fromEntries(t.map(t=>[t,this.clampByRotation(e)])),!1)})}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=Aw(this.options,"shadow"),n=xm(t.map(t=>this.context.element.getElement(t).getBounds())),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,A]=wm(n),s={width:o,height:A,x:r,y:i};this.shadow?this.shadow.attr(Object.assign(Object.assign(Object.assign({},e),s),{visibility:"visible"})):(this.shadow=new sc({style:Object.assign(Object.assign(Object.assign({$layer:"transient"},e),s),{pointerEvents:"none"})}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdge(){const{hideEdge:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(Km):Array.from(new Set(this.target.map(e=>n.getRelatedEdgesData(e,t).map(Km)).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.removeEventListener("blur",this.onDragEnd),r.removeEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach(n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)}),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){var t;this.unbindEvents(),null===(t=this.shadow)||void 0===t||t.destroy(),super.destroy()}}uE.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),trigger:[],dropEffect:"move",state:"selected",hideEdge:"none",shadow:!1,shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5],cursor:{default:"default",grab:"grab",grabbing:"grabbing"}};var hE=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r{e.has(n.id)||(e.add(n.id),t.push(n))})}return!1}function fE(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&fE(i,e,n,r))return!0;return!1}const gE=()=>!0;class pE{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||gE,n=t.edgeFilter||gE;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(t=>t.id))};updateCache=t=>{const e=new Set;t.forEach(t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach(t=>e.add(t.id)),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach(t=>e.add(t.id)),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)}),e.forEach(t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)})};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach(n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}}),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some(e=>e.id===t)}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map(t=>this.getNode(t.target));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map(t=>this.getNode(t.source));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];dE([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];fE(this.getNode(t),new Set,e,r)}}let vE=class t extends hE{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach(t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter(e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id}),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter(e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id}),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex(e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName)),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter(e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey),e.push(t);break;case"TreeStructureChanged":{const n=e.find(e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId);n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}}),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some(e=>e.id===t)}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map(t=>this.getNode(t.target));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map(t=>this.getNode(t.source));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach(e=>{e.childrenMap.set(t.id,new Set)}),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch(()=>{for(const e of t)this.doAddNode(e)})}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach(t=>this.doRemoveEdge(t.id)),this.nodeMap.delete(t),this.treeIndices.forEach(n=>{n.childrenMap.get(t)?.forEach(t=>{n.parentMap.delete(t.id)});const r=n.parentMap.get(t);r&&n.childrenMap.get(r.id)?.delete(e),n.parentMap.delete(t),n.childrenMap.delete(t)}),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch(()=>{t.forEach(t=>this.doRemoveNode(t))})}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch(()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})})}mergeNodeData(t,e){this.batch(()=>{Object.entries(e).forEach(([e,n])=>{this.updateNodeDataProperty(t,e,n)})})}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch(()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})})}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch(()=>{for(const e of t)this.doAddEdge(e)})}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch(()=>{t.forEach(t=>this.doRemoveEdge(t))})}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})})}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})})}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch(()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})})}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch(()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})})}mergeEdgeData(t,e){this.batch(()=>{Object.entries(e).forEach(([e,n])=>{this.updateEdgeDataProperty(t,e,n)})})}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})}))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})})}addTree(t,e){this.batch(()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach(t=>{t.children?.forEach(n=>{this.setParent(n.id,t.id,e)})})})}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter(e=>!this.getParent(e.id,t))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n);if(!r)return;const i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(null==e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const A=this.getNode(e);r.parentMap.set(t,A),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(A.id);s||(s=new Set,r.childrenMap.set(A.id,s)),s.add(i),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:A.id})})}dfsTree(t,e,n){return fE(this.getNode(t),new Set,e,t=>this.getChildren(t,n))}bfsTree(t,e,n){return dE([this.getNode(t)],new Set,e,t=>this.getChildren(t,n))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return dE([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return fE(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map(t=>({...t,data:{...t.data}})),n=this.getAllEdges().map(t=>({...t,data:{...t.data}})),r=new t({nodes:e,edges:n});return this.treeIndices.forEach(({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach((t,e)=>{i.set(e,r.getNode(t.id))});const o=new Map;e.forEach((t,e)=>{o.set(e,new Set(Array.from(t).map(t=>r.getNode(t.id))))}),r.treeIndices.set(n,{parentMap:i,childrenMap:o})}),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new pE({graph:this,...t})}},mE=class{constructor(t,e){this.context=t,this.options=e||{}}};function yE(t,e){return class extends mE{constructor(e,n){if(super(e,n),this.instance=new t({}),this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>(t.tick(e),this.getLayoutResult(t))}}execute(t,e){return De(this,void 0,void 0,function*(){return yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(be({},this.options,e))),this.getLayoutResult(this.instance)})}graphData2LayoutModel(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e,...r],edges:n}}transformOptions(t){if(t.node=t=>{var n;const{style:r}=t||{},i="combo"in(t||{})&&null!==(n=t.combo)&&void 0!==n?n:null,o=Km(t);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({id:o},re(null==r?void 0:r.x)?{x:r.x}:{}),re(null==r?void 0:r.y)?{y:r.y}:{}),re(null==r?void 0:r.z)?{z:r.z}:{}),{parentId:i}),(t=>e.model.isCombo(t))(o)?{isCombo:!0}:{})},t.edge=t=>({id:Km(t),source:t.source,target:t.target}),!("onTick"in t))return t;const n=t.onTick;return t.onTick=t=>n(this.getLayoutResult(t)),t}getLayoutResult(t){const{model:e}=this.context,n={nodes:[],edges:[],combos:[]};return t.forEachNode(t=>{var r;const i=String(t.id),o=e.isCombo(i)?n.combos:n.nodes,A=Object.assign({x:t.x,y:t.y,z:null!==(r=t.z)&&void 0!==r?r:0},t.size?{size:t.size}:{});null==o||o.push({id:i,style:A})}),t.forEachEdge(t=>{const e={controlPoints:t.points||[]};n.edges.push({id:String(t.id),source:String(t.source),target:String(t.target),style:e})}),n}}}function wE(t){const{nodes:e,edges:n=[]}=t,r={nodes:[],edges:[],combos:[]};return e.forEach(t=>{const e=t.data._isCombo?r.combos:r.nodes,{x:n,y:i,z:o=0}=t.data;null==e||e.push({id:t.id,style:{x:n,y:i,z:o}})}),n.forEach(t=>{const{id:e,source:n,target:i,data:{points:o=[],controlPoints:A=o.slice(1,o.length-1)}}=t;r.edges.push({id:e,source:n,target:i,style:Object.assign({},(null==A?void 0:A.length)?{controlPoints:A.map(Sy)}:{})})}),r}function bE(t,e,...n){if(e in t)return t[e](...n);if("instance"in t){const r=t.instance;if(e in r)return r[e](...n)}return null}function BE(t,e){if(e in t)return t[e];if("instance"in t){const n=t.instance;if(e in n)return n[e]}return null}class EE extends uE{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find(t=>["d3-force","d3-force-3d"].includes(null==t?void 0:t.id))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(Zv("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return De(this,void 0,void 0,function*(){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach((r,i)=>{const{x:o=0,y:A=0}=r.style||{};n&&bE(n,"setFixedPosition",t[i],[...ay([+o,+A],this.clampByRotation(e))])})})}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e&&BE(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach(t=>{const{x:n=0,y:r=0}=t.style||{};e&&bE(e,"setFixedPosition",Km(t),[+n,+r])})}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t&&BE(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach(e=>{t&&bE(t,"setFixedPosition",Km(e),[null,null,null])})}}class xE extends iy{constructor(t,e){super(t,Object.assign({},xE.defaultOptions,e)),this.isZoomEvent=t=>Boolean(t.data&&"scale"in t.data),this.relatedEdgeToUpdate=new Set,this.zoom=this.context.graph.getZoom(),this.fixElementSize=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{graph:e}=this.context,{state:n,nodeFilter:r,edgeFilter:i,comboFilter:o}=this.options,A=(n?e.getElementDataByState("node",n):e.getNodeData()).filter(r),s=(n?e.getElementDataByState("edge",n):e.getEdgeData()).filter(i),a=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),c=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,l=[...A,...a];l.length>0&&l.forEach(t=>this.fixNodeLike(t,c)),this.updateRelatedEdges(),s.length>0&&s.forEach(t=>this.fixEdge(t,c))}),this.cachedStyles=new Map,this.getOriginalFieldValue=(t,e,n)=>{var r;const i=this.cachedStyles.get(t)||[],o=(null===(r=i.find(t=>t.shape===e))||void 0===r?void 0:r.style)||{};return n in o||(o[n]=e.attributes[n],this.cachedStyles.set(t,[...i.filter(t=>t.shape!==e),{shape:e,style:o}])),o[n]},this.scaleEntireElement=(t,e,n)=>{e.setLocalScale(1/n);const r=this.cachedStyles.get(t)||[];r.push({shape:e}),this.cachedStyles.set(t,r)},this.scaleSpecificShapes=(t,e,n)=>{const r=function(t){const e=[],n=t=>{(null==t?void 0:t.children.length)&&t.children.forEach(t=>{e.push(t),n(t)})};return n(t),e}(t);(Array.isArray(n)?n:[n]).forEach(n=>{const{shape:i,fields:o}=n,A="function"==typeof i?i(r):t.getShape(i);A&&(o?o.forEach(n=>{const r=this.getOriginalFieldValue(t.id,A,n);re(r)&&(A.style[n]=r/e)}):this.scaleEntireElement(t.id,A,e))})},this.skipIfExceedViewport=t=>{const{viewport:e}=this.context;return!(null==e?void 0:e.isInViewport(t.getRenderBounds(),!1,30))},this.fixNodeLike=(t,e)=>{const n=Km(t),{element:r,model:i}=this.context,o=r.getElement(n);if(!o||this.skipIfExceedViewport(o))return;i.getRelatedEdgesData(n).forEach(t=>this.relatedEdgeToUpdate.add(Km(t)));const A=this.options[o.type];A?this.scaleSpecificShapes(o,e,A):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=Km(t),r=this.context.element.getElement(n);if(!r||this.skipIfExceedViewport(r))return;const i=this.options.edge;if(!i)return r.style.transformOrigin="center",void this.scaleEntireElement(n,r,e);this.scaleSpecificShapes(r,e,i)},this.updateRelatedEdges=()=>{const{element:t}=this.context;this.relatedEdgeToUpdate.size>0&&this.relatedEdgeToUpdate.forEach(e=>{const n=t.getElement(e);null==n||n.update({})}),this.relatedEdgeToUpdate.clear()},this.resetTransform=t=>De(this,void 0,void 0,function*(){var e;(null===(e=t.data)||void 0===e?void 0:e.firstRender)||(this.options.reset?this.restoreCachedStyles():this.fixElementSize({data:{scale:this.zoom}}))}),this.bindEvents()}restoreCachedStyles(){if(this.cachedStyles.size>0){this.cachedStyles.forEach(t=>{t.forEach(({shape:t,style:e})=>{if(Ee(e))t.setLocalScale(1);else{if(this.options.state)return;Object.entries(e).forEach(([e,n])=>t.style[e]=n)}})});const{graph:t,element:e}=this.context,n=Object.keys(Object.fromEntries(this.cachedStyles)).filter(e=>e&&"node"===t.getElementType(e));if(n.length>0){const r=new Set;n.forEach(e=>{t.getRelatedEdgesData(e).forEach(t=>r.add(Km(t)))}),r.forEach(t=>{const n=null==e?void 0:e.getElement(t);null==n||n.update({})})}}}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.on(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.off(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}xE.defaultOptions={enable:t=>t.data.scale<1,nodeFilter:()=>!0,edgeFilter:()=>!0,comboFilter:()=>!0,edge:[{shape:"key",fields:["lineWidth"]},{shape:"halo",fields:["lineWidth"]},{shape:"label"}],reset:!1};class CE extends iy{constructor(t,e){super(t,Object.assign({},CE.defaultOptions,e)),this.focus=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{graph:e}=this.context;yield e.focusElement(t.target.id,this.options.animation)}),this.shortcut=new Wy(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)})}validate(t){if(this.destroyed||!this.isKeydown())return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}isKeydown(){const{trigger:t}=this.options;return!(null==t?void 0:t.length)||this.shortcut.match(t)}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)})}destroy(){this.unbindEvents(),this.shortcut.destroy(),super.destroy()}}CE.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0,trigger:[]};class ME extends iy{constructor(e,n){super(e,Object.assign({},ME.defaultOptions,n)),this.isFrozen=!1,this.toggleFrozen=t=>{this.isFrozen="dragstart"===t.type},this.hoverElement=e=>{if(!this.validate(e))return;const n=e.type===t.CommonEvent.POINTER_ENTER;this.updateElementsState(e,n);const{onHover:r,onHoverEnd:i}=this.options;n?null==r||r(e):null==i||i(e)},this.updateElementsState=(t,e)=>{if(!this.options.state&&!this.options.inactiveState)return;const{graph:n}=this.context,{state:r,animation:i,inactiveState:o}=this.options,A=this.getActiveIds(t),s={};if(r&&Object.assign(s,this.getElementsState(A,r,e)),o){const t=zm(n.getData(),!0).filter(t=>!A.includes(t));Object.assign(s,this.getElementsState(t,o,e))}n.setElementState(s,i)},this.getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach(t=>{const o=r.getElementState(t);i[t]=n?o.includes(e)?o:[...o,e]:o.filter(t=>t!==e)}),i},this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)});const n=this.context.canvas.document;n.addEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.addEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}getActiveIds(t){const{graph:e}=this.context,{degree:n,direction:r}=this.options,i=t.target.id;return n?Jy(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||eE(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)});const n=this.context.canvas.document;n.removeEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.removeEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}destroy(){this.unbindEvents(),super.destroy()}}ME.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class FE extends Yy{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e,graph:n}=this.context;this.pathShape=new nc({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[Xy(t,n)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(Xy(t,this.context.graph)),null===(e=this.pathShape)||void 0===e||e.setAttribute("d",function(t,e=!0){const n=[];return t.forEach((t,e)=>{n.push([0===e?"M":"L",...t])}),e&&n.push(["Z"]),n}(this.points)),n&&"default"===r&&this.points.length>2&&super.updateElementsStates(this.points)}onPointerUp(){this.points&&(this.points.length<2||super.updateElementsStates(this.points),this.clearLasso())}clearLasso(){var t;null===(t=this.pathShape)||void 0===t||t.remove(),this.pathShape=void 0,this.points=void 0}}class kE extends iy{constructor(t,e){super(t,Object.assign({},kE.defaultOptions,e)),this.hiddenShapes=[],this.isVisible=!0,this.setElementsVisibility=(t,e,n)=>{t.filter(Boolean).forEach(t=>{"hidden"!==e||t.isVisible()?"visible"===e&&this.hiddenShapes.includes(t)?this.hiddenShapes.splice(this.hiddenShapes.indexOf(t),1):ey(t,e,n):this.hiddenShapes.push(t)})},this.filterShapes=(t,e)=>{if(Gt(e))return n=>!e(t,n);const n=null==e?void 0:e[t];return t=>!t.className||!(null==n?void 0:n.includes(t.className))},this.hideShapes=t=>{if(!this.validate(t)||!this.isVisible)return;const{element:e}=this.context,{shapes:n={}}=this.options;this.setElementsVisibility(e.getNodes(),"hidden",this.filterShapes("node",n)),this.setElementsVisibility(e.getEdges(),"hidden",this.filterShapes("edge",n)),this.setElementsVisibility(e.getCombos(),"hidden",this.filterShapes("combo",n)),this.isVisible=!1},this.showShapes=pe(t=>{if(!this.validate(t)||this.isVisible)return;const{element:e}=this.context;this.setElementsVisibility(e.getNodes(),"visible"),this.setElementsVisibility(e.getEdges(),"visible"),this.setElementsVisibility(e.getCombos(),"visible"),this.isVisible=!0},this.options.debounce),this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.on(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.off(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}kE.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class SE extends iy{constructor(t,e){super(t,Object.assign({},SE.defaultOptions,e)),this.onWheel=t=>De(this,void 0,void 0,function*(){this.options.preventDefault&&t.preventDefault();const e=t.deltaX,n=t.deltaY;yield this.scroll([-e,-n],t)}),this.shortcut=new Wy(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),zt(r)){null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel);const{up:n=[],down:i=[],left:o=[],right:A=[]}=r;this.shortcut.bind(n,t=>this.scroll([0,-10],t)),this.shortcut.bind(i,t=>this.scroll([0,10],t)),this.shortcut.bind(o,t=>this.scroll([-10,0],t)),this.shortcut.bind(A,t=>this.scroll([10,0],t))}else null===(n=this.graphDom)||void 0===n||n.addEventListener(t.CommonEvent.WHEEL,this.onWheel,{passive:!1})}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}formatDisplacement(t){const{sensitivity:e}=this.options;return t=ly(t,e),t=this.clampByDirection(t),t=this.clampByRange(t)}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[A,s,a,c]=pm(this.options.range),l=[o*A,i*s,o*a,i*c],u=Em(Bm(n.getCanvasCenter()),l),h=cy(n.getViewportCenter(),[t,e,0]);if(!Cm(h,u)){const{min:[n,r],max:[i,o]}=u;(h[0]0||h[0]>i&&t<0)&&(t=0),(h[1]0||h[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{onFinish:n}=this.options,r=this.context.graph,i=this.formatDisplacement(t);yield r.translateBy(i,!1),null==n||n()})}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel),super.destroy()}}SE.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class QE extends iy{constructor(t,e){super(t,Object.assign({},QE.defaultOptions,e)),this.zoom=(t,e,n)=>De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{graph:r}=this.context;let i=this.options.origin;!i&&"viewport"in e&&(i=Sy(e.viewport));const{sensitivity:o,onFinish:A}=this.options,s=1+ne(t,-50,50)*o/100,a=r.getZoom();yield r.zoomTo(a*s,n,i),null==A||A()}),this.onReset=()=>De(this,void 0,void 0,function*(){yield this.context.graph.zoomTo(1,this.options.animation)}),this.preventDefault=t=>{this.options.preventDefault&&t.preventDefault()},this.shortcut=new Wy(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),Array.isArray(e))if(e.includes(t.CommonEvent.PINCH))this.shortcut.bind([t.CommonEvent.PINCH],t=>{this.zoom(t.scale,t,!1)});else{const n=this.context.canvas.getContainer();null==n||n.addEventListener(t.CommonEvent.WHEEL,this.preventDefault),this.shortcut.bind([...e,t.CommonEvent.WHEEL],t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(null!=n?n:e),t,!1)})}if("object"==typeof e){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,t=>this.zoom(10,t,this.options.animation)),this.shortcut.bind(n,t=>this.zoom(-10,t,this.options.animation)),this.shortcut.bind(r,this.onReset)}}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.context.canvas.getContainer())||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.preventDefault),super.destroy()}}function UE(t,e,n,r="height"){const i=t[r],o=e[r];return"center"===n?(i+o)/2:t.height}QE.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};const NE=Object.assign,TE={getId:t=>t.id||t.name,getPreH:t=>t.preH||0,getPreV:t=>t.preV||0,getHGap:t=>t.hgap||18,getVGap:t=>t.vgap||18,getChildren:t=>t.children,getHeight:t=>t.height||36,getWidth(t){const e=t.label||" ";return t.width||18*e.split("").length}};let OE=class t{constructor(e,n){if(this.x=0,this.y=0,this.depth=0,this.children=[],this.hgap=0,this.vgap=0,e instanceof t||"x"in e&&"y"in e&&"children"in e){const t=e;return this.data=t.data,this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.depth=t.depth,this.children=t.children,this.parent=t.parent,this.hgap=t.hgap,this.vgap=t.vgap,this.preH=t.preH,void(this.preV=t.preV)}this.data=e;const r=n.getHGap(e),i=n.getVGap(e);this.preH=n.getPreH(e),this.preV=n.getPreV(e),this.width=n.getWidth(e),this.height=n.getHeight(e),this.width+=this.preH,this.height+=this.preV,this.id=n.getId(e),this.addGap(r,i)}isRoot(){return 0===this.depth}isLeaf(){return 0===this.children.length}addGap(t,e){this.hgap+=t,this.vgap+=e,this.width+=2*t,this.height+=2*e}eachNode(t){let e,n=[this];for(;e=n.shift();)t(e),n=e.children.concat(n)}DFTraverse(t){this.eachNode(t)}BFTraverse(t){let e,n=[this];for(;e=n.shift();)t(e),n=n.concat(e.children)}getBoundingBox(){const t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode(e=>{t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)}),t}translate(t=0,e=0){this.eachNode(n=>{n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV})}right2left(){const t=this.getBoundingBox();this.eachNode(e=>{e.x=e.x-2*(e.x-t.left)-e.width}),this.translate(t.width,0)}bottom2top(){const t=this.getBoundingBox();this.eachNode(e=>{e.y=e.y-2*(e.y-t.top)-e.height}),this.translate(0,t.height)}};function IE(t,e={},n){e=NE({},TE,e);const r=new OE(t,e),i=[r];let o;if(!n&&!t.collapsed)for(;o=i.shift();)if(!o.data.collapsed){const t=e.getChildren(o.data),n=t?t.length:0;if(o.children=new Array(n),t&&n)for(let r=0;r{const i=t.fromNode(e,n);i&&r.push(i)}),n?new t(e.height,e.width,e.x,r):new t(e.width,e.height,e.y,r)}};function DE(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach(t=>{DE(t,e,n)})}function RE(t,e){let n=e?t.y:t.x;return t.children.forEach(t=>{n=Math.min(RE(t,e),n)}),n}function HE(t,e){DE(t,-RE(t,e),e)}function _E(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((t,r)=>{_E(t,e.children[r],n)})}function GE(t,e,n=0){e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach(t=>{GE(t,e,n)})}function KE(t,e={}){const n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){let r=t.c[e-1],i=r.mod,c=t.c[e],l=c.mod;for(;null!==r&&null!==c;){n&&a(r)>n.low&&(n=n.nxt);const u=i+r.prelim+r.w-(l+c.prelim);u>0&&(l+=u,n&&o(t,e,n.index,u));const h=a(r),d=a(c);h<=d&&(r=s(r),null!==r&&(i+=r.mod)),h>=d&&(c=A(c),null!==c&&(l+=c.mod))}!r&&c?function(t,e,n,r){const i=t.c[0].el;i.tl=n;const o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,c,l):r&&!c&&function(t,e,n,r){const i=t.c[e].er;i.tr=n;const o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){const i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function A(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function a(t){return t.y+t.h}function c(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}GE(t,n);const l=PE.fromNode(t,n);return l&&(function t(e){if(0===e.cs)return void r(e);t(e.c[0]);let n=c(a(e.c[0].el),0,null);for(let r=1;r{t.isRoot()||(t.side="left")}),r.eachNode(t=>{t.isRoot()||(t.side="right")}),{left:n,right:r}}const zE=["LR","RL","TB","BT","H","V"],VE=["LR","RL","H"],WE=zE[0];function YE(t,e,n){const r=e.direction||WE;if(e.isHorizontal=(t=>VE.indexOf(t)>-1)(r),-1===zE.indexOf(r))throw new TypeError(`Invalid direction: ${r}`);if(r===zE[0])n(t,e);else if(r===zE[1])n(t,e),t.right2left();else if(r===zE[2])n(t,e);else if(r===zE[3])n(t,e),t.bottom2top();else if(r===zE[4]||r===zE[5]){const{left:r,right:i}=jE(t,e);n(r,e),n(i,e),e.isHorizontal?r.right2left():r.bottom2top(),i.translate(r.x-i.x,r.y-i.y),t.x=r.x,t.y=i.y;const o=t.getBoundingBox();e.isHorizontal?o.top<0&&t.translate(0,-o.top):o.left<0&&t.translate(-o.left,0)}let i=e.fixedRoot;return void 0===i&&(i=!0),i&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){const[n,r]=e.isHorizontal?["x","y"]:["y","x"],i={x:1/0,y:1/0},o={x:-1/0,y:-1/0};let A=0;t.DFTraverse(t=>{A++;const{x:e,y:n}=t;i.x=Math.min(i.x,e),i.y=Math.min(i.y,n),o.x=Math.max(o.x,e),o.y=Math.max(o.y,n)});const s=o[r]-i[r];if(0===s)return;const a=2*Math.PI/A;t.DFTraverse(e=>{const o=e[r],A=i[r],c=e[n],l=t[n],u=(o-A)/s*(2*Math.PI-a)+a,h=c-l;e.x=Math.cos(u)*h,e.y=Math.sin(u)*h})}}(t,e),t}let XE=class extends LE{execute(){return YE(this.rootNode,this.options,KE)}};const qE={};function $E(t,e){const n=NE({},qE,e);return new XE(t,n).execute()}let ZE=class{constructor(t=0,e=[]){this.x=0,this.y=0,this.leftChild=null,this.rightChild=null,this.isLeaf=!1,this.height=t,this.children=e}};const JE={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function tx(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((t,r)=>{tx(t,e.children[r],n)})}function ex(t,e={}){const n=NE({},JE,e);let r=0,i=null;const o=function t(e){e.width=0,e.depth&&e.depth>r&&(r=e.depth);const n=e.children,i=n.length,o=new ZE(0,[]);return n.forEach((e,n)=>{const r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)}),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{const n=e.children.map(e=>t(e)),r=Math.min(...n);e.drawingDepth=r-1}return e.drawingDepth}(o),function t(e){e.x=e.drawingDepth*n.rankSep,e.isLeaf?(e.y=0,i&&(e.y=i.y+i.height+n.nodeSep,e.originNode.parent!==i.originNode.parent&&(e.y+=n.subTreeSep)),i=e):(e.children.forEach(e=>{t(e)}),e.y=(e.leftChild.y+e.rightChild.y)/2)}(o),tx(o,t,n.isHorizontal),t}class nx extends LE{execute(){return this.rootNode.width=0,YE(this.rootNode,this.options,ex)}}const rx={};function ix(t,e){const n=NE({},rx,e);return new nx(t,n).execute()}function ox(t,e,n,r){let i=null;t.eachNode(t=>{!function(t,e,n,r,i){const o=("function"==typeof n?n(t):n)*t.depth;if(!r)try{if(t.parent&&t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch{}if(t.x+=o,e){if(t.y=e.y+UE(e,t,i),e.parent&&t.parent&&t.parent.id!==e.parent.id){const n=e.parent,r=n.y+UE(n,t,i);t.y=r>t.y?r:t.y}}else t.y=0}(t,i,e,n,r),i=t})}const Ax=["LR","RL","H"],sx=Ax[0];let ax=class extends LE{execute(){const t=this.options,e=this.rootNode;t.isHorizontal=!0;const{indent:n=20,dropCap:r=!0,direction:i=sx,align:o}=t;if(i&&-1===Ax.indexOf(i))throw new TypeError(`Invalid direction: ${i}`);if(i===Ax[0])ox(e,n,r,o);else if(i===Ax[1])ox(e,n,r,o),e.right2left();else if(i===Ax[2]){const{left:i,right:A}=jE(e,t);ox(i,n,r,o),i.right2left(),ox(A,n,r,o);const s=i.getBoundingBox();A.translate(s.width,0),e.x=A.x-e.width/2}return e}};const cx={};function lx(t,e){const n=NE({},cx,e);return new ax(t,n).execute()}function ux(t,e){let n=0;return t.children.length?t.children.forEach(t=>{n+=ux(t,e)}):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function hx(t){const e=t.children,n=e.length;if(n){e.forEach(t=>{hx(t)});const r=e[0],i=e[n-1],o=i.y-r.y+i.height;let A=0;if(e.forEach(t=>{A+=t.totalHeight}),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>A){const n=t.y+(t.height-o)/2-r.y;e.forEach(t=>{t.translate(0,n)})}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}const dx={getSubTreeSep:()=>0};function fx(t,e={}){return e=NE({},dx,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse(t=>{t.x=t.parent.x+t.parent.width}),t.parent=void 0,ux(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode(t=>{const e=t.children,n=e.length;if(n){const r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(let t=1;t=",!0],["&&",!0],["||",!0],["+",!0],["-",!0],["*",!0],["/",!0],["%",!0],["!",!0],["<",!0],[">",!0]]),Mx=new Map([[46,bx.DOT],[91,bx.BRACKET_LEFT],[93,bx.BRACKET_RIGHT],[40,bx.PAREN_LEFT],[41,bx.PAREN_RIGHT],[44,bx.COMMA],[63,bx.QUESTION],[58,bx.COLON],[36,bx.DOLLAR]]),Fx=new Map;for(const[t,e]of Mx.entries())Fx.set(t,{type:e,value:String.fromCharCode(t)});function kx(t){return t>=48&&t<=57}function Sx(t){return t>=97&&t<=122||t>=65&&t<=90||95===t}function Qx(t){return Sx(t)||kx(t)}function Ux(t){return Ex.has(t)}var Nx;!function(t){t[t.Program=0]="Program",t[t.Literal=1]="Literal",t[t.Identifier=2]="Identifier",t[t.MemberExpression=3]="MemberExpression",t[t.CallExpression=4]="CallExpression",t[t.BinaryExpression=5]="BinaryExpression",t[t.UnaryExpression=6]="UnaryExpression",t[t.ConditionalExpression=7]="ConditionalExpression"}(Nx||(Nx={}));const Tx=new Map([["||",2],["&&",3],["===",4],["!==",4],[">",5],[">=",5],["<",5],["<=",5],["+",6],["-",6],["*",7],["/",7],["%",7],["!",8]]),Ox={type:Nx.Literal,value:null},Ix={type:Nx.Literal,value:!0},Lx={type:Nx.Literal,value:!1},Px=t=>{let e=0;const n=t.length,r=()=>e>=n?null:t[e],i=()=>t[e++],o=t=>{const e=r();return null!==e&&e.type===t},A=t=>t.type===bx.OPERATOR?Tx.get(t.value)||-1:t.type===bx.DOT||t.type===bx.BRACKET_LEFT?9:t.type===bx.QUESTION?1:-1,s=t=>{let n,A;if(i().type===bx.DOT){if(!o(bx.IDENTIFIER)){const t=r();throw new wx("Expected property name",e,t?t.value:"")}const t=i();n={type:Nx.Identifier,name:t.value},A=!1}else{if(n=c(0),!o(bx.BRACKET_RIGHT)){const t=r();throw new wx("Expected closing bracket",e,t?t.value:"")}i(),A=!0}return{type:Nx.MemberExpression,object:t,property:n,computed:A}},a=()=>{const t=r();if(!t)throw new wx("Unexpected end of input",e,"");if(t.type===bx.OPERATOR&&("!"===t.value||"-"===t.value)){i();const e=a();return{type:Nx.UnaryExpression,operator:t.value,argument:e,prefix:!0}}switch(t.type){case bx.NUMBER:return i(),{type:Nx.Literal,value:Number(t.value)};case bx.STRING:return i(),{type:Nx.Literal,value:t.value};case bx.BOOLEAN:return i(),"true"===t.value?Ix:Lx;case bx.NULL:return i(),Ox;case bx.IDENTIFIER:return i(),{type:Nx.Identifier,name:t.value};case bx.FUNCTION:return(()=>{const t=i(),n=[];if(!o(bx.PAREN_LEFT)){const t=r();throw new wx("Expected opening parenthesis after function name",e,t?t.value:"")}for(i();;){if(o(bx.PAREN_RIGHT)){i();break}if(!r()){const t=r();throw new wx("Expected closing parenthesis",e,t?t.value:"")}if(n.length>0){if(!o(bx.COMMA)){const t=r();throw new wx("Expected comma between function arguments",e,t?t.value:"")}i()}const t=c(0);n.push(t)}return{type:Nx.CallExpression,callee:{type:Nx.Identifier,name:t.value},arguments:n}})();case bx.PAREN_LEFT:{i();const t=c(0);if(!o(bx.PAREN_RIGHT)){const t=r();throw new wx("Expected closing parenthesis",e,t?t.value:"")}return i(),t}default:throw new wx(`Unexpected token: ${t.type}`,e,t.value)}},c=(l=0)=>{let u=a();for(;e")}i();const n=c(0);u={type:Nx.ConditionalExpression,test:u,consequent:t,alternate:n}}}return u},l=c();return{type:Nx.Program,body:l}},Dx=(t,e,n)=>{let r=e;n&&(r={...e,context:{...e.context,...n}});const i=t=>{switch(t.type){case Nx.Literal:return(t=>t.value)(t);case Nx.Identifier:return(t=>{if(!(t.name in r.context))throw new wx(`Undefined variable: ${t.name}`);return r.context[t.name]})(t);case Nx.MemberExpression:return(t=>{const e=i(t.object);if(null==e)throw new wx("Cannot access property of null or undefined");return e[t.computed?i(t.property):t.property.name]})(t);case Nx.CallExpression:return(t=>{const e=r.functions[t.callee.name];if(!e)throw new wx(`Undefined function: ${t.callee.name}`);return e(...t.arguments.map(t=>i(t)))})(t);case Nx.BinaryExpression:return(t=>{if("&&"===t.operator){const e=i(t.left);return e?i(t.right):e}if("||"===t.operator)return i(t.left)||i(t.right);const e=i(t.left),n=i(t.right);switch(t.operator){case"+":return e+n;case"-":return e-n;case"*":return e*n;case"/":return e/n;case"%":return e%n;case"===":return e===n;case"!==":return e!==n;case">":return e>n;case">=":return e>=n;case"<":return e{const e=i(t.argument);if(t.prefix)switch(t.operator){case"!":return!e;case"-":if("number"!=typeof e)throw new wx(`Cannot apply unary - to non-number: ${e}`);return-e;default:throw new wx(`Unknown operator: ${t.operator}`)}throw new wx(`Postfix operators are not supported: ${t.operator}`)})(t);case Nx.ConditionalExpression:return(t=>{const e=i(t.test);return i(e?t.consequent:t.alternate)})(t);default:throw new wx(`Evaluation error: Unsupported node type: ${t.type}`)}};return i(t.body)};function Rx(t){const e=(t=>{const e=t,n=e.length,r=new Array(Math.ceil(n/3));let i=0,o=0;function A(t){const r=o+1;o++;let i="",A=!1;for(;o({context:t,functions:e}))({},yx);return(t={})=>Dx(n,r,t)}function Hx(t,e){if("string"!=typeof t)return;const n=t.trim();if(n)try{return Rx(n),function(t,e={}){return Rx(t)(e)}(n,e)}catch(t){return}}function _x(t){return"number"==typeof t}function Gx(t){if(!t)return[0,0,0];if(_x(t))return[t,t,t];if(Array.isArray(t)&&0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function Kx(t){return null==t}function jx(t){return"string"==typeof t}function zx(t){return"function"==typeof t}function Vx(t,e){if("function"==typeof t)return t;if("string"==typeof t){const n=t;return(...t)=>{const r={};for(let n=0;nt}function Wx(t,e,n="node"){if(Kx(t))return()=>e;if(jx(t)){const r=Vx(t,[n]);return t=>{const n=r(t);return _x(n)?n:e}}return zx(t)?t:_x(t)?()=>t:()=>e}function Yx(t,e=10,n="node"){if(Kx(t))return()=>e;if(jx(t)){const r=Vx(t,[n]);return t=>{const n=r(t);return function(t){return!!_x(t)||!!Array.isArray(t)&&t.every(t=>_x(t))}(n)?n:e}}return zx(t)?t:_x(t)||Array.isArray(t)?()=>t:()=>e}const Xx=(t,e,n=10,r=0)=>{const i=Yx(e,r),o=Yx(t,n);return t=>{const[e,n,r]=Gx(o(t)),[A,s,a]=Gx(i(t));return[e+A,n+s,r+a]}};function qx(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}class $x{constructor(t,e={}){this.edgeIdCounter=new Map,this.nodeMap=function(t,e){if(!t)throw new Error("Data.nodes is required");const n=new Map;for(const r of t){const t={_original:r};for(const e of Zx){const n=r[e];Kx(n)||(t[e]=n)}if(e){const n=e(r);for(const e in n){const r=n[e];Kx(r)||(t[e]=r)}}if(Kx(t.id))throw new Error("Node is missing id field");n.set(t.id,t)}return n}(t.nodes,e.node),this.edgeMap=function(t,e,n){const r=new Map;for(const i of t){const t={_original:i};for(const e of Jx){const n=i[e];Kx(n)||(t[e]=n)}if(e){const n=e(i);for(const e in n){const r=n[e];Kx(r)||(t[e]=r)}}if(Kx(t.source)||Kx(t.target))throw new Error("Edge is missing source or target field");Kx(t.id)&&(t.id=null==n?void 0:n(i)),r.set(t.id,t)}return r}(t.edges||[],e.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(t){this.nodeMap=t.nodes,this.edgeMap=t.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(t){return this.nodeMap.get(t)}nodeAt(t){this.indexNodeCache||this.buildNodeIndexCache();const e=this.indexNodeCache.get(t);return e?this.nodeMap.get(e):void 0}nodeIndexOf(t){var e;return this.nodeIndexCache||this.buildNodeIndexCache(),null!==(e=this.nodeIndexCache.get(t))&&void 0!==e?e:-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(t){let e=0;this.nodeMap.forEach(n=>t(n,e++))}originalNode(t){const e=this.nodeMap.get(t);return null==e?void 0:e._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(t){return this.edgeMap.get(t)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(t){let e=0;this.edgeMap.forEach(n=>t(n,e++))}originalEdge(t){const e=this.edgeMap.get(t);return null==e?void 0:e._original}edgeCount(){return this.edgeMap.size}getEdgeId(t){if(t.id)return t.id;const e=`${t.source}-${t.target}`,n=this.edgeIdCounter.get(e)||0,r=0===n?e:`${e}-${n}`;return this.edgeIdCounter.set(e,n+1),r}degree(t,e="both"){this.degreeCache||this.buildDegreeCache();const n=this.degreeCache.get(t);return n?n[e]:0}neighbors(t,e="both"){if(this.outAdjacencyCache&&this.inAdjacencyCache||this.buildAdjacencyCache(),"out"===e)return Array.from(this.outAdjacencyCache.get(t)||[]);if("in"===e)return Array.from(this.inAdjacencyCache.get(t)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(t)||[]);const n=this.inAdjacencyCache.get(t),r=this.outAdjacencyCache.get(t);if(!n&&!r)return[];if(!n)return Array.from(r);if(!r)return Array.from(n);const i=new Set;return n.forEach(t=>i.add(t)),r.forEach(t=>i.add(t)),Array.from(i)}successors(t){return this.neighbors(t,"out")}predecessors(t){return this.neighbors(t,"in")}setNodeOrder(t){const e=new Map;for(const n of t)e.set(n.id,n);this.nodeMap=e,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(const t of this.edges()){const{source:e,target:n}=t;if(t.source===t.target)continue;this.degreeCache.has(e)||this.degreeCache.set(e,{in:0,out:0,both:0});const r=this.degreeCache.get(t.source);r&&(r.out++,r.both++),this.degreeCache.has(n)||this.degreeCache.set(n,{in:0,out:0,both:0});const i=this.degreeCache.get(t.target);i&&(i.in++,i.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(const t of this.edges())this.nodeMap.has(t.source)&&this.nodeMap.has(t.target)&&(this.outAdjacencyCache.has(t.source)||this.outAdjacencyCache.set(t.source,new Set),this.outAdjacencyCache.get(t.source).add(t.target),this.inAdjacencyCache.has(t.target)||this.inAdjacencyCache.set(t.target,new Set),this.inAdjacencyCache.get(t.target).add(t.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let t=0;this.nodeMap.forEach((e,n)=>{this.nodeIndexCache.set(n,t),this.indexNodeCache.set(t,n),t++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}}const Zx=["id","x","y","z","vx","vy","vz","fx","fy","fz","parentId"],Jx=["id","source","target","points"];function tC(t,e,n,r=2){t.forEachNode(t=>{Kx(t.x)&&(t.x=Math.random()*e),Kx(t.y)&&(t.y=Math.random()*n),3===r&&Kx(t.z)&&(t.z=Math.random()*Math.min(e,n))})}class eC{constructor(t,e={}){this.graph=new $x(t,e)}export(){return this.graph.data()}replace(t){this.graph.replace(t)}forEachNode(t){this.graph.forEachNode(t)}forEachEdge(t){this.graph.forEachEdge((e,n)=>{e.sourceNode=this.graph.node(e.source),e.targetNode=this.graph.node(e.target),t(e,n)})}destroy(){this.graph.destroy()}} /** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: Apache-2.0 */const nC=Symbol("Comlink.proxy"),rC=Symbol("Comlink.endpoint"),iC=Symbol("Comlink.releaseProxy"),oC=Symbol("Comlink.finalizer"),AC=Symbol("Comlink.thrown"),sC=t=>"object"==typeof t&&null!==t||"function"==typeof t,aC=new Map([["proxy",{canHandle:t=>sC(t)&&t[nC],serialize(t){const{port1:e,port2:n}=new MessageChannel;return cC(t,e),[n,[n]]},deserialize:t=>(t.start(),uC(t))}],["throw",{canHandle:t=>sC(t)&&AC in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function cC(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(i){if(!i||!i.data)return;if(!function(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:o,type:A,path:s}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(wC);let c;try{const e=s.slice(0,-1).reduce((t,e)=>t[e],t),n=s.reduce((t,e)=>t[e],t);switch(A){case"GET":c=n;break;case"SET":e[s.slice(-1)[0]]=wC(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,a);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[nC]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;cC(t,n),c=function(t,e){return mC.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[AC]:0}}Promise.resolve(c).catch(t=>({value:t,[AC]:0})).then(n=>{const[i,s]=yC(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===A&&(e.removeEventListener("message",r),lC(e),oC in t&&"function"==typeof t[oC]&&t[oC]())}).catch(t=>{const[n,r]=yC({value:new TypeError("Unserializable return value"),[AC]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)})}),e.start&&e.start()}function lC(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function uC(t,e){const n=new Map;return t.addEventListener("message",function(t){const{data:e}=t;if(!e||!e.id)return;const r=n.get(e.id);if(r)try{r(e)}finally{n.delete(e.id)}}),pC(t,n,[],e)}function hC(t){if(t)throw new Error("Proxy has been released and is not useable")}function dC(t){return bC(t,new Map,{type:"RELEASE"}).then(()=>{lC(t)})}const fC=new WeakMap,gC="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(fC.get(t)||0)-1;fC.set(t,e),0===e&&dC(t)});function pC(t,e,n=[],r=function(){}){let i=!1;const o=new Proxy(r,{get(r,A){if(hC(i),A===iC)return()=>{!function(t){gC&&gC.unregister(t)}(o),dC(t),e.clear(),i=!0};if("then"===A){if(0===n.length)return{then:()=>o};const r=bC(t,e,{type:"GET",path:n.map(t=>t.toString())}).then(wC);return r.then.bind(r)}return pC(t,e,[...n,A])},set(r,o,A){hC(i);const[s,a]=yC(A);return bC(t,e,{type:"SET",path:[...n,o].map(t=>t.toString()),value:s},a).then(wC)},apply(r,o,A){hC(i);const s=n[n.length-1];if(s===rC)return bC(t,e,{type:"ENDPOINT"}).then(wC);if("bind"===s)return pC(t,e,n.slice(0,-1));const[a,c]=vC(A);return bC(t,e,{type:"APPLY",path:n.map(t=>t.toString()),argumentList:a},c).then(wC)},construct(r,o){hC(i);const[A,s]=vC(o);return bC(t,e,{type:"CONSTRUCT",path:n.map(t=>t.toString()),argumentList:A},s).then(wC)}});return function(t,e){const n=(fC.get(e)||0)+1;fC.set(e,n),gC&&gC.register(t,e,t)}(o,t),o}function vC(t){const e=t.map(yC);return[e.map(t=>t[0]),(n=e.map(t=>t[1]),Array.prototype.concat.apply([],n))];var n}const mC=new WeakMap;function yC(t){for(const[e,n]of aC)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},mC.get(t)||[]]}function wC(t){switch(t.type){case"HANDLER":return aC.get(t.name).deserialize(t.value);case"RAW":return t.value}}function bC(t,e,n,r){return new Promise(i=>{const o=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.set(o,i),t.start&&t.start(),t.postMessage(Object.assign({id:o},n),r)})}class BC{constructor(){this.worker=null,this.workerApi=null}execute(t,e,n){return mx(this,0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw new Error("Worker API not initialized");return yield this.workerApi.execute(t,e,n)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return mx(this,0,void 0,function*(){const t=this.resolveWorkerPath(),e=t.includes("/lib/")||t.endsWith(".mjs")?"module":"classic";this.worker=new Worker(t,{type:e}),this.workerApi=uC(this.worker)})}resolveWorkerPath(){const t=(()=>{if("undefined"==typeof document)return null;const t=document.currentScript;if(null==t?void 0:t.src)return t.src;const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t--){const n=e[t].src;if(n&&(n.includes("index.js")||n.includes("index.min.js")))return n}return null})();if(t){if(t.includes("index.js")||t.includes("index.min.js")){const e=t.replace(/index(\.min)?\.(m?js)(\?.*)?$/,"worker.js");if(e!==t)return e}const e=t.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(e!==t)return e;const n=t.replace(/\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(n!==t)return n}return"./worker.js"}}class EC{constructor(t){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),t)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(t,e){return Object.assign({},t,e||{})}execute(t,e){return mx(this,0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,e);const{node:n,edge:r,enableWorker:i}=this.runtimeOptions;this.context=new eC(t,{node:n,edge:r}),this.model=this.context.graph;i&&"undefined"!=typeof Worker?yield this.layoutInWorker(t,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(t,e){var n;return mx(this,0,void 0,function*(){try{this.supervisor||(this.supervisor=new BC);const r=yield this.supervisor.execute(this.id,t,e);null===(n=this.context)||void 0===n||n.replace(r)}catch(t){console.error("Layout in worker failed, fallback to main thread layout.",t),yield this.layout(e)}})}forEachNode(t){this.context.forEachNode(t)}forEachEdge(t){this.context.forEachEdge(t)}destroy(){var t;null===(t=this.context)||void 0===t||t.destroy(),this.model=null,this.context=null,this.supervisor&&(this.supervisor.destroy(),this.supervisor=null)}}class xC extends EC{}function CC(t){return!!t.tick&&!!t.stop}class MC{constructor(t={}){this.options=t,this.nodes=new Map,this.edges=new Map,this.inEdges=new Map,this.outEdges=new Map,this.parentMap=new Map,this.childrenMap=new Map,t.tree&&Array.isArray(t.tree)&&t.tree.length>0&&("string"==typeof t.tree[0]?t.tree.forEach(t=>{this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map)}):(this.attachTreeStructure("default"),this.addTree(t.tree))),t.nodes&&t.nodes.forEach(t=>this.addNode(t)),t.edges&&t.edges.forEach(t=>this.addEdge(t))}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.inEdges.set(t.id,new Set),this.outEdges.set(t.id,new Set))}addNodes(t){t.forEach(t=>this.addNode(t))}getNode(t){return this.nodes.get(t)}hasNode(t){return this.nodes.has(t)}removeNode(t){if(!this.nodes.has(t))return;const e=Array.from(this.inEdges.get(t)||[]),n=Array.from(this.outEdges.get(t)||[]);e.forEach(t=>this.removeEdge(t)),n.forEach(t=>this.removeEdge(t)),this.nodes.delete(t),this.inEdges.delete(t),this.outEdges.delete(t),this.parentMap.forEach(e=>{e.delete(t)}),this.childrenMap.forEach(e=>{e.delete(t)})}getAllNodes(){return Array.from(this.nodes.values())}addEdge(t){if(!this.nodes.has(t.source)||!this.nodes.has(t.target))throw new Error(`Cannot add edge ${t.id}: source ${t.source} or target ${t.target} does not exist`);this.edges.set(t.id,t),this.outEdges.get(t.source).add(t.id),this.inEdges.get(t.target).add(t.id)}addEdges(t){t.forEach(t=>this.addEdge(t))}getEdge(t){return this.edges.get(t)}hasEdge(t){return this.edges.has(t)}removeEdge(t){var e,n;const r=this.edges.get(t);r&&(this.edges.delete(t),null===(e=this.outEdges.get(r.source))||void 0===e||e.delete(t),null===(n=this.inEdges.get(r.target))||void 0===n||n.delete(t))}getAllEdges(){return Array.from(this.edges.values())}updateEdgeData(t,e){const n=this.edges.get(t);n&&Object.assign(n.data,e)}updateNodeData(t,e){const n=this.nodes.get(t);n&&Object.assign(n.data,e)}getRelatedEdges(t,e="both"){const n=[];if("in"===e||"both"===e){const e=this.inEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&n.push(e)})}if("out"===e||"both"===e){const e=this.outEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&n.push(e)})}return n}getSuccessors(t){const e=this.outEdges.get(t);if(!e||0===e.size)return[];const n=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.target);t&&n.push(t)}}),n.length>0?n:[]}getPredecessors(t){const e=this.inEdges.get(t);if(!e||0===e.size)return[];const n=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.source);t&&n.push(t)}}),n.length>0?n:[]}getNeighbors(t){const e=[...this.getSuccessors(t)||[],...this.getPredecessors(t)||[]],n=Array.from(new Map(e.map(t=>[t.id,t])).values());return n.length>0?n:[]}attachTreeStructure(t){this.parentMap.has(t)||(this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map))}addTree(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default");this.hasTreeStructure(i)||this.attachTreeStructure(i);const o=Array.isArray(t)?t:[t],A=(t,e)=>{this.addNode({id:t.id,data:t.data}),void 0!==e&&this.setParent(t.id,e,i),t.children&&t.children.length>0&&t.children.forEach(e=>{A(e,t.id)})};o.forEach(t=>A(t))}hasTreeStructure(t){return this.parentMap.has(t)}setParent(t,e,n){var r,i,o;const A=n||(null!==(i=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==i?i:"default");this.parentMap.has(A)||this.attachTreeStructure(A);const s=this.parentMap.get(A),a=this.childrenMap.get(A),c=s.get(t);void 0!==c&&(null===(o=a.get(c))||void 0===o||o.delete(t)),s.set(t,e),a.has(e)||a.set(e,new Set),a.get(e).add(t)}getParent(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default");this.parentMap.has(i)||this.attachTreeStructure(i);const o=this.parentMap.get(i);if(!o)return;const A=o.get(t);return void 0===A?null:this.nodes.get(A)}getChildren(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default"),o=this.childrenMap.get(i);if(!o)return[];const A=o.get(t);return A?Array.from(A).map(t=>this.nodes.get(t)).filter(t=>void 0!==t):[]}getRoots(t){var e,n;const r=t||(null!==(n=null===(e=this.options.tree)||void 0===e?void 0:e[0])&&void 0!==n?n:"default"),i=this.parentMap.get(r),o=[];return this.nodes.forEach(t=>{i&&void 0!==i.get(t.id)||o.push(t)}),o}dfsTree(t,e){const n=[t],r=new Set;for(;n.length>0;){const t=n.pop();if(r.has(t))continue;const i=this.getNode(t);if(i){r.add(t);if(!0===e(i))continue;const o=this.getChildren(t);for(let t=o.length-1;t>=0;t--)r.has(o[t].id)||n.push(o[t].id)}}}}const FC=(t,e)=>{if("next"!==t&&"prev"!==t)return e},kC=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let SC=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return kC(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&kC(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let n=e.prev;for(;n!==e;)t.push(JSON.stringify(n,FC)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}};class QC extends SC{}const UC=()=>1,NC=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let A;for(;t.getAllNodes().length;){for(;A=o.dequeue();)TC(t,e,n,A);for(;A=i.dequeue();)TC(t,e,n,A);if(t.getAllNodes().length)for(let i=e.length-2;i>0;--i)if(A=e[i].dequeue(),A){r=r.concat(TC(t,e,n,A,!0));break}}return r},TC=(t,e,n,r,i)=>{var o,A;const s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach(r=>{const o=r.data.weight,A=t.getNode(r.source);i&&s.push({v:r.source,w:r.target,in:0,out:0}),void 0===A.data.out&&(A.data.out=0),A.data.out-=o,IC(e,n,Object.assign({v:A.id},A.data))}),null===(A=t.getRelatedEdges(r.v,"out"))||void 0===A||A.forEach(r=>{const i=r.data.weight,o=r.target,A=t.getNode(o);void 0===A.data.in&&(A.data.in=0),A.data.in-=i,IC(e,n,Object.assign({v:A.id},A.data))}),t.removeNode(r.v)),i?s:void 0},OC=(t,e)=>{const n=new MC;let r=0,i=0;t.getAllNodes().forEach(t=>{n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})}),t.getAllEdges().forEach(t=>{const o=n.getRelatedEdges(t.source,"out").find(e=>e.target===t.target),A=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,Object.assign(Object.assign({},o.data),{weight:o.data.weight+A})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:A}}),i=Math.max(i,n.getNode(t.source).data.out+=A),r=Math.max(r,n.getNode(t.target).data.in+=A)});const o=[],A=i+r+3;for(let t=0;t{IC(o,s,Object.assign({v:t.id},n.getNode(t.id).data))}),{buckets:o,zeroIdx:s,graph:n}},IC=(t,e,n)=>{n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)},LC=(t,e)=>{const n=((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=OC(t,e||UC);return null===(n=NC(r.graph,r.buckets,r.zeroIdx).map(e=>t.getRelatedEdges(e.v,"out").filter(({target:t})=>t===e.w)))||void 0===n?void 0:n.flat()})(t,t=>t.data.weight||1);null==n||n.forEach(e=>{const n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},n)})})},PC=(t,e,n,r)=>{let i;do{i=`${r}${Math.random()}`}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},DC=t=>{const e=new MC;return t.getAllNodes().forEach(n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))}),t.getAllEdges().forEach(t=>{e.addEdge(t)}),e},RC=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let A,s,a=Number(t.width)/2,c=Number(t.height)/2;return i||o?(Math.abs(o)*a>Math.abs(i)*c?(o<0&&(c=-c),A=c*i/o,s=c):(i<0&&(a=-a),A=a,s=a*o/i),{x:n+A,y:r+s}):{x:0,y:0}},HC=t=>{const e=[],n=GC(t)+1;for(let t=0;t{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)});for(let r=0;r{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i});return e},_C=(t,e,n,r)=>{const i={width:0,height:0};return _x(n)&&_x(r)&&(i.rank=n,i.order=r),PC(t,"border",i,e)},GC=t=>{let e;return t.getAllNodes().forEach(t=>{const n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)}),e||(e=0),e},KC=(t,e)=>t.reduce((t,n)=>e(t)>e(n)?n:t),jC=(t,e,n,r,i,o)=>{if(!r.includes(e.id)){r.push(e.id),n||o.push(e.id);const A=i(e.id);A&&A.forEach(e=>jC(t,e,n,r,i,o)),n&&o.push(e.id)}},zC=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>t.getNeighbors(e),A=[],s=[];return i.forEach(e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);jC(t,e,"post"===n,s,o,A)}),A},VC=(t,e,n,r,i,o)=>{const A={rank:o,borderType:e,width:0,height:0},s=o-i.data.minRank,a=i.data[e][s-1],c=PC(t,"border",A,n);i.data[e][s]=c,t.setParent(c,r),a&&t.addEdge({id:`e${Math.random()}`,source:a,target:c,data:{weight:1}})},WC=t=>{t.getAllNodes().forEach(t=>{YC(t)}),t.getAllEdges().forEach(t=>{YC(t)})},YC=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},XC=t=>{t.getAllNodes().forEach(t=>{qC(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>qC(t)),t.data.hasOwnProperty("y")&&qC(t.data)})},qC=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},$C=t=>{t.getAllNodes().forEach(t=>{ZC(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>ZC(t)),t.data.hasOwnProperty("x")&&ZC(t.data)})},ZC=t=>{const e=t.x;t.x=t.y,t.y=e},JC=(t,e,n,r,i,o,A)=>{const s=t.getChildren(A);if(!(null==s?void 0:s.length))return void(A!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:A,data:{weight:0,minlen:n}}));const a=_C(t,"_bt"),c=_C(t,"_bb"),l=t.getNode(A);t.setParent(a,A),l.data.borderTop=a,t.setParent(c,A),l.data.borderBottom=c,null==s||s.forEach(s=>{JC(t,e,n,r,i,o,s.id);const l=s.data.borderTop?s.data.borderTop:s.id,u=s.data.borderBottom?s.data.borderBottom:s.id,h=s.data.borderTop?r:2*r,d=l!==u?1:i-o[A]+1;t.addEdge({id:`e${Math.random()}`,source:a,target:l,data:{minlen:d,weight:h,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:u,target:c,data:{minlen:d,weight:h,nestingEdge:!0}})}),t.getParent(A)||t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:i+o[A]}})},tM=t=>{const e={},n=(r,i)=>{const o=t.getChildren(r);null==o||o.forEach(t=>n(t.id,i+1)),e[r]=i};return t.getRoots().forEach(t=>n(t.id,1)),e},eM=t=>{let e=0;return t.getAllEdges().forEach(t=>{e+=t.data.weight}),e},nM="edge-label",rM=(t,e,n)=>{let r=e.source,i=t.getNode(r).data.rank;const o=e.target,A=t.getNode(o).data.rank,s=e.data.labelRank;if(A===i+1)return;let a,c,l;for(t.removeEdge(e.id),l=0,++i;i{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},oM=(t,e,n)=>{const r=((t,e)=>null==t?void 0:t.reduce((t,n,r)=>(t[n]=e[r],t),{}))(n,n.map((t,e)=>e)),i=e.map(e=>{const n=t.getRelatedEdges(e,"out").map(t=>({pos:r[t.target]||0,weight:t.data.weight}));return null==n?void 0:n.sort((t,e)=>t.pos-e.pos)}),o=i.flat().filter(t=>void 0!==t);let A=1;for(;A{if(t){let e=t.pos+A;a[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=a[e+1]),e=e-1>>1,a[e]+=t.weight;c+=t.weight*n}}),c},AM=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=oM(t,e[r-1],e[r]);return n},sM=t=>{const e={},n=t.getAllNodes(),r=n.map(t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0}),i=Math.max(...r),o=[];for(let t=0;tt.getNode(e.id).data.rank-t.getNode(n.id).data.rank),s=A.filter(e=>void 0!==t.getNode(e.id).data.fixorder),a=s.sort((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder);return null==a||a.forEach(n=>{isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0}),null==A||A.forEach(n=>t.dfsTree(n.id,t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)})),o},aM=t=>{var e,n;const r=[];for(;null==t?void 0:t.length;){const i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach(t=>{return(e=i,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&cM(e,t)})(t);var e}),null===(n=i.out)||void 0===n||n.forEach(e=>{return(n=i,e=>{e.in.push(n),0===--e.indegree&&t.push(e)})(e);var n})}const i=r.filter(t=>!t.merged),o=["vs","i","barycenter","weight"];return i.map(t=>{const e={};return null==o||o.forEach(n=>{void 0!==t[n]&&(e[n]=t[n])}),e})},cM=(t,e)=>{var n;let r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},lM=(t,e,n)=>{let r,i=n;for(;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},uM=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenterr.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.orderr.order)return 1}return t?r.i-n.i:n.i-r.i},hM=(t,e,n,r,i,o)=>{var A,s,a,c;let l=t.getChildren(e).map(t=>t.id);const u=t.getNode(e),h=u?u.data.borderLeft:void 0,d=u?u.data.borderRight:void 0,f={};h&&(l=null==l?void 0:l.filter(t=>t!==h&&t!==d));const g=((t,e)=>e.map(e=>{const n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};const r={sum:0,weight:0};return null==n||n.forEach(e=>{const n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight}),{v:e,barycenter:r.sum/r.weight,weight:r.weight}}))(t,l||[]);null==g||g.forEach(e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=hM(t,e.v,n,r,o);f[e.v]=i,i.hasOwnProperty("barycenter")&&fM(e,i)}});const p=((t,e)=>{var n,r,i;const o={};null==t||t.forEach((t,e)=>{o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)}),null===(n=e.getAllEdges())||void 0===n||n.forEach(t=>{const e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))});const A=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,t=>!t.indegree);return aM(A)})(g,n);dM(p,f),null===(A=p.filter(t=>t.vs.length>0))||void 0===A||A.forEach(e=>{const n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)});const v=((t,e,n,r)=>{const i=((t,e)=>{const n={lhs:[],rhs:[]};return null==t||t.forEach(t=>{e(t)?n.lhs.push(t):n.rhs.push(t)}),n})(t,t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")}),o=i.lhs,A=i.rhs.sort((t,e)=>-t.i- -e.i),s=[];let a=0,c=0,l=0;null==o||o.sort(uM(!!e,!!n)),l=lM(s,A,l),null==o||o.forEach(t=>{var e;l+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),a+=t.barycenter*t.weight,c+=t.weight,l=lM(s,A,l)});const u={vs:s.flat()};return c&&(u.barycenter=a/c,u.weight=c),u})(p,r,i,o);if(h&&(v.vs=[h,v.vs,d].flat(),null===(s=t.getPredecessors(h))||void 0===s?void 0:s.length)){const e=t.getNode((null===(a=t.getPredecessors(h))||void 0===a?void 0:a[0].id)||""),n=t.getNode((null===(c=t.getPredecessors(d))||void 0===c?void 0:c[0].id)||"");v.hasOwnProperty("barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+e.data.order+n.data.order)/(v.weight+2),v.weight+=2}return v},dM=(t,e)=>{null==t||t.forEach(t=>{var n;const r=null===(n=t.vs)||void 0===n?void 0:n.map(t=>e[t]?e[t].vs:t);t.vs=r.flat()})},fM=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)};function gM(t){return Array.isArray(t)}var pM=function(t){if("object"!=typeof t||null===t)return t;var e;if(gM(t)){e=[];for(var n=0,r=t.length;ne.map(e=>((t,e,n)=>{const r=iM(t),i=new MC;return i.addNode({id:r,data:{}}),t.getAllNodes().forEach(o=>{var A,s;const a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(Object.assign({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach(e=>{const n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(Object.assign({},t.getNode(n)));const r=i.getRelatedEdges(n,"out").find(({target:t})=>t===o.id),A=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,Object.assign(Object.assign({},r.data),{weight:e.data.weight+A})):i.addEdge({id:e.id,source:n,target:o.id,data:{weight:e.data.weight+A}})}),o.data.hasOwnProperty("minRank")&&i.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:[null===(A=o.data.borderLeft)||void 0===A?void 0:A[e-o.data.minRank]],borderRight:[null===(s=o.data.borderRight)||void 0===s?void 0:s[e-o.data.minRank]]})))}),i})(t,e,n)),mM=(t,e,n,r)=>{const i=new MC;null==t||t.forEach(t=>{var o;const A=t.getRoots()[0].id,s=hM(t,A,i,e,n,r);for(let e=0;e<(null===(o=s.vs)||void 0===o?void 0:o.length);e++){const n=t.getNode(s.vs[e]);n&&(n.data.order=e)}((t,e,n)=>{const r={};let i;null==n||n.forEach(n=>{let o,A,s=t.getParent(n);for(;s;){if(o=t.getParent(s.id),o?(A=r[o.id],r[o.id]=s.id):(A=i,i=s.id),A&&A!==s.id)return e.hasNode(A)||e.addNode({id:A,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${A}-${s.id}`)||e.addEdge({id:`e${A}-${s.id}`,source:A,target:s.id,data:{}}));s=o}})})(t,i,s.vs)})},yM=(t,e)=>{null==e||e.forEach(e=>{null==e||e.forEach((e,n)=>{t.getNode(e).data.order=n})})},wM=(t,e)=>{const n=(t=>{const e={};let n=0;const r=i=>{const o=n;t.getChildren(i).forEach(t=>r(t.id)),e[i]={low:o,lim:n++}};return t.getRoots().forEach(t=>r(t.id)),e})(t);e.forEach(e=>{var r,i;let o=e,A=t.getNode(o);const s=A.data.originalEdge;if(!s)return;const a=((t,e,n,r)=>{var i,o;const A=[],s=[],a=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);let l,u;l=n;do{l=null===(i=t.getParent(l))||void 0===i?void 0:i.id,A.push(l)}while(l&&(e[l].low>a||c>e[l].lim));for(u=l,l=r;l&&l!==u;)s.push(l),l=null===(o=t.getParent(l))||void 0===o?void 0:o.id;return{lca:u,path:A.concat(s.reverse())}})(t,n,s.source,s.target),c=a.path,l=a.lca;let u=0,h=c[u],d=!0;for(;o!==s.target;){if(A=t.getNode(o),d){for(;h!==l&&(null===(r=t.getNode(h))||void 0===r?void 0:r.data.maxRank){const n={};function r(e,r){const i=function(t){return JSON.stringify(t.slice(1))}(e);r.get(i)||(!function(e,r,i,o,A){var s,a;let c;for(let l=r;l{const r=t.getNode(e.id);r.data.dummy&&(r.data.orderA)&&EM(n,e.id,c)}))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,A=0;const s=new Map;return null==n||n.forEach((a,c)=>{var l;if("border"===(null===(l=t.getNode(a))||void 0===l?void 0:l.data.dummy)){const e=t.getPredecessors(a)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,A,c,o,i],s),A=c,o=i)}r([n,A,n.length,i,e.length],s)}),n};return(null==e?void 0:e.length)&&e.reduce(i),n},BM=(t,e)=>{var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find(e=>t.getNode(e.id).data.dummy)},EM=(t,e,n)=>{let r=e,i=n;if(r>i){const t=r;r=i,i=t}let o=t[r];o||(t[r]=o={}),o[i]=!0},xM=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},CM=(t,e,n,r,i,o)=>{const A=new MC,s=MM(r,i,o);return null==e||e.forEach(e=>{let r;null==e||e.forEach(e=>{const i=n[e];if(A.hasNode(i)||A.addNode({id:i,data:{}}),r){const o=n[r],a=A.getRelatedEdges(o,"out").find(t=>t.target===i);a?A.updateEdgeData(a.id,Object.assign(Object.assign({},a.data),{weight:Math.max(s(t,e,r),a.data.weight||0)})):A.addEdge({id:`e${Math.random()}`,source:o,target:i,data:{weight:Math.max(s(t,e,r),0)}})}r=e})}),A};const MM=(t,e,n)=>(r,i,o)=>{const A=r.getNode(i),s=r.getNode(o);let a=0,c=0;if(a+=A.data.width/2,A.data.hasOwnProperty("labelpos"))switch((A.data.labelpos||"").toLowerCase()){case"l":c=-A.data.width/2;break;case"r":c=A.data.width/2}if(c&&(a+=n?c:-c),c=0,a+=(A.data.dummy?e:t)/2,a+=(s.data.dummy?e:t)/2,a+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(a+=n?c:-c),c=0,a},FM=(t,e)=>t.getNode(e).data.width||0,kM=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=HC(t),A=Object.assign(((t,e)=>{const n={},r=(e,r)=>{let i=0,o=0;const A=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach((e,a)=>{var c;const l=BM(t,e),u=l?t.getNode(l.id).data.order:A;(l||e===s)&&(null===(c=r.slice(o,a+1))||void 0===c||c.forEach(e=>{var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach(r=>{var o;const A=t.getNode(r.id),s=A.data.order;!(s{a="u"===e?o:Object.values(o).reverse(),["l","r"].forEach(n=>{"r"===n&&(a=a.map(t=>Object.values(t).reverse()));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),c=((t,e,n,r)=>{const i={},o={},A={};return null==e||e.forEach(t=>{null==t||t.forEach((t,e)=>{i[t]=t,o[t]=t,A[t]=e})}),null==e||e.forEach(t=>{let e=-1;null==t||t.forEach(t=>{let s=r(t).map(t=>t.id);if(s.length){s=s.sort((t,e)=>A[t]-A[e]);const r=(s.length-1)/2;for(let a=Math.floor(r),c=Math.ceil(r);a<=c;++a){const r=s[a];o[t]===t&&e{var s;const a={},c=CM(t,e,n,i,o,A),l=A?"borderLeft":"borderRight",u=(t,e)=>{let n=c.getAllNodes(),r=n.pop();const i={};for(;r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return u(t=>{a[t]=(c.getRelatedEdges(t,"in")||[]).reduce((t,e)=>Math.max(t,(a[e.source]||0)+e.data.weight),0)},c.getPredecessors.bind(c)),u(e=>{const n=(c.getRelatedEdges(e,"out")||[]).reduce((t,e)=>Math.min(t,(a[e.target]||0)-e.data.weight),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==l&&(a[e]=Math.max(a[e],n))},c.getSuccessors.bind(c)),null===(s=Object.values(r))||void 0===s||s.forEach(t=>{a[t]=a[n[t]]}),a})(t,a,c.root,c.align,r,i,"r"===n);"r"===n&&Object.keys(l).forEach(t=>l[t]=-l[t]),s[e+n]=l})});const c=((t,e)=>KC(Object.values(e),e=>{var n;let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach(n=>{const o=e[n],A=FM(t,n)/2;r=Math.max(o+A,r),i=Math.min(o-A,i)}),r-i}))(t,s);return c&&function(t,e){const n=Object.values(e),r=Math.min(...n),i=Math.max(...n);["u","d"].forEach(n=>{["l","r"].forEach(o=>{const A=n+o,s=t[A];let a;if(s===e)return;const c=Object.values(s);a="l"===o?r-Math.min(...c):i-Math.max(...c),a&&(t[A]={},Object.keys(s).forEach(e=>{t[A][e]=s[e]+a}))})})}(s,c),((t,e)=>{const n={};return Object.keys(t.ul).forEach(r=>{if(e)n[r]=t[e.toLowerCase()][r];else{const e=Object.values(t).map(t=>t[r]);n[r]=(e[0]+e[1])/2}}),n})(s,n)},SM=(t,e)=>{var n;const r=DC(t);((t,e)=>{const{ranksep:n=0}=e||{},r=HC(t);let i=0;null==r||r.forEach(e=>{const r=e.map(e=>t.getNode(e).data.height),o=Math.max(...r,0);null==e||e.forEach(e=>{t.getNode(e).data.y=i+o/2}),i+=o+n})})(r,e);const i=kM(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach(t=>{r.getNode(t).data.x=i[t]})},QM=t=>{const e={},n=r=>{var i;const o=t.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;let A;return e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach(t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===A||e0===t.getRelatedEdges(e.id,"in").length).forEach(t=>n(t.id))},UM=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,NM=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach(i=>{const o=i.source,A=r===o?i.target:o;t.hasNode(A)||UM(e,i)||(t.addNode({id:A,data:{}}),t.addEdge({id:i.id,source:r,target:A,data:{}}),n(A))})};return t.getAllNodes().forEach(t=>n(t.id)),t.getAllNodes().length},TM=(t,e)=>{const n=r=>{var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach(i=>{const o=i.source,A=r===o?i.target:o;t.hasNode(A)||void 0===e.getNode(A).data.layer&&UM(e,i)||(t.addNode({id:A,data:{}}),t.addEdge({id:i.id,source:r,target:A,data:{}}),n(A))})};return t.getAllNodes().forEach(t=>n(t.id)),t.getAllNodes().length},OM=(t,e)=>KC(e.getAllEdges(),n=>t.hasNode(n.source)!==t.hasNode(n.target)?UM(e,n):1/0),IM=(t,e,n)=>{t.getAllNodes().forEach(t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n})},LM=t=>{const e=(t=>{const e=new MC;return t.getAllNodes().forEach(t=>{e.addNode(Object.assign({},t))}),t.getAllEdges().forEach(t=>{const n=e.getRelatedEdges(t.source,"out").find(e=>e.target===t.target);n?e.updateEdgeData(null==n?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})}),e})(t);QM(e);const n=(t=>{const e=new MC({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);NM(e,t){let n=zC(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach(n=>{DM(t,e,n)})},DM=(t,e,n)=>{const r=t.getNode(n).data.parent,i=t.getRelatedEdges(n,"both").find(t=>t.target===r||t.source===r);i.data.cutvalue=RM(t,e,n)},RM=(t,e,n)=>{const r=t.getNode(n).data.parent;let i=!0,o=e.getRelatedEdges(n,"out").find(t=>t.target===r),A=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find(t=>t.target===n)),A=o.data.weight,e.getRelatedEdges(n,"both").forEach(e=>{const o=e.source===n,s=o?e.target:e.source;if(s!==r){const r=o===i,a=e.data.weight;if(A+=r?a:-a,VM(t,n,s)){const e=t.getRelatedEdges(n,"both").find(t=>t.source===s||t.target===s).data.cutvalue;A+=r?-e:e}}}),A},HM=(t,e=t.getAllNodes()[0].id)=>{_M(t,{},1,e)},_M=(t,e,n,r,i)=>{var o;const A=n;let s=n;const a=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach(n=>{e[n.id]||(s=_M(t,e,s,n.id,r))}),a.data.low=A,a.data.lim=s++,i?a.data.parent=i:delete a.data.parent,s},GM=t=>t.getAllEdges().find(t=>t.data.cutvalue<0),KM=(t,e,n)=>{let r=n.source,i=n.target;e.getRelatedEdges(r,"out").find(t=>t.target===i)||(r=n.target,i=n.source);const o=t.getNode(r),A=t.getNode(i);let s=o,a=!1;o.data.lim>A.data.lim&&(s=A,a=!0);const c=e.getAllEdges().filter(e=>a===WM(t.getNode(e.source),s)&&a!==WM(t.getNode(e.target),s));return KC(c,t=>UM(e,t))},jM=(t,e,n,r)=>{const i=t.getRelatedEdges(n.source,"both").find(t=>t.source===n.target||t.target===n.target);i&&t.removeEdge(i.id),t.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),HM(t),PM(t,e),zM(t,e)},zM=(t,e)=>{const n=t.getAllNodes().find(t=>!t.data.parent);let r=zC(t,n,"pre");r=r.slice(1),r.forEach(n=>{const r=t.getNode(n).data.parent;let i=e.getRelatedEdges(n,"out").find(t=>t.target===r),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find(t=>t.target===n),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))})},VM=(t,e,n)=>t.getRelatedEdges(e,"both").find(t=>t.source===n||t.target===n),WM=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,YM=QM,XM=t=>{(t=>{const e={};let n;const r=i=>{var o;const A=t.getNode(i);if(!A)return 0;if(e[i])return A.data.rank;let s;return e[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach(t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e0===t.getRelatedEdges(e.id,"in").length).forEach(t=>{t&&r(t.id)}),void 0===n&&(n=0);const i={},o=(e,n)=>{var r;const A=t.getNode(e),s=isNaN(A.data.layer)?n:A.data.layer;(void 0===A.data.rank||A.data.rank{o(t.target,s+t.data.minlen)}))};t.getAllNodes().forEach(t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=n:o(t.id,e.layer))})})(t),(t=>{const e=new MC({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);TM(e,t){LM(t)},$M=(t,e)=>{const{ranker:n,rankdir:r="tb",nodeOrder:i,keepNodeOrder:o,align:A,nodesep:s=50,edgesep:a=20,ranksep:c=50}=e;gF(t),LC(t);const{nestingRoot:l,nodeRankFactor:u}=(t=>{const e=PC(t,"root",{},"_root"),n=tM(t);let r=Math.max(...Object.values(n));Math.abs(r)===1/0&&(r=1);const i=r-1,o=2*i+1;t.getAllEdges().forEach(t=>{t.data.minlen*=o});const A=eM(t)+1;return t.getRoots().forEach(r=>{JC(t,e,o,A,i,n,r.id)}),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":qM(t);break;case"tight-tree":default:XM(t);break;case"longest-path":YM(t)}})(DC(t),n),sF(t),((t,e=0)=>{const n=t.getAllNodes(),r=n.filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),i=Math.min(...r),o=[];n.forEach(t=>{const e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)});let A=0;for(let n=0;n{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=A)}))}})(t,u),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach(e=>{e.data.nestingEdge&&t.removeEdge(e.id)})})(t,l),(t=>{const e=t.getAllNodes().filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),n=Math.min(...e);t.getAllNodes().forEach(t=>{t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)})})(t),aF(t),cF(t);const h=[];((t,e)=>{t.getAllEdges().forEach(n=>rM(t,n,e))})(t,h),wM(t,h),(t=>{const e=n=>{const r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach(t=>e(t.id)),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let e=i.data.minRank,r=i.data.maxRank+1;ee(t.id))})(t),o&&((t,e)=>{const n=t.getAllNodes().filter(e=>{var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)}),r=n.map(t=>t.data.rank),i=Math.max(...r),o=[];for(let t=0;t{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))})})(t,i),((t,e)=>{const n=GC(t),r=[],i=[];for(let t=1;t-1;t--)i.push(t);const o=vM(t,r,"in"),A=vM(t,i,"out");let s=sM(t);yM(t,s);let a,c=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){mM(n%2?o:A,n%4>=2,!1,e),s=HC(t);const i=AM(t,s);i=2,!0,e),s=HC(t);const i=AM(t,s);i{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||WC(t)})(t,r),SM(t,{align:A,nodesep:s,edgesep:a,ranksep:c}),vF(t),fF(t),((t,e)=>{e.forEach(e=>{let n=t.getNode(e);const{data:r}=n,i=r.originalEdge;let o;i&&t.addEdge(i);let A=e;for(;n.data.dummy;)o=t.getSuccessors(A)[0],t.removeNode(A),i.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===nM&&(i.data.x=n.data.x,i.data.y=n.data.y,i.data.width=n.data.width,i.data.height=n.data.height),A=o.id,n=t.getNode(A)})})(t,h),hF(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||XC(t),"lr"!==n&&"rl"!==n||($C(t),WC(t))})(t,r);const{width:d,height:f}=lF(t);return uF(t),dF(t),(t=>{t.getAllEdges().forEach(e=>{const n=e.data;if(n.reversed){t.removeEdge(e.id);const r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},n),{forwardName:r})})}})})(t),{width:d,height:f}},ZM=(t,e)=>{t.getAllNodes().forEach(n=>{const r=t.getNode(n.id);if(e.hasNode(n.id)){const t=e.getNode(n.id);r.data.fixorder=t.data._order,delete t.data._order}else delete r.data.fixorder})},JM=(t,e)=>{t.getAllNodes().forEach(n=>{var r;const i=t.getNode(n.id);if(i){const t=e.getNode(n.id);i.data.x=t.data.x,i.data.y=t.data.y,i.data._order=t.data.order,i.data._rank=t.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=t.data.width,i.data.height=t.data.height)}}),t.getAllEdges().forEach(n=>{const r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)})},tF=["width","height","layer","fixorder"],eF={width:0,height:0},nF=["minlen","weight","width","height","labeloffset"],rF={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},iF=["labelpos"],oF=t=>{const e=new MC({tree:[]});return t.getAllNodes().forEach(n=>{const r=yF(t.getNode(n.id).data),i=Object.assign(Object.assign({},eF),r),o=mF(i,tF);e.hasNode(n.id)||e.addNode({id:n.id,data:Object.assign({},o)});const A=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);Kx(A)||(e.hasNode(A.id)||e.addNode(Object.assign({},A)),e.setParent(n.id,A.id))}),t.getAllEdges().forEach(n=>{const r=yF(t.getEdge(n.id).data),i={};null==iF||iF.forEach(t=>{void 0!==r[t]&&(i[t]=r[t])}),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},rF,mF(r,nF),i)})}),e},AF=(t,e)=>{const{ranksep:n=0,rankdir:r}=e;return t.getAllNodes().forEach(t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)}),t.getAllEdges().forEach(t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===r||"BT"===r?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)}),n/2},sF=t=>{t.getAllEdges().forEach(e=>{if(e.data.width&&e.data.height){const n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};PC(t,"edge-proxy",r,"_ep")}})},aF=t=>{let e=0;return t.getAllNodes().forEach(n=>{var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))}),e},cF=t=>{t.getAllNodes().forEach(e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))})},lF=(t,e)=>{let n,r,i=0,o=0;const{marginx:A=0,marginy:s=0}={},a=t=>{if(!t.data)return;const e=t.data.x,A=t.data.y,s=t.data.width,a=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(A)||isNaN(a)||(void 0===r&&(r=A-a/2),r=Math.min(r,A-a/2),o=Math.max(o,A+a/2))};return t.getAllNodes().forEach(t=>{a(t)}),t.getAllEdges().forEach(t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&a(t)}),n-=A,r-=s,t.getAllNodes().forEach(t=>{t.data.x-=n,t.data.y-=r}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>{t.x-=n,t.y-=r}),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)}),{width:i-n+A,height:o-r+s}},uF=t=>{t.getAllEdges().forEach(e=>{const n=t.getNode(e.source),r=t.getNode(e.target);let i,o;e.data.points?(i=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],i={x:r.data.x,y:r.data.y},o={x:n.data.x,y:n.data.y}),e.data.points.unshift(RC(n.data,i)),e.data.points.push(RC(r.data,o))})},hF=t=>{t.getAllEdges().forEach(t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}})},dF=t=>{t.getAllEdges().forEach(t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())})},fF=t=>{t.getAllNodes().forEach(e=>{var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){const n=t.getNode(e.id),o=t.getNode(n.data.borderTop),A=t.getNode(n.data.borderBottom),s=t.getNode(n.data.borderLeft[(null===(r=n.data.borderLeft)||void 0===r?void 0:r.length)-1]),a=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==a?void 0:a.data.x)-(null==s?void 0:s.data.x))||10,n.data.height=Math.abs((null==A?void 0:A.data.y)-(null==o?void 0:o.data.y))||10,n.data.x=((null==s?void 0:s.data.x)||0)+n.data.width/2,n.data.y=((null==o?void 0:o.data.y)||0)+n.data.height/2}}),t.getAllNodes().forEach(e=>{"border"===e.data.dummy&&t.removeNode(e.id)})},gF=t=>{t.getAllEdges().forEach(e=>{if(e.source===e.target){const n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}})},pF=t=>{const e=HC(t);null==e||e.forEach(e=>{let n=0;null==e||e.forEach((e,r)=>{var i;const o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach(e=>{PC(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")}),delete o.data.selfEdges})})},vF=t=>{t.getAllNodes().forEach(e=>{const n=t.getNode(e.id);if("selfedge"===n.data.dummy){const r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,A=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*A/3,y:o-s},{x:i+5*A/6,y:o-s},{y:o,x:i+A},{x:i+5*A/6,y:o+s},{x:i+2*A/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}})},mF=(t,e)=>{const n={};return null==e||e.forEach(e=>{void 0!==t[e]&&(n[e]=+t[e])}),n},yF=(t={})=>{const e={};return Object.keys(t).forEach(n=>{e[n.toLowerCase()]=t[n]}),e},wF={nodeSize:10,nodeSpacing:0,rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class bF extends EC{constructor(){super(...arguments),this.id="antv-dagre"}getDefaultOptions(){return wF}layout(t){return mx(this,0,void 0,function*(){const{nodeSize:e,nodeSpacing:n,align:r,rankdir:i="TB",ranksep:o,nodesep:A,edgeLabelSpace:s,ranker:a="tight-tree",nodeOrder:c,begin:l,controlPoints:u,radial:h,sortByCombo:d,preset:f,ranksepFunc:g,nodesepFunc:p}=t,v=Wx(g,null!=o?o:50,"node"),m=Wx(p,null!=A?A:50,"node");let y=m,w=v;"LR"!==i&&"RL"!==i||(y=v,w=m);const b=new MC({tree:[]}),B=this.model.nodes(),E=this.model.edges(),x=Xx(e,n,wF.nodeSize,wF.nodeSpacing);B.forEach(t=>{var e;const n=t._original,r=x(n),i=w(n),o=y(n),A=r[0]+2*o,s=r[1]+2*i,a=null===(e=t.data)||void 0===e?void 0:e.layer;_x(a)?b.addNode({id:t.id,data:{width:A,height:s,layer:a,originalWidth:r[0],originalHeight:r[1]}}):b.addNode({id:t.id,data:{width:A,height:s,originalWidth:r[0],originalHeight:r[1]}})}),E.forEach(t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{}})}),d&&(b.attachTreeStructure("combo"),B.forEach(t=>{const e=null==t?void 0:t.parentId;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}));let C=null;(null==f?void 0:f.length)&&(C=new MC,f.forEach(t=>{C.addNode({id:t.id,data:t.data})})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:A}=e;!r&&i&&ZM(t,i);const s=oF(t);let a;n&&(e.ranksep=AF(s,{rankdir:o,ranksep:A}));try{a=$M(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}JM(t,s)})(b,{prevGraph:C,edgeLabelSpace:s,keepNodeOrder:!!c,nodeOrder:c||[],acyclicer:"greedy",ranker:a,rankdir:i,nodesep:A,align:r});const M=[0,0];if(l){let t=1/0,e=1/0;b.getAllNodes().forEach(n=>{t>n.data.x&&(t=n.data.x),e>n.data.y&&(e=n.data.y)}),b.getAllEdges().forEach(n=>{var r;null===(r=n.data.points)||void 0===r||r.forEach(n=>{t>n.x&&(t=n.x),e>n.y&&(e=n.y)})}),M[0]=l[0]-t,M[1]=l[1]-e}const F="LR"===i||"RL"===i;if(h);else{const t=new Set,e="BT"===i||"RL"===i?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach(e=>{e.data.x=e.data.x+M[0],e.data.y=e.data.y+M[1],t.add(F?e.data.x:e.data.y)});const n=Array.from(t).sort(e),r=F?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,o=F?(t,e,n)=>{const r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter(t=>t.y<=r&&t.y>=i)}:(t,e,n)=>{const r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter(t=>t.x<=r&&t.x>=i)};b.getAllEdges().forEach((t,e)=>{var i;s&&u&&"loop"!==t.data.type&&(t.data.controlPoints=BF(null===(i=t.data.points)||void 0===i?void 0:i.map(({x:t,y:e})=>({x:t+M[0],y:e+M[1]})),b.getNode(t.source),b.getNode(t.target),n,F,r,o))})}this.model.forEachNode(t=>{const e=b.getNode(t.id);if(e){const{x:n,y:r,width:i,height:o,originalWidth:A,originalHeight:s}=e.data,a=d?b.getChildren(t.id,"combo"):b.getChildren(t.id);if(a.length>0){let e=1/0,n=-1/0,r=1/0,i=-1/0;a.forEach(t=>{const o=t.id,A=b.getNode(o);if(null==A?void 0:A.data){const t=A.data.x,o=A.data.y,s=A.data.originalWidth||A.data.width||0,a=A.data.originalHeight||A.data.height||0;e=Math.min(e,t-s/2),n=Math.max(n,t+s/2),r=Math.min(r,o-a/2),i=Math.max(i,o+a/2)}});const o=20,A=(n-e||0)+2*o,s=(i-r||0)+2*o;t.x=(e+n)/2,t.y=(r+i)/2,t.size=[A,s]}else t.x=n,t.y=r,t.size=[A,s]}}),this.model.forEachEdge(t=>{const e=b.getEdge(t.id);e&&e.data.controlPoints&&(t.points=e.data.controlPoints.map(qx))})})}}const BF=(t,e,n,r,i,o,A)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){let{x:t,y:a}=e.data,{x:c,y:l}=n.data;if(i&&(t=e.data.y,a=e.data.x,c=n.data.y,l=n.data.x),l!==a&&t!==c){const u=r.indexOf(a),h=r[u+1];if(h){const t=s[0],e=i?{x:(a+h)/2,y:(null==t?void 0:t.y)||c}:{x:(null==t?void 0:t.x)||c,y:(a+h)/2};t&&!o(t,e)||s.unshift(e)}const d=r.indexOf(l),f=Math.abs(d-u);if(1===f)s=A(s,e.data,n.data),s.length||s.push(i?{x:(a+l)/2,y:t}:{x:t,y:(a+l)/2});else if(f>1){const e=r[d-1];if(e){const n=s[s.length-1],r=i?{x:(l+e)/2,y:(null==n?void 0:n.y)||c}:{x:(null==n?void 0:n.x)||t,y:(l+e)/2};n&&!o(n,r)||s.push(r)}}}}return s};function EF(t,e,n=2){if(1===t.nodeCount()){const r=t.firstNode();r.x=e[0],r.y=e[1],3===n&&(r.z=e[2]||0)}}function xF(t,e){const n=t.nodes();return n.sort(e),t.setNodeOrder(n),t}function CF(t,e="desc"){return xF(t,(n,r)=>{const i=t.degree(n.id),o=t.degree(r.id);return"asc"===e?i-o:o-i})}function MF(t,e){return xF(t,(n,r)=>{const i=t.originalNode(n.id),o=t.originalNode(r.id);return e(i,o)})}function FF(t,e=!1){const n=t.nodeCount();if(0===n)return t;const r=t.nodes(),i=[r[0]],o={};o[r[0].id]=!0;let A=0,s=0;return t.forEachNode(a=>{if(0!==s){const c=t.degree(a.id,"both"),l=s{const{width:e,height:n,center:r}=t,i=null!=e?e:"undefined"!=typeof window?window.innerWidth:0,o=null!=n?n:"undefined"!=typeof window?window.innerHeight:0;return{width:i,height:o,center:null!=r?r:[i/2,o/2]}},SF={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1,nodeSize:10,nodeSpacing:0};class QF extends EC{constructor(){super(...arguments),this.id="circular"}getDefaultOptions(){return SF}layout(){return mx(this,0,void 0,function*(){const{width:t,height:e,center:n}=kF(this.options),r=this.model.nodeCount();if(!r||1===r)return void EF(this.model,n);const{ordering:i,nodeSpacing:o,nodeSize:A,endAngle:s=2*Math.PI,startAngle:a=0,divisions:c,angleRatio:l,clockwise:u}=this.options;"topology"===i?FF(this.model,!1):"topology-directed"===i?FF(this.model,!0):"degree"===i&&CF(this.model,"asc");let{radius:h,startRadius:d,endRadius:f}=this.options;const g=this.model.nodes(),p=Xx(A,o,SF.nodeSize,SF.nodeSpacing);if(o){let t=0;for(const e of g)t+=Math.max(...p(e._original));h=t/(2*Math.PI)}else h||d||f?!d&&f?d=f:d&&!f&&(f=d):h=Math.min(e,t)/2;const v=(s-a)/r*l,m=Math.ceil(r/c),y=2*Math.PI/c;for(let t=0;t{const n=d(t),r=d(e);return n===r?0:n>r?-1:1};MF(this.model,t)}const f=this.model.nodes(),g=new Map;for(const t of f){const e="degree"===d?this.model.degree(t.id):d(t._original);g.set(t.id,e)}const p=this.model.firstNode(),v=o||g.get(p.id)/4,m=Xx(u,h,UF.nodeSize,UF.nodeSpacing),y=new Map;for(const t of f)y.set(t.id,Math.max(...m(t._original)));const w=[{nodes:[]}];let b=w[0];for(let t=0;t0){const t=b.nodes[0],n=Math.abs(g.get(t.id)-g.get(e.id));v&&n>=v&&(b={nodes:[]},w.push(b))}b.nodes.push(e)}for(const t of w){const e=t.nodes.map(t=>y.get(t.id));t.nodeSizes=e,t.maxNodeSize=Math.max(...e)}if(w.forEach(t=>{const e=void 0===A?2*Math.PI-2*Math.PI/t.nodes.length:A;t.dTheta=e/Math.max(1,t.nodes.length-1)}),c){let t=0;for(let e=0;e1){const e=n.nodeSizes||[];let r=0;for(let t=0;t0?r/A:0;t=Math.max(s,t)}if(n.r=t,e{0===r&&(e=n.r||0),n.r=e,e+=t})}w.forEach(t=>{const e=t.dTheta||0,r=t.r||0;t.nodes.forEach((t,i)=>{const o=l+(s?1:-1)*e*i;t.x=n[0]+r*Math.cos(o),t.y=n[1]+r*Math.sin(o)})})})}}function TF(t,...e){return e.forEach(e=>{e&&Object.keys(e).forEach(n=>{const r=e[n];void 0!==r&&(t[n]=r)})}),t}const OF=4294967296;var IF,LF,PF=0,DF=0,RF=0,HF=0,_F=0,GF=0,KF="object"==typeof performance&&performance.now?performance:Date,jF="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function zF(){return _F||(jF(VF),_F=KF.now()+GF)}function VF(){_F=0}function WF(){this._call=this._time=this._next=null}function YF(t,e,n){var r=new WF;return r.restart(t,e,n),r}function XF(){_F=(HF=KF.now())+GF,PF=DF=0;try{!function(){zF(),++PF;for(var t,e=IF;e;)(t=_F-e._time)>=0&&e._call.call(void 0,t),e=e._next;--PF}()}finally{PF=0,function(){var t,e,n=IF,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:IF=e);LF=t,$F(r)}(),_F=0}}function qF(){var t=KF.now(),e=t-HF;e>1e3&&(GF-=e,HF=t)}function $F(t){PF||(DF&&(DF=clearTimeout(DF)),t-_F>24?(t<1/0&&(DF=setTimeout(XF,t-KF.now()-GF)),RF&&(RF=clearInterval(RF))):(RF||(HF=KF.now(),RF=setInterval(qF,1e3)),PF=1,jF(XF)))}WF.prototype=YF.prototype={constructor:WF,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?zF():+n)+(null==e?0:+e),this._next||LF===this||(LF?LF._next=this:IF=this,LF=this),this._call=t,this._time=n,$F()},stop:function(){this._call&&(this._call=null,this._time=1/0,$F())}};var ZF={value:()=>{}};function JF(){for(var t,e=0,n=arguments.length,r={};e=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),A=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++A0)for(var n,r,i=new Array(n),o=0;o(t=(1664525*t+1013904223)%OF)/OF}();function u(){h(),c.call("tick",e),n1?(null==n?s.delete(t):s.set(t,f(n)),e):s.get(t)},find:function(e,n,r){var i,o,A,s,a,c=0,l=t.length;for(null==r?r=1/0:r*=r,c=0;c1?(c.on(t,n),e):c.on(t)}}}function sk(t){return function(){return t}}function ak(t){var e,n,r,i=sk(.1);function o(t){for(var i,o=0,A=e.length;o=(o=(g+v)/2))?g=o:v=o,(l=n>=(A=(p+m)/2))?p=A:m=A,i=d,!(d=d[u=l<<1|c]))return i[u]=f,t;if(s=+t._x.call(null,d.data),a=+t._y.call(null,d.data),e===s&&n===a)return f.next=d,i?i[u]=f:t._root=f,t;do{i=i?i[u]=new Array(4):t._root=new Array(4),(c=e>=(o=(g+v)/2))?g=o:v=o,(l=n>=(A=(p+m)/2))?p=A:m=A}while((u=l<<1|c)==(h=(a>=A)<<1|s>=o));return i[h]=d,i[u]=f,t}function hk(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function dk(t){return t[0]}function fk(t){return t[1]}function gk(t,e,n){var r=new pk(null==e?dk:e,null==n?fk:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function pk(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function vk(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var mk=gk.prototype=pk.prototype;function yk(t){return t.x+t.vx}function wk(t){return t.y+t.vy}function bk(t){var e,n,r,i=1,o=1;function A(){for(var t,A,a,c,l,u,h,d=e.length,f=0;fc+f||ol+f||Aa.index){var g=c-s.x-s.vx,p=l-s.y-s.vy,v=g*g+p*p;vt.r&&(t.r=t[e].r)}function a(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r=s)){(t.data!==e||t.next)&&(0===u&&(f+=(u=lk(n))*u),0===h&&(f+=(h=lk(n))*h),f[s(t,e,r),t]));for(A=0,i=new Array(c);Al&&(l=r),iu&&(u=i));if(a>l||c>u)return this;for(this.cover(a,c).cover(l,u),n=0;nt||t>=i||r>e||e>=o;)switch(s=(eh||(o=a.y0)>d||(A=a.x1)=v)<<1|t>=p)&&(a=f[f.length-1],f[f.length-1]=f[f.length-1-c],f[f.length-1-c]=a)}else{var m=t-+this._x.call(null,g.data),y=e-+this._y.call(null,g.data),w=m*m+y*y;if(w=(s=(f+p)/2))?f=s:p=s,(l=A>=(a=(g+v)/2))?g=a:v=a,e=d,!(d=d[u=l<<1|c]))return this;if(!d.length)break;(e[u+1&3]||e[u+2&3]||e[u+3&3])&&(n=e,h=u)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):e?(i?e[u]=i:delete e[u],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(n?n[h]=d:this._root=d),this):(this._root=i,this)},mk.removeAll=function(t){for(var e=0,n=t.length;et[e];function Fk(){function t(t){return()=>t}let e,n=t=>t.cluster,r=t(1),i=t(-1),o=t(100),A=t(.1),s=[0,0],a=[],c={},l=[],u=100,h=100,d={none:{x:0,y:0}},f=[],g="force",p=!0,v=.1;function m(t){if(!p)return m;e.tick(),w();for(let e,r=0,i=a.length,o=t*v;r{const r=n(t._original);e[r]||(e[r]={count:0,sumforceNodeSize:0})}),t.forEach(t=>{const i=n(t._original),o=r(t._original),A=e[i];A.count=A.count+1,A.sumforceNodeSize=A.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=A}),e}(a),s=function(t){const e={},r=[];t.forEach(t=>{const r=function(t){const e=Mk(t,"source"),r=Mk(t,"target"),i=n(c[e]._original),o=n(c[r]._original);return i<=o?`${i}~${o}`:`${o}~${i}`}(t);let i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i});return Object.entries(e).forEach(([t,e])=>{const n=t.split("~")[0],i=t.split("~")[1];void 0!==n&&void 0!==i&&r.push({source:n,target:i,count:e})}),r}(l),o=Object.keys(A),o.forEach((e,n)=>{const r=A[e];t.push({id:e,size:r.count,r:Math.sqrt(r.sumforceNodeSize/Math.PI)}),i[e]=n}),s.forEach(t=>{const n=Mk(t,"source"),r=Mk(t,"target"),o=i[n],A=i[r];void 0!==o&&void 0!==A&&e.push({source:o,target:A,count:t.count})}),{nodes:t,links:e}}();e=Ak(s.nodes).force("x",ak(u).strength(.1)).force("y",ck(h).strength(.1)).force("collide",bk(t=>t.r).iterations(4)).force("charge",Bk().strength(i)).force("links",Ck(s.nodes.length?s.links:[]).distance(o).strength(A)),f=e.nodes(),w()}()}function w(){return d={none:{x:0,y:0}},f.forEach(t=>{d[t.id]={x:t.x-s[0],y:t.y-s[1]}}),d}return m.initialize=t=>{a=t,y()},m.template=function(t){return arguments.length?(g=t,y(),m):g},m.groupBy=function(t){return arguments.length?"string"==typeof t?(n=e=>e[t],m):(n=t,m):n},m.enableGrouping=function(t){return arguments.length?(p=t,m):p},m.strength=function(t){return arguments.length?(v=t,m):v},m.centerX=function(t){return arguments.length?(u=t,m):u},m.centerY=function(t){return arguments.length?(h=t,m):h},m.nodes=function(t){return arguments.length?(function(t){c={},t.forEach(t=>{c[t.id]=t})}(t||[]),a=t||[],m):a},m.links=function(t){return arguments.length?(l=t||[],y(),m):l},m.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),y(),m):r},m.nodeSize=m.forceNodeSize,m.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),y(),m):i},m.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),y(),m):o},m.forceLinkStrength=function(e){return arguments.length?(A="function"==typeof e?e:t(+e),y(),m):A},m.offset=function(t){return arguments.length?(s=t,m):s},m.getFocis=w,m}var kk={}.toString,Sk=function(t,e){return kk.call(t)==="[object "+e+"]"},Qk=function(t){if(!function(t){return"object"==typeof t&&null!==t}(t)||!Sk(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};function Uk(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function Nk(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(Uk(e,i)){var o=e[i];null!==o&&Qk(o)?(Qk(t[i])||(t[i]={}),ne.id===t),r=this.model.node(t);if(!r||!n)return;const i=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e{delete r[t],delete n[t]})}parseOptions(t){const e=t;return void 0===e.iterations&&(e.link&&void 0===e.link.iterations&&(e.iterations=e.link.iterations),e.collide&&void 0===e.collide.iterations&&(e.iterations=e.collide.iterations)),e}layout(){var t;return mx(this,0,void 0,function*(){const e=this.parseOptions(this.options||{});this.createD3Copies();const n=this.setSimulation(e);return n.nodes(this.d3Nodes),null===(t=n.force("link"))||void 0===t||t.links(this.d3Edges),new Promise(t=>{n.on("end",()=>{this.syncPositionsFromD3(),t()})})})}createD3Copies(){this.d3Nodes=[],this.d3Edges=[],this.model.forEachNode(t=>{this.d3Nodes.push(Object.assign({},t))}),this.model.forEachEdge(t=>{this.d3Edges.push(Object.assign({},t))})}syncPositionsFromD3(){this.d3Nodes.forEach(t=>{const e=this.model.node(t.id);e&&(e.x=t.x,e.y=t.y,void 0!==t.z&&(e.z=t.z),void 0!==t.fx&&(e.fx=t.fx),void 0!==t.fy&&(e.fy=t.fy),void 0!==t.fz&&(e.fz=t.fz),void 0!==t.vx&&(e.vx=t.vx),void 0!==t.vy&&(e.vy=t.vy),void 0!==t.vz&&(e.vz=t.vz))})}initSimulation(){return Ak()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",()=>{var e;this.syncPositionsFromD3(),null===(e=t.onTick)||void 0===e||e.call(t,this)})),Ik(e,this.config.simulationAttrs.map(e=>[e,t[e]])),this.setupForces(e,t),e}setupForces(t,e){this.setupLinkForce(t,e),this.setupManyBodyForce(t,e),this.setupCenterForce(t,e),this.setupCollisionForce(t,e),this.setupXForce(t,e),this.setupYForce(t,e),this.setupRadialForce(t,e),this.setupClusterForce(t,e)}getCenterOptions(t){if(!1===t.center)return;const e=kF({width:t.width,height:t.height});return TF({},t.center||{},{x:e.width/2,y:e.height/2,strength:t.centerStrength})}setupCenterForce(t,e){const n=this.getCenterOptions(e);if(n){let e=t.force("center");e||(e=function(t,e){var n,r=1;function i(){var i,o,A=n.length,s=0,a=0;for(i=0;i0&&r){let e=t.force("link");e||(e=Ck(),t.force("link",e));const n=[];void 0!==r.id&&n.push(["id",r.id]),void 0!==r.distance&&n.push(["distance",r.distance]),void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.iterations&&n.push(["iterations",r.iterations]),Ik(e,n)}else t.force("link",null)}getCollisionOptions(t){if(!1===t.preventOverlap&&(!1===t.collide||void 0===t.collide))return;const e=Xx(t.nodeSize,t.nodeSpacing,Tk.nodeSize,Tk.nodeSpacing);return TF({},t.collide||{},{radius:t.collide&&t.collide.radius||(t=>Math.max(...e(t._original))/2),strength:t.collideStrength,iterations:t.collideIterations})}setupCollisionForce(t,e){const n=this.getCollisionOptions(e);if(n){let e=t.force("collide");e||(e=bk(),t.force("collide",e));const r=[];void 0!==n.radius&&r.push(["radius",n.radius]),void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.iterations&&r.push(["iterations",n.iterations]),Ik(e,r)}else t.force("collide",null)}getXForceOptions(t){var e;if(!1===t.x)return;const n=this.getCenterOptions(t);return TF({},t.x||{},{x:null!==(e=t.forceXPosition)&&void 0!==e?e:n&&n.x,strength:t.forceXStrength})}setupXForce(t,e){const n=this.getXForceOptions(e);if(n){let e=t.force("x");e||(e=ak(),t.force("x",e));const r=[];void 0!==n.x&&r.push(["x",n.x]),void 0!==n.strength&&r.push(["strength",n.strength]),Ik(e,r)}else t.force("x",null)}getYForceOptions(t){var e;if(!1===t.y)return;const n=this.getCenterOptions(t);return TF({},t.y||{},{y:null!==(e=t.forceYPosition)&&void 0!==e?e:n&&n.y,strength:t.forceYStrength})}setupYForce(t,e){const n=this.getYForceOptions(e);if(n){let e=t.force("y");e||(e=ck(),t.force("y",e));const r=[];void 0!==n.y&&r.push(["y",n.y]),void 0!==n.strength&&r.push(["strength",n.strength]),Ik(e,r)}else t.force("y",null)}getRadialOptions(t){var e,n,r;if(void 0!==t.radial||void 0!==t.radialStrength||void 0!==t.radialRadius||void 0!==t.radialX||void 0!==t.radialY){const i=this.getCenterOptions(t);return TF({},t.radial||{},{strength:t.radialStrength,radius:null!==(e=t.radialRadius)&&void 0!==e?e:100,x:null!==(n=t.radialX)&&void 0!==n?n:i&&i.x,y:null!==(r=t.radialY)&&void 0!==r?r:i&&i.y})}}setupRadialForce(t,e){const n=this.getRadialOptions(e);if(n){let e=t.force("radial");e||(e=function(t,e,n){var r,i,o,A=sk(.1);function s(t){for(var A=0,s=r.length;Ae.reduce((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e,t);function Lk(t){return function(){return t}}function Pk(t){var e,n,r,i=Lk(.1);function o(t){for(var i,o=0,A=e.length;o1&&(l.vy+=h*g),o>2&&(l.vz+=d*g)}}function l(){if(i){var e,n=i.length;for(A=new Array(n),s=new Array(n),e=0;e[1,2,3].includes(t))||2,l()},c.strength=function(t){return arguments.length?(a="function"==typeof t?t:Lk(+t),l(),c):a},c.radius=function(e){return arguments.length?(t="function"==typeof e?e:Lk(+e),l(),c):t},c.x=function(t){return arguments.length?(e=+t,c):e},c.y=function(t){return arguments.length?(n=+t,c):n},c.z=function(t){return arguments.length?(r=+t,c):r},c}function _k(t){return 1e-6*(t()-.5)}function Gk(t,e,n){if(isNaN(e))return t;var r,i,o,A,s,a,c=t._root,l={data:n},u=t._x0,h=t._x1;if(!c)return t._root=l,t;for(;c.length;)if((A=e>=(i=(u+h)/2))?u=i:h=i,r=c,!(c=c[s=+A]))return r[s]=l,t;if(e===(o=+t._x.call(null,c.data)))return l.next=c,r?r[s]=l:t._root=l,t;do{r=r?r[s]=new Array(2):t._root=new Array(2),(A=e>=(i=(u+h)/2))?u=i:h=i}while((s=+A)===(a=+(o>=i)));return r[a]=c,r[s]=l,t}function Kk(t,e,n){this.node=t,this.x0=e,this.x1=n}function jk(t){return t[0]}function zk(t,e){var n=new Vk(null==e?jk:e,NaN,NaN);return null==t?n:n.addAll(t)}function Vk(t,e,n){this._x=t,this._x0=e,this._x1=n,this._root=void 0}function Wk(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Yk=zk.prototype=Vk.prototype;function Xk(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,A,s,a,c,l,u,h,d,f,g,p,v=t._root,m={data:i},y=t._x0,w=t._y0,b=t._z0,B=t._x1,E=t._y1,x=t._z1;if(!v)return t._root=m,t;for(;v.length;)if((h=e>=(A=(y+B)/2))?y=A:B=A,(d=n>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(b+x)/2))?b=a:x=a,o=v,!(v=v[g=f<<2|d<<1|h]))return o[g]=m,t;if(c=+t._x.call(null,v.data),l=+t._y.call(null,v.data),u=+t._z.call(null,v.data),e===c&&n===l&&r===u)return m.next=v,o?o[g]=m:t._root=m,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(h=e>=(A=(y+B)/2))?y=A:B=A,(d=n>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(b+x)/2))?b=a:x=a}while((g=f<<2|d<<1|h)==(p=(u>=a)<<2|(l>=s)<<1|c>=A));return o[p]=v,o[g]=m,t}function qk(t,e,n,r,i,o,A){this.node=t,this.x0=e,this.y0=n,this.z0=r,this.x1=i,this.y1=o,this.z1=A}Yk.copy=function(){var t,e,n=new Vk(this._x,this._x0,this._x1),r=this._root;if(!r)return n;if(!r.length)return n._root=Wk(r),n;for(t=[{source:r,target:n._root=new Array(2)}];r=t.pop();)for(var i=0;i<2;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(2)}):r.target[i]=Wk(e));return n},Yk.add=function(t){const e=+this._x.call(null,t);return Gk(this.cover(e),e,t)},Yk.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e);let r=1/0,i=-1/0;for(let o,A=0;Ai&&(i=o));if(r>i)return this;this.cover(r).cover(i);for(let r=0;rt||t>=n;)switch(i=+(ta||(i=o.x1)=u))&&(o=c[c.length-1],c[c.length-1]=c[c.length-1-A],c[c.length-1-A]=o)}else{var h=Math.abs(t-+this._x.call(null,l.data));h=(A=(u+h)/2))?u=A:h=A,e=l,!(l=l[a=+s]))return this;if(!l.length)break;e[a+1&1]&&(n=e,c=a)}for(;l.data!==t;)if(r=l,!(l=l.next))return this;return(i=l.next)&&delete l.next,r?(i?r.next=i:delete r.next,this):e?(i?e[a]=i:delete e[a],(l=e[0]||e[1])&&l===(e[1]||e[0])&&!l.length&&(n?n[c]=l:this._root=l),this):(this._root=i,this)},Yk.removeAll=function(t){for(var e=0,n=t.length;eMath.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function Zk(t){return t[0]}function Jk(t){return t[1]}function tS(t){return t[2]}function eS(t,e,n,r){var i=new nS(null==e?Zk:e,null==n?Jk:n,null==r?tS:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function nS(t,e,n,r,i,o,A,s,a){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=A,this._y1=s,this._z1=a,this._root=void 0}function rS(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var iS=eS.prototype=nS.prototype;function oS(t){return t.x+t.vx}function AS(t){return t.y+t.vy}function sS(t){return t.z+t.vz}function aS(t){var e,n,r,i,o=1,A=1;function s(){for(var t,s,c,l,u,h,d,f,g=e.length,p=0;p1&&(u=c.y+c.vy),n>2&&(h=c.z+c.vz),s.visit(v);function v(t,e,r,A,s,a,g){var p=[e,r,A,s,a,g],v=p[0],m=p[1],y=p[2],w=p[n],b=p[n+1],B=p[n+2],E=t.data,x=t.r,C=d+x;if(!E)return v>l+C||w1&&(m>u+C||b2&&(y>h+C||Bc.index){var M=l-E.x-E.vx,F=n>1?u-E.y-E.vy:0,k=n>2?h-E.z-E.vz:0,S=M*M+F*F+k*k;S1&&0===F&&(S+=(F=_k(i))*F),n>2&&0===k&&(S+=(k=_k(i))*k),S=(C-(S=Math.sqrt(S)))/S*o,c.vx+=(M*=S)*(C=(x*=x)/(f+x)),n>1&&(c.vy+=(F*=S)*C),n>2&&(c.vz+=(k*=S)*C),E.vx-=M*(C=1-C),n>1&&(E.vy-=F*C),n>2&&(E.vz-=k*C))}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;et.r&&(t.r=t[e].r)}function c(){if(e){var n,i,o=e.length;for(r=new Array(o),n=0;n"function"==typeof t)||Math.random,n=r.find(t=>[1,2,3].includes(t))||2,c()},s.iterations=function(t){return arguments.length?(A=+t,s):A},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:Lk(+e),c(),s):t},s}function cS(t,e,n){var r,i=1;function o(){var o,A,s=r.length,a=0,c=0,l=0;for(o=0;oa&&(a=h),dc&&(c=d),fl&&(l=f));if(o>a||A>c||s>l)return this;this.cover(o,A,s).cover(a,c,l);for(let o=0;ot||t>=A||i>e||e>=s||o>n||n>=a;)switch(l=(np||(A=u.y0)>v||(s=u.z0)>m||(a=u.x1)=E)<<2|(e>=B)<<1|t>=b)&&(u=y[y.length-1],y[y.length-1]=y[y.length-1-h],y[y.length-1-h]=u)}else{var x=t-+this._x.call(null,w.data),C=e-+this._y.call(null,w.data),M=n-+this._z.call(null,w.data),F=x*x+C*C+M*M;if(F{if(!u.length)do{const o=u.data;$k(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(u=u.next);return h>a||d>c||f>l||g=(a=(v+w)/2))?v=a:w=a,(h=A>=(c=(m+b)/2))?m=c:b=c,(d=s>=(l=(y+B)/2))?y=l:B=l,e=p,!(p=p[f=d<<2|h<<1|u]))return this;if(!p.length)break;(e[f+1&7]||e[f+2&7]||e[f+3&7]||e[f+4&7]||e[f+5&7]||e[f+6&7]||e[f+7&7])&&(n=e,g=f)}for(;p.data!==t;)if(r=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,r?(i?r.next=i:delete r.next,this):e?(i?e[f]=i:delete e[f],(p=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&p===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!p.length&&(n?n[g]=p:this._root=p),this):(this._root=i,this)},iS.removeAll=function(t){for(var e=0,n=t.length;e(t=(1664525*t+1013904223)%lS)/lS}();function d(){f(),u.call("tick",n),i1&&(null==l.fy?l.y+=l.vy*=a:(l.y=l.fy,l.vy=0)),r>2&&(null==l.fz?l.z+=l.vz*=a:(l.z=l.fz,l.vz=0));return n}function g(){for(var e,n=0,i=t.length;n1&&isNaN(e.y)||r>2&&isNaN(e.z)){var o=10*(r>2?Math.cbrt(.5+n):r>1?Math.sqrt(.5+n):n),A=n*fS,s=n*gS;1===r?e.x=o:2===r?(e.x=o*Math.cos(A),e.y=o*Math.sin(A)):(e.x=o*Math.sin(A)*Math.cos(s),e.y=o*Math.cos(A),e.z=o*Math.sin(A)*Math.sin(s))}(isNaN(e.vx)||r>1&&isNaN(e.vy)||r>2&&isNaN(e.vz))&&(e.vx=0,r>1&&(e.vy=0),r>2&&(e.vz=0))}}function p(e){return e.initialize&&e.initialize(t,h,r),e}return null==t&&(t=[]),g(),n={tick:f,restart:function(){return l.restart(d),n},stop:function(){return l.stop(),n},numDimensions:function(t){return arguments.length?(r=Math.min(3,Math.max(1,Math.round(t))),c.forEach(p),n):r},nodes:function(e){return arguments.length?(t=e,g(),c.forEach(p),n):t},alpha:function(t){return arguments.length?(i=+t,n):i},alphaMin:function(t){return arguments.length?(o=+t,n):o},alphaDecay:function(t){return arguments.length?(A=+t,n):+A},alphaTarget:function(t){return arguments.length?(s=+t,n):s},velocityDecay:function(t){return arguments.length?(a=1-t,n):1-a},randomSource:function(t){return arguments.length?(h=t,c.forEach(p),n):h},force:function(t,e){return arguments.length>1?(null==e?c.delete(t):c.set(t,p(e)),n):c.get(t)},find:function(){var e,n,i,o,A,s,a=Array.prototype.slice.call(arguments),c=a.shift()||0,l=(r>1?a.shift():null)||0,u=(r>2?a.shift():null)||0,h=a.shift()||1/0,d=0,f=t.length;for(h*=h,d=0;d1?(u.on(t,e),n):u.on(t)}}}function vS(){var t,e,n,r,i,o,A=Lk(-30),s=1,a=1/0,c=.81;function l(r){var o,A=t.length,s=(1===e?zk(t,uS):2===e?gk(t,uS,hS):3===e?eS(t,uS,hS,dS):null).visitAfter(h);for(i=r,o=0;o1&&(t.y=A/l),e>2&&(t.z=s/l)}else{(n=t).x=n.data.x,e>1&&(n.y=n.data.y),e>2&&(n.z=n.data.z);do{c+=o[n.data.index]}while(n=n.next)}t.value=c}function d(t,A,l,u,h){if(!t.value)return!0;var d=[l,u,h][e-1],f=t.x-n.x,g=e>1?t.y-n.y:0,p=e>2?t.z-n.z:0,v=d-A,m=f*f+g*g+p*p;if(v*v/c1&&0===g&&(m+=(g=_k(r))*g),e>2&&0===p&&(m+=(p=_k(r))*p),m1&&(n.vy+=g*t.value*i/m),e>2&&(n.vz+=p*t.value*i/m)),!0;if(!(t.length||m>=a)){(t.data!==n||t.next)&&(0===f&&(m+=(f=_k(r))*f),e>1&&0===g&&(m+=(g=_k(r))*g),e>2&&0===p&&(m+=(p=_k(r))*p),m1&&(n.vy+=g*v),e>2&&(n.vz+=p*v))}while(t=t.next)}}return l.initialize=function(n,...i){t=n,r=i.find(t=>"function"==typeof t)||Math.random,e=i.find(t=>[1,2,3].includes(t))||2,u()},l.strength=function(t){return arguments.length?(A="function"==typeof t?t:Lk(+t),u(),l):A},l.distanceMin=function(t){return arguments.length?(s=t*t,l):Math.sqrt(s)},l.distanceMax=function(t){return arguments.length?(a=t*t,l):Math.sqrt(a)},l.theta=function(t){return arguments.length?(c=t*t,l):Math.sqrt(c)},l}function mS(t){return t.index}function yS(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function wS(t){var e,n,r,i,o,A,s,a=mS,c=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},l=Lk(30),u=1;function h(r){for(var o=0,a=t.length;o1&&(v=h.y+h.vy-l.y-l.vy||_k(s)),i>2&&(m=h.z+h.vz-l.z-l.vz||_k(s)),p*=d=((d=Math.sqrt(p*p+v*v+m*m))-n[g])/d*r*e[g],v*=d,m*=d,h.vx-=p*(f=A[g]),i>1&&(h.vy-=v*f),i>2&&(h.vz-=m*f),l.vx+=p*(f=1-f),i>1&&(l.vy+=v*f),i>2&&(l.vz+=m*f)}function d(){if(r){var i,s,c=r.length,l=t.length,u=new Map(r.map((t,e)=>[a(t,e,r),t]));for(i=0,o=new Array(c);i"function"==typeof t)||Math.random,i=e.find(t=>[1,2,3].includes(t))||2,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(a=t,h):a},h.iterations=function(t){return arguments.length?(u=+t,h):u},h.strength=function(t){return arguments.length?(c="function"==typeof t?t:Lk(+t),f(),h):c},h.distance=function(t){return arguments.length?(l="function"==typeof t?t:Lk(+t),g(),h):l},h}var bS,BS,ES,xS,CS,MS,FS,kS,SS,QS,US,NS,TS,OS,IS,LS,PS,DS,RS,HS,_S,GS,KS,jS,zS,VS,WS,YS,XS,qS,$S,ZS,JS,tQ,eQ,nQ,rQ,iQ,oQ,AQ,sQ,aQ,cQ,lQ,uQ,hQ,dQ,fQ,gQ,pQ,vQ,mQ,yQ,wQ,bQ,BQ,EQ,xQ,CQ,MQ,FQ,kQ,SQ,QQ,UQ,NQ,TQ,OQ,IQ,LQ,PQ,DQ,RQ,HQ,_Q,GQ,KQ,jQ,zQ,VQ,WQ,YQ,XQ,qQ,$Q,ZQ,JQ,tU,eU,nU,rU,iU,oU,AU,sU,aU,cU,lU,uU,hU,dU,fU,gU,pU,vU,mU,yU,wU,bU="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function BU(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function EU(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){var n=!1;try{n=this instanceof t}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}),n}function xU(){if(xS)return ES;return xS=1,ES=function(t,e){return t===e||t!=t&&e!=e}}function CU(){if(MS)return CS;MS=1;var t=xU();return CS=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},CS}function MU(){if(LS)return IS;LS=1;var t=BS?bS:(BS=1,bS=function(){this.__data__=[],this.size=0}),e=function(){if(kS)return FS;kS=1;var t=CU(),e=Array.prototype.splice;return FS=function(n){var r=this.__data__,i=t(r,n);return!(i<0||(i==r.length-1?r.pop():e.call(r,i,1),--this.size,0))},FS}(),n=function(){if(QS)return SS;QS=1;var t=CU();return SS=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},SS}(),r=function(){if(NS)return US;NS=1;var t=CU();return US=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(OS)return TS;OS=1;var t=CU();return TS=function(e,n){var r=this.__data__,i=t(r,e);return i<0?(++this.size,r.push([e,n])):r[i][1]=n,this},TS}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1&&e%1==0&&e-1&&t%1==0&&t<=9007199254740991}}function uN(){if(AN)return oN;return AN=1,oN=function(t){return function(e){return t(e)}}}var hN,dN,fN,gN,pN,vN,mN,yN,wN,bN,BN,EN,xN,CN,MN,FN,kN,SN,QN,UN,NN,TN,ON,IN,LN,PN,DN,RN={exports:{}};function HN(){return hN||(hN=1,function(t,e){var n=FU(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r&&n.process,A=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=A}(RN,RN.exports)),RN.exports}function _N(){if(fN)return dN;fN=1;var t=function(){if(iN)return rN;iN=1;var t=QU(),e=lN(),n=WU(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,rN=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=uN(),n=HN(),r=n&&n.isTypedArray,i=r?e(r):t;return dN=i}function GN(){if(pN)return gN;pN=1;var t=(hU||(hU=1,uU=function(t,e){for(var n=-1,r=Array(t);++nl))return!1;var h=a.get(r),d=a.get(i);if(h&&d)return h==i&&d==r;var f=-1,g=!0,p=2&o?new t:void 0;for(a.set(r,i),a.set(i,r);++f0&&o(l)?i>1?n(l,i-1,o,A,s):t(s,l):A||(s[s.length]=l)}return s},TL}function sG(){if(DL)return PL;DL=1;var t=LL?IL:(LL=1,IL=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}),e=Math.max;return PL=function(n,r,i){return r=e(void 0===r?n.length-1:r,0),function(){for(var o=arguments,A=-1,s=e(o.length-r,0),a=Array(s);++A0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},_L}(),n=e(t);return KL=n}function cG(){if(VL)return zL;VL=1;var t=B_(),e=sG(),n=aG();return zL=function(r,i){return n(e(r,i,t),r+"")}}function lG(){if(YL)return WL;return YL=1,WL=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o-1}}(),n=(iP||(iP=1,rP=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r=200){var g=s?null:i(A);if(g)return o(g);h=!1,l=r,f=new t}else f=s?[]:d;t:for(;++cA){var s=o;o=A,A=s}return o+""+A+""+(t.isUndefined(i)?"\0":i)}function A(t,e){return o(t,e.v,e.w,e.name)}return n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(t){return this._label=t,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return t.keys(this._nodes)},n.prototype.sources=function(){var e=this;return t.filter(this.nodes(),function(n){return t.isEmpty(e._in[n])})},n.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),function(n){return t.isEmpty(e._out[n])})},n.prototype.setNodes=function(e,n){var r=arguments,i=this;return t.each(e,function(t){r.length>1?i.setNode(t,n):i.setNode(t)}),this},n.prototype.setNode=function(n,r){return t.has(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=r),this):(this._nodes[n]=arguments.length>1?r:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=e,this._children[n]={},this._children[e][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)},n.prototype.node=function(t){return this._nodes[t]},n.prototype.hasNode=function(e){return t.has(this._nodes,e)},n.prototype.removeNode=function(e){var n=this;if(t.has(this._nodes,e)){var r=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),function(t){n.setParent(t)}),delete this._children[e]),t.each(t.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},n.prototype.setParent=function(n,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=e;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===n)throw new Error("Setting "+r+" as parent of "+n+" would create a cycle");this.setNode(r)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=r,this._children[r][n]=!0,this},n.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},n.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==e)return n}},n.prototype.children=function(n){if(t.isUndefined(n)&&(n=e),this._isCompound){var r=this._children[n];if(r)return t.keys(r)}else{if(n===e)return this.nodes();if(this.hasNode(n))return[]}},n.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},n.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},n.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},n.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},n.prototype.filterNodes=function(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;t.each(this._nodes,function(t,r){e(r)&&n.setNode(r,t)}),t.each(this._edgeObjs,function(t){n.hasNode(t.v)&&n.hasNode(t.w)&&n.setEdge(t,r.edge(t))});var i={};function o(t){var e=r.parent(t);return void 0===e||n.hasNode(e)?(i[t]=e,e):e in i?i[e]:o(e)}return this._isCompound&&t.each(n.nodes(),function(t){n.setParent(t,o(t))}),n},n.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return t.values(this._edgeObjs)},n.prototype.setPath=function(e,n){var r=this,i=arguments;return t.reduce(e,function(t,e){return i.length>1?r.setEdge(t,e,n):r.setEdge(t,e),e}),this},n.prototype.setEdge=function(){var e,n,i,A,s=!1,a=arguments[0];"object"==typeof a&&null!==a&&"v"in a?(e=a.v,n=a.w,i=a.name,2===arguments.length&&(A=arguments[1],s=!0)):(e=a,n=arguments[1],i=arguments[3],arguments.length>2&&(A=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var c=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,c))return s&&(this._edgeLabels[c]=A),this;if(!t.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[c]=s?A:this._defaultEdgeLabelFn(e,n,i);var l=function(t,e,n,r){var i=""+e,o=""+n;if(!t&&i>o){var A=i;i=o,o=A}var s={v:i,w:o};r&&(s.name=r);return s}(this._isDirected,e,n,i);return e=l.v,n=l.w,Object.freeze(l),this._edgeObjs[c]=l,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][c]=l,this._out[e][c]=l,this._edgeCount++,this},n.prototype.edge=function(t,e,n){var r=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,t,e,n);return this._edgeLabels[r]},n.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},n.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,t,e,n),s=this._edgeObjs[r];return s&&(t=s.v,e=s.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[e],t),i(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},n.prototype.inEdges=function(e,n){var r=this._in[e];if(r){var i=t.values(r);return n?t.filter(i,function(t){return t.v===n}):i}},n.prototype.outEdges=function(e,n){var r=this._out[e];if(r){var i=t.values(r);return n?t.filter(i,function(t){return t.w===n}):i}},n.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},bP}function yG(){return MP?CP:(MP=1,CP={Graph:mG(),version:xP?EP:(xP=1,EP="2.1.8")})}function wG(){if(kP)return FP;kP=1;var t=vG(),e=mG();function n(e){return t.map(e.nodes(),function(n){var r=e.node(n),i=e.parent(n),o={v:n};return t.isUndefined(r)||(o.value=r),t.isUndefined(i)||(o.parent=i),o})}function r(e){return t.map(e.edges(),function(n){var r=e.edge(n),i={v:n.v,w:n.w};return t.isUndefined(n.name)||(i.name=n.name),t.isUndefined(r)||(i.value=r),i})}return FP={write:function(e){var i={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:n(e),edges:r(e)};t.isUndefined(e.graph())||(i.value=t.clone(e.graph()));return i},read:function(n){var r=new e(n.options).setGraph(n.value);return t.each(n.nodes,function(t){r.setNode(t.v,t.value),t.parent&&r.setParent(t.v,t.parent)}),t.each(n.edges,function(t){r.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),r}},FP}function bG(){if(QP)return SP;QP=1;var t=vG();return SP=function(e){var n,r={},i=[];function o(i){t.has(r,i)||(r[i]=!0,n.push(i),t.each(e.successors(i),o),t.each(e.predecessors(i),o))}return t.each(e.nodes(),function(t){n=[],o(t),n.length&&i.push(n)}),i},SP}function BG(){if(NP)return UP;NP=1;var t=vG();function e(){this._arr=[],this._keyIndices={}}return UP=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(t){return t.key})},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,n){var r=this._keyIndices;if(e=String(e),!t.has(r,e)){var i=this._arr,o=i.length;return r[e]=o,i.push({key:e,priority:n}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)},e.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n>1].priority0&&(o=a.removeMin(),(A=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(c);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return TP}function xG(){if(LP)return IP;LP=1;var t=EG(),e=vG();return IP=function(n,r,i){return e.transform(n.nodes(),function(e,o){e[o]=t(n,o,r,i)},{})},IP}function CG(){if(DP)return PP;DP=1;var t=vG();return PP=function(e){var n=0,r=[],i={},o=[];function A(s){var a=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),e.successors(s).forEach(function(e){t.has(i,e)?i[e].onStack&&(a.lowlink=Math.min(a.lowlink,i[e].index)):(A(e),a.lowlink=Math.min(a.lowlink,i[e].lowlink))}),a.lowlink===a.index){var c,l=[];do{c=r.pop(),i[c].onStack=!1,l.push(c)}while(s!==c);o.push(l)}}return e.nodes().forEach(function(e){t.has(i,e)||A(e)}),o},PP}function MG(){if(HP)return RP;HP=1;var t=vG(),e=CG();return RP=function(n){return t.filter(e(n),function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])})},RP}function FG(){if(GP)return _P;GP=1;var t=vG();_P=function(t,n,r){return function(t,e,n){var r={},i=t.nodes();return i.forEach(function(t){r[t]={},r[t][t]={distance:0},i.forEach(function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})}),n(t).forEach(function(n){var i=n.v===t?n.w:n.v,o=e(n);r[t][i]={distance:o,predecessor:t}})}),i.forEach(function(t){var e=r[t];i.forEach(function(n){var o=r[n];i.forEach(function(n){var r=o[t],i=e[n],A=o[n],s=r.distance+i.distance;s0;){if(o=a.removeMin(),t.has(s,o))A.setEdge(o,s[o]);else{if(l)throw new Error("Input graph is not connected: "+r);l=!0}r.nodeEdges(o).forEach(c)}return A},JP}function OG(){if(iD)return rD;iD=1;var t=yG();return rD={Graph:t.Graph,json:wG(),alg:nD?eD:(nD=1,eD={components:bG(),dijkstra:EG(),dijkstraAll:xG(),findCycles:MG(),floydWarshall:FG(),isAcyclic:SG(),postorder:UG(),preorder:NG(),prim:TG(),tarjan:CG(),topsort:kG()}),version:t.version}}function IG(){if(AD)return oD;var t;AD=1;try{t=OG()}catch(t){}return t||(t=window.graphlib),oD=t}function LG(){if(aD)return sD;aD=1;var t=p_();return sD=function(e){return t(e,5)}}function PG(){if(lD)return cD;lD=1;var t=xU(),e=VN(),n=cN(),r=UU();return cD=function(i,o,A){if(!r(A))return!1;var s=typeof o;return!!("number"==s?e(A)&&n(o,A.length):"string"==s&&o in A)&&t(A[o],i)},cD}function DG(){if(hD)return uD;hD=1;var t=cG(),e=xU(),n=PG(),r=XN(),i=Object.prototype,o=i.hasOwnProperty,A=t(function(t,A){t=Object(t);var s=-1,a=A.length,c=a>2?A[2]:void 0;for(c&&n(A[0],A[1],c)&&(a=1);++s-1?s[a?i[c]:c]:void 0}},dD}(),e=t(_G());return FD=e}function KG(){if(QD)return SD;QD=1;var t=AG();return SD=function(e){return(null==e?0:e.length)?t(e,1):[]}}function jG(){if(ND)return UD;ND=1;var t=y_(),e=E_(),n=XN();return UD=function(r,i){return null==r?r:t(r,e(i),n)}}function zG(){if(OD)return TD;return OD=1,TD=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0},TD}function VG(){if(LD)return ID;LD=1;var t=jU(),e=w_(),n=X_();return ID=function(r,i){var o={};return i=n(i,3),e(r,function(e,n,r){t(o,n,i(e,n,r))}),o}}function WG(){if(DD)return PD;DD=1;var t=L_();return PD=function(e,n,r){for(var i=-1,o=e.length;++ie}),n=B_();return _D=function(r){return r&&r.length?t(r,n,e):void 0}}function XG(){if(jD)return KD;jD=1;var t=jU(),e=xU();return KD=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function qG(){if(YD)return WD;return YD=1,WD=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function $G(){if(ZD)return $D;ZD=1;var t=XG(),e=qH(),n=l_(),r=$H(),i=d_(),o=YU(),A=XU(),s=fG(),a=aN(),c=NU(),l=UU(),u=function(){if(VD)return zD;VD=1;var t=QU(),e=n_(),n=WU(),r=Function.prototype,i=Object.prototype,o=r.toString,A=i.hasOwnProperty,s=o.call(Object);return zD=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var a=A.call(i,"constructor")&&i.constructor;return"function"==typeof a&&a instanceof a&&o.call(a)==s}}(),h=_N(),d=qG(),f=function(){if(qD)return XD;qD=1;var t=VU(),e=XN();return XD=function(n){return t(n,e(n))}}();return $D=function(g,p,v,m,y,w,b){var B=d(g,v),E=d(p,v),x=b.get(E);if(x)t(g,v,x);else{var C=w?w(B,E,v+"",g,p,b):void 0,M=void 0===C;if(M){var F=A(E),k=!F&&a(E),S=!F&&!k&&h(E);C=E,F||k||S?A(B)?C=B:s(B)?C=r(B):k?(M=!1,C=e(E,!0)):S?(M=!1,C=n(E,!0)):C=[]:u(E)||o(E)?(C=B,o(B)?C=f(B):l(B)&&!c(B)||(C=i(E))):M=!1}M&&(b.set(E,C),y(C,E,m,w,b),b.delete(E)),t(g,v,C)}}}function ZG(){if(iR)return rR;iR=1;var t=function(){if(tR)return JD;tR=1;var t=_U(),e=XG(),n=y_(),r=$G(),i=UU(),o=XN(),A=qG();return JD=function s(a,c,l,u,h){a!==c&&n(c,function(n,o){if(h||(h=new t),i(n))r(a,c,o,l,s,u,h);else{var d=u?u(A(a,o),n,o+"",a,c,h):void 0;void 0===d&&(d=n),e(a,o,d)}},o)},JD}(),e=function(){if(nR)return eR;nR=1;var t=cG(),e=PG();return eR=function(n){return t(function(t,r){var i=-1,o=r.length,A=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(A=n.length>3&&"function"==typeof A?(o--,A):void 0,s&&e(r[0],r[1],s)&&(A=o<3?void 0:A,o=1),t=Object(t);++in||A&&s&&c&&!a&&!l||i&&s&&c||!r&&c||!o)return 1;if(!i&&!A&&!l&&e=a?c:c*("desc"==r[i]?-1:1)}return e.index-n.index},TR}function aK(){if(LR)return IR;LR=1;var t=R_(),e=K_(),n=X_(),r=tG(),i=(QR||(QR=1,SR=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),SR),o=uN(),A=sK(),s=B_(),a=XU();return IR=function(c,l,u){l=l.length?t(l,function(t){return a(t)?function(n){return e(n,1===t.length?t[0]:t)}:t}):[s];var h=-1;l=t(l,o(n));var d=r(c,function(e,n,r){return{criteria:t(l,function(t){return t(e)}),index:++h,value:e}});return i(d,function(t,e){return A(t,e,u)})},IR}function cK(){if(DR)return PR;DR=1;var t=AG(),e=aK(),n=cG(),r=PG(),i=n(function(n,i){if(null==n)return[];var o=i.length;return o>1&&r(n,i[0],i[1])?i=[]:o>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),e(n,t(i,1),[])});return PR=i}function lK(){if(HR)return RR;HR=1;var t=H_(),e=0;return RR=function(n){var r=++e;return t(n)+r},RR}function uK(){if(jR)return KR;jR=1;var t=zU(),e=(GR||(GR=1,_R=function(t,e,n){for(var r=-1,i=t.length,o=e.length,A={};++r0;--a)if(r=e[a].dequeue()){o=o.concat(i(t,e,n,r,!0));break}}return o}(a.graph,a.buckets,a.zeroIdx);return t.flatten(t.map(c,function(t){return A.outEdges(t.v,t.w)}),!0)};var r=t.constant(1);function i(e,n,r,i,A){var s=A?[]:void 0;return t.forEach(e.inEdges(i.v),function(t){var i=e.edge(t),a=e.node(t.v);A&&s.push({v:t.v,w:t.w}),a.out-=i,o(n,r,a)}),t.forEach(e.outEdges(i.v),function(t){var i=e.edge(t),A=t.w,s=e.node(A);s.in-=i,o(n,r,s)}),e.removeNode(i.v),s}function o(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}return XR}function fK(){if(ZR)return $R;ZR=1;var t=hK(),e=dK();return $R={run:function(n){var r="greedy"===n.graph().acyclicer?e(n,function(t){return function(e){return t.edge(e).weight}}(n)):function(e){var n=[],r={},i={};function o(A){t.has(i,A)||(i[A]=!0,r[A]=!0,t.forEach(e.outEdges(A),function(e){t.has(r,e.w)?n.push(e):o(e.w)}),delete r[A])}return t.forEach(e.nodes(),o),n}(n);t.forEach(r,function(e){var r=n.edge(e);n.removeEdge(e),r.forwardName=e.name,r.reversed=!0,n.setEdge(e.w,e.v,r,t.uniqueId("rev"))})},undo:function(e){t.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}},$R}function gK(){if(tH)return JR;tH=1;var t=hK(),e=IG().Graph;function n(e,n,r,i){var o;do{o=t.uniqueId(i)}while(e.hasNode(o));return r.dummy=n,e.setNode(o,r),o}function r(e){return t.max(t.map(e.nodes(),function(n){var r=e.node(n).rank;if(!t.isUndefined(r))return r}))}return JR={addDummyNode:n,simplify:function(n){var r=(new e).setGraph(n.graph());return t.forEach(n.nodes(),function(t){r.setNode(t,n.node(t))}),t.forEach(n.edges(),function(t){var e=r.edge(t.v,t.w)||{weight:0,minlen:1},i=n.edge(t);r.setEdge(t.v,t.w,{weight:e.weight+i.weight,minlen:Math.max(e.minlen,i.minlen)})}),r},asNonCompoundGraph:function(n){var r=new e({multigraph:n.isMultigraph()}).setGraph(n.graph());return t.forEach(n.nodes(),function(t){n.children(t).length||r.setNode(t,n.node(t))}),t.forEach(n.edges(),function(t){r.setEdge(t,n.edge(t))}),r},successorWeights:function(e){var n=t.map(e.nodes(),function(n){var r={};return t.forEach(e.outEdges(n),function(t){r[t.w]=(r[t.w]||0)+e.edge(t).weight}),r});return t.zipObject(e.nodes(),n)},predecessorWeights:function(e){var n=t.map(e.nodes(),function(n){var r={};return t.forEach(e.inEdges(n),function(t){r[t.v]=(r[t.v]||0)+e.edge(t).weight}),r});return t.zipObject(e.nodes(),n)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,A=e.x-i,s=e.y-o,a=t.width/2,c=t.height/2;if(!A&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*a>Math.abs(A)*c?(s<0&&(c=-c),n=c*A/s,r=c):(A<0&&(a=-a),n=a,r=a*s/A);return{x:i+n,y:o+r}},buildLayerMatrix:function(e){var n=t.map(t.range(r(e)+1),function(){return[]});return t.forEach(e.nodes(),function(r){var i=e.node(r),o=i.rank;t.isUndefined(o)||(n[o][i.order]=r)}),n},normalizeRanks:function(e){var n=t.min(t.map(e.nodes(),function(t){return e.node(t).rank}));t.forEach(e.nodes(),function(r){var i=e.node(r);t.has(i,"rank")&&(i.rank-=n)})},removeEmptyRanks:function(e){var n=t.min(t.map(e.nodes(),function(t){return e.node(t).rank})),r=[];t.forEach(e.nodes(),function(t){var i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});var i=0,o=e.graph().nodeRankFactor;t.forEach(r,function(n,r){t.isUndefined(n)&&r%o!==0?--i:i&&t.forEach(n,function(t){e.node(t).rank+=i})})},addBorderNode:function(t,e,r,i){var o={width:0,height:0};arguments.length>=4&&(o.rank=r,o.order=i);return n(t,"border",o,e)},maxRank:r,partition:function(e,n){var r={lhs:[],rhs:[]};return t.forEach(e,function(t){n(t)?r.lhs.push(t):r.rhs.push(t)}),r},time:function(e,n){var r=t.now();try{return n()}finally{console.log(e+" time: "+(t.now()-r)+"ms")}},notime:function(t,e){return e()}},JR}function pK(){if(nH)return eH;nH=1;var t=hK(),e=gK();return eH={run:function(n){n.graph().dummyChains=[],t.forEach(n.edges(),function(t){!function(t,n){var r,i,o,A=n.v,s=t.node(A).rank,a=n.w,c=t.node(a).rank,l=n.name,u=t.edge(n),h=u.labelRank;if(c===s+1)return;for(t.removeEdge(n),o=0,++s;sa.lim&&(c=a,l=!0);var u=t.filter(r.edges(),function(t){return l===g(e,e.node(t.v),c)&&l!==g(e,e.node(t.w),c)});return t.minBy(u,function(t){return n(r,t)})}function f(e,n,r,o){var A=r.v,s=r.w;e.removeEdge(A,s),e.setEdge(o.v,o.w,{}),l(e),a(e,n),function(e,n){var r=t.find(e.nodes(),function(t){return!n.node(t).parent}),o=i(e,r);o=o.slice(1),t.forEach(o,function(t){var r=e.node(t).parent,i=n.edge(t,r),o=!1;i||(i=n.edge(r,t),o=!0),n.node(t).rank=n.node(r).rank+(o?i.minlen:-i.minlen)})}(e,n)}function g(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}return sH=s,s.initLowLimValues=l,s.initCutValues=a,s.calcCutValue=c,s.leaveEdge=h,s.enterEdge=d,s.exchangeEdges=f,sH}function wK(){if(lH)return cH;lH=1;var t=vK().longestPath,e=mK(),n=yK();cH=function(n){switch(n.graph().ranker){case"network-simplex":default:i(n);break;case"tight-tree":!function(n){t(n),e(n)}(n);break;case"longest-path":r(n)}};var r=t;function i(t){n(t)}return cH}function bK(){if(hH)return uH;hH=1;var t=hK();return uH=function(e){var n=function(e){var n={},r=0;function i(o){var A=r;t.forEach(e.children(o),i),n[o]={low:A,lim:r++}}return t.forEach(e.children(),i),n}(e);t.forEach(e.graph().dummyChains,function(t){for(var r=e.node(t),i=r.edgeObj,o=function(t,e,n,r){var i,o,A=[],s=[],a=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),A.push(i)}while(i&&(e[i].low>a||c>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:A.concat(s.reverse()),lca:o}}(e,n,i.v,i.w),A=o.path,s=o.lca,a=0,c=A[a],l=!0;t!==i.w;){if(r=e.node(t),l){for(;(c=A[a])!==s&&e.node(c).maxRank=e.barycenter)&&function(t,e){var n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(e,n)}}function i(t){return function(n){n.in.push(t),0===--n.indegree&&e.push(n)}}for(;e.length;){var o=e.pop();n.push(o),t.forEach(o.in.reverse(),r(o)),t.forEach(o.out,i(o))}return t.map(t.filter(n,function(t){return!t.merged}),function(e){return t.pick(e,["vs","i","barycenter","weight"])})}(t.filter(r,function(t){return!t.indegree}))},CH}function CK(){if(QH)return SH;QH=1;var t=hK(),e=function(){if(xH)return EH;xH=1;var t=hK();return EH=function(e,n){return t.map(n,function(n){var r=e.inEdges(n);if(r.length){var i=t.reduce(r,function(t,n){var r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}return{v:n}})},EH}(),n=xK(),r=function(){if(kH)return FH;kH=1;var t=hK(),e=gK();function n(e,n,r){for(var i;n.length&&(i=t.last(n)).i<=r;)n.pop(),e.push(i.vs),r++;return r}return FH=function(r,i){var o,A=e.partition(r,function(e){return t.has(e,"barycenter")}),s=A.lhs,a=t.sortBy(A.rhs,function(t){return-t.i}),c=[],l=0,u=0,h=0;s.sort((o=!!i,function(t,e){return t.barycentere.barycenter?1:o?e.i-t.i:t.i-e.i})),h=n(c,a,h),t.forEach(s,function(t){h+=t.vs.length,c.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,h=n(c,a,h)});var d={vs:t.flatten(c,!0)};return u&&(d.barycenter=l/u,d.weight=u),d}}();return SH=function i(o,A,s,a){var c=o.children(A),l=o.node(A),u=l?l.borderLeft:void 0,h=l?l.borderRight:void 0,d={};u&&(c=t.filter(c,function(t){return t!==u&&t!==h}));var f=e(o,c);t.forEach(f,function(e){if(o.children(e.v).length){var n=i(o,e.v,s,a);d[e.v]=n,t.has(n,"barycenter")&&(r=e,A=n,t.isUndefined(r.barycenter)?(r.barycenter=A.barycenter,r.weight=A.weight):(r.barycenter=(r.barycenter*r.weight+A.barycenter*A.weight)/(r.weight+A.weight),r.weight+=A.weight))}var r,A});var g=n(f,s);!function(e,n){t.forEach(e,function(e){e.vs=t.flatten(e.vs.map(function(t){return n[t]?n[t].vs:t}),!0)})}(g,d);var p=r(g,a);if(u&&(p.vs=t.flatten([u,p.vs,h],!0),o.predecessors(u).length)){var v=o.node(o.predecessors(u)[0]),m=o.node(o.predecessors(h)[0]);t.has(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+v.order+m.order)/(p.weight+2),p.weight+=2}return p},SH}function MK(){if(NH)return UH;NH=1;var t=hK(),e=IG().Graph;return UH=function(n,r,i){var o=function(e){var n;for(;e.hasNode(n=t.uniqueId("_root")););return n}(n),A=new e({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(t){return n.node(t)});return t.forEach(n.nodes(),function(e){var s=n.node(e),a=n.parent(e);(s.rank===r||s.minRank<=r&&r<=s.maxRank)&&(A.setNode(e),A.setParent(e,a||o),t.forEach(n[i](e),function(r){var i=r.v===e?r.w:r.v,o=A.edge(i,e),s=t.isUndefined(o)?0:o.weight;A.setEdge(i,e,{weight:n.edge(r).weight+s})}),t.has(s,"minRank")&&A.setNode(e,{borderLeft:s.borderLeft[r],borderRight:s.borderRight[r]}))}),A},UH}function FK(){if(LH)return IH;LH=1;var t=hK(),e=function(){if(wH)return yH;wH=1;var t=hK();return yH=function(e){var n={},r=t.filter(e.nodes(),function(t){return!e.children(t).length}),i=t.max(t.map(r,function(t){return e.node(t).rank})),o=t.map(t.range(i+1),function(){return[]});function A(r){if(!t.has(n,r)){n[r]=!0;var i=e.node(r);o[i.rank].push(r),t.forEach(e.successors(r),A)}}var s=t.sortBy(r,function(t){return e.node(t).rank});return t.forEach(s,A),o},yH}(),n=function(){if(BH)return bH;BH=1;var t=hK();function e(e,n,r){for(var i=t.zipObject(r,t.map(r,function(t,e){return e})),o=t.flatten(t.map(n,function(n){return t.sortBy(t.map(e.outEdges(n),function(t){return{pos:i[t.w],weight:e.edge(t).weight}}),"pos")}),!0),A=1;A0;)e%2&&(n+=a[e+1]),a[e=e-1>>1]+=t.weight;c+=t.weight*n})),c}return bH=function(t,n){for(var r=0,i=1;i=2),u=s.buildLayerMatrix(r);var p=n(r,u);pa)&&o(r,t,c)})})}return t.reduce(n,function(n,r){var o,A=-1,s=0;return t.forEach(r,function(t,a){if("border"===e.node(t).dummy){var c=e.predecessors(t);c.length&&(o=e.node(c[0]).order,i(r,s,a,A,o),s=a,A=o)}i(r,s,r.length,o,n.length)}),r}),r}function o(t,e,n){if(e>n){var r=e;e=n,n=r}var i=t[e];i||(t[e]=i={}),i[n]=!0}function A(e,n,r){if(n>r){var i=n;n=r,r=i}return t.has(e[n],r)}function s(e,n,r,i){var o={},s={},a={};return t.forEach(n,function(e){t.forEach(e,function(t,e){o[t]=t,s[t]=t,a[t]=e})}),t.forEach(n,function(e){var n=-1;t.forEach(e,function(e){var c=i(e);if(c.length){c=t.sortBy(c,function(t){return a[t]});for(var l=(c.length-1)/2,u=Math.floor(l),h=Math.ceil(l);u<=h;++u){var d=c[u];s[e]===e&&n({}));const e=Yx(this.options.nodeSize,0);this.model.forEachNode(n=>{const r=n._original,[i,o]=Gx(e(r)),A={width:i,height:o};if(t.setNode(String(n.id),A),this.isCompound()){if(Kx(n.parentId))return;t.setParent(String(n.id),String(n.parentId))}});const{edgeLabelSize:n,edgeLabelOffset:r,edgeLabelPos:i,edgeMinLen:o,edgeWeight:A}=this.options,s=Yx(n,0,"edge"),a=Wx(r,10,"edge"),c="string"==typeof i?()=>i:Vx(i,["edge"]),l=Wx(o,1,"edge"),u=Wx(A,1,"edge");this.model.forEachEdge(e=>{const n=e._original,[r,i]=Gx(s(n)),o={width:r,height:i,labelpos:c(n),labeloffset:a(n),minlen:l(n),weight:u(n)};t.setEdge(String(e.source),String(e.target),o,String(e.id))}),TK.layout(t),this.model.forEachNode(e=>{const n=t.node(String(e.id));n&&(e.x=n.x,e.y=n.y,e.size=[n.width,n.height])}),this.model.forEachEdge(e=>{const n=t.edge(String(e.source),String(e.target),String(e.id));if(!n)return;const{width:r,height:i,weight:o,minlen:A,labelpos:s,labeloffset:a,points:c}=n;e.labelSize=[r,i],e.weight=o,e.minLen=A,e.labelPos=s,e.labelOffset=a,e.points=c.map(qx)})})}isCompound(){return null!==this.isCompoundGraph?this.isCompoundGraph:(t=this.options.compound,Sk(t,"Boolean")?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(t=>!Kx(t.parentId)),this.isCompoundGraph));var t}}const PK=1e-6;function DK(t){var e;let n=0;if(t.length)for(let e=0;en&&(n=r.r)}else if(t.data){n=t.data.r||0;let r=t.next;for(;r;)n=Math.max(n,(null===(e=r.data)||void 0===e?void 0:e.r)||0),r=r.next}t.r=n}function RK(t=1,e=.005,n=2){function r(r,i){!function(t,e,n,r,i=2){const o=e/n,A=t.nodes(),s=A.map((t,e)=>{const{nodeStrength:n,x:r,y:i,z:A,size:s,mass:a}=t;return{x:r,y:i,z:A,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n,mass:a||1}}),a=(2===i?gk(s,t=>t.x,t=>t.y):eS(s,t=>t.x,t=>t.y,t=>t.z)).visitAfter(HK),c=new Map;s.forEach(t=>{c.set(t.id,t),function(t,e,n){e.visit((e,r,i,o,A,s,a)=>_K(e,r,i,o,A,s,a,t,n))}(t,a,i)}),s.map(t=>{const e=t.id;r[e]={x:t.vx/t.mass,y:t.vy/t.mass,z:t.vz/t.mass}})}(r,t,e*e,i,n)}return r.factor=function(e){return arguments.length?(t=e,r):t},r.coulombDisScale=function(t){return arguments.length?(e=t,r):e},r.dimensions=function(t){return arguments.length?(n=t,r):n},r}function HK(t){let e=0,n=0,r=0,i=0,o=0;const A=t.length;if(A){for(let s=0;s{var c;if((null===(c=t.data)||void 0===c?void 0:c.id)===s.id)return;const l=2===a?r:3===a?o:n,u=s.x-t.x||.1,h=s.y-t.y||.1,d=s.z-t.z||.1,f=[u,h,d],g=l-e;let p=0;for(let t=0;te||this.iteration<1);)this.tick(1);return Promise.resolve().then(()=>{var t;null===(t=this.endCallback)||void 0===t||t.call(this)}),this}return this.running=!0,this.timer=window.setInterval(()=>{var n;this.tick(1),(this.iteration>=t||this.judgingDistance{this.velMap[t.id]={x:0,y:0,z:0}}),this}force(t,e){return 1===arguments.length?this.forces.get(t)||null:(null===e?this.forces.delete(t):e&&this.forces.set(t,e),e||null)}runOneStep(){const t={},e=this.model.nodes();if(!e.length)return 0;e.forEach(e=>{t[e.id]={x:0,y:0,z:0}}),this.forces.forEach(e=>{e(this.model,t)}),this.updateVelocity(t);const n=this.updatePosition();return this.monitor(t,e),n}setFixedPosition(t,e){const n=this.model.node(t);if(!n)return;const r=["fx","fy","fz"];if(null===e)return void r.forEach(t=>delete n[t]);e.forEach((t,e)=>{e{const A=o.id;let s=(this.velMap[A].x+t[A].x*r)*e,a=(this.velMap[A].y+t[A].y*r)*e,c=3===i?(this.velMap[A].z+t[A].z*r)*e:0;const l=Math.sqrt(s*s+a*a+c*c);if(l>n){const t=n/l;s*=t,a*=t,c*=t}this.velMap[A]={x:s,y:a,z:c}})}updatePosition(){const{distanceThresholdMode:t="mean",interval:e=.02,dimensions:n=2}=this.options,r=this.model.nodes();let i=0,o="max"===t?-1/0:"min"===t?1/0:0;return r.forEach(r=>{const A=r.id;if(_x(r.fx)&&_x(r.fy))return r.x=r.fx,r.y=r.fy,void(3===n&&_x(r.fz)&&(r.z=r.fz));const s=this.velMap[A].x*e,a=this.velMap[A].y*e,c=3===n?this.velMap[A].z*e:0;r.x+=s,r.y+=a,3===n&&(r.z=(r.z||0)+c);const l=Math.sqrt(s*s+a*a+c*c);"max"===t?o=Math.max(o,l):"min"===t?o=Math.min(o,l):i+=l}),"mean"===t?i/r.length:o}monitor(t,e){const{monitor:n,dimensions:r=2}=this.options;if(!n)return;let i=0;e.forEach(e=>{const n=t[e.id],o=n.x*n.x+n.y*n.y+(3===r?n.z*n.z:0);i+=(e.mass||1)*o*.5}),n({energy:i,nodes:e,edges:this.model.edges(),iterations:this.iteration})}}var zK={}.toString,VK=Object.prototype,WK=Object.prototype.hasOwnProperty;function YK(t){if(Kx(t))return!0;if(function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)}(t))return!t.length;var e=function(t){return zK.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||VK)}(t))return!Object.keys(t).length;for(var n in t)if(WK.call(t,n))return!1;return!0}const XK={nodeSize:30,dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,collideStrength:1,preventOverlap:!0,distanceThresholdMode:"mean"};class qK extends xC{constructor(){super(...arguments),this.id="force",this.simulation=null}getDefaultOptions(){return XK}layout(){var t;return mx(this,0,void 0,function*(){const e=this.parseOptions(this.options),{width:n,height:r,dimensions:i}=e;if(this.initializePhysicsData(this.model,e),tC(this.model,n,r,i),!(null===(t=this.model.nodes())||void 0===t?void 0:t.length))return;const o=this.setSimulation(e);return o.data(this.model),o.initialize(e),o.restart(),new Promise(t=>{o.on("end",()=>t())})})}initializePhysicsData(t,e){const{nodeSize:n,getMass:r,nodeStrength:i,edgeStrength:o,linkDistance:A}=e;t.forEachNode(t=>{const e=t._original;t.size=n(e),t.mass=r(e),t.nodeStrength=i(e)}),t.forEachEdge(e=>{const n=e._original;e.edgeStrength=o(n),e.linkDistance=A(n,t.originalNode(e.source),t.originalNode(e.target))})}setSimulation(t){const e=this.simulation||new jK;return this.simulation||(this.simulation=e.on("tick",()=>{var e;null===(e=t.onTick)||void 0===e||e.call(t,this)})),this.setupRepulsiveForce(e,t),this.setupAttractiveForce(e,t),this.setupCollideForce(e,t),this.setupGravityForce(e,t),this.setupCentripetalForce(e,t),e}setupRepulsiveForce(t,e){const{factor:n,coulombDisScale:r,dimensions:i}=e;let o=t.force("repulsive");o||(o=RK(n,r,i),t.force("repulsive",o)),o.factor&&o.factor(n),o.coulombDisScale&&o.coulombDisScale(r),o.dimensions&&o.dimensions(i)}setupAttractiveForce(t,e){const{dimensions:n,preventOverlap:r}=e;if((this.model.edges()||[]).length>0){let e=t.force("attractive");e||(e=function(t=2){let e=!1;function n(e,n){e.forEachEdge(r=>{var i,o;const{source:A,target:s}=r,a=e.node(A),c=e.node(s);if(!a||!c)return;let l=c.x-a.x,u=c.y-a.y,h=3===t?(null!==(i=c.z)&&void 0!==i?i:0)-(null!==(o=a.z)&&void 0!==o?o:0):0;l||u||(l=.01,u=.01,3!==t||h||(h=.01));const d=Math.sqrt(l*l+u*u+h*h);if(d{const{id:A,mass:s,x:a,y:c,z:l=0}=o;let u=0,h=0,d=0,f=e;const g=r.degree(A),p=null==n?void 0:n(o,g);if(p){const[t,e,n]=p;u=a-t,h=c-e,f=n}else u=a-t[0],h=c-t[1],d=l-(t[2]||0);f&&(i[A].x-=f*u/s,i[A].y-=f*h/s,i[A].z-=f*d/s)})}return r.center=function(e){return arguments.length?(t=e,r):t},r.gravity=function(t){return arguments.length?(e=t,r):e},r.getCenter=function(t){return arguments.length?(n=t,r):n},r}(n,r),t.force("gravity",e)),e.center&&e.center(n),e.gravity&&e.gravity(r),e.getCenter&&e.getCenter(i)}else t.force("gravity",null)}setupCollideForce(t,e){const{preventOverlap:n,collideStrength:r=1,dimensions:i}=e;if(n&&r){let e=t.force("collide");e||(e=function(t=2){let e=1;function n(n,r){const i=n.nodes();if(i.length<2||e<=0)return;if(2===t){const t=i.map((t,e)=>({id:t.id,index:e,x:t.x,y:t.y,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy})),e=gk(t,t=>t.x,t=>t.y).visitAfter(DK);for(const n of t)e.visit((t,e,i,A,s)=>{const a=t.r||0,c=n.r+a;if(e>n.x+c||An.y+c||sn.index&&o(n,t,r),l=l.next}while(l);return!1});return}const s=i.map((t,e)=>{var n;return{id:t.id,index:e,x:t.x,y:t.y,z:null!==(n=t.z)&&void 0!==n?n:0,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy,fz:t.fz}});for(let t=0;t=a)return;s=c)return;aObject.assign(Object.assign({},t),{data:t.data||{}})),h=l.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}}));r.forEachNode(t=>{const{id:c,mass:l,x:d,y:f,z:g=0,data:p}=t,v=r.degree(c,"in"),m=r.degree(c,"out"),y=r.degree(c,"both"),w=Object.assign(Object.assign({},t),{data:p||{}}),{x:b,y:B,z:E,centerStrength:x}=(null==a?void 0:a(w,u,h,e,n))||{x:0,y:0,z:0,centerStrength:0};if(!_x(b)||!_x(B))return;const C=(d-b)/l,M=(f-B)/l,F=(g-(E||0))/l;if(x&&(i[c].x-=x*C,i[c].y-=x*M,i[c].z-=x*F),0===y){const t=A(w);if(!t)return;return i[c].x-=t*C,i[c].y-=t*M,void(i[c].z-=t*F)}if(0===v||0===m){const t=o(w,u,h);if(!t)return;return i[c].x-=t*C,i[c].y-=t*M,void(i[c].z-=t*F)}const k=s(w);k&&(i[c].x-=k*C,i[c].y-=k*M,i[c].z-=k*F)})}return r.options=function(e){return arguments.length?(t=e,r):t},r.width=function(t){return arguments.length?(e=t,r):e},r.height=function(t){return arguments.length?(n=t,r):n},r}(),t.force("centripetal",e)),e.options&&e.options(n),e.width&&e.width(r),e.height&&e.height(i)}else t.force("centripetal",null)}parseOptions(t){const e=Object.assign(Object.assign({},t),kF(t));if(e.nodeClusterBy&&(e.nodeClusterBy=Vx(e.nodeClusterBy,["node"])),t.getMass?e.getMass=Wx(t.getMass,1):e.getMass=t=>{if(!t)return 1;const e=this.model.degree(t.id,"both");return!e||e<5?1:5*e*1},t.getCenter){const n=["node","degree"];e.getCenter=Vx(t.getCenter,n)}const n=Xx(t.nodeSize,t.nodeSpacing);return e.nodeSize=t=>{if(!t)return 0;const[e,r,i]=n(t);return Math.max(e,r,i)},e.linkDistance=t.linkDistance?Vx(t.linkDistance,["edge","source","target"]):(t,e,n)=>1+t.nodeSize(e)+t.nodeSize(n),e.nodeStrength=Wx(t.nodeStrength,1),e.edgeStrength=Wx(t.edgeStrength,1,"edge"),e.clusterNodeStrength=Wx(t.clusterNodeStrength,1),this.formatCentripetal(e),e}formatCentripetal(t){var e,n;const{dimensions:r,centripetalOptions:i,center:o,leafCluster:A,clustering:s,nodeClusterBy:a}=t,c=Vx(null==i?void 0:i.leaf,["node","nodes","edges"]),l=Wx(null==i?void 0:i.single,2),u=Wx(null==i?void 0:i.others,1),h=Vx(null!==(e=null==i?void 0:i.center)&&void 0!==e?e:t=>({x:o[0],y:o[1],z:3===r?o[2]:void 0}),["node","nodes","edges","width","height"]),d=Object.assign(Object.assign({},i),{leaf:c,single:l,others:u,center:h});let f,g;if(i&&(t.centripetalOptions=d),A&&a&&(f=this.getSameTypeLeafMap(a),g=Array.from(new Set(null===(n=this.model.nodes())||void 0===n?void 0:n.map(t=>a(t._original))))||[],t.centripetalOptions=Object.assign({},d,{single:()=>100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=f[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==g?void 0:g.length)?1:t.clusterNodeStrength(e)},others:()=>1,center:t=>{const e=this.model.degree(t.id,"both");if(!e)return{x:100,y:100,z:0};let n;if(1===e){const{sameTypeLeaves:e=[]}=f[t.id]||{};1===e.length?n=void 0:e.length>1&&(n=this.getAvgNodePosition(e))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y,z:null==n?void 0:n.z}}})),s&&a){f||(f=this.getSameTypeLeafMap(a));let e=[];YK(e)&&this.model.forEachNode(t=>{const n=a(t._original);n&&!e.includes(n)&&e.push(n)});const n={};e.forEach(t=>{const e=this.model.nodes().filter(e=>a(e._original)===t);n[t]=this.getAvgNodePosition(e)}),t.centripetalOptions=Object.assign(d,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[a(t._original)];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}}getSameTypeLeafMap(t){const e={};return this.model.forEachNode(n=>{1===this.model.degree(n.id,"both")&&(e[n.id]=this.getCoreNodeAndSiblingLeaves(n,t))}),e}getCoreNodeAndSiblingLeaves(t,e){const n=this.model.degree(t.id,"in"),r=this.model.degree(t.id,"out");let i=t,o=[];if(0===n){const e=this.model.successors(t.id);i=this.model.node(e[0]),o=this.model.neighbors(i.id).map(t=>this.model.node(t))}else if(0===r){const e=this.model.predecessors(t.id);i=this.model.node(e[0]),o=this.model.neighbors(i.id).map(t=>this.model.node(t))}o=o.filter(t=>0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out"));const A=e(t._original)||"",s=o.filter(t=>e(t._original)===A&&(0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out")));return{coreNode:i,siblingLeaves:o,sameTypeLeaves:s}}getAvgNodePosition(t){const e={x:0,y:0};t.forEach(t=>{e.x+=t.x||0,e.y+=t.y||0});const n=t.length||1;return{x:e.x/n,y:e.y/n}}tick(t=1){return this.simulation&&this.simulation.tick(t),this}stop(){return this.simulation&&this.simulation.stop(),this}restart(){return this.simulation&&this.simulation.restart(),this}setFixedPosition(t,e){return this.simulation&&this.simulation.setFixedPosition(t,e),this}}class $K{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,n=t.ry-this.ry;let r=Math.hypot(e,n);r=r<1e-4?1e-4:r;const i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/e,r=(this.ry*this.mass+t.ry*t.mass)/e,i=this.degree+t.degree;return new $K({rx:n,ry:r,mass:e,degree:i})}}class ZK{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new ZK({xmid:t,ymid:e,length:n})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new ZK({xmid:t,ymid:e,length:n})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new ZK({xmid:t,ymid:e,length:n})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new ZK({xmid:t,ymid:e,length:n})}}class JK{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new JK(this.quad.NW()),this.NE=new JK(this.quad.NE()),this.SW=new JK(this.quad.SW()),this.SE=new JK(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t){e{delete n[t]})}isNodeFixed(t){return _x(t.fx)&&_x(t.fy)}syncFixedPositions(){this.model.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy)})}runOneStep(){const{model:t,options:e}=this,{preventOverlap:n,barnesHut:r}=e,i=this.maxIteration-this.iteration,o=t.nodes();for(let t=0;tc&&(c=o),su&&(u=s))}let h=Math.max(c-a,u-l);(!isFinite(h)||h<=0)&&(h=1);const d=new ZK({xmid:(c+a)/2,ymid:(u+l)/2,length:h,massCenter:r,mass:s}),f=new JK(d);for(let e=0;e0?f:1:(d=r*h/u,0!==f&&(d=d>1.5*f?1.5*f:d)),this.sg=d;let g=0,p=1/0,v=0,m=0;for(let e=0;ef&&(u=f);const y=u*this.forces[A][0],w=u*this.forces[A][1];r.x+=y,r.y+=w;const b=Math.hypot(y,w);b>0&&(m++,v+=b,b>g&&(g=b),b0?v/m:0;default:return g}}destroy(){this.stop(),this.forces={},this.preForces={},this.bodies={},this.sizes={},this.off()}};const ej={nodeSize:10,nodeSpacing:0,width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class nj extends xC{constructor(){super(...arguments),this.id="force-atlas2",this.simulation=null}getDefaultOptions(){return ej}layout(t){return mx(this,0,void 0,function*(){const e=this.parseOptions(t),{width:n,height:r,prune:i,center:o}=e,A=this.model.nodeCount();if(!A||1===A)return EF(this.model,o);tC(this.model,n,r);const s=this.getSizes(e.nodeSize,e.nodeSpacing),a=this.setSimulation();a.data(this.model,s),a.initialize(e),a.restart();const c=()=>new Promise(t=>{a.on("end",t)});if(!i)return c();if(yield c(),i){const t=this.model.edges();for(let e=0;e{n[t.id]=Math.max(...r(t._original))}),n}setSimulation(){const t=this.simulation||new tj;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}parseOptions(t={}){const{barnesHut:e,prune:n,maxIteration:r,kr:i,kg:o}=t,A={},s=this.model.nodeCount();return void 0===e&&s>250&&(A.barnesHut=!0),void 0===n&&s>100&&(A.prune=!0),0!==r||n?0===r&&n&&(A.maxIteration=100,s<=200&&s>100?A.maxIteration=500:s>200&&(A.maxIteration=950)):(A.maxIteration=250,s<=200&&s>100?A.maxIteration=1e3:s>200&&(A.maxIteration=1200)),i||(A.kr=50,s>100&&s<=500?A.kr=20:s>500&&(A.kr=1)),o||(A.kg=20,s>100&&s<=500?A.kg=10:s>500&&(A.kg=1)),Object.assign(Object.assign(Object.assign({},t),A),kF(t))}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}setFixedPosition(t,e){var n;null===(n=this.simulation)||void 0===n||n.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}}class rj extends KK{constructor(){super(...arguments),this.displacements=null,this.clusterMap=null}data(t){return this.model=t,this}initialize(t){super.initialize(t),this.recomputeConstants(),this.displacements=null,this.clusterMap=null,this.initDisplacements()}recomputeConstants(){const{model:t,options:e}=this,{width:n,height:r}=kF(e),i=n*r;this.k2=i/(t.nodeCount()+1),this.k=Math.sqrt(this.k2),this.maxDisplace=Math.sqrt(i)/10}runOneStep(){return this.syncFixedPositions(),this.initDisplacements(),this.calculateRepulsive(),this.calculateAttractive(),this.applyClusterGravity(),this.applyGlobalGravity(),this.updatePositions()}setFixedPosition(t,e){const n=this.model.node(t);if(!n)return;const r=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e{delete n[t]})}isNodeFixed(t){return!Kx(t.fx)&&!Kx(t.fy)}syncFixedPositions(){const{model:t,options:e}=this,n=3===e.dimensions;t.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy,n&&void 0!==t.fz&&(t.z=t.fz))})}initDisplacements(){this.displacements||(this.displacements=new Map,this.model.forEachNode(t=>{this.displacements.set(t.id,{x:0,y:0,z:0})})),this.displacements.forEach(t=>{t.x=0,t.y=0,t.z=0})}calculateRepulsive(){const{model:t,options:e}=this,n=3===e.dimensions,r=t.nodes();for(let t=0;t{const{source:r,target:i}=e;if(!r||!i||r===i)return;const o=t.node(r),A=t.node(i),s=this.displacements.get(r),a=this.displacements.get(i),c=this.isNodeFixed(o),l=this.isNodeFixed(A),u=A.x-o.x,h=A.y-o.y,d=n?A.z-o.z:0,f=Math.sqrt(u*u+h*h+d*d);if(0===f)return;const g=f/this.k,p=u*g,v=h*g,m=d*g;c||l?c&&!l?(a.x-=2*p,a.y-=2*v,n&&(a.z-=2*m)):!c&&l&&(s.x+=2*p,s.y+=2*v,n&&(s.z+=2*m)):(s.x+=p,s.y+=v,a.x-=p,a.y-=v,n&&(s.z+=m,a.z-=m))})}applyClusterGravity(){const{model:t,options:e}=this,{nodeClusterBy:n,clusterGravity:r,dimensions:i,clustering:o}=e;if(!o)return;if(this.clusterMap||(this.clusterMap=new Map,t.forEachNode(e=>{const r=n(t.originalNode(e.id));this.clusterMap.has(r)||this.clusterMap.set(r,{name:r,cx:0,cy:0,cz:0,count:0})})),0===this.clusterMap.size)return;const A=3===i;this.clusterMap.forEach(t=>{t.cx=0,t.cy=0,t.cz=0,t.count=0}),t.forEachNode(e=>{const r=n(t.originalNode(e.id)),i=this.clusterMap.get(r);i&&(i.cx+=e.x,i.cy+=e.y,A&&(i.cz+=e.z),i.count++)}),this.clusterMap.forEach(t=>{t.count>0&&(t.cx/=t.count,t.cy/=t.count,t.cz/=t.count)}),t.forEachNode(e=>{const{id:i}=e;if(this.isNodeFixed(e))return;const o=n(t.originalNode(i)),s=this.clusterMap.get(o);if(!s)return;const a=this.displacements.get(i),c=e.x-s.cx,l=e.y-s.cy,u=A?e.z-s.cz:0,h=Math.sqrt(c*c+l*l+u*u);if(0===h)return;const d=this.k*r;a.x-=d*c/h,a.y-=d*l/h,A&&(a.z-=d*u/h)})}applyGlobalGravity(){const{model:t,options:e}=this,{gravity:n,center:r,dimensions:i}=e,o=3===i,A=.01*this.k*n;t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const n=this.displacements.get(e);n.x-=A*(t.x-r[0]),n.y-=A*(t.y-r[1]),o&&(n.z-=A*(t.z-(r[2]||0)))})}updatePositions(){const{model:t,options:e}=this,{speed:n,dimensions:r,distanceThresholdMode:i="max"}=e,o=3===r;let A=0,s=1/0,a=0,c=0;if(t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const r=this.displacements.get(e),i=Math.sqrt(r.x*r.x+r.y*r.y+(o?r.z*r.z:0));if(0===i)return;const l=Math.min(this.maxDisplace*(n/800),i),u=l/i;t.x+=r.x*u,t.y+=r.y*u,o&&(t.z=t.z+r.z*u),A=Math.max(A,l),s=Math.min(s,l),a+=l,c++}),0===c)return 0;switch(i){case"min":return s===1/0?0:s;case"mean":return a/c;default:return A}}destroy(){var t,e;this.stop(),null===(t=this.displacements)||void 0===t||t.clear(),null===(e=this.clusterMap)||void 0===e||e.clear()}}const ij={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"node.cluster",dimensions:2};class oj extends xC{constructor(){super(...arguments),this.id="fruchterman",this.simulation=null}getDefaultOptions(){return ij}parseOptions(t={}){const{clustering:e,nodeClusterBy:n}=this.options,r=e&&!!n;return Object.assign(t,kF(t),{clustering:r,nodeClusterBy:Vx(n,["node"])}),t}layout(){return mx(this,0,void 0,function*(){const t=this.parseOptions(this.options),{dimensions:e,center:n,width:r,height:i}=t,o=this.model.nodeCount();if(!o||1===o)return void EF(this.model,n,e);tC(this.model,r,i,e);const A=this.setSimulation();return A.data(this.model),A.initialize(t),A.restart(),new Promise(t=>{A.on("end",()=>t())})})}setSimulation(){const t=this.simulation||new rj;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}setFixedPosition(t,e){var n;null===(n=this.simulation)||void 0===n||n.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}}const Aj={begin:[0,0],preventOverlap:!0,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,nodeSpacing:10,width:300,height:300};class sj extends EC{constructor(){super(...arguments),this.id="grid"}getDefaultOptions(){return Aj}parseOptions(t={},e){const{rows:n,cols:r,position:i,sortBy:o}=t,{width:A,height:s,center:a}=kF(t);let c=t.rows,l=t.cols;const u=e.nodeCount();if(null!=n&&null!=r)c=n,l=r;else if(null!=n&&null==r)c=n,l=Math.ceil(u/c);else if(null==n&&null!=r)l=r,c=Math.ceil(u/l);else{const t=Math.sqrt(u*s/A);c=Math.round(t),l=Math.round(A/s*t)}c=Math.max(c,1),l=Math.max(l,1);const h={rows:c,cols:l};if(h.cols*h.rows>u){const t=aj(h),e=cj(h);(t-1)*e>=u?aj(h,t-1):(e-1)*t>=u&&cj(h,e-1)}else for(;h.cols*h.rows=u?cj(h,e+1):aj(h,t+1)}const d=o?"degree"===o||"id"===o?o:Vx(o,["nodeA","nodeB"]):Aj.sortBy;return Object.assign(Object.assign({},t),{sortBy:d,rcs:h,center:a,width:A,height:s,position:Vx(i,["node"])})}layout(){return mx(this,0,void 0,function*(){const{begin:t,rcs:e,sortBy:n,width:r,height:i,condense:o,preventOverlap:A,nodeSpacing:s,nodeSize:a,position:c}=this.parseOptions(this.options,this.model),l=this.model.nodeCount();if(!l||1===l)return void EF(this.model,t);"degree"===n?CF(this.model):"id"===n?xF(this.model,(t,e)=>{const n=t.id,r=e.id;return"number"==typeof n&&"number"==typeof r?n-r:String(n).localeCompare(String(r))}):MF(this.model,n);let u=o?0:r/e.cols,h=o?0:i/e.rows;if(A){const t=Xx(a,s,Aj.nodeSize,Aj.nodeSpacing);this.model.forEachNode(e=>{const[n,r]=t(e._original);u=Math.max(u,n),h=Math.max(h,r)})}const d={},f={row:0,col:0},g={};this.model.forEachNode(n=>{const r=n._original;let i;if(c&&(i=c(r)),i&&(void 0!==i.row||void 0!==i.col)){const t={row:i.row,col:i.col};if(void 0===t.col)for(t.col=0;lj(d,t);)t.col++;else if(void 0===t.row)for(t.row=0;lj(d,t);)t.row++;g[n.id]=t,uj(d,t)}dj(n,t,u,h,g,e,f,d)})})}}const aj=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.min(r,i);else{Math.min(r,i)===t.rows?t.rows=e:t.cols=e}return n},cj=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.max(r,i);else{Math.max(r,i)===t.rows?t.rows=e:t.cols=e}return n},lj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,uj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,hj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},dj=(t,e,n,r,i,o,A,s)=>{let a,c;const l=i[t.id];if(l)a=l.col*n+n/2+e[0],c=l.row*r+r/2+e[1];else{for(;lj(s,A);)hj(o,A);a=A.col*n+n/2+e[0],c=A.row*r+r/2+e[1],uj(s,A),hj(o,A)}t.x=a,t.y=c};var fj={};const gj=Object.prototype.toString;function pj(t){const e=gj.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var vj=EU(Object.freeze({__proto__:null,isAnyArray:pj}));var mj,yj=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!pj(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!pj(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!pj(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var A=t[r],s=r+1;s1&&void 0!==arguments[1]?arguments[1]:{};if(!pj(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var A=t[r],s=r+1;sA&&(A=t[s]);return A}(t);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=n.min,A=void 0===o?n.autoMinMax?r:0:o,s=n.max,a=void 0===s?n.autoMinMax?i:1:s;if(A>=a)throw new RangeError("min option must be smaller than max option");for(var c=(a-A)/(i-r),l=0;l=0&&n?` ${A(t,e-1)}`:A(t,e)).padEnd(e)}function A(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function s(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function a(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function c(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function l(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function u(e,n){if(!t.isAnyArray(n))throw new TypeError("row indices must be an array");for(let t=0;t=e.rows)throw new RangeError("row indices are out of range")}function h(e,n){if(!t.isAnyArray(n))throw new TypeError("column indices must be an array");for(let t=0;t=e.columns)throw new RangeError("column indices are out of range")}function d(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(g("startRow",e),g("endRow",n),g("startColumn",r),g("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function f(t,e=0){let n=[];for(let r=0;r=i)throw new RangeError("min must be smaller than max");let A=i-r,s=new w(t,e);for(let n=0;nn?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;tn?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;nt.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;it[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;et[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;et&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){p(this);let t=this.get(0,0),e=[0,0];for(let n=0;nt&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;ee&&(e=this.get(t,n));return e}maxRowIndex(t){s(this,t),p(this);let e=this.get(t,0),n=[t,0];for(let r=1;re&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(s(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;ne&&(e=this.get(n,t));return e}maxColumnIndex(t){a(this,t),p(this);let e=this.get(0,t),n=[0,t];for(let r=1;re&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(a(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n=1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=w.checkMatrix(t);let e=new w(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),A=this.get(1,0),s=t.get(1,0),a=this.get(1,1),c=t.get(1,1),l=(n+a)*(r+c),u=(A+a)*r,h=n*(o-c),d=a*(s-r),f=(n+i)*c,g=l+d-f+(i-a)*(s+c),p=h+f,v=u+d,m=l-u+h+(A-n)*(r+o);return e.set(0,0,g),e.set(0,1,p),e.set(1,0,v),e.set(1,1,m),e}strassen3x3(t){t=w.checkMatrix(t);let e=new w(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),A=this.get(1,1),s=this.get(1,2),a=this.get(2,0),c=this.get(2,1),l=this.get(2,2),u=t.get(0,0),h=t.get(0,1),d=t.get(0,2),f=t.get(1,0),g=t.get(1,1),p=t.get(1,2),v=t.get(2,0),m=t.get(2,1),y=t.get(2,2),b=(n-o)*(-h+g),B=(-n+o+A)*(u-h+g),E=(o+A)*(-u+h),x=n*u,C=(-n+a+c)*(u-d+p),M=(-n+a)*(d-p),F=(a+c)*(-u+d),k=(-i+c+l)*(g+v-m),S=(i-l)*(g-m),Q=i*v,U=(c+l)*(-v+m),N=(-i+A+s)*(p+v-y),T=(i-s)*(p-y),O=(A+s)*(-v+y),I=x+Q+r*f,L=(n+r+i-o-A-c-l)*g+B+E+x+k+Q+U,P=x+C+F+(n+r+i-A-s-a-c)*p+Q+N+O,D=b+A*(-u+h+f-g-p-v+y)+B+x+Q+N+T,R=b+B+E+x+s*m,H=Q+N+T+O+o*d,_=x+C+M+c*(-u+d+f-g-p-v+m)+k+S+Q,G=k+S+Q+U+a*h,K=x+C+M+F+l*y;return e.set(0,0,I),e.set(0,1,L),e.set(0,2,P),e.set(1,0,D),e.set(1,1,R),e.set(1,2,H),e.set(2,0,_),e.set(2,1,G),e.set(2,2,K),e}mmulStrassen(t){t=w.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function A(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=v.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),a=Math.max(r,o);return e=A(e,s,a),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=A(e,r+1,i+1),n=A(n,r+1,i+1)):r%2==1?(e=A(e,r+1,i),n=A(n,r+1,i)):i%2==1&&(e=A(e,r,i+1),n=A(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),a=e.subMatrix(0,o-1,0,s-1),c=n.subMatrix(0,o-1,0,s-1),l=e.subMatrix(0,o-1,s,e.columns-1),u=n.subMatrix(0,o-1,s,n.columns-1),h=e.subMatrix(o,e.rows-1,0,s-1),d=n.subMatrix(o,n.rows-1,0,s-1),f=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),p=t(v.add(a,f),v.add(c,g),o,s),m=t(v.add(h,f),c,o,s),y=t(a,v.sub(u,g),o,s),w=t(f,v.sub(d,c),o,s),b=t(v.add(a,l),g,o,s),B=t(v.sub(h,a),v.add(c,u),o,s),E=t(v.sub(l,f),v.add(d,g),o,s),x=v.add(p,w);x.sub(b),x.add(E);let C=v.add(y,b),M=v.add(m,w),F=v.sub(p,m);F.add(y),F.add(B);let k=v.zeros(2*x.rows,2*x.columns);return k=k.setSubMatrix(x,0,0),k=k.setSubMatrix(C,x.rows,0),k=k.setSubMatrix(M,0,x.columns),k=k.setSubMatrix(F,x.rows,x.columns),k.subMatrix(0,r-1,0,i-1)}(e,t=A(t,s,a),s,a)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:n=0,max:r=1}=t;if(!Number.isFinite(n))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(n>=r)throw new RangeError("min must be smaller than max");let i=new w(this.rows,this.columns);for(let t=0;t0&&e(o,{min:n,max:r,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:n=0,max:r=1}=t;if(!Number.isFinite(n))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(n>=r)throw new RangeError("min must be smaller than max");let i=new w(this.rows,this.columns);for(let t=0;tn||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new w(t.length,n-e+1);for(let i=0;i=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);r.set(i,o-e,this.get(t[i],o))}return r}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new w(n-e+1,t.length);for(let i=0;i=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);r.set(o-e,i,this.get(o,t[i]))}return r}setSubMatrix(t,e,n){if((t=w.checkMatrix(t)).isEmpty())return this;d(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r"number"==typeof t)}v.prototype.klass="Matrix","undefined"!=typeof Symbol&&(v.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return i(this)}),v.random=v.rand,v.randomInt=v.randInt,v.diagonal=v.diag,v.prototype.diagonal=v.prototype.diag,v.identity=v.eye,v.prototype.negate=v.prototype.neg,v.prototype.tensorProduct=v.prototype.kroneckerProduct;class w extends v{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n=0)this.#t(e,n);else{if(!t.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t=0)this.#e=new w(t,t);else if(this.#e=new w(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new b(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new w(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const r=new b(n);for(let i=0,o=0,A=0;A=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t=this.diagonalSize&&(e=++t)}}}b.prototype.klassType="SymmetricMatrix";class B extends b{static isDistanceMatrix(t){return b.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new b(this)}clone(){const t=new B(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,A=0;A=n&&(i=1+ ++o);return r}}B.prototype.klassSubType="DistanceMatrix";class E extends v{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class x extends E{constructor(t,e,n){u(t,e),h(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class C extends v{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class M extends v{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class F{constructor(t){let e,n,r,i,o,A,s,a,c,l=(t=M.checkMatrix(t)).clone(),u=l.rows,h=l.columns,d=new Float64Array(u),f=1;for(e=0;eMath.abs(a[i])&&(i=e);if(i!==n){for(r=0;r=0;i--){for(r=0;re?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new w(e,n);for(let i=0;iMath.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class S{constructor(t){let e,n,r,i,o=(t=M.checkMatrix(t)).clone(),A=t.rows,s=t.columns,a=new Float64Array(s);for(r=0;r=0;o--){for(i=0;i=0;n--){for(t=0;t=0;t--)if(0!==d[t]){for(let e=t+1;e=0;t--){if(t0;){let t,e;for(t=E-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+C*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(p[t])<=e||Number.isNaN(p[t])){p[t]=0;break}}if(t===E-2)e=4;else{let n;for(n=E-1;n>=t&&n!==t;n--){let e=(n!==E?Math.abs(p[n]):0)+(n!==t+1?Math.abs(p[n-1]):0);if(Math.abs(d[n])<=C*e){d[n]=0;break}}n===t?e=3:n===E-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=p[E-2];p[E-2]=0;for(let n=E-2;n>=t;n--){let i=k(d[n],e),o=d[n]/i,A=e/i;if(d[n]=i,n!==t&&(e=-A*p[n-1],p[n-1]=o*p[n-1]),c)for(let t=0;t=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,c&&te&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,A=o.rows,s=o.columns,a=new w(n,A);for(let t=0;tt&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return w.diag(this.s)}}function U(t,e,n=!1){return t=M.checkMatrix(t),e=M.checkMatrix(e),n?new Q(t).solve(e):t.isSquare()?new F(t).solve(e):new S(t).solve(e)}function N(t,e){let n=[];for(let r=0;ri)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e0;s--){for(u=0,A=0,c=0;c0&&(o=-o),e[s]=u*o,A-=i*o,n[s-1]=i-o,a=0;ac)do{for(i=n[c],u=(n[c+1]-i)/(2*e[c]),h=k(u,1),u<0&&(h=-h),n[c]=e[c]/(u+h),n[c+1]=e[c]*(u+h),d=n[c+1],o=i-n[c],A=c+2;A=c;A--)for(p=g,g=f,y=m,i=f*e[A],o=f*u,h=k(u,e[A]),e[A+1]=m*h,m=e[A]/h,f=u/h,u=f*n[A]-m*i,n[A+1]=o+m*(f*i+m*n[A]),a=0;aB*b);n[c]=n[c]+w,e[c]=0}for(A=0;A=c;s--)n[s]=e.get(s,c-1)/l,A+=n[s]*n[s];for(o=Math.sqrt(A),n[c]>0&&(o=-o),A-=n[c]*o,n[c]=n[c]-o,a=c;a=c;s--)i+=n[s]*e.get(s,a);for(i/=A,s=c;s<=h;s++)e.set(s,a,e.get(s,a)-i*n[s])}for(s=0;s<=h;s++){for(i=0,a=h;a>=c;a--)i+=n[a]*e.get(s,a);for(i/=A,a=c;a<=h;a++)e.set(s,a,e.get(s,a)-i*n[a])}n[c]=l*n[c],e.set(c,c-1,l*o)}}for(s=0;s=u+1;c--)if(0!==e.get(c,c-1)){for(s=c+1;s<=h;s++)n[s]=e.get(s,c-1);for(a=c;a<=h;a++){for(o=0,s=c;s<=h;s++)o+=n[s]*r.get(s,a);for(o=o/n[c]/e.get(c,c-1),s=c;s<=h;s++)r.set(s,a,r.get(s,a)+o*n[s])}}}(o,t,e,A),function(t,e,n,r,i){let o,A,s,a,c,l,u,h,d,f,g,p,v,m,y,w=t-1,b=0,B=t-1,E=Number.EPSILON,x=0,C=0,M=0,F=0,k=0,S=0,Q=0,U=0;for(o=0;oB)&&(n[o]=i.get(o,o),e[o]=0),A=Math.max(o-1,0);A=b;){for(a=w;a>b&&(S=Math.abs(i.get(a-1,a-1))+Math.abs(i.get(a,a)),0===S&&(S=C),!(Math.abs(i.get(a,a-1))=0){for(Q=M>=0?M+Q:M-Q,n[w-1]=h+Q,n[w]=n[w-1],0!==Q&&(n[w]=h-u/Q),e[w-1]=0,e[w]=0,h=i.get(w,w-1),S=Math.abs(h)+Math.abs(Q),M=h/S,F=Q/S,k=Math.sqrt(M*M+F*F),M/=k,F/=k,A=w-1;A0)){for(S=Math.sqrt(S),d=a&&(Q=i.get(c,c),k=h-Q,S=d-Q,M=(k*S-u)/i.get(c+1,c)+i.get(c,c+1),F=i.get(c+1,c+1)-Q-k-S,k=i.get(c+2,c+1),S=Math.abs(M)+Math.abs(F)+Math.abs(k),M/=S,F/=S,k/=S,c!==a)&&!(Math.abs(i.get(c,c-1))*(Math.abs(F)+Math.abs(k))c+2&&i.set(o,o-3,0);for(s=c;s<=w-1&&(m=s!==w-1,s!==c&&(M=i.get(s,s-1),F=i.get(s+1,s-1),k=m?i.get(s+2,s-1):0,h=Math.abs(M)+Math.abs(F)+Math.abs(k),0!==h&&(M/=h,F/=h,k/=h)),0!==h);s++)if(S=Math.sqrt(M*M+F*F+k*k),M<0&&(S=-S),0!==S){for(s!==c?i.set(s,s-1,-S*h):a!==c&&i.set(s,s-1,-i.get(s,s-1)),M+=S,h=M/S,d=F/S,Q=k/S,F/=M,k/=M,A=s;A=0;w--)if(M=n[w],F=e[w],0===F)for(a=w,i.set(w,w,1),o=w-1;o>=0;o--){for(u=i.get(o,o)-M,k=0,A=a;A<=w;A++)k+=i.get(o,A)*i.get(A,w);if(e[o]<0)Q=u,S=k;else if(a=o,0===e[o]?i.set(o,w,0!==u?-k/u:-k/(E*C)):(h=i.get(o,o+1),d=i.get(o+1,o),F=(n[o]-M)*(n[o]-M)+e[o]*e[o],l=(h*S-Q*k)/F,i.set(o,w,l),i.set(o+1,w,Math.abs(h)>Math.abs(Q)?(-k-u*l)/h:(-S-d*l)/Q)),l=Math.abs(i.get(o,w)),E*l*l>1)for(A=o;A<=w;A++)i.set(A,w,i.get(A,w)/l)}else if(F<0)for(a=w-1,Math.abs(i.get(w,w-1))>Math.abs(i.get(w-1,w))?(i.set(w-1,w-1,F/i.get(w,w-1)),i.set(w-1,w,-(i.get(w,w)-M)/i.get(w,w-1))):(y=I(0,-i.get(w-1,w),i.get(w-1,w-1)-M,F),i.set(w-1,w-1,y[0]),i.set(w-1,w,y[1])),i.set(w,w-1,0),i.set(w,w,1),o=w-2;o>=0;o--){for(f=0,g=0,A=a;A<=w;A++)f+=i.get(o,A)*i.get(A,w-1),g+=i.get(o,A)*i.get(A,w);if(u=i.get(o,o)-M,e[o]<0)Q=u,k=f,S=g;else if(a=o,0===e[o]?(y=I(-f,-g,u,F),i.set(o,w-1,y[0]),i.set(o,w,y[1])):(h=i.get(o,o+1),d=i.get(o+1,o),p=(n[o]-M)*(n[o]-M)+e[o]*e[o]-F*F,v=2*(n[o]-M)*F,0===p&&0===v&&(p=E*C*(Math.abs(u)+Math.abs(F)+Math.abs(h)+Math.abs(d)+Math.abs(Q))),y=I(h*k-Q*f+F*g,h*S-Q*g-F*f,p,v),i.set(o,w-1,y[0]),i.set(o,w,y[1]),Math.abs(h)>Math.abs(Q)+Math.abs(F)?(i.set(o+1,w-1,(-f-u*i.get(o,w-1)+F*i.get(o,w))/h),i.set(o+1,w,(-g-u*i.get(o,w)-F*i.get(o,w-1))/h)):(y=I(-k-d*i.get(o,w-1),-S-d*i.get(o,w),Q,F),i.set(o+1,w-1,y[0]),i.set(o+1,w,y[1]))),l=Math.max(Math.abs(i.get(o,w-1)),Math.abs(i.get(o,w))),E*l*l>1)for(A=o;A<=w;A++)i.set(A,w-1,i.get(A,w-1)/l),i.set(A,w,i.get(A,w)/l)}for(o=0;oB)for(A=o;A=b;A--)for(o=b;o<=B;o++){for(Q=0,s=b;s<=Math.min(A,B);s++)Q+=r.get(o,s)*i.get(s,A);r.set(o,A,Q)}}(o,a,s,A,t)}this.n=o,this.e=a,this.d=s,this.V=A}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new w(n,n);for(t=0;t0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function I(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class L{constructor(t){if(!(t=M.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,A=new w(o,o),s=!0;for(n=0;n0,A.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r=0;o--)for(i=0;iA;t++)l=e.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=e.mmul(l).div(l.transpose().mmul(l).get(0,0)),t>0&&(h=a.clone().sub(u).pow(2).sum()),u=a.clone(),r?(c=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),s=r.mmul(c).div(c.transpose().mmul(c).get(0,0))):s=a;if(r){let t=e.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));t=t.div(t.norm());let n=e.clone().sub(a.clone().mmul(t.transpose())),i=s.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),o=r.clone().sub(a.clone().mulS(i.get(0,0)).mmul(c.transpose()));this.t=a,this.p=t.transpose(),this.w=l.transpose(),this.q=c,this.u=s,this.s=a.transpose().mmul(a),this.xResidual=n,this.yResidual=o,this.betas=i}else this.w=l.transpose(),this.s=a.transpose().mmul(a).sqrt(),this.t=i?a.clone().div(this.s.get(0,0)):a,this.xResidual=e.sub(a.mmul(l.transpose()))}}return fj.AbstractMatrix=v,fj.CHO=L,fj.CholeskyDecomposition=L,fj.DistanceMatrix=B,fj.EVD=O,fj.EigenvalueDecomposition=O,fj.LU=F,fj.LuDecomposition=F,fj.Matrix=w,fj.MatrixColumnSelectionView=class extends E{constructor(t,e){h(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},fj.MatrixColumnView=class extends E{constructor(t,e){a(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},fj.MatrixFlipColumnView=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},fj.MatrixFlipRowView=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},fj.MatrixRowSelectionView=class extends E{constructor(t,e){u(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},fj.MatrixRowView=class extends E{constructor(t,e){s(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},fj.MatrixSelectionView=x,fj.MatrixSubView=class extends E{constructor(t,e,n,r,i){d(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},fj.MatrixTransposeView=class extends E{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},fj.NIPALS=P,fj.Nipals=P,fj.QR=S,fj.QrDecomposition=S,fj.SVD=Q,fj.SingularValueDecomposition=Q,fj.SymmetricMatrix=b,fj.WrapperMatrix1D=C,fj.WrapperMatrix2D=M,fj.correlation=function(e,n=e,r={}){e=new w(e);let i=!1;if("object"!=typeof n||w.isMatrix(n)||t.isAnyArray(n)?n=new w(n):(r=n,n=e,i=!0),e.rows!==n.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:o=!0,scale:A=!0}=r;o&&(e.center("column"),i||n.center("column")),A&&(e.scale("column"),i||n.scale("column"));const s=e.standardDeviation("column",{unbiased:!0}),a=i?s:n.standardDeviation("column",{unbiased:!0}),c=e.transpose().mmul(n);for(let t=0;te?o[t]=1/o[t]:o[t]=0;return i.mmul(w.diag(o).mmul(r.transpose()))},fj.solve=U,fj.wrap=function(e,n){if(t.isAnyArray(e))return e[0]&&t.isAnyArray(e[0])?new M(e):new C(e,n);throw new Error("the argument is not an array")},fj}var Bj=bj(),Ej=BU(Bj);const xj=Bj.Matrix,Cj=Bj.SingularValueDecomposition;Ej.Matrix?Ej.Matrix:Bj.Matrix;const Mj=(t,e)=>{const n=t.nodeCount(),r=Array.from({length:n},()=>[]),i={};let o=0;return t.forEachNode(t=>{i[t.id]=o++}),t.forEachEdge(t=>{const e=i[t.source],n=i[t.target];null!=e&&null!=n&&(r[e].push(n),r[n].push(e))}),r};function Fj(t){const e=t.length;new Array(e).fill(0);const n=Array.from({length:e},()=>new Array(e).fill(1/0));for(let r=0;r0&&(this.data[0]=e,this.bubbleDown(0)),t}empty(){return 0===this.data.length}bubbleUp(t){const e=this.data;for(;t>0;){const n=t-1>>1;if(e[n][0]<=e[t][0])break;[e[n],e[t]]=[e[t],e[n]],t=n}}bubbleDown(t){const e=this.data,n=e.length;for(;;){const r=2*t+1,i=2*t+2;let o=t;if(r{const n=t.length,r=new Array(n);for(let i=0;i{const n=o[A++];t.x=n[0]+e[0],t.y=n[1]+e[1]})})}}const Nj=t=>{let e=Number.NEGATIVE_INFINITY;const n=[],r=t.length;for(let i=0;i{try{const n=t.length,r=new xj(n,n);for(let e=0;e{let o=0;t.forEachNode(A=>{let s=0;t.forEachNode(t=>{if(s<=o)return void s++;if(A.id===t.id)return;if(r.get(A.id)!==r.get(t.id))return;let a=A.x-t.x,c=A.y-t.y,l=Math.sqrt(a*a+c*c);if(0===l){l=1;const t=o>s?1:-1;a=.01*t,c=.01*t}const u=Math.max(...i(A._original));if(l{r&&t.forEachNode(t=>{const n=t.x-i.x,r=t.y-i.y,o=Math.sqrt(n*n+r*r);let A=r/o,s=-n/o;const a=e.get(t.id),c=Math.sqrt(a.x*a.x+a.y*a.y);let l=Math.acos((A*a.x+s*a.y)/c);l>Math.PI/2&&(l-=Math.PI/2,A*=-1,s*=-1);const u=Math.cos(l)*c;e.set(t.id,{x:A*u,y:s*u})});let s=0,a=0;return t.forEachNode(t=>{if(t.id===i.id)return;const c=e.get(t.id),l=Math.sqrt(c.x*c.x+c.y*c.y);if(l>0){const e=Math.min(o*(n/800),l);if(t.x+=c.x/l*e,t.y+=c.y/l*e,r){let e=t.x-i.x,n=t.y-i.y;const r=Math.sqrt(e*e+n*n);e=e/r*A.get(t.id),n=n/r*A.get(t.id),t.x=i.x+e,t.y=i.y+n}s+=e,a++}}),a>0?s/a:0},Pj={focusNode:null,linkDistance:50,maxIteration:1e3,maxPreventOverlapIteration:200,preventOverlap:!1,sortStrength:10,strictRadial:!0,unitRadius:null,nodeSize:10,nodeSpacing:0};class Dj extends EC{constructor(){super(...arguments),this.id="radial"}getDefaultOptions(){return Pj}layout(){return mx(this,0,void 0,function*(){const{width:t,height:e,center:n}=kF(this.options),r=this.model.nodeCount();if(!r||1===r)return EF(this.model,n);const{focusNode:i,linkDistance:o=Pj.linkDistance,maxIteration:A=Pj.maxIteration,maxPreventOverlapIteration:s=Pj.maxPreventOverlapIteration,nodeSize:a,nodeSpacing:c,preventOverlap:l,sortBy:u,sortStrength:h=Pj.sortStrength,strictRadial:d,unitRadius:f}=this.options,g=i&&this.model.node(i)||this.model.firstNode(),p=this.model.nodeIndexOf(g.id),v=Fj(Mj(this.model)),m=Gj(v,p);_j(v,p,m+1);const y=v[p],w=(t-n[0]>n[0]?n[0]:t-n[0])||t/2,b=(e-n[1]>n[1]?n[1]:e-n[1])||e/2,B=Math.min(w,b),E=Math.max(...y),x=[],C=new Map,M=null!=f?f:B/E;y.forEach((t,e)=>{const n=t*M;x.push(n),C.set(this.model.nodeAt(e).id,n)});const F=Rj(this.model,v,o,x,M,u,h),k=Tj(F,2,o),S=k[p];let Q=0;if(this.model.forEachNode(t=>{const e=k[Q];t.x=e[0]-S[0],t.y=e[1]-S[1],Q++}),this.run(A,F,x,p),this.model.forEachNode(t=>{t.x+=n[0],t.y+=n[1]}),l){const e={nodeSizeFunc:Xx(a,c,Pj.nodeSize,Pj.nodeSpacing),radiiMap:C,width:t,strictRadial:Boolean(d),focusNode:g,maxIteration:s,k:r/4.5};((t,e)=>{const n=Object.assign(Object.assign({},Oj),e),{maxIteration:r,width:i,k:o,speed:A=Oj.speed,strictRadial:s,focusNode:a,radiiMap:c,nodeSizeFunc:l}=n,u=.002*o,h=new Map,d=i/10;for(let e=0;e{h.set(t.id,{x:0,y:0})}),Ij(t,h,o,c,l),!(Lj(t,h,A,s,a,d,c){const s=e.length,a=new Array(s),c=new Array(s);for(let t=0;t{const e=t.length,n=t[0].length,r=[];for(let i=0;i{const r=t.length;for(let i=0;i{const n=t[e];let r=0;for(let t=0;t{r.x=jj(t)+n[0],r.y=jj(e)+n[1]})})}}const jj=t=>.9*(Math.random()-.5)*t,zj={"antv-dagre":bF,"d3-force-3d":class extends Ok{constructor(){super(...arguments),this.id="d3-force-3d",this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:wS,manyBody:vS,center:cS,collide:aS,radial:Hk,x:Rk,y:Dk,z:Pk}}getDefaultOptions(){return{numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return pS()}setupForces(t,e){Object.entries(this.forceMap).forEach(([n,r])=>{const i=n;if(e[n]){let n=t.force(i);n||(n=r(),t.force(i,n)),Ik(n,Object.entries(e[i]))}else t.force(i,null)})}},"d3-force":Ok,"force-atlas2":nj,circular:QF,concentric:NF,dagre:LK,force:qK,fruchterman:oj,grid:sj,mds:Uj,radial:Dj,random:Kj},Vj={layout:t=>t?{type:"concentric",preventOverlap:!0}:{type:"force",preventOverlap:!0},nodeSize:20,nodeSpacing:0,comboPadding:10,comboSpacing:0},Wj="root";class Yj extends EC{constructor(){super(...arguments),this.id="combo-combined",this.relativePositions=new Map,this.getParentId=t=>t.parentId||Wj}getDefaultOptions(){return Vj}layout(){return mx(this,0,void 0,function*(){const{center:t}=kF(this.options);this.resetLayoutState();const e=this.buildHierarchyTree();yield this.layoutHierarchy(e),this.convertToGlobalPositions(e,t),this.applyPositionsToModel(e)})}isCombo(t){return Boolean(t.isCombo)}resetLayoutState(){this.relativePositions.clear()}layoutHierarchy(t){return mx(this,0,void 0,function*(){for(const e of t.children||[])this.isCombo(e)&&(yield this.layoutHierarchy(e));const e=t.children||[];if(0===e.length)return t.size=[0,0,0],void(t.parentId=t.id===Wj?null:t.parentId);const n=this.getLayoutConfig(t),{type:r}=n,i=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i{const e=this.relativePositions.get(t.id);if(!e)return;const n=Object.assign(Object.assign({},e),{x:e.x-a[0],y:e.y-a[1]});this.relativePositions.set(t.id,n)})})}recordRelativePositions(t,e){const n=this.calculateComboCenter(t);t.forEach(t=>{this.relativePositions.set(t.id,{x:t.x-n[0],y:t.y-n[1],relativeTo:String(e.id)})})}buildHierarchyTree(){const t={id:Wj,isCombo:!0,children:[],parentId:null},e=new Map;return e.set(Wj,t),this.model.forEachNode(t=>{if(this.isCombo(t)){const n=Object.assign(Object.assign({},t),{children:[],parentId:this.getParentId(t)});e.set(String(t.id),n)}}),this.model.forEachNode(t=>{const n=e.get(this.getParentId(t));if(this.isCombo(t)){const r=e.get(String(t.id));n&&r&&(n.children.push(r),r.parentId=n.id)}else n&&n.children.push(Object.assign(Object.assign({},t),{children:[],parentId:this.getParentId(t)}))}),t}convertToGlobalPositions(t,e){var n,r;const i=t.id===Wj?null:this.relativePositions.get(t.id),o=e[0]+(null!==(n=null==i?void 0:i.x)&&void 0!==n?n:0),A=e[1]+(null!==(r=null==i?void 0:i.y)&&void 0!==r?r:0);t.x=o,t.y=A,(t.children||[]).forEach(t=>{var e,n;const r=this.relativePositions.get(t.id);t.x=o+(null!==(e=null==r?void 0:r.x)&&void 0!==e?e:0),t.y=A+(null!==(n=null==r?void 0:r.y)&&void 0!==n?n:0),t.size=this.getNodeLikeSize(t,!1),this.isCombo(t)&&this.convertToGlobalPositions(t,[o,A])})}getLayoutConfig(t){const e="object"==typeof this.options.layout?this.options.layout:Vx(this.options.layout,["comboId"]);if("function"==typeof e){const n=t.id===Wj?null:t.id;return this.normalizeLayoutConfig(e(n))}return this.normalizeLayoutConfig(e)}normalizeLayoutConfig(t){const e=Object.assign(Object.assign({type:"concentric"},kF(this.options)),{nodeSize:"node.size",nodeSpacing:0});return t?"string"==typeof t?Object.assign(Object.assign({},e),{type:t}):Object.assign(Object.assign({},e),t):e}getLayoutClass(t){return zj[t]||zj.concentric}createTemporaryGraphData(t){const e=t.map(t=>Object.assign(Object.assign({},t),{size:this.getNodeLikeSize(t)})),n=new Set(t.map(t=>String(t.id))),r=[],i=t=>{let e=String(t);const r=new Set;for(;e&&!r.has(e);){if(n.has(e))return e;r.add(e);const t=this.model.node(e),i=null==t?void 0:t.parentId;e=null==i?null:String(i)}return null};return this.model.forEachEdge(t=>{const e=i(String(t.source)),n=i(String(t.target));e&&n&&e!==n&&r.push({source:e,target:n})}),{nodes:e,edges:r}}calculateComboCenter(t){if(0===t.length)return[0,0];const e=new Map;t.forEach(t=>{const n=this.getNodeLikeSize(t);e.set(t.id,n)});let n=1/0,r=1/0,i=-1/0,o=-1/0;return t.forEach(t=>{const[A=0,s=0]=e.get(t.id);n=Math.min(n,t.x-A/2),r=Math.min(r,t.y-s/2),i=Math.max(i,t.x+A/2),o=Math.max(o,t.y+s/2)}),Number.isFinite(n)&&Number.isFinite(r)?[(n+i)/2,(r+o)/2]:[0,0]}calculateComboBounds(t){const e=t.children||[];if(0===e.length)return{center:[0,0],width:0,height:0};let n=1/0,r=1/0,i=-1/0,o=-1/0;if(e.forEach(t=>{var e,A;const s=this.relativePositions.get(t.id),a=null!==(e=null==s?void 0:s.x)&&void 0!==e?e:0,c=null!==(A=null==s?void 0:s.y)&&void 0!==A?A:0,[l,u]=this.getNodeLikeSize(t);n=Math.min(n,a-l/2),r=Math.min(r,c-u/2),i=Math.max(i,a+l/2),o=Math.max(o,c+u/2)}),!Number.isFinite(n)||!Number.isFinite(r))return{center:[0,0],width:0,height:0};const A=Wx(this.options.comboPadding,20,"combo")(t._original);return{center:[(n+i)/2,(r+o)/2],width:i-n+2*A,height:o-r+2*A}}getNodeLikeSize(t,e=!0){return this.isCombo(t)?this.getComboSize(t,e):this.getNodeSize(t,e)}getNodeSize(t,e=!0){const{nodeSize:n,nodeSpacing:r}=this.options;return Xx(n,e?r:0)(t._original)}getComboSize(t,e=!0){const n=Wx(this.options.comboSpacing,0,"combo"),r=e?n(t._original):0,[i,o]=t.size;return[i+r/2,o+r/2,0]}applyPositionsToModel(t){const e=t=>{const e=this.model.node(t.id);e&&(e.x=t.x,e.y=t.y,t.size&&(e.size=t.size))},n=t=>{t.id!==Wj&&e(t),(t.children||[]).forEach(t=>{this.isCombo(t)?n(t):e(t)})};n(t)}}class Xj extends mE{constructor(){super(...arguments),this.id="fishbone"}getRoot(){const t=this.context.model.getRootsData();if(!(Ee(t)||t.length>2))return t[0]}formatSize(t){const e="function"==typeof t?t:()=>t;return t=>cw(e(t))}doLayout(t,e){const{hGap:n,getRibSep:r,vGap:i,nodeSize:o,height:A}=e,{model:s}=this.context,a=this.formatSize(o);let c=a(t)[0]+r(t);const l=(t,e=0)=>{var r;return e+=n*((t.children||[]).length+1),null===(r=t.children)||void 0===r||r.forEach(t=>{var n;null===(n=s.getNodeLikeDatum(t).children)||void 0===n||n.forEach(t=>{const n=s.getNodeLikeDatum(t);e=l(n,e)})}),e},u=t=>{if(1===t.depth)return c;const e=s.getParentData(t.id,"tree");if(Zj(t)){const r=s.getParentData(e.id,"tree"),o=f(t)-f(r);return u(e)+o*n/i}{const n=(e.children||[]).indexOf(t.id),r=s.getNodeData((e.children||[]).slice(n));return h(e)-r.reduce((t,e)=>t+l(e),0)-a(e)[0]/2}},h=me(t=>{if($j(t))return a(t)[0]/2;const e=s.getParentData(t.id,"tree");if(Zj(t))return u(t)+l(t)+a(t)[0]/2;{const r=f(t)-f(e),o=n/i;return u(t)+r*o}},t=>t.id),d=t=>f(s.getParentData(t,"tree")),f=me(t=>{if($j(t))return A/2;if(Zj(t)){const e=s.getParentData(t.id,"tree"),n=e.children.indexOf(t.id);if(0===n)return d(e.id)+i;const r=s.getNodeLikeDatum(e.children[n-1]);if(Ee(r.children))return f(r)+i;const o=s.getDescendantsData(r.id);return Math.max(...o.map(t=>Zj(t)?d(t.id):f(t)))+i}{if(Ee(t.children))return d(t.id)+i;const e=s.getNodeLikeDatum(t.children.slice(-1)[0]);if(Ee(e.children))return f(e)+i;const n=s.getDescendantsData(t.id).slice(-1)[0];return(Zj(n)?d(n.id):f(n))+i}},t=>t.id);let g=0;const p={nodes:[],edges:[]},v=t=>{var e;null===(e=t.children)||void 0===e||e.forEach(t=>v(s.getNodeLikeDatum(t)));const n=f(t),i=h(t);if(p.nodes.push({id:t.id,x:i,y:n}),$j(t))return;const o=s.getRelatedEdgesData(t.id,"in")[0],A=[u(t),Zj(t)?n:d(t.id)];p.edges.push({id:Km(o),controlPoints:[A],relatedNodeId:t.id}),g=Math.max(g,i+r(t)),1===t.depth&&(c=g)};return v(t),p}placeAlterative(t,e){const n=(e.children||[]).filter((t,e)=>e%2!=0);if(0===n.length)return t;const{model:r}=this.context,i=t.nodes.find(t=>t.id===e.id).y,o=t=>{const e=r.getAncestorsData(t,"tree");if(Ee(e))return!1;const i=1===e.length?t:e[e.length-2].id;return n.includes(i)};t.nodes.forEach(t=>{o(t.id)&&(t.y=2*i-t.y)}),t.edges.forEach(t=>{o(t.relatedNodeId)&&(t.controlPoints=t.controlPoints.map(t=>[t[0],2*i-t[1]]))})}rightToLeft(t,e){return t.nodes.forEach(t=>t.x=e.width-t.x),t.edges.forEach(t=>{t.controlPoints=t.controlPoints.map(t=>[e.width-t[0],t[1]])}),t}execute(t,e){return De(this,void 0,void 0,function*(){const n=Object.assign(Object.assign(Object.assign({},Xj.defaultOptions),this.options),e),{direction:r,nodeSize:i}=n,o=this.getRoot();if(!o)return t;const A=this.formatSize(i);n.vGap||(n.vGap=Math.max(...(t.nodes||[]).map(t=>A(t)[1]))),n.hGap||(n.hGap=Math.max(...(t.nodes||[]).map(t=>A(t)[0])));let s=this.doLayout(o,n);this.placeAlterative(s,o),"RL"===r&&(s=this.rightToLeft(s,n));const{model:a}=this.context,c=[],l=[];return s.nodes.forEach(t=>{const{id:e,x:n,y:r}=t,i=a.getNodeLikeDatum(e);c.push(qj(i,{x:n,y:r}))}),s.edges.forEach(t=>{const{id:e,controlPoints:n}=t,r=a.getEdgeDatum(e);l.push(qj(r,{controlPoints:n}))}),{nodes:c,edges:l}})}}Xj.defaultOptions={direction:"RL",getRibSep:()=>60};const qj=(t,e)=>Object.assign(Object.assign({},t),{style:Object.assign(Object.assign({},t.style||{}),e)}),$j=t=>0===t.depth,Zj=t=>(t.depth||(t.depth=0))%2==0;class Jj extends mE{constructor(){super(...arguments),this.id="snake"}formatSize(t,e){const n="function"==typeof e?e:()=>e;return t.reduce((t,e)=>{const[r,i]=cw(n(e))||[0,0];return[Math.max(t[0],r),Math.max(t[1],i)]},[0,0])}validate(t){const{nodes:e=[],edges:n=[]}=t,r={},i={},o={};e.forEach(t=>{r[t.id]=0,i[t.id]=0,o[t.id]=[]}),n.forEach(t=>{r[t.target]++,i[t.source]++,o[t.source].push(t.target)});const A=new Set,s=t=>{A.has(t)||(A.add(t),o[t].forEach(s))};if(s(e[0].id),A.size!==e.length)return!1;const a=e.filter(t=>0===r[t.id]),c=e.filter(t=>0===i[t.id]);if(1!==a.length||1!==c.length)return!1;return e.filter(t=>1===r[t.id]&&1===i[t.id]).length===e.length-2}execute(t,e){return De(this,void 0,void 0,function*(){var n;if(!this.validate(t))return t;const{nodeSize:r,padding:i,sortBy:o,cols:A,colGap:s,rowGap:a,clockwise:c,width:l,height:u}=Object.assign({},Jj.defaultOptions,this.options,e),[h,d,f,g]=pm(i),p=this.formatSize(t.nodes||[],r),v=Math.ceil((t.nodes||[]).length/A);let m=s||(l-g-d-A*p[0])/(A-1),y=a||(u-h-f-v*p[1])/(v-1);(y===1/0||y<0)&&(y=0),(m===1/0||m<0)&&(m=0);const w=o?null===(n=t.nodes)||void 0===n?void 0:n.sort(o):function(t){const{nodes:e=[],edges:n=[]}=t,r={},i={};e.forEach(t=>{r[t.id]=0,i[t.id]=[]}),n.forEach(t=>{r[t.target]++,i[t.source].push(t.target)});const o=[],A=[];e.forEach(t=>{0===r[t.id]&&o.push(t.id)});for(;o.length>0;){const t=o.shift(),n=e.find(e=>e.id===t);A.push(n),i[t].forEach(t=>{r[t]--,0===r[t]&&o.push(t)})}return A}(t),b=(w||[]).map((t,e)=>{const n=Math.floor(e/A),r=e%A,i=g+(c?n%2==0?r:A-1-r:n%2==0?A-1-r:r)*(p[0]+m)+p[0]/2,o=h+n*(p[1]+y)+p[1]/2;return{id:t.id,style:{x:i,y:o}}});return{nodes:b}})}}Jj.defaultOptions={padding:0,cols:5,clockwise:!0};class tz extends ry{}function ez(t,e=!0,n){const r=document.createElement("div");return r.setAttribute("class",`g6-${t}`),Object.assign(r.style,{position:"absolute",display:"block"}),e&&Object.assign(r.style,{position:"unset",gridArea:"1 / 1 / 2 / 2",inset:"0px",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none"}),n&&Object.assign(r.style,n),r}function nz(t,e="div",n={},r="",i=document.body){const o=document.getElementById(t);o&&o.remove();const A=document.createElement(e);return A.innerHTML=r,A.id=t,Object.assign(A.style,n),i.appendChild(A),A}class rz extends tz{constructor(t,e){super(t,Object.assign({},rz.defaultOptions,e)),this.$element=ez("background");this.context.canvas.getContainer().prepend(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t),Object.assign(this.$element.style,Se(this.options,["key","type"]))})}destroy(){super.destroy(),this.$element.remove()}}function iz(t,e,n,r,i,o){const A=n-t,s=r-e;let a=i-t,c=o-e,l=a*A+c*s,u=0;l<=0?u=0:(a=A-a,c=s-c,l=a*A+c*s,u=l<=0?0:l*l/(A*A+s*s));const h=a*a+c*c-u;return h<0?0:h}function oz(t,e,n,r){return(t-n)*(t-n)+(e-r)*(e-r)}function Az(t,e,n,r,i){return oz(t,e,n,r)this.y1&&e>=this.y2)return!1;if(t>this.x1&&t>=this.x2)return!1;if(tthis.x2+n)return!1}else if(tthis.x1+n)return!1;if(this.y1this.y2+n)return!1}else if(ethis.y1+n)return!1;return!0}}var cz,lz;!function(t){t[t.POINT=1]="POINT",t[t.PARALLEL=2]="PARALLEL",t[t.COINCIDENT=3]="COINCIDENT",t[t.NONE=4]="NONE"}(cz||(cz={}));class uz{constructor(t,e=0,n=0){this.state=t,this.x=e,this.y=n}}function hz(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const e=n/i,o=r/i;return 0<=e&&e<=1&&0<=o&&o<=1?new uz(cz.POINT,t.x1+e*(t.x2-t.x1),t.y1+e*(t.y2-t.y1)):new uz(cz.NONE)}return new uz(0===n||0===r?cz.COINCIDENT:cz.PARALLEL)}function dz(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const t=n/i,e=r/i;if(0<=t&&t<=1&&0<=e&&e<=1)return t}return Number.POSITIVE_INFINITY}function fz(t,e,n){const r=new Set;return t.width<=0?(r.add(lz.LEFT),r.add(lz.RIGHT)):et.x+t.width&&r.add(lz.RIGHT),t.height<=0?(r.add(lz.TOP),r.add(lz.BOTTOM)):nt.y+t.height&&r.add(lz.BOTTOM),r}function gz(t,e){let n=e.x1,r=e.y1;const i=e.x2,o=e.y2,A=Array.from(fz(t,i,o));if(0===A.length)return!0;let s=fz(t,n,r);for(;0!==s.size;){for(const t of A)if(s.has(t))return!1;if(s.has(lz.RIGHT)||s.has(lz.LEFT)){let e=t.x;s.has(lz.RIGHT)&&(e+=t.width),r+=(e-n)*(o-r)/(i-n),n=e}else{let e=t.y;s.has(lz.BOTTOM)&&(e+=t.height),n+=(e-r)*(i-n)/(o-r),r=e}s=fz(t,n,r)}return!0}function pz(t,e){let n=Number.POSITIVE_INFINITY,r=0;function i(t,i,o,A){let s=dz(e,new az(t,i,o,A));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s1?n:(i(t.x,t.y2,t.x2,t.y2),r>1?n:(i(t.x2,t.y,t.x2,t.y2),0===r?-1:n))}function vz(t,e){let n=0;const r=hz(t,new az(e.x,e.y,e.x2,e.y));n+=r.state===cz.POINT?1:0;const i=hz(t,new az(e.x,e.y,e.x,e.y2));n+=i.state===cz.POINT?1:0;const o=hz(t,new az(e.x,e.y2,e.x2,e.y2));n+=o.state===cz.POINT?1:0;const A=hz(t,new az(e.x2,e.y,e.x2,e.y2));return n+=A.state===cz.POINT?1:0,{top:r,left:i,bottom:o,right:A,count:n}}!function(t){t[t.LEFT=0]="LEFT",t[t.TOP=1]="TOP",t[t.RIGHT=2]="RIGHT",t[t.BOTTOM=3]="BOTTOM"}(lz||(lz={}));class mz{constructor(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(t){return new mz(t.x,t.y,t.width,t.height)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new mz(this.x,this.y,this.width,this.height)}add(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x+t.width),i=Math.max(this.y2,t.y+t.height);this.x=e,this.y=n,this.width=r-e,this.height=i-n}addPoint(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x),i=Math.max(this.y2,t.y);this.x=e,this.y=n,this.width=r-e,this.height=i-n}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(t){t.rect(this.x,this.y,this.width,this.height)}containsPt(t,e){return t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}get area(){return this.width*this.height}intersects(t){return!(this.area<=0||t.width<=0||t.height<=0)&&(t.x+t.width>this.x&&t.y+t.height>this.y&&t.x=this.width?this.width-1:t}boundY(t){return t=this.height?this.height-1:t}scaleX(t){return this.boundX(Math.floor((t-this.pixelX)/this.pixelGroup))}scaleY(t){return this.boundY(Math.floor((t-this.pixelY)/this.pixelGroup))}scale(t){const e=this.scaleX(t.x),n=this.scaleY(t.y),r=this.boundX(Math.ceil((t.x+t.width-this.pixelX)/this.pixelGroup)),i=this.boundY(Math.ceil((t.y+t.height-this.pixelY)/this.pixelGroup));return new mz(e,n,r-e,i-n)}invertScaleX(t){return Math.round(t*this.pixelGroup+this.pixelX)}invertScaleY(t){return Math.round(t*this.pixelGroup+this.pixelY)}addPadding(t,e){const n=Math.ceil(e/this.pixelGroup),r=this.boundX(t.x-n),i=this.boundY(t.y-n),o=this.boundX(t.x2+n),A=this.boundY(t.y2+n);return new mz(r,i,o-r,A-i)}get(t,e){return t<0||e<0||t>=this.width||e>=this.height?Number.NaN:this.area[t+e*this.width]}inc(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]+=n)}set(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]=n)}incArea(t,e){if(t.width<=0||t.height<=0||0===e)return;const n=this.width,r=t.width,i=Math.max(0,t.i),o=Math.max(0,t.j),A=Math.min(t.i+t.width,n),s=Math.min(t.j+t.height,this.height);if(!(s<=0||A<=0||i>=n||s>=this.height))for(let a=o;aMath.min(t,e),Number.POSITIVE_INFINITY),r=this.area.reduce((t,e)=>Math.max(t,e),Number.NEGATIVE_INFINITY),i=t=>(t-n)/(r-n);t.scale(this.pixelGroup,this.pixelGroup);for(let e=0;ee?"black":"white",t.fillRect(n,r,1,1)}t.restore()}}}function bz(t,e){const n=t=>({x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e});return Array.isArray(t)?t.map(n):n(t)}function Bz(t,e,n){return Ez(Object.assign(sz(t),{distSquare:(e,n)=>iz(t.x1,t.y1,t.x2,t.y2,e,n)}),e,n)}function Ez(t,e,n){const r=bz(t,n),i=e.scale(r),o=e.createSub(i,r);return function(t,e,n,r){const i=n*n;for(let o=0;ot.distSquare(e,n)),o}function xz(t,e){return{x:t,y:e}}function Cz(t,e,n,r){if(0===t.length)return[];const i=function(t){if(t.length<2)return t;let e=0,n=0;return t.forEach(t=>{e+=t.cx,n+=t.cy}),e/=t.length,n/=t.length,t.map(t=>{const r=e-t.cx,i=n-t.cy;return[t,r*r+i*i]}).sort((t,e)=>t[1]-e[1]).map(t=>t[0])}(t);return i.map((t,o)=>{const A=i.slice(0,o);return function(t,e,n,r,i){const o=xz(e.cx,e.cy),A=function(t,e,n){let r=Number.POSITIVE_INFINITY;return e.reduce((e,i)=>{const o=oz(t.x,t.y,i.cx,i.cy);if(o>r)return e;const A=new az(t.x,t.y,i.cx,i.cy),s=function(t,e){return t.reduce((t,n)=>gz(n,e)&&function(t,e){function n(t,n,r,i){let o=dz(e,new az(t,n,r,i));return o=Math.abs(o-.5),o>=0&&o<=1?1:0}let r=n(t.x,t.y,t.x2,t.y);return r+=n(t.x,t.y,t.x,t.y2),r>1||(r+=n(t.x,t.y2,t.x2,t.y2),r>1||(r+=n(t.x2,t.y,t.x2,t.y2),r>0))}(n,e)?t+1:t,0)}(n,A);return o*(s+1)*(s+1)0;){const t=o.pop(),n=kz(e,t),s=n?vz(t,n):null;if(!n||!s||2!==s.count){A||i.push(t);continue}let a=r,c=Sz(n,a,s,!0),l=Fz(c,o)||Fz(c,i),u=Mz(c,e);for(;!l&&u&&a>=1;)a/=1.5,c=Sz(n,a,s,!0),l=Fz(c,o)||Fz(c,i),u=Mz(c,e);if(!c||l||u||(o.push(new az(t.x1,t.y1,c.x,c.y)),o.push(new az(c.x,c.y,t.x2,t.y2)),A=!0),A)continue;a=r,c=Sz(n,a,s,!1);let h=Fz(c,o)||Fz(c,i);for(u=Mz(c,e);!h&&u&&a>=1;)a/=1.5,c=Sz(n,a,s,!1),h=Fz(c,o)||Fz(c,i),u=Mz(c,e);c&&!h&&(o.push(new az(t.x1,t.y1,c.x,c.y)),o.push(new az(c.x,c.y,t.x2,t.y2)),A=!0),A||i.push(t)}for(;o.length>0;)i.push(o.pop());return i}(new az(o.x,o.y,A.cx,A.cy),t,r,i);return function(t,e){const n=[];for(;t.length>0;){const r=t.pop();if(0===t.length){n.push(r);break}const i=t.pop(),o=new az(r.x1,r.y1,i.x2,i.y2);kz(e,o)?(n.push(r),t.push(i)):t.push(o)}return n}(s,t)}(e,t,A,n,r)}).flat()}function Mz(t,e){return e.some(e=>e.containsPt(t.x,t.y))}function Fz(t,e){return e.some(e=>!!Az(e.x1,e.y1,t.x,t.y,.001)||!!Az(e.x2,e.y2,t.x,t.y,.001))}function kz(t,e){let n=Number.POSITIVE_INFINITY,r=null;for(const i of t){if(!gz(i,e))continue;const t=pz(i,e);t>=0&&ts.y?xz(t.x-e,t.y-e):xz(t.x2+e,t.y-e):o.yA.x?xz(t.x-e,t.y-e):xz(t.x-e,t.y2+e):i.xs.y?xz(t.x2+e,t.y2+e):xz(t.x-e,t.y2+e):o.yA.x?xz(t.x2+e,t.y2+e):xz(t.x2+e,t.y-e):i.xr)return!1}return!0}function Uz(t,e){switch(t){case-2:return(((3-e)*e-3)*e+1)/6;case-1:return((3*e-6)*e*e+4)/6;case 0:return(((-3*e+3)*e+3)*e+1)/6;case 1:return e*e*e/6;default:throw new Error("unknown error")}}class Nz{constructor(t=[],e=!0){this.points=t,this.closed=e}get(t){const e=t,n=this.points.length;return t<0?this.closed?this.get(t+n):this.points[0]:t>=n?this.closed?this.get(t-n):this.points[n-1]:this.points[e]}get length(){return this.points.length}toString(t=1/0){const e=this.points;if(0===e.length)return"";const n="function"==typeof t?t:function(t){if(!Number.isFinite(t))return t=>t;if(0===t)return Math.round;const e=Math.pow(10,t);return t=>Math.round(t*e)/e}(t);let r="M";for(const t of e)r+=`${n(t.x)},${n(t.y)} L`;return r=r.slice(0,-1),this.closed&&(r+=" Z"),r}draw(t){const e=this.points;if(0!==e.length){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const n of e)t.lineTo(n.x,n.y);this.closed&&t.closePath()}}sample(t){return function(t=8){return e=>{let n=t,r=e.length;if(n>1)for(r=Math.floor(e.length/n);r<3&&n>1;)n-=1,r=Math.floor(e.length/n);const i=[];for(let t=0,o=0;o{if(t<0||e.length<3)return e;const n=[];let r=0;const i=t*t;for(;r{if(n.length<3)return n;const r=[],i=n.closed,o=n.length+3-1+(i?0:2);r.push(e(n,2-(i?0:2),0));for(let A=2-(i?0:2);Ae.containsPt(t.cx,t.cy)&&this.withinArea(t.cx,t.cy))}withinArea(t,e){if(0===this.length)return!1;let n=0;const r=this.points[0],i=new az(r.x,r.y,r.x,r.y);for(let r=1;re?i+o:i}function o(t,e){let n=0;return n=i(t,e,n,1),n=i(t+1,e,n,2),n=i(t,e+1,n,4),n=i(t+1,e+1,n,8),Number.isNaN(n)?-1:n}let A=1;function s(e,n){let i=e,s=n,a=t.invertScaleX(i),c=t.invertScaleY(s);for(let e=0;ePz(e.raw,t));return!(e<0)&&(this.members.splice(e,1),this.dirty.add(Dz.MEMBERS),!0)}removeNonMember(t){const e=this.nonMembers.findIndex(e=>Pz(e.raw,t));return!(e<0)&&(this.nonMembers.splice(e,1),this.dirty.add(Dz.NON_MEMBERS),!0)}removeEdge(t){const e=this.edges.findIndex(e=>e.obj.equals(t));return!(e<0)&&(this.edges.splice(e,1),this.dirty.add(Dz.NON_MEMBERS),!0)}pushNonMember(...t){if(0!==t.length){this.dirty.add(Dz.NON_MEMBERS);for(const e of t)this.nonMembers.push({raw:e,obj:Lz(e)?yz.from(e):mz.from(e),area:null})}}pushEdge(...t){if(0!==t.length){this.dirty.add(Dz.EDGES);for(const e of t)this.edges.push({raw:e,obj:az.from(e),area:null})}}update(){const t=this.dirty.has(Dz.MEMBERS),e=this.dirty.has(Dz.NON_MEMBERS);let n=this.dirty.has(Dz.EDGES);this.dirty.clear();const r=this.members.map(t=>t.obj);if(this.o.virtualEdges&&(t||e)){const t=this.nonMembers.map(t=>t.obj),e=Cz(r,t,this.o.maxRoutingIterations,this.o.morphBuffer),i=new Map(this.virtualEdges.map(t=>[t.obj.toString(),t.area]));this.virtualEdges=e.map(t=>{var e;return{raw:t,obj:t,area:null!==(e=i.get(t.toString()))&&void 0!==e?e:null}}),n=!0}let i=!1;if(t||n){const t=this.virtualEdges.concat(this.edges).map(t=>t.obj),e=function(t,e){if(0===t.length)return new mz(0,0,0,0);const n=mz.from(t[0]);for(const e of t)n.add(e);for(const t of e)n.add(sz(t));return n}(r,t),n=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,o=mz.from(bz(e,n));o.equals(this.activeRegion)||(i=!0,this.activeRegion=o)}if(i){const t=Math.ceil(this.activeRegion.width/this.o.pixelGroup),e=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=wz.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach(t=>t.area=null),this.nonMembers.forEach(t=>t.area=null),this.edges.forEach(t=>t.area=null),this.virtualEdges.forEach(t=>t.area=null)):t===this.potentialArea.width&&e===this.potentialArea.height||(this.potentialArea=wz.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const o=new Map,A=t=>{if(t.area){const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof mz?"R":"C"}`;o.set(e,t.area)}},s=t=>{if(t.area)return;const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof mz?"R":"C"}`;if(o.has(e)){const n=o.get(e);return void(t.area=this.potentialArea.copy(n,{x:t.obj.x-this.o.nodeR1,y:t.obj.y-this.o.nodeR1}))}const n=t.obj instanceof mz?function(t,e,n){const r=e.scale(t),i=e.addPadding(r,n),o=e.createSub(i,{x:t.x-n,y:t.y-n}),A=r.x-i.x,s=r.y-i.y,a=i.x2-r.x2,c=i.y2-r.y2,l=i.width-A-a,u=i.height-s-c,h=n*n;o.fillArea({x:A,y:s,width:l+1,height:u+1},h);const d=[0],f=Math.max(s,A,a,c);{const i=e.invertScaleX(r.x+r.width/2);for(let o=1;o{this.activeRegion.intersects(t.obj)?s(t):t.area=null}),this.edges.forEach(t=>{t.area||(t.area=Bz(t.obj,this.potentialArea,this.o.edgeR1))}),this.virtualEdges.forEach(t=>{t.area||(t.area=Bz(t.obj,this.potentialArea,this.o.edgeR1))})}drawMembers(t){for(const e of this.members)e.obj.draw(t)}drawNonMembers(t){for(const e of this.nonMembers)e.obj.draw(t)}drawEdges(t){for(const e of this.edges)e.obj.draw(t)}drawPotentialArea(t,e=!0){this.potentialArea.draw(t,e)}compute(){if(0===this.members.length)return new Nz([]);this.dirty.size>0&&this.update();const{o:t,potentialArea:e}=this,n=this.members.map(t=>t.area),r=this.virtualEdges.concat(this.edges).map(t=>t.area),i=this.nonMembers.filter(t=>null!=t.area).map(t=>t.area),o=this.members.map(t=>t.obj);return function(t,e,n,r,i,o={}){const A=Object.assign({},Iz,o);let s=A.threshold,a=A.memberInfluenceFactor,c=A.edgeInfluenceFactor,l=A.nonMemberInfluenceFactor;const u=(A.nodeR0-A.nodeR1)*(A.nodeR0-A.nodeR1),h=(A.edgeR0-A.edgeR1)*(A.edgeR0-A.edgeR1);for(let o=0;o0))break;l*=.8}}return new Nz([])}(e,n,r,i,t=>t.containsElements(o),t)}};class Hz extends tz{constructor(t,e){super(t,be({},Hz.defaultOptions,e)),this.path=null,this.members=new Map,this.avoidMembers=new Map,this.bubbleSetOptions={},this.drawBubbleSets=()=>{const{style:t,bubbleSetOptions:e}=this.parseOptions();xe(this.bubbleSetOptions,e)||this.init(),this.bubbleSetOptions=Object.assign({},e);const n=Object.assign(Object.assign({},t),{d:this.getPath()});this.shape?this.shape.update(n):(this.shape=new xw({style:n}),this.context.canvas.appendChild(this.shape))},this.updateBubbleSetsPath=t=>{if(!this.shape)return;const e=Km(t.data);[...this.options.members,...this.options.avoidMembers].includes(e)&&this.shape.update(Object.assign(Object.assign({},this.parseOptions().style),{d:this.getPath(e)}))},this.getPath=t=>{const{graph:e}=this.context,n=this.options.members,r=[...this.members.keys()],i=this.options.avoidMembers,o=[...this.avoidMembers.keys()];if(0===n.length&&0===i.length)return this.members.clear(),this.avoidMembers.clear(),this.path=[],this.path;if(!t&&this.path&&xe(n,r)&&xe(i,o))return this.path;const{enter:A=[],exit:s=[]}=ty(r,n,t=>t),{enter:a=[],exit:c=[]}=ty(o,i,t=>t);if(t){const e=n.includes(t),r=i.includes(t);e&&(s.push(t),A.push(t)),r&&(c.push(t),a.push(t))}const l=(t,n,r)=>{t.forEach(t=>{const i=r?this.members:this.avoidMembers,o=r?"pushMember":"pushNonMember",A=r?"removeMember":"removeNonMember";if(n){let n;"edge"===e.getElementType(t)?([n]=Gz(e,t),this.bubbleSets.pushEdge(n)):([n]=_z(e,t),this.bubbleSets[o](n)),i.set(t,n)}else{const n=i.get(t);n&&("edge"===e.getElementType(t)?this.bubbleSets.removeEdge(n):this.bubbleSets[A](n),i.delete(t))}})};l(s,!1,!0),l(A,!0,!0),l(c,!1,!1),l(a,!0,!1);const u=this.bubbleSets.compute().sample(8).simplify(0).bSplines().simplify(0);return this.path=Ew(u.points.map(Sy)),this.path},this.bindEvents(),this.bubbleSets=new Rz(this.options)}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath)}init(){this.bubbleSets=new Rz(this.options),this.members.clear(),this.avoidMembers.clear(),this.path=null}parseOptions(){const t=this.options,{type:e,key:n,members:r,avoidMembers:i}=t,o=Pe(t,["type","key","members","avoidMembers"]),A=Object.keys(o).reduce((t,e)=>(e in Iz?t.bubbleSetOptions[e]=o[e]:t.style[e]=o[e],t),{style:{},bubbleSetOptions:{}});return Object.assign({type:e,key:n,members:r,avoidMembers:i},A)}addMember(t){const e=Array.isArray(t)?t:[t];e.some(t=>this.options.avoidMembers.includes(t))&&(this.options.avoidMembers=this.options.avoidMembers.filter(t=>!e.includes(t))),this.options.members=[...new Set([...this.options.members,...e])],this.drawBubbleSets()}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter(t=>!e.includes(t)),this.drawBubbleSets()}updateMember(t){this.options.members=Gt(t)?t(this.options.members):t,this.drawBubbleSets()}getMember(){return this.options.members}addAvoidMember(t){const e=Array.isArray(t)?t:[t];e.some(t=>this.options.members.includes(t))&&(this.options.members=this.options.members.filter(t=>!e.includes(t))),this.options.avoidMembers=[...new Set([...this.options.avoidMembers,...e])],this.drawBubbleSets()}removeAvoidMember(t){const e=Array.isArray(t)?t:[t];this.options.avoidMembers.some(t=>e.includes(t))&&(this.options.avoidMembers=this.options.avoidMembers.filter(t=>!e.includes(t)),this.drawBubbleSets())}updateAvoidMember(t){this.options.avoidMembers=Array.isArray(t)?t:[t],this.drawBubbleSets()}getAvoidMember(){return this.options.avoidMembers}destroy(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath),this.shape&&(this.shape.destroy(),this.shape=void 0),super.destroy()}}Hz.defaultOptions=Object.assign({members:[],avoidMembers:[],fill:"lightblue",fillOpacity:.2,stroke:"blue",strokeOpacity:.2},Iz);const _z=(t,e)=>(Array.isArray(e)?e:[e]).map(e=>{const n=t.getElementRenderBounds(e);return new mz(n.min[0],n.min[1],mm(n),ym(n))}),Gz=(t,e)=>(Array.isArray(e)?e:[e]).map(e=>{const n=t.getEdgeData(e),r=t.getElementPosition(n.source),i=t.getElementPosition(n.target);return az.from({x1:r[0],y1:r[1],x2:i[0],y2:i[1]})});class Kz extends tz{constructor(t,e){super(t,Object.assign({},Kz.defaultOptions,e)),this.targetElement=null,this.wheelHandler=t=>{t.stopPropagation()},this.onTriggerEvent=t=>{var e;null===(e=t.preventDefault)||void 0===e||e.call(t),this.show(t)},this.onMenuItemClick=t=>{const{onClick:e,trigger:n}=this.options;if(t.target instanceof HTMLElement&&t.target.className.includes("g6-contextmenu-li")){const n=t.target.getAttribute("value");null==e||e(n,t.target,this.targetElement),this.hide()}"click"!==n&&this.hide()},this.initElement(),this.update(e)}initElement(){this.$element=ez("contextmenu",!1,{zIndex:"99"});const{className:t}=this.options;t&&this.$element.classList.add(t),this.$element.addEventListener("wheel",this.wheelHandler);this.context.canvas.getContainer().appendChild(this.$element),nz("g6-contextmenu-css","style",{},"\n .g6-contextmenu {\n font-size: 12px;\n background-color: rgba(255, 255, 255, 0.96);\n border-radius: 4px;\n overflow-x: hidden;\n overflow-y: auto;\n max-height: calc(100% - 8px);\n box-shadow: rgba(0, 0, 0, 0.12) 0px 6px 12px 0px;\n transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, left 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s, top 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s;\n }\n\n .g6-contextmenu::-webkit-scrollbar {\n width: 6px;\n }\n\n .g6-contextmenu::-webkit-scrollbar-thumb {\n background-color: rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n }\n\n .g6-contextmenu::-webkit-scrollbar-thumb:hover {\n background-color: rgba(0, 0, 0, 0.3);\n }\n\n .g6-contextmenu-ul {\n max-width: 256px;\n min-width: 96px;\n list-style: none;\n padding: 0;\n margin: 0;\n }\n\n .g6-contextmenu-li {\n padding: 8px 12px;\n cursor: pointer;\n user-select: none;\n }\n\n .g6-contextmenu-li:hover {\n background-color: #f5f5f5;\n cursor: pointer;\n }\n",document.head)}show(t){return De(this,void 0,void 0,function*(){const{enable:e,offset:n}=this.options;if("function"==typeof e&&!e(t)||!e)return void this.hide();const r=yield this.getDOMContent(t);r instanceof HTMLElement?(this.$element.innerHTML="",this.$element.appendChild(r)):this.$element.innerHTML=r;const i=this.context.graph.getCanvas().getContainer().getBoundingClientRect();let o=t.client.x-i.left+n[0],A=t.client.y-i.top+n[1];this.$element.style.display="block";const s=this.$element.offsetWidth,a=this.$element.offsetHeight,c=i.width,l=i.height;o=Math.max(4,Math.min(o,c-s-4)),A=Math.max(4,Math.min(A,l-a-4)),this.$element.style.left=`${o}px`,this.$element.style.top=`${A}px`,this.targetElement=t.target})}hide(){this.$element.style.display="none",this.targetElement=null}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy(),this.$element.remove()}getDOMContent(t){return De(this,void 0,void 0,function*(){const{getContent:e,getItems:n}=this.options;return n?`\n
    \n ${(yield n(t)).map(t=>`
  • ${t.name}
  • `).join("")}\n
\n `:yield e(t)})}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`canvas:${e}`,this.onTriggerEvent),t.on(`node:${e}`,this.onTriggerEvent),t.on(`edge:${e}`,this.onTriggerEvent),t.on(`combo:${e}`,this.onTriggerEvent),document.addEventListener("click",this.onMenuItemClick)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`canvas:${e}`,this.onTriggerEvent),t.off(`node:${e}`,this.onTriggerEvent),t.off(`edge:${e}`,this.onTriggerEvent),t.off(`combo:${e}`,this.onTriggerEvent),document.removeEventListener("click",this.onMenuItemClick),this.$element.removeEventListener("wheel",this.wheelHandler)}}Kz.defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'
Loading...
',getContent:()=>"It is a empty context menu.",enable:()=>!0};class jz extends tz{constructor(t,e){super(t,Object.assign({},jz.defaultOptions,e)),this.edgeBundles={},this.edgePoints={},this.onBundle=()=>{const{model:t,element:e}=this.context,n=t.getEdgeData();this.divideEdges(this.options.divisions);const{cycles:r,iterRate:i,divRate:o}=this.options;let{lambda:A,divisions:s,iterations:a}=this.options;for(let t=0;t{var n;if(e.source===e.target)return;const r=Km(e);t[r]=this.getEdgeForces(e,s,A);for(let e=0;e{const n=Km(t),r=e.getElement(n);null==r||r.update({d:dB(this.edgePoints[n])})})},this.bindEvents()}get nodeMap(){const t=this.context.model.getNodeData();return Object.fromEntries(t.map(t=>[Km(t),yy(My(t))]))}divideEdges(t){this.context.model.getEdgeData().forEach(e=>{var n;const r=Km(e);(n=this.edgePoints)[r]||(n[r]=[]);const i=this.nodeMap[e.source],o=this.nodeMap[e.target];if(1===t)this.edgePoints[r].push(i),this.edgePoints[r].push(uy(ay(i,o),2)),this.edgePoints[r].push(o);else{const e=(0===this.edgePoints[r].length?dy(i,o):$z(this.edgePoints[r]))/(t+1);let n=e;const A=[i];for(let t=1;tn;){const t=n/s,r=ay(i,ly(cy(o,i),t));A.push(r),s-=n,n=e}n-=s}A.push(o),this.edgePoints[r]=A}})}getVectorPosition(t){const e=this.nodeMap[t.source],n=this.nodeMap[t.target],[r,i]=cy(n,e);return{source:e,target:n,vx:r,vy:i,length:dy(e,n)}}measureEdgeCompatibility(t,e){const n=this.getVectorPosition(t),r=this.getVectorPosition(e);return zz(n,r)*Vz(n,r)*Wz(n,r)*qz(n,r)}getEdgeBundles(){const t={},e=this.options.bundleThreshold,n=this.context.model.getEdgeData();return n.forEach((r,i)=>{n.forEach((n,o)=>{var A,s;if(o<=i)return;this.measureEdgeCompatibility(r,n)>=e&&(t[A=Km(r)]||(t[A]=[]),t[Km(r)].push(n),t[s=Km(n)]||(t[s]=[]),t[Km(n)].push(r))})}),t}getSpringForce(t,e){const{pre:n,cur:r,next:i}=t;return ly(cy(ay(n,i),ly(r,2)),e)}getElectrostaticForce(t,e){Ee(this.edgeBundles)&&(this.edgeBundles=this.getEdgeBundles());const n=this.edgeBundles[Km(e)];let r=[0,0];return null==n||n.forEach(n=>{const i=this.edgePoints[Km(n)][t],o=this.edgePoints[Km(e)][t],A=cy(i,o),s=dy(i,o);r=ay(r,ly(A,1/s))}),r}getEdgeForces(t,e,n){const r=this.nodeMap[t.source],i=this.nodeMap[t.target],o=this.options.K/(dy(r,i)*(e+1)),A=[[0,0]],s=Km(t);for(let r=1;rMath.abs(function(t,e){return[t,e]=sy(t,e),t.reduce((t,n,r)=>t+n*e[r],0)}([t.vx,t.vy],[e.vx,e.vy])/(t.length*e.length)),Vz=(t,e)=>{const n=(t.length+e.length)/2;return 2/(n/Math.min(t.length,e.length)+Math.max(t.length,e.length)/n)},Wz=(t,e)=>{const n=(t.length+e.length)/2;return n/(n+dy(uy(ay(t.source,t.target),2),uy(ay(e.source,e.target),2)))},Yz=(t,e)=>{if(e.source[0]===e.target[0])return[e.source[0],t[1]];if(e.source[1]===e.target[1])return[t[0],e.source[1]];const n=(e.source[1]-e.target[1])/(e.source[0]-e.target[0]),r=(n*n*e.source[0]+n*(t[1]-e.source[1])+t[0])/(n*n+1);return[r,n*(r-e.source[0])+e.source[1]]},Xz=(t,e)=>{const n=Yz(e.source,t),r=Yz(e.target,t),i=uy(ay(n,r),2),o=uy(ay(t.source,t.target),2);return 0===dy(n,r)?0:Math.max(0,1-2*dy(o,i)/dy(n,r))},qz=(t,e)=>Math.min(Xz(t,e),Xz(e,t)),$z=t=>{let e=0;for(let n=1;n{if("drag"===this.options.trigger&&this.isLensOn)return;const e=Sy(t.canvas);this.renderLens(e),this.renderFocusElements()},this.renderLens=t=>{const e=Object.assign({},Zz,this.options.style);this.isLensOn||(this.lens=new Tw({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,Qy(t),{size:2*this.r}),this.lens.update(e)},this.getFilterData=()=>{const{filter:t}=this.options,{model:e}=this.context,n=e.getData();if(!t)return n;const{nodes:r,edges:i,combos:o}=n;return{nodes:r.filter(e=>t(Km(e),"node")),edges:i.filter(e=>t(Km(e),"edge")),combos:o.filter(e=>t(Km(e),"combo"))}},this.getFocusElements=t=>{const{nodes:e,edges:n}=this.getFilterData(),r=e.filter(e=>dy(My(e),t)Km(t));return{nodes:r,edges:n.filter(t=>{const{source:e,target:n}=t,r=i.includes(e),o=i.includes(n);switch(this.options.nodeType){case"both":return r&&o;case"either":return r!==o;case"source":return r&&!o;case"target":return!r&&o;default:return!1}})}},this.renderFocusElements=()=>{const{element:t,graph:e}=this.context;if(!this.isLensOn)return;const n=this.lens.getCenter(),{nodes:r,edges:i}=this.getFocusElements(n),o=new Set,A=n=>{const r=Km(n);o.add(r);const i=t.getElement(r);if(!i)return;const A=this.shapes.get(r)||i.cloneNode();A.setPosition(i.getPosition()),A.id=i.id,this.shapes.has(r)?Object.entries(i.attributes).forEach(([t,e])=>{A.style[t]!==e&&(A.style[t]=e)}):(this.canvas.appendChild(A),this.shapes.set(r,A));const s=e.getElementType(r),a=this.getElementStyle(s,n);A.update(a)};r.forEach(A),i.forEach(A),this.shapes.forEach((t,e)=>{o.has(e)||(t.destroy(),this.shapes.delete(e))})},this.scaleRByWheel=t=>{var e;this.options.preventDefault&&t.preventDefault();const{clientX:n,clientY:r,deltaX:i,deltaY:o}=t,{graph:A,canvas:s}=this.context,a=A.getCanvasByClient([n,r]),c=null===(e=this.lens)||void 0===e?void 0:e.getCenter();if(!this.isLensOn||dy(a,c)>this.r)return;const{maxR:l,minR:u}=this.options,h=i+o>0?1/.95:.95,d=Math.min(...s.getSize())/2;this.r=Math.max(u||0,Math.min(l||d,this.r*h)),this.renderLens(c),this.renderFocusElements()},this.isLensDragging=!1,this.onDragStart=t=>{var e;const n=Sy(t.canvas),r=null===(e=this.lens)||void 0===e?void 0:e.getCenter();!this.isLensOn||dy(n,r)>this.r||(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=Sy(t.canvas);this.renderLens(e),this.renderFocusElements()},this.onDragEnd=()=>{this.isLensDragging=!1},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}getElementStyle(t,e){const n="node"===t?this.options.nodeStyle:this.options.edgeStyle;return"function"==typeof n?n(e):n}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.addEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.addEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.addEventListener(t.CommonEvent.DRAG,this.onDrag),o.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel,{passive:!1}))}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.removeEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.removeEventListener(t.CommonEvent.DRAG,this.onDrag),o.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel))}update(t){var e;this.unbindEvents(),super.update(t),this.r=null!==(e=t.r)&&void 0!==e?e:this.r,this.bindEvents()}destroy(){this.unbindEvents(),this.isLensOn&&this.lens.destroy(),this.shapes.forEach((t,e)=>{t.destroy(),this.shapes.delete(e)}),super.destroy()}}Jz.defaultOptions={trigger:"pointermove",r:60,nodeType:"both",filter:()=>!0,style:{lineWidth:2},nodeStyle:{label:!1},edgeStyle:{label:!0},scaleRBy:"wheel",preventDefault:!0};const tV={fill:"#ccc",fillOpacity:.1,lineWidth:2,stroke:"#000",strokeOpacity:.8,labelFontSize:12};class eV extends tz{constructor(t,e){super(t,Object.assign({},eV.defaultOptions,e)),this.r=this.options.r,this.d=this.options.d,this.onCreateFisheye=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=Sy(t.canvas);this.onMagnify(e)},this.onMagnify=t=>{t.some(isNaN)||(this.renderLens(t),this.renderFocusElements())},this.renderLens=t=>{const e=Object.assign({},tV,this.options.style);this.isLensOn||(this.lens=new Tw({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,Qy(t),{size:2*this.r,label:this.options.showDPercent,labelText:this.getDPercent()}),this.lens.update(e)},this.getDPercent=()=>{const{minD:t,maxD:e}=this.options;return`${Math.round((this.d-t)/(e-t)*100)}%`},this.prevMagnifiedStyleMap=new Map,this.prevOriginStyleMap=new Map,this.renderFocusElements=()=>{if(!this.isLensOn)return;const{graph:t}=this.context,e=this.lens.getCenter(),n=(this.d+1)*this.r,r=new Map,i=new Map;t.getNodeData().forEach(o=>{const A=My(o),s=dy(A,e);if(s>this.r)return;const a=n*s/(this.d*s+this.r),[c,l]=A,[u,h]=e,d=[u+a*((c-u)/s),h+a*((l-h)/s)],f=Km(o),g=this.getNodeStyle(o),p=ke(t.getElementRenderStyle(f),Object.keys(g));r.set(f,Object.assign(Object.assign({},Qy(d)),g)),i.set(f,Object.assign(Object.assign({},Qy(A)),p))}),this.updateStyle(r,i)},this.getNodeStyle=t=>{const{nodeStyle:e}=this.options;return"function"==typeof e?e(t):e},this.updateStyle=(t,e)=>{const{graph:n,element:r}=this.context,{enter:i,exit:o,keep:A}=ty(Array.from(this.prevMagnifiedStyleMap.keys()),Array.from(t.keys()),t=>t),s=new Set,a=(t,e)=>{const i=r.getElement(t);null==i||i.update(e),n.getRelatedEdgesData(t).forEach(t=>{s.add(Km(t))})};[...i,...A].forEach(e=>{a(e,t.get(e))}),o.forEach(t=>{a(t,this.prevOriginStyleMap.get(t)),this.prevOriginStyleMap.delete(t)}),s.forEach(t=>{const e=r.getElement(t);null==e||e.update({})}),this.prevMagnifiedStyleMap=t,e.forEach((t,e)=>{this.prevOriginStyleMap.has(e)||this.prevOriginStyleMap.set(e,t)})},this.isWheelValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;const{clientX:e,clientY:n}=t;return!(dy(this.context.graph.getCanvasByClient([e,n]),this.lens.getCenter())>this.r)},this.scaleR=t=>{const{maxR:e,minR:n}=this.options,r=t?1/.95:.95,i=Math.min(...this.context.canvas.getSize())/2;this.r=Math.max(n||0,Math.min(e||i,this.r*r))},this.scaleD=t=>{const{maxD:e,minD:n}=this.options,r=t?this.d+.1:this.d-.1;this.d=Math.max(n,Math.min(e,r))},this.scaleRByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleR(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleD(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.isDragValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;return!(dy(Sy(t.canvas),this.lens.getCenter())>this.r)},this.isLensDragging=!1,this.onDragStart=t=>{this.isDragValid(t)&&(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=Sy(t.canvas);this.onMagnify(e)},this.onDragEnd=()=>{this.isLensDragging=!1},this.scaleRByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleR(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleD(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,A=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&A.addEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&A.addEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){A.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),A.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;A.addEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,n,{passive:!1})}}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,A=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&A.removeEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&A.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){A.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),A.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;A.removeEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,n)}}update(t){var e,n;this.unbindEvents(),super.update(t),this.r=null!==(e=t.r)&&void 0!==e?e:this.r,this.d=null!==(n=t.d)&&void 0!==n?n:this.d,this.bindEvents()}destroy(){var t;this.unbindEvents(),this.isLensOn&&(null===(t=this.lens)||void 0===t||t.destroy()),this.prevMagnifiedStyleMap.clear(),this.prevOriginStyleMap.clear(),super.destroy()}}eV.defaultOptions={trigger:"pointermove",r:120,d:1.5,maxD:5,minD:0,showDPercent:!0,style:{},nodeStyle:{label:!0},preventDefault:!0};class nV extends tz{constructor(t,e){super(t,Object.assign({},nV.defaultOptions,e)),this.$el=this.context.canvas.getContainer(),this.graphSize=[0,0],this.onFullscreenChange=()=>{var t,e,n,r;const i=!!document.fullscreenElement;this.options.autoFit&&this.setGraphSize(i),i?null===(e=(t=this.options).onEnter)||void 0===e||e.call(t):null===(r=(n=this.options).onExit)||void 0===r||r.call(n)},this.shortcut=new Wy(t.graph),this.bindEvents(),this.style=document.createElement("style"),document.head.appendChild(this.style),this.style.innerHTML="\n :not(:root):fullscreen::backdrop {\n background: transparent;\n }\n "}bindEvents(){this.unbindEvents(),this.shortcut.unbindAll();const{request:t=[],exit:e=[]}=this.options.trigger;this.shortcut.bind(t,this.request),this.shortcut.bind(e,this.exit);["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach(t=>{document.addEventListener(t,this.onFullscreenChange,!1)})}unbindEvents(){this.shortcut.unbindAll();["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach(t=>{document.removeEventListener(t,this.onFullscreenChange,!1)})}setGraphSize(t=!0){var e,n;let r,i;t?(r=(null===(e=globalThis.screen)||void 0===e?void 0:e.width)||0,i=(null===(n=globalThis.screen)||void 0===n?void 0:n.height)||0,this.graphSize=this.context.graph.getSize()):[r,i]=this.graphSize,this.context.graph.setSize(r,i),this.context.graph.render()}request(){!document.fullscreenElement&&(document.fullscreenEnabled||Reflect.get(document,"webkitFullscreenEnabled")||Reflect.get(document,"mozFullscreenEnabled")||Reflect.get(document,"msFullscreenEnabled"))&&this.$el.requestFullscreen().catch(t=>{Zv(`Error attempting to enable full-screen: ${t.message} (${t.name})`)})}exit(){document.fullscreenElement&&document.exitFullscreen()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.exit(),this.style.remove(),super.destroy()}}nV.defaultOptions={trigger:{},autoFit:!0};class rV extends tz{constructor(t,e){super(t,Object.assign({},rV.defaultOptions,e)),this.$element=ez("grid-line",!0),this.offset=[0,0],this.currentScale=1,this.followZoom=t=>{const{data:{scale:e,origin:n}}=t;if(!e||void 0===n&&void 0===this.context.viewport)return;const r=this.currentScale;this.currentScale=e;const i=e/r,o=ly(n||this.context.graph.getCanvasCenter(),1-i),A=this.baseSize*e,s=ay(my(ly(this.offset,i),A),o);this.$element.style.backgroundSize=`${A}px ${A}px`,this.$element.style.backgroundPosition=`${s[0]}px ${s[1]}px`,this.offset=my(s,A)},this.followTranslate=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)},this.onTransform=t=>{const e=this.parseFollow(this.options.follow);e.zoom&&this.followZoom(t),e.translate&&this.followTranslate(t)};this.context.canvas.getContainer().prepend(this.$element),this.baseSize=this.options.size,this.updateStyle(),this.bindEvents()}update(t){super.update(t),void 0!==t.size&&(this.baseSize=t.size),this.updateStyle()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}updateStyle(){const{stroke:t,lineWidth:e,border:n,borderLineWidth:r,borderStroke:i,borderStyle:o}=this.options,A=this.baseSize*this.currentScale;Object.assign(this.$element.style,{border:n?`${r}px ${o} ${i}`:"none",backgroundImage:`linear-gradient(${t} ${e}px, transparent ${e}px), linear-gradient(90deg, ${t} ${e}px, transparent ${e}px)`,backgroundSize:`${A}px ${A}px`,backgroundRepeat:"repeat"})}updateOffset(t){const e=this.baseSize*this.currentScale;this.offset=my(ay(this.offset,t),e),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}parseFollow(t){var e,n;return ue(t)?{translate:t,zoom:t}:{translate:null!==(e=null==t?void 0:t.translate)&&void 0!==e&&e,zoom:null!==(n=null==t?void 0:t.zoom)&&void 0!==n&&n}}destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}function iV(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach(t=>{const{type:n,value:r}=t,i=Km(r);if("NodeAdded"===n||"EdgeAdded"===n||"ComboAdded"===n)e.Added.set(i,t);else if("NodeUpdated"===n||"EdgeUpdated"===n||"ComboUpdated"===n)if(e.Added.has(i))e.Added.set(i,{type:n.replace("Updated","Added"),value:r});else if(e.Updated.has(i)){const{original:t}=e.Updated.get(i);e.Updated.set(i,{type:n,value:r,original:t})}else e.Removed.has(i)||e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)?e.Added.delete(i):e.Updated.has(i)?(e.Updated.delete(i),e.Removed.set(i,t)):e.Removed.set(i,t))}),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}function oV(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:A=[],ComboAdded:s=[],ComboUpdated:a=[],ComboRemoved:c=[]}=ee(t,t=>t.type);return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:a},remove:{nodes:r,edges:A,combos:c}}}function AV(t,e){for(const n in t)zt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),AV(t[n],e[n])):void 0===e[n]&&(e[n]=nm(n))}function sV(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:A}=oV(iV(t));return["nodes","edges","combos"].forEach(t=>{o[t]&&o[t].forEach(e=>{var i,o;const A=Object.assign({},e.value);let s=Object.assign({},e.original);if(n){const t=n.graph.getElementType(Km(e.original)),r="edge"===t?"stroke":"fill",i=n.element.getElementComputedStyle(t,e.original);s=Object.assign(Object.assign({},e.original),{style:Object.assign({[r]:i[r]},e.original.style)})}AV(A,s),(i=r.current.update)[t]||(i[t]=[]),r.current.update[t].push(A),(o=r.original.update)[t]||(o[t]=[]),r.original.update[t].push(s)}),i[t]&&i[t].forEach(e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.add)[t]||(n[t]=[]),r.current.add[t].push(o),(i=r.original.remove)[t]||(i[t]=[]),r.original.remove[t].push(o)}),A[t]&&A[t].forEach(e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.remove)[t]||(n[t]=[]),r.current.remove[t].push(o),(i=r.original.add)[t]||(i[t]=[]),r.original.add[t].push(o)})}),r}rV.defaultOptions={border:!0,borderLineWidth:1,borderStroke:"#eee",borderStyle:"solid",lineWidth:1,size:20,stroke:"#eee"};class aV extends tz{constructor(e,n){super(e,Object.assign({},aV.defaultOptions,n)),this.batchChanges=null,this.batchAnimation=!1,this.undoStack=[],this.redoStack=[],this.freezed=!1,this.executeCommand=(t,e=!0)=>{var n,r,i;this.freezed=!0,null===(r=(n=this.options).executeCommand)||void 0===r||r.call(n,t);const o=e?t.original:t.current;this.context.graph.addData(o.add),this.context.graph.updateData(o.update),this.context.graph.removeData(zm(o.remove,!1)),null===(i=this.context.element)||void 0===i||i.draw({silence:!0,animation:t.animation}),this.freezed=!1},this.addCommand=e=>{var n;if(!this.freezed){if(e.type===t.GraphEvent.AFTER_DRAW){const{dataChanges:t=[],animation:r=!0}=e.data;if(null===(n=this.context.batch)||void 0===n?void 0:n.isBatching){if(!this.batchChanges)return;return this.batchChanges.push(t),void(this.batchAnimation&&(this.batchAnimation=r))}this.batchChanges=[t],this.batchAnimation=r}this.undoStackPush(sV(this.batchChanges.flat(),this.batchAnimation,this.context)),this.notify(t.HistoryEvent.ADD,this.undoStack[this.undoStack.length-1])}},this.initBatchCommand=t=>{const{initiate:e}=t.data;if(this.batchAnimation=!1,e)this.batchChanges=[];else{this.undoStack.pop()||(this.batchChanges=null)}},this.emitter=new hE;const{graph:r}=this.context;r.on(t.GraphEvent.AFTER_DRAW,this.addCommand),r.on(t.GraphEvent.BATCH_START,this.initBatchCommand),r.on(t.GraphEvent.BATCH_END,this.addCommand)}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}undo(){var e,n,r,i;const o=this.undoStack.pop();if(o){this.executeCommand(o);if(!1===(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,o,!1)))return;this.redoStack.push(o),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,o,!1),this.notify(t.HistoryEvent.UNDO,o)}return this}redo(){const e=this.redoStack.pop();return e&&(this.executeCommand(e,!1),this.undoStackPush(e),this.notify(t.HistoryEvent.REDO,e)),this}undoAndCancel(){const e=this.undoStack.pop();return e&&(this.executeCommand(e,!1),this.redoStack=[],this.notify(t.HistoryEvent.CANCEL,e)),this}undoStackPush(t){var e,n,r,i;const{stackSize:o}=this.options;0!==o&&this.undoStack.length>=o&&this.undoStack.shift();!1!==(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,t,!0))&&(this.undoStack.push(t),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,t,!0))}clear(){this.undoStack=[],this.redoStack=[],this.batchChanges=null,this.batchAnimation=!1,this.notify(t.HistoryEvent.CLEAR,null)}notify(e,n){this.emitter.emit(e,{cmd:n}),this.emitter.emit(t.HistoryEvent.CHANGE,{cmd:n})}on(t,e){this.emitter.on(t,e)}destroy(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.addCommand),e.off(t.GraphEvent.BATCH_START,this.initBatchCommand),e.off(t.GraphEvent.BATCH_END,this.addCommand),this.emitter.off(),super.destroy(),this.undoStack=[],this.redoStack=[]}}aV.defaultOptions={stackSize:0};const cV={toXy(t,e){if(!e)return[...t];const n=e[0].slice(1),r=e[1].slice(1);return t.map(t=>[t[n],t[r]])},fromXy(t,e){if(!e)return[...t];const n=e[0].slice(1),r=e[1].slice(1);return t.map(([t,e])=>({[n]:t,[r]:e}))}};let lV=class{constructor(t,e){this._cells=[],this._cellSize=e,this._reverseCellSize=1/e;for(const e of t){const t=this.coordToCellNum(e[0]),n=this.coordToCellNum(e[1]);this._cells[t]||(this._cells[t]=[]),this._cells[t][n]||(this._cells[t][n]=[]),this._cells[t][n].push(e)}}cellPoints(t,e){var n;return(null===(n=this._cells[t])||void 0===n?void 0:n[e])||[]}rangePoints(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this.coordToCellNum(t[2]),i=this.coordToCellNum(t[3]),o=[];for(let t=e;t<=r;t++)for(let e=n;e<=i;e++){const n=this.cellPoints(t,e);for(const t of n)o.push(t)}return o}removePoint(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this._cells[e][n],i=r.findIndex(([e,n])=>e===t[0]&&n===t[1]);return i>-1&&r.splice(i,1),r}trunc(t){return Math.trunc(t)}coordToCellNum(t){return this.trunc(t*this._reverseCellSize)}extendBbox(t,e){return[t[0]-e*this._cellSize,t[1]-e*this._cellSize,t[2]+e*this._cellSize,t[3]+e*this._cellSize]}};const uV=+(Math.pow(2,27)+1);function hV(t,e,n){const r=t*e,i=uV*t,o=i-(i-t),A=t-o,s=uV*e,a=s-(s-e),c=e-a,l=A*c-(r-o*a-A*a-o*c);return n?(n[0]=l,n[1]=r,n):[l,r]}function dV(t,e,n){const r=t+e,i=r-t,o=e-i,A=t-(r-i);return n?(n[0]=A+o,n[1]=r,n):[A+o,r]}function fV(t,e){const n=t.length;if(1===n){const n=hV(t[0],e);return n[0]?n:[n[1]]}const r=new Array(2*n),i=[.1,.1],o=[.1,.1];let A=0;hV(t[0],e,i),i[0]&&(r[A++]=i[0]);for(let s=1;s=r?(c=u,A+=1,A=r?(c=u,A+=1,A0){if(i<=0)return o;A=r+i}else{if(!(r<0))return o;if(i>=0)return o;A=-(r+i)}const s=33306690738754716e-32*A;return o>=s||o<=-s?o:bV(t,e,n)},function(t,e,n,r){const i=t[0]-r[0],o=e[0]-r[0],A=n[0]-r[0],s=t[1]-r[1],a=e[1]-r[1],c=n[1]-r[1],l=t[2]-r[2],u=e[2]-r[2],h=n[2]-r[2],d=o*c,f=A*a,g=A*s,p=i*c,v=i*a,m=o*s,y=l*(d-f)+u*(g-p)+h*(v-m),w=7771561172376103e-31*((Math.abs(d)+Math.abs(f))*Math.abs(l)+(Math.abs(g)+Math.abs(p))*Math.abs(u)+(Math.abs(v)+Math.abs(m))*Math.abs(h));return y>w||-y>w?y:BV(t,e,n,r)}];function xV(t){let e=EV[t.length];return e||(e=EV[t.length]=wV(t.length)),e.apply(void 0,...t)}var CV=function(){for(;EV.length<=5;)EV.push(wV(EV.length));const t=function(t,e,n,r,i,o,A){return function(...e){switch(e.length){case 0:case 1:return 0;case 2:return r(e[0],e[1]);case 3:return i(e[0],e[1],e[2]);case 4:return o(e[0],e[1],e[2],e[3]);case 5:return A(e[0],e[1],e[2],e[3],e[4])}return t(e)}}(void 0,xV,...EV);for(let e=0;e<=5;++e)t[e]=EV[e];return t}();const MV=CV[3];function FV(t,e,n,r){const i=CV(t,n,r),o=CV(e,n,r);if(i>0&&o>0||i<0&&o<0)return!1;const A=CV(n,t,e),s=CV(r,t,e);return!(A>0&&s>0||A<0&&s<0)&&(0!==i||0!==o||0!==A||0!==s||function(t,e,n,r){for(let i=0;i<2;++i){const o=t[i],A=e[i],[s,a]=[Math.min(o,A),Math.max(o,A)],c=n[i],l=r[i],[u,h]=[Math.min(c,l),Math.max(c,l)];if(hA&&i>s&&!QV([t[0],e[a]],n)&&!QV([t[1],e[a]],n)&&(A=r,s=i,o=e[a]);return o}function TV(t,e,n,r,i){let o=!1;for(let A=0;Ac||n[1]>l));c>=n[0]&&l>=n[1]&&i.add(a),null!==u&&(t.splice(A+1,0,u),r.removePoint(u),o=!0)}return o?TV(t,e,n,r,i):t}function OV(t,e,n){const r=e||20,i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r=0;o--)t[o][0]r&&(r=t[o][0]),t[o][1]>i&&(i=t[o][1]);return[r-e,i-n]}(i),A=[o[0]*LV,o[1]*LV],s=function(t){const e=t.length;if(e<3){const n=new Array(e);for(let t=0;tt[e][0]-t[n][0]||t[e][1]-t[n][1]);const r=[n[0],n[1]],i=[n[0],n[1]];for(let o=2;o1&&MV(t[r[s-2]],t[r[s-1]],A)<=0;)s-=1,r.pop();for(r.push(e),s=i.length;s>1&&MV(t[i[s-2]],t[i[s-1]],A)>=0;)s-=1,i.pop();i.push(e)}const o=new Array(i.length+r.length-2);let A=0;for(let t=0,e=r.length;t0;--t)o[A++]=i[t];return o}(i).reverse().map(t=>i[t]);s.push(s[0]);const a=i.filter(function(t){return s.indexOf(t)<0}),c=Math.ceil(1/(i.length/(o[0]*o[1]))),l=TV(s,Math.pow(r,2),A,function(t,e){return new lV(t,e)}(a,c),new Set);return n?cV.fromXy(l,n):l}const IV=Math.cos(90/(180/Math.PI)),LV=.6;const PV=(t,e,n)=>{if("sharp"===n)return[["M",t[0]-e,t[1]-e],["L",t[0]+e,t[1]-e],["L",t[0]+e,t[1]+e],["L",t[0]-e,t[1]+e],["Z"]];const r=[e,e,0,0,0];return[["M",t[0],t[1]-e],["A",...r,t[0],t[1]+e],["A",...r,t[0],t[1]-e]]},DV=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?ay(t[0],hy(gy(cy(t[0],t[1])),e)):t[0],o="sharp"===n?ay(t[1],hy(gy(cy(t[1],t[0])),e)):t[1],A=hy(gy(vy(cy(i,o),!1)),e),s=hy(A,-1),a=ay(i,A),c=ay(o,A),l=ay(o,s),u=ay(i,s);return"sharp"===n?[["M",a[0],a[1]],["L",c[0],c[1]],["L",l[0],l[1]],["L",u[0],u[1]],["Z"]]:[["M",a[0],a[1]],["L",c[0],c[1]],["A",...r,l[0],l[1]],["L",u[0],u[1]],["A",...r,a[0],a[1]]]},RV=(t,e)=>{const n=_y(t).map((n,r)=>{const i=(r-2+t.length)%t.length,o=(r-1+t.length)%t.length,A=(r+1)%t.length,s=t[i],a=t[o],c=t[A],l=cy(s,a),u=cy(a,n),h=cy(n,c),d=(t,e)=>py(t,e,!0)hy(gy(vy(t,!1)),e),v=p(u);return[{p:yy(ay(a,f?p(l):v)),concave:f&&a},{p:yy(ay(n,g?p(h):v)),concave:g&&n}]}),r=[e,e,0,0,0],i=n.findIndex((t,e)=>!(n[(e-1+n.length)%n.length][0].concave||n[(e-1+n.length)%n.length][1].concave||t[0].concave||t[0].concave||t[1].concave)),o=n.slice(i).concat(n.slice(0,i));let A=[];return o.flatMap((t,e)=>{const i=[],s=o[n.length-1];return 0===e&&i.push(["M",...s[1].p]),t[0].concave?A.push(t[0].p,t[1].p):i.push(["A",...r,...t[0].p]),t[1].concave?A.unshift(t[1].p):i.push(["L",...t[1].p]),3===A.length&&(i.pop(),i.push(["C",...A.flat()]),A=[]),i})},HV=(t,e)=>{const n=_y(t).map((e,n)=>({p:e,v:gy(cy(t[(n+1)%t.length],e))}));return n.forEach((r,i)=>{const o=i>0?i-1:t.length-1,A=n[o].v,s=gy(ay(A,hy(r.v,py(A,r.v,!0)t.p))},_V=(t,e)=>{const n=t.map((n,r)=>{const i=t[0===r?t.length-1:r-1],o=wy(hy(gy(vy(cy(i,n),!1)),e));return[ay(i,o),ay(n,o)]}),r=n.flat(),i=r.map((t,e)=>{if(e%2==0)return null;return xy([r[(e-1)%r.length],r[e%r.length]],[r[(e+1)%r.length],r[(e+2)%r.length]],!0)}).filter(Boolean);return i.map((t,e)=>[0===e?"M":"L",t[0],t[1]]).concat([["Z"]])};class GV extends tz{constructor(t,e){super(t,Object.assign({},GV.defaultOptions,e)),this.hullMemberIds=[],this.drawHull=()=>{if(this.shape){const t=!xe(this.optionsCache,this.options);this.shape.update(this.getHullStyle(t))}else this.shape=new xw({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape);this.optionsCache=Object.assign({},this.options)},this.updateHullPath=t=>{this.shape&&this.options.members.includes(Km(t.data))&&this.shape.update({d:this.getHullPath(!0)})},this.getHullPath=(t=!1)=>{const{graph:e}=this.context,n=this.getMember();if(0===n.length)return"";const r=n.map(t=>e.getNodeData(t)),i=OV(r.map(My),this.options.concavity).slice(1).reverse(),o=i.flatMap(t=>r.filter(e=>xe(My(e),t)).map(Km));return xe(o,this.hullMemberIds)&&!t||(this.hullMemberIds=o,this.path=function(t,e,n){if(1===t.length)return PV(t[0],e,n);if(2===t.length)return DV(t,e,n);if(3===t.length){const[r,i,o]=_y(t);if(Iy(r,i,o))return DV([r,o],e,n)}switch(n){case"smooth":return HV(t,e);case"sharp":return _V(t,e);default:return RV(t,e)}}(i,this.getPadding(),this.options.corner)),this.path},this.bindEvents()}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}unbindEvents(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}getHullStyle(t){const e=this.options,{members:n,padding:r,corner:i}=e,o=Pe(e,["members","padding","corner"]);return Object.assign(Object.assign({},o),{d:this.getHullPath(t)})}getPadding(){const{graph:t}=this.context,e=this.hullMemberIds.reduce((e,n)=>{const{halfExtents:r}=t.getElementRenderBounds(n),i=Math.max(r[0],r[1]);return Math.max(e,i)},0);return e+this.options.padding}addMember(t){const e=Array.isArray(t)?t:[t];this.options.members=[...new Set([...this.options.members,...e])],this.shape.update({d:this.getHullPath()})}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter(t=>!e.includes(t)),e.some(t=>this.hullMemberIds.includes(t))&&this.shape.update({d:this.getHullPath()})}updateMember(t){this.options.members=Gt(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}getMember(){return this.options.members}destroy(){this.unbindEvents(),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function KV(t,e){e(t),t.children&&t.children.forEach(function(t){t&&KV(t,e)})}function jV(t){VV(t,!0)}function zV(t){VV(t,!1)}function VV(t,e){var n=e?"visible":"hidden";KV(t,function(t){t.attr("visibility",n)})}GV.defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",fillOpacity:.2,labelOpacity:1,stroke:"blue",strokeOpacity:.2};var WV=function(t){function e(){for(var e=[],n=0;n=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom},t}();function JV(t,e){return Gt(t)?t.apply(void 0,_e([],He(e),!1)):t}var tW,eW=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map(function(t){var e=He(t,2),r=e[0],i=e[1],o=n(i);return[r,{name:o,class:".".concat(o),id:"#".concat(o),toString:function(){return o}}]}));return Object.assign(r,{prefix:n}),r},nW=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach(function(i){var o=He(i,2),A=o[0],s=o[1],a=t;Object.prototype.hasOwnProperty.call(e,A)&&(s?qt(s)?(qt(t[A])||(a[A]={}),ne&&t="A"&&n<="Z"};function PW(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach(function(t){var i=He(t,2),o=i[0],A=i[1];if("className"===o||"class"===o);else if(LW(o,"show")&&LW(IW(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(OW(t))}(e,"show")?r[o]=A:r[o.replace(new RegExp(OW(e)),"")]=A;else if(!LW(o,"show")&&LW(o,e)!==n){var s=IW(o,e);"filter"===s&&"function"==typeof A||(r[s]=A)}}),r}function DW(t,e){return Object.entries(t).reduce(function(t,n){var r=He(n,2),i=r[0],o=r[1];return i.startsWith("show")?t["show".concat(e).concat(i.slice(4))]=o:t["".concat(e).concat(OW(i))]=o,t},{})}function RW(t,e){void 0===e&&(e=["x","y","class","className"]);var n=["transform","transformOrigin","anchor","visibility","pointerEvents","zIndex","cursor","clipPath","clipPathTargets","offsetPath","offsetPathTargets","offsetDistance","draggable","droppable"],r={},i={};return Object.entries(t).forEach(function(t){var o=He(t,2),A=o[0],s=o[1];e.includes(A)||(-1!==n.indexOf(A)?i[A]=s:r[A]=s)}),[r,i]}function HW(t,e){var n={YYYY:t.getFullYear(),MM:t.getMonth()+1,DD:t.getDate(),HH:t.getHours(),mm:t.getMinutes(),ss:t.getSeconds()},r=e;return Object.keys(n).forEach(function(t){var e=n[t];r=r.replace(t,"YYYY"===t?"".concat(e):"".concat(e).padStart(2,"0"))}),r}function _W(t,e){if(e)try{var n=e.replace(/translate\(([+-]*[\d]+[%]*),[ ]*([+-]*[\d]+[%]*)\)/g,function(e,n,r){return"translate(".concat(function(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,A=He([e,n].map(function(t,e){var n;return t.includes("%")?parseFloat((null===(n=t.match(/[+-]?([0-9]*[.])?[0-9]+/))||void 0===n?void 0:n[0])||"0")/100*(0===e?i:o):t}),2);return[A[0],A[1]]}(t,n,r),")")});t.attr("transform",n)}catch(t){}}var GW=function(t,e){null!=e?t.replaceChildren?Array.isArray(e)?t.replaceChildren.apply(t,_e([],He(e),!1)):t.replaceChildren(e):(t.innerHTML="",Array.isArray(e)?e.forEach(function(e){return t.appendChild(e)}):t.appendChild(e)):t.innerHTML=""};function KW(t){return/\S+-\S+/g.test(t)?t.split("-").map(function(t){return t[0]}):t.length>2?[t[0]]:t.split("")}function jW(){VV(this,"hidden"!==this.attributes.visibility)}var zW=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,rW({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return Ie(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=YV(this)),this._offscreen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultOptions",{get:function(){return this._defaultOptions},enumerable:!1,configurable:!0}),e.prototype.connectedCallback=function(){this.render(this.attributes,this),this.bindEvents(this.attributes,this),this.initialized=!0},e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e.prototype.attributeChangedCallback=function(t){"visibility"===t&&jW.call(this)},e.prototype.update=function(t,e){var n;return this.attr(rW({},this.attributes,t||{})),null===(n=this.render)||void 0===n?void 0:n.call(this,this.attributes,this,e)},e.prototype.clear=function(){this.removeChildren()},e.prototype.bindEvents=function(t,e){},e.prototype.getSubShapeStyle=function(t){return t.x,t.y,t.transform,t.transformOrigin,t.class,t.className,t.zIndex,Pe(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(Wa),VW=function(t,e,n){return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"]]},WW=VW,YW=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},XW=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},qW=XW;var $W=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function ZW(t){var e=function(t){var e="default";if(zt(t)&&t instanceof Image)e="image";else if(Gt(t))e="symbol";else if(Jt(t)){var n=new RegExp("data:(image|text)");e=t.match(n)?"base64":/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(t)?"url":"symbol"}return e}(t);return["base64","url","image"].includes(e)?"image":t&&"symbol"===e?"path":null}var JW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,n){var r=t.x,i=void 0===r?0:r,o=t.y,A=void 0===o?0:o,s=this.getSubShapeStyle(t),a=s.symbol,c=s.size,l=void 0===c?16:c,u=Pe(s,["symbol","size"]),h=ZW(a);hW(!!h,QW(n),function(t){t.maybeAppendByClassName("marker",h).attr("className","marker ".concat(h,"-marker")).call(function(t){if("image"===h){var n=2*l;t.styles({img:a,width:n,height:n,x:i-l,y:A-l})}else{n=l/2;var r=Gt(a)?a:e.getSymbol(a);t.styles(Le({d:null==r?void 0:r(i,A,n)},u))}})})},e.MARKER_SYMBOL_MAP=new Map,e.registerSymbol=function(t,n){e.MARKER_SYMBOL_MAP.set(t,n)},e.getSymbol=function(t){return e.MARKER_SYMBOL_MAP.get(t)},e.getSymbols=function(){return Array.from(e.MARKER_SYMBOL_MAP.keys())},e}(zW);function tY(t,...e){return e.reduce((t,e)=>n=>t(e(n)),t)}function eY(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}JW.registerSymbol("cross",function(t,e,n){return[["M",t-n,e-n],["L",t+n,e+n],["M",t+n,e-n],["L",t-n,e+n]]}),JW.registerSymbol("hyphen",function(t,e,n){return[["M",t-n,e],["L",t+n,e]]}),JW.registerSymbol("line",YW),JW.registerSymbol("plus",function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]}),JW.registerSymbol("tick",function(t,e,n){return[["M",t-n/2,e-n],["L",t+n/2,e-n],["M",t,e-n],["L",t,e+n],["M",t-n/2,e+n],["L",t+n/2,e+n]]}),JW.registerSymbol("circle",VW),JW.registerSymbol("point",WW),JW.registerSymbol("bowtie",function(t,e,n){var r=n-1.5;return[["M",t-n,e-r],["L",t+n,e+r],["L",t+n,e-r],["L",t-n,e+r],["Z"]]}),JW.registerSymbol("hexagon",function(t,e,n){var r=n/2*Math.sqrt(3);return[["M",t,e-n],["L",t+r,e-n/2],["L",t+r,e+n/2],["L",t,e+n],["L",t-r,e+n/2],["L",t-r,e-n/2],["Z"]]}),JW.registerSymbol("square",function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]}),JW.registerSymbol("diamond",function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]}),JW.registerSymbol("triangle",function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+r],["L",t,e-r],["L",t+n,e+r],["Z"]]}),JW.registerSymbol("triangle-down",function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-r],["L",t+n,e-r],["L",t,e+r],["Z"]]}),JW.registerSymbol("line",YW),JW.registerSymbol("dot",XW),JW.registerSymbol("dash",qW),JW.registerSymbol("smooth",function(t,e,n){return[["M",t-n,e],["A",n/2,n/2,0,1,1,t,e],["A",n/2,n/2,0,1,0,t+n,e]]}),JW.registerSymbol("hv",function(t,e,n){return[["M",t-n-1,e-2.5],["L",t,e-2.5],["L",t,e+2.5],["L",t+n+1,e+2.5]]}),JW.registerSymbol("vh",function(t,e,n){return[["M",t-n-1,e+2.5],["L",t,e+2.5],["L",t,e-2.5],["L",t+n+1,e-2.5]]}),JW.registerSymbol("hvh",function(t,e,n){return[["M",t-(n+1),e+2.5],["L",t-n/2,e+2.5],["L",t-n/2,e-2.5],["L",t+n/2,e-2.5],["L",t+n/2,e+2.5],["L",t+n+1,e+2.5]]}),JW.registerSymbol("vhv",function(t,e){return[["M",t-5,e+2.5],["L",t-5,e],["L",t,e],["L",t,e-3],["L",t,e+3],["L",t+6.5,e+3]]}),JW.registerSymbol("focus",function(t,e,n){var r=.2*n,i=.7*n;return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"],["M",t-i,e],["L",t-r,e],["M",t+r,e],["L",t+i,e],["M",t,e-i],["L",t,e-r],["M",t,e+r],["L",t,e+i]]});const nY=Math.sqrt(50),rY=Math.sqrt(10),iY=Math.sqrt(2);function oY(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),o=r/10**i;return i>=0?(o>=nY?10:o>=rY?5:o>=iY?2:1)*10**i:-(10**-i)/(o>=nY?10:o>=rY?5:o>=iY?2:1)}const AY=(t,e,n=5)=>{const r=[t,e];let i,o=0,A=r.length-1,s=r[o],a=r[A];return a0?(s=Math.floor(s/i)*i,a=Math.ceil(a/i)*i,i=oY(s,a,n)):i<0&&(s=Math.ceil(s*i)/i,a=Math.floor(a*i)/i,i=oY(s,a,n)),i>0?(r[o]=Math.floor(s/i)*i,r[A]=Math.ceil(a/i)*i):i<0&&(r[o]=Math.ceil(s*i)/i,r[A]=Math.floor(a*i)/i),r};function sY(t){return!(de(t)||(e=t,null===e)||Number.isNaN(t));var e}var aY={exports:{}},cY={exports:{}},lY=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},uY=Array.prototype.concat,hY=Array.prototype.slice,dY=cY.exports=function(t){for(var e=[],n=0,r=t.length;n=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},wY.to.keyword=function(t){return mY[t.slice(0,3)]};var EY=y(aY.exports);function xY(t,e,n){let r=n;return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function CY(t){const e=EY.get(t);if(!e)return null;const{model:n,value:r}=e;return"rgb"===n?r:"hsl"===n?function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100,i=t[3];if(0===n)return[255*r,255*r,255*r,i];const o=r<.5?r*(1+n):r+n-r*n,A=2*r-o;return[255*xY(A,o,e+1/3),255*xY(A,o,e),255*xY(A,o,e-1/3),i]}(r):null}const MY=(t,e)=>n=>t*(1-n)+e*n,FY=(t,e)=>"number"==typeof t&&"number"==typeof e?MY(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=CY(t),r=CY(e);return null===n||null===r?n?()=>t:()=>e:t=>{const e=new Array(4);for(let i=0;i<4;i+=1){const o=n[i],A=r[i];e[i]=o*(1-t)+A*t}const[i,o,A,s]=e;return`rgba(${Math.round(i)}, ${Math.round(o)}, ${Math.round(A)}, ${s})`}})(t,e):()=>t,kY=(t,e)=>{const n=MY(t,e);return t=>Math.round(n(t))};function SY({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function QY(t){return"object"==typeof t?t.valueOf():t}class UY extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=QY,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(SY({map:this.map,initKey:this.initKey},t))}has(t){return super.has(SY({map:this.map,initKey:this.initKey},t))}set(t,e){return super.set(function({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}({map:this.map,initKey:this.initKey},t),e)}delete(t){return super.delete(function({map:t,initKey:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}({map:this.map,initKey:this.initKey},t))}}class NY{constructor(t){this.options=be({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=be({},this.options,t),this.rescale(t)}rescale(t){}}const TY=Symbol("defaultUnknown");function OY(t,e,n){for(let r=0;r`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class PY extends NY{getDefaultOptions(){return{domain:[],range:[],unknown:TY}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&OY(this.domainIndexMap,this.getDomain(),this.domainKey),IY({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&OY(this.rangeIndexMap,this.getRange(),this.rangeKey),IY({value:this.rangeKey(t),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(t){const[e]=this.options.domain,[n]=this.options.range;if(this.domainKey=LY(e),this.rangeKey=LY(n),!this.rangeIndexMap)return this.rangeIndexMap=new Map,void(this.domainIndexMap=new Map);t&&!t.range||this.rangeIndexMap.clear(),(!t||t.domain||t.compare)&&(this.domainIndexMap.clear(),this.sortedDomain=void 0)}clone(){return new PY(this.options)}getRange(){return this.options.range}getDomain(){if(this.sortedDomain)return this.sortedDomain;const{domain:t,compare:e}=this.options;return this.sortedDomain=e?[...t].sort(e):t,this.sortedDomain}}function DY(t){return Math.round(1e12*t)/1e12}function RY(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:A,align:s}=t,a=e.length,c=function(t,e){const n=e-t.length;return n>0?[...t,...new Array(n).fill(1)]:n<0?t.slice(0,e):t}(o,a),[l,u]=n,h=u-l,d=h/(2/a*r+1-1/a*i),f=d*i/a,g=d-a*f,p=function(t){const e=Math.min(...t);return t.map(t=>t/e)}(c),v=g/p.reduce((t,e)=>t+e),m=new UY(e.map((t,e)=>{const n=p[e]*v;return[t,A?Math.floor(n):n]})),y=new UY(e.map((t,e)=>{const n=p[e]*v+f;return[t,A?Math.floor(n):n]})),w=Array.from(y.values()).reduce((t,e)=>t+e),b=l+(h-(w-w/a*i))*s;let B=A?Math.round(b):b;const E=new Array(a);for(let t=0;t0?t:e}getPaddingOuter(){const{padding:t,paddingOuter:e}=this.options;return t>0?t:e}rescale(){super.rescale();const{align:t,domain:e,range:n,round:r,flex:i}=this.options,{adjustedRange:o,valueBandWidth:A,valueStep:s}=function(t){var e;const{domain:n}=t,r=n.length;if(0===r)return{valueBandWidth:void 0,valueStep:void 0,adjustedRange:[]};if(null===(e=t.flex)||void 0===e?void 0:e.length)return RY(t);const{range:i,paddingOuter:o,paddingInner:A,round:s,align:a}=t;let c,l,u=i[0];const h=i[1]-u,d=2*o,f=r-A;c=h/Math.max(1,d+f),s&&(c=Math.floor(c)),u+=(h-c*(r-A))*a,l=c*(1-A),s&&(u=Math.round(u),l=Math.round(l));const g=new Array(r).fill(0).map((t,e)=>u+e*c);return{valueStep:c,valueBandWidth:l,adjustedRange:g}}({align:t,range:n,round:r,flex:i,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:e});this.valueStep=s,this.valueBandWidth=A,this.adjustedRange=o}}const _Y=(t,e,n)=>{let r,i,o=t,A=e;if(o===A&&n>0)return[o];let s=oY(o,A,n);if(0===s||!Number.isFinite(s))return[];if(s>0){o=Math.ceil(o/s),A=Math.floor(A/s),i=new Array(r=Math.ceil(A-o+1));for(let t=0;t{const[r,i]=t,[o,A]=e;let s,a;return r{const r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),A=t[0]>t[r],s=A?[...t].reverse():t,a=A?[...e].reverse():e;for(let t=0;t{const n=function(t,e,n,r){let i=n,o=r||t.length;const A=t=>t;for(;ie?o=n:i=n+1}return i}(t,e,1,r)-1,A=i[n];return tY(o[n],A)(e)}},jY=(t,e,n,r)=>(Math.min(t.length,e.length)>2?KY:GY)(t,e,r?kY:n);class zY extends NY{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:MY,tickCount:5}}map(t){return sY(t)?this.output(t):this.options.unknown}invert(t){return sY(t)?this.input(t):this.options.unknown}nice(){if(!this.options.nice)return;const[t,e,n,...r]=this.getTickMethodOptions();this.options.domain=this.chooseNice()(t,e,n,...r)}getTicks(){const{tickMethod:t}=this.options,[e,n,r,...i]=this.getTickMethodOptions();return t(e,n,r,...i)}getTickMethodOptions(){const{domain:t,tickCount:e}=this.options;return[t[0],t[t.length-1],e]}chooseNice(){return AY}rescale(){this.nice();const[t,e]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t)),this.composeInput(t,e,this.chooseClamp(e))}chooseClamp(t){const{clamp:e,range:n}=this.options,r=this.options.domain.map(t),i=Math.min(r.length,n.length);return e?function(t,e){const n=ee?t:e;return t=>Math.min(Math.max(n,t),r)}(r[0],r[i-1]):Te}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,A=jY(n.map(t),r,o,i);this.output=tY(A,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=jY(i,r.map(t),MY);this.input=tY(e,n,o)}}class VY extends zY{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:FY,tickMethod:_Y,tickCount:5}}chooseTransforms(){return[Te,Te]}clone(){return new VY(this.options)}}var WY=function(t){function e(e){var n=this,r=e.style,i=Pe(e,["style"]);return(n=t.call(this,be({},{type:"column"},Le({style:r},i)))||this).columnsGroup=new Xa({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return Ie(e,t),e.prototype.render=function(){var t=this.attributes,e=t.columns,n=t.x,r=t.y;this.columnsGroup.style.transform="translate(".concat(n,", ").concat(r,")"),QW(this.columnsGroup).selectAll(".column").data(e.flat()).join(function(t){return t.append("rect").attr("className","column").each(function(t){this.attr(t)})},function(t){return t.each(function(t){this.attr(t)})},function(t){return t.remove()})},e.prototype.update=function(t){this.attr(rW({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(ja),YY=function(t){function e(e){var n=this,r=e.style,i=Pe(e,["style"]);return(n=t.call(this,be({},{type:"lines"},Le({style:r},i)))||this).linesGroup=n.appendChild(new Xa),n.areasGroup=n.appendChild(new Xa),n.render(),n}return Ie(e,t),e.prototype.render=function(){var t=this.attributes,e=t.lines,n=t.areas,r=t.x,i=t.y;this.style.transform="translate(".concat(r,", ").concat(i,")"),e&&this.renderLines(e),n&&this.renderAreas(n)},e.prototype.clear=function(){this.linesGroup.removeChildren(),this.areasGroup.removeChildren()},e.prototype.update=function(t){this.attr(rW({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){QW(this.linesGroup).selectAll(".line").data(t).join(function(t){return t.append("path").attr("className","line").each(function(t){this.attr(t)})},function(t){return t.each(function(t){this.attr(t)})},function(t){return t.remove()})},e.prototype.renderAreas=function(t){QW(this.linesGroup).selectAll(".area").data(t).join(function(t){return t.append("path").attr("className","area").each(function(t){this.attr(t)})},function(t){return t.each(function(t){this.style(t)})},function(t){return t.remove()})},e}(ja);function XY(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map(function(t,e){return _e([e===n?"M":"L"],He(t),!1)});return e?r.reverse():r}function qY(t,e){if(void 0===e&&(e=!1),t.length<=2)return XY(t);for(var n=[],r=t.length,i=0;i=0?(s[a]+=i[a],i[a]=s[a]):(s[a]+=o[a],o[a]=s[a]);return e}var tX=function(t){function e(e){return t.call(this,e,{type:"line",x:0,y:0,width:200,height:20,isStack:!1,color:["#83daad","#edbf45","#d2cef9","#e290b3","#6f63f4"],smooth:!0,lineLineWidth:1,areaOpacity:0,isGroup:!1,columnLineWidth:1,columnStroke:"#fff",scale:1,spacing:0})||this}return Ie(e,t),Object.defineProperty(e.prototype,"rawData",{get:function(){var t=this.attributes.data;if(!t||0===(null==t?void 0:t.length))return[[]];var e=ge(t);return re(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?JY(this.rawData):this.rawData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scales",{get:function(){return this.createScales(this.data)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseline",{get:function(){var t=this.scales.y,e=He(t.getOptions().domain||[0,0],2),n=e[0],r=e[1];return r<0?t.map(r):t.map(n<0?0:n)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"containerShape",{get:function(){var t=this.attributes;return{width:t.width,height:t.height}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesStyle",{get:function(){var t=this,e=this.attributes,n=e.type,r=e.isStack,i=e.smooth;if("line"!==n)throw new Error("linesStyle can only be used in line type");var o=PW(this.attributes,"area"),A=PW(this.attributes,"line"),s=this.containerShape.width,a=this.data;if(0===a[0].length)return{lines:[],areas:[]};var c=this.scales,l=function(t,e){var n,r=e.x,i=e.y,o=He(i.getOptions().range||[0,0],2),A=o[0],s=o[1];return s>A&&(n=He([A,s],2),s=n[0],A=n[1]),t.map(function(t){return t.map(function(t,e){return[r.map(e),ne(i.map(t),s,A)]})})}(a,{x:c.x,y:c.y}),u=[];if(o){var h=this.baseline;u=r?i?function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=t[i],A=qY(o),s=void 0;if(0===i)s=$Y(A,e,n);else{var a=qY(t[i-1],!0),c=o[0];a[0][0]="L",s=_e(_e(_e([],He(A),!1),He(a),!1),[_e(["M"],He(c),!1),["Z"]],!1)}r.push(s)}return r}(l,s,h):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=XY(t[i]),A=void 0;if(0===i)A=$Y(o,e,n);else{var s=XY(t[i-1],!0);s[0][0]="L",A=_e(_e(_e([],He(o),!1),He(s),!1),[["Z"]],!1)}r.push(A)}return r}(l,s,h):function(t,e,n,r){return t.map(function(t){return $Y(e?qY(t):XY(t),n,r)})}(l,i,s,h)}return{lines:l.map(function(e,n){return Le({stroke:t.getColor(n),d:i?qY(e):XY(e)},A)}),areas:u.map(function(e,n){return Le({d:e,fill:t.getColor(n)},o)})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=PW(this.attributes,"column"),n=this.attributes,r=n.isStack,i=n.type,o=n.scale;if("column"!==i)throw new Error("columnsStyle can only be used in column type");var A=this.containerShape.height,s=this.rawData;if(!s)return{columns:[]};r&&(s=JY(s));var a=this.createScales(s),c=a.x,l=a.y,u=He(ZY(s),2),h=u[0],d=u[1],f=new VY({domain:[0,d-(h>0?0:h)],range:[0,A*o]}),g=c.getBandWidth(),p=this.rawData;return{columns:s.map(function(n,i){return n.map(function(n,o){var A=g/s.length;return Le(Le({fill:t.getColor(i)},e),r?{x:c.map(o),y:l.map(n),width:g,height:f.map(p[i][o])}:{x:c.map(o)+A*i,y:n>=0?l.map(n):l.map(0),width:A,height:f.map(Math.abs(n))})})})}},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){var n,r,i;(n=e,r=".container",i="rect",n.querySelector(r)?QW(n).select(r):QW(n).append(i)).attr("className","container").node();var o=t.type,A=t.x,s=t.y,a="spark".concat(o),c=Le({x:A,y:s},"line"===o?this.linesStyle:this.columnsStyle);QW(e).selectAll(".spark").data([o]).join(function(t){return t.append(function(t){return"line"===t?new YY({className:a,style:c}):new WY({className:a,style:c})}).attr("className","spark ".concat(a))},function(t){return t.update(c)},function(t){return t.remove()})},e.prototype.getColor=function(t){var e=this.attributes.color;return jt(e)?e[t%e.length]:Gt(e)?e.call(null,t):e},e.prototype.createScales=function(t){var e,n,r=this.attributes,i=r.type,o=r.scale,A=r.range,s=void 0===A?[]:A,a=r.spacing,c=this.containerShape,l=c.width,u=c.height,h=He(ZY(t),2),d=h[0],f=h[1],g=new VY({domain:[null!==(e=s[0])&&void 0!==e?e:d,null!==(n=s[1])&&void 0!==n?n:f],range:[u,u*(1-o)]});return"line"===i?{type:i,x:new VY({domain:[0,t[0].length-1],range:[0,l]}),y:g}:{type:i,x:new HY({domain:t[0].map(function(t,e){return e}),range:[0,l],paddingInner:a,paddingOuter:a/2,align:.5}),y:g}},e.tag="sparkline",e}(zW);function eX(t){if(!t)return{enter:!1,update:!1,exit:!1};var e=["enter","update","exit"],n=Object.fromEntries(Object.entries(t).filter(function(t){var n=He(t,1)[0];return!e.includes(n)}));return Object.fromEntries(e.map(function(e){return function(t){return"boolean"!=typeof t&&"enter"in t&&"update"in t&&"exit"in t}(t)?!1===t[e]?[e,!1]:[e,Le(Le({},t[e]),n)]:[e,n]}))}function nX(t,e){t?t.finished.then(e):e()}function rX(t,e){"update"in t?t.update(e):t.attr(e)}function iX(t,e,n){return 0===e.length?null:n?t.animate(e,n):(rX(t,{style:e.slice(-1)[0]}),null)}function oX(t,e,n){var r={},i={};return Object.entries(e).forEach(function(e){var n=He(e,2),o=n[0],A=n[1];if(!Kt(A)){var s=t.style[o]||t.parsedStyle[o]||0;s!==A&&(r[o]=s,i[o]=A)}}),n?iX(t,[r,i],Le({fill:"both"},n)):(rX(t,i),null)}function AX(t,e){return t.style.opacity||(t.style.opacity=1),oX(t,{opacity:0},e)}var sX={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},aX={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},cX={x:0,y:0,orientation:"horizontal",showLabel:!0,type:"start"},lX=eW({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),uX=eW({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),hX=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,e){var n=t.x,r=t.y,i=t.size,o=void 0===i?10:i,A=t.radius,s=void 0===A?o/4:A,a=t.orientation,c=t.classNamePrefix,l=Pe(t,["x","y","size","radius","orientation","classNamePrefix"]),u=o,h=2.4*u,d=c?"".concat(uX.iconRect.name," ").concat(c,"handle-icon-rect"):uX.iconRect.name,f=function(t){return c?"".concat(uX.iconLine,"-").concat(t," ").concat(c,"handle-icon-line"):"".concat(uX.iconLine,"-").concat(t)},g=QW(e).maybeAppendByClassName(uX.iconRect,"rect").attr("className",d).styles(Le(Le({},l),{width:u,height:h,radius:s,x:n-u/2,y:r-h/2,transformOrigin:"center"})),p=n+1/3*u-u/2,v=n+2/3*u-u/2,m=r+1/4*h-h/2,y=r+3/4*h-h/2;g.maybeAppendByClassName("".concat(uX.iconLine,"-1"),"line").attr("className",f(1)).styles(Le({x1:p,x2:p,y1:m,y2:y},l)),g.maybeAppendByClassName("".concat(uX.iconLine,"-2"),"line").attr("className",f(2)).styles(Le({x1:v,x2:v,y1:m,y2:y},l)),"vertical"===a&&(g.node().style.transform="rotate(90)")},e}(zW),dX=function(t){function e(e){return t.call(this,e,cX)||this}return Ie(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.x,i=n.y,o=n.showLabel,A=PW(this.attributes,"label"),s=A.x,a=void 0===s?0:s,c=A.y,l=void 0===c?0:c,u=A.transform,h=A.transformOrigin,d=He(RW(Pe(A,["x","y","transform","transformOrigin"]),[]),2),f=d[0],g=d[1],p=QW(t).maybeAppendByClassName(uX.labelGroup,"g").styles(g),v=Le(Le({},aX),f),m=v.text,y=Pe(v,["text"]);hW(!!o,p,function(t){e.label=t.maybeAppendByClassName(uX.label,"text").styles(Le(Le({},y),{x:r+a,y:i+l,transform:u,transformOrigin:h,text:"".concat(m)})),e.label.on("mousedown",function(t){t.stopPropagation()}),e.label.on("touchstart",function(t){t.stopPropagation()})})},e.prototype.renderIcon=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.orientation,o=e.type,A=e.classNamePrefix,s=Le(Le({x:n,y:r,orientation:i,classNamePrefix:A},sX),PW(this.attributes,"icon")),a=this.attributes.iconShape,c=void 0===a?function(){return new hX({style:s})}:a;QW(t).maybeAppendByClassName(uX.iconGroup,"g").selectAll(uX.icon.class).data([c]).join(function(t){return t.append("string"==typeof c?c:function(){return c(o)}).attr("className",uX.icon.name)},function(t){return t.update(s)},function(t){return t.remove()})},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(zW),fX=function(t){function e(e){var n=t.call(this,e,Le(Le(Le({x:0,y:0,animate:{duration:100,fill:"both"},brushable:!0,formatter:function(t){return t.toString()},handleSpacing:2,orientation:"horizontal",padding:0,autoFitLabel:!0,scrollable:!0,selectionFill:"#5B8FF9",selectionFillOpacity:.45,selectionZIndex:2,showHandle:!0,showLabel:!0,slidable:!0,trackFill:"#416180",trackLength:200,trackOpacity:.05,trackSize:20,trackZIndex:-1,values:[0,1],type:"range",selectionType:"select",handleIconOffset:0},DW(cX,"handle")),DW(sX,"handleIcon")),DW(aX,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(lW(e));var r=n.availableSpace,i=r.x,o=r.y,A=n.getBBox(),s=A.x,a=A.y;n.selectionStartPos=n.getRatio(n.prevPos-n.getOrientVal([i,o])-n.getOrientVal([+s,+a])),n.selectionWidth=0,document.addEventListener("pointermove",n.onDragging),document.addEventListener("pointerup",n.onDragEnd)}},n.onDragging=function(t){var e=n.attributes,r=e.slidable,i=e.brushable,o=e.type;t.stopPropagation();var A=n.getOrientVal(lW(t)),s=A-n.prevPos;if(s){var a=n.getRatio(s);switch(n.target){case"start":r&&n.setValuesOffset(a);break;case"end":r&&n.setValuesOffset(0,a);break;case"selection":r&&n.setValuesOffset(a,a);break;case"track":if(!i)return;n.selectionWidth+=a,"range"===o?n.innerSetValues([n.selectionStartPos,n.selectionStartPos+n.selectionWidth].sort(),!0):n.innerSetValues([0,n.selectionStartPos+n.selectionWidth],!0)}n.prevPos=A}},n.onDragEnd=function(){document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointerup",n.onDragEnd),n.target="",n.updateHandlesPosition(!1)},n.onValueChange=function(t){var e=n.attributes,r=e.onChange,i=e.type,o="range"===i?t:t[1],A="range"===i?n.getValues():n.getValues()[1],s=new Vs("valuechange",{detail:{oldValue:o,value:A}});n.dispatchEvent(s),null==r||r(A)},n.selectionStartPos=0,n.selectionWidth=0,n.prevPos=0,n.target="",n}return Ie(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return this.attributes.values},set:function(t){this.attributes.values=this.clampValues(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sparklineStyle",{get:function(){if("horizontal"!==this.attributes.orientation)return null;var t=PW(this.attributes,"sparkline");return Le(Le({zIndex:0},this.availableSpace),t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t=this.attributes,e=t.trackLength,n=t.trackSize,r=He(this.getOrientVal([[e,n],[n,e]]),2);return{width:r[0],height:r[1]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes;t.x,t.y;var e=He(UW(t.padding),4),n=e[0],r=e[1],i=e[2],o=e[3],A=this.shape;return{x:o,y:n,width:A.width-(o+r),height:A.height-(n+i)}},enumerable:!1,configurable:!0}),e.prototype.getValues=function(){return this.values},e.prototype.setValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1),this.attributes.values=t;var n=!1!==e&&this.attributes.animate;this.updateSelectionArea(n),this.updateHandlesPosition(n)},e.prototype.updateSelectionArea=function(t){var e=this.calcSelectionArea();this.foregroundGroup.selectAll(lX.selection.class).each(function(n,r){oX(this,e[r],t)})},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&oX(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&oX(this.endHandle,this.getHandleStyle("end"),t))},e.prototype.innerSetValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1);var n=this.values,r=this.clampValues(t);this.attributes.values=r,this.setValues(r),e&&this.onValueChange(n)},e.prototype.renderTrack=function(t){var e=this.attributes,n=e.x,r=e.y,i=PW(this.attributes,"track");this.trackShape=QW(t).maybeAppendByClassName(lX.track,"rect").styles(Le(Le({x:n,y:r},this.shape),i))},e.prototype.renderBrushArea=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.brushable;this.brushArea=QW(t).maybeAppendByClassName(lX.brushArea,"rect").styles(Le({x:n,y:r,fill:"transparent",cursor:i?"crosshair":"default"},this.shape))},e.prototype.renderSparkline=function(t){var e=this,n=this.attributes,r=n.x,i=n.y;hW("horizontal"===n.orientation,QW(t).maybeAppendByClassName(lX.sparklineGroup,"g"),function(t){var n=Le(Le({},e.sparklineStyle),{x:r,y:i});t.maybeAppendByClassName(lX.sparkline,function(){return new tX({style:n})}).update(n)})},e.prototype.renderHandles=function(){var t,e=this,n=this.attributes,r=n.showHandle,i=n.type,o=r?"range"===i?["start","end"]:["end"]:[],A=this;null===(t=this.foregroundGroup)||void 0===t||t.selectAll(lX.handle.class).data(o.map(function(t){return{type:t}}),function(t){return t.type}).join(function(t){return t.append(function(t){var n=t.type;return new dX({style:e.getHandleStyle(n)})}).each(function(t){var e=t.type;this.attr("class","".concat(lX.handle.name," ").concat(e,"-handle"));var n="".concat(e,"Handle");A[n]=this,this.addEventListener("pointerdown",A.onDragStart(e))})},function(t){return t.each(function(t){var e=t.type;this.update(A.getHandleStyle(e))})},function(t){return t.each(function(t){var e=t.type,n="".concat(e,"Handle");A[n]=void 0}).remove()})},e.prototype.renderSelection=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.type,o=e.selectionType;this.foregroundGroup=QW(t).maybeAppendByClassName(lX.foreground,"g");var A=PW(this.attributes,"selection"),s=function(t){return t.style("visibility",function(t){return t.show?"visible":"hidden"}).style("cursor",function(t){return"select"===o?"grab":"invert"===o?"crosshair":"default"}).styles(Le(Le({},A),{transform:"translate(".concat(n,", ").concat(r,")")}))},a=this;this.foregroundGroup.selectAll(lX.selection.class).data("value"===i?[]:this.calcSelectionArea().map(function(t,e){return{style:Le({},t),index:e,show:"select"===o?1===e:1!==e}}),function(t){return t.index}).join(function(t){return t.append("rect").attr("className",lX.selection.name).call(s).each(function(t,e){var n=this;1===e?(a.selectionShape=QW(this),this.on("pointerdown",function(t){n.attr("cursor","grabbing"),a.onDragStart("selection")(t)}),a.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),a.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),a.dispatchCustomEvent(this,"click","selectionClick"),this.addEventListener("pointerdown",function(){n.attr("cursor","grabbing")}),this.addEventListener("pointerup",function(){n.attr("cursor","pointer")}),this.addEventListener("pointerover",function(){n.attr("cursor","pointer")})):this.on("pointerdown",a.onDragStart("track"))})},function(t){return t.call(s)},function(t){return t.remove()}),this.updateSelectionArea(!1),this.renderHandles()},e.prototype.render=function(t,e){this.renderTrack(e),this.renderSparkline(e),this.renderBrushArea(e),this.renderSelection(e)},e.prototype.clampValues=function(t,e){var n;void 0===e&&(e=4);var r=He(this.range,2),i=r[0],o=r[1],A=He(this.getValues().map(function(t){return BW(t,e)}),2),s=A[0],a=A[1],c=He(((Array.isArray(t)?t:[s,null!=t?t:a])||[s,a]).map(function(t){return BW(t,e)}),2),l=c[0],u=c[1];if("value"===this.attributes.type)return[0,ne(u,i,o)];l>u&&(l=(n=He([u,l],2))[0],u=n[1]);var h=u-l;return h>o-i?[i,o]:lo?a===o&&s===l?[l,o]:[o-h,o]:[l,u]},e.prototype.calcSelectionArea=function(t){var e=He(this.clampValues(t),2),n=e[0],r=e[1],i=this.availableSpace,o=i.x,A=i.y,s=i.width,a=i.height;return this.getOrientVal([[{y:A,height:a,x:o,width:n*s},{y:A,height:a,x:n*s+o,width:(r-n)*s},{y:A,height:a,x:r*s,width:(1-r)*s}],[{x:o,width:s,y:A,height:n*a},{x:o,width:s,y:n*a+A,height:(r-n)*a},{x:o,width:s,y:r*a,height:(1-r)*a}]])},e.prototype.calcHandlePosition=function(t){var e=this.attributes.handleIconOffset,n=this.availableSpace,r=n.x,i=n.y,o=n.width,A=n.height,s=He(this.clampValues(),2),a=s[0],c=s[1],l="start"===t?-e:e,u=("start"===t?a:c)*this.getOrientVal([o,A])+l;return{x:r+this.getOrientVal([u,o/2]),y:i+this.getOrientVal([A/2,u])}},e.prototype.inferTextStyle=function(t){return"horizontal"===this.attributes.orientation?{}:"start"===t?{transformOrigin:"left center",transform:"rotate(90)",textAlign:"start"}:"end"===t?{transformOrigin:"right center",transform:"rotate(90)",textAlign:"end"}:{}},e.prototype.calcHandleText=function(t){var e,n=this.attributes,r=n.type,i=n.orientation,o=n.formatter,A=n.autoFitLabel,s=PW(this.attributes,"handle"),a=PW(s,"label"),c=s.spacing,l=this.getHandleSize(),u=this.clampValues(),h=o("start"===t?u[0]:u[1]),d=new XV({style:Le(Le(Le({},a),this.inferTextStyle(t)),{text:h})}),f=d.getBBox(),g=f.width,p=f.height;if(d.destroy(),!A){if("value"===r)return{text:h,x:0,y:-p-c};var v=c+l+("horizontal"===i?g/2:0);return(e={text:h})["horizontal"===i?"x":"y"]="start"===t?-v:v,e}var m=0,y=0,w=this.availableSpace,b=w.width,B=w.height,E=this.calcSelectionArea()[1],x=E.x,C=E.y,M=E.width,F=E.height,k=c+l;if("horizontal"===i){var S=k+g/2;if("start"===t)m=x-k-g>0?-S:S;else m=b-x-M-k>g?S:-S}else{var Q=p+k;y="start"===t?C-l>p?-Q:k:B-(C+F)-l>p?Q:-k}return{x:m,y:y,text:h}},e.prototype.getHandleLabelStyle=function(t){var e=PW(this.attributes,"handleLabel");return Le(Le(Le({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=PW(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return Le({cursor:n,shape:t,size:r},e)},e.prototype.getHandleStyle=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.showLabel,o=e.showLabelOnInteraction,A=e.orientation,s=this.calcHandlePosition(t),a=s.x,c=s.y,l=this.calcHandleText(t),u=i;return!i&&o&&(u=!!this.target),Le(Le(Le({},DW(this.getHandleIconStyle(),"icon")),DW(Le(Le({},this.getHandleLabelStyle(t)),l),"label")),{transform:"translate(".concat(a+n,", ").concat(c+r,")"),orientation:A,showLabel:u,type:t,zIndex:3})},e.prototype.getHandleSize=function(){var t=this.attributes,e=t.handleIconSize,n=t.width,r=t.height;return e||Math.floor((this.getOrientVal([+r,+n])+4)/2.4)},e.prototype.getOrientVal=function(t){var e=He(t,2),n=e[0],r=e[1];return"horizontal"===this.attributes.orientation?n:r},e.prototype.setValuesOffset=function(t,e){void 0===e&&(e=0);var n=this.attributes.type,r=He(this.getValues(),2),i=[r[0]+("range"===n?t:0),r[1]+e].sort();this.innerSetValues(i,!0)},e.prototype.getRatio=function(t){var e=this.availableSpace,n=e.width,r=e.height;return t/this.getOrientVal([n,r])},e.prototype.dispatchCustomEvent=function(t,e,n){var r=this;t.on(e,function(t){t.stopPropagation(),r.dispatchEvent(new Vs(n,{detail:t}))})},e.prototype.bindEvents=function(){this.addEventListener("wheel",this.onScroll);var t=this.brushArea;this.dispatchCustomEvent(t,"click","trackClick"),this.dispatchCustomEvent(t,"pointerenter","trackMouseenter"),this.dispatchCustomEvent(t,"pointerleave","trackMouseleave"),t.on("pointerdown",this.onDragStart("track"))},e.prototype.onScroll=function(t){if(this.attributes.scrollable){var e=t.deltaX,n=t.deltaY||e,r=this.getRatio(n);this.setValuesOffset(r,r)}},e.tag="slider",e}(zW),gX="grid-group",pX="main-group",vX="line-group",mX="tick-group",yX="label-group",wX="title-group",bX="grid",BX="line",EX="line-first",xX="line-second",CX="tick",MX="tick-item",FX="label",kX="label-item",SX="title",QX={data:[],animate:{enter:!1,update:{duration:100,easing:"ease-in-out-sine",fill:"both"},exit:{duration:100,fill:"both"}},showArrow:!0,showGrid:!0,showLabel:!0,showLine:!0,showTick:!0,showTitle:!0,showTrunc:!1,dataThreshold:100,lineLineWidth:1,lineStroke:"black",crossPadding:10,titleFill:"black",titleFontSize:12,titlePosition:"lb",titleSpacing:0,titleTextAlign:"center",titleTextBaseline:"middle",lineArrow:function(){return new nc({style:{d:[["M",10,10],["L",-10,0],["L",10,-10],["L",0,0],["L",10,10],["Z"]],fill:"black",transformOrigin:"center"}})},labelAlign:"parallel",labelDirection:"positive",labelFontSize:12,labelSpacing:0,gridConnect:"line",gridControlAngles:[],gridDirection:"positive",gridLength:0,gridType:"segment",lineArrowOffset:15,lineArrowSize:10,tickDirection:"positive",tickLength:5,tickLineWidth:1,tickStroke:"black",labelOverlap:[]};be({},QX,{style:{type:"arc"}}),be({},QX,{style:{}});var UX=eW({mainGroup:pX,gridGroup:gX,grid:bX,lineGroup:vX,line:BX,tickGroup:mX,tick:CX,tickItem:MX,labelGroup:yX,label:FX,labelItem:kX,titleGroup:wX,title:SX,lineFirst:EX,lineSecond:xX},"axis"),NX=eW({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function TX(t){return t.reduce(function(t,e,n){return t.push(_e([0===n?"M":"L"],He(e),!1)),t},[])}function OX(t,e,n){return"surround"===e.type?function(t,e,n){var r=e.connect,i=void 0===r?"line":r,o=e.center;if("line"===i)return TX(t);if(!o)return[];var A=wW(t[0],o),s=n?0:1;return t.reduce(function(t,e,n){return 0===n?t.push(_e(["M"],He(e),!1)):t.push(_e(["A",A,A,0,0,s],He(e),!1)),t},[])}(t,e,n):TX(t)}function IX(t,e,n){var r=n.type,i=n.connect,o=n.center,A=n.closed?[["Z"]]:[],s=He([OX(t,n),OX(e.slice().reverse(),n,!0)],2),a=s[0],c=s[1],l=He([t[0],e.slice(-1)[0]],2),u=l[0],h=l[1],d=function(t,e){return[a,t,c,e,A].flat()};if("line"===i||"surround"===r)return d([_e(["L"],He(h),!1)],[_e(["L"],He(u),!1)]);if(!o)throw new Error("Arc grid need to specified center");var f=He([wW(h,o),wW(u,o)],2),g=f[0],p=f[1];return d([_e(["A",g,g,0,0,1],He(h),!1),_e(["L"],He(h),!1)],[_e(["A",p,p,0,0,0],He(u),!1),_e(["L"],He(u),!1)])}var LX=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Pe(t,["type","center","areaFill","closed"]),r=function(t){var e=t.data,n=void 0===e?[]:e;return t.closed?n.map(function(t){var e=t.points,n=He(e,1)[0];return Le(Le({},t),{points:_e(_e([],He(e),!1),[n],!1)})}):n}(t),i=QW(e).maybeAppendByClassName(NX.lineGroup,"g"),o=QW(e).maybeAppendByClassName(NX.regionGroup,"g"),A=function(t,e,n,r){var i=n.animate,o=n.isBillboard,A=e.map(function(t,e){return{id:t.id||"grid-line-".concat(e),d:OX(t.points,n)}});return t.selectAll(NX.line.class).data(A,function(t){return t.id}).join(function(t){return t.append("path").each(function(t,e){var n=JV(FW(Le({d:t.d},r)),[t,e,A]);this.attr(Le({class:NX.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))})},function(t){return t.transition(function(t,e){return oX(this,JV(FW(Le({d:t.d},r)),[t,e,A]),i.update)})},function(t){return t.transition(function(){var t=this,e=AX(this,i.exit);return nX(e,function(){return t.remove()}),e})}).transitions()}(i,r,t,n),s=function(t,e,n){var r=n.animate,i=n.connect,o=n.areaFill;if(e.length<2||!o||!i)return[];for(var A=Array.isArray(o)?o:[o,"transparent"],s=function(t){return A[t%A.length]},a=[],c=0;c180?1:0,b=t>e?0:1;return"M".concat(f,",").concat(g,",A").concat(s,",").concat(a,",0,").concat(w,",").concat(b,",").concat(v,",").concat(m)}function qX(t,e,n,r){var i=e.startAngle,o=e.endAngle,A=e.center,s=e.radius,a=e.classNamePrefix;return t.selectAll(UX.line.class).data([{d:XX.apply(void 0,_e(_e([i,o],He(A),!1),[s],!1))}],function(t,e){return e}).join(function(t){var n=t.append("path").attr("className",UX.line.name).styles(e).styles({d:function(t){return t.d}});return jX(n,UX.line,BX,a),n},function(t){return t.transition(function(){var t=this,e=function(t,e,n,r){if(!r)return t.attr("__keyframe_data__",n),null;var i=r.duration,o=void 0===i?0:i,A=fW(e,n),s=Math.ceil(+o/16),a=new Array(s).fill(0).map(function(t,e,n){return{__keyframe_data__:A(e/(n.length-1))}});return t.animate(a,Le({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return _e(_e([n,r],He(i),!1),[o],!1)}(this),_e(_e([i,o],He(A),!1),[s],!1),r.update);if(e){var n=function(){var e=Ce(t.attributes,"__keyframe_data__");t.style.d=XX.apply(void 0,_e([],He(e),!1))};e.onframe=n,e.onfinish=n}return e}).styles(e)},function(t){return t.remove()}).styles(n).transitions()}function $X(t){var e=He(t,2),n=He(e[0],2),r=n[0],i=n[1],o=He(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function ZX(t,e,n,r){var i=e.showTrunc,o=e.startPos,A=e.endPos,s=e.truncRange,a=e.lineExtension,c=e.classNamePrefix,l=He([o,A],2),u=He(l[0],2),h=u[0],d=u[1],f=He(l[1],2),g=f[0],p=f[1],v=He(a?function(t,e,n){void 0===n&&(n=[0,0]);var r=He([t,e,n],3),i=He(r[0],2),o=i[0],A=i[1],s=He(r[1],2),a=s[0],c=s[1],l=He(r[2],2),u=l[0],h=l[1],d=He([a-o,c-A],2),f=d[0],g=d[1],p=Math.sqrt(Math.pow(f,2)+Math.pow(g,2)),v=He([-u/p,h/p],2),m=v[0],y=v[1];return[m*f,m*g,y*f,y*g]}(o,A,a):new Array(4).fill(0),4),m=v[0],y=v[1],w=v[2],b=v[3],B=function(e){return t.selectAll(UX.line.class).data(e,function(t,e){return e}).join(function(t){var e=t.append("line").styles(n).transition(function(t){return oX(this,$X(t.line),!1)});return e.attr("className",function(t){if(!c)return"".concat(UX.line.name," ").concat(t.className);var e=KX(UX.line.name,BX,c);if(t.className===UX.lineFirst.name){var n=KX(UX.lineFirst.name,EX,c);return"".concat(e," ").concat(n)}if(t.className===UX.lineSecond.name){n=KX(UX.lineSecond.name,xX,c);return"".concat(e," ").concat(n)}return e}),e},function(t){return t.styles(n).transition(function(t){return oX(this,$X(t.line),r.update)})},function(t){return t.remove()}).transitions()};if(!i||!s)return B([{line:[[h+m,d+y],[g+w,p+b]],className:UX.line.name}]);var E=He(s,2),x=E[0],C=E[1],M=g-h,F=p-d,k=He([h+M*x,d+F*x],2),S=k[0],Q=k[1],U=He([h+M*C,d+F*C],2),N=U[0],T=U[1],O=B([{line:[[h+m,d+y],[S,Q]],className:UX.lineFirst.name},{line:[[N,T],[g+w,p+b]],className:UX.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),O}function JX(t,e,n){var r,i=e.type,o=PW(e,"line");return r="linear"===i?ZX(t,e,EW(o,"arrow"),n):qX(t,e,EW(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,A=n.showTrunc,s=n.lineArrow,a=n.lineArrowOffset,c=n.lineArrowSize;if(i="arc"===e?t.select(UX.line.class):A?t.select(UX.lineSecond.class):t.select(UX.line.class),!o||!s||"arc"===n.type&&YX(n.startAngle,n.endAngle)){var l=i.node();l&&(l.style.markerEnd=void 0)}else{var u=uW(s);u.attr(r),kW(u,c),i.style("markerEnd",u).style("markerEndOffset",-a)}}(t,i,e,o),r}function tq(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function eq(t,e){var n=e.gridLength;return t.map(function(t,r){var i=t.value,o=He(zX(i,e),2),A=o[0],s=o[1],a=He(gW(function(t,e){return _X(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[A,s],[A+a[0],s+a[1]]]}})}function nq(t,e,n,r){var i=n.classNamePrefix,o=PW(n,"grid"),A=o.type,s=o.areaFill,a=tq(n),c=DX(e,n.gridFilter),l="segment"===A?eq(c,n):function(t,e){var n=e.gridControlAngles,r=tq(e);if(!r)throw new Error("grid center is not provide");if(t.length<2)throw new Error("Invalid grid data");if(!n||0===n.length)throw new Error("Invalid gridControlAngles");var i=He(r,2),o=i[0],A=i[1];return t.map(function(t,r){var i=He(zX(t.value,e),2),s=i[0],a=i[1],c=He([s-o,a-A],2),l=c[0],u=c[1],h=[];return n.forEach(function(t){var e=qV(t),n=He([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=l*r-u*i+o,a=l*i+u*r+A;h.push([s,a])}),{points:h,id:r}})}(c,n),u=Le(Le({},o),{center:a,areaFill:Gt(s)?c.map(function(t,e){return JV(s,[t,e,c])}):s,animate:r,data:l});return t.selectAll(UX.grid.class).data([1]).join(function(t){var e=t.append(function(){return new LX({style:u})}).attr("className",UX.grid.name);return jX(e,UX.grid,bX,i),e},function(t){return t.transition(function(){return this.update(u)})},function(t){return t.remove()}).transitions()}var rq=function(){function t(t,e,n,r){this.set(t,e,n,r)}return Object.defineProperty(t.prototype,"left",{get:function(){return this.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this.defined("x2")&&this.defined("x1")?this.x2-this.x1:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.defined("y2")&&this.defined("y1")?this.y2-this.y1:void 0},enumerable:!1,configurable:!0}),t.prototype.rotatedPoints=function(t,e,n){var r=this,i=r.x1,o=r.y1,A=r.x2,s=r.y2,a=Math.cos(t),c=Math.sin(t),l=e-e*a+n*c,u=n-e*c-n*a;return[[a*i-c*s+l,c*i+a*s+u],[a*A-c*s+l,c*A+a*s+u],[a*i-c*o+l,c*i+a*o+u],[a*A-c*o+l,c*A+a*o+u]]},t.prototype.set=function(t,e,n,r){return n0,p=r-a,v=i-c,m=l*v-u*p;if(m<0===g)return!1;var y=h*v-d*p;return y<0!==g&&m>f!==g&&y>f!==g}(e,t)})}function lq(t,e,n){var r,i,o=e.crossPadding,A=new Set,s=null,a=function(t,e){var n=t.type,r=t.labelDirection,i=t.crossSize;if(!i)return!1;if("arc"===n){var o=t.center,A=t.radius,s=He(o,2),a=s[0],c=s[1],l="negative"===r?0:i,u=-A-l,h=A+l,d=He(UW(e),4),f=d[0],g=d[1],p=d[2],v=d[3];return new rq(a+u-v,c+u-f,a+h+g,c+h+p)}var m=He(t.startPos,2),y=m[0],w=m[1],b=He(t.endPos,2),B=b[0],E=b[1],x=He(WX(t)?[-e,0,e,0]:[0,e,0,-e],4),C=x[0],M=x[1],F=x[2],k=x[3],S=gW(GX(0,t),i),Q=new rq(y,w,B,E);return Q.x1+=k,Q.y1+=C,Q.x2+=M+S[0],Q.y2+=F+S[1],Q}(e,o),c=function(t){return!a||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,A=t.y2;return aq([[r,o],[i,o],[i,A],[r,A]],iq(e,n))}(a,t)},l=function(t,e){return!t||!t.firstChild||!function(t,e,n){var r,i,o=iq(t,n).flat(1),A=iq(e,n).flat(1),s=[[o[0],o[1],o[2],o[3]],[o[0],o[1],o[4],o[5]],[o[4],o[5],o[6],o[7]],[o[2],o[3],o[6],o[7]]];try{for(var a=Re(s),c=a.next();!c.done;c=a.next())if(cq(A,c.value))return!0}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return!1}(t.firstChild,e.firstChild,UW(n))};try{for(var u=Re(t),h=u.next();!h.done;h=u.next()){var d=h.value;c(d)?!s||l(s,d)?s=d:(A.add(s),A.add(d)):A.add(d)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}return Array.from(A)}function uq(t,e){return void 0===e&&(e={}),Kt(t)?0:"number"==typeof t?t:Math.floor(oW(t,e))}var hq=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter(function(t,e){return!(e%r)||(zV(t),!1)})},dq=function(t){return t.filter(iW)};var fq=new Map([["hide",function(t,e,n,r){var i=t.length,o=e.keepHeader,A=e.keepTail;if(!(i<=1||2===i&&o&&A)){var s,a,c=hq,l=function(t){return t.forEach(r.show),t},u=2,h=t.slice(),d=t.slice(),f=Math.min.apply(Math,_e([1],He(t.map(function(t){return t.getBBox().width})),!1));if("linear"===n.type&&(VX(n)||WX(n))){var g=NW(t[0]).left,p=NW(t[i-1]).right,v=Math.abs(p-g)||1;u=Math.max(Math.floor(i*f/v),u)}for(o&&(s=h.splice(0,1)[0]),A&&(a=h.splice(-1,1)[0],h.reverse()),l(h);ug+f;w-=f){var b=y(w);if("object"==typeof b)return b.value}}}],["wrap",function(t,e,n,r,i){var o,A=e.maxLines,s=void 0===A?3:A,a=e.recoverWhenFailed,c=void 0===a||a,l=e.margin,u=void 0===l?[0,0,0,0]:l,h=JV(null!==(o=e.wordWrapWidth)&&void 0!==o?o:50,[i]),d=t.map(function(t){return t.attr("maxLines")||1}),f=Math.min.apply(Math,_e([],He(d),!1)),g=function(){return lq(t,n,u).length<1},p=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&VX(t)?"negative"===n?"bottom":"top":"middle"}(n),v=function(e){return t.forEach(function(t,n){var i=Array.isArray(e)?e[n]:e;r.wrap(t,h,i,p)})};if(!(f>s)){if("linear"===n.type&&VX(n)){if(v(s),g())return}else for(var m=f;m<=s;m++)if(v(m),g())return;c&&v(d)}}]]);function gq(){for(var t=[],e=0;e=1)})(t,e,o)&&(null==A||A(t,i,e,r,n))})}(this.node().childNodes,t,e,{hide:zV,show:jV,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=yq(e.__data__.value,t,n),i=e.querySelector(UX.labelItem.class);i&&Eq(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&cW(t,e||1/0,n)},wrap:function(t,e,n){var r,i;t&&(void 0===(r=n)&&(r=2),void 0===i&&(i="top"),aW(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector(UX.labelItem.class)}})}function Cq(t,e,n,r,i){var o=n.indexOf(e),A=i.labelRender,s=i.classNamePrefix,a=QW(t).append(A?bq(e,o,n,i):function(t,e,n,r){var i=r.labelFormatter;return Gt(i)?function(){return uW(JV(i,[t,e,n,GX(t.value,r)]))}:function(){return uW(t.label||"")}}(e,o,n,i)).attr("className",UX.labelItem.name).node();jX(QW(a),UX.labelItem,kX,s);var c=He(RW(PX(r,[e,o,n])),2),l=c[0],u=c[1],h=u.transform,d=Pe(u,["transform"]);_W(a,h);var f=mq(e,a,i);if(a.getLocalEulerAngles()||a.setLocalEulerAngles(f),Eq(a,Le(Le({},yq(e.value,f,i)),l)),"html"===a.nodeName){var g=a.getBBox(),p=a.style.x||0;a.attr("x",p-g.width/2)}return t.attr(d),a}function Mq(t,e,n,r,i){var o,A,s,a=n.classNamePrefix,c=DX(e,n.labelFilter),l=PW(n,"label"),u=t.selectAll(UX.label.class).data(c,function(t,e){return e}).join(function(t){var r=t.append("g").attr("className",UX.label.name).transition(function(t){Cq(this,t,e,l,n);var r=wq(t,e,n),i=r.x,o=r.y;return this.style.transform="translate(".concat(i,", ").concat(o,")"),null});return jX(r,UX.label,FX,a),r},function(t){return t.transition(function(t){var i=function(t,e,n,r){if(void 0===r&&(r="destroy"),function(t,e){return"text"===t.nodeName&&"text"===e.nodeName&&t.attributes.text===e.attributes.text}(t,e))return t.remove(),[null];var i=function(){"destroy"===r?t.destroy():"hide"===r&&zV(t),e.isVisible()&&jV(e)};if(!n)return i(),[null];var o=n.duration,A=void 0===o?0:o,s=n.delay,a=void 0===s?0:s,c=Math.ceil(+A/2),l=+A/4,u=He(t.getGeometryBounds().center,2),h=u[0],d=u[1],f=He(e.getGeometryBounds().center,2),g=He([(h+f[0])/2-h,(d+f[1])/2-d],2),p=g[0],v=g[1],m=t.style.opacity,y=void 0===m?1:m,w=e.style.opacity,b=void 0===w?1:w,B=t.style.transform||"",E=e.style.transform||"",x=t.animate([{opacity:y,transform:"translate(0, 0) ".concat(B)},{opacity:0,transform:"translate(".concat(p,", ").concat(v,") ").concat(B)}],Le(Le({fill:"both"},n),{duration:a+c+l})),C=e.animate([{opacity:0,transform:"translate(".concat(-p,", ").concat(-v,") ").concat(E),offset:.01},{opacity:b,transform:"translate(0, 0) ".concat(E)}],Le(Le({fill:"both"},n),{duration:c+l,delay:a+c-l}));return nX(C,i),[x,C]}(this.querySelector(UX.labelItem.class),Cq(this,t,e,l,n),r.update),o=wq(t,e,n),A=o.x,s=o.y,a=oX(this,{transform:"translate(".concat(A,", ").concat(s,")")},r.update);return _e(_e([],He(i),!1),[a],!1)})},function(t){return o=t,t.transition(function(){var t=this,e=AX(this.childNodes[0],r.exit);return nX(e,function(){return QW(t).remove()}),e}),o}).transitions();return s=function(){xq.call(t,n,i)},0===(A=u).length?s():Promise.all(A.map(function(t){return null==t?void 0:t.finished})).then(s),u}function Fq(t,e){return _X(t,e.tickDirection,e)}function kq(t,e,n,r,i){var o=He(function(t,e){var n=He(t,2);return[[0,0],[n[0]*e,n[1]*e]]}(r,JV(i.tickLength,[t,e,n])),2),A=He(o[0],2),s=A[0],a=A[1],c=He(o[1],2);return{x1:s,x2:c[0],y1:a,y2:c[1]}}function Sq(t,e,n,r,i,o){var A=function(t,e,n,r,i){var o=i.tickFormatter,A=i.classNamePrefix,s=Fq(e.value,i),a="line";Gt(o)&&(a=function(){return JV(o,[e,n,r,s])});var c=t.append(a).attr("className",UX.tickItem.name);return jX(c,UX.tickItem,MX,A),c}(QW(this),t,e,n,r);!function(t,e,n,r,i,o,A){var s=Fq(t.value,o),a=kq(t,e,n,s,o),c=a.x1,l=a.x2,u=a.y1,h=a.y2,d=He(RW(PX(A,[t,e,n,s])),2),f=d[0],g=d[1];"line"===r.node().nodeName&&r.styles(Le({x1:c,x2:l,y1:u,y2:h},f)),i.attr(g),r.styles(f)}(t,e,n,A,this,r,i);var s=He(zX(t.value,r),2),a=s[0],c=s[1];return oX(this,{transform:"translate(".concat(a,", ").concat(c,")")},o)}function Qq(t,e,n,r,i){var o=He(RW(PW(r,"title")),2),A=o[0],s=o[1],a=s.transform,c=s.transformOrigin,l=Pe(s,["transform","transformOrigin"]);e.styles(l);var u=a||function(t,e,n){var r=2*t.getGeometryBounds().halfExtents[1];if("vertical"===e){if("left"===n)return"rotate(-90) translate(0, ".concat(r/2,")");if("right"===n)return"rotate(-90) translate(0, -".concat(r/2,")")}return""}(t.node(),A.direction,A.position);t.styles(Le(Le({},A),{transformOrigin:c})),_W(t.node(),u);var h=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,A=KW(i),s=t.node().getLocalBounds(),a=He(s.min,2),c=a[0],l=a[1],u=He(s.halfExtents,2),h=u[0],d=u[1],f=He(e.node().getLocalBounds().halfExtents,2),g=f[0],p=f[1],v=He([c+h,l+d],2),m=v[0],y=v[1],w=He(UW(o),4),b=w[0],B=w[1],E=w[2],x=w[3];if(["start","end"].includes(i)&&"linear"===n.type){var C=n.startPos,M=n.endPos,F=He("start"===i?[C,M]:[M,C],2),k=F[0],S=F[1],Q=He(gW(bW([-S[0]+k[0],-S[1]+k[1]]),b),2),U=Q[0],N=Q[1];return{x:k[0]+U,y:k[1]+N}}return A.includes("t")&&(y-=d+p+b),A.includes("r")&&(m+=h+g+B),A.includes("l")&&(m-=h+g+x),A.includes("b")&&(y+=d+p+E),{x:m,y:y}}(QW(n._offscreen||n.querySelector(UX.mainGroup.class)),e,r),d=h.x,f=h.y;return oX(e.node(),{transform:"translate(".concat(d,", ").concat(f,")")},i)}function Uq(t,e,n,r){var i=t.showLine,o=t.showTick,A=t.showLabel,s=t.classNamePrefix,a=e.maybeAppendByClassName(UX.lineGroup,"g");jX(a,UX.lineGroup,vX,s);var c=hW(i,a,function(e){return JX(e,t,r)})||[],l=e.maybeAppendByClassName(UX.tickGroup,"g");jX(l,UX.tickGroup,mX,s);var u=hW(o,l,function(e){return function(t,e,n,r){var i=n.classNamePrefix,o=DX(e,n.tickFilter),A=PW(n,"tick");return t.selectAll(UX.tick.class).data(o,function(t){return t.id||t.label}).join(function(t){var e=t.append("g").attr("className",UX.tick.name).transition(function(t,e){return Sq.call(this,t,e,o,n,A,!1)});return jX(e,UX.tick,CX,i),e},function(t){return t.transition(function(t,e){return this.removeChildren(),Sq.call(this,t,e,o,n,A,r.update)})},function(t){return t.transition(function(){var t=this,e=AX(this.childNodes[0],r.exit);return nX(e,function(){return t.remove()}),e})}).transitions()}(e,n,t,r)})||[],h=e.maybeAppendByClassName(UX.labelGroup,"g");jX(h,UX.labelGroup,yX,s);var d=hW(A,h,function(i){return Mq(i,n,t,r,e.node())})||[];return _e(_e(_e([],He(c),!1),He(u),!1),He(d),!1).filter(function(t){return!!t})}var Nq=function(t){function e(e){return t.call(this,e,QX)||this}return Ie(e,t),e.prototype.render=function(t,e,n){var r=this,i=t.titleText,o=t.data,A=t.animate,s=t.showTitle,a=t.showGrid,c=t.dataThreshold,l=t.truncRange,u=t.classNamePrefix,h=e.className||"axis";u?e.attr("className","".concat(h," ").concat(u,"axis")):e.className||e.attr("className","axis");var d=function(t,e){if(t.length<=e)return t;for(var n=Math.floor(t.length/e),r=[],i=0;il[0]&&e1?{width:55,height:0}:{width:0,height:0}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageShape",{get:function(){var t=He(function(t){var e;return(null===(e=t[0])||void 0===e?void 0:e.map(function(e,n){return t.map(function(t){return t[n]})}))||[]}(this.pageViews.map(function(t){var e=t.getBBox();return[e.width,e.height]})).map(function(t){return Math.max.apply(Math,_e([],He(t),!1))}),2),e=t[0],n=t[1],r=this.attributes,i=r.pageWidth,o=void 0===i?e:i,A=r.pageHeight;return{pageWidth:o,pageHeight:void 0===A?n:A}},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.playWindow},Object.defineProperty(e.prototype,"totalPages",{get:function(){return this.pageViews.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currPage",{get:function(){return this.innerCurrPage},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e=t.prototype.getBBox.call(this),n=e.x,r=e.y,i=this.controllerShape,o=this.pageShape,A=o.pageWidth,s=o.pageHeight;return new ZV(n,r,A+i.width,s)},e.prototype.goTo=function(t){var e=this,n=this.attributes.animate,r=this,i=r.currPage,o=r.playState,A=r.playWindow,s=r.pageViews;if("idle"!==o||t<0||s.length<=0||t>=s.length)return null;s[i].setLocalPosition(0,0),this.prepareFollowingPage(t);var a=He(this.getFollowingPageDiff(t),2),c=a[0],l=a[1];this.playState="running";var u=iX(A,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-c,", ").concat(-l,")")}],n);return nX(u,function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()}),u},e.prototype.prev=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n<=0)return null;var r=t?(n-1+e)%e:ne(n-1,0,e);return this.goTo(r)},e.prototype.next=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n>=e-1)return null;var r=t?(n+1)%e:ne(n+1,0,e);return this.goTo(r)},e.prototype.renderClipPath=function(t){var e=this.pageShape,n=e.pageWidth,r=e.pageHeight;n&&r?(this.clipPath=t.maybeAppendByClassName(n$.clipPath,"rect").styles({width:n,height:r}),this.contentGroup.attr("clipPath",this.clipPath.node())):this.contentGroup.style.clipPath=void 0},e.prototype.setVisiblePages=function(t){this.playWindow.children.forEach(function(e,n){t.includes(n)?jV(e):zV(e)})},e.prototype.adjustControllerLayout=function(){var t=this,e=t.prevBtnGroup,n=t.nextBtnGroup,r=t.pageInfoGroup,i=this.attributes,o=i.orientation,A=i.controllerPadding,s=r.getBBox(),a=s.width;s.height;var c=He("horizontal"===o?[-180,0]:[-90,90],2),l=c[0],u=c[1];e.setLocalEulerAngles(l),n.setLocalEulerAngles(u);var h=e.getBBox(),d=h.width,f=h.height,g=n.getBBox(),p=g.width,v=g.height,m=Math.max(d,a,p),y="horizontal"===o?{offset:[[0,0],[d/2+A,0],[d+a+2*A,0]],textAlign:"start"}:{offset:[[m/2,-f-A],[m/2,0],[m/2,v+A]],textAlign:"center"},w=He(y.offset,3),b=He(w[0],2),B=b[0],E=b[1],x=He(w[1],2),C=x[0],M=x[1],F=He(w[2],2),k=F[0],S=F[1],Q=y.textAlign,U=r.querySelector("text");U&&(U.style.textAlign=Q),e.setLocalPosition(B,E),r.setLocalPosition(C,M),n.setLocalPosition(k,S)},e.prototype.updatePageInfo=function(){var t,e=this,n=e.currPage,r=e.pageViews,i=e.attributes.formatter;r.length<2||(null===(t=this.pageInfoGroup.querySelector(n$.pageInfo.class))||void 0===t||t.attr("text",i(n+1,r.length)),this.adjustControllerLayout())},e.prototype.getFollowingPageDiff=function(t){var e=this.currPage;if(e===t)return[0,0];var n=this.attributes.orientation,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,A=t=2,l=t.maybeAppendByClassName(n$.controller,"g");if(VV(l.node(),c),c){var u=PW(this.attributes,"button"),h=PW(this.attributes,"pageNum"),d=He(RW(u),2),f=d[0],g=d[1],p=f.size,v=Pe(f,["size"]),m=!l.select(n$.prevBtnGroup.class).node(),y=l.maybeAppendByClassName(n$.prevBtnGroup,"g").styles(g);this.prevBtnGroup=y.node();var w=y.maybeAppendByClassName(n$.prevBtn,"path");if(o){var b=Tq(n$.prevBtn.name,jq,o);w.node().setAttribute("class",b)}var B=l.maybeAppendByClassName(n$.nextBtnGroup,"g").styles(g);this.nextBtnGroup=B.node();var E=B.maybeAppendByClassName(n$.nextBtn,"path");if(o){var x=Tq(n$.nextBtn.name,zq,o);E.node().setAttribute("class",x)}[w,E].forEach(function(t){t.styles(Le(Le({},v),{transformOrigin:"center"})),kW(t.node(),p)});var C=l.maybeAppendByClassName(n$.pageInfoGroup,"g");this.pageInfoGroup=C.node();var M=C.maybeAppendByClassName(n$.pageInfo,"text");if(M.styles(h),o){var F=Tq(n$.pageInfo.name,Vq,o);M.node().setAttribute("class",F)}this.updatePageInfo(),l.node().setLocalPosition(s+r,a/2),m&&(this.prevBtnGroup.addEventListener("click",function(){e.prev()}),this.nextBtnGroup.addEventListener("click",function(){e.next()}))}},e.prototype.render=function(t,e){var n=t.x,r=void 0===n?0:n,i=t.y,o=void 0===i?0:i;this.attr("transform","translate(".concat(r,", ").concat(o,")"));var A=QW(e);this.renderClipPath(A),this.renderController(A),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=pe(function(){return t.render(t.attributes,t)},50);this.playWindow.addEventListener(ea.INSERTED,e),this.playWindow.addEventListener(ea.REMOVED,e)},e}(zW),i$="component-poptip",o$="component-poptip-arrow",A$="component-poptip-text",s$=((t$={})[".".concat(i$)]={visibility:"visible",position:"absolute","background-color":"rgba(0, 0, 0)","box-shadow":"0px 0px 10px #aeaeae","border-radius":"3px",color:"#fff",opacity:.8,"font-size":"12px",padding:"4px 6px",display:"flex","justify-content":"center","align-items":"center","z-index":8,transition:"visibility 50ms"},t$[".".concat(A$)]={"text-align":"center"},t$[".".concat(i$,"[data-position='top']")]={transform:"translate(-50%, -100%)"},t$[".".concat(i$,"[data-position='left']")]={transform:"translate(-100%, -50%)"},t$[".".concat(i$,"[data-position='right']")]={transform:"translate(0, -50%)"},t$[".".concat(i$,"[data-position='bottom']")]={transform:"translate(-50%, 0)"},t$[".".concat(i$,"[data-position='top-left']")]={transform:"translate(0,-100%)"},t$[".".concat(i$,"[data-position='top-right']")]={transform:"translate(-100%,-100%)"},t$[".".concat(i$,"[data-position='left-top']")]={transform:"translate(-100%, 0)"},t$[".".concat(i$,"[data-position='left-bottom']")]={transform:"translate(-100%, -100%)"},t$[".".concat(i$,"[data-position='right-top']")]={transform:"translate(0, 0)"},t$[".".concat(i$,"[data-position='right-bottom']")]={transform:"translate(0, -100%)"},t$[".".concat(i$,"[data-position='bottom-left']")]={transform:"translate(0, 0)"},t$[".".concat(i$,"[data-position='bottom-right']")]={transform:"translate(-100%, 0)"},t$[".".concat(o$)]={width:"4px",height:"4px",transform:"rotate(45deg)","background-color":"rgba(0, 0, 0)",position:"absolute","z-index":-1},t$[".".concat(i$,"[data-position='top']")]={transform:"translate(-50%, calc(-100% - 5px))"},t$["[data-position='top'] .".concat(o$)]={bottom:"-2px"},t$[".".concat(i$,"[data-position='left']")]={transform:"translate(calc(-100% - 5px), -50%)"},t$["[data-position='left'] .".concat(o$)]={right:"-2px"},t$[".".concat(i$,"[data-position='right']")]={transform:"translate(5px, -50%)"},t$["[data-position='right'] .".concat(o$)]={left:"-2px"},t$[".".concat(i$,"[data-position='bottom']")]={transform:"translate(-50%, 5px)"},t$["[data-position='bottom'] .".concat(o$)]={top:"-2px"},t$[".".concat(i$,"[data-position='top-left']")]={transform:"translate(0, calc(-100% - 5px))"},t$["[data-position='top-left'] .".concat(o$)]={left:"10px",bottom:"-2px"},t$[".".concat(i$,"[data-position='top-right']")]={transform:"translate(-100%, calc(-100% - 5px))"},t$["[data-position='top-right'] .".concat(o$)]={right:"10px",bottom:"-2px"},t$[".".concat(i$,"[data-position='left-top']")]={transform:"translate(calc(-100% - 5px), 0)"},t$["[data-position='left-top'] .".concat(o$)]={right:"-2px",top:"8px"},t$[".".concat(i$,"[data-position='left-bottom']")]={transform:"translate(calc(-100% - 5px), -100%)"},t$["[data-position='left-bottom'] .".concat(o$)]={right:"-2px",bottom:"8px"},t$[".".concat(i$,"[data-position='right-top']")]={transform:"translate(5px, 0)"},t$["[data-position='right-top'] .".concat(o$)]={left:"-2px",top:"8px"},t$[".".concat(i$,"[data-position='right-bottom']")]={transform:"translate(5px, -100%)"},t$["[data-position='right-bottom'] .".concat(o$)]={left:"-2px",bottom:"8px"},t$[".".concat(i$,"[data-position='bottom-left']")]={transform:"translate(0, 5px)"},t$["[data-position='bottom-left'] .".concat(o$)]={top:"-2px",left:"8px"},t$[".".concat(i$,"[data-position='bottom-right']")]={transform:"translate(-100%, 5px)"},t$["[data-position='bottom-right'] .".concat(o$)]={top:"-2px",right:"8px"},t$);function a$(t){var e=t&&document.getElementById(t);return e||((e=document.createElement("div")).setAttribute("id",t),document.body.appendChild(e)),e}var c$=function(t){function e(n){var r=t.call(this,be({style:{id:"component-poptip"}},e.defaultOptions,n))||this;return r.visibility="visible",r.map=new Map,r.domStyles="",r.initShape(),r.render(r.attributes,r),r}return Ie(e,t),Object.defineProperty(e.prototype,"visible",{get:function(){return"visible"===this.visibility},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.visibility=this.style.visibility,this.updatePoptipElement()},e.prototype.update=function(t){this.attr(be({},this.style,t)),this.render(this.attributes,this)},e.prototype.bind=function(t,e){var n=this;if(t){var r=this.style.text,i=function(i){var o=t,A=n.style,s=r;if(e){var a="function"==typeof e?e.call(null,i):e,c=a.html,l=a.target,u=Pe(a,["html","target"]);A=function(t,e,n){return e&&fe(t,e),n&&fe(t,n),t}({},n.style,u),(l||!1===l)&&(o=l),"string"==typeof c&&(s=c)}var h=A.position,d=A.arrowPointAtCenter,f=A.follow,g=A.offset;if(o){var p=i,v=He(function(t,e,n,r,i,o){if(void 0===i&&(i=!1),void 0===o&&(o=!1),o)return[t,e];var A=n.getBoundingClientRect(),s=A.x,a=A.y,c=A.width,l=A.height;switch(r){case"top":return i?[s+c/2,a]:[t,a];case"left":return i?[s,a+l/2]:[s,e];case"bottom":return i?[s+c/2,a+l]:[t,a+l];case"right":return i?[s+c,a+l/2]:[s+c,e];case"top-right":case"right-top":return[s+c,a];case"left-bottom":case"bottom-left":return[s,a+l];case"right-bottom":case"bottom-right":return[s+c,a+l];default:return[s,a]}}(p.clientX,p.clientY,o,h,d,f),2),m=v[0],y=v[1];n.showTip(m,y,{text:s,position:h,offset:g})}else n.hideTip()},o=function(){n.hideTip()};t.addEventListener("mousemove",i),t.addEventListener("mouseleave",o),this.map.set(t,[i,o])}},e.prototype.unbind=function(t){if(this.map.has(t)){var e=He(this.map.get(t)||[],2),n=e[0],r=e[1];n&&t.removeEventListener("mousemove",n),r&&t.removeEventListener("mouseleave",r),this.map.delete(t)}},e.prototype.clear=function(){this.container.innerHTML=""},e.prototype.destroy=function(){var e,n=this;_e([],He(this.map.keys()),!1).forEach(function(t){return n.unbind(t)}),null===(e=this.container)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.showTip=function(t,e,n){var r=Ce(n,"text");if((!r||"string"==typeof r)&&(this.applyStyles(),t&&e&&n)){var i=n.offset,o=n.position;if(o&&this.container.setAttribute("data-position",o),this.setOffsetPosition(t,e,i),"string"==typeof r){var A=this.container.querySelector(".".concat(A$));A&&(A.innerHTML=r)}this.visibility="visible",this.container.style.visibility="visible"}},e.prototype.hideTip=function(){this.visibility="hidden",this.container.style.visibility="hidden"},e.prototype.getContainer=function(){return this.container},e.prototype.getClassName=function(){var t=this.style.containerClassName;return"".concat(i$).concat(t?" ".concat(t):"")},e.prototype.initShape=function(){var t=this,e=this.style.id;this.container=function(t){var e,n,r=(e=a$,function(){for(var t=[],r=0;r');t.innerHTML=A,Jt(r)?t.innerHTML+=r:r&&((o=r)instanceof Element||o instanceof Document)&&t.appendChild(r),i&&(t.getElementsByClassName(A$)[0].textContent=i),this.applyStyles(),this.container.style.visibility=this.visibility},e.prototype.applyStyles=function(){var t=rW({},s$,this.style.domStyles),e=Object.entries(t).reduce(function(t,e){var n=He(e,2),r=n[0],i=n[1],o=Object.entries(i).reduce(function(t,e){var n=He(e,2),r=n[0],i=n[1];return"".concat(t).concat(r,": ").concat(i,";")},"");return"".concat(t).concat(r,"{").concat(o,"}")},"");if(this.domStyles!==e){this.domStyles=e;var n=this.container.querySelector("style");n&&this.container.removeChild(n),(n=document.createElement("style")).innerHTML=e,this.container.appendChild(n)}},e.prototype.setOffsetPosition=function(t,e,n){void 0===n&&(n=this.style.offset);var r=He(n,2),i=r[0],o=void 0===i?0:i,A=r[1],s=void 0===A?0:A;this.container.style.left="".concat(t+o,"px"),this.container.style.top="".concat(e+s,"px")},e.tag="poptip",e.defaultOptions={style:{x:0,y:0,width:0,height:0,target:null,visibility:"hidden",text:"",position:"top",follow:!1,offset:[0,0],domStyles:s$,template:'
')}},e}(zW),l$=eW({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",focusGroup:"focus-group",focus:"focus",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item"),u$={offset:[0,20],domStyles:{".component-poptip":{opacity:"1",padding:"8px 12px",background:"#fff",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)"},".component-poptip-arrow":{display:"none"},".component-poptip-text":{color:"#000",lineHeight:"20px"}}};var h$=function(t){function e(e,n){var r=t.call(this,e,{span:[1,1],marker:function(){return new za({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this;return r.keyFields={},r.keyFields=n||{},r}return Ie(e,t),Object.defineProperty(e.prototype,"showValue",{get:function(){var t=this.attributes.valueText;return!!t&&("string"==typeof t||"number"==typeof t?""!==t:"function"==typeof t||""!==t.attr("text"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"actualSpace",{get:function(){var t=this.labelGroup,e=this.valueGroup,n=this.attributes,r=n.markerSize,i=n.focus,o=n.focusMarkerSize,A=t.node().getBBox(),s=A.width,a=A.height,c=e.node().getBBox(),l=c.width,u=c.height;return{markerWidth:r,labelWidth:s,valueWidth:l,focusWidth:i?null!=o?o:12:0,height:Math.max(r,a,u)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=He(UW(t),2),n=e[0],r=e[1],i=this.showValue?r:0,o=n+i;return[n/o,i/o]},enumerable:!1,configurable:!0}),e.prototype.setAttribute=function(e,n){t.prototype.setAttribute.call(this,e,n)},Object.defineProperty(e.prototype,"shape",{get:function(){var t,e=this.attributes,n=e.markerSize,r=e.width,i=this.actualSpace,o=i.markerWidth,A=i.focusWidth,s=i.height,a=this.actualSpace,c=a.labelWidth,l=a.valueWidth,u=He(this.spacing,3),h=u[0],d=u[1],f=u[2];if(r){var g=r-n-h-d-A-f,p=He(this.span,2);c=(t=He([p[0]*g,p[1]*g],2))[0],l=t[1]}return{width:o+c+l+h+d+A+f,height:s,markerWidth:o,labelWidth:c,valueWidth:l,focusWidth:A}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes,e=t.spacing,n=t.focus;if(!e)return[0,0,0];var r=He(UW(e),3),i=r[0],o=r[1],A=r[2];return[i,this.showValue?o:0,n?A:0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layout",{get:function(){var t=this.shape,e=t.markerWidth,n=t.labelWidth,r=t.valueWidth,i=t.focusWidth,o=t.width,A=t.height,s=He(this.spacing,3),a=s[0],c=s[1];return{height:A,width:o,markerWidth:e,labelWidth:n,valueWidth:r,focusWidth:i,position:[e/2,e+a,e+n+a+c,e+n+r+a+c+s[2]+i/2]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(l$.marker.class);return e?e.style:{}}(this.markerGroup.node()),e=this.attributes,n=e.markerSize,r=e.markerStrokeWidth,i=void 0===r?t.strokeWidth:r,o=e.markerLineWidth,A=void 0===o?t.lineWidth:o,s=e.markerStroke,a=void 0===s?t.stroke:s,c=+(i||A||(a?1:0))*Math.sqrt(2),l=this.markerGroup.node().getBBox(),u=l.width,h=l.height;return(1-c/Math.max(u,h))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.marker,i=n.classNamePrefix,o=PW(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(l$.markerGroup,"g").style("zIndex",0),hW(!!r,this.markerGroup,function(){var t,n=e.markerGroup.node(),A=null===(t=n.childNodes)||void 0===t?void 0:t[0],s=Tq(l$.marker.name,Pq,i),a="string"==typeof r?new JW({style:{symbol:r},className:s}):r();if(A)if(a.nodeName===A.nodeName)A instanceof JW?A.update(Le(Le({},o),{symbol:r})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=Re(Object.entries(i)),A=o.next();!A.done;A=o.next()){var s=He(A.value,2),a=s[0],c=s[1];"id"!==a&&"className"!==a&&t.attr(a,c)}}catch(t){n={error:t}}finally{try{A&&!A.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(A,a),QW(A).styles(o));else{if(A.remove(),!(a instanceof JW)){var c=Tq(l$.marker.name,Pq,i);a.className=c}QW(a).styles(o),n.appendChild(a)}else{if(!(a instanceof JW)){var l=Tq(l$.marker.name,Pq,i);a.className=l,QW(a).styles(o)}n.appendChild(a)}e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]);var u=kW(e.markerGroup.node(),e.scaleSize);e.markerGroup.node().style._transform="scale(".concat(u,")")})},e.prototype.renderLabel=function(t){var e=PW(this.attributes,"label"),n=e.text,r=Pe(e,["text"]),i=this.attributes.classNamePrefix;this.labelGroup=t.maybeAppendByClassName(l$.labelGroup,"g").style("zIndex",0);var o=Tq(l$.label.name,Dq,i),A=this.labelGroup.maybeAppendByClassName(l$.label,function(){return uW(n)});A.node().setAttribute("class",o),A.styles(r)},e.prototype.renderValue=function(t){var e=this,n=PW(this.attributes,"value"),r=n.text,i=Pe(n,["text"]),o=this.attributes.classNamePrefix;this.valueGroup=t.maybeAppendByClassName(l$.valueGroup,"g").style("zIndex",0),hW(this.showValue,this.valueGroup,function(){var t=Tq(l$.value.name,Rq,o),n=e.valueGroup.maybeAppendByClassName(l$.value,function(){return uW(r)});n.node().setAttribute("class",t),n.styles(i)})},e.prototype.createPoptip=function(){var t=this.attributes.poptip||{};t.render;var e=Pe(t,["render"]),n=new c$({style:rW(u$,e)});return this.poptipGroup=n,n},e.prototype.bindPoptip=function(t){var e=this,n=this.attributes.poptip;n&&(this.poptipGroup||this.createPoptip()).bind(t,function(){var t=e.attributes,r=t.labelText,i=t.valueText,o=t.markerFill,A="string"==typeof r?r:null==r?void 0:r.attr("text"),s="string"==typeof i?i:null==i?void 0:i.attr("text");if("function"==typeof n.render)return{html:n.render(Le(Le({},e.keyFields),{label:A,value:s,color:o}))};var a="";return"string"!=typeof A&&"number"!=typeof A||(a+='
'.concat(A,"
")),"string"!=typeof s&&"number"!=typeof s||(a+='
'.concat(s,"
")),{html:a}})},e.prototype.renderFocus=function(t){var e=this,n=this.attributes,r=n.focus,i=n.focusMarkerSize,o=n.classNamePrefix,A={x:0,y:0,size:i,opacity:.6,symbol:"focus",stroke:"#aaaaaa",lineWidth:1};de(r)||(this.focusGroup=t.maybeAppendByClassName(l$.focusGroup,"g").style("zIndex",0),hW(r,this.focusGroup,function(){var n=Tq(l$.focus.name,Hq,o),r=new JW({style:Le(Le({},A),{symbol:"focus"}),className:n}),i=new za({style:{r:A.size/2,fill:"transparent"}}),s=e.focusGroup.node();s.appendChild(i),s.appendChild(r),r.update({opacity:0}),t.node().addEventListener("pointerenter",function(){r.update({opacity:1})}),t.node().addEventListener("pointerleave",function(){r.update({opacity:0})})}))},e.prototype.renderPoptip=function(t){var e=this;this.attributes.poptip&&[t.maybeAppendByClassName(l$.value,"g").node(),t.maybeAppendByClassName(l$.label,"g").node()].forEach(function(t){t&&e.bindPoptip(t)})},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=PW(this.attributes,"background");this.background=t.maybeAppendByClassName(l$.backgroundGroup,"g").style("zIndex",-1);var o=this.background.maybeAppendByClassName(l$.background,"rect");o.styles(Le({width:n,height:r},i));var A=this.attributes.classNamePrefix,s=void 0===A?"":A;if(s){var a=Tq(l$.background.name,_q,s);o.node().setAttribute("class",a)}},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=He(t.position,4),o=i[0],A=i[1],s=i[2],a=i[3],c=r/2;this.markerGroup.styles({transform:"translate(".concat(o,", ").concat(c,")").concat(this.markerGroup.node().style._transform)}),this.labelGroup.styles({transform:"translate(".concat(A,", ").concat(c,")")}),this.focusGroup&&this.focusGroup.styles({transform:"translate(".concat(a,", ").concat(c,")")}),cW(this.labelGroup.select(l$.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({transform:"translate(".concat(s,", ").concat(c,")")}),cW(this.valueGroup.select(l$.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=QW(e),r=t.x,i=void 0===r?0:r,o=t.y,A=void 0===o?0:o;n.styles({transform:"translate(".concat(i,", ").concat(A,")")}),this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.renderPoptip(n),this.renderFocus(n),this.adjustLayout()},e}(zW),d$=eW({page:"item-page",navigator:"navigator",item:"item"},"items"),f$=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},g$=function(t){function e(e){var n=t.call(this,e,{data:[],gridRow:1/0,gridCol:void 0,padding:0,width:1e3,height:100,rowPadding:0,colPadding:0,layout:"flex",orientation:"horizontal",click:Ne,mouseenter:Ne,mouseleave:Ne})||this;return n.navigatorShape=[0,0],n}return Ie(e,t),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.navigator.getContainer()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){var t=this.attributes,e=t.gridRow,n=t.gridCol,r=t.data;if(!e&&!n)throw new Error("gridRow and gridCol can not be set null at the same time");return e&&n?[e,n]:e?[e,r.length]:[r.length,n]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderData",{get:function(){var t=this.attributes,e=t.data,n=t.layout,r=t.poptip,i=t.focus,o=t.focusMarkerSize,A=t.classNamePrefix,s=PW(this.attributes,"item"),a=e.map(function(t,a){var c=t.id,l=void 0===c?a:c,u=t.label,h=t.value;return{id:"".concat(l),index:a,style:Le({layout:n,labelText:u,valueText:h,poptip:r,focus:i,focusMarkerSize:o,classNamePrefix:A},Object.fromEntries(Object.entries(s).map(function(n){var r=He(n,2);return[r[0],JV(r[1],[t,a,e])]})))}});return a},enumerable:!1,configurable:!0}),e.prototype.getGridLayout=function(){var t=this,e=this.attributes,n=e.orientation,r=e.width,i=e.rowPadding,o=e.colPadding,A=He(this.navigatorShape,1)[0],s=He(this.grid,2),a=s[0],c=s[1],l=c*a,u=0;return this.pageViews.children.map(function(e,s){var h,d,f=Math.floor(s/l),g=s%l,p=t.ifHorizontal(c,a),v=[Math.floor(g/p),g%p];"vertical"===n&&v.reverse();var m=He(v,2),y=m[0],w=m[1],b=(r-A-(c-1)*o)/c,B=e.getBBox().height,E=He([0,0],2),x=E[0],C=E[1];return"horizontal"===n?(x=(h=He([u,y*(B+i)],2))[0],C=h[1],u=w===c-1?0:u+b+o):(x=(d=He([w*(b+o),u],2))[0],C=d[1],u=y===a-1?0:u+B+i),{page:f,index:s,row:y,col:w,pageIndex:g,width:b,height:B,x:x,y:C}})},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=He(this.navigatorShape,1)[0],A=He(this.grid,2),s=A[0],a=A[1],c=He([e-o,n],2),l=c[0],u=c[1],h=He([0,0,0,0,0,0,0,0],8),d=h[0],f=h[1],g=h[2],p=h[3],v=h[4],m=h[5],y=h[6],w=h[7];return this.pageViews.children.map(function(t,e){var n,o,A,c,h=t.getBBox(),b=h.width,B=h.height,E=0===y?0:i,x=y+E+b;return x<=l&&f$(v,function(t){return t0?(this.navigatorShape=[55,0],t.call(this)):e},enumerable:!1,configurable:!0}),e.prototype.ifHorizontal=function(t,e){return Oq(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(d$.item.class).forEach(function(e){t.appendChild(e)}),t.querySelectorAll(d$.page.class).forEach(function(e){t.removeChild(e).destroy()})},e.prototype.renderItems=function(t){var e=this.attributes,n=e.click,r=e.mouseenter,i=e.mouseleave,o=e.classNamePrefix;this.flattenPage(t);var A=this.dispatchCustomEvent.bind(this),s=Tq(d$.item.name,Lq,o);QW(t).selectAll(d$.item.class).data(this.renderData,function(t){return t.id}).join(function(t){return t.append(function(t){var e=t.style,n=Pe(t,["style"]);return new h$({style:e},n)}).attr("className",s).on("click",function(){null==n||n(this),A("itemClick",{item:this})}).on("pointerenter",function(){null==r||r(this),A("itemMouseenter",{item:this})}).on("pointerleave",function(){null==i||i(this),A("itemMouseleave",{item:this})})},function(t){return t.each(function(t){var e=t.style;this.update(e)})},function(t){return t.remove()})},e.prototype.relayoutNavigator=function(){var t,e=this.attributes,n=e.layout,r=e.width,i=(null===(t=this.pageViews.children[0])||void 0===t?void 0:t.getBBox().height)||0,o=He(this.navigatorShape,2),A=o[0],s=o[1];this.navigator.update("grid"===n?{pageWidth:r-A,pageHeight:i-s}:{})},e.prototype.adjustLayout=function(){var t,e,n=this,r=Object.entries((t=this.itemsLayout,e="page",t.reduce(function(t,n){return(t[n[e]]=t[n[e]]||[]).push(n),t},{}))).map(function(t){var e=He(t,2);return{page:e[0],layouts:e[1]}}),i=_e([],He(this.navigator.getContainer().children),!1);r.forEach(function(t){var e=t.layouts,r=n.pageViews.appendChild(new Xa({className:d$.page.name}));e.forEach(function(t){var e=t.x,n=t.y,o=t.index,A=t.width,s=t.height,a=i[o];r.appendChild(a),Me(a,"__layout__",t),a.update({x:e,y:n,width:A,height:s})})}),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes,n=e.orientation,r=e.classNamePrefix,i=PW(this.attributes,"nav"),o=rW({orientation:n,classNamePrefix:r},i),A=this;return t.selectAll(d$.navigator.class).data(["nav"]).join(function(t){return t.append(function(){return new r$({style:o})}).attr("className",d$.navigator.name).each(function(){A.navigator=this})},function(t){return t.each(function(){this.update(o)})},function(t){return t.remove()}),this.navigator},e.prototype.getBBox=function(){return this.navigator.getBBox()},e.prototype.render=function(t,e){var n=this.attributes.data;if(n&&0!==n.length){var r=this.renderNavigator(QW(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new Vs(t,{detail:e});this.dispatchEvent(n)},e}(zW),p$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.update=function(t){this.attr(t)},e}($a),v$=function(t){function e(e){return t.call(this,e,qq)||this}return Ie(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,A=r.classNamePrefix,s=He(RW(PW(this.attributes,"title")),2),a=s[0],c=s[1];this.titleGroup=t.maybeAppendByClassName($q.titleGroup,"g").styles(c);var l=Le(Le({width:e,height:n},a),{text:i?o:"",classNamePrefix:A});this.title=this.titleGroup.maybeAppendByClassName($q.title,function(){return new e$({style:l})}).update(l)},e.prototype.renderCustom=function(t){var e=this.attributes.data,n={innerHTML:this.attributes.render(e),pointerEvents:"auto"};t.maybeAppendByClassName($q.html,function(){return new p$({className:$q.html.name,style:n})}).update(n)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,A=He(RW(PW(this.attributes,"title",!0)),2),s=A[0],a=A[1],c=Le(Le({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName($q.itemsGroup,"g").styles(Le(Le({},a),{transform:"translate(".concat(n,", ").concat(r,")")}));var l=this;this.itemsGroup.selectAll($q.items.class).data(["items"]).join(function(t){return t.append(function(){return new g$({style:c})}).attr("className",$q.items.name).each(function(){l.items=QW(this)})},function(t){return t.update(c)},function(t){return t.remove()})},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().style.transform="translate(".concat(e,", ").concat(n,")")}},Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes,e=t.showTitle,n=t.width,r=t.height;return e?this.title.node().getAvailableSpace():new ZV(0,0,n,r)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e,n,r=null===(e=this.title)||void 0===e?void 0:e.node(),i=null===(n=this.items)||void 0===n?void 0:n.node();return r&&i?function(t,e){var n=t.attributes,r=n.position,i=n.spacing,o=n.inset,A=n.text,s=t.getBBox(),a=e.getBBox(),c=KW(r),l=He(UW(A?i:0),4),u=l[0],h=l[1],d=l[2],f=l[3],g=He(UW(o),4),p=g[0],v=g[1],m=g[2],y=g[3],w=He([f+h,u+d],2),b=w[0],B=w[1],E=He([y+v,p+m],2),x=E[0],C=E[1];if("l"===c[0])return new ZV(s.x,s.y,a.width+s.width+b+x,Math.max(a.height+C,s.height));if("t"===c[0])return new ZV(s.x,s.y,Math.max(a.width+x,s.width),a.height+s.height+B+C);var M=He([e.attributes.width||a.width,e.attributes.height||a.height],2),F=M[0],k=M[1];return new ZV(a.x,a.y,F+s.width+b+x,k+s.height+B+C)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=this.attributes,r=n.width,i=n.height,o=n.x,A=void 0===o?0:o,s=n.y,a=void 0===s?0:s,c=n.classNamePrefix,l=n.render,u=QW(e),h=e.className||"legend-category";c?e.attr("className","".concat(h," ").concat(c,"legend")):e.className||e.attr("className","legend-category"),e.style.transform="translate(".concat(A,", ").concat(a,")"),l?this.renderCustom(u):(this.renderTitle(u,r,i),this.renderItems(u,this.availableSpace),this.adjustLayout())},e}(zW),m$={backgroundFill:"#262626",backgroundLineCap:"round",backgroundLineWidth:1,backgroundStroke:"#333",backgroundZIndex:-1,formatter:function(t){return t.toString()},labelFill:"#fff",labelFontSize:12,labelTextBaseline:"middle",padding:[2,4],position:"right",radius:0,zIndex:999},y$=eW({background:"background",labelGroup:"label-group",label:"label"},"indicator"),w$=function(t){function e(e){var n=t.call(this,e,m$)||this;return n.point=[0,0],n.group=n.appendChild(new Xa({})),n.isMutationObserved=!0,n}return Ie(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=He(UW(t.padding),4),r=n[0],i=n[1],o=n[2],A=n[3],s=this.label.node().getLocalBounds(),a=s.min,c=s.max,l=new ZV(a[0]-A,a[1]-r,c[0]+i-a[0]+A,c[1]+o-a[1]+r),u=this.getPath(e,l),h=PW(this.attributes,"background");this.background=QW(this.group).maybeAppendByClassName(y$.background,"path").styles(Le(Le({},h),{d:u})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=He(RW(PW(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var A=Pe(i,["text"]);(this.label=QW(this.group).maybeAppendByClassName(y$.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(y$.label,function(){return uW(e(n))}).style("text",e(n).toString()).selectAll("text").styles(A)},e.prototype.adjustLayout=function(){var t=He(this.point,2),e=t[0],n=t[1],r=this.attributes,i=r.x,o=r.y;this.group.attr("transform","translate(".concat(i-e,", ").concat(o-n,")"))},e.prototype.getPath=function(t,e){var n=this.attributes.radius,r=e.x,i=e.y,o=e.width,A=e.height,s=[["M",r+n,i],["L",r+o-n,i],["A",n,n,0,0,1,r+o,i+n],["L",r+o,i+A-n],["A",n,n,0,0,1,r+o-n,i+A],["L",r+n,i+A],["A",n,n,0,0,1,r,i+A-n],["L",r,i+n],["A",n,n,0,0,1,r+n,i],["Z"]],a={top:4,right:6,bottom:0,left:2}[t],c=this.createCorner([s[a].slice(-2),s[a+1].slice(-2)]);return s.splice.apply(s,_e([a+1,1],He(c),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=TW.apply(void 0,_e([],He(t),!1)),r=He(t,2),i=He(r[0],2),o=i[0],A=i[1],s=He(r[1],2),a=s[0],c=s[1],l=He(n?[a-o,[o,a]]:[c-A,[A,c]],2),u=l[0],h=He(l[1],2),d=h[0],f=h[1],g=u/2,p=e*(u/Math.abs(u)),v=p/2,m=p*Math.sqrt(3)/2*.8,y=He([d,d+g-v,d+g,d+g+v,f],5),w=y[0],b=y[1],B=y[2],E=y[3],x=y[4];return n?(this.point=[B,A-m],[["L",w,A],["L",b,A],["L",B,A-m],["L",E,A],["L",x,A]]):(this.point=[o+m,B],[["L",o,w],["L",o,b],["L",o+m,B],["L",o,E],["L",o,x]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?zV(this):jV(this)},e.prototype.bindEvents=function(){this.label.on(ea.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(zW);function b$(t){return void 0===t&&(t=""),{CONTAINER:"".concat(t,"tooltip"),TITLE:"".concat(t,"tooltip-title"),LIST:"".concat(t,"tooltip-list"),LIST_ITEM:"".concat(t,"tooltip-list-item"),NAME:"".concat(t,"tooltip-list-item-name"),MARKER:"".concat(t,"tooltip-list-item-marker"),NAME_LABEL:"".concat(t,"tooltip-list-item-name-label"),VALUE:"".concat(t,"tooltip-list-item-value"),CROSSHAIR_X:"".concat(t,"tooltip-crosshair-x"),CROSSHAIR_Y:"".concat(t,"tooltip-crosshair-y")}}var B$={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function E$(t){var e;void 0===t&&(t="");var n=b$(t);return(e={})[".".concat(n.CONTAINER)]={position:"absolute",visibility:"visible","z-index":8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)","background-color":"rgba(255, 255, 255, 0.96)","box-shadow":"0 6px 12px 0 rgba(0, 0, 0, 0.12)","border-radius":"4px",color:"rgba(0, 0, 0, 0.65)","font-size":"12px","line-height":"20px",padding:"12px","min-width":"120px","max-width":"360px","font-family":"Roboto-Regular"},e[".".concat(n.TITLE)]={color:"rgba(0, 0, 0, 0.45)"},e[".".concat(n.LIST)]={margin:"0px","list-style-type":"none",padding:"0px"},e[".".concat(n.LIST_ITEM)]={"list-style-type":"none",display:"flex","line-height":"2em","align-items":"center","justify-content":"space-between","white-space":"nowrap"},e[".".concat(n.MARKER)]={width:"8px",height:"8px","border-radius":"50%",display:"inline-block","margin-right":"4px"},e[".".concat(n.NAME)]={display:"flex","align-items":"center","max-width":"216px"},e[".".concat(n.NAME_LABEL)]=Le({flex:1},B$),e[".".concat(n.VALUE)]=Le({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},B$),e[".".concat(n.CROSSHAIR_X)]={position:"absolute",width:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e[".".concat(n.CROSSHAIR_Y)]={position:"absolute",height:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e}var x$=function(t){function e(e){var n,r,i=this,o=null===(r=null===(n=e.style)||void 0===n?void 0:n.template)||void 0===r?void 0:r.prefixCls,A=b$(o);return(i=t.call(this,e,{data:[],x:0,y:0,visibility:"visible",title:"",position:"bottom-right",offset:[5,5],enterable:!1,container:{x:0,y:0},bounding:null,template:{prefixCls:"",container:'
'),title:'
'),item:'
  • \n \n \n {name}\n \n {value}\n
  • ')},style:E$(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return Ie(e,t),Object.defineProperty(e.prototype,"HTMLTooltipElement",{get:function(){return this.element},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.element},Object.defineProperty(e.prototype,"elementSize",{get:function(){return{width:this.element.offsetWidth,height:this.element.offsetHeight}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"HTMLTooltipItemsElements",{get:function(){var t=this.attributes,e=t.data,n=t.template;return e.map(function(t,e){var r=t.name,i=void 0===r?"":r,o=t.color,A=void 0===o?"black":o,s=t.index,a=Pe(t,["name","color","index"]),c=Le({name:i,color:A,index:null!=s?s:e},a);return Sn(function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]}):t}(n.item,c))})},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.renderHTMLTooltipElement(),this.updatePosition()},e.prototype.destroy=function(){var e;null===(e=this.element)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.show=function(t,e){var n=this;if(void 0!==t&&void 0!==e){var r=function(){n.attributes.x=null!=t?t:n.attributes.x,n.attributes.y=null!=e?e:n.attributes.y,n.updatePosition()};"hidden"===this.element.style.visibility?this.closeTransition(r):r()}this.element.style.visibility="visible"},e.prototype.hide=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.attributes.enterable&&this.isCursorEntered(t,e)||(this.element.style.visibility="hidden")},e.prototype.initShape=function(){var t=this.attributes.template;this.element=Sn(t.container),this.id&&this.element.setAttribute("id",this.id)},e.prototype.renderCustomContent=function(){if(void 0===this.prevCustomContentKey||this.prevCustomContentKey!==this.attributes.contentKey){this.prevCustomContentKey=this.attributes.contentKey;var t=this.attributes.content;t&&("string"==typeof t?this.element.innerHTML=t:GW(this.element,t))}},e.prototype.renderHTMLTooltipElement=function(){var t,e,n=this.attributes,r=n.template,i=n.title,o=n.enterable,A=n.style,s=n.content,a=b$(r.prefixCls),c=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(c.innerHTML=r.title,c.getElementsByClassName(a.TITLE)[0].innerHTML=i):null===(e=null===(t=c.getElementsByClassName(a.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var l=this.HTMLTooltipItemsElements,u=document.createElement("ul");u.className=a.LIST,GW(u,l);var h=this.element.querySelector(".".concat(a.LIST));h?h.replaceWith(u):c.appendChild(u)}!function(t,e){Object.entries(e).forEach(function(e){var n=He(e,2),r=n[0],i=n[1];_e([t],He(t.querySelectorAll(r)),!1).filter(function(t){return t.matches(r)}).forEach(function(t){t&&(t.style.cssText+=Object.entries(i).reduce(function(t,e){return"".concat(t).concat(e.join(":"),";")},""))})})}(c,A)},e.prototype.getRelativeOffsetFromCursor=function(t){var e=this.attributes,n=e.position,r=e.offset,i=(t||n).split("-"),o={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]},A=this.elementSize,s=A.width,a=A.height,c=[-s/2,-a/2];return i.forEach(function(t){var e=He(c,2),n=e[0],i=e[1],A=He(o[t],2),l=A[0],u=A[1];c=[n+(s/2+r[0])*l,i+(a/2+r[1])*u]}),c},e.prototype.setOffsetPosition=function(t){var e=He(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,A=void 0===o?0:o,s=i.y,a=void 0===s?0:s,c=i.container,l=c.x,u=c.y;this.element.style.left="".concat(+A+l+n,"px"),this.element.style.top="".concat(+a+u+r,"px")},e.prototype.updatePosition=function(){var t=this.attributes.showDelay,e=void 0===t?60:t,n=Date.now();this.timestamp>0&&n-this.timestampp+s.width,top:fv+s.height},y=[];a.split("-").forEach(function(t){m[t]?y.push(g[t]):y.push(t)});var w=y.join("-");return this.getRelativeOffsetFromCursor(w)},e.prototype.isCursorEntered=function(t,e){if(this.element){var n=this.element.getBoundingClientRect(),r=n.x,i=n.y,o=n.width,A=n.height;return new ZV(r,i,o,A).isPointIn(t,e)}return!1},e.prototype.closeTransition=function(t){var e=this,n=this.element.style.transition;this.element.style.transition="none",t(),setTimeout(function(){e.element.style.transition=n},10)},e.tag="tooltip",e}(zW),C$=function(t){function e(n){var r=t.call(this,rW({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new sc({})),r.label=r.background.appendChild(new Xa({})),r}return Ie(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return UW(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=PW(this.attributes,"label");QW(this.label).maybeAppend(".label",function(){return uW(e)}).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=He(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3],A=t.width,s=t.height,a=A+o+r,c=s+n+i,l=PW(this.attributes,"background"),u=this.style,h=u.width,d=void 0===h?0:h,f=u.height,g=void 0===f?0:f,p=u.selected;this.background.attr(Le(Le({},l),{width:Math.max(a,d),height:Math.max(c,g),fill:p?this.selectedColor:"#fff"})),this.label.attr({transform:"translate(".concat(o,", ").concat((c-s)/2,")")})},e.prototype.render=function(){this.renderLabel(),this.renderBackground()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("pointerenter",function(){t.style.selected||t.background.attr("fill",t.hoverColor)}),this.addEventListener("pointerleave",function(){t.style.selected||t.background.attr("fill",t.style.backgroundFill)});var e=this;this.addEventListener("click",function(){var n=t.style,r=n.label,i=n.value,o=n.onClick;null==o||o(i,{label:r,value:i},e)})},e.defaultOptions={style:{value:"",label:"",cursor:"pointer"}},e}(zW),M$=function(t){function e(n){var r,i,o=t.call(this,rW({},e.defaultOptions,n))||this;o.currentValue=null===(r=e.defaultOptions.style)||void 0===r?void 0:r.defaultValue,o.isPointerInSelect=!1,o.select=o.appendChild(new sc({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new sc({className:"dropdown"}));var A=o.style.defaultValue;return A&&(null===(i=o.style.options)||void 0===i?void 0:i.some(function(t){return t.value===A}))&&(o.currentValue=A),o}return Ie(e,t),e.prototype.setValue=function(t){this.currentValue=t,this.render()},e.prototype.getValue=function(){return this.currentValue},Object.defineProperty(e.prototype,"dropdownPadding",{get:function(){return UW(this.style.dropdownPadding)},enumerable:!1,configurable:!0}),e.prototype.renderSelect=function(){var t,e=this,n=this.style,r=n.x,i=n.y,o=n.width,A=n.height,s=n.bordered,a=n.showDropdownIcon,c=PW(this.attributes,"select"),l=PW(this.attributes,"placeholder");this.select.attr(Le(Le({x:r,y:i,width:o,height:A},c),{fill:"#fff",strokeWidth:s?1:0}));var u=this.dropdownPadding;a&&QW(this.select).maybeAppend(".dropdown-icon","path").style("d","M-5,-3.5 L0,3.5 L5,-3.5").style("transform","translate(".concat(r+o-10-u[1]-u[3],", ").concat(i+A/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var h=null===(t=this.style.options)||void 0===t?void 0:t.find(function(t){return t.value===e.currentValue}),d=Le({x:r+u[3]},l);QW(this.select).selectAll(".placeholder").data(h?[]:[1]).join(function(t){return t.append("text").attr("className","placeholder").styles(d).style("y",function(){var t=this.getBBox();return i+(A-t.height)/2})},function(t){return t.styles(d)},function(t){return t.remove()});var f=PW(this.attributes,"optionLabel"),g=Le({x:r+u[3]},f);QW(this.select).selectAll(".value").data(h?[h]:[]).join(function(t){return t.append(function(t){return uW(t.label)}).attr("className","value").styles(g).style("y",function(){var t=this.getBBox();return i+(A-t.height)/2})},function(t){return t.styles(g)},function(t){return t.remove()})},e.prototype.renderDropdown=function(){var t,e,n=this,r=this.style,i=r.x,o=r.y,A=r.width,s=r.height,a=r.options,c=r.onSelect,l=r.open,u=PW(this.attributes,"dropdown"),h=PW(this.attributes,"option"),d=this.dropdownPadding;QW(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(a,function(t){return t.value}).join(function(t){return t.append(function(t){return new C$({className:"dropdown-item",style:Le(Le(Le({},t),h),{width:A-d[1]-d[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==c||c(t,e,r),n.dispatchEvent(new Vs("change",{detail:{value:t,option:e,item:r}})),zV(n.dropdown)}})})}).each(function(t,e){var n,r=(null===(n=this.parentNode)||void 0===n?void 0:n.children).reduce(function(t,n,r){return re.time?1:0})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"space",{get:function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,A=t.controllerHeight,s=ne(+i-A,0,+i),a=new ZV(e,n+ +i-A,+r,A),c=0,l="time"===o?10:s;return{axisBBox:"chart"===o?new ZV(e,n+s-(c=35),+r,c):new ZV,controllerBBox:a,timelineBBox:new ZV(e,n+("time"===o?s:s-l),+r,l-c)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=He(Array.isArray(t)?t:[0,t],2),o=i[0],A=i[1],s=r.length,a=r[Math.floor(o*s)],c=r[Math.ceil(A*s)-(Array.isArray(t)?0:1)];this.states.values=[null!==(e=null==a?void 0:a.time)&&void 0!==e?e:r[0].time,null!==(n=null==c?void 0:c.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=He(Array.isArray(t)?t:[void 0,t],2),A=o[0],s=o[1],a=i.find(function(t){return t.time===A}),c=i.find(function(t){return t.time===s});this.states.values=[null!==(e=null==a?void 0:a.time)&&void 0!==e?e:null===(n=i[0])||void 0===n?void 0:n.time,null!==(r=null==c?void 0:c.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,A=He(t,2),s=A[0],a=A[1];this.states.values=[null!==(n=null===(e=o[s])||void 0===e?void 0:e.time)&&void 0!==n?n:o[0].time,null!==(i=null===(r=this.data[a])||void 0===r?void 0:r.time)&&void 0!==i?i:1/0]},Object.defineProperty(e.prototype,"sliderValues",{get:function(){var t,e=this.states,n=e.values,r=e.selectionType,i=He(Array.isArray(n)?n:[void 0,n],2),o=i[0],A=i[1],s=this.data,a=s.length,c="value"===r;return[(t=s.findIndex(function(t){return t.time===o}),c?0:t>-1?t/a:0),function(){if(A===1/0)return 1;var t=s.findIndex(function(t){return t.time===A});return t>-1?t/a:c?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=He(Array.isArray(e)?e:[this.data[0].time,e],2),i=r[0],o=r[1];return"value"===n?o:[i,o]},enumerable:!1,configurable:!0}),e.prototype.getDatumByRatio=function(t){var e=this.data,n=e.length;return e[Math.floor(t*(n-1))]},Object.defineProperty(e.prototype,"chartHandleIconShape",{get:function(){var t=this.states.selectionType,e=this.space.timelineBBox.height;return"range"===t?function(t){return new Y$({style:{type:t,height:e,iconSize:e/6}})}:function(){return new tc({style:{x1:0,y1:-e/2,x2:0,y2:e/2,lineWidth:2,stroke:"#c8c8c8"}})}},enumerable:!1,configurable:!0}),e.prototype.getChartStyle=function(t){var e=this,n=t.x,r=t.y,i=t.width,o=t.height,A=this.states,s=A.selectionType,a=A.chartType,c=this.data,l=this.attributes,u=l.type,h=l.labelFormatter,d=PW(this.attributes,"chart");d.type;var f=Pe(d,["type"]),g="range"===s;if("time"===u)return Le({handleIconShape:function(){return new W$({})},selectionFill:"#2e7ff8",selectionFillOpacity:1,showLabelOnInteraction:!0,handleLabelDy:g?-15:0,autoFitLabel:g,handleSpacing:g?-15:0,trackFill:"#edeeef",trackLength:i,trackOpacity:.5,trackRadius:o/2,trackSize:o/2,type:s,values:this.sliderValues,formatter:function(t){if(h)return h(t);var n=e.getDatumByRatio(t).time;return"number"==typeof n?q$(n):HW(n,"YYYY-MM-DD HH:mm:ss")},transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},f);var p="range"===s?5:0,v=c.map(function(t){return t.value});return Le({handleIconOffset:p,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:v,sparklineType:a,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},f)},e.prototype.renderChart=function(t){void 0===t&&(t=this.space.timelineBBox),this.timeline.update(this.getChartStyle(t))},e.prototype.updateSelection=function(){this.timeline.setValues(this.sliderValues,!0),this.handleSliderChange(this.sliderValues)},e.prototype.getAxisStyle=function(t){var e=this.data,n=this.attributes,r=n.interval,i=n.labelFormatter,o=PW(this.attributes,"axis"),A=t.x,s=t.y,a=t.width,c=_e(_e([],He(e),!1),[{time:0}],!1).map(function(t,e,n){var r=t.time;return{label:"".concat(r),value:e/(n.length-1),time:r}}),l=Le({startPos:[A,s],endPos:[A+a,s],data:c,labelFilter:function(t,e){return er?"value"===A?[0,0]:"acc"===s?[o(n),o(n)]:[0,o(i-n)]:n<0?"acc"===s?[0,o(i)]:[o(n+r-i),r]:[o(n),o(i)]}(d);return this.setByIndex(g),this.updateSelection(),g},e.prototype.internalBackward=function(t){var e,n,r=this.moveSelection("backward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onBackward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.backward=function(){this.internalBackward()},e.prototype.internalPlay=function(t){var e,n,r=this,i=this.data,o=this.attributes.loop,A=this.states.speed,s=void 0===A?1:A;this.playInterval=window.setInterval(function(){r.internalForward()[1]!==i.length||o||(r.internalPause(),r.renderController())},1e3/s),this.states.state="play",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPlay)||void 0===n||n.call(e))},e.prototype.play=function(){this.internalPlay()},e.prototype.internalPause=function(t){var e,n;clearInterval(this.playInterval),this.states.state="pause",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPause)||void 0===n||n.call(e))},e.prototype.pause=function(){this.internalPause()},e.prototype.internalForward=function(t){var e,n,r=this.moveSelection("forward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onForward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.forward=function(){this.internalForward()},e.prototype.handleSpeedChange=function(t){var e,n;this.states.speed=t,"play"===this.states.state&&(this.internalPause(!0),this.internalPlay(!0)),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSpeedChange)||void 0===n||n.call(e,t)},e.prototype.handleSelectionTypeChange=function(t){var e,n;this.states.selectionType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSelectionTypeChange)||void 0===n||n.call(e,t)},e.prototype.handleChartTypeChange=function(t){var e,n;this.states.chartType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onChartTypeChange)||void 0===n||n.call(e,t)},e.prototype.render=function(){var t=this.space,e=t.axisBBox,n=t.controllerBBox,r=t.timelineBBox;this.renderController(n),this.renderAxis(e),this.renderChart(r),"play"===this.states.state&&this.internalPlay()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.internalPause(!0)},e.defaultOptions={style:{x:0,y:0,axisLabelFill:"#6e6e6e",axisLabelTextAlign:"left",axisLabelTextBaseline:"top",axisLabelTransform:"translate(5, -12)",axisLineLineWidth:1,axisLineStroke:"#cacdd1",axisTickLength:15,axisTickLineWidth:1,axisTickStroke:"#cacdd1",chartShowLabel:!1,chartType:"line",controllerAlign:"center",controllerHeight:40,data:[],interval:"day",loop:!1,playMode:"acc",selectionType:"range",type:"time"}},e}(zW);function Z$(t){const{width:e,height:n,renderer:r}=t,i=function(t){var e;const{container:n,className:r,graphCanvas:i}=t;if(n)return"string"==typeof n?document.getElementById(n):n;const o=ez(r,!1),{width:A,height:s,containerStyle:a}=t,[c,l]=function(t){const{width:e,height:n,placement:r,graphCanvas:i}=t,[o,A]=i.getSize(),[s,a]=Cy(r);return[s*(o-e),a*(A-n)]}(t);return Object.assign(o.style,Object.assign({position:"absolute",left:c+"px",top:l+"px",width:A+"px",height:s+"px"},a)),null===(e=i.getContainer())||void 0===e||e.appendChild(o),o}(t);return[i,new xc({width:e,height:n,container:i,renderer:r||new _b})]}class J$ extends tz{constructor(e,n){super(e,Object.assign({},J$.defaultOptions,n)),this.typePrefix="__data__",this.draw=!1,this.fieldMap={node:new Map,edge:new Map,combo:new Map},this.selectedItems=[],this.bindEvents=()=>{const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.createElement)},this.changeState=(t,e)=>{const{graph:n}=this.context,{typePrefix:r}=this,i=Ce(t,[r,"id"]),o=Ce(t,[r,"style","labelText"]),[A]=i.split("__"),s=this.fieldMap[A].get(o)||[];n.setElementState(Object.fromEntries(null==s?void 0:s.map(t=>[t,e])))},this.click=t=>{if("hover"===this.options.trigger)return;const e=Ce(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?(this.selectedItems=this.selectedItems.filter(t=>t!==e),this.changeState(t,[])):(this.selectedItems.push(e),this.changeState(t,"selected"))},this.mouseleave=t=>{"click"!==this.options.trigger&&(this.selectedItems=[],this.changeState(t,[]))},this.mouseenter=t=>{if("click"===this.options.trigger)return;const e=Ce(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?this.selectedItems=this.selectedItems.filter(t=>t!==e):(this.selectedItems.push(e),this.changeState(t,"active"))},this.setFieldMap=(t,e,n)=>{if(!t)return;const r=this.fieldMap[n];if(r)if(r.has(t)){const n=r.get(t);n&&(n.push(e),r.set(t,n))}else r.set(t,[e])},this.getEvents=()=>({mouseenter:this.mouseenter,mouseleave:this.mouseleave,click:this.click}),this.getMarkerData=(t,e)=>{if(!t)return[];const{model:n,element:r}=this.context,{nodes:i,edges:o,combos:A}=n.getData(),s={},a=e=>Gt(t)?t(e):t,c={node:"circle",edge:"line",combo:"rect"},l={circle:"circle",ellipse:"circle",image:"bowtie",rect:"square",star:"cross",triangle:"triangle",diamond:"diamond",cubic:"dot",line:"hyphen",polyline:"hyphen",quadratic:"hv","cubic-horizontal":"hyphen","cubic-vertical":"line"},u=(t,e)=>{t.forEach(t=>{const{id:n}=t,i=Ce(t,["data",a(t)]),o=(null==r?void 0:r.getElementType(e,t))||"circle",A=((t,e)=>null==r?void 0:r.getElementComputedStyle(t,e))(e,t),u=("edge"===e?null==A?void 0:A.stroke:null==A?void 0:A.fill)||"#1783ff";n&&i&&i.replace(/\s+/g,"")&&(this.setFieldMap(i,n,e),s[i]||(s[i]={id:`${e}__${n}`,label:i,marker:l[o]||c[e],elementType:e,lineWidth:1,stroke:u,fill:u}))})};switch(e){case"node":u(i,"node");break;case"edge":u(o,"edge");break;case"combo":u(A,"combo");break;default:return[]}return Object.values(s)},this.createElement=()=>{if(this.draw)return void this.updateElement();const t=this.options,{width:e,height:n,nodeField:r,edgeField:i,comboField:o,trigger:A,position:s,container:a,containerStyle:c,className:l}=t,u=Pe(t,["width","height","nodeField","edgeField","comboField","trigger","position","container","containerStyle","className"]),h=this.getMarkerData(r,"node"),d=this.getMarkerData(i,"edge"),f=this.getMarkerData(o,"combo"),g=[...h,...f,...d],p=Object.assign({width:e,height:n,data:g,itemMarkerLineWidth:({lineWidth:t})=>t,itemMarker:({marker:t})=>t,itemMarkerStroke:({stroke:t})=>t,itemMarkerFill:({fill:t})=>t,gridCol:h.length},u,this.getEvents()),v=new v$({className:"legend",style:p});this.category=v;this.upsertCanvas().appendChild(v),this.draw=!0},this.bindEvents()}update(t){super.update(t),this.clear(),this.createElement()}clear(){var t,e;null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.container)||void 0===e||e.remove(),this.canvas=void 0,this.container=void 0,this.draw=!1}updateElement(){this.category&&this.category.update({itemMarkerOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5,itemLabelOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5})}upsertCanvas(){if(this.canvas)return this.canvas;const t=this.context.canvas,[e,n]=t.getSize(),{width:r=e,height:i=n,position:o,container:A,containerStyle:s,className:a}=this.options,[c,l]=Z$({width:r,height:i,graphCanvas:t,container:A,containerStyle:s,placement:o,className:"legend"});return this.container=c,a&&c.classList.add(a),this.canvas=l,this.canvas}destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}J$.defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16,width:240,height:160};class tZ extends tz{constructor(t,e){super(t,Object.assign({},tZ.defaultOptions,e)),this.onDraw=t=>{var e;(null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.render)||this.onRender()},this.landmarkMap=new Map,this.mask=null,this.isMaskDragging=!1,this.onMaskDragStart=t=>{this.mask&&(this.isMaskDragging=!0,this.mask.setPointerCapture(t.pointerId),this.mask.addEventListener("pointermove",this.onMaskDrag),this.mask.addEventListener("pointerup",this.onMaskDragEnd),this.mask.addEventListener("pointercancel",this.onMaskDragEnd))},this.onMaskDrag=t=>{if(!this.mask||!this.isMaskDragging)return;const{size:[e,n]}=this.options,{movementX:r,movementY:i}=t,{left:o,top:A,width:s,height:a}=this.mask.style,[,,c,l]=this.maskBBox;let u=parseInt(o)+r,h=parseInt(A)+i,d=parseInt(s),f=parseInt(a);u<0&&(u=0),h<0&&(h=0),u+d>e&&(u=nZ(e-d,0)),h+f>n&&(h=nZ(n-f,0)),d0?(u=nZ(u-r,0),d=eZ(d+r,e)):r<0&&(d=eZ(d-r,e))),f0?(h=nZ(h-i,0),f=eZ(f+i,n)):i<0&&(f=eZ(f-i,n))),Object.assign(this.mask.style,{left:u+"px",top:h+"px",width:d+"px",height:f+"px"});const g=parseInt(o)-u,p=parseInt(A)-h;if(0===g&&0===p)return;const v=this.context.canvas.getCamera().getZoom()/this.canvas.getCamera().getZoom();this.context.graph.translateBy([g*v,p*v],!1)},this.onMaskDragEnd=t=>{this.mask&&(this.isMaskDragging=!1,this.mask.releasePointerCapture(t.pointerId),this.mask.removeEventListener("pointermove",this.onMaskDrag),this.mask.removeEventListener("pointerup",this.onMaskDragEnd),this.mask.removeEventListener("pointercancel",this.onMaskDragEnd))},this.onTransform=Qe(()=>{this.isMaskDragging||(this.updateMask(),this.setCamera())},32,{leading:!0}),this.setOnRender(),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),"delay"in t&&this.setOnRender(),this.bindEvents()}setOnRender(){this.onRender=pe(()=>{this.renderMinimap(),this.renderMask()},this.options.delay)}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.onDraw),e.on(t.GraphEvent.AFTER_RENDER,this.onRender),e.on(t.GraphEvent.AFTER_ANIMATE,this.onRender),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.onDraw),e.off(t.GraphEvent.AFTER_RENDER,this.onRender),e.off(t.GraphEvent.AFTER_ANIMATE,this.onRender),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}renderMinimap(){const t=this.getElements(),e=this.initCanvas();this.setShapes(e,t)}getElements(){const{filter:t}=this.options,{model:e,element:n}=this.context,r=e.getData(),i={nodes:r.nodes.filter(t=>null==n?void 0:n.getElement(Km(t))),edges:r.edges.filter(t=>{const e=null==n?void 0:n.getElement(Km(t));return e&&JB(e)}),combos:r.combos.filter(t=>null==n?void 0:n.getElement(Km(t)))};if(!t)return i;const{nodes:o,edges:A,combos:s}=i;return{nodes:o.filter(e=>t(Km(e),"node")),edges:A.filter(e=>t(Km(e),"edge")),combos:s.filter(e=>t(Km(e),"combo"))}}setShapes(t,e){const{nodes:n,edges:r,combos:i}=e,{shape:o}=this.options,{element:A}=this.context,s=(e,n)=>{const r=Km(e),i=null==A?void 0:A.getElement(r);if(!i)return;const s=i.getShape("key");let a;if("string"==typeof o){const t=o;a=i.getShape(t).cloneNode()}else{const t=o(r,n,i);a=t===i?t.cloneNode(!0):t}a.setPosition(s.getPosition()),i.style.zIndex&&(a.style.zIndex=i.style.zIndex),a.id=i.id,t.appendChild(a)};t.removeChildren(),r.forEach(t=>s(t,"edge")),i.forEach(t=>s(t,"combo")),n.forEach(t=>s(t,"node"))}initCanvas(){const{renderer:t,size:[e,n]}=this.options;if(this.canvas){const{width:r,height:i}=this.canvas.getConfig();e===r&&n===i||this.canvas.resize(e,n),t&&this.canvas.setRenderer(t)}else{const{className:r,position:i,container:o,containerStyle:A}=this.options,[s,a]=Z$({renderer:t,width:e,height:n,placement:i,className:"minimap",container:o,containerStyle:A,graphCanvas:this.context.canvas});r&&s.classList.add(r),this.container=s,this.canvas=a}return this.setCamera(),this.canvas}createLandmark(t,e,n){const r=`${t.join(",")}-${e.join(",")}-${n}`;if(this.landmarkMap.has(r))return this.landmarkMap.get(r);const i=this.canvas.getCamera().createLandmark(r,{position:t,focalPoint:e,zoom:n});return this.landmarkMap.set(r,i),i}setCamera(){var t;const{canvas:e}=this.context,n=null===(t=this.canvas)||void 0===t?void 0:t.getCamera();if(!n)return;const{size:[r,i],padding:o}=this.options,[A,s,a,c]=pm(o),{min:l,max:u,center:h}=e.getBounds("elements"),d=(r-c-s)/(u[0]-l[0]),f=(i-A-a)/(u[1]-l[1]),g=Math.min(d,f),p=this.createLandmark(h,h,g);n.gotoLandmark(p,0)}get maskBBox(){const{canvas:t}=this.context,e=t.getSize(),n=t.getCanvasByViewport([0,0]),r=t.getCanvasByViewport(e),i=this.canvas.canvas2Viewport(Qy(n)),o=this.canvas.canvas2Viewport(Qy(r)),A=o.x-i.x,s=o.y-i.y;return[i.x,i.y,A,s]}calculateMaskBBox(){const{size:[t,e]}=this.options;let[n,r,i,o]=this.maskBBox;return n<0&&(i=eZ(i+n,t),n=0),r<0&&(o=eZ(o+r,e),r=0),n+i>t&&(i=nZ(t-n,0)),r+o>e&&(o=nZ(e-r,0)),[eZ(n,t),eZ(r,e),nZ(i,0),nZ(o,0)]}renderMask(){const{maskStyle:t}=this.options;this.mask||(this.mask=document.createElement("div"),this.mask.addEventListener("pointerdown",this.onMaskDragStart),this.mask.draggable=!0,this.mask.addEventListener("dragstart",t=>t.preventDefault&&t.preventDefault())),this.container.appendChild(this.mask),Object.assign(this.mask.style,Object.assign(Object.assign({},t),{cursor:"move",position:"absolute",pointerEvents:"auto"})),this.updateMask()}updateMask(){if(!this.mask)return;const[t,e,n,r]=this.calculateMaskBBox();Object.assign(this.mask.style,{top:e+"px",left:t+"px",width:n+"px",height:r+"px"})}destroy(){var t,e,n;this.unbindEvents(),null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.mask)||void 0===e||e.remove(),null===(n=this.container)||void 0===n||n.remove(),super.destroy()}}tZ.defaultOptions={size:[240,160],shape:"key",padding:10,position:"right-bottom",maskStyle:{border:"1px solid #ddd",background:"rgba(0, 0, 0, 0.1)"},containerStyle:{border:"1px solid #ddd",background:"#fff"},delay:128};const eZ=(t,e)=>Math.min(t,e),nZ=(t,e)=>Math.max(t,e),rZ={x1:0,y1:0,x2:0,y2:0,visibility:"hidden"};class iZ extends tz{constructor(t,e){super(t,Object.assign({},iZ.defaultOptions,e)),this.initSnapline=()=>{const t=this.context.canvas.getLayer("transient");this.horizontalLine||(this.horizontalLine=t.appendChild(new tc({style:Object.assign(Object.assign({},rZ),this.options.horizontalLineStyle)}))),this.verticalLine||(this.verticalLine=t.appendChild(new tc({style:Object.assign(Object.assign({},rZ),this.options.verticalLineStyle)})))},this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!0,this.autoSnapToLine=(t,e,n)=>De(this,void 0,void 0,function*(){const{verticalX:r,horizontalY:i}=n,{tolerance:o}=this.options,{min:[A,s],max:[a,c],center:[l,u]}=e;let h=0,d=0;null!==r&&(oZ(a,r){const{target:e}=t,n=.5;if(this.isHorizontalSticking||this.isVerticalSticking){const[r,i]=this.getDelta(t);if(this.isHorizontalSticking&&this.isVerticalSticking&&Math.abs(r)<=n&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,-i]},!1),!1;if(this.isHorizontalSticking&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[0,-i]},!1),!1;if(this.isVerticalSticking&&Math.abs(r)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,0]},!1),!1;this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!1,setTimeout(()=>{this.enableStick=!0},200)}return this.enableStick},this.calcSnaplineMetadata=(t,e)=>{const{tolerance:n,shape:r}=this.options,{min:[i,o],max:[A,s],center:[a,c]}=e;let l=null,u=null,h=null,d=null,f=null,g=null;return this.getNodes().some(e=>{if(xe(t.id,e.id))return!1;const p=AZ(e,r).getRenderBounds(),{min:[v,m],max:[y,w],center:[b,B]}=p;return null===l&&(oZ(b,a){this.initSnapline()},this.onDrag=t=>De(this,void 0,void 0,function*(){const{target:e}=t;if(this.options.autoSnap){if(!this.enableSnap(t))return}const n=AZ(e,this.options.shape).getRenderBounds(),r=this.calcSnaplineMetadata(e,n);this.hideSnapline(),null===r.verticalX&&null===r.horizontalY||this.updateSnapline(r),this.options.autoSnap&&(yield this.autoSnapToLine(e.id,n,r))}),this.onDragEnd=()=>{this.hideSnapline()},this.bindEvents()}getNodes(){var t;const{filter:e}=this.options,n=((null===(t=this.context.element)||void 0===t?void 0:t.getNodes())||[]).filter(t=>{var e;return JB(t)&&(null===(e=this.context.viewport)||void 0===e?void 0:e.isInViewport(t.getRenderBounds()))});return e?n.filter(t=>e(t)):n}hideSnapline(){this.horizontalLine.style.visibility="hidden",this.verticalLine.style.visibility="hidden"}getLineWidth(t){const{lineWidth:e}=this.options[`${t}LineStyle`];return+(e||rZ.lineWidth||1)/this.context.graph.getZoom()}updateSnapline(t){const{verticalX:e,verticalMinY:n,verticalMaxY:r,horizontalY:i,horizontalMinX:o,horizontalMaxX:A}=t,[s,a]=this.context.canvas.getSize(),{offset:c}=this.options;null!==i?Object.assign(this.horizontalLine.style,{x1:c===1/0?0:o-c,y1:i,x2:c===1/0?s:A+c,y2:i,visibility:"visible",lineWidth:this.getLineWidth("horizontal")}):this.horizontalLine.style.visibility="hidden",null!==e?Object.assign(this.verticalLine.style,{x1:e,y1:c===1/0?0:n-c,x2:e,y2:c===1/0?a:r+c,visibility:"visible",lineWidth:this.getLineWidth("vertical")}):this.verticalLine.style.visibility="hidden"}getDelta(t){const e=this.context.graph.getZoom();return uy([t.dx,t.dy],e)}bindEvents(){return De(this,void 0,void 0,function*(){const{graph:e}=this.context;e.on(t.NodeEvent.DRAG_START,this.onDragStart),e.on(t.NodeEvent.DRAG,this.onDrag),e.on(t.NodeEvent.DRAG_END,this.onDragEnd)})}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.DRAG_START,this.onDragStart),e.off(t.NodeEvent.DRAG,this.onDrag),e.off(t.NodeEvent.DRAG_END,this.onDragEnd)}destroyElements(){var t,e;null===(t=this.horizontalLine)||void 0===t||t.destroy(),null===(e=this.verticalLine)||void 0===e||e.destroy()}destroy(){this.destroyElements(),this.unbindEvents(),super.destroy()}}iZ.defaultOptions={tolerance:5,offset:20,autoSnap:!0,shape:"key",verticalLineStyle:{stroke:"#1783FF"},horizontalLineStyle:{stroke:"#1783FF"},filter:()=>!0};const oZ=(t,e)=>Math.abs(t-e),AZ=(t,e)=>"function"==typeof e?e(t):t.getShape(e),sZ=["timestamp","time","date","datetime"];class aZ extends tz{get padding(){return pm(this.options.padding)}constructor(t,e){super(t,Object.assign({},aZ.defaultOptions,e)),this.backup(),this.upsertTimebar()}play(){var t;null===(t=this.timebar)||void 0===t||t.play()}pause(){var t;null===(t=this.timebar)||void 0===t||t.pause()}forward(){var t;null===(t=this.timebar)||void 0===t||t.forward()}backward(){var t;null===(t=this.timebar)||void 0===t||t.backward()}reset(){var t;null===(t=this.timebar)||void 0===t||t.reset()}update(t){super.update(t),this.backup(),this.upsertTimebar()}backup(){this.originalData=cZ(this.context.graph.getData())}upsertTimebar(){const{canvas:t}=this.context,e=this.options,{onChange:n,timebarType:r,data:i,x:o,y:A,width:s,height:a,mode:c}=e,l=Pe(e,["onChange","timebarType","data","x","y","width","height","mode"]),u=t.getSize(),[h]=this.padding;this.upsertCanvas().ready.then(()=>{var t;const e=Object.assign(Object.assign({x:u[0]/2-s/2,y:h,onChange:t=>{const e=(jt(t)?t:[t,t]).map(t=>function(t){return t instanceof Date}(t)?t.getTime():t);"modify"===this.options.mode?this.filterElements(e):this.hiddenElements(e),null==n||n(e)}},l),{data:i.map(t=>re(t)?{time:t,value:0}:t),width:s,height:a,type:r});this.timebar?this.timebar.update(e):(this.timebar=new $$({style:e}),null===(t=this.canvas)||void 0===t||t.appendChild(this.timebar))})}upsertCanvas(){if(this.canvas)return this.canvas;const{className:t,height:e,position:n}=this.options,r=this.context.canvas,[i]=r.getSize(),[o,,A]=this.padding,[s,a]=Z$({width:i,height:e+o+A,graphCanvas:r,className:"timebar",placement:n});return this.container=s,t&&s.classList.add(t),this.canvas=a,this.canvas}filterElements(t){return De(this,void 0,void 0,function*(){var e;if(!this.originalData)return;const{elementTypes:n,getTime:r}=this.options,{graph:i,element:o}=this.context,A=cZ(this.originalData);n.forEach(e=>{const n=`${e}s`;A[n]=(this.originalData[n]||[]).filter(e=>{const n=r(e);return!!lZ(n,t)})});const s=[...A.nodes,...A.combos].map(t=>Km(t));A.edges=A.edges.filter(t=>{const e=t.source,n=t.target;return s.includes(e)&&s.includes(n)}),i.setData(A),yield null===(e=o.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished})}hiddenElements(t){const{graph:e}=this.context,{elementTypes:n,getTime:r}=this.options,i=[],o=[];n.forEach(e=>{var n;const A=`${e}s`;((null===(n=this.originalData)||void 0===n?void 0:n[A])||[]).forEach(e=>{const n=Km(e),A=r(e);lZ(A,t)?o.push(n):i.push(n)})}),e.hideElement(i,!1),e.showElement(o,!1)}destroy(){var t,e,n;const{graph:r}=this.context;this.originalData&&r.setData(Object.assign({},this.originalData)),null===(t=this.timebar)||void 0===t||t.destroy(),null===(e=this.canvas)||void 0===e||e.destroy(),null===(n=this.container)||void 0===n||n.remove(),this.originalData=void 0,this.container=void 0,this.timebar=void 0,this.canvas=void 0,super.destroy()}}aZ.defaultOptions={position:"bottom",enable:!0,timebarType:"time",className:"g6-timebar",width:450,height:60,zIndex:3,elementTypes:["node"],padding:10,mode:"modify",getTime:t=>uZ(t,sZ,void 0),loop:!1};const cZ=t=>{const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e],edges:[...n],combos:[...r]}},lZ=(t,e)=>{if(re(e))return t===e;const[n,r]=e;return t>=n&&t<=r},uZ=(t,e,n)=>{var r;for(let n=0;n{const t=this.updateCanvas();this.renderTitle(t)},this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onRender),e.on(t.GraphEvent.AFTER_ANIMATE,this.onRender)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onRender),e.off(t.GraphEvent.AFTER_ANIMATE,this.onRender)}destroy(){var t,e;this.unbindEvents(),null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.container)||void 0===e||e.remove(),super.destroy()}updateCanvas(){const{size:t,className:e,align:n}=this.options,[r]=this.context.canvas.getSize(),[i=0,,o=0]=this.padding,A=t+i+o;if(this.canvas){const{width:t,height:e}=this.canvas.getConfig();r===t&&A===e||this.canvas.resize(r,A)}else{const t={left:"left-top",center:"top",right:"right-top"},[i,o]=Z$({width:r,height:A,placement:t[n]||t.left,className:"title-canvas",graphCanvas:this.context.canvas});e&&i.classList.add(e),this.container=i,this.canvas=o}return this.canvas}renderTitle(t){const e=new yZ({options:this.options,ctx:this.context});t.removeChildren(),e.getTitle().forEach(e=>{e&&t.appendChild(e)})}}class yZ{get padding(){return pm(this.options.padding)}constructor(t){const{options:e,ctx:n}=t;this.options=e,this.context=n}getTitle(){const t=this.options,e=pZ,n=t[e],r=vZ,i=t[r],{spacing:o=44,padding:A,align:s}=t,a=Pe(t,[e+"",r+"","spacing","padding","align"]),c=n,l=i,u=Aw(a,pZ),h=Aw(a,vZ),[d]=this.context.graph.getSize(),[f=0,g=0,,p=0]=this.padding,v=d,m=v-p-g;let y=null,w=p,b="left";switch(s){case"left":default:w=p,b="left";break;case"center":w=v/2,b="center";break;case"right":w=v-g,b="right"}const B=new yw({className:pZ,style:Object.assign(Object.assign(Object.assign(Object.assign({},dZ),{wordWrapWidth:m-5,x:w,y:f,textAlign:b}),u),{text:c})}),E=B.getBBox();return l&&(y=new yw({className:"subTitle",style:Object.assign(Object.assign(Object.assign(Object.assign({},fZ),{wordWrapWidth:m-5,x:w,y:E.height+o+f,textAlign:b}),h),{text:l})})),[B,y]}}class wZ extends tz{constructor(t,e){super(t,Object.assign({},wZ.defaultOptions,e)),this.$element=ez("toolbar",!1),this.onToolbarItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof Element&&t.target.className.includes("g6-toolbar-item")){const n=t.target.getAttribute("value");null==e||e(n,t.target)}};const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),nz("g6-toolbar-css","style",{},"\n .g6-toolbar {\n position: absolute;\n z-index: 100;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);\n opacity: 0.65;\n }\n .g6-toolbar .g6-toolbar-item {\n display: inline-block;\n width: 16px;\n height: 16px;\n padding: 4px;\n cursor: pointer;\n box-sizing: content-box;\n }\n\n .g6-toolbar .g6-toolbar-item:hover {\n background-color: #f0f0f0;\n }\n\n .g6-toolbar .g6-toolbar-item svg {\n display: inline-block;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n",document.head),nz("g6-toolbar-svgicon","div",{display:"none"},'\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t);const{className:n,position:r,style:i}=this.options;this.$element.className=`g6-toolbar ${n||""}`,Object.assign(this.$element.style,i,function(t){const e={top:"unset",right:"unset",bottom:"unset",left:"unset"};return t.split("-").forEach(t=>{e[t]="8px"}),e.flexDirection=t.startsWith("top")||t.startsWith("bottom")?"row":"column",e}(r)),this.$element.innerHTML=yield this.getDOMContent()})}destroy(){this.$element.removeEventListener("click",this.onToolbarItemClick),this.$element.remove(),super.destroy()}getDOMContent(){return De(this,void 0,void 0,function*(){return(yield this.options.getItems()).map(t=>{var e;return`\n
    \n \n
    `}).join("")})}}wZ.defaultOptions={position:"top-left"};class bZ extends tz{constructor(t,e){super(t,Object.assign({},bZ.defaultOptions,e)),this.currentTarget=null,this.tooltipElement=null,this.container=null,this.isEnable=(t,e)=>{const{enable:n}=this.options;return"function"==typeof n?n(t,e):n},this.onClick=t=>{const{target:{id:e}}=t;this.currentTarget===e?this.hide(t):this.show(t)},this.onPointerMove=t=>{const{target:e}=t;this.currentTarget&&e.id!==this.currentTarget&&this.show(t)},this.onPointerLeave=t=>{this.hide(t)},this.onCanvasMove=t=>{this.hide(t)},this.onPointerOver=t=>{this.show(t)},this.showById=t=>De(this,void 0,void 0,function*(){const e={target:{id:t}};yield this.show(e)}),this.getElementData=(t,e)=>{const{model:n}=this.context;switch(e){case"node":return n.getNodeData([t]);case"edge":return n.getEdgeData([t]);case"combo":return n.getComboData([t]);default:return[]}},this.show=t=>De(this,void 0,void 0,function*(){var e,n;const{client:r,target:{id:i}}=t;if(eE(t.target))return;const o=this.context.graph.getElementType(i),{getContent:A,title:s}=this.options,a=this.getElementData(i,o);if(!this.tooltipElement)return;if(!this.isEnable(t,a))return void this.hide(t);let c,l,u={};if(A){if(u.content=yield A(t,a),!u.content)return}else{const t=this.context.graph.getElementRenderStyle(i),e="node"===o?t.fill:t.stroke;u={title:s||o,data:a.map(t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:e}))}}if(this.currentTarget=i,r)c=r.x,l=r.y;else{const t=Ce(a,"0.style",{x:0,y:0});c=t.x,l=t.y}null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!0),this.tooltipElement.update(Object.assign(Object.assign(Object.assign({},this.tooltipStyleProps),{x:c,y:l,style:{".tooltip":{visibility:"visible"}}}),u))}),this.hide=t=>{var e,n,r,i,o;if(!t)return null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!1),null===(r=this.tooltipElement)||void 0===r||r.hide(),void(this.currentTarget=null);if(!this.tooltipElement)return;if(!this.currentTarget)return;const{client:{x:A,y:s}}=t;null===(o=(i=this.options).onOpenChange)||void 0===o||o.call(i,!1),this.tooltipElement.hide(A,s),this.currentTarget=null},this.initTooltip=()=>{var t;const e=new x$({className:"tooltip",style:this.tooltipStyleProps});return null===(t=this.container)||void 0===t||t.appendChild(e.HTMLTooltipElement),e},this.render(),this.bindEvents()}getEvents(){return"click"===this.options.trigger?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerover":this.onPointerOver,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerover":this.onPointerOver,"edge:pointermove":this.onPointerMove,"combo:pointerover":this.onPointerOver,"combo:pointermove":this.onPointerMove,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}update(t){var e;this.unbindEvents(),super.update(t),this.tooltipElement&&(null===(e=this.container)||void 0===e||e.removeChild(this.tooltipElement.HTMLTooltipElement)),this.tooltipElement=this.initTooltip(),this.bindEvents()}render(){const{canvas:t}=this.context,e=t.getContainer();e&&(this.container=e,this.tooltipElement=this.initTooltip())}unbindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach(n=>{t.off(n,e[n])})}bindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach(n=>{t.on(n,e[n])})}get tooltipStyleProps(){const{canvas:t}=this.context,{center:e}=t.getBounds(),n=t.getContainer(),{top:r,left:i}=n.getBoundingClientRect(),{style:o,position:A,enterable:s,container:a={x:-i,y:-r},title:c,offset:l}=this.options,[u,h]=e,[d,f]=t.getSize();return{x:u,y:h,container:a,title:c,bounding:{x:0,y:0,width:d,height:f},position:A,enterable:s,offset:l,style:o}}destroy(){var t;this.unbindEvents(),this.tooltipElement&&(null===(t=this.container)||void 0===t||t.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}let BZ;function EZ(t,e){BZ||(BZ=document.createElement("canvas")),BZ.width=t,BZ.height=e;return BZ.getContext("2d").clearRect(0,0,t,e),BZ}bZ.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};class xZ extends tz{constructor(t,e){super(t,Object.assign({},xZ.defaultOptions,e)),this.$element=ez("watermark");this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t);const n=this.options,{width:r,height:i,text:o,imageURL:A}=n,s=Pe(n,["width","height","text","imageURL"]);Object.keys(s).forEach(e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])});const a=A?yield function(t,e,n,r){return De(this,void 0,void 0,function*(){const i=EZ(t,e),o=i.getContext("2d"),{rotate:A,opacity:s}=r;A&&o.rotate(A),s&&(o.globalAlpha=s);const a=new Image;return a.crossOrigin="anonymous",a.src=n,new Promise(n=>{a.onload=function(){const r=t>a.width?(t-a.width)/2:0,A=e>a.height?(e-a.height)/2:0;o.drawImage(a,0,0,a.width,a.height,r,A,t-2*r,e-2*A),n(i.toDataURL())}})})}(r,i,A,s):yield function(t,e,n,r){return De(this,void 0,void 0,function*(){const i=EZ(t,e),o=i.getContext("2d"),{rotate:A,opacity:s,textFill:a,textFontSize:c,textFontFamily:l,textFontVariant:u,textFontWeight:h,textAlign:d,textBaseline:f}=r;return o.textAlign=d,o.textBaseline=f,o.translate(t/2,e/2),o.font=`${c}px ${l} ${u} ${h}`,A&&o.rotate(A),s&&(o.globalAlpha=s),a&&(o.fillStyle=a,o.fillText(`${n}`,0,0)),i.toDataURL()})}(r,i,o,s);this.$element.style.backgroundImage=`url(${a})`})}destroy(){super.destroy(),this.$element.remove()}}xZ.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const CZ=["#7E92B5","#F4664A","#FFBE3A"],MZ={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},FZ={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function kZ(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeHaloStrokeOpacityActive:A=.15,nodeHaloStrokeOpacitySelected:s=.25,nodeOpacityDisabled:a=.06,nodeIconOpacityInactive:c=.85,nodeOpacityInactive:l=.25,nodeBadgePalette:u=CZ,nodePaletteOptions:h=MZ,edgeColor:d,edgeColorDisabled:f,edgePaletteOptions:g=FZ,comboColor:p,comboColorDisabled:v,comboStroke:m,comboStrokeDisabled:y,edgeColorInactive:w}=t;return{background:e,node:{palette:h,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:u,fill:r,fillOpacity:1,halo:!1,iconFill:"#fff",iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelFill:n,labelFillOpacity:.85,labelLineHeight:16,labelPadding:[0,2],labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelOffsetY:2,lineWidth:0,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65,size:32,stroke:o,strokeOpacity:1,zIndex:2},state:{selected:{halo:!0,haloLineWidth:24,haloStrokeOpacity:s,labelFontSize:12,labelFontWeight:"bold",lineWidth:4,stroke:o},active:{halo:!0,haloLineWidth:12,haloStrokeOpacity:A},highlight:{labelFontWeight:"bold",lineWidth:4,stroke:o,strokeOpacity:.85},inactive:{badgeBackgroundOpacity:l,donutOpacity:l,fillOpacity:l,iconOpacity:c,labelFill:n,labelFillOpacity:l,strokeOpacity:l},disabled:{badgeBackgroundOpacity:.25,donutOpacity:a,fill:i,fillOpacity:a,iconFill:i,iconOpacity:.25,labelFill:n,labelFillOpacity:.25,strokeOpacity:a}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"node-expand",collapse:"node-collapse",update:[{fields:["x","y","fill","stroke"]}],translate:[{fields:["x","y"]}]}},edge:{palette:g,style:{badgeBackgroundFill:d,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,badgeBackgroundOpacity:1,fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:1,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,stroke:d,strokeOpacity:1,zIndex:1},state:{selected:{halo:!0,haloStrokeOpacity:.25,labelFontSize:14,labelFontWeight:"bold",lineWidth:3},active:{halo:!0,haloStrokeOpacity:.15},highlight:{labelFontWeight:"bold",lineWidth:3},inactive:{stroke:w,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:f,fillOpacity:.45,strokeOpacity:.45,labelOpacity:.25,badgeBackgroundOpacity:.45}},animation:{enter:"fade",exit:"fade",expand:"path-in",collapse:"path-out",show:"fade",hide:"fade",update:[{fields:["sourceNode","targetNode"]},{fields:["stroke"],shape:"key"}],translate:[{fields:["sourceNode","targetNode"]}]}},combo:{style:{collapsedMarkerFill:e,collapsedMarkerFontSize:12,collapsedMarkerFillOpacity:1,collapsedSize:32,collapsedFillOpacity:1,fill:p,halo:!1,haloLineWidth:12,haloStroke:m,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,fillOpacity:.04,strokeOpacity:1,padding:10,stroke:m},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{fillOpacity:.65,labelOpacity:.25,strokeOpacity:.65},disabled:{fill:v,fillOpacity:.25,labelOpacity:.25,stroke:y,strokeOpacity:.25}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"combo-expand",collapse:"combo-collapse",update:[{fields:["x","y"]},{fields:["fill","stroke","lineWidth"],shape:"key"}],translate:[{fields:["x","y"]}]}}}}const SZ=kZ({bgColor:"#000000",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696",edgeColor:"#637088",edgeColorDisabled:"#637088",edgeColorInactive:"#D0E4FF",edgePaletteOptions:{type:"group",color:["#637088","#0F55A6","#008383","#9C5D38","#8B53A6","#4E40A6","#8F6608","#3E801D","#A65383","#175E75","#0F8248"]},nodeColor:"#1783ff",nodeColorDisabled:"#D0E4FF",nodeHaloStrokeOpacityActive:.25,nodeHaloStrokeOpacitySelected:.45,nodeIconOpacityInactive:.45,nodeOpacityDisabled:.25,nodeOpacityInactive:.45,nodeStroke:"#d0e4ff",textColor:"#ffffff"}),QZ=kZ({bgColor:"#ffffff",comboColor:"#99ADD1",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",edgeColorInactive:"#1B324F",nodeColor:"#1783ff",nodeColorDisabled:"#1B324F",nodeHaloStrokeOpacityActive:.15,nodeHaloStrokeOpacitySelected:.25,nodeIconOpacityInactive:.85,nodeOpacityDisabled:.06,nodeOpacityInactive:.25,nodeStroke:"#000000",textColor:"#000000"});class UZ extends ry{beforeDraw(t,e){return t}afterLayout(t,e){}}function NZ(t,e,n,r,i){const o=Km(r),A=`${n}s`,s=i?r:t.add[A].get(o)||t.update[A].get(o)||t.remove[A].get(o)||r;Object.entries(t).forEach(([t,n])=>{e===t?n[A].set(o,s):n[A].delete(o)})}function TZ(t,e){return Object.keys(t).every(n=>t[n]===e[n])}const OZ=(t,e,n,r)=>{const i=`${n}s`,o=Km(r);t.add[i].has(o)||t.update[i].has(o)||t[e][i].set(Km(r),r)};const IZ=new WeakMap;const LZ=(t,e,n=2)=>{if("object"!=typeof t||"object"!=typeof e)return t===e;const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r){const r=t[i],o=e[i];if(n>1&&"object"==typeof r&&"object"==typeof o){if(!LZ(r,o,n-1))return!1}else if(r!==o)return!1}return!0};function PZ(t,e,n){Yv[t][e]&&Zv(`The extension ${e} of ${t} has been registered before, and will be overridden.`),Object.assign(Yv[t],{[e]:n})} /*! * @antv/g-plugin-dragndrop * @description A G plugin for Drag n Drop implemented with PointerEvents * @version 2.1.1 * @date 12/24/2025, 11:56:44 AM * @author AntVis * @docs https://g.antv.antgroup.com/ */var DZ=function(){function t(e){A(this,t),this.dragndropPluginOptions=e}return a(t,[{key:"apply",value:function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,A=function(t){var e=t.target,r=e===i,A=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(A){var s=!1,a=t.timeStamp,c=[t.clientX,t.clientY],l=null,u=[t.clientX,t.clientY],h=function(){var t=Ar(ir().mark(function t(o){var h,d,f,g,p,v;return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=2;break}if(h=o.timeStamp-a,d=gn([o.clientX,o.clientY],c),!(h<=n.dragndropPluginOptions.dragstartTimeThreshold||d<=n.dragndropPluginOptions.dragstartDistanceThreshold)){t.next=1;break}return t.abrupt("return");case 1:o.type="dragstart",A.dispatchEvent(o),s=!0;case 2:if(o.type="drag",o.dx=o.clientX-u[0],o.dy=o.clientY-u[1],A.dispatchEvent(o),u=[o.clientX,o.clientY],r){t.next=4;break}return f="pointer"===n.dragndropPluginOptions.overlap?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=3,i.elementsFromPoint(f[0],f[1]);case 3:g=t.sent,p=g[g.indexOf(e)+1],v=(null==p?void 0:p.closest("[droppable=true]"))||(n.dragndropPluginOptions.isDocumentDroppable?i:null),l!==v&&(l&&(o.type="dragleave",o.target=l,l.dispatchEvent(o)),v&&(o.type="dragenter",o.target=v,v.dispatchEvent(o)),(l=v)&&(o.type="dragover",o.target=l,l.dispatchEvent(o)));case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}();o.addEventListener("pointermove",h);var d=function(t){if(s){t.detail={preventClick:!0};var e=t.clone();l&&(e.type="drop",e.target=l,l.dispatchEvent(e)),e.type="dragend",A.dispatchEvent(e),s=!1}o.removeEventListener("pointermove",h)};e.addEventListener("pointerup",d,{once:!0}),e.addEventListener("pointerupoutside",d,{once:!0})}};r.hooks.init.tap(t.tag,function(){o.addEventListener("pointerdown",A)}),r.hooks.destroy.tap(t.tag,function(){o.removeEventListener("pointerdown",A)})}}])}();DZ.tag="Dragndrop";var RZ=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),(t=g(this,e)).name="dragndrop",t.options=n,t}return v(e,t),a(e,[{key:"init",value:function(){this.addRenderingPlugin(new DZ(o({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)}}])}(ur);const HZ=["main"],_Z=["background","main","label","transient"];class GZ{getConfig(){return this.config}getLayer(t="main"){return this.extends.layers[t]||this.getLayers().main}getLayers(){return this.extends.layers}getRenderer(t){return this.extends.renderers[t]}getCamera(t="main"){return this.getLayer(t).getCamera()}getRoot(t="main"){return this.getLayer(t).getRoot()}getContextService(t="main"){return this.getLayer(t).getContextService()}setCursor(t){this.config.cursor=t,this.getLayer().setCursor(t)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(t){this.config={enableMultiLayer:!0},Object.assign(this.config,t);const e=this.config,{renderer:n,background:r,cursor:i,enableMultiLayer:o}=e,A=Pe(e,["renderer","background","cursor","enableMultiLayer"]),s=o?_Z:HZ,a=KZ(n,s),c=Object.fromEntries(s.map(t=>[t,new xc(Object.assign(Object.assign({},A),{supportsMutipleCanvasesInOneContainer:o,renderer:a[t],background:o?"background"===t?r:void 0:r}))]));jZ(c),this.extends={config:this.config,renderer:n,renderers:a,layers:c}}get ready(){return Promise.all(Object.entries(this.getLayers()).map(([,t])=>t.ready))}resize(t,e){Object.assign(this.extends.config,{width:t,height:e}),Object.values(this.getLayers()).forEach(n=>{const r=n.getCamera(),i=r.getPosition(),o=r.getFocalPoint();n.resize(t,e),r.setPosition(i),r.setFocalPoint(o)})}getBounds(t){return xm(Object.values(this.getLayers()).map(e=>t?e.getRoot().childNodes.find(e=>e.classList.includes(t)):e.getRoot()).filter(t=>(null==t?void 0:t.childNodes.length)>0).map(t=>t.getBounds()))}getContainer(){const t=this.extends.config.container;return"string"==typeof t?document.getElementById(t):t}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(t,e){var n;const r=(null===(n=t.style)||void 0===n?void 0:n.$layer)||"main";return this.getLayer(r).appendChild(t,e)}setRenderer(t){if(t===this.extends.renderer)return;const e=KZ(t,this.config.enableMultiLayer?_Z:HZ);this.extends.renderers=e,Object.entries(e).forEach(([t,e])=>this.getLayer(t).setRenderer(e)),jZ(this.getLayers())}getCanvasByViewport(t){return Sy(this.getLayer().viewport2Canvas(Qy(t)))}getViewportByCanvas(t){return Sy(this.getLayer().canvas2Viewport(Qy(t)))}getViewportByClient(t){return Sy(this.getLayer().client2Viewport(Qy(t)))}getClientByViewport(t){return Sy(this.getLayer().viewport2Client(Qy(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),n=e.client2Viewport(Qy(t));return Sy(e.viewport2Canvas(n))}toDataURL(){return De(this,arguments,void 0,function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:n="viewport"}=t,r=Pe(t,["mode"]);let[i,o,A,s]=[0,0,0,0];if("viewport"===n)[A,s]=this.getSize();else if("overall"===n){const t=this.getBounds(),e=wm(t);[i,o]=t.min,[A,s]=e}const a=Sn('
    '),c=new xc({width:A,height:s,renderer:new _b,devicePixelRatio:e,container:a,background:this.extends.config.background});yield c.ready,c.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),c.appendChild(this.getRoot().cloneNode(!0));const l=this.getLayer("label").getRoot().cloneNode(!0),u=c.viewport2Canvas({x:0,y:0}),h=this.getCanvasByViewport([0,0]);l.translate([h[0]-u.x,h[1]-u.y]),l.scale(1/this.getCamera().getZoom()),c.appendChild(l),c.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const d=this.getCamera(),f=c.getCamera();if("viewport"===n)f.setZoom(d.getZoom()),f.setPosition(d.getPosition()),f.setFocalPoint(d.getFocalPoint());else if("overall"===n){const[t,e,n]=f.getPosition(),[r,A,s]=f.getFocalPoint();f.setPosition([t+i,e+o,n]),f.setFocalPoint([r+i,A+o,s])}const g=c.getContextService();return new Promise(t=>{c.addEventListener(mc.RERENDER,()=>De(this,void 0,void 0,function*(){yield new Promise(t=>setTimeout(t,300));const e=yield g.toDataURL(r);t(e)}))})})}destroy(){Object.values(this.getLayers()).forEach(t=>{t.getCamera().cancelLandmarkAnimation(),t.destroy()})}}function KZ(t,e){return Object.fromEntries(e.map(e=>{const n=(null==t?void 0:t(e))||new _b;return n instanceof _b&&n.setConfig({enableDirtyRectangleRendering:!1}),"main"===e?n.registerPlugin(new RZ({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[e,n]}))}function jZ(t){Object.entries(t).forEach(([t,e])=>{const n=e.getContextService().getDomElement();(null==n?void 0:n.style)&&(n.style.gridArea="1 / 1 / 2 / 2",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")),(null==n?void 0:n.parentElement)&&(n.parentElement.style.display="grid",n.parentElement.style.isolation="isolate")})}const zZ=t=>t?parseInt(t):0;function VZ(t){if(!t)return[0,0];let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||zZ(e.width),r=t.clientHeight||zZ(e.height);return[n-(zZ(e.paddingLeft)+zZ(e.paddingRight)),r-(zZ(e.paddingTop)+zZ(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(re(e)?e:1,1),Math.max(re(n)?n:1,1)]}class WZ{constructor(t){this.type=t}}class YZ extends WZ{constructor(t,e){super(t),this.data=e}}class XZ extends WZ{constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class qZ extends WZ{constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class $Z extends WZ{constructor(t,e){super(t),this.data=e}}function ZZ(t,e){t.emit(e.type,e)}function JZ(t){var e;return(null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0}const tJ="cachedStyle",eJ=t=>`__${t}__`;function nJ(t,e){return Ce(t,[tJ,eJ(e)])}class rJ{constructor(t){this.tasks=[],this.animations=new Set,this.context=t}getTasks(){const t=[...this.tasks];return this.tasks=[],t}add(t,e){this.tasks.push([t,e])}animate(t,e,n){var r,i,o;null===(r=null==e?void 0:e.before)||void 0===r||r.call(e);const A=this.getTasks().map(([e,r])=>{var i,o,A;const{element:s,elementType:a,stage:c}=e,l=im(this.context.options,a,c,t);null===(i=null==r?void 0:r.before)||void 0===i||i.call(r);const u=l.length?Am(s,this.inferStyle(e,n),l):null;return u?(null===(o=null==r?void 0:r.beforeAnimate)||void 0===o||o.call(r,u),u.finished.then(()=>{var t,e;null===(t=null==r?void 0:r.afterAnimate)||void 0===t||t.call(r,u),null===(e=null==r?void 0:r.after)||void 0===e||e.call(r),this.animations.delete(u)})):null===(A=null==r?void 0:r.after)||void 0===A||A.call(r),u}).filter(Boolean);A.forEach(t=>this.animations.add(t));const s=tm(A);return s?(null===(i=null==e?void 0:e.beforeAnimate)||void 0===i||i.call(e,s),s.finished.then(()=>{var t,n;null===(t=null==e?void 0:e.afterAnimate)||void 0===t||t.call(e,s),null===(n=null==e?void 0:e.after)||void 0===n||n.call(e),this.release()})):null===(o=null==e?void 0:e.after)||void 0===o||o.call(e),s}inferStyle(t,e){var n,r;const{element:i,elementType:o,stage:A,originalStyle:s,updatedStyle:a={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},s),a));const{modifiedStyle:c}=t,l={},u={};if("enter"===A)Object.assign(l,{opacity:0});else if("exit"===A)Object.assign(u,{opacity:0});else if("show"===A)Object.assign(l,{opacity:0}),Object.assign(u,{opacity:null!==(n=nJ(i,"opacity"))&&void 0!==n?n:nm("opacity")});else if("hide"===A)Object.assign(l,{opacity:null!==(r=nJ(i,"opacity"))&&void 0!==r?r:nm("opacity")}),Object.assign(u,{opacity:0});else if("collapse"===A){const{collapse:t}=e||{},{target:n,descendants:r,position:A}=t;if("node"===o){if(r.includes(i.id)){const[t,e,n]=A;Object.assign(u,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e]=A;Object.assign(u,{x:t,y:e,childrenNode:s.childrenNode})}}else"edge"===o&&Object.assign(u,{sourceNode:c.sourceNode,targetNode:c.targetNode})}else if("expand"===A){const{expand:t}=e||{},{target:n,descendants:r,position:A}=t;if("node"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=A;Object.assign(l,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=A;Object.assign(l,{x:t,y:e,z:n,childrenNode:c.childrenNode})}}else"edge"===o&&Object.assign(l,{sourceNode:c.sourceNode,targetNode:c.targetNode})}return[Object.keys(l).length>0?Object.assign({},s,l):s,Object.keys(u).length>0?Object.assign({},c,u):c]}stop(){this.animations.forEach(t=>t.cancel())}clear(){this.tasks=[]}release(){var t,e;const{canvas:n}=this.context,r=null===(e=null===(t=n.document)||void 0===t?void 0:t.timeline)||void 0===e?void 0:e.animationsWithPromises;r&&(n.document.timeline.animationsWithPromises=r.filter(t=>"finished"!==t.playState))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class iJ{constructor(t){this.batchCount=0,this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(e=!0){this.batchCount++,1===this.batchCount&&this.emit(new YZ(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new YZ(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class oJ extends ny{constructor(e){super(e),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=e=>{const{target:n}=e,r=function(t){if(!t)return null;if(t instanceof hc)return{type:"canvas",element:t};let e=t;for(;e;){if(RB(e))return{type:"node",element:e};if(HB(e))return{type:"edge",element:e};if(_B(e))return{type:"combo",element:e};e=e.parentElement}return null}(n);if(!r)return;const{graph:i,canvas:o}=this.context,{type:A,element:s}=r;if("destroyed"in s&&(eE(s)||s.destroyed))return;const{type:a,detail:c,button:l}=e,u=Object.assign(Object.assign({},e),{target:s,targetType:A,originalTarget:n});a===t.CommonEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${this.currentTargetType}:${t.CommonEvent.POINTER_LEAVE}`,Object.assign(Object.assign({},u),{type:t.CommonEvent.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),s&&(Object.assign(u,{type:t.CommonEvent.POINTER_ENTER}),i.emit(`${A}:${t.CommonEvent.POINTER_ENTER}`,u))),this.currentTarget=s,this.currentTargetType=A),a===t.CommonEvent.CLICK&&2===l||(i.emit(`${A}:${a}`,u),i.emit(a,u)),a===t.CommonEvent.CLICK&&2===c&&(Object.assign(u,{type:t.CommonEvent.DBLCLICK}),i.emit(`${A}:${t.CommonEvent.DBLCLICK}`,u),i.emit(t.CommonEvent.DBLCLICK,u)),a===t.CommonEvent.POINTER_DOWN&&2===l&&(Object.assign(u,{type:t.CommonEvent.CONTEXT_MENU,preventDefault:()=>{var e;null===(e=o.getContainer())||void 0===e||e.addEventListener(t.CommonEvent.CONTEXT_MENU,t=>t.preventDefault(),{once:!0})}}),i.emit(`${A}:${t.CommonEvent.CONTEXT_MENU}`,u),i.emit(t.CommonEvent.CONTEXT_MENU,u))},this.forwardContainerEvents=t=>{this.context.graph.emit(t.type,t)},this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach(t=>{e.addEventListener(t,this.forwardContainerEvents)});const n=this.context.canvas.document;n&&[t.CommonEvent.CLICK,t.CommonEvent.DBLCLICK,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE,t.CommonEvent.POINTER_ENTER,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_OUT,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_UP,t.CommonEvent.CONTEXT_MENU,t.CommonEvent.DRAG_START,t.CommonEvent.DRAG,t.CommonEvent.DRAG_END,t.CommonEvent.DRAG_ENTER,t.CommonEvent.DRAG_OVER,t.CommonEvent.DRAG_LEAVE,t.CommonEvent.DROP,t.CommonEvent.WHEEL].forEach(t=>{n.addEventListener(t,this.forwardCanvasEvents)})}destroy(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach(t=>{e.removeEventListener(t,this.forwardContainerEvents)}),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}function AJ(t){const{id:e=Km(t),style:n,data:r}=t,i=Pe(t,["id","style","data"]),o=Object.assign(Object.assign({},t),{style:Object.assign({},n),data:Object.assign({},r)});return function(t){return"source"in t&&"target"in t}(t)?Object.assign({id:e,data:o},i):{id:e,data:o}}function sJ(t){return t.data}class aJ{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new vE}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===Lv.NodeUpdated||e===Lv.EdgeUpdated||e===Lv.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:iE(n),original:iE(r),type:e})}else this.changes.push({value:iE(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}isBatching(){return this.batchCount>0}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=sJ(n);return this.isCombo(Km(r))||(void 0===t||t.includes(Km(r)))&&e.push(r),e},[])}getEdgeDatum(t){return sJ(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce((e,n)=>{const r=sJ(n);return(void 0===t||t.includes(Km(r)))&&e.push(r),e},[])}getComboData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=sJ(n);return this.isCombo(Km(r))?((void 0===t||t.includes(Km(r)))&&e.push(r),e):e},[])}getRootsData(t=Vv){return this.model.getRoots(t).map(sJ)}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(sJ):[]}getDescendantsData(t){const e=this.getElementDataById(t),n=[];return Zy(e,t=>{t!==e&&n.push(t)},t=>this.getChildrenData(Km(t)),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void Zv("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?sJ(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?Vv:zv,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(sJ):[]}getElementsDataByType(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementDataById(t){return"edge"===this.getElementType(t)?this.getEdgeDatum(t):this.getNodeLikeDatum(t)}getNodeLikeDatum(t){return sJ(this.model.getNode(t))}getNodeLikeData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=sJ(n);return t?t.includes(Km(r))&&e.push(r):e.push(r),e},[])}getElementDataByState(t,e){return this.getElementsDataByType(t).filter(t=>{var n;return null===(n=t.states)||void 0===n?void 0:n.includes(e)})}getElementState(t){var e;return(null===(e=this.getElementDataById(t))||void 0===e?void 0:e.states)||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(sJ)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(sJ)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i,edges:o,combos:A}=this.getData(),s=ty(i,e,t=>Km(t),oE),a=ty(o,n,t=>Km(t),oE),c=ty(A,r,t=>Km(t),oE);this.batch(()=>{const t={nodes:s.enter,edges:a.enter,combos:c.enter};this.addData(t),this.computeZIndex(t,"add",!0);const e={nodes:s.update,edges:a.update,combos:c.update};this.updateData(e),this.computeZIndex(e,"update",!0);const n={nodes:s.exit.map(Km),edges:a.exit.map(Km),combos:c.exit.map(Km)};this.removeData(n)})}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)}),this.computeZIndex(t,"add")}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map(t=>(this.pushChange({value:t,type:Lv.NodeAdded}),AJ(t)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map(t=>(this.pushChange({value:t,type:Lv.EdgeAdded}),AJ(t)))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(zv)||e.attachTreeStructure(zv),e.addNodes(t.map(t=>(this.comboIds.add(Km(t)),this.pushChange({value:t,type:Lv.ComboAdded}),AJ(t)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const n=this.getNodeLikeDatum(t),r=e.map(Km);this.addNodeData(e),this.updateNodeData([{id:t,children:[...n.children||[],...r]}]),this.addEdgeData(r.map(e=>({source:t,target:e})))}computeZIndex(t,e,n=!1){!n&&this.isBatching()||this.batch(()=>{const{nodes:n=[],edges:r=[],combos:i=[]}=t;i.forEach(t=>{var n,r,i;const o=Km(t);if("add"===e&&re(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t))return;const A=this.getParentData(o,zv),s=A?(null!==(i=null===(r=A.style)||void 0===r?void 0:r.zIndex)&&void 0!==i?i:0)+1:0;this.preventUpdateNodeLikeHierarchy(()=>{this.updateComboData([{id:o,style:{zIndex:s}}])})}),n.forEach(t=>{var n,r,i;const o=Km(t);if("add"===e&&re(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t)&&!("children"in t))return;let A=0;const s=this.getParentData(o,zv);if(s)A=((null===(r=s.style)||void 0===r?void 0:r.zIndex)||0)+1;else{const t=this.getParentData(o,Vv);t&&(A=(null===(i=null==t?void 0:t.style)||void 0===i?void 0:i.zIndex)||0)}this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:o,style:{zIndex:A}}])})}),r.forEach(t=>{var e,n,r,i,o;if(re(null===(e=t.style)||void 0===e?void 0:e.zIndex))return;let{id:A,source:s,target:a}=t;if(A){const t=this.getEdgeDatum(A);s=t.source,a=t.target}else A=Km(t);if(!s||!a)return;const c=(null===(r=null===(n=this.getNodeLikeDatum(s))||void 0===n?void 0:n.style)||void 0===r?void 0:r.zIndex)||0,l=(null===(o=null===(i=this.getNodeLikeDatum(a))||void 0===i?void 0:i.style)||void 0===o?void 0:o.zIndex)||0;this.updateEdgeData([{id:Km(t),style:{zIndex:Math.max(c,l)-1}}])})})}getFrontZIndex(t){var e;const n=this.getElementType(t),r=this.getElementDataById(t),i=this.getData();if(Object.assign(i,{[`${n}s`]:i[`${n}s`].filter(e=>Km(e)!==t)}),"combo"===n&&!rw(r)){const e=new Set(this.getAncestorsData(t,zv).map(Km));i.nodes=i.nodes.filter(t=>!e.has(Km(t))),i.combos=i.combos.filter(t=>!e.has(Km(t))),i.edges=i.edges.filter(({source:t,target:n})=>!e.has(t)&&!e.has(n))}return Math.max((null===(e=r.style)||void 0===e?void 0:e.zIndex)||0,0,...Object.values(i).flat().map(t=>{var e;return((null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0)+1}))}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach(t=>{const n=Km(t),r=jm(t);void 0!==r&&(e.hasTreeStructure(zv)||e.attachTreeStructure(zv),null===r&&this.refreshComboData(n),this.setParent(n,jm(t),zv));const i=t.children||[];if(i.length){e.hasTreeStructure(Vv)||e.attachTreeStructure(Vv);const t=i.filter(t=>e.hasNode(t));t.forEach(t=>this.setParent(t,n,Vv)),t.length!==i.length&&this.updateNodeData([{id:n,children:t}])}})}preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.updateNodeData(e),this.updateComboData(r),this.updateEdgeData(n)}),this.computeZIndex(t,"update")}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{const n=[];t.forEach(t=>{const r=Km(t),i=sJ(e.getNode(r));if(oE(i,t))return;const o=rE(i,t);this.pushChange({value:o,original:i,type:Lv.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({nodes:t},"update")}refreshData(){const{nodes:t,edges:e,combos:n}=this.getData();t.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.NodeUpdated})}),e.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.EdgeUpdated})}),n.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.ComboUpdated})})}syncNodeLikeDatum(t){const{model:e}=this,n=Km(t);if(!e.hasNode(n))return;const r=rE(sJ(e.getNode(n)),t);e.mergeNodeData(n,r)}syncEdgeDatum(t){const{model:e}=this,n=Km(t);if(!e.hasEdge(n))return;const r=rE(sJ(e.getEdge(n)),t);e.mergeEdgeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{t.forEach(t=>{const n=Km(t),r=sJ(e.getEdge(n));if(oE(r,t))return;t.source&&r.source!==t.source&&e.updateEdgeSource(n,t.source),t.target&&r.target!==t.target&&e.updateEdgeTarget(n,t.target);const i=rE(r,t);this.pushChange({value:i,original:r,type:Lv.EdgeUpdated}),e.mergeEdgeData(n,i)})}),this.computeZIndex({edges:t},"update")}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch(()=>{const n=[];t.forEach(t=>{const r=Km(t),i=sJ(e.getNode(r));if(oE(i,t))return;const o=rE(i,t);this.pushChange({value:o,original:i,type:Lv.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({combos:t},"update")}setParent(t,e,n,r=!0){if(t===e)return;const i=jm(this.getNodeLikeDatum(t));if(i!==e&&n===zv){const n={id:t,combo:e};this.isCombo(t),this.syncNodeLikeDatum(n)}this.model.setParent(t,e,n),r&&n===zv&&function(t,e){void 0===e&&(e=new Map);var n=[];if(Array.isArray(t))for(var r=0,i=t.length;r{void 0!==t&&this.refreshComboData(t)})}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,zv);e&&this.pushChange({value:e,original:e,type:Lv.ComboUpdated}),n.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.ComboUpdated})})}getElementPosition(t){return My(this.getElementDataById(t))}translateNodeLikeBy(t,e){this.isCombo(t)?this.translateComboBy(t,e):this.translateNodeBy(t,e)}translateNodeLikeTo(t,e){this.isCombo(t)?this.translateComboTo(t,e):this.translateNodeTo(t,e)}translateNodeBy(t,e){const n=ay(this.getElementPosition(t),[...e,0].slice(0,3));this.translateNodeTo(t,n)}translateNodeTo(t,e){const[n=0,r=0,i=0]=e;this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:t,style:{x:n,y:r,z:i}}])})}translateComboBy(t,e){const[n=0,r=0,i=0]=e;if([n,r,i].some(isNaN)||[n,r,i].every(t=>0===t))return;const o=this.getComboData([t])[0];if(!o)return;const A=new Set;Zy(o,t=>{const e=Km(t);if(A.has(e))return;A.add(e);const[o,s,a]=My(t),c=rE(t,{style:{x:o+n,y:s+r,z:a+i}});this.pushChange({value:c,original:t,type:this.isCombo(e)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(e,c)},t=>this.getChildrenData(Km(t)),"BT")}translateComboTo(t,e){var n;if(e.some(isNaN))return;const[r=0,i=0,o=0]=e,A=null===(n=this.getComboData([t]))||void 0===n?void 0:n[0];if(!A)return;const[s,a,c]=My(A),l=r-s,u=i-a,h=o-c;Zy(A,t=>{const e=Km(t),[n,r,i]=My(t),o=rE(t,{style:{x:n+l,y:r+u,z:i+h}});this.pushChange({value:o,original:t,type:this.isCombo(e)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(e,o)},t=>this.getChildrenData(Km(t)),"BT")}removeData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.removeEdgeData(n),this.removeNodeData(e),this.removeComboData(r),this.latestRemovedComboIds=new Set(r)})}removeNodeData(t=[]){t.length&&this.batch(()=>{t.forEach(t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Km)),this.pushChange({value:this.getNodeData([t])[0],type:Lv.NodeRemoved}),this.removeNodeLikeHierarchy(t)}),this.model.removeNodes(t)})}removeEdgeData(t=[]){t.length&&(t.forEach(t=>this.pushChange({value:this.getEdgeData([t])[0],type:Lv.EdgeRemoved})),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch(()=>{t.forEach(t=>{this.pushChange({value:this.getComboData([t])[0],type:Lv.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)}),this.model.removeNodes(t)})}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(zv)){const e=jm(this.getNodeLikeDatum(t));this.setParent(t,void 0,zv,!1),this.model.getChildren(t,zv).forEach(t=>{const n=sJ(t),r=Km(n);this.setParent(Km(n),e,zv,!1);const i=rE(n,{id:Km(n),combo:e});this.pushChange({value:i,original:n,type:this.isCombo(r)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(Km(n),i)}),Kt(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error($v(`Unknown element type of id: ${t}`))}destroy(){const{model:t}=this,e=t.getAllNodes(),n=t.getAllEdges();t.removeEdges(n.map(t=>t.id)),t.removeNodes(e.map(t=>t.id)),this.context={}}}class cJ{constructor(t){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=t}init(){this.initContainer()}initContainer(){if(!this.container||this.container.destroyed){const{canvas:t}=this.context;this.container=t.appendChild(new Xa({className:"elements"}))}}emit(t,e){e.silence||ZZ(this.context.graph,t)}forEachElementData(t){$y.forEach(e=>{const n=this.context.model.getElementsDataByType(e);t(e,n)})}getElementType(t,e){var n;const{options:r,graph:i}=this.context,o=sE(e)&&(null===(n=r[t])||void 0===n?void 0:n.type)||e.type;return o?"string"==typeof o?o:o.call(i,e):"edge"===t?"line":"circle"}getTheme(t){return Jv(this.context.options)[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:n={}}=this.getTheme(t);return Object.assign({},...e.map(t=>n[t]||{}))}computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData((e,n)=>{var r,i;const o=Object.assign({},hw(null===(r=this.getTheme(e))||void 0===r?void 0:r.palette),hw(null===(i=t[e])||void 0===i?void 0:i.palette));(null==o?void 0:o.field)&&Object.assign(this.paletteStyle,function(t,e){if(!e)return{};const{type:n,color:r,field:i,invert:o}=e,A=t=>{const e="string"==typeof r?Xv("palette",r):r;if("function"==typeof e){const n={};return t.forEach(([t,r])=>{n[t]=e(o?1-r:r)}),n}if(Array.isArray(e)){const n=o?[...e].reverse():e,r={};return t.forEach(([t,i])=>{r[t]=n[i%e.length]}),r}return{}},s=(t,e)=>{var n;return"string"==typeof t?null===(n=e.data)||void 0===n?void 0:n[t]:null==t?void 0:t(e)};if("group"===n){const e=ee(t,t=>{if(!i)return"default";const e=s(i,t);return e?String(e):"default"}),n=A(Object.keys(e).map((t,e)=>[t,e])),r={};return Object.entries(e).forEach(([t,e])=>{e.forEach(e=>{r[Km(e)]=n[t]})}),r}if("value"===n){const[e,n]=t.reduce(([t,e],n)=>{const r=s(i,n);if("number"!=typeof r)throw new Error($v(`Palette field ${i} is not a number`));return[Math.min(t,r),Math.max(e,r)]},[1/0,-1/0]),r=n-e;return A(t.map(t=>[t.id,(s(i,t)-e)/r]))}}(n,o))})}getPaletteStyle(t,e){const n=this.paletteStyle[e];return n?"edge"===t?{stroke:n}:{fill:n}:{}}computeElementDefaultStyle(t,e){var n;const{options:r}=this.context,i=(null===(n=r[t])||void 0===n?void 0:n.style)||{};"transform"in i&&Array.isArray(i.transform)&&(i.transform=[...i.transform]),this.defaultStyle[Km(e.datum)]=lw(i,e)}computeElementsDefaultStyle(t){const{graph:e}=this.context;this.forEachElementData((n,r)=>{const i=r.length;for(let o=0;othis.getElementStateStyle(t,e,n)))}computeElementsStatesStyle(t){const{graph:e}=this.context;this.forEachElementData((n,r)=>{const i=r.length;for(let o=0;othis.elementMap[t])}getEdges(){return this.context.model.getEdgeData().map(t=>this.elementMap[Km(t)])}getCombos(){return this.context.model.getComboData().map(({id:t})=>this.elementMap[t])}getElementComputedStyle(t,e){const n=Km(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(t,n),o=e.style||{},A=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),a=this.getStateStyle(n),c=sE(e)?Object.assign({},r,i,o,A,s,a):Object.assign({},o);if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!c.collapsed?[]:t.map(Km).filter(t=>this.getElement(t));Object.assign(c,{childrenNode:e,childrenData:t})}return c}getDrawData(t){this.init();const e=this.computeChangesAndDrawData(t);if(!e)return null;const{type:n="draw",stage:r=n}=t;return this.markDestroyElement(e.drawData),this.computeStyle(r),{type:n,stage:r,data:e}}draw(t={animation:!0}){const e=this.getDrawData(t);if(!e)return;const{data:{drawData:{add:n,update:r,remove:i}}}=e;return this.destroyElements(i,t),this.createElements(n,t),this.updateElements(r,t),this.setAnimationTask(t,e)}preLayoutDraw(){return De(this,arguments,void 0,function*(t={animation:!0}){var e,n;const r=this.getDrawData(t);if(!r)return;const{data:{drawData:i}}=r;yield null===(n=null===(e=this.context.layout)||void 0===e?void 0:e.preLayout)||void 0===n?void 0:n.call(e,i);const{add:o,update:A,remove:s}=i;return this.destroyElements(s,t),this.createElements(o,t),this.updateElements(A,t),this.setAnimationTask(t,r)})}setAnimationTask(e,n){const{animation:r,silence:i}=e,{data:{dataChanges:o,drawData:A},stage:s,type:a}=n;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new YZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===a}),e),beforeAnimate:n=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.DRAW,n,A),e),afterAnimate:n=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.DRAW,n,A),e),after:()=>this.emit(new YZ(t.GraphEvent.AFTER_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===a,firstRender:!1===this.context.graph.rendered}),e)})}computeChangesAndDrawData(t){const{model:e}=this.context,n=e.getChanges(),r=iV(n);if(0===r.length)return null;const{NodeAdded:i=[],NodeUpdated:o=[],NodeRemoved:A=[],EdgeAdded:s=[],EdgeUpdated:a=[],EdgeRemoved:c=[],ComboAdded:l=[],ComboUpdated:u=[],ComboRemoved:h=[]}=ee(r,t=>t.type),d=(t,e)=>{const n=[];return t.forEach(t=>{const r=Km(t.value);this.getElement(r)?n.push(t):e.push(t)}),n},f=d(o,i),g=d(a,s),p=d(u,l),v=t=>new Map(t.map(t=>{const e=t.value;return[Km(e),e]})),m={add:{nodes:v(i),edges:v(s),combos:v(l)},update:{nodes:v(f),edges:v(g),combos:v(p)},remove:{nodes:v(A),edges:v(c),combos:v(h)}},y=this.transformData(m,t);return e.clearChanges(),{dataChanges:n,drawData:y}}transformData(t,e){const n=this.context.transform.getTransformInstance();return Object.values(n).reduce((t,n)=>n.beforeDraw(t,e),t)}createElement(e,n,r){var i;const o=Km(n);if(this.getElement(o))return;const A=this.getElementType(e,n),s=this.getElementComputedStyle(e,n),a=Xv(e,A);if(!a)return Zv(`The element ${A} of ${e} is not registered.`);this.emit(new qZ(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const c=this.container.appendChild(new a({id:o,context:this.context,style:s}));this.shapeTypeMap[o]=A,this.elementMap[o]=c;const{stage:l="enter"}=r;null===(i=this.context.animation)||void 0===i||i.add({element:c,elementType:e,stage:l,originalStyle:Object.assign({},c.attributes),updatedStyle:s},{after:()=>{var i;this.emit(new qZ(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),null===(i=c.onCreate)||void 0===i||i.call(c)}})}createElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach(([t,n])=>{n.forEach(n=>this.createElement(t,n,e))})}getUpdateStageStyle(t,e,n){const{stage:r="update"}=n;if("translate"===r){if("node"===t||"combo"===t){const{style:{x:t=0,y:n=0,z:r=0}={}}=e;return{x:t,y:n,z:r}}return{}}return this.getElementComputedStyle(t,e)}updateElement(e,n,r){var i;const o=Km(n),{stage:A="update"}=r,s=this.getElement(o);if(!s)return()=>null;this.emit(new qZ(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const a=this.getElementType(e,n),c=this.getUpdateStageStyle(e,n,r);this.shapeTypeMap[o]!==a&&(s.destroy(),delete this.shapeTypeMap[o],delete this.elementMap[o],this.createElement(e,n,{animation:!1,silence:!0}));const l="visibility"!==A?A:"hidden"===c.visibility?"hide":"show";"hide"===l&&delete c.visibility,null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:l,originalStyle:Object.assign({},s.attributes),updatedStyle:c},{before:()=>{const t=this.elementMap[o];"collapse"!==A&&tE(t,c),"visibility"===A&&(function(t,e){return eJ(e)in(Ce(t,tJ)||{})}(t,"opacity")||function(t,e){const n=Array.isArray(e)?e:[e];Ce(t,tJ)||Me(t,tJ,{}),n.forEach(e=>{Me(Ce(t,tJ),eJ(e),t.attributes[e])})}(t,"opacity"),this.visibilityCache.set(t,"show"===l?"visible":"hidden"),"show"===l&&ey(t,"visible"))},after:()=>{var i;const s=this.elementMap[o];"collapse"===A&&tE(s,c),"hide"===l&&ey(s,this.visibilityCache.get(s)),this.emit(new qZ(t.GraphEvent.AFTER_ELEMENT_UPDATE,e,n),r),null===(i=s.onUpdate)||void 0===i||i.call(s)}})}updateElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach(([t,n])=>{n.forEach(n=>this.updateElement(t,n,e))})}markDestroyElement(t){Object.values(t.remove).forEach(t=>{t.forEach(t=>{const e=Km(t),n=this.getElement(e);n&&function(t){Me(t,"__to_be_destroyed__",!0)}(n)})})}destroyElement(e,n,r){var i;const{stage:o="exit"}=r,A=Km(n),s=this.elementMap[A];if(!s)return()=>null;this.emit(new qZ(t.GraphEvent.BEFORE_ELEMENT_DESTROY,e,n),r),null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:o,originalStyle:Object.assign({},s.attributes),updatedStyle:{}},{after:()=>{var i;this.clearElement(A),s.destroy(),null===(i=s.onDestroy)||void 0===i||i.call(s),this.emit(new qZ(t.GraphEvent.AFTER_ELEMENT_DESTROY,e,n),r)}})}destroyElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["combo",i],["edge",r],["node",n]].forEach(([t,n])=>{n.forEach(n=>this.destroyElement(t,n,e))})}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}alignLayoutResultToElement(t,e){var n,r;const i=null===(n=t.nodes)||void 0===n?void 0:n.find(t=>Km(t)===e);if(i){const n=cy(My(this.context.model.getNodeLikeDatum(e)),My(i));null===(r=t.nodes)||void 0===r||r.forEach(t=>{var e,r,i;(null===(e=t.style)||void 0===e?void 0:e.x)&&(t.style.x+=n[0]),(null===(r=t.style)||void 0===r?void 0:r.y)&&(t.style.y+=n[1]),(null===(i=t.style)||void 0===i?void 0:i.z)&&(t.style.z+=n[2]||0)})}}syncLayoutResult(t,e){return De(this,void 0,void 0,function*(){const{layout:n,model:r}=this.context;if(!n)return;const i=this.context.options.layout,o=yield n.simulate(i?(A=i,Array.isArray(A)?A.map(t=>Object.assign(Object.assign({},t),{preLayout:!0})):Object.assign(Object.assign({},A),{preLayout:!0})):void 0);var A;e&&this.alignLayoutResultToElement(o,t),r.updateData(o)})}collapseNode(e,n){return De(this,void 0,void 0,function*(){var r;const{animation:i,align:o}=n;yield this.syncLayoutResult(e,o);const A=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(this.context.animation.clear(),this.computeStyle("collapse"),!A)return;const{drawData:s}=A,{add:a,remove:c,update:l}=s;this.markDestroyElement(s);const u={animation:i,stage:"collapse",data:s};this.destroyElements(c,u),this.createElements(a,u),this.updateElements(l,u),yield null===(r=this.context.animation.animate(i,{beforeAnimate:e=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.COLLAPSE,e,s),u),afterAnimate:e=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.COLLAPSE,e,s),u)},{collapse:{target:e,descendants:Array.from(c.nodes).map(([,t])=>Km(t)),position:My(l.nodes.get(e))}}))||void 0===r?void 0:r.finished})}expandNode(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i}=this.context,{animation:o,align:A}=n,s=My(i.getNodeData([e])[0]);yield this.syncLayoutResult(e,A);const a=this.computeChangesAndDrawData({stage:"expand",animation:o});if(this.createElements(a.drawData.add,{animation:!1,stage:"expand",target:e}),this.context.animation.clear(),this.computeStyle("expand"),!a)return;const{drawData:c}=a,{update:l,add:u}=c,h={animation:o,stage:"expand",data:c};u.edges.forEach(t=>l.edges.set(Km(t),t)),u.nodes.forEach(t=>l.nodes.set(Km(t),t)),this.updateElements(l,h),yield null===(r=this.context.animation.animate(o,{beforeAnimate:e=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.EXPAND,e,c),h),afterAnimate:e=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.EXPAND,e,c),h)},{expand:{target:e,descendants:Array.from(u.nodes).map(([,t])=>Km(t)),position:s}}))||void 0===r?void 0:r.finished})}collapseCombo(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i,element:o}=this.context;if(i.getAncestorsData(e,zv).some(t=>rw(t)))return;const A=o.getElement(e),s=A.getComboPosition(Object.assign(Object.assign({},A.attributes),{collapsed:!0})),a=this.computeChangesAndDrawData({stage:"collapse",animation:n});if(!a)return;const{dataChanges:c,drawData:l}=a;this.markDestroyElement(l);const{update:u,remove:h}=l,d={animation:n,stage:"collapse",data:l};this.destroyElements(h,d),this.updateElements(u,d);const f=t=>Array.from(t).map(([,t])=>Km(t));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new YZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:c,animation:n}),d),beforeAnimate:e=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.COLLAPSE,e,l),d),afterAnimate:e=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.COLLAPSE,e,l),d),after:()=>this.emit(new YZ(t.GraphEvent.AFTER_DRAW,{dataChanges:c,animation:n}),d)},{collapse:{target:e,descendants:[...f(h.nodes),...f(h.combos)],position:s}}))||void 0===r?void 0:r.finished})}expandCombo(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i}=this.context,o=My(i.getComboData([e])[0]);this.computeStyle("expand");const A=this.computeChangesAndDrawData({stage:"expand",animation:n});if(!A)return;const{dataChanges:s,drawData:a}=A,{add:c,update:l}=a,u={animation:n,stage:"expand",data:a,target:e};this.createElements(c,u),this.updateElements(l,u);const h=t=>Array.from(t).map(([,t])=>Km(t));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new YZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:s,animation:n}),u),beforeAnimate:e=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.EXPAND,e,a),u),afterAnimate:e=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.EXPAND,e,a),u),after:()=>this.emit(new YZ(t.GraphEvent.AFTER_DRAW,{dataChanges:s,animation:n}),u)},{expand:{target:e,descendants:[...h(c.nodes),...h(c.combos)],position:o}}))||void 0===r?void 0:r.finished})}clear(){this.container.destroy(),this.initContainer(),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={}}destroy(){this.clear(),this.container.destroy(),this.context={}}}class lJ{get presetOptions(){return{animation:!!rm(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.instances=[],this.context=t}getLayoutInstance(){return this.instances}preLayout(e){return De(this,void 0,void 0,function*(){var n,r,i,o;const{graph:A,model:s}=this.context,{add:a}=e;ZZ(A,new YZ(t.GraphEvent.BEFORE_LAYOUT,{type:"pre"}));const c=yield null===(n=this.context.layout)||void 0===n?void 0:n.simulate();null===(r=null==c?void 0:c.nodes)||void 0===r||r.forEach(t=>{const e=Km(t),n=a.nodes.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)}),null===(i=null==c?void 0:c.edges)||void 0===i||i.forEach(t=>{const e=Km(t),n=a.edges.get(e);s.syncEdgeDatum(t),n&&Object.assign(n.style,t.style)}),null===(o=null==c?void 0:c.combos)||void 0===o||o.forEach(t=>{const e=Km(t),n=a.combos.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)}),ZZ(A,new YZ(t.GraphEvent.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)})}postLayout(){return De(this,arguments,void 0,function*(e=this.options){if(!e)return;const n=Array.isArray(e)?e:[e],{graph:r}=this.context;ZZ(r,new YZ(t.GraphEvent.BEFORE_LAYOUT,{type:"post"}));for(let e=0;en.afterLayout(t,e))}simulate(){return De(this,arguments,void 0,function*(t=this.options){if(!t)return{};const e=Array.isArray(t)?t:[t];let n={};for(let t=0;tthis.updateElementPosition(t,!1)}):(o.execute(t),o.stop(),o.tick(i));const A=yield o.execute(t);if(r){const t=this.updateElementPosition(A,r);yield null==t?void 0:t.finished}return A})}treeLayout(t,e,n){return De(this,void 0,void 0,function*(){const{type:n,animation:r}=e,i=Xv("layout",n);if(!i)return{};const{nodes:o=[],edges:A=[]}=t,s=new vE({nodes:o.map(t=>({id:Km(t),data:t.data||{}})),edges:A.map(t=>({id:Km(t),source:t.source,target:t.target,data:t.data||{}}))});!function(t){if(t.hasTreeStructure(Vv))return;t.attachTreeStructure(Vv);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,Vv)}}(s);const a={nodes:[],edges:[]},c={nodes:[],edges:[]};s.getRoots(Vv).forEach(t=>{Zy(t,t=>{t.children=s.getSuccessors(t.id)},t=>s.getSuccessors(t.id),"TB");const n=i(t,e),{x:r,y:o,z:A=0}=n;Zy(n,t=>{const{id:e,x:n,y:i,z:s=0}=t;a.nodes.push({id:e,style:{x:r,y:o,z:A}}),c.nodes.push({id:e,style:{x:n,y:i,z:s}})},t=>t.children,"TB")});const l=this.inferTreeLayoutOffset(c);if(uJ(c,l),r){uJ(a,l),this.updateElementPosition(a,!1);const t=this.updateElementPosition(c,r);yield null==t?void 0:t.finished}return c})}inferTreeLayoutOffset(t){var e;let[n,r]=[1/0,-1/0],[i,o]=[1/0,-1/0];null===(e=t.nodes)||void 0===e||e.forEach(t=>{const{x:e=0,y:A=0}=t.style||{};n=Math.min(n,e),r=Math.max(r,e),i=Math.min(i,A),o=Math.max(o,A)});const{canvas:A}=this.context,s=A.getSize(),[a,c]=A.getCanvasByViewport([0,0]),[l,u]=A.getCanvasByViewport(s);if(n>=a&&r<=l&&i>=c&&o<=u)return[0,0];return[(a+l)/2-(n+r)/2,(c+u)/2-(i+o)/2]}stopLayout(){this.instance&&CC(this.instance)&&(this.instance.stop(),this.instance=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutData(t){const{nodeFilter:e=()=>!0,comboFilter:n=()=>!0,preLayout:r=!1,isLayoutInvisibleNodes:i=!1}=t,{nodes:o,edges:A,combos:s}=this.context.model.getData(),{element:a,model:c}=this.context,l=t=>a.getElement(t),u=r?t=>{var n;if(!i){if("hidden"===(null===(n=t.style)||void 0===n?void 0:n.visibility))return!1;if(c.getAncestorsData(t.id,Vv).some(rw))return!1;if(c.getAncestorsData(t.id,zv).some(rw))return!1}return e(t)}:t=>{const n=Km(t),r=l(n);return!!r&&(!eE(r)&&e(t))},h=o.filter(u),d=s.filter(n),f=new Map(h.map(t=>[Km(t),t]));d.forEach(t=>f.set(Km(t),t));return{nodes:h,edges:A.filter(({source:t,target:e})=>f.has(t)&&f.has(e)),combos:d}}initGraphLayout(t){var e;const{element:n,viewport:r}=this.context,{type:i,animation:o,iterations:A}=t,s=Pe(t,["type","animation","iterations"]),[a,c]=r.getCanvasSize(),l=[a/2,c/2],u=null!==(e=null==t?void 0:t.nodeSize)&&void 0!==e?e:t=>{const e=null==n?void 0:n.getElement(t.id);return e?e.attributes.size:null==n?void 0:n.getElementComputedStyle("node",t).size},h=Xv("layout",i);if(!h)return Zv(`The layout of ${i} is not registered.`);const d=Object.getPrototypeOf(h.prototype)===mE.prototype?h:function(t){return!("forEachNode"in t.prototype)&&!("forEachEdge"in t.prototype)}(h)?function(t,e){return class extends mE{constructor(e,n){if(super(e,n),this.instance=new t({}),this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>{var n;return wE(null===(n=t.tick)||void 0===n?void 0:n.call(t,e))}}}execute(t,e){return De(this,void 0,void 0,function*(){return wE(yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(be({},this.options,e))))})}transformOptions(t){if(!("onTick"in t))return t;const e=t.onTick;return t.onTick=t=>e(wE(t)),t}graphData2LayoutModel(t){const{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.map(t=>{const e=Km(t),{data:n,style:r,combo:i}=t,o=Pe(t,["data","style","combo"]),A={id:e,data:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n),{data:n}),i?{parentId:i}:{}),{style:r}),o)};return(null==r?void 0:r.x)&&Object.assign(A.data,{x:r.x}),(null==r?void 0:r.y)&&Object.assign(A.data,{y:r.y}),(null==r?void 0:r.z)&&Object.assign(A.data,{z:r.z}),A}),A=new Map(o.map(t=>[t.id,t])),s=r.filter(t=>{const{source:e,target:n}=t;return A.has(e)&&A.has(n)}).map(t=>{const{source:e,target:n,data:r,style:i}=t;return{id:Km(t),source:e,target:n,data:Object.assign({},r),style:Object.assign({},i)}}),a=i.map(t=>({id:Km(t),data:Object.assign({_isCombo:!0},t.data),style:Object.assign({},t.style)})),c=new vE({nodes:[...o,...a],edges:s});return e.model.model.hasTreeStructure(zv)&&(c.attachTreeStructure(zv),o.forEach(t=>{const n=e.model.model.getParent(t.id,zv);n&&c.hasNode(n.id)&&c.setParent(t.id,n.id,zv)})),c}}}(h,this.context):yE(h,this.context),f=new d(this.context),g={nodeSize:u,width:a,height:c,center:l};switch(f.id){case"d3-force":case"d3-force-3d":Object.assign(g,{center:{x:a/2,y:c/2,z:0}})}return be(f.options,g,s),f}updateElementPosition(t,e){const{model:n,element:r}=this.context;return r?(n.updateData(t),r.draw({animation:e,silence:!0})):null}destroy(){this.stopLayout(),this.context={},this.instance=void 0,this.instances=[],this.animationResult=void 0}}const uJ=(t,e)=>{var n;const[r,i]=e;null===(n=t.nodes)||void 0===n||n.forEach(t=>{if(t.style){const{x:e=0,y:n=0}=t.style;t.style.x=e+r,t.style.y=n+i}else t.style={x:r,y:i}})};function hJ(t){return t.layout?(Array.isArray(t.layout)||"preLayout"in t.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(t.layout.type)&&(t.layout.preLayout=!0),t):t}class dJ extends ny{constructor(t){super(t),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){const e=this.extensionMap[t];if(e)return e;Zv(`Cannot find the plugin ${t}, will try to find it by type.`);const n=this.extensions.find(e=>e.type===t);return n?this.extensionMap[n.key]:void 0}}const fJ=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class gJ extends ny{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...fJ.slice(0,fJ.length-1),...t,fJ[fJ.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class pJ{get padding(){return pm(this.context.options.padding)}get paddingOffset(){const[t,e,n,r]=this.padding,[i,o,A]=[(r-e)/2,(t-n)/2,0];return[i,o,A]}constructor(t){this.landmarkCounter=0,this.context=t;const[e,n]=this.paddingOffset,{zoom:r,rotation:i,x:o=e,y:A=n}=t.options;this.transform({mode:"absolute",scale:r,translate:[o,A],rotate:i},!1)}get camera(){const{canvas:t}=this.context;return new Proxy(t.getCamera(),{get:(e,n)=>{const r=Object.entries(t.getLayers()).filter(([t])=>!["main"].includes(t)),i=r.map(([,t])=>t.getCamera()),o=e[n];if("function"==typeof o)return(...t)=>{const r=o.apply(e,t);return i.forEach(e=>{e[n].apply(e,t)}),r}}})}createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=rm(this.context.options,t);return!!e&&ke(Object.assign({},e),["easing","duration"])}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e,n]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e/2,n/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateOptions(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),A=e.getFocalPoint(),[s,a]=this.getCanvasCenter(),[c=0,l=0,u=0]=r,h=uy([-c,-l,-u],i);return"relative"===n?{position:ay(o,h),focalPoint:ay(A,h)}:{position:ay([s,a,o[2]],h),focalPoint:ay([s,a,A[2]],h)}}getRotateOptions(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomOptions(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return ne("relative"===r?n*i:i,...e)}transform(e,n){return De(this,void 0,void 0,function*(){const{graph:r}=this.context,{translate:i,rotate:o,scale:A,origin:s}=e;this.cancelAnimation();const a=this.getAnimation(n);if(ZZ(r,new $Z(t.GraphEvent.BEFORE_TRANSFORM,e)),!o&&A&&!i&&s&&!a)return this.camera.setZoomByViewportPoint(this.getZoomOptions(e),s),void ZZ(r,new $Z(t.GraphEvent.AFTER_TRANSFORM,e));const c={};if(i&&Object.assign(c,this.getTranslateOptions(e)),re(o)&&Object.assign(c,this.getRotateOptions(e)),re(A)&&Object.assign(c,{zoom:this.getZoomOptions(e)}),a)return ZZ(r,new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.TRANSFORM,null,e)),new Promise(n=>{this.transformResolver=n,this.camera.gotoLandmark(this.createLandmark(c),Object.assign(Object.assign({},a),{onfinish:()=>{ZZ(r,new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.TRANSFORM,null,e)),ZZ(r,new $Z(t.GraphEvent.AFTER_TRANSFORM,e)),this.transformResolver=void 0,n()}}))});this.camera.gotoLandmark(this.createLandmark(c),{duration:0}),ZZ(r,new $Z(t.GraphEvent.AFTER_TRANSFORM,e))})}fitView(t,e){return De(this,void 0,void 0,function*(){const[n,r,i,o]=this.padding,{when:A="always",direction:s="both"}=t||{},[a,c]=this.context.canvas.getSize(),l=a-o-r,u=c-n-i,h=this.context.canvas.getBounds(),d=this.getBBoxInViewport(h),[f,g]=wm(d);if("overflow"===A&&!("x"===s&&f>=l||"y"===s&&g>=u||"both"===s&&f>=l&&g>=u))return yield this.fitCenter({animation:e});const p=l/f,v=u/g,m="x"===s?p:"y"===s?v:Math.min(p,v),y=this.getAnimation(e);Number.isFinite(m)&&(yield this.transform({mode:"relative",scale:m,translate:ay(cy(this.getCanvasCenter(),this.getBBoxInViewport(h).center),uy(this.paddingOffset,m))},y))})}fitCenter(t){return De(this,void 0,void 0,function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)})}focusElements(t){return De(this,arguments,void 0,function*(t,e={}){const{element:n}=this.context;if(!n)return;const r=xm(t.map(t=>{return r=n.getElement(t),e.shapes?r.getShape(e.shapes).getRenderBounds():r.getRenderBounds();var r}));yield this.focus(r,e)})}focus(t,e){return De(this,void 0,void 0,function*(){const n=this.context.graph.getViewportByCanvas(t.center),r=cy(e.position||this.getCanvasCenter(),n);yield this.transform({mode:"relative",translate:ay(r,this.paddingOffset)},e.animation)})}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[A,s]=r.getViewportByCanvas(n),a=new yr;return a.setMinMax([i,o,0],[A,s,0]),a}isInViewport(t,e=!1,n=0){const{graph:r}=this.context,i=this.getCanvasSize(),[o,A]=r.getCanvasByViewport([0,0]),[s,a]=r.getCanvasByViewport(i);let c=new yr;return c.setMinMax([o,A,0],[s,a,0]),n&&(c=Em(c,n)),fm(t)?Cm(t,c):e?function(t,e){const[n,r]=t.min,[i,o]=t.max,[A,s]=e.min,[a,c]=e.max;return n>=A&&i<=a&&r>=s&&o<=c}(t,c):c.intersects(t)}cancelAnimation(){var t,e;(null===(t=this.camera.landmarks)||void 0===t?void 0:t.length)&&this.camera.cancelLandmarkAnimation(),null===(e=this.transformResolver)||void 0===e||e.call(this)}}class vJ extends hE{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new aJ},this.isCollapsingExpanding=!1,this.onResize=pe(()=>{this.resize()},300),this._setOptions(Object.assign({},vJ.defaultOptions,t),!0),this.context.graph=this,this.options.autoResize&&(null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(t){this._setOptions(t,!1)}_setOptions(t,e){if(this.updateCanvas(t),Object.assign(this.options,function(t){return[hJ].reduce((t,e)=>e(t),t)}(t)),e){const{data:e}=t;return void(e&&this.addData(e))}const{behaviors:n,combo:r,data:i,edge:o,layout:A,node:s,plugins:a,theme:c,transforms:l}=t;n&&this.setBehaviors(n),i&&this.setData(i),s&&this.setNode(s),o&&this.setEdge(o),r&&this.setCombo(r),A&&this.setLayout(A),c&&this.setTheme(c),a&&this.setPlugins(a),l&&this.setTransforms(l)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){t&&(this.options.width=t),e&&(this.options.height=e),this.resize(t,e)}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t,this.context.model.refreshData()}setEdge(t){this.options.edge=t,this.context.model.refreshData()}setCombo(t){this.options.combo=t,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(t){this.options.theme=Gt(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=Gt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=Gt(t)?t(this.getBehaviors()):t,null===(e=this.context.behavior)||void 0===e||e.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){var e;this.options.plugins=Gt(t)?t(this.getPlugins()):t,null===(e=this.context.plugin)||void 0===e||e.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){var e;this.options.transforms=Gt(t)?t(this.getTransforms()):t,null===(e=this.context.transform)||void 0===e||e.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e)),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}hasNode(t){return this.context.model.hasNode(t)}hasEdge(t){return this.context.model.hasEdge(t)}hasCombo(t){return this.context.model.hasCombo(t)}getElementData(t){return Array.isArray(t)?t.map(t=>this.context.model.getElementDataById(t)):this.context.model.getElementDataById(t)}getNodeData(t){return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeLikeDatum(t)}getEdgeData(t){return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeDatum(t)}getComboData(t){return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getNodeLikeDatum(t)}setData(t){this.context.model.setData(Gt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Gt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Gt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Gt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Gt(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(Gt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Gt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Gt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Gt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Gt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Gt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Gt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Gt(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getDescendantsData(t){return this.context.model.getDescendantsData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}initCanvas(){return De(this,void 0,void 0,function*(){var e;if(this.context.canvas)return yield this.context.canvas.ready;const{container:n="container",width:r,height:i,renderer:o,cursor:A,background:s,canvas:a,devicePixelRatio:c=(null!==(e=globalThis.devicePixelRatio)&&void 0!==e?e:1)}=this.options;if(n instanceof GZ)this.context.canvas=n,A&&n.setCursor(A),o&&n.setRenderer(o),yield n.ready;else{const e=Jt(n)?document.getElementById(n):n,l=VZ(e);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:e,width:r,height:i});const u=Object.assign(Object.assign({},a),{container:e,width:r||l[0],height:i||l[1],background:s,renderer:o,cursor:A,devicePixelRatio:c}),h=new GZ(u);this.context.canvas=h,yield h.ready,this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:h})}})}updateCanvas(e){var n,r;const{renderer:i,cursor:o,height:A,width:s}=e,a=this.context.canvas;a&&(i&&(this.emit(t.GraphEvent.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),a.setRenderer(i),this.emit(t.GraphEvent.AFTER_RENDERER_CHANGE,{renderer:i})),o&&a.setCursor(o),(re(s)||re(A))&&this.setSize(null!==(n=null!=s?s:this.options.width)&&void 0!==n?n:0,null!==(r=null!=A?A:this.options.height)&&void 0!==r?r:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new iJ(this.context)),this.context.plugin||(this.context.plugin=new dJ(this.context)),this.context.viewport||(this.context.viewport=new pJ(this.context)),this.context.transform||(this.context.transform=new gJ(this.context)),this.context.element||(this.context.element=new cJ(this.context)),this.context.animation||(this.context.animation=new rJ(this.context)),this.context.layout||(this.context.layout=new lJ(this.context)),this.context.behavior||(this.context.behavior=new oJ(this.context))}prepare(){return De(this,void 0,void 0,function*(){yield Promise.resolve(),this.destroyed?console.error($v("The graph instance has been destroyed")):(yield this.initCanvas(),this.initRuntime())})}render(){return De(this,void 0,void 0,function*(){if(yield this.prepare(),ZZ(this,new YZ(t.GraphEvent.BEFORE_RENDER)),this.options.layout)if(this.rendered||(e=this.options.layout,Array.isArray(e)||!(null==e?void 0:e.preLayout))){const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const t=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}else{const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}var e;this.rendered=!0,ZZ(this,new YZ(t.GraphEvent.AFTER_RENDER))})}draw(){return De(this,void 0,void 0,function*(){var t;yield this.prepare(),yield null===(t=this.context.element.draw())||void 0===t?void 0:t.finished})}layout(t){return De(this,void 0,void 0,function*(){yield this.context.layout.postLayout(t)})}stopLayout(){this.context.layout.stopLayout()}clear(){return De(this,void 0,void 0,function*(){const{model:t,element:e}=this.context;t.setData({}),t.clearChanges(),null==e||e.clear()})}destroy(){var e;ZZ(this,new YZ(t.GraphEvent.BEFORE_DESTROY));const{layout:n,animation:r,element:i,model:o,canvas:A,behavior:s,plugin:a}=this.context;null==a||a.destroy(),null==s||s.destroy(),null==n||n.destroy(),null==r||r.destroy(),null==i||i.destroy(),o.destroy(),null==A||A.destroy(),this.options={},this.context={},this.off(),null===(e=globalThis.removeEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize),this.destroyed=!0,ZZ(this,new YZ(t.GraphEvent.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,n){var r;const i=VZ(null===(r=this.context.canvas)||void 0===r?void 0:r.getContainer()),o=[e||i[0],n||i[1]];if(!this.context.canvas)return;const A=this.context.canvas.getSize();xe(o,A)||(ZZ(this,new YZ(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:o})),this.context.canvas.resize(...o),ZZ(this,new YZ(t.GraphEvent.AFTER_SIZE_CHANGE,{size:o})))}fitView(t,e){return De(this,void 0,void 0,function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.fitView(t,e)})}fitCenter(t){return De(this,void 0,void 0,function*(){var e;yield null===(e=this.context.viewport)||void 0===e?void 0:e.fitCenter({animation:t})})}autoFit(){return De(this,void 0,void 0,function*(){const{autoFit:t}=this.context.options;if(t)if(Jt(t))"view"===t?yield this.fitView():"center"===t&&(yield this.fitCenter());else{const{type:e,animation:n}=t;"view"===e?yield this.fitView(t.options,n):"center"===e&&(yield this.fitCenter(n))}})}focusElement(t,e){return De(this,void 0,void 0,function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.focusElements(Array.isArray(t)?t:[t],{animation:e})})}zoomBy(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)})}zoomTo(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)})}getZoom(){return this.context.viewport.getZoom()}rotateBy(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)})}rotateTo(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)})}getRotation(){return this.context.viewport.getRotation()}translateBy(t,e){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)})}translateTo(t,e){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)})}getPosition(){return cy([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach(([t,e])=>this.context.model.translateNodeLikeBy(t,e)),yield null===(i=this.context.element.draw({animation:A,stage:"translate"}))||void 0===i?void 0:i.finished})}translateElementTo(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach(([t,e])=>this.context.model.translateNodeLikeTo(t,e)),yield null===(i=this.context.element.draw({animation:A,stage:"translate"}))||void 0===i?void 0:i.finished})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return Se(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach(([t,e])=>{const n=this.getElementType(t);s[`${n}s`].push({id:t,style:{visibility:e}})});const{model:a,element:c}=this.context;a.preventUpdateNodeLikeHierarchy(()=>{a.updateData(s)}),yield null===(i=c.draw({animation:A,stage:"visibility"}))||void 0===i?void 0:i.finished})}showElement(t,e){return De(this,void 0,void 0,function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map(t=>[t,"visible"])),e)})}hideElement(t,e){return De(this,void 0,void 0,function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map(t=>[t,"hidden"])),e)})}getElementVisibility(t){var e,n;const r=this.context.element.getElement(t);return null!==(n=null===(e=null==r?void 0:r.style)||void 0===e?void 0:e.visibility)&&void 0!==n?n:"visible"}setElementZIndex(t,e){return De(this,void 0,void 0,function*(){var n;const r={nodes:[],edges:[],combos:[]},i=zt(t)?t:{[t]:e};Object.entries(i).forEach(([t,e])=>{const n=this.getElementType(t);r[`${n}s`].push({id:t,style:{zIndex:e}})});const{model:o,element:A}=this.context;o.preventUpdateNodeLikeHierarchy(()=>o.updateData(r)),yield null===(n=A.draw({animation:!1,stage:"zIndex"}))||void 0===n?void 0:n.finished})}frontElement(t){return De(this,void 0,void 0,function*(){const e=Array.isArray(t)?t:[t],{model:n}=this.context,r={};e.map(t=>{const e=n.getFrontZIndex(t);if("combo"===n.getElementType(t)){const i=n.getAncestorsData(t,zv).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Km(i))],A=e-JZ(i);o.forEach(t=>{r[Km(t)]=this.getElementZIndex(Km(t))+A});const{internal:s}=vB(o.map(Km),t=>n.getRelatedEdgesData(t));s.forEach(t=>{const e=Km(t);r[e]=this.getElementZIndex(e)+A})}else r[t]=e}),yield this.setElementZIndex(r)})}getElementZIndex(t){return JZ(this.context.model.getElementDataById(t))}setElementState(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach(([t,e])=>{const n=this.getElementType(t);var r;s[`${n}s`].push({id:t,states:(r=e,r?Array.isArray(r)?r:[r]:[])})}),this.updateData(s),yield null===(i=this.context.element.draw({animation:A,stage:"state"}))||void 0===i?void 0:i.finished})}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}collapseElement(t){return De(this,arguments,void 0,function*(t,e=!0){const{model:n,element:r}=this.context;if(rw(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!1});const i=n.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,n.updateData("node"===i?{nodes:[{id:t,style:{collapsed:!0}}]}:{combos:[{id:t,style:{collapsed:!0}}]}),"node"===i?yield r.collapseNode(t,e):"combo"===i&&(yield r.collapseCombo(t,!!e.animation)),this.isCollapsingExpanding=!1})}expandElement(t){return De(this,arguments,void 0,function*(t,e=!0){const{model:n,element:r}=this.context;if(!rw(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!1});const i=n.getElementType(t);this.isCollapsingExpanding=!0,n.updateData("node"===i?{nodes:[{id:t,style:{collapsed:!1}}]}:{combos:[{id:t,style:{collapsed:!1}}]}),"node"===i?yield r.expandNode(t,e):"combo"===i&&(yield r.expandCombo(t,!!e.animation)),this.isCollapsingExpanding=!1})}setElementCollapsibility(t,e){const n=this.getElementType(t);"node"===n?this.updateNodeData([{id:t,style:{collapsed:e}}]):"combo"===n&&this.updateComboData([{id:t,style:{collapsed:e}}])}toDataURL(){return De(this,arguments,void 0,function*(t={}){return this.context.canvas.toDataURL(t)})}getCanvasByViewport(t){return this.context.canvas.getCanvasByViewport(t)}getViewportByCanvas(t){return this.context.canvas.getViewportByCanvas(t)}getClientByCanvas(t){return this.context.canvas.getClientByCanvas(t)}getCanvasByClient(t){return this.context.canvas.getCanvasByClient(t)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(t,e,n){return super.on(t,e,n)}once(t,e){return super.once(t,e)}off(t,e){return super.off(t,e)}}vJ.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const mJ=(t,e)=>{const{source:n,target:r}=e,i=t.getElementDataById(n),o=t.getElementDataById(r),A=mB(i,e=>t.getParentData(e,zv)),s=mB(o,e=>t.getParentData(e,zv)),a={sourceNode:Km(A),targetNode:Km(s)};return e.style?Object.assign(e.style,a):e.style=a,e};class yJ extends UZ{constructor(t,e){super(t,be({},yJ.defaultOptions,e)),this.assignSizeByCentrality=(t,e,n,r,i,o)=>{const A=[e,n],s=[r[0],i[0]],a=[r[1],i[1]],c=[r[2],i[2]],l=(t,e)=>{if("function"==typeof o)return o(t,A,e);switch(o){case"linear":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return i===r?o:o+(t-r)/(i-r)*(A-o)})(t,A,e);case"log":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return o+Math.log(t-r+1)/Math.log(i-r+1)*(A-o)})(t,A,e);case"pow":return((t,e,n,r=2)=>{const[i,o]=e,[A,s]=n;return A+Math.pow((t-i)/(o-i),r)*(s-A)})(t,A,e,2);case"sqrt":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return o+Math.sqrt((t-r)/(i-r))*(A-o)})(t,A,e);default:return e[0]}};return[l(t,s),l(t,a),l(t,c)]}}beforeDraw(t){const{model:e}=this.context,n=e.getNodeData(),r=cw(this.options.maxSize),i=cw(this.options.minSize),o=this.getCentralities(this.options.centrality),A=o.size>0?Math.max(...o.values()):0,s=o.size>0?Math.min(...o.values()):0;return n.forEach(e=>{var n;const a=this.assignSizeByCentrality(o.get(Km(e))||0,s,A,i,r,this.options.scale),c=null===(n=this.context.element)||void 0===n?void 0:n.getElement(Km(e)),l={size:a};this.assignLabelStyle(l,a,e,c),c&&TZ(l,c.attributes)||NZ(t,c?"update":"add","node",be(e,{style:l}),!0)}),t}assignLabelStyle(t,e,n,r){var i;const o=r?r.config.style:null===(i=this.context.element)||void 0===i?void 0:i.getElementComputedStyle("node",n);if(Object.assign(t,ke(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const n=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:n,labelLineHeight:n+vm(t.labelPadding)})}return t}getLabelSizeByNodeSize(t,e,n){const r=Math.min(...t)/2,[i,o]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[n,e];return Math.min(o,Math.max(r,i))}getCentralities(t){const{model:e}=this.context,n=e.getData();if("function"==typeof t)return t(n);const r=e.getRelatedEdgesData.bind(e);return Vm(n,r,t)}}yJ.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class wJ extends UZ{constructor(t,e){super(t,Object.assign({},wJ.defaultOptions,e))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var t;const e=My(this.ref),{graph:n,model:r}=this.context;null===(t=r.getData().nodes)||void 0===t||t.forEach(t=>{var i;if(Km(t)===Km(this.ref))return;const o=by(cy(My(t),e)),A=Math.abs(o)>Math.PI/2,s=!t.children||0===t.children.length,a=Km(t),c=null===(i=this.context.element)||void 0===i?void 0:i.getElement(a);if(!c||!c.isVisible())return;const l=(s?1:-1)*(cw(n.getElementRenderStyle(a).size)[0]/2+this.options.offset),u=[["translate",l*Math.cos(o),l*Math.sin(o)],["rotate",A?Tr(o)+180:Tr(o)]];r.updateNodeData([{id:Km(t),style:{labelTextAlign:A===s?"right":"left",labelTextBaseline:"middle",labelTransform:u}}])}),n.draw()}}wJ.defaultOptions={offset:5};const bJ=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class BJ extends UZ{constructor(t,e){super(t,Object.assign({},BJ.defaultOptions,e)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=t=>{const{add:{edges:e},update:{nodes:n,edges:r,combos:i},remove:{edges:o}}=t,{model:A}=this.context,s=new Map,a=(t,e)=>{A.getRelatedEdgesData(e).forEach(t=>!s.has(Km(t))&&s.set(Km(t),t))};n.forEach(a),i.forEach(a);const c=e=>{const n=new Set(t.remove.edges.keys()),r=A.getEdgeData().filter(t=>!n.has(Km(t))).map(t=>mJ(A,t));xJ(e,r).forEach(t=>{const e=Km(t);s.has(e)||s.set(e,t)})};if(o.size&&o.forEach(c),e.size&&e.forEach(c),r.size){const t=oV(iV(A.getChanges())).update.edges;r.forEach(e=>{var n;c(e);const r=null===(n=t.find(t=>Km(t.value)===Km(e)))||void 0===n?void 0:n.original;r&&!CJ(e,r)&&c(r)})}Ee(this.options.edges)||s.forEach((t,e)=>!this.options.edges.includes(e)&&s.delete(e));const l=A.getEdgeData().map(Km);return new Map([...s].sort((t,e)=>l.indexOf(t[0])-l.indexOf(e[0])))},this.applyBundlingStyle=(t,e,n)=>{var r,i;const{edgeMap:o,reverses:A}=EJ(e),s=null!==(r=this.options.loopMode)&&void 0!==r?r:"spread",a=null!==(i=this.options.loopDistance)&&void 0!==i?i:n,c=new Map;o.forEach(e=>{e.forEach((e,r,i)=>{var o,l;const u=i.length,h=e.style||{};if(e.source===e.target)if("nested"===s){const t=h.loopPlacement||"top",n=`${e.source}-${t}`;if(h.loopPlacement=t,void 0===h.loopDist){const t=null!==(o=c.get(n))&&void 0!==o?o:0;h.loopDist=35+t*a,c.set(n,t+1)}}else{const t=bJ.length;h.loopPlacement=bJ[r%t],h.loopDist=Math.floor(r/t)*n+50}else if(1===u)h.curveOffset=0;else{const t=(r%2==0?1:-1)*(A[`${e.source}|${e.target}|${r}`]?-1:1);h.curveOffset=u%2==1?t*Math.ceil(r/2)*n*2:t*(Math.floor(r/2)*n*2+n)}const d=Object.assign(e,{type:"quadratic",style:h}),f=null===(l=this.context.element)||void 0===l?void 0:l.getElement(Km(e));f&&TZ(d.style,f.attributes)||NZ(t,f?"update":"add","edge",d,!0)})})},this.resetEdgeStyle=t=>{const e=t.style||{},n=this.cacheMergeStyle.get(Km(t))||{};return Object.keys(n).forEach(r=>{xe(e[r],n[r])&&(t[r]?e[r]=t[r]:delete e[r])}),Object.assign(t,{style:e})},this.applyMergingStyle=(t,e)=>{const{edgeMap:n,reverses:r}=EJ(e);n.forEach(e=>{var n;if(1===e.length){const r=e[0],i=null===(n=this.context.element)||void 0===n?void 0:n.getElement(Km(r)),o=this.resetEdgeStyle(r);return void(i&&TZ(o,i.attributes)||NZ(t,i?"update":"add","edge",o))}const i=e.map(({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:A}=n,s={},[a,c]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return ue(o)&&(s[a]=o),ue(A)&&(s[c]=A),s}).reduce((t,e)=>Object.assign(Object.assign({},t),e),{});e.forEach((e,n,r)=>{var o;if(0!==n)return void NZ(t,"remove","edge",e);const A=Object.assign({},Gt(this.options.style)?this.options.style(r):this.options.style,{childrenData:r});this.cacheMergeStyle.set(Km(e),A);const s=Object.assign(Object.assign({},e),{type:"line",style:Object.assign(Object.assign(Object.assign({},e.style),i),A)}),a=null===(o=this.context.element)||void 0===o?void 0:o.getElement(Km(e));a&&TZ(s.style,a.attributes)||NZ(t,a?"update":"add","edge",s,!0)})})}}beforeDraw(t){const e=this.getAffectedParallelEdges(t);return 0===e.size||("bundle"===this.options.mode?this.applyBundlingStyle(t,e,this.options.distance):this.applyMergingStyle(t,e)),t}}BJ.defaultOptions={mode:"bundle",distance:15,loopMode:"spread",loopDistance:15};const EJ=t=>{const e=new Map,n=new Set,r={},i=new Map;for(const[o,A]of t){if(n.has(o))continue;const{source:s,target:a}=A,c=`${s}-${a}`;e.has(c)||(e.set(c,[]),i.set(c,new Set));const l=e.get(c),u=i.get(c);l&&u&&!u.has(o)&&(l.push(A),u.add(o),n.add(o));for(const[l,u]of t)if(!n.has(l)&&l!==o&&CJ(A,u)){const t=e.get(c),o=i.get(c);t&&o&&!o.has(l)&&(t.push(u),o.add(l),s===u.target&&a===u.source&&(r[`${u.source}|${u.target}|${t.length-1}`]=!0),n.add(l))}}return{edgeMap:e,reverses:r}},xJ=(t,e,n)=>e.filter(e=>CJ(e,t)),CJ=(t,e)=>{const{sourceNode:n,targetNode:r}=t.style||{},{sourceNode:i,targetNode:o}=e.style||{};return n===i&&r===o||n===o&&r===i};const MJ={animation:{"combo-collapse":um,"combo-expand":hm,"node-collapse":sm,"node-expand":am,"path-in":cm,"path-out":lm,fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}]},behavior:{"brush-select":Yy,"click-select":nw,"collapse-expand":nE,"create-edge":cE,"drag-canvas":lE,"drag-element-force":EE,"drag-element":uE,"fix-element-size":xE,"focus-element":CE,"hover-activate":ME,"lasso-select":FE,"auto-adapt-label":oy,"optimize-viewport-transform":kE,"scroll-canvas":SE,"zoom-canvas":QE},combo:{circle:Yb,rect:Xb},edge:{cubic:BB,line:MB,polyline:PB,quadratic:DB,"cubic-horizontal":EB,"cubic-radial":xB,"cubic-vertical":CB},layout:{"antv-dagre":bF,"combo-combined":Yj,"compact-box":$E,"d3-force":Ok,"force-atlas2":nj,circular:QF,concentric:NF,dagre:LK,dendrogram:ix,fishbone:Xj,force:qK,fruchterman:oj,grid:sj,indented:lx,mds:Uj,mindmap:vx,radial:Dj,random:Kj,snake:Jj},node:{circle:Tw,diamond:Iw,ellipse:Rw,hexagon:Hw,html:Gb,image:Kb,rect:jb,star:zb,donut:Lw,triangle:Vb},palette:{spectral:["rgb(158, 1, 66)","rgb(213, 62, 79)","rgb(244, 109, 67)","rgb(253, 174, 97)","rgb(254, 224, 139)","rgb(255, 255, 191)","rgb(230, 245, 152)","rgb(171, 221, 164)","rgb(102, 194, 165)","rgb(50, 136, 189)","rgb(94, 79, 162)"],tableau:["rgb(78, 121, 167)","rgb(242, 142, 44)","rgb(225, 87, 89)","rgb(118, 183, 178)","rgb(89, 161, 79)","rgb(237, 201, 73)","rgb(175, 122, 161)","rgb(255, 157, 167)","rgb(156, 117, 95)","rgb(186, 176, 171)"],oranges:["rgb(255, 245, 235)","rgb(254, 230, 206)","rgb(253, 208, 162)","rgb(253, 174, 107)","rgb(253, 141, 60)","rgb(241, 105, 19)","rgb(217, 72, 1)","rgb(166, 54, 3)","rgb(127, 39, 4)"],greens:["rgb(247, 252, 245)","rgb(229, 245, 224)","rgb(199, 233, 192)","rgb(161, 217, 155)","rgb(116, 196, 118)","rgb(65, 171, 93)","rgb(35, 139, 69)","rgb(0, 109, 44)","rgb(0, 68, 27)"],blues:["rgb(247, 251, 255)","rgb(222, 235, 247)","rgb(198, 219, 239)","rgb(158, 202, 225)","rgb(107, 174, 214)","rgb(66, 146, 198)","rgb(33, 113, 181)","rgb(8, 81, 156)","rgb(8, 48, 107)"]},theme:{dark:SZ,light:QZ},plugin:{"bubble-sets":Hz,"edge-bundling":jz,"edge-filter-lens":Jz,"grid-line":rV,background:rz,contextmenu:Kz,fisheye:eV,fullscreen:nV,history:aV,hull:GV,legend:J$,minimap:tZ,snapline:iZ,timebar:aZ,title:mZ,toolbar:wZ,tooltip:bZ,watermark:xZ},transform:{"arrange-draw-order":class extends UZ{beforeDraw(t){const{model:e}=this.context,n=t.add.combos,r=t=>{const n=[];return t.forEach((t,r)=>{const i=e.getAncestorsData(r,"combo").map(t=>Km(t)).reverse();n.push([r,t,i.length])}),new Map(n.sort(([,,t],[,,e])=>e-t).map(([t,e])=>[t,e]))};return t.add.combos=r(n),t.update.combos=r(t.update.combos),t}},"collapse-expand-combo":class extends UZ{beforeDraw(t,e){if("visibility"===e.stage)return t;if(!this.context.model.model.hasTreeStructure(zv))return t;const{model:n}=this.context,{add:r,update:i}=t,o=[...t.update.combos.entries(),...t.add.combos.entries()];for(;o.length;){const[e,A]=o.pop();if(rw(A)){const A=n.getDescendantsData(e),s=A.map(Km),{internal:a,external:c}=vB(s,t=>n.getRelatedEdgesData(t));A.forEach(e=>{const r=Km(e),i=o.findIndex(([t])=>t===r);-1!==i&&o.splice(i,1);const A=n.getElementType(r);NZ(t,"remove",A,e)}),a.forEach(e=>NZ(t,"remove","edge",e)),c.forEach(t=>{var e;const n=Km(t);(null===(e=this.context.element)||void 0===e?void 0:e.getElement(n))?i.edges.set(n,t):r.edges.set(n,t)})}else{const r=n.getChildrenData(e),i=r.map(Km),{edges:A}=vB(i,t=>n.getRelatedEdgesData(t));[...r,...A].forEach(e=>{var r;const i=Km(e),A=n.getElementType(i),s=null===(r=this.context.element)||void 0===r?void 0:r.getElement(i);NZ(t,s?"update":"add",A,e),"combo"===A&&o.push([i,e])})}}return t}},"collapse-expand-node":class extends UZ{getElement(t){return this.context.element.getElement(t)}handleExpand(t,e){if(OZ(e,"add","node",t),rw(t))return;const n=Km(t);OZ(e,"add","node",t);this.context.model.getRelatedEdgesData(n).forEach(t=>{NZ(e,"add","edge",t)});this.context.model.getChildrenData(n).forEach(t=>{this.handleExpand(t,e)})}beforeDraw(t){const{graph:e,model:n}=this.context;if(!n.model.hasTreeStructure(Vv))return t;const{add:{nodes:r,edges:i},update:{nodes:o}}=t,A=new Map,s=new Map;r.forEach((t,e)=>{rw(t)&&A.set(e,t)}),i.forEach(t=>{if("node"!==e.getElementType(t.source))return;const n=e.getNodeData(t.source);rw(n)&&A.set(t.source,n)}),o.forEach((t,e)=>{const n=this.getElement(e);if(!n)return;const r=n.attributes.collapsed;rw(t)?r||A.set(e,t):r&&s.set(e,t)});const a=new Set;return A.forEach((e,r)=>{n.getDescendantsData(r).forEach(e=>{const r=Km(e);if(a.has(r))return;NZ(t,"remove","node",e);n.getRelatedEdgesData(r).forEach(e=>{NZ(t,"remove","edge",e)}),a.add(r)})}),s.forEach((e,r)=>{n.getAncestorsData(r,Vv).some(rw)?NZ(t,"remove","node",e):this.handleExpand(e,t)}),t}},"get-edge-actual-ends":class extends UZ{beforeDraw(t){const{add:e,update:n}=t,{model:r}=this.context;return[...e.edges.entries(),...n.edges.entries()].forEach(([,t])=>{mJ(r,t)}),t}},"map-node-size":yJ,"place-radial-labels":wJ,"process-parallel-edges":BJ,"update-related-edges":class extends UZ{beforeDraw(t,e){const{stage:n}=e;if("visibility"===n)return t;const{model:r}=this.context,{update:{nodes:i,edges:o,combos:A}}=t,s=(t,e)=>{r.getRelatedEdgesData(e).forEach(t=>!o.has(Km(t))&&o.set(Km(t),t))};return i.forEach(s),A.forEach(s),t}}},shape:{circle:za,ellipse:Ya,group:Xa,html:$a,image:Cw,line:tc,path:nc,polygon:ic,polyline:Ac,rect:sc,text:cc,label:yw,badge:ww}};Object.entries(MJ).forEach(([t,e])=>{Object.entries(e).forEach(([e,n])=>{PZ(t,e,n)})});t.AntVDagreLayout=bF,t.AutoAdaptLabel=oy,t.Background=rz,t.Badge=ww,t.BaseBehavior=iy,t.BaseCombo=Wb,t.BaseEdge=bB,t.BaseLayout=mE,t.BaseNode=Nw,t.BasePlugin=tz,t.BaseShape=pw,t.BaseTransform=UZ,t.BrushSelect=Yy,t.BubbleSets=Hz,t.CameraSetting=class extends tz{constructor(t,e){super(t,e),this.setOptions=t=>{const e=(t,e)=>{switch(t){case"projectionMode":return"perspective"===e?1:0;case"cameraType":return{orbiting:0,exploring:1,tracking:2}[e];case"aspect":return"number"==typeof e?e:this.getCanvasAspect();default:return e}};Object.entries({cameraType:"setType",near:"setNear",far:"setFar",fov:"setFov",aspect:"setAspect",projectionMode:"setProjectionMode",distance:"setDistance",minDistance:"setMinDistance",maxDistance:"setMaxDistance",roll:"setRoll",elevation:"setElevation",azimuth:"setAzimuth"}).forEach(([n,r])=>{const i=t[n];if(void 0!==i){const t=e(n,i);this.context.canvas.getCamera()[r](t)}})},this.bindEvents()}update(t){this.setOptions(t),super.update(t)}bindEvents(){this.context.graph.once(t.GraphEvent.BEFORE_DRAW,()=>this.setOptions(this.options))}getCanvasAspect(){const[t,e]=this.context.viewport.getCanvasSize();return t/e}},t.Canvas=GZ,t.Circle=Tw,t.CircleCombo=Yb,t.CircularLayout=QF,t.ClickSelect=nw,t.CollapseExpand=nE,t.ComboCombinedLayout=Yj,t.CompactBoxLayout=$E,t.ConcentricLayout=NF,t.Contextmenu=Kz,t.CreateEdge=cE,t.Cubic=BB,t.CubicHorizontal=EB,t.CubicRadial=xB,t.CubicVertical=CB,t.D3ForceLayout=Ok,t.DagreLayout=LK,t.DendrogramLayout=ix,t.Diamond=Iw,t.Donut=Lw,t.DragCanvas=lE,t.DragElement=uE,t.DragElementForce=EE,t.EdgeBundling=jz,t.EdgeFilterLens=Jz,t.Ellipse=Rw,t.FishboneLayout=Xj,t.Fisheye=eV,t.FixElementSize=xE,t.FocusElement=CE,t.ForceAtlas2Layout=nj,t.ForceLayout=qK,t.FruchtermanLayout=oj,t.Fullscreen=nV,t.Graph=vJ,t.GridLayout=sj,t.GridLine=rV,t.HTML=Gb,t.Hexagon=Hw,t.History=aV,t.HoverActivate=ME,t.Hull=GV,t.Icon=Qw,t.Image=Kb,t.IndentedLayout=lx,t.Label=yw,t.LassoSelect=FE,t.Legend=J$,t.Line=MB,t.MDSLayout=Uj,t.MapNodeSize=yJ,t.MindmapLayout=vx,t.Minimap=tZ,t.OptimizeViewportTransform=kE,t.PlaceRadialLabels=wJ,t.Polyline=PB,t.ProcessParallelEdges=BJ,t.Quadratic=DB,t.RadialLayout=Dj,t.RandomLayout=Kj,t.Rect=jb,t.RectCombo=Xb,t.ScrollCanvas=SE,t.Shortcut=Wy,t.SnakeLayout=Jj,t.Snapline=iZ,t.Star=zb,t.Timebar=aZ,t.Title=mZ,t.Toolbar=wZ,t.Tooltip=bZ,t.Triangle=Vb,t.Watermark=xZ,t.ZoomCanvas=QE,t.effect=function(t,e,n){IZ.has(t)||IZ.set(t,{});const r=IZ.get(t);if(!r[e])return r[e]=n,!0;const i=r[e];return!LZ(i,n)&&(r[e]=n,!0)},t.getExtension=Xv,t.getExtensions=function(t){return Yv[t]},t.iconfont={css:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.css",js:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.js"},t.idOf=Km,t.invokeLayoutMethod=bE,t.isCollapsed=rw,t.omitStyleProps=aw,t.parseSize=cw,t.positionOf=My,t.register=PZ,t.setVisibility=ey,t.subStyleProps=Aw,t.treeToGraphData=function(t,e){const{getNodeData:n=(t,e)=>{if(t.depth=e,!t.children)return t;const{children:n}=t,r=Pe(t,["children"]);return Object.assign(Object.assign({},r),{children:n.map(t=>t.id)})},getEdgeData:r=(t,e)=>({source:t.id,target:e.id}),getChildren:i=t=>t.children||[]}=e||{},o=[],A=[];return Zy(t,(t,e)=>{o.push(n(t,e));const s=i(t);for(const e of s)A.push(r(t,e))},t=>i(t),"TB"),{nodes:o,edges:A}},t.version=qv});