@antv/g6 5.0.45 → 5.0.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/g6.min.js +4 -4
  2. package/dist/lib/behaviors/zoom-canvas.d.ts +9 -1
  3. package/dist/lib/elements/nodes/image.d.ts +1 -0
  4. package/dist/lib/registry/register.d.ts +1 -5
  5. package/dist/lib/version.d.ts +1 -1
  6. package/esm/behaviors/brush-select.js +3 -1
  7. package/esm/behaviors/brush-select.js.map +1 -1
  8. package/esm/behaviors/drag-element.js +2 -0
  9. package/esm/behaviors/drag-element.js.map +1 -1
  10. package/esm/behaviors/zoom-canvas.d.ts +9 -1
  11. package/esm/behaviors/zoom-canvas.js +2 -2
  12. package/esm/behaviors/zoom-canvas.js.map +1 -1
  13. package/esm/elements/nodes/image.d.ts +1 -0
  14. package/esm/elements/nodes/image.js +13 -2
  15. package/esm/elements/nodes/image.js.map +1 -1
  16. package/esm/plugins/minimap/index.js +2 -0
  17. package/esm/plugins/minimap/index.js.map +1 -1
  18. package/esm/registry/register.d.ts +1 -5
  19. package/esm/registry/register.js +4 -10
  20. package/esm/registry/register.js.map +1 -1
  21. package/esm/version.d.ts +1 -1
  22. package/esm/version.js +1 -1
  23. package/lib/behaviors/brush-select.js +3 -1
  24. package/lib/behaviors/brush-select.js.map +1 -1
  25. package/lib/behaviors/drag-element.js +2 -0
  26. package/lib/behaviors/drag-element.js.map +1 -1
  27. package/lib/behaviors/zoom-canvas.d.ts +9 -1
  28. package/lib/behaviors/zoom-canvas.js +2 -2
  29. package/lib/behaviors/zoom-canvas.js.map +1 -1
  30. package/lib/elements/nodes/image.d.ts +1 -0
  31. package/lib/elements/nodes/image.js +13 -2
  32. package/lib/elements/nodes/image.js.map +1 -1
  33. package/lib/plugins/minimap/index.js +2 -0
  34. package/lib/plugins/minimap/index.js.map +1 -1
  35. package/lib/registry/register.d.ts +1 -5
  36. package/lib/registry/register.js +4 -10
  37. package/lib/registry/register.js.map +1 -1
  38. package/lib/version.d.ts +1 -1
  39. package/lib/version.js +1 -1
  40. package/package.json +7 -7
  41. package/src/behaviors/brush-select.ts +3 -2
  42. package/src/behaviors/drag-element.ts +1 -0
  43. package/src/behaviors/zoom-canvas.ts +10 -2
  44. package/src/elements/nodes/image.ts +14 -2
  45. package/src/plugins/minimap/index.ts +2 -0
  46. package/src/registry/register.ts +5 -8
  47. package/src/version.ts +1 -1
package/dist/g6.min.js CHANGED
@@ -1,4 +1,4 @@
1
- !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";var e="undefined"!=typeof document?document.currentScript:null;function n(t){return n="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},n(t)}function r(t){var e=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e);if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==n(e)?e:e+""}function i(t,e,n){return(e=r(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(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 a(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,r(i.key),i)}}function u(t,e,n){return e&&l(t.prototype,e),n&&l(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function h(t,e){if(t){if("string"==typeof t)return c(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}function d(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function g(t,e){if(e&&("object"==n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function v(t,e,n){return e=f(e),g(t,p()?Reflect.construct(e,n||[],f(t).constructor):e.apply(t,n))}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}function y(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}function b(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(t){u=!0,i=t}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(t,e)||h(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function E(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function w(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?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}var k={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||t,a),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],s]:t._events[l].push(s):(t._events[l]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},s.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},s.prototype.emit=function(t,e,r,i,o,a){var s=n?n+t:t;if(!this._events[s])return!1;var l,u,c=this._events[s],h=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,i),!0;case 5:return c.fn.call(c.context,e,r,i,o),!0;case 6:return c.fn.call(c.context,e,r,i,o,a),!0}for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var d,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(t,c[u].fn,void 0,!0),h){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,e);break;case 3:c[u].fn.call(c[u].context,e,r);break;case 4:c[u].fn.call(c[u].context,e,r,i);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];c[u].fn.apply(c[u].context,l)}}return!0},s.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},s.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},s.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var l=0,u=[],c=s.length;l<c;l++)(s[l].fn!==e||i&&!s[l].once||r&&s[l].context!==r)&&u.push(s[l]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,t.exports=s}(k);var M=E(k.exports),S=1e-6,N="undefined"!=typeof Float32Array?Float32Array:Array;function O(){var t=new N(9);return N!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function T(){var t=new N(16);return N!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function C(t){var e=new N(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function A(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function P(t,e,n,r,i,o,a,s,l,u,c,h,d,f,p,g){var v=new N(16);return v[0]=t,v[1]=e,v[2]=n,v[3]=r,v[4]=i,v[5]=o,v[6]=a,v[7]=s,v[8]=l,v[9]=u,v[10]=c,v[11]=h,v[12]=d,v[13]=f,v[14]=p,v[15]=g,v}function R(t,e,n,r,i,o,a,s,l,u,c,h,d,f,p,g,v){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=l,t[8]=u,t[9]=c,t[10]=h,t[11]=d,t[12]=f,t[13]=p,t[14]=g,t[15]=v,t}function D(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function L(t,e){if(t===e){var n=e[1],r=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function _(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=n*s-r*a,b=n*l-i*a,x=n*u-o*a,E=r*l-i*s,w=r*u-o*s,k=i*u-o*l,M=c*g-h*p,S=c*v-d*p,N=c*m-f*p,O=h*v-d*g,T=h*m-f*g,C=d*m-f*v,A=y*C-b*T+x*O+E*N-w*S+k*M;return A?(A=1/A,t[0]=(s*C-l*T+u*O)*A,t[1]=(i*T-r*C-o*O)*A,t[2]=(g*k-v*w+m*E)*A,t[3]=(d*w-h*k-f*E)*A,t[4]=(l*N-a*C-u*S)*A,t[5]=(n*C-i*N+o*S)*A,t[6]=(v*x-p*k-m*b)*A,t[7]=(c*k-d*x+f*b)*A,t[8]=(a*T-s*N+u*M)*A,t[9]=(r*N-n*T-o*M)*A,t[10]=(p*w-g*x+m*y)*A,t[11]=(h*x-c*w-f*y)*A,t[12]=(s*S-a*O-l*M)*A,t[13]=(n*O-r*S+i*M)*A,t[14]=(g*b-p*E-v*y)*A,t[15]=(c*E-h*b+d*y)*A,t):null}function I(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*a-n*o)*(h*v-d*g)-(e*s-r*o)*(c*v-d*p)+(e*l-i*o)*(c*g-h*p)+(n*s-r*a)*(u*v-d*f)-(n*l-i*a)*(u*g-h*f)+(r*l-i*s)*(u*p-c*f)}function j(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],b=n[0],x=n[1],E=n[2],w=n[3];return t[0]=b*r+x*s+E*h+w*g,t[1]=b*i+x*l+E*d+w*v,t[2]=b*o+x*u+E*f+w*m,t[3]=b*a+x*c+E*p+w*y,b=n[4],x=n[5],E=n[6],w=n[7],t[4]=b*r+x*s+E*h+w*g,t[5]=b*i+x*l+E*d+w*v,t[6]=b*o+x*u+E*f+w*m,t[7]=b*a+x*c+E*p+w*y,b=n[8],x=n[9],E=n[10],w=n[11],t[8]=b*r+x*s+E*h+w*g,t[9]=b*i+x*l+E*d+w*v,t[10]=b*o+x*u+E*f+w*m,t[11]=b*a+x*c+E*p+w*y,b=n[12],x=n[13],E=n[14],w=n[15],t[12]=b*r+x*s+E*h+w*g,t[13]=b*i+x*l+E*d+w*v,t[14]=b*o+x*u+E*f+w*m,t[15]=b*a+x*c+E*p+w*y,t}function B(t,e,n){var r,i,o,a,s,l,u,c,h,d,f,p,g=n[0],v=n[1],m=n[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],d=e[9],f=e[10],p=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=d,t[10]=f,t[11]=p,t[12]=r*g+s*v+h*m+e[12],t[13]=i*g+l*v+d*m+e[13],t[14]=o*g+u*v+f*m+e[14],t[15]=a*g+c*v+p*m+e[15]),t}function F(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function z(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+u*r,t[5]=a*i+c*r,t[6]=s*i+h*r,t[7]=l*i+d*r,t[8]=u*i-o*r,t[9]=c*i-a*r,t[10]=h*i-s*r,t[11]=d*i-l*r,t}function G(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],l=e[3],u=e[8],c=e[9],h=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-u*r,t[1]=a*i-c*r,t[2]=s*i-h*r,t[3]=l*i-d*r,t[8]=o*r+u*i,t[9]=a*r+c*i,t[10]=s*r+h*i,t[11]=l*r+d*i,t}function V(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function W(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function H(t,e,n){var r,i,o,a=n[0],s=n[1],l=n[2],u=Math.hypot(a,s,l);return u<S?null:(a*=u=1/u,s*=u,l*=u,r=Math.sin(e),o=1-(i=Math.cos(e)),t[0]=a*a*o+i,t[1]=s*a*o+l*r,t[2]=l*a*o-s*r,t[3]=0,t[4]=a*s*o-l*r,t[5]=s*s*o+i,t[6]=l*s*o+a*r,t[7]=0,t[8]=a*l*o+s*r,t[9]=s*l*o-a*r,t[10]=l*l*o+i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function U(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=n,t[7]=0,t[8]=0,t[9]=-n,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function $(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=0,t[2]=-n,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=n,t[9]=0,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Y(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=0,t[4]=-n,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function q(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=r+r,l=i+i,u=o+o,c=r*s,h=r*l,d=r*u,f=i*l,p=i*u,g=o*u,v=a*s,m=a*l,y=a*u;return t[0]=1-(f+g),t[1]=h+y,t[2]=d-m,t[3]=0,t[4]=h-y,t[5]=1-(c+g),t[6]=p+v,t[7]=0,t[8]=d+m,t[9]=p-v,t[10]=1-(c+f),t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t}function X(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function K(t,e){var n=e[0],r=e[1],i=e[2],o=e[4],a=e[5],s=e[6],l=e[8],u=e[9],c=e[10];return t[0]=Math.hypot(n,r,i),t[1]=Math.hypot(o,a,s),t[2]=Math.hypot(l,u,c),t}function Z(t,e){var n=new N(3);K(n,e);var r=1/n[0],i=1/n[1],o=1/n[2],a=e[0]*r,s=e[1]*i,l=e[2]*o,u=e[4]*r,c=e[5]*i,h=e[6]*o,d=e[8]*r,f=e[9]*i,p=e[10]*o,g=a+c+p,v=0;return g>0?(v=2*Math.sqrt(g+1),t[3]=.25*v,t[0]=(h-f)/v,t[1]=(d-l)/v,t[2]=(s-u)/v):a>c&&a>p?(v=2*Math.sqrt(1+a-c-p),t[3]=(h-f)/v,t[0]=.25*v,t[1]=(s+u)/v,t[2]=(d+l)/v):c>p?(v=2*Math.sqrt(1+c-a-p),t[3]=(d-l)/v,t[0]=(s+u)/v,t[1]=.25*v,t[2]=(h+f)/v):(v=2*Math.sqrt(1+p-a-c),t[3]=(s-u)/v,t[0]=(d+l)/v,t[1]=(h+f)/v,t[2]=.25*v),t}function Q(t,e,n,r,i){var o=e[0],a=e[1],s=e[2],l=e[3],u=o+o,c=a+a,h=s+s,d=o*u,f=o*c,p=o*h,g=a*c,v=a*h,m=s*h,y=l*u,b=l*c,x=l*h,E=r[0],w=r[1],k=r[2],M=i[0],S=i[1],N=i[2],O=(1-(g+m))*E,T=(f+x)*E,C=(p-b)*E,A=(f-x)*w,P=(1-(d+m))*w,R=(v+y)*w,D=(p+b)*k,L=(v-y)*k,_=(1-(d+g))*k;return t[0]=O,t[1]=T,t[2]=C,t[3]=0,t[4]=A,t[5]=P,t[6]=R,t[7]=0,t[8]=D,t[9]=L,t[10]=_,t[11]=0,t[12]=n[0]+M-(O*M+A*S+D*N),t[13]=n[1]+S-(T*M+P*S+L*N),t[14]=n[2]+N-(C*M+R*S+_*N),t[15]=1,t}function J(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,f=i*s,p=i*l,g=o*a,v=o*s,m=o*l;return t[0]=1-h-p,t[1]=c+m,t[2]=d-v,t[3]=0,t[4]=c-m,t[5]=1-u-p,t[6]=f+g,t[7]=0,t[8]=d+v,t[9]=f-g,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function tt(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,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?(o=1/(r-i),t[10]=(i+r)*o,t[14]=2*i*r*o):(t[10]=-1,t[14]=-2*r),t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var et=tt;function nt(t,e,n,r,i,o,a){var s=1/(e-n),l=1/(r-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=(a+o)*u,t[15]=1,t}var rt=nt;function it(t,e,n,r,i,o,a){var s=1/(e-n),l=1/(r-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=o*u,t[15]=1,t}function ot(t,e,n,r){var i,o,a,s,l,u,c,h,d,f,p=e[0],g=e[1],v=e[2],m=r[0],y=r[1],b=r[2],x=n[0],E=n[1],w=n[2];return Math.abs(p-x)<S&&Math.abs(g-E)<S&&Math.abs(v-w)<S?D(t):(c=p-x,h=g-E,d=v-w,i=y*(d*=f=1/Math.hypot(c,h,d))-b*(h*=f),o=b*(c*=f)-m*d,a=m*h-y*c,(f=Math.hypot(i,o,a))?(i*=f=1/f,o*=f,a*=f):(i=0,o=0,a=0),s=h*a-d*o,l=d*i-c*a,u=c*o-h*i,(f=Math.hypot(s,l,u))?(s*=f=1/f,l*=f,u*=f):(s=0,l=0,u=0),t[0]=i,t[1]=s,t[2]=c,t[3]=0,t[4]=o,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=u,t[10]=d,t[11]=0,t[12]=-(i*p+o*g+a*v),t[13]=-(s*p+l*g+u*v),t[14]=-(c*p+h*g+d*v),t[15]=1,t)}function at(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t[9]=e[9]-n[9],t[10]=e[10]-n[10],t[11]=e[11]-n[11],t[12]=e[12]-n[12],t[13]=e[13]-n[13],t[14]=e[14]-n[14],t[15]=e[15]-n[15],t}function st(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}var lt=j,ut=at,ct=Object.freeze({__proto__:null,add:function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t[9]=e[9]+n[9],t[10]=e[10]+n[10],t[11]=e[11]+n[11],t[12]=e[12]+n[12],t[13]=e[13]+n[13],t[14]=e[14]+n[14],t[15]=e[15]+n[15],t},adjoint:function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],m=e[15];return t[0]=s*(d*m-f*v)-h*(l*m-u*v)+g*(l*f-u*d),t[1]=-(r*(d*m-f*v)-h*(i*m-o*v)+g*(i*f-o*d)),t[2]=r*(l*m-u*v)-s*(i*m-o*v)+g*(i*u-o*l),t[3]=-(r*(l*f-u*d)-s*(i*f-o*d)+h*(i*u-o*l)),t[4]=-(a*(d*m-f*v)-c*(l*m-u*v)+p*(l*f-u*d)),t[5]=n*(d*m-f*v)-c*(i*m-o*v)+p*(i*f-o*d),t[6]=-(n*(l*m-u*v)-a*(i*m-o*v)+p*(i*u-o*l)),t[7]=n*(l*f-u*d)-a*(i*f-o*d)+c*(i*u-o*l),t[8]=a*(h*m-f*g)-c*(s*m-u*g)+p*(s*f-u*h),t[9]=-(n*(h*m-f*g)-c*(r*m-o*g)+p*(r*f-o*h)),t[10]=n*(s*m-u*g)-a*(r*m-o*g)+p*(r*u-o*s),t[11]=-(n*(s*f-u*h)-a*(r*f-o*h)+c*(r*u-o*s)),t[12]=-(a*(h*v-d*g)-c*(s*v-l*g)+p*(s*d-l*h)),t[13]=n*(h*v-d*g)-c*(r*v-i*g)+p*(r*d-i*h),t[14]=-(n*(s*v-l*g)-a*(r*v-i*g)+p*(r*l-i*s)),t[15]=n*(s*d-l*h)-a*(r*d-i*h)+c*(r*l-i*s),t},clone:C,copy:A,create:T,determinant:I,equals:function(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],v=t[14],m=t[15],y=e[0],b=e[1],x=e[2],E=e[3],w=e[4],k=e[5],M=e[6],N=e[7],O=e[8],T=e[9],C=e[10],A=e[11],P=e[12],R=e[13],D=e[14],L=e[15];return Math.abs(n-y)<=S*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-b)<=S*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-x)<=S*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(o-E)<=S*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(a-w)<=S*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-k)<=S*Math.max(1,Math.abs(s),Math.abs(k))&&Math.abs(l-M)<=S*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(u-N)<=S*Math.max(1,Math.abs(u),Math.abs(N))&&Math.abs(c-O)<=S*Math.max(1,Math.abs(c),Math.abs(O))&&Math.abs(h-T)<=S*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(d-C)<=S*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(f-A)<=S*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(p-P)<=S*Math.max(1,Math.abs(p),Math.abs(P))&&Math.abs(g-R)<=S*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(v-D)<=S*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(m-L)<=S*Math.max(1,Math.abs(m),Math.abs(L))},exactEquals:st,frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},fromQuat:J,fromQuat2:function(t,e){var n=new N(3),r=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=r*r+i*i+o*o+a*a;return h>0?(n[0]=2*(s*a+c*r+l*o-u*i)/h,n[1]=2*(l*a+c*i+u*r-s*o)/h,n[2]=2*(u*a+c*o+s*i-l*r)/h):(n[0]=2*(s*a+c*r+l*o-u*i),n[1]=2*(l*a+c*i+u*r-s*o),n[2]=2*(u*a+c*o+s*i-l*r)),q(t,e,n),t},fromRotation:H,fromRotationTranslation:q,fromRotationTranslationScale:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=e[3],l=i+i,u=o+o,c=a+a,h=i*l,d=i*u,f=i*c,p=o*u,g=o*c,v=a*c,m=s*l,y=s*u,b=s*c,x=r[0],E=r[1],w=r[2];return t[0]=(1-(p+v))*x,t[1]=(d+b)*x,t[2]=(f-y)*x,t[3]=0,t[4]=(d-b)*E,t[5]=(1-(h+v))*E,t[6]=(g+m)*E,t[7]=0,t[8]=(f+y)*w,t[9]=(g-m)*w,t[10]=(1-(h+p))*w,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:Q,fromScaling:W,fromTranslation:V,fromValues:P,fromXRotation:U,fromYRotation:$,fromZRotation:Y,frustum:function(t,e,n,r,i,o,a){var s=1/(n-e),l=1/(i-r),u=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*l,t[6]=0,t[7]=0,t[8]=(n+e)*s,t[9]=(i+r)*l,t[10]=(a+o)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*u,t[15]=0,t},getRotation:Z,getScaling:K,getTranslation:X,identity:D,invert:_,lookAt:ot,mul:lt,multiply:j,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:rt,orthoNO:nt,orthoZO:it,perspective:et,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),l=2/(a+s),u=2/(i+o);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=-(a-s)*l*.5,t[9]=(i-o)*u*.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:tt,perspectiveZO:function(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,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?(o=1/(r-i),t[10]=i*o,t[14]=i*r*o):(t[10]=-1,t[14]=-r),t},rotate:function(t,e,n,r){var i,o,a,s,l,u,c,h,d,f,p,g,v,m,y,b,x,E,w,k,M,N,O,T,C=r[0],A=r[1],P=r[2],R=Math.hypot(C,A,P);return R<S?null:(C*=R=1/R,A*=R,P*=R,i=Math.sin(n),a=1-(o=Math.cos(n)),s=e[0],l=e[1],u=e[2],c=e[3],h=e[4],d=e[5],f=e[6],p=e[7],g=e[8],v=e[9],m=e[10],y=e[11],b=C*C*a+o,x=A*C*a+P*i,E=P*C*a-A*i,w=C*A*a-P*i,k=A*A*a+o,M=P*A*a+C*i,N=C*P*a+A*i,O=A*P*a-C*i,T=P*P*a+o,t[0]=s*b+h*x+g*E,t[1]=l*b+d*x+v*E,t[2]=u*b+f*x+m*E,t[3]=c*b+p*x+y*E,t[4]=s*w+h*k+g*M,t[5]=l*w+d*k+v*M,t[6]=u*w+f*k+m*M,t[7]=c*w+p*k+y*M,t[8]=s*N+h*O+g*T,t[9]=l*N+d*O+v*T,t[10]=u*N+f*O+m*T,t[11]=c*N+p*O+y*T,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},rotateX:z,rotateY:G,rotateZ:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],l=e[3],u=e[4],c=e[5],h=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+u*r,t[1]=a*i+c*r,t[2]=s*i+h*r,t[3]=l*i+d*r,t[4]=u*i-o*r,t[5]=c*i-a*r,t[6]=h*i-s*r,t[7]=d*i-l*r,t},scale:F,set:R,str:function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},sub:ut,subtract:at,targetTo:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=r[0],l=r[1],u=r[2],c=i-n[0],h=o-n[1],d=a-n[2],f=c*c+h*h+d*d;f>0&&(c*=f=1/Math.sqrt(f),h*=f,d*=f);var p=l*d-u*h,g=u*c-s*d,v=s*h-l*c;return(f=p*p+g*g+v*v)>0&&(p*=f=1/Math.sqrt(f),g*=f,v*=f),t[0]=p,t[1]=g,t[2]=v,t[3]=0,t[4]=h*v-d*g,t[5]=d*p-c*v,t[6]=c*g-h*p,t[7]=0,t[8]=c,t[9]=h,t[10]=d,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t},translate:B,transpose:L});function ht(){var t=new N(3);return N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function dt(t){var e=new N(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ft(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function pt(t,e,n){var r=new N(3);return r[0]=t,r[1]=e,r[2]=n,r}function gt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function vt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function mt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function yt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function bt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function xt(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 Et(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function wt(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],l=n[2];return t[0]=i*l-o*s,t[1]=o*a-r*l,t[2]=r*s-i*a,t}function kt(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 Mt(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 St(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)<=S*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=S*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=S*Math.max(1,Math.abs(i),Math.abs(s))}var Nt=yt,Ot=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.hypot(n,r,i)},Tt=ft;function Ct(){var t=new N(4);return N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function At(t,e,n,r){var i=new N(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i}function Pt(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 Rt(){var t=new N(4);return N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Dt(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 Lt(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=n[0],l=n[1],u=n[2],c=n[3];return t[0]=r*c+a*s+i*u-o*l,t[1]=i*c+a*l+o*s-r*u,t[2]=o*c+a*u+r*l-i*s,t[3]=a*c-r*s-i*l-o*u,t}function _t(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 It(t,e,n,r){var i=.5*Math.PI/180;e*=i,n*=i,r*=i;var o=Math.sin(e),a=Math.cos(e),s=Math.sin(n),l=Math.cos(n),u=Math.sin(r),c=Math.cos(r);return t[0]=o*l*c-a*s*u,t[1]=a*s*c+o*l*u,t[2]=a*l*u-o*s*c,t[3]=a*l*c+o*s*u,t}ht(),function(){var t=Ct()}();var jt=At,Bt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Ft=function(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t},zt=Lt,Gt=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 Vt(){var t=new N(2);return N!=Float32Array&&(t[0]=0,t[1]=0),t}ht(),pt(1,0,0),pt(0,1,0),Rt(),Rt(),O(),function(){var t=Vt()}();var Wt=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Ht=function(t,e){return void 0===e&&(e=[]),function(t,e){if(!Wt(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n}(t,(function(t){return!function(t,e){return!!Wt(t)&&t.indexOf(e)>-1}(e,t)}))};function Ut(t){return"function"==typeof t}function $t(t){return null==t}function Yt(t){return Array.isArray(t)}var qt=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Xt(t,e){if(t)if(Yt(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(qt(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var Kt=function(t){return"object"==typeof t&&null!==t},Zt={}.toString,Qt=function(t,e){return Zt.call(t)==="[object "+e+"]"},Jt=function(t){if(!Kt(t)||!Qt(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 te(t){if(!Array.isArray(t))return-1/0;var e=t.length;if(!e)return-1/0;for(var n=t[0],r=1;r<e;r++)n=Math.max(n,t[r]);return n}var ee=function(t){if(Yt(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])};function ne(t){return"string"==typeof t}var re=Object.prototype.hasOwnProperty;function ie(t,e){if(!e||!Yt(t))return{};for(var n,r={},i=Ut(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),re.call(r,n)?r[n].push(a):r[n]=[a]}return r}var oe=function(t,e,n){return t<e?e:t>n?n:t};function ae(t){return"number"==typeof t}function se(t,e,n){return void 0===n&&(n=1e-5),t===e||Math.abs(t-e)<n}var le=function(t,e){if(Yt(t)){for(var n,r=-1/0,i=0;i<t.length;i++){var o=t[i],a=Ut(e)?e(o):o[e];a>r&&(n=o,r=a)}return n}},ue=function(t,e){if(Yt(t)){for(var n,r=1/0,i=0;i<t.length;i++){var o=t[i],a=Ut(e)?e(o):o[e];a<r&&(n=o,r=a)}return n}},ce=function(t,e){return(t%e+e)%e},he=function(t){return $t(t)?"":t.toString()};var de=function(t){var e=he(t);return e.charAt(0).toUpperCase()+e.substring(1)},fe={}.toString,pe=function(t){return Qt(t,"Boolean")};var ge=Object.prototype,ve=function(t){return void 0===t},me=function(t){if("object"!=typeof t||null===t)return t;var e;if(Yt(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=me(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=me(t[i]):e[i]=t[i];return e};function ye(t,e,n){var r;return function(){var n=this,i=arguments;clearTimeout(r),r=setTimeout((function(){r=null,t.apply(n,i)}),e)}}var be=new Map;function xe(t,e,n){void 0===n&&(n=128);return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0];be.has(t)||be.set(t,function(t){var e,n,r,i=t||1;function o(t,o){++e>i&&(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=be.get(t);if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s}}function Ee(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(Ee(e,i)){var o=e[i];null!==o&&Jt(o)?(Jt(t[i])||(t[i]={}),n<r?we(t[i],o,n+1,r):t[i]=e[i]):Yt(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var ke=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)we(t,e[r]);return t},Me=Object.prototype.hasOwnProperty;function Se(t){if($t(t))return!0;if(Wt(t))return!t.length;var e=function(t){return fe.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||ge)}(t))return!Object.keys(t).length;for(var n in t)if(Me.call(t,n))return!1;return!0}var Ne=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(ne(t)||ne(e))return!1;if(Wt(t)||Wt(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=Ne(t[r],e[r]));r++);return n}if(Kt(t)||Kt(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=Ne(t[i[r]],e[i[r]]));r++);return n}return!1},Oe=function(t,e,n){for(var r=0,i=ne(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},Te=function(t,e,n){var r=t,i=ne(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(qt(r[t])||(r[t]=ae(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},Ce=Object.prototype.hasOwnProperty,Ae=function(t,e){if(null===t||!Jt(t))return{};var n={};return Xt(e,(function(e){Ce.call(t,e)&&(n[e]=t[e])})),n},Pe=function(t,e){return function(t,e,n){if(!Yt(t)&&!Jt(t))return t;var r=n;return Xt(t,(function(t,n){r=e(r,t,n)})),r}(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},Re=function(t,e,n){var r,i,o,a,s=0;n||(n={});var l=function(){s=!1===n.leading?0:Date.now(),r=null,a=t.apply(i,o),r||(i=o=null)},u=function(){var u=Date.now();s||!1!==n.leading||(s=u);var c=e-(u-s);return i=this,o=arguments,c<=0||c>e?(r&&(clearTimeout(r),r=null),s=u,a=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(l,c)),a};return u.cancel=function(){clearTimeout(r),s=0,r=i=o=null},u},De={},Le=function(){},_e=function(t){return t},Ie=function(t,e){return Ie=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])},Ie(t,e)};function je(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}Ie(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var Be=function(){return Be=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Be.apply(this,arguments)};function Fe(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<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function ze(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}l((r=r.apply(t,e||[])).next())}))}function Ge(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=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 Ve(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 We(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function He(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;var Ue={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function $e(t,e,n){if(t[n].length>7){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 Ye={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function qe(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return Ye[e]===t.length-1&&"achlmqstvz".includes(e)}))}function Xe(t){return qe(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function Ke(t){return Xe(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function Ze(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=Ye[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,Ye[n]))),Ye[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 Je(t){return t>=48&&t<=57||43===t||45===t||46===t}function tn(t){return t>=48&&t<=57}function en(t){var e,n=t.max,r=t.pathValue,i=t.index,o=i,a=!1,s=!1,l=!1,u=!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)),tn(e)||46===e){if(46!==e){if(a=48===e,o+=1,e=r.charCodeAt(o),a&&o<n&&e&&tn(e))return void(t.err="[path-util]: Invalid path value at index ".concat(i,', "').concat(r[i],'" illegal number'));for(;o<n&&tn(r.charCodeAt(o));)o+=1,s=!0;e=r.charCodeAt(o)}if(46===e){for(u=!0,o+=1;tn(r.charCodeAt(o));)o+=1,l=!0;e=r.charCodeAt(o)}if(101===e||69===e){if(u&&!s&&!l)return void(t.err="[path-util]: Invalid path value at index ".concat(o,', "').concat(r[o],'" invalid float exponent'));if(o+=1,43!==(e=r.charCodeAt(o))&&45!==e||(o+=1),!(o<n&&tn(r.charCodeAt(o))))return void(t.err="[path-util]: Invalid path value at index ".concat(o,', "').concat(r[o],'" invalid integer exponent'));for(;o<n&&tn(r.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="[path-util]: Invalid path value at index ".concat(o,', "').concat(r[o],'" is not a number')}function nn(t){for(var e,n=t.pathValue,r=t.max;t.index<r&&(10===(e=n.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e));)t.index+=1}function rn(t){var e=t.max,n=t.pathValue,r=t.index,i=n.charCodeAt(r),o=Ye[n[r].toLowerCase()];if(t.segmentStart=r,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(i))if(t.index+=1,nn(t),t.data=[],o){for(;;){for(var a=o;a>0;a-=1){if(97!=(32|i)||3!==a&&4!==a?en(t):Qe(t),t.err.length)return;t.data.push(t.param),nn(t),t.index<e&&44===n.charCodeAt(t.index)&&(t.index+=1,nn(t))}if(t.index>=t.max)break;if(!Je(n.charCodeAt(t.index)))break}Ze(t)}else Ze(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(Xe(t))return[].concat(t);var e=function(t){if(qe(t))return[].concat(t);var e=new on(t);for(nn(e);e.index<e.max&&!e.err.length;)rn(e);return e.err?e.err:e.segments}(t),n=0,r=0,i=0,o=0;return e.map((function(t){var e,a=t.slice(1).map(Number),s=t[0],l=s.toUpperCase();if("M"===s)return n=a[0],r=a[1],i=n,o=r,["M",n,r];if(s!==l)switch(l){case"A":e=[l,a[0],a[1],a[2],a[3],a[4],a[5]+n,a[6]+r];break;case"V":e=[l,a[0]+r];break;case"H":e=[l,a[0]+n];break;default:var u=a.map((function(t,e){return t+(e%2?r:n)}));e=[l].concat(u)}else e=[l].concat(a);var c=e.length;switch(l){case"Z":n=i,r=o;break;case"H":n=e[1];break;case"V":r=e[1];break;default:n=e[c-2],r=e[c-1],"M"===l&&(i=n,o=r)}return e}))}function sn(t,e){var n=t[0],r=e.x1,i=e.y1,o=e.x2,a=e.y2,s=t.slice(1).map(Number),l=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)l=["L",t[1],i];else if("V"===n)l=["L",r,t[1]];else if("S"===n){var u=2*r-o,c=2*i-a;e.x1=u,e.y1=c,l=["C",u,c].concat(s)}else if("T"===n){var h=2*r-e.qx,d=2*i-e.qy;e.qx=h,e.qy=d,l=["Q",h,d].concat(s)}else if("Q"===n){var f=s[0],p=s[1];e.qx=f,e.qy=p}return l}function ln(t){if(Ke(t))return[].concat(t);for(var e=an(t),n=Be({},Ue),r=0;r<e.length;r+=1){e[r]=sn(e[r],n);var i=e[r],o=i.length;n.x1=+i[o-2],n.y1=+i[o-1],n.x2=+i[o-4]||n.x1,n.y2=+i[o-3]||n.y1}return e}function un(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function cn(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,p,g=t,v=e,m=n,y=r,b=s,x=l,E=120*Math.PI/180,w=Math.PI/180*(+i||0),k=[];if(u)h=u[0],d=u[1],f=u[2],p=u[3];else{g=(c=un(g,v,-w)).x,v=c.y;var M=(g-(b=(c=un(b,x,-w)).x))/2,S=(v-(x=c.y))/2,N=M*M/(m*m)+S*S/(y*y);N>1&&(m*=N=Math.sqrt(N),y*=N);var O=m*m,T=y*y,C=(o===a?-1:1)*Math.sqrt(Math.abs((O*T-O*S*S-T*M*M)/(O*S*S+T*M*M)));f=C*m*S/y+(g+b)/2,p=C*-y*M/m+(v+x)/2,h=Math.asin(((v-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),d=Math.asin(((x-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),h=g<f?Math.PI-h:h,d=b<f?Math.PI-d:d,h<0&&(h=2*Math.PI+h),d<0&&(d=2*Math.PI+d),a&&h>d&&(h-=2*Math.PI),!a&&d>h&&(d-=2*Math.PI)}var A=d-h;if(Math.abs(A)>E){var P=d,R=b,D=x;d=h+E*(a&&d>h?1:-1),k=cn(b=f+m*Math.cos(d),x=p+y*Math.sin(d),m,y,i,0,a,R,D,[d,P,f,p])}A=d-h;var L=Math.cos(h),_=Math.sin(h),I=Math.cos(d),j=Math.sin(d),B=Math.tan(A/4),F=4/3*m*B,z=4/3*y*B,G=[g,v],V=[g+F*_,v-z*L],W=[b+F*j,x-z*I],H=[b,x];if(V[0]=2*G[0]-V[0],V[1]=2*G[1]-V[1],u)return V.concat(W,H,k);for(var U=[],$=0,Y=(k=V.concat(W,H,k)).length;$<Y;$+=1)U[$]=$%2?un(k[$-1],k[$],w).y:un(k[$],k[$+1],w).x;return U}function hn(t,e,n){var r=t[0],i=t[1];return[r+(e[0]-r)*n,i+(e[1]-i)*n]}var dn=function(t,e,n,r){return We(We([],hn([t,e],[n,r],.5),!0),[n,r,n,r],!1)};function fn(t,e){var n,r,i,o,a,s,l,u,c,h=t[0],d=t.slice(1).map(Number),f=d[0],p=d[1],g=e.x1,v=e.y1,m=e.x,y=e.y;switch("TQ".includes(h)||(e.qx=null,e.qy=null),h){case"M":return e.x=f,e.y=p,t;case"A":return n=[g,v].concat(d),["C"].concat(cn(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9]));case"Q":return e.qx=f,e.qy=p,n=[g,v].concat(d),["C"].concat((r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],[(u=1/3)*r+(c=2/3)*o,u*i+c*a,u*s+c*o,u*l+c*a,s,l]));case"L":return["C"].concat(dn(g,v,f,p));case"Z":return g===m&&v===y?["C",g,v,m,y,m,y]:["C"].concat(dn(g,v,m,y))}return t}function pn(t,e){if(void 0===e&&(e=!1),function(t){return Ke(t)&&t.every((function(t){var e=t[0];return"MC".includes(e)}))}(t)){var n=[].concat(t);return e?[n,[]]:n}for(var r,i,o=ln(t),a=Be({},Ue),s=[],l="",u=o.length,c=[],h=0;h<u;h+=1){o[h]&&(l=o[h][0]),s[h]=l;var d=fn(o[h],a);o[h]=d,$e(o,s,h),u=o.length,"Z"===l&&c.push(h),i=(r=o[h]).length,a.x1=+r[i-2],a.y1=+r[i-1],a.x2=+r[i-4]||a.x1,a.y2=+r[i-3]||a.y1}return e?[o,c]:o}function gn(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function vn(t,e,n,r,i){var o=gn([t,e],[n,r]),a={x:0,y:0};if("number"==typeof i)if(i<=0)a={x:t,y:e};else if(i>=o)a={x:n,y:r};else{var s=hn([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 mn(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 yn(t,e,n,r,i,o,a,s,l,u){var c=Math.abs,h=Math.sin,d=Math.cos,f=Math.sqrt,p=Math.PI,g=c(n),v=c(r),m=(i%360+360)%360*(p/180);if(t===s&&e===l)return{x:t,y:e};if(0===g||0===v)return vn(t,e,s,l,u).point;var y=(t-s)/2,b=(e-l)/2,x={x:d(m)*y+h(m)*b,y:-h(m)*y+d(m)*b},E=Math.pow(x.x,2)/Math.pow(g,2)+Math.pow(x.y,2)/Math.pow(v,2);E>1&&(g*=f(E),v*=f(E));var w=(Math.pow(g,2)*Math.pow(v,2)-Math.pow(g,2)*Math.pow(x.y,2)-Math.pow(v,2)*Math.pow(x.x,2))/(Math.pow(g,2)*Math.pow(x.y,2)+Math.pow(v,2)*Math.pow(x.x,2)),k=(o!==a?1:-1)*f(w=w<0?0:w),M=k*(g*x.y/v),S=k*(-v*x.x/g),N=d(m)*M-h(m)*S+(t+s)/2,O=h(m)*M+d(m)*S+(e+l)/2,T={x:(x.x-M)/g,y:(x.y-S)/v},C=mn({x:1,y:0},T),A=mn(T,{x:(-x.x-M)/g,y:(-x.y-S)/v});!a&&A>0?A-=2*p:a&&A<0&&(A+=2*p);var P=C+(A%=2*p)*u,R=g*d(P),D=v*h(P);return{x:d(m)*R-h(m)*D+N,y:h(m)*R+d(m)*D+O}}function bn(t,e,n,r,i,o,a,s,l,u,c){var h,d=c.bbox,f=void 0===d||d,p=c.length,g=void 0===p||p,v=c.sampleSize,m=void 0===v?30:v,y="number"==typeof u,b=t,x=e,E=0,w=[b,x,E],k=[b,x],M={x:0,y:0},S=[{x:b,y:x}];y&&u<=0&&(M={x:b,y:x});for(var N=0;N<=m;N+=1){if(b=(h=yn(t,e,n,r,i,o,a,s,l,N/m)).x,x=h.y,f&&S.push({x:b,y:x}),g&&(E+=gn(k,[b,x])),k=[b,x],y&&E>=u&&u>w[2]){var O=(E-u)/(E-w[2]);M={x:k[0]*(1-O)+w[0]*O,y:k[1]*(1-O)+w[1]*O}}w=[b,x,E]}return y&&u>=E&&(M={x:s,y:l}),{length:E,point:M,min:{x:Math.min.apply(null,S.map((function(t){return t.x}))),y:Math.min.apply(null,S.map((function(t){return t.y})))},max:{x:Math.max.apply(null,S.map((function(t){return t.x}))),y:Math.max.apply(null,S.map((function(t){return t.y})))}}}function xn(t,e,n,r,i,o,a,s,l){var u=1-l;return{x:Math.pow(u,3)*t+3*Math.pow(u,2)*l*n+3*u*Math.pow(l,2)*i+Math.pow(l,3)*a,y:Math.pow(u,3)*e+3*Math.pow(u,2)*l*r+3*u*Math.pow(l,2)*o+Math.pow(l,3)*s}}function En(t,e,n,r,i,o,a,s,l,u){var c,h=u.bbox,d=void 0===h||h,f=u.length,p=void 0===f||f,g=u.sampleSize,v=void 0===g?10:g,m="number"==typeof l,y=t,b=e,x=0,E=[y,b,x],w=[y,b],k={x:0,y:0},M=[{x:y,y:b}];m&&l<=0&&(k={x:y,y:b});for(var S=0;S<=v;S+=1){if(y=(c=xn(t,e,n,r,i,o,a,s,S/v)).x,b=c.y,d&&M.push({x:y,y:b}),p&&(x+=gn(w,[y,b])),w=[y,b],m&&x>=l&&l>E[2]){var N=(x-l)/(x-E[2]);k={x:w[0]*(1-N)+E[0]*N,y:w[1]*(1-N)+E[1]*N}}E=[y,b,x]}return m&&l>=x&&(k={x:a,y:s}),{length:x,point:k,min:{x:Math.min.apply(null,M.map((function(t){return t.x}))),y:Math.min.apply(null,M.map((function(t){return t.y})))},max:{x:Math.max.apply(null,M.map((function(t){return t.x}))),y:Math.max.apply(null,M.map((function(t){return t.y})))}}}function wn(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 kn(t,e,n,r,i,o,a,s){var l,u=s.bbox,c=void 0===u||u,h=s.length,d=void 0===h||h,f=s.sampleSize,p=void 0===f?10:f,g="number"==typeof a,v=t,m=e,y=0,b=[v,m,y],x=[v,m],E={x:0,y:0},w=[{x:v,y:m}];g&&a<=0&&(E={x:v,y:m});for(var k=0;k<=p;k+=1){if(v=(l=wn(t,e,n,r,i,o,k/p)).x,m=l.y,c&&w.push({x:v,y:m}),d&&(y+=gn(x,[v,m])),x=[v,m],g&&y>=a&&a>b[2]){var M=(y-a)/(y-b[2]);E={x:x[0]*(1-M)+b[0]*M,y:x[1]*(1-M)+b[1]*M}}b=[v,m,y]}return g&&a>=y&&(E={x:i,y:o}),{length:y,point:E,min:{x:Math.min.apply(null,w.map((function(t){return t.x}))),y:Math.min.apply(null,w.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 Mn(t,e,n){for(var r,i,o,a,s,l,u,c,h,d=ln(t),f="number"==typeof e,p=[],g=0,v=0,m=0,y=0,b=[],x=[],E=0,w={x:0,y:0},k=w,M=w,S=w,N=0,O=0,T=d.length;O<T;O+=1)p=(u="M"===(c=(h=d[O])[0]))?p:[g,v].concat(h.slice(1)),u?(k=w={x:m=h[1],y:y=h[2]},E=0,f&&e<.001&&(S=w)):"L"===c?(E=(r=vn(p[0],p[1],p[2],p[3],(e||0)-N)).length,w=r.min,k=r.max,M=r.point):"A"===c?(E=(i=bn(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],(e||0)-N,n||{})).length,w=i.min,k=i.max,M=i.point):"C"===c?(E=(o=En(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],(e||0)-N,n||{})).length,w=o.min,k=o.max,M=o.point):"Q"===c?(E=(a=kn(p[0],p[1],p[2],p[3],p[4],p[5],(e||0)-N,n||{})).length,w=a.min,k=a.max,M=a.point):"Z"===c&&(E=(s=vn((p=[g,v,m,y])[0],p[1],p[2],p[3],(e||0)-N)).length,w=s.min,k=s.max,M=s.point),f&&N<e&&N+E>=e&&(S=M),x.push(k),b.push(w),N+=E,g=(l="Z"!==c?h.slice(-2):[m,y])[0],v=l[1];return f&&e>=N&&(S={x:g,y:v}),{length:N,point:S,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,x.map((function(t){return t.x}))),y:Math.max.apply(null,x.map((function(t){return t.y})))}}}function Sn(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 Nn(t){return function(t){var e=0,n=0,r=0;return pn(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],l=o[2],u=o[3],c=o[4],h=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,l,u,c,h),i=t.slice(-2),e=i[0],n=i[1],r})).reduce((function(t,e){return t+e}),0)}(t)>=0}function On(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),i=e?En(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],{bbox:!1}).length:0;return{s:t,ss:e?i?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=hn(n,r,e),s=hn(r,i,e),l=hn(i,o,e),u=hn(a,s,e),c=hn(s,l,e),h=hn(u,c,e);return[["C"].concat(a,u,h),["C"].concat(c,l,o)]}(r):[t,t]:[t],l:i}}))}function Tn(t,e,n){var r=On(t),i=On(e),o=r.length,a=i.length,s=r.filter((function(t){return t.l})).length,l=i.filter((function(t){return t.l})).length,u=r.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/s||0,c=i.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/l||0,h=n||Math.max(o,a),d=[u,c],f=[h-o,h-a],p=0,g=[r,i].map((function(t,e){return t.l===h?t.map((function(t){return t.s})):t.map((function(t,n){return p=n&&f[e]&&t.l>=d[e],f[e]-=p?1:0,p?t.ss:[t.s]})).flat()}));return g[0].length===g[1].length?g:Tn(g[0],g[1],h)}function Cn(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}function An(){return An="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=f(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}},An.apply(null,arguments)}function Pn(t,e,n,r){var i=An(f(t.prototype),e,n);return"function"==typeof i?function(t){return i.apply(n,t)}:i}function Rn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function Dn(t,e){var n=Math.min.apply(Math,We([],Ve(t),!1)),r=Math.min.apply(Math,We([],Ve(e),!1));return{x:n,y:r,width:Math.max.apply(Math,We([],Ve(t),!1))-n,height:Math.max.apply(Math,We([],Ve(e),!1))-r}}function Ln(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function _n(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function In(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),l=1/0,u=-1/0,c=[o,a],h=2*-Math.PI;h<=2*Math.PI;h+=Math.PI){var d=s+h;o<a?o<d&&d<a&&c.push(d):a<d&&d<o&&c.push(d)}for(h=0;h<c.length;h++){var f=Ln(t,0,n,r,i,c[h]);f<l&&(l=f),f>u&&(u=f)}var p=function(t,e,n){return Math.atan(e/(t*Math.tan(n)))}(n,r,i),g=1/0,v=-1/0,m=[o,a];for(h=2*-Math.PI;h<=2*Math.PI;h+=Math.PI){var y=p+h;o<a?o<y&&y<a&&m.push(y):a<y&&y<o&&m.push(y)}for(h=0;h<m.length;h++){var b=_n(0,e,n,r,i,m[h]);b<g&&(g=b),b>v&&(v=b)}return{x:l,y:g,width:u-l,height:v-g}}function jn(t,e,n,r,i,o){var a=-1,s=1/0,l=[n,r],u=20;o&&o>200&&(u=o/10);for(var c=1/u,h=c/10,d=0;d<=u;d++){var f=d*c,p=[i.apply(void 0,We([],Ve(t.concat([f])),!1)),i.apply(void 0,We([],Ve(e.concat([f])),!1))];(y=Rn(l[0],l[1],p[0],p[1]))<s&&(a=f,s=y)}if(0===a)return{x:t[0],y:e[0]};if(1===a){var g=t.length;return{x:t[g-1],y:e[g-1]}}s=1/0;for(d=0;d<32&&!(h<1e-4);d++){var v=a-h,m=a+h,y=(p=[i.apply(void 0,We([],Ve(t.concat([v])),!1)),i.apply(void 0,We([],Ve(e.concat([v])),!1))],Rn(l[0],l[1],p[0],p[1]));if(v>=0&&y<s)a=v,s=y;else{var b=[i.apply(void 0,We([],Ve(t.concat([m])),!1)),i.apply(void 0,We([],Ve(e.concat([m])),!1))],x=Rn(l[0],l[1],b[0],b[1]);m<=1&&x<s?(a=m,s=x):h*=.5}}return{x:i.apply(void 0,We([],Ve(t.concat([a])),!1)),y:i.apply(void 0,We([],Ve(e.concat([a])),!1))}}function Bn(t,e,n,r){return Rn(t,e,n,r)}function Fn(t,e,n,r,i){return{x:(1-i)*t+i*n,y:(1-i)*e+i*r}}function zn(t,e,n,r,i,o){var a=[n-t,r-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(a,[0,0]))return Math.sqrt((i-t)*(i-t)+(o-e)*(o-e));var s=[-a[1],a[0]];!function(t,e){var n=e[0],r=e[1],i=n*n+r*r;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s);var l=[i-t,o-e];return Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}(l,s))}function Gn(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 Vn(t,e,n,r){var i,o,a,s=-3*t+9*e-9*n+3*r,l=6*t-12*e+6*n,u=3*e-3*t,c=[];if(se(s,0))se(l,0)||(i=-u/l)>=0&&i<=1&&c.push(i);else{var h=l*l-4*s*u;se(h,0)?c.push(-l/(2*s)):h>0&&(o=(-l-(a=Math.sqrt(h)))/(2*s),(i=(-l+a)/(2*s))>=0&&i<=1&&c.push(i),o>=0&&o<=1&&c.push(o))}return c}function Wn(t,e,n,r,i,o,a,s){for(var l=[t,a],u=[e,s],c=Vn(t,n,i,a),h=Vn(e,r,o,s),d=0;d<c.length;d++)l.push(Gn(t,n,i,a,c[d]));for(d=0;d<h.length;d++)u.push(Gn(e,r,o,s,h[d]));return Dn(l,u)}function Hn(t,e,n,r,i,o,a,s,l,u,c){var h=function(t,e,n,r,i,o,a,s,l,u,c){return jn([t,n,i,a],[e,r,o,s],l,u,Gn,c)}(t,e,n,r,i,o,a,s,l,u,c);return Rn(h.x,h.y,l,u)}function Un(t){return function(t){if(t.length<2)return 0;for(var e=0,n=0;n<t.length-1;n++){var r=t[n],i=t[n+1];e+=Rn(r[0],r[1],i[0],i[1])}return e}(t)}function $n(t,e,n,r){var i=1-r;return i*i*t+2*r*i*e+r*r*n}function Yn(t,e,n){var r=t+n-2*e;if(se(r,0))return[.5];var i=(t-e)/r;return i<=1&&i>=0?[i]:[]}function qn(t,e,n,r,i,o){var a=Yn(t,n,i)[0],s=Yn(e,r,o)[0],l=[t,i],u=[e,o];return void 0!==a&&l.push($n(t,n,i,a)),void 0!==s&&u.push($n(e,r,o,s)),Dn(l,u)}function Xn(t,e,n,r,i,o,a,s){var l=function(t,e,n,r,i,o,a,s){return jn([t,n,i],[e,r,o],a,s,$n)}(t,e,n,r,i,o,a,s);return Rn(l.x,l.y,a,s)}function Kn(){Kn=function(){return e};var t,e={},r=Object.prototype,i=r.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",l=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function h(t,e,n,r){var i=e&&e.prototype instanceof y?e:y,a=Object.create(i.prototype),s=new P(r||[]);return o(a,"_invoke",{value:O(t,n,s)}),a}function d(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var f="suspendedStart",p="suspendedYield",g="executing",v="completed",m={};function y(){}function b(){}function x(){}var E={};c(E,s,(function(){return this}));var w=Object.getPrototypeOf,k=w&&w(w(R([])));k&&k!==r&&i.call(k,s)&&(E=k);var M=x.prototype=y.prototype=Object.create(E);function S(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function N(t,e){function r(o,a,s,l){var u=d(t[o],t,a);if("throw"!==u.type){var c=u.arg,h=c.value;return h&&"object"==n(h)&&i.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,s,l)}),(function(t){r("throw",t,s,l)})):e.resolve(h).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,l)}))}l(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function O(e,n,r){var i=f;return function(o,a){if(i===g)throw Error("Generator is already running");if(i===v){if("throw"===o)throw a;return{value:t,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=T(s,r);if(l){if(l===m)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===f)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=g;var u=d(e,n,r);if("normal"===u.type){if(i=r.done?v:p,u.arg===m)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=v,r.method="throw",r.arg=u.arg)}}}function T(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var o=d(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,m;var a=o.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function A(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,a=function n(){for(;++o<e.length;)if(i.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return a.next=a}}throw new TypeError(n(e)+" is not iterable")}return b.prototype=x,o(M,"constructor",{value:x,configurable:!0}),o(x,"constructor",{value:b,configurable:!0}),b.displayName=c(x,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,c(t,u,"GeneratorFunction")),t.prototype=Object.create(M),t},e.awrap=function(t){return{__await:t}},S(N.prototype),c(N.prototype,l,(function(){return this})),e.AsyncIterator=N,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new N(h(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(M),c(M,u,"Generator"),c(M,s,(function(){return this})),c(M,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=R,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(r,i){return s.type="throw",s.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),u=i.call(a,"finallyLoc");if(l&&u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),A(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;A(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:R(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function Zn(t,e,n,r,i,o,a){try{var s=t[o](a),l=s.value}catch(t){return void n(t)}s.done?e(l):Promise.resolve(l).then(r,i)}function Qn(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){Zn(o,r,i,a,s,"next",t)}function s(t){Zn(o,r,i,a,s,"throw",t)}a(void 0)}))}}function Jn(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(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 tr(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<o.length;r++)n=o[r],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}
1
+ !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";var e="undefined"!=typeof document?document.currentScript:null;function n(t){return n="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},n(t)}function r(t){var e=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e);if("object"!=n(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==n(e)?e:e+""}function i(t,e,n){return(e=r(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(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 a(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,r(i.key),i)}}function u(t,e,n){return e&&l(t.prototype,e),n&&l(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function h(t,e){if(t){if("string"==typeof t)return c(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}function d(t){return function(t){if(Array.isArray(t))return c(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},f(t)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function g(t,e){if(e&&("object"==n(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function v(t,e,n){return e=f(e),g(t,p()?Reflect.construct(e,n||[],f(t).constructor):e.apply(t,n))}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}function y(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}function b(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,s=[],l=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=o.call(n)).done)&&(s.push(r.value),s.length!==e);l=!0);}catch(t){u=!0,i=t}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(t,e)||h(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function E(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function w(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){return this instanceof t?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}var k={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new i(r,o||t,a),l=n?n+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],s]:t._events[l].push(s):(t._events[l]=s,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),s.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},s.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,a=new Array(o);i<o;i++)a[i]=r[i].fn;return a},s.prototype.listenerCount=function(t){var e=n?n+t:t,r=this._events[e];return r?r.fn?1:r.length:0},s.prototype.emit=function(t,e,r,i,o,a){var s=n?n+t:t;if(!this._events[s])return!1;var l,u,c=this._events[s],h=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),h){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,r),!0;case 4:return c.fn.call(c.context,e,r,i),!0;case 5:return c.fn.call(c.context,e,r,i,o),!0;case 6:return c.fn.call(c.context,e,r,i,o,a),!0}for(u=1,l=new Array(h-1);u<h;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var d,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(t,c[u].fn,void 0,!0),h){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,e);break;case 3:c[u].fn.call(c[u].context,e,r);break;case 4:c[u].fn.call(c[u].context,e,r,i);break;default:if(!l)for(d=1,l=new Array(h-1);d<h;d++)l[d-1]=arguments[d];c[u].fn.apply(c[u].context,l)}}return!0},s.prototype.on=function(t,e,n){return o(this,t,e,n,!1)},s.prototype.once=function(t,e,n){return o(this,t,e,n,!0)},s.prototype.removeListener=function(t,e,r,i){var o=n?n+t:t;if(!this._events[o])return this;if(!e)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==e||i&&!s.once||r&&s.context!==r||a(this,o);else{for(var l=0,u=[],c=s.length;l<c;l++)(s[l].fn!==e||i&&!s[l].once||r&&s[l].context!==r)&&u.push(s[l]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(t){var e;return t?(e=n?n+t:t,this._events[e]&&a(this,e)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,t.exports=s}(k);var M=E(k.exports),S=1e-6,N="undefined"!=typeof Float32Array?Float32Array:Array;function O(){var t=new N(9);return N!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function T(){var t=new N(16);return N!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function C(t){var e=new N(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function A(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function P(t,e,n,r,i,o,a,s,l,u,c,h,d,f,p,g){var v=new N(16);return v[0]=t,v[1]=e,v[2]=n,v[3]=r,v[4]=i,v[5]=o,v[6]=a,v[7]=s,v[8]=l,v[9]=u,v[10]=c,v[11]=h,v[12]=d,v[13]=f,v[14]=p,v[15]=g,v}function R(t,e,n,r,i,o,a,s,l,u,c,h,d,f,p,g,v){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=l,t[8]=u,t[9]=c,t[10]=h,t[11]=d,t[12]=f,t[13]=p,t[14]=g,t[15]=v,t}function D(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function L(t,e){if(t===e){var n=e[1],r=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function _(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],m=e[15],y=n*s-r*a,b=n*l-i*a,x=n*u-o*a,E=r*l-i*s,w=r*u-o*s,k=i*u-o*l,M=c*g-h*p,S=c*v-d*p,N=c*m-f*p,O=h*v-d*g,T=h*m-f*g,C=d*m-f*v,A=y*C-b*T+x*O+E*N-w*S+k*M;return A?(A=1/A,t[0]=(s*C-l*T+u*O)*A,t[1]=(i*T-r*C-o*O)*A,t[2]=(g*k-v*w+m*E)*A,t[3]=(d*w-h*k-f*E)*A,t[4]=(l*N-a*C-u*S)*A,t[5]=(n*C-i*N+o*S)*A,t[6]=(v*x-p*k-m*b)*A,t[7]=(c*k-d*x+f*b)*A,t[8]=(a*T-s*N+u*M)*A,t[9]=(r*N-n*T-o*M)*A,t[10]=(p*w-g*x+m*y)*A,t[11]=(h*x-c*w-f*y)*A,t[12]=(s*S-a*O-l*M)*A,t[13]=(n*O-r*S+i*M)*A,t[14]=(g*b-p*E-v*y)*A,t[15]=(c*E-h*b+d*y)*A,t):null}function I(t){var e=t[0],n=t[1],r=t[2],i=t[3],o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],h=t[10],d=t[11],f=t[12],p=t[13],g=t[14],v=t[15];return(e*a-n*o)*(h*v-d*g)-(e*s-r*o)*(c*v-d*p)+(e*l-i*o)*(c*g-h*p)+(n*s-r*a)*(u*v-d*f)-(n*l-i*a)*(u*g-h*f)+(r*l-i*s)*(u*p-c*f)}function j(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],d=e[9],f=e[10],p=e[11],g=e[12],v=e[13],m=e[14],y=e[15],b=n[0],x=n[1],E=n[2],w=n[3];return t[0]=b*r+x*s+E*h+w*g,t[1]=b*i+x*l+E*d+w*v,t[2]=b*o+x*u+E*f+w*m,t[3]=b*a+x*c+E*p+w*y,b=n[4],x=n[5],E=n[6],w=n[7],t[4]=b*r+x*s+E*h+w*g,t[5]=b*i+x*l+E*d+w*v,t[6]=b*o+x*u+E*f+w*m,t[7]=b*a+x*c+E*p+w*y,b=n[8],x=n[9],E=n[10],w=n[11],t[8]=b*r+x*s+E*h+w*g,t[9]=b*i+x*l+E*d+w*v,t[10]=b*o+x*u+E*f+w*m,t[11]=b*a+x*c+E*p+w*y,b=n[12],x=n[13],E=n[14],w=n[15],t[12]=b*r+x*s+E*h+w*g,t[13]=b*i+x*l+E*d+w*v,t[14]=b*o+x*u+E*f+w*m,t[15]=b*a+x*c+E*p+w*y,t}function B(t,e,n){var r,i,o,a,s,l,u,c,h,d,f,p,g=n[0],v=n[1],m=n[2];return e===t?(t[12]=e[0]*g+e[4]*v+e[8]*m+e[12],t[13]=e[1]*g+e[5]*v+e[9]*m+e[13],t[14]=e[2]*g+e[6]*v+e[10]*m+e[14],t[15]=e[3]*g+e[7]*v+e[11]*m+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=e[8],d=e[9],f=e[10],p=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=d,t[10]=f,t[11]=p,t[12]=r*g+s*v+h*m+e[12],t[13]=i*g+l*v+d*m+e[13],t[14]=o*g+u*v+f*m+e[14],t[15]=a*g+c*v+p*m+e[15]),t}function F(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function z(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+u*r,t[5]=a*i+c*r,t[6]=s*i+h*r,t[7]=l*i+d*r,t[8]=u*i-o*r,t[9]=c*i-a*r,t[10]=h*i-s*r,t[11]=d*i-l*r,t}function G(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],l=e[3],u=e[8],c=e[9],h=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-u*r,t[1]=a*i-c*r,t[2]=s*i-h*r,t[3]=l*i-d*r,t[8]=o*r+u*i,t[9]=a*r+c*i,t[10]=s*r+h*i,t[11]=l*r+d*i,t}function V(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function W(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function H(t,e,n){var r,i,o,a=n[0],s=n[1],l=n[2],u=Math.hypot(a,s,l);return u<S?null:(a*=u=1/u,s*=u,l*=u,r=Math.sin(e),o=1-(i=Math.cos(e)),t[0]=a*a*o+i,t[1]=s*a*o+l*r,t[2]=l*a*o-s*r,t[3]=0,t[4]=a*s*o-l*r,t[5]=s*s*o+i,t[6]=l*s*o+a*r,t[7]=0,t[8]=a*l*o+s*r,t[9]=s*l*o-a*r,t[10]=l*l*o+i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function U(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=n,t[7]=0,t[8]=0,t[9]=-n,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function $(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=0,t[2]=-n,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=n,t[9]=0,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Y(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=0,t[4]=-n,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function q(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=r+r,l=i+i,u=o+o,c=r*s,h=r*l,d=r*u,f=i*l,p=i*u,g=o*u,v=a*s,m=a*l,y=a*u;return t[0]=1-(f+g),t[1]=h+y,t[2]=d-m,t[3]=0,t[4]=h-y,t[5]=1-(c+g),t[6]=p+v,t[7]=0,t[8]=d+m,t[9]=p-v,t[10]=1-(c+f),t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t}function X(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function K(t,e){var n=e[0],r=e[1],i=e[2],o=e[4],a=e[5],s=e[6],l=e[8],u=e[9],c=e[10];return t[0]=Math.hypot(n,r,i),t[1]=Math.hypot(o,a,s),t[2]=Math.hypot(l,u,c),t}function Z(t,e){var n=new N(3);K(n,e);var r=1/n[0],i=1/n[1],o=1/n[2],a=e[0]*r,s=e[1]*i,l=e[2]*o,u=e[4]*r,c=e[5]*i,h=e[6]*o,d=e[8]*r,f=e[9]*i,p=e[10]*o,g=a+c+p,v=0;return g>0?(v=2*Math.sqrt(g+1),t[3]=.25*v,t[0]=(h-f)/v,t[1]=(d-l)/v,t[2]=(s-u)/v):a>c&&a>p?(v=2*Math.sqrt(1+a-c-p),t[3]=(h-f)/v,t[0]=.25*v,t[1]=(s+u)/v,t[2]=(d+l)/v):c>p?(v=2*Math.sqrt(1+c-a-p),t[3]=(d-l)/v,t[0]=(s+u)/v,t[1]=.25*v,t[2]=(h+f)/v):(v=2*Math.sqrt(1+p-a-c),t[3]=(s-u)/v,t[0]=(d+l)/v,t[1]=(h+f)/v,t[2]=.25*v),t}function Q(t,e,n,r,i){var o=e[0],a=e[1],s=e[2],l=e[3],u=o+o,c=a+a,h=s+s,d=o*u,f=o*c,p=o*h,g=a*c,v=a*h,m=s*h,y=l*u,b=l*c,x=l*h,E=r[0],w=r[1],k=r[2],M=i[0],S=i[1],N=i[2],O=(1-(g+m))*E,T=(f+x)*E,C=(p-b)*E,A=(f-x)*w,P=(1-(d+m))*w,R=(v+y)*w,D=(p+b)*k,L=(v-y)*k,_=(1-(d+g))*k;return t[0]=O,t[1]=T,t[2]=C,t[3]=0,t[4]=A,t[5]=P,t[6]=R,t[7]=0,t[8]=D,t[9]=L,t[10]=_,t[11]=0,t[12]=n[0]+M-(O*M+A*S+D*N),t[13]=n[1]+S-(T*M+P*S+L*N),t[14]=n[2]+N-(C*M+R*S+_*N),t[15]=1,t}function J(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=n+n,s=r+r,l=i+i,u=n*a,c=r*a,h=r*s,d=i*a,f=i*s,p=i*l,g=o*a,v=o*s,m=o*l;return t[0]=1-h-p,t[1]=c+m,t[2]=d-v,t[3]=0,t[4]=c-m,t[5]=1-u-p,t[6]=f+g,t[7]=0,t[8]=d+v,t[9]=f-g,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function tt(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,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?(o=1/(r-i),t[10]=(i+r)*o,t[14]=2*i*r*o):(t[10]=-1,t[14]=-2*r),t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var et=tt;function nt(t,e,n,r,i,o,a){var s=1/(e-n),l=1/(r-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=(a+o)*u,t[15]=1,t}var rt=nt;function it(t,e,n,r,i,o,a){var s=1/(e-n),l=1/(r-i),u=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=u,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*l,t[14]=o*u,t[15]=1,t}function ot(t,e,n,r){var i,o,a,s,l,u,c,h,d,f,p=e[0],g=e[1],v=e[2],m=r[0],y=r[1],b=r[2],x=n[0],E=n[1],w=n[2];return Math.abs(p-x)<S&&Math.abs(g-E)<S&&Math.abs(v-w)<S?D(t):(c=p-x,h=g-E,d=v-w,i=y*(d*=f=1/Math.hypot(c,h,d))-b*(h*=f),o=b*(c*=f)-m*d,a=m*h-y*c,(f=Math.hypot(i,o,a))?(i*=f=1/f,o*=f,a*=f):(i=0,o=0,a=0),s=h*a-d*o,l=d*i-c*a,u=c*o-h*i,(f=Math.hypot(s,l,u))?(s*=f=1/f,l*=f,u*=f):(s=0,l=0,u=0),t[0]=i,t[1]=s,t[2]=c,t[3]=0,t[4]=o,t[5]=l,t[6]=h,t[7]=0,t[8]=a,t[9]=u,t[10]=d,t[11]=0,t[12]=-(i*p+o*g+a*v),t[13]=-(s*p+l*g+u*v),t[14]=-(c*p+h*g+d*v),t[15]=1,t)}function at(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t[9]=e[9]-n[9],t[10]=e[10]-n[10],t[11]=e[11]-n[11],t[12]=e[12]-n[12],t[13]=e[13]-n[13],t[14]=e[14]-n[14],t[15]=e[15]-n[15],t}function st(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}var lt=j,ut=at,ct=Object.freeze({__proto__:null,add:function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t[9]=e[9]+n[9],t[10]=e[10]+n[10],t[11]=e[11]+n[11],t[12]=e[12]+n[12],t[13]=e[13]+n[13],t[14]=e[14]+n[14],t[15]=e[15]+n[15],t},adjoint:function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],h=e[9],d=e[10],f=e[11],p=e[12],g=e[13],v=e[14],m=e[15];return t[0]=s*(d*m-f*v)-h*(l*m-u*v)+g*(l*f-u*d),t[1]=-(r*(d*m-f*v)-h*(i*m-o*v)+g*(i*f-o*d)),t[2]=r*(l*m-u*v)-s*(i*m-o*v)+g*(i*u-o*l),t[3]=-(r*(l*f-u*d)-s*(i*f-o*d)+h*(i*u-o*l)),t[4]=-(a*(d*m-f*v)-c*(l*m-u*v)+p*(l*f-u*d)),t[5]=n*(d*m-f*v)-c*(i*m-o*v)+p*(i*f-o*d),t[6]=-(n*(l*m-u*v)-a*(i*m-o*v)+p*(i*u-o*l)),t[7]=n*(l*f-u*d)-a*(i*f-o*d)+c*(i*u-o*l),t[8]=a*(h*m-f*g)-c*(s*m-u*g)+p*(s*f-u*h),t[9]=-(n*(h*m-f*g)-c*(r*m-o*g)+p*(r*f-o*h)),t[10]=n*(s*m-u*g)-a*(r*m-o*g)+p*(r*u-o*s),t[11]=-(n*(s*f-u*h)-a*(r*f-o*h)+c*(r*u-o*s)),t[12]=-(a*(h*v-d*g)-c*(s*v-l*g)+p*(s*d-l*h)),t[13]=n*(h*v-d*g)-c*(r*v-i*g)+p*(r*d-i*h),t[14]=-(n*(s*v-l*g)-a*(r*v-i*g)+p*(r*l-i*s)),t[15]=n*(s*d-l*h)-a*(r*d-i*h)+c*(r*l-i*s),t},clone:C,copy:A,create:T,determinant:I,equals:function(t,e){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],h=t[9],d=t[10],f=t[11],p=t[12],g=t[13],v=t[14],m=t[15],y=e[0],b=e[1],x=e[2],E=e[3],w=e[4],k=e[5],M=e[6],N=e[7],O=e[8],T=e[9],C=e[10],A=e[11],P=e[12],R=e[13],D=e[14],L=e[15];return Math.abs(n-y)<=S*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-b)<=S*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-x)<=S*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(o-E)<=S*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(a-w)<=S*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(s-k)<=S*Math.max(1,Math.abs(s),Math.abs(k))&&Math.abs(l-M)<=S*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(u-N)<=S*Math.max(1,Math.abs(u),Math.abs(N))&&Math.abs(c-O)<=S*Math.max(1,Math.abs(c),Math.abs(O))&&Math.abs(h-T)<=S*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(d-C)<=S*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(f-A)<=S*Math.max(1,Math.abs(f),Math.abs(A))&&Math.abs(p-P)<=S*Math.max(1,Math.abs(p),Math.abs(P))&&Math.abs(g-R)<=S*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(v-D)<=S*Math.max(1,Math.abs(v),Math.abs(D))&&Math.abs(m-L)<=S*Math.max(1,Math.abs(m),Math.abs(L))},exactEquals:st,frob:function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},fromQuat:J,fromQuat2:function(t,e){var n=new N(3),r=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],l=e[5],u=e[6],c=e[7],h=r*r+i*i+o*o+a*a;return h>0?(n[0]=2*(s*a+c*r+l*o-u*i)/h,n[1]=2*(l*a+c*i+u*r-s*o)/h,n[2]=2*(u*a+c*o+s*i-l*r)/h):(n[0]=2*(s*a+c*r+l*o-u*i),n[1]=2*(l*a+c*i+u*r-s*o),n[2]=2*(u*a+c*o+s*i-l*r)),q(t,e,n),t},fromRotation:H,fromRotationTranslation:q,fromRotationTranslationScale:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=e[3],l=i+i,u=o+o,c=a+a,h=i*l,d=i*u,f=i*c,p=o*u,g=o*c,v=a*c,m=s*l,y=s*u,b=s*c,x=r[0],E=r[1],w=r[2];return t[0]=(1-(p+v))*x,t[1]=(d+b)*x,t[2]=(f-y)*x,t[3]=0,t[4]=(d-b)*E,t[5]=(1-(h+v))*E,t[6]=(g+m)*E,t[7]=0,t[8]=(f+y)*w,t[9]=(g-m)*w,t[10]=(1-(h+p))*w,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},fromRotationTranslationScaleOrigin:Q,fromScaling:W,fromTranslation:V,fromValues:P,fromXRotation:U,fromYRotation:$,fromZRotation:Y,frustum:function(t,e,n,r,i,o,a){var s=1/(n-e),l=1/(i-r),u=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*l,t[6]=0,t[7]=0,t[8]=(n+e)*s,t[9]=(i+r)*l,t[10]=(a+o)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*u,t[15]=0,t},getRotation:Z,getScaling:K,getTranslation:X,identity:D,invert:_,lookAt:ot,mul:lt,multiply:j,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:rt,orthoNO:nt,orthoZO:it,perspective:et,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),l=2/(a+s),u=2/(i+o);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=-(a-s)*l*.5,t[9]=(i-o)*u*.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:tt,perspectiveZO:function(t,e,n,r,i){var o,a=1/Math.tan(e/2);return t[0]=a/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,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?(o=1/(r-i),t[10]=i*o,t[14]=i*r*o):(t[10]=-1,t[14]=-r),t},rotate:function(t,e,n,r){var i,o,a,s,l,u,c,h,d,f,p,g,v,m,y,b,x,E,w,k,M,N,O,T,C=r[0],A=r[1],P=r[2],R=Math.hypot(C,A,P);return R<S?null:(C*=R=1/R,A*=R,P*=R,i=Math.sin(n),a=1-(o=Math.cos(n)),s=e[0],l=e[1],u=e[2],c=e[3],h=e[4],d=e[5],f=e[6],p=e[7],g=e[8],v=e[9],m=e[10],y=e[11],b=C*C*a+o,x=A*C*a+P*i,E=P*C*a-A*i,w=C*A*a-P*i,k=A*A*a+o,M=P*A*a+C*i,N=C*P*a+A*i,O=A*P*a-C*i,T=P*P*a+o,t[0]=s*b+h*x+g*E,t[1]=l*b+d*x+v*E,t[2]=u*b+f*x+m*E,t[3]=c*b+p*x+y*E,t[4]=s*w+h*k+g*M,t[5]=l*w+d*k+v*M,t[6]=u*w+f*k+m*M,t[7]=c*w+p*k+y*M,t[8]=s*N+h*O+g*T,t[9]=l*N+d*O+v*T,t[10]=u*N+f*O+m*T,t[11]=c*N+p*O+y*T,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},rotateX:z,rotateY:G,rotateZ:function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],l=e[3],u=e[4],c=e[5],h=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+u*r,t[1]=a*i+c*r,t[2]=s*i+h*r,t[3]=l*i+d*r,t[4]=u*i-o*r,t[5]=c*i-a*r,t[6]=h*i-s*r,t[7]=d*i-l*r,t},scale:F,set:R,str:function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},sub:ut,subtract:at,targetTo:function(t,e,n,r){var i=e[0],o=e[1],a=e[2],s=r[0],l=r[1],u=r[2],c=i-n[0],h=o-n[1],d=a-n[2],f=c*c+h*h+d*d;f>0&&(c*=f=1/Math.sqrt(f),h*=f,d*=f);var p=l*d-u*h,g=u*c-s*d,v=s*h-l*c;return(f=p*p+g*g+v*v)>0&&(p*=f=1/Math.sqrt(f),g*=f,v*=f),t[0]=p,t[1]=g,t[2]=v,t[3]=0,t[4]=h*v-d*g,t[5]=d*p-c*v,t[6]=c*g-h*p,t[7]=0,t[8]=c,t[9]=h,t[10]=d,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t},translate:B,transpose:L});function ht(){var t=new N(3);return N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function dt(t){var e=new N(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ft(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function pt(t,e,n){var r=new N(3);return r[0]=t,r[1]=e,r[2]=n,r}function gt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function vt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function mt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function yt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function bt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function xt(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 Et(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function wt(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],l=n[2];return t[0]=i*l-o*s,t[1]=o*a-r*l,t[2]=r*s-i*a,t}function kt(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 Mt(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 St(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)<=S*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=S*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=S*Math.max(1,Math.abs(i),Math.abs(s))}var Nt=yt,Ot=function(t,e){var n=e[0]-t[0],r=e[1]-t[1],i=e[2]-t[2];return Math.hypot(n,r,i)},Tt=ft;function Ct(){var t=new N(4);return N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function At(t,e,n,r){var i=new N(4);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i}function Pt(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 Rt(){var t=new N(4);return N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Dt(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 Lt(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3],s=n[0],l=n[1],u=n[2],c=n[3];return t[0]=r*c+a*s+i*u-o*l,t[1]=i*c+a*l+o*s-r*u,t[2]=o*c+a*u+r*l-i*s,t[3]=a*c-r*s-i*l-o*u,t}function _t(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 It(t,e,n,r){var i=.5*Math.PI/180;e*=i,n*=i,r*=i;var o=Math.sin(e),a=Math.cos(e),s=Math.sin(n),l=Math.cos(n),u=Math.sin(r),c=Math.cos(r);return t[0]=o*l*c-a*s*u,t[1]=a*s*c+o*l*u,t[2]=a*l*u-o*s*c,t[3]=a*l*c+o*s*u,t}ht(),function(){var t=Ct()}();var jt=At,Bt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},Ft=function(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t},zt=Lt,Gt=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 Vt(){var t=new N(2);return N!=Float32Array&&(t[0]=0,t[1]=0),t}ht(),pt(1,0,0),pt(0,1,0),Rt(),Rt(),O(),function(){var t=Vt()}();var Wt=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},Ht=function(t,e){return void 0===e&&(e=[]),function(t,e){if(!Wt(t))return t;for(var n=[],r=0;r<t.length;r++){var i=t[r];e(i,r)&&n.push(i)}return n}(t,(function(t){return!function(t,e){return!!Wt(t)&&t.indexOf(e)>-1}(e,t)}))};function Ut(t){return"function"==typeof t}function $t(t){return null==t}function Yt(t){return Array.isArray(t)}var qt=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function Xt(t,e){if(t)if(Yt(t))for(var n=0,r=t.length;n<r&&!1!==e(t[n],n);n++);else if(qt(t))for(var i in t)if(t.hasOwnProperty(i)&&!1===e(t[i],i))break}var Kt=function(t){return"object"==typeof t&&null!==t},Zt={}.toString,Qt=function(t,e){return Zt.call(t)==="[object "+e+"]"},Jt=function(t){if(!Kt(t)||!Qt(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 te(t){if(!Array.isArray(t))return-1/0;var e=t.length;if(!e)return-1/0;for(var n=t[0],r=1;r<e;r++)n=Math.max(n,t[r]);return n}var ee=function(t){if(Yt(t))return t.reduce((function(t,e){return Math.min(t,e)}),t[0])};function ne(t){return"string"==typeof t}var re=Object.prototype.hasOwnProperty;function ie(t,e){if(!e||!Yt(t))return{};for(var n,r={},i=Ut(e)?e:function(t){return t[e]},o=0;o<t.length;o++){var a=t[o];n=i(a),re.call(r,n)?r[n].push(a):r[n]=[a]}return r}var oe=function(t,e,n){return t<e?e:t>n?n:t};function ae(t){return"number"==typeof t}function se(t,e,n){return void 0===n&&(n=1e-5),t===e||Math.abs(t-e)<n}var le=function(t,e){if(Yt(t)){for(var n,r=-1/0,i=0;i<t.length;i++){var o=t[i],a=Ut(e)?e(o):o[e];a>r&&(n=o,r=a)}return n}},ue=function(t,e){if(Yt(t)){for(var n,r=1/0,i=0;i<t.length;i++){var o=t[i],a=Ut(e)?e(o):o[e];a<r&&(n=o,r=a)}return n}},ce=function(t,e){return(t%e+e)%e},he=function(t){return $t(t)?"":t.toString()};var de=function(t){var e=he(t);return e.charAt(0).toUpperCase()+e.substring(1)},fe={}.toString,pe=function(t){return Qt(t,"Boolean")};var ge=Object.prototype,ve=function(t){return void 0===t},me=function(t){if("object"!=typeof t||null===t)return t;var e;if(Yt(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=me(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=me(t[i]):e[i]=t[i];return e};function ye(t,e,n){var r;return function(){var n=this,i=arguments;clearTimeout(r),r=setTimeout((function(){r=null,t.apply(n,i)}),e)}}var be=new Map;function xe(t,e,n){void 0===n&&(n=128);return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0];be.has(t)||be.set(t,function(t){var e,n,r,i=t||1;function o(t,o){++e>i&&(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=be.get(t);if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s}}function Ee(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(Ee(e,i)){var o=e[i];null!==o&&Jt(o)?(Jt(t[i])||(t[i]={}),n<r?we(t[i],o,n+1,r):t[i]=e[i]):Yt(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}var ke=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)we(t,e[r]);return t},Me=Object.prototype.hasOwnProperty;function Se(t){if($t(t))return!0;if(Wt(t))return!t.length;var e=function(t){return fe.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||ge)}(t))return!Object.keys(t).length;for(var n in t)if(Me.call(t,n))return!1;return!0}var Ne=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(ne(t)||ne(e))return!1;if(Wt(t)||Wt(e)){if(t.length!==e.length)return!1;for(var n=!0,r=0;r<t.length&&(n=Ne(t[r],e[r]));r++);return n}if(Kt(t)||Kt(e)){var i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(n=!0,r=0;r<i.length&&(n=Ne(t[i[r]],e[i[r]]));r++);return n}return!1},Oe=function(t,e,n){for(var r=0,i=ne(e)?e.split("."):e;t&&r<i.length;)t=t[i[r++]];return void 0===t||r<i.length?n:t},Te=function(t,e,n){var r=t,i=ne(e)?e.split("."):e;return i.forEach((function(t,e){e<i.length-1?(qt(r[t])||(r[t]=ae(i[e+1])?[]:{}),r=r[t]):r[t]=n})),t},Ce=Object.prototype.hasOwnProperty,Ae=function(t,e){if(null===t||!Jt(t))return{};var n={};return Xt(e,(function(e){Ce.call(t,e)&&(n[e]=t[e])})),n},Pe=function(t,e){return function(t,e,n){if(!Yt(t)&&!Jt(t))return t;var r=n;return Xt(t,(function(t,n){r=e(r,t,n)})),r}(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})},Re=function(t,e,n){var r,i,o,a,s=0;n||(n={});var l=function(){s=!1===n.leading?0:Date.now(),r=null,a=t.apply(i,o),r||(i=o=null)},u=function(){var u=Date.now();s||!1!==n.leading||(s=u);var c=e-(u-s);return i=this,o=arguments,c<=0||c>e?(r&&(clearTimeout(r),r=null),s=u,a=t.apply(i,o),r||(i=o=null)):r||!1===n.trailing||(r=setTimeout(l,c)),a};return u.cancel=function(){clearTimeout(r),s=0,r=i=o=null},u},De={},Le=function(){},_e=function(t){return t},Ie=function(t,e){return Ie=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])},Ie(t,e)};function je(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}Ie(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var Be=function(){return Be=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},Be.apply(this,arguments)};function Fe(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<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}function ze(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}l((r=r.apply(t,e||[])).next())}))}function Ge(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=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 Ve(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 We(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function He(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)}"function"==typeof SuppressedError&&SuppressedError;var Ue={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function $e(t,e,n){if(t[n].length>7){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 Ye={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function qe(t){return Array.isArray(t)&&t.every((function(t){var e=t[0].toLowerCase();return Ye[e]===t.length-1&&"achlmqstvz".includes(e)}))}function Xe(t){return qe(t)&&t.every((function(t){var e=t[0];return e===e.toUpperCase()}))}function Ke(t){return Xe(t)&&t.every((function(t){var e=t[0];return"ACLMQZ".includes(e)}))}function Ze(t){for(var e=t.pathValue[t.segmentStart],n=e.toLowerCase(),r=t.data;r.length>=Ye[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,Ye[n]))),Ye[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 Je(t){return t>=48&&t<=57||43===t||45===t||46===t}function tn(t){return t>=48&&t<=57}function en(t){var e,n=t.max,r=t.pathValue,i=t.index,o=i,a=!1,s=!1,l=!1,u=!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)),tn(e)||46===e){if(46!==e){if(a=48===e,o+=1,e=r.charCodeAt(o),a&&o<n&&e&&tn(e))return void(t.err="[path-util]: Invalid path value at index ".concat(i,', "').concat(r[i],'" illegal number'));for(;o<n&&tn(r.charCodeAt(o));)o+=1,s=!0;e=r.charCodeAt(o)}if(46===e){for(u=!0,o+=1;tn(r.charCodeAt(o));)o+=1,l=!0;e=r.charCodeAt(o)}if(101===e||69===e){if(u&&!s&&!l)return void(t.err="[path-util]: Invalid path value at index ".concat(o,', "').concat(r[o],'" invalid float exponent'));if(o+=1,43!==(e=r.charCodeAt(o))&&45!==e||(o+=1),!(o<n&&tn(r.charCodeAt(o))))return void(t.err="[path-util]: Invalid path value at index ".concat(o,', "').concat(r[o],'" invalid integer exponent'));for(;o<n&&tn(r.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="[path-util]: Invalid path value at index ".concat(o,', "').concat(r[o],'" is not a number')}function nn(t){for(var e,n=t.pathValue,r=t.max;t.index<r&&(10===(e=n.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e));)t.index+=1}function rn(t){var e=t.max,n=t.pathValue,r=t.index,i=n.charCodeAt(r),o=Ye[n[r].toLowerCase()];if(t.segmentStart=r,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(i))if(t.index+=1,nn(t),t.data=[],o){for(;;){for(var a=o;a>0;a-=1){if(97!=(32|i)||3!==a&&4!==a?en(t):Qe(t),t.err.length)return;t.data.push(t.param),nn(t),t.index<e&&44===n.charCodeAt(t.index)&&(t.index+=1,nn(t))}if(t.index>=t.max)break;if(!Je(n.charCodeAt(t.index)))break}Ze(t)}else Ze(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(Xe(t))return[].concat(t);var e=function(t){if(qe(t))return[].concat(t);var e=new on(t);for(nn(e);e.index<e.max&&!e.err.length;)rn(e);return e.err?e.err:e.segments}(t),n=0,r=0,i=0,o=0;return e.map((function(t){var e,a=t.slice(1).map(Number),s=t[0],l=s.toUpperCase();if("M"===s)return n=a[0],r=a[1],i=n,o=r,["M",n,r];if(s!==l)switch(l){case"A":e=[l,a[0],a[1],a[2],a[3],a[4],a[5]+n,a[6]+r];break;case"V":e=[l,a[0]+r];break;case"H":e=[l,a[0]+n];break;default:var u=a.map((function(t,e){return t+(e%2?r:n)}));e=[l].concat(u)}else e=[l].concat(a);var c=e.length;switch(l){case"Z":n=i,r=o;break;case"H":n=e[1];break;case"V":r=e[1];break;default:n=e[c-2],r=e[c-1],"M"===l&&(i=n,o=r)}return e}))}function sn(t,e){var n=t[0],r=e.x1,i=e.y1,o=e.x2,a=e.y2,s=t.slice(1).map(Number),l=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)l=["L",t[1],i];else if("V"===n)l=["L",r,t[1]];else if("S"===n){var u=2*r-o,c=2*i-a;e.x1=u,e.y1=c,l=["C",u,c].concat(s)}else if("T"===n){var h=2*r-e.qx,d=2*i-e.qy;e.qx=h,e.qy=d,l=["Q",h,d].concat(s)}else if("Q"===n){var f=s[0],p=s[1];e.qx=f,e.qy=p}return l}function ln(t){if(Ke(t))return[].concat(t);for(var e=an(t),n=Be({},Ue),r=0;r<e.length;r+=1){e[r]=sn(e[r],n);var i=e[r],o=i.length;n.x1=+i[o-2],n.y1=+i[o-1],n.x2=+i[o-4]||n.x1,n.y2=+i[o-3]||n.y1}return e}function un(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function cn(t,e,n,r,i,o,a,s,l,u){var c,h,d,f,p,g=t,v=e,m=n,y=r,b=s,x=l,E=120*Math.PI/180,w=Math.PI/180*(+i||0),k=[];if(u)h=u[0],d=u[1],f=u[2],p=u[3];else{g=(c=un(g,v,-w)).x,v=c.y;var M=(g-(b=(c=un(b,x,-w)).x))/2,S=(v-(x=c.y))/2,N=M*M/(m*m)+S*S/(y*y);N>1&&(m*=N=Math.sqrt(N),y*=N);var O=m*m,T=y*y,C=(o===a?-1:1)*Math.sqrt(Math.abs((O*T-O*S*S-T*M*M)/(O*S*S+T*M*M)));f=C*m*S/y+(g+b)/2,p=C*-y*M/m+(v+x)/2,h=Math.asin(((v-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),d=Math.asin(((x-p)/y*Math.pow(10,9)|0)/Math.pow(10,9)),h=g<f?Math.PI-h:h,d=b<f?Math.PI-d:d,h<0&&(h=2*Math.PI+h),d<0&&(d=2*Math.PI+d),a&&h>d&&(h-=2*Math.PI),!a&&d>h&&(d-=2*Math.PI)}var A=d-h;if(Math.abs(A)>E){var P=d,R=b,D=x;d=h+E*(a&&d>h?1:-1),k=cn(b=f+m*Math.cos(d),x=p+y*Math.sin(d),m,y,i,0,a,R,D,[d,P,f,p])}A=d-h;var L=Math.cos(h),_=Math.sin(h),I=Math.cos(d),j=Math.sin(d),B=Math.tan(A/4),F=4/3*m*B,z=4/3*y*B,G=[g,v],V=[g+F*_,v-z*L],W=[b+F*j,x-z*I],H=[b,x];if(V[0]=2*G[0]-V[0],V[1]=2*G[1]-V[1],u)return V.concat(W,H,k);for(var U=[],$=0,Y=(k=V.concat(W,H,k)).length;$<Y;$+=1)U[$]=$%2?un(k[$-1],k[$],w).y:un(k[$],k[$+1],w).x;return U}function hn(t,e,n){var r=t[0],i=t[1];return[r+(e[0]-r)*n,i+(e[1]-i)*n]}var dn=function(t,e,n,r){return We(We([],hn([t,e],[n,r],.5),!0),[n,r,n,r],!1)};function fn(t,e){var n,r,i,o,a,s,l,u,c,h=t[0],d=t.slice(1).map(Number),f=d[0],p=d[1],g=e.x1,v=e.y1,m=e.x,y=e.y;switch("TQ".includes(h)||(e.qx=null,e.qy=null),h){case"M":return e.x=f,e.y=p,t;case"A":return n=[g,v].concat(d),["C"].concat(cn(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9]));case"Q":return e.qx=f,e.qy=p,n=[g,v].concat(d),["C"].concat((r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],l=n[5],[(u=1/3)*r+(c=2/3)*o,u*i+c*a,u*s+c*o,u*l+c*a,s,l]));case"L":return["C"].concat(dn(g,v,f,p));case"Z":return g===m&&v===y?["C",g,v,m,y,m,y]:["C"].concat(dn(g,v,m,y))}return t}function pn(t,e){if(void 0===e&&(e=!1),function(t){return Ke(t)&&t.every((function(t){var e=t[0];return"MC".includes(e)}))}(t)){var n=[].concat(t);return e?[n,[]]:n}for(var r,i,o=ln(t),a=Be({},Ue),s=[],l="",u=o.length,c=[],h=0;h<u;h+=1){o[h]&&(l=o[h][0]),s[h]=l;var d=fn(o[h],a);o[h]=d,$e(o,s,h),u=o.length,"Z"===l&&c.push(h),i=(r=o[h]).length,a.x1=+r[i-2],a.y1=+r[i-1],a.x2=+r[i-4]||a.x1,a.y2=+r[i-3]||a.y1}return e?[o,c]:o}function gn(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function vn(t,e,n,r,i){var o=gn([t,e],[n,r]),a={x:0,y:0};if("number"==typeof i)if(i<=0)a={x:t,y:e};else if(i>=o)a={x:n,y:r};else{var s=hn([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 mn(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 yn(t,e,n,r,i,o,a,s,l,u){var c=Math.abs,h=Math.sin,d=Math.cos,f=Math.sqrt,p=Math.PI,g=c(n),v=c(r),m=(i%360+360)%360*(p/180);if(t===s&&e===l)return{x:t,y:e};if(0===g||0===v)return vn(t,e,s,l,u).point;var y=(t-s)/2,b=(e-l)/2,x={x:d(m)*y+h(m)*b,y:-h(m)*y+d(m)*b},E=Math.pow(x.x,2)/Math.pow(g,2)+Math.pow(x.y,2)/Math.pow(v,2);E>1&&(g*=f(E),v*=f(E));var w=(Math.pow(g,2)*Math.pow(v,2)-Math.pow(g,2)*Math.pow(x.y,2)-Math.pow(v,2)*Math.pow(x.x,2))/(Math.pow(g,2)*Math.pow(x.y,2)+Math.pow(v,2)*Math.pow(x.x,2)),k=(o!==a?1:-1)*f(w=w<0?0:w),M=k*(g*x.y/v),S=k*(-v*x.x/g),N=d(m)*M-h(m)*S+(t+s)/2,O=h(m)*M+d(m)*S+(e+l)/2,T={x:(x.x-M)/g,y:(x.y-S)/v},C=mn({x:1,y:0},T),A=mn(T,{x:(-x.x-M)/g,y:(-x.y-S)/v});!a&&A>0?A-=2*p:a&&A<0&&(A+=2*p);var P=C+(A%=2*p)*u,R=g*d(P),D=v*h(P);return{x:d(m)*R-h(m)*D+N,y:h(m)*R+d(m)*D+O}}function bn(t,e,n,r,i,o,a,s,l,u,c){var h,d=c.bbox,f=void 0===d||d,p=c.length,g=void 0===p||p,v=c.sampleSize,m=void 0===v?30:v,y="number"==typeof u,b=t,x=e,E=0,w=[b,x,E],k=[b,x],M={x:0,y:0},S=[{x:b,y:x}];y&&u<=0&&(M={x:b,y:x});for(var N=0;N<=m;N+=1){if(b=(h=yn(t,e,n,r,i,o,a,s,l,N/m)).x,x=h.y,f&&S.push({x:b,y:x}),g&&(E+=gn(k,[b,x])),k=[b,x],y&&E>=u&&u>w[2]){var O=(E-u)/(E-w[2]);M={x:k[0]*(1-O)+w[0]*O,y:k[1]*(1-O)+w[1]*O}}w=[b,x,E]}return y&&u>=E&&(M={x:s,y:l}),{length:E,point:M,min:{x:Math.min.apply(null,S.map((function(t){return t.x}))),y:Math.min.apply(null,S.map((function(t){return t.y})))},max:{x:Math.max.apply(null,S.map((function(t){return t.x}))),y:Math.max.apply(null,S.map((function(t){return t.y})))}}}function xn(t,e,n,r,i,o,a,s,l){var u=1-l;return{x:Math.pow(u,3)*t+3*Math.pow(u,2)*l*n+3*u*Math.pow(l,2)*i+Math.pow(l,3)*a,y:Math.pow(u,3)*e+3*Math.pow(u,2)*l*r+3*u*Math.pow(l,2)*o+Math.pow(l,3)*s}}function En(t,e,n,r,i,o,a,s,l,u){var c,h=u.bbox,d=void 0===h||h,f=u.length,p=void 0===f||f,g=u.sampleSize,v=void 0===g?10:g,m="number"==typeof l,y=t,b=e,x=0,E=[y,b,x],w=[y,b],k={x:0,y:0},M=[{x:y,y:b}];m&&l<=0&&(k={x:y,y:b});for(var S=0;S<=v;S+=1){if(y=(c=xn(t,e,n,r,i,o,a,s,S/v)).x,b=c.y,d&&M.push({x:y,y:b}),p&&(x+=gn(w,[y,b])),w=[y,b],m&&x>=l&&l>E[2]){var N=(x-l)/(x-E[2]);k={x:w[0]*(1-N)+E[0]*N,y:w[1]*(1-N)+E[1]*N}}E=[y,b,x]}return m&&l>=x&&(k={x:a,y:s}),{length:x,point:k,min:{x:Math.min.apply(null,M.map((function(t){return t.x}))),y:Math.min.apply(null,M.map((function(t){return t.y})))},max:{x:Math.max.apply(null,M.map((function(t){return t.x}))),y:Math.max.apply(null,M.map((function(t){return t.y})))}}}function wn(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 kn(t,e,n,r,i,o,a,s){var l,u=s.bbox,c=void 0===u||u,h=s.length,d=void 0===h||h,f=s.sampleSize,p=void 0===f?10:f,g="number"==typeof a,v=t,m=e,y=0,b=[v,m,y],x=[v,m],E={x:0,y:0},w=[{x:v,y:m}];g&&a<=0&&(E={x:v,y:m});for(var k=0;k<=p;k+=1){if(v=(l=wn(t,e,n,r,i,o,k/p)).x,m=l.y,c&&w.push({x:v,y:m}),d&&(y+=gn(x,[v,m])),x=[v,m],g&&y>=a&&a>b[2]){var M=(y-a)/(y-b[2]);E={x:x[0]*(1-M)+b[0]*M,y:x[1]*(1-M)+b[1]*M}}b=[v,m,y]}return g&&a>=y&&(E={x:i,y:o}),{length:y,point:E,min:{x:Math.min.apply(null,w.map((function(t){return t.x}))),y:Math.min.apply(null,w.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 Mn(t,e,n){for(var r,i,o,a,s,l,u,c,h,d=ln(t),f="number"==typeof e,p=[],g=0,v=0,m=0,y=0,b=[],x=[],E=0,w={x:0,y:0},k=w,M=w,S=w,N=0,O=0,T=d.length;O<T;O+=1)p=(u="M"===(c=(h=d[O])[0]))?p:[g,v].concat(h.slice(1)),u?(k=w={x:m=h[1],y:y=h[2]},E=0,f&&e<.001&&(S=w)):"L"===c?(E=(r=vn(p[0],p[1],p[2],p[3],(e||0)-N)).length,w=r.min,k=r.max,M=r.point):"A"===c?(E=(i=bn(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],(e||0)-N,n||{})).length,w=i.min,k=i.max,M=i.point):"C"===c?(E=(o=En(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],(e||0)-N,n||{})).length,w=o.min,k=o.max,M=o.point):"Q"===c?(E=(a=kn(p[0],p[1],p[2],p[3],p[4],p[5],(e||0)-N,n||{})).length,w=a.min,k=a.max,M=a.point):"Z"===c&&(E=(s=vn((p=[g,v,m,y])[0],p[1],p[2],p[3],(e||0)-N)).length,w=s.min,k=s.max,M=s.point),f&&N<e&&N+E>=e&&(S=M),x.push(k),b.push(w),N+=E,g=(l="Z"!==c?h.slice(-2):[m,y])[0],v=l[1];return f&&e>=N&&(S={x:g,y:v}),{length:N,point:S,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,x.map((function(t){return t.x}))),y:Math.max.apply(null,x.map((function(t){return t.y})))}}}function Sn(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 Nn(t){return function(t){var e=0,n=0,r=0;return pn(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],l=o[2],u=o[3],c=o[4],h=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,l,u,c,h),i=t.slice(-2),e=i[0],n=i[1],r})).reduce((function(t,e){return t+e}),0)}(t)>=0}function On(t){return t.map((function(t,e,n){var r=e&&n[e-1].slice(-2).concat(t.slice(1)),i=e?En(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],{bbox:!1}).length:0;return{s:t,ss:e?i?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=hn(n,r,e),s=hn(r,i,e),l=hn(i,o,e),u=hn(a,s,e),c=hn(s,l,e),h=hn(u,c,e);return[["C"].concat(a,u,h),["C"].concat(c,l,o)]}(r):[t,t]:[t],l:i}}))}function Tn(t,e,n){var r=On(t),i=On(e),o=r.length,a=i.length,s=r.filter((function(t){return t.l})).length,l=i.filter((function(t){return t.l})).length,u=r.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/s||0,c=i.filter((function(t){return t.l})).reduce((function(t,e){return t+e.l}),0)/l||0,h=n||Math.max(o,a),d=[u,c],f=[h-o,h-a],p=0,g=[r,i].map((function(t,e){return t.l===h?t.map((function(t){return t.s})):t.map((function(t,n){return p=n&&f[e]&&t.l>=d[e],f[e]-=p?1:0,p?t.ss:[t.s]})).flat()}));return g[0].length===g[1].length?g:Tn(g[0],g[1],h)}function Cn(t){var e=document.createElement("div");e.innerHTML=t;var n=e.childNodes[0];return n&&e.contains(n)&&e.removeChild(n),n}function An(){return An="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=f(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}},An.apply(null,arguments)}function Pn(t,e,n,r){var i=An(f(t.prototype),e,n);return"function"==typeof i?function(t){return i.apply(n,t)}:i}function Rn(t,e,n,r){var i=t-n,o=e-r;return Math.sqrt(i*i+o*o)}function Dn(t,e){var n=Math.min.apply(Math,We([],Ve(t),!1)),r=Math.min.apply(Math,We([],Ve(e),!1));return{x:n,y:r,width:Math.max.apply(Math,We([],Ve(t),!1))-n,height:Math.max.apply(Math,We([],Ve(e),!1))-r}}function Ln(t,e,n,r,i,o){return n*Math.cos(i)*Math.cos(o)-r*Math.sin(i)*Math.sin(o)+t}function _n(t,e,n,r,i,o){return n*Math.sin(i)*Math.cos(o)+r*Math.cos(i)*Math.sin(o)+e}function In(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),l=1/0,u=-1/0,c=[o,a],h=2*-Math.PI;h<=2*Math.PI;h+=Math.PI){var d=s+h;o<a?o<d&&d<a&&c.push(d):a<d&&d<o&&c.push(d)}for(h=0;h<c.length;h++){var f=Ln(t,0,n,r,i,c[h]);f<l&&(l=f),f>u&&(u=f)}var p=function(t,e,n){return Math.atan(e/(t*Math.tan(n)))}(n,r,i),g=1/0,v=-1/0,m=[o,a];for(h=2*-Math.PI;h<=2*Math.PI;h+=Math.PI){var y=p+h;o<a?o<y&&y<a&&m.push(y):a<y&&y<o&&m.push(y)}for(h=0;h<m.length;h++){var b=_n(0,e,n,r,i,m[h]);b<g&&(g=b),b>v&&(v=b)}return{x:l,y:g,width:u-l,height:v-g}}function jn(t,e,n,r,i,o){var a=-1,s=1/0,l=[n,r],u=20;o&&o>200&&(u=o/10);for(var c=1/u,h=c/10,d=0;d<=u;d++){var f=d*c,p=[i.apply(void 0,We([],Ve(t.concat([f])),!1)),i.apply(void 0,We([],Ve(e.concat([f])),!1))];(y=Rn(l[0],l[1],p[0],p[1]))<s&&(a=f,s=y)}if(0===a)return{x:t[0],y:e[0]};if(1===a){var g=t.length;return{x:t[g-1],y:e[g-1]}}s=1/0;for(d=0;d<32&&!(h<1e-4);d++){var v=a-h,m=a+h,y=(p=[i.apply(void 0,We([],Ve(t.concat([v])),!1)),i.apply(void 0,We([],Ve(e.concat([v])),!1))],Rn(l[0],l[1],p[0],p[1]));if(v>=0&&y<s)a=v,s=y;else{var b=[i.apply(void 0,We([],Ve(t.concat([m])),!1)),i.apply(void 0,We([],Ve(e.concat([m])),!1))],x=Rn(l[0],l[1],b[0],b[1]);m<=1&&x<s?(a=m,s=x):h*=.5}}return{x:i.apply(void 0,We([],Ve(t.concat([a])),!1)),y:i.apply(void 0,We([],Ve(e.concat([a])),!1))}}function Bn(t,e,n,r){return Rn(t,e,n,r)}function Fn(t,e,n,r,i){return{x:(1-i)*t+i*n,y:(1-i)*e+i*r}}function zn(t,e,n,r,i,o){var a=[n-t,r-e];if(function(t,e){return t[0]===e[0]&&t[1]===e[1]}(a,[0,0]))return Math.sqrt((i-t)*(i-t)+(o-e)*(o-e));var s=[-a[1],a[0]];!function(t,e){var n=e[0],r=e[1],i=n*n+r*r;i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i}(s,s);var l=[i-t,o-e];return Math.abs(function(t,e){return t[0]*e[0]+t[1]*e[1]}(l,s))}function Gn(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 Vn(t,e,n,r){var i,o,a,s=-3*t+9*e-9*n+3*r,l=6*t-12*e+6*n,u=3*e-3*t,c=[];if(se(s,0))se(l,0)||(i=-u/l)>=0&&i<=1&&c.push(i);else{var h=l*l-4*s*u;se(h,0)?c.push(-l/(2*s)):h>0&&(o=(-l-(a=Math.sqrt(h)))/(2*s),(i=(-l+a)/(2*s))>=0&&i<=1&&c.push(i),o>=0&&o<=1&&c.push(o))}return c}function Wn(t,e,n,r,i,o,a,s){for(var l=[t,a],u=[e,s],c=Vn(t,n,i,a),h=Vn(e,r,o,s),d=0;d<c.length;d++)l.push(Gn(t,n,i,a,c[d]));for(d=0;d<h.length;d++)u.push(Gn(e,r,o,s,h[d]));return Dn(l,u)}function Hn(t,e,n,r,i,o,a,s,l,u,c){var h=function(t,e,n,r,i,o,a,s,l,u,c){return jn([t,n,i,a],[e,r,o,s],l,u,Gn,c)}(t,e,n,r,i,o,a,s,l,u,c);return Rn(h.x,h.y,l,u)}function Un(t){return function(t){if(t.length<2)return 0;for(var e=0,n=0;n<t.length-1;n++){var r=t[n],i=t[n+1];e+=Rn(r[0],r[1],i[0],i[1])}return e}(t)}function $n(t,e,n,r){var i=1-r;return i*i*t+2*r*i*e+r*r*n}function Yn(t,e,n){var r=t+n-2*e;if(se(r,0))return[.5];var i=(t-e)/r;return i<=1&&i>=0?[i]:[]}function qn(t,e,n,r,i,o){var a=Yn(t,n,i)[0],s=Yn(e,r,o)[0],l=[t,i],u=[e,o];return void 0!==a&&l.push($n(t,n,i,a)),void 0!==s&&u.push($n(e,r,o,s)),Dn(l,u)}function Xn(t,e,n,r,i,o,a,s){var l=function(t,e,n,r,i,o,a,s){return jn([t,n,i],[e,r,o],a,s,$n)}(t,e,n,r,i,o,a,s);return Rn(l.x,l.y,a,s)}function Kn(){Kn=function(){return e};var t,e={},r=Object.prototype,i=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function u(t,e,n,r){return Object.defineProperty(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r})}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function c(e,n,r,i){var o=n&&n.prototype instanceof f?n:f,a=Object.create(o.prototype);return u(a,"_invoke",function(e,n,r){var i=1;return function(o,a){if(3===i)throw Error("Generator is already running");if(4===i){if("throw"===o)throw a;return{value:t,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var l=w(s,r);if(l){if(l===d)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(1===i)throw i=4,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=3;var u=h(e,n,r);if("normal"===u.type){if(i=r.done?4:2,u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=4,r.method="throw",r.arg=u.arg)}}}(e,r,new S(i||[])),!0),a}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=c;var d={};function f(){}function p(){}function g(){}var v={};u(v,a,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(N([])));y&&y!==r&&i.call(y,a)&&(v=y);var b=g.prototype=f.prototype=Object.create(v);function x(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function r(o,a,s,l){var u=h(t[o],t,a);if("throw"!==u.type){var c=u.arg,d=c.value;return d&&"object"==n(d)&&i.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,s,l)}),(function(t){r("throw",t,s,l)})):e.resolve(d).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,l)}))}l(u.arg)}var o;u(this,"_invoke",(function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}),!0)}function w(e,n){var r=n.method,i=e.i[r];if(i===t)return n.delegate=null,"throw"===r&&e.i.return&&(n.method="return",n.arg=t,w(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var o=h(i,e.i,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,d;var a=o.arg;return a?a.done?(n[e.r]=a.value,n.next=e.n,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,d):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,d)}function k(t){this.tryEntries.push(t)}function M(e){var n=e[4]||{};n.type="normal",n.arg=t,e[4]=n}function S(t){this.tryEntries=[[-1]],t.forEach(k,this),this.reset(!0)}function N(e){if(null!=e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,s=function n(){for(;++o<e.length;)if(i.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return s.next=s}}throw new TypeError(n(e)+" is not iterable")}return p.prototype=g,u(b,"constructor",g),u(g,"constructor",p),p.displayName=u(g,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,u(t,l,"GeneratorFunction")),t.prototype=Object.create(b),t},e.awrap=function(t){return{__await:t}},x(E.prototype),u(E.prototype,s,(function(){return this})),e.AsyncIterator=E,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new E(c(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(b),u(b,l,"Generator"),u(b,a,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),e.keys=function(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}},e.values=N,S.prototype={constructor:S,reset:function(e){if(this.prev=this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(M),!e)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0][4];if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function r(t){a.type="throw",a.arg=e,n.next=t}for(var i=n.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o[4],s=this.prev,l=o[1],u=o[2];if(-1===o[0])return r("end"),!1;if(!l&&!u)throw Error("try statement without catch or finally");if(null!=o[0]&&o[0]<=s){if(s<l)return this.method="next",this.arg=t,r(l),!0;if(s<u)return r(u),!1}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r[0]>-1&&r[0]<=this.prev&&this.prev<r[2]){var i=r;break}}i&&("break"===t||"continue"===t)&&i[0]<=e&&e<=i[2]&&(i=null);var o=i?i[4]:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i[2],d):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[2]===t)return this.complete(n[4],n[3]),M(n),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n[0]===t){var r=n[4];if("throw"===r.type){var i=r.arg;M(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={i:N(e),r:n,n:r},"next"===this.method&&(this.arg=t),d}},e}function Zn(t,e,n,r,i,o,a){try{var s=t[o](a),l=s.value}catch(t){return void n(t)}s.done?e(l):Promise.resolve(l).then(r,i)}function Qn(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){Zn(o,r,i,a,s,"next",t)}function s(t){Zn(o,r,i,a,s,"throw",t)}a(void 0)}))}}function Jn(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=h(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 tr(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<o.length;r++)n=o[r],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}
2
2
  /*!
3
3
  * @antv/g-lite
4
4
  * @description A core module for rendering engine implements DOM API.
@@ -15,7 +15,7 @@
15
15
  * @author AntVis
16
16
  * @docs https://g.antv.antgroup.com/
17
17
  */
18
- var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return y(e,t),u(e)}(Ts),pu=0,gu=function(){return u((function t(e,n){var r;s(this,t),this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=e,e.animation=this,this.timeline=n,this.id="".concat(pu++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(r=this.effect)||void 0===r?void 0:r.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}),[{key:"pending",get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending}},{key:"playState",get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"}},{key:"ready",get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise((function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}})),this.pending||this.resolveReadyPromise()),this.readyPromise}},{key:"finished",get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise((function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}})),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise}},{key:"currentTime",get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){if(t=Number(t),!isNaN(t)){var e;if(this.timeline.restart(),!this._paused&&null!==this._startTime)this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate;this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this))}}},{key:"startTime",get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}}},{key:"_isFinished",get:function(){return!this._idle&&(this._playbackRate>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=this.oldPlayState,e=this.pending?"pending":this.playState;return this.readyPromise&&e!==t&&("idle"===e?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===t?this.resolveReadyPromise():"pending"===e&&(this.readyPromise=void 0)),this.finishedPromise&&e!==t&&("idle"===e?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===e?this.resolveFinishedPromise():"finished"===t&&(this.finishedPromise=void 0)),this.oldPlayState=e,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=0,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new fu(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(br)}},{key:"addEventListener",value:function(t,e,n){throw new Error(br)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(br)}},{key:"dispatchEvent",value:function(t){throw new Error(br)}},{key:"commitStyles",value:function(){throw new Error(br)}},{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 fu(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 fu(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),vu=.1,mu="function"==typeof Float32Array,yu=function(t,e){return 1-3*e+3*t},bu=function(t,e){return 3*e-6*t},xu=function(t){return 3*t},Eu=function(t,e,n){return((yu(e,n)*t+bu(e,n))*t+xu(e))*t},wu=function(t,e,n){return 3*yu(e,n)*t*t+2*bu(e,n)*t+xu(e)},ku=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=mu?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Eu(o*vu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=vu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*vu,s=wu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=wu(e,n,r);if(0===o)return e;e-=(Eu(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=Eu(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+vu,t,n)};return function(t){return 0===t||1===t?t:Eu(a(t),e,r)}},Mu=function(t){return Math.pow(t,2)},Su=function(t){return Math.pow(t,3)},Nu=function(t){return Math.pow(t,4)},Ou=function(t){return Math.pow(t,5)},Tu=function(t){return Math.pow(t,6)},Cu=function(t){return 1-Math.cos(t*Math.PI/2)},Au=function(t){return 1-Math.sqrt(1-t*t)},Pu=function(t){return t*t*(3*t-2)},Ru=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)},Du=function(t){var e=b(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=oe(Number(r),1,10),s=oe(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)},Lu=function(t){var e=arguments.length>2?arguments[2]:void 0,n=b(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],l=void 0===s?10:s,u=n[3],c=void 0===u?0:u;i=oe(i,.1,1e3),a=oe(a,.1,1e3),l=oe(l,.1,1e3),c=oe(c,.1,1e3);var h=Math.sqrt(a/i),d=l/(2*Math.sqrt(a*i)),f=d<1?h*Math.sqrt(1-d*d):0,p=d<1?(d*h-c)/f:-c+h,g=e?e*t/1e3:t;return g=d<1?Math.exp(-g*d*h)*(1*Math.cos(f*g)+p*Math.sin(f*g)):(1+p*g)*Math.exp(-g*h),0===t||1===t?t:1-g},_u=function(t){var e=b(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)(oe(t,0,1)*r)/r},Iu=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return ku(n,r,i,o)(t)},ju=ku(.42,0,1,1),Bu=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)}},Fu=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}},zu=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}},Gu={steps:_u,"step-start":function(t){return _u(t,[1,"start"])},"step-end":function(t){return _u(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Iu,ease:function(t){return Iu(t,[.25,.1,.25,1])},in:ju,out:Bu(ju),"in-out":Fu(ju),"out-in":zu(ju),"in-quad":Mu,"out-quad":Bu(Mu),"in-out-quad":Fu(Mu),"out-in-quad":zu(Mu),"in-cubic":Su,"out-cubic":Bu(Su),"in-out-cubic":Fu(Su),"out-in-cubic":zu(Su),"in-quart":Nu,"out-quart":Bu(Nu),"in-out-quart":Fu(Nu),"out-in-quart":zu(Nu),"in-quint":Ou,"out-quint":Bu(Ou),"in-out-quint":Fu(Ou),"out-in-quint":zu(Ou),"in-expo":Tu,"out-expo":Bu(Tu),"in-out-expo":Fu(Tu),"out-in-expo":zu(Tu),"in-sine":Cu,"out-sine":Bu(Cu),"in-out-sine":Fu(Cu),"out-in-sine":zu(Cu),"in-circ":Au,"out-circ":Bu(Au),"in-out-circ":Fu(Au),"out-in-circ":zu(Au),"in-back":Pu,"out-back":Bu(Pu),"in-out-back":Fu(Pu),"out-in-back":zu(Pu),"in-bounce":Ru,"out-bounce":Bu(Ru),"in-out-bounce":Fu(Ru),"out-in-bounce":zu(Ru),"in-elastic":Du,"out-elastic":Bu(Du),"in-out-elastic":Fu(Du),"out-in-elastic":zu(Du),spring:Lu,"spring-in":Lu,"spring-out":Bu(Lu),"spring-in-out":Fu(Lu),"spring-out-in":zu(Lu)},Vu=function(t){return t};function Wu(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Hu="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",Uu=new RegExp("cubic-bezier\\(".concat(Hu,",").concat(Hu,",").concat(Hu,",").concat(Hu,"\\)")),$u=/steps\(\s*(\d+)\s*\)/,Yu=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function qu(t){var e=Uu.exec(t);if(e)return ku.apply(void 0,d(e.slice(1).map(Number)));var n=$u.exec(t);if(n)return Wu(Number(n[1]),0);var r=Yu.exec(t);return r?Wu(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Gu[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)]||Gu.linear}function Xu(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 Ku(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e<Math.min(n.delay,r)?1: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),l=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),u=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,l,s);return n.currentIteration=l,n.progress=u,n.easingFunction(u)}function Zu(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Qu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:qu(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var a=o,s=o+1,l=i[a].computedOffset,u=i[s].computedOffset,c=l,h=u;0===o&&(c=-1/0,0===u&&(s=a)),o===i.length-2&&(h=1/0,1===l&&(a=s)),n.push({applyFrom:c,applyTo:h,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:tc(r,i[a].value,i[s].value,e)})}return n.sort((function(t,e){return t.startOffset-e.startOffset})),n}(r,n);return function(t,e){if(null!==e)i.filter((function(t){return e>=t.applyFrom&&e<t.applyTo})).forEach((function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Qu(n)&&t.setAttribute(n,null)}}function Qu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Ju=function(t,e,n){return function(r){var i=ec(t,e,r);return ae(i)?i:n(i)}};function tc(t,e,n,r){var i=ga[t];if(i&&i.syntax&&i.int){var o=bl.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=o.parser,s=a?a(e,r):e,l=a?a(n,r):n,u=o.mixer(s,l,r);if(u){var c=Ju.apply(void 0,d(u));return function(t){return 0===t?e:1===t?n:c(t)}}}}return Ju(!1,!0,(function(t){return t?n:e}))}function ec(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),a=[],s=0;s<o;s++)a.push(ec(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments ".concat(t,":").concat(e))}var nc=function(){return u((function t(){s(this,t),this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Vu,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}),[{key:"easing",get:function(){return this._easing},set:function(t){this.easingFunction=qu(t),this._easing=t}}])}();function rc(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var a={};"offset"in t&&(a.offset=Number(t.offset)),"easing"in t&&(a.easing=t.easing),"composite"in t&&(a.composite=t.composite),e[o]=a}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort((function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)})),e}(t));for(var n=t.map((function(t){var n={};for(var r in null!=e&&e.composite&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)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<n.length;o++){var a=n[o].offset;if($t(a))r=!1;else{if(a<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=a}}return n=n.filter((function(t){return Number(t.offset)>=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;a<r;a++){var s=n[a].computedOffset;if(!$t(s)&&!$t(o)){for(var l=1;l<a-i;l++)n[i+l].computedOffset=o+(Number(s)-o)*l/(a-i);i=a,o=Number(s)}}}(),n}var ic="backwards|forwards|both|none".split("|"),oc="reverse|alternate|alternate-reverse".split("|");function ac(t,e){return function(t){var e=new nc;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(n){if(void 0!==t[n]&&null!==t[n]&&"auto"!==t[n]){if(("number"==typeof e[n]||"duration"===n)&&("number"!=typeof t[n]||isNaN(t[n])))return;if("fill"===n&&-1===ic.indexOf(t[n]))return;if("direction"===n&&-1===oc.indexOf(t[n]))return;e[n]=t[n]}})):e.duration=t,e}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}))}var sc=function(){return u((function t(e,n,r){var i=this;s(this,t),this.composite="replace",this.iterationComposite="replace",this.target=e,this.timing=ac(r),this.timing.effect=this,this.timing.activeDuration=Xu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=rc(n,this.timing),this.interpolations=Zu(this.normalizedKeyframes,this.timing,this.target);var o=bl.globalThis.Proxy;this.computedTiming=o?new o(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?i.animation&&i.animation.currentTime||null:"currentIteration"===e?i.animation&&"running"===i.animation.playState?t.currentIteration||0:null:"progress"===e?i.animation&&"running"===i.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}),[{key:"applyInterpolations",value:function(){this.interpolations(this.target,Number(this.timeFraction))}},{key:"update",value:function(t){return null!==t&&(this.timeFraction=Ku(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)}},{key:"getKeyframes",value:function(){return this.normalizedKeyframes}},{key:"setKeyframes",value:function(t){this.normalizedKeyframes=rc(t)}},{key:"getComputedTiming",value:function(){return this.computedTiming}},{key:"getTiming",value:function(){return this.timing}},{key:"updateTiming",value:function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))}}])}();function lc(t,e){return Number(t.id)-Number(e.id)}var uc=function(){return u((function t(e){var n=this;s(this,t),this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){n.currentTime=t,n.discardAnimations(),0===n.animations.length?n.timelineTicking=!1:n.requestAnimationFrame(n.webAnimationsNextTick)},this.processRafCallbacks=function(t){var e=n.rafCallbacks;n.rafCallbacks=[],t<Number(n.currentTime)&&(t=Number(n.currentTime)),n.animations.sort(lc),n.animations=n.tick(t,!0,n.animations)[0],e.forEach((function(e){e[1](t)})),n.applyPendingEffects()},this.document=e}),[{key:"getAnimations",value:function(){return this.discardAnimations(),this.animations.slice()}},{key:"isTicking",value:function(){return this.inTick}},{key:"play",value:function(t,e,n){var r=new sc(t,e,n),i=new gu(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i}},{key:"applyDirtiedAnimation",value:function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(lc),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach((function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)})),this.applyPendingEffects()}}},{key:"restart",value:function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame}},{key:"destroy",value:function(){this.document.defaultView.cancelAnimationFrame(this.frameId)}},{key:"applyPendingEffects",value:function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]}},{key:"updateAnimationsPromises",value:function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))}},{key:"discardAnimations",value:function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))}},{key:"restartWebAnimationsNextTick",value:function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))}},{key:"rAF",value:function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e}},{key:"requestAnimationFrame",value:function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))}},{key:"tick",value:function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],l=[],u=[];return n.forEach((function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(a.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?l.push(n):u.push(n)})),(r=this.pendingEffects).push.apply(r,a),(i=this.pendingEffects).push.apply(i,s),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[l,u]}}])}();bl.EasingFunction=qu,bl.AnimationTimeline=uc;const cc={duration:500},hc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var dc,fc,pc,gc,vc,mc,yc,bc,xc;!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"}(dc||(dc={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(fc||(fc={})),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,(pc=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",pc.DBLCLICK="combo:dblclick",pc.POINTER_OVER="combo:pointerover",pc.POINTER_LEAVE="combo:pointerleave",pc.POINTER_ENTER="combo:pointerenter",pc.POINTER_MOVE="combo:pointermove",pc.POINTER_OUT="combo:pointerout",pc.POINTER_DOWN="combo:pointerdown",pc.POINTER_UP="combo:pointerup",pc.CONTEXT_MENU="combo:contextmenu",pc.DRAG_START="combo:dragstart",pc.DRAG="combo:drag",pc.DRAG_END="combo:dragend",pc.DRAG_ENTER="combo:dragenter",pc.DRAG_OVER="combo:dragover",pc.DRAG_LEAVE="combo:dragleave",pc.DROP="combo:drop",t.CommonEvent=void 0,(gc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",gc.DBLCLICK="dblclick",gc.POINTER_OVER="pointerover",gc.POINTER_LEAVE="pointerleave",gc.POINTER_ENTER="pointerenter",gc.POINTER_MOVE="pointermove",gc.POINTER_OUT="pointerout",gc.POINTER_DOWN="pointerdown",gc.POINTER_UP="pointerup",gc.CONTEXT_MENU="contextmenu",gc.DRAG_START="dragstart",gc.DRAG="drag",gc.DRAG_END="dragend",gc.DRAG_ENTER="dragenter",gc.DRAG_OVER="dragover",gc.DRAG_LEAVE="dragleave",gc.DROP="drop",gc.KEY_DOWN="keydown",gc.KEY_UP="keyup",gc.WHEEL="wheel",gc.PINCH="pinch",t.ContainerEvent=void 0,(vc=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",vc.KEY_UP="keyup",t.EdgeEvent=void 0,(mc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",mc.DBLCLICK="edge:dblclick",mc.POINTER_OVER="edge:pointerover",mc.POINTER_LEAVE="edge:pointerleave",mc.POINTER_ENTER="edge:pointerenter",mc.POINTER_MOVE="edge:pointermove",mc.POINTER_OUT="edge:pointerout",mc.POINTER_DOWN="edge:pointerdown",mc.POINTER_UP="edge:pointerup",mc.CONTEXT_MENU="edge:contextmenu",mc.DRAG_ENTER="edge:dragenter",mc.DRAG_OVER="edge:dragover",mc.DRAG_LEAVE="edge:dragleave",mc.DROP="edge:drop",t.GraphEvent=void 0,(yc=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",yc.AFTER_CANVAS_INIT="aftercanvasinit",yc.BEFORE_SIZE_CHANGE="beforesizechange",yc.AFTER_SIZE_CHANGE="aftersizechange",yc.BEFORE_ELEMENT_CREATE="beforeelementcreate",yc.AFTER_ELEMENT_CREATE="afterelementcreate",yc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",yc.AFTER_ELEMENT_UPDATE="afterelementupdate",yc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",yc.AFTER_ELEMENT_DESTROY="afterelementdestroy",yc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",yc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",yc.BEFORE_DRAW="beforedraw",yc.AFTER_DRAW="afterdraw",yc.BEFORE_RENDER="beforerender",yc.AFTER_RENDER="afterrender",yc.BEFORE_ANIMATE="beforeanimate",yc.AFTER_ANIMATE="afteranimate",yc.BEFORE_LAYOUT="beforelayout",yc.AFTER_LAYOUT="afterlayout",yc.BEFORE_STAGE_LAYOUT="beforestagelayout",yc.AFTER_STAGE_LAYOUT="afterstagelayout",yc.BEFORE_TRANSFORM="beforetransform",yc.AFTER_TRANSFORM="aftertransform",yc.BATCH_START="batchstart",yc.BATCH_END="batchend",yc.BEFORE_DESTROY="beforedestroy",yc.AFTER_DESTROY="afterdestroy",yc.BEFORE_RENDERER_CHANGE="beforerendererchange",yc.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(bc=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",bc.REDO="redo",bc.CANCEL="cancel",bc.ADD="add",bc.CLEAR="clear",bc.CHANGE="change",t.NodeEvent=void 0,(xc=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",xc.DBLCLICK="node:dblclick",xc.POINTER_OVER="node:pointerover",xc.POINTER_LEAVE="node:pointerleave",xc.POINTER_ENTER="node:pointerenter",xc.POINTER_MOVE="node:pointermove",xc.POINTER_OUT="node:pointerout",xc.POINTER_DOWN="node:pointerdown",xc.POINTER_UP="node:pointerup",xc.CONTEXT_MENU="node:contextmenu",xc.DRAG_START="node:dragstart",xc.DRAG="node:drag",xc.DRAG_END="node:dragend",xc.DRAG_ENTER="node:dragenter",xc.DRAG_OVER="node:dragover",xc.DRAG_LEAVE="node:dragleave",xc.DROP="node:drop";const Ec="combo",wc="tree";var kc;t.ExtensionCategory=void 0,(kc=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",kc.EDGE="edge",kc.COMBO="combo",kc.THEME="theme",kc.PALETTE="palette",kc.LAYOUT="layout",kc.BEHAVIOR="behavior",kc.PLUGIN="plugin",kc.ANIMATION="animation",kc.TRANSFORM="transform",kc.SHAPE="shape";const Mc={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Sc(t,e){var n;const r=null===(n=Mc[t])||void 0===n?void 0:n[e];if(r)return r}const Nc="5.0.45";function Oc(t){return`[G6 v${Nc}] ${t}`}const Tc=t=>{console.warn(Oc(t))};function Cc(e){const{theme:n}=e;if(!n)return{};const r=Sc(t.ExtensionCategory.THEME,n);return r||(Tc(`The theme of ${n} is not registered.`),{})}function Ac(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 Pc(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=>$t(t)))||r.every((t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&Ne(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 Rc(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 Dc(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},cc);return qt(n)&&Object.assign(r,n),qt(e)&&Object.assign(r,e),r}function Lc(e,n,r,i){var o,a;const{animation:s}=e;if(!1===s||!1===i)return[];const l=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===l)return[];const u=null==l?void 0:l[r];if(!1===u)return[];const c=null===(a=Cc(e)[n])||void 0===a?void 0:a.animation,h=(e=[])=>function(e){if("string"==typeof e){return Sc(t.ExtensionCategory.ANIMATION,e)||(Tc(`The animation of ${e} is not registered.`),[])}return e}(e).map((t=>Object.assign(Object.assign(Object.assign(Object.assign({},hc),qt(s)&&s),t),qt(i)&&i)));if(u)return h(u);if(!c)return[];const d=c[r];return!1===d?[]:h(d)}function _c(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<r.length;a++){const s=r[a];if("translate"===s[0]){if(s[1]===t&&s[2]===e)return null;i=a,o.push(["translate",t,e])}else if("translate3d"===s[0]){if(s[1]===t&&s[2]===e&&s[3]===n)return null;i=a,o.push(["translate3d",t,e,null!=n?n:0])}else o.push(s)}return-1===i&&o.splice(0,0,ae(n)?["translate3d",t,e,null!=n?n:0]:["translate",t,e]),0===o.length?null:o}const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Ic=(t,e,n)=>{if(!n.length)return null;const[r,i]=e;let o;const a=n.map((e=>{var{fields:n,shape:a,states:s}=e,l=Fe(e,["fields","shape","states"]);const u=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const a=`get${de(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(!u)return null;const{shape:c,fromStyle:h,toStyle:d}=u,f=[{},{}];if(n.forEach((t=>{var e,n;Object.assign(f[0],{[t]:null!==(e=h[t])&&void 0!==e?e:Rc(t)}),Object.assign(f[1],{[t]:null!==(n=d[t])&&void 0!==n?n:Rc(t)})})),f.some((t=>Object.keys(t).some((t=>["x","y","z"].includes(t)))))){const{x:t=0,y:e=0,z:n,transform:r=""}=c.attributes||{};f.forEach((i=>{var o,a,s;i.transform=_c(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 p=c.animate(Pc(f),l);return void 0===a&&(o=p),p})).filter(Boolean),s=o||(null==a?void 0:a[0]);return s?Ac(s,a.filter((t=>t!=t))):null},jc=[{fields:["x","y"]}],Bc=jc,Fc=[{fields:["sourceNode","targetNode"]}],zc=Fc,Gc=[{fields:["childrenNode","x","y"]}],Vc=Gc;function Wc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function Hc(t,e,n){return t>=e&&t<=n}function Uc(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 $c(t=0){const e=Uc(t);return e[0]+e[2]}function Yc(t){return t.max[0]-t.min[0]}function qc(t){return t.max[1]-t.min[1]}function Xc(t){return[Yc(t),qc(t)]}function Kc(t,e){const n=Wc(t)?Zc(t):t.getShape("key").getBounds();return e?Qc(n,e):n}function Zc(t){const[e,n,r=0]=t,i=new fr;return i.setMinMax([e,n,r],[e,n,r]),i}function Qc(t,e){const[n,r,i,o]=Uc(e),[a,s,l]=t.min,[u,c,h]=t.max,d=new fr;return d.setMinMax([a-o,s-n,l],[u+r,c+i,h]),d}function Jc(t){if(0===t.length)return new fr;if(1===t.length)return t[0];const e=new fr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function th(t,e){return Hc(t[0],e.min[0],e.max[0])&&Hc(t[1],e.min[1],e.max[1])}function eh(t,e,n=!1){const{min:[r,i],max:[o,a]}=e,s=(t[1]===i||t[1]===a)&&(n||Hc(t[0],r,o)),l=(t[0]===r||t[0]===o)&&(n||Hc(t[1],i,a));return s||l}function nh(t,e){const{center:n}=e;return t[0]===n[0]&&t[1]===n[1]}function rh(t,e){const[n,r]=t,[i,o]=e.min,[a,s]=e.max,l=n-i,u=a-n,c=r-o,h=s-r,d=Math.min(l,u,c,h);return d===l?"left":d===u?"right":d===c?"top":d===h?"bottom":"left"}function ih(t,e){const n=me(t);if(th(t,e)){switch(rh(t,e)){case"left":n[0]=e.min[0];break;case"right":n[0]=e.max[0];break;case"top":n[1]=e.min[1];break;case"bottom":n[1]=e.max[1]}}else{const[r,i]=t,[o,a]=e.min,[s,l]=e.max;n[0]=Hc(r,o,s)?r:r<o?o:s,n[1]=Hc(i,a,l)?i:i<a?a:l}return n}var oh=function(t,e){return t===e},ah=function(){function t(t,e){void 0===e&&(e=null),this.value=t,this.next=e}return t.prototype.toString=function(t){return t?t(this.value):"".concat(this.value)},t}(),sh=function(){function t(t){void 0===t&&(t=oh),this.head=null,this.tail=null,this.compare=t}return t.prototype.prepend=function(t){var e=new ah(t,this.head);return this.head=e,this.tail||(this.tail=e),this},t.prototype.append=function(t){var e=new ah(t);return this.head?(this.tail.next=e,this.tail=e,this):(this.head=e,this.tail=e,this)},t.prototype.delete=function(t){if(!this.head)return null;for(var e=null;this.head&&this.compare(this.head.value,t);)e=this.head,this.head=this.head.next;var n=this.head;if(null!==n)for(;n.next;)this.compare(n.next.value,t)?(e=n.next,n.next=n.next.next):n=n.next;return this.compare(this.tail.value,t)&&(this.tail=n),e},t.prototype.find=function(t){var e=t.value,n=void 0===e?void 0:e,r=t.callback,i=void 0===r?void 0:r;if(!this.head)return null;for(var o=this.head;o;){if(i&&i(o.value))return o;if(void 0!==n&&this.compare(o.value,n))return o;o=o.next}return null},t.prototype.deleteTail=function(){var t=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,t;for(var e=this.head;e.next;)e.next.next?e=e.next:e.next=null;return this.tail=e,t},t.prototype.deleteHead=function(){if(!this.head)return null;var t=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),t},t.prototype.fromArray=function(t){var e=this;return t.forEach((function(t){return e.append(t)})),this},t.prototype.toArray=function(){for(var t=[],e=this.head;e;)t.push(e),e=e.next;return t},t.prototype.reverse=function(){for(var t=this.head,e=null,n=null;t;)n=t.next,t.next=e,e=t,t=n;this.tail=this.head,this.head=e},t.prototype.toString=function(t){return void 0===t&&(t=void 0),this.toArray().map((function(e){return e.toString(t)})).toString()},t}(),lh=function(t,e,n){void 0===e&&(e=[]);var r=e.filter((function(e){return e.source===t||e.target===t}));if("target"===n){return r.filter((function(e){return e.source===t})).map((function(t){return t.target}))}if("source"===n){return r.filter((function(e){return e.target===t})).map((function(t){return t.source}))}return r.map((function(e){return e.source===t?e.target:e.source}))},uh={}.toString,ch=function(t,e){return uh.call(t)==="[object "+e+"]"},hh=function(t){return ch(t,"Function")},dh=function(t){return Array.isArray?Array.isArray(t):ch(t,"Array")};var fh,ph=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return function(t,e){var n,r;if(t)if(dh(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var a in t)if(t.hasOwnProperty(a)&&!1===e(t[a],a))break}(t,(function(n,r){hh(t)&&"prototype"===r||e.push(n)})),e};!function(t,e){if(!hh(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};n.cache=new Map}((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return fh||(fh=document.createElement("canvas").getContext("2d")),fh.font=[o,a,i,n+"px",r].join(" "),fh.measureText(function(t){return ch(t,"String")}(t)?t:"").width}),(function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}([t],ph(e)).join("")}));function gh(t,e,n,r){if(t===e)return[t];if(r[e])return r[e];for(var i=[],o=0,a=n[e];o<a.length;o++){var s=gh(t,a[o],n,r);if(!s)return;for(var l=0,u=s;l<u.length;l++){var c=u[l];dh(c)?i.push(We(We([],c,!0),[e],!1)):i.push([c,e])}}return r[e]=i,r[e]}var vh,mh=function(t,e,n,r,i){var o=function(t,e,n,r){var i=t.nodes,o=void 0===i?[]:i,a=t.edges,s=void 0===a?[]:a,l={},u={},c={};o.forEach((function(t,n){var r=t.id;u[r]=1/0,r===e&&(u[r]=0)}));for(var h=o.length,d=function(t){var e=function(t,e,n){for(var r,i=1/0,o=0;o<e.length;o++){var a=e[o].id;!n[a]&&t[a]<=i&&(i=t[a],r=e[o])}return r}(u,o,l),i=e.id;if(l[i]=!0,u[i]===1/0)return"continue";var a=[];a=n?function(t,e){return e.filter((function(e){return e.source===t}))}(i,s):function(t,e){return e.filter((function(e){return e.source===t||e.target===t}))}(i,s),a.forEach((function(t){var n=t.target,o=t.source,a=n===i?o:n,s=r&&t[r]?t[r]:1;u[a]>u[e.id]+s?(u[a]=u[e.id]+s,c[a]=[e.id]):u[a]===u[e.id]+s&&c[a].push(e.id)}))},f=0;f<h;f++)d();c[e]=[e];var p={};for(var g in u)u[g]!==1/0&&gh(e,g,c,p);var v={};for(var g in p)v[g]=p[g][0];return{length:u,path:v,allPath:p}}(t,e,r,i),a=o.length,s=o.path,l=o.allPath;return{length:a[n],path:s[n],allPath:l[n]}};!function(t){t.EuclideanDistance="euclideanDistance"}(vh||(vh={}));function yh(t){if(void 0!==t.id)return t.id;if(void 0!==t.source&&void 0!==t.target)return`${t.source}-${t.target}`;throw new Error(Oc("The datum does not have available id."))}function bh(t){return t.combo}function xh(t,e){const n={nodes:(t.nodes||[]).map(yh),edges:(t.edges||[]).map(yh),combos:(t.combos||[]).map(yh)};return e?Object.values(n).flat():n}!function(){function t(t){void 0===t&&(t=10),this.linkedList=new sh,this.maxStep=t}Object.defineProperty(t.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),t.prototype.isEmpty=function(){return!this.linkedList.head},t.prototype.isMaxStack=function(){return this.toArray().length>=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 Eh=(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(yh(t),n.direction).length;i.set(yh(t),r)})),i}case"betweenness":return kh(t,n.directed,n.weightPropertyName);case"closeness":return Mh(t,n.directed,n.weightPropertyName);case"eigenvector":return Nh(t,n.directed);case"pagerank":return Sh(t,n.epsilon,n.linkProb);default:return wh(t)}},wh=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach((t=>{n.set(yh(t),0)})),n},kh=(t,e,n)=>{const r=wh(t),{nodes:i=[]}=t;return i.forEach((o=>{i.forEach((i=>{if(o!==i){const{allPath:a}=mh(t,yh(o),yh(i),e,n),s=a.length;a.flat().forEach((t=>{t!==yh(o)&&t!==yh(i)&&r.set(t,r.get(t)+1/s)}))}}))})),r},Mh=(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}=mh(t,yh(o),yh(i),e,n);r+=a}return r}),0);r.set(yh(o),1/a)})),r},Sh=(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,l=void 0===s?[]:s,u=t.edges,c=void 0===u?[]:u,h=l.length,d={},f={},p=0;p<h;++p)d[v=(E=l[p]).id]=1/h,f[v]=1/h;for(var g=function(t){var e={},n=t.nodes,r=void 0===n?[]:n,i=t.edges,o=void 0===i?[]:i;return r.forEach((function(t){e[t.id]={degree:0,inDegree:0,outDegree:0}})),o.forEach((function(t){e[t.source].degree++,e[t.source].outDegree++,e[t.target].degree++,e[t.target].inDegree++})),e}(t);a>0&&i>e;){for(o=0,p=0;p<h;++p){var v=(E=l[p]).id;if(r=0,0===g[E.id].inDegree)d[v]=0;else{for(var m=lh(v,c,"source"),y=0;y<m.length;++y){var b=m[y],x=g[b].outDegree;x>0&&(r+=f[b]/x)}d[v]=n*r,o+=d[v]}}for(o=(1-o)/h,i=0,p=0;p<h;++p){var E;r=d[v=(E=l[p]).id]+o,i+=Math.abs(r-f[v]),f[v]=r}a-=1}return f}(t,e,n);return null===(r=t.nodes)||void 0===r||r.forEach((t=>{i.set(yh(t),o[yh(t)])})),i},Nh=(t,e)=>{const{nodes:n=[]}=t,r=Oh(t,e),i=Th(r,n.length),o=new Map;return n.forEach(((t,e)=>{o.set(yh(t),i[e])})),o},Oh=(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=>yh(e)===t)),a=n.findIndex((t=>yh(t)===r));e?i[o][a]=1:(i[o][a]=1,i[a][o]=1)})),i},Th=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let a=0;a<n&&o>r;a++){const n=Array(e).fill(0);for(let r=0;r<e;r++)for(let o=0;o<e;o++)n[r]+=t[r][o]*i[o];const r=Math.sqrt(n.reduce(((t,e)=>t+e*e),0));for(let t=0;t<e;t++)n[t]/=r;o=Math.sqrt(n.reduce(((t,e,n)=>t+(e-i[n])*e),0)),i=n}return i};function Ch(t,e,n,r=Ne){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()),l=[],u=[],c=[],h=[];return s.forEach((t=>{a.has(t)?r(i.get(t),o.get(t))?h.push(o.get(t)):u.push(o.get(t)):l.push(o.get(t))})),a.forEach((t=>{s.has(t)||c.push(i.get(t))})),{enter:l,exit:c,keep:h,update:u}}function Ah(t,e,n){t.forEach((t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)}))}class Ph{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}=Ch(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=Sc(e,r);if(!i)return Tc(`The extension ${r} of ${e} is not registered.`);const o=new i(this.context,t);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.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach((({key:t})=>this.destroyExtension(t)))}destroy(){Object.values(this.extensionMap).forEach((t=>t.destroy())),this.context={},this.extensions=[],this.extensionMap={}}}class Rh{constructor(t,e){this.events=[],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 Dh extends Rh{}class Lh extends Dh{constructor(t,e){super(t,Object.assign({},Lh.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(Qc(r,this.options.padding))):n.hide.push(t)})),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=Ch(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=Eh(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(Ut(e))return t.sort(((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id))));const{node:a=[],edge:s=[],combo:l=[]}=ie(t,(t=>t.type)),u=Ut(r)?l.sort(((t,e)=>r(...o.getComboData([t.id,e.id])))):l,c=Ut(n)?a.sort(((t,e)=>n(...o.getNodeData([t.id,e.id])))):this.sortNodesByCentrality(a,n),h=Ut(i)?s.sort(((t,e)=>i(...o.getEdgeData([t.id,e.id])))):s;return[...u,...c,...h]},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&&Ah(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&Ah(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Re(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 Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Lh.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const _h=[0,0,0];function Ih(t,e){return t.map(((t,n)=>t+e[n]))}function jh(t,e){return t.map(((t,n)=>t-e[n]))}function Bh(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Fh(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function zh(t,e){return t.map((t=>t*e))}function Gh(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+Math.pow(n-e[r]||0,2)),0))}function Vh(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function Wh(t){const e=t.reduce(((t,e)=>t+Math.pow(e,2)),0);return t.map((t=>t/Math.sqrt(e)))}function Hh(t,e,n=!1){const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(Bh(t,e).reduce(((t,e)=>t+e),0)/(Gh(t,_h)*Gh(e,_h)));return n&&r<0&&(i=2*Math.PI-i),i}function Uh(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function $h(t,e){return t.map((t=>t%e))}function Yh(t){return[t[0],t[1]]}function qh(t){return 2===t.length?[t[0],t[1],0]:t}function Xh(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function Kh(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=qh(t),r=qh(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]]}(jh(n,r),jh(i,o)).every((t=>0===t))}function Zh(t,e,n=!1){if(Kh(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])),l=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||Hc(s,0,1)&&Hc(l,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Qh(t){if(Array.isArray(t))return Hc(t[0],0,1)&&Hc(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 Jh(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function td(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function ed(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,Qh(e))}function nd(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function rd(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function id(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function od(t,e,n,r=!1){if(Ne(t,e))return t;const i=Wh(r?jh(t,e):jh(e,t)),o=[i[0]*n,i[1]*n];return Ih(Yh(t),o)}function ad(t,e){return t[1]===e[1]}function sd(t,e,n){return Kh([t,e],[e,n])}function ld(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function ud(t,e,n,r=!0,i=!1){for(let o=0;o<n.length;o++){let a=n[o],s=n[(o+1)%n.length];r&&(a=Ih(e,a),s=Ih(e,s));const l=Zh([e,i?ld(t,e):t],[a,s]);if(l)return{point:l,line:[a,s]}}return{point:e,line:void 0}}function cd(t,e,n=!1){const r=e.center,i=jh(n?ld(t,r):t,e.center),o=Math.atan2(i[1],i[0]);if(isNaN(o))return r;const a=Yc(e)/2,s=qc(e)/2;return[r[0]+a*Math.cos(o),r[1]+s*Math.sin(o)]}function hd(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach((e=>{const i=function(t,e){const n=dd(t,e);return Gh(t,n)}(t,e);i<n&&(n=i,r=e)})),r}function dd(t,e){const[n,r]=e[0],[i,o]=e[1],[a,s]=t,l=i-n,u=o-r;if(0===l&&0===u)return[n,r];let c=((a-n)*l+(s-r)*u)/(l*l+u*u);c>1?c=1:c<0&&(c=0);return[n+c*l,r+c*u]}function fd(t,e=!0){const n=function(t){return Fh(t.reduce(((t,e)=>Ih(t,e)),[0,0]),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 pd(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}class gd{constructor(t,e,n){if(this.phase=e,this.pointerByTouch=[],this.initialDistance=null,this.emitter=t,gd.instance)return gd.callbacks[this.phase].push(n),gd.instance;this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.bindEvents(),gd.instance=this,gd.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)){gd.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),gd.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;gd.callbacks.pinchmove.forEach((e=>e(t,{scale:5*(o-1)})))}onPointerUp(t){var e;gd.callbacks.pinchend.forEach((e=>e(t,{scale:0}))),gd.isPinching=!1,this.initialDistance=null,this.pointerByTouch=[],null===(e=gd.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),gd.instance=null}off(t,e){const n=gd.callbacks[t].indexOf(e);n>-1&&gd.callbacks[t].splice(n,1),this.tryDestroy()}tryDestroy(){Object.values(gd.callbacks).every((t=>0===t.length))&&this.destroy()}}gd.isPinching=!1,gd.instance=null,gd.callbacks={pinchstart:[],pinchmove:[],pinchend:[]};const vd=t=>t.map((t=>ne(t)?t.toLocaleLowerCase():t));class md{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.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 gd(this.emitter,"pinchmove",this.boundHandlePinch)),this.map.set(e,n))}unbind(t,e){this.map.forEach(((n,r)=>{Ne(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}match(t){const e=vd(Array.from(this.recordKey)).sort(),n=vd(t).sort();return Ne(e,n)}bindEvents(){var e;const{emitter:n}=this;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)&&Ne(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),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,"blur",this.onFocus)}}class yd extends Dh{constructor(t,e){super(t,ke({},yd.defaultOptions,e)),this.shortcut=new md(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 Xl({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=bd(t),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(pd(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=bd(t),this.updateElementsStates(pd(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)=>(t[yh(e)]=[],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);let 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]}))}Ut(o)&&(s=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=yh(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;t<s;r=t++){const s=e[t+n][0],l=e[t+n][1],u=e[r+n][0],c=e[r+n][1];l>o!=c>o&&i<(u-s)*(o-l)/(c-l)+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(yh(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 Ut(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=ke(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}yd.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 bd=t=>[t.canvas.x,t.canvas.y],xd=.8,Ed=["node","edge","combo"];function wd(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)wd(t,e,n,r,i+1);"BT"===r&&e(t,i)}function kd(t,e,n,r,i="both"){if("combo"===e||"node"===e)return Md(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const a=Md(t,o.source,r-1,i),s=Md(t,o.target,r-1,i);return Array.from(new Set([...a,...s,n]))}function Md(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=yh(t);!o.has(e)&&i<n&&(a.add(e),o.add(e))})))}),(e=>t.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 Sd(t){return t.states||[]}class Nd extends Dh{constructor(t,e){super(t,Object.assign({},Nd.defaultOptions,e)),this.onClickSelect=t=>ze(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=>ze(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 md(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.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 kd(r,n,e.id,"function"==typeof i?i(t):i).filter((t=>t!==e.id))}updateState(t){return ze(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=Sd(a.getElementData(o.id)).includes(e)?"unselect":"select",l={},u=this.isMultipleSelect,c=[o.id],h=this.getNeighborIds(t);if(u)if(Object.assign(l,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach((t=>{const r=new Set(a.getElementState(t));r.add(e),r.delete(n),l[t]=Array.from(r)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{const i=l[t];i.includes(e)||i.includes(r)||i.includes(n)||l[t].push(n)}))}else{const t=l[o.id];l[o.id]=t.filter((t=>t!==e&&t!==r)),t.includes(n)||l[o.id].push(n),h.forEach((t=>{l[t]=l[t].filter((t=>t!==r)),l[t].includes(e)||l[t].push(n)}))}else if("select"===s){Object.assign(l,this.getClearStates(!!n));const t=(t,e)=>{t.forEach((t=>{l[t]||(l[t]=a.getElementState(t)),l[t].push(e)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{c.includes(t)||h.includes(t)||l[t].push(n)}))}else Object.assign(l,this.getClearStates());yield a.setElementState(l,i)}))}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach((t=>{i[yh(t)]=Sd(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:l}=e.getData(),u={};return[...a,...s,...l].forEach((e=>{const n=Sd(e),r=n.filter((t=>!o.has(t)));(t||r.length!==n.length)&&(u[yh(e)]=r)})),u}clearState(){return ze(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 Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function Od(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function Td(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function Cd(t,e,n=!0){if(!e)return t;if(!Td(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=he(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Ad(t,e){const n=Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Td(n,e)&&Object.assign(t,{[Cd(n,e)]:r}),t)),{});if("opacity"in t){const r=function(t,e){return`${e}${de(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 Pd(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 Rd(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 Dd(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function Ld(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 _d(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 Id(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 jd(t){const e="string"==typeof t?Sc("palette",t):t;if("function"!=typeof e)return e}function Bd(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 Fd(t,e,n=1,r=!1){const i=r?n:1;return Bd((t.max[0]-t.min[0])*i,e)}Nd.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class zd extends _l{constructor(t){Vd(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,l,u,c,h,d,f;const p=this.shapeMap[e];if(!1===r)return void(p&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,p),i.removeChild(p),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,p)));const g="string"==typeof n?Sc(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error(Oc(`Shape ${n} not found`));if(!p||p.destroyed||!(p instanceof g)){p&&(null===(l=null==o?void 0:o.beforeDestroy)||void 0===l||l.call(o,p),null==p||p.destroy(),null===(u=null==o?void 0:o.afterDestroy)||void 0===u||u.call(o,p)),null===(c=null==o?void 0:o.beforeCreate)||void 0===c||c.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(h=null==o?void 0:o.afterCreate)||void 0===h||h.call(o,t),t}return null===(d=null==o?void 0:o.beforeUpdate)||void 0===d||d.call(o,p),_g(p,r),null===(f=null==o?void 0:o.afterUpdate)||void 0===f||f.call(o,p),p}update(t={}){const e=Object.assign({},this.attributes,t);Vd(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:a,clipPath:s,component:l}=e,u=Fe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,u),r&&t.setAttribute("transform",r);ae(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);l&&t.setAttribute("component",l)}(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:l,visibility:u}=t;return Fe(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&&(Gd(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${de(r)}Style`];if(Ut(o)){const r=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)))),a=i.animate(Pc(r),e);a&&(Gd(i,a),n.push(a))}}));const r=(r,i)=>{if(!Se(r)){const o=this[`get${de(i)}Style`];if(Ut(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(Pc(o),e);t&&(Gd(a,t),n.push(t))}}))}}};this.compositeShapes.forEach((([t,e])=>{const n=Pd(this.shapeMap,e);r(n,t)}))}}return Ac(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;Ah(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function Gd(t,e){null==e||e.finished.then((()=>{const n=t.activeAnimations.findIndex((t=>t===e));n>-1&&t.activeAnimations.splice(n,1)}))}function Vd(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=_c(e,n,r,i);o&&(t.transform=o)}return t}class Wd extends zd{constructor(t){super(_d({style:Wd.defaultStyleProps},t))}isTextStyle(t){return Td(t,"label")}isBackgroundStyle(t){return Td(t,"background")}getTextStyle(t){const e=this.getGraphicStyle(t),{padding:n}=e;return Rd(Fe(e,["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Ad(e,"background"),{min:[a,s],center:[l,u],halfExtents:[c,h]}=this.shapeMap.text.getGeometryBounds(),[d,f,p,g]=Uc(i),v=2*c+g+f,{width:m,height:y}=o;m&&y?Object.assign(o,{x:l-Number(m)/2,y:u-Number(y)/2}):Object.assign(o,{x:a-g,y:s-d,width:n?Math.min(v,r+g+f):v,height:2*h+d+p});const{radius:b}=o;if("string"==typeof b&&b.endsWith("%")){const t=Number(b.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Zl,this.getTextStyle(t),e),this.upsert("background",Xl,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}Wd.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 Hd extends zd{constructor(t){super(_d({style:Hd.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",Wd,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}Hd.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const Ud={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 $d(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 Ud?r=t:e.unshift(t),i={type:r},Ud[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<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])})),e}const Yd=t=>{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<t.length-2;e+=1){const[n,r]=t[e-1],[i,a]=t[e],[s,l]=t[e+1],[u,c]=e!==t.length-2?t[e+2]:[s,l],h=i+(s-n)/6,d=a+(l-r)/6,f=s-(u-i)/6,p=l-(c-a)/6;o.push(["C",h,d,f,p,s,l])}return o};class qd extends zd{constructor(t){super(_d({style:qd.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{maxWidth:n,offsetX:r,offsetY:i,autoRotate:o,placement:a,closeToPath:s}=e,l=Fe(e,["maxWidth","offsetX","offsetY","autoRotate","placement","closeToPath"]),u=this.shapeMap.key,c=null==u?void 0:u.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,a){const[s,l]=ed(t,e),u={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:[["translate",s+n,l+r]]};if("center"===e||!i)return u;const c=$d(o);if(!c||c.length<=3)return u;const h=c.map(((t,e)=>{const n=t,r=c[(e+1)%c.length];return Ne(n,r)?null:[n,r]})).filter(Boolean),d=hd([s,l],h),f=dd([s,l],d);if(f&&d&&(u.transform=[["translate",f[0]+n,f[1]+r]],a)){const t=Math.atan((d[0][1]-d[1][1])/(d[0][0]-d[1][0]));u.transform.push(["rotate",t/Math.PI*180]),u.textAlign="center","right"!==e&&"left"!==e||(u.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return u}(c,a,r,i,s,t.d,o),{wordWrapWidth:Fd(c,n)},l)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",Hl,this.getKeyStyle(t),e),this.upsert("label",Wd,this.getLabelStyle(t),e)}}qd.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let Xd=class extends zl{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Zd=this,this.isMutationObserved=!0,this.addEventListener(Vs.MOUNTED,this.onMounted),this.addEventListener(Vs.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 Xl({style:a});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const Kd=new WeakMap;let Zd=null;const Qd=t=>{if(Zd&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Zd).includes(t)){const e=Kd.get(t);e?e.includes(Zd)||e.push(Zd):Kd.set(t,[Zd])}},Jd=t=>{const e=Kd.get(t);e&&e.forEach((t=>t.handleRadius()))};class tf extends zd{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()?Xd:Zl,this.getIconStyle(t),e)}}class ef extends zd{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 nf extends ef{constructor(t){super(_d({style:nf.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return Dd(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(Rd(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,a=Fe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(Lg(s,n,i,o),{wordWrapWidth:Fd(s,r)},a)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Fe(e,["fill"]),i=Ad(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=Ad(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=Dd(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=Pd(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=Fe(t,["badges","badgePalette","opacity"]),l=jd(o),u=Ad(this.getGraphicStyle(s),"badge");return i.forEach(((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:l?l[e%(null==l?void 0:l.length)]:void 0,opacity:a},u),this.getBadgeStyle(t))})),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Fe(t,["placement","offsetX","offsetY"]),a=Lg(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=Ad(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(Tg(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 Ng(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();Ah(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return Pd(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return ud(t,ed(e,"center"),[ed(e,"left-top"),ed(e,"right-top"),ed(e,"right-bottom"),ed(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",tf,n,e),Qd(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{const r=n[t];this.upsert(`badge-${t}`,Hd,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,Dl,r,e)}))}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Wd,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)&&Jd(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}nf.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 rf=class t extends nf{constructor(e){super(_d({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",Dl,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*xd;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}};rf.defaultStyleProps={size:32};class of extends nf{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",$l,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 ud(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 af extends of{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 sf extends rf{constructor(t){super(_d({style:sf.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...Dd(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return ne(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=>ae(t)?{value:t}:t)),i=Ad(this.getGraphicStyle(t),"donut"),o=jd(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(),l=this.parseInnerR();let u=0;r.forEach(((t,n)=>{const{value:c=0,color:h=o[n%o.length]}=t,d=Fe(t,["value","color"]),f=360*(0===a?1/r.length:c/a);this.upsert(`round${n}`,Hl,Object.assign(Object.assign(Object.assign({},i),{d:uf(s,l,u,u+f),fill:h}),d),e),u+=f}))}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}sf.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const lf=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],uf=(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],l=[lf(t,e,r,a),lf(t,e,n,a),lf(t,e,n,s),lf(t,e,r,s)],u=s-a>Math.PI?1:0;return[["M",l[0][0],l[0][1]],["L",l[1][0],l[1][1]],["A",n,n,0,u,1,l[2][0],l[2][1]],["L",l[3][0],l[3][1]],["A",r,r,0,u,0,l[0][0],l[0][1]],["Z"]]})(i,o,t,e,n,r)};class cf extends nf{constructor(t){super(_d({style:cf.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Il,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)*xd;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}}cf.defaultStyleProps={size:[45,35]};class hf extends of{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)*xd;return!!e&&Object.assign({width:n,height:n},e)}}
18
+ var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return y(e,t),u(e)}(Ts),pu=0,gu=function(){return u((function t(e,n){var r;s(this,t),this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=e,e.animation=this,this.timeline=n,this.id="".concat(pu++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(r=this.effect)||void 0===r?void 0:r.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}),[{key:"pending",get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending}},{key:"playState",get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"}},{key:"ready",get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise((function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}})),this.pending||this.resolveReadyPromise()),this.readyPromise}},{key:"finished",get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise((function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}})),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise}},{key:"currentTime",get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){if(t=Number(t),!isNaN(t)){var e;if(this.timeline.restart(),!this._paused&&null!==this._startTime)this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate;this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this))}}},{key:"startTime",get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}}},{key:"_isFinished",get:function(){return!this._idle&&(this._playbackRate>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=this.oldPlayState,e=this.pending?"pending":this.playState;return this.readyPromise&&e!==t&&("idle"===e?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===t?this.resolveReadyPromise():"pending"===e&&(this.readyPromise=void 0)),this.finishedPromise&&e!==t&&("idle"===e?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===e?this.resolveFinishedPromise():"finished"===t&&(this.finishedPromise=void 0)),this.oldPlayState=e,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=0,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new fu(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(br)}},{key:"addEventListener",value:function(t,e,n){throw new Error(br)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(br)}},{key:"dispatchEvent",value:function(t){throw new Error(br)}},{key:"commitStyles",value:function(){throw new Error(br)}},{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 fu(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 fu(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),vu=.1,mu="function"==typeof Float32Array,yu=function(t,e){return 1-3*e+3*t},bu=function(t,e){return 3*e-6*t},xu=function(t){return 3*t},Eu=function(t,e,n){return((yu(e,n)*t+bu(e,n))*t+xu(e))*t},wu=function(t,e,n){return 3*yu(e,n)*t*t+2*bu(e,n)*t+xu(e)},ku=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=mu?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Eu(o*vu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=vu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*vu,s=wu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=wu(e,n,r);if(0===o)return e;e-=(Eu(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=Eu(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+vu,t,n)};return function(t){return 0===t||1===t?t:Eu(a(t),e,r)}},Mu=function(t){return Math.pow(t,2)},Su=function(t){return Math.pow(t,3)},Nu=function(t){return Math.pow(t,4)},Ou=function(t){return Math.pow(t,5)},Tu=function(t){return Math.pow(t,6)},Cu=function(t){return 1-Math.cos(t*Math.PI/2)},Au=function(t){return 1-Math.sqrt(1-t*t)},Pu=function(t){return t*t*(3*t-2)},Ru=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)},Du=function(t){var e=b(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=oe(Number(r),1,10),s=oe(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)},Lu=function(t){var e=arguments.length>2?arguments[2]:void 0,n=b(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],l=void 0===s?10:s,u=n[3],c=void 0===u?0:u;i=oe(i,.1,1e3),a=oe(a,.1,1e3),l=oe(l,.1,1e3),c=oe(c,.1,1e3);var h=Math.sqrt(a/i),d=l/(2*Math.sqrt(a*i)),f=d<1?h*Math.sqrt(1-d*d):0,p=d<1?(d*h-c)/f:-c+h,g=e?e*t/1e3:t;return g=d<1?Math.exp(-g*d*h)*(1*Math.cos(f*g)+p*Math.sin(f*g)):(1+p*g)*Math.exp(-g*h),0===t||1===t?t:1-g},_u=function(t){var e=b(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)(oe(t,0,1)*r)/r},Iu=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return ku(n,r,i,o)(t)},ju=ku(.42,0,1,1),Bu=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)}},Fu=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}},zu=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}},Gu={steps:_u,"step-start":function(t){return _u(t,[1,"start"])},"step-end":function(t){return _u(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Iu,ease:function(t){return Iu(t,[.25,.1,.25,1])},in:ju,out:Bu(ju),"in-out":Fu(ju),"out-in":zu(ju),"in-quad":Mu,"out-quad":Bu(Mu),"in-out-quad":Fu(Mu),"out-in-quad":zu(Mu),"in-cubic":Su,"out-cubic":Bu(Su),"in-out-cubic":Fu(Su),"out-in-cubic":zu(Su),"in-quart":Nu,"out-quart":Bu(Nu),"in-out-quart":Fu(Nu),"out-in-quart":zu(Nu),"in-quint":Ou,"out-quint":Bu(Ou),"in-out-quint":Fu(Ou),"out-in-quint":zu(Ou),"in-expo":Tu,"out-expo":Bu(Tu),"in-out-expo":Fu(Tu),"out-in-expo":zu(Tu),"in-sine":Cu,"out-sine":Bu(Cu),"in-out-sine":Fu(Cu),"out-in-sine":zu(Cu),"in-circ":Au,"out-circ":Bu(Au),"in-out-circ":Fu(Au),"out-in-circ":zu(Au),"in-back":Pu,"out-back":Bu(Pu),"in-out-back":Fu(Pu),"out-in-back":zu(Pu),"in-bounce":Ru,"out-bounce":Bu(Ru),"in-out-bounce":Fu(Ru),"out-in-bounce":zu(Ru),"in-elastic":Du,"out-elastic":Bu(Du),"in-out-elastic":Fu(Du),"out-in-elastic":zu(Du),spring:Lu,"spring-in":Lu,"spring-out":Bu(Lu),"spring-in-out":Fu(Lu),"spring-out-in":zu(Lu)},Vu=function(t){return t};function Wu(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Hu="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",Uu=new RegExp("cubic-bezier\\(".concat(Hu,",").concat(Hu,",").concat(Hu,",").concat(Hu,"\\)")),$u=/steps\(\s*(\d+)\s*\)/,Yu=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function qu(t){var e=Uu.exec(t);if(e)return ku.apply(void 0,d(e.slice(1).map(Number)));var n=$u.exec(t);if(n)return Wu(Number(n[1]),0);var r=Yu.exec(t);return r?Wu(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Gu[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)]||Gu.linear}function Xu(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 Ku(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e<Math.min(n.delay,r)?1: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),l=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),u=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,l,s);return n.currentIteration=l,n.progress=u,n.easingFunction(u)}function Zu(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Qu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:qu(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var a=o,s=o+1,l=i[a].computedOffset,u=i[s].computedOffset,c=l,h=u;0===o&&(c=-1/0,0===u&&(s=a)),o===i.length-2&&(h=1/0,1===l&&(a=s)),n.push({applyFrom:c,applyTo:h,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:tc(r,i[a].value,i[s].value,e)})}return n.sort((function(t,e){return t.startOffset-e.startOffset})),n}(r,n);return function(t,e){if(null!==e)i.filter((function(t){return e>=t.applyFrom&&e<t.applyTo})).forEach((function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Qu(n)&&t.setAttribute(n,null)}}function Qu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Ju=function(t,e,n){return function(r){var i=ec(t,e,r);return ae(i)?i:n(i)}};function tc(t,e,n,r){var i=ga[t];if(i&&i.syntax&&i.int){var o=bl.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=o.parser,s=a?a(e,r):e,l=a?a(n,r):n,u=o.mixer(s,l,r);if(u){var c=Ju.apply(void 0,d(u));return function(t){return 0===t?e:1===t?n:c(t)}}}}return Ju(!1,!0,(function(t){return t?n:e}))}function ec(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),a=[],s=0;s<o;s++)a.push(ec(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments ".concat(t,":").concat(e))}var nc=function(){return u((function t(){s(this,t),this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Vu,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}),[{key:"easing",get:function(){return this._easing},set:function(t){this.easingFunction=qu(t),this._easing=t}}])}();function rc(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var a={};"offset"in t&&(a.offset=Number(t.offset)),"easing"in t&&(a.easing=t.easing),"composite"in t&&(a.composite=t.composite),e[o]=a}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort((function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)})),e}(t));for(var n=t.map((function(t){var n={};for(var r in null!=e&&e.composite&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)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<n.length;o++){var a=n[o].offset;if($t(a))r=!1;else{if(a<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=a}}return n=n.filter((function(t){return Number(t.offset)>=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;a<r;a++){var s=n[a].computedOffset;if(!$t(s)&&!$t(o)){for(var l=1;l<a-i;l++)n[i+l].computedOffset=o+(Number(s)-o)*l/(a-i);i=a,o=Number(s)}}}(),n}var ic="backwards|forwards|both|none".split("|"),oc="reverse|alternate|alternate-reverse".split("|");function ac(t,e){return function(t){var e=new nc;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(n){if(void 0!==t[n]&&null!==t[n]&&"auto"!==t[n]){if(("number"==typeof e[n]||"duration"===n)&&("number"!=typeof t[n]||isNaN(t[n])))return;if("fill"===n&&-1===ic.indexOf(t[n]))return;if("direction"===n&&-1===oc.indexOf(t[n]))return;e[n]=t[n]}})):e.duration=t,e}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}))}var sc=function(){return u((function t(e,n,r){var i=this;s(this,t),this.composite="replace",this.iterationComposite="replace",this.target=e,this.timing=ac(r),this.timing.effect=this,this.timing.activeDuration=Xu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=rc(n,this.timing),this.interpolations=Zu(this.normalizedKeyframes,this.timing,this.target);var o=bl.globalThis.Proxy;this.computedTiming=o?new o(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?i.animation&&i.animation.currentTime||null:"currentIteration"===e?i.animation&&"running"===i.animation.playState?t.currentIteration||0:null:"progress"===e?i.animation&&"running"===i.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}),[{key:"applyInterpolations",value:function(){this.interpolations(this.target,Number(this.timeFraction))}},{key:"update",value:function(t){return null!==t&&(this.timeFraction=Ku(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)}},{key:"getKeyframes",value:function(){return this.normalizedKeyframes}},{key:"setKeyframes",value:function(t){this.normalizedKeyframes=rc(t)}},{key:"getComputedTiming",value:function(){return this.computedTiming}},{key:"getTiming",value:function(){return this.timing}},{key:"updateTiming",value:function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))}}])}();function lc(t,e){return Number(t.id)-Number(e.id)}var uc=function(){return u((function t(e){var n=this;s(this,t),this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){n.currentTime=t,n.discardAnimations(),0===n.animations.length?n.timelineTicking=!1:n.requestAnimationFrame(n.webAnimationsNextTick)},this.processRafCallbacks=function(t){var e=n.rafCallbacks;n.rafCallbacks=[],t<Number(n.currentTime)&&(t=Number(n.currentTime)),n.animations.sort(lc),n.animations=n.tick(t,!0,n.animations)[0],e.forEach((function(e){e[1](t)})),n.applyPendingEffects()},this.document=e}),[{key:"getAnimations",value:function(){return this.discardAnimations(),this.animations.slice()}},{key:"isTicking",value:function(){return this.inTick}},{key:"play",value:function(t,e,n){var r=new sc(t,e,n),i=new gu(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i}},{key:"applyDirtiedAnimation",value:function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(lc),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach((function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)})),this.applyPendingEffects()}}},{key:"restart",value:function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame}},{key:"destroy",value:function(){this.document.defaultView.cancelAnimationFrame(this.frameId)}},{key:"applyPendingEffects",value:function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]}},{key:"updateAnimationsPromises",value:function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))}},{key:"discardAnimations",value:function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))}},{key:"restartWebAnimationsNextTick",value:function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))}},{key:"rAF",value:function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e}},{key:"requestAnimationFrame",value:function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))}},{key:"tick",value:function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],l=[],u=[];return n.forEach((function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(a.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?l.push(n):u.push(n)})),(r=this.pendingEffects).push.apply(r,a),(i=this.pendingEffects).push.apply(i,s),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[l,u]}}])}();bl.EasingFunction=qu,bl.AnimationTimeline=uc;const cc={duration:500},hc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var dc,fc,pc,gc,vc,mc,yc,bc,xc;!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"}(dc||(dc={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(fc||(fc={})),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,(pc=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",pc.DBLCLICK="combo:dblclick",pc.POINTER_OVER="combo:pointerover",pc.POINTER_LEAVE="combo:pointerleave",pc.POINTER_ENTER="combo:pointerenter",pc.POINTER_MOVE="combo:pointermove",pc.POINTER_OUT="combo:pointerout",pc.POINTER_DOWN="combo:pointerdown",pc.POINTER_UP="combo:pointerup",pc.CONTEXT_MENU="combo:contextmenu",pc.DRAG_START="combo:dragstart",pc.DRAG="combo:drag",pc.DRAG_END="combo:dragend",pc.DRAG_ENTER="combo:dragenter",pc.DRAG_OVER="combo:dragover",pc.DRAG_LEAVE="combo:dragleave",pc.DROP="combo:drop",t.CommonEvent=void 0,(gc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",gc.DBLCLICK="dblclick",gc.POINTER_OVER="pointerover",gc.POINTER_LEAVE="pointerleave",gc.POINTER_ENTER="pointerenter",gc.POINTER_MOVE="pointermove",gc.POINTER_OUT="pointerout",gc.POINTER_DOWN="pointerdown",gc.POINTER_UP="pointerup",gc.CONTEXT_MENU="contextmenu",gc.DRAG_START="dragstart",gc.DRAG="drag",gc.DRAG_END="dragend",gc.DRAG_ENTER="dragenter",gc.DRAG_OVER="dragover",gc.DRAG_LEAVE="dragleave",gc.DROP="drop",gc.KEY_DOWN="keydown",gc.KEY_UP="keyup",gc.WHEEL="wheel",gc.PINCH="pinch",t.ContainerEvent=void 0,(vc=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",vc.KEY_UP="keyup",t.EdgeEvent=void 0,(mc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",mc.DBLCLICK="edge:dblclick",mc.POINTER_OVER="edge:pointerover",mc.POINTER_LEAVE="edge:pointerleave",mc.POINTER_ENTER="edge:pointerenter",mc.POINTER_MOVE="edge:pointermove",mc.POINTER_OUT="edge:pointerout",mc.POINTER_DOWN="edge:pointerdown",mc.POINTER_UP="edge:pointerup",mc.CONTEXT_MENU="edge:contextmenu",mc.DRAG_ENTER="edge:dragenter",mc.DRAG_OVER="edge:dragover",mc.DRAG_LEAVE="edge:dragleave",mc.DROP="edge:drop",t.GraphEvent=void 0,(yc=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",yc.AFTER_CANVAS_INIT="aftercanvasinit",yc.BEFORE_SIZE_CHANGE="beforesizechange",yc.AFTER_SIZE_CHANGE="aftersizechange",yc.BEFORE_ELEMENT_CREATE="beforeelementcreate",yc.AFTER_ELEMENT_CREATE="afterelementcreate",yc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",yc.AFTER_ELEMENT_UPDATE="afterelementupdate",yc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",yc.AFTER_ELEMENT_DESTROY="afterelementdestroy",yc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",yc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",yc.BEFORE_DRAW="beforedraw",yc.AFTER_DRAW="afterdraw",yc.BEFORE_RENDER="beforerender",yc.AFTER_RENDER="afterrender",yc.BEFORE_ANIMATE="beforeanimate",yc.AFTER_ANIMATE="afteranimate",yc.BEFORE_LAYOUT="beforelayout",yc.AFTER_LAYOUT="afterlayout",yc.BEFORE_STAGE_LAYOUT="beforestagelayout",yc.AFTER_STAGE_LAYOUT="afterstagelayout",yc.BEFORE_TRANSFORM="beforetransform",yc.AFTER_TRANSFORM="aftertransform",yc.BATCH_START="batchstart",yc.BATCH_END="batchend",yc.BEFORE_DESTROY="beforedestroy",yc.AFTER_DESTROY="afterdestroy",yc.BEFORE_RENDERER_CHANGE="beforerendererchange",yc.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(bc=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",bc.REDO="redo",bc.CANCEL="cancel",bc.ADD="add",bc.CLEAR="clear",bc.CHANGE="change",t.NodeEvent=void 0,(xc=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",xc.DBLCLICK="node:dblclick",xc.POINTER_OVER="node:pointerover",xc.POINTER_LEAVE="node:pointerleave",xc.POINTER_ENTER="node:pointerenter",xc.POINTER_MOVE="node:pointermove",xc.POINTER_OUT="node:pointerout",xc.POINTER_DOWN="node:pointerdown",xc.POINTER_UP="node:pointerup",xc.CONTEXT_MENU="node:contextmenu",xc.DRAG_START="node:dragstart",xc.DRAG="node:drag",xc.DRAG_END="node:dragend",xc.DRAG_ENTER="node:dragenter",xc.DRAG_OVER="node:dragover",xc.DRAG_LEAVE="node:dragleave",xc.DROP="node:drop";const Ec="combo",wc="tree";var kc;t.ExtensionCategory=void 0,(kc=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",kc.EDGE="edge",kc.COMBO="combo",kc.THEME="theme",kc.PALETTE="palette",kc.LAYOUT="layout",kc.BEHAVIOR="behavior",kc.PLUGIN="plugin",kc.ANIMATION="animation",kc.TRANSFORM="transform",kc.SHAPE="shape";const Mc={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Sc(t,e){var n;const r=null===(n=Mc[t])||void 0===n?void 0:n[e];if(r)return r}const Nc="5.0.46";function Oc(t){return`[G6 v${Nc}] ${t}`}const Tc=t=>{console.warn(Oc(t))};function Cc(e){const{theme:n}=e;if(!n)return{};const r=Sc(t.ExtensionCategory.THEME,n);return r||(Tc(`The theme of ${n} is not registered.`),{})}function Ac(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 Pc(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=>$t(t)))||r.every((t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&Ne(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 Rc(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 Dc(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},cc);return qt(n)&&Object.assign(r,n),qt(e)&&Object.assign(r,e),r}function Lc(e,n,r,i){var o,a;const{animation:s}=e;if(!1===s||!1===i)return[];const l=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===l)return[];const u=null==l?void 0:l[r];if(!1===u)return[];const c=null===(a=Cc(e)[n])||void 0===a?void 0:a.animation,h=(e=[])=>function(e){if("string"==typeof e){return Sc(t.ExtensionCategory.ANIMATION,e)||(Tc(`The animation of ${e} is not registered.`),[])}return e}(e).map((t=>Object.assign(Object.assign(Object.assign(Object.assign({},hc),qt(s)&&s),t),qt(i)&&i)));if(u)return h(u);if(!c)return[];const d=c[r];return!1===d?[]:h(d)}function _c(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<r.length;a++){const s=r[a];if("translate"===s[0]){if(s[1]===t&&s[2]===e)return null;i=a,o.push(["translate",t,e])}else if("translate3d"===s[0]){if(s[1]===t&&s[2]===e&&s[3]===n)return null;i=a,o.push(["translate3d",t,e,null!=n?n:0])}else o.push(s)}return-1===i&&o.splice(0,0,ae(n)?["translate3d",t,e,null!=n?n:0]:["translate",t,e]),0===o.length?null:o}const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Ic=(t,e,n)=>{if(!n.length)return null;const[r,i]=e;let o;const a=n.map((e=>{var{fields:n,shape:a,states:s}=e,l=Fe(e,["fields","shape","states"]);const u=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const a=`get${de(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(!u)return null;const{shape:c,fromStyle:h,toStyle:d}=u,f=[{},{}];if(n.forEach((t=>{var e,n;Object.assign(f[0],{[t]:null!==(e=h[t])&&void 0!==e?e:Rc(t)}),Object.assign(f[1],{[t]:null!==(n=d[t])&&void 0!==n?n:Rc(t)})})),f.some((t=>Object.keys(t).some((t=>["x","y","z"].includes(t)))))){const{x:t=0,y:e=0,z:n,transform:r=""}=c.attributes||{};f.forEach((i=>{var o,a,s;i.transform=_c(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 p=c.animate(Pc(f),l);return void 0===a&&(o=p),p})).filter(Boolean),s=o||(null==a?void 0:a[0]);return s?Ac(s,a.filter((t=>t!=t))):null},jc=[{fields:["x","y"]}],Bc=jc,Fc=[{fields:["sourceNode","targetNode"]}],zc=Fc,Gc=[{fields:["childrenNode","x","y"]}],Vc=Gc;function Wc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function Hc(t,e,n){return t>=e&&t<=n}function Uc(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 $c(t=0){const e=Uc(t);return e[0]+e[2]}function Yc(t){return t.max[0]-t.min[0]}function qc(t){return t.max[1]-t.min[1]}function Xc(t){return[Yc(t),qc(t)]}function Kc(t,e){const n=Wc(t)?Zc(t):t.getShape("key").getBounds();return e?Qc(n,e):n}function Zc(t){const[e,n,r=0]=t,i=new fr;return i.setMinMax([e,n,r],[e,n,r]),i}function Qc(t,e){const[n,r,i,o]=Uc(e),[a,s,l]=t.min,[u,c,h]=t.max,d=new fr;return d.setMinMax([a-o,s-n,l],[u+r,c+i,h]),d}function Jc(t){if(0===t.length)return new fr;if(1===t.length)return t[0];const e=new fr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function th(t,e){return Hc(t[0],e.min[0],e.max[0])&&Hc(t[1],e.min[1],e.max[1])}function eh(t,e,n=!1){const{min:[r,i],max:[o,a]}=e,s=(t[1]===i||t[1]===a)&&(n||Hc(t[0],r,o)),l=(t[0]===r||t[0]===o)&&(n||Hc(t[1],i,a));return s||l}function nh(t,e){const{center:n}=e;return t[0]===n[0]&&t[1]===n[1]}function rh(t,e){const[n,r]=t,[i,o]=e.min,[a,s]=e.max,l=n-i,u=a-n,c=r-o,h=s-r,d=Math.min(l,u,c,h);return d===l?"left":d===u?"right":d===c?"top":d===h?"bottom":"left"}function ih(t,e){const n=me(t);if(th(t,e)){switch(rh(t,e)){case"left":n[0]=e.min[0];break;case"right":n[0]=e.max[0];break;case"top":n[1]=e.min[1];break;case"bottom":n[1]=e.max[1]}}else{const[r,i]=t,[o,a]=e.min,[s,l]=e.max;n[0]=Hc(r,o,s)?r:r<o?o:s,n[1]=Hc(i,a,l)?i:i<a?a:l}return n}var oh=function(t,e){return t===e},ah=function(){function t(t,e){void 0===e&&(e=null),this.value=t,this.next=e}return t.prototype.toString=function(t){return t?t(this.value):"".concat(this.value)},t}(),sh=function(){function t(t){void 0===t&&(t=oh),this.head=null,this.tail=null,this.compare=t}return t.prototype.prepend=function(t){var e=new ah(t,this.head);return this.head=e,this.tail||(this.tail=e),this},t.prototype.append=function(t){var e=new ah(t);return this.head?(this.tail.next=e,this.tail=e,this):(this.head=e,this.tail=e,this)},t.prototype.delete=function(t){if(!this.head)return null;for(var e=null;this.head&&this.compare(this.head.value,t);)e=this.head,this.head=this.head.next;var n=this.head;if(null!==n)for(;n.next;)this.compare(n.next.value,t)?(e=n.next,n.next=n.next.next):n=n.next;return this.compare(this.tail.value,t)&&(this.tail=n),e},t.prototype.find=function(t){var e=t.value,n=void 0===e?void 0:e,r=t.callback,i=void 0===r?void 0:r;if(!this.head)return null;for(var o=this.head;o;){if(i&&i(o.value))return o;if(void 0!==n&&this.compare(o.value,n))return o;o=o.next}return null},t.prototype.deleteTail=function(){var t=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,t;for(var e=this.head;e.next;)e.next.next?e=e.next:e.next=null;return this.tail=e,t},t.prototype.deleteHead=function(){if(!this.head)return null;var t=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),t},t.prototype.fromArray=function(t){var e=this;return t.forEach((function(t){return e.append(t)})),this},t.prototype.toArray=function(){for(var t=[],e=this.head;e;)t.push(e),e=e.next;return t},t.prototype.reverse=function(){for(var t=this.head,e=null,n=null;t;)n=t.next,t.next=e,e=t,t=n;this.tail=this.head,this.head=e},t.prototype.toString=function(t){return void 0===t&&(t=void 0),this.toArray().map((function(e){return e.toString(t)})).toString()},t}(),lh=function(t,e,n){void 0===e&&(e=[]);var r=e.filter((function(e){return e.source===t||e.target===t}));if("target"===n){return r.filter((function(e){return e.source===t})).map((function(t){return t.target}))}if("source"===n){return r.filter((function(e){return e.target===t})).map((function(t){return t.source}))}return r.map((function(e){return e.source===t?e.target:e.source}))},uh={}.toString,ch=function(t,e){return uh.call(t)==="[object "+e+"]"},hh=function(t){return ch(t,"Function")},dh=function(t){return Array.isArray?Array.isArray(t):ch(t,"Array")};var fh,ph=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return function(t,e){var n,r;if(t)if(dh(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var a in t)if(t.hasOwnProperty(a)&&!1===e(t[a],a))break}(t,(function(n,r){hh(t)&&"prototype"===r||e.push(n)})),e};!function(t,e){if(!hh(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};n.cache=new Map}((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return fh||(fh=document.createElement("canvas").getContext("2d")),fh.font=[o,a,i,n+"px",r].join(" "),fh.measureText(function(t){return ch(t,"String")}(t)?t:"").width}),(function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}([t],ph(e)).join("")}));function gh(t,e,n,r){if(t===e)return[t];if(r[e])return r[e];for(var i=[],o=0,a=n[e];o<a.length;o++){var s=gh(t,a[o],n,r);if(!s)return;for(var l=0,u=s;l<u.length;l++){var c=u[l];dh(c)?i.push(We(We([],c,!0),[e],!1)):i.push([c,e])}}return r[e]=i,r[e]}var vh,mh=function(t,e,n,r,i){var o=function(t,e,n,r){var i=t.nodes,o=void 0===i?[]:i,a=t.edges,s=void 0===a?[]:a,l={},u={},c={};o.forEach((function(t,n){var r=t.id;u[r]=1/0,r===e&&(u[r]=0)}));for(var h=o.length,d=function(t){var e=function(t,e,n){for(var r,i=1/0,o=0;o<e.length;o++){var a=e[o].id;!n[a]&&t[a]<=i&&(i=t[a],r=e[o])}return r}(u,o,l),i=e.id;if(l[i]=!0,u[i]===1/0)return"continue";var a=[];a=n?function(t,e){return e.filter((function(e){return e.source===t}))}(i,s):function(t,e){return e.filter((function(e){return e.source===t||e.target===t}))}(i,s),a.forEach((function(t){var n=t.target,o=t.source,a=n===i?o:n,s=r&&t[r]?t[r]:1;u[a]>u[e.id]+s?(u[a]=u[e.id]+s,c[a]=[e.id]):u[a]===u[e.id]+s&&c[a].push(e.id)}))},f=0;f<h;f++)d();c[e]=[e];var p={};for(var g in u)u[g]!==1/0&&gh(e,g,c,p);var v={};for(var g in p)v[g]=p[g][0];return{length:u,path:v,allPath:p}}(t,e,r,i),a=o.length,s=o.path,l=o.allPath;return{length:a[n],path:s[n],allPath:l[n]}};!function(t){t.EuclideanDistance="euclideanDistance"}(vh||(vh={}));function yh(t){if(void 0!==t.id)return t.id;if(void 0!==t.source&&void 0!==t.target)return`${t.source}-${t.target}`;throw new Error(Oc("The datum does not have available id."))}function bh(t){return t.combo}function xh(t,e){const n={nodes:(t.nodes||[]).map(yh),edges:(t.edges||[]).map(yh),combos:(t.combos||[]).map(yh)};return e?Object.values(n).flat():n}!function(){function t(t){void 0===t&&(t=10),this.linkedList=new sh,this.maxStep=t}Object.defineProperty(t.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),t.prototype.isEmpty=function(){return!this.linkedList.head},t.prototype.isMaxStack=function(){return this.toArray().length>=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 Eh=(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(yh(t),n.direction).length;i.set(yh(t),r)})),i}case"betweenness":return kh(t,n.directed,n.weightPropertyName);case"closeness":return Mh(t,n.directed,n.weightPropertyName);case"eigenvector":return Nh(t,n.directed);case"pagerank":return Sh(t,n.epsilon,n.linkProb);default:return wh(t)}},wh=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach((t=>{n.set(yh(t),0)})),n},kh=(t,e,n)=>{const r=wh(t),{nodes:i=[]}=t;return i.forEach((o=>{i.forEach((i=>{if(o!==i){const{allPath:a}=mh(t,yh(o),yh(i),e,n),s=a.length;a.flat().forEach((t=>{t!==yh(o)&&t!==yh(i)&&r.set(t,r.get(t)+1/s)}))}}))})),r},Mh=(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}=mh(t,yh(o),yh(i),e,n);r+=a}return r}),0);r.set(yh(o),1/a)})),r},Sh=(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,l=void 0===s?[]:s,u=t.edges,c=void 0===u?[]:u,h=l.length,d={},f={},p=0;p<h;++p)d[v=(E=l[p]).id]=1/h,f[v]=1/h;for(var g=function(t){var e={},n=t.nodes,r=void 0===n?[]:n,i=t.edges,o=void 0===i?[]:i;return r.forEach((function(t){e[t.id]={degree:0,inDegree:0,outDegree:0}})),o.forEach((function(t){e[t.source].degree++,e[t.source].outDegree++,e[t.target].degree++,e[t.target].inDegree++})),e}(t);a>0&&i>e;){for(o=0,p=0;p<h;++p){var v=(E=l[p]).id;if(r=0,0===g[E.id].inDegree)d[v]=0;else{for(var m=lh(v,c,"source"),y=0;y<m.length;++y){var b=m[y],x=g[b].outDegree;x>0&&(r+=f[b]/x)}d[v]=n*r,o+=d[v]}}for(o=(1-o)/h,i=0,p=0;p<h;++p){var E;r=d[v=(E=l[p]).id]+o,i+=Math.abs(r-f[v]),f[v]=r}a-=1}return f}(t,e,n);return null===(r=t.nodes)||void 0===r||r.forEach((t=>{i.set(yh(t),o[yh(t)])})),i},Nh=(t,e)=>{const{nodes:n=[]}=t,r=Oh(t,e),i=Th(r,n.length),o=new Map;return n.forEach(((t,e)=>{o.set(yh(t),i[e])})),o},Oh=(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=>yh(e)===t)),a=n.findIndex((t=>yh(t)===r));e?i[o][a]=1:(i[o][a]=1,i[a][o]=1)})),i},Th=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let a=0;a<n&&o>r;a++){const n=Array(e).fill(0);for(let r=0;r<e;r++)for(let o=0;o<e;o++)n[r]+=t[r][o]*i[o];const r=Math.sqrt(n.reduce(((t,e)=>t+e*e),0));for(let t=0;t<e;t++)n[t]/=r;o=Math.sqrt(n.reduce(((t,e,n)=>t+(e-i[n])*e),0)),i=n}return i};function Ch(t,e,n,r=Ne){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()),l=[],u=[],c=[],h=[];return s.forEach((t=>{a.has(t)?r(i.get(t),o.get(t))?h.push(o.get(t)):u.push(o.get(t)):l.push(o.get(t))})),a.forEach((t=>{s.has(t)||c.push(i.get(t))})),{enter:l,exit:c,keep:h,update:u}}function Ah(t,e,n){t.forEach((t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)}))}class Ph{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}=Ch(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=Sc(e,r);if(!i)return Tc(`The extension ${r} of ${e} is not registered.`);const o=new i(this.context,t);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.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach((({key:t})=>this.destroyExtension(t)))}destroy(){Object.values(this.extensionMap).forEach((t=>t.destroy())),this.context={},this.extensions=[],this.extensionMap={}}}class Rh{constructor(t,e){this.events=[],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 Dh extends Rh{}class Lh extends Dh{constructor(t,e){super(t,Object.assign({},Lh.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(Qc(r,this.options.padding))):n.hide.push(t)})),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=Ch(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=Eh(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(Ut(e))return t.sort(((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id))));const{node:a=[],edge:s=[],combo:l=[]}=ie(t,(t=>t.type)),u=Ut(r)?l.sort(((t,e)=>r(...o.getComboData([t.id,e.id])))):l,c=Ut(n)?a.sort(((t,e)=>n(...o.getNodeData([t.id,e.id])))):this.sortNodesByCentrality(a,n),h=Ut(i)?s.sort(((t,e)=>i(...o.getEdgeData([t.id,e.id])))):s;return[...u,...c,...h]},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&&Ah(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&Ah(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Re(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 Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Lh.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const _h=[0,0,0];function Ih(t,e){return t.map(((t,n)=>t+e[n]))}function jh(t,e){return t.map(((t,n)=>t-e[n]))}function Bh(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Fh(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function zh(t,e){return t.map((t=>t*e))}function Gh(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+Math.pow(n-e[r]||0,2)),0))}function Vh(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function Wh(t){const e=t.reduce(((t,e)=>t+Math.pow(e,2)),0);return t.map((t=>t/Math.sqrt(e)))}function Hh(t,e,n=!1){const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(Bh(t,e).reduce(((t,e)=>t+e),0)/(Gh(t,_h)*Gh(e,_h)));return n&&r<0&&(i=2*Math.PI-i),i}function Uh(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function $h(t,e){return t.map((t=>t%e))}function Yh(t){return[t[0],t[1]]}function qh(t){return 2===t.length?[t[0],t[1],0]:t}function Xh(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function Kh(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=qh(t),r=qh(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]]}(jh(n,r),jh(i,o)).every((t=>0===t))}function Zh(t,e,n=!1){if(Kh(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])),l=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||Hc(s,0,1)&&Hc(l,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Qh(t){if(Array.isArray(t))return Hc(t[0],0,1)&&Hc(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 Jh(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function td(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function ed(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,Qh(e))}function nd(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function rd(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function id(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function od(t,e,n,r=!1){if(Ne(t,e))return t;const i=Wh(r?jh(t,e):jh(e,t)),o=[i[0]*n,i[1]*n];return Ih(Yh(t),o)}function ad(t,e){return t[1]===e[1]}function sd(t,e,n){return Kh([t,e],[e,n])}function ld(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function ud(t,e,n,r=!0,i=!1){for(let o=0;o<n.length;o++){let a=n[o],s=n[(o+1)%n.length];r&&(a=Ih(e,a),s=Ih(e,s));const l=Zh([e,i?ld(t,e):t],[a,s]);if(l)return{point:l,line:[a,s]}}return{point:e,line:void 0}}function cd(t,e,n=!1){const r=e.center,i=jh(n?ld(t,r):t,e.center),o=Math.atan2(i[1],i[0]);if(isNaN(o))return r;const a=Yc(e)/2,s=qc(e)/2;return[r[0]+a*Math.cos(o),r[1]+s*Math.sin(o)]}function hd(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach((e=>{const i=function(t,e){const n=dd(t,e);return Gh(t,n)}(t,e);i<n&&(n=i,r=e)})),r}function dd(t,e){const[n,r]=e[0],[i,o]=e[1],[a,s]=t,l=i-n,u=o-r;if(0===l&&0===u)return[n,r];let c=((a-n)*l+(s-r)*u)/(l*l+u*u);c>1?c=1:c<0&&(c=0);return[n+c*l,r+c*u]}function fd(t,e=!0){const n=function(t){return Fh(t.reduce(((t,e)=>Ih(t,e)),[0,0]),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 pd(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}class gd{constructor(t,e,n){if(this.phase=e,this.pointerByTouch=[],this.initialDistance=null,this.emitter=t,gd.instance)return gd.callbacks[this.phase].push(n),gd.instance;this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.bindEvents(),gd.instance=this,gd.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)){gd.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),gd.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;gd.callbacks.pinchmove.forEach((e=>e(t,{scale:5*(o-1)})))}onPointerUp(t){var e;gd.callbacks.pinchend.forEach((e=>e(t,{scale:0}))),gd.isPinching=!1,this.initialDistance=null,this.pointerByTouch=[],null===(e=gd.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),gd.instance=null}off(t,e){const n=gd.callbacks[t].indexOf(e);n>-1&&gd.callbacks[t].splice(n,1),this.tryDestroy()}tryDestroy(){Object.values(gd.callbacks).every((t=>0===t.length))&&this.destroy()}}gd.isPinching=!1,gd.instance=null,gd.callbacks={pinchstart:[],pinchmove:[],pinchend:[]};const vd=t=>t.map((t=>ne(t)?t.toLocaleLowerCase():t));class md{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.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 gd(this.emitter,"pinchmove",this.boundHandlePinch)),this.map.set(e,n))}unbind(t,e){this.map.forEach(((n,r)=>{Ne(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}match(t){const e=vd(Array.from(this.recordKey)).sort(),n=vd(t).sort();return Ne(e,n)}bindEvents(){var e;const{emitter:n}=this;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)&&Ne(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),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,"blur",this.onFocus)}}class yd extends Dh{constructor(t,e){super(t,ke({},yd.defaultOptions,e)),this.shortcut=new md(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 Xl({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=bd(t),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(pd(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=bd(t),this.updateElementsStates(pd(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[yh(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);let 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]}))}Ut(o)&&(s=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=yh(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;t<s;r=t++){const s=e[t+n][0],l=e[t+n][1],u=e[r+n][0],c=e[r+n][1];l>o!=c>o&&i<(u-s)*(o-l)/(c-l)+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(yh(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 Ut(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=ke(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}yd.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 bd=t=>[t.canvas.x,t.canvas.y],xd=.8,Ed=["node","edge","combo"];function wd(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)wd(t,e,n,r,i+1);"BT"===r&&e(t,i)}function kd(t,e,n,r,i="both"){if("combo"===e||"node"===e)return Md(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const a=Md(t,o.source,r-1,i),s=Md(t,o.target,r-1,i);return Array.from(new Set([...a,...s,n]))}function Md(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=yh(t);!o.has(e)&&i<n&&(a.add(e),o.add(e))})))}),(e=>t.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 Sd(t){return t.states||[]}class Nd extends Dh{constructor(t,e){super(t,Object.assign({},Nd.defaultOptions,e)),this.onClickSelect=t=>ze(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=>ze(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 md(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.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 kd(r,n,e.id,"function"==typeof i?i(t):i).filter((t=>t!==e.id))}updateState(t){return ze(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=Sd(a.getElementData(o.id)).includes(e)?"unselect":"select",l={},u=this.isMultipleSelect,c=[o.id],h=this.getNeighborIds(t);if(u)if(Object.assign(l,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach((t=>{const r=new Set(a.getElementState(t));r.add(e),r.delete(n),l[t]=Array.from(r)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{const i=l[t];i.includes(e)||i.includes(r)||i.includes(n)||l[t].push(n)}))}else{const t=l[o.id];l[o.id]=t.filter((t=>t!==e&&t!==r)),t.includes(n)||l[o.id].push(n),h.forEach((t=>{l[t]=l[t].filter((t=>t!==r)),l[t].includes(e)||l[t].push(n)}))}else if("select"===s){Object.assign(l,this.getClearStates(!!n));const t=(t,e)=>{t.forEach((t=>{l[t]||(l[t]=a.getElementState(t)),l[t].push(e)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{c.includes(t)||h.includes(t)||l[t].push(n)}))}else Object.assign(l,this.getClearStates());yield a.setElementState(l,i)}))}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach((t=>{i[yh(t)]=Sd(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:l}=e.getData(),u={};return[...a,...s,...l].forEach((e=>{const n=Sd(e),r=n.filter((t=>!o.has(t)));(t||r.length!==n.length)&&(u[yh(e)]=r)})),u}clearState(){return ze(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 Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function Od(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function Td(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function Cd(t,e,n=!0){if(!e)return t;if(!Td(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=he(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Ad(t,e){const n=Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Td(n,e)&&Object.assign(t,{[Cd(n,e)]:r}),t)),{});if("opacity"in t){const r=function(t,e){return`${e}${de(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 Pd(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 Rd(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 Dd(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function Ld(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 _d(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 Id(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 jd(t){const e="string"==typeof t?Sc("palette",t):t;if("function"!=typeof e)return e}function Bd(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 Fd(t,e,n=1,r=!1){const i=r?n:1;return Bd((t.max[0]-t.min[0])*i,e)}Nd.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class zd extends _l{constructor(t){Vd(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,l,u,c,h,d,f;const p=this.shapeMap[e];if(!1===r)return void(p&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,p),i.removeChild(p),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,p)));const g="string"==typeof n?Sc(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error(Oc(`Shape ${n} not found`));if(!p||p.destroyed||!(p instanceof g)){p&&(null===(l=null==o?void 0:o.beforeDestroy)||void 0===l||l.call(o,p),null==p||p.destroy(),null===(u=null==o?void 0:o.afterDestroy)||void 0===u||u.call(o,p)),null===(c=null==o?void 0:o.beforeCreate)||void 0===c||c.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(h=null==o?void 0:o.afterCreate)||void 0===h||h.call(o,t),t}return null===(d=null==o?void 0:o.beforeUpdate)||void 0===d||d.call(o,p),_g(p,r),null===(f=null==o?void 0:o.afterUpdate)||void 0===f||f.call(o,p),p}update(t={}){const e=Object.assign({},this.attributes,t);Vd(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:a,clipPath:s,component:l}=e,u=Fe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,u),r&&t.setAttribute("transform",r);ae(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);l&&t.setAttribute("component",l)}(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:l,visibility:u}=t;return Fe(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&&(Gd(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${de(r)}Style`];if(Ut(o)){const r=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)))),a=i.animate(Pc(r),e);a&&(Gd(i,a),n.push(a))}}));const r=(r,i)=>{if(!Se(r)){const o=this[`get${de(i)}Style`];if(Ut(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(Pc(o),e);t&&(Gd(a,t),n.push(t))}}))}}};this.compositeShapes.forEach((([t,e])=>{const n=Pd(this.shapeMap,e);r(n,t)}))}}return Ac(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;Ah(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function Gd(t,e){null==e||e.finished.then((()=>{const n=t.activeAnimations.findIndex((t=>t===e));n>-1&&t.activeAnimations.splice(n,1)}))}function Vd(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=_c(e,n,r,i);o&&(t.transform=o)}return t}class Wd extends zd{constructor(t){super(_d({style:Wd.defaultStyleProps},t))}isTextStyle(t){return Td(t,"label")}isBackgroundStyle(t){return Td(t,"background")}getTextStyle(t){const e=this.getGraphicStyle(t),{padding:n}=e;return Rd(Fe(e,["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Ad(e,"background"),{min:[a,s],center:[l,u],halfExtents:[c,h]}=this.shapeMap.text.getGeometryBounds(),[d,f,p,g]=Uc(i),v=2*c+g+f,{width:m,height:y}=o;m&&y?Object.assign(o,{x:l-Number(m)/2,y:u-Number(y)/2}):Object.assign(o,{x:a-g,y:s-d,width:n?Math.min(v,r+g+f):v,height:2*h+d+p});const{radius:b}=o;if("string"==typeof b&&b.endsWith("%")){const t=Number(b.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Zl,this.getTextStyle(t),e),this.upsert("background",Xl,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}Wd.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 Hd extends zd{constructor(t){super(_d({style:Hd.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",Wd,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}Hd.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const Ud={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 $d(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 Ud?r=t:e.unshift(t),i={type:r},Ud[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<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])})),e}const Yd=t=>{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<t.length-2;e+=1){const[n,r]=t[e-1],[i,a]=t[e],[s,l]=t[e+1],[u,c]=e!==t.length-2?t[e+2]:[s,l],h=i+(s-n)/6,d=a+(l-r)/6,f=s-(u-i)/6,p=l-(c-a)/6;o.push(["C",h,d,f,p,s,l])}return o};class qd extends zd{constructor(t){super(_d({style:qd.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{maxWidth:n,offsetX:r,offsetY:i,autoRotate:o,placement:a,closeToPath:s}=e,l=Fe(e,["maxWidth","offsetX","offsetY","autoRotate","placement","closeToPath"]),u=this.shapeMap.key,c=null==u?void 0:u.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,a){const[s,l]=ed(t,e),u={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:[["translate",s+n,l+r]]};if("center"===e||!i)return u;const c=$d(o);if(!c||c.length<=3)return u;const h=c.map(((t,e)=>{const n=t,r=c[(e+1)%c.length];return Ne(n,r)?null:[n,r]})).filter(Boolean),d=hd([s,l],h),f=dd([s,l],d);if(f&&d&&(u.transform=[["translate",f[0]+n,f[1]+r]],a)){const t=Math.atan((d[0][1]-d[1][1])/(d[0][0]-d[1][0]));u.transform.push(["rotate",t/Math.PI*180]),u.textAlign="center","right"!==e&&"left"!==e||(u.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return u}(c,a,r,i,s,t.d,o),{wordWrapWidth:Fd(c,n)},l)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",Hl,this.getKeyStyle(t),e),this.upsert("label",Wd,this.getLabelStyle(t),e)}}qd.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let Xd=class extends zl{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Zd=this,this.isMutationObserved=!0,this.addEventListener(Vs.MOUNTED,this.onMounted),this.addEventListener(Vs.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 Xl({style:a});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const Kd=new WeakMap;let Zd=null;const Qd=t=>{if(Zd&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Zd).includes(t)){const e=Kd.get(t);e?e.includes(Zd)||e.push(Zd):Kd.set(t,[Zd])}},Jd=t=>{const e=Kd.get(t);e&&e.forEach((t=>t.handleRadius()))};class tf extends zd{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()?Xd:Zl,this.getIconStyle(t),e)}}class ef extends zd{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 nf extends ef{constructor(t){super(_d({style:nf.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return Dd(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(Rd(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,a=Fe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(Lg(s,n,i,o),{wordWrapWidth:Fd(s,r)},a)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Fe(e,["fill"]),i=Ad(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=Ad(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=Dd(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=Pd(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=Fe(t,["badges","badgePalette","opacity"]),l=jd(o),u=Ad(this.getGraphicStyle(s),"badge");return i.forEach(((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:l?l[e%(null==l?void 0:l.length)]:void 0,opacity:a},u),this.getBadgeStyle(t))})),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Fe(t,["placement","offsetX","offsetY"]),a=Lg(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=Ad(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(Tg(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 Ng(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();Ah(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return Pd(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return ud(t,ed(e,"center"),[ed(e,"left-top"),ed(e,"right-top"),ed(e,"right-bottom"),ed(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",tf,n,e),Qd(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{const r=n[t];this.upsert(`badge-${t}`,Hd,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,Dl,r,e)}))}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Wd,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)&&Jd(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}nf.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 rf=class t extends nf{constructor(e){super(_d({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",Dl,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*xd;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}};rf.defaultStyleProps={size:32};class of extends nf{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",$l,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 ud(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 af extends of{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 sf extends rf{constructor(t){super(_d({style:sf.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...Dd(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return ne(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=>ae(t)?{value:t}:t)),i=Ad(this.getGraphicStyle(t),"donut"),o=jd(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(),l=this.parseInnerR();let u=0;r.forEach(((t,n)=>{const{value:c=0,color:h=o[n%o.length]}=t,d=Fe(t,["value","color"]),f=360*(0===a?1/r.length:c/a);this.upsert(`round${n}`,Hl,Object.assign(Object.assign(Object.assign({},i),{d:uf(s,l,u,u+f),fill:h}),d),e),u+=f}))}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}sf.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const lf=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],uf=(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],l=[lf(t,e,r,a),lf(t,e,n,a),lf(t,e,n,s),lf(t,e,r,s)],u=s-a>Math.PI?1:0;return[["M",l[0][0],l[0][1]],["L",l[1][0],l[1][1]],["A",n,n,0,u,1,l[2][0],l[2][1]],["L",l[3][0],l[3][1]],["A",r,r,0,u,0,l[0][0],l[0][1]],["Z"]]})(i,o,t,e,n,r)};class cf extends nf{constructor(t){super(_d({style:cf.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Il,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)*xd;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}}cf.defaultStyleProps={size:[45,35]};class hf extends of{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)*xd;return!!e&&Object.assign({width:n,height:n},e)}}
19
19
  /*!
20
20
  * @antv/g-plugin-canvas-path-generator
21
21
  * @description A G plugin of path generator with Canvas2D API
@@ -63,12 +63,12 @@ var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).
63
63
  * @date 2/27/2025, 8:29:44 AM
64
64
  * @author AntVis
65
65
  * @docs https://g.antv.antgroup.com/
66
- */class Np extends nf{constructor(t){super(Object.assign(Object.assign({},t),{style:Object.assign({},Np.defaultStyleProps,t.style)})),this.rootPointerEvent=new As(null),this.forwardEvents=t=>{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);Te(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=Ae(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Fe(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",Xl,{x:r,y:i,width:o,height:a,opacity:0},e);return this.upsert("key",Fl,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof Sp))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;e<t.changedTouches.length;e++){const r=t.changedTouches[e];ve(r.button)&&(r.button=0),ve(r.buttons)&&(r.buttons=1),ve(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),ve(r.width)&&(r.width=r.radiusX||1),ve(r.height)&&(r.height=r.radiusY||1),ve(r.tiltX)&&(r.tiltX=0),ve(r.tiltY)&&(r.tiltY=0),ve(r.pointerType)&&(r.pointerType="touch"),ve(r.pointerId)&&(r.pointerId=r.identifier||0),ve(r.pressure)&&(r.pressure=r.force||.5),ve(r.twist)&&(r.twist=0),ve(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;ve(e.isPrimary)&&(e.isPrimary=!0),ve(e.width)&&(e.width=1),ve(e.height)&&(e.height=1),ve(e.tiltX)&&(e.tiltX=0),ve(e.tiltY)&&(e.tiltY=0),ve(e.pointerType)&&(e.pointerType="mouse"),ve(e.pointerId)&&(e.pointerId=1),ve(e.pressure)&&(e.pressure=.5),ve(e.twist)&&(e.twist=0),ve(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.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}bootstrapEvent(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);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const[a,s]=this.context.canvas.getCanvasByViewport([i,o]);return t.canvas.x=a,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:a}=t;if($t(r)||$t(i)){const t=this.eventService.client2Viewport({x:o,y:a});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}onframe(){super.onframe();const{opacity:t}=this.attributes;this.getDomElement().style.opacity=`${t}`}}Np.defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};let Op=class t extends nf{constructor(e){super(_d({style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),r=super.getKeyStyle(t),{fillOpacity:i,opacity:o=i}=r,a=Fe(r,["fillOpacity","opacity"]);return Object.assign(Object.assign({opacity:o},a),{width:e,height:n,x:-e/2,y:-n/2})}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getShape("key").attributes,{fill:n,stroke:r}=e;Fe(e,["fill","stroke"]);const i=Ad(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=Ih(this.getSize(t),[o,o]);return Object.assign(Object.assign({},i),{width:a,height:s,fill:"transparent",x:-a/2,y:-s/2})}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&Object.assign({width:n*xd,height:r*xd},e)}drawKeyShape(t,e){const n=this.upsert("key",Xd,this.getKeyStyle(t),e);return Qd(this),n}drawHaloShape(t,e){this.upsert("halo",Xl,this.getHaloStyle(t),e)}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Jd(this)}};Op.defaultStyleProps={size:32};class Tp extends nf{constructor(t){super(t)}getKeyStyle(t){const[e,n]=this.getSize(t);return Object.assign(Object.assign({},super.getKeyStyle(t)),{width:e,height:n,x:-e/2,y:-n/2})}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getShape("key").attributes;return!!e&&Object.assign({width:n*xd,height:r*xd},e)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}}class Cp extends of{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*xd;return!!e&&Object.assign({width:n,height:n},e)}getPortXY(t,e){const{placement:n="top"}=e;return Ng(this.getShape("key").getLocalBounds(),n,function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t)),!1)}}class Ap extends of{constructor(t){super(_d({style:Ap.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getShape("key").getLocalBounds(),[o,a]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,a,n);return Ng(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||Se(n||r))return!1;const o=Ad(this.getGraphicStyle(t),"icon"),a=this.getShape("key").getLocalBounds(),[s,l]=function(t,e){const{center:n}=t,[r,i]=Xc(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(a,i),u=2*function(t,e){let[n,r]=Xc(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(Math.pow(r,2)-Math.pow(Math.sqrt(Math.pow(n/2,2)+Math.pow(r,2))-n/2,2))/(2*r)}(a,i)*xd;return Object.assign({x:s,y:l,width:u,height:u},o)}}Ap.defaultStyleProps={size:40,direction:"up"};class Pp extends nf{constructor(t){super(_d({style:Pp.defaultStyleProps},t)),this.type="combo",this.updateComboPosition(this.parsedAttributes)}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,a]=Uc(e);return Ih(Dd(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Dd(t.collapsedSize)}getExpandedKeySize(t){const e=this.getContentBBox(t);return[Yc(e),qc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=e.map((t=>this.context.element.getElement(t))).filter(Boolean);if(0===r.length){const e=new fr,{x:n=0,y:r=0,size:i}=t,[o,a]=Dd(i);return e.setMinMax([n-o/2,r-a/2,0],[n+o/2,r+a/2,0]),e}const i=Jc(r.map((t=>t.getBounds())));return n?Qc(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",tf,n,e),Qd(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Ad(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Fe(e,["type"]),i=this.getShape("key"),[o,a]=ed(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(yh(t)))).length.toString():Ut(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(yh(e))));if(r.length>0&&r.some(td)){return Fh(r.reduce(((t,e)=>Ih(t,Jh(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}}),Jd(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 Fe(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}}Pp.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Rp extends Pp{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Dl,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&&Ad(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=Dd(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=Xc(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}}class Dp extends Pp{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Xl,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&&Ad(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const Lp={padding:10};function _p(t,e,n,r,i,o){const{padding:a}=Object.assign(Lp,o),s=Kc(n,a),l=Kc(r,a),u=[t,...i,e];let c=null;const h=[];for(let t=0,e=u.length;t<e-1;t++){const n=t+1,r=u[t],i=u[n],o=ad(d=r,f=i)||function(t,e){return t[0]===e[0]}(d,f);let p=null;if(0===t)if(n===e-1)if(s.intersects(l))p=Hp(r,i,s,l);else if(nh(r,s)||nh(i,l))o||(p=Wp(r,i,s,l));else{const t=ih(r,s),e=ih(i,l);p=zp(t,e,Bp(t,e)),p.points.unshift(t),p.points.push(e)}else th(i,s)?p=Hp(r,i,s,Kc(i,a),c):o||(p=Gp(r,i,s));else n===e-1?th(r,l)?p=Hp(r,i,Kc(r,a),l,c):o||(p=Vp(r,i,l,c)):o||(p=zp(r,i,c));p?(h.push(...p.points),c=p.direction):c=Bp(r,i),n<e-1&&h.push(i)}var d,f;return h.map(Yh)}const Ip={N:"S",S:"N",W:"E",E:"W"},jp={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Bp(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function Fp(t,e){return"N"===e||"S"===e?qc(t):Yc(t)}function zp(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Bp(t,r),a=Bp(t,i),s=n?Ip[n]:null,l=o===n||o!==s&&a!==n?r:i;return{points:[l],direction:Bp(l,e)}}function Gp(t,e,n){if(nh(t,n)){const r=Up(t,e,n);return{points:[r],direction:Bp(r,e)}}{const r=ih(t,n),i=["left","right"].includes(rh(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:Bp(i,e)}}}function Vp(t,e,n,r){const i=nh(e,n)?e:ih(e,n),o=[[i[0],t[1]],[t[0],i[1]]],a=o.filter((t=>function(t,e){return!th(t,e)}(t,n)&&!eh(t,n,!0))),s=a.filter((e=>Bp(e,t)!==r));if(s.length>0){const n=s.find((e=>Bp(t,e)===r))||s[0];return{points:[n],direction:Bp(n,e)}}{const i=od(e,Ht(o,a)[0],Fp(n,r)/2);return{points:[Up(i,t,n),i],direction:Bp(i,e)}}}function Wp(t,e,n,r){let i=Gp(t,e,n);const o=qh(i.points[0]);if(th(o,r)){i=Gp(e,t,r);const a=qh(i.points[0]);if(th(a,n)){const s=od(t,o,Fp(n,Bp(t,o))/2),l=od(e,a,Fp(r,Bp(e,a))/2),u=[(s[0]+l[0])/2,(s[1]+l[1])/2],c=Gp(t,u,n),h=Vp(u,e,r,c.direction);i.points=[c.points[0],h.points[0]],i.direction=h.direction}}return i}function Hp(t,e,n,r,i){const o=Jc([n,r]),a=Gh(e,o.center)>Gh(t,o.center),[s,l]=a?[e,t]:[t,e],u=qc(o)+Yc(o);let c;if(i){const t=[s[0]+u*Math.cos(jp[i]),s[1]+u*Math.sin(jp[i])];c=od(ih(t,o),t,.01)}else c=od(ih(s,o),s,-.01);let h=Up(c,l,o),d=[id(c,2),id(h,2)];if(Ne(id(c),id(h))){const t=Hh(jh(c,s),[1,0,0])+Math.PI/2;h=[l[0]+u*Math.cos(t),l[1]+u*Math.sin(t),0],h=id(od(ih(h,o),l,-.01),2);d=[c,Up(c,h,o),h]}return{points:a?d.reverse():d,direction:Bp(a?c:h,e)}}function Up(t,e,n){let r=[t[0],e[1]];return th(r,n)&&(r=[e[0],t[1]]),r}function $p(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=nd(t.getPoint(o)),s=nd(t.getPoint(o+.01));let l="start"===e?"left":"end"===e?"right":"center";if(ad(a,s)||!n){const[e,n]=Yp(t,o,r,i);return{transform:[["translate",e,n]],textAlign:l}}let u=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(l="center"===l?l:"left"===l?"right":"left",r*=-1,u+=Math.PI);const[c,h]=Yp(t,o,r,i,u);return{textAlign:l,transform:[["translate",c,h],["rotate",u/Math.PI*180]]}}function Yp(t,e,n,r,i){const[o,a]=nd(t.getPoint(e));let s=n,l=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),l=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+l]}function qp(t,e,n,r){if(Ne(t,e))return t;const i=jh(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=Wh(Uh(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Xp(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function Kp(t,e=0,n=!1){const r=t.length-1,i=t[0],o=t[r],a=t.slice(1,r),s=[["M",i[0],i[1]]];return a.forEach(((t,n)=>{const r=a[n-1]||i,l=a[n+1]||o;if(!sd(r,t,l)&&e){const[n,i]=function(t,e,n,r){const i=Vh(t,e),o=Vh(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])],l=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,l]}(r,t,l,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 Zp(t,e,n,r,i){const o=Kc(t),a=t.getCenter();let s=r&&Cg(r),l=i&&Cg(i);if(!s||!l){const r=(t=>{const e=Math.PI/2,n=qc(t)/2,r=Yc(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],u=r[e][1],[c,h]=Xc(o),d=Math.max(c,h),f=Ih(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Ih(a,[d*Math.cos(u),d*Math.sin(u),0]);s=Dg(t,f),l=Dg(t,p),n||([s,l]=[l,s])}return[s,l]}function Qp(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[l,u]=Zp(t,e,n,a,s);const c=function(t,e,n,r){const i=t.getCenter();if(Ne(e,n)){const t=jh(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Ih(e,o),Ih(n,Bh(o,[1,-1,1]))]}return[od(i,e,Gh(i,e)+r),od(i,n,Gh(i,n)+r)]}(t,l,u,r);return a&&(l=Rg(a,c[0])),s&&(u=Rg(s,c.at(-1))),Xp(l,u,c)}function Jp(t,e,n,r,i,o,a){const s=Og(t),l=s[o||a],u=s[a||o];let[c,h]=Zp(t,n,r,l,u);const d=function(t,e,n,r){const i=[],o=Kc(t);if(Ne(e,n)){switch(rh(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=rh(e,o),a=rh(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]),l=s(t,e),u=s(a,n),c=Up(l,u,o);i.push(l,c,u)}}return i}(t,c,h,i);return l&&(c=Rg(l,d[0])),u&&(h=Rg(u,d.at(-1))),Kp([c,...d,h],e)}function tg(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 eg(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(yh(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(Od);return n[t]||n.at(-1)}return t}const ng=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var rg=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:ng,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 ig extends ef{constructor(t){super(_d({style:ig.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=Fe(e,["loop"]),{sourceNode:i,targetNode:o}=this;var a,s;const l={d:n&&(s=o,(a=i)&&s&&a===s)?this.getLoopPath(t):this.getKeyPath(t)};return Hl.PARSED_STYLE_LIST.forEach((t=>{t in r&&(l[t]=r[t])})),l}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=Kc(r),o=Math.max(Yc(i),qc(i)),{placement:a,clockwise:s,dist:l=o}=Ad(this.getGraphicStyle(t),"loop");return Qp(r,a,s,l,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:a}=this,[s,l]=function(t,e,n,r){const i=Ag(t,e,n,r),o=Ag(e,t,r,n);return[i,o]}(o,a,r,i);if(!e){return[s?Cg(s):o.getCenter(),l?Cg(l):a.getCenter()]}const u="function"==typeof n?n():n;return[Pg(s||o,u[0]||l||a),Pg(l||a,u[u.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Ad(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a}=e,s=Fe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),l=$p(this.shapeMap.key,n,o,r,i),u=this.shapeMap.key.getLocalBounds(),c=function(t,e,n=1){return Bd(Gh(t[0],t[1])*n,e)}([u.min,u.max],a);return Object.assign({wordWrapWidth:c},l,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Ad(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Fe(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,l=2*(null===(a=t.label)||void 0===a?void 0:a.getGeometryBounds().halfExtents[0])||0;return $p(t.key,n,!0,(l?(l/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?zl:Hl)({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=Ad(this.getGraphicStyle(t),r),{size:o,type:a}=i,s=Fe(i,["size","type"]),[l,u]=Dd(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),c=(Ut(a)?a:rg[a]||ng)(l,u);return Object.assign(Ae(n,["stroke","strokeOpacity","fillOpacity"]),{width:l,height:u},Object.assign({},c&&{d:c,fill:"simple"===a?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Wd,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",Hl,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",Hd,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",Hl,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}}ig.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 og extends ig{constructor(t){super(_d({style:og.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 ae(t)?[t,1-t]:t}(i),function(t){return ae(t)?[t,-t]:t}(o),r);return Xp(e,n,a)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[qp(t,e,n[0],r[0]),qp(t,e,n[1],r[1])]}}og.defaultStyleProps={curvePosition:.5,curveOffset:20};class ag extends og{constructor(t){super(_d({style:ag.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]]]}}ag.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class sg extends og{constructor(t){super(_d({style:sg.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=Jh(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=Jh(this.ref);return[Gh(t,e),Xh(jh(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)]]}}sg.defaultStyleProps={curvePosition:.5,curveOffset:20};class lg extends og{constructor(t){super(_d({style:lg.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]]]}}lg.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let ug=class t extends ig{constructor(e){super(_d({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};ug.defaultStyleProps={};const cg={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:Vh},hg=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function dg(t,e){const n=t=>Math.round(t/e);return ae(t)?n(t):t.map(n)}function fg(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function pg(t,e,n,r){const i=fg(t,e),o=n[hg(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(fg(o||r,t),i)}function gg(t,e,n){return Math.min(...e.map((e=>n(t,e))))}const vg=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,a=Qc(e.getRenderBounds(),o),s=Object.keys(i).reduce(((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=Xc(a),l=[t[0]+n.stepX*o,t[1]+n.stepY*s],u=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],a=[r,i],s=[r,n],l=[e,n];return[[o,a],[a,s],[s,l],[l,o]]}(a);for(let n=0;n<u.length;n++){const r=Zh([t,l],u[n]);r&&eh(r,a)&&e.push(r)}}return e}),[]);return th(t,a)||s.push(t),s.map((t=>dg(t,r.gridSize)))},mg=(t,e,n,r,i,o,a)=>{const s=[];let l=[o[0]===r[0]?r[0]:t[0]*a,o[1]===r[1]?r[1]:t[1]*a];s.unshift(l);let u=t,c=e[hg(u)];for(;c;){const t=c,r=u;pg(t,r,e,n)&&(l=[t[0]===r[0]?l[0]:t[0]*a,t[1]===r[1]?l[1]:t[1]*a],s.unshift(l)),c=e[hg(t)],u=t}const h=i.map((t=>[t[0]*a,t[1]*a])),d=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o<t.length;o++){const a=t[o],s=n(a,e);s<i&&(r=a,i=s)}return r}(h,l,Vh);return s.unshift(d),s};function yg(t,e,n,r){const i=Yh(t.getCenter()),o=Yh(e.getCenter()),a=Object.assign(cg,r),{gridSize:s}=a,l=((t,e)=>{const{offset:n,gridSize:r}=e,i={};return t.forEach((t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Qc(t.getRenderBounds(),n);for(let t=dg(e.min[0],r);t<=dg(e.max[0],r);t+=1)for(let n=dg(e.min[1],r);n<=dg(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0})),i})(a.enableObstacleAvoidance?n:[t,e],a),u=dg(i,s),c=dg(o,s),h=vg(i,t,a.startDirections,a),d=vg(o,e,a.endDirections,a);h.forEach((t=>delete l[hg(t)])),d.forEach((t=>delete l[hg(t)]));const f={},p={},g={},v={},m={},y=new bg;for(let t=0;t<h.length;t++){const e=h[t],n=hg(e);f[n]=e,v[n]=0,m[n]=gg(e,d,a.distFunc),y.add({id:n,value:m[n]})}const b=d.map((t=>hg(t)));let x,E=a.maximumLoops,w=1/0;for(const[t,e]of Object.entries(f))m[t]<=w&&(w=m[t],x=e);for(;Object.keys(f).length>0&&E>0;){const t=y.minId(!1);if(!t)break;x=f[t];const e=hg(x);if(b.includes(e))return mg(x,g,u,o,h,c,s);delete f[e],y.remove(e),p[e]=!0;for(const t of Object.values(a.directionMap)){const n=Ih(x,[t.stepX,t.stepY]),r=hg(n);if(p[r])continue;const i=pg(x,n,g,u);if(i>a.maxAllowedDirectionChange)continue;if(l[r])continue;f[r]||(f[r]=n);const o=a.penalties[i],c=a.distFunc(x,n)+(isNaN(o)?s:o),h=v[e]+c,b=v[r];b&&h>=b||(g[r]=x,v[r]=h,m[r]=h+gg(n,d,a.distFunc),y.add({id:r,value:m[r]}))}E-=1}return[]}class bg{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<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n=e}}this.arr.splice(r,0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;if(!e||this.arr[e-1].value<t.value)return this.arr.push(t),void(this.map[t.id]=!0);this._innerAdd(t,e)}remove(t){this.map[t]&&delete this.map[t]}_clearAndGetMinId(){let t;for(let e=this.arr.length-1;e>=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 xg extends ig{constructor(t){super(_d({style:xg.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=yg(n,r,this.context.element.getNodes(),e),a.length||(a=_p(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(a=_p(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 Kp(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=Kc(i),a=Math.max(Yc(o),qc(o))/4,{placement:s,clockwise:l,dist:u=a}=Ad(this.getGraphicStyle(t),"loop");return Jp(i,r,s,l,u,e,n)}}xg.defaultStyleProps={radius:0,controlPoints:[],router:!1};class Eg extends ig{constructor(t){super(_d({style:Eg.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||qp(r,i,e,n))}}function wg(t){return t instanceof nf&&"node"===t.type}function kg(t){return t instanceof ig}function Mg(t){return t instanceof Pp}Eg.defaultStyleProps={curvePosition:.5,curveOffset:30};const Sg={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 Ng(t,e,n=Sg,r=!0){const i=[.5,.5],o=ne(e)?Oe(n,e.toLocaleLowerCase(),i):e;if(!r&&ne(e))return o;const[a,s]=o||i;return[t.min[0]+Yc(t)*a,t.min[1]+qc(t)*s]}function Og(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{var i;const{key:o,placement:a}=n;Tg(n)&&(e[i=o||r]||(e[i]=ed(t.getShape("key").getBounds(),a)))})),e}function Tg(t){const{r:e}=t;return!e||0===Number(e)}function Cg(t){return Wc(t)?t:t.getPosition()}function Ag(t,e,n,r){const i=Og(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Cg(t))),s=function(t,e){const n=Og(t);if(e)return[Cg(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Cg(t))):[t.getCenter()]}(e,r),[l]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=Gh(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Cg(t)===l))}function Pg(t,e){return Mg(t)||wg(t)?Dg(t,e):Rg(t,e)}function Rg(t,e){if(!t||!e)return[0,0,0];if(Wc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return cd(Wc(e)?e:wg(e)?e.getCenter():e.getPosition(),t.getBounds())}function Dg(t,e){if(!t||!e)return[0,0,0];const n=Wc(e)?e:wg(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function Lg(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[a,s]=ed(t,e),[l,u]=i?["bottom","top"]:["top","bottom"];return{transform:[["translate",a+n,s+r]],textBaseline:o.includes("top")?u:o.includes("bottom")?l:"middle",textAlign:o.includes("left")?"right":o.includes("right")?"left":"center"}}function _g(t,e){"update"in t?t.update(e):t.attr(e)}function Ig(t){return Oe(t,"__to_be_destroyed__",!1)}class jg extends Dh{constructor(t,e){super(t,Object.assign({},jg.defaultOptions,e)),this.onCollapseExpand=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{target:e}=t;if(!(wg(n=e)||kg(n)||Mg(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:l,animation:u,align:c}=this.options;Od(a)?(yield o.expandElement(r,{animation:u,align:c}),null==l||l(r)):(yield o.collapseElement(r,{animation:u,align:c}),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 Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}jg.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const Bg="g6-create-edge-assist-node-id";class Fg extends Dh{constructor(t,e){super(t,Object.assign({},Fg.defaultOptions,e)),this.drop=t=>ze(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=>ze(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:l}=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 u=i.getElementData(this.source);i.addNodeData([{id:Bg,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=u.style)||void 0===e?void 0:e.x,y:null===(n=u.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:Bg,style:Object.assign({pointerEvents:"none"},l)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished})),this.updateAssistEdge=t=>ze(this,void 0,void 0,(function*(){var e;if(!this.source)return;const{model:n,element:r}=this.context;n.translateNodeTo(Bg,[t.canvas.x,t.canvas.y]),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 l;const u=a({id:`${this.source}-${s}-${De[l=l||"g"]?De[l]+=1:De[l]=1,l+De[l]}`,source:this.source,target:s,style:i});r.addEdgeData([u]),o(u)},this.cancelEdge=()=>ze(this,void 0,void 0,(function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([Bg]),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 Ut(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()}}Fg.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class zg extends Dh{constructor(t,e){super(t,Object.assign({},zg.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||gd.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;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=ye((()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)}),300),this.shortcut=new md(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(qt(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 ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(Bh(t,r),this.options.animation),this.invokeOnFinish()}))}translate(t,e){return ze(this,void 0,void 0,(function*(){t=this.clampByDirection(t),t=this.clampByRange(t),yield this.context.graph.translateBy(t,e)}))}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,l,u]=Uc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[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()}}zg.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class Gg extends Dh{constructor(e,n){super(e,Object.assign({},Gg.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>ze(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,Ec);e&&yh(e)===i&&n.refreshComboData(i),n.setParent(t,i,Ec)})),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.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 Fh([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=!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]=jh([+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=[]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}moveElement(t,e){return ze(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,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=Ad(this.options,"shadow"),n=Jc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Xc(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 Xl({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(yh):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(yh))).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()}}Gg.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),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 Vg=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<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],a=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var a=r[o],s=a.callback;a.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};a(i),a(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function Wg(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach((n=>{e.has(n.id)||(e.add(n.id),t.push(n))}))}return!1}function Hg(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)&&Hg(i,e,n,r))return!0;return!1}const Ug=()=>!0;class $g{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||Ug,n=t.edgeFilter||Ug;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];Wg([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];Hg(this.getNode(t),new Set,e,r)}}let Yg=class t extends Vg{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 Hg(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Wg([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 Wg([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 Hg(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 $g({graph:this,...t})}};class qg{constructor(t,e){this.context=t,this.options=e||{}}}function Xg(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(nd)}:{})})})),r}function Kg(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 Zg(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 Qg extends Gg{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):(Tc("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return ze(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&&Kg(n,"setFixedPosition",t[i],[...Ih([+o,+a],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&&Zg(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach((t=>{const{x:n=0,y:r=0}=t.style||{};e&&Kg(e,"setFixedPosition",yh(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&&Zg(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach((e=>{t&&Kg(t,"setFixedPosition",yh(e),[null,null,null])}))}}class Jg extends Dh{constructor(t,e){super(t,Object.assign({},Jg.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=>ze(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),l=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),u=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,c=[...a,...l];c.length>0&&c.forEach((t=>this.fixNodeLike(t,u))),this.updateRelatedEdges(),s.length>0&&s.forEach((t=>this.fixEdge(t,u)))})),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);ae(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=yh(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(yh(t))));const a=this.options[o.type];a?this.scaleSpecificShapes(o,e,a):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=yh(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=>ze(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(Se(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(yh(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 Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Jg.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 tv extends Dh{constructor(t,e){super(t,Object.assign({},tv.defaultOptions,e)),this.focus=t=>ze(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.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}destroy(){this.unbindEvents(),super.destroy()}}tv.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};class ev extends Dh{constructor(e,n){super(e,Object.assign({},ev.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=xh(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(),Ed.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?kd(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||Ig(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.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()}}ev.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class nv extends yd{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e}=this.context;this.pathShape=new Hl({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[bd(t)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(bd(t)),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 rv extends Dh{constructor(t,e){super(t,Object.assign({},rv.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):Ah(t,e,n):this.hiddenShapes.push(t)}))},this.filterShapes=(t,e)=>{if(Ut(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=ye((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 Ut(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}rv.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class iv extends Dh{constructor(t,e){super(t,Object.assign({},iv.defaultOptions,e)),this.onWheel=t=>ze(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 md(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),qt(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=Bh(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,l,u]=Uc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return ze(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 Ut(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()}}iv.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class ov extends Dh{constructor(t,e){super(t,Object.assign({},ov.defaultOptions,e)),this.zoom=(t,e,n)=>ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{graph:r}=this.context;let i;"viewport"in e&&(i=nd(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+oe(t,-50,50)*o/100,l=r.getZoom();yield r.zoomTo(l*s,n,i),null==a||a()})),this.onReset=()=>ze(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 md(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 Ut(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()}}ov.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};var av={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},sv=av,lv={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function uv(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof uv)return t;n.data=t;var r=e.getHGap(t),i=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,i),n}sv.assign(uv.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(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:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}});var cv=function(t,e,n){void 0===e&&(e={});var r,i=new uv(t,e=sv.assign({},lv,e)),o=[i];if(!n&&!t.collapsed)for(;r=o.shift();)if(!r.data.collapsed){var a=e.getChildren(r.data),s=a?a.length:0;if(r.children=new Array(s),a&&s)for(var l=0;l<s;l++){var u=new uv(a[l],e);r.children[l]=u,o.push(u),u.parent=r,u.depth=r.depth+1}}return i},hv=cv,dv=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=hv(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),fv=dv;function pv(t,e,n,r){void 0===r&&(r=[]);var i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function gv(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){gv(t,e,n)}))}function vv(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(vv(t,e),n)})),n}function mv(t,e){gv(t,-vv(t,e),e)}function yv(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){yv(t,e.children[r],n)}))}function bv(t,e,n){void 0===n&&(n=0),e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach((function(t){bv(t,e,n)}))}pv.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(pv.fromNode(t,e))})),e?new pv(t.height,t.width,t.x,n):new pv(t.width,t.height,t.y,n)};var xv=cv,Ev=function(t,e){for(var n=xv(t.data,e,!0),r=xv(t.data,e,!0),i=t.children.length,o=Math.round(i/2),a=e.getSide||function(t,e){return e<o?"right":"left"},s=0;s<i;s++){var l=t.children[s];"right"===a(l,s)?r.children.push(l):n.children.push(l)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},wv=Ev,kv=["LR","RL","TB","BT","H","V"],Mv=["LR","RL","H"],Sv=kv[0],Nv=function(t,e,n){var r=e.direction||Sv;if(e.isHorizontal=function(t){return Mv.indexOf(t)>-1}(r),-1===kv.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===kv[0])n(t,e);else if(r===kv[1])n(t,e),t.right2left();else if(r===kv[2])n(t,e);else if(r===kv[3])n(t,e),t.bottom2top();else if(r===kv[4]||r===kv[5]){var i=wv(t,e),o=i.left,a=i.right;n(o,e),n(a,e),e.isHorizontal?o.right2left():o.bottom2top(),a.translate(o.x-a.x,o.y-a.y),t.x=o.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var l=e.fixedRoot;return void 0===l&&(l=!0),l&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){var n=e.isHorizontal?["x","y"]:["y","x"],r=n[0],i=n[1],o={x:1/0,y:1/0},a={x:-1/0,y:-1/0},s=0;t.DFTraverse((function(t){s++;var e=t.x,n=t.y;o.x=Math.min(o.x,e),o.y=Math.min(o.y,n),a.x=Math.max(a.x,e),a.y=Math.max(a.y,n)}));var l=a[i]-o[i];if(0===l)return;var u=2*Math.PI/s;t.DFTraverse((function(e){var n=(e[i]-o[i])/l*(2*Math.PI-u)+u,a=e[r]-t[r];e.x=Math.cos(n)*a,e.y=Math.sin(n)*a}))}}(t,e),t};function Ov(t,e){return Ov=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ov(t,e)}var Tv=function(t,e){void 0===e&&(e={});var 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){for(var r=t.c[e-1],i=r.mod,u=t.c[e],c=u.mod;null!==r&&null!==u;){l(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(c+u.prelim);h>0&&(c+=h,o(t,e,n.index,h));var d=l(r),f=l(u);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(u=a(u))&&(c+=u.mod)}!r&&u?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var 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,u,c):r&&!u&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var 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){var 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 l(t){return t.y+t.h}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}bv(t,n);var c=pv.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=u(l(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=l(e.c[o].er);i(e,o,n),n=u(a,o,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}else r(e)}(c),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)n+=(e+=t.c[r].shift)+t.c[r].change,t.c[r].mod+=n}(e);for(var r=0;r<e.cs;r++)t(e.c[r],n)}(c,0),yv(c,t,n),mv(t,n),t},Cv=Nv,Av=av,Pv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Ov(n,r),e.prototype.execute=function(){return Cv(this.rootNode,this.options,Tv)},e}(fv),Rv={};var Dv=function(t,e){return e=Av.assign({},Rv,e),new Pv(t,e).execute()},Lv=av;function _v(t,e){void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}var Iv={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function jv(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((function(t,r){jv(t,e.children[r],n)}))}function Bv(t,e){return Bv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Bv(t,e)}var Fv=function(t,e){void 0===e&&(e={}),e=Lv.assign({},Iv,e);var n,r=0;var i=function t(e){if(!e)return null;e.width=0,e.depth&&e.depth>r&&(r=e.depth);var n=e.children,i=n.length,o=new _v(e.height,[]);return n.forEach((function(e,n){var 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{var n=e.children.map((function(e){return t(e)})),i=Math.min.apply(null,n);e.drawingDepth=i-1}return e.drawingDepth}(i),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(i),jv(i,t,e.isHorizontal),t},zv=Nv,Gv=av,Vv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Bv(n,r),e.prototype.execute=function(){var t=this;return t.rootNode.width=0,zv(t.rootNode,t.options,Fv)},e}(fv),Wv={};var Hv=function(t,e){return e=Gv.assign({},Wv,e),new Vv(t,e).execute()},Uv=av;function $v(t,e){return $v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$v(t,e)}var Yv=fv,qv=function(t,e,n,r){var i=null;t.eachNode((function(t){!function(t,e,n,r,i){var o=("function"==typeof n?n(t):n)*t.depth;if(!r)try{if(t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch(t){}if(t.x+=o,e){if(t.y=e.y+Uv.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+Uv.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},Xv=Ev,Kv=av,Zv=["LR","RL","H"],Qv=Zv[0],Jv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,$v(n,r),e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,o=void 0===i||i,a=t.direction,s=void 0===a?Qv:a,l=t.align;if(s&&-1===Zv.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Zv[0])qv(e,r,o,l);else if(s===Zv[1])qv(e,r,o,l),e.right2left();else if(s===Zv[2]){var u=Xv(e,t),c=u.left,h=u.right;qv(c,r,o,l),c.right2left(),qv(h,r,o,l);var d=c.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},e}(Yv),tm={};var em=function(t,e){return e=Kv.assign({},tm,e),new Jv(t,e).execute()},nm=av;function rm(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=rm(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function im(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){im(t)}));var r=e[0],i=e[n-1],o=i.y-r.y+i.height,a=0;if(e.forEach((function(t){a+=t.totalHeight})),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>a){var s=t.y+(t.height-o)/2-r.y;e.forEach((function(t){t.translate(0,s)}))}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}var om={getSubTreeSep:function(){return 0}};function am(t,e){return am=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},am(t,e)}var sm=function(t,e){void 0===e&&(e={}),e=nm.assign({},om,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,rm(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var 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(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}})),im(t)},lm=Nv,um=av,cm=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,am(n,r),e.prototype.execute=function(){return lm(this.rootNode,this.options,sm)},e}(fv),hm={};var dm=function(t,e){return e=um.assign({},hm,e),new cm(t,e).execute()},fm={compactBox:Dv,dendrogram:Hv,indented:em,mindmap:dm};const pm=(t,e)=>{if("next"!==t&&"prev"!==t)return e},gm=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let vm=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 gm(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&gm(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,pm)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},mm=class extends vm{};const ym=()=>1,bm=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)xm(t,e,n,a);for(;a=i.dequeue();)xm(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(xm(t,e,n,a,!0));break}}return r},xm=(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,wm(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,wm(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},Em=(t,e)=>{const n=new Yg;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<a;t++)o.push(new mm);const s=r+1;return n.getAllNodes().forEach((t=>{wm(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},wm=(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)},km=(t,e)=>{const n=((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=Em(t,e||ym);return null===(n=bm(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)})}))},Mm=(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},Sm=t=>{const e=new Yg;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},Nm=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,l=Number(t.width)/2,u=Number(t.height)/2;return i||o?(Math.abs(o)*l>Math.abs(i)*u?(o<0&&(u=-u),a=u*i/o,s=u):(i<0&&(l=-l),a=l,s=l*o/i),{x:n+a,y:r+s}):{x:0,y:0}},Om=t=>{const e=[],n=Cm(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(let r=0;r<n;r++)e[r]=e[r].sort(((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},Tm=(t,e,n,r)=>{const i={width:0,height:0};return ae(n)&&ae(r)&&(i.rank=n,i.order=r),Mm(t,"border",i,e)},Cm=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},Am=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),Pm=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>Pm(t,e,n,r,i,o))),n&&o.push(e.id))},Rm=(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}`);Pm(t,e,"post"===n,s,o,a)})),a},Dm=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],l=Mm(t,"border",a,n);i.data[e][o]=l,t.setParent(l,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:l,data:{weight:1}})},Lm=t=>{t.getAllNodes().forEach((t=>{_m(t)})),t.getAllEdges().forEach((t=>{_m(t)}))},_m=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Im=t=>{t.getAllNodes().forEach((t=>{jm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>jm(t))),t.data.hasOwnProperty("y")&&jm(t.data)}))},jm=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},Bm=t=>{t.getAllNodes().forEach((t=>{Fm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Fm(t))),t.data.hasOwnProperty("x")&&Fm(t.data)}))},Fm=t=>{const e=t.x;t.x=t.y,t.y=e},zm=(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 l=Tm(t,"_bt"),u=Tm(t,"_bb"),c=t.getNode(a);t.setParent(l,a),c.data.borderTop=l,t.setParent(u,a),c.data.borderBottom=u,null==s||s.forEach((s=>{zm(t,e,n,r,i,o,s.id);const c=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=c!==h?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:h,target:u,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:l,data:{weight:0,minlen:i+o[a]}})},Gm=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},Vm=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Wm="edge-label",Hm=(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 l,u,c;for(t.removeEdge(e.id),c=0,++i;i<a;++c,++i)e.data.points=[],u={originalEdge:e,width:0,height:0,rank:i},l=Mm(t,"edge",u,"_d"),i===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=Wm,u.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:l,data:{weight:e.data.weight}}),0===c&&n.push(l),r=l;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},Um=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},$m=(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<n.length;)a<<=1;const s=2*a-1;a-=1;const l=Array(s).fill(0,0,s);let u=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;l[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=l[e+1]),e=e-1>>1,l[e]+=t.weight;u+=t.weight*n}})),u},Ym=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=$m(t,e[r-1],e[r]);return n},qm=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;t<i+1;t++)o.push([]);const a=n.sort(((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank)),s=a.filter((e=>void 0!==t.getNode(e.id).data.fixorder)).sort(((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder));return null==s||s.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},Xm=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)&&Km(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}))},Km=(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},Zm=(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},Qm=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i},Jm=(t,e,n,r,i,o)=>{var a,s,l,u;let c=t.getChildren(e).map((t=>t.id));const h=t.getNode(e),d=h?h.data.borderLeft:void 0,f=h?h.data.borderRight:void 0,p={};d&&(c=null==c?void 0:c.filter((t=>t!==d&&t!==f)));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,c||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=Jm(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&ey(e,i)}}));const v=((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 Xm(a)})(g,n);ty(v,p),null===(a=v.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 m=((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 l=0,u=0,c=0;null==o||o.sort(Qm(!!e,!!n)),c=Zm(s,a,c),null==o||o.forEach((t=>{var e;c+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,c=Zm(s,a,c)}));const h={vs:s.flat()};return u&&(h.barycenter=l/u,h.weight=u),h})(v,r,i,o);if(d&&(m.vs=[d,m.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(l=t.getPredecessors(d))||void 0===l?void 0:l[0].id)||""),n=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||"");m.hasOwnProperty("barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+e.data.order+n.data.order)/(m.weight+2),m.weight+=2}return m},ty=(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()}))},ey=(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)},ny=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Um(t),i=new Yg({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((o=>{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:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i})(t,e,n))),ry=(t,e,n,r)=>{const i=new Yg;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Jm(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)}))},iy=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},oy=(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 l=((t,e,n,r)=>{var i,o;const a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);let c,h;c=n;do{c=null===(i=t.getParent(c))||void 0===i?void 0:i.id,a.push(c)}while(c&&(e[c].low>l||u>e[c].lim));for(h=c,c=r;c&&c!==h;)s.push(c),c=null===(o=t.getParent(c))||void 0===o?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}})(t,n,s.source,s.target),u=l.path,c=l.lca;let h=0,d=u[h],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==c&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)h++,d=u[h];d===c&&(f=!1)}if(!f){for(;h<u.length-1&&(null===(i=t.getNode(u[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=u[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},ay=(t,e)=>{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,l;let u;for(let c=r;c<i;c++)u=e[c],(null===(s=t.getNode(u))||void 0===s?void 0:s.data.dummy)&&(null===(l=t.getPredecessors(u))||void 0===l||l.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&ly(n,e.id,u)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((l,u)=>{var c;if("border"===(null===(c=t.getNode(l))||void 0===c?void 0:c.data.dummy)){const e=t.getPredecessors(l)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,u,o,i],s),a=u,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},sy=(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))},ly=(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},uy=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},cy=(t,e,n,r,i,o)=>{const a=new Yg,s=hy(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],l=a.getRelatedEdges(o,"out").find((t=>t.target===i));l?a.updateEdgeData(l.id,Object.assign(Object.assign({},l.data),{weight:Math.max(s(t,e,r),l.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 hy=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let l=0,u=0;if(l+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":u=-a.data.width/2;break;case"r":u=a.data.width/2}if(u&&(l+=n?u:-u),u=0,l+=(a.data.dummy?e:t)/2,l+=(s.data.dummy?e:t)/2,l+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":u=s.data.width/2;break;case"r":u=-s.data.width/2}return u&&(l+=n?u:-u),u=0,l},dy=(t,e)=>t.getNode(e).data.width||0,fy=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=Om(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,l)=>{var u;const c=sy(t,e),h=c?t.getNode(c.id).data.order:a;(c||e===s)&&(null===(u=r.slice(o,l+1))||void 0===u||u.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<i||h<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||ly(n,r.id,e)}))})),o=l+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),ay(t,o)),s={};let l=[];["u","d"].forEach((e=>{l="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(l=l.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),u=((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 l=Math.floor(r),u=Math.ceil(r);l<=u;++l){const r=s[l];o[t]===t&&e<a[r]&&!uy(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,l,a,o),c=((t,e,n,r,i,o,a)=>{var s;const l={},u=cy(t,e,n,i,o,a),c=a?"borderLeft":"borderRight",h=(t,e)=>{let n=u.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 h((t=>{l[t]=(u.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(l[e.source]||0)+e.data.weight)),0)}),u.getPredecessors.bind(u)),h((e=>{const n=(u.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(l[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==c&&(l[e]=Math.max(l[e],n))}),u.getSuccessors.bind(u)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{l[t]=l[n[t]]})),l})(t,l,u.root,u.align,r,i,"r"===n);"r"===n&&Object.keys(c).forEach((t=>c[t]=-c[t])),s[e+n]=c}))}));const u=((t,e)=>Am(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=dy(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return u&&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 l;if(s===e)return;const u=Object.values(s);l="l"===o?r-Math.min(...u):i-Math.max(...u),l&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+l})))}))}))}(s,u),((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)},py=(t,e)=>{var n;const r=Sm(t);((t,e)=>{const{ranksep:n=0}=e||{},r=Om(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=fy(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},gy=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||e<a)&&(a=e)})),a||(a=0),o.data.rank=a,a};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>n(t.id)))},vy=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,my=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||vy(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},yy=(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&&vy(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},by=(t,e)=>Am(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?vy(e,n):1/0)),xy=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},Ey=t=>{const e=(t=>{const e=new Yg;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);gy(e);const n=(t=>{const e=new Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);my(e,t)<r;)i=by(e,t),o=e.hasNode(i.source)?vy(t,i):-vy(t,i),xy(e,t,o);return e})(e);let r,i;for(Sy(n),wy(n,e);r=Oy(n);)i=Ty(n,e,r),Cy(n,e,r,i)},wy=(t,e)=>{let n=Rm(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{ky(t,e,n)}))},ky=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=My(t,e,n)},My=(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,l=e.data.weight;if(a+=r?l:-l,Py(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},Sy=(t,e=t.getAllNodes()[0].id)=>{Ny(t,{},1,e)},Ny=(t,e,n,r,i)=>{var o;const a=n;let s=n;const l=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=Ny(t,e,s,n.id,r))})),l.data.low=a,l.data.lim=s++,i?l.data.parent=i:delete l.data.parent,s},Oy=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),Ty=(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,l=!1;o.data.lim>a.data.lim&&(s=a,l=!0);const u=e.getAllEdges().filter((e=>l===Ry(t.getNode(e.source),s)&&l!==Ry(t.getNode(e.target),s)));return Am(u,(t=>vy(e,t)))},Cy=(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:{}}),Sy(t),wy(t,e),Ay(t,e)},Ay=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=Rm(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))}))},Py=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),Ry=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Dy=gy,Ly=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||e<s)&&(s=e)})),s||(s=0),(void 0===n||s<n)&&(n=s),a.data.rank=s,s};t.getAllNodes().filter((e=>0===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<s)&&(a.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach((t=>{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 Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);yy(e,t)<r;)i=by(e,t),o=e.hasNode(i.source)?vy(t,i):-vy(t,i),xy(e,t,o)})(t)},_y=t=>{Ey(t)},Iy=(t,e)=>{const{ranker:n,rankdir:r="tb",nodeOrder:i,keepNodeOrder:o,align:a,nodesep:s=50,edgesep:l=20,ranksep:u=50}=e;tb(t),km(t);const{nestingRoot:c,nodeRankFactor:h}=(t=>{const e=Mm(t,"root",{},"_root"),n=Gm(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=Vm(t)+1;return t.getRoots().forEach((r=>{zm(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":_y(t);break;case"tight-tree":default:Ly(t);break;case"longest-path":Dy(t)}})(Sm(t),n),$y(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<o.length;n++){const r=o[n];void 0===r?n%e!=0&&(a-=1):a&&(null==r||r.forEach((e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}})(t,h),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach((e=>{e.data.nestingEdge&&t.removeEdge(e.id)}))})(t,c),(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),Yy(t),qy(t);const d=[];((t,e)=>{t.getAllEdges().forEach((n=>Hm(t,n,e)))})(t,d),oy(t,d),(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;e<r;e+=1)Dm(t,"borderLeft","_bl",n,i,e),Dm(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach((t=>e(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)})).map((t=>t.data.rank)),r=Math.max(...n),i=[];for(let t=0;t<r+1;t++)i[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=i[n.data.rank].length,i[n.data.rank].push(e)))}))})(t,i),((t,e)=>{const n=Cm(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=ny(t,r,"in"),a=ny(t,i,"out");let s=qm(t);iy(t,s);let l,u=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){ry(n%2?o:a,n%4>=2,!1,e),s=Om(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}s=qm(t),iy(t,s);for(let n=0,r=0;r<4;++n,++r){ry(n%2?o:a,n%4>=2,!0,e),s=Om(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}iy(t,l)})(t,o),eb(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||Lm(t)})(t,r),py(t,{align:a,nodesep:s,edgesep:l,ranksep:u}),nb(t),Jy(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===Wm&&(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,d),Zy(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Im(t),"lr"!==n&&"rl"!==n||(Bm(t),Lm(t))})(t,r);const{width:f,height:p}=Xy(t);return Ky(t),Qy(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:f,height:p}},jy=(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}))},By=(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)}))},Fy=["width","height","layer","fixorder"],zy={width:0,height:0},Gy=["minlen","weight","width","height","labeloffset"],Vy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Wy=["labelpos"],Hy=t=>{const e=new Yg({tree:[]});return t.getAllNodes().forEach((n=>{const r=ib(t.getNode(n.id).data),i=Object.assign(Object.assign({},zy),r),o=rb(i,Fy);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);$t(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=ib(t.getEdge(n.id).data),i={};null==Wy||Wy.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},Vy,rb(r,Gy),i)})})),e},Uy=(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},$y=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};Mm(t,"edge-proxy",r,"_ep")}}))},Yy=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},qy=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))}))},Xy=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}={},l=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,l=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(l)||(void 0===r&&(r=a-l/2),r=Math.min(r,a-l/2),o=Math.max(o,a+l/2))};return t.getAllNodes().forEach((t=>{l(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&l(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}},Ky=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(Nm(n.data,i)),e.data.points.push(Nm(r.data,o))}))},Zy=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}}))},Qy=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Jy=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]),l=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==l?void 0:l.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)}))},tb=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)}}))},eb=t=>{const e=Om(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=>{Mm(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},nb=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}}))},rb=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},ib=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},ob=Array.isArray,ab=t=>{const e=[],n=t.length;for(let r=0;r<n;r+=1){e[r]=[];for(let i=0;i<n;i+=1)r===i?e[r][i]=0:0!==t[r][i]&&t[r][i]?e[r][i]=t[r][i]:e[r][i]=1/0}for(let t=0;t<n;t+=1)for(let r=0;r<n;r+=1)for(let i=0;i<n;i+=1)e[r][i]>e[r][t]+e[t][i]&&(e[r][i]=e[r][t]+e[t][i]);return e},sb=(t,e)=>{const{nodes:n,edges:r}=t,i=[],o={};if(!n)throw new Error("invalid nodes data!");return n&&n.forEach(((t,e)=>{o[t.id]=e;i.push([])})),null==r||r.forEach((t=>{const{source:e,target:n}=t,r=o[e],a=o[n];void 0!==r&&void 0!==a&&(i[r][a]=1,i[a][r]=1)})),i},lb=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),ub=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let l=0;l<e.length;l++){const u=e[l];if(t.hasNode(u.id)&&!(null==a?void 0:a(u))){if(null==s?void 0:s(u))return;"TB"===r&&n(u),ub(t,t.getChildren(u.id,i),n,r,i,o),"TB"!==r&&n(u)}}},cb=t=>{if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){const e=[];return t.forEach((t=>{e.push(t)})),e.map((t=>cb(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=cb(t[n])})),e}return t},hb=(t,e)=>{const n=cb(t);return n.data=n.data||{},e&&(ae(n.data.x)||(n.data.x=Math.random()*e[0]),ae(n.data.y)||(n.data.y=Math.random()*e[1])),n};function db(t){if(!t)return[0,0,0];if(ae(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function fb(t,e){let n;return n=Ut(e)?e:ae(e)?()=>e:()=>t,n}function pb(t,e,n=!0){return e||0===e?Ut(e)?e:ae(e)?()=>e:Array.isArray(e)?()=>n?Math.max(...e)||t:e:qt(e)&&e.width&&e.height?()=>n?Math.max(e.width,e.height)||t:[e.width,e.height]:()=>t:e=>{const{size:r}=e.data||{};return r?Array.isArray(r)?n?Math.max(...r)||t:r:qt(r)&&r.width&&r.height?n?Math.max(r.width,r.height)||t:[r.width,r.height]:r:t}}const gb=(t,e,n=10)=>{let r;const i="function"==typeof e?e:()=>e||0;r=t?Array.isArray(t)?e=>t:Ut(t)?t:e=>t:t=>{var e,r,i;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return null===(r=t.data)||void 0===r?void 0:r.bboxSize;if(null===(i=t.data)||void 0===i?void 0:i.size){const e=t.data.size;return Array.isArray(e)?e:qt(e)?[e.width,e.height]:e}return n};return t=>{const e=r(t),n=i(t);return Math.max(...db(e))+n}},vb={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class mb{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},vb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{nodeSize:i,align:o,rankdir:a="TB",ranksep:s,nodesep:l,ranksepFunc:u,nodesepFunc:c,edgeLabelSpace:h,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:v,sortByCombo:m,preset:y}=r,b=new Yg({tree:[]}),x=fb(s||50,u),E=fb(l||50,c);let w=E,k=x;"LR"!==a&&"RL"!==a||(w=x,k=E);const M=pb(10,i,!1),S=e.getAllNodes(),N=e.getAllEdges();let O;S.forEach((t=>{const e=db(M(t)),n=k(t),r=w(t),i=e[0]+2*r,o=e[1]+2*n,a=t.data.layer;ae(a)?b.addNode({id:t.id,data:{width:i,height:o,layer:a}}):b.addNode({id:t.id,data:{width:i,height:o}})})),m&&(b.attachTreeStructure("combo"),S.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),N.forEach((t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),(null==y?void 0:y.length)&&(O=new Yg({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&jy(t,i);const s=Hy(t);let l;n&&(e.ranksep=Uy(s,{rankdir:o,ranksep:a}));try{l=Iy(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}By(t,s)})(b,{prevGraph:O,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:l,align:o});const T=[0,0];if(p){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)}))})),T[0]=p[0]-t,T[1]=p[1]-e}const C="LR"===a||"RL"===a;if(v);else{const t=new Set,e="BT"===a||"RL"===a?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach((e=>{e.data.x=e.data.x+T[0],e.data.y=e.data.y+T[1],t.add(C?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=C?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=C?(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 o;h&&g&&"loop"!==t.data.type&&(t.data.controlPoints=yb(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+T[0],y:e+T[1]}))),b.getNode(t.source),b.getNode(t.target),n,C,r,i))}))}let A=[];A=b.getAllNodes().map((t=>hb(t)));const P=b.getAllEdges();t&&(A.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),P.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:A,edges:P}}))}}const yb=(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:l}=e.data,{x:u,y:c}=n.data;if(i&&(t=e.data.y,l=e.data.x,u=n.data.y,c=n.data.x),c!==l&&t!==u){const h=r.indexOf(l),d=r[h+1];if(d){const t=s[0],e=i?{x:(l+d)/2,y:(null==t?void 0:t.y)||u}:{x:(null==t?void 0:t.x)||u,y:(l+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(c),p=Math.abs(f-h);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(l+c)/2,y:t}:{x:t,y:(l+c)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(c+e)/2,y:(null==n?void 0:n.y)||u}:{x:(null==n?void 0:n.x)||t,y:(c+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},bb=(t,e,n)=>{const r=t.getAllNodes(),i=t.getAllEdges();if(!(null==r?void 0:r.length)){return{nodes:[],edges:i}}if(1===r.length){e&&t.mergeNodeData(r[0].id,{x:n[0],y:n[1]});return{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:n[0],y:n[1]})})],edges:i}}},xb={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class Eb{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},xb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:l=0,endAngle:u=2*Math.PI,angleRatio:c,ordering:h,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),v=e.getAllEdges(),[m,y,b]=kb(i,o,a),x=null==g?void 0:g.length;if(!x||1===x)return bb(e,t,b);const E=(u-l)/x;let{radius:w,startRadius:k,endRadius:M}=r;if(f){const t=fb(10,f),e=pb(10,p);let n=-1/0;g.forEach((t=>{const r=e(t);n<r&&(n=r)}));let r=0;g.forEach(((e,i)=>{r+=0===i?n||10:(t(e)||0)+(n||10)})),w=r/(2*Math.PI)}else w||k||M?!k&&M?k=M:k&&!M&&(M=k):w=Math.min(y,m)/2;const S=E*c;let N=[];N="topology"===h?wb(e,g):"topology-directed"===h?wb(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(hb(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>hb(t)));const O=Math.ceil(x/s);for(let t=0;t<x;++t){let e=w;e||null===k||null===M||(e=k+t*(M-k)/(x-1)),e||(e=10+100*t/(x-1));let n=l+t%O*S+2*Math.PI/s*Math.floor(t/O);d||(n=u-t%O*S-2*Math.PI/s*Math.floor(t/O)),N[t].data.x=b[0]+Math.cos(n)*e,N[t].data.y=b[1]+Math.sin(n)*e}t&&N.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:N,edges:v}}))}}const wb=(t,e,n=!1)=>{const r=[hb(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,l)=>{if(0!==l)if(l!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[l+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const l=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let u=!1;for(let e=0;e<l.length;e++){const n=l[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(hb(n)),i[n.id]=!0,u=!0;break}}let c=0;for(;!u&&(i[e[c].id]||(r.push(hb(e[c])),i[e[c].id]=!0,u=!0),c++,c!==o););}else r.push(hb(s)),i[s.id]=!0,a++})),r};const kb=(t,e,n)=>{let r=t,i=e,o=n;return r||"undefined"==typeof window||(r=window.innerWidth),i||"undefined"==typeof window||(i=window.innerHeight),o||(o=[r/2,i/2]),[r,i,o]},Mb={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Sb{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Mb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:l,sweep:u,clockwise:c,equidistant:h,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,v=e.getAllNodes(),m=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,x=i||[y/2,b/2];if(!(null==v?void 0:v.length)||1===v.length)return bb(e,t,x);const E=[];let w,k=0;ob(p)?w=Math.max(p[0],p[1]):Ut(p)?(w=-1/0,v.forEach((t=>{const e=Math.max(...db(p(t)));e>w&&(w=e)}))):w=p,ob(g)?k=Math.max(g[0],g[1]):ae(g)&&(k=g),v.forEach((t=>{const e=hb(t);E.push(e);let n=w;const{data:r}=e;ob(r.size)?n=Math.max(r.size[0],r.size[1]):ae(r.size)?n=r.size:qt(r.size)&&(n=Math.max(r.size.width,r.size.height)),w=Math.max(w,n),Ut(g)&&(k=Math.max(g(t),k))}));const M={};E.forEach(((t,e)=>{M[t.id]=e}));let S=s;ne(S)&&void 0!==E[0].data[S]||(S="degree"),"degree"===S?E.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):E.sort(((t,e)=>e.data[S]-t.data[S]));const N=E[0],O=(l||("degree"===S?e.getDegree(N.id,"both"):N.data[S]))/4,T=[{nodes:[]}];let C=T[0];E.forEach((t=>{if(C.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(C.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(C.nodes[0].data[S]-t.data[S]);O&&n>=O&&(C={nodes:[]},T.push(C))}C.nodes.push(t)}));let A=w+k;if(!d){const t=T.length>0&&T[0].nodes.length>1,e=(Math.min(y,b)/2-A)/(T.length+(t?1:0));A=Math.min(A,e)}let P=0;if(T.forEach((t=>{const e=void 0===u?2*Math.PI-2*Math.PI/t.nodes.length:u;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){const e=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),r=Math.sqrt(A*A/(e*e+n*n));P=Math.max(r,P)}t.r=P,P+=A})),h){let t=0,e=0;for(let n=0;n<T.length;n++){const r=(T[n].r||0)-e;t=Math.max(t,r)}e=0,T.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}T.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(c?1:-1)*e*r;t.data.x=x[0]+n*Math.cos(i),t.data.y=x[1]+n*Math.sin(i)}))})),t&&E.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:E,edges:m}}))}}function Nb(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,l,u,c,h,d,f=t._root,p={data:r},g=t._x0,v=t._y0,m=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a,i=f,!(f=f[h=c<<1|u]))return i[h]=p,t;if(s=+t._x.call(null,f.data),l=+t._y.call(null,f.data),e===s&&n===l)return p.next=f,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a}while((h=c<<1|u)==(d=(l>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function Ob(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Tb(t){return t[0]}function Cb(t){return t[1]}function Ab(t,e,n){var r=new Pb(null==e?Tb:e,null==n?Cb:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Pb(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 Rb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Db=Ab.prototype=Pb.prototype;function Lb(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,l,u,c,h,d,f,p,g,v,m=t._root,y={data:i},b=t._x0,x=t._y0,E=t._z0,w=t._x1,k=t._y1,M=t._z1;if(!m)return t._root=y,t;for(;m.length;)if((d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l,o=m,!(m=m[g=p<<2|f<<1|d]))return o[g]=y,t;if(u=+t._x.call(null,m.data),c=+t._y.call(null,m.data),h=+t._z.call(null,m.data),e===u&&n===c&&r===h)return y.next=m,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l}while((g=p<<2|f<<1|d)==(v=(h>=l)<<2|(c>=s)<<1|u>=a));return o[v]=m,o[g]=y,t}function _b(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}Db.copy=function(){var t,e,n=new Pb(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=Rb(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=Rb(e));return n},Db.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Nb(this.cover(e,n),e,n,t)},Db.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<o;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<l&&(l=r),r>c&&(c=r),i<u&&(u=i),i>h&&(h=i));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<o;++n)Nb(this,a[n],s[n],t[n]);return this},Db.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a,s,l=i-n||1,u=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=u,u=a,l*=2,s){case 0:i=n+l,o=r+l;break;case 1:n=i-l,o=r+l;break;case 2:i=n+l,r=o-l;break;case 3:n=i-l,r=o-l}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},Db.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Db.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},Db.find=function(t,e,n){var r,i,o,a,s,l,u,c=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new Ob(g,c,h,d,f)),null==n?n=1/0:(c=t-n,h=e-n,d=t+n,f=e+n,n*=n);l=p.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(o=l.y0)>f||(a=l.x1)<c||(s=l.y1)<h))if(g.length){var v=(i+a)/2,m=(o+s)/2;p.push(new Ob(g[3],v,m,a,s),new Ob(g[2],i,m,v,s),new Ob(g[1],v,o,a,m),new Ob(g[0],i,o,v,m)),(u=(e>=m)<<1|t>=v)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-u],p[p.length-1-u]=l)}else{var y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),x=y*y+b*b;if(x<n){var E=Math.sqrt(n=x);c=t-E,h=e-E,d=t+E,f=e+E,r=g.data}}return r},Db.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,l,u,c,h,d,f=this._root,p=this._x0,g=this._y0,v=this._x1,m=this._y1;if(!f)return this;if(f.length)for(;;){if((u=o>=(s=(p+v)/2))?p=s:v=s,(c=a>=(l=(g+m)/2))?g=l:m=l,e=f,!(f=f[h=c<<1|u]))return this;if(!f.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},Db.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Db.root=function(){return this._root},Db.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Db.visit=function(t){var e,n,r,i,o,a,s=[],l=this._root;for(l&&s.push(new Ob(l,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&l.length){var u=(r+o)/2,c=(i+a)/2;(n=l[3])&&s.push(new Ob(n,u,c,o,a)),(n=l[2])&&s.push(new Ob(n,r,c,u,a)),(n=l[1])&&s.push(new Ob(n,u,i,o,c)),(n=l[0])&&s.push(new Ob(n,r,i,u,c))}return this},Db.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Ob(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,l=e.x1,u=e.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&n.push(new Ob(o,a,s,c,h)),(o=i[1])&&n.push(new Ob(o,c,s,l,h)),(o=i[2])&&n.push(new Ob(o,a,h,c,u)),(o=i[3])&&n.push(new Ob(o,c,h,l,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Db.x=function(t){return arguments.length?(this._x=t,this):this._x},Db.y=function(t){return arguments.length?(this._y=t,this):this._y};const Ib=(t,e,n,r,i,o)=>Math.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function jb(t){return t[0]}function Bb(t){return t[1]}function Fb(t){return t[2]}function zb(t,e,n,r){var i=new Gb(null==e?jb:e,null==n?Bb:n,null==r?Fb:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Gb(t,e,n,r,i,o,a,s,l){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=l,this._root=void 0}function Vb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Wb=zb.prototype=Gb.prototype;Wb.copy=function(){var t,e,n=new Gb(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=Vb(r),n;for(t=[{source:r,target:n._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(8)}):r.target[i]=Vb(e));return n},Wb.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Lb(this.cover(e,n,r),e,n,r,t)},Wb.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let o=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(f=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>l&&(l=d),f<a&&(a=f),f>u&&(u=f),p<s&&(s=p),p>c&&(c=p));if(o>l||a>u||s>c)return this;this.cover(o,a,s).cover(l,u,c);for(let o=0;o<e;++o)Lb(this,n[o],r[o],i[o],t[o]);return this},Wb.cover=function(t,e,n){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,o=this._z0,a=this._x1,s=this._y1,l=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,l=(o=Math.floor(n))+1;else{for(var u,c,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=l;)switch(c=(n<o)<<2|(e<i)<<1|t<r,(u=new Array(8))[c]=d,d=u,h*=2,c){case 0:a=r+h,s=i+h,l=o+h;break;case 1:r=a-h,s=i+h,l=o+h;break;case 2:a=r+h,i=s-h,l=o+h;break;case 3:r=a-h,i=s-h,l=o+h;break;case 4:a=r+h,s=i+h,o=l-h;break;case 5:r=a-h,s=i+h,o=l-h;break;case 6:a=r+h,i=s-h,o=l-h;break;case 7:r=a-h,i=s-h,o=l-h}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=l,this},Wb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Wb.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Wb.find=function(t,e,n,r){var i,o,a,s,l,u,c,h,d,f=this._x0,p=this._y0,g=this._z0,v=this._x1,m=this._y1,y=this._z1,b=[],x=this._root;for(x&&b.push(new _b(x,f,p,g,v,m,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,v=t+r,m=e+r,y=n+r,r*=r);h=b.pop();)if(!(!(x=h.node)||(o=h.x0)>v||(a=h.y0)>m||(s=h.z0)>y||(l=h.x1)<f||(u=h.y1)<p||(c=h.z1)<g))if(x.length){var E=(o+l)/2,w=(a+u)/2,k=(s+c)/2;b.push(new _b(x[7],E,w,k,l,u,c),new _b(x[6],o,w,k,E,u,c),new _b(x[5],E,a,k,l,w,c),new _b(x[4],o,a,k,E,w,c),new _b(x[3],E,w,s,l,u,k),new _b(x[2],o,w,s,E,u,k),new _b(x[1],E,a,s,l,w,k),new _b(x[0],o,a,s,E,w,k)),(d=(n>=k)<<2|(e>=w)<<1|t>=E)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=h)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),N=n-+this._z.call(null,x.data),O=M*M+S*S+N*N;if(O<r){var T=Math.sqrt(r=O);f=t-T,p=e-T,g=n-T,v=t+T,m=e+T,y=n+T,i=x.data}}return i},Wb.findAllWithinRadius=function(t,e,n,r){const i=[],o=t-r,a=e-r,s=n-r,l=t+r,u=e+r,c=n+r;return this.visit(((h,d,f,p,g,v,m)=>{if(!h.length)do{const o=h.data;Ib(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(h=h.next);return d>l||f>u||p>c||g<o||v<a||m<s})),i},Wb.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,n,r,i,o,a,s,l,u,c,h,d,f,p,g,v=this._root,m=this._x0,y=this._y0,b=this._z0,x=this._x1,E=this._y1,w=this._z1;if(!v)return this;if(v.length)for(;;){if((h=o>=(l=(m+x)/2))?m=l:x=l,(d=a>=(u=(y+E)/2))?y=u:E=u,(f=s>=(c=(b+w)/2))?b=c:w=c,e=v,!(v=v[p=f<<2|d<<1|h]))return this;if(!v.length)break;(e[p+1&7]||e[p+2&7]||e[p+3&7]||e[p+4&7]||e[p+5&7]||e[p+6&7]||e[p+7&7])&&(n=e,g=p)}for(;v.data!==t;)if(r=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(n?n[g]=v:this._root=v),this):(this._root=i,this)},Wb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Wb.root=function(){return this._root},Wb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Wb.visit=function(t){var e,n,r,i,o,a,s,l,u=[],c=this._root;for(c&&u.push(new _b(c,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=u.pop();)if(!t(c=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,l=e.z1)&&c.length){var h=(r+a)/2,d=(i+s)/2,f=(o+l)/2;(n=c[7])&&u.push(new _b(n,h,d,f,a,s,l)),(n=c[6])&&u.push(new _b(n,r,d,f,h,s,l)),(n=c[5])&&u.push(new _b(n,h,i,f,a,d,l)),(n=c[4])&&u.push(new _b(n,r,i,f,h,d,l)),(n=c[3])&&u.push(new _b(n,h,d,o,a,s,f)),(n=c[2])&&u.push(new _b(n,r,d,o,h,s,f)),(n=c[1])&&u.push(new _b(n,h,i,o,a,d,f)),(n=c[0])&&u.push(new _b(n,r,i,o,h,d,f))}return this},Wb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new _b(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,l=e.z0,u=e.x1,c=e.y1,h=e.z1,d=(a+u)/2,f=(s+c)/2,p=(l+h)/2;(o=i[0])&&n.push(new _b(o,a,s,l,d,f,p)),(o=i[1])&&n.push(new _b(o,d,s,l,u,f,p)),(o=i[2])&&n.push(new _b(o,a,f,l,d,c,p)),(o=i[3])&&n.push(new _b(o,d,f,l,u,c,p)),(o=i[4])&&n.push(new _b(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new _b(o,d,s,p,u,f,h)),(o=i[6])&&n.push(new _b(o,a,f,p,d,c,h)),(o=i[7])&&n.push(new _b(o,d,f,p,u,c,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Wb.x=function(t){return arguments.length?(this._x=t,this):this._x},Wb.y=function(t){return arguments.length?(this._y=t,this):this._y},Wb.z=function(t){return arguments.length?(this._z=t,this):this._z};function Hb(t,e,n,r,i=2){const o=e/n,a=t.getAllNodes(),s=a.map(((t,e)=>{const{nodeStrength:n,x:r,y:i,z:a,size:s}=t.data;return{x:r,y:i,z:a,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n}})),l=(2===i?Ab(s,(t=>t.x),(t=>t.y)):zb(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Ub),u=new Map;return s.forEach((t=>{u.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>$b(e,r,i,o,a,t,n)))}(t,l,i)})),s.map(((t,e)=>{const{id:n,data:i}=a[e],{mass:o=1}=i;r[n]={x:t.vx/o,y:t.vy/o,z:t.vz/o}})),r}function Ub(t){let e=0,n=0,r=0,i=0,o=0;const a=t.length;if(a){for(let s=0;s<a;s++){const a=t[s];a&&a.weight&&(e+=a.weight,n+=a.x*a.weight,r+=a.y*a.weight,i+=a.z*a.weight,o+=a.size*a.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const $b=(t,e,n,r,i,o,a)=>{var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===o.id)return;const l=[n,r,i][a-1],u=o.x-t.x||.1,c=o.y-t.y||.1,h=o.z-t.z||.1,d=[u,c,h],f=l-e;let p=0;for(let t=0;t<a;t++)p+=d[t]*d[t];const g=Math.sqrt(p)*p;if(f*f*.81<p){const e=t.weight/g;return o.vx+=u*e,o.vy+=c*e,o.vz+=h*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=u*e,o.vy+=c*e,o.vz+=h*e}};const Yb={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,preventOverlap:!0,distanceThresholdMode:"mean"};class qb{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Yb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;(this.judgingDistance>this.lastOptions.minMovement||e<1)&&e<t;e++)this.runOneStep(this.lastCalcGraph,this.lastGraph,e,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericForceLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),{dimensions:s,width:l,height:u,nodeSize:c,getMass:h,nodeStrength:d,edgeStrength:f,linkDistance:p}=a,g=i.map(((t,e)=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{x:ae(t.data.x)?t.data.x:Math.random()*l,y:ae(t.data.y)?t.data.y:Math.random()*u,z:ae(t.data.z)?t.data.z:Math.random()*Math.sqrt(l*u),size:c(t)||30,mass:h(t),nodeStrength:d(t)})}))),v=o.map((t=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{edgeStrength:f(t),linkDistance:p(t,e.getNode(t.source),e.getNode(t.target))})})));if(!(null==i?void 0:i.length))return this.lastResult={nodes:[],edges:o},{nodes:[],edges:o};const m={};i.forEach(((t,e)=>{m[t.id]={x:0,y:0,z:0}}));const y=new Yg({nodes:g,edges:v});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:x,onTick:E}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=m,"undefined"==typeof window)return;let w=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Jb(e,g),edges:o}),this.runOneStep(y,e,w,m,a),this.updatePosition(e,y,m,a),t&&g.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0}))),null==E||E({nodes:Jb(e,g),edges:o}),w++,(w>=b||this.judgingDistance<x)&&(window.clearInterval(this.timeInterval),n({nodes:Jb(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o}=t;n.width=r||"undefined"==typeof window?r:window.innerWidth,n.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(n.center=[n.width/2,n.height/2]),o||(n.getMass=t=>{let n=1;ae(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);const r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n}),n.nodeSize=gb(t.nodeSize,t.nodeSpacing);const a=t.linkDistance?fb(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=a,n.nodeStrength=fb(1,t.nodeStrength),n.edgeStrength=fb(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:l}=t,u=e.getAllNodes(),c=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let h,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&l&&(h=Xb(e,l),d=Array.from(new Set(null==u?void 0:u.map((t=>t.data[l]))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=h[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==d?void 0:d.length)?1:t.clusterNodeStrength(e)},others:1,center:t=>{const n=e.getDegree(t.id,"both");if(!n)return{x:100,y:100,z:0};let r;if(1===n){const{sameTypeLeaves:e=[]}=h[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Qb(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),s&&l){h||(h=Xb(e,l)),d||(d=Array.from(new Set(u.map((t=>t.data[l]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=u.filter((e=>e.data[l]===t)).map((t=>e.getNode(t.id)));n[t]=Qb(r)})),t.centripetalOptions=Object.assign(c,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[l]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}const{leaf:f,single:p,others:g}=t.centripetalOptions||{};f&&"function"!=typeof f&&(t.centripetalOptions.leaf=()=>f),p&&"function"!=typeof p&&(t.centripetalOptions.single=()=>p),g&&"function"!=typeof g&&(t.centripetalOptions.others=()=>g)}runOneStep(t,e,n,r,i){const o={},a=t.getAllNodes(),s=t.getAllEdges();if(!(null==a?void 0:a.length))return;const{monitor:l}=i;if(this.calRepulsive(t,o,i),s&&this.calAttractive(t,o,i),this.calGravity(t,e,o,i),this.updateVelocity(t,o,r,i),l){l({energy:this.calTotalEnergy(o,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:n})}}calTotalEnergy(t,e){if(!(null==e?void 0:e.length))return 0;let n=0;return e.forEach(((e,r)=>{const i=t[e.id].x,o=t[e.id].y,a=3===this.options.dimensions?t[e.id].z:0,s=i*i+o*o+a*a,{mass:l=1}=e.data;n+=l*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;Hb(t,i,o*o,e,r)}calAttractive(t,e,n){const{dimensions:r,nodeSize:i}=n;t.getAllEdges().forEach(((n,o)=>{const{source:a,target:s}=n,l=t.getNode(a),u=t.getNode(s);if(!l||!u)return;let c=u.data.x-l.data.x,h=u.data.y-l.data.y,d=3===r?u.data.z-l.data.z:0;c||h||(c=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(c*c+h*h+d*d);if(f<i(l)+i(u))return;const p=c/f,g=h/f,v=d/f,{linkDistance:m=200,edgeStrength:y=200}=n.data||{},b=(m-f)*y,x=1/(l.data.mass||1),E=1/(u.data.mass||1),w=p*b,k=g*b,M=v*b;e[a].x-=w*x,e[a].y-=k*x,e[a].z-=M*x,e[s].x+=w*E,e[s].y+=k*E,e[s].z+=M*E}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:l,height:u,center:c,gravity:h,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:v,z:m}=f,y=e.getNode(o);let b=0,x=0,E=0,w=h;const k=t.getDegree(o,"in"),M=t.getDegree(o,"out"),S=t.getDegree(o,"both"),N=null==i?void 0:i(y,S);if(N){const[t,e,n]=N;b=g-t,x=v-e,w=n}else b=g-c[0],x=v-c[1],E=m-c[2];if(w&&(n[o].x-=w*b/p,n[o].y-=w*x/p,n[o].z-=w*E/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:c,y:h,z:f,centerStrength:b}=(null==i?void 0:i(y,a,s,l,u))||{x:0,y:0,z:0,centerStrength:0};if(!ae(c)||!ae(h))return;const x=(g-c)/p,E=(v-h)/p,w=(m-f)/p;if(b&&(n[o].x-=b*x,n[o].y-=b*E,n[o].z-=b*w),0===S){const t=e(y);if(!t)return;return n[o].x-=t*x,n[o].y-=t*E,void(n[o].z-=t*w)}if(0===k||0===M){const e=t(y,a,s);if(!e)return;return n[o].x-=e*x,n[o].y-=e*E,void(n[o].z-=e*w)}const N=r(y);if(!N)return;n[o].x-=N*x,n[o].y-=N*E,n[o].z-=N*w}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,l=t.getAllNodes();(null==l?void 0:l.length)&&l.forEach((t=>{const{id:r}=t;let l=(n[r].x+e[r].x*a)*i||.01,u=(n[r].y+e[r].y*a)*i||.01,c=3===s?(n[r].z+e[r].z*a)*i||.01:0;const h=Math.sqrt(l*l+u*u+c*c);if(h>o){const t=o/h;l*=t,u*=t,c*=t}n[r]={x:l,y:u,z:c}}))}updatePosition(t,e,n,r){const{distanceThresholdMode:i,interval:o,dimensions:a}=r,s=e.getAllNodes();if(!(null==s?void 0:s.length))return void(this.judgingDistance=0);let l=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,u=t.getNode(s);if(ae(u.data.fx)&&ae(u.data.fy))return void e.mergeNodeData(s,{x:u.data.fx,y:u.data.fy,z:3===a?u.data.fz:void 0});const c=n[s].x*o,h=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+c,y:r.data.y+h,z:r.data.z+d});const f=Math.sqrt(c*c+h*h+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:l+=f}})),i&&"mean"!==i||(this.judgingDistance=l/s.length)}}const Xb=(t,e)=>{const n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};const r={};return n.forEach(((n,i)=>{1===t.getDegree(n.id,"both")&&(r[n.id]=Kb(t,"leaf",n,e))})),r},Kb=(t,e,n,r)=>{const i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out");let a=n,s=[];0===i?(a=t.getSuccessors(n.id)[0],s=t.getNeighbors(a.id)):0===o&&(a=t.getPredecessors(n.id)[0],s=t.getNeighbors(a.id)),s=s.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")));return{coreNode:a,siblingLeaves:s,sameTypeLeaves:Zb(t,e,r,n,s)}},Zb=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out"))),a},Qb=t=>{const e={x:0,y:0};t.forEach((t=>{const{x:n,y:r}=t.data;e.x+=n||0,e.y+=r||0}));const n=t.length||1;return{x:e.x/n,y:e.y/n}},Jb=(t,e)=>e.map((e=>{const{id:n,data:r}=e,i=t.getNode(n);return Object.assign(Object.assign({},i),{data:Object.assign(Object.assign({},i.data),{x:r.x,y:r.y,z:r.z})})}));var tx={};const ex=Object.prototype.toString;function nx(t){const e=ex.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var rx=w(Object.freeze({__proto__:null,isAnyArray:nx}));var ix=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(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(!nx(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(!nx(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;s<o;s++)t[s]<a&&(a=t[s]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(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;s<o;s++)t[s]>a&&(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,l=void 0===s?n.autoMinMax?i:1:s;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var u=(l-a)/(i-r),c=0;c<t.length;c++)e[c]=(t[c]-r)*u+a;return e}}),ox=w(ix);Object.defineProperty(tx,"__esModule",{value:!0});var ax=rx,sx=ox;const lx=" ".repeat(2),ux=" ".repeat(4);function cx(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${lx}[\n${ux}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),l=Math.min(a,n),u=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){i=!0;break t}}for(let e=0;e<s;e++){let n=[];for(let o=0;o<l;o++)n.push(hx(t.get(e,o),r,i));u.push(`${n.join(" ")}`)}l!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);s!==o&&u.push(`... ${o-e} more rows`);return u.join(`\n${ux}`)}(t,n,r,i,o)}\n${lx}]\n${lx}rows: ${t.rows}\n${lx}columns: ${t.columns}\n}`}function hx(t,e,n){return(t>=0&&n?` ${dx(t,e-1)}`:dx(t,e)).padEnd(e)}function dx(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 fx(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 px(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 gx(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 vx(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 mx(t,e){if(!ax.isAnyArray(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}function yx(t,e){if(!ax.isAnyArray(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}function bx(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(Ex("startRow",e),Ex("endRow",n),Ex("startColumn",r),Ex("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 xx(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function Ex(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function wx(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class kx{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new Sx(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.set(i,t,n[i*e+t]);return r}static rowVector(t){let e=new Sx(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new Sx(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new Sx(t,e)}static ones(t,e){return new Sx(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new Sx(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,r());return i}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:o=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let a=i-r,s=new Sx(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=r+Math.round(o()*a);s.set(n,t,e)}return s}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let r=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<r;t++)i.set(t,t,n);return i}static diag(t,e,n){let r=t.length;void 0===e&&(e=r),void 0===n&&(n=e);let i=Math.min(r,e,n),o=this.zeros(e,n);for(let e=0;e<i;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new Sx(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.min(t.get(o,n),e.get(o,n)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new this(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.max(t.get(o,n),e.get(o,n)));return i}static checkMatrix(t){return kx.isMatrix(t)?t:new Sx(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.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<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let a=i;a<e;a++){let e=t.get(n,a)-o*t.get(r,a);t.set(n,a,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new Sx(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)r.setSubMatrix(this,this.rows*t,this.columns*e);return r}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){fx(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return Sx.rowVector(this.getRow(t))}setRow(t,e){fx(this,t),e=gx(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){fx(this,t),fx(this,e);for(let n=0;n<this.columns;n++){let r=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,r)}return this}getColumn(t){px(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return Sx.columnVector(this.getColumn(t))}setColumn(t,e){px(this,t),e=vx(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){px(this,t),px(this,e);for(let n=0;n<this.rows;n++){let r=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,r)}return this}addRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){fx(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){px(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[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;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){wx(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>t&&(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;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){wx(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}maxRow(t){if(fx(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){fx(this,t),wx(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(fx(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){fx(this,t),wx(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r),n[1]=r);return n}maxColumn(t){if(px(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){px(this,t),wx(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(px(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){px(this,t),wx(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){kx.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}mmul(t){t=Sx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new Sx(e,r),o=new Float64Array(n);for(let a=0;a<r;a++){for(let e=0;e<n;e++)o[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,a,e)}}return i}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=Sx.eye(this.rows),n=this;for(let r=t;r>=1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=Sx.checkMatrix(t);let e=new Sx(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),l=this.get(1,1),u=t.get(1,1),c=(n+l)*(r+u),h=(a+l)*r,d=n*(o-u),f=l*(s-r),p=(n+i)*u,g=c+f-p+(i-l)*(s+u),v=d+p,m=h+f,y=c-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,v),e.set(1,0,m),e.set(1,1,y),e}strassen3x3(t){t=Sx.checkMatrix(t);let e=new Sx(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),l=this.get(2,0),u=this.get(2,1),c=this.get(2,2),h=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),v=t.get(1,2),m=t.get(2,0),y=t.get(2,1),b=t.get(2,2),x=(n-o)*(-d+g),E=(-n+o+a)*(h-d+g),w=(o+a)*(-h+d),k=n*h,M=(-n+l+u)*(h-f+v),S=(-n+l)*(f-v),N=(l+u)*(-h+f),O=(-i+u+c)*(g+m-y),T=(i-c)*(g-y),C=i*m,A=(u+c)*(-m+y),P=(-i+a+s)*(v+m-b),R=(i-s)*(v-b),D=(a+s)*(-m+b),L=k+C+r*p,_=(n+r+i-o-a-u-c)*g+E+w+k+O+C+A,I=k+M+N+(n+r+i-a-s-l-u)*v+C+P+D,j=x+a*(-h+d+p-g-v-m+b)+E+k+C+P+R,B=x+E+w+k+s*y,F=C+P+R+D+o*f,z=k+M+S+u*(-h+f+p-g-v-m+y)+O+T+C,G=O+T+C+A+l*d,V=k+M+S+N+c*b;return e.set(0,0,L),e.set(0,1,_),e.set(0,2,I),e.set(1,0,j),e.set(1,1,B),e.set(1,2,F),e.set(2,0,z),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=Sx.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=kx.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),l=Math.max(r,o);return e=a(e,s,l),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),l=e.subMatrix(0,o-1,0,s-1),u=n.subMatrix(0,o-1,0,s-1),c=e.subMatrix(0,o-1,s,e.columns-1),h=n.subMatrix(0,o-1,s,n.columns-1),d=e.subMatrix(o,e.rows-1,0,s-1),f=n.subMatrix(o,n.rows-1,0,s-1),p=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),v=t(kx.add(l,p),kx.add(u,g),o,s),m=t(kx.add(d,p),u,o,s),y=t(l,kx.sub(h,g),o,s),b=t(p,kx.sub(f,u),o,s),x=t(kx.add(l,c),g,o,s),E=t(kx.sub(d,l),kx.add(u,h),o,s),w=t(kx.sub(c,p),kx.add(f,g),o,s),k=kx.add(v,b);k.sub(x),k.add(w);let M=kx.add(y,x),S=kx.add(m,b),N=kx.sub(v,m);N.add(y),N.add(E);let O=kx.zeros(2*k.rows,2*k.columns);return O=O.setSubMatrix(k,0,0),O=O.setSubMatrix(M,k.rows,0),O=O.setSubMatrix(S,0,k.columns),O=O.setSubMatrix(N,k.rows,k.columns),O.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,l),s,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Sx(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&sx(i,{min:e,max:n,output:i}),r.setRow(t,i)}return r}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Sx(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&sx(i,{min:e,max:n,output:i}),r.setColumn(t,i)}return r}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),r=this.get(e,this.columns-1-n);this.set(e,n,r),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),r=this.get(this.rows-1-n,e);this.set(n,e,r),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=Sx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new Sx(e*r,n*i);for(let a=0;a<e;a++)for(let e=0;e<n;e++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)o.set(r*a+n,i*e+s,this.get(a,e)*t.get(n,s));return o}kroneckerSum(t){if(t=Sx.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,r=this.kroneckerProduct(Sx.eye(n,n)),i=Sx.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new Sx(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=Mx){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Mx){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){bx(this,t,e,n,r);let i=new Sx(e-t+1,r-n+1);for(let o=t;o<=e;o++)for(let e=n;e<=r;e++)i.set(o-t,e-n,this.get(o,e));return i}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new Sx(t.length,n-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[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 Sx(n-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[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=Sx.checkMatrix(t)).isEmpty())return this;bx(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r<t.rows;r++)for(let i=0;i<t.columns;i++)this.set(e+r,n+i,t.get(r,i));return this}selection(t,e){mx(this,t),yx(this,e);let n=new Sx(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new Sx(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=xx(t.rows);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]+=t.get(n,r);return e}(this);case"column":return function(t){let e=xx(t.columns);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]+=t.get(n,r);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e+=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=xx(t.rows,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]*=t.get(n,r);return e}(this);case"column":return function(t){let e=xx(t.columns,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]*=t.get(n,r);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e*=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!ax.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,l=0;for(let e=0;e<i;e++)l=t.get(a,e)-n[a],r+=l,s+=l*l;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!ax.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,l=0;for(let e=0;e<r;e++)l=t.get(e,a)-n[a],i+=l,s+=l*l;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return function(t,e,n){const r=t.rows,i=t.columns,o=r*i;let a=0,s=0,l=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)l=t.get(e,r)-n,a+=l,s+=l*l;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}(this,n,r);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!ax.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[n])}(this,n),this;case"column":if(!ax.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[r])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=t.get(n,e)**2/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!ax.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=t.get(e,n)**2/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!ax.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[r])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=t.get(i,r)**2/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return cx(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function Mx(t,e){return t-e}kx.prototype.klass="Matrix","undefined"!=typeof Symbol&&(kx.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return cx(this)}),kx.random=kx.rand,kx.randomInt=kx.randInt,kx.diagonal=kx.diag,kx.prototype.diagonal=kx.prototype.diag,kx.identity=kx.eye,kx.prototype.negate=kx.prototype.neg,kx.prototype.tensorProduct=kx.prototype.kroneckerProduct;let Sx=class t extends kx{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<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),t.isMatrix(e))this.#t(e.rows,e.columns),t.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!ax.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<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!t[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return fx(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),fx(this,t,!0),e=Float64Array.from(gx(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){px(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let r=0;r<t;r++)n[r]=this.data[e][r];for(let r=t+1;r<this.columns;r++)n[r-1]=this.data[e][r];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),px(this,t,!0),e=vx(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>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<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t);return this},t.prototype.powM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t.get(e,n));return this}}(kx,Sx);class Nx extends kx{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return Sx.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),Sx.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=Sx.copy(t,new Sx(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new Sx(t,t);else if(this.#e=new Sx(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new Nx(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new Sx(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<e.length;i++)e[i]=this.get(r,n),++n>=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 Nx(n);for(let i=0,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}Nx.prototype.klassType="SymmetricMatrix";class Ox extends Nx{static isDistanceMatrix(t){return Nx.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 Nx(this)}clone(){const t=new Ox(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<e.length;i++)e[i]=this.get(r,n),++n>=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<e;a++)r.set(i,o,t[a]),++i>=n&&(i=1+ ++o);return r}}Ox.prototype.klassSubType="DistanceMatrix";class Tx extends kx{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class Cx extends Tx{constructor(t,e,n){mx(t,e),yx(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 Ax extends kx{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 Px extends kx{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 Rx{constructor(t){let e,n,r,i,o,a,s,l,u,c=(t=Px.checkMatrix(t)).clone(),h=c.rows,d=c.columns,f=new Float64Array(h),p=1;for(e=0;e<h;e++)f[e]=e;for(l=new Float64Array(h),n=0;n<d;n++){for(e=0;e<h;e++)l[e]=c.get(e,n);for(e=0;e<h;e++){for(u=Math.min(e,n),o=0,r=0;r<u;r++)o+=c.get(e,r)*l[r];l[e]-=o,c.set(e,n,l[e])}for(i=n,e=n+1;e<h;e++)Math.abs(l[e])>Math.abs(l[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=c.get(i,r),c.set(i,r,c.get(n,r)),c.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<h&&0!==c.get(n,n))for(e=n+1;e<h;e++)c.set(e,n,c.get(e,n)/c.get(n,n))}this.LU=c,this.pivotVector=f,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=Sx.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,a=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)a.set(i,r,a.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new Sx(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?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 Sx(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Dx(t,e){let n=0;return Math.abs(t)>Math.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 Lx{constructor(t){let e,n,r,i,o=(t=Px.checkMatrix(t)).clone(),a=t.rows,s=t.columns,l=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=Dx(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<a;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<a;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<a;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}l[r]=-t}this.QR=o,this.Rdiag=l}solve(t){t=Sx.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,a,s=t.columns,l=t.clone(),u=e.columns;for(o=0;o<u;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*l.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)l.set(r,i,l.get(r,i)+a*e.get(r,o))}for(o=u-1;o>=0;o--){for(i=0;i<s;i++)l.set(o,i,l.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)l.set(r,i,l.get(r,i)-l.get(o,i)*e.get(r,o))}return l.subMatrix(0,u-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new Sx(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,a=i.columns,s=new Sx(o,a);for(n=a-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<a;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}let _x=class{constructor(t,e={}){if((t=Px.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,r=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=e;let s,l=Boolean(i),u=Boolean(o),c=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,c=!0;let e=l;l=u,u=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let h=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new Sx(n,h),g=new Sx(r,r),v=new Float64Array(r),m=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),E=Math.max(b,x);for(let t=0;t<E;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=Dx(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<b&&0!==f[t]){let r=0;for(let i=t;i<n;i++)r+=s.get(i,t)*s.get(i,e);r=-r/s.get(t,t);for(let i=t;i<n;i++)s.set(i,e,s.get(i,e)+r*s.get(i,t))}v[e]=s.get(t,e)}if(l&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<r;e++)v[t]=Dx(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<r;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<n&&0!==v[t]){for(let e=t+1;e<n;e++)m[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)m[e]+=v[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-v[e]/v[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*m[i])}}if(u)for(let e=t+1;e<r;e++)g.set(e,t,v[e])}}let w=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<w&&(f[w-1]=0),x+1<w&&(v[x]=s.get(x,w-1)),v[w-1]=0,l){for(let t=b;t<h;t++){for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<h;e++){let r=0;for(let i=t;i<n;i++)r+=p.get(i,t)*p.get(i,e);r=-r/p.get(t,t);for(let i=t;i<n;i++)p.set(i,e,p.get(i,e)+r*p.get(i,t))}for(let e=t;e<n;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}}if(u)for(let t=r-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<r;e++){let n=0;for(let i=t+1;i<r;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t+1,t);for(let i=t+1;i<r;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}let k=w-1,M=Number.EPSILON;for(;w>0;){let t,e;for(t=w-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+M*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===w-2)e=4;else{let n;for(n=w-1;n>=t&&n!==t;n--){let e=(n!==w?Math.abs(v[n]):0)+(n!==t+1?Math.abs(v[n-1]):0);if(Math.abs(f[n])<=M*e){f[n]=0;break}}n===t?e=3:n===w-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=v[w-2];v[w-2]=0;for(let n=w-2;n>=t;n--){let i=Dx(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*v[n-1],v[n-1]=o*v[n-1]),u)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,w-1),g.set(t,w-1,-a*g.get(t,n)+o*g.get(t,w-1)),g.set(t,n,i)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let r=t;r<w;r++){let i=Dx(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*v[r],v[r]=o*v[r],l)for(let e=0;e<n;e++)i=o*p.get(e,r)+a*p.get(e,t-1),p.set(e,t-1,-a*p.get(e,r)+o*p.get(e,t-1)),p.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(f[w-1]),Math.abs(f[w-2]),Math.abs(v[w-2]),Math.abs(f[t]),Math.abs(v[t])),i=f[w-1]/e,o=f[w-2]/e,a=v[w-2]/e,s=f[t]/e,c=v[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let m=0;0===h&&0===d||(m=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),m=d/(h+m));let y=(s+i)*(s-i)+m,b=s*c;for(let e=t;e<w-1;e++){let i=Dx(y,b);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=b/i;if(e!==t&&(v[e-1]=i),y=o*f[e]+a*v[e],v[e]=o*v[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],u)for(let t=0;t<r;t++)i=o*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+o*g.get(t,e+1)),g.set(t,e,i);if(i=Dx(y,b),0===i&&(i=Number.MIN_VALUE),o=y/i,a=b/i,f[e]=i,y=o*v[e]+a*f[e+1],f[e+1]=-a*v[e]+o*f[e+1],b=a*v[e+1],v[e+1]=o*v[e+1],l&&e<n-1)for(let t=0;t<n;t++)i=o*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+o*p.get(t,e+1)),p.set(t,e,i)}v[w-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,u))for(let e=0;e<=k;e++)g.set(e,t,-g.get(e,t));for(;t<k&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(l&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);t++}w--}}if(c){let t=g;g=p,p=t}this.m=n,this.n=r,this.s=f,this.U=p,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=Sx.zeros(r,r);for(let t=0;t<r;t++)Math.abs(this.s[t])<=n?i.set(t,t,0):i.set(t,t,1/this.s[t]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(i),l=a.rows,u=o.rows,c=Sx.zeros(l,u);for(let t=0;t<l;t++)for(let e=0;e<u;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);c.set(t,e,n)}return c.mmul(e)}solveForDiagonal(t){return this.solve(Sx.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new Sx(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<r;n++)Math.abs(this.s[n])>e&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,l=new Sx(n,a);for(let t=0;t<n;t++)for(let e=0;e<a;e++){let n=0;for(let r=0;r<s;r++)n+=i.get(t,r)*o.get(e,r);l.set(t,e,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>t&&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 Sx.diag(this.s)}};function Ix(t,e,n=!1){return t=Px.checkMatrix(t),e=Px.checkMatrix(e),n?new _x(t).solve(e):t.isSquare()?new Rx(t).solve(e):new Lx(t).solve(e)}function jx(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function Bx(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class Fx{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=Px.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,a=new Sx(o,o),s=new Float64Array(o),l=new Float64Array(o),u=t,c=!1;if(c=!!n||t.isSymmetric(),c){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h;for(l=0;l<t;l++)n[l]=r.get(t-1,l);for(s=t-1;s>0;s--){for(h=0,a=0,u=0;u<s;u++)h+=Math.abs(n[u]);if(0===h)for(e[s]=n[s-1],l=0;l<s;l++)n[l]=r.get(s-1,l),r.set(s,l,0),r.set(l,s,0);else{for(u=0;u<s;u++)n[u]/=h,a+=n[u]*n[u];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=h*o,a-=i*o,n[s-1]=i-o,l=0;l<s;l++)e[l]=0;for(l=0;l<s;l++){for(i=n[l],r.set(l,s,i),o=e[l]+r.get(l,l)*i,u=l+1;u<=s-1;u++)o+=r.get(u,l)*n[u],e[u]+=r.get(u,l)*i;e[l]=o}for(i=0,l=0;l<s;l++)e[l]/=a,i+=e[l]*n[l];for(c=i/(a+a),l=0;l<s;l++)e[l]-=c*n[l];for(l=0;l<s;l++){for(i=n[l],o=e[l],u=l;u<=s-1;u++)r.set(u,l,r.get(u,l)-(i*e[u]+o*n[u]));n[l]=r.get(s-1,l),r.set(s,l,0)}}n[s]=a}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),a=n[s+1],0!==a){for(u=0;u<=s;u++)n[u]=r.get(u,s+1)/a;for(l=0;l<=s;l++){for(o=0,u=0;u<=s;u++)o+=r.get(u,s+1)*r.get(u,l);for(u=0;u<=s;u++)r.set(u,l,r.get(u,l)-o*n[u])}}for(u=0;u<=s;u++)r.set(u,s+1,0)}for(l=0;l<t;l++)n[l]=r.get(t-1,l),r.set(t-1,l,0);r.set(t-1,t-1,1),e[0]=0}(o,l,s,a),function(t,e,n,r){let i,o,a,s,l,u,c,h,d,f,p,g,v,m,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,E=0,w=Number.EPSILON;for(u=0;u<t;u++){for(E=Math.max(E,Math.abs(n[u])+Math.abs(e[u])),c=u;c<t&&!(Math.abs(e[c])<=w*E);)c++;if(c>u)do{for(i=n[u],h=(n[u+1]-i)/(2*e[u]),d=Dx(h,1),h<0&&(d=-d),n[u]=e[u]/(h+d),n[u+1]=e[u]*(h+d),f=n[u+1],o=i-n[u],a=u+2;a<t;a++)n[a]-=o;for(x+=o,h=n[c],p=1,g=p,v=p,m=e[u+1],y=0,b=0,a=c-1;a>=u;a--)for(v=g,g=p,b=y,i=p*e[a],o=p*h,d=Dx(h,e[a]),e[a+1]=y*d,y=e[a]/d,p=h/d,h=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),l=0;l<t;l++)o=r.get(l,a+1),r.set(l,a+1,y*r.get(l,a)+p*o),r.set(l,a,p*r.get(l,a)-y*o);h=-y*b*v*m*e[u]/f,e[u]=y*h,n[u]=p*h}while(Math.abs(e[u])>w*E);n[u]=n[u]+x,e[u]=0}for(a=0;a<t-1;a++){for(l=a,h=n[a],s=a+1;s<t;s++)n[s]<h&&(l=s,h=n[s]);if(l!==a)for(n[l]=n[a],n[a]=h,s=0;s<t;s++)h=r.get(s,a),r.set(s,a,r.get(s,l)),r.set(s,l,h)}}(o,l,s,a)}else{let t=new Sx(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h=0,d=t-1;for(u=h+1;u<=d-1;u++){for(c=0,s=u;s<=d;s++)c+=Math.abs(e.get(s,u-1));if(0!==c){for(a=0,s=d;s>=u;s--)n[s]=e.get(s,u-1)/c,a+=n[s]*n[s];for(o=Math.sqrt(a),n[u]>0&&(o=-o),a-=n[u]*o,n[u]=n[u]-o,l=u;l<t;l++){for(i=0,s=d;s>=u;s--)i+=n[s]*e.get(s,l);for(i/=a,s=u;s<=d;s++)e.set(s,l,e.get(s,l)-i*n[s])}for(s=0;s<=d;s++){for(i=0,l=d;l>=u;l--)i+=n[l]*e.get(s,l);for(i/=a,l=u;l<=d;l++)e.set(s,l,e.get(s,l)-i*n[l])}n[u]=c*n[u],e.set(u,u-1,c*o)}}for(s=0;s<t;s++)for(l=0;l<t;l++)r.set(s,l,s===l?1:0);for(u=d-1;u>=h+1;u--)if(0!==e.get(u,u-1)){for(s=u+1;s<=d;s++)n[s]=e.get(s,u-1);for(l=u;l<=d;l++){for(o=0,s=u;s<=d;s++)o+=n[s]*r.get(s,l);for(o=o/n[u]/e.get(u,u-1),s=u;s<=d;s++)r.set(s,l,r.get(s,l)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,l,u,c,h,d,f,p,g,v,m,y,b,x=t-1,E=0,w=t-1,k=Number.EPSILON,M=0,S=0,N=0,O=0,T=0,C=0,A=0,P=0;for(o=0;o<t;o++)for((o<E||o>w)&&(n[o]=i.get(o,o),e[o]=0),a=Math.max(o-1,0);a<t;a++)S+=Math.abs(i.get(o,a));for(;x>=E;){for(l=x;l>E&&(C=Math.abs(i.get(l-1,l-1))+Math.abs(i.get(l,l)),0===C&&(C=S),!(Math.abs(i.get(l,l-1))<k*C));)l--;if(l===x)i.set(x,x,i.get(x,x)+M),n[x]=i.get(x,x),e[x]=0,x--,P=0;else if(l===x-1){if(h=i.get(x,x-1)*i.get(x-1,x),N=(i.get(x-1,x-1)-i.get(x,x))/2,O=N*N+h,A=Math.sqrt(Math.abs(O)),i.set(x,x,i.get(x,x)+M),i.set(x-1,x-1,i.get(x-1,x-1)+M),d=i.get(x,x),O>=0){for(A=N>=0?N+A:N-A,n[x-1]=d+A,n[x]=n[x-1],0!==A&&(n[x]=d-h/A),e[x-1]=0,e[x]=0,d=i.get(x,x-1),C=Math.abs(d)+Math.abs(A),N=d/C,O=A/C,T=Math.sqrt(N*N+O*O),N/=T,O/=T,a=x-1;a<t;a++)A=i.get(x-1,a),i.set(x-1,a,O*A+N*i.get(x,a)),i.set(x,a,O*i.get(x,a)-N*A);for(o=0;o<=x;o++)A=i.get(o,x-1),i.set(o,x-1,O*A+N*i.get(o,x)),i.set(o,x,O*i.get(o,x)-N*A);for(o=E;o<=w;o++)A=r.get(o,x-1),r.set(o,x-1,O*A+N*r.get(o,x)),r.set(o,x,O*r.get(o,x)-N*A)}else n[x-1]=d+N,n[x]=d+N,e[x-1]=A,e[x]=-A;x-=2,P=0}else{if(d=i.get(x,x),f=0,h=0,l<x&&(f=i.get(x-1,x-1),h=i.get(x,x-1)*i.get(x-1,x)),10===P){for(M+=d,o=E;o<=x;o++)i.set(o,o,i.get(o,o)-d);C=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*C,h=-.4375*C*C}if(30===P&&(C=(f-d)/2,C=C*C+h,C>0)){for(C=Math.sqrt(C),f<d&&(C=-C),C=d-h/((f-d)/2+C),o=E;o<=x;o++)i.set(o,o,i.get(o,o)-C);M+=C,d=f=h=.964}for(P+=1,u=x-2;u>=l&&(A=i.get(u,u),T=d-A,C=f-A,N=(T*C-h)/i.get(u+1,u)+i.get(u,u+1),O=i.get(u+1,u+1)-A-T-C,T=i.get(u+2,u+1),C=Math.abs(N)+Math.abs(O)+Math.abs(T),N/=C,O/=C,T/=C,u!==l)&&!(Math.abs(i.get(u,u-1))*(Math.abs(O)+Math.abs(T))<k*(Math.abs(N)*(Math.abs(i.get(u-1,u-1))+Math.abs(A)+Math.abs(i.get(u+1,u+1)))));)u--;for(o=u+2;o<=x;o++)i.set(o,o-2,0),o>u+2&&i.set(o,o-3,0);for(s=u;s<=x-1&&(y=s!==x-1,s!==u&&(N=i.get(s,s-1),O=i.get(s+1,s-1),T=y?i.get(s+2,s-1):0,d=Math.abs(N)+Math.abs(O)+Math.abs(T),0!==d&&(N/=d,O/=d,T/=d)),0!==d);s++)if(C=Math.sqrt(N*N+O*O+T*T),N<0&&(C=-C),0!==C){for(s!==u?i.set(s,s-1,-C*d):l!==u&&i.set(s,s-1,-i.get(s,s-1)),N+=C,d=N/C,f=O/C,A=T/C,O/=N,T/=N,a=s;a<t;a++)N=i.get(s,a)+O*i.get(s+1,a),y&&(N+=T*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-N*A)),i.set(s,a,i.get(s,a)-N*d),i.set(s+1,a,i.get(s+1,a)-N*f);for(o=0;o<=Math.min(x,s+3);o++)N=d*i.get(o,s)+f*i.get(o,s+1),y&&(N+=A*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-N*T)),i.set(o,s,i.get(o,s)-N),i.set(o,s+1,i.get(o,s+1)-N*O);for(o=E;o<=w;o++)N=d*r.get(o,s)+f*r.get(o,s+1),y&&(N+=A*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-N*T)),r.set(o,s,r.get(o,s)-N),r.set(o,s+1,r.get(o,s+1)-N*O)}}}if(0===S)return;for(x=t-1;x>=0;x--)if(N=n[x],O=e[x],0===O)for(l=x,i.set(x,x,1),o=x-1;o>=0;o--){for(h=i.get(o,o)-N,T=0,a=l;a<=x;a++)T+=i.get(o,a)*i.get(a,x);if(e[o]<0)A=h,C=T;else if(l=o,0===e[o]?i.set(o,x,0!==h?-T/h:-T/(k*S)):(d=i.get(o,o+1),f=i.get(o+1,o),O=(n[o]-N)*(n[o]-N)+e[o]*e[o],c=(d*C-A*T)/O,i.set(o,x,c),i.set(o+1,x,Math.abs(d)>Math.abs(A)?(-T-h*c)/d:(-C-f*c)/A)),c=Math.abs(i.get(o,x)),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/c)}else if(O<0)for(l=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,O/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-N)/i.get(x,x-1))):(b=zx(0,-i.get(x-1,x),i.get(x-1,x-1)-N,O),i.set(x-1,x-1,b[0]),i.set(x-1,x,b[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=l;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(h=i.get(o,o)-N,e[o]<0)A=h,T=p,C=g;else if(l=o,0===e[o]?(b=zx(-p,-g,h,O),i.set(o,x-1,b[0]),i.set(o,x,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),v=(n[o]-N)*(n[o]-N)+e[o]*e[o]-O*O,m=2*(n[o]-N)*O,0===v&&0===m&&(v=k*S*(Math.abs(h)+Math.abs(O)+Math.abs(d)+Math.abs(f)+Math.abs(A))),b=zx(d*T-A*p+O*g,d*C-A*g-O*p,v,m),i.set(o,x-1,b[0]),i.set(o,x,b[1]),Math.abs(d)>Math.abs(A)+Math.abs(O)?(i.set(o+1,x-1,(-p-h*i.get(o,x-1)+O*i.get(o,x))/d),i.set(o+1,x,(-g-h*i.get(o,x)-O*i.get(o,x-1))/d)):(b=zx(-T-f*i.get(o,x-1),-C-f*i.get(o,x),A,O),i.set(o+1,x-1,b[0]),i.set(o+1,x,b[1]))),c=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/c),i.set(a,x,i.get(a,x)/c)}for(o=0;o<t;o++)if(o<E||o>w)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=E;a--)for(o=E;o<=w;o++){for(A=0,s=E;s<=Math.min(a,w);s++)A+=r.get(o,s)*i.get(s,a);r.set(o,a,A)}}(o,l,s,a,t)}this.n=o,this.e=l,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 Sx(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function zx(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 Gx{constructor(t){if(!(t=Px.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new Sx(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=a.get(r,e)*a.get(n,e);o=(i.get(n,r)-o)/a.get(r,r),a.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&&=t>0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)a.set(n,r,0)}this.L=a,this.positiveDefinite=s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=Px.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,a=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<a;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<a;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class Vx{constructor(t,e={}){t=Px.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=ax.isAnyArray(n)&&"number"==typeof n[0]?Sx.columnVector(n):Px.checkMatrix(n),n.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=t.getColumnVector(0);let s,l,u,c,h=1;for(let e=0;e<i&&h>o;e++)u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),s=t.mmul(u).div(u.transpose().mmul(u).get(0,0)),e>0&&(h=s.clone().sub(c).pow(2).sum()),c=s.clone(),n?(l=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=n.mmul(l).div(l.transpose().mmul(l).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),i=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),o=n.clone().sub(s.clone().mulS(i.get(0,0)).mmul(l.transpose()));this.t=s,this.p=e.transpose(),this.w=u.transpose(),this.q=l,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=u.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(u.transpose()))}}tx.AbstractMatrix=kx,tx.CHO=Gx,tx.CholeskyDecomposition=Gx,tx.DistanceMatrix=Ox,tx.EVD=Fx,tx.EigenvalueDecomposition=Fx,tx.LU=Rx,tx.LuDecomposition=Rx;var Wx=tx.Matrix=Sx;tx.MatrixColumnSelectionView=class extends Tx{constructor(t,e){yx(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])}},tx.MatrixColumnView=class extends Tx{constructor(t,e){px(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)}},tx.MatrixFlipColumnView=class extends Tx{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)}},tx.MatrixFlipRowView=class extends Tx{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)}},tx.MatrixRowSelectionView=class extends Tx{constructor(t,e){mx(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)}},tx.MatrixRowView=class extends Tx{constructor(t,e){fx(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)}},tx.MatrixSelectionView=Cx,tx.MatrixSubView=class extends Tx{constructor(t,e,n,r,i){bx(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)}},tx.MatrixTransposeView=class extends Tx{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)}},tx.NIPALS=Vx,tx.Nipals=Vx,tx.QR=Lx,tx.QrDecomposition=Lx,tx.SVD=_x;var Hx=tx.SingularValueDecomposition=_x;tx.SymmetricMatrix=Nx,tx.WrapperMatrix1D=Ax,tx.WrapperMatrix2D=Px,tx.correlation=function(t,e=t,n={}){t=new Sx(t);let r=!1;if("object"!=typeof e||Sx.isMatrix(e)||ax.isAnyArray(e)?e=new Sx(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:o=!0}=n;i&&(t.center("column"),r||e.center("column")),o&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),l=t.transpose().mmul(e);for(let e=0;e<l.rows;e++)for(let n=0;n<l.columns;n++)l.set(e,n,l.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return l},tx.covariance=function(t,e=t,n={}){t=new Sx(t);let r=!1;if("object"!=typeof e||Sx.isMatrix(e)||ax.isAnyArray(e)?e=new Sx(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(t=t.center("column"),r||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e<o.rows;e++)for(let n=0;n<o.columns;n++)o.set(e,n,o.get(e,n)*(1/(t.rows-1)));return o};var Ux=tx.default=Sx;tx.determinant=function t(e){if((e=Sx.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,a,s;return o=new Cx(e,[1,2],[1,2]),a=new Cx(e,[1,2],[0,2]),s=new Cx(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(a)+i*t(s)}return new Rx(e).determinant}throw Error("determinant can only be calculated for a square matrix")},tx.inverse=function(t,e=!1){return t=Px.checkMatrix(t),e?new _x(t).inverse():Ix(t,Sx.eye(t.rows))},tx.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=Sx.checkMatrix(t)).rows,o=new Sx(i,i);for(let e=0;e<i;e++){let a=Sx.columnVector(t.getRow(e)),s=t.subMatrixRow(jx(i,e)).transpose(),l=new _x(s).solve(a),u=Sx.sub(a,s.mmul(l)).abs().max();o.setRow(e,Bx(u,l,e,n,r))}return o},tx.pseudoInverse=function(t,e=Number.EPSILON){if((t=Sx.checkMatrix(t)).isEmpty())return t.transpose();let n=new _x(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(Sx.diag(o).mmul(r.transpose()))},tx.solve=Ix,tx.wrap=function(t,e){if(ax.isAnyArray(t))return t[0]&&ax.isAnyArray(t[0])?new Px(t):new Ax(t,e);throw new Error("the argument is not an array")};const $x=Wx,Yx=Hx;Ux.Matrix&&Ux.Matrix;const qx={center:[0,0],linkDistance:50};class Xx{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},qx),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i=[0,0],linkDistance:o=50}=r,a=e.getAllNodes(),s=e.getAllEdges();if(!(null==a?void 0:a.length)||1===a.length)return bb(e,t,i);const l=sb({nodes:a,edges:s}),u=ab(l);Kx(u);const c=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(u,o),h=Zx(c),d=[];h.forEach(((t,e)=>{const n=hb(a[e]);n.data.x=t[0]+i[0],n.data.y=t[1]+i[1],d.push(n)})),t&&d.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:d,edges:s}}))}}const Kx=t=>{let e=-999999;t.forEach((t=>{t.forEach((t=>{t!==1/0&&e<t&&(e=t)}))})),t.forEach(((n,r)=>{n.forEach(((n,i)=>{n===1/0&&(t[r][i]=e)}))}))},Zx=t=>{const e=$x.mul($x.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);const o=new Yx(e),a=$x.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>$x.mul([t],[a]).toJSON()[0].splice(0,2)))};function Qx(t){return!!t.tick&&!!t.stop}const Jx={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},tE={center:[0,0],comboPadding:10,treeKey:"combo"};class eE{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},tE),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:i,treeKey:o,outerLayout:a}=r,s=e.getAllNodes().filter((t=>!t.data._isCombo)),l=e.getAllNodes().filter((t=>t.data._isCombo)),u=e.getAllEdges(),c=null==s?void 0:s.length;if(!c||1===c)return bb(e,t,i);const h=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;l.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,u,r,p);yield Promise.all(g);const v=new Map,m=[],y=new Map;let b=!0;e.getRoots(o).forEach((t=>{const n=p.get(t.id),r=f.get(t.id)||d.get(t.id),i={id:t.id,data:Object.assign(Object.assign({},t.data),{x:n.data.x||r.data.x,y:n.data.y||r.data.y,fx:n.data.fx||r.data.fx,fy:n.data.fy||r.data.fy,mass:n.data.mass||r.data.mass,size:n.data.size})};m.push(i),v.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):b=!1,ub(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const x=[];let E;if(u.forEach((t=>{const e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&v.has(e)&&v.has(n)&&x.push({id:t.id,source:e,target:n,data:{}})})),null==m?void 0:m.length){if(1===m.length)m[0].data.x=i[0],m[0].data.y=i[1];else{const t=new Yg({nodes:m,edges:x}),e=a||new qb;if(b&&Jx[e.id]){const e=m.length<100?new Xx:new Sb;yield e.assign(t)}const n=Object.assign({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===e.id?{gravity:1,factor:4,linkDistance:(t,e,n)=>(Math.max(...e.data.size)||32)/2+(Math.max(...n.data.size)||32)/2+200}:{});E=yield nE(e,t,n)}p.forEach((t=>{var e;const n=E.nodes.find((e=>e.id===t.id));if(n){const{x:e,y:r}=n.data;t.data.visited=!0,t.data.x=e,t.data.y=r,h.push({id:t.id,data:{x:e,y:r}})}const{x:r,y:i}=t.data;null===(e=t.data.nodes)||void 0===e||e.forEach((t=>{h.push({id:t.id,data:{x:t.data.x+r,y:t.data.y+i}})}))})),p.forEach((({data:t})=>{const{x:e,y:n,visited:r,nodes:i}=t;null==i||i.forEach((t=>{if(!r){const r=h.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&h.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:h,edges:u}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=ae(r)?()=>r:Ut(r)?r:()=>0,e.spacing=a,n)if(Ut(n))o=t=>{const e=n(t),r=a(t);if(ob(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(ob(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)/2}else{const t=n/2;o=e=>t+a(e)/2}else o=t=>{const e=a(t);if(t.size){if(ob(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(qt(t.size)){return((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2}return(t.size+e)/2}return 32+e/2};return e.nodeSize=o,s=ae(i)?()=>i:ob(i)?()=>Math.max.apply(null,i):Ut(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,a){const{nodeSize:s,comboPadding:l,spacing:u,innerLayout:c}=o,h=c||new Sb({}),d={center:[0,0],preventOverlap:!0,nodeSpacing:u},f=[],p=t=>{let e=(null==l?void 0:l(t))||10;return ob(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{a.set(o.id,{id:o.id,data:{nodes:[],size:p(o).size}});let l=Promise.resolve();ub(t,[o],(o=>{var u;if(!o.data._isCombo)return;const{size:c,padding:f}=p(o);if(null===(u=t.getChildren(o.id,e))||void 0===u?void 0:u.length){const u=a.get(o.id);a.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==u?void 0:u.data)});const c=new Map,p=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return a.has(t.id)||a.set(t.id,{id:t.id,data:Object.assign({},t.data)}),c.set(t.id,!0),a.get(t.id);const e=n.get(t.id)||r.get(t.id);return c.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),g={nodes:p,edges:i.filter((t=>c.has(t.source)&&c.has(t.target)))};let v=1/0;p.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=a.get(t.id))||void 0===e?void 0:e.data.size)||(null==s?void 0:s(t))||[30,30]),ae(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),l=l.then((()=>ze(this,void 0,void 0,(function*(){const t=new Yg(g);yield nE(h,t,d,!0);const{minX:e,minY:n,maxX:r,maxY:i}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;ob(o)?1===o.length&&(o=[o[0],o[0]]):ae(o)?o=[o,o]:(void 0===o||isNaN(o))&&(o=[30,30]);const a=[o[0]/2,o[1]/2],s=t.data.x-a[0],l=t.data.x+a[0],u=t.data.y-a[1],c=t.data.y+a[1];e>s&&(e=s),n>u&&(n=u),r<l&&(r=l),i<c&&(i=c)})),{minX:e,minY:n,maxX:r,maxY:i}})(p),s=(r+e)/2,l=(i+n)/2;g.nodes.forEach((t=>{t.data.x-=s,t.data.y-=l}));const u=[Math.max(r-e,v)+2*f,Math.max(i-n,v)+2*f];a.get(o.id).data.size=u,a.get(o.id).data.nodes=p}))))}else a.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:c})});return!0}),"BT",e),f.push(l)})),f}}function nE(t,e,n,r){var i;return ze(this,void 0,void 0,(function*(){return Qx(t)?(t.execute(e,n),t.stop(),t.tick(null!==(i=n.iterations)&&void 0!==i?i:300)):r?yield t.assign(e,n):yield t.execute(e,n)}))}function rE(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,l=0;for(i=0;i<a;++i)s+=(o=n[i]).x,l+=o.y;for(s=(s/a-t)*r,l=(l/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=l}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function iE(t){return function(){return t}}function oE(t){return 1e-6*(t()-.5)}function aE(t){return t.x+t.vx}function sE(t){return t.y+t.vy}function lE(t){var e,n,r,i=1,o=1;function a(){for(var t,a,l,u,c,h,d,f=e.length,p=0;p<o;++p)for(a=Ab(e,aE,sE).visitAfter(s),t=0;t<f;++t)l=e[t],h=n[l.index],d=h*h,u=l.x+l.vx,c=l.y+l.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=h+f;if(!s)return e>u+p||o<u-p||n>c+p||a<c-p;if(s.index>l.index){var g=u-s.x-s.vx,v=c-s.y-s.vy,m=g*g+v*v;m<p*p&&(0===g&&(m+=(g=oE(r))*g),0===v&&(m+=(v=oE(r))*v),m=(p-(m=Math.sqrt(m)))/m*i,l.vx+=(g*=m)*(p=(f*=f)/(d+f)),l.vy+=(v*=m)*p,s.vx-=g*(p=1-p),s.vy-=v*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function l(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=iE(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,l()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),l(),a):t},a}function uE(t){return t.index}function cE(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function hE(t){var e,n,r,i,o,a,s=uE,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},u=iE(30),c=1;function h(r){for(var i=0,s=t.length;i<c;++i)for(var l,u,h,d,f,p,g,v=0;v<s;++v)u=(l=t[v]).source,d=(h=l.target).x+h.vx-u.x-u.vx||oE(a),f=h.y+h.vy-u.y-u.vy||oE(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[v])/p*r*e[v],f*=p,h.vx-=d*(g=o[v]),h.vy-=f*g,u.vx+=d*(g=1-g),u.vy+=f*g}function d(){if(r){var a,l,u=r.length,c=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(u);a<c;++a)(l=t[a]).index=a,"object"!=typeof l.source&&(l.source=cE(h,l.source)),"object"!=typeof l.target&&(l.target=cE(h,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(a=0,o=new Array(c);a<c;++a)l=t[a],o[a]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(c),f(),n=new Array(c),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+u(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,a=e,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(c=+t,h):c},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:iE(+t),f(),h):l},h.distance=function(t){return arguments.length?(u="function"==typeof t?t:iE(+t),p(),h):u},h}var dE={value:()=>{}};function fE(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new pE(r)}function pE(t){this._=t}function gE(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function vE(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=dE,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}pE.prototype=fE.prototype={constructor:pE,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=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(;++a<s;)if(n=(t=o[a]).type)i[n]=vE(i[n],t.name,e);else if(null==e)for(n in i)i[n]=vE(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=gE(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new pE(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var mE,yE,bE=0,xE=0,EE=0,wE=0,kE=0,ME=0,SE="object"==typeof performance&&performance.now?performance:Date,NE="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function OE(){return kE||(NE(TE),kE=SE.now()+ME)}function TE(){kE=0}function CE(){this._call=this._time=this._next=null}function AE(t,e,n){var r=new CE;return r.restart(t,e,n),r}function PE(){kE=(wE=SE.now())+ME,bE=xE=0;try{!function(){OE(),++bE;for(var t,e=mE;e;)(t=kE-e._time)>=0&&e._call.call(void 0,t),e=e._next;--bE}()}finally{bE=0,function(){var t,e,n=mE,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:mE=e);yE=t,DE(r)}(),kE=0}}function RE(){var t=SE.now(),e=t-wE;e>1e3&&(ME-=e,wE=t)}function DE(t){bE||(xE&&(xE=clearTimeout(xE)),t-kE>24?(t<1/0&&(xE=setTimeout(PE,t-SE.now()-ME)),EE&&(EE=clearInterval(EE))):(EE||(wE=SE.now(),EE=setInterval(RE,1e3)),bE=1,NE(PE)))}CE.prototype=AE.prototype={constructor:CE,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?OE():+n)+(null==e?0:+e),this._next||yE===this||(yE?yE._next=this:mE=this,yE=this),this._call=t,this._time=n,DE()},stop:function(){this._call&&(this._call=null,this._time=1/0,DE())}};const LE=4294967296;function _E(t){return t.x}function IE(t){return t.y}var jE=Math.PI*(3-Math.sqrt(5));function BE(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=AE(h),u=fE("tick","end"),c=function(){let t=1;return()=>(t=(1664525*t+1013904223)%LE)/LE}();function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(r){var l,u,c=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),l=0;l<c;++l)null==(u=t[l]).fx?u.x+=u.vx*=a:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=a:(u.y=u.fy,u.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),o=n*jE;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,c),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(o=+t,e):o},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(c=t,s.forEach(p),e):c},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,l,u=0,c=t.length;for(null==r?r=1/0:r*=r,u=0;u<c;++u)(a=(i=e-(s=t[u]).x)*i+(o=n-s.y)*o)<r&&(l=s,r=a);return l},on:function(t,n){return arguments.length>1?(u.on(t,n),e):u.on(t)}}}function FE(){var t,e,n,r,i,o=iE(-30),a=1,s=1/0,l=.81;function u(n){var i,o=t.length,a=Ab(t,_E,IE).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function c(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+o(n,e,t)}}function h(t){var e,n,r,o,a,s=0,l=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,l+=n,r+=n*e.x,o+=n*e.y);t.x=r/l,t.y=o/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index]}while(e=e.next)}t.value=s}function d(t,o,u,c){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,f=c-o,p=h*h+d*d;if(f*f/l<p)return p<s&&(0===h&&(p+=(h=oE(n))*h),0===d&&(p+=(d=oE(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=h*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=oE(n))*h),0===d&&(p+=(d=oE(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=h*f,e.vy+=d*f)}while(t=t.next)}}return u.initialize=function(e,r){t=e,n=r,c()},u.strength=function(t){return arguments.length?(o="function"==typeof t?t:iE(+t),c(),u):o},u.distanceMin=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.distanceMax=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.theta=function(t){return arguments.length?(l=t*t,u):Math.sqrt(l)},u}function zE(t,e,n){var r,i,o,a=iE(.1);function s(t){for(var a=0,s=r.length;a<s;++a){var l=r[a],u=l.x-e||1e-6,c=l.y-n||1e-6,h=Math.sqrt(u*u+c*c),d=(o[a]-h)*i[a]*t/h;l.vx+=u*d,l.vy+=c*d}}function l(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+a(r[e],e,r)}}return"function"!=typeof t&&(t=iE(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,l()},s.strength=function(t){return arguments.length?(a="function"==typeof t?t:iE(+t),l(),s):a},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),l(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function GE(t){var e,n,r,i=iE(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=iE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:iE(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),a(),o):t},o}function VE(t){var e,n,r,i=iE(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=iE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:iE(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),a(),o):t},o}class WE{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:hE,manyBody:FE,center:rE,collide:lE,radial:zE,x:GE,y:VE},this.options={link:{id:t=>t.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},ke(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,e)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const n=this.context.nodes.find((e=>e.id===t));n&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){n[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,n;const r=ke({},this.options,t);return r.collide&&void 0===(null===(e=r.collide)||void 0===e?void 0:e.radius)&&(r.collide=r.collide||{},r.collide.radius=null!==(n=r.nodeSize)&&void 0!==n?n:10),void 0===r.iterations&&(r.link&&void 0===r.link.iterations&&(r.iterations=r.link.iterations),r.collide&&void 0===r.collide.iterations&&(r.iterations=r.collide.iterations)),this.context.options=r,r}genericLayout(t,e,n){var r;return ze(this,void 0,void 0,(function*(){const i=this.getOptions(n),o=e.getAllNodes().map((({id:t,data:e})=>Object.assign(Object.assign({id:t},e),Ae(e.data,this.config.inputNodeAttrs)))),a=e.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const s=new Promise((t=>{this.resolver=t})),l=this.setSimulation(i);return l.nodes(o),null===(r=l.force("link"))||void 0===r||r.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:n,graph:r}=this.context,i=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),Ae(t,this.config.outputNodeAttrs))}))),o=n.map((({id:t,source:e,target:n,data:r})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof n?n.id:n,data:r})));return t&&i.forEach((t=>r.mergeNodeData(t.id,t.data))),{nodes:i,edges:o}}initSimulation(){return BE()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),HE(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([n,r])=>{const i=n;if(t[n]){let n=e.force(i);n||(n=r(),e.force(i,n)),HE(n,Object.entries(t[i]))}else e.force(i,null)})),e}}const HE=(t,e)=>e.reduce(((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e),t);var UE,$E,YE,qE,XE,KE,ZE,QE,JE,tw,ew,nw,rw,iw,ow,aw,sw,lw,uw,cw,hw,dw,fw,pw,gw,vw,mw,yw,bw,xw,Ew,ww,kw,Mw,Sw,Nw,Ow,Tw,Cw,Aw,Pw,Rw,Dw,Lw,_w,Iw,jw,Bw,Fw,zw,Gw,Vw,Ww,Hw,Uw,$w,Yw,qw,Xw,Kw,Zw,Qw,Jw,tk,ek,nk,rk,ik,ok,ak,sk,lk,uk,ck,hk,dk,fk,pk,gk,vk,mk,yk,bk,xk,Ek,wk,kk,Mk,Sk,Nk,Ok,Tk,Ck,Ak,Pk,Rk,Dk,Lk,_k,Ik,jk,Bk,Fk,zk,Gk,Vk,Wk,Hk;function Uk(){if(qE)return YE;return qE=1,YE=function(t,e){return t===e||t!=t&&e!=e}}function $k(){if(KE)return XE;KE=1;var t=Uk();return XE=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},XE}function Yk(){if(aw)return ow;aw=1;var t=$E?UE:($E=1,UE=function(){this.__data__=[],this.size=0}),e=function(){if(QE)return ZE;QE=1;var t=$k(),e=Array.prototype.splice;return ZE=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))},ZE}(),n=function(){if(tw)return JE;tw=1;var t=$k();return JE=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},JE}(),r=function(){if(nw)return ew;nw=1;var t=$k();return ew=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(iw)return rw;iw=1;var t=$k();return rw=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},rw}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,ow=o}function qk(){if(vw)return gw;vw=1;var t="object"==typeof x&&x&&x.Object===Object&&x;return gw=t}function Xk(){if(yw)return mw;yw=1;var t=qk(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return mw=n}function Kk(){if(xw)return bw;xw=1;var t=Xk().Symbol;return bw=t}function Zk(){if(Nw)return Sw;Nw=1;var t=Kk(),e=function(){if(ww)return Ew;ww=1;var t=Kk(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return Ew=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var a=!0}catch(t){}var s=r.call(t);return a&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(Mw)return kw;Mw=1;var t=Object.prototype.toString;return kw=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return Sw=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function Qk(){if(Tw)return Ow;return Tw=1,Ow=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Jk(){if(Aw)return Cw;Aw=1;var t=Zk(),e=Qk();return Cw=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function tM(){if(Lw)return Dw;Lw=1;var t,e=function(){if(Rw)return Pw;Rw=1;var t=Xk()["__core-js_shared__"];return Pw=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Dw=function(t){return!!n&&n in t}}function eM(){if(Iw)return _w;Iw=1;var t=Function.prototype.toString;return _w=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function nM(){if(Vw)return Gw;Vw=1;var t=function(){if(Bw)return jw;Bw=1;var t=Jk(),e=tM(),n=Qk(),r=eM(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,u=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return jw=function(o){return!(!n(o)||e(o))&&(t(o)?u:i).test(r(o))}}(),e=zw?Fw:(zw=1,Fw=function(t,e){return null==t?void 0:t[e]});return Gw=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function rM(){if(Hw)return Ww;Hw=1;var t=nM()(Xk(),"Map");return Ww=t}function iM(){if($w)return Uw;$w=1;var t=nM()(Object,"create");return Uw=t}function oM(){if(ik)return rk;ik=1;var t=function(){if(qw)return Yw;qw=1;var t=iM();return Yw=function(){this.__data__=t?t(null):{},this.size=0}}(),e=Kw?Xw:(Kw=1,Xw=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Qw)return Zw;Qw=1;var t=iM(),e=Object.prototype.hasOwnProperty;return Zw=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},Zw}(),r=function(){if(tk)return Jw;tk=1;var t=iM(),e=Object.prototype.hasOwnProperty;return Jw=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},Jw}(),i=function(){if(nk)return ek;nk=1;var t=iM();return ek=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},ek}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,rk=o}function aM(){if(ck)return uk;ck=1;var t=lk?sk:(lk=1,sk=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return uk=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},uk}function sM(){if(xk)return bk;xk=1;var t=function(){if(ak)return ok;ak=1;var t=oM(),e=Yk(),n=rM();return ok=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(dk)return hk;dk=1;var t=aM();return hk=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(pk)return fk;pk=1;var t=aM();return fk=function(e){return t(this,e).get(e)}}(),r=function(){if(vk)return gk;vk=1;var t=aM();return gk=function(e){return t(this,e).has(e)}}(),i=function(){if(yk)return mk;yk=1;var t=aM();return mk=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},mk}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,bk=o}function lM(){if(Mk)return kk;Mk=1;var t=Yk(),e=function(){if(lw)return sw;lw=1;var t=Yk();return sw=function(){this.__data__=new t,this.size=0}}(),n=(cw||(cw=1,uw=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),uw),r=dw?hw:(dw=1,hw=function(t){return this.__data__.get(t)}),i=pw?fw:(pw=1,fw=function(t){return this.__data__.has(t)}),o=function(){if(wk)return Ek;wk=1;var t=Yk(),e=rM(),n=sM();return Ek=function(r,i){var o=this.__data__;if(o instanceof t){var a=o.__data__;if(!e||a.length<199)return a.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(a)}return o.set(r,i),this.size=o.size,this},Ek}();function a(e){var n=this.__data__=new t(e);this.size=n.size}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,kk=a}function uM(){if(Nk)return Sk;return Nk=1,Sk=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},Sk}function cM(){if(Tk)return Ok;Tk=1;var t=nM(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Ok=e}function hM(){if(Ak)return Ck;Ak=1;var t=cM();return Ck=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function dM(){if(Rk)return Pk;Rk=1;var t=hM(),e=Uk(),n=Object.prototype.hasOwnProperty;return Pk=function(r,i,o){var a=r[i];n.call(r,i)&&e(a,o)&&(void 0!==o||i in r)||t(r,i,o)}}function fM(){if(Lk)return Dk;Lk=1;var t=dM(),e=hM();return Dk=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,l=r.length;++s<l;){var u=r[s],c=o?o(i[u],n[u],u,i,n):void 0;void 0===c&&(c=n[u]),a?e(i,u,c):t(i,u,c)}return i},Dk}function pM(){if(Bk)return jk;return Bk=1,jk=function(t){return null!=t&&"object"==typeof t}}function gM(){if(Vk)return Gk;Vk=1;var t=function(){if(zk)return Fk;zk=1;var t=Zk(),e=pM();return Fk=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=pM(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return Gk=o}function vM(){if(Hk)return Wk;Hk=1;var t=Array.isArray;return Wk=t}var mM,yM,bM,xM,EM,wM,kM,MM,SM,NM,OM,TM={exports:{}};function CM(){return bM||(bM=1,function(t,e){var n=Xk(),r=yM?mM:(yM=1,mM=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,a=o&&o.exports===i?n.Buffer:void 0,s=(a?a.isBuffer:void 0)||r;t.exports=s}(TM,TM.exports)),TM.exports}function AM(){if(EM)return xM;EM=1;var t=/^(?:0|[1-9]\d*)$/;return xM=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},xM}function PM(){if(kM)return wM;kM=1;return wM=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function RM(){if(OM)return NM;return OM=1,NM=function(t){return function(e){return t(e)}}}var DM,LM,_M,IM,jM,BM,FM,zM,GM,VM,WM,HM,UM,$M,YM,qM,XM,KM,ZM,QM,JM,tS,eS,nS,rS,iS,oS,aS={exports:{}};function sS(){return DM||(DM=1,function(t,e){var n=qk(),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}(aS,aS.exports)),aS.exports}function lS(){if(_M)return LM;_M=1;var t=function(){if(SM)return MM;SM=1;var t=Zk(),e=PM(),n=pM(),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,MM=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=RM(),n=sS(),r=n&&n.isTypedArray,i=r?e(r):t;return LM=i}function uS(){if(jM)return IM;jM=1;var t=(Ik||(Ik=1,_k=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),_k),e=gM(),n=vM(),r=CM(),i=AM(),o=lS(),a=Object.prototype.hasOwnProperty;return IM=function(s,l){var u=n(s),c=!u&&e(s),h=!u&&!c&&r(s),d=!u&&!c&&!h&&o(s),f=u||c||h||d,p=f?t(s.length,String):[],g=p.length;for(var v in s)!l&&!a.call(s,v)||f&&("length"==v||h&&("offset"==v||"parent"==v)||d&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||i(v,g))||p.push(v);return p},IM}function cS(){if(FM)return BM;FM=1;var t=Object.prototype;return BM=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function hS(){if(GM)return zM;return GM=1,zM=function(t,e){return function(n){return t(e(n))}}}function dS(){if(UM)return HM;UM=1;var t=cS(),e=function(){if(WM)return VM;WM=1;var t=hS()(Object.keys,Object);return VM=t}(),n=Object.prototype.hasOwnProperty;return HM=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function fS(){if(YM)return $M;YM=1;var t=Jk(),e=PM();return $M=function(n){return null!=n&&e(n.length)&&!t(n)}}function pS(){if(XM)return qM;XM=1;var t=uS(),e=dS(),n=fS();return qM=function(r){return n(r)?t(r):e(r)}}function gS(){if(eS)return tS;eS=1;var t=Qk(),e=cS(),n=JM?QM:(JM=1,QM=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return tS=function(i){if(!t(i))return n(i);var o=e(i),a=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&a.push(s);return a}}function vS(){if(rS)return nS;rS=1;var t=uS(),e=gS(),n=fS();return nS=function(r){return n(r)?t(r,!0):e(r)}}var mS,yS,bS,xS,ES,wS,kS,MS,SS,NS,OS,TS,CS,AS,PS,RS,DS,LS,_S,IS,jS,BS,FS,zS,GS,VS,WS,HS,US,$S,YS,qS,XS,KS,ZS,QS,JS,tN,eN,nN,rN,iN,oN,aN,sN,lN,uN,cN,hN,dN,fN,pN,gN,vN,mN,yN,bN,xN,EN,wN,kN,MN,SN,NN,ON,TN,CN,AN,PN,RN,DN,LN,_N,IN,jN,BN,FN,zN,GN,VN,WN,HN,UN,$N,YN,qN,XN,KN,ZN,QN,JN,tO,eO,nO,rO,iO,oO,aO,sO,lO,uO,cO,hO,dO,fO,pO,gO,vO,mO,yO,bO,xO,EO,wO,kO,MO,SO,NO,OO,TO,CO,AO,PO,RO,DO,LO,_O,IO,jO,BO,FO,zO,GO,VO,WO,HO,UO,$O,YO,qO,XO,KO,ZO,QO,JO,tT,eT,nT,rT,iT,oT,aT,sT,lT,uT,cT,hT,dT,fT,pT,gT,vT,mT,yT,bT,xT,ET,wT,kT,MT,ST,NT,OT,TT,CT,AT,PT,RT,DT,LT,_T,IT,jT,BT,FT,zT,GT,VT,WT,HT,UT,$T,YT,qT,XT,KT,ZT,QT,JT,tC,eC,nC,rC,iC,oC,aC,sC,lC,uC,cC,hC,dC,fC,pC,gC,vC,mC,yC,bC,xC,EC,wC,kC,MC,SC,NC,OC,TC,CC,AC,PC,RC,DC,LC,_C,IC,jC,BC,FC,zC,GC,VC,WC,HC,UC,$C,YC,qC,XC,KC,ZC,QC,JC,tA,eA,nA,rA,iA,oA,aA,sA,lA,uA,cA,hA,dA,fA,pA,gA,vA,mA,yA,bA,xA,EA,wA,kA,MA,SA,NA,OA={exports:{}};function TA(){return mS||(mS=1,function(t,e){var n=Xk(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,a=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=a?a(n):new t.constructor(n);return t.copy(r),r}}(OA,OA.exports)),OA.exports}function CA(){if(bS)return yS;return bS=1,yS=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},yS}function AA(){if(ES)return xS;return ES=1,xS=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a,n,t)&&(o[i++]=a)}return o},xS}function PA(){if(kS)return wS;return kS=1,wS=function(){return[]}}function RA(){if(SS)return MS;SS=1;var t=AA(),e=PA(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return MS=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function DA(){if(CS)return TS;return CS=1,TS=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},TS}function LA(){if(PS)return AS;PS=1;var t=hS()(Object.getPrototypeOf,Object);return AS=t}function _A(){if(DS)return RS;DS=1;var t=DA(),e=LA(),n=RA(),r=PA(),i=Object.getOwnPropertySymbols;return RS=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function IA(){if(jS)return IS;jS=1;var t=DA(),e=vM();return IS=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function jA(){if(FS)return BS;FS=1;var t=IA(),e=RA(),n=pS();return BS=function(r){return t(r,n,e)}}function BA(){if(YS)return $S;YS=1;var t=nM()(Xk(),"Set");return $S=t}function FA(){if(ZS)return KS;ZS=1;var t=function(){if(WS)return VS;WS=1;var t=nM()(Xk(),"DataView");return VS=t}(),e=rM(),n=function(){if(US)return HS;US=1;var t=nM()(Xk(),"Promise");return HS=t}(),r=BA(),i=function(){if(XS)return qS;XS=1;var t=nM()(Xk(),"WeakMap");return qS=t}(),o=Zk(),a=eM(),s="[object Map]",l="[object Promise]",u="[object Set]",c="[object WeakMap]",h="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),v=a(i),m=o;return(t&&m(new t(new ArrayBuffer(1)))!=h||e&&m(new e)!=s||n&&m(n.resolve())!=l||r&&m(new r)!=u||i&&m(new i)!=c)&&(m=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?a(n):"";if(r)switch(r){case d:return h;case f:return s;case p:return l;case g:return u;case v:return c}return e}),KS=m}function zA(){if(eN)return tN;eN=1;var t=Xk().Uint8Array;return tN=t}function GA(){if(rN)return nN;rN=1;var t=zA();return nN=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function VA(){if(hN)return cN;hN=1;var t=GA();return cN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function WA(){if(fN)return dN;fN=1;var t=GA(),e=function(){if(oN)return iN;oN=1;var t=GA();return iN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(sN)return aN;sN=1;var t=/\w*$/;return aN=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(uN)return lN;uN=1;var t=Kk(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return lN=function(t){return n?Object(n.call(t)):{}}}(),i=VA();return dN=function(o,a,s){var l=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new l(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function HA(){if(gN)return pN;gN=1;var t=Qk(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return pN=n}function UA(){if(mN)return vN;mN=1;var t=HA(),e=LA(),n=cS();return vN=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function $A(){if(EN)return xN;EN=1;var t=function(){if(bN)return yN;bN=1;var t=FA(),e=pM();return yN=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=RM(),n=sS(),r=n&&n.isMap,i=r?e(r):t;return xN=i}function YA(){if(SN)return MN;SN=1;var t=function(){if(kN)return wN;kN=1;var t=FA(),e=pM();return wN=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=RM(),n=sS(),r=n&&n.isSet,i=r?e(r):t;return MN=i}function qA(){if(ON)return NN;ON=1;var t=lM(),e=uM(),n=dM(),r=function(){if(ZM)return KM;ZM=1;var t=fM(),e=pS();return KM=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(oS)return iS;oS=1;var t=fM(),e=vS();return iS=function(n,r){return n&&t(r,e(r),n)}}(),o=TA(),a=CA(),s=function(){if(OS)return NS;OS=1;var t=fM(),e=RA();return NS=function(n,r){return t(n,e(n),r)}}(),l=function(){if(_S)return LS;_S=1;var t=fM(),e=_A();return LS=function(n,r){return t(n,e(n),r)}}(),u=jA(),c=function(){if(GS)return zS;GS=1;var t=IA(),e=_A(),n=vS();return zS=function(r){return t(r,n,e)}}(),h=FA(),d=function(){if(JS)return QS;JS=1;var t=Object.prototype.hasOwnProperty;return QS=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},QS}(),f=WA(),p=UA(),g=vM(),v=CM(),m=$A(),y=Qk(),b=YA(),x=pS(),E=vS(),w="[object Arguments]",k="[object Function]",M="[object Object]",S={};return S[w]=S["[object Array]"]=S["[object ArrayBuffer]"]=S["[object DataView]"]=S["[object Boolean]"]=S["[object Date]"]=S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Map]"]=S["[object Number]"]=S[M]=S["[object RegExp]"]=S["[object Set]"]=S["[object String]"]=S["[object Symbol]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S["[object Error]"]=S[k]=S["[object WeakMap]"]=!1,NN=function N(O,T,C,A,P,R){var D,L=1&T,_=2&T,I=4&T;if(C&&(D=P?C(O,A,P,R):C(O)),void 0!==D)return D;if(!y(O))return O;var j=g(O);if(j){if(D=d(O),!L)return a(O,D)}else{var B=h(O),F=B==k||"[object GeneratorFunction]"==B;if(v(O))return o(O,L);if(B==M||B==w||F&&!P){if(D=_||F?{}:p(O),!L)return _?l(O,i(D,O)):s(O,r(D,O))}else{if(!S[B])return P?O:{};D=f(O,B,L)}}R||(R=new t);var z=R.get(O);if(z)return z;R.set(O,D),b(O)?O.forEach((function(t){D.add(N(t,T,C,t,O,R))})):m(O)&&O.forEach((function(t,e){D.set(e,N(t,T,C,e,O,R))}));var G=j?void 0:(I?_?c:u:_?E:x)(O);return e(G||O,(function(t,e){G&&(t=O[e=t]),n(D,e,N(t,T,C,e,O,R))})),D},NN}function XA(){if(CN)return TN;CN=1;var t=qA();return TN=function(e){return t(e,4)}}function KA(){if(PN)return AN;return PN=1,AN=function(t){return function(){return t}}}function ZA(){if(_N)return LN;_N=1;var t=(DN||(DN=1,RN=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var l=a[t?s:++i];if(!1===n(o[l],l,o))break}return e}}),RN),e=t();return LN=e}function QA(){if(jN)return IN;jN=1;var t=ZA(),e=pS();return IN=function(n,r){return n&&t(n,r,e)}}function JA(){if(GN)return zN;GN=1;var t=QA(),e=function(){if(FN)return BN;FN=1;var t=fS();return BN=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,a=n?o:-1,s=Object(r);(n?a--:++a<o)&&!1!==i(s[a],a,s););return r}},BN}(),n=e(t);return zN=n}function tP(){if(WN)return VN;return WN=1,VN=function(t){return t}}function eP(){if(UN)return HN;UN=1;var t=tP();return HN=function(e){return"function"==typeof e?e:t}}function nP(){if(YN)return $N;YN=1;var t=uM(),e=JA(),n=eP(),r=vM();return $N=function(i,o){return(r(i)?t:e)(i,n(o))}}function rP(){return XN?qN:(XN=1,qN=nP())}function iP(){if(rO)return nO;rO=1;var t=sM(),e=JN?QN:(JN=1,QN=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=eO?tO:(eO=1,tO=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,nO=r}function oP(){if(sO)return aO;return sO=1,aO=function(t,e){return t.has(e)}}function aP(){if(uO)return lO;uO=1;var t=iP(),e=(oO||(oO=1,iO=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),iO),n=oP();return lO=function(r,i,o,a,s,l){var u=1&o,c=r.length,h=i.length;if(c!=h&&!(u&&h>c))return!1;var d=l.get(r),f=l.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,v=2&o?new t:void 0;for(l.set(r,i),l.set(i,r);++p<c;){var m=r[p],y=i[p];if(a)var b=u?a(y,m,p,i,r,l):a(m,y,p,r,i,l);if(void 0!==b){if(b)continue;g=!1;break}if(v){if(!e(i,(function(t,e){if(!n(v,e)&&(m===t||s(m,t,o,a,l)))return v.push(e)}))){g=!1;break}}else if(m!==y&&!s(m,y,o,a,l)){g=!1;break}}return l.delete(r),l.delete(i),g},lO}function sP(){if(fO)return dO;return fO=1,dO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},dO}function lP(){if(gO)return pO;gO=1;var t=Kk(),e=zA(),n=Uk(),r=aP(),i=(hO||(hO=1,cO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),cO),o=sP(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return pO=function(t,a,l,u,c,h,d){switch(l){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!h(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var f=i;case"[object Set]":var p=1&u;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;u|=2,d.set(t,a);var v=r(f(t),f(a),u,c,h,d);return d.delete(t),v;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function uP(){if(bO)return yO;bO=1;var t=lM(),e=aP(),n=lP(),r=function(){if(mO)return vO;mO=1;var t=jA(),e=Object.prototype.hasOwnProperty;return vO=function(n,r,i,o,a,s){var l=1&i,u=t(n),c=u.length;if(c!=t(r).length&&!l)return!1;for(var h=c;h--;){var d=u[h];if(!(l?d in r:e.call(r,d)))return!1}var f=s.get(n),p=s.get(r);if(f&&p)return f==r&&p==n;var g=!0;s.set(n,r),s.set(r,n);for(var v=l;++h<c;){var m=n[d=u[h]],y=r[d];if(o)var b=l?o(y,m,d,r,n,s):o(m,y,d,n,r,s);if(!(void 0===b?m===y||a(m,y,i,o,s):b)){g=!1;break}v||(v="constructor"==d)}if(g&&!v){var x=n.constructor,E=r.constructor;x==E||!("constructor"in n)||!("constructor"in r)||"function"==typeof x&&x instanceof x&&"function"==typeof E&&E instanceof E||(g=!1)}return s.delete(n),s.delete(r),g},vO}(),i=FA(),o=vM(),a=CM(),s=lS(),l="[object Arguments]",u="[object Array]",c="[object Object]",h=Object.prototype.hasOwnProperty;return yO=function(d,f,p,g,v,m){var y=o(d),b=o(f),x=y?u:i(d),E=b?u:i(f),w=(x=x==l?c:x)==c,k=(E=E==l?c:E)==c,M=x==E;if(M&&a(d)){if(!a(f))return!1;y=!0,w=!1}if(M&&!w)return m||(m=new t),y||s(d)?e(d,f,p,g,v,m):n(d,f,x,p,g,v,m);if(!(1&p)){var S=w&&h.call(d,"__wrapped__"),N=k&&h.call(f,"__wrapped__");if(S||N){var O=S?d.value():d,T=N?f.value():f;return m||(m=new t),v(O,T,p,g,m)}}return!!M&&(m||(m=new t),r(d,f,p,g,v,m))}}function cP(){if(EO)return xO;EO=1;var t=uP(),e=pM();return xO=function n(r,i,o,a,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,a,n,s))},xO}function hP(){if(SO)return MO;SO=1;var t=Qk();return MO=function(e){return e==e&&!t(e)}}function dP(){if(CO)return TO;return CO=1,TO=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function fP(){if(PO)return AO;PO=1;var t=function(){if(kO)return wO;kO=1;var t=lM(),e=cP();return wO=function(n,r,i,o){var a=i.length,s=a,l=!o;if(null==n)return!s;for(n=Object(n);a--;){var u=i[a];if(l&&u[2]?u[1]!==n[u[0]]:!(u[0]in n))return!1}for(;++a<s;){var c=(u=i[a])[0],h=n[c],d=u[1];if(l&&u[2]){if(void 0===h&&!(c in n))return!1}else{var f=new t;if(o)var p=o(h,d,c,n,r,f);if(!(void 0===p?e(d,h,3,o,f):p))return!1}}return!0},wO}(),e=function(){if(OO)return NO;OO=1;var t=hP(),e=pS();return NO=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],a=n[o];r[i]=[o,a,t(a)]}return r},NO}(),n=dP();return AO=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function pP(){if(DO)return RO;DO=1;var t=Zk(),e=pM();return RO=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function gP(){if(_O)return LO;_O=1;var t=vM(),e=pP(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return LO=function(i,o){if(t(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function vP(){if(FO)return BO;FO=1;var t=function(){if(jO)return IO;jO=1;var t=sM();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var a=n.apply(this,t);return i.cache=o.set(e,a)||o,a};return i.cache=new(e.Cache||t),i}return e.Cache=t,IO=e}();return BO=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function mP(){if(WO)return VO;return WO=1,VO=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},VO}function yP(){if(YO)return $O;YO=1;var t=function(){if(UO)return HO;UO=1;var t=Kk(),e=mP(),n=vM(),r=pP(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return HO=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},HO}();return $O=function(e){return null==e?"":t(e)}}function bP(){if(XO)return qO;XO=1;var t=vM(),e=gP(),n=function(){if(GO)return zO;GO=1;var t=vP(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t((function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,(function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)})),r}));return zO=r}(),r=yP();return qO=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function xP(){if(ZO)return KO;ZO=1;var t=pP();return KO=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function EP(){if(JO)return QO;JO=1;var t=bP(),e=xP();return QO=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},QO}function wP(){if(oT)return iT;oT=1;var t=bP(),e=gM(),n=vM(),r=AM(),i=PM(),o=xP();return iT=function(a,s,l){for(var u=-1,c=(s=t(s,a)).length,h=!1;++u<c;){var d=o(s[u]);if(!(h=null!=a&&l(a,d)))break;a=a[d]}return h||++u!=c?h:!!(c=null==a?0:a.length)&&i(c)&&r(d,c)&&(n(a)||e(a))},iT}function kP(){if(sT)return aT;sT=1;var t=rT?nT:(rT=1,nT=function(t,e){return null!=t&&e in Object(t)}),e=wP();return aT=function(n,r){return null!=n&&e(n,r,t)}}function MP(){if(uT)return lT;uT=1;var t=cP(),e=function(){if(eT)return tT;eT=1;var t=EP();return tT=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=kP(),r=gP(),i=hP(),o=dP(),a=xP();return lT=function(s,l){return r(s)&&i(l)?o(a(s),l):function(r){var i=e(r,s);return void 0===i&&i===l?n(r,s):t(l,i,3)}}}function SP(){if(hT)return cT;return hT=1,cT=function(t){return function(e){return null==e?void 0:e[t]}}}function NP(){if(gT)return pT;gT=1;var t=SP(),e=function(){if(fT)return dT;fT=1;var t=EP();return dT=function(e){return function(n){return t(n,e)}}}(),n=gP(),r=xP();return pT=function(i){return n(i)?t(r(i)):e(i)}}function OP(){if(mT)return vT;mT=1;var t=fP(),e=MP(),n=tP(),r=vM(),i=NP();return vT=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function TP(){if(bT)return yT;bT=1;var t=AA(),e=function(){if(ZN)return KN;ZN=1;var t=JA();return KN=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},KN}(),n=OP(),r=vM();return yT=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function CP(){if(kT)return wT;kT=1;var t=function(){if(ET)return xT;ET=1;var t=Object.prototype.hasOwnProperty;return xT=function(e,n){return null!=e&&t.call(e,n)}}(),e=wP();return wT=function(n,r){return null!=n&&e(n,r,t)}}function AP(){if(ST)return MT;ST=1;var t=dS(),e=FA(),n=gM(),r=vM(),i=fS(),o=CM(),a=cS(),s=lS(),l=Object.prototype.hasOwnProperty;return MT=function(u){if(null==u)return!0;if(i(u)&&(r(u)||"string"==typeof u||"function"==typeof u.splice||o(u)||s(u)||n(u)))return!u.length;var c=e(u);if("[object Map]"==c||"[object Set]"==c)return!u.size;if(a(u))return!t(u).length;for(var h in u)if(l.call(u,h))return!1;return!0}}function PP(){if(OT)return NT;return OT=1,NT=function(t){return void 0===t}}function RP(){if(CT)return TT;CT=1;var t=JA(),e=fS();return TT=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,(function(t,e,n){o[++i]=r(t,e,n)})),o},TT}function DP(){if(PT)return AT;PT=1;var t=mP(),e=OP(),n=RP(),r=vM();return AT=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function LP(){if(jT)return IT;jT=1;var t=(DT||(DT=1,RT=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),RT),e=JA(),n=OP(),r=(_T||(_T=1,LT=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),LT),i=vM();return IT=function(o,a,s){var l=i(o)?t:r,u=arguments.length<3;return l(o,n(a,4),s,u,e)},IT}function _P(){if(YT)return $T;YT=1;var t=function(){if(GT)return zT;GT=1;var t=SP()("length");return zT=t}(),e=function(){if(WT)return VT;WT=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return VT=function(e){return t.test(e)}}(),n=function(){if(UT)return HT;UT=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",l="[\\ufe0e\\ufe0f]?",u=l+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+l+s+")*",c="(?:"+[i+n+"?",n,o,a,e].join("|")+")",h=RegExp(r+"(?="+r+")|"+c+u,"g");return HT=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return $T=function(r){return e(r)?n(r):t(r)}}function IP(){if(XT)return qT;XT=1;var t=dS(),e=FA(),n=fS(),r=function(){if(FT)return BT;FT=1;var t=Zk(),e=vM(),n=pM();return BT=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=_P();return qT=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var a=e(o);return"[object Map]"==a||"[object Set]"==a?o.size:t(o).length}}function jP(){if(ZT)return KT;ZT=1;var t=uM(),e=HA(),n=QA(),r=OP(),i=LA(),o=vM(),a=CM(),s=Jk(),l=Qk(),u=lS();return KT=function(c,h,d){var f=o(c),p=f||a(c)||u(c);if(h=r(h,4),null==d){var g=c&&c.constructor;d=p?f?new g:[]:l(c)&&s(g)?e(i(c)):{}}return(p?t:n)(c,(function(t,e,n){return h(d,t,e,n)})),d},KT}function BP(){if(eC)return tC;eC=1;var t=DA(),e=function(){if(JT)return QT;JT=1;var t=Kk(),e=gM(),n=vM(),r=t?t.isConcatSpreadable:void 0;return QT=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return tC=function n(r,i,o,a,s){var l=-1,u=r.length;for(o||(o=e),s||(s=[]);++l<u;){var c=r[l];i>0&&o(c)?i>1?n(c,i-1,o,a,s):t(s,c):a||(s[s.length]=c)}return s},tC}function FP(){if(oC)return iC;oC=1;var t=rC?nC:(rC=1,nC=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 iC=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),l=Array(s);++a<s;)l[a]=o[r+a];a=-1;for(var u=Array(r+1);++a<r;)u[a]=o[a];return u[r]=i(l),t(n,this,u)}},iC}function zP(){if(hC)return cC;hC=1;var t=function(){if(sC)return aC;sC=1;var t=KA(),e=cM(),n=tP();return aC=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(uC)return lC;uC=1;var t=Date.now;return lC=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},lC}(),n=e(t);return cC=n}function GP(){if(fC)return dC;fC=1;var t=tP(),e=FP(),n=zP();return dC=function(r,i){return n(e(r,i,t),r+"")}}function VP(){if(gC)return pC;return gC=1,pC=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},pC}function WP(){if(EC)return xC;EC=1;var t=VP(),e=mC?vC:(mC=1,vC=function(t){return t!=t}),n=(bC||(bC=1,yC=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),yC);return xC=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function HP(){if(CC)return TC;CC=1;var t=BA(),e=OC?NC:(OC=1,NC=function(){}),n=sP(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return TC=r}function UP(){if(PC)return AC;PC=1;var t=iP(),e=function(){if(kC)return wC;kC=1;var t=WP();return wC=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(SC||(SC=1,MC=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),MC),r=oP(),i=HP(),o=sP();return AC=function(a,s,l){var u=-1,c=e,h=a.length,d=!0,f=[],p=f;if(l)d=!1,c=n;else if(h>=200){var g=s?null:i(a);if(g)return o(g);d=!1,c=r,p=new t}else p=s?[]:f;t:for(;++u<h;){var v=a[u],m=s?s(v):v;if(v=l||0!==v?v:0,d&&m==m){for(var y=p.length;y--;)if(p[y]===m)continue t;s&&p.push(m),f.push(v)}else c(p,m,l)||(p!==f&&p.push(m),f.push(v))}return f},AC}function $P(){if(DC)return RC;DC=1;var t=fS(),e=pM();return RC=function(n){return e(n)&&t(n)}}function YP(){if(_C)return LC;_C=1;var t=BP(),e=GP(),n=UP(),r=$P(),i=e((function(e){return n(t(e,1,r,!0))}));return LC=i}function qP(){if(FC)return BC;FC=1;var t=function(){if(jC)return IC;jC=1;var t=mP();return IC=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=pS();return BC=function(n){return null==n?[]:t(n,e(n))}}function XP(){if(GC)return zC;var t;GC=1;try{t={clone:XA(),constant:KA(),each:rP(),filter:TP(),has:CP(),isArray:vM(),isEmpty:AP(),isFunction:Jk(),isUndefined:PP(),keys:pS(),map:DP(),reduce:LP(),size:IP(),transform:jP(),union:YP(),values:qP()}}catch(t){}return t||(t=window._),zC=t}function KP(){if(WC)return VC;WC=1;var t=XP();VC=n;var e="\0";function n(n){this._isDirected=!t.has(n,"directed")||n.directed,this._isMultigraph=!!t.has(n,"multigraph")&&n.multigraph,this._isCompound=!!t.has(n,"compound")&&n.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function r(t,e){t[e]?t[e]++:t[e]=1}function i(t,e){--t[e]||delete t[e]}function o(e,n,r,i){var o=""+n,a=""+r;if(!e&&o>a){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,l=arguments[0];"object"==typeof l&&null!==l&&"v"in l?(e=l.v,n=l.w,i=l.name,2===arguments.length&&(a=arguments[1],s=!0)):(e=l,n=arguments[1],i=arguments[3],arguments.length>2&&(a=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var u=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,u))return s&&(this._edgeLabels[u]=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[u]=s?a:this._defaultEdgeLabelFn(e,n,i);var c=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=c.v,n=c.w,Object.freeze(c),this._edgeObjs[u]=c,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][u]=c,this._out[e][u]=c,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))},VC}function ZP(){return YC?$C:(YC=1,$C={Graph:KP(),version:UC?HC:(UC=1,HC="2.1.8")})}function QP(){if(XC)return qC;XC=1;var t=XP(),e=KP();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 qC={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}}}function JP(){if(ZC)return KC;ZC=1;var t=XP();return KC=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},KC}function tR(){if(JC)return QC;JC=1;var t=XP();function e(){this._arr=[],this._keyIndices={}}return QC=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<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},QC}function eR(){if(eA)return tA;eA=1;var t=XP(),e=tR();tA=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},l=new e,u=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),u=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);u<n.distance&&(n.distance=u,n.predecessor=o,l.decrease(e,u))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},l.add(t,e)}));for(;l.size()>0&&(o=l.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(u);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return tA}function nR(){if(rA)return nA;rA=1;var t=eR(),e=XP();return nA=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function rR(){if(oA)return iA;oA=1;var t=XP();return iA=function(e){var n=0,r=[],i={},o=[];function a(s){var l=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&&(l.lowlink=Math.min(l.lowlink,i[e].index)):(a(e),l.lowlink=Math.min(l.lowlink,i[e].lowlink))})),l.lowlink===l.index){var u,c=[];do{u=r.pop(),i[u].onStack=!1,c.push(u)}while(s!==u);o.push(c)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},iA}function iR(){if(sA)return aA;sA=1;var t=XP(),e=rR();return aA=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function oR(){if(uA)return lA;uA=1;var t=XP();lA=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;s<a.distance&&(a.distance=s,a.predecessor=i.predecessor)}))}))})),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return lA}function aR(){if(hA)return cA;hA=1;var t=XP();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),(function a(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),a),delete i[s],o.push(s))})),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return cA=e,e.CycleException=n,n.prototype=new Error,cA}function sR(){if(fA)return dA;fA=1;var t=aR();return dA=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function lR(){if(gA)return pA;gA=1;var t=XP();function e(n,r,i,o,a,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(a(r),(function(t){e(n,t,i,o,a,s)})),i&&s.push(r))}return pA=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],s={};return t.each(r,(function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,a)})),a},pA}function uR(){if(mA)return vA;mA=1;var t=lR();return vA=function(e,n){return t(e,n,"post")}}function cR(){if(bA)return yA;bA=1;var t=lR();return yA=function(e,n){return t(e,n,"pre")}}function hR(){if(EA)return xA;EA=1;var t=XP(),e=KP(),n=tR();return xA=function(r,i){var o,a=new e,s={},l=new n;function u(t){var e=t.v===o?t.w:t.v,n=l.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,l.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){l.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),l.decrease(r.nodes()[0],0);var c=!1;for(;l.size()>0;){if(o=l.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(c)throw new Error("Input graph is not connected: "+r);c=!0}r.nodeEdges(o).forEach(u)}return a}}try{NA=function(){if(SA)return MA;SA=1;var t=ZP();return MA={Graph:t.Graph,json:QP(),alg:kA?wA:(kA=1,wA={components:JP(),dijkstra:eR(),dijkstraAll:nR(),findCycles:iR(),floydWarshall:oR(),isAcyclic:sR(),postorder:uR(),preorder:cR(),prim:hR(),tarjan:rR(),topsort:aR()}),version:t.version}}()}catch(t){}NA||(NA=window.graphlib);var dR,fR,pR,gR,vR,mR,yR,bR,xR,ER,wR,kR,MR,SR,NR,OR,TR,CR,AR,PR,RR,DR,LR,_R,IR,jR,BR,FR,zR,GR,VR,WR,HR,UR,$R,YR,qR,XR,KR,ZR,QR,JR,tD,eD,nD,rD,iD,oD,aD,sD,lD,uD,cD,hD,dD,fD,pD,gD,vD,mD,yD,bD,xD,ED,wD,kD,MD,SD,ND,OD,TD,CD,AD,PD,RD,DD,LD,_D,ID,jD,BD,FD,zD,GD,VD,WD,HD,UD,$D,YD,qD,XD,KD,ZD=NA;function QD(){if(gR)return pR;gR=1;var t=Uk(),e=fS(),n=AM(),r=Qk();return pR=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)},pR}function JD(){if(kR)return wR;kR=1;var t=function(){if(ER)return xR;ER=1;var t=/\s/;return xR=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},xR}(),e=/^\s+/;return wR=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function tL(){if(OR)return NR;OR=1;var t=function(){if(SR)return MR;SR=1;var t=JD(),e=Qk(),n=pP(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return MR=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var l="function"==typeof s.valueOf?s.valueOf():s;s=e(l)?l+"":l}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var u=i.test(s);return u||o.test(s)?a(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),e=1/0;return NR=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function eL(){if(PR)return AR;PR=1;var t=VP(),e=OP(),n=function(){if(CR)return TR;CR=1;var t=tL();return TR=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return AR=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var l=null==a?0:n(a);return l<0&&(l=r(s+l,0)),t(i,e(o,3),l)},AR}function nL(){if(_R)return LR;_R=1;var t=BP();return LR=function(e){return(null==e?0:e.length)?t(e,1):[]}}function rL(){if(WR)return VR;WR=1;var t=pP();return VR=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=n(a);if(null!=s&&(void 0===l?s==s&&!t(s):r(s,l)))var l=s,u=a}return u},VR}function iL(){if(XR)return qR;XR=1;var t=hM(),e=Uk();return qR=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function oL(){if(JR)return QR;return JR=1,QR=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function aL(){if(rD)return nD;rD=1;var t=iL(),e=TA(),n=VA(),r=CA(),i=UA(),o=gM(),a=vM(),s=$P(),l=CM(),u=Jk(),c=Qk(),h=function(){if(ZR)return KR;ZR=1;var t=Zk(),e=LA(),n=pM(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return KR=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var l=a.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==s}}(),d=lS(),f=oL(),p=function(){if(eD)return tD;eD=1;var t=fM(),e=vS();return tD=function(n){return t(n,e(n))}}();return nD=function(g,v,m,y,b,x,E){var w=f(g,m),k=f(v,m),M=E.get(k);if(M)t(g,m,M);else{var S=x?x(w,k,m+"",g,v,E):void 0,N=void 0===S;if(N){var O=a(k),T=!O&&l(k),C=!O&&!T&&d(k);S=k,O||T||C?a(w)?S=w:s(w)?S=r(w):T?(N=!1,S=e(k,!0)):C?(N=!1,S=n(k,!0)):S=[]:h(k)||o(k)?(S=w,o(w)?S=p(w):c(w)&&!u(w)||(S=i(k))):N=!1}N&&(E.set(k,S),b(S,k,y,x,E),E.delete(k)),t(g,m,S)}}}function sL(){if(hD)return cD;return hD=1,cD=function(t,e){return t<e}}function lL(){if(ED)return xD;ED=1;var t=EP(),e=function(){if(bD)return yD;bD=1;var t=dM(),e=bP(),n=AM(),r=Qk(),i=xP();return yD=function(o,a,s,l){if(!r(o))return o;for(var u=-1,c=(a=e(a,o)).length,h=c-1,d=o;null!=d&&++u<c;){var f=i(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(u!=h){var g=d[f];void 0===(p=l?l(g,f,d):void 0)&&(p=r(g)?g:n(a[u+1])?[]:{})}t(d,f,p),d=d[f]}return o},yD}(),n=bP();return xD=function(r,i,o){for(var a=-1,s=i.length,l={};++a<s;){var u=i[a],c=t(r,u);o(c,u)&&e(l,n(u,r),c)}return l},xD}function uL(){if(PD)return AD;PD=1;var t=function(){if(CD)return TD;CD=1;var t=Math.ceil,e=Math.max;return TD=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),l=Array(s);s--;)l[o?s:++a]=n,n+=i;return l},TD}(),e=QD(),n=tL();return AD=function(r){return function(i,o,a){return a&&"number"!=typeof a&&e(i,o,a)&&(o=a=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),a=void 0===a?i<o?1:-1:n(a),t(i,o,a,r)}},AD}function cL(){if(FD)return BD;FD=1;var t=function(){if(jD)return ID;jD=1;var t=pP();return ID=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,l=null===n,u=n==n,c=t(n);if(!l&&!c&&!a&&e>n||a&&s&&u&&!l&&!c||i&&s&&u||!r&&u||!o)return 1;if(!i&&!a&&!c&&e<n||c&&r&&o&&!i&&!a||l&&r&&o||!s&&o||!u)return-1}return 0}}();return BD=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,l=r.length;++i<s;){var u=t(o[i],a[i]);if(u)return i>=l?u:u*("desc"==r[i]?-1:1)}return e.index-n.index},BD}function hL(){if(GD)return zD;GD=1;var t=mP(),e=EP(),n=OP(),r=RP(),i=(_D||(_D=1,LD=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),LD),o=RM(),a=cL(),s=tP(),l=vM();return zD=function(u,c,h){c=c.length?t(c,(function(t){return l(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;c=t(c,o(n));var f=r(u,(function(e,n,r){return{criteria:t(c,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,h)}))},zD}try{KD={cloneDeep:function(){if(fR)return dR;fR=1;var t=qA();return dR=function(e){return t(e,5)}}(),constant:KA(),defaults:function(){if(mR)return vR;mR=1;var t=GP(),e=Uk(),n=QD(),r=vS(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,l=a.length,u=l>2?a[2]:void 0;for(u&&n(a[0],a[1],u)&&(l=1);++s<l;)for(var c=a[s],h=r(c),d=-1,f=h.length;++d<f;){var p=h[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=c[p])}return t}));return vR=a}(),each:rP(),filter:TP(),find:function(){if(DR)return RR;DR=1;var t=function(){if(bR)return yR;bR=1;var t=OP(),e=fS(),n=pS();return yR=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var l=t(o,3);i=n(i),o=function(t){return l(s[t],t,s)}}var u=r(i,o,a);return u>-1?s[l?i[u]:u]:void 0}},yR}(),e=t(eL());return RR=e}(),flatten:nL(),forEach:nP(),forIn:function(){if(jR)return IR;jR=1;var t=ZA(),e=eP(),n=vS();return IR=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:CP(),isUndefined:PP(),last:(FR||(FR=1,BR=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),BR),map:DP(),mapValues:function(){if(GR)return zR;GR=1;var t=hM(),e=QA(),n=OP();return zR=function(r,i){var o={};return i=n(i,3),e(r,(function(e,n,r){t(o,n,i(e,n,r))})),o}}(),max:function(){if(YR)return $R;YR=1;var t=rL(),e=UR?HR:(UR=1,HR=function(t,e){return t>e}),n=tP();return $R=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(uD)return lD;uD=1;var t=function(){if(oD)return iD;oD=1;var t=lM(),e=iL(),n=ZA(),r=aL(),i=Qk(),o=vS(),a=oL();return iD=function s(l,u,c,h,d){l!==u&&n(u,(function(n,o){if(d||(d=new t),i(n))r(l,u,o,c,s,h,d);else{var f=h?h(a(l,o),n,o+"",l,u,d):void 0;void 0===f&&(f=n),e(l,o,f)}}),o)},iD}(),e=function(){if(sD)return aD;sD=1;var t=GP(),e=QD();return aD=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);++i<o;){var l=r[i];l&&n(t,l,i,a)}return t}))},aD}(),n=e((function(e,n,r){t(e,n,r)}));return lD=n}(),min:function(){if(fD)return dD;fD=1;var t=rL(),e=sL(),n=tP();return dD=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(gD)return pD;gD=1;var t=rL(),e=OP(),n=sL();return pD=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(mD)return vD;mD=1;var t=Xk();return vD=function(){return t.Date.now()}}(),pick:function(){if(OD)return ND;OD=1;var t=function(){if(kD)return wD;kD=1;var t=lL(),e=kP();return wD=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(SD)return MD;SD=1;var t=nL(),e=FP(),n=zP();return MD=function(r){return n(e(r,void 0,t),r+"")}}()((function(e,n){return null==e?{}:t(e,n)}));return ND=e}(),range:function(){if(DD)return RD;DD=1;var t=uL()();return RD=t}(),reduce:LP(),sortBy:function(){if(WD)return VD;WD=1;var t=BP(),e=hL(),n=GP(),r=QD(),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 VD=i}(),uniqueId:function(){if(UD)return HD;UD=1;var t=yP(),e=0;return HD=function(n){var r=++e;return t(n)+r},HD}(),values:qP(),zipObject:function(){if(XD)return qD;XD=1;var t=dM(),e=(YD||(YD=1,$D=function(t,e,n){for(var r=-1,i=t.length,o=e.length,a={};++r<i;){var s=r<o?e[r]:void 0;n(a,t[r],s)}return a}),$D);return qD=function(n,r){return e(n||[],r||[],t)},qD}()}}catch(t){}KD||(KD=window._);var dL=KD,fL=pL;function pL(){var t={};t._next=t._prev=t,this._sentinel=t}function gL(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function vL(t,e){if("_next"!==t&&"_prev"!==t)return e}pL.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return gL(e),e},pL.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&gL(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},pL.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,vL)),n=n._prev;return"["+t.join(", ")+"]"};var mL=dL,yL=ZD.Graph,bL=fL,xL=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new yL,r=0,i=0;mL.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),mL.forEach(t.edges(),(function(t){var o=n.edge(t.v,t.w)||0,a=e(t),s=o+a;n.setEdge(t.v,t.w,s),i=Math.max(i,n.node(t.v).out+=a),r=Math.max(r,n.node(t.w).in+=a)}));var o=mL.range(i+r+3).map((function(){return new bL})),a=r+1;return mL.forEach(n.nodes(),(function(t){kL(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||EL),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)wL(t,e,n,r);for(;r=o.dequeue();)wL(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(wL(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return mL.flatten(mL.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},EL=mL.constant(1);function wL(t,e,n,r,i){var o=i?[]:void 0;return mL.forEach(t.inEdges(r.v),(function(r){var a=t.edge(r),s=t.node(r.v);i&&o.push({v:r.v,w:r.w}),s.out-=a,kL(e,n,s)})),mL.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,kL(e,n,a)})),t.removeNode(r.v),o}function kL(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)}var ML=dL,SL=xL,NL={run:function(t){var e="greedy"===t.graph().acyclicer?SL(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){ML.has(r,o)||(r[o]=!0,n[o]=!0,ML.forEach(t.outEdges(o),(function(t){ML.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return ML.forEach(t.nodes(),i),e}(t);ML.forEach(e,(function(e){var n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,ML.uniqueId("rev"))}))},undo:function(t){ML.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}}))}};var OL=dL,TL=ZD.Graph,CL={addDummyNode:AL,simplify:function(t){var e=(new TL).setGraph(t.graph());return OL.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),OL.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})})),e},asNonCompoundGraph:function(t){var e=new TL({multigraph:t.isMultigraph()}).setGraph(t.graph());return OL.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),OL.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=OL.map(t.nodes(),(function(e){var n={};return OL.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return OL.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=OL.map(t.nodes(),(function(e){var n={};return OL.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return OL.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,a=e.x-i,s=e.y-o,l=t.width/2,u=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*l>Math.abs(a)*u?(s<0&&(u=-u),n=u*a/s,r=u):(a<0&&(l=-l),n=l,r=l*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=OL.map(OL.range(PL(t)+1),(function(){return[]}));return OL.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;OL.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=OL.min(OL.map(t.nodes(),(function(e){return t.node(e).rank})));OL.forEach(t.nodes(),(function(n){var r=t.node(n);OL.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=OL.min(OL.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];OL.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r)}));var r=0,i=t.graph().nodeRankFactor;OL.forEach(n,(function(e,n){OL.isUndefined(e)&&n%i!=0?--r:r&&OL.forEach(e,(function(e){t.node(e).rank+=r}))}))},addBorderNode:function(t,e,n,r){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return AL(t,"border",i,e)},maxRank:PL,partition:function(t,e){var n={lhs:[],rhs:[]};return OL.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=OL.now();try{return e()}finally{console.log(t+" time: "+(OL.now()-n)+"ms")}},notime:function(t,e){return e()}};function AL(t,e,n,r){var i;do{i=OL.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function PL(t){return OL.max(OL.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!OL.isUndefined(n))return n})))}var RL=dL,DL=CL,LL={run:function(t){t.graph().dummyChains=[],RL.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,l=t.node(s).rank,u=e.name,c=t.edge(e),h=c.labelRank;if(l===a+1)return;for(t.removeEdge(e),i=0,++a;a<l;++i,++a)c.points=[],r={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},n=DL.addDummyNode(t,"edge",r,"_d"),a===h&&(r.width=c.width,r.height=c.height,r.dummy="edge-label",r.labelpos=c.labelpos),t.setEdge(o,n,{weight:c.weight},u),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:c.weight},u)}(t,e)}))},undo:function(t){RL.forEach(t.graph().dummyChains,(function(e){var n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)}))}};var _L=dL,IL={longestPath:function(t){var e={};_L.forEach(t.sources(),(function n(r){var i=t.node(r);if(_L.has(e,r))return i.rank;e[r]=!0;var o=_L.min(_L.map(t.outEdges(r),(function(e){return n(e.w)-t.edge(e).minlen})));return o!==Number.POSITIVE_INFINITY&&null!=o||(o=0),i.rank=o}))},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var jL=dL,BL=ZD.Graph,FL=IL.slack,zL=function(t){var e,n,r=new BL({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;GL(r,t)<o;)e=VL(r,t),n=r.hasNode(e.v)?FL(t,e):-FL(t,e),WL(r,t,n);return r};function GL(t,e){return jL.forEach(t.nodes(),(function n(r){jL.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||FL(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function VL(t,e){return jL.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return FL(e,n)}))}function WL(t,e,n){jL.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var HL=dL,UL=zL,$L=IL.slack,YL=IL.longestPath,qL=ZD.alg.preorder,XL=ZD.alg.postorder,KL=CL.simplify,ZL=QL;function QL(t){t=KL(t),YL(t);var e,n=UL(t);for(e_(n),JL(n,t);e=r_(n);)o_(n,t,e,i_(n,t,e))}function JL(t,e){var n=XL(t,t.nodes());n=n.slice(0,n.length-1),HL.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=t_(t,e,n)}(t,e,n)}))}function t_(t,e,n){var r=t.node(n).parent,i=!0,o=e.edge(n,r),a=0;return o||(i=!1,o=e.edge(r,n)),a=o.weight,HL.forEach(e.nodeEdges(n),(function(o){var s,l,u=o.v===n,c=u?o.w:o.v;if(c!==r){var h=u===i,d=e.edge(o).weight;if(a+=h?d:-d,s=n,l=c,t.hasEdge(s,l)){var f=t.edge(n,c).cutvalue;a+=h?-f:f}}})),a}function e_(t,e){arguments.length<2&&(e=t.nodes()[0]),n_(t,{},1,e)}function n_(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,HL.forEach(t.neighbors(r),(function(i){HL.has(e,i)||(n=n_(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function r_(t){return HL.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function i_(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var o=t.node(r),a=t.node(i),s=o,l=!1;o.lim>a.lim&&(s=a,l=!0);var u=HL.filter(e.edges(),(function(e){return l===a_(t,t.node(e.v),s)&&l!==a_(t,t.node(e.w),s)}));return HL.minBy(u,(function(t){return $L(e,t)}))}function o_(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),e_(t),JL(t,e),function(t,e){var n=HL.find(t.nodes(),(function(t){return!e.node(t).parent})),r=qL(t,n);r=r.slice(1),HL.forEach(r,(function(n){var r=t.node(n).parent,i=e.edge(n,r),o=!1;i||(i=e.edge(r,n),o=!0),e.node(n).rank=e.node(r).rank+(o?i.minlen:-i.minlen)}))}(t,e)}function a_(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}QL.initLowLimValues=e_,QL.initCutValues=JL,QL.calcCutValue=t_,QL.leaveEdge=r_,QL.enterEdge=i_,QL.exchangeEdges=o_;var s_=IL.longestPath,l_=zL,u_=ZL,c_=function(t){switch(t.graph().ranker){case"network-simplex":default:d_(t);break;case"tight-tree":!function(t){s_(t),l_(t)}(t);break;case"longest-path":h_(t)}};var h_=s_;function d_(t){u_(t)}var f_=dL,p_=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;f_.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return f_.forEach(t.children(),r),e}(t);f_.forEach(t.graph().dummyChains,(function(n){for(var r=t.node(n),i=r.edgeObj,o=function(t,e,n,r){var i,o,a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>l||u>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:a.concat(s.reverse()),lca:o}}(t,e,i.v,i.w),a=o.path,s=o.lca,l=0,u=a[l],c=!0;n!==i.w;){if(r=t.node(n),c){for(;(u=a[l])!==s&&t.node(u).maxRank<r.rank;)l++;u===s&&(c=!1)}if(!c){for(;l<a.length-1&&t.node(u=a[l+1]).minRank<=r.rank;)l++;u=a[l]}t.setParent(n,u),n=t.successors(n)[0]}}))};var g_=dL,v_=CL,m_={run:function(t){var e=v_.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&g_.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return g_.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=g_.max(g_.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,g_.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return g_.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;g_.forEach(t.children(),(function(a){y_(t,e,i,o,r,n,a)})),t.graph().nodeRankFactor=i},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,g_.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function y_(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var l=v_.addBorderNode(t,"_bt"),u=v_.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(l,a),c.borderTop=l,t.setParent(u,a),c.borderBottom=u,g_.forEach(s,(function(s){y_(t,e,n,r,i,o,s);var c=t.node(s),h=c.borderTop?c.borderTop:s,d=c.borderBottom?c.borderBottom:s,f=c.borderTop?r:2*r,p=h!==d?1:i-o[a]+1;t.setEdge(l,h,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,l,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var b_=dL,x_=CL,E_=function(t){b_.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&b_.forEach(r,e),b_.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)w_(t,"borderLeft","_bl",n,i,o),w_(t,"borderRight","_br",n,i,o)}}))};function w_(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],l=x_.addDummyNode(t,"border",a,n);i[e][o]=l,t.setParent(l,r),s&&t.setEdge(s,l,{weight:1})}var k_=dL,M_={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||S_(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){k_.forEach(t.nodes(),(function(e){O_(t.node(e))})),k_.forEach(t.edges(),(function(e){var n=t.edge(e);k_.forEach(n.points,O_),k_.has(n,"y")&&O_(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){k_.forEach(t.nodes(),(function(e){T_(t.node(e))})),k_.forEach(t.edges(),(function(e){var n=t.edge(e);k_.forEach(n.points,T_),k_.has(n,"x")&&T_(n)}))}(t),S_(t))}};function S_(t){k_.forEach(t.nodes(),(function(e){N_(t.node(e))})),k_.forEach(t.edges(),(function(e){N_(t.edge(e))}))}function N_(t){var e=t.width;t.width=t.height,t.height=e}function O_(t){t.y=-t.y}function T_(t){var e=t.x;t.x=t.y,t.y=e}var C_=dL,A_=function(t){var e={},n=C_.filter(t.nodes(),(function(e){return!t.children(e).length})),r=C_.max(C_.map(n,(function(e){return t.node(e).rank}))),i=C_.map(C_.range(r+1),(function(){return[]}));function o(n){if(!C_.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),C_.forEach(t.successors(n),o)}}var a=C_.sortBy(n,(function(e){return t.node(e).rank}));return C_.forEach(a,o),i};var P_=dL,R_=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=D_(t,e[r-1],e[r]);return n};function D_(t,e,n){for(var r=P_.zipObject(n,P_.map(n,(function(t,e){return e}))),i=P_.flatten(P_.map(e,(function(e){return P_.sortBy(P_.map(t.outEdges(e),(function(e){return{pos:r[e.w],weight:t.edge(e).weight}})),"pos")})),!0),o=1;o<n.length;)o<<=1;var a=2*o-1;o-=1;var s=P_.map(new Array(a),(function(){return 0})),l=0;return P_.forEach(i.forEach((function(t){var e=t.pos+o;s[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=s[e+1]),s[e=e-1>>1]+=t.weight;l+=t.weight*n}))),l}var L_=dL;var __=dL,I_=function(t,e){var n={};return __.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};__.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),__.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];__.isUndefined(e)||__.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(__.isUndefined(e.barycenter)||__.isUndefined(t.barycenter)||e.barycenter>=t.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}(t,e)}}function r(e){return function(n){n.in.push(e),0==--n.indegree&&t.push(n)}}for(;t.length;){var i=t.pop();e.push(i),__.forEach(i.in.reverse(),n(i)),__.forEach(i.out,r(i))}return __.map(__.filter(e,(function(t){return!t.merged})),(function(t){return __.pick(t,["vs","i","barycenter","weight"])}))}(__.filter(n,(function(t){return!t.indegree})))};var j_=dL,B_=CL;function F_(t,e,n){for(var r;e.length&&(r=j_.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var z_=dL,G_=function(t,e){return L_.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=L_.reduce(n,(function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}}),{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}}))},V_=I_,W_=function(t,e){var n=B_.partition(t,(function(t){return j_.has(t,"barycenter")})),r=n.lhs,i=j_.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,l=0;r.sort((u=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:u?e.i-t.i:t.i-e.i})),l=F_(o,i,l),j_.forEach(r,(function(t){l+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,l=F_(o,i,l)}));var u;var c={vs:j_.flatten(o,!0)};s&&(c.barycenter=a/s,c.weight=s);return c},H_=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,u={};s&&(o=z_.filter(o,(function(t){return t!==s&&t!==l})));var c=G_(e,o);z_.forEach(c,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);u[n.v]=o,z_.has(o,"barycenter")&&(a=n,s=o,z_.isUndefined(a.barycenter)?(a.barycenter=s.barycenter,a.weight=s.weight):(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight))}var a,s}));var h=V_(c,r);!function(t,e){z_.forEach(t,(function(t){t.vs=z_.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,u);var d=W_(h,i);if(s&&(d.vs=z_.flatten([s,d.vs,l],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(l)[0]);z_.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var U_=dL,$_=ZD.Graph,Y_=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=U_.uniqueId("_root")););return e}(t),i=new $_({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return U_.forEach(t.nodes(),(function(o){var a=t.node(o),s=t.parent(o);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),U_.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=U_.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),U_.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var q_=dL;var X_=dL,K_=A_,Z_=R_,Q_=H_,J_=Y_,tI=function(t,e,n){var r,i={};q_.forEach(n,(function(n){for(var o,a,s=t.parent(n);s;){if((o=t.parent(s))?(a=i[o],i[o]=s):(a=r,r=s),a&&a!==s)return void e.setEdge(a,s);s=o}}))},eI=ZD.Graph,nI=CL,rI=function(t){var e=nI.maxRank(t),n=iI(t,X_.range(1,e+1),"inEdges"),r=iI(t,X_.range(e-1,-1,-1),"outEdges"),i=K_(t);aI(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,l=0;l<4;++s,++l){oI(s%2?n:r,s%4>=2),i=nI.buildLayerMatrix(t);var u=Z_(t,i);u<a&&(l=0,o=X_.cloneDeep(i),a=u)}aI(t,o)};function iI(t,e,n){return X_.map(e,(function(e){return J_(t,e,n)}))}function oI(t,e){var n=new eI;X_.forEach(t,(function(t){var r=t.graph().root,i=Q_(t,r,n,e);X_.forEach(i.vs,(function(e,n){t.node(e).order=n})),tI(t,n,i.vs)}))}function aI(t,e){X_.forEach(e,(function(e){X_.forEach(e,(function(e,n){t.node(e).order=n}))}))}var sI=dL,lI=ZD.Graph,uI=CL,cI=function(t){var e,n=uI.buildLayerMatrix(t),r=sI.merge(function(t,e){var n={};function r(e,r){var i=0,o=0,a=e.length,s=sI.last(r);return sI.forEach(r,(function(e,l){var u=function(t,e){if(t.node(e).dummy)return sI.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=u?t.node(u).order:a;(u||e===s)&&(sI.forEach(r.slice(o,l+1),(function(e){sI.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||c<a)||o.dummy&&t.node(e).dummy||hI(n,r,e)}))})),o=l+1,i=c)})),r}return sI.reduce(e,r),n}(t,n),function(t,e){var n={};function r(e,r,i,o,a){var s;sI.forEach(sI.range(r,i),(function(r){s=e[r],t.node(s).dummy&&sI.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&hI(n,e,s)}))}))}function i(e,n){var i,o=-1,a=0;return sI.forEach(n,(function(s,l){if("border"===t.node(s).dummy){var u=t.predecessors(s);u.length&&(i=t.node(u[0]).order,r(n,a,l,o,i),a=l,o=i)}r(n,a,n.length,i,e.length)})),n}return sI.reduce(e,i),n}(t,n)),i={};sI.forEach(["u","d"],(function(o){e="u"===o?n:sI.values(n).reverse(),sI.forEach(["l","r"],(function(n){"r"===n&&(e=sI.map(e,(function(t){return sI.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=function(t,e,n,r){var i={},o={},a={};return sI.forEach(e,(function(t){sI.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),sI.forEach(e,(function(t){var e=-1;sI.forEach(t,(function(t){var s=r(t);if(s.length){s=sI.sortBy(s,(function(t){return a[t]}));for(var l=(s.length-1)/2,u=Math.floor(l),c=Math.ceil(l);u<=c;++u){var h=s[u];o[t]===t&&e<a[h]&&!dI(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}(0,e,r,a),l=function(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new lI,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),l=r.node(o),u=0;if(u+=s.width/2,sI.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(u+=n?a:-a),a=0,u+=(s.dummy?e:t)/2,u+=(l.dummy?e:t)/2,u+=l.width/2,sI.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(u+=n?a:-a),a=0,u}}(o.nodesep,o.edgesep,r);return sI.forEach(e,(function(e){var r;sI.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],l=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),l||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function l(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}function u(t){o[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,o[e.v]+a.edge(e))}),0)}function c(e){var n=a.outEdges(e).reduce((function(t,e){return Math.min(t,o[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==s&&(o[e]=Math.max(o[e],n))}return l(u,a.predecessors.bind(a)),l(c,a.successors.bind(a)),sI.forEach(r,(function(t){o[t]=o[n[t]]})),o}(t,e,s.root,s.align,"r"===n);"r"===n&&(l=sI.mapValues(l,(function(t){return-t}))),i[o+n]=l}))}));var o=function(t,e){return sI.minBy(sI.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return sI.forIn(e,(function(e,i){var o=function(t,e){return t.node(e).width}(t,i)/2;n=Math.max(e+o,n),r=Math.min(e-o,r)})),n-r}))}(t,i);return function(t,e){var n=sI.values(e),r=sI.min(n),i=sI.max(n);sI.forEach(["u","d"],(function(n){sI.forEach(["l","r"],(function(o){var a,s=n+o,l=t[s];if(l!==e){var u=sI.values(l);(a="l"===o?r-sI.min(u):i-sI.max(u))&&(t[s]=sI.mapValues(l,(function(t){return t+a})))}}))}))}(i,o),function(t,e){return sI.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=sI.sortBy(sI.map(t,r));return(i[1]+i[2])/2}))}(i,t.graph().align)};function hI(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 dI(t,e,n){if(e>n){var r=e;e=n,n=r}return sI.has(t[e],n)}var fI=dL,pI=CL,gI=cI,vI=function(t){(function(t){var e=pI.buildLayerMatrix(t),n=t.graph().ranksep,r=0;fI.forEach(e,(function(e){var i=fI.max(fI.map(e,(function(e){return t.node(e).height})));fI.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=pI.asNonCompoundGraph(t)),fI.forEach(gI(t),(function(e,n){t.node(n).x=e}))};var mI=dL,yI=NL,bI=LL,xI=c_,EI=CL.normalizeRanks,wI=p_,kI=CL.removeEmptyRanks,MI=m_,SI=E_,NI=M_,OI=rI,TI=vI,CI=CL,AI=ZD.Graph,PI=function(t,e){var n=e&&e.debugTiming?CI.time:CI.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new AI({multigraph:!0,compound:!0}),n=GI(t.graph());return e.setGraph(mI.merge({},DI,zI(n,RI),mI.pick(n,LI))),mI.forEach(t.nodes(),(function(n){var r=GI(t.node(n));e.setNode(n,mI.defaults(zI(r,_I),II)),e.setParent(n,t.parent(n))})),mI.forEach(t.edges(),(function(n){var r=GI(t.edge(n));e.setEdge(n,mI.merge({},BI,zI(r,jI),mI.pick(r,FI)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,mI.forEach(t.edges(),(function(n){var r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){mI.forEach(t.edges(),(function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){yI.run(t)})),e(" nestingGraph.run",(function(){MI.run(t)})),e(" rank",(function(){xI(CI.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};CI.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){kI(t)})),e(" nestingGraph.cleanup",(function(){MI.cleanup(t)})),e(" normalizeRanks",(function(){EI(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;mI.forEach(t.nodes(),(function(n){var r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=mI.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){mI.forEach(t.nodes(),(function(e){var n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){bI.run(t)})),e(" parentDummyChains",(function(){wI(t)})),e(" addBorderSegments",(function(){SI(t)})),e(" order",(function(){OI(t)})),e(" insertSelfEdges",(function(){!function(t){var e=CI.buildLayerMatrix(t);mI.forEach(e,(function(e){var n=0;mI.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,mI.forEach(i.selfEdges,(function(e){CI.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")})),delete i.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){NI.adjust(t)})),e(" position",(function(){TI(t)})),e(" positionSelfEdges",(function(){!function(t){mI.forEach(t.nodes(),(function(e){var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,o=r.y,a=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{x:i+a,y:o},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){mI.forEach(t.nodes(),(function(e){if(t.children(e).length){var n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),o=t.node(mI.last(n.borderLeft)),a=t.node(mI.last(n.borderRight));n.width=Math.abs(a.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}})),mI.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){bI.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);if(mI.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){NI.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=t.graph(),a=o.marginx||0,s=o.marginy||0;function l(t){var o=t.x,a=t.y,s=t.width,l=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-l/2),i=Math.max(i,a+l/2)}mI.forEach(t.nodes(),(function(e){l(t.node(e))})),mI.forEach(t.edges(),(function(e){var n=t.edge(e);mI.has(n,"x")&&l(n)})),e-=a,r-=s,mI.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),mI.forEach(t.edges(),(function(n){var i=t.edge(n);mI.forEach(i.points,(function(t){t.x-=e,t.y-=r})),mI.has(i,"x")&&(i.x-=e),mI.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n,r,i=t.edge(e),o=t.node(e.v),a=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=a,r=o),i.points.unshift(CI.intersectRect(o,n)),i.points.push(CI.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){yI.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){mI.forEach(t.nodes(),(function(n){var r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,e.children(n).length&&(r.width=i.width,r.height=i.height))})),mI.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,mI.has(i,"x")&&(r.x=i.x,r.y=i.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var RI=["nodesep","edgesep","ranksep","marginx","marginy"],DI={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},LI=["acyclicer","ranker","rankdir","align"],_I=["width","height"],II={width:0,height:0},jI=["minlen","weight","width","height","labeloffset"],BI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},FI=["labelpos"];function zI(t,e){return mI.mapValues(mI.pick(t,e),Number)}function GI(t){var e={};return mI.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var VI=dL,WI=CL,HI=ZD.Graph,UI={debugOrdering:function(t){var e=WI.buildLayerMatrix(t),n=new HI({compound:!0,multigraph:!0}).setGraph({});return VI.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),VI.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),VI.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),VI.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var $I={graphlib:ZD,layout:PI,debug:UI,util:{time:CL.time,notime:CL.notime},version:"0.8.5"},YI=E($I);class qI{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,qI.defaultOptions,t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new $I.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>ae(t)))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach((t=>{const{id:e}=t,n=Object.assign({},t.data);if(void 0!==r){const[e,i]=db(Ut(r)?r(t):r);Object.assign(n,{width:e,height:i})}i.setNode(e.toString(),n)})),e.getAllEdges().forEach((({id:t,source:e,target:n})=>{i.setEdge(e.toString(),n.toString(),{id:t})})),YI.layout(i);const o={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);o.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:a}=r,s=Fe(r,["id"]),{v:l,w:u}=n;o.edges.push({id:a,source:l,target:u,data:s}),t&&e.mergeEdgeData(a,s)})),o}))}}qI.defaultOptions={};class XI{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 XI({rx:n,ry:r,mass:e,degree:i})}}class KI{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 KI({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 KI({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 KI({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 KI({xmid:t,ymid:e,length:n})}}class ZI{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 ZI(this.quad.NW()),this.NE=new ZI(this.quad.NE()),this.SW=new ZI(this.quad.SW()),this.SE=new ZI(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)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}const QI={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class JI{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},QI),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:l,maxIteration:u,nodeSize:c,center:h}=o;if(!(null==i?void 0:i.length)||1===i.length)return bb(e,t,h);const d=i.map((t=>hb(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Yg({nodes:d,edges:f}),g=this.getSizes(p,c);if(this.run(p,e,u,g,t,o),l){for(let t=0;t<f.length;t+=1){const{source:e,target:n}=f[t],r=p.getDegree(e),i=p.getDegree(e);if(r<=1){const t=p.getNode(n);p.mergeNodeData(e,{x:t.data.x,y:t.data.y})}else if(i<=1){const t=p.getNode(e);p.mergeNodeData(n,{x:t.data.x,y:t.data.y})}}const n=Object.assign(Object.assign({},o),{prune:!1,barnesHut:!1});this.run(p,e,100,g,t,n)}return{nodes:d,edges:r}}))}getSizes(t,e){const n=t.getAllNodes(),r={};for(let t=0;t<n.length;t+=1){const i=n[t];r[i.id]=gb(e,void 0)(i)}return r}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:l,kr:u,kg:c}=n;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=o||"undefined"==typeof window?o:window.innerHeight,n.center=r||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===s&&e>100&&(n.prune=!0),0!==l||s?0===l&&s&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),u||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:l}=o,u=t.getAllNodes();let c=0,h=n;const d={},f={},p={};for(let e=0;e<u.length;e+=1){const{data:n,id:r}=u[e];if(d[r]=[0,0],s){const i={id:e,rx:n.x,ry:n.y,mass:1,g:a,degree:t.getDegree(r)};p[r]=new XI(i)}}for(;h>0;)c=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:c,forces:d,preForces:f,bodies:p,sizes:r},o),h--,null==l||l({nodes:u,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:l,sizes:u}=e;let{forces:c}=e;const{preventOverlap:h,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...c[e]],c[e]=[0,0]}return c=this.getAttrForces(t,r,i,u,c,n),c=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,c,l,n):this.getRepGraForces(t,r,i,c,o,u,n),this.updatePos(t,c,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:l,prune:u}=o,c=t.getAllEdges();for(let o=0;o<c.length;o+=1){const{source:h,target:d}=c[o],f=t.getNode(h),p=t.getNode(d),g=t.getDegree(h),v=t.getDegree(d);if(u&&(g<=1||v<=1))continue;const m=[p.data.x-f.data.x,p.data.y-f.data.y];let y=Math.hypot(m[0],m[1]);y=y<1e-4?1e-4:y,m[0]=m[0]/y,m[1]=m[1]/y,a&&e<n&&(y=y-r[h]-r[d]);let b=y,x=b;"linlog"===l&&(b=Math.log(1+y),x=b),s&&(b=y/g,x=y/v),a&&e<n&&y<=0?(b=0,x=0):a&&e<n&&y>0&&(b=y,x=y),i[h][0]+=b*m[0],i[d][0]-=x*m[0],i[h][1]+=b*m[1],i[d][1]-=x*m[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),l=s.length;let u=9e10,c=-9e10,h=9e10,d=-9e10;for(let e=0;e<l;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=c&&(c=i.x),i.x<=u&&(u=i.x),i.y>=d&&(d=i.y),i.y<=h&&(h=i.y))}const f=Math.max(c-u,d-h),p=new KI({xmid:(c+u)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:l}),g=new ZI(p);for(let e=0;e<l;e+=1){const{id:r}=s[e];a&&t.getDegree(r)<=1||n[r].in(p)&&g.insert(n[r])}for(let r=0;r<l;r+=1){const{id:l,data:u}=s[r],c=t.getDegree(l);if(a&&c<=1)continue;n[l].resetForce(),g.updateForce(n[l]),e[l][0]-=n[l].fx,e[l][1]-=n[l].fy;const h=[u.x-o[0],u.y-o[1]];let d=Math.hypot(h[0],h[1]);d=d<1e-4?1e-4:d,h[0]=h[0]/d,h[1]=h[1]/d;const f=i*(c+1);e[l][0]-=f*h[0],e[l][1]-=f*h[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:l,kg:u,center:c,prune:h}=a,d=t.getAllNodes(),f=d.length;for(let a=0;a<f;a+=1){const p=d[a],g=t.getDegree(p.id);for(let u=a+1;u<f;u+=1){const a=d[u],c=t.getDegree(a.id);if(h&&(g<=1||c<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let v=Math.hypot(f[0],f[1]);v=v<1e-4?1e-4:v,f[0]=f[0]/v,f[1]=f[1]/v,s&&e<n&&(v=v-o[p.id]-o[a.id]);let m=l*(g+1)*(c+1)/v;s&&e<n&&v<0?m=i*(g+1)*(c+1):s&&e<n&&0===v?m=0:s&&e<n&&v>0&&(m=l*(g+1)*(c+1)/v),r[p.id][0]-=m*f[0],r[a.id][0]+=m*f[0],r[p.id][1]-=m*f[1],r[a.id][1]+=m*f[1]}const v=[p.data.x-c[0],p.data.y-c[1]],m=Math.hypot(v[0],v[1]);v[0]=v[0]/m,v[1]=v[1]/m;const y=u*(g+1);r[p.id][0]-=y*v[0],r[p.id][1]-=y*v[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:l}=i,u=t.getAllNodes(),c=u.length,h=[],d=[];let f=0,p=0,g=r;for(let r=0;r<c;r+=1){const{id:i}=u[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],l=Math.hypot(a[0],a[1]),c=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(c[0],c[1]);h[r]=l,d[r]=g/2,f+=(o+1)*h[r],p+=(o+1)*d[r]}const v=g;g=a*p/f,0!==v&&(g=g>1.5*v?1.5*v:g);for(let n=0;n<c;n+=1){const{id:r,data:i}=u[n],a=t.getDegree(r);if(s&&a<=1)continue;if(ae(i.fx)&&ae(i.fy))continue;let c=o*g/(1+g*Math.sqrt(h[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=l/d;c=c>f?f:c;const p=c*e[r][0],v=c*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+v})}return g}}const tj={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};class ej{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},tj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericFruchtermanLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;e<t;e++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericFruchtermanLayout(t,e,n){return ze(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:l,nodeClusterBy:u,maxIteration:c,onTick:h}=r,d=e.getAllNodes(),f=e.getAllEdges();if(!(null==d?void 0:d.length)){const t={nodes:[],edges:f};return this.lastResult=t,t}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0});const n={nodes:[Object.assign(Object.assign({},d[0]),{data:Object.assign(Object.assign({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:f};return this.lastResult=n,n}const p=d.map((t=>hb(t,[o,a]))),g=new Yg({nodes:p,edges:f}),v={};if(l&&p.forEach((t=>{const e=t.data[u];v[e]||(v[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=p,this.lastLayoutEdges=f,this.lastAssign=t,this.lastGraph=g,this.lastOptions=r,this.lastClusterMap=v,"undefined"==typeof window)return;let m=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,v,r),t&&p.forEach((({id:t,data:n})=>e.mergeNodeData(t,{x:n.x,y:n.y,z:3===i?n.z:void 0}))),null==h||h({nodes:p,edges:f}),m++,m>=c&&(window.clearInterval(this.timeInterval),n({nodes:p,edges:f}))):n({nodes:p,edges:f})}),0),this.running=!0}))}))}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:n,nodeClusterBy:r}=e,{center:i,width:o,height:a}=e;return e.width=o||"undefined"==typeof window?o:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!r,e}runOneStep(t,e,n){const{dimensions:r,height:i,width:o,gravity:a,center:s,speed:l,clustering:u,nodeClusterBy:c,clusterGravity:h}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),v=Math.sqrt(g),m={};if(this.applyCalculate(t,m,v,g),u){for(const t in e)e[t].cx=0,e[t].cy=0,e[t].count=0;p.forEach((t=>{const{data:n}=t,r=e[n[c]];ae(n.x)&&(r.cx+=n.x),ae(n.y)&&(r.cy+=n.y),r.count++}));for(const t in e)e[t].cx/=e[t].count,e[t].cy/=e[t].count;const t=h||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!ae(o.x)||!ae(o.y))return;const a=e[o[c]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),l=v*t;m[i].x-=l*(o.x-a.cx)/s,m[i].y-=l*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!ae(i.x)||!ae(i.y))return;const o=.01*v*a;m[n].x-=o*(i.x-s[0]),m[n].y-=o*(i.y-s[1]),3===r&&(m[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if(ae(o.fx)&&ae(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!ae(o.x)||!ae(o.y))return;const a=Math.sqrt(m[i].x*m[i].x+m[i].y*m[i].y+(3===r?m[i].z*m[i].z:0));if(a>0){const e=Math.min(f*(l/800),a);t.mergeNodeData(i,{x:o.x+m[i].x/a*e,y:o.y+m[i].y/a*e,z:3===r?o.z+m[i].z/a*e:void 0})}}))}applyCalculate(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)}calRepulsive(t,e,n){const r=t.getAllNodes();r.forEach((({data:t,id:i},o)=>{e[i]={x:0,y:0,z:0},r.forEach((({data:r,id:a},s)=>{if(o<=s||!ae(t.x)||!ae(r.x)||!ae(t.y)||!ae(r.y))return;let l=t.x-r.x,u=t.y-r.y,c=3===this.options.dimensions?t.z-r.z:0,h=l*l+u*u+c*c;0===h&&(h=1,l=.01,u=.01,c=.01);const d=n/h,f=l*d,p=u*d,g=c*d;e[i].x+=f,e[i].y+=p,e[a].x-=f,e[a].y-=p,3===this.options.dimensions&&(e[i].z+=g,e[a].z-=g)}))}))}calAttractive(t,e,n){t.getAllEdges().forEach((r=>{const{source:i,target:o}=r;if(!i||!o||i===o)return;const{data:a}=t.getNode(i),{data:s}=t.getNode(o);if(!(ae(s.x)&&ae(a.x)&&ae(s.y)&&ae(a.y)))return;const l=s.x-a.x,u=s.y-a.y,c=3===this.options.dimensions?s.z-a.z:0,h=Math.sqrt(l*l+u*u+c*c)/n,d=l*h,f=u*h,p=c*h;e[i].x+=d,e[i].y+=f,e[o].x-=d,e[o].y-=f,3===this.options.dimensions&&(e[i].z+=p,e[o].z-=p)}))}}const nj={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300};class rj{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},nj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{begin:i=[0,0],condense:o,preventOverlapPadding:a,preventOverlap:s,rows:l,cols:u,nodeSpacing:c,nodeSize:h,width:d,height:f,position:p}=r;let{sortBy:g}=r;const v=e.getAllNodes(),m=e.getAllEdges(),y=null==v?void 0:v.length;if(!y||1===y)return bb(e,t,i);const b=v.map((t=>hb(t)));"id"===g||ne(g)&&void 0!==b[0].data[g]||(g="degree"),"degree"===g?b.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):"id"===g?b.sort(((t,e)=>ae(e.id)&&ae(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const x=d||"undefined"==typeof window?d:window.innerWidth,E=f||"undefined"==typeof window?f:window.innerHeight,w=y,k={rows:l,cols:u};if(null!=l&&null!=u)k.rows=l,k.cols=u;else if(null!=l&&null==u)k.rows=l,k.cols=Math.ceil(w/k.rows);else if(null==l&&null!=u)k.cols=u,k.rows=Math.ceil(w/k.cols);else{const t=Math.sqrt(w*E/x);k.rows=Math.round(t),k.cols=Math.round(x/E*t)}if(k.rows=Math.max(k.rows,1),k.cols=Math.max(k.cols,1),k.cols*k.rows>w){const t=ij(k),e=oj(k);(t-1)*e>=w?ij(k,t-1):(e-1)*t>=w&&oj(k,e-1)}else for(;k.cols*k.rows<w;){const t=ij(k),e=oj(k);(e+1)*t>=w?oj(k,e+1):ij(k,t+1)}let M=o?0:x/k.cols,S=o?0:E/k.rows;if(s||c){const t=fb(10,c),n=pb(30,h,!1);b.forEach((r=>{r.data.x&&r.data.y||(r.data.x=0,r.data.y=0);const i=e.getNode(r.id),[o,s]=db(n(i)||30),l=void 0!==t?t(r):a,u=o+l,c=s+l;M=Math.max(M,u),S=Math.max(S,c)}))}const N={},O={row:0,col:0},T={};for(let t=0;t<b.length;t++){const n=b[t];let r;if(p&&(r=p(e.getNode(n.id))),r&&(void 0!==r.row||void 0!==r.col)){const t={row:r.row,col:r.col};if(void 0===t.col)for(t.col=0;aj(N,t);)t.col++;else if(void 0===t.row)for(t.row=0;aj(N,t);)t.row++;T[n.id]=t,sj(N,t)}uj(n,i,M,S,T,k,O,N)}const C={nodes:b,edges:m};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),C}))}}const ij=(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},oj=(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},aj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,sj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,lj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},uj=(t,e,n,r,i,o,a,s)=>{let l,u;const c=i[t.id];if(c)l=c.col*n+n/2+e[0],u=c.row*r+r/2+e[1];else{for(;aj(s,a);)lj(o,a);l=a.col*n+n/2+e[0],u=a.row*r+r/2+e[1],sj(s,a),lj(o,a)}t.data.x=l,t.data.y=u},cj={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},hj=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,l)=>{if(s===l)return;if(i[s]!==i[l])return;let u=a.x-e.x,c=a.y-e.y,h=Math.sqrt(u*u+c*c);if(0===h){h=1;const t=s>l?1:-1;u=.01*t,c=.01*t}if(h<o(t[s])/2+o(t[l])/2){const t=r*r/h;n[s].x+=u/h*t,n[s].y+=c/h*t}}))}))},dj=(t,e,n,r,i,o,a,s)=>{const l=o||a/10;return r&&e.forEach(((e,n)=>{const r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o);let s=o/a,l=-r/a;const u=Math.sqrt(e.x*e.x+e.y*e.y);let c=Math.acos((s*e.x+l*e.y)/u);c>Math.PI/2&&(c-=Math.PI/2,s*=-1,l*=-1);const h=Math.cos(c)*u;e.x=s*h,e.y=l*h})),t.forEach(((o,a)=>{if(a===i)return;const u=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(u>0&&a!==i){const c=Math.min(l*(n/800),u);if(o.x+=e[a].x/u*c,o.y+=e[a].y/u*c,r){let e=o.x-t[i].x,n=o.y-t[i].y;const r=Math.sqrt(e*e+n*n);e=e/r*s[a],n=n/r*s[a],o.x=t[i].x+e,o.y=t[i].y+n}}})),t},fj={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class pj{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},fj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:l,nodeSize:u,nodeSpacing:c,strictRadial:h,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:v=10,maxIteration:m=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,E=o||"undefined"==typeof window?o:window.innerHeight,w=a||[x/2,E/2];if(!(null==y?void 0:y.length)||1===y.length)return bb(e,t,w);let k=y[0];if(ne(s)){for(let t=0;t<y.length;t++)if(y[t].id===s){k=y[t];break}}else k=s||y[0];const M=mj(y,k.id),S=sb({nodes:y,edges:b}),N=ab(S),O=bj(N,M);yj(N,M,O+1);const T=N[M];let C=x-w[0]>w[0]?w[0]:x-w[0],A=E-w[1]>w[1]?w[1]:E-w[1];0===C&&(C=x/2),0===A&&(A=E/2);const P=Math.min(C,A),R=Math.max(...T),D=[],L=l||P/R;T.forEach(((t,e)=>{D[e]=t*L}));const _=gj(y,N,g,D,L,p,v),I=vj(_),j=((t,e,n)=>{try{const n=$x.mul($x.pow(e,2),-.5),r=n.mean("row"),i=n.mean("column"),o=n.mean();n.add(o).subRowVector(r).subColumnVector(i);const a=new Yx(n),s=$x.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>$x.mul([e],[s]).toJSON()[0].splice(0,t)))}catch(t){const r=[];for(let t=0;t<e.length;t++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}})(g,_,g);let B,F=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[M][0],y:(isNaN(e)?Math.random()*g:e)-j[M][1]})));if(this.run(m,F,I,_,D,M),d){B=gb(u,c);const t={nodes:y,nodeSizeFunc:B,positions:F,radii:D,height:E,width:x,strictRadial:Boolean(h),focusIdx:M,iterations:f||200,k:F.length/4.5};F=((t,e)=>{const n=Object.assign(Object.assign({},cj),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:l,focusIdx:u,radii:c=[],nodeSizeFunc:h}=n,d=t.getAllNodes(),f=[],p=o/10;for(let t=0;t<i;t++)r.forEach(((t,e)=>{f[e]={x:0,y:0}})),hj(d,r,f,a,c,h),dj(r,f,s,l,u,p,o,c);return r})(e,t)}const z=[];F.forEach(((t,e)=>{const n=hb(y[e]);n.data.x=t.x+w[0],n.data.y=t.y+w[1],z.push(n)})),t&&z.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:z,edges:b}}))}run(t,e,n,r,i,o){for(let a=0;a<=t;a++){const s=a/t;this.oneIteration(s,e,i,r,n,o)}}oneIteration(t,e,n,r,i,o){const a=1-t;e.forEach(((s,l)=>{const u=lb(s,{x:0,y:0}),c=0===u?0:1/u;if(l===o)return;let h=0,d=0,f=0;e.forEach(((t,e)=>{if(l===e)return;const n=lb(s,t),o=0===n?0:1/n,a=r[e][l];f+=i[l][e],h+=i[l][e]*(t.x+a*(s.x-t.x)*o),d+=i[l][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[l]?0:1/n[l];f*=a,f+=t*p*p,h*=a,h+=t*p*s.x*c,s.x=h/f,d*=a,d+=t*p*s.y*c,s.y=d/f}))}}const gj=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];if(e){const l={};e.forEach(((e,u)=>{const c=[];e.forEach(((e,s)=>{var h,d;if(u===s)c.push(0);else if(r[u]===r[s])if("data"===o)c.push(e*(Math.abs(u-s)*a)/(r[u]/i));else if(o){let n,f;if(l[t[u].id])n=l[t[u].id];else{const e=("id"===o?t[u].id:null===(h=t[u].data)||void 0===h?void 0:h[o])||0;n=ne(e)?e.charCodeAt(0):e,l[t[u].id]=n}if(l[t[s].id])f=l[t[s].id];else{const e=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=ne(e)?e.charCodeAt(0):e,l[t[s].id]=f}c.push(e*(Math.abs(n-f)*a)/(r[u]/i))}else c.push(e*n/(r[u]/i));else{const t=(n+i)/2;c.push(e*t)}})),s.push(c)}))}return s},vj=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},mj=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},yj=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},bj=(t,e)=>{let n=0;for(let r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},xj={center:[0,0],width:300,height:300};class Ej{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},xj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a}=r,s=e.getAllNodes(),l=o||"undefined"==typeof window?o:window.innerWidth,u=a||"undefined"==typeof window?a:window.innerHeight,c=i||[l/2,u/2],h=[];s&&s.forEach((t=>{h.push({id:t.id,data:{x:.9*(Math.random()-.5)*l+c[0],y:.9*(Math.random()-.5)*u+c[1]}})})),t&&h.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:h,edges:e.getAllEdges()}}))}}
66
+ */class Np extends nf{constructor(t){super(Object.assign(Object.assign({},t),{style:Object.assign({},Np.defaultStyleProps,t.style)})),this.rootPointerEvent=new As(null),this.forwardEvents=t=>{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);Te(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=Ae(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Fe(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",Xl,{x:r,y:i,width:o,height:a,opacity:0},e);return this.upsert("key",Fl,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof Sp))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;e<t.changedTouches.length;e++){const r=t.changedTouches[e];ve(r.button)&&(r.button=0),ve(r.buttons)&&(r.buttons=1),ve(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),ve(r.width)&&(r.width=r.radiusX||1),ve(r.height)&&(r.height=r.radiusY||1),ve(r.tiltX)&&(r.tiltX=0),ve(r.tiltY)&&(r.tiltY=0),ve(r.pointerType)&&(r.pointerType="touch"),ve(r.pointerId)&&(r.pointerId=r.identifier||0),ve(r.pressure)&&(r.pressure=r.force||.5),ve(r.twist)&&(r.twist=0),ve(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;ve(e.isPrimary)&&(e.isPrimary=!0),ve(e.width)&&(e.width=1),ve(e.height)&&(e.height=1),ve(e.tiltX)&&(e.tiltX=0),ve(e.tiltY)&&(e.tiltY=0),ve(e.pointerType)&&(e.pointerType="mouse"),ve(e.pointerId)&&(e.pointerId=1),ve(e.pressure)&&(e.pressure=.5),ve(e.twist)&&(e.twist=0),ve(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.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}bootstrapEvent(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);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const[a,s]=this.context.canvas.getCanvasByViewport([i,o]);return t.canvas.x=a,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:a}=t;if($t(r)||$t(i)){const t=this.eventService.client2Viewport({x:o,y:a});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}onframe(){super.onframe();const{opacity:t}=this.attributes;this.getDomElement().style.opacity=`${t}`}}Np.defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};let Op=class t extends nf{constructor(e){super(_d({style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),r=super.getKeyStyle(t),{fillOpacity:i,opacity:o=i}=r,a=Fe(r,["fillOpacity","opacity"]);return Object.assign(Object.assign({opacity:o},a),{width:e,height:n,x:-e/2,y:-n/2})}getBounds(){return this.getShape("key").getBounds()}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getShape("key").attributes,{fill:n,stroke:r}=e;Fe(e,["fill","stroke"]);const i=Ad(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=Ih(this.getSize(t),[o,o]),{lineWidth:l}=i,u={fill:"transparent",lineWidth:l/2,width:a-l/2,height:s-l/2,x:-(a-l/2)/2,y:-(s-l/2)/2};return Object.assign(Object.assign({},i),u)}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&Object.assign({width:n*xd,height:r*xd},e)}drawKeyShape(t,e){const n=this.upsert("key",Xd,this.getKeyStyle(t),e);return Qd(this),n}drawHaloShape(t,e){this.upsert("halo",Xl,this.getHaloStyle(t),e)}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Jd(this)}};Op.defaultStyleProps={size:32};class Tp extends nf{constructor(t){super(t)}getKeyStyle(t){const[e,n]=this.getSize(t);return Object.assign(Object.assign({},super.getKeyStyle(t)),{width:e,height:n,x:-e/2,y:-n/2})}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getShape("key").attributes;return!!e&&Object.assign({width:n*xd,height:r*xd},e)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}}class Cp extends of{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*xd;return!!e&&Object.assign({width:n,height:n},e)}getPortXY(t,e){const{placement:n="top"}=e;return Ng(this.getShape("key").getLocalBounds(),n,function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t)),!1)}}class Ap extends of{constructor(t){super(_d({style:Ap.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getShape("key").getLocalBounds(),[o,a]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,a,n);return Ng(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||Se(n||r))return!1;const o=Ad(this.getGraphicStyle(t),"icon"),a=this.getShape("key").getLocalBounds(),[s,l]=function(t,e){const{center:n}=t,[r,i]=Xc(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(a,i),u=2*function(t,e){let[n,r]=Xc(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(Math.pow(r,2)-Math.pow(Math.sqrt(Math.pow(n/2,2)+Math.pow(r,2))-n/2,2))/(2*r)}(a,i)*xd;return Object.assign({x:s,y:l,width:u,height:u},o)}}Ap.defaultStyleProps={size:40,direction:"up"};class Pp extends nf{constructor(t){super(_d({style:Pp.defaultStyleProps},t)),this.type="combo",this.updateComboPosition(this.parsedAttributes)}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,a]=Uc(e);return Ih(Dd(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Dd(t.collapsedSize)}getExpandedKeySize(t){const e=this.getContentBBox(t);return[Yc(e),qc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=e.map((t=>this.context.element.getElement(t))).filter(Boolean);if(0===r.length){const e=new fr,{x:n=0,y:r=0,size:i}=t,[o,a]=Dd(i);return e.setMinMax([n-o/2,r-a/2,0],[n+o/2,r+a/2,0]),e}const i=Jc(r.map((t=>t.getBounds())));return n?Qc(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",tf,n,e),Qd(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Ad(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Fe(e,["type"]),i=this.getShape("key"),[o,a]=ed(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(yh(t)))).length.toString():Ut(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(yh(e))));if(r.length>0&&r.some(td)){return Fh(r.reduce(((t,e)=>Ih(t,Jh(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}}),Jd(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 Fe(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}}Pp.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Rp extends Pp{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Dl,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&&Ad(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=Dd(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=Xc(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}}class Dp extends Pp{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Xl,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&&Ad(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const Lp={padding:10};function _p(t,e,n,r,i,o){const{padding:a}=Object.assign(Lp,o),s=Kc(n,a),l=Kc(r,a),u=[t,...i,e];let c=null;const h=[];for(let t=0,e=u.length;t<e-1;t++){const n=t+1,r=u[t],i=u[n],o=ad(d=r,f=i)||function(t,e){return t[0]===e[0]}(d,f);let p=null;if(0===t)if(n===e-1)if(s.intersects(l))p=Hp(r,i,s,l);else if(nh(r,s)||nh(i,l))o||(p=Wp(r,i,s,l));else{const t=ih(r,s),e=ih(i,l);p=zp(t,e,Bp(t,e)),p.points.unshift(t),p.points.push(e)}else th(i,s)?p=Hp(r,i,s,Kc(i,a),c):o||(p=Gp(r,i,s));else n===e-1?th(r,l)?p=Hp(r,i,Kc(r,a),l,c):o||(p=Vp(r,i,l,c)):o||(p=zp(r,i,c));p?(h.push(...p.points),c=p.direction):c=Bp(r,i),n<e-1&&h.push(i)}var d,f;return h.map(Yh)}const Ip={N:"S",S:"N",W:"E",E:"W"},jp={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Bp(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function Fp(t,e){return"N"===e||"S"===e?qc(t):Yc(t)}function zp(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Bp(t,r),a=Bp(t,i),s=n?Ip[n]:null,l=o===n||o!==s&&a!==n?r:i;return{points:[l],direction:Bp(l,e)}}function Gp(t,e,n){if(nh(t,n)){const r=Up(t,e,n);return{points:[r],direction:Bp(r,e)}}{const r=ih(t,n),i=["left","right"].includes(rh(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:Bp(i,e)}}}function Vp(t,e,n,r){const i=nh(e,n)?e:ih(e,n),o=[[i[0],t[1]],[t[0],i[1]]],a=o.filter((t=>function(t,e){return!th(t,e)}(t,n)&&!eh(t,n,!0))),s=a.filter((e=>Bp(e,t)!==r));if(s.length>0){const n=s.find((e=>Bp(t,e)===r))||s[0];return{points:[n],direction:Bp(n,e)}}{const i=od(e,Ht(o,a)[0],Fp(n,r)/2);return{points:[Up(i,t,n),i],direction:Bp(i,e)}}}function Wp(t,e,n,r){let i=Gp(t,e,n);const o=qh(i.points[0]);if(th(o,r)){i=Gp(e,t,r);const a=qh(i.points[0]);if(th(a,n)){const s=od(t,o,Fp(n,Bp(t,o))/2),l=od(e,a,Fp(r,Bp(e,a))/2),u=[(s[0]+l[0])/2,(s[1]+l[1])/2],c=Gp(t,u,n),h=Vp(u,e,r,c.direction);i.points=[c.points[0],h.points[0]],i.direction=h.direction}}return i}function Hp(t,e,n,r,i){const o=Jc([n,r]),a=Gh(e,o.center)>Gh(t,o.center),[s,l]=a?[e,t]:[t,e],u=qc(o)+Yc(o);let c;if(i){const t=[s[0]+u*Math.cos(jp[i]),s[1]+u*Math.sin(jp[i])];c=od(ih(t,o),t,.01)}else c=od(ih(s,o),s,-.01);let h=Up(c,l,o),d=[id(c,2),id(h,2)];if(Ne(id(c),id(h))){const t=Hh(jh(c,s),[1,0,0])+Math.PI/2;h=[l[0]+u*Math.cos(t),l[1]+u*Math.sin(t),0],h=id(od(ih(h,o),l,-.01),2);d=[c,Up(c,h,o),h]}return{points:a?d.reverse():d,direction:Bp(a?c:h,e)}}function Up(t,e,n){let r=[t[0],e[1]];return th(r,n)&&(r=[e[0],t[1]]),r}function $p(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=nd(t.getPoint(o)),s=nd(t.getPoint(o+.01));let l="start"===e?"left":"end"===e?"right":"center";if(ad(a,s)||!n){const[e,n]=Yp(t,o,r,i);return{transform:[["translate",e,n]],textAlign:l}}let u=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(l="center"===l?l:"left"===l?"right":"left",r*=-1,u+=Math.PI);const[c,h]=Yp(t,o,r,i,u);return{textAlign:l,transform:[["translate",c,h],["rotate",u/Math.PI*180]]}}function Yp(t,e,n,r,i){const[o,a]=nd(t.getPoint(e));let s=n,l=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),l=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+l]}function qp(t,e,n,r){if(Ne(t,e))return t;const i=jh(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=Wh(Uh(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Xp(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function Kp(t,e=0,n=!1){const r=t.length-1,i=t[0],o=t[r],a=t.slice(1,r),s=[["M",i[0],i[1]]];return a.forEach(((t,n)=>{const r=a[n-1]||i,l=a[n+1]||o;if(!sd(r,t,l)&&e){const[n,i]=function(t,e,n,r){const i=Vh(t,e),o=Vh(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])],l=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,l]}(r,t,l,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 Zp(t,e,n,r,i){const o=Kc(t),a=t.getCenter();let s=r&&Cg(r),l=i&&Cg(i);if(!s||!l){const r=(t=>{const e=Math.PI/2,n=qc(t)/2,r=Yc(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],u=r[e][1],[c,h]=Xc(o),d=Math.max(c,h),f=Ih(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Ih(a,[d*Math.cos(u),d*Math.sin(u),0]);s=Dg(t,f),l=Dg(t,p),n||([s,l]=[l,s])}return[s,l]}function Qp(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[l,u]=Zp(t,e,n,a,s);const c=function(t,e,n,r){const i=t.getCenter();if(Ne(e,n)){const t=jh(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Ih(e,o),Ih(n,Bh(o,[1,-1,1]))]}return[od(i,e,Gh(i,e)+r),od(i,n,Gh(i,n)+r)]}(t,l,u,r);return a&&(l=Rg(a,c[0])),s&&(u=Rg(s,c.at(-1))),Xp(l,u,c)}function Jp(t,e,n,r,i,o,a){const s=Og(t),l=s[o||a],u=s[a||o];let[c,h]=Zp(t,n,r,l,u);const d=function(t,e,n,r){const i=[],o=Kc(t);if(Ne(e,n)){switch(rh(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=rh(e,o),a=rh(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]),l=s(t,e),u=s(a,n),c=Up(l,u,o);i.push(l,c,u)}}return i}(t,c,h,i);return l&&(c=Rg(l,d[0])),u&&(h=Rg(u,d.at(-1))),Kp([c,...d,h],e)}function tg(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 eg(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(yh(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(Od);return n[t]||n.at(-1)}return t}const ng=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var rg=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:ng,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 ig extends ef{constructor(t){super(_d({style:ig.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=Fe(e,["loop"]),{sourceNode:i,targetNode:o}=this;var a,s;const l={d:n&&(s=o,(a=i)&&s&&a===s)?this.getLoopPath(t):this.getKeyPath(t)};return Hl.PARSED_STYLE_LIST.forEach((t=>{t in r&&(l[t]=r[t])})),l}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=Kc(r),o=Math.max(Yc(i),qc(i)),{placement:a,clockwise:s,dist:l=o}=Ad(this.getGraphicStyle(t),"loop");return Qp(r,a,s,l,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:a}=this,[s,l]=function(t,e,n,r){const i=Ag(t,e,n,r),o=Ag(e,t,r,n);return[i,o]}(o,a,r,i);if(!e){return[s?Cg(s):o.getCenter(),l?Cg(l):a.getCenter()]}const u="function"==typeof n?n():n;return[Pg(s||o,u[0]||l||a),Pg(l||a,u[u.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Ad(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a}=e,s=Fe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),l=$p(this.shapeMap.key,n,o,r,i),u=this.shapeMap.key.getLocalBounds(),c=function(t,e,n=1){return Bd(Gh(t[0],t[1])*n,e)}([u.min,u.max],a);return Object.assign({wordWrapWidth:c},l,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Ad(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Fe(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,l=2*(null===(a=t.label)||void 0===a?void 0:a.getGeometryBounds().halfExtents[0])||0;return $p(t.key,n,!0,(l?(l/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?zl:Hl)({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=Ad(this.getGraphicStyle(t),r),{size:o,type:a}=i,s=Fe(i,["size","type"]),[l,u]=Dd(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),c=(Ut(a)?a:rg[a]||ng)(l,u);return Object.assign(Ae(n,["stroke","strokeOpacity","fillOpacity"]),{width:l,height:u},Object.assign({},c&&{d:c,fill:"simple"===a?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Wd,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",Hl,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",Hd,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",Hl,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}}ig.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 og extends ig{constructor(t){super(_d({style:og.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 ae(t)?[t,1-t]:t}(i),function(t){return ae(t)?[t,-t]:t}(o),r);return Xp(e,n,a)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[qp(t,e,n[0],r[0]),qp(t,e,n[1],r[1])]}}og.defaultStyleProps={curvePosition:.5,curveOffset:20};class ag extends og{constructor(t){super(_d({style:ag.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]]]}}ag.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class sg extends og{constructor(t){super(_d({style:sg.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=Jh(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=Jh(this.ref);return[Gh(t,e),Xh(jh(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)]]}}sg.defaultStyleProps={curvePosition:.5,curveOffset:20};class lg extends og{constructor(t){super(_d({style:lg.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]]]}}lg.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let ug=class t extends ig{constructor(e){super(_d({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};ug.defaultStyleProps={};const cg={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:Vh},hg=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function dg(t,e){const n=t=>Math.round(t/e);return ae(t)?n(t):t.map(n)}function fg(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function pg(t,e,n,r){const i=fg(t,e),o=n[hg(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(fg(o||r,t),i)}function gg(t,e,n){return Math.min(...e.map((e=>n(t,e))))}const vg=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,a=Qc(e.getRenderBounds(),o),s=Object.keys(i).reduce(((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=Xc(a),l=[t[0]+n.stepX*o,t[1]+n.stepY*s],u=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],a=[r,i],s=[r,n],l=[e,n];return[[o,a],[a,s],[s,l],[l,o]]}(a);for(let n=0;n<u.length;n++){const r=Zh([t,l],u[n]);r&&eh(r,a)&&e.push(r)}}return e}),[]);return th(t,a)||s.push(t),s.map((t=>dg(t,r.gridSize)))},mg=(t,e,n,r,i,o,a)=>{const s=[];let l=[o[0]===r[0]?r[0]:t[0]*a,o[1]===r[1]?r[1]:t[1]*a];s.unshift(l);let u=t,c=e[hg(u)];for(;c;){const t=c,r=u;pg(t,r,e,n)&&(l=[t[0]===r[0]?l[0]:t[0]*a,t[1]===r[1]?l[1]:t[1]*a],s.unshift(l)),c=e[hg(t)],u=t}const h=i.map((t=>[t[0]*a,t[1]*a])),d=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o<t.length;o++){const a=t[o],s=n(a,e);s<i&&(r=a,i=s)}return r}(h,l,Vh);return s.unshift(d),s};function yg(t,e,n,r){const i=Yh(t.getCenter()),o=Yh(e.getCenter()),a=Object.assign(cg,r),{gridSize:s}=a,l=((t,e)=>{const{offset:n,gridSize:r}=e,i={};return t.forEach((t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Qc(t.getRenderBounds(),n);for(let t=dg(e.min[0],r);t<=dg(e.max[0],r);t+=1)for(let n=dg(e.min[1],r);n<=dg(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0})),i})(a.enableObstacleAvoidance?n:[t,e],a),u=dg(i,s),c=dg(o,s),h=vg(i,t,a.startDirections,a),d=vg(o,e,a.endDirections,a);h.forEach((t=>delete l[hg(t)])),d.forEach((t=>delete l[hg(t)]));const f={},p={},g={},v={},m={},y=new bg;for(let t=0;t<h.length;t++){const e=h[t],n=hg(e);f[n]=e,v[n]=0,m[n]=gg(e,d,a.distFunc),y.add({id:n,value:m[n]})}const b=d.map((t=>hg(t)));let x,E=a.maximumLoops,w=1/0;for(const[t,e]of Object.entries(f))m[t]<=w&&(w=m[t],x=e);for(;Object.keys(f).length>0&&E>0;){const t=y.minId(!1);if(!t)break;x=f[t];const e=hg(x);if(b.includes(e))return mg(x,g,u,o,h,c,s);delete f[e],y.remove(e),p[e]=!0;for(const t of Object.values(a.directionMap)){const n=Ih(x,[t.stepX,t.stepY]),r=hg(n);if(p[r])continue;const i=pg(x,n,g,u);if(i>a.maxAllowedDirectionChange)continue;if(l[r])continue;f[r]||(f[r]=n);const o=a.penalties[i],c=a.distFunc(x,n)+(isNaN(o)?s:o),h=v[e]+c,b=v[r];b&&h>=b||(g[r]=x,v[r]=h,m[r]=h+gg(n,d,a.distFunc),y.add({id:r,value:m[r]}))}E-=1}return[]}class bg{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<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n=e}}this.arr.splice(r,0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;if(!e||this.arr[e-1].value<t.value)return this.arr.push(t),void(this.map[t.id]=!0);this._innerAdd(t,e)}remove(t){this.map[t]&&delete this.map[t]}_clearAndGetMinId(){let t;for(let e=this.arr.length-1;e>=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 xg extends ig{constructor(t){super(_d({style:xg.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=yg(n,r,this.context.element.getNodes(),e),a.length||(a=_p(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(a=_p(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 Kp(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=Kc(i),a=Math.max(Yc(o),qc(o))/4,{placement:s,clockwise:l,dist:u=a}=Ad(this.getGraphicStyle(t),"loop");return Jp(i,r,s,l,u,e,n)}}xg.defaultStyleProps={radius:0,controlPoints:[],router:!1};class Eg extends ig{constructor(t){super(_d({style:Eg.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||qp(r,i,e,n))}}function wg(t){return t instanceof nf&&"node"===t.type}function kg(t){return t instanceof ig}function Mg(t){return t instanceof Pp}Eg.defaultStyleProps={curvePosition:.5,curveOffset:30};const Sg={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 Ng(t,e,n=Sg,r=!0){const i=[.5,.5],o=ne(e)?Oe(n,e.toLocaleLowerCase(),i):e;if(!r&&ne(e))return o;const[a,s]=o||i;return[t.min[0]+Yc(t)*a,t.min[1]+qc(t)*s]}function Og(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{var i;const{key:o,placement:a}=n;Tg(n)&&(e[i=o||r]||(e[i]=ed(t.getShape("key").getBounds(),a)))})),e}function Tg(t){const{r:e}=t;return!e||0===Number(e)}function Cg(t){return Wc(t)?t:t.getPosition()}function Ag(t,e,n,r){const i=Og(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Cg(t))),s=function(t,e){const n=Og(t);if(e)return[Cg(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Cg(t))):[t.getCenter()]}(e,r),[l]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=Gh(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Cg(t)===l))}function Pg(t,e){return Mg(t)||wg(t)?Dg(t,e):Rg(t,e)}function Rg(t,e){if(!t||!e)return[0,0,0];if(Wc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return cd(Wc(e)?e:wg(e)?e.getCenter():e.getPosition(),t.getBounds())}function Dg(t,e){if(!t||!e)return[0,0,0];const n=Wc(e)?e:wg(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function Lg(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[a,s]=ed(t,e),[l,u]=i?["bottom","top"]:["top","bottom"];return{transform:[["translate",a+n,s+r]],textBaseline:o.includes("top")?u:o.includes("bottom")?l:"middle",textAlign:o.includes("left")?"right":o.includes("right")?"left":"center"}}function _g(t,e){"update"in t?t.update(e):t.attr(e)}function Ig(t){return Oe(t,"__to_be_destroyed__",!1)}class jg extends Dh{constructor(t,e){super(t,Object.assign({},jg.defaultOptions,e)),this.onCollapseExpand=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{target:e}=t;if(!(wg(n=e)||kg(n)||Mg(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:l,animation:u,align:c}=this.options;Od(a)?(yield o.expandElement(r,{animation:u,align:c}),null==l||l(r)):(yield o.collapseElement(r,{animation:u,align:c}),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 Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}jg.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const Bg="g6-create-edge-assist-node-id";class Fg extends Dh{constructor(t,e){super(t,Object.assign({},Fg.defaultOptions,e)),this.drop=t=>ze(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=>ze(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:l}=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 u=i.getElementData(this.source);i.addNodeData([{id:Bg,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=u.style)||void 0===e?void 0:e.x,y:null===(n=u.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:Bg,style:Object.assign({pointerEvents:"none"},l)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished})),this.updateAssistEdge=t=>ze(this,void 0,void 0,(function*(){var e;if(!this.source)return;const{model:n,element:r}=this.context;n.translateNodeTo(Bg,[t.canvas.x,t.canvas.y]),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 l;const u=a({id:`${this.source}-${s}-${De[l=l||"g"]?De[l]+=1:De[l]=1,l+De[l]}`,source:this.source,target:s,style:i});r.addEdgeData([u]),o(u)},this.cancelEdge=()=>ze(this,void 0,void 0,(function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([Bg]),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 Ut(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()}}Fg.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class zg extends Dh{constructor(t,e){super(t,Object.assign({},zg.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||gd.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;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=ye((()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)}),300),this.shortcut=new md(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(qt(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 ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(Bh(t,r),this.options.animation),this.invokeOnFinish()}))}translate(t,e){return ze(this,void 0,void 0,(function*(){t=this.clampByDirection(t),t=this.clampByRange(t),yield this.context.graph.translateBy(t,e)}))}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,l,u]=Uc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[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()}}zg.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class Gg extends Dh{constructor(e,n){super(e,Object.assign({},Gg.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>ze(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,Ec);e&&yh(e)===i&&n.refreshComboData(i),n.setParent(t,i,Ec)})),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.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 Fh([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]=jh([+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=[]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}moveElement(t,e){return ze(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,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=Ad(this.options,"shadow"),n=Jc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Xc(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 Xl({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(yh):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(yh))).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()}}Gg.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),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 Vg=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<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],a=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var a=r[o],s=a.callback;a.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};a(i),a(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function Wg(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach((n=>{e.has(n.id)||(e.add(n.id),t.push(n))}))}return!1}function Hg(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)&&Hg(i,e,n,r))return!0;return!1}const Ug=()=>!0;class $g{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||Ug,n=t.edgeFilter||Ug;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];Wg([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];Hg(this.getNode(t),new Set,e,r)}}let Yg=class t extends Vg{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 Hg(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Wg([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 Wg([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 Hg(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 $g({graph:this,...t})}};class qg{constructor(t,e){this.context=t,this.options=e||{}}}function Xg(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(nd)}:{})})})),r}function Kg(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 Zg(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 Qg extends Gg{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):(Tc("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return ze(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&&Kg(n,"setFixedPosition",t[i],[...Ih([+o,+a],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&&Zg(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach((t=>{const{x:n=0,y:r=0}=t.style||{};e&&Kg(e,"setFixedPosition",yh(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&&Zg(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach((e=>{t&&Kg(t,"setFixedPosition",yh(e),[null,null,null])}))}}class Jg extends Dh{constructor(t,e){super(t,Object.assign({},Jg.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=>ze(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),l=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),u=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,c=[...a,...l];c.length>0&&c.forEach((t=>this.fixNodeLike(t,u))),this.updateRelatedEdges(),s.length>0&&s.forEach((t=>this.fixEdge(t,u)))})),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);ae(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=yh(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(yh(t))));const a=this.options[o.type];a?this.scaleSpecificShapes(o,e,a):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=yh(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=>ze(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(Se(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(yh(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 Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Jg.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 tv extends Dh{constructor(t,e){super(t,Object.assign({},tv.defaultOptions,e)),this.focus=t=>ze(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.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}destroy(){this.unbindEvents(),super.destroy()}}tv.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};class ev extends Dh{constructor(e,n){super(e,Object.assign({},ev.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=xh(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(),Ed.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?kd(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||Ig(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.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()}}ev.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class nv extends yd{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e}=this.context;this.pathShape=new Hl({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[bd(t)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(bd(t)),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 rv extends Dh{constructor(t,e){super(t,Object.assign({},rv.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):Ah(t,e,n):this.hiddenShapes.push(t)}))},this.filterShapes=(t,e)=>{if(Ut(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=ye((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 Ut(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}rv.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class iv extends Dh{constructor(t,e){super(t,Object.assign({},iv.defaultOptions,e)),this.onWheel=t=>ze(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 md(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),qt(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=Bh(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,l,u]=Uc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return ze(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 Ut(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()}}iv.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class ov extends Dh{constructor(t,e){super(t,Object.assign({},ov.defaultOptions,e)),this.zoom=(t,e,n)=>ze(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=nd(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+oe(t,-50,50)*o/100,l=r.getZoom();yield r.zoomTo(l*s,n,i),null==a||a()})),this.onReset=()=>ze(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 md(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 Ut(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()}}ov.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};var av={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},sv=av,lv={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function uv(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof uv)return t;n.data=t;var r=e.getHGap(t),i=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,i),n}sv.assign(uv.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(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:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}});var cv=function(t,e,n){void 0===e&&(e={});var r,i=new uv(t,e=sv.assign({},lv,e)),o=[i];if(!n&&!t.collapsed)for(;r=o.shift();)if(!r.data.collapsed){var a=e.getChildren(r.data),s=a?a.length:0;if(r.children=new Array(s),a&&s)for(var l=0;l<s;l++){var u=new uv(a[l],e);r.children[l]=u,o.push(u),u.parent=r,u.depth=r.depth+1}}return i},hv=cv,dv=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=hv(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),fv=dv;function pv(t,e,n,r){void 0===r&&(r=[]);var i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function gv(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){gv(t,e,n)}))}function vv(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(vv(t,e),n)})),n}function mv(t,e){gv(t,-vv(t,e),e)}function yv(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){yv(t,e.children[r],n)}))}function bv(t,e,n){void 0===n&&(n=0),e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach((function(t){bv(t,e,n)}))}pv.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(pv.fromNode(t,e))})),e?new pv(t.height,t.width,t.x,n):new pv(t.width,t.height,t.y,n)};var xv=cv,Ev=function(t,e){for(var n=xv(t.data,e,!0),r=xv(t.data,e,!0),i=t.children.length,o=Math.round(i/2),a=e.getSide||function(t,e){return e<o?"right":"left"},s=0;s<i;s++){var l=t.children[s];"right"===a(l,s)?r.children.push(l):n.children.push(l)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},wv=Ev,kv=["LR","RL","TB","BT","H","V"],Mv=["LR","RL","H"],Sv=kv[0],Nv=function(t,e,n){var r=e.direction||Sv;if(e.isHorizontal=function(t){return Mv.indexOf(t)>-1}(r),-1===kv.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===kv[0])n(t,e);else if(r===kv[1])n(t,e),t.right2left();else if(r===kv[2])n(t,e);else if(r===kv[3])n(t,e),t.bottom2top();else if(r===kv[4]||r===kv[5]){var i=wv(t,e),o=i.left,a=i.right;n(o,e),n(a,e),e.isHorizontal?o.right2left():o.bottom2top(),a.translate(o.x-a.x,o.y-a.y),t.x=o.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var l=e.fixedRoot;return void 0===l&&(l=!0),l&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){var n=e.isHorizontal?["x","y"]:["y","x"],r=n[0],i=n[1],o={x:1/0,y:1/0},a={x:-1/0,y:-1/0},s=0;t.DFTraverse((function(t){s++;var e=t.x,n=t.y;o.x=Math.min(o.x,e),o.y=Math.min(o.y,n),a.x=Math.max(a.x,e),a.y=Math.max(a.y,n)}));var l=a[i]-o[i];if(0===l)return;var u=2*Math.PI/s;t.DFTraverse((function(e){var n=(e[i]-o[i])/l*(2*Math.PI-u)+u,a=e[r]-t[r];e.x=Math.cos(n)*a,e.y=Math.sin(n)*a}))}}(t,e),t};function Ov(t,e){return Ov=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ov(t,e)}var Tv=function(t,e){void 0===e&&(e={});var 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){for(var r=t.c[e-1],i=r.mod,u=t.c[e],c=u.mod;null!==r&&null!==u;){l(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(c+u.prelim);h>0&&(c+=h,o(t,e,n.index,h));var d=l(r),f=l(u);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(u=a(u))&&(c+=u.mod)}!r&&u?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var 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,u,c):r&&!u&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var 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){var 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 l(t){return t.y+t.h}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}bv(t,n);var c=pv.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=u(l(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=l(e.c[o].er);i(e,o,n),n=u(a,o,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}else r(e)}(c),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)n+=(e+=t.c[r].shift)+t.c[r].change,t.c[r].mod+=n}(e);for(var r=0;r<e.cs;r++)t(e.c[r],n)}(c,0),yv(c,t,n),mv(t,n),t},Cv=Nv,Av=av,Pv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Ov(n,r),e.prototype.execute=function(){return Cv(this.rootNode,this.options,Tv)},e}(fv),Rv={};var Dv=function(t,e){return e=Av.assign({},Rv,e),new Pv(t,e).execute()},Lv=av;function _v(t,e){void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}var Iv={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function jv(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((function(t,r){jv(t,e.children[r],n)}))}function Bv(t,e){return Bv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Bv(t,e)}var Fv=function(t,e){void 0===e&&(e={}),e=Lv.assign({},Iv,e);var n,r=0;var i=function t(e){if(!e)return null;e.width=0,e.depth&&e.depth>r&&(r=e.depth);var n=e.children,i=n.length,o=new _v(e.height,[]);return n.forEach((function(e,n){var 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{var n=e.children.map((function(e){return t(e)})),i=Math.min.apply(null,n);e.drawingDepth=i-1}return e.drawingDepth}(i),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(i),jv(i,t,e.isHorizontal),t},zv=Nv,Gv=av,Vv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Bv(n,r),e.prototype.execute=function(){var t=this;return t.rootNode.width=0,zv(t.rootNode,t.options,Fv)},e}(fv),Wv={};var Hv=function(t,e){return e=Gv.assign({},Wv,e),new Vv(t,e).execute()},Uv=av;function $v(t,e){return $v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$v(t,e)}var Yv=fv,qv=function(t,e,n,r){var i=null;t.eachNode((function(t){!function(t,e,n,r,i){var o=("function"==typeof n?n(t):n)*t.depth;if(!r)try{if(t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch(t){}if(t.x+=o,e){if(t.y=e.y+Uv.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+Uv.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},Xv=Ev,Kv=av,Zv=["LR","RL","H"],Qv=Zv[0],Jv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,$v(n,r),e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,o=void 0===i||i,a=t.direction,s=void 0===a?Qv:a,l=t.align;if(s&&-1===Zv.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Zv[0])qv(e,r,o,l);else if(s===Zv[1])qv(e,r,o,l),e.right2left();else if(s===Zv[2]){var u=Xv(e,t),c=u.left,h=u.right;qv(c,r,o,l),c.right2left(),qv(h,r,o,l);var d=c.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},e}(Yv),tm={};var em=function(t,e){return e=Kv.assign({},tm,e),new Jv(t,e).execute()},nm=av;function rm(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=rm(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function im(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){im(t)}));var r=e[0],i=e[n-1],o=i.y-r.y+i.height,a=0;if(e.forEach((function(t){a+=t.totalHeight})),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>a){var s=t.y+(t.height-o)/2-r.y;e.forEach((function(t){t.translate(0,s)}))}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}var om={getSubTreeSep:function(){return 0}};function am(t,e){return am=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},am(t,e)}var sm=function(t,e){void 0===e&&(e={}),e=nm.assign({},om,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,rm(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var 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(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}})),im(t)},lm=Nv,um=av,cm=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,am(n,r),e.prototype.execute=function(){return lm(this.rootNode,this.options,sm)},e}(fv),hm={};var dm=function(t,e){return e=um.assign({},hm,e),new cm(t,e).execute()},fm={compactBox:Dv,dendrogram:Hv,indented:em,mindmap:dm};const pm=(t,e)=>{if("next"!==t&&"prev"!==t)return e},gm=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let vm=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 gm(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&gm(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,pm)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},mm=class extends vm{};const ym=()=>1,bm=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)xm(t,e,n,a);for(;a=i.dequeue();)xm(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(xm(t,e,n,a,!0));break}}return r},xm=(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,wm(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,wm(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},Em=(t,e)=>{const n=new Yg;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<a;t++)o.push(new mm);const s=r+1;return n.getAllNodes().forEach((t=>{wm(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},wm=(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)},km=(t,e)=>{const n=((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=Em(t,e||ym);return null===(n=bm(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)})}))},Mm=(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},Sm=t=>{const e=new Yg;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},Nm=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,l=Number(t.width)/2,u=Number(t.height)/2;return i||o?(Math.abs(o)*l>Math.abs(i)*u?(o<0&&(u=-u),a=u*i/o,s=u):(i<0&&(l=-l),a=l,s=l*o/i),{x:n+a,y:r+s}):{x:0,y:0}},Om=t=>{const e=[],n=Cm(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(let r=0;r<n;r++)e[r]=e[r].sort(((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},Tm=(t,e,n,r)=>{const i={width:0,height:0};return ae(n)&&ae(r)&&(i.rank=n,i.order=r),Mm(t,"border",i,e)},Cm=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},Am=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),Pm=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>Pm(t,e,n,r,i,o))),n&&o.push(e.id))},Rm=(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}`);Pm(t,e,"post"===n,s,o,a)})),a},Dm=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],l=Mm(t,"border",a,n);i.data[e][o]=l,t.setParent(l,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:l,data:{weight:1}})},Lm=t=>{t.getAllNodes().forEach((t=>{_m(t)})),t.getAllEdges().forEach((t=>{_m(t)}))},_m=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Im=t=>{t.getAllNodes().forEach((t=>{jm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>jm(t))),t.data.hasOwnProperty("y")&&jm(t.data)}))},jm=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},Bm=t=>{t.getAllNodes().forEach((t=>{Fm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Fm(t))),t.data.hasOwnProperty("x")&&Fm(t.data)}))},Fm=t=>{const e=t.x;t.x=t.y,t.y=e},zm=(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 l=Tm(t,"_bt"),u=Tm(t,"_bb"),c=t.getNode(a);t.setParent(l,a),c.data.borderTop=l,t.setParent(u,a),c.data.borderBottom=u,null==s||s.forEach((s=>{zm(t,e,n,r,i,o,s.id);const c=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=c!==h?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:h,target:u,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:l,data:{weight:0,minlen:i+o[a]}})},Gm=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},Vm=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Wm="edge-label",Hm=(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 l,u,c;for(t.removeEdge(e.id),c=0,++i;i<a;++c,++i)e.data.points=[],u={originalEdge:e,width:0,height:0,rank:i},l=Mm(t,"edge",u,"_d"),i===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=Wm,u.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:l,data:{weight:e.data.weight}}),0===c&&n.push(l),r=l;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},Um=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},$m=(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<n.length;)a<<=1;const s=2*a-1;a-=1;const l=Array(s).fill(0,0,s);let u=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;l[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=l[e+1]),e=e-1>>1,l[e]+=t.weight;u+=t.weight*n}})),u},Ym=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=$m(t,e[r-1],e[r]);return n},qm=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;t<i+1;t++)o.push([]);const a=n.sort(((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank)),s=a.filter((e=>void 0!==t.getNode(e.id).data.fixorder)).sort(((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder));return null==s||s.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},Xm=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)&&Km(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}))},Km=(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},Zm=(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},Qm=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i},Jm=(t,e,n,r,i,o)=>{var a,s,l,u;let c=t.getChildren(e).map((t=>t.id));const h=t.getNode(e),d=h?h.data.borderLeft:void 0,f=h?h.data.borderRight:void 0,p={};d&&(c=null==c?void 0:c.filter((t=>t!==d&&t!==f)));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,c||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=Jm(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&ey(e,i)}}));const v=((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 Xm(a)})(g,n);ty(v,p),null===(a=v.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 m=((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 l=0,u=0,c=0;null==o||o.sort(Qm(!!e,!!n)),c=Zm(s,a,c),null==o||o.forEach((t=>{var e;c+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,c=Zm(s,a,c)}));const h={vs:s.flat()};return u&&(h.barycenter=l/u,h.weight=u),h})(v,r,i,o);if(d&&(m.vs=[d,m.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(l=t.getPredecessors(d))||void 0===l?void 0:l[0].id)||""),n=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||"");m.hasOwnProperty("barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+e.data.order+n.data.order)/(m.weight+2),m.weight+=2}return m},ty=(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()}))},ey=(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)},ny=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Um(t),i=new Yg({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((o=>{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:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i})(t,e,n))),ry=(t,e,n,r)=>{const i=new Yg;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Jm(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)}))},iy=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},oy=(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 l=((t,e,n,r)=>{var i,o;const a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);let c,h;c=n;do{c=null===(i=t.getParent(c))||void 0===i?void 0:i.id,a.push(c)}while(c&&(e[c].low>l||u>e[c].lim));for(h=c,c=r;c&&c!==h;)s.push(c),c=null===(o=t.getParent(c))||void 0===o?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}})(t,n,s.source,s.target),u=l.path,c=l.lca;let h=0,d=u[h],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==c&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)h++,d=u[h];d===c&&(f=!1)}if(!f){for(;h<u.length-1&&(null===(i=t.getNode(u[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=u[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},ay=(t,e)=>{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,l;let u;for(let c=r;c<i;c++)u=e[c],(null===(s=t.getNode(u))||void 0===s?void 0:s.data.dummy)&&(null===(l=t.getPredecessors(u))||void 0===l||l.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&ly(n,e.id,u)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((l,u)=>{var c;if("border"===(null===(c=t.getNode(l))||void 0===c?void 0:c.data.dummy)){const e=t.getPredecessors(l)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,u,o,i],s),a=u,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},sy=(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))},ly=(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},uy=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},cy=(t,e,n,r,i,o)=>{const a=new Yg,s=hy(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],l=a.getRelatedEdges(o,"out").find((t=>t.target===i));l?a.updateEdgeData(l.id,Object.assign(Object.assign({},l.data),{weight:Math.max(s(t,e,r),l.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 hy=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let l=0,u=0;if(l+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":u=-a.data.width/2;break;case"r":u=a.data.width/2}if(u&&(l+=n?u:-u),u=0,l+=(a.data.dummy?e:t)/2,l+=(s.data.dummy?e:t)/2,l+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":u=s.data.width/2;break;case"r":u=-s.data.width/2}return u&&(l+=n?u:-u),u=0,l},dy=(t,e)=>t.getNode(e).data.width||0,fy=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=Om(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,l)=>{var u;const c=sy(t,e),h=c?t.getNode(c.id).data.order:a;(c||e===s)&&(null===(u=r.slice(o,l+1))||void 0===u||u.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<i||h<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||ly(n,r.id,e)}))})),o=l+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),ay(t,o)),s={};let l=[];["u","d"].forEach((e=>{l="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(l=l.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),u=((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 l=Math.floor(r),u=Math.ceil(r);l<=u;++l){const r=s[l];o[t]===t&&e<a[r]&&!uy(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,l,a,o),c=((t,e,n,r,i,o,a)=>{var s;const l={},u=cy(t,e,n,i,o,a),c=a?"borderLeft":"borderRight",h=(t,e)=>{let n=u.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 h((t=>{l[t]=(u.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(l[e.source]||0)+e.data.weight)),0)}),u.getPredecessors.bind(u)),h((e=>{const n=(u.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(l[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==c&&(l[e]=Math.max(l[e],n))}),u.getSuccessors.bind(u)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{l[t]=l[n[t]]})),l})(t,l,u.root,u.align,r,i,"r"===n);"r"===n&&Object.keys(c).forEach((t=>c[t]=-c[t])),s[e+n]=c}))}));const u=((t,e)=>Am(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=dy(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return u&&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 l;if(s===e)return;const u=Object.values(s);l="l"===o?r-Math.min(...u):i-Math.max(...u),l&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+l})))}))}))}(s,u),((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)},py=(t,e)=>{var n;const r=Sm(t);((t,e)=>{const{ranksep:n=0}=e||{},r=Om(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=fy(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},gy=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||e<a)&&(a=e)})),a||(a=0),o.data.rank=a,a};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>n(t.id)))},vy=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,my=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||vy(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},yy=(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&&vy(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},by=(t,e)=>Am(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?vy(e,n):1/0)),xy=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},Ey=t=>{const e=(t=>{const e=new Yg;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);gy(e);const n=(t=>{const e=new Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);my(e,t)<r;)i=by(e,t),o=e.hasNode(i.source)?vy(t,i):-vy(t,i),xy(e,t,o);return e})(e);let r,i;for(Sy(n),wy(n,e);r=Oy(n);)i=Ty(n,e,r),Cy(n,e,r,i)},wy=(t,e)=>{let n=Rm(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{ky(t,e,n)}))},ky=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=My(t,e,n)},My=(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,l=e.data.weight;if(a+=r?l:-l,Py(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},Sy=(t,e=t.getAllNodes()[0].id)=>{Ny(t,{},1,e)},Ny=(t,e,n,r,i)=>{var o;const a=n;let s=n;const l=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=Ny(t,e,s,n.id,r))})),l.data.low=a,l.data.lim=s++,i?l.data.parent=i:delete l.data.parent,s},Oy=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),Ty=(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,l=!1;o.data.lim>a.data.lim&&(s=a,l=!0);const u=e.getAllEdges().filter((e=>l===Ry(t.getNode(e.source),s)&&l!==Ry(t.getNode(e.target),s)));return Am(u,(t=>vy(e,t)))},Cy=(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:{}}),Sy(t),wy(t,e),Ay(t,e)},Ay=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=Rm(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))}))},Py=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),Ry=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Dy=gy,Ly=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||e<s)&&(s=e)})),s||(s=0),(void 0===n||s<n)&&(n=s),a.data.rank=s,s};t.getAllNodes().filter((e=>0===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<s)&&(a.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach((t=>{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 Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);yy(e,t)<r;)i=by(e,t),o=e.hasNode(i.source)?vy(t,i):-vy(t,i),xy(e,t,o)})(t)},_y=t=>{Ey(t)},Iy=(t,e)=>{const{ranker:n,rankdir:r="tb",nodeOrder:i,keepNodeOrder:o,align:a,nodesep:s=50,edgesep:l=20,ranksep:u=50}=e;tb(t),km(t);const{nestingRoot:c,nodeRankFactor:h}=(t=>{const e=Mm(t,"root",{},"_root"),n=Gm(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=Vm(t)+1;return t.getRoots().forEach((r=>{zm(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":_y(t);break;case"tight-tree":default:Ly(t);break;case"longest-path":Dy(t)}})(Sm(t),n),$y(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<o.length;n++){const r=o[n];void 0===r?n%e!=0&&(a-=1):a&&(null==r||r.forEach((e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}})(t,h),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach((e=>{e.data.nestingEdge&&t.removeEdge(e.id)}))})(t,c),(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),Yy(t),qy(t);const d=[];((t,e)=>{t.getAllEdges().forEach((n=>Hm(t,n,e)))})(t,d),oy(t,d),(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;e<r;e+=1)Dm(t,"borderLeft","_bl",n,i,e),Dm(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach((t=>e(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)})).map((t=>t.data.rank)),r=Math.max(...n),i=[];for(let t=0;t<r+1;t++)i[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=i[n.data.rank].length,i[n.data.rank].push(e)))}))})(t,i),((t,e)=>{const n=Cm(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=ny(t,r,"in"),a=ny(t,i,"out");let s=qm(t);iy(t,s);let l,u=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){ry(n%2?o:a,n%4>=2,!1,e),s=Om(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}s=qm(t),iy(t,s);for(let n=0,r=0;r<4;++n,++r){ry(n%2?o:a,n%4>=2,!0,e),s=Om(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}iy(t,l)})(t,o),eb(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||Lm(t)})(t,r),py(t,{align:a,nodesep:s,edgesep:l,ranksep:u}),nb(t),Jy(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===Wm&&(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,d),Zy(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Im(t),"lr"!==n&&"rl"!==n||(Bm(t),Lm(t))})(t,r);const{width:f,height:p}=Xy(t);return Ky(t),Qy(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:f,height:p}},jy=(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}))},By=(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)}))},Fy=["width","height","layer","fixorder"],zy={width:0,height:0},Gy=["minlen","weight","width","height","labeloffset"],Vy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Wy=["labelpos"],Hy=t=>{const e=new Yg({tree:[]});return t.getAllNodes().forEach((n=>{const r=ib(t.getNode(n.id).data),i=Object.assign(Object.assign({},zy),r),o=rb(i,Fy);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);$t(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=ib(t.getEdge(n.id).data),i={};null==Wy||Wy.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},Vy,rb(r,Gy),i)})})),e},Uy=(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},$y=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};Mm(t,"edge-proxy",r,"_ep")}}))},Yy=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},qy=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))}))},Xy=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}={},l=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,l=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(l)||(void 0===r&&(r=a-l/2),r=Math.min(r,a-l/2),o=Math.max(o,a+l/2))};return t.getAllNodes().forEach((t=>{l(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&l(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}},Ky=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(Nm(n.data,i)),e.data.points.push(Nm(r.data,o))}))},Zy=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}}))},Qy=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Jy=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]),l=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==l?void 0:l.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)}))},tb=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)}}))},eb=t=>{const e=Om(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=>{Mm(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},nb=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}}))},rb=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},ib=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},ob=Array.isArray,ab=t=>{const e=[],n=t.length;for(let r=0;r<n;r+=1){e[r]=[];for(let i=0;i<n;i+=1)r===i?e[r][i]=0:0!==t[r][i]&&t[r][i]?e[r][i]=t[r][i]:e[r][i]=1/0}for(let t=0;t<n;t+=1)for(let r=0;r<n;r+=1)for(let i=0;i<n;i+=1)e[r][i]>e[r][t]+e[t][i]&&(e[r][i]=e[r][t]+e[t][i]);return e},sb=(t,e)=>{const{nodes:n,edges:r}=t,i=[],o={};if(!n)throw new Error("invalid nodes data!");return n&&n.forEach(((t,e)=>{o[t.id]=e;i.push([])})),null==r||r.forEach((t=>{const{source:e,target:n}=t,r=o[e],a=o[n];void 0!==r&&void 0!==a&&(i[r][a]=1,i[a][r]=1)})),i},lb=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),ub=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let l=0;l<e.length;l++){const u=e[l];if(t.hasNode(u.id)&&!(null==a?void 0:a(u))){if(null==s?void 0:s(u))return;"TB"===r&&n(u),ub(t,t.getChildren(u.id,i),n,r,i,o),"TB"!==r&&n(u)}}},cb=t=>{if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){const e=[];return t.forEach((t=>{e.push(t)})),e.map((t=>cb(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=cb(t[n])})),e}return t},hb=(t,e)=>{const n=cb(t);return n.data=n.data||{},e&&(ae(n.data.x)||(n.data.x=Math.random()*e[0]),ae(n.data.y)||(n.data.y=Math.random()*e[1])),n};function db(t){if(!t)return[0,0,0];if(ae(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function fb(t,e){let n;return n=Ut(e)?e:ae(e)?()=>e:()=>t,n}function pb(t,e,n=!0){return e||0===e?Ut(e)?e:ae(e)?()=>e:Array.isArray(e)?()=>n?Math.max(...e)||t:e:qt(e)&&e.width&&e.height?()=>n?Math.max(e.width,e.height)||t:[e.width,e.height]:()=>t:e=>{const{size:r}=e.data||{};return r?Array.isArray(r)?n?Math.max(...r)||t:r:qt(r)&&r.width&&r.height?n?Math.max(r.width,r.height)||t:[r.width,r.height]:r:t}}const gb=(t,e,n=10)=>{let r;const i="function"==typeof e?e:()=>e||0;r=t?Array.isArray(t)?e=>t:Ut(t)?t:e=>t:t=>{var e,r,i;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return null===(r=t.data)||void 0===r?void 0:r.bboxSize;if(null===(i=t.data)||void 0===i?void 0:i.size){const e=t.data.size;return Array.isArray(e)?e:qt(e)?[e.width,e.height]:e}return n};return t=>{const e=r(t),n=i(t);return Math.max(...db(e))+n}},vb={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class mb{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},vb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{nodeSize:i,align:o,rankdir:a="TB",ranksep:s,nodesep:l,ranksepFunc:u,nodesepFunc:c,edgeLabelSpace:h,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:v,sortByCombo:m,preset:y}=r,b=new Yg({tree:[]}),x=fb(s||50,u),E=fb(l||50,c);let w=E,k=x;"LR"!==a&&"RL"!==a||(w=x,k=E);const M=pb(10,i,!1),S=e.getAllNodes(),N=e.getAllEdges();let O;S.forEach((t=>{const e=db(M(t)),n=k(t),r=w(t),i=e[0]+2*r,o=e[1]+2*n,a=t.data.layer;ae(a)?b.addNode({id:t.id,data:{width:i,height:o,layer:a}}):b.addNode({id:t.id,data:{width:i,height:o}})})),m&&(b.attachTreeStructure("combo"),S.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),N.forEach((t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),(null==y?void 0:y.length)&&(O=new Yg({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&jy(t,i);const s=Hy(t);let l;n&&(e.ranksep=Uy(s,{rankdir:o,ranksep:a}));try{l=Iy(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}By(t,s)})(b,{prevGraph:O,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:l,align:o});const T=[0,0];if(p){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)}))})),T[0]=p[0]-t,T[1]=p[1]-e}const C="LR"===a||"RL"===a;if(v);else{const t=new Set,e="BT"===a||"RL"===a?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach((e=>{e.data.x=e.data.x+T[0],e.data.y=e.data.y+T[1],t.add(C?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=C?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=C?(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 o;h&&g&&"loop"!==t.data.type&&(t.data.controlPoints=yb(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+T[0],y:e+T[1]}))),b.getNode(t.source),b.getNode(t.target),n,C,r,i))}))}let A=[];A=b.getAllNodes().map((t=>hb(t)));const P=b.getAllEdges();t&&(A.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),P.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:A,edges:P}}))}}const yb=(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:l}=e.data,{x:u,y:c}=n.data;if(i&&(t=e.data.y,l=e.data.x,u=n.data.y,c=n.data.x),c!==l&&t!==u){const h=r.indexOf(l),d=r[h+1];if(d){const t=s[0],e=i?{x:(l+d)/2,y:(null==t?void 0:t.y)||u}:{x:(null==t?void 0:t.x)||u,y:(l+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(c),p=Math.abs(f-h);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(l+c)/2,y:t}:{x:t,y:(l+c)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(c+e)/2,y:(null==n?void 0:n.y)||u}:{x:(null==n?void 0:n.x)||t,y:(c+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},bb=(t,e,n)=>{const r=t.getAllNodes(),i=t.getAllEdges();if(!(null==r?void 0:r.length)){return{nodes:[],edges:i}}if(1===r.length){e&&t.mergeNodeData(r[0].id,{x:n[0],y:n[1]});return{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:n[0],y:n[1]})})],edges:i}}},xb={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class Eb{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},xb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:l=0,endAngle:u=2*Math.PI,angleRatio:c,ordering:h,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),v=e.getAllEdges(),[m,y,b]=kb(i,o,a),x=null==g?void 0:g.length;if(!x||1===x)return bb(e,t,b);const E=(u-l)/x;let{radius:w,startRadius:k,endRadius:M}=r;if(f){const t=fb(10,f),e=pb(10,p);let n=-1/0;g.forEach((t=>{const r=e(t);n<r&&(n=r)}));let r=0;g.forEach(((e,i)=>{r+=0===i?n||10:(t(e)||0)+(n||10)})),w=r/(2*Math.PI)}else w||k||M?!k&&M?k=M:k&&!M&&(M=k):w=Math.min(y,m)/2;const S=E*c;let N=[];N="topology"===h?wb(e,g):"topology-directed"===h?wb(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(hb(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>hb(t)));const O=Math.ceil(x/s);for(let t=0;t<x;++t){let e=w;e||null===k||null===M||(e=k+t*(M-k)/(x-1)),e||(e=10+100*t/(x-1));let n=l+t%O*S+2*Math.PI/s*Math.floor(t/O);d||(n=u-t%O*S-2*Math.PI/s*Math.floor(t/O)),N[t].data.x=b[0]+Math.cos(n)*e,N[t].data.y=b[1]+Math.sin(n)*e}t&&N.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:N,edges:v}}))}}const wb=(t,e,n=!1)=>{const r=[hb(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,l)=>{if(0!==l)if(l!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[l+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const l=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let u=!1;for(let e=0;e<l.length;e++){const n=l[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(hb(n)),i[n.id]=!0,u=!0;break}}let c=0;for(;!u&&(i[e[c].id]||(r.push(hb(e[c])),i[e[c].id]=!0,u=!0),c++,c!==o););}else r.push(hb(s)),i[s.id]=!0,a++})),r};const kb=(t,e,n)=>{let r=t,i=e,o=n;return r||"undefined"==typeof window||(r=window.innerWidth),i||"undefined"==typeof window||(i=window.innerHeight),o||(o=[r/2,i/2]),[r,i,o]},Mb={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Sb{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Mb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:l,sweep:u,clockwise:c,equidistant:h,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,v=e.getAllNodes(),m=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,x=i||[y/2,b/2];if(!(null==v?void 0:v.length)||1===v.length)return bb(e,t,x);const E=[];let w,k=0;ob(p)?w=Math.max(p[0],p[1]):Ut(p)?(w=-1/0,v.forEach((t=>{const e=Math.max(...db(p(t)));e>w&&(w=e)}))):w=p,ob(g)?k=Math.max(g[0],g[1]):ae(g)&&(k=g),v.forEach((t=>{const e=hb(t);E.push(e);let n=w;const{data:r}=e;ob(r.size)?n=Math.max(r.size[0],r.size[1]):ae(r.size)?n=r.size:qt(r.size)&&(n=Math.max(r.size.width,r.size.height)),w=Math.max(w,n),Ut(g)&&(k=Math.max(g(t),k))}));const M={};E.forEach(((t,e)=>{M[t.id]=e}));let S=s;ne(S)&&void 0!==E[0].data[S]||(S="degree"),"degree"===S?E.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):E.sort(((t,e)=>e.data[S]-t.data[S]));const N=E[0],O=(l||("degree"===S?e.getDegree(N.id,"both"):N.data[S]))/4,T=[{nodes:[]}];let C=T[0];E.forEach((t=>{if(C.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(C.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(C.nodes[0].data[S]-t.data[S]);O&&n>=O&&(C={nodes:[]},T.push(C))}C.nodes.push(t)}));let A=w+k;if(!d){const t=T.length>0&&T[0].nodes.length>1,e=(Math.min(y,b)/2-A)/(T.length+(t?1:0));A=Math.min(A,e)}let P=0;if(T.forEach((t=>{const e=void 0===u?2*Math.PI-2*Math.PI/t.nodes.length:u;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){const e=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),r=Math.sqrt(A*A/(e*e+n*n));P=Math.max(r,P)}t.r=P,P+=A})),h){let t=0,e=0;for(let n=0;n<T.length;n++){const r=(T[n].r||0)-e;t=Math.max(t,r)}e=0,T.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}T.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(c?1:-1)*e*r;t.data.x=x[0]+n*Math.cos(i),t.data.y=x[1]+n*Math.sin(i)}))})),t&&E.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:E,edges:m}}))}}function Nb(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,l,u,c,h,d,f=t._root,p={data:r},g=t._x0,v=t._y0,m=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a,i=f,!(f=f[h=c<<1|u]))return i[h]=p,t;if(s=+t._x.call(null,f.data),l=+t._y.call(null,f.data),e===s&&n===l)return p.next=f,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a}while((h=c<<1|u)==(d=(l>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function Ob(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Tb(t){return t[0]}function Cb(t){return t[1]}function Ab(t,e,n){var r=new Pb(null==e?Tb:e,null==n?Cb:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Pb(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 Rb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Db=Ab.prototype=Pb.prototype;function Lb(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,l,u,c,h,d,f,p,g,v,m=t._root,y={data:i},b=t._x0,x=t._y0,E=t._z0,w=t._x1,k=t._y1,M=t._z1;if(!m)return t._root=y,t;for(;m.length;)if((d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l,o=m,!(m=m[g=p<<2|f<<1|d]))return o[g]=y,t;if(u=+t._x.call(null,m.data),c=+t._y.call(null,m.data),h=+t._z.call(null,m.data),e===u&&n===c&&r===h)return y.next=m,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l}while((g=p<<2|f<<1|d)==(v=(h>=l)<<2|(c>=s)<<1|u>=a));return o[v]=m,o[g]=y,t}function _b(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}Db.copy=function(){var t,e,n=new Pb(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=Rb(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=Rb(e));return n},Db.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Nb(this.cover(e,n),e,n,t)},Db.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<o;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<l&&(l=r),r>c&&(c=r),i<u&&(u=i),i>h&&(h=i));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<o;++n)Nb(this,a[n],s[n],t[n]);return this},Db.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a,s,l=i-n||1,u=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=u,u=a,l*=2,s){case 0:i=n+l,o=r+l;break;case 1:n=i-l,o=r+l;break;case 2:i=n+l,r=o-l;break;case 3:n=i-l,r=o-l}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},Db.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Db.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},Db.find=function(t,e,n){var r,i,o,a,s,l,u,c=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new Ob(g,c,h,d,f)),null==n?n=1/0:(c=t-n,h=e-n,d=t+n,f=e+n,n*=n);l=p.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(o=l.y0)>f||(a=l.x1)<c||(s=l.y1)<h))if(g.length){var v=(i+a)/2,m=(o+s)/2;p.push(new Ob(g[3],v,m,a,s),new Ob(g[2],i,m,v,s),new Ob(g[1],v,o,a,m),new Ob(g[0],i,o,v,m)),(u=(e>=m)<<1|t>=v)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-u],p[p.length-1-u]=l)}else{var y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),x=y*y+b*b;if(x<n){var E=Math.sqrt(n=x);c=t-E,h=e-E,d=t+E,f=e+E,r=g.data}}return r},Db.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,l,u,c,h,d,f=this._root,p=this._x0,g=this._y0,v=this._x1,m=this._y1;if(!f)return this;if(f.length)for(;;){if((u=o>=(s=(p+v)/2))?p=s:v=s,(c=a>=(l=(g+m)/2))?g=l:m=l,e=f,!(f=f[h=c<<1|u]))return this;if(!f.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},Db.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Db.root=function(){return this._root},Db.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Db.visit=function(t){var e,n,r,i,o,a,s=[],l=this._root;for(l&&s.push(new Ob(l,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&l.length){var u=(r+o)/2,c=(i+a)/2;(n=l[3])&&s.push(new Ob(n,u,c,o,a)),(n=l[2])&&s.push(new Ob(n,r,c,u,a)),(n=l[1])&&s.push(new Ob(n,u,i,o,c)),(n=l[0])&&s.push(new Ob(n,r,i,u,c))}return this},Db.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Ob(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,l=e.x1,u=e.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&n.push(new Ob(o,a,s,c,h)),(o=i[1])&&n.push(new Ob(o,c,s,l,h)),(o=i[2])&&n.push(new Ob(o,a,h,c,u)),(o=i[3])&&n.push(new Ob(o,c,h,l,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Db.x=function(t){return arguments.length?(this._x=t,this):this._x},Db.y=function(t){return arguments.length?(this._y=t,this):this._y};const Ib=(t,e,n,r,i,o)=>Math.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function jb(t){return t[0]}function Bb(t){return t[1]}function Fb(t){return t[2]}function zb(t,e,n,r){var i=new Gb(null==e?jb:e,null==n?Bb:n,null==r?Fb:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Gb(t,e,n,r,i,o,a,s,l){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=l,this._root=void 0}function Vb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Wb=zb.prototype=Gb.prototype;Wb.copy=function(){var t,e,n=new Gb(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=Vb(r),n;for(t=[{source:r,target:n._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(8)}):r.target[i]=Vb(e));return n},Wb.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Lb(this.cover(e,n,r),e,n,r,t)},Wb.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let o=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(f=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>l&&(l=d),f<a&&(a=f),f>u&&(u=f),p<s&&(s=p),p>c&&(c=p));if(o>l||a>u||s>c)return this;this.cover(o,a,s).cover(l,u,c);for(let o=0;o<e;++o)Lb(this,n[o],r[o],i[o],t[o]);return this},Wb.cover=function(t,e,n){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,o=this._z0,a=this._x1,s=this._y1,l=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,l=(o=Math.floor(n))+1;else{for(var u,c,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=l;)switch(c=(n<o)<<2|(e<i)<<1|t<r,(u=new Array(8))[c]=d,d=u,h*=2,c){case 0:a=r+h,s=i+h,l=o+h;break;case 1:r=a-h,s=i+h,l=o+h;break;case 2:a=r+h,i=s-h,l=o+h;break;case 3:r=a-h,i=s-h,l=o+h;break;case 4:a=r+h,s=i+h,o=l-h;break;case 5:r=a-h,s=i+h,o=l-h;break;case 6:a=r+h,i=s-h,o=l-h;break;case 7:r=a-h,i=s-h,o=l-h}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=l,this},Wb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Wb.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Wb.find=function(t,e,n,r){var i,o,a,s,l,u,c,h,d,f=this._x0,p=this._y0,g=this._z0,v=this._x1,m=this._y1,y=this._z1,b=[],x=this._root;for(x&&b.push(new _b(x,f,p,g,v,m,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,v=t+r,m=e+r,y=n+r,r*=r);h=b.pop();)if(!(!(x=h.node)||(o=h.x0)>v||(a=h.y0)>m||(s=h.z0)>y||(l=h.x1)<f||(u=h.y1)<p||(c=h.z1)<g))if(x.length){var E=(o+l)/2,w=(a+u)/2,k=(s+c)/2;b.push(new _b(x[7],E,w,k,l,u,c),new _b(x[6],o,w,k,E,u,c),new _b(x[5],E,a,k,l,w,c),new _b(x[4],o,a,k,E,w,c),new _b(x[3],E,w,s,l,u,k),new _b(x[2],o,w,s,E,u,k),new _b(x[1],E,a,s,l,w,k),new _b(x[0],o,a,s,E,w,k)),(d=(n>=k)<<2|(e>=w)<<1|t>=E)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=h)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),N=n-+this._z.call(null,x.data),O=M*M+S*S+N*N;if(O<r){var T=Math.sqrt(r=O);f=t-T,p=e-T,g=n-T,v=t+T,m=e+T,y=n+T,i=x.data}}return i},Wb.findAllWithinRadius=function(t,e,n,r){const i=[],o=t-r,a=e-r,s=n-r,l=t+r,u=e+r,c=n+r;return this.visit(((h,d,f,p,g,v,m)=>{if(!h.length)do{const o=h.data;Ib(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(h=h.next);return d>l||f>u||p>c||g<o||v<a||m<s})),i},Wb.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,n,r,i,o,a,s,l,u,c,h,d,f,p,g,v=this._root,m=this._x0,y=this._y0,b=this._z0,x=this._x1,E=this._y1,w=this._z1;if(!v)return this;if(v.length)for(;;){if((h=o>=(l=(m+x)/2))?m=l:x=l,(d=a>=(u=(y+E)/2))?y=u:E=u,(f=s>=(c=(b+w)/2))?b=c:w=c,e=v,!(v=v[p=f<<2|d<<1|h]))return this;if(!v.length)break;(e[p+1&7]||e[p+2&7]||e[p+3&7]||e[p+4&7]||e[p+5&7]||e[p+6&7]||e[p+7&7])&&(n=e,g=p)}for(;v.data!==t;)if(r=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(n?n[g]=v:this._root=v),this):(this._root=i,this)},Wb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Wb.root=function(){return this._root},Wb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Wb.visit=function(t){var e,n,r,i,o,a,s,l,u=[],c=this._root;for(c&&u.push(new _b(c,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=u.pop();)if(!t(c=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,l=e.z1)&&c.length){var h=(r+a)/2,d=(i+s)/2,f=(o+l)/2;(n=c[7])&&u.push(new _b(n,h,d,f,a,s,l)),(n=c[6])&&u.push(new _b(n,r,d,f,h,s,l)),(n=c[5])&&u.push(new _b(n,h,i,f,a,d,l)),(n=c[4])&&u.push(new _b(n,r,i,f,h,d,l)),(n=c[3])&&u.push(new _b(n,h,d,o,a,s,f)),(n=c[2])&&u.push(new _b(n,r,d,o,h,s,f)),(n=c[1])&&u.push(new _b(n,h,i,o,a,d,f)),(n=c[0])&&u.push(new _b(n,r,i,o,h,d,f))}return this},Wb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new _b(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,l=e.z0,u=e.x1,c=e.y1,h=e.z1,d=(a+u)/2,f=(s+c)/2,p=(l+h)/2;(o=i[0])&&n.push(new _b(o,a,s,l,d,f,p)),(o=i[1])&&n.push(new _b(o,d,s,l,u,f,p)),(o=i[2])&&n.push(new _b(o,a,f,l,d,c,p)),(o=i[3])&&n.push(new _b(o,d,f,l,u,c,p)),(o=i[4])&&n.push(new _b(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new _b(o,d,s,p,u,f,h)),(o=i[6])&&n.push(new _b(o,a,f,p,d,c,h)),(o=i[7])&&n.push(new _b(o,d,f,p,u,c,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Wb.x=function(t){return arguments.length?(this._x=t,this):this._x},Wb.y=function(t){return arguments.length?(this._y=t,this):this._y},Wb.z=function(t){return arguments.length?(this._z=t,this):this._z};function Hb(t,e,n,r,i=2){const o=e/n,a=t.getAllNodes(),s=a.map(((t,e)=>{const{nodeStrength:n,x:r,y:i,z:a,size:s}=t.data;return{x:r,y:i,z:a,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n}})),l=(2===i?Ab(s,(t=>t.x),(t=>t.y)):zb(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Ub),u=new Map;return s.forEach((t=>{u.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>$b(e,r,i,o,a,t,n)))}(t,l,i)})),s.map(((t,e)=>{const{id:n,data:i}=a[e],{mass:o=1}=i;r[n]={x:t.vx/o,y:t.vy/o,z:t.vz/o}})),r}function Ub(t){let e=0,n=0,r=0,i=0,o=0;const a=t.length;if(a){for(let s=0;s<a;s++){const a=t[s];a&&a.weight&&(e+=a.weight,n+=a.x*a.weight,r+=a.y*a.weight,i+=a.z*a.weight,o+=a.size*a.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const $b=(t,e,n,r,i,o,a)=>{var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===o.id)return;const l=[n,r,i][a-1],u=o.x-t.x||.1,c=o.y-t.y||.1,h=o.z-t.z||.1,d=[u,c,h],f=l-e;let p=0;for(let t=0;t<a;t++)p+=d[t]*d[t];const g=Math.sqrt(p)*p;if(f*f*.81<p){const e=t.weight/g;return o.vx+=u*e,o.vy+=c*e,o.vz+=h*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=u*e,o.vy+=c*e,o.vz+=h*e}};const Yb={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,preventOverlap:!0,distanceThresholdMode:"mean"};class qb{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Yb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;(this.judgingDistance>this.lastOptions.minMovement||e<1)&&e<t;e++)this.runOneStep(this.lastCalcGraph,this.lastGraph,e,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericForceLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),{dimensions:s,width:l,height:u,nodeSize:c,getMass:h,nodeStrength:d,edgeStrength:f,linkDistance:p}=a,g=i.map(((t,e)=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{x:ae(t.data.x)?t.data.x:Math.random()*l,y:ae(t.data.y)?t.data.y:Math.random()*u,z:ae(t.data.z)?t.data.z:Math.random()*Math.sqrt(l*u),size:c(t)||30,mass:h(t),nodeStrength:d(t)})}))),v=o.map((t=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{edgeStrength:f(t),linkDistance:p(t,e.getNode(t.source),e.getNode(t.target))})})));if(!(null==i?void 0:i.length))return this.lastResult={nodes:[],edges:o},{nodes:[],edges:o};const m={};i.forEach(((t,e)=>{m[t.id]={x:0,y:0,z:0}}));const y=new Yg({nodes:g,edges:v});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:x,onTick:E}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=m,"undefined"==typeof window)return;let w=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Jb(e,g),edges:o}),this.runOneStep(y,e,w,m,a),this.updatePosition(e,y,m,a),t&&g.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0}))),null==E||E({nodes:Jb(e,g),edges:o}),w++,(w>=b||this.judgingDistance<x)&&(window.clearInterval(this.timeInterval),n({nodes:Jb(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o}=t;n.width=r||"undefined"==typeof window?r:window.innerWidth,n.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(n.center=[n.width/2,n.height/2]),o||(n.getMass=t=>{let n=1;ae(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);const r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n}),n.nodeSize=gb(t.nodeSize,t.nodeSpacing);const a=t.linkDistance?fb(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=a,n.nodeStrength=fb(1,t.nodeStrength),n.edgeStrength=fb(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:l}=t,u=e.getAllNodes(),c=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let h,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&l&&(h=Xb(e,l),d=Array.from(new Set(null==u?void 0:u.map((t=>t.data[l]))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=h[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==d?void 0:d.length)?1:t.clusterNodeStrength(e)},others:1,center:t=>{const n=e.getDegree(t.id,"both");if(!n)return{x:100,y:100,z:0};let r;if(1===n){const{sameTypeLeaves:e=[]}=h[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Qb(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),s&&l){h||(h=Xb(e,l)),d||(d=Array.from(new Set(u.map((t=>t.data[l]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=u.filter((e=>e.data[l]===t)).map((t=>e.getNode(t.id)));n[t]=Qb(r)})),t.centripetalOptions=Object.assign(c,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[l]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}const{leaf:f,single:p,others:g}=t.centripetalOptions||{};f&&"function"!=typeof f&&(t.centripetalOptions.leaf=()=>f),p&&"function"!=typeof p&&(t.centripetalOptions.single=()=>p),g&&"function"!=typeof g&&(t.centripetalOptions.others=()=>g)}runOneStep(t,e,n,r,i){const o={},a=t.getAllNodes(),s=t.getAllEdges();if(!(null==a?void 0:a.length))return;const{monitor:l}=i;if(this.calRepulsive(t,o,i),s&&this.calAttractive(t,o,i),this.calGravity(t,e,o,i),this.updateVelocity(t,o,r,i),l){l({energy:this.calTotalEnergy(o,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:n})}}calTotalEnergy(t,e){if(!(null==e?void 0:e.length))return 0;let n=0;return e.forEach(((e,r)=>{const i=t[e.id].x,o=t[e.id].y,a=3===this.options.dimensions?t[e.id].z:0,s=i*i+o*o+a*a,{mass:l=1}=e.data;n+=l*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;Hb(t,i,o*o,e,r)}calAttractive(t,e,n){const{dimensions:r,nodeSize:i}=n;t.getAllEdges().forEach(((n,o)=>{const{source:a,target:s}=n,l=t.getNode(a),u=t.getNode(s);if(!l||!u)return;let c=u.data.x-l.data.x,h=u.data.y-l.data.y,d=3===r?u.data.z-l.data.z:0;c||h||(c=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(c*c+h*h+d*d);if(f<i(l)+i(u))return;const p=c/f,g=h/f,v=d/f,{linkDistance:m=200,edgeStrength:y=200}=n.data||{},b=(m-f)*y,x=1/(l.data.mass||1),E=1/(u.data.mass||1),w=p*b,k=g*b,M=v*b;e[a].x-=w*x,e[a].y-=k*x,e[a].z-=M*x,e[s].x+=w*E,e[s].y+=k*E,e[s].z+=M*E}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:l,height:u,center:c,gravity:h,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:v,z:m}=f,y=e.getNode(o);let b=0,x=0,E=0,w=h;const k=t.getDegree(o,"in"),M=t.getDegree(o,"out"),S=t.getDegree(o,"both"),N=null==i?void 0:i(y,S);if(N){const[t,e,n]=N;b=g-t,x=v-e,w=n}else b=g-c[0],x=v-c[1],E=m-c[2];if(w&&(n[o].x-=w*b/p,n[o].y-=w*x/p,n[o].z-=w*E/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:c,y:h,z:f,centerStrength:b}=(null==i?void 0:i(y,a,s,l,u))||{x:0,y:0,z:0,centerStrength:0};if(!ae(c)||!ae(h))return;const x=(g-c)/p,E=(v-h)/p,w=(m-f)/p;if(b&&(n[o].x-=b*x,n[o].y-=b*E,n[o].z-=b*w),0===S){const t=e(y);if(!t)return;return n[o].x-=t*x,n[o].y-=t*E,void(n[o].z-=t*w)}if(0===k||0===M){const e=t(y,a,s);if(!e)return;return n[o].x-=e*x,n[o].y-=e*E,void(n[o].z-=e*w)}const N=r(y);if(!N)return;n[o].x-=N*x,n[o].y-=N*E,n[o].z-=N*w}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,l=t.getAllNodes();(null==l?void 0:l.length)&&l.forEach((t=>{const{id:r}=t;let l=(n[r].x+e[r].x*a)*i||.01,u=(n[r].y+e[r].y*a)*i||.01,c=3===s?(n[r].z+e[r].z*a)*i||.01:0;const h=Math.sqrt(l*l+u*u+c*c);if(h>o){const t=o/h;l*=t,u*=t,c*=t}n[r]={x:l,y:u,z:c}}))}updatePosition(t,e,n,r){const{distanceThresholdMode:i,interval:o,dimensions:a}=r,s=e.getAllNodes();if(!(null==s?void 0:s.length))return void(this.judgingDistance=0);let l=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,u=t.getNode(s);if(ae(u.data.fx)&&ae(u.data.fy))return void e.mergeNodeData(s,{x:u.data.fx,y:u.data.fy,z:3===a?u.data.fz:void 0});const c=n[s].x*o,h=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+c,y:r.data.y+h,z:r.data.z+d});const f=Math.sqrt(c*c+h*h+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:l+=f}})),i&&"mean"!==i||(this.judgingDistance=l/s.length)}}const Xb=(t,e)=>{const n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};const r={};return n.forEach(((n,i)=>{1===t.getDegree(n.id,"both")&&(r[n.id]=Kb(t,"leaf",n,e))})),r},Kb=(t,e,n,r)=>{const i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out");let a=n,s=[];0===i?(a=t.getSuccessors(n.id)[0],s=t.getNeighbors(a.id)):0===o&&(a=t.getPredecessors(n.id)[0],s=t.getNeighbors(a.id)),s=s.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")));return{coreNode:a,siblingLeaves:s,sameTypeLeaves:Zb(t,e,r,n,s)}},Zb=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out"))),a},Qb=t=>{const e={x:0,y:0};t.forEach((t=>{const{x:n,y:r}=t.data;e.x+=n||0,e.y+=r||0}));const n=t.length||1;return{x:e.x/n,y:e.y/n}},Jb=(t,e)=>e.map((e=>{const{id:n,data:r}=e,i=t.getNode(n);return Object.assign(Object.assign({},i),{data:Object.assign(Object.assign({},i.data),{x:r.x,y:r.y,z:r.z})})}));var tx={};const ex=Object.prototype.toString;function nx(t){const e=ex.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var rx=w(Object.freeze({__proto__:null,isAnyArray:nx}));var ix=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(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(!nx(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(!nx(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;s<o;s++)t[s]<a&&(a=t[s]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(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;s<o;s++)t[s]>a&&(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,l=void 0===s?n.autoMinMax?i:1:s;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var u=(l-a)/(i-r),c=0;c<t.length;c++)e[c]=(t[c]-r)*u+a;return e}}),ox=w(ix);Object.defineProperty(tx,"__esModule",{value:!0});var ax=rx,sx=ox;const lx=" ".repeat(2),ux=" ".repeat(4);function cx(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${lx}[\n${ux}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),l=Math.min(a,n),u=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){i=!0;break t}}for(let e=0;e<s;e++){let n=[];for(let o=0;o<l;o++)n.push(hx(t.get(e,o),r,i));u.push(`${n.join(" ")}`)}l!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);s!==o&&u.push(`... ${o-e} more rows`);return u.join(`\n${ux}`)}(t,n,r,i,o)}\n${lx}]\n${lx}rows: ${t.rows}\n${lx}columns: ${t.columns}\n}`}function hx(t,e,n){return(t>=0&&n?` ${dx(t,e-1)}`:dx(t,e)).padEnd(e)}function dx(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 fx(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 px(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 gx(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 vx(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 mx(t,e){if(!ax.isAnyArray(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}function yx(t,e){if(!ax.isAnyArray(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}function bx(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(Ex("startRow",e),Ex("endRow",n),Ex("startColumn",r),Ex("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 xx(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function Ex(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function wx(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class kx{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new Sx(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.set(i,t,n[i*e+t]);return r}static rowVector(t){let e=new Sx(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new Sx(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new Sx(t,e)}static ones(t,e){return new Sx(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new Sx(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,r());return i}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:o=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let a=i-r,s=new Sx(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=r+Math.round(o()*a);s.set(n,t,e)}return s}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let r=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<r;t++)i.set(t,t,n);return i}static diag(t,e,n){let r=t.length;void 0===e&&(e=r),void 0===n&&(n=e);let i=Math.min(r,e,n),o=this.zeros(e,n);for(let e=0;e<i;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new Sx(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.min(t.get(o,n),e.get(o,n)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new this(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.max(t.get(o,n),e.get(o,n)));return i}static checkMatrix(t){return kx.isMatrix(t)?t:new Sx(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.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<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let a=i;a<e;a++){let e=t.get(n,a)-o*t.get(r,a);t.set(n,a,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new Sx(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)r.setSubMatrix(this,this.rows*t,this.columns*e);return r}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){fx(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return Sx.rowVector(this.getRow(t))}setRow(t,e){fx(this,t),e=gx(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){fx(this,t),fx(this,e);for(let n=0;n<this.columns;n++){let r=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,r)}return this}getColumn(t){px(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return Sx.columnVector(this.getColumn(t))}setColumn(t,e){px(this,t),e=vx(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){px(this,t),px(this,e);for(let n=0;n<this.rows;n++){let r=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,r)}return this}addRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){fx(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){px(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[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;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){wx(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>t&&(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;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){wx(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}maxRow(t){if(fx(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){fx(this,t),wx(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(fx(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){fx(this,t),wx(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r),n[1]=r);return n}maxColumn(t){if(px(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){px(this,t),wx(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(px(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){px(this,t),wx(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){kx.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}mmul(t){t=Sx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new Sx(e,r),o=new Float64Array(n);for(let a=0;a<r;a++){for(let e=0;e<n;e++)o[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,a,e)}}return i}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=Sx.eye(this.rows),n=this;for(let r=t;r>=1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=Sx.checkMatrix(t);let e=new Sx(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),l=this.get(1,1),u=t.get(1,1),c=(n+l)*(r+u),h=(a+l)*r,d=n*(o-u),f=l*(s-r),p=(n+i)*u,g=c+f-p+(i-l)*(s+u),v=d+p,m=h+f,y=c-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,v),e.set(1,0,m),e.set(1,1,y),e}strassen3x3(t){t=Sx.checkMatrix(t);let e=new Sx(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),l=this.get(2,0),u=this.get(2,1),c=this.get(2,2),h=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),v=t.get(1,2),m=t.get(2,0),y=t.get(2,1),b=t.get(2,2),x=(n-o)*(-d+g),E=(-n+o+a)*(h-d+g),w=(o+a)*(-h+d),k=n*h,M=(-n+l+u)*(h-f+v),S=(-n+l)*(f-v),N=(l+u)*(-h+f),O=(-i+u+c)*(g+m-y),T=(i-c)*(g-y),C=i*m,A=(u+c)*(-m+y),P=(-i+a+s)*(v+m-b),R=(i-s)*(v-b),D=(a+s)*(-m+b),L=k+C+r*p,_=(n+r+i-o-a-u-c)*g+E+w+k+O+C+A,I=k+M+N+(n+r+i-a-s-l-u)*v+C+P+D,j=x+a*(-h+d+p-g-v-m+b)+E+k+C+P+R,B=x+E+w+k+s*y,F=C+P+R+D+o*f,z=k+M+S+u*(-h+f+p-g-v-m+y)+O+T+C,G=O+T+C+A+l*d,V=k+M+S+N+c*b;return e.set(0,0,L),e.set(0,1,_),e.set(0,2,I),e.set(1,0,j),e.set(1,1,B),e.set(1,2,F),e.set(2,0,z),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=Sx.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=kx.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),l=Math.max(r,o);return e=a(e,s,l),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),l=e.subMatrix(0,o-1,0,s-1),u=n.subMatrix(0,o-1,0,s-1),c=e.subMatrix(0,o-1,s,e.columns-1),h=n.subMatrix(0,o-1,s,n.columns-1),d=e.subMatrix(o,e.rows-1,0,s-1),f=n.subMatrix(o,n.rows-1,0,s-1),p=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),v=t(kx.add(l,p),kx.add(u,g),o,s),m=t(kx.add(d,p),u,o,s),y=t(l,kx.sub(h,g),o,s),b=t(p,kx.sub(f,u),o,s),x=t(kx.add(l,c),g,o,s),E=t(kx.sub(d,l),kx.add(u,h),o,s),w=t(kx.sub(c,p),kx.add(f,g),o,s),k=kx.add(v,b);k.sub(x),k.add(w);let M=kx.add(y,x),S=kx.add(m,b),N=kx.sub(v,m);N.add(y),N.add(E);let O=kx.zeros(2*k.rows,2*k.columns);return O=O.setSubMatrix(k,0,0),O=O.setSubMatrix(M,k.rows,0),O=O.setSubMatrix(S,0,k.columns),O=O.setSubMatrix(N,k.rows,k.columns),O.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,l),s,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Sx(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&sx(i,{min:e,max:n,output:i}),r.setRow(t,i)}return r}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Sx(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&sx(i,{min:e,max:n,output:i}),r.setColumn(t,i)}return r}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),r=this.get(e,this.columns-1-n);this.set(e,n,r),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),r=this.get(this.rows-1-n,e);this.set(n,e,r),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=Sx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new Sx(e*r,n*i);for(let a=0;a<e;a++)for(let e=0;e<n;e++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)o.set(r*a+n,i*e+s,this.get(a,e)*t.get(n,s));return o}kroneckerSum(t){if(t=Sx.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,r=this.kroneckerProduct(Sx.eye(n,n)),i=Sx.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new Sx(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=Mx){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Mx){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){bx(this,t,e,n,r);let i=new Sx(e-t+1,r-n+1);for(let o=t;o<=e;o++)for(let e=n;e<=r;e++)i.set(o-t,e-n,this.get(o,e));return i}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new Sx(t.length,n-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[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 Sx(n-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[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=Sx.checkMatrix(t)).isEmpty())return this;bx(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r<t.rows;r++)for(let i=0;i<t.columns;i++)this.set(e+r,n+i,t.get(r,i));return this}selection(t,e){mx(this,t),yx(this,e);let n=new Sx(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new Sx(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=xx(t.rows);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]+=t.get(n,r);return e}(this);case"column":return function(t){let e=xx(t.columns);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]+=t.get(n,r);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e+=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=xx(t.rows,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]*=t.get(n,r);return e}(this);case"column":return function(t){let e=xx(t.columns,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]*=t.get(n,r);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e*=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!ax.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,l=0;for(let e=0;e<i;e++)l=t.get(a,e)-n[a],r+=l,s+=l*l;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!ax.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,l=0;for(let e=0;e<r;e++)l=t.get(e,a)-n[a],i+=l,s+=l*l;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return function(t,e,n){const r=t.rows,i=t.columns,o=r*i;let a=0,s=0,l=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)l=t.get(e,r)-n,a+=l,s+=l*l;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}(this,n,r);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!ax.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[n])}(this,n),this;case"column":if(!ax.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[r])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=t.get(n,e)**2/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!ax.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=t.get(e,n)**2/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!ax.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[r])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=t.get(i,r)**2/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return cx(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function Mx(t,e){return t-e}kx.prototype.klass="Matrix","undefined"!=typeof Symbol&&(kx.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return cx(this)}),kx.random=kx.rand,kx.randomInt=kx.randInt,kx.diagonal=kx.diag,kx.prototype.diagonal=kx.prototype.diag,kx.identity=kx.eye,kx.prototype.negate=kx.prototype.neg,kx.prototype.tensorProduct=kx.prototype.kroneckerProduct;let Sx=class t extends kx{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<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),t.isMatrix(e))this.#t(e.rows,e.columns),t.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!ax.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<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!t[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return fx(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),fx(this,t,!0),e=Float64Array.from(gx(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){px(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let r=0;r<t;r++)n[r]=this.data[e][r];for(let r=t+1;r<this.columns;r++)n[r-1]=this.data[e][r];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),px(this,t,!0),e=vx(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>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<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t);return this},t.prototype.powM=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<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t.get(e,n));return this}}(kx,Sx);class Nx extends kx{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return Sx.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),Sx.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=Sx.copy(t,new Sx(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new Sx(t,t);else if(this.#e=new Sx(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new Nx(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new Sx(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<e.length;i++)e[i]=this.get(r,n),++n>=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 Nx(n);for(let i=0,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}Nx.prototype.klassType="SymmetricMatrix";class Ox extends Nx{static isDistanceMatrix(t){return Nx.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 Nx(this)}clone(){const t=new Ox(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<e.length;i++)e[i]=this.get(r,n),++n>=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<e;a++)r.set(i,o,t[a]),++i>=n&&(i=1+ ++o);return r}}Ox.prototype.klassSubType="DistanceMatrix";class Tx extends kx{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class Cx extends Tx{constructor(t,e,n){mx(t,e),yx(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 Ax extends kx{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 Px extends kx{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 Rx{constructor(t){let e,n,r,i,o,a,s,l,u,c=(t=Px.checkMatrix(t)).clone(),h=c.rows,d=c.columns,f=new Float64Array(h),p=1;for(e=0;e<h;e++)f[e]=e;for(l=new Float64Array(h),n=0;n<d;n++){for(e=0;e<h;e++)l[e]=c.get(e,n);for(e=0;e<h;e++){for(u=Math.min(e,n),o=0,r=0;r<u;r++)o+=c.get(e,r)*l[r];l[e]-=o,c.set(e,n,l[e])}for(i=n,e=n+1;e<h;e++)Math.abs(l[e])>Math.abs(l[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=c.get(i,r),c.set(i,r,c.get(n,r)),c.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<h&&0!==c.get(n,n))for(e=n+1;e<h;e++)c.set(e,n,c.get(e,n)/c.get(n,n))}this.LU=c,this.pivotVector=f,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=Sx.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,a=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)a.set(i,r,a.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new Sx(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?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 Sx(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Dx(t,e){let n=0;return Math.abs(t)>Math.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 Lx{constructor(t){let e,n,r,i,o=(t=Px.checkMatrix(t)).clone(),a=t.rows,s=t.columns,l=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=Dx(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<a;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<a;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<a;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}l[r]=-t}this.QR=o,this.Rdiag=l}solve(t){t=Sx.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,a,s=t.columns,l=t.clone(),u=e.columns;for(o=0;o<u;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*l.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)l.set(r,i,l.get(r,i)+a*e.get(r,o))}for(o=u-1;o>=0;o--){for(i=0;i<s;i++)l.set(o,i,l.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)l.set(r,i,l.get(r,i)-l.get(o,i)*e.get(r,o))}return l.subMatrix(0,u-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new Sx(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,a=i.columns,s=new Sx(o,a);for(n=a-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<a;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}let _x=class{constructor(t,e={}){if((t=Px.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,r=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=e;let s,l=Boolean(i),u=Boolean(o),c=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,c=!0;let e=l;l=u,u=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let h=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new Sx(n,h),g=new Sx(r,r),v=new Float64Array(r),m=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),E=Math.max(b,x);for(let t=0;t<E;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=Dx(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<b&&0!==f[t]){let r=0;for(let i=t;i<n;i++)r+=s.get(i,t)*s.get(i,e);r=-r/s.get(t,t);for(let i=t;i<n;i++)s.set(i,e,s.get(i,e)+r*s.get(i,t))}v[e]=s.get(t,e)}if(l&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<r;e++)v[t]=Dx(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<r;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<n&&0!==v[t]){for(let e=t+1;e<n;e++)m[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)m[e]+=v[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-v[e]/v[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*m[i])}}if(u)for(let e=t+1;e<r;e++)g.set(e,t,v[e])}}let w=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<w&&(f[w-1]=0),x+1<w&&(v[x]=s.get(x,w-1)),v[w-1]=0,l){for(let t=b;t<h;t++){for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<h;e++){let r=0;for(let i=t;i<n;i++)r+=p.get(i,t)*p.get(i,e);r=-r/p.get(t,t);for(let i=t;i<n;i++)p.set(i,e,p.get(i,e)+r*p.get(i,t))}for(let e=t;e<n;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}}if(u)for(let t=r-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<r;e++){let n=0;for(let i=t+1;i<r;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t+1,t);for(let i=t+1;i<r;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}let k=w-1,M=Number.EPSILON;for(;w>0;){let t,e;for(t=w-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+M*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===w-2)e=4;else{let n;for(n=w-1;n>=t&&n!==t;n--){let e=(n!==w?Math.abs(v[n]):0)+(n!==t+1?Math.abs(v[n-1]):0);if(Math.abs(f[n])<=M*e){f[n]=0;break}}n===t?e=3:n===w-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=v[w-2];v[w-2]=0;for(let n=w-2;n>=t;n--){let i=Dx(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*v[n-1],v[n-1]=o*v[n-1]),u)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,w-1),g.set(t,w-1,-a*g.get(t,n)+o*g.get(t,w-1)),g.set(t,n,i)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let r=t;r<w;r++){let i=Dx(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*v[r],v[r]=o*v[r],l)for(let e=0;e<n;e++)i=o*p.get(e,r)+a*p.get(e,t-1),p.set(e,t-1,-a*p.get(e,r)+o*p.get(e,t-1)),p.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(f[w-1]),Math.abs(f[w-2]),Math.abs(v[w-2]),Math.abs(f[t]),Math.abs(v[t])),i=f[w-1]/e,o=f[w-2]/e,a=v[w-2]/e,s=f[t]/e,c=v[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let m=0;0===h&&0===d||(m=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),m=d/(h+m));let y=(s+i)*(s-i)+m,b=s*c;for(let e=t;e<w-1;e++){let i=Dx(y,b);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=b/i;if(e!==t&&(v[e-1]=i),y=o*f[e]+a*v[e],v[e]=o*v[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],u)for(let t=0;t<r;t++)i=o*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+o*g.get(t,e+1)),g.set(t,e,i);if(i=Dx(y,b),0===i&&(i=Number.MIN_VALUE),o=y/i,a=b/i,f[e]=i,y=o*v[e]+a*f[e+1],f[e+1]=-a*v[e]+o*f[e+1],b=a*v[e+1],v[e+1]=o*v[e+1],l&&e<n-1)for(let t=0;t<n;t++)i=o*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+o*p.get(t,e+1)),p.set(t,e,i)}v[w-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,u))for(let e=0;e<=k;e++)g.set(e,t,-g.get(e,t));for(;t<k&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(l&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);t++}w--}}if(c){let t=g;g=p,p=t}this.m=n,this.n=r,this.s=f,this.U=p,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=Sx.zeros(r,r);for(let t=0;t<r;t++)Math.abs(this.s[t])<=n?i.set(t,t,0):i.set(t,t,1/this.s[t]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(i),l=a.rows,u=o.rows,c=Sx.zeros(l,u);for(let t=0;t<l;t++)for(let e=0;e<u;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);c.set(t,e,n)}return c.mmul(e)}solveForDiagonal(t){return this.solve(Sx.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new Sx(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<r;n++)Math.abs(this.s[n])>e&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,l=new Sx(n,a);for(let t=0;t<n;t++)for(let e=0;e<a;e++){let n=0;for(let r=0;r<s;r++)n+=i.get(t,r)*o.get(e,r);l.set(t,e,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>t&&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 Sx.diag(this.s)}};function Ix(t,e,n=!1){return t=Px.checkMatrix(t),e=Px.checkMatrix(e),n?new _x(t).solve(e):t.isSquare()?new Rx(t).solve(e):new Lx(t).solve(e)}function jx(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function Bx(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class Fx{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=Px.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,a=new Sx(o,o),s=new Float64Array(o),l=new Float64Array(o),u=t,c=!1;if(c=!!n||t.isSymmetric(),c){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h;for(l=0;l<t;l++)n[l]=r.get(t-1,l);for(s=t-1;s>0;s--){for(h=0,a=0,u=0;u<s;u++)h+=Math.abs(n[u]);if(0===h)for(e[s]=n[s-1],l=0;l<s;l++)n[l]=r.get(s-1,l),r.set(s,l,0),r.set(l,s,0);else{for(u=0;u<s;u++)n[u]/=h,a+=n[u]*n[u];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=h*o,a-=i*o,n[s-1]=i-o,l=0;l<s;l++)e[l]=0;for(l=0;l<s;l++){for(i=n[l],r.set(l,s,i),o=e[l]+r.get(l,l)*i,u=l+1;u<=s-1;u++)o+=r.get(u,l)*n[u],e[u]+=r.get(u,l)*i;e[l]=o}for(i=0,l=0;l<s;l++)e[l]/=a,i+=e[l]*n[l];for(c=i/(a+a),l=0;l<s;l++)e[l]-=c*n[l];for(l=0;l<s;l++){for(i=n[l],o=e[l],u=l;u<=s-1;u++)r.set(u,l,r.get(u,l)-(i*e[u]+o*n[u]));n[l]=r.get(s-1,l),r.set(s,l,0)}}n[s]=a}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),a=n[s+1],0!==a){for(u=0;u<=s;u++)n[u]=r.get(u,s+1)/a;for(l=0;l<=s;l++){for(o=0,u=0;u<=s;u++)o+=r.get(u,s+1)*r.get(u,l);for(u=0;u<=s;u++)r.set(u,l,r.get(u,l)-o*n[u])}}for(u=0;u<=s;u++)r.set(u,s+1,0)}for(l=0;l<t;l++)n[l]=r.get(t-1,l),r.set(t-1,l,0);r.set(t-1,t-1,1),e[0]=0}(o,l,s,a),function(t,e,n,r){let i,o,a,s,l,u,c,h,d,f,p,g,v,m,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,E=0,w=Number.EPSILON;for(u=0;u<t;u++){for(E=Math.max(E,Math.abs(n[u])+Math.abs(e[u])),c=u;c<t&&!(Math.abs(e[c])<=w*E);)c++;if(c>u)do{for(i=n[u],h=(n[u+1]-i)/(2*e[u]),d=Dx(h,1),h<0&&(d=-d),n[u]=e[u]/(h+d),n[u+1]=e[u]*(h+d),f=n[u+1],o=i-n[u],a=u+2;a<t;a++)n[a]-=o;for(x+=o,h=n[c],p=1,g=p,v=p,m=e[u+1],y=0,b=0,a=c-1;a>=u;a--)for(v=g,g=p,b=y,i=p*e[a],o=p*h,d=Dx(h,e[a]),e[a+1]=y*d,y=e[a]/d,p=h/d,h=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),l=0;l<t;l++)o=r.get(l,a+1),r.set(l,a+1,y*r.get(l,a)+p*o),r.set(l,a,p*r.get(l,a)-y*o);h=-y*b*v*m*e[u]/f,e[u]=y*h,n[u]=p*h}while(Math.abs(e[u])>w*E);n[u]=n[u]+x,e[u]=0}for(a=0;a<t-1;a++){for(l=a,h=n[a],s=a+1;s<t;s++)n[s]<h&&(l=s,h=n[s]);if(l!==a)for(n[l]=n[a],n[a]=h,s=0;s<t;s++)h=r.get(s,a),r.set(s,a,r.get(s,l)),r.set(s,l,h)}}(o,l,s,a)}else{let t=new Sx(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h=0,d=t-1;for(u=h+1;u<=d-1;u++){for(c=0,s=u;s<=d;s++)c+=Math.abs(e.get(s,u-1));if(0!==c){for(a=0,s=d;s>=u;s--)n[s]=e.get(s,u-1)/c,a+=n[s]*n[s];for(o=Math.sqrt(a),n[u]>0&&(o=-o),a-=n[u]*o,n[u]=n[u]-o,l=u;l<t;l++){for(i=0,s=d;s>=u;s--)i+=n[s]*e.get(s,l);for(i/=a,s=u;s<=d;s++)e.set(s,l,e.get(s,l)-i*n[s])}for(s=0;s<=d;s++){for(i=0,l=d;l>=u;l--)i+=n[l]*e.get(s,l);for(i/=a,l=u;l<=d;l++)e.set(s,l,e.get(s,l)-i*n[l])}n[u]=c*n[u],e.set(u,u-1,c*o)}}for(s=0;s<t;s++)for(l=0;l<t;l++)r.set(s,l,s===l?1:0);for(u=d-1;u>=h+1;u--)if(0!==e.get(u,u-1)){for(s=u+1;s<=d;s++)n[s]=e.get(s,u-1);for(l=u;l<=d;l++){for(o=0,s=u;s<=d;s++)o+=n[s]*r.get(s,l);for(o=o/n[u]/e.get(u,u-1),s=u;s<=d;s++)r.set(s,l,r.get(s,l)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,l,u,c,h,d,f,p,g,v,m,y,b,x=t-1,E=0,w=t-1,k=Number.EPSILON,M=0,S=0,N=0,O=0,T=0,C=0,A=0,P=0;for(o=0;o<t;o++)for((o<E||o>w)&&(n[o]=i.get(o,o),e[o]=0),a=Math.max(o-1,0);a<t;a++)S+=Math.abs(i.get(o,a));for(;x>=E;){for(l=x;l>E&&(C=Math.abs(i.get(l-1,l-1))+Math.abs(i.get(l,l)),0===C&&(C=S),!(Math.abs(i.get(l,l-1))<k*C));)l--;if(l===x)i.set(x,x,i.get(x,x)+M),n[x]=i.get(x,x),e[x]=0,x--,P=0;else if(l===x-1){if(h=i.get(x,x-1)*i.get(x-1,x),N=(i.get(x-1,x-1)-i.get(x,x))/2,O=N*N+h,A=Math.sqrt(Math.abs(O)),i.set(x,x,i.get(x,x)+M),i.set(x-1,x-1,i.get(x-1,x-1)+M),d=i.get(x,x),O>=0){for(A=N>=0?N+A:N-A,n[x-1]=d+A,n[x]=n[x-1],0!==A&&(n[x]=d-h/A),e[x-1]=0,e[x]=0,d=i.get(x,x-1),C=Math.abs(d)+Math.abs(A),N=d/C,O=A/C,T=Math.sqrt(N*N+O*O),N/=T,O/=T,a=x-1;a<t;a++)A=i.get(x-1,a),i.set(x-1,a,O*A+N*i.get(x,a)),i.set(x,a,O*i.get(x,a)-N*A);for(o=0;o<=x;o++)A=i.get(o,x-1),i.set(o,x-1,O*A+N*i.get(o,x)),i.set(o,x,O*i.get(o,x)-N*A);for(o=E;o<=w;o++)A=r.get(o,x-1),r.set(o,x-1,O*A+N*r.get(o,x)),r.set(o,x,O*r.get(o,x)-N*A)}else n[x-1]=d+N,n[x]=d+N,e[x-1]=A,e[x]=-A;x-=2,P=0}else{if(d=i.get(x,x),f=0,h=0,l<x&&(f=i.get(x-1,x-1),h=i.get(x,x-1)*i.get(x-1,x)),10===P){for(M+=d,o=E;o<=x;o++)i.set(o,o,i.get(o,o)-d);C=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*C,h=-.4375*C*C}if(30===P&&(C=(f-d)/2,C=C*C+h,C>0)){for(C=Math.sqrt(C),f<d&&(C=-C),C=d-h/((f-d)/2+C),o=E;o<=x;o++)i.set(o,o,i.get(o,o)-C);M+=C,d=f=h=.964}for(P+=1,u=x-2;u>=l&&(A=i.get(u,u),T=d-A,C=f-A,N=(T*C-h)/i.get(u+1,u)+i.get(u,u+1),O=i.get(u+1,u+1)-A-T-C,T=i.get(u+2,u+1),C=Math.abs(N)+Math.abs(O)+Math.abs(T),N/=C,O/=C,T/=C,u!==l)&&!(Math.abs(i.get(u,u-1))*(Math.abs(O)+Math.abs(T))<k*(Math.abs(N)*(Math.abs(i.get(u-1,u-1))+Math.abs(A)+Math.abs(i.get(u+1,u+1)))));)u--;for(o=u+2;o<=x;o++)i.set(o,o-2,0),o>u+2&&i.set(o,o-3,0);for(s=u;s<=x-1&&(y=s!==x-1,s!==u&&(N=i.get(s,s-1),O=i.get(s+1,s-1),T=y?i.get(s+2,s-1):0,d=Math.abs(N)+Math.abs(O)+Math.abs(T),0!==d&&(N/=d,O/=d,T/=d)),0!==d);s++)if(C=Math.sqrt(N*N+O*O+T*T),N<0&&(C=-C),0!==C){for(s!==u?i.set(s,s-1,-C*d):l!==u&&i.set(s,s-1,-i.get(s,s-1)),N+=C,d=N/C,f=O/C,A=T/C,O/=N,T/=N,a=s;a<t;a++)N=i.get(s,a)+O*i.get(s+1,a),y&&(N+=T*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-N*A)),i.set(s,a,i.get(s,a)-N*d),i.set(s+1,a,i.get(s+1,a)-N*f);for(o=0;o<=Math.min(x,s+3);o++)N=d*i.get(o,s)+f*i.get(o,s+1),y&&(N+=A*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-N*T)),i.set(o,s,i.get(o,s)-N),i.set(o,s+1,i.get(o,s+1)-N*O);for(o=E;o<=w;o++)N=d*r.get(o,s)+f*r.get(o,s+1),y&&(N+=A*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-N*T)),r.set(o,s,r.get(o,s)-N),r.set(o,s+1,r.get(o,s+1)-N*O)}}}if(0===S)return;for(x=t-1;x>=0;x--)if(N=n[x],O=e[x],0===O)for(l=x,i.set(x,x,1),o=x-1;o>=0;o--){for(h=i.get(o,o)-N,T=0,a=l;a<=x;a++)T+=i.get(o,a)*i.get(a,x);if(e[o]<0)A=h,C=T;else if(l=o,0===e[o]?i.set(o,x,0!==h?-T/h:-T/(k*S)):(d=i.get(o,o+1),f=i.get(o+1,o),O=(n[o]-N)*(n[o]-N)+e[o]*e[o],c=(d*C-A*T)/O,i.set(o,x,c),i.set(o+1,x,Math.abs(d)>Math.abs(A)?(-T-h*c)/d:(-C-f*c)/A)),c=Math.abs(i.get(o,x)),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/c)}else if(O<0)for(l=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,O/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-N)/i.get(x,x-1))):(b=zx(0,-i.get(x-1,x),i.get(x-1,x-1)-N,O),i.set(x-1,x-1,b[0]),i.set(x-1,x,b[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=l;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(h=i.get(o,o)-N,e[o]<0)A=h,T=p,C=g;else if(l=o,0===e[o]?(b=zx(-p,-g,h,O),i.set(o,x-1,b[0]),i.set(o,x,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),v=(n[o]-N)*(n[o]-N)+e[o]*e[o]-O*O,m=2*(n[o]-N)*O,0===v&&0===m&&(v=k*S*(Math.abs(h)+Math.abs(O)+Math.abs(d)+Math.abs(f)+Math.abs(A))),b=zx(d*T-A*p+O*g,d*C-A*g-O*p,v,m),i.set(o,x-1,b[0]),i.set(o,x,b[1]),Math.abs(d)>Math.abs(A)+Math.abs(O)?(i.set(o+1,x-1,(-p-h*i.get(o,x-1)+O*i.get(o,x))/d),i.set(o+1,x,(-g-h*i.get(o,x)-O*i.get(o,x-1))/d)):(b=zx(-T-f*i.get(o,x-1),-C-f*i.get(o,x),A,O),i.set(o+1,x-1,b[0]),i.set(o+1,x,b[1]))),c=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/c),i.set(a,x,i.get(a,x)/c)}for(o=0;o<t;o++)if(o<E||o>w)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=E;a--)for(o=E;o<=w;o++){for(A=0,s=E;s<=Math.min(a,w);s++)A+=r.get(o,s)*i.get(s,a);r.set(o,a,A)}}(o,l,s,a,t)}this.n=o,this.e=l,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 Sx(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function zx(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 Gx{constructor(t){if(!(t=Px.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new Sx(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=a.get(r,e)*a.get(n,e);o=(i.get(n,r)-o)/a.get(r,r),a.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&&=t>0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)a.set(n,r,0)}this.L=a,this.positiveDefinite=s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=Px.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,a=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<a;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<a;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class Vx{constructor(t,e={}){t=Px.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=ax.isAnyArray(n)&&"number"==typeof n[0]?Sx.columnVector(n):Px.checkMatrix(n),n.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=t.getColumnVector(0);let s,l,u,c,h=1;for(let e=0;e<i&&h>o;e++)u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),s=t.mmul(u).div(u.transpose().mmul(u).get(0,0)),e>0&&(h=s.clone().sub(c).pow(2).sum()),c=s.clone(),n?(l=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=n.mmul(l).div(l.transpose().mmul(l).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),i=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),o=n.clone().sub(s.clone().mulS(i.get(0,0)).mmul(l.transpose()));this.t=s,this.p=e.transpose(),this.w=u.transpose(),this.q=l,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=u.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(u.transpose()))}}tx.AbstractMatrix=kx,tx.CHO=Gx,tx.CholeskyDecomposition=Gx,tx.DistanceMatrix=Ox,tx.EVD=Fx,tx.EigenvalueDecomposition=Fx,tx.LU=Rx,tx.LuDecomposition=Rx;var Wx=tx.Matrix=Sx;tx.MatrixColumnSelectionView=class extends Tx{constructor(t,e){yx(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])}},tx.MatrixColumnView=class extends Tx{constructor(t,e){px(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)}},tx.MatrixFlipColumnView=class extends Tx{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)}},tx.MatrixFlipRowView=class extends Tx{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)}},tx.MatrixRowSelectionView=class extends Tx{constructor(t,e){mx(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)}},tx.MatrixRowView=class extends Tx{constructor(t,e){fx(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)}},tx.MatrixSelectionView=Cx,tx.MatrixSubView=class extends Tx{constructor(t,e,n,r,i){bx(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)}},tx.MatrixTransposeView=class extends Tx{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)}},tx.NIPALS=Vx,tx.Nipals=Vx,tx.QR=Lx,tx.QrDecomposition=Lx,tx.SVD=_x;var Hx=tx.SingularValueDecomposition=_x;tx.SymmetricMatrix=Nx,tx.WrapperMatrix1D=Ax,tx.WrapperMatrix2D=Px,tx.correlation=function(t,e=t,n={}){t=new Sx(t);let r=!1;if("object"!=typeof e||Sx.isMatrix(e)||ax.isAnyArray(e)?e=new Sx(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:o=!0}=n;i&&(t.center("column"),r||e.center("column")),o&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),l=t.transpose().mmul(e);for(let e=0;e<l.rows;e++)for(let n=0;n<l.columns;n++)l.set(e,n,l.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return l},tx.covariance=function(t,e=t,n={}){t=new Sx(t);let r=!1;if("object"!=typeof e||Sx.isMatrix(e)||ax.isAnyArray(e)?e=new Sx(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(t=t.center("column"),r||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e<o.rows;e++)for(let n=0;n<o.columns;n++)o.set(e,n,o.get(e,n)*(1/(t.rows-1)));return o};var Ux=tx.default=Sx;tx.determinant=function t(e){if((e=Sx.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,a,s;return o=new Cx(e,[1,2],[1,2]),a=new Cx(e,[1,2],[0,2]),s=new Cx(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(a)+i*t(s)}return new Rx(e).determinant}throw Error("determinant can only be calculated for a square matrix")},tx.inverse=function(t,e=!1){return t=Px.checkMatrix(t),e?new _x(t).inverse():Ix(t,Sx.eye(t.rows))},tx.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=Sx.checkMatrix(t)).rows,o=new Sx(i,i);for(let e=0;e<i;e++){let a=Sx.columnVector(t.getRow(e)),s=t.subMatrixRow(jx(i,e)).transpose(),l=new _x(s).solve(a),u=Sx.sub(a,s.mmul(l)).abs().max();o.setRow(e,Bx(u,l,e,n,r))}return o},tx.pseudoInverse=function(t,e=Number.EPSILON){if((t=Sx.checkMatrix(t)).isEmpty())return t.transpose();let n=new _x(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(Sx.diag(o).mmul(r.transpose()))},tx.solve=Ix,tx.wrap=function(t,e){if(ax.isAnyArray(t))return t[0]&&ax.isAnyArray(t[0])?new Px(t):new Ax(t,e);throw new Error("the argument is not an array")};const $x=Wx,Yx=Hx;Ux.Matrix&&Ux.Matrix;const qx={center:[0,0],linkDistance:50};class Xx{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},qx),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i=[0,0],linkDistance:o=50}=r,a=e.getAllNodes(),s=e.getAllEdges();if(!(null==a?void 0:a.length)||1===a.length)return bb(e,t,i);const l=sb({nodes:a,edges:s}),u=ab(l);Kx(u);const c=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(u,o),h=Zx(c),d=[];h.forEach(((t,e)=>{const n=hb(a[e]);n.data.x=t[0]+i[0],n.data.y=t[1]+i[1],d.push(n)})),t&&d.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:d,edges:s}}))}}const Kx=t=>{let e=-999999;t.forEach((t=>{t.forEach((t=>{t!==1/0&&e<t&&(e=t)}))})),t.forEach(((n,r)=>{n.forEach(((n,i)=>{n===1/0&&(t[r][i]=e)}))}))},Zx=t=>{const e=$x.mul($x.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);const o=new Yx(e),a=$x.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>$x.mul([t],[a]).toJSON()[0].splice(0,2)))};function Qx(t){return!!t.tick&&!!t.stop}const Jx={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},tE={center:[0,0],comboPadding:10,treeKey:"combo"};class eE{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},tE),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:i,treeKey:o,outerLayout:a}=r,s=e.getAllNodes().filter((t=>!t.data._isCombo)),l=e.getAllNodes().filter((t=>t.data._isCombo)),u=e.getAllEdges(),c=null==s?void 0:s.length;if(!c||1===c)return bb(e,t,i);const h=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;l.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,u,r,p);yield Promise.all(g);const v=new Map,m=[],y=new Map;let b=!0;e.getRoots(o).forEach((t=>{const n=p.get(t.id),r=f.get(t.id)||d.get(t.id),i={id:t.id,data:Object.assign(Object.assign({},t.data),{x:n.data.x||r.data.x,y:n.data.y||r.data.y,fx:n.data.fx||r.data.fx,fy:n.data.fy||r.data.fy,mass:n.data.mass||r.data.mass,size:n.data.size})};m.push(i),v.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):b=!1,ub(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const x=[];let E;if(u.forEach((t=>{const e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&v.has(e)&&v.has(n)&&x.push({id:t.id,source:e,target:n,data:{}})})),null==m?void 0:m.length){if(1===m.length)m[0].data.x=i[0],m[0].data.y=i[1];else{const t=new Yg({nodes:m,edges:x}),e=a||new qb;if(b&&Jx[e.id]){const e=m.length<100?new Xx:new Sb;yield e.assign(t)}const n=Object.assign({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===e.id?{gravity:1,factor:4,linkDistance:(t,e,n)=>(Math.max(...e.data.size)||32)/2+(Math.max(...n.data.size)||32)/2+200}:{});E=yield nE(e,t,n)}p.forEach((t=>{var e;const n=E.nodes.find((e=>e.id===t.id));if(n){const{x:e,y:r}=n.data;t.data.visited=!0,t.data.x=e,t.data.y=r,h.push({id:t.id,data:{x:e,y:r}})}const{x:r,y:i}=t.data;null===(e=t.data.nodes)||void 0===e||e.forEach((t=>{h.push({id:t.id,data:{x:t.data.x+r,y:t.data.y+i}})}))})),p.forEach((({data:t})=>{const{x:e,y:n,visited:r,nodes:i}=t;null==i||i.forEach((t=>{if(!r){const r=h.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&h.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:h,edges:u}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=ae(r)?()=>r:Ut(r)?r:()=>0,e.spacing=a,n)if(Ut(n))o=t=>{const e=n(t),r=a(t);if(ob(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(ob(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)/2}else{const t=n/2;o=e=>t+a(e)/2}else o=t=>{const e=a(t);if(t.size){if(ob(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(qt(t.size)){return((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2}return(t.size+e)/2}return 32+e/2};return e.nodeSize=o,s=ae(i)?()=>i:ob(i)?()=>Math.max.apply(null,i):Ut(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,a){const{nodeSize:s,comboPadding:l,spacing:u,innerLayout:c}=o,h=c||new Sb({}),d={center:[0,0],preventOverlap:!0,nodeSpacing:u},f=[],p=t=>{let e=(null==l?void 0:l(t))||10;return ob(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{a.set(o.id,{id:o.id,data:{nodes:[],size:p(o).size}});let l=Promise.resolve();ub(t,[o],(o=>{var u;if(!o.data._isCombo)return;const{size:c,padding:f}=p(o);if(null===(u=t.getChildren(o.id,e))||void 0===u?void 0:u.length){const u=a.get(o.id);a.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==u?void 0:u.data)});const c=new Map,p=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return a.has(t.id)||a.set(t.id,{id:t.id,data:Object.assign({},t.data)}),c.set(t.id,!0),a.get(t.id);const e=n.get(t.id)||r.get(t.id);return c.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),g={nodes:p,edges:i.filter((t=>c.has(t.source)&&c.has(t.target)))};let v=1/0;p.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=a.get(t.id))||void 0===e?void 0:e.data.size)||(null==s?void 0:s(t))||[30,30]),ae(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),l=l.then((()=>ze(this,void 0,void 0,(function*(){const t=new Yg(g);yield nE(h,t,d,!0);const{minX:e,minY:n,maxX:r,maxY:i}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;ob(o)?1===o.length&&(o=[o[0],o[0]]):ae(o)?o=[o,o]:(void 0===o||isNaN(o))&&(o=[30,30]);const a=[o[0]/2,o[1]/2],s=t.data.x-a[0],l=t.data.x+a[0],u=t.data.y-a[1],c=t.data.y+a[1];e>s&&(e=s),n>u&&(n=u),r<l&&(r=l),i<c&&(i=c)})),{minX:e,minY:n,maxX:r,maxY:i}})(p),s=(r+e)/2,l=(i+n)/2;g.nodes.forEach((t=>{t.data.x-=s,t.data.y-=l}));const u=[Math.max(r-e,v)+2*f,Math.max(i-n,v)+2*f];a.get(o.id).data.size=u,a.get(o.id).data.nodes=p}))))}else a.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:c})});return!0}),"BT",e),f.push(l)})),f}}function nE(t,e,n,r){var i;return ze(this,void 0,void 0,(function*(){return Qx(t)?(t.execute(e,n),t.stop(),t.tick(null!==(i=n.iterations)&&void 0!==i?i:300)):r?yield t.assign(e,n):yield t.execute(e,n)}))}function rE(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,l=0;for(i=0;i<a;++i)s+=(o=n[i]).x,l+=o.y;for(s=(s/a-t)*r,l=(l/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=l}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function iE(t){return function(){return t}}function oE(t){return 1e-6*(t()-.5)}function aE(t){return t.x+t.vx}function sE(t){return t.y+t.vy}function lE(t){var e,n,r,i=1,o=1;function a(){for(var t,a,l,u,c,h,d,f=e.length,p=0;p<o;++p)for(a=Ab(e,aE,sE).visitAfter(s),t=0;t<f;++t)l=e[t],h=n[l.index],d=h*h,u=l.x+l.vx,c=l.y+l.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=h+f;if(!s)return e>u+p||o<u-p||n>c+p||a<c-p;if(s.index>l.index){var g=u-s.x-s.vx,v=c-s.y-s.vy,m=g*g+v*v;m<p*p&&(0===g&&(m+=(g=oE(r))*g),0===v&&(m+=(v=oE(r))*v),m=(p-(m=Math.sqrt(m)))/m*i,l.vx+=(g*=m)*(p=(f*=f)/(d+f)),l.vy+=(v*=m)*p,s.vx-=g*(p=1-p),s.vy-=v*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function l(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=iE(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,l()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),l(),a):t},a}function uE(t){return t.index}function cE(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function hE(t){var e,n,r,i,o,a,s=uE,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},u=iE(30),c=1;function h(r){for(var i=0,s=t.length;i<c;++i)for(var l,u,h,d,f,p,g,v=0;v<s;++v)u=(l=t[v]).source,d=(h=l.target).x+h.vx-u.x-u.vx||oE(a),f=h.y+h.vy-u.y-u.vy||oE(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[v])/p*r*e[v],f*=p,h.vx-=d*(g=o[v]),h.vy-=f*g,u.vx+=d*(g=1-g),u.vy+=f*g}function d(){if(r){var a,l,u=r.length,c=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(u);a<c;++a)(l=t[a]).index=a,"object"!=typeof l.source&&(l.source=cE(h,l.source)),"object"!=typeof l.target&&(l.target=cE(h,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(a=0,o=new Array(c);a<c;++a)l=t[a],o[a]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(c),f(),n=new Array(c),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+u(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,a=e,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(c=+t,h):c},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:iE(+t),f(),h):l},h.distance=function(t){return arguments.length?(u="function"==typeof t?t:iE(+t),p(),h):u},h}var dE={value:()=>{}};function fE(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new pE(r)}function pE(t){this._=t}function gE(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function vE(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=dE,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}pE.prototype=fE.prototype={constructor:pE,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=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(;++a<s;)if(n=(t=o[a]).type)i[n]=vE(i[n],t.name,e);else if(null==e)for(n in i)i[n]=vE(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=gE(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new pE(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var mE,yE,bE=0,xE=0,EE=0,wE=0,kE=0,ME=0,SE="object"==typeof performance&&performance.now?performance:Date,NE="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function OE(){return kE||(NE(TE),kE=SE.now()+ME)}function TE(){kE=0}function CE(){this._call=this._time=this._next=null}function AE(t,e,n){var r=new CE;return r.restart(t,e,n),r}function PE(){kE=(wE=SE.now())+ME,bE=xE=0;try{!function(){OE(),++bE;for(var t,e=mE;e;)(t=kE-e._time)>=0&&e._call.call(void 0,t),e=e._next;--bE}()}finally{bE=0,function(){var t,e,n=mE,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:mE=e);yE=t,DE(r)}(),kE=0}}function RE(){var t=SE.now(),e=t-wE;e>1e3&&(ME-=e,wE=t)}function DE(t){bE||(xE&&(xE=clearTimeout(xE)),t-kE>24?(t<1/0&&(xE=setTimeout(PE,t-SE.now()-ME)),EE&&(EE=clearInterval(EE))):(EE||(wE=SE.now(),EE=setInterval(RE,1e3)),bE=1,NE(PE)))}CE.prototype=AE.prototype={constructor:CE,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?OE():+n)+(null==e?0:+e),this._next||yE===this||(yE?yE._next=this:mE=this,yE=this),this._call=t,this._time=n,DE()},stop:function(){this._call&&(this._call=null,this._time=1/0,DE())}};const LE=4294967296;function _E(t){return t.x}function IE(t){return t.y}var jE=Math.PI*(3-Math.sqrt(5));function BE(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=AE(h),u=fE("tick","end"),c=function(){let t=1;return()=>(t=(1664525*t+1013904223)%LE)/LE}();function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(r){var l,u,c=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),l=0;l<c;++l)null==(u=t[l]).fx?u.x+=u.vx*=a:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=a:(u.y=u.fy,u.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),o=n*jE;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,c),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(o=+t,e):o},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(c=t,s.forEach(p),e):c},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,l,u=0,c=t.length;for(null==r?r=1/0:r*=r,u=0;u<c;++u)(a=(i=e-(s=t[u]).x)*i+(o=n-s.y)*o)<r&&(l=s,r=a);return l},on:function(t,n){return arguments.length>1?(u.on(t,n),e):u.on(t)}}}function FE(){var t,e,n,r,i,o=iE(-30),a=1,s=1/0,l=.81;function u(n){var i,o=t.length,a=Ab(t,_E,IE).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function c(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+o(n,e,t)}}function h(t){var e,n,r,o,a,s=0,l=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,l+=n,r+=n*e.x,o+=n*e.y);t.x=r/l,t.y=o/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index]}while(e=e.next)}t.value=s}function d(t,o,u,c){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,f=c-o,p=h*h+d*d;if(f*f/l<p)return p<s&&(0===h&&(p+=(h=oE(n))*h),0===d&&(p+=(d=oE(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=h*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=oE(n))*h),0===d&&(p+=(d=oE(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=h*f,e.vy+=d*f)}while(t=t.next)}}return u.initialize=function(e,r){t=e,n=r,c()},u.strength=function(t){return arguments.length?(o="function"==typeof t?t:iE(+t),c(),u):o},u.distanceMin=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.distanceMax=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.theta=function(t){return arguments.length?(l=t*t,u):Math.sqrt(l)},u}function zE(t,e,n){var r,i,o,a=iE(.1);function s(t){for(var a=0,s=r.length;a<s;++a){var l=r[a],u=l.x-e||1e-6,c=l.y-n||1e-6,h=Math.sqrt(u*u+c*c),d=(o[a]-h)*i[a]*t/h;l.vx+=u*d,l.vy+=c*d}}function l(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+a(r[e],e,r)}}return"function"!=typeof t&&(t=iE(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,l()},s.strength=function(t){return arguments.length?(a="function"==typeof t?t:iE(+t),l(),s):a},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),l(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function GE(t){var e,n,r,i=iE(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=iE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:iE(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),a(),o):t},o}function VE(t){var e,n,r,i=iE(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=iE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:iE(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),a(),o):t},o}class WE{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:hE,manyBody:FE,center:rE,collide:lE,radial:zE,x:GE,y:VE},this.options={link:{id:t=>t.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},ke(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,e)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const n=this.context.nodes.find((e=>e.id===t));n&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){n[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,n;const r=ke({},this.options,t);return r.collide&&void 0===(null===(e=r.collide)||void 0===e?void 0:e.radius)&&(r.collide=r.collide||{},r.collide.radius=null!==(n=r.nodeSize)&&void 0!==n?n:10),void 0===r.iterations&&(r.link&&void 0===r.link.iterations&&(r.iterations=r.link.iterations),r.collide&&void 0===r.collide.iterations&&(r.iterations=r.collide.iterations)),this.context.options=r,r}genericLayout(t,e,n){var r;return ze(this,void 0,void 0,(function*(){const i=this.getOptions(n),o=e.getAllNodes().map((({id:t,data:e})=>Object.assign(Object.assign({id:t},e),Ae(e.data,this.config.inputNodeAttrs)))),a=e.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const s=new Promise((t=>{this.resolver=t})),l=this.setSimulation(i);return l.nodes(o),null===(r=l.force("link"))||void 0===r||r.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:n,graph:r}=this.context,i=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),Ae(t,this.config.outputNodeAttrs))}))),o=n.map((({id:t,source:e,target:n,data:r})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof n?n.id:n,data:r})));return t&&i.forEach((t=>r.mergeNodeData(t.id,t.data))),{nodes:i,edges:o}}initSimulation(){return BE()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),HE(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([n,r])=>{const i=n;if(t[n]){let n=e.force(i);n||(n=r(),e.force(i,n)),HE(n,Object.entries(t[i]))}else e.force(i,null)})),e}}const HE=(t,e)=>e.reduce(((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e),t);var UE,$E,YE,qE,XE,KE,ZE,QE,JE,tw,ew,nw,rw,iw,ow,aw,sw,lw,uw,cw,hw,dw,fw,pw,gw,vw,mw,yw,bw,xw,Ew,ww,kw,Mw,Sw,Nw,Ow,Tw,Cw,Aw,Pw,Rw,Dw,Lw,_w,Iw,jw,Bw,Fw,zw,Gw,Vw,Ww,Hw,Uw,$w,Yw,qw,Xw,Kw,Zw,Qw,Jw,tk,ek,nk,rk,ik,ok,ak,sk,lk,uk,ck,hk,dk,fk,pk,gk,vk,mk,yk,bk,xk,Ek,wk,kk,Mk,Sk,Nk,Ok,Tk,Ck,Ak,Pk,Rk,Dk,Lk,_k,Ik,jk,Bk,Fk,zk,Gk,Vk,Wk,Hk;function Uk(){if(qE)return YE;return qE=1,YE=function(t,e){return t===e||t!=t&&e!=e}}function $k(){if(KE)return XE;KE=1;var t=Uk();return XE=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},XE}function Yk(){if(aw)return ow;aw=1;var t=$E?UE:($E=1,UE=function(){this.__data__=[],this.size=0}),e=function(){if(QE)return ZE;QE=1;var t=$k(),e=Array.prototype.splice;return ZE=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))},ZE}(),n=function(){if(tw)return JE;tw=1;var t=$k();return JE=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},JE}(),r=function(){if(nw)return ew;nw=1;var t=$k();return ew=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(iw)return rw;iw=1;var t=$k();return rw=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},rw}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,ow=o}function qk(){if(vw)return gw;vw=1;var t="object"==typeof x&&x&&x.Object===Object&&x;return gw=t}function Xk(){if(yw)return mw;yw=1;var t=qk(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return mw=n}function Kk(){if(xw)return bw;xw=1;var t=Xk().Symbol;return bw=t}function Zk(){if(Nw)return Sw;Nw=1;var t=Kk(),e=function(){if(ww)return Ew;ww=1;var t=Kk(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return Ew=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var a=!0}catch(t){}var s=r.call(t);return a&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(Mw)return kw;Mw=1;var t=Object.prototype.toString;return kw=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return Sw=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function Qk(){if(Tw)return Ow;return Tw=1,Ow=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Jk(){if(Aw)return Cw;Aw=1;var t=Zk(),e=Qk();return Cw=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function tM(){if(Lw)return Dw;Lw=1;var t,e=function(){if(Rw)return Pw;Rw=1;var t=Xk()["__core-js_shared__"];return Pw=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Dw=function(t){return!!n&&n in t}}function eM(){if(Iw)return _w;Iw=1;var t=Function.prototype.toString;return _w=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function nM(){if(Vw)return Gw;Vw=1;var t=function(){if(Bw)return jw;Bw=1;var t=Jk(),e=tM(),n=Qk(),r=eM(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,u=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return jw=function(o){return!(!n(o)||e(o))&&(t(o)?u:i).test(r(o))}}(),e=zw?Fw:(zw=1,Fw=function(t,e){return null==t?void 0:t[e]});return Gw=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function rM(){if(Hw)return Ww;Hw=1;var t=nM()(Xk(),"Map");return Ww=t}function iM(){if($w)return Uw;$w=1;var t=nM()(Object,"create");return Uw=t}function oM(){if(ik)return rk;ik=1;var t=function(){if(qw)return Yw;qw=1;var t=iM();return Yw=function(){this.__data__=t?t(null):{},this.size=0}}(),e=Kw?Xw:(Kw=1,Xw=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Qw)return Zw;Qw=1;var t=iM(),e=Object.prototype.hasOwnProperty;return Zw=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},Zw}(),r=function(){if(tk)return Jw;tk=1;var t=iM(),e=Object.prototype.hasOwnProperty;return Jw=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},Jw}(),i=function(){if(nk)return ek;nk=1;var t=iM();return ek=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},ek}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,rk=o}function aM(){if(ck)return uk;ck=1;var t=lk?sk:(lk=1,sk=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return uk=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},uk}function sM(){if(xk)return bk;xk=1;var t=function(){if(ak)return ok;ak=1;var t=oM(),e=Yk(),n=rM();return ok=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(dk)return hk;dk=1;var t=aM();return hk=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(pk)return fk;pk=1;var t=aM();return fk=function(e){return t(this,e).get(e)}}(),r=function(){if(vk)return gk;vk=1;var t=aM();return gk=function(e){return t(this,e).has(e)}}(),i=function(){if(yk)return mk;yk=1;var t=aM();return mk=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},mk}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,bk=o}function lM(){if(Mk)return kk;Mk=1;var t=Yk(),e=function(){if(lw)return sw;lw=1;var t=Yk();return sw=function(){this.__data__=new t,this.size=0}}(),n=(cw||(cw=1,uw=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),uw),r=dw?hw:(dw=1,hw=function(t){return this.__data__.get(t)}),i=pw?fw:(pw=1,fw=function(t){return this.__data__.has(t)}),o=function(){if(wk)return Ek;wk=1;var t=Yk(),e=rM(),n=sM();return Ek=function(r,i){var o=this.__data__;if(o instanceof t){var a=o.__data__;if(!e||a.length<199)return a.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(a)}return o.set(r,i),this.size=o.size,this},Ek}();function a(e){var n=this.__data__=new t(e);this.size=n.size}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,kk=a}function uM(){if(Nk)return Sk;return Nk=1,Sk=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},Sk}function cM(){if(Tk)return Ok;Tk=1;var t=nM(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Ok=e}function hM(){if(Ak)return Ck;Ak=1;var t=cM();return Ck=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function dM(){if(Rk)return Pk;Rk=1;var t=hM(),e=Uk(),n=Object.prototype.hasOwnProperty;return Pk=function(r,i,o){var a=r[i];n.call(r,i)&&e(a,o)&&(void 0!==o||i in r)||t(r,i,o)}}function fM(){if(Lk)return Dk;Lk=1;var t=dM(),e=hM();return Dk=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,l=r.length;++s<l;){var u=r[s],c=o?o(i[u],n[u],u,i,n):void 0;void 0===c&&(c=n[u]),a?e(i,u,c):t(i,u,c)}return i},Dk}function pM(){if(Bk)return jk;return Bk=1,jk=function(t){return null!=t&&"object"==typeof t}}function gM(){if(Vk)return Gk;Vk=1;var t=function(){if(zk)return Fk;zk=1;var t=Zk(),e=pM();return Fk=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=pM(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return Gk=o}function vM(){if(Hk)return Wk;Hk=1;var t=Array.isArray;return Wk=t}var mM,yM,bM,xM,EM,wM,kM,MM,SM,NM,OM,TM={exports:{}};function CM(){return bM||(bM=1,function(t,e){var n=Xk(),r=yM?mM:(yM=1,mM=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,a=o&&o.exports===i?n.Buffer:void 0,s=(a?a.isBuffer:void 0)||r;t.exports=s}(TM,TM.exports)),TM.exports}function AM(){if(EM)return xM;EM=1;var t=/^(?:0|[1-9]\d*)$/;return xM=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},xM}function PM(){if(kM)return wM;kM=1;return wM=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function RM(){if(OM)return NM;return OM=1,NM=function(t){return function(e){return t(e)}}}var DM,LM,_M,IM,jM,BM,FM,zM,GM,VM,WM,HM,UM,$M,YM,qM,XM,KM,ZM,QM,JM,tS,eS,nS,rS,iS,oS,aS={exports:{}};function sS(){return DM||(DM=1,function(t,e){var n=qk(),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}(aS,aS.exports)),aS.exports}function lS(){if(_M)return LM;_M=1;var t=function(){if(SM)return MM;SM=1;var t=Zk(),e=PM(),n=pM(),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,MM=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=RM(),n=sS(),r=n&&n.isTypedArray,i=r?e(r):t;return LM=i}function uS(){if(jM)return IM;jM=1;var t=(Ik||(Ik=1,_k=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),_k),e=gM(),n=vM(),r=CM(),i=AM(),o=lS(),a=Object.prototype.hasOwnProperty;return IM=function(s,l){var u=n(s),c=!u&&e(s),h=!u&&!c&&r(s),d=!u&&!c&&!h&&o(s),f=u||c||h||d,p=f?t(s.length,String):[],g=p.length;for(var v in s)!l&&!a.call(s,v)||f&&("length"==v||h&&("offset"==v||"parent"==v)||d&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||i(v,g))||p.push(v);return p},IM}function cS(){if(FM)return BM;FM=1;var t=Object.prototype;return BM=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function hS(){if(GM)return zM;return GM=1,zM=function(t,e){return function(n){return t(e(n))}}}function dS(){if(UM)return HM;UM=1;var t=cS(),e=function(){if(WM)return VM;WM=1;var t=hS()(Object.keys,Object);return VM=t}(),n=Object.prototype.hasOwnProperty;return HM=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function fS(){if(YM)return $M;YM=1;var t=Jk(),e=PM();return $M=function(n){return null!=n&&e(n.length)&&!t(n)}}function pS(){if(XM)return qM;XM=1;var t=uS(),e=dS(),n=fS();return qM=function(r){return n(r)?t(r):e(r)}}function gS(){if(eS)return tS;eS=1;var t=Qk(),e=cS(),n=JM?QM:(JM=1,QM=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return tS=function(i){if(!t(i))return n(i);var o=e(i),a=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&a.push(s);return a}}function vS(){if(rS)return nS;rS=1;var t=uS(),e=gS(),n=fS();return nS=function(r){return n(r)?t(r,!0):e(r)}}var mS,yS,bS,xS,ES,wS,kS,MS,SS,NS,OS,TS,CS,AS,PS,RS,DS,LS,_S,IS,jS,BS,FS,zS,GS,VS,WS,HS,US,$S,YS,qS,XS,KS,ZS,QS,JS,tN,eN,nN,rN,iN,oN,aN,sN,lN,uN,cN,hN,dN,fN,pN,gN,vN,mN,yN,bN,xN,EN,wN,kN,MN,SN,NN,ON,TN,CN,AN,PN,RN,DN,LN,_N,IN,jN,BN,FN,zN,GN,VN,WN,HN,UN,$N,YN,qN,XN,KN,ZN,QN,JN,tO,eO,nO,rO,iO,oO,aO,sO,lO,uO,cO,hO,dO,fO,pO,gO,vO,mO,yO,bO,xO,EO,wO,kO,MO,SO,NO,OO,TO,CO,AO,PO,RO,DO,LO,_O,IO,jO,BO,FO,zO,GO,VO,WO,HO,UO,$O,YO,qO,XO,KO,ZO,QO,JO,tT,eT,nT,rT,iT,oT,aT,sT,lT,uT,cT,hT,dT,fT,pT,gT,vT,mT,yT,bT,xT,ET,wT,kT,MT,ST,NT,OT,TT,CT,AT,PT,RT,DT,LT,_T,IT,jT,BT,FT,zT,GT,VT,WT,HT,UT,$T,YT,qT,XT,KT,ZT,QT,JT,tC,eC,nC,rC,iC,oC,aC,sC,lC,uC,cC,hC,dC,fC,pC,gC,vC,mC,yC,bC,xC,EC,wC,kC,MC,SC,NC,OC,TC,CC,AC,PC,RC,DC,LC,_C,IC,jC,BC,FC,zC,GC,VC,WC,HC,UC,$C,YC,qC,XC,KC,ZC,QC,JC,tA,eA,nA,rA,iA,oA,aA,sA,lA,uA,cA,hA,dA,fA,pA,gA,vA,mA,yA,bA,xA,EA,wA,kA,MA,SA,NA,OA={exports:{}};function TA(){return mS||(mS=1,function(t,e){var n=Xk(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,a=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=a?a(n):new t.constructor(n);return t.copy(r),r}}(OA,OA.exports)),OA.exports}function CA(){if(bS)return yS;return bS=1,yS=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},yS}function AA(){if(ES)return xS;return ES=1,xS=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a,n,t)&&(o[i++]=a)}return o},xS}function PA(){if(kS)return wS;return kS=1,wS=function(){return[]}}function RA(){if(SS)return MS;SS=1;var t=AA(),e=PA(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return MS=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function DA(){if(CS)return TS;return CS=1,TS=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},TS}function LA(){if(PS)return AS;PS=1;var t=hS()(Object.getPrototypeOf,Object);return AS=t}function _A(){if(DS)return RS;DS=1;var t=DA(),e=LA(),n=RA(),r=PA(),i=Object.getOwnPropertySymbols;return RS=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function IA(){if(jS)return IS;jS=1;var t=DA(),e=vM();return IS=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function jA(){if(FS)return BS;FS=1;var t=IA(),e=RA(),n=pS();return BS=function(r){return t(r,n,e)}}function BA(){if(YS)return $S;YS=1;var t=nM()(Xk(),"Set");return $S=t}function FA(){if(ZS)return KS;ZS=1;var t=function(){if(WS)return VS;WS=1;var t=nM()(Xk(),"DataView");return VS=t}(),e=rM(),n=function(){if(US)return HS;US=1;var t=nM()(Xk(),"Promise");return HS=t}(),r=BA(),i=function(){if(XS)return qS;XS=1;var t=nM()(Xk(),"WeakMap");return qS=t}(),o=Zk(),a=eM(),s="[object Map]",l="[object Promise]",u="[object Set]",c="[object WeakMap]",h="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),v=a(i),m=o;return(t&&m(new t(new ArrayBuffer(1)))!=h||e&&m(new e)!=s||n&&m(n.resolve())!=l||r&&m(new r)!=u||i&&m(new i)!=c)&&(m=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?a(n):"";if(r)switch(r){case d:return h;case f:return s;case p:return l;case g:return u;case v:return c}return e}),KS=m}function zA(){if(eN)return tN;eN=1;var t=Xk().Uint8Array;return tN=t}function GA(){if(rN)return nN;rN=1;var t=zA();return nN=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function VA(){if(hN)return cN;hN=1;var t=GA();return cN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function WA(){if(fN)return dN;fN=1;var t=GA(),e=function(){if(oN)return iN;oN=1;var t=GA();return iN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(sN)return aN;sN=1;var t=/\w*$/;return aN=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(uN)return lN;uN=1;var t=Kk(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return lN=function(t){return n?Object(n.call(t)):{}}}(),i=VA();return dN=function(o,a,s){var l=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new l(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function HA(){if(gN)return pN;gN=1;var t=Qk(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return pN=n}function UA(){if(mN)return vN;mN=1;var t=HA(),e=LA(),n=cS();return vN=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function $A(){if(EN)return xN;EN=1;var t=function(){if(bN)return yN;bN=1;var t=FA(),e=pM();return yN=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=RM(),n=sS(),r=n&&n.isMap,i=r?e(r):t;return xN=i}function YA(){if(SN)return MN;SN=1;var t=function(){if(kN)return wN;kN=1;var t=FA(),e=pM();return wN=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=RM(),n=sS(),r=n&&n.isSet,i=r?e(r):t;return MN=i}function qA(){if(ON)return NN;ON=1;var t=lM(),e=uM(),n=dM(),r=function(){if(ZM)return KM;ZM=1;var t=fM(),e=pS();return KM=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(oS)return iS;oS=1;var t=fM(),e=vS();return iS=function(n,r){return n&&t(r,e(r),n)}}(),o=TA(),a=CA(),s=function(){if(OS)return NS;OS=1;var t=fM(),e=RA();return NS=function(n,r){return t(n,e(n),r)}}(),l=function(){if(_S)return LS;_S=1;var t=fM(),e=_A();return LS=function(n,r){return t(n,e(n),r)}}(),u=jA(),c=function(){if(GS)return zS;GS=1;var t=IA(),e=_A(),n=vS();return zS=function(r){return t(r,n,e)}}(),h=FA(),d=function(){if(JS)return QS;JS=1;var t=Object.prototype.hasOwnProperty;return QS=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},QS}(),f=WA(),p=UA(),g=vM(),v=CM(),m=$A(),y=Qk(),b=YA(),x=pS(),E=vS(),w="[object Arguments]",k="[object Function]",M="[object Object]",S={};return S[w]=S["[object Array]"]=S["[object ArrayBuffer]"]=S["[object DataView]"]=S["[object Boolean]"]=S["[object Date]"]=S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Map]"]=S["[object Number]"]=S[M]=S["[object RegExp]"]=S["[object Set]"]=S["[object String]"]=S["[object Symbol]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S["[object Error]"]=S[k]=S["[object WeakMap]"]=!1,NN=function N(O,T,C,A,P,R){var D,L=1&T,_=2&T,I=4&T;if(C&&(D=P?C(O,A,P,R):C(O)),void 0!==D)return D;if(!y(O))return O;var j=g(O);if(j){if(D=d(O),!L)return a(O,D)}else{var B=h(O),F=B==k||"[object GeneratorFunction]"==B;if(v(O))return o(O,L);if(B==M||B==w||F&&!P){if(D=_||F?{}:p(O),!L)return _?l(O,i(D,O)):s(O,r(D,O))}else{if(!S[B])return P?O:{};D=f(O,B,L)}}R||(R=new t);var z=R.get(O);if(z)return z;R.set(O,D),b(O)?O.forEach((function(t){D.add(N(t,T,C,t,O,R))})):m(O)&&O.forEach((function(t,e){D.set(e,N(t,T,C,e,O,R))}));var G=j?void 0:(I?_?c:u:_?E:x)(O);return e(G||O,(function(t,e){G&&(t=O[e=t]),n(D,e,N(t,T,C,e,O,R))})),D},NN}function XA(){if(CN)return TN;CN=1;var t=qA();return TN=function(e){return t(e,4)}}function KA(){if(PN)return AN;return PN=1,AN=function(t){return function(){return t}}}function ZA(){if(_N)return LN;_N=1;var t=(DN||(DN=1,RN=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var l=a[t?s:++i];if(!1===n(o[l],l,o))break}return e}}),RN),e=t();return LN=e}function QA(){if(jN)return IN;jN=1;var t=ZA(),e=pS();return IN=function(n,r){return n&&t(n,r,e)}}function JA(){if(GN)return zN;GN=1;var t=QA(),e=function(){if(FN)return BN;FN=1;var t=fS();return BN=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,a=n?o:-1,s=Object(r);(n?a--:++a<o)&&!1!==i(s[a],a,s););return r}},BN}(),n=e(t);return zN=n}function tP(){if(WN)return VN;return WN=1,VN=function(t){return t}}function eP(){if(UN)return HN;UN=1;var t=tP();return HN=function(e){return"function"==typeof e?e:t}}function nP(){if(YN)return $N;YN=1;var t=uM(),e=JA(),n=eP(),r=vM();return $N=function(i,o){return(r(i)?t:e)(i,n(o))}}function rP(){return XN?qN:(XN=1,qN=nP())}function iP(){if(rO)return nO;rO=1;var t=sM(),e=JN?QN:(JN=1,QN=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=eO?tO:(eO=1,tO=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,nO=r}function oP(){if(sO)return aO;return sO=1,aO=function(t,e){return t.has(e)}}function aP(){if(uO)return lO;uO=1;var t=iP(),e=(oO||(oO=1,iO=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),iO),n=oP();return lO=function(r,i,o,a,s,l){var u=1&o,c=r.length,h=i.length;if(c!=h&&!(u&&h>c))return!1;var d=l.get(r),f=l.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,v=2&o?new t:void 0;for(l.set(r,i),l.set(i,r);++p<c;){var m=r[p],y=i[p];if(a)var b=u?a(y,m,p,i,r,l):a(m,y,p,r,i,l);if(void 0!==b){if(b)continue;g=!1;break}if(v){if(!e(i,(function(t,e){if(!n(v,e)&&(m===t||s(m,t,o,a,l)))return v.push(e)}))){g=!1;break}}else if(m!==y&&!s(m,y,o,a,l)){g=!1;break}}return l.delete(r),l.delete(i),g},lO}function sP(){if(fO)return dO;return fO=1,dO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},dO}function lP(){if(gO)return pO;gO=1;var t=Kk(),e=zA(),n=Uk(),r=aP(),i=(hO||(hO=1,cO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),cO),o=sP(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return pO=function(t,a,l,u,c,h,d){switch(l){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!h(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var f=i;case"[object Set]":var p=1&u;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;u|=2,d.set(t,a);var v=r(f(t),f(a),u,c,h,d);return d.delete(t),v;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function uP(){if(bO)return yO;bO=1;var t=lM(),e=aP(),n=lP(),r=function(){if(mO)return vO;mO=1;var t=jA(),e=Object.prototype.hasOwnProperty;return vO=function(n,r,i,o,a,s){var l=1&i,u=t(n),c=u.length;if(c!=t(r).length&&!l)return!1;for(var h=c;h--;){var d=u[h];if(!(l?d in r:e.call(r,d)))return!1}var f=s.get(n),p=s.get(r);if(f&&p)return f==r&&p==n;var g=!0;s.set(n,r),s.set(r,n);for(var v=l;++h<c;){var m=n[d=u[h]],y=r[d];if(o)var b=l?o(y,m,d,r,n,s):o(m,y,d,n,r,s);if(!(void 0===b?m===y||a(m,y,i,o,s):b)){g=!1;break}v||(v="constructor"==d)}if(g&&!v){var x=n.constructor,E=r.constructor;x==E||!("constructor"in n)||!("constructor"in r)||"function"==typeof x&&x instanceof x&&"function"==typeof E&&E instanceof E||(g=!1)}return s.delete(n),s.delete(r),g},vO}(),i=FA(),o=vM(),a=CM(),s=lS(),l="[object Arguments]",u="[object Array]",c="[object Object]",h=Object.prototype.hasOwnProperty;return yO=function(d,f,p,g,v,m){var y=o(d),b=o(f),x=y?u:i(d),E=b?u:i(f),w=(x=x==l?c:x)==c,k=(E=E==l?c:E)==c,M=x==E;if(M&&a(d)){if(!a(f))return!1;y=!0,w=!1}if(M&&!w)return m||(m=new t),y||s(d)?e(d,f,p,g,v,m):n(d,f,x,p,g,v,m);if(!(1&p)){var S=w&&h.call(d,"__wrapped__"),N=k&&h.call(f,"__wrapped__");if(S||N){var O=S?d.value():d,T=N?f.value():f;return m||(m=new t),v(O,T,p,g,m)}}return!!M&&(m||(m=new t),r(d,f,p,g,v,m))}}function cP(){if(EO)return xO;EO=1;var t=uP(),e=pM();return xO=function n(r,i,o,a,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,a,n,s))},xO}function hP(){if(SO)return MO;SO=1;var t=Qk();return MO=function(e){return e==e&&!t(e)}}function dP(){if(CO)return TO;return CO=1,TO=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function fP(){if(PO)return AO;PO=1;var t=function(){if(kO)return wO;kO=1;var t=lM(),e=cP();return wO=function(n,r,i,o){var a=i.length,s=a,l=!o;if(null==n)return!s;for(n=Object(n);a--;){var u=i[a];if(l&&u[2]?u[1]!==n[u[0]]:!(u[0]in n))return!1}for(;++a<s;){var c=(u=i[a])[0],h=n[c],d=u[1];if(l&&u[2]){if(void 0===h&&!(c in n))return!1}else{var f=new t;if(o)var p=o(h,d,c,n,r,f);if(!(void 0===p?e(d,h,3,o,f):p))return!1}}return!0},wO}(),e=function(){if(OO)return NO;OO=1;var t=hP(),e=pS();return NO=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],a=n[o];r[i]=[o,a,t(a)]}return r},NO}(),n=dP();return AO=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function pP(){if(DO)return RO;DO=1;var t=Zk(),e=pM();return RO=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function gP(){if(_O)return LO;_O=1;var t=vM(),e=pP(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return LO=function(i,o){if(t(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function vP(){if(FO)return BO;FO=1;var t=function(){if(jO)return IO;jO=1;var t=sM();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var a=n.apply(this,t);return i.cache=o.set(e,a)||o,a};return i.cache=new(e.Cache||t),i}return e.Cache=t,IO=e}();return BO=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function mP(){if(WO)return VO;return WO=1,VO=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},VO}function yP(){if(YO)return $O;YO=1;var t=function(){if(UO)return HO;UO=1;var t=Kk(),e=mP(),n=vM(),r=pP(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return HO=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},HO}();return $O=function(e){return null==e?"":t(e)}}function bP(){if(XO)return qO;XO=1;var t=vM(),e=gP(),n=function(){if(GO)return zO;GO=1;var t=vP(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t((function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,(function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)})),r}));return zO=r}(),r=yP();return qO=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function xP(){if(ZO)return KO;ZO=1;var t=pP();return KO=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function EP(){if(JO)return QO;JO=1;var t=bP(),e=xP();return QO=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},QO}function wP(){if(oT)return iT;oT=1;var t=bP(),e=gM(),n=vM(),r=AM(),i=PM(),o=xP();return iT=function(a,s,l){for(var u=-1,c=(s=t(s,a)).length,h=!1;++u<c;){var d=o(s[u]);if(!(h=null!=a&&l(a,d)))break;a=a[d]}return h||++u!=c?h:!!(c=null==a?0:a.length)&&i(c)&&r(d,c)&&(n(a)||e(a))},iT}function kP(){if(sT)return aT;sT=1;var t=rT?nT:(rT=1,nT=function(t,e){return null!=t&&e in Object(t)}),e=wP();return aT=function(n,r){return null!=n&&e(n,r,t)}}function MP(){if(uT)return lT;uT=1;var t=cP(),e=function(){if(eT)return tT;eT=1;var t=EP();return tT=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=kP(),r=gP(),i=hP(),o=dP(),a=xP();return lT=function(s,l){return r(s)&&i(l)?o(a(s),l):function(r){var i=e(r,s);return void 0===i&&i===l?n(r,s):t(l,i,3)}}}function SP(){if(hT)return cT;return hT=1,cT=function(t){return function(e){return null==e?void 0:e[t]}}}function NP(){if(gT)return pT;gT=1;var t=SP(),e=function(){if(fT)return dT;fT=1;var t=EP();return dT=function(e){return function(n){return t(n,e)}}}(),n=gP(),r=xP();return pT=function(i){return n(i)?t(r(i)):e(i)}}function OP(){if(mT)return vT;mT=1;var t=fP(),e=MP(),n=tP(),r=vM(),i=NP();return vT=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function TP(){if(bT)return yT;bT=1;var t=AA(),e=function(){if(ZN)return KN;ZN=1;var t=JA();return KN=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},KN}(),n=OP(),r=vM();return yT=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function CP(){if(kT)return wT;kT=1;var t=function(){if(ET)return xT;ET=1;var t=Object.prototype.hasOwnProperty;return xT=function(e,n){return null!=e&&t.call(e,n)}}(),e=wP();return wT=function(n,r){return null!=n&&e(n,r,t)}}function AP(){if(ST)return MT;ST=1;var t=dS(),e=FA(),n=gM(),r=vM(),i=fS(),o=CM(),a=cS(),s=lS(),l=Object.prototype.hasOwnProperty;return MT=function(u){if(null==u)return!0;if(i(u)&&(r(u)||"string"==typeof u||"function"==typeof u.splice||o(u)||s(u)||n(u)))return!u.length;var c=e(u);if("[object Map]"==c||"[object Set]"==c)return!u.size;if(a(u))return!t(u).length;for(var h in u)if(l.call(u,h))return!1;return!0}}function PP(){if(OT)return NT;return OT=1,NT=function(t){return void 0===t}}function RP(){if(CT)return TT;CT=1;var t=JA(),e=fS();return TT=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,(function(t,e,n){o[++i]=r(t,e,n)})),o},TT}function DP(){if(PT)return AT;PT=1;var t=mP(),e=OP(),n=RP(),r=vM();return AT=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function LP(){if(jT)return IT;jT=1;var t=(DT||(DT=1,RT=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),RT),e=JA(),n=OP(),r=(_T||(_T=1,LT=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),LT),i=vM();return IT=function(o,a,s){var l=i(o)?t:r,u=arguments.length<3;return l(o,n(a,4),s,u,e)},IT}function _P(){if(YT)return $T;YT=1;var t=function(){if(GT)return zT;GT=1;var t=SP()("length");return zT=t}(),e=function(){if(WT)return VT;WT=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return VT=function(e){return t.test(e)}}(),n=function(){if(UT)return HT;UT=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",l="[\\ufe0e\\ufe0f]?",u=l+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+l+s+")*",c="(?:"+[i+n+"?",n,o,a,e].join("|")+")",h=RegExp(r+"(?="+r+")|"+c+u,"g");return HT=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return $T=function(r){return e(r)?n(r):t(r)}}function IP(){if(XT)return qT;XT=1;var t=dS(),e=FA(),n=fS(),r=function(){if(FT)return BT;FT=1;var t=Zk(),e=vM(),n=pM();return BT=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=_P();return qT=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var a=e(o);return"[object Map]"==a||"[object Set]"==a?o.size:t(o).length}}function jP(){if(ZT)return KT;ZT=1;var t=uM(),e=HA(),n=QA(),r=OP(),i=LA(),o=vM(),a=CM(),s=Jk(),l=Qk(),u=lS();return KT=function(c,h,d){var f=o(c),p=f||a(c)||u(c);if(h=r(h,4),null==d){var g=c&&c.constructor;d=p?f?new g:[]:l(c)&&s(g)?e(i(c)):{}}return(p?t:n)(c,(function(t,e,n){return h(d,t,e,n)})),d},KT}function BP(){if(eC)return tC;eC=1;var t=DA(),e=function(){if(JT)return QT;JT=1;var t=Kk(),e=gM(),n=vM(),r=t?t.isConcatSpreadable:void 0;return QT=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return tC=function n(r,i,o,a,s){var l=-1,u=r.length;for(o||(o=e),s||(s=[]);++l<u;){var c=r[l];i>0&&o(c)?i>1?n(c,i-1,o,a,s):t(s,c):a||(s[s.length]=c)}return s},tC}function FP(){if(oC)return iC;oC=1;var t=rC?nC:(rC=1,nC=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 iC=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),l=Array(s);++a<s;)l[a]=o[r+a];a=-1;for(var u=Array(r+1);++a<r;)u[a]=o[a];return u[r]=i(l),t(n,this,u)}},iC}function zP(){if(hC)return cC;hC=1;var t=function(){if(sC)return aC;sC=1;var t=KA(),e=cM(),n=tP();return aC=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(uC)return lC;uC=1;var t=Date.now;return lC=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},lC}(),n=e(t);return cC=n}function GP(){if(fC)return dC;fC=1;var t=tP(),e=FP(),n=zP();return dC=function(r,i){return n(e(r,i,t),r+"")}}function VP(){if(gC)return pC;return gC=1,pC=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},pC}function WP(){if(EC)return xC;EC=1;var t=VP(),e=mC?vC:(mC=1,vC=function(t){return t!=t}),n=(bC||(bC=1,yC=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),yC);return xC=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function HP(){if(CC)return TC;CC=1;var t=BA(),e=OC?NC:(OC=1,NC=function(){}),n=sP(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return TC=r}function UP(){if(PC)return AC;PC=1;var t=iP(),e=function(){if(kC)return wC;kC=1;var t=WP();return wC=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(SC||(SC=1,MC=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),MC),r=oP(),i=HP(),o=sP();return AC=function(a,s,l){var u=-1,c=e,h=a.length,d=!0,f=[],p=f;if(l)d=!1,c=n;else if(h>=200){var g=s?null:i(a);if(g)return o(g);d=!1,c=r,p=new t}else p=s?[]:f;t:for(;++u<h;){var v=a[u],m=s?s(v):v;if(v=l||0!==v?v:0,d&&m==m){for(var y=p.length;y--;)if(p[y]===m)continue t;s&&p.push(m),f.push(v)}else c(p,m,l)||(p!==f&&p.push(m),f.push(v))}return f},AC}function $P(){if(DC)return RC;DC=1;var t=fS(),e=pM();return RC=function(n){return e(n)&&t(n)}}function YP(){if(_C)return LC;_C=1;var t=BP(),e=GP(),n=UP(),r=$P(),i=e((function(e){return n(t(e,1,r,!0))}));return LC=i}function qP(){if(FC)return BC;FC=1;var t=function(){if(jC)return IC;jC=1;var t=mP();return IC=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=pS();return BC=function(n){return null==n?[]:t(n,e(n))}}function XP(){if(GC)return zC;var t;GC=1;try{t={clone:XA(),constant:KA(),each:rP(),filter:TP(),has:CP(),isArray:vM(),isEmpty:AP(),isFunction:Jk(),isUndefined:PP(),keys:pS(),map:DP(),reduce:LP(),size:IP(),transform:jP(),union:YP(),values:qP()}}catch(t){}return t||(t=window._),zC=t}function KP(){if(WC)return VC;WC=1;var t=XP();VC=n;var e="\0";function n(n){this._isDirected=!t.has(n,"directed")||n.directed,this._isMultigraph=!!t.has(n,"multigraph")&&n.multigraph,this._isCompound=!!t.has(n,"compound")&&n.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function r(t,e){t[e]?t[e]++:t[e]=1}function i(t,e){--t[e]||delete t[e]}function o(e,n,r,i){var o=""+n,a=""+r;if(!e&&o>a){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,l=arguments[0];"object"==typeof l&&null!==l&&"v"in l?(e=l.v,n=l.w,i=l.name,2===arguments.length&&(a=arguments[1],s=!0)):(e=l,n=arguments[1],i=arguments[3],arguments.length>2&&(a=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var u=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,u))return s&&(this._edgeLabels[u]=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[u]=s?a:this._defaultEdgeLabelFn(e,n,i);var c=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=c.v,n=c.w,Object.freeze(c),this._edgeObjs[u]=c,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][u]=c,this._out[e][u]=c,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))},VC}function ZP(){return YC?$C:(YC=1,$C={Graph:KP(),version:UC?HC:(UC=1,HC="2.1.8")})}function QP(){if(XC)return qC;XC=1;var t=XP(),e=KP();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 qC={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}}}function JP(){if(ZC)return KC;ZC=1;var t=XP();return KC=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},KC}function tR(){if(JC)return QC;JC=1;var t=XP();function e(){this._arr=[],this._keyIndices={}}return QC=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<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},QC}function eR(){if(eA)return tA;eA=1;var t=XP(),e=tR();tA=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},l=new e,u=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),u=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);u<n.distance&&(n.distance=u,n.predecessor=o,l.decrease(e,u))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},l.add(t,e)}));for(;l.size()>0&&(o=l.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(u);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return tA}function nR(){if(rA)return nA;rA=1;var t=eR(),e=XP();return nA=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function rR(){if(oA)return iA;oA=1;var t=XP();return iA=function(e){var n=0,r=[],i={},o=[];function a(s){var l=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&&(l.lowlink=Math.min(l.lowlink,i[e].index)):(a(e),l.lowlink=Math.min(l.lowlink,i[e].lowlink))})),l.lowlink===l.index){var u,c=[];do{u=r.pop(),i[u].onStack=!1,c.push(u)}while(s!==u);o.push(c)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},iA}function iR(){if(sA)return aA;sA=1;var t=XP(),e=rR();return aA=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function oR(){if(uA)return lA;uA=1;var t=XP();lA=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;s<a.distance&&(a.distance=s,a.predecessor=i.predecessor)}))}))})),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return lA}function aR(){if(hA)return cA;hA=1;var t=XP();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),(function a(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),a),delete i[s],o.push(s))})),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return cA=e,e.CycleException=n,n.prototype=new Error,cA}function sR(){if(fA)return dA;fA=1;var t=aR();return dA=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function lR(){if(gA)return pA;gA=1;var t=XP();function e(n,r,i,o,a,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(a(r),(function(t){e(n,t,i,o,a,s)})),i&&s.push(r))}return pA=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],s={};return t.each(r,(function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,a)})),a},pA}function uR(){if(mA)return vA;mA=1;var t=lR();return vA=function(e,n){return t(e,n,"post")}}function cR(){if(bA)return yA;bA=1;var t=lR();return yA=function(e,n){return t(e,n,"pre")}}function hR(){if(EA)return xA;EA=1;var t=XP(),e=KP(),n=tR();return xA=function(r,i){var o,a=new e,s={},l=new n;function u(t){var e=t.v===o?t.w:t.v,n=l.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,l.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){l.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),l.decrease(r.nodes()[0],0);var c=!1;for(;l.size()>0;){if(o=l.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(c)throw new Error("Input graph is not connected: "+r);c=!0}r.nodeEdges(o).forEach(u)}return a}}try{NA=function(){if(SA)return MA;SA=1;var t=ZP();return MA={Graph:t.Graph,json:QP(),alg:kA?wA:(kA=1,wA={components:JP(),dijkstra:eR(),dijkstraAll:nR(),findCycles:iR(),floydWarshall:oR(),isAcyclic:sR(),postorder:uR(),preorder:cR(),prim:hR(),tarjan:rR(),topsort:aR()}),version:t.version}}()}catch(t){}NA||(NA=window.graphlib);var dR,fR,pR,gR,vR,mR,yR,bR,xR,ER,wR,kR,MR,SR,NR,OR,TR,CR,AR,PR,RR,DR,LR,_R,IR,jR,BR,FR,zR,GR,VR,WR,HR,UR,$R,YR,qR,XR,KR,ZR,QR,JR,tD,eD,nD,rD,iD,oD,aD,sD,lD,uD,cD,hD,dD,fD,pD,gD,vD,mD,yD,bD,xD,ED,wD,kD,MD,SD,ND,OD,TD,CD,AD,PD,RD,DD,LD,_D,ID,jD,BD,FD,zD,GD,VD,WD,HD,UD,$D,YD,qD,XD,KD,ZD=NA;function QD(){if(gR)return pR;gR=1;var t=Uk(),e=fS(),n=AM(),r=Qk();return pR=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)},pR}function JD(){if(kR)return wR;kR=1;var t=function(){if(ER)return xR;ER=1;var t=/\s/;return xR=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},xR}(),e=/^\s+/;return wR=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function tL(){if(OR)return NR;OR=1;var t=function(){if(SR)return MR;SR=1;var t=JD(),e=Qk(),n=pP(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return MR=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var l="function"==typeof s.valueOf?s.valueOf():s;s=e(l)?l+"":l}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var u=i.test(s);return u||o.test(s)?a(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),e=1/0;return NR=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function eL(){if(PR)return AR;PR=1;var t=VP(),e=OP(),n=function(){if(CR)return TR;CR=1;var t=tL();return TR=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return AR=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var l=null==a?0:n(a);return l<0&&(l=r(s+l,0)),t(i,e(o,3),l)},AR}function nL(){if(_R)return LR;_R=1;var t=BP();return LR=function(e){return(null==e?0:e.length)?t(e,1):[]}}function rL(){if(WR)return VR;WR=1;var t=pP();return VR=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=n(a);if(null!=s&&(void 0===l?s==s&&!t(s):r(s,l)))var l=s,u=a}return u},VR}function iL(){if(XR)return qR;XR=1;var t=hM(),e=Uk();return qR=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function oL(){if(JR)return QR;return JR=1,QR=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function aL(){if(rD)return nD;rD=1;var t=iL(),e=TA(),n=VA(),r=CA(),i=UA(),o=gM(),a=vM(),s=$P(),l=CM(),u=Jk(),c=Qk(),h=function(){if(ZR)return KR;ZR=1;var t=Zk(),e=LA(),n=pM(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return KR=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var l=a.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==s}}(),d=lS(),f=oL(),p=function(){if(eD)return tD;eD=1;var t=fM(),e=vS();return tD=function(n){return t(n,e(n))}}();return nD=function(g,v,m,y,b,x,E){var w=f(g,m),k=f(v,m),M=E.get(k);if(M)t(g,m,M);else{var S=x?x(w,k,m+"",g,v,E):void 0,N=void 0===S;if(N){var O=a(k),T=!O&&l(k),C=!O&&!T&&d(k);S=k,O||T||C?a(w)?S=w:s(w)?S=r(w):T?(N=!1,S=e(k,!0)):C?(N=!1,S=n(k,!0)):S=[]:h(k)||o(k)?(S=w,o(w)?S=p(w):c(w)&&!u(w)||(S=i(k))):N=!1}N&&(E.set(k,S),b(S,k,y,x,E),E.delete(k)),t(g,m,S)}}}function sL(){if(hD)return cD;return hD=1,cD=function(t,e){return t<e}}function lL(){if(ED)return xD;ED=1;var t=EP(),e=function(){if(bD)return yD;bD=1;var t=dM(),e=bP(),n=AM(),r=Qk(),i=xP();return yD=function(o,a,s,l){if(!r(o))return o;for(var u=-1,c=(a=e(a,o)).length,h=c-1,d=o;null!=d&&++u<c;){var f=i(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(u!=h){var g=d[f];void 0===(p=l?l(g,f,d):void 0)&&(p=r(g)?g:n(a[u+1])?[]:{})}t(d,f,p),d=d[f]}return o},yD}(),n=bP();return xD=function(r,i,o){for(var a=-1,s=i.length,l={};++a<s;){var u=i[a],c=t(r,u);o(c,u)&&e(l,n(u,r),c)}return l},xD}function uL(){if(PD)return AD;PD=1;var t=function(){if(CD)return TD;CD=1;var t=Math.ceil,e=Math.max;return TD=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),l=Array(s);s--;)l[o?s:++a]=n,n+=i;return l},TD}(),e=QD(),n=tL();return AD=function(r){return function(i,o,a){return a&&"number"!=typeof a&&e(i,o,a)&&(o=a=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),a=void 0===a?i<o?1:-1:n(a),t(i,o,a,r)}},AD}function cL(){if(FD)return BD;FD=1;var t=function(){if(jD)return ID;jD=1;var t=pP();return ID=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,l=null===n,u=n==n,c=t(n);if(!l&&!c&&!a&&e>n||a&&s&&u&&!l&&!c||i&&s&&u||!r&&u||!o)return 1;if(!i&&!a&&!c&&e<n||c&&r&&o&&!i&&!a||l&&r&&o||!s&&o||!u)return-1}return 0}}();return BD=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,l=r.length;++i<s;){var u=t(o[i],a[i]);if(u)return i>=l?u:u*("desc"==r[i]?-1:1)}return e.index-n.index},BD}function hL(){if(GD)return zD;GD=1;var t=mP(),e=EP(),n=OP(),r=RP(),i=(_D||(_D=1,LD=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),LD),o=RM(),a=cL(),s=tP(),l=vM();return zD=function(u,c,h){c=c.length?t(c,(function(t){return l(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;c=t(c,o(n));var f=r(u,(function(e,n,r){return{criteria:t(c,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,h)}))},zD}try{KD={cloneDeep:function(){if(fR)return dR;fR=1;var t=qA();return dR=function(e){return t(e,5)}}(),constant:KA(),defaults:function(){if(mR)return vR;mR=1;var t=GP(),e=Uk(),n=QD(),r=vS(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,l=a.length,u=l>2?a[2]:void 0;for(u&&n(a[0],a[1],u)&&(l=1);++s<l;)for(var c=a[s],h=r(c),d=-1,f=h.length;++d<f;){var p=h[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=c[p])}return t}));return vR=a}(),each:rP(),filter:TP(),find:function(){if(DR)return RR;DR=1;var t=function(){if(bR)return yR;bR=1;var t=OP(),e=fS(),n=pS();return yR=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var l=t(o,3);i=n(i),o=function(t){return l(s[t],t,s)}}var u=r(i,o,a);return u>-1?s[l?i[u]:u]:void 0}},yR}(),e=t(eL());return RR=e}(),flatten:nL(),forEach:nP(),forIn:function(){if(jR)return IR;jR=1;var t=ZA(),e=eP(),n=vS();return IR=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:CP(),isUndefined:PP(),last:(FR||(FR=1,BR=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),BR),map:DP(),mapValues:function(){if(GR)return zR;GR=1;var t=hM(),e=QA(),n=OP();return zR=function(r,i){var o={};return i=n(i,3),e(r,(function(e,n,r){t(o,n,i(e,n,r))})),o}}(),max:function(){if(YR)return $R;YR=1;var t=rL(),e=UR?HR:(UR=1,HR=function(t,e){return t>e}),n=tP();return $R=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(uD)return lD;uD=1;var t=function(){if(oD)return iD;oD=1;var t=lM(),e=iL(),n=ZA(),r=aL(),i=Qk(),o=vS(),a=oL();return iD=function s(l,u,c,h,d){l!==u&&n(u,(function(n,o){if(d||(d=new t),i(n))r(l,u,o,c,s,h,d);else{var f=h?h(a(l,o),n,o+"",l,u,d):void 0;void 0===f&&(f=n),e(l,o,f)}}),o)},iD}(),e=function(){if(sD)return aD;sD=1;var t=GP(),e=QD();return aD=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);++i<o;){var l=r[i];l&&n(t,l,i,a)}return t}))},aD}(),n=e((function(e,n,r){t(e,n,r)}));return lD=n}(),min:function(){if(fD)return dD;fD=1;var t=rL(),e=sL(),n=tP();return dD=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(gD)return pD;gD=1;var t=rL(),e=OP(),n=sL();return pD=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(mD)return vD;mD=1;var t=Xk();return vD=function(){return t.Date.now()}}(),pick:function(){if(OD)return ND;OD=1;var t=function(){if(kD)return wD;kD=1;var t=lL(),e=kP();return wD=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(SD)return MD;SD=1;var t=nL(),e=FP(),n=zP();return MD=function(r){return n(e(r,void 0,t),r+"")}}()((function(e,n){return null==e?{}:t(e,n)}));return ND=e}(),range:function(){if(DD)return RD;DD=1;var t=uL()();return RD=t}(),reduce:LP(),sortBy:function(){if(WD)return VD;WD=1;var t=BP(),e=hL(),n=GP(),r=QD(),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 VD=i}(),uniqueId:function(){if(UD)return HD;UD=1;var t=yP(),e=0;return HD=function(n){var r=++e;return t(n)+r},HD}(),values:qP(),zipObject:function(){if(XD)return qD;XD=1;var t=dM(),e=(YD||(YD=1,$D=function(t,e,n){for(var r=-1,i=t.length,o=e.length,a={};++r<i;){var s=r<o?e[r]:void 0;n(a,t[r],s)}return a}),$D);return qD=function(n,r){return e(n||[],r||[],t)},qD}()}}catch(t){}KD||(KD=window._);var dL=KD,fL=pL;function pL(){var t={};t._next=t._prev=t,this._sentinel=t}function gL(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function vL(t,e){if("_next"!==t&&"_prev"!==t)return e}pL.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return gL(e),e},pL.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&gL(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},pL.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,vL)),n=n._prev;return"["+t.join(", ")+"]"};var mL=dL,yL=ZD.Graph,bL=fL,xL=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new yL,r=0,i=0;mL.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),mL.forEach(t.edges(),(function(t){var o=n.edge(t.v,t.w)||0,a=e(t),s=o+a;n.setEdge(t.v,t.w,s),i=Math.max(i,n.node(t.v).out+=a),r=Math.max(r,n.node(t.w).in+=a)}));var o=mL.range(i+r+3).map((function(){return new bL})),a=r+1;return mL.forEach(n.nodes(),(function(t){kL(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||EL),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)wL(t,e,n,r);for(;r=o.dequeue();)wL(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(wL(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return mL.flatten(mL.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},EL=mL.constant(1);function wL(t,e,n,r,i){var o=i?[]:void 0;return mL.forEach(t.inEdges(r.v),(function(r){var a=t.edge(r),s=t.node(r.v);i&&o.push({v:r.v,w:r.w}),s.out-=a,kL(e,n,s)})),mL.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,kL(e,n,a)})),t.removeNode(r.v),o}function kL(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)}var ML=dL,SL=xL,NL={run:function(t){var e="greedy"===t.graph().acyclicer?SL(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){ML.has(r,o)||(r[o]=!0,n[o]=!0,ML.forEach(t.outEdges(o),(function(t){ML.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return ML.forEach(t.nodes(),i),e}(t);ML.forEach(e,(function(e){var n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,ML.uniqueId("rev"))}))},undo:function(t){ML.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}}))}};var OL=dL,TL=ZD.Graph,CL={addDummyNode:AL,simplify:function(t){var e=(new TL).setGraph(t.graph());return OL.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),OL.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})})),e},asNonCompoundGraph:function(t){var e=new TL({multigraph:t.isMultigraph()}).setGraph(t.graph());return OL.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),OL.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=OL.map(t.nodes(),(function(e){var n={};return OL.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return OL.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=OL.map(t.nodes(),(function(e){var n={};return OL.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return OL.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,a=e.x-i,s=e.y-o,l=t.width/2,u=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*l>Math.abs(a)*u?(s<0&&(u=-u),n=u*a/s,r=u):(a<0&&(l=-l),n=l,r=l*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=OL.map(OL.range(PL(t)+1),(function(){return[]}));return OL.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;OL.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=OL.min(OL.map(t.nodes(),(function(e){return t.node(e).rank})));OL.forEach(t.nodes(),(function(n){var r=t.node(n);OL.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=OL.min(OL.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];OL.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r)}));var r=0,i=t.graph().nodeRankFactor;OL.forEach(n,(function(e,n){OL.isUndefined(e)&&n%i!=0?--r:r&&OL.forEach(e,(function(e){t.node(e).rank+=r}))}))},addBorderNode:function(t,e,n,r){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return AL(t,"border",i,e)},maxRank:PL,partition:function(t,e){var n={lhs:[],rhs:[]};return OL.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=OL.now();try{return e()}finally{console.log(t+" time: "+(OL.now()-n)+"ms")}},notime:function(t,e){return e()}};function AL(t,e,n,r){var i;do{i=OL.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function PL(t){return OL.max(OL.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!OL.isUndefined(n))return n})))}var RL=dL,DL=CL,LL={run:function(t){t.graph().dummyChains=[],RL.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,l=t.node(s).rank,u=e.name,c=t.edge(e),h=c.labelRank;if(l===a+1)return;for(t.removeEdge(e),i=0,++a;a<l;++i,++a)c.points=[],r={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},n=DL.addDummyNode(t,"edge",r,"_d"),a===h&&(r.width=c.width,r.height=c.height,r.dummy="edge-label",r.labelpos=c.labelpos),t.setEdge(o,n,{weight:c.weight},u),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:c.weight},u)}(t,e)}))},undo:function(t){RL.forEach(t.graph().dummyChains,(function(e){var n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)}))}};var _L=dL,IL={longestPath:function(t){var e={};_L.forEach(t.sources(),(function n(r){var i=t.node(r);if(_L.has(e,r))return i.rank;e[r]=!0;var o=_L.min(_L.map(t.outEdges(r),(function(e){return n(e.w)-t.edge(e).minlen})));return o!==Number.POSITIVE_INFINITY&&null!=o||(o=0),i.rank=o}))},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var jL=dL,BL=ZD.Graph,FL=IL.slack,zL=function(t){var e,n,r=new BL({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;GL(r,t)<o;)e=VL(r,t),n=r.hasNode(e.v)?FL(t,e):-FL(t,e),WL(r,t,n);return r};function GL(t,e){return jL.forEach(t.nodes(),(function n(r){jL.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||FL(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function VL(t,e){return jL.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return FL(e,n)}))}function WL(t,e,n){jL.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var HL=dL,UL=zL,$L=IL.slack,YL=IL.longestPath,qL=ZD.alg.preorder,XL=ZD.alg.postorder,KL=CL.simplify,ZL=QL;function QL(t){t=KL(t),YL(t);var e,n=UL(t);for(e_(n),JL(n,t);e=r_(n);)o_(n,t,e,i_(n,t,e))}function JL(t,e){var n=XL(t,t.nodes());n=n.slice(0,n.length-1),HL.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=t_(t,e,n)}(t,e,n)}))}function t_(t,e,n){var r=t.node(n).parent,i=!0,o=e.edge(n,r),a=0;return o||(i=!1,o=e.edge(r,n)),a=o.weight,HL.forEach(e.nodeEdges(n),(function(o){var s,l,u=o.v===n,c=u?o.w:o.v;if(c!==r){var h=u===i,d=e.edge(o).weight;if(a+=h?d:-d,s=n,l=c,t.hasEdge(s,l)){var f=t.edge(n,c).cutvalue;a+=h?-f:f}}})),a}function e_(t,e){arguments.length<2&&(e=t.nodes()[0]),n_(t,{},1,e)}function n_(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,HL.forEach(t.neighbors(r),(function(i){HL.has(e,i)||(n=n_(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function r_(t){return HL.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function i_(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var o=t.node(r),a=t.node(i),s=o,l=!1;o.lim>a.lim&&(s=a,l=!0);var u=HL.filter(e.edges(),(function(e){return l===a_(t,t.node(e.v),s)&&l!==a_(t,t.node(e.w),s)}));return HL.minBy(u,(function(t){return $L(e,t)}))}function o_(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),e_(t),JL(t,e),function(t,e){var n=HL.find(t.nodes(),(function(t){return!e.node(t).parent})),r=qL(t,n);r=r.slice(1),HL.forEach(r,(function(n){var r=t.node(n).parent,i=e.edge(n,r),o=!1;i||(i=e.edge(r,n),o=!0),e.node(n).rank=e.node(r).rank+(o?i.minlen:-i.minlen)}))}(t,e)}function a_(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}QL.initLowLimValues=e_,QL.initCutValues=JL,QL.calcCutValue=t_,QL.leaveEdge=r_,QL.enterEdge=i_,QL.exchangeEdges=o_;var s_=IL.longestPath,l_=zL,u_=ZL,c_=function(t){switch(t.graph().ranker){case"network-simplex":default:d_(t);break;case"tight-tree":!function(t){s_(t),l_(t)}(t);break;case"longest-path":h_(t)}};var h_=s_;function d_(t){u_(t)}var f_=dL,p_=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;f_.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return f_.forEach(t.children(),r),e}(t);f_.forEach(t.graph().dummyChains,(function(n){for(var r=t.node(n),i=r.edgeObj,o=function(t,e,n,r){var i,o,a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>l||u>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:a.concat(s.reverse()),lca:o}}(t,e,i.v,i.w),a=o.path,s=o.lca,l=0,u=a[l],c=!0;n!==i.w;){if(r=t.node(n),c){for(;(u=a[l])!==s&&t.node(u).maxRank<r.rank;)l++;u===s&&(c=!1)}if(!c){for(;l<a.length-1&&t.node(u=a[l+1]).minRank<=r.rank;)l++;u=a[l]}t.setParent(n,u),n=t.successors(n)[0]}}))};var g_=dL,v_=CL,m_={run:function(t){var e=v_.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&g_.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return g_.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=g_.max(g_.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,g_.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return g_.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;g_.forEach(t.children(),(function(a){y_(t,e,i,o,r,n,a)})),t.graph().nodeRankFactor=i},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,g_.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function y_(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var l=v_.addBorderNode(t,"_bt"),u=v_.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(l,a),c.borderTop=l,t.setParent(u,a),c.borderBottom=u,g_.forEach(s,(function(s){y_(t,e,n,r,i,o,s);var c=t.node(s),h=c.borderTop?c.borderTop:s,d=c.borderBottom?c.borderBottom:s,f=c.borderTop?r:2*r,p=h!==d?1:i-o[a]+1;t.setEdge(l,h,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,l,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var b_=dL,x_=CL,E_=function(t){b_.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&b_.forEach(r,e),b_.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)w_(t,"borderLeft","_bl",n,i,o),w_(t,"borderRight","_br",n,i,o)}}))};function w_(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],l=x_.addDummyNode(t,"border",a,n);i[e][o]=l,t.setParent(l,r),s&&t.setEdge(s,l,{weight:1})}var k_=dL,M_={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||S_(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){k_.forEach(t.nodes(),(function(e){O_(t.node(e))})),k_.forEach(t.edges(),(function(e){var n=t.edge(e);k_.forEach(n.points,O_),k_.has(n,"y")&&O_(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){k_.forEach(t.nodes(),(function(e){T_(t.node(e))})),k_.forEach(t.edges(),(function(e){var n=t.edge(e);k_.forEach(n.points,T_),k_.has(n,"x")&&T_(n)}))}(t),S_(t))}};function S_(t){k_.forEach(t.nodes(),(function(e){N_(t.node(e))})),k_.forEach(t.edges(),(function(e){N_(t.edge(e))}))}function N_(t){var e=t.width;t.width=t.height,t.height=e}function O_(t){t.y=-t.y}function T_(t){var e=t.x;t.x=t.y,t.y=e}var C_=dL,A_=function(t){var e={},n=C_.filter(t.nodes(),(function(e){return!t.children(e).length})),r=C_.max(C_.map(n,(function(e){return t.node(e).rank}))),i=C_.map(C_.range(r+1),(function(){return[]}));function o(n){if(!C_.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),C_.forEach(t.successors(n),o)}}var a=C_.sortBy(n,(function(e){return t.node(e).rank}));return C_.forEach(a,o),i};var P_=dL,R_=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=D_(t,e[r-1],e[r]);return n};function D_(t,e,n){for(var r=P_.zipObject(n,P_.map(n,(function(t,e){return e}))),i=P_.flatten(P_.map(e,(function(e){return P_.sortBy(P_.map(t.outEdges(e),(function(e){return{pos:r[e.w],weight:t.edge(e).weight}})),"pos")})),!0),o=1;o<n.length;)o<<=1;var a=2*o-1;o-=1;var s=P_.map(new Array(a),(function(){return 0})),l=0;return P_.forEach(i.forEach((function(t){var e=t.pos+o;s[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=s[e+1]),s[e=e-1>>1]+=t.weight;l+=t.weight*n}))),l}var L_=dL;var __=dL,I_=function(t,e){var n={};return __.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};__.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),__.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];__.isUndefined(e)||__.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(__.isUndefined(e.barycenter)||__.isUndefined(t.barycenter)||e.barycenter>=t.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}(t,e)}}function r(e){return function(n){n.in.push(e),0==--n.indegree&&t.push(n)}}for(;t.length;){var i=t.pop();e.push(i),__.forEach(i.in.reverse(),n(i)),__.forEach(i.out,r(i))}return __.map(__.filter(e,(function(t){return!t.merged})),(function(t){return __.pick(t,["vs","i","barycenter","weight"])}))}(__.filter(n,(function(t){return!t.indegree})))};var j_=dL,B_=CL;function F_(t,e,n){for(var r;e.length&&(r=j_.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var z_=dL,G_=function(t,e){return L_.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=L_.reduce(n,(function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}}),{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}}))},V_=I_,W_=function(t,e){var n=B_.partition(t,(function(t){return j_.has(t,"barycenter")})),r=n.lhs,i=j_.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,l=0;r.sort((u=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:u?e.i-t.i:t.i-e.i})),l=F_(o,i,l),j_.forEach(r,(function(t){l+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,l=F_(o,i,l)}));var u;var c={vs:j_.flatten(o,!0)};s&&(c.barycenter=a/s,c.weight=s);return c},H_=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,u={};s&&(o=z_.filter(o,(function(t){return t!==s&&t!==l})));var c=G_(e,o);z_.forEach(c,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);u[n.v]=o,z_.has(o,"barycenter")&&(a=n,s=o,z_.isUndefined(a.barycenter)?(a.barycenter=s.barycenter,a.weight=s.weight):(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight))}var a,s}));var h=V_(c,r);!function(t,e){z_.forEach(t,(function(t){t.vs=z_.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,u);var d=W_(h,i);if(s&&(d.vs=z_.flatten([s,d.vs,l],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(l)[0]);z_.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var U_=dL,$_=ZD.Graph,Y_=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=U_.uniqueId("_root")););return e}(t),i=new $_({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return U_.forEach(t.nodes(),(function(o){var a=t.node(o),s=t.parent(o);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),U_.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=U_.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),U_.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var q_=dL;var X_=dL,K_=A_,Z_=R_,Q_=H_,J_=Y_,tI=function(t,e,n){var r,i={};q_.forEach(n,(function(n){for(var o,a,s=t.parent(n);s;){if((o=t.parent(s))?(a=i[o],i[o]=s):(a=r,r=s),a&&a!==s)return void e.setEdge(a,s);s=o}}))},eI=ZD.Graph,nI=CL,rI=function(t){var e=nI.maxRank(t),n=iI(t,X_.range(1,e+1),"inEdges"),r=iI(t,X_.range(e-1,-1,-1),"outEdges"),i=K_(t);aI(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,l=0;l<4;++s,++l){oI(s%2?n:r,s%4>=2),i=nI.buildLayerMatrix(t);var u=Z_(t,i);u<a&&(l=0,o=X_.cloneDeep(i),a=u)}aI(t,o)};function iI(t,e,n){return X_.map(e,(function(e){return J_(t,e,n)}))}function oI(t,e){var n=new eI;X_.forEach(t,(function(t){var r=t.graph().root,i=Q_(t,r,n,e);X_.forEach(i.vs,(function(e,n){t.node(e).order=n})),tI(t,n,i.vs)}))}function aI(t,e){X_.forEach(e,(function(e){X_.forEach(e,(function(e,n){t.node(e).order=n}))}))}var sI=dL,lI=ZD.Graph,uI=CL,cI=function(t){var e,n=uI.buildLayerMatrix(t),r=sI.merge(function(t,e){var n={};function r(e,r){var i=0,o=0,a=e.length,s=sI.last(r);return sI.forEach(r,(function(e,l){var u=function(t,e){if(t.node(e).dummy)return sI.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=u?t.node(u).order:a;(u||e===s)&&(sI.forEach(r.slice(o,l+1),(function(e){sI.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||c<a)||o.dummy&&t.node(e).dummy||hI(n,r,e)}))})),o=l+1,i=c)})),r}return sI.reduce(e,r),n}(t,n),function(t,e){var n={};function r(e,r,i,o,a){var s;sI.forEach(sI.range(r,i),(function(r){s=e[r],t.node(s).dummy&&sI.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&hI(n,e,s)}))}))}function i(e,n){var i,o=-1,a=0;return sI.forEach(n,(function(s,l){if("border"===t.node(s).dummy){var u=t.predecessors(s);u.length&&(i=t.node(u[0]).order,r(n,a,l,o,i),a=l,o=i)}r(n,a,n.length,i,e.length)})),n}return sI.reduce(e,i),n}(t,n)),i={};sI.forEach(["u","d"],(function(o){e="u"===o?n:sI.values(n).reverse(),sI.forEach(["l","r"],(function(n){"r"===n&&(e=sI.map(e,(function(t){return sI.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=function(t,e,n,r){var i={},o={},a={};return sI.forEach(e,(function(t){sI.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),sI.forEach(e,(function(t){var e=-1;sI.forEach(t,(function(t){var s=r(t);if(s.length){s=sI.sortBy(s,(function(t){return a[t]}));for(var l=(s.length-1)/2,u=Math.floor(l),c=Math.ceil(l);u<=c;++u){var h=s[u];o[t]===t&&e<a[h]&&!dI(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}(0,e,r,a),l=function(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new lI,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),l=r.node(o),u=0;if(u+=s.width/2,sI.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(u+=n?a:-a),a=0,u+=(s.dummy?e:t)/2,u+=(l.dummy?e:t)/2,u+=l.width/2,sI.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(u+=n?a:-a),a=0,u}}(o.nodesep,o.edgesep,r);return sI.forEach(e,(function(e){var r;sI.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],l=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),l||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function l(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}function u(t){o[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,o[e.v]+a.edge(e))}),0)}function c(e){var n=a.outEdges(e).reduce((function(t,e){return Math.min(t,o[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==s&&(o[e]=Math.max(o[e],n))}return l(u,a.predecessors.bind(a)),l(c,a.successors.bind(a)),sI.forEach(r,(function(t){o[t]=o[n[t]]})),o}(t,e,s.root,s.align,"r"===n);"r"===n&&(l=sI.mapValues(l,(function(t){return-t}))),i[o+n]=l}))}));var o=function(t,e){return sI.minBy(sI.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return sI.forIn(e,(function(e,i){var o=function(t,e){return t.node(e).width}(t,i)/2;n=Math.max(e+o,n),r=Math.min(e-o,r)})),n-r}))}(t,i);return function(t,e){var n=sI.values(e),r=sI.min(n),i=sI.max(n);sI.forEach(["u","d"],(function(n){sI.forEach(["l","r"],(function(o){var a,s=n+o,l=t[s];if(l!==e){var u=sI.values(l);(a="l"===o?r-sI.min(u):i-sI.max(u))&&(t[s]=sI.mapValues(l,(function(t){return t+a})))}}))}))}(i,o),function(t,e){return sI.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=sI.sortBy(sI.map(t,r));return(i[1]+i[2])/2}))}(i,t.graph().align)};function hI(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 dI(t,e,n){if(e>n){var r=e;e=n,n=r}return sI.has(t[e],n)}var fI=dL,pI=CL,gI=cI,vI=function(t){(function(t){var e=pI.buildLayerMatrix(t),n=t.graph().ranksep,r=0;fI.forEach(e,(function(e){var i=fI.max(fI.map(e,(function(e){return t.node(e).height})));fI.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=pI.asNonCompoundGraph(t)),fI.forEach(gI(t),(function(e,n){t.node(n).x=e}))};var mI=dL,yI=NL,bI=LL,xI=c_,EI=CL.normalizeRanks,wI=p_,kI=CL.removeEmptyRanks,MI=m_,SI=E_,NI=M_,OI=rI,TI=vI,CI=CL,AI=ZD.Graph,PI=function(t,e){var n=e&&e.debugTiming?CI.time:CI.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new AI({multigraph:!0,compound:!0}),n=GI(t.graph());return e.setGraph(mI.merge({},DI,zI(n,RI),mI.pick(n,LI))),mI.forEach(t.nodes(),(function(n){var r=GI(t.node(n));e.setNode(n,mI.defaults(zI(r,_I),II)),e.setParent(n,t.parent(n))})),mI.forEach(t.edges(),(function(n){var r=GI(t.edge(n));e.setEdge(n,mI.merge({},BI,zI(r,jI),mI.pick(r,FI)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,mI.forEach(t.edges(),(function(n){var r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){mI.forEach(t.edges(),(function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){yI.run(t)})),e(" nestingGraph.run",(function(){MI.run(t)})),e(" rank",(function(){xI(CI.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};CI.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){kI(t)})),e(" nestingGraph.cleanup",(function(){MI.cleanup(t)})),e(" normalizeRanks",(function(){EI(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;mI.forEach(t.nodes(),(function(n){var r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=mI.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){mI.forEach(t.nodes(),(function(e){var n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){bI.run(t)})),e(" parentDummyChains",(function(){wI(t)})),e(" addBorderSegments",(function(){SI(t)})),e(" order",(function(){OI(t)})),e(" insertSelfEdges",(function(){!function(t){var e=CI.buildLayerMatrix(t);mI.forEach(e,(function(e){var n=0;mI.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,mI.forEach(i.selfEdges,(function(e){CI.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")})),delete i.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){NI.adjust(t)})),e(" position",(function(){TI(t)})),e(" positionSelfEdges",(function(){!function(t){mI.forEach(t.nodes(),(function(e){var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,o=r.y,a=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{x:i+a,y:o},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){mI.forEach(t.nodes(),(function(e){if(t.children(e).length){var n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),o=t.node(mI.last(n.borderLeft)),a=t.node(mI.last(n.borderRight));n.width=Math.abs(a.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}})),mI.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){bI.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);if(mI.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){NI.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=t.graph(),a=o.marginx||0,s=o.marginy||0;function l(t){var o=t.x,a=t.y,s=t.width,l=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-l/2),i=Math.max(i,a+l/2)}mI.forEach(t.nodes(),(function(e){l(t.node(e))})),mI.forEach(t.edges(),(function(e){var n=t.edge(e);mI.has(n,"x")&&l(n)})),e-=a,r-=s,mI.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),mI.forEach(t.edges(),(function(n){var i=t.edge(n);mI.forEach(i.points,(function(t){t.x-=e,t.y-=r})),mI.has(i,"x")&&(i.x-=e),mI.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n,r,i=t.edge(e),o=t.node(e.v),a=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=a,r=o),i.points.unshift(CI.intersectRect(o,n)),i.points.push(CI.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){yI.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){mI.forEach(t.nodes(),(function(n){var r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,e.children(n).length&&(r.width=i.width,r.height=i.height))})),mI.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,mI.has(i,"x")&&(r.x=i.x,r.y=i.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var RI=["nodesep","edgesep","ranksep","marginx","marginy"],DI={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},LI=["acyclicer","ranker","rankdir","align"],_I=["width","height"],II={width:0,height:0},jI=["minlen","weight","width","height","labeloffset"],BI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},FI=["labelpos"];function zI(t,e){return mI.mapValues(mI.pick(t,e),Number)}function GI(t){var e={};return mI.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var VI=dL,WI=CL,HI=ZD.Graph,UI={debugOrdering:function(t){var e=WI.buildLayerMatrix(t),n=new HI({compound:!0,multigraph:!0}).setGraph({});return VI.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),VI.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),VI.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),VI.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var $I={graphlib:ZD,layout:PI,debug:UI,util:{time:CL.time,notime:CL.notime},version:"0.8.5"},YI=E($I);class qI{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,qI.defaultOptions,t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new $I.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>ae(t)))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach((t=>{const{id:e}=t,n=Object.assign({},t.data);if(void 0!==r){const[e,i]=db(Ut(r)?r(t):r);Object.assign(n,{width:e,height:i})}i.setNode(e.toString(),n)})),e.getAllEdges().forEach((({id:t,source:e,target:n})=>{i.setEdge(e.toString(),n.toString(),{id:t})})),YI.layout(i);const o={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);o.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:a}=r,s=Fe(r,["id"]),{v:l,w:u}=n;o.edges.push({id:a,source:l,target:u,data:s}),t&&e.mergeEdgeData(a,s)})),o}))}}qI.defaultOptions={};class XI{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 XI({rx:n,ry:r,mass:e,degree:i})}}class KI{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 KI({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 KI({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 KI({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 KI({xmid:t,ymid:e,length:n})}}class ZI{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 ZI(this.quad.NW()),this.NE=new ZI(this.quad.NE()),this.SW=new ZI(this.quad.SW()),this.SE=new ZI(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)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}const QI={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class JI{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},QI),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:l,maxIteration:u,nodeSize:c,center:h}=o;if(!(null==i?void 0:i.length)||1===i.length)return bb(e,t,h);const d=i.map((t=>hb(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Yg({nodes:d,edges:f}),g=this.getSizes(p,c);if(this.run(p,e,u,g,t,o),l){for(let t=0;t<f.length;t+=1){const{source:e,target:n}=f[t],r=p.getDegree(e),i=p.getDegree(e);if(r<=1){const t=p.getNode(n);p.mergeNodeData(e,{x:t.data.x,y:t.data.y})}else if(i<=1){const t=p.getNode(e);p.mergeNodeData(n,{x:t.data.x,y:t.data.y})}}const n=Object.assign(Object.assign({},o),{prune:!1,barnesHut:!1});this.run(p,e,100,g,t,n)}return{nodes:d,edges:r}}))}getSizes(t,e){const n=t.getAllNodes(),r={};for(let t=0;t<n.length;t+=1){const i=n[t];r[i.id]=gb(e,void 0)(i)}return r}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:l,kr:u,kg:c}=n;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=o||"undefined"==typeof window?o:window.innerHeight,n.center=r||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===s&&e>100&&(n.prune=!0),0!==l||s?0===l&&s&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),u||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:l}=o,u=t.getAllNodes();let c=0,h=n;const d={},f={},p={};for(let e=0;e<u.length;e+=1){const{data:n,id:r}=u[e];if(d[r]=[0,0],s){const i={id:e,rx:n.x,ry:n.y,mass:1,g:a,degree:t.getDegree(r)};p[r]=new XI(i)}}for(;h>0;)c=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:c,forces:d,preForces:f,bodies:p,sizes:r},o),h--,null==l||l({nodes:u,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:l,sizes:u}=e;let{forces:c}=e;const{preventOverlap:h,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...c[e]],c[e]=[0,0]}return c=this.getAttrForces(t,r,i,u,c,n),c=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,c,l,n):this.getRepGraForces(t,r,i,c,o,u,n),this.updatePos(t,c,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:l,prune:u}=o,c=t.getAllEdges();for(let o=0;o<c.length;o+=1){const{source:h,target:d}=c[o],f=t.getNode(h),p=t.getNode(d),g=t.getDegree(h),v=t.getDegree(d);if(u&&(g<=1||v<=1))continue;const m=[p.data.x-f.data.x,p.data.y-f.data.y];let y=Math.hypot(m[0],m[1]);y=y<1e-4?1e-4:y,m[0]=m[0]/y,m[1]=m[1]/y,a&&e<n&&(y=y-r[h]-r[d]);let b=y,x=b;"linlog"===l&&(b=Math.log(1+y),x=b),s&&(b=y/g,x=y/v),a&&e<n&&y<=0?(b=0,x=0):a&&e<n&&y>0&&(b=y,x=y),i[h][0]+=b*m[0],i[d][0]-=x*m[0],i[h][1]+=b*m[1],i[d][1]-=x*m[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),l=s.length;let u=9e10,c=-9e10,h=9e10,d=-9e10;for(let e=0;e<l;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=c&&(c=i.x),i.x<=u&&(u=i.x),i.y>=d&&(d=i.y),i.y<=h&&(h=i.y))}const f=Math.max(c-u,d-h),p=new KI({xmid:(c+u)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:l}),g=new ZI(p);for(let e=0;e<l;e+=1){const{id:r}=s[e];a&&t.getDegree(r)<=1||n[r].in(p)&&g.insert(n[r])}for(let r=0;r<l;r+=1){const{id:l,data:u}=s[r],c=t.getDegree(l);if(a&&c<=1)continue;n[l].resetForce(),g.updateForce(n[l]),e[l][0]-=n[l].fx,e[l][1]-=n[l].fy;const h=[u.x-o[0],u.y-o[1]];let d=Math.hypot(h[0],h[1]);d=d<1e-4?1e-4:d,h[0]=h[0]/d,h[1]=h[1]/d;const f=i*(c+1);e[l][0]-=f*h[0],e[l][1]-=f*h[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:l,kg:u,center:c,prune:h}=a,d=t.getAllNodes(),f=d.length;for(let a=0;a<f;a+=1){const p=d[a],g=t.getDegree(p.id);for(let u=a+1;u<f;u+=1){const a=d[u],c=t.getDegree(a.id);if(h&&(g<=1||c<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let v=Math.hypot(f[0],f[1]);v=v<1e-4?1e-4:v,f[0]=f[0]/v,f[1]=f[1]/v,s&&e<n&&(v=v-o[p.id]-o[a.id]);let m=l*(g+1)*(c+1)/v;s&&e<n&&v<0?m=i*(g+1)*(c+1):s&&e<n&&0===v?m=0:s&&e<n&&v>0&&(m=l*(g+1)*(c+1)/v),r[p.id][0]-=m*f[0],r[a.id][0]+=m*f[0],r[p.id][1]-=m*f[1],r[a.id][1]+=m*f[1]}const v=[p.data.x-c[0],p.data.y-c[1]],m=Math.hypot(v[0],v[1]);v[0]=v[0]/m,v[1]=v[1]/m;const y=u*(g+1);r[p.id][0]-=y*v[0],r[p.id][1]-=y*v[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:l}=i,u=t.getAllNodes(),c=u.length,h=[],d=[];let f=0,p=0,g=r;for(let r=0;r<c;r+=1){const{id:i}=u[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],l=Math.hypot(a[0],a[1]),c=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(c[0],c[1]);h[r]=l,d[r]=g/2,f+=(o+1)*h[r],p+=(o+1)*d[r]}const v=g;g=a*p/f,0!==v&&(g=g>1.5*v?1.5*v:g);for(let n=0;n<c;n+=1){const{id:r,data:i}=u[n],a=t.getDegree(r);if(s&&a<=1)continue;if(ae(i.fx)&&ae(i.fy))continue;let c=o*g/(1+g*Math.sqrt(h[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=l/d;c=c>f?f:c;const p=c*e[r][0],v=c*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+v})}return g}}const tj={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};class ej{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},tj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericFruchtermanLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;e<t;e++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericFruchtermanLayout(t,e,n){return ze(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:l,nodeClusterBy:u,maxIteration:c,onTick:h}=r,d=e.getAllNodes(),f=e.getAllEdges();if(!(null==d?void 0:d.length)){const t={nodes:[],edges:f};return this.lastResult=t,t}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0});const n={nodes:[Object.assign(Object.assign({},d[0]),{data:Object.assign(Object.assign({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:f};return this.lastResult=n,n}const p=d.map((t=>hb(t,[o,a]))),g=new Yg({nodes:p,edges:f}),v={};if(l&&p.forEach((t=>{const e=t.data[u];v[e]||(v[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=p,this.lastLayoutEdges=f,this.lastAssign=t,this.lastGraph=g,this.lastOptions=r,this.lastClusterMap=v,"undefined"==typeof window)return;let m=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,v,r),t&&p.forEach((({id:t,data:n})=>e.mergeNodeData(t,{x:n.x,y:n.y,z:3===i?n.z:void 0}))),null==h||h({nodes:p,edges:f}),m++,m>=c&&(window.clearInterval(this.timeInterval),n({nodes:p,edges:f}))):n({nodes:p,edges:f})}),0),this.running=!0}))}))}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:n,nodeClusterBy:r}=e,{center:i,width:o,height:a}=e;return e.width=o||"undefined"==typeof window?o:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!r,e}runOneStep(t,e,n){const{dimensions:r,height:i,width:o,gravity:a,center:s,speed:l,clustering:u,nodeClusterBy:c,clusterGravity:h}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),v=Math.sqrt(g),m={};if(this.applyCalculate(t,m,v,g),u){for(const t in e)e[t].cx=0,e[t].cy=0,e[t].count=0;p.forEach((t=>{const{data:n}=t,r=e[n[c]];ae(n.x)&&(r.cx+=n.x),ae(n.y)&&(r.cy+=n.y),r.count++}));for(const t in e)e[t].cx/=e[t].count,e[t].cy/=e[t].count;const t=h||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!ae(o.x)||!ae(o.y))return;const a=e[o[c]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),l=v*t;m[i].x-=l*(o.x-a.cx)/s,m[i].y-=l*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!ae(i.x)||!ae(i.y))return;const o=.01*v*a;m[n].x-=o*(i.x-s[0]),m[n].y-=o*(i.y-s[1]),3===r&&(m[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if(ae(o.fx)&&ae(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!ae(o.x)||!ae(o.y))return;const a=Math.sqrt(m[i].x*m[i].x+m[i].y*m[i].y+(3===r?m[i].z*m[i].z:0));if(a>0){const e=Math.min(f*(l/800),a);t.mergeNodeData(i,{x:o.x+m[i].x/a*e,y:o.y+m[i].y/a*e,z:3===r?o.z+m[i].z/a*e:void 0})}}))}applyCalculate(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)}calRepulsive(t,e,n){const r=t.getAllNodes();r.forEach((({data:t,id:i},o)=>{e[i]={x:0,y:0,z:0},r.forEach((({data:r,id:a},s)=>{if(o<=s||!ae(t.x)||!ae(r.x)||!ae(t.y)||!ae(r.y))return;let l=t.x-r.x,u=t.y-r.y,c=3===this.options.dimensions?t.z-r.z:0,h=l*l+u*u+c*c;0===h&&(h=1,l=.01,u=.01,c=.01);const d=n/h,f=l*d,p=u*d,g=c*d;e[i].x+=f,e[i].y+=p,e[a].x-=f,e[a].y-=p,3===this.options.dimensions&&(e[i].z+=g,e[a].z-=g)}))}))}calAttractive(t,e,n){t.getAllEdges().forEach((r=>{const{source:i,target:o}=r;if(!i||!o||i===o)return;const{data:a}=t.getNode(i),{data:s}=t.getNode(o);if(!(ae(s.x)&&ae(a.x)&&ae(s.y)&&ae(a.y)))return;const l=s.x-a.x,u=s.y-a.y,c=3===this.options.dimensions?s.z-a.z:0,h=Math.sqrt(l*l+u*u+c*c)/n,d=l*h,f=u*h,p=c*h;e[i].x+=d,e[i].y+=f,e[o].x-=d,e[o].y-=f,3===this.options.dimensions&&(e[i].z+=p,e[o].z-=p)}))}}const nj={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300};class rj{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},nj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{begin:i=[0,0],condense:o,preventOverlapPadding:a,preventOverlap:s,rows:l,cols:u,nodeSpacing:c,nodeSize:h,width:d,height:f,position:p}=r;let{sortBy:g}=r;const v=e.getAllNodes(),m=e.getAllEdges(),y=null==v?void 0:v.length;if(!y||1===y)return bb(e,t,i);const b=v.map((t=>hb(t)));"id"===g||ne(g)&&void 0!==b[0].data[g]||(g="degree"),"degree"===g?b.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):"id"===g?b.sort(((t,e)=>ae(e.id)&&ae(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const x=d||"undefined"==typeof window?d:window.innerWidth,E=f||"undefined"==typeof window?f:window.innerHeight,w=y,k={rows:l,cols:u};if(null!=l&&null!=u)k.rows=l,k.cols=u;else if(null!=l&&null==u)k.rows=l,k.cols=Math.ceil(w/k.rows);else if(null==l&&null!=u)k.cols=u,k.rows=Math.ceil(w/k.cols);else{const t=Math.sqrt(w*E/x);k.rows=Math.round(t),k.cols=Math.round(x/E*t)}if(k.rows=Math.max(k.rows,1),k.cols=Math.max(k.cols,1),k.cols*k.rows>w){const t=ij(k),e=oj(k);(t-1)*e>=w?ij(k,t-1):(e-1)*t>=w&&oj(k,e-1)}else for(;k.cols*k.rows<w;){const t=ij(k),e=oj(k);(e+1)*t>=w?oj(k,e+1):ij(k,t+1)}let M=o?0:x/k.cols,S=o?0:E/k.rows;if(s||c){const t=fb(10,c),n=pb(30,h,!1);b.forEach((r=>{r.data.x&&r.data.y||(r.data.x=0,r.data.y=0);const i=e.getNode(r.id),[o,s]=db(n(i)||30),l=void 0!==t?t(r):a,u=o+l,c=s+l;M=Math.max(M,u),S=Math.max(S,c)}))}const N={},O={row:0,col:0},T={};for(let t=0;t<b.length;t++){const n=b[t];let r;if(p&&(r=p(e.getNode(n.id))),r&&(void 0!==r.row||void 0!==r.col)){const t={row:r.row,col:r.col};if(void 0===t.col)for(t.col=0;aj(N,t);)t.col++;else if(void 0===t.row)for(t.row=0;aj(N,t);)t.row++;T[n.id]=t,sj(N,t)}uj(n,i,M,S,T,k,O,N)}const C={nodes:b,edges:m};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),C}))}}const ij=(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},oj=(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},aj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,sj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,lj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},uj=(t,e,n,r,i,o,a,s)=>{let l,u;const c=i[t.id];if(c)l=c.col*n+n/2+e[0],u=c.row*r+r/2+e[1];else{for(;aj(s,a);)lj(o,a);l=a.col*n+n/2+e[0],u=a.row*r+r/2+e[1],sj(s,a),lj(o,a)}t.data.x=l,t.data.y=u},cj={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},hj=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,l)=>{if(s===l)return;if(i[s]!==i[l])return;let u=a.x-e.x,c=a.y-e.y,h=Math.sqrt(u*u+c*c);if(0===h){h=1;const t=s>l?1:-1;u=.01*t,c=.01*t}if(h<o(t[s])/2+o(t[l])/2){const t=r*r/h;n[s].x+=u/h*t,n[s].y+=c/h*t}}))}))},dj=(t,e,n,r,i,o,a,s)=>{const l=o||a/10;return r&&e.forEach(((e,n)=>{const r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o);let s=o/a,l=-r/a;const u=Math.sqrt(e.x*e.x+e.y*e.y);let c=Math.acos((s*e.x+l*e.y)/u);c>Math.PI/2&&(c-=Math.PI/2,s*=-1,l*=-1);const h=Math.cos(c)*u;e.x=s*h,e.y=l*h})),t.forEach(((o,a)=>{if(a===i)return;const u=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(u>0&&a!==i){const c=Math.min(l*(n/800),u);if(o.x+=e[a].x/u*c,o.y+=e[a].y/u*c,r){let e=o.x-t[i].x,n=o.y-t[i].y;const r=Math.sqrt(e*e+n*n);e=e/r*s[a],n=n/r*s[a],o.x=t[i].x+e,o.y=t[i].y+n}}})),t},fj={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class pj{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},fj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:l,nodeSize:u,nodeSpacing:c,strictRadial:h,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:v=10,maxIteration:m=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,E=o||"undefined"==typeof window?o:window.innerHeight,w=a||[x/2,E/2];if(!(null==y?void 0:y.length)||1===y.length)return bb(e,t,w);let k=y[0];if(ne(s)){for(let t=0;t<y.length;t++)if(y[t].id===s){k=y[t];break}}else k=s||y[0];const M=mj(y,k.id),S=sb({nodes:y,edges:b}),N=ab(S),O=bj(N,M);yj(N,M,O+1);const T=N[M];let C=x-w[0]>w[0]?w[0]:x-w[0],A=E-w[1]>w[1]?w[1]:E-w[1];0===C&&(C=x/2),0===A&&(A=E/2);const P=Math.min(C,A),R=Math.max(...T),D=[],L=l||P/R;T.forEach(((t,e)=>{D[e]=t*L}));const _=gj(y,N,g,D,L,p,v),I=vj(_),j=((t,e,n)=>{try{const n=$x.mul($x.pow(e,2),-.5),r=n.mean("row"),i=n.mean("column"),o=n.mean();n.add(o).subRowVector(r).subColumnVector(i);const a=new Yx(n),s=$x.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>$x.mul([e],[s]).toJSON()[0].splice(0,t)))}catch(t){const r=[];for(let t=0;t<e.length;t++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}})(g,_,g);let B,F=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[M][0],y:(isNaN(e)?Math.random()*g:e)-j[M][1]})));if(this.run(m,F,I,_,D,M),d){B=gb(u,c);const t={nodes:y,nodeSizeFunc:B,positions:F,radii:D,height:E,width:x,strictRadial:Boolean(h),focusIdx:M,iterations:f||200,k:F.length/4.5};F=((t,e)=>{const n=Object.assign(Object.assign({},cj),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:l,focusIdx:u,radii:c=[],nodeSizeFunc:h}=n,d=t.getAllNodes(),f=[],p=o/10;for(let t=0;t<i;t++)r.forEach(((t,e)=>{f[e]={x:0,y:0}})),hj(d,r,f,a,c,h),dj(r,f,s,l,u,p,o,c);return r})(e,t)}const z=[];F.forEach(((t,e)=>{const n=hb(y[e]);n.data.x=t.x+w[0],n.data.y=t.y+w[1],z.push(n)})),t&&z.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:z,edges:b}}))}run(t,e,n,r,i,o){for(let a=0;a<=t;a++){const s=a/t;this.oneIteration(s,e,i,r,n,o)}}oneIteration(t,e,n,r,i,o){const a=1-t;e.forEach(((s,l)=>{const u=lb(s,{x:0,y:0}),c=0===u?0:1/u;if(l===o)return;let h=0,d=0,f=0;e.forEach(((t,e)=>{if(l===e)return;const n=lb(s,t),o=0===n?0:1/n,a=r[e][l];f+=i[l][e],h+=i[l][e]*(t.x+a*(s.x-t.x)*o),d+=i[l][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[l]?0:1/n[l];f*=a,f+=t*p*p,h*=a,h+=t*p*s.x*c,s.x=h/f,d*=a,d+=t*p*s.y*c,s.y=d/f}))}}const gj=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];if(e){const l={};e.forEach(((e,u)=>{const c=[];e.forEach(((e,s)=>{var h,d;if(u===s)c.push(0);else if(r[u]===r[s])if("data"===o)c.push(e*(Math.abs(u-s)*a)/(r[u]/i));else if(o){let n,f;if(l[t[u].id])n=l[t[u].id];else{const e=("id"===o?t[u].id:null===(h=t[u].data)||void 0===h?void 0:h[o])||0;n=ne(e)?e.charCodeAt(0):e,l[t[u].id]=n}if(l[t[s].id])f=l[t[s].id];else{const e=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=ne(e)?e.charCodeAt(0):e,l[t[s].id]=f}c.push(e*(Math.abs(n-f)*a)/(r[u]/i))}else c.push(e*n/(r[u]/i));else{const t=(n+i)/2;c.push(e*t)}})),s.push(c)}))}return s},vj=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},mj=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},yj=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},bj=(t,e)=>{let n=0;for(let r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},xj={center:[0,0],width:300,height:300};class Ej{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},xj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a}=r,s=e.getAllNodes(),l=o||"undefined"==typeof window?o:window.innerWidth,u=a||"undefined"==typeof window?a:window.innerHeight,c=i||[l/2,u/2],h=[];s&&s.forEach((t=>{h.push({id:t.id,data:{x:.9*(Math.random()-.5)*l+c[0],y:.9*(Math.random()-.5)*u+c[1]}})})),t&&h.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:h,edges:e.getAllEdges()}}))}}
67
67
  /**
68
68
  * @license
69
69
  * Copyright 2019 Google LLC
70
70
  * SPDX-License-Identifier: Apache-2.0
71
- */const wj=Symbol("Comlink.proxy"),kj=Symbol("Comlink.endpoint"),Mj=Symbol("Comlink.releaseProxy"),Sj=Symbol("Comlink.finalizer"),Nj=Symbol("Comlink.thrown"),Oj=t=>"object"==typeof t&&null!==t||"function"==typeof t,Tj=new Map([["proxy",{canHandle:t=>Oj(t)&&t[wj],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Cj(t,e),[n,[n]]},deserialize:t=>(t.start(),Pj(t))}],["throw",{canHandle:t=>Oj(t)&&Nj 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 Cj(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),l=(i.data.argumentList||[]).map(zj);let u;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":u=n;break;case"SET":e[s.slice(-1)[0]]=zj(i.data.value),u=!0;break;case"APPLY":u=n.apply(e,l);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[wj]:!0})}(new n(...l));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;Cj(t,n),u=function(t,e){return Bj.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[Nj]:0}}Promise.resolve(u).catch((t=>({value:t,[Nj]:0}))).then((n=>{const[i,s]=Fj(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),Aj(e),Sj in t&&"function"==typeof t[Sj]&&t[Sj]())})).catch((t=>{const[n,r]=Fj({value:new TypeError("Unserializable return value"),[Nj]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function Aj(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function Pj(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)}})),Ij(t,n,[],e)}function Rj(t){if(t)throw new Error("Proxy has been released and is not useable")}function Dj(t){return Gj(t,new Map,{type:"RELEASE"}).then((()=>{Aj(t)}))}const Lj=new WeakMap,_j="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Lj.get(t)||0)-1;Lj.set(t,e),0===e&&Dj(t)}));function Ij(t,e,n=[],r=function(){}){let i=!1;const o=new Proxy(r,{get(r,a){if(Rj(i),a===Mj)return()=>{!function(t){_j&&_j.unregister(t)}(o),Dj(t),e.clear(),i=!0};if("then"===a){if(0===n.length)return{then:()=>o};const r=Gj(t,e,{type:"GET",path:n.map((t=>t.toString()))}).then(zj);return r.then.bind(r)}return Ij(t,e,[...n,a])},set(r,o,a){Rj(i);const[s,l]=Fj(a);return Gj(t,e,{type:"SET",path:[...n,o].map((t=>t.toString())),value:s},l).then(zj)},apply(r,o,a){Rj(i);const s=n[n.length-1];if(s===kj)return Gj(t,e,{type:"ENDPOINT"}).then(zj);if("bind"===s)return Ij(t,e,n.slice(0,-1));const[l,u]=jj(a);return Gj(t,e,{type:"APPLY",path:n.map((t=>t.toString())),argumentList:l},u).then(zj)},construct(r,o){Rj(i);const[a,s]=jj(o);return Gj(t,e,{type:"CONSTRUCT",path:n.map((t=>t.toString())),argumentList:a},s).then(zj)}});return function(t,e){const n=(Lj.get(e)||0)+1;Lj.set(e,n),_j&&_j.register(t,e,t)}(o,t),o}function jj(t){const e=t.map(Fj);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const Bj=new WeakMap;function Fj(t){for(const[e,n]of Tj)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},Bj.get(t)||[]]}function zj(t){switch(t.type){case"HANDLER":return Tj.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Gj(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 Vj extends Vg{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=Pj(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())}execute(){var t;return ze(this,void 0,void 0,(function*(){if(this.running)return this;this.running=!0;const e=this.layout.options,{onTick:n}=e,r=Fe(e,["onTick"]),i={};Object.keys(r).forEach((t=>{Ut(r[t])||(i[t]=r[t])}));const o={layout:{id:this.layout.id,options:i,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},a=new Float32Array([0]),[s]=yield this.proxy.calculateLayout(o,[a]);return s}))}stop(){return this.running=!1,this.proxy.stopLayout(),this}kill(){this.proxy[Mj]()}isRunning(){return this.running}}class Wj extends qg{constructor(){super(...arguments),this.id="fishbone"}getRoot(){const t=this.context.model.getRootsData();if(!(Se(t)||t.length>2))return t[0]}formatSize(t){const e="function"==typeof t?t:()=>t;return t=>Dd(e(t))}doLayout(t,e){const{hGap:n,getRibSep:r,vGap:i,nodeSize:o,height:a}=e,{model:s}=this.context,l=this.formatSize(o);let u=l(t)[0]+r(t);const c=(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=c(n,e)}))})),e},h=t=>{if(1===t.depth)return u;const e=s.getParentData(t.id,"tree");if($j(t)){const r=s.getParentData(e.id,"tree"),o=p(t)-p(r);return h(e)+o*n/i}{const n=(e.children||[]).indexOf(t.id),r=s.getNodeData((e.children||[]).slice(n));return d(e)-r.reduce(((t,e)=>t+c(e)),0)-l(e)[0]/2}},d=xe((t=>{if(Uj(t))return l(t)[0]/2;const e=s.getParentData(t.id,"tree");if($j(t))return h(t)+c(t)+l(t)[0]/2;{const r=p(t)-p(e),o=n/i;return h(t)+r*o}}),(t=>t.id)),f=t=>p(s.getParentData(t,"tree")),p=xe((t=>{if(Uj(t))return a/2;if($j(t)){const e=s.getParentData(t.id,"tree"),n=e.children.indexOf(t.id);if(0===n)return f(e.id)+i;const r=s.getNodeLikeDatum(e.children[n-1]);if(Se(r.children))return p(r)+i;const o=s.getDescendantsData(r.id);return Math.max(...o.map((t=>$j(t)?f(t.id):p(t))))+i}{if(Se(t.children))return f(t.id)+i;const e=s.getNodeLikeDatum(t.children.slice(-1)[0]);if(Se(e.children))return p(e)+i;const n=s.getDescendantsData(t.id).slice(-1)[0];return($j(n)?f(n.id):p(n))+i}}),(t=>t.id));let g=0;const v={nodes:[],edges:[]},m=t=>{var e;null===(e=t.children)||void 0===e||e.forEach((t=>m(s.getNodeLikeDatum(t))));const n=p(t),i=d(t);if(v.nodes.push({id:t.id,x:i,y:n}),Uj(t))return;const o=s.getRelatedEdgesData(t.id,"in")[0],a=[h(t),$j(t)?n:f(t.id)];v.edges.push({id:yh(o),controlPoints:[a],relatedNodeId:t.id}),g=Math.max(g,i+r(t)),1===t.depth&&(u=g)};return m(t),v}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(Se(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 ze(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign(Object.assign({},Wj.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:l}=this.context,u=[],c=[];return s.nodes.forEach((t=>{const{id:e,x:n,y:r}=t,i=l.getNodeLikeDatum(e);u.push(Hj(i,{x:n,y:r}))})),s.edges.forEach((t=>{const{id:e,controlPoints:n}=t,r=l.getEdgeDatum(e);c.push(Hj(r,{controlPoints:n}))})),{nodes:u,edges:c}}))}}Wj.defaultOptions={direction:"RL",getRibSep:()=>60};const Hj=(t,e)=>Object.assign(Object.assign({},t),{style:Object.assign(Object.assign({},t.style||{}),e)}),Uj=t=>0===t.depth,$j=t=>(t.depth||(t.depth=0))%2==0;class Yj extends qg{constructor(){super(...arguments),this.id="snake"}formatSize(t,e){const n="function"==typeof e?e:()=>e;return t.reduce(((t,e)=>{const[r,i]=Dd(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 l=e.filter((t=>0===r[t.id])),u=e.filter((t=>0===i[t.id]));if(1!==l.length||1!==u.length)return!1;return e.filter((t=>1===r[t.id]&&1===i[t.id])).length===e.length-2}execute(t,e){return ze(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:l,clockwise:u,width:c,height:h}=Object.assign({},Yj.defaultOptions,this.options,e),[d,f,p,g]=Uc(i),v=this.formatSize(t.nodes||[],r),m=Math.ceil((t.nodes||[]).length/a);let y=s||(c-g-f-a*v[0])/(a-1),b=l||(h-d-p-m*v[1])/(m-1);(b===1/0||b<0)&&(b=0),(y===1/0||y<0)&&(y=0);const x=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),E=(x||[]).map(((t,e)=>{const n=Math.floor(e/a),r=e%a,i=g+(u?n%2==0?r:a-1-r:n%2==0?a-1-r:r)*(v[0]+y)+v[0]/2,o=d+n*(v[1]+b)+v[1]/2;return{id:t.id,style:{x:i,y:o}}}));return{nodes:E}}))}}Yj.defaultOptions={padding:0,cols:5,clockwise:!0};class qj extends Rh{}function Xj(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 Kj(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 Zj extends qj{constructor(t,e){super(t,Object.assign({},Zj.defaultOptions,e)),this.$element=Xj("background");this.context.canvas.getContainer().prepend(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(this,void 0,void 0,(function*(){e.update.call(this,t),Object.assign(this.$element.style,Pe(this.options,["key","type"]))}))}destroy(){super.destroy(),this.$element.remove()}}function Qj(t,e,n,r,i,o){const a=n-t,s=r-e;let l=i-t,u=o-e,c=l*a+u*s,h=0;c<=0?h=0:(l=a-l,u=s-u,c=l*a+u*s,h=c<=0?0:c*c/(a*a+s*s));const d=l*l+u*u-h;return d<0?0:d}function Jj(t,e,n,r){return(t-n)*(t-n)+(e-r)*(e-r)}function tB(t,e,n,r,i){return Jj(t,e,n,r)<i*i}function eB(t){const e=Math.min(t.x1,t.x2),n=Math.max(t.x1,t.x2),r=Math.min(t.y1,t.y2),i=Math.max(t.y1,t.y2);return{x:e,y:r,x2:n,y2:i,width:n-e,height:i-r}}Zj.defaultOptions={transition:"background 0.5s",backgroundSize:"cover",zIndex:"-1"};class nB{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}draw(t){t.moveTo(this.x1,this.y1),t.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(t){return new nB(t.x1,t.y1,t.x2,t.y2)}cuts(t,e){if(this.y1===this.y2)return!1;if(e<this.y1&&e<=this.y2||e>this.y1&&e>=this.y2)return!1;if(t>this.x1&&t>=this.x2)return!1;if(t<this.x1&&t<=this.x2)return!0;return t<=this.x1+(e-this.y1)*(this.x2-this.x1)/(this.y2-this.y1)}distSquare(t,e){return Qj(this.x1,this.y1,this.x2,this.y2,t,e)}ptClose(t,e,n){if(this.x1<this.x2){if(t<this.x1-n||t>this.x2+n)return!1}else if(t<this.x2-n||t>this.x1+n)return!1;if(this.y1<this.y2){if(e<this.y1-n||e>this.y2+n)return!1}else if(e<this.y2-n||e>this.y1+n)return!1;return!0}}var rB,iB;!function(t){t[t.POINT=1]="POINT",t[t.PARALLEL=2]="PARALLEL",t[t.COINCIDENT=3]="COINCIDENT",t[t.NONE=4]="NONE"}(rB||(rB={}));class oB{constructor(t,e=0,n=0){this.state=t,this.x=e,this.y=n}}function aB(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 oB(rB.POINT,t.x1+e*(t.x2-t.x1),t.y1+e*(t.y2-t.y1)):new oB(rB.NONE)}return new oB(0===n||0===r?rB.COINCIDENT:rB.PARALLEL)}function sB(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 lB(t,e,n){const r=new Set;return t.width<=0?(r.add(iB.LEFT),r.add(iB.RIGHT)):e<t.x?r.add(iB.LEFT):e>t.x+t.width&&r.add(iB.RIGHT),t.height<=0?(r.add(iB.TOP),r.add(iB.BOTTOM)):n<t.y?r.add(iB.TOP):n>t.y+t.height&&r.add(iB.BOTTOM),r}function uB(t,e){let n=e.x1,r=e.y1;const i=e.x2,o=e.y2,a=Array.from(lB(t,i,o));if(0===a.length)return!0;let s=lB(t,n,r);for(;0!==s.size;){for(const t of a)if(s.has(t))return!1;if(s.has(iB.RIGHT)||s.has(iB.LEFT)){let e=t.x;s.has(iB.RIGHT)&&(e+=t.width),r+=(e-n)*(o-r)/(i-n),n=e}else{let e=t.y;s.has(iB.BOTTOM)&&(e+=t.height),n+=(e-r)*(i-n)/(o-r),r=e}s=lB(t,n,r)}return!0}function cB(t,e){let n=Number.POSITIVE_INFINITY,r=0;function i(t,i,o,a){let s=sB(e,new nB(t,i,o,a));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s<n&&(n=s))}return i(t.x,t.y,t.x2,t.y),i(t.x,t.y,t.x,t.y2),r>1?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 hB(t,e){let n=0;const r=aB(t,new nB(e.x,e.y,e.x2,e.y));n+=r.state===rB.POINT?1:0;const i=aB(t,new nB(e.x,e.y,e.x,e.y2));n+=i.state===rB.POINT?1:0;const o=aB(t,new nB(e.x,e.y2,e.x2,e.y2));n+=o.state===rB.POINT?1:0;const a=aB(t,new nB(e.x2,e.y,e.x2,e.y2));return n+=a.state===rB.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"}(iB||(iB={}));class dB{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 dB(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 dB(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.x2&&t.y<this.y2)}distSquare(t,e){if(this.containsPt(t,e))return 0;const n=lB(this,t,e);return n.has(iB.TOP)?n.has(iB.LEFT)?Jj(t,e,this.x,this.y):n.has(iB.RIGHT)?Jj(t,e,this.x2,this.y):(this.y-e)*(this.y-e):n.has(iB.BOTTOM)?n.has(iB.LEFT)?Jj(t,e,this.x,this.y2):n.has(iB.RIGHT)?Jj(t,e,this.x2,this.y2):(e-this.y2)*(e-this.y2):n.has(iB.LEFT)?(this.x-t)*(this.x-t):n.has(iB.RIGHT)?(t-this.x2)*(t-this.x2):0}}class fB{constructor(t,e,n){this.cx=t,this.cy=e,this.radius=n}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return 2*this.radius}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return 2*this.radius}static from(t){return new fB(t.cx,t.cy,t.radius)}containsPt(t,e){return Jj(this.cx,this.cy,t,e)<this.radius*this.radius}distSquare(t,e){const n=Jj(this.cx,this.cy,t,e);if(n<this.radius*this.radius)return 0;const r=Math.sqrt(n)-this.radius;return r*r}draw(t){t.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,2*Math.PI)}}class pB{constructor(t,e=0,n=0,r=0,i=0,o=10,a=10,s=new Float32Array(Math.max(0,o*a)).fill(0)){this.pixelGroup=t,this.i=e,this.j=n,this.pixelX=r,this.pixelY=i,this.width=o,this.height=a,this.area=s}createSub(t,e){return new pB(this.pixelGroup,t.x,t.y,e.x,e.y,t.width,t.height)}static fromPixelRegion(t,e){return new pB(e,0,0,t.x,t.y,Math.ceil(t.width/e),Math.ceil(t.height/e))}copy(t,e){return new pB(this.pixelGroup,this.scaleX(e.x),this.scaleY(e.y),e.x,e.y,t.width,t.height,t.area)}boundX(t){return t<this.i?this.i:t>=this.width?this.width-1:t}boundY(t){return t<this.j?this.j: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 dB(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 dB(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 l=o;l<s;l++){const o=(l-t.j)*r,s=l*n;for(let n=i;n<a;n++){const r=t.area[n-t.i+o];0!==r&&(this.area[n+s]+=e*r)}}}fill(t){this.area.fill(t)}fillArea(t,e){const n=t.x+t.y*this.width;for(let r=0;r<t.height;r++){const i=n+r*this.width;this.area.fill(e,i,i+t.width)}}fillHorizontalLine(t,e,n,r){const i=t+e*this.width;this.area.fill(r,i,i+n)}fillVerticalLine(t,e,n,r){const i=t+e*this.width;for(let t=0;t<n;t++)this.area[i+t*this.width]=r}clear(){this.area.fill(0)}toString(){let t="";for(let e=0;e<this.height;e++){const n=e*this.width;for(let e=0;e<this.width;e++){t+=this.area[n+e].toFixed(1).padStart(6),t+=" "}t+="\n"}return t}draw(t,e=!0){if(this.width<=0||this.height<=0)return;t.save(),e&&t.translate(this.pixelX,this.pixelY);const n=this.area.reduce(((t,e)=>Math.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;e<this.width;e++)for(let n=0;n<this.height;n++){const r=this.area[e+n*this.width];t.fillStyle=`rgba(0, 0, 0, ${i(r)})`,t.fillRect(e,n,1,1)}t.restore()}drawThreshold(t,e,n=!0){if(!(this.width<=0||this.height<=0)){t.save(),n&&t.translate(this.pixelX,this.pixelY),t.scale(this.pixelGroup,this.pixelGroup);for(let n=0;n<this.width;n++)for(let r=0;r<this.height;r++){const i=this.area[n+r*this.width];t.fillStyle=i>e?"black":"white",t.fillRect(n,r,1,1)}t.restore()}}}function gB(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 vB(t,e,n){return mB(Object.assign(eB(t),{distSquare:(e,n)=>Qj(t.x1,t.y1,t.x2,t.y2,e,n)}),e,n)}function mB(t,e,n){const r=gB(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;o<t.height;o++)for(let a=0;a<t.width;a++){const s=r(e.invertScaleX(t.i+a),e.invertScaleY(t.j+o));if(0!==s){if(s<i){const e=n-Math.sqrt(s);t.set(a,o,e*e)}}else t.set(a,o,i)}}(o,e,n,((e,n)=>t.distSquare(e,n))),o}function yB(t,e){return{x:t,y:e}}function bB(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=yB(e.cx,e.cy),a=function(t,e,n){let r=Number.POSITIVE_INFINITY;return e.reduce(((e,i)=>{const o=Jj(t.x,t.y,i.cx,i.cy);if(o>r)return e;const a=new nB(t.x,t.y,i.cx,i.cy),s=function(t,e){return t.reduce(((t,n)=>uB(n,e)&&function(t,e){function n(t,n,r,i){let o=sB(e,new nB(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)<r&&(e=i,r=o*(s+1)*(s+1)),e}),null)}(o,n,t);if(null==a)return[];const s=function(t,e,n,r){const i=[],o=[];o.push(t);let a=!0;for(let t=0;t<n&&a;t++)for(a=!1;!a&&o.length>0;){const t=o.pop(),n=wB(e,t),s=n?hB(t,n):null;if(!n||!s||2!==s.count){a||i.push(t);continue}let l=r,u=kB(n,l,s,!0),c=EB(u,o)||EB(u,i),h=xB(u,e);for(;!c&&h&&l>=1;)l/=1.5,u=kB(n,l,s,!0),c=EB(u,o)||EB(u,i),h=xB(u,e);if(!u||c||h||(o.push(new nB(t.x1,t.y1,u.x,u.y)),o.push(new nB(u.x,u.y,t.x2,t.y2)),a=!0),a)continue;l=r,u=kB(n,l,s,!1);let d=EB(u,o)||EB(u,i);for(h=xB(u,e);!d&&h&&l>=1;)l/=1.5,u=kB(n,l,s,!1),d=EB(u,o)||EB(u,i),h=xB(u,e);u&&!d&&(o.push(new nB(t.x1,t.y1,u.x,u.y)),o.push(new nB(u.x,u.y,t.x2,t.y2)),a=!0),a||i.push(t)}for(;o.length>0;)i.push(o.pop());return i}(new nB(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 nB(r.x1,r.y1,i.x2,i.y2);wB(e,o)?(n.push(r),t.push(i)):t.push(o)}return n}(s,t)}(e,t,a,n,r)})).flat()}function xB(t,e){return e.some((e=>e.containsPt(t.x,t.y)))}function EB(t,e){return e.some((e=>!!tB(e.x1,e.y1,t.x,t.y,.001)||!!tB(e.x2,e.y2,t.x,t.y,.001)))}function wB(t,e){let n=Number.POSITIVE_INFINITY,r=null;for(const i of t){if(!uB(i,e))continue;const t=cB(i,e);t>=0&&t<n&&(r=i,n=t)}return r}function kB(t,e,n,r){const i=n.top,o=n.left,a=n.bottom,s=n.right;if(r){if(o.state===rB.POINT){if(i.state===rB.POINT)return yB(t.x-e,t.y-e);if(a.state===rB.POINT)return yB(t.x-e,t.y2+e);const n=t.width*t.height;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?yB(t.x-e,t.y-e):yB(t.x2+e,t.y-e):o.y<s.y?yB(t.x-e,t.y2+e):yB(t.x2+e,t.y2+e)}if(s.state===rB.POINT){if(i.state===rB.POINT)return yB(t.x2+e,t.y-e);if(a.state===rB.POINT)return yB(t.x2+e,t.y2+e)}const n=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*n?i.x>a.x?yB(t.x-e,t.y-e):yB(t.x-e,t.y2+e):i.x<a.x?yB(t.x2+e,t.y-e):yB(t.x2+e,t.y2+e)}if(o.state===rB.POINT){if(i.state===rB.POINT)return yB(t.x2+e,t.y2+e);if(a.state===rB.POINT)return yB(t.x2+e,t.y-e);const n=t.height*t.width;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?yB(t.x2+e,t.y2+e):yB(t.x-e,t.y2+e):o.y<s.y?yB(t.x2+e,t.y-e):yB(t.x-e,t.y-e)}if(s.state===rB.POINT){if(i.state===rB.POINT)return yB(t.x-e,t.y2+e);if(a.state===rB.POINT)return yB(t.x-e,t.y-e)}const l=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*l?i.x>a.x?yB(t.x2+e,t.y2+e):yB(t.x2+e,t.y-e):i.x<a.x?yB(t.x-e,t.y2+e):yB(t.x-e,t.y-e)}function MB(t,e,n,r){if(!(t.closed?n<t.length:n<t.length-1))return!1;const i=t.get(e),o=t.get(n+1);for(let a=e+1;a<=n;a++){const e=t.get(a);if(Qj(i.x,i.y,o.x,o.y,e.x,e.y)>r)return!1}return!0}function SB(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 NB{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<r;o++,t+=n)i.push(e.get(t));return new NB(i)}}(t)(this)}simplify(t){return function(t=0){return e=>{if(t<0||e.length<3)return e;const n=[];let r=0;const i=t*t;for(;r<e.length;){let t=r+1;for(;MB(e,r,t,i);)t++;n.push(e.get(r)),r=t}return new NB(n)}}(t)(this)}bSplines(t){return function(t=6){function e(t,e,n){let r=0,i=0;for(let o=-2;o<=1;o++){const a=t.get(e+o),s=SB(o,n);r+=s*a.x,i+=s*a.y}return{x:r,y:i}}return n=>{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);a<o;a++)for(let i=1;i<=t;i++)r.push(e(n,a,i/t));return new NB(r)}}(t)(this)}apply(t){return t(this)}containsElements(t){const e=function(t){if(0===t.length)return null;const e=t[0],n=new dB(e.x,e.y,0,0);for(const e of t)n.addPoint(e);return n}(this.points);return!!e&&t.every((t=>e.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 nB(r.x,r.y,r.x,r.y);for(let r=1;r<this.points.length;r++){const o=this.points[r];i.x1=i.x2,i.y1=i.y2,i.x2=o.x,i.y2=o.y,i.cuts(t,e)&&n++}return i.x1=i.x2,i.y1=i.y2,i.x2=r.x,i.y2=r.y,i.cuts(t,e)&&n++,n%2==1}}class OB{constructor(t=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=t}add(t){this.set.add(`${t.x}x${t.y}`),this.arr[this.count++]=t}contains(t){return this.set.has(`${t.x}x${t.y}`)}isFirst(t){if(0===this.count)return!1;const e=this.arr[0];return null!=e&&e.x===t.x&&e.y===t.y}path(){return new NB(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(t){return this.arr[t]}get length(){return this.count}}function TB(t,e){const n=2*(Math.floor(t.width)+Math.floor(t.height)),r=new OB(n);function i(n,r,i,o){const a=t.get(n,r);return Number.isNaN(a)?Number.NaN:a>e?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,l=t.invertScaleX(i),u=t.invertScaleY(s);for(let e=0;e<t.width*t.height;e++){const e={x:l,y:u};if(r.contains(e)){if(r.isFirst(e))return!0}else r.add(e);const n=o(i,s);switch(n){case-1:return!0;case 0:case 3:case 2:case 7:a=2;break;case 12:case 14:case 4:a=3;break;case 6:a=0===a?3:2;break;case 1:case 13:case 5:a=0;break;case 9:a=2===a?0:1;break;case 10:case 8:case 11:a=1;break;default:return console.warn("Marching squares invalid state: "+n),!0}switch(a){case 0:s--,u-=t.pixelGroup;break;case 1:s++,u+=t.pixelGroup;break;case 3:i--,l-=t.pixelGroup;break;case 2:i++,l+=t.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+n),!0}}return!0}for(let n=0;n<t.width;n++)for(let i=0;i<t.height;i++){if(t.get(n,i)<=e)continue;const a=o(n,i);if(!(a<0||15===a)&&s(n,i))return r.path()}return null}const CB={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};function AB(t){return null!=t&&"number"==typeof t.radius}function PB(t,e){if(AB(t)!==AB(e))return!1;if(AB(t)){const n=e;return t.cx===n.cx&&t.cy===n.cy&&t.radius===n.radius}const n=e;return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}var RB;!function(t){t[t.MEMBERS=0]="MEMBERS",t[t.NON_MEMBERS=1]="NON_MEMBERS",t[t.EDGES=2]="EDGES"}(RB||(RB={}));let DB=class{constructor(t={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new dB(0,0,0,0),this.potentialArea=new pB(1,0,0,0,0,0,0),this.o=Object.assign({},CB,t)}pushMember(...t){if(0!==t.length){this.dirty.add(RB.MEMBERS);for(const e of t)this.members.push({raw:e,obj:AB(e)?fB.from(e):dB.from(e),area:null})}}removeMember(t){const e=this.members.findIndex((e=>PB(e.raw,t)));return!(e<0)&&(this.members.splice(e,1),this.dirty.add(RB.MEMBERS),!0)}removeNonMember(t){const e=this.nonMembers.findIndex((e=>PB(e.raw,t)));return!(e<0)&&(this.nonMembers.splice(e,1),this.dirty.add(RB.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(RB.NON_MEMBERS),!0)}pushNonMember(...t){if(0!==t.length){this.dirty.add(RB.NON_MEMBERS);for(const e of t)this.nonMembers.push({raw:e,obj:AB(e)?fB.from(e):dB.from(e),area:null})}}pushEdge(...t){if(0!==t.length){this.dirty.add(RB.EDGES);for(const e of t)this.edges.push({raw:e,obj:nB.from(e),area:null})}}update(){const t=this.dirty.has(RB.MEMBERS),e=this.dirty.has(RB.NON_MEMBERS);let n=this.dirty.has(RB.EDGES);this.dirty.clear();const r=this.members.map((t=>t.obj));if(this.o.virtualEdges&&(t||e)){const t=bB(r,this.nonMembers.map((t=>t.obj)),this.o.maxRoutingIterations,this.o.morphBuffer),e=new Map(this.virtualEdges.map((t=>[t.obj.toString(),t.area])));this.virtualEdges=t.map((t=>{var n;return{raw:t,obj:t,area:null!==(n=e.get(t.toString()))&&void 0!==n?n:null}})),n=!0}let i=!1;if(t||n){const t=function(t,e){if(0===t.length)return new dB(0,0,0,0);const n=dB.from(t[0]);for(const e of t)n.add(e);for(const t of e)n.add(eB(t));return n}(r,this.virtualEdges.concat(this.edges).map((t=>t.obj))),e=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,n=dB.from(gB(t,e));n.equals(this.activeRegion)||(i=!0,this.activeRegion=n)}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=pB.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=pB.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 dB?"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 dB?"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 dB?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,l=i.x2-r.x2,u=i.y2-r.y2,c=i.width-a-l,h=i.height-s-u,d=n*n;o.fillArea({x:a,y:s,width:c+1,height:h+1},d);const f=[0],p=Math.max(s,a,l,u);{const i=e.invertScaleX(r.x+r.width/2);for(let o=1;o<p;o++){const a=e.invertScaleY(r.y-o),s=t.distSquare(i,a);if(!(s<d))break;{const t=n-Math.sqrt(s);f.push(t*t)}}}const g=[],v=Math.max(a,l),m=Math.max(s,l);for(let i=1;i<v;i++){const o=e.invertScaleX(r.x-i),a=[];for(let i=1;i<m;i++){const s=e.invertScaleY(r.y-i),l=t.distSquare(o,s);if(l<d){const t=n-Math.sqrt(l);a.push(t*t)}else a.push(0)}g.push(a)}for(let t=1;t<Math.min(s,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s-t,c+1,e)}for(let t=1;t<Math.min(u,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s+h+t,c+1,e)}for(let t=1;t<Math.min(a,f.length);t++){const e=f[t];o.fillVerticalLine(a-t,s,h+1,e)}for(let t=1;t<Math.min(u,f.length);t++){const e=f[t];o.fillVerticalLine(a+c+t,s,h+1,e)}for(let t=1;t<a;t++){const e=g[t-1],n=a-t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<u;t++)o.set(n,s+h+t,e[t-1])}for(let t=1;t<l;t++){const e=g[t-1],n=a+c+t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<u;t++)o.set(n,s+h+t,e[t-1])}return o}(t.obj,this.potentialArea,this.o.nodeR1):mB(t.obj,this.potentialArea,this.o.nodeR1);t.area=n,o.set(e,n)};this.members.forEach(a),this.nonMembers.forEach(a),this.members.forEach(s),this.nonMembers.forEach((t=>{this.activeRegion.intersects(t.obj)?s(t):t.area=null})),this.edges.forEach((t=>{t.area||(t.area=vB(t.obj,this.potentialArea,this.o.edgeR1))})),this.virtualEdges.forEach((t=>{t.area||(t.area=vB(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 NB([]);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({},CB,o);let s=a.threshold,l=a.memberInfluenceFactor,u=a.edgeInfluenceFactor,c=a.nonMemberInfluenceFactor;const h=(a.nodeR0-a.nodeR1)*(a.nodeR0-a.nodeR1),d=(a.edgeR0-a.edgeR1)*(a.edgeR0-a.edgeR1);for(let o=0;o<a.maxMarchingIterations;o++){if(t.clear(),0!==l){const n=l/h;for(const r of e)t.incArea(r,n)}if(0!==u){const e=u/d;for(const r of n)t.incArea(r,e)}if(0!==c){const e=c/h;for(const n of r)t.incArea(n,e)}const f=TB(t,s);if(f&&i(f))return f;if(s*=.95,o<=.5*a.maxMarchingIterations)l*=1.2,u*=1.2;else{if(!(0!==c&&r.length>0))break;c*=.8}}return new NB([])}(e,n,r,i,(t=>t.containsElements(o)),t)}};class LB extends qj{constructor(t,e){super(t,ke({},LB.defaultOptions,e)),this.members=new Map,this.avoidMembers=new Map,this.bubbleSetOptions={},this.drawBubbleSets=()=>{const{style:t,bubbleSetOptions:e}=this.parseOptions();Ne(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 qd({style:n}),this.context.canvas.appendChild(this.shape))},this.updateBubbleSetsPath=t=>{if(!this.shape)return;const e=yh(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(!t&&Ne(n,r)&&Ne(i,o))return this.path;const{enter:a=[],exit:s=[]}=Ch(r,n,(t=>t)),{enter:l=[],exit:u=[]}=Ch(o,i,(t=>t));t&&(s.push(t),a.push(t));const c=(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]=IB(e,t),this.bubbleSets.pushEdge(n)):([n]=_B(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))}}))};c(s,!1,!0),c(a,!0,!0),c(u,!1,!1),c(l,!0,!1);const h=this.bubbleSets.compute().sample(8).simplify(0).bSplines().simplify(0);return this.path=Yd(h.points.map(nd)),this.path},this.bindEvents(),this.bubbleSets=new DB(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 DB(this.options),this.members=new Map,this.avoidMembers=new Map}parseOptions(){const t=this.options,{type:e,key:n,members:r,avoidMembers:i}=t,o=Fe(t,["type","key","members","avoidMembers"]),a=Object.keys(o).reduce(((t,e)=>(e in CB?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=Ut(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.destroy(),super.destroy()}}LB.defaultOptions=Object.assign({members:[],avoidMembers:[],fill:"lightblue",fillOpacity:.2,stroke:"blue",strokeOpacity:.2},CB);const _B=(t,e)=>(Array.isArray(e)?e:[e]).map((e=>{const n=t.getElementRenderBounds(e);return new dB(n.min[0],n.min[1],Yc(n),qc(n))})),IB=(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 nB.from({x1:r[0],y1:r[1],x2:i[0],y2:i[1]})}));class jB extends qj{constructor(t,e){super(t,Object.assign({},jB.defaultOptions,e)),this.targetElement=null,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=Xj("contextmenu",!1,{zIndex:"99"});const{className:t}=this.options;t&&this.$element.classList.add(t);this.context.canvas.getContainer().appendChild(this.$element),Kj("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: hidden;\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-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 ze(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();this.$element.style.left=`${t.client.x-i.left+n[0]}px`,this.$element.style.top=`${t.client.y-i.top+n[1]}px`,this.$element.style.display="block",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 ze(this,void 0,void 0,(function*(){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(yield n(t)).map((t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`)).join("")}\n </ul>\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)}}jB.defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};class BB extends qj{constructor(t,e){super(t,Object.assign({},BB.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:l}=this.options;for(let t=0;t<r;t++){for(let t=0;t<l;t++){const t={};n.forEach((e=>{var n;if(e.source===e.target)return;const r=yh(e);t[r]=this.getEdgeForces(e,s,a);for(let e=0;e<s+1;e++)(n=this.edgePoints)[r]||(n[r]=[]),this.edgePoints[r][e]=Ih(this.edgePoints[r][e],t[r][e])}))}a/=2,s*=o,l*=i,this.divideEdges(s)}n.forEach((t=>{const n=yh(t),r=e.getElement(n);null==r||r.update({d:Kp(this.edgePoints[n])})}))},this.bindEvents()}get nodeMap(){const t=this.context.model.getNodeData();return Object.fromEntries(t.map((t=>[yh(t),Yh(Jh(t))])))}divideEdges(t){this.context.model.getEdgeData().forEach((e=>{var n;const r=yh(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(Fh(Ih(i,o),2)),this.edgePoints[r].push(o);else{const e=(0===this.edgePoints[r].length?Gh(i,o):UB(this.edgePoints[r]))/(t+1);let n=e;const a=[i];for(let t=1;t<this.edgePoints[r].length;t++){const i=this.edgePoints[r][t-1],o=this.edgePoints[r][t];let s=Gh(o,i);for(;s>n;){const t=n/s,r=Ih(i,Bh(jh(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]=jh(n,e);return{source:e,target:n,vx:r,vy:i,length:Gh(e,n)}}measureEdgeCompatibility(t,e){const n=this.getVectorPosition(t),r=this.getVectorPosition(e);return FB(n,r)*zB(n,r)*GB(n,r)*HB(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=yh(r)]||(t[a]=[]),t[yh(r)].push(n),t[s=yh(n)]||(t[s]=[]),t[yh(n)].push(r))}))})),t}getSpringForce(t,e){const{pre:n,cur:r,next:i}=t;return Bh(jh(Ih(n,i),Bh(r,2)),e)}getElectrostaticForce(t,e){Se(this.edgeBundles)&&(this.edgeBundles=this.getEdgeBundles());const n=this.edgeBundles[yh(e)];let r=[0,0];return null==n||n.forEach((n=>{const i=this.edgePoints[yh(n)][t],o=this.edgePoints[yh(e)][t],a=jh(i,o),s=Gh(i,o);r=Ih(r,Bh(a,1/s))})),r}getEdgeForces(t,e,n){const r=this.nodeMap[t.source],i=this.nodeMap[t.target],o=this.options.K/(Gh(r,i)*(e+1)),a=[[0,0]],s=yh(t);for(let r=1;r<e;r++){const e=this.getSpringForce({pre:this.edgePoints[s][r-1],cur:this.edgePoints[s][r],next:this.edgePoints[s][r+1]||[0,0]},o),i=this.getElectrostaticForce(r,t);a.push(Bh(Ih(e,i),n))}return a.push([0,0]),a}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onBundle)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onBundle)}destroy(){this.unbindEvents(),super.destroy()}}BB.defaultOptions={K:.1,lambda:.1,divisions:1,divRate:2,cycles:6,iterations:90,iterRate:2/3,bundleThreshold:.6};const FB=(t,e)=>Math.abs(function(t,e){return t.reduce(((t,n,r)=>t+n*e[r]),0)}([t.vx,t.vy],[e.vx,e.vy])/(t.length*e.length)),zB=(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)},GB=(t,e)=>{const n=(t.length+e.length)/2;return n/(n+Gh(Fh(Ih(t.source,t.target),2),Fh(Ih(e.source,e.target),2)))},VB=(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]]},WB=(t,e)=>{const n=VB(e.source,t),r=VB(e.target,t),i=Fh(Ih(n,r),2),o=Fh(Ih(t.source,t.target),2);return 0===Gh(n,r)?0:Math.max(0,1-2*Gh(o,i)/Gh(n,r))},HB=(t,e)=>Math.min(WB(t,e),WB(e,t)),UB=t=>{let e=0;for(let n=1;n<t.length;n++)e+=Gh(t[n],t[n-1]);return e},$B={fill:"#fff",fillOpacity:1,lineWidth:1,stroke:"#000",strokeOpacity:.8,zIndex:-1/0};class YB extends qj{constructor(t,e){super(t,Object.assign({},YB.defaultOptions,e)),this.shapes=new Map,this.r=this.options.r,this.onEdgeFilter=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=nd(t.canvas);this.renderLens(e),this.renderFocusElements()},this.renderLens=t=>{const e=Object.assign({},$B,this.options.style);this.isLensOn||(this.lens=new rf({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,rd(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(yh(e),"node"))),edges:i.filter((e=>t(yh(e),"edge"))),combos:o.filter((e=>t(yh(e),"combo")))}},this.getFocusElements=t=>{const{nodes:e,edges:n}=this.getFilterData(),r=e.filter((e=>Gh(Jh(e),t)<this.r)),i=r.map((t=>yh(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=yh(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),l=this.getElementStyle(s,n);a.update(l)};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,l=a.getCanvasByClient([n,r]),u=null===(e=this.lens)||void 0===e?void 0:e.getCenter();if(!this.isLensOn||Gh(l,u)>this.r)return;const{maxR:c,minR:h}=this.options,d=i+o>0?1/.95:.95,f=Math.min(...s.getSize())/2;this.r=Math.max(h||0,Math.min(c||f,this.r*d)),this.renderLens(u),this.renderFocusElements()},this.isLensDragging=!1,this.onDragStart=t=>{var e;const n=nd(t.canvas),r=null===(e=this.lens)||void 0===e?void 0:e.getCenter();!this.isLensOn||Gh(n,r)>this.r||(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=nd(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()}}YB.defaultOptions={trigger:"pointermove",r:60,nodeType:"both",filter:()=>!0,style:{lineWidth:2},nodeStyle:{label:!1},edgeStyle:{label:!0},scaleRBy:"wheel",preventDefault:!0};const qB={fill:"#ccc",fillOpacity:.1,lineWidth:2,stroke:"#000",strokeOpacity:.8,labelFontSize:12};class XB extends qj{constructor(t,e){super(t,Object.assign({},XB.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=nd(t.canvas);this.onMagnify(e)},this.onMagnify=t=>{t.some(isNaN)||(this.renderLens(t),this.renderFocusElements())},this.renderLens=t=>{const e=Object.assign({},qB,this.options.style);this.isLensOn||(this.lens=new rf({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,rd(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=Jh(o),s=Gh(a,e);if(s>this.r)return;const l=n*s/(this.d*s+this.r),[u,c]=a,[h,d]=e,f=[h+l*((u-h)/s),d+l*((c-d)/s)],p=yh(o),g=this.getNodeStyle(o),v=Ae(t.getElementRenderStyle(p),Object.keys(g));r.set(p,Object.assign(Object.assign({},rd(f)),g)),i.set(p,Object.assign(Object.assign({},rd(a)),v))})),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}=Ch(Array.from(this.prevMagnifiedStyleMap.keys()),Array.from(t.keys()),(t=>t)),s=new Set,l=(t,e)=>{const i=r.getElement(t);null==i||i.update(e),n.getRelatedEdgesData(t).forEach((t=>{s.add(yh(t))}))};[...i,...a].forEach((e=>{l(e,t.get(e))})),o.forEach((t=>{l(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!(Gh(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!(Gh(nd(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=nd(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()}}XB.defaultOptions={trigger:"pointermove",r:120,d:1.5,maxD:5,minD:0,showDPercent:!0,style:{},nodeStyle:{label:!0},preventDefault:!0};class KB extends qj{constructor(t,e){super(t,Object.assign({},KB.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 md(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=>{Tc(`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()}}KB.defaultOptions={trigger:{},autoFit:!0};class ZB extends qj{constructor(t,e){super(t,Object.assign({},ZB.defaultOptions,e)),this.$element=Xj("grid-line",!0),this.offset=[0,0],this.currentScale=1,this.followZoom=t=>{const{data:{scale:e,origin:n}}=t;if(!e)return;const r=this.currentScale;this.currentScale=e;const i=e/r,o=Bh(n||this.context.graph.getCanvasCenter(),1-i),a=this.baseSize*e,s=Ih($h(Bh(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=$h(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=$h(Ih(this.offset,t),e),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}parseFollow(t){var e,n;return pe(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 QB(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=yh(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 JB(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:a=[],ComboAdded:s=[],ComboUpdated:l=[],ComboRemoved:u=[]}=ie(t,(t=>t.type));return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:l},remove:{nodes:r,edges:a,combos:u}}}function tF(t,e){for(const n in t)qt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),tF(t[n],e[n])):void 0===e[n]&&(e[n]=Rc(n))}function eF(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:a}=JB(QB(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(yh(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)})}tF(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}ZB.defaultOptions={border:!0,borderLineWidth:1,borderStroke:"#eee",borderStyle:"solid",lineWidth:1,size:20,stroke:"#eee"};class nF extends qj{constructor(e,n){super(e,Object.assign({},nF.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(xh(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(eF(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 Vg;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=[]}}nF.defaultOptions={stackSize:0};const rF={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 iF=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 oF=+(Math.pow(2,27)+1);function aF(t,e,n){const r=t*e,i=oF*t,o=i-(i-t),a=t-o,s=oF*e,l=s-(s-e),u=e-l,c=a*u-(r-o*l-a*l-o*u);return n?(n[0]=c,n[1]=r,n):[c,r]}function sF(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 lF(t,e){const n=t.length;if(1===n){const n=aF(t[0],e);return n[0]?n:[n[1]]}const r=new Array(2*n),i=[.1,.1],o=[.1,.1];let a=0;aF(t[0],e,i),i[0]&&(r[a++]=i[0]);for(let s=1;s<n;++s){aF(t[s],e,o);sF(i[1],o[0],i),i[0]&&(r[a++]=i[0]);const n=o[1],l=i[1],u=n+l,c=l-(u-n);i[1]=u,c&&(r[a++]=c)}return i[1]&&(r[a++]=i[1]),0===a&&(r[a++]=0),r.length=a,r}function uF(t,e){const n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){const n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],-e[0]);const i=new Array(n+r);let o=0,a=0,s=0;const l=Math.abs;let u,c,h=t[a],d=l(h),f=-e[s],p=l(f);d<p?(c=h,a+=1,a<n&&(h=t[a],d=l(h))):(c=f,s+=1,s<r&&(f=-e[s],p=l(f))),a<n&&d<p||s>=r?(u=h,a+=1,a<n&&(h=t[a],d=l(h))):(u=f,s+=1,s<r&&(f=-e[s],p=l(f)));let g,v,m,y,b,x=u+c,E=x-u,w=c-E,k=w,M=x;for(;a<n&&s<r;)d<p?(u=h,a+=1,a<n&&(h=t[a],d=l(h))):(u=f,s+=1,s<r&&(f=-e[s],p=l(f))),c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g;for(;a<n;)u=h,c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g,a+=1,a<n&&(h=t[a]);for(;s<r;)u=f,c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g,s+=1,s<r&&(f=-e[s]);return k&&(i[o++]=k),M&&(i[o++]=M),o||(i[o++]=0),i.length=o,i}function cF(t,e){const n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){const n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],e[0]);const i=new Array(n+r);let o=0,a=0,s=0;const l=Math.abs;let u,c,h=t[a],d=l(h),f=e[s],p=l(f);d<p?(c=h,a+=1,a<n&&(h=t[a],d=l(h))):(c=f,s+=1,s<r&&(f=e[s],p=l(f))),a<n&&d<p||s>=r?(u=h,a+=1,a<n&&(h=t[a],d=l(h))):(u=f,s+=1,s<r&&(f=e[s],p=l(f)));let g,v,m,y,b,x=u+c,E=x-u,w=c-E,k=w,M=x;for(;a<n&&s<r;)d<p?(u=h,a+=1,a<n&&(h=t[a],d=l(h))):(u=f,s+=1,s<r&&(f=e[s],p=l(f))),c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g;for(;a<n;)u=h,c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g,a+=1,a<n&&(h=t[a]);for(;s<r;)u=f,c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g,s+=1,s<r&&(f=e[s]);return k&&(i[o++]=k),M&&(i[o++]=M),o||(i[o++]=0),i.length=o,i}function hF(t,e,n,r){return function(n,i,o){const a=t(t(e(i[1],o[0]),e(-o[1],i[0])),t(e(n[1],i[0]),e(-i[1],n[0]))),s=t(e(n[1],o[0]),e(-o[1],n[0])),l=r(a,s);return l[l.length-1]}}function dF(t,e,n,r){return function(i,o,a,s){const l=t(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),s[2]))),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2])))),u=t(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),s[2]))),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2])))),c=r(l,u);return c[c.length-1]}}function fF(t,e,n,r){return function(i,o,a,s,l){const u=t(t(t(n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),a[2]),t(n(t(e(a[1],l[0]),e(-l[1],a[0])),-s[2]),n(t(e(a[1],s[0]),e(-s[1],a[0])),l[2]))),o[3]),t(n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),o[2]),t(n(t(e(o[1],l[0]),e(-l[1],o[0])),-s[2]),n(t(e(o[1],s[0]),e(-s[1],o[0])),l[2]))),-a[3]),n(t(n(t(e(a[1],l[0]),e(-l[1],a[0])),o[2]),t(n(t(e(o[1],l[0]),e(-l[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),l[2]))),s[3]))),t(n(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),s[2]))),-l[3]),t(n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),o[2]),t(n(t(e(o[1],l[0]),e(-l[1],o[0])),-s[2]),n(t(e(o[1],s[0]),e(-s[1],o[0])),l[2]))),i[3]),n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-s[2]),n(t(e(i[1],s[0]),e(-s[1],i[0])),l[2]))),-o[3])))),t(t(n(t(n(t(e(o[1],l[0]),e(-l[1],o[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),l[2]))),s[3]),t(n(t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2]))),-l[3]),n(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),s[2]))),i[3]))),t(n(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),s[2]))),-o[3]),t(n(t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2]))),a[3]),n(t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2]))),-s[3]))))),c=t(t(t(n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),a[2]),t(n(t(e(a[1],l[0]),e(-l[1],a[0])),-s[2]),n(t(e(a[1],s[0]),e(-s[1],a[0])),l[2]))),i[3]),n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-s[2]),n(t(e(i[1],s[0]),e(-s[1],i[0])),l[2]))),-a[3])),t(n(t(n(t(e(a[1],l[0]),e(-l[1],a[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),l[2]))),s[3]),n(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),s[2]))),-l[3]))),t(t(n(t(n(t(e(a[1],l[0]),e(-l[1],a[0])),o[2]),t(n(t(e(o[1],l[0]),e(-l[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),l[2]))),i[3]),n(t(n(t(e(a[1],l[0]),e(-l[1],a[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),l[2]))),-o[3])),t(n(t(n(t(e(o[1],l[0]),e(-l[1],o[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),l[2]))),a[3]),n(t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2]))),-l[3])))),h=r(u,c);return h[h.length-1]}}function pF(t){return(3===t?hF:4===t?dF:fF)(cF,aF,lF,uF)}const gF=pF(3),vF=pF(4),mF=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,n){const r=(t[1]-n[1])*(e[0]-n[0]),i=(t[0]-n[0])*(e[1]-n[1]),o=r-i;let a;if(r>0){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:gF(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],l=e[1]-r[1],u=n[1]-r[1],c=t[2]-r[2],h=e[2]-r[2],d=n[2]-r[2],f=o*u,p=a*l,g=a*s,v=i*u,m=i*l,y=o*s,b=c*(f-p)+h*(g-v)+d*(m-y),x=7771561172376103e-31*((Math.abs(f)+Math.abs(p))*Math.abs(c)+(Math.abs(g)+Math.abs(v))*Math.abs(h)+(Math.abs(m)+Math.abs(y))*Math.abs(d));return b>x||-b>x?b:vF(t,e,n,r)}];function yF(t){let e=mF[t.length];return e||(e=mF[t.length]=pF(t.length)),e.apply(void 0,...t)}var bF=function(){for(;mF.length<=5;)mF.push(pF(mF.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,yF,...mF);for(let e=0;e<=5;++e)t[e]=mF[e];return t}();const xF=bF[3];function EF(t,e,n,r){const i=bF(t,n,r),o=bF(e,n,r);if(i>0&&o>0||i<0&&o<0)return!1;const a=bF(n,t,e),s=bF(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,l]=[Math.min(o,a),Math.max(o,a)],u=n[i],c=r[i],[h,d]=[Math.min(u,c),Math.max(u,c)];if(d<s||l<h)return!1}return!0}(t,e,n,r))}function wF(t,e){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function kF(t,e,n){const r=[e[0]-t[0],e[1]-t[1]],i=[n[0]-t[0],n[1]-t[1]],o=wF(t,e),a=wF(t,n);return(r[0]*i[0]+r[1]*i[1])/Math.sqrt(o*a)}function MF(t,e){for(let n=0;n<e.length-1;n++){const r=[e[n],e[n+1]];if(!(t[0][0]===r[0][0]&&t[0][1]===r[0][1]||t[0][0]===r[1][0]&&t[0][1]===r[1][1])&&EF(t[0],t[1],r[0],r[1]))return!0}return!1}function SF(t){return[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]}function NF(t,e,n){let r,i,o=null,a=CF,s=CF;for(let l=0;l<e.length;l++)r=kF(t[0],t[1],e[l]),i=kF(t[1],t[0],e[l]),r>a&&i>s&&!MF([t[0],e[l]],n)&&!MF([t[1],e[l]],n)&&(a=r,s=i,o=e[l]);return o}function OF(t,e,n,r,i){let o=!1;for(let a=0;a<t.length-1;a++){const s=[t[a],t[a+1]],l=s[0][0]+","+s[0][1]+","+s[1][0]+","+s[1][1];if(wF(s[0],s[1])<e||i.has(l))continue;let u,c,h,d=0,f=SF(s);do{f=r.extendBbox(f,d),u=f[2]-f[0],c=f[3]-f[1],h=NF(s,r.rangePoints(f),t),d++}while(null===h&&(n[0]>u||n[1]>c));u>=n[0]&&c>=n[1]&&i.add(l),null!==h&&(t.splice(a+1,0,h),r.removePoint(h),o=!0)}return o?OF(t,e,n,r,i):t}function TF(t,e,n){const r=e||20,i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];n[0]===i[0]&&n[1]===i[1]||e.push(i),n=i}return e}(function(t){return t.sort((function(t,e){return t[0]-e[0]||t[1]-e[1]}))}(rF.toXy(t,n)));if(i.length<4){const t=i.concat([i[0]]);return n?rF.fromXy(t,n):t}const o=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=t.length-1;o>=0;o--)t[o][0]<e&&(e=t[o][0]),t[o][1]<n&&(n=t[o][1]),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]*AF,o[1]*AF],s=function(t){const e=t.length;if(e<3){const n=new Array(e);for(let t=0;t<e;++t)n[t]=t;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:n}const n=new Array(e);for(let t=0;t<e;++t)n[t]=t;n.sort(((e,n)=>t[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;o<e;++o){const e=n[o],a=t[e];let s=r.length;for(;s>1&&xF(t[r[s-2]],t[r[s-1]],a)<=0;)s-=1,r.pop();for(r.push(e),s=i.length;s>1&&xF(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;t<e;++t)o[a++]=r[t];for(let t=i.length-2;t>0;--t)o[a++]=i[t];return o}(i).reverse().map((t=>i[t]));s.push(s[0]);const l=i.filter((function(t){return s.indexOf(t)<0})),u=Math.ceil(1/(i.length/(o[0]*o[1]))),c=OF(s,Math.pow(r,2),a,function(t,e){return new iF(t,e)}(l,u),new Set);return n?rF.fromXy(c,n):c}const CF=Math.cos(90/(180/Math.PI)),AF=.6;const PF=(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]]},RF=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?Ih(t[0],zh(Wh(jh(t[0],t[1])),e)):t[0],o="sharp"===n?Ih(t[1],zh(Wh(jh(t[1],t[0])),e)):t[1],a=zh(Wh(Uh(jh(i,o),!1)),e),s=zh(a,-1),l=Ih(i,a),u=Ih(o,a),c=Ih(o,s),h=Ih(i,s);return"sharp"===n?[["M",l[0],l[1]],["L",u[0],u[1]],["L",c[0],c[1]],["L",h[0],h[1]],["Z"]]:[["M",l[0],l[1]],["L",u[0],u[1]],["A",...r,c[0],c[1]],["L",h[0],h[1]],["A",...r,l[0],l[1]]]},DF=(t,e)=>{const n=fd(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],l=t[o],u=t[a],c=jh(s,l),h=jh(l,n),d=jh(n,u),f=(t,e)=>Hh(t,e,!0)<Math.PI,p=f(c,h),g=f(h,d),v=t=>zh(Wh(Uh(t,!1)),e),m=v(h);return[{p:Yh(Ih(l,p?v(c):m)),concave:p&&l},{p:Yh(Ih(n,g?v(d):m)),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}))},LF=(t,e)=>{const n=fd(t).map(((e,n)=>({p:e,v:Wh(jh(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=Wh(Ih(a,zh(r.v,Hh(a,r.v,!0)<Math.PI?1:-1)));r.p=Ih(r.p,zh(s,e))})),Yd(n.map((t=>t.p)))},_F=(t,e)=>{const n=t.map(((n,r)=>{const i=t[0===r?t.length-1:r-1],o=qh(zh(Wh(Uh(jh(i,n),!1)),e));return[Ih(i,o),Ih(n,o)]})),r=n.flat();return r.map(((t,e)=>{if(e%2==0)return null;return Zh([r[(e-1)%r.length],r[e%r.length]],[r[(e+1)%r.length],r[(e+2)%r.length]],!0)})).filter(Boolean).map(((t,e)=>[0===e?"M":"L",t[0],t[1]])).concat([["Z"]])};class IF extends qj{constructor(t,e){super(t,Object.assign({},IF.defaultOptions,e)),this.hullMemberIds=[],this.drawHull=()=>{if(this.shape){const t=!Ne(this.optionsCache,this.options);this.shape.update(this.getHullStyle(t))}else this.shape=new qd({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape);this.optionsCache=Object.assign({},this.options)},this.updateHullPath=t=>{this.shape&&this.options.members.includes(yh(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=TF(r.map(Jh),this.options.concavity).slice(1).reverse(),o=i.flatMap((t=>r.filter((e=>Ne(Jh(e),t))).map(yh)));return Ne(o,this.hullMemberIds)&&!t||(this.hullMemberIds=o,this.path=function(t,e,n){if(1===t.length)return PF(t[0],e,n);if(2===t.length)return RF(t,e,n);if(3===t.length){const[r,i,o]=fd(t);if(sd(r,i,o))return RF([r,o],e,n)}switch(n){case"smooth":return LF(t,e);case"sharp":return _F(t,e);default:return DF(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)}getHullStyle(t){const e=this.options,{members:n,padding:r,corner:i}=e,o=Fe(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=Ut(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}getMember(){return this.options.members}destroy(){this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.drawHull),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function jF(t,e){e(t),t.children&&t.children.forEach((function(t){t&&jF(t,e)}))}function BF(t){zF(t,!0)}function FF(t){zF(t,!1)}function zF(t,e){var n=e?"visible":"hidden";jF(t,(function(t){t.attr("visibility",n)}))}IF.defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",fillOpacity:.2,labelOpacity:1,stroke:"blue",strokeOpacity:.2};var GF=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,We([],Ve(e),!1))||this;return r.isMutationObserved=!0,r.addEventListener(Vs.INSERTED,(function(){FF(r)})),r}return je(e,t),e}(jl);function VF(t){var e=t.appendChild(new GF({class:"offscreen"}));return FF(e),e}var WF=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=Fe(e,["style"]);return t.call(this,Be({style:Be({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return je(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=VF(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(Zl);function HF(t){return t*Math.PI/180}function UF(t){return Number((180*t/Math.PI).toPrecision(5))}var $F=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=n,this.height=r}return Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y},enumerable:!1,configurable:!0}),t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t.prototype.toJSON=function(){return{x:this.x,y:this.y,width:this.width,height:this.height,top:this.top,right:this.right,bottom:this.bottom,left:this.left}},t.prototype.isPointIn=function(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom},t}();function YF(t,e){return Ut(t)?t.apply(void 0,We([],Ve(e),!1)):t}var qF,XF=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map((function(t){var e=Ve(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},KF=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=Ve(i,2),a=o[0],s=o[1],l=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?Jt(s)?(Jt(t[a])||(l[a]={}),n<r?KF(t[a],s,n+1,r):l[a]=e[a]):Yt(s)?(l[a]=[],l[a]=l[a].concat(s)):l[a]=s:l[a]=s)}))},ZF=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)KF(t,e[r]);return t},QF=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},JF=xe((function(t,e){var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return qF||(qF=bl.offscreenCanvasCreator.getOrCreateContext(void 0)),qF.font=[o,a,i,"".concat(n,"px"),r].join(" "),qF.measureText(t).width}),(function(t,e){return[t,Object.values(e||tz(t)).join()].join("")}),4096),tz=function(t){var e=t.style.fontFamily||"sans-serif",n=t.style.fontWeight||"normal",r=t.style.fontStyle||"normal",i=t.style.fontVariant,o=t.style.fontSize;return{fontSize:o="object"==typeof o?o.value:o,fontFamily:e,fontWeight:n,fontStyle:r,fontVariant:i}};function ez(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function nz(t,e){var n=ez(t);n&&n.attr(e)}function rz(t,e,n){void 0===n&&(n="..."),nz(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function iz(t){var e=t.canvas,n=t.touches,r=t.offsetX,i=t.offsetY;if(e)return[e.x,e.y];if(n){var o=n[0];return[o.clientX,o.clientY]}return r&&i?[r,i]:[0,0]}function oz(t){return"function"==typeof t?t():ne(t)||ae(t)?new WF({style:{text:String(t)}}):t}function az(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=function(t){t.node().removeChildren()}),t?n(e):(r&&i(e),null)}function sz(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=!1),!!(r&&t===e||i&&t===n)||t>e&&t<n}function lz(t,e){return"number"==typeof t&&"number"==typeof e?function(t,e){return function(n){return t*(1-n)+e*n}}(t,e):Array.isArray(t)&&Array.isArray(e)?function(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0;return function(i){var o=new Array(r),a=new Array(n),s=0;for(s=0;s<r;++s)o[s]=lz(t[s],e[s]);for(;s<n;++s)a[s]=e[s];for(s=0;s<r;++s)a[s]=o[s](i);return a}}(t,e):"object"==typeof t&&"object"==typeof e?function(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n={},r={};return Object.entries(e).forEach((function(e){var i=Ve(e,2),o=i[0],a=i[1];o in t?n[o]=lz(t[o],a):r[o]=a})),function(t){return Object.entries(n).forEach((function(e){var n=Ve(e,2),i=n[0],o=n[1];return r[i]=o(t)})),r}}(t,e):function(e){return t}}function uz(t,e){return[t[0]*e,t[1]*e]}function cz(t,e){return[t[0]+e[0],t[1]+e[1]]}function hz(t,e){return[t[0]-e[0],t[1]-e[1]]}function dz(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function fz(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function pz(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function gz(t){if(0===t[0]&&0===t[1])return[0,0];var e=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2));return[t[0]/e,t[1]/e]}function vz(t,e){return+t.toPrecision(e)}function mz(t,e){var n={},r=Array.isArray(e)?e:[e];for(var i in t)r.includes(i)||(n[i]=t[i]);return n}function yz(t,e,n){void 0===n&&(n=[[0,0],[1,1]]);for(var r=[],i=0,o=t.length;i<o;i+=2)r.push([t[i],t[i+1]]);var a,s,l,u=function(t,e,n,r){var i,o,a,s,l,u,c=[],h=!!r,d=[1/0,1/0],f=[-1/0,-1/0];if(h){d=(i=Ve(r,2))[0],f=i[1];for(var p=0,g=t.length;p<g;p+=1)d=dz(d,m=t[p]),f=fz(f,m)}p=0;for(var v=t.length;p<v;p+=1){var m=t[p];if(0===p)u=m;else if(p===v-1)l=m,c.push(u),c.push(l);else{o=t[p-1];var y=[0,0];y=uz(y=hz(a=t[p+1],o),e);var b=pz(m,o),x=pz(m,a),E=b+x;0!==E&&(b/=E,x/=E);var w=uz(y,-b),k=uz(y,x);l=cz(m,w),s=dz(s=cz(m,k),fz(a,m)),s=fz(s,dz(a,m)),l=dz(l=cz(m,w=uz(w=hz(s,m),-b/x)),fz(o,m)),s=cz(m,k=uz(k=hz(m,l=fz(l,dz(o,m))),x/b)),h&&(l=dz(l=fz(l,d),f),s=dz(s=fz(s,d),f)),c.push(u),c.push(l),u=s}}return c}(r,.4,0,n),c=r.length,h=[];for(i=0;i<c-1;i+=1)a=u[2*i],s=u[2*i+1],l=r[i+1],h.push(["C",a[0],a[1],s[0],s[1],l[0],l[1]]);return h}var bz=["$el","cx","cy","d","dx","dy","fill","fillOpacity","filter","fontFamily","fontSize","fontStyle","fontVariant","fontWeight","height","img","increasedLineWidthForHitTesting","innerHTML","isBillboard","billboardRotation","isSizeAttenuation","isClosed","isOverflowing","leading","letterSpacing","lineDash","lineHeight","lineWidth","markerEnd","markerEndOffset","markerMid","markerStart","markerStartOffset","maxLines","metrics","miterLimit","offsetX","offsetY","opacity","path","points","r","radius","rx","ry","shadowColor","src","stroke","strokeOpacity","text","textAlign","textBaseline","textDecorationColor","textDecorationLine","textDecorationStyle","textOverflow","textPath","textPathSide","textPathStartOffset","transform","transformOrigin","visibility","width","wordWrap","wordWrapWidth","x","x1","x2","y","y1","y2","z1","z2","zIndex"];function xz(t){return bz.includes(t)}function Ez(t){var e={};for(var n in t)xz(n)&&(e[n]=t[n]);return e}function wz(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,a=e/Math.max(i,o);return t.style.transform="scale(".concat(a,")"),a}var kz=function(){function t(t,n,r,i,o,a,s){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=[null,null,null,null,null]),void 0===a&&(a=[]),void 0===s&&(s=[]),e.add(this),this._elements=Array.from(t),this._data=n,this._parent=r,this._document=i,this._enter=o[0],this._update=o[1],this._exit=o[2],this._merge=o[3],this._split=o[4],this._transitions=a,this._facetElements=s}var e,n,r;return t.prototype.selectAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(e,null,this._elements[0],this._document)},t.prototype.selectFacetAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(this._elements,null,this._parent,this._document,void 0,void 0,e)},t.prototype.select=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t)[0]||null:t;return new n([e],null,e,this._document)},t.prototype.append=function(t){var e=this,r="function"==typeof t?t:function(){return e.createElement(t)},i=[];if(null!==this._data){for(var o=0;o<this._data.length;o++){var a=this._data[o],s=Ve(Array.isArray(a)?a:[a,null],2),l=s[0],u=s[1];(h=r(l,o)).__data__=l,null!==u&&(h.__fromElements__=u),this._parent.appendChild(h),i.push(h)}return new n(i,null,this._parent,this._document)}for(o=0;o<this._elements.length;o++){var c=this._elements[o],h=r(l=c.__data__,o);c.appendChild(h),i.push(h)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=He(this,e,"m",r).call(this,"#"===t[0]?t:"#".concat(t),n);return i.attr("id",t),i},t.prototype.maybeAppendByClassName=function(t,n){var i=t.toString(),o=He(this,e,"m",r).call(this,"."===i[0]?i:".".concat(i),n);return o.attr("className",i),o},t.prototype.maybeAppendByName=function(t,n){var i=He(this,e,"m",r).call(this,'[name="'.concat(t,'"]'),n);return i.attr("name",t),i},t.prototype.data=function(t,e,r){var i,o;void 0===e&&(e=function(t){return t}),void 0===r&&(r=function(){return null});for(var a,s,l,u=[],c=[],h=new Set(this._elements),d=[],f=new Set,p=new Map(this._elements.map((function(t,n){return[e(t.__data__,n),t]}))),g=new Map(this._facetElements.map((function(t,n){return[e(t.__data__,n),t]}))),v=(a=this._elements,s=function(t){return r(t.__data__)},l=new Map,a.forEach((function(t){var e=s(t);l.has(e)||l.set(e,[]),l.get(e).push(t)})),l),m=0;m<t.length;m++){var y=t[m],b=e(y,m),x=r(y,m);if(p.has(b))(M=p.get(b)).__data__=y,M.__facet__=!1,c.push(M),h.delete(M),p.delete(b);else if(g.has(b)){(M=g.get(b)).__data__=y,M.__facet__=!0,c.push(M),g.delete(b)}else if(v.has(b)){var E=v.get(b);d.push([y,E]);try{for(var w=(i=void 0,Ge(E)),k=w.next();!k.done;k=w.next()){var M=k.value;h.delete(M)}}catch(t){i={error:t}}finally{try{k&&!k.done&&(o=w.return)&&o.call(w)}finally{if(i)throw i.error}}v.delete(b)}else if(p.has(x)){(M=p.get(x)).__toData__?M.__toData__.push(y):M.__toData__=[y],f.add(M),h.delete(M)}else u.push(y)}var S=[new n([],u,this._parent,this._document),new n(c,null,this._parent,this._document),new n(h,null,this._parent,this._document),new n([],d,this._parent,this._document),new n(f,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,S)},t.prototype.merge=function(t){var e=We(We([],Ve(this._elements),!1),Ve(t._elements),!1),r=We(We([],Ve(this._transitions),!1),Ve(t._transitions),!1);return new n(e,null,this._parent,this._document,void 0,r)},t.prototype.createElement=function(t){if(this._document)return this._document.createElement(t,{});var e=n.registry[t];return e?new e:function(t){throw new Error(t)}("Unknown node type: ".concat(t))},t.prototype.join=function(t,e,n,r,i){void 0===t&&(t=function(t){return t}),void 0===e&&(e=function(t){return t}),void 0===n&&(n=function(t){return t.remove()}),void 0===r&&(r=function(t){return t}),void 0===i&&(i=function(t){return t.remove()});var o=t(this._enter),a=e(this._update),s=n(this._exit),l=r(this._merge),u=i(this._split);return a.merge(o).merge(s).merge(l).merge(u)},t.prototype.remove=function(){for(var t=function(t){var n=e._elements[t],r=e._transitions[t];r?r.then((function(){return n.remove()})):n.remove()},e=this,r=0;r<this._elements.length;r++)t(r);return new n([],null,this._parent,this._document,void 0,this._transitions)},t.prototype.each=function(t){for(var e=0;e<this._elements.length;e++){var n=this._elements[e],r=n.__data__;t.call(n,r,e)}return this},t.prototype.attr=function(t,e){var n="function"!=typeof e?function(){return e}:e;return this.each((function(r,i){void 0!==e&&(this[t]=n.call(this,r,i))}))},t.prototype.style=function(t,e,n){void 0===n&&(n=!0);var r="function"==typeof e&&n?e:function(){return e};return this.each((function(n,i){void 0!==e&&(this.style[t]=r.call(this,n,i))}))},t.prototype.styles=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!0),this.each((function(n,r){var i=this;Object.entries(t).forEach((function(t){var o=Ve(t,2),a=o[0],s=o[1],l="function"==typeof s&&e?s:function(){return s};void 0!==s&&i.attr(a,l.call(i,n,r))}))}))},t.prototype.update=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.maybeUpdate=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.transition=function(t){var e=this._transitions;return this.each((function(n,r){e[r]=t.call(this,n,r)}))},t.prototype.on=function(t,e){return this.each((function(){this.addEventListener(t,e)})),this},t.prototype.call=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.call.apply(t,We([this._parent,this],Ve(e),!1)),this},t.prototype.node=function(){return this._elements[0]},t.prototype.nodes=function(){return this._elements},t.prototype.transitions=function(){return this._transitions.filter((function(t){return!!t}))},t.prototype.parent=function(){return this._parent},n=t,e=new WeakSet,r=function(t,e){var r=this._elements[0],i=r.querySelector(t);if(i)return new n([i],null,this._parent,this._document);var o="string"==typeof e?this.createElement(e):e();return r.appendChild(o),new n([o],null,this._parent,this._document)},t.registry={g:jl,rect:Xl,circle:Dl,path:Hl,text:WF,ellipse:Il,image:zl,line:Vl,polygon:$l,polyline:ql,html:Fl},t}();function Mz(t){return new kz([t],null,t,t.ownerDocument)}function Sz(t){if(ae(t))return[t,t,t,t];if(Yt(t)){var e=t.length;if(1===e)return[t[0],t[0],t[0],t[0]];if(2===e)return[t[0],t[1],t[0],t[1]];if(3===e)return[t[0],t[1],t[2],t[1]];if(4===e)return t}return[0,0,0,0]}function Nz(t){var e=t.getLocalBounds(),n=Ve([e.min,e.max],2),r=Ve(n[0],2),i=r[0],o=r[1],a=Ve(n[1],2),s=a[0],l=a[1];return{x:i,y:o,width:s-i,height:l-o,left:i,bottom:l,top:o,right:s}}function Oz(t,e){var n=Ve(t,2),r=n[0],i=n[1],o=Ve(e,2),a=o[0],s=o[1];return r!==a&&i===s}function Tz(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function Cz(t,e,n){var r;void 0===n&&(n=!0);var i=e||(null===(r=t.match(/^([a-z][a-z0-9]+)/))||void 0===r?void 0:r[0])||"",o=t.replace(new RegExp("^(".concat(i,")")),"");return n?function(t){return t.toString().charAt(0).toLowerCase()+t.toString().slice(1)}(o):o}var Az=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function Pz(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach((function(t){var i=Ve(t,2),o=i[0],a=i[1];if("className"===o||"class"===o);else if(Az(o,"show")&&Az(Cz(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(Tz(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(Tz(e)),"")]=a;else if(!Az(o,"show")&&Az(o,e)!==n){var s=Cz(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function Rz(t,e){return Object.entries(t).reduce((function(t,n){var r=Ve(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(Tz(i))]=o,t}),{})}function Dz(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=Ve(t,2),a=o[0],s=o[1];e.includes(a)||(-1!==n.indexOf(a)?i[a]=s:r[a]=s)})),[r,i]}function Lz(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 _z(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=Ve([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 Iz=function(t,e){null!=e?t.replaceChildren?Array.isArray(e)?t.replaceChildren.apply(t,We([],Ve(e),!1)):t.replaceChildren(e):(t.innerHTML="",Array.isArray(e)?e.forEach((function(e){return t.appendChild(e)})):t.appendChild(e)):t.innerHTML=""};function jz(){zF(this,"hidden"!==this.attributes.visibility)}var Bz=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,ZF({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return je(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=VF(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&&jz.call(this)},e.prototype.update=function(t,e){var n;return this.attr(ZF({},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,Fe(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(_l),Fz=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"]]},zz=Fz,Gz=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},Vz=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},Wz=Vz;var Hz=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function Uz(t){var e=function(t){var e="default";if(qt(t)&&t instanceof Image)e="image";else if(Ut(t))e="symbol";else if(ne(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 $z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(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),l=s.symbol,u=s.size,c=void 0===u?16:u,h=Fe(s,["symbol","size"]),d=Uz(l);az(!!d,Mz(n),(function(t){t.maybeAppendByClassName("marker",d).attr("className","marker ".concat(d,"-marker")).call((function(t){if("image"===d){var n=2*c;t.styles({img:l,width:n,height:n,x:i-c,y:a-c})}else{n=c/2;var r=Ut(l)?l:e.getSymbol(l);t.styles(Be({d:null==r?void 0:r(i,a,n)},h))}}))}))},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}(Bz);function Yz(t,...e){return e.reduce(((t,e)=>n=>t(e(n))),t)}function qz(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}$z.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]]})),$z.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),$z.registerSymbol("line",Gz),$z.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),$z.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]]})),$z.registerSymbol("circle",Fz),$z.registerSymbol("point",zz),$z.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"]]})),$z.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"]]})),$z.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"]]})),$z.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),$z.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"]]})),$z.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"]]})),$z.registerSymbol("line",Gz),$z.registerSymbol("dot",Vz),$z.registerSymbol("dash",Wz),$z.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]]})),$z.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]]})),$z.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]]})),$z.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]]})),$z.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]]}));const Xz=Math.sqrt(50),Kz=Math.sqrt(10),Zz=Math.sqrt(2);function Qz(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>=Xz?10:o>=Kz?5:o>=Zz?2:1)*10**i:-(10**-i)/(o>=Xz?10:o>=Kz?5:o>=Zz?2:1)}const Jz=(t,e,n=5)=>{const r=[t,e];let i,o=0,a=r.length-1,s=r[o],l=r[a];return l<s&&([s,l]=[l,s],[o,a]=[a,o]),i=Qz(s,l,n),i>0?(s=Math.floor(s/i)*i,l=Math.ceil(l/i)*i,i=Qz(s,l,n)):i<0&&(s=Math.ceil(s*i)/i,l=Math.floor(l*i)/i,i=Qz(s,l,n)),i>0?(r[o]=Math.floor(s/i)*i,r[a]=Math.ceil(l/i)*i):i<0&&(r[o]=Math.ceil(s*i)/i,r[a]=Math.floor(l*i)/i),r};function tG(t){return!(ve(t)||(e=t,null===e)||Number.isNaN(t));var e}var eG={exports:{}},nG={exports:{}},rG=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))},iG=Array.prototype.concat,oG=Array.prototype.slice,aG=nG.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];rG(i)?e=iG.call(e,oG.call(i)):e.push(i)}return e};aG.wrap=function(t){return function(){return t(aG(arguments))}};var sG=nG.exports,lG={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},uG=sG,cG=Object.hasOwnProperty,hG=Object.create(null);for(var dG in lG)cG.call(lG,dG)&&(hG[lG[dG]]=dG);var fG=eG.exports={to:{},get:{}};function pG(t,e,n){return Math.min(Math.max(e,t),n)}function gG(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}fG.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=fG.get.hsl(t),n="hsl";break;case"hwb":e=fG.get.hwb(t),n="hwb";break;default:e=fG.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},fG.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;i[n]=parseInt(e.slice(o,o+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:cG.call(lG,e[1])?((i=lG[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=pG(i[n],0,255);return i[3]=pG(i[3],0,1),i},fG.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,pG(parseFloat(e[2]),0,100),pG(parseFloat(e[3]),0,100),pG(isNaN(n)?1:n,0,1)]}return null},fG.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,pG(parseFloat(e[2]),0,100),pG(parseFloat(e[3]),0,100),pG(isNaN(n)?1:n,0,1)]}return null},fG.to.hex=function(){var t=uG(arguments);return"#"+gG(t[0])+gG(t[1])+gG(t[2])+(t[3]<1?gG(Math.round(255*t[3])):"")},fG.to.rgb=function(){var t=uG(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},fG.to.rgb.percent=function(){var t=uG(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},fG.to.hsl=function(){var t=uG(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},fG.to.hwb=function(){var t=uG(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},fG.to.keyword=function(t){return hG[t.slice(0,3)]};var vG=E(eG.exports);function mG(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 yG(t){const e=vG.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*mG(a,o,e+1/3),255*mG(a,o,e),255*mG(a,o,e-1/3),i]}(r):null}const bG=(t,e)=>n=>t*(1-n)+e*n,xG=(t,e)=>"number"==typeof t&&"number"==typeof e?bG(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=yG(t),r=yG(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,EG=(t,e)=>{const n=bG(t,e);return t=>Math.round(n(t))};function wG({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function kG(t){return"object"==typeof t?t.valueOf():t}class MG extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=kG,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(wG({map:this.map,initKey:this.initKey},t))}has(t){return super.has(wG({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 SG{constructor(t){this.options=ke({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=ke({},this.options,t),this.rescale(t)}rescale(t){}}const NG=Symbol("defaultUnknown");function OG(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function TG(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let a=i.get(e);if(void 0===a){if(o!==NG)return o;a=n.push(e)-1,i.set(e,a)}return r[a%r.length]}function CG(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class AG extends SG{getDefaultOptions(){return{domain:[],range:[],unknown:NG}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&OG(this.domainIndexMap,this.getDomain(),this.domainKey),TG({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&OG(this.rangeIndexMap,this.getRange(),this.rangeKey),TG({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=CG(e),this.rangeKey=CG(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 AG(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 PG(t){return Math.round(1e12*t)/1e12}function RG(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:a,align:s}=t,l=e.length,u=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,l),[c,h]=n,d=h-c,f=d/(2/l*r+1-1/l*i),p=f*i/l,g=f-l*p,v=function(t){const e=Math.min(...t);return t.map((t=>t/e))}(u),m=g/v.reduce(((t,e)=>t+e)),y=new MG(e.map(((t,e)=>{const n=v[e]*m;return[t,a?Math.floor(n):n]}))),b=new MG(e.map(((t,e)=>{const n=v[e]*m+p;return[t,a?Math.floor(n):n]}))),x=Array.from(b.values()).reduce(((t,e)=>t+e)),E=c+(d-(x-x/l*i))*s;let w=a?Math.round(E):E;const k=new Array(l);for(let t=0;t<l;t+=1){k[t]=PG(w);const n=e[t];w+=b.get(n)}return{valueBandWidth:y,valueStep:b,adjustedRange:k}}class DG extends AG{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:NG,flex:[]}}constructor(t){super(t)}clone(){return new DG(this.options)}getStep(t){return void 0===this.valueStep?1:"number"==typeof this.valueStep?this.valueStep:void 0===t?Array.from(this.valueStep.values())[0]:this.valueStep.get(t)}getBandWidth(t){return void 0===this.valueBandWidth?1:"number"==typeof this.valueBandWidth?this.valueBandWidth:void 0===t?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(t)}getRange(){return this.adjustedRange}getPaddingInner(){const{padding:t,paddingInner:e}=this.options;return t>0?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 RG(t);const{range:i,paddingOuter:o,paddingInner:a,round:s,align:l}=t;let u,c,h=i[0];const d=i[1]-h,f=2*o,p=r-a;u=d/Math.max(1,f+p),s&&(u=Math.floor(u)),h+=(d-u*(r-a))*l,c=u*(1-a),s&&(h=Math.round(h),c=Math.round(c));const g=new Array(r).fill(0).map(((t,e)=>h+e*u));return{valueStep:u,valueBandWidth:c,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 LG=(t,e,n)=>{let r,i,o=t,a=e;if(o===a&&n>0)return[o];let s=Qz(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<r;t+=1)i[t]=(o+t)*s}else{s=-s,o=Math.ceil(o*s),a=Math.floor(a*s),i=new Array(r=Math.ceil(a-o+1));for(let t=0;t<r;t+=1)i[t]=(o+t)/s}return i},_G=(t,e,n)=>{const[r,i]=t,[o,a]=e;let s,l;return r<i?(s=qz(r,i),l=n(o,a)):(s=qz(i,r),l=n(a,o)),Yz(l,s)},IG=(t,e,n)=>{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,l=a?[...e].reverse():e;for(let t=0;t<r;t+=1)i[t]=qz(s[t],s[t+1]),o[t]=n(l[t],l[t+1]);return e=>{const n=function(t,e,n,r){let i=n,o=r||t.length;for(;i<o;){const n=Math.floor((i+o)/2);t[n]>e?o=n:i=n+1}return i}(t,e,1,r)-1,a=i[n];return Yz(o[n],a)(e)}},jG=(t,e,n,r)=>(Math.min(t.length,e.length)>2?IG:_G)(t,e,r?EG:n);class BG extends SG{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:bG,tickCount:5}}map(t){return tG(t)?this.output(t):this.options.unknown}invert(t){return tG(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 Jz}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=e<t?e:t,r=t>e?t:e;return t=>Math.min(Math.max(n,t),r)}(r[0],r[i-1]):_e}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,a=jG(n.map(t),r,o,i);this.output=Yz(a,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=jG(i,r.map(t),bG);this.input=Yz(e,n,o)}}class FG extends BG{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:xG,tickMethod:LG,tickCount:5}}chooseTransforms(){return[_e,_e]}clone(){return new FG(this.options)}}var zG=function(t){function e(e){var n=this,r=e.style,i=Fe(e,["style"]);return(n=t.call(this,ke({},{type:"column"},Be({style:r},i)))||this).columnsGroup=new jl({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return je(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,")"),Mz(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(ZF({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(Rl),GG=function(t){function e(e){var n=this,r=e.style,i=Fe(e,["style"]);return(n=t.call(this,ke({},{type:"lines"},Be({style:r},i)))||this).linesGroup=n.appendChild(new jl),n.areasGroup=n.appendChild(new jl),n.render(),n}return je(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(ZF({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){Mz(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){Mz(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}(Rl);function VG(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map((function(t,e){return We([e===n?"M":"L"],Ve(t),!1)}));return e?r.reverse():r}function WG(t,e){if(void 0===e&&(e=!1),t.length<=2)return VG(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];Ne(o,n.slice(-2))||n.push.apply(n,We([],Ve(o),!1))}var a=yz(n);return e?a.unshift(We(["M"],Ve(t[r-1]),!1)):a.unshift(We(["M"],Ve(t[0]),!1)),a}function HG(t,e,n){var r=me(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function UG(t){return 0===t.length?[0,0]:[ee(ue(t,(function(t){return ee(t)||0}))),te(le(t,(function(t){return te(t)||0})))]}function $G(t){for(var e=me(t),n=e[0].length,r=Ve([Array(n).fill(0),Array(n).fill(0)],2),i=r[0],o=r[1],a=0;a<e.length;a+=1)for(var s=e[a],l=0;l<n;l+=1)s[l]>=0?(s[l]+=i[l],i[l]=s[l]):(s[l]+=o[l],o[l]=s[l]);return e}var YG=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 je(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=me(t);return ae(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?$G(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=Ve(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=Pz(this.attributes,"area"),a=Pz(this.attributes,"line"),s=this.containerShape.width,l=this.data;if(0===l[0].length)return{lines:[],areas:[]};var u=this.scales,c=function(t,e){var n,r=e.x,i=e.y,o=Ve(i.getOptions().range||[0,0],2),a=o[0],s=o[1];return s>a&&(n=Ve([a,s],2),s=n[0],a=n[1]),t.map((function(t){return t.map((function(t,e){return[r.map(e),oe(i.map(t),s,a)]}))}))}(l,{x:u.x,y:u.y}),h=[];if(o){var d=this.baseline;h=r?i?function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=t[i],a=WG(o),s=void 0;if(0===i)s=HG(a,e,n);else{var l=WG(t[i-1],!0),u=o[0];l[0][0]="L",s=We(We(We([],Ve(a),!1),Ve(l),!1),[We(["M"],Ve(u),!1),["Z"]],!1)}r.push(s)}return r}(c,s,d):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=VG(t[i]),a=void 0;if(0===i)a=HG(o,e,n);else{var s=VG(t[i-1],!0);s[0][0]="L",a=We(We(We([],Ve(o),!1),Ve(s),!1),[["Z"]],!1)}r.push(a)}return r}(c,s,d):function(t,e,n,r){return t.map((function(t){return HG(e?WG(t):VG(t),n,r)}))}(c,i,s,d)}return{lines:c.map((function(e,n){return Be({stroke:t.getColor(n),d:i?WG(e):VG(e)},a)})),areas:h.map((function(e,n){return Be({d:e,fill:t.getColor(n)},o)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=Pz(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=$G(s));var l=this.createScales(s),u=l.x,c=l.y,h=Ve(UG(s),2),d=h[0],f=h[1],p=new FG({domain:[0,f-(d>0?0:d)],range:[0,a*o]}),g=u.getBandWidth(),v=this.rawData;return{columns:s.map((function(n,i){return n.map((function(n,o){var a=g/s.length;return Be(Be({fill:t.getColor(i)},e),r?{x:u.map(o),y:c.map(n),width:g,height:p.map(v[i][o])}:{x:u.map(o)+a*i,y:n>=0?c.map(n):c.map(0),width:a,height:p.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)?Mz(n).select(r):Mz(n).append(i)).attr("className","container").node();var o=t.type,a=t.x,s=t.y,l="spark".concat(o),u=Be({x:a,y:s},"line"===o?this.linesStyle:this.columnsStyle);Mz(e).selectAll(".spark").data([o]).join((function(t){return t.append((function(t){return"line"===t?new GG({className:l,style:u}):new zG({className:l,style:u})})).attr("className","spark ".concat(l))}),(function(t){return t.update(u)}),(function(t){return t.remove()}))},e.prototype.getColor=function(t){var e=this.attributes.color;return Yt(e)?e[t%e.length]:Ut(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,l=r.spacing,u=this.containerShape,c=u.width,h=u.height,d=Ve(UG(t),2),f=d[0],p=d[1],g=new FG({domain:[null!==(e=s[0])&&void 0!==e?e:f,null!==(n=s[1])&&void 0!==n?n:p],range:[h,h*(1-o)]});return"line"===i?{type:i,x:new FG({domain:[0,t[0].length-1],range:[0,c]}),y:g}:{type:i,x:new DG({domain:t[0].map((function(t,e){return e})),range:[0,c],paddingInner:l,paddingOuter:l/2,align:.5}),y:g}},e.tag="sparkline",e}(Bz);function qG(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=Ve(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,Be(Be({},t[e]),n)]:[e,n]})))}function XG(t,e){t?t.finished.then(e):e()}function KG(t,e){"update"in t?t.update(e):t.attr(e)}function ZG(t,e,n){return 0===e.length?null:n?t.animate(e,n):(KG(t,{style:e.slice(-1)[0]}),null)}function QG(t,e,n){var r={},i={};return Object.entries(e).forEach((function(e){var n=Ve(e,2),o=n[0],a=n[1];if(!$t(a)){var s=t.style[o]||t.parsedStyle[o]||0;s!==a&&(r[o]=s,i[o]=a)}})),n?ZG(t,[r,i],Be({fill:"both"},n)):(KG(t,i),null)}function JG(t,e){return t.style.opacity||(t.style.opacity=1),QG(t,{opacity:0},e)}var tV={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},eV={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},nV={x:0,y:0,orientation:"horizontal",showLabel:!0,type:"start"},rV=XF({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),iV=XF({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),oV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(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,l=t.orientation,u=Fe(t,["x","y","size","radius","orientation"]),c=o,h=2.4*c,d=Mz(e).maybeAppendByClassName(iV.iconRect,"rect").styles(Be(Be({},u),{width:c,height:h,radius:s,x:n-c/2,y:r-h/2,transformOrigin:"center"})),f=n+1/3*c-c/2,p=n+2/3*c-c/2,g=r+1/4*h-h/2,v=r+3/4*h-h/2;d.maybeAppendByClassName("".concat(iV.iconLine,"-1"),"line").styles(Be({x1:f,x2:f,y1:g,y2:v},u)),d.maybeAppendByClassName("".concat(iV.iconLine,"-2"),"line").styles(Be({x1:p,x2:p,y1:g,y2:v},u)),"vertical"===l&&(d.node().style.transform="rotate(90)")},e}(Bz),aV=function(t){function e(e){return t.call(this,e,nV)||this}return je(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.x,i=n.y,o=n.showLabel,a=Pz(this.attributes,"label"),s=a.x,l=void 0===s?0:s,u=a.y,c=void 0===u?0:u,h=a.transform,d=a.transformOrigin,f=Ve(Dz(Fe(a,["x","y","transform","transformOrigin"]),[]),2),p=f[0],g=f[1],v=Mz(t).maybeAppendByClassName(iV.labelGroup,"g").styles(g),m=Be(Be({},eV),p),y=m.text,b=Fe(m,["text"]);az(!!o,v,(function(t){e.label=t.maybeAppendByClassName(iV.label,"text").styles(Be(Be({},b),{x:r+l,y:i+c,transform:h,transformOrigin:d,text:"".concat(y)})),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=Be(Be({x:n,y:r,orientation:i},tV),Pz(this.attributes,"icon")),s=this.attributes.iconShape,l=void 0===s?function(){return new oV({style:a})}:s;Mz(t).maybeAppendByClassName(iV.iconGroup,"g").selectAll(iV.icon.class).data([l]).join((function(t){return t.append("string"==typeof l?l:function(){return l(o)}).attr("className",iV.icon.name)}),(function(t){return t.update(a)}),(function(t){return t.remove()}))},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(Bz),sV=function(t){function e(e){var n=t.call(this,e,Be(Be(Be({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},Rz(nV,"handle")),Rz(tV,"handleIcon")),Rz(eV,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(iz(e));var r=n.availableSpace,i=r.x,o=r.y,a=n.getBBox(),s=a.x,l=a.y;n.selectionStartPos=n.getRatio(n.prevPos-n.getOrientVal([i,o])-n.getOrientVal([+s,+l])),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(iz(t)),s=a-n.prevPos;if(s){var l=n.getRatio(s);switch(n.target){case"start":r&&n.setValuesOffset(l);break;case"end":r&&n.setValuesOffset(0,l);break;case"selection":r&&n.setValuesOffset(l,l);break;case"track":if(!i)return;n.selectionWidth+=l,"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 Rs("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 je(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=Pz(this.attributes,"sparkline");return Be(Be({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=Ve(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=Ve(Sz(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(rV.selection.class).each((function(n,r){QG(this,e[r],t)}))},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&QG(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&QG(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=Pz(this.attributes,"track");this.trackShape=Mz(t).maybeAppendByClassName(rV.track,"rect").styles(Be(Be({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=Mz(t).maybeAppendByClassName(rV.brushArea,"rect").styles(Be({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;az("horizontal"===n.orientation,Mz(t).maybeAppendByClassName(rV.sparklineGroup,"g"),(function(t){var n=Be(Be({},e.sparklineStyle),{x:r,y:i});t.maybeAppendByClassName(rV.sparkline,(function(){return new YG({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(rV.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 aV({style:e.getHandleStyle(n)})})).each((function(t){var e=t.type;this.attr("class","".concat(rV.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=Mz(t).maybeAppendByClassName(rV.foreground,"g");var a=Pz(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(Be(Be({},a),{transform:"translate(".concat(n,", ").concat(r,")")}))},l=this;this.foregroundGroup.selectAll(rV.selection.class).data("value"===i?[]:this.calcSelectionArea().map((function(t,e){return{style:Be({},t),index:e,show:"select"===o?1===e:1!==e}})),(function(t){return t.index})).join((function(t){return t.append("rect").attr("className",rV.selection.name).call(s).each((function(t,e){var n=this;1===e?(l.selectionShape=Mz(this),this.on("pointerdown",(function(t){n.attr("cursor","grabbing"),l.onDragStart("selection")(t)})),l.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),l.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),l.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",l.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=Ve(this.range,2),i=r[0],o=r[1],a=Ve(this.getValues().map((function(t){return vz(t,e)})),2),s=a[0],l=a[1],u=Ve(((Array.isArray(t)?t:[s,null!=t?t:l])||[s,l]).map((function(t){return vz(t,e)})),2),c=u[0],h=u[1];if("value"===this.attributes.type)return[0,oe(h,i,o)];c>h&&(c=(n=Ve([h,c],2))[0],h=n[1]);var d=h-c;return d>o-i?[i,o]:c<i?s===i&&l===h?[i,h]:[i,d+i]:h>o?l===o&&s===c?[c,o]:[o-d,o]:[c,h]},e.prototype.calcSelectionArea=function(t){var e=Ve(this.clampValues(t),2),n=e[0],r=e[1],i=this.availableSpace,o=i.x,a=i.y,s=i.width,l=i.height;return this.getOrientVal([[{y:a,height:l,x:o,width:n*s},{y:a,height:l,x:n*s+o,width:(r-n)*s},{y:a,height:l,x:r*s,width:(1-r)*s}],[{x:o,width:s,y:a,height:n*l},{x:o,width:s,y:n*l+a,height:(r-n)*l},{x:o,width:s,y:r*l,height:(1-r)*l}]])},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=Ve(this.clampValues(),2),l=s[0],u=s[1],c="start"===t?-e:e,h=("start"===t?l:u)*this.getOrientVal([o,a])+c;return{x:r+this.getOrientVal([h,o/2]),y:i+this.getOrientVal([a/2,h])}},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=Pz(this.attributes,"handle"),l=Pz(s,"label"),u=s.spacing,c=this.getHandleSize(),h=this.clampValues(),d=o("start"===t?h[0]:h[1]),f=new WF({style:Be(Be(Be({},l),this.inferTextStyle(t)),{text:d})}),p=f.getBBox(),g=p.width,v=p.height;if(f.destroy(),!a){if("value"===r)return{text:d,x:0,y:-v-u};var m=u+c+("horizontal"===i?g/2:0);return(e={text:d})["horizontal"===i?"x":"y"]="start"===t?-m:m,e}var y=0,b=0,x=this.availableSpace,E=x.width,w=x.height,k=this.calcSelectionArea()[1],M=k.x,S=k.y,N=k.width,O=k.height,T=u+c;if("horizontal"===i){var C=T+g/2;if("start"===t)y=M-T-g>0?-C:C;else y=E-M-N-T>g?C:-C}else{var A=v+T;b="start"===t?S-c>v?-A:T:w-(S+O)-c>v?A:-T}return{x:y,y:b,text:d}},e.prototype.getHandleLabelStyle=function(t){var e=Pz(this.attributes,"handleLabel");return Be(Be(Be({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=Pz(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return Be({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),l=s.x,u=s.y,c=this.calcHandleText(t),h=i;return!i&&o&&(h=!!this.target),Be(Be(Be({},Rz(this.getHandleIconStyle(),"icon")),Rz(Be(Be({},this.getHandleLabelStyle(t)),c),"label")),{transform:"translate(".concat(l+n,", ").concat(u+r,")"),orientation:a,showLabel:h,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=Ve(t,2),n=e[0],r=e[1];return"horizontal"===this.attributes.orientation?n:r},e.prototype.setValuesOffset=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=!1);var r=this.attributes.type,i=Ve(this.getValues(),2),o=[i[0]+("range"===r?t:0),i[1]+e].sort();n?this.setValues(o):this.innerSetValues(o,!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 Rs(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,!0)}},e.tag="slider",e}(Bz),lV={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 Hl({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:[]};ke({},lV,{style:{type:"arc"}}),ke({},lV,{style:{}});var uV=XF({mainGroup:"main-group",gridGroup:"grid-group",grid:"grid",lineGroup:"line-group",line:"line",tickGroup:"tick-group",tick:"tick",tickItem:"tick-item",labelGroup:"label-group",label:"label",labelItem:"label-item",titleGroup:"title-group",title:"title",lineFirst:"line-first",lineSecond:"line-second"},"axis"),cV=XF({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function hV(t){return t.reduce((function(t,e,n){return t.push(We([0===n?"M":"L"],Ve(e),!1)),t}),[])}function dV(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 hV(t);if(!o)return[];var a=pz(t[0],o),s=n?0:1;return t.reduce((function(t,e,n){return 0===n?t.push(We(["M"],Ve(e),!1)):t.push(We(["A",a,a,0,0,s],Ve(e),!1)),t}),[])}(t,e,n):hV(t)}function fV(t,e,n){var r=n.type,i=n.connect,o=n.center,a=n.closed?[["Z"]]:[],s=Ve([dV(t,n),dV(e.slice().reverse(),n,!0)],2),l=s[0],u=s[1],c=Ve([t[0],e.slice(-1)[0]],2),h=c[0],d=c[1],f=function(t,e){return[l,t,u,e,a].flat()};if("line"===i||"surround"===r)return f([We(["L"],Ve(d),!1)],[We(["L"],Ve(h),!1)]);if(!o)throw new Error("Arc grid need to specified center");var p=Ve([pz(d,o),pz(h,o)],2),g=p[0],v=p[1];return f([We(["A",g,g,0,0,1],Ve(d),!1),We(["L"],Ve(d),!1)],[We(["A",v,v,0,0,0],Ve(h),!1),We(["L"],Ve(h),!1)])}var pV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Fe(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=Ve(e,1)[0];return Be(Be({},t),{points:We(We([],Ve(e),!1),[n],!1)})})):n}(t),i=Mz(e).maybeAppendByClassName(cV.lineGroup,"g"),o=Mz(e).maybeAppendByClassName(cV.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:dV(t.points,n)}}));return t.selectAll(cV.line.class).data(a,(function(t){return t.id})).join((function(t){return t.append("path").each((function(t,e){var n=YF(Ez(Be({d:t.d},r)),[t,e,a]);this.attr(Be({class:cV.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))}))}),(function(t){return t.transition((function(t,e){return QG(this,YF(Ez(Be({d:t.d},r)),[t,e,a]),i.update)}))}),(function(t){return t.transition((function(){var t=this,e=JG(this,i.exit);return XG(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]},l=[],u=0;u<e.length-1;u++){var c=Ve([e[u].points,e[u+1].points],2),h=fV(c[0],c[1],n);l.push({d:h,fill:s(u)})}return t.selectAll(cV.region.class).data(l,(function(t,e){return e})).join((function(t){return t.append("path").each((function(t,e){var n=YF(t,[t,e,l]);this.attr(n)})).attr("className",cV.region.name)}),(function(t){return t.transition((function(t,e){return QG(this,YF(t,[t,e,l]),r.update)}))}),(function(t){return t.transition((function(){var t=this,e=JG(this,r.exit);return XG(e,(function(){return t.remove()})),e}))})).transitions()}(o,r,t);return We(We([],Ve(a),!1),Ve(s),!1)},e}(Bz);function gV(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var n=Ve(t,2);return[n[0],YF(n[1],e)]})))}function vV(t,e){return e&&Ut(e)?t.filter(e):t}function mV(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}function yV(t,e){if("linear"===e.type){var n=Ve(e.startPos,2),r=n[0],i=n[1],o=Ve(e.endPos,2),a=Ve([o[0]-r,o[1]-i],2);return gz([a[0],a[1]])}var s=HF(mV(t,e));return[-Math.sin(s),Math.cos(s)]}function bV(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(yV(t,n),"positive"!==e)}function xV(t,e){return bV(t,e.labelDirection,e)}function EV(t,e){return"linear"===e.type?function(t,e){var n=Ve(e.startPos,2),r=n[0],i=n[1],o=Ve(e.endPos,2),a=Ve([o[0]-r,o[1]-i],2);return[r+a[0]*t,i+a[1]*t]}(t,e):function(t,e){var n=e.radius,r=Ve(e.center,2),i=r[0],o=r[1],a=HF(mV(t,e));return[i+n*Math.cos(a),o+n*Math.sin(a)]}(t,e)}function wV(t){return 0===yV(0,t)[1]}function kV(t){return 0===yV(0,t)[0]}function MV(t,e){return e-t==360}function SV(t,e,n,r,i){var o=e-t,a=Ve([i,i],2),s=a[0],l=a[1],u=Ve([HF(t),HF(e)],2),c=u[0],h=u[1],d=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},f=Ve(d(c),2),p=f[0],g=f[1],v=Ve(d(h),2),m=v[0],y=v[1];if(MV(t,e)){var b=Ve(d((h+c)/2),2);return[["M",p,g],["A",s,l,0,1,0,b[0],b[1]],["A",s,l,0,1,0,m,y]]}var x=o>180?1:0,E=t>e?0:1;return"M".concat(p,",").concat(g,",A").concat(s,",").concat(l,",0,").concat(x,",").concat(E,",").concat(m,",").concat(y)}function NV(t,e,n,r){var i=e.startAngle,o=e.endAngle,a=e.center,s=e.radius;return t.selectAll(uV.line.class).data([{d:SV.apply(void 0,We(We([i,o],Ve(a),!1),[s],!1))}],(function(t,e){return e})).join((function(t){return t.append("path").attr("className",uV.line.name).styles(e).styles({d:function(t){return t.d}})}),(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=lz(e,n),s=Math.ceil(+o/16),l=new Array(s).fill(0).map((function(t,e,n){return{__keyframe_data__:a(e/(n.length-1))}}));return t.animate(l,Be({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return We(We([n,r],Ve(i),!1),[o],!1)}(this),We(We([i,o],Ve(a),!1),[s],!1),r.update);if(e){var n=function(){var e=Oe(t.attributes,"__keyframe_data__");t.style.d=SV.apply(void 0,We([],Ve(e),!1))};e.onframe=n,e.onfinish=n}return e})).styles(e)}),(function(t){return t.remove()})).styles(n).transitions()}function OV(t){var e=Ve(t,2),n=Ve(e[0],2),r=n[0],i=n[1],o=Ve(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function TV(t,e,n,r){var i=e.showTrunc,o=e.startPos,a=e.endPos,s=e.truncRange,l=e.lineExtension,u=Ve([o,a],2),c=Ve(u[0],2),h=c[0],d=c[1],f=Ve(u[1],2),p=f[0],g=f[1],v=Ve(l?function(t,e,n){void 0===n&&(n=[0,0]);var r=Ve([t,e,n],3),i=Ve(r[0],2),o=i[0],a=i[1],s=Ve(r[1],2),l=s[0],u=s[1],c=Ve(r[2],2),h=c[0],d=c[1],f=Ve([l-o,u-a],2),p=f[0],g=f[1],v=Math.sqrt(Math.pow(p,2)+Math.pow(g,2)),m=Ve([-h/v,d/v],2),y=m[0],b=m[1];return[y*p,y*g,b*p,b*g]}(o,a,l):new Array(4).fill(0),4),m=v[0],y=v[1],b=v[2],x=v[3],E=function(e){return t.selectAll(uV.line.class).data(e,(function(t,e){return e})).join((function(t){return t.append("line").attr("className",(function(t){return"".concat(uV.line.name," ").concat(t.className)})).styles(n).transition((function(t){return QG(this,OV(t.line),!1)}))}),(function(t){return t.styles(n).transition((function(t){return QG(this,OV(t.line),r.update)}))}),(function(t){return t.remove()})).transitions()};if(!i||!s)return E([{line:[[h+m,d+y],[p+b,g+x]],className:uV.line.name}]);var w=Ve(s,2),k=w[0],M=w[1],S=p-h,N=g-d,O=Ve([h+S*k,d+N*k],2),T=O[0],C=O[1],A=Ve([h+S*M,d+N*M],2),P=A[0],R=A[1],D=E([{line:[[h+m,d+y],[T,C]],className:uV.lineFirst.name},{line:[[P,R],[p+b,g+x]],className:uV.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),D}function CV(t,e,n){var r,i=e.type,o=Pz(e,"line");return r="linear"===i?TV(t,e,mz(o,"arrow"),n):NV(t,e,mz(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,a=n.showTrunc,s=n.lineArrow,l=n.lineArrowOffset,u=n.lineArrowSize;if(i="arc"===e?t.select(uV.line.class):a?t.select(uV.lineSecond.class):t.select(uV.line.class),!o||!s||"arc"===n.type&&MV(n.startAngle,n.endAngle)){var c=i.node();c&&(c.style.markerEnd=void 0)}else{var h=oz(s);h.attr(r),wz(h,u),i.style("markerEnd",h).style("markerEndOffset",-l)}}(t,i,e,o),r}function AV(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function PV(t,e){var n=e.gridLength;return t.map((function(t,r){var i=t.value,o=Ve(EV(i,e),2),a=o[0],s=o[1],l=Ve(uz(function(t,e){return bV(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[a,s],[a+l[0],s+l[1]]]}}))}function RV(t,e,n,r){var i=Pz(n,"grid"),o=i.type,a=i.areaFill,s=AV(n),l=vV(e,n.gridFilter),u="segment"===o?PV(l,n):function(t,e){var n=e.gridControlAngles,r=AV(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=Ve(r,2),o=i[0],a=i[1];return t.map((function(t,r){var i=Ve(EV(t.value,e),2),s=i[0],l=i[1],u=Ve([s-o,l-a],2),c=u[0],h=u[1],d=[];return n.forEach((function(t){var e=HF(t),n=Ve([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=c*r-h*i+o,l=c*i+h*r+a;d.push([s,l])})),{points:d,id:r}}))}(l,n),c=Be(Be({},i),{center:s,areaFill:Ut(a)?l.map((function(t,e){return YF(a,[t,e,l])})):a,animate:r,data:u});return t.selectAll(uV.grid.class).data([1]).join((function(t){return t.append((function(){return new pV({style:c})})).attr("className",uV.grid.name)}),(function(t){return t.transition((function(){return this.update(c)}))}),(function(t){return t.remove()})).transitions()}var DV=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,l=Math.cos(t),u=Math.sin(t),c=e-e*l+n*u,h=n-e*u-n*l;return[[l*i-u*s+c,u*i+l*s+h],[l*a-u*s+c,u*a+l*s+h],[l*i-u*o+c,u*i+l*o+h],[l*a-u*o+c,u*a+l*o+h]]},t.prototype.set=function(t,e,n,r){return n<t?(this.x2=t,this.x1=n):(this.x1=t,this.x2=n),r<e?(this.y2=e,this.y1=r):(this.y1=e,this.y2=r),this},t.prototype.defined=function(t){return this[t]!==Number.MAX_VALUE&&this[t]!==-Number.MAX_VALUE},t}();function LV(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getBounds(),i=Ve(r.min,2),o=i[0],a=i[1],s=Ve(r.max,2),l=s[0],u=s[1],c=t.getBBox(),h=c.width,d=c.height,f=0,p=0,g=o,v=a,m=ez(t);if(m){d-=1.5;var y=m.style.textAlign,b=m.style.textBaseline;"center"===y?g=(o+l)/2:"right"!==y&&"end"!==y||(g=l),"middle"===b?v=(a+u)/2:"bottom"===b&&(v=u)}var x=Ve(Sz(e),4),E=x[0],w=void 0===E?0:E,k=x[1],M=void 0===k?0:k,S=x[2],N=void 0===S?w:S,O=x[3],T=new DV((f+=o)-(void 0===O?M:O),(p+=a)-w,f+h+M,p+d+N);return t.setEulerAngles(n),T.rotatedPoints(HF(n),g,v)}function _V(t,e){return e[0]<=Math.max(t[0][0],t[1][0])&&e[0]<=Math.min(t[0][0],t[1][0])&&e[1]<=Math.max(t[0][1],t[1][1])&&e[1]<=Math.min(t[0][1],t[1][1])}function IV(t,e,n){var r=(e[1]-t[1])*(n[0]-e[0])-(e[0]-t[0])*(n[1]-e[1]);return 0===r?0:r<0?2:1}function jV(t,e){return e.every((function(e){return function(t,e){var n=t.length;if(n<3)return!1;var r,i,o,a,s,l,u=[e,[9999,e[1]]],c=0,h=0;do{var d=[t[h],t[(h+1)%n]];if(i=u,o=void 0,a=void 0,s=void 0,l=void 0,o=IV((r=d)[0],r[1],i[0]),a=IV(r[0],r[1],i[1]),s=IV(i[0],i[1],r[0]),l=IV(i[0],i[1],r[1]),o!==a&&s!==l||0===o&&_V(r,i[0])||0===a&&_V(r,i[1])||0===s&&_V(i,r[0])||0===l&&_V(i,r[1])){if(0===IV(d[0],e,d[1]))return _V(d,e);c++}h=(h+1)%n}while(0!==h);return!!(1&c)}(t,e)}))}function BV(t,e){return[[t[0],t[1],t[2],t[3]],[t[2],t[3],t[4],t[5]],[t[4],t[5],t[6],t[7]],[t[6],t[7],t[0],t[1]]].some((function(t){return function(t,e){var n=Ve(t,4),r=n[0],i=n[1],o=n[2],a=n[3],s=Ve(e,4),l=s[0],u=s[1],c=o-r,h=a-i,d=s[2]-l,f=s[3]-u,p=c*f-d*h;if(0===p)return!1;var g=p>0,v=r-l,m=i-u,y=c*m-h*v;if(y<0===g)return!1;var b=d*m-f*v;return b<0!==g&&y>p!==g&&b>p!==g}(e,t)}))}function FV(t,e,n){var r,i,o=e.crossPadding,a=new Set,s=null,l=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=Ve(o,2),l=s[0],u=s[1],c="negative"===r?0:i,h=-a-c,d=a+c,f=Ve(Sz(e),4),p=f[0],g=f[1],v=f[2],m=f[3];return new DV(l+h-m,u+h-p,l+d+g,u+d+v)}var y=Ve(t.startPos,2),b=y[0],x=y[1],E=Ve(t.endPos,2),w=E[0],k=E[1],M=Ve(kV(t)?[-e,0,e,0]:[0,e,0,-e],4),S=M[0],N=M[1],O=M[2],T=M[3],C=uz(xV(0,t),i),A=new DV(b,x,w,k);return A.x1+=T,A.y1+=S,A.x2+=N+C[0],A.y2+=O+C[1],A}(e,o),u=function(t){return!l||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,a=t.y2;return jV([[r,o],[i,o],[i,a],[r,a]],LV(e,n))}(l,t)},c=function(t,e){return!t||!t.firstChild||!function(t,e,n){var r,i,o=LV(t,n).flat(1),a=LV(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 l=Ge(s),u=l.next();!u.done;u=l.next())if(BV(a,u.value))return!0}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return!1}(t.firstChild,e.firstChild,Sz(n))};try{for(var h=Ge(t),d=h.next();!d.done;d=h.next()){var f=d.value;u(f)?!s||c(s,f)?s=f:(a.add(s),a.add(f)):a.add(f)}}catch(t){r={error:t}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return Array.from(a)}function zV(t,e){return void 0===e&&(e={}),$t(t)?0:"number"==typeof t?t:Math.floor(JF(t,e))}var GV=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter((function(t,e){return!(e%r)||(FF(t),!1)}))};var VV=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,l,u,c=GV,h=function(t){return t.forEach(r.show),t},d=2,f=t.slice(),p=t.slice(),g=Math.min.apply(Math,We([1],Ve(t.map((function(t){return t.getBBox().width}))),!1));if("linear"===n.type&&(wV(n)||kV(n))){var v=Nz(t[0]).left,m=Nz(t[i-1]).right,y=Math.abs(m-v)||1;d=Math.max(Math.floor(i*g/y),d)}for(o&&(s=f.splice(0,1)[0]),a&&(l=f.splice(-1,1)[0],f.reverse()),h(f);d<t.length&&FV((u=l?We(We([l],Ve(p),!1),[s],!1):We([s],Ve(p),!1),u.filter(QF)),n,null==e?void 0:e.margin).length;){if(l&&!s&&d%2==0)f.splice(0,1).forEach(r.hide);else if(l&&s){f.splice(0,1).forEach(r.hide)}p=c(h(f),{seq:d}),d++}}}],["rotate",function(t,e,n,r){var i,o,a=e.optionalAngles,s=void 0===a?[0,45,90]:a,l=e.margin,u=e.recoverWhenFailed,c=void 0===u||u,h=t.map((function(t){return t.getLocalEulerAngles()})),d=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.rotate(t,+i)}))};try{for(var f=Ge(s),p=f.next();!p.done;p=f.next()){if(d(p.value),FV(t,n,l).length<1)return}}catch(t){i={error:t}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}c&&d(h)}],["ellipsis",function(t,e,n,r){if(!(t.length<=1)){var i=e.suffix,o=void 0===i?"...":i,a=e.minLength,s=e.maxLength,l=void 0===s?1/0:s,u=e.step,c=void 0===u?" ":u,h=e.margin,d=void 0===h?[0,0,0,0]:h,f=tz(r.getTextShape(t[0])),p=zV(c,f),g=a?zV(a,f):p,v=zV(l,f);($t(v)||v===1/0)&&(v=Math.max.apply(null,t.map((function(t){return t.getBBox().width}))));var m=t.slice(),y=Ve(d,4);y[0],y[1],y[2],y[3];for(var b=function(e){if(m.forEach((function(t){r.ellipsis(r.getTextShape(t),e,o)})),(m=FV(t,n,d)).length<1)return{value:void 0}},x=v;x>g+p;x-=p){var E=b(x);if("object"==typeof E)return E.value}}}],["wrap",function(t,e,n,r){var i=e.wordWrapWidth,o=void 0===i?50:i,a=e.maxLines,s=void 0===a?3:a,l=e.recoverWhenFailed,u=void 0===l||l,c=e.margin,h=void 0===c?[0,0,0,0]:c,d=t.map((function(t){return t.attr("maxLines")||1})),f=Math.min.apply(Math,We([],Ve(d),!1)),p=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&wV(t)?"negative"===n?"bottom":"top":"middle"}(n),g=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.wrap(t,o,i,p)}))};if(!(f>s)){for(var v=f;v<=s;v++)if(g(v),FV(t,n,h).length<1)return;u&&g(d)}}]]);function WV(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce((function(t,e){return t*function(t){return"positive"===t?-1:1}(e)}),1)}function HV(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)}function UV(t,e){var n=Ve(t,2),r=n[0],i=n[1],o=Ve(e,2),a=o[0],s=o[1],l=Ve([r*a+i*s,r*s-i*a],2),u=l[0],c=l[1];return Math.atan2(c,u)}function $V(t,e,n){var r,i=n.labelAlign;if(null===(r=e.style.transform)||void 0===r?void 0:r.includes("rotate"))return e.getLocalEulerAngles();var o=xV(t.value,n),a=yV(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return sz(e,-90,90)||(e+=180),e}(UF("perpendicular"===i?UV([1,0],o):UV([a[0]<0?-1:1,0],a)))}function YV(t,e,n){var r=n.type,i=n.labelAlign,o=xV(t,n),a=HV(e),s=HV(UF(UV([1,0],o))),l="center",u="middle";return"linear"===r?[90,270].includes(s)&&0===a?(l="center",u=1===o[1]?"top":"bottom"):s%180||![90,270].includes(a)?0===s?(sz(a,0,90,!1,!0)||sz(a,0,90)||sz(a,270,360))&&(l="start"):90===s?sz(a,0,90,!1,!0)?l="start":(sz(a,90,180)||sz(a,270,360))&&(l="end"):270===s?sz(a,0,90,!1,!0)?l="end":(sz(a,90,180)||sz(a,270,360))&&(l="start"):180===s&&(90===a?l="start":(sz(a,0,90)||sz(a,270,360))&&(l="end")):l="center":"parallel"===i?u=sz(s,0,180,!0)?"top":"bottom":"horizontal"===i?sz(s,90,270,!1)?l="end":(sz(s,270,360,!1)||sz(s,0,90))&&(l="start"):"perpendicular"===i&&(l=sz(s,90,270)?"end":"start"),{textAlign:l,textBaseline:u}}function qV(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,a=n.labelDirection,s=n.labelSpacing,l=e.indexOf(t),u=YF(s,[t,l,e]),c=Ve([xV(t.value,n),WV(a,o)],2),h=Ve(cz(uz(c[0],u+(1===c[1]?YF(r?i:0,[t,l,e]):0)),EV(t.value,n)),2);return{x:h[0],y:h[1]}}function XV(t,e){"text"===t.nodeName&&t.attr(e)}function KV(t){!function(t,e,n){var r=e.labelOverlap,i=void 0===r?[]:r;i.length&&i.forEach((function(r){var i=r.type,o=VV.get(i);(function(t,e,n){return!(e.labelOverlap.length<1)&&("hide"===n?!function(t){for(var e=t;e;){if("offscreen"===e.className)return!0;e=e.parent}return!1}(t[0]):"rotate"===n?!t.some((function(t){var e;return!!(null===(e=t.attr("transform"))||void 0===e?void 0:e.includes("rotate"))})):"ellipsis"!==n&&"wrap"!==n||t.filter((function(t){return t.querySelector("text")})).length>1)})(t,e,i)&&(null==o||o(t,r,e,n))}))}(this.node().childNodes,t,{hide:FF,show:BF,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=YV(e.__data__.value,t,n),i=e.querySelector(uV.labelItem.class);i&&XV(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&rz(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"),nz(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector("text")}})}function ZV(t,e,n,r,i){var o=n.indexOf(e),a=Mz(t).append(function(t,e,n,r){var i=r.labelFormatter;return Ut(i)?function(){return oz(YF(i,[t,e,n,xV(t.value,r)]))}:function(){return oz(t.label||"")}}(e,o,n,i)).attr("className",uV.labelItem.name).node(),s=Ve(Dz(gV(r,[e,o,n])),2),l=s[0],u=s[1],c=u.transform,h=Fe(u,["transform"]);_z(a,c);var d=$V(e,a,i);return a.getLocalEulerAngles()||a.setLocalEulerAngles(d),XV(a,Be(Be({},YV(e.value,d,i)),l)),t.attr(h),a}function QV(t,e,n,r){var i=vV(e,n.labelFilter),o=Pz(n,"label");return t.selectAll(uV.label.class).data(i,(function(t,e){return e})).join((function(r){return r.append("g").attr("className",uV.label.name).transition((function(t){ZV(this,t,e,o,n);var r=qV(t,e,n),i=r.x,a=r.y;return this.style.transform="translate(".concat(i,", ").concat(a,")"),null})).call((function(){KV.call(t,n)}))}),(function(i){return i.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&&FF(t),e.isVisible()&&BF(e)};if(!n)return i(),[null];var o=n.duration,a=void 0===o?0:o,s=n.delay,l=void 0===s?0:s,u=Math.ceil(+a/2),c=+a/4,h=Ve(t.getGeometryBounds().center,2),d=h[0],f=h[1],p=Ve(e.getGeometryBounds().center,2),g=Ve([(d+p[0])/2-d,(f+p[1])/2-f],2),v=g[0],m=g[1],y=t.style.opacity,b=void 0===y?1:y,x=e.style.opacity,E=void 0===x?1:x,w=t.style.transform||"",k=e.style.transform||"",M=t.animate([{opacity:b,transform:"translate(0, 0) ".concat(w)},{opacity:0,transform:"translate(".concat(v,", ").concat(m,") ").concat(w)}],Be(Be({fill:"both"},n),{duration:l+u+c})),S=e.animate([{opacity:0,transform:"translate(".concat(-v,", ").concat(-m,") ").concat(k),offset:.01},{opacity:E,transform:"translate(0, 0) ".concat(k)}],Be(Be({fill:"both"},n),{duration:u+c,delay:l+u-c}));return XG(S,i),[M,S]}(this.querySelector(uV.labelItem.class),ZV(this,t,e,o,n),r.update),a=qV(t,e,n),s=a.x,l=a.y,u=QG(this,{transform:"translate(".concat(s,", ").concat(l,")")},r.update);return We(We([],Ve(i),!1),[u],!1)})).call((function(e){var r,i,o=Oe(e,"_transitions").flat().filter(QF);i=function(){KV.call(t,n)},0===(r=o).length?i():Promise.all(r.map((function(t){return null==t?void 0:t.finished}))).then(i)}))}),(function(t){return t.transition((function(){var t=this,e=JG(this.childNodes[0],r.exit);return XG(e,(function(){return Mz(t).remove()})),e}))})).transitions()}function JV(t,e){return bV(t,e.tickDirection,e)}function tW(t,e,n,r,i){var o=Ve(function(t,e){var n=Ve(t,2);return[[0,0],[n[0]*e,n[1]*e]]}(r,YF(i.tickLength,[t,e,n])),2),a=Ve(o[0],2),s=a[0],l=a[1],u=Ve(o[1],2);return{x1:s,x2:u[0],y1:l,y2:u[1]}}function eW(t,e,n,r,i,o){var a=function(t,e,n,r,i){var o=i.tickFormatter,a=JV(e.value,i),s="line";return Ut(o)&&(s=function(){return YF(o,[e,n,r,a])}),t.append(s).attr("className",uV.tickItem.name)}(Mz(this),t,e,n,r);!function(t,e,n,r,i,o,a){var s=JV(t.value,o),l=tW(t,e,n,s,o),u=l.x1,c=l.x2,h=l.y1,d=l.y2,f=Ve(Dz(gV(a,[t,e,n,s])),2),p=f[0],g=f[1];"line"===r.node().nodeName&&r.styles(Be({x1:u,x2:c,y1:h,y2:d},p)),i.attr(g),r.styles(p)}(t,e,n,a,this,r,i);var s=Ve(EV(t.value,r),2),l=s[0],u=s[1];return QG(this,{transform:"translate(".concat(l,", ").concat(u,")")},o)}var nW=XF({text:"text"},"title");function rW(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function iW(t,e){var n=Object.entries(e).reduce((function(e,n){var r=Ve(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e}),{});t.styles(n)}var oW=function(t){function e(e){return t.call(this,e,{text:"",width:0,height:0,fill:"#4a505a",fontWeight:"bold",fontSize:12,fontFamily:"sans-serif",inset:0,spacing:0,position:"top-left"})||this}return je(e,t),e.prototype.getAvailableSpace=function(){var t=this.attributes,e=t.width,n=t.height,r=t.position,i=t.spacing,o=t.inset,a=this.querySelector(nW.text.class);if(!a)return new $F(0,0,+e,+n);var s=a.getBBox(),l=s.width,u=s.height,c=Ve(Sz(i),4),h=c[0],d=c[1],f=c[2],p=c[3],g=Ve([0,0,+e,+n],4),v=g[0],m=g[1],y=g[2],b=g[3],x=rW(r);if(x.includes("i"))return new $F(v,m,y,b);x.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=Ve(0===r?[u+f,+n-u-f]:[0,+n],2),m=i[0],b=i[1]),"r"===t&&(o=Ve([+e-l-p],1),y=o[0]),"b"===t&&(a=Ve([+n-u-h],1),b=a[0]),"l"===t&&(s=Ve(0===r?[l+d,+e-l-d]:[0,+e],2),v=s[0],y=s[1])}));var E=Ve(Sz(o),4),w=E[0],k=E[1],M=E[2],S=E[3],N=Ve([S+k,w+M],2),O=N[0],T=N[1];return new $F(v+S,m+w,y-O,b-T)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new $F(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=Fe(t,["width","height","position","spacing"]),i=Ve(Dz(r),1)[0],o=function(t){var e,n,r,i,o=t,a=o.width,s=o.height,l=o.position,u=Ve([+a/2,+s/2],2),c=Ve([+u[0],+u[1],"center","middle"],4),h=c[0],d=c[1],f=c[2],p=c[3],g=rW(l);return g.includes("l")&&(h=(e=Ve([0,"start"],2))[0],f=e[1]),g.includes("r")&&(h=(n=Ve([+a,"end"],2))[0],f=n[1]),g.includes("t")&&(d=(r=Ve([0,"top"],2))[0],p=r[1]),g.includes("b")&&(d=(i=Ve([+s,"bottom"],2))[0],p=i[1]),{x:h,y:d,textAlign:f,textBaseline:p}}(t),a=o.x,s=o.y,l=o.textAlign,u=o.textBaseline;az(!!r.text,Mz(e),(function(t){n.title=t.maybeAppendByClassName(nW.text,"text").styles(i).call(iW,{x:a,y:s,textAlign:l,textBaseline:u}).node()}))},e}(Bz);function aW(t,e,n,r,i){var o=Ve(Dz(Pz(r,"title")),2),a=o[0],s=o[1],l=s.transform,u=s.transformOrigin,c=Fe(s,["transform","transformOrigin"]);e.styles(c);var h=l||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(Be(Be({},a),{transformOrigin:u})),_z(t.node(),h);var d=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,a=rW(i),s=t.node().getLocalBounds(),l=Ve(s.min,2),u=l[0],c=l[1],h=Ve(s.halfExtents,2),d=h[0],f=h[1],p=Ve(e.node().getLocalBounds().halfExtents,2),g=p[0],v=p[1],m=Ve([u+d,c+f],2),y=m[0],b=m[1],x=Ve(Sz(o),4),E=x[0],w=x[1],k=x[2],M=x[3];if(["start","end"].includes(i)&&"linear"===n.type){var S=n.startPos,N=n.endPos,O=Ve("start"===i?[S,N]:[N,S],2),T=O[0],C=O[1],A=Ve(uz(gz([-C[0]+T[0],-C[1]+T[1]]),E),2),P=A[0],R=A[1];return{x:T[0]+P,y:T[1]+R}}return a.includes("t")&&(b-=f+v+E),a.includes("r")&&(y+=d+g+w),a.includes("l")&&(y-=d+g+M),a.includes("b")&&(b+=f+v+k),{x:y,y:b}}(Mz(n._offscreen||n.querySelector(uV.mainGroup.class)),e,r),f=d.x,p=d.y;return QG(e.node(),{transform:"translate(".concat(f,", ").concat(p,")")},i)}function sW(t,e,n,r){var i=t.showLine,o=t.showTick,a=t.showLabel,s=az(i,e.maybeAppendByClassName(uV.lineGroup,"g"),(function(e){return CV(e,t,r)}))||[],l=az(o,e.maybeAppendByClassName(uV.tickGroup,"g"),(function(e){return function(t,e,n,r){var i=vV(e,n.tickFilter),o=Pz(n,"tick");return t.selectAll(uV.tick.class).data(i,(function(t){return t.id||t.label})).join((function(t){return t.append("g").attr("className",uV.tick.name).transition((function(t,e){return eW.call(this,t,e,i,n,o,!1)}))}),(function(t){return t.transition((function(t,e){return this.removeChildren(),eW.call(this,t,e,i,n,o,r.update)}))}),(function(t){return t.transition((function(){var t=this,e=JG(this.childNodes[0],r.exit);return XG(e,(function(){return t.remove()})),e}))})).transitions()}(e,n,t,r)}))||[],u=az(a,e.maybeAppendByClassName(uV.labelGroup,"g"),(function(e){return QV(e,n,t,r)}))||[];return We(We(We([],Ve(s),!1),Ve(l),!1),Ve(u),!1).filter((function(t){return!!t}))}var lW=function(t){function e(e){return t.call(this,e,lV)||this}return je(e,t),e.prototype.render=function(t,e,n){var r=this,i=t.titleText,o=t.data,a=t.animate,s=t.showTitle,l=t.showGrid,u=t.dataThreshold,c=t.truncRange,h=function(t,e){if(t.length<=e)return t;for(var n=Math.floor(t.length/e),r=[],i=0;i<t.length;i+=n)r.push(t[i]);return r}(o,u).filter((function(t){var e=t.value;return!(c&&e>c[0]&&e<c[1])})),d=qG(void 0===n?a:n),f=az(l,Mz(e).maybeAppendByClassName(uV.gridGroup,"g"),(function(e){return RV(e,h,t,d)}))||[],p=Mz(e).maybeAppendByClassName(uV.mainGroup,"g");i&&(!this.initialized&&d.enter||this.initialized&&d.update)&&sW(t,Mz(this.offscreenGroup),h,qG(!1));var g=sW(t,Mz(p.node()),h,d),v=az(s,Mz(e).maybeAppendByClassName(uV.titleGroup,"g"),(function(e){return function(t,e,n,r){var i=n.titleText;return t.selectAll(uV.title.class).data([{title:i}].filter((function(t){return!!t.title})),(function(t,e){return t.title})).join((function(o){return o.append((function(){return oz(i)})).attr("className",uV.title.name).transition((function(){return aW(Mz(this),t,e,n,r.enter)}))}),(function(i){return i.transition((function(){return aW(Mz(this),t,e,n,r.update)}))}),(function(t){return t.remove()})).transitions()}(e,r,t,d)}))||[];return We(We(We([],Ve(f),!1),Ve(g),!1),Ve(v),!1).flat().filter((function(t){return!!t}))},e}(Bz),uW=XF({prevBtnGroup:"prev-btn-group",prevBtn:"prev-btn",nextBtnGroup:"next-btn-group",nextBtn:"next-btn",pageInfoGroup:"page-info-group",pageInfo:"page-info",playWindow:"play-window",contentGroup:"content-group",controller:"controller",clipPath:"clip-path"},"navigator"),cW=function(t){function e(e){var n=t.call(this,e,{x:0,y:0,animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonD:Hz(0,0,6),buttonSize:12,controllerPadding:5,controllerSpacing:5,formatter:function(t,e){return"".concat(t,"/").concat(e)},defaultPage:0,loop:!1,orientation:"horizontal",pageNumFill:"black",pageNumFontSize:12,pageNumTextAlign:"start",pageNumTextBaseline:"middle"})||this;return n.playState="idle",n.contentGroup=n.appendChild(new jl({class:uW.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new jl({class:uW.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return je(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return oe(t,0,Math.max(this.pageViews.length-1,0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.playWindow.children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"controllerShape",{get:function(){return this.totalPages>1?{width:55,height:0}:{width:0,height:0}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageShape",{get:function(){var t=Ve(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,We([],Ve(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 $F(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 l=Ve(this.getFollowingPageDiff(t),2),u=l[0],c=l[1];this.playState="running";var h=ZG(a,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-u,", ").concat(-c,")")}],n);return XG(h,(function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()})),h},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:oe(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:oe(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(uW.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)?BF(e):FF(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(),l=s.width;s.height;var u=Ve("horizontal"===o?[-180,0]:[-90,90],2),c=u[0],h=u[1];e.setLocalEulerAngles(c),n.setLocalEulerAngles(h);var d=e.getBBox(),f=d.width,p=d.height,g=n.getBBox(),v=g.width,m=g.height,y=Math.max(f,l,v),b="horizontal"===o?{offset:[[0,0],[f/2+a,0],[f+l+2*a,0]],textAlign:"start"}:{offset:[[y/2,-p-a],[y/2,0],[y/2,m+a]],textAlign:"center"},x=Ve(b.offset,3),E=Ve(x[0],2),w=E[0],k=E[1],M=Ve(x[1],2),S=M[0],N=M[1],O=Ve(x[2],2),T=O[0],C=O[1],A=b.textAlign,P=r.querySelector("text");P&&(P.style.textAlign=A),e.setLocalPosition(w,k),r.setLocalPosition(S,N),n.setLocalPosition(T,C)},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(uW.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<e?-1:1;return"horizontal"===n?[a*i,0]:[0,a*o]},e.prototype.prepareFollowingPage=function(t){var e=this.currPage,n=this.pageViews;if(this.setVisiblePages([t,e]),t!==e){var r=Ve(this.getFollowingPageDiff(t),2),i=r[0],o=r[1];n[t].setLocalPosition(i,o)}},e.prototype.renderController=function(t){var e=this,n=this.attributes.controllerSpacing,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,a=this.pageViews.length>=2,s=t.maybeAppendByClassName(uW.controller,"g");if(zF(s.node(),a),a){var l=Pz(this.attributes,"button"),u=Pz(this.attributes,"pageNum"),c=Ve(Dz(l),2),h=c[0],d=c[1],f=h.size,p=Fe(h,["size"]),g=!s.select(uW.prevBtnGroup.class).node(),v=s.maybeAppendByClassName(uW.prevBtnGroup,"g").styles(d);this.prevBtnGroup=v.node();var m=v.maybeAppendByClassName(uW.prevBtn,"path"),y=s.maybeAppendByClassName(uW.nextBtnGroup,"g").styles(d);this.nextBtnGroup=y.node(),[m,y.maybeAppendByClassName(uW.nextBtn,"path")].forEach((function(t){t.styles(Be(Be({},p),{transformOrigin:"center"})),wz(t.node(),f)}));var b=s.maybeAppendByClassName(uW.pageInfoGroup,"g");this.pageInfoGroup=b.node(),b.maybeAppendByClassName(uW.pageInfo,"text").styles(u),this.updatePageInfo(),s.node().setLocalPosition(i+n,o/2),g&&(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=Mz(e);this.renderClipPath(a),this.renderController(a),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=ye((function(){return t.render(t.attributes,t)}),50);this.playWindow.addEventListener(Vs.INSERTED,e),this.playWindow.addEventListener(Vs.REMOVED,e)},e}(Bz);function hW(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}$z.registerSymbol("hiddenHandle",(function(t,e,n){var r=1.4*n;return[["M",t-n,e-r],["L",t+n,e-r],["L",t+n,e+r],["L",t-n,e+r],["Z"]]})),$z.registerSymbol("verticalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=t+.4*r;return[["M",t,e],["L",a,e+i],["L",t+r,e+i],["L",t+r,e-i],["L",a,e-i],["Z"],["M",a,e+o],["L",t+r-2,e+o],["M",a,e-o],["L",t+r-2,e-o]]})),$z.registerSymbol("horizontalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=e+.4*r;return[["M",t,e],["L",t-i,a],["L",t-i,e+r],["L",t+i,e+r],["L",t+i,a],["Z"],["M",t-o,a],["L",t-o,e+r-2],["M",t+o,a],["L",t+o,e+r-2]]}));var dW=XF({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item");var fW=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new Dl({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this}return je(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.markerSize,r=t.node().getBBox(),i=r.width,o=r.height,a=e.node().getBBox(),s=a.width,l=a.height;return{markerWidth:n,labelWidth:i,valueWidth:s,height:Math.max(n,o,l)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=Ve(Sz(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}),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.height,s=this.actualSpace,l=s.labelWidth,u=s.valueWidth,c=Ve(this.spacing,2),h=c[0],d=c[1];if(r){var f=r-n-h-d,p=Ve(this.span,2);l=(t=Ve([p[0]*f,p[1]*f],2))[0],u=t[1]}return{width:o+l+u+h+d,height:a,markerWidth:o,labelWidth:l,valueWidth:u}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes.spacing;if(!t)return[0,0];var e=Ve(Sz(t),2),n=e[0],r=e[1];return this.showValue?[n,r]:[n,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.width,o=t.height,a=Ve(this.spacing,2),s=a[0];return{height:o,width:i,markerWidth:e,labelWidth:n,valueWidth:r,position:[e/2,e+s,e+n+s+a[1]]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(dW.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,l=void 0===s?t.stroke:s,u=+(i||a||(l?1:0))*Math.sqrt(2),c=this.markerGroup.node().getBBox(),h=c.width,d=c.height;return(1-u/Math.max(h,d))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes.marker,r=Pz(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(dW.markerGroup,"g").style("zIndex",0),az(!!n,this.markerGroup,(function(){var t,i=e.markerGroup.node(),o=null===(t=i.childNodes)||void 0===t?void 0:t[0],a="string"==typeof n?new $z({style:{symbol:n},className:dW.marker.name}):n();o?a.nodeName===o.nodeName?o instanceof $z?o.update(Be(Be({},r),{symbol:n})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=Ge(Object.entries(i)),a=o.next();!a.done;a=o.next()){var s=Ve(a.value,2),l=s[0],u=s[1];"id"!==l&&"className"!==l&&t.attr(l,u)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(o,a),Mz(o).styles(r)):(o.remove(),Mz(a).attr("className",dW.marker.name).styles(r),i.appendChild(a)):(a instanceof $z||Mz(a).attr("className",dW.marker.name).styles(r),i.appendChild(a)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]);var s=wz(e.markerGroup.node(),e.scaleSize);e.markerGroup.node().style._transform="scale(".concat(s,")")}))},e.prototype.renderLabel=function(t){var e=Pz(this.attributes,"label"),n=e.text,r=Fe(e,["text"]);this.labelGroup=t.maybeAppendByClassName(dW.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(dW.label,(function(){return oz(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=Pz(this.attributes,"value"),r=n.text,i=Fe(n,["text"]);this.valueGroup=t.maybeAppendByClassName(dW.valueGroup,"g").style("zIndex",0),az(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(dW.value,(function(){return oz(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=Pz(this.attributes,"background");this.background=t.maybeAppendByClassName(dW.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(dW.background,"rect").styles(Be({width:n,height:r},i))},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=Ve(t.position,3),o=i[0],a=i[1],s=i[2],l=r/2;this.markerGroup.styles({transform:"translate(".concat(o,", ").concat(l,")").concat(this.markerGroup.node().style._transform)}),this.labelGroup.styles({transform:"translate(".concat(a,", ").concat(l,")")}),rz(this.labelGroup.select(dW.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({transform:"translate(".concat(s,", ").concat(l,")")}),rz(this.valueGroup.select(dW.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=Mz(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.adjustLayout()},e}(Bz),pW=XF({page:"item-page",navigator:"navigator",item:"item"},"items"),gW=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},vW=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:Le,mouseenter:Le,mouseleave:Le})||this;return n.navigatorShape=[0,0],n}return je(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=Pz(this.attributes,"item"),i=e.map((function(t,i){var o=t.id,a=void 0===o?i:o,s=t.label,l=t.value;return{id:"".concat(a),index:i,style:Be({layout:n,labelText:s,valueText:l},Object.fromEntries(Object.entries(r).map((function(n){var r=Ve(n,2);return[r[0],YF(r[1],[t,i,e])]}))))}}));return i},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=Ve(this.navigatorShape,1)[0],s=Ve(this.grid,2),l=s[0],u=s[1],c=u*l,h=0;return this.pageViews.children.map((function(e,s){var d,f,p=Math.floor(s/c),g=s%c,v=t.ifHorizontal(u,l),m=[Math.floor(g/v),g%v];"vertical"===n&&m.reverse();var y=Ve(m,2),b=y[0],x=y[1],E=(r-a-(u-1)*o)/u,w=e.getBBox().height,k=Ve([0,0],2),M=k[0],S=k[1];return"horizontal"===n?(M=(d=Ve([h,b*(w+i)],2))[0],S=d[1],h=x===u-1?0:h+E+o):(M=(f=Ve([x*(E+o),h],2))[0],S=f[1],h=b===l-1?0:h+w+i),{page:p,index:s,row:b,col:x,pageIndex:g,width:E,height:w,x:M,y:S}}))},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=Ve(this.navigatorShape,1)[0],a=Ve(this.grid,2),s=a[0],l=a[1],u=Ve([e-o,n],2),c=u[0],h=u[1],d=Ve([0,0,0,0,0,0,0,0],8),f=d[0],p=d[1],g=d[2],v=d[3],m=d[4],y=d[5],b=d[6],x=d[7];return this.pageViews.children.map((function(t,e){var n,o,a,u,d=t.getBBox(),E=d.width,w=d.height,k=0===b?0:i,M=b+k+E;return M<=c&&gW(m,(function(t){return t<l}))?(n=Ve([b+k,x,M],3),f=n[0],p=n[1],b=n[2],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}):(o=Ve([y+1,0,0,x+w+r],4),y=o[0],m=o[1],b=o[2],(x=o[3])+w<=h&&gW(y,(function(t){return t<s}))?(a=Ve([b,x,E],3),f=a[0],p=a[1],b=a[2],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}):(u=Ve([0,0,E,0,g+1,0,0,0],8),f=u[0],p=u[1],b=u[2],x=u[3],g=u[4],v=u[5],y=u[6],m=u[7],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}))}))},Object.defineProperty(e.prototype,"itemsLayout",{get:function(){this.navigatorShape=[0,0];var t="grid"===this.attributes.layout?this.getGridLayout:this.getFlexLayout,e=t.call(this);return e.slice(-1)[0].page>0?(this.navigatorShape=[55,0],t.call(this)):e},enumerable:!1,configurable:!0}),e.prototype.ifHorizontal=function(t,e){return hW(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(pW.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(pW.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;this.flattenPage(t);var o=this.dispatchCustomEvent.bind(this);Mz(t).selectAll(pW.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new fW({style:e})})).attr("className",pW.item.name).on("click",(function(){null==n||n(this),o("itemClick",{item:this})})).on("pointerenter",(function(){null==r||r(this),o("itemMouseenter",{item:this})})).on("pointerleave",(function(){null==i||i(this),o("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=Ve(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=Ve(t,2);return{page:e[0],layouts:e[1]}})),i=We([],Ve(this.navigator.getContainer().children),!1);r.forEach((function(t){var e=t.layouts,r=n.pageViews.appendChild(new jl({className:pW.page.name}));e.forEach((function(t){var e=t.x,n=t.y,o=t.index,a=t.width,s=t.height,l=i[o];r.appendChild(l),Te(l,"__layout__",t),l.update({x:e,y:n,width:a,height:s})}))})),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes.orientation,n=Pz(this.attributes,"nav"),r=ZF({orientation:e},n),i=this;return t.selectAll(pW.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new cW({style:r})})).attr("className",pW.navigator.name).each((function(){i.navigator=this}))}),(function(t){return t.each((function(){this.update(r)}))}),(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(Mz(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new Rs(t,{detail:e});this.dispatchEvent(n)},e}(Bz),mW=XF({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),yW={showLabel:!0,formatter:function(t){return t.toString()},markerSize:25,markerStroke:"#c5c5c5",markerFill:"#fff",markerLineWidth:1,labelFontSize:12,labelFill:"#c5c5c5",labelText:"",orientation:"vertical",spacing:0};!function(t){function e(e){return t.call(this,e,yW)||this}je(e,t),e.prototype.render=function(t,e){var n=Mz(e).maybeAppendByClassName(mW.markerGroup,"g");this.renderMarker(n);var r=Mz(e).maybeAppendByClassName(mW.labelGroup,"g");this.renderLabel(r)},e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.orientation,i=n.markerSymbol,o=void 0===i?hW(r,"horizontalHandle","verticalHandle"):i;az(!!o,t,(function(t){var n=Pz(e.attributes,"marker"),r=Be({symbol:o},n);e.marker=t.maybeAppendByClassName(mW.marker,(function(){return new $z({style:r})})).update(r)}))},e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.showLabel,i=n.orientation,o=n.spacing,a=void 0===o?0:o,s=n.formatter;az(r,t,(function(t){var n,r=Pz(e.attributes,"label"),o=r.text,l=Fe(r,["text"]),u=(null===(n=t.select(mW.marker.class))||void 0===n?void 0:n.node().getBBox())||{},c=u.width,h=void 0===c?0:c,d=u.height,f=Ve(hW(i,[0,(void 0===d?0:d)+a,"center","top"],[h+a,0,"start","middle"]),4),p=f[0],g=f[1],v=f[2],m=f[3];t.maybeAppendByClassName(mW.label,"text").styles(Be(Be({},l),{x:p,y:g,text:s(o).toString(),textAlign:v,textBaseline:m}))}))}}(Bz);var bW={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},xW=ZF({},bW,{});ZF({},bW,Rz(yW,"handle"),{color:["#d0e3fa","#acc7f6","#8daaf2","#6d8eea","#4d73cd","#325bb1","#5a3e75","#8c3c79","#e23455","#e7655b"],indicatorBackgroundFill:"#262626",indicatorLabelFill:"white",indicatorLabelFontSize:12,indicatorVisibility:"hidden",labelAlign:"value",labelDirection:"positive",labelSpacing:5,showHandle:!0,showIndicator:!0,showLabel:!0,slidable:!0,titleText:"",type:"continuous"});var EW=XF({title:"title",titleGroup:"title-group",items:"items",itemsGroup:"items-group",contentGroup:"content-group",ribbonGroup:"ribbon-group",ribbon:"ribbon",handlesGroup:"handles-group",handle:"handle",startHandle:"start-handle",endHandle:"end-handle",labelGroup:"label-group",label:"label",indicator:"indicator"},"legend"),wW=function(t){function e(e){return t.call(this,e,xW)||this}return je(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,a=Ve(Dz(Pz(this.attributes,"title")),2),s=a[0],l=a[1];this.titleGroup=t.maybeAppendByClassName(EW.titleGroup,"g").styles(l);var u=Be(Be({width:e,height:n},s),{text:i?o:""});this.title=this.titleGroup.maybeAppendByClassName(EW.title,(function(){return new oW({style:u})})).update(u)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,a=Ve(Dz(Pz(this.attributes,"title",!0)),2),s=a[0],l=a[1],u=Be(Be({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(EW.itemsGroup,"g").styles(Be(Be({},l),{transform:"translate(".concat(n,", ").concat(r,")")}));var c=this;this.itemsGroup.selectAll(EW.items.class).data(["items"]).join((function(t){return t.append((function(){return new vW({style:u})})).attr("className",EW.items.name).each((function(){c.items=Mz(this)}))}),(function(t){return t.update(u)}),(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 $F(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(),l=e.getBBox(),u=rW(r),c=Ve(Sz(a?i:0),4),h=c[0],d=c[1],f=c[2],p=c[3],g=Ve(Sz(o),4),v=g[0],m=g[1],y=g[2],b=g[3],x=Ve([p+d,h+f],2),E=x[0],w=x[1],k=Ve([b+m,v+y],2),M=k[0],S=k[1];if("l"===u[0])return new $F(s.x,s.y,l.width+s.width+E+M,Math.max(l.height+S,s.height));if("t"===u[0])return new $F(s.x,s.y,Math.max(l.width+M,s.width),l.height+s.height+w+S);var N=Ve([e.attributes.width||l.width,e.attributes.height||l.height],2),O=N[0],T=N[1];return new $F(l.x,l.y,O+s.width+E+M,T+s.height+w+S)}(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,l=void 0===s?0:s,u=Mz(e);e.style.transform="translate(".concat(a,", ").concat(l,")"),this.renderTitle(u,r,i),this.renderItems(u,this.availableSpace),this.adjustLayout()},e}(Bz),kW={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},MW=XF({background:"background",labelGroup:"label-group",label:"label"},"indicator"),SW=function(t){function e(e){var n=t.call(this,e,kW)||this;return n.point=[0,0],n.group=n.appendChild(new jl({})),n.isMutationObserved=!0,n}return je(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=Ve(Sz(t.padding),4),r=n[0],i=n[1],o=n[2],a=n[3],s=this.label.node().getLocalBounds(),l=s.min,u=s.max,c=new $F(l[0]-a,l[1]-r,u[0]+i-l[0]+a,u[1]+o-l[1]+r),h=this.getPath(e,c),d=Pz(this.attributes,"background");this.background=Mz(this.group).maybeAppendByClassName(MW.background,"path").styles(Be(Be({},d),{d:h})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=Ve(Dz(Pz(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var a=Fe(i,["text"]);(this.label=Mz(this.group).maybeAppendByClassName(MW.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(MW.label,(function(){return oz(e(n))})).style("text",e(n).toString()).selectAll("text").styles(a)},e.prototype.adjustLayout=function(){var t=Ve(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"]],l={top:4,right:6,bottom:0,left:2}[t],u=this.createCorner([s[l].slice(-2),s[l+1].slice(-2)]);return s.splice.apply(s,We([l+1,1],Ve(u),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=Oz.apply(void 0,We([],Ve(t),!1)),r=Ve(t,2),i=Ve(r[0],2),o=i[0],a=i[1],s=Ve(r[1],2),l=s[0],u=s[1],c=Ve(n?[l-o,[o,l]]:[u-a,[a,u]],2),h=c[0],d=Ve(c[1],2),f=d[0],p=d[1],g=h/2,v=e*(h/Math.abs(h)),m=v/2,y=v*Math.sqrt(3)/2*.8,b=Ve([f,f+g-m,f+g,f+g+m,p],5),x=b[0],E=b[1],w=b[2],k=b[3],M=b[4];return n?(this.point=[w,a-y],[["L",x,a],["L",E,a],["L",w,a-y],["L",k,a],["L",M,a]]):(this.point=[o+y,w],[["L",o,x],["L",o,E],["L",o+y,w],["L",o,k],["L",o,M]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?FF(this):BF(this)},e.prototype.bindEvents=function(){this.label.on(Vs.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(Bz);function NW(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 OW={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function TW(t){var e;void 0===t&&(t="");var n=NW(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)]=Be({flex:1},OW),e[".".concat(n.VALUE)]=Be({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},OW),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 CW=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=NW(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:'<div class="'.concat(a.CONTAINER,'"></div>'),title:'<div class="'.concat(a.TITLE,'"></div>'),item:'<li class="'.concat(a.LIST_ITEM,'" data-index={index}>\n <span class="').concat(a.NAME,'">\n <span class="').concat(a.MARKER,'" style="background:{color}"></span>\n <span class="').concat(a.NAME_LABEL,'" title="{name}">{name}</span>\n </span>\n <span class="').concat(a.VALUE,'" title="{value}">{value}</span>\n </li>')},style:TW(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return je(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,l=Fe(t,["name","color","index"]),u=Be({name:i,color:a,index:null!=s?s:e},l);return Cn(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,u))}))},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=Cn(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:Iz(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,l=NW(r.prefixCls),u=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(u.innerHTML=r.title,u.getElementsByClassName(l.TITLE)[0].innerHTML=i):null===(e=null===(t=u.getElementsByClassName(l.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var c=this.HTMLTooltipItemsElements,h=document.createElement("ul");h.className=l.LIST,Iz(h,c);var d=this.element.querySelector(".".concat(l.LIST));d?d.replaceWith(h):u.appendChild(h)}!function(t,e){Object.entries(e).forEach((function(e){var n=Ve(e,2),r=n[0],i=n[1];We([t],Ve(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(":"),";")}),""))}))}))}(u,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,l=a.height,u=[-s/2,-l/2];return i.forEach((function(t){var e=Ve(u,2),n=e[0],i=e[1],a=Ve(o[t],2),c=a[0],h=a[1];u=[n+(s/2+r[0])*c,i+(l/2+r[1])*h]})),u},e.prototype.setOffsetPosition=function(t){var e=Ve(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=void 0===o?0:o,s=i.y,l=void 0===s?0:s,u=i.container,c=u.x,h=u.y;this.element.style.left="".concat(+a+c+n,"px"),this.element.style.top="".concat(+l+h+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.timestamp<e||(this.timestamp=n,this.setOffsetPosition(this.autoPosition(this.getRelativeOffsetFromCursor())))},e.prototype.autoPosition=function(t){var e=Ve(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=i.y,s=i.bounding,l=i.position;if(!s)return[n,r];var u=this.element,c=u.offsetWidth,h=u.offsetHeight,d=Ve([+o+n,+a+r],2),f=d[0],p=d[1],g={left:"right",right:"left",top:"bottom",bottom:"top"},v=s.x,m=s.y,y={left:f<v,right:f+c>v+s.width,top:p<m,bottom:p+h>m+s.height},b=[];l.split("-").forEach((function(t){y[t]?b.push(g[t]):b.push(t)}));var x=b.join("-");return this.getRelativeOffsetFromCursor(x)},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 $F(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}(Bz),AW=function(t){function e(n){var r=t.call(this,ZF({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new Xl({})),r.label=r.background.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Sz(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=Pz(this.attributes,"label");Mz(this.label).maybeAppend(".label",(function(){return oz(e)})).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=Ve(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3],a=t.width,s=t.height,l=a+o+r,u=s+n+i,c=Pz(this.attributes,"background"),h=this.style,d=h.width,f=void 0===d?0:d,p=h.height,g=void 0===p?0:p,v=h.selected;this.background.attr(Be(Be({},c),{width:Math.max(l,f),height:Math.max(u,g),fill:v?this.selectedColor:"#fff"})),this.label.attr({transform:"translate(".concat(o,", ").concat((u-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}(Bz),PW=function(t){function e(n){var r,i,o=t.call(this,ZF({},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 Xl({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new Xl({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 je(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 Sz(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,l=n.showDropdownIcon,u=Pz(this.attributes,"select"),c=Pz(this.attributes,"placeholder");this.select.attr(Be(Be({x:r,y:i,width:o,height:a},u),{fill:"#fff",strokeWidth:s?1:0}));var h=this.dropdownPadding;l&&Mz(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-h[1]-h[3],", ").concat(i+a/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var d=null===(t=this.style.options)||void 0===t?void 0:t.find((function(t){return t.value===e.currentValue})),f=Be({x:r+h[3]},c);Mz(this.select).selectAll(".placeholder").data(d?[]:[1]).join((function(t){return t.append("text").attr("className","placeholder").styles(f).style("y",(function(){var t=this.getBBox();return i+(a-t.height)/2}))}),(function(t){return t.styles(f)}),(function(t){return t.remove()}));var p=Pz(this.attributes,"optionLabel"),g=Be({x:r+h[3]},p);Mz(this.select).selectAll(".value").data(d?[d]:[]).join((function(t){return t.append((function(t){return oz(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,l=r.options,u=r.onSelect,c=r.open,h=Pz(this.attributes,"dropdown"),d=Pz(this.attributes,"option"),f=this.dropdownPadding;Mz(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(l,(function(t){return t.value})).join((function(t){return t.append((function(t){return new AW({className:"dropdown-item",style:Be(Be(Be({},t),d),{width:a-f[1]-f[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==u||u(t,e,r),n.dispatchEvent(new Rs("change",{detail:{value:t,option:e,item:r}})),FF(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 r<e&&(t+=n.getBBox().height),t}),0);this.attr("transform","translate(".concat(f[3],", ").concat(f[0]+r,")"))}))}),(function(t){return t.update((function(t){return{selected:t.value===n.currentValue}}))}),(function(t){return t.remove()}));var p=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),g=h.spacing;this.dropdown.attr(Be({transform:"translate(".concat(i,", ").concat(o+s+g,")"),width:p.width+f[1]+f[3],height:p.height+f[0]+f[2]},h)),!c&&FF(this.dropdown)},e.prototype.render=function(){this.renderSelect(),this.renderDropdown()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("click",(function(t){t.stopPropagation()})),this.select.addEventListener("click",(function(){"visible"===t.dropdown.style.visibility?FF(t.dropdown):BF(t.dropdown)})),this.addEventListener("pointerenter",(function(){t.isPointerInSelect=!0})),this.addEventListener("pointerleave",(function(){t.isPointerInSelect=!1})),null===document||void 0===document||document.addEventListener("click",(function(){t.isPointerInSelect||FF(t.dropdown)}))},e.defaultOptions={style:{x:0,y:0,width:140,height:32,options:[],bordered:!0,defaultValue:"",selectRadius:8,selectStroke:"#d9d9d9",showDropdownIcon:!0,placeholderText:"请选择",placeholderFontSize:12,placeholderTextBaseline:"top",placeholderFill:"#c2c2c2",dropdownFill:"#fff",dropdownStroke:"#d9d9d9",dropdownRadius:8,dropdownShadowBlur:4,dropdownShadowColor:"rgba(0, 0, 0, 0.08)",dropdownPadding:8,dropdownSpacing:10,optionPadding:[8,12],optionFontSize:12,optionTextBaseline:"top",optionBackgroundFill:"#fff",optionBackgroundRadius:4,optionLabelFontSize:12,optionLabelTextBaseline:"top"}},e}(Bz),RW=function(t){function e(n){var r=t.call(this,ZF({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new Xl({})),r.icon=r.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"BaseIcon"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineWidth",{get:function(){return Math.log10(this.attributes.size)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return Sz(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=Ve(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3];return Math.max(t-Math.max(o+r,n+i),2*this.lineWidth+1)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.size,i=r/2,o=Pz(this.attributes,"background");this.background.attr(Be({x:e-i,y:n-i,width:r,height:r},o))},e.prototype.showIndicator=function(){if(this.label){var t=this.attributes.size,e=this.background.getBBox(),n=e.x,r=e.y;this.indicator.update({x:n+t/2,y:r-5,labelText:this.label,visibility:"visible"})}},e.prototype.hideIndicator=function(){this.indicator.update({visibility:"hidden"})},e.prototype.connectedCallback=function(){var e;t.prototype.connectedCallback.call(this);var n=this.attributes.size,r=this.background.getBBox(),i=r.x,o=r.y,a=null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView;a&&(this.indicator=a.appendChild(new SW({style:{x:i+n/2,y:o-n/2,visibility:"hidden",position:"top",radius:3,zIndex:100}})))},e.prototype.disconnectedCallback=function(){this.indicator.destroy()},e.prototype.render=function(){this.renderIcon(),this.showBackground&&this.renderBackground()},e.prototype.bindEvents=function(){var t=this,n=this.attributes.onClick;if(this.addEventListener("click",(function(){null==n||n(t)})),this.showBackground){var r=function(){return t.background.attr({opacity:e.backgroundOpacities.default})};this.addEventListener("pointerenter",(function(){t.background.attr({opacity:e.backgroundOpacities.hover}),t.showIndicator()})),this.addEventListener("pointerleave",(function(){r(),t.hideIndicator()})),this.addEventListener("pointerdown",(function(){t.background.attr({opacity:e.backgroundOpacities.active})})),this.addEventListener("pointerup",(function(){r()}))}},e.tag="IconBase",e.defaultOptions={style:{x:0,y:0,size:10,color:"#565758",backgroundRadius:4,backgroundFill:"#e2e2e2"}},e.backgroundOpacities={default:0,hover:.8,active:1},e}(Bz),DW=function(t,e){return void 0===e&&(e="#565758"),new Hl({style:{fill:e,d:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},LW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.arcPath=function(t,e,n){var r=Ve([n,n],2),i=r[0],o=r[1],a=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=Ve(a(-5/4*Math.PI),2),l=s[0],u=s[1],c=Ve(a(1/4*Math.PI),2),h=c[0],d=c[1];return"M".concat(l,",").concat(u,",A").concat(i,",").concat(o,",0,1,1,").concat(h,",").concat(d)},Object.defineProperty(e.prototype,"label",{get:function(){return"重置"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o+.5;Mz(this.icon).maybeAppend(".reset","path").styles({stroke:r,lineWidth:o,d:this.arcPath(e,n,i/2-o),markerStart:DW(a,r)})},e}(RW),_W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e-o,n],[e,n+a],[e,n],[e+o,n-a],[e+o,n+a],[e,n]];Mz(this.icon).maybeAppend(".backward","polygon").styles({points:s,fill:r})},e}(RW),IW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e+o,n],[e,n+a],[e,n],[e-o,n-a],[e-o,n+a],[e,n]];Mz(this.icon).maybeAppend(".forward","polygon").styles({points:s,fill:r})},e}(RW),jW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3*Math.pow(3,.5)*.8,a=[[e+o,n],[e-o/2,n-i/2*.8],[e-o/2,n+i/2*.8],[e+o,n]];Mz(this.icon).maybeAppend(".play","polygon").styles({points:a,fill:r})},e}(RW),BW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3,a=[[e-o,n-i/2],[e-o,n+i/2],[e-o/2,n+i/2],[e-o/2,n-i/2],[e-o,n-i/2],[e+o/2,n-i/2],[e+o/2,n+i/2],[e+o,n+i/2],[e+o,n-i/2]];Mz(this.icon).maybeAppend(".pause","polygon").styles({points:a,fill:r})},e}(RW),FW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o;Mz(this.icon).maybeAppend(".left-line","line").styles({x1:e-i/2,y1:n-i/2,x2:e-i/2,y2:n+i/2,stroke:r,lineWidth:o}),Mz(this.icon).maybeAppend(".right-line","line").styles({x1:e+i/2,y1:n-i/2,x2:e+i/2,y2:n+i/2,stroke:r,lineWidth:o}),Mz(this.icon).maybeAppend(".left-arrow","line").styles({x1:e,y1:n,x2:e-i/2+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:DW(2*o,r)}),Mz(this.icon).maybeAppend(".right-arrow","line").styles({x1:e,y1:n,x2:e+i/2-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:DW(2*o,r)})},e}(RW),zW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;Mz(this.icon).maybeAppend(".line","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o});var a=o;Mz(this.icon).maybeAppend(".left-arrow","line").styles({x1:e-i/2-2*a,y1:n,x2:e-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:DW(2*o,r)}),Mz(this.icon).maybeAppend(".right-arrow","line").styles({x1:e+i/2+2*a,y1:n,x2:e+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:DW(2*o,r)})},e}(RW),GW=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},VW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=(i-2*o-o)/4,s=(i-2*o-o)/2,l=Ve([e-i/2+o,n+i/2-2*o],2),u=l[0],c=l[1];Mz(this.icon).maybeAppend(".coordinate","polyline").styles({points:GW(i).map((function(t){var r=Ve(t,2),i=r[0],o=r[1];return[i+e,o+n]})),stroke:r,lineWidth:o}),Mz(this.icon).maybeAppend(".line","polyline").styles({points:[[u,c],[u+a,c-s],[u+2*a,c],[u+4*a,c-2*s]],stroke:r,lineWidth:o})},e}(RW),WW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"条形图"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return[1,4,2,4,3]},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.data,e=this.attributes,n=e.x,r=e.y,i=e.color,o=this.iconSize,a=this.lineWidth,s=a,l=(o-s)/t.length,u=(o-2*s)/4,c=Ve([n-o/2+2*s,r+o/2-s],2),h=c[0],d=c[1];Mz(this.icon).maybeAppend(".coordinate","polyline").styles({points:GW(o).map((function(t){var e=Ve(t,2),i=e[0],o=e[1];return[i+n,o+r]})),stroke:i,lineWidth:a}),Mz(this.icon).maybeAppend(".bars","g").selectAll(".column").data(this.data.map((function(t,e){return{value:t,index:e}}))).join((function(t){return t.append("line").attr("className","column").style("x1",(function(t){var e=t.index;return h+l*e})).style("y1",d).style("x2",(function(t){var e=t.index;return h+l*e})).style("y2",(function(t){var e=t.value;return d-u*e})).styles({y1:d,stroke:i,lineWidth:a})}))},e}(RW),HW=function(t){function e(e){var n=t.call(this,ZF({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return je(e,t),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;Mz(this.icon).maybeAppend(".split","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o})},e}(RW),UW=function(t){function e(){var e=t.apply(this,We([],Ve(arguments),!1))||this;return e.showBackground=!1,e}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Sz(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes,n=e.x,r=e.y,i=e.speed,o=void 0===i?1:i,a=Pe(this.attributes,["x","y","transform","transformOrigin","width","height","size","color","speed"]),s=oe(t,20,1/0),l=Be(Be({},a),{x:n-s/2,y:r-10,width:s,height:20,defaultValue:o,bordered:!1,showDropdownIcon:!1,selectRadius:2,dropdownPadding:this.padding,dropdownRadius:2,dropdownSpacing:t/5,placeholderFontSize:t/2,optionPadding:0,optionLabelFontSize:t/2,optionBackgroundRadius:1,options:[{label:"1x",value:1},{label:"1.5x",value:1.5},{label:"2x",value:2}]});Mz(this.icon).maybeAppend(".speed",(function(){return new PW({style:l})})).attr("className","speed").each((function(){this.update(l)}))},e.tag="SpeedSelect",e}(RW),$W=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new jl({})),n.currentType=n.attributes.type,n}return je(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.onChange;var n=Fe(e,["onChange"]);Mz(this.icon).selectAll(".icon").data([this.currentType]).join((function(e){return e.append((function(e){var n,r=null===(n=t.toggles.find((function(t){return Ve(t,1)[0]===e})))||void 0===n?void 0:n[1];if(!r)throw new Error("Invalid type: ".concat(e));return new r({})})).attr("className","icon").styles(n,!1).update({})}),(function(t){return t.styles({restStyles:n}).update({})}),(function(t){return t.remove()}))},e.prototype.bindEvents=function(){var t=this,e=this.attributes.onChange;this.addEventListener("click",(function(n){n.preventDefault(),n.stopPropagation();var r=(t.toggles.findIndex((function(e){return Ve(e,1)[0]===t.currentType}))+1)%t.toggles.length,i=t.toggles[r][0];null==e||e(t.currentType),t.currentType=i,t.render()}))},e.tag="ToggleIcon",e}(Bz),YW=function(t){function e(e){var n=t.call(this,ZF({},{style:{type:"play"}},e))||this;return n.toggles=[["play",jW],["pause",BW]],n}return je(e,t),e}($W),qW=function(t){function e(e){var n=t.call(this,ZF({},{style:{type:"range"}},e))||this;return n.toggles=[["range",FW],["value",zW]],n}return je(e,t),e}($W),XW=function(t){function e(e){var n=t.call(this,ZF({},{style:{type:"column"}},e))||this;return n.toggles=[["line",VW],["column",WW]],n}return je(e,t),e}($W),KW={reset:LW,speed:UW,backward:_W,playPause:YW,forward:IW,selectionType:qW,chartType:XW,split:HW},ZW=function(t){function e(n){var r=t.call(this,ZF({},e.defaultOptions,n))||this;return r.background=r.appendChild(new Xl({})),r.functions=r.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Sz(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.x,n=t.y,r=t.width,i=t.height,o=Pz(this.attributes,"background");this.background.attr(Be({x:e,y:n,width:r,height:i},o))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,i=n.iconSize,o=n.iconSpacing,a=n.x,s=n.y,l=n.width,u=n.height,c=n.align,h=Ve(this.padding,4),d=h[1],f=h[3],p=r.reduce((function(t,e){return t.length&&e.length?t.concat.apply(t,We(["split"],Ve(e),!1)):t.concat.apply(t,We([],Ve(e),!1))}),[]),g=p.length*(i+o)-o,v={left:f+i/2,center:(l-g)/2+i/2,right:l-g-f-d+i/2}[c]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),p.forEach((function(t,n){var r,l=KW[t],c={x:a+n*(i+o)+v,y:s+u/2,size:i};if(l===UW?(c.speed=e.attributes.speed,c.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[YW,qW,XW].includes(l)?(c.onChange=function(n){return e.handleFunctionChange(t,{value:n})},l===YW&&(c.type="play"===e.attributes.state?"pause":"play"),l===qW&&(c.type="range"===e.attributes.selectionType?"value":"range"),l===XW&&(c.type="line"===e.attributes.chartType?"column":"line")):c.onClick=function(){return e.handleFunctionChange(t,{value:t})},l===UW){var h=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;h&&(e.speedSelect=new l({style:Be(Be({},c),{zIndex:100})}),h.appendChild(e.speedSelect))}else e.functions.appendChild(new l({style:c}))}))},e.prototype.disconnectedCallback=function(){var e;t.prototype.disconnectedCallback.call(this),null===(e=this.speedSelect)||void 0===e||e.destroy()},e.prototype.render=function(){this.renderBackground(),this.renderFunctions()},e.prototype.handleFunctionChange=function(t,e){var n=this.attributes.onChange;null==n||n(t,e)},e.defaultOptions={style:{x:0,y:0,width:300,height:40,padding:0,align:"center",iconSize:25,iconSpacing:0,speed:1,state:"pause",chartType:"line",selectionType:"range",backgroundFill:"#fbfdff",backgroundStroke:"#ebedf0",functions:[["reset","speed"],["backward","playPause","forward"],["selectionType","chartType"]]}},e}(Bz),QW=function(t){function e(n){var r=t.call(this,ZF({},e.defaultOptions,n))||this;return r.bindEvents(),r}return je(e,t),e.prototype.bindEvents=function(){var t=this;this.addEventListener("mouseenter",(function(){t.attr("lineWidth",Math.ceil(+(t.style.r||0)/2))})),this.addEventListener("mouseleave",(function(){t.attr("lineWidth",0)}))},e.defaultOptions={style:{r:5,fill:"#3f7cf7",lineWidth:0,stroke:"#3f7cf7",strokeOpacity:.5,cursor:"pointer"}},e}(Dl),JW=function(t){function e(n){return t.call(this,ZF({},e.defaultOptions,n))||this}return je(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=Pz(this.attributes,"background");Mz(this).maybeAppend("background","rect").attr("className","background").styles(Be({x:e-r/2,y:n-i/2,width:r,height:i},o))},e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.iconSize,i=Pz(this.attributes,"icon"),o=r/2;Mz(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(Be({x1:e-1,y1:n-o,x2:e-1,y2:n+o},i)),Mz(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(Be({x1:e+1,y1:n-o,x2:e+1,y2:n+o},i))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,a=Pz(this.attributes,"border"),s="start"===o?+r/2:-r/2;Mz(this).maybeAppend("border","line").attr("className","border").styles(Be({x1:s+e,y1:n-i/2,x2:s+e,y2:n+i/2},a))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{x:0,y:0,width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(Bz);function tH(t,e){return"number"==typeof t?eH(t):function(t,e){var n=new Date(t);switch(e){case"half-hour":case"hour":case"four-hour":return[0,6,12,18].includes(n.getHours())&&0===n.getMinutes()?Lz(n,"HH:mm\nYYYY-MM-DD"):Lz(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(Lz(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?Lz(n,"DD\nYYYY-MM"):Lz(n,"DD");case"week":return n.getDate()<=7?Lz(n,"DD\nYYYY-MM"):Lz(n,"DD");case"month":return[0,6].includes(n.getMonth())?Lz(n,"MM月\nYYYY"):Lz(n,"MM月");case"season":return[0].includes(n.getMonth())?Lz(n,"MM月\nYYYY"):Lz(n,"MM月");case"year":return Lz(n,"YYYY");default:return Lz(n,"YYYY-MM-DD HH:mm")}}(t,e)}function eH(t){var e=String(Math.floor(t/3600)).padStart(2,"0"),n=String(Math.floor(t%3600/60)).padStart(2,"0"),r=String(Math.floor(t%60)).padStart(2,"0");return t<3600?"".concat(n,":").concat(r):"".concat(e,":").concat(n,":").concat(r)}var nH=function(t){function e(n){var r=t.call(this,ZF({},e.defaultOptions,n))||this;r.axis=r.appendChild(new lW({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new sV({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new ZW({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?We([],Ve(e),!1):e);r.setBySliderValues(t),r.dispatchOnChange(n)};var i=r.attributes,o=i.selectionType,a=i.chartType,s=i.speed,l=i.state,u=i.playMode,c=i.values;return r.states={chartType:a,playMode:u,selectionType:o,speed:s,state:l},r.setByTimebarValues(c),r}return je(e,t),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.data.sort((function(t,e){return t.time<e.time?-1:t.time>e.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=oe(+i-a,0,+i),l=new $F(e,n+ +i-a,+r,a),u=0,c="time"===o?10:s;return{axisBBox:"chart"===o?new $F(e,n+s-(u=35),+r,u):new $F,controllerBBox:l,timelineBBox:new $F(e,n+("time"===o?s:s-c),+r,c-u)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=Ve(Array.isArray(t)?t:[0,t],2),o=i[0],a=i[1],s=r.length,l=r[Math.floor(o*s)],u=r[Math.ceil(a*s)-(Array.isArray(t)?0:1)];this.states.values=[null!==(e=null==l?void 0:l.time)&&void 0!==e?e:r[0].time,null!==(n=null==u?void 0:u.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=Ve(Array.isArray(t)?t:[void 0,t],2),a=o[0],s=o[1],l=i.find((function(t){return t.time===a})),u=i.find((function(t){return t.time===s}));this.states.values=[null!==(e=null==l?void 0:l.time)&&void 0!==e?e:null===(n=i[0])||void 0===n?void 0:n.time,null!==(r=null==u?void 0:u.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,a=Ve(t,2),s=a[0],l=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[l])||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=Ve(Array.isArray(n)?n:[void 0,n],2),o=i[0],a=i[1],s=this.data,l=s.length,u="value"===r;return[(t=s.findIndex((function(t){return t.time===o})),u?0:t>-1?t/l:0),function(){if(a===1/0)return 1;var t=s.findIndex((function(t){return t.time===a}));return t>-1?t/l:u?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=Ve(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 JW({style:{type:t,height:e,iconSize:e/6}})}:function(){return new Vl({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,l=a.chartType,u=this.data,c=this.attributes,h=c.type,d=c.labelFormatter,f=Pz(this.attributes,"chart");f.type;var p=Fe(f,["type"]),g="range"===s;if("time"===h)return Be({handleIconShape:function(){return new QW({})},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(d)return d(t);var n=e.getDatumByRatio(t).time;return"number"==typeof n?eH(n):Lz(n,"YYYY-MM-DD HH:mm:ss")},transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},p);var v="range"===s?5:0,m=u.map((function(t){return t.value}));return Be({handleIconOffset:v,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:m,sparklineType:l,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},p)},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=Pz(this.attributes,"axis"),a=t.x,s=t.y,l=t.width,u=We(We([],Ve(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}})),c=Be({startPos:[a,s],endPos:[a+l,s],data:u,labelFilter:function(t,e){return e<u.length-1},labelFormatter:function(t){var e=t.time;return i?i(e):tH(e,r)}},o);return c},e.prototype.renderAxis=function(t){void 0===t&&(t=this.space.axisBBox),"chart"===this.attributes.type&&this.axis.update(this.getAxisStyle(t))},e.prototype.renderController=function(t){void 0===t&&(t=this.space.controllerBBox);var e=this.attributes.type,n=this.states,r=n.state,i=n.speed,o=n.selectionType,a=n.chartType,s=Pz(this.attributes,"controller"),l=this,u=Be(Be(Be({},t),{iconSize:20,speed:i,state:r,selectionType:o,chartType:a,onChange:function(t,e){var n=e.value;switch(t){case"reset":l.internalReset();break;case"speed":l.handleSpeedChange(n);break;case"backward":l.internalBackward();break;case"playPause":"play"===n?l.internalPlay():l.internalPause();break;case"forward":l.internalForward();break;case"selectionType":l.handleSelectionTypeChange(n);break;case"chartType":l.handleChartTypeChange(n)}}}),s);"time"===e&&(u.functions=[["reset","speed"],["backward","playPause","forward"],["selectionType"]]),this.controller.update(u)},e.prototype.dispatchOnChange=function(t){var e=this.data,n=this.attributes.onChange,r=this.states,i=r.values,o=r.selectionType,a=Ve(i,2),s=a[0],l=a[1],u=l===1/0?e.at(-1).time:l;t&&function(t,e){if(Array.isArray(t)){if(!Array.isArray(e))return!1;if(t[0]===e[0]){if(t[1]===e[1])return!0;if(t[1]===1/0||e[1]===1/0)return!0}return!1}return!Array.isArray(e)&&t===e}(t,"range"===o?[s,u]:u)||null==n||n("range"===o?[s,u]:u)},e.prototype.internalReset=function(t){var e,n,r=this.states.selectionType;this.internalPause(),this.setBySliderValues("range"===r?[0,1]:[0,0]),this.renderController(),this.updateSelection(),t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onReset)||void 0===n||n.call(e),this.dispatchOnChange())},e.prototype.reset=function(){this.internalReset()},e.prototype.moveSelection=function(t,e){var n=this.data,r=n.length,i=this.states,o=i.values,a=i.selectionType,s=i.playMode,l=Ve(o,2),u=l[0],c=l[1],h=n.findIndex((function(t){return t.time===u})),d=n.findIndex((function(t){return t.time===c}));-1===d&&(d=r);var f,p="backward"===t?-1:1;"range"===a?"acc"===s?(f=[h,d+p],-1===p&&h===d&&(f=[h,r])):f=[h+p,d+p]:f=[h,d+p];var g=function(t){var e=Ve(t.sort((function(t,e){return t-e})),2),n=e[0],i=e[1],o=function(t){return oe(t,0,r)};return i>r?"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)]}(f);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}(Bz);function rH(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=Xj(r,!1),{width:a,height:s,containerStyle:l}=t,[u,c]=function(t){const{width:e,height:n,placement:r,graphCanvas:i}=t,[o,a]=i.getSize(),[s,l]=Qh(r);return[s*(o-e),l*(a-n)]}(t);return Object.assign(o.style,Object.assign({position:"absolute",left:u+"px",top:c+"px",width:a+"px",height:s+"px"},l)),null===(e=i.getContainer())||void 0===e||e.appendChild(o),o}(t);return[i,new hu({width:e,height:n,container:i,renderer:r||new Sp})]}class iH extends qj{constructor(e,n){super(e,Object.assign({},iH.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=Oe(t,[r,"id"]),o=Oe(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=Oe(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=Oe(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={},l=e=>Ut(t)?t(e):t,u={node:"circle",edge:"line",combo:"rect"},c={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"},h=(t,e)=>{t.forEach((t=>{const{id:n}=t,i=Oe(t,["data",l(t)]),o=(null==r?void 0:r.getElementType(e,t))||"circle",a=((t,e)=>null==r?void 0:r.getElementComputedStyle(t,e))(e,t),h=("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:c[o]||u[e],elementType:e,lineWidth:1,stroke:h,fill:h}))}))};switch(e){case"node":h(i,"node");break;case"edge":h(o,"edge");break;case"combo":h(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:l,containerStyle:u,className:c}=t,h=Fe(t,["width","height","nodeField","edgeField","comboField","trigger","position","container","containerStyle","className"]),d=this.getMarkerData(r,"node"),f=this.getMarkerData(i,"edge"),p=this.getMarkerData(o,"combo"),g=[...d,...p,...f],v=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:d.length},h,this.getEvents()),m=new wW({className:"legend",style:v});this.category=m;this.upsertCanvas().appendChild(m),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:l}=this.options,[u,c]=rH({width:r,height:i,graphCanvas:t,container:a,containerStyle:s,placement:o,className:"legend"});return this.container=u,l&&u.classList.add(l),this.canvas=c,this.canvas}destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}iH.defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16,width:240,height:160};class oH extends qj{constructor(t,e){super(t,Object.assign({},oH.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.shapes=new Map,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:l}=this.mask.style,[,,u,c]=this.maskBBox;let h=parseInt(o)+r,d=parseInt(a)+i,f=parseInt(s),p=parseInt(l);h<0&&(h=0),d<0&&(d=0),h+f>e&&(h=sH(e-f,0)),d+p>n&&(d=sH(n-p,0)),f<u&&(r>0?(h=sH(h-r,0),f=aH(f+r,e)):r<0&&(f=aH(f-r,e))),p<c&&(i>0?(d=sH(d-i,0),p=aH(p+i,n)):i<0&&(p=aH(p-i,n))),Object.assign(this.mask.style,{left:h+"px",top:d+"px",width:f+"px",height:p+"px"});const g=parseInt(o)-h,v=parseInt(a)-d;if(0===g&&0===v)return;const m=this.context.canvas.getCamera().getZoom()/this.canvas.getCamera().getZoom();this.context.graph.translateBy([g*m,v*m],!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=Re((()=>{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=ye((()=>{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_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_TRANSFORM,this.onTransform)}renderMinimap(){const t=this.getElements(),e=this.initCanvas();this.setShapes(e,t)}getElements(){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(yh(e),"node"))),edges:i.filter((e=>t(yh(e),"edge"))),combos:o.filter((e=>t(yh(e),"combo")))}}setShapes(t,e){const{nodes:n,edges:r,combos:i}=e,{shape:o}=this.options,{element:a}=this.context;if("key"===o){const e=new Set,o=n=>{const r=yh(n);e.add(r);const i=a.getElement(r);if(!i)return;const o=i.getShape("key"),s=this.shapes.get(r)||o.cloneNode();s.setPosition(o.getPosition()),i.style.zIndex&&(s.style.zIndex=i.style.zIndex),s.id=i.id,this.shapes.has(r)?Object.entries(o.attributes).forEach((([t,e])=>{s.style[t]!==e&&(s.style[t]=e)})):(t.appendChild(s),this.shapes.set(r,s))};return r.forEach(o),i.forEach(o),n.forEach(o),void this.shapes.forEach(((n,r)=>{e.has(r)||(t.removeChild(n),this.shapes.delete(r))}))}const s=(t,e)=>{const n=a.getElement(t).getPosition();return e.setPosition(n),e};t.removeChildren(),r.forEach((e=>t.appendChild(o(yh(e),"edge")))),i.forEach((e=>{t.appendChild(s(yh(e),o(yh(e),"combo")))})),n.forEach((e=>{t.appendChild(s(yh(e),o(yh(e),"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,l]=rH({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=l}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,l,u]=Uc(o),{min:c,max:h,center:d}=e.getBounds("elements"),f=(r-u-s)/(h[0]-c[0]),p=(i-a-l)/(h[1]-c[1]),g=Math.min(f,p),v=this.createLandmark(d,d,g);n.gotoLandmark(v,0)}get maskBBox(){const{canvas:t}=this.context,e=t.getSize(),n=t.getCanvasByViewport([0,0]),r=t.getCanvasByViewport(e),i=this.canvas.canvas2Viewport(rd(n)),o=this.canvas.canvas2Viewport(rd(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=aH(i+n,t),n=0),r<0&&(o=aH(o+r,e),r=0),n+i>t&&(i=sH(t-n,0)),r+o>e&&(o=sH(e-r,0)),[aH(n,t),aH(r,e),sH(i,0),sH(o,0)]}renderMask(){const{maskStyle:t}=this.options;this.mask||(this.mask=document.createElement("div"),this.mask.addEventListener("pointerdown",this.onMaskDragStart)),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;this.unbindEvents(),this.canvas.destroy(),null===(t=this.mask)||void 0===t||t.remove(),super.destroy()}}oH.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 aH=(t,e)=>Math.min(t,e),sH=(t,e)=>Math.max(t,e),lH={x1:0,y1:0,x2:0,y2:0,visibility:"hidden"};class uH extends qj{constructor(t,e){super(t,Object.assign({},uH.defaultOptions,e)),this.initSnapline=()=>{const t=this.context.canvas.getLayer("transient");this.horizontalLine||(this.horizontalLine=t.appendChild(new Vl({style:Object.assign(Object.assign({},lH),this.options.horizontalLineStyle)}))),this.verticalLine||(this.verticalLine=t.appendChild(new Vl({style:Object.assign(Object.assign({},lH),this.options.verticalLineStyle)})))},this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!0,this.autoSnapToLine=(t,e,n)=>ze(this,void 0,void 0,(function*(){const{verticalX:r,horizontalY:i}=n,{tolerance:o}=this.options,{min:[a,s],max:[l,u],center:[c,h]}=e;let d=0,f=0;null!==r&&(cH(l,r)<o&&(d=r-l),cH(a,r)<o&&(d=r-a),cH(c,r)<o&&(d=r-c),0!==d&&(this.isVerticalSticking=!0)),null!==i&&(cH(u,i)<o&&(f=i-u),cH(s,i)<o&&(f=i-s),cH(h,i)<o&&(f=i-h),0!==f&&(this.isHorizontalSticking=!0)),0===d&&0===f||(yield this.context.graph.translateElementBy({[t]:[d,f]},!1))})),this.enableSnap=t=>{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:[l,u]}=e;let c=null,h=null,d=null,f=null,p=null,g=null;return this.getNodes().some((e=>{if(Ne(t.id,e.id))return!1;const v=hH(e,r).getRenderBounds(),{min:[m,y],max:[b,x],center:[E,w]}=v;return null===c&&(cH(E,l)<n?c=E:cH(m,i)<n||cH(m,a)<n?c=m:(cH(b,a)<n||cH(b,i)<n)&&(c=b),null!==c&&(h=Math.min(y,o),d=Math.max(x,s))),null===f&&(cH(w,u)<n?f=w:cH(y,o)<n||cH(y,s)<n?f=y:(cH(x,s)<n||cH(x,o)<n)&&(f=x),null!==f&&(p=Math.min(m,i),g=Math.max(b,a))),null!==c&&null!==f})),{verticalX:c,verticalMinY:h,verticalMaxY:d,horizontalY:f,horizontalMinX:p,horizontalMaxX:g}},this.onDragStart=()=>{this.initSnapline()},this.onDrag=t=>ze(this,void 0,void 0,(function*(){const{target:e}=t;if(this.options.autoSnap){if(!this.enableSnap(t))return}const n=hH(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"hidden"!==Oe(t,["style","visibility"])&&(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||lH.lineWidth||1)/this.context.graph.getZoom()}updateSnapline(t){const{verticalX:e,verticalMinY:n,verticalMaxY:r,horizontalY:i,horizontalMinX:o,horizontalMaxX:a}=t,[s,l]=this.context.canvas.getSize(),{offset:u}=this.options;null!==i?Object.assign(this.horizontalLine.style,{x1:u===1/0?0:o-u,y1:i,x2:u===1/0?s:a+u,y2:i,visibility:"visible",lineWidth:this.getLineWidth("horizontal")}):this.horizontalLine.style.visibility="hidden",null!==e?Object.assign(this.verticalLine.style,{x1:e,y1:u===1/0?0:n-u,x2:e,y2:u===1/0?l:r+u,visibility:"visible",lineWidth:this.getLineWidth("vertical")}):this.verticalLine.style.visibility="hidden"}getDelta(t){const e=this.context.graph.getZoom();return Fh([t.dx,t.dy],e)}bindEvents(){return ze(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()}}uH.defaultOptions={tolerance:5,offset:20,autoSnap:!0,shape:"key",verticalLineStyle:{stroke:"#1783FF"},horizontalLineStyle:{stroke:"#1783FF"},filter:()=>!0};const cH=(t,e)=>Math.abs(t-e),hH=(t,e)=>"function"==typeof e?e(t):t.getShape(e),dH=["timestamp","time","date","datetime"];class fH extends qj{get padding(){return Uc(this.options.padding)}constructor(t,e){super(t,Object.assign({},fH.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=pH(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:l,mode:u}=e,c=Fe(e,["onChange","timebarType","data","x","y","width","height","mode"]),h=t.getSize(),[d]=this.padding;this.upsertCanvas().ready.then((()=>{var t;const e=Object.assign(Object.assign({x:h[0]/2-s/2,y:d,onChange:t=>{const e=(Yt(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)}},c),{data:i.map((t=>ae(t)?{time:t,value:0}:t)),width:s,height:l,type:r});this.timebar?this.timebar.update(e):(this.timebar=new nH({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,l]=rH({width:i,height:e+o+a,graphCanvas:r,className:"timebar",placement:n});return this.container=s,t&&s.classList.add(t),this.canvas=l,this.canvas}filterElements(t){return ze(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=pH(this.originalData);n.forEach((e=>{const n=`${e}s`;a[n]=(this.originalData[n]||[]).filter((e=>{const n=r(e);return!!gH(n,t)}))}));const s=[...a.nodes,...a.combos].map((t=>yh(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=yh(e),a=r(e);gH(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()}}fH.defaultOptions={position:"bottom",enable:!0,timebarType:"time",className:"g6-timebar",width:450,height:60,zIndex:3,elementTypes:["node"],padding:10,mode:"modify",getTime:t=>vH(t,dH,void 0),loop:!1};const pH=t=>{const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e],edges:[...n],combos:[...r]}},gH=(t,e)=>{if(ae(e))return t===e;const[n,r]=e;return t>=n&&t<=r},vH=(t,e,n)=>{var r;for(let n=0;n<e.length;n++){const i=e[n],o=null===(r=t.data)||void 0===r?void 0:r[i];if(o)return o}return n};class mH extends qj{constructor(t,e){super(t,Object.assign({},mH.defaultOptions,e)),this.$element=Xj("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),Kj("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),Kj("g6-toolbar-svgicon","div",{display:"none"},'\n <svg>\n <symbol id="zoom-in" viewBox="64 64 896 896">\n <path d="M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="zoom-out" viewBox="64 64 896 896">\n <path d="M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="edit" viewBox="64 64 896 896">\n <path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>\n </symbol>\n <symbol id="delete" viewBox="64 64 896 896">\n <path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"></path>\n </symbol>\n <symbol id="redo" viewBox="64 64 896 896">\n <path d="M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"></path>\n </symbol>\n <symbol id="undo" viewBox="64 64 896 896">\n <path d="M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z"></path>\n </symbol>\n <symbol id="export" viewBox="64 64 896 896">\n <path d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"></path>\n </symbol>\n <symbol id="auto-fit" viewBox="64 64 896 896">\n <path d="M952 474H829.8C812.5 327.6 696.4 211.5 550 194.2V72c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v122.2C327.6 211.5 211.5 327.6 194.2 474H72c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h122.2C211.5 696.4 327.6 812.5 474 829.8V952c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V829.8C696.4 812.5 812.5 696.4 829.8 550H952c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM512 756c-134.8 0-244-109.2-244-244s109.2-244 244-244 244 109.2 244 244-109.2 244-244 244z"></path>\n <path d="M512 392c-32.1 0-62.1 12.4-84.8 35.2-22.7 22.7-35.2 52.7-35.2 84.8s12.5 62.1 35.2 84.8C449.9 619.4 480 632 512 632s62.1-12.5 84.8-35.2C619.4 574.1 632 544 632 512s-12.5-62.1-35.2-84.8A118.57 118.57 0 00512 392z"></path>\n </symbol>\n <symbol id="reset" viewBox="64 64 896 896">\n <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path>\n </symbol>\n <symbol id="exit-fullscreen" viewBox="0 0 1024 1024">\n <path d="M418.13333333 361.43786666c0 0.2048-0.13653333 0.4096-0.13653334 0.68266667C417.99679999 362.32533333 418.13333333 362.53013333 418.13333333 362.73493333 418.13333333 371.54133333 414.44693333 379.392 408.78079999 385.39946666 408.43946666 385.7408 408.30293333 386.21866666 408.02986666 386.49173333c-1.09226667 1.09226667-2.59413333 1.77493333-3.82293333 2.73066667C398.40426666 393.65973333 391.64586666 396.8 383.93173333 396.8 383.72693333 396.8 383.59039999 396.73173333 383.38559999 396.73173333S382.97599999 396.8 382.77119999 396.8L112.29866666 396.8C92.50133333 396.8 76.79999999 381.50826666 76.79999999 362.66666666 76.66346666 343.89333333 92.63786666 328.53333333 112.16213333 328.53333333l189.44 0L87.44959999 114.51733333C73.59146666 100.59093333 73.25013333 78.5408 86.63039999 65.29706666c13.17546667-13.44853333 35.36213333-12.97066667 49.152 0.88746667l214.08426667 214.08426667L349.86666666 90.89706666C349.79839999 71.23626666 365.22666666 55.46666666 383.99999999 55.46666666 402.77333333 55.33013333 418.13333333 71.30453333 418.13333333 90.8288L418.13333333 361.43786666zM928.90453333 328.53333333l-189.44 0 214.15253333-214.08426667c13.85813333-13.9264 14.19946667-35.90826667 0.88746667-49.22026666-13.17546667-13.44853333-35.36213333-12.97066667-49.152 0.88746666l-214.08426667 214.08426667L691.26826666 90.89706666C691.26826666 71.23626666 675.83999999 55.46666666 657.06666666 55.46666666 638.29333333 55.33013333 622.93333333 71.30453333 622.93333333 90.8288l0 270.60906666c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 362.32533333 622.93333333 362.53013333 622.93333333 362.73493333 622.93333333 371.54133333 626.61973333 379.392 632.28586666 385.39946666c0.34133333 0.34133333 0.47786667 0.8192 0.8192 1.09226667 1.09226667 1.09226667 2.59413333 1.77493333 3.8912 2.73066667C642.66239999 393.65973333 649.42079999 396.8 657.13493333 396.8c0.2048 0 0.34133333-0.06826667 0.54613333-0.06826667S658.09066666 396.8 658.29546666 396.8l270.5408 0C948.56533333 396.8 964.26666666 381.50826666 964.26666666 362.66666666 964.40319999 343.89333333 948.42879999 328.53333333 928.90453333 328.53333333zM418.13333333 635.73333333c0-8.8064-3.6864-16.5888-9.35253334-22.66453333C408.43946666 612.72746666 408.30293333 612.2496 408.02986666 611.90826666 406.86933333 610.88426666 405.43573333 610.2016 404.20693333 609.24586666 398.47253333 604.80853333 391.64586666 601.6 383.93173333 601.6 383.72693333 601.6 383.59039999 601.73653333 383.38559999 601.73653333S382.97599999 601.6 382.77119999 601.6L112.29866666 601.6C92.50133333 601.6 76.79999999 616.96 76.79999999 635.73333333 76.66346666 654.50666666 92.63786666 669.86666666 112.16213333 669.86666666l189.44 0-214.15253334 214.15253334c-13.85813333 13.85813333-14.19946667 35.84-0.88746666 49.22026666 13.17546667 13.44853333 35.36213333 12.9024 49.152-0.95573333l214.08426666-214.08426667 0 189.37173334c0 19.59253333 15.42826667 35.49866667 34.2016 35.36213333C402.77333333 943.2064 418.13333333 927.232 418.13333333 907.5712L418.13333333 637.09866666c0-0.27306667-0.13653333-0.47786667-0.13653334-0.68266666C417.99679999 636.14293333 418.13333333 635.93813333 418.13333333 635.73333333zM739.46453333 669.86666666l189.44 0c19.456 0 35.49866667-15.36 35.36213333-34.13333333C964.26666666 616.96 948.56533333 601.6 928.76799999 601.6L658.29546666 601.6C658.09066666 601.6 657.88586666 601.73653333 657.68106666 601.73653333S657.33973333 601.6 657.13493333 601.6C649.42079999 601.6 642.59413333 604.80853333 636.85973333 609.24586666 635.63093333 610.2016 634.19733333 610.88426666 633.03679999 611.90826666 632.76373333 612.2496 632.62719999 612.72746666 632.28586666 613.0688 626.61973333 619.14453333 622.93333333 626.92693333 622.93333333 635.73333333c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 636.6208 622.93333333 636.8256 622.93333333 637.09866666l0 270.5408C622.93333333 927.232 638.29333333 943.2064 657.06666666 942.93333333c18.77333333 0.13653333 34.2016-15.70133333 34.2016-35.36213333l0-189.37173334 214.08426667 214.08426667c13.78986667 13.85813333 35.90826667 14.40426667 49.152 0.95573333 13.312-13.312 12.97066667-35.36213333-0.88746667-49.22026666L739.46453333 669.86666666z" ></path></symbol>\n <symbol id="request-fullscreen" viewBox="0 0 1024 1024">\n <path d="M69.818182 87.598545v273.128728a34.909091 34.909091 0 0 0 69.818182 0V163.653818l221.928727 222.021818a33.512727 33.512727 0 0 0 47.383273-47.383272L186.926545 116.363636h197.073455a34.909091 34.909091 0 0 0 0-69.818181H110.871273C85.364364 46.545455 69.818182 59.671273 69.818182 87.598545zM938.542545 46.545455H665.413818a34.909091 34.909091 0 0 0 0 69.818181h197.073455L640.465455 338.292364a33.512727 33.512727 0 0 0 47.383272 47.383272l221.928728-222.021818v197.073455a34.909091 34.909091 0 0 0 69.818181 0V87.598545c0-27.927273-15.453091-41.053091-40.96-41.05309z m-827.671272 907.636363h273.128727a34.909091 34.909091 0 0 0 0-69.818182H186.926545l222.021819-221.928727a33.512727 33.512727 0 0 0-47.383273-47.383273L139.636364 837.073455V640a34.909091 34.909091 0 0 0-69.818182 0v273.128727c0 27.927273 15.546182 41.053091 41.053091 41.053091z m868.724363-41.053091V640a34.909091 34.909091 0 0 0-69.818181 0v197.073455L687.941818 615.051636a33.512727 33.512727 0 0 0-47.383273 47.383273L862.487273 884.363636H665.413818a34.909091 34.909091 0 0 0 0 69.818182h273.128727c25.6 0 41.053091-13.125818 41.053091-41.053091z" ></path></symbol>\n </svg>\n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(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 ze(this,void 0,void 0,(function*(){return(yield this.options.getItems()).map((t=>{var e;return`\n <div class="g6-toolbar-item" value="${t.value}" title="${null!==(e=t.title)&&void 0!==e?e:""}">\n <svg aria-hidden="true" focusable="false">\n <use xlink:href="#${t.id}"></use>\n </svg>\n </div>`})).join("")}))}}mH.defaultOptions={position:"top-left"};class yH extends qj{constructor(t,e){super(t,Object.assign({},yH.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.onPointerEnter=t=>{this.show(t)},this.showById=t=>ze(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=>ze(this,void 0,void 0,(function*(){var e,n;const{client:r,target:{id:i}}=t;if(Ig(t.target))return;const o=this.context.graph.getElementType(i),{getContent:a,title:s}=this.options,l=this.getElementData(i,o);if(!this.tooltipElement||!this.isEnable(t,l))return;let u,c,h={};if(a){if(h.content=yield a(t,l),!h.content)return}else{const t=this.context.graph.getElementRenderStyle(i),e="node"===o?t.fill:t.stroke;h={title:s||o,data:l.map((t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:e})))}}if(this.currentTarget=i,r)u=r.x,c=r.y;else{const t=Oe(l,"0.style",{x:0,y:0});u=t.x,c=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:u,y:c,style:{".tooltip":{visibility:"visible"}}}),h))})),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 CW({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:pointerenter":this.onPointerEnter,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerenter":this.onPointerEnter,"edge:pointermove":this.onPointerMove,"combo:pointerenter":this.onPointerEnter,"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:l={x:-i,y:-r},title:u,offset:c}=this.options,[h,d]=e,[f,p]=t.getSize();return{x:h,y:d,container:l,title:u,bounding:{x:0,y:0,width:f,height:p},position:a,enterable:s,offset:c,style:o}}destroy(){var t;this.unbindEvents(),this.tooltipElement&&(null===(t=this.container)||void 0===t||t.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}let bH;function xH(t,e){bH||(bH=document.createElement("canvas")),bH.width=t,bH.height=e;return bH.getContext("2d").clearRect(0,0,t,e),bH}yH.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};class EH extends qj{constructor(t,e){super(t,Object.assign({},EH.defaultOptions,e)),this.$element=Xj("watermark");this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(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=Fe(n,["width","height","text","imageURL"]);Object.keys(s).forEach((e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])}));const l=a?yield function(t,e,n,r){return ze(this,void 0,void 0,(function*(){const i=xH(t,e),o=i.getContext("2d"),{rotate:a,opacity:s}=r;a&&o.rotate(a),s&&(o.globalAlpha=s);const l=new Image;return l.crossOrigin="anonymous",l.src=n,new Promise((n=>{l.onload=function(){const r=t>l.width?(t-l.width)/2:0,a=e>l.height?(e-l.height)/2:0;o.drawImage(l,0,0,l.width,l.height,r,a,t-2*r,e-2*a),n(i.toDataURL())}}))}))}(r,i,a,s):yield function(t,e,n,r){return ze(this,void 0,void 0,(function*(){const i=xH(t,e),o=i.getContext("2d"),{rotate:a,opacity:s,textFill:l,textFontSize:u,textFontFamily:c,textFontVariant:h,textFontWeight:d,textAlign:f,textBaseline:p}=r;return o.textAlign=f,o.textBaseline=p,o.translate(t/2,e/2),o.font=`${u}px ${c} ${h} ${d}`,a&&o.rotate(a),s&&(o.globalAlpha=s),l&&(o.fillStyle=l,o.fillText(`${n}`,0,0)),i.toDataURL()}))}(r,i,o,s);this.$element.style.backgroundImage=`url(${l})`}))}destroy(){super.destroy(),this.$element.remove()}}EH.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const wH=["#7E92B5","#F4664A","#FFBE3A"],kH={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},MH={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function SH(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeHaloStrokeOpacityActive:a=.15,nodeHaloStrokeOpacitySelected:s=.25,nodeOpacityDisabled:l=.06,nodeIconOpacityInactive:u=.85,nodeOpacityInactive:c=.25,nodeBadgePalette:h=wH,nodePaletteOptions:d=kH,edgeColor:f,edgeColorDisabled:p,edgePaletteOptions:g=MH,comboColor:v,comboColorDisabled:m,comboStroke:y,comboStrokeDisabled:b,edgeColorInactive:x}=t;return{background:e,node:{palette:d,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:h,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:c,donutOpacity:c,fillOpacity:c,iconOpacity:u,labelFill:n,labelFillOpacity:c,strokeOpacity:c},disabled:{badgeBackgroundOpacity:.25,donutOpacity:l,fill:i,fillOpacity:l,iconFill:i,iconOpacity:.25,labelFill:n,labelFillOpacity:.25,strokeOpacity:l}},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:f,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,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:f,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:x,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:p,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:v,halo:!1,haloLineWidth:12,haloStroke:y,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:y},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:m,fillOpacity:.25,labelOpacity:.25,stroke:b,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 NH=SH({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"}),OH=SH({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 TH extends Rh{beforeDraw(t,e){return t}afterLayout(t,e){}}function CH(t,e,n,r,i){const o=yh(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 AH(t,e){return Object.keys(t).every((n=>t[n]===e[n]))}const PH=(t,e,n,r)=>{const i=`${n}s`,o=yh(r);t.add[i].has(o)||t.update[i].has(o)||t[e][i].set(yh(r),r)};const RH=new WeakMap;const DH=(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(!DH(r,o,n-1))return!1}else if(r!==o)return!1}return!0};function LH(t,e,n,r=!1){const i=Mc[t][e];!r&&i?i!==n&&Tc(`The extension ${e} of ${t} has been registered before.`):Object.assign(Mc[t],{[e]:n})}
71
+ */const wj=Symbol("Comlink.proxy"),kj=Symbol("Comlink.endpoint"),Mj=Symbol("Comlink.releaseProxy"),Sj=Symbol("Comlink.finalizer"),Nj=Symbol("Comlink.thrown"),Oj=t=>"object"==typeof t&&null!==t||"function"==typeof t,Tj=new Map([["proxy",{canHandle:t=>Oj(t)&&t[wj],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Cj(t,e),[n,[n]]},deserialize:t=>(t.start(),Pj(t))}],["throw",{canHandle:t=>Oj(t)&&Nj 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 Cj(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),l=(i.data.argumentList||[]).map(zj);let u;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":u=n;break;case"SET":e[s.slice(-1)[0]]=zj(i.data.value),u=!0;break;case"APPLY":u=n.apply(e,l);break;case"CONSTRUCT":u=function(t){return Object.assign(t,{[wj]:!0})}(new n(...l));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;Cj(t,n),u=function(t,e){return Bj.set(t,e),t}(e,[e])}break;case"RELEASE":u=void 0;break;default:return}}catch(t){u={value:t,[Nj]:0}}Promise.resolve(u).catch((t=>({value:t,[Nj]:0}))).then((n=>{const[i,s]=Fj(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),Aj(e),Sj in t&&"function"==typeof t[Sj]&&t[Sj]())})).catch((t=>{const[n,r]=Fj({value:new TypeError("Unserializable return value"),[Nj]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function Aj(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function Pj(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)}})),Ij(t,n,[],e)}function Rj(t){if(t)throw new Error("Proxy has been released and is not useable")}function Dj(t){return Gj(t,new Map,{type:"RELEASE"}).then((()=>{Aj(t)}))}const Lj=new WeakMap,_j="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(Lj.get(t)||0)-1;Lj.set(t,e),0===e&&Dj(t)}));function Ij(t,e,n=[],r=function(){}){let i=!1;const o=new Proxy(r,{get(r,a){if(Rj(i),a===Mj)return()=>{!function(t){_j&&_j.unregister(t)}(o),Dj(t),e.clear(),i=!0};if("then"===a){if(0===n.length)return{then:()=>o};const r=Gj(t,e,{type:"GET",path:n.map((t=>t.toString()))}).then(zj);return r.then.bind(r)}return Ij(t,e,[...n,a])},set(r,o,a){Rj(i);const[s,l]=Fj(a);return Gj(t,e,{type:"SET",path:[...n,o].map((t=>t.toString())),value:s},l).then(zj)},apply(r,o,a){Rj(i);const s=n[n.length-1];if(s===kj)return Gj(t,e,{type:"ENDPOINT"}).then(zj);if("bind"===s)return Ij(t,e,n.slice(0,-1));const[l,u]=jj(a);return Gj(t,e,{type:"APPLY",path:n.map((t=>t.toString())),argumentList:l},u).then(zj)},construct(r,o){Rj(i);const[a,s]=jj(o);return Gj(t,e,{type:"CONSTRUCT",path:n.map((t=>t.toString())),argumentList:a},s).then(zj)}});return function(t,e){const n=(Lj.get(e)||0)+1;Lj.set(e,n),_j&&_j.register(t,e,t)}(o,t),o}function jj(t){const e=t.map(Fj);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const Bj=new WeakMap;function Fj(t){for(const[e,n]of Tj)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},Bj.get(t)||[]]}function zj(t){switch(t.type){case"HANDLER":return Tj.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Gj(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 Vj extends Vg{constructor(t,e,n){super(),this.graph=t,this.layout=e,this.options=n,this.spawnWorker()}spawnWorker(){this.proxy=Pj(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())}execute(){var t;return ze(this,void 0,void 0,(function*(){if(this.running)return this;this.running=!0;const e=this.layout.options,{onTick:n}=e,r=Fe(e,["onTick"]),i={};Object.keys(r).forEach((t=>{Ut(r[t])||(i[t]=r[t])}));const o={layout:{id:this.layout.id,options:i,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},a=new Float32Array([0]),[s]=yield this.proxy.calculateLayout(o,[a]);return s}))}stop(){return this.running=!1,this.proxy.stopLayout(),this}kill(){this.proxy[Mj]()}isRunning(){return this.running}}class Wj extends qg{constructor(){super(...arguments),this.id="fishbone"}getRoot(){const t=this.context.model.getRootsData();if(!(Se(t)||t.length>2))return t[0]}formatSize(t){const e="function"==typeof t?t:()=>t;return t=>Dd(e(t))}doLayout(t,e){const{hGap:n,getRibSep:r,vGap:i,nodeSize:o,height:a}=e,{model:s}=this.context,l=this.formatSize(o);let u=l(t)[0]+r(t);const c=(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=c(n,e)}))})),e},h=t=>{if(1===t.depth)return u;const e=s.getParentData(t.id,"tree");if($j(t)){const r=s.getParentData(e.id,"tree"),o=p(t)-p(r);return h(e)+o*n/i}{const n=(e.children||[]).indexOf(t.id),r=s.getNodeData((e.children||[]).slice(n));return d(e)-r.reduce(((t,e)=>t+c(e)),0)-l(e)[0]/2}},d=xe((t=>{if(Uj(t))return l(t)[0]/2;const e=s.getParentData(t.id,"tree");if($j(t))return h(t)+c(t)+l(t)[0]/2;{const r=p(t)-p(e),o=n/i;return h(t)+r*o}}),(t=>t.id)),f=t=>p(s.getParentData(t,"tree")),p=xe((t=>{if(Uj(t))return a/2;if($j(t)){const e=s.getParentData(t.id,"tree"),n=e.children.indexOf(t.id);if(0===n)return f(e.id)+i;const r=s.getNodeLikeDatum(e.children[n-1]);if(Se(r.children))return p(r)+i;const o=s.getDescendantsData(r.id);return Math.max(...o.map((t=>$j(t)?f(t.id):p(t))))+i}{if(Se(t.children))return f(t.id)+i;const e=s.getNodeLikeDatum(t.children.slice(-1)[0]);if(Se(e.children))return p(e)+i;const n=s.getDescendantsData(t.id).slice(-1)[0];return($j(n)?f(n.id):p(n))+i}}),(t=>t.id));let g=0;const v={nodes:[],edges:[]},m=t=>{var e;null===(e=t.children)||void 0===e||e.forEach((t=>m(s.getNodeLikeDatum(t))));const n=p(t),i=d(t);if(v.nodes.push({id:t.id,x:i,y:n}),Uj(t))return;const o=s.getRelatedEdgesData(t.id,"in")[0],a=[h(t),$j(t)?n:f(t.id)];v.edges.push({id:yh(o),controlPoints:[a],relatedNodeId:t.id}),g=Math.max(g,i+r(t)),1===t.depth&&(u=g)};return m(t),v}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(Se(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 ze(this,void 0,void 0,(function*(){const n=Object.assign(Object.assign(Object.assign({},Wj.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:l}=this.context,u=[],c=[];return s.nodes.forEach((t=>{const{id:e,x:n,y:r}=t,i=l.getNodeLikeDatum(e);u.push(Hj(i,{x:n,y:r}))})),s.edges.forEach((t=>{const{id:e,controlPoints:n}=t,r=l.getEdgeDatum(e);c.push(Hj(r,{controlPoints:n}))})),{nodes:u,edges:c}}))}}Wj.defaultOptions={direction:"RL",getRibSep:()=>60};const Hj=(t,e)=>Object.assign(Object.assign({},t),{style:Object.assign(Object.assign({},t.style||{}),e)}),Uj=t=>0===t.depth,$j=t=>(t.depth||(t.depth=0))%2==0;class Yj extends qg{constructor(){super(...arguments),this.id="snake"}formatSize(t,e){const n="function"==typeof e?e:()=>e;return t.reduce(((t,e)=>{const[r,i]=Dd(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 l=e.filter((t=>0===r[t.id])),u=e.filter((t=>0===i[t.id]));if(1!==l.length||1!==u.length)return!1;return e.filter((t=>1===r[t.id]&&1===i[t.id])).length===e.length-2}execute(t,e){return ze(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:l,clockwise:u,width:c,height:h}=Object.assign({},Yj.defaultOptions,this.options,e),[d,f,p,g]=Uc(i),v=this.formatSize(t.nodes||[],r),m=Math.ceil((t.nodes||[]).length/a);let y=s||(c-g-f-a*v[0])/(a-1),b=l||(h-d-p-m*v[1])/(m-1);(b===1/0||b<0)&&(b=0),(y===1/0||y<0)&&(y=0);const x=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),E=(x||[]).map(((t,e)=>{const n=Math.floor(e/a),r=e%a,i=g+(u?n%2==0?r:a-1-r:n%2==0?a-1-r:r)*(v[0]+y)+v[0]/2,o=d+n*(v[1]+b)+v[1]/2;return{id:t.id,style:{x:i,y:o}}}));return{nodes:E}}))}}Yj.defaultOptions={padding:0,cols:5,clockwise:!0};class qj extends Rh{}function Xj(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 Kj(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 Zj extends qj{constructor(t,e){super(t,Object.assign({},Zj.defaultOptions,e)),this.$element=Xj("background");this.context.canvas.getContainer().prepend(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(this,void 0,void 0,(function*(){e.update.call(this,t),Object.assign(this.$element.style,Pe(this.options,["key","type"]))}))}destroy(){super.destroy(),this.$element.remove()}}function Qj(t,e,n,r,i,o){const a=n-t,s=r-e;let l=i-t,u=o-e,c=l*a+u*s,h=0;c<=0?h=0:(l=a-l,u=s-u,c=l*a+u*s,h=c<=0?0:c*c/(a*a+s*s));const d=l*l+u*u-h;return d<0?0:d}function Jj(t,e,n,r){return(t-n)*(t-n)+(e-r)*(e-r)}function tB(t,e,n,r,i){return Jj(t,e,n,r)<i*i}function eB(t){const e=Math.min(t.x1,t.x2),n=Math.max(t.x1,t.x2),r=Math.min(t.y1,t.y2),i=Math.max(t.y1,t.y2);return{x:e,y:r,x2:n,y2:i,width:n-e,height:i-r}}Zj.defaultOptions={transition:"background 0.5s",backgroundSize:"cover",zIndex:"-1"};class nB{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}draw(t){t.moveTo(this.x1,this.y1),t.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(t){return new nB(t.x1,t.y1,t.x2,t.y2)}cuts(t,e){if(this.y1===this.y2)return!1;if(e<this.y1&&e<=this.y2||e>this.y1&&e>=this.y2)return!1;if(t>this.x1&&t>=this.x2)return!1;if(t<this.x1&&t<=this.x2)return!0;return t<=this.x1+(e-this.y1)*(this.x2-this.x1)/(this.y2-this.y1)}distSquare(t,e){return Qj(this.x1,this.y1,this.x2,this.y2,t,e)}ptClose(t,e,n){if(this.x1<this.x2){if(t<this.x1-n||t>this.x2+n)return!1}else if(t<this.x2-n||t>this.x1+n)return!1;if(this.y1<this.y2){if(e<this.y1-n||e>this.y2+n)return!1}else if(e<this.y2-n||e>this.y1+n)return!1;return!0}}var rB,iB;!function(t){t[t.POINT=1]="POINT",t[t.PARALLEL=2]="PARALLEL",t[t.COINCIDENT=3]="COINCIDENT",t[t.NONE=4]="NONE"}(rB||(rB={}));class oB{constructor(t,e=0,n=0){this.state=t,this.x=e,this.y=n}}function aB(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 oB(rB.POINT,t.x1+e*(t.x2-t.x1),t.y1+e*(t.y2-t.y1)):new oB(rB.NONE)}return new oB(0===n||0===r?rB.COINCIDENT:rB.PARALLEL)}function sB(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 lB(t,e,n){const r=new Set;return t.width<=0?(r.add(iB.LEFT),r.add(iB.RIGHT)):e<t.x?r.add(iB.LEFT):e>t.x+t.width&&r.add(iB.RIGHT),t.height<=0?(r.add(iB.TOP),r.add(iB.BOTTOM)):n<t.y?r.add(iB.TOP):n>t.y+t.height&&r.add(iB.BOTTOM),r}function uB(t,e){let n=e.x1,r=e.y1;const i=e.x2,o=e.y2,a=Array.from(lB(t,i,o));if(0===a.length)return!0;let s=lB(t,n,r);for(;0!==s.size;){for(const t of a)if(s.has(t))return!1;if(s.has(iB.RIGHT)||s.has(iB.LEFT)){let e=t.x;s.has(iB.RIGHT)&&(e+=t.width),r+=(e-n)*(o-r)/(i-n),n=e}else{let e=t.y;s.has(iB.BOTTOM)&&(e+=t.height),n+=(e-r)*(i-n)/(o-r),r=e}s=lB(t,n,r)}return!0}function cB(t,e){let n=Number.POSITIVE_INFINITY,r=0;function i(t,i,o,a){let s=sB(e,new nB(t,i,o,a));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s<n&&(n=s))}return i(t.x,t.y,t.x2,t.y),i(t.x,t.y,t.x,t.y2),r>1?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 hB(t,e){let n=0;const r=aB(t,new nB(e.x,e.y,e.x2,e.y));n+=r.state===rB.POINT?1:0;const i=aB(t,new nB(e.x,e.y,e.x,e.y2));n+=i.state===rB.POINT?1:0;const o=aB(t,new nB(e.x,e.y2,e.x2,e.y2));n+=o.state===rB.POINT?1:0;const a=aB(t,new nB(e.x2,e.y,e.x2,e.y2));return n+=a.state===rB.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"}(iB||(iB={}));class dB{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 dB(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 dB(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.x2&&t.y<this.y2)}distSquare(t,e){if(this.containsPt(t,e))return 0;const n=lB(this,t,e);return n.has(iB.TOP)?n.has(iB.LEFT)?Jj(t,e,this.x,this.y):n.has(iB.RIGHT)?Jj(t,e,this.x2,this.y):(this.y-e)*(this.y-e):n.has(iB.BOTTOM)?n.has(iB.LEFT)?Jj(t,e,this.x,this.y2):n.has(iB.RIGHT)?Jj(t,e,this.x2,this.y2):(e-this.y2)*(e-this.y2):n.has(iB.LEFT)?(this.x-t)*(this.x-t):n.has(iB.RIGHT)?(t-this.x2)*(t-this.x2):0}}class fB{constructor(t,e,n){this.cx=t,this.cy=e,this.radius=n}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return 2*this.radius}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return 2*this.radius}static from(t){return new fB(t.cx,t.cy,t.radius)}containsPt(t,e){return Jj(this.cx,this.cy,t,e)<this.radius*this.radius}distSquare(t,e){const n=Jj(this.cx,this.cy,t,e);if(n<this.radius*this.radius)return 0;const r=Math.sqrt(n)-this.radius;return r*r}draw(t){t.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,2*Math.PI)}}class pB{constructor(t,e=0,n=0,r=0,i=0,o=10,a=10,s=new Float32Array(Math.max(0,o*a)).fill(0)){this.pixelGroup=t,this.i=e,this.j=n,this.pixelX=r,this.pixelY=i,this.width=o,this.height=a,this.area=s}createSub(t,e){return new pB(this.pixelGroup,t.x,t.y,e.x,e.y,t.width,t.height)}static fromPixelRegion(t,e){return new pB(e,0,0,t.x,t.y,Math.ceil(t.width/e),Math.ceil(t.height/e))}copy(t,e){return new pB(this.pixelGroup,this.scaleX(e.x),this.scaleY(e.y),e.x,e.y,t.width,t.height,t.area)}boundX(t){return t<this.i?this.i:t>=this.width?this.width-1:t}boundY(t){return t<this.j?this.j: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 dB(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 dB(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 l=o;l<s;l++){const o=(l-t.j)*r,s=l*n;for(let n=i;n<a;n++){const r=t.area[n-t.i+o];0!==r&&(this.area[n+s]+=e*r)}}}fill(t){this.area.fill(t)}fillArea(t,e){const n=t.x+t.y*this.width;for(let r=0;r<t.height;r++){const i=n+r*this.width;this.area.fill(e,i,i+t.width)}}fillHorizontalLine(t,e,n,r){const i=t+e*this.width;this.area.fill(r,i,i+n)}fillVerticalLine(t,e,n,r){const i=t+e*this.width;for(let t=0;t<n;t++)this.area[i+t*this.width]=r}clear(){this.area.fill(0)}toString(){let t="";for(let e=0;e<this.height;e++){const n=e*this.width;for(let e=0;e<this.width;e++){t+=this.area[n+e].toFixed(1).padStart(6),t+=" "}t+="\n"}return t}draw(t,e=!0){if(this.width<=0||this.height<=0)return;t.save(),e&&t.translate(this.pixelX,this.pixelY);const n=this.area.reduce(((t,e)=>Math.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;e<this.width;e++)for(let n=0;n<this.height;n++){const r=this.area[e+n*this.width];t.fillStyle=`rgba(0, 0, 0, ${i(r)})`,t.fillRect(e,n,1,1)}t.restore()}drawThreshold(t,e,n=!0){if(!(this.width<=0||this.height<=0)){t.save(),n&&t.translate(this.pixelX,this.pixelY),t.scale(this.pixelGroup,this.pixelGroup);for(let n=0;n<this.width;n++)for(let r=0;r<this.height;r++){const i=this.area[n+r*this.width];t.fillStyle=i>e?"black":"white",t.fillRect(n,r,1,1)}t.restore()}}}function gB(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 vB(t,e,n){return mB(Object.assign(eB(t),{distSquare:(e,n)=>Qj(t.x1,t.y1,t.x2,t.y2,e,n)}),e,n)}function mB(t,e,n){const r=gB(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;o<t.height;o++)for(let a=0;a<t.width;a++){const s=r(e.invertScaleX(t.i+a),e.invertScaleY(t.j+o));if(0!==s){if(s<i){const e=n-Math.sqrt(s);t.set(a,o,e*e)}}else t.set(a,o,i)}}(o,e,n,((e,n)=>t.distSquare(e,n))),o}function yB(t,e){return{x:t,y:e}}function bB(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=yB(e.cx,e.cy),a=function(t,e,n){let r=Number.POSITIVE_INFINITY;return e.reduce(((e,i)=>{const o=Jj(t.x,t.y,i.cx,i.cy);if(o>r)return e;const a=new nB(t.x,t.y,i.cx,i.cy),s=function(t,e){return t.reduce(((t,n)=>uB(n,e)&&function(t,e){function n(t,n,r,i){let o=sB(e,new nB(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)<r&&(e=i,r=o*(s+1)*(s+1)),e}),null)}(o,n,t);if(null==a)return[];const s=function(t,e,n,r){const i=[],o=[];o.push(t);let a=!0;for(let t=0;t<n&&a;t++)for(a=!1;!a&&o.length>0;){const t=o.pop(),n=wB(e,t),s=n?hB(t,n):null;if(!n||!s||2!==s.count){a||i.push(t);continue}let l=r,u=kB(n,l,s,!0),c=EB(u,o)||EB(u,i),h=xB(u,e);for(;!c&&h&&l>=1;)l/=1.5,u=kB(n,l,s,!0),c=EB(u,o)||EB(u,i),h=xB(u,e);if(!u||c||h||(o.push(new nB(t.x1,t.y1,u.x,u.y)),o.push(new nB(u.x,u.y,t.x2,t.y2)),a=!0),a)continue;l=r,u=kB(n,l,s,!1);let d=EB(u,o)||EB(u,i);for(h=xB(u,e);!d&&h&&l>=1;)l/=1.5,u=kB(n,l,s,!1),d=EB(u,o)||EB(u,i),h=xB(u,e);u&&!d&&(o.push(new nB(t.x1,t.y1,u.x,u.y)),o.push(new nB(u.x,u.y,t.x2,t.y2)),a=!0),a||i.push(t)}for(;o.length>0;)i.push(o.pop());return i}(new nB(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 nB(r.x1,r.y1,i.x2,i.y2);wB(e,o)?(n.push(r),t.push(i)):t.push(o)}return n}(s,t)}(e,t,a,n,r)})).flat()}function xB(t,e){return e.some((e=>e.containsPt(t.x,t.y)))}function EB(t,e){return e.some((e=>!!tB(e.x1,e.y1,t.x,t.y,.001)||!!tB(e.x2,e.y2,t.x,t.y,.001)))}function wB(t,e){let n=Number.POSITIVE_INFINITY,r=null;for(const i of t){if(!uB(i,e))continue;const t=cB(i,e);t>=0&&t<n&&(r=i,n=t)}return r}function kB(t,e,n,r){const i=n.top,o=n.left,a=n.bottom,s=n.right;if(r){if(o.state===rB.POINT){if(i.state===rB.POINT)return yB(t.x-e,t.y-e);if(a.state===rB.POINT)return yB(t.x-e,t.y2+e);const n=t.width*t.height;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?yB(t.x-e,t.y-e):yB(t.x2+e,t.y-e):o.y<s.y?yB(t.x-e,t.y2+e):yB(t.x2+e,t.y2+e)}if(s.state===rB.POINT){if(i.state===rB.POINT)return yB(t.x2+e,t.y-e);if(a.state===rB.POINT)return yB(t.x2+e,t.y2+e)}const n=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*n?i.x>a.x?yB(t.x-e,t.y-e):yB(t.x-e,t.y2+e):i.x<a.x?yB(t.x2+e,t.y-e):yB(t.x2+e,t.y2+e)}if(o.state===rB.POINT){if(i.state===rB.POINT)return yB(t.x2+e,t.y2+e);if(a.state===rB.POINT)return yB(t.x2+e,t.y-e);const n=t.height*t.width;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?yB(t.x2+e,t.y2+e):yB(t.x-e,t.y2+e):o.y<s.y?yB(t.x2+e,t.y-e):yB(t.x-e,t.y-e)}if(s.state===rB.POINT){if(i.state===rB.POINT)return yB(t.x-e,t.y2+e);if(a.state===rB.POINT)return yB(t.x-e,t.y-e)}const l=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*l?i.x>a.x?yB(t.x2+e,t.y2+e):yB(t.x2+e,t.y-e):i.x<a.x?yB(t.x-e,t.y2+e):yB(t.x-e,t.y-e)}function MB(t,e,n,r){if(!(t.closed?n<t.length:n<t.length-1))return!1;const i=t.get(e),o=t.get(n+1);for(let a=e+1;a<=n;a++){const e=t.get(a);if(Qj(i.x,i.y,o.x,o.y,e.x,e.y)>r)return!1}return!0}function SB(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 NB{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<r;o++,t+=n)i.push(e.get(t));return new NB(i)}}(t)(this)}simplify(t){return function(t=0){return e=>{if(t<0||e.length<3)return e;const n=[];let r=0;const i=t*t;for(;r<e.length;){let t=r+1;for(;MB(e,r,t,i);)t++;n.push(e.get(r)),r=t}return new NB(n)}}(t)(this)}bSplines(t){return function(t=6){function e(t,e,n){let r=0,i=0;for(let o=-2;o<=1;o++){const a=t.get(e+o),s=SB(o,n);r+=s*a.x,i+=s*a.y}return{x:r,y:i}}return n=>{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);a<o;a++)for(let i=1;i<=t;i++)r.push(e(n,a,i/t));return new NB(r)}}(t)(this)}apply(t){return t(this)}containsElements(t){const e=function(t){if(0===t.length)return null;const e=t[0],n=new dB(e.x,e.y,0,0);for(const e of t)n.addPoint(e);return n}(this.points);return!!e&&t.every((t=>e.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 nB(r.x,r.y,r.x,r.y);for(let r=1;r<this.points.length;r++){const o=this.points[r];i.x1=i.x2,i.y1=i.y2,i.x2=o.x,i.y2=o.y,i.cuts(t,e)&&n++}return i.x1=i.x2,i.y1=i.y2,i.x2=r.x,i.y2=r.y,i.cuts(t,e)&&n++,n%2==1}}class OB{constructor(t=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=t}add(t){this.set.add(`${t.x}x${t.y}`),this.arr[this.count++]=t}contains(t){return this.set.has(`${t.x}x${t.y}`)}isFirst(t){if(0===this.count)return!1;const e=this.arr[0];return null!=e&&e.x===t.x&&e.y===t.y}path(){return new NB(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(t){return this.arr[t]}get length(){return this.count}}function TB(t,e){const n=2*(Math.floor(t.width)+Math.floor(t.height)),r=new OB(n);function i(n,r,i,o){const a=t.get(n,r);return Number.isNaN(a)?Number.NaN:a>e?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,l=t.invertScaleX(i),u=t.invertScaleY(s);for(let e=0;e<t.width*t.height;e++){const e={x:l,y:u};if(r.contains(e)){if(r.isFirst(e))return!0}else r.add(e);const n=o(i,s);switch(n){case-1:return!0;case 0:case 3:case 2:case 7:a=2;break;case 12:case 14:case 4:a=3;break;case 6:a=0===a?3:2;break;case 1:case 13:case 5:a=0;break;case 9:a=2===a?0:1;break;case 10:case 8:case 11:a=1;break;default:return console.warn("Marching squares invalid state: "+n),!0}switch(a){case 0:s--,u-=t.pixelGroup;break;case 1:s++,u+=t.pixelGroup;break;case 3:i--,l-=t.pixelGroup;break;case 2:i++,l+=t.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+n),!0}}return!0}for(let n=0;n<t.width;n++)for(let i=0;i<t.height;i++){if(t.get(n,i)<=e)continue;const a=o(n,i);if(!(a<0||15===a)&&s(n,i))return r.path()}return null}const CB={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};function AB(t){return null!=t&&"number"==typeof t.radius}function PB(t,e){if(AB(t)!==AB(e))return!1;if(AB(t)){const n=e;return t.cx===n.cx&&t.cy===n.cy&&t.radius===n.radius}const n=e;return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}var RB;!function(t){t[t.MEMBERS=0]="MEMBERS",t[t.NON_MEMBERS=1]="NON_MEMBERS",t[t.EDGES=2]="EDGES"}(RB||(RB={}));let DB=class{constructor(t={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new dB(0,0,0,0),this.potentialArea=new pB(1,0,0,0,0,0,0),this.o=Object.assign({},CB,t)}pushMember(...t){if(0!==t.length){this.dirty.add(RB.MEMBERS);for(const e of t)this.members.push({raw:e,obj:AB(e)?fB.from(e):dB.from(e),area:null})}}removeMember(t){const e=this.members.findIndex((e=>PB(e.raw,t)));return!(e<0)&&(this.members.splice(e,1),this.dirty.add(RB.MEMBERS),!0)}removeNonMember(t){const e=this.nonMembers.findIndex((e=>PB(e.raw,t)));return!(e<0)&&(this.nonMembers.splice(e,1),this.dirty.add(RB.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(RB.NON_MEMBERS),!0)}pushNonMember(...t){if(0!==t.length){this.dirty.add(RB.NON_MEMBERS);for(const e of t)this.nonMembers.push({raw:e,obj:AB(e)?fB.from(e):dB.from(e),area:null})}}pushEdge(...t){if(0!==t.length){this.dirty.add(RB.EDGES);for(const e of t)this.edges.push({raw:e,obj:nB.from(e),area:null})}}update(){const t=this.dirty.has(RB.MEMBERS),e=this.dirty.has(RB.NON_MEMBERS);let n=this.dirty.has(RB.EDGES);this.dirty.clear();const r=this.members.map((t=>t.obj));if(this.o.virtualEdges&&(t||e)){const t=bB(r,this.nonMembers.map((t=>t.obj)),this.o.maxRoutingIterations,this.o.morphBuffer),e=new Map(this.virtualEdges.map((t=>[t.obj.toString(),t.area])));this.virtualEdges=t.map((t=>{var n;return{raw:t,obj:t,area:null!==(n=e.get(t.toString()))&&void 0!==n?n:null}})),n=!0}let i=!1;if(t||n){const t=function(t,e){if(0===t.length)return new dB(0,0,0,0);const n=dB.from(t[0]);for(const e of t)n.add(e);for(const t of e)n.add(eB(t));return n}(r,this.virtualEdges.concat(this.edges).map((t=>t.obj))),e=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,n=dB.from(gB(t,e));n.equals(this.activeRegion)||(i=!0,this.activeRegion=n)}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=pB.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=pB.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 dB?"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 dB?"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 dB?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,l=i.x2-r.x2,u=i.y2-r.y2,c=i.width-a-l,h=i.height-s-u,d=n*n;o.fillArea({x:a,y:s,width:c+1,height:h+1},d);const f=[0],p=Math.max(s,a,l,u);{const i=e.invertScaleX(r.x+r.width/2);for(let o=1;o<p;o++){const a=e.invertScaleY(r.y-o),s=t.distSquare(i,a);if(!(s<d))break;{const t=n-Math.sqrt(s);f.push(t*t)}}}const g=[],v=Math.max(a,l),m=Math.max(s,l);for(let i=1;i<v;i++){const o=e.invertScaleX(r.x-i),a=[];for(let i=1;i<m;i++){const s=e.invertScaleY(r.y-i),l=t.distSquare(o,s);if(l<d){const t=n-Math.sqrt(l);a.push(t*t)}else a.push(0)}g.push(a)}for(let t=1;t<Math.min(s,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s-t,c+1,e)}for(let t=1;t<Math.min(u,f.length);t++){const e=f[t];o.fillHorizontalLine(a,s+h+t,c+1,e)}for(let t=1;t<Math.min(a,f.length);t++){const e=f[t];o.fillVerticalLine(a-t,s,h+1,e)}for(let t=1;t<Math.min(u,f.length);t++){const e=f[t];o.fillVerticalLine(a+c+t,s,h+1,e)}for(let t=1;t<a;t++){const e=g[t-1],n=a-t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<u;t++)o.set(n,s+h+t,e[t-1])}for(let t=1;t<l;t++){const e=g[t-1],n=a+c+t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<u;t++)o.set(n,s+h+t,e[t-1])}return o}(t.obj,this.potentialArea,this.o.nodeR1):mB(t.obj,this.potentialArea,this.o.nodeR1);t.area=n,o.set(e,n)};this.members.forEach(a),this.nonMembers.forEach(a),this.members.forEach(s),this.nonMembers.forEach((t=>{this.activeRegion.intersects(t.obj)?s(t):t.area=null})),this.edges.forEach((t=>{t.area||(t.area=vB(t.obj,this.potentialArea,this.o.edgeR1))})),this.virtualEdges.forEach((t=>{t.area||(t.area=vB(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 NB([]);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({},CB,o);let s=a.threshold,l=a.memberInfluenceFactor,u=a.edgeInfluenceFactor,c=a.nonMemberInfluenceFactor;const h=(a.nodeR0-a.nodeR1)*(a.nodeR0-a.nodeR1),d=(a.edgeR0-a.edgeR1)*(a.edgeR0-a.edgeR1);for(let o=0;o<a.maxMarchingIterations;o++){if(t.clear(),0!==l){const n=l/h;for(const r of e)t.incArea(r,n)}if(0!==u){const e=u/d;for(const r of n)t.incArea(r,e)}if(0!==c){const e=c/h;for(const n of r)t.incArea(n,e)}const f=TB(t,s);if(f&&i(f))return f;if(s*=.95,o<=.5*a.maxMarchingIterations)l*=1.2,u*=1.2;else{if(!(0!==c&&r.length>0))break;c*=.8}}return new NB([])}(e,n,r,i,(t=>t.containsElements(o)),t)}};class LB extends qj{constructor(t,e){super(t,ke({},LB.defaultOptions,e)),this.members=new Map,this.avoidMembers=new Map,this.bubbleSetOptions={},this.drawBubbleSets=()=>{const{style:t,bubbleSetOptions:e}=this.parseOptions();Ne(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 qd({style:n}),this.context.canvas.appendChild(this.shape))},this.updateBubbleSetsPath=t=>{if(!this.shape)return;const e=yh(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(!t&&Ne(n,r)&&Ne(i,o))return this.path;const{enter:a=[],exit:s=[]}=Ch(r,n,(t=>t)),{enter:l=[],exit:u=[]}=Ch(o,i,(t=>t));t&&(s.push(t),a.push(t));const c=(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]=IB(e,t),this.bubbleSets.pushEdge(n)):([n]=_B(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))}}))};c(s,!1,!0),c(a,!0,!0),c(u,!1,!1),c(l,!0,!1);const h=this.bubbleSets.compute().sample(8).simplify(0).bSplines().simplify(0);return this.path=Yd(h.points.map(nd)),this.path},this.bindEvents(),this.bubbleSets=new DB(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 DB(this.options),this.members=new Map,this.avoidMembers=new Map}parseOptions(){const t=this.options,{type:e,key:n,members:r,avoidMembers:i}=t,o=Fe(t,["type","key","members","avoidMembers"]),a=Object.keys(o).reduce(((t,e)=>(e in CB?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=Ut(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.destroy(),super.destroy()}}LB.defaultOptions=Object.assign({members:[],avoidMembers:[],fill:"lightblue",fillOpacity:.2,stroke:"blue",strokeOpacity:.2},CB);const _B=(t,e)=>(Array.isArray(e)?e:[e]).map((e=>{const n=t.getElementRenderBounds(e);return new dB(n.min[0],n.min[1],Yc(n),qc(n))})),IB=(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 nB.from({x1:r[0],y1:r[1],x2:i[0],y2:i[1]})}));class jB extends qj{constructor(t,e){super(t,Object.assign({},jB.defaultOptions,e)),this.targetElement=null,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=Xj("contextmenu",!1,{zIndex:"99"});const{className:t}=this.options;t&&this.$element.classList.add(t);this.context.canvas.getContainer().appendChild(this.$element),Kj("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: hidden;\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-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 ze(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();this.$element.style.left=`${t.client.x-i.left+n[0]}px`,this.$element.style.top=`${t.client.y-i.top+n[1]}px`,this.$element.style.display="block",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 ze(this,void 0,void 0,(function*(){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(yield n(t)).map((t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`)).join("")}\n </ul>\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)}}jB.defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};class BB extends qj{constructor(t,e){super(t,Object.assign({},BB.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:l}=this.options;for(let t=0;t<r;t++){for(let t=0;t<l;t++){const t={};n.forEach((e=>{var n;if(e.source===e.target)return;const r=yh(e);t[r]=this.getEdgeForces(e,s,a);for(let e=0;e<s+1;e++)(n=this.edgePoints)[r]||(n[r]=[]),this.edgePoints[r][e]=Ih(this.edgePoints[r][e],t[r][e])}))}a/=2,s*=o,l*=i,this.divideEdges(s)}n.forEach((t=>{const n=yh(t),r=e.getElement(n);null==r||r.update({d:Kp(this.edgePoints[n])})}))},this.bindEvents()}get nodeMap(){const t=this.context.model.getNodeData();return Object.fromEntries(t.map((t=>[yh(t),Yh(Jh(t))])))}divideEdges(t){this.context.model.getEdgeData().forEach((e=>{var n;const r=yh(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(Fh(Ih(i,o),2)),this.edgePoints[r].push(o);else{const e=(0===this.edgePoints[r].length?Gh(i,o):UB(this.edgePoints[r]))/(t+1);let n=e;const a=[i];for(let t=1;t<this.edgePoints[r].length;t++){const i=this.edgePoints[r][t-1],o=this.edgePoints[r][t];let s=Gh(o,i);for(;s>n;){const t=n/s,r=Ih(i,Bh(jh(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]=jh(n,e);return{source:e,target:n,vx:r,vy:i,length:Gh(e,n)}}measureEdgeCompatibility(t,e){const n=this.getVectorPosition(t),r=this.getVectorPosition(e);return FB(n,r)*zB(n,r)*GB(n,r)*HB(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=yh(r)]||(t[a]=[]),t[yh(r)].push(n),t[s=yh(n)]||(t[s]=[]),t[yh(n)].push(r))}))})),t}getSpringForce(t,e){const{pre:n,cur:r,next:i}=t;return Bh(jh(Ih(n,i),Bh(r,2)),e)}getElectrostaticForce(t,e){Se(this.edgeBundles)&&(this.edgeBundles=this.getEdgeBundles());const n=this.edgeBundles[yh(e)];let r=[0,0];return null==n||n.forEach((n=>{const i=this.edgePoints[yh(n)][t],o=this.edgePoints[yh(e)][t],a=jh(i,o),s=Gh(i,o);r=Ih(r,Bh(a,1/s))})),r}getEdgeForces(t,e,n){const r=this.nodeMap[t.source],i=this.nodeMap[t.target],o=this.options.K/(Gh(r,i)*(e+1)),a=[[0,0]],s=yh(t);for(let r=1;r<e;r++){const e=this.getSpringForce({pre:this.edgePoints[s][r-1],cur:this.edgePoints[s][r],next:this.edgePoints[s][r+1]||[0,0]},o),i=this.getElectrostaticForce(r,t);a.push(Bh(Ih(e,i),n))}return a.push([0,0]),a}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onBundle)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onBundle)}destroy(){this.unbindEvents(),super.destroy()}}BB.defaultOptions={K:.1,lambda:.1,divisions:1,divRate:2,cycles:6,iterations:90,iterRate:2/3,bundleThreshold:.6};const FB=(t,e)=>Math.abs(function(t,e){return t.reduce(((t,n,r)=>t+n*e[r]),0)}([t.vx,t.vy],[e.vx,e.vy])/(t.length*e.length)),zB=(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)},GB=(t,e)=>{const n=(t.length+e.length)/2;return n/(n+Gh(Fh(Ih(t.source,t.target),2),Fh(Ih(e.source,e.target),2)))},VB=(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]]},WB=(t,e)=>{const n=VB(e.source,t),r=VB(e.target,t),i=Fh(Ih(n,r),2),o=Fh(Ih(t.source,t.target),2);return 0===Gh(n,r)?0:Math.max(0,1-2*Gh(o,i)/Gh(n,r))},HB=(t,e)=>Math.min(WB(t,e),WB(e,t)),UB=t=>{let e=0;for(let n=1;n<t.length;n++)e+=Gh(t[n],t[n-1]);return e},$B={fill:"#fff",fillOpacity:1,lineWidth:1,stroke:"#000",strokeOpacity:.8,zIndex:-1/0};class YB extends qj{constructor(t,e){super(t,Object.assign({},YB.defaultOptions,e)),this.shapes=new Map,this.r=this.options.r,this.onEdgeFilter=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=nd(t.canvas);this.renderLens(e),this.renderFocusElements()},this.renderLens=t=>{const e=Object.assign({},$B,this.options.style);this.isLensOn||(this.lens=new rf({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,rd(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(yh(e),"node"))),edges:i.filter((e=>t(yh(e),"edge"))),combos:o.filter((e=>t(yh(e),"combo")))}},this.getFocusElements=t=>{const{nodes:e,edges:n}=this.getFilterData(),r=e.filter((e=>Gh(Jh(e),t)<this.r)),i=r.map((t=>yh(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=yh(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),l=this.getElementStyle(s,n);a.update(l)};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,l=a.getCanvasByClient([n,r]),u=null===(e=this.lens)||void 0===e?void 0:e.getCenter();if(!this.isLensOn||Gh(l,u)>this.r)return;const{maxR:c,minR:h}=this.options,d=i+o>0?1/.95:.95,f=Math.min(...s.getSize())/2;this.r=Math.max(h||0,Math.min(c||f,this.r*d)),this.renderLens(u),this.renderFocusElements()},this.isLensDragging=!1,this.onDragStart=t=>{var e;const n=nd(t.canvas),r=null===(e=this.lens)||void 0===e?void 0:e.getCenter();!this.isLensOn||Gh(n,r)>this.r||(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=nd(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()}}YB.defaultOptions={trigger:"pointermove",r:60,nodeType:"both",filter:()=>!0,style:{lineWidth:2},nodeStyle:{label:!1},edgeStyle:{label:!0},scaleRBy:"wheel",preventDefault:!0};const qB={fill:"#ccc",fillOpacity:.1,lineWidth:2,stroke:"#000",strokeOpacity:.8,labelFontSize:12};class XB extends qj{constructor(t,e){super(t,Object.assign({},XB.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=nd(t.canvas);this.onMagnify(e)},this.onMagnify=t=>{t.some(isNaN)||(this.renderLens(t),this.renderFocusElements())},this.renderLens=t=>{const e=Object.assign({},qB,this.options.style);this.isLensOn||(this.lens=new rf({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,rd(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=Jh(o),s=Gh(a,e);if(s>this.r)return;const l=n*s/(this.d*s+this.r),[u,c]=a,[h,d]=e,f=[h+l*((u-h)/s),d+l*((c-d)/s)],p=yh(o),g=this.getNodeStyle(o),v=Ae(t.getElementRenderStyle(p),Object.keys(g));r.set(p,Object.assign(Object.assign({},rd(f)),g)),i.set(p,Object.assign(Object.assign({},rd(a)),v))})),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}=Ch(Array.from(this.prevMagnifiedStyleMap.keys()),Array.from(t.keys()),(t=>t)),s=new Set,l=(t,e)=>{const i=r.getElement(t);null==i||i.update(e),n.getRelatedEdgesData(t).forEach((t=>{s.add(yh(t))}))};[...i,...a].forEach((e=>{l(e,t.get(e))})),o.forEach((t=>{l(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!(Gh(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!(Gh(nd(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=nd(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()}}XB.defaultOptions={trigger:"pointermove",r:120,d:1.5,maxD:5,minD:0,showDPercent:!0,style:{},nodeStyle:{label:!0},preventDefault:!0};class KB extends qj{constructor(t,e){super(t,Object.assign({},KB.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 md(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=>{Tc(`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()}}KB.defaultOptions={trigger:{},autoFit:!0};class ZB extends qj{constructor(t,e){super(t,Object.assign({},ZB.defaultOptions,e)),this.$element=Xj("grid-line",!0),this.offset=[0,0],this.currentScale=1,this.followZoom=t=>{const{data:{scale:e,origin:n}}=t;if(!e)return;const r=this.currentScale;this.currentScale=e;const i=e/r,o=Bh(n||this.context.graph.getCanvasCenter(),1-i),a=this.baseSize*e,s=Ih($h(Bh(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=$h(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=$h(Ih(this.offset,t),e),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}parseFollow(t){var e,n;return pe(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 QB(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach((t=>{const{type:n,value:r}=t,i=yh(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 JB(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:a=[],ComboAdded:s=[],ComboUpdated:l=[],ComboRemoved:u=[]}=ie(t,(t=>t.type));return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:l},remove:{nodes:r,edges:a,combos:u}}}function tF(t,e){for(const n in t)qt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),tF(t[n],e[n])):void 0===e[n]&&(e[n]=Rc(n))}function eF(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:a}=JB(QB(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(yh(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)})}tF(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}ZB.defaultOptions={border:!0,borderLineWidth:1,borderStroke:"#eee",borderStyle:"solid",lineWidth:1,size:20,stroke:"#eee"};class nF extends qj{constructor(e,n){super(e,Object.assign({},nF.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(xh(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(eF(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 Vg;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=[]}}nF.defaultOptions={stackSize:0};const rF={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 iF=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 oF=+(Math.pow(2,27)+1);function aF(t,e,n){const r=t*e,i=oF*t,o=i-(i-t),a=t-o,s=oF*e,l=s-(s-e),u=e-l,c=a*u-(r-o*l-a*l-o*u);return n?(n[0]=c,n[1]=r,n):[c,r]}function sF(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 lF(t,e){const n=t.length;if(1===n){const n=aF(t[0],e);return n[0]?n:[n[1]]}const r=new Array(2*n),i=[.1,.1],o=[.1,.1];let a=0;aF(t[0],e,i),i[0]&&(r[a++]=i[0]);for(let s=1;s<n;++s){aF(t[s],e,o);sF(i[1],o[0],i),i[0]&&(r[a++]=i[0]);const n=o[1],l=i[1],u=n+l,c=l-(u-n);i[1]=u,c&&(r[a++]=c)}return i[1]&&(r[a++]=i[1]),0===a&&(r[a++]=0),r.length=a,r}function uF(t,e){const n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){const n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],-e[0]);const i=new Array(n+r);let o=0,a=0,s=0;const l=Math.abs;let u,c,h=t[a],d=l(h),f=-e[s],p=l(f);d<p?(c=h,a+=1,a<n&&(h=t[a],d=l(h))):(c=f,s+=1,s<r&&(f=-e[s],p=l(f))),a<n&&d<p||s>=r?(u=h,a+=1,a<n&&(h=t[a],d=l(h))):(u=f,s+=1,s<r&&(f=-e[s],p=l(f)));let g,v,m,y,b,x=u+c,E=x-u,w=c-E,k=w,M=x;for(;a<n&&s<r;)d<p?(u=h,a+=1,a<n&&(h=t[a],d=l(h))):(u=f,s+=1,s<r&&(f=-e[s],p=l(f))),c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g;for(;a<n;)u=h,c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g,a+=1,a<n&&(h=t[a]);for(;s<r;)u=f,c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g,s+=1,s<r&&(f=-e[s]);return k&&(i[o++]=k),M&&(i[o++]=M),o||(i[o++]=0),i.length=o,i}function cF(t,e){const n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){const n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],e[0]);const i=new Array(n+r);let o=0,a=0,s=0;const l=Math.abs;let u,c,h=t[a],d=l(h),f=e[s],p=l(f);d<p?(c=h,a+=1,a<n&&(h=t[a],d=l(h))):(c=f,s+=1,s<r&&(f=e[s],p=l(f))),a<n&&d<p||s>=r?(u=h,a+=1,a<n&&(h=t[a],d=l(h))):(u=f,s+=1,s<r&&(f=e[s],p=l(f)));let g,v,m,y,b,x=u+c,E=x-u,w=c-E,k=w,M=x;for(;a<n&&s<r;)d<p?(u=h,a+=1,a<n&&(h=t[a],d=l(h))):(u=f,s+=1,s<r&&(f=e[s],p=l(f))),c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g;for(;a<n;)u=h,c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g,a+=1,a<n&&(h=t[a]);for(;s<r;)u=f,c=k,x=u+c,E=x-u,w=c-E,w&&(i[o++]=w),g=M+x,v=g-M,m=g-v,y=x-v,b=M-m,k=b+y,M=g,s+=1,s<r&&(f=e[s]);return k&&(i[o++]=k),M&&(i[o++]=M),o||(i[o++]=0),i.length=o,i}function hF(t,e,n,r){return function(n,i,o){const a=t(t(e(i[1],o[0]),e(-o[1],i[0])),t(e(n[1],i[0]),e(-i[1],n[0]))),s=t(e(n[1],o[0]),e(-o[1],n[0])),l=r(a,s);return l[l.length-1]}}function dF(t,e,n,r){return function(i,o,a,s){const l=t(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),s[2]))),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2])))),u=t(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),s[2]))),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2])))),c=r(l,u);return c[c.length-1]}}function fF(t,e,n,r){return function(i,o,a,s,l){const u=t(t(t(n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),a[2]),t(n(t(e(a[1],l[0]),e(-l[1],a[0])),-s[2]),n(t(e(a[1],s[0]),e(-s[1],a[0])),l[2]))),o[3]),t(n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),o[2]),t(n(t(e(o[1],l[0]),e(-l[1],o[0])),-s[2]),n(t(e(o[1],s[0]),e(-s[1],o[0])),l[2]))),-a[3]),n(t(n(t(e(a[1],l[0]),e(-l[1],a[0])),o[2]),t(n(t(e(o[1],l[0]),e(-l[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),l[2]))),s[3]))),t(n(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),s[2]))),-l[3]),t(n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),o[2]),t(n(t(e(o[1],l[0]),e(-l[1],o[0])),-s[2]),n(t(e(o[1],s[0]),e(-s[1],o[0])),l[2]))),i[3]),n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-s[2]),n(t(e(i[1],s[0]),e(-s[1],i[0])),l[2]))),-o[3])))),t(t(n(t(n(t(e(o[1],l[0]),e(-l[1],o[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),l[2]))),s[3]),t(n(t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2]))),-l[3]),n(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),s[2]))),i[3]))),t(n(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),s[2]))),-o[3]),t(n(t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2]))),a[3]),n(t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2]))),-s[3]))))),c=t(t(t(n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),a[2]),t(n(t(e(a[1],l[0]),e(-l[1],a[0])),-s[2]),n(t(e(a[1],s[0]),e(-s[1],a[0])),l[2]))),i[3]),n(t(n(t(e(s[1],l[0]),e(-l[1],s[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-s[2]),n(t(e(i[1],s[0]),e(-s[1],i[0])),l[2]))),-a[3])),t(n(t(n(t(e(a[1],l[0]),e(-l[1],a[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),l[2]))),s[3]),n(t(n(t(e(a[1],s[0]),e(-s[1],a[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),s[2]))),-l[3]))),t(t(n(t(n(t(e(a[1],l[0]),e(-l[1],a[0])),o[2]),t(n(t(e(o[1],l[0]),e(-l[1],o[0])),-a[2]),n(t(e(o[1],a[0]),e(-a[1],o[0])),l[2]))),i[3]),n(t(n(t(e(a[1],l[0]),e(-l[1],a[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-a[2]),n(t(e(i[1],a[0]),e(-a[1],i[0])),l[2]))),-o[3])),t(n(t(n(t(e(o[1],l[0]),e(-l[1],o[0])),i[2]),t(n(t(e(i[1],l[0]),e(-l[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),l[2]))),a[3]),n(t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2]))),-l[3])))),h=r(u,c);return h[h.length-1]}}function pF(t){return(3===t?hF:4===t?dF:fF)(cF,aF,lF,uF)}const gF=pF(3),vF=pF(4),mF=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,n){const r=(t[1]-n[1])*(e[0]-n[0]),i=(t[0]-n[0])*(e[1]-n[1]),o=r-i;let a;if(r>0){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:gF(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],l=e[1]-r[1],u=n[1]-r[1],c=t[2]-r[2],h=e[2]-r[2],d=n[2]-r[2],f=o*u,p=a*l,g=a*s,v=i*u,m=i*l,y=o*s,b=c*(f-p)+h*(g-v)+d*(m-y),x=7771561172376103e-31*((Math.abs(f)+Math.abs(p))*Math.abs(c)+(Math.abs(g)+Math.abs(v))*Math.abs(h)+(Math.abs(m)+Math.abs(y))*Math.abs(d));return b>x||-b>x?b:vF(t,e,n,r)}];function yF(t){let e=mF[t.length];return e||(e=mF[t.length]=pF(t.length)),e.apply(void 0,...t)}var bF=function(){for(;mF.length<=5;)mF.push(pF(mF.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,yF,...mF);for(let e=0;e<=5;++e)t[e]=mF[e];return t}();const xF=bF[3];function EF(t,e,n,r){const i=bF(t,n,r),o=bF(e,n,r);if(i>0&&o>0||i<0&&o<0)return!1;const a=bF(n,t,e),s=bF(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,l]=[Math.min(o,a),Math.max(o,a)],u=n[i],c=r[i],[h,d]=[Math.min(u,c),Math.max(u,c)];if(d<s||l<h)return!1}return!0}(t,e,n,r))}function wF(t,e){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function kF(t,e,n){const r=[e[0]-t[0],e[1]-t[1]],i=[n[0]-t[0],n[1]-t[1]],o=wF(t,e),a=wF(t,n);return(r[0]*i[0]+r[1]*i[1])/Math.sqrt(o*a)}function MF(t,e){for(let n=0;n<e.length-1;n++){const r=[e[n],e[n+1]];if(!(t[0][0]===r[0][0]&&t[0][1]===r[0][1]||t[0][0]===r[1][0]&&t[0][1]===r[1][1])&&EF(t[0],t[1],r[0],r[1]))return!0}return!1}function SF(t){return[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]}function NF(t,e,n){let r,i,o=null,a=CF,s=CF;for(let l=0;l<e.length;l++)r=kF(t[0],t[1],e[l]),i=kF(t[1],t[0],e[l]),r>a&&i>s&&!MF([t[0],e[l]],n)&&!MF([t[1],e[l]],n)&&(a=r,s=i,o=e[l]);return o}function OF(t,e,n,r,i){let o=!1;for(let a=0;a<t.length-1;a++){const s=[t[a],t[a+1]],l=s[0][0]+","+s[0][1]+","+s[1][0]+","+s[1][1];if(wF(s[0],s[1])<e||i.has(l))continue;let u,c,h,d=0,f=SF(s);do{f=r.extendBbox(f,d),u=f[2]-f[0],c=f[3]-f[1],h=NF(s,r.rangePoints(f),t),d++}while(null===h&&(n[0]>u||n[1]>c));u>=n[0]&&c>=n[1]&&i.add(l),null!==h&&(t.splice(a+1,0,h),r.removePoint(h),o=!0)}return o?OF(t,e,n,r,i):t}function TF(t,e,n){const r=e||20,i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];n[0]===i[0]&&n[1]===i[1]||e.push(i),n=i}return e}(function(t){return t.sort((function(t,e){return t[0]-e[0]||t[1]-e[1]}))}(rF.toXy(t,n)));if(i.length<4){const t=i.concat([i[0]]);return n?rF.fromXy(t,n):t}const o=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=t.length-1;o>=0;o--)t[o][0]<e&&(e=t[o][0]),t[o][1]<n&&(n=t[o][1]),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]*AF,o[1]*AF],s=function(t){const e=t.length;if(e<3){const n=new Array(e);for(let t=0;t<e;++t)n[t]=t;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:n}const n=new Array(e);for(let t=0;t<e;++t)n[t]=t;n.sort(((e,n)=>t[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;o<e;++o){const e=n[o],a=t[e];let s=r.length;for(;s>1&&xF(t[r[s-2]],t[r[s-1]],a)<=0;)s-=1,r.pop();for(r.push(e),s=i.length;s>1&&xF(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;t<e;++t)o[a++]=r[t];for(let t=i.length-2;t>0;--t)o[a++]=i[t];return o}(i).reverse().map((t=>i[t]));s.push(s[0]);const l=i.filter((function(t){return s.indexOf(t)<0})),u=Math.ceil(1/(i.length/(o[0]*o[1]))),c=OF(s,Math.pow(r,2),a,function(t,e){return new iF(t,e)}(l,u),new Set);return n?rF.fromXy(c,n):c}const CF=Math.cos(90/(180/Math.PI)),AF=.6;const PF=(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]]},RF=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?Ih(t[0],zh(Wh(jh(t[0],t[1])),e)):t[0],o="sharp"===n?Ih(t[1],zh(Wh(jh(t[1],t[0])),e)):t[1],a=zh(Wh(Uh(jh(i,o),!1)),e),s=zh(a,-1),l=Ih(i,a),u=Ih(o,a),c=Ih(o,s),h=Ih(i,s);return"sharp"===n?[["M",l[0],l[1]],["L",u[0],u[1]],["L",c[0],c[1]],["L",h[0],h[1]],["Z"]]:[["M",l[0],l[1]],["L",u[0],u[1]],["A",...r,c[0],c[1]],["L",h[0],h[1]],["A",...r,l[0],l[1]]]},DF=(t,e)=>{const n=fd(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],l=t[o],u=t[a],c=jh(s,l),h=jh(l,n),d=jh(n,u),f=(t,e)=>Hh(t,e,!0)<Math.PI,p=f(c,h),g=f(h,d),v=t=>zh(Wh(Uh(t,!1)),e),m=v(h);return[{p:Yh(Ih(l,p?v(c):m)),concave:p&&l},{p:Yh(Ih(n,g?v(d):m)),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}))},LF=(t,e)=>{const n=fd(t).map(((e,n)=>({p:e,v:Wh(jh(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=Wh(Ih(a,zh(r.v,Hh(a,r.v,!0)<Math.PI?1:-1)));r.p=Ih(r.p,zh(s,e))})),Yd(n.map((t=>t.p)))},_F=(t,e)=>{const n=t.map(((n,r)=>{const i=t[0===r?t.length-1:r-1],o=qh(zh(Wh(Uh(jh(i,n),!1)),e));return[Ih(i,o),Ih(n,o)]})),r=n.flat();return r.map(((t,e)=>{if(e%2==0)return null;return Zh([r[(e-1)%r.length],r[e%r.length]],[r[(e+1)%r.length],r[(e+2)%r.length]],!0)})).filter(Boolean).map(((t,e)=>[0===e?"M":"L",t[0],t[1]])).concat([["Z"]])};class IF extends qj{constructor(t,e){super(t,Object.assign({},IF.defaultOptions,e)),this.hullMemberIds=[],this.drawHull=()=>{if(this.shape){const t=!Ne(this.optionsCache,this.options);this.shape.update(this.getHullStyle(t))}else this.shape=new qd({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape);this.optionsCache=Object.assign({},this.options)},this.updateHullPath=t=>{this.shape&&this.options.members.includes(yh(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=TF(r.map(Jh),this.options.concavity).slice(1).reverse(),o=i.flatMap((t=>r.filter((e=>Ne(Jh(e),t))).map(yh)));return Ne(o,this.hullMemberIds)&&!t||(this.hullMemberIds=o,this.path=function(t,e,n){if(1===t.length)return PF(t[0],e,n);if(2===t.length)return RF(t,e,n);if(3===t.length){const[r,i,o]=fd(t);if(sd(r,i,o))return RF([r,o],e,n)}switch(n){case"smooth":return LF(t,e);case"sharp":return _F(t,e);default:return DF(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)}getHullStyle(t){const e=this.options,{members:n,padding:r,corner:i}=e,o=Fe(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=Ut(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}getMember(){return this.options.members}destroy(){this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.drawHull),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function jF(t,e){e(t),t.children&&t.children.forEach((function(t){t&&jF(t,e)}))}function BF(t){zF(t,!0)}function FF(t){zF(t,!1)}function zF(t,e){var n=e?"visible":"hidden";jF(t,(function(t){t.attr("visibility",n)}))}IF.defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",fillOpacity:.2,labelOpacity:1,stroke:"blue",strokeOpacity:.2};var GF=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,We([],Ve(e),!1))||this;return r.isMutationObserved=!0,r.addEventListener(Vs.INSERTED,(function(){FF(r)})),r}return je(e,t),e}(jl);function VF(t){var e=t.appendChild(new GF({class:"offscreen"}));return FF(e),e}var WF=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=Fe(e,["style"]);return t.call(this,Be({style:Be({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return je(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=VF(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(Zl);function HF(t){return t*Math.PI/180}function UF(t){return Number((180*t/Math.PI).toPrecision(5))}var $F=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=n,this.height=r}return Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y},enumerable:!1,configurable:!0}),t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t.prototype.toJSON=function(){return{x:this.x,y:this.y,width:this.width,height:this.height,top:this.top,right:this.right,bottom:this.bottom,left:this.left}},t.prototype.isPointIn=function(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom},t}();function YF(t,e){return Ut(t)?t.apply(void 0,We([],Ve(e),!1)):t}var qF,XF=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map((function(t){var e=Ve(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},KF=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=Ve(i,2),a=o[0],s=o[1],l=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?Jt(s)?(Jt(t[a])||(l[a]={}),n<r?KF(t[a],s,n+1,r):l[a]=e[a]):Yt(s)?(l[a]=[],l[a]=l[a].concat(s)):l[a]=s:l[a]=s)}))},ZF=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r+=1)KF(t,e[r]);return t},QF=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},JF=xe((function(t,e){var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return qF||(qF=bl.offscreenCanvasCreator.getOrCreateContext(void 0)),qF.font=[o,a,i,"".concat(n,"px"),r].join(" "),qF.measureText(t).width}),(function(t,e){return[t,Object.values(e||tz(t)).join()].join("")}),4096),tz=function(t){var e=t.style.fontFamily||"sans-serif",n=t.style.fontWeight||"normal",r=t.style.fontStyle||"normal",i=t.style.fontVariant,o=t.style.fontSize;return{fontSize:o="object"==typeof o?o.value:o,fontFamily:e,fontWeight:n,fontStyle:r,fontVariant:i}};function ez(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function nz(t,e){var n=ez(t);n&&n.attr(e)}function rz(t,e,n){void 0===n&&(n="..."),nz(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function iz(t){var e=t.canvas,n=t.touches,r=t.offsetX,i=t.offsetY;if(e)return[e.x,e.y];if(n){var o=n[0];return[o.clientX,o.clientY]}return r&&i?[r,i]:[0,0]}function oz(t){return"function"==typeof t?t():ne(t)||ae(t)?new WF({style:{text:String(t)}}):t}function az(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=function(t){t.node().removeChildren()}),t?n(e):(r&&i(e),null)}function sz(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=!1),!!(r&&t===e||i&&t===n)||t>e&&t<n}function lz(t,e){return"number"==typeof t&&"number"==typeof e?function(t,e){return function(n){return t*(1-n)+e*n}}(t,e):Array.isArray(t)&&Array.isArray(e)?function(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0;return function(i){var o=new Array(r),a=new Array(n),s=0;for(s=0;s<r;++s)o[s]=lz(t[s],e[s]);for(;s<n;++s)a[s]=e[s];for(s=0;s<r;++s)a[s]=o[s](i);return a}}(t,e):"object"==typeof t&&"object"==typeof e?function(t,e){void 0===t&&(t={}),void 0===e&&(e={});var n={},r={};return Object.entries(e).forEach((function(e){var i=Ve(e,2),o=i[0],a=i[1];o in t?n[o]=lz(t[o],a):r[o]=a})),function(t){return Object.entries(n).forEach((function(e){var n=Ve(e,2),i=n[0],o=n[1];return r[i]=o(t)})),r}}(t,e):function(e){return t}}function uz(t,e){return[t[0]*e,t[1]*e]}function cz(t,e){return[t[0]+e[0],t[1]+e[1]]}function hz(t,e){return[t[0]-e[0],t[1]-e[1]]}function dz(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function fz(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function pz(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function gz(t){if(0===t[0]&&0===t[1])return[0,0];var e=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2));return[t[0]/e,t[1]/e]}function vz(t,e){return+t.toPrecision(e)}function mz(t,e){var n={},r=Array.isArray(e)?e:[e];for(var i in t)r.includes(i)||(n[i]=t[i]);return n}function yz(t,e,n){void 0===n&&(n=[[0,0],[1,1]]);for(var r=[],i=0,o=t.length;i<o;i+=2)r.push([t[i],t[i+1]]);var a,s,l,u=function(t,e,n,r){var i,o,a,s,l,u,c=[],h=!!r,d=[1/0,1/0],f=[-1/0,-1/0];if(h){d=(i=Ve(r,2))[0],f=i[1];for(var p=0,g=t.length;p<g;p+=1)d=dz(d,m=t[p]),f=fz(f,m)}p=0;for(var v=t.length;p<v;p+=1){var m=t[p];if(0===p)u=m;else if(p===v-1)l=m,c.push(u),c.push(l);else{o=t[p-1];var y=[0,0];y=uz(y=hz(a=t[p+1],o),e);var b=pz(m,o),x=pz(m,a),E=b+x;0!==E&&(b/=E,x/=E);var w=uz(y,-b),k=uz(y,x);l=cz(m,w),s=dz(s=cz(m,k),fz(a,m)),s=fz(s,dz(a,m)),l=dz(l=cz(m,w=uz(w=hz(s,m),-b/x)),fz(o,m)),s=cz(m,k=uz(k=hz(m,l=fz(l,dz(o,m))),x/b)),h&&(l=dz(l=fz(l,d),f),s=dz(s=fz(s,d),f)),c.push(u),c.push(l),u=s}}return c}(r,.4,0,n),c=r.length,h=[];for(i=0;i<c-1;i+=1)a=u[2*i],s=u[2*i+1],l=r[i+1],h.push(["C",a[0],a[1],s[0],s[1],l[0],l[1]]);return h}var bz=["$el","cx","cy","d","dx","dy","fill","fillOpacity","filter","fontFamily","fontSize","fontStyle","fontVariant","fontWeight","height","img","increasedLineWidthForHitTesting","innerHTML","isBillboard","billboardRotation","isSizeAttenuation","isClosed","isOverflowing","leading","letterSpacing","lineDash","lineHeight","lineWidth","markerEnd","markerEndOffset","markerMid","markerStart","markerStartOffset","maxLines","metrics","miterLimit","offsetX","offsetY","opacity","path","points","r","radius","rx","ry","shadowColor","src","stroke","strokeOpacity","text","textAlign","textBaseline","textDecorationColor","textDecorationLine","textDecorationStyle","textOverflow","textPath","textPathSide","textPathStartOffset","transform","transformOrigin","visibility","width","wordWrap","wordWrapWidth","x","x1","x2","y","y1","y2","z1","z2","zIndex"];function xz(t){return bz.includes(t)}function Ez(t){var e={};for(var n in t)xz(n)&&(e[n]=t[n]);return e}function wz(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,a=e/Math.max(i,o);return t.style.transform="scale(".concat(a,")"),a}var kz=function(){function t(t,n,r,i,o,a,s){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o=[null,null,null,null,null]),void 0===a&&(a=[]),void 0===s&&(s=[]),e.add(this),this._elements=Array.from(t),this._data=n,this._parent=r,this._document=i,this._enter=o[0],this._update=o[1],this._exit=o[2],this._merge=o[3],this._split=o[4],this._transitions=a,this._facetElements=s}var e,n,r;return t.prototype.selectAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(e,null,this._elements[0],this._document)},t.prototype.selectFacetAll=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t):t;return new n(this._elements,null,this._parent,this._document,void 0,void 0,e)},t.prototype.select=function(t){var e="string"==typeof t?this._parent.querySelectorAll(t)[0]||null:t;return new n([e],null,e,this._document)},t.prototype.append=function(t){var e=this,r="function"==typeof t?t:function(){return e.createElement(t)},i=[];if(null!==this._data){for(var o=0;o<this._data.length;o++){var a=this._data[o],s=Ve(Array.isArray(a)?a:[a,null],2),l=s[0],u=s[1];(h=r(l,o)).__data__=l,null!==u&&(h.__fromElements__=u),this._parent.appendChild(h),i.push(h)}return new n(i,null,this._parent,this._document)}for(o=0;o<this._elements.length;o++){var c=this._elements[o],h=r(l=c.__data__,o);c.appendChild(h),i.push(h)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=He(this,e,"m",r).call(this,"#"===t[0]?t:"#".concat(t),n);return i.attr("id",t),i},t.prototype.maybeAppendByClassName=function(t,n){var i=t.toString(),o=He(this,e,"m",r).call(this,"."===i[0]?i:".".concat(i),n);return o.attr("className",i),o},t.prototype.maybeAppendByName=function(t,n){var i=He(this,e,"m",r).call(this,'[name="'.concat(t,'"]'),n);return i.attr("name",t),i},t.prototype.data=function(t,e,r){var i,o;void 0===e&&(e=function(t){return t}),void 0===r&&(r=function(){return null});for(var a,s,l,u=[],c=[],h=new Set(this._elements),d=[],f=new Set,p=new Map(this._elements.map((function(t,n){return[e(t.__data__,n),t]}))),g=new Map(this._facetElements.map((function(t,n){return[e(t.__data__,n),t]}))),v=(a=this._elements,s=function(t){return r(t.__data__)},l=new Map,a.forEach((function(t){var e=s(t);l.has(e)||l.set(e,[]),l.get(e).push(t)})),l),m=0;m<t.length;m++){var y=t[m],b=e(y,m),x=r(y,m);if(p.has(b))(M=p.get(b)).__data__=y,M.__facet__=!1,c.push(M),h.delete(M),p.delete(b);else if(g.has(b)){(M=g.get(b)).__data__=y,M.__facet__=!0,c.push(M),g.delete(b)}else if(v.has(b)){var E=v.get(b);d.push([y,E]);try{for(var w=(i=void 0,Ge(E)),k=w.next();!k.done;k=w.next()){var M=k.value;h.delete(M)}}catch(t){i={error:t}}finally{try{k&&!k.done&&(o=w.return)&&o.call(w)}finally{if(i)throw i.error}}v.delete(b)}else if(p.has(x)){(M=p.get(x)).__toData__?M.__toData__.push(y):M.__toData__=[y],f.add(M),h.delete(M)}else u.push(y)}var S=[new n([],u,this._parent,this._document),new n(c,null,this._parent,this._document),new n(h,null,this._parent,this._document),new n([],d,this._parent,this._document),new n(f,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,S)},t.prototype.merge=function(t){var e=We(We([],Ve(this._elements),!1),Ve(t._elements),!1),r=We(We([],Ve(this._transitions),!1),Ve(t._transitions),!1);return new n(e,null,this._parent,this._document,void 0,r)},t.prototype.createElement=function(t){if(this._document)return this._document.createElement(t,{});var e=n.registry[t];return e?new e:function(t){throw new Error(t)}("Unknown node type: ".concat(t))},t.prototype.join=function(t,e,n,r,i){void 0===t&&(t=function(t){return t}),void 0===e&&(e=function(t){return t}),void 0===n&&(n=function(t){return t.remove()}),void 0===r&&(r=function(t){return t}),void 0===i&&(i=function(t){return t.remove()});var o=t(this._enter),a=e(this._update),s=n(this._exit),l=r(this._merge),u=i(this._split);return a.merge(o).merge(s).merge(l).merge(u)},t.prototype.remove=function(){for(var t=function(t){var n=e._elements[t],r=e._transitions[t];r?r.then((function(){return n.remove()})):n.remove()},e=this,r=0;r<this._elements.length;r++)t(r);return new n([],null,this._parent,this._document,void 0,this._transitions)},t.prototype.each=function(t){for(var e=0;e<this._elements.length;e++){var n=this._elements[e],r=n.__data__;t.call(n,r,e)}return this},t.prototype.attr=function(t,e){var n="function"!=typeof e?function(){return e}:e;return this.each((function(r,i){void 0!==e&&(this[t]=n.call(this,r,i))}))},t.prototype.style=function(t,e,n){void 0===n&&(n=!0);var r="function"==typeof e&&n?e:function(){return e};return this.each((function(n,i){void 0!==e&&(this.style[t]=r.call(this,n,i))}))},t.prototype.styles=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!0),this.each((function(n,r){var i=this;Object.entries(t).forEach((function(t){var o=Ve(t,2),a=o[0],s=o[1],l="function"==typeof s&&e?s:function(){return s};void 0!==s&&i.attr(a,l.call(i,n,r))}))}))},t.prototype.update=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.maybeUpdate=function(t,e){void 0===e&&(e=!0);var n="function"==typeof t&&e?t:function(){return t};return this.each((function(e,r){t&&this.update&&this.update(n.call(this,e,r))}))},t.prototype.transition=function(t){var e=this._transitions;return this.each((function(n,r){e[r]=t.call(this,n,r)}))},t.prototype.on=function(t,e){return this.each((function(){this.addEventListener(t,e)})),this},t.prototype.call=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.call.apply(t,We([this._parent,this],Ve(e),!1)),this},t.prototype.node=function(){return this._elements[0]},t.prototype.nodes=function(){return this._elements},t.prototype.transitions=function(){return this._transitions.filter((function(t){return!!t}))},t.prototype.parent=function(){return this._parent},n=t,e=new WeakSet,r=function(t,e){var r=this._elements[0],i=r.querySelector(t);if(i)return new n([i],null,this._parent,this._document);var o="string"==typeof e?this.createElement(e):e();return r.appendChild(o),new n([o],null,this._parent,this._document)},t.registry={g:jl,rect:Xl,circle:Dl,path:Hl,text:WF,ellipse:Il,image:zl,line:Vl,polygon:$l,polyline:ql,html:Fl},t}();function Mz(t){return new kz([t],null,t,t.ownerDocument)}function Sz(t){if(ae(t))return[t,t,t,t];if(Yt(t)){var e=t.length;if(1===e)return[t[0],t[0],t[0],t[0]];if(2===e)return[t[0],t[1],t[0],t[1]];if(3===e)return[t[0],t[1],t[2],t[1]];if(4===e)return t}return[0,0,0,0]}function Nz(t){var e=t.getLocalBounds(),n=Ve([e.min,e.max],2),r=Ve(n[0],2),i=r[0],o=r[1],a=Ve(n[1],2),s=a[0],l=a[1];return{x:i,y:o,width:s-i,height:l-o,left:i,bottom:l,top:o,right:s}}function Oz(t,e){var n=Ve(t,2),r=n[0],i=n[1],o=Ve(e,2),a=o[0],s=o[1];return r!==a&&i===s}function Tz(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function Cz(t,e,n){var r;void 0===n&&(n=!0);var i=e||(null===(r=t.match(/^([a-z][a-z0-9]+)/))||void 0===r?void 0:r[0])||"",o=t.replace(new RegExp("^(".concat(i,")")),"");return n?function(t){return t.toString().charAt(0).toLowerCase()+t.toString().slice(1)}(o):o}var Az=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function Pz(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach((function(t){var i=Ve(t,2),o=i[0],a=i[1];if("className"===o||"class"===o);else if(Az(o,"show")&&Az(Cz(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(Tz(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(Tz(e)),"")]=a;else if(!Az(o,"show")&&Az(o,e)!==n){var s=Cz(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function Rz(t,e){return Object.entries(t).reduce((function(t,n){var r=Ve(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(Tz(i))]=o,t}),{})}function Dz(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=Ve(t,2),a=o[0],s=o[1];e.includes(a)||(-1!==n.indexOf(a)?i[a]=s:r[a]=s)})),[r,i]}function Lz(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 _z(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=Ve([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 Iz=function(t,e){null!=e?t.replaceChildren?Array.isArray(e)?t.replaceChildren.apply(t,We([],Ve(e),!1)):t.replaceChildren(e):(t.innerHTML="",Array.isArray(e)?e.forEach((function(e){return t.appendChild(e)})):t.appendChild(e)):t.innerHTML=""};function jz(){zF(this,"hidden"!==this.attributes.visibility)}var Bz=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,ZF({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return je(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=VF(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&&jz.call(this)},e.prototype.update=function(t,e){var n;return this.attr(ZF({},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,Fe(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(_l),Fz=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"]]},zz=Fz,Gz=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},Vz=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},Wz=Vz;var Hz=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function Uz(t){var e=function(t){var e="default";if(qt(t)&&t instanceof Image)e="image";else if(Ut(t))e="symbol";else if(ne(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 $z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(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),l=s.symbol,u=s.size,c=void 0===u?16:u,h=Fe(s,["symbol","size"]),d=Uz(l);az(!!d,Mz(n),(function(t){t.maybeAppendByClassName("marker",d).attr("className","marker ".concat(d,"-marker")).call((function(t){if("image"===d){var n=2*c;t.styles({img:l,width:n,height:n,x:i-c,y:a-c})}else{n=c/2;var r=Ut(l)?l:e.getSymbol(l);t.styles(Be({d:null==r?void 0:r(i,a,n)},h))}}))}))},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}(Bz);function Yz(t,...e){return e.reduce(((t,e)=>n=>t(e(n))),t)}function qz(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}$z.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]]})),$z.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),$z.registerSymbol("line",Gz),$z.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),$z.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]]})),$z.registerSymbol("circle",Fz),$z.registerSymbol("point",zz),$z.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"]]})),$z.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"]]})),$z.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"]]})),$z.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),$z.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"]]})),$z.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"]]})),$z.registerSymbol("line",Gz),$z.registerSymbol("dot",Vz),$z.registerSymbol("dash",Wz),$z.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]]})),$z.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]]})),$z.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]]})),$z.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]]})),$z.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]]}));const Xz=Math.sqrt(50),Kz=Math.sqrt(10),Zz=Math.sqrt(2);function Qz(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>=Xz?10:o>=Kz?5:o>=Zz?2:1)*10**i:-(10**-i)/(o>=Xz?10:o>=Kz?5:o>=Zz?2:1)}const Jz=(t,e,n=5)=>{const r=[t,e];let i,o=0,a=r.length-1,s=r[o],l=r[a];return l<s&&([s,l]=[l,s],[o,a]=[a,o]),i=Qz(s,l,n),i>0?(s=Math.floor(s/i)*i,l=Math.ceil(l/i)*i,i=Qz(s,l,n)):i<0&&(s=Math.ceil(s*i)/i,l=Math.floor(l*i)/i,i=Qz(s,l,n)),i>0?(r[o]=Math.floor(s/i)*i,r[a]=Math.ceil(l/i)*i):i<0&&(r[o]=Math.ceil(s*i)/i,r[a]=Math.floor(l*i)/i),r};function tG(t){return!(ve(t)||(e=t,null===e)||Number.isNaN(t));var e}var eG={exports:{}},nG={exports:{}},rG=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))},iG=Array.prototype.concat,oG=Array.prototype.slice,aG=nG.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];rG(i)?e=iG.call(e,oG.call(i)):e.push(i)}return e};aG.wrap=function(t){return function(){return t(aG(arguments))}};var sG=nG.exports,lG={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},uG=sG,cG=Object.hasOwnProperty,hG=Object.create(null);for(var dG in lG)cG.call(lG,dG)&&(hG[lG[dG]]=dG);var fG=eG.exports={to:{},get:{}};function pG(t,e,n){return Math.min(Math.max(e,t),n)}function gG(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}fG.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=fG.get.hsl(t),n="hsl";break;case"hwb":e=fG.get.hwb(t),n="hwb";break;default:e=fG.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},fG.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;i[n]=parseInt(e.slice(o,o+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:cG.call(lG,e[1])?((i=lG[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=pG(i[n],0,255);return i[3]=pG(i[3],0,1),i},fG.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,pG(parseFloat(e[2]),0,100),pG(parseFloat(e[3]),0,100),pG(isNaN(n)?1:n,0,1)]}return null},fG.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,pG(parseFloat(e[2]),0,100),pG(parseFloat(e[3]),0,100),pG(isNaN(n)?1:n,0,1)]}return null},fG.to.hex=function(){var t=uG(arguments);return"#"+gG(t[0])+gG(t[1])+gG(t[2])+(t[3]<1?gG(Math.round(255*t[3])):"")},fG.to.rgb=function(){var t=uG(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},fG.to.rgb.percent=function(){var t=uG(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},fG.to.hsl=function(){var t=uG(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},fG.to.hwb=function(){var t=uG(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},fG.to.keyword=function(t){return hG[t.slice(0,3)]};var vG=E(eG.exports);function mG(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 yG(t){const e=vG.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*mG(a,o,e+1/3),255*mG(a,o,e),255*mG(a,o,e-1/3),i]}(r):null}const bG=(t,e)=>n=>t*(1-n)+e*n,xG=(t,e)=>"number"==typeof t&&"number"==typeof e?bG(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=yG(t),r=yG(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,EG=(t,e)=>{const n=bG(t,e);return t=>Math.round(n(t))};function wG({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function kG(t){return"object"==typeof t?t.valueOf():t}class MG extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=kG,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(wG({map:this.map,initKey:this.initKey},t))}has(t){return super.has(wG({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 SG{constructor(t){this.options=ke({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=ke({},this.options,t),this.rescale(t)}rescale(t){}}const NG=Symbol("defaultUnknown");function OG(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function TG(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let a=i.get(e);if(void 0===a){if(o!==NG)return o;a=n.push(e)-1,i.set(e,a)}return r[a%r.length]}function CG(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class AG extends SG{getDefaultOptions(){return{domain:[],range:[],unknown:NG}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&OG(this.domainIndexMap,this.getDomain(),this.domainKey),TG({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&OG(this.rangeIndexMap,this.getRange(),this.rangeKey),TG({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=CG(e),this.rangeKey=CG(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 AG(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 PG(t){return Math.round(1e12*t)/1e12}function RG(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:a,align:s}=t,l=e.length,u=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,l),[c,h]=n,d=h-c,f=d/(2/l*r+1-1/l*i),p=f*i/l,g=f-l*p,v=function(t){const e=Math.min(...t);return t.map((t=>t/e))}(u),m=g/v.reduce(((t,e)=>t+e)),y=new MG(e.map(((t,e)=>{const n=v[e]*m;return[t,a?Math.floor(n):n]}))),b=new MG(e.map(((t,e)=>{const n=v[e]*m+p;return[t,a?Math.floor(n):n]}))),x=Array.from(b.values()).reduce(((t,e)=>t+e)),E=c+(d-(x-x/l*i))*s;let w=a?Math.round(E):E;const k=new Array(l);for(let t=0;t<l;t+=1){k[t]=PG(w);const n=e[t];w+=b.get(n)}return{valueBandWidth:y,valueStep:b,adjustedRange:k}}class DG extends AG{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:NG,flex:[]}}constructor(t){super(t)}clone(){return new DG(this.options)}getStep(t){return void 0===this.valueStep?1:"number"==typeof this.valueStep?this.valueStep:void 0===t?Array.from(this.valueStep.values())[0]:this.valueStep.get(t)}getBandWidth(t){return void 0===this.valueBandWidth?1:"number"==typeof this.valueBandWidth?this.valueBandWidth:void 0===t?Array.from(this.valueBandWidth.values())[0]:this.valueBandWidth.get(t)}getRange(){return this.adjustedRange}getPaddingInner(){const{padding:t,paddingInner:e}=this.options;return t>0?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 RG(t);const{range:i,paddingOuter:o,paddingInner:a,round:s,align:l}=t;let u,c,h=i[0];const d=i[1]-h,f=2*o,p=r-a;u=d/Math.max(1,f+p),s&&(u=Math.floor(u)),h+=(d-u*(r-a))*l,c=u*(1-a),s&&(h=Math.round(h),c=Math.round(c));const g=new Array(r).fill(0).map(((t,e)=>h+e*u));return{valueStep:u,valueBandWidth:c,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 LG=(t,e,n)=>{let r,i,o=t,a=e;if(o===a&&n>0)return[o];let s=Qz(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<r;t+=1)i[t]=(o+t)*s}else{s=-s,o=Math.ceil(o*s),a=Math.floor(a*s),i=new Array(r=Math.ceil(a-o+1));for(let t=0;t<r;t+=1)i[t]=(o+t)/s}return i},_G=(t,e,n)=>{const[r,i]=t,[o,a]=e;let s,l;return r<i?(s=qz(r,i),l=n(o,a)):(s=qz(i,r),l=n(a,o)),Yz(l,s)},IG=(t,e,n)=>{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,l=a?[...e].reverse():e;for(let t=0;t<r;t+=1)i[t]=qz(s[t],s[t+1]),o[t]=n(l[t],l[t+1]);return e=>{const n=function(t,e,n,r){let i=n,o=r||t.length;for(;i<o;){const n=Math.floor((i+o)/2);t[n]>e?o=n:i=n+1}return i}(t,e,1,r)-1,a=i[n];return Yz(o[n],a)(e)}},jG=(t,e,n,r)=>(Math.min(t.length,e.length)>2?IG:_G)(t,e,r?EG:n);class BG extends SG{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:bG,tickCount:5}}map(t){return tG(t)?this.output(t):this.options.unknown}invert(t){return tG(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 Jz}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=e<t?e:t,r=t>e?t:e;return t=>Math.min(Math.max(n,t),r)}(r[0],r[i-1]):_e}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,a=jG(n.map(t),r,o,i);this.output=Yz(a,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=jG(i,r.map(t),bG);this.input=Yz(e,n,o)}}class FG extends BG{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:xG,tickMethod:LG,tickCount:5}}chooseTransforms(){return[_e,_e]}clone(){return new FG(this.options)}}var zG=function(t){function e(e){var n=this,r=e.style,i=Fe(e,["style"]);return(n=t.call(this,ke({},{type:"column"},Be({style:r},i)))||this).columnsGroup=new jl({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return je(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,")"),Mz(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(ZF({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(Rl),GG=function(t){function e(e){var n=this,r=e.style,i=Fe(e,["style"]);return(n=t.call(this,ke({},{type:"lines"},Be({style:r},i)))||this).linesGroup=n.appendChild(new jl),n.areasGroup=n.appendChild(new jl),n.render(),n}return je(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(ZF({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){Mz(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){Mz(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}(Rl);function VG(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map((function(t,e){return We([e===n?"M":"L"],Ve(t),!1)}));return e?r.reverse():r}function WG(t,e){if(void 0===e&&(e=!1),t.length<=2)return VG(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];Ne(o,n.slice(-2))||n.push.apply(n,We([],Ve(o),!1))}var a=yz(n);return e?a.unshift(We(["M"],Ve(t[r-1]),!1)):a.unshift(We(["M"],Ve(t[0]),!1)),a}function HG(t,e,n){var r=me(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function UG(t){return 0===t.length?[0,0]:[ee(ue(t,(function(t){return ee(t)||0}))),te(le(t,(function(t){return te(t)||0})))]}function $G(t){for(var e=me(t),n=e[0].length,r=Ve([Array(n).fill(0),Array(n).fill(0)],2),i=r[0],o=r[1],a=0;a<e.length;a+=1)for(var s=e[a],l=0;l<n;l+=1)s[l]>=0?(s[l]+=i[l],i[l]=s[l]):(s[l]+=o[l],o[l]=s[l]);return e}var YG=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 je(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=me(t);return ae(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?$G(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=Ve(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=Pz(this.attributes,"area"),a=Pz(this.attributes,"line"),s=this.containerShape.width,l=this.data;if(0===l[0].length)return{lines:[],areas:[]};var u=this.scales,c=function(t,e){var n,r=e.x,i=e.y,o=Ve(i.getOptions().range||[0,0],2),a=o[0],s=o[1];return s>a&&(n=Ve([a,s],2),s=n[0],a=n[1]),t.map((function(t){return t.map((function(t,e){return[r.map(e),oe(i.map(t),s,a)]}))}))}(l,{x:u.x,y:u.y}),h=[];if(o){var d=this.baseline;h=r?i?function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=t[i],a=WG(o),s=void 0;if(0===i)s=HG(a,e,n);else{var l=WG(t[i-1],!0),u=o[0];l[0][0]="L",s=We(We(We([],Ve(a),!1),Ve(l),!1),[We(["M"],Ve(u),!1),["Z"]],!1)}r.push(s)}return r}(c,s,d):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=VG(t[i]),a=void 0;if(0===i)a=HG(o,e,n);else{var s=VG(t[i-1],!0);s[0][0]="L",a=We(We(We([],Ve(o),!1),Ve(s),!1),[["Z"]],!1)}r.push(a)}return r}(c,s,d):function(t,e,n,r){return t.map((function(t){return HG(e?WG(t):VG(t),n,r)}))}(c,i,s,d)}return{lines:c.map((function(e,n){return Be({stroke:t.getColor(n),d:i?WG(e):VG(e)},a)})),areas:h.map((function(e,n){return Be({d:e,fill:t.getColor(n)},o)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=Pz(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=$G(s));var l=this.createScales(s),u=l.x,c=l.y,h=Ve(UG(s),2),d=h[0],f=h[1],p=new FG({domain:[0,f-(d>0?0:d)],range:[0,a*o]}),g=u.getBandWidth(),v=this.rawData;return{columns:s.map((function(n,i){return n.map((function(n,o){var a=g/s.length;return Be(Be({fill:t.getColor(i)},e),r?{x:u.map(o),y:c.map(n),width:g,height:p.map(v[i][o])}:{x:u.map(o)+a*i,y:n>=0?c.map(n):c.map(0),width:a,height:p.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)?Mz(n).select(r):Mz(n).append(i)).attr("className","container").node();var o=t.type,a=t.x,s=t.y,l="spark".concat(o),u=Be({x:a,y:s},"line"===o?this.linesStyle:this.columnsStyle);Mz(e).selectAll(".spark").data([o]).join((function(t){return t.append((function(t){return"line"===t?new GG({className:l,style:u}):new zG({className:l,style:u})})).attr("className","spark ".concat(l))}),(function(t){return t.update(u)}),(function(t){return t.remove()}))},e.prototype.getColor=function(t){var e=this.attributes.color;return Yt(e)?e[t%e.length]:Ut(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,l=r.spacing,u=this.containerShape,c=u.width,h=u.height,d=Ve(UG(t),2),f=d[0],p=d[1],g=new FG({domain:[null!==(e=s[0])&&void 0!==e?e:f,null!==(n=s[1])&&void 0!==n?n:p],range:[h,h*(1-o)]});return"line"===i?{type:i,x:new FG({domain:[0,t[0].length-1],range:[0,c]}),y:g}:{type:i,x:new DG({domain:t[0].map((function(t,e){return e})),range:[0,c],paddingInner:l,paddingOuter:l/2,align:.5}),y:g}},e.tag="sparkline",e}(Bz);function qG(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=Ve(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,Be(Be({},t[e]),n)]:[e,n]})))}function XG(t,e){t?t.finished.then(e):e()}function KG(t,e){"update"in t?t.update(e):t.attr(e)}function ZG(t,e,n){return 0===e.length?null:n?t.animate(e,n):(KG(t,{style:e.slice(-1)[0]}),null)}function QG(t,e,n){var r={},i={};return Object.entries(e).forEach((function(e){var n=Ve(e,2),o=n[0],a=n[1];if(!$t(a)){var s=t.style[o]||t.parsedStyle[o]||0;s!==a&&(r[o]=s,i[o]=a)}})),n?ZG(t,[r,i],Be({fill:"both"},n)):(KG(t,i),null)}function JG(t,e){return t.style.opacity||(t.style.opacity=1),QG(t,{opacity:0},e)}var tV={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},eV={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},nV={x:0,y:0,orientation:"horizontal",showLabel:!0,type:"start"},rV=XF({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),iV=XF({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),oV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(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,l=t.orientation,u=Fe(t,["x","y","size","radius","orientation"]),c=o,h=2.4*c,d=Mz(e).maybeAppendByClassName(iV.iconRect,"rect").styles(Be(Be({},u),{width:c,height:h,radius:s,x:n-c/2,y:r-h/2,transformOrigin:"center"})),f=n+1/3*c-c/2,p=n+2/3*c-c/2,g=r+1/4*h-h/2,v=r+3/4*h-h/2;d.maybeAppendByClassName("".concat(iV.iconLine,"-1"),"line").styles(Be({x1:f,x2:f,y1:g,y2:v},u)),d.maybeAppendByClassName("".concat(iV.iconLine,"-2"),"line").styles(Be({x1:p,x2:p,y1:g,y2:v},u)),"vertical"===l&&(d.node().style.transform="rotate(90)")},e}(Bz),aV=function(t){function e(e){return t.call(this,e,nV)||this}return je(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.x,i=n.y,o=n.showLabel,a=Pz(this.attributes,"label"),s=a.x,l=void 0===s?0:s,u=a.y,c=void 0===u?0:u,h=a.transform,d=a.transformOrigin,f=Ve(Dz(Fe(a,["x","y","transform","transformOrigin"]),[]),2),p=f[0],g=f[1],v=Mz(t).maybeAppendByClassName(iV.labelGroup,"g").styles(g),m=Be(Be({},eV),p),y=m.text,b=Fe(m,["text"]);az(!!o,v,(function(t){e.label=t.maybeAppendByClassName(iV.label,"text").styles(Be(Be({},b),{x:r+l,y:i+c,transform:h,transformOrigin:d,text:"".concat(y)})),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=Be(Be({x:n,y:r,orientation:i},tV),Pz(this.attributes,"icon")),s=this.attributes.iconShape,l=void 0===s?function(){return new oV({style:a})}:s;Mz(t).maybeAppendByClassName(iV.iconGroup,"g").selectAll(iV.icon.class).data([l]).join((function(t){return t.append("string"==typeof l?l:function(){return l(o)}).attr("className",iV.icon.name)}),(function(t){return t.update(a)}),(function(t){return t.remove()}))},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(Bz),sV=function(t){function e(e){var n=t.call(this,e,Be(Be(Be({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},Rz(nV,"handle")),Rz(tV,"handleIcon")),Rz(eV,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(iz(e));var r=n.availableSpace,i=r.x,o=r.y,a=n.getBBox(),s=a.x,l=a.y;n.selectionStartPos=n.getRatio(n.prevPos-n.getOrientVal([i,o])-n.getOrientVal([+s,+l])),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(iz(t)),s=a-n.prevPos;if(s){var l=n.getRatio(s);switch(n.target){case"start":r&&n.setValuesOffset(l);break;case"end":r&&n.setValuesOffset(0,l);break;case"selection":r&&n.setValuesOffset(l,l);break;case"track":if(!i)return;n.selectionWidth+=l,"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 Rs("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 je(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=Pz(this.attributes,"sparkline");return Be(Be({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=Ve(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=Ve(Sz(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(rV.selection.class).each((function(n,r){QG(this,e[r],t)}))},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&QG(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&QG(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=Pz(this.attributes,"track");this.trackShape=Mz(t).maybeAppendByClassName(rV.track,"rect").styles(Be(Be({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=Mz(t).maybeAppendByClassName(rV.brushArea,"rect").styles(Be({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;az("horizontal"===n.orientation,Mz(t).maybeAppendByClassName(rV.sparklineGroup,"g"),(function(t){var n=Be(Be({},e.sparklineStyle),{x:r,y:i});t.maybeAppendByClassName(rV.sparkline,(function(){return new YG({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(rV.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 aV({style:e.getHandleStyle(n)})})).each((function(t){var e=t.type;this.attr("class","".concat(rV.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=Mz(t).maybeAppendByClassName(rV.foreground,"g");var a=Pz(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(Be(Be({},a),{transform:"translate(".concat(n,", ").concat(r,")")}))},l=this;this.foregroundGroup.selectAll(rV.selection.class).data("value"===i?[]:this.calcSelectionArea().map((function(t,e){return{style:Be({},t),index:e,show:"select"===o?1===e:1!==e}})),(function(t){return t.index})).join((function(t){return t.append("rect").attr("className",rV.selection.name).call(s).each((function(t,e){var n=this;1===e?(l.selectionShape=Mz(this),this.on("pointerdown",(function(t){n.attr("cursor","grabbing"),l.onDragStart("selection")(t)})),l.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),l.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),l.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",l.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=Ve(this.range,2),i=r[0],o=r[1],a=Ve(this.getValues().map((function(t){return vz(t,e)})),2),s=a[0],l=a[1],u=Ve(((Array.isArray(t)?t:[s,null!=t?t:l])||[s,l]).map((function(t){return vz(t,e)})),2),c=u[0],h=u[1];if("value"===this.attributes.type)return[0,oe(h,i,o)];c>h&&(c=(n=Ve([h,c],2))[0],h=n[1]);var d=h-c;return d>o-i?[i,o]:c<i?s===i&&l===h?[i,h]:[i,d+i]:h>o?l===o&&s===c?[c,o]:[o-d,o]:[c,h]},e.prototype.calcSelectionArea=function(t){var e=Ve(this.clampValues(t),2),n=e[0],r=e[1],i=this.availableSpace,o=i.x,a=i.y,s=i.width,l=i.height;return this.getOrientVal([[{y:a,height:l,x:o,width:n*s},{y:a,height:l,x:n*s+o,width:(r-n)*s},{y:a,height:l,x:r*s,width:(1-r)*s}],[{x:o,width:s,y:a,height:n*l},{x:o,width:s,y:n*l+a,height:(r-n)*l},{x:o,width:s,y:r*l,height:(1-r)*l}]])},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=Ve(this.clampValues(),2),l=s[0],u=s[1],c="start"===t?-e:e,h=("start"===t?l:u)*this.getOrientVal([o,a])+c;return{x:r+this.getOrientVal([h,o/2]),y:i+this.getOrientVal([a/2,h])}},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=Pz(this.attributes,"handle"),l=Pz(s,"label"),u=s.spacing,c=this.getHandleSize(),h=this.clampValues(),d=o("start"===t?h[0]:h[1]),f=new WF({style:Be(Be(Be({},l),this.inferTextStyle(t)),{text:d})}),p=f.getBBox(),g=p.width,v=p.height;if(f.destroy(),!a){if("value"===r)return{text:d,x:0,y:-v-u};var m=u+c+("horizontal"===i?g/2:0);return(e={text:d})["horizontal"===i?"x":"y"]="start"===t?-m:m,e}var y=0,b=0,x=this.availableSpace,E=x.width,w=x.height,k=this.calcSelectionArea()[1],M=k.x,S=k.y,N=k.width,O=k.height,T=u+c;if("horizontal"===i){var C=T+g/2;if("start"===t)y=M-T-g>0?-C:C;else y=E-M-N-T>g?C:-C}else{var A=v+T;b="start"===t?S-c>v?-A:T:w-(S+O)-c>v?A:-T}return{x:y,y:b,text:d}},e.prototype.getHandleLabelStyle=function(t){var e=Pz(this.attributes,"handleLabel");return Be(Be(Be({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=Pz(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return Be({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),l=s.x,u=s.y,c=this.calcHandleText(t),h=i;return!i&&o&&(h=!!this.target),Be(Be(Be({},Rz(this.getHandleIconStyle(),"icon")),Rz(Be(Be({},this.getHandleLabelStyle(t)),c),"label")),{transform:"translate(".concat(l+n,", ").concat(u+r,")"),orientation:a,showLabel:h,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=Ve(t,2),n=e[0],r=e[1];return"horizontal"===this.attributes.orientation?n:r},e.prototype.setValuesOffset=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=!1);var r=this.attributes.type,i=Ve(this.getValues(),2),o=[i[0]+("range"===r?t:0),i[1]+e].sort();n?this.setValues(o):this.innerSetValues(o,!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 Rs(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,!0)}},e.tag="slider",e}(Bz),lV={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 Hl({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:[]};ke({},lV,{style:{type:"arc"}}),ke({},lV,{style:{}});var uV=XF({mainGroup:"main-group",gridGroup:"grid-group",grid:"grid",lineGroup:"line-group",line:"line",tickGroup:"tick-group",tick:"tick",tickItem:"tick-item",labelGroup:"label-group",label:"label",labelItem:"label-item",titleGroup:"title-group",title:"title",lineFirst:"line-first",lineSecond:"line-second"},"axis"),cV=XF({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function hV(t){return t.reduce((function(t,e,n){return t.push(We([0===n?"M":"L"],Ve(e),!1)),t}),[])}function dV(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 hV(t);if(!o)return[];var a=pz(t[0],o),s=n?0:1;return t.reduce((function(t,e,n){return 0===n?t.push(We(["M"],Ve(e),!1)):t.push(We(["A",a,a,0,0,s],Ve(e),!1)),t}),[])}(t,e,n):hV(t)}function fV(t,e,n){var r=n.type,i=n.connect,o=n.center,a=n.closed?[["Z"]]:[],s=Ve([dV(t,n),dV(e.slice().reverse(),n,!0)],2),l=s[0],u=s[1],c=Ve([t[0],e.slice(-1)[0]],2),h=c[0],d=c[1],f=function(t,e){return[l,t,u,e,a].flat()};if("line"===i||"surround"===r)return f([We(["L"],Ve(d),!1)],[We(["L"],Ve(h),!1)]);if(!o)throw new Error("Arc grid need to specified center");var p=Ve([pz(d,o),pz(h,o)],2),g=p[0],v=p[1];return f([We(["A",g,g,0,0,1],Ve(d),!1),We(["L"],Ve(d),!1)],[We(["A",v,v,0,0,0],Ve(h),!1),We(["L"],Ve(h),!1)])}var pV=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Fe(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=Ve(e,1)[0];return Be(Be({},t),{points:We(We([],Ve(e),!1),[n],!1)})})):n}(t),i=Mz(e).maybeAppendByClassName(cV.lineGroup,"g"),o=Mz(e).maybeAppendByClassName(cV.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:dV(t.points,n)}}));return t.selectAll(cV.line.class).data(a,(function(t){return t.id})).join((function(t){return t.append("path").each((function(t,e){var n=YF(Ez(Be({d:t.d},r)),[t,e,a]);this.attr(Be({class:cV.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))}))}),(function(t){return t.transition((function(t,e){return QG(this,YF(Ez(Be({d:t.d},r)),[t,e,a]),i.update)}))}),(function(t){return t.transition((function(){var t=this,e=JG(this,i.exit);return XG(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]},l=[],u=0;u<e.length-1;u++){var c=Ve([e[u].points,e[u+1].points],2),h=fV(c[0],c[1],n);l.push({d:h,fill:s(u)})}return t.selectAll(cV.region.class).data(l,(function(t,e){return e})).join((function(t){return t.append("path").each((function(t,e){var n=YF(t,[t,e,l]);this.attr(n)})).attr("className",cV.region.name)}),(function(t){return t.transition((function(t,e){return QG(this,YF(t,[t,e,l]),r.update)}))}),(function(t){return t.transition((function(){var t=this,e=JG(this,r.exit);return XG(e,(function(){return t.remove()})),e}))})).transitions()}(o,r,t);return We(We([],Ve(a),!1),Ve(s),!1)},e}(Bz);function gV(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var n=Ve(t,2);return[n[0],YF(n[1],e)]})))}function vV(t,e){return e&&Ut(e)?t.filter(e):t}function mV(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}function yV(t,e){if("linear"===e.type){var n=Ve(e.startPos,2),r=n[0],i=n[1],o=Ve(e.endPos,2),a=Ve([o[0]-r,o[1]-i],2);return gz([a[0],a[1]])}var s=HF(mV(t,e));return[-Math.sin(s),Math.cos(s)]}function bV(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(yV(t,n),"positive"!==e)}function xV(t,e){return bV(t,e.labelDirection,e)}function EV(t,e){return"linear"===e.type?function(t,e){var n=Ve(e.startPos,2),r=n[0],i=n[1],o=Ve(e.endPos,2),a=Ve([o[0]-r,o[1]-i],2);return[r+a[0]*t,i+a[1]*t]}(t,e):function(t,e){var n=e.radius,r=Ve(e.center,2),i=r[0],o=r[1],a=HF(mV(t,e));return[i+n*Math.cos(a),o+n*Math.sin(a)]}(t,e)}function wV(t){return 0===yV(0,t)[1]}function kV(t){return 0===yV(0,t)[0]}function MV(t,e){return e-t==360}function SV(t,e,n,r,i){var o=e-t,a=Ve([i,i],2),s=a[0],l=a[1],u=Ve([HF(t),HF(e)],2),c=u[0],h=u[1],d=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},f=Ve(d(c),2),p=f[0],g=f[1],v=Ve(d(h),2),m=v[0],y=v[1];if(MV(t,e)){var b=Ve(d((h+c)/2),2);return[["M",p,g],["A",s,l,0,1,0,b[0],b[1]],["A",s,l,0,1,0,m,y]]}var x=o>180?1:0,E=t>e?0:1;return"M".concat(p,",").concat(g,",A").concat(s,",").concat(l,",0,").concat(x,",").concat(E,",").concat(m,",").concat(y)}function NV(t,e,n,r){var i=e.startAngle,o=e.endAngle,a=e.center,s=e.radius;return t.selectAll(uV.line.class).data([{d:SV.apply(void 0,We(We([i,o],Ve(a),!1),[s],!1))}],(function(t,e){return e})).join((function(t){return t.append("path").attr("className",uV.line.name).styles(e).styles({d:function(t){return t.d}})}),(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=lz(e,n),s=Math.ceil(+o/16),l=new Array(s).fill(0).map((function(t,e,n){return{__keyframe_data__:a(e/(n.length-1))}}));return t.animate(l,Be({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return We(We([n,r],Ve(i),!1),[o],!1)}(this),We(We([i,o],Ve(a),!1),[s],!1),r.update);if(e){var n=function(){var e=Oe(t.attributes,"__keyframe_data__");t.style.d=SV.apply(void 0,We([],Ve(e),!1))};e.onframe=n,e.onfinish=n}return e})).styles(e)}),(function(t){return t.remove()})).styles(n).transitions()}function OV(t){var e=Ve(t,2),n=Ve(e[0],2),r=n[0],i=n[1],o=Ve(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function TV(t,e,n,r){var i=e.showTrunc,o=e.startPos,a=e.endPos,s=e.truncRange,l=e.lineExtension,u=Ve([o,a],2),c=Ve(u[0],2),h=c[0],d=c[1],f=Ve(u[1],2),p=f[0],g=f[1],v=Ve(l?function(t,e,n){void 0===n&&(n=[0,0]);var r=Ve([t,e,n],3),i=Ve(r[0],2),o=i[0],a=i[1],s=Ve(r[1],2),l=s[0],u=s[1],c=Ve(r[2],2),h=c[0],d=c[1],f=Ve([l-o,u-a],2),p=f[0],g=f[1],v=Math.sqrt(Math.pow(p,2)+Math.pow(g,2)),m=Ve([-h/v,d/v],2),y=m[0],b=m[1];return[y*p,y*g,b*p,b*g]}(o,a,l):new Array(4).fill(0),4),m=v[0],y=v[1],b=v[2],x=v[3],E=function(e){return t.selectAll(uV.line.class).data(e,(function(t,e){return e})).join((function(t){return t.append("line").attr("className",(function(t){return"".concat(uV.line.name," ").concat(t.className)})).styles(n).transition((function(t){return QG(this,OV(t.line),!1)}))}),(function(t){return t.styles(n).transition((function(t){return QG(this,OV(t.line),r.update)}))}),(function(t){return t.remove()})).transitions()};if(!i||!s)return E([{line:[[h+m,d+y],[p+b,g+x]],className:uV.line.name}]);var w=Ve(s,2),k=w[0],M=w[1],S=p-h,N=g-d,O=Ve([h+S*k,d+N*k],2),T=O[0],C=O[1],A=Ve([h+S*M,d+N*M],2),P=A[0],R=A[1],D=E([{line:[[h+m,d+y],[T,C]],className:uV.lineFirst.name},{line:[[P,R],[p+b,g+x]],className:uV.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),D}function CV(t,e,n){var r,i=e.type,o=Pz(e,"line");return r="linear"===i?TV(t,e,mz(o,"arrow"),n):NV(t,e,mz(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,a=n.showTrunc,s=n.lineArrow,l=n.lineArrowOffset,u=n.lineArrowSize;if(i="arc"===e?t.select(uV.line.class):a?t.select(uV.lineSecond.class):t.select(uV.line.class),!o||!s||"arc"===n.type&&MV(n.startAngle,n.endAngle)){var c=i.node();c&&(c.style.markerEnd=void 0)}else{var h=oz(s);h.attr(r),wz(h,u),i.style("markerEnd",h).style("markerEndOffset",-l)}}(t,i,e,o),r}function AV(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function PV(t,e){var n=e.gridLength;return t.map((function(t,r){var i=t.value,o=Ve(EV(i,e),2),a=o[0],s=o[1],l=Ve(uz(function(t,e){return bV(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[a,s],[a+l[0],s+l[1]]]}}))}function RV(t,e,n,r){var i=Pz(n,"grid"),o=i.type,a=i.areaFill,s=AV(n),l=vV(e,n.gridFilter),u="segment"===o?PV(l,n):function(t,e){var n=e.gridControlAngles,r=AV(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=Ve(r,2),o=i[0],a=i[1];return t.map((function(t,r){var i=Ve(EV(t.value,e),2),s=i[0],l=i[1],u=Ve([s-o,l-a],2),c=u[0],h=u[1],d=[];return n.forEach((function(t){var e=HF(t),n=Ve([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=c*r-h*i+o,l=c*i+h*r+a;d.push([s,l])})),{points:d,id:r}}))}(l,n),c=Be(Be({},i),{center:s,areaFill:Ut(a)?l.map((function(t,e){return YF(a,[t,e,l])})):a,animate:r,data:u});return t.selectAll(uV.grid.class).data([1]).join((function(t){return t.append((function(){return new pV({style:c})})).attr("className",uV.grid.name)}),(function(t){return t.transition((function(){return this.update(c)}))}),(function(t){return t.remove()})).transitions()}var DV=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,l=Math.cos(t),u=Math.sin(t),c=e-e*l+n*u,h=n-e*u-n*l;return[[l*i-u*s+c,u*i+l*s+h],[l*a-u*s+c,u*a+l*s+h],[l*i-u*o+c,u*i+l*o+h],[l*a-u*o+c,u*a+l*o+h]]},t.prototype.set=function(t,e,n,r){return n<t?(this.x2=t,this.x1=n):(this.x1=t,this.x2=n),r<e?(this.y2=e,this.y1=r):(this.y1=e,this.y2=r),this},t.prototype.defined=function(t){return this[t]!==Number.MAX_VALUE&&this[t]!==-Number.MAX_VALUE},t}();function LV(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getBounds(),i=Ve(r.min,2),o=i[0],a=i[1],s=Ve(r.max,2),l=s[0],u=s[1],c=t.getBBox(),h=c.width,d=c.height,f=0,p=0,g=o,v=a,m=ez(t);if(m){d-=1.5;var y=m.style.textAlign,b=m.style.textBaseline;"center"===y?g=(o+l)/2:"right"!==y&&"end"!==y||(g=l),"middle"===b?v=(a+u)/2:"bottom"===b&&(v=u)}var x=Ve(Sz(e),4),E=x[0],w=void 0===E?0:E,k=x[1],M=void 0===k?0:k,S=x[2],N=void 0===S?w:S,O=x[3],T=new DV((f+=o)-(void 0===O?M:O),(p+=a)-w,f+h+M,p+d+N);return t.setEulerAngles(n),T.rotatedPoints(HF(n),g,v)}function _V(t,e){return e[0]<=Math.max(t[0][0],t[1][0])&&e[0]<=Math.min(t[0][0],t[1][0])&&e[1]<=Math.max(t[0][1],t[1][1])&&e[1]<=Math.min(t[0][1],t[1][1])}function IV(t,e,n){var r=(e[1]-t[1])*(n[0]-e[0])-(e[0]-t[0])*(n[1]-e[1]);return 0===r?0:r<0?2:1}function jV(t,e){return e.every((function(e){return function(t,e){var n=t.length;if(n<3)return!1;var r,i,o,a,s,l,u=[e,[9999,e[1]]],c=0,h=0;do{var d=[t[h],t[(h+1)%n]];if(i=u,o=void 0,a=void 0,s=void 0,l=void 0,o=IV((r=d)[0],r[1],i[0]),a=IV(r[0],r[1],i[1]),s=IV(i[0],i[1],r[0]),l=IV(i[0],i[1],r[1]),o!==a&&s!==l||0===o&&_V(r,i[0])||0===a&&_V(r,i[1])||0===s&&_V(i,r[0])||0===l&&_V(i,r[1])){if(0===IV(d[0],e,d[1]))return _V(d,e);c++}h=(h+1)%n}while(0!==h);return!!(1&c)}(t,e)}))}function BV(t,e){return[[t[0],t[1],t[2],t[3]],[t[2],t[3],t[4],t[5]],[t[4],t[5],t[6],t[7]],[t[6],t[7],t[0],t[1]]].some((function(t){return function(t,e){var n=Ve(t,4),r=n[0],i=n[1],o=n[2],a=n[3],s=Ve(e,4),l=s[0],u=s[1],c=o-r,h=a-i,d=s[2]-l,f=s[3]-u,p=c*f-d*h;if(0===p)return!1;var g=p>0,v=r-l,m=i-u,y=c*m-h*v;if(y<0===g)return!1;var b=d*m-f*v;return b<0!==g&&y>p!==g&&b>p!==g}(e,t)}))}function FV(t,e,n){var r,i,o=e.crossPadding,a=new Set,s=null,l=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=Ve(o,2),l=s[0],u=s[1],c="negative"===r?0:i,h=-a-c,d=a+c,f=Ve(Sz(e),4),p=f[0],g=f[1],v=f[2],m=f[3];return new DV(l+h-m,u+h-p,l+d+g,u+d+v)}var y=Ve(t.startPos,2),b=y[0],x=y[1],E=Ve(t.endPos,2),w=E[0],k=E[1],M=Ve(kV(t)?[-e,0,e,0]:[0,e,0,-e],4),S=M[0],N=M[1],O=M[2],T=M[3],C=uz(xV(0,t),i),A=new DV(b,x,w,k);return A.x1+=T,A.y1+=S,A.x2+=N+C[0],A.y2+=O+C[1],A}(e,o),u=function(t){return!l||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,a=t.y2;return jV([[r,o],[i,o],[i,a],[r,a]],LV(e,n))}(l,t)},c=function(t,e){return!t||!t.firstChild||!function(t,e,n){var r,i,o=LV(t,n).flat(1),a=LV(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 l=Ge(s),u=l.next();!u.done;u=l.next())if(BV(a,u.value))return!0}catch(t){r={error:t}}finally{try{u&&!u.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return!1}(t.firstChild,e.firstChild,Sz(n))};try{for(var h=Ge(t),d=h.next();!d.done;d=h.next()){var f=d.value;u(f)?!s||c(s,f)?s=f:(a.add(s),a.add(f)):a.add(f)}}catch(t){r={error:t}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(r)throw r.error}}return Array.from(a)}function zV(t,e){return void 0===e&&(e={}),$t(t)?0:"number"==typeof t?t:Math.floor(JF(t,e))}var GV=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter((function(t,e){return!(e%r)||(FF(t),!1)}))};var VV=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,l,u,c=GV,h=function(t){return t.forEach(r.show),t},d=2,f=t.slice(),p=t.slice(),g=Math.min.apply(Math,We([1],Ve(t.map((function(t){return t.getBBox().width}))),!1));if("linear"===n.type&&(wV(n)||kV(n))){var v=Nz(t[0]).left,m=Nz(t[i-1]).right,y=Math.abs(m-v)||1;d=Math.max(Math.floor(i*g/y),d)}for(o&&(s=f.splice(0,1)[0]),a&&(l=f.splice(-1,1)[0],f.reverse()),h(f);d<t.length&&FV((u=l?We(We([l],Ve(p),!1),[s],!1):We([s],Ve(p),!1),u.filter(QF)),n,null==e?void 0:e.margin).length;){if(l&&!s&&d%2==0)f.splice(0,1).forEach(r.hide);else if(l&&s){f.splice(0,1).forEach(r.hide)}p=c(h(f),{seq:d}),d++}}}],["rotate",function(t,e,n,r){var i,o,a=e.optionalAngles,s=void 0===a?[0,45,90]:a,l=e.margin,u=e.recoverWhenFailed,c=void 0===u||u,h=t.map((function(t){return t.getLocalEulerAngles()})),d=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.rotate(t,+i)}))};try{for(var f=Ge(s),p=f.next();!p.done;p=f.next()){if(d(p.value),FV(t,n,l).length<1)return}}catch(t){i={error:t}}finally{try{p&&!p.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}c&&d(h)}],["ellipsis",function(t,e,n,r){if(!(t.length<=1)){var i=e.suffix,o=void 0===i?"...":i,a=e.minLength,s=e.maxLength,l=void 0===s?1/0:s,u=e.step,c=void 0===u?" ":u,h=e.margin,d=void 0===h?[0,0,0,0]:h,f=tz(r.getTextShape(t[0])),p=zV(c,f),g=a?zV(a,f):p,v=zV(l,f);($t(v)||v===1/0)&&(v=Math.max.apply(null,t.map((function(t){return t.getBBox().width}))));var m=t.slice(),y=Ve(d,4);y[0],y[1],y[2],y[3];for(var b=function(e){if(m.forEach((function(t){r.ellipsis(r.getTextShape(t),e,o)})),(m=FV(t,n,d)).length<1)return{value:void 0}},x=v;x>g+p;x-=p){var E=b(x);if("object"==typeof E)return E.value}}}],["wrap",function(t,e,n,r){var i=e.wordWrapWidth,o=void 0===i?50:i,a=e.maxLines,s=void 0===a?3:a,l=e.recoverWhenFailed,u=void 0===l||l,c=e.margin,h=void 0===c?[0,0,0,0]:c,d=t.map((function(t){return t.attr("maxLines")||1})),f=Math.min.apply(Math,We([],Ve(d),!1)),p=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&wV(t)?"negative"===n?"bottom":"top":"middle"}(n),g=function(e){return t.forEach((function(t,n){var i=Array.isArray(e)?e[n]:e;r.wrap(t,o,i,p)}))};if(!(f>s)){for(var v=f;v<=s;v++)if(g(v),FV(t,n,h).length<1)return;u&&g(d)}}]]);function WV(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce((function(t,e){return t*function(t){return"positive"===t?-1:1}(e)}),1)}function HV(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)}function UV(t,e){var n=Ve(t,2),r=n[0],i=n[1],o=Ve(e,2),a=o[0],s=o[1],l=Ve([r*a+i*s,r*s-i*a],2),u=l[0],c=l[1];return Math.atan2(c,u)}function $V(t,e,n){var r,i=n.labelAlign;if(null===(r=e.style.transform)||void 0===r?void 0:r.includes("rotate"))return e.getLocalEulerAngles();var o=xV(t.value,n),a=yV(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return sz(e,-90,90)||(e+=180),e}(UF("perpendicular"===i?UV([1,0],o):UV([a[0]<0?-1:1,0],a)))}function YV(t,e,n){var r=n.type,i=n.labelAlign,o=xV(t,n),a=HV(e),s=HV(UF(UV([1,0],o))),l="center",u="middle";return"linear"===r?[90,270].includes(s)&&0===a?(l="center",u=1===o[1]?"top":"bottom"):s%180||![90,270].includes(a)?0===s?(sz(a,0,90,!1,!0)||sz(a,0,90)||sz(a,270,360))&&(l="start"):90===s?sz(a,0,90,!1,!0)?l="start":(sz(a,90,180)||sz(a,270,360))&&(l="end"):270===s?sz(a,0,90,!1,!0)?l="end":(sz(a,90,180)||sz(a,270,360))&&(l="start"):180===s&&(90===a?l="start":(sz(a,0,90)||sz(a,270,360))&&(l="end")):l="center":"parallel"===i?u=sz(s,0,180,!0)?"top":"bottom":"horizontal"===i?sz(s,90,270,!1)?l="end":(sz(s,270,360,!1)||sz(s,0,90))&&(l="start"):"perpendicular"===i&&(l=sz(s,90,270)?"end":"start"),{textAlign:l,textBaseline:u}}function qV(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,a=n.labelDirection,s=n.labelSpacing,l=e.indexOf(t),u=YF(s,[t,l,e]),c=Ve([xV(t.value,n),WV(a,o)],2),h=Ve(cz(uz(c[0],u+(1===c[1]?YF(r?i:0,[t,l,e]):0)),EV(t.value,n)),2);return{x:h[0],y:h[1]}}function XV(t,e){"text"===t.nodeName&&t.attr(e)}function KV(t){!function(t,e,n){var r=e.labelOverlap,i=void 0===r?[]:r;i.length&&i.forEach((function(r){var i=r.type,o=VV.get(i);(function(t,e,n){return!(e.labelOverlap.length<1)&&("hide"===n?!function(t){for(var e=t;e;){if("offscreen"===e.className)return!0;e=e.parent}return!1}(t[0]):"rotate"===n?!t.some((function(t){var e;return!!(null===(e=t.attr("transform"))||void 0===e?void 0:e.includes("rotate"))})):"ellipsis"!==n&&"wrap"!==n||t.filter((function(t){return t.querySelector("text")})).length>1)})(t,e,i)&&(null==o||o(t,r,e,n))}))}(this.node().childNodes,t,{hide:FF,show:BF,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=YV(e.__data__.value,t,n),i=e.querySelector(uV.labelItem.class);i&&XV(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&rz(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"),nz(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector("text")}})}function ZV(t,e,n,r,i){var o=n.indexOf(e),a=Mz(t).append(function(t,e,n,r){var i=r.labelFormatter;return Ut(i)?function(){return oz(YF(i,[t,e,n,xV(t.value,r)]))}:function(){return oz(t.label||"")}}(e,o,n,i)).attr("className",uV.labelItem.name).node(),s=Ve(Dz(gV(r,[e,o,n])),2),l=s[0],u=s[1],c=u.transform,h=Fe(u,["transform"]);_z(a,c);var d=$V(e,a,i);return a.getLocalEulerAngles()||a.setLocalEulerAngles(d),XV(a,Be(Be({},YV(e.value,d,i)),l)),t.attr(h),a}function QV(t,e,n,r){var i=vV(e,n.labelFilter),o=Pz(n,"label");return t.selectAll(uV.label.class).data(i,(function(t,e){return e})).join((function(r){return r.append("g").attr("className",uV.label.name).transition((function(t){ZV(this,t,e,o,n);var r=qV(t,e,n),i=r.x,a=r.y;return this.style.transform="translate(".concat(i,", ").concat(a,")"),null})).call((function(){KV.call(t,n)}))}),(function(i){return i.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&&FF(t),e.isVisible()&&BF(e)};if(!n)return i(),[null];var o=n.duration,a=void 0===o?0:o,s=n.delay,l=void 0===s?0:s,u=Math.ceil(+a/2),c=+a/4,h=Ve(t.getGeometryBounds().center,2),d=h[0],f=h[1],p=Ve(e.getGeometryBounds().center,2),g=Ve([(d+p[0])/2-d,(f+p[1])/2-f],2),v=g[0],m=g[1],y=t.style.opacity,b=void 0===y?1:y,x=e.style.opacity,E=void 0===x?1:x,w=t.style.transform||"",k=e.style.transform||"",M=t.animate([{opacity:b,transform:"translate(0, 0) ".concat(w)},{opacity:0,transform:"translate(".concat(v,", ").concat(m,") ").concat(w)}],Be(Be({fill:"both"},n),{duration:l+u+c})),S=e.animate([{opacity:0,transform:"translate(".concat(-v,", ").concat(-m,") ").concat(k),offset:.01},{opacity:E,transform:"translate(0, 0) ".concat(k)}],Be(Be({fill:"both"},n),{duration:u+c,delay:l+u-c}));return XG(S,i),[M,S]}(this.querySelector(uV.labelItem.class),ZV(this,t,e,o,n),r.update),a=qV(t,e,n),s=a.x,l=a.y,u=QG(this,{transform:"translate(".concat(s,", ").concat(l,")")},r.update);return We(We([],Ve(i),!1),[u],!1)})).call((function(e){var r,i,o=Oe(e,"_transitions").flat().filter(QF);i=function(){KV.call(t,n)},0===(r=o).length?i():Promise.all(r.map((function(t){return null==t?void 0:t.finished}))).then(i)}))}),(function(t){return t.transition((function(){var t=this,e=JG(this.childNodes[0],r.exit);return XG(e,(function(){return Mz(t).remove()})),e}))})).transitions()}function JV(t,e){return bV(t,e.tickDirection,e)}function tW(t,e,n,r,i){var o=Ve(function(t,e){var n=Ve(t,2);return[[0,0],[n[0]*e,n[1]*e]]}(r,YF(i.tickLength,[t,e,n])),2),a=Ve(o[0],2),s=a[0],l=a[1],u=Ve(o[1],2);return{x1:s,x2:u[0],y1:l,y2:u[1]}}function eW(t,e,n,r,i,o){var a=function(t,e,n,r,i){var o=i.tickFormatter,a=JV(e.value,i),s="line";return Ut(o)&&(s=function(){return YF(o,[e,n,r,a])}),t.append(s).attr("className",uV.tickItem.name)}(Mz(this),t,e,n,r);!function(t,e,n,r,i,o,a){var s=JV(t.value,o),l=tW(t,e,n,s,o),u=l.x1,c=l.x2,h=l.y1,d=l.y2,f=Ve(Dz(gV(a,[t,e,n,s])),2),p=f[0],g=f[1];"line"===r.node().nodeName&&r.styles(Be({x1:u,x2:c,y1:h,y2:d},p)),i.attr(g),r.styles(p)}(t,e,n,a,this,r,i);var s=Ve(EV(t.value,r),2),l=s[0],u=s[1];return QG(this,{transform:"translate(".concat(l,", ").concat(u,")")},o)}var nW=XF({text:"text"},"title");function rW(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function iW(t,e){var n=Object.entries(e).reduce((function(e,n){var r=Ve(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e}),{});t.styles(n)}var oW=function(t){function e(e){return t.call(this,e,{text:"",width:0,height:0,fill:"#4a505a",fontWeight:"bold",fontSize:12,fontFamily:"sans-serif",inset:0,spacing:0,position:"top-left"})||this}return je(e,t),e.prototype.getAvailableSpace=function(){var t=this.attributes,e=t.width,n=t.height,r=t.position,i=t.spacing,o=t.inset,a=this.querySelector(nW.text.class);if(!a)return new $F(0,0,+e,+n);var s=a.getBBox(),l=s.width,u=s.height,c=Ve(Sz(i),4),h=c[0],d=c[1],f=c[2],p=c[3],g=Ve([0,0,+e,+n],4),v=g[0],m=g[1],y=g[2],b=g[3],x=rW(r);if(x.includes("i"))return new $F(v,m,y,b);x.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=Ve(0===r?[u+f,+n-u-f]:[0,+n],2),m=i[0],b=i[1]),"r"===t&&(o=Ve([+e-l-p],1),y=o[0]),"b"===t&&(a=Ve([+n-u-h],1),b=a[0]),"l"===t&&(s=Ve(0===r?[l+d,+e-l-d]:[0,+e],2),v=s[0],y=s[1])}));var E=Ve(Sz(o),4),w=E[0],k=E[1],M=E[2],S=E[3],N=Ve([S+k,w+M],2),O=N[0],T=N[1];return new $F(v+S,m+w,y-O,b-T)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new $F(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=Fe(t,["width","height","position","spacing"]),i=Ve(Dz(r),1)[0],o=function(t){var e,n,r,i,o=t,a=o.width,s=o.height,l=o.position,u=Ve([+a/2,+s/2],2),c=Ve([+u[0],+u[1],"center","middle"],4),h=c[0],d=c[1],f=c[2],p=c[3],g=rW(l);return g.includes("l")&&(h=(e=Ve([0,"start"],2))[0],f=e[1]),g.includes("r")&&(h=(n=Ve([+a,"end"],2))[0],f=n[1]),g.includes("t")&&(d=(r=Ve([0,"top"],2))[0],p=r[1]),g.includes("b")&&(d=(i=Ve([+s,"bottom"],2))[0],p=i[1]),{x:h,y:d,textAlign:f,textBaseline:p}}(t),a=o.x,s=o.y,l=o.textAlign,u=o.textBaseline;az(!!r.text,Mz(e),(function(t){n.title=t.maybeAppendByClassName(nW.text,"text").styles(i).call(iW,{x:a,y:s,textAlign:l,textBaseline:u}).node()}))},e}(Bz);function aW(t,e,n,r,i){var o=Ve(Dz(Pz(r,"title")),2),a=o[0],s=o[1],l=s.transform,u=s.transformOrigin,c=Fe(s,["transform","transformOrigin"]);e.styles(c);var h=l||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(Be(Be({},a),{transformOrigin:u})),_z(t.node(),h);var d=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,a=rW(i),s=t.node().getLocalBounds(),l=Ve(s.min,2),u=l[0],c=l[1],h=Ve(s.halfExtents,2),d=h[0],f=h[1],p=Ve(e.node().getLocalBounds().halfExtents,2),g=p[0],v=p[1],m=Ve([u+d,c+f],2),y=m[0],b=m[1],x=Ve(Sz(o),4),E=x[0],w=x[1],k=x[2],M=x[3];if(["start","end"].includes(i)&&"linear"===n.type){var S=n.startPos,N=n.endPos,O=Ve("start"===i?[S,N]:[N,S],2),T=O[0],C=O[1],A=Ve(uz(gz([-C[0]+T[0],-C[1]+T[1]]),E),2),P=A[0],R=A[1];return{x:T[0]+P,y:T[1]+R}}return a.includes("t")&&(b-=f+v+E),a.includes("r")&&(y+=d+g+w),a.includes("l")&&(y-=d+g+M),a.includes("b")&&(b+=f+v+k),{x:y,y:b}}(Mz(n._offscreen||n.querySelector(uV.mainGroup.class)),e,r),f=d.x,p=d.y;return QG(e.node(),{transform:"translate(".concat(f,", ").concat(p,")")},i)}function sW(t,e,n,r){var i=t.showLine,o=t.showTick,a=t.showLabel,s=az(i,e.maybeAppendByClassName(uV.lineGroup,"g"),(function(e){return CV(e,t,r)}))||[],l=az(o,e.maybeAppendByClassName(uV.tickGroup,"g"),(function(e){return function(t,e,n,r){var i=vV(e,n.tickFilter),o=Pz(n,"tick");return t.selectAll(uV.tick.class).data(i,(function(t){return t.id||t.label})).join((function(t){return t.append("g").attr("className",uV.tick.name).transition((function(t,e){return eW.call(this,t,e,i,n,o,!1)}))}),(function(t){return t.transition((function(t,e){return this.removeChildren(),eW.call(this,t,e,i,n,o,r.update)}))}),(function(t){return t.transition((function(){var t=this,e=JG(this.childNodes[0],r.exit);return XG(e,(function(){return t.remove()})),e}))})).transitions()}(e,n,t,r)}))||[],u=az(a,e.maybeAppendByClassName(uV.labelGroup,"g"),(function(e){return QV(e,n,t,r)}))||[];return We(We(We([],Ve(s),!1),Ve(l),!1),Ve(u),!1).filter((function(t){return!!t}))}var lW=function(t){function e(e){return t.call(this,e,lV)||this}return je(e,t),e.prototype.render=function(t,e,n){var r=this,i=t.titleText,o=t.data,a=t.animate,s=t.showTitle,l=t.showGrid,u=t.dataThreshold,c=t.truncRange,h=function(t,e){if(t.length<=e)return t;for(var n=Math.floor(t.length/e),r=[],i=0;i<t.length;i+=n)r.push(t[i]);return r}(o,u).filter((function(t){var e=t.value;return!(c&&e>c[0]&&e<c[1])})),d=qG(void 0===n?a:n),f=az(l,Mz(e).maybeAppendByClassName(uV.gridGroup,"g"),(function(e){return RV(e,h,t,d)}))||[],p=Mz(e).maybeAppendByClassName(uV.mainGroup,"g");i&&(!this.initialized&&d.enter||this.initialized&&d.update)&&sW(t,Mz(this.offscreenGroup),h,qG(!1));var g=sW(t,Mz(p.node()),h,d),v=az(s,Mz(e).maybeAppendByClassName(uV.titleGroup,"g"),(function(e){return function(t,e,n,r){var i=n.titleText;return t.selectAll(uV.title.class).data([{title:i}].filter((function(t){return!!t.title})),(function(t,e){return t.title})).join((function(o){return o.append((function(){return oz(i)})).attr("className",uV.title.name).transition((function(){return aW(Mz(this),t,e,n,r.enter)}))}),(function(i){return i.transition((function(){return aW(Mz(this),t,e,n,r.update)}))}),(function(t){return t.remove()})).transitions()}(e,r,t,d)}))||[];return We(We(We([],Ve(f),!1),Ve(g),!1),Ve(v),!1).flat().filter((function(t){return!!t}))},e}(Bz),uW=XF({prevBtnGroup:"prev-btn-group",prevBtn:"prev-btn",nextBtnGroup:"next-btn-group",nextBtn:"next-btn",pageInfoGroup:"page-info-group",pageInfo:"page-info",playWindow:"play-window",contentGroup:"content-group",controller:"controller",clipPath:"clip-path"},"navigator"),cW=function(t){function e(e){var n=t.call(this,e,{x:0,y:0,animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonD:Hz(0,0,6),buttonSize:12,controllerPadding:5,controllerSpacing:5,formatter:function(t,e){return"".concat(t,"/").concat(e)},defaultPage:0,loop:!1,orientation:"horizontal",pageNumFill:"black",pageNumFontSize:12,pageNumTextAlign:"start",pageNumTextBaseline:"middle"})||this;return n.playState="idle",n.contentGroup=n.appendChild(new jl({class:uW.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new jl({class:uW.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return je(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return oe(t,0,Math.max(this.pageViews.length-1,0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.playWindow.children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"controllerShape",{get:function(){return this.totalPages>1?{width:55,height:0}:{width:0,height:0}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pageShape",{get:function(){var t=Ve(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,We([],Ve(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 $F(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 l=Ve(this.getFollowingPageDiff(t),2),u=l[0],c=l[1];this.playState="running";var h=ZG(a,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-u,", ").concat(-c,")")}],n);return XG(h,(function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()})),h},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:oe(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:oe(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(uW.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)?BF(e):FF(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(),l=s.width;s.height;var u=Ve("horizontal"===o?[-180,0]:[-90,90],2),c=u[0],h=u[1];e.setLocalEulerAngles(c),n.setLocalEulerAngles(h);var d=e.getBBox(),f=d.width,p=d.height,g=n.getBBox(),v=g.width,m=g.height,y=Math.max(f,l,v),b="horizontal"===o?{offset:[[0,0],[f/2+a,0],[f+l+2*a,0]],textAlign:"start"}:{offset:[[y/2,-p-a],[y/2,0],[y/2,m+a]],textAlign:"center"},x=Ve(b.offset,3),E=Ve(x[0],2),w=E[0],k=E[1],M=Ve(x[1],2),S=M[0],N=M[1],O=Ve(x[2],2),T=O[0],C=O[1],A=b.textAlign,P=r.querySelector("text");P&&(P.style.textAlign=A),e.setLocalPosition(w,k),r.setLocalPosition(S,N),n.setLocalPosition(T,C)},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(uW.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<e?-1:1;return"horizontal"===n?[a*i,0]:[0,a*o]},e.prototype.prepareFollowingPage=function(t){var e=this.currPage,n=this.pageViews;if(this.setVisiblePages([t,e]),t!==e){var r=Ve(this.getFollowingPageDiff(t),2),i=r[0],o=r[1];n[t].setLocalPosition(i,o)}},e.prototype.renderController=function(t){var e=this,n=this.attributes.controllerSpacing,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,a=this.pageViews.length>=2,s=t.maybeAppendByClassName(uW.controller,"g");if(zF(s.node(),a),a){var l=Pz(this.attributes,"button"),u=Pz(this.attributes,"pageNum"),c=Ve(Dz(l),2),h=c[0],d=c[1],f=h.size,p=Fe(h,["size"]),g=!s.select(uW.prevBtnGroup.class).node(),v=s.maybeAppendByClassName(uW.prevBtnGroup,"g").styles(d);this.prevBtnGroup=v.node();var m=v.maybeAppendByClassName(uW.prevBtn,"path"),y=s.maybeAppendByClassName(uW.nextBtnGroup,"g").styles(d);this.nextBtnGroup=y.node(),[m,y.maybeAppendByClassName(uW.nextBtn,"path")].forEach((function(t){t.styles(Be(Be({},p),{transformOrigin:"center"})),wz(t.node(),f)}));var b=s.maybeAppendByClassName(uW.pageInfoGroup,"g");this.pageInfoGroup=b.node(),b.maybeAppendByClassName(uW.pageInfo,"text").styles(u),this.updatePageInfo(),s.node().setLocalPosition(i+n,o/2),g&&(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=Mz(e);this.renderClipPath(a),this.renderController(a),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=ye((function(){return t.render(t.attributes,t)}),50);this.playWindow.addEventListener(Vs.INSERTED,e),this.playWindow.addEventListener(Vs.REMOVED,e)},e}(Bz);function hW(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}$z.registerSymbol("hiddenHandle",(function(t,e,n){var r=1.4*n;return[["M",t-n,e-r],["L",t+n,e-r],["L",t+n,e+r],["L",t-n,e+r],["Z"]]})),$z.registerSymbol("verticalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=t+.4*r;return[["M",t,e],["L",a,e+i],["L",t+r,e+i],["L",t+r,e-i],["L",a,e-i],["Z"],["M",a,e+o],["L",t+r-2,e+o],["M",a,e-o],["L",t+r-2,e-o]]})),$z.registerSymbol("horizontalHandle",(function(t,e,n){var r=1.4*n,i=n/2,o=n/6,a=e+.4*r;return[["M",t,e],["L",t-i,a],["L",t-i,e+r],["L",t+i,e+r],["L",t+i,a],["Z"],["M",t-o,a],["L",t-o,e+r-2],["M",t+o,a],["L",t+o,e+r-2]]}));var dW=XF({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item");var fW=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new Dl({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this}return je(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.markerSize,r=t.node().getBBox(),i=r.width,o=r.height,a=e.node().getBBox(),s=a.width,l=a.height;return{markerWidth:n,labelWidth:i,valueWidth:s,height:Math.max(n,o,l)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=Ve(Sz(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}),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.height,s=this.actualSpace,l=s.labelWidth,u=s.valueWidth,c=Ve(this.spacing,2),h=c[0],d=c[1];if(r){var f=r-n-h-d,p=Ve(this.span,2);l=(t=Ve([p[0]*f,p[1]*f],2))[0],u=t[1]}return{width:o+l+u+h+d,height:a,markerWidth:o,labelWidth:l,valueWidth:u}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes.spacing;if(!t)return[0,0];var e=Ve(Sz(t),2),n=e[0],r=e[1];return this.showValue?[n,r]:[n,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.width,o=t.height,a=Ve(this.spacing,2),s=a[0];return{height:o,width:i,markerWidth:e,labelWidth:n,valueWidth:r,position:[e/2,e+s,e+n+s+a[1]]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(dW.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,l=void 0===s?t.stroke:s,u=+(i||a||(l?1:0))*Math.sqrt(2),c=this.markerGroup.node().getBBox(),h=c.width,d=c.height;return(1-u/Math.max(h,d))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes.marker,r=Pz(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(dW.markerGroup,"g").style("zIndex",0),az(!!n,this.markerGroup,(function(){var t,i=e.markerGroup.node(),o=null===(t=i.childNodes)||void 0===t?void 0:t[0],a="string"==typeof n?new $z({style:{symbol:n},className:dW.marker.name}):n();o?a.nodeName===o.nodeName?o instanceof $z?o.update(Be(Be({},r),{symbol:n})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=Ge(Object.entries(i)),a=o.next();!a.done;a=o.next()){var s=Ve(a.value,2),l=s[0],u=s[1];"id"!==l&&"className"!==l&&t.attr(l,u)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(o,a),Mz(o).styles(r)):(o.remove(),Mz(a).attr("className",dW.marker.name).styles(r),i.appendChild(a)):(a instanceof $z||Mz(a).attr("className",dW.marker.name).styles(r),i.appendChild(a)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]);var s=wz(e.markerGroup.node(),e.scaleSize);e.markerGroup.node().style._transform="scale(".concat(s,")")}))},e.prototype.renderLabel=function(t){var e=Pz(this.attributes,"label"),n=e.text,r=Fe(e,["text"]);this.labelGroup=t.maybeAppendByClassName(dW.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(dW.label,(function(){return oz(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=Pz(this.attributes,"value"),r=n.text,i=Fe(n,["text"]);this.valueGroup=t.maybeAppendByClassName(dW.valueGroup,"g").style("zIndex",0),az(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(dW.value,(function(){return oz(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=Pz(this.attributes,"background");this.background=t.maybeAppendByClassName(dW.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(dW.background,"rect").styles(Be({width:n,height:r},i))},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=Ve(t.position,3),o=i[0],a=i[1],s=i[2],l=r/2;this.markerGroup.styles({transform:"translate(".concat(o,", ").concat(l,")").concat(this.markerGroup.node().style._transform)}),this.labelGroup.styles({transform:"translate(".concat(a,", ").concat(l,")")}),rz(this.labelGroup.select(dW.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({transform:"translate(".concat(s,", ").concat(l,")")}),rz(this.valueGroup.select(dW.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=Mz(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.adjustLayout()},e}(Bz),pW=XF({page:"item-page",navigator:"navigator",item:"item"},"items"),gW=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},vW=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:Le,mouseenter:Le,mouseleave:Le})||this;return n.navigatorShape=[0,0],n}return je(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=Pz(this.attributes,"item"),i=e.map((function(t,i){var o=t.id,a=void 0===o?i:o,s=t.label,l=t.value;return{id:"".concat(a),index:i,style:Be({layout:n,labelText:s,valueText:l},Object.fromEntries(Object.entries(r).map((function(n){var r=Ve(n,2);return[r[0],YF(r[1],[t,i,e])]}))))}}));return i},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=Ve(this.navigatorShape,1)[0],s=Ve(this.grid,2),l=s[0],u=s[1],c=u*l,h=0;return this.pageViews.children.map((function(e,s){var d,f,p=Math.floor(s/c),g=s%c,v=t.ifHorizontal(u,l),m=[Math.floor(g/v),g%v];"vertical"===n&&m.reverse();var y=Ve(m,2),b=y[0],x=y[1],E=(r-a-(u-1)*o)/u,w=e.getBBox().height,k=Ve([0,0],2),M=k[0],S=k[1];return"horizontal"===n?(M=(d=Ve([h,b*(w+i)],2))[0],S=d[1],h=x===u-1?0:h+E+o):(M=(f=Ve([x*(E+o),h],2))[0],S=f[1],h=b===l-1?0:h+w+i),{page:p,index:s,row:b,col:x,pageIndex:g,width:E,height:w,x:M,y:S}}))},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=Ve(this.navigatorShape,1)[0],a=Ve(this.grid,2),s=a[0],l=a[1],u=Ve([e-o,n],2),c=u[0],h=u[1],d=Ve([0,0,0,0,0,0,0,0],8),f=d[0],p=d[1],g=d[2],v=d[3],m=d[4],y=d[5],b=d[6],x=d[7];return this.pageViews.children.map((function(t,e){var n,o,a,u,d=t.getBBox(),E=d.width,w=d.height,k=0===b?0:i,M=b+k+E;return M<=c&&gW(m,(function(t){return t<l}))?(n=Ve([b+k,x,M],3),f=n[0],p=n[1],b=n[2],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}):(o=Ve([y+1,0,0,x+w+r],4),y=o[0],m=o[1],b=o[2],(x=o[3])+w<=h&&gW(y,(function(t){return t<s}))?(a=Ve([b,x,E],3),f=a[0],p=a[1],b=a[2],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}):(u=Ve([0,0,E,0,g+1,0,0,0],8),f=u[0],p=u[1],b=u[2],x=u[3],g=u[4],v=u[5],y=u[6],m=u[7],{width:E,height:w,x:f,y:p,page:g,index:e,pageIndex:v++,row:y,col:m++}))}))},Object.defineProperty(e.prototype,"itemsLayout",{get:function(){this.navigatorShape=[0,0];var t="grid"===this.attributes.layout?this.getGridLayout:this.getFlexLayout,e=t.call(this);return e.slice(-1)[0].page>0?(this.navigatorShape=[55,0],t.call(this)):e},enumerable:!1,configurable:!0}),e.prototype.ifHorizontal=function(t,e){return hW(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(pW.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(pW.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;this.flattenPage(t);var o=this.dispatchCustomEvent.bind(this);Mz(t).selectAll(pW.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new fW({style:e})})).attr("className",pW.item.name).on("click",(function(){null==n||n(this),o("itemClick",{item:this})})).on("pointerenter",(function(){null==r||r(this),o("itemMouseenter",{item:this})})).on("pointerleave",(function(){null==i||i(this),o("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=Ve(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=Ve(t,2);return{page:e[0],layouts:e[1]}})),i=We([],Ve(this.navigator.getContainer().children),!1);r.forEach((function(t){var e=t.layouts,r=n.pageViews.appendChild(new jl({className:pW.page.name}));e.forEach((function(t){var e=t.x,n=t.y,o=t.index,a=t.width,s=t.height,l=i[o];r.appendChild(l),Te(l,"__layout__",t),l.update({x:e,y:n,width:a,height:s})}))})),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes.orientation,n=Pz(this.attributes,"nav"),r=ZF({orientation:e},n),i=this;return t.selectAll(pW.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new cW({style:r})})).attr("className",pW.navigator.name).each((function(){i.navigator=this}))}),(function(t){return t.each((function(){this.update(r)}))}),(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(Mz(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new Rs(t,{detail:e});this.dispatchEvent(n)},e}(Bz),mW=XF({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),yW={showLabel:!0,formatter:function(t){return t.toString()},markerSize:25,markerStroke:"#c5c5c5",markerFill:"#fff",markerLineWidth:1,labelFontSize:12,labelFill:"#c5c5c5",labelText:"",orientation:"vertical",spacing:0};!function(t){function e(e){return t.call(this,e,yW)||this}je(e,t),e.prototype.render=function(t,e){var n=Mz(e).maybeAppendByClassName(mW.markerGroup,"g");this.renderMarker(n);var r=Mz(e).maybeAppendByClassName(mW.labelGroup,"g");this.renderLabel(r)},e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.orientation,i=n.markerSymbol,o=void 0===i?hW(r,"horizontalHandle","verticalHandle"):i;az(!!o,t,(function(t){var n=Pz(e.attributes,"marker"),r=Be({symbol:o},n);e.marker=t.maybeAppendByClassName(mW.marker,(function(){return new $z({style:r})})).update(r)}))},e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.showLabel,i=n.orientation,o=n.spacing,a=void 0===o?0:o,s=n.formatter;az(r,t,(function(t){var n,r=Pz(e.attributes,"label"),o=r.text,l=Fe(r,["text"]),u=(null===(n=t.select(mW.marker.class))||void 0===n?void 0:n.node().getBBox())||{},c=u.width,h=void 0===c?0:c,d=u.height,f=Ve(hW(i,[0,(void 0===d?0:d)+a,"center","top"],[h+a,0,"start","middle"]),4),p=f[0],g=f[1],v=f[2],m=f[3];t.maybeAppendByClassName(mW.label,"text").styles(Be(Be({},l),{x:p,y:g,text:s(o).toString(),textAlign:v,textBaseline:m}))}))}}(Bz);var bW={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},xW=ZF({},bW,{});ZF({},bW,Rz(yW,"handle"),{color:["#d0e3fa","#acc7f6","#8daaf2","#6d8eea","#4d73cd","#325bb1","#5a3e75","#8c3c79","#e23455","#e7655b"],indicatorBackgroundFill:"#262626",indicatorLabelFill:"white",indicatorLabelFontSize:12,indicatorVisibility:"hidden",labelAlign:"value",labelDirection:"positive",labelSpacing:5,showHandle:!0,showIndicator:!0,showLabel:!0,slidable:!0,titleText:"",type:"continuous"});var EW=XF({title:"title",titleGroup:"title-group",items:"items",itemsGroup:"items-group",contentGroup:"content-group",ribbonGroup:"ribbon-group",ribbon:"ribbon",handlesGroup:"handles-group",handle:"handle",startHandle:"start-handle",endHandle:"end-handle",labelGroup:"label-group",label:"label",indicator:"indicator"},"legend"),wW=function(t){function e(e){return t.call(this,e,xW)||this}return je(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,a=Ve(Dz(Pz(this.attributes,"title")),2),s=a[0],l=a[1];this.titleGroup=t.maybeAppendByClassName(EW.titleGroup,"g").styles(l);var u=Be(Be({width:e,height:n},s),{text:i?o:""});this.title=this.titleGroup.maybeAppendByClassName(EW.title,(function(){return new oW({style:u})})).update(u)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,a=Ve(Dz(Pz(this.attributes,"title",!0)),2),s=a[0],l=a[1],u=Be(Be({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(EW.itemsGroup,"g").styles(Be(Be({},l),{transform:"translate(".concat(n,", ").concat(r,")")}));var c=this;this.itemsGroup.selectAll(EW.items.class).data(["items"]).join((function(t){return t.append((function(){return new vW({style:u})})).attr("className",EW.items.name).each((function(){c.items=Mz(this)}))}),(function(t){return t.update(u)}),(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 $F(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(),l=e.getBBox(),u=rW(r),c=Ve(Sz(a?i:0),4),h=c[0],d=c[1],f=c[2],p=c[3],g=Ve(Sz(o),4),v=g[0],m=g[1],y=g[2],b=g[3],x=Ve([p+d,h+f],2),E=x[0],w=x[1],k=Ve([b+m,v+y],2),M=k[0],S=k[1];if("l"===u[0])return new $F(s.x,s.y,l.width+s.width+E+M,Math.max(l.height+S,s.height));if("t"===u[0])return new $F(s.x,s.y,Math.max(l.width+M,s.width),l.height+s.height+w+S);var N=Ve([e.attributes.width||l.width,e.attributes.height||l.height],2),O=N[0],T=N[1];return new $F(l.x,l.y,O+s.width+E+M,T+s.height+w+S)}(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,l=void 0===s?0:s,u=Mz(e);e.style.transform="translate(".concat(a,", ").concat(l,")"),this.renderTitle(u,r,i),this.renderItems(u,this.availableSpace),this.adjustLayout()},e}(Bz),kW={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},MW=XF({background:"background",labelGroup:"label-group",label:"label"},"indicator"),SW=function(t){function e(e){var n=t.call(this,e,kW)||this;return n.point=[0,0],n.group=n.appendChild(new jl({})),n.isMutationObserved=!0,n}return je(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=Ve(Sz(t.padding),4),r=n[0],i=n[1],o=n[2],a=n[3],s=this.label.node().getLocalBounds(),l=s.min,u=s.max,c=new $F(l[0]-a,l[1]-r,u[0]+i-l[0]+a,u[1]+o-l[1]+r),h=this.getPath(e,c),d=Pz(this.attributes,"background");this.background=Mz(this.group).maybeAppendByClassName(MW.background,"path").styles(Be(Be({},d),{d:h})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=Ve(Dz(Pz(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var a=Fe(i,["text"]);(this.label=Mz(this.group).maybeAppendByClassName(MW.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(MW.label,(function(){return oz(e(n))})).style("text",e(n).toString()).selectAll("text").styles(a)},e.prototype.adjustLayout=function(){var t=Ve(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"]],l={top:4,right:6,bottom:0,left:2}[t],u=this.createCorner([s[l].slice(-2),s[l+1].slice(-2)]);return s.splice.apply(s,We([l+1,1],Ve(u),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=Oz.apply(void 0,We([],Ve(t),!1)),r=Ve(t,2),i=Ve(r[0],2),o=i[0],a=i[1],s=Ve(r[1],2),l=s[0],u=s[1],c=Ve(n?[l-o,[o,l]]:[u-a,[a,u]],2),h=c[0],d=Ve(c[1],2),f=d[0],p=d[1],g=h/2,v=e*(h/Math.abs(h)),m=v/2,y=v*Math.sqrt(3)/2*.8,b=Ve([f,f+g-m,f+g,f+g+m,p],5),x=b[0],E=b[1],w=b[2],k=b[3],M=b[4];return n?(this.point=[w,a-y],[["L",x,a],["L",E,a],["L",w,a-y],["L",k,a],["L",M,a]]):(this.point=[o+y,w],[["L",o,x],["L",o,E],["L",o+y,w],["L",o,k],["L",o,M]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?FF(this):BF(this)},e.prototype.bindEvents=function(){this.label.on(Vs.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(Bz);function NW(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 OW={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function TW(t){var e;void 0===t&&(t="");var n=NW(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)]=Be({flex:1},OW),e[".".concat(n.VALUE)]=Be({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},OW),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 CW=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=NW(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:'<div class="'.concat(a.CONTAINER,'"></div>'),title:'<div class="'.concat(a.TITLE,'"></div>'),item:'<li class="'.concat(a.LIST_ITEM,'" data-index={index}>\n <span class="').concat(a.NAME,'">\n <span class="').concat(a.MARKER,'" style="background:{color}"></span>\n <span class="').concat(a.NAME_LABEL,'" title="{name}">{name}</span>\n </span>\n <span class="').concat(a.VALUE,'" title="{value}">{value}</span>\n </li>')},style:TW(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return je(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,l=Fe(t,["name","color","index"]),u=Be({name:i,color:a,index:null!=s?s:e},l);return Cn(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,u))}))},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=Cn(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:Iz(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,l=NW(r.prefixCls),u=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(u.innerHTML=r.title,u.getElementsByClassName(l.TITLE)[0].innerHTML=i):null===(e=null===(t=u.getElementsByClassName(l.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var c=this.HTMLTooltipItemsElements,h=document.createElement("ul");h.className=l.LIST,Iz(h,c);var d=this.element.querySelector(".".concat(l.LIST));d?d.replaceWith(h):u.appendChild(h)}!function(t,e){Object.entries(e).forEach((function(e){var n=Ve(e,2),r=n[0],i=n[1];We([t],Ve(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(":"),";")}),""))}))}))}(u,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,l=a.height,u=[-s/2,-l/2];return i.forEach((function(t){var e=Ve(u,2),n=e[0],i=e[1],a=Ve(o[t],2),c=a[0],h=a[1];u=[n+(s/2+r[0])*c,i+(l/2+r[1])*h]})),u},e.prototype.setOffsetPosition=function(t){var e=Ve(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=void 0===o?0:o,s=i.y,l=void 0===s?0:s,u=i.container,c=u.x,h=u.y;this.element.style.left="".concat(+a+c+n,"px"),this.element.style.top="".concat(+l+h+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.timestamp<e||(this.timestamp=n,this.setOffsetPosition(this.autoPosition(this.getRelativeOffsetFromCursor())))},e.prototype.autoPosition=function(t){var e=Ve(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,a=i.y,s=i.bounding,l=i.position;if(!s)return[n,r];var u=this.element,c=u.offsetWidth,h=u.offsetHeight,d=Ve([+o+n,+a+r],2),f=d[0],p=d[1],g={left:"right",right:"left",top:"bottom",bottom:"top"},v=s.x,m=s.y,y={left:f<v,right:f+c>v+s.width,top:p<m,bottom:p+h>m+s.height},b=[];l.split("-").forEach((function(t){y[t]?b.push(g[t]):b.push(t)}));var x=b.join("-");return this.getRelativeOffsetFromCursor(x)},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 $F(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}(Bz),AW=function(t){function e(n){var r=t.call(this,ZF({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new Xl({})),r.label=r.background.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Sz(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=Pz(this.attributes,"label");Mz(this.label).maybeAppend(".label",(function(){return oz(e)})).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=Ve(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3],a=t.width,s=t.height,l=a+o+r,u=s+n+i,c=Pz(this.attributes,"background"),h=this.style,d=h.width,f=void 0===d?0:d,p=h.height,g=void 0===p?0:p,v=h.selected;this.background.attr(Be(Be({},c),{width:Math.max(l,f),height:Math.max(u,g),fill:v?this.selectedColor:"#fff"})),this.label.attr({transform:"translate(".concat(o,", ").concat((u-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}(Bz),PW=function(t){function e(n){var r,i,o=t.call(this,ZF({},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 Xl({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new Xl({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 je(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 Sz(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,l=n.showDropdownIcon,u=Pz(this.attributes,"select"),c=Pz(this.attributes,"placeholder");this.select.attr(Be(Be({x:r,y:i,width:o,height:a},u),{fill:"#fff",strokeWidth:s?1:0}));var h=this.dropdownPadding;l&&Mz(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-h[1]-h[3],", ").concat(i+a/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var d=null===(t=this.style.options)||void 0===t?void 0:t.find((function(t){return t.value===e.currentValue})),f=Be({x:r+h[3]},c);Mz(this.select).selectAll(".placeholder").data(d?[]:[1]).join((function(t){return t.append("text").attr("className","placeholder").styles(f).style("y",(function(){var t=this.getBBox();return i+(a-t.height)/2}))}),(function(t){return t.styles(f)}),(function(t){return t.remove()}));var p=Pz(this.attributes,"optionLabel"),g=Be({x:r+h[3]},p);Mz(this.select).selectAll(".value").data(d?[d]:[]).join((function(t){return t.append((function(t){return oz(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,l=r.options,u=r.onSelect,c=r.open,h=Pz(this.attributes,"dropdown"),d=Pz(this.attributes,"option"),f=this.dropdownPadding;Mz(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(l,(function(t){return t.value})).join((function(t){return t.append((function(t){return new AW({className:"dropdown-item",style:Be(Be(Be({},t),d),{width:a-f[1]-f[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==u||u(t,e,r),n.dispatchEvent(new Rs("change",{detail:{value:t,option:e,item:r}})),FF(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 r<e&&(t+=n.getBBox().height),t}),0);this.attr("transform","translate(".concat(f[3],", ").concat(f[0]+r,")"))}))}),(function(t){return t.update((function(t){return{selected:t.value===n.currentValue}}))}),(function(t){return t.remove()}));var p=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),g=h.spacing;this.dropdown.attr(Be({transform:"translate(".concat(i,", ").concat(o+s+g,")"),width:p.width+f[1]+f[3],height:p.height+f[0]+f[2]},h)),!c&&FF(this.dropdown)},e.prototype.render=function(){this.renderSelect(),this.renderDropdown()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("click",(function(t){t.stopPropagation()})),this.select.addEventListener("click",(function(){"visible"===t.dropdown.style.visibility?FF(t.dropdown):BF(t.dropdown)})),this.addEventListener("pointerenter",(function(){t.isPointerInSelect=!0})),this.addEventListener("pointerleave",(function(){t.isPointerInSelect=!1})),null===document||void 0===document||document.addEventListener("click",(function(){t.isPointerInSelect||FF(t.dropdown)}))},e.defaultOptions={style:{x:0,y:0,width:140,height:32,options:[],bordered:!0,defaultValue:"",selectRadius:8,selectStroke:"#d9d9d9",showDropdownIcon:!0,placeholderText:"请选择",placeholderFontSize:12,placeholderTextBaseline:"top",placeholderFill:"#c2c2c2",dropdownFill:"#fff",dropdownStroke:"#d9d9d9",dropdownRadius:8,dropdownShadowBlur:4,dropdownShadowColor:"rgba(0, 0, 0, 0.08)",dropdownPadding:8,dropdownSpacing:10,optionPadding:[8,12],optionFontSize:12,optionTextBaseline:"top",optionBackgroundFill:"#fff",optionBackgroundRadius:4,optionLabelFontSize:12,optionLabelTextBaseline:"top"}},e}(Bz),RW=function(t){function e(n){var r=t.call(this,ZF({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new Xl({})),r.icon=r.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"BaseIcon"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineWidth",{get:function(){return Math.log10(this.attributes.size)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"padding",{get:function(){return Sz(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=Ve(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3];return Math.max(t-Math.max(o+r,n+i),2*this.lineWidth+1)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.size,i=r/2,o=Pz(this.attributes,"background");this.background.attr(Be({x:e-i,y:n-i,width:r,height:r},o))},e.prototype.showIndicator=function(){if(this.label){var t=this.attributes.size,e=this.background.getBBox(),n=e.x,r=e.y;this.indicator.update({x:n+t/2,y:r-5,labelText:this.label,visibility:"visible"})}},e.prototype.hideIndicator=function(){this.indicator.update({visibility:"hidden"})},e.prototype.connectedCallback=function(){var e;t.prototype.connectedCallback.call(this);var n=this.attributes.size,r=this.background.getBBox(),i=r.x,o=r.y,a=null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView;a&&(this.indicator=a.appendChild(new SW({style:{x:i+n/2,y:o-n/2,visibility:"hidden",position:"top",radius:3,zIndex:100}})))},e.prototype.disconnectedCallback=function(){this.indicator.destroy()},e.prototype.render=function(){this.renderIcon(),this.showBackground&&this.renderBackground()},e.prototype.bindEvents=function(){var t=this,n=this.attributes.onClick;if(this.addEventListener("click",(function(){null==n||n(t)})),this.showBackground){var r=function(){return t.background.attr({opacity:e.backgroundOpacities.default})};this.addEventListener("pointerenter",(function(){t.background.attr({opacity:e.backgroundOpacities.hover}),t.showIndicator()})),this.addEventListener("pointerleave",(function(){r(),t.hideIndicator()})),this.addEventListener("pointerdown",(function(){t.background.attr({opacity:e.backgroundOpacities.active})})),this.addEventListener("pointerup",(function(){r()}))}},e.tag="IconBase",e.defaultOptions={style:{x:0,y:0,size:10,color:"#565758",backgroundRadius:4,backgroundFill:"#e2e2e2"}},e.backgroundOpacities={default:0,hover:.8,active:1},e}(Bz),DW=function(t,e){return void 0===e&&(e="#565758"),new Hl({style:{fill:e,d:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},LW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),e.prototype.arcPath=function(t,e,n){var r=Ve([n,n],2),i=r[0],o=r[1],a=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=Ve(a(-5/4*Math.PI),2),l=s[0],u=s[1],c=Ve(a(1/4*Math.PI),2),h=c[0],d=c[1];return"M".concat(l,",").concat(u,",A").concat(i,",").concat(o,",0,1,1,").concat(h,",").concat(d)},Object.defineProperty(e.prototype,"label",{get:function(){return"重置"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o+.5;Mz(this.icon).maybeAppend(".reset","path").styles({stroke:r,lineWidth:o,d:this.arcPath(e,n,i/2-o),markerStart:DW(a,r)})},e}(RW),_W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e-o,n],[e,n+a],[e,n],[e+o,n-a],[e+o,n+a],[e,n]];Mz(this.icon).maybeAppend(".backward","polygon").styles({points:s,fill:r})},e}(RW),IW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,a=i/2/Math.pow(3,.5),s=[[e,n],[e,n-a],[e+o,n],[e,n+a],[e,n],[e-o,n-a],[e-o,n+a],[e,n]];Mz(this.icon).maybeAppend(".forward","polygon").styles({points:s,fill:r})},e}(RW),jW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3*Math.pow(3,.5)*.8,a=[[e+o,n],[e-o/2,n-i/2*.8],[e-o/2,n+i/2*.8],[e+o,n]];Mz(this.icon).maybeAppend(".play","polygon").styles({points:a,fill:r})},e}(RW),BW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3,a=[[e-o,n-i/2],[e-o,n+i/2],[e-o/2,n+i/2],[e-o/2,n-i/2],[e-o,n-i/2],[e+o/2,n-i/2],[e+o/2,n+i/2],[e+o,n+i/2],[e+o,n-i/2]];Mz(this.icon).maybeAppend(".pause","polygon").styles({points:a,fill:r})},e}(RW),FW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=o;Mz(this.icon).maybeAppend(".left-line","line").styles({x1:e-i/2,y1:n-i/2,x2:e-i/2,y2:n+i/2,stroke:r,lineWidth:o}),Mz(this.icon).maybeAppend(".right-line","line").styles({x1:e+i/2,y1:n-i/2,x2:e+i/2,y2:n+i/2,stroke:r,lineWidth:o}),Mz(this.icon).maybeAppend(".left-arrow","line").styles({x1:e,y1:n,x2:e-i/2+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:DW(2*o,r)}),Mz(this.icon).maybeAppend(".right-arrow","line").styles({x1:e,y1:n,x2:e+i/2-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:DW(2*o,r)})},e}(RW),zW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;Mz(this.icon).maybeAppend(".line","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o});var a=o;Mz(this.icon).maybeAppend(".left-arrow","line").styles({x1:e-i/2-2*a,y1:n,x2:e-2*a,y2:n,stroke:r,lineWidth:o,markerEnd:DW(2*o,r)}),Mz(this.icon).maybeAppend(".right-arrow","line").styles({x1:e+i/2+2*a,y1:n,x2:e+2*a,y2:n,stroke:r,lineWidth:o,markerEnd:DW(2*o,r)})},e}(RW),GW=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},VW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,a=(i-2*o-o)/4,s=(i-2*o-o)/2,l=Ve([e-i/2+o,n+i/2-2*o],2),u=l[0],c=l[1];Mz(this.icon).maybeAppend(".coordinate","polyline").styles({points:GW(i).map((function(t){var r=Ve(t,2),i=r[0],o=r[1];return[i+e,o+n]})),stroke:r,lineWidth:o}),Mz(this.icon).maybeAppend(".line","polyline").styles({points:[[u,c],[u+a,c-s],[u+2*a,c],[u+4*a,c-2*s]],stroke:r,lineWidth:o})},e}(RW),WW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return je(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"条形图"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return[1,4,2,4,3]},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.data,e=this.attributes,n=e.x,r=e.y,i=e.color,o=this.iconSize,a=this.lineWidth,s=a,l=(o-s)/t.length,u=(o-2*s)/4,c=Ve([n-o/2+2*s,r+o/2-s],2),h=c[0],d=c[1];Mz(this.icon).maybeAppend(".coordinate","polyline").styles({points:GW(o).map((function(t){var e=Ve(t,2),i=e[0],o=e[1];return[i+n,o+r]})),stroke:i,lineWidth:a}),Mz(this.icon).maybeAppend(".bars","g").selectAll(".column").data(this.data.map((function(t,e){return{value:t,index:e}}))).join((function(t){return t.append("line").attr("className","column").style("x1",(function(t){var e=t.index;return h+l*e})).style("y1",d).style("x2",(function(t){var e=t.index;return h+l*e})).style("y2",(function(t){var e=t.value;return d-u*e})).styles({y1:d,stroke:i,lineWidth:a})}))},e}(RW),HW=function(t){function e(e){var n=t.call(this,ZF({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return je(e,t),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;Mz(this.icon).maybeAppend(".split","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o})},e}(RW),UW=function(t){function e(){var e=t.apply(this,We([],Ve(arguments),!1))||this;return e.showBackground=!1,e}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Sz(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes,n=e.x,r=e.y,i=e.speed,o=void 0===i?1:i,a=Pe(this.attributes,["x","y","transform","transformOrigin","width","height","size","color","speed"]),s=oe(t,20,1/0),l=Be(Be({},a),{x:n-s/2,y:r-10,width:s,height:20,defaultValue:o,bordered:!1,showDropdownIcon:!1,selectRadius:2,dropdownPadding:this.padding,dropdownRadius:2,dropdownSpacing:t/5,placeholderFontSize:t/2,optionPadding:0,optionLabelFontSize:t/2,optionBackgroundRadius:1,options:[{label:"1x",value:1},{label:"1.5x",value:1.5},{label:"2x",value:2}]});Mz(this.icon).maybeAppend(".speed",(function(){return new PW({style:l})})).attr("className","speed").each((function(){this.update(l)}))},e.tag="SpeedSelect",e}(RW),$W=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new jl({})),n.currentType=n.attributes.type,n}return je(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.onChange;var n=Fe(e,["onChange"]);Mz(this.icon).selectAll(".icon").data([this.currentType]).join((function(e){return e.append((function(e){var n,r=null===(n=t.toggles.find((function(t){return Ve(t,1)[0]===e})))||void 0===n?void 0:n[1];if(!r)throw new Error("Invalid type: ".concat(e));return new r({})})).attr("className","icon").styles(n,!1).update({})}),(function(t){return t.styles({restStyles:n}).update({})}),(function(t){return t.remove()}))},e.prototype.bindEvents=function(){var t=this,e=this.attributes.onChange;this.addEventListener("click",(function(n){n.preventDefault(),n.stopPropagation();var r=(t.toggles.findIndex((function(e){return Ve(e,1)[0]===t.currentType}))+1)%t.toggles.length,i=t.toggles[r][0];null==e||e(t.currentType),t.currentType=i,t.render()}))},e.tag="ToggleIcon",e}(Bz),YW=function(t){function e(e){var n=t.call(this,ZF({},{style:{type:"play"}},e))||this;return n.toggles=[["play",jW],["pause",BW]],n}return je(e,t),e}($W),qW=function(t){function e(e){var n=t.call(this,ZF({},{style:{type:"range"}},e))||this;return n.toggles=[["range",FW],["value",zW]],n}return je(e,t),e}($W),XW=function(t){function e(e){var n=t.call(this,ZF({},{style:{type:"column"}},e))||this;return n.toggles=[["line",VW],["column",WW]],n}return je(e,t),e}($W),KW={reset:LW,speed:UW,backward:_W,playPause:YW,forward:IW,selectionType:qW,chartType:XW,split:HW},ZW=function(t){function e(n){var r=t.call(this,ZF({},e.defaultOptions,n))||this;return r.background=r.appendChild(new Xl({})),r.functions=r.appendChild(new jl({})),r}return je(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return Sz(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.x,n=t.y,r=t.width,i=t.height,o=Pz(this.attributes,"background");this.background.attr(Be({x:e,y:n,width:r,height:i},o))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,i=n.iconSize,o=n.iconSpacing,a=n.x,s=n.y,l=n.width,u=n.height,c=n.align,h=Ve(this.padding,4),d=h[1],f=h[3],p=r.reduce((function(t,e){return t.length&&e.length?t.concat.apply(t,We(["split"],Ve(e),!1)):t.concat.apply(t,We([],Ve(e),!1))}),[]),g=p.length*(i+o)-o,v={left:f+i/2,center:(l-g)/2+i/2,right:l-g-f-d+i/2}[c]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),p.forEach((function(t,n){var r,l=KW[t],c={x:a+n*(i+o)+v,y:s+u/2,size:i};if(l===UW?(c.speed=e.attributes.speed,c.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[YW,qW,XW].includes(l)?(c.onChange=function(n){return e.handleFunctionChange(t,{value:n})},l===YW&&(c.type="play"===e.attributes.state?"pause":"play"),l===qW&&(c.type="range"===e.attributes.selectionType?"value":"range"),l===XW&&(c.type="line"===e.attributes.chartType?"column":"line")):c.onClick=function(){return e.handleFunctionChange(t,{value:t})},l===UW){var h=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;h&&(e.speedSelect=new l({style:Be(Be({},c),{zIndex:100})}),h.appendChild(e.speedSelect))}else e.functions.appendChild(new l({style:c}))}))},e.prototype.disconnectedCallback=function(){var e;t.prototype.disconnectedCallback.call(this),null===(e=this.speedSelect)||void 0===e||e.destroy()},e.prototype.render=function(){this.renderBackground(),this.renderFunctions()},e.prototype.handleFunctionChange=function(t,e){var n=this.attributes.onChange;null==n||n(t,e)},e.defaultOptions={style:{x:0,y:0,width:300,height:40,padding:0,align:"center",iconSize:25,iconSpacing:0,speed:1,state:"pause",chartType:"line",selectionType:"range",backgroundFill:"#fbfdff",backgroundStroke:"#ebedf0",functions:[["reset","speed"],["backward","playPause","forward"],["selectionType","chartType"]]}},e}(Bz),QW=function(t){function e(n){var r=t.call(this,ZF({},e.defaultOptions,n))||this;return r.bindEvents(),r}return je(e,t),e.prototype.bindEvents=function(){var t=this;this.addEventListener("mouseenter",(function(){t.attr("lineWidth",Math.ceil(+(t.style.r||0)/2))})),this.addEventListener("mouseleave",(function(){t.attr("lineWidth",0)}))},e.defaultOptions={style:{r:5,fill:"#3f7cf7",lineWidth:0,stroke:"#3f7cf7",strokeOpacity:.5,cursor:"pointer"}},e}(Dl),JW=function(t){function e(n){return t.call(this,ZF({},e.defaultOptions,n))||this}return je(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=Pz(this.attributes,"background");Mz(this).maybeAppend("background","rect").attr("className","background").styles(Be({x:e-r/2,y:n-i/2,width:r,height:i},o))},e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.iconSize,i=Pz(this.attributes,"icon"),o=r/2;Mz(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(Be({x1:e-1,y1:n-o,x2:e-1,y2:n+o},i)),Mz(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(Be({x1:e+1,y1:n-o,x2:e+1,y2:n+o},i))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,a=Pz(this.attributes,"border"),s="start"===o?+r/2:-r/2;Mz(this).maybeAppend("border","line").attr("className","border").styles(Be({x1:s+e,y1:n-i/2,x2:s+e,y2:n+i/2},a))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{x:0,y:0,width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(Bz);function tH(t,e){return"number"==typeof t?eH(t):function(t,e){var n=new Date(t);switch(e){case"half-hour":case"hour":case"four-hour":return[0,6,12,18].includes(n.getHours())&&0===n.getMinutes()?Lz(n,"HH:mm\nYYYY-MM-DD"):Lz(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(Lz(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?Lz(n,"DD\nYYYY-MM"):Lz(n,"DD");case"week":return n.getDate()<=7?Lz(n,"DD\nYYYY-MM"):Lz(n,"DD");case"month":return[0,6].includes(n.getMonth())?Lz(n,"MM月\nYYYY"):Lz(n,"MM月");case"season":return[0].includes(n.getMonth())?Lz(n,"MM月\nYYYY"):Lz(n,"MM月");case"year":return Lz(n,"YYYY");default:return Lz(n,"YYYY-MM-DD HH:mm")}}(t,e)}function eH(t){var e=String(Math.floor(t/3600)).padStart(2,"0"),n=String(Math.floor(t%3600/60)).padStart(2,"0"),r=String(Math.floor(t%60)).padStart(2,"0");return t<3600?"".concat(n,":").concat(r):"".concat(e,":").concat(n,":").concat(r)}var nH=function(t){function e(n){var r=t.call(this,ZF({},e.defaultOptions,n))||this;r.axis=r.appendChild(new lW({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new sV({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new ZW({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?We([],Ve(e),!1):e);r.setBySliderValues(t),r.dispatchOnChange(n)};var i=r.attributes,o=i.selectionType,a=i.chartType,s=i.speed,l=i.state,u=i.playMode,c=i.values;return r.states={chartType:a,playMode:u,selectionType:o,speed:s,state:l},r.setByTimebarValues(c),r}return je(e,t),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.data.sort((function(t,e){return t.time<e.time?-1:t.time>e.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=oe(+i-a,0,+i),l=new $F(e,n+ +i-a,+r,a),u=0,c="time"===o?10:s;return{axisBBox:"chart"===o?new $F(e,n+s-(u=35),+r,u):new $F,controllerBBox:l,timelineBBox:new $F(e,n+("time"===o?s:s-c),+r,c-u)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=Ve(Array.isArray(t)?t:[0,t],2),o=i[0],a=i[1],s=r.length,l=r[Math.floor(o*s)],u=r[Math.ceil(a*s)-(Array.isArray(t)?0:1)];this.states.values=[null!==(e=null==l?void 0:l.time)&&void 0!==e?e:r[0].time,null!==(n=null==u?void 0:u.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=Ve(Array.isArray(t)?t:[void 0,t],2),a=o[0],s=o[1],l=i.find((function(t){return t.time===a})),u=i.find((function(t){return t.time===s}));this.states.values=[null!==(e=null==l?void 0:l.time)&&void 0!==e?e:null===(n=i[0])||void 0===n?void 0:n.time,null!==(r=null==u?void 0:u.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,a=Ve(t,2),s=a[0],l=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[l])||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=Ve(Array.isArray(n)?n:[void 0,n],2),o=i[0],a=i[1],s=this.data,l=s.length,u="value"===r;return[(t=s.findIndex((function(t){return t.time===o})),u?0:t>-1?t/l:0),function(){if(a===1/0)return 1;var t=s.findIndex((function(t){return t.time===a}));return t>-1?t/l:u?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=Ve(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 JW({style:{type:t,height:e,iconSize:e/6}})}:function(){return new Vl({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,l=a.chartType,u=this.data,c=this.attributes,h=c.type,d=c.labelFormatter,f=Pz(this.attributes,"chart");f.type;var p=Fe(f,["type"]),g="range"===s;if("time"===h)return Be({handleIconShape:function(){return new QW({})},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(d)return d(t);var n=e.getDatumByRatio(t).time;return"number"==typeof n?eH(n):Lz(n,"YYYY-MM-DD HH:mm:ss")},transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},p);var v="range"===s?5:0,m=u.map((function(t){return t.value}));return Be({handleIconOffset:v,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:m,sparklineType:l,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},p)},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=Pz(this.attributes,"axis"),a=t.x,s=t.y,l=t.width,u=We(We([],Ve(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}})),c=Be({startPos:[a,s],endPos:[a+l,s],data:u,labelFilter:function(t,e){return e<u.length-1},labelFormatter:function(t){var e=t.time;return i?i(e):tH(e,r)}},o);return c},e.prototype.renderAxis=function(t){void 0===t&&(t=this.space.axisBBox),"chart"===this.attributes.type&&this.axis.update(this.getAxisStyle(t))},e.prototype.renderController=function(t){void 0===t&&(t=this.space.controllerBBox);var e=this.attributes.type,n=this.states,r=n.state,i=n.speed,o=n.selectionType,a=n.chartType,s=Pz(this.attributes,"controller"),l=this,u=Be(Be(Be({},t),{iconSize:20,speed:i,state:r,selectionType:o,chartType:a,onChange:function(t,e){var n=e.value;switch(t){case"reset":l.internalReset();break;case"speed":l.handleSpeedChange(n);break;case"backward":l.internalBackward();break;case"playPause":"play"===n?l.internalPlay():l.internalPause();break;case"forward":l.internalForward();break;case"selectionType":l.handleSelectionTypeChange(n);break;case"chartType":l.handleChartTypeChange(n)}}}),s);"time"===e&&(u.functions=[["reset","speed"],["backward","playPause","forward"],["selectionType"]]),this.controller.update(u)},e.prototype.dispatchOnChange=function(t){var e=this.data,n=this.attributes.onChange,r=this.states,i=r.values,o=r.selectionType,a=Ve(i,2),s=a[0],l=a[1],u=l===1/0?e.at(-1).time:l;t&&function(t,e){if(Array.isArray(t)){if(!Array.isArray(e))return!1;if(t[0]===e[0]){if(t[1]===e[1])return!0;if(t[1]===1/0||e[1]===1/0)return!0}return!1}return!Array.isArray(e)&&t===e}(t,"range"===o?[s,u]:u)||null==n||n("range"===o?[s,u]:u)},e.prototype.internalReset=function(t){var e,n,r=this.states.selectionType;this.internalPause(),this.setBySliderValues("range"===r?[0,1]:[0,0]),this.renderController(),this.updateSelection(),t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onReset)||void 0===n||n.call(e),this.dispatchOnChange())},e.prototype.reset=function(){this.internalReset()},e.prototype.moveSelection=function(t,e){var n=this.data,r=n.length,i=this.states,o=i.values,a=i.selectionType,s=i.playMode,l=Ve(o,2),u=l[0],c=l[1],h=n.findIndex((function(t){return t.time===u})),d=n.findIndex((function(t){return t.time===c}));-1===d&&(d=r);var f,p="backward"===t?-1:1;"range"===a?"acc"===s?(f=[h,d+p],-1===p&&h===d&&(f=[h,r])):f=[h+p,d+p]:f=[h,d+p];var g=function(t){var e=Ve(t.sort((function(t,e){return t-e})),2),n=e[0],i=e[1],o=function(t){return oe(t,0,r)};return i>r?"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)]}(f);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}(Bz);function rH(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=Xj(r,!1),{width:a,height:s,containerStyle:l}=t,[u,c]=function(t){const{width:e,height:n,placement:r,graphCanvas:i}=t,[o,a]=i.getSize(),[s,l]=Qh(r);return[s*(o-e),l*(a-n)]}(t);return Object.assign(o.style,Object.assign({position:"absolute",left:u+"px",top:c+"px",width:a+"px",height:s+"px"},l)),null===(e=i.getContainer())||void 0===e||e.appendChild(o),o}(t);return[i,new hu({width:e,height:n,container:i,renderer:r||new Sp})]}class iH extends qj{constructor(e,n){super(e,Object.assign({},iH.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=Oe(t,[r,"id"]),o=Oe(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=Oe(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=Oe(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={},l=e=>Ut(t)?t(e):t,u={node:"circle",edge:"line",combo:"rect"},c={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"},h=(t,e)=>{t.forEach((t=>{const{id:n}=t,i=Oe(t,["data",l(t)]),o=(null==r?void 0:r.getElementType(e,t))||"circle",a=((t,e)=>null==r?void 0:r.getElementComputedStyle(t,e))(e,t),h=("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:c[o]||u[e],elementType:e,lineWidth:1,stroke:h,fill:h}))}))};switch(e){case"node":h(i,"node");break;case"edge":h(o,"edge");break;case"combo":h(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:l,containerStyle:u,className:c}=t,h=Fe(t,["width","height","nodeField","edgeField","comboField","trigger","position","container","containerStyle","className"]),d=this.getMarkerData(r,"node"),f=this.getMarkerData(i,"edge"),p=this.getMarkerData(o,"combo"),g=[...d,...p,...f],v=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:d.length},h,this.getEvents()),m=new wW({className:"legend",style:v});this.category=m;this.upsertCanvas().appendChild(m),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:l}=this.options,[u,c]=rH({width:r,height:i,graphCanvas:t,container:a,containerStyle:s,placement:o,className:"legend"});return this.container=u,l&&u.classList.add(l),this.canvas=c,this.canvas}destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}iH.defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16,width:240,height:160};class oH extends qj{constructor(t,e){super(t,Object.assign({},oH.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.shapes=new Map,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:l}=this.mask.style,[,,u,c]=this.maskBBox;let h=parseInt(o)+r,d=parseInt(a)+i,f=parseInt(s),p=parseInt(l);h<0&&(h=0),d<0&&(d=0),h+f>e&&(h=sH(e-f,0)),d+p>n&&(d=sH(n-p,0)),f<u&&(r>0?(h=sH(h-r,0),f=aH(f+r,e)):r<0&&(f=aH(f-r,e))),p<c&&(i>0?(d=sH(d-i,0),p=aH(p+i,n)):i<0&&(p=aH(p-i,n))),Object.assign(this.mask.style,{left:h+"px",top:d+"px",width:f+"px",height:p+"px"});const g=parseInt(o)-h,v=parseInt(a)-d;if(0===g&&0===v)return;const m=this.context.canvas.getCamera().getZoom()/this.canvas.getCamera().getZoom();this.context.graph.translateBy([g*m,v*m],!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=Re((()=>{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=ye((()=>{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_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_TRANSFORM,this.onTransform)}renderMinimap(){const t=this.getElements(),e=this.initCanvas();this.setShapes(e,t)}getElements(){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(yh(e),"node"))),edges:i.filter((e=>t(yh(e),"edge"))),combos:o.filter((e=>t(yh(e),"combo")))}}setShapes(t,e){const{nodes:n,edges:r,combos:i}=e,{shape:o}=this.options,{element:a}=this.context;if("key"===o){const e=new Set,o=n=>{const r=yh(n);e.add(r);const i=a.getElement(r);if(!i)return;const o=i.getShape("key"),s=this.shapes.get(r)||o.cloneNode();s.setPosition(o.getPosition()),i.style.zIndex&&(s.style.zIndex=i.style.zIndex),s.id=i.id,this.shapes.has(r)?Object.entries(o.attributes).forEach((([t,e])=>{s.style[t]!==e&&(s.style[t]=e)})):(t.appendChild(s),this.shapes.set(r,s))};return r.forEach(o),i.forEach(o),n.forEach(o),void this.shapes.forEach(((n,r)=>{e.has(r)||(t.removeChild(n),this.shapes.delete(r))}))}const s=(t,e)=>{const n=a.getElement(t).getPosition();return e.setPosition(n),e};t.removeChildren(),r.forEach((e=>t.appendChild(o(yh(e),"edge")))),i.forEach((e=>{t.appendChild(s(yh(e),o(yh(e),"combo")))})),n.forEach((e=>{t.appendChild(s(yh(e),o(yh(e),"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,l]=rH({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=l}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,l,u]=Uc(o),{min:c,max:h,center:d}=e.getBounds("elements"),f=(r-u-s)/(h[0]-c[0]),p=(i-a-l)/(h[1]-c[1]),g=Math.min(f,p),v=this.createLandmark(d,d,g);n.gotoLandmark(v,0)}get maskBBox(){const{canvas:t}=this.context,e=t.getSize(),n=t.getCanvasByViewport([0,0]),r=t.getCanvasByViewport(e),i=this.canvas.canvas2Viewport(rd(n)),o=this.canvas.canvas2Viewport(rd(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=aH(i+n,t),n=0),r<0&&(o=aH(o+r,e),r=0),n+i>t&&(i=sH(t-n,0)),r+o>e&&(o=sH(e-r,0)),[aH(n,t),aH(r,e),sH(i,0),sH(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;this.unbindEvents(),this.canvas.destroy(),null===(t=this.mask)||void 0===t||t.remove(),super.destroy()}}oH.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 aH=(t,e)=>Math.min(t,e),sH=(t,e)=>Math.max(t,e),lH={x1:0,y1:0,x2:0,y2:0,visibility:"hidden"};class uH extends qj{constructor(t,e){super(t,Object.assign({},uH.defaultOptions,e)),this.initSnapline=()=>{const t=this.context.canvas.getLayer("transient");this.horizontalLine||(this.horizontalLine=t.appendChild(new Vl({style:Object.assign(Object.assign({},lH),this.options.horizontalLineStyle)}))),this.verticalLine||(this.verticalLine=t.appendChild(new Vl({style:Object.assign(Object.assign({},lH),this.options.verticalLineStyle)})))},this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!0,this.autoSnapToLine=(t,e,n)=>ze(this,void 0,void 0,(function*(){const{verticalX:r,horizontalY:i}=n,{tolerance:o}=this.options,{min:[a,s],max:[l,u],center:[c,h]}=e;let d=0,f=0;null!==r&&(cH(l,r)<o&&(d=r-l),cH(a,r)<o&&(d=r-a),cH(c,r)<o&&(d=r-c),0!==d&&(this.isVerticalSticking=!0)),null!==i&&(cH(u,i)<o&&(f=i-u),cH(s,i)<o&&(f=i-s),cH(h,i)<o&&(f=i-h),0!==f&&(this.isHorizontalSticking=!0)),0===d&&0===f||(yield this.context.graph.translateElementBy({[t]:[d,f]},!1))})),this.enableSnap=t=>{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:[l,u]}=e;let c=null,h=null,d=null,f=null,p=null,g=null;return this.getNodes().some((e=>{if(Ne(t.id,e.id))return!1;const v=hH(e,r).getRenderBounds(),{min:[m,y],max:[b,x],center:[E,w]}=v;return null===c&&(cH(E,l)<n?c=E:cH(m,i)<n||cH(m,a)<n?c=m:(cH(b,a)<n||cH(b,i)<n)&&(c=b),null!==c&&(h=Math.min(y,o),d=Math.max(x,s))),null===f&&(cH(w,u)<n?f=w:cH(y,o)<n||cH(y,s)<n?f=y:(cH(x,s)<n||cH(x,o)<n)&&(f=x),null!==f&&(p=Math.min(m,i),g=Math.max(b,a))),null!==c&&null!==f})),{verticalX:c,verticalMinY:h,verticalMaxY:d,horizontalY:f,horizontalMinX:p,horizontalMaxX:g}},this.onDragStart=()=>{this.initSnapline()},this.onDrag=t=>ze(this,void 0,void 0,(function*(){const{target:e}=t;if(this.options.autoSnap){if(!this.enableSnap(t))return}const n=hH(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"hidden"!==Oe(t,["style","visibility"])&&(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||lH.lineWidth||1)/this.context.graph.getZoom()}updateSnapline(t){const{verticalX:e,verticalMinY:n,verticalMaxY:r,horizontalY:i,horizontalMinX:o,horizontalMaxX:a}=t,[s,l]=this.context.canvas.getSize(),{offset:u}=this.options;null!==i?Object.assign(this.horizontalLine.style,{x1:u===1/0?0:o-u,y1:i,x2:u===1/0?s:a+u,y2:i,visibility:"visible",lineWidth:this.getLineWidth("horizontal")}):this.horizontalLine.style.visibility="hidden",null!==e?Object.assign(this.verticalLine.style,{x1:e,y1:u===1/0?0:n-u,x2:e,y2:u===1/0?l:r+u,visibility:"visible",lineWidth:this.getLineWidth("vertical")}):this.verticalLine.style.visibility="hidden"}getDelta(t){const e=this.context.graph.getZoom();return Fh([t.dx,t.dy],e)}bindEvents(){return ze(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()}}uH.defaultOptions={tolerance:5,offset:20,autoSnap:!0,shape:"key",verticalLineStyle:{stroke:"#1783FF"},horizontalLineStyle:{stroke:"#1783FF"},filter:()=>!0};const cH=(t,e)=>Math.abs(t-e),hH=(t,e)=>"function"==typeof e?e(t):t.getShape(e),dH=["timestamp","time","date","datetime"];class fH extends qj{get padding(){return Uc(this.options.padding)}constructor(t,e){super(t,Object.assign({},fH.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=pH(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:l,mode:u}=e,c=Fe(e,["onChange","timebarType","data","x","y","width","height","mode"]),h=t.getSize(),[d]=this.padding;this.upsertCanvas().ready.then((()=>{var t;const e=Object.assign(Object.assign({x:h[0]/2-s/2,y:d,onChange:t=>{const e=(Yt(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)}},c),{data:i.map((t=>ae(t)?{time:t,value:0}:t)),width:s,height:l,type:r});this.timebar?this.timebar.update(e):(this.timebar=new nH({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,l]=rH({width:i,height:e+o+a,graphCanvas:r,className:"timebar",placement:n});return this.container=s,t&&s.classList.add(t),this.canvas=l,this.canvas}filterElements(t){return ze(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=pH(this.originalData);n.forEach((e=>{const n=`${e}s`;a[n]=(this.originalData[n]||[]).filter((e=>{const n=r(e);return!!gH(n,t)}))}));const s=[...a.nodes,...a.combos].map((t=>yh(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=yh(e),a=r(e);gH(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()}}fH.defaultOptions={position:"bottom",enable:!0,timebarType:"time",className:"g6-timebar",width:450,height:60,zIndex:3,elementTypes:["node"],padding:10,mode:"modify",getTime:t=>vH(t,dH,void 0),loop:!1};const pH=t=>{const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e],edges:[...n],combos:[...r]}},gH=(t,e)=>{if(ae(e))return t===e;const[n,r]=e;return t>=n&&t<=r},vH=(t,e,n)=>{var r;for(let n=0;n<e.length;n++){const i=e[n],o=null===(r=t.data)||void 0===r?void 0:r[i];if(o)return o}return n};class mH extends qj{constructor(t,e){super(t,Object.assign({},mH.defaultOptions,e)),this.$element=Xj("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),Kj("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),Kj("g6-toolbar-svgicon","div",{display:"none"},'\n <svg>\n <symbol id="zoom-in" viewBox="64 64 896 896">\n <path d="M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="zoom-out" viewBox="64 64 896 896">\n <path d="M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="edit" viewBox="64 64 896 896">\n <path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>\n </symbol>\n <symbol id="delete" viewBox="64 64 896 896">\n <path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"></path>\n </symbol>\n <symbol id="redo" viewBox="64 64 896 896">\n <path d="M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"></path>\n </symbol>\n <symbol id="undo" viewBox="64 64 896 896">\n <path d="M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z"></path>\n </symbol>\n <symbol id="export" viewBox="64 64 896 896">\n <path d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"></path>\n </symbol>\n <symbol id="auto-fit" viewBox="64 64 896 896">\n <path d="M952 474H829.8C812.5 327.6 696.4 211.5 550 194.2V72c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v122.2C327.6 211.5 211.5 327.6 194.2 474H72c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h122.2C211.5 696.4 327.6 812.5 474 829.8V952c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V829.8C696.4 812.5 812.5 696.4 829.8 550H952c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM512 756c-134.8 0-244-109.2-244-244s109.2-244 244-244 244 109.2 244 244-109.2 244-244 244z"></path>\n <path d="M512 392c-32.1 0-62.1 12.4-84.8 35.2-22.7 22.7-35.2 52.7-35.2 84.8s12.5 62.1 35.2 84.8C449.9 619.4 480 632 512 632s62.1-12.5 84.8-35.2C619.4 574.1 632 544 632 512s-12.5-62.1-35.2-84.8A118.57 118.57 0 00512 392z"></path>\n </symbol>\n <symbol id="reset" viewBox="64 64 896 896">\n <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path>\n </symbol>\n <symbol id="exit-fullscreen" viewBox="0 0 1024 1024">\n <path d="M418.13333333 361.43786666c0 0.2048-0.13653333 0.4096-0.13653334 0.68266667C417.99679999 362.32533333 418.13333333 362.53013333 418.13333333 362.73493333 418.13333333 371.54133333 414.44693333 379.392 408.78079999 385.39946666 408.43946666 385.7408 408.30293333 386.21866666 408.02986666 386.49173333c-1.09226667 1.09226667-2.59413333 1.77493333-3.82293333 2.73066667C398.40426666 393.65973333 391.64586666 396.8 383.93173333 396.8 383.72693333 396.8 383.59039999 396.73173333 383.38559999 396.73173333S382.97599999 396.8 382.77119999 396.8L112.29866666 396.8C92.50133333 396.8 76.79999999 381.50826666 76.79999999 362.66666666 76.66346666 343.89333333 92.63786666 328.53333333 112.16213333 328.53333333l189.44 0L87.44959999 114.51733333C73.59146666 100.59093333 73.25013333 78.5408 86.63039999 65.29706666c13.17546667-13.44853333 35.36213333-12.97066667 49.152 0.88746667l214.08426667 214.08426667L349.86666666 90.89706666C349.79839999 71.23626666 365.22666666 55.46666666 383.99999999 55.46666666 402.77333333 55.33013333 418.13333333 71.30453333 418.13333333 90.8288L418.13333333 361.43786666zM928.90453333 328.53333333l-189.44 0 214.15253333-214.08426667c13.85813333-13.9264 14.19946667-35.90826667 0.88746667-49.22026666-13.17546667-13.44853333-35.36213333-12.97066667-49.152 0.88746666l-214.08426667 214.08426667L691.26826666 90.89706666C691.26826666 71.23626666 675.83999999 55.46666666 657.06666666 55.46666666 638.29333333 55.33013333 622.93333333 71.30453333 622.93333333 90.8288l0 270.60906666c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 362.32533333 622.93333333 362.53013333 622.93333333 362.73493333 622.93333333 371.54133333 626.61973333 379.392 632.28586666 385.39946666c0.34133333 0.34133333 0.47786667 0.8192 0.8192 1.09226667 1.09226667 1.09226667 2.59413333 1.77493333 3.8912 2.73066667C642.66239999 393.65973333 649.42079999 396.8 657.13493333 396.8c0.2048 0 0.34133333-0.06826667 0.54613333-0.06826667S658.09066666 396.8 658.29546666 396.8l270.5408 0C948.56533333 396.8 964.26666666 381.50826666 964.26666666 362.66666666 964.40319999 343.89333333 948.42879999 328.53333333 928.90453333 328.53333333zM418.13333333 635.73333333c0-8.8064-3.6864-16.5888-9.35253334-22.66453333C408.43946666 612.72746666 408.30293333 612.2496 408.02986666 611.90826666 406.86933333 610.88426666 405.43573333 610.2016 404.20693333 609.24586666 398.47253333 604.80853333 391.64586666 601.6 383.93173333 601.6 383.72693333 601.6 383.59039999 601.73653333 383.38559999 601.73653333S382.97599999 601.6 382.77119999 601.6L112.29866666 601.6C92.50133333 601.6 76.79999999 616.96 76.79999999 635.73333333 76.66346666 654.50666666 92.63786666 669.86666666 112.16213333 669.86666666l189.44 0-214.15253334 214.15253334c-13.85813333 13.85813333-14.19946667 35.84-0.88746666 49.22026666 13.17546667 13.44853333 35.36213333 12.9024 49.152-0.95573333l214.08426666-214.08426667 0 189.37173334c0 19.59253333 15.42826667 35.49866667 34.2016 35.36213333C402.77333333 943.2064 418.13333333 927.232 418.13333333 907.5712L418.13333333 637.09866666c0-0.27306667-0.13653333-0.47786667-0.13653334-0.68266666C417.99679999 636.14293333 418.13333333 635.93813333 418.13333333 635.73333333zM739.46453333 669.86666666l189.44 0c19.456 0 35.49866667-15.36 35.36213333-34.13333333C964.26666666 616.96 948.56533333 601.6 928.76799999 601.6L658.29546666 601.6C658.09066666 601.6 657.88586666 601.73653333 657.68106666 601.73653333S657.33973333 601.6 657.13493333 601.6C649.42079999 601.6 642.59413333 604.80853333 636.85973333 609.24586666 635.63093333 610.2016 634.19733333 610.88426666 633.03679999 611.90826666 632.76373333 612.2496 632.62719999 612.72746666 632.28586666 613.0688 626.61973333 619.14453333 622.93333333 626.92693333 622.93333333 635.73333333c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 636.6208 622.93333333 636.8256 622.93333333 637.09866666l0 270.5408C622.93333333 927.232 638.29333333 943.2064 657.06666666 942.93333333c18.77333333 0.13653333 34.2016-15.70133333 34.2016-35.36213333l0-189.37173334 214.08426667 214.08426667c13.78986667 13.85813333 35.90826667 14.40426667 49.152 0.95573333 13.312-13.312 12.97066667-35.36213333-0.88746667-49.22026666L739.46453333 669.86666666z" ></path></symbol>\n <symbol id="request-fullscreen" viewBox="0 0 1024 1024">\n <path d="M69.818182 87.598545v273.128728a34.909091 34.909091 0 0 0 69.818182 0V163.653818l221.928727 222.021818a33.512727 33.512727 0 0 0 47.383273-47.383272L186.926545 116.363636h197.073455a34.909091 34.909091 0 0 0 0-69.818181H110.871273C85.364364 46.545455 69.818182 59.671273 69.818182 87.598545zM938.542545 46.545455H665.413818a34.909091 34.909091 0 0 0 0 69.818181h197.073455L640.465455 338.292364a33.512727 33.512727 0 0 0 47.383272 47.383272l221.928728-222.021818v197.073455a34.909091 34.909091 0 0 0 69.818181 0V87.598545c0-27.927273-15.453091-41.053091-40.96-41.05309z m-827.671272 907.636363h273.128727a34.909091 34.909091 0 0 0 0-69.818182H186.926545l222.021819-221.928727a33.512727 33.512727 0 0 0-47.383273-47.383273L139.636364 837.073455V640a34.909091 34.909091 0 0 0-69.818182 0v273.128727c0 27.927273 15.546182 41.053091 41.053091 41.053091z m868.724363-41.053091V640a34.909091 34.909091 0 0 0-69.818181 0v197.073455L687.941818 615.051636a33.512727 33.512727 0 0 0-47.383273 47.383273L862.487273 884.363636H665.413818a34.909091 34.909091 0 0 0 0 69.818182h273.128727c25.6 0 41.053091-13.125818 41.053091-41.053091z" ></path></symbol>\n </svg>\n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(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 ze(this,void 0,void 0,(function*(){return(yield this.options.getItems()).map((t=>{var e;return`\n <div class="g6-toolbar-item" value="${t.value}" title="${null!==(e=t.title)&&void 0!==e?e:""}">\n <svg aria-hidden="true" focusable="false">\n <use xlink:href="#${t.id}"></use>\n </svg>\n </div>`})).join("")}))}}mH.defaultOptions={position:"top-left"};class yH extends qj{constructor(t,e){super(t,Object.assign({},yH.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.onPointerEnter=t=>{this.show(t)},this.showById=t=>ze(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=>ze(this,void 0,void 0,(function*(){var e,n;const{client:r,target:{id:i}}=t;if(Ig(t.target))return;const o=this.context.graph.getElementType(i),{getContent:a,title:s}=this.options,l=this.getElementData(i,o);if(!this.tooltipElement||!this.isEnable(t,l))return;let u,c,h={};if(a){if(h.content=yield a(t,l),!h.content)return}else{const t=this.context.graph.getElementRenderStyle(i),e="node"===o?t.fill:t.stroke;h={title:s||o,data:l.map((t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:e})))}}if(this.currentTarget=i,r)u=r.x,c=r.y;else{const t=Oe(l,"0.style",{x:0,y:0});u=t.x,c=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:u,y:c,style:{".tooltip":{visibility:"visible"}}}),h))})),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 CW({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:pointerenter":this.onPointerEnter,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerenter":this.onPointerEnter,"edge:pointermove":this.onPointerMove,"combo:pointerenter":this.onPointerEnter,"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:l={x:-i,y:-r},title:u,offset:c}=this.options,[h,d]=e,[f,p]=t.getSize();return{x:h,y:d,container:l,title:u,bounding:{x:0,y:0,width:f,height:p},position:a,enterable:s,offset:c,style:o}}destroy(){var t;this.unbindEvents(),this.tooltipElement&&(null===(t=this.container)||void 0===t||t.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}let bH;function xH(t,e){bH||(bH=document.createElement("canvas")),bH.width=t,bH.height=e;return bH.getContext("2d").clearRect(0,0,t,e),bH}yH.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};class EH extends qj{constructor(t,e){super(t,Object.assign({},EH.defaultOptions,e)),this.$element=Xj("watermark");this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return ze(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=Fe(n,["width","height","text","imageURL"]);Object.keys(s).forEach((e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])}));const l=a?yield function(t,e,n,r){return ze(this,void 0,void 0,(function*(){const i=xH(t,e),o=i.getContext("2d"),{rotate:a,opacity:s}=r;a&&o.rotate(a),s&&(o.globalAlpha=s);const l=new Image;return l.crossOrigin="anonymous",l.src=n,new Promise((n=>{l.onload=function(){const r=t>l.width?(t-l.width)/2:0,a=e>l.height?(e-l.height)/2:0;o.drawImage(l,0,0,l.width,l.height,r,a,t-2*r,e-2*a),n(i.toDataURL())}}))}))}(r,i,a,s):yield function(t,e,n,r){return ze(this,void 0,void 0,(function*(){const i=xH(t,e),o=i.getContext("2d"),{rotate:a,opacity:s,textFill:l,textFontSize:u,textFontFamily:c,textFontVariant:h,textFontWeight:d,textAlign:f,textBaseline:p}=r;return o.textAlign=f,o.textBaseline=p,o.translate(t/2,e/2),o.font=`${u}px ${c} ${h} ${d}`,a&&o.rotate(a),s&&(o.globalAlpha=s),l&&(o.fillStyle=l,o.fillText(`${n}`,0,0)),i.toDataURL()}))}(r,i,o,s);this.$element.style.backgroundImage=`url(${l})`}))}destroy(){super.destroy(),this.$element.remove()}}EH.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const wH=["#7E92B5","#F4664A","#FFBE3A"],kH={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},MH={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function SH(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeHaloStrokeOpacityActive:a=.15,nodeHaloStrokeOpacitySelected:s=.25,nodeOpacityDisabled:l=.06,nodeIconOpacityInactive:u=.85,nodeOpacityInactive:c=.25,nodeBadgePalette:h=wH,nodePaletteOptions:d=kH,edgeColor:f,edgeColorDisabled:p,edgePaletteOptions:g=MH,comboColor:v,comboColorDisabled:m,comboStroke:y,comboStrokeDisabled:b,edgeColorInactive:x}=t;return{background:e,node:{palette:d,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:h,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:c,donutOpacity:c,fillOpacity:c,iconOpacity:u,labelFill:n,labelFillOpacity:c,strokeOpacity:c},disabled:{badgeBackgroundOpacity:.25,donutOpacity:l,fill:i,fillOpacity:l,iconFill:i,iconOpacity:.25,labelFill:n,labelFillOpacity:.25,strokeOpacity:l}},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:f,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,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:f,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:x,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:p,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:v,halo:!1,haloLineWidth:12,haloStroke:y,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:y},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:m,fillOpacity:.25,labelOpacity:.25,stroke:b,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 NH=SH({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"}),OH=SH({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 TH extends Rh{beforeDraw(t,e){return t}afterLayout(t,e){}}function CH(t,e,n,r,i){const o=yh(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 AH(t,e){return Object.keys(t).every((n=>t[n]===e[n]))}const PH=(t,e,n,r)=>{const i=`${n}s`,o=yh(r);t.add[i].has(o)||t.update[i].has(o)||t[e][i].set(yh(r),r)};const RH=new WeakMap;const DH=(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(!DH(r,o,n-1))return!1}else if(r!==o)return!1}return!0};function LH(t,e,n){Mc[t][e]&&Tc(`The extension ${e} of ${t} has been registered before, and will be overridden.`),Object.assign(Mc[t],{[e]:n})}
72
72
  /*!
73
73
  * @antv/g-plugin-dragndrop
74
74
  * @description A G plugin for Drag n Drop implemented with PointerEvents