@antv/g6 5.0.0-beta.13 → 5.0.0-beta.14

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 (42) hide show
  1. package/dist/g6.min.js +1 -1
  2. package/esm/index.d.ts +1 -1
  3. package/esm/index.js +1 -1
  4. package/esm/item/edge.js +1 -1
  5. package/esm/item/edge.js.map +1 -1
  6. package/esm/item/node.d.ts +0 -7
  7. package/esm/item/node.js +0 -3
  8. package/esm/item/node.js.map +1 -1
  9. package/esm/runtime/controller/interaction.js +9 -4
  10. package/esm/runtime/controller/interaction.js.map +1 -1
  11. package/esm/runtime/controller/plugin.js.map +1 -1
  12. package/esm/stdlib/behavior/drag-canvas.js +2 -2
  13. package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
  14. package/esm/stdlib/behavior/drag-node.js +1 -0
  15. package/esm/stdlib/behavior/drag-node.js.map +1 -1
  16. package/esm/stdlib/behavior/zoom-canvas.js +7 -3
  17. package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
  18. package/lib/index.d.ts +1 -1
  19. package/lib/index.js +1 -1
  20. package/lib/item/edge.js +1 -1
  21. package/lib/item/edge.js.map +1 -1
  22. package/lib/item/node.d.ts +0 -7
  23. package/lib/item/node.js +0 -3
  24. package/lib/item/node.js.map +1 -1
  25. package/lib/runtime/controller/interaction.js +9 -4
  26. package/lib/runtime/controller/interaction.js.map +1 -1
  27. package/lib/runtime/controller/plugin.js.map +1 -1
  28. package/lib/stdlib/behavior/drag-canvas.js +2 -2
  29. package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
  30. package/lib/stdlib/behavior/drag-node.js +1 -0
  31. package/lib/stdlib/behavior/drag-node.js.map +1 -1
  32. package/lib/stdlib/behavior/zoom-canvas.js +7 -3
  33. package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/index.ts +1 -1
  36. package/src/item/edge.ts +5 -1
  37. package/src/item/node.ts +0 -26
  38. package/src/runtime/controller/interaction.ts +10 -4
  39. package/src/runtime/controller/plugin.ts +1 -1
  40. package/src/stdlib/behavior/drag-canvas.ts +2 -2
  41. package/src/stdlib/behavior/drag-node.ts +1 -0
  42. package/src/stdlib/behavior/zoom-canvas.ts +15 -3
package/dist/g6.min.js CHANGED
@@ -3,4 +3,4 @@
3
3
  * @license
4
4
  * Copyright 2019 Google LLC
5
5
  * SPDX-License-Identifier: Apache-2.0
6
- */const qP=Symbol("Comlink.proxy"),$P=Symbol("Comlink.endpoint"),ZP=Symbol("Comlink.releaseProxy"),QP=Symbol("Comlink.finalizer"),JP=Symbol("Comlink.thrown"),tw=t=>"object"==typeof t&&null!==t||"function"==typeof t,ew=new Map([["proxy",{canHandle:t=>tw(t)&&t[qP],serialize(t){const{port1:e,port2:n}=new MessageChannel;return nw(t,e),[n,[n]]},deserialize:t=>(t.start(),iw(t))}],["throw",{canHandle:t=>tw(t)&&JP 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 nw(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(pw);let c;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),n=s.reduce(((t,e)=>t[e]),t);switch(a){case"GET":c=n;break;case"SET":e[s.slice(-1)[0]]=pw(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,l);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[qP]:!0})}(new n(...l));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;nw(t,n),c=function(t,e){return hw.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[JP]:0}}Promise.resolve(c).catch((t=>({value:t,[JP]:0}))).then((n=>{const[i,s]=dw(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),rw(e),QP in t&&"function"==typeof t[QP]&&t[QP]())})).catch((t=>{const[n,r]=dw({value:new TypeError("Unserializable return value"),[JP]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function rw(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function iw(t,e){return cw(t,[],e)}function ow(t){if(t)throw new Error("Proxy has been released and is not useable")}function aw(t){return fw(t,{type:"RELEASE"}).then((()=>{rw(t)}))}const sw=new WeakMap,lw="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(sw.get(t)||0)-1;sw.set(t,e),0===e&&aw(t)}));function cw(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if(ow(r),o===ZP)return()=>{!function(t){lw&&lw.unregister(t)}(i),aw(t),r=!0};if("then"===o){if(0===e.length)return{then:()=>i};const n=fw(t,{type:"GET",path:e.map((t=>t.toString()))}).then(pw);return n.then.bind(n)}return cw(t,[...e,o])},set(n,i,o){ow(r);const[a,s]=dw(o);return fw(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(pw)},apply(n,i,o){ow(r);const a=e[e.length-1];if(a===$P)return fw(t,{type:"ENDPOINT"}).then(pw);if("bind"===a)return cw(t,e.slice(0,-1));const[s,l]=uw(o);return fw(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},l).then(pw)},construct(n,i){ow(r);const[o,a]=uw(i);return fw(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(pw)}});return function(t,e){const n=(sw.get(e)||0)+1;sw.set(e,n),lw&&lw.register(t,e,t)}(i,t),i}function uw(t){const e=t.map(dw);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const hw=new WeakMap;function dw(t){for(const[e,n]of ew)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},hw.get(t)||[]]}function pw(t){switch(t.type){case"HANDLER":return ew.get(t.name).deserialize(t.value);case"RAW":return t.value}}function fw(t,e,n){return new Promise((r=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){n.data&&n.data.id&&n.data.id===i&&(t.removeEventListener("message",e),r(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),n)}))}var gw=function(t){function e(e,n,r){var i=t.call(this)||this;return i.graph=e,i.layout=n,i.options=r,i.spawnWorker(),i}return Pc(e,t),e.prototype.spawnWorker=function(){this.proxy=iw(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())},e.prototype.execute=function(){var t;return Oc(this,void 0,void 0,(function(){var e,n,r,i,o,a;return Ic(this,(function(s){switch(s.label){case 0:return this.running?[2,this]:(this.running=!0,(e=this.layout.options).onTick,n=Nc(e,["onTick"]),r={},Object.keys(n).forEach((function(t){Se(n[t])||(r[t]=n[t])})),i={layout:{id:this.layout.id,options:r,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},o=new Float32Array([0]),[4,this.proxy.calculateLayout(i,[o])]);case 1:return a=Bc.apply(void 0,[s.sent(),1]),[2,a[0]]}}))}))},e.prototype.stop=function(){return this.running=!1,this.proxy.stopLayout(),this},e.prototype.kill=function(){this.proxy[ZP]()},e.prototype.isRunning=function(){return this.running},e}(Fc);const mw=Object.prototype.toString;function vw(t){const e=mw.call(t);return e.endsWith("Array]")&&!e.includes("Big")}function yw(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!vw(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(!vw(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(!vw(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(!vw(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 c=(l-a)/(i-r),u=0;u<t.length;u++)e[u]=(t[u]-r)*c+a;return e}const Ew=" ".repeat(2),_w=" ".repeat(4);function bw(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${Ew}[\n${_w}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),l=Math.min(a,n),c=[];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(Sw(t.get(e,o),r,i));c.push(`${n.join(" ")}`)}l!==a&&(c[c.length-1]+=` ... ${a-n} more columns`);s!==o&&c.push(`... ${o-e} more rows`);return c.join(`\n${_w}`)}(t,n,r,i,o)}\n${Ew}]\n${Ew}rows: ${t.rows}\n${Ew}columns: ${t.columns}\n}`}function Sw(t,e,n){return(t>=0&&n?` ${xw(t,e-1)}`:xw(t,e)).padEnd(e)}function xw(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 Tw(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 Aw(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 Rw(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 Mw(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 Cw(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(ww("startRow",e),ww("endRow",n),ww("startColumn",r),ww("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 Pw(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function ww(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Nw(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Ow{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new Dw(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 Dw(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 Dw(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 Dw(t,e)}static ones(t,e){return new Dw(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 Dw(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 Dw(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 Dw(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 Ow.isMatrix(t)?t:new Dw(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}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 Dw(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){Tw(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return Dw.rowVector(this.getRow(t))}setRow(t,e){Tw(this,t),e=Rw(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){Tw(this,t),Tw(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){Aw(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return Dw.columnVector(this.getColumn(t))}setColumn(t,e){Aw(this,t),e=Mw(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){Aw(this,t),Aw(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=Rw(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=Rw(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=Rw(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=Rw(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=Mw(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=Mw(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=Mw(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=Mw(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){Tw(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){Aw(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(){Nw(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(){Nw(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(Tw(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){Tw(this,t),Nw(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(Tw(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){Tw(this,t),Nw(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(Aw(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){Aw(this,t),Nw(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(Aw(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){Aw(this,t),Nw(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"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n)*this.get(t,n);return Math.sqrt(e)}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){Ow.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=Dw.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new Dw(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}strassen2x2(t){t=Dw.checkMatrix(t);let e=new Dw(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),c=t.get(1,1),u=(n+l)*(r+c),h=(a+l)*r,d=n*(o-c),p=l*(s-r),f=(n+i)*c,g=u+p-f+(i-l)*(s+c),m=d+f,v=h+p,y=u-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,m),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=Dw.checkMatrix(t);let e=new Dw(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),c=this.get(2,1),u=this.get(2,2),h=t.get(0,0),d=t.get(0,1),p=t.get(0,2),f=t.get(1,0),g=t.get(1,1),m=t.get(1,2),v=t.get(2,0),y=t.get(2,1),E=t.get(2,2),_=(n-o)*(-d+g),b=(-n+o+a)*(h-d+g),S=(o+a)*(-h+d),x=n*h,T=(-n+l+c)*(h-p+m),A=(-n+l)*(p-m),R=(l+c)*(-h+p),M=(-i+c+u)*(g+v-y),C=(i-u)*(g-y),P=i*v,w=(c+u)*(-v+y),N=(-i+a+s)*(m+v-E),O=(i-s)*(m-E),I=(a+s)*(-v+E),D=x+P+r*f,B=(n+r+i-o-a-c-u)*g+b+S+x+M+P+w,k=x+T+R+(n+r+i-a-s-l-c)*m+P+N+I,L=_+a*(-h+d+f-g-m-v+E)+b+x+P+N+O,F=_+b+S+x+s*y,U=P+N+O+I+o*p,G=x+T+A+c*(-h+p+f-g-m-v+y)+M+C+P,V=M+C+P+w+l*d,W=x+T+A+R+u*E;return e.set(0,0,D),e.set(0,1,B),e.set(0,2,k),e.set(1,0,L),e.set(1,1,F),e.set(1,2,U),e.set(2,0,G),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=Dw.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=Ow.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),c=n.subMatrix(0,o-1,0,s-1),u=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),p=n.subMatrix(o,n.rows-1,0,s-1),f=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),m=t(Ow.add(l,f),Ow.add(c,g),o,s),v=t(Ow.add(d,f),c,o,s),y=t(l,Ow.sub(h,g),o,s),E=t(f,Ow.sub(p,c),o,s),_=t(Ow.add(l,u),g,o,s),b=t(Ow.sub(d,l),Ow.add(c,h),o,s),S=t(Ow.sub(u,f),Ow.add(p,g),o,s),x=Ow.add(m,E);x.sub(_),x.add(S);let T=Ow.add(y,_),A=Ow.add(v,E),R=Ow.sub(m,v);R.add(y),R.add(b);let M=Ow.zeros(2*x.rows,2*x.columns);return M=M.setSubMatrix(x,0,0),M=M.setSubMatrix(T,x.rows,0),M=M.setSubMatrix(A,0,x.columns),M=M.setSubMatrix(R,x.rows,x.columns),M.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 Dw(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&yw(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 Dw(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&yw(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=Dw.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new Dw(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=Dw.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(Dw.eye(n,n)),i=Dw.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new Dw(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=Iw){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Iw){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){Cw(this,t,e,n,r);let i=new Dw(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 Dw(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 Dw(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=Dw.checkMatrix(t)).isEmpty())return this;Cw(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){!function(t,e){if(!vw(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")}(this,t),function(t,e){if(!vw(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")}(this,e);let n=new Dw(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(){let t=new Dw(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(e,n,this.get(e,n));return t}sum(t){switch(t){case"row":return function(t){let e=Pw(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=Pw(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=Pw(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=Pw(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(!vw(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(!vw(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(!vw(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(!vw(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+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!vw(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+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!vw(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+=Math.pow(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 bw(this,t)}}function Iw(t,e){return t-e}Ow.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Ow.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return bw(this)}),Ow.random=Ow.rand,Ow.randomInt=Ow.randInt,Ow.diagonal=Ow.diag,Ow.prototype.diagonal=Ow.prototype.diag,Ow.identity=Ow.eye,Ow.prototype.negate=Ow.prototype.neg,Ow.prototype.tensorProduct=Ow.prototype.kroneckerProduct;class Dw extends Ow{constructor(t,e){if(super(),Dw.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){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))}else{if(!vw(t))throw new TypeError("First argument must be a positive number or an array");{const n=t;if("number"!=typeof(e=(t=n.length)?n[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<t;r++){if(n[r].length!==e)throw new RangeError("Inconsistent array dimensions");if(!n[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[r]))}}}this.rows=t,this.columns=e}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return Tw(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Tw(this,t,!0),e=Float64Array.from(Rw(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Aw(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),Aw(this,t,!0),e=Mw(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,Math.pow(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,Math.pow(this.get(e,n),t.get(e,n)));return this}}(Ow,Dw);class Bw extends Ow{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]}}function kw(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 Lw{constructor(t,e={}){if((t=Bw.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),c=Boolean(o),u=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,u=!0;let e=l;l=c,c=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),p=new Float64Array(d),f=new Dw(n,h),g=new Dw(r,r),m=new Float64Array(r),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let E=Math.min(n-1,r),_=Math.max(0,Math.min(r-2,n)),b=Math.max(E,_);for(let t=0;t<b;t++){if(t<E){p[t]=0;for(let e=t;e<n;e++)p[t]=kw(p[t],s.get(e,t));if(0!==p[t]){s.get(t,t)<0&&(p[t]=-p[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/p[t]);s.set(t,t,s.get(t,t)+1)}p[t]=-p[t]}for(let e=t+1;e<r;e++){if(t<E&&0!==p[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))}m[e]=s.get(t,e)}if(l&&t<E)for(let e=t;e<n;e++)f.set(e,t,s.get(e,t));if(t<_){m[t]=0;for(let e=t+1;e<r;e++)m[t]=kw(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<r;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<n&&0!==m[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)v[e]+=m[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-m[e]/m[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*v[i])}}if(c)for(let e=t+1;e<r;e++)g.set(e,t,m[e])}}let S=Math.min(r,n+1);if(E<r&&(p[E]=s.get(E,E)),n<S&&(p[S-1]=0),_+1<S&&(m[_]=s.get(_,S-1)),m[S-1]=0,l){for(let t=E;t<h;t++){for(let e=0;e<n;e++)f.set(e,t,0);f.set(t,t,1)}for(let t=E-1;t>=0;t--)if(0!==p[t]){for(let e=t+1;e<h;e++){let r=0;for(let i=t;i<n;i++)r+=f.get(i,t)*f.get(i,e);r=-r/f.get(t,t);for(let i=t;i<n;i++)f.set(i,e,f.get(i,e)+r*f.get(i,t))}for(let e=t;e<n;e++)f.set(e,t,-f.get(e,t));f.set(t,t,1+f.get(t,t));for(let e=0;e<t-1;e++)f.set(e,t,0)}else{for(let e=0;e<n;e++)f.set(e,t,0);f.set(t,t,1)}}if(c)for(let t=r-1;t>=0;t--){if(t<_&&0!==m[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 x=S-1,T=Number.EPSILON;for(;S>0;){let t,e;for(t=S-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+T*Math.abs(p[t]+Math.abs(p[t+1]));if(Math.abs(m[t])<=e||Number.isNaN(m[t])){m[t]=0;break}}if(t===S-2)e=4;else{let n;for(n=S-1;n>=t&&n!==t;n--){let e=(n!==S?Math.abs(m[n]):0)+(n!==t+1?Math.abs(m[n-1]):0);if(Math.abs(p[n])<=T*e){p[n]=0;break}}n===t?e=3:n===S-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=m[S-2];m[S-2]=0;for(let n=S-2;n>=t;n--){let i=kw(p[n],e),o=p[n]/i,a=e/i;if(p[n]=i,n!==t&&(e=-a*m[n-1],m[n-1]=o*m[n-1]),c)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,S-1),g.set(t,S-1,-a*g.get(t,n)+o*g.get(t,S-1)),g.set(t,n,i)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let r=t;r<S;r++){let i=kw(p[r],e),o=p[r]/i,a=e/i;if(p[r]=i,e=-a*m[r],m[r]=o*m[r],l)for(let e=0;e<n;e++)i=o*f.get(e,r)+a*f.get(e,t-1),f.set(e,t-1,-a*f.get(e,r)+o*f.get(e,t-1)),f.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(p[S-1]),Math.abs(p[S-2]),Math.abs(m[S-2]),Math.abs(p[t]),Math.abs(m[t])),i=p[S-1]/e,o=p[S-2]/e,a=m[S-2]/e,s=p[t]/e,u=m[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let v=0;0===h&&0===d||(v=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),v=d/(h+v));let y=(s+i)*(s-i)+v,E=s*u;for(let e=t;e<S-1;e++){let i=kw(y,E);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=E/i;if(e!==t&&(m[e-1]=i),y=o*p[e]+a*m[e],m[e]=o*m[e]-a*p[e],E=a*p[e+1],p[e+1]=o*p[e+1],c)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=kw(y,E),0===i&&(i=Number.MIN_VALUE),o=y/i,a=E/i,p[e]=i,y=o*m[e]+a*p[e+1],p[e+1]=-a*m[e]+o*p[e+1],E=a*m[e+1],m[e+1]=o*m[e+1],l&&e<n-1)for(let t=0;t<n;t++)i=o*f.get(t,e)+a*f.get(t,e+1),f.set(t,e+1,-a*f.get(t,e)+o*f.get(t,e+1)),f.set(t,e,i)}m[S-2]=y;break}case 4:if(p[t]<=0&&(p[t]=p[t]<0?-p[t]:0,c))for(let e=0;e<=x;e++)g.set(e,t,-g.get(e,t));for(;t<x&&!(p[t]>=p[t+1]);){let e=p[t];if(p[t]=p[t+1],p[t+1]=e,c&&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=f.get(r,t+1),f.set(r,t+1,f.get(r,t)),f.set(r,t,e);t++}S--}}if(u){let t=g;g=f,f=t}this.m=n,this.n=r,this.s=p,this.U=f,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=Dw.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,c=o.rows,u=Dw.zeros(l,c);for(let t=0;t<l;t++)for(let e=0;e<c;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);u.set(t,e,n)}return u.mmul(e)}solveForDiagonal(t){return this.solve(Dw.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new Dw(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 Dw(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 Dw.diag(this.s)}}var Fw={center:[0,0],linkDistance:50},Uw=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=wc(wc({},Fw),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f;return Ic(this,(function(g){return r=wc(wc({},this.options),n),i=r.center,o=void 0===i?[0,0]:i,a=r.linkDistance,s=void 0===a?50:a,l=e.getAllNodes(),c=e.getAllEdges(),(null==l?void 0:l.length)&&1!==l.length?(u=NP({nodes:l,edges:c},!1),h=wP(u),Gw(h),d=OP(h,s),p=Vw(d),f=[],p.forEach((function(t,e){var n=GP(l[e]);n.data.x=t[0]+o[0],n.data.y=t[1]+o[1],f.push(n)})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:c}]):[2,HP(e,t,o)]}))}))},t}(),Gw=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(n,r){n.forEach((function(n,i){n===1/0&&(t[r][i]=e)}))}))},Vw=function(t){var e=Dw.mul(Dw.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);var o=new Lw(e),a=Dw.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((function(t){return Dw.mul([t],[a]).toJSON()[0].splice(0,2)}))};function Ww(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,l,c,u,h,d,p=t._root,f={data:r},g=t._x0,m=t._y0,v=t._x1,y=t._y1;if(!p)return t._root=f,t;for(;p.length;)if((c=e>=(o=(g+v)/2))?g=o:v=o,(u=n>=(a=(m+y)/2))?m=a:y=a,i=p,!(p=p[h=u<<1|c]))return i[h]=f,t;if(s=+t._x.call(null,p.data),l=+t._y.call(null,p.data),e===s&&n===l)return f.next=p,i?i[h]=f:t._root=f,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(c=e>=(o=(g+v)/2))?g=o:v=o,(u=n>=(a=(m+y)/2))?m=a:y=a}while((h=u<<1|c)==(d=(l>=a)<<1|s>=o));return i[d]=p,i[h]=f,t}function zw(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Hw(t){return t[0]}function jw(t){return t[1]}function Xw(t,e,n){var r=new Yw(null==e?Hw:e,null==n?jw:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Yw(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 Kw(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var qw=Xw.prototype=Yw.prototype;function $w(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,l,c,u,h,d,p,f,g,m,v=t._root,y={data:i},E=t._x0,_=t._y0,b=t._z0,S=t._x1,x=t._y1,T=t._z1;if(!v)return t._root=y,t;for(;v.length;)if((d=e>=(a=(E+S)/2))?E=a:S=a,(p=n>=(s=(_+x)/2))?_=s:x=s,(f=r>=(l=(b+T)/2))?b=l:T=l,o=v,!(v=v[g=f<<2|p<<1|d]))return o[g]=y,t;if(c=+t._x.call(null,v.data),u=+t._y.call(null,v.data),h=+t._z.call(null,v.data),e===c&&n===u&&r===h)return y.next=v,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(E+S)/2))?E=a:S=a,(p=n>=(s=(_+x)/2))?_=s:x=s,(f=r>=(l=(b+T)/2))?b=l:T=l}while((g=f<<2|p<<1|d)==(m=(h>=l)<<2|(u>=s)<<1|c>=a));return o[m]=v,o[g]=y,t}function Zw(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}function Qw(t){return t[0]}function Jw(t){return t[1]}function tN(t){return t[2]}function eN(t,e,n,r){var i=new nN(null==e?Qw:e,null==n?Jw:n,null==r?tN:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function nN(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 rN(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}qw.copy=function(){var t,e,n=new Yw(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=Kw(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]=Kw(e));return n},qw.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Ww(this.cover(e,n),e,n,t)},qw.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),l=1/0,c=1/0,u=-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>u&&(u=r),i<c&&(c=i),i>h&&(h=i));if(l>u||c>h)return this;for(this.cover(l,c).cover(u,h),n=0;n<o;++n)Ww(this,a[n],s[n],t[n]);return this},qw.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,c=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=c,c=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=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},qw.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},qw.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]]},qw.find=function(t,e,n){var r,i,o,a,s,l,c,u=this._x0,h=this._y0,d=this._x1,p=this._y1,f=[],g=this._root;for(g&&f.push(new zw(g,u,h,d,p)),null==n?n=1/0:(u=t-n,h=e-n,d=t+n,p=e+n,n*=n);l=f.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(o=l.y0)>p||(a=l.x1)<u||(s=l.y1)<h))if(g.length){var m=(i+a)/2,v=(o+s)/2;f.push(new zw(g[3],m,v,a,s),new zw(g[2],i,v,m,s),new zw(g[1],m,o,a,v),new zw(g[0],i,o,m,v)),(c=(e>=v)<<1|t>=m)&&(l=f[f.length-1],f[f.length-1]=f[f.length-1-c],f[f.length-1-c]=l)}else{var y=t-+this._x.call(null,g.data),E=e-+this._y.call(null,g.data),_=y*y+E*E;if(_<n){var b=Math.sqrt(n=_);u=t-b,h=e-b,d=t+b,p=e+b,r=g.data}}return r},qw.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,c,u,h,d,p=this._root,f=this._x0,g=this._y0,m=this._x1,v=this._y1;if(!p)return this;if(p.length)for(;;){if((c=o>=(s=(f+m)/2))?f=s:m=s,(u=a>=(l=(g+v)/2))?g=l:v=l,e=p,!(p=p[h=u<<1|c]))return this;if(!p.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}for(;p.data!==t;)if(r=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(p=e[0]||e[1]||e[2]||e[3])&&p===(e[3]||e[2]||e[1]||e[0])&&!p.length&&(n?n[d]=p:this._root=p),this):(this._root=i,this)},qw.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},qw.root=function(){return this._root},qw.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},qw.visit=function(t){var e,n,r,i,o,a,s=[],l=this._root;for(l&&s.push(new zw(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 c=(r+o)/2,u=(i+a)/2;(n=l[3])&&s.push(new zw(n,c,u,o,a)),(n=l[2])&&s.push(new zw(n,r,u,c,a)),(n=l[1])&&s.push(new zw(n,c,i,o,u)),(n=l[0])&&s.push(new zw(n,r,i,c,u))}return this},qw.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new zw(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,c=e.y1,u=(a+l)/2,h=(s+c)/2;(o=i[0])&&n.push(new zw(o,a,s,u,h)),(o=i[1])&&n.push(new zw(o,u,s,l,h)),(o=i[2])&&n.push(new zw(o,a,h,u,c)),(o=i[3])&&n.push(new zw(o,u,h,l,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},qw.x=function(t){return arguments.length?(this._x=t,this):this._x},qw.y=function(t){return arguments.length?(this._y=t,this):this._y};var iN=eN.prototype=nN.prototype;iN.copy=function(){var t,e,n=new nN(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=rN(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]=rN(e));return n},iN.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return $w(this.cover(e,n,r),e,n,r,t)},iN.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,c=-1/0,u=-1/0;for(let h,d,p,f,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(p=+this._y.call(null,h))||isNaN(f=+this._z.call(null,h))||(n[g]=d,r[g]=p,i[g]=f,d<o&&(o=d),d>l&&(l=d),p<a&&(a=p),p>c&&(c=p),f<s&&(s=f),f>u&&(u=f));if(o>l||a>c||s>u)return this;this.cover(o,a,s).cover(l,c,u);for(let o=0;o<e;++o)$w(this,n[o],r[o],i[o],t[o]);return this},iN.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 c,u,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=l;)switch(u=(n<o)<<2|(e<i)<<1|t<r,(c=new Array(8))[u]=d,d=c,h*=2,u){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},iN.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},iN.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]]},iN.find=function(t,e,n,r){var i,o,a,s,l,c,u,h,d,p=this._x0,f=this._y0,g=this._z0,m=this._x1,v=this._y1,y=this._z1,E=[],_=this._root;for(_&&E.push(new Zw(_,p,f,g,m,v,y)),null==r?r=1/0:(p=t-r,f=e-r,g=n-r,m=t+r,v=e+r,y=n+r,r*=r);h=E.pop();)if(!(!(_=h.node)||(o=h.x0)>m||(a=h.y0)>v||(s=h.z0)>y||(l=h.x1)<p||(c=h.y1)<f||(u=h.z1)<g))if(_.length){var b=(o+l)/2,S=(a+c)/2,x=(s+u)/2;E.push(new Zw(_[7],b,S,x,l,c,u),new Zw(_[6],o,S,x,b,c,u),new Zw(_[5],b,a,x,l,S,u),new Zw(_[4],o,a,x,b,S,u),new Zw(_[3],b,S,s,l,c,x),new Zw(_[2],o,S,s,b,c,x),new Zw(_[1],b,a,s,l,S,x),new Zw(_[0],o,a,s,b,S,x)),(d=(n>=x)<<2|(e>=S)<<1|t>=b)&&(h=E[E.length-1],E[E.length-1]=E[E.length-1-d],E[E.length-1-d]=h)}else{var T=t-+this._x.call(null,_.data),A=e-+this._y.call(null,_.data),R=n-+this._z.call(null,_.data),M=T*T+A*A+R*R;if(M<r){var C=Math.sqrt(r=M);p=t-C,f=e-C,g=n-C,m=t+C,v=e+C,y=n+C,i=_.data}}return i},iN.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,c,u,h,d,p,f,g,m=this._root,v=this._x0,y=this._y0,E=this._z0,_=this._x1,b=this._y1,S=this._z1;if(!m)return this;if(m.length)for(;;){if((h=o>=(l=(v+_)/2))?v=l:_=l,(d=a>=(c=(y+b)/2))?y=c:b=c,(p=s>=(u=(E+S)/2))?E=u:S=u,e=m,!(m=m[f=p<<2|d<<1|h]))return this;if(!m.length)break;(e[f+1&7]||e[f+2&7]||e[f+3&7]||e[f+4&7]||e[f+5&7]||e[f+6&7]||e[f+7&7])&&(n=e,g=f)}for(;m.data!==t;)if(r=m,!(m=m.next))return this;return(i=m.next)&&delete m.next,r?(i?r.next=i:delete r.next,this):e?(i?e[f]=i:delete e[f],(m=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&m===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!m.length&&(n?n[g]=m:this._root=m),this):(this._root=i,this)},iN.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},iN.root=function(){return this._root},iN.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},iN.visit=function(t){var e,n,r,i,o,a,s,l,c=[],u=this._root;for(u&&c.push(new Zw(u,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(u=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,l=e.z1)&&u.length){var h=(r+a)/2,d=(i+s)/2,p=(o+l)/2;(n=u[7])&&c.push(new Zw(n,h,d,p,a,s,l)),(n=u[6])&&c.push(new Zw(n,r,d,p,h,s,l)),(n=u[5])&&c.push(new Zw(n,h,i,p,a,d,l)),(n=u[4])&&c.push(new Zw(n,r,i,p,h,d,l)),(n=u[3])&&c.push(new Zw(n,h,d,o,a,s,p)),(n=u[2])&&c.push(new Zw(n,r,d,o,h,s,p)),(n=u[1])&&c.push(new Zw(n,h,i,o,a,d,p)),(n=u[0])&&c.push(new Zw(n,r,i,o,h,d,p))}return this},iN.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Zw(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,c=e.x1,u=e.y1,h=e.z1,d=(a+c)/2,p=(s+u)/2,f=(l+h)/2;(o=i[0])&&n.push(new Zw(o,a,s,l,d,p,f)),(o=i[1])&&n.push(new Zw(o,d,s,l,c,p,f)),(o=i[2])&&n.push(new Zw(o,a,p,l,d,u,f)),(o=i[3])&&n.push(new Zw(o,d,p,l,c,u,f)),(o=i[4])&&n.push(new Zw(o,a,s,f,d,p,h)),(o=i[5])&&n.push(new Zw(o,d,s,f,c,p,h)),(o=i[6])&&n.push(new Zw(o,a,p,f,d,u,h)),(o=i[7])&&n.push(new Zw(o,d,p,f,c,u,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},iN.x=function(t){return arguments.length?(this._x=t,this):this._x},iN.y=function(t){return arguments.length?(this._y=t,this):this._y},iN.z=function(t){return arguments.length?(this._z=t,this):this._z};function oN(t,e,n,r,i){void 0===i&&(i=2);var o=e/n,a=t.getAllNodes(),s=a.map((function(t,e){var n=t.data,r=n.nodeStrength;return{x:n.x,y:n.y,z:n.z,size:n.size,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*r}})),l=(2===i?Xw(s,(function(t){return t.x}),(function(t){return t.y})):eN(s,(function(t){return t.x}),(function(t){return t.y}),(function(t){return t.z}))).visitAfter(aN),c=new Map;return s.forEach((function(t){c.set(t.id,t),function(t,e,n){e.visit((function(e,r,i,o,a){return sN(e,r,i,o,a,t,n)}))}(t,l,i)})),s.map((function(t,e){var n=a[e],i=n.id,o=n.data.mass,s=void 0===o?1:o;r[i]={x:t.vx/s,y:t.vy/s,z:t.vz/s}})),r}function aN(t){var e=0,n=0,r=0,i=0,o=0,a=t.length;if(a){for(var s=0;s<a;s++){(l=t[s])&&l.weight&&(e+=l.weight,n+=l.x*l.weight,r+=l.y*l.weight,i+=l.z*l.weight,o+=l.size*l.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{var l=t;t.x=l.data.x,t.y=l.data.y,t.z=l.data.z,t.size=l.data.size,t.weight=l.data.weight}}var sN=function(t,e,n,r,i,o,a){var s;if((null===(s=t.data)||void 0===s?void 0:s.id)!==o.id){for(var l=[n,r,i][a-1],c=o.x-t.x||.1,u=o.y-t.y||.1,h=o.z-t.z||.1,d=[c,u,h],p=l-e,f=0,g=0;g<a;g++)f+=d[g]*d[g];var m=Math.sqrt(f)*f;if(p*p*.81<f){var v=t.weight/m;return o.vx+=c*v,o.vy+=u*v,o.vz+=h*v,!0}if(t.length)return!1;if(t.data!==o){v=t.data.weight/m;o.vx+=c*v,o.vy+=u*v,o.vz+=h*v}}};var lN={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"},cN=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=wc(wc({},lN),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var n=0;(this.judgingDistance>this.lastOptions.minMovement||n<1)&&n<t;n++)this.runOneStep(this.lastCalcGraph,this.lastGraph,n,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var r={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),r},t.prototype.genericForceLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x=this;return Ic(this,(function(T){return r=wc(wc({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),s=a.dimensions,l=a.width,c=a.height,u=a.nodeSize,h=a.getMass,d=a.nodeStrength,p=a.edgeStrength,f=a.linkDistance,g=i.map((function(t,e){return wc(wc({},t),{data:wc(wc({},t.data),{x:Ue(t.data.x)?t.data.x:Math.random()*l,y:Ue(t.data.y)?t.data.y:Math.random()*c,z:Ue(t.data.z)?t.data.z:Math.random()*Math.sqrt(l*c),size:u(t)||30,mass:h(t),nodeStrength:d(t)})})})),m=o.map((function(t){return wc(wc({},t),{data:wc(wc({},t.data),{edgeStrength:p(t),linkDistance:f(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(v={},i.forEach((function(t,e){v[t.id]={x:0,y:0,z:0}})),y=new TP({nodes:g,edges:m}),this.formatCentripetal(a,y),E=a.maxIteration,_=a.minMovement,b=a.onTick,this.lastLayoutNodes=g,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=v,"undefined"==typeof window?[2]:(S=0,[2,new Promise((function(n){x.timeInterval=window.setInterval((function(){i&&x.running||n({nodes:fN(e,g),edges:o}),x.runOneStep(y,e,S,v,a),x.updatePosition(e,y,v,a),t&&g.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0})})),null==b||b({nodes:fN(e,g),edges:o}),(++S>=E||x.judgingDistance<_)&&(window.clearInterval(x.timeInterval),n({nodes:fN(e,g),edges:o}))}),0),x.running=!0}))])):(this.lastResult={nodes:[],edges:o},[2,{nodes:[],edges:o}])}))}))},t.prototype.formatOptions=function(t,e){var n=wc({},t),r=t.width,i=t.height,o=t.getMass,a=t.nodeSize;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=function(t){var n=1;Ue(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);var r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n});var s,l=VP(0,t.nodeSpacing);s=a?Se(a)?function(t){return a(t)+l(t)}:PP(a)?function(t){var e=a;return Math.max(e[0],e[1])+l(t)}:function(t){return a+l(t)}:function(t){var e=((null==t?void 0:t.data)||{}).size;return e?PP(e)?Math.max(e[0],e[1])+l(t):Me(e)?Math.max(e.width,e.height)+l(t):e+l(t):10+l(t)},n.nodeSize=s;var c=t.linkDistance?VP(1,t.linkDistance):function(t){return 1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target))};return n.linkDistance=c,n.nodeStrength=VP(1,t.nodeStrength),n.edgeStrength=VP(1,t.edgeStrength),n},t.prototype.formatCentripetal=function(t,e){var n,r,i=t.dimensions,o=t.centripetalOptions,a=t.center,s=t.clusterNodeStrength,l=t.leafCluster,c=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),d=o||{leaf:2,single:2,others:1,center:function(t){return{x:a[0],y:a[1],z:3===i?a[2]:void 0}}};if("function"!=typeof s&&(t.clusterNodeStrength=function(t){return s}),l&&u&&(n=uN(e,u),r=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],t.centripetalOptions=Object.assign(d,{single:100,leaf:function(e){var i=n[e.id]||{},o=i.siblingLeaves,a=i.sameTypeLeaves;return(null==a?void 0:a.length)===(null==o?void 0:o.length)||1===(null==r?void 0:r.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var r,i=e.getDegree(t.id,"both");if(!i)return{x:100,y:100,z:0};if(1===i){var o=(n[t.id]||{}).sameTypeLeaves,a=void 0===o?[]:o;1===a.length?r=void 0:a.length>1&&(r=pN(a))}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}}})),c&&u){n||(n=uN(e,u)),r||(r=Array.from(new Set(h.map((function(t){return t.data[u]}))))),r=r.filter((function(t){return void 0!==t}));var p={};r.forEach((function(t){var n=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));p[t]=pN(n)})),t.centripetalOptions=Object.assign(d,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=p[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}var f=t.centripetalOptions||{},g=f.leaf,m=f.single,v=f.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),m&&"function"!=typeof m&&(t.centripetalOptions.single=function(){return m}),v&&"function"!=typeof v&&(t.centripetalOptions.others=function(){return v})},t.prototype.runOneStep=function(t,e,n,r,i){var o={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var l=i.monitor;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})}},t.prototype.calTotalEnergy=function(t,e){var n=this;if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,i){var o=t[e.id].x,a=t[e.id].y,s=3===n.options.dimensions?t[e.id].z:0,l=o*o+a*a+s*s,c=e.data.mass;r+=(void 0===c?1:c)*l*.5})),r},t.prototype.calRepulsive=function(t,e,n){var r=n.dimensions,i=n.factor,o=n.coulombDisScale;oN(t,i,o*o,e,r)},t.prototype.calAttractive=function(t,e,n){var r=n.dimensions,i=n.nodeSize;t.getAllEdges().forEach((function(n,o){var a=n.source,s=n.target,l=t.getNode(a),c=t.getNode(s);if(l&&c){var u=c.data.x-l.data.x,h=c.data.y-l.data.y,d=3===r?c.data.z-l.data.z:0;u||h||(u=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));var p=Math.sqrt(u*u+h*h+d*d);if(!(p<i(l)+i(c))){var f=u/p,g=h/p,m=d/p,v=n.data||{},y=v.linkDistance,E=void 0===y?200:y,_=v.edgeStrength,b=(E-p)*(void 0===_?200:_),S=1/(l.data.mass||1),x=1/(c.data.mass||1),T=f*b,A=g*b,R=m*b;e[a].x-=T*S,e[a].y-=A*S,e[a].z-=R*S,e[s].x+=T*x,e[s].y+=A*x,e[s].z+=R*x}}}))},t.prototype.calGravity=function(t,e,n,r){var i=r.getCenter,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),l=r.width,c=r.height,u=r.center,h=r.gravity,d=r.centripetalOptions;o&&o.forEach((function(r){var o=r.id,p=r.data,f=p.mass,g=p.x,m=p.y,v=p.z,y=e.getNode(o),E=0,_=0,b=0,S=h,x=t.getDegree(o,"in"),T=t.getDegree(o,"out"),A=t.getDegree(o,"both"),R=null==i?void 0:i(y,A);if(R){var M=Bc(R,3);E=g-M[0],_=m-M[1],S=M[2]}else E=g-u[0],_=m-u[1],b=v-u[2];if(S&&(n[o].x-=S*E/f,n[o].y-=S*_/f,n[o].z-=S*b/f),d){var C=d.leaf,P=d.single,w=d.others,N=d.center,O=(null==N?void 0:N(y,a,s,l,c))||{x:0,y:0,z:0,centerStrength:0},I=O.x,D=O.y,B=O.z,k=O.centerStrength;if(!Ue(I)||!Ue(D))return;var L=(g-I)/f,F=(m-D)/f,U=(v-B)/f;if(k&&(n[o].x-=k*L,n[o].y-=k*F,n[o].z-=k*U),0===A){var G=P(y);if(!G)return;return n[o].x-=G*L,n[o].y-=G*F,void(n[o].z-=G*U)}if(0===x||0===T){var V=C(y,a,s);if(!V)return;return n[o].x-=V*L,n[o].y-=V*F,void(n[o].z-=V*U)}var W=w(y);if(!W)return;n[o].x-=W*L,n[o].y-=W*F,n[o].z-=W*U}}))},t.prototype.updateVelocity=function(t,e,n,r){var i=r.damping,o=r.maxSpeed,a=r.interval,s=r.dimensions,l=t.getAllNodes();(null==l?void 0:l.length)&&l.forEach((function(t){var r=t.id,l=(n[r].x+e[r].x*a)*i||.01,c=(n[r].y+e[r].y*a)*i||.01,u=3===s?(n[r].z+e[r].z*a)*i||.01:0,h=Math.sqrt(l*l+c*c+u*u);if(h>o){var d=o/h;l*=d,c*=d,u*=d}n[r]={x:l,y:c,z:u}}))},t.prototype.updatePosition=function(t,e,n,r){var i=this,o=r.distanceThresholdMode,a=r.interval,s=r.dimensions,l=e.getAllNodes();if(null==l?void 0:l.length){var c=0;"max"===o?this.judgingDistance=-1/0:"min"===o&&(this.judgingDistance=1/0),l.forEach((function(r){var l=r.id,u=t.getNode(l);if(Ue(u.data.fx)&&Ue(u.data.fy))e.mergeNodeData(l,{x:u.data.fx,y:u.data.fy,z:3===s?u.data.fz:void 0});else{var h=n[l].x*a,d=n[l].y*a,p=3===s?n[l].z*a:0;e.mergeNodeData(l,{x:r.data.x+h,y:r.data.y+d,z:r.data.z+p});var f=Math.sqrt(h*h+d*d+p*p);switch(o){case"max":i.judgingDistance<f&&(i.judgingDistance=f);break;case"min":i.judgingDistance>f&&(i.judgingDistance=f);break;default:c+=f}}})),o&&"mean"!==o||(this.judgingDistance=c/l.length)}else this.judgingDistance=0},t}(),uN=function(t,e){var n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};var r={};return n.forEach((function(n,i){1===t.getDegree(n.id,"both")&&(r[n.id]=hN(t,"leaf",n,e))})),r},hN=function(t,e,n,r){var i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out"),a=n,s=[];return 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((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:dN(t,e,r,n,s)}},dN=function(t,e,n,r,i){var o=r.data[n]||"",a=(null==i?void 0:i.filter((function(t){return t.data[n]===o})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},pN=function(t){var e={x:0,y:0};t.forEach((function(t){var n=t.data,r=n.x,i=n.y;e.x+=r||0,e.y+=i||0}));var n=t.length||1;return{x:e.x/n,y:e.y/n}},fN=function(t,e){return e.map((function(e){var n=e.id,r=e.data,i=t.getNode(n);return wc(wc({},i),{data:wc(wc({},i.data),{x:r.x,y:r.y,z:r.z})})}))},gN={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},mN=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=wc(wc({},gN),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P,w,N,O,I,D,B,k,L,F,U,G;return Ic(this,(function(V){if(r=wc(wc({},this.options),n),i=r.center,o=r.width,a=r.height,s=r.sortBy,l=r.maxLevelDiff,c=r.sweep,u=r.clockwise,h=r.equidistant,d=r.preventOverlap,p=r.startAngle,f=void 0===p?1.5*Math.PI:p,g=r.nodeSize,m=r.nodeSpacing,v=e.getAllNodes(),y=e.getAllEdges(),E=o||"undefined"==typeof window?o:window.innerWidth,_=a||"undefined"==typeof window?a:window.innerHeight,b=i||[E/2,_/2],!(null==v?void 0:v.length)||1===v.length)return[2,HP(e,t,b)];if(S=[],T=0,PP(g)?x=Math.max(g[0],g[1]):Se(g)?(x=-1/0,v.forEach((function(t){var e=g(t);e>x&&(x=e)}))):x=g,PP(m)?T=Math.max(m[0],m[1]):Ue(m)&&(T=m),v.forEach((function(t){var e=GP(t);S.push(e);var n=x,r=e.data;PP(r.size)?n=Math.max(r.size[0],r.size[1]):Ue(r.size)?n=r.size:Me(r.size)&&(n=Math.max(r.size.width,r.size.height)),x=Math.max(x,n),Se(m)&&(T=Math.max(m(t),T))})),A={},S.forEach((function(t,e){A[t.id]=e})),De(R=s)&&void 0!==S[0].data[R]||(R="degree"),"degree"===R?S.sort((function(t,n){return e.getDegree(n.id,"both")-e.getDegree(t.id,"both")})):S.sort((function(t,e){return e.data[R]-t.data[R]})),M=S[0],C=(l||("degree"===R?e.getDegree(M.id,"both"):M.data[R]))/4,w=(P=[{nodes:[]}])[0],S.forEach((function(t){if(w.nodes.length>0){var n="degree"===R?Math.abs(e.getDegree(w.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(w.nodes[0].data[R]-t.data[R]);C&&n>=C&&(w={nodes:[]},P.push(w))}w.nodes.push(t)})),N=x+T,d||(O=P.length>0&&P[0].nodes.length>1,I=Math.min(E,_)/2-N,D=I/(P.length+(O?1:0)),N=Math.min(N,D)),B=0,P.forEach((function(t){var e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){var n=Math.cos(t.dTheta)-Math.cos(0),r=Math.sin(t.dTheta)-Math.sin(0),i=Math.sqrt(N*N/(n*n+r*r));B=Math.max(i,B)}t.r=B,B+=N})),h){for(k=0,L=0,F=0;F<P.length;F++)U=P[F],G=(U.r||0)-L,k=Math.max(k,G);L=0,P.forEach((function(t,e){0===e&&(L=t.r||0),t.r=L,L+=k}))}return P.forEach((function(t){var e=t.dTheta||0,n=t.r||0;t.nodes.forEach((function(t,r){var i=f+(u?1:-1)*e*r;t.data.x=b[0]+n*Math.cos(i),t.data.y=b[1]+n*Math.sin(i)}))})),t&&S.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:S,edges:y}]}))}))},t}(),vN={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},yN={center:[0,0],comboPadding:10,treeKey:"combo"},EN=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="comboCombined",this.options=wc(wc({},yN),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericComboCombinedLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){switch(n.label){case 0:return[4,this.genericComboCombinedLayout(!0,t,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.genericComboCombinedLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x;return Ic(this,(function(T){switch(T.label){case 0:return r=this.initVals(wc(wc({},this.options),n)),i=r.center,o=r.treeKey,a=r.outerLayout,s=e.getAllNodes().filter((function(t){return!t.data._isCombo})),l=e.getAllNodes().filter((function(t){return t.data._isCombo})),c=e.getAllEdges(),(u=null==s?void 0:s.length)&&1!==u?(h=[],d=new Map,s.forEach((function(t){d.set(t.id,t)})),p=new Map,l.forEach((function(t){p.set(t.id,t)})),f=new Map,g=this.getInnerGraphs(e,o,d,p,c,r,f),[4,Promise.all(g)]):[2,HP(e,t,i)];case 1:return T.sent(),m=new Map,v=[],y=new Map,E=!0,e.getRoots(o).forEach((function(t){var n=f.get(t.id),r=p.get(t.id)||d.get(t.id),i={id:t.id,data:wc(wc({},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})};v.push(i),m.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()):E=!1,FP(e,[t],(function(e){e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)})),_=[],c.forEach((function(t){var e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&m.has(e)&&m.has(n)&&_.push({id:t.id,source:e,target:n,data:{}})})),(null==v?void 0:v.length)?1!==v.length?[3,2]:(v[0].data.x=i[0],v[0].data.y=i[1],[3,6]):[3,7];case 2:return S=new TP({nodes:v,edges:_}),x=a||new cN,E&&vN[x.id]?[4,(v.length<100?new Uw:new mN).assign(S)]:[3,4];case 3:T.sent(),T.label=4;case 4:return[4,x.execute(S,wc({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===x.id?{gravity:1,factor:4,linkDistance:function(t,e,n){return(Math.max.apply(Math,kc([],Bc(e.data.size)))||32)/2+(Math.max.apply(Math,kc([],Bc(n.data.size)))||32)/2+200}}:{}))];case 5:b=T.sent(),T.label=6;case 6:f.forEach((function(t){var e,n=b.nodes.find((function(e){return e.id===t.id}));if(n){var r=n.data,i=r.x,o=r.y;t.data.visited=!0,t.data.x=i,t.data.y=o,h.push({id:t.id,data:{x:i,y:o}})}var a=t.data,s=a.x,l=a.y;null===(e=t.data.nodes)||void 0===e||e.forEach((function(t){h.push({id:t.id,data:{x:t.data.x+s,y:t.data.y+l}})}))})),f.forEach((function(t){var e,n=t.data,r=n.x,i=n.y,o=n.visited;null===(e=n.nodes)||void 0===e||e.forEach((function(t){if(!o){var e=h.find((function(e){return e.id===t.id}));e.data.x+=r||0,e.data.y+=i||0}}))})),T.label=7;case 7:return t&&h.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:h,edges:c}]}}))}))},t.prototype.initVals=function(t){var e,n,r,i=wc({},t),o=t.nodeSize,a=t.spacing,s=t.comboPadding;if(n=Ue(a)?function(){return a}:Se(a)?a:function(){return 0},i.spacing=n,o)if(Se(o))e=function(t){var e=o(t),r=n(t);return PP(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2:((e||32)+r)/2};else if(PP(o)){var l=(o[0]>o[1]?o[0]:o[1])/2;e=function(t){return l+n(t)/2}}else{var c=o/2;e=function(t){return c+n(t)/2}}else e=function(t){var e=n(t);return t.size?PP(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2:Me(t.size)?((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2:(t.size+e)/2:32+e/2};return i.nodeSize=e,r=Ue(s)?function(){return s}:PP(s)?function(){return Math.max.apply(null,s)}:Se(s)?s:function(){return 0},i.comboPadding=r,i},t.prototype.getInnerGraphs=function(t,e,n,r,i,o,a){var s=this,l=o.nodeSize,c=o.comboPadding,u=o.spacing,h=o.innerLayout||new mN({}),d={center:[0,0],preventOverlap:!0,nodeSpacing:u},p=[],f=function(t){var e=(null==c?void 0:c(t))||10;return PP(e)&&(e=Math.max.apply(Math,kc([],Bc(e)))),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((function(o){a.set(o.id,{id:o.id,data:{nodes:[],size:f(o).size}});var c=Promise.resolve();FP(t,[o],(function(o){var u;if(o.data._isCombo){var p=f(o),g=p.size,m=p.padding;if(null===(u=t.getChildren(o.id,e))||void 0===u?void 0:u.length){var v=a.get(o.id);a.set(o.id,{id:o.id,data:wc({nodes:[]},null==v?void 0:v.data)});var y=new Map,E=t.getChildren(o.id,e).map((function(t){if(t.data._isCombo)return a.has(t.id)||a.set(t.id,{id:t.id,data:wc({},t.data)}),y.set(t.id,!0),a.get(t.id);var e=n.get(t.id)||r.get(t.id);return y.set(t.id,!0),{id:t.id,data:wc(wc({},e.data),t.data)}})),_={nodes:E,edges:i.filter((function(t){return y.has(t.source)&&y.has(t.target)}))},b=1/0;E.forEach((function(t){var e,n,r=t.data.size;r||(r=(null===(e=a.get(t.id))||void 0===e?void 0:e.data.size)||(null===(n=l)||void 0===n?void 0:n(t))||[30,30]),Ue(r)&&(r=[r,r]);var i=Bc(r,2),o=i[0],s=i[1];b>o&&(b=o),b>s&&(b=s),t.data.size=r})),c=c.then((function(){return Oc(s,void 0,void 0,(function(){var t,e,n,r,i,s,l,c,u;return Ic(this,(function(p){switch(p.label){case 0:return t=new TP(_),[4,h.assign(t,d)];case 1:return e=p.sent(),n=DP(E),r=n.minX,i=n.minY,s=n.maxX,l=n.maxY,c={x:(s+r)/2,y:(l+i)/2},_.nodes.forEach((function(t){t.data.x-=c.x,t.data.y-=c.y})),u=[Math.max(s-r,b)+2*m,Math.max(l-i,b)+2*m],a.get(o.id).data.size=u,a.get(o.id).data.nodes=E,[2,e]}}))}))}))}else a.set(o.id,{id:o.id,data:wc(wc({},o.data),{size:g})});return!0}}),"BT",e),p.push(c)})),p},t}();function _N(t){return function(){return t}}function bN(t){return 1e-6*(t()-.5)}function SN(t){return t.x+t.vx}function xN(t){return t.y+t.vy}function TN(t){var e,n,r,i=1,o=1;function a(){for(var t,a,l,c,u,h,d,p=e.length,f=0;f<o;++f)for(a=Xw(e,SN,xN).visitAfter(s),t=0;t<p;++t)l=e[t],h=n[l.index],d=h*h,c=l.x+l.vx,u=l.y+l.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,p=t.r,f=h+p;if(!s)return e>c+f||o<c-f||n>u+f||a<u-f;if(s.index>l.index){var g=c-s.x-s.vx,m=u-s.y-s.vy,v=g*g+m*m;v<f*f&&(0===g&&(v+=(g=bN(r))*g),0===m&&(v+=(m=bN(r))*m),v=(f-(v=Math.sqrt(v)))/v*i,l.vx+=(g*=v)*(f=(p*=p)/(d+p)),l.vy+=(m*=v)*f,s.vx-=g*(f=1-f),s.vy-=m*f)}}}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=_N(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:_N(+e),l(),a):t},a}function AN(t){return t.index}function RN(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function MN(t){var e,n,r,i,o,a,s=AN,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=_N(30),u=1;function h(r){for(var i=0,s=t.length;i<u;++i)for(var l,c,h,d,p,f,g,m=0;m<s;++m)c=(l=t[m]).source,d=(h=l.target).x+h.vx-c.x-c.vx||bN(a),p=h.y+h.vy-c.y-c.vy||bN(a),d*=f=((f=Math.sqrt(d*d+p*p))-n[m])/f*r*e[m],p*=f,h.vx-=d*(g=o[m]),h.vy-=p*g,c.vx+=d*(g=1-g),c.vy+=p*g}function d(){if(r){var a,l,c=r.length,u=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(c);a<u;++a)(l=t[a]).index=a,"object"!=typeof l.source&&(l.source=RN(h,l.source)),"object"!=typeof l.target&&(l.target=RN(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(u);a<u;++a)l=t[a],o[a]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(u),p(),n=new Array(u),f()}}function p(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function f(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+c(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?(u=+t,h):u},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:_N(+t),p(),h):l},h.distance=function(t){return arguments.length?(c="function"==typeof t?t:_N(+t),f(),h):c},h}var CN={value:()=>{}};function PN(){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 wN(r)}function wN(t){this._=t}function NN(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function ON(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=CN,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}wN.prototype=PN.prototype={constructor:wN,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]=ON(i[n],t.name,e);else if(null==e)for(n in i)i[n]=ON(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=NN(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new wN(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 IN,DN,BN=0,kN=0,LN=0,FN=1e3,UN=0,GN=0,VN=0,WN="object"==typeof performance&&performance.now?performance:Date,zN="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function HN(){return GN||(zN(jN),GN=WN.now()+VN)}function jN(){GN=0}function XN(){this._call=this._time=this._next=null}function YN(t,e,n){var r=new XN;return r.restart(t,e,n),r}function KN(){GN=(UN=WN.now())+VN,BN=kN=0;try{!function(){HN(),++BN;for(var t,e=IN;e;)(t=GN-e._time)>=0&&e._call.call(void 0,t),e=e._next;--BN}()}finally{BN=0,function(){var t,e,n=IN,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:IN=e);DN=t,$N(r)}(),GN=0}}function qN(){var t=WN.now(),e=t-UN;e>FN&&(VN-=e,UN=t)}function $N(t){BN||(kN&&(kN=clearTimeout(kN)),t-GN>24?(t<1/0&&(kN=setTimeout(KN,t-WN.now()-VN)),LN&&(LN=clearInterval(LN))):(LN||(UN=WN.now(),LN=setInterval(qN,FN)),BN=1,zN(KN)))}XN.prototype=YN.prototype={constructor:XN,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?HN():+n)+(null==e?0:+e),this._next||DN===this||(DN?DN._next=this:IN=this,DN=this),this._call=t,this._time=n,$N()},stop:function(){this._call&&(this._call=null,this._time=1/0,$N())}};const ZN=1664525,QN=1013904223,JN=4294967296;function tO(t){return t.x}function eO(t){return t.y}var nO=10,rO=Math.PI*(3-Math.sqrt(5));function iO(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=YN(h),c=PN("tick","end"),u=function(){let t=1;return()=>(t=(ZN*t+QN)%JN)/JN}();function h(){d(),c.call("tick",e),n<r&&(l.stop(),c.call("end",e))}function d(r){var l,c,u=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<u;++l)null==(c=t[l]).fx?c.x+=c.vx*=a:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=a:(c.y=c.fy,c.vy=0);return e}function p(){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=nO*Math.sqrt(.5+n),o=n*rO;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function f(e){return e.initialize&&e.initialize(t,u),e}return null==t&&(t=[]),p(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,p(),s.forEach(f),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?(u=t,s.forEach(f),e):u},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,f(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,l,c=0,u=t.length;for(null==r?r=1/0:r*=r,c=0;c<u;++c)(a=(i=e-(s=t[c]).x)*i+(o=n-s.y)*o)<r&&(l=s,r=a);return l},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function oO(){var t,e,n,r,i,o=_N(-30),a=1,s=1/0,l=.81;function c(n){var i,o=t.length,a=Xw(t,tO,eO).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function u(){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,c,u){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,p=u-o,f=h*h+d*d;if(p*p/l<f)return f<s&&(0===h&&(f+=(h=bN(n))*h),0===d&&(f+=(d=bN(n))*d),f<a&&(f=Math.sqrt(a*f)),e.vx+=h*t.value*r/f,e.vy+=d*t.value*r/f),!0;if(!(t.length||f>=s)){(t.data!==e||t.next)&&(0===h&&(f+=(h=bN(n))*h),0===d&&(f+=(d=bN(n))*d),f<a&&(f=Math.sqrt(a*f)));do{t.data!==e&&(p=i[t.data.index]*r/f,e.vx+=h*p,e.vy+=d*p)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,u()},c.strength=function(t){return arguments.length?(o="function"==typeof t?t:_N(+t),u(),c):o},c.distanceMin=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.theta=function(t){return arguments.length?(l=t*t,c):Math.sqrt(l)},c}function aO(t){var e,n,r,i=_N(.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=_N(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:_N(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:_N(+e),a(),o):t},o}function sO(t){var e,n,r,i=_N(.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=_N(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:_N(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:_N(+e),a(),o):t},o}function lO(){function t(t){return function(){return t}}var e,n=function(t){return t.cluster},r=t(1),i=t(-1),o=t(100),a=t(.1),s=[0,0],l=[],c={},u=[],h=100,d=100,p={none:{x:0,y:0}},f=[],g="force",m=!0,v=.1;function y(t){if(!m)return y;e.tick(),_();for(var r=0,i=l.length,o=void 0,a=t*v;r<i;++r)(o=l[r]).vx+=(p[n(o)].x-o.x)*a,o.vy+=(p[n(o)].y-o.y)*a}function E(){l&&function(){if(!l||!l.length)return;if(void 0===n(l[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t=(s=[],p=[],g={},m={},v=[],m=function(t){var e={};return t.forEach((function(t){var r=n(t);e[r]||(e[r]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var i=n(t),o=r(t),a=e[i];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=a})),e}(l),v=function(t){var e={},r=[];return t.forEach((function(t){var r=function(t){var e=t.source,r=t.target,i=n(c[e]),o=n(c[r]);return i<=o?i+"~"+o:o+"~"+i}(t),i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i})),Object.entries(e).forEach((function(t){var e=Bc(t,2),n=e[0],i=e[1],o=n.split("~")[0],a=n.split("~")[1];void 0!==o&&void 0!==a&&r.push({source:o,target:a,count:i})})),r}(u),Object.keys(m).forEach((function(t,e){var n=m[t];s.push({id:t,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[t]=e})),v.forEach((function(t){var e=t.source,n=t.target,r=g[e],i=g[n];void 0!==r&&void 0!==i&&p.push({source:r,target:i,count:t.count})})),{nodes:s,links:p});var s,p,g,m,v;e=iO(t.nodes).force("x",aO(h).strength(.1)).force("y",sO(d).strength(.1)).force("collide",TN((function(t){return t.r})).iterations(4)).force("charge",oO().strength(i)).force("links",MN(t.nodes.length?t.links:[]).distance(o).strength(a)),f=e.nodes(),_()}()}function _(){return p={none:{x:0,y:0}},f.forEach((function(t){p[t.id]={x:t.x-s[0],y:t.y-s[1]}})),p}return y.initialize=function(t){l=t,E()},y.template=function(t){return arguments.length?(g=t,E(),y):g},y.groupBy=function(t){return arguments.length?"string"==typeof t?(n=function(e){return e[t]},y):(n=t,y):n},y.enableGrouping=function(t){return arguments.length?(m=t,y):m},y.strength=function(t){return arguments.length?(v=t,y):v},y.centerX=function(t){return arguments.length?(h=t,y):h},y.centerY=function(t){return arguments.length?(d=t,y):d},y.nodes=function(t){return arguments.length?(function(t){c={},t.forEach((function(t){c[t.id]=t}))}(t||[]),l=t||[],y):l},y.links=function(t){return arguments.length?(u=t||[],E(),y):u},y.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),E(),y):r},y.nodeSize=y.forceNodeSize,y.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),E(),y):i},y.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),E(),y):o},y.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),E(),y):a},y.offset=function(t){return arguments.length?(s=t,y):s},y.getFocis=_,y}var cO={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},uO=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=wc(wc({},cO),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var n={nodes:hO(this.lastLayoutNodes),edges:dO(this.lastLayoutEdges)};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P=this;return Ic(this,(function(w){return r=wc(wc({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=i.map((function(t){var e,n;return wc(wc({},GP(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),s=o.map((function(t){return GP(t)})),this.lastLayoutNodes=a,this.lastLayoutEdges=s,this.lastAssign=t,this.lastGraph=e,l=r.alphaMin,c=r.alphaDecay,u=r.alpha,h=r.nodeStrength,d=r.edgeStrength,p=r.linkDistance,f=r.clustering,g=r.clusterFociStrength,m=r.clusterEdgeDistance,v=r.clusterEdgeStrength,y=r.clusterNodeStrength,E=r.clusterNodeSize,_=r.collideStrength,b=void 0===_?1:_,S=r.center,x=void 0===S?[0,0]:S,T=r.preventOverlap,A=r.nodeSize,R=r.nodeSpacing,M=r.onTick,C=r.forceSimulation,[2,new Promise((function(n){if(C){if(f)(o=lO()).nodes(a),o.links(s);if(C.nodes(a),s){S=MN().id((function(t){return t.id})).links(s);d&&S.strength(d),p&&S.distance(p),C.force("link",S)}T&&P.overlapProcess(C,{nodeSize:A,nodeSpacing:R,collideStrength:b}),C.alpha(u).restart();var r=hO(a),i=dO(s);t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n({nodes:r,edges:i})}else try{var o,_=oO();if(h&&_.strength(h),C=iO().nodes(a),f)(o=lO()).centerX(x[0]).centerY(x[1]).template("force").strength(g),s&&o.links(s),a&&o.nodes(a),o.forceLinkDistance(m).forceLinkStrength(v).forceCharge(y).forceNodeSize(E),C.force("group",o);if(C.force("center",function(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}(x[0],x[1])).force("charge",_).alpha(u).alphaDecay(c).alphaMin(l),T&&P.overlapProcess(C,{nodeSize:A,nodeSpacing:R,collideStrength:b}),s){var S=MN().id((function(t){return t.id})).links(s);d&&S.strength(d),p&&S.distance(p),C.force("link",S)}C.on("tick",(function(){var n=hO(a);null==M||M({nodes:n,edges:dO(s)}),t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var r=hO(a);t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n({nodes:r,edges:dO(s)})}))}catch(t){console.warn(t)}P.forceSimulation=C}))]}))}))},t.prototype.overlapProcess=function(t,e){var n,r,i=e.nodeSize,o=e.nodeSpacing,a=e.collideStrength;if(r=Ue(o)?function(){return o}:Se(o)?o:function(){return 0},i)if(Se(i))n=function(t){return i(t)+r(t)};else if(PP(i)){var s=(i[0]>i[1]?i[0]:i[1])/2;n=function(t){return s+r(t)}}else if(Ue(i)){var l=i/2;n=function(t){return l+r(t)}}else n=function(){return 10};else n=function(t){return t.size?PP(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+r(t):Me(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+r(t):t.size/2+r(t):10+r(t)};t.force("collisionForce",TN(n).strength(a))},t}(),hO=function(t){return t.map((function(t){var e=t.x,n=t.y,r=Nc(t,["x","y"]);return wc(wc({},r),{data:wc(wc({},r.data),{x:e,y:n})})}))},dO=function(t){return t.map((function(t){var e=t.source,n=t.target,r=Nc(t,["source","target"]);return wc(wc({},r),{source:e.id,target:n.id})}))},pO=function(t,e){if("next"!==t&&"prev"!==t)return e},fO=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},gO=function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return fO(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&fO(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,n=e.prev;n!==e;)t.push(JSON.stringify(n,pO)),n=null==n?void 0:n.prev;return"["+t.join(", ")+"]"},t}(),mO=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e}(gO),vO=function(){return 1},yO=function(t,e,n){for(var r,i=[],o=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;r=a.dequeue();)EO(t,e,n,r);for(;r=o.dequeue();)EO(t,e,n,r);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(EO(t,e,n,r,!0));break}}return i},EO=function(t,e,n,r,i){var o,a,s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach((function(r){var 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,bO(e,n,wc({v:a.id},a.data))})),null===(a=t.getRelatedEdges(r.v,"out"))||void 0===a||a.forEach((function(r){var i=r.data.weight,o=r.target,a=t.getNode(o);void 0===a.data.in&&(a.data.in=0),a.data.in-=i,bO(e,n,wc({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},_O=function(t,e){var n=new TP,r=0,i=0;t.getAllNodes().forEach((function(t){n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var o=n.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),a=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,wc(wc({},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)}));for(var o=[],a=i+r+3,s=0;s<a;s++)o.push(new mO);var l=r+1;return n.getAllNodes().forEach((function(t){bO(o,l,wc({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:l,graph:n}},bO=function(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)},SO=function(t,e){var n="greedy"===e?function(t,e){var n;if(t.getAllNodes().length<=1)return[];var r=_O(t,e||vO);return null===(n=yO(r.graph,r.buckets,r.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===n?void 0:n.flat()}(t,(function(t){return t.data.weight||1})):xO(t);null==n||n.forEach((function(e){var 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:wc({},n)})}))},xO=function(t){var e=[],n={},r={},i=function(o){r[o]||(r[o]=!0,n[o]=!0,t.getRelatedEdges(o,"out").forEach((function(t){n[t.target]?e.push(t):i(t.target)})),delete n[o])};return t.getAllNodes().forEach((function(t){return i(t.id)})),e},TO=function(t,e,n,r){var i;do{i=""+r+Math.random()}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},AO=function(t){var e=new TP;return t.getAllNodes().forEach((function(n){t.getChildren(n.id).length||e.addNode(wc({},n))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},RO=function(t,e){var n,r,i=Number(t.x),o=Number(t.y),a=Number(e.x)-i,s=Number(e.y)-o,l=Number(t.width)/2,c=Number(t.height)/2;return a||s?(Math.abs(s)*l>Math.abs(a)*c?(s<0&&(c=-c),n=c*a/s,r=c):(a<0&&(l=-l),n=l,r=l*s/a),{x:i+n,y:o+r}):{x:0,y:0}},MO=function(t){for(var e=[],n=PO(t)+1,r=0;r<n;r++)e.push([]);t.getAllNodes().forEach((function(t){var n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(r=0;r<n;r++)e[r]=e[r].sort((function(e,n){return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},CO=function(t,e,n,r){var i={width:0,height:0};return Ue(n)&&Ue(r)&&(i.rank=n,i.order=r),TO(t,"border",i,e)},PO=function(t){var e;return t.getAllNodes().forEach((function(t){var n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)})),e||(e=0),e},wO=function(t,e){return t.reduce((function(t,n){return e(t)>e(n)?n:t}))},NO=function(t,e,n,r,i,o){r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((function(e){return NO(t,e,n,r,i,o)})),n&&o.push(e.id))},OO=function(t,e,n,r){var i=Array.isArray(e)?e:[e],o=function(e){return r?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return i.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);NO(t,e,"post"===n,s,o,a)})),a},IO="edge-label",DO=function(t,e,n){var r=e.source,i=t.getNode(r).data.rank,o=e.target,a=t.getNode(o).data.rank,s=e.data.labelRank;if(a!==i+1){var l,c,u;for(t.removeEdge(e.id),u=0,++i;i<a;++u,++i)e.data.points=[],l=TO(t,"edge",c={originalEdge:e,width:0,height:0,rank:i},"_d"),i===s&&(c.width=e.data.width,c.height=e.data.height,c.dummy=IO,c.labelpos=e.data.labelpos),t.addEdge({id:"e"+Math.random(),source:r,target:l,data:{weight:e.data.weight}}),0===u&&n.push(l),r=l;t.addEdge({id:"e"+Math.random(),source:r,target:o,data:{weight:e.data.weight}})}},BO=function(t){var e={},n=function(r){var i,o,a=t.getNode(r);return a?e[r]?a.data.rank:(e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===o||e<o)&&(o=e)})),o||(o=0),a.data.rank=o,o):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return n(t.id)}))},kO=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},LO=function(t,e){var n=function(r){e.getRelatedEdges(r,"both").forEach((function(i){var o=i.source,a=r===o?i.target:o;t.hasNode(a)||kO(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((function(t){return n(t.id)})),t.getAllNodes().length},FO=function(t,e){var n=function(r){var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach((function(i){var o=i.source,a=r===o?i.target:o;t.hasNode(a)||void 0===e.getNode(a).data.layer&&kO(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((function(t){return n(t.id)})),t.getAllNodes().length},UO=function(t,e){return wO(e.getAllEdges(),(function(n){return t.hasNode(n.source)!==t.hasNode(n.target)?kO(e,n):1/0}))},GO=function(t,e,n){t.getAllNodes().forEach((function(t){var r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},VO=function(t){var e=function(t){var e=new TP;return t.getAllNodes().forEach((function(t){e.addNode(wc({},t))})),t.getAllEdges().forEach((function(t){var n=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));n?e.updateEdgeData(null==n?void 0:n.id,wc(wc({},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);BO(e);var n,r,i=function(t){var e,n,r=new TP({tree:[]}),i=t.getAllNodes()[0],o=t.getAllNodes().length;for(r.addNode(i);LO(r,t)<o;)e=UO(r,t),n=r.hasNode(e.source)?kO(t,e):-kO(t,e),GO(r,t,n);return r}(e);for(jO(i),WO(i,e);n=YO(i);)r=KO(i,e,n),qO(i,e,n,r)},WO=function(t,e){var n=OO(t,t.getAllNodes(),"post",!1);(n=n.slice(0,(null==n?void 0:n.length)-1)).forEach((function(n){zO(t,e,n)}))},zO=function(t,e,n){var r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((function(t){return t.target===r||t.source===r})).data.cutvalue=HO(t,e,n)},HO=function(t,e,n){var r=t.getNode(n).data.parent,i=!0,o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),a=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n}))),a=o.data.weight,e.getRelatedEdges(n,"both").forEach((function(e){var o=e.source===n,s=o?e.target:e.source;if(s!==r){var l=o===i,c=e.data.weight;if(a+=l?c:-c,ZO(t,n,s)){var u=t.getRelatedEdges(n,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=l?-u:u}}})),a},jO=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),XO(t,{},1,e)},XO=function(t,e,n,r,i){var o,a=n,s=n,l=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((function(n){e[n.id]||(s=XO(t,e,s,n.id,r))})),l.data.low=a,l.data.lim=s++,i?l.data.parent=i:delete l.data.parent,s},YO=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},KO=function(t,e,n){var r=n.source,i=n.target;e.getRelatedEdges(r,"out").find((function(t){return t.target===i}))||(r=n.target,i=n.source);var o=t.getNode(r),a=t.getNode(i),s=o,l=!1;o.data.lim>a.data.lim&&(s=a,l=!0);var c=e.getAllEdges().filter((function(e){return l===QO(t.getNode(e.source),s)&&l!==QO(t.getNode(e.target),s)}));return wO(c,(function(t){return kO(e,t)}))},qO=function(t,e,n,r){var i=t.getRelatedEdges(n.source,"both").find((function(t){return 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:{}}),jO(t),WO(t,e),$O(t,e)},$O=function(t,e){var n=t.getAllNodes().find((function(t){return!t.data.parent})),r=OO(t,n,"pre",!1);(r=r.slice(1)).forEach((function(n){var r=t.getNode(n).data.parent,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find((function(t){return 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))}))},ZO=function(t,e,n){return t.getRelatedEdges(e,"both").find((function(t){return t.source===n||t.target===n}))},QO=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},JO=BO,tI=function(t){!function(t){var e,n={},r=function(i){var o,a,s=t.getNode(i);return s?n[i]?s.data.rank:(n[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&r(t.id)})),void 0===e&&(e=0);var i={},o=function(e,n){var r,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((function(t){o(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var n=t.data;n&&(isNaN(n.layer)?n.rank-=e:o(t.id,n.layer))}))}(t),function(t){var e,n,r=new TP({tree:[]}),i=t.getAllNodes()[0],o=t.getAllNodes().length;for(r.addNode(i);FO(r,t)<o;)e=UO(r,t),n=r.hasNode(e.source)?kO(t,e):-kO(t,e),GO(r,t,n)}(t)},eI=function(t){VO(t)},nI=function(t,e){var n=function(t){var e={},n=0,r=function(i){var o=n;t.getChildren(i).forEach((function(t){return r(t.id)})),e[i]={low:o,lim:n++}};return t.getRoots().forEach((function(t){return r(t.id)})),e}(t);e.forEach((function(e){var r,i,o=e,a=t.getNode(o),s=a.data.originalEdge;if(s)for(var l=function(t,e,n,r){var i,o,a,s,l=[],c=[],u=Math.min(e[n].low,e[r].low),h=Math.max(e[n].lim,e[r].lim);a=n;do{a=null===(i=t.getParent(a))||void 0===i?void 0:i.id,l.push(a)}while(a&&(e[a].low>u||h>e[a].lim));for(s=a,a=r;a&&a!==s;)c.push(a),a=null===(o=t.getParent(a))||void 0===o?void 0:o.id;return{lca:s,path:l.concat(c.reverse())}}(t,n,s.source,s.target),c=l.path,u=l.lca,h=0,d=c[h],p=!0;o!==s.target;){if(a=t.getNode(o),p){for(;d!==u&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)d=c[++h];d===u&&(p=!1)}if(!p){for(;h<c.length-1&&(null===(i=t.getNode(c[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=c[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},rI=function(t,e,n,r,i,o,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var l=CO(t,"_bt"),c=CO(t,"_bb"),u=t.getNode(a);t.setParent(l,a),u.data.borderTop=l,t.setParent(c,a),u.data.borderBottom=c,null==s||s.forEach((function(s){rI(t,e,n,r,i,o,s.id);var u=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,p=u!==h?1:i-o[a]+1;t.addEdge({id:"e"+Math.random(),source:l,target:u,data:{minlen:p,weight:d,nestingEdge:!0}}),t.addEdge({id:"e"+Math.random(),source:h,target:c,data:{minlen:p,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e"+Math.random(),source:e,target:l,data:{weight:0,minlen:i+o[a]}})}else a!==e&&t.addEdge({id:"e"+Math.random(),source:e,target:a,data:{weight:0,minlen:n}})},iI=function(t){var e={},n=function(r,i){var o=t.getChildren(r);null==o||o.forEach((function(t){return n(t.id,i+1)})),e[r]=i};return t.getRoots().forEach((function(t){return n(t.id,1)})),e},oI=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e},aI=function(t,e,n,r,i,o){var a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],l=TO(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}})},sI=function(t){t.getAllNodes().forEach((function(t){lI(t)})),t.getAllEdges().forEach((function(t){lI(t)}))},lI=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},cI=function(t){t.getAllNodes().forEach((function(t){uI(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return uI(t)})),t.data.hasOwnProperty("y")&&uI(t.data)}))},uI=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},hI=function(t){t.getAllNodes().forEach((function(t){dI(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return dI(t)})),t.data.hasOwnProperty("x")&&dI(t.data)}))},dI=function(t){var e=t.x;t.x=t.y,t.y=e},pI=function(t){for(var e={},n=t.getAllNodes(),r=n.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),i=Math.max.apply(Math,kc([],Bc(r))),o=[],a=0;a<i+1;a++)o.push([]);var s=n.sort((function(e,n){return t.getNode(e.id).data.rank-t.getNode(n.id).data.rank})),l=s.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,n){return t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder}));return null==l||l.forEach((function(n){isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0})),null==s||s.forEach((function(n){return t.dfsTree(n.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)}))})),o},fI=function(t,e,n){for(var r=function(t,e){return null==t?void 0:t.reduce((function(t,n,r){return t[n]=e[r],t}),{})}(n,n.map((function(t,e){return e}))),i=e.map((function(e){var n=t.getRelatedEdges(e,"out").map((function(t){return{pos:r[t.target]||0,weight:t.data.weight}}));return null==n?void 0:n.sort((function(t,e){return t.pos-e.pos}))})),o=i.flat().filter((function(t){return void 0!==t})),a=1;a<n.length;)a<<=1;var s=2*a-1;a-=1;var l=Array(s).fill(0,0,s),c=0;return null==o||o.forEach((function(t){if(t){var e=t.pos+a;l[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=l[e+1]),l[e=e-1>>1]+=t.weight;c+=t.weight*n}})),c},gI=function(t,e){for(var n=0,r=1;r<(null==e?void 0:e.length);r+=1)n+=fI(t,e[r-1],e[r]);return n},mI=function(t){for(var e;t.hasNode(e="_root"+Math.random()););return e},vI=function(t){for(var e,n,r=[],i=function(){var i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach((function(t){return(e=i,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&yI(e,t)})(t);var e})),null===(n=i.out)||void 0===n||n.forEach((function(e){return(n=i,function(e){e.in.push(n),0==--e.indegree&&t.push(e)})(e);var n}))};null==t?void 0:t.length;)i();var o=r.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return o.map((function(t){var e={};return null==a||a.forEach((function(n){void 0!==t[n]&&(e[n]=t[n])})),e}))},yI=function(t,e){var n,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},EI=function(t,e){var n,r,i,o={};null==t||t.forEach((function(t,e){o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var 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((function(t){var e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))}));var a=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,(function(t){return!t.indegree}));return vI(a)},_I=function(t,e,n){for(var r,i=n;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},bI=function(t,e){return function(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}},SI=function(t,e,n,r,i,o){var a,s,l,c,u=t.getChildren(e).map((function(t){return t.id})),h=t.getNode(e),d=h?h.data.borderLeft:void 0,p=h?h.data.borderRight:void 0,f={};d&&(u=null==u?void 0:u.filter((function(t){return t!==d&&t!==p})));var g=function(t,e){return e.map((function(e){var n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};var r={sum:0,weight:0};return null==n||n.forEach((function(e){var 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,u||[]);null==g||g.forEach((function(e){var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){var a=SI(t,e.v,n,r,o);f[e.v]=a,a.hasOwnProperty("barycenter")&&TI(e,a)}}));var m=EI(g,n);xI(m,f),null===(a=m.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)}));var v=function(t,e,n,r){var i=function(t,e){var n={lhs:[],rhs:[]};return null==t||t.forEach((function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n}(t,(function(t){var e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),o=i.lhs,a=i.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],l=0,c=0,u=0;null==o||o.sort(bI(!!e,!!n)),u=_I(s,a,u),null==o||o.forEach((function(t){var e;u+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),l+=t.barycenter*t.weight,c+=t.weight,u=_I(s,a,u)}));var h={vs:s.flat()};return c&&(h.barycenter=l/c,h.weight=c),h}(m,r,i,o);if(d&&(v.vs=[d,v.vs,p].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){var y=t.getNode((null===(l=t.getPredecessors(d))||void 0===l?void 0:l[0].id)||""),E=t.getNode((null===(c=t.getPredecessors(p))||void 0===c?void 0:c[0].id)||"");v.hasOwnProperty("barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+y.data.order+E.data.order)/(v.weight+2),v.weight+=2}return v},xI=function(t,e){null==t||t.forEach((function(t){var n,r=null===(n=t.vs)||void 0===n?void 0:n.map((function(t){return e[t]?e[t].vs:t}));t.vs=r.flat()}))},TI=function(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)},AI=function(t,e,n){return e.map((function(e){return function(t,e,n){var r=mI(t),i=new TP({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((function(o){var a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(wc({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(wc({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach((function(e){var n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(wc({},t.getNode(n)));var r=i.getRelatedEdges(n,"out").find((function(t){return t.target===o.id})),a=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,wc(wc({},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,wc(wc({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i}(t,e,n)}))},RI=function(t,e,n,r){var i=new TP;null==t||t.forEach((function(t){for(var o,a=t.getRoots()[0].id,s=SI(t,a,i,e,n,r),l=0;l<(null===(o=s.vs)||void 0===o?void 0:o.length);l++){var c=t.getNode(s.vs[l]);c&&(c.data.order=l)}!function(t,e,n){var r,i={};null==n||n.forEach((function(n){for(var o,a,s=t.getParent(n);s;){if((o=t.getParent(s.id))?(a=i[o.id],i[o.id]=s.id):(a=r,r=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)}))},MI=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,n){t.getNode(e).data.order=n}))}))},CI=function(t,e){var n={};function r(e,r,i,o,a){for(var s,l,c,u=r;u<i;u++)c=e[u],(null===(s=t.getNode(c))||void 0===s?void 0:s.data.dummy)&&(null===(l=t.getPredecessors(c))||void 0===l||l.forEach((function(e){var r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&wI(n,e.id,c)})))}function i(t,e){var n=function(t){return JSON.stringify(t.slice(1))}(t);e.get(n)||(r.apply(void 0,kc([],Bc(t))),e.set(n,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,n){var r,o=-1,a=0,s=new Map;return null==n||n.forEach((function(l,c){var u;if("border"===(null===(u=t.getNode(l))||void 0===u?void 0:u.data.dummy)){var h=t.getPredecessors(l)||[];h.length&&(r=t.getNode(h[0].id).data.order,i([n,a,c,o,r],s),a=c,o=r)}i([n,a,n.length,r,e.length],s)})),n})),n},PI=function(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((function(e){return t.getNode(e.id).data.dummy}))},wI=function(t,e,n){var r=e,i=n;if(r>i){var o=r;r=i,i=o}var a=t[r];a||(t[r]=a={}),a[i]=!0},NI=function(t,e,n){var r=e;r>n&&(r=n);return!!t[r]},OI=function(t,e,n,r,i,o){var a=new TP,s=II(r,i,o);return null==e||e.forEach((function(e){var r;null==e||e.forEach((function(e){var i=n[e];if(a.hasNode(i)||a.addNode({id:i,data:{}}),r){var o=n[r],l=a.getRelatedEdges(o,"out").find((function(t){return t.target===i}));l?a.updateEdgeData(l.id,wc(wc({},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};var II=function(t,e,n){return function(r,i,o){var a=r.getNode(i),s=r.getNode(o),l=0,c=0;if(l+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":c=-a.data.width/2;break;case"r":c=a.data.width/2}if(c&&(l+=n?c:-c),c=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":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(l+=n?c:-c),c=0,l}},DI=function(t,e){return t.getNode(e).data.width||0},BI=function(t,e){var n=e||{},r=n.align,i=n.nodesep,o=void 0===i?0:i,a=n.edgesep,s=void 0===a?0:a,l=MO(t),c=Object.assign(function(t,e){var n={};return(null==e?void 0:e.length)&&e.reduce((function(e,r){var i=0,o=0,a=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach((function(e,l){var c,u=PI(t,e),h=u?t.getNode(u.id).data.order:a;(u||e===s)&&(null===(c=r.slice(o,l+1))||void 0===c||c.forEach((function(e){var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach((function(r){var o,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)||wI(n,r.id,e)}))})),o=l+1,i=h)})),r})),n}(t,l),CI(t,l)),u={},h=[];["u","d"].forEach((function(e){h="u"===e?l:Object.values(l).reverse(),["l","r"].forEach((function(n){"r"===n&&(h=h.map((function(t){return Object.values(t).reverse()})));var r=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),i=function(t,e,n,r){var i={},o={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=r(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var l=(s.length-1)/2,c=Math.floor(l),u=Math.ceil(l);c<=u;++c){var h=s[c];o[t]===t&&e<a[h]&&!NI(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}(0,h,c,r),a=function(t,e,n,r,i,o,a){var s,l={},c=OI(t,e,n,i,o,a),u=a?"borderLeft":"borderRight",h=function(t,e){for(var n=c.getAllNodes(),r=n.pop(),i={};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((function(t){l[t]=(c.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(l[e.source]||0)+e.data.weight)}),0)}),c.getPredecessors.bind(c)),h((function(e){var n=(c.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(l[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==u&&(l[e]=Math.max(l[e],n))}),c.getSuccessors.bind(c)),null===(s=Object.values(r))||void 0===s||s.forEach((function(t){l[t]=l[n[t]]})),l}(t,h,i.root,i.align,o,s,"r"===n);"r"===n&&Object.keys(a).forEach((function(t){return a[t]=-a[t]})),u[e+n]=a}))}));var d=function(t,e){return wO(Object.values(e),(function(e){var n,r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach((function(n){var o=e[n],a=DI(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i}))}(t,u);return d&&function(t,e){var n=Object.values(e),r=Math.min.apply(Math,kc([],Bc(n))),i=Math.max.apply(Math,kc([],Bc(n)));["u","d"].forEach((function(n){["l","r"].forEach((function(o){var a,s=n+o,l=t[s];if(l!==e){var c=Object.values(l);(a="l"===o?r-Math.min.apply(Math,kc([],Bc(c))):i-Math.max.apply(Math,kc([],Bc(c))))&&(t[s]={},Object.keys(l).forEach((function(e){t[s][e]=l[e]+a})))}}))}))}(u,d),function(t,e){var n={};return Object.keys(t.ul).forEach((function(r){if(e)n[r]=t[e.toLowerCase()][r];else{var i=Object.values(t).map((function(t){return t[r]}));n[r]=(i[0]+i[1])/2}})),n}(u,r)},kI=function(t,e){var n,r=AO(t);!function(t,e){var n=(e||{}).ranksep,r=void 0===n?0:n,i=MO(t),o=0;null==i||i.forEach((function(e){var n=e.map((function(e){return t.getNode(e).data.height})),i=Math.max.apply(Math,kc(kc([],Bc(n)),[0]));null==e||e.forEach((function(e){t.getNode(e).data.y=o+i/2})),o+=i+r}))}(r,e);var i=BI(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((function(t){r.getNode(t).data.x=i[t]}))},LI=function(t,e){var n=e.acyclicer,r=e.ranker,i=e.rankdir,o=void 0===i?"tb":i,a=e.nodeOrder,s=e.keepNodeOrder,l=e.align,c=e.nodesep,u=void 0===c?50:c,h=e.edgesep,d=void 0===h?20:h,p=e.ranksep,f=void 0===p?50:p;eD(t),SO(t,n);var g=function(t){var e=TO(t,"root",{},"_root"),n=iI(t),r=Math.max.apply(Math,kc([],Bc(Object.values(n))));Math.abs(r)===1/0&&(r=1);var i=r-1,o=2*i+1;t.getAllEdges().forEach((function(t){t.data.minlen*=o}));var a=oI(t)+1;return t.getRoots().forEach((function(r){rI(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}}(t),m=g.nestingRoot,v=g.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":eI(t);break;case"tight-tree":default:tI(t);break;case"longest-path":JO(t)}}(AO(t),r),YI(t),function(t,e){void 0===e&&(e=0);var n=t.getAllNodes(),r=n.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),i=Math.min.apply(Math,kc([],Bc(r))),o=[];n.forEach((function(t){var e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)}));for(var a=0,s=0;s<o.length;s++){var l=o[s];void 0===l?s%e!=0&&(a-=1):a&&(null==l||l.forEach((function(e){var n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}}(t,v),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,m),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),n=Math.min.apply(Math,kc([],Bc(e)));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)}))}(t),KI(t),qI(t);var y=[];!function(t,e){t.getAllEdges().forEach((function(n){return DO(t,n,e)}))}(t,y),nI(t,y),function(t){var e=function(n){var r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach((function(t){return e(t.id)})),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(var o=i.data.minRank,a=i.data.maxRank+1;o<a;o+=1)aI(t,"borderLeft","_bl",n,i,o),aI(t,"borderRight","_br",n,i,o)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),s&&function(t,e){for(var n=t.getAllNodes().filter((function(e){var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)})),r=n.map((function(t){return t.data.rank})),i=Math.max.apply(Math,kc([],Bc(r))),o=[],a=0;a<i+1;a++)o[a]=[];null==e||e.forEach((function(e){var n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))}))}(t,a),function(t,e){for(var n=PO(t),r=[],i=[],o=1;o<n+1;o++)r.push(o);for(o=n-1;o>-1;o--)i.push(o);var a=AI(t,r,"in"),s=AI(t,i,"out"),l=pI(t);MI(t,l);for(var c,u=Number.POSITIVE_INFINITY,h=(o=0,0);h<4;++o,++h)RI(o%2?a:s,o%4>=2,!1,e),l=MO(t),(d=gI(t,l))<u&&(h=0,c=tn(l),u=d);for(l=pI(t),MI(t,l),o=0,h=0;h<4;++o,++h){var d;RI(o%2?a:s,o%4>=2,!0,e),l=MO(t),(d=gI(t,l))<u&&(h=0,c=tn(l),u=d)}MI(t,c)}(t,s),nD(t),function(t,e){var n=e.toLowerCase();"lr"!==n&&"rl"!==n||sI(t)}(t,o),kI(t,{align:l,nodesep:u,edgesep:d,ranksep:f}),rD(t),tD(t),function(t,e){e.forEach((function(e){var n,r=t.getNode(e),i=r.data.originalEdge;i&&t.addEdge(i);for(var o=e;r.data.dummy;)n=t.getSuccessors(o)[0],t.removeNode(o),i.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===IO&&(i.data.x=r.data.x,i.data.y=r.data.y,i.data.width=r.data.width,i.data.height=r.data.height),o=n.id,r=t.getNode(o)}))}(t,y),QI(t),function(t,e){var n=e.toLowerCase();"bt"!==n&&"rl"!==n||cI(t),"lr"!==n&&"rl"!==n||(hI(t),sI(t))}(t,o);var E=$I(t),_=E.width,b=E.height;return ZI(t),JI(t),function(t){t.getAllEdges().forEach((function(e){var n=e.data;if(n.reversed){t.removeEdge(e.id);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:wc(wc({},n),{forwardName:r})})}}))}(t),{width:_,height:b}},FI=function(t,e){t.getAllNodes().forEach((function(n){var r=t.getNode(n.id),i=e.getNode(n.id);void 0!==i?(r.data.fixorder=i.data._order,delete i.data._order):delete r.data.fixorder}))},UI=function(t,e){t.getAllNodes().forEach((function(n){var r,i=t.getNode(n.id);if(i){var o=e.getNode(n.id);i.data.x=o.data.x,i.data.y=o.data.y,i.data._order=o.data.order,i.data._rank=o.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=o.data.width,i.data.height=o.data.height)}})),t.getAllEdges().forEach((function(n){var 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)}))},GI=["width","height","layer","fixorder"],VI={width:0,height:0},WI=["minlen","weight","width","height","labeloffset"],zI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},HI=["labelpos"],jI=function(t){var e=new TP({tree:[]});return t.getAllNodes().forEach((function(n){var r=oD(t.getNode(n.id).data),i=wc(wc({},VI),r),o=iD(i,GI);e.hasNode(n.id)||e.addNode({id:n.id,data:wc({},o)});var a=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);xe(a)||(e.hasNode(a.id)||e.addNode(wc({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((function(n){var r=oD(t.getEdge(n.id).data),i={};null==HI||HI.forEach((function(t){void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},zI,iD(r,WI),i)})})),e},XI=function(t,e){var n=e.ranksep,r=void 0===n?0:n,i=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===i||"BT"===i?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),r/2},YI=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};TO(t,"edge-proxy",r,"_ep")}}))},KI=function(t){var e=0;return t.getAllNodes().forEach((function(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},qI=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},$I=function(t,e){var n,r,i=0,o=0,a=e||{},s=a.marginx,l=void 0===s?0:s,c=a.marginy,u=void 0===c?0:c,h=function(t){if(t.data){var 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((function(t){h(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&h(t)})),n-=l,r-=u,t.getAllNodes().forEach((function(t){t.data.x-=n,t.data.y-=r})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(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+l,height:o-r+u}},ZI=function(t){t.getAllEdges().forEach((function(e){var n,r,i=t.getNode(e.source),o=t.getNode(e.target);e.data.points?(n=e.data.points[0],r=e.data.points[e.data.points.length-1]):(e.data.points=[],n={x:o.data.x,y:o.data.y},r={x:i.data.x,y:i.data.y}),e.data.points.unshift(RO(i.data,n)),e.data.points.push(RO(o.data,r))}))},QI=function(t){t.getAllEdges().forEach((function(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}}))},JI=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},tD=function(t){t.getAllNodes().forEach((function(e){var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){var o=t.getNode(e.id),a=t.getNode(o.data.borderTop),s=t.getNode(o.data.borderBottom),l=t.getNode(o.data.borderLeft[(null===(r=o.data.borderLeft)||void 0===r?void 0:r.length)-1]),c=t.getNode(o.data.borderRight[(null===(i=o.data.borderRight)||void 0===i?void 0:i.length)-1]);o.data.width=Math.abs((null==c?void 0:c.data.x)-(null==l?void 0:l.data.x))||10,o.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,o.data.x=((null==l?void 0:l.data.x)||0)+o.data.width/2,o.data.y=((null==a?void 0:a.data.y)||0)+o.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},eD=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}}))},nD=function(t){var e=MO(t);null==e||e.forEach((function(e){var n=0;null==e||e.forEach((function(e,r){var i,o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach((function(e){TO(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},rD=function(t){t.getAllNodes().forEach((function(e){var n=t.getNode(e.id);if("selfedge"===n.data.dummy){var 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}}))},iD=function(t,e){var n={};return null==e||e.forEach((function(e){void 0!==t[e]&&(n[e]=+t[e])})),n},oD=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(n){e[n.toLowerCase()]=t[n]})),e},aD={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,controlPoints:!1,radial:!1,focusNode:null},sD=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.options=wc(wc({},aD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){switch(n.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P,w,N,O,I,D,B,k;return Ic(this,(function(L){return r=wc(wc({},this.options),n),i=r.nodeSize,o=r.align,a=r.rankdir,s=void 0===a?"TB":a,l=r.ranksep,c=r.nodesep,u=r.ranksepFunc,h=r.nodesepFunc,d=r.edgeLabelSpace,p=r.nodeOrder,f=r.begin,g=r.controlPoints,m=r.radial,v=r.sortByCombo,y=new TP({tree:[]}),E=VP(l||50,u),_=VP(c||50,h),b=_,S=E,"LR"!==s&&"RL"!==s||(b=E,S=_),x=zP(i,void 0),T=e.getAllNodes(),A=e.getAllEdges(),T.forEach((function(t){var e=x(t),n=S(t),r=e+2*b(t),i=e+2*n,o=t.data.layer;Ue(o)?y.addNode({id:t.id,data:{width:r,height:i,layer:o}}):y.addNode({id:t.id,data:{width:r,height:i}})})),v&&(y.attachTreeStructure("combo"),T.forEach((function(t){var e=t.data.parentId;void 0!==e&&y.hasNode(e)&&y.setParent(t.id,e,"combo")}))),A.forEach((function(t){y.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),function(t,e){var n=e.edgeLabelSpace,r=e.keepNodeOrder,i=e.prevGraph,o=e.rankdir,a=e.ranksep;!r&&i&&FI(t,i);var s,l=jI(t);n&&(e.ranksep=XI(l,{rankdir:o,ranksep:a}));try{s=LI(l,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}UI(t,l)}(y,{prevGraph:null,edgeLabelSpace:d,keepNodeOrder:!!p,nodeOrder:p||[],acyclicer:"greedy",ranker:"network-simplex",rankdir:s,nodesep:c,align:o}),R=[0,0],f&&(M=1/0,C=1/0,y.getAllNodes().forEach((function(t){M>t.data.x&&(M=t.data.x),C>t.data.y&&(C=t.data.y)})),y.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){M>t.x&&(M=t.x),C>t.y&&(C=t.y)}))})),R[0]=f[0]-M,R[1]=f[1]-C),P="LR"===s||"RL"===s,m||(w=new Set,N="BT"===s||"RL"===s?function(t,e){return e-t}:function(t,e){return t-e},y.getAllNodes().forEach((function(t){t.data.x=t.data.x+R[0],t.data.y=t.data.y+R[1],w.add(P?t.data.x:t.data.y)})),O=Array.from(w).sort(N),I=P?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},D=P?function(t,e,n){var r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter((function(t){return t.y<=r&&t.y>=i}))}:function(t,e,n){var r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter((function(t){return t.x<=r&&t.x>=i}))},y.getAllEdges().forEach((function(t,e){var n;d&&g&&"loop"!==t.data.type&&(t.data.controlPoints=lD(null===(n=t.data.points)||void 0===n?void 0:n.map((function(t){var e=t.x,n=t.y;return{x:e+R[0],y:n+R[1]}})),y.getNode(t.source),y.getNode(t.target),O,P,I,D))}))),B=[],B=y.getAllNodes().map((function(t){return GP(t)})),k=y.getAllEdges(),t&&(B.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),k.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:B,edges:k}]}))}))},t}(),lD=function(t,e,n,r,i,o,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){var l=e.data,c=l.x,u=l.y,h=n.data,d=h.x,p=h.y;if(i&&(c=e.data.y,u=e.data.x,d=n.data.y,p=n.data.x),p!==u&&c!==d){var f=r.indexOf(u),g=r[f+1];if(g){var m=s[0],v=i?{x:(u+g)/2,y:(null==m?void 0:m.y)||d}:{x:(null==m?void 0:m.x)||d,y:(u+g)/2};m&&!o(m,v)||s.unshift(v)}var y=r.indexOf(p),E=Math.abs(y-f);if(1===E)(s=a(s,e.data,n.data)).length||s.push(i?{x:(u+p)/2,y:c}:{x:c,y:(u+p)/2});else if(E>1){var _=r[y-1];if(_){var b=s[s.length-1],S=i?{x:(p+_)/2,y:(null==b?void 0:b.y)||d}:{x:(null==b?void 0:b.x)||c,y:(p+_)/2};b&&!o(b,S)||s.push(S)}}}}return s},cD=function(){function t(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}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,n=t.ry-this.ry,r=Math.hypot(e,n);r=r<1e-4?1e-4:r;var i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var n=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/n,ry:(this.ry*this.mass+e.ry*e.mass)/n,mass:n,degree:this.degree+e.degree})},t}(),uD=cD,hD=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),dD=hD,pD=function(){function t(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)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(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))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(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)))},t}(),fD=pD,gD={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},mD=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=wc(wc({},gD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T;return Ic(this,(function(A){if(r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),a=o.width,s=o.height,l=o.prune,c=o.maxIteration,u=o.nodeSize,h=o.center,!(null==i?void 0:i.length)||1===i.length)return[2,HP(e,t,h)];if(d=i.map((function(t){return GP(t,[a,s])})),p=r.filter((function(t){return t.source!==t.target})),f=new TP({nodes:d,edges:p}),g=this.getSizes(f,e,u),this.run(f,e,c,g,t,o),l){for(m=0;m<p.length;m+=1)v=p[m],y=v.source,E=v.target,_=f.getDegree(y),b=f.getDegree(y),_<=1?(S=f.getNode(E),f.mergeNodeData(y,{x:S.data.x,y:S.data.y})):b<=1&&(x=f.getNode(y),f.mergeNodeData(E,{x:x.data.x,y:x.data.y}));T=wc(wc({},o),{prune:!1,barnesHut:!1}),this.run(f,e,100,g,t,T)}return[2,{nodes:d,edges:r}]}))}))},t.prototype.getSizes=function(t,e,n){for(var r=t.getAllNodes(),i={},o=0;o<r.length;o+=1){var a=r[o],s=a.id,l=a.data;if(i[s]=10,Ue(l.size))i[s]=l.size;else if(PP(l.size))isNaN(l.size[0])||(i[s]=Math.max(l.size[0])),isNaN(l.size[1])||(i[s]=Math.max(l.size[1]));else if(Me(l.size))i[s]=Math.max(l.size.width,l.size.height);else if(Se(n)){var c=n(e.getNode(s));PP(c)?i[s]=Math.max.apply(Math,kc([],Bc(c))):i[s]=c}else PP(n)?i[s]=Math.max.apply(Math,kc([],Bc(n))):Ue(n)&&(i[s]=n)}return i},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var n=wc(wc({},this.options),t),r=n.center,i=n.width,o=n.height,a=n.barnesHut,s=n.prune,l=n.maxIteration,c=n.kr,u=n.kg;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)),c||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),u||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n},t.prototype.run=function(t,e,n,r,i,o){for(var a=o.kr,s=o.barnesHut,l=o.onTick,c=t.getAllNodes(),u=0,h=n,d={},p={},f={},g=0;g<c.length;g+=1){var m=c[g],v=m.data,y=m.id;if(d[y]=[0,0],s){var E={id:g,rx:v.x,ry:v.y,mass:1,g:a,degree:t.getDegree(y)};f[y]=new uD(E)}}for(;h>0;)u=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:u,forces:d,preForces:p,bodies:f,sizes:r},o),h--,null==l||l({nodes:c,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,n){for(var r=e.iter,i=e.preventOverlapIters,o=e.krPrime,a=e.sg,s=e.preForces,l=e.bodies,c=e.sizes,u=e.forces,h=n.preventOverlap,d=n.barnesHut,p=t.getAllNodes(),f=0;f<p.length;f+=1){var g=p[f].id;s[g]=kc([],Bc(u[g])),u[g]=[0,0]}return u=this.getAttrForces(t,r,i,c,u,n),u=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,u,l,n):this.getRepGraForces(t,r,i,u,o,c,n),this.updatePos(t,u,s,a,n)},t.prototype.getAttrForces=function(t,e,n,r,i,o){for(var a=o.preventOverlap,s=o.dissuadeHubs,l=o.mode,c=o.prune,u=t.getAllEdges(),h=0;h<u.length;h+=1){var d=u[h],p=d.source,f=d.target,g=t.getNode(p),m=t.getNode(f),v=t.getDegree(p),y=t.getDegree(f);if(!c||!(v<=1||y<=1)){var E=[m.data.x-g.data.x,m.data.y-g.data.y],_=Math.hypot(E[0],E[1]);_=_<1e-4?1e-4:_,E[0]=E[0]/_,E[1]=E[1]/_,a&&e<n&&(_=_-r[p]-r[f]);var b=_,S=b;"linlog"===l&&(S=b=Math.log(1+_)),s&&(b=_/v,S=_/y),a&&e<n&&_<=0?(b=0,S=0):a&&e<n&&_>0&&(b=_,S=_),i[p][0]+=b*E[0],i[f][0]-=S*E[0],i[p][1]+=b*E[1],i[f][1]-=S*E[1]}}return i},t.prototype.getOptRepGraForces=function(t,e,n,r){for(var i=r.kg,o=r.center,a=r.prune,s=t.getAllNodes(),l=s.length,c=9e10,u=-9e10,h=9e10,d=-9e10,p=0;p<l;p+=1){var f=s[p],g=f.id,m=f.data;a&&t.getDegree(g)<=1||(n[g].setPos(m.x,m.y),m.x>=u&&(u=m.x),m.x<=c&&(c=m.x),m.y>=d&&(d=m.y),m.y<=h&&(h=m.y))}var v=Math.max(u-c,d-h),y=new dD({xmid:(u+c)/2,ymid:(d+h)/2,length:v,massCenter:o,mass:l}),E=new fD(y);for(p=0;p<l;p+=1){g=s[p].id;a&&t.getDegree(g)<=1||n[g].in(y)&&E.insert(n[g])}for(p=0;p<l;p+=1){var _=s[p],b=(g=_.id,m=_.data,t.getDegree(g));if(!(a&&b<=1)){n[g].resetForce(),E.updateForce(n[g]),e[g][0]-=n[g].fx,e[g][1]-=n[g].fy;var S=[m.x-o[0],m.y-o[1]],x=Math.hypot(S[0],S[1]);x=x<1e-4?1e-4:x,S[0]=S[0]/x,S[1]=S[1]/x;var T=i*(b+1);e[g][0]-=T*S[0],e[g][1]-=T*S[1]}}return e},t.prototype.getRepGraForces=function(t,e,n,r,i,o,a){for(var s=a.preventOverlap,l=a.kr,c=a.kg,u=a.center,h=a.prune,d=t.getAllNodes(),p=d.length,f=0;f<p;f+=1){for(var g=d[f],m=t.getDegree(g.id),v=f+1;v<p;v+=1){var y=d[v],E=t.getDegree(y.id);if(!h||!(m<=1||E<=1)){var _=[y.data.x-g.data.x,y.data.y-g.data.y],b=Math.hypot(_[0],_[1]);b=b<1e-4?1e-4:b,_[0]=_[0]/b,_[1]=_[1]/b,s&&e<n&&(b=b-o[g.id]-o[y.id]);var S=l*(m+1)*(E+1)/b;s&&e<n&&b<0?S=i*(m+1)*(E+1):s&&e<n&&0===b?S=0:s&&e<n&&b>0&&(S=l*(m+1)*(E+1)/b),r[g.id][0]-=S*_[0],r[y.id][0]+=S*_[0],r[g.id][1]-=S*_[1],r[y.id][1]+=S*_[1]}}var x=[g.data.x-u[0],g.data.y-u[1]],T=Math.hypot(x[0],x[1]);x[0]=x[0]/T,x[1]=x[1]/T;var A=c*(m+1);r[g.id][0]-=A*x[0],r[g.id][1]-=A*x[1]}return r},t.prototype.updatePos=function(t,e,n,r,i){for(var o=i.ks,a=i.tao,s=i.prune,l=i.ksmax,c=t.getAllNodes(),u=c.length,h=[],d=[],p=0,f=0,g=r,m=0;m<u;m+=1){var v=c[m].id,y=t.getDegree(v);if(!(s&&y<=1)){var E=[e[v][0]-n[v][0],e[v][1]-n[v][1]],_=Math.hypot(E[0],E[1]),b=[e[v][0]+n[v][0],e[v][1]+n[v][1]],S=Math.hypot(b[0],b[1]);h[m]=_,d[m]=S/2,p+=(y+1)*h[m],f+=(y+1)*d[m]}}var x=g;g=a*f/p,0!==x&&(g=g>1.5*x?1.5*x:g);for(m=0;m<u;m+=1){var T=c[m],A=(v=T.id,T.data);y=t.getDegree(v);if(!(s&&y<=1)&&(!Ue(A.fx)||!Ue(A.fy))){var R=o*g/(1+g*Math.sqrt(h[m])),M=Math.hypot(e[v][0],e[v][1]),C=l/(M=M<1e-4?1e-4:M),P=(R=R>C?C:R)*e[v][0],w=R*e[v][1];t.mergeNodeData(v,{x:A.x+P,y:A.y+w})}}return g},t}(),vD={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},yD=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=wc(wc({},vD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var n=0;n<t;n++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var r={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),r},t.prototype.genericFruchtermanLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E=this;return Ic(this,(function(_){return this.running?[2]:(r=this.formatOptions(n),i=r.dimensions,o=r.width,a=r.height,s=r.center,l=r.clustering,c=r.nodeClusterBy,u=r.maxIteration,h=r.onTick,d=e.getAllNodes(),p=e.getAllEdges(),(null==d?void 0:d.length)?1===d.length?(t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0}),f={nodes:[wc(wc({},d[0]),{data:wc(wc({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:p},this.lastResult=f,[2,f]):(g=d.map((function(t){return GP(t,[o,a])})),m=new TP({nodes:g,edges:p}),v={},l&&g.forEach((function(t){var e=t.data[c];v[e]||(v[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=g,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=m,this.lastOptions=r,this.lastClusterMap=v,"undefined"==typeof window?[2]:(y=0,[2,new Promise((function(n){E.timeInterval=window.setInterval((function(){E.running?(E.runOneStep(m,v,r),t&&g.forEach((function(t){var n=t.id,r=t.data;return e.mergeNodeData(n,{x:r.x,y:r.y,z:3===i?r.z:void 0})})),null==h||h({nodes:g,edges:p}),++y>=u&&(window.clearInterval(E.timeInterval),n({nodes:g,edges:p}))):n({nodes:g,edges:p})}),0),E.running=!0}))])):(f={nodes:[],edges:p},this.lastResult=f,[2,f]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=wc(wc({},this.options),t),n=e.clustering,r=e.nodeClusterBy,i=e.center,o=e.width,a=e.height;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},t.prototype.runOneStep=function(t,e,n){var r=n.dimensions,i=n.height,o=n.width,a=n.gravity,s=n.center,l=n.speed,c=n.clustering,u=n.nodeClusterBy,h=n.clusterGravity,d=i*o,p=Math.sqrt(d)/10,f=t.getAllNodes(),g=d/(f.length+1),m=Math.sqrt(g),v={};if(this.applyCalculate(t,v,m,g),c){for(var y in e)e[y].cx=0,e[y].cy=0,e[y].count=0;for(var y in f.forEach((function(t){var n=t.data,r=e[n[u]];Ue(n.x)&&(r.cx+=n.x),Ue(n.y)&&(r.cy+=n.y),r.count++})),e)e[y].cx/=e[y].count,e[y].cy/=e[y].count;var E=h||a;f.forEach((function(t,n){var r=t.id,i=t.data;if(Ue(i.x)&&Ue(i.y)){var o=e[i[u]],a=Math.sqrt((i.x-o.cx)*(i.x-o.cx)+(i.y-o.cy)*(i.y-o.cy)),s=m*E;v[r].x-=s*(i.x-o.cx)/a,v[r].y-=s*(i.y-o.cy)/a}}))}f.forEach((function(t,e){var n=t.id,i=t.data;if(Ue(i.x)&&Ue(i.y)){var o=.01*m*a;v[n].x-=o*(i.x-s[0]),v[n].y-=o*(i.y-s[1]),3===r&&(v[n].z-=o*(i.z-s[2]))}})),f.forEach((function(e,n){var i=e.id,o=e.data;if(Ue(o.fx)&&Ue(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(Ue(o.x)&&Ue(o.y)){var a=Math.sqrt(v[i].x*v[i].x+v[i].y*v[i].y+(3===r?v[i].z*v[i].z:0));if(a>0){var s=Math.min(p*(l/800),a);t.mergeNodeData(i,{x:o.x+v[i].x/a*s,y:o.y+v[i].y/a*s,z:3===r?o.z+v[i].z/a*s:void 0})}}}))},t.prototype.applyCalculate=function(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)},t.prototype.calRepulsive=function(t,e,n){var r=this,i=t.getAllNodes();i.forEach((function(t,o){var a=t.data,s=t.id;e[s]={x:0,y:0,z:0},i.forEach((function(t,i){var l=t.data,c=t.id;if(!(o<=i)&&Ue(a.x)&&Ue(l.x)&&Ue(a.y)&&Ue(l.y)){var u=a.x-l.x,h=a.y-l.y,d=3===r.options.dimensions?a.z-l.z:0,p=u*u+h*h+d*d;0===p&&(p=1,u=.01,h=.01,d=.01);var f=n/p,g=u*f,m=h*f,v=d*f;e[s].x+=g,e[s].y+=m,e[c].x-=g,e[c].y-=m,3===r.options.dimensions&&(e[s].z+=v,e[c].z-=v)}}))}))},t.prototype.calAttractive=function(t,e,n){var r=this;t.getAllEdges().forEach((function(i){var o=i.source,a=i.target;if(o&&a&&o!==a){var s=t.getNode(o).data,l=t.getNode(a).data;if(Ue(l.x)&&Ue(s.x)&&Ue(l.y)&&Ue(s.y)){var c=l.x-s.x,u=l.y-s.y,h=3===r.options.dimensions?l.z-s.z:0,d=Math.sqrt(c*c+u*u+h*h)/n,p=c*d,f=u*d,g=h*d;e[o].x+=p,e[o].y+=f,e[a].x-=p,e[a].y-=f,3===r.options.dimensions&&(e[o].z+=g,e[a].z-=g)}}}))},t}(),ED={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},_D=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=wc(wc({},ED),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P,w,N,O,I,D,B,k,L,F,U;return Ic(this,(function(G){if(r=wc(wc({},this.options),n),i=r.begin,o=void 0===i?[0,0]:i,a=r.condense,s=r.preventOverlapPadding,l=r.preventOverlap,c=r.rows,u=r.cols,h=r.nodeSpacing,d=r.nodeSize,p=r.width,f=r.height,g=r.position,m=r.sortBy,v=e.getAllNodes(),y=e.getAllEdges(),!(E=null==v?void 0:v.length)||1===E)return[2,HP(e,t,o)];if(_=v.map((function(t){return GP(t)})),"id"===m||De(m)&&void 0!==_[0].data[m]||(m="degree"),"degree"===m?_.sort((function(t,n){return e.getDegree(n.id,"both")-e.getDegree(t.id,"both")})):"id"===m?_.sort((function(t,e){return Ue(e.id)&&Ue(t.id)?e.id-t.id:(""+t.id).localeCompare(""+e.id)})):_.sort((function(t,e){return e.data[m]-t.data[m]})),b=p||"undefined"==typeof window?p:window.innerWidth,S=f||"undefined"==typeof window?f:window.innerHeight,x=E,T={rows:c,cols:u},null!=c&&null!=u?(T.rows=c,T.cols=u):null!=c&&null==u?(T.rows=c,T.cols=Math.ceil(x/T.rows)):null==c&&null!=u?(T.cols=u,T.rows=Math.ceil(x/T.cols)):(A=Math.sqrt(x*S/b),T.rows=Math.round(A),T.cols=Math.round(b/S*A)),T.rows=Math.max(T.rows,1),T.cols=Math.max(T.cols,1),T.cols*T.rows>x)R=bD(T),M=SD(T),(R-1)*M>=x?bD(T,R-1):(M-1)*R>=x&&SD(T,M-1);else for(;T.cols*T.rows<x;)R=bD(T),((M=SD(T))+1)*R>=x?SD(T,M+1):bD(T,R+1);for(C=a?0:b/T.cols,P=a?0:S/T.rows,(l||h)&&(w=VP(10,h),N=WP(30,d,!1),_.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var n,r,i=e.getNode(t.id),o=N(i)||30;PP(o)?(n=o[0],r=o[1]):(n=o,r=o);var a=void 0!==w?w(t):s,l=n+a,c=r+a;C=Math.max(C,l),P=Math.max(P,c)}))),O={},I={row:0,col:0},D={},B=0;B<_.length;B++){if(k=_[B],L=void 0,g&&(L=g(e.getNode(k.id))),L&&(void 0!==L.row||void 0!==L.col)){if(void 0===(F={row:L.row,col:L.col}).col)for(F.col=0;xD(O,F);)F.col++;else if(void 0===F.row)for(F.row=0;xD(O,F);)F.row++;D[k.id]=F,TD(O,F)}RD(k,o,C,P,D,T,I,O)}return U={nodes:_,edges:y},t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,U]}))}))},t}(),bD=function(t,e){var n,r=t.rows||5,i=t.cols||5;null==e?n=Math.min(r,i):Math.min(r,i)===t.rows?t.rows=e:t.cols=e;return n},SD=function(t,e){var n,r=t.rows||5,i=t.cols||5;null==e?n=Math.max(r,i):Math.max(r,i)===t.rows?t.rows=e:t.cols=e;return n},xD=function(t,e){return t["c-"+e.row+"-"+e.col]||!1},TD=function(t,e){return t["c-"+e.row+"-"+e.col]=!0},AD=function(t,e){var n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},RD=function(t,e,n,r,i,o,a,s){var l,c,u=i[t.id];if(u)l=u.col*n+n/2+e[0],c=u.row*r+r/2+e[1];else{for(;xD(s,a);)AD(o,a);l=a.col*n+n/2+e[0],c=a.row*r+r/2+e[1],TD(s,a),AD(o,a)}t.data.x=l,t.data.y=c},MD={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},CD=function(t,e,n,r,i,o){e.forEach((function(a,s){n[s]={x:0,y:0},e.forEach((function(e,l){if(s!==l&&i[s]===i[l]){var c=a.x-e.x,u=a.y-e.y,h=Math.sqrt(c*c+u*u);if(0===h){h=1;var d=s>l?1:-1;c=.01*d,u=.01*d}if(h<o(t[s])/2+o(t[l])/2){var p=r*r/h;n[s].x+=c/h*p,n[s].y+=u/h*p}}}))}))},PD=function(t,e,n,r,i,o,a,s){var l=o||a/10;return r&&e.forEach((function(e,n){var r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o),s=o/a,l=-r/a,c=Math.sqrt(e.x*e.x+e.y*e.y),u=Math.acos((s*e.x+l*e.y)/c);u>Math.PI/2&&(u-=Math.PI/2,s*=-1,l*=-1);var h=Math.cos(u)*c;e.x=s*h,e.y=l*h})),t.forEach((function(o,a){if(a!==i){var c=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(c>0&&a!==i){var u=Math.min(l*(n/800),c);if(o.x+=e[a].x/c*u,o.y+=e[a].y/c*u,r){var h=o.x-t[i].x,d=o.y-t[i].y,p=Math.sqrt(h*h+d*d);h=h/p*s[a],d=d/p*s[a],o.x=t[i].x+h,o.y=t[i].y+d}}}})),t},wD={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},ND=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=wc(wc({},wD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P,w,N,O,I,D,B,k,L,F,U,G,V,W,z,H,j;return Ic(this,(function(X){if(r=wc(wc({},this.options),n),i=r.width,o=r.height,a=r.center,s=r.focusNode,l=r.unitRadius,c=r.nodeSize,u=r.nodeSpacing,h=r.strictRadial,d=r.preventOverlap,p=r.maxPreventOverlapIteration,f=r.sortBy,g=r.linkDistance,m=void 0===g?50:g,v=r.sortStrength,y=void 0===v?10:v,E=r.maxIteration,_=void 0===E?1e3:E,b=e.getAllNodes(),S=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,T=o||"undefined"==typeof window?o:window.innerHeight,A=a||[x/2,T/2],!(null==b?void 0:b.length)||1===b.length)return[2,HP(e,t,A)];if(R=b[0],De(s)){for(M=0;M<b.length;M++)if(b[M].id===s){R=b[M];break}}else R=s||b[0];return C=DD(b,R.id),P=NP({nodes:b,edges:S},!1),w=wP(P),N=kD(w,C),BD(w,C,N+1),O=w[C],I=x-A[0]>A[0]?A[0]:x-A[0],D=T-A[1]>A[1]?A[1]:T-A[1],0===I&&(I=x/2),0===D&&(D=T/2),B=Math.min(I,D),k=Math.max.apply(Math,kc([],Bc(O))),L=[],F=l||B/k,O.forEach((function(t,e){L[e]=t*F})),U=OD(b,w,m,L,F,f,y),G=ID(U),V=function(t,e,n){try{var r=Dw.mul(Dw.pow(e,2),-.5),i=r.mean("row"),o=r.mean("column"),a=r.mean();r.add(a).subRowVector(i).subColumnVector(o);var s=new Lw(r),l=Dw.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return Dw.mul([e],[l]).toJSON()[0].splice(0,t)}))}catch(t){for(var c=[],u=0;u<e.length;u++){var h=Math.random()*n,d=Math.random()*n;c.push([h,d])}return c}}(m,U,m),W=V.map((function(t){var e=Bc(t,2),n=e[0],r=e[1];return{x:(isNaN(n)?Math.random()*m:n)-V[C][0],y:(isNaN(r)?Math.random()*m:r)-V[C][1]}})),this.run(_,W,G,U,L,C),d&&(z=zP(c,u),H={nodes:b,nodeSizeFunc:z,positions:W,radii:L,height:T,width:x,strictRadial:Boolean(h),focusIdx:C,iterations:p||200,k:W.length/4.5},W=function(t,e){for(var n=wc(wc({},MD),e),r=n.positions,i=n.iterations,o=n.width,a=n.k,s=n.speed,l=void 0===s?100:s,c=n.strictRadial,u=n.focusIdx,h=n.radii,d=void 0===h?[]:h,p=n.nodeSizeFunc,f=t.getAllNodes(),g=[],m=o/10,v=0;v<i;v++)r.forEach((function(t,e){g[e]={x:0,y:0}})),CD(f,r,g,a,d,p),PD(r,g,l,c,u,m,o,d);return r}(e,H)),j=[],W.forEach((function(t,e){var n=GP(b[e]);n.data.x=t.x+A[0],n.data.y=t.y+A[1],j.push(n)})),t&&j.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:j,edges:S}]}))}))},t.prototype.run=function(t,e,n,r,i,o){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,i,r,n,o)}},t.prototype.oneIteration=function(t,e,n,r,i,o){var a=1-t;e.forEach((function(s,l){var c=LP(s,{x:0,y:0}),u=0===c?0:1/c;if(l!==o){var h=0,d=0,p=0;e.forEach((function(t,e){if(l!==e){var n=LP(s,t),o=0===n?0:1/n,a=r[e][l];p+=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)}}));var f=0===n[l]?0:1/n[l];p*=a,p+=t*f*f,h*=a,h+=t*f*s.x*u,s.x=h/p,d*=a,d+=t*f*s.y*u,s.y=d/p}}))},t}(),OD=function(t,e,n,r,i,o,a){if(!t)return[];var s=[];if(e){var l={};e.forEach((function(e,c){var u=[];e.forEach((function(e,s){var h,d;if(c===s)u.push(0);else if(r[c]===r[s])if("data"===o)u.push(e*(Math.abs(c-s)*a)/(r[c]/i));else if(o){var p=void 0,f=void 0;if(l[t[c].id])p=l[t[c].id];else{var g=("id"===o?t[c].id:null===(h=t[c].data)||void 0===h?void 0:h[o])||0;p=De(g)?g.charCodeAt(0):g,l[t[c].id]=p}if(l[t[s].id])f=l[t[s].id];else{g=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=De(g)?g.charCodeAt(0):g,l[t[s].id]=f}u.push(e*(Math.abs(p-f)*a)/(r[c]/i))}else u.push(e*n/(r[c]/i));else{var m=(n+i)/2;u.push(e*m)}})),s.push(u)}))}return s},ID=function(t){for(var e=t.length,n=t[0].length,r=[],i=0;i<e;i++){for(var o=[],a=0;a<n;a++)0!==t[i][a]?o.push(1/(t[i][a]*t[i][a])):o.push(0);r.push(o)}return r},DD=function(t,e){var n=-1;return t.forEach((function(t,r){t.id===e&&(n=r)})),Math.max(n,0)},BD=function(t,e,n){for(var r=t.length,i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(var 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(i=0;i<r;i++)if(i!==e)for(o=0;o<r;o++)if(t[i][o]===1/0){var a=Math.abs(t[e][i]-t[e][o]);a=0===a?1:a,t[i][o]=a}},kD=function(t,e){for(var n=0,r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},LD={center:[0,0],width:300,height:300},FD=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=wc(wc({},LD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h;return Ic(this,(function(d){return r=wc(wc({},this.options),n),i=r.center,o=r.width,a=r.height,s=e.getAllNodes(),.9,l=o||"undefined"==typeof window?o:window.innerWidth,c=a||"undefined"==typeof window?a:window.innerHeight,u=i||[l/2,c/2],h=[],s&&s.forEach((function(t){h.push({id:t.id,data:{x:.9*(Math.random()-.5)*l+u[0],y:.9*(Math.random()-.5)*c+u[1]}})})),t&&h.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:h,edges:e.getAllEdges()}]}))}))},t}(),UD={circular:XP,concentric:mN,mds:Uw,random:FD,grid:_D,radial:ND,force:cN,d3force:uO,fruchterman:yD,forceAtlas2:mD,dagre:sD,comboCombined:EN};function GD(t){return!!t.tick&&!!t.stop}var VD=Object.freeze({__proto__:null,CircularLayout:XP,Supervisor:gw,registry:UD,GridLayout:_D,RandomLayout:FD,MDSLayout:Uw,ConcentricLayout:mN,RadialLayout:ND,FruchtermanLayout:yD,D3ForceLayout:uO,ForceLayout:cN,ForceAtlas2Layout:mD,DagreLayout:sD,ComboCombinedLayout:EN,isLayoutWithIterations:GD,camelize:CP,isArray:PP,toNumber:function(t){var e=parseFloat(t);return isNaN(e)?t:e},floydWarshall:wP,getAdjMatrix:NP,scaleMatrix:OP,traverseTreeUp:function(t,e){"function"==typeof e&&IP(t,e)},getLayoutBBox:DP,getAvgNodePosition:function(t){var e={x:0,y:0};t.forEach((function(t){e.x+=t.data.x||0,e.y+=t.data.y||0}));var n=t.length||1;return{x:e.x/n,y:e.y/n}},getCoreNodeAndRelativeLeafNodes:function(t,e,n,r,i,o){var a=i[e.id],s=a.in,l=a.out,c=e,u=[];0===s?(c=BP("source",e,n),u=kP("both",c,n).map((function(t){return o[t]}))):0===l&&(c=BP("target",e,n),u=kP("both",c,n).map((function(t){return o[t]}))),u=u.filter((function(t){return i[t.id]&&(0===i[t.id].in||0===i[t.id].out)}));var h=function(t,e,n,r,i){var o=n[e]||"",a=(null==r?void 0:r.filter((function(t){return t[e]===o})))||[];return"leaf"===t&&(a=a.filter((function(t){var e,n;return 0===(null===(e=i[t.id])||void 0===e?void 0:e.in)||0===(null===(n=i[t.id])||void 0===n?void 0:n.out)}))),a}(t,r,e,u,i);return{coreNode:c,relativeLeafNodes:u,sameTypeLeafNodes:h}},getEuclideanDistance:LP,graphTreeDfs:FP,clone:UP,cloneFormatData:GP,formatNumberFn:VP,formatSizeFn:WP,formatNodeSize:zP});class WD{constructor(t){this.updateConfig=t=>{this.options=Object.assign(this.options,t)},this.options=t}destroy(){}}class zD{constructor(t){this.options=an(this.getDefaultCfgs(),t),this.events={},this.destroyed=!1}updateCfgs(t){this.options=an(this.options,t),this.init(this.graph)}getDefaultCfgs(){return{}}init(t){this.graph=t}getEvents(){return{}}destroy(){const{graph:t}=this;Ce(this.events,((e,n)=>{t.off(n,e)})),this.events=null,this.options=null,this.destroyed=!0}}const HD=["pointerenter","click"],jD=(t,e)=>{const n=t.filter((t=>!e.includes(t)));return{active:e.filter((e=>!t.includes(e))),inactive:n}},XD={multiple:!0,shouldBegin:()=>!0,shouldUpdate:()=>!0,trigger:"click",activeState:"selected"};const YD=(t,e)=>{const n=new Set;return e.forEach((r=>{t.getRelatedEdgesData(r).forEach((r=>{const{source:i,target:o,id:a}=r;t.getItemVisible(a)&&e.includes(i)&&e.includes(o)&&n.add(a)}))})),Array.from(n)},KD=(t,e,n,r,i,o,a,s={},l=!0)=>{let c=i.get(t.model.id);if(c)return c;const{shapeIds:u,drawSource:h=!0,drawTarget:d=!0,visible:p=!0}=s;if("node"===t.type)c=t.clone(e,u,!0);else if("edge"===t.type){let l,p;h&&(l=KD(t.sourceItem,e,n,r,i,o,a,s,!1)),d&&(p=KD(t.targetItem,e,n,r,i,o,a,s,!1)),c=t.clone(n,l,p,u,!0)}else{const l=[];a.getChildren(t.model.id,"combo").forEach((t=>{const c=o.get(t.id);c&&l.push(KD(c,e,n,r,i,o,a,s,!1))})),c=t.clone(r,u,!0,(()=>(t=>{if(!t.length)return!1;const e={center:[0,0,0],min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0],size:[0,0,0]};let n=0;return t.forEach((t=>{const r=t.getBBox();if(r){n++;const{min:t,max:i}=r;t.forEach(((t,n)=>{t<e.min[n]&&(e.min[n]=t)})),i.forEach(((t,n)=>{t>e.max[n]&&(e.max[n]=t)}))}})),!!n&&(e.size=e.size.map(((t,n)=>e.max[n]-e.min[n])),e.center=e.center.map(((t,n)=>(e.max[n]+e.min[n])/2)),e)})(l)),(()=>l)),c.toBack()}if(i.set(t.model.id,c),c.transient=!0,"edge"!==t.type&&l&&a.hasTreeStructure("combo")){let l=a.getParent(t.model.id,"combo");for(;l;){const t=o.get(l.id);if(t){KD(t,e,n,r,i,o,a,s).toBack()}l=a.getParent(l.id,"combo")}}return(null==u?void 0:u.length)&&p&&c.childNodes.forEach((t=>t.show())),c};function qD(t,e){return[t,gn(),e].join("->")}const $D=["drag","shift","ctrl","alt","meta"],ZD="g6-brush-select-brush-shape",QD={trigger:"shift",selectedState:"selected",itemTypes:["node","edge"],eventName:"",selectSetMode:"latest",brushStyle:{fill:"#EEF6FF",fillOpacity:.4,stroke:"#DDEEFE",lineWidth:1},shouldBegin:()=>!0,shouldUpdate:()=>!0,onSelect:()=>{},onDeselect:()=>{}};class JD extends WD{constructor(t){super(Object.assign({},QD,t)),this.selectedIds={nodes:[],edges:[],combos:[]},this.getEvents=()=>({pointerdown:this.onMouseDown,pointermove:this.onMouseMove,pointerup:this.onMouseUp}),t.trigger&&!$D.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for brush-select behavior!`),this.options.trigger=QD.trigger)}isKeydown(t){const e=this.options.trigger;return{drag:!0,shift:t.shiftKey,ctrl:t.ctrlKey,alt:t.altKey,meta:t.metaKey}[e]}onMouseDown(t){if(!this.options.shouldBegin(t))return;const{itemId:e,itemType:n,canvas:r}=t;if(e&&"node"===n)return;if(this.beginPoint={x:r.x,y:r.y},!this.isKeydown(t))return void this.clearStates();const{brush:i}=this;i||(this.brush=this.createBrush()),this.brush&&(this.brush.setAttribute("width",0),this.brush.setAttribute("height",0),this.brush.setAttribute("visibility","visible")),this.mousedown=!0}onMouseMove(t){this.mousedown&&this.isKeydown(t)&&(this.dragging=!0,this.brush=this.updateBrush(t))}onMouseUp(t){this.mousedown&&(this.isKeydown(t)||this.clearStates(),this.removeBrush(),this.brush=void 0,this.selectedIds=this.selectItems(t),this.dragging=!1,this.mousedown=!1)}clearStates(t=void 0,e=void 0){const{graph:n}=this,{selectedState:r,eventName:i,onDeselect:o}=this.options;let a=[],s=[],l=[];if(t?(a=t.nodes,s=t.edges,l=t.combos,this.selectedIds=e||{nodes:[],edges:[],combos:[]}):(a=n.findIdByState("node",r),s=n.findIdByState("edge",r),l=n.findIdByState("combo",r),this.selectedIds={nodes:[],edges:[],combos:[]}),a.concat(s).concat(l).forEach((t=>n.setItemState(t,r,!1))),a.length||s.length||l.length){const t={nodes:a,edges:s,combos:l};null==o||o(this.selectedIds,t),i&&n.emit(i,{action:"deselect",selectedIds:this.selectedIds,deselectedIds:t})}}selectItems(t){var e,n,r,i,o,a,s,l;const{graph:c,options:u}=this,{selectedState:h,itemTypes:d,eventName:p,selectSetMode:f,shouldUpdate:g,onSelect:m}=u,v=this.getSelector(),y=this.getPoints(t).filter(Boolean);if(y.length<2)return;let E=v(c,y,d.concat("node")),_=(t,e)=>e;const b=(null===(e=this.selectedIds)||void 0===e?void 0:e.nodes.length)||(null===(n=this.selectedIds)||void 0===n?void 0:n.edges.length)||(null===(r=this.selectedIds)||void 0===r?void 0:r.combos.length);switch(f){case"diff":b&&(_=bR);break;case"union":_=SR;break;case"intersect":b&&(_=xR)}E={nodes:_(null===(i=this.selectedIds)||void 0===i?void 0:i.nodes,E.nodes).filter((t=>g("node",t,"select",this))),edges:[],combos:_(null===(o=this.selectedIds)||void 0===o?void 0:o.combos,E.combos).filter((t=>g("combo",t,"select",this)))};const S=d.includes("edge");S&&(E.edges=YD(c,E.nodes.concat(E.combos)).filter((t=>g("edge",t,"select",this))));const x=d.includes("node");x||(E.nodes=[]);const T=d.includes("combo");if(T||(E.combos=[]),h){const t={nodes:x?bR(null===(a=this.selectedIds)||void 0===a?void 0:a.nodes,E.nodes):[],edges:S?bR(null===(s=this.selectedIds)||void 0===s?void 0:s.edges,E.edges):[],combos:T?bR(null===(l=this.selectedIds)||void 0===l?void 0:l.combos,E.combos):[]};(t.nodes.length||t.edges.length||t.combos.length)&&this.clearStates(t,E);const{nodes:e,edges:n,combos:r}=E;e.concat(n).concat(r).forEach((t=>c.setItemState(t,h,!0)))}this.selectedIds=E;return(E.nodes.length||E.edges.length||E.combos.length)&&(null==m||m(this.selectedIds)),p&&c.emit(p,{action:"select",selectedIds:this.selectedIds}),this.selectedIds}createBrush(){const{graph:t,options:e}=this,{brushStyle:n}=e;return t.drawTransient("rect",ZD,{style:Object.assign(Object.assign({},n),{pointerEvents:"none"})})}updateBrush(t){const{beginPoint:e,graph:n}=this,r=t.canvas;return n.drawTransient("rect",ZD,{style:{width:Math.abs(r.x-e.x),height:Math.abs(r.y-e.y),x:Math.min(r.x,e.x),y:Math.min(r.y,e.y)}})}removeBrush(){const{graph:t}=this;t.drawTransient("rect",ZD,{action:"remove"})}getSelector(){return QH.rectSelector}getPoints(t){const{canvas:e}=t;return[this.beginPoint,e]}destroy(){this.removeBrush()}}const tB=["shift","ctrl","alt","meta"],eB={multiple:!0,trigger:"shift",selectedState:"selected",itemTypes:["node","edge"],eventName:"",shouldBegin:()=>!0,shouldUpdate:()=>!0};const nB=["click","dblclick"],rB={trigger:"click",eventName:"",disableAnimate:!1,shouldBegin:()=>!0,shouldUpdate:()=>!0};const iB={trigger:"dblclick",shouldBegin:()=>!0};const oB=["drag","directionKeys"],aB={enableOptimize:void 0,dragOnItems:!1,trigger:"drag",direction:"both",secondaryKey:"",secondaryKeyToDisable:"shift",speedUpKey:"",scalableRange:0,eventName:"",shouldBegin:()=>!0};const sB="g6-drag-node-delegate-shape",lB={enableTransient:!0,enableDelegate:!1,delegateStyle:{fill:"#F3F9FF",fillOpacity:.5,stroke:"#1890FF",strokeOpacity:.9,lineDash:[5,5]},throttle:16,hideRelatedEdges:!1,selectedState:"selected",eventName:"",updateComboStructure:!0,shouldBegin:()=>!0};const cB="g6-drag-combo-delegate-shape",uB={enableTransient:!0,enableDelegate:!1,delegateStyle:{fill:"#F3F9FF",fillOpacity:.5,stroke:"#1890FF",strokeOpacity:.9,lineDash:[5,5]},throttle:16,hideRelatedEdges:!1,selectedState:"selected",eventName:"",updateComboStructure:!0,shouldBegin:()=>!0};const hB=["wheel","upDownKeys"],dB={enableOptimize:void 0,triggerOnItems:!0,sensitivity:10,trigger:"wheel",secondaryKey:"",speedUpKey:"shift",eventName:"",minZoom:1e-5,maxZoom:1e3,shouldBegin:()=>!0};const pB={throttle:16,activateState:"active",eventName:"",itemTypes:["node","edge","combo"],shouldBegin:()=>!0};const fB="g6-lasso-select-brush-shape";const gB=["drag","directionKeys"],mB={trigger:"drag",secondaryKey:"",speedUpKey:"shift",eventName:"",triggerOnItems:!1,shouldBegin:()=>!0};class vB extends WD{constructor(t){const e=Object.assign({},mB,t);gB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid for rotate-canvas-3d behavior, "drag" will take effect instead. Only "${gB.join('", "')}" are available.`),e.trigger="drag"),super(e),this.getEvents=()=>"drag"===this.options.trigger?{pointerdown:this.onPointerDown,pointermove:this.onPointerMove,pointerup:this.onPointerUp,keydown:this.onKeydown,keyup:this.onKeyup}:{keydown:this.onKeydown,keyup:this.onKeyup}}onPointerDown(t){const{triggerOnItems:e,shouldBegin:n}=this.options;if(t.itemId&&!e||!n(t))return;const{client:r}=t;this.pointStartAt={x:r.x,y:r.y}}onPointerMove(t){if(!this.pointStartAt)return;const{shouldBegin:e,secondaryKey:n}=this.options;if(n&&!this.keydown)return;if(!e(t))return;const{client:r}=t,i={x:r.x-this.pointStartAt.x,y:r.y-this.pointStartAt.y},{graph:o}=this,a=o.canvas.getCamera();this.rotate(a,i.x,i.y),this.pointStartAt={x:r.x,y:r.y}}onPointerUp(t){this.pointStartAt=void 0}onKeydown(t){const{key:e}=t,{trigger:n,secondaryKey:r,speedUpKey:i}=this.options;if("directionKeys"===n&&(!r||r&&this.keydown)){const{graph:t}=this,n=t.canvas.getCamera(),r=1*(this.speedUpKeydown?10:1);"ArrowUp"===e&&n.pan(0,r),"ArrowDown"===e&&n.pan(0,-r),"ArrowLeft"===e&&n.pan(r,0),"ArrowRight"===e&&n.pan(-r,0)}r===e.toLowerCase()&&(this.keydown=!0),i===e.toLowerCase()&&(this.speedUpKeydown=!0)}onKeyup(t){const{key:e}=t,{secondaryKey:n,speedUpKey:r}=this.options;n===e.toLowerCase()&&(this.keydown=!1),r===e.toLowerCase()&&(this.speedUpKeydown=!1)}rotate(t,e,n){const{width:r,height:i}=this.graph.canvas.getConfig();let o=10,a=10;e*e>2*n*n?a*=.5:n*n>2*e*e&&(o*=.5);const s=e*(20/i)*o,l=n*(20/r)*a;t.rotate(s,-l,0)}}const yB=["drag","directionKeys"],EB={trigger:"directionKeys",secondaryKey:"",eventName:"",shouldBegin:()=>!0};const _B=["drag","directionKeys"],bB={trigger:"directionKeys",secondaryKey:"",eventName:"",shouldBegin:()=>!0};const SB=["wheel","upDownKeys"],xB={trigger:"wheel",secondaryKey:"",eventName:"",sensitivity:10,triggerOnItems:!0,minZoom:.01,maxZoom:10,shouldBegin:()=>!0};function TB({optionName:t,shouldBe:e,now:n,scope:r}){console.warn(`G6 [${r}]: Invalid option, ${t} must be one of ${e.join(", ")}, but got ${n}`)}const AB=["shift","ctrl","control","alt","meta"],RB=["click","drag"],MB="g6-create-edge-virtual-edge",CB="g6-create-edge-dummy-node",PB={trigger:"click",secondaryKey:void 0,shouldBegin:()=>!0,shouldEnd:()=>!1,edgeConfig:{}};const wB=["shift","ctrl","alt","control"],NB={trigger:"ctrl",combinedKey:"1",functionName:"fitView",functionParams:[]};const OB={direction:"both",enableOptimize:!1,zoomKey:"ctrl",scalableRange:0,allowDragOnItem:!0,zoomRatio:.05};const IB=["shift","ctrl","alt","control","meta"];function DB(t){const e=(t?Array.isArray(t)?t:[t]:[]).filter((t=>{const e=IB.includes(t);return e||console.warn(`Invalid zoomKey: ${t}, please use a valid zoomKey: ${JSON.stringify(IB)}`),e}));return 0===e.length&&e.push("ctrl"),e}var BB=Object.freeze({__proto__:null,ActivateRelations:class extends WD{constructor(t){super(Object.assign({},XD,t)),this.getEvents=()=>{const{trigger:t}=this.options;return"pointerenter"===t?{"node:pointerenter":this.setAllItemStates,"combo:pointerenter":this.setAllItemStates,"node:pointerleave":this.clearActiveState,"combo:pointerleave":this.clearActiveState}:{"node:click":this.setAllItemStates,"combo:click":this.setAllItemStates,"canvas:click":this.clearActiveState}},t.trigger&&!HD.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for activate-relations behavior!`),this.options.trigger=XD.trigger),this.prevEdgeIds=[],this.prevNodeIds=[]}setAllItemStates(t){const{itemId:e}=t,{graph:n}=this,{activeState:r}=this.options;if(!n||n.destroyed)return;if(!this.options.shouldBegin(t))return;const i=n.getNeighborNodesData(e,"both").map((t=>t.id)),o=n.getRelatedEdgesData(e,"both").map((t=>t.id)),a=[e,...i],{active:s,inactive:l}=jD(this.prevNodeIds,a),{active:c,inactive:u}=jD(this.prevEdgeIds,o);n.historyBatch((()=>{n.setItemState(s,r,!0),n.setItemState(l,r,!1),n.setItemState(c,r,!0),n.setItemState(u,r,!1)})),this.prevNodeIds=a,this.prevEdgeIds=o}clearActiveState(t){const{activeState:e}=this.options;this.graph.historyBatch((()=>{this.graph.setItemState(this.prevNodeIds,e,!1),this.graph.setItemState(this.prevEdgeIds,e,!1)})),this.prevNodeIds=[],this.prevEdgeIds=[]}},BrushSelect:JD,ClickSelect:class extends WD{constructor(t){super(Object.assign({},eB,t)),this.selectedIds=[],this.canvasPointerDown=void 0,this.canvasPointerMove=!1,this.timeout=void 0,this.getEvents=()=>({"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClickBesideDblClick,"canvas:pointerdown":this.onCanvasPointerDown,"canvas:pointermove":this.onCanvasPointerMove,"canvas:pointerup":this.onCanvasPointerUp}),t.trigger&&!tB.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for click-select behavior!`),this.options.trigger=eB.trigger)}isMultipleSelect(t){if(!this.options.multiple)return!1;return{shift:t.shiftKey,ctrl:t.ctrlKey,alt:t.altKey,meta:t.metaKey}[this.options.trigger]}onClickBesideDblClick(t){if(this.timeout)return clearTimeout(this.timeout),void(this.timeout=void 0);this.timeout=setTimeout((()=>{this.timeout=void 0,this.onClick(t)}),200)}onClick(t){if(!this.options.shouldBegin(t))return;const e=t.itemType,n=t.itemId;if(!this.options.itemTypes.includes(e))return;const r=this.options.selectedState,i=this.isMultipleSelect(t),o=!this.graph.findIdByState(e,r).includes(n),a=o?"select":"unselect";if(this.options.shouldUpdate(t)&&(this.graph.historyBatch((()=>{i||this.graph.setItemState(this.selectedIds,r,!1),this.graph.setItemState(n,r,o)})),o?this.selectedIds.push(n):this.selectedIds.filter((t=>t!==n))),this.options.eventName){const t=this.graph.findIdByState("node",r),i=this.graph.findIdByState("edge",r),o=this.graph.findIdByState("combo",r);this.graph.emit(this.options.eventName,{action:a,itemId:n,itemType:e,selectedNodeIds:t,selectedEdgeIds:i,selectedComboIds:o})}}onCanvasPointerDown(t){this.canvasPointerDown={x:t.canvas.x,y:t.canvas.y},this.canvasPointerMove=!1}onCanvasPointerMove(t){if(this.canvasPointerDown){const e=Math.abs(this.canvasPointerDown.x-t.canvas.x),n=Math.abs(this.canvasPointerDown.y-t.canvas.y);(e>1||n>1)&&(this.canvasPointerMove=!0)}}onCanvasPointerUp(t){this.canvasPointerDown&&!this.canvasPointerMove&&this.onCanvasClick(t),this.canvasPointerDown=void 0,this.canvasPointerMove=!1}onCanvasClick(t){if(!this.options.shouldBegin(t))return;const e=this.options.selectedState;this.selectedIds.length&&(this.options.shouldUpdate(t)&&this.graph.setItemState(this.selectedIds,e,!1),this.options.eventName&&this.graph.emit(this.options.eventName,{action:"unselect",itemId:"",itemType:"",selectedNodeIds:[],selectedEdgeIds:[],selectedComboIds:[]}))}},CollapseExpandTree:class extends WD{constructor(t){super(Object.assign({},rB,t)),this.timeout=void 0,this.getEvents=()=>"dblclick"===this.options.trigger?{"node:dblclick":this.onClick}:{"node:click":this.onClickBesideDblClick},t.trigger&&!nB.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for collapse-expand-tree behavior!`),this.options.trigger=rB.trigger)}onClickBesideDblClick(t){if(this.timeout)return clearTimeout(this.timeout),void(this.timeout=void 0);this.timeout=setTimeout((()=>{this.timeout=void 0,this.onClick(t)}),200)}onClick(t){if(!this.options.shouldBegin(t))return;const{itemId:e,itemType:n}=t,{disableAnimate:r}=this.options,i=this.graph.getNodeData(e);if(!i)return void console.warn(`Node with id ${e} is not exist`);this.graph.frontItem(e);let o="expand";i.data.collapsed?this.graph.expand(e,r):(this.graph.collapse(e,r),o="collapse"),this.options.eventName&&this.graph.emit(this.options.eventName,{action:o,itemId:e,itemType:n})}},CollapseExpandCombo:class extends WD{constructor(t){super(Object.assign({},iB,t)),this.getEvents=()=>"dblclick"===this.options.trigger?{"combo:dblclick":this.collapseExpandCombo}:{"combo:click":this.collapseExpandCombo}}collapseExpandCombo(t){if(!this.options.shouldBegin(t))return;const{itemId:e}=t;this.graph.getComboData(e).data.collapsed?this.graph.expandCombo(e):this.graph.collapseCombo(e)}},DragCanvas:class extends WD{constructor(t){const e=Object.assign({},aB,t);oB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid, 'drag' will take effect.`),e.trigger="drag"),super(e)}getEvents(){return"undefined"!=typeof window&&(window.addEventListener("keydown",this.onKeydown.bind(this)),window.addEventListener("keyup",this.onKeyup.bind(this))),"directionKeys"===this.options.trigger?{keydown:this.onKeydown,keyup:this.onKeyup}:{pointerdown:this.onPointerDown,pointermove:this.onPointerMove,pointerup:this.onPointerUp,keydown:this.onKeydown,keyup:this.onKeyup}}onPointerDown(t){const{secondaryKey:e,secondaryKeyToDisable:n,dragOnItems:r,shouldBegin:i}=this.options;if(n&&this.disableKeydown)return;if(e&&!this.keydown)return;if(!i(t))return;if(t.itemId&&"CANVAS"!==t.itemId&&!r)return;const{client:o}=t;this.pointerDownAt={x:o.x,y:o.y},document.addEventListener("mouseup",(t=>{this.onPointerUp()}),{once:!0})}hideShapes(){const{graph:t}=this,{tileBehavior:e,tileBehaviorSize:n=1e3}=t.getSpecification().optimize||{},r=void 0!==this.options.enableOptimize?this.options.enableOptimize:e;if(Ue(r)?t.getAllNodesData().length>r:r){this.hiddenEdgeIds=t.getAllEdgesData().map((t=>t.id)).filter((e=>!0===t.getItemVisible(e))),this.hiddenNodeIds=t.getAllNodesData().map((t=>t.id)).filter((e=>!0===t.getItemVisible(e)));const e=[...this.hiddenNodeIds],r=Math.ceil(e.length/n),i=Array.from({length:r},((t,r)=>e.slice(r*n,r*n+n))),o=()=>{if(!i.length&&this.tileRequestId)return cancelAnimationFrame(this.tileRequestId),void(this.tileRequestId=void 0);const e=i.shift();t.executeWithNoStack((()=>{t.hideItem(e,!1,!0)})),this.tileRequestId=requestAnimationFrame(o)};this.tileRequestId=requestAnimationFrame(o)}}formatDisplacement(t,e){const{graph:n}=this,{scalableRange:r,direction:i}=this.options,[o,a]=n.getSize(),s=n.canvas.getRoot().getRenderBounds();let l,c=Number(r);if("string"==typeof r&&(r.includes("px")&&(l=r.includes("px"),c=Number(r.replace("px",""))),r.includes("%")&&(c=Number(r.replace("%",""))/100)),0===c)return{dx:t,dy:e};let u=c,h=c;l||(u=o*c,h=a*c);const d=n.getViewportByCanvas({x:s.min[0],y:s.min[1]}),p=n.getViewportByCanvas({x:s.max[0],y:s.max[1]});let f=t,g=e;return("y"===i||t>0&&p.x+t>o+u||t<0&&d.x+u+t<0)&&(f=0),("x"===i||e>0&&p.y+e>a+h||e<0&&d.y+h+e<0)&&(g=0),{dx:f,dy:g}}onPointerMove(t){if(!this.pointerDownAt)return;const{eventName:e,direction:n,secondaryKeyToDisable:r}=this.options;if(r&&this.disableKeydown)return;this.dragging||(this.hideShapes(),this.dragging=!0);const i=Date.now();if(this.lastDragTriggerTime&&i-this.lastDragTriggerTime<50)return;const{graph:o}=this,{client:a}=t,s=a.x-this.pointerDownAt.x,l=a.y-this.pointerDownAt.y;if("x"===n&&!s)return;if("y"===n&&!l)return;if("both"===n&&!s&&!l)return;const{dx:c,dy:u}=this.formatDisplacement(s,l);o.translate({dx:c,dy:u}),this.pointerDownAt={x:a.x,y:a.y},e&&this.graph.emit(e,{translate:{dx:c,dy:u}}),this.lastDragTriggerTime=i}onPointerUp(){this.pointerDownAt=void 0,this.dragging=!1;const{graph:t,hiddenNodeIds:e,hiddenEdgeIds:n=[]}=this,{tileBehavior:r,tileBehaviorSize:i=1e3}=t.getSpecification().optimize||{},o=void 0!==this.options.enableOptimize?this.options.enableOptimize:r;if((Ue(o)?t.getAllNodesData().length>o:o)&&(this.tileRequestId&&(cancelAnimationFrame(this.tileRequestId),this.tileRequestId=void 0),e)){const r=[...e,...n],o=Math.ceil(r.length/i),a=Array.from({length:o},((t,e)=>r.slice(e*i,e*i+i))),s=()=>{if(!a.length&&this.tileRequestId)return cancelAnimationFrame(this.tileRequestId),void(this.tileRequestId=void 0);t.startHistoryBatch(),t.showItem(a.shift(),!1),t.stopHistoryBatch(),this.tileRequestId=requestAnimationFrame(s)};this.tileRequestId=requestAnimationFrame(s)}}onKeydown(t){const{key:e}=t,{secondaryKey:n,secondaryKeyToDisable:r,trigger:i,speedUpKey:o,eventName:a,shouldBegin:s}=this.options;if(n&&n===e.toLowerCase()&&(this.keydown=!0),o&&o===e.toLowerCase()&&(this.speedupKeydown=!0),r&&r===e.toLowerCase()&&(this.disableKeydown=!0),"directionKeys"===i){if(n&&!this.keydown)return;if(r&&this.disableKeydown)return;if(!s(t))return;const{graph:i,speedupKeydown:o}=this,l=o?20:1;let c=0,u=0;switch(e){case"ArrowLeft":c=-l;break;case"ArrowRight":c=l;break;case"ArrowUp":u=-l;break;case"ArrowDown":u=l}if(c||u){const{dx:t,dy:e}=this.formatDisplacement(c,u);i.translate({dx:t,dy:e}),a&&this.graph.emit(a,{translate:{dx:t,dy:e}})}}}onKeyup(t){const{key:e}=t,{secondaryKey:n,secondaryKeyToDisable:r,speedUpKey:i}=this.options;n&&n===e.toLowerCase()&&(this.keydown=!1),i&&i===e.toLowerCase()&&(this.speedupKeydown=!1),r&&r===e.toLowerCase()&&(this.disableKeydown=!1)}destroy(){"undefined"!=typeof window&&(window.removeEventListener("keydown",this.onKeydown.bind(this)),window.removeEventListener("keyup",this.onKeyup.bind(this)))}},DragNode:class extends WD{constructor(t){const e=Object.assign({},lB,t);e.enableDelegate&&(e.enableTransient=!1),(e.enableDelegate||e.enableTransient)&&(e.hideRelatedEdges=!1),super(e),this.hiddenEdges=[],this.selectedNodeIds=[],this.hiddenNearEdges=[],this.hiddenComboTreeItems=[],this.originPositions=[],this.pointerDown=void 0,this.dragging=!1,this.getEvents=()=>{const t={"node:pointerdown":this.onPointerDown,pointermove:this.onPointerMove,click:this.onClick,keydown:this.onKeydown};return this.options.updateComboStructure?Object.assign({"node:drop":this.onDropNode,"combo:drop":this.onDropCombo,"canvas:drop":this.onDropCanvas},t):Object.assign({pointerup:this.onClick},t)},this.throttledMoveNodes=(t,e,n,r=!0)=>{}}getRelatedEdges(t,e,n=!0){const r=[];sP(this.graph,e,(t=>r.push(t.id)));let i=Be(t.concat(r).flatMap((t=>this.graph.getRelatedEdgesData(t))));return n&&(i=i.filter((t=>this.graph.getItemVisible(t.id)))),i}getNearEdgesForNodes(t){return Be(t.flatMap((t=>this.graph.getNearEdgesForNode(t))))}getComboTreeItems(t){const e=[];return this.options.updateComboStructure?e:(t.forEach((t=>{const n=this.graph.getNodeData(t);if(!n.data.parentId)return;let r,i=n.data.parentId;for(;i;){const t=this.graph.getComboData(i);if(!t)break;r=t,i=t.data.parentId,e.push(r)}})),Be(e).filter((t=>this.graph.getItemVisible(t.id))))}onPointerDown(t){this.options.shouldBegin(t)&&(this.pointerDown={x:t.canvas.x,y:t.canvas.y},this.dragging=!1)}onPointerMove(t){if(!this.pointerDown)return;const e=Math.abs(this.pointerDown.x-t.canvas.x),n=Math.abs(this.pointerDown.y-t.canvas.y);if(e<1&&n<1)return;const r=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType;if(!this.dragging){this.dragging=!0;const e=t.itemId;this.selectedNodeIds=this.graph.findIdByState("node",this.options.selectedState,!0),e&&!this.selectedNodeIds.includes(e)&&(this.selectedNodeIds=[e]),this.originPositions=this.selectedNodeIds.map((t=>{if(!this.graph.getNodeData(t))return void console.warn("node does not exist",t);const{x:e,y:n}=this.graph.getNodeData(t).data;if(this.options.enableDelegate){const r=this.graph.getRenderBBox(t);if(r){const[i,o]=r.min,[a,s]=r.max;return{id:t,x:e,y:n,minX:i,minY:o,maxX:a,maxY:s}}}return{id:t,x:e,y:n}})).filter(Boolean),this.options.hideRelatedEdges&&!r&&(this.hiddenComboTreeItems=this.getComboTreeItems(this.selectedNodeIds),this.hiddenEdges=this.getRelatedEdges(this.selectedNodeIds,this.hiddenComboTreeItems),this.graph.executeWithNoStack((()=>{this.graph.hideItem(this.hiddenEdges.map((t=>t.id)),!0),this.graph.hideItem(this.hiddenComboTreeItems.map((t=>t.id)),!0)}))),r?(this.hiddenComboTreeItems=this.getComboTreeItems(this.selectedNodeIds),this.hiddenEdges=this.getRelatedEdges(this.selectedNodeIds,this.hiddenComboTreeItems),this.selectedNodeIds.forEach((t=>{this.graph.drawTransient("node",t,{upsertAncestors:!this.options.updateComboStructure})})),this.hiddenEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})})),this.graph.executeWithNoStack((()=>{this.graph.hideItem(this.selectedNodeIds,!0),this.graph.hideItem(this.hiddenEdges.map((t=>t.id)),!0),this.graph.hideItem(this.hiddenComboTreeItems.map((t=>t.id)),!0)}))):this.graph.frontItem(this.selectedNodeIds),this.options.throttle>0?this.throttledMoveNodes=pn(this.moveNodes,this.options.throttle,{leading:!0,trailing:!0}):this.throttledMoveNodes=this.moveNodes,this.originX=t.canvas.x,this.originY=t.canvas.y}if(this.dragging&&r){const t=this.selectedNodeIds.filter((t=>{var e;return(null===(e=this.graph.getNodeData(t))||void 0===e?void 0:e.data.preventPolylineEdgeOverlap)||!1}));if(t){const e=this.hiddenEdges.map((t=>t.id));this.hiddenNearEdges=this.getNearEdgesForNodes(t).filter((t=>!e.includes(t.id))),this.hiddenNearEdges.length&&(this.hiddenNearEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})})),this.graph.hideItem(this.hiddenNearEdges.map((t=>t.id)),!0))}}if(!this.originPositions.length||!this.dragging)return;const i=t,o=i.canvas.x-this.originX,a=i.canvas.y-this.originY;if(this.options.enableDelegate)this.moveDelegate(o,a);else{const t=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType;this.throttledMoveNodes(o,a,t,!this.options.updateComboStructure)}}moveNodes(t,e,n,r=!0,i){if(n)this.originPositions.forEach((({id:n,x:i,y:o})=>{this.graph.drawTransient("node",n,{data:{x:i+t,y:o+e},upsertAncestors:r})})),this.hiddenEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})}));else{const n=this.originPositions.map((({id:n,x:r,y:i})=>({id:n,data:{x:r+t,y:i+e}}))),o=[...this.originPositions];this.graph.updateNodePosition(n,r,!0,(()=>null==i?void 0:i(o)))}}moveDelegate(t,e){const n=Math.min(...this.originPositions.map((t=>t.minX))),r=Math.min(...this.originPositions.map((t=>t.minY))),i=Math.max(...this.originPositions.map((t=>t.maxX))),o=Math.max(...this.originPositions.map((t=>t.maxY)));this.graph.drawTransient("rect",sB,{style:Object.assign({x:n+t,y:r+e,width:i-n,height:o-r},this.options.delegateStyle)})}clearDelegate(){this.graph.drawTransient("rect",sB,{action:"remove"})}clearTransientItems(t){this.hiddenEdges.forEach((t=>{this.graph.drawTransient("node",t.source,{action:"remove"}),this.graph.drawTransient("node",t.target,{action:"remove"}),this.graph.drawTransient("edge",t.id,{action:"remove"})})),this.hiddenNearEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{action:"remove"})})),this.hiddenComboTreeItems.forEach((t=>{const e=t.data._isCombo;this.graph.drawTransient(e?"combo":"node",t.id,{action:"remove"})})),t.forEach((({id:t})=>{this.graph.drawTransient("node",t,{action:"remove"})}))}restoreHiddenItems(t){this.graph.pauseStack(),this.hiddenEdges.length&&(this.graph.showItem(this.hiddenEdges.map((t=>t.id)),!0),this.hiddenEdges=[]),this.hiddenNearEdges.length&&(this.graph.showItem(this.hiddenNearEdges.map((t=>t.id)),!0),this.hiddenNearEdges=[]),this.hiddenComboTreeItems.length&&(this.graph.showItem(this.hiddenComboTreeItems.map((t=>t.id)),!0),this.hiddenComboTreeItems=[]);this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType&&this.graph.showItem(this.originPositions.concat(t).map((t=>t.id)),!0),this.graph.resumeStack()}clearState(){this.originPositions=[]}onClick(t){this.onPointerUp(t),this.clearState()}onPointerUp(t){this.pointerDown=void 0,this.dragging=!1,this.selectedNodeIds=[];const e=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType,n=t,r=n.canvas.x-this.originX+.01,i=n.canvas.y-this.originY+.01;this.moveNodes(r,i,!1,!0,en((t=>{e&&this.clearTransientItems(t),this.options.enableDelegate&&this.clearDelegate(),this.restoreHiddenItems(t),this.options.eventName&&this.graph.emit(this.options.eventName,{itemIds:t.map((t=>t.id))}),this.clearState()})))}onKeydown(t){if("Escape"!==t.key&&"Esc"!==t.key)return;this.clearDelegate(),this.clearTransientItems(this.originPositions),this.restoreHiddenItems();if(!(this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType)&&!this.options.enableDelegate){const t=this.originPositions.map((({id:t,x:e,y:n})=>({id:t,data:{x:e,y:n}})));this.graph.updateNodePosition(t)}this.clearState()}onDropNode(t){return Oc(this,void 0,void 0,(function*(){const e=yield this.graph.canvas.document.elementsFromPoint(t.canvas.x,t.canvas.y),n=this.originPositions.map((({id:t})=>t)),r=e.map((t=>{var e,n;return null===(n=(e=t.parentNode).getAttribute)||void 0===n?void 0:n.call(e,"data-item-id")})).filter((t=>void 0!==t&&!n.includes(t))),i=r.find((t=>this.graph.getComboData(t)||this.graph.getNodeData(t))),o=this.graph.getNodeData(i)?this.graph.getNodeData(i).data.parentId:i;this.graph.startHistoryBatch(),this.originPositions.forEach((({id:t})=>{const e=this.graph.getNodeData(t);if(!e)return;const{parentId:n}=e.data;n!==o&&this.graph.updateData("node",{id:t,data:{parentId:o}})})),this.onPointerUp(t),this.graph.stopHistoryBatch()}))}onDropCombo(t){t.stopPropagation();const e=t.itemId;this.graph.startHistoryBatch(),this.onPointerUp(t),this.originPositions.forEach((({id:t})=>{const n=this.graph.getNodeData(t);if(!n)return;const{parentId:r}=n.data;r!==e&&this.graph.updateData("node",{id:t,data:{parentId:e}})})),this.clearState(),this.graph.stopHistoryBatch()}onDropCanvas(t){return Oc(this,void 0,void 0,(function*(){const e=yield this.graph.canvas.document.elementsFromPoint(t.canvas.x,t.canvas.y),n=this.originPositions.map((({id:t})=>t)),r=e.map((t=>{var e,n;return null===(n=(e=t.parentNode).getAttribute)||void 0===n?void 0:n.call(e,"data-item-id")})).filter((t=>void 0!==t&&!n.includes(t))),i=r.find((t=>this.graph.getComboData(t)||this.graph.getNodeData(t))),o=this.graph.getNodeData(i)?this.graph.getNodeData(i).data.parentId:i;this.graph.startHistoryBatch(),this.onPointerUp(t);const a=[];this.originPositions.forEach((({id:t})=>{const{parentId:e}=this.graph.getNodeData(t).data;o&&e!==o?a.push({id:t,data:{parentId:o}}):e&&a.push({id:t,data:{parentId:void 0}})})),a.length&&this.graph.updateData("node",a),this.clearState(),this.graph.stopHistoryBatch()}))}},DragCombo:class extends WD{constructor(t){const e=Object.assign({},uB,t);e.enableDelegate&&(e.enableTransient=!1),(e.enableDelegate||e.enableTransient)&&(e.hideRelatedEdges=!1),super(e),this.hiddenEdges=[],this.hiddenComboTreeRoots=[],this.originPositions=[],this.pointerDown=void 0,this.dragging=!1,this.getEvents=()=>{const t={"combo:pointerdown":this.onPointerDown,pointermove:this.onPointerMove,click:this.onPointerUp,keydown:this.onKeydown};return this.options.updateComboStructure?Object.assign({"node:drop":this.onDropNode,"combo:drop":this.onDropCombo,"canvas:drop":this.onDropCanvas},t):Object.assign({pointerup:this.onPointerUp},t)},this.throttledMoveCombos=(t,e,n,r=!0)=>{}}getRelatedEdges(t,e){let n=t.flatMap((t=>this.graph.getRelatedEdgesData(t)));return sP(this.graph,e,(t=>{n=n.concat(this.graph.getRelatedEdgesData(t.id))})),Be(n).filter((t=>this.graph.getItemVisible(t.id)))}getComboTreeItems(t){let e=[];this.options.updateComboStructure?e=t.map((t=>this.graph.getComboData(t))):t.forEach((t=>{const n=this.graph.getComboData(t);let r=n,i=n.data.parentId;for(;i;){const t=this.graph.getComboData(i);if(!t)break;i=t.data.parentId,r=t}e.push(r)}));const n=e;return sP(this.graph,e,(t=>n.push(t)),"TB"),Be(n).filter((e=>!t.includes(e.id)&&this.graph.getItemVisible(e.id)))}onPointerDown(t){this.options.shouldBegin(t)&&(this.pointerDown={x:t.canvas.x,y:t.canvas.y},this.dragging=!1)}onPointerMove(t){if(!this.pointerDown)return;const e=Math.abs(this.pointerDown.x-t.canvas.x),n=Math.abs(this.pointerDown.y-t.canvas.y);if(e<1&&n<1)return;const r=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType;if(this.dragging&&(this.originPositions=this.selectedComboIds.map((t=>{if(!this.graph.getComboData(t))return void console.warn("combo does not exist",t);const e=this.graph.getRenderBBox(t,!0,r);if(!e)return;const[n,i]=e.center;if(this.options.enableDelegate){const[r,o]=e.min,[a,s]=e.max;return{id:t,x:n,y:i,minX:r,minY:o,maxX:a,maxY:s}}return{id:t,x:n,y:i}})).filter(Boolean)),!this.dragging){this.dragging=!0;const e=t.itemId;let n=this.graph.findIdByState("combo",this.options.selectedState,!0);e&&"combo"===t.itemType&&!n.includes(e)&&(n=[e]),this.selectedComboIds=n,this.options.hideRelatedEdges&&!r&&(this.hiddenComboTreeRoots=this.getComboTreeItems(n),this.hiddenEdges=this.getRelatedEdges(n,this.hiddenComboTreeRoots),this.graph.executeWithNoStack((()=>{this.graph.hideItem(this.hiddenEdges.map((t=>t.id)),!0),this.graph.hideItem(this.hiddenComboTreeRoots.map((t=>t.id)),!0)}))),r?(this.hiddenComboTreeRoots=this.getComboTreeItems(n),this.hiddenEdges=this.getRelatedEdges(n,this.hiddenComboTreeRoots),n.forEach((t=>{this.graph.drawTransient("combo",t,{upsertAncestors:!this.options.updateComboStructure})})),this.hiddenEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})})),this.graph.executeWithNoStack((()=>{this.graph.hideItem(n,!0),this.graph.hideItem(this.hiddenEdges.map((t=>t.id)),!0),this.graph.hideItem(this.hiddenComboTreeRoots.map((t=>t.id)),!0)}))):this.graph.frontItem(n),this.options.throttle>0?this.throttledMoveCombos=pn(this.moveCombos,this.options.throttle,{leading:!0,trailing:!0}):this.throttledMoveCombos=this.moveCombos,this.originX=t.canvas.x,this.originY=t.canvas.y,this.previousX=t.canvas.x,this.previousY=t.canvas.y}if(!this.originPositions.length||!this.dragging)return;const i=t,o=i.canvas.x-this.previousX,a=i.canvas.y-this.previousY;if(this.options.enableDelegate)this.moveDelegate(o,a);else{const t=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType;this.throttledMoveCombos(o,a,t,!this.options.updateComboStructure)}}moveCombos(t,e,n,r=!0,i){if(n)this.originPositions.forEach((({id:n,x:i,y:o})=>{this.graph.drawTransient("combo",n,{data:{x:i+t,y:o+e},upsertAncestors:r})})),this.hiddenEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})}));else{const n=[...this.originPositions];this.graph.moveCombo(this.originPositions.map((({id:t})=>t)),t,e,r,(()=>null==i?void 0:i(n)))}this.previousX+=t,this.previousY+=e}moveDelegate(t,e){const n=Math.min(...this.originPositions.map((t=>t.minX))),r=Math.min(...this.originPositions.map((t=>t.minY))),i=Math.max(...this.originPositions.map((t=>t.maxX))),o=Math.max(...this.originPositions.map((t=>t.maxY)));this.graph.drawTransient("rect",cB,{style:Object.assign({x:n+t,y:r+e,width:i-n,height:o-r},this.options.delegateStyle)})}clearDelegate(){this.graph.drawTransient("rect",cB,{action:"remove"})}clearTransientItems(){this.hiddenEdges.forEach((t=>{this.graph.drawTransient("combo",t.source,{action:"remove"}),this.graph.drawTransient("combo",t.target,{action:"remove"}),this.graph.drawTransient("edge",t.id,{action:"remove"})})),this.hiddenComboTreeRoots.forEach((t=>{const e=t.data._isCombo;this.graph.drawTransient(e?"combo":"node",t.id,{action:"remove"})})),this.originPositions.forEach((({id:t})=>{this.graph.drawTransient("combo",t,{action:"remove"})}))}restoreHiddenItems(t){this.graph.pauseStack(),this.hiddenEdges.length&&(this.graph.showItem(this.hiddenEdges.map((t=>t.id)),!0),this.hiddenEdges=[]),this.hiddenComboTreeRoots.length&&(this.graph.showItem(this.hiddenComboTreeRoots.map((t=>t.id)),!0),this.hiddenComboTreeRoots=[]);this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType&&this.graph.showItem(this.originPositions.concat(t).map((t=>t.id)),!0),this.graph.resumeStack()}onPointerUp(t){this.pointerDown=void 0,this.dragging=!1;const e=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType,n=t,r=e?this.originX:this.previousX,i=e?this.originY:this.previousY,o=n.canvas.x-r+.01,a=n.canvas.y-i+.01;this.moveCombos(o,a,!1,!0,en((t=>{e&&this.clearTransientItems(),this.options.enableDelegate&&this.clearDelegate(),this.restoreHiddenItems(t),this.options.eventName&&this.graph.emit(this.options.eventName,{itemIds:t.map((t=>t.id))}),this.originPositions=[]}),16,!1))}onKeydown(t){if("Escape"!==t.key&&"Esc"!==t.key)return;this.clearDelegate(),this.clearTransientItems(),this.restoreHiddenItems();if(!(this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType)&&!this.options.enableDelegate){const t=this.originPositions.map((({id:t,x:e,y:n})=>({id:t,data:{x:e,y:n}})));this.graph.updateComboPosition(t)}this.originPositions=[]}onDropNode(t){return Oc(this,void 0,void 0,(function*(){const e=yield this.graph.canvas.document.elementsFromPoint(t.canvas.x,t.canvas.y),n=this.originPositions.map((({id:t})=>t)),r=e.map((t=>{var e,n;return null===(n=(e=t.parentNode).getAttribute)||void 0===n?void 0:n.call(e,"data-item-id")})).filter((t=>void 0!==t&&!n.includes(t))),i=r.find((t=>this.graph.getComboData(t)||this.graph.getNodeData(t))),o=this.graph.getNodeData(i)?this.graph.getNodeData(i).data.parentId:i;this.originPositions.forEach((({id:t})=>{const e=this.graph.getComboData(t);if(!e)return;const{parentId:n}=e.data;n!==o&&this.graph.updateData("node",{id:t,data:{parentId:o}})})),this.onPointerUp(t)}))}onDropCombo(t){const e=t.itemId;this.graph.startHistoryBatch(),this.originPositions.forEach((({id:t})=>{const n=this.graph.getComboData(t);if(!n||n.id===e)return;const{parentId:r}=n.data;r!==e&&this.graph.updateData("combo",{id:t,data:{parentId:e}})})),this.graph.stopHistoryBatch(),this.onPointerUp(t)}onDropCanvas(t){this.graph.startHistoryBatch(),this.originPositions.forEach((({id:t})=>{const e=this.graph.getComboData(t);if(!e)return;const{parentId:n}=e.data;n&&this.graph.updateData("combo",{id:t,data:{parentId:void 0}})})),this.graph.stopHistoryBatch(),this.onPointerUp(t)}},ZoomCanvas:class extends WD{constructor(t){const e=Object.assign({},dB,t);hB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid, 'wheel' will take effect.`),e.trigger="wheel"),super(e)}getEvents(){var t,e;return null===(e=(t=this.graph.canvas.getContextService().getDomElement()).addEventListener)||void 0===e||e.call(t,"wheel",(t=>{t.preventDefault()}),{passive:!1}),"upDownKeys"===this.options.trigger?{keydown:this.onKeydown,keyup:this.onKeyup}:{wheel:this.onWheel,keydown:this.onKeydown,keyup:this.onKeyup}}hideShapes(){const{graph:t}=this,{tileBehavior:e,tileBehaviorSize:n=1e3}=t.getSpecification().optimize||{},r=void 0!==this.options.enableOptimize?this.options.enableOptimize:e;if(Ue(r)?t.getAllNodesData().length>r:r){this.hiddenEdgeIds=t.getAllEdgesData().map((t=>t.id)).filter((e=>!0===t.getItemVisible(e))),this.hiddenNodeIds=t.getAllNodesData().map((t=>t.id)).filter((e=>!0===t.getItemVisible(e)));const e=[...this.hiddenNodeIds],r=Math.ceil(e.length/n),i=Array.from({length:r},((t,r)=>e.slice(r*n,r*n+n))),o=()=>{if(!i.length&&this.tileRequestId)return cancelAnimationFrame(this.tileRequestId),void(this.tileRequestId=void 0);const e=i.shift();t.startHistoryBatch(),t.hideItem(e,!1,!0),t.stopHistoryBatch(),this.tileRequestId=requestAnimationFrame(o)};this.tileRequestId=requestAnimationFrame(o)}}endZoom(){const{graph:t,hiddenEdgeIds:e=[],hiddenNodeIds:n}=this,{tileBehavior:r,tileBehaviorSize:i=1e3}=t.getSpecification().optimize||{},o=void 0!==this.options.enableOptimize?this.options.enableOptimize:r,a=Ue(o)?t.getAllNodesData().length>o:o;if(this.zooming=!1,a&&(this.tileRequestId&&(cancelAnimationFrame(this.tileRequestId),this.tileRequestId=void 0),n)){const r=[...n,...e],o=Math.ceil(r.length/i),a=Array.from({length:o},((t,e)=>r.slice(e*i,e*i+i))),s=()=>{if(!a.length&&this.tileRequestId)return cancelAnimationFrame(this.tileRequestId),void(this.tileRequestId=void 0);t.executeWithNoStack((()=>{t.showItem(a.shift(),!1)})),this.tileRequestId=requestAnimationFrame(s)};this.tileRequestId=requestAnimationFrame(s)}this.hiddenEdgeIds=[],this.hiddenNodeIds=[]}onWheel(t){const{graph:e,keydown:n}=this,{deltaY:r,client:i,itemId:o}=t,{eventName:a,sensitivity:s,secondaryKey:l,triggerOnItems:c,minZoom:u,maxZoom:h,shouldBegin:d}=this.options;if(l&&!n||o&&"CANVAS"!==o&&!c||!d(t))return void this.endZoom();this.zooming||(this.hideShapes(),this.zooming=!0);const p=Date.now();if(this.lastWheelTriggerTime&&p-this.lastWheelTriggerTime<50)return;let f=1;r<0&&(f=(100+s)/100),r>0&&(f=100/(100+s));const g=f*e.getZoom();u&&g<u||h&&g>h||(e.zoom(f,{x:i.x,y:i.y}),this.lastWheelTriggerTime=p,clearTimeout(this.zoomTimer),this.zoomTimer=setTimeout((()=>{this.endZoom()}),300),a&&e.emit(a,{zoom:{ratio:f}}))}onKeydown(t){const{key:e}=t,{secondaryKey:n,trigger:r,speedUpKey:i,eventName:o,sensitivity:a,shouldBegin:s}=this.options;if(n&&n===e.toLowerCase()&&(this.keydown=!0),i&&i===e.toLowerCase()&&(this.speedupKeydown=!0),"upDownKeys"===r){if(n&&!this.keydown)return;if(!s(t))return;const{graph:r,speedupKeydown:i}=this,l=i?20:1;let c=1;switch(e){case"ArrowUp":c=(100+a*l)/100;break;case"ArrowDown":c=100/(100+a*l)}1!==c&&(r.zoom(c),o&&r.emit(o,{zoom:{ratio:c}}))}}onKeyup(t){const{key:e}=t,{secondaryKey:n,speedUpKey:r}=this.options;n&&n===e.toLowerCase()&&(this.keydown=!1),r&&r===e.toLowerCase()&&(this.speedupKeydown=!1)}},HoverActivate:class extends WD{constructor(t){super(Object.assign({},pB,t)),this.getEvents=()=>({"node:pointerenter":this.onPointerEnter,"node:pointerleave":this.onPointerLeave,"edge:pointerenter":this.onPointerEnter,"edge:pointerleave":this.onPointerLeave,"combo:pointerenter":this.onPointerEnter,"combo:pointerleave":this.onPointerLeave})}onPointerEnter(t){const{itemId:e,itemType:n}=t,{graph:r,currentItemInfo:i}=this,{activateState:o,itemTypes:a,eventName:s}=this.options;i&&a.includes(i.itemType)&&r.setItemState(i.id,o,!1),a.includes(n)&&(r.setItemState(e,o,!0),this.currentItemInfo={id:e,itemType:n},s&&this.graph.emit(s,{itemId:e,itemType:n,state:o,action:"pointerenter"}))}onPointerLeave(t){const{itemId:e,itemType:n}=t,{activateState:r,itemTypes:i,eventName:o}=this.options;if(!i.includes(n))return;const{graph:a}=this;a.setItemState(e,r,!1),this.currentItemInfo=void 0,o&&this.graph.emit(o,{itemId:e,itemType:n,state:r,action:"pointerleave"})}},LassoSelect:class extends JD{constructor(){super(...arguments),this.selectedIds={nodes:[],edges:[],combos:[]},this.points=[],this.onMouseDown=t=>{this.points=[],this.removeBrush(),super.onMouseDown(t),this.beginPoint&&this.points.push(this.beginPoint)},this.onMouseMove=t=>{if(this.mousedown){const{canvas:e}=t;this.points.push({x:e.x,y:e.y})}super.onMouseMove(t)},this.onMouseUp=t=>{const{canvas:e}=t;this.points.push({x:e.x,y:e.y}),super.onMouseUp(t),this.removeBrush(),this.points=[]},this.updateBrush=t=>{const{graph:e}=this;return e.drawTransient("path",fB,{style:{path:this.getLassoPath()}})},this.removeBrush=()=>{const{graph:t}=this;t.drawTransient("path",fB,{action:"remove"})},this.getLassoPath=()=>{const t=this.points,e=[];return t.length&&(t.forEach(((t,n)=>{0===n?e.push(["M",t.x,t.y]):e.push(["L",t.x,t.y])})),e.push(["L",t[0].x,t[0].y])),e}}getSelector(){return QH.lassoSelector}getPoints(){return this.points}createBrush(){const{graph:t,options:e}=this,{brushStyle:n}=e;return t.drawTransient("path",fB,{style:Object.assign({pointerEvents:"none"},n)})}},OrbitCanvas3D:class extends vB{constructor(t){const e=Object.assign({},EB,t);yB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid for track-canvas-3d behavior, "drag" will take effect instead. Only "${yB.join('", "')}" are available.`),e.trigger="drag"),super(e)}setTrackingCamera(){const{graph:t}=this,e=t.canvas.getCamera();this.previousType=e.type,t.canvas.getCamera().setType(Ur.ORBITING)}restoreCameraType(){if(void 0!==this.previousType){const{graph:t}=this;t.canvas.getCamera().setType(this.previousType)}}onPointerDown(t){this.setTrackingCamera(),super.onPointerDown(t)}onPointerUp(t){this.restoreCameraType(),super.onPointerUp(t)}onKeydown(t){const{trigger:e,secondaryKey:n}=this.options;"directionKeys"===e&&(!n||n&&this.keydown)&&this.setTrackingCamera(),super.onKeydown(t)}onKeyup(t){const{trigger:e,secondaryKey:n}=this.options;"directionKeys"===e&&(!n||n&&this.keydown)&&this.restoreCameraType(),super.onKeyup(t)}},RotateCanvas3D:vB,TrackCanvas3D:class extends vB{constructor(t){const e=Object.assign({},bB,t);_B.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid for track-canvas-3d behavior, "drag" will take effect instead. Only "${_B.join('", "')}" are available.`),e.trigger="drag"),super(e)}setTrackingCamera(){const{graph:t}=this,e=t.canvas.getCamera();this.previousType=e.type,t.canvas.getCamera().setType(Ur.TRACKING)}restoreCameraType(){if(void 0!==this.previousType){const{graph:t}=this;t.canvas.getCamera().setType(this.previousType)}}onPointerDown(t){this.setTrackingCamera(),super.onPointerDown(t)}onPointerUp(t){this.restoreCameraType(),super.onPointerUp(t)}onKeydown(t){const{trigger:e,secondaryKey:n}=this.options;"directionKeys"===e&&(!n||n&&this.keydown)&&this.setTrackingCamera(),super.onKeydown(t)}onKeyup(t){const{trigger:e,secondaryKey:n}=this.options;"directionKeys"===e&&(!n||n&&this.keydown)&&this.restoreCameraType(),super.onKeyup(t)}},ZoomCanvas3D:class extends WD{constructor(t){const e=Object.assign({},xB,t);SB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid for zoom-canvas-3d behavior, "wheel" will take effect instead. Only "${SB.join('", "')}" are available.`),e.trigger="wheel"),super(e),this.getEvents=()=>{const t=this.graph.canvas.getContextService().getDomElement();return t&&t.addEventListener&&t.addEventListener("wheel",(t=>{t.preventDefault()}),{passive:!1}),"wheel"===this.options.trigger?{wheel:this.onWheel,keydown:this.onKeydown,keyup:this.onKeyup}:{keydown:this.onKeydown,keyup:this.onKeyup}}}onWheel(t){const{graph:e,options:n}=this,{secondaryKey:r,triggerOnItems:i,eventName:o,minZoom:a,maxZoom:s,sensitivity:l=1,shouldBegin:c}=n;if(t.itemId&&!i)return;if(!c(t))return;if(r&&!this.keydown)return;const u=e.canvas.getCamera(),h=t.deltaY>0?1:-1,d=u.getDistance(),p=100*h*l/d*Math.sqrt(d),f=d+p,g=u.getAzimuth(),m=(g<90&&g>-90?1:-1)*(u.getDistanceVector()[2]<0?1:-1)>0;p>0&&m&&f>1/a*200||p<0&&!m&&f>200*s||(u.dolly(p),o&&e.emit(o,{zoom:u.getZoom()}))}onKeydown(t){const{key:e}=t,{trigger:n,secondaryKey:r}=this.options;"upDownKeys"===n&&("ArrowUp"===e&&this.onWheel({deltaY:-1}),"ArrowDown"===e&&this.onWheel({deltaY:1})),r===e.toLowerCase()&&(this.keydown=!0)}onKeyup(t){const{key:e}=t,{secondaryKey:n}=this.options;n===e.toLowerCase()&&(this.keydown=!1)}},CreateEdge:class extends WD{constructor(t){super(Object.assign({},PB,t)),this.isKeyDown=!1,this.addingEdge=null,this.dummyNode=null,this.getEvents=()=>{const{trigger:t,secondaryKey:e}=this.options,[n]=RB,r=t===n?{"node:click":this.handleCreateEdge,pointermove:this.updateEndPoint,"edge:click":this.cancelCreating,"canvas:click":this.cancelCreating,"combo:click":this.handleCreateEdge}:{"node:dragstart":this.handleCreateEdge,"combo:dragstart":this.handleCreateEdge,drag:this.updateEndPoint,drop:this.onDrop},i=e?{keydown:this.onKeyDown,keyup:this.onKeyUp}:{};return Object.assign(Object.assign({},r),i)},this.handleCreateEdge=t=>{if(this.options.secondaryKey&&!this.isKeyDown)return;if(this.options.shouldEnd(t))return;const{graph:e,options:n,addingEdge:r}=this,i=t.itemId,{edgeConfig:o,createVirtualEventName:a,createActualEventName:s}=n;if(r){const t=e.addData("edge",{id:qD(r.source,i),source:r.source,target:i,data:Object.assign(Object.assign({},o),{type:i===r.source?"loop-edge":o.type})});return s&&e.emit(s,{edge:t}),void this.cancelCreating()}this.dummyNode=e.addData("node",{id:CB,data:{x:t.canvas.x,y:t.canvas.y,keyShape:{opacity:0,interactive:!1},labelShape:{opacity:0},anchorPoints:[[.5,.5]]}}),this.addingEdge=e.addData("edge",{id:MB,source:i,target:CB,data:Object.assign({},o)}),a&&e.emit(a,{edge:this.addingEdge})},this.onDrop=t=>Oc(this,void 0,void 0,(function*(){const{addingEdge:e,options:n,graph:r}=this,{edgeConfig:i,secondaryKey:o,createActualEventName:a}=n;if(o&&!this.isKeyDown)return;if(!e)return;const s=(yield this.graph.canvas.document.elementsFromPoint(t.canvas.x,t.canvas.y)).map((t=>{var e,n;return null===(n=(e=t.parentNode).getAttribute)||void 0===n?void 0:n.call(e,"data-item-id")})).filter((t=>void 0!==t&&!1!==t)),l=s.find((t=>this.graph.getComboData(t)||this.graph.getNodeData(t)));if(!l)return void this.cancelCreating();const c=r.addData("edge",{id:qD(e.source,l),source:e.source,target:l,data:Object.assign(Object.assign({},i),{type:l===e.source?"loop-edge":i.type})});a&&r.emit(a,{edge:c}),this.cancelCreating()})),this.updateEndPoint=t=>{const{options:e,graph:n,addingEdge:r,isKeyDown:i}=this;if(e.secondaryKey&&!i)return;if(!r)return;const o=r.source,a=r.target;n.getItemById(o)?n.updatePosition("node",{id:a,data:{x:t.canvas.x,y:t.canvas.y}}):this.addingEdge=null},this.cancelCreating=()=>{this.addingEdge&&(this.graph.removeData("edge",MB),this.addingEdge=null),this.dummyNode&&(this.graph.removeData("node",CB),this.dummyNode=null),this.options.cancelCreateEventName&&this.graph.emit(this.options.cancelCreateEventName,{})},this.onKeyDown=t=>{const e=t.key;e&&e.toLocaleLowerCase()===this.options.secondaryKey&&(this.isKeyDown=!0)},this.onKeyUp=t=>{this.addingEdge&&this.cancelCreating(),this.isKeyDown=!1},this.validateOptions(t)}validateOptions(t){t.trigger&&!RB.includes(t.trigger)&&(TB({optionName:"create-edge.trigger",shouldBe:RB,now:t.trigger,scope:"behavior"}),this.options.trigger=PB.trigger),t.secondaryKey&&!AB.includes(t.secondaryKey)&&(TB({optionName:"create-edge.secondaryKey",shouldBe:AB,now:t.secondaryKey,scope:"behavior"}),this.options.secondaryKey=PB.secondaryKey)}},ShortcutsCall:class extends WD{constructor(t){super(Object.assign({},NB,t)),this.triggerKeydown=!1,this.getEvents=()=>({keyup:this.onKeyUp,keydown:this.onKeyDown}),t.trigger&&!wB.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for shortcuts-call behavior!`),this.options.trigger=NB.trigger),t.combinedKey===this.options.trigger&&(this.options.combinedKey=void 0)}onKeyDown(t){const e=t.key;if(!e)return;const{graph:n}=this,{trigger:r,combinedKey:i,functionName:o,functionParams:a}=this.options,s=r.toLowerCase(),l=e.toLowerCase();if(this.triggerKeydown||(l===s||"control"===l&&"ctrl"===s||"ctrl"===l&&"control"===s)&&(this.triggerKeydown=!0),!n[o])return console.warn(`G6: Invalid functionName option: "${o}" for shortcuts-call behavior!`),{};if(!this.triggerKeydown)return;if(!i)return void(a&&a.length?n[o](...a):n[o]());const c=i.toLowerCase();(l===c||"control"===l&&"ctrl"===c||"ctrl"===l&&"control"===c)&&(a&&a.length?n[o](...a):n[o]())}onKeyUp(t){const e=t.key;if(!e)return;const{trigger:n}=this.options,r=n.toLowerCase(),i=e.toLowerCase();(i===r||"control"===i&&"ctrl"===r||"ctrl"===i&&"control"===r)&&(this.triggerKeydown=!1)}},ScrollCanvas:class extends WD{constructor(t){super(Object.assign({},OB,t,{zoomKey:DB(t.zoomKey)})),this.optimized=!1,this.getEvents=()=>({wheel:this.onWheel})}onWheel(t){if(!this.allowDrag(t))return;const e=this.graph,{zoomKey:n,zoomRatio:r,enableOptimize:i}=this.options,o=Array.isArray(n)?[].concat(n):[n];o.includes("control")&&o.push("ctrl");const a=o.some((e=>t[`${e}Key`])),s=t.nativeEvent;if(a){const n=e.canvas.client2Viewport({x:t.client.x,y:t.client.y});let i=e.getZoom();s&&s.wheelDelta>0?i+=i*r:i-=i*r,e.zoomTo(i,{x:n.x,y:n.y})}else{const n=t.deltaX||t.movement.x,r=t.deltaY||t.movement.y,{dx:i,dy:o}=this.formatDisplacement(n,r);e.translate({dx:-i,dy:-o})}if(i){this.optimized||(this.hideShapes(),this.optimized=!0),clearTimeout(this.timeout),this.timeout=void 0;const t=window.setTimeout((()=>{this.showShapes(),this.optimized=!1}),100);this.timeout=t}}formatDisplacement(t,e){const{graph:n}=this,{scalableRange:r,direction:i}=this.options,[o,a]=n.getSize(),s=n.canvas.getRoot().getRenderBounds();let l,c=Number(r);"string"==typeof r&&(r.includes("px")&&(l=r.includes("px"),c=Number(r.replace("px",""))),r.includes("%")&&(c=Number(r.replace("%",""))/100));let u=c,h=c;l||(u=o*c,h=a*c);const d=n.getViewportByCanvas({x:s.min[0],y:s.min[1]}),p=n.getViewportByCanvas({x:s.max[0],y:s.max[1]}),f=d.x,g=d.y,m=p.x,v=p.y;return t>0?m<-u?t=0:m-t<-u&&(t=m+u):t<0&&(f>o+u?t=0:f-t>o+u&&(t=f-(o+u))),e>0?v<-h?e=0:v-e<-h&&(e=v+h):e<0&&(g>a+h?e=0:g-e>a+h&&(e=g-(a+h))),"x"===i?e=0:"y"===i&&(t=0),{dx:t,dy:e}}allowDrag(t){const{itemType:e}=t,{allowDragOnItem:n}=this.options,r="canvas"===e;if(Ke(n)&&!n&&!r)return!1;if(Me(n)){const{node:t,edge:r,combo:i}=n;if(!t&&"node"===e)return!1;if(!r&&"edge"===e)return!1;if(!i&&"combo"===e)return!1}return!0}hideShapes(){const{graph:t,options:e}=this,{tileBehavior:n,tileBehaviorSize:r=1e3}=t.getSpecification().optimize||{},{optimizeZoom:i}=e,o=this.options.enableOptimize||n;if(Ue(o)?t.getAllNodesData().length>o:o){const e=t.getZoom(),n=t.getAllEdgesData().map((t=>t.id)).filter((e=>t.getItemVisible(e)));t.hideItem(n,!0),e<i?this.hiddenEdgeIds.push(...n):this.hiddenEdgeIds=n;const o=t.getAllNodesData().map((t=>t.id)).filter((e=>t.getItemVisible(e)));let a;const s=Math.ceil(o.length/r),l=Array.from({length:s},((t,e)=>o.slice(e*r,e*r+r))),c=()=>{if(!l.length)return void cancelAnimationFrame(a);const e=l.shift();t.startHistoryBatch(),t.hideItem(e,!1,!0),t.stopHistoryBatch(),a=requestAnimationFrame(c)};a=requestAnimationFrame(c),e<i?this.hiddenNodeIds.push(...o):this.hiddenNodeIds=o}}showShapes(){const{graph:t,hiddenEdgeIds:e,hiddenNodeIds:n}=this,r=t.getZoom(),{optimizeZoom:i}=this.options;if(r<i)return;const{tileBehavior:o,tileBehaviorSize:a=1e3}=t.getSpecification().optimize||{},s=this.options.enableOptimize||o;if(!(Ue(s)?t.getAllNodesData().length>s:s))return void(this.hiddenEdgeIds=this.hiddenNodeIds=[]);let l;const c=[...n,...e],u=Math.ceil(c.length/a),h=Array.from({length:u},((t,e)=>c.slice(e*a,e*a+a))),d=()=>{h.length?(t.executeWithNoStack((()=>{t.showItem(h.shift(),!1)})),l=requestAnimationFrame(d)):cancelAnimationFrame(l)};l=requestAnimationFrame(d),this.hiddenEdgeIds=this.hiddenNodeIds=[]}}});const kB=(t,e,n,r)=>{const i=r[1]-r[0],o=n[1]-n[0],a=new Map;return t.forEach((t=>{a.set(t.id,(t.data[e]-n[0])*i/o+r[0])})),a},LB=t=>{if(t)return Ue(t)?[t,t]:Re(t)?t.length>2?[t[0],t[1]]:t:void 0};var FB,UB=Object.freeze({__proto__:null,MapNodeSize:(t,e={},n)=>{const{field:r,range:i=[8,40]}=e;if(!r)return t;const{nodes:o}=t,a=new Map;let s=-1/0,l=1/0;o.forEach((t=>{a.set(t.id,t),s<t.data[r]&&(s=t.data[r]),l>t.data[r]&&(l=t.data[r])}));return kB(o,r,[l,s],i).forEach(((t,e)=>{let n=t;isNaN(t)&&(n=i[0]);const r=a.get(e);r.data.keyShape=Object.assign(Object.assign({},r.data.keyShape),{r:n/2,width:n,height:n})})),t},TransformV4Data:(t,e={},n)=>{const{nodes:r=[],edges:i=[],combos:o=[]}=t,a=r.map((t=>{const{id:e,type:n,style:r,size:i,color:o,label:a,labelCfg:s={},icon:l,linkPoints:c}=t,u=Nc(t,["id","type","style","size","color","label","labelCfg","icon","linkPoints"]),h=[];if(c){const{top:t,bottom:e,left:n,right:r}=c,i=Nc(c,["top","bottom","left","right"]);Object.keys({top:t,bottom:e,left:n,right:r}).forEach((t=>{c[t]&&h.push(Object.assign({position:t},i))}))}const{style:d={}}=s,p=Nc(s,["style"]),{background:f}=d,g={id:e,data:Object.assign(Object.assign({},u),{labelShape:Object.assign(Object.assign({},d),p)})};n&&(g.data.type=n.includes("-node")?n:`${n}-node`),r&&(g.data.keyShape=r);const m=LB(i);return m&&(g.data.keyShape=Object.assign(Object.assign({},g.data.keyShape),{r:null==m?void 0:m[0],width:null==m?void 0:m[0],height:null==m?void 0:m[1]})),o&&(g.data.keyShape.fill=o),a&&(g.data.labelShape.text=a),(null==l?void 0:l.show)&&(g.data.icon=l),h.length&&(g.data.anchorShapes=h),f&&(g.data.labelBackgroundShape=f),g})),s=i.map((t=>{const{id:e=gn(),type:n,source:r,target:i,style:o,size:a,color:s,label:l,labelCfg:c={},icon:u,linkPoints:h}=t,d=Nc(t,["id","type","source","target","style","size","color","label","labelCfg","icon","linkPoints"]),{style:p={}}=c,f=Nc(c,["style"]),{background:g}=p,m={id:e,source:r,target:i,data:Object.assign(Object.assign({},d),{labelShape:Object.assign(Object.assign({},p),f)})};return n&&(m.data.type=n.includes("-edge")?n:`${n}-edge`),o&&(m.data.keyShape=o),a&&(m.data.keyShape=m.data.keyShape||{},m.data.keyShape.lineWidth=a),s&&(m.data.keyShape=m.data.keyShape||{},m.data.keyShape.stroke=s),l&&(m.data.labelShape.text=l),g&&(m.data.labelBackgroundShape=g),m})),l=o.map((t=>{const{id:e,type:n,style:r,size:i,color:o,label:a,labelCfg:s={},icon:l,linkPoints:c}=t,u=Nc(t,["id","type","style","size","color","label","labelCfg","icon","linkPoints"]),{style:h={}}=s,d=Nc(s,["style"]),{background:p}=h,f={id:e,data:Object.assign(Object.assign({},u),{labelShape:Object.assign(Object.assign({},h),d)})};n&&(f.data.type=n.includes("-combo")?n:`${n}-combo`),r&&(f.data.keyShape=r);const g=LB(i);return g&&(f.data.keyShape=Object.assign(Object.assign({},f.data.keyShape),{r:null==g?void 0:g[0],width:null==g?void 0:g[0],height:null==g?void 0:g[1]})),o&&(f.data.keyShape=f.data.keyShape||{},f.data.keyShape.fill=o),a&&(f.data.labelShape.text=a),p&&(f.data.labelBackgroundShape=p),f}));return{nodes:a||[],edges:s||[],combos:l||[]}},ValidateData:(t,e={},n)=>{const{nodes:r,edges:i,combos:o}=t,a=new Map,s=new Map,l=new Map,c=(t,e,n=!1)=>void 0===t.id?n?void(t.id=`${e}-${gn()}`):(console.error(`Unique global id is neccessary for graph items. The ${e} ${JSON.stringify(t)} without id will be ignored.`),!1):a.has(t.id)?(console.error(`Unique global id is neccessary for graph nodes/edges/combos. The ${e} ${JSON.stringify(t)} with id ${t.id} is duplicated.`),!1):(void 0===t.data&&(t.data={}),!0),u=null==o?void 0:o.map((t=>!!c(t,"combo")&&(a.set(t.id,!0),l.set(t.id,!0),t))).filter(Boolean);null==u||u.forEach((t=>{const{parentId:e}=t.data;void 0===e||l.has(e)||n&&n.hasNode(e)||(console.error(`The parentId of combo with id ${t.id} will be removed since it is not exist in combos.`),delete t.data.parentId)}));const h=null==r?void 0:r.map((t=>{if(!c(t,"node"))return!1;const{parentId:e}=t.data;return void 0===e||l.has(e)||n&&n.hasNode(e)||(console.error(`The parentId of node with id ${t.id} will be removed since it is not exist in combos.`),delete t.data.parentId),a.set(t.id,!0),s.set(t.id,!0),t})).filter(Boolean),d=null==i?void 0:i.map((t=>{const{id:e}=t;let{source:r,target:i}=t;if(!c(t,"edge",!0))return!1;if(null==n?void 0:n.hasEdge(e)){const t=null==n?void 0:n.getEdge(e);void 0===r&&(r=t.source),void 0===i&&(i=t.target)}return void 0===r?(console.error(`The edge with id ${e} will be ignored since its source is undefined.`),!1):void 0===i?(console.error(`The edge with id ${e} will be ignored since its target is undefined.`),!1):s.has(r)||l.has(r)||n&&n.hasNode(r)?s.has(i)||l.has(i)||n&&n.hasNode(i)?(a.set(e,!0),t):(console.error(`The edge with id ${e} will be ignored since its target ${i} is not existed in nodes and combos.`),!1):(console.error(`The edge with id ${e} will be ignored since its source ${r} is not existed in nodes and combos.`),!1)})).filter(Boolean);return{nodes:h||[],edges:d||[],combos:u||[]}}});!function(t){t.rightTop="rightTop",t.right="right",t.rightBottom="rightBottom",t.bottomRight="bottomRight",t.bottom="bottom",t.bottomLeft="bottomLeft",t.leftBottom="leftBottom",t.left="left",t.leftTop="leftTop",t.topLeft="topLeft",t.top="top",t.topRight="topRight"}(FB||(FB={}));const GB=(t,e,n=1,r=!1)=>{const i=r?n:1,o=(t.max[0]-t.min[0])*i;return WB(o,e)},VB=(t,e,n=1)=>{const r=LP(t[0],t[1])*n;return WB(r,e)},WB=(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},zB=t=>Boolean((null==t?void 0:t.fields)&&t.formatter),HB=t=>{if(!t)return;const{levels:e,animateCfg:n}=t;if(!e)return;const r=e.find((t=>t.primary));if(!r)return;const i=e.indexOf(r),o={};return e.forEach(((t,e)=>{o[e-i]=t.zoomRange})),{animateCfg:n,levels:o}},jB=(t,e)=>{let n=0;return Object.keys(t).forEach((r=>{const i=t[r];e>=i[0]&&e<i[1]&&(n=Number(r))})),n};class XB{constructor(t){this.scaleTransformCache="",this.zoomCache={hiddenShape:{},zoom:1,zoomLevel:0,balanceRatio:1,levelShapes:{},wordWrapWidth:32,animateConfig:RR.zoom,firstRender:!0},this.onZoom=(t,e,n={})=>{var r,i,o;if(this.lodStrategy){const{levels:a}=this.lodStrategy,{levelShapes:s,hiddenShape:l,animateConfig:c,firstRender:u=!0,zoomLevel:h}=this.zoomCache,d=jB(a,e),p=Object.keys(s).map(Number),f=Math.max(...p),g=Math.min(...p);if(d<h)if(u)for(let e=d+1;e<=f;e++)null===(r=s[String(e)])||void 0===r||r.forEach((e=>{t[e]&&!n[e]&&(t[e].hide(),l[e]=!0)}));else for(let e=d+1;e<=f;e++)null===(i=s[String(e)])||void 0===i||i.forEach((e=>NR(e,t[e],l,c)));else if(d>h)for(let e=d;e>=g;e--)null===(o=s[String(e)])||void 0===o||o.forEach((e=>{wR(e,t[e],this.mergedStyles[e]||this.mergedStyles[e.replace("Background","")],l,c)}));this.zoomCache.zoomLevel=d}this.balanceShapeSize(t,e),this.zoomCache.zoom=e};const{themeStyles:e,lodStrategy:n,enableBalanceShape:r,zoom:i}=t;e&&(this.themeStyles=e),this.lodStrategy=n,this.enableBalanceShape=r,this.boundsCache={},this.zoomCache.zoom=i,this.zoomCache.balanceRatio=1/i,this.zoomCache.animateConfig=Object.assign(Object.assign({},RR.zoom),null==n?void 0:n.animateCfg)}mergeStyles(t){this.mergedStyles=this.getMergedStyles(t)}getMergedStyles(t){var e;const{data:n}=t,r={};Object.keys(n).forEach((t=>{gR.includes(t)?"badgeShapes"===t?(r[t]={},Object.keys(n[t]).forEach((e=>{if(isNaN(Number(e)))return void(r[t][e]=n[t][e]);const{position:i}=n[t][e];r[`${i}BadgeShape`]=Object.assign(Object.assign({},n[t][e]),{tag:"badgeShape"})}))):"anchorShapes"===t?Object.keys(n[t]).forEach((e=>{r[`anchorShape${e}`]=Object.assign(Object.assign({},n[t][e]),{tag:"anchorShape"})})):r[t]=n[t]:t===mR&&Object.keys(n[t]).forEach((e=>r[e]=n[t][e]))}));const i=zR([this.themeStyles,this.defaultStyles,r]),o=null===(e=i.labelBackgroundShape)||void 0===e?void 0:e.padding;return o&&(i.labelBackgroundShape.padding=WR(o)),i}updateCache(t){["keyShape","labelShape"].concat(Object.keys(FB)).map((t=>`${t}BadgeShape`)).forEach((e=>{const n=t[e];(null==n?void 0:n.getAttribute(LR))&&("labelShape"===e?this.boundsCache[`${e}Geometry`]=n.getGeometryBounds():this.boundsCache[`${e}Local`]=n.getLocalBounds(),n.setAttribute(LR,!1))}));const e={};if(Object.keys(t).forEach((n=>{const{lod:r}=t[n].attributes;void 0!==r&&(e[r]=e[r]||[],e[r].push(n))})),this.zoomCache.levelShapes=e,t.labelShape){const{maxWidth:e="200%"}=this.mergedStyles.labelShape||{};this.zoomCache.wordWrapWidth=GB(t.keyShape.getLocalBounds(),e,1)}}afterDraw(t,e,n){return{}}drawLabelShape(t,e,n,r){const{labelShape:i}=this.mergedStyles;if(!i||!i.text||!t.data.labelShape)return;const{keyShape:o}=e,a=JR(o,this.mergedStyles.keyShape,o.getLocalBounds()),{position:s,offsetX:l,offsetY:c,offsetZ:u,maxWidth:h,angle:d}=i,p=Nc(i,["position","offsetX","offsetY","offsetZ","maxWidth","angle"]),f=GB(a,h,this.zoomCache.zoom,this.enableBalanceShape),g={x:a.center[0],y:a.max[1],z:a.center[2],textBaseline:"top",textAlign:"center",offsetX:0,offsetY:0,offsetZ:0,wordWrapWidth:f};switch(s){case"center":g.y=a.center[1],g.textBaseline="middle";break;case"top":g.y=a.min[1],g.textBaseline="bottom",g.offsetY=-2;break;case"left":g.x=a.min[0],g.y=a.center[1],g.textAlign="right",g.textBaseline="middle",g.offsetX=-4;break;case"right":g.x=a.max[0],g.y=a.center[1],g.textAlign="left",g.textBaseline="middle",g.offsetX=4;break;default:g.offsetY=2}const m=void 0===l?g.offsetX:l,v=void 0===c?g.offsetY:c,y=void 0===u?g.offsetZ:u;g.x+=m,g.y+=v,g.z+=y;const E=Object.assign(Object.assign(Object.assign(Object.assign({},this.defaultStyles.labelShape),g),{isBillboard:!0}),p);return d&&(E.transform=`rotate(${d}rad)`),this.upsertShape("text","labelShape",E,e,t)}drawLabelBackgroundShape(t,e,n,r){const{labelShape:i}=e;if(!i||!i.style.text||!t.data.labelShape)return;this.boundsCache.labelShapeGeometry&&!i.getAttribute(LR)||(this.boundsCache.labelShapeGeometry=i.getGeometryBounds(),i.setAttribute(LR,!1));const{labelShapeGeometry:o}=this.boundsCache,a=o.max[1]-o.min[1],s=Math.min(o.max[0]-o.min[0]+2,i.attributes.wordWrapWidth),l=this.mergedStyles.labelBackgroundShape,{padding:c}=l,u=Nc(l,["padding"]),h=Object.assign(Object.assign({fill:"#fff"},u),{x:i.attributes.x+o.min[0]-c[3],y:i.attributes.y+o.min[1]-c[0],width:s+c[1]+c[3],height:a+c[0]+c[2]}),d=this.upsertShape("rect","labelBackgroundShape",h,e,t);return this.balanceShapeSize(e,this.zoomCache.zoom),d}drawIconShape(t,e,n,r){const{iconShape:i}=this.mergedStyles,{width:o,height:a,fontSize:s,text:l,offsetX:c=0,offsetY:u=0}=i,h=o||s,d=a||s,p=l?"text":"image";return"image"===p?(i.x=-h/2+c,i.y=-d/2+u,i.width=h,i.height=d):(i.textAlign="center",i.textBaseline="middle",i.x=c,i.y=u,i.fontSize=h),this.upsertShape(p,"iconShape",i,e,t)}drawHaloShape(t,e,n,r){const{keyShape:i}=e,{haloShape:o,keyShape:a}=this.mergedStyles;if(!1===o.visible)return;const{nodeName:s,attributes:l}=i,{x:c,y:u,fill:h}=l;return this.upsertShape(s,"haloShape",Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},l),a),{x:c,y:u,stroke:h}),o),{batchKey:"halo"}),e,t)}drawAnchorShapes(t,e,n,r){const{anchorShapes:i,keyShape:o}=this.mergedStyles,a=Object.values(this.mergedStyles).filter((t=>"anchorShape"===t.tag));if(!a.length)return;this.boundsCache.keyShapeLocal=this.boundsCache.keyShapeLocal||e.keyShape.getLocalBounds();const s={},l=this.calculateAnchorPosition(o);return a.forEach(((n,r)=>{const{position:a,fill:c=o.fill}=n,u=Nc(n,["position","fill"]),[h,d]=this.getAnchorPosition(a,l),p=`anchorShape${r}`;s[p]=this.upsertShape("circle",p,Object.assign(Object.assign({cx:h,cy:d,fill:c},i),u),e,t)})),s}getAnchorPosition(t,e){const n=this.boundsCache.keyShapeLocal,r=n.max[0]-n.min[0],i=n.max[1]-n.min[1],o=[n.max[0]-n.center[0],n.min[1]-n.center[1]];return t instanceof Array?[r*(t[0]-.5),i*(t[1]-.5)]:"string"==typeof t?e[t=t.toLowerCase()]||e.default||o:e.default||o}calculateAnchorPosition(t){const e=t.x,n=t.y,r=t.r,i={};return i.top=[e,n-r],i.left=[e-r,n],i.right=i.default=[e+r,n],i.bottom=[e,n+r],i}drawBadgeShapes(t,e,n,r){const{badgeShapes:i,keyShape:o}=this.mergedStyles,a=Object.values(this.mergedStyles).filter((t=>"badgeShape"===t.tag));if(!a.length)return{};const s=JR(e.keyShape,o,e.keyShape.getLocalBounds()),l=Math.min(s.max[0]-s.min[0],s.max[1]-s.min[1]),c={};return a.forEach(((n,r)=>{const{position:o}=n,a=Nc(n,["position"]),u=`${o}BadgeShape`,h=Object.assign(Object.assign({},i),a),d=i.palette?i.palette[r%i.palette.length]:"#7E92B5",{text:p="",type:f,color:g=d,size:m=l/3,textColor:v,zIndex:y=2,offsetX:E=0,offsetY:_=0}=h,b=Nc(h,["text","type","color","size","textColor","zIndex","offsetX","offsetY"]),S=m,x={x:0,y:0};switch(o){case"rightTop":case"topRight":x.x=s.max[0]/2+E,x.y=.44*s.min[1]-S+_;break;case"right":x.x=s.max[0]/2+E,x.y=-S/2+_;break;case"rightBottom":case"bottomRight":x.x=s.max[0]/2+E,x.y=.44*s.max[1]+_;break;case"leftTop":case"topLeft":x.x=s.min[0]/2+E,x.y=.44*s.min[1]-S+_;break;case"left":x.x=s.min[0]/2+E,x.y=-S/2+_;break;case"leftBottom":case"bottomLeft":x.x=s.min[0]/2+E,x.y=.44*s.max[1]+_;break;case"top":x.x=E,x.y=.44*s.min[1]-S+_;break;default:x.x=E,x.y=.44*s.max[1]+_}const T=o.toLowerCase(),A=T.includes("left"),R=!A&&!T.includes("right"),M=S-3;let C=A?"right":"left",P=A?x.x-3:x.x+2;R&&(C="center",P=x.x),c[u]=this.upsertShape("text",u,Object.assign(Object.assign({text:p,fill:v,fontSize:M,x:P,y:x.y+S/2},b),{textAlign:C,textBaseline:"middle",zIndex:y+1}),e,t),this.boundsCache[`${u}Local`]=c[u].getLocalBounds();const w=this.boundsCache[`${u}Local`],N=`${o}BadgeBackgroundShape`,O=p.length<=1?S:Math.max(S,w.max[0]-w.min[0])+8;c[N]=this.upsertShape("rect",N,Object.assign({text:p,fill:g,height:S,width:O,radius:S/2,zIndex:y,x:w.center[0]-O/2,y:w.center[1]-S/2},b),e,t)})),c}drawOtherShapes(t,e,n,r){return{}}balanceShapeSize(t,e){if(!this.enableBalanceShape)return;const{keyShape:n,labelShape:r,labelBackgroundShape:i}=t,o=1/e||1;if(this.zoomCache.balanceRatio=o,!r||!r.isVisible())return;const{position:a="bottom"}=this.mergedStyles.labelShape,s=n.getLocalBounds();if(e<1)r.style.transformOrigin="bottom"===a?"0":"";else switch(a){case"bottom":r.style.transformOrigin="0 "+(s.max[1]-r.attributes.y);break;case"right":r.style.transformOrigin=s.max[0]-r.attributes.x+" 0";break;case"top":r.style.transformOrigin="0 "+(s.min[1]-r.attributes.y);break;case"left":r.style.transformOrigin=s.min[0]-r.attributes.x+" 0";break;default:r.style.transformOrigin=""}const l=(r.style.transform||"").replace(this.scaleTransformCache,""),c=`scale(${o}, ${o})`;if(r.style.transform=`${l} ${c}`,this.scaleTransformCache=c,r.style.wordWrapWidth=this.zoomCache.wordWrapWidth*e,!i||!i.isVisible())return;const[u,h,d,p]=this.mergedStyles.labelBackgroundShape.padding,f=h+p,{width:g,height:m,x:v,y:y}=i.attributes;switch(a){case"top":i.style.transformOrigin=`${p+(g-f)/2} ${e<1?m-d:s.min[1]-y}`;break;case"left":i.style.transformOrigin=`${e<1?g-h:s.min[0]-v} ${u+(m-u-d)/2}`;break;case"right":i.style.transformOrigin=`${e<1?p:s.max[0]-v} ${u+(m-u-d)/2}`;break;case"bottom":i.style.transformOrigin=`${p+(g-f)/2} ${e<1?u+(m-u-d)/2:s.max[1]-y}`;break;default:i.style.transformOrigin=`${p+(g-f)/2} ${u+(m-u-d)/2}`}const{labelShapeGeometry:E}=this.boundsCache,_=((E.max[0]-E.min[0])*o+f)/g;i.style.transform=`scale(${_}, ${o})`}upsertShape(t,e,n,r,i){return GR(t,e,n,r,i)}}var YB=Object.freeze({__proto__:null,CircleCombo:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:16,x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("circle","keyShape",this.mergedStyles.keyShape,e,t)}},RectCombo:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{x:0,y:0,width:32,height:32}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("rect","keyShape",this.mergedStyles.keyShape,e,t)}getMergedStyles(t){const e=super.getMergedStyles(t);return e.keyShape.x=e.keyShape.x-e.keyShape.width/2,e.keyShape.y=e.keyShape.y-e.keyShape.height/2,e}}});const KB={sphere:dg,cube:hg,plane:pg},qB=10,$B=(t,e,n,r)=>{if(!KB[t])return FR(t,e,n);const i=e,{materialType:o="lambert"}=i,a=Nc(i,["materialType"]);r.GeometryCache||(r.GeometryCache={});let s=r.GeometryCache[t];if(s||(s=r.GeometryCache[t]=new KB[t](r,{radius:qB,latitudeBands:32,longitudeBands:32})),r.MaterialCache||(r.MaterialCache={}),!r.MaterialCache[o])switch(o){case"basic":r.MaterialCache[o]=new yg(r);break;case"phong":{const t={shininess:30};r.MaterialCache[o]=new _g(r,t)}default:r.MaterialCache[o]=new Sg(r)}const l=new Vh({style:Object.assign(Object.assign({visibility:"visible",strokeOpacity:0},a),{geometry:s,material:r.MaterialCache[o]}),id:n});switch(l.setOrigin(0,0,0),t){case"cube":l.scale([e.width/qB,e.height/qB,e.depth/qB]);break;case"plane":l.scale([e.width/qB,e.depth/qB]);break;default:{const t=(e.r||e.radius)/qB;l.scale(t)}}return l};class ZB extends XB{constructor(t){super(t),this.dimensions=3,this.onZoom=(t,e)=>{},this.device=t.device}drawLabelShape(t,e,n,r){const{keyShape:i}=e,{r:o,width:a,height:s,depth:l,x:c,y:u,z:h}=i.attributes,d={center:[c,u,h],min:[c-o||a/2,u-o||s/2,h-o||l/2],max:[c+o||a/2,u+o||s/2,h+o||l/2]},{labelShape:p}=this.mergedStyles,{position:f,offsetX:g,offsetY:m,maxWidth:v}=p,y=Nc(p,["position","offsetX","offsetY","maxWidth"]),E={x:d.center[0],y:d.max[1],z:d.center[2],textBaseline:"top",textAlign:"center",offsetX:0,offsetY:0};switch(f){case"top":E.y=d.min[1],E.textBaseline="bottom",E.offsetY=-4;break;case"left":E.x=d.min[0],E.y=d.center[1],E.textAlign="right",E.textBaseline="middle",E.offsetX=-8;break;case"right":E.x=d.max[0],E.y=d.center[1],E.textAlign="left",E.textBaseline="middle",E.offsetX=8;break;default:E.offsetY=4}const _=void 0===g?E.offsetX:g,b=void 0===m?E.offsetY:m;E.x+=_,E.y+=b;const S=Object.assign(Object.assign(Object.assign(Object.assign({},this.defaultStyles.labelShape),E),{isBillboard:!0}),y);return this.upsertShape("text","labelShape",S,e)}drawIconShape(t,e,n,r){return super.drawIconShape(t,e,n,r)}drawHaloShape(t,e,n,r){const{keyShape:i}=e,{haloShape:o}=this.mergedStyles;if(!1===o.visible)return;const{nodeName:a,attributes:s}=i;return this.upsertShape(a,"haloShape",Object.assign(Object.assign(Object.assign({},s),{stroke:s.fill}),o),e)}drawAnchorShapes(t,e,n,r){return{}}drawBadgeShapes(t,e,n,r){return super.drawBadgeShapes(t,e,n,r)}drawOtherShapes(t,e,n,r){return{}}upsertShape(t,e,n,r){return((t,e,n,r,i)=>{let o=r[e];if(o)if(o.nodeName!==t)o.remove(),o=$B(t,n,e,i),o.setAttribute(LR,!0);else{const e={},r=o.attributes;Object.keys(n).forEach((t=>{r[t]!==n[t]&&(e[t]=n[t],o.style[t]=n[t])})),QR(t,e)&&o.setAttribute(LR,!0)}else o=$B(t,n,e,i),o.setAttribute(LR,!0);return r[e]=o,o})(t,e,n,r,this.device)}}const QB={horizontal:0,vertical:Math.PI/2};const JB=["#61DDAA","#65789B","#F6BD16","#7262FD","#78D3F8","#9661BC","#F6903D","#008685","#F08BB4"];const tk=(t,e)=>[t*Math.cos(e),-t*Math.sin(e)],ek=(t,e)=>{let n=0;const r=[];return Object.keys(t).forEach((i=>{const o=+t[i];isNaN(o)||(r.push({key:i,value:o,color:e[i]}),n+=o)})),{totalValue:n,configs:r}},nk=(t,e)=>{const n=t.attr("r"),r=e*n;return{lineWidth:n-r,arcR:(n+r)/2}};var rk=Object.freeze({__proto__:null,CircleNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:16,x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&this.drawLabelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&this.drawLabelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes&&this.drawAnchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&this.drawIconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes&&this.drawBadgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("circle","keyShape",this.mergedStyles.keyShape,e,t)}},SphereNode:class extends ZB{constructor(t){super(t),this.defaultStyles={keyShape:{r:5,latitudeBands:32,longitudeBands:32,x:0,y:0,z:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("sphere","keyShape",this.mergedStyles.keyShape,e)}},RectNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{x:0,y:0,width:32,height:32}}}drawKeyShape(t,e,n,r){return this.upsertShape("rect","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{x:this.mergedStyles.keyShape.x-this.mergedStyles.keyShape.width/2,y:this.mergedStyles.keyShape.y-this.mergedStyles.keyShape.height/2}),e,t)}calculateAnchorPosition(t){const e=t.x,n=t.y,r=t.height,i=t.width,o={};return o.top=[e,n-r/2],o.left=[e-i/2,n],o.right=o.default=[e+i/2,n],o.bottom=[e,n+r/2],o}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}},StarNode:class extends XB{constructor(t){super(t),this.defaultOuterR=20,this.defaultStyles={keyShape:{outerR:this.defaultOuterR,innerR:3*this.defaultOuterR/8,x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){const{keyShape:i}=this.mergedStyles,o=this.getStarPath(i.outerR,i.innerR);return this.upsertShape("path","keyShape",Object.assign(Object.assign({},i),{path:o}),e,t)}getStarPath(t,e){return[["M",0,-t],["L",e*Math.cos(3*Math.PI/10),-e*Math.sin(3*Math.PI/10)],["L",t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],["L",e*Math.cos(Math.PI/10),e*Math.sin(Math.PI/10)],["L",t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],["L",0,e],["L",-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],["L",-e*Math.cos(Math.PI/10),e*Math.sin(Math.PI/10)],["L",-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],["L",-e*Math.cos(3*Math.PI/10),-e*Math.sin(3*Math.PI/10)],"Z"]}calculateAnchorPosition(t){const e={},n=t.outerR,r=t.innerR;return e.top=[0,-n],e.left=[-n*Math.cos(Math.PI/10),-n*Math.sin(Math.PI/10)],e.leftbottom=[-n*Math.cos(3*Math.PI/10),n*Math.sin(3*Math.PI/10)],e.bottom=[0,r],e.rightbottom=[n*Math.cos(3*Math.PI/10),n*Math.sin(3*Math.PI/10)],e.right=e.default=[n*Math.cos(Math.PI/10),-n*Math.sin(Math.PI/10)],e}},HexagonNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:16,x:0,y:0,direction:"vertical"}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){const{keyShape:i}=this.mergedStyles;return this.upsertShape("polygon","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{points:this.getHexagonPoints(i.r,i.direction)}),e,t)}getHexagonPoints(t,e){const n=Math.PI/3,r=[];for(let i=0;i<6;i++){const o=i*n+QB[e],a=t*Math.cos(o),s=t*Math.sin(o);r.push([a,s])}return r}calculateAnchorPosition(t){const e="horizontal"===t.direction?["right","rightbottom","leftbottom","left","lefttop","righttop"]:["bottom","leftbottom","lefttop","top","righttop","rightbottom"],n=Math.PI/3,r=QB[t.direction],i=t.r,o={};for(let t=0;t<6;t++){const a=t*n+r,s=i*Math.cos(a),l=i*Math.sin(a);o[e[t]]=[s,l]}return o.hasOwnProperty("default")||(o.default=o[e[0]]),o}},TriangleNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:12,x:0,y:0,direction:"up"}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){const{keyShape:i}=this.mergedStyles;return this.upsertShape("path","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{path:this.getTrianglePath(i.r,i.direction)}),e,t)}getTrianglePath(t,e){const n=3*t/2,r=3*t/Math.sin(1/3*Math.PI)/2;let i;return i="down"===e?[["M",0,n],["L",r,-n],["L",-r,-n],["Z"]]:"left"===e?[["M",-n,0],["L",n,r],["L",n,-r],["Z"]]:"right"===e?[["M",n,0],["L",-n,r],["L",-n,-r],["Z"]]:[["M",0,-n],["L",r,n],["L",-r,n],["Z"]],i}drawIconShape(t,e,n,r){const{keyShape:i}=this.mergedStyles,{iconShape:o}=this.mergedStyles;let a=0,s=i.r/4;"right"===i.direction?(a=-i.r/4,s=0):"left"===i.direction?(a=i.r/4,s=0):"down"===i.direction&&(a=0,s=-i.r/4);const{width:l,height:c,fontSize:u,text:h,offsetX:d=0,offsetY:p=0}=o,f=l||u,g=c||u,m=h?"text":"image";return"image"===m?(o.x=-f/2+d+a,o.y=-g/2+p+s,o.width=f,o.height=g):(o.textAlign="center",o.textBaseline="middle",o.x=d+a,o.y=p+s,o.fontSize=f),this.upsertShape(m,"iconShape",o,e,t)}calculateAnchorPosition(t){const e=t.direction,n=t.r,r=3*n/2,i=3*n/Math.sin(1/3*Math.PI)/2,o={};return"down"===e?(o.bottom=[0,r],o.right=o.default=[i,-r],o.left=[-i,-r]):"left"===e?(o.top=[r,-i],o.bottom=[r,i],o.left=o.default=[-r,0]):"right"===e?(o.top=[-r,-i],o.bottom=[-r,i],o.right=o.default=[r,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]),o}},EllipseNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{rx:16,ry:12,x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("ellipse","keyShape",this.mergedStyles.keyShape,e,t)}calculateAnchorPosition(t){const e=t.x,n=t.y,r={};return r.top=[e,n-t.ry],r.left=[e-t.rx,n],r.right=r.default=[e+t.rx,n],r.bottom=[e,n+t.ry],r}},DonutNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:16,x:0,y:0},donutShapes:{innerSize:.6,attrs:{},colorMap:{},zIndex:1}},this.drawDonutSegment=(t,e,n,r,i,o)=>{const{arcR:a,beginAngle:s,config:l,index:c,lineWidth:u,zIndex:h,totalValue:d,drawWhole:p=!1}=t,f=`donutShape${c}`,g=l.value/d;if(g<.001)return{beginAngle:s,shouldEnd:!1};let m,v,y;const E=tk(a,s);if(p||g>.999)m=[a,1e-4],y=1;else{const t=g*Math.PI*2;v=s+t,m=tk(a,v),y=t>Math.PI?1:0}const _={path:[["M",E[0],E[1]],["A",a,a,0,y,0,m[0],m[1]]],stroke:l.color||JB[c%JB.length],lineWidth:u,zIndex:h};return e[f]=this.upsertShape("path",f,_,r,n),{beginAngle:v,shouldEnd:p||g>.999}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.donutShapes){const i=this.drawDonutShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawDonutShapes(t,e,n,r){const{donutShapes:{innerSize:i,attrs:o,colorMap:a,zIndex:s}}=this.mergedStyles,l=Object.keys(o).length;if(!l)return;const{configs:c,totalValue:u}=ek(o,a);if(!u)return;const{lineWidth:h,arcR:d}=nk(e.keyShape,i);let p=0;const f={};return Ce(c,((i,o)=>{const a=this.drawDonutSegment({arcR:d,beginAngle:p,config:i,index:o,lineWidth:h,zIndex:s,totalValue:u,drawWhole:1===l},f,t,e,n,r);a.shouldEnd||(p=a.beginAngle)})),f}drawKeyShape(t,e,n,r){return this.upsertShape("circle","keyShape",this.mergedStyles.keyShape,e,t)}},DiamondNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{size:[32,32],x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){const{keyShape:i}=this.mergedStyles;return this.upsertShape("path","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{path:this.getDiamondPath(i)}),e,t)}getDiamondPath(t){const e=t.size[0],n=t.size[1];return[["M",0,-n/2],["L",e/2,0],["L",0,n/2],["L",-e/2,0],["Z"]]}calculateAnchorPosition(t){const e={},n=t.size[0],r=t.size[1];return e.bottom=[0,r/2],e.left=[-n/2,0],e.right=e.default=[n/2,0],e.top=[0,-r/2],e}},ModelRectNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{x:0,y:0,width:185,height:70,stroke:"#C0DCEA",strokeWidth:"2",radius:2,fill:"white"}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),o}drawKeyShape(t,e,n,r){const{x:i,y:o,height:a,width:s}=this.mergedStyles.keyShape;return this.upsertShape("rect","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{x:i-s/2,y:o-a/2}),e,t)}calculateAnchorPosition(t){const e=t.x,n=t.y,r=t.height,i=t.width,o=e-i/2-(this.mergedStyles.preRect?5:0),a={};return a.top=[e,n-r/2],a.left=[o,n],a.right=a.default=[e+i/2,n],a.bottom=[e,n+r/2],a}drawLabelShape(t,e,n,r){const{labelShape:i,description:o,keyShape:a}=this.mergedStyles;if(!i)return;const{width:s,height:l,x:c,y:u}=a,{offsetX:h=0,offsetY:d=0}=i,p=!(!i||!o),f=p?Math.min(l,s)/5:Math.min(l,s)/6,g=p?this.logoX+this.logoWidth+s/20:0,m=p?0-l/7:0,v=s/2-(this.logoX+this.logoWidth+s/20)-2*f;return i.maxWidth=v,this.upsertShape("text","labelShape",Object.assign({wordWrap:!0,textOverflow:"ellipsis",textBaseline:"middle",textAlign:p?"left":"middle",x:g+h,y:m+d,maxLines:1,wordWrapWidth:v},i),e,t)}drawOtherShapes(t,e,n,r){const{logoIcon:i,preRect:o,stateIcon:a,description:s,label:l,keyShape:c}=this.mergedStyles;return Object.assign(Object.assign(Object.assign(Object.assign({},this.drawPreRectShape(o,c,t,e)),this.drawLogoIconShape(i,c,t,e)),this.drawDescriptionShape(s,c,t,e)),this.drawStateIcon(a,c,t,e))}drawPreRectShape(t,e,n,r){if(!t)return;const{x:i,y:o,height:a,width:s}=e,{width:l=5,fill:c="#5CAAF8"}=t;return{otherShapePreRect:this.upsertShape("rect","otherShapePreRect",{width:l,height:a,x:i-s/2-l,y:o-a/2,fill:c,radius:2},r,n)}}drawLogoIconShape(t,e,n,r){const{x:i,y:o,width:a,height:s}=e;if(!t)return this.logoWidth=16,this.logoHeight=16,this.logoX=i-a/2+a/10-this.logoWidth/2,void(this.logoY=o-this.logoHeight/2);const{width:l=16,height:c=16,fontSize:u,text:h,offsetX:d=0,offsetY:p=0}=t,f=this.logoWidth=l||u,g=this.logoHeight=l||u,m=h?"text":"image",v=this.logoX=i-a/2+d+a/10-l/2,y=this.logoY=h?p:o-c/2+p;h&&(t.textAlign="center",t.textBaseline="middle");const E={};return E.otherShapeLogoIcon=this.upsertShape(m,"otherShapeLogoIcon",Object.assign({width:f,height:g,x:v,y:y},t),r,n),E}drawDescriptionShape(t,e,n,r){if(!t)return;const{width:i,height:o}=e,{text:a,fontSize:s,offsetX:l=0,offsetY:c=0}=t,u=Math.min(o,i)/5,h=this.logoX+this.logoWidth+i/20,d=i/2-h-2*u,p=u/2;return{otherShapeDescription:this.upsertShape("text","otherShapeDescription",Object.assign({textBaseline:"middle",textAlign:"left",fontSize:p,x:h+l,y:0+o/6+c,wordWrap:!0,wordWrapWidth:d,maxLines:1,textOverflow:"ellipsis",fill:"#C2C2C2"},t),r,n)}}drawStateIcon(t,e,n,r){if(!t)return;const{x:i,y:o,width:a}=e,{width:s=16,height:l=16,fontSize:c,text:u,offsetX:h=0,offsetY:d=0}=t,p=s||c,f=s||c,g=u?"text":"image",m=i+a/2-a/10+h,v=u?d:o-(l||c)/2+d;return u&&(t.textAlign="center",t.textBaseline="middle"),{otherShapestateIcon:this.upsertShape(g,"otherShapestateIcon",Object.assign({width:p,height:f,x:m,y:v},t),r,n)}}},ImageNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{x:0,y:0,width:32,height:32}}}drawKeyShape(t,e,n,r){var i;const o=null===(i=this.mergedStyles.keyShape)||void 0===i?void 0:i.clipCfg;let a;if(o){const{type:t}=o,e=Nc(o,["type"]);a=new BR[t],a.attr(e)}const s=this.upsertShape("image","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{x:this.mergedStyles.keyShape.x,y:this.mergedStyles.keyShape.y,anchor:"0.5 0.5"}),e,t);return a&&(s.appendChild(a),s.attr("clipPath",a)),s}calculateAnchorPosition(t){const e=t.x,n=t.y,r=t.height,i=t.width,o={};return o.top=[e,n-r/2],o.left=[e-i/2,n],o.right=o.default=[e+i/2,n],o.bottom=[e,n+r/2],o}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawHaloShape(t,e,n,r){var i;const{keyShape:o}=e,{haloShape:a,keyShape:s}=this.mergedStyles;if(!1===(null==a?void 0:a.visible))return;const l=(null===(i=null==a?void 0:a.clipCfg)||void 0===i?void 0:i.type)||"rect",{attributes:c}=o,{x:u,y:h,fill:d}=c;return this.upsertShape(l,"haloShape",Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),s),{x:u,y:h,stroke:d}),a),{fill:"transparent",batchKey:"halo"}),e,t)}},CubeNode:class extends ZB{constructor(t){super(t),this.defaultStyles={keyShape:{latitudeBands:32,longitudeBands:32,width:10,height:10,depth:10,x:0,y:0,z:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("cube","keyShape",this.mergedStyles.keyShape,e)}},BaseNode:XB,BaseNode3D:ZB});const ik=(t,e,n)=>{switch(t){case"triangle":default:return`M 0,0 L ${e},-${n/2} L ${e},${n/2} Z`;case"circle":{const t=Math.max(e,n)/2;return`M 0, 0\n a ${t},${t} 0 1,0 ${2*t},0\n a ${t},${t} 0 1,0 ${2*-t},0`}case"diamond":return`M 0,0 \n L ${e/2},${-n/2} \n L ${e},0 \n L ${e/2},${n/2} Z`;case"vee":return`M 0,0 L ${e},-${n/2}\n L ${2*e/3},0 L ${e},${n/2} Z`;case"rect":return`M 0,${-n/2} \n L ${e},${-n/2} \n L ${e},${n/2} \n L 0,${n/2} Z`;case"triangle-rect":{const t=e/2,r=e/7,i=e-r;return`M 0,0 L ${t},-${n/2} L ${t},${n/2} Z\n M ${i}, -${n/2}\n L ${i+r} -${n/2}\n L ${i+r} ${n/2}\n L ${i} ${n/2}\n Z`}case"simple":return`M ${e},-${n/2} L 0,0 L ${e},${n/2}`}},ok={type:"triangle",width:10,height:10};class ak{constructor(t){this.defaultStyles={},this.zoomCache={hiddenShape:{},balanceRatio:1,zoom:1,zoomLevel:0,levelShapes:{},wordWrapWidth:50,animateConfig:RR.zoom,firstRender:!0},this.onZoom=(t,e,n={})=>{var r,i,o;if(this.balanceShapeSize(t,e),!this.lodStrategy)return;const{levels:a}=this.lodStrategy,{levelShapes:s,hiddenShape:l,animateConfig:c,firstRender:u=!0,zoomLevel:h}=this.zoomCache,d=jB(a,e),p=Object.keys(s).map(Number),f=Math.max(...p),g=Math.min(...p);if(d<h)if(u)for(let e=d+1;e<=f;e++)null===(r=s[String(e)])||void 0===r||r.forEach((e=>{var r;t[e]&&!n[e]&&(null===(r=t[e])||void 0===r||r.hide())}));else for(let e=d+1;e<=f;e++)null===(i=s[String(e)])||void 0===i||i.forEach((e=>NR(e,t[e],l,c)));else if(d>h)for(let e=d;e>=g;e--)null===(o=s[String(e)])||void 0===o||o.forEach((e=>{l[e]||wR(e,t[e],this.mergedStyles[e]||this.mergedStyles[e.replace("Background","")],l,c)}));this.zoomCache.zoom=e,this.zoomCache.zoomLevel=d,this.zoomCache.firstRender=!1};const{themeStyles:e,lodStrategy:n,zoom:r}=t;e&&(this.themeStyles=e),this.lodStrategy=n,this.boundsCache={},this.zoomCache.zoom=r,this.zoomCache.balanceRatio=1/r,this.zoomCache.animateConfig=Object.assign(Object.assign({},RR.zoom),null==n?void 0:n.animateCfg)}mergeStyles(t){this.mergedStyles=this.getMergedStyles(t)}getMergedStyles(t){var e;const{data:n}=t,r={};Object.keys(n).forEach((t=>{gR.includes(t)?r[t]=n[t]:t===mR&&Object.keys(n[t]).forEach((e=>r[e]=n[t][e]))}));const i=zR([this.themeStyles,this.defaultStyles,r]),o=null===(e=i.labelBackgroundShape)||void 0===e?void 0:e.padding;return o&&(i.labelBackgroundShape.padding=WR(o,vR)),i}updateCache(t){["labelShape","labelBackgroundShape"].forEach((e=>{const n=t[e];(null==n?void 0:n.getAttribute(LR))&&(this.boundsCache[`${e}Geometry`]=n.getGeometryBounds(),this.boundsCache[`${e}Transform`]=n.style.transform,n.setAttribute(LR,!1))}));const{zoom:e}=this.zoomCache,n={};Object.keys(t).forEach((e=>{const{lod:r}=t[e].attributes;void 0!==r&&(n[r]=n[r]||[],n[r].push(e))})),this.zoomCache.levelShapes=n;const{maxWidth:r="60%"}=this.mergedStyles.labelShape||{};this.zoomCache.wordWrapWidth=VB([this.sourcePoint,this.targetPoint],r,1),this.zoomCache.zoom=1,this.zoomCache.zoomLevel=0,1!==e&&this.onZoom(t,e)}afterDraw(t,e,n){return{}}drawLabelShape(t,e,n,r){const{keyShape:i}=e,{labelShape:o}=this.mergedStyles;if(!o||!o.text||!t.data.labelShape)return;const{position:a,offsetX:s,offsetY:l,autoRotate:c=!0,maxWidth:u}=o,h=Nc(o,["position","offsetX","offsetY","autoRotate","maxWidth"]),d={textAlign:"center",offsetX:0,offsetY:0,pointRatio:[.5,.501]};switch(Ue(a)&&(d.pointRatio=[a,a+.01]),a){case"start":d.pointRatio=[0,.01],d.textAlign="left",d.offsetX=4;break;case"end":d.pointRatio=[.99,1],d.textAlign="right",d.offsetX=-4}const p=i.getPoint(d.pointRatio[0]);let f={x:p.x,y:p.y},g=!1;if(c){const t=i.getPoint(d.pointRatio[1]);let e=Math.atan((p.y-t.y)/(p.x-t.x));isNaN(e)&&(e=0),g=t.x<p.x,g&&("start"===a?(d.textAlign="right",d.offsetX=-4):"end"===a&&(d.textAlign="left",d.offsetX=4));const n=void 0===s?d.offsetX:s,r=void 0===l?d.offsetY:l,o={x:p.x+n*Math.cos(e),y:p.y+n*Math.sin(e)};f={x:o.x+r*Math.cos(Math.PI-e),y:o.y+r*Math.sin(Math.PI-e),transform:`rotate(${e/Math.PI*180})`}}this.labelPosition=Object.assign(Object.assign({},f),{isRevert:g});const m=VB([this.sourcePoint,this.targetPoint],u,this.zoomCache.zoom);this.zoomCache.wordWrapWidth=m;const v=Object.assign(Object.assign(Object.assign(Object.assign({},this.defaultStyles.labelShape),{textAlign:d.textAlign,wordWrapWidth:m,isBillboard:!0}),f),h);return this.boundsCache.labelShapeTransform=v.transform,this.upsertShape("text","labelShape",v,e,t)}drawLabelBackgroundShape(t,e,n,r){const{labelShape:i}=e;if(!i||!i.style.text||!t.data.labelShape)return;const{labelBackgroundShape:o,labelShape:a}=this.mergedStyles,s=this.boundsCache.labelShapeGeometry||i.getGeometryBounds(),{x:l,y:c,transform:u,isRevert:h}=this.labelPosition,{padding:d}=o,p=Nc(o,["padding"]),{balanceRatio:f=1}=this.zoomCache,g=s.max[0]-s.min[0],m=s.max[1]-s.min[1],v=Object.assign(Object.assign({fill:"#fff"},p),{x:s.min[0]-d[3]+l,y:s.min[1]-d[0]/f+c,width:g+d[1]+d[3],height:m+(d[0]+d[2])/f,transform:u});return"start"===a.position?v.transformOrigin=h?`${v.width-d[1]} ${v.height/2}`:`${d[3]} ${v.height/2}`:"end"===a.position?v.transformOrigin=h?`${d[3]} ${v.height/2}`:`${v.width-d[1]} ${v.height/2}`:v.transformOrigin=`${g/2+d[3]} ${m/2+d[0]}`,this.upsertShape("rect","labelBackgroundShape",v,e,t)}drawIconShape(t,e,n,r){const{labelShape:i,labelBackgroundShape:o,keyShape:a}=e,{iconShape:s,labelShape:l}=this.mergedStyles,{width:c,height:u,fontSize:h,text:d,offsetX:p=0,offsetY:f=0}=s,g=c||h,m=u||h,v=d?"text":"image";if("text"===v?(s.textAlign="left",s.textBaseline="top",s.fontSize=g):(s.width=g,s.height=m),l){const t=o||i,e=this.boundsCache.labelBackgroundShapeGeometry||this.boundsCache.labelShapeGeometry||t.getGeometryBounds(),{min:n,max:r,halfExtents:a}=e,l=r[1]-n[1],c=r[0]-n[0],{x:u,y:h,transform:d}=t.attributes,{textAlign:v}=i.attributes;s.x=n[0]-g+4+u+p,s.y=n[1]+(l-m)/2+h+f,d&&(s.transform=d,s.transformOrigin="right"===v?`${c/2-g/2+4+a[0]-p} ${m/2-f}`:"left"===v?`${g+4-p} ${m/2-f}`:`${(g+c)/2-p} ${m/2-f}`)}else{const t=a.getPoint(.5);s.x=t.x+p,s.y=t.y+f}return this.upsertShape(v,"iconShape",s,e,t)}drawHaloShape(t,e,n,r){const{keyShape:i}=e,{haloShape:o}=this.mergedStyles;if(!1===o.visible)return;const{nodeName:a,attributes:s}=i;return this.upsertShape(a,"haloShape",Object.assign(Object.assign(Object.assign({},s),{stroke:s.stroke}),o),e,t)}drawOtherShapes(t,e,n,r){return{}}balanceShapeSize(t,e){const{labelShape:n,labelBackgroundShape:r}=t,i=1/e||1;this.zoomCache.balanceRatio=i;const{labelShape:o={}}=this.mergedStyles,{position:a="bottom"}=o;if(!n)return;n.style.transformOrigin="bottom"===a?"0":"";const s=this.boundsCache.labelShapeTransform;n.style.transform=`${s} scale(${i}, ${i})`;const l=this.zoomCache.wordWrapWidth*e;if(n.style.wordWrapWidth=l,!r)return;const c=this.boundsCache.labelBackgroundShapeTransform;r.style.transform=`${c} scale(${i}, ${i})`}setSourcePoint(t){this.sourcePoint=t}setTargetPoint(t){this.targetPoint=t}setNodeMap(t){this.nodeMap=t}upsertArrow(t,e,n,r,i){const o="marker"+("start"===t?"Start":"End");if(!e)return i[o]=null,void(i[`${o}Offset`]=0);const a=Ke(e)?Object.assign({},ok):e,{type:s="triangle",width:l=10,height:c=10,path:u,offset:h=0}=a,d=Nc(a,["type","width","height","path","offset"]);i[o]=this.upsertShape("path",`${o}Shape`,Object.assign(Object.assign(Object.assign({},n),{fill:"simple"===s?"":n.stroke,path:u||ik(s,l,c),anchor:"0.5 0.5",transformOrigin:"center"}),d),{},r),i[`${o}Offset`]=l/2+h}upsertShape(t,e,n,r,i){return GR(t,e,n,r,i)}}class sk extends ak{constructor(t){super(t),this.type="line-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}}}draw(t,e,n,r,i,o){const{data:a={}}=t;let s={keyShape:void 0};return s.keyShape=this.drawKeyShape(t,e,n,r,i),a.haloShape&&(s.haloShape=this.drawHaloShape(t,r,i)),a.labelShape&&(s.labelShape=this.drawLabelShape(t,r,i)),a.labelBackgroundShape&&(s.labelBackgroundShape=this.drawLabelBackgroundShape(t,r,i)),a.iconShape&&(s.iconShape=this.drawIconShape(t,r,i)),a.otherShapes&&(s=Object.assign(Object.assign({},s),this.drawOtherShapes(t,r,i))),s}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,{startArrow:s,endArrow:l}=a,c=Nc(a,["startArrow","endArrow"]),u=Object.assign(Object.assign({},c),{x1:e.x,y1:e.y,z1:e.z||0,x2:n.x,y2:n.y,z2:n.z||0,isBillboard:!0});return this.upsertArrow("start",s,c,t,u),this.upsertArrow("end",l,c,t,u),this.upsertShape("line","keyShape",u,r,t)}}const lk=(t,e,n=0,r=0)=>{const i={x:(1-n)*t.x+n*e.x,y:(1-n)*t.y+n*e.y};let o=[0,0];It(o,[e.x-t.x,e.y-t.y]),o&&(o[0]||o[1])||(o=[0,0]);const a=[-o[1]*r,o[0]*r];return i.x+=a[0],i.y+=a[1],i},ck=t=>{const e=[];return t.forEach((t=>{if("A"!==t[0])for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1]]);else{const n=t.length;e.push([t[n-2],t[n-1]])}})),e};const uk=t=>t.max[0]-t.min[0],hk=t=>t.max[1]-t.min[1],dk=t=>{const{x:e,y:n}=t,r=new Lr;return r.setMinMax([e,n,0],[e,n,0]),r},pk=(t,e)=>{const{max:[n,r],min:[i,o]}=t,a=new Lr;return(uk(t)||hk(t))&&a.setMinMax([i-e,o-e,0],[n+e,r+e,0]),a},fk=(t,e)=>{const n=Math.min(t.min[0],e.min[0]),r=Math.min(t.min[1],e.min[1]),i=Math.max(t.max[0],e.max[0]),o=Math.max(t.max[1],e.max[1]),a=new Lr;return a.setMinMax([n,r,0],[i,o,0]),a},gk=t=>[{x:t.min[0],y:t.min[1]},{x:t.max[0],y:t.min[1]},{x:t.max[0],y:t.max[1]},{x:t.min[0],y:t.max[1]}],mk=(t,e)=>{const{x:n,y:r}=t;return n<e.min[0]||n>e.max[0]||r<e.min[1]||r>e.max[1]},vk=(t,e,n)=>{const r=((t,e)=>{const n=Math.abs(t.x-e.center[0]),r=Math.abs(t.y-e.center[1]);return 0===n&&0===r?0:n/uk(e)>r/hk(e)})(e,t);if(0===r){let r=t.center[0],i=t.center[1];return n.y<e.y?i=t.min[1]:n.x>e.x?r=t.max[0]:n.x<e.x?r=t.min[0]:n.x===e.x&&(i=t.max[1]),{x:r,y:i}}return r?{x:e.x>t.center[0]?t.max[0]:t.min[0],y:e.y}:{x:e.x,y:e.y>t.center[1]?t.max[1]:t.min[1]}},yk=(t,e,n,r)=>{const i=n.x-t.x,o=n.y-t.y,a=r.x-t.x,s=r.y-t.y,l=n.x-e.x,c=n.y-e.y,u=r.x-e.x,h=r.y-e.y;return(i*s-o*a)*(l*h-c*u)<=0&&(i*c-o*l)*(a*h-s*u)<=0},Ek=(t,e,n)=>{if(uk(n)||hk(n)){const[r,i,o,a]=gk(n);return yk(t,e,r,i)||yk(t,e,r,a)||yk(t,e,i,o)||yk(t,e,o,a)}return!1},_k=(t,e)=>{let n=0,r=t[0],i=Sk(t[0],e);for(let o=0;o<t.length;o++){const a=t[o],s=Sk(a,e);s<i&&(r=a,i=s,n=o)}return{index:n,nearestPoint:r}},bk=(t,e)=>{const n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},Sk=(t,e)=>{const n=t.x-e.x,r=t.y-e.y,i=t.z-e.z;return isNaN(i)?Math.sqrt(n*n+r*r):Math.sqrt(n*n+r*r+i*i)},xk=(t,e)=>!(!t||!e)&&(t.x===e.x&&t.y===e.y&&t.z===e.z),Tk=(t,e)=>{const{x:n,y:r,r:i}=t,{x:o,y:a}=e,s=o-n,l=a-r;if(s*s+l*l<i*i)return null;const c=Math.atan(l/s);return{x:n+Math.abs(i*Math.cos(c))*Math.sign(s),y:r+Math.abs(i*Math.sin(c))*Math.sign(l)}},Ak=(t,e)=>{const{x:n,y:r,width:i,height:o}=t,a=[],s={x:n+i/2,y:r+o/2};a.push({x:n,y:r}),a.push({x:n+i,y:r}),a.push({x:n+i,y:r+o}),a.push({x:n,y:r+o}),a.push({x:n,y:r});let l=null;for(let t=1;t<a.length&&(l=Rk(a[t-1],a[t],s,e),!l);t++);return l},Rk=(t,e,n,r)=>{const i=n.x-t.x,o=n.y-t.y,a=e.x-t.x,s=e.y-t.y,l=r.x-n.x,c=r.y-n.y,u=a*c-s*l,h=1/u;if(u*u>1e-4*(a*a+s*s)*(l*l+c*c)){const e=(i*c-o*l)*h,n=(i*s-o*a)*h;return IR(e,0,1)&&IR(n,0,1)?{x:t.x+e*a,y:t.y+e*s}:null}return null},Mk=t=>{const e=[],n={};return Ce(t,(t=>{t.id=`${t.x}|||${t.y}`,n[t.id]||(n[t.id]=t,e.push(t))})),e},Ck=(t,e,n,r,i)=>Mk(Dk(t,e,i.offset,n,r)),Pk=(t,e,n,r,i)=>DR(t,e)+DR(t,n)+((t,e)=>{let n=0;return e.forEach((e=>{e&&(t.x===e.x&&(n+=-2),t.y===e.y&&(n+=-2))})),n})(t,[e,n,r,i]),wk=(t,e,n,r,i=0)=>{t.unshift(e[r]),n[r]&&n[r]!==r&&i<=100&&wk(t,e,n,n[r],i+1)},Nk=(t,e,n,r)=>{const i=[];return t.forEach((t=>{if(t!==e&&(t.x===e.x||t.y===e.y)){if(Ek(t,e,n)||Ek(t,e,r))return;i.push(t)}})),Mk(i)},Ok=(t,e,n)=>{const r=[],i=t[0];return r.push(`M ${i.x} ${i.y}`),Ce(t,((n,i)=>{const o=t[i+1],a=t[i+2];if(o&&a)if(((t,e,n)=>!(t.x===e.x&&e.x===n.x||t.y===e.y&&e.y===n.y))(n,o,a)&&e){const[t,i]=((t,e,n,r)=>{const i=DR(t,e),o=DR(n,e),a=Math.min(i,o)/2;return r=Math.min(r,a),[{x:e.x-r/i*(e.x-t.x),y:e.y-r/i*(e.y-t.y)},{x:e.x-r/o*(e.x-n.x),y:e.y-r/o*(e.y-n.y)}]})(n,o,a,e);r.push(`L ${t.x} ${t.y}`),r.push(`Q ${o.x} ${o.y} ${i.x} ${i.y}`),r.push(`L ${i.x} ${i.y}`)}else r.push(`L ${o.x} ${o.y}`);else o&&r.push(`L ${o.x} ${o.y}`)})),n&&r.push("Z"),r.join(" ")},Ik=(t,e,n,r)=>{if(!e||e.length<2)return"M 0 0 L 0 0";const i=Bk(e);return Ok(i,n,r)},Dk=(t,e,n,r,i)=>{let o,a;o=r&&r.getType()?null==r?void 0:r.getBBox():dk(t),a=i&&i.getType()?null==i?void 0:i.getBBox():dk(e);const s=pk(o,n),l=pk(a,n),c=vk(s,t,e),u=vk(l,e,t),h=((t=[])=>{const e=[],n=[];t.forEach((t=>{e.push(t.x),n.push(t.y)}));const r=Math.min(...e),i=Math.max(...e),o=Math.min(...n),a=Math.max(...n),s=new Lr;return s.setMinMax([r,o,0],[i,a,0]),s})([c,u]),d=fk(s,h),p=fk(l,h);let f=[];f=f.concat(gk(d)).concat(gk(p));const g={x:(t.x+e.x)/2,y:(t.y+e.y)/2};[h,d,p].forEach((t=>{f=f.concat(((t,e)=>((t,e)=>e<t.min[0]||e>t.max[0]?[]:[{x:e,y:t.min[1]},{x:e,y:t.max[1]}])(t,e.x).concat(((t,e)=>e<t.min[1]||e>t.max[1]?[]:[{x:t.min[0],y:e},{x:t.max[0],y:e}])(t,e.y)))(t,g).filter((t=>mk(t,s)&&mk(t,l))))})),[{x:c.x,y:u.y},{x:u.x,y:c.y}].forEach((t=>{mk(t,s)&&mk(t,l)&&f.push(t)})),f.unshift(c),f.push(u),f=Mk(f);const m=((t,e,n,r,i,o,a)=>{const s=[],l={[e.id]:e},c={},u={},h={};u[e.id]=0,h[e.id]=Pk(e,n,e);const d=new kk;d.add({id:e.id,value:h[e.id]});const p={};let f;for(t.forEach((t=>{p[t.id]=t}));Object.keys(l).length;){const g=d.minId(!1);if(!g)break;if(f=l[g],f.id===n.id){const t=[];return wk(t,p,c,n.id),t}delete l[f.id],d.remove(f.id),s.push(f),Nk(t,f,r,i).forEach((t=>{if(-1!==s.indexOf(t))return;const r=t.id;l[r]||(l[r]=t);const i=h[f.id]+DR(f,t);u[r]&&i>=u[r]||(c[r]=f.id,u[r]=i,h[r]=u[r]+Pk(t,n,e,o,a)),d.add({id:r,value:h[r]})}))}return[e,n]})(f,c,u,o,a,t,e);return m.unshift(t),m.push(e),Mk(m)},Bk=t=>{if(!(null==t?void 0:t.length))return t;const e=t[t.length-1],n={x:e.x,y:e.y};let r=[e],i=[e];for(let e=t.length-2;e>=0;e--){const o=t[e];if(o.x===n.x?r.push(o):(r=[o],n.x=o.x),o.y===n.y?i.push(o):(i=[o],n.y=o.y),r.length>2){const e=t.indexOf(r[1]);e>-1&&t.splice(e,1)}else if(i.length>2){const e=t.indexOf(i[1]);e>-1&&t.splice(e,1)}}return t};class kk{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){const n=[0,e-1];for(;n[1]-n[0]>1;){const e=Math.floor((n[0]+n[1])/2);if(this.arr[e].value>t.value)n[1]=e;else{if(!(this.arr[e].value<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n[0]=e}}this.arr.splice(n[1],0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;return e?this.arr[e-1].value<t.value?(this.arr.push(t),void(this.map[t.id]=!0)):void this._innerAdd(t,e):(this.arr.push(t),void(this.map[t.id]=!0))}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 Lk{constructor(t,e){this.boundary=t,this.edges=[],this.divided=!1,this.capacity=e}insert(t){var e,n,r,i;return!!this.boundary.intersects(t.bbox)&&(this.edges.length<this.capacity?(this.edges.push(t),!0):(this.divided||this.subdivide(),(null===(e=this.northeast)||void 0===e?void 0:e.insert(t))||(null===(n=this.northwest)||void 0===n?void 0:n.insert(t))||(null===(r=this.southeast)||void 0===r?void 0:r.insert(t))||(null===(i=this.southwest)||void 0===i?void 0:i.insert(t))||!1))}subdivide(){const t=this.boundary.center[0],e=this.boundary.center[1],n=this.boundary.halfExtents[0]/2,r=this.boundary.halfExtents[1]/2,i=new Lr;i.setMinMax([t-2*n,e-2*r,0],[t,e,0]),this.northwest=new Lk(i,this.capacity);const o=new Lr;o.setMinMax([t,e-2*r,0],[t+2*n,e,0]),this.northeast=new Lk(o,this.capacity);const a=new Lr;a.setMinMax([t-2*n,e,0],[t,e+2*r,0]),this.southwest=new Lk(a,this.capacity);const s=new Lr;s.setMinMax([t,e,0],[t+2*n,e+2*r,0]),this.southeast=new Lk(s,this.capacity),this.divided=!0}queryRange(t){var e,n,r,i;if(!t.intersects(this.boundary))return[];let o=this.edges.filter((e=>e.bbox.intersects(t)));return this.divided&&(o=o.concat((null===(e=this.northeast)||void 0===e?void 0:e.queryRange(t))||[],(null===(n=this.northwest)||void 0===n?void 0:n.queryRange(t))||[],(null===(r=this.southeast)||void 0===r?void 0:r.queryRange(t))||[],(null===(i=this.southwest)||void 0===i?void 0:i.queryRange(t))||[])),o}}class Fk{constructor(t){this.quadTree=t}getCollidingEdges(t){return this.quadTree.queryRange(t)}}const Uk={name:"orth",obstacleAvoidance:!1,offset:20,maxAllowedDirectionChange:Math.PI/2,maximumLoops:2e3,gridSize:10,directions:[{stepX:1,stepY:0},{stepX:-1,stepY:0},{stepX:0,stepY:1},{stepX:0,stepY:-1}],get penalties(){return{0:0,45:this.gridSize/2,90:this.gridSize/2}},distFunc:DR,fallbackRoute:Ck},Gk={name:"er",maxAllowedDirectionChange:Math.PI/4,directions:[{stepX:1,stepY:0},{stepX:1,stepY:1},{stepX:0,stepY:1},{stepX:-1,stepY:1},{stepX:-1,stepY:0},{stepX:-1,stepY:-1},{stepX:0,stepY:-1},{stepX:1,stepY:-1}],distFunc:(t,e)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),fallbackRoute:Ck},Vk=(t,e)=>{const n=Math.round(Math.abs(t/e));return n<0?0:(t<0?-1:1)*n},Wk=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n||r?Math.atan2(r,n):0},zk=(t,e)=>{const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n},Hk=(t,e,n)=>{let r=1/0;for(let i=0,o=e.length;i<o;i++){const o=n(t,e[i]);o<r&&(r=o)}return r},jk=(t,e,n,r,i)=>{const o=[];if(!n)return[t];const{directions:a,offset:s}=i,l=n.getBBox(),c=e.x>l.min[0]&&e.x<l.max[0]&&e.y>l.min[1]&&e.y<l.max[1],u=pk(l,s);for(const t in u)u[t]=hn(u[t],(t=>Vk(t,i.gridSize)));if(c){for(const e of a){const n=[[{x:u.min[0],y:u.min[1]},{x:u.max[0],y:u.min[1]}],[{x:u.min[0],y:u.min[1]},{x:u.min[0],y:u.max[1]}],[{x:u.max[0],y:u.min[1]},{x:u.max[0],y:u.max[1]}],[{x:u.min[0],y:u.max[1]},{x:u.max[0],y:u.max[1]}]];for(let r=0;r<4;r++){const i=n[r],a=$R(t,{x:t.x+e.stepX*uk(u),y:t.y+e.stepY*hk(u)},i[0],i[1]);a&&!Ek(t,a,l)&&(a.id=`${a.x}|||${a.y}`,o.push(a))}}return o}const h=vk(u,t,r);return h.id=`${h.x}|||${h.y}`,[h]},Xk=(t,e,n,r)=>{const i=Wk(t,e),o=n[t.id];if(!o){const e=Wk(r,t);return zk(e,i)}const a=Wk({x:o.x,y:o.y},t);return zk(a,i)},Yk=(t,e,n,r,i,o,a)=>{const s=[r];let l=r,c=t.id,u=t.x,h=t.y;const d={x:u,y:h,id:c};Xk(d,o,e,n)&&(l={x:o.x===r.x?r.x:d.x*a,y:o.y===r.y?r.y:d.y*a},s.unshift(l));let p=e[c];for(;p&&p.id!==c;){const t={x:u,y:h,id:c},r={x:p.x,y:p.y,id:p.id};Xk(r,t,e,n)&&(l={x:r.x===t.x?l.x:r.x*a,y:r.y===t.y?l.y:r.y*a},s.unshift(l)),c=r.id,u=r.x,h=r.y,p=e[c]}return s[0].x=u===n.x?i.x:l.x,s[0].y=h===n.y?i.y:l.y,s.unshift(i),s},Kk=(t,e,n,r,i)=>{const o=r.get(e),a=r.get(n),s=(null==o?void 0:o.getPosition())||t[0],l=(null==a?void 0:a.getPosition())||t[t.length-1];if(isNaN(s.x)||isNaN(l.x))return[];const c="orth"===i.name?Uk:an(Uk,Gk),u=an(c,i);if(!u.obstacleAvoidance)return u.fallbackRoute(s,l,o,a,u);const{penalties:h,gridSize:d}=u,p=((t,e,n)=>{const r={};return t.forEach((t=>{if(!t||!t.isVisible())return;const i=pk(t.getBBox(),n);for(let t=Vk(i.min[0],e);t<=Vk(i.max[0],e);t+=1)for(let n=Vk(i.min[1],e);n<=Vk(i.max[1],e);n+=1)r[`${t}|||${n}`]=!0})),r})(r,d,u.offset),f={x:Vk(s.x,d),y:Vk(s.y,d)},g={x:Vk(l.x,d),y:Vk(l.y,d)};s.id=`${f.x}|||${f.y}`,l.id=`${g.x}|||${g.y}`;const m=jk(f,s,o,g,u),v=jk(g,l,a,f,u);m.forEach((t=>{delete p[t.id]})),v.forEach((t=>{delete p[t.id]}));const y={},E={},_={},b={},S={},x=new kk;for(let t=0;t<m.length;t++){const e=m[t];y[e.id]=e,b[e.id]=0,S[e.id]=Hk(e,v,u.distFunc),x.add({id:e.id,value:S[e.id]})}let T,A,R,M,C,P,w=u.maximumLoops,N=1/0;const O={};for(v.forEach((t=>{O[`${t.x}|||${t.y}`]=!0})),Object.keys(y).forEach((t=>{const e=y[t].id;S[e]<=N&&(N=S[e],T=y[e])}));Object.keys(y).length>0&&w>0;){const t=x.minId((w+1)%30==0);if(!t)break;if(T=y[t],O[`${T.x}|||${T.y}`])return Yk(T,_,f,l,s,g,d);delete y[T.id],x.remove(T.id),E[T.id]=!0;for(let t=0;t<u.directions.length;t++){A=u.directions[t];const e=`${Math.round(T.x)+A.stepX}|||${Math.round(T.y)+A.stepY}`;if(R={x:T.x+A.stepX,y:T.y+A.stepY,id:e},E[e])continue;if(P=Xk(T,R,_,f),P>u.maxAllowedDirectionChange)continue;if(p[e])continue;y[e]||(y[e]=R);const n=h[P];M=u.distFunc(T,R)+(isNaN(n)?d:n),C=b[T.id]+M;const r=b[e];r&&C>=r||(_[e]=T,b[e]=C,S[e]=C+Hk(R,v,u.distFunc),x.add({id:e,value:S[e]}))}w-=1}return u.fallbackRoute(s,l,o,a,u)};var qk;!function(t){t.top="top",t["top-right"]="top-right",t.right="right",t["bottom-right"]="bottom-right",t.bottom="bottom",t["bottom-left"]="bottom-left",t.left="left",t["top-left"]="top-left"}(qk||(qk={}));const $k=Math.PI/8,Zk={[qk.top]:[-5*$k,-3*$k],[qk["top-right"]]:[-3*$k,-$k],[qk.right]:[-$k,$k],[qk["bottom-right"]]:[$k,3*$k],[qk.bottom]:[3*$k,5*$k],[qk["bottom-left"]]:[5*$k,7*$k],[qk.left]:[7*$k,9*$k],[qk["top-left"]]:[-7*$k,-5*$k]},Qk=(t,e,n)=>[t*Math.cos(n),e*Math.sin(n)],Jk=(t,e,n,r)=>{const[i,o]=Qk(t,e,n),[a,s]=Qk(t,e,r);return[i,o,a,s]};class tL extends ak{constructor(t){super(t),this.type="cubic-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}},this.getControlPoints=(t,e,n=.5,r,i=20)=>{if((null==r?void 0:r.length)>1)return r;return[this.getControlPoint(t,e,n,i),this.getControlPoint(t,e,n,-i)]},this.getControlPoint=(t,e,n=0,r=0)=>{const i={x:(1-n)*t.x+n*e.x,y:(1-n)*t.y+n*e.y};let o=[0,0];It(o,[e.x-t.x,e.y-t.y]),o&&(o[0]||o[1])||(o=[0,0]);const a=[-o[1]*r,o[0]*r];return i.x+=a[0],i.y+=a[1],i}}draw(t,e,n,r,i,o){const{data:a={}}=t,s={keyShape:void 0};return s.keyShape=this.drawKeyShape(t,e,n,r,i),a.haloShape&&(s.haloShape=this.drawHaloShape(t,r,i)),a.labelShape&&(s.labelShape=this.drawLabelShape(t,r,i)),a.labelBackgroundShape&&(s.labelBackgroundShape=this.drawLabelBackgroundShape(t,r,i)),a.iconShape&&(s.iconShape=this.drawIconShape(t,r,i)),s}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,{startArrow:s,endArrow:l}=a,c=Nc(a,["startArrow","endArrow"]),u=this.getControlPoints(e,n,a.curvePosition,a.controlPoints,a.curveOffset),h=Object.assign(Object.assign({},c),{path:[["M",e.x,e.y],["C",u[0].x,u[0].y,u[1].x,u[1].y,n.x,n.y]]});return this.upsertArrow("start",s,c,t,h),this.upsertArrow("end",l,c,t,h),this.upsertShape("path","keyShape",h,r,t)}}var eL=Object.freeze({__proto__:null,LineEdge:sk,QuadraticEdge:class extends ak{constructor(t){super(t),this.type="quadratic-edge",this.defaultStyles={keyShape:{controlPoints:[],curvePosition:.5,curveOffset:30,isBillboard:!0}},this.getControlPoints=(t,e,n=0,r,i)=>(null==r?void 0:r.length)?r:[lk(t,e,n,i)]}draw(t,e,n,r,i,o){const{data:a={}}=t,s={keyShape:void 0};return s.keyShape=this.drawKeyShape(t,e,n,r,i),a.haloShape&&(s.haloShape=this.drawHaloShape(t,r,i)),a.labelShape&&(s.labelShape=this.drawLabelShape(t,r,i)),a.labelBackgroundShape&&(s.labelBackgroundShape=this.drawLabelBackgroundShape(t,r,i)),a.iconShape&&(s.iconShape=this.drawIconShape(t,r,i)),s}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,{startArrow:s,endArrow:l}=a,c=Nc(a,["startArrow","endArrow"]),u=this.getControlPoints(e,n,a.curvePosition,a.controlPoints,a.curveOffset)[0],h=Object.assign(Object.assign({},c),{path:[["M",e.x,e.y],["Q",u.x,u.y,n.x,n.y]]});return this.upsertArrow("start",s,c,t,h),this.upsertArrow("end",l,c,t,h),this.upsertShape("path","keyShape",h,r,t)}},PolylineEdge:class extends sk{constructor(t){super(t),this.type="polyline-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}}}draw(t,e,n,r,i,o){const{data:a={}}=t,s={keyShape:void 0};return s.keyShape=this.drawKeyShape(t,e,n,r,i),a.haloShape&&(s.haloShape=this.drawHaloShape(t,r,i)),a.labelShape&&(s.labelShape=this.drawLabelShape(t,r,i)),a.labelBackgroundShape&&(s.labelBackgroundShape=this.drawLabelBackgroundShape(t,r,i)),a.iconShape&&(s.iconShape=this.drawIconShape(t,r,i)),s}getControlPoints(t,e,n){const{keyShape:r}=this.mergedStyles;return r.controlPoints}getPath(t,e,n,r,i){const{id:o,source:a,target:s}=t;if(!i&&"er"!==r.name)return Ik(0,e,n);const l=Kk(e,a,s,this.nodeMap,r);return Ik(0,l,n)}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,s=this.getControlPoints(t,e,n);let l=[e,n];s&&(l=[e,...s,n]);const c=function(t,e,n,r){return e&&Qe(t,e),n&&Qe(t,n),r&&Qe(t,r),t}({},{offset:a.offset,name:"orth"},a.routeCfg),u=this.getPath(t,l,a.radius,c,ln(s)),{startArrow:h,endArrow:d}=a,p=Nc(a,["startArrow","endArrow"]),f=Object.assign(Object.assign({},p),{path:u,isBillboard:!0});return this.upsertArrow("start",h,p,t,f),this.upsertArrow("end",d,p,t,f),this.upsertShape("path","keyShape",f,r,t)}},LoopEdge:class extends tL{constructor(t){super(t),this.type="loop-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0,loopCfg:{position:qk.top,clockwise:!0}}}}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,{startPoint:s,endPoint:l,controlPoints:c}=this.getPathPoints(t,e,n,a.loopCfg),{startArrow:u,endArrow:h}=a,d=Nc(a,["startArrow","endArrow"]),p=Object.assign(Object.assign({},a),{path:[["M",s.x,s.y],["C",c[0].x,c[0].y,c[1].x,c[1].y,l.x,l.y]]});return this.upsertArrow("start",u,d,t,p),this.upsertArrow("end",h,d,t,p),this.upsertShape("path","keyShape",p,r,t)}getPathPoints(t,e,n,r){const{source:i,target:o}=t;if(i!==o)throw new Error;const a=this.nodeMap.get(i),s=a.shapeMap.keyShape.nodeName,l=a.getKeyBBox(),c=uk(l),u=hk(l),h=u/2,d=c/2,p=l.center;let f=[e.x,e.y],g=[n.x,n.y];const m=r.position||qk.top;if(f[0]===g[0]&&f[1]===g[1]&&([f,g]="circle"===s||"ellipse"===s?((t,e,n,r)=>{var i,o;const[a,s,l,c]=Jk(n,r,(null===(i=Zk[t])||void 0===i?void 0:i[0])||-$k,(null===(o=Zk[t])||void 0===o?void 0:o[1])||$k);return[[e[0]+a,e[1]+s],[e[0]+l,e[1]+c]]})(m,p,d,h):((t,e,n,r,i)=>{const o=Math.min(r/2,n/2),a=Math.min(r,n),s=i?Math.min(a,i):o,l={[qk.top]:[[e[0]-s,e[1]-r],[e[0]+s,e[1]-r]],[qk["top-right"]]:[[e[0]+n-s,e[1]-r],[e[0]+n,e[1]-r+s]],[qk.right]:[[e[0]+n,e[1]-s],[e[0]+n,e[1]+s]],[qk["bottom-right"]]:[[e[0]+n,e[1]+r-s],[e[0]+n-s,e[1]+r]],[qk.bottom]:[[e[0]+s,e[1]+r],[e[0]-s,e[1]+r]],[qk["bottom-left"]]:[[e[0]-n+s,e[1]+r],[e[0]-n,e[1]+r-s]],[qk.left]:[[e[0]-n,e[1]+s],[e[0]-n,e[1]-s]],[qk["top-left"]]:[[e[0]-n,e[1]-r+s],[e[0]-n+s,e[1]-r]]};return l[t]||l[qk.top]})(m,p,d,h,r.pointPadding),!1===r.clockwise)){const t=f;f=g,g=t}const v=r.dist||2*Math.max(c,u),y=[f[0]-p[0],f[1]-p[1]],E=[g[0]-p[0],g[1]-p[1]],_=bk([0,0],y),b=bk([0,0],E),S=(b+v)/b,x=Ot([0,0],y,(_+v)/_),T=Ot([0,0],E,S),A=[{x:p[0]+x[0],y:p[1]+x[1]},{x:p[0]+T[0],y:p[1]+T[1]}];return{startPoint:{x:f[0],y:f[1]},endPoint:{x:g[0],y:g[1]},controlPoints:A}}},CubicHorizontalEdge:class extends tL{constructor(t){super(t),this.type="cubic-horizontal-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}},this.getControlPoints=(t,e,n=.5,r,i)=>{if((null==r?void 0:r.length)>1)return r;const o=(t.x-e.x)*n;return[this.getControlPoint(t,e,o),this.getControlPoint(e,t,-o)]},this.getControlPoint=(t,e,n=0)=>{if(e.y===t.y||e.x===t.x)return{x:(t.x+e.x)/2,y:t.y};return{x:t.x-n,y:t.y}}}},CubicVerticalEdge:class extends tL{constructor(t){super(t),this.type="cubic-vertical-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}},this.getControlPoints=(t,e,n=.5,r,i)=>{if((null==r?void 0:r.length)>1)return r;const o=(t.y-e.y)*n;return[this.getControlPoint(t,e,o),this.getControlPoint(e,t,-o)]},this.getControlPoint=(t,e,n=0)=>{if(e.y===t.y||e.x===t.x)return{x:t.x,y:(t.y+e.y)/2};return{x:t.x,y:t.y-n}}}},CubicEdge:tL});const nL="rgb(253, 253, 253)",rL="rgb(240, 240, 240)",iL="rgba(153,173,209,1)",oL={node:{palette:["#4089FF","#CD75FF","#06B8A8","#FF8834","#5888C3","#FA73CD","#07BCE0","#CB962A","#23AD61","#FF8075"],lodStrategy:{levels:[{zoomRange:[0,.65]},{zoomRange:[.65,.8]},{zoomRange:[.8,1.6],primary:!0},{zoomRange:[1.6,2]},{zoomRange:[2,1/0]}],animateCfg:{duration:200}},styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{r:16,fill:"rgb(34,126,255)",lineWidth:0,zIndex:0}),labelShape:Object.assign(Object.assign({},ER),{fill:"#000",position:"bottom",zIndex:2,lod:0,maxWidth:"200%",textOverflow:"ellipsis",wordWrap:!0,maxLines:1}),labelBackgroundShape:{padding:[2,4,2,4],lineWidth:0,fill:"#fff",opacity:.75,zIndex:1,lod:0},iconShape:Object.assign(Object.assign({},ER),{fill:"#fff",fontSize:16,zIndex:1,lod:-1}),anchorShapes:{lineWidth:1,stroke:"rgba(0, 0, 0, 0.65)",zIndex:2,r:3,lod:0},badgeShapes:{palette:["#7E92B5","#F86254","#EDB74B"],textColor:"#fff",zIndex:3,lod:-1},haloShape:{visible:!1,droppable:!1}},selected:{keyShape:{stroke:"#000",lineWidth:3},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,droppable:!1}},active:{keyShape:{lineWidth:0},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,droppable:!1}},highlight:{keyShape:{stroke:"rgba(0,0,0,0.85)",lineWidth:3},labelShape:{fontWeight:700},haloShape:{visible:!1,droppable:!1}},inactive:{keyShape:{opacity:.25},labelShape:{opacity:.25},iconShape:{opacity:.25},haloShape:{visible:!1,droppable:!1}},disable:{keyShape:{fill:rL,lineWidth:0},haloShape:{visible:!1,droppable:!1}}}]},edge:{palette:["#99ADD1","#4089FF","#CD75FF","#06B8A8","#FF8834","#5888C3","#FA73CD","#07BCE0","#CB962A","#23AD61","#FF8075"],lodStrategy:{levels:[{zoomRange:[0,.65]},{zoomRange:[.65,.8]},{zoomRange:[.8,1.6],primary:!0},{zoomRange:[1.6,2]},{zoomRange:[2,1/0]}],animateCfg:{duration:200}},styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{lineWidth:1,stroke:"rgb(153, 173, 209)",increasedLineWidthForHitTesting:2,zIndex:1}),labelShape:Object.assign(Object.assign({},ER),{fill:"rgba(0,0,0,0.85)",position:"middle",textBaseline:"middle",zIndex:3,textOverflow:"ellipsis",wordWrap:!0,maxLines:1,maxWidth:"60%",lod:0}),labelBackgroundShape:{padding:[4,4,4,4],lineWidth:0,fill:"#fff",opacity:.75,zIndex:2,lod:0},iconShape:Object.assign(Object.assign({},ER),{fill:"rgb(140, 140, 140)",fontSize:16,zIndex:2,offsetX:-10,lod:-1})},selected:{keyShape:{lineWidth:2},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},active:{keyShape:{lineWidth:1},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},highlight:{keyShape:{lineWidth:2},labelShape:{fontWeight:700}},inactive:{keyShape:{stroke:"rgb(210, 218, 233)",lineWidth:1}},disable:{keyShape:{stroke:"rgb(217, 217, 217)",lineWidth:1}}}]},combo:{styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{fill:nL,lineWidth:1,stroke:iL,r:5,width:20,height:10,padding:[25,20,15,20]}),labelShape:Object.assign(Object.assign({},ER),{fill:"#000",position:"bottom",zIndex:2,lod:0,maxLines:1}),labelBackgroundShape:{padding:[2,4,2,4],lineWidth:0,fill:"#fff",opacity:.75,zIndex:1,lod:0}},selected:{keyShape:{stroke:"rgba(27,50,79,1)",fill:nL,lineWidth:4},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,stroke:"rgba(153,173,209,1)",droppable:!1}},active:{keyShape:{stroke:iL,lineWidth:1},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,stroke:"rgba(153,173,209,1)",droppable:!1}},highlight:{keyShape:{stroke:iL,lineWidth:4},labelShape:{fontWeight:700}},inactive:{keyShape:{stroke:iL,fill:nL,lineWidth:1,opacity:.65},labelShape:{opacity:.65}},disable:{keyShape:{fill:rL,stroke:"rgba(153,173,209,1)",opacity:.25,lineWidth:1},labelShape:{opacity:.25}},collapsed:{keyShape:Object.assign(Object.assign({},yR),{fill:nL,lineWidth:1,stroke:iL,r:16,width:48,height:24,padding:[25,20,15,20]}),iconShape:Object.assign(Object.assign({},ER),{fill:iL,fontSize:12,zIndex:1,lod:-1,contentType:"childCount",visible:!0})}}]},canvas:{backgroundColor:"#fff"}},aL="rgba(255,255,255,0.85)",sL="rgb(253, 253, 253)",lL="rgba(153,173,209,1)",cL="#D0E4FF",uL="#637088",hL="#D0E4FF",dL={node:{palette:["#4089FF","#CD75FF","#06B8A8","#FF8834","#5888C3","#FA73CD","#07BCE0","#CB962A","#23AD61","#FF8075"],lodStrategy:{levels:[{zoomRange:[0,.65]},{zoomRange:[.65,.8]},{zoomRange:[.8,1.6],primary:!0},{zoomRange:[1.6,2]},{zoomRange:[2,1/0]}],animateCfg:{duration:200}},styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{r:16,fill:"rgb(34,126,255)",lineWidth:0,zIndex:0}),labelShape:Object.assign(Object.assign({},ER),{fill:aL,opacity:.85,position:"bottom",zIndex:2,lod:0,maxWidth:"200%",textOverflow:"ellipsis",wordWrap:!0,maxLines:1}),labelBackgroundShape:{padding:[2,4,2,4],lineWidth:0,fill:"#000",opacity:.75,zIndex:1,lod:0},iconShape:Object.assign(Object.assign({},ER),{fill:"#fff",fontSize:16,zIndex:1,lod:-1}),anchorShapes:{lineWidth:1,stroke:hL,fill:"#000",zIndex:2,r:3,lod:0},badgeShapes:{palette:["#7E92B5","#F86254","#EDB74B"],textColor:"#fff",zIndex:3,lod:-1},haloShape:{visible:!1,droppable:!1}},selected:{keyShape:{stroke:hL,lineWidth:3},labelShape:{fontWeight:700},haloShape:{opacity:.45,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},active:{keyShape:{lineWidth:0},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},highlight:{keyShape:{stroke:hL,lineWidth:3},labelShape:{fontWeight:700},haloShape:{visible:!1,droppable:!1}},inactive:{keyShape:{opacity:.45},labelShape:{opacity:.45},iconShape:{opacity:.45},haloShape:{visible:!1,droppable:!1}},disable:{keyShape:{fill:cL,lineWidth:0},haloShape:{visible:!1,droppable:!1}}}]},edge:{palette:["#637088","#2A59A6","#854CA6","#04786D","#A65822","#39587F","#A34B85","#057A92","#84621B","#17703F","#A6534C"],lodStrategy:{levels:[{zoomRange:[0,.65]},{zoomRange:[.65,.8]},{zoomRange:[.8,1.6],primary:!0},{zoomRange:[1.6,2]},{zoomRange:[2,1/0]}],animateCfg:{duration:200}},styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{lineWidth:1,stroke:uL,increasedLineWidthForHitTesting:2,zIndex:1}),labelShape:Object.assign(Object.assign({},ER),{fill:aL,opacity:.85,position:"middle",textBaseline:"middle",zIndex:3,textOverflow:"ellipsis",wordWrap:!0,maxLines:1,maxWidth:"60%",lod:0}),labelBackgroundShape:{padding:[4,4,4,4],lineWidth:0,fill:"#000",opacity:.75,zIndex:2,lod:0},iconShape:Object.assign(Object.assign({},ER),{fill:"rgb(140, 140, 140)",fontSize:16,zIndex:2,offsetX:-10,lod:-1})},selected:{keyShape:{lineWidth:2},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},active:{keyShape:{lineWidth:1},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},highlight:{keyShape:{lineWidth:2},labelShape:{fontWeight:700}},inactive:{keyShape:{stroke:uL,lineWidth:1,opacity:.45}},disable:{keyShape:{stroke:uL,opacity:.08,lineWidth:1}}}]},combo:{styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{fill:sL,lineWidth:1,stroke:uL,r:5,width:20,height:10,padding:[25,20,15,20]}),labelShape:Object.assign(Object.assign({},ER),{fill:aL,opacity:.85,position:"bottom",zIndex:2,lod:0,maxLines:1}),labelBackgroundShape:{padding:[2,4,2,4],lineWidth:0,fill:"#000",opacity:.75,zIndex:1,lod:0}},selected:{keyShape:{stroke:hL,fill:sL,lineWidth:2},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,stroke:lL,droppable:!1}},active:{keyShape:{stroke:hL,lineWidth:1},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,stroke:lL,droppable:!1}},highlight:{keyShape:{stroke:hL,fill:sL,lineWidth:2},labelShape:{fontWeight:700}},inactive:{keyShape:{stroke:uL,fill:sL,lineWidth:1},labelShape:{opacity:.65}},disable:{keyShape:{fill:cL,opacity:.25},iconShape:{fill:cL,opacity:.25},labelShape:{opacity:.25}},collapsed:{keyShape:Object.assign(Object.assign({},yR),{fill:sL,lineWidth:1,stroke:lL,r:16,width:48,height:24,padding:[25,20,15,20]}),iconShape:Object.assign(Object.assign({},ER),{fill:lL,fontSize:12,zIndex:1,lod:-1,contentType:"childCount",visible:!0})}}]},canvas:{backgroundColor:"#000"}};var pL=Object.freeze({__proto__:null,LightTheme:oL,DarkTheme:dL});class fL{constructor(t,e){this.getSpecification=()=>this.specification,this.specification=this.solver(t,e),this.options=t}destroy(){}}var gL={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]},mL=u((function(t){var e=Array.prototype.concat,n=Array.prototype.slice,r=t.exports=function(t){for(var r,i=[],o=0,a=t.length;o<a;o++){var s=t[o];(r=s)&&"string"!=typeof r&&(r instanceof Array||Array.isArray(r)||r.length>=0&&(r.splice instanceof Function||Object.getOwnPropertyDescriptor(r,r.length-1)&&"String"!==r.constructor.name))?i=e.call(i,n.call(s)):i.push(s)}return i};r.wrap=function(t){return function(){return t(r(arguments))}}})),vL=u((function(t){var e=Object.hasOwnProperty,n=Object.create(null);for(var r in gL)e.call(gL,r)&&(n[gL[r]]=r);var i=t.exports={to:{},get:{}};function o(t,e,n){return Math.min(Math.max(e,t),n)}function a(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}i.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=i.get.hsl(t),n="hsl";break;case"hwb":e=i.get.hwb(t),n="hwb";break;default:e=i.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},i.get.rgb=function(t){if(!t)return null;var n,r,i,a=[0,0,0,1];if(n=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(i=n[2],n=n[1],r=0;r<3;r++){var s=2*r;a[r]=parseInt(n.slice(s,s+2),16)}i&&(a[3]=parseInt(i,16)/255)}else if(n=t.match(/^#([a-f0-9]{3,4})$/i)){for(i=(n=n[1])[3],r=0;r<3;r++)a[r]=parseInt(n[r]+n[r],16);i&&(a[3]=parseInt(i+i,16)/255)}else if(n=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(r=0;r<3;r++)a[r]=parseInt(n[r+1],0);n[4]&&(n[5]?a[3]=.01*parseFloat(n[4]):a[3]=parseFloat(n[4]))}else{if(!(n=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(n=t.match(/^(\w+)$/))?"transparent"===n[1]?[0,0,0,0]:e.call(gL,n[1])?((a=gL[n[1]])[3]=1,a):null:null;for(r=0;r<3;r++)a[r]=Math.round(2.55*parseFloat(n[r+1]));n[4]&&(n[5]?a[3]=.01*parseFloat(n[4]):a[3]=parseFloat(n[4]))}for(r=0;r<3;r++)a[r]=o(a[r],0,255);return a[3]=o(a[3],0,1),a},i.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,o(parseFloat(e[2]),0,100),o(parseFloat(e[3]),0,100),o(isNaN(n)?1:n,0,1)]}return null},i.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,o(parseFloat(e[2]),0,100),o(parseFloat(e[3]),0,100),o(isNaN(n)?1:n,0,1)]}return null},i.to.hex=function(){var t=mL(arguments);return"#"+a(t[0])+a(t[1])+a(t[2])+(t[3]<1?a(Math.round(255*t[3])):"")},i.to.rgb=function(){var t=mL(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]+")"},i.to.rgb.percent=function(){var t=mL(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]+")"},i.to.hsl=function(){var t=mL(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},i.to.hwb=function(){var t=mL(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},i.to.keyword=function(t){return n[t.slice(0,3)]}}));const yL={};for(const t of Object.keys(gL))yL[gL[t]]=t;const EL={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};var _L=EL;for(const t of Object.keys(EL)){if(!("channels"in EL[t]))throw new Error("missing channels property: "+t);if(!("labels"in EL[t]))throw new Error("missing channel labels property: "+t);if(EL[t].labels.length!==EL[t].channels)throw new Error("channel and label counts mismatch: "+t);const{channels:e,labels:n}=EL[t];delete EL[t].channels,delete EL[t].labels,Object.defineProperty(EL[t],"channels",{value:e}),Object.defineProperty(EL[t],"labels",{value:n})}function bL(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}function SL(t){const e=function(){const t={},e=Object.keys(_L);for(let n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;){const t=n.pop(),r=Object.keys(_L[t]);for(let i=r.length,o=0;o<i;o++){const i=r[o],a=e[i];-1===a.distance&&(a.distance=e[t].distance+1,a.parent=t,n.unshift(i))}}return e}function xL(t,e){return function(n){return e(t(n))}}function TL(t,e){const n=[e[t].parent,t];let r=_L[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)n.unshift(e[i].parent),r=xL(_L[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}EL.rgb.hsl=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=o-i;let s,l;o===i?s=0:e===o?s=(n-r)/a:n===o?s=2+(r-e)/a:r===o&&(s=4+(e-n)/a),s=Math.min(60*s,360),s<0&&(s+=360);const c=(i+o)/2;return l=o===i?0:c<=.5?a/(o+i):a/(2-o-i),[s,100*l,100*c]},EL.rgb.hsv=function(t){let e,n,r,i,o;const a=t[0]/255,s=t[1]/255,l=t[2]/255,c=Math.max(a,s,l),u=c-Math.min(a,s,l),h=function(t){return(c-t)/6/u+.5};return 0===u?(i=0,o=0):(o=u/c,e=h(a),n=h(s),r=h(l),a===c?i=r-n:s===c?i=1/3+e-r:l===c&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*o,100*c]},EL.rgb.hwb=function(t){const e=t[0],n=t[1];let r=t[2];const i=EL.rgb.hsl(t)[0],o=1/255*Math.min(e,Math.min(n,r));return r=1-1/255*Math.max(e,Math.max(n,r)),[i,100*o,100*r]},EL.rgb.cmyk=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.min(1-e,1-n,1-r);return[100*((1-e-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*((1-r-i)/(1-i)||0),100*i]},EL.rgb.keyword=function(t){const e=yL[t];if(e)return e;let n,r=1/0;for(const e of Object.keys(gL)){const i=bL(t,gL[e]);i<r&&(r=i,n=e)}return n},EL.keyword.rgb=function(t){return gL[t]},EL.rgb.xyz=function(t){let e=t[0]/255,n=t[1]/255,r=t[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;return[100*(.4124*e+.3576*n+.1805*r),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},EL.rgb.lab=function(t){const e=EL.rgb.xyz(t);let n=e[0],r=e[1],i=e[2];n/=95.047,r/=100,i/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;return[116*r-16,500*(n-r),200*(r-i)]},EL.hsl.rgb=function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100;let i,o,a;if(0===n)return a=255*r,[a,a,a];i=r<.5?r*(1+n):r+n-r*n;const s=2*r-i,l=[0,0,0];for(let t=0;t<3;t++)o=e+1/3*-(t-1),o<0&&o++,o>1&&o--,a=6*o<1?s+6*(i-s)*o:2*o<1?i:3*o<2?s+(i-s)*(2/3-o)*6:s,l[t]=255*a;return l},EL.hsl.hsv=function(t){const e=t[0];let n=t[1]/100,r=t[2]/100,i=n;const o=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=o<=1?o:2-o;return[e,100*(0===r?2*i/(o+i):2*n/(r+n)),100*((r+n)/2)]},EL.hsv.rgb=function(t){const e=t[0]/60,n=t[1]/100;let r=t[2]/100;const i=Math.floor(e)%6,o=e-Math.floor(e),a=255*r*(1-n),s=255*r*(1-n*o),l=255*r*(1-n*(1-o));switch(r*=255,i){case 0:return[r,l,a];case 1:return[s,r,a];case 2:return[a,r,l];case 3:return[a,s,r];case 4:return[l,a,r];case 5:return[r,a,s]}},EL.hsv.hsl=function(t){const e=t[0],n=t[1]/100,r=t[2]/100,i=Math.max(r,.01);let o,a;a=(2-n)*r;const s=(2-n)*i;return o=n*i,o/=s<=1?s:2-s,o=o||0,a/=2,[e,100*o,100*a]},EL.hwb.rgb=function(t){const e=t[0]/360;let n=t[1]/100,r=t[2]/100;const i=n+r;let o;i>1&&(n/=i,r/=i);const a=Math.floor(6*e),s=1-r;o=6*e-a,0!=(1&a)&&(o=1-o);const l=n+o*(s-n);let c,u,h;switch(a){default:case 6:case 0:c=s,u=l,h=n;break;case 1:c=l,u=s,h=n;break;case 2:c=n,u=s,h=l;break;case 3:c=n,u=l,h=s;break;case 4:c=l,u=n,h=s;break;case 5:c=s,u=n,h=l}return[255*c,255*u,255*h]},EL.cmyk.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},EL.xyz.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100;let i,o,a;return i=3.2406*e+-1.5372*n+-.4986*r,o=-.9689*e+1.8758*n+.0415*r,a=.0557*e+-.204*n+1.057*r,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[255*i,255*o,255*a]},EL.xyz.lab=function(t){let e=t[0],n=t[1],r=t[2];e/=95.047,n/=100,r/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;return[116*n-16,500*(e-n),200*(n-r)]},EL.lab.xyz=function(t){let e,n,r;n=(t[0]+16)/116,e=t[1]/500+n,r=n-t[2]/200;const i=n**3,o=e**3,a=r**3;return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,e*=95.047,n*=100,r*=108.883,[e,n,r]},EL.lab.lch=function(t){const e=t[0],n=t[1],r=t[2];let i;i=360*Math.atan2(r,n)/2/Math.PI,i<0&&(i+=360);return[e,Math.sqrt(n*n+r*r),i]},EL.lch.lab=function(t){const e=t[0],n=t[1],r=t[2]/360*2*Math.PI;return[e,n*Math.cos(r),n*Math.sin(r)]},EL.rgb.ansi16=function(t,e=null){const[n,r,i]=t;let o=null===e?EL.rgb.hsv(t)[2]:e;if(o=Math.round(o/50),0===o)return 30;let a=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===o&&(a+=60),a},EL.hsv.ansi16=function(t){return EL.rgb.ansi16(EL.hsv.rgb(t),t[2])},EL.rgb.ansi256=function(t){const e=t[0],n=t[1],r=t[2];if(e===n&&n===r)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;return 16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},EL.ansi16.rgb=function(t){let e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];const n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},EL.ansi256.rgb=function(t){if(t>=232){const e=10*(t-232)+8;return[e,e,e]}let e;t-=16;return[Math.floor(t/36)/5*255,Math.floor((e=t%36)/6)/5*255,e%6/5*255]},EL.rgb.hex=function(t){const e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},EL.hex.rgb=function(t){const e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let n=e[0];3===e[0].length&&(n=n.split("").map((t=>t+t)).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},EL.rgb.hcg=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.max(Math.max(e,n),r),o=Math.min(Math.min(e,n),r),a=i-o;let s,l;return s=a<1?o/(1-a):0,l=a<=0?0:i===e?(n-r)/a%6:i===n?2+(r-e)/a:4+(e-n)/a,l/=6,l%=1,[360*l,100*a,100*s]},EL.hsl.hcg=function(t){const e=t[1]/100,n=t[2]/100,r=n<.5?2*e*n:2*e*(1-n);let i=0;return r<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},EL.hsv.hcg=function(t){const e=t[1]/100,n=t[2]/100,r=e*n;let i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},EL.hcg.rgb=function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];const i=[0,0,0],o=e%1*6,a=o%1,s=1-a;let l=0;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return l=(1-n)*r,[255*(n*i[0]+l),255*(n*i[1]+l),255*(n*i[2]+l)]},EL.hcg.hsv=function(t){const e=t[1]/100,n=e+t[2]/100*(1-e);let r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},EL.hcg.hsl=function(t){const e=t[1]/100,n=t[2]/100*(1-e)+.5*e;let r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},EL.hcg.hwb=function(t){const e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},EL.hwb.hcg=function(t){const e=t[1]/100,n=1-t[2]/100,r=n-e;let i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},EL.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},EL.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},EL.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},EL.gray.hsl=function(t){return[0,0,t[0]]},EL.gray.hsv=EL.gray.hsl,EL.gray.hwb=function(t){return[0,100,t[0]]},EL.gray.cmyk=function(t){return[0,0,0,t[0]]},EL.gray.lab=function(t){return[t[0],0,0]},EL.gray.hex=function(t){const e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},EL.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};const AL={};Object.keys(_L).forEach((t=>{AL[t]={},Object.defineProperty(AL[t],"channels",{value:_L[t].channels}),Object.defineProperty(AL[t],"labels",{value:_L[t].labels});const e=function(t){const e=SL(t),n={},r=Object.keys(e);for(let t=r.length,i=0;i<t;i++){const t=r[i];null!==e[t].parent&&(n[t]=TL(t,e))}return n}(t);Object.keys(e).forEach((n=>{const r=e[n];AL[t][n]=function(t){const e=function(...e){const n=e[0];if(null==n)return n;n.length>1&&(e=n);const r=t(e);if("object"==typeof r)for(let t=r.length,e=0;e<t;e++)r[e]=Math.round(r[e]);return r};return"conversion"in t&&(e.conversion=t.conversion),e}(r),AL[t][n].raw=function(t){const e=function(...e){const n=e[0];return null==n?n:(n.length>1&&(e=n),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var RL=AL;const ML=["keyword","gray","hex"],CL={};for(const t of Object.keys(RL))CL[[...RL[t].labels].sort().join("")]=t;const PL={};function wL(t,e){if(!(this instanceof wL))return new wL(t,e);if(e&&e in ML&&(e=null),e&&!(e in RL))throw new Error("Unknown model: "+e);let n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof wL)this.model=t.model,this.color=[...t.color],this.valpha=t.valpha;else if("string"==typeof t){const e=vL.get(t);if(null===e)throw new Error("Unable to parse color from string: "+t);this.model=e.model,r=RL[this.model].channels,this.color=e.value.slice(0,r),this.valpha="number"==typeof e.value[r]?e.value[r]:1}else if(t.length>0){this.model=e||"rgb",r=RL[this.model].channels;const n=Array.prototype.slice.call(t,0,r);this.color=DL(n,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;const e=Object.keys(t);"alpha"in t&&(e.splice(e.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);const r=e.sort().join("");if(!(r in CL))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=CL[r];const{labels:i}=RL[this.model],o=[];for(n=0;n<i.length;n++)o.push(t[i[n]]);this.color=DL(o)}if(PL[this.model])for(r=RL[this.model].channels,n=0;n<r;n++){const t=PL[this.model][n];t&&(this.color[n]=t(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}wL.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(t){let e=this.model in vL.to?this:this.rgb();e=e.round("number"==typeof t?t:1);const n=1===e.valpha?e.color:[...e.color,this.valpha];return vL.to[e.model](n)},percentString(t){const e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:[...e.color,this.valpha];return vL.to.rgb.percent(n)},array(){return 1===this.valpha?[...this.color]:[...this.color,this.valpha]},object(){const t={},{channels:e}=RL[this.model],{labels:n}=RL[this.model];for(let r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray(){const t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject(){const t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round(t){return t=Math.max(t||0,0),new wL([...this.color.map(NL(t)),this.valpha],this.model)},alpha(t){return void 0!==t?new wL([...this.color,Math.max(0,Math.min(1,t))],this.model):this.valpha},red:OL("rgb",0,IL(255)),green:OL("rgb",1,IL(255)),blue:OL("rgb",2,IL(255)),hue:OL(["hsl","hsv","hsl","hwb","hcg"],0,(t=>(t%360+360)%360)),saturationl:OL("hsl",1,IL(100)),lightness:OL("hsl",2,IL(100)),saturationv:OL("hsv",1,IL(100)),value:OL("hsv",2,IL(100)),chroma:OL("hcg",1,IL(100)),gray:OL("hcg",2,IL(100)),white:OL("hwb",1,IL(100)),wblack:OL("hwb",2,IL(100)),cyan:OL("cmyk",0,IL(100)),magenta:OL("cmyk",1,IL(100)),yellow:OL("cmyk",2,IL(100)),black:OL("cmyk",3,IL(100)),x:OL("xyz",0,IL(95.047)),y:OL("xyz",1,IL(100)),z:OL("xyz",2,IL(108.833)),l:OL("lab",0,IL(100)),a:OL("lab",1),b:OL("lab",2),keyword(t){return void 0!==t?new wL(t):RL[this.model].keyword(this.color)},hex(t){return void 0!==t?new wL(t):vL.to.hex(this.rgb().round().color)},hexa(t){if(void 0!==t)return new wL(t);const e=this.rgb().round().color;let n=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===n.length&&(n="0"+n),vL.to.hex(e)+n},rgbNumber(){const t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity(){const t=this.rgb().color,e=[];for(const[n,r]of t.entries()){const t=r/255;e[n]=t<=.04045?t/12.92:((t+.055)/1.055)**2.4}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast(t){const e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level(t){const e=this.contrast(t);return e>=7?"AAA":e>=4.5?"AA":""},isDark(){const t=this.rgb().color;return(2126*t[0]+7152*t[1]+722*t[2])/1e4<128},isLight(){return!this.isDark()},negate(){const t=this.rgb();for(let e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten(t){const e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken(t){const e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate(t){const e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate(t){const e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten(t){const e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken(t){const e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale(){const t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return wL.rgb(e,e,e)},fade(t){return this.alpha(this.valpha-this.valpha*t)},opaquer(t){return this.alpha(this.valpha+this.valpha*t)},rotate(t){const e=this.hsl();let n=e.color[0];return n=(n+t)%360,n=n<0?360+n:n,e.color[0]=n,e},mix(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);const n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,o=2*i-1,a=n.alpha()-r.alpha(),s=((o*a==-1?o:(o+a)/(1+o*a))+1)/2,l=1-s;return wL.rgb(s*n.red()+l*r.red(),s*n.green()+l*r.green(),s*n.blue()+l*r.blue(),n.alpha()*i+r.alpha()*(1-i))}};for(const t of Object.keys(RL)){if(ML.includes(t))continue;const{channels:e}=RL[t];wL.prototype[t]=function(...e){return this.model===t?new wL(this):e.length>0?new wL(e,t):new wL([...(n=RL[this.model][t].raw(this.color),Array.isArray(n)?n:[n]),this.valpha],t);var n},wL[t]=function(...n){let r=n[0];return"number"==typeof r&&(r=DL(n,e)),new wL(r,t)}}function NL(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}function OL(t,e,n){t=Array.isArray(t)?t:[t];for(const r of t)(PL[r]||(PL[r]=[]))[e]=n;return t=t[0],function(r){let i;return void 0!==r?(n&&(r=n(r)),i=this[t](),i.color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function IL(t){return function(e){return Math.max(0,Math.min(t,e))}}function DL(t,e){for(let n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}var BL=wL;function kL(t,e){(function(t){return"string"==typeof t&&-1!==t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var n=function(t){return"string"==typeof t&&-1!==t.indexOf("%")}(t);return t=360===e?t:Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(String(t*e),10)/100),Math.abs(t-e)<1e-6?1:t=360===e?(t<0?t%e+e:t%e)/parseFloat(String(e)):t%e/parseFloat(String(e))}function LL(t){return t<=1?"".concat(100*Number(t),"%"):t}function FL(t){return 1===t.length?"0"+t:String(t)}function UL(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*n*(e-t):n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function GL(t){return VL(t)/255}function VL(t){return parseInt(t,16)}var WL={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",goldenrod:"#daa520",gold:"#ffd700",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavenderblush:"#fff0f5",lavender:"#e6e6fa",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function zL(t){var e,n,r,i={r:0,g:0,b:0},o=1,a=null,s=null,l=null,c=!1,u=!1;return"string"==typeof t&&(t=function(t){if(t=t.trim().toLowerCase(),0===t.length)return!1;var e=!1;if(WL[t])t=WL[t],e=!0;else if("transparent"===t)return{r:0,g:0,b:0,a:0,format:"name"};var n=YL.rgb.exec(t);if(n)return{r:n[1],g:n[2],b:n[3]};if(n=YL.rgba.exec(t),n)return{r:n[1],g:n[2],b:n[3],a:n[4]};if(n=YL.hsl.exec(t),n)return{h:n[1],s:n[2],l:n[3]};if(n=YL.hsla.exec(t),n)return{h:n[1],s:n[2],l:n[3],a:n[4]};if(n=YL.hsv.exec(t),n)return{h:n[1],s:n[2],v:n[3]};if(n=YL.hsva.exec(t),n)return{h:n[1],s:n[2],v:n[3],a:n[4]};if(n=YL.hex8.exec(t),n)return{r:VL(n[1]),g:VL(n[2]),b:VL(n[3]),a:GL(n[4]),format:e?"name":"hex8"};if(n=YL.hex6.exec(t),n)return{r:VL(n[1]),g:VL(n[2]),b:VL(n[3]),format:e?"name":"hex"};if(n=YL.hex4.exec(t),n)return{r:VL(n[1]+n[1]),g:VL(n[2]+n[2]),b:VL(n[3]+n[3]),a:GL(n[4]+n[4]),format:e?"name":"hex8"};if(n=YL.hex3.exec(t),n)return{r:VL(n[1]+n[1]),g:VL(n[2]+n[2]),b:VL(n[3]+n[3]),format:e?"name":"hex"};return!1}(t)),"object"==typeof t&&(KL(t.r)&&KL(t.g)&&KL(t.b)?(e=t.r,n=t.g,r=t.b,i={r:255*kL(e,255),g:255*kL(n,255),b:255*kL(r,255)},c=!0,u="%"===String(t.r).substr(-1)?"prgb":"rgb"):KL(t.h)&&KL(t.s)&&KL(t.v)?(a=LL(t.s),s=LL(t.v),i=function(t,e,n){t=6*kL(t,360),e=kL(e,100),n=kL(n,100);var r=Math.floor(t),i=t-r,o=n*(1-e),a=n*(1-i*e),s=n*(1-(1-i)*e),l=r%6;return{r:255*[n,a,o,o,s,n][l],g:255*[s,n,n,a,o,o][l],b:255*[o,o,s,n,n,a][l]}}(t.h,a,s),c=!0,u="hsv"):KL(t.h)&&KL(t.s)&&KL(t.l)&&(a=LL(t.s),l=LL(t.l),i=function(t,e,n){var r,i,o;if(t=kL(t,360),e=kL(e,100),n=kL(n,100),0===e)i=n,o=n,r=n;else{var a=n<.5?n*(1+e):n+e-n*e,s=2*n-a;r=UL(s,a,t+1/3),i=UL(s,a,t),o=UL(s,a,t-1/3)}return{r:255*r,g:255*i,b:255*o}}(t.h,a,l),c=!0,u="hsl"),Object.prototype.hasOwnProperty.call(t,"a")&&(o=t.a)),o=function(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}(o),{ok:c,format:t.format||u,r:Math.min(255,Math.max(i.r,0)),g:Math.min(255,Math.max(i.g,0)),b:Math.min(255,Math.max(i.b,0)),a:o}}var HL="(?:".concat("[-\\+]?\\d*\\.\\d+%?",")|(?:").concat("[-\\+]?\\d+%?",")"),jL="[\\s|\\(]+(".concat(HL,")[,|\\s]+(").concat(HL,")[,|\\s]+(").concat(HL,")\\s*\\)?"),XL="[\\s|\\(]+(".concat(HL,")[,|\\s]+(").concat(HL,")[,|\\s]+(").concat(HL,")[,|\\s]+(").concat(HL,")\\s*\\)?"),YL={CSS_UNIT:new RegExp(HL),rgb:new RegExp("rgb"+jL),rgba:new RegExp("rgba"+XL),hsl:new RegExp("hsl"+jL),hsla:new RegExp("hsla"+XL),hsv:new RegExp("hsv"+jL),hsva:new RegExp("hsva"+XL),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/};function KL(t){return Boolean(YL.CSS_UNIT.exec(String(t)))}var qL=2,$L=.16,ZL=.05,QL=.05,JL=.15,tF=5,eF=4,nF=[{index:7,opacity:.15},{index:6,opacity:.25},{index:5,opacity:.3},{index:5,opacity:.45},{index:5,opacity:.65},{index:5,opacity:.85},{index:4,opacity:.9},{index:3,opacity:.95},{index:2,opacity:.97},{index:1,opacity:.98}];function rF(t){var e=function(t,e,n){t=kL(t,255),e=kL(e,255),n=kL(n,255);var r=Math.max(t,e,n),i=Math.min(t,e,n),o=0,a=r,s=r-i,l=0===r?0:s/r;if(r===i)o=0;else{switch(r){case t:o=(e-n)/s+(e<n?6:0);break;case e:o=(n-t)/s+2;break;case n:o=(t-e)/s+4}o/=6}return{h:o,s:l,v:a}}(t.r,t.g,t.b);return{h:360*e.h,s:e.s,v:e.v}}function iF(t){var e=t.r,n=t.g,r=t.b;return"#".concat(function(t,e,n,r){var i=[FL(Math.round(t).toString(16)),FL(Math.round(e).toString(16)),FL(Math.round(n).toString(16))];return r&&i[0].startsWith(i[0].charAt(1))&&i[1].startsWith(i[1].charAt(1))&&i[2].startsWith(i[2].charAt(1))?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}(e,n,r,!1))}function oF(t,e,n){var r;return(r=Math.round(t.h)>=60&&Math.round(t.h)<=240?n?Math.round(t.h)-qL*e:Math.round(t.h)+qL*e:n?Math.round(t.h)+qL*e:Math.round(t.h)-qL*e)<0?r+=360:r>=360&&(r-=360),r}function aF(t,e,n){return 0===t.h&&0===t.s?t.s:((r=n?t.s-$L*e:e===eF?t.s+$L:t.s+ZL*e)>1&&(r=1),n&&e===tF&&r>.1&&(r=.1),r<.06&&(r=.06),Number(r.toFixed(2)));var r}function sF(t,e,n){var r;return(r=n?t.v+QL*e:t.v-JL*e)>1&&(r=1),Number(r.toFixed(2))}function lF(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[],r=zL(t),i=tF;i>0;i-=1){var o=rF(r),a=iF(zL({h:oF(o,i,!0),s:aF(o,i,!0),v:sF(o,i,!0)}));n.push(a)}n.push(iF(r));for(var s=1;s<=eF;s+=1){var l=rF(r),c=iF(zL({h:oF(l,s),s:aF(l,s),v:sF(l,s)}));n.push(c)}return"dark"===e.theme?nF.map((function(t){var r,i,o,a=t.index,s=t.opacity;return iF((r=zL(e.backgroundColor||"#141414"),i=zL(n[a]),o=100*s/100,{r:(i.r-r.r)*o+r.r,g:(i.g-r.g)*o+r.g,b:(i.b-r.b)*o+r.b}))})):n}var cF={red:"#F5222D",volcano:"#FA541C",orange:"#FA8C16",gold:"#FAAD14",yellow:"#FADB14",lime:"#A0D911",green:"#52C41A",cyan:"#13C2C2",blue:"#1677FF",geekblue:"#2F54EB",purple:"#722ED1",magenta:"#EB2F96",grey:"#666666"},uF={},hF={};Object.keys(cF).forEach((function(t){uF[t]=lF(cF[t]),uF[t].primary=uF[t][5],hF[t]=lF(cF[t],{theme:"dark",backgroundColor:"#141414"}),hF[t].primary=hF[t][5]}));const dF=(t,e,n)=>{const r=BL(t),i=BL(e);return BL([(1-n)*r.red()+n*i.red(),(1-n)*r.green()+n*i.green(),(1-n)*r.blue()+n*i.blue()]).rgb()},pF=(t,e="#fff",n="light")=>"light"!==n?((t,e="#fff",n="#777")=>{const r=dF(e,t,.2).rgb().toString(),i=dF(e,t,.3).rgb().toString(),o=dF(e,t,.6).rgb().toString(),a=dF(e,t,.8).rgb().toString(),s=dF(e,n,.2).rgb().toString(),l=dF(e,n,.25).rgb().toString(),c=dF(e,n,.3).rgb().toString(),u=dF(e,n,.4).rgb().toString(),h=dF(e,n,.5).rgb().toString(),d=lF(t,{theme:"dark",backgroundColor:e}),p=BL(t).hex().toLowerCase(),f=d.indexOf(p);let g=t;return-1!==f&&(g=d[f+1]),{mainStroke:a,mainFill:r,activeStroke:t,activeFill:i,inactiveStroke:a,inactiveFill:r,selectedStroke:t,selectedFill:r,highlightStroke:t,highlightFill:o,disableStroke:h,disableFill:l,edgeMainStroke:a,edgeActiveStroke:t,edgeInactiveStroke:n,edgeSelectedStroke:t,edgeHighlightStroke:t,edgeDisableStroke:c,comboMainStroke:u,comboMainFill:l,comboActiveStroke:t,comboActiveFill:s,comboInactiveStroke:u,comboInactiveFill:l,comboSelectedStroke:t,comboSelectedFill:s,comboHighlightStroke:g,comboHighlightFill:l,comboDisableStroke:u,comboDisableFill:s}})(t,e,"#777"):((t,e="#fff",n="rgb(150, 150, 150)")=>{const r=dF(e,t,.05).rgb().toString(),i=dF(e,t,.1).rgb().toString(),o=dF(e,t,.2).rgb().toString(),a=dF(e,t,.4).rgb().toString(),s=dF(e,n,.02).rgb().toString(),l=dF(e,n,.05).rgb().toString(),c=dF(e,n,.1).rgb().toString(),u=dF(e,n,.2).rgb().toString(),h=dF(e,n,.3).rgb().toString(),d=lF(t,{theme:"default",backgroundColor:e}),p=BL(t).hex().toLowerCase(),f=d.indexOf(p);let g=t;return-1!==f&&(g=d[f+1]),{mainStroke:t,mainFill:i,activeStroke:t,activeFill:r,inactiveStroke:a,inactiveFill:r,selectedStroke:t,selectedFill:i,highlightStroke:g,highlightFill:o,disableStroke:h,disableFill:l,edgeMainStroke:a,edgeActiveStroke:t,edgeInactiveStroke:u,edgeSelectedStroke:t,edgeHighlightStroke:t,edgeDisableStroke:c,comboMainStroke:h,comboMainFill:s,comboActiveStroke:t,comboActiveFill:r,comboInactiveStroke:h,comboInactiveFill:s,comboSelectedStroke:t,comboSelectedFill:s,comboHighlightStroke:g,comboHighlightFill:s,comboDisableStroke:u,comboDisableFill:l}})(t,e,"rgb(150, 150, 150)");var fF=Object.freeze({__proto__:null,SpecThemeSolver:class extends fL{solver(t,e){const{base:n="light",specification:r}=t,i=e[n],o=Object.assign({},i);return r&&(["node","edge","combo"].forEach((t=>{if(!r[t])return;const{palette:e=o[t].palette,lodStrategy:n=o[t].lodStrategy,dataTypeField:a}=r[t];let{getStyleSets:s}=r[t];a&&!s&&(s=e=>e.map((e=>({default:{keyShape:"edge"===t?{stroke:e}:{fill:e}}}))));const{styles:[l]}=i[t],c=(null==s?void 0:s(e))||{};let u;Re(c)?u=c.map((t=>{const e=Object.assign({},l);return Object.keys(t).forEach((n=>{e[n]=zR([l[n],t[n]])})),e})):(u={others:l},Object.keys(c).forEach((t=>{const e=Object.assign({},l),n=c[t];Object.keys(n).forEach((t=>{e[t]=zR([l[t],n[t]])})),u[t]=e}))),o[t]={dataTypeField:a,palette:e,lodStrategy:n,styles:u}})),o.canvas=Object.assign(Object.assign({},i.canvas),r.canvas)),o}},BaseThemeSolver:fL,SubjectThemeSolver:class extends fL{solver(t,e){const{base:n="light",baseColor:r="#fff",specification:i}=t,o=e[n],a=Object.assign({},o);return i&&(["node","edge","combo"].forEach((t=>{if(!i[t])return;const{palette:e,dataTypeField:s}=i[t],{styles:[l]}=o[t];let c;Re(e)?c=e.map((e=>{const i=pF(e,r,n);return this.getMergeStylesFromColorSet(t,i,l)})):(c={others:l},Object.keys(e).forEach((i=>{const o=e[i],a=pF(o,r,n);c[i]=this.getMergeStylesFromColorSet(t,a,l)}))),a[t]={dataTypeField:s,palette:e,styles:c}})),a.canvas=Object.assign(Object.assign({},o.canvas),i.canvas)),a.canvas=Object.assign(Object.assign({},o.canvas),i.canvas),a}getMergeStylesFromColorSet(t,e,n){const r=Object.assign({},n);return"node"===t?(r.default=zR([n.default,{keyShape:{stroke:e.mainStroke,fill:e.mainFill}}]),r.selected=zR([n.selected,{keyShape:{fill:e.selectedFill,stroke:e.selectedStroke,shadowColor:e.selectedStroke}}]),r.active=zR([n.active,{keyShape:{fill:e.activeFill,stroke:e.activeStroke,shadowColor:e.mainStroke}}]),r.highlight=zR([n.highlight,{keyShape:{fill:e.highlightFill,stroke:e.highlightStroke}}]),r.inactive=zR([n.inactive,{keyShape:{fill:e.inactiveFill,stroke:e.inactiveStroke}}]),r.disable=zR([n.disable,{keyShape:{fill:e.disableFill,stroke:e.disableStroke}}])):"edge"===t?(r.default=zR([n.default,{keyShape:{stroke:e.edgeMainStroke}}]),r.selected=zR([n.selected,{keyShape:{stroke:e.edgeSelectedStroke,shadowColor:e.edgeSelectedStroke}}]),r.active=zR([n.active,{keyShape:{stroke:e.edgeActiveStroke}}]),r.highlight=zR([n.highlight,{keyShape:{stroke:e.edgeHighlightStroke}}]),r.inactive=zR([n.inactive,{keyShape:{stroke:e.edgeInactiveStroke}}]),r.disable=zR([n.disable,{keyShape:{stroke:e.edgeDisableStroke}}])):"combo"===t&&(r.default=zR([n.default,{keyShape:{fill:e.comboMainFill,stroke:e.comboMainStroke}}]),r.selected=zR([n.selected,{keyShape:{stroke:e.comboSelectedStroke,fill:e.comboSelectedFill,shadowColor:e.comboSelectedStroke}}]),r.active=zR([n.active,{keyShape:{stroke:e.comboActiveStroke,fill:e.comboActiveFill}}]),r.highlight=zR([n.highlight,{keyShape:{stroke:e.comboHighlightStroke,fill:e.comboHighlightFill}}]),r.inactive=zR([n.inactive,{keyShape:{stroke:e.comboInactiveStroke,fill:e.comboInactiveFill}}]),r.disable=zR([n.disable,{keyShape:{stroke:e.comboDisableStroke,fill:e.comboDisableFill}}])),r}},mixColor:dF});const gF={stroke:"#000",strokeOpacity:.8,lineWidth:2,fillOpacity:.1,fill:"#ccc"};const mF="url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHBhdHRlcm4gaWQ9ImdyaWQiIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGggZD0iTSAwIDEwIEwgNDAgMTAgTSAxMCAwIEwgMTAgNDAgTSAwIDIwIEwgNDAgMjAgTSAyMCAwIEwgMjAgNDAgTSAwIDMwIEwgNDAgMzAgTSAzMCAwIEwgMzAgNDAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2UwZTBlMCIgb3BhY2l0eT0iMC4yIiBzdHJva2Utd2lkdGg9IjEiLz48cGF0aCBkPSJNIDQwIDAgTCAwIDAgMCA0MCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZTBlMGUwIiBzdHJva2Utd2lkdGg9IjEiLz48L3BhdHRlcm4+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JpZCkiLz48L3N2Zz4=)";var vF;!function(t){t.redo="redo",t.undo="undo"}(vF||(vF={}));class yF{constructor(t,e){this.action=t,this.ids=e}undo(t){t.executeWithNoStack((()=>{"front"===this.action?t.backItem(this.ids):t.frontItem(this.ids)}))}redo(t){t.executeWithNoStack((()=>{"front"===this.action?t.frontItem(this.ids):t.backItem(this.ids)}))}}class EF{constructor(t){this.changes=t}updateItemsStates(t,e){null==e||e.map((e=>{const{ids:n,states:r,value:i}=e;t.executeWithNoStack((()=>{t.setItemState(n,r,i)}))}))}undo(t){this.updateItemsStates(t,this.changes.oldValue)}redo(t){this.updateItemsStates(t,this.changes.newValue)}}class _F{constructor(t,e){this.changes=t,this.disableAnimate=e}toggleItemsVisible(t,e){t.pauseStack(),Ce(e,(e=>e.visible?t.showItem(e.ids,this.disableAnimate):t.hideItem(e.ids,this.disableAnimate))),t.resumeStack()}undo(t){const{oldValue:e}=this.changes;this.toggleItemsVisible(t,e)}redo(t){const{newValue:e}=this.changes;this.toggleItemsVisible(t,e)}}class bF{constructor(t,e,n,r){this.action=t,this.type=e,this.changes=n,this.upsertAncestors=r}removeChangedData(t){const e=this.changes.map((t=>{var e;return null===(e=t.value)||void 0===e?void 0:e.id})).filter(Boolean);t.executeWithNoStack((()=>{t.removeData(this.type,e)}))}addChangedData(t){const e=this.changes.map((t=>t.value)).filter(Boolean);t.executeWithNoStack((()=>{t.addData(this.type,e)}))}updateChangedData(t,e,n=!1){const r=new Map;"combo"!==this.type||n?this.changes.forEach((t=>{const n=e===vF.undo?t.oldValue:t.newValue;if("number"==typeof n&&isNaN(n)||["x","y"].includes(t.propertyName)&&void 0===n)return;const i=r.get(t.nodeId)||{};r.set(t.id,{id:t.id,data:Object.assign(Object.assign({},i.data),{[t.propertyName]:n})})})):this.changes.forEach((t=>{const e=r.get(t.nodeId)||{};r.set(t.nodeId,{id:t.nodeId,data:Object.assign(Object.assign({},e.data),{parentId:vF.undo?t.oldParentId:t.newParentId})})})),t.pauseStack();const i=Array.from(r.values());n?t.updateNodePosition(i,this.upsertAncestors):t.updateData(this.type,i),t.resumeStack()}undo(t){"add"===this.action&&this.removeChangedData(t),"remove"===this.action&&this.addChangedData(t),"update"===this.action&&this.updateChangedData(t,vF.undo),"updatePosition"===this.action&&this.updateChangedData(t,vF.undo,"updatePosition"===this.action)}redo(t){"remove"===this.action&&this.removeChangedData(t),"add"===this.action&&this.addChangedData(t),"update"===this.action&&this.updateChangedData(t,vF.redo),"updatePosition"===this.action&&this.updateChangedData(t,vF.redo,"updatePosition"===this.action)}}class SF{constructor(t,e){this.action=t,this.ids=e}undo(t){t.executeWithNoStack((()=>{"expandCombo"===this.action?t.collapseCombo(this.ids):t.expandCombo(this.ids)}))}redo(t){t.executeWithNoStack((()=>{"collapseCombo"===this.action?t.collapseCombo(this.ids):t.expandCombo(this.ids)}))}}class xF{static create(t){var{type:e,action:n,changes:r}=t,i=Nc(t,["type","action","changes"]);const o=[],a=Le(r,"type");for(const t in a){const r={NodeDataUpdated:"node",EdgeDataUpdated:"edge",NodeAdded:"node",EdgeAdded:"edge",NodeRemoved:"node",EdgeRemoved:"edge",TreeStructureChanged:"combo"};r[t]&&o.push(new bF(n,e||r[t],a[t],"NodeDataUpdated"===t?i.upsertAncestors:void 0))}const s={updateState:new EF(r),updateVisibility:new _F(r,i.disableAnimate),front:new yF("front",i.ids),back:new yF("back",i.ids),expandCombo:new SF("expandCombo",i.ids),collapseCombo:new SF("collapseCombo",i.ids)};return s[n]&&o.push(s[n]),o}}const TF={add:["addData","addCombo"],remove:["removeData"],update:["updateData","updateNodePosition","updateComboPosition","updatePosition","moveCombo","collapseCombo","expandCombo"],stateChange:["setItemState","clearItemState"],layerChange:["frontItem","backItem"],displayChange:["showItem","hideItem"]},AF=t=>{for(const[e,n]of Object.entries(TF))if(n.includes(t))return e;throw new Error(`Unknown apiName: ${t}. Unable to determine category.`)};class RF{constructor(t=0){this.items=[],this.maxStep=t}push(t){0!==this.maxStep&&this.items.length===this.maxStep&&this.items.shift(),this.items.push(t)}pop(){if(0!==this.items.length)return this.items.pop();throw new Error("Stack is empty")}size(){return this.items.length}clear(){this.items=[]}toArray(){return this.items}}function MF(t,e){e(t),t.children&&t.children.forEach((function(t){t&&MF(t,e)}))}function CF(t){wF(t,!0)}function PF(t){wF(t,!1)}function wF(t,e){var n=e?"visible":"hidden";MF(t,(function(t){t.attr("visibility",n)}))}var NF=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,kc([],Bc(e),!1))||this;return r.addEventListener(ms.INSERTED,(function(){PF(r)})),r}return Pc(e,t),e}(qs);function OF(t){var e=t.appendChild(new NF({class:"offscreen"}));return PF(e),e}var IF=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=Nc(e,["style"]);return t.call(this,wc({style:wc({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return Pc(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=OF(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(rl);function DF(t){return t*Math.PI/180}function BF(t){return Number((180*t/Math.PI).toPrecision(5))}var kF=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}();function LF(t,e){return Se(t)?t.apply(void 0,kc([],Bc(e),!1)):t}var FF,UF=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map((function(t){var e=Bc(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},GF=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=Bc(i,2),a=o[0],s=o[1],l=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?we(s)?(we(t[a])||(l[a]={}),n<r?GF(t[a],s,n+1,r):l[a]=e[a]):Re(s)?(l[a]=[],l[a]=l[a].concat(s)):l[a]=s:l[a]=s)}))},VF=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)GF(t,e[r]);return t},WF=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},zF=nn((function(t,e){var n=De(t)?t:t.style.text.toString(),r=e||HF(t),i=r.fontSize,o=r.fontFamily,a=r.fontWeight,s=r.fontStyle,l=r.fontVariant;return FF||(FF=document.createElement("canvas").getContext("2d")),FF.font=[s,l,a,"".concat(i,"px"),o].join(" "),FF.measureText(n).width}),(function(t,e){return[De(t)?t:t.style.text.toString(),Object.values(e||HF(t)).join()].join("")})),HF=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 jF(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function XF(t,e){var n=jF(t);n&&n.attr(e)}function YF(t,e,n){void 0===n&&(n="..."),XF(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function KF(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 qF(t){return"function"==typeof t?t():De(t)||Ue(t)?new IF({style:{text:String(t)}}):t}function $F(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 ZF(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}var QF=function(t,e){return function(n){return t*(1-n)+e*n}};function JF(t,e){return"number"==typeof t&&"number"==typeof e?QF(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]=JF(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=Bc(e,2),o=i[0],a=i[1];o in t?n[o]=JF(t[o],a):r[o]=a})),function(t){return Object.entries(n).forEach((function(e){var n=Bc(e,2),i=n[0],o=n[1];return r[i]=o(t)})),r}}(t,e):function(e){return t}}function tU(t,e){return[t[0]*e,t[1]*e]}function eU(t,e){return[t[0]+e[0],t[1]+e[1]]}function nU(t,e){return[t[0]-e[0],t[1]-e[1]]}function rU(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function iU(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function oU(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function aU(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 sU(t,e){return+t.toPrecision(e)}function lU(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 cU(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=[[0,0],[1,1]]);for(var r=!!e,i=[],o=0,a=t.length;o<a;o+=2)i.push([t[o],t[o+1]]);var s,l,c,u=function(t,e,n,r){var i,o,a,s,l,c,u=[],h=!!r,d=[1/0,1/0],p=[-1/0,-1/0];if(h){d=(i=Bc(r,2))[0],p=i[1];for(var f=0,g=t.length;f<g;f+=1)d=rU(d,v=t[f]),p=iU(p,v)}f=0;for(var m=t.length;f<m;f+=1){var v=t[f];if(0!==f||n)if(f!==m-1||n){o=t[[f?f-1:m-1,f-1][n?0:1]];var y=[0,0];y=tU(y=nU(a=t[n?(f+1)%m:f+1],o),e);var E=oU(v,o),_=oU(v,a),b=E+_;0!==b&&(E/=b,_/=b);var S=tU(y,-E),x=tU(y,_);l=eU(v,S),s=rU(s=eU(v,x),iU(a,v)),s=iU(s,rU(a,v)),l=rU(l=eU(v,S=tU(S=nU(s,v),-E/_)),iU(o,v)),s=eU(v,x=tU(x=nU(v,l=iU(l,rU(o,v))),_/E)),h&&(l=rU(l=iU(l,d),p),s=rU(s=iU(s,d),p)),u.push(c),u.push(l),c=s}else l=v,u.push(c),u.push(l);else c=v}return n&&u.push(u.shift()),u}(i,.4,r,n),h=i.length,d=[];for(o=0;o<h-1;o+=1)s=u[2*o],l=u[2*o+1],c=i[o+1],d.push(["C",s[0],s[1],l[0],l[1],c[0],c[1]]);return r&&(s=u[h],l=u[h+1],c=Bc(i,1)[0],d.push(["C",s[0],s[1],l[0],l[1],c[0],c[1]])),d}var uU=["$el","anchor","cx","cy","d","defX","defY","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 hU(t){return uU.includes(t)}function dU(t){var e={};for(var n in t)hU(n)&&(e[n]=t[n]);return e}function pU(t,e,n){void 0===n&&(n=!1);var r=t.getBBox(),i=r.width,o=r.height,a=e/Math.max(i,o);return n&&t.scale(a),a}var fU=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=Bc(Array.isArray(a)?a:[a,null],2),l=s[0],c=s[1];(h=r(l,o)).__data__=l,null!==c&&(h.__fromElements__=c),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 u=this._elements[o],h=r(l=u.__data__,o);u.appendChild(h),i.push(h)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=Lc(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=Lc(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=Lc(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,c=[],u=[],h=new Set(this._elements),d=[],p=new Set,f=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]}))),m=(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),v=0;v<t.length;v++){var y=t[v],E=e(y,v),_=r(y,v);if(f.has(E))(T=f.get(E)).__data__=y,T.__facet__=!1,u.push(T),h.delete(T),f.delete(E);else if(g.has(E)){(T=g.get(E)).__data__=y,T.__facet__=!0,u.push(T),g.delete(E)}else if(m.has(E)){var b=m.get(E);d.push([y,b]);try{for(var S=(i=void 0,Dc(b)),x=S.next();!x.done;x=S.next()){var T=x.value;h.delete(T)}}catch(t){i={error:t}}finally{try{x&&!x.done&&(o=S.return)&&o.call(S)}finally{if(i)throw i.error}}m.delete(E)}else if(f.has(_)){(T=f.get(_)).__toData__?T.__toData__.push(y):T.__toData__=[y],p.add(T),h.delete(T)}else c.push(y)}var A=[new n([],c,this._parent,this._document),new n(u,null,this._parent,this._document),new n(h,null,this._parent,this._document),new n([],d,this._parent,this._document),new n(p,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,A)},t.prototype.merge=function(t){var e=kc(kc([],Bc(this._elements),!1),Bc(t._elements),!1),r=kc(kc([],Bc(this._transitions),!1),Bc(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),c=i(this._split);return a.merge(o).merge(s).merge(l).merge(c)},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=Bc(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,kc([this._parent,this],Bc(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:qs,rect:nl,circle:Xs,path:Js,text:IF,ellipse:Ks,image:Zs,line:Qs,polygon:tl,polyline:el,html:$s},t}();function gU(t){return new fU([t],null,t,t.ownerDocument)}function mU(t){if(Ue(t))return[t,t,t,t];if(Re(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 vU(t){var e=t.getLocalBounds(),n=Bc([e.min,e.max],2),r=Bc(n[0],2),i=r[0],o=r[1],a=Bc(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 yU(t,e){var n=Bc(t,2),r=n[0],i=n[1],o=Bc(e,2),a=o[0],s=o[1];return r!==a&&i===s}function EU(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function _U(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 bU=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function SU(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach((function(t){var i=Bc(t,2),o=i[0],a=i[1];if("className"===o||"class"===o);else if(bU(o,"show")&&bU(_U(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(EU(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(EU(e)),"")]=a;else if(!bU(o,"show")&&bU(o,e)!==n){var s=_U(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function xU(t,e){return Object.entries(t).reduce((function(t,n){var r=Bc(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(EU(i))]=o,t}),{})}function TU(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=Bc(t,2),a=o[0],s=o[1];e.includes(a)||(-1!==n.indexOf(a)?i[a]=s:r[a]=s)})),[r,i]}function AU(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 RU(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=Bc([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){}}function MU(){wF(this,"hidden"!==this.attributes.visibility)}var CU=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,VF({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return Pc(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=OF(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&&MU.call(this)},e.prototype.update=function(t,e){var n;return this.attr(VF({},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}(Ys),PU=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"]]},wU=PU,NU=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},OU=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},IU=OU;var DU=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function BU(t){var e=function(t){var e="default";if(Me(t)&&t instanceof Image)e="image";else if(Se(t))e="symbol";else if(De(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 kU=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e.prototype.render=function(t,n){var r=t.symbol,i=t.size,o=void 0===i?16:i,a=Nc(t,["symbol","size"]),s=BU(r);$F(!!s,gU(n),(function(t){t.maybeAppendByClassName("marker",s).attr("className","marker ".concat(s,"-marker")).call((function(t){if("image"===s){var n=2*o;t.styles({img:r,width:n,height:n,x:-o,y:-o})}else{n=o/2;var i=Se(r)?r:e.getSymbol(r);t.styles(wc({path:null==i?void 0:i(0,0,n)},a))}}))}))},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}(CU);function LU(t,...e){return e.reduce(((t,e)=>n=>t(e(n))),t)}function FU(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}kU.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]]})),kU.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),kU.registerSymbol("line",NU),kU.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),kU.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]]})),kU.registerSymbol("circle",PU),kU.registerSymbol("point",wU),kU.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"]]})),kU.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"]]})),kU.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"]]})),kU.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),kU.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"]]})),kU.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"]]})),kU.registerSymbol("line",NU),kU.registerSymbol("dot",OU),kU.registerSymbol("dash",IU),kU.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]]})),kU.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]]})),kU.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]]})),kU.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]]})),kU.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 UU=Math.sqrt(50),GU=Math.sqrt(10),VU=Math.sqrt(2);function WU(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>=UU?10:o>=GU?5:o>=VU?2:1)*10**i:-(10**-i)/(o>=UU?10:o>=GU?5:o>=VU?2:1)}const zU=(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=WU(s,l,n),i>0?(s=Math.floor(s/i)*i,l=Math.ceil(l/i)*i,i=WU(s,l,n)):i<0&&(s=Math.ceil(s*i)/i,l=Math.floor(l*i)/i,i=WU(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 HU(t){return!WM(t)&&!UM(t)&&!Number.isNaN(t)}function jU(t,e){return n=>{n.prototype.rescale=function(){this.initRange(),this.nice();const[t]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t))},n.prototype.initRange=function(){const{interpolator:e}=this.options;this.options.range=t(e)},n.prototype.composeOutput=function(t,n){const{domain:r,interpolator:i,round:o}=this.getOptions(),a=e(r.map(t)),s=o?(t=>e=>{const n=t(e);return PM(n)?Math.round(n):n})(i):i;this.output=LU(s,a,n,t)},n.prototype.invert=void 0}}function XU(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 YU(t){const e=vL.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*XU(a,o,e+1/3),255*XU(a,o,e),255*XU(a,o,e-1/3),i]}(r):null}const KU=(t,e)=>n=>t*(1-n)+e*n,qU=(t,e)=>"number"==typeof t&&"number"==typeof e?KU(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=YU(t),r=YU(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,$U=(t,e)=>{const n=KU(t,e);return t=>Math.round(n(t))};function ZU({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function QU(t){return"object"==typeof t?t.valueOf():t}class JU extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=QU,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(ZU({map:this.map,initKey:this.initKey},t))}has(t){return super.has(ZU({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 tG{constructor(t){this.options=KM({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=KM({},this.options,t),this.rescale(t)}rescale(t){}}const eG=Symbol("defaultUnknown");function nG(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function rG(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let a=i.get(e);if(void 0===a){if(o!==eG)return o;a=n.push(e)-1,i.set(e,a)}return r[a%r.length]}function iG(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class oG extends tG{getDefaultOptions(){return{domain:[],range:[],unknown:eG}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&nG(this.domainIndexMap,this.getDomain(),this.domainKey),rG({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&nG(this.rangeIndexMap,this.getRange(),this.rangeKey),rG({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=iG(e),this.rangeKey=iG(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 oG(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 aG(t){return Math.round(1e12*t)/1e12}function sG(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:a,align:s}=t,l=e.length,c=function(t,e){const n=e-t.length;return n>0?[...t,...new Array(n).fill(1)]:n<0?t.slice(0,e):t}(o,l),[u,h]=n,d=h-u,p=d/(2/l*r+1-1/l*i),f=p*i/l,g=p-l*f,m=function(t){const e=Math.min(...t);return t.map((t=>t/e))}(c),v=g/m.reduce(((t,e)=>t+e)),y=new JU(e.map(((t,e)=>{const n=m[e]*v;return[t,a?Math.floor(n):n]}))),E=new JU(e.map(((t,e)=>{const n=m[e]*v+f;return[t,a?Math.floor(n):n]}))),_=Array.from(E.values()).reduce(((t,e)=>t+e)),b=u+(d-(_-_/l*i))*s;let S=a?Math.round(b):b;const x=new Array(l);for(let t=0;t<l;t+=1){x[t]=aG(S);const n=e[t];S+=E.get(n)}return{valueBandWidth:y,valueStep:E,adjustedRange:x}}class lG extends oG{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:eG,flex:[]}}constructor(t){super(t)}clone(){return new lG(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 sG(t);const{range:i,paddingOuter:o,paddingInner:a,round:s,align:l}=t;let c,u,h=i[0];const d=i[1]-h,p=2*o,f=r-a;c=d/Math.max(1,p+f),s&&(c=Math.floor(c)),h+=(d-c*(r-a))*l,u=c*(1-a),s&&(h=Math.round(h),u=Math.round(u));const g=new Array(r).fill(0).map(((t,e)=>h+e*c));return{valueStep:c,valueBandWidth:u,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 cG=(t,e,n)=>{let r,i,o=t,a=e;if(o===a&&n>0)return[o];let s=WU(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},uG=(t,e,n)=>{const[r,i]=t,[o,a]=e;let s,l;return r<i?(s=FU(r,i),l=n(o,a)):(s=FU(i,r),l=n(a,o)),LU(l,s)},hG=(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]=FU(s[t],s[t+1]),o[t]=n(l[t],l[t+1]);return e=>{const n=function(t,e,n,r,i){let o=n||0,a=r||t.length;const s=i||(t=>t);for(;o<a;){const n=Math.floor((o+a)/2);s(t[n])>e?a=n:o=n+1}return o}(t,e,1,r)-1,a=i[n];return LU(o[n],a)(e)}},dG=(t,e,n,r)=>(Math.min(t.length,e.length)>2?hG:uG)(t,e,r?$U:n);class pG extends tG{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:KU,tickCount:5}}map(t){return HU(t)?this.output(t):this.options.unknown}invert(t){return HU(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 zU}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]):eC}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,a=dG(n.map(t),r,o,i);this.output=LU(a,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=dG(i,r.map(t),KU);this.input=LU(e,n,o)}}class fG extends pG{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:qU,tickMethod:cG,tickCount:5}}chooseTransforms(){return[eC,eC]}clone(){return new fG(this.options)}}function gG(t,e){for(var n=[],r=0,i=t.length;r<i;r++)n.push(t[r].substr(0,e));return n}var mG=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],vG=["January","February","March","April","May","June","July","August","September","October","November","December"],yG=gG(vG,3);!function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0,i=e;r<i.length;r++){var o=i[r];for(var a in o)t[a]=o[a]}}({},{dayNamesShort:gG(mG,3),dayNames:mG,monthNamesShort:yG,monthNames:vG,amPm:["am","pm"],DoFn:function(t){return t+["th","st","nd","rd"][t%10>3?0:(t-t%10!=10?1:0)*t%10]}});var EG,_G=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};let bG=EG=class extends fG{getDefaultOptions(){return{domain:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolator:eC,tickMethod:cG,tickCount:5}}constructor(t){super(t)}clone(){return new EG(this.options)}};bG=EG=_G([jU((function(t){return[t(0),t(1)]}),(t=>{const[e,n]=t;return LU(KU(0,1),FU(e,n))}))],bG);var SG,xG=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};let TG=SG=class extends fG{getDefaultOptions(){return{domain:[0,.5,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolator:eC,tickMethod:cG,tickCount:5}}constructor(t){super(t)}clone(){return new SG(this.options)}};TG=SG=xG([jU((function(t){return[t(0),t(.5),t(1)]}),(t=>{const[e,n,r]=t,i=LU(KU(0,.5),FU(e,n)),o=LU(KU(.5,1),FU(n,r));return t=>e>r?t<n?o(t):i(t):t<n?i(t):o(t)}))],TG);var AG=function(t){function e(e){var n=this,r=e.style,i=Nc(e,["style"]);return(n=t.call(this,an({},{type:"column"},wc({style:r},i)))||this).columnsGroup=new qs({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return Pc(e,t),e.prototype.render=function(){var t=this.attributes.columns;gU(this.columnsGroup).selectAll(".column").data(t.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(VF({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(js),RG=function(t){function e(e){var n=this,r=e.style,i=Nc(e,["style"]);return(n=t.call(this,an({},{type:"lines"},wc({style:r},i)))||this).linesGroup=n.appendChild(new qs),n.areasGroup=n.appendChild(new qs),n.render(),n}return Pc(e,t),e.prototype.render=function(){var t=this.attributes,e=t.lines,n=t.areas;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(VF({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){gU(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){gU(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}(js);function MG(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map((function(t,e){return kc([e===n?"M":"L"],Bc(t),!1)}));return e?r.reverse():r}function CG(t,e){if(void 0===e&&(e=!1),t.length<=2)return MG(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];un(o,n.slice(-2))||n.push.apply(n,kc([],Bc(o),!1))}var a=cU(n,!1);return e?a.unshift(kc(["M"],Bc(t[r-1]),!1)):a.unshift(kc(["M"],Bc(t[0]),!1)),a}function PG(t,e,n){var r=tn(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function wG(t){return 0===t.length?[0,0]:[Oe(ze(t,(function(t){return Oe(t)||0}))),Ne(We(t,(function(t){return Ne(t)||0})))]}function NG(t){for(var e=tn(t),n=e[0].length,r=Bc([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 OG=function(t){function e(e){return t.call(this,e,{type:"line",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 Pc(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=tn(t);return Ue(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?NG(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=Bc(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=SU(this.attributes,"area"),a=SU(this.attributes,"line"),s=this.containerShape.width,l=this.data;if(0===l[0].length)return{lines:[],areas:[]};var c=this.scales,u=function(t,e){var n,r=e.x,i=e.y,o=Bc(i.getOptions().range||[0,0],2),a=o[0],s=o[1];return s>a&&(n=Bc([a,s],2),s=n[0],a=n[1]),t.map((function(t){return t.map((function(t,e){return[r.map(e),Fe(i.map(t),s,a)]}))}))}(l,{type:"line",x:c.x,y:c.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=CG(o),s=void 0;if(0===i)s=PG(a,e,n);else{var l=CG(t[i-1],!0),c=o[0];l[0][0]="L",s=kc(kc(kc([],Bc(a),!1),Bc(l),!1),[kc(["M"],Bc(c),!1),["Z"]],!1)}r.push(s)}return r}(u,s,d):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=MG(t[i]),a=void 0;if(0===i)a=PG(o,e,n);else{var s=MG(t[i-1],!0);s[0][0]="L",a=kc(kc(kc([],Bc(o),!1),Bc(s),!1),[["Z"]],!1)}r.push(a)}return r}(u,s,d):function(t,e,n,r){return t.map((function(t){return PG(e?CG(t):MG(t),n,r)}))}(u,i,s,d)}return{lines:u.map((function(e,n){return wc({stroke:t.getColor(n),path:i?CG(e):MG(e)},a)})),areas:h.map((function(e,n){return wc({path:e,fill:t.getColor(n)},o)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=SU(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=NG(s));var l=this.createScales(s),c=l.x,u=l.y,h=Bc(wG(s),2),d=h[0],p=h[1],f=new fG({domain:[0,p-(d>0?0:d)],range:[0,a*o]}),g=c.getBandWidth(),m=this.rawData;return{columns:s.map((function(n,i){return n.map((function(n,o){var a=g/s.length;return wc(wc({fill:t.getColor(i)},e),r?{x:c.map(o),y:u.map(n),width:g,height:f.map(m[i][o])}:{x:c.map(o)+a*i,y:n>=0?u.map(n):u.map(0),width:a,height:f.map(Math.abs(n))})}))}))}},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){var n,r,i;(n=e,r=".container",i="rect",n.querySelector(r)?gU(n).select(r):gU(n).append(i)).attr("className","container").node();var o=t.type,a="spark".concat(o),s="line"===o?this.linesStyle:this.columnsStyle;gU(e).selectAll(".spark").data([o]).join((function(t){return t.append((function(t){return"line"===t?new RG({className:a,style:s}):new AG({className:a,style:s})})).attr("className","spark ".concat(a))}),(function(t){return t.update(s)}),(function(t){return t.remove()}))},e.prototype.getColor=function(t){var e=this.attributes.color;return Re(e)?e[t%e.length]:Se(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,c=this.containerShape,u=c.width,h=c.height,d=Bc(wG(t),2),p=d[0],f=d[1],g=new fG({domain:[null!==(e=s[0])&&void 0!==e?e:p,null!==(n=s[1])&&void 0!==n?n:f],range:[h,h*(1-o)]});return"line"===i?{type:i,x:new fG({domain:[0,t[0].length-1],range:[0,u]}),y:g}:{type:i,x:new lG({domain:t[0].map((function(t,e){return e})),range:[0,u],paddingInner:l,paddingOuter:l/2,align:.5}),y:g}},e.tag="sparkline",e}(CU);function IG(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=Bc(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,wc(wc({},t[e]),n)]:[e,n]})))}function DG(t,e){t?t.finished.then(e):e()}function BG(t,e){"update"in t?t.update(e):t.attr(e)}function kG(t,e,n){return 0===e.length?null:n?t.animate(e,n):(BG(t,{style:e.slice(-1)[0]}),null)}function LG(t,e,n){var r={},i={};return Object.entries(e).forEach((function(e){var n=Bc(e,2),o=n[0],a=n[1];if(!xe(a)){var s=t.style[o]||t.parsedStyle[o]||0;s!==a&&(r[o]=s,i[o]=a)}})),n?kG(t,[r,i],wc({fill:"both"},n)):(BG(t,i),null)}function FG(t,e){return t.style.opacity||(t.style.opacity=1),LG(t,{opacity:0},e)}var UG={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},GG={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},VG={orientation:"horizontal",showLabel:!0,type:"start"},WG=UF({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),zG=UF({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),HG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e.prototype.render=function(t,e){var n=t.size,r=void 0===n?10:n,i=t.radius,o=void 0===i?r/4:i,a=t.orientation,s=Nc(t,["size","radius","orientation"]),l=r,c=2.4*l,u=gU(e).maybeAppendByClassName(zG.iconRect,"rect").styles(wc(wc({},s),{width:l,height:c,radius:o,x:-l/2,y:-c/2})),h=1/3*l,d=2/3*l,p=1/4*c,f=3/4*c;u.maybeAppendByClassName("".concat(zG.iconLine,"-1"),"line").styles(wc({x1:h,x2:h,y1:p,y2:f},s)),u.maybeAppendByClassName("".concat(zG.iconLine,"-2"),"line").styles(wc({x1:d,x2:d,y1:p,y2:f},s)),u.node().setOrigin(l/2,c/2),"vertical"===a?e.setLocalEulerAngles(90):e.setLocalEulerAngles(0)},e}(CU),jG=function(t){function e(e){return t.call(this,e,VG)||this}return Pc(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes.showLabel,r=SU(this.attributes,"label"),i=r.transform,o=Bc(TU(Nc(r,["transform"]),[]),2),a=o[0],s=o[1],l=gU(t).maybeAppendByClassName(zG.labelGroup,"g").styles(s),c=wc(wc({},GG),a),u=c.text,h=Nc(c,["text"]);$F(!!n,l,(function(t){e.label=t.maybeAppendByClassName(zG.label,"text").styles(wc(wc({},h),{transform:i,text:"".concat(u)})),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.orientation,r=e.type,i=wc(wc({orientation:n},UG),SU(this.attributes,"icon")),o=this.attributes.iconShape,a=void 0===o?function(){return new HG({style:i})}:o;gU(t).maybeAppendByClassName(zG.iconGroup,"g").selectAll(zG.icon.class).data([a]).join((function(t){return t.append("string"==typeof a?a:function(){return a(r)}).attr("className",zG.icon.name)}),(function(t){return t.update(i)}),(function(t){return t.remove()}))},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(CU),XG=function(t){function e(e){var n=t.call(this,e,wc(wc(wc({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},xU(VG,"handle")),xU(UG,"handleIcon")),xU(GG,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(KF(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(KF(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 hs("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 Pc(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=SU(this.attributes,"sparkline");return wc(wc({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=Bc(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=Bc(mU(this.attributes.padding),4),e=t[0],n=t[1],r=t[2],i=t[3],o=this.shape;return{x:i,y:e,width:o.width-(i+n),height:o.height-(e+r)}},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(WG.selection.class).each((function(n,r){LG(this,e[r],t)}))},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&LG(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&LG(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=SU(this.attributes,"track");this.trackShape=gU(t).maybeAppendByClassName(WG.track,"rect").styles(wc(wc({},this.shape),e))},e.prototype.renderBrushArea=function(t){var e=this.attributes.brushable;this.brushArea=gU(t).maybeAppendByClassName(WG.brushArea,"rect").styles(wc({fill:"transparent",cursor:e?"crosshair":"default"},this.shape))},e.prototype.renderSparkline=function(t){var e=this;$F("horizontal"===this.attributes.orientation,gU(t).maybeAppendByClassName(WG.sparklineGroup,"g"),(function(t){var n=e.sparklineStyle;t.maybeAppendByClassName(WG.sparkline,(function(){return new OG({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(WG.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 jG({style:e.getHandleStyle(n)})})).each((function(t){var e=t.type;this.attr("class","".concat(WG.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.type,r=e.selectionType;this.foregroundGroup=gU(t).maybeAppendByClassName(WG.foreground,"g");var i=SU(this.attributes,"selection"),o=function(t){return t.style("visibility",(function(t){return t.show?"visible":"hidden"})).style("cursor",(function(t){return"select"===r?"grab":"invert"===r?"crosshair":"default"})).styles(i)},a=this;this.foregroundGroup.selectAll(WG.selection.class).data("value"===n?[]:this.calcSelectionArea().map((function(t,e){return{style:wc({},t),index:e,show:"select"===r?1===e:1!==e}})),(function(t){return t.index})).join((function(t){return t.append("rect").attr("className",WG.selection.name).call(o).each((function(t,e){var n=this;1===e?(a.selectionShape=gU(this),this.on("pointerdown",(function(t){n.attr("cursor","grabbing"),a.onDragStart("selection")(t)})),a.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),a.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),a.dispatchCustomEvent(this,"click","selectionClick"),this.addEventListener("pointerdown",(function(){n.attr("cursor","grabbing")})),this.addEventListener("pointerup",(function(){n.attr("cursor","grab")}))):this.on("pointerdown",a.onDragStart("track"))}))}),(function(t){return t.call(o)}),(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=Bc(this.range,2),i=r[0],o=r[1],a=Bc(this.getValues().map((function(t){return sU(t,e)})),2),s=a[0],l=a[1],c=Bc(((Array.isArray(t)?t:[s,null!=t?t:l])||[s,l]).map((function(t){return sU(t,e)})),2),u=c[0],h=c[1];if("value"===this.attributes.type)return[0,Fe(h,i,o)];u>h&&(u=(n=Bc([h,u],2))[0],h=n[1]);var d=h-u;return d>o-i?[i,o]:u<i?s===i&&l===h?[i,h]:[i,d+i]:h>o?l===o&&s===u?[u,o]:[o-d,o]:[u,h]},e.prototype.calcSelectionArea=function(t){var e=Bc(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=Bc(this.clampValues(),2),l=s[0],c=s[1],u="start"===t?-e:e,h=("start"===t?l:c)*this.getOrientVal([o,a])+u;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?{transform:"rotate(90)",textAlign:"start"}:"end"===t?{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=SU(this.attributes,"handle"),l=SU(s,"label"),c=s.spacing,u=this.getHandleSize(),h=this.clampValues(),d=o("start"===t?h[0]:h[1]),p=new IF({style:wc(wc(wc({},l),this.inferTextStyle(t)),{text:d})}),f=p.getBBox(),g=f.width,m=f.height;if(p.destroy(),!a){if("value"===r)return{text:d,x:0,y:-m-c};var v=c+u+("horizontal"===i?g/2:0);return(e={text:d})["horizontal"===i?"x":"y"]="start"===t?-v:v,e}var y=0,E=0,_=this.availableSpace,b=_.width,S=_.height,x=this.calcSelectionArea()[1],T=x.x,A=x.y,R=x.width,M=x.height,C=c+u;if("horizontal"===i){var P=C+g/2;if("start"===t)y=T-C-g>0?-P:P;else y=b-T-R-C>g?P:-P}else{var w=m+C;E="start"===t?A-u>m?-w:C:S-(A+M)-u>m?w:-C}return{x:y,y:E,text:d}},e.prototype.getHandleLabelStyle=function(t){var e=SU(this.attributes,"handleLabel");return wc(wc(wc({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=SU(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return wc({cursor:n,shape:t,size:r},e)},e.prototype.getHandleStyle=function(t){var e=this.attributes,n=e.showLabel,r=e.showLabelOnInteraction,i=e.orientation,o=this.calcHandlePosition(t),a=this.calcHandleText(t),s=n;return!n&&r&&(s=!!this.target),wc(wc(wc(wc({},xU(this.getHandleIconStyle(),"icon")),xU(wc(wc({},this.getHandleLabelStyle(t)),a),"label")),o),{orientation:i,showLabel:s,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=Bc(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=Bc(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 hs(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}(CU),YG={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 Js({style:{path:[["M",10,10],["L",-10,0],["L",10,-10],["L",0,0],["L",10,10],["Z"]],anchor:"0.5 0.5",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:[]};an({},YG,{style:{type:"arc"}}),an({},YG,{style:{}});var KG=UF({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"),qG=UF({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function $G(t){return t.reduce((function(t,e,n){return t.push(kc([0===n?"M":"L"],Bc(e),!1)),t}),[])}function ZG(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 $G(t);if(!o)return[];var a=oU(t[0],o),s=n?0:1;return t.reduce((function(t,e,n){return 0===n?t.push(kc(["M"],Bc(e),!1)):t.push(kc(["A",a,a,0,0,s],Bc(e),!1)),t}),[])}(t,e,n):$G(t)}function QG(t,e,n){var r=n.type,i=n.connect,o=n.center,a=n.closed?[["Z"]]:[],s=Bc([ZG(t,n),ZG(e.slice().reverse(),n,!0)],2),l=s[0],c=s[1],u=Bc([t[0],e.slice(-1)[0]],2),h=u[0],d=u[1],p=function(t,e){return[l,t,c,e,a].flat()};if("line"===i||"surround"===r)return p([kc(["L"],Bc(d),!1)],[kc(["L"],Bc(h),!1)]);if(!o)throw new Error("Arc grid need to specified center");var f=Bc([oU(d,o),oU(h,o)],2),g=f[0],m=f[1];return p([kc(["A",g,g,0,0,1],Bc(d),!1),kc(["L"],Bc(d),!1)],[kc(["A",m,m,0,0,0],Bc(h),!1),kc(["L"],Bc(h),!1)])}var JG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Nc(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=Bc(e,1)[0];return wc(wc({},t),{points:kc(kc([],Bc(e),!1),[n],!1)})})):n}(t),i=gU(e).maybeAppendByClassName(qG.lineGroup,"g"),o=gU(e).maybeAppendByClassName(qG.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),path:ZG(t.points,n)}}));return t.selectAll(qG.line.class).data(a,(function(t){return t.id})).join((function(t){return t.append("path").each((function(t,e){var n=LF(dU(wc({path:t.path},r)),[t,e,a]);this.attr(wc({class:qG.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))}))}),(function(t){return t.transition((function(t,e){return LG(this,LF(dU(wc({path:t.path},r)),[t,e,a]),i.update)}))}),(function(t){return t.transition((function(){var t=this,e=FG(this,i.exit);return DG(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=[],c=0;c<e.length-1;c++){var u=Bc([e[c].points,e[c+1].points],2),h=QG(u[0],u[1],n);l.push({path:h,fill:s(c)})}return t.selectAll(qG.region.class).data(l,(function(t,e){return e})).join((function(t){return t.append("path").each((function(t,e){var n=LF(t,[t,e,l]);this.attr(n)})).attr("className",qG.region.name)}),(function(t){return t.transition((function(t,e){return LG(this,LF(t,[t,e,l]),r.update)}))}),(function(t){return t.transition((function(){var t=this,e=FG(this,r.exit);return DG(e,(function(){return t.remove()})),e}))})).transitions()}(o,r,t);return kc(kc([],Bc(a),!1),Bc(s),!1)},e}(CU);function tV(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var n=Bc(t,2);return[n[0],LF(n[1],e)]})))}function eV(t,e){return e&&Se(e)?t.filter(e):t}var nV=nn((function(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}),(function(t,e){return[t,e.startAngle,e.endAngle].join()})),rV=nn((function(t,e){if("linear"===e.type){var n=Bc(e.startPos,2),r=n[0],i=n[1],o=Bc(e.endPos,2),a=Bc([o[0]-r,o[1]-i],2);return aU([a[0],a[1]])}var s=DF(nV(t,e));return[-Math.sin(s),Math.cos(s)]}),(function(t,e){var n=function(t){if("linear"===t.type){var e=t.startPos,n=t.endPos;return kc(kc([],Bc(e),!1),Bc(n),!1)}var r=t.startAngle,i=t.endAngle,o=t.center,a=t.radius;return kc(kc([r,i],Bc(o),!1),[a],!1)}(e);return"arc"===e.type&&n.push(t),n.join()}));function iV(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(rV(t,n),"positive"!==e)}function oV(t,e){return iV(t,e.labelDirection,e)}var aV=nn((function(t,e){var n=Bc(e.startPos,2),r=n[0],i=n[1],o=Bc(e.endPos,2),a=Bc([o[0]-r,o[1]-i],2);return[r+a[0]*t,i+a[1]*t]}),(function(t,e){return kc(kc([t],Bc(e.startPos),!1),Bc(e.endPos),!1).join()})),sV=nn((function(t,e){var n=e.radius,r=Bc(e.center,2),i=r[0],o=r[1],a=DF(nV(t,e));return[i+n*Math.cos(a),o+n*Math.sin(a)]}),(function(t,e){return kc([t,e.startAngle,e.endAngle,e.radius],Bc(e.center),!1).join()}));function lV(t,e){return"linear"===e.type?aV(t,e):sV(t,e)}function cV(t){return 0===rV(0,t)[1]}function uV(t){return 0===rV(0,t)[0]}function hV(t,e){return e-t==360}function dV(t,e,n,r,i){var o=e-t,a=Bc([i,i],2),s=a[0],l=a[1],c=Bc([DF(t),DF(e)],2),u=c[0],h=c[1],d=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},p=Bc(d(u),2),f=p[0],g=p[1],m=Bc(d(h),2),v=m[0],y=m[1];if(hV(t,e)){var E=Bc(d((h+u)/2),2);return[["M",f,g],["A",s,l,0,1,0,E[0],E[1]],["A",s,l,0,1,0,v,y]]}var _=o>180?1:0,b=t>e?0:1;return"M".concat(f,",").concat(g,",A").concat(s,",").concat(l,",0,").concat(_,",").concat(b,",").concat(v,",").concat(y)}function pV(t,e,n,r){var i=e.startAngle,o=e.endAngle,a=e.center,s=e.radius;return t.selectAll(KG.line.class).data([{path:dV.apply(void 0,kc(kc([i,o],Bc(a),!1),[s],!1))}],(function(t,e){return e})).join((function(t){return t.append("path").attr("className",KG.line.name).styles(e).styles({path:function(t){return t.path}})}),(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=JF(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,wc({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return kc(kc([n,r],Bc(i),!1),[o],!1)}(this),kc(kc([i,o],Bc(a),!1),[s],!1),r.update);if(e){var n=function(){var e=dn(t.attributes,"__keyframe_data__");t.style.path=dV.apply(void 0,kc([],Bc(e),!1))};e.onframe=n,e.onfinish=n}return e})).styles(e)}),(function(t){return t.remove()})).styles(n).transitions()}function fV(t){var e=Bc(t,2),n=Bc(e[0],2),r=n[0],i=n[1],o=Bc(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function gV(t,e,n,r){var i=e.showTrunc,o=e.startPos,a=e.endPos,s=e.truncRange,l=e.lineExtension,c=Bc([o,a],2),u=Bc(c[0],2),h=u[0],d=u[1],p=Bc(c[1],2),f=p[0],g=p[1],m=Bc(l?function(t,e,n){void 0===n&&(n=[0,0]);var r=Bc([t,e,n],3),i=Bc(r[0],2),o=i[0],a=i[1],s=Bc(r[1],2),l=s[0],c=s[1],u=Bc(r[2],2),h=u[0],d=u[1],p=Bc([l-o,c-a],2),f=p[0],g=p[1],m=Math.sqrt(Math.pow(f,2)+Math.pow(g,2)),v=Bc([-h/m,d/m],2),y=v[0],E=v[1];return[y*f,y*g,E*f,E*g]}(o,a,l):new Array(4).fill(0),4),v=m[0],y=m[1],E=m[2],_=m[3],b=function(e){return t.selectAll(KG.line.class).data(e,(function(t,e){return e})).join((function(t){return t.append("line").attr("className",(function(t){return"".concat(KG.line.name," ").concat(t.className)})).styles(n).transition((function(t){return LG(this,fV(t.line),!1)}))}),(function(t){return t.styles(n).transition((function(t){return LG(this,fV(t.line),r.update)}))}),(function(t){return t.remove()})).transitions()};if(!i||!s)return b([{line:[[h+v,d+y],[f+E,g+_]],className:KG.line.name}]);var S=Bc(s,2),x=S[0],T=S[1],A=f-h,R=g-d,M=Bc([h+A*x,d+R*x],2),C=M[0],P=M[1],w=Bc([h+A*T,d+R*T],2),N=w[0],O=w[1],I=b([{line:[[h+v,d+y],[C,P]],className:KG.lineFirst.name},{line:[[N,O],[f+E,g+_]],className:KG.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),I}function mV(t,e,n){var r,i=e.type,o=SU(e,"line");return r="linear"===i?gV(t,e,lU(o,"arrow"),n):pV(t,e,lU(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,a=n.showTrunc,s=n.lineArrow,l=n.lineArrowOffset,c=n.lineArrowSize;if(i="arc"===e?t.select(KG.line.class):a?t.select(KG.lineSecond.class):t.select(KG.line.class),!o||!s||"arc"===n.type&&hV(n.startAngle,n.endAngle)){var u=i.node();u&&(u.style.markerEnd=void 0)}else{var h=qF(s);h.attr(r),pU(h,c,!0),i.style("markerEnd",h).style("markerEndOffset",-l)}}(t,i,e,o),r}function vV(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function yV(t,e){var n=e.gridLength;return t.map((function(t,r){var i=t.value,o=Bc(lV(i,e),2),a=o[0],s=o[1],l=Bc(tU(function(t,e){return iV(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[a,s],[a+l[0],s+l[1]]]}}))}function EV(t,e,n,r){var i=SU(n,"grid"),o=i.type,a=i.areaFill,s=vV(n),l=eV(e,n.gridFilter),c="segment"===o?yV(l,n):function(t,e){var n=e.gridControlAngles,r=vV(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=Bc(r,2),o=i[0],a=i[1];return t.map((function(t,r){var i=Bc(lV(t.value,e),2),s=i[0],l=i[1],c=Bc([s-o,l-a],2),u=c[0],h=c[1],d=[];return n.forEach((function(t){var e=DF(t),n=Bc([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=u*r-h*i+o,l=u*i+h*r+a;d.push([s,l])})),{points:d,id:r}}))}(l,n),u=wc(wc({},i),{center:s,areaFill:Se(a)?l.map((function(t,e){return LF(a,[t,e,l])})):a,animate:r,data:c});return t.selectAll(KG.grid.class).data([1]).join((function(t){return t.append((function(){return new JG({style:u})})).attr("className",KG.grid.name)}),(function(t){return t.transition((function(){return this.update(u)}))}),(function(t){return t.remove()})).transitions()}var _V=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),c=Math.sin(t),u=e-e*l+n*c,h=n-e*c-n*l;return[[l*i-c*s+u,c*i+l*s+h],[l*a-c*s+u,c*a+l*s+h],[l*i-c*o+u,c*i+l*o+h],[l*a-c*o+u,c*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 bV(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getLocalBounds(),i=Bc(r.min,2),o=i[0],a=i[1],s=Bc(r.max,2),l=s[0],c=s[1],u=SV(t),h=u.width,d=u.height,p=0,f=0,g=o,m=a,v=jF(t);if(v){d-=1.5;var y=v.style.textAlign,E=v.style.textBaseline;"center"===y?g=(o+l)/2:"right"!==y&&"end"!==y||(g=l),"middle"===E?m=(a+c)/2:"bottom"===E&&(m=c)}var _=Bc(mU(e),4),b=_[0],S=void 0===b?0:b,x=_[1],T=void 0===x?0:x,A=_[2],R=void 0===A?S:A,M=_[3],C=new _V((p+=o)-(void 0===M?T:M),(f+=a)-S,p+h+T,f+d+R);return t.setEulerAngles(n),C.rotatedPoints(DF(n),g,m)}function SV(t){return t.__bbox__?t.__bbox__:t.getBBox()}function xV(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 TV(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 AV(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,c=[e,[9999,e[1]]],u=0,h=0;do{var d=[t[h],t[(h+1)%n]];if(i=c,o=void 0,a=void 0,s=void 0,l=void 0,o=TV((r=d)[0],r[1],i[0]),a=TV(r[0],r[1],i[1]),s=TV(i[0],i[1],r[0]),l=TV(i[0],i[1],r[1]),o!==a&&s!==l||0===o&&xV(r,i[0])||0===a&&xV(r,i[1])||0===s&&xV(i,r[0])||0===l&&xV(i,r[1])){if(0===TV(d[0],e,d[1]))return xV(d,e);u++}h=(h+1)%n}while(0!==h);return!!(1&u)}(t,e)}))}function RV(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=Bc(t,4),r=n[0],i=n[1],o=n[2],a=n[3],s=Bc(e,4),l=s[0],c=s[1],u=o-r,h=a-i,d=s[2]-l,p=s[3]-c,f=u*p-d*h;if(0===f)return!1;var g=f>0,m=r-l,v=i-c,y=u*v-h*m;if(y<0===g)return!1;var E=d*v-p*m;return E<0!==g&&y>f!==g&&E>f!==g}(e,t)}))}function MV(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=Bc(o,2),l=s[0],c=s[1],u="negative"===r?0:i,h=-a-u,d=a+u,p=Bc(mU(e),4),f=p[0],g=p[1],m=p[2],v=p[3];return new _V(l+h-v,c+h-f,l+d+g,c+d+m)}var y=Bc(t.startPos,2),E=y[0],_=y[1],b=Bc(t.endPos,2),S=b[0],x=b[1],T=Bc(uV(t)?[-e,0,e,0]:[0,e,0,-e],4),A=T[0],R=T[1],M=T[2],C=T[3],P=tU(oV(0,t),i),w=new _V(E,_,S,x);return w.x1+=C,w.y1+=A,w.x2+=R+P[0],w.y2+=M+P[1],w}(e,o),c=function(t){return!l||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,a=t.y2;return AV([[r,o],[i,o],[i,a],[r,a]],bV(e,n))}(l,t)},u=function(t,e){return!t||!function(t,e,n){var r,i,o=bV(t,n).flat(1),a=bV(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=Dc(s),c=l.next();!c.done;c=l.next())if(RV(a,c.value))return!0}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return!1}(t,e,mU(n))};try{for(var h=Dc(t),d=h.next();!d.done;d=h.next()){var p=d.value;c(p)?!s||u(s,p)?s=p:(a.add(s),a.add(p)):a.add(p)}}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 CV(t,e){return void 0===e&&(e={}),xe(t)?0:"number"==typeof t?t:Math.floor(zF(t,e))}var PV=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter((function(t,e){return!(e%r)||(PF(t),!1)}))};var wV=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,c,u=PV,h=function(t){return t.forEach(r.show),t},d=2,p=t.slice(),f=t.slice(),g=Math.min.apply(Math,kc([1],Bc(t.map((function(t){return SV(t).width}))),!1));if("linear"===n.type&&(cV(n)||uV(n))){var m=vU(t[0]).left,v=vU(t[i-1]).right,y=Math.abs(v-m)||1;d=Math.max(Math.floor(i*g/y),d)}for(o&&(s=p.splice(0,1)[0]),a&&(l=p.splice(-1,1)[0],p.reverse()),h(p);d<t.length&&MV((c=l?kc(kc([l],Bc(f),!1),[s],!1):kc([s],Bc(f),!1),c.filter(WF)),n,null==e?void 0:e.margin).length;){if(l&&!s&&d%2==0)p.splice(0,1).forEach(r.hide);else if(l&&s){p.splice(0,1).forEach(r.hide)}f=u(h(p),{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,c=e.recoverWhenFailed,u=void 0===c||c,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 p=Dc(s),f=p.next();!f.done;f=p.next()){if(d(f.value),MV(t,n,l).length<1)return}}catch(t){i={error:t}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}u&&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,c=e.step,u=void 0===c?" ":c,h=e.margin,d=void 0===h?[0,0,0,0]:h,p=HF(r.getTextShape(t[0])),f=CV(u,p),g=a?CV(a,p):f,m=CV(l,p);(xe(m)||m===1/0)&&(m=Math.max.apply(null,t.map((function(t){return SV(t).width}))));var v=t.slice(),y=Bc(d,4);y[0],y[1],y[2],y[3];for(var E=function(e){if(v.forEach((function(t){r.ellipsis(r.getTextShape(t),e,o)})),(v=MV(t,n,d)).length<1)return{value:void 0}},_=m;_>g+f;_-=f){var b=E(_);if("object"==typeof b)return b.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,c=void 0===l||l,u=e.margin,h=void 0===u?[0,0,0,0]:u,d=t.map((function(t){return t.attr("maxLines")||1})),p=Math.min.apply(Math,kc([],Bc(d),!1)),f=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&cV(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,f)}))};if(!(p>s)){for(var m=p;m<=s;m++)if(g(m),MV(t,n,h).length<1)return;c&&g(d)}}]]);function NV(){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)}var OV=function(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)},IV=nn((function(t,e){var n=Bc(t,2),r=n[0],i=n[1],o=Bc(e,2),a=o[0],s=o[1],l=Bc([r*a+i*s,r*s-i*a],2),c=l[0],u=l[1];return Math.atan2(u,c)}),(function(t,e){return kc(kc([],Bc(t),!1),Bc(e),!1).join()}));function DV(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=oV(t.value,n),a=rV(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return ZF(e,-90,90)||(e+=180),e}(BF("perpendicular"===i?IV([1,0],o):IV([a[0]<0?-1:1,0],a)))}function BV(t,e,n){var r=n.type,i=n.labelAlign,o=oV(t,n),a=OV(e),s=OV(BF(IV([1,0],o))),l="center",c="middle";return"linear"===r?[90,270].includes(s)&&0===a?(l="center",c=1===o[1]?"top":"bottom"):s%180||![90,270].includes(a)?0===s?(ZF(a,0,90,!1,!0)||ZF(a,0,90)||ZF(a,270,360))&&(l="start"):90===s?ZF(a,0,90,!1,!0)?l="start":(ZF(a,90,180)||ZF(a,270,360))&&(l="end"):270===s?ZF(a,0,90,!1,!0)?l="end":(ZF(a,90,180)||ZF(a,270,360))&&(l="start"):180===s&&(90===a?l="start":(ZF(a,0,90)||ZF(a,270,360))&&(l="end")):l="center":"parallel"===i?c=ZF(s,0,180,!0)?"top":"bottom":"horizontal"===i?ZF(s,90,270,!1)?l="end":(ZF(s,270,360,!1)||ZF(s,0,90))&&(l="start"):"perpendicular"===i&&(l=ZF(s,90,270)?"end":"start"),{textAlign:l,textBaseline:c}}function kV(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,a=n.labelDirection,s=n.labelSpacing,l=e.indexOf(t),c=LF(s,[t,l,e]),u=Bc([oV(t.value,n),NV(a,o)],2),h=Bc(eU(tU(u[0],c+(1===u[1]?LF(r?i:0,[t,l,e]):0)),lV(t.value,n)),2);return{x:h[0],y:h[1]}}function LV(t,e){"text"===t.nodeName&&t.attr(e)}function FV(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=wV.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:PF,show:CF,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=BV(e.__data__.value,t,n),i=e.querySelector(KG.labelItem.class);i&&LV(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&YF(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"),XF(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector("text")}})}function UV(t,e,n,r,i){var o=n.indexOf(e),a=gU(t).append(function(t,e,n,r){var i=r.labelFormatter;return Se(i)?function(){return qF(LF(i,[t,e,n,oV(t.value,r)]))}:function(){return qF(t.label||"")}}(e,o,n,i)).attr("className",KG.labelItem.name).node(),s=Bc(TU(tV(r,[e,o,n])),2),l=s[0],c=s[1],u=c.transform,h=Nc(c,["transform"]);RU(t,u);var d=DV(e,t,i);return t.setLocalEulerAngles(+d),LV(a,wc(wc({},BV(e.value,d,i)),l)),RU(t,u),t.attr(h),a}function GV(t,e,n,r){var i=eV(e,n.labelFilter),o=SU(n,"label");return t.selectAll(KG.label.class).data(i,(function(t,e){return e})).join((function(r){return r.append("g").attr("className",KG.label.name).transition((function(t){return UV(this,t,e,o,n),this.attr(kV(t,e,n)),this.__bbox__=t.bbox,null})).call((function(){return FV.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&&PF(t),e.isVisible()&&CF(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,c=Math.ceil(+a/2),u=+a/4,h=function(t){if("circle"===t.nodeName){var e=Bc(t.getLocalPosition(),2),n=e[0],r=e[1],i=t.attr("r");return[n-i,r-i]}return t.getLocalPosition()},d=Bc(h(t),2),p=d[0],f=d[1],g=Bc(h(e),2),m=Bc([(p+g[0])/2-p,(f+g[1])/2-f],2),v=m[0],y=m[1],E=t.style.opacity,_=void 0===E?1:E,b=e.style.opacity,S=void 0===b?1:b,x=t.animate([{opacity:_,transform:"translate(0, 0)"},{opacity:0,transform:"translate(".concat(v,", ").concat(y,")")}],wc(wc({fill:"both"},n),{duration:l+c+u})),T=e.animate([{opacity:0,transform:"translate(".concat(-v,", ").concat(-y,")"),offset:.01},{opacity:S,transform:"translate(0, 0)"}],wc(wc({fill:"both"},n),{duration:c+u,delay:l+c-u}));return DG(T,i),[x,T]}(this.querySelector(KG.labelItem.class),UV(this,t,e,o,n),r.update),a=LG(this,kV(t,e,n),r.update);return this.__bbox__=t.bbox,kc(kc([],Bc(i),!1),[a],!1)})).call((function(e){var r,i,o=dn(e,"_transitions").flat().filter(WF);i=function(){return FV.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=FG(this.childNodes[0],r.exit);return DG(e,(function(){return gU(t).remove()})),e}))})).transitions()}function VV(t,e){return iV(t,e.tickDirection,e)}var WV=nn((function(t,e){var n=Bc(t,2);return[[0,0],[n[0]*e,n[1]*e]]}),(function(t,e){return kc(kc([],Bc(t),!1),[e],!1).join()}));function zV(t,e,n,r,i,o,a){var s=VV(t.value,o),l=function(t,e,n,r,i){var o=i.tickLength,a=Bc(WV(r,LF(o,[t,e,n])),2),s=Bc(a[0],2),l=s[0],c=s[1],u=Bc(a[1],2);return{x1:l,x2:u[0],y1:c,y2:u[1]}}(t,e,n,s,o),c=l.x1,u=l.x2,h=l.y1,d=l.y2,p=Bc(TU(tV(a,[t,e,n,s])),2),f=p[0],g=p[1];"line"===r.node().nodeName&&r.styles(wc({x1:c,x2:u,y1:h,y2:d},f)),i.attr(g),r.styles(f)}function HV(t,e,n,r,i,o){var a=function(t,e,n,r,i){var o=i.tickFormatter,a=VV(e.value,i),s="line";return Se(o)&&(s=function(){return LF(o,[e,n,r,a])}),t.append(s).attr("className",KG.tickItem.name)}(gU(this),t,e,n,r);zV(t,e,n,a,this,r,i);var s=Bc(lV(t.value,r),2);return LG(this,{x:s[0],y:s[1]},o)}var jV=UF({text:"text"},"title");function XV(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function YV(t,e){var n=Object.entries(e).reduce((function(e,n){var r=Bc(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e}),{});t.styles(n)}var KV=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 Pc(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(jV.text.class);if(!a)return new kF(0,0,+e,+n);var s=a.getBBox(),l=s.width,c=s.height,u=Bc(mU(i),4),h=u[0],d=u[1],p=u[2],f=u[3],g=Bc([0,0,+e,+n],4),m=g[0],v=g[1],y=g[2],E=g[3],_=XV(r);if(_.includes("i"))return new kF(m,v,y,E);_.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=Bc(0===r?[c+p,+n-c-p]:[0,+n],2),v=i[0],E=i[1]),"r"===t&&(o=Bc([+e-l-f],1),y=o[0]),"b"===t&&(a=Bc([+n-c-h],1),E=a[0]),"l"===t&&(s=Bc(0===r?[l+d,+e-l-d]:[0,+e],2),m=s[0],y=s[1])}));var b=Bc(mU(o),4),S=b[0],x=b[1],T=b[2],A=b[3],R=Bc([A+x,S+T],2),M=R[0],C=R[1];return new kF(m+A,v+S,y-M,E-C)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new kF(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=Nc(t,["width","height","position","spacing"]),i=Bc(TU(r),1)[0],o=function(t){var e,n,r,i,o=t,a=o.width,s=o.height,l=o.position,c=Bc([+a/2,+s/2],2),u=Bc([+c[0],+c[1],"center","middle"],4),h=u[0],d=u[1],p=u[2],f=u[3],g=XV(l);return g.includes("l")&&(h=(e=Bc([0,"start"],2))[0],p=e[1]),g.includes("r")&&(h=(n=Bc([+a,"end"],2))[0],p=n[1]),g.includes("t")&&(d=(r=Bc([0,"top"],2))[0],f=r[1]),g.includes("b")&&(d=(i=Bc([+s,"bottom"],2))[0],f=i[1]),{x:h,y:d,textAlign:p,textBaseline:f}}(t),a=o.x,s=o.y,l=o.textAlign,c=o.textBaseline;$F(!!r.text,gU(e),(function(t){n.title=t.maybeAppendByClassName(jV.text,"text").styles(i).call(YV,{x:a,y:s,textAlign:l,textBaseline:c}).node()}))},e}(CU);function qV(t,e,n,r,i){var o=Bc(TU(SU(r,"title")),2),a=o[0],s=o[1],l=s.transform,c=Nc(s,["transform"]);t.styles(a),e.styles(c);var u=l||function(t,e,n){var r=t.cloneNode(!0);r.style.transform="scale(1, 1)",r.style.transform="none";var i=r.getBBox().height;if("vertical"===e){if("left"===n)return"rotate(-90) translate(0, ".concat(i/2,")");if("right"===n)return"rotate(-90) translate(0, -".concat(i/2,")")}return""}(t.node(),a.direction,a.position);RU(t.node(),u);var h=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,a=XV(i),s=t.node().getLocalBounds(),l=Bc(s.min,2),c=l[0],u=l[1],h=Bc(s.halfExtents,2),d=h[0],p=h[1],f=Bc(e.node().getLocalBounds().halfExtents,2),g=f[0],m=f[1],v=Bc([c+d,u+p],2),y=v[0],E=v[1],_=Bc(mU(o),4),b=_[0],S=_[1],x=_[2],T=_[3];if(["start","end"].includes(i)&&"linear"===n.type){var A=n.startPos,R=n.endPos,M=Bc("start"===i?[A,R]:[R,A],2),C=M[0],P=M[1],w=Bc(tU(aU([-P[0]+C[0],-P[1]+C[1]]),b),2),N=w[0],O=w[1];return{x:C[0]+N,y:C[1]+O}}return a.includes("t")&&(E-=p+m+b),a.includes("r")&&(y+=d+g+S),a.includes("l")&&(y-=d+2*g+T),a.includes("b")&&(E+=p+2*m+x),{x:y,y:E}}(gU(n._offscreen||n.querySelector(KG.mainGroup.class)),e,r),d=h.x,p=h.y,f=LG(e.node(),{x:d,y:p},i);return RU(t.node(),u),f}function $V(t,e,n,r){var i=t.showLine,o=t.showTick,a=t.showLabel,s=$F(i,e.maybeAppendByClassName(KG.lineGroup,"g"),(function(e){return mV(e,t,r)}))||[],l=$F(o,e.maybeAppendByClassName(KG.tickGroup,"g"),(function(e){return function(t,e,n,r){var i=eV(e,n.tickFilter),o=SU(n,"tick");return t.selectAll(KG.tick.class).data(i,(function(t){return t.id||t.label})).join((function(t){return t.append("g").attr("className",KG.tick.name).transition((function(t,e){return HV.call(this,t,e,i,n,o,!1)}))}),(function(t){return t.transition((function(t,e){return this.removeChildren(),HV.call(this,t,e,i,n,o,r.update)}))}),(function(t){return t.transition((function(){var t=this,e=FG(this.childNodes[0],r.exit);return DG(e,(function(){return t.remove()})),e}))})).transitions()}(e,n,t,r)}))||[],c=$F(a,e.maybeAppendByClassName(KG.labelGroup,"g"),(function(e){return GV(e,n,t,r)}))||[];return kc(kc(kc([],Bc(s),!1),Bc(l),!1),Bc(c),!1).filter((function(t){return!!t}))}var ZV=function(t){function e(e){return t.call(this,e,YG)||this}return Pc(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,c=t.dataThreshold,u=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,c).filter((function(t){var e=t.value;return!(u&&e>u[0]&&e<u[1])})),d=IG(void 0===n?a:n),p=$F(l,gU(e).maybeAppendByClassName(KG.gridGroup,"g"),(function(e){return EV(e,h,t,d)}))||[],f=gU(e).maybeAppendByClassName(KG.mainGroup,"g");i&&(!this.initialized&&d.enter||this.initialized&&d.update)&&$V(t,gU(this.offscreenGroup),h,IG(!1));var g=$V(t,gU(f.node()),h,d),m=$F(s,gU(e).maybeAppendByClassName(KG.titleGroup,"g"),(function(e){return function(t,e,n,r){var i=n.titleText;return t.selectAll(KG.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 qF(i)})).attr("className",KG.title.name).transition((function(){return qV(gU(this),t,e,n,r.enter)}))}),(function(i){return i.transition((function(){return qV(gU(this),t,e,n,r.update)}))}),(function(t){return t.remove()})).transitions()}(e,r,t,d)}))||[];return kc(kc(kc([],Bc(p),!1),Bc(g),!1),Bc(m),!1).flat().filter((function(t){return!!t}))},e}(CU),QV=UF({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"),JV=function(t){function e(e){var n=t.call(this,e,{animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonPath:DU(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 qs({class:QV.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new qs({class:QV.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return Pc(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return Fe(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=Bc(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,kc([],Bc(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 kF(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=Bc(this.getFollowingPageDiff(t),2),c=l[0],u=l[1];this.playState="running";var h=kG(a,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-c,", ").concat(-u,")")}],n);return DG(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:Fe(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:Fe(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(QV.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)?CF(e):PF(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 c=Bc("horizontal"===o?[-180,0]:[-90,90],2),u=c[0],h=c[1];e.setLocalEulerAngles(u),n.setLocalEulerAngles(h);var d=e.getBBox(),p=d.width,f=d.height,g=n.getBBox(),m=g.width,v=g.height,y=Math.max(p,l,m),E="horizontal"===o?{offset:[[0,0],[p/2+a,0],[p+l+2*a,0]],textAlign:"start"}:{offset:[[y/2,-f-a],[y/2,0],[y/2,v+a]],textAlign:"center"},_=Bc(E.offset,3),b=Bc(_[0],2),S=b[0],x=b[1],T=Bc(_[1],2),A=T[0],R=T[1],M=Bc(_[2],2),C=M[0],P=M[1],w=E.textAlign,N=r.querySelector("text");N&&(N.style.textAlign=w),e.setLocalPosition(S,x),r.setLocalPosition(A,R),n.setLocalPosition(C,P)},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(QV.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=Bc(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(QV.controller,"g");if(wF(s.node(),a),a){var l=SU(this.attributes,"button"),c=SU(this.attributes,"pageNum"),u=Bc(TU(l),2),h=u[0],d=u[1],p=h.size,f=Nc(h,["size"]),g=!s.select(QV.prevBtnGroup.class).node(),m=s.maybeAppendByClassName(QV.prevBtnGroup,"g").styles(d);this.prevBtnGroup=m.node();var v=m.maybeAppendByClassName(QV.prevBtn,"path"),y=s.maybeAppendByClassName(QV.nextBtnGroup,"g").styles(d);this.nextBtnGroup=y.node(),[v,y.maybeAppendByClassName(QV.nextBtn,"path")].forEach((function(t){t.styles(wc(wc({},f),{transformOrigin:"center"})),pU(t.node(),p,!0)}));var E=s.maybeAppendByClassName(QV.pageInfoGroup,"g");this.pageInfoGroup=E.node(),E.maybeAppendByClassName(QV.pageInfo,"text").styles(c),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=gU(e);this.renderClipPath(n),this.renderController(n),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=en((function(){return t.render(t.attributes,t)}),50);this.playWindow.addEventListener(ms.INSERTED,e),this.playWindow.addEventListener(ms.REMOVED,e)},e}(CU);function tW(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}kU.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"]]})),kU.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]]})),kU.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 eW=UF({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 nW=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new Xs({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this}return Pc(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=Bc(mU(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,c=s.valueWidth,u=Bc(this.spacing,2),h=u[0],d=u[1];if(r){var p=r-n-h-d,f=Bc(this.span,2);l=(t=Bc([f[0]*p,f[1]*p],2))[0],c=t[1]}return{width:o+l+c+h+d,height:a,markerWidth:o,labelWidth:l,valueWidth:c}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes.spacing;if(!t)return[0,0];var e=Bc(mU(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=Bc(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(eW.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,c=+(i||a||(l?1:0))*Math.sqrt(2),u=this.markerGroup.node().getBBox(),h=u.width,d=u.height;return(1-c/Math.max(h,d))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes.marker,r=SU(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(eW.markerGroup,"g").style("zIndex",0),$F(!!n,this.markerGroup,(function(){var t=e.markerGroup.node(),i=t.getElementsByClassName(eW.marker.name)[0],o=n();i?o.nodeName===i.nodeName?(!function(t,e){var n,r,i=e.attributes;try{for(var o=Dc(Object.entries(i)),a=o.next();!a.done;a=o.next()){var s=Bc(a.value,2),l=s[0],c=s[1];"id"!==l&&"className"!==l&&t.attr(l,c)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(i,o),gU(i).styles(r)):(i.remove(),gU(o).attr("className",eW.marker.name).styles(r),t.appendChild(o)):(gU(o).attr("className",eW.marker.name).styles(r),t.appendChild(o)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]),pU(e.markerGroup.node(),e.scaleSize,!0)}))},e.prototype.renderLabel=function(t){var e=SU(this.attributes,"label"),n=e.text,r=Nc(e,["text"]);this.labelGroup=t.maybeAppendByClassName(eW.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(eW.label,(function(){return qF(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=SU(this.attributes,"value"),r=n.text,i=Nc(n,["text"]);this.valueGroup=t.maybeAppendByClassName(eW.valueGroup,"g").style("zIndex",0),$F(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(eW.value,(function(){return qF(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=SU(this.attributes,"background");this.background=t.maybeAppendByClassName(eW.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(eW.background,"rect").styles(wc({width:n,height:r},i))},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=Bc(t.position,3),o=i[0],a=i[1],s=i[2],l=r/2;this.markerGroup.styles({x:o,y:l}),this.labelGroup.styles({x:a,y:l}),YF(this.labelGroup.select(eW.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({x:s,y:l}),YF(this.valueGroup.select(eW.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=gU(e);this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.adjustLayout()},e}(CU),rW=UF({page:"item-page",navigator:"navigator",item:"item"},"items"),iW=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},oW=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:mn,mouseenter:mn,mouseleave:mn})||this;return n.navigatorShape=[0,0],n}return Pc(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=SU(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:wc({layout:n,labelText:s,valueText:l},Object.fromEntries(Object.entries(r).map((function(n){var r=Bc(n,2);return[r[0],LF(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=Bc(this.navigatorShape,1)[0],s=Bc(this.grid,2),l=s[0],c=s[1],u=c*l,h=0;return this.pageViews.children.map((function(e,s){var d,p,f=Math.floor(s/u),g=s%u,m=t.ifHorizontal(c,l),v=[Math.floor(g/m),g%m];"vertical"===n&&v.reverse();var y=Bc(v,2),E=y[0],_=y[1],b=(r-a-(c-1)*o)/c,S=e.getBBox().height,x=Bc([0,0],2),T=x[0],A=x[1];return"horizontal"===n?(T=(d=Bc([h,E*(S+i)],2))[0],A=d[1],h=_===c-1?0:h+b+o):(T=(p=Bc([_*(b+o),h],2))[0],A=p[1],h=E===l-1?0:h+S+i),{page:f,index:s,row:E,col:_,pageIndex:g,width:b,height:S,x:T,y:A}}))},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=Bc(this.navigatorShape,1)[0],a=Bc(this.grid,2),s=a[0],l=a[1],c=Bc([e-o,n],2),u=c[0],h=c[1],d=Bc([0,0,0,0,0,0,0,0],8),p=d[0],f=d[1],g=d[2],m=d[3],v=d[4],y=d[5],E=d[6],_=d[7];return this.pageViews.children.map((function(t,e){var n,o,a,c,d=t.getBBox(),b=d.width,S=d.height,x=0===E?0:i,T=E+x+b;return T<=u&&iW(v,(function(t){return t<l}))?(n=Bc([E+x,_,T],3),p=n[0],f=n[1],E=n[2],{width:b,height:S,x:p,y:f,page:g,index:e,pageIndex:m++,row:y,col:v++}):(o=Bc([y+1,0,0,_+S+r],4),y=o[0],v=o[1],E=o[2],(_=o[3])+S<=h&&iW(y,(function(t){return t<s}))?(a=Bc([E,_,b],3),p=a[0],f=a[1],E=a[2],{width:b,height:S,x:p,y:f,page:g,index:e,pageIndex:m++,row:y,col:v++}):(c=Bc([0,0,b,0,g+1,0,0,0],8),p=c[0],f=c[1],E=c[2],_=c[3],g=c[4],m=c[5],y=c[6],v=c[7],{width:b,height:S,x:p,y:f,page:g,index:e,pageIndex:m++,row:y,col:v++}))}))},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 tW(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(rW.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(rW.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);gU(t).selectAll(rW.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new nW({style:e})})).attr("className",rW.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=Bc(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=Bc(t,2);return{page:e[0],layouts:e[1]}})),i=kc([],Bc(this.navigator.getContainer().children),!1);r.forEach((function(t){var e=t.layouts,r=n.pageViews.appendChild(new qs({className:rW.page.name}));e.forEach((function(t){var e,n,o,a,s=t.x,l=t.y,c=t.index,u=t.width,h=t.height,d=i[c];r.appendChild(d),n=t,o=d,(a=De(e="__layout__")?e.split("."):e).forEach((function(t,e){e<a.length-1?(Me(o[t])||(o[t]=Ue(a[e+1])?[]:{}),o=o[t]):o[t]=n})),d.update({x:s,y:l,width:u,height:h})}))})),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes.orientation,n=SU(this.attributes,"nav"),r=VF({orientation:e},n),i=this;return t.selectAll(rW.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new JV({style:r})})).attr("className",rW.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(gU(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new hs(t,{detail:e});this.dispatchEvent(n)},e}(CU),aW=UF({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),sW={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,sW)||this}Pc(e,t),e.prototype.render=function(t,e){var n=gU(e).maybeAppendByClassName(aW.markerGroup,"g");this.renderMarker(n);var r=gU(e).maybeAppendByClassName(aW.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?tW(r,"horizontalHandle","verticalHandle"):i;$F(!!o,t,(function(t){var n=SU(e.attributes,"marker"),r=wc({symbol:o},n);e.marker=t.maybeAppendByClassName(aW.marker,(function(){return new kU({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;$F(r,t,(function(t){var n,r=SU(e.attributes,"label"),o=r.text,l=Nc(r,["text"]),c=(null===(n=t.select(aW.marker.class))||void 0===n?void 0:n.node().getBBox())||{},u=c.width,h=void 0===u?0:u,d=c.height,p=Bc(tW(i,[0,(void 0===d?0:d)+a,"center","top"],[h+a,0,"start","middle"]),4),f=p[0],g=p[1],m=p[2],v=p[3];t.maybeAppendByClassName(aW.label,"text").styles(wc(wc({},l),{x:f,y:g,text:s(o).toString(),textAlign:m,textBaseline:v}))}))}}(CU);var lW={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},cW=VF({},lW,{});VF({},lW,xU(sW,"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 uW=UF({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"),hW=function(t){function e(e){return t.call(this,e,cW)||this}return Pc(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,a=Bc(TU(SU(this.attributes,"title")),2),s=a[0],l=a[1];this.titleGroup=t.maybeAppendByClassName(uW.titleGroup,"g").styles(l);var c=wc(wc({width:e,height:n},s),{text:i?o:""});this.title=this.titleGroup.maybeAppendByClassName(uW.title,(function(){return new KV({style:c})})).update(c)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,a=Bc(TU(SU(this.attributes,"title",!0)),2),s=a[0],l=a[1],c=wc(wc({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(uW.itemsGroup,"g").styles(wc({x:n,y:r},l));var u=this;this.itemsGroup.selectAll(uW.items.class).data(["items"]).join((function(t){return t.append((function(){return new oW({style:c})})).attr("className",uW.items.name).each((function(){u.items=gU(this)}))}),(function(t){return t.update(c)}),(function(t){return t.remove()}))},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().setLocalPosition(e,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 kF(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(),c=XV(r),u=Bc(mU(a?i:0),4),h=u[0],d=u[1],p=u[2],f=u[3],g=Bc(mU(o),4),m=g[0],v=g[1],y=g[2],E=g[3],_=Bc([f+d,h+p],2),b=_[0],S=_[1],x=Bc([E+v,m+y],2),T=x[0],A=x[1];if("l"===c[0])return new kF(s.x,s.y,l.width+s.width+b+T,Math.max(l.height+A,s.height));if("t"===c[0])return new kF(s.x,s.y,Math.max(l.width+T,s.width),l.height+s.height+S+A);var R=Bc([e.attributes.width||l.width,e.attributes.height||l.height],2),M=R[0],C=R[1];return new kF(l.x,l.y,M+s.width+b+T,C+s.height+S+A)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=t.width,r=t.height,i=gU(e);this.renderTitle(i,n,r),this.renderItems(i,this.availableSpace),this.adjustLayout()},e}(CU),dW={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},pW=UF({background:"background",labelGroup:"label-group",label:"label"},"indicator"),fW=function(t){function e(e){var n=t.call(this,e,dW)||this;return n.point=[0,0],n.group=n.appendChild(new qs({})),n.isMutationObserved=!0,n}return Pc(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=Bc(mU(t.padding),4),r=n[0],i=n[1],o=n[2],a=n[3],s=this.label.node().getLocalBounds(),l=s.min,c=s.max,u=new kF(l[0]-a,l[1]-r,c[0]+i-l[0]+a,c[1]+o-l[1]+r),h=this.getPath(e,u),d=SU(this.attributes,"background");this.background=gU(this.group).maybeAppendByClassName(pW.background,"path").styles(wc(wc({},d),{path:h})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=Bc(TU(SU(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var a=Nc(i,["text"]);(this.label=gU(this.group).maybeAppendByClassName(pW.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(pW.label,(function(){return qF(e(n))})).style("text",e(n).toString()).selectAll("text").styles(a)},e.prototype.adjustLayout=function(){var t=Bc(this.point,2),e=t[0],n=t[1];this.group.attr("x",-e).attr("y",-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],c=this.createCorner([s[l].slice(-2),s[l+1].slice(-2)]);return s.splice.apply(s,kc([l+1,1],Bc(c),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=yU.apply(void 0,kc([],Bc(t),!1)),r=Bc(t,2),i=Bc(r[0],2),o=i[0],a=i[1],s=Bc(r[1],2),l=s[0],c=s[1],u=Bc(n?[l-o,[o,l]]:[c-a,[a,c]],2),h=u[0],d=Bc(u[1],2),p=d[0],f=d[1],g=h/2,m=e*(h/Math.abs(h)),v=m/2,y=m*Math.sqrt(3)/2*.8,E=Bc([p,p+g-v,p+g,p+g+v,f],5),_=E[0],b=E[1],S=E[2],x=E[3],T=E[4];return n?(this.point=[S,a-y],[["L",_,a],["L",b,a],["L",S,a-y],["L",x,a],["L",T,a]]):(this.point=[o+y,S],[["L",o,_],["L",o,b],["L",o+y,S],["L",o,x],["L",o,T]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?PF(this):CF(this)},e.prototype.bindEvents=function(){this.label.on(ms.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(CU),gW=function(t){function e(n){var r=t.call(this,VF({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new nl({})),r.label=r.background.appendChild(new qs({})),r}return Pc(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return mU(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=SU(this.attributes,"label");gU(this.label).maybeAppend(".label",(function(){return qF(e)})).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=Bc(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,c=s+n+i,u=SU(this.attributes,"background"),h=this.style,d=h.width,p=void 0===d?0:d,f=h.height,g=void 0===f?0:f,m=h.selected;this.background.attr(wc(wc({},u),{width:Math.max(l,p),height:Math.max(c,g),fill:m?this.selectedColor:"#fff"})),this.label.attr({x:o,y:(c-s)/2})},e.prototype.render=function(){this.renderLabel(),this.renderBackground()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("pointerenter",(function(){t.style.selected||t.background.attr("fill",t.hoverColor)})),this.addEventListener("pointerleave",(function(){t.style.selected||t.background.attr("fill",t.style.backgroundFill)}));var e=this;this.addEventListener("click",(function(){var n=t.style,r=n.label,i=n.value,o=n.onClick;null==o||o(i,{label:r,value:i},e)}))},e.defaultOptions={style:{value:"",label:"",cursor:"pointer"}},e}(CU),mW=function(t){function e(n){var r,i,o=t.call(this,VF({},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 nl({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new nl({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 Pc(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 mU(this.style.dropdownPadding)},enumerable:!1,configurable:!0}),e.prototype.renderSelect=function(){var t,e=this,n=this.style,r=n.width,i=n.height,o=n.bordered,a=n.showDropdownIcon,s=SU(this.attributes,"select"),l=SU(this.attributes,"placeholder");this.select.attr(wc(wc({width:r,height:i},s),{fill:"#fff",strokeWidth:o?1:0}));var c=this.dropdownPadding;a&&gU(this.select).maybeAppend(".dropdown-icon","path").style("d","M-5,-3.5 L0,3.5 L5,-3.5").style("transform","translate(".concat(r-10-c[1]-c[3],", ").concat(i/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var u=null===(t=this.style.options)||void 0===t?void 0:t.find((function(t){return t.value===e.currentValue})),h=wc({x:c[3]},l);gU(this.select).selectAll(".placeholder").data(u?[]:[1]).join((function(t){return t.append("text").attr("className","placeholder").styles(h).style("y",(function(){var t=this.getBBox();return(i-t.height)/2}))}),(function(t){return t.styles(h)}),(function(t){return t.remove()}));var d=SU(this.attributes,"optionLabel"),p=wc({x:c[3]},d);gU(this.select).selectAll(".value").data(u?[u]:[]).join((function(t){return t.append((function(t){return qF(t.label)})).attr("className","value").styles(p).style("y",(function(){var t=this.getBBox();return(i-t.height)/2}))}),(function(t){return t.styles(p)}),(function(t){return t.remove()}))},e.prototype.renderDropdown=function(){var t,e,n=this,r=this.style,i=r.width,o=r.height,a=r.options,s=r.onSelect,l=r.open,c=SU(this.attributes,"dropdown"),u=SU(this.attributes,"option"),h=this.dropdownPadding;gU(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(a,(function(t){return t.value})).join((function(t){return t.append((function(t){return new gW({className:"dropdown-item",style:wc(wc(wc({},t),u),{width:i-h[1]-h[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==s||s(t,e,r),n.dispatchEvent(new hs("change",{detail:{value:t,option:e,item:r}})),PF(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(h[3],", ").concat(h[0]+r,")"))}))}),(function(t){return t.update((function(t){return{selected:t.value===n.currentValue}}))}),(function(t){return t.remove()}));var d=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),p=c.spacing;this.dropdown.attr(wc({y:o+p,width:d.width+h[1]+h[3],height:d.height+h[0]+h[2]},c)),!l&&PF(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?PF(t.dropdown):CF(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||PF(t.dropdown)}))},e.defaultOptions={style:{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}(CU),vW=function(t){function e(n){var r=t.call(this,VF({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new nl({})),r.icon=r.appendChild(new qs({})),r}return Pc(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 mU(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=Bc(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.size,e=t/2,n=SU(this.attributes,"background");this.background.attr(wc({x:-e,y:-e,width:t,height:t},n))},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 fW({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}(CU),yW=function(t,e){return void 0===e&&(e="#565758"),new Js({style:{fill:e,anchor:"0.5 0.5",path:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},EW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e.prototype.arcPath=function(t,e,n){var r=Bc([n,n],2),i=r[0],o=r[1],a=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=Bc(a(-5/4*Math.PI),2),l=s[0],c=s[1],u=Bc(a(1/4*Math.PI),2),h=u[0],d=u[1];return"M".concat(l,",").concat(c,",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.color,e=this.iconSize,n=this.lineWidth,r=n+.5;gU(this.icon).maybeAppend(".reset","path").styles({stroke:t,lineWidth:n,path:this.arcPath(0,0,e/2-n),markerStart:yW(r,t)})},e}(vW),_W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=e/2,r=e/2/Math.pow(3,.5),i=[[0,0],[0,-r],[-n,0],[0,r],[0,0],[n,-r],[n,r],[0,0]];gU(this.icon).maybeAppend(".backward","polygon").styles({points:i,fill:t})},e}(vW),bW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=e/2,r=e/2/Math.pow(3,.5),i=[[0,0],[0,-r],[n,0],[0,r],[0,0],[-n,-r],[-n,r],[0,0]];gU(this.icon).maybeAppend(".forward","polygon").styles({points:i,fill:t})},e}(vW),SW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=e/3*Math.pow(3,.5)*.8,r=[[n,0],[-n/2,-e/2*.8],[-n/2,e/2*.8],[n,0]];gU(this.icon).maybeAppend(".play","polygon").styles({points:r,fill:t})},e}(vW),xW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=e/3,r=[[-n,-e/2],[-n,e/2],[-n/2,e/2],[-n/2,-e/2],[-n,-e/2],[n/2,-e/2],[n/2,e/2],[n,e/2],[n,-e/2]];gU(this.icon).maybeAppend(".pause","polygon").styles({points:r,fill:t})},e}(vW),TW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=this.lineWidth,r=n;gU(this.icon).maybeAppend(".left-line","line").styles({x1:-e/2,y1:-e/2,x2:-e/2,y2:e/2,stroke:t,lineWidth:n}),gU(this.icon).maybeAppend(".right-line","line").styles({x1:e/2,y1:-e/2,x2:e/2,y2:e/2,stroke:t,lineWidth:n}),gU(this.icon).maybeAppend(".left-arrow","line").styles({x1:0,y1:0,x2:-e/2+2*r,y2:0,stroke:t,lineWidth:n,markerEnd:yW(2*n,t)}),gU(this.icon).maybeAppend(".right-arrow","line").styles({x1:0,y1:0,x2:e/2-2*r,y2:0,stroke:t,lineWidth:n,markerEnd:yW(2*n,t)})},e}(vW),AW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=this.lineWidth;gU(this.icon).maybeAppend(".line","line").styles({x1:0,y1:-e/2,x2:0,y2:e/2,stroke:t,lineWidth:n});var r=n;gU(this.icon).maybeAppend(".left-arrow","line").styles({x1:-e/2-2*r,y1:0,x2:2*-r,y2:0,stroke:t,lineWidth:n,markerEnd:yW(2*n,t)}),gU(this.icon).maybeAppend(".right-arrow","line").styles({x1:e/2+2*r,y1:0,x2:2*r,y2:0,stroke:t,lineWidth:n,markerEnd:yW(2*n,t)})},e}(vW),RW=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},MW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=this.lineWidth,r=(e-2*n-n)/4,i=(e-2*n-n)/2,o=Bc([-e/2+n,e/2-2*n],2),a=o[0],s=o[1];gU(this.icon).maybeAppend(".coordinate","polyline").styles({points:RW(e),stroke:t,lineWidth:n}),gU(this.icon).maybeAppend(".line","polyline").styles({points:[[a,s],[a+r,s-i],[a+2*r,s],[a+4*r,s-2*i]],stroke:t,lineWidth:n})},e}(vW),CW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(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.color,n=this.iconSize,r=this.lineWidth,i=r,o=(n-i)/t.length,a=(n-2*i)/4,s=Bc([-n/2+2*i,n/2-i],2),l=s[0],c=s[1];gU(this.icon).maybeAppend(".coordinate","polyline").styles({points:RW(n),stroke:e,lineWidth:r}),gU(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 l+o*e})).style("y1",c).style("x2",(function(t){var e=t.index;return l+o*e})).style("y2",(function(t){var e=t.value;return c-a*e})).styles({y1:c,stroke:e,lineWidth:r})}))},e}(vW),PW=function(t){function e(e){var n=t.call(this,VF({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return Pc(e,t),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=this.lineWidth;gU(this.icon).maybeAppend(".split","line").styles({x1:0,y1:-e/2,x2:0,y2:e/2,stroke:t,lineWidth:n})},e}(vW),wW=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.showBackground=!1,e}return Pc(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return mU(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes.speed,n=void 0===e?1:e,r=function(t,e){return Ie(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})}(this.attributes,["x","y","width","height","size","color","speed"]),i=Fe(t,20,1/0),o=-i/2,a=wc(wc({},r),{x:o,y:-10,width:i,height:20,defaultValue:n,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}]});gU(this.icon).maybeAppend(".speed",(function(){return new mW({style:a})})).attr("className","speed").each((function(){this.update(a)}))},e.tag="SpeedSelect",e}(vW),NW=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new qs({})),n.currentType=n.attributes.type,n}return Pc(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.x,e.y,e.onChange;var n=Nc(e,["x","y","onChange"]);gU(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 Bc(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 Bc(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}(CU),OW=function(t){function e(e){var n=t.call(this,VF({},{style:{type:"play"}},e))||this;return n.toggles=[["play",SW],["pause",xW]],n}return Pc(e,t),e}(NW),IW=function(t){function e(e){var n=t.call(this,VF({},{style:{type:"range"}},e))||this;return n.toggles=[["range",TW],["value",AW]],n}return Pc(e,t),e}(NW),DW=function(t){function e(e){var n=t.call(this,VF({},{style:{type:"column"}},e))||this;return n.toggles=[["line",MW],["column",CW]],n}return Pc(e,t),e}(NW),BW={reset:EW,speed:wW,backward:_W,playPause:OW,forward:bW,selectionType:IW,chartType:DW,split:PW},kW=function(t){function e(n){var r=t.call(this,VF({},e.defaultOptions,n))||this;return r.background=r.appendChild(new nl({})),r.functions=r.appendChild(new qs({})),r}return Pc(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return mU(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.width,n=t.height,r=SU(this.attributes,"background");this.background.attr(wc({width:e,height:n},r))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,i=n.iconSize,o=n.iconSpacing,a=n.width,s=n.height,l=n.align,c=Bc(this.padding,4),u=c[1],h=c[3],d=r.reduce((function(t,e){return t.length&&e.length?t.concat.apply(t,kc(["split"],Bc(e),!1)):t.concat.apply(t,kc([],Bc(e),!1))}),[]),p=d.length*(i+o)-o,f={left:h+i/2,center:(a-p)/2+i/2,right:a-p-h-u+i/2}[l]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),d.forEach((function(t,n){var r,a=BW[t],l={x:n*(i+o)+f,y:s/2,size:i};if(a===wW?(l.speed=e.attributes.speed,l.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[OW,IW,DW].includes(a)?(l.onChange=function(n){return e.handleFunctionChange(t,{value:n})},a===OW&&(l.type="play"===e.attributes.state?"pause":"play"),a===IW&&(l.type="range"===e.attributes.selectionType?"value":"range"),a===DW&&(l.type="line"===e.attributes.chartType?"column":"line")):l.onClick=function(){return e.handleFunctionChange(t,{value:t})},a===wW){var c=e.getBBox(),u=c.x,h=c.y,d=l.x,p=l.y,g=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;g&&(e.speedSelect=new a({style:wc(wc({},l),{zIndex:100,x:u+d,y:h+p})}),g.appendChild(e.speedSelect))}else e.functions.appendChild(new a({style:l}))}))},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:{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}(CU),LW=function(t){function e(n){var r=t.call(this,VF({},e.defaultOptions,n))||this;return r.bindEvents(),r}return Pc(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}(Xs),FW=function(t){function e(n){return t.call(this,VF({},e.defaultOptions,n))||this}return Pc(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.width,n=t.height,r=SU(this.attributes,"background");gU(this).maybeAppend("background","rect").attr("className","background").styles(wc({x:-e/2,y:-n/2,width:e,height:n},r))},e.prototype.renderIcon=function(){var t=this.attributes.iconSize,e=SU(this.attributes,"icon"),n=t/2;gU(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(wc({x1:-1,y1:-n,x2:-1,y2:n},e)),gU(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(wc({x1:1,y1:-n,x2:1,y2:n},e))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.width,n=t.height,r=t.type,i=SU(this.attributes,"border"),o="start"===r?+e/2:-e/2;gU(this).maybeAppend("border","line").attr("className","border").styles(wc({x1:o,y1:-n/2,x2:o,y2:+n/2},i))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(CU);function UW(t,e){return"number"==typeof t?GW(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()?AU(n,"HH:mm\nYYYY-MM-DD"):AU(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(AU(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?AU(n,"DD\nYYYY-MM"):AU(n,"DD");case"week":return n.getDate()<=7?AU(n,"DD\nYYYY-MM"):AU(n,"DD");case"month":return[0,6].includes(n.getMonth())?AU(n,"MM月\nYYYY"):AU(n,"MM月");case"season":return[0].includes(n.getMonth())?AU(n,"MM月\nYYYY"):AU(n,"MM月");case"year":return AU(n,"YYYY");default:return AU(n,"YYYY-MM-DD HH:mm")}}(t,e)}function GW(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 VW=function(t){function e(n){var r=t.call(this,VF({},e.defaultOptions,n))||this;r.axis=r.appendChild(new ZV({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new XG({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new kW({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?kc([],Bc(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,c=i.playMode,u=i.values;return r.states={chartType:a,playMode:c,selectionType:o,speed:s,state:l},r.setByTimebarValues(u),r}return Pc(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.width,n=t.height,r=t.type,i=t.controllerHeight,o=Fe(+n-i,0,+n),a=new kF(0,+n-i,+e,i),s=0,l="time"===r?10:o;return{axisBBox:"chart"===r?new kF(0,o-(s=35),+e,s):new kF,controllerBBox:a,timelineBBox:new kF(0,"time"===r?o:o-l,+e,l-s)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=Bc(Array.isArray(t)?t:[0,t],2),o=i[0],a=i[1],s=r.length,l=r[Math.floor(o*s)],c=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==c?void 0:c.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=Bc(Array.isArray(t)?t:[void 0,t],2),a=o[0],s=o[1],l=i.find((function(t){return t.time===a})),c=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==c?void 0:c.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,a=Bc(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=Bc(Array.isArray(n)?n:[void 0,n],2),o=i[0],a=i[1],s=this.data,l=s.length,c="value"===r;return[(t=s.findIndex((function(t){return t.time===o})),c?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:c?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=Bc(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 FW({style:{type:t,height:e,iconSize:e/6}})}:function(){return new Qs({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,c=this.data,u=this.attributes,h=u.type,d=u.labelFormatter,p=SU(this.attributes,"chart");p.type;var f=Nc(p,["type"]),g="range"===s;if("time"===h)return wc({handleIconShape:function(){return new LW({})},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?GW(n):AU(n,"YYYY-MM-DD HH:mm:ss")},x:n,y:r,zIndex:1},f);var m="range"===s?5:0,v=c.map((function(t){return t.value}));return wc({handleIconOffset:m,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:v,sparklineType:l,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,x:n,y:r,zIndex:1},f)},e.prototype.renderChart=function(t){void 0===t&&(t=this.space.timelineBBox),this.timeline.update(this.getChartStyle(t))},e.prototype.updateSelection=function(){this.timeline.setValues(this.sliderValues,!0),this.handleSliderChange(this.sliderValues)},e.prototype.getAxisStyle=function(t){var e=this.data,n=this.attributes,r=n.interval,i=n.labelFormatter,o=SU(this.attributes,"axis"),a=t.x,s=t.y,l=t.width,c=kc(kc([],Bc(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}})),u=wc({startPos:[a,s],endPos:[a+l,s],data:c,labelFilter:function(t,e){return e<c.length-1},labelFormatter:function(t){var e=t.time;return i?i(e):UW(e,r)}},o);return u},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=SU(this.attributes,"controller"),l=this,c=wc(wc(wc({},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&&(c.functions=[["reset","speed"],["backward","playPause","forward"],["selectionType"]]),this.controller.update(c)},e.prototype.dispatchOnChange=function(t){var e=this.data,n=this.attributes.onChange,r=this.states,i=r.values,o=r.selectionType,a=Bc(i,2),s=a[0],l=a[1],c=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,c]:c)||null==n||n("range"===o?[s,c]:c)},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=Bc(o,2),c=l[0],u=l[1],h=n.findIndex((function(t){return t.time===c})),d=n.findIndex((function(t){return t.time===u}));-1===d&&(d=r);var p,f="backward"===t?-1:1;"range"===a?"acc"===s?(p=[h,d+f],-1===f&&h===d&&(p=[h,r])):p=[h+f,d+f]:p=[h,d+f];var g=function(t){var e=Bc(t.sort((function(t,e){return t-e})),2),n=e[0],i=e[1],o=function(t){return Fe(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)]}(p);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:{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}(CU);const WW=".legend-category-item-marker";const zW=t=>t?`${t.substring(0,1).toUpperCase()}${t.substring(1)}`:"";var HW=[],jW=[];function XW(t,e){if(e=e||{},void 0===t)throw new Error("insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).");var n,r=!0===e.prepend?"prepend":"append",i=void 0!==e.container?e.container:document.querySelector("head"),o=HW.indexOf(i);return-1===o&&(o=HW.push(i)-1,jW[o]={}),void 0!==jW[o]&&void 0!==jW[o][r]?n=jW[o][r]:(n=jW[o][r]=function(){var t=document.createElement("style");return t.setAttribute("type","text/css"),t}(),"prepend"===r?i.insertBefore(n,i.childNodes[0]):i.appendChild(n)),65279===t.charCodeAt(0)&&(t=t.substr(1,t.length)),n.styleSheet?n.styleSheet.cssText+=t:n.textContent+=t,n}var YW=XW,KW=XW;YW.insertCss=KW,"undefined"!=typeof document&&YW("\n .g6-component-contextmenu {\n border: 1px solid #e2e2e2;\n border-radius: 4px;\n font-size: 12px;\n color: #545454;\n background-color: rgba(255, 255, 255, 0.9);\n padding: 10px 8px;\n box-shadow: rgb(174, 174, 174) 0px 0px 10px;\n }\n .g6-contextmenu-ul {\n padding: 0;\n margin: 0;\n list-style: none;\n }\n .g6-loading-dom {\n border: 5px solid #e5e5e5;\n border-top: 5px solid #227EFF;\n border-radius: 50%;\n width: 25px;\n height: 25px;\n animation: turn-around 1.5s linear infinite;\n }\n @keyframes turn-around {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n");const qW=(t,e)=>{const n=t.getBoundingClientRect(),{clientX:r,clientY:i}=e;return Math.abs(r-n.x)<4&&Math.abs(i-n.y)<4?"left-top":Math.abs(r-n.x)<4&&Math.abs(i-n.y-n.height)<4?"left-bottom":Math.abs(r-n.x-n.width)<4&&Math.abs(i-n.y)<4?"right-top":Math.abs(r-n.x-n.width)<4&&Math.abs(i-n.y-n.height)<4?"right-bottom":Math.abs(r-n.x)<4?"left":Math.abs(i-n.y)<4?"top":Math.abs(i-n.y-n.height)<4&&"bottom"},$W={"left-top":"nwse-resize","right-bottom":"nwse-resize","right-top":"nesw-resize","left-bottom":"nesw-resize",left:"ew-resize",right:"ew-resize",top:"ns-resize",bottom:"ns-resize"};"undefined"!=typeof document&&YW("\n .g6-component-tooltip {\n border: 1px solid #e2e2e2;\n border-radius: 4px;\n font-size: 12px;\n color: #545454;\n background-color: rgba(255, 255, 255, 0.9);\n padding: 10px 8px;\n box-shadow: rgb(174, 174, 174) 0px 0px 10px;\n }\n .tooltip-type {\n padding: 0;\n margin: 0;\n }\n .tooltip-id {\n color: #531dab;\n }\n .g6-loading-dom {\n border: 5px solid #e5e5e5;\n border-top: 5px solid #227EFF;\n border-radius: 50%;\n width: 25px;\n height: 25px;\n animation: turn-around 1.5s linear infinite;\n }\n @keyframes turn-around {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n");const ZW=(t,e)=>{const n={};return Object.entries(t).forEach((([t,r])=>{const i=`${e}${t[0].toUpperCase()}${t.slice(1)}`;n[i]=r})),n},QW=["timestamp","time","date","datetime"],JW=["value","date"],tz=(t,e,n)=>{for(let n=0;n<e.length;n++){const r=e[n],i=null==t?void 0:t[r];if(i)return i}return n};const ez=.01,nz={stroke:"#000",strokeOpacity:.8,lineWidth:2,fillOpacity:1,fill:"#fff"};var rz=Object.freeze({__proto__:null,Fisheye:class extends zD{constructor(t){super(t),this.pointerDown=void 0,this.cacheCenter=void 0,this.dragPrePos=void 0,this.dragging=!1,this.cachedOriginPositions={},this.cachedTransientTexts={},this.initOriginPositions=()=>{const{graph:t}=this,e={};return t.getAllNodesData().forEach((t=>{e[t.id]={x:t.data.x,y:t.data.y,texts:[]}})),this.cachedOriginPositions=e,e},this.scaleRByDrag=pn(this.scaleRByDragMethod.bind(this),this.options.throttle,{leading:!0,trailing:!0}),this.scaleDByDrag=pn(this.scaleDByDragMethod.bind(this),this.options.throttle,{leading:!0,trailing:!0})}getDefaultCfgs(){return{key:`fisheye-${gn()}`,trigger:"mousemove",d:1.5,r:300,delegateStyle:tn(gF),showLabel:!0,maxD:5,minD:0,throttle:16,scaleRBy:"drag",scaleDBy:"drag",showDPercent:!0}}getEvents(){const t={pointerdown:this.onPointerDown,pointerup:this.onPointerUp,wheel:this.onWheel,afterlayout:this.initOriginPositions};switch(this.options.trigger){case"click":return Object.assign(Object.assign({},t),{click:this.magnify});case"drag":return Object.assign(Object.assign({},t),{pointermove:this.onPointerMove});default:return Object.assign(Object.assign({},t),{pointermove:this.magnify})}}init(t){super.init(t);const{r:e,d:n}=this.options;this.cachedTransientTexts={},this.initOriginPositions(),this.r2=e*e,this.molecularParam=(n+1)*e}isInLensDelegate(t,e){const{cx:n,cy:r,r:i}=t.style;return e.x>=n-i&&e.x<=n+i&&e.y>=r-i&&e.y<=r+i}onPointerUp(t){this.pointerDown=void 0,this.cacheCenter=void 0,this.dragging=!1}onPointerMove(t){!this.dragging&&this.pointerDown&&(this.dragging=!0),this.pointerDown&&this.moveDelegate(this.delegate,t)}onPointerDown(t){const{delegate:e}=this;!e||e.destroyed?(this.cacheCenter={x:t.canvas.x,y:t.canvas.y},this.magnify(t)):this.cacheCenter={x:e.attr("cx"),y:e.attr("cy")},this.pointerDown={x:t.canvas.x,y:t.canvas.y},this.dragging=!1,this.dragPrePos={x:t.canvas.x,y:t.canvas.y}}moveDelegate(t,e){this.isInLensDelegate(t,{x:e.canvas.x,y:e.canvas.y})&&(this.delegateCenterDiff={x:e.canvas.x-this.pointerDown.x,y:e.canvas.y-this.pointerDown.y},this.magnify(e,this.cacheCenter))}onWheel(t){const{delegate:e,options:n}=this,{scaleDBy:r,scaleRBy:i}=n;e&&!e.destroyed&&("wheel"!==r&&"wheel"!==i||this.isInLensDelegate(e,{x:t.canvas.x,y:t.canvas.y})&&("wheel"===i&&this.scaleRByWheel(t),"wheel"===r&&this.scaleDByWheel(t)))}scaleRByWheel(t){if(!t||!t.originalEvent)return;t.preventDefault&&t.preventDefault();const{graph:e,options:n}=this;let r;const{delegate:i,maxR:o,minR:a,d:s}=n;let{r:l}=n;const c=(i?{x:i.attr("cx"),y:i.attr("cy")}:void 0)||{x:t.canvas.x,y:t.canvas.y};r=t.originalEvent.deltaY<0?.95:1/.95;const u=e.canvas.context.config.canvas.height;(l>(o||u)&&r>1||l<(a||.05*u)&&r<1)&&(r=1),l*=r,this.options.r=l,this.r2=l*l,this.molecularParam=(s+1)*l,this.delegateCenterDiff=void 0,this.magnify(t,c)}scaleRByDragMethod(t){if(!t)return;const{dragPrePos:e,graph:n,options:r}=this,{maxR:i,minR:o,d:a}=r;let s,{r:l}=r;s=t.canvas.x-e.x<0?.95:1/.95;const c=n.canvas.context.config.canvas,[u=(null==c?void 0:c.width)||500,h=(null==c?void 0:c.height)||500]=n.getSize();(l>(i||h)&&s>1||l<(o||.05*h)&&s<1)&&(s=1),l*=s,this.options.r=l,this.r2=l*l,this.molecularParam=(a+1)*l,this.magnify(t),this.dragPrePos={x:t.canvas.x,y:t.canvas.y}}scaleDByWheel(t){if(!t&&!t.originalEvent)return;t.preventDefault&&t.preventDefault();let e=0;e=t.originalEvent.deltaY<0?-.1:.1;const{d:n,maxD:r,minD:i,r:o}=this.options,a=n+e;if(a<r&&a>i){this.options.d=a,this.molecularParam=(a+1)*o;const{delegate:e}=this,n=e?{x:e.attr("cx"),y:e.attr("cy")}:void 0;this.delegateCenterDiff=void 0,this.magnify(t,n)}}scaleDByDragMethod(t){const{d:e,maxD:n,minD:r,r:i}=this.options,o=e+(t.canvas.x-this.dragPrePos.x>0?.1:-.1);o<n&&o>r&&(this.options.d=o,this.molecularParam=(o+1)*i,this.magnify(t)),this.dragPrePos={x:t.canvas.x,y:t.canvas.y}}magnify(t,e){var n;this.restoreCache();const{r2:r,graph:i,cachedOriginPositions:o,cachedTransientTexts:a,molecularParam:s,delegateCenterDiff:l,options:c}=this,u=Object.keys(o).map((t=>({id:t,data:{x:o[t].x,y:o[t].y}}))),{r:h,d:d,showLabel:p,trigger:f}=c,g=i.getAllNodesData(),m=g.length,v=i.getCanvasByClient(t.client);let y=e?{x:e.x,y:e.y}:{x:v.x,y:v.y};!this.dragging||"mousemove"!==f&&"click"!==f||(y=this.cacheCenter),l&&(y.x+=l.x,y.y+=l.y),this.updateDelegate(y,h,t);for(let t=0;t<m;t++){const e=g[t],{x:l,y:c}=o[e.id];if(isNaN(l)||isNaN(c))continue;const f=(l-y.x)*(l-y.x)+(c-y.y)*(c-y.y);if(!isNaN(f)&&f<r&&0!==f){const t=Math.sqrt(f),r=s*t/(d*t+h),g=(l-y.x)/t,m=(c-y.y)/t,v=g*r+y.x,E=m*r+y.y,_={id:e.id,data:{x:v,y:E}},b=e.data.label||(null===(n=e.data.labelShape)||void 0===n?void 0:n.text);if(p&&2*t<h){const t=`node-text-${e.id}`,n=a[t];if(n)n.attr({x:_.data.x,y:_.data.y}),n.show(),o[e.id].texts.push(n);else if(b){const n=i.drawTransient("text",t,{style:{text:b,x:_.data.x,y:_.data.y,textAlign:"center",textBaseline:"middle",fill:"#000",lineWidth:1,fontSize:12,isBillboard:!0,lod:-1}});a[t]=n,o[e.id].texts.push(n)}}u[e.id]=_}else o[e.id]||(o[e.id]={x:l,y:c,texts:[]})}i.updateNodePosition(Object.values(u))}restoreCache(){const t=Object.assign({},this.cachedOriginPositions);return Object.values(this.cachedOriginPositions).forEach((t=>{var e;null===(e=t.texts)||void 0===e||e.forEach((t=>t.hide()))})),t}updateParams(t){const{r:e,d:n,trigger:r,minD:i,maxD:o,minR:a,maxR:s,scaleDBy:l,scaleRBy:c}=t;isNaN(t.r)||(this.options.r=e,this.r2=e*e),isNaN(n)||(this.options.d=n),isNaN(o)||(this.options.maxD=o),isNaN(i)||(this.options.minD=i),isNaN(s)||(this.options.maxR=s),isNaN(a)||(this.options.minR=a);const{graph:u,dPercentText:h,options:d}=this,{d:p,r:f}=d;this.molecularParam=(p+1)*f,"mousemove"!==r&&"click"!==r&&"drag"!==r||(this.options.trigger=r),"drag"!==l&&"wheel"!==l&&"unset"!==l||(this.options.scaleDBy=l,u.drawTransient("circle","lens-shape",{action:"remove"}),h&&u.drawTransient("text","lens-text-shape",{action:"remove"})),"drag"!==c&&"wheel"!==c&&"unset"!==c||(this.options.scaleRBy=c,u.drawTransient("circle","lens-shape",{action:"remove"}),h&&u.drawTransient("text","lens-text-shape",{action:"remove"}))}updateDelegate(t,e,n){const{graph:r,dPercentText:i}=this;let o=this.delegate;if(!o||o.destroyed){const n=this.options.delegateStyle||gF;o=r.drawTransient("circle","lens-shape",{style:Object.assign({r:e/1.5,cx:t.x,cy:t.y},n)})}else o.attr({cx:t.x,cy:t.y,r:e/1.5});const{d:a,minD:s,maxD:l,showDPercent:c}=this.options;if(c){const n=Math.round((a-s)/(l-s)*100),o=t.y+e/1.5+16;if(!i||i.destroyed){const e=r.drawTransient("text","lens-text-shape",{style:{text:`${n}%`,x:t.x,y:o,fill:"#aaa",stroke:"#fff",lineWidth:1,fontSize:12}});this.dPercentText=e}else i.attr({text:`${n}%`,x:t.x,y:o})}if(this.delegate=o,"drag"!==this.options.trigger){if("drag"===this.options.scaleRBy){if(!this.pointerDown)return;this.scaleRByDrag(n)}if("drag"===this.options.scaleDBy){if(!this.pointerDown)return;this.scaleDByDrag(n)}}}clear(){const{graph:t,delegate:e,cachedOriginPositions:n,dPercentText:r}=this;this.restoreCache(),t.updateNodePosition(Object.keys(n).map((t=>({id:t,data:{x:n[t].x,y:n[t].y}})))),e&&!e.destroyed&&t.drawTransient("circle","lens-shape",{action:"remove"}),r&&!r.destroyed&&t.drawTransient("text","lens-text-shape",{action:"remove"})}destroy(){this.clear()}},Grid:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`grid-${gn()}`,img:mF,follow:!0}}init(t){super.init(t);const e=t.getZoom(),n=t.container,r=this.canvas||n.firstChild.nextSibling,[i,o]=t.getSize(),a=this.options.img||mF,s=yP("<div class='g6-grid-container' style=\"position: absolute; left:0;top:0;right:0;bottom:0;overflow: hidden;\"></div>"),l=yP(`<div \n class='g6-grid' \n style='position:absolute;\n transform-origin: 0% 0% 0px;\n background-image: ${a};\n user-select: none\n '></div>`);s.appendChild(l),EP(s,{width:`${i}px`,height:`${o}px`,left:`${n.offsetLeft}px`,top:`${n.offsetTop}px`}),EP(l,{width:i/e+"px",height:o/e+"px",left:"0px",top:"0px"}),n.insertBefore(s,r),this.container=s}getEvents(){return{viewportchange:this.updateGrid}}updateGrid(t){const e=this.container;let{matrix:n}=t;n||(n=[1,0,0,0,1,0,0,0,1]);const r=this.options.follow;EP(e,{transform:`matrix(${n[0]}, ${n[1]}, ${n[3]}, ${n[4]}, ${r?n[6]:"0"}, ${r?n[7]:"0"})`})}getContainer(){return this.container}destroy(){var t;super.destroy(),null===(t=this.canvas)||void 0===t||t.destroy();const e=this.container;(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)}},getCategoryByApiName:AF,History:class extends zD{constructor(t){super(),this.stackSize=0,this.stackActive=!0,this.withoutStackingCounter=0;const{enableStack:e,stackCfg:n}=an(this.getDefaultCfgs(),t);this.enableStack=e,this.cfg=n,this.isBatching=!1,this.undoStack=new RF(this.cfg.stackSize),this.redoStack=new RF(this.cfg.stackSize),this.initBatchCommands()}getDefaultCfgs(){return{enableStack:!0,stackCfg:{stackSize:0,stackActive:!0,includes:[],excludes:[],ignoreAdd:!1,ignoreRemove:!1,ignoreUpdate:!1,ignoreStateChange:!1,ignoreLayerChange:!1,ignoreDisplayChange:!1}}}init(t){super.init(t),this.clear()}getUndoStack(){return this.undoStack.toArray()}getRedoStack(){return this.redoStack.toArray()}getStack(){return{redoStack:this.getRedoStack(),undoStack:this.getUndoStack()}}clear(){this.clearUndoStack(),this.clearRedoStack()}clearUndoStack(){this.undoStack.clear()}clearRedoStack(){this.redoStack.clear()}isEnable(){return this.enableStack}push(t,e=vF.undo,n=!0){if(this.stackActive){if(e===vF.undo){if(n&&this.clearRedoStack(),ln(t))return;this.undoStack.push(t),this.initBatchCommands()}else this.redoStack.push(t);this.graph.emit("history:change",t,e,n)}else console.error("Stacking operations are currently paused. Unable to push to the stack.")}pauseStack(){this.withoutStackingCounter++,1===this.withoutStackingCounter&&(this.stackActive=!1)}resumeStack(){this.withoutStackingCounter>0&&this.withoutStackingCounter--,0===this.withoutStackingCounter&&(this.stackActive=!0)}undo(){if(this.isEnable()){const t=this.undoStack.pop();if(t){this.push(t,vF.redo,!1);for(let e=t.length-1;e>=0;e--)t[e].undo(this.graph)}}return this}redo(){if(this.isEnable()){const t=this.redoStack.pop();t&&(this.push(t,vF.undo,!1),Ce(t,(t=>t.redo(this.graph))))}return this}canUndo(){return this.isEnable()&&this.undoStack.size()>0}canRedo(){return this.isEnable()&&this.redoStack.size()>0}initBatchCommands(){this.batchCommands=[]}startHistoryBatch(){if(this.isBatching)throw new Error("Ensure that historyBatch processing is stopped before starting.");this.initBatchCommands(),this.isBatching=!0}stopHistoryBatch(){if(!this.isBatching)throw new Error("Ensure that historyBatch processing is started before stopping.");this.push(this.batchCommands),this.isBatching=!1}historyBatch(t){this.startHistoryBatch(),t(),this.stopHistoryBatch()}getEvents(){return{afteritemchange:this.handleUpdateHistory,afteritemzindexchange:this.handleUpdateHistory,afteritemstatechange:this.handleUpdateHistory,afteritemvisibilitychange:this.handleUpdateHistory,aftercollapsecombo:this.handleUpdateHistory,afterexpandcombo:this.handleUpdateHistory}}handleUpdateHistory(t){const{apiName:e,changes:n}=t;if((!n||0!==n.length)&&this.shouldPushToStack(e)){if(this.batchCommands=[...this.batchCommands,...xF.create(t)],this.isBatching)return;this.push(this.batchCommands)}}shouldPushToStack(t){const{includes:e=[],excludes:n=[]}=this.cfg;if(!this.enableStack||!this.stackActive)return!1;if(e.includes(t))return!0;if(n.includes(t))return!1;let r=AF(t);return!r||(r="ignore"+je(r),!this.cfg[r])}notify(t,e,...n){t.emit(e,n)}},Legend:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`legend-${gn()}`,container:null,className:"g6-category-legend",orientation:"horizontal",selectedState:"selected",activeState:"active"}}getEvents(){return{afterrender:this.updateLegend}}init(t){super.init(t);const{size:e="fit-content",orientation:n}=this.options,r=t.getSize();if(this.size=e,this.selectedTypes={node:new Set,edge:new Set},this.activeType={node:void 0,edge:void 0},this.selectedIds={node:new Set,edge:new Set},this.activeIds={node:new Set,edge:new Set},this.styleCache={node:{},edge:{}},"fit-content"===e&&(this.size=["horizontal"===n?r[0]:"fit-content","horizontal"===n?"fit-content":r[1]]),"number"==typeof e[0])this.size[0]=e[0];else if(e[0].includes("%")){const t=Number(e[0].replace("%"))/100||1;this.size[0]=r[0]*t}if("number"==typeof e[1])this.size[1]=e[1];else if("100%"===e[1]){const t=Number(e[0].replace("%"))/100||1;this.size[1]=r[1]*t}}updateLegend(){const{size:t}=this;if(!this.canvas){const e=["fit-content"===t[0]?0:t[0],"fit-content"===t[1]?0:t[1]],{canvas:n,background:r,renderer:i="canvas"}=this.options;n?this.canvas=n:(this.wrapper||(this.wrapper=this.createWrapper()),this.canvas=fR(i,this.wrapper,e[0],e[1],void 0,{background:r})),this.canvas.addEventListener("click",(t=>{var e;if("document"!==(null===(e=t.target)||void 0===e?void 0:e.nodeName))return;const{graph:n,options:r}=this,{activeState:i,selectedState:o}=r;if(this.activeIds.node.size&&n.clearItemState(Array.from(this.activeIds.node),i),this.activeIds.edge.size&&n.clearItemState(Array.from(this.activeIds.edge),i),this.activeIds={node:new Set,edge:new Set},o){const{node:t,edge:e}=this.selectedIds;n.clearItemState(Array.from(t),o),n.clearItemState(Array.from(e),o),this.selectedIds={node:new Set,edge:new Set}}this.selectedTypes.node.forEach((t=>{const e=this.canvas.getRoot().querySelector(`#marker-node-${t}`);if(!e)return;const n=this.styleCache.node[t].lineWidth;e.style.lineWidth=n})),this.selectedTypes.edge.forEach((t=>{const e=this.canvas.getRoot().querySelector(`#marker-edge-${t}`);if(!e)return;const n=this.styleCache.edge[t].lineWidth;e.style.lineWidth=n})),this.selectedTypes={node:new Set,edge:new Set},this.activeType={node:void 0,edge:void 0}}))}this.canvas.ready.then((()=>{this.nodeLegend=this.upsertLegend("node"),this.edgeLegend=this.upsertLegend("edge"),this.updateLayout()}))}createWrapper(){const{options:t,graph:e,size:n}=this,{container:r,className:i}=t;let o;De(r)&&(o=document.getElementById(r)),o||(o=e.container);const a=["fit-content"===n[0]?0:n[0],"fit-content"===n[1]?0:n[1]],s=yP(`<div class='${i}' style='width: ${a[0]}px; height: ${a[1]}px; overflow: hidden;'></div>`);return o.appendChild(s),s}upsertLegend(t="node"){const{graph:e,options:n,canvas:r}=this,{node:i,edge:o,orientation:a}=n,s="node"===t?i:o;if(!(null==s?void 0:s.enable))return;const{title:l,typeField:c,labelFormatter:u,rows:h=1,cols:d=4,colPadding:p=5,rowPadding:f=8,padding:g=[0,0,0,0],labelStyle:m={},markerStyle:v}=s,y={shape:"node"===t?"circle":"line",size:10,color:"#ccc",fillOpacity:.3},E=WR(g),_={};Object.keys(m).forEach((t=>{_[`itemLabel${je(t)}`]=m[t]}));const b=_.itemLabelSpacing,{size:S,grid:x}=this.getLegendSize(h,d,E),T="node"===t?e.getAllNodesData():e.getAllEdgesData(),A=new Set,R={};T.map((t=>{if(t.data[c]){const e=t.data[c];A.add(e),R[e]||(R[e]=t)}}));const M=Array.from(A),C=M.map((t=>({typeValue:t,label:u?u(t):t}))),P=["fill","stroke","fillOpacity","opacity","lineWidth","shadow","shadowBlur","size"],w={};let N;if(v){const e=Object.assign({},y,v||{}),{shape:n}=e,r=Nc(e,["shape"]);N=this.getShapeConfig(t,n),Object.keys(r).forEach((t=>{const e=r[t];let n=e;"object"==typeof e?n=t=>e[t.typeValue]||e[t.typeValue].size||10:Se(e)&&(n=t=>e(t.typeValue)),"color"===t?(w.itemMarkerFill=w.itemMarkerFill||n,w.itemMarkerStroke=w.itemMarkerStroke||n):w[`itemMarker${zW(t)}`]=n}))}else{const n=e.canvas.getRoot(),r=n.getElementById(`${t}-group`)||n,i={},o={x1:-10,y1:0,x2:10,y2:0};M.forEach((t=>{const e=r.find((e=>e.getAttribute("data-item-id")===R[t].id)).querySelector("#keyShape");i[t]={shape:e.nodeName,style:Object.assign(Object.assign({},e.attributes),o)}})),P.forEach((t=>{w[`itemMarker${zW(t)}`]=e=>{const{typeValue:n}=e;let r=t;return"size"===t&&(i[n].style.r&&(r="r"),r="width"),i[n].style[r]||y[t]}})),N=t=>{const{typeValue:e}=t,n=i[e].shape||y.shape;return{Shape:BR[n],style:i[e].style}}}const O=new hW({style:Object.assign(Object.assign(Object.assign({x:E[3],y:E[0],data:C,layout:"flex",orientation:a,gridRow:x[0],gridCol:x[1],colPadding:p,rowPadding:f,width:S[0],height:S[1],titleText:l,itemSpacing:b},_),w),{itemMarker:e=>{const{Shape:n,style:r}=N(e),{typeValue:i}=e;return this.styleCache[t][i]=r,()=>new n({style:r,id:`marker-${t}-${i}`})},mouseenter:e=>this.handleMouseEnter(e,M,c,t,T),mouseleave:e=>this.handleMouseLeave(e,M,c,t),click:e=>this.handleClick(e,M,c,t,T)})});return r.appendChild(O),O}updateLayout(){const{nodeLegend:t,edgeLegend:e,options:n,size:r}=this;if(t&&e){const{node:r,edge:i,orientation:o}=n,{order:a=1,padding:s}=r,{order:l=2,padding:c}=i;let u,h;a<l?(u={padding:WR(s),legend:t},h={padding:WR(c),legend:e}):(h={padding:WR(s),legend:t},u={padding:WR(c),legend:e});const d=u.legend.getRenderBounds();if("horizontal"===o){u.legend.translateLocal([0,-d.min[1]+u.padding[0]]);const t=u.legend.childNodes[1].childNodes[0].childNodes[0].getRenderBounds();if(t){const e=t.max[1]+u.padding[2];h.legend.translateLocal([0,e])}}else{u.legend.translateLocal([-d.min[0]+u.padding[3],0]);const t=u.legend.childNodes[1].childNodes[0].childNodes[0].childNodes[1].getRenderBounds().max[0]+u.padding[1];h.legend.translateLocal([t,0])}}if("fit-content"===r[0]||"fit-content"===r[1]){const t=this.canvas.getRoot().getRenderBounds(),e=["fit-content"===r[0]?t.max[0]-t.min[0]:r[0],"fit-content"===r[1]?t.max[1]-t.min[1]:r[1]];this.canvas.resize(e[0],e[1]),this.wrapper&&(this.wrapper.style.width=`${e[0]}px`,this.wrapper.style.height=`${e[1]}px`)}}getShapeConfig(t,e){const n="node"===t?Xs:Qs,r="node"===t?{r:10,width:20,height:20,lineWidth:1}:{lineWidth:4,x1:-10,y1:0,x2:10,y2:0};if("string"==typeof e){const t=BR[e]||n;return()=>({Shape:t,style:r})}return t=>{const i=e[t.typeValue];if("string"==typeof i){return{Shape:BR[i],style:r}}{const{type:t,style:e}=i;return{Shape:BR[t]||n,style:Object.assign(Object.assign({},r),e)}}}}getLegendSize(t,e,n){const{graph:r,options:i,size:o}=this,{orientation:a}=i;let[s,l]=o,c=[t,e];const[u,h]=r.getSize();return"horizontal"===a?("fit-content"===o[0]&&(s=u),"fit-content"===o[1]&&(l=50)):("fit-content"===o[0]&&(s=50),"fit-content"===o[1]&&(l=h),c=[e,t]),s+=n[1]+n[3],l+=n[0]+n[2],{size:[s,l],grid:c}}handleMouseEnter(t,e,n,r,i){const{graph:o,options:a}=this,{activeState:s}=a;if(!s)return;const{index:l}=t.__data__,c=e[l];this.activeType[n]=c;const u=i.filter((t=>t.data[n]===c)).map((t=>t.id));o.setItemState(u,s,!0),u.forEach((t=>this.activeIds[r].add(t))),t.querySelector(WW).style.lineWidth=this.styleCache[r][c].lineWidth+2||4}handleMouseLeave(t,e,n,r){const{graph:i,options:o}=this,{activeState:a}=o;if(!a)return;this.activeType[n]=void 0;const s=i.findIdByState(r,a,!0),{index:l}=t.__data__,c=e[l];this.selectedTypes[r].has(c)?t.querySelector(WW).style.lineWidth=this.styleCache[r][c].lineWidth+4||6:t.querySelector(WW).style.lineWidth=this.styleCache[r][c].lineWidth||1,i.setItemState(s,a,!1),s.forEach((t=>this.activeIds[r].delete(t)))}handleClick(t,e,n,r,i){const{graph:o,options:a}=this,{selectedState:s}=a;if(!s)return;const{index:l}=t.__data__,c=e[l],u=i.filter((t=>t.data[n]===c)).map((t=>t.id));this.selectedTypes[r].has(c)?(this.selectedTypes[r].delete(c),u.forEach((t=>this.selectedIds[r].delete(t))),o.setItemState(u,s,!1),t.querySelector(WW).style.lineWidth=4):(this.selectedTypes[r].add(c),u.forEach((t=>this.selectedIds[r].add(t))),o.setItemState(u,s,!0),t.querySelector(WW).style.lineWidth=this.styleCache[r][c].lineWidth+4||6)}destroy(){var t;super.destroy(),null===(t=this.canvas)||void 0===t||t.destroy()}},Menu:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`menu-${gn()}`,offsetX:6,offsetY:6,handleMenuClick:void 0,getContent:t=>"\n <ul class='g6-contextmenu-ul'>\n <li class='g6-contextmenu-li'>菜单项1</li>\n <li class='g6-contextmenu-li'>菜单项2</li>\n </ul>\n ",shouldBegin:t=>!0,onHide:()=>!0,itemTypes:["node","edge","combo"],trigger:"click",container:null,loadingContent:"<div class='g6-loading-dom'></div>",liHoverStyle:{color:"white","background-color":"#227EFF"}}}getEvents(){return"click"===this.options.trigger?{click:this.onMenuShow,touchend:this.onMenuShow}:{contextmenu:this.onMenuShow}}init(t){super.init(t);const e=this.options.className;YW(`\n .g6-contextmenu-li:hover{\n ${Object.keys(this.options.liHoverStyle).map((t=>`${t}:${this.options.liHoverStyle[t]};`)).join("")}\n }\n `);const n=yP(`<div class=${e||"g6-component-contextmenu"}></div>`);EP(n,{top:"0px",position:"absolute",visibility:"hidden"});let r=this.options.container;r||(r=this.graph.container),De(r)&&(r=document.getElementById(r)),r.appendChild(n),this.menu=n}onMenuShow(t){return Oc(this,void 0,void 0,(function*(){const e=this;t.preventDefault(),e.onMenuHide();const n=this.options.itemTypes;if(t.itemId){if(t.itemId&&t.itemType&&-1===n.indexOf(t.itemType))return void e.onMenuHide()}else if(-1===n.indexOf("canvas"))return void e.onMenuHide();if(!(0,this.options.shouldBegin)(t))return;const r=this.menu,i=this.graph,o=this.options.getContent(t),a=i.getSize()[0],s=i.getSize()[1],l=r.getBoundingClientRect(),c=this.options.offsetX||0,u=this.options.offsetY||0,h=this.graph.container.offsetTop,d=this.graph.container.offsetLeft;let p=t.viewport.x+d+c,f=t.viewport.y+h+u-55;if(p+l.width>a&&(p-=l.width+d+c),f+l.height>s&&(f-=l.height+h+u),EP(r,{top:`${f}px`,left:`${p}px`,visibility:"visible"}),De(o))r.innerHTML=o;else if(o instanceof HTMLElement)r.innerHTML=o.outerHTML;else{if(De(this.options.loadingContent)?r.innerHTML=this.options.loadingContent:r.innerHTML=this.options.loadingContent.outerHTML,t.itemId==this.currentTarget&&this.asyncMenu||(this.currentTarget=t.itemId,this.asyncMenu=yield this.options.getContent(t)),t.itemId!=this.currentTarget)return;De(this.asyncMenu)?r.innerHTML=this.asyncMenu:r.innerHTML=this.asyncMenu.outerHTML}this.removeMenuEventListener();const g=this.options.handleMenuClick;g&&(this.handleMenuClickWrapper=e=>{g(e.target,t.itemId,i)},r.addEventListener("click",this.handleMenuClickWrapper));let m="click"===this.options.trigger;const v=t=>{m?m=!1:e.onMenuHide()};document.body.addEventListener("click",v),this.handler=v}))}removeMenuEventListener(){const t=this.handleMenuClickWrapper,e=this.handler;if(t){this.menu.removeEventListener("click",t),this.handleMenuClickWrapper=null}e&&document.body.removeEventListener("click",e)}onMenuHide(){const t=this.menu;t&&(EP(t,{visibility:"hidden"}),this.removeMenuEventListener())}destroy(){const t=this.menu;if(this.removeMenuEventListener(),t){let e=this.options.container;e||(e=this.graph.container),De(e)&&(e=document.getElementById(e)),e.removeChild(t)}}},Minimap:class extends zD{constructor(t){super(t),this.itemMap=new Map,this.visibleCache={},this.handleUpdateCanvas=en((t=>{this.destroyed||this.updateCanvas()}),100,!1),this.handleVisibilityChange=t=>{const{ids:e,value:n}=t;e.forEach((t=>{this.visibleCache[t]=n})),this.debounceCloneVisibility()},this.debounceCloneVisibility=en((()=>{const t=this.canvas.getRoot().getElementById("node-group"),e=this.canvas.getRoot().getElementById("edge-group");((null==t?void 0:t.childNodes)||[]).concat((null==e?void 0:e.childNodes)||[]).forEach((t=>{var e;const n=null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"data-item-id");this.visibleCache.hasOwnProperty(n)&&(this.visibleCache[n]?t.childNodes.forEach((t=>t.show())):!1===this.visibleCache[n]&&t.childNodes.forEach((t=>t.hide())))})),this.visibleCache={}}),50,!1)}getDefaultCfgs(){return{key:`minimap-${gn()}`,container:null,className:"g6-minimap",viewportClassName:"g6-minimap-viewport",mode:"default",padding:8,size:[200,120],delegateStyle:{fill:"#40a9ff",stroke:"#096dd9"},refresh:!0,hideEdge:!1}}getEvents(){return{afteritemstatechange:this.handleUpdateCanvas,afterlayout:this.handleUpdateCanvas,viewportchange:this.handleUpdateCanvas,afteritemchange:this.handleUpdateCanvas,afteritemvisibilitychange:this.handleVisibilityChange}}disableRefresh(){this.options.refresh=!1}enableRefresh(){this.options.refresh=!0,this.updateCanvas()}initViewport(){const{canvas:t,options:e,destroyed:n,graph:r}=this,{size:i,viewportClassName:o}=e;if(n)return;const a=t.context.config.container,s=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,l=navigator.userAgent.toLowerCase().indexOf("safari")>-1,c=yP(`\n <div\n class=${o}\n style='position:absolute;\n left:0;\n top:0;\n border: 2px solid #1980ff;\n box-sizing:border-box;\n background: rgba(0, 0, 255, 0.1);\n cursor:move'\n draggable=${!l&&!s}\n />`);let u=0,h=0,d=!1,p=!1;const f=l||s?"mousedown":"dragstart";this.container.addEventListener("mousemove",(t=>{const e=qW(c,t);e?(this.container.style.cursor=$W[e],c.style.cursor=$W[e]):(this.container.style.cursor="unset",c.style.cursor="move")})),c.addEventListener(f,(t=>{var e,n;if(p=qW(c,t),!p){if(t.dataTransfer){const r=new Image;r.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' %3E%3Cpath /%3E%3C/svg%3E",null===(n=(e=t.dataTransfer).setDragImage)||void 0===n||n.call(e,r,0,0);try{t.dataTransfer.setData("text/html","view-port-minimap")}catch(e){t.dataTransfer.setData("text","view-port-minimap")}}this.options.refresh=!1,t.target===c&&(d=!0,u=t.clientX,h=t.clientY)}}).bind(this),!1);const g=t=>{const{style:e}=c,n=parseInt(e.left,10),o=parseInt(e.top,10),a=parseInt(e.width,10),s=parseInt(e.height,10);if(p){const{clientX:e,clientY:r}=t,i={left:n,top:o,width:a,height:s};return p.includes("left")?(i.left=`${e}px`,i.width=n+a-e+"px"):p.includes("right")&&(i.width=e-n+"px"),p.includes("top")?(i.top=`${r}`,i.height=""+(o+s-r)):p.includes("bottom")&&(i.height=""+(r-o)),void EP(c,i)}if(!d||xe(t.clientX)||xe(t.clientY))return;const{ratio:l}=this,f=r.getZoom();let g=u-t.clientX,m=h-t.clientY;(n-g<0||n-g+a>=i[0])&&(g=0),(o-m<0||o-m+s>=i[1])&&(m=0),r.translate({dx:g*f/l,dy:m*f/l}).then((()=>{this.updateViewport()})),u=t.clientX,h=t.clientY};l||s||c.addEventListener("drag",g.bind(this),!1);const m=()=>{d=!1,p=!1,this.options.refresh=!0},v=l||s?"mouseup":"dragend";c.addEventListener(v,m.bind(this),!1);c.addEventListener("wheel",(t=>{}),!1),a.addEventListener("mouseleave",m.bind(this)),a.addEventListener("mouseup",m.bind(this)),(l||s)&&a.addEventListener("mousemove",g.bind(this),!1),this.viewport=c,a.appendChild(c)}updateViewport(){if(this.destroyed)return;this.viewport||this.initViewport();const{options:t,graph:e,dx:n,dy:r,ratio:i,viewport:o}=this,{size:a}=t,s=e.canvas.context.config.canvas,[l=(null==s?void 0:s.scrollWidth)||500,c=(null==s?void 0:s.scrollHeight)||500]=e.getSize(),u=e.getZoom(),h=e.canvas.getRoot().getRenderBounds(),d=e.getViewportByCanvas({x:h.min[0],y:h.min[1]}),p=e.getViewportByCanvas({x:h.max[0],y:h.max[1]});let f=l*i/u,g=c*i/u,m=0,v=0;d.x<0?(m=-d.x/l*f+n,p.x<l&&(f=a[0]-m)):f-=d.x/l*f-n,d.y<0?(v=-d.y/c*g+r,p.y<c&&(g=a[1]-v)):g-=d.y/c*g-r;const y=f+m;y>a[0]&&(f-=y-a[0]);const E=g+v;E>a[1]&&(g-=E-a[1]),EP(o,{left:`${m}px`,top:`${v}px`,width:`${f}px`,height:`${g}px`})}updateGraphShapes(){const{graph:t,options:e,canvas:n}=this,r=t.canvas.getRoot();if(r.destroyed)return;let i;n.removeChildren();const{hideEdge:o}=e;o?(i=new qs,n.appendChild(i),r.children.forEach((t=>{"edge-group"!==t.id&&i.appendChild(t.cloneNode(!0))}))):(i=r.cloneNode(!0),n.appendChild(i))}updateKeyShapes(){const{graph:t,options:e,canvas:n}=this,{hideEdge:r}=e,i=n.getRoot();r||Ce(t.getAllEdgesData(),(t=>{this.updateOneEdgeKeyShape(t,i)})),Ce(t.getAllNodesData(),(t=>{this.updateOneNodeKeyShape(t,i)}));const o=t.getAllCombosData();if(o&&o.length){let t=i.find((t=>"combo-group"===t.id));t||(t=new qs({id:"combo-group"}),i.appendChild(t)),setTimeout((()=>{this.destroyed||(Ce(o,(e=>{this.updateOneNodeKeyShape(e,t)})),null==t||t.sort(),null==t||t.toBack(),this.updateCanvas())}),250)}this.clearDestroyedShapes()}updateOneNodeKeyShape(t,e){var n;const{itemMap:r=new Map,graph:i}=this,o=i.canvas.getRoot().find((t=>"node-group"===t.id));if(!o)return;let{minimapItem:a,graphItem:s}=r.get(t.id)||{};a&&!a.destroyed||(s=null===(n=o.find((e=>e.getAttribute("data-item-id")===t.id)))||void 0===n?void 0:n.find((t=>"keyShape"===t.id)),a=s.cloneNode(),a.id=`minimap-keyShape-${t.id}`,e.appendChild(a),r.set(t.id,{graphItem:s,minimapItem:a}));const l=s.getRenderBounds();if(!l)return;const c=s.attributes,u=Object.assign(Object.assign({},c),{cx:l.center[0],cy:l.center[1]});a.toFront();const h=a.get("type");"rect"!==h&&"image"!==h&&"text"!==h||(u.x=l.min[0],u.y=l.min[1]),Object.keys(u).forEach((t=>{a.style[t]=u[t]})),i.getItemVisible(t.id)?a.show():a.hide();const d=t.data.depth;isNaN(d)||a.set("zIndex",d),this.itemMap=r}updateDelegateShapes(){const{graph:t,options:e,canvas:n}=this,{hideEdge:r}=e,i=n.getRoot();r||Ce(t.getAllEdgesData(),(t=>{this.updateOneEdgeKeyShape(t,i)})),Ce(t.getAllNodesData(),(t=>{this.updateOneNodeDelegateShape(t,i)}));const o=t.getAllCombosData();if(o&&o.length){const t=i.find((t=>"comboGroup"===t.get("name")))||i.addGroup({name:"comboGroup"});setTimeout((()=>{this.destroyed||(Ce(o,(e=>{this.updateOneNodeKeyShape(e,t)})),null==t||t.sort(),null==t||t.toBack(),this.updateCanvas())}),250)}this.clearDestroyedShapes()}clearDestroyedShapes(){const{itemMap:t=new Map}=this;t.forEach(((e,n)=>{const{minimapItem:r,graphItem:i}=e||{};i.destroyed&&r&&(r.remove(),t.delete(n))}))}updateOneEdgeKeyShape(t,e){var n;const{itemMap:r=new Map,graph:i}=this,o=i.canvas.getRoot().find((t=>"edge-group"===t.id));if(!o)return;let{minimapItem:a,graphItem:s}=r.get(t.id)||{};if(a&&!a.destroyed){const{path:t,x1:e,x2:n,y1:r,y2:i}=s.style;a.style.path=t,a.style.x1=e,a.style.x2=n,a.style.y1=r,a.style.y2=i}else s=null===(n=o.find((e=>e.getAttribute("data-item-id")===t.id)))||void 0===n?void 0:n.find((t=>"keyShape"===t.id)),a=s.cloneNode(),a.id=`minimap-keyShape-${t.id}`,e.appendChild(a);i.getItemVisible(t.id)?a.show():a.hide(),r.set(t.id,{graphItem:s,minimapItem:a}),this.itemMap=r}updateOneNodeDelegateShape(t,e){var n;const{itemMap:r=new Map,options:i,graph:o}=this,{delegateStyle:a}=i,s=o.canvas.getRoot().find((t=>"node-group"===t.id));if(!s)return;let{minimapItem:l,graphItem:c}=r.get(t.id)||{};c||(c=null===(n=s.find((e=>e.getAttribute("data-item-id")===t.id)))||void 0===n?void 0:n.find((t=>"keyShape"===t.id)));const u=c.getRenderBounds(),h=Object.assign({x:u.min[0],y:u.min[1],width:u.max[0]-u.min[0],height:u.max[1]-u.min[1]},a);!l||l.destroyed?(l=new nl({style:Object.assign(Object.assign(Object.assign({},c.attributes),h),a),id:`minimap-delegate-${t.id}`}),e.appendChild(l)):Object.keys(h).forEach((t=>l.style[t]=h[t])),l.toFront(),o.getItemVisible(t.id)?l.show():l.hide(),r.set(t.id,{graphItem:c,minimapItem:l}),this.itemMap=r}init(t){super.init(t);this.initContainer().then((()=>this.updateCanvas()))}initContainer(){var t,e;const{graph:n,options:r}=this,{size:i,className:o}=r;let a=r.container;const s=yP(`<div class='${o}' style='width: ${i[0]}px; height: ${i[1]}px; overflow: hidden;'></div>`);De(a)&&(a=document.getElementById(a)),a?a.appendChild(s):n.container.appendChild(s),this.container&&(this.container.remove(),null===(t=this.viewport)||void 0===t||t.remove(),this.viewport=void 0,null===(e=this.canvas)||void 0===e||e.destroy()),this.container=s;const l=createDom('<div class="g6-minimap-container" style="position: relative;"></div>');s.appendChild(l),l.addEventListener("dragenter",(t=>{t.preventDefault()})),l.addEventListener("dragover",(t=>{t.preventDefault()}));const c=n.canvas;return this.canvas=fR("canvas",l,i[0],i[1],c.devicePixelRatio),this.canvas.ready}updateCanvas(){if(this.destroyed)return;const{graph:t,canvas:e,options:n}=this,{refresh:r,size:i,padding:o,mode:a}=n;if(!r||t.destroyed||e.destroyed)return;switch(a){case"default":this.updateGraphShapes();break;case"keyShape":this.updateKeyShapes();break;case"delegate":this.updateDelegateShapes()}const s=e.getRoot();if(!s)return;const l=s.getRenderBounds(),c=t.canvas.getRoot().getRenderBounds(),u=c.max[0]-c.min[0],h=c.max[1]-c.min[1],d=Math.min((i[0]-2*o)/u,(i[1]-2*o)/h),p=e.viewport2Canvas({x:0,y:0});e.getCamera().setFocalPoint(p.x,p.y),e.getCamera().setPosition(p.x,p.y),e.getCamera().setZoom(d),e.getCamera().setPosition(l.center[0],l.center[1]),e.getCamera().setFocalPoint(l.center[0],l.center[1]);const{x:f,y:g}=e.canvas2Viewport({x:l.min[0],y:l.min[1]});this.ratio=d,this.dx=f,this.dy=g,this.updateViewport()}getCanvas(){return this.canvas}getViewport(){return this.viewport}getContainer(){return this.container}destroy(){var t;super.destroy(),null===(t=this.canvas)||void 0===t||t.destroy();const e=this.container;(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)}},Toolbar:class extends zD{constructor(t){super(t),this.ToolbarDOM=yP("<div></div>"),this.ContainerDOM=yP("<div></div>")}getDefaultCfgs(){return{handleClick:void 0,getContent:t=>'\n <ul class=\'g6-component-toolbar\'>\n <li code=\'zoomIn\'>\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24">\n <path d="M658.432 428.736a33.216 33.216 0 0 1-33.152 33.152H525.824v99.456a33.216 33.216 0 0 1-66.304 0V461.888H360.064a33.152 33.152 0 0 1 0-66.304H459.52V296.128a33.152 33.152 0 0 1 66.304 0V395.52H625.28c18.24 0 33.152 14.848 33.152 33.152z m299.776 521.792a43.328 43.328 0 0 1-60.864-6.912l-189.248-220.992a362.368 362.368 0 0 1-215.36 70.848 364.8 364.8 0 1 1 364.8-364.736 363.072 363.072 0 0 1-86.912 235.968l192.384 224.64a43.392 43.392 0 0 1-4.8 61.184z m-465.536-223.36a298.816 298.816 0 0 0 298.432-298.432 298.816 298.816 0 0 0-298.432-298.432A298.816 298.816 0 0 0 194.24 428.8a298.816 298.816 0 0 0 298.432 298.432z"></path>\n </svg>\n </li>\n <li code=\'zoomOut\'>\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24">\n <path d="M639.936 416a32 32 0 0 1-32 32h-256a32 32 0 0 1 0-64h256a32 32 0 0 1 32 32z m289.28 503.552a41.792 41.792 0 0 1-58.752-6.656l-182.656-213.248A349.76 349.76 0 0 1 480 768 352 352 0 1 1 832 416a350.4 350.4 0 0 1-83.84 227.712l185.664 216.768a41.856 41.856 0 0 1-4.608 59.072zM479.936 704c158.784 0 288-129.216 288-288S638.72 128 479.936 128a288.32 288.32 0 0 0-288 288c0 158.784 129.216 288 288 288z" p-id="3853"></path>\n </svg>\n </li>\n <li code=\'realZoom\'>\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="24">\n <path d="M384 320v384H320V320h64z m256 0v384H576V320h64zM512 576v64H448V576h64z m0-192v64H448V384h64z m355.968 576H92.032A28.16 28.16 0 0 1 64 931.968V28.032C64 12.608 76.608 0 95.168 0h610.368L896 192v739.968a28.16 28.16 0 0 1-28.032 28.032zM704 64v128h128l-128-128z m128 192h-190.464V64H128v832h704V256z"></path>\n </svg>\n </li>\n <li code=\'autoZoom\'>\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="24">\n <path d="M684.288 305.28l0.128-0.64-0.128-0.64V99.712c0-19.84 15.552-35.904 34.496-35.712a35.072 35.072 0 0 1 34.56 35.776v171.008h170.944c19.648 0 35.84 15.488 35.712 34.432a35.072 35.072 0 0 1-35.84 34.496h-204.16l-0.64-0.128a32.768 32.768 0 0 1-20.864-7.552c-1.344-1.024-2.816-1.664-3.968-2.816-0.384-0.32-0.512-0.768-0.832-1.088a33.472 33.472 0 0 1-9.408-22.848zM305.28 64a35.072 35.072 0 0 0-34.56 35.776v171.008H99.776A35.072 35.072 0 0 0 64 305.216c0 18.944 15.872 34.496 35.84 34.496h204.16l0.64-0.128a32.896 32.896 0 0 0 20.864-7.552c1.344-1.024 2.816-1.664 3.904-2.816 0.384-0.32 0.512-0.768 0.768-1.088a33.024 33.024 0 0 0 9.536-22.848l-0.128-0.64 0.128-0.704V99.712A35.008 35.008 0 0 0 305.216 64z m618.944 620.288h-204.16l-0.64 0.128-0.512-0.128c-7.808 0-14.72 3.2-20.48 7.68-1.28 1.024-2.752 1.664-3.84 2.752-0.384 0.32-0.512 0.768-0.832 1.088a33.664 33.664 0 0 0-9.408 22.912l0.128 0.64-0.128 0.704v204.288c0 19.712 15.552 35.904 34.496 35.712a35.072 35.072 0 0 0 34.56-35.776V753.28h170.944c19.648 0 35.84-15.488 35.712-34.432a35.072 35.072 0 0 0-35.84-34.496z m-593.92 11.52c-0.256-0.32-0.384-0.768-0.768-1.088-1.088-1.088-2.56-1.728-3.84-2.688a33.088 33.088 0 0 0-20.48-7.68l-0.512 0.064-0.64-0.128H99.84a35.072 35.072 0 0 0-35.84 34.496 35.072 35.072 0 0 0 35.712 34.432H270.72v171.008c0 19.84 15.552 35.84 34.56 35.776a35.008 35.008 0 0 0 34.432-35.712V720l-0.128-0.64 0.128-0.704a33.344 33.344 0 0 0-9.472-22.848zM512 374.144a137.92 137.92 0 1 0 0.128 275.84A137.92 137.92 0 0 0 512 374.08z"></path>\n </svg>\n </li>\n </ul>\n ',zoomSensitivity:10,minZoom:1e-5,maxZoom:1e3}}getContainer(){const{container:t}=this.options;return this.ContainerDOM="string"==typeof t?document.getElementById(t):this.graph.container,this.ContainerDOM}init(t){super.init(t),this.getContainer(),this.insertStyle();const{getContent:e,className:n,handleClick:r,position:i}=this.options,o=e(t);this.ToolbarDOM="string"==typeof o?yP(o):o,this.ToolbarDOM.setAttribute("class",n||"g6-component-toolbar"),this.ContainerDOM.appendChild(this.ToolbarDOM),this.ToolbarDOM.addEventListener("click",(e=>{const n=(t=>{if(!t)return[];if(t.composedPath)return t.composedPath();const e=[];let n=t.target;for(;n;){if(e.push(n),"HTML"===n.tagName)return e.push(document,window),e;n=n.parentElement}return e})(e).filter((t=>"LI"===t.nodeName));if(0===n.length)return;const i=n[0].getAttribute("code");i&&(r?r(i,t):this.handleDefaultOperator(i))})),i&&EP(this.ToolbarDOM,{top:`${i.y}px`,left:`${i.x}px`})}insertStyle(){"undefined"!=typeof document&&YW("\n .g6-component-toolbar {\n position: absolute;\n list-style-type: none;\n padding: 6px;\n left: 0px;\n top: 0px;\n background-color: rgba(255, 255, 255, 0.9);\n border: 1px solid #e2e2e2;\n border-radius: 4px;\n font-size: 12px;\n color: #545454;\n margin: 0;\n }\n .g6-component-toolbar li {\n float: left;\n text-align: center;\n width: 35px;\n height: 24px;\n cursor: pointer;\n list-style-type:none;\n list-style: none;\n margin-left: 0px;\n }\n .g6-component-toolbar li .icon {\n opacity: 0.7;\n }\n .g6-component-toolbar li .icon:hover {\n opacity: 1;\n }\n ")}zoomOut(){const{zoomSensitivity:t}=this.options,e=100/(100+t);1!==e&&this.graph.zoom(e)}zoomIn(){const{zoomSensitivity:t}=this.options,e=(100+t)/100;1!==e&&this.graph.zoom(e)}realZoom(){this.graph.zoomTo(1)}autoZoom(){this.graph.fitView()}handleDefaultOperator(t){switch(t){case"zoomOut":this.zoomOut();break;case"zoomIn":this.zoomIn();break;case"realZoom":this.realZoom();break;case"autoZoom":this.autoZoom()}}destroy(){const{ToolbarDOM:t,ContainerDOM:e}=this,{handleClick:n}=this.options;t&&e.removeChild(t),n&&t.removeEventListener("click",n),super.destroy()}},Tooltip:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`tooltip-${gn()}`,offsetX:0,offsetY:0,getContent:t=>`\n <div>\n <h4 class='tooltip-type'>类型: ${t.itemType}</h4>\n <span class='tooltip-id'>ID: ${t.itemId}</span>\n </div>\n `,shouldBegin:t=>!0,itemTypes:["node","edge","combo"],trigger:"pointerenter",fixToNode:void 0,loadingContent:"<div class='g6-loading-dom'></div>"}}getEvents(){return"click"===this.options.trigger?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,afterremoveitem:this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerenter":this.onPointerEnter,"node:pointerleave":this.onPointerLeave,"node:pointermove":this.onPointerMove,"edge:pointerenter":this.onPointerEnter,"edge:pointerleave":this.onPointerLeave,"edge:pointermove":this.onPointerMove,"combo:pointerenter":this.onPointerEnter,"combo:pointerleave":this.onPointerLeave,"combo:pointermove":this.onPointerMove,afterremoveitem:this.onPointerLeave,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}init(t){super.init(t);const e=yP(`<div class='${this.options.className||"g6-component-tooltip"}'></div>`);EP(e,{position:"absolute",visibility:"hidden",display:"none"}),"click"!==this.options.trigger&&(e.addEventListener("pointerenter",(t=>{EP(e,{visibility:"visible",display:"unset"})})),e.addEventListener("pointerleave",(t=>{this.hideTooltip()})));let n=this.options.container;n||(n=this.graph.container),De(n)&&(n=document.getElementById(n)),n.appendChild(e),this.tooltip=e,this.container=n}onClick(t){if(t.itemId&&t.itemType&&-1===this.options.itemTypes.indexOf(t.itemType))return;const{itemId:e}=t;this.currentTarget===e?(this.currentTarget=null,this.hideTooltip(),this.graph.emit("tooltipchange",{itemId:e,action:"hide"})):(this.currentTarget=e,this.showTooltip(t))}onPointerEnter(t){if(t.itemId&&t.itemType&&-1===this.options.itemTypes.indexOf(t.itemType))return;const{itemId:e}=t;this.currentTarget=e,this.showTooltip(t),this.graph.emit("tooltipchange",{itemId:t.itemId,action:"show"})}onPointerMove(t){t.itemId&&t.itemType&&-1===this.options.itemTypes.indexOf(t.itemType)||this.currentTarget&&t.itemId!==this.currentTarget&&this.showTooltip(t)}onPointerLeave(){this.hideTooltip(),this.graph.emit("tooltipchange",{itemId:this.currentTarget,action:"hide"}),this.currentTarget=null}clearContainer(){this.container.innerHTML=""}showTooltip(t){return Oc(this,void 0,void 0,(function*(){if(clearTimeout(this.hidenTimer),!t.itemId)return;if(t.itemType&&-1===this.options.itemTypes.indexOf(t.itemType))return;const e=this.options.getContent(t),n=this.tooltip;EP(n,{display:"unset"});const r=this.updatePosition(t);if(EP(n,{visibility:"visible",left:`${r.x}px`,top:`${r.y}px`}),De(e))n.innerHTML=e;else if(e instanceof HTMLElement)this.clearContainer(),this.container.appendChild(e);else{if(this.asyncTooltip=null,De(this.options.loadingContent)?n.innerHTML=this.options.loadingContent:n.innerHTML=this.options.loadingContent.outerHTML,this.asyncTooltip&&t.itemId===this.currentAsyncTarget||(this.currentAsyncTarget=t.itemId,this.asyncTooltip=yield this.options.getContent(t)),t.itemId!=this.currentAsyncTarget)return;De(this.asyncTooltip)?n.innerHTML=this.asyncTooltip:(this.clearContainer(),this.container.appendChild(this.asyncTooltip))}}))}hideTooltip(){const t=this.tooltip;t&&(this.hidenTimer=setTimeout((()=>{EP(t,{visibility:"hidden",display:"none"})}),100),t.addEventListener("pointerenter",(t=>{clearTimeout(this.hidenTimer)})),t.addEventListener("pointerleave",(e=>{EP(t,{visibility:"hidden",display:"none"})})))}updatePosition(t){const e=this.options.shouldBegin,n=this.tooltip;if(!e(t))return void EP(n,{visibility:"hidden",display:"none"});const r=this.graph,i=r.getSize()[0],o=r.getSize()[1],a=this.options.offsetX||0,s=this.options.offsetY||0;let l={x:t.viewport.x,y:t.viewport.y};const c=this.options.fixToNode;if(t.itemType&&"node"===t.itemType&&c){const e=r.getRenderBBox(t.itemId),i=e.max[0]-e.min[0],o=e.max[1]-e.min[1];if(De(c))switch(c){case"right":l={x:e.min[0]+1*i,y:e.min[1]-.5*o};break;case"rightTop":case"topRight":l={x:e.min[0]+1*i,y:e.min[1]-1*o};break;case"rightBottom":case"bottomRight":l={x:e.min[0]+1*i,y:e.min[1]};break;case"bottom":l={x:e.min[0]+0*i,y:e.min[1]};break;case"top":{const t=n.getBoundingClientRect();l={x:e.min[0]+0*i,y:e.min[1]-t.height};break}case"left":{const t=n.getBoundingClientRect();l={x:e.min[0]-t.width,y:e.min[1]-.5*o};break}case"leftTop":case"topLeft":{const t=n.getBoundingClientRect();l={x:e.min[0]-t.width,y:e.min[1]-1*o};break}case"leftBottom":case"bottomLeft":{const t=n.getBoundingClientRect();l={x:e.min[0]-t.width,y:e.min[1]};break}default:l={x:e.min[0]+1*i,y:e.min[1]-.5*o},console.warn(`The '${this.options.fixToNode}' fixToNode position configuration is not supported, please use 'top'|'left'| 'right'| 'bottom'| 'topLeft'| 'leftTop'| 'topRight'| 'rightTop'| 'bottomLeft'| 'leftBottom'| 'bottomRight'| 'rightBottom', or use array to config, like: [0,5,1]`)}else Re(c)&&c.length>=2&&(l={x:e.min[0]+i*c[0],y:e.min[1]-o*(1-c[1])})}const{x:u,y:h}=this.graph.getViewportByCanvas(l),d=this.graph.container,p={x:u+d.offsetLeft+a,y:h+d.offsetTop+s},f=n.getBoundingClientRect();return u+f.width+a>i&&(p.x-=f.width+a),h+f.height+s>o&&(p.y-=f.height+s,p.y<0&&(p.y=0)),p}destroy(){this.container.removeChild(this.tooltip)}},Timebar:class extends zD{get padding(){return WR(this.options.padding)}get containerShape(){const{width:t,height:e}=this.options,[n,r,i,o]=this.padding;return{x:o,y:n,width:t+o+r,height:e+n+i+30}}get data(){const{graph:t}=this;return{nodes:t.getAllNodesData(),edges:t.getAllEdgesData()}}constructor(t){super(t),this.itemTypes=["node","edge"]}getDefaultCfgs(){return{axisStyle:{},className:"g6-component-timebar",controllerStyle:{},data:[],filterItemTypes:["node"],filterType:"modify",getTimeFromItem:t=>tz(t.data,QW,void 0),getTimeFromData:t=>tz(t,QW,void 0),getValueFromItem:t=>tz(t,JW,0),height:60,padding:10,position:"bottom",timebarType:"time",width:200}}getEvents(){return{afterrender:this.updateTimebar,afterchangedata:this.handleDataChange}}init(t){super.init(t)}reset(){this.timebar.reset()}backward(){this.timebar.backward()}play(){this.timebar.play()}pause(){this.timebar.pause()}forward(){this.timebar.forward()}destroy(){this.canvas.destroy(),super.destroy()}get container(){const{container:t}=this.options;if(t instanceof HTMLElement)return t;const e=document.getElementById(t);return e||this.graph.container}createWrapper(){const{options:t}=this,{className:e}=t,{width:n,height:r}=this.containerShape,i=yP(`<div class="${e}" style="width: ${n}px;height: ${r}"></div>`);return this.container.appendChild(i),i}createCanvas(){const{width:t,height:e}=this.containerShape;return fR("canvas",this.wrapper,t,e,void 0,{background:"#fff"})}updateTimebar(){this.wrapper||(this.wrapper=this.createWrapper()),this.canvas||(this.canvas=this.createCanvas()),this.canvas.ready.then((()=>{this.renderTimebar()}))}updatePosition(){const{graph:t}=this,{x:e,y:n}=this.options,{width:r}=this.containerShape,{position:i}=this.options,[o,a]=t.getSize();if(!e&&!n&&"bottom"===i)this.wrapper.style.top=a+"px",this.wrapper.style.left=(o-r)/2+"px"}renderTimebar(){const{x:t,y:e}=this.containerShape,n=this.options,{x:r,y:i,axisStyle:o={},chartStyle:a={},className:s,container:l,controllerStyle:c={},data:u,filter:h,filterItemTypes:d,filterType:p,getTimeFromData:f,getTimeFromItem:g,getValueFromData:m,onChange:v,padding:y,position:E,shouldIgnore:_,timebarType:b,type:S}=n,x=Nc(n,["x","y","axisStyle","chartStyle","className","container","controllerStyle","data","filter","filterItemTypes","filterType","getTimeFromData","getTimeFromItem","getValueFromData","onChange","padding","position","shouldIgnore","timebarType","type"]),T=u.map((t=>({time:(null==f?void 0:f(t))||(null==t?void 0:t.time),value:(null==m?void 0:m(t))||(null==t?void 0:t.value)}))),A=Object.assign(Object.assign(Object.assign(Object.assign({x:t,y:e,data:T,type:b,onChange:t=>{this.handleValuesChange(t),null==v||v(t)}},ZW(o,"axis")),ZW(c,"controller")),ZW(a,"chart")),x);this.timebar?this.timebar.update(A):this.timebar=this.canvas.appendChild(new VW({style:A})),this.updatePosition()}handleDataChange(){this.graphDataCache=an({},this.data),this.updateTimebar(),this.processValuesChange()}handleValuesChange(t){this.processValuesChange(t)}processValuesChange(t=this.timebar.values){const{filter:e}=this.options;e?e(t):this.filter(t)}filter(t){(!this.graphDataCache||0===this.graphDataCache.nodes.length&&0===this.graphDataCache.edges.length)&&(this.graphDataCache=an({},this.data));const{filterType:e,filterItemTypes:n,shouldIgnore:r,getTimeFromItem:i}=this.options,o={nodes:{enter:[],exit:[]},edges:{enter:[],exit:[]}},a=a=>{const s=`${a}s`;if(!(s in this.data))return;this.graphDataCache[s].forEach((l=>{const c="node"===a?this.graph.getNodeData(l.id):this.graph.getEdgeData(l.id),u=i(l,a),h=void 0!==c,d=c&&this.graph.getItemVisible(l.id),p=()=>{("modify"!==e||h)&&("visibility"!==e||d)||o[s].enter.push(l)};(()=>{if("edge"!==a)return!1;const{source:t,target:e}=l,n=[...o.nodes.enter,...this.data.nodes],r=n.find((e=>e.id===t)),i=n.find((t=>t.id===e));return!r||!i})()||(n.includes(a)?void 0===u||(null==r?void 0:r(l,a,t))||(e=>Array.isArray(t)?e>=t[0]&&e<=t[1]:e===t)(u)?p():this.data[s].find((({id:t})=>t===l.id))&&("modify"===e&&h||"visibility"===e&&d)&&o[s].exit.push(l):p())}))};this.itemTypes.forEach((t=>a(t))),this.mutateGraph(o)}mutateGraph(t){const{filterType:e}=this.options,n=n=>{const{enter:r,exit:i}=t[`${n}s`];"modify"===e?(this.graph.addData(n,r),this.graph.removeData(n,i.map((t=>t.id)))):(this.graph.showItem(r.map((t=>t.id))),this.graph.hideItem(i.map((t=>t.id))))};(t=>{const e=console.error;console.error=()=>{},null==t||t(),console.error=e})((()=>{this.itemTypes.forEach((t=>n(t)))}))}},Snapline:class extends zD{setTolerance(t){this.tolerance=t}getTolerance(){return this.tolerance}getDrawLineIdByDrawLine(t){if(t)return`${t.line[0].x}-${t.line[0].y}-${t.line[1].x}-${t.line[1].y}`}getDrawLineIdByPoints([t,e]){return`${t.x}-${t.y}-${e.x}-${e.y}`}addAlignLinesForChoose(){function t(t,e,n){return t>=e-n&&t<=e+n}this.vContrastPoints.forEach((e=>{t(this.draggingBBox.min[0],e.x,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:e.x,y:this.draggingBBox.center[1]}],lp:"left"},offset:{x:e.x-this.draggingBBox.min[0],y:0}}),t(this.draggingBBox.center[0],e.x,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:e.x,y:this.draggingBBox.center[1]}],lp:"vcenter"},offset:{x:e.x-this.draggingBBox.center[0],y:0}}),t(this.draggingBBox.max[0],e.x,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:e.x,y:this.draggingBBox.center[1]}],lp:"right"},offset:{x:e.x-this.draggingBBox.max[0],y:0}})})),this.hContrastPoints.forEach((e=>{t(this.draggingBBox.min[1],e.y,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:this.draggingBBox.min[0],y:e.y}],lp:"top"},offset:{x:0,y:e.y-this.draggingBBox.min[1]}}),t(this.draggingBBox.center[1],e.y,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:this.draggingBBox.center[0],y:e.y}],lp:"hcenter"},offset:{x:0,y:e.y-this.draggingBBox.center[1]}}),t(this.draggingBBox.max[1],e.y,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:this.draggingBBox.max[0],y:e.y}],lp:"bottom"},offset:{x:0,y:e.y-this.draggingBBox.max[1]}})}))}initAlignLinesForChoose(){this.alignLinesForChoose.v=[],this.alignLinesForChoose.h=[];let t=[];this.graph.getAllCombosData().forEach((e=>{t.push(e.id)})),this.graph.getAllNodesData().forEach((e=>{t.push(e.id)})),t=t.filter((t=>t!==this.dragItemId)),t.forEach((t=>{const e=this.graph.getRenderBBox(t,!0);Math.abs(this.draggingBBox.min[0]-e.min[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.min[0],y:e.center[1]},{x:e.min[0],y:this.draggingBBox.center[1]}],lp:"left"},offset:{x:this.draggingBBox.min[0]-e.min[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.min[0]-e.center[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:e.center[0],y:this.draggingBBox.center[1]}],lp:"left"},offset:{x:this.draggingBBox.min[0]-e.center[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.min[0]-e.max[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.max[0],y:e.center[1]},{x:e.max[0],y:this.draggingBBox.center[1]}],lp:"left"},offset:{x:this.draggingBBox.min[0]-e.max[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.center[0]-e.min[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.min[0],y:e.center[1]},{x:e.min[0],y:this.draggingBBox.center[1]}],lp:"vcenter"},offset:{x:this.draggingBBox.center[0]-e.min[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.center[0]-e.center[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:e.center[0],y:this.draggingBBox.center[1]}],lp:"vcenter"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.center[0]-e.max[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.max[0],y:e.center[1]},{x:e.max[0],y:this.draggingBBox.center[1]}],lp:"vcenter"},offset:{x:this.draggingBBox.center[0]-e.max[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.max[0]-e.min[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.min[0],y:e.center[1]},{x:e.min[0],y:this.draggingBBox.center[1]}],lp:"right"},offset:{x:this.draggingBBox.max[0]-e.min[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.max[0]-e.center[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:e.center[0],y:this.draggingBBox.center[1]}],lp:"right"},offset:{x:this.draggingBBox.max[0]-e.center[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.max[0]-e.max[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.max[0],y:e.center[1]},{x:e.max[0],y:this.draggingBBox.center[1]}],lp:"right"},offset:{x:this.draggingBBox.max[0]-e.max[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.min[1]-e.max[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.max[1]},{x:this.draggingBBox.center[0],y:e.max[1]}],lp:"top"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.min[1]-e.max[1]}}),Math.abs(this.draggingBBox.min[1]-e.center[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:this.draggingBBox.center[0],y:e.center[1]}],lp:"top"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.min[1]-e.center[1]}}),Math.abs(this.draggingBBox.min[1]-e.min[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.max[1]},{x:this.draggingBBox.center[0],y:e.max[1]}],lp:"top"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.min[1]-e.min[1]}}),Math.abs(this.draggingBBox.center[1]-e.max[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.max[1]},{x:this.draggingBBox.center[0],y:e.max[1]}],lp:"hcenter"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.center[1]-e.max[1]}}),Math.abs(this.draggingBBox.center[1]-e.center[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:this.draggingBBox.center[0],y:e.center[1]}],lp:"hcenter"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.center[1]-e.min[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.min[1]},{x:this.draggingBBox.center[0],y:e.min[1]}],lp:"hcenter"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.center[1]-e.min[1]}}),Math.abs(this.draggingBBox.max[1]-e.max[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.max[1]},{x:this.draggingBBox.center[0],y:e.max[1]}],lp:"bottom"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.max[1]-e.max[1]}}),Math.abs(this.draggingBBox.max[1]-e.center[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:this.draggingBBox.center[0],y:e.center[1]}],lp:"bottom"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.max[1]-e.center[1]}}),Math.abs(this.draggingBBox.max[1]-e.min[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.min[1]},{x:this.draggingBBox.center[0],y:e.min[1]}],lp:"bottom"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.max[1]-e.min[1]}})}))}chooseAlignLine(){if(this.alignLinesForChoose.v.length+this.alignLinesForChoose.h.length===0)return{v:void 0,h:void 0};let t=[],e=[];const n=Math.min(...this.alignLinesForChoose.v.map((t=>t.offset.x))),r=Math.min(...this.alignLinesForChoose.h.map((t=>t.offset.y)));t=this.alignLinesForChoose.v.filter((t=>t.offset.x===n)),e=this.alignLinesForChoose.h.filter((t=>t.offset.y===r));{const n=t.some((t=>"vcenter"===t.dl.lp)),r=t.some((t=>"left"===t.dl.lp));t=t.filter((t=>"vcenter"===t.dl.lp||("left"===t.dl.lp?!(n||!r):"right"===t.dl.lp&&(!n&&!r))));const i=e.some((t=>"hcenter"===t.dl.lp)),o=e.some((t=>"top"===t.dl.lp));e=e.filter((t=>"hcenter"===t.dl.lp||("top"===t.dl.lp?!(i||!o):"bottom"===t.dl.lp&&(!i&&!o))))}const i=Array.from(t.reduce(((t,e)=>{var n;return(!t.has(e.dl.lp)||Math.abs(e.offset.x)<Math.abs(null===(n=t.get(e.dl.lp))||void 0===n?void 0:n.offset.x))&&t.set(e.dl.lp,e),t}),new Map).values()),o=Array.from(e.reduce(((t,e)=>{var n;return(!t.has(e.dl.lp)||Math.abs(e.offset.y)<Math.abs(null===(n=t.get(e.dl.lp))||void 0===n?void 0:n.offset.y))&&t.set(e.dl.lp,e),t}),new Map).values()),a=i.length?i.reduce(((t,e)=>e.offset.x>t.offset.x?e:t)):void 0,s=o.length?o.reduce(((t,e)=>e.offset.y>t.offset.y?e:t)):void 0;return{v:a?a.dl:void 0,h:s?s.dl:void 0}}constructor(t){super(t),this.historyPoints=[void 0,void 0],this.initialOffset=[void 0,void 0],this.updateCache=new Map,this.getCurOffsetCompareToInitialOffset=t=>{if(void 0===this.initialOffset[0]||void 0===this.initialOffset[1])return[void 0,void 0];const e=[t.canvas.x-this.draggingBBox.center[0],t.canvas.y-this.draggingBBox.center[1]];return[e[0]-this.initialOffset[0],e[1]-this.initialOffset[1]]},this.dragging=!1,this.draggingBBox=void 0,this.getPointerOffsetWithItem=t=>({x:Math.abs(t.x-this.draggingBBox.center[0]),y:Math.abs(t.x-this.draggingBBox.center[1])}),this.tolerance=4,this.toleranceFactor=2,this.vContrastPoints=[],this.hContrastPoints=[],this.alignLinesForChoose={v:[],h:[]},this.isAdsorbed=[!1,!1],this.dragEvent=void 0,this.dragItemId=void 0,this.dragItemType=void 0,this.historyAbsorbArea=[void 0,void 0],this.canAdsorbCount=0,this.canAdsorbCountDown=()=>{if(this.canAdsorbCount>0){const t=setInterval((()=>{this.canAdsorbCount--,this.canAdsorbCount<=0&&clearTimeout(t)}),100)}},this.onDrag=pn((t=>{var e,n,r,i,o,a,s,l;let c,u,h,d;this.dragEvent=t,this.initAlignLinesForChoose(),this.historyPoints[0]=this.historyPoints[1],this.historyPoints[1]={x:t.canvas.x,y:t.canvas.y};const p=(e,n)=>{Math.abs(this.getCurOffsetCompareToInitialOffset(t)[0])<=this.tolerance*this.toleranceFactor?("left"===e?this.doUpdatePosition({x:n[0].x+this.draggingBBox.halfExtents[0]}):"vcenter"===e?this.doUpdatePosition({x:n[0].x}):"right"===e&&this.doUpdatePosition({fx:n[0].x-this.draggingBBox.halfExtents[0]}),this.updateAlignLineWhenAbsorb([!0,!1])):(this.doUpdatePosition({fx:void 0}),this.removeAlignLine([!0,void 0]),this.canAdsorbCount=10,this.canAdsorbCountDown())},f=(e,n)=>{Math.abs(this.getCurOffsetCompareToInitialOffset(t)[1])<=this.tolerance*this.toleranceFactor?("top"===e?this.doUpdatePosition({fy:n[0].y+this.draggingBBox.halfExtents[1]}):"hcenter"===e?this.doUpdatePosition({fy:n[0].y}):"bottom"===e&&this.doUpdatePosition({fy:n[0].y-this.draggingBBox.halfExtents[1]}),this.updateAlignLineWhenAbsorb([!1,!0])):(this.doUpdatePosition({fy:void 0}),this.removeAlignLine([void 0,!0]),this.canAdsorbCount=10,this.canAdsorbCountDown())},g=()=>{const t=this.canDrawLine();t&&(this.drawAlignLines({vdl:t.vdl,hdl:void 0}),this.absorb({vdl:t.vdl,hdl:void 0}))},m=()=>{const t=this.canDrawLine();t&&(this.drawAlignLines({vdl:void 0,hdl:t.hdl}),this.absorb({vdl:void 0,hdl:t.hdl}))};if(this.isAdsorbed[0]&&this.isAdsorbed[1])c=null===(e=this.drawedLines[0].dl)||void 0===e?void 0:e.lp,u=null===(n=this.drawedLines[0].dl)||void 0===n?void 0:n.line,h=null===(r=this.drawedLines[1].dl)||void 0===r?void 0:r.lp,d=null===(i=this.drawedLines[1].dl)||void 0===i?void 0:i.line,p(c,u),f(h,d);else if(this.isAdsorbed[0]&&!this.isAdsorbed[1])c=null===(o=this.drawedLines[0].dl)||void 0===o?void 0:o.lp,u=null===(a=this.drawedLines[0].dl)||void 0===a?void 0:a.line,p(c,u),m();else if(!this.isAdsorbed[0]&&this.isAdsorbed[1])h=null===(s=this.drawedLines[1].dl)||void 0===s?void 0:s.lp,d=null===(l=this.drawedLines[1].dl)||void 0===l?void 0:l.line,f(c,u),g();else if(!this.isAdsorbed[0]&&!this.isAdsorbed[1]){const t=this.canDrawLine();t&&(this.drawAlignLines(t),this.absorb(t))}}).bind(this),16,{leading:!1,trailing:!0}),this.drawedLines=[void 0,void 0],this.throttleUpdate=pn((()=>{this.graph.updateNodePosition(Array.from(this.updateCache.values()),!1,!0),this.updateCache.clear()}),16,{leading:!0,trailing:!0}),this.init(t.graph)}getEvents(){return{pointerdown:this.onPointerDown,pointermove:this.onPointerMove,pointerup:this.onPointerUp}}onPointerDown(t){this.historyPoints[1]={x:t.canvas.x,y:t.canvas.y},this.dragItemId=t.itemId,this.dragItemType=t.itemType}onPointerMove(t){this.historyPoints[1]&&"node"===this.dragItemType&&(this.dragging?this.onDrag(t):(this.onDragStart(t),this.dragging=!0))}onPointerUp(t){this.dragging?this.onDragEnd():(this.historyPoints=[void 0,void 0],this.dragging=!1,this.dragItemId=void 0,this.dragItemType=void 0)}getGraph(t){return t.currentTarget}onDragStart(t){this.draggingBBox=this.graph.getRenderBBox(t.itemId,!0),this.initialOffset=[t.canvas.x-this.draggingBBox.center[0],t.canvas.y-this.draggingBBox.center[1]]}onDragEnd(){this.dragEvent=void 0,this.historyPoints=[void 0,void 0],this.dragging=!1,this.dragItemId=void 0,this.dragItemType=void 0}drawAlignLines({vdl:t,hdl:e}){const n=t?this.getDrawLineIdByDrawLine(t):void 0,r=e?this.getDrawLineIdByDrawLine(e):void 0;let i,o;t&&(i=this.graph.drawTransient("line",n,{style:{stroke:"red",lineWidth:1,x1:t.line[0].x,y1:t.line[0].y,x2:t.line[1].x,y2:t.line[1].y}}),this.drawedLines[0]={do:i,dl:t}),e&&(o=this.graph.drawTransient("line",r,{style:{stroke:"red",lineWidth:1,x1:e.line[0].x,y1:e.line[0].y,x2:e.line[1].x,y2:e.line[1].y}}),this.drawedLines[1]={do:o,dl:e})}removeAlignLine([t,e]){if(t){const t=this.getDrawLineIdByDrawLine(this.drawedLines[0].dl);this.graph.drawTransient("line",t,{action:"remove"}),this.drawedLines[0]=void 0,this.isAdsorbed[0]=!1}if(e){const t=this.getDrawLineIdByDrawLine(this.drawedLines[1].dl);this.graph.drawTransient("line",t,{action:"remove"}),this.drawedLines[1]=void 0,this.isAdsorbed[1]=!1}}removeAlignLineByID(t){const[e,n]=this.drawedLines;this.drawedLines.forEach(((r,i)=>{if(r&&r.do){this.getDrawLineIdByPoints(r.dl.line)===t&&(0===i&&e?(e.dl=void 0,e.do=void 0):1===i&&n&&(n.dl=void 0,n.do=void 0),this.isAdsorbed[i]=!1)}})),this.drawedLines[0]=e,this.drawedLines[1]=n,this.graph.drawTransient("line",t,{action:"remove"})}getDraggingBBoxPointByLinePosition(t){if(this.draggingBBox)return"left"===t?{x:this.draggingBBox.min[0],y:this.draggingBBox.center[1]}:"vcenter"===t||"hcenter"===t?{x:this.draggingBBox.center[0],y:this.draggingBBox.center[1]}:"right"===t?{x:this.draggingBBox.max[0],y:this.draggingBBox.center[1]}:"top"===t?{x:this.draggingBBox.center[0],y:this.draggingBBox.min[1]}:"bottom"===t?{x:this.draggingBBox.center[0],y:this.draggingBBox.max[1]}:void 0}updateAlignLineWhenAbsorb([t,e]){if(t&&this.drawedLines[0]&&this.drawedLines[0].do){const t=this.getDraggingBBoxPointByLinePosition(this.drawedLines[0].dl.lp),e={line:[this.drawedLines[0].dl.line[0],{x:this.drawedLines[0].dl.line[0].x,y:t.y}],lp:this.drawedLines[0].dl.lp};this.removeAlignLineByID(this.drawedLines[0].do.id),this.drawAlignLines({vdl:e,hdl:void 0}),this.isAdsorbed[0]=!0}if(e&&this.drawedLines[1]&&this.drawedLines[1].do){const t=this.getDraggingBBoxPointByLinePosition(this.drawedLines[1].dl.lp),e={line:[this.drawedLines[1].dl.line[0],{x:t.x,y:this.drawedLines[1].dl.line[0].y}],lp:this.drawedLines[1].dl.lp};this.removeAlignLineByID(this.drawedLines[1].do.id),this.drawAlignLines({vdl:void 0,hdl:e}),this.isAdsorbed[1]=!0}}canDrawLine(){const{v:t,h:e}=this.chooseAlignLine();return!(!t&&!e)&&{vdl:t,hdl:e}}canCancelAbsorb(){let t=[void 0,void 0];const e=this.drawedLines[0].dl,n=this.drawedLines[1].dl,r=this.getPointerOffsetWithItem({x:this.dragEvent.canvas.x,y:this.dragEvent.canvas.y});return e&&Math.abs(r.x)>this.tolerance*this.toleranceFactor&&(t[0]=!0),n&&Math.abs(r.y)>this.tolerance*this.toleranceFactor&&(t[1]=!0),t}absorb(t){t.vdl&&(this.isAdsorbed[0]=!0,this.historyAbsorbArea[0]=[t.vdl.line[0].x-this.tolerance*this.toleranceFactor,t.vdl.line[0].x+this.tolerance*this.toleranceFactor],this.updateDraggingItemPosition(this.drawedLines[0].dl)),t.hdl&&(this.isAdsorbed[1]=!0,this.historyAbsorbArea[1]=[t.hdl.line[0].y-this.tolerance*this.toleranceFactor,t.hdl.line[0].y+this.tolerance*this.toleranceFactor],this.updateDraggingItemPosition(this.drawedLines[1].dl))}updateDraggingItemPosition(t,e){if(this.historyPoints[0]||this.historyPoints[1]){if(t){if("left"===t.lp){const e=t.line[0].x+this.draggingBBox.halfExtents[0];this.doUpdatePosition({fx:e})}"vcenter"===t.lp&&this.doUpdatePosition({fx:t.line[0].x}),"right"===t.lp&&this.doUpdatePosition({fx:t.line[0].x-this.draggingBBox.halfExtents[0]}),"top"===t.lp&&this.doUpdatePosition({fy:t.line[0].y+this.draggingBBox.halfExtents[1]}),"hcenter"===t.lp&&this.doUpdatePosition({fy:t.line[0].y}),"bottom"===t.lp&&this.doUpdatePosition({fy:t.line[0].y-this.draggingBBox.halfExtents[1]})}if(e){if(e.x){const t=this.draggingBBox.center[0]+e.x;this.doUpdatePosition({x:t,fx:void 0})}if(e.y){const t=this.draggingBBox.center[1]+e.y;this.doUpdatePosition({y:t,fy:void 0})}}}}doUpdatePosition(t){const e=this.updateCache.get(this.dragItemId);this.updateCache.set(this.dragItemId,{id:this.dragItemId,data:Object.assign(Object.assign({},null==e?void 0:e.data),t)}),this.throttleUpdate()}},EdgeFilterLens:class extends zD{constructor(t){super(t),this.cachedTransientNodes=new Set,this.cachedTransientEdges=new Set}getDefaultCfgs(){return{showType:"both",trigger:"mousemove",r:60,delegateStyle:tn(nz),showLabel:"edge",scaleRBy:"wheel"}}getEvents(){let t={pointerdown:this.onPointerDown,pointerup:this.onPointerUp,wheel:this.onWheel};switch(this.options.trigger){case"click":t=Object.assign(Object.assign({},t),{click:this.filter});break;case"drag":t=Object.assign(Object.assign({},t),{pointermove:this.onPointerMove});break;default:t=Object.assign(Object.assign({},t),{pointermove:this.filter})}return t}init(t){super.init(t);const e=this.options.showLabel,n="node"===e||"both"===e,r="edge"===e||"both"===e;this.showNodeLabel=n,this.showEdgeLabel=r;this.options.shouldShow||(this.options.shouldShow=()=>!0)}onPointerUp(t){this.dragging=!1}onPointerMove(t){this.dragging&&this.moveDelegate(t)}onPointerDown(t){const{delegate:e}=this;let n;!e||e.destroyed?(n={x:t.canvas.x,y:t.canvas.y},this.filter(t)):n={x:e.style.cx,y:e.style.cy},this.delegateCenterDiff={x:t.canvas.x-n.x,y:t.canvas.y-n.y},this.dragging=!0}isInLensDelegate(t,e){const{cx:n,cy:r,r:i}=t.style;return e.x>=n-i&&e.x<=n+i&&e.y>=r-i&&e.y<=r+i}moveDelegate(t){if(this.isInLensDelegate(this.delegate,{x:t.canvas.x,y:t.canvas.y})){const e={x:t.canvas.x-this.delegateCenterDiff.x,y:t.canvas.y-this.delegateCenterDiff.y};this.filter(t,e)}}onWheel(t){const{delegate:e,options:n}=this,{scaleRBy:r}=n;e&&!e.destroyed&&"wheel"===r&&this.isInLensDelegate(e,{x:t.canvas.x,y:t.canvas.y})&&"wheel"===r&&this.scaleRByWheel(t)}scaleRByWheel(t){if(!t||!t.originalEvent)return;t.preventDefault&&t.preventDefault();const{graph:e,options:n}=this,r=e.canvas.context.config.canvas,i=(null==r?void 0:r.height)||500,o=n.maxR?Math.min(n.maxR,i):i,a=n.minR?Math.max(n.minR,i*ez):i*ez,s=1+-1*t.originalEvent.deltaY*ez;let l=n.r*s;l=Math.min(l,o),l=Math.max(l,a),n.r=l,this.delegate.style.r=l,this.filter(t)}filter(t,e){const{graph:n,options:r,showNodeLabel:i,showEdgeLabel:o,cachedTransientNodes:a,cachedTransientEdges:s}=this,l=r.r,c=r.showType,u=r.shouldShow,h=e||{x:t.canvas.x,y:t.canvas.y};this.updateDelegate(h,l);const d=n.getAllNodesData(),p=new Map;d.forEach((t=>{const{data:e,id:n}=t;Sk({x:e.x,y:e.y},h)<l&&p.set(n,t)}));const f=n.getAllEdgesData(),g=[];f.forEach((t=>{const e=t.source,n=t.target;u(t)&&("only-source"===c||"one"===c?p.get(e)&&!p.get(n)&&g.push(t):"only-target"===c||"one"===c?p.get(n)&&!p.get(e)&&g.push(t):"both"===c&&p.get(e)&&p.get(n)&&g.push(t))}));const m=new Set,v=new Set;p.forEach((t=>{m.add(t.id),a.has(t.id)?a.delete(t.id):n.drawTransient("node",t.id,{shapeIds:i?["labelShape","labelBackgroundShape","keyShape"]:["keyShape"]})})),a.forEach((t=>{n.drawTransient("node",t,{action:"remove"})})),o&&(g.forEach((t=>{v.add(t.id),s.has(t.id)?s.delete(t.id):n.drawTransient("edge",t.id,{shapeIds:["labelShape","labelBackgroundShape","keyShape"],drawSource:!1,drawTarget:!1})})),s.forEach((t=>{n.drawTransient("edge",t,{action:"remove"})}))),this.cachedTransientNodes=m,this.cachedTransientEdges=v}updateParams(t){const e=this,{r:n,trigger:r,minR:i,maxR:o,scaleRBy:a,showLabel:s,shouldShow:l}=t;isNaN(t.r)||(e.options.r=n),isNaN(o)||(e.options.maxR=o),isNaN(i)||(e.options.minR=i),"mousemove"!==r&&"click"!==r&&"drag"!==r||(e.options.trigger=r),"wheel"!==a&&"unset"!==a||(e.options.scaleRBy=a,e.delegate.remove(),e.delegate.destroy()),"node"!==s&&"both"!==s||(e.showNodeLabel=!0),"edge"!==s&&"both"!==s||(e.showEdgeLabel=!0),l&&(e.options.shouldShow=l)}updateDelegate(t,e){const{graph:n,options:r,delegate:i}=this;let o=i;if(!o||o.destroyed){const i=r.delegateStyle||nz;o=n.drawTransient("circle","lens-shape",{style:Object.assign({r:e,cx:t.x,cy:t.y,zIndex:-1},i)}),o.toBack()}else o=n.drawTransient("circle","lens-shape",{style:{r:e,cx:t.x,cy:t.y}});this.delegate=o}clear(){const{graph:t,delegate:e,cachedTransientNodes:n,cachedTransientEdges:r}=this;e&&!e.destroyed&&t.drawTransient("circle","lens-shape",{action:"remove"}),n.forEach((e=>{t.drawTransient("node",e,{action:"remove"})})),r.forEach((e=>{t.drawTransient("edge",e,{action:"remove"})})),n.clear(),r.clear()}destroy(){this.clear()}}});const iz=(t,e,n)=>{const r=t.getRenderBBox(e);if(!r)return!1;const i=[[r.min[0],r.min[1]],[r.max[0],r.min[1]],[r.max[0],r.max[1]],[r.min[0],r.max[1]]];return jR(n,i)};const oz=(t,e,n,r,i,o)=>{const a=t.getRenderBBox(e);return!!a&&(a.center[0]>=n&&a.center[0]<=r&&a.center[1]>=i&&a.center[1]<=o)},az=t=>{if(t.length<2)throw new Error(`point length must largn than 2, now it's ${t.length}`);const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(r),t.unshift(i),t.push(e),t.push(n);const o=[];for(let e=1;e<t.length-2;e+=1){const n=t[e-1].x,r=t[e-1].y,i=t[e].x,a=t[e].y,s=t[e+1].x,l=t[e+1].y,c=i+(s-n)/6,u=a+(l-r)/6,h=s-((e!==t.length-2?t[e+2].x:s)-i)/6,d=l-((e!==t.length-2?t[e+2].y:l)-a)/6;o.push(["C",c,u,h,d,s,l])}return o.unshift(["M",r.x,r.y]),o};function sz(t,e){if(!t||t.length<1)return"";if(1===t.length)return(t=>{const n=[t[0][0],t[0][1]-e],r=[t[0][0],t[0][1]+e];return[["M",n],["A",e,e,0,0,0,r],["A",e,e,0,0,0,n]]})(t);if(2===t.length)return(t=>{const n=Ot([0,0],lz(t[0],t[1]),e),r=Ot([0,0],n,-1),i=Nt([0,0],t[0],n),o=Nt([0,0],t[1],n),a=Nt([0,0],t[1],r),s=Nt([0,0],t[0],r);return`M ${i} L ${o} A ${[e,e,"0,0,0",a].join(",")} L ${s} A ${[e,e,"0,0,0",i].join(",")}`})(t);let n=new Array(t.length);for(let r=0;r<n.length;++r){const i=0===r?t[t.length-1]:t[r-1],o=t[r],a=Ot([0,0],lz(i,o),e);n[r]=[Nt([0,0],i,a),Nt([0,0],o,a)]}const r=`A ${[e,e,"0,0,0,"].join(",")}`;return n=n.map(((t,e)=>{let i="";return 0===e&&(i=`M ${n[n.length-1][1]} `),i+=`${r+t[0]} L ${t[1]}`,i})),n.join(" ")}const lz=(t,e)=>{const n=[t[1]-e[1],e[0]-t[0]],r=Math.sqrt(n[0]*n[0]+n[1]*n[1]);if(0===r)throw new Error("p0 should not be equal to p1");return[n[0]/r,n[1]/r]},cz=(t,e)=>[e[0]-t[0],e[1]-t[1]],uz=(t,e)=>Ot([0,0],It([0,0],t),e),hz=(t,e)=>{const n=e.x1,r=e.y1,i=e.x2-n,o=e.y2-r;let a,s=t.x-n,l=t.y-r,c=s*i+l*o;c<=0?a=0:(s=i-s,l=o-l,c=s*i+l*o,a=c<=0?0:c*c/(i*i+o*o));let u=s*s+l*l-a;return u<0&&(u=0),u};class dz{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}getBBox(){const t=Math.min(this.x1,this.x2),e=Math.min(this.y1,this.y2),n=Math.max(this.x1,this.x2),r=Math.max(this.y1,this.y2);return{min:[t,e],max:[n,r],center:[(t+n)/2,(e+r)/2],halfExtents:[(n-t)/2,(r-e)/2]}}}const pz=(t,e)=>Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2),fz=(t,e,n)=>{const r=["top","left","bottom","right"],i=t.getRenderBBox(e);if(!i)return 1/0;let o=Number.POSITIVE_INFINITY,a=0;for(let t=0;t<4;t++){const[e,s,l,c]=gz(i,r[t]);let u=mz(n,new dz(e,s,l,c));u=Math.abs(u-.5),u>=0&&u<=1&&(a+=1,o=u<o?u:o)}return 0===a?-1:o},gz=(t,e)=>({top:[t.min[0],t.min[1],t.max[0],t.min[1]],left:[t.min[0],t.min[1],t.min[0],t.max[1]],bottom:[t.min[0],t.max[1],t.max[0],t.max[1]],right:[t.max[0],t.min[1],t.max[0],t.max[1]]}[e]),mz=(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(t>=0&&t<=1&&e>=0&&e<=1)return t}return Number.POSITIVE_INFINITY},vz=(t,e,n=.001)=>Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)<Math.pow(n,2),yz=(t,e,n)=>{const r=["top","left","bottom","right"],i=t.getRenderBBox(e);if(!i)return;let o=0;const a=[];for(let t=0;t<4;t++){const[e,s,l,c]=gz(i,r[t]);a[t]=$R({x:n.x1,y:n.y1},{x:n.x2,y:n.y2},{x:e,y:s},{x:l,y:c}),a[t]&&(o+=1)}return[a,o]},Ez=(t,e)=>{const n=t.x<e.x,r=t.x>e.x+e.width,i=t.y>e.y+e.height,o=t.y<e.y;if(!(n||r||i||o))return 0;if(i&&!n&&!r)return Math.pow(e.y+e.height-t.y,2);if(o&&!n&&!r)return Math.pow(t.y-e.y,2);if(n&&!i&&!o)return Math.pow(e.x-t.x,2);if(r&&!i&&!o)return Math.pow(e.x+e.width-t.x,2);const a=Math.min(Math.abs(e.x-t.x),Math.abs(e.x+e.width-t.x)),s=Math.min(Math.abs(e.y-t.y),Math.abs(e.y+e.height-t.y));return a*a+s*s},_z=(t,e,n)=>(t.y-n.y)*(e.x-n.x)-(t.x-n.x)*(e.y-n.y),bz=t=>{const e=t.map((t=>({x:t.data.x,y:t.data.y})));e.sort(((t,e)=>t.x===e.x?t.y-e.y:t.x-e.x));const n={};for(let t=e.length-1;t>=0;t--){const{x:r,y:i}=e[t];n[`${r}-${i}`]&&e.splice(t,1),n[`${r}-${i}`]=!0}if(1===e.length)return e;const r=[];for(let t=0;t<e.length;t++){for(;r.length>=2&&_z(r[r.length-2],r[r.length-1],e[t])<=0;)r.pop();r.push(e[t])}const i=[];for(let t=e.length-1;t>=0;t--){for(;i.length>=2&&_z(i[i.length-2],i[i.length-1],e[t])<=0;)i.pop();i.push(e[t])}i.pop(),r.pop();return r.concat(i)},Sz={maxRoutingIterations:100,maxMarchingIterations:100,pixelGroupSize:2,edgeR0:10,edgeR1:10,nodeR0:5,nodeR1:10,morphBuffer:5,threshold:.001,skip:16,nodeInfluenceFactor:1,edgeInfluenceFactor:1,negativeNodeInfluenceFactor:-.5};function xz(t,e,n){let r=!1;const i=(t,n)=>e.cells[t+n*e.width],o=(t,e)=>{let r=0;return i(t-1,e-1)>=n&&(r+=1),i(t,e-1)>n&&(r+=2),i(t-1,e)>n&&(r+=4),i(t,e)>n&&(r+=8),r},a=(n,r)=>{let i,a,s=n,l=r;for(let n=0;n<e.width*e.height;n++){if(i=s,a=l,t.findIndex((t=>t.x===s&&t.y===l))>-1){if(t[0].x===s&&t[0].y===l)return!0}else t.push({x:s,y:l});const e=o(s,l);switch(e){case-1:return console.warn("Marched out of bounds"),!0;case 0:case 3:case 2:case 7:s++;break;case 12:case 14:case 4:s--;break;case 6:0===i&&(-1===a?s-=1:s+=1);break;case 1:case 13:case 5:l--;break;case 9:1===i&&(0===a?l-=1:l+=1);break;case 10:case 8:case 11:l++;break;default:return console.warn(`Marching squares invalid state: ${e}`),!0}}};this.march=()=>{for(let t=0;t<e.width&&!r;t+=1)for(let s=0;s<e.height&&!r;s+=1)i(t,s)>n&&15!==o(t,s)&&(r=a(t,s));return r}}const Tz=(t,e,n)=>{let r=Number.POSITIVE_INFINITY,i=null;return e.forEach((e=>{const o=fz(t,e.id,n);o>=0&&o<r&&(i=e,r=o)})),i};function Az(t,e,n,r,i,o){const a=((t,e,n,r)=>{let i=null,o=Number.POSITIVE_INFINITY;return n.forEach((n=>{const a={x:e.data.x,y:e.data.y},s={x:n.data.x,y:n.data.y},l=pz(a,s),c=new dz(a.x,a.y,s.x,s.y),u=r.reduce(((e,n)=>fz(t,n.id,c)>0?e+1:e),0);l*Math.pow(u+1,2)<o&&(i=n,o=l*Math.pow(u+1,2))})),i})(t,e,r,n);if(null===a)return[];const s=new dz(e.data.x,e.data.y,a.data.x,a.data.y),l=((t,e,n,r,i)=>{const o=[],a=[];a.push(e);let s=!0,l=0;const c=(t,e)=>{let n=!1;return e.forEach((e=>{n||(vz(t,{x:e.x1,y:e.y1})||vz(t,{x:e.x2,y:e.y2}))&&(n=!0)})),n},u=(t,e,n)=>{for(const r of n){const n=t.getRenderBBox(r.id);if(!n)continue;const[i,o]=n.min,a=[[i,o],[n.max[0],o],[i,n.max[1]],[n.max[0],n.max[1]]];if(YR(a,e.x,e.y))return!0}return!1};for(;s&&l<r;)for(s=!1;!s&&a.length;){const e=a.pop(),r=Tz(t,n,e);if(r){const[l,h]=yz(t,r.id,e);if(2===h){const h=h=>{let d=i,p=Cz(r,d,l,h),f=c(p,a)||c(p,o),g=u(t,p,n);for(;!f&&g&&d>=1;)d/=1.5,p=Cz(r,d,l,h),f=c(p,a)||c(p,o),g=u(t,p,n);!p||f||h&&g||(a.push(new dz(e.x1,e.y1,p.x,p.y)),a.push(new dz(p.x,p.y,e.x2,e.y2)),s=!0)};h(!0),s||h(!1)}}s||o.push(e),l+=1}for(;a.length;)o.push(a.pop());return o})(t,s,n,i,o),c=(e=>{const r=[];for(;e.length>0;){const i=e.pop();if(0===e.length){r.push(i);break}const o=e.pop(),a=new dz(i.x1,i.y1,o.x2,o.y2);Tz(t,n,a)?(r.push(i),e.push(o)):e.push(a)}return r})(l);return c}const Rz=(t,e,n,r)=>{const i=Object.assign(Sz,r),o=(t=>{let e=0,n=0;if(t.length>0){for(const r of t)e+=r.x,n+=r.y;e/=t.length,n/=t.length}return{x:e,y:n}})(e.map((t=>({x:t.data.x,y:t.data.y}))));e=e.sort(((t,e)=>pz({x:t.data.x,y:t.data.y},o)-pz({x:e.data.x,y:e.data.y},o)));const a=[],s=[];e.forEach((e=>{Az(t,e,n,a,i.maxRoutingIterations,i.morphBuffer).forEach((t=>{s.push(t)})),a.push(e)}));const l=function(t,e,n,r){const i={min:[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,0],max:[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,0],halfExtents:[0,0,0]},o=[];e.forEach((e=>{o.push(t.getRenderBBox(e.id))})),n.forEach((t=>{o.push(t.getBBox())}));for(const t of o)i.min[0]=(t.min[0]<i.min[0]?t.min[0]:i.min[0])-r,i.min[1]=(t.min[1]<i.min[1]?t.min[1]:i.min[1])-r,i.max[0]=(t.max[0]>i.max[0]?t.max[0]:i.max[0])+r,i.max[1]=(t.max[1]>i.max[1]?t.max[1]:i.max[1])+r;return i.halfExtents=[(i.max[0]-i.min[0])/2,(i.max[1]-i.min[1])/2,0],i}(t,e,s,i.nodeR0),c=((t,e,n)=>{const r=Math.ceil(t/n),i=Math.ceil(e/n);return{cells:new Float32Array(Math.max(0,r*i)).fill(0),width:r,height:i}})(l.max[0]-l.min[0],l.max[1]-l.min[1],i.pixelGroupSize);let u=[],h=[];for(let r=0;r<i.maxMarchingIterations;r++){if(Mz(t,e,n,s,l,c,i),u=[],h=[],!new xz(u,c,i.threshold).march())continue;const o=u.map((t=>({x:Math.round(t.x*i.pixelGroupSize+l.min[0]),y:Math.round(t.y*i.pixelGroupSize+l.min[1])})));if(o){let t=o.length;if(i.skip>1)for(t=Math.floor(o.length/i.skip);t<3&&i.skip>1;)i.skip-=1,t=Math.floor(o.length/i.skip);for(let e=0,n=0;n<t;n+=1,e+=i.skip)h.push({x:o[e].x,y:o[e].y})}const a=()=>{for(const n of e){const e=h.map((t=>[t.x,t.y])),r=t.getRenderBBox(n.id);if(r&&!YR(e,r.center[0],r.center[1]))return!1}return!0};if(h&&a())return h;if(i.threshold*=.9,r<=.5*i.maxMarchingIterations)i.memberInfluenceFactor*=1.2,i.edgeInfluenceFactor*=1.2;else{if(!(0!==i.nonMemberInfluenceFactor&&n.length>0))break;i.nonMemberInfluenceFactor*=.8}}return h};function Mz(t,e,n,r,i,o,a){function s(t,e){const n=Math.floor((t-e)/a.pixelGroupSize);return n<0?0:n}function l(t,e){return t*a.pixelGroupSize+e}const c=(a.nodeR0-a.nodeR1)*(a.nodeR0-a.nodeR1),u=(a.edgeR0-a.edgeR1)*(a.edgeR0-a.edgeR1),h=(t,e)=>[Math.min(s(t.min[0],e+i.min[0]),o.width),Math.min(s(t.min[1],e+i.min[1]),o.height),Math.min(s(t.max[0],-e+i.min[0]),o.width),Math.min(s(t.max[1],-e+i.min[1]),o.height)],d=(t,e,n)=>{const r=t.getRenderBBox(e.id);if(!r)return;const[s,c,u,d]=h(r,a.nodeR1);for(let t=c;t<d;t+=1)for(let e=s;e<u;e+=1){if(n<0&&o[e+t*o.width]<=0)continue;const s=l(e,i.min[0]),c=l(t,i.min[1]),u=Ez({x:s,y:c},{x:r.min[0],y:r.min[1],width:r.max[0]-r.min[0],height:r.max[1]-r.min[1]});if(u<Math.pow(a.nodeR1,2)){const r=Math.sqrt(u)-a.nodeR1;o.cells[e+t*o.width]+=n*r*r}}};a.nodeInfluenceFactor&&e.forEach((e=>{d(t,e,a.nodeInfluenceFactor/c)})),a.edgeInfluenceFactor&&r.forEach((t=>{((t,e)=>{const n=t.getBBox(),[r,s,c,u]=h(n,a.edgeR1);for(let n=s;n<u;n+=1)for(let s=r;s<c;s+=1){if(e<0&&o.cells[s+n*o.width]<=0)continue;const r=l(s,i.min[0]),c=l(n,i.min[1]),u=hz({x:r,y:c},t);if(u<Math.pow(a.edgeR1,2)){const t=Math.sqrt(u)-a.edgeR1;o.cells[s+n*o.width]+=e*t*t}}})(t,a.edgeInfluenceFactor/u)})),a.negativeNodeInfluenceFactor&&n.forEach((e=>{d(t,e,a.negativeNodeInfluenceFactor/c)}))}function Cz(t,e,n,r){const i=t.getBBox(),[o,a,s,l]=n,c={topLeft:{x:i.minX-e,y:i.minY-e},topRight:{x:i.maxX+e,y:i.minY-e},bottomLeft:{x:i.minX-e,y:i.maxY+e},bottomRight:{x:i.maxX+e,y:i.maxY+e}},u=i.height*i.width;function h(t,e){return i.width*(.5*(t.y-i.minY+(e.y-i.minY)))}if(a){if(o)return r?c.topLeft:c.bottomRight;if(s)return r?c.bottomLeft:c.topRight;return h(a,l)<.5*u?a.y>l.y?r?c.topLeft:c.bottomRight:r?c.topRight:c.bottomLeft:a.y<l.y?r?c.bottomLeft:c.topRight:r?c.bottomRight:c.topLeft}if(l){if(o)return r?c.topRight:c.bottomLeft;if(s)return r?c.bottomRight:c.topLeft}return h(o,s)<.5*u?o.x>s.x?r?c.topLeft:c.bottomRight:r?c.bottomLeft:c.topRight:o.x<s.x?r?c.topRight:c.bottomLeft:r?c.bottomRight:c.topLeft}class Pz{constructor(t,e){const{members:n=[],nonMembers:r=[]}=e;this.options=e,this.graph=t,this.members=n.map((e=>t.getNodeData(e)||t.getComboData(e))),this.nonMembers=r.map((e=>t.getNodeData(e)||t.getComboData(e))),this.setPadding(),this.setType(),this.path=this.getPath(this.members,this.nonMembers),this.render()}getDefaultCfg(){return{id:"g6-hull",type:"round-convex",members:[],nonMembers:[]}}setPadding(){let t=30;if(this.members.length){const e=this.graph.getRenderBBox(this.members[0].id);e&&(t=e.halfExtents[0])}this.padding=this.options.padding>0?this.options.padding+t:10+t,this.bubbleCfg=Object.assign(Object.assign({},this.options.bubbleCfg),{nodeR0:this.padding-t,nodeR1:this.padding-t,morphBuffer:this.padding-t})}setType(){this.type=this.options.type,this.members.length<3&&(this.type="round-convex"),"round-convex"!==this.type&&"smooth-convex"!==this.type&&"bubble"!==this.type&&(console.warn("The hull type should be either round-convex, smooth-convex or bubble, round-convex is used by default."),this.type="round-convex")}getPath(t,e){let n,r,i;switch(this.type){case"round-convex":n=bz(t),i=sz(n.map((t=>[t.x,t.y])),this.padding),r=i;break;case"smooth-convex":n=bz(t),2===n.length?(i=sz(n.map((t=>[t.x,t.y])),this.padding),r=i):n.length>2&&(i=function(t,e){const n=t.length;if(!t||n<1)return"";if(1===n)return(t=>{const n=[t[0][0],t[0][1]-e],r=[t[0][0],t[0][1]+e];return`M ${n} A ${[e,e,"0,0,0",r].join(",")} A ${[e,e,"0,0,0",n].join(",")}`})(t);if(2===n)return(t=>{const n=cz(t[0],t[1]),r=uz(n,e),i=Nt([0,0],t[0],Ot([0,0],r,-1)),o=Nt([0,0],t[1],r),a=1.2*e,s=uz(It([0,0],n),a),l=Ot([0,0],s,-1),c=Nt([0,0],i,l),u=Nt([0,0],o,l),h=Nt([0,0],i,s);return`M ${i} C ${[c,u,o].join(",")} S ${[h,i].join(",")} Z`})(t);const r=t.map(((e,r)=>{const i=t[(r+1)%n];return{p:e,v:It([0,0],cz(e,i))}}));for(let t=0;t<r.length;++t){const i=It([0,0],Nt([0,0],r[t>0?t-1:n-1].v,Ot([0,0],r[t].v,-1)));r[t].p=Nt([0,0],r[t].p,Ot([0,0],i,e))}return r.map((t=>{const e=t.p;return{x:e[0],y:e[1]}}))}(n.map((t=>[t.x,t.y])),this.padding),r=az(i));break;case"bubble":n=Rz(this.graph,t,e,this.bubbleCfg),r=n.length>=2&&az(n)}return r}render(){if(!this.path)return;const t=this.graph.drawTransient("path",this.options.id,{style:Object.assign({path:this.path,pointerEvents:"none"},this.options.style)}),{labelShape:e}=this.options;if(null==e?void 0:e.text){const n=t.getRenderBounds(),r=Nc(e,["position","offsetX","offsetY"]),i=this.getLabelStyle(e,n);this.graph.drawTransient("text",`${this.options.id}-label`,{style:Object.assign(Object.assign({pointerEvents:"none"},r),i)})}t.toBack(),this.hullShape=t}getLabelStyle(t,e){const{position:n,offsetX:r=0,offsetY:i=0,autoRotate:o=!0}=t,{min:a,max:s,center:l}=e,c={x:0,y:0,textAlign:"center",textBaseline:"middle"},u={x:0,y:0};switch(n){case"bottom":case"outside-bottom":u.x=(a[0]+s[0])/2,u.y=s[1],c.textBaseline="bottom";break;case"left":case"outside-left":u.x=a[0],u.y=(a[1]+s[1])/2,c.textAlign="left";break;case"right":case"outside-right":u.x=s[0],u.y=(a[1]+s[1])/2,c.textAlign="right";break;default:u.x=(a[0]+s[0])/2,u.y=a[1],c.textBaseline="top"}let h;const d=ck(this.path);if("bubble"===this.type)switch(n){case"bottom":h={x:l[0],y:s[0]+10};break;case"left":h={x:s[0]+10,y:l[1]};break;case"right":h={x:a[0]-10,y:l[1]};break;default:h={x:l[0],y:s[1]-10}}else h={x:l[0],y:l[1]};const p=((t,e)=>{const n=t.length,r={};for(let i=0;i<n-1;i++){const n={x:t[i][0],y:t[i][1]},o={x:t[i+1][0],y:t[i+1][1]};if(n.x===o.x&&n.y===o.y)continue;const a=`${n.x}-${n.y}-${o.x}-${o.y}`;if(r[a])continue;r[a]=!0;const s=$R(n,o,e[0],e[1]);if(s)return{point:s,line:[n,o]}}})(d,[h,((t,e,n)=>{const r=(e.y-t.y)/(e.x-t.x);if(Math.abs(r)===1/0)return{x:t.x,y:e.y>t.y?t.y-n:t.y+n};if(0===r)return{x:e.x>t.x?t.x-n:t.x+n,y:e.y};const i=t.y-r*t.x,o=e.x>t.x?-1:1,a=t.x+o*n;return{x:a,y:r*a+i}})(u,h,100)]);if(p){const{point:t,line:e}=p;if(c.x=t.x+r,c.y=t.y+i,o){const t=Math.atan((e[0].y-e[1].y)/(e[0].x-e[1].x));c.transform=`rotate(${t/Math.PI*180}deg)`,c.textAlign="center","right"!==n&&"left"!==n||(c.textBaseline=t>0?"right"===n?"top":"bottom":"right"===n?"bottom":"top")}}else c.x=u.x+r,c.y=u.y+i;return"outside"===n.split("-")[0]&&(c.textBaseline=(t=>{switch(t){case"top":return"bottom";case"bottom":return"top";case"left":return"right";default:return"left"}})(c.textBaseline)),c}addMember(t){if(!t)return;const e=Re(t)?t:[t];let n=!1;return e.forEach((t=>{const e=this.graph.getNodeData(t)||this.graph.getComboData(t);-1===this.members.indexOf(e)&&(this.members.push(e),n=!0);const r=this.nonMembers.indexOf(e);r>-1&&(this.nonMembers.splice(r,1),n=!0)})),n&&this.updateMembers(this.members.map((t=>t.id)),this.nonMembers.map((t=>t.id))),!1}addNonMember(t){if(!t)return;const e=Re(t)?t:[t];let n=!1;return e.forEach((t=>{const e=this.graph.getNodeData(t)||this.graph.getComboData(t);-1===this.nonMembers.indexOf(e)&&(this.nonMembers.push(e),n=!0);const r=this.members.indexOf(e);r>-1&&(this.members.splice(r,1),n=!0)})),!!n&&(this.updateMembers(this.members.map((t=>t.id)),this.nonMembers.map((t=>t.id))),!0)}removeMember(t){if(!t)return;const e=Re(t)?t:[t];let n=!1;return e.forEach((t=>{const e=this.members.findIndex((e=>e.id===t));e>-1&&(this.members.splice(e,1),n=!0)})),!!n&&(this.updateMembers(this.members.map((t=>t.id)),this.nonMembers.map((t=>t.id))),!0)}removeNonMember(t){if(!t)return;const e=Re(t)?t:[t];let n=!1;return e.forEach((t=>{const e=this.graph.getNodeData(t)||this.graph.getComboData(t),r=this.nonMembers.indexOf(e);r>-1&&(this.nonMembers.splice(r,1),n=!0)})),!!n&&(this.updateMembers(this.members.map((t=>t.id)),this.nonMembers.map((t=>t.id))),!0)}updateMembers(t,e){t&&(this.options.members=t,this.members=t.map((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)))),e&&(this.options.nonMembers=e,this.nonMembers=e.map((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)))),this.path=this.getPath(this.members,this.nonMembers),this.render()}updateStyle(t){this.graph.drawTransient("path",this.options.id,{style:Object.assign(Object.assign({},t),{pointerEvents:"none"})})}updateOptions(t){const{members:e,nonMembers:n}=t;this.options=Object.assign(Object.assign(Object.assign({},this.options),t),{style:Object.assign(Object.assign({},this.options.style),t.style),labelShape:Object.assign(Object.assign({},this.options.labelShape),t.labelShape)}),e&&(this.members=e.map((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)))),n&&(this.nonMembers=n.map((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)))),this.setPadding(),this.setType(),this.path=this.getPath(this.members,this.nonMembers),this.render()}contain(t){let e;const n=this.graph.getRenderBBox(t);if(n)return e=[[n.min[0],n.min[1]],[n.max[0],n.min[1]],[n.max[0],n.max[1]],[n.min[0],n.max[1]]],e=e.map((t=>{const e=this.graph.getPointByCanvas(t[0],t[1]);return[e.x,e.y]})),jR(e,ck(this.path));console.warn(`The item with ${t} is not existed in the graph.`)}destroy(){this.graph.drawTransient("path",this.options.id,{action:"remove"})}}const{ValidateData:wz,TransformV4Data:Nz,MapNodeSize:Oz}=UB,{compactBox:Iz,dendrogram:Dz,indented:Bz,mindmap:kz}=ZC,{DarkTheme:Lz,LightTheme:Fz}=pL,{SpecThemeSolver:Uz,SubjectThemeSolver:Gz}=fF,{CircleNode:Vz,RectNode:Wz,DiamondNode:zz,DonutNode:Hz,SphereNode:jz,StarNode:Xz,HexagonNode:Yz,TriangleNode:Kz,EllipseNode:qz,ModelRectNode:$z,ImageNode:Zz,CubeNode:Qz,BaseNode:Jz,BaseNode3D:tH}=rk,{LineEdge:eH,CubicEdge:nH,CubicHorizontalEdge:rH,CubicVerticalEdge:iH,LoopEdge:oH,PolylineEdge:aH,QuadraticEdge:sH}=eL,{CircleCombo:lH,RectCombo:cH}=YB,{ActivateRelations:uH,BrushSelect:hH,HoverActivate:dH,LassoSelect:pH,OrbitCanvas3D:fH,RotateCanvas3D:gH,TrackCanvas3D:mH,ZoomCanvas3D:vH,ZoomCanvas:yH,DragCanvas:EH,CollapseExpandTree:_H,CollapseExpandCombo:bH,DragNode:SH,DragCombo:xH,ClickSelect:TH,CreateEdge:AH,ShortcutsCall:RH,ScrollCanvas:MH}=BB,{History:CH,Tooltip:PH,Minimap:wH,Grid:NH,Menu:OH,Fisheye:IH,Legend:DH,Toolbar:BH,Timebar:kH,Snapline:LH,EdgeFilterLens:FH}=rz,{ForceLayout:UH,GridLayout:GH,CircularLayout:VH,ConcentricLayout:WH,RandomLayout:zH,MDSLayout:HH,RadialLayout:jH,FruchtermanLayout:XH,D3ForceLayout:YH,ForceAtlas2Layout:KH,DagreLayout:qH,ComboCombinedLayout:$H}=VD,ZH={transforms:{"validate-data":wz,"transform-v4-data":Nz,"map-node-size":Oz},themes:{light:Fz,dark:Lz},themeSolvers:{spec:Uz,subject:Gz},layouts:Object.assign({force:UH,grid:GH,circular:VH,concentric:WH},ZC),behaviors:{"drag-canvas":EH,"zoom-canvas":yH,"drag-node":SH,"drag-combo":xH,"collapse-expand-combo":bH,"collapse-expand-tree":_H,"click-select":TH},plugins:{history:CH},nodes:{"circle-node":Vz,"rect-node":Wz,"image-node":Zz},edges:{"line-edge":eH,"loop-edge":oH},combos:{"circle-combo":lH,"rect-combo":cH},markers:{collapse:(t,e,n)=>[["M",t-n,e],["a",n,n,0,1,0,2*n,0],["a",n,n,0,1,0,2*-n,0],["M",t-n+4,e],["L",t+n-4,e]],expand:(t,e,n)=>[["M",t-n,e],["a",n,n,0,1,0,2*n,0],["a",n,n,0,1,0,2*-n,0],["M",t-n+4,e],["L",t-n+2*n-4,e],["M",t-n+n,e-n+4],["L",t,e+n-4]],upTriangle:(t,e,n)=>{const r=n*Math.cos(Math.PI/6),i=n*Math.sin(Math.PI/6);return[["M",t-r,e+i],["L",t+r,e+i],["L",t,e-n],["Z"]]},downTriangle:(t,e,n)=>{const r=n*Math.cos(Math.PI/6),i=n*Math.sin(Math.PI/6);return[["M",t-r,e-i],["L",t+r,e-i],["L",t,e+n],["Z"]]}}},QH={rectSelector:(t,e,n)=>{const[r,i]=e,o=Math.min(r.x,i.x),a=Math.max(r.x,i.x),s=Math.min(r.y,i.y),l=Math.max(r.y,i.y),c=[],u=[];let h=[];return n.includes("node")&&t.getAllNodesData().forEach((e=>{const{id:n}=e;t.getItemVisible(n)&&oz(t,n,o,a,s,l)&&c.push(n)})),n.includes("combo")&&t.getAllCombosData().forEach((e=>{const{id:n}=e;t.getItemVisible(n)&&oz(t,n,o,a,s,l)&&u.push(n)})),n.includes("edge")&&(h=YD(t,c.concat(u))),{nodes:c,edges:h,combos:u}},lassoSelector:(t,e,n)=>{const r=e.map((t=>[t.x,t.y])),i=[];let o=[];const a=[];return n.includes("node")&&t.getAllNodesData().forEach((e=>{const{id:n}=e;t.getItemVisible(n)&&iz(t,n,r)&&i.push(n)})),n.includes("combo")&&t.getAllCombosData().forEach((e=>{const{id:n}=e;t.getItemVisible(n)&&iz(t,n,r)&&a.push(n)})),n.includes("edge")&&(o=YD(t,i.concat(a))),{nodes:i,edges:o,combos:a}}},JH={useLib:{transforms:{},themes:{},layouts:{},behaviors:{},plugins:{},nodes:{},edges:{},combos:{}}},tj={ValidateData:wz,TransformV4Data:Nz,MapNodeSize:Oz,LightTheme:Fz,DarkTheme:Lz,SpecThemeSolver:Uz,SubjectThemeSolver:Gz,ForceLayout:UH,GridLayout:GH,CircularLayout:VH,ConcentricLayout:WH,RandomLayout:zH,MDSLayout:HH,RadialLayout:jH,FruchtermanLayout:XH,D3ForceLayout:YH,ForceAtlas2Layout:KH,DagreLayout:qH,ComboCombinedLayout:$H,compactBox:Iz,dendrogram:Dz,indented:Bz,mindmap:kz,CircleNode:Vz,RectNode:Wz,DiamondNode:zz,DonutNode:Hz,SphereNode:jz,StarNode:Xz,HexagonNode:Yz,TriangleNode:Kz,EllipseNode:qz,ModelRectNode:$z,CubeNode:Qz,BaseNode:Jz,BaseNode3D:tH,LineEdge:eH,CubicEdge:nH,CubicHorizontalEdge:rH,CubicVerticalEdge:iH,LoopEdge:oH,PolylineEdge:aH,QuadraticEdge:sH,CircleCombo:lH,RectCombo:cH,BaseBehavior:WD,ActivateRelations:uH,BrushSelect:hH,HoverActivate:dH,LassoSelect:pH,OrbitCanvas3D:fH,RotateCanvas3D:gH,TrackCanvas3D:mH,ZoomCanvas3D:vH,ZoomCanvas:yH,DragCanvas:EH,CollapseExpandTree:_H,CollapseExpandCombo:bH,DragNode:SH,DragCombo:xH,CreateEdge:AH,ShortcutsCall:RH,ScrollCanvas:MH,BasePlugin:zD,History:CH,Toolbar:BH,Tooltip:PH,Minimap:wH,Grid:NH,Menu:OH,Fisheye:IH,Legend:DH,Timebar:kH,Hull:class extends zD{constructor(t){super(t),this.hullMap={},this.cacheChanges={remove:[],update:[]},this.debounceUpdateMembers=pn((()=>{Object.keys(this.hullMap).forEach((t=>{const e=this.hullMap[t];if(this.cacheChanges.remove.length)_R(e.options.members,this.cacheChanges.remove)&&e.removeMember(this.cacheChanges.remove);else if(this.cacheChanges.update.length){const t=this.cacheChanges.update.map((t=>t.id));_R(e.options.members,t)&&e.updateMembers()}})),this.cacheChanges={update:[],remove:[]}}),50,{trailing:!0,leading:!0}),this.key=(null==t?void 0:t.key)||`hull-${Math.random()}`}getDefaultCfgs(){return{key:`hull-${gn()}`,padding:10,style:{fill:"lightblue",stroke:"blue",opacity:.2},labelShape:Object.assign(Object.assign({},ER),{position:"outside-top",offsetY:-2}),hulls:[]}}init(t){super.init(t)}getEvents(){return{afteritemchange:this.handleNodesChange,afterrender:this.handleAfterRender}}handleNodesChange(t){const{itemType:e,models:n,ids:r,action:i}=t;"edge"!==e&&"add"!==i&&("remove"===i?this.cacheChanges.remove=this.cacheChanges.remove.concat(r):this.cacheChanges.update=this.cacheChanges.update.concat(n),this.debounceUpdateMembers())}handleAfterRender(){this.addHull(this.options.hulls)}addHull(t){const{padding:e,style:n,bubbleCfg:r,labelShape:i}=this.options;(Re(t)?t:[t]).forEach((t=>{const{id:o,style:a,labelShape:s,members:l}=t,c=Nc(t,["id","style","labelShape","members"]),u=null==l?void 0:l.filter((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)));if(!(null==u?void 0:u.length))return void console.warn("Create hull failed. There are no valid members.");u.length!==l.length&&console.warn(`Some member of hull ${o} is not exist in the graph. Hull ${o} is added without those invalid members.`);const h=Object.assign({id:`${this.key}-${o}`,padding:e,bubbleCfg:r,style:Object.assign(Object.assign({},n),a),labelShape:(null==s?void 0:s.text)?Object.assign(Object.assign({},i),s):void 0,members:u},c);this.hullMap[o]?this.updateHull(h):this.hullMap[o]=new Pz(this.graph,h)}))}updateHull(t){(Re(t)?t:[t]).forEach((t=>{const{id:e}=t,n=Nc(t,["id"]);this.hullMap[e]?this.hullMap[e].updateOptions(n):console.warn(`Update hull component failed. The bubble with id ${e} is not existed.`)}))}removeHull(t){(Re(t)?t:[t]).forEach((t=>{this.hullMap[t].destroy(),delete this.hullMap[t]}))}addHullMember(t,e){const n=this.hullMap[t];n?n.addMember(e):console.warn(`Add member to hull faield. The hull with id ${t} is not exist`)}removeHullMember(t,e){const n=this.hullMap[t];n?n.removeMember(e):console.warn(`Remove member from hull faield. The hull with id ${t} is not exist`)}addHullNonMember(t,e){const n=this.hullMap[t];n?n.addNonMember(e):console.warn(`Add non member to hull faield. The hull with id ${t} is not exist`)}removeHullNonMember(t,e){const n=this.hullMap[t];n?n.removeNonMember(e):console.warn(`Remove non member from hull faield. The hull with id ${t} is not exist`)}},Snapline:LH,EdgeFilterLens:FH,WaterMarker:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`watermarker-${gn()}`,container:null,canvas:void 0,mode:"image",width:void 0,height:void 0,position:"bottom",begin:[0,0],seperation:[100,100],image:{imgURL:"https://gw.alipayobjects.com/os/s/prod/antv/assets/image/logo-with-text-73b8a.svg",width:94,height:28,rotate:0},text:{texts:"AntV",rotate:20,fontSize:14,fontFamily:"Microsoft YaHei",fill:"rgba(0, 0, 0, 0.1)",textBaseline:"top"}}}init(t){super.init(t);this.initCanvas().then((()=>{this.updateWaterMarker()}))}getEvents(){return{aftersetsize:this.onGraphSetSize}}initCanvas(){const{graph:t,options:e}=this,{width:n,height:r,position:i,canvas:o}=e;let a,s=e.container;const l=t.getSize();if(o)return this.canvas=o,this.canvasSize=[l[0],l[1]],this.followGraphSize=!0,this.container=t.container,o.ready;De(s)&&(s=document.getElementById(s)),a=s||t.container,a.style.position||(a.style.position="relative"),this.canvasSize=[void 0===n?l[0]:n,void 0===r?l[1]:r],this.followGraphSize=void 0===n||void 0===r,this.canvas=fR("canvas",a,this.canvasSize[0],this.canvasSize[1]);const c=this.canvas.getContextService().getDomElement();c.style.position="fixed",c.style.outline="none",c.style.pointerEvents="none",c.style.userSelect="none",this.container=a;const u=this.canvas.getContextService().getDomElement();this.container.removeChild(u);const h=t.canvas.getContextService().getDomElement(),d=t.transientCanvas.getContextService().getDomElement();switch(i){case"top":this.container.appendChild(u);break;case"middle":this.container.insertBefore(u,d);break;default:this.container.insertBefore(u,h)}return this.canvas.ready}onGraphSetSize(t){const{size:e}=t;this.followGraphSize&&(this.canvas.resize(e[0],e[1]),this.updateWaterMarker())}updateWaterMarker(){if("text"===this.options.mode)this.setTextWaterMarker();else this.setImageWaterMarker()}setImageWaterMarker(){const{canvas:t,options:e,canvasSize:n}=this,{image:r,begin:i,seperation:o}=e,{imgURL:a,rotate:s=0}=r,l=Nc(r,["imgURL","rotate"]),c=[...i];let u;const h=()=>{const t=new qs;for(;c[0]<n[0];){const e=new Zs({style:Object.assign(Object.assign({},l),{img:a,x:c[0],y:c[1]})});s&&(e.style.transformOrigin="center",e.style.transform=`rotate(${s}deg)`),u||(u=e.getLocalBounds()),t.appendChild(e),c[0]+=2*u.halfExtents[0]+o[0]}return t};for(;c[1]<n[1];)t.appendChild(h()),c[0]=i[0],c[1]+=2*u.halfExtents[1]+o[1]}setTextWaterMarker(){return Oc(this,void 0,void 0,(function*(){const{canvas:t,options:e,canvasSize:n}=this,{text:r,seperation:i,begin:o}=e,{texts:a,rotate:s}=r,l=Nc(r,["texts","rotate"]),c=[...o],u=(De(a)?[a]:a).join("\n");let h;const d=()=>{const t=new qs;for(;c[0]<n[0];){const e=new rl({style:Object.assign(Object.assign({},l),{text:u,x:c[0],y:c[1]})});s&&(e.style.transform=`rotate(${s}deg)`),h||(h=e.getLocalBounds()),t.appendChild(e),c[0]+=2*h.halfExtents[0]+i[0]}return t};for(;c[1]<n[1];)t.appendChild(d()),c[0]=o[0],c[1]+=2*h.halfExtents[1]+i[1]}))}destroy(){const{canvas:t,options:e}=this;let n;e.container||(n=this.graph.container),De(n)&&(n=document.getElementById(n)),n!==this.graph.container&&n.remove(),t.destroy()}}},ej=(t,e,n)=>{var r;const i=`${n}s`;if(Se(t))return t;const o="string"==typeof t?t:t.type;return null===(r=e[i])||void 0===r?void 0:r[o]},nj=["collapse-expand-tree"];function rj(t){if(!(null==t?void 0:t.length))return!1;const e=t.map((t=>De(t)?t:t.type)).filter(Boolean);return _R(nj,e)}class ij{constructor(t){this.extensions=[],this.graph=t,this.tap()}findData(t,e){const{graphCore:n}=this,r=typeof e,i=Re(e);if("string"===r||"number"===r||i){const r=i?e:[e];switch(t){case"node":return r.map((t=>{if(!n.hasNode(t))return;const e=n.getNode(t);return e.data._isCombo?void 0:e}));case"edge":return r.map((t=>n.hasEdge(t)?n.getEdge(t):void 0));case"combo":return r.map((t=>{if(!n.hasNode(t))return;const e=n.getNode(t);return e.data._isCombo?e:void 0}))}}else if("function"===r){return("node"===t?n.getAllNodes:n.getAllEdges)().filter((t=>e(t)))}}findAllData(t){if(!this.graphCore)return[];switch(t){case"node":return this.graphCore.getAllNodes();case"edge":return this.graphCore.getAllEdges();default:return[]}}findRelatedEdges(t,e="both"){return this.graphCore.getRelatedEdges(t,e)}findNeighborNodes(t,e="both"){return"in"===e?this.graphCore.getAncestors(t):"out"===e?this.graphCore.getSuccessors(t):this.graphCore.getNeighbors(t)}findChildren(t,e){if(this.graphCore.hasNode(t))return this.graphCore.getChildren(t,e)}tap(){this.extensions=this.getExtensions(),this.graph.hooks.datachange.tap(this.onDataChange.bind(this)),this.graph.hooks.treecollapseexpand.tap(this.onTreeCollapseExpand.bind(this)),this.graph.hooks.layout.tap(this.onLayout.bind(this)),this.graph.hooks.init.tap(this.onGraphInit.bind(this)),this.graph.hooks.behaviorchange.tap(this.onBehaviorChange.bind(this)),this.graph.hooks.modechange.tap(this.onModeChange.bind(this))}getExtensions(){const{transforms:t=[]}=this.graph.getSpecification();return[...t,"validate-data"].map((t=>({config:t,func:ej(t,JH.useLib,"transform")}))).filter((t=>!!t.func))}onDataChange(t){const{data:e,type:n}=t,{graphCore:r}=this,i=()=>{switch(n){case"remove":this.removeData(e);break;case"update":this.updateData(e);break;case"moveCombo":this.moveCombo(e);break;case"addCombo":this.addCombo(e);break;default:this.changeData(e,n)}};r?r.batch(i):i()}onTreeCollapseExpand(t){const{ids:e,action:n}=t;e.forEach((t=>{this.graphCore.mergeNodeData(t,{collapsed:"collapse"===n})}))}onLayout({options:t}){this.treeDirtyFlag&&mP(t)&&this.establishGraphCoreTree()}onGraphInit(){const{modes:t={}}=this.graph.getSpecification();rj(t[this.graph.getMode()||"default"])&&this.establishGraphCoreTree()}onBehaviorChange(t){const{action:e,modes:n,behaviors:r}=t,i=this.graph.getMode()||"default";"add"===e&&n.includes(i)&&rj(r)&&this.establishGraphCoreTree()}onModeChange(t){const{modes:e={}}=this.graph.getSpecification();rj(e[t.mode])&&this.establishGraphCoreTree()}establishGraphCoreTree(){if(!this.treeDirtyFlag)return;const t=this.graphCore.getAllNodes(),e=this.graphCore.getAllEdges(),n=t.filter((t=>t.data.isRoot)).map((t=>t.id));fP({},{nodes:t,edges:e},n).forEach((t=>{gP(t,(t=>{var e;null===(e=t.children)||void 0===e||e.forEach((e=>{this.graphCore.setParent(e.id,t.id,"tree")}))}))})),this.treeDirtyFlag=!1}changeData(t,e){var n;const{type:r,data:i}=this.formatData(t)||{};if(!r)return;this.dataType=r;const{nodes:o=[],edges:a=[],combos:s=[]}=this.transformData(i);if("replace"===e)this.graphCore=new TP(tn({nodes:o.concat((null==s?void 0:s.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),{_isCombo:!0})}))))||[]),edges:a})),(null==s?void 0:s.length)&&(this.graphCore.attachTreeStructure("combo"),o.forEach((t=>{t.data.parentId&&(dP(this.graph,t.id,t.data.parentId)?this.graphCore.setParent(t.id,t.data.parentId,"combo"):this.graphCore.mergeNodeData(t.id,{parentId:void 0}))})),s.forEach((t=>{t.data.parentId&&(dP(this.graph,t.id,t.data.parentId)?this.graphCore.setParent(t.id,t.data.parentId,"combo"):this.graphCore.mergeNodeData(t.id,{parentId:void 0}))})));else{const{graphCore:t}=this,n=oP({nodes:t.getAllNodes(),edges:[]}),r=o.concat(s.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),{_isCombo:!0})}))));if(n.nodes.length){if("mergeReplace"===e){const t=r.map((t=>t.id));n.nodes.forEach((e=>{t.includes(e.id)||this.removeNode(e)}))}r.forEach((e=>{t.hasNode(e.id)?t.mergeNodeData(e.id,e.data):t.addNode(e)}))}else t.addNodes(r);if(n.edges=t.getAllEdges(),n.edges.length){if("mergeReplace"===e){const e=a.map((t=>t.id));n.edges.forEach((n=>{e.includes(n.id)||t.removeEdge(n.id)}))}a.forEach((e=>{t.hasEdge(e.id)?t.mergeEdgeData(e.id,e.data):t.addEdge(e)}))}else t.addEdges(a)}if(null===(n=i.edges)||void 0===n?void 0:n.length){const{graphCore:t}=this;this.updateTreeGraph(r,{nodes:t.getAllNodes(),edges:t.getAllEdges()})}}removeNode(t){const{id:e,data:n}=t,{graphCore:r}=this;if(r.hasTreeStructure("combo")){r.setParent(e,void 0,"combo");const{parentId:t}=n;r.getChildren(e,"combo").forEach((e=>{r.setParent(e.id,t,"combo"),r.mergeNodeData(e.id,{parentId:t})}))}if(r.hasTreeStructure("tree")){const t=[];r.dfsTree(e,(e=>{t.push(e.id)}),"tree");const n=r.getAllEdges().filter((({source:e,target:n})=>t.includes(e)&&t.includes(n))).map((t=>t.id));this.graph.showItem(t.filter((t=>t!==e)).concat(n)),r.setParent(e,void 0,"tree"),r.getChildren(e,"tree").forEach((t=>r.setParent(t.id,void 0,"tree")))}r.removeNode(e)}removeData(t){const{graphCore:e}=this,{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.concat(i),a=e.getAllNodes(),s=e.getAllEdges();if(a.length&&o.length&&o.forEach((t=>{this.removeNode(t)})),s.length&&r.length){const t=r.map((t=>t.id)).filter((t=>e.hasEdge(t)));e.removeEdges(t)}}updateData(t){const{graphCore:e}=this,{type:n,data:r}=this.formatData(t);if(!n)return;const{nodes:i=[],edges:o=[],combos:a=[]}=r,{nodes:s,edges:l,combos:c}=oP({nodes:e.getAllNodes(),edges:e.getAllEdges()});if(s.length&&i.forEach((t=>{const{id:n,data:r}=t;if(r){const r=oj(e.getNode(n),t);e.mergeNodeData(n,r)}r.hasOwnProperty("parentId")&&e.setParent(n,r.parentId,"combo")})),l.length&&o.forEach((t=>{const n=e.getEdge(t.id);if(!n)return;const{id:r,source:i,target:o,data:a}=t;if(i&&n.source!==i&&e.updateEdgeSource(r,i),o&&n.target!==o&&e.updateEdgeTarget(r,o),a){const n=oj(e.getEdge(r),t);e.mergeEdgeData(r,n)}})),c.length){const t=[];a.forEach((n=>{const{id:r,data:i}=n;if(!i)return;const{x:o,y:a}=i,s=Nc(i,["x","y"]);if(void 0!==o||void 0!==a)if(this.graphCore.getChildren(r,"combo").length){const e=this.graph.getRenderBBox(r,!0);if(!e)return;const[i,s]=e.center,l=o-i,c=a-s;sP(this.graph,[n],(e=>{const{x:n,y:r,_isCombo:i}=e.data;i||t.push({id:e.id,data:{x:n+l,y:r+c}})}),"BT")}else t.push({id:r,data:{x:o,y:a}});if(Object.keys(s).length){const t=oj(e.getNode(r),{id:r,data:s});e.mergeNodeData(r,t),s.hasOwnProperty("parentId")&&e.setParent(r,s.parentId,"combo")}})),t.forEach((t=>{const{id:n,data:r}=t;e.mergeNodeData(n,r)}))}(null==o?void 0:o.filter((t=>t.hasOwnProperty("source")||t.hasOwnProperty("target"))).length)&&this.updateTreeGraph(n,{nodes:this.graphCore.getAllNodes(),edges:this.graphCore.getAllEdges()})}formatData(t){const{type:e,value:n}=t;let r=n;if(e){if("treeData"===e)r=pP(n);else if("fetch"===e);else if(!r.nodes)return void console.warn('Input data type is invalid, the type shuold be "graphData", "treeData", or "fetch".')}else r=t;return{type:e||this.dataType||"graphData",data:r}}moveCombo(t){const{combos:e=[]}=t,n=[];e.forEach((t=>{const{dx:e=0,dy:r=0}=t.data;if(e||r)if(this.graphCore.getChildren(t.id,"combo").length)sP(this.graph,[t],(t=>{const{x:i,y:o,_isCombo:a}=t.data;a&&this.graphCore.getChildren(t.id,"combo").length||n.push({id:t.id,data:{x:i+e,y:o+r}})}),"BT");else{const i=this.graphCore.getNode(t.id),{x:o=0,y:a=0}=i.data;n.push({id:t.id,data:{x:o+e,y:a+r}})}}));const{graphCore:r}=this;n.forEach((t=>{const{id:e,data:n}=t;if(n){const n=oj(r.getNode(e),t);r.mergeNodeData(e,n)}}))}addCombo(t){const{combos:e=[]}=t;if(!(null==e?void 0:e.length))return;const{graphCore:n}=this,{id:r,data:i}=e[0],{_children:o=[]}=i,a=Nc(i,["_children"]);n.hasTreeStructure("combo")||n.attachTreeStructure("combo"),n.hasNode(r)?n.mergeNodeData(r,Object.assign(Object.assign({},a),{_isCombo:!0})):n.addNode({id:r,data:Object.assign(Object.assign({},a),{_isCombo:!0})}),o.forEach((t=>{this.graphCore.hasNode(t)?(n.setParent(t,r,"combo"),n.mergeNodeData(t,{parentId:r})):console.warn(`Adding child ${t} to combo ${r} failed. The child ${t} does not exist`)}))}transformData(t){let e=tn(t);return this.extensions.forEach((({func:t,config:n})=>{e=t(e,n,this.graphCore)})),e}updateTreeGraph(t,e){this.graphCore.attachTreeStructure("tree"),"treeData"===t?e.edges.forEach((t=>{const{source:e,target:n}=t;this.graphCore.setParent(n,e,"tree")})):this.treeDirtyFlag=!0}}const oj=(t,e)=>{const{data:n}=e,{data:r}=t,i={};return Object.keys(n).forEach((t=>{Re(r[t])||Re(n[t])?i[t]=n[t]:"object"==typeof r[t]&&"object"==typeof n[t]?i[t]=Object.assign(Object.assign({},r[t]),n[t]):i[t]=n[t]})),i};var aj,sj;!function(t){t.pointerover="pointerover",t.pointerenter="pointerenter",t.pointerdown="pointerdown",t.pointermove="pointermove",t.pointerup="pointerup",t.pointerleave="pointerleave",t.click="click",t.wheel="wheel",t.dragstart="dragstart",t.drag="drag",t.dragend="dragend",t.dragenter="dragenter",t.dragleave="dragleave",t.dragover="dragover",t.dragout="dragout",t.drop="drop"}(aj||(aj={})),function(t){t.focus="focus",t.blur="blur",t.keyup="keyup",t.keydown="keydown",t.keypress="keypress"}(sj||(sj={}));const lj=t=>{var e;if("document"===t.nodeName)return{itemType:"canvas",itemId:void 0,groupElement:t};let n=t;for(;n&&!(null===(e=n.getAttribute)||void 0===e?void 0:e.call(n,"data-item-type"));)n=n.parentElement;return n?{itemType:n.getAttribute("data-item-type"),itemId:n.getAttribute("data-item-id"),groupElement:n}:null},cj=(t,e)=>Object.assign(Object.assign({},t),{type:"contextmenu",preventDefault:()=>{e.canvas.getContextService().getDomElement().addEventListener("contextmenu",(t=>{t.preventDefault()}),{once:!0})}});class uj{constructor(t){this.behaviorMap=new Map,this.listenersMap={},this.tap=()=>{this.graph.hooks.init.tap((()=>this.onModeChange({mode:"default"}))),this.onModeChange({mode:"default"}),this.graph.hooks.modechange.tap(this.onModeChange),this.graph.hooks.behaviorchange.tap(this.onBehaviorChange)},this.validateMode=t=>{if("default"===t)return!0;const e=this.graph.getSpecification().modes||{};return Object.keys(e).includes(t)},this.initBehavior=t=>{const e="string"==typeof t?t:t.key||t.type;if(this.behaviorMap.has(e))console.error(`G6: Failed to add behavior with key or type "${e}"! It was already added.`);else try{const n=ej(t,JH.useLib,"behavior"),r=new n("string"==typeof t?{}:t);return r.graph=this.graph,r&&this.behaviorMap.set(e,r),r}catch(t){return console.error(`G6: Failed to initialize behavior with key or type "${e}"!`,t),null}},this.destroyBehavior=(t,e)=>{try{e.destroy()}catch(e){console.error(`G6: Failed to destroy behavior with key or type "${t}"!`,e)}},this.addListeners=(t,e)=>{const n=e.getEvents();this.listenersMap[t]={},Object.keys(n).forEach((r=>{const i=((t,e,n)=>r=>{try{n(r)}catch(n){throw console.error(`G6: Error occurred in "${e}" phase of the behavior "${t}"!`),n}})(t,r,n[r].bind(e));this.graph.on(r,i),this.listenersMap[t][r]=i}))},this.removeListeners=t=>{Object.keys(this.listenersMap[t]||{}).forEach((e=>{const n=this.listenersMap[t][e];this.graph.off(e,n)}))},this.onModeChange=t=>{var e;const{mode:n}=t;if(this.mode===n)return;this.validateMode(n)||console.warn(`G6: Mode "${n}" was not specified in current graph.`),this.mode=n,this.behaviorMap.forEach(((t,e)=>{this.removeListeners(e),this.destroyBehavior(e,t)})),this.behaviorMap.clear();((null===(e=this.graph.getSpecification().modes)||void 0===e?void 0:e[n])||[]).forEach((t=>{this.initBehavior(t)})),this.listenersMap={},this.behaviorMap.forEach(((t,e)=>{this.addListeners(e,t)}))},this.onBehaviorChange=t=>{const{action:e,modes:n,behaviors:r}=t;n.forEach((t=>{t===this.mode&&("add"!==e?"remove"!==e?"update"===e&&r.forEach((t=>{const e="string"==typeof t?t:t.key||t.type,n=this.behaviorMap.get(e);n&&n.updateConfig(t)})):r.forEach((t=>{const e="string"==typeof t?t:t.key||t.type,n=this.behaviorMap.get(e);n&&(this.removeListeners(e),this.destroyBehavior(e,n))})):r.forEach((t=>{const e="string"==typeof t?t:t.key||t.type,n=this.initBehavior(t);n&&this.addListeners(e,n)})))}))},this.initEvents=()=>{Object.values(aj).forEach((t=>{this.graph.canvas.document.addEventListener(t,this.handleCanvasEvent)}));const t=this.graph.canvas.getContextService().getDomElement();Object.values(sj).forEach((e=>{t&&t.addEventListener&&t.addEventListener(e,this.handleDOMEvent)}))},this.handleCanvasEvent=t=>{const e=lj(t.target);if(!e)return;const{itemType:n,itemId:r}=e,i=Object.assign(Object.assign({},t),{itemType:n,itemId:r,gEvent:t,stopPropagation:t.stopPropagation,currentTarget:this.graph});if("click"===i.type&&2===i.detail&&this.handleCanvasEvent(Object.assign(Object.assign({},t),{type:"dblclick"})),"canvas"!==i.itemType){if(("node"===n||"edge"===n||"combo"===n)&&("pointermove"!==i.type&&"pointerleave"!==i.type||this.handlePointerMove(i),this.graph.emit(`${n}:${t.type}`,i),this.graph.emit(`${t.type}`,i),"pointerdown"===i.type&&2===i.button)){const t=cj(i,this.graph);this.graph.emit(`${n}:contextmenu`,t),this.graph.emit("contextmenu",t)}}else if("pointermove"===i.type&&this.handlePointerMove(i),this.graph.emit(`canvas:${t.type}`,i),this.graph.emit(`${t.type}`,i),"pointerdown"===i.type&&2===i.button){const t=cj(i,this.graph);this.graph.emit("canvas:contextmenu",t),this.graph.emit("contextmenu",t)}},this.handlePointerMove=t=>{const e=this.prevItemInfo,n=lj(t.target);if((null==e?void 0:e.itemId)!==(null==n?void 0:n.itemId)){if(e){const n=e.itemType;this.graph.emit(`${n}:pointerleave`,Object.assign(Object.assign({},t),{itemId:e.itemId,itemType:e.itemType,type:"pointerleave",target:e.groupElement}))}if(n){const e=n.itemType;this.graph.emit(`${e}:pointerenter`,Object.assign(Object.assign({},t),{type:"pointerenter",target:n.groupElement}))}}this.prevItemInfo=n},this.handleDOMEvent=t=>{this.graph.emit(t.type,t)},this.graph=t,this.initEvents(),this.tap()}getMode(){return this.mode}}const hj={node:t=>{const{id:e,data:n}=t,{color:r,label:i,icon:o,badges:a,keyShape:s}=n,l=Object.assign(Object.assign({},n),{keyShape:Object.assign({},s)});return r&&(l.keyShape.fill=r),i&&(l.labelShape={text:i}),o&&(l.iconShape=o),a&&(l.badgeShapes=a),{id:e,data:l}},edge:t=>{const{id:e,source:n,target:r,data:i}=t,{color:o,label:a,icon:s,badge:l,keyShape:c}=i,u=Object.assign(Object.assign({},i),{keyShape:Object.assign({},c)});return o&&(u.keyShape.stroke=o),a&&(u.labelShape={text:a}),s&&(u.iconShape=s),l&&(u.badgeShape=l),{id:e,source:n,target:r,data:u}},combo:t=>t};class dj{constructor(t){this.destroyed=!1,this.visible=!0,this.states=[],this.shapeMap={keyShape:void 0},this.afterDrawShapeMap={},this.transient=!1,this.stateDirtyMap={},this.cacheStateStyles={},this.cacheNotHiddenByItem={},this.cacheHiddenByItem={},this.animateFrameListener=pn((t=>{var e;null===(e=this.onframe)||void 0===e||e.call(this,t)}),16,{trailing:!0,leading:!0}),this.device=t.device,this.onframe=t.onframe}init(t){var e;const{model:n,containerGroup:r,mapper:i,stateMapper:o,renderExtensions:a,zoom:s=1,theme:l={},type:c}=t;this.type=c,this.group=new qs({style:{zIndex:0}}),this.group.setAttribute("data-item-type",this.type),this.group.setAttribute("data-item-id",t.model.id),r.appendChild(this.group),this.model=n,this.mapper=i,this.zoom=s,this.stateMapper=o,this.displayModel=this.getDisplayModelAndChanges(n).model,this.renderExtensions=a;const{type:u=("edge"===this.type?"line-edge":`circle-${this.type}`),lodStrategy:h,enableBalanceShape:d}=this.displayModel.data,p=a.find((t=>t.type===u));this.themeStyles=l.styles;const f=h?HB(h):l.lodStrategy;if(!p)throw"node"===this.type?new Error(`TypeError: RenderExtension is not a constructor. The '${u}' in your data haven't been registered. You can use built-in node types like 'rect-node', 'circle-node' or create a custom node type as you like.`):"edge"==this.type?new Error(`TypeError: RenderExtension is not a constructor. The '${u}' in your data haven't been registered. You can use built-in edge types like 'line-edge', 'quadratic-edge','cubic-edge' or create a custom edge type as you like.`):new Error(`TypeError: RenderExtension is not a constructor. The '${u}' haven't been registered.`);this.renderExt=new p({themeStyles:null===(e=this.themeStyles)||void 0===e?void 0:e.default,lodStrategy:f,enableBalanceShape:d,device:this.device,zoom:this.zoom})}draw(t,e,n,r=!0,i=(()=>{})){var o,a;this.afterDrawShapeMap=(null===(a=(o=this.renderExt).afterDraw)||void 0===a?void 0:a.call(o,t,Object.assign(Object.assign({},this.shapeMap),this.afterDrawShapeMap)))||{},this.shapeMap=VR(this.shapeMap,this.afterDrawShapeMap,this.group,!1,(t=>!gR.includes(t)||(console.warn(`Shape with id ${t} is reserved and should be returned in draw function, if the shape with ${t} returned by afterDraw is a new one, it will not be added to the group.`),!1))),this.changedStates=[]}update(t,e,n,r,i,o=!0,a){var s;this.model=t,r&&(this.themeStyles=r.styles);const{model:l,typeChange:c}=this.getDisplayModelAndChanges(this.model,e,n);if(this.displayModel=l,this.lodStrategy=l.data.lodStrategy?HB(l.data.lodStrategy):(null==r?void 0:r.lodStrategy)||this.lodStrategy,i)this.updatePosition(l,e,o,a);else{if(c){Object.values(this.shapeMap).forEach((t=>t.destroy())),this.shapeMap={keyShape:void 0};const{type:t=("node"===this.type?"circle-node":"line-edge")}=l.data,e=this.renderExtensions.find((e=>e.type===t));this.renderExt=new e({themeStyles:this.themeStyles.default,lodStrategy:this.lodStrategy,device:this.device,zoom:this.zoom})}else this.renderExt.themeStyles=this.themeStyles.default,this.renderExt.lodStrategy=this.lodStrategy;(null===(s=this.states)||void 0===s?void 0:s.length)?this.drawWithStates(this.states,o,a):this.draw(this.displayModel,e,void 0,o,a),this.stateDirtyMap={},this.states.forEach((({name:t})=>this.stateDirtyMap[t]=!0))}}updatePosition(t,e,n,r){}getDisplayModelAndChanges(t,e,n){const{mapper:r,type:i}=this,o=hj[i],{data:a}=t,s=Nc(t,["data"]),{current:l=a}=e||{};if(!r){let e=!1;return l&&(e=Boolean(l.type)),{model:o(t),typeChange:e}}if(Se(r))return{model:Object.assign(Object.assign({},o(t)),r(t))};const c=n?void 0:Object.keys(l).concat(Object.keys(s));let u=!1;const h=Nc(t,["data"]),d=o(t).data;return Object.keys(r).forEach((e=>{let n=r[e];const i=gR.includes(e),o=i||e===mR;if(o&&zB(n)||!o)if(d.hasOwnProperty(e))"type"!==e||c&&!c.includes("type")||(u=!0);else{const{changed:i,value:a}=pj({innerModel:t,mapper:r,fieldName:e,dataChangedFields:c});if(o){if(!a)return;n=a}else d[e]=a;i&&"type"===e&&(u=!0)}i?(d[e]=d[e]||Me(t.data[e])?Object.assign({},t.data[e]):{},fj({innerModel:t,mapper:n,dataChangedFields:c,shapeConfig:d[e],fieldPath:[e]})):e===mR&&(d[e]=d[e]||Me(t.data[e])?Object.assign({},t.data[e]):{},Object.keys(n).forEach((r=>{var i;if(!(null===(i=d[e])||void 0===i?void 0:i.hasOwnProperty(r))){d[e][r]=d[e][r]||{};const i=n[r];fj({innerModel:t,mapper:i,dataChangedFields:c,shapeConfig:d[e][r],fieldPath:[e,r]})}})))})),{model:Object.assign(Object.assign({},h),{data:d}),typeChange:u}}getID(){return this.model.id}getType(){return this.type}show(t=!0){Promise.all(this.stopAnimations()).finally((()=>{var e;if(this.destroyed)return;const{animates:n={}}=this.displayModel.data;if(t&&(null===(e=n.show)||void 0===e?void 0:e.length)){const t={};Object.values(n.show).forEach((e=>{const{shapeId:n="group"}=e;t[n]=(t[n]||[]).concat(e.fields)}));const e={};Object.keys(this.shapeMap).forEach((n=>{const r=this.shapeMap[n];if(this.cacheHiddenByItem[n]){if(t[n]){e[n]=e[n]||{};const i=TR(r);t[n].forEach((t=>{i.hasOwnProperty(t)&&(e[n][t]=r.style[t],r.style[t]=i[t])}))}r.show()}})),t.group&&!this.shapeMap.keyShape.isVisible()&&t.group.forEach((t=>{const e="size"===t?"transform":t;AR[0].hasOwnProperty(e)&&(this.group.style[e]=AR[0][e])})),Object.keys(e).length&&(this.animations=this.runWithAnimates(n,"show",e))}else Object.keys(this.shapeMap).forEach((t=>{const e=this.shapeMap[t];this.cacheHiddenByItem[t]&&e.show()}));this.visible=!0,this.cacheHiddenByItem={}}))}hide(t=!0,e=!1){this.cacheNotHiddenByItem={};const n=()=>{Object.keys(this.shapeMap).forEach((t=>{if(e&&"keyShape"===t)return;const n=this.shapeMap[t];n.isVisible()?(n.hide(),this.cacheHiddenByItem[t]=!0):this.cacheNotHiddenByItem[t]=!0}))};Promise.all(this.stopAnimations()).then((()=>{var e;if(this.destroyed)return;const{animates:r={}}=this.displayModel.data;t&&(null===(e=r.hide)||void 0===e?void 0:e.length)?this.animations=this.runWithAnimates(r,"hide",void 0,n):n(),this.visible=!1}))}isVisible(){return this.visible}toFront(){this.group.toFront()}toBack(){this.group.toBack()}hasState(t){const e=this.states.find((e=>e.name===t));return(null==e?void 0:e.value)||!1}setState(t,e){const n=tn(this.states),r=this.states.find((e=>e.name===t));if(e)r?r.value=e:this.states.push({name:t,value:e});else{const t=this.states.indexOf(r);this.states.splice(t,1)}this.renderExt.constructor.prototype.hasOwnProperty("setState")?this.renderExt.setState(t,e,this.shapeMap):(this.changedStates=[t],this.drawWithStates(n))}clearStates(t){const e=tn(this.states),n=[];let r=[];t?this.states.filter((e=>{t.includes(e.name)?r.push(e):n.push(e)})):r=this.states.map((({name:t,value:e})=>({name:t,value:!1}))),this.states=n,this.changedStates=r.map((t=>t.name)),this.renderExt.constructor.prototype.hasOwnProperty("setState")?r.forEach((({name:t,value:e})=>this.renderExt.setState(t,e,this.shapeMap))):this.drawWithStates(e)}getStates(){return this.states}runWithAnimates(t,e,n,r=(()=>{})){let i={};return n?i=n:Object.keys(this.shapeMap).forEach((t=>{i[t]=TR(this.shapeMap[t])})),PR(t,i,this.shapeMap,this.group,e,[],(()=>{}),r)}drawWithStates(t,e=!0,n){const r=Nc(this.themeStyles,["default"]),{data:i}=this.displayModel;let o={};this.states.forEach((({name:t,value:e})=>{var n;const a=this.cacheStateStyles[t]||{},s=null===(n=this.stateMapper)||void 0===n?void 0:n[t];if(!s&&!(null==r?void 0:r[t]))return;s&&e&&(!this.stateDirtyMap.hasOwnProperty(t)||this.stateDirtyMap[t])&&(this.stateDirtyMap[t]=!1,Object.keys(s).forEach((t=>{a[t]=Object.assign({},i[t]),gR.includes(t)?fj({innerModel:this.model,mapper:s[t],dataChangedFields:void 0,shapeConfig:a[t],fieldPath:[t]}):t===mR&&s[t]&&Object.keys(s[t]).forEach((e=>{a[t]=a[t]||{},a[t][e]=a[t][e]||{},fj({innerModel:this.model,mapper:s[t][e],dataChangedFields:void 0,shapeConfig:a[t][e],fieldPath:[t,e]})}))}))),this.cacheStateStyles[t]=a;const l=zR([r[t],a]);o=zR([o,l])})),this.draw(Object.assign(Object.assign({},this.displayModel),{data:zR([i,o])}),void 0,{previous:t,current:this.states},e,n)}getKeyBBox(){const{keyShape:t}=this.shapeMap;return(null==t?void 0:t.getRenderBounds())||{center:[0,0,0]}}getLocalKeyBBox(){const{keyShape:t}=this.shapeMap;return(null==t?void 0:t.getLocalBounds())||{center:[0,0,0]}}getBBox(){var t;if(null===(t=this.animations)||void 0===t?void 0:t.length){const{keyShape:t,labelShape:e}=this.shapeMap,{x:n=0,y:r=0,z:i=0}=this.displayModel.data,{keyShape:o,labelShape:a}=this.renderExt.mergedStyles,s=e?(t=>{const e={center:[0,0,0],min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0],size:[0,0,0]};return t.forEach((t=>{const{min:n,max:r}=t;n.forEach(((t,n)=>{t<e.min[n]&&(e.min[n]=t)})),r.forEach(((t,n)=>{t>e.max[n]&&(e.max[n]=t)}))})),e.center=e.center.map(((t,n)=>(e.max[n]+e.min[n])/2)),e})([JR(t,o),JR(e,a)]):JR(t,o);return[n,r,i].forEach(((t,e)=>{s.max[e]+=t,s.min[e]+=t,s.center[e]+=t})),s}return this.group.getRenderBounds()}stopAnimations(){var t,e,n,r;const i=[];if(null===(t=this.animations)||void 0===t?void 0:t.length)for(;this.animations.length;){const t=this.animations.pop();if("running"!==t.playState)break;i.push(OR(t)),null===(e=t.onManualCancel)||void 0===e||e.call(t)}if(null===(n=this.groupAnimations)||void 0===n?void 0:n.length){for(;this.groupAnimations.length;){const t=this.groupAnimations.pop();if("running"!==t.playState)break;i.push(OR(t)),null===(r=t.onManualCancel)||void 0===r||r.call(t)}this.groupAnimations=[]}return i}updateZoom(t){this.zoom=t,this.renderExt.onZoom(this.shapeMap,t,this.cacheHiddenByItem)}destroy(){var t;const e=()=>{this.group.destroy(),this.model=null,this.displayModel=null,this.destroyed=!0};this.stopAnimations();const{animates:n}=this.displayModel.data;(null===(t=null==n?void 0:n.buildOut)||void 0===t?void 0:t.length)&&!this.transient?this.animations=this.runWithAnimates(n,"buildOut",void 0,e):e()}}const pj=({innerModel:t,fieldName:e,mapper:n,dataChangedFields:r})=>{const i=n[e]||"";if(zB(i)){const{fields:e,formatter:n}=i;if(!r||_R(r,e)){return{changed:!0,value:n(t)||""}}return{changed:!1}}return{changed:!0,value:i}},fj=({innerModel:t,mapper:e,dataChangedFields:n,shapeConfig:r,fieldPath:i})=>{if(!e)return;let o=t.data;null==i||i.forEach((t=>{o=o[t]||{}})),Object.keys(e).forEach((i=>{if(null==o?void 0:o.hasOwnProperty(i))return;const{value:a}=pj({innerModel:t,mapper:e,fieldName:i,dataChangedFields:n});r[i]=a}))};class gj extends dj{constructor(t){super(t),this.init(Object.assign(Object.assign({},t),{type:t.type||"node"})),t.delayFirstDraw||this.draw(this.displayModel,void 0,void 0,!this.displayModel.data.disableAnimate,t.onfinish)}draw(t,e,n,r=!0,i=(()=>{})){var o;const{group:a,renderExt:s,shapeMap:l,model:c}=this;s.mergeStyles(t);const u=!(null===(o=this.shapeMap)||void 0===o?void 0:o.keyShape),h=s.draw(t,this.shapeMap,e,n);this.shapeMap=VR(l,h,a);const{animates:d,disableAnimate:p,x:f=0,y:g=0,z:m=0}=t.data;u?(a.style.x=f,a.style.y=g,a.style.z=m):(this.stopAnimations(),this.updatePosition(t,e,r,i));const{haloShape:v}=this.shapeMap;if(null==v||v.toBack(),super.draw(t,e,n,r,i),s.updateCache(this.shapeMap),u&&s.onZoom(this.shapeMap,this.zoom),r&&!p&&d){const t=(t=>{if(!t.update)return t;const e=[];return t.update.forEach((t=>{const{shapeId:n,fields:r}=t,i=[...r];if(!(t=>!t||"group"===t)(n))return void e.push(Object.assign(Object.assign({},t),{fields:i}));let o=!1;if(r.includes("x")){const t=i.indexOf("x");i.splice(t,1),o=!0}if(r.includes("y")){const t=i.indexOf("y");i.splice(t,1),o=!0}o?0!==i.length&&e.push(Object.assign(Object.assign({},t),{fields:i})):e.push(Object.assign(Object.assign({},t),{fields:i}))})),Object.assign(Object.assign({},t),{update:e})})(d);this.animations=PR(t,s.mergedStyles,this.shapeMap,a,u?"buildIn":"update",this.changedStates,this.animateFrameListener,(t=>i(c.id,t)))}}update(t,e,n,r,i,o,a){super.update(t,e,n,r,i,o,a)}updatePosition(t,e,n,r=(()=>{})){const{group:i}=this,{fx:o,fy:a,fz:s,x:l,y:c,z:u=0,animates:h,disableAnimate:d}=t.data,p={x:void 0===o?l:o,y:void 0===a?c:a,z:void 0===s?u:s};if(!(isNaN(p.x)||isNaN(p.y)||isNaN(p.z))){if(n&&!d&&(null==h?void 0:h.update)){const e=h.update.filter((({shapeId:t,fields:e=[]})=>(!t||"group"===t)&&(e.includes("x")||e.includes("y"))));if(e.length){const n=PR({update:e},{group:p},this.shapeMap,i,"update",[],this.animateFrameListener,(e=>r(t.id,e)));return void(this.groupAnimations=n)}}i.style.x=p.x,i.style.y=p.y,i.style.z=p.z,r(t.id,!n)}}clone(t,e,n){if(null==e?void 0:e.length){const n=new qs;return e.forEach((t=>{var e;if(!this.shapeMap[t]||this.shapeMap[t].destroyed)return;const r=this.shapeMap[t].cloneNode();r.style.opacity=(null===(e=this.renderExt.mergedStyles[t])||void 0===e?void 0:e.opacity)||1,n.appendChild(r)})),n.setPosition(this.group.getPosition()),t.appendChild(n),n}const r=tn(this.model);r.data.disableAnimate=n;const i=new gj({model:r,renderExtensions:this.renderExtensions,containerGroup:t,mapper:this.mapper,stateMapper:this.stateMapper,zoom:this.zoom,theme:{styles:this.themeStyles,lodStrategy:this.lodStrategy}});return Object.keys(this.shapeMap).forEach((t=>{this.shapeMap[t].isVisible()||i.shapeMap[t].hide()})),i}getAnchorPoint(t,e){const{anchorPoints:n=[]}=this.displayModel.data;return this.getIntersectPoint(t,this.getPosition(),n,e)}getIntersectPoint(t,e,n,r){const{keyShape:i}=this.shapeMap,o=i.nodeName,{x:a,y:s,z:l}=e,c=i.getRenderBounds(),u=c.max[0]-c.min[0],h=c.max[1]-c.min[1],d=n.map((t=>{const[e,n]=t;return{x:u*e+c.min[0],y:h*n+c.min[1]}}));if(void 0!==r&&d[r])return d[r];let p;switch(o){case"circle":p=Tk({x:a,y:s,r:i.attributes.r},t);break;case"ellipse":p=((t,e)=>{const{rx:n,ry:r,x:i,y:o}=t,a=e.x-i,s=e.y-o;let l=Math.atan2(s/r,a/n);return l<0&&(l+=2*Math.PI),{x:i+n*Math.cos(l),y:o+r*Math.sin(l)}})({x:a,y:s,rx:i.attributes.rx,ry:i.attributes.ry},t);break;case"mesh":p=e;break;default:p=Ak({x:c.min[0],y:c.min[1],width:u,height:h},t)}let f=p;return n.length&&(f||(f=t),f=_k(d,f).nearestPoint),f?(isNaN(l)||(f.z=l),f):{x:a,y:s,z:l}}getPosition(){if(this.shapeMap.keyShape&&void 0!==this.group.attributes.x&&3!==this.renderExt.dimensions){const{center:t}=this.shapeMap.keyShape.getRenderBounds();return{x:t[0],y:t[1],z:t[2]}}const{x:t=0,y:e=0,z:n=0,fx:r,fy:i,fz:o}=this.model.data;return{x:void 0===r?t:r,y:void 0===i?e:i,z:void 0===o?n:o}}}class mj extends dj{constructor(t){super(t),this.destroyed=!1,this.type="edge",this.cache={},this.init(Object.assign(Object.assign({},t),{type:"edge"}));const{sourceItem:e,targetItem:n,nodeMap:r}=t;this.sourceItem=e,this.targetItem=n,this.nodeMap=r,"node"===e.getType()&&this.nodeMap.set(e.getID(),e),"node"===e.getType()&&this.nodeMap.set(n.getID(),n),t.delayFirstDraw||this.draw(this.displayModel)}draw(t,e,n,r=!0,i=(()=>{})){var o,a;const{sourcePoint:s,targetPoint:l}=this.getEndPoints(t);this.renderExt.mergeStyles(t);const c=!(null===(o=this.shapeMap)||void 0===o?void 0:o.keyShape);this.renderExt.setSourcePoint(s),this.renderExt.setTargetPoint(l),this.renderExt.setNodeMap(this.nodeMap);const u=this.renderExt.draw(t,s,l,this.shapeMap,e,n);this.shapeMap=VR(this.shapeMap,u,this.group);const{animates:h,disableAnimate:d}=t.data,p=Object.assign({},h),f=this.renderExt.mergedStyles,{haloShape:g,labelShape:m}=this.shapeMap;null==g||g.toBack(),null==m||m.toFront(),super.draw(t,e,n),this.renderExt.updateCache(this.shapeMap),c?this.renderExt.onZoom(this.shapeMap,this.zoom):this.stopAnimations();r&&!d&&(null===(a=p[c?"buildIn":"update"])||void 0===a?void 0:a.length)&&(this.animations=PR(p,f,this.shapeMap,this.group,c?"buildIn":"update",this.changedStates,this.animateFrameListener,(e=>i(t.id,e)))),c&&!this.visible&&(this.visible=!0,this.hide(!1))}forceUpdate(){if(this.destroyed)return;const{sourcePoint:t,targetPoint:e,changed:n}=this.getEndPoints(this.displayModel);if(!n)return;this.renderExt.setSourcePoint(t),this.renderExt.setTargetPoint(e);const r=this.renderExt.draw(this.displayModel,t,e,this.shapeMap);this.shapeMap=VR(this.shapeMap,r,this.group)}updateEnd(t,e){"source"===t?this.sourceItem=e:"target"===t&&(this.targetItem=e),this.draw(this.displayModel)}getEndPoints(t){var e;const{sourceAnchor:n,targetAnchor:r,keyShape:i}=t.data,o=this.sourceItem.getPosition(),a=this.targetItem.getPosition();if(!this.shouldUpdatePoints(o,a,null==i?void 0:i.controlPoints))return{sourcePoint:this.cache.sourcePointCache,targetPoint:this.cache.targetPointCache,changed:!1};let s=o,l=a;if(null===(e=null==i?void 0:i.controlPoints)||void 0===e?void 0:e.length){const t=i.controlPoints.filter((t=>!xk(t,o)&&!xk(t,a)));l=_k(t,o).nearestPoint,s=_k(t,a).nearestPoint}return this.cache.sourcePointCache=this.sourceItem.getAnchorPoint(l,n),this.cache.targetPointCache=this.targetItem.getAnchorPoint(s,r),{sourcePoint:this.cache.sourcePointCache,targetPoint:this.cache.targetPointCache,changed:!0}}shouldUpdatePoints(t,e,n){const r="combo"===this.sourceItem.type||"combo"===this.targetItem.type,i=!(xk(t,this.cache.sourcePositionCache)&&xk(e,this.cache.targetPositionCache)&&n===this.cache.controlPointsCache)||r;return i&&(this.cache.sourcePositionCache=t,this.cache.targetPositionCache=e,this.cache.controlPointsCache=n),i}clone(t,e,n,r,i){if(null==r?void 0:r.length){const e=new qs;return r.forEach((t=>{var n;if(!this.shapeMap[t]||this.shapeMap[t].destroyed)return;const r=this.shapeMap[t].cloneNode();r.style.opacity=(null===(n=this.renderExt.mergedStyles[t])||void 0===n?void 0:n.opacity)||1,e.appendChild(r)})),t.appendChild(e),e}const o=tn(this.model);o.data.disableAnimate=i;const a=new mj({model:o,renderExtensions:this.renderExtensions,sourceItem:e,targetItem:n,nodeMap:this.nodeMap,containerGroup:t,mapper:this.mapper,stateMapper:this.stateMapper,zoom:this.zoom,theme:{styles:this.themeStyles,lodStrategy:this.lodStrategy}});return Object.keys(this.shapeMap).forEach((t=>{var e;this.shapeMap[t].isVisible()||null===(e=a.shapeMap[t])||void 0===e||e.hide()})),a}}class vj extends gj{constructor(t){super(Object.assign(Object.assign({},t),{type:"combo"})),this.forceUpdate=pn((()=>{this.updateModelByBounds(this.displayModel),this.destroyed||this.draw(this.displayModel)}),16,{leading:!0,trailing:!0})}init(t){this.getCombinedBounds=t.getCombinedBounds,this.getChildren=t.getChildren,super.init(t)}draw(t,e,n,r=!0,i=(()=>{})){t.data.collapsed&&Object.keys(this.themeStyles.collapsed).forEach((e=>{t.data[e]=t.data[e]||{},t.data[e]=Object.assign(Object.assign({},t.data[e]),this.themeStyles.collapsed[e]),"childCount"===this.themeStyles.collapsed[e].contentType&&(t.data[e].text=`${this.getChildren().length||0}`)})),super.draw(t,e,n,r,i)}getDisplayModelAndChanges(t,e,n){const r=super.getDisplayModelAndChanges(t,e,n),i=r.model;return{model:this.updateModelByBounds(i),typeChange:r.typeChange}}updateModelByBounds(t){const e=this.getCombinedBounds();if(this.cacheCombinedBounds=e,e){const{size:n,center:r}=e;if(t.data.x=r[0],t.data.y=r[1],t.data.z=r[2],!t.data.collapsed){t.data.keyShape=t.data.keyShape||{};const{padding:e=[0,0,0,0]}=t.data.keyShape,r=n[0]+e[1]+e[3],i=n[1]+e[0]+e[2];t.data.keyShape.width=r,t.data.keyShape.height=i,t.data.keyShape.r=Math.sqrt(r*r+i*i)/2}}return t}getPosition(){const{x:t=0,y:e=0,z:n=0}=this.model.data;this.cacheCombinedBounds=this.cacheCombinedBounds||this.getCombinedBounds();const{center:r}=this.cacheCombinedBounds||{};return r?{x:r[0],y:r[1],z:r[2]}:{x:t,y:e,z:n}}getIntersectPoint(t,e,n){var r,i;const{keyShape:o}=this.shapeMap,a=o.nodeName,{collapsed:s,keyShape:l}=this.displayModel.data,{x:c,y:u,z:h}=e;let d;if("circle"===a)d=Tk({x:c,y:u,r:(s?null==l?void 0:l.r:o.attributes.r)||o.attributes.r},t);else{const e=(null===(r=this.renderExt.boundsCache)||void 0===r?void 0:r.keyShapeLocal)||o.getLocalBounds();d=Ak(s?{x:c-l.width/2,y:u-l.height/2,width:l.width,height:l.height}:{x:c+e.min[0],y:u+e.min[1],width:e.max[0]-e.min[0],height:e.max[1]-e.min[1]},t)}let p=this.anchorPointsCache;if(!p){const t=(null===(i=this.renderExt.boundsCache)||void 0===i?void 0:i.keyShapeLocal)||this.shapeMap.keyShape.getLocalBounds(),e=t.max[0]-t.min[0],r=t.max[1]-t.min[1];p=n.map((t=>{const[n,i]=t;return{x:e*(n-.5)+c,y:r*(i-.5)+u}})),this.anchorPointsCache=p}let f=d;return n.length&&(f||(f=t),f=_k(p,f).nearestPoint),f||{x:c,y:u}}clone(t,e,n,r,i){if(null==e?void 0:e.length){const n=new qs;return e.forEach((t=>{var e;if(!this.shapeMap[t]||this.shapeMap[t].destroyed)return;const r=this.shapeMap[t].cloneNode();r.style.opacity=(null===(e=this.renderExt.mergedStyles[t])||void 0===e?void 0:e.opacity)||1,n.appendChild(r)})),n.setPosition(this.group.getPosition()),t.appendChild(n),n}const o=tn(this.model);o.data.disableAnimate=n;const a=new vj({model:o,renderExtensions:this.renderExtensions,containerGroup:t,mapper:this.mapper,stateMapper:this.stateMapper,zoom:this.zoom,theme:{styles:this.themeStyles,lodStrategy:this.lodStrategy},getCombinedBounds:r||this.getCombinedBounds,getChildren:i||this.getChildren});return Object.keys(this.shapeMap).forEach((t=>{this.shapeMap[t].isVisible()||a.shapeMap[t].hide()})),a}}class yj{constructor(t){this.nodeExtensions=[],this.edgeExtensions=[],this.comboExtensions=[],this.itemMap=new Map,this.nodeDataTypeSet=new Set,this.edgeDataTypeSet=new Set,this.comboDataTypeSet=new Set,this.transientObjectMap=new Map,this.transientItemMap=new Map,this.onViewportChange=en((({transform:t,effectTiming:e,tileLodSize:n=1e3})=>{const{zoom:r}=t;if(r){const t=this.graph.getZoom(),e=this.graph.getCanvasRange(),r=Array.from(this.itemMap,(([t,e])=>e)),i=[],o=[];r.forEach((t=>{const{keyShape:n}=t.shapeMap;if(!n)return;((t,e,n)=>n?t.min[0]>e.min[0]-e.halfExtents[0]*n&&t.max[0]<e.max[0]+e.halfExtents[0]*n&&t.min[1]>e.min[1]-e.halfExtents[1]*n&&t.max[1]<e.max[1]+e.halfExtents[1]*n:t.min[0]>e.min[0]&&t.max[0]<e.max[0]&&t.min[1]>e.min[1]&&t.max[1]<e.max[1])(n.getRenderBounds(),e,.4)?i.push(t):o.push(t)}));const a=i.concat(o),s=Math.ceil(r.length/n),l=Array.from({length:s},((t,e)=>a.slice(e*n,e*n+n)));let c;const u=()=>{l.length?(l.shift().forEach((e=>e.updateZoom(t))),c=requestAnimationFrame(u)):cancelAnimationFrame(c)};c=requestAnimationFrame(u),this.zoom=t}}),500,!1),this.onThemeChange=({theme:t})=>{if(!t)return;const{nodeDataTypeSet:e,edgeDataTypeSet:n}=this,{node:r,edge:i}=t;this.itemMap.forEach((t=>{const o=t.getType(),a="node"===o?r:i,s="node"===o?e:n,{dataTypeField:l}=a;let c;l&&(c=t.model.data[l]);const u=Ej(s,l,c,a);t.update(t.model,void 0,!1,u)}))},this.onMapperChange=({type:t,mapper:e})=>{e&&this.itemMap.forEach((n=>{n.getType()===t&&(n.mapper=e,n.update(n.model,void 0,!1))}))},this.onDestroy=()=>{Object.values(this.itemMap).forEach((t=>t.destroy())),this.itemMap.clear()},this.graph=t;const{node:e,edge:n,combo:r,nodeState:i={},edgeState:o={},comboState:a={}}=t.getSpecification();this.nodeMapper=e,this.edgeMapper=n,this.comboMapper=r,this.nodeStateMapper=i,this.edgeStateMapper=o,this.comboStateMapper=a,this.tap()}tap(){const t=this.getExtensions();this.nodeExtensions=t.node,this.edgeExtensions=t.edge,this.comboExtensions=t.combo,this.graph.hooks.render.tap(this.onRender.bind(this)),this.graph.hooks.itemchange.tap(this.onChange.bind(this)),this.graph.hooks.itemstatechange.tap(this.onItemStateChange.bind(this)),this.graph.hooks.itemvisibilitychange.tap(this.onItemVisibilityChange.bind(this)),this.graph.hooks.itemzindexchange.tap(this.onItemZIndexChange.bind(this)),this.graph.hooks.transientupdate.tap(this.onTransientUpdate.bind(this)),this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this)),this.graph.hooks.themechange.tap(this.onThemeChange.bind(this)),this.graph.hooks.mapperchange.tap(this.onMapperChange.bind(this)),this.graph.hooks.treecollapseexpand.tap(this.onTreeCollapseExpand.bind(this)),this.graph.hooks.destroy.tap(this.onDestroy.bind(this))}getExtensions(){this.graph.getSpecification();const t=Object.keys(JH.useLib.nodes||{}),e=Object.keys(JH.useLib.edges||{}),n=Object.keys(JH.useLib.combos||{});return{node:t.map((t=>ej(t,JH.useLib,"node"))).filter(Boolean),edge:e.map((t=>ej(t,JH.useLib,"edge"))).filter(Boolean),combo:n.map((t=>ej(t,JH.useLib,"combo"))).filter(Boolean)}}onRender(t){return Oc(this,void 0,void 0,(function*(){const{graphCore:e,theme:n={},transientCanvas:r,tileOptimize:i={}}=t,{graph:o}=this;o.canvas.removeChildren();const a=new qs({id:"combo-group",style:{zIndex:0}}),s=new qs({id:"edge-group",style:{zIndex:1}}),l=new qs({id:"node-group",style:{zIndex:2}});if(o.canvas.appendChild(a),o.canvas.appendChild(s),o.canvas.appendChild(l),this.nodeGroup=l,this.edgeGroup=s,this.comboGroup=a,r.removeChildren(),this.transientComboGroup=new qs({id:"combo-group",style:{zIndex:0}}),this.transientEdgeGroup=new qs({id:"edge-group",style:{zIndex:1}}),this.transientNodeGroup=new qs({id:"node-group",style:{zIndex:2}}),r.appendChild(this.transientComboGroup),r.appendChild(this.transientEdgeGroup),r.appendChild(this.transientNodeGroup),"webgl-3d"===o.rendererType){const t=new gg({style:{fill:"white",intensity:2*Math.PI}}),e=new mg({style:{fill:"white",direction:[-1,0,1],intensity:.7*Math.PI}});o.canvas.appendChild(t),o.canvas.appendChild(e);const{width:n,height:r}=o.canvas.getConfig();o.canvas.getCamera().setPerspective(.1,5e4,45,n/r)}const{nodes:c,edges:u,combos:h}=oP({nodes:e.getAllNodes(),edges:e.getAllEdges()}),d=this.renderNodes(c,n.node,i);let p;d&&(p=yield d),this.renderCombos(h,n.combo,e);const f=this.renderEdges(u,n.edge,i,p);if(f&&(yield f),this.sortByComboTree(e),e.hasTreeStructure("combo")&&aP(e,e.getRoots("combo"),(t=>{t.data.collapsed&&this.collapseCombo(e,t)}),"BT","combo"),e.hasTreeStructure("tree")){const t=[];aP(e,e.getRoots("tree"),(e=>{e.data.collapsed&&t.push(e)}),"BT","tree"),this.collapseSubTree(t,e,!1)}}))}onChange(t){const{changes:e,graphCore:n,action:r,animate:i=!0,upsertAncestors:o=!0,theme:a={},callback:s=(()=>{})}=t,l=((t,e)=>{const n={NodeRemoved:[],EdgeRemoved:[],NodeAdded:[],EdgeAdded:[],NodeDataUpdated:[],EdgeUpdated:[],EdgeDataUpdated:[],TreeStructureChanged:[],ComboStructureChanged:[],TreeStructureAttached:[],TreeStructureDetached:[]};return e.forEach((e=>{const{type:r}=e;if(["NodeDataUpdated","EdgeUpdated","EdgeDataUpdated"].includes(r)){const{id:i}=e;if(!t.hasNode(i)&&!t.hasEdge(i)){const o=Number(i);return void((!isNaN(o)&&t.hasNode(o)||t.hasEdge(o))&&n[r].push(Object.assign(Object.assign({},e),{id:o})))}}else{if("TreeStructureChanged"===r)return void("combo"===e.treeKey?n.ComboStructureChanged.push(e):"tree"===e.treeKey&&n.TreeStructureChanged.push(e));if(["NodeRemoved","EdgeRemoved","TreeStructureAttached","TreeStructureDetached"].includes(r))n[r].push(e);else{const{id:i}=e.value;if(!t.hasNode(i)&&!t.hasEdge(i)){const o=Number(i);return void((!isNaN(o)&&t.hasNode(o)||t.hasEdge(o))&&n[r].push(Object.assign(Object.assign({},e),{value:Object.assign(Object.assign({},e.value),{id:o})})))}}}n[r].push(e)})),n})(n,e),{itemMap:c}=this;[...l.EdgeRemoved,...l.NodeRemoved].forEach((({value:t})=>{const{id:e}=t,n=c.get(e);n&&(n.destroy(),c.delete(e))}));const{node:u={},edge:h={},combo:d={}}=a;if(l.NodeAdded.length){const t=[],e=[];l.NodeAdded.map((t=>t.value)).forEach((n=>{n.data._isCombo?e.push(n):t.push(n)})),t.length&&this.renderNodes(t,u),e.length&&this.renderCombos(e,d,n)}if(l.EdgeAdded.length&&this.renderEdges(l.EdgeAdded.map((t=>t.value)),h),l.NodeDataUpdated.length){const t={};l.NodeDataUpdated.forEach((e=>{const{id:n,propertyName:r,newValue:i,oldValue:o}=e;t[n]=t[n]||{id:n,previous:{},current:{}},r?(t[n].previous[r]=o,t[n].current[r]=i):t[n]={id:n,isReplace:!0,previous:o,current:i}}));const{dataTypeField:e}=u,a=new Set,h=new Set,d=t=>{(t?[...t]:[...h,...a]).forEach((t=>{const e=c.get(t);e&&!e.destroyed&&e.forceUpdate()}))},p=en(d,16,!1);Object.values(t).forEach((t=>{var l;const{isReplace:p,previous:f,current:g,id:m}=t;if(!n.hasNode(m))return;const v="updatePosition"===r,y=c.get(m);if(!y||y.destroyed)return;const E=y.getType(),_=n.getNode(m);if("node"===E&&v){const{x:t,y:e,fx:n,fy:r}=g;if(isNaN(t)&&isNaN(e)&&isNaN(n)&&isNaN(r))return void s(_,!0)}const b=new Set;if(n.hasTreeStructure("combo")){"combo"===E&&g.collapsed!==f.collapsed&&(g.collapsed?this.collapseCombo(n,_):!1===g.collapsed&&this.expandCombo(n,_));const t=y.displayModel.data.parentId;if(o){const e=[_];t&&t!==g.parentId&&n.hasNode(t)&&e.push(n.getNode(t)),lP(this.graph,n,e,(t=>{t.data._isCombo&&t.id!==_.id&&h.add(t.id);n.getRelatedEdges(t.id).forEach((t=>{a.add(t.id),b.add(t.id)}))}))}else"combo"===E&&sP(this.graph,[_],(t=>{n.getRelatedEdges(t.id).forEach((t=>{a.add(t.id),b.add(t.id)})),t.data._isCombo&&t.id!==_.id&&h.add(t.id)}))}let S;e&&f[e]!==g[e]&&(S=Ej(this.nodeDataTypeSet,e,g[e],u));let x;((null===(l=null==_?void 0:_.data)||void 0===l?void 0:l.preventPolylineEdgeOverlap)||!1?this.findNearEdgesByNode(m,n).concat(n.getRelatedEdges(m)):n.getRelatedEdges(m)).forEach((t=>{a.add(t.id),b.add(t.id)})),y.onframe=()=>d(b),_.data._isCombo&&f.collapsed!==g.collapsed&&(x=this.graph.getItemAllStates(m),this.graph.clearItemState(m)),y.update(_,{previous:f,current:g},p,S,v,i,pn(((t,e)=>{var n;null===(n=y.onframe)||void 0===n||n.call(y,!0),y.onframe=void 0,x&&x.forEach((t=>this.graph.setItemState(m,t,!0))),s(_,e)}),500,{leading:!0,trailing:!0}));const T=this.itemMap.get(g.parentId);g.parentId&&(null==T?void 0:T.model.data.collapsed)&&this.graph.executeWithNoStack((()=>{this.graph.hideItem(_.id,!1)}))})),p()}if(l.EdgeDataUpdated.length){const t={};l.EdgeDataUpdated.forEach((e=>{const{id:n,propertyName:r,newValue:i,oldValue:o}=e;t[n]=t[n]||{id:n,previous:{},current:{}},r?(t[n].previous[r]=o,t[n].current[r]=i):t[n]={id:n,isReplace:!0,previous:o,current:i}}));const{dataTypeField:e=""}=h;Object.values(t).forEach((t=>{const{isReplace:r,current:o,previous:a,id:l}=t;let u;a[e]!==o[e]&&(u=Ej(this.edgeDataTypeSet,e,o[e],h));const d=c.get(l),p=n.getEdge(l);d&&!d.destroyed&&d.update(p,{current:o,previous:a},r,u,void 0,i,((t,e)=>s(p,e)))}))}if(l.EdgeUpdated.length){const t={};l.EdgeUpdated.forEach((e=>{const{id:n,propertyName:r,newValue:i}=e;t[n]=t[n]||{id:n},t[n][r]=i})),Object.values(t).forEach((t=>{const{source:e,target:n,id:r}=t,i=c.get(r);void 0!==e&&i.updateEnd("source",this.itemMap.get(e)),void 0!==n&&i.updateEnd("target",this.itemMap.get(n))}))}l.ComboStructureChanged.length&&this.sortByComboTree(n),l.TreeStructureChanged.length&&l.TreeStructureChanged.forEach((t=>{const{nodeId:e}=t;let r=n.getParent(e,"tree");for(;r;){if(r.data.collapsed){this.graph.hideItem(e,!0);break}r=n.getParent(r.id,"tree")}}))}onItemStateChange(t){const{ids:e,states:n,value:r}=t;e.forEach((t=>{const e=this.itemMap.get(t);e?n&&r?n.forEach((t=>e.setState(t,r))):e.clearStates(n):console.warn(`Fail to set state for item ${t}, which is not exist.`)}))}onItemVisibilityChange(t){const{ids:e,value:n,graphCore:r,animate:i=!0,keepKeyShape:o=!1}=t;e.forEach((t=>{const e=this.itemMap.get(t);if(!e)return void console.warn(`Fail to set visibility for item ${t}, which is not exist.`);const a=e.getType();if(n)if("edge"===a)e.show(i);else{if(r.hasTreeStructure("combo")){let t=!1;if(uP(r,[e.model],(e=>(e.data.collapsed&&(t=!0),t))),t)return}const n=r.getRelatedEdges(t);e.show(i),n.forEach((({id:t,source:e,target:n})=>{var r;this.getItemVisible(e)&&this.getItemVisible(n)&&(null===(r=this.itemMap.get(t))||void 0===r||r.show(i))}))}else if(e.hide(i,o),"edge"!==a){r.getRelatedEdges(t).forEach((({id:t})=>{var e;null===(e=this.itemMap.get(t))||void 0===e||e.hide(i)}))}}))}onItemZIndexChange(t){const{ids:e=[],action:n,graphCore:r}=t;e.forEach((t=>{const e=this.itemMap.get(t);e&&("front"===n?(e.toFront(),r.hasTreeStructure("combo")&&sP(this.graph,[e.model],(t=>{if(t.data._isCombo){const e=this.itemMap.get(t.id);e&&e.toFront()}}),"TB")):(e.toBack(),r.hasTreeStructure("combo")&&cP(this.graph,[e.model],(t=>{var e;null===(e=this.itemMap.get(t.id))||void 0===e||e.toBack()}))))}))}onTransientUpdate(t){var e,n;const{transientObjectMap:r}=this,{type:i,id:o,config:a={},canvas:s,graphCore:l}=t,{style:c={},data:u={},capture:h,action:d,shapeIds:p,drawSource:f,drawTarget:g,upsertAncestors:m,visible:v=!0}=a,y="node"===i||"edge"===i||"combo"===i;if("remove"===d){if(y){const t=this.transientItemMap.get(o);return"combo"===i&&aP(l,[l.getNode(o)],(t=>{const e=this.transientItemMap.get(t.id);e&&!e.destroyed&&e.destroy(),this.transientItemMap.delete(t.id)}),"BT"),t&&!t.destroyed&&((null===(n=(e=t).getType)||void 0===n?void 0:n.call(e))||t.remove(),t.destroy()),void this.transientItemMap.delete(o)}{const t=r.get(o);return t&&!t.destroyed&&t.destroy(),void r.delete(o)}}if(y){const t=this.itemMap.get(o);if(!t)return void console.warn(`Fail to draw transient item of ${o}, which is not exist.`);const e=KD(t,this.transientNodeGroup,this.transientEdgeGroup,this.transientComboGroup,this.transientItemMap,this.itemMap,l,{shapeIds:p,drawSource:f,drawTarget:g,visible:v},m);if(p){if(("node"===i||"combo"===i)&&u.hasOwnProperty("x")&&u.hasOwnProperty("y")){const{x:t,y:n}=u;e.setPosition([t,n])}}else{const t=e,n=u.hasOwnProperty("x")&&u.hasOwnProperty("y");if("combo"===i&&n){const{x:e,y:n}=u,{x:r=e,y:i=n}=t.displayModel.data,o=e-r,a=n-i;aP(l,[t.model],(t=>{const e=this.transientItemMap.get(t.id);if(!e)return;const{x:n=0,y:r=0}=e.model.data;null==e||e.update(Object.assign(Object.assign({},e.model),{data:Object.assign(Object.assign({},e.model.data),{x:n+o,y:r+a})}))}),"BT")}if(l.hasTreeStructure("combo")&&"edge"!==i&&n){let e=l.getParent(t.model.id,"combo");for(;e;){const t=this.transientItemMap.get(e.id);t&&t.forceUpdate(),e=l.getParent(e.id,"combo")}}t.update(Object.assign(Object.assign({},t.model),{data:Object.assign(Object.assign({},t.model.data),u)}))}return}const E=String(o),_=GR(i,E,c,Object.fromEntries(r));r.set(E,_),_.style.pointerEvents=h?"auto":"none",s.getRoot().appendChild(_)}getTransient(t){return this.transientObjectMap.get(t)}getTransientItem(t){return this.transientItemMap[t]}findDisplayModel(t){var e;return null===(e=this.itemMap.get(t))||void 0===e?void 0:e.displayModel}renderNodes(t,e={},n){return Oc(this,void 0,void 0,(function*(){const{nodeExtensions:r,nodeGroup:i,nodeDataTypeSet:o,graph:a}=this,{dataTypeField:s=""}=e,{tileFirstRender:l,tileFirstRenderSize:c=1e3}=n||{},u=a.getZoom(),h=Ue(l)?t.length>l:l,d=[],p=[],f=this.graph.getCanvasRange();if(t.forEach((t=>{let n;s&&(n=t.data[s]);const l=Ej(o,s,n,e),c=new gj({delayFirstDraw:h,model:t,renderExtensions:r,containerGroup:i,mapper:this.nodeMapper,stateMapper:this.nodeStateMapper,zoom:u,theme:l,device:"webgl-3d"===a.rendererType?a.canvas.context.deviceRendererPlugin.getDevice():void 0});this.itemMap.set(t.id,c);const{x:g,y:m}=c.model.data;h&&((t,e)=>{const{x:n,y:r}=t;return n>e.min[0]&&n<e.max[0]&&r>e.min[1]&&r<e.max[1]})({x:g,y:m},f)?d.push(c):p.push(c)})),h){let t;const e=Math.ceil(p.length/c),n=Array.from({length:e},((t,e)=>p.slice(e*c,e*c+c)));n.unshift(d);const r=e=>{if(!n.length)return cancelAnimationFrame(t),e(d);n.shift().forEach((t=>t.draw(t.displayModel,void 0,void 0,!t.displayModel.data.disableAnimate))),t=requestAnimationFrame((()=>r(e)))};return new Promise((e=>{t=requestAnimationFrame((()=>r(e)))}))}}))}renderCombos(t,e={},n){return Oc(this,void 0,void 0,(function*(){const{comboExtensions:r,comboGroup:i,comboDataTypeSet:o,graph:a,itemMap:s}=this,{dataTypeField:l=""}=e,c=a.getZoom();t.forEach((t=>{let u;l&&(u=t.data[l]);const h=Ej(o,l,u,e),d=()=>((t,e)=>{if(!e.length)return!1;const n={center:[0,0,0],min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0],size:[0,0,0]};let r=0;return e.forEach((e=>{const i=t.getRenderBBox(e.model.id);if(i){if(e.model.data._isCombo){const{center:t}=e.getCombinedBounds()||{};t&&["min","max","center"].forEach((e=>{i[e]=i[e].map(((e,n)=>e-i.center[n]+t[n]))}))}r++;const{min:t,max:o}=i;t.forEach(((t,e)=>{t<n.min[e]&&(n.min[e]=t)})),o.forEach(((t,e)=>{t>n.max[e]&&(n.max[e]=t)}))}})),!!r&&(n.size=n.size.map(((t,e)=>n.max[e]-n.min[e])),n.center=n.center.map(((t,e)=>(n.max[e]+n.min[e])/2)),n)})(a,n.getChildren(t.id,"combo").map((({id:t})=>s.get(t))).filter(Boolean)),p=()=>n.getChildren(t.id,"combo").map((({id:t})=>s.get(t))),f=new vj({model:t,getCombinedBounds:d,getChildren:p,renderExtensions:r,containerGroup:i,mapper:this.comboMapper,stateMapper:this.comboStateMapper,zoom:c,theme:h,device:"webgl-3d"===a.rendererType?a.canvas.context.deviceRendererPlugin.getDevice():void 0});f.getCombinedBounds=d,f.getChildren=p,f.type="combo",s.set(t.id,f)}))}))}renderEdges(t,e={},n,r){const{edgeExtensions:i,edgeGroup:o,itemMap:a,edgeDataTypeSet:s,graph:l}=this,{dataTypeField:c=""}=e,{tileFirstRender:u,tileFirstRenderSize:h=1e3}=n||{},d=l.getZoom(),p=_j(a,"node"),f=Ue(u)?t.length>u:u,g=new Set(null==r?void 0:r.map((t=>t.getID()))),m=[],v=[];if(t.forEach((t=>{const{source:n,target:r,id:l}=t,u=a.get(n),h=a.get(r);if(!u)return void console.warn(`The source node ${n} is not exist in the graph for edge ${l}, please add the node first`);if(!h)return void console.warn(`The source node ${n} is not exist in the graph for edge ${l}, please add the node first`);let y;c&&(y=t.data[c]);const E=Ej(s,c,y,e),_=new mj({delayFirstDraw:f,model:t,renderExtensions:i,containerGroup:o,mapper:this.edgeMapper,stateMapper:this.edgeStateMapper,sourceItem:u,targetItem:h,nodeMap:p,zoom:d,theme:E});return a.set(l,_),g.has(n)||g.has(r)?m.push(_):v.push(_),_})),f){let t;const e=Math.ceil(v.length/h),n=Array.from({length:e},((t,e)=>v.slice(e*h,e*h+h)));n.unshift(m);const r=e=>{if(!n.length)return cancelAnimationFrame(t),e();n.shift().forEach((t=>t.draw(t.displayModel))),t=requestAnimationFrame((()=>r(e)))};return new Promise((e=>{t=requestAnimationFrame((()=>r(e)))}))}}findIdByState(t,e,n=!0){const r=[];return this.itemMap.forEach((i=>{i.getType()===t&&i.hasState(e)===n&&r.push(i.getID())})),r}getItemState(t,e){const n=this.itemMap.get(t);return n?n.hasState(e):(console.warn(`Fail to get item state, the item with id ${t} does not exist.`),!1)}getItemAllStates(t){const e=this.itemMap.get(t);return e?e.getStates().filter((({value:t})=>t)).map((({name:t})=>t)):(console.warn(`Fail to get item state, the item with id ${t} does not exist.`),[])}getItemById(t){return this.itemMap.get(t)}getItemBBox(t,e=!1,n=!1){const r=n?this.transientItemMap.get(t):this.itemMap.get(t);return r?r instanceof qs?r.getRenderBounds():e?r.getKeyBBox():r.getBBox():(console.warn(`Fail to get item bbox, the item with id ${t} does not exist.`),!1)}getItemVisible(t){const e=this.itemMap.get(t);return e?e.isVisible():(console.warn(`Fail to get item visible, the item with id ${t} does not exist.`),!1)}findNearEdgesByNode(t,e){var n;const r=e.getAllEdges(),i=this.graph.getRenderBBox(void 0),o=new Lk(i,4);Ce(r,(t=>{const{data:{x:n,y:r}}=e.getNode(t.source),{data:{x:i,y:a}}=e.getNode(t.target);o.insert({id:t.id,p1:{x:n,y:r},p2:{x:i,y:a},bbox:this.graph.getRenderBBox(t.id)})}));const a=this.getTransientItem(t)||this.getItemById(t),s=this.graph.getRenderBBox(t),l=null===(n=null==a?void 0:a.model)||void 0===n?void 0:n.data;l&&s.update([l.x,l.y,0],s.halfExtents);const c=new Fk(o).getCollidingEdges(s);return hn(c,(t=>e.getEdge(t.id)))}sortByComboTree(t){t.hasTreeStructure("combo")&&aP(t,t.getRoots("combo"),(t=>{const e=this.itemMap.get(t.id);t.data._isCombo&&e&&e.toFront()}))}collapseCombo(t,e){let n=[];const r=[];sP(this.graph,[e],(i=>{i.id!==e.id&&this.graph.executeWithNoStack((()=>{this.graph.hideItem(i.id,!1)})),n=n.concat(t.getRelatedEdges(i.id)),r.push(i.id)}));const i=[];Be(n).forEach((t=>{const{id:n,source:o,target:a}=t;if(!this.graph.getItemVisible(n))return;const s=r.includes(o),l=r.includes(a);if(s&&l)return;const c=s?e.id:o,u=l?e.id:a;i.push({source:c,target:u})})),this.graph.executeWithNoStack((()=>{this.graph.addData("edge",bj(i))}))}expandCombo(t,e){let n=!1;if(uP(t,[e],(t=>!!t.data.collapsed&&(n=!0,!0))),n)return;const r=[];let i=[];const o=[];sP(this.graph,[e],(n=>{t.getRelatedEdges(n.id).forEach((t=>{t.data._virtual?r.push(t.id):i.push(t.id)})),n.id!==e.id&&(t.getNode(n.data.parentId).data.collapsed||o.push(n.id),n.data._isCombo&&n.data.collapsed&&this.collapseCombo(t,n))}));const a=[],s=new Map;i=Be(i.filter((e=>{const{source:n,target:r}=t.getEdge(e),i={source:n,target:r},l={source:this.graph.getItemVisible(n)||o.includes(n),target:this.graph.getItemVisible(r)||o.includes(r)};if(l.source&&l.target)return!0;const c={source:void 0,target:void 0};return Object.keys(c).forEach((e=>{l[e]?c[e]=i[e]:(s.get(i[e])||uP(t,[t.getNode(i[e])],(t=>{s.has(i[e])||(this.graph.getItemVisible(t.id)||o.includes(t.id))&&s.set(i[e],t.id)})),c[e]=s.get(i[e]))})),void 0!==c.source&&void 0!==c.target&&a.push(c),!1}))),this.graph.executeWithNoStack((()=>{this.graph.removeData("edge",Be(r)),this.graph.showItem(i.concat(o)),this.graph.addData("edge",bj(a))}))}onTreeCollapseExpand(t){const{ids:e,animate:n,action:r,graphCore:i}=t,o=e.map((t=>i.getNode(t)));if("collapse"===r)this.collapseSubTree(o,i,n);else this.expandSubTree(o,i,n)}collapseSubTree(t,e,n=!0){let r=[];t.forEach((t=>{let n=!0;const i=[];aP(e,[t],(r=>{var o;if(r.id===t.id)return;const a=e.getNeighbors(r.id);!(null===(o=e.getChildren(r.id,"tree"))||void 0===o?void 0:o.length)&&a.length>1&&(n=!1),i.push(r)}),"TB","tree",{stopAllFn:()=>!n}),n&&(r=r.concat(i.map((e=>({id:e.id,data:{x:t.data.x,y:t.data.y}})))))})),r.length&&this.graph.updateNodePosition(r,void 0,!n,((t,e)=>{this.graph.hideItem(t.id,e)}),void 0)}expandSubTree(t,e,n=!0){return Oc(this,void 0,void 0,(function*(){let r=[],i=[];t.forEach((t=>{const n=[];aP(e,[t],(t=>n.push(t.id)),"TB","tree",{stopBranchFn:e=>{const r=e.id!==t.id&&e.data.collapsed;return r&&n.push(e.id),r}}),i=i.concat(e.getAllEdges().filter((t=>n.includes(t.source)&&n.includes(t.target))).map((t=>t.id))),r=r.concat(n.filter((e=>e!==t.id)))}));const o=Be(r.concat(i));this.graph.showItem(o,!n),yield this.graph.layout(void 0,!n)}))}}const Ej=(t,e,n,r)=>{const{styles:i=[],lodStrategy:o}=r,a=HB(o);if(!e){return{styles:Re(i)?i[0]:Object.values(i)[0],lodStrategy:a}}let s;if(t.add(n),Re(i)){const e=i.length;s=i[Array.from(t).indexOf(n)%e]}else Me(i)&&(s=i[n]||i.others);return{styles:s,lodStrategy:a}},_j=(t,e)=>{const n=new Map;return t.forEach(((t,r)=>{t.type===e&&n.set(r,t)})),n},bj=t=>{const e=new Map;t.forEach((t=>{const{source:n,target:r}=t,i=`${n}_${r}`,o=e.get(i)||{edges:[],source:n,target:r};o.edges.push(t),e.set(i,o)}));const n=[];return e.forEach((t=>{const{source:e,target:r,edges:i}=t;n.push({id:`virtual-${gn()}`,source:e,target:r,data:{_virtual:!0,keyShape:{lineWidth:i.length}}})})),n};function Sj(t){return!!t.execute}function xj(t){return["circular","random","grid","mds","concentric","radial","fruchterman","fruchtermanGPU","d3force","force","gforce","forceAtlas2"].indexOf(t.type)>-1}class Tj{constructor(t){this.extensions={},this.graph=t,this.animatedDisplayObject=new js({}),this.tap()}tap(){this.graph.hooks.layout.tap(this.onLayout.bind(this)),this.graph.hooks.destroy.tap(this.onDestroy.bind(this))}onLayout(t){return Oc(this,void 0,void 0,(function*(){let e;this.stopLayout();const{graphCore:n,options:r,animate:i=!0}=t;let o=n.getAllNodes();(t=>{const{type:e}=t;return!!["comboCombined","comboForce"].includes(e)||!("dagre"!==e||!t.sortByCombo)})(r)||(o=o.filter((t=>this.graph.getItemVisible(t.id)&&!t.data._isCombo)));const a={};o.forEach((t=>a[t.id]=!0));const s={nodes:o,edges:n.getAllEdges().filter((t=>a[t.source]&&a[t.target]))},l=new TP(s);n.hasTreeStructure("combo")&&(l.attachTreeStructure("combo"),o.forEach((t=>{const e=n.getParent(t.id,"combo");e&&l.hasNode(e.id)&&l.setParent(t.id,e.id,"combo")})));const[c,u]=this.graph.getSize(),h=[c/2,u/2],d=((t,e=32)=>t.nodeSize?t.nodeSize:t=>{const{size:n,keyShape:r}=t.data;if(Re(n))return Math.max(...n);if(Ue(n))return n;if(!r)return e;const{r:i,width:o,height:a}=r;if(!isNaN(i))return 2*i;const s=!isNaN(o),l=!isNaN(a);return s&&l?Math.max(o,a):s?o:l?a:e})(r,32);if(Sj(r)){const{animated:t=!1,animationEffectTiming:n={duration:1e3},execute:i}=r,o=Nc(r,["animated","animationEffectTiming","execute"]);e=yield i(l,Object.assign({nodeSize:d,width:c,height:u,center:h},o)),t&&(yield this.animateLayoutWithoutIterations(e,n))}else{const{type:t="grid",animated:o=!1,animationEffectTiming:a={duration:1e3},iterations:p=300}=r,f=Nc(r,["type","animated","animationEffectTiming","iterations"]);let{workerEnabled:g=!1}=r;const m=ZH.layouts[t]||JH.useLib.layouts[t];if(!m)throw new Error(`Unknown layout algorithm: ${t}`);if(mP(r))return void(yield this.handleTreeLayout(t,Object.assign({nodeSize:d,width:c,height:u,center:h},f),a,n,s,i));const v=new m(Object.assign({nodeSize:d,width:c,height:u,center:h},f));if(this.currentLayout=v,xj(r)||(g=!1),g){const t=new gw(l,v,{iterations:p});this.currentSupervisor=t,e=yield t.execute()}else GD(v)?o?e=yield v.execute(l,{onTick:t=>{this.updateNodesPosition(t),this.graph.emit("tick",t)}}):(v.execute(l),v.stop(),e=v.tick(p)):(e=yield v.execute(l),o&&(yield this.animateLayoutWithoutIterations(e,a)))}this.updateNodesPosition(e,i)}))}handleTreeLayout(t,e,n,r,i,o){return Oc(this,void 0,void 0,(function*(){const{animated:i=!1,rootIds:a=[],begin:s=[0,0],radial:l}=e,c=[],u=new Map;r.getRoots("tree").filter((t=>!t.data._isCombo)).map((t=>({id:t.id,children:[]}))).forEach((n=>{u.set(n.id,n),r.dfsTree(n.id,(t=>{u.get(t.id).children=r.getChildren(t.id,"tree").filter((t=>!t.data._isCombo)).map((t=>(u.set(t.id,{id:t.id,children:[]}),u.get(t.id))))}),"tree"),((t,e,n,r,i,o=[0,0])=>{const{treeGap:a=50}=n,s=((t,e)=>{const{direction:n}=e;switch(t){case"compactBox":case"dendrogram":return"TB"!==n&&" BT"!==n&&" V"!==n;case"indented":return!0;case"mindmap":return"V"!==n}})(e,n),l=ZC[e](t,n),c=[1/0,-1/0],u=[];gP(l,(t=>{const{id:e,x:n,y:i}=t;u.push(e);const o=s?"y":"x";c[0]>t[o]&&(c[0]=t[o]),c[1]<t[o]&&(c[1]=t[o]),r.get(e).data={x:n,y:i}}));const h=o[s?1:0]-c[0];u.forEach((t=>{const{x:e,y:n}=r.get(t).data;i.push({id:t,data:s?{x:e,y:n+h}:{x:e+h,y:n}})})),o[s?1:0]+=c[1]+h+a})(n,t,e,u,c,s),l&&(c.forEach((t=>u.set(t.id,t))),((t,e,n)=>{const r={x:1/0,y:1/0},i={x:-1/0,y:-1/0};let o="x",a="y";n&&["V","TB","BT"].indexOf(n)>=0&&(a="x",o="y");let s=0;gP(t,(t=>{s++;const{x:n,y:o}=e.get(t.id).data;n>i.x&&(i.x=n),n<r.x&&(r.x=n),o>i.y&&(i.y=o),o<r.y&&(r.y=o)}));const l=2*Math.PI/s,c=i[a]-r[a];if(0===c)return;const u=e.get(t.id);gP(t,(t=>{const n=e.get(t.id),i=(n.data[a]-r[a])/c*(2*Math.PI-l)+l,s=Math.abs(n.data[o]-u.data[o]);return n.data.x=s*Math.cos(i),n.data.y=s*Math.sin(i),!0}))})(n,u))})),i&&(yield this.animateLayoutWithoutIterations({nodes:c,edges:[]},n)),this.graph.emit("afterlayout"),this.updateNodesPosition({nodes:c,edges:[]},i||o)}))}stopLayout(){this.currentLayout&&GD(this.currentLayout)&&(this.currentLayout.stop(),this.currentLayout=null),this.currentSupervisor&&(this.currentSupervisor.stop(),this.currentSupervisor=null),this.currentAnimation&&(this.currentAnimation.finish(),this.currentAnimation=null)}getCurrentAnimation(){return this.currentAnimation}onDestroy(){this.stopLayout(),this.currentSupervisor&&this.currentSupervisor.kill()}updateNodesPosition(t,e=!0){const{nodes:n,edges:r}=t;this.graph.updateNodePosition(n,void 0,!e);const i=r.filter((t=>t.data.controlPoints)).map((t=>({id:t.id,data:{keyShape:{controlPoints:t.data.controlPoints}}})));i.length&&this.graph.updateData("edge",i)}animateLayoutWithoutIterations(t,e){return Oc(this,void 0,void 0,(function*(){e.iterations=1;const n=t.nodes.map((t=>Object.assign({},this.graph.getNodeData(`${t.id}`))));this.animatedDisplayObject.isConnected||(yield this.graph.canvas.ready,this.graph.canvas.appendChild(this.animatedDisplayObject)),this.currentAnimation=this.animatedDisplayObject.animate([{opacity:0},{opacity:1}],e),this.currentAnimation.onframe=e=>{const r=e.target.effect.getComputedTiming().progress,i=n.map((({id:e,data:n},i)=>{const{x:o=0,y:a=0}=n,{x:s,y:l}=t.nodes[i].data;return{id:e,data:{x:o+(s-o)*r,y:a+(l-a)*r}}}));this.updateNodesPosition({nodes:i,edges:[]})},yield this.currentAnimation.finished}))}}let Aj=0;class Rj{constructor(t){this.graph=t,this.tap()}tap(){this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this))}onViewportChange({transform:t,effectTiming:e}){return Oc(this,void 0,void 0,(function*(){const n=this.graph.canvas.getCamera(),r=this.graph.transientCanvas.getCamera(),{translate:i,rotate:o,zoom:a,origin:s=this.graph.getViewportCenter()}=t,l=n.getZoom();if(e){const{duration:t=1e3,easing:s="linear",easingFunction:c}=e,u={};if(i){const{dx:t=0,dy:e=0,dz:r=0}=i,[o,a,s]=n.getPosition(),[l,c,h]=n.getFocalPoint();u.position=[o-t,a-e,s-r],u.focalPoint=[l-t,c-e,h-r]}if(a){const{ratio:t}=a;u.zoom=l*t}if(o){const{angle:t}=o;u.roll=n.getRoll()+t}const h=n.createLandmark("mark"+Aj++,u),d=r.createLandmark(`mark${Aj}`,u);return new Promise((e=>{r.gotoLandmark(d,{duration:Number(t),easing:s,easingFunction:c}),n.gotoLandmark(h,{duration:Number(t),easing:s,easingFunction:c,onfinish:()=>{e(void 0)}})}))}if(i){const{dx:t=0,dy:e=0}=i;n.pan(-t/l,-e/l),r.pan(-t/l,-e/l)}if(o){const{angle:t}=o,[e,i]=n.getPosition();s&&(n.setPosition(s.x,s.y),n.setFocalPoint(s.x,s.y),r.setPosition(s.x,s.y),r.setFocalPoint(s.x,s.y)),n.rotate(0,0,t),r.rotate(0,0,t),s&&(n.pan(e-s.x,i-s.y),r.pan(e-s.x,i-s.y))}if(a){const{ratio:t}=a;n.setZoomByViewportPoint(l*t,[s.x,s.y]),r.setZoomByViewportPoint(l*t,[s.x,s.y])}}))}destroy(){}}class Mj{constructor(t){this.graph=t,this.tap()}tap(){this.extension=this.getExtension(),this.themes=this.getThemes(),this.graph.hooks.init.tap(this.onInit.bind(this)),this.graph.hooks.themechange.tap(this.onThemeChange.bind(this))}getExtension(){const{theme:t={}}=this.graph.getSpecification();return this.themeConfig=t,t?ej(t,JH.useLib,"themeSolver"):void 0}getThemes(){return((t,e)=>t[`${e}s`])(JH.useLib,"theme")}onInit({canvases:t}){if(this.extension&&(this.solver=new this.extension(this.themeConfig,this.themes),this.specification=this.solver.specification,this.specification)){const{canvas:e}=this.specification,n=t.background.getContextService().getDomElement();n&&n.style&&Object.keys(e).forEach((t=>n.style[t]=e[t]))}}onThemeChange({canvases:t}){t&&(this.extension=this.getExtension(),this.onInit({canvases:t}))}}class Cj{constructor(t){this.extensions={},this.graph=t}}class Pj{constructor(t){this.extensions=[],this.pluginMap=new Map,this.listenersMap={},this.addListeners=(t,e,n=!0)=>{const r=e.getEvents();this.listenersMap[t]={},Object.keys(r).forEach((i=>{const o=((t,e,n)=>r=>{try{n(r)}catch(n){throw console.error(`G6: Error occurred in "${e}" phase of the plugin "${t}"!`),n}})(t,i,r[i].bind(e));this.graph.on(i,o),this.listenersMap[t][i]=o,!n&&["afterrender","afterlayout"].includes(i)&&o({})}))},this.removeListeners=t=>{const e=this.listenersMap[t];Object.keys(e).forEach((t=>{const n=e[t];n&&this.graph.off(t,n)}))},this.graph=t,this.tap()}tap(){this.graph.hooks.init.tap(this.onPluginInit.bind(this)),this.graph.hooks.pluginchange.tap(this.onPluginChange.bind(this)),this.graph.hooks.destroy.tap(this.onDestroy.bind(this))}onPluginInit(){this.pluginMap.clear();const{graph:t}=this;(t.getSpecification().plugins||[]).forEach(this.initPlugin.bind(this)),this.listenersMap={},this.pluginMap.forEach(((t,e)=>{const{plugin:n}=t;this.addListeners(e,n)}))}initPlugin(t){var e,n;const{graph:r}=this;if(t instanceof zD){t.init(r);const n=t.key||(null===(e=t.options)||void 0===e?void 0:e.key)||`plugin-${gn()}`;return this.pluginMap.set(n,{type:n,plugin:t}),{key:n,plugin:t}}const i=ej(t,JH.useLib,"plugin"),o="string"==typeof t?{}:t,a="string"==typeof t?t:t.type,s="string"==typeof t?t:t.key||(null===(n=t.options)||void 0===n?void 0:n.key)||a;if(!i)throw new Error(`Plugin ${a} not found, please make sure you have registered it first`);const l=new i(Object.assign(Object.assign({},o),{key:s}));return l.init(r),this.pluginMap.set(s,{type:a,plugin:l}),{key:s,type:a,plugin:l}}onPluginChange(t){const{action:e,plugins:n}=t;"add"!==e?"remove"!==e?"update"!==e||n.forEach((t=>{if("string"==typeof t)return;const e=t.key||t.type,n=this.pluginMap.get(e);if(!n)return;const{plugin:r}=n;r.updateCfgs(t),this.removeListeners(e),this.addListeners(e,r,!1)})):n.forEach((t=>{var e;const n=("string"==typeof t?t:t.key)||(null===(e=t.options)||void 0===e?void 0:e.key)||t.type,r=this.pluginMap.get(n);if(!r)return;const{plugin:i}=r;this.removeListeners(n),i.destroy(),this.pluginMap.delete(n)})):n.forEach((t=>{const{key:e,plugin:n}=this.initPlugin(t);this.addListeners(e,n,!1)}))}hasPlugin(t){return this.pluginMap.has(t)}getPlugin(t){const{plugin:e}=this.pluginMap.get(t);if(!e)throw new Error("Plugin not found for key: "+t);return e}onDestroy(){this.pluginMap.forEach((t=>{const{plugin:e}=t;e.destroy()}))}destroy(){}}class wj{constructor(t){this.listeners=[];const{name:e}=t;this.name=e}tap(t){this.listeners.push(t)}unTap(t){const e=this.listeners.indexOf(t);e>-1&&this.listeners.splice(e,1)}emit(t){this.listeners.forEach((e=>e(t)))}emitLinearAsync(t){return Oc(this,void 0,void 0,(function*(){for(const e of this.listeners)yield e(t)}))}}const Nj=(t,e)=>(Object.keys(e).forEach((t=>{JH.useLib[t]=Object.assign({},JH.useLib[t],e[t]||{}),Object.keys(JH.useLib[t]).forEach((e=>{JH.useLib[t][e].type=e}))})),t);function Oj(t,e,n){const r=[0,0,0,0,0,0,0,0,0];return function(t,e){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1}(r,n),y(t,r,e)}function Ij(t,e,n){const r=[0,0,0,0,0,0,0,0,0];return function(t,e){var n=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=n,t[2]=0,t[3]=-n,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1}(r,n),y(t,r,e)}function Dj(t,e,n){const r=[0,0,0,0,0,0,0,0,0];return function(t,e){t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1}(r,n),y(t,r,e)}function Bj(t,e,n){return y(t,n,e)}var kj=Object.freeze({__proto__:null,extend:Nj,mock:t=>{const e=[],n=Array.from({length:t}).map(((t,n)=>{const r=`node-${n}`;return e.push(r),{id:r,data:{}}})),r=[];for(let e=0;e<t;e+=1)for(let n=0;n<t-1;n+=1)r.push({source:`node-${e}`,target:`node-${n}`,id:gn("edge_id_"),data:{}});return{circle:(t="")=>{let i=t;-1===e.indexOf(i)&&(i="node-0");const o=r.filter((t=>t.source===i||t.target===i));return{nodes:n,edges:o}},random:(i=.5)=>{const o=parseInt(String(t*i)),a=e.sort((()=>Math.random()-.5)).slice(0,o),s=r.filter((t=>-1!==a.indexOf(t.target))).sort((()=>Math.random()-.5)).slice(0,o);return{nodes:n,edges:s}}}},isEncode:zB,getArrowPath:ik,graphCoreTreeDfs:aP,graphComboTreeDfs:sP,traverseAncestorsAndSucceeds:lP,traverseGraphAncestors:cP,traverseAncestors:uP,isSucceed:hP,treeData2GraphData:pP,graphData2TreeData:fP,traverse:gP,getEdgesBetween:YD,transform:function(t,e){const n=t?[].concat(t):[1,0,0,0,1,0,0,0,1];for(let t=0,r=e.length;t<r;t++){const r=e[t];switch(r[0]){case"t":Oj(n,n,[r[1],r[2]]);break;case"s":Dj(n,n,[r[1],r[2]]);break;case"r":Ij(n,n,r[1]);break;case"m":Bj(n,n,r[1])}}return n}});Ps.enableCSSParsing=!1;const Lj="5.0.0-beta.13",Fj=Nj(class extends Fc{constructor(t){super(),this.defaultSpecification={theme:{type:"spec",base:"light"},enableStack:!0},this.executeWithNoStack=t=>{const e=this.getHistoryPlugin();null==e||e.pauseStack();try{t()}finally{null==e||e.resumeStack()}},this.specification=Object.assign({},this.defaultSpecification,this.formatSpecification(t)),this.initHooks(),this.initCanvas(),this.initControllers(),this.initHistory(),this.hooks.init.emit({canvases:{background:this.backgroundCanvas,main:this.canvas,transient:this.transientCanvas}});const{data:e}=t;e&&this.read(e)}initControllers(){this.dataController=new ij(this),this.interactionController=new uj(this),this.layoutController=new Tj(this),this.themeController=new Mj(this),this.itemController=new yj(this),this.viewportController=new Rj(this),this.extensionController=new Cj(this),this.pluginController=new Pj(this)}initCanvas(){const{renderer:t,container:e,canvas:n,backgroundCanvas:r,transientCanvas:i,width:o,height:a}=this.specification;let s;if(t&&!De(t)?(this.rendererType=t.type||"canvas",s=t.pixelRatio):this.rendererType=t||"canvas",n)this.canvas=n,this.backgroundCanvas=r,this.transientCanvas=i,this.container=e;else{const t=De(e)?document.getElementById(e):e;if(!t)return console.error(`Create graph failed. The container for graph ${t} is not exist.`),void this.destroy();this.container=t;const n=[o,a];void 0===n[0]&&(n[0]=t.scrollWidth),void 0===n[1]&&(n[1]=t.scrollHeight),this.backgroundCanvas=fR(this.rendererType,t,n[0],n[1],s),this.canvas=fR(this.rendererType,t,n[0],n[1],s),this.transientCanvas=fR(this.rendererType,t,n[0],n[1],s)}Promise.all([this.backgroundCanvas,this.canvas,this.transientCanvas].map((t=>t.ready))).then((()=>{[this.backgroundCanvas,this.canvas,this.transientCanvas].forEach(((t,e)=>{const n=t.getContextService().getDomElement();n&&n.style&&(n.style.position="absolute",n.style.outline="none",n.tabIndex=1,2===e&&(n.style.pointerEvents="none"))})),this.canvasReady=!0}))}initHistory(){const{enableStack:t,stackCfg:e}=this.specification;if(t){const n={type:"history",key:"history",enableStack:t,stackCfg:e};this.specification.plugins||(this.specification.plugins=[]),this.specification.plugins.push(n)}}changeRenderer(t){this.rendererType=t||"canvas",((t,e)=>{let n;switch(t.toLowerCase()){case"svg":n=new Sb;break;case"webgl-3d":case"webgl":n=new pR,n.registerPlugin(new xg);break;default:n=new Lu}n.registerPlugin(new P_),e.setRenderer(n)})(this.rendererType,this.canvas)}initHooks(){this.hooks={init:new wj({name:"init"}),datachange:new wj({name:"datachange"}),itemchange:new wj({name:"itemchange"}),render:new wj({name:"render"}),layout:new wj({name:"layout"}),viewportchange:new wj({name:"viewport"}),modechange:new wj({name:"modechange"}),behaviorchange:new wj({name:"behaviorchange"}),itemstatechange:new wj({name:"itemstatechange"}),itemvisibilitychange:new wj({name:"itemvisibilitychange"}),itemzindexchange:new wj({name:"itemzindexchange"}),transientupdate:new wj({name:"transientupdate"}),pluginchange:new wj({name:"pluginchange"}),themechange:new wj({name:"themechange"}),mapperchange:new wj({name:"mapperchange"}),treecollapseexpand:new wj({name:"treecollapseexpand"}),destroy:new wj({name:"destroy"})}}formatSpecification(t){var e;return Object.assign(Object.assign(Object.assign({},this.specification),t),{optimize:Object.assign(Object.assign({tileBehavior:2e3,tileBehaviorSize:1e3,tileFirstRender:1e4,tileFirstRenderSize:1e3},null===(e=this.specification)||void 0===e?void 0:e.optimize),t.optimize)})}updateSpecification(t){return Object.assign(this.specification,this.formatSpecification(t))}updateTheme(t){this.specification.theme=t,this.hooks.themechange.emit({canvases:{background:this.backgroundCanvas,main:this.canvas,transient:this.transientCanvas}}),this.hooks.themechange.emit({theme:this.themeController.specification})}updateMapper(t,e){switch(t){case"node":this.specification.node=e;break;case"edge":this.specification.edge=e;break;case"combo":this.specification.combo=e}this.hooks.mapperchange.emit({type:t,mapper:e})}getSpecification(){return this.specification}read(t){return Oc(this,void 0,void 0,(function*(){const{tileFirstRender:e,tileFirstRenderSize:n}=this.specification.optimize||{};this.hooks.datachange.emit({data:t,type:"replace"});const r=()=>Oc(this,void 0,void 0,(function*(){yield this.hooks.render.emitLinearAsync({graphCore:this.dataController.graphCore,theme:this.themeController.specification,transientCanvas:this.transientCanvas,tileOptimize:{tileFirstRender:e,tileFirstRenderSize:n}}),this.emit("afterrender"),this.once("afterlayout",(()=>Oc(this,void 0,void 0,(function*(){const{autoFit:t}=this.specification;if(t)if("view"===t)yield this.fitView({rules:{boundsType:"layout"}});else if("center"===t)yield this.fitCenter("layout");else{const{type:e,effectTiming:n}=t,r=Nc(t,["type","effectTiming"]);if("view"===e){const{padding:t,rules:e}=r;yield this.fitView({padding:t,rules:Object.assign(Object.assign({},e),{boundsType:"layout"})},n)}else"center"===e?yield this.fitCenter("layout",n):"position"===e&&(yield this.translateTo(r.position,n))}})))),yield this.layout()}));this.canvasReady||(yield Promise.all([this.backgroundCanvas,this.canvas,this.transientCanvas].map((t=>t.ready)))),yield r()}))}changeData(t,e="mergeReplace"){return Oc(this,void 0,void 0,(function*(){const{tileFirstRender:n,tileFirstRenderSize:r}=this.specification.optimize||{};this.hooks.datachange.emit({data:t,type:e}),this.hooks.render.emit({graphCore:this.dataController.graphCore,theme:this.themeController.specification,transientCanvas:this.transientCanvas,tileOptimize:{tileFirstRender:n,tileFirstRenderSize:r}}),this.emit("afterrender"),yield this.layout()}))}clear(){this.startHistoryBatch(),this.removeData("edge",this.getAllEdgesData().map((t=>t.id))),this.removeData("node",this.getAllNodesData().map((t=>t.id))),this.removeData("combo",this.getAllCombosData().map((t=>t.id))),this.stopHistoryBatch()}getViewportCenter(){const{width:t,height:e}=this.canvas.getConfig();return{x:t/2,y:e/2}}transform(t,e){return Oc(this,void 0,void 0,(function*(){const{tileLodSize:n}=this.specification.optimize||{};yield this.hooks.viewportchange.emitLinearAsync({transform:t,effectTiming:e,tileLodSize:n}),this.emit("viewportchange",t)}))}stopTransformTransition(){this.canvas.getCamera().cancelLandmarkAnimation()}translate(t,e){return Oc(this,void 0,void 0,(function*(){yield this.transform({translate:t},e)}))}translateTo({x:t,y:e},n){return Oc(this,void 0,void 0,(function*(){const{x:r,y:i}=this.getViewportCenter();yield this.translate({dx:r-t,dy:i-e},n)}))}zoom(t,e,n){return Oc(this,void 0,void 0,(function*(){yield this.transform({zoom:{ratio:t},origin:e},n)}))}zoomTo(t,e,n){return Oc(this,void 0,void 0,(function*(){yield this.zoom(t/this.canvas.getCamera().getZoom(),e,n)}))}getZoom(){return this.canvas.getCamera().getZoom()}rotate(t,e,n){return Oc(this,void 0,void 0,(function*(){yield this.transform({rotate:{angle:t},origin:e},n)}))}rotateTo(t,e,n){return Oc(this,void 0,void 0,(function*(){yield this.rotate(t-this.canvas.getCamera().getRoll(),e,n)}))}fitView(t,e){return Oc(this,void 0,void 0,(function*(){const{padding:n,rules:r}=t||{},[i,o,a,s]=n?WR(n):[0,0,0,0],{direction:l="both",ratioRule:c="min",boundsType:u="render"}=r||{},{center:[h,d],halfExtents:p}="render"===u?this.canvas.document.documentElement.getBounds():vP(this),f=this.canvas.canvas2Viewport({x:h,y:d}),{width:g,height:m}=this.canvas.getConfig(),v=2*p[0],y=2*p[1],E=this.canvas.viewport2Canvas({x:s,y:i}),_=this.canvas.viewport2Canvas({x:g-o,y:m-a}),b=(_.x-E.x)/v,S=(_.y-E.y)/y;let x;x="x"===l?b:"y"===l?S:"max"===c?Math.max(b,S):Math.min(b,S),yield this.transform({translate:{dx:g/2-f.x,dy:m/2-f.y},zoom:{ratio:x}},e)}))}fitCenter(t="render",e){return Oc(this,void 0,void 0,(function*(){const{center:[n,r]}="render"===t?this.canvas.document.documentElement.getBounds():vP(this);yield this.translateTo(this.canvas.canvas2Viewport({x:n,y:r}),e)}))}focusItem(t,e){return Oc(this,void 0,void 0,(function*(){let n=null;for(const e of Re(t)?t:[t]){const t=this.getItemById(e);if(t){const e=t.group.getBounds();n?n.add(e):n=e}}if(n){const{center:[t,r]}=n;yield this.translateTo(this.canvas.canvas2Viewport({x:t,y:r}),e)}}))}getItemById(t){return this.itemController.getItemById(t)}getSize(){const{width:t=500,height:e=500}=this.specification;return[t,e]}setSize(t){if(!Re(t)||t.length<2)return void console.warn(`Failed to setSize. The parameter size: ${t} is invalid. It must be an array with 2 number elements.`);const e=[this.specification.width,this.specification.height];this.emit("beforesetsize",{oldSize:e,size:t}),this.specification.width=t[0],this.specification.height=t[1],this.canvas.resize(t[0],t[1]),this.transientCanvas.resize(t[0],t[1]),this.backgroundCanvas.resize(t[0],t[1]),this.emit("aftersetsize",{oldSize:e,size:t})}getCanvasRange(){const[t,e]=this.getSize(),n=this.getCanvasByViewport({x:0,y:0}),r=this.getCanvasByViewport({x:t,y:e});return{min:[n.x,n.y,n.z],max:[r.x,r.y,r.z],center:[(n.x+r.x)/2,(n.y+r.y)/2,(n.z+r.z)/2],halfExtents:[(r.x-n.x)/2,(r.y-n.y)/2,(r.z-n.z)/2]}}getCanvasByViewport(t){return this.canvas.viewport2Canvas(t)}getViewportByCanvas(t){return this.canvas.canvas2Viewport(t)}getClientByCanvas(t){const e=this.canvas.canvas2Viewport(t);return this.canvas.viewport2Client(e)}getCanvasByClient(t){const e=this.canvas.client2Viewport(t);return this.canvas.viewport2Canvas(e)}getNodeData(t){var e;const n=De(t)||Ue(t)?[t]:t;return null===(e=this.dataController.findData("node",n))||void 0===e?void 0:e[0]}getEdgeData(t){var e;const n=De(t)||Ue(t)||Ue(t)?[t]:t;return null===(e=this.dataController.findData("edge",n))||void 0===e?void 0:e[0]}getComboData(t){var e;const n=De(t)||Ue(t)?[t]:t;return null===(e=this.dataController.findData("combo",n))||void 0===e?void 0:e[0]}getAllNodesData(){return this.dataController.findAllData("node")}getAllEdgesData(){return this.dataController.findAllData("edge")}getAllCombosData(){return this.dataController.findAllData("combo")}getRelatedEdgesData(t,e="both"){return this.dataController.findRelatedEdges(t,e)}getNeighborNodesData(t,e="both"){return this.dataController.findNeighborNodes(t,e)}getComboChildrenData(t){return this.dataController.findChildren(t,"combo")}getDisplayModel(t){return this.itemController.findDisplayModel(t)}getNearEdgesForNode(t){const{graphCore:e}=this.dataController;return this.itemController.findNearEdgesByNode(t,e)}findIdByState(t,e,n=!0,r){let i=this.itemController.findIdByState(t,e,n);if(r){let e=this.getEdgeData;"node"===t?e=this.getNodeData:"combo"===t&&(e=this.getComboData),i=i.filter((t=>r(e(t))))}return i}addData(t,e){const{graphCore:n}=this.dataController,{specification:r}=this.themeController;n.once("changed",(i=>{if(!i.changes.length)return;const o=i.changes,a={type:t,action:"add",models:e,apiName:"addData",changes:o};this.emit("beforeitemchange",a),this.hooks.itemchange.emit({type:t,changes:n.reduceChanges(i.changes),graphCore:n,theme:r}),this.emit("afteritemchange",a)}));const i=Re(e)?e:[e],o={nodes:[],edges:[],combos:[]};o[`${t}s`]=i,this.hooks.datachange.emit({data:o,type:"union"});const a=this.dataController.findData(t,i.map((t=>t.id)));return Re(e)?a:a[0]}removeData(t,e){const n=Re(e)?e:[e],r={nodes:[],edges:[],combos:[]},{graphCore:i}=this.dataController,{specification:o}=this.themeController,a="edge"===t?i.getEdge:i.getNode,s="edge"===t?i.hasEdge:i.hasNode;r[`${t}s`]=n.map((e=>{if(s.bind(i)(e))return a.bind(i)(e);console.warn(`The ${t} data with id ${e} does not exist. It will be ignored`)})).filter(Boolean),i.once("changed",(e=>{if(!e.changes.length)return;const r=e.changes,a={type:t,action:"remove",ids:n,apiName:"removeData",changes:r};this.emit("beforeitemchange",a),this.hooks.itemchange.emit({type:t,changes:e.changes,graphCore:i,theme:o}),this.emit("afteritemchange",a)})),this.hooks.datachange.emit({data:r,type:"remove"})}extendChanges(t){return t.map((t=>{const{id:e,propertyName:n,oldValue:r,newValue:i}=t;if(!r||!i)return t;if(n)return r!==i&&t;const o=this.getItemById(e).displayModel.data,a=Object.keys(r),s=Object.keys(i);return[...new Set([...a,...s])].forEach((t=>{Object.prototype.hasOwnProperty.call(r,t)||(r[t]=o[t]),Object.prototype.hasOwnProperty.call(i,t)||(i[t]=o[t])})),void 0!==r.x&&!Number.isNaN(r.x)||r._isCombo||(r.x=0),void 0!==r.y&&!Number.isNaN(r.x)||r._isCombo||(r.y=0),Number.isNaN(i.x)&&delete i.x,Number.isNaN(i.y)&&delete i.y,!un(i,r)&&Object.assign(Object.assign({},t),{newValue:i,oldValue:r})})).filter(Boolean)}updateData(t,e){const n=Re(e)?e:[e],r={nodes:[],edges:[],combos:[]};r[`${t}s`]=n;const{graphCore:i}=this.dataController,{specification:o}=this.themeController;i.once("changed",(n=>{const r=this.extendChanges(tn(n.changes)),a={type:t,action:"update",models:e,apiName:"updateData",changes:r};this.emit("beforeitemchange",a),this.hooks.itemchange.emit({type:t,changes:n.changes,graphCore:i,theme:o}),this.emit("afteritemchange",a)})),this.hooks.datachange.emit({data:r,type:"update"});const a=this.dataController.findData(t,n.map((t=>t.id)));return Re(e)?a:a[0]}updateNodePosition(t,e,n=!1,r,i){return this.updatePosition("node",t,e,n,r,i)}updateComboPosition(t,e,n=!1,r,i){return this.updatePosition("combo",t,e,n,r,i)}getHistoryPlugin(){if(this.specification.enableStack&&this.pluginController.hasPlugin("history"))return this.pluginController.getPlugin("history");console.error("The history plugin is not loaded or initialized.")}updatePosition(t,e,n,r=!1,i,o){const a=Re(e)?e:[e],{graphCore:s}=this.dataController,{specification:l}=this.themeController;s.once("changed",(o=>{if(!o.changes.length)return;const a=o.changes.filter((t=>!un(t.newValue,t.oldValue))),c={type:t,action:"updatePosition",upsertAncestors:n,models:e,apiName:"updatePosition",changes:a};this.emit("beforeitemchange",c),this.hooks.itemchange.emit({type:t,changes:o.changes,graphCore:s,theme:l,upsertAncestors:n,action:"updatePosition",animate:!r,callback:i}),this.emit("afteritemchange",c)})),this.hooks.datachange.emit({data:{nodes:"node"===t?a:[],edges:[],combos:"combo"===t?a:[]},type:"update"});const c=this.dataController.findData(t,a.map((t=>t.id)));return Re(e)?c:c[0]}getItemPreviousVisibility(t){const e=t.map((t=>({id:t,visible:this.getItemVisible(t)}))),n=Le(e,"visible"),r=[];for(const t in n)r.push({ids:hn(n[t],(t=>t.id)),visible:"true"===t});return r}showItem(t,e=!1){const n=Re(t)?t:[t];if(ln(n))return;const r={newValue:[{ids:n,visible:!0}],oldValue:this.getItemPreviousVisibility(n)};this.hooks.itemvisibilitychange.emit({ids:n,value:!0,graphCore:this.dataController.graphCore,animate:!e}),this.emit("afteritemvisibilitychange",{ids:t,value:!0,animate:!e,action:"updateVisibility",apiName:"showItem",changes:r})}hideItem(t,e=!1,n=!1){const r=Re(t)?t:[t];if(ln(r))return;const i={newValue:[{ids:r,visible:!1}],oldValue:this.getItemPreviousVisibility(r)};this.hooks.itemvisibilitychange.emit({ids:r,value:!1,graphCore:this.dataController.graphCore,animate:!e,keepKeyShape:n}),this.emit("afteritemvisibilitychange",{ids:t,value:!1,animate:!e,action:"updateVisibility",apiName:"hideItem",keepKeyShape:n,changes:i})}frontItem(t){const e=Re(t)?t:[t];this.hooks.itemzindexchange.emit({ids:e,action:"front",graphCore:this.dataController.graphCore}),this.emit("afteritemzindexchange",{ids:e,action:"front",apiName:"frontItem"})}backItem(t){const e=Re(t)?t:[t];this.hooks.itemzindexchange.emit({ids:e,action:"back",graphCore:this.dataController.graphCore}),this.emit("afteritemzindexchange",{ids:e,action:"back",apiName:"backItem"})}getItemPreviousStates(t){const{ids:e,states:n}=t,r=Array.isArray(e)?e:[e],i=Array.isArray(n)?n:[n];if(!ln(r))return r.flatMap((t=>i.map((e=>({ids:t,states:e,value:this.getItemState(t,e)})))))}setItemState(t,e,n){const r=Re(t)?t:[t],i=Re(e)?e:[e],o={ids:r,states:i,value:n},a={newValue:[o],oldValue:this.getItemPreviousStates(o)};this.hooks.itemstatechange.emit({ids:r,states:i,value:n}),this.emit("afteritemstatechange",{ids:t,states:e,value:n,action:"updateState",apiName:"setItemState",changes:a})}getItemState(t,e){return this.itemController.getItemState(t,e)}getItemAllStates(t){return this.itemController.getItemAllStates(t)}clearItemState(t,e){const n=Re(t)?t:[t],r={ids:n,states:e,value:!1},i={newValue:[r],oldValue:this.getItemPreviousStates(r)};this.hooks.itemstatechange.emit({ids:n,states:e,value:!1}),this.emit("afteritemstatechange",{ids:t,states:e,value:!1,action:"updateState",apiName:"clearItemState",changes:i})}getRenderBBox(t,e=!1,n=!1){return t?this.itemController.getItemBBox(t,e,n):this.canvas.getRoot().getRenderBounds()}getItemVisible(t){return this.itemController.getItemVisible(t)}addCombo(t,e){const{graphCore:n}=this.dataController,{specification:r}=this.themeController;n.once("changed",(e=>{if(!e.changes.length)return;const i=e.changes,o={type:"combo",action:"add",models:[t],apiName:"addCombo",changes:i};this.emit("beforeitemchange",o),this.hooks.itemchange.emit({type:"combo",changes:n.reduceChanges(e.changes),graphCore:n,theme:r}),this.emit("afteritemchange",o)}));const i={nodes:[],edges:[],combos:[Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{_children:e})})]};return this.hooks.datachange.emit({data:i,type:"addCombo"}),this.dataController.findData("combo",[t.id])[0]}collapseCombo(t){const e=Re(t)?t:[t];this.executeWithNoStack((()=>{this.updateData("combo",e.map((t=>({id:t,data:{collapsed:!0}}))))})),this.emit("aftercollapsecombo",{type:"combo",action:"collapseCombo",ids:t,apiName:"collapseCombo"})}expandCombo(t){const e=Re(t)?t:[t];this.executeWithNoStack((()=>{this.updateData("combo",e.map((t=>({id:t,data:{collapsed:!1}}))))})),this.emit("afterexpandcombo",{type:"combo",action:"expandCombo",ids:t,apiName:"expandCombo"})}moveCombo(t,e,n,r,i){const o=Re(t)?t:[t],{graphCore:a}=this.dataController,{specification:s}=this.themeController;return a.once("changed",(t=>{if(!t.changes.length)return;const l=this.extendChanges(tn(t.changes)),c={type:"combo",ids:o,dx:e,dy:n,action:"updatePosition",upsertAncestors:r,apiName:"moveCombo",changes:l};this.emit("beforeitemchange",c),this.hooks.itemchange.emit({type:"combo",changes:t.changes,graphCore:a,theme:s,upsertAncestors:r,action:"updatePosition",callback:i}),this.emit("afteritemchange",c)})),this.hooks.datachange.emit({data:{nodes:[],edges:[],combos:o.map((t=>({id:t,data:{dx:e,dy:n}})))},type:"moveCombo"}),this.dataController.findData("combo",o)}layout(t,e=!1){return Oc(this,void 0,void 0,(function*(){this.emit("beforelayout");const{graphCore:n}=this.dataController,r=Object.assign(Object.assign({},this.getSpecification().layout),t);this.updateSpecification({layout:r});if(!t&&!this.getSpecification().layout||!Object.keys(r).length){n.getAllNodes().every((t=>xe(t.data.x)&&xe(t.data.y)))?r.type="grid":r.execute=t=>Oc(this,void 0,void 0,(function*(){return{nodes:t.getAllNodes().map((t=>({id:t.id,data:{x:Number(t.data.x)||0,y:Number(t.data.y)||0}}))),edges:[]}}))}yield this.hooks.layout.emitLinearAsync({graphCore:n,options:r,animate:!e}),this.emit("afterlayout")}))}stopLayout(){this.layoutController.stopLayout()}getLayoutCurrentAnimation(){return this.layoutController.getCurrentAnimation()}setMode(t){this.hooks.modechange.emit({mode:t})}getMode(){return this.interactionController.getMode()}setCursor(t){this.canvas.setCursor(t),this.transientCanvas.setCursor(t)}addBehaviors(t,e){const n=Re(e)?e:[e],r=Re(t)?t:[t];this.hooks.behaviorchange.emit({action:"add",modes:n,behaviors:r}),n.forEach((t=>{this.specification.modes[t]=this.specification.modes[t].concat(r)}))}removeBehaviors(t,e){const n=Re(e)?e:[e];this.hooks.behaviorchange.emit({action:"remove",modes:n,behaviors:t}),n.forEach((e=>{t.forEach((t=>{const n=this.specification.modes[e].find((e=>Me(e)&&e.key===t)),r=this.specification.modes[e].indexOf(n);this.specification.modes[e].splice(r,1)}))}))}updateBehavior(t,e){this.hooks.behaviorchange.emit({action:"update",modes:[e],behaviors:[t]})}addPlugins(t){const e=Re(t)?t:[t];this.specification.plugins||(this.specification.plugins=[]);const n=this.specification.plugins,r=[];e.forEach((t=>{n.find((e=>"string"!=typeof e&&"string"!=typeof t&&e.key===t.key))?console.warn(`Add plugin with key ${t.key} failed, the key is duplicated to the existing plugins on the graph.`):r.push(t)})),this.specification.plugins=n.concat(r),this.hooks.pluginchange.emit({action:"add",plugins:r})}removePlugins(t){const e=Re(t)?t:[t];this.hooks.pluginchange.emit({action:"remove",plugins:e});const{plugins:n}=this.specification;this.specification.plugins=null==n?void 0:n.filter((t=>Me(t)?!(e.includes(t.key)||e.includes(t)):!e.includes(t)))}updatePlugin(t){const{plugins:e}=this.specification,{key:n}=t;if(!n)return void console.warn("Update plugin failed, the key for the plugin to be updated should be assign.");if(!e)return void console.warn("Update plugin failed, the plugin to be updated does not exist.");const r=null==e?void 0:e.find((t=>"string"==typeof t?t===n:t.key===n));if(!r)return void console.warn("Update plugin failed, the key for the plugin to be updated should be assign.");const i=e.indexOf(r);e[i]=Object.assign(Object.assign({},r),t),this.hooks.pluginchange.emit({action:"update",plugins:[t]})}drawTransient(t,e,n,r){return this.hooks.transientupdate.emit({type:t,id:e,config:n,canvas:r||this.transientCanvas,graphCore:this.dataController.graphCore}),this.itemController.getTransient(String(e))}toDataURL(t){return Oc(this,void 0,void 0,(function*(){const e=this.backgroundCanvas,n=this.canvas,r=this.transientCanvas,i=this.rendererType,o="undefined"!=typeof window?window.devicePixelRatio:1,a=this.getSize()[0],s=this.getSize()[1],l=yP('<div id="virtual-image"></div>'),c=fR(i,l,a,s,o),u=c.getContextService();let h;"svg"!==i&&(h=new nl({style:{x:0,y:0,z:-1,width:u.getDomElement().width,height:u.getDomElement().height,fill:e.getContextService().getDomElement().style["background-color"]}}),c.appendChild(h));const d=e.getRoot().cloneNode(!0),p=n.getRoot().cloneNode(!0),f=r.getRoot().cloneNode(!0);c.appendChild(d),c.appendChild(p),c.appendChild(f),c.render(),t||(t="image/png");let g="";return yield u.toDataURL({type:t}).then((t=>{g=t})),g}))}toFullDataURL(t,e){return Oc(this,void 0,void 0,(function*(){const n=this.backgroundCanvas,r=this.canvas,i=this.transientCanvas,o=r.getRoot(),a=r.getRoot(),s=i.getRoot(),l=this.rendererType,c=o.getBBox(),u=a.getBBox(),h=s.getBBox();let d=e?e.padding:void 0;d?Ue(d)&&(d=[d,d,d,d]):d=[0,0,0,0];const p=(h.left?c.left?Math.min(c.left,u.left,h.left):Math.min(u.left,h.left):u.left)-d[3],f=(h.right?c.right?Math.max(c.right,u.right,h.right):Math.max(u.right,h.right):u.right)+d[1],g=(h.top?c.top?Math.min(c.top,u.top,h.top):Math.min(u.top,h.top):u.top)-d[0],m=(h.bottom?c.bottom?Math.max(c.bottom,u.bottom,h.bottom):Math.max(u.bottom,h.bottom):u.bottom)+d[2],v=(p+f)/2,y=(g+m)/2,E=(f-p)/2,_=(m-g)/2,b="undefined"!=typeof window?window.devicePixelRatio:1,S=2*E,x=2*_,T=yP('<div id="virtual-image"></div>'),A=fR(l,T,S,x,b),R=A.getContextService();if("svg"!==l){const t=new nl({style:{x:0,y:0,z:-1,width:R.getDomElement().width,height:R.getDomElement().height,fill:n.getContextService().getDomElement().style["background-color"]}});A.appendChild(t)}const M=o.cloneNode(!0),C=a.cloneNode(!0),P=s.cloneNode(!0),w=[-v+E,-y+_];M.setPosition(w),C.setPosition(w),P.setPosition(w),A.appendChild(M),A.appendChild(C),A.appendChild(P),A.render(),t||(t="image/png");let N="";return yield R.toDataURL({type:t}).then((t=>{N=t})),N}))}dataURLToImage(t,e,n,r){if(t&&"data:"!==t){if("undefined"!=typeof window)if(window.Blob&&window.URL&&"svg"!==e){const e=t.split(",");let i="";if(e&&e.length>0){const t=e[0].match(/:(.*?);/);t&&t.length>=2&&(i=t[1])}const o=atob(e[1]);let a=o.length;const s=new Uint8Array(a);for(;a--;)s[a]=o.charCodeAt(a);const l=new Blob([s],{type:i});window.navigator.msSaveBlob?window.navigator.msSaveBlob(l,r):n.addEventListener("click",(()=>{n.download=r,n.href=window.URL.createObjectURL(l)}))}else n.addEventListener("click",(()=>{n.download=r,n.href=t}))}else console.error("Download image failed. The graph is too large or there is invalid attribute values in graph items")}downloadImage(t,e){const n=this.rendererType;e||(e="image/png");const r=(t||"graph")+("svg"===n?".svg":e.split("/")[1]),i=document.createElement("a");this.asyncToDataUrl(e,(t=>{this.dataURLToImage(t,n,i,r);const e=document.createEvent("MouseEvents");e.initEvent("click",!1,!1),i.dispatchEvent(e)}))}downloadFullImage(t,e,n){const r=this.rendererType;e||(e="image/png");const i=(t||"graph")+("svg"===r?".svg":e.split("/")[1]),o=document.createElement("a");this.asyncToFullDataUrl(e,n,(t=>{this.dataURLToImage(t,r,o,i);const e=document.createEvent("MouseEvents");e.initEvent("click",!1,!1),o.dispatchEvent(e)}))}asyncToDataUrl(t,e){let n="";t||(t="image/png"),setTimeout((()=>Oc(this,void 0,void 0,(function*(){yield this.toDataURL(t).then((t=>{n=t})),e&&e(n)}))),16)}asyncToFullDataUrl(t,e,n){let r="";t||(t="image/png"),setTimeout((()=>Oc(this,void 0,void 0,(function*(){yield this.toFullDataURL(t,e).then((t=>{r=t})),n&&n(r)}))),16)}isHistoryEnabled(){const t=this.getHistoryPlugin();return null==t?void 0:t.isEnable()}pushStack(t,e,n){const r=this.getHistoryPlugin();return null==r?void 0:r.push(t,e,n)}pauseStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.pauseStack()}resumeStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.resumeStack()}getUndoStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.getUndoStack()}getRedoStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.getRedoStack()}getStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.getStack()}undo(){const t=this.getHistoryPlugin();null==t||t.undo()}redo(){const t=this.getHistoryPlugin();null==t||t.redo()}canUndo(){const t=this.getHistoryPlugin();return null==t?void 0:t.canUndo()}canRedo(){const t=this.getHistoryPlugin();return null==t?void 0:t.canRedo()}startHistoryBatch(){const t=this.getHistoryPlugin();null==t||t.startHistoryBatch()}stopHistoryBatch(){const t=this.getHistoryPlugin();null==t||t.stopHistoryBatch()}historyBatch(t){const e=this.getHistoryPlugin();null==e||e.historyBatch(t)}cleanHistory(t){const e=this.getHistoryPlugin();return t?"undo"===t?null==e?void 0:e.clearUndoStack():null==e?void 0:e.clearRedoStack():null==e?void 0:e.clear()}collapse(t,e=!1,n){this.hooks.treecollapseexpand.emit({ids:Re(t)?t:[t],action:"collapse",animate:!e,graphCore:this.dataController.graphCore})}expand(t,e=!1,n){this.hooks.treecollapseexpand.emit({ids:Re(t)?t:[t],action:"expand",animate:!e,graphCore:this.dataController.graphCore})}destroy(t){this.canvas.destroy(),this.backgroundCanvas.destroy(),this.transientCanvas.destroy(),this.cleanHistory(),null==t||t(),this.hooks.destroy.emit({}),this.destroyed=!0}},ZH);var Uj={Graph:Fj,Util:kj,stdLib:ZH,Extensions:tj,extend:Nj,version:Lj};t.Extensions=tj,t.Graph=Fj,t.PluginBase=zD,t.Util=kj,t.default=Uj,t.extend=Nj,t.isImmediatelyInvokedLayoutOptions=Sj,t.isLayoutWorkerized=xj,t.stdLib=ZH,t.version=Lj,Object.defineProperty(t,"__esModule",{value:!0})}));
6
+ */const qP=Symbol("Comlink.proxy"),$P=Symbol("Comlink.endpoint"),ZP=Symbol("Comlink.releaseProxy"),QP=Symbol("Comlink.finalizer"),JP=Symbol("Comlink.thrown"),tw=t=>"object"==typeof t&&null!==t||"function"==typeof t,ew=new Map([["proxy",{canHandle:t=>tw(t)&&t[qP],serialize(t){const{port1:e,port2:n}=new MessageChannel;return nw(t,e),[n,[n]]},deserialize:t=>(t.start(),iw(t))}],["throw",{canHandle:t=>tw(t)&&JP 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 nw(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(pw);let c;try{const e=s.slice(0,-1).reduce(((t,e)=>t[e]),t),n=s.reduce(((t,e)=>t[e]),t);switch(a){case"GET":c=n;break;case"SET":e[s.slice(-1)[0]]=pw(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,l);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[qP]:!0})}(new n(...l));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;nw(t,n),c=function(t,e){return hw.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[JP]:0}}Promise.resolve(c).catch((t=>({value:t,[JP]:0}))).then((n=>{const[i,s]=dw(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===a&&(e.removeEventListener("message",r),rw(e),QP in t&&"function"==typeof t[QP]&&t[QP]())})).catch((t=>{const[n,r]=dw({value:new TypeError("Unserializable return value"),[JP]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)}))})),e.start&&e.start()}function rw(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function iw(t,e){return cw(t,[],e)}function ow(t){if(t)throw new Error("Proxy has been released and is not useable")}function aw(t){return fw(t,{type:"RELEASE"}).then((()=>{rw(t)}))}const sw=new WeakMap,lw="FinalizationRegistry"in globalThis&&new FinalizationRegistry((t=>{const e=(sw.get(t)||0)-1;sw.set(t,e),0===e&&aw(t)}));function cw(t,e=[],n=function(){}){let r=!1;const i=new Proxy(n,{get(n,o){if(ow(r),o===ZP)return()=>{!function(t){lw&&lw.unregister(t)}(i),aw(t),r=!0};if("then"===o){if(0===e.length)return{then:()=>i};const n=fw(t,{type:"GET",path:e.map((t=>t.toString()))}).then(pw);return n.then.bind(n)}return cw(t,[...e,o])},set(n,i,o){ow(r);const[a,s]=dw(o);return fw(t,{type:"SET",path:[...e,i].map((t=>t.toString())),value:a},s).then(pw)},apply(n,i,o){ow(r);const a=e[e.length-1];if(a===$P)return fw(t,{type:"ENDPOINT"}).then(pw);if("bind"===a)return cw(t,e.slice(0,-1));const[s,l]=uw(o);return fw(t,{type:"APPLY",path:e.map((t=>t.toString())),argumentList:s},l).then(pw)},construct(n,i){ow(r);const[o,a]=uw(i);return fw(t,{type:"CONSTRUCT",path:e.map((t=>t.toString())),argumentList:o},a).then(pw)}});return function(t,e){const n=(sw.get(e)||0)+1;sw.set(e,n),lw&&lw.register(t,e,t)}(i,t),i}function uw(t){const e=t.map(dw);return[e.map((t=>t[0])),(n=e.map((t=>t[1])),Array.prototype.concat.apply([],n))];var n}const hw=new WeakMap;function dw(t){for(const[e,n]of ew)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},hw.get(t)||[]]}function pw(t){switch(t.type){case"HANDLER":return ew.get(t.name).deserialize(t.value);case"RAW":return t.value}}function fw(t,e,n){return new Promise((r=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.addEventListener("message",(function e(n){n.data&&n.data.id&&n.data.id===i&&(t.removeEventListener("message",e),r(n.data))})),t.start&&t.start(),t.postMessage(Object.assign({id:i},e),n)}))}var gw=function(t){function e(e,n,r){var i=t.call(this)||this;return i.graph=e,i.layout=n,i.options=r,i.spawnWorker(),i}return Pc(e,t),e.prototype.spawnWorker=function(){this.proxy=iw(new Worker(new URL("./worker.js","undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("g6.min.js",document.baseURI).href),{type:"module"})),this.running&&(this.running=!1,this.execute())},e.prototype.execute=function(){var t;return Oc(this,void 0,void 0,(function(){var e,n,r,i,o,a;return Ic(this,(function(s){switch(s.label){case 0:return this.running?[2,this]:(this.running=!0,(e=this.layout.options).onTick,n=Nc(e,["onTick"]),r={},Object.keys(n).forEach((function(t){Se(n[t])||(r[t]=n[t])})),i={layout:{id:this.layout.id,options:r,iterations:null===(t=this.options)||void 0===t?void 0:t.iterations},nodes:this.graph.getAllNodes(),edges:this.graph.getAllEdges()},o=new Float32Array([0]),[4,this.proxy.calculateLayout(i,[o])]);case 1:return a=Bc.apply(void 0,[s.sent(),1]),[2,a[0]]}}))}))},e.prototype.stop=function(){return this.running=!1,this.proxy.stopLayout(),this},e.prototype.kill=function(){this.proxy[ZP]()},e.prototype.isRunning=function(){return this.running},e}(Fc);const mw=Object.prototype.toString;function vw(t){const e=mw.call(t);return e.endsWith("Array]")&&!e.includes("Big")}function yw(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!vw(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(!vw(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(!vw(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(!vw(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 c=(l-a)/(i-r),u=0;u<t.length;u++)e[u]=(t[u]-r)*c+a;return e}const Ew=" ".repeat(2),_w=" ".repeat(4);function bw(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${Ew}[\n${_w}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),l=Math.min(a,n),c=[];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(Sw(t.get(e,o),r,i));c.push(`${n.join(" ")}`)}l!==a&&(c[c.length-1]+=` ... ${a-n} more columns`);s!==o&&c.push(`... ${o-e} more rows`);return c.join(`\n${_w}`)}(t,n,r,i,o)}\n${Ew}]\n${Ew}rows: ${t.rows}\n${Ew}columns: ${t.columns}\n}`}function Sw(t,e,n){return(t>=0&&n?` ${xw(t,e-1)}`:xw(t,e)).padEnd(e)}function xw(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 Tw(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 Aw(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 Rw(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 Mw(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 Cw(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(ww("startRow",e),ww("endRow",n),ww("startColumn",r),ww("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 Pw(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function ww(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Nw(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Ow{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new Dw(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 Dw(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 Dw(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 Dw(t,e)}static ones(t,e){return new Dw(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 Dw(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 Dw(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 Dw(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 Ow.isMatrix(t)?t:new Dw(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}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 Dw(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){Tw(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return Dw.rowVector(this.getRow(t))}setRow(t,e){Tw(this,t),e=Rw(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){Tw(this,t),Tw(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){Aw(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return Dw.columnVector(this.getColumn(t))}setColumn(t,e){Aw(this,t),e=Mw(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){Aw(this,t),Aw(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=Rw(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=Rw(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=Rw(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=Rw(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=Mw(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=Mw(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=Mw(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=Mw(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){Tw(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){Aw(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(){Nw(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(){Nw(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(Tw(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){Tw(this,t),Nw(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(Tw(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){Tw(this,t),Nw(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(Aw(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){Aw(this,t),Nw(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(Aw(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){Aw(this,t),Nw(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"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let n=0;n<this.columns;n++)e+=this.get(t,n)*this.get(t,n);return Math.sqrt(e)}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){Ow.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=Dw.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new Dw(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}strassen2x2(t){t=Dw.checkMatrix(t);let e=new Dw(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),c=t.get(1,1),u=(n+l)*(r+c),h=(a+l)*r,d=n*(o-c),p=l*(s-r),f=(n+i)*c,g=u+p-f+(i-l)*(s+c),m=d+f,v=h+p,y=u-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,m),e.set(1,0,v),e.set(1,1,y),e}strassen3x3(t){t=Dw.checkMatrix(t);let e=new Dw(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),c=this.get(2,1),u=this.get(2,2),h=t.get(0,0),d=t.get(0,1),p=t.get(0,2),f=t.get(1,0),g=t.get(1,1),m=t.get(1,2),v=t.get(2,0),y=t.get(2,1),E=t.get(2,2),_=(n-o)*(-d+g),b=(-n+o+a)*(h-d+g),S=(o+a)*(-h+d),x=n*h,T=(-n+l+c)*(h-p+m),A=(-n+l)*(p-m),R=(l+c)*(-h+p),M=(-i+c+u)*(g+v-y),C=(i-u)*(g-y),P=i*v,w=(c+u)*(-v+y),N=(-i+a+s)*(m+v-E),O=(i-s)*(m-E),I=(a+s)*(-v+E),D=x+P+r*f,B=(n+r+i-o-a-c-u)*g+b+S+x+M+P+w,k=x+T+R+(n+r+i-a-s-l-c)*m+P+N+I,L=_+a*(-h+d+f-g-m-v+E)+b+x+P+N+O,F=_+b+S+x+s*y,U=P+N+O+I+o*p,G=x+T+A+c*(-h+p+f-g-m-v+y)+M+C+P,V=M+C+P+w+l*d,W=x+T+A+R+u*E;return e.set(0,0,D),e.set(0,1,B),e.set(0,2,k),e.set(1,0,L),e.set(1,1,F),e.set(1,2,U),e.set(2,0,G),e.set(2,1,V),e.set(2,2,W),e}mmulStrassen(t){t=Dw.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=Ow.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),c=n.subMatrix(0,o-1,0,s-1),u=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),p=n.subMatrix(o,n.rows-1,0,s-1),f=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),m=t(Ow.add(l,f),Ow.add(c,g),o,s),v=t(Ow.add(d,f),c,o,s),y=t(l,Ow.sub(h,g),o,s),E=t(f,Ow.sub(p,c),o,s),_=t(Ow.add(l,u),g,o,s),b=t(Ow.sub(d,l),Ow.add(c,h),o,s),S=t(Ow.sub(u,f),Ow.add(p,g),o,s),x=Ow.add(m,E);x.sub(_),x.add(S);let T=Ow.add(y,_),A=Ow.add(v,E),R=Ow.sub(m,v);R.add(y),R.add(b);let M=Ow.zeros(2*x.rows,2*x.columns);return M=M.setSubMatrix(x,0,0),M=M.setSubMatrix(T,x.rows,0),M=M.setSubMatrix(A,0,x.columns),M=M.setSubMatrix(R,x.rows,x.columns),M.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 Dw(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&yw(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 Dw(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&yw(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=Dw.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new Dw(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=Dw.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(Dw.eye(n,n)),i=Dw.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new Dw(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=Iw){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Iw){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){Cw(this,t,e,n,r);let i=new Dw(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 Dw(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 Dw(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=Dw.checkMatrix(t)).isEmpty())return this;Cw(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){!function(t,e){if(!vw(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")}(this,t),function(t,e){if(!vw(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")}(this,e);let n=new Dw(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(){let t=new Dw(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(e,n,this.get(e,n));return t}sum(t){switch(t){case"row":return function(t){let e=Pw(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=Pw(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=Pw(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=Pw(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(!vw(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(!vw(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(!vw(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(!vw(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+=Math.pow(t.get(n,e),2)/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!vw(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+=Math.pow(t.get(e,n),2)/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!vw(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+=Math.pow(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 bw(this,t)}}function Iw(t,e){return t-e}Ow.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Ow.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return bw(this)}),Ow.random=Ow.rand,Ow.randomInt=Ow.randInt,Ow.diagonal=Ow.diag,Ow.prototype.diagonal=Ow.prototype.diag,Ow.identity=Ow.eye,Ow.prototype.negate=Ow.prototype.neg,Ow.prototype.tensorProduct=Ow.prototype.kroneckerProduct;class Dw extends Ow{constructor(t,e){if(super(),Dw.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){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))}else{if(!vw(t))throw new TypeError("First argument must be a positive number or an array");{const n=t;if("number"!=typeof(e=(t=n.length)?n[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<t;r++){if(n[r].length!==e)throw new RangeError("Inconsistent array dimensions");if(!n[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(n[r]))}}}this.rows=t,this.columns=e}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return Tw(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Tw(this,t,!0),e=Float64Array.from(Rw(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Aw(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),Aw(this,t,!0),e=Mw(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,Math.pow(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,Math.pow(this.get(e,n),t.get(e,n)));return this}}(Ow,Dw);class Bw extends Ow{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]}}function kw(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 Lw{constructor(t,e={}){if((t=Bw.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),c=Boolean(o),u=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,u=!0;let e=l;l=c,c=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),p=new Float64Array(d),f=new Dw(n,h),g=new Dw(r,r),m=new Float64Array(r),v=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let E=Math.min(n-1,r),_=Math.max(0,Math.min(r-2,n)),b=Math.max(E,_);for(let t=0;t<b;t++){if(t<E){p[t]=0;for(let e=t;e<n;e++)p[t]=kw(p[t],s.get(e,t));if(0!==p[t]){s.get(t,t)<0&&(p[t]=-p[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/p[t]);s.set(t,t,s.get(t,t)+1)}p[t]=-p[t]}for(let e=t+1;e<r;e++){if(t<E&&0!==p[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))}m[e]=s.get(t,e)}if(l&&t<E)for(let e=t;e<n;e++)f.set(e,t,s.get(e,t));if(t<_){m[t]=0;for(let e=t+1;e<r;e++)m[t]=kw(m[t],m[e]);if(0!==m[t]){m[t+1]<0&&(m[t]=0-m[t]);for(let e=t+1;e<r;e++)m[e]/=m[t];m[t+1]+=1}if(m[t]=-m[t],t+1<n&&0!==m[t]){for(let e=t+1;e<n;e++)v[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)v[e]+=m[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-m[e]/m[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*v[i])}}if(c)for(let e=t+1;e<r;e++)g.set(e,t,m[e])}}let S=Math.min(r,n+1);if(E<r&&(p[E]=s.get(E,E)),n<S&&(p[S-1]=0),_+1<S&&(m[_]=s.get(_,S-1)),m[S-1]=0,l){for(let t=E;t<h;t++){for(let e=0;e<n;e++)f.set(e,t,0);f.set(t,t,1)}for(let t=E-1;t>=0;t--)if(0!==p[t]){for(let e=t+1;e<h;e++){let r=0;for(let i=t;i<n;i++)r+=f.get(i,t)*f.get(i,e);r=-r/f.get(t,t);for(let i=t;i<n;i++)f.set(i,e,f.get(i,e)+r*f.get(i,t))}for(let e=t;e<n;e++)f.set(e,t,-f.get(e,t));f.set(t,t,1+f.get(t,t));for(let e=0;e<t-1;e++)f.set(e,t,0)}else{for(let e=0;e<n;e++)f.set(e,t,0);f.set(t,t,1)}}if(c)for(let t=r-1;t>=0;t--){if(t<_&&0!==m[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 x=S-1,T=Number.EPSILON;for(;S>0;){let t,e;for(t=S-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+T*Math.abs(p[t]+Math.abs(p[t+1]));if(Math.abs(m[t])<=e||Number.isNaN(m[t])){m[t]=0;break}}if(t===S-2)e=4;else{let n;for(n=S-1;n>=t&&n!==t;n--){let e=(n!==S?Math.abs(m[n]):0)+(n!==t+1?Math.abs(m[n-1]):0);if(Math.abs(p[n])<=T*e){p[n]=0;break}}n===t?e=3:n===S-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=m[S-2];m[S-2]=0;for(let n=S-2;n>=t;n--){let i=kw(p[n],e),o=p[n]/i,a=e/i;if(p[n]=i,n!==t&&(e=-a*m[n-1],m[n-1]=o*m[n-1]),c)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,S-1),g.set(t,S-1,-a*g.get(t,n)+o*g.get(t,S-1)),g.set(t,n,i)}break}case 2:{let e=m[t-1];m[t-1]=0;for(let r=t;r<S;r++){let i=kw(p[r],e),o=p[r]/i,a=e/i;if(p[r]=i,e=-a*m[r],m[r]=o*m[r],l)for(let e=0;e<n;e++)i=o*f.get(e,r)+a*f.get(e,t-1),f.set(e,t-1,-a*f.get(e,r)+o*f.get(e,t-1)),f.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(p[S-1]),Math.abs(p[S-2]),Math.abs(m[S-2]),Math.abs(p[t]),Math.abs(m[t])),i=p[S-1]/e,o=p[S-2]/e,a=m[S-2]/e,s=p[t]/e,u=m[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let v=0;0===h&&0===d||(v=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),v=d/(h+v));let y=(s+i)*(s-i)+v,E=s*u;for(let e=t;e<S-1;e++){let i=kw(y,E);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=E/i;if(e!==t&&(m[e-1]=i),y=o*p[e]+a*m[e],m[e]=o*m[e]-a*p[e],E=a*p[e+1],p[e+1]=o*p[e+1],c)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=kw(y,E),0===i&&(i=Number.MIN_VALUE),o=y/i,a=E/i,p[e]=i,y=o*m[e]+a*p[e+1],p[e+1]=-a*m[e]+o*p[e+1],E=a*m[e+1],m[e+1]=o*m[e+1],l&&e<n-1)for(let t=0;t<n;t++)i=o*f.get(t,e)+a*f.get(t,e+1),f.set(t,e+1,-a*f.get(t,e)+o*f.get(t,e+1)),f.set(t,e,i)}m[S-2]=y;break}case 4:if(p[t]<=0&&(p[t]=p[t]<0?-p[t]:0,c))for(let e=0;e<=x;e++)g.set(e,t,-g.get(e,t));for(;t<x&&!(p[t]>=p[t+1]);){let e=p[t];if(p[t]=p[t+1],p[t+1]=e,c&&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=f.get(r,t+1),f.set(r,t+1,f.get(r,t)),f.set(r,t,e);t++}S--}}if(u){let t=g;g=f,f=t}this.m=n,this.n=r,this.s=p,this.U=f,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=Dw.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,c=o.rows,u=Dw.zeros(l,c);for(let t=0;t<l;t++)for(let e=0;e<c;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);u.set(t,e,n)}return u.mmul(e)}solveForDiagonal(t){return this.solve(Dw.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new Dw(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 Dw(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 Dw.diag(this.s)}}var Fw={center:[0,0],linkDistance:50},Uw=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=wc(wc({},Fw),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f;return Ic(this,(function(g){return r=wc(wc({},this.options),n),i=r.center,o=void 0===i?[0,0]:i,a=r.linkDistance,s=void 0===a?50:a,l=e.getAllNodes(),c=e.getAllEdges(),(null==l?void 0:l.length)&&1!==l.length?(u=NP({nodes:l,edges:c},!1),h=wP(u),Gw(h),d=OP(h,s),p=Vw(d),f=[],p.forEach((function(t,e){var n=GP(l[e]);n.data.x=t[0]+o[0],n.data.y=t[1]+o[1],f.push(n)})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:c}]):[2,HP(e,t,o)]}))}))},t}(),Gw=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(n,r){n.forEach((function(n,i){n===1/0&&(t[r][i]=e)}))}))},Vw=function(t){var e=Dw.mul(Dw.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);var o=new Lw(e),a=Dw.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((function(t){return Dw.mul([t],[a]).toJSON()[0].splice(0,2)}))};function Ww(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,l,c,u,h,d,p=t._root,f={data:r},g=t._x0,m=t._y0,v=t._x1,y=t._y1;if(!p)return t._root=f,t;for(;p.length;)if((c=e>=(o=(g+v)/2))?g=o:v=o,(u=n>=(a=(m+y)/2))?m=a:y=a,i=p,!(p=p[h=u<<1|c]))return i[h]=f,t;if(s=+t._x.call(null,p.data),l=+t._y.call(null,p.data),e===s&&n===l)return f.next=p,i?i[h]=f:t._root=f,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(c=e>=(o=(g+v)/2))?g=o:v=o,(u=n>=(a=(m+y)/2))?m=a:y=a}while((h=u<<1|c)==(d=(l>=a)<<1|s>=o));return i[d]=p,i[h]=f,t}function zw(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Hw(t){return t[0]}function jw(t){return t[1]}function Xw(t,e,n){var r=new Yw(null==e?Hw:e,null==n?jw:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Yw(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 Kw(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var qw=Xw.prototype=Yw.prototype;function $w(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,l,c,u,h,d,p,f,g,m,v=t._root,y={data:i},E=t._x0,_=t._y0,b=t._z0,S=t._x1,x=t._y1,T=t._z1;if(!v)return t._root=y,t;for(;v.length;)if((d=e>=(a=(E+S)/2))?E=a:S=a,(p=n>=(s=(_+x)/2))?_=s:x=s,(f=r>=(l=(b+T)/2))?b=l:T=l,o=v,!(v=v[g=f<<2|p<<1|d]))return o[g]=y,t;if(c=+t._x.call(null,v.data),u=+t._y.call(null,v.data),h=+t._z.call(null,v.data),e===c&&n===u&&r===h)return y.next=v,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(E+S)/2))?E=a:S=a,(p=n>=(s=(_+x)/2))?_=s:x=s,(f=r>=(l=(b+T)/2))?b=l:T=l}while((g=f<<2|p<<1|d)==(m=(h>=l)<<2|(u>=s)<<1|c>=a));return o[m]=v,o[g]=y,t}function Zw(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}function Qw(t){return t[0]}function Jw(t){return t[1]}function tN(t){return t[2]}function eN(t,e,n,r){var i=new nN(null==e?Qw:e,null==n?Jw:n,null==r?tN:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function nN(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 rN(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}qw.copy=function(){var t,e,n=new Yw(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=Kw(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]=Kw(e));return n},qw.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Ww(this.cover(e,n),e,n,t)},qw.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),l=1/0,c=1/0,u=-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>u&&(u=r),i<c&&(c=i),i>h&&(h=i));if(l>u||c>h)return this;for(this.cover(l,c).cover(u,h),n=0;n<o;++n)Ww(this,a[n],s[n],t[n]);return this},qw.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,c=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=c,c=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=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},qw.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},qw.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]]},qw.find=function(t,e,n){var r,i,o,a,s,l,c,u=this._x0,h=this._y0,d=this._x1,p=this._y1,f=[],g=this._root;for(g&&f.push(new zw(g,u,h,d,p)),null==n?n=1/0:(u=t-n,h=e-n,d=t+n,p=e+n,n*=n);l=f.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(o=l.y0)>p||(a=l.x1)<u||(s=l.y1)<h))if(g.length){var m=(i+a)/2,v=(o+s)/2;f.push(new zw(g[3],m,v,a,s),new zw(g[2],i,v,m,s),new zw(g[1],m,o,a,v),new zw(g[0],i,o,m,v)),(c=(e>=v)<<1|t>=m)&&(l=f[f.length-1],f[f.length-1]=f[f.length-1-c],f[f.length-1-c]=l)}else{var y=t-+this._x.call(null,g.data),E=e-+this._y.call(null,g.data),_=y*y+E*E;if(_<n){var b=Math.sqrt(n=_);u=t-b,h=e-b,d=t+b,p=e+b,r=g.data}}return r},qw.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,c,u,h,d,p=this._root,f=this._x0,g=this._y0,m=this._x1,v=this._y1;if(!p)return this;if(p.length)for(;;){if((c=o>=(s=(f+m)/2))?f=s:m=s,(u=a>=(l=(g+v)/2))?g=l:v=l,e=p,!(p=p[h=u<<1|c]))return this;if(!p.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}for(;p.data!==t;)if(r=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(p=e[0]||e[1]||e[2]||e[3])&&p===(e[3]||e[2]||e[1]||e[0])&&!p.length&&(n?n[d]=p:this._root=p),this):(this._root=i,this)},qw.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},qw.root=function(){return this._root},qw.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},qw.visit=function(t){var e,n,r,i,o,a,s=[],l=this._root;for(l&&s.push(new zw(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 c=(r+o)/2,u=(i+a)/2;(n=l[3])&&s.push(new zw(n,c,u,o,a)),(n=l[2])&&s.push(new zw(n,r,u,c,a)),(n=l[1])&&s.push(new zw(n,c,i,o,u)),(n=l[0])&&s.push(new zw(n,r,i,c,u))}return this},qw.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new zw(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,c=e.y1,u=(a+l)/2,h=(s+c)/2;(o=i[0])&&n.push(new zw(o,a,s,u,h)),(o=i[1])&&n.push(new zw(o,u,s,l,h)),(o=i[2])&&n.push(new zw(o,a,h,u,c)),(o=i[3])&&n.push(new zw(o,u,h,l,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},qw.x=function(t){return arguments.length?(this._x=t,this):this._x},qw.y=function(t){return arguments.length?(this._y=t,this):this._y};var iN=eN.prototype=nN.prototype;iN.copy=function(){var t,e,n=new nN(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=rN(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]=rN(e));return n},iN.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return $w(this.cover(e,n,r),e,n,r,t)},iN.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,c=-1/0,u=-1/0;for(let h,d,p,f,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(p=+this._y.call(null,h))||isNaN(f=+this._z.call(null,h))||(n[g]=d,r[g]=p,i[g]=f,d<o&&(o=d),d>l&&(l=d),p<a&&(a=p),p>c&&(c=p),f<s&&(s=f),f>u&&(u=f));if(o>l||a>c||s>u)return this;this.cover(o,a,s).cover(l,c,u);for(let o=0;o<e;++o)$w(this,n[o],r[o],i[o],t[o]);return this},iN.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 c,u,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=l;)switch(u=(n<o)<<2|(e<i)<<1|t<r,(c=new Array(8))[u]=d,d=c,h*=2,u){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},iN.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},iN.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]]},iN.find=function(t,e,n,r){var i,o,a,s,l,c,u,h,d,p=this._x0,f=this._y0,g=this._z0,m=this._x1,v=this._y1,y=this._z1,E=[],_=this._root;for(_&&E.push(new Zw(_,p,f,g,m,v,y)),null==r?r=1/0:(p=t-r,f=e-r,g=n-r,m=t+r,v=e+r,y=n+r,r*=r);h=E.pop();)if(!(!(_=h.node)||(o=h.x0)>m||(a=h.y0)>v||(s=h.z0)>y||(l=h.x1)<p||(c=h.y1)<f||(u=h.z1)<g))if(_.length){var b=(o+l)/2,S=(a+c)/2,x=(s+u)/2;E.push(new Zw(_[7],b,S,x,l,c,u),new Zw(_[6],o,S,x,b,c,u),new Zw(_[5],b,a,x,l,S,u),new Zw(_[4],o,a,x,b,S,u),new Zw(_[3],b,S,s,l,c,x),new Zw(_[2],o,S,s,b,c,x),new Zw(_[1],b,a,s,l,S,x),new Zw(_[0],o,a,s,b,S,x)),(d=(n>=x)<<2|(e>=S)<<1|t>=b)&&(h=E[E.length-1],E[E.length-1]=E[E.length-1-d],E[E.length-1-d]=h)}else{var T=t-+this._x.call(null,_.data),A=e-+this._y.call(null,_.data),R=n-+this._z.call(null,_.data),M=T*T+A*A+R*R;if(M<r){var C=Math.sqrt(r=M);p=t-C,f=e-C,g=n-C,m=t+C,v=e+C,y=n+C,i=_.data}}return i},iN.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,c,u,h,d,p,f,g,m=this._root,v=this._x0,y=this._y0,E=this._z0,_=this._x1,b=this._y1,S=this._z1;if(!m)return this;if(m.length)for(;;){if((h=o>=(l=(v+_)/2))?v=l:_=l,(d=a>=(c=(y+b)/2))?y=c:b=c,(p=s>=(u=(E+S)/2))?E=u:S=u,e=m,!(m=m[f=p<<2|d<<1|h]))return this;if(!m.length)break;(e[f+1&7]||e[f+2&7]||e[f+3&7]||e[f+4&7]||e[f+5&7]||e[f+6&7]||e[f+7&7])&&(n=e,g=f)}for(;m.data!==t;)if(r=m,!(m=m.next))return this;return(i=m.next)&&delete m.next,r?(i?r.next=i:delete r.next,this):e?(i?e[f]=i:delete e[f],(m=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&m===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!m.length&&(n?n[g]=m:this._root=m),this):(this._root=i,this)},iN.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},iN.root=function(){return this._root},iN.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},iN.visit=function(t){var e,n,r,i,o,a,s,l,c=[],u=this._root;for(u&&c.push(new Zw(u,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(u=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,l=e.z1)&&u.length){var h=(r+a)/2,d=(i+s)/2,p=(o+l)/2;(n=u[7])&&c.push(new Zw(n,h,d,p,a,s,l)),(n=u[6])&&c.push(new Zw(n,r,d,p,h,s,l)),(n=u[5])&&c.push(new Zw(n,h,i,p,a,d,l)),(n=u[4])&&c.push(new Zw(n,r,i,p,h,d,l)),(n=u[3])&&c.push(new Zw(n,h,d,o,a,s,p)),(n=u[2])&&c.push(new Zw(n,r,d,o,h,s,p)),(n=u[1])&&c.push(new Zw(n,h,i,o,a,d,p)),(n=u[0])&&c.push(new Zw(n,r,i,o,h,d,p))}return this},iN.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Zw(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,c=e.x1,u=e.y1,h=e.z1,d=(a+c)/2,p=(s+u)/2,f=(l+h)/2;(o=i[0])&&n.push(new Zw(o,a,s,l,d,p,f)),(o=i[1])&&n.push(new Zw(o,d,s,l,c,p,f)),(o=i[2])&&n.push(new Zw(o,a,p,l,d,u,f)),(o=i[3])&&n.push(new Zw(o,d,p,l,c,u,f)),(o=i[4])&&n.push(new Zw(o,a,s,f,d,p,h)),(o=i[5])&&n.push(new Zw(o,d,s,f,c,p,h)),(o=i[6])&&n.push(new Zw(o,a,p,f,d,u,h)),(o=i[7])&&n.push(new Zw(o,d,p,f,c,u,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},iN.x=function(t){return arguments.length?(this._x=t,this):this._x},iN.y=function(t){return arguments.length?(this._y=t,this):this._y},iN.z=function(t){return arguments.length?(this._z=t,this):this._z};function oN(t,e,n,r,i){void 0===i&&(i=2);var o=e/n,a=t.getAllNodes(),s=a.map((function(t,e){var n=t.data,r=n.nodeStrength;return{x:n.x,y:n.y,z:n.z,size:n.size,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*r}})),l=(2===i?Xw(s,(function(t){return t.x}),(function(t){return t.y})):eN(s,(function(t){return t.x}),(function(t){return t.y}),(function(t){return t.z}))).visitAfter(aN),c=new Map;return s.forEach((function(t){c.set(t.id,t),function(t,e,n){e.visit((function(e,r,i,o,a){return sN(e,r,i,o,a,t,n)}))}(t,l,i)})),s.map((function(t,e){var n=a[e],i=n.id,o=n.data.mass,s=void 0===o?1:o;r[i]={x:t.vx/s,y:t.vy/s,z:t.vz/s}})),r}function aN(t){var e=0,n=0,r=0,i=0,o=0,a=t.length;if(a){for(var s=0;s<a;s++){(l=t[s])&&l.weight&&(e+=l.weight,n+=l.x*l.weight,r+=l.y*l.weight,i+=l.z*l.weight,o+=l.size*l.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{var l=t;t.x=l.data.x,t.y=l.data.y,t.z=l.data.z,t.size=l.data.size,t.weight=l.data.weight}}var sN=function(t,e,n,r,i,o,a){var s;if((null===(s=t.data)||void 0===s?void 0:s.id)!==o.id){for(var l=[n,r,i][a-1],c=o.x-t.x||.1,u=o.y-t.y||.1,h=o.z-t.z||.1,d=[c,u,h],p=l-e,f=0,g=0;g<a;g++)f+=d[g]*d[g];var m=Math.sqrt(f)*f;if(p*p*.81<f){var v=t.weight/m;return o.vx+=c*v,o.vy+=u*v,o.vz+=h*v,!0}if(t.length)return!1;if(t.data!==o){v=t.data.weight/m;o.vx+=c*v,o.vy+=u*v,o.vz+=h*v}}};var lN={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"},cN=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=wc(wc({},lN),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var n=0;(this.judgingDistance>this.lastOptions.minMovement||n<1)&&n<t;n++)this.runOneStep(this.lastCalcGraph,this.lastGraph,n,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var r={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),r},t.prototype.genericForceLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x=this;return Ic(this,(function(T){return r=wc(wc({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),s=a.dimensions,l=a.width,c=a.height,u=a.nodeSize,h=a.getMass,d=a.nodeStrength,p=a.edgeStrength,f=a.linkDistance,g=i.map((function(t,e){return wc(wc({},t),{data:wc(wc({},t.data),{x:Ue(t.data.x)?t.data.x:Math.random()*l,y:Ue(t.data.y)?t.data.y:Math.random()*c,z:Ue(t.data.z)?t.data.z:Math.random()*Math.sqrt(l*c),size:u(t)||30,mass:h(t),nodeStrength:d(t)})})})),m=o.map((function(t){return wc(wc({},t),{data:wc(wc({},t.data),{edgeStrength:p(t),linkDistance:f(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(v={},i.forEach((function(t,e){v[t.id]={x:0,y:0,z:0}})),y=new TP({nodes:g,edges:m}),this.formatCentripetal(a,y),E=a.maxIteration,_=a.minMovement,b=a.onTick,this.lastLayoutNodes=g,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=v,"undefined"==typeof window?[2]:(S=0,[2,new Promise((function(n){x.timeInterval=window.setInterval((function(){i&&x.running||n({nodes:fN(e,g),edges:o}),x.runOneStep(y,e,S,v,a),x.updatePosition(e,y,v,a),t&&g.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0})})),null==b||b({nodes:fN(e,g),edges:o}),(++S>=E||x.judgingDistance<_)&&(window.clearInterval(x.timeInterval),n({nodes:fN(e,g),edges:o}))}),0),x.running=!0}))])):(this.lastResult={nodes:[],edges:o},[2,{nodes:[],edges:o}])}))}))},t.prototype.formatOptions=function(t,e){var n=wc({},t),r=t.width,i=t.height,o=t.getMass,a=t.nodeSize;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=function(t){var n=1;Ue(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);var r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n});var s,l=VP(0,t.nodeSpacing);s=a?Se(a)?function(t){return a(t)+l(t)}:PP(a)?function(t){var e=a;return Math.max(e[0],e[1])+l(t)}:function(t){return a+l(t)}:function(t){var e=((null==t?void 0:t.data)||{}).size;return e?PP(e)?Math.max(e[0],e[1])+l(t):Me(e)?Math.max(e.width,e.height)+l(t):e+l(t):10+l(t)},n.nodeSize=s;var c=t.linkDistance?VP(1,t.linkDistance):function(t){return 1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target))};return n.linkDistance=c,n.nodeStrength=VP(1,t.nodeStrength),n.edgeStrength=VP(1,t.edgeStrength),n},t.prototype.formatCentripetal=function(t,e){var n,r,i=t.dimensions,o=t.centripetalOptions,a=t.center,s=t.clusterNodeStrength,l=t.leafCluster,c=t.clustering,u=t.nodeClusterBy,h=e.getAllNodes(),d=o||{leaf:2,single:2,others:1,center:function(t){return{x:a[0],y:a[1],z:3===i?a[2]:void 0}}};if("function"!=typeof s&&(t.clusterNodeStrength=function(t){return s}),l&&u&&(n=uN(e,u),r=Array.from(new Set(null==h?void 0:h.map((function(t){return t.data[u]}))))||[],t.centripetalOptions=Object.assign(d,{single:100,leaf:function(e){var i=n[e.id]||{},o=i.siblingLeaves,a=i.sameTypeLeaves;return(null==a?void 0:a.length)===(null==o?void 0:o.length)||1===(null==r?void 0:r.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var r,i=e.getDegree(t.id,"both");if(!i)return{x:100,y:100,z:0};if(1===i){var o=(n[t.id]||{}).sameTypeLeaves,a=void 0===o?[]:o;1===a.length?r=void 0:a.length>1&&(r=pN(a))}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}}})),c&&u){n||(n=uN(e,u)),r||(r=Array.from(new Set(h.map((function(t){return t.data[u]}))))),r=r.filter((function(t){return void 0!==t}));var p={};r.forEach((function(t){var n=h.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));p[t]=pN(n)})),t.centripetalOptions=Object.assign(d,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=p[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}var f=t.centripetalOptions||{},g=f.leaf,m=f.single,v=f.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),m&&"function"!=typeof m&&(t.centripetalOptions.single=function(){return m}),v&&"function"!=typeof v&&(t.centripetalOptions.others=function(){return v})},t.prototype.runOneStep=function(t,e,n,r,i){var o={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var l=i.monitor;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})}},t.prototype.calTotalEnergy=function(t,e){var n=this;if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,i){var o=t[e.id].x,a=t[e.id].y,s=3===n.options.dimensions?t[e.id].z:0,l=o*o+a*a+s*s,c=e.data.mass;r+=(void 0===c?1:c)*l*.5})),r},t.prototype.calRepulsive=function(t,e,n){var r=n.dimensions,i=n.factor,o=n.coulombDisScale;oN(t,i,o*o,e,r)},t.prototype.calAttractive=function(t,e,n){var r=n.dimensions,i=n.nodeSize;t.getAllEdges().forEach((function(n,o){var a=n.source,s=n.target,l=t.getNode(a),c=t.getNode(s);if(l&&c){var u=c.data.x-l.data.x,h=c.data.y-l.data.y,d=3===r?c.data.z-l.data.z:0;u||h||(u=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));var p=Math.sqrt(u*u+h*h+d*d);if(!(p<i(l)+i(c))){var f=u/p,g=h/p,m=d/p,v=n.data||{},y=v.linkDistance,E=void 0===y?200:y,_=v.edgeStrength,b=(E-p)*(void 0===_?200:_),S=1/(l.data.mass||1),x=1/(c.data.mass||1),T=f*b,A=g*b,R=m*b;e[a].x-=T*S,e[a].y-=A*S,e[a].z-=R*S,e[s].x+=T*x,e[s].y+=A*x,e[s].z+=R*x}}}))},t.prototype.calGravity=function(t,e,n,r){var i=r.getCenter,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),l=r.width,c=r.height,u=r.center,h=r.gravity,d=r.centripetalOptions;o&&o.forEach((function(r){var o=r.id,p=r.data,f=p.mass,g=p.x,m=p.y,v=p.z,y=e.getNode(o),E=0,_=0,b=0,S=h,x=t.getDegree(o,"in"),T=t.getDegree(o,"out"),A=t.getDegree(o,"both"),R=null==i?void 0:i(y,A);if(R){var M=Bc(R,3);E=g-M[0],_=m-M[1],S=M[2]}else E=g-u[0],_=m-u[1],b=v-u[2];if(S&&(n[o].x-=S*E/f,n[o].y-=S*_/f,n[o].z-=S*b/f),d){var C=d.leaf,P=d.single,w=d.others,N=d.center,O=(null==N?void 0:N(y,a,s,l,c))||{x:0,y:0,z:0,centerStrength:0},I=O.x,D=O.y,B=O.z,k=O.centerStrength;if(!Ue(I)||!Ue(D))return;var L=(g-I)/f,F=(m-D)/f,U=(v-B)/f;if(k&&(n[o].x-=k*L,n[o].y-=k*F,n[o].z-=k*U),0===A){var G=P(y);if(!G)return;return n[o].x-=G*L,n[o].y-=G*F,void(n[o].z-=G*U)}if(0===x||0===T){var V=C(y,a,s);if(!V)return;return n[o].x-=V*L,n[o].y-=V*F,void(n[o].z-=V*U)}var W=w(y);if(!W)return;n[o].x-=W*L,n[o].y-=W*F,n[o].z-=W*U}}))},t.prototype.updateVelocity=function(t,e,n,r){var i=r.damping,o=r.maxSpeed,a=r.interval,s=r.dimensions,l=t.getAllNodes();(null==l?void 0:l.length)&&l.forEach((function(t){var r=t.id,l=(n[r].x+e[r].x*a)*i||.01,c=(n[r].y+e[r].y*a)*i||.01,u=3===s?(n[r].z+e[r].z*a)*i||.01:0,h=Math.sqrt(l*l+c*c+u*u);if(h>o){var d=o/h;l*=d,c*=d,u*=d}n[r]={x:l,y:c,z:u}}))},t.prototype.updatePosition=function(t,e,n,r){var i=this,o=r.distanceThresholdMode,a=r.interval,s=r.dimensions,l=e.getAllNodes();if(null==l?void 0:l.length){var c=0;"max"===o?this.judgingDistance=-1/0:"min"===o&&(this.judgingDistance=1/0),l.forEach((function(r){var l=r.id,u=t.getNode(l);if(Ue(u.data.fx)&&Ue(u.data.fy))e.mergeNodeData(l,{x:u.data.fx,y:u.data.fy,z:3===s?u.data.fz:void 0});else{var h=n[l].x*a,d=n[l].y*a,p=3===s?n[l].z*a:0;e.mergeNodeData(l,{x:r.data.x+h,y:r.data.y+d,z:r.data.z+p});var f=Math.sqrt(h*h+d*d+p*p);switch(o){case"max":i.judgingDistance<f&&(i.judgingDistance=f);break;case"min":i.judgingDistance>f&&(i.judgingDistance=f);break;default:c+=f}}})),o&&"mean"!==o||(this.judgingDistance=c/l.length)}else this.judgingDistance=0},t}(),uN=function(t,e){var n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};var r={};return n.forEach((function(n,i){1===t.getDegree(n.id,"both")&&(r[n.id]=hN(t,"leaf",n,e))})),r},hN=function(t,e,n,r){var i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out"),a=n,s=[];return 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((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:dN(t,e,r,n,s)}},dN=function(t,e,n,r,i){var o=r.data[n]||"",a=(null==i?void 0:i.filter((function(t){return t.data[n]===o})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},pN=function(t){var e={x:0,y:0};t.forEach((function(t){var n=t.data,r=n.x,i=n.y;e.x+=r||0,e.y+=i||0}));var n=t.length||1;return{x:e.x/n,y:e.y/n}},fN=function(t,e){return e.map((function(e){var n=e.id,r=e.data,i=t.getNode(n);return wc(wc({},i),{data:wc(wc({},i.data),{x:r.x,y:r.y,z:r.z})})}))},gN={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},mN=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=wc(wc({},gN),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P,w,N,O,I,D,B,k,L,F,U,G;return Ic(this,(function(V){if(r=wc(wc({},this.options),n),i=r.center,o=r.width,a=r.height,s=r.sortBy,l=r.maxLevelDiff,c=r.sweep,u=r.clockwise,h=r.equidistant,d=r.preventOverlap,p=r.startAngle,f=void 0===p?1.5*Math.PI:p,g=r.nodeSize,m=r.nodeSpacing,v=e.getAllNodes(),y=e.getAllEdges(),E=o||"undefined"==typeof window?o:window.innerWidth,_=a||"undefined"==typeof window?a:window.innerHeight,b=i||[E/2,_/2],!(null==v?void 0:v.length)||1===v.length)return[2,HP(e,t,b)];if(S=[],T=0,PP(g)?x=Math.max(g[0],g[1]):Se(g)?(x=-1/0,v.forEach((function(t){var e=g(t);e>x&&(x=e)}))):x=g,PP(m)?T=Math.max(m[0],m[1]):Ue(m)&&(T=m),v.forEach((function(t){var e=GP(t);S.push(e);var n=x,r=e.data;PP(r.size)?n=Math.max(r.size[0],r.size[1]):Ue(r.size)?n=r.size:Me(r.size)&&(n=Math.max(r.size.width,r.size.height)),x=Math.max(x,n),Se(m)&&(T=Math.max(m(t),T))})),A={},S.forEach((function(t,e){A[t.id]=e})),De(R=s)&&void 0!==S[0].data[R]||(R="degree"),"degree"===R?S.sort((function(t,n){return e.getDegree(n.id,"both")-e.getDegree(t.id,"both")})):S.sort((function(t,e){return e.data[R]-t.data[R]})),M=S[0],C=(l||("degree"===R?e.getDegree(M.id,"both"):M.data[R]))/4,w=(P=[{nodes:[]}])[0],S.forEach((function(t){if(w.nodes.length>0){var n="degree"===R?Math.abs(e.getDegree(w.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(w.nodes[0].data[R]-t.data[R]);C&&n>=C&&(w={nodes:[]},P.push(w))}w.nodes.push(t)})),N=x+T,d||(O=P.length>0&&P[0].nodes.length>1,I=Math.min(E,_)/2-N,D=I/(P.length+(O?1:0)),N=Math.min(N,D)),B=0,P.forEach((function(t){var e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){var n=Math.cos(t.dTheta)-Math.cos(0),r=Math.sin(t.dTheta)-Math.sin(0),i=Math.sqrt(N*N/(n*n+r*r));B=Math.max(i,B)}t.r=B,B+=N})),h){for(k=0,L=0,F=0;F<P.length;F++)U=P[F],G=(U.r||0)-L,k=Math.max(k,G);L=0,P.forEach((function(t,e){0===e&&(L=t.r||0),t.r=L,L+=k}))}return P.forEach((function(t){var e=t.dTheta||0,n=t.r||0;t.nodes.forEach((function(t,r){var i=f+(u?1:-1)*e*r;t.data.x=b[0]+n*Math.cos(i),t.data.y=b[1]+n*Math.sin(i)}))})),t&&S.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:S,edges:y}]}))}))},t}(),vN={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},yN={center:[0,0],comboPadding:10,treeKey:"combo"},EN=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="comboCombined",this.options=wc(wc({},yN),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericComboCombinedLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){switch(n.label){case 0:return[4,this.genericComboCombinedLayout(!0,t,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.genericComboCombinedLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x;return Ic(this,(function(T){switch(T.label){case 0:return r=this.initVals(wc(wc({},this.options),n)),i=r.center,o=r.treeKey,a=r.outerLayout,s=e.getAllNodes().filter((function(t){return!t.data._isCombo})),l=e.getAllNodes().filter((function(t){return t.data._isCombo})),c=e.getAllEdges(),(u=null==s?void 0:s.length)&&1!==u?(h=[],d=new Map,s.forEach((function(t){d.set(t.id,t)})),p=new Map,l.forEach((function(t){p.set(t.id,t)})),f=new Map,g=this.getInnerGraphs(e,o,d,p,c,r,f),[4,Promise.all(g)]):[2,HP(e,t,i)];case 1:return T.sent(),m=new Map,v=[],y=new Map,E=!0,e.getRoots(o).forEach((function(t){var n=f.get(t.id),r=p.get(t.id)||d.get(t.id),i={id:t.id,data:wc(wc({},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})};v.push(i),m.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()):E=!1,FP(e,[t],(function(e){e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)})),_=[],c.forEach((function(t){var e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&m.has(e)&&m.has(n)&&_.push({id:t.id,source:e,target:n,data:{}})})),(null==v?void 0:v.length)?1!==v.length?[3,2]:(v[0].data.x=i[0],v[0].data.y=i[1],[3,6]):[3,7];case 2:return S=new TP({nodes:v,edges:_}),x=a||new cN,E&&vN[x.id]?[4,(v.length<100?new Uw:new mN).assign(S)]:[3,4];case 3:T.sent(),T.label=4;case 4:return[4,x.execute(S,wc({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===x.id?{gravity:1,factor:4,linkDistance:function(t,e,n){return(Math.max.apply(Math,kc([],Bc(e.data.size)))||32)/2+(Math.max.apply(Math,kc([],Bc(n.data.size)))||32)/2+200}}:{}))];case 5:b=T.sent(),T.label=6;case 6:f.forEach((function(t){var e,n=b.nodes.find((function(e){return e.id===t.id}));if(n){var r=n.data,i=r.x,o=r.y;t.data.visited=!0,t.data.x=i,t.data.y=o,h.push({id:t.id,data:{x:i,y:o}})}var a=t.data,s=a.x,l=a.y;null===(e=t.data.nodes)||void 0===e||e.forEach((function(t){h.push({id:t.id,data:{x:t.data.x+s,y:t.data.y+l}})}))})),f.forEach((function(t){var e,n=t.data,r=n.x,i=n.y,o=n.visited;null===(e=n.nodes)||void 0===e||e.forEach((function(t){if(!o){var e=h.find((function(e){return e.id===t.id}));e.data.x+=r||0,e.data.y+=i||0}}))})),T.label=7;case 7:return t&&h.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:h,edges:c}]}}))}))},t.prototype.initVals=function(t){var e,n,r,i=wc({},t),o=t.nodeSize,a=t.spacing,s=t.comboPadding;if(n=Ue(a)?function(){return a}:Se(a)?a:function(){return 0},i.spacing=n,o)if(Se(o))e=function(t){var e=o(t),r=n(t);return PP(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2:((e||32)+r)/2};else if(PP(o)){var l=(o[0]>o[1]?o[0]:o[1])/2;e=function(t){return l+n(t)/2}}else{var c=o/2;e=function(t){return c+n(t)/2}}else e=function(t){var e=n(t);return t.size?PP(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2:Me(t.size)?((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2:(t.size+e)/2:32+e/2};return i.nodeSize=e,r=Ue(s)?function(){return s}:PP(s)?function(){return Math.max.apply(null,s)}:Se(s)?s:function(){return 0},i.comboPadding=r,i},t.prototype.getInnerGraphs=function(t,e,n,r,i,o,a){var s=this,l=o.nodeSize,c=o.comboPadding,u=o.spacing,h=o.innerLayout||new mN({}),d={center:[0,0],preventOverlap:!0,nodeSpacing:u},p=[],f=function(t){var e=(null==c?void 0:c(t))||10;return PP(e)&&(e=Math.max.apply(Math,kc([],Bc(e)))),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((function(o){a.set(o.id,{id:o.id,data:{nodes:[],size:f(o).size}});var c=Promise.resolve();FP(t,[o],(function(o){var u;if(o.data._isCombo){var p=f(o),g=p.size,m=p.padding;if(null===(u=t.getChildren(o.id,e))||void 0===u?void 0:u.length){var v=a.get(o.id);a.set(o.id,{id:o.id,data:wc({nodes:[]},null==v?void 0:v.data)});var y=new Map,E=t.getChildren(o.id,e).map((function(t){if(t.data._isCombo)return a.has(t.id)||a.set(t.id,{id:t.id,data:wc({},t.data)}),y.set(t.id,!0),a.get(t.id);var e=n.get(t.id)||r.get(t.id);return y.set(t.id,!0),{id:t.id,data:wc(wc({},e.data),t.data)}})),_={nodes:E,edges:i.filter((function(t){return y.has(t.source)&&y.has(t.target)}))},b=1/0;E.forEach((function(t){var e,n,r=t.data.size;r||(r=(null===(e=a.get(t.id))||void 0===e?void 0:e.data.size)||(null===(n=l)||void 0===n?void 0:n(t))||[30,30]),Ue(r)&&(r=[r,r]);var i=Bc(r,2),o=i[0],s=i[1];b>o&&(b=o),b>s&&(b=s),t.data.size=r})),c=c.then((function(){return Oc(s,void 0,void 0,(function(){var t,e,n,r,i,s,l,c,u;return Ic(this,(function(p){switch(p.label){case 0:return t=new TP(_),[4,h.assign(t,d)];case 1:return e=p.sent(),n=DP(E),r=n.minX,i=n.minY,s=n.maxX,l=n.maxY,c={x:(s+r)/2,y:(l+i)/2},_.nodes.forEach((function(t){t.data.x-=c.x,t.data.y-=c.y})),u=[Math.max(s-r,b)+2*m,Math.max(l-i,b)+2*m],a.get(o.id).data.size=u,a.get(o.id).data.nodes=E,[2,e]}}))}))}))}else a.set(o.id,{id:o.id,data:wc(wc({},o.data),{size:g})});return!0}}),"BT",e),p.push(c)})),p},t}();function _N(t){return function(){return t}}function bN(t){return 1e-6*(t()-.5)}function SN(t){return t.x+t.vx}function xN(t){return t.y+t.vy}function TN(t){var e,n,r,i=1,o=1;function a(){for(var t,a,l,c,u,h,d,p=e.length,f=0;f<o;++f)for(a=Xw(e,SN,xN).visitAfter(s),t=0;t<p;++t)l=e[t],h=n[l.index],d=h*h,c=l.x+l.vx,u=l.y+l.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,p=t.r,f=h+p;if(!s)return e>c+f||o<c-f||n>u+f||a<u-f;if(s.index>l.index){var g=c-s.x-s.vx,m=u-s.y-s.vy,v=g*g+m*m;v<f*f&&(0===g&&(v+=(g=bN(r))*g),0===m&&(v+=(m=bN(r))*m),v=(f-(v=Math.sqrt(v)))/v*i,l.vx+=(g*=v)*(f=(p*=p)/(d+p)),l.vy+=(m*=v)*f,s.vx-=g*(f=1-f),s.vy-=m*f)}}}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=_N(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:_N(+e),l(),a):t},a}function AN(t){return t.index}function RN(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function MN(t){var e,n,r,i,o,a,s=AN,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=_N(30),u=1;function h(r){for(var i=0,s=t.length;i<u;++i)for(var l,c,h,d,p,f,g,m=0;m<s;++m)c=(l=t[m]).source,d=(h=l.target).x+h.vx-c.x-c.vx||bN(a),p=h.y+h.vy-c.y-c.vy||bN(a),d*=f=((f=Math.sqrt(d*d+p*p))-n[m])/f*r*e[m],p*=f,h.vx-=d*(g=o[m]),h.vy-=p*g,c.vx+=d*(g=1-g),c.vy+=p*g}function d(){if(r){var a,l,c=r.length,u=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(c);a<u;++a)(l=t[a]).index=a,"object"!=typeof l.source&&(l.source=RN(h,l.source)),"object"!=typeof l.target&&(l.target=RN(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(u);a<u;++a)l=t[a],o[a]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(u),p(),n=new Array(u),f()}}function p(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function f(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+c(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?(u=+t,h):u},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:_N(+t),p(),h):l},h.distance=function(t){return arguments.length?(c="function"==typeof t?t:_N(+t),f(),h):c},h}var CN={value:()=>{}};function PN(){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 wN(r)}function wN(t){this._=t}function NN(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function ON(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=CN,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}wN.prototype=PN.prototype={constructor:wN,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]=ON(i[n],t.name,e);else if(null==e)for(n in i)i[n]=ON(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=NN(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new wN(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 IN,DN,BN=0,kN=0,LN=0,FN=1e3,UN=0,GN=0,VN=0,WN="object"==typeof performance&&performance.now?performance:Date,zN="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function HN(){return GN||(zN(jN),GN=WN.now()+VN)}function jN(){GN=0}function XN(){this._call=this._time=this._next=null}function YN(t,e,n){var r=new XN;return r.restart(t,e,n),r}function KN(){GN=(UN=WN.now())+VN,BN=kN=0;try{!function(){HN(),++BN;for(var t,e=IN;e;)(t=GN-e._time)>=0&&e._call.call(void 0,t),e=e._next;--BN}()}finally{BN=0,function(){var t,e,n=IN,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:IN=e);DN=t,$N(r)}(),GN=0}}function qN(){var t=WN.now(),e=t-UN;e>FN&&(VN-=e,UN=t)}function $N(t){BN||(kN&&(kN=clearTimeout(kN)),t-GN>24?(t<1/0&&(kN=setTimeout(KN,t-WN.now()-VN)),LN&&(LN=clearInterval(LN))):(LN||(UN=WN.now(),LN=setInterval(qN,FN)),BN=1,zN(KN)))}XN.prototype=YN.prototype={constructor:XN,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?HN():+n)+(null==e?0:+e),this._next||DN===this||(DN?DN._next=this:IN=this,DN=this),this._call=t,this._time=n,$N()},stop:function(){this._call&&(this._call=null,this._time=1/0,$N())}};const ZN=1664525,QN=1013904223,JN=4294967296;function tO(t){return t.x}function eO(t){return t.y}var nO=10,rO=Math.PI*(3-Math.sqrt(5));function iO(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=YN(h),c=PN("tick","end"),u=function(){let t=1;return()=>(t=(ZN*t+QN)%JN)/JN}();function h(){d(),c.call("tick",e),n<r&&(l.stop(),c.call("end",e))}function d(r){var l,c,u=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<u;++l)null==(c=t[l]).fx?c.x+=c.vx*=a:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=a:(c.y=c.fy,c.vy=0);return e}function p(){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=nO*Math.sqrt(.5+n),o=n*rO;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function f(e){return e.initialize&&e.initialize(t,u),e}return null==t&&(t=[]),p(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,p(),s.forEach(f),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?(u=t,s.forEach(f),e):u},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,f(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,l,c=0,u=t.length;for(null==r?r=1/0:r*=r,c=0;c<u;++c)(a=(i=e-(s=t[c]).x)*i+(o=n-s.y)*o)<r&&(l=s,r=a);return l},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function oO(){var t,e,n,r,i,o=_N(-30),a=1,s=1/0,l=.81;function c(n){var i,o=t.length,a=Xw(t,tO,eO).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function u(){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,c,u){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,p=u-o,f=h*h+d*d;if(p*p/l<f)return f<s&&(0===h&&(f+=(h=bN(n))*h),0===d&&(f+=(d=bN(n))*d),f<a&&(f=Math.sqrt(a*f)),e.vx+=h*t.value*r/f,e.vy+=d*t.value*r/f),!0;if(!(t.length||f>=s)){(t.data!==e||t.next)&&(0===h&&(f+=(h=bN(n))*h),0===d&&(f+=(d=bN(n))*d),f<a&&(f=Math.sqrt(a*f)));do{t.data!==e&&(p=i[t.data.index]*r/f,e.vx+=h*p,e.vy+=d*p)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,u()},c.strength=function(t){return arguments.length?(o="function"==typeof t?t:_N(+t),u(),c):o},c.distanceMin=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a)},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s)},c.theta=function(t){return arguments.length?(l=t*t,c):Math.sqrt(l)},c}function aO(t){var e,n,r,i=_N(.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=_N(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:_N(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:_N(+e),a(),o):t},o}function sO(t){var e,n,r,i=_N(.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=_N(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:_N(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:_N(+e),a(),o):t},o}function lO(){function t(t){return function(){return t}}var e,n=function(t){return t.cluster},r=t(1),i=t(-1),o=t(100),a=t(.1),s=[0,0],l=[],c={},u=[],h=100,d=100,p={none:{x:0,y:0}},f=[],g="force",m=!0,v=.1;function y(t){if(!m)return y;e.tick(),_();for(var r=0,i=l.length,o=void 0,a=t*v;r<i;++r)(o=l[r]).vx+=(p[n(o)].x-o.x)*a,o.vy+=(p[n(o)].y-o.y)*a}function E(){l&&function(){if(!l||!l.length)return;if(void 0===n(l[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t=(s=[],p=[],g={},m={},v=[],m=function(t){var e={};return t.forEach((function(t){var r=n(t);e[r]||(e[r]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var i=n(t),o=r(t),a=e[i];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=a})),e}(l),v=function(t){var e={},r=[];return t.forEach((function(t){var r=function(t){var e=t.source,r=t.target,i=n(c[e]),o=n(c[r]);return i<=o?i+"~"+o:o+"~"+i}(t),i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i})),Object.entries(e).forEach((function(t){var e=Bc(t,2),n=e[0],i=e[1],o=n.split("~")[0],a=n.split("~")[1];void 0!==o&&void 0!==a&&r.push({source:o,target:a,count:i})})),r}(u),Object.keys(m).forEach((function(t,e){var n=m[t];s.push({id:t,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[t]=e})),v.forEach((function(t){var e=t.source,n=t.target,r=g[e],i=g[n];void 0!==r&&void 0!==i&&p.push({source:r,target:i,count:t.count})})),{nodes:s,links:p});var s,p,g,m,v;e=iO(t.nodes).force("x",aO(h).strength(.1)).force("y",sO(d).strength(.1)).force("collide",TN((function(t){return t.r})).iterations(4)).force("charge",oO().strength(i)).force("links",MN(t.nodes.length?t.links:[]).distance(o).strength(a)),f=e.nodes(),_()}()}function _(){return p={none:{x:0,y:0}},f.forEach((function(t){p[t.id]={x:t.x-s[0],y:t.y-s[1]}})),p}return y.initialize=function(t){l=t,E()},y.template=function(t){return arguments.length?(g=t,E(),y):g},y.groupBy=function(t){return arguments.length?"string"==typeof t?(n=function(e){return e[t]},y):(n=t,y):n},y.enableGrouping=function(t){return arguments.length?(m=t,y):m},y.strength=function(t){return arguments.length?(v=t,y):v},y.centerX=function(t){return arguments.length?(h=t,y):h},y.centerY=function(t){return arguments.length?(d=t,y):d},y.nodes=function(t){return arguments.length?(function(t){c={},t.forEach((function(t){c[t.id]=t}))}(t||[]),l=t||[],y):l},y.links=function(t){return arguments.length?(u=t||[],E(),y):u},y.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),E(),y):r},y.nodeSize=y.forceNodeSize,y.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),E(),y):i},y.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),E(),y):o},y.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),E(),y):a},y.offset=function(t){return arguments.length?(s=t,y):s},y.getFocis=_,y}var cO={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},uO=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=wc(wc({},cO),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var n={nodes:hO(this.lastLayoutNodes),edges:dO(this.lastLayoutEdges)};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n},t.prototype.genericForceLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P=this;return Ic(this,(function(w){return r=wc(wc({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=i.map((function(t){var e,n;return wc(wc({},GP(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(n=t.data)||void 0===n?void 0:n.y})})),s=o.map((function(t){return GP(t)})),this.lastLayoutNodes=a,this.lastLayoutEdges=s,this.lastAssign=t,this.lastGraph=e,l=r.alphaMin,c=r.alphaDecay,u=r.alpha,h=r.nodeStrength,d=r.edgeStrength,p=r.linkDistance,f=r.clustering,g=r.clusterFociStrength,m=r.clusterEdgeDistance,v=r.clusterEdgeStrength,y=r.clusterNodeStrength,E=r.clusterNodeSize,_=r.collideStrength,b=void 0===_?1:_,S=r.center,x=void 0===S?[0,0]:S,T=r.preventOverlap,A=r.nodeSize,R=r.nodeSpacing,M=r.onTick,C=r.forceSimulation,[2,new Promise((function(n){if(C){if(f)(o=lO()).nodes(a),o.links(s);if(C.nodes(a),s){S=MN().id((function(t){return t.id})).links(s);d&&S.strength(d),p&&S.distance(p),C.force("link",S)}T&&P.overlapProcess(C,{nodeSize:A,nodeSpacing:R,collideStrength:b}),C.alpha(u).restart();var r=hO(a),i=dO(s);t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n({nodes:r,edges:i})}else try{var o,_=oO();if(h&&_.strength(h),C=iO().nodes(a),f)(o=lO()).centerX(x[0]).centerY(x[1]).template("force").strength(g),s&&o.links(s),a&&o.nodes(a),o.forceLinkDistance(m).forceLinkStrength(v).forceCharge(y).forceNodeSize(E),C.force("group",o);if(C.force("center",function(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}(x[0],x[1])).force("charge",_).alpha(u).alphaDecay(c).alphaMin(l),T&&P.overlapProcess(C,{nodeSize:A,nodeSpacing:R,collideStrength:b}),s){var S=MN().id((function(t){return t.id})).links(s);d&&S.strength(d),p&&S.distance(p),C.force("link",S)}C.on("tick",(function(){var n=hO(a);null==M||M({nodes:n,edges:dO(s)}),t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var r=hO(a);t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),n({nodes:r,edges:dO(s)})}))}catch(t){console.warn(t)}P.forceSimulation=C}))]}))}))},t.prototype.overlapProcess=function(t,e){var n,r,i=e.nodeSize,o=e.nodeSpacing,a=e.collideStrength;if(r=Ue(o)?function(){return o}:Se(o)?o:function(){return 0},i)if(Se(i))n=function(t){return i(t)+r(t)};else if(PP(i)){var s=(i[0]>i[1]?i[0]:i[1])/2;n=function(t){return s+r(t)}}else if(Ue(i)){var l=i/2;n=function(t){return l+r(t)}}else n=function(){return 10};else n=function(t){return t.size?PP(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+r(t):Me(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+r(t):t.size/2+r(t):10+r(t)};t.force("collisionForce",TN(n).strength(a))},t}(),hO=function(t){return t.map((function(t){var e=t.x,n=t.y,r=Nc(t,["x","y"]);return wc(wc({},r),{data:wc(wc({},r.data),{x:e,y:n})})}))},dO=function(t){return t.map((function(t){var e=t.source,n=t.target,r=Nc(t,["source","target"]);return wc(wc({},r),{source:e.id,target:n.id})}))},pO=function(t,e){if("next"!==t&&"prev"!==t)return e},fO=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},gO=function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return fO(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&fO(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,n=e.prev;n!==e;)t.push(JSON.stringify(n,pO)),n=null==n?void 0:n.prev;return"["+t.join(", ")+"]"},t}(),mO=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e}(gO),vO=function(){return 1},yO=function(t,e,n){for(var r,i=[],o=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;r=a.dequeue();)EO(t,e,n,r);for(;r=o.dequeue();)EO(t,e,n,r);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(EO(t,e,n,r,!0));break}}return i},EO=function(t,e,n,r,i){var o,a,s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach((function(r){var 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,bO(e,n,wc({v:a.id},a.data))})),null===(a=t.getRelatedEdges(r.v,"out"))||void 0===a||a.forEach((function(r){var i=r.data.weight,o=r.target,a=t.getNode(o);void 0===a.data.in&&(a.data.in=0),a.data.in-=i,bO(e,n,wc({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},_O=function(t,e){var n=new TP,r=0,i=0;t.getAllNodes().forEach((function(t){n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var o=n.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),a=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,wc(wc({},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)}));for(var o=[],a=i+r+3,s=0;s<a;s++)o.push(new mO);var l=r+1;return n.getAllNodes().forEach((function(t){bO(o,l,wc({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:l,graph:n}},bO=function(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)},SO=function(t,e){var n="greedy"===e?function(t,e){var n;if(t.getAllNodes().length<=1)return[];var r=_O(t,e||vO);return null===(n=yO(r.graph,r.buckets,r.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===n?void 0:n.flat()}(t,(function(t){return t.data.weight||1})):xO(t);null==n||n.forEach((function(e){var 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:wc({},n)})}))},xO=function(t){var e=[],n={},r={},i=function(o){r[o]||(r[o]=!0,n[o]=!0,t.getRelatedEdges(o,"out").forEach((function(t){n[t.target]?e.push(t):i(t.target)})),delete n[o])};return t.getAllNodes().forEach((function(t){return i(t.id)})),e},TO=function(t,e,n,r){var i;do{i=""+r+Math.random()}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},AO=function(t){var e=new TP;return t.getAllNodes().forEach((function(n){t.getChildren(n.id).length||e.addNode(wc({},n))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},RO=function(t,e){var n,r,i=Number(t.x),o=Number(t.y),a=Number(e.x)-i,s=Number(e.y)-o,l=Number(t.width)/2,c=Number(t.height)/2;return a||s?(Math.abs(s)*l>Math.abs(a)*c?(s<0&&(c=-c),n=c*a/s,r=c):(a<0&&(l=-l),n=l,r=l*s/a),{x:i+n,y:o+r}):{x:0,y:0}},MO=function(t){for(var e=[],n=PO(t)+1,r=0;r<n;r++)e.push([]);t.getAllNodes().forEach((function(t){var n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(r=0;r<n;r++)e[r]=e[r].sort((function(e,n){return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},CO=function(t,e,n,r){var i={width:0,height:0};return Ue(n)&&Ue(r)&&(i.rank=n,i.order=r),TO(t,"border",i,e)},PO=function(t){var e;return t.getAllNodes().forEach((function(t){var n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)})),e||(e=0),e},wO=function(t,e){return t.reduce((function(t,n){return e(t)>e(n)?n:t}))},NO=function(t,e,n,r,i,o){r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((function(e){return NO(t,e,n,r,i,o)})),n&&o.push(e.id))},OO=function(t,e,n,r){var i=Array.isArray(e)?e:[e],o=function(e){return r?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return i.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);NO(t,e,"post"===n,s,o,a)})),a},IO="edge-label",DO=function(t,e,n){var r=e.source,i=t.getNode(r).data.rank,o=e.target,a=t.getNode(o).data.rank,s=e.data.labelRank;if(a!==i+1){var l,c,u;for(t.removeEdge(e.id),u=0,++i;i<a;++u,++i)e.data.points=[],l=TO(t,"edge",c={originalEdge:e,width:0,height:0,rank:i},"_d"),i===s&&(c.width=e.data.width,c.height=e.data.height,c.dummy=IO,c.labelpos=e.data.labelpos),t.addEdge({id:"e"+Math.random(),source:r,target:l,data:{weight:e.data.weight}}),0===u&&n.push(l),r=l;t.addEdge({id:"e"+Math.random(),source:r,target:o,data:{weight:e.data.weight}})}},BO=function(t){var e={},n=function(r){var i,o,a=t.getNode(r);return a?e[r]?a.data.rank:(e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===o||e<o)&&(o=e)})),o||(o=0),a.data.rank=o,o):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return n(t.id)}))},kO=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},LO=function(t,e){var n=function(r){e.getRelatedEdges(r,"both").forEach((function(i){var o=i.source,a=r===o?i.target:o;t.hasNode(a)||kO(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((function(t){return n(t.id)})),t.getAllNodes().length},FO=function(t,e){var n=function(r){var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach((function(i){var o=i.source,a=r===o?i.target:o;t.hasNode(a)||void 0===e.getNode(a).data.layer&&kO(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((function(t){return n(t.id)})),t.getAllNodes().length},UO=function(t,e){return wO(e.getAllEdges(),(function(n){return t.hasNode(n.source)!==t.hasNode(n.target)?kO(e,n):1/0}))},GO=function(t,e,n){t.getAllNodes().forEach((function(t){var r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},VO=function(t){var e=function(t){var e=new TP;return t.getAllNodes().forEach((function(t){e.addNode(wc({},t))})),t.getAllEdges().forEach((function(t){var n=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));n?e.updateEdgeData(null==n?void 0:n.id,wc(wc({},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);BO(e);var n,r,i=function(t){var e,n,r=new TP({tree:[]}),i=t.getAllNodes()[0],o=t.getAllNodes().length;for(r.addNode(i);LO(r,t)<o;)e=UO(r,t),n=r.hasNode(e.source)?kO(t,e):-kO(t,e),GO(r,t,n);return r}(e);for(jO(i),WO(i,e);n=YO(i);)r=KO(i,e,n),qO(i,e,n,r)},WO=function(t,e){var n=OO(t,t.getAllNodes(),"post",!1);(n=n.slice(0,(null==n?void 0:n.length)-1)).forEach((function(n){zO(t,e,n)}))},zO=function(t,e,n){var r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((function(t){return t.target===r||t.source===r})).data.cutvalue=HO(t,e,n)},HO=function(t,e,n){var r=t.getNode(n).data.parent,i=!0,o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),a=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n}))),a=o.data.weight,e.getRelatedEdges(n,"both").forEach((function(e){var o=e.source===n,s=o?e.target:e.source;if(s!==r){var l=o===i,c=e.data.weight;if(a+=l?c:-c,ZO(t,n,s)){var u=t.getRelatedEdges(n,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=l?-u:u}}})),a},jO=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),XO(t,{},1,e)},XO=function(t,e,n,r,i){var o,a=n,s=n,l=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((function(n){e[n.id]||(s=XO(t,e,s,n.id,r))})),l.data.low=a,l.data.lim=s++,i?l.data.parent=i:delete l.data.parent,s},YO=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},KO=function(t,e,n){var r=n.source,i=n.target;e.getRelatedEdges(r,"out").find((function(t){return t.target===i}))||(r=n.target,i=n.source);var o=t.getNode(r),a=t.getNode(i),s=o,l=!1;o.data.lim>a.data.lim&&(s=a,l=!0);var c=e.getAllEdges().filter((function(e){return l===QO(t.getNode(e.source),s)&&l!==QO(t.getNode(e.target),s)}));return wO(c,(function(t){return kO(e,t)}))},qO=function(t,e,n,r){var i=t.getRelatedEdges(n.source,"both").find((function(t){return 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:{}}),jO(t),WO(t,e),$O(t,e)},$O=function(t,e){var n=t.getAllNodes().find((function(t){return!t.data.parent})),r=OO(t,n,"pre",!1);(r=r.slice(1)).forEach((function(n){var r=t.getNode(n).data.parent,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find((function(t){return 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))}))},ZO=function(t,e,n){return t.getRelatedEdges(e,"both").find((function(t){return t.source===n||t.target===n}))},QO=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},JO=BO,tI=function(t){!function(t){var e,n={},r=function(i){var o,a,s=t.getNode(i);return s?n[i]?s.data.rank:(n[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&r(t.id)})),void 0===e&&(e=0);var i={},o=function(e,n){var r,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((function(t){o(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var n=t.data;n&&(isNaN(n.layer)?n.rank-=e:o(t.id,n.layer))}))}(t),function(t){var e,n,r=new TP({tree:[]}),i=t.getAllNodes()[0],o=t.getAllNodes().length;for(r.addNode(i);FO(r,t)<o;)e=UO(r,t),n=r.hasNode(e.source)?kO(t,e):-kO(t,e),GO(r,t,n)}(t)},eI=function(t){VO(t)},nI=function(t,e){var n=function(t){var e={},n=0,r=function(i){var o=n;t.getChildren(i).forEach((function(t){return r(t.id)})),e[i]={low:o,lim:n++}};return t.getRoots().forEach((function(t){return r(t.id)})),e}(t);e.forEach((function(e){var r,i,o=e,a=t.getNode(o),s=a.data.originalEdge;if(s)for(var l=function(t,e,n,r){var i,o,a,s,l=[],c=[],u=Math.min(e[n].low,e[r].low),h=Math.max(e[n].lim,e[r].lim);a=n;do{a=null===(i=t.getParent(a))||void 0===i?void 0:i.id,l.push(a)}while(a&&(e[a].low>u||h>e[a].lim));for(s=a,a=r;a&&a!==s;)c.push(a),a=null===(o=t.getParent(a))||void 0===o?void 0:o.id;return{lca:s,path:l.concat(c.reverse())}}(t,n,s.source,s.target),c=l.path,u=l.lca,h=0,d=c[h],p=!0;o!==s.target;){if(a=t.getNode(o),p){for(;d!==u&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)d=c[++h];d===u&&(p=!1)}if(!p){for(;h<c.length-1&&(null===(i=t.getNode(c[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=c[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},rI=function(t,e,n,r,i,o,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var l=CO(t,"_bt"),c=CO(t,"_bb"),u=t.getNode(a);t.setParent(l,a),u.data.borderTop=l,t.setParent(c,a),u.data.borderBottom=c,null==s||s.forEach((function(s){rI(t,e,n,r,i,o,s.id);var u=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,p=u!==h?1:i-o[a]+1;t.addEdge({id:"e"+Math.random(),source:l,target:u,data:{minlen:p,weight:d,nestingEdge:!0}}),t.addEdge({id:"e"+Math.random(),source:h,target:c,data:{minlen:p,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e"+Math.random(),source:e,target:l,data:{weight:0,minlen:i+o[a]}})}else a!==e&&t.addEdge({id:"e"+Math.random(),source:e,target:a,data:{weight:0,minlen:n}})},iI=function(t){var e={},n=function(r,i){var o=t.getChildren(r);null==o||o.forEach((function(t){return n(t.id,i+1)})),e[r]=i};return t.getRoots().forEach((function(t){return n(t.id,1)})),e},oI=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e},aI=function(t,e,n,r,i,o){var a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],l=TO(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}})},sI=function(t){t.getAllNodes().forEach((function(t){lI(t)})),t.getAllEdges().forEach((function(t){lI(t)}))},lI=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},cI=function(t){t.getAllNodes().forEach((function(t){uI(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return uI(t)})),t.data.hasOwnProperty("y")&&uI(t.data)}))},uI=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},hI=function(t){t.getAllNodes().forEach((function(t){dI(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return dI(t)})),t.data.hasOwnProperty("x")&&dI(t.data)}))},dI=function(t){var e=t.x;t.x=t.y,t.y=e},pI=function(t){for(var e={},n=t.getAllNodes(),r=n.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),i=Math.max.apply(Math,kc([],Bc(r))),o=[],a=0;a<i+1;a++)o.push([]);var s=n.sort((function(e,n){return t.getNode(e.id).data.rank-t.getNode(n.id).data.rank})),l=s.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,n){return t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder}));return null==l||l.forEach((function(n){isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0})),null==s||s.forEach((function(n){return t.dfsTree(n.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)}))})),o},fI=function(t,e,n){for(var r=function(t,e){return null==t?void 0:t.reduce((function(t,n,r){return t[n]=e[r],t}),{})}(n,n.map((function(t,e){return e}))),i=e.map((function(e){var n=t.getRelatedEdges(e,"out").map((function(t){return{pos:r[t.target]||0,weight:t.data.weight}}));return null==n?void 0:n.sort((function(t,e){return t.pos-e.pos}))})),o=i.flat().filter((function(t){return void 0!==t})),a=1;a<n.length;)a<<=1;var s=2*a-1;a-=1;var l=Array(s).fill(0,0,s),c=0;return null==o||o.forEach((function(t){if(t){var e=t.pos+a;l[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=l[e+1]),l[e=e-1>>1]+=t.weight;c+=t.weight*n}})),c},gI=function(t,e){for(var n=0,r=1;r<(null==e?void 0:e.length);r+=1)n+=fI(t,e[r-1],e[r]);return n},mI=function(t){for(var e;t.hasNode(e="_root"+Math.random()););return e},vI=function(t){for(var e,n,r=[],i=function(){var i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach((function(t){return(e=i,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&yI(e,t)})(t);var e})),null===(n=i.out)||void 0===n||n.forEach((function(e){return(n=i,function(e){e.in.push(n),0==--e.indegree&&t.push(e)})(e);var n}))};null==t?void 0:t.length;)i();var o=r.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return o.map((function(t){var e={};return null==a||a.forEach((function(n){void 0!==t[n]&&(e[n]=t[n])})),e}))},yI=function(t,e){var n,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},EI=function(t,e){var n,r,i,o={};null==t||t.forEach((function(t,e){o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var 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((function(t){var e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))}));var a=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,(function(t){return!t.indegree}));return vI(a)},_I=function(t,e,n){for(var r,i=n;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},bI=function(t,e){return function(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}},SI=function(t,e,n,r,i,o){var a,s,l,c,u=t.getChildren(e).map((function(t){return t.id})),h=t.getNode(e),d=h?h.data.borderLeft:void 0,p=h?h.data.borderRight:void 0,f={};d&&(u=null==u?void 0:u.filter((function(t){return t!==d&&t!==p})));var g=function(t,e){return e.map((function(e){var n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};var r={sum:0,weight:0};return null==n||n.forEach((function(e){var 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,u||[]);null==g||g.forEach((function(e){var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){var a=SI(t,e.v,n,r,o);f[e.v]=a,a.hasOwnProperty("barycenter")&&TI(e,a)}}));var m=EI(g,n);xI(m,f),null===(a=m.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)}));var v=function(t,e,n,r){var i=function(t,e){var n={lhs:[],rhs:[]};return null==t||t.forEach((function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n}(t,(function(t){var e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),o=i.lhs,a=i.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],l=0,c=0,u=0;null==o||o.sort(bI(!!e,!!n)),u=_I(s,a,u),null==o||o.forEach((function(t){var e;u+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),l+=t.barycenter*t.weight,c+=t.weight,u=_I(s,a,u)}));var h={vs:s.flat()};return c&&(h.barycenter=l/c,h.weight=c),h}(m,r,i,o);if(d&&(v.vs=[d,v.vs,p].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){var y=t.getNode((null===(l=t.getPredecessors(d))||void 0===l?void 0:l[0].id)||""),E=t.getNode((null===(c=t.getPredecessors(p))||void 0===c?void 0:c[0].id)||"");v.hasOwnProperty("barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+y.data.order+E.data.order)/(v.weight+2),v.weight+=2}return v},xI=function(t,e){null==t||t.forEach((function(t){var n,r=null===(n=t.vs)||void 0===n?void 0:n.map((function(t){return e[t]?e[t].vs:t}));t.vs=r.flat()}))},TI=function(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)},AI=function(t,e,n){return e.map((function(e){return function(t,e,n){var r=mI(t),i=new TP({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((function(o){var a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(wc({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(wc({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach((function(e){var n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(wc({},t.getNode(n)));var r=i.getRelatedEdges(n,"out").find((function(t){return t.target===o.id})),a=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,wc(wc({},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,wc(wc({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i}(t,e,n)}))},RI=function(t,e,n,r){var i=new TP;null==t||t.forEach((function(t){for(var o,a=t.getRoots()[0].id,s=SI(t,a,i,e,n,r),l=0;l<(null===(o=s.vs)||void 0===o?void 0:o.length);l++){var c=t.getNode(s.vs[l]);c&&(c.data.order=l)}!function(t,e,n){var r,i={};null==n||n.forEach((function(n){for(var o,a,s=t.getParent(n);s;){if((o=t.getParent(s.id))?(a=i[o.id],i[o.id]=s.id):(a=r,r=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)}))},MI=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,n){t.getNode(e).data.order=n}))}))},CI=function(t,e){var n={};function r(e,r,i,o,a){for(var s,l,c,u=r;u<i;u++)c=e[u],(null===(s=t.getNode(c))||void 0===s?void 0:s.data.dummy)&&(null===(l=t.getPredecessors(c))||void 0===l||l.forEach((function(e){var r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&wI(n,e.id,c)})))}function i(t,e){var n=function(t){return JSON.stringify(t.slice(1))}(t);e.get(n)||(r.apply(void 0,kc([],Bc(t))),e.set(n,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,n){var r,o=-1,a=0,s=new Map;return null==n||n.forEach((function(l,c){var u;if("border"===(null===(u=t.getNode(l))||void 0===u?void 0:u.data.dummy)){var h=t.getPredecessors(l)||[];h.length&&(r=t.getNode(h[0].id).data.order,i([n,a,c,o,r],s),a=c,o=r)}i([n,a,n.length,r,e.length],s)})),n})),n},PI=function(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((function(e){return t.getNode(e.id).data.dummy}))},wI=function(t,e,n){var r=e,i=n;if(r>i){var o=r;r=i,i=o}var a=t[r];a||(t[r]=a={}),a[i]=!0},NI=function(t,e,n){var r=e;r>n&&(r=n);return!!t[r]},OI=function(t,e,n,r,i,o){var a=new TP,s=II(r,i,o);return null==e||e.forEach((function(e){var r;null==e||e.forEach((function(e){var i=n[e];if(a.hasNode(i)||a.addNode({id:i,data:{}}),r){var o=n[r],l=a.getRelatedEdges(o,"out").find((function(t){return t.target===i}));l?a.updateEdgeData(l.id,wc(wc({},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};var II=function(t,e,n){return function(r,i,o){var a=r.getNode(i),s=r.getNode(o),l=0,c=0;if(l+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":c=-a.data.width/2;break;case"r":c=a.data.width/2}if(c&&(l+=n?c:-c),c=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":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(l+=n?c:-c),c=0,l}},DI=function(t,e){return t.getNode(e).data.width||0},BI=function(t,e){var n=e||{},r=n.align,i=n.nodesep,o=void 0===i?0:i,a=n.edgesep,s=void 0===a?0:a,l=MO(t),c=Object.assign(function(t,e){var n={};return(null==e?void 0:e.length)&&e.reduce((function(e,r){var i=0,o=0,a=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach((function(e,l){var c,u=PI(t,e),h=u?t.getNode(u.id).data.order:a;(u||e===s)&&(null===(c=r.slice(o,l+1))||void 0===c||c.forEach((function(e){var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach((function(r){var o,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)||wI(n,r.id,e)}))})),o=l+1,i=h)})),r})),n}(t,l),CI(t,l)),u={},h=[];["u","d"].forEach((function(e){h="u"===e?l:Object.values(l).reverse(),["l","r"].forEach((function(n){"r"===n&&(h=h.map((function(t){return Object.values(t).reverse()})));var r=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),i=function(t,e,n,r){var i={},o={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=r(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var l=(s.length-1)/2,c=Math.floor(l),u=Math.ceil(l);c<=u;++c){var h=s[c];o[t]===t&&e<a[h]&&!NI(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}(0,h,c,r),a=function(t,e,n,r,i,o,a){var s,l={},c=OI(t,e,n,i,o,a),u=a?"borderLeft":"borderRight",h=function(t,e){for(var n=c.getAllNodes(),r=n.pop(),i={};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((function(t){l[t]=(c.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(l[e.source]||0)+e.data.weight)}),0)}),c.getPredecessors.bind(c)),h((function(e){var n=(c.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(l[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==u&&(l[e]=Math.max(l[e],n))}),c.getSuccessors.bind(c)),null===(s=Object.values(r))||void 0===s||s.forEach((function(t){l[t]=l[n[t]]})),l}(t,h,i.root,i.align,o,s,"r"===n);"r"===n&&Object.keys(a).forEach((function(t){return a[t]=-a[t]})),u[e+n]=a}))}));var d=function(t,e){return wO(Object.values(e),(function(e){var n,r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach((function(n){var o=e[n],a=DI(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i}))}(t,u);return d&&function(t,e){var n=Object.values(e),r=Math.min.apply(Math,kc([],Bc(n))),i=Math.max.apply(Math,kc([],Bc(n)));["u","d"].forEach((function(n){["l","r"].forEach((function(o){var a,s=n+o,l=t[s];if(l!==e){var c=Object.values(l);(a="l"===o?r-Math.min.apply(Math,kc([],Bc(c))):i-Math.max.apply(Math,kc([],Bc(c))))&&(t[s]={},Object.keys(l).forEach((function(e){t[s][e]=l[e]+a})))}}))}))}(u,d),function(t,e){var n={};return Object.keys(t.ul).forEach((function(r){if(e)n[r]=t[e.toLowerCase()][r];else{var i=Object.values(t).map((function(t){return t[r]}));n[r]=(i[0]+i[1])/2}})),n}(u,r)},kI=function(t,e){var n,r=AO(t);!function(t,e){var n=(e||{}).ranksep,r=void 0===n?0:n,i=MO(t),o=0;null==i||i.forEach((function(e){var n=e.map((function(e){return t.getNode(e).data.height})),i=Math.max.apply(Math,kc(kc([],Bc(n)),[0]));null==e||e.forEach((function(e){t.getNode(e).data.y=o+i/2})),o+=i+r}))}(r,e);var i=BI(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((function(t){r.getNode(t).data.x=i[t]}))},LI=function(t,e){var n=e.acyclicer,r=e.ranker,i=e.rankdir,o=void 0===i?"tb":i,a=e.nodeOrder,s=e.keepNodeOrder,l=e.align,c=e.nodesep,u=void 0===c?50:c,h=e.edgesep,d=void 0===h?20:h,p=e.ranksep,f=void 0===p?50:p;eD(t),SO(t,n);var g=function(t){var e=TO(t,"root",{},"_root"),n=iI(t),r=Math.max.apply(Math,kc([],Bc(Object.values(n))));Math.abs(r)===1/0&&(r=1);var i=r-1,o=2*i+1;t.getAllEdges().forEach((function(t){t.data.minlen*=o}));var a=oI(t)+1;return t.getRoots().forEach((function(r){rI(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}}(t),m=g.nestingRoot,v=g.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":eI(t);break;case"tight-tree":default:tI(t);break;case"longest-path":JO(t)}}(AO(t),r),YI(t),function(t,e){void 0===e&&(e=0);var n=t.getAllNodes(),r=n.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),i=Math.min.apply(Math,kc([],Bc(r))),o=[];n.forEach((function(t){var e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)}));for(var a=0,s=0;s<o.length;s++){var l=o[s];void 0===l?s%e!=0&&(a-=1):a&&(null==l||l.forEach((function(e){var n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}}(t,v),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,m),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),n=Math.min.apply(Math,kc([],Bc(e)));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)}))}(t),KI(t),qI(t);var y=[];!function(t,e){t.getAllEdges().forEach((function(n){return DO(t,n,e)}))}(t,y),nI(t,y),function(t){var e=function(n){var r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach((function(t){return e(t.id)})),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(var o=i.data.minRank,a=i.data.maxRank+1;o<a;o+=1)aI(t,"borderLeft","_bl",n,i,o),aI(t,"borderRight","_br",n,i,o)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),s&&function(t,e){for(var n=t.getAllNodes().filter((function(e){var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)})),r=n.map((function(t){return t.data.rank})),i=Math.max.apply(Math,kc([],Bc(r))),o=[],a=0;a<i+1;a++)o[a]=[];null==e||e.forEach((function(e){var n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))}))}(t,a),function(t,e){for(var n=PO(t),r=[],i=[],o=1;o<n+1;o++)r.push(o);for(o=n-1;o>-1;o--)i.push(o);var a=AI(t,r,"in"),s=AI(t,i,"out"),l=pI(t);MI(t,l);for(var c,u=Number.POSITIVE_INFINITY,h=(o=0,0);h<4;++o,++h)RI(o%2?a:s,o%4>=2,!1,e),l=MO(t),(d=gI(t,l))<u&&(h=0,c=tn(l),u=d);for(l=pI(t),MI(t,l),o=0,h=0;h<4;++o,++h){var d;RI(o%2?a:s,o%4>=2,!0,e),l=MO(t),(d=gI(t,l))<u&&(h=0,c=tn(l),u=d)}MI(t,c)}(t,s),nD(t),function(t,e){var n=e.toLowerCase();"lr"!==n&&"rl"!==n||sI(t)}(t,o),kI(t,{align:l,nodesep:u,edgesep:d,ranksep:f}),rD(t),tD(t),function(t,e){e.forEach((function(e){var n,r=t.getNode(e),i=r.data.originalEdge;i&&t.addEdge(i);for(var o=e;r.data.dummy;)n=t.getSuccessors(o)[0],t.removeNode(o),i.data.points.push({x:r.data.x,y:r.data.y}),r.data.dummy===IO&&(i.data.x=r.data.x,i.data.y=r.data.y,i.data.width=r.data.width,i.data.height=r.data.height),o=n.id,r=t.getNode(o)}))}(t,y),QI(t),function(t,e){var n=e.toLowerCase();"bt"!==n&&"rl"!==n||cI(t),"lr"!==n&&"rl"!==n||(hI(t),sI(t))}(t,o);var E=$I(t),_=E.width,b=E.height;return ZI(t),JI(t),function(t){t.getAllEdges().forEach((function(e){var n=e.data;if(n.reversed){t.removeEdge(e.id);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:wc(wc({},n),{forwardName:r})})}}))}(t),{width:_,height:b}},FI=function(t,e){t.getAllNodes().forEach((function(n){var r=t.getNode(n.id),i=e.getNode(n.id);void 0!==i?(r.data.fixorder=i.data._order,delete i.data._order):delete r.data.fixorder}))},UI=function(t,e){t.getAllNodes().forEach((function(n){var r,i=t.getNode(n.id);if(i){var o=e.getNode(n.id);i.data.x=o.data.x,i.data.y=o.data.y,i.data._order=o.data.order,i.data._rank=o.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=o.data.width,i.data.height=o.data.height)}})),t.getAllEdges().forEach((function(n){var 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)}))},GI=["width","height","layer","fixorder"],VI={width:0,height:0},WI=["minlen","weight","width","height","labeloffset"],zI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},HI=["labelpos"],jI=function(t){var e=new TP({tree:[]});return t.getAllNodes().forEach((function(n){var r=oD(t.getNode(n.id).data),i=wc(wc({},VI),r),o=iD(i,GI);e.hasNode(n.id)||e.addNode({id:n.id,data:wc({},o)});var a=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);xe(a)||(e.hasNode(a.id)||e.addNode(wc({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((function(n){var r=oD(t.getEdge(n.id).data),i={};null==HI||HI.forEach((function(t){void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},zI,iD(r,WI),i)})})),e},XI=function(t,e){var n=e.ranksep,r=void 0===n?0:n,i=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===i||"BT"===i?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),r/2},YI=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};TO(t,"edge-proxy",r,"_ep")}}))},KI=function(t){var e=0;return t.getAllNodes().forEach((function(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},qI=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},$I=function(t,e){var n,r,i=0,o=0,a=e||{},s=a.marginx,l=void 0===s?0:s,c=a.marginy,u=void 0===c?0:c,h=function(t){if(t.data){var 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((function(t){h(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&h(t)})),n-=l,r-=u,t.getAllNodes().forEach((function(t){t.data.x-=n,t.data.y-=r})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(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+l,height:o-r+u}},ZI=function(t){t.getAllEdges().forEach((function(e){var n,r,i=t.getNode(e.source),o=t.getNode(e.target);e.data.points?(n=e.data.points[0],r=e.data.points[e.data.points.length-1]):(e.data.points=[],n={x:o.data.x,y:o.data.y},r={x:i.data.x,y:i.data.y}),e.data.points.unshift(RO(i.data,n)),e.data.points.push(RO(o.data,r))}))},QI=function(t){t.getAllEdges().forEach((function(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}}))},JI=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},tD=function(t){t.getAllNodes().forEach((function(e){var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){var o=t.getNode(e.id),a=t.getNode(o.data.borderTop),s=t.getNode(o.data.borderBottom),l=t.getNode(o.data.borderLeft[(null===(r=o.data.borderLeft)||void 0===r?void 0:r.length)-1]),c=t.getNode(o.data.borderRight[(null===(i=o.data.borderRight)||void 0===i?void 0:i.length)-1]);o.data.width=Math.abs((null==c?void 0:c.data.x)-(null==l?void 0:l.data.x))||10,o.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,o.data.x=((null==l?void 0:l.data.x)||0)+o.data.width/2,o.data.y=((null==a?void 0:a.data.y)||0)+o.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},eD=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}}))},nD=function(t){var e=MO(t);null==e||e.forEach((function(e){var n=0;null==e||e.forEach((function(e,r){var i,o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach((function(e){TO(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},rD=function(t){t.getAllNodes().forEach((function(e){var n=t.getNode(e.id);if("selfedge"===n.data.dummy){var 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}}))},iD=function(t,e){var n={};return null==e||e.forEach((function(e){void 0!==t[e]&&(n[e]=+t[e])})),n},oD=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(n){e[n.toLowerCase()]=t[n]})),e},aD={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,controlPoints:!1,radial:!1,focusNode:null},sD=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.options=wc(wc({},aD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){switch(n.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P,w,N,O,I,D,B,k;return Ic(this,(function(L){return r=wc(wc({},this.options),n),i=r.nodeSize,o=r.align,a=r.rankdir,s=void 0===a?"TB":a,l=r.ranksep,c=r.nodesep,u=r.ranksepFunc,h=r.nodesepFunc,d=r.edgeLabelSpace,p=r.nodeOrder,f=r.begin,g=r.controlPoints,m=r.radial,v=r.sortByCombo,y=new TP({tree:[]}),E=VP(l||50,u),_=VP(c||50,h),b=_,S=E,"LR"!==s&&"RL"!==s||(b=E,S=_),x=zP(i,void 0),T=e.getAllNodes(),A=e.getAllEdges(),T.forEach((function(t){var e=x(t),n=S(t),r=e+2*b(t),i=e+2*n,o=t.data.layer;Ue(o)?y.addNode({id:t.id,data:{width:r,height:i,layer:o}}):y.addNode({id:t.id,data:{width:r,height:i}})})),v&&(y.attachTreeStructure("combo"),T.forEach((function(t){var e=t.data.parentId;void 0!==e&&y.hasNode(e)&&y.setParent(t.id,e,"combo")}))),A.forEach((function(t){y.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),function(t,e){var n=e.edgeLabelSpace,r=e.keepNodeOrder,i=e.prevGraph,o=e.rankdir,a=e.ranksep;!r&&i&&FI(t,i);var s,l=jI(t);n&&(e.ranksep=XI(l,{rankdir:o,ranksep:a}));try{s=LI(l,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}UI(t,l)}(y,{prevGraph:null,edgeLabelSpace:d,keepNodeOrder:!!p,nodeOrder:p||[],acyclicer:"greedy",ranker:"network-simplex",rankdir:s,nodesep:c,align:o}),R=[0,0],f&&(M=1/0,C=1/0,y.getAllNodes().forEach((function(t){M>t.data.x&&(M=t.data.x),C>t.data.y&&(C=t.data.y)})),y.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){M>t.x&&(M=t.x),C>t.y&&(C=t.y)}))})),R[0]=f[0]-M,R[1]=f[1]-C),P="LR"===s||"RL"===s,m||(w=new Set,N="BT"===s||"RL"===s?function(t,e){return e-t}:function(t,e){return t-e},y.getAllNodes().forEach((function(t){t.data.x=t.data.x+R[0],t.data.y=t.data.y+R[1],w.add(P?t.data.x:t.data.y)})),O=Array.from(w).sort(N),I=P?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},D=P?function(t,e,n){var r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter((function(t){return t.y<=r&&t.y>=i}))}:function(t,e,n){var r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter((function(t){return t.x<=r&&t.x>=i}))},y.getAllEdges().forEach((function(t,e){var n;d&&g&&"loop"!==t.data.type&&(t.data.controlPoints=lD(null===(n=t.data.points)||void 0===n?void 0:n.map((function(t){var e=t.x,n=t.y;return{x:e+R[0],y:n+R[1]}})),y.getNode(t.source),y.getNode(t.target),O,P,I,D))}))),B=[],B=y.getAllNodes().map((function(t){return GP(t)})),k=y.getAllEdges(),t&&(B.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),k.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:B,edges:k}]}))}))},t}(),lD=function(t,e,n,r,i,o,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){var l=e.data,c=l.x,u=l.y,h=n.data,d=h.x,p=h.y;if(i&&(c=e.data.y,u=e.data.x,d=n.data.y,p=n.data.x),p!==u&&c!==d){var f=r.indexOf(u),g=r[f+1];if(g){var m=s[0],v=i?{x:(u+g)/2,y:(null==m?void 0:m.y)||d}:{x:(null==m?void 0:m.x)||d,y:(u+g)/2};m&&!o(m,v)||s.unshift(v)}var y=r.indexOf(p),E=Math.abs(y-f);if(1===E)(s=a(s,e.data,n.data)).length||s.push(i?{x:(u+p)/2,y:c}:{x:c,y:(u+p)/2});else if(E>1){var _=r[y-1];if(_){var b=s[s.length-1],S=i?{x:(p+_)/2,y:(null==b?void 0:b.y)||d}:{x:(null==b?void 0:b.x)||c,y:(p+_)/2};b&&!o(b,S)||s.push(S)}}}}return s},cD=function(){function t(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}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,n=t.ry-this.ry,r=Math.hypot(e,n);r=r<1e-4?1e-4:r;var i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var n=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/n,ry:(this.ry*this.mass+e.ry*e.mass)/n,mass:n,degree:this.degree+e.degree})},t}(),uD=cD,hD=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),dD=hD,pD=function(){function t(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)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(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))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(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)))},t}(),fD=pD,gD={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},mD=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=wc(wc({},gD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T;return Ic(this,(function(A){if(r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),a=o.width,s=o.height,l=o.prune,c=o.maxIteration,u=o.nodeSize,h=o.center,!(null==i?void 0:i.length)||1===i.length)return[2,HP(e,t,h)];if(d=i.map((function(t){return GP(t,[a,s])})),p=r.filter((function(t){return t.source!==t.target})),f=new TP({nodes:d,edges:p}),g=this.getSizes(f,e,u),this.run(f,e,c,g,t,o),l){for(m=0;m<p.length;m+=1)v=p[m],y=v.source,E=v.target,_=f.getDegree(y),b=f.getDegree(y),_<=1?(S=f.getNode(E),f.mergeNodeData(y,{x:S.data.x,y:S.data.y})):b<=1&&(x=f.getNode(y),f.mergeNodeData(E,{x:x.data.x,y:x.data.y}));T=wc(wc({},o),{prune:!1,barnesHut:!1}),this.run(f,e,100,g,t,T)}return[2,{nodes:d,edges:r}]}))}))},t.prototype.getSizes=function(t,e,n){for(var r=t.getAllNodes(),i={},o=0;o<r.length;o+=1){var a=r[o],s=a.id,l=a.data;if(i[s]=10,Ue(l.size))i[s]=l.size;else if(PP(l.size))isNaN(l.size[0])||(i[s]=Math.max(l.size[0])),isNaN(l.size[1])||(i[s]=Math.max(l.size[1]));else if(Me(l.size))i[s]=Math.max(l.size.width,l.size.height);else if(Se(n)){var c=n(e.getNode(s));PP(c)?i[s]=Math.max.apply(Math,kc([],Bc(c))):i[s]=c}else PP(n)?i[s]=Math.max.apply(Math,kc([],Bc(n))):Ue(n)&&(i[s]=n)}return i},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var n=wc(wc({},this.options),t),r=n.center,i=n.width,o=n.height,a=n.barnesHut,s=n.prune,l=n.maxIteration,c=n.kr,u=n.kg;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)),c||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),u||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n},t.prototype.run=function(t,e,n,r,i,o){for(var a=o.kr,s=o.barnesHut,l=o.onTick,c=t.getAllNodes(),u=0,h=n,d={},p={},f={},g=0;g<c.length;g+=1){var m=c[g],v=m.data,y=m.id;if(d[y]=[0,0],s){var E={id:g,rx:v.x,ry:v.y,mass:1,g:a,degree:t.getDegree(y)};f[y]=new uD(E)}}for(;h>0;)u=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:u,forces:d,preForces:p,bodies:f,sizes:r},o),h--,null==l||l({nodes:c,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,n){for(var r=e.iter,i=e.preventOverlapIters,o=e.krPrime,a=e.sg,s=e.preForces,l=e.bodies,c=e.sizes,u=e.forces,h=n.preventOverlap,d=n.barnesHut,p=t.getAllNodes(),f=0;f<p.length;f+=1){var g=p[f].id;s[g]=kc([],Bc(u[g])),u[g]=[0,0]}return u=this.getAttrForces(t,r,i,c,u,n),u=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,u,l,n):this.getRepGraForces(t,r,i,u,o,c,n),this.updatePos(t,u,s,a,n)},t.prototype.getAttrForces=function(t,e,n,r,i,o){for(var a=o.preventOverlap,s=o.dissuadeHubs,l=o.mode,c=o.prune,u=t.getAllEdges(),h=0;h<u.length;h+=1){var d=u[h],p=d.source,f=d.target,g=t.getNode(p),m=t.getNode(f),v=t.getDegree(p),y=t.getDegree(f);if(!c||!(v<=1||y<=1)){var E=[m.data.x-g.data.x,m.data.y-g.data.y],_=Math.hypot(E[0],E[1]);_=_<1e-4?1e-4:_,E[0]=E[0]/_,E[1]=E[1]/_,a&&e<n&&(_=_-r[p]-r[f]);var b=_,S=b;"linlog"===l&&(S=b=Math.log(1+_)),s&&(b=_/v,S=_/y),a&&e<n&&_<=0?(b=0,S=0):a&&e<n&&_>0&&(b=_,S=_),i[p][0]+=b*E[0],i[f][0]-=S*E[0],i[p][1]+=b*E[1],i[f][1]-=S*E[1]}}return i},t.prototype.getOptRepGraForces=function(t,e,n,r){for(var i=r.kg,o=r.center,a=r.prune,s=t.getAllNodes(),l=s.length,c=9e10,u=-9e10,h=9e10,d=-9e10,p=0;p<l;p+=1){var f=s[p],g=f.id,m=f.data;a&&t.getDegree(g)<=1||(n[g].setPos(m.x,m.y),m.x>=u&&(u=m.x),m.x<=c&&(c=m.x),m.y>=d&&(d=m.y),m.y<=h&&(h=m.y))}var v=Math.max(u-c,d-h),y=new dD({xmid:(u+c)/2,ymid:(d+h)/2,length:v,massCenter:o,mass:l}),E=new fD(y);for(p=0;p<l;p+=1){g=s[p].id;a&&t.getDegree(g)<=1||n[g].in(y)&&E.insert(n[g])}for(p=0;p<l;p+=1){var _=s[p],b=(g=_.id,m=_.data,t.getDegree(g));if(!(a&&b<=1)){n[g].resetForce(),E.updateForce(n[g]),e[g][0]-=n[g].fx,e[g][1]-=n[g].fy;var S=[m.x-o[0],m.y-o[1]],x=Math.hypot(S[0],S[1]);x=x<1e-4?1e-4:x,S[0]=S[0]/x,S[1]=S[1]/x;var T=i*(b+1);e[g][0]-=T*S[0],e[g][1]-=T*S[1]}}return e},t.prototype.getRepGraForces=function(t,e,n,r,i,o,a){for(var s=a.preventOverlap,l=a.kr,c=a.kg,u=a.center,h=a.prune,d=t.getAllNodes(),p=d.length,f=0;f<p;f+=1){for(var g=d[f],m=t.getDegree(g.id),v=f+1;v<p;v+=1){var y=d[v],E=t.getDegree(y.id);if(!h||!(m<=1||E<=1)){var _=[y.data.x-g.data.x,y.data.y-g.data.y],b=Math.hypot(_[0],_[1]);b=b<1e-4?1e-4:b,_[0]=_[0]/b,_[1]=_[1]/b,s&&e<n&&(b=b-o[g.id]-o[y.id]);var S=l*(m+1)*(E+1)/b;s&&e<n&&b<0?S=i*(m+1)*(E+1):s&&e<n&&0===b?S=0:s&&e<n&&b>0&&(S=l*(m+1)*(E+1)/b),r[g.id][0]-=S*_[0],r[y.id][0]+=S*_[0],r[g.id][1]-=S*_[1],r[y.id][1]+=S*_[1]}}var x=[g.data.x-u[0],g.data.y-u[1]],T=Math.hypot(x[0],x[1]);x[0]=x[0]/T,x[1]=x[1]/T;var A=c*(m+1);r[g.id][0]-=A*x[0],r[g.id][1]-=A*x[1]}return r},t.prototype.updatePos=function(t,e,n,r,i){for(var o=i.ks,a=i.tao,s=i.prune,l=i.ksmax,c=t.getAllNodes(),u=c.length,h=[],d=[],p=0,f=0,g=r,m=0;m<u;m+=1){var v=c[m].id,y=t.getDegree(v);if(!(s&&y<=1)){var E=[e[v][0]-n[v][0],e[v][1]-n[v][1]],_=Math.hypot(E[0],E[1]),b=[e[v][0]+n[v][0],e[v][1]+n[v][1]],S=Math.hypot(b[0],b[1]);h[m]=_,d[m]=S/2,p+=(y+1)*h[m],f+=(y+1)*d[m]}}var x=g;g=a*f/p,0!==x&&(g=g>1.5*x?1.5*x:g);for(m=0;m<u;m+=1){var T=c[m],A=(v=T.id,T.data);y=t.getDegree(v);if(!(s&&y<=1)&&(!Ue(A.fx)||!Ue(A.fy))){var R=o*g/(1+g*Math.sqrt(h[m])),M=Math.hypot(e[v][0],e[v][1]),C=l/(M=M<1e-4?1e-4:M),P=(R=R>C?C:R)*e[v][0],w=R*e[v][1];t.mergeNodeData(v,{x:A.x+P,y:A.y+w})}}return g},t}(),vD={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},yD=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=wc(wc({},vD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var n=0;n<t;n++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var r={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),r},t.prototype.genericFruchtermanLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E=this;return Ic(this,(function(_){return this.running?[2]:(r=this.formatOptions(n),i=r.dimensions,o=r.width,a=r.height,s=r.center,l=r.clustering,c=r.nodeClusterBy,u=r.maxIteration,h=r.onTick,d=e.getAllNodes(),p=e.getAllEdges(),(null==d?void 0:d.length)?1===d.length?(t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0}),f={nodes:[wc(wc({},d[0]),{data:wc(wc({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:p},this.lastResult=f,[2,f]):(g=d.map((function(t){return GP(t,[o,a])})),m=new TP({nodes:g,edges:p}),v={},l&&g.forEach((function(t){var e=t.data[c];v[e]||(v[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=g,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=m,this.lastOptions=r,this.lastClusterMap=v,"undefined"==typeof window?[2]:(y=0,[2,new Promise((function(n){E.timeInterval=window.setInterval((function(){E.running?(E.runOneStep(m,v,r),t&&g.forEach((function(t){var n=t.id,r=t.data;return e.mergeNodeData(n,{x:r.x,y:r.y,z:3===i?r.z:void 0})})),null==h||h({nodes:g,edges:p}),++y>=u&&(window.clearInterval(E.timeInterval),n({nodes:g,edges:p}))):n({nodes:g,edges:p})}),0),E.running=!0}))])):(f={nodes:[],edges:p},this.lastResult=f,[2,f]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=wc(wc({},this.options),t),n=e.clustering,r=e.nodeClusterBy,i=e.center,o=e.width,a=e.height;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},t.prototype.runOneStep=function(t,e,n){var r=n.dimensions,i=n.height,o=n.width,a=n.gravity,s=n.center,l=n.speed,c=n.clustering,u=n.nodeClusterBy,h=n.clusterGravity,d=i*o,p=Math.sqrt(d)/10,f=t.getAllNodes(),g=d/(f.length+1),m=Math.sqrt(g),v={};if(this.applyCalculate(t,v,m,g),c){for(var y in e)e[y].cx=0,e[y].cy=0,e[y].count=0;for(var y in f.forEach((function(t){var n=t.data,r=e[n[u]];Ue(n.x)&&(r.cx+=n.x),Ue(n.y)&&(r.cy+=n.y),r.count++})),e)e[y].cx/=e[y].count,e[y].cy/=e[y].count;var E=h||a;f.forEach((function(t,n){var r=t.id,i=t.data;if(Ue(i.x)&&Ue(i.y)){var o=e[i[u]],a=Math.sqrt((i.x-o.cx)*(i.x-o.cx)+(i.y-o.cy)*(i.y-o.cy)),s=m*E;v[r].x-=s*(i.x-o.cx)/a,v[r].y-=s*(i.y-o.cy)/a}}))}f.forEach((function(t,e){var n=t.id,i=t.data;if(Ue(i.x)&&Ue(i.y)){var o=.01*m*a;v[n].x-=o*(i.x-s[0]),v[n].y-=o*(i.y-s[1]),3===r&&(v[n].z-=o*(i.z-s[2]))}})),f.forEach((function(e,n){var i=e.id,o=e.data;if(Ue(o.fx)&&Ue(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(Ue(o.x)&&Ue(o.y)){var a=Math.sqrt(v[i].x*v[i].x+v[i].y*v[i].y+(3===r?v[i].z*v[i].z:0));if(a>0){var s=Math.min(p*(l/800),a);t.mergeNodeData(i,{x:o.x+v[i].x/a*s,y:o.y+v[i].y/a*s,z:3===r?o.z+v[i].z/a*s:void 0})}}}))},t.prototype.applyCalculate=function(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)},t.prototype.calRepulsive=function(t,e,n){var r=this,i=t.getAllNodes();i.forEach((function(t,o){var a=t.data,s=t.id;e[s]={x:0,y:0,z:0},i.forEach((function(t,i){var l=t.data,c=t.id;if(!(o<=i)&&Ue(a.x)&&Ue(l.x)&&Ue(a.y)&&Ue(l.y)){var u=a.x-l.x,h=a.y-l.y,d=3===r.options.dimensions?a.z-l.z:0,p=u*u+h*h+d*d;0===p&&(p=1,u=.01,h=.01,d=.01);var f=n/p,g=u*f,m=h*f,v=d*f;e[s].x+=g,e[s].y+=m,e[c].x-=g,e[c].y-=m,3===r.options.dimensions&&(e[s].z+=v,e[c].z-=v)}}))}))},t.prototype.calAttractive=function(t,e,n){var r=this;t.getAllEdges().forEach((function(i){var o=i.source,a=i.target;if(o&&a&&o!==a){var s=t.getNode(o).data,l=t.getNode(a).data;if(Ue(l.x)&&Ue(s.x)&&Ue(l.y)&&Ue(s.y)){var c=l.x-s.x,u=l.y-s.y,h=3===r.options.dimensions?l.z-s.z:0,d=Math.sqrt(c*c+u*u+h*h)/n,p=c*d,f=u*d,g=h*d;e[o].x+=p,e[o].y+=f,e[a].x-=p,e[a].y-=f,3===r.options.dimensions&&(e[o].z+=g,e[a].z-=g)}}}))},t}(),ED={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},_D=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=wc(wc({},ED),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P,w,N,O,I,D,B,k,L,F,U;return Ic(this,(function(G){if(r=wc(wc({},this.options),n),i=r.begin,o=void 0===i?[0,0]:i,a=r.condense,s=r.preventOverlapPadding,l=r.preventOverlap,c=r.rows,u=r.cols,h=r.nodeSpacing,d=r.nodeSize,p=r.width,f=r.height,g=r.position,m=r.sortBy,v=e.getAllNodes(),y=e.getAllEdges(),!(E=null==v?void 0:v.length)||1===E)return[2,HP(e,t,o)];if(_=v.map((function(t){return GP(t)})),"id"===m||De(m)&&void 0!==_[0].data[m]||(m="degree"),"degree"===m?_.sort((function(t,n){return e.getDegree(n.id,"both")-e.getDegree(t.id,"both")})):"id"===m?_.sort((function(t,e){return Ue(e.id)&&Ue(t.id)?e.id-t.id:(""+t.id).localeCompare(""+e.id)})):_.sort((function(t,e){return e.data[m]-t.data[m]})),b=p||"undefined"==typeof window?p:window.innerWidth,S=f||"undefined"==typeof window?f:window.innerHeight,x=E,T={rows:c,cols:u},null!=c&&null!=u?(T.rows=c,T.cols=u):null!=c&&null==u?(T.rows=c,T.cols=Math.ceil(x/T.rows)):null==c&&null!=u?(T.cols=u,T.rows=Math.ceil(x/T.cols)):(A=Math.sqrt(x*S/b),T.rows=Math.round(A),T.cols=Math.round(b/S*A)),T.rows=Math.max(T.rows,1),T.cols=Math.max(T.cols,1),T.cols*T.rows>x)R=bD(T),M=SD(T),(R-1)*M>=x?bD(T,R-1):(M-1)*R>=x&&SD(T,M-1);else for(;T.cols*T.rows<x;)R=bD(T),((M=SD(T))+1)*R>=x?SD(T,M+1):bD(T,R+1);for(C=a?0:b/T.cols,P=a?0:S/T.rows,(l||h)&&(w=VP(10,h),N=WP(30,d,!1),_.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var n,r,i=e.getNode(t.id),o=N(i)||30;PP(o)?(n=o[0],r=o[1]):(n=o,r=o);var a=void 0!==w?w(t):s,l=n+a,c=r+a;C=Math.max(C,l),P=Math.max(P,c)}))),O={},I={row:0,col:0},D={},B=0;B<_.length;B++){if(k=_[B],L=void 0,g&&(L=g(e.getNode(k.id))),L&&(void 0!==L.row||void 0!==L.col)){if(void 0===(F={row:L.row,col:L.col}).col)for(F.col=0;xD(O,F);)F.col++;else if(void 0===F.row)for(F.row=0;xD(O,F);)F.row++;D[k.id]=F,TD(O,F)}RD(k,o,C,P,D,T,I,O)}return U={nodes:_,edges:y},t&&_.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,U]}))}))},t}(),bD=function(t,e){var n,r=t.rows||5,i=t.cols||5;null==e?n=Math.min(r,i):Math.min(r,i)===t.rows?t.rows=e:t.cols=e;return n},SD=function(t,e){var n,r=t.rows||5,i=t.cols||5;null==e?n=Math.max(r,i):Math.max(r,i)===t.rows?t.rows=e:t.cols=e;return n},xD=function(t,e){return t["c-"+e.row+"-"+e.col]||!1},TD=function(t,e){return t["c-"+e.row+"-"+e.col]=!0},AD=function(t,e){var n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},RD=function(t,e,n,r,i,o,a,s){var l,c,u=i[t.id];if(u)l=u.col*n+n/2+e[0],c=u.row*r+r/2+e[1];else{for(;xD(s,a);)AD(o,a);l=a.col*n+n/2+e[0],c=a.row*r+r/2+e[1],TD(s,a),AD(o,a)}t.data.x=l,t.data.y=c},MD={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},CD=function(t,e,n,r,i,o){e.forEach((function(a,s){n[s]={x:0,y:0},e.forEach((function(e,l){if(s!==l&&i[s]===i[l]){var c=a.x-e.x,u=a.y-e.y,h=Math.sqrt(c*c+u*u);if(0===h){h=1;var d=s>l?1:-1;c=.01*d,u=.01*d}if(h<o(t[s])/2+o(t[l])/2){var p=r*r/h;n[s].x+=c/h*p,n[s].y+=u/h*p}}}))}))},PD=function(t,e,n,r,i,o,a,s){var l=o||a/10;return r&&e.forEach((function(e,n){var r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o),s=o/a,l=-r/a,c=Math.sqrt(e.x*e.x+e.y*e.y),u=Math.acos((s*e.x+l*e.y)/c);u>Math.PI/2&&(u-=Math.PI/2,s*=-1,l*=-1);var h=Math.cos(u)*c;e.x=s*h,e.y=l*h})),t.forEach((function(o,a){if(a!==i){var c=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(c>0&&a!==i){var u=Math.min(l*(n/800),c);if(o.x+=e[a].x/c*u,o.y+=e[a].y/c*u,r){var h=o.x-t[i].x,d=o.y-t[i].y,p=Math.sqrt(h*h+d*d);h=h/p*s[a],d=d/p*s[a],o.x=t[i].x+h,o.y=t[i].y+d}}}})),t},wD={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},ND=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=wc(wc({},wD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h,d,p,f,g,m,v,y,E,_,b,S,x,T,A,R,M,C,P,w,N,O,I,D,B,k,L,F,U,G,V,W,z,H,j;return Ic(this,(function(X){if(r=wc(wc({},this.options),n),i=r.width,o=r.height,a=r.center,s=r.focusNode,l=r.unitRadius,c=r.nodeSize,u=r.nodeSpacing,h=r.strictRadial,d=r.preventOverlap,p=r.maxPreventOverlapIteration,f=r.sortBy,g=r.linkDistance,m=void 0===g?50:g,v=r.sortStrength,y=void 0===v?10:v,E=r.maxIteration,_=void 0===E?1e3:E,b=e.getAllNodes(),S=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,T=o||"undefined"==typeof window?o:window.innerHeight,A=a||[x/2,T/2],!(null==b?void 0:b.length)||1===b.length)return[2,HP(e,t,A)];if(R=b[0],De(s)){for(M=0;M<b.length;M++)if(b[M].id===s){R=b[M];break}}else R=s||b[0];return C=DD(b,R.id),P=NP({nodes:b,edges:S},!1),w=wP(P),N=kD(w,C),BD(w,C,N+1),O=w[C],I=x-A[0]>A[0]?A[0]:x-A[0],D=T-A[1]>A[1]?A[1]:T-A[1],0===I&&(I=x/2),0===D&&(D=T/2),B=Math.min(I,D),k=Math.max.apply(Math,kc([],Bc(O))),L=[],F=l||B/k,O.forEach((function(t,e){L[e]=t*F})),U=OD(b,w,m,L,F,f,y),G=ID(U),V=function(t,e,n){try{var r=Dw.mul(Dw.pow(e,2),-.5),i=r.mean("row"),o=r.mean("column"),a=r.mean();r.add(a).subRowVector(i).subColumnVector(o);var s=new Lw(r),l=Dw.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return Dw.mul([e],[l]).toJSON()[0].splice(0,t)}))}catch(t){for(var c=[],u=0;u<e.length;u++){var h=Math.random()*n,d=Math.random()*n;c.push([h,d])}return c}}(m,U,m),W=V.map((function(t){var e=Bc(t,2),n=e[0],r=e[1];return{x:(isNaN(n)?Math.random()*m:n)-V[C][0],y:(isNaN(r)?Math.random()*m:r)-V[C][1]}})),this.run(_,W,G,U,L,C),d&&(z=zP(c,u),H={nodes:b,nodeSizeFunc:z,positions:W,radii:L,height:T,width:x,strictRadial:Boolean(h),focusIdx:C,iterations:p||200,k:W.length/4.5},W=function(t,e){for(var n=wc(wc({},MD),e),r=n.positions,i=n.iterations,o=n.width,a=n.k,s=n.speed,l=void 0===s?100:s,c=n.strictRadial,u=n.focusIdx,h=n.radii,d=void 0===h?[]:h,p=n.nodeSizeFunc,f=t.getAllNodes(),g=[],m=o/10,v=0;v<i;v++)r.forEach((function(t,e){g[e]={x:0,y:0}})),CD(f,r,g,a,d,p),PD(r,g,l,c,u,m,o,d);return r}(e,H)),j=[],W.forEach((function(t,e){var n=GP(b[e]);n.data.x=t.x+A[0],n.data.y=t.y+A[1],j.push(n)})),t&&j.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:j,edges:S}]}))}))},t.prototype.run=function(t,e,n,r,i,o){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,i,r,n,o)}},t.prototype.oneIteration=function(t,e,n,r,i,o){var a=1-t;e.forEach((function(s,l){var c=LP(s,{x:0,y:0}),u=0===c?0:1/c;if(l!==o){var h=0,d=0,p=0;e.forEach((function(t,e){if(l!==e){var n=LP(s,t),o=0===n?0:1/n,a=r[e][l];p+=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)}}));var f=0===n[l]?0:1/n[l];p*=a,p+=t*f*f,h*=a,h+=t*f*s.x*u,s.x=h/p,d*=a,d+=t*f*s.y*u,s.y=d/p}}))},t}(),OD=function(t,e,n,r,i,o,a){if(!t)return[];var s=[];if(e){var l={};e.forEach((function(e,c){var u=[];e.forEach((function(e,s){var h,d;if(c===s)u.push(0);else if(r[c]===r[s])if("data"===o)u.push(e*(Math.abs(c-s)*a)/(r[c]/i));else if(o){var p=void 0,f=void 0;if(l[t[c].id])p=l[t[c].id];else{var g=("id"===o?t[c].id:null===(h=t[c].data)||void 0===h?void 0:h[o])||0;p=De(g)?g.charCodeAt(0):g,l[t[c].id]=p}if(l[t[s].id])f=l[t[s].id];else{g=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=De(g)?g.charCodeAt(0):g,l[t[s].id]=f}u.push(e*(Math.abs(p-f)*a)/(r[c]/i))}else u.push(e*n/(r[c]/i));else{var m=(n+i)/2;u.push(e*m)}})),s.push(u)}))}return s},ID=function(t){for(var e=t.length,n=t[0].length,r=[],i=0;i<e;i++){for(var o=[],a=0;a<n;a++)0!==t[i][a]?o.push(1/(t[i][a]*t[i][a])):o.push(0);r.push(o)}return r},DD=function(t,e){var n=-1;return t.forEach((function(t,r){t.id===e&&(n=r)})),Math.max(n,0)},BD=function(t,e,n){for(var r=t.length,i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(var 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(i=0;i<r;i++)if(i!==e)for(o=0;o<r;o++)if(t[i][o]===1/0){var a=Math.abs(t[e][i]-t[e][o]);a=0===a?1:a,t[i][o]=a}},kD=function(t,e){for(var n=0,r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},LD={center:[0,0],width:300,height:300},FD=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=wc(wc({},LD),t)}return t.prototype.execute=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return Oc(this,void 0,void 0,(function(){return Ic(this,(function(n){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,n){return Oc(this,void 0,void 0,(function(){var r,i,o,a,s,l,c,u,h;return Ic(this,(function(d){return r=wc(wc({},this.options),n),i=r.center,o=r.width,a=r.height,s=e.getAllNodes(),.9,l=o||"undefined"==typeof window?o:window.innerWidth,c=a||"undefined"==typeof window?a:window.innerHeight,u=i||[l/2,c/2],h=[],s&&s.forEach((function(t){h.push({id:t.id,data:{x:.9*(Math.random()-.5)*l+u[0],y:.9*(Math.random()-.5)*c+u[1]}})})),t&&h.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:h,edges:e.getAllEdges()}]}))}))},t}(),UD={circular:XP,concentric:mN,mds:Uw,random:FD,grid:_D,radial:ND,force:cN,d3force:uO,fruchterman:yD,forceAtlas2:mD,dagre:sD,comboCombined:EN};function GD(t){return!!t.tick&&!!t.stop}var VD=Object.freeze({__proto__:null,CircularLayout:XP,Supervisor:gw,registry:UD,GridLayout:_D,RandomLayout:FD,MDSLayout:Uw,ConcentricLayout:mN,RadialLayout:ND,FruchtermanLayout:yD,D3ForceLayout:uO,ForceLayout:cN,ForceAtlas2Layout:mD,DagreLayout:sD,ComboCombinedLayout:EN,isLayoutWithIterations:GD,camelize:CP,isArray:PP,toNumber:function(t){var e=parseFloat(t);return isNaN(e)?t:e},floydWarshall:wP,getAdjMatrix:NP,scaleMatrix:OP,traverseTreeUp:function(t,e){"function"==typeof e&&IP(t,e)},getLayoutBBox:DP,getAvgNodePosition:function(t){var e={x:0,y:0};t.forEach((function(t){e.x+=t.data.x||0,e.y+=t.data.y||0}));var n=t.length||1;return{x:e.x/n,y:e.y/n}},getCoreNodeAndRelativeLeafNodes:function(t,e,n,r,i,o){var a=i[e.id],s=a.in,l=a.out,c=e,u=[];0===s?(c=BP("source",e,n),u=kP("both",c,n).map((function(t){return o[t]}))):0===l&&(c=BP("target",e,n),u=kP("both",c,n).map((function(t){return o[t]}))),u=u.filter((function(t){return i[t.id]&&(0===i[t.id].in||0===i[t.id].out)}));var h=function(t,e,n,r,i){var o=n[e]||"",a=(null==r?void 0:r.filter((function(t){return t[e]===o})))||[];return"leaf"===t&&(a=a.filter((function(t){var e,n;return 0===(null===(e=i[t.id])||void 0===e?void 0:e.in)||0===(null===(n=i[t.id])||void 0===n?void 0:n.out)}))),a}(t,r,e,u,i);return{coreNode:c,relativeLeafNodes:u,sameTypeLeafNodes:h}},getEuclideanDistance:LP,graphTreeDfs:FP,clone:UP,cloneFormatData:GP,formatNumberFn:VP,formatSizeFn:WP,formatNodeSize:zP});class WD{constructor(t){this.updateConfig=t=>{this.options=Object.assign(this.options,t)},this.options=t}destroy(){}}class zD{constructor(t){this.options=an(this.getDefaultCfgs(),t),this.events={},this.destroyed=!1}updateCfgs(t){this.options=an(this.options,t),this.init(this.graph)}getDefaultCfgs(){return{}}init(t){this.graph=t}getEvents(){return{}}destroy(){const{graph:t}=this;Ce(this.events,((e,n)=>{t.off(n,e)})),this.events=null,this.options=null,this.destroyed=!0}}const HD=["pointerenter","click"],jD=(t,e)=>{const n=t.filter((t=>!e.includes(t)));return{active:e.filter((e=>!t.includes(e))),inactive:n}},XD={multiple:!0,shouldBegin:()=>!0,shouldUpdate:()=>!0,trigger:"click",activeState:"selected"};const YD=(t,e)=>{const n=new Set;return e.forEach((r=>{t.getRelatedEdgesData(r).forEach((r=>{const{source:i,target:o,id:a}=r;t.getItemVisible(a)&&e.includes(i)&&e.includes(o)&&n.add(a)}))})),Array.from(n)},KD=(t,e,n,r,i,o,a,s={},l=!0)=>{let c=i.get(t.model.id);if(c)return c;const{shapeIds:u,drawSource:h=!0,drawTarget:d=!0,visible:p=!0}=s;if("node"===t.type)c=t.clone(e,u,!0);else if("edge"===t.type){let l,p;h&&(l=KD(t.sourceItem,e,n,r,i,o,a,s,!1)),d&&(p=KD(t.targetItem,e,n,r,i,o,a,s,!1)),c=t.clone(n,l,p,u,!0)}else{const l=[];a.getChildren(t.model.id,"combo").forEach((t=>{const c=o.get(t.id);c&&l.push(KD(c,e,n,r,i,o,a,s,!1))})),c=t.clone(r,u,!0,(()=>(t=>{if(!t.length)return!1;const e={center:[0,0,0],min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0],size:[0,0,0]};let n=0;return t.forEach((t=>{const r=t.getBBox();if(r){n++;const{min:t,max:i}=r;t.forEach(((t,n)=>{t<e.min[n]&&(e.min[n]=t)})),i.forEach(((t,n)=>{t>e.max[n]&&(e.max[n]=t)}))}})),!!n&&(e.size=e.size.map(((t,n)=>e.max[n]-e.min[n])),e.center=e.center.map(((t,n)=>(e.max[n]+e.min[n])/2)),e)})(l)),(()=>l)),c.toBack()}if(i.set(t.model.id,c),c.transient=!0,"edge"!==t.type&&l&&a.hasTreeStructure("combo")){let l=a.getParent(t.model.id,"combo");for(;l;){const t=o.get(l.id);if(t){KD(t,e,n,r,i,o,a,s).toBack()}l=a.getParent(l.id,"combo")}}return(null==u?void 0:u.length)&&p&&c.childNodes.forEach((t=>t.show())),c};function qD(t,e){return[t,gn(),e].join("->")}const $D=["drag","shift","ctrl","alt","meta"],ZD="g6-brush-select-brush-shape",QD={trigger:"shift",selectedState:"selected",itemTypes:["node","edge"],eventName:"",selectSetMode:"latest",brushStyle:{fill:"#EEF6FF",fillOpacity:.4,stroke:"#DDEEFE",lineWidth:1},shouldBegin:()=>!0,shouldUpdate:()=>!0,onSelect:()=>{},onDeselect:()=>{}};class JD extends WD{constructor(t){super(Object.assign({},QD,t)),this.selectedIds={nodes:[],edges:[],combos:[]},this.getEvents=()=>({pointerdown:this.onMouseDown,pointermove:this.onMouseMove,pointerup:this.onMouseUp}),t.trigger&&!$D.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for brush-select behavior!`),this.options.trigger=QD.trigger)}isKeydown(t){const e=this.options.trigger;return{drag:!0,shift:t.shiftKey,ctrl:t.ctrlKey,alt:t.altKey,meta:t.metaKey}[e]}onMouseDown(t){if(!this.options.shouldBegin(t))return;const{itemId:e,itemType:n,canvas:r}=t;if(e&&"node"===n)return;if(this.beginPoint={x:r.x,y:r.y},!this.isKeydown(t))return void this.clearStates();const{brush:i}=this;i||(this.brush=this.createBrush()),this.brush&&(this.brush.setAttribute("width",0),this.brush.setAttribute("height",0),this.brush.setAttribute("visibility","visible")),this.mousedown=!0}onMouseMove(t){this.mousedown&&this.isKeydown(t)&&(this.dragging=!0,this.brush=this.updateBrush(t))}onMouseUp(t){this.mousedown&&(this.isKeydown(t)||this.clearStates(),this.removeBrush(),this.brush=void 0,this.selectedIds=this.selectItems(t),this.dragging=!1,this.mousedown=!1)}clearStates(t=void 0,e=void 0){const{graph:n}=this,{selectedState:r,eventName:i,onDeselect:o}=this.options;let a=[],s=[],l=[];if(t?(a=t.nodes,s=t.edges,l=t.combos,this.selectedIds=e||{nodes:[],edges:[],combos:[]}):(a=n.findIdByState("node",r),s=n.findIdByState("edge",r),l=n.findIdByState("combo",r),this.selectedIds={nodes:[],edges:[],combos:[]}),a.concat(s).concat(l).forEach((t=>n.setItemState(t,r,!1))),a.length||s.length||l.length){const t={nodes:a,edges:s,combos:l};null==o||o(this.selectedIds,t),i&&n.emit(i,{action:"deselect",selectedIds:this.selectedIds,deselectedIds:t})}}selectItems(t){var e,n,r,i,o,a,s,l;const{graph:c,options:u}=this,{selectedState:h,itemTypes:d,eventName:p,selectSetMode:f,shouldUpdate:g,onSelect:m}=u,v=this.getSelector(),y=this.getPoints(t).filter(Boolean);if(y.length<2)return;let E=v(c,y,d.concat("node")),_=(t,e)=>e;const b=(null===(e=this.selectedIds)||void 0===e?void 0:e.nodes.length)||(null===(n=this.selectedIds)||void 0===n?void 0:n.edges.length)||(null===(r=this.selectedIds)||void 0===r?void 0:r.combos.length);switch(f){case"diff":b&&(_=bR);break;case"union":_=SR;break;case"intersect":b&&(_=xR)}E={nodes:_(null===(i=this.selectedIds)||void 0===i?void 0:i.nodes,E.nodes).filter((t=>g("node",t,"select",this))),edges:[],combos:_(null===(o=this.selectedIds)||void 0===o?void 0:o.combos,E.combos).filter((t=>g("combo",t,"select",this)))};const S=d.includes("edge");S&&(E.edges=YD(c,E.nodes.concat(E.combos)).filter((t=>g("edge",t,"select",this))));const x=d.includes("node");x||(E.nodes=[]);const T=d.includes("combo");if(T||(E.combos=[]),h){const t={nodes:x?bR(null===(a=this.selectedIds)||void 0===a?void 0:a.nodes,E.nodes):[],edges:S?bR(null===(s=this.selectedIds)||void 0===s?void 0:s.edges,E.edges):[],combos:T?bR(null===(l=this.selectedIds)||void 0===l?void 0:l.combos,E.combos):[]};(t.nodes.length||t.edges.length||t.combos.length)&&this.clearStates(t,E);const{nodes:e,edges:n,combos:r}=E;e.concat(n).concat(r).forEach((t=>c.setItemState(t,h,!0)))}this.selectedIds=E;return(E.nodes.length||E.edges.length||E.combos.length)&&(null==m||m(this.selectedIds)),p&&c.emit(p,{action:"select",selectedIds:this.selectedIds}),this.selectedIds}createBrush(){const{graph:t,options:e}=this,{brushStyle:n}=e;return t.drawTransient("rect",ZD,{style:Object.assign(Object.assign({},n),{pointerEvents:"none"})})}updateBrush(t){const{beginPoint:e,graph:n}=this,r=t.canvas;return n.drawTransient("rect",ZD,{style:{width:Math.abs(r.x-e.x),height:Math.abs(r.y-e.y),x:Math.min(r.x,e.x),y:Math.min(r.y,e.y)}})}removeBrush(){const{graph:t}=this;t.drawTransient("rect",ZD,{action:"remove"})}getSelector(){return QH.rectSelector}getPoints(t){const{canvas:e}=t;return[this.beginPoint,e]}destroy(){this.removeBrush()}}const tB=["shift","ctrl","alt","meta"],eB={multiple:!0,trigger:"shift",selectedState:"selected",itemTypes:["node","edge"],eventName:"",shouldBegin:()=>!0,shouldUpdate:()=>!0};const nB=["click","dblclick"],rB={trigger:"click",eventName:"",disableAnimate:!1,shouldBegin:()=>!0,shouldUpdate:()=>!0};const iB={trigger:"dblclick",shouldBegin:()=>!0};const oB=["drag","directionKeys"],aB={enableOptimize:void 0,dragOnItems:!1,trigger:"drag",direction:"both",secondaryKey:"",secondaryKeyToDisable:"shift",speedUpKey:"",scalableRange:0,eventName:"",shouldBegin:()=>!0};const sB="g6-drag-node-delegate-shape",lB={enableTransient:!0,enableDelegate:!1,delegateStyle:{fill:"#F3F9FF",fillOpacity:.5,stroke:"#1890FF",strokeOpacity:.9,lineDash:[5,5]},throttle:16,hideRelatedEdges:!1,selectedState:"selected",eventName:"",updateComboStructure:!0,shouldBegin:()=>!0};const cB="g6-drag-combo-delegate-shape",uB={enableTransient:!0,enableDelegate:!1,delegateStyle:{fill:"#F3F9FF",fillOpacity:.5,stroke:"#1890FF",strokeOpacity:.9,lineDash:[5,5]},throttle:16,hideRelatedEdges:!1,selectedState:"selected",eventName:"",updateComboStructure:!0,shouldBegin:()=>!0};const hB=["wheel","upDownKeys"],dB={enableOptimize:void 0,triggerOnItems:!0,sensitivity:10,trigger:"wheel",secondaryKey:"",speedUpKey:"shift",eventName:"",minZoom:1e-5,maxZoom:1e3,shouldBegin:()=>!0};const pB={throttle:16,activateState:"active",eventName:"",itemTypes:["node","edge","combo"],shouldBegin:()=>!0};const fB="g6-lasso-select-brush-shape";const gB=["drag","directionKeys"],mB={trigger:"drag",secondaryKey:"",speedUpKey:"shift",eventName:"",triggerOnItems:!1,shouldBegin:()=>!0};class vB extends WD{constructor(t){const e=Object.assign({},mB,t);gB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid for rotate-canvas-3d behavior, "drag" will take effect instead. Only "${gB.join('", "')}" are available.`),e.trigger="drag"),super(e),this.getEvents=()=>"drag"===this.options.trigger?{pointerdown:this.onPointerDown,pointermove:this.onPointerMove,pointerup:this.onPointerUp,keydown:this.onKeydown,keyup:this.onKeyup}:{keydown:this.onKeydown,keyup:this.onKeyup}}onPointerDown(t){const{triggerOnItems:e,shouldBegin:n}=this.options;if(t.itemId&&!e||!n(t))return;const{client:r}=t;this.pointStartAt={x:r.x,y:r.y}}onPointerMove(t){if(!this.pointStartAt)return;const{shouldBegin:e,secondaryKey:n}=this.options;if(n&&!this.keydown)return;if(!e(t))return;const{client:r}=t,i={x:r.x-this.pointStartAt.x,y:r.y-this.pointStartAt.y},{graph:o}=this,a=o.canvas.getCamera();this.rotate(a,i.x,i.y),this.pointStartAt={x:r.x,y:r.y}}onPointerUp(t){this.pointStartAt=void 0}onKeydown(t){const{key:e}=t,{trigger:n,secondaryKey:r,speedUpKey:i}=this.options;if("directionKeys"===n&&(!r||r&&this.keydown)){const{graph:t}=this,n=t.canvas.getCamera(),r=1*(this.speedUpKeydown?10:1);"ArrowUp"===e&&n.pan(0,r),"ArrowDown"===e&&n.pan(0,-r),"ArrowLeft"===e&&n.pan(r,0),"ArrowRight"===e&&n.pan(-r,0)}r===e.toLowerCase()&&(this.keydown=!0),i===e.toLowerCase()&&(this.speedUpKeydown=!0)}onKeyup(t){const{key:e}=t,{secondaryKey:n,speedUpKey:r}=this.options;n===e.toLowerCase()&&(this.keydown=!1),r===e.toLowerCase()&&(this.speedUpKeydown=!1)}rotate(t,e,n){const{width:r,height:i}=this.graph.canvas.getConfig();let o=10,a=10;e*e>2*n*n?a*=.5:n*n>2*e*e&&(o*=.5);const s=e*(20/i)*o,l=n*(20/r)*a;t.rotate(s,-l,0)}}const yB=["drag","directionKeys"],EB={trigger:"directionKeys",secondaryKey:"",eventName:"",shouldBegin:()=>!0};const _B=["drag","directionKeys"],bB={trigger:"directionKeys",secondaryKey:"",eventName:"",shouldBegin:()=>!0};const SB=["wheel","upDownKeys"],xB={trigger:"wheel",secondaryKey:"",eventName:"",sensitivity:10,triggerOnItems:!0,minZoom:.01,maxZoom:10,shouldBegin:()=>!0};function TB({optionName:t,shouldBe:e,now:n,scope:r}){console.warn(`G6 [${r}]: Invalid option, ${t} must be one of ${e.join(", ")}, but got ${n}`)}const AB=["shift","ctrl","control","alt","meta"],RB=["click","drag"],MB="g6-create-edge-virtual-edge",CB="g6-create-edge-dummy-node",PB={trigger:"click",secondaryKey:void 0,shouldBegin:()=>!0,shouldEnd:()=>!1,edgeConfig:{}};const wB=["shift","ctrl","alt","control"],NB={trigger:"ctrl",combinedKey:"1",functionName:"fitView",functionParams:[]};const OB={direction:"both",enableOptimize:!1,zoomKey:"ctrl",scalableRange:0,allowDragOnItem:!0,zoomRatio:.05};const IB=["shift","ctrl","alt","control","meta"];function DB(t){const e=(t?Array.isArray(t)?t:[t]:[]).filter((t=>{const e=IB.includes(t);return e||console.warn(`Invalid zoomKey: ${t}, please use a valid zoomKey: ${JSON.stringify(IB)}`),e}));return 0===e.length&&e.push("ctrl"),e}var BB=Object.freeze({__proto__:null,ActivateRelations:class extends WD{constructor(t){super(Object.assign({},XD,t)),this.getEvents=()=>{const{trigger:t}=this.options;return"pointerenter"===t?{"node:pointerenter":this.setAllItemStates,"combo:pointerenter":this.setAllItemStates,"node:pointerleave":this.clearActiveState,"combo:pointerleave":this.clearActiveState}:{"node:click":this.setAllItemStates,"combo:click":this.setAllItemStates,"canvas:click":this.clearActiveState}},t.trigger&&!HD.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for activate-relations behavior!`),this.options.trigger=XD.trigger),this.prevEdgeIds=[],this.prevNodeIds=[]}setAllItemStates(t){const{itemId:e}=t,{graph:n}=this,{activeState:r}=this.options;if(!n||n.destroyed)return;if(!this.options.shouldBegin(t))return;const i=n.getNeighborNodesData(e,"both").map((t=>t.id)),o=n.getRelatedEdgesData(e,"both").map((t=>t.id)),a=[e,...i],{active:s,inactive:l}=jD(this.prevNodeIds,a),{active:c,inactive:u}=jD(this.prevEdgeIds,o);n.historyBatch((()=>{n.setItemState(s,r,!0),n.setItemState(l,r,!1),n.setItemState(c,r,!0),n.setItemState(u,r,!1)})),this.prevNodeIds=a,this.prevEdgeIds=o}clearActiveState(t){const{activeState:e}=this.options;this.graph.historyBatch((()=>{this.graph.setItemState(this.prevNodeIds,e,!1),this.graph.setItemState(this.prevEdgeIds,e,!1)})),this.prevNodeIds=[],this.prevEdgeIds=[]}},BrushSelect:JD,ClickSelect:class extends WD{constructor(t){super(Object.assign({},eB,t)),this.selectedIds=[],this.canvasPointerDown=void 0,this.canvasPointerMove=!1,this.timeout=void 0,this.getEvents=()=>({"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClickBesideDblClick,"canvas:pointerdown":this.onCanvasPointerDown,"canvas:pointermove":this.onCanvasPointerMove,"canvas:pointerup":this.onCanvasPointerUp}),t.trigger&&!tB.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for click-select behavior!`),this.options.trigger=eB.trigger)}isMultipleSelect(t){if(!this.options.multiple)return!1;return{shift:t.shiftKey,ctrl:t.ctrlKey,alt:t.altKey,meta:t.metaKey}[this.options.trigger]}onClickBesideDblClick(t){if(this.timeout)return clearTimeout(this.timeout),void(this.timeout=void 0);this.timeout=setTimeout((()=>{this.timeout=void 0,this.onClick(t)}),200)}onClick(t){if(!this.options.shouldBegin(t))return;const e=t.itemType,n=t.itemId;if(!this.options.itemTypes.includes(e))return;const r=this.options.selectedState,i=this.isMultipleSelect(t),o=!this.graph.findIdByState(e,r).includes(n),a=o?"select":"unselect";if(this.options.shouldUpdate(t)&&(this.graph.historyBatch((()=>{i||this.graph.setItemState(this.selectedIds,r,!1),this.graph.setItemState(n,r,o)})),o?this.selectedIds.push(n):this.selectedIds.filter((t=>t!==n))),this.options.eventName){const t=this.graph.findIdByState("node",r),i=this.graph.findIdByState("edge",r),o=this.graph.findIdByState("combo",r);this.graph.emit(this.options.eventName,{action:a,itemId:n,itemType:e,selectedNodeIds:t,selectedEdgeIds:i,selectedComboIds:o})}}onCanvasPointerDown(t){this.canvasPointerDown={x:t.canvas.x,y:t.canvas.y},this.canvasPointerMove=!1}onCanvasPointerMove(t){if(this.canvasPointerDown){const e=Math.abs(this.canvasPointerDown.x-t.canvas.x),n=Math.abs(this.canvasPointerDown.y-t.canvas.y);(e>1||n>1)&&(this.canvasPointerMove=!0)}}onCanvasPointerUp(t){this.canvasPointerDown&&!this.canvasPointerMove&&this.onCanvasClick(t),this.canvasPointerDown=void 0,this.canvasPointerMove=!1}onCanvasClick(t){if(!this.options.shouldBegin(t))return;const e=this.options.selectedState;this.selectedIds.length&&(this.options.shouldUpdate(t)&&this.graph.setItemState(this.selectedIds,e,!1),this.options.eventName&&this.graph.emit(this.options.eventName,{action:"unselect",itemId:"",itemType:"",selectedNodeIds:[],selectedEdgeIds:[],selectedComboIds:[]}))}},CollapseExpandTree:class extends WD{constructor(t){super(Object.assign({},rB,t)),this.timeout=void 0,this.getEvents=()=>"dblclick"===this.options.trigger?{"node:dblclick":this.onClick}:{"node:click":this.onClickBesideDblClick},t.trigger&&!nB.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for collapse-expand-tree behavior!`),this.options.trigger=rB.trigger)}onClickBesideDblClick(t){if(this.timeout)return clearTimeout(this.timeout),void(this.timeout=void 0);this.timeout=setTimeout((()=>{this.timeout=void 0,this.onClick(t)}),200)}onClick(t){if(!this.options.shouldBegin(t))return;const{itemId:e,itemType:n}=t,{disableAnimate:r}=this.options,i=this.graph.getNodeData(e);if(!i)return void console.warn(`Node with id ${e} is not exist`);this.graph.frontItem(e);let o="expand";i.data.collapsed?this.graph.expand(e,r):(this.graph.collapse(e,r),o="collapse"),this.options.eventName&&this.graph.emit(this.options.eventName,{action:o,itemId:e,itemType:n})}},CollapseExpandCombo:class extends WD{constructor(t){super(Object.assign({},iB,t)),this.getEvents=()=>"dblclick"===this.options.trigger?{"combo:dblclick":this.collapseExpandCombo}:{"combo:click":this.collapseExpandCombo}}collapseExpandCombo(t){if(!this.options.shouldBegin(t))return;const{itemId:e}=t;this.graph.getComboData(e).data.collapsed?this.graph.expandCombo(e):this.graph.collapseCombo(e)}},DragCanvas:class extends WD{constructor(t){const e=Object.assign({},aB,t);oB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid, 'drag' will take effect.`),e.trigger="drag"),super(e)}getEvents(){return"undefined"!=typeof window&&(window.addEventListener("keydown",this.onKeydown.bind(this)),window.addEventListener("keyup",this.onKeyup.bind(this))),"directionKeys"===this.options.trigger?{keydown:this.onKeydown,keyup:this.onKeyup}:{pointerdown:this.onPointerDown,pointermove:this.onPointerMove,pointerup:this.onPointerUp,keydown:this.onKeydown,keyup:this.onKeyup}}onPointerDown(t){const{secondaryKey:e,secondaryKeyToDisable:n,dragOnItems:r,shouldBegin:i}=this.options;if(n&&this.disableKeydown)return;if(e&&!this.keydown)return;if(!i(t))return;if(t.itemId&&"CANVAS"!==t.itemId&&!r)return;const{client:o}=t;this.pointerDownAt={x:o.x,y:o.y},document.addEventListener("mouseup",(t=>{this.onPointerUp()}),{once:!0})}hideShapes(){const{graph:t}=this,{tileBehavior:e,tileBehaviorSize:n=1e3}=t.getSpecification().optimize||{},r=void 0!==this.options.enableOptimize?this.options.enableOptimize:e;if(Ue(r)?t.getAllNodesData().length>r:r){this.hiddenEdgeIds=t.getAllEdgesData().map((t=>t.id)).filter((e=>!0===t.getItemVisible(e))),this.hiddenNodeIds=t.getAllNodesData().map((t=>t.id)).filter((e=>!0===t.getItemVisible(e)));const e=[...this.hiddenNodeIds],r=Math.ceil(e.length/n),i=Array.from({length:r},((t,r)=>e.slice(r*n,r*n+n))),o=()=>{if(!i.length&&this.tileRequestId)return cancelAnimationFrame(this.tileRequestId),void(this.tileRequestId=void 0);const e=i.shift();t.executeWithNoStack((()=>{t.hideItem(e,!1,!0)})),this.tileRequestId=requestAnimationFrame(o)};this.tileRequestId=requestAnimationFrame(o)}}formatDisplacement(t,e){const{graph:n}=this,{scalableRange:r,direction:i}=this.options,[o,a]=n.getSize(),s=n.canvas.getRoot().getRenderBounds();let l,c=Number(r);if("string"==typeof r&&(r.includes("px")&&(l=r.includes("px"),c=Number(r.replace("px",""))),r.includes("%")&&(c=Number(r.replace("%",""))/100)),0===c)return{dx:t,dy:e};let u=c,h=c;l||(u=o*c,h=a*c);const d=n.getViewportByCanvas({x:s.min[0],y:s.min[1]}),p=n.getViewportByCanvas({x:s.max[0],y:s.max[1]});let f=t,g=e;return("y"===i||t>0&&p.x+t>o+u||t<0&&d.x+u+t<0)&&(f=0),("x"===i||e>0&&p.y+e>a+h||e<0&&d.y+h+e<0)&&(g=0),{dx:f,dy:g}}onPointerMove(t){if(!this.pointerDownAt)return;const{eventName:e,direction:n,secondaryKeyToDisable:r}=this.options;if(r&&this.disableKeydown)return;this.dragging||(this.hideShapes(),this.dragging=!0);const i=Date.now();if(this.lastDragTriggerTime&&i-this.lastDragTriggerTime<50)return;const{graph:o}=this,{client:a}=t,s=a.x-this.pointerDownAt.x,l=a.y-this.pointerDownAt.y;if("x"===n&&!s)return;if("y"===n&&!l)return;if("both"===n&&!s&&!l)return;const{dx:c,dy:u}=this.formatDisplacement(s,l);o.translate({dx:c,dy:u}),this.pointerDownAt={x:a.x,y:a.y},e&&this.graph.emit(e,{translate:{dx:c,dy:u}}),this.lastDragTriggerTime=i}onPointerUp(){this.pointerDownAt=void 0,this.dragging=!1;const{graph:t,hiddenNodeIds:e,hiddenEdgeIds:n=[]}=this,{tileBehavior:r,tileBehaviorSize:i=1e3}=t.getSpecification().optimize||{},o=void 0!==this.options.enableOptimize?this.options.enableOptimize:r;if((Ue(o)?t.getAllNodesData().length>o:o)&&(this.tileRequestId&&(cancelAnimationFrame(this.tileRequestId),this.tileRequestId=void 0),e)){const r=[...e,...n],o=Math.ceil(r.length/i),a=Array.from({length:o},((t,e)=>r.slice(e*i,e*i+i))),s=()=>{if(!a.length&&this.tileRequestId)return cancelAnimationFrame(this.tileRequestId),void(this.tileRequestId=void 0);t.startHistoryBatch(),t.showItem(a.shift(),!1),t.stopHistoryBatch(),this.tileRequestId=requestAnimationFrame(s)};this.tileRequestId=requestAnimationFrame(s)}}onKeydown(t){const{key:e}=t,{secondaryKey:n,secondaryKeyToDisable:r,trigger:i,speedUpKey:o,eventName:a,shouldBegin:s}=this.options;if(n&&n===e.toLowerCase()&&(this.keydown=!0),o&&o===e.toLowerCase()&&(this.speedupKeydown=!0),r&&r===e.toLowerCase()&&(this.disableKeydown=!0),"directionKeys"===i){if(n&&!this.keydown)return;if(r&&this.disableKeydown)return;if(!s(t))return;const{graph:i,speedupKeydown:o}=this,l=o?20:1;let c=0,u=0;switch(e){case"ArrowLeft":c=-l;break;case"ArrowRight":c=l;break;case"ArrowUp":u=-l;break;case"ArrowDown":u=l}if(c||u){const{dx:t,dy:e}=this.formatDisplacement(c,u);i.translate({dx:t,dy:e}),a&&this.graph.emit(a,{translate:{dx:t,dy:e}})}}}onKeyup(t){const{key:e}=t,{secondaryKey:n,secondaryKeyToDisable:r,speedUpKey:i}=this.options;n&&n===e.toLowerCase()&&(this.keydown=!1),i&&i===e.toLowerCase()&&(this.speedupKeydown=!1),r&&r===e.toLowerCase()&&(this.disableKeydown=!1)}destroy(){"undefined"!=typeof window&&(window.removeEventListener("keydown",this.onKeydown.bind(this)),window.removeEventListener("keyup",this.onKeyup.bind(this)))}},DragNode:class extends WD{constructor(t){const e=Object.assign({},lB,t);e.enableDelegate&&(e.enableTransient=!1),(e.enableDelegate||e.enableTransient)&&(e.hideRelatedEdges=!1),super(e),this.hiddenEdges=[],this.selectedNodeIds=[],this.hiddenNearEdges=[],this.hiddenComboTreeItems=[],this.originPositions=[],this.pointerDown=void 0,this.dragging=!1,this.getEvents=()=>{const t={"node:pointerdown":this.onPointerDown,pointermove:this.onPointerMove,click:this.onClick,"node:pointerup":this.onPointerUp,keydown:this.onKeydown};return this.options.updateComboStructure?Object.assign({"node:drop":this.onDropNode,"combo:drop":this.onDropCombo,"canvas:drop":this.onDropCanvas},t):Object.assign({pointerup:this.onClick},t)},this.throttledMoveNodes=(t,e,n,r=!0)=>{}}getRelatedEdges(t,e,n=!0){const r=[];sP(this.graph,e,(t=>r.push(t.id)));let i=Be(t.concat(r).flatMap((t=>this.graph.getRelatedEdgesData(t))));return n&&(i=i.filter((t=>this.graph.getItemVisible(t.id)))),i}getNearEdgesForNodes(t){return Be(t.flatMap((t=>this.graph.getNearEdgesForNode(t))))}getComboTreeItems(t){const e=[];return this.options.updateComboStructure?e:(t.forEach((t=>{const n=this.graph.getNodeData(t);if(!n.data.parentId)return;let r,i=n.data.parentId;for(;i;){const t=this.graph.getComboData(i);if(!t)break;r=t,i=t.data.parentId,e.push(r)}})),Be(e).filter((t=>this.graph.getItemVisible(t.id))))}onPointerDown(t){this.options.shouldBegin(t)&&(this.pointerDown={x:t.canvas.x,y:t.canvas.y},this.dragging=!1)}onPointerMove(t){if(!this.pointerDown)return;const e=Math.abs(this.pointerDown.x-t.canvas.x),n=Math.abs(this.pointerDown.y-t.canvas.y);if(e<1&&n<1)return;const r=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType;if(!this.dragging){this.dragging=!0;const e=t.itemId;this.selectedNodeIds=this.graph.findIdByState("node",this.options.selectedState,!0),e&&!this.selectedNodeIds.includes(e)&&(this.selectedNodeIds=[e]),this.originPositions=this.selectedNodeIds.map((t=>{if(!this.graph.getNodeData(t))return void console.warn("node does not exist",t);const{x:e,y:n}=this.graph.getNodeData(t).data;if(this.options.enableDelegate){const r=this.graph.getRenderBBox(t);if(r){const[i,o]=r.min,[a,s]=r.max;return{id:t,x:e,y:n,minX:i,minY:o,maxX:a,maxY:s}}}return{id:t,x:e,y:n}})).filter(Boolean),this.options.hideRelatedEdges&&!r&&(this.hiddenComboTreeItems=this.getComboTreeItems(this.selectedNodeIds),this.hiddenEdges=this.getRelatedEdges(this.selectedNodeIds,this.hiddenComboTreeItems),this.graph.executeWithNoStack((()=>{this.graph.hideItem(this.hiddenEdges.map((t=>t.id)),!0),this.graph.hideItem(this.hiddenComboTreeItems.map((t=>t.id)),!0)}))),r?(this.hiddenComboTreeItems=this.getComboTreeItems(this.selectedNodeIds),this.hiddenEdges=this.getRelatedEdges(this.selectedNodeIds,this.hiddenComboTreeItems),this.selectedNodeIds.forEach((t=>{this.graph.drawTransient("node",t,{upsertAncestors:!this.options.updateComboStructure})})),this.hiddenEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})})),this.graph.executeWithNoStack((()=>{this.graph.hideItem(this.selectedNodeIds,!0),this.graph.hideItem(this.hiddenEdges.map((t=>t.id)),!0),this.graph.hideItem(this.hiddenComboTreeItems.map((t=>t.id)),!0)}))):this.graph.frontItem(this.selectedNodeIds),this.options.throttle>0?this.throttledMoveNodes=pn(this.moveNodes,this.options.throttle,{leading:!0,trailing:!0}):this.throttledMoveNodes=this.moveNodes,this.originX=t.canvas.x,this.originY=t.canvas.y}if(this.dragging&&r){const t=this.selectedNodeIds.filter((t=>{var e;return(null===(e=this.graph.getNodeData(t))||void 0===e?void 0:e.data.preventPolylineEdgeOverlap)||!1}));if(t){const e=this.hiddenEdges.map((t=>t.id));this.hiddenNearEdges=this.getNearEdgesForNodes(t).filter((t=>!e.includes(t.id))),this.hiddenNearEdges.length&&(this.hiddenNearEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})})),this.graph.hideItem(this.hiddenNearEdges.map((t=>t.id)),!0))}}if(!this.originPositions.length||!this.dragging)return;const i=t,o=i.canvas.x-this.originX,a=i.canvas.y-this.originY;if(this.options.enableDelegate)this.moveDelegate(o,a);else{const t=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType;this.throttledMoveNodes(o,a,t,!this.options.updateComboStructure)}}moveNodes(t,e,n,r=!0,i){if(n)this.originPositions.forEach((({id:n,x:i,y:o})=>{this.graph.drawTransient("node",n,{data:{x:i+t,y:o+e},upsertAncestors:r})})),this.hiddenEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})}));else{const n=this.originPositions.map((({id:n,x:r,y:i})=>({id:n,data:{x:r+t,y:i+e}}))),o=[...this.originPositions];this.graph.updateNodePosition(n,r,!0,(()=>null==i?void 0:i(o)))}}moveDelegate(t,e){const n=Math.min(...this.originPositions.map((t=>t.minX))),r=Math.min(...this.originPositions.map((t=>t.minY))),i=Math.max(...this.originPositions.map((t=>t.maxX))),o=Math.max(...this.originPositions.map((t=>t.maxY)));this.graph.drawTransient("rect",sB,{style:Object.assign({x:n+t,y:r+e,width:i-n,height:o-r},this.options.delegateStyle)})}clearDelegate(){this.graph.drawTransient("rect",sB,{action:"remove"})}clearTransientItems(t){this.hiddenEdges.forEach((t=>{this.graph.drawTransient("node",t.source,{action:"remove"}),this.graph.drawTransient("node",t.target,{action:"remove"}),this.graph.drawTransient("edge",t.id,{action:"remove"})})),this.hiddenNearEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{action:"remove"})})),this.hiddenComboTreeItems.forEach((t=>{const e=t.data._isCombo;this.graph.drawTransient(e?"combo":"node",t.id,{action:"remove"})})),t.forEach((({id:t})=>{this.graph.drawTransient("node",t,{action:"remove"})}))}restoreHiddenItems(t){this.graph.pauseStack(),this.hiddenEdges.length&&(this.graph.showItem(this.hiddenEdges.map((t=>t.id)),!0),this.hiddenEdges=[]),this.hiddenNearEdges.length&&(this.graph.showItem(this.hiddenNearEdges.map((t=>t.id)),!0),this.hiddenNearEdges=[]),this.hiddenComboTreeItems.length&&(this.graph.showItem(this.hiddenComboTreeItems.map((t=>t.id)),!0),this.hiddenComboTreeItems=[]);this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType&&this.graph.showItem(this.originPositions.concat(t).map((t=>t.id)),!0),this.graph.resumeStack()}clearState(){this.originPositions=[]}onClick(t){this.onPointerUp(t),this.clearState()}onPointerUp(t){this.pointerDown=void 0,this.dragging=!1,this.selectedNodeIds=[];const e=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType,n=t,r=n.canvas.x-this.originX+.01,i=n.canvas.y-this.originY+.01;this.moveNodes(r,i,!1,!0,en((t=>{e&&this.clearTransientItems(t),this.options.enableDelegate&&this.clearDelegate(),this.restoreHiddenItems(t),this.options.eventName&&this.graph.emit(this.options.eventName,{itemIds:t.map((t=>t.id))}),this.clearState()})))}onKeydown(t){if("Escape"!==t.key&&"Esc"!==t.key)return;this.clearDelegate(),this.clearTransientItems(this.originPositions),this.restoreHiddenItems();if(!(this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType)&&!this.options.enableDelegate){const t=this.originPositions.map((({id:t,x:e,y:n})=>({id:t,data:{x:e,y:n}})));this.graph.updateNodePosition(t)}this.clearState()}onDropNode(t){return Oc(this,void 0,void 0,(function*(){const e=yield this.graph.canvas.document.elementsFromPoint(t.canvas.x,t.canvas.y),n=this.originPositions.map((({id:t})=>t)),r=e.map((t=>{var e,n;return null===(n=(e=t.parentNode).getAttribute)||void 0===n?void 0:n.call(e,"data-item-id")})).filter((t=>void 0!==t&&!n.includes(t))),i=r.find((t=>this.graph.getComboData(t)||this.graph.getNodeData(t))),o=this.graph.getNodeData(i)?this.graph.getNodeData(i).data.parentId:i;this.graph.startHistoryBatch(),this.originPositions.forEach((({id:t})=>{const e=this.graph.getNodeData(t);if(!e)return;const{parentId:n}=e.data;n!==o&&this.graph.updateData("node",{id:t,data:{parentId:o}})})),this.onPointerUp(t),this.graph.stopHistoryBatch()}))}onDropCombo(t){t.stopPropagation();const e=t.itemId;this.graph.startHistoryBatch(),this.onPointerUp(t),this.originPositions.forEach((({id:t})=>{const n=this.graph.getNodeData(t);if(!n)return;const{parentId:r}=n.data;r!==e&&this.graph.updateData("node",{id:t,data:{parentId:e}})})),this.clearState(),this.graph.stopHistoryBatch()}onDropCanvas(t){return Oc(this,void 0,void 0,(function*(){const e=yield this.graph.canvas.document.elementsFromPoint(t.canvas.x,t.canvas.y),n=this.originPositions.map((({id:t})=>t)),r=e.map((t=>{var e,n;return null===(n=(e=t.parentNode).getAttribute)||void 0===n?void 0:n.call(e,"data-item-id")})).filter((t=>void 0!==t&&!n.includes(t))),i=r.find((t=>this.graph.getComboData(t)||this.graph.getNodeData(t))),o=this.graph.getNodeData(i)?this.graph.getNodeData(i).data.parentId:i;this.graph.startHistoryBatch(),this.onPointerUp(t);const a=[];this.originPositions.forEach((({id:t})=>{const{parentId:e}=this.graph.getNodeData(t).data;o&&e!==o?a.push({id:t,data:{parentId:o}}):e&&a.push({id:t,data:{parentId:void 0}})})),a.length&&this.graph.updateData("node",a),this.clearState(),this.graph.stopHistoryBatch()}))}},DragCombo:class extends WD{constructor(t){const e=Object.assign({},uB,t);e.enableDelegate&&(e.enableTransient=!1),(e.enableDelegate||e.enableTransient)&&(e.hideRelatedEdges=!1),super(e),this.hiddenEdges=[],this.hiddenComboTreeRoots=[],this.originPositions=[],this.pointerDown=void 0,this.dragging=!1,this.getEvents=()=>{const t={"combo:pointerdown":this.onPointerDown,pointermove:this.onPointerMove,click:this.onPointerUp,keydown:this.onKeydown};return this.options.updateComboStructure?Object.assign({"node:drop":this.onDropNode,"combo:drop":this.onDropCombo,"canvas:drop":this.onDropCanvas},t):Object.assign({pointerup:this.onPointerUp},t)},this.throttledMoveCombos=(t,e,n,r=!0)=>{}}getRelatedEdges(t,e){let n=t.flatMap((t=>this.graph.getRelatedEdgesData(t)));return sP(this.graph,e,(t=>{n=n.concat(this.graph.getRelatedEdgesData(t.id))})),Be(n).filter((t=>this.graph.getItemVisible(t.id)))}getComboTreeItems(t){let e=[];this.options.updateComboStructure?e=t.map((t=>this.graph.getComboData(t))):t.forEach((t=>{const n=this.graph.getComboData(t);let r=n,i=n.data.parentId;for(;i;){const t=this.graph.getComboData(i);if(!t)break;i=t.data.parentId,r=t}e.push(r)}));const n=e;return sP(this.graph,e,(t=>n.push(t)),"TB"),Be(n).filter((e=>!t.includes(e.id)&&this.graph.getItemVisible(e.id)))}onPointerDown(t){this.options.shouldBegin(t)&&(this.pointerDown={x:t.canvas.x,y:t.canvas.y},this.dragging=!1)}onPointerMove(t){if(!this.pointerDown)return;const e=Math.abs(this.pointerDown.x-t.canvas.x),n=Math.abs(this.pointerDown.y-t.canvas.y);if(e<1&&n<1)return;const r=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType;if(this.dragging&&(this.originPositions=this.selectedComboIds.map((t=>{if(!this.graph.getComboData(t))return void console.warn("combo does not exist",t);const e=this.graph.getRenderBBox(t,!0,r);if(!e)return;const[n,i]=e.center;if(this.options.enableDelegate){const[r,o]=e.min,[a,s]=e.max;return{id:t,x:n,y:i,minX:r,minY:o,maxX:a,maxY:s}}return{id:t,x:n,y:i}})).filter(Boolean)),!this.dragging){this.dragging=!0;const e=t.itemId;let n=this.graph.findIdByState("combo",this.options.selectedState,!0);e&&"combo"===t.itemType&&!n.includes(e)&&(n=[e]),this.selectedComboIds=n,this.options.hideRelatedEdges&&!r&&(this.hiddenComboTreeRoots=this.getComboTreeItems(n),this.hiddenEdges=this.getRelatedEdges(n,this.hiddenComboTreeRoots),this.graph.executeWithNoStack((()=>{this.graph.hideItem(this.hiddenEdges.map((t=>t.id)),!0),this.graph.hideItem(this.hiddenComboTreeRoots.map((t=>t.id)),!0)}))),r?(this.hiddenComboTreeRoots=this.getComboTreeItems(n),this.hiddenEdges=this.getRelatedEdges(n,this.hiddenComboTreeRoots),n.forEach((t=>{this.graph.drawTransient("combo",t,{upsertAncestors:!this.options.updateComboStructure})})),this.hiddenEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})})),this.graph.executeWithNoStack((()=>{this.graph.hideItem(n,!0),this.graph.hideItem(this.hiddenEdges.map((t=>t.id)),!0),this.graph.hideItem(this.hiddenComboTreeRoots.map((t=>t.id)),!0)}))):this.graph.frontItem(n),this.options.throttle>0?this.throttledMoveCombos=pn(this.moveCombos,this.options.throttle,{leading:!0,trailing:!0}):this.throttledMoveCombos=this.moveCombos,this.originX=t.canvas.x,this.originY=t.canvas.y,this.previousX=t.canvas.x,this.previousY=t.canvas.y}if(!this.originPositions.length||!this.dragging)return;const i=t,o=i.canvas.x-this.previousX,a=i.canvas.y-this.previousY;if(this.options.enableDelegate)this.moveDelegate(o,a);else{const t=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType;this.throttledMoveCombos(o,a,t,!this.options.updateComboStructure)}}moveCombos(t,e,n,r=!0,i){if(n)this.originPositions.forEach((({id:n,x:i,y:o})=>{this.graph.drawTransient("combo",n,{data:{x:i+t,y:o+e},upsertAncestors:r})})),this.hiddenEdges.forEach((t=>{this.graph.drawTransient("edge",t.id,{})}));else{const n=[...this.originPositions];this.graph.moveCombo(this.originPositions.map((({id:t})=>t)),t,e,r,(()=>null==i?void 0:i(n)))}this.previousX+=t,this.previousY+=e}moveDelegate(t,e){const n=Math.min(...this.originPositions.map((t=>t.minX))),r=Math.min(...this.originPositions.map((t=>t.minY))),i=Math.max(...this.originPositions.map((t=>t.maxX))),o=Math.max(...this.originPositions.map((t=>t.maxY)));this.graph.drawTransient("rect",cB,{style:Object.assign({x:n+t,y:r+e,width:i-n,height:o-r},this.options.delegateStyle)})}clearDelegate(){this.graph.drawTransient("rect",cB,{action:"remove"})}clearTransientItems(){this.hiddenEdges.forEach((t=>{this.graph.drawTransient("combo",t.source,{action:"remove"}),this.graph.drawTransient("combo",t.target,{action:"remove"}),this.graph.drawTransient("edge",t.id,{action:"remove"})})),this.hiddenComboTreeRoots.forEach((t=>{const e=t.data._isCombo;this.graph.drawTransient(e?"combo":"node",t.id,{action:"remove"})})),this.originPositions.forEach((({id:t})=>{this.graph.drawTransient("combo",t,{action:"remove"})}))}restoreHiddenItems(t){this.graph.pauseStack(),this.hiddenEdges.length&&(this.graph.showItem(this.hiddenEdges.map((t=>t.id)),!0),this.hiddenEdges=[]),this.hiddenComboTreeRoots.length&&(this.graph.showItem(this.hiddenComboTreeRoots.map((t=>t.id)),!0),this.hiddenComboTreeRoots=[]);this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType&&this.graph.showItem(this.originPositions.concat(t).map((t=>t.id)),!0),this.graph.resumeStack()}onPointerUp(t){this.pointerDown=void 0,this.dragging=!1;const e=this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType,n=t,r=e?this.originX:this.previousX,i=e?this.originY:this.previousY,o=n.canvas.x-r+.01,a=n.canvas.y-i+.01;this.moveCombos(o,a,!1,!0,en((t=>{e&&this.clearTransientItems(),this.options.enableDelegate&&this.clearDelegate(),this.restoreHiddenItems(t),this.options.eventName&&this.graph.emit(this.options.eventName,{itemIds:t.map((t=>t.id))}),this.originPositions=[]}),16,!1))}onKeydown(t){if("Escape"!==t.key&&"Esc"!==t.key)return;this.clearDelegate(),this.clearTransientItems(),this.restoreHiddenItems();if(!(this.options.enableTransient&&"webgl-3d"!==this.graph.rendererType)&&!this.options.enableDelegate){const t=this.originPositions.map((({id:t,x:e,y:n})=>({id:t,data:{x:e,y:n}})));this.graph.updateComboPosition(t)}this.originPositions=[]}onDropNode(t){return Oc(this,void 0,void 0,(function*(){const e=yield this.graph.canvas.document.elementsFromPoint(t.canvas.x,t.canvas.y),n=this.originPositions.map((({id:t})=>t)),r=e.map((t=>{var e,n;return null===(n=(e=t.parentNode).getAttribute)||void 0===n?void 0:n.call(e,"data-item-id")})).filter((t=>void 0!==t&&!n.includes(t))),i=r.find((t=>this.graph.getComboData(t)||this.graph.getNodeData(t))),o=this.graph.getNodeData(i)?this.graph.getNodeData(i).data.parentId:i;this.originPositions.forEach((({id:t})=>{const e=this.graph.getComboData(t);if(!e)return;const{parentId:n}=e.data;n!==o&&this.graph.updateData("node",{id:t,data:{parentId:o}})})),this.onPointerUp(t)}))}onDropCombo(t){const e=t.itemId;this.graph.startHistoryBatch(),this.originPositions.forEach((({id:t})=>{const n=this.graph.getComboData(t);if(!n||n.id===e)return;const{parentId:r}=n.data;r!==e&&this.graph.updateData("combo",{id:t,data:{parentId:e}})})),this.graph.stopHistoryBatch(),this.onPointerUp(t)}onDropCanvas(t){this.graph.startHistoryBatch(),this.originPositions.forEach((({id:t})=>{const e=this.graph.getComboData(t);if(!e)return;const{parentId:n}=e.data;n&&this.graph.updateData("combo",{id:t,data:{parentId:void 0}})})),this.graph.stopHistoryBatch(),this.onPointerUp(t)}},ZoomCanvas:class extends WD{constructor(t){const e=Object.assign({},dB,t);hB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid, 'wheel' will take effect.`),e.trigger="wheel"),super(e)}getEvents(){var t,e;return null===(e=(t=this.graph.canvas.getContextService().getDomElement()).addEventListener)||void 0===e||e.call(t,"wheel",(t=>{t.preventDefault()}),{passive:!1}),"upDownKeys"===this.options.trigger?{keydown:this.onKeydown,keyup:this.onKeyup}:{wheel:this.onWheel,keydown:this.onKeydown,keyup:this.onKeyup}}hideShapes(){const{graph:t}=this,{tileBehavior:e,tileBehaviorSize:n=1e3}=t.getSpecification().optimize||{},r=void 0!==this.options.enableOptimize?this.options.enableOptimize:e;if(Ue(r)?t.getAllNodesData().length>r:r){this.hiddenEdgeIds=t.getAllEdgesData().map((t=>t.id)).filter((e=>!0===t.getItemVisible(e))),this.hiddenNodeIds=t.getAllNodesData().map((t=>t.id)).filter((e=>!0===t.getItemVisible(e)));const e=[...this.hiddenNodeIds],r=Math.ceil(e.length/n),i=Array.from({length:r},((t,r)=>e.slice(r*n,r*n+n))),o=()=>{if(!i.length&&this.tileRequestId)return cancelAnimationFrame(this.tileRequestId),void(this.tileRequestId=void 0);const e=i.shift();t.startHistoryBatch(),t.hideItem(e,!1,!0),t.stopHistoryBatch(),this.tileRequestId=requestAnimationFrame(o)};this.tileRequestId=requestAnimationFrame(o)}}endZoom(){const{graph:t,hiddenEdgeIds:e=[],hiddenNodeIds:n}=this,{tileBehavior:r,tileBehaviorSize:i=1e3}=t.getSpecification().optimize||{},o=void 0!==this.options.enableOptimize?this.options.enableOptimize:r,a=Ue(o)?t.getAllNodesData().length>o:o;if(this.zooming=!1,a&&(this.tileRequestId&&(cancelAnimationFrame(this.tileRequestId),this.tileRequestId=void 0),n)){const r=[...n,...e],o=Math.ceil(r.length/i),a=Array.from({length:o},((t,e)=>r.slice(e*i,e*i+i))),s=()=>{if(!a.length&&this.tileRequestId)return cancelAnimationFrame(this.tileRequestId),void(this.tileRequestId=void 0);t.executeWithNoStack((()=>{t.showItem(a.shift(),!1)})),this.tileRequestId=requestAnimationFrame(s)};this.tileRequestId=requestAnimationFrame(s)}this.hiddenEdgeIds=[],this.hiddenNodeIds=[]}onWheel(t){const{graph:e,keydown:n}=this,{deltaY:r,client:i,itemId:o}=t,{eventName:a,sensitivity:s,secondaryKey:l,triggerOnItems:c,minZoom:u,maxZoom:h,shouldBegin:d}=this.options;if(l&&!n||o&&"CANVAS"!==o&&!c||!d(t))return void this.endZoom();this.zooming||(this.hideShapes(),this.zooming=!0);const p=Date.now();if(this.lastWheelTriggerTime&&p-this.lastWheelTriggerTime<50)return;let f=1;r<0&&(f=(100+s)/100),r>0&&(f=100/(100+s));const g=f*e.getZoom();if(u&&g<u)return;if(h&&g>h)return;const{tileBehavior:m}=e.getSpecification().optimize||{},v="boolean"==typeof m?m:e.getAllNodesData().length<m;e.zoom(f,{x:i.x,y:i.y},v?{duration:50}:void 0),this.lastWheelTriggerTime=p,clearTimeout(this.zoomTimer),this.zoomTimer=setTimeout((()=>{this.endZoom()}),300),a&&e.emit(a,{zoom:{ratio:f}})}onKeydown(t){const{key:e}=t,{secondaryKey:n,trigger:r,speedUpKey:i,eventName:o,sensitivity:a,shouldBegin:s}=this.options;if(n&&n===e.toLowerCase()&&(this.keydown=!0),i&&i===e.toLowerCase()&&(this.speedupKeydown=!0),"upDownKeys"===r){if(n&&!this.keydown)return;if(!s(t))return;const{graph:r,speedupKeydown:i}=this,l=i?20:1;let c=1;switch(e){case"ArrowUp":c=(100+a*l)/100;break;case"ArrowDown":c=100/(100+a*l)}1!==c&&(r.zoom(c),o&&r.emit(o,{zoom:{ratio:c}}))}}onKeyup(t){const{key:e}=t,{secondaryKey:n,speedUpKey:r}=this.options;n&&n===e.toLowerCase()&&(this.keydown=!1),r&&r===e.toLowerCase()&&(this.speedupKeydown=!1)}},HoverActivate:class extends WD{constructor(t){super(Object.assign({},pB,t)),this.getEvents=()=>({"node:pointerenter":this.onPointerEnter,"node:pointerleave":this.onPointerLeave,"edge:pointerenter":this.onPointerEnter,"edge:pointerleave":this.onPointerLeave,"combo:pointerenter":this.onPointerEnter,"combo:pointerleave":this.onPointerLeave})}onPointerEnter(t){const{itemId:e,itemType:n}=t,{graph:r,currentItemInfo:i}=this,{activateState:o,itemTypes:a,eventName:s}=this.options;i&&a.includes(i.itemType)&&r.setItemState(i.id,o,!1),a.includes(n)&&(r.setItemState(e,o,!0),this.currentItemInfo={id:e,itemType:n},s&&this.graph.emit(s,{itemId:e,itemType:n,state:o,action:"pointerenter"}))}onPointerLeave(t){const{itemId:e,itemType:n}=t,{activateState:r,itemTypes:i,eventName:o}=this.options;if(!i.includes(n))return;const{graph:a}=this;a.setItemState(e,r,!1),this.currentItemInfo=void 0,o&&this.graph.emit(o,{itemId:e,itemType:n,state:r,action:"pointerleave"})}},LassoSelect:class extends JD{constructor(){super(...arguments),this.selectedIds={nodes:[],edges:[],combos:[]},this.points=[],this.onMouseDown=t=>{this.points=[],this.removeBrush(),super.onMouseDown(t),this.beginPoint&&this.points.push(this.beginPoint)},this.onMouseMove=t=>{if(this.mousedown){const{canvas:e}=t;this.points.push({x:e.x,y:e.y})}super.onMouseMove(t)},this.onMouseUp=t=>{const{canvas:e}=t;this.points.push({x:e.x,y:e.y}),super.onMouseUp(t),this.removeBrush(),this.points=[]},this.updateBrush=t=>{const{graph:e}=this;return e.drawTransient("path",fB,{style:{path:this.getLassoPath()}})},this.removeBrush=()=>{const{graph:t}=this;t.drawTransient("path",fB,{action:"remove"})},this.getLassoPath=()=>{const t=this.points,e=[];return t.length&&(t.forEach(((t,n)=>{0===n?e.push(["M",t.x,t.y]):e.push(["L",t.x,t.y])})),e.push(["L",t[0].x,t[0].y])),e}}getSelector(){return QH.lassoSelector}getPoints(){return this.points}createBrush(){const{graph:t,options:e}=this,{brushStyle:n}=e;return t.drawTransient("path",fB,{style:Object.assign({pointerEvents:"none"},n)})}},OrbitCanvas3D:class extends vB{constructor(t){const e=Object.assign({},EB,t);yB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid for track-canvas-3d behavior, "drag" will take effect instead. Only "${yB.join('", "')}" are available.`),e.trigger="drag"),super(e)}setTrackingCamera(){const{graph:t}=this,e=t.canvas.getCamera();this.previousType=e.type,t.canvas.getCamera().setType(Ur.ORBITING)}restoreCameraType(){if(void 0!==this.previousType){const{graph:t}=this;t.canvas.getCamera().setType(this.previousType)}}onPointerDown(t){this.setTrackingCamera(),super.onPointerDown(t)}onPointerUp(t){this.restoreCameraType(),super.onPointerUp(t)}onKeydown(t){const{trigger:e,secondaryKey:n}=this.options;"directionKeys"===e&&(!n||n&&this.keydown)&&this.setTrackingCamera(),super.onKeydown(t)}onKeyup(t){const{trigger:e,secondaryKey:n}=this.options;"directionKeys"===e&&(!n||n&&this.keydown)&&this.restoreCameraType(),super.onKeyup(t)}},RotateCanvas3D:vB,TrackCanvas3D:class extends vB{constructor(t){const e=Object.assign({},bB,t);_B.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid for track-canvas-3d behavior, "drag" will take effect instead. Only "${_B.join('", "')}" are available.`),e.trigger="drag"),super(e)}setTrackingCamera(){const{graph:t}=this,e=t.canvas.getCamera();this.previousType=e.type,t.canvas.getCamera().setType(Ur.TRACKING)}restoreCameraType(){if(void 0!==this.previousType){const{graph:t}=this;t.canvas.getCamera().setType(this.previousType)}}onPointerDown(t){this.setTrackingCamera(),super.onPointerDown(t)}onPointerUp(t){this.restoreCameraType(),super.onPointerUp(t)}onKeydown(t){const{trigger:e,secondaryKey:n}=this.options;"directionKeys"===e&&(!n||n&&this.keydown)&&this.setTrackingCamera(),super.onKeydown(t)}onKeyup(t){const{trigger:e,secondaryKey:n}=this.options;"directionKeys"===e&&(!n||n&&this.keydown)&&this.restoreCameraType(),super.onKeyup(t)}},ZoomCanvas3D:class extends WD{constructor(t){const e=Object.assign({},xB,t);SB.includes(e.trigger)||(console.warn(`The trigger ${e.trigger} is not valid for zoom-canvas-3d behavior, "wheel" will take effect instead. Only "${SB.join('", "')}" are available.`),e.trigger="wheel"),super(e),this.getEvents=()=>{const t=this.graph.canvas.getContextService().getDomElement();return t&&t.addEventListener&&t.addEventListener("wheel",(t=>{t.preventDefault()}),{passive:!1}),"wheel"===this.options.trigger?{wheel:this.onWheel,keydown:this.onKeydown,keyup:this.onKeyup}:{keydown:this.onKeydown,keyup:this.onKeyup}}}onWheel(t){const{graph:e,options:n}=this,{secondaryKey:r,triggerOnItems:i,eventName:o,minZoom:a,maxZoom:s,sensitivity:l=1,shouldBegin:c}=n;if(t.itemId&&!i)return;if(!c(t))return;if(r&&!this.keydown)return;const u=e.canvas.getCamera(),h=t.deltaY>0?1:-1,d=u.getDistance(),p=100*h*l/d*Math.sqrt(d),f=d+p,g=u.getAzimuth(),m=(g<90&&g>-90?1:-1)*(u.getDistanceVector()[2]<0?1:-1)>0;p>0&&m&&f>1/a*200||p<0&&!m&&f>200*s||(u.dolly(p),o&&e.emit(o,{zoom:u.getZoom()}))}onKeydown(t){const{key:e}=t,{trigger:n,secondaryKey:r}=this.options;"upDownKeys"===n&&("ArrowUp"===e&&this.onWheel({deltaY:-1}),"ArrowDown"===e&&this.onWheel({deltaY:1})),r===e.toLowerCase()&&(this.keydown=!0)}onKeyup(t){const{key:e}=t,{secondaryKey:n}=this.options;n===e.toLowerCase()&&(this.keydown=!1)}},CreateEdge:class extends WD{constructor(t){super(Object.assign({},PB,t)),this.isKeyDown=!1,this.addingEdge=null,this.dummyNode=null,this.getEvents=()=>{const{trigger:t,secondaryKey:e}=this.options,[n]=RB,r=t===n?{"node:click":this.handleCreateEdge,pointermove:this.updateEndPoint,"edge:click":this.cancelCreating,"canvas:click":this.cancelCreating,"combo:click":this.handleCreateEdge}:{"node:dragstart":this.handleCreateEdge,"combo:dragstart":this.handleCreateEdge,drag:this.updateEndPoint,drop:this.onDrop},i=e?{keydown:this.onKeyDown,keyup:this.onKeyUp}:{};return Object.assign(Object.assign({},r),i)},this.handleCreateEdge=t=>{if(this.options.secondaryKey&&!this.isKeyDown)return;if(this.options.shouldEnd(t))return;const{graph:e,options:n,addingEdge:r}=this,i=t.itemId,{edgeConfig:o,createVirtualEventName:a,createActualEventName:s}=n;if(r){const t=e.addData("edge",{id:qD(r.source,i),source:r.source,target:i,data:Object.assign(Object.assign({},o),{type:i===r.source?"loop-edge":o.type})});return s&&e.emit(s,{edge:t}),void this.cancelCreating()}this.dummyNode=e.addData("node",{id:CB,data:{x:t.canvas.x,y:t.canvas.y,keyShape:{opacity:0,interactive:!1},labelShape:{opacity:0},anchorPoints:[[.5,.5]]}}),this.addingEdge=e.addData("edge",{id:MB,source:i,target:CB,data:Object.assign({},o)}),a&&e.emit(a,{edge:this.addingEdge})},this.onDrop=t=>Oc(this,void 0,void 0,(function*(){const{addingEdge:e,options:n,graph:r}=this,{edgeConfig:i,secondaryKey:o,createActualEventName:a}=n;if(o&&!this.isKeyDown)return;if(!e)return;const s=(yield this.graph.canvas.document.elementsFromPoint(t.canvas.x,t.canvas.y)).map((t=>{var e,n;return null===(n=(e=t.parentNode).getAttribute)||void 0===n?void 0:n.call(e,"data-item-id")})).filter((t=>void 0!==t&&!1!==t)),l=s.find((t=>this.graph.getComboData(t)||this.graph.getNodeData(t)));if(!l)return void this.cancelCreating();const c=r.addData("edge",{id:qD(e.source,l),source:e.source,target:l,data:Object.assign(Object.assign({},i),{type:l===e.source?"loop-edge":i.type})});a&&r.emit(a,{edge:c}),this.cancelCreating()})),this.updateEndPoint=t=>{const{options:e,graph:n,addingEdge:r,isKeyDown:i}=this;if(e.secondaryKey&&!i)return;if(!r)return;const o=r.source,a=r.target;n.getItemById(o)?n.updatePosition("node",{id:a,data:{x:t.canvas.x,y:t.canvas.y}}):this.addingEdge=null},this.cancelCreating=()=>{this.addingEdge&&(this.graph.removeData("edge",MB),this.addingEdge=null),this.dummyNode&&(this.graph.removeData("node",CB),this.dummyNode=null),this.options.cancelCreateEventName&&this.graph.emit(this.options.cancelCreateEventName,{})},this.onKeyDown=t=>{const e=t.key;e&&e.toLocaleLowerCase()===this.options.secondaryKey&&(this.isKeyDown=!0)},this.onKeyUp=t=>{this.addingEdge&&this.cancelCreating(),this.isKeyDown=!1},this.validateOptions(t)}validateOptions(t){t.trigger&&!RB.includes(t.trigger)&&(TB({optionName:"create-edge.trigger",shouldBe:RB,now:t.trigger,scope:"behavior"}),this.options.trigger=PB.trigger),t.secondaryKey&&!AB.includes(t.secondaryKey)&&(TB({optionName:"create-edge.secondaryKey",shouldBe:AB,now:t.secondaryKey,scope:"behavior"}),this.options.secondaryKey=PB.secondaryKey)}},ShortcutsCall:class extends WD{constructor(t){super(Object.assign({},NB,t)),this.triggerKeydown=!1,this.getEvents=()=>({keyup:this.onKeyUp,keydown:this.onKeyDown}),t.trigger&&!wB.includes(t.trigger)&&(console.warn(`G6: Invalid trigger option "${t.trigger}" for shortcuts-call behavior!`),this.options.trigger=NB.trigger),t.combinedKey===this.options.trigger&&(this.options.combinedKey=void 0)}onKeyDown(t){const e=t.key;if(!e)return;const{graph:n}=this,{trigger:r,combinedKey:i,functionName:o,functionParams:a}=this.options,s=r.toLowerCase(),l=e.toLowerCase();if(this.triggerKeydown||(l===s||"control"===l&&"ctrl"===s||"ctrl"===l&&"control"===s)&&(this.triggerKeydown=!0),!n[o])return console.warn(`G6: Invalid functionName option: "${o}" for shortcuts-call behavior!`),{};if(!this.triggerKeydown)return;if(!i)return void(a&&a.length?n[o](...a):n[o]());const c=i.toLowerCase();(l===c||"control"===l&&"ctrl"===c||"ctrl"===l&&"control"===c)&&(a&&a.length?n[o](...a):n[o]())}onKeyUp(t){const e=t.key;if(!e)return;const{trigger:n}=this.options,r=n.toLowerCase(),i=e.toLowerCase();(i===r||"control"===i&&"ctrl"===r||"ctrl"===i&&"control"===r)&&(this.triggerKeydown=!1)}},ScrollCanvas:class extends WD{constructor(t){super(Object.assign({},OB,t,{zoomKey:DB(t.zoomKey)})),this.optimized=!1,this.getEvents=()=>({wheel:this.onWheel})}onWheel(t){if(!this.allowDrag(t))return;const e=this.graph,{zoomKey:n,zoomRatio:r,enableOptimize:i}=this.options,o=Array.isArray(n)?[].concat(n):[n];o.includes("control")&&o.push("ctrl");const a=o.some((e=>t[`${e}Key`])),s=t.nativeEvent;if(a){const n=e.canvas.client2Viewport({x:t.client.x,y:t.client.y});let i=e.getZoom();s&&s.wheelDelta>0?i+=i*r:i-=i*r,e.zoomTo(i,{x:n.x,y:n.y})}else{const n=t.deltaX||t.movement.x,r=t.deltaY||t.movement.y,{dx:i,dy:o}=this.formatDisplacement(n,r);e.translate({dx:-i,dy:-o})}if(i){this.optimized||(this.hideShapes(),this.optimized=!0),clearTimeout(this.timeout),this.timeout=void 0;const t=window.setTimeout((()=>{this.showShapes(),this.optimized=!1}),100);this.timeout=t}}formatDisplacement(t,e){const{graph:n}=this,{scalableRange:r,direction:i}=this.options,[o,a]=n.getSize(),s=n.canvas.getRoot().getRenderBounds();let l,c=Number(r);"string"==typeof r&&(r.includes("px")&&(l=r.includes("px"),c=Number(r.replace("px",""))),r.includes("%")&&(c=Number(r.replace("%",""))/100));let u=c,h=c;l||(u=o*c,h=a*c);const d=n.getViewportByCanvas({x:s.min[0],y:s.min[1]}),p=n.getViewportByCanvas({x:s.max[0],y:s.max[1]}),f=d.x,g=d.y,m=p.x,v=p.y;return t>0?m<-u?t=0:m-t<-u&&(t=m+u):t<0&&(f>o+u?t=0:f-t>o+u&&(t=f-(o+u))),e>0?v<-h?e=0:v-e<-h&&(e=v+h):e<0&&(g>a+h?e=0:g-e>a+h&&(e=g-(a+h))),"x"===i?e=0:"y"===i&&(t=0),{dx:t,dy:e}}allowDrag(t){const{itemType:e}=t,{allowDragOnItem:n}=this.options,r="canvas"===e;if(Ke(n)&&!n&&!r)return!1;if(Me(n)){const{node:t,edge:r,combo:i}=n;if(!t&&"node"===e)return!1;if(!r&&"edge"===e)return!1;if(!i&&"combo"===e)return!1}return!0}hideShapes(){const{graph:t,options:e}=this,{tileBehavior:n,tileBehaviorSize:r=1e3}=t.getSpecification().optimize||{},{optimizeZoom:i}=e,o=this.options.enableOptimize||n;if(Ue(o)?t.getAllNodesData().length>o:o){const e=t.getZoom(),n=t.getAllEdgesData().map((t=>t.id)).filter((e=>t.getItemVisible(e)));t.hideItem(n,!0),e<i?this.hiddenEdgeIds.push(...n):this.hiddenEdgeIds=n;const o=t.getAllNodesData().map((t=>t.id)).filter((e=>t.getItemVisible(e)));let a;const s=Math.ceil(o.length/r),l=Array.from({length:s},((t,e)=>o.slice(e*r,e*r+r))),c=()=>{if(!l.length)return void cancelAnimationFrame(a);const e=l.shift();t.startHistoryBatch(),t.hideItem(e,!1,!0),t.stopHistoryBatch(),a=requestAnimationFrame(c)};a=requestAnimationFrame(c),e<i?this.hiddenNodeIds.push(...o):this.hiddenNodeIds=o}}showShapes(){const{graph:t,hiddenEdgeIds:e,hiddenNodeIds:n}=this,r=t.getZoom(),{optimizeZoom:i}=this.options;if(r<i)return;const{tileBehavior:o,tileBehaviorSize:a=1e3}=t.getSpecification().optimize||{},s=this.options.enableOptimize||o;if(!(Ue(s)?t.getAllNodesData().length>s:s))return void(this.hiddenEdgeIds=this.hiddenNodeIds=[]);let l;const c=[...n,...e],u=Math.ceil(c.length/a),h=Array.from({length:u},((t,e)=>c.slice(e*a,e*a+a))),d=()=>{h.length?(t.executeWithNoStack((()=>{t.showItem(h.shift(),!1)})),l=requestAnimationFrame(d)):cancelAnimationFrame(l)};l=requestAnimationFrame(d),this.hiddenEdgeIds=this.hiddenNodeIds=[]}}});const kB=(t,e,n,r)=>{const i=r[1]-r[0],o=n[1]-n[0],a=new Map;return t.forEach((t=>{a.set(t.id,(t.data[e]-n[0])*i/o+r[0])})),a},LB=t=>{if(t)return Ue(t)?[t,t]:Re(t)?t.length>2?[t[0],t[1]]:t:void 0};var FB,UB=Object.freeze({__proto__:null,MapNodeSize:(t,e={},n)=>{const{field:r,range:i=[8,40]}=e;if(!r)return t;const{nodes:o}=t,a=new Map;let s=-1/0,l=1/0;o.forEach((t=>{a.set(t.id,t),s<t.data[r]&&(s=t.data[r]),l>t.data[r]&&(l=t.data[r])}));return kB(o,r,[l,s],i).forEach(((t,e)=>{let n=t;isNaN(t)&&(n=i[0]);const r=a.get(e);r.data.keyShape=Object.assign(Object.assign({},r.data.keyShape),{r:n/2,width:n,height:n})})),t},TransformV4Data:(t,e={},n)=>{const{nodes:r=[],edges:i=[],combos:o=[]}=t,a=r.map((t=>{const{id:e,type:n,style:r,size:i,color:o,label:a,labelCfg:s={},icon:l,linkPoints:c}=t,u=Nc(t,["id","type","style","size","color","label","labelCfg","icon","linkPoints"]),h=[];if(c){const{top:t,bottom:e,left:n,right:r}=c,i=Nc(c,["top","bottom","left","right"]);Object.keys({top:t,bottom:e,left:n,right:r}).forEach((t=>{c[t]&&h.push(Object.assign({position:t},i))}))}const{style:d={}}=s,p=Nc(s,["style"]),{background:f}=d,g={id:e,data:Object.assign(Object.assign({},u),{labelShape:Object.assign(Object.assign({},d),p)})};n&&(g.data.type=n.includes("-node")?n:`${n}-node`),r&&(g.data.keyShape=r);const m=LB(i);return m&&(g.data.keyShape=Object.assign(Object.assign({},g.data.keyShape),{r:null==m?void 0:m[0],width:null==m?void 0:m[0],height:null==m?void 0:m[1]})),o&&(g.data.keyShape.fill=o),a&&(g.data.labelShape.text=a),(null==l?void 0:l.show)&&(g.data.icon=l),h.length&&(g.data.anchorShapes=h),f&&(g.data.labelBackgroundShape=f),g})),s=i.map((t=>{const{id:e=gn(),type:n,source:r,target:i,style:o,size:a,color:s,label:l,labelCfg:c={},icon:u,linkPoints:h}=t,d=Nc(t,["id","type","source","target","style","size","color","label","labelCfg","icon","linkPoints"]),{style:p={}}=c,f=Nc(c,["style"]),{background:g}=p,m={id:e,source:r,target:i,data:Object.assign(Object.assign({},d),{labelShape:Object.assign(Object.assign({},p),f)})};return n&&(m.data.type=n.includes("-edge")?n:`${n}-edge`),o&&(m.data.keyShape=o),a&&(m.data.keyShape=m.data.keyShape||{},m.data.keyShape.lineWidth=a),s&&(m.data.keyShape=m.data.keyShape||{},m.data.keyShape.stroke=s),l&&(m.data.labelShape.text=l),g&&(m.data.labelBackgroundShape=g),m})),l=o.map((t=>{const{id:e,type:n,style:r,size:i,color:o,label:a,labelCfg:s={},icon:l,linkPoints:c}=t,u=Nc(t,["id","type","style","size","color","label","labelCfg","icon","linkPoints"]),{style:h={}}=s,d=Nc(s,["style"]),{background:p}=h,f={id:e,data:Object.assign(Object.assign({},u),{labelShape:Object.assign(Object.assign({},h),d)})};n&&(f.data.type=n.includes("-combo")?n:`${n}-combo`),r&&(f.data.keyShape=r);const g=LB(i);return g&&(f.data.keyShape=Object.assign(Object.assign({},f.data.keyShape),{r:null==g?void 0:g[0],width:null==g?void 0:g[0],height:null==g?void 0:g[1]})),o&&(f.data.keyShape=f.data.keyShape||{},f.data.keyShape.fill=o),a&&(f.data.labelShape.text=a),p&&(f.data.labelBackgroundShape=p),f}));return{nodes:a||[],edges:s||[],combos:l||[]}},ValidateData:(t,e={},n)=>{const{nodes:r,edges:i,combos:o}=t,a=new Map,s=new Map,l=new Map,c=(t,e,n=!1)=>void 0===t.id?n?void(t.id=`${e}-${gn()}`):(console.error(`Unique global id is neccessary for graph items. The ${e} ${JSON.stringify(t)} without id will be ignored.`),!1):a.has(t.id)?(console.error(`Unique global id is neccessary for graph nodes/edges/combos. The ${e} ${JSON.stringify(t)} with id ${t.id} is duplicated.`),!1):(void 0===t.data&&(t.data={}),!0),u=null==o?void 0:o.map((t=>!!c(t,"combo")&&(a.set(t.id,!0),l.set(t.id,!0),t))).filter(Boolean);null==u||u.forEach((t=>{const{parentId:e}=t.data;void 0===e||l.has(e)||n&&n.hasNode(e)||(console.error(`The parentId of combo with id ${t.id} will be removed since it is not exist in combos.`),delete t.data.parentId)}));const h=null==r?void 0:r.map((t=>{if(!c(t,"node"))return!1;const{parentId:e}=t.data;return void 0===e||l.has(e)||n&&n.hasNode(e)||(console.error(`The parentId of node with id ${t.id} will be removed since it is not exist in combos.`),delete t.data.parentId),a.set(t.id,!0),s.set(t.id,!0),t})).filter(Boolean),d=null==i?void 0:i.map((t=>{const{id:e}=t;let{source:r,target:i}=t;if(!c(t,"edge",!0))return!1;if(null==n?void 0:n.hasEdge(e)){const t=null==n?void 0:n.getEdge(e);void 0===r&&(r=t.source),void 0===i&&(i=t.target)}return void 0===r?(console.error(`The edge with id ${e} will be ignored since its source is undefined.`),!1):void 0===i?(console.error(`The edge with id ${e} will be ignored since its target is undefined.`),!1):s.has(r)||l.has(r)||n&&n.hasNode(r)?s.has(i)||l.has(i)||n&&n.hasNode(i)?(a.set(e,!0),t):(console.error(`The edge with id ${e} will be ignored since its target ${i} is not existed in nodes and combos.`),!1):(console.error(`The edge with id ${e} will be ignored since its source ${r} is not existed in nodes and combos.`),!1)})).filter(Boolean);return{nodes:h||[],edges:d||[],combos:u||[]}}});!function(t){t.rightTop="rightTop",t.right="right",t.rightBottom="rightBottom",t.bottomRight="bottomRight",t.bottom="bottom",t.bottomLeft="bottomLeft",t.leftBottom="leftBottom",t.left="left",t.leftTop="leftTop",t.topLeft="topLeft",t.top="top",t.topRight="topRight"}(FB||(FB={}));const GB=(t,e,n=1,r=!1)=>{const i=r?n:1,o=(t.max[0]-t.min[0])*i;return WB(o,e)},VB=(t,e,n=1)=>{const r=LP(t[0],t[1])*n;return WB(r,e)},WB=(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},zB=t=>Boolean((null==t?void 0:t.fields)&&t.formatter),HB=t=>{if(!t)return;const{levels:e,animateCfg:n}=t;if(!e)return;const r=e.find((t=>t.primary));if(!r)return;const i=e.indexOf(r),o={};return e.forEach(((t,e)=>{o[e-i]=t.zoomRange})),{animateCfg:n,levels:o}},jB=(t,e)=>{let n=0;return Object.keys(t).forEach((r=>{const i=t[r];e>=i[0]&&e<i[1]&&(n=Number(r))})),n};class XB{constructor(t){this.scaleTransformCache="",this.zoomCache={hiddenShape:{},zoom:1,zoomLevel:0,balanceRatio:1,levelShapes:{},wordWrapWidth:32,animateConfig:RR.zoom,firstRender:!0},this.onZoom=(t,e,n={})=>{var r,i,o;if(this.lodStrategy){const{levels:a}=this.lodStrategy,{levelShapes:s,hiddenShape:l,animateConfig:c,firstRender:u=!0,zoomLevel:h}=this.zoomCache,d=jB(a,e),p=Object.keys(s).map(Number),f=Math.max(...p),g=Math.min(...p);if(d<h)if(u)for(let e=d+1;e<=f;e++)null===(r=s[String(e)])||void 0===r||r.forEach((e=>{t[e]&&!n[e]&&(t[e].hide(),l[e]=!0)}));else for(let e=d+1;e<=f;e++)null===(i=s[String(e)])||void 0===i||i.forEach((e=>NR(e,t[e],l,c)));else if(d>h)for(let e=d;e>=g;e--)null===(o=s[String(e)])||void 0===o||o.forEach((e=>{wR(e,t[e],this.mergedStyles[e]||this.mergedStyles[e.replace("Background","")],l,c)}));this.zoomCache.zoomLevel=d}this.balanceShapeSize(t,e),this.zoomCache.zoom=e};const{themeStyles:e,lodStrategy:n,enableBalanceShape:r,zoom:i}=t;e&&(this.themeStyles=e),this.lodStrategy=n,this.enableBalanceShape=r,this.boundsCache={},this.zoomCache.zoom=i,this.zoomCache.balanceRatio=1/i,this.zoomCache.animateConfig=Object.assign(Object.assign({},RR.zoom),null==n?void 0:n.animateCfg)}mergeStyles(t){this.mergedStyles=this.getMergedStyles(t)}getMergedStyles(t){var e;const{data:n}=t,r={};Object.keys(n).forEach((t=>{gR.includes(t)?"badgeShapes"===t?(r[t]={},Object.keys(n[t]).forEach((e=>{if(isNaN(Number(e)))return void(r[t][e]=n[t][e]);const{position:i}=n[t][e];r[`${i}BadgeShape`]=Object.assign(Object.assign({},n[t][e]),{tag:"badgeShape"})}))):"anchorShapes"===t?Object.keys(n[t]).forEach((e=>{r[`anchorShape${e}`]=Object.assign(Object.assign({},n[t][e]),{tag:"anchorShape"})})):r[t]=n[t]:t===mR&&Object.keys(n[t]).forEach((e=>r[e]=n[t][e]))}));const i=zR([this.themeStyles,this.defaultStyles,r]),o=null===(e=i.labelBackgroundShape)||void 0===e?void 0:e.padding;return o&&(i.labelBackgroundShape.padding=WR(o)),i}updateCache(t){["keyShape","labelShape"].concat(Object.keys(FB)).map((t=>`${t}BadgeShape`)).forEach((e=>{const n=t[e];(null==n?void 0:n.getAttribute(LR))&&("labelShape"===e?this.boundsCache[`${e}Geometry`]=n.getGeometryBounds():this.boundsCache[`${e}Local`]=n.getLocalBounds(),n.setAttribute(LR,!1))}));const e={};if(Object.keys(t).forEach((n=>{const{lod:r}=t[n].attributes;void 0!==r&&(e[r]=e[r]||[],e[r].push(n))})),this.zoomCache.levelShapes=e,t.labelShape){const{maxWidth:e="200%"}=this.mergedStyles.labelShape||{};this.zoomCache.wordWrapWidth=GB(t.keyShape.getLocalBounds(),e,1)}}afterDraw(t,e,n){return{}}drawLabelShape(t,e,n,r){const{labelShape:i}=this.mergedStyles;if(!i||!i.text||!t.data.labelShape)return;const{keyShape:o}=e,a=JR(o,this.mergedStyles.keyShape,o.getLocalBounds()),{position:s,offsetX:l,offsetY:c,offsetZ:u,maxWidth:h,angle:d}=i,p=Nc(i,["position","offsetX","offsetY","offsetZ","maxWidth","angle"]),f=GB(a,h,this.zoomCache.zoom,this.enableBalanceShape),g={x:a.center[0],y:a.max[1],z:a.center[2],textBaseline:"top",textAlign:"center",offsetX:0,offsetY:0,offsetZ:0,wordWrapWidth:f};switch(s){case"center":g.y=a.center[1],g.textBaseline="middle";break;case"top":g.y=a.min[1],g.textBaseline="bottom",g.offsetY=-2;break;case"left":g.x=a.min[0],g.y=a.center[1],g.textAlign="right",g.textBaseline="middle",g.offsetX=-4;break;case"right":g.x=a.max[0],g.y=a.center[1],g.textAlign="left",g.textBaseline="middle",g.offsetX=4;break;default:g.offsetY=2}const m=void 0===l?g.offsetX:l,v=void 0===c?g.offsetY:c,y=void 0===u?g.offsetZ:u;g.x+=m,g.y+=v,g.z+=y;const E=Object.assign(Object.assign(Object.assign(Object.assign({},this.defaultStyles.labelShape),g),{isBillboard:!0}),p);return d&&(E.transform=`rotate(${d}rad)`),this.upsertShape("text","labelShape",E,e,t)}drawLabelBackgroundShape(t,e,n,r){const{labelShape:i}=e;if(!i||!i.style.text||!t.data.labelShape)return;this.boundsCache.labelShapeGeometry&&!i.getAttribute(LR)||(this.boundsCache.labelShapeGeometry=i.getGeometryBounds(),i.setAttribute(LR,!1));const{labelShapeGeometry:o}=this.boundsCache,a=o.max[1]-o.min[1],s=Math.min(o.max[0]-o.min[0]+2,i.attributes.wordWrapWidth),l=this.mergedStyles.labelBackgroundShape,{padding:c}=l,u=Nc(l,["padding"]),h=Object.assign(Object.assign({fill:"#fff"},u),{x:i.attributes.x+o.min[0]-c[3],y:i.attributes.y+o.min[1]-c[0],width:s+c[1]+c[3],height:a+c[0]+c[2]}),d=this.upsertShape("rect","labelBackgroundShape",h,e,t);return this.balanceShapeSize(e,this.zoomCache.zoom),d}drawIconShape(t,e,n,r){const{iconShape:i}=this.mergedStyles,{width:o,height:a,fontSize:s,text:l,offsetX:c=0,offsetY:u=0}=i,h=o||s,d=a||s,p=l?"text":"image";return"image"===p?(i.x=-h/2+c,i.y=-d/2+u,i.width=h,i.height=d):(i.textAlign="center",i.textBaseline="middle",i.x=c,i.y=u,i.fontSize=h),this.upsertShape(p,"iconShape",i,e,t)}drawHaloShape(t,e,n,r){const{keyShape:i}=e,{haloShape:o,keyShape:a}=this.mergedStyles;if(!1===o.visible)return;const{nodeName:s,attributes:l}=i,{x:c,y:u,fill:h}=l;return this.upsertShape(s,"haloShape",Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},l),a),{x:c,y:u,stroke:h}),o),{batchKey:"halo"}),e,t)}drawAnchorShapes(t,e,n,r){const{anchorShapes:i,keyShape:o}=this.mergedStyles,a=Object.values(this.mergedStyles).filter((t=>"anchorShape"===t.tag));if(!a.length)return;this.boundsCache.keyShapeLocal=this.boundsCache.keyShapeLocal||e.keyShape.getLocalBounds();const s={},l=this.calculateAnchorPosition(o);return a.forEach(((n,r)=>{const{position:a,fill:c=o.fill}=n,u=Nc(n,["position","fill"]),[h,d]=this.getAnchorPosition(a,l),p=`anchorShape${r}`;s[p]=this.upsertShape("circle",p,Object.assign(Object.assign({cx:h,cy:d,fill:c},i),u),e,t)})),s}getAnchorPosition(t,e){const n=this.boundsCache.keyShapeLocal,r=n.max[0]-n.min[0],i=n.max[1]-n.min[1],o=[n.max[0]-n.center[0],n.min[1]-n.center[1]];return t instanceof Array?[r*(t[0]-.5),i*(t[1]-.5)]:"string"==typeof t?e[t=t.toLowerCase()]||e.default||o:e.default||o}calculateAnchorPosition(t){const e=t.x,n=t.y,r=t.r,i={};return i.top=[e,n-r],i.left=[e-r,n],i.right=i.default=[e+r,n],i.bottom=[e,n+r],i}drawBadgeShapes(t,e,n,r){const{badgeShapes:i,keyShape:o}=this.mergedStyles,a=Object.values(this.mergedStyles).filter((t=>"badgeShape"===t.tag));if(!a.length)return{};const s=JR(e.keyShape,o,e.keyShape.getLocalBounds()),l=Math.min(s.max[0]-s.min[0],s.max[1]-s.min[1]),c={};return a.forEach(((n,r)=>{const{position:o}=n,a=Nc(n,["position"]),u=`${o}BadgeShape`,h=Object.assign(Object.assign({},i),a),d=i.palette?i.palette[r%i.palette.length]:"#7E92B5",{text:p="",type:f,color:g=d,size:m=l/3,textColor:v,zIndex:y=2,offsetX:E=0,offsetY:_=0}=h,b=Nc(h,["text","type","color","size","textColor","zIndex","offsetX","offsetY"]),S=m,x={x:0,y:0};switch(o){case"rightTop":case"topRight":x.x=s.max[0]/2+E,x.y=.44*s.min[1]-S+_;break;case"right":x.x=s.max[0]/2+E,x.y=-S/2+_;break;case"rightBottom":case"bottomRight":x.x=s.max[0]/2+E,x.y=.44*s.max[1]+_;break;case"leftTop":case"topLeft":x.x=s.min[0]/2+E,x.y=.44*s.min[1]-S+_;break;case"left":x.x=s.min[0]/2+E,x.y=-S/2+_;break;case"leftBottom":case"bottomLeft":x.x=s.min[0]/2+E,x.y=.44*s.max[1]+_;break;case"top":x.x=E,x.y=.44*s.min[1]-S+_;break;default:x.x=E,x.y=.44*s.max[1]+_}const T=o.toLowerCase(),A=T.includes("left"),R=!A&&!T.includes("right"),M=S-3;let C=A?"right":"left",P=A?x.x-3:x.x+2;R&&(C="center",P=x.x),c[u]=this.upsertShape("text",u,Object.assign(Object.assign({text:p,fill:v,fontSize:M,x:P,y:x.y+S/2},b),{textAlign:C,textBaseline:"middle",zIndex:y+1}),e,t),this.boundsCache[`${u}Local`]=c[u].getLocalBounds();const w=this.boundsCache[`${u}Local`],N=`${o}BadgeBackgroundShape`,O=p.length<=1?S:Math.max(S,w.max[0]-w.min[0])+8;c[N]=this.upsertShape("rect",N,Object.assign({text:p,fill:g,height:S,width:O,radius:S/2,zIndex:y,x:w.center[0]-O/2,y:w.center[1]-S/2},b),e,t)})),c}drawOtherShapes(t,e,n,r){return{}}balanceShapeSize(t,e){if(!this.enableBalanceShape)return;const{keyShape:n,labelShape:r,labelBackgroundShape:i}=t,o=1/e||1;if(this.zoomCache.balanceRatio=o,!r||!r.isVisible())return;const{position:a="bottom"}=this.mergedStyles.labelShape,s=n.getLocalBounds();if(e<1)r.style.transformOrigin="bottom"===a?"0":"";else switch(a){case"bottom":r.style.transformOrigin="0 "+(s.max[1]-r.attributes.y);break;case"right":r.style.transformOrigin=s.max[0]-r.attributes.x+" 0";break;case"top":r.style.transformOrigin="0 "+(s.min[1]-r.attributes.y);break;case"left":r.style.transformOrigin=s.min[0]-r.attributes.x+" 0";break;default:r.style.transformOrigin=""}const l=(r.style.transform||"").replace(this.scaleTransformCache,""),c=`scale(${o}, ${o})`;if(r.style.transform=`${l} ${c}`,this.scaleTransformCache=c,r.style.wordWrapWidth=this.zoomCache.wordWrapWidth*e,!i||!i.isVisible())return;const[u,h,d,p]=this.mergedStyles.labelBackgroundShape.padding,f=h+p,{width:g,height:m,x:v,y:y}=i.attributes;switch(a){case"top":i.style.transformOrigin=`${p+(g-f)/2} ${e<1?m-d:s.min[1]-y}`;break;case"left":i.style.transformOrigin=`${e<1?g-h:s.min[0]-v} ${u+(m-u-d)/2}`;break;case"right":i.style.transformOrigin=`${e<1?p:s.max[0]-v} ${u+(m-u-d)/2}`;break;case"bottom":i.style.transformOrigin=`${p+(g-f)/2} ${e<1?u+(m-u-d)/2:s.max[1]-y}`;break;default:i.style.transformOrigin=`${p+(g-f)/2} ${u+(m-u-d)/2}`}const{labelShapeGeometry:E}=this.boundsCache,_=((E.max[0]-E.min[0])*o+f)/g;i.style.transform=`scale(${_}, ${o})`}upsertShape(t,e,n,r,i){return GR(t,e,n,r,i)}}var YB=Object.freeze({__proto__:null,CircleCombo:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:16,x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("circle","keyShape",this.mergedStyles.keyShape,e,t)}},RectCombo:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{x:0,y:0,width:32,height:32}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("rect","keyShape",this.mergedStyles.keyShape,e,t)}getMergedStyles(t){const e=super.getMergedStyles(t);return e.keyShape.x=e.keyShape.x-e.keyShape.width/2,e.keyShape.y=e.keyShape.y-e.keyShape.height/2,e}}});const KB={sphere:dg,cube:hg,plane:pg},qB=10,$B=(t,e,n,r)=>{if(!KB[t])return FR(t,e,n);const i=e,{materialType:o="lambert"}=i,a=Nc(i,["materialType"]);r.GeometryCache||(r.GeometryCache={});let s=r.GeometryCache[t];if(s||(s=r.GeometryCache[t]=new KB[t](r,{radius:qB,latitudeBands:32,longitudeBands:32})),r.MaterialCache||(r.MaterialCache={}),!r.MaterialCache[o])switch(o){case"basic":r.MaterialCache[o]=new yg(r);break;case"phong":{const t={shininess:30};r.MaterialCache[o]=new _g(r,t)}default:r.MaterialCache[o]=new Sg(r)}const l=new Vh({style:Object.assign(Object.assign({visibility:"visible",strokeOpacity:0},a),{geometry:s,material:r.MaterialCache[o]}),id:n});switch(l.setOrigin(0,0,0),t){case"cube":l.scale([e.width/qB,e.height/qB,e.depth/qB]);break;case"plane":l.scale([e.width/qB,e.depth/qB]);break;default:{const t=(e.r||e.radius)/qB;l.scale(t)}}return l};class ZB extends XB{constructor(t){super(t),this.dimensions=3,this.onZoom=(t,e)=>{},this.device=t.device}drawLabelShape(t,e,n,r){const{keyShape:i}=e,{r:o,width:a,height:s,depth:l,x:c,y:u,z:h}=i.attributes,d={center:[c,u,h],min:[c-o||a/2,u-o||s/2,h-o||l/2],max:[c+o||a/2,u+o||s/2,h+o||l/2]},{labelShape:p}=this.mergedStyles,{position:f,offsetX:g,offsetY:m,maxWidth:v}=p,y=Nc(p,["position","offsetX","offsetY","maxWidth"]),E={x:d.center[0],y:d.max[1],z:d.center[2],textBaseline:"top",textAlign:"center",offsetX:0,offsetY:0};switch(f){case"top":E.y=d.min[1],E.textBaseline="bottom",E.offsetY=-4;break;case"left":E.x=d.min[0],E.y=d.center[1],E.textAlign="right",E.textBaseline="middle",E.offsetX=-8;break;case"right":E.x=d.max[0],E.y=d.center[1],E.textAlign="left",E.textBaseline="middle",E.offsetX=8;break;default:E.offsetY=4}const _=void 0===g?E.offsetX:g,b=void 0===m?E.offsetY:m;E.x+=_,E.y+=b;const S=Object.assign(Object.assign(Object.assign(Object.assign({},this.defaultStyles.labelShape),E),{isBillboard:!0}),y);return this.upsertShape("text","labelShape",S,e)}drawIconShape(t,e,n,r){return super.drawIconShape(t,e,n,r)}drawHaloShape(t,e,n,r){const{keyShape:i}=e,{haloShape:o}=this.mergedStyles;if(!1===o.visible)return;const{nodeName:a,attributes:s}=i;return this.upsertShape(a,"haloShape",Object.assign(Object.assign(Object.assign({},s),{stroke:s.fill}),o),e)}drawAnchorShapes(t,e,n,r){return{}}drawBadgeShapes(t,e,n,r){return super.drawBadgeShapes(t,e,n,r)}drawOtherShapes(t,e,n,r){return{}}upsertShape(t,e,n,r){return((t,e,n,r,i)=>{let o=r[e];if(o)if(o.nodeName!==t)o.remove(),o=$B(t,n,e,i),o.setAttribute(LR,!0);else{const e={},r=o.attributes;Object.keys(n).forEach((t=>{r[t]!==n[t]&&(e[t]=n[t],o.style[t]=n[t])})),QR(t,e)&&o.setAttribute(LR,!0)}else o=$B(t,n,e,i),o.setAttribute(LR,!0);return r[e]=o,o})(t,e,n,r,this.device)}}const QB={horizontal:0,vertical:Math.PI/2};const JB=["#61DDAA","#65789B","#F6BD16","#7262FD","#78D3F8","#9661BC","#F6903D","#008685","#F08BB4"];const tk=(t,e)=>[t*Math.cos(e),-t*Math.sin(e)],ek=(t,e)=>{let n=0;const r=[];return Object.keys(t).forEach((i=>{const o=+t[i];isNaN(o)||(r.push({key:i,value:o,color:e[i]}),n+=o)})),{totalValue:n,configs:r}},nk=(t,e)=>{const n=t.attr("r"),r=e*n;return{lineWidth:n-r,arcR:(n+r)/2}};var rk=Object.freeze({__proto__:null,CircleNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:16,x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&this.drawLabelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&this.drawLabelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes&&this.drawAnchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&this.drawIconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes&&this.drawBadgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("circle","keyShape",this.mergedStyles.keyShape,e,t)}},SphereNode:class extends ZB{constructor(t){super(t),this.defaultStyles={keyShape:{r:5,latitudeBands:32,longitudeBands:32,x:0,y:0,z:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("sphere","keyShape",this.mergedStyles.keyShape,e)}},RectNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{x:0,y:0,width:32,height:32}}}drawKeyShape(t,e,n,r){return this.upsertShape("rect","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{x:this.mergedStyles.keyShape.x-this.mergedStyles.keyShape.width/2,y:this.mergedStyles.keyShape.y-this.mergedStyles.keyShape.height/2}),e,t)}calculateAnchorPosition(t){const e=t.x,n=t.y,r=t.height,i=t.width,o={};return o.top=[e,n-r/2],o.left=[e-i/2,n],o.right=o.default=[e+i/2,n],o.bottom=[e,n+r/2],o}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}},StarNode:class extends XB{constructor(t){super(t),this.defaultOuterR=20,this.defaultStyles={keyShape:{outerR:this.defaultOuterR,innerR:3*this.defaultOuterR/8,x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){const{keyShape:i}=this.mergedStyles,o=this.getStarPath(i.outerR,i.innerR);return this.upsertShape("path","keyShape",Object.assign(Object.assign({},i),{path:o}),e,t)}getStarPath(t,e){return[["M",0,-t],["L",e*Math.cos(3*Math.PI/10),-e*Math.sin(3*Math.PI/10)],["L",t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],["L",e*Math.cos(Math.PI/10),e*Math.sin(Math.PI/10)],["L",t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],["L",0,e],["L",-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],["L",-e*Math.cos(Math.PI/10),e*Math.sin(Math.PI/10)],["L",-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],["L",-e*Math.cos(3*Math.PI/10),-e*Math.sin(3*Math.PI/10)],"Z"]}calculateAnchorPosition(t){const e={},n=t.outerR,r=t.innerR;return e.top=[0,-n],e.left=[-n*Math.cos(Math.PI/10),-n*Math.sin(Math.PI/10)],e.leftbottom=[-n*Math.cos(3*Math.PI/10),n*Math.sin(3*Math.PI/10)],e.bottom=[0,r],e.rightbottom=[n*Math.cos(3*Math.PI/10),n*Math.sin(3*Math.PI/10)],e.right=e.default=[n*Math.cos(Math.PI/10),-n*Math.sin(Math.PI/10)],e}},HexagonNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:16,x:0,y:0,direction:"vertical"}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){const{keyShape:i}=this.mergedStyles;return this.upsertShape("polygon","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{points:this.getHexagonPoints(i.r,i.direction)}),e,t)}getHexagonPoints(t,e){const n=Math.PI/3,r=[];for(let i=0;i<6;i++){const o=i*n+QB[e],a=t*Math.cos(o),s=t*Math.sin(o);r.push([a,s])}return r}calculateAnchorPosition(t){const e="horizontal"===t.direction?["right","rightbottom","leftbottom","left","lefttop","righttop"]:["bottom","leftbottom","lefttop","top","righttop","rightbottom"],n=Math.PI/3,r=QB[t.direction],i=t.r,o={};for(let t=0;t<6;t++){const a=t*n+r,s=i*Math.cos(a),l=i*Math.sin(a);o[e[t]]=[s,l]}return o.hasOwnProperty("default")||(o.default=o[e[0]]),o}},TriangleNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:12,x:0,y:0,direction:"up"}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){const{keyShape:i}=this.mergedStyles;return this.upsertShape("path","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{path:this.getTrianglePath(i.r,i.direction)}),e,t)}getTrianglePath(t,e){const n=3*t/2,r=3*t/Math.sin(1/3*Math.PI)/2;let i;return i="down"===e?[["M",0,n],["L",r,-n],["L",-r,-n],["Z"]]:"left"===e?[["M",-n,0],["L",n,r],["L",n,-r],["Z"]]:"right"===e?[["M",n,0],["L",-n,r],["L",-n,-r],["Z"]]:[["M",0,-n],["L",r,n],["L",-r,n],["Z"]],i}drawIconShape(t,e,n,r){const{keyShape:i}=this.mergedStyles,{iconShape:o}=this.mergedStyles;let a=0,s=i.r/4;"right"===i.direction?(a=-i.r/4,s=0):"left"===i.direction?(a=i.r/4,s=0):"down"===i.direction&&(a=0,s=-i.r/4);const{width:l,height:c,fontSize:u,text:h,offsetX:d=0,offsetY:p=0}=o,f=l||u,g=c||u,m=h?"text":"image";return"image"===m?(o.x=-f/2+d+a,o.y=-g/2+p+s,o.width=f,o.height=g):(o.textAlign="center",o.textBaseline="middle",o.x=d+a,o.y=p+s,o.fontSize=f),this.upsertShape(m,"iconShape",o,e,t)}calculateAnchorPosition(t){const e=t.direction,n=t.r,r=3*n/2,i=3*n/Math.sin(1/3*Math.PI)/2,o={};return"down"===e?(o.bottom=[0,r],o.right=o.default=[i,-r],o.left=[-i,-r]):"left"===e?(o.top=[r,-i],o.bottom=[r,i],o.left=o.default=[-r,0]):"right"===e?(o.top=[-r,-i],o.bottom=[-r,i],o.right=o.default=[r,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]),o}},EllipseNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{rx:16,ry:12,x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("ellipse","keyShape",this.mergedStyles.keyShape,e,t)}calculateAnchorPosition(t){const e=t.x,n=t.y,r={};return r.top=[e,n-t.ry],r.left=[e-t.rx,n],r.right=r.default=[e+t.rx,n],r.bottom=[e,n+t.ry],r}},DonutNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{r:16,x:0,y:0},donutShapes:{innerSize:.6,attrs:{},colorMap:{},zIndex:1}},this.drawDonutSegment=(t,e,n,r,i,o)=>{const{arcR:a,beginAngle:s,config:l,index:c,lineWidth:u,zIndex:h,totalValue:d,drawWhole:p=!1}=t,f=`donutShape${c}`,g=l.value/d;if(g<.001)return{beginAngle:s,shouldEnd:!1};let m,v,y;const E=tk(a,s);if(p||g>.999)m=[a,1e-4],y=1;else{const t=g*Math.PI*2;v=s+t,m=tk(a,v),y=t>Math.PI?1:0}const _={path:[["M",E[0],E[1]],["A",a,a,0,y,0,m[0],m[1]]],stroke:l.color||JB[c%JB.length],lineWidth:u,zIndex:h};return e[f]=this.upsertShape("path",f,_,r,n),{beginAngle:v,shouldEnd:p||g>.999}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.donutShapes){const i=this.drawDonutShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawDonutShapes(t,e,n,r){const{donutShapes:{innerSize:i,attrs:o,colorMap:a,zIndex:s}}=this.mergedStyles,l=Object.keys(o).length;if(!l)return;const{configs:c,totalValue:u}=ek(o,a);if(!u)return;const{lineWidth:h,arcR:d}=nk(e.keyShape,i);let p=0;const f={};return Ce(c,((i,o)=>{const a=this.drawDonutSegment({arcR:d,beginAngle:p,config:i,index:o,lineWidth:h,zIndex:s,totalValue:u,drawWhole:1===l},f,t,e,n,r);a.shouldEnd||(p=a.beginAngle)})),f}drawKeyShape(t,e,n,r){return this.upsertShape("circle","keyShape",this.mergedStyles.keyShape,e,t)}},DiamondNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{size:[32,32],x:0,y:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){const{keyShape:i}=this.mergedStyles;return this.upsertShape("path","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{path:this.getDiamondPath(i)}),e,t)}getDiamondPath(t){const e=t.size[0],n=t.size[1];return[["M",0,-n/2],["L",e/2,0],["L",0,n/2],["L",-e/2,0],["Z"]]}calculateAnchorPosition(t){const e={},n=t.size[0],r=t.size[1];return e.bottom=[0,r/2],e.left=[-n/2,0],e.right=e.default=[n/2,0],e.top=[0,-r/2],e}},ModelRectNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{x:0,y:0,width:185,height:70,stroke:"#C0DCEA",strokeWidth:"2",radius:2,fill:"white"}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),o}drawKeyShape(t,e,n,r){const{x:i,y:o,height:a,width:s}=this.mergedStyles.keyShape;return this.upsertShape("rect","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{x:i-s/2,y:o-a/2}),e,t)}calculateAnchorPosition(t){const e=t.x,n=t.y,r=t.height,i=t.width,o=e-i/2-(this.mergedStyles.preRect?5:0),a={};return a.top=[e,n-r/2],a.left=[o,n],a.right=a.default=[e+i/2,n],a.bottom=[e,n+r/2],a}drawLabelShape(t,e,n,r){const{labelShape:i,description:o,keyShape:a}=this.mergedStyles;if(!i)return;const{width:s,height:l,x:c,y:u}=a,{offsetX:h=0,offsetY:d=0}=i,p=!(!i||!o),f=p?Math.min(l,s)/5:Math.min(l,s)/6,g=p?this.logoX+this.logoWidth+s/20:0,m=p?0-l/7:0,v=s/2-(this.logoX+this.logoWidth+s/20)-2*f;return i.maxWidth=v,this.upsertShape("text","labelShape",Object.assign({wordWrap:!0,textOverflow:"ellipsis",textBaseline:"middle",textAlign:p?"left":"middle",x:g+h,y:m+d,maxLines:1,wordWrapWidth:v},i),e,t)}drawOtherShapes(t,e,n,r){const{logoIcon:i,preRect:o,stateIcon:a,description:s,label:l,keyShape:c}=this.mergedStyles;return Object.assign(Object.assign(Object.assign(Object.assign({},this.drawPreRectShape(o,c,t,e)),this.drawLogoIconShape(i,c,t,e)),this.drawDescriptionShape(s,c,t,e)),this.drawStateIcon(a,c,t,e))}drawPreRectShape(t,e,n,r){if(!t)return;const{x:i,y:o,height:a,width:s}=e,{width:l=5,fill:c="#5CAAF8"}=t;return{otherShapePreRect:this.upsertShape("rect","otherShapePreRect",{width:l,height:a,x:i-s/2-l,y:o-a/2,fill:c,radius:2},r,n)}}drawLogoIconShape(t,e,n,r){const{x:i,y:o,width:a,height:s}=e;if(!t)return this.logoWidth=16,this.logoHeight=16,this.logoX=i-a/2+a/10-this.logoWidth/2,void(this.logoY=o-this.logoHeight/2);const{width:l=16,height:c=16,fontSize:u,text:h,offsetX:d=0,offsetY:p=0}=t,f=this.logoWidth=l||u,g=this.logoHeight=l||u,m=h?"text":"image",v=this.logoX=i-a/2+d+a/10-l/2,y=this.logoY=h?p:o-c/2+p;h&&(t.textAlign="center",t.textBaseline="middle");const E={};return E.otherShapeLogoIcon=this.upsertShape(m,"otherShapeLogoIcon",Object.assign({width:f,height:g,x:v,y:y},t),r,n),E}drawDescriptionShape(t,e,n,r){if(!t)return;const{width:i,height:o}=e,{text:a,fontSize:s,offsetX:l=0,offsetY:c=0}=t,u=Math.min(o,i)/5,h=this.logoX+this.logoWidth+i/20,d=i/2-h-2*u,p=u/2;return{otherShapeDescription:this.upsertShape("text","otherShapeDescription",Object.assign({textBaseline:"middle",textAlign:"left",fontSize:p,x:h+l,y:0+o/6+c,wordWrap:!0,wordWrapWidth:d,maxLines:1,textOverflow:"ellipsis",fill:"#C2C2C2"},t),r,n)}}drawStateIcon(t,e,n,r){if(!t)return;const{x:i,y:o,width:a}=e,{width:s=16,height:l=16,fontSize:c,text:u,offsetX:h=0,offsetY:d=0}=t,p=s||c,f=s||c,g=u?"text":"image",m=i+a/2-a/10+h,v=u?d:o-(l||c)/2+d;return u&&(t.textAlign="center",t.textBaseline="middle"),{otherShapestateIcon:this.upsertShape(g,"otherShapestateIcon",Object.assign({width:p,height:f,x:m,y:v},t),r,n)}}},ImageNode:class extends XB{constructor(t){super(t),this.defaultStyles={keyShape:{x:0,y:0,width:32,height:32}}}drawKeyShape(t,e,n,r){var i;const o=null===(i=this.mergedStyles.keyShape)||void 0===i?void 0:i.clipCfg;let a;if(o){const{type:t}=o,e=Nc(o,["type"]);a=new BR[t],a.attr(e)}const s=this.upsertShape("image","keyShape",Object.assign(Object.assign({},this.mergedStyles.keyShape),{x:this.mergedStyles.keyShape.x,y:this.mergedStyles.keyShape.y,anchor:"0.5 0.5"}),e,t);return a&&(s.appendChild(a),s.attr("clipPath",a)),s}calculateAnchorPosition(t){const e=t.x,n=t.y,r=t.height,i=t.width,o={};return o.top=[e,n-r/2],o.left=[e-i/2,n],o.right=o.default=[e+i/2,n],o.bottom=[e,n+r/2],o}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.anchorShapes){const i=this.drawAnchorShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}if(i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawHaloShape(t,e,n,r){var i;const{keyShape:o}=e,{haloShape:a,keyShape:s}=this.mergedStyles;if(!1===(null==a?void 0:a.visible))return;const l=(null===(i=null==a?void 0:a.clipCfg)||void 0===i?void 0:i.type)||"rect",{attributes:c}=o,{x:u,y:h,fill:d}=c;return this.upsertShape(l,"haloShape",Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),s),{x:u,y:h,stroke:d}),a),{fill:"transparent",batchKey:"halo"}),e,t)}},CubeNode:class extends ZB{constructor(t){super(t),this.defaultStyles={keyShape:{latitudeBands:32,longitudeBands:32,width:10,height:10,depth:10,x:0,y:0,z:0}}}draw(t,e,n,r){const{data:i={}}=t;let o={keyShape:void 0};if(o.keyShape=this.drawKeyShape(t,e,n),i.haloShape&&this.drawHaloShape&&(o.haloShape=this.drawHaloShape(t,e,n)),i.labelShape&&(o.labelShape=this.drawLabelShape(t,e,n)),i.labelBackgroundShape&&(o.labelBackgroundShape=this.drawLabelBackgroundShape(t,e,n)),i.iconShape&&(o.iconShape=this.drawIconShape(t,e,n)),i.badgeShapes){const i=this.drawBadgeShapes(t,e,n,r);o=Object.assign(Object.assign({},o),i)}return i.otherShapes&&this.drawOtherShapes&&(o=Object.assign(Object.assign({},o),this.drawOtherShapes(t,e,n))),o}drawKeyShape(t,e,n,r){return this.upsertShape("cube","keyShape",this.mergedStyles.keyShape,e)}},BaseNode:XB,BaseNode3D:ZB});const ik=(t,e,n)=>{switch(t){case"triangle":default:return`M 0,0 L ${e},-${n/2} L ${e},${n/2} Z`;case"circle":{const t=Math.max(e,n)/2;return`M 0, 0\n a ${t},${t} 0 1,0 ${2*t},0\n a ${t},${t} 0 1,0 ${2*-t},0`}case"diamond":return`M 0,0 \n L ${e/2},${-n/2} \n L ${e},0 \n L ${e/2},${n/2} Z`;case"vee":return`M 0,0 L ${e},-${n/2}\n L ${2*e/3},0 L ${e},${n/2} Z`;case"rect":return`M 0,${-n/2} \n L ${e},${-n/2} \n L ${e},${n/2} \n L 0,${n/2} Z`;case"triangle-rect":{const t=e/2,r=e/7,i=e-r;return`M 0,0 L ${t},-${n/2} L ${t},${n/2} Z\n M ${i}, -${n/2}\n L ${i+r} -${n/2}\n L ${i+r} ${n/2}\n L ${i} ${n/2}\n Z`}case"simple":return`M ${e},-${n/2} L 0,0 L ${e},${n/2}`}},ok={type:"triangle",width:10,height:10};class ak{constructor(t){this.defaultStyles={},this.zoomCache={hiddenShape:{},balanceRatio:1,zoom:1,zoomLevel:0,levelShapes:{},wordWrapWidth:50,animateConfig:RR.zoom,firstRender:!0},this.onZoom=(t,e,n={})=>{var r,i,o;if(this.balanceShapeSize(t,e),!this.lodStrategy)return;const{levels:a}=this.lodStrategy,{levelShapes:s,hiddenShape:l,animateConfig:c,firstRender:u=!0,zoomLevel:h}=this.zoomCache,d=jB(a,e),p=Object.keys(s).map(Number),f=Math.max(...p),g=Math.min(...p);if(d<h)if(u)for(let e=d+1;e<=f;e++)null===(r=s[String(e)])||void 0===r||r.forEach((e=>{var r;t[e]&&!n[e]&&(null===(r=t[e])||void 0===r||r.hide())}));else for(let e=d+1;e<=f;e++)null===(i=s[String(e)])||void 0===i||i.forEach((e=>NR(e,t[e],l,c)));else if(d>h)for(let e=d;e>=g;e--)null===(o=s[String(e)])||void 0===o||o.forEach((e=>{l[e]||wR(e,t[e],this.mergedStyles[e]||this.mergedStyles[e.replace("Background","")],l,c)}));this.zoomCache.zoom=e,this.zoomCache.zoomLevel=d,this.zoomCache.firstRender=!1};const{themeStyles:e,lodStrategy:n,zoom:r}=t;e&&(this.themeStyles=e),this.lodStrategy=n,this.boundsCache={},this.zoomCache.zoom=r,this.zoomCache.balanceRatio=1/r,this.zoomCache.animateConfig=Object.assign(Object.assign({},RR.zoom),null==n?void 0:n.animateCfg)}mergeStyles(t){this.mergedStyles=this.getMergedStyles(t)}getMergedStyles(t){var e;const{data:n}=t,r={};Object.keys(n).forEach((t=>{gR.includes(t)?r[t]=n[t]:t===mR&&Object.keys(n[t]).forEach((e=>r[e]=n[t][e]))}));const i=zR([this.themeStyles,this.defaultStyles,r]),o=null===(e=i.labelBackgroundShape)||void 0===e?void 0:e.padding;return o&&(i.labelBackgroundShape.padding=WR(o,vR)),i}updateCache(t){["labelShape","labelBackgroundShape"].forEach((e=>{const n=t[e];(null==n?void 0:n.getAttribute(LR))&&(this.boundsCache[`${e}Geometry`]=n.getGeometryBounds(),this.boundsCache[`${e}Transform`]=n.style.transform,n.setAttribute(LR,!1))}));const{zoom:e}=this.zoomCache,n={};Object.keys(t).forEach((e=>{const{lod:r}=t[e].attributes;void 0!==r&&(n[r]=n[r]||[],n[r].push(e))})),this.zoomCache.levelShapes=n;const{maxWidth:r="60%"}=this.mergedStyles.labelShape||{};this.zoomCache.wordWrapWidth=VB([this.sourcePoint,this.targetPoint],r,1),this.zoomCache.zoom=1,this.zoomCache.zoomLevel=0,1!==e&&this.onZoom(t,e)}afterDraw(t,e,n){return{}}drawLabelShape(t,e,n,r){const{keyShape:i}=e,{labelShape:o}=this.mergedStyles;if(!o||!o.text||!t.data.labelShape)return;const{position:a,offsetX:s,offsetY:l,autoRotate:c=!0,maxWidth:u}=o,h=Nc(o,["position","offsetX","offsetY","autoRotate","maxWidth"]),d={textAlign:"center",offsetX:0,offsetY:0,pointRatio:[.5,.501]};switch(Ue(a)&&(d.pointRatio=[a,a+.01]),a){case"start":d.pointRatio=[0,.01],d.textAlign="left",d.offsetX=4;break;case"end":d.pointRatio=[.99,1],d.textAlign="right",d.offsetX=-4}const p=i.getPoint(d.pointRatio[0]);let f={x:p.x,y:p.y},g=!1;if(c){const t=i.getPoint(d.pointRatio[1]);let e=Math.atan((p.y-t.y)/(p.x-t.x));isNaN(e)&&(e=0),g=t.x<p.x,g&&("start"===a?(d.textAlign="right",d.offsetX=-4):"end"===a&&(d.textAlign="left",d.offsetX=4));const n=void 0===s?d.offsetX:s,r=void 0===l?d.offsetY:l,o={x:p.x+n*Math.cos(e),y:p.y+n*Math.sin(e)};f={x:o.x+r*Math.cos(Math.PI-e),y:o.y+r*Math.sin(Math.PI-e),transform:`rotate(${e/Math.PI*180})`}}this.labelPosition=Object.assign(Object.assign({},f),{isRevert:g});const m=VB([this.sourcePoint,this.targetPoint],u,this.zoomCache.zoom);this.zoomCache.wordWrapWidth=m;const v=Object.assign(Object.assign(Object.assign(Object.assign({},this.defaultStyles.labelShape),{textAlign:d.textAlign,wordWrapWidth:m,isBillboard:!0}),f),h);return this.boundsCache.labelShapeTransform=v.transform,this.upsertShape("text","labelShape",v,e,t)}drawLabelBackgroundShape(t,e,n,r){const{labelShape:i}=e;if(!i||!i.style.text||!t.data.labelShape)return;const{labelBackgroundShape:o,labelShape:a}=this.mergedStyles,s=this.boundsCache.labelShapeGeometry||i.getGeometryBounds(),{x:l,y:c,transform:u,isRevert:h}=this.labelPosition,{padding:d}=o,p=Nc(o,["padding"]),{balanceRatio:f=1}=this.zoomCache,g=s.max[0]-s.min[0],m=s.max[1]-s.min[1],v=Object.assign(Object.assign({fill:"#fff"},p),{x:s.min[0]-d[3]+l,y:s.min[1]-d[0]/f+c,width:g+d[1]+d[3],height:m+(d[0]+d[2])/f,transform:u});return"start"===a.position?v.transformOrigin=h?`${v.width-d[1]} ${v.height/2}`:`${d[3]} ${v.height/2}`:"end"===a.position?v.transformOrigin=h?`${d[3]} ${v.height/2}`:`${v.width-d[1]} ${v.height/2}`:v.transformOrigin=`${g/2+d[3]} ${m/2+d[0]}`,this.upsertShape("rect","labelBackgroundShape",v,e,t)}drawIconShape(t,e,n,r){const{labelShape:i,labelBackgroundShape:o,keyShape:a}=e,{iconShape:s,labelShape:l}=this.mergedStyles,{width:c,height:u,fontSize:h,text:d,offsetX:p=0,offsetY:f=0}=s,g=c||h,m=u||h,v=d?"text":"image";if("text"===v?(s.textAlign="left",s.textBaseline="top",s.fontSize=g):(s.width=g,s.height=m),l){const t=o||i,e=this.boundsCache.labelBackgroundShapeGeometry||this.boundsCache.labelShapeGeometry||t.getGeometryBounds(),{min:n,max:r,halfExtents:a}=e,l=r[1]-n[1],c=r[0]-n[0],{x:u,y:h,transform:d}=t.attributes,{textAlign:v}=i.attributes;s.x=n[0]-g+4+u+p,s.y=n[1]+(l-m)/2+h+f,d&&(s.transform=d,s.transformOrigin="right"===v?`${c/2-g/2+4+a[0]-p} ${m/2-f}`:"left"===v?`${g+4-p} ${m/2-f}`:`${(g+c)/2-p} ${m/2-f}`)}else{const t=a.getPoint(.5);s.x=t.x+p,s.y=t.y+f}return this.upsertShape(v,"iconShape",s,e,t)}drawHaloShape(t,e,n,r){const{keyShape:i}=e,{haloShape:o}=this.mergedStyles;if(!1===o.visible)return;const{nodeName:a,attributes:s}=i;return this.upsertShape(a,"haloShape",Object.assign(Object.assign(Object.assign({},s),{stroke:s.stroke}),o),e,t)}drawOtherShapes(t,e,n,r){return{}}balanceShapeSize(t,e){const{labelShape:n,labelBackgroundShape:r}=t,i=1/e||1;this.zoomCache.balanceRatio=i;const{labelShape:o={}}=this.mergedStyles,{position:a="bottom"}=o;if(!n)return;n.style.transformOrigin="bottom"===a?"0":"";const s=this.boundsCache.labelShapeTransform;n.style.transform=`${s} scale(${i}, ${i})`;const l=this.zoomCache.wordWrapWidth*e;if(n.style.wordWrapWidth=l,!r)return;const c=this.boundsCache.labelBackgroundShapeTransform;r.style.transform=`${c} scale(${i}, ${i})`}setSourcePoint(t){this.sourcePoint=t}setTargetPoint(t){this.targetPoint=t}setNodeMap(t){this.nodeMap=t}upsertArrow(t,e,n,r,i){const o="marker"+("start"===t?"Start":"End");if(!e)return i[o]=null,void(i[`${o}Offset`]=0);const a=Ke(e)?Object.assign({},ok):e,{type:s="triangle",width:l=10,height:c=10,path:u,offset:h=0}=a,d=Nc(a,["type","width","height","path","offset"]);i[o]=this.upsertShape("path",`${o}Shape`,Object.assign(Object.assign(Object.assign({},n),{fill:"simple"===s?"":n.stroke,path:u||ik(s,l,c),anchor:"0.5 0.5",transformOrigin:"center"}),d),{},r),i[`${o}Offset`]=l/2+h}upsertShape(t,e,n,r,i){return GR(t,e,n,r,i)}}class sk extends ak{constructor(t){super(t),this.type="line-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}}}draw(t,e,n,r,i,o){const{data:a={}}=t;let s={keyShape:void 0};return s.keyShape=this.drawKeyShape(t,e,n,r,i),a.haloShape&&(s.haloShape=this.drawHaloShape(t,r,i)),a.labelShape&&(s.labelShape=this.drawLabelShape(t,r,i)),a.labelBackgroundShape&&(s.labelBackgroundShape=this.drawLabelBackgroundShape(t,r,i)),a.iconShape&&(s.iconShape=this.drawIconShape(t,r,i)),a.otherShapes&&(s=Object.assign(Object.assign({},s),this.drawOtherShapes(t,r,i))),s}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,{startArrow:s,endArrow:l}=a,c=Nc(a,["startArrow","endArrow"]),u=Object.assign(Object.assign({},c),{x1:e.x,y1:e.y,z1:e.z||0,x2:n.x,y2:n.y,z2:n.z||0,isBillboard:!0});return this.upsertArrow("start",s,c,t,u),this.upsertArrow("end",l,c,t,u),this.upsertShape("line","keyShape",u,r,t)}}const lk=(t,e,n=0,r=0)=>{const i={x:(1-n)*t.x+n*e.x,y:(1-n)*t.y+n*e.y};let o=[0,0];It(o,[e.x-t.x,e.y-t.y]),o&&(o[0]||o[1])||(o=[0,0]);const a=[-o[1]*r,o[0]*r];return i.x+=a[0],i.y+=a[1],i},ck=t=>{const e=[];return t.forEach((t=>{if("A"!==t[0])for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1]]);else{const n=t.length;e.push([t[n-2],t[n-1]])}})),e};const uk=t=>t.max[0]-t.min[0],hk=t=>t.max[1]-t.min[1],dk=t=>{const{x:e,y:n}=t,r=new Lr;return r.setMinMax([e,n,0],[e,n,0]),r},pk=(t,e)=>{const{max:[n,r],min:[i,o]}=t,a=new Lr;return(uk(t)||hk(t))&&a.setMinMax([i-e,o-e,0],[n+e,r+e,0]),a},fk=(t,e)=>{const n=Math.min(t.min[0],e.min[0]),r=Math.min(t.min[1],e.min[1]),i=Math.max(t.max[0],e.max[0]),o=Math.max(t.max[1],e.max[1]),a=new Lr;return a.setMinMax([n,r,0],[i,o,0]),a},gk=t=>[{x:t.min[0],y:t.min[1]},{x:t.max[0],y:t.min[1]},{x:t.max[0],y:t.max[1]},{x:t.min[0],y:t.max[1]}],mk=(t,e)=>{const{x:n,y:r}=t;return n<e.min[0]||n>e.max[0]||r<e.min[1]||r>e.max[1]},vk=(t,e,n)=>{const r=((t,e)=>{const n=Math.abs(t.x-e.center[0]),r=Math.abs(t.y-e.center[1]);return 0===n&&0===r?0:n/uk(e)>r/hk(e)})(e,t);if(0===r){let r=t.center[0],i=t.center[1];return n.y<e.y?i=t.min[1]:n.x>e.x?r=t.max[0]:n.x<e.x?r=t.min[0]:n.x===e.x&&(i=t.max[1]),{x:r,y:i}}return r?{x:e.x>t.center[0]?t.max[0]:t.min[0],y:e.y}:{x:e.x,y:e.y>t.center[1]?t.max[1]:t.min[1]}},yk=(t,e,n,r)=>{const i=n.x-t.x,o=n.y-t.y,a=r.x-t.x,s=r.y-t.y,l=n.x-e.x,c=n.y-e.y,u=r.x-e.x,h=r.y-e.y;return(i*s-o*a)*(l*h-c*u)<=0&&(i*c-o*l)*(a*h-s*u)<=0},Ek=(t,e,n)=>{if(uk(n)||hk(n)){const[r,i,o,a]=gk(n);return yk(t,e,r,i)||yk(t,e,r,a)||yk(t,e,i,o)||yk(t,e,o,a)}return!1},_k=(t,e)=>{let n=0,r=t[0],i=Sk(t[0],e);for(let o=0;o<t.length;o++){const a=t[o],s=Sk(a,e);s<i&&(r=a,i=s,n=o)}return{index:n,nearestPoint:r}},bk=(t,e)=>{const n=t[0]-e[0],r=t[1]-e[1];return Math.sqrt(n*n+r*r)},Sk=(t,e)=>{const n=t.x-e.x,r=t.y-e.y,i=t.z-e.z;return isNaN(i)?Math.sqrt(n*n+r*r):Math.sqrt(n*n+r*r+i*i)},xk=(t,e)=>!(!t||!e)&&(t.x===e.x&&t.y===e.y&&t.z===e.z),Tk=(t,e)=>{const{x:n,y:r,r:i}=t,{x:o,y:a}=e,s=o-n,l=a-r;if(s*s+l*l<i*i)return null;const c=Math.atan(l/s);return{x:n+Math.abs(i*Math.cos(c))*Math.sign(s),y:r+Math.abs(i*Math.sin(c))*Math.sign(l)}},Ak=(t,e)=>{const{x:n,y:r,width:i,height:o}=t,a=[],s={x:n+i/2,y:r+o/2};a.push({x:n,y:r}),a.push({x:n+i,y:r}),a.push({x:n+i,y:r+o}),a.push({x:n,y:r+o}),a.push({x:n,y:r});let l=null;for(let t=1;t<a.length&&(l=Rk(a[t-1],a[t],s,e),!l);t++);return l},Rk=(t,e,n,r)=>{const i=n.x-t.x,o=n.y-t.y,a=e.x-t.x,s=e.y-t.y,l=r.x-n.x,c=r.y-n.y,u=a*c-s*l,h=1/u;if(u*u>1e-4*(a*a+s*s)*(l*l+c*c)){const e=(i*c-o*l)*h,n=(i*s-o*a)*h;return IR(e,0,1)&&IR(n,0,1)?{x:t.x+e*a,y:t.y+e*s}:null}return null},Mk=t=>{const e=[],n={};return Ce(t,(t=>{t.id=`${t.x}|||${t.y}`,n[t.id]||(n[t.id]=t,e.push(t))})),e},Ck=(t,e,n,r,i)=>Mk(Dk(t,e,i.offset,n,r)),Pk=(t,e,n,r,i)=>DR(t,e)+DR(t,n)+((t,e)=>{let n=0;return e.forEach((e=>{e&&(t.x===e.x&&(n+=-2),t.y===e.y&&(n+=-2))})),n})(t,[e,n,r,i]),wk=(t,e,n,r,i=0)=>{t.unshift(e[r]),n[r]&&n[r]!==r&&i<=100&&wk(t,e,n,n[r],i+1)},Nk=(t,e,n,r)=>{const i=[];return t.forEach((t=>{if(t!==e&&(t.x===e.x||t.y===e.y)){if(Ek(t,e,n)||Ek(t,e,r))return;i.push(t)}})),Mk(i)},Ok=(t,e,n)=>{const r=[],i=t[0];return r.push(`M ${i.x} ${i.y}`),Ce(t,((n,i)=>{const o=t[i+1],a=t[i+2];if(o&&a)if(((t,e,n)=>!(t.x===e.x&&e.x===n.x||t.y===e.y&&e.y===n.y))(n,o,a)&&e){const[t,i]=((t,e,n,r)=>{const i=DR(t,e),o=DR(n,e),a=Math.min(i,o)/2;return r=Math.min(r,a),[{x:e.x-r/i*(e.x-t.x),y:e.y-r/i*(e.y-t.y)},{x:e.x-r/o*(e.x-n.x),y:e.y-r/o*(e.y-n.y)}]})(n,o,a,e);r.push(`L ${t.x} ${t.y}`),r.push(`Q ${o.x} ${o.y} ${i.x} ${i.y}`),r.push(`L ${i.x} ${i.y}`)}else r.push(`L ${o.x} ${o.y}`);else o&&r.push(`L ${o.x} ${o.y}`)})),n&&r.push("Z"),r.join(" ")},Ik=(t,e,n,r)=>{if(!e||e.length<2)return"M 0 0 L 0 0";const i=Bk(e);return Ok(i,n,r)},Dk=(t,e,n,r,i)=>{let o,a;o=r&&r.getType()?null==r?void 0:r.getBBox():dk(t),a=i&&i.getType()?null==i?void 0:i.getBBox():dk(e);const s=pk(o,n),l=pk(a,n),c=vk(s,t,e),u=vk(l,e,t),h=((t=[])=>{const e=[],n=[];t.forEach((t=>{e.push(t.x),n.push(t.y)}));const r=Math.min(...e),i=Math.max(...e),o=Math.min(...n),a=Math.max(...n),s=new Lr;return s.setMinMax([r,o,0],[i,a,0]),s})([c,u]),d=fk(s,h),p=fk(l,h);let f=[];f=f.concat(gk(d)).concat(gk(p));const g={x:(t.x+e.x)/2,y:(t.y+e.y)/2};[h,d,p].forEach((t=>{f=f.concat(((t,e)=>((t,e)=>e<t.min[0]||e>t.max[0]?[]:[{x:e,y:t.min[1]},{x:e,y:t.max[1]}])(t,e.x).concat(((t,e)=>e<t.min[1]||e>t.max[1]?[]:[{x:t.min[0],y:e},{x:t.max[0],y:e}])(t,e.y)))(t,g).filter((t=>mk(t,s)&&mk(t,l))))})),[{x:c.x,y:u.y},{x:u.x,y:c.y}].forEach((t=>{mk(t,s)&&mk(t,l)&&f.push(t)})),f.unshift(c),f.push(u),f=Mk(f);const m=((t,e,n,r,i,o,a)=>{const s=[],l={[e.id]:e},c={},u={},h={};u[e.id]=0,h[e.id]=Pk(e,n,e);const d=new kk;d.add({id:e.id,value:h[e.id]});const p={};let f;for(t.forEach((t=>{p[t.id]=t}));Object.keys(l).length;){const g=d.minId(!1);if(!g)break;if(f=l[g],f.id===n.id){const t=[];return wk(t,p,c,n.id),t}delete l[f.id],d.remove(f.id),s.push(f),Nk(t,f,r,i).forEach((t=>{if(-1!==s.indexOf(t))return;const r=t.id;l[r]||(l[r]=t);const i=h[f.id]+DR(f,t);u[r]&&i>=u[r]||(c[r]=f.id,u[r]=i,h[r]=u[r]+Pk(t,n,e,o,a)),d.add({id:r,value:h[r]})}))}return[e,n]})(f,c,u,o,a,t,e);return m.unshift(t),m.push(e),Mk(m)},Bk=t=>{if(!(null==t?void 0:t.length))return t;const e=t[t.length-1],n={x:e.x,y:e.y};let r=[e],i=[e];for(let e=t.length-2;e>=0;e--){const o=t[e];if(o.x===n.x?r.push(o):(r=[o],n.x=o.x),o.y===n.y?i.push(o):(i=[o],n.y=o.y),r.length>2){const e=t.indexOf(r[1]);e>-1&&t.splice(e,1)}else if(i.length>2){const e=t.indexOf(i[1]);e>-1&&t.splice(e,1)}}return t};class kk{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){const n=[0,e-1];for(;n[1]-n[0]>1;){const e=Math.floor((n[0]+n[1])/2);if(this.arr[e].value>t.value)n[1]=e;else{if(!(this.arr[e].value<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n[0]=e}}this.arr.splice(n[1],0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;return e?this.arr[e-1].value<t.value?(this.arr.push(t),void(this.map[t.id]=!0)):void this._innerAdd(t,e):(this.arr.push(t),void(this.map[t.id]=!0))}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 Lk{constructor(t,e){this.boundary=t,this.edges=[],this.divided=!1,this.capacity=e}insert(t){var e,n,r,i;return!!this.boundary.intersects(t.bbox)&&(this.edges.length<this.capacity?(this.edges.push(t),!0):(this.divided||this.subdivide(),(null===(e=this.northeast)||void 0===e?void 0:e.insert(t))||(null===(n=this.northwest)||void 0===n?void 0:n.insert(t))||(null===(r=this.southeast)||void 0===r?void 0:r.insert(t))||(null===(i=this.southwest)||void 0===i?void 0:i.insert(t))||!1))}subdivide(){const t=this.boundary.center[0],e=this.boundary.center[1],n=this.boundary.halfExtents[0]/2,r=this.boundary.halfExtents[1]/2,i=new Lr;i.setMinMax([t-2*n,e-2*r,0],[t,e,0]),this.northwest=new Lk(i,this.capacity);const o=new Lr;o.setMinMax([t,e-2*r,0],[t+2*n,e,0]),this.northeast=new Lk(o,this.capacity);const a=new Lr;a.setMinMax([t-2*n,e,0],[t,e+2*r,0]),this.southwest=new Lk(a,this.capacity);const s=new Lr;s.setMinMax([t,e,0],[t+2*n,e+2*r,0]),this.southeast=new Lk(s,this.capacity),this.divided=!0}queryRange(t){var e,n,r,i;if(!t.intersects(this.boundary))return[];let o=this.edges.filter((e=>e.bbox.intersects(t)));return this.divided&&(o=o.concat((null===(e=this.northeast)||void 0===e?void 0:e.queryRange(t))||[],(null===(n=this.northwest)||void 0===n?void 0:n.queryRange(t))||[],(null===(r=this.southeast)||void 0===r?void 0:r.queryRange(t))||[],(null===(i=this.southwest)||void 0===i?void 0:i.queryRange(t))||[])),o}}class Fk{constructor(t){this.quadTree=t}getCollidingEdges(t){return this.quadTree.queryRange(t)}}const Uk={name:"orth",obstacleAvoidance:!1,offset:20,maxAllowedDirectionChange:Math.PI/2,maximumLoops:2e3,gridSize:10,directions:[{stepX:1,stepY:0},{stepX:-1,stepY:0},{stepX:0,stepY:1},{stepX:0,stepY:-1}],get penalties(){return{0:0,45:this.gridSize/2,90:this.gridSize/2}},distFunc:DR,fallbackRoute:Ck},Gk={name:"er",maxAllowedDirectionChange:Math.PI/4,directions:[{stepX:1,stepY:0},{stepX:1,stepY:1},{stepX:0,stepY:1},{stepX:-1,stepY:1},{stepX:-1,stepY:0},{stepX:-1,stepY:-1},{stepX:0,stepY:-1},{stepX:1,stepY:-1}],distFunc:(t,e)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),fallbackRoute:Ck},Vk=(t,e)=>{const n=Math.round(Math.abs(t/e));return n<0?0:(t<0?-1:1)*n},Wk=(t,e)=>{const n=e.x-t.x,r=e.y-t.y;return n||r?Math.atan2(r,n):0},zk=(t,e)=>{const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n},Hk=(t,e,n)=>{let r=1/0;for(let i=0,o=e.length;i<o;i++){const o=n(t,e[i]);o<r&&(r=o)}return r},jk=(t,e,n,r,i)=>{const o=[];if(!n)return[t];const{directions:a,offset:s}=i,l=n.getBBox(),c=e.x>l.min[0]&&e.x<l.max[0]&&e.y>l.min[1]&&e.y<l.max[1],u=pk(l,s);for(const t in u)u[t]=hn(u[t],(t=>Vk(t,i.gridSize)));if(c){for(const e of a){const n=[[{x:u.min[0],y:u.min[1]},{x:u.max[0],y:u.min[1]}],[{x:u.min[0],y:u.min[1]},{x:u.min[0],y:u.max[1]}],[{x:u.max[0],y:u.min[1]},{x:u.max[0],y:u.max[1]}],[{x:u.min[0],y:u.max[1]},{x:u.max[0],y:u.max[1]}]];for(let r=0;r<4;r++){const i=n[r],a=$R(t,{x:t.x+e.stepX*uk(u),y:t.y+e.stepY*hk(u)},i[0],i[1]);a&&!Ek(t,a,l)&&(a.id=`${a.x}|||${a.y}`,o.push(a))}}return o}const h=vk(u,t,r);return h.id=`${h.x}|||${h.y}`,[h]},Xk=(t,e,n,r)=>{const i=Wk(t,e),o=n[t.id];if(!o){const e=Wk(r,t);return zk(e,i)}const a=Wk({x:o.x,y:o.y},t);return zk(a,i)},Yk=(t,e,n,r,i,o,a)=>{const s=[r];let l=r,c=t.id,u=t.x,h=t.y;const d={x:u,y:h,id:c};Xk(d,o,e,n)&&(l={x:o.x===r.x?r.x:d.x*a,y:o.y===r.y?r.y:d.y*a},s.unshift(l));let p=e[c];for(;p&&p.id!==c;){const t={x:u,y:h,id:c},r={x:p.x,y:p.y,id:p.id};Xk(r,t,e,n)&&(l={x:r.x===t.x?l.x:r.x*a,y:r.y===t.y?l.y:r.y*a},s.unshift(l)),c=r.id,u=r.x,h=r.y,p=e[c]}return s[0].x=u===n.x?i.x:l.x,s[0].y=h===n.y?i.y:l.y,s.unshift(i),s},Kk=(t,e,n,r,i)=>{const o=r.get(e),a=r.get(n),s=(null==o?void 0:o.getPosition())||t[0],l=(null==a?void 0:a.getPosition())||t[t.length-1];if(isNaN(s.x)||isNaN(l.x))return[];const c="orth"===i.name?Uk:an(Uk,Gk),u=an(c,i);if(!u.obstacleAvoidance)return u.fallbackRoute(s,l,o,a,u);const{penalties:h,gridSize:d}=u,p=((t,e,n)=>{const r={};return t.forEach((t=>{if(!t||!t.isVisible())return;const i=pk(t.getBBox(),n);for(let t=Vk(i.min[0],e);t<=Vk(i.max[0],e);t+=1)for(let n=Vk(i.min[1],e);n<=Vk(i.max[1],e);n+=1)r[`${t}|||${n}`]=!0})),r})(r,d,u.offset),f={x:Vk(s.x,d),y:Vk(s.y,d)},g={x:Vk(l.x,d),y:Vk(l.y,d)};s.id=`${f.x}|||${f.y}`,l.id=`${g.x}|||${g.y}`;const m=jk(f,s,o,g,u),v=jk(g,l,a,f,u);m.forEach((t=>{delete p[t.id]})),v.forEach((t=>{delete p[t.id]}));const y={},E={},_={},b={},S={},x=new kk;for(let t=0;t<m.length;t++){const e=m[t];y[e.id]=e,b[e.id]=0,S[e.id]=Hk(e,v,u.distFunc),x.add({id:e.id,value:S[e.id]})}let T,A,R,M,C,P,w=u.maximumLoops,N=1/0;const O={};for(v.forEach((t=>{O[`${t.x}|||${t.y}`]=!0})),Object.keys(y).forEach((t=>{const e=y[t].id;S[e]<=N&&(N=S[e],T=y[e])}));Object.keys(y).length>0&&w>0;){const t=x.minId((w+1)%30==0);if(!t)break;if(T=y[t],O[`${T.x}|||${T.y}`])return Yk(T,_,f,l,s,g,d);delete y[T.id],x.remove(T.id),E[T.id]=!0;for(let t=0;t<u.directions.length;t++){A=u.directions[t];const e=`${Math.round(T.x)+A.stepX}|||${Math.round(T.y)+A.stepY}`;if(R={x:T.x+A.stepX,y:T.y+A.stepY,id:e},E[e])continue;if(P=Xk(T,R,_,f),P>u.maxAllowedDirectionChange)continue;if(p[e])continue;y[e]||(y[e]=R);const n=h[P];M=u.distFunc(T,R)+(isNaN(n)?d:n),C=b[T.id]+M;const r=b[e];r&&C>=r||(_[e]=T,b[e]=C,S[e]=C+Hk(R,v,u.distFunc),x.add({id:e,value:S[e]}))}w-=1}return u.fallbackRoute(s,l,o,a,u)};var qk;!function(t){t.top="top",t["top-right"]="top-right",t.right="right",t["bottom-right"]="bottom-right",t.bottom="bottom",t["bottom-left"]="bottom-left",t.left="left",t["top-left"]="top-left"}(qk||(qk={}));const $k=Math.PI/8,Zk={[qk.top]:[-5*$k,-3*$k],[qk["top-right"]]:[-3*$k,-$k],[qk.right]:[-$k,$k],[qk["bottom-right"]]:[$k,3*$k],[qk.bottom]:[3*$k,5*$k],[qk["bottom-left"]]:[5*$k,7*$k],[qk.left]:[7*$k,9*$k],[qk["top-left"]]:[-7*$k,-5*$k]},Qk=(t,e,n)=>[t*Math.cos(n),e*Math.sin(n)],Jk=(t,e,n,r)=>{const[i,o]=Qk(t,e,n),[a,s]=Qk(t,e,r);return[i,o,a,s]};class tL extends ak{constructor(t){super(t),this.type="cubic-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}},this.getControlPoints=(t,e,n=.5,r,i=20)=>{if((null==r?void 0:r.length)>1)return r;return[this.getControlPoint(t,e,n,i),this.getControlPoint(t,e,n,-i)]},this.getControlPoint=(t,e,n=0,r=0)=>{const i={x:(1-n)*t.x+n*e.x,y:(1-n)*t.y+n*e.y};let o=[0,0];It(o,[e.x-t.x,e.y-t.y]),o&&(o[0]||o[1])||(o=[0,0]);const a=[-o[1]*r,o[0]*r];return i.x+=a[0],i.y+=a[1],i}}draw(t,e,n,r,i,o){const{data:a={}}=t,s={keyShape:void 0};return s.keyShape=this.drawKeyShape(t,e,n,r,i),a.haloShape&&(s.haloShape=this.drawHaloShape(t,r,i)),a.labelShape&&(s.labelShape=this.drawLabelShape(t,r,i)),a.labelBackgroundShape&&(s.labelBackgroundShape=this.drawLabelBackgroundShape(t,r,i)),a.iconShape&&(s.iconShape=this.drawIconShape(t,r,i)),s}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,{startArrow:s,endArrow:l}=a,c=Nc(a,["startArrow","endArrow"]),u=this.getControlPoints(e,n,a.curvePosition,a.controlPoints,a.curveOffset),h=Object.assign(Object.assign({},c),{path:[["M",e.x,e.y],["C",u[0].x,u[0].y,u[1].x,u[1].y,n.x,n.y]]});return this.upsertArrow("start",s,c,t,h),this.upsertArrow("end",l,c,t,h),this.upsertShape("path","keyShape",h,r,t)}}var eL=Object.freeze({__proto__:null,LineEdge:sk,QuadraticEdge:class extends ak{constructor(t){super(t),this.type="quadratic-edge",this.defaultStyles={keyShape:{controlPoints:[],curvePosition:.5,curveOffset:30,isBillboard:!0}},this.getControlPoints=(t,e,n=0,r,i)=>(null==r?void 0:r.length)?r:[lk(t,e,n,i)]}draw(t,e,n,r,i,o){const{data:a={}}=t,s={keyShape:void 0};return s.keyShape=this.drawKeyShape(t,e,n,r,i),a.haloShape&&(s.haloShape=this.drawHaloShape(t,r,i)),a.labelShape&&(s.labelShape=this.drawLabelShape(t,r,i)),a.labelBackgroundShape&&(s.labelBackgroundShape=this.drawLabelBackgroundShape(t,r,i)),a.iconShape&&(s.iconShape=this.drawIconShape(t,r,i)),s}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,{startArrow:s,endArrow:l}=a,c=Nc(a,["startArrow","endArrow"]),u=this.getControlPoints(e,n,a.curvePosition,a.controlPoints,a.curveOffset)[0],h=Object.assign(Object.assign({},c),{path:[["M",e.x,e.y],["Q",u.x,u.y,n.x,n.y]]});return this.upsertArrow("start",s,c,t,h),this.upsertArrow("end",l,c,t,h),this.upsertShape("path","keyShape",h,r,t)}},PolylineEdge:class extends sk{constructor(t){super(t),this.type="polyline-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}}}draw(t,e,n,r,i,o){const{data:a={}}=t,s={keyShape:void 0};return s.keyShape=this.drawKeyShape(t,e,n,r,i),a.haloShape&&(s.haloShape=this.drawHaloShape(t,r,i)),a.labelShape&&(s.labelShape=this.drawLabelShape(t,r,i)),a.labelBackgroundShape&&(s.labelBackgroundShape=this.drawLabelBackgroundShape(t,r,i)),a.iconShape&&(s.iconShape=this.drawIconShape(t,r,i)),s}getControlPoints(t,e,n){const{keyShape:r}=this.mergedStyles;return r.controlPoints}getPath(t,e,n,r,i){const{id:o,source:a,target:s}=t;if(!i&&"er"!==r.name)return Ik(0,e,n);const l=Kk(e,a,s,this.nodeMap,r);return Ik(0,l,n)}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,s=this.getControlPoints(t,e,n);let l=[e,n];s&&(l=[e,...s,n]);const c=function(t,e,n,r){return e&&Qe(t,e),n&&Qe(t,n),r&&Qe(t,r),t}({},{offset:a.offset,name:"orth"},a.routeCfg),u=this.getPath(t,l,a.radius,c,ln(s)),{startArrow:h,endArrow:d}=a,p=Nc(a,["startArrow","endArrow"]),f=Object.assign(Object.assign({},p),{path:u,isBillboard:!0});return this.upsertArrow("start",h,p,t,f),this.upsertArrow("end",d,p,t,f),this.upsertShape("path","keyShape",f,r,t)}},LoopEdge:class extends tL{constructor(t){super(t),this.type="loop-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0,loopCfg:{position:qk.top,clockwise:!0}}}}drawKeyShape(t,e,n,r,i,o){const{keyShape:a}=this.mergedStyles,{startPoint:s,endPoint:l,controlPoints:c}=this.getPathPoints(t,e,n,a.loopCfg),{startArrow:u,endArrow:h}=a,d=Nc(a,["startArrow","endArrow"]),p=Object.assign(Object.assign({},a),{path:[["M",s.x,s.y],["C",c[0].x,c[0].y,c[1].x,c[1].y,l.x,l.y]]});return this.upsertArrow("start",u,d,t,p),this.upsertArrow("end",h,d,t,p),this.upsertShape("path","keyShape",p,r,t)}getPathPoints(t,e,n,r){const{source:i,target:o}=t;if(i!==o)throw new Error;const a=this.nodeMap.get(i),s=a.shapeMap.keyShape.nodeName,l=a.getKeyBBox(),c=uk(l),u=hk(l),h=u/2,d=c/2,p=l.center;let f=[e.x,e.y],g=[n.x,n.y];const m=r.position||qk.top;if(f[0]===g[0]&&f[1]===g[1]&&([f,g]="circle"===s||"ellipse"===s?((t,e,n,r)=>{var i,o;const[a,s,l,c]=Jk(n,r,(null===(i=Zk[t])||void 0===i?void 0:i[0])||-$k,(null===(o=Zk[t])||void 0===o?void 0:o[1])||$k);return[[e[0]+a,e[1]+s],[e[0]+l,e[1]+c]]})(m,p,d,h):((t,e,n,r,i)=>{const o=Math.min(r/2,n/2),a=Math.min(r,n),s=i?Math.min(a,i):o,l={[qk.top]:[[e[0]-s,e[1]-r],[e[0]+s,e[1]-r]],[qk["top-right"]]:[[e[0]+n-s,e[1]-r],[e[0]+n,e[1]-r+s]],[qk.right]:[[e[0]+n,e[1]-s],[e[0]+n,e[1]+s]],[qk["bottom-right"]]:[[e[0]+n,e[1]+r-s],[e[0]+n-s,e[1]+r]],[qk.bottom]:[[e[0]+s,e[1]+r],[e[0]-s,e[1]+r]],[qk["bottom-left"]]:[[e[0]-n+s,e[1]+r],[e[0]-n,e[1]+r-s]],[qk.left]:[[e[0]-n,e[1]+s],[e[0]-n,e[1]-s]],[qk["top-left"]]:[[e[0]-n,e[1]-r+s],[e[0]-n+s,e[1]-r]]};return l[t]||l[qk.top]})(m,p,d,h,r.pointPadding),!1===r.clockwise)){const t=f;f=g,g=t}const v=r.dist||2*Math.max(c,u),y=[f[0]-p[0],f[1]-p[1]],E=[g[0]-p[0],g[1]-p[1]],_=bk([0,0],y),b=bk([0,0],E),S=(b+v)/b,x=Ot([0,0],y,(_+v)/_),T=Ot([0,0],E,S),A=[{x:p[0]+x[0],y:p[1]+x[1]},{x:p[0]+T[0],y:p[1]+T[1]}];return{startPoint:{x:f[0],y:f[1]},endPoint:{x:g[0],y:g[1]},controlPoints:A}}},CubicHorizontalEdge:class extends tL{constructor(t){super(t),this.type="cubic-horizontal-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}},this.getControlPoints=(t,e,n=.5,r,i)=>{if((null==r?void 0:r.length)>1)return r;const o=(t.x-e.x)*n;return[this.getControlPoint(t,e,o),this.getControlPoint(e,t,-o)]},this.getControlPoint=(t,e,n=0)=>{if(e.y===t.y||e.x===t.x)return{x:(t.x+e.x)/2,y:t.y};return{x:t.x-n,y:t.y}}}},CubicVerticalEdge:class extends tL{constructor(t){super(t),this.type="cubic-vertical-edge",this.defaultStyles={keyShape:{x1:0,y1:0,z1:0,x2:0,y2:0,z2:0,isBillboard:!0}},this.getControlPoints=(t,e,n=.5,r,i)=>{if((null==r?void 0:r.length)>1)return r;const o=(t.y-e.y)*n;return[this.getControlPoint(t,e,o),this.getControlPoint(e,t,-o)]},this.getControlPoint=(t,e,n=0)=>{if(e.y===t.y||e.x===t.x)return{x:t.x,y:(t.y+e.y)/2};return{x:t.x,y:t.y-n}}}},CubicEdge:tL});const nL="rgb(253, 253, 253)",rL="rgb(240, 240, 240)",iL="rgba(153,173,209,1)",oL={node:{palette:["#4089FF","#CD75FF","#06B8A8","#FF8834","#5888C3","#FA73CD","#07BCE0","#CB962A","#23AD61","#FF8075"],lodStrategy:{levels:[{zoomRange:[0,.65]},{zoomRange:[.65,.8]},{zoomRange:[.8,1.6],primary:!0},{zoomRange:[1.6,2]},{zoomRange:[2,1/0]}],animateCfg:{duration:200}},styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{r:16,fill:"rgb(34,126,255)",lineWidth:0,zIndex:0}),labelShape:Object.assign(Object.assign({},ER),{fill:"#000",position:"bottom",zIndex:2,lod:0,maxWidth:"200%",textOverflow:"ellipsis",wordWrap:!0,maxLines:1}),labelBackgroundShape:{padding:[2,4,2,4],lineWidth:0,fill:"#fff",opacity:.75,zIndex:1,lod:0},iconShape:Object.assign(Object.assign({},ER),{fill:"#fff",fontSize:16,zIndex:1,lod:-1}),anchorShapes:{lineWidth:1,stroke:"rgba(0, 0, 0, 0.65)",zIndex:2,r:3,lod:0},badgeShapes:{palette:["#7E92B5","#F86254","#EDB74B"],textColor:"#fff",zIndex:3,lod:-1},haloShape:{visible:!1,droppable:!1}},selected:{keyShape:{stroke:"#000",lineWidth:3},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,droppable:!1}},active:{keyShape:{lineWidth:0},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,droppable:!1}},highlight:{keyShape:{stroke:"rgba(0,0,0,0.85)",lineWidth:3},labelShape:{fontWeight:700},haloShape:{visible:!1,droppable:!1}},inactive:{keyShape:{opacity:.25},labelShape:{opacity:.25},iconShape:{opacity:.25},haloShape:{visible:!1,droppable:!1}},disable:{keyShape:{fill:rL,lineWidth:0},haloShape:{visible:!1,droppable:!1}}}]},edge:{palette:["#99ADD1","#4089FF","#CD75FF","#06B8A8","#FF8834","#5888C3","#FA73CD","#07BCE0","#CB962A","#23AD61","#FF8075"],lodStrategy:{levels:[{zoomRange:[0,.65]},{zoomRange:[.65,.8]},{zoomRange:[.8,1.6],primary:!0},{zoomRange:[1.6,2]},{zoomRange:[2,1/0]}],animateCfg:{duration:200}},styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{lineWidth:1,stroke:"rgb(153, 173, 209)",increasedLineWidthForHitTesting:2,zIndex:1}),labelShape:Object.assign(Object.assign({},ER),{fill:"rgba(0,0,0,0.85)",position:"middle",textBaseline:"middle",zIndex:3,textOverflow:"ellipsis",wordWrap:!0,maxLines:1,maxWidth:"60%",lod:0}),labelBackgroundShape:{padding:[4,4,4,4],lineWidth:0,fill:"#fff",opacity:.75,zIndex:2,lod:0},iconShape:Object.assign(Object.assign({},ER),{fill:"rgb(140, 140, 140)",fontSize:16,zIndex:2,offsetX:-10,lod:-1})},selected:{keyShape:{lineWidth:2},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},active:{keyShape:{lineWidth:1},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},highlight:{keyShape:{lineWidth:2},labelShape:{fontWeight:700}},inactive:{keyShape:{stroke:"rgb(210, 218, 233)",lineWidth:1}},disable:{keyShape:{stroke:"rgb(217, 217, 217)",lineWidth:1}}}]},combo:{styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{fill:nL,lineWidth:1,stroke:iL,r:5,width:20,height:10,padding:[25,20,15,20]}),labelShape:Object.assign(Object.assign({},ER),{fill:"#000",position:"bottom",zIndex:2,lod:0,maxLines:1}),labelBackgroundShape:{padding:[2,4,2,4],lineWidth:0,fill:"#fff",opacity:.75,zIndex:1,lod:0}},selected:{keyShape:{stroke:"rgba(27,50,79,1)",fill:nL,lineWidth:4},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,stroke:"rgba(153,173,209,1)",droppable:!1}},active:{keyShape:{stroke:iL,lineWidth:1},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,stroke:"rgba(153,173,209,1)",droppable:!1}},highlight:{keyShape:{stroke:iL,lineWidth:4},labelShape:{fontWeight:700}},inactive:{keyShape:{stroke:iL,fill:nL,lineWidth:1,opacity:.65},labelShape:{opacity:.65}},disable:{keyShape:{fill:rL,stroke:"rgba(153,173,209,1)",opacity:.25,lineWidth:1},labelShape:{opacity:.25}},collapsed:{keyShape:Object.assign(Object.assign({},yR),{fill:nL,lineWidth:1,stroke:iL,r:16,width:48,height:24,padding:[25,20,15,20]}),iconShape:Object.assign(Object.assign({},ER),{fill:iL,fontSize:12,zIndex:1,lod:-1,contentType:"childCount",visible:!0})}}]},canvas:{backgroundColor:"#fff"}},aL="rgba(255,255,255,0.85)",sL="rgb(253, 253, 253)",lL="rgba(153,173,209,1)",cL="#D0E4FF",uL="#637088",hL="#D0E4FF",dL={node:{palette:["#4089FF","#CD75FF","#06B8A8","#FF8834","#5888C3","#FA73CD","#07BCE0","#CB962A","#23AD61","#FF8075"],lodStrategy:{levels:[{zoomRange:[0,.65]},{zoomRange:[.65,.8]},{zoomRange:[.8,1.6],primary:!0},{zoomRange:[1.6,2]},{zoomRange:[2,1/0]}],animateCfg:{duration:200}},styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{r:16,fill:"rgb(34,126,255)",lineWidth:0,zIndex:0}),labelShape:Object.assign(Object.assign({},ER),{fill:aL,opacity:.85,position:"bottom",zIndex:2,lod:0,maxWidth:"200%",textOverflow:"ellipsis",wordWrap:!0,maxLines:1}),labelBackgroundShape:{padding:[2,4,2,4],lineWidth:0,fill:"#000",opacity:.75,zIndex:1,lod:0},iconShape:Object.assign(Object.assign({},ER),{fill:"#fff",fontSize:16,zIndex:1,lod:-1}),anchorShapes:{lineWidth:1,stroke:hL,fill:"#000",zIndex:2,r:3,lod:0},badgeShapes:{palette:["#7E92B5","#F86254","#EDB74B"],textColor:"#fff",zIndex:3,lod:-1},haloShape:{visible:!1,droppable:!1}},selected:{keyShape:{stroke:hL,lineWidth:3},labelShape:{fontWeight:700},haloShape:{opacity:.45,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},active:{keyShape:{lineWidth:0},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},highlight:{keyShape:{stroke:hL,lineWidth:3},labelShape:{fontWeight:700},haloShape:{visible:!1,droppable:!1}},inactive:{keyShape:{opacity:.45},labelShape:{opacity:.45},iconShape:{opacity:.45},haloShape:{visible:!1,droppable:!1}},disable:{keyShape:{fill:cL,lineWidth:0},haloShape:{visible:!1,droppable:!1}}}]},edge:{palette:["#637088","#2A59A6","#854CA6","#04786D","#A65822","#39587F","#A34B85","#057A92","#84621B","#17703F","#A6534C"],lodStrategy:{levels:[{zoomRange:[0,.65]},{zoomRange:[.65,.8]},{zoomRange:[.8,1.6],primary:!0},{zoomRange:[1.6,2]},{zoomRange:[2,1/0]}],animateCfg:{duration:200}},styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{lineWidth:1,stroke:uL,increasedLineWidthForHitTesting:2,zIndex:1}),labelShape:Object.assign(Object.assign({},ER),{fill:aL,opacity:.85,position:"middle",textBaseline:"middle",zIndex:3,textOverflow:"ellipsis",wordWrap:!0,maxLines:1,maxWidth:"60%",lod:0}),labelBackgroundShape:{padding:[4,4,4,4],lineWidth:0,fill:"#000",opacity:.75,zIndex:2,lod:0},iconShape:Object.assign(Object.assign({},ER),{fill:"rgb(140, 140, 140)",fontSize:16,zIndex:2,offsetX:-10,lod:-1})},selected:{keyShape:{lineWidth:2},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},active:{keyShape:{lineWidth:1},haloShape:{opacity:.25,lineWidth:12,zIndex:-1,pointerEvents:"none",visible:!0,droppable:!1}},highlight:{keyShape:{lineWidth:2},labelShape:{fontWeight:700}},inactive:{keyShape:{stroke:uL,lineWidth:1,opacity:.45}},disable:{keyShape:{stroke:uL,opacity:.08,lineWidth:1}}}]},combo:{styles:[{default:{keyShape:Object.assign(Object.assign({},yR),{fill:sL,lineWidth:1,stroke:uL,r:5,width:20,height:10,padding:[25,20,15,20]}),labelShape:Object.assign(Object.assign({},ER),{fill:aL,opacity:.85,position:"bottom",zIndex:2,lod:0,maxLines:1}),labelBackgroundShape:{padding:[2,4,2,4],lineWidth:0,fill:"#000",opacity:.75,zIndex:1,lod:0}},selected:{keyShape:{stroke:hL,fill:sL,lineWidth:2},labelShape:{fontWeight:700},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,stroke:lL,droppable:!1}},active:{keyShape:{stroke:hL,lineWidth:1},haloShape:{opacity:.25,lineWidth:12,pointerEvents:"none",zIndex:-1,visible:!0,stroke:lL,droppable:!1}},highlight:{keyShape:{stroke:hL,fill:sL,lineWidth:2},labelShape:{fontWeight:700}},inactive:{keyShape:{stroke:uL,fill:sL,lineWidth:1},labelShape:{opacity:.65}},disable:{keyShape:{fill:cL,opacity:.25},iconShape:{fill:cL,opacity:.25},labelShape:{opacity:.25}},collapsed:{keyShape:Object.assign(Object.assign({},yR),{fill:sL,lineWidth:1,stroke:lL,r:16,width:48,height:24,padding:[25,20,15,20]}),iconShape:Object.assign(Object.assign({},ER),{fill:lL,fontSize:12,zIndex:1,lod:-1,contentType:"childCount",visible:!0})}}]},canvas:{backgroundColor:"#000"}};var pL=Object.freeze({__proto__:null,LightTheme:oL,DarkTheme:dL});class fL{constructor(t,e){this.getSpecification=()=>this.specification,this.specification=this.solver(t,e),this.options=t}destroy(){}}var gL={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]},mL=u((function(t){var e=Array.prototype.concat,n=Array.prototype.slice,r=t.exports=function(t){for(var r,i=[],o=0,a=t.length;o<a;o++){var s=t[o];(r=s)&&"string"!=typeof r&&(r instanceof Array||Array.isArray(r)||r.length>=0&&(r.splice instanceof Function||Object.getOwnPropertyDescriptor(r,r.length-1)&&"String"!==r.constructor.name))?i=e.call(i,n.call(s)):i.push(s)}return i};r.wrap=function(t){return function(){return t(r(arguments))}}})),vL=u((function(t){var e=Object.hasOwnProperty,n=Object.create(null);for(var r in gL)e.call(gL,r)&&(n[gL[r]]=r);var i=t.exports={to:{},get:{}};function o(t,e,n){return Math.min(Math.max(e,t),n)}function a(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}i.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=i.get.hsl(t),n="hsl";break;case"hwb":e=i.get.hwb(t),n="hwb";break;default:e=i.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},i.get.rgb=function(t){if(!t)return null;var n,r,i,a=[0,0,0,1];if(n=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(i=n[2],n=n[1],r=0;r<3;r++){var s=2*r;a[r]=parseInt(n.slice(s,s+2),16)}i&&(a[3]=parseInt(i,16)/255)}else if(n=t.match(/^#([a-f0-9]{3,4})$/i)){for(i=(n=n[1])[3],r=0;r<3;r++)a[r]=parseInt(n[r]+n[r],16);i&&(a[3]=parseInt(i+i,16)/255)}else if(n=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(r=0;r<3;r++)a[r]=parseInt(n[r+1],0);n[4]&&(n[5]?a[3]=.01*parseFloat(n[4]):a[3]=parseFloat(n[4]))}else{if(!(n=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(n=t.match(/^(\w+)$/))?"transparent"===n[1]?[0,0,0,0]:e.call(gL,n[1])?((a=gL[n[1]])[3]=1,a):null:null;for(r=0;r<3;r++)a[r]=Math.round(2.55*parseFloat(n[r+1]));n[4]&&(n[5]?a[3]=.01*parseFloat(n[4]):a[3]=parseFloat(n[4]))}for(r=0;r<3;r++)a[r]=o(a[r],0,255);return a[3]=o(a[3],0,1),a},i.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,o(parseFloat(e[2]),0,100),o(parseFloat(e[3]),0,100),o(isNaN(n)?1:n,0,1)]}return null},i.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,o(parseFloat(e[2]),0,100),o(parseFloat(e[3]),0,100),o(isNaN(n)?1:n,0,1)]}return null},i.to.hex=function(){var t=mL(arguments);return"#"+a(t[0])+a(t[1])+a(t[2])+(t[3]<1?a(Math.round(255*t[3])):"")},i.to.rgb=function(){var t=mL(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]+")"},i.to.rgb.percent=function(){var t=mL(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]+")"},i.to.hsl=function(){var t=mL(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},i.to.hwb=function(){var t=mL(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},i.to.keyword=function(t){return n[t.slice(0,3)]}}));const yL={};for(const t of Object.keys(gL))yL[gL[t]]=t;const EL={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};var _L=EL;for(const t of Object.keys(EL)){if(!("channels"in EL[t]))throw new Error("missing channels property: "+t);if(!("labels"in EL[t]))throw new Error("missing channel labels property: "+t);if(EL[t].labels.length!==EL[t].channels)throw new Error("channel and label counts mismatch: "+t);const{channels:e,labels:n}=EL[t];delete EL[t].channels,delete EL[t].labels,Object.defineProperty(EL[t],"channels",{value:e}),Object.defineProperty(EL[t],"labels",{value:n})}function bL(t,e){return(t[0]-e[0])**2+(t[1]-e[1])**2+(t[2]-e[2])**2}function SL(t){const e=function(){const t={},e=Object.keys(_L);for(let n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;){const t=n.pop(),r=Object.keys(_L[t]);for(let i=r.length,o=0;o<i;o++){const i=r[o],a=e[i];-1===a.distance&&(a.distance=e[t].distance+1,a.parent=t,n.unshift(i))}}return e}function xL(t,e){return function(n){return e(t(n))}}function TL(t,e){const n=[e[t].parent,t];let r=_L[e[t].parent][t],i=e[t].parent;for(;e[i].parent;)n.unshift(e[i].parent),r=xL(_L[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}EL.rgb.hsl=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=o-i;let s,l;o===i?s=0:e===o?s=(n-r)/a:n===o?s=2+(r-e)/a:r===o&&(s=4+(e-n)/a),s=Math.min(60*s,360),s<0&&(s+=360);const c=(i+o)/2;return l=o===i?0:c<=.5?a/(o+i):a/(2-o-i),[s,100*l,100*c]},EL.rgb.hsv=function(t){let e,n,r,i,o;const a=t[0]/255,s=t[1]/255,l=t[2]/255,c=Math.max(a,s,l),u=c-Math.min(a,s,l),h=function(t){return(c-t)/6/u+.5};return 0===u?(i=0,o=0):(o=u/c,e=h(a),n=h(s),r=h(l),a===c?i=r-n:s===c?i=1/3+e-r:l===c&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*o,100*c]},EL.rgb.hwb=function(t){const e=t[0],n=t[1];let r=t[2];const i=EL.rgb.hsl(t)[0],o=1/255*Math.min(e,Math.min(n,r));return r=1-1/255*Math.max(e,Math.max(n,r)),[i,100*o,100*r]},EL.rgb.cmyk=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.min(1-e,1-n,1-r);return[100*((1-e-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*((1-r-i)/(1-i)||0),100*i]},EL.rgb.keyword=function(t){const e=yL[t];if(e)return e;let n,r=1/0;for(const e of Object.keys(gL)){const i=bL(t,gL[e]);i<r&&(r=i,n=e)}return n},EL.keyword.rgb=function(t){return gL[t]},EL.rgb.xyz=function(t){let e=t[0]/255,n=t[1]/255,r=t[2]/255;e=e>.04045?((e+.055)/1.055)**2.4:e/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92,r=r>.04045?((r+.055)/1.055)**2.4:r/12.92;return[100*(.4124*e+.3576*n+.1805*r),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},EL.rgb.lab=function(t){const e=EL.rgb.xyz(t);let n=e[0],r=e[1],i=e[2];n/=95.047,r/=100,i/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,i=i>.008856?i**(1/3):7.787*i+16/116;return[116*r-16,500*(n-r),200*(r-i)]},EL.hsl.rgb=function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100;let i,o,a;if(0===n)return a=255*r,[a,a,a];i=r<.5?r*(1+n):r+n-r*n;const s=2*r-i,l=[0,0,0];for(let t=0;t<3;t++)o=e+1/3*-(t-1),o<0&&o++,o>1&&o--,a=6*o<1?s+6*(i-s)*o:2*o<1?i:3*o<2?s+(i-s)*(2/3-o)*6:s,l[t]=255*a;return l},EL.hsl.hsv=function(t){const e=t[0];let n=t[1]/100,r=t[2]/100,i=n;const o=Math.max(r,.01);r*=2,n*=r<=1?r:2-r,i*=o<=1?o:2-o;return[e,100*(0===r?2*i/(o+i):2*n/(r+n)),100*((r+n)/2)]},EL.hsv.rgb=function(t){const e=t[0]/60,n=t[1]/100;let r=t[2]/100;const i=Math.floor(e)%6,o=e-Math.floor(e),a=255*r*(1-n),s=255*r*(1-n*o),l=255*r*(1-n*(1-o));switch(r*=255,i){case 0:return[r,l,a];case 1:return[s,r,a];case 2:return[a,r,l];case 3:return[a,s,r];case 4:return[l,a,r];case 5:return[r,a,s]}},EL.hsv.hsl=function(t){const e=t[0],n=t[1]/100,r=t[2]/100,i=Math.max(r,.01);let o,a;a=(2-n)*r;const s=(2-n)*i;return o=n*i,o/=s<=1?s:2-s,o=o||0,a/=2,[e,100*o,100*a]},EL.hwb.rgb=function(t){const e=t[0]/360;let n=t[1]/100,r=t[2]/100;const i=n+r;let o;i>1&&(n/=i,r/=i);const a=Math.floor(6*e),s=1-r;o=6*e-a,0!=(1&a)&&(o=1-o);const l=n+o*(s-n);let c,u,h;switch(a){default:case 6:case 0:c=s,u=l,h=n;break;case 1:c=l,u=s,h=n;break;case 2:c=n,u=s,h=l;break;case 3:c=n,u=l,h=s;break;case 4:c=l,u=n,h=s;break;case 5:c=s,u=n,h=l}return[255*c,255*u,255*h]},EL.cmyk.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},EL.xyz.rgb=function(t){const e=t[0]/100,n=t[1]/100,r=t[2]/100;let i,o,a;return i=3.2406*e+-1.5372*n+-.4986*r,o=-.9689*e+1.8758*n+.0415*r,a=.0557*e+-.204*n+1.057*r,i=i>.0031308?1.055*i**(1/2.4)-.055:12.92*i,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,i=Math.min(Math.max(0,i),1),o=Math.min(Math.max(0,o),1),a=Math.min(Math.max(0,a),1),[255*i,255*o,255*a]},EL.xyz.lab=function(t){let e=t[0],n=t[1],r=t[2];e/=95.047,n/=100,r/=108.883,e=e>.008856?e**(1/3):7.787*e+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116;return[116*n-16,500*(e-n),200*(n-r)]},EL.lab.xyz=function(t){let e,n,r;n=(t[0]+16)/116,e=t[1]/500+n,r=n-t[2]/200;const i=n**3,o=e**3,a=r**3;return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,e*=95.047,n*=100,r*=108.883,[e,n,r]},EL.lab.lch=function(t){const e=t[0],n=t[1],r=t[2];let i;i=360*Math.atan2(r,n)/2/Math.PI,i<0&&(i+=360);return[e,Math.sqrt(n*n+r*r),i]},EL.lch.lab=function(t){const e=t[0],n=t[1],r=t[2]/360*2*Math.PI;return[e,n*Math.cos(r),n*Math.sin(r)]},EL.rgb.ansi16=function(t,e=null){const[n,r,i]=t;let o=null===e?EL.rgb.hsv(t)[2]:e;if(o=Math.round(o/50),0===o)return 30;let a=30+(Math.round(i/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===o&&(a+=60),a},EL.hsv.ansi16=function(t){return EL.rgb.ansi16(EL.hsv.rgb(t),t[2])},EL.rgb.ansi256=function(t){const e=t[0],n=t[1],r=t[2];if(e===n&&n===r)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;return 16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},EL.ansi16.rgb=function(t){let e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];const n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},EL.ansi256.rgb=function(t){if(t>=232){const e=10*(t-232)+8;return[e,e,e]}let e;t-=16;return[Math.floor(t/36)/5*255,Math.floor((e=t%36)/6)/5*255,e%6/5*255]},EL.rgb.hex=function(t){const e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},EL.hex.rgb=function(t){const e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];let n=e[0];3===e[0].length&&(n=n.split("").map((t=>t+t)).join(""));const r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},EL.rgb.hcg=function(t){const e=t[0]/255,n=t[1]/255,r=t[2]/255,i=Math.max(Math.max(e,n),r),o=Math.min(Math.min(e,n),r),a=i-o;let s,l;return s=a<1?o/(1-a):0,l=a<=0?0:i===e?(n-r)/a%6:i===n?2+(r-e)/a:4+(e-n)/a,l/=6,l%=1,[360*l,100*a,100*s]},EL.hsl.hcg=function(t){const e=t[1]/100,n=t[2]/100,r=n<.5?2*e*n:2*e*(1-n);let i=0;return r<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},EL.hsv.hcg=function(t){const e=t[1]/100,n=t[2]/100,r=e*n;let i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},EL.hcg.rgb=function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];const i=[0,0,0],o=e%1*6,a=o%1,s=1-a;let l=0;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=s,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=s,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=s}return l=(1-n)*r,[255*(n*i[0]+l),255*(n*i[1]+l),255*(n*i[2]+l)]},EL.hcg.hsv=function(t){const e=t[1]/100,n=e+t[2]/100*(1-e);let r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},EL.hcg.hsl=function(t){const e=t[1]/100,n=t[2]/100*(1-e)+.5*e;let r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},EL.hcg.hwb=function(t){const e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},EL.hwb.hcg=function(t){const e=t[1]/100,n=1-t[2]/100,r=n-e;let i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},EL.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},EL.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},EL.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},EL.gray.hsl=function(t){return[0,0,t[0]]},EL.gray.hsv=EL.gray.hsl,EL.gray.hwb=function(t){return[0,100,t[0]]},EL.gray.cmyk=function(t){return[0,0,0,t[0]]},EL.gray.lab=function(t){return[t[0],0,0]},EL.gray.hex=function(t){const e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},EL.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};const AL={};Object.keys(_L).forEach((t=>{AL[t]={},Object.defineProperty(AL[t],"channels",{value:_L[t].channels}),Object.defineProperty(AL[t],"labels",{value:_L[t].labels});const e=function(t){const e=SL(t),n={},r=Object.keys(e);for(let t=r.length,i=0;i<t;i++){const t=r[i];null!==e[t].parent&&(n[t]=TL(t,e))}return n}(t);Object.keys(e).forEach((n=>{const r=e[n];AL[t][n]=function(t){const e=function(...e){const n=e[0];if(null==n)return n;n.length>1&&(e=n);const r=t(e);if("object"==typeof r)for(let t=r.length,e=0;e<t;e++)r[e]=Math.round(r[e]);return r};return"conversion"in t&&(e.conversion=t.conversion),e}(r),AL[t][n].raw=function(t){const e=function(...e){const n=e[0];return null==n?n:(n.length>1&&(e=n),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var RL=AL;const ML=["keyword","gray","hex"],CL={};for(const t of Object.keys(RL))CL[[...RL[t].labels].sort().join("")]=t;const PL={};function wL(t,e){if(!(this instanceof wL))return new wL(t,e);if(e&&e in ML&&(e=null),e&&!(e in RL))throw new Error("Unknown model: "+e);let n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof wL)this.model=t.model,this.color=[...t.color],this.valpha=t.valpha;else if("string"==typeof t){const e=vL.get(t);if(null===e)throw new Error("Unable to parse color from string: "+t);this.model=e.model,r=RL[this.model].channels,this.color=e.value.slice(0,r),this.valpha="number"==typeof e.value[r]?e.value[r]:1}else if(t.length>0){this.model=e||"rgb",r=RL[this.model].channels;const n=Array.prototype.slice.call(t,0,r);this.color=DL(n,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;const e=Object.keys(t);"alpha"in t&&(e.splice(e.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);const r=e.sort().join("");if(!(r in CL))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=CL[r];const{labels:i}=RL[this.model],o=[];for(n=0;n<i.length;n++)o.push(t[i[n]]);this.color=DL(o)}if(PL[this.model])for(r=RL[this.model].channels,n=0;n<r;n++){const t=PL[this.model][n];t&&(this.color[n]=t(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}wL.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string(t){let e=this.model in vL.to?this:this.rgb();e=e.round("number"==typeof t?t:1);const n=1===e.valpha?e.color:[...e.color,this.valpha];return vL.to[e.model](n)},percentString(t){const e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:[...e.color,this.valpha];return vL.to.rgb.percent(n)},array(){return 1===this.valpha?[...this.color]:[...this.color,this.valpha]},object(){const t={},{channels:e}=RL[this.model],{labels:n}=RL[this.model];for(let r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray(){const t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject(){const t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round(t){return t=Math.max(t||0,0),new wL([...this.color.map(NL(t)),this.valpha],this.model)},alpha(t){return void 0!==t?new wL([...this.color,Math.max(0,Math.min(1,t))],this.model):this.valpha},red:OL("rgb",0,IL(255)),green:OL("rgb",1,IL(255)),blue:OL("rgb",2,IL(255)),hue:OL(["hsl","hsv","hsl","hwb","hcg"],0,(t=>(t%360+360)%360)),saturationl:OL("hsl",1,IL(100)),lightness:OL("hsl",2,IL(100)),saturationv:OL("hsv",1,IL(100)),value:OL("hsv",2,IL(100)),chroma:OL("hcg",1,IL(100)),gray:OL("hcg",2,IL(100)),white:OL("hwb",1,IL(100)),wblack:OL("hwb",2,IL(100)),cyan:OL("cmyk",0,IL(100)),magenta:OL("cmyk",1,IL(100)),yellow:OL("cmyk",2,IL(100)),black:OL("cmyk",3,IL(100)),x:OL("xyz",0,IL(95.047)),y:OL("xyz",1,IL(100)),z:OL("xyz",2,IL(108.833)),l:OL("lab",0,IL(100)),a:OL("lab",1),b:OL("lab",2),keyword(t){return void 0!==t?new wL(t):RL[this.model].keyword(this.color)},hex(t){return void 0!==t?new wL(t):vL.to.hex(this.rgb().round().color)},hexa(t){if(void 0!==t)return new wL(t);const e=this.rgb().round().color;let n=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===n.length&&(n="0"+n),vL.to.hex(e)+n},rgbNumber(){const t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity(){const t=this.rgb().color,e=[];for(const[n,r]of t.entries()){const t=r/255;e[n]=t<=.04045?t/12.92:((t+.055)/1.055)**2.4}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast(t){const e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level(t){const e=this.contrast(t);return e>=7?"AAA":e>=4.5?"AA":""},isDark(){const t=this.rgb().color;return(2126*t[0]+7152*t[1]+722*t[2])/1e4<128},isLight(){return!this.isDark()},negate(){const t=this.rgb();for(let e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten(t){const e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken(t){const e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate(t){const e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate(t){const e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten(t){const e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken(t){const e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale(){const t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return wL.rgb(e,e,e)},fade(t){return this.alpha(this.valpha-this.valpha*t)},opaquer(t){return this.alpha(this.valpha+this.valpha*t)},rotate(t){const e=this.hsl();let n=e.color[0];return n=(n+t)%360,n=n<0?360+n:n,e.color[0]=n,e},mix(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);const n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,o=2*i-1,a=n.alpha()-r.alpha(),s=((o*a==-1?o:(o+a)/(1+o*a))+1)/2,l=1-s;return wL.rgb(s*n.red()+l*r.red(),s*n.green()+l*r.green(),s*n.blue()+l*r.blue(),n.alpha()*i+r.alpha()*(1-i))}};for(const t of Object.keys(RL)){if(ML.includes(t))continue;const{channels:e}=RL[t];wL.prototype[t]=function(...e){return this.model===t?new wL(this):e.length>0?new wL(e,t):new wL([...(n=RL[this.model][t].raw(this.color),Array.isArray(n)?n:[n]),this.valpha],t);var n},wL[t]=function(...n){let r=n[0];return"number"==typeof r&&(r=DL(n,e)),new wL(r,t)}}function NL(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}function OL(t,e,n){t=Array.isArray(t)?t:[t];for(const r of t)(PL[r]||(PL[r]=[]))[e]=n;return t=t[0],function(r){let i;return void 0!==r?(n&&(r=n(r)),i=this[t](),i.color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function IL(t){return function(e){return Math.max(0,Math.min(t,e))}}function DL(t,e){for(let n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}var BL=wL;function kL(t,e){(function(t){return"string"==typeof t&&-1!==t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var n=function(t){return"string"==typeof t&&-1!==t.indexOf("%")}(t);return t=360===e?t:Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(String(t*e),10)/100),Math.abs(t-e)<1e-6?1:t=360===e?(t<0?t%e+e:t%e)/parseFloat(String(e)):t%e/parseFloat(String(e))}function LL(t){return t<=1?"".concat(100*Number(t),"%"):t}function FL(t){return 1===t.length?"0"+t:String(t)}function UL(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*n*(e-t):n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function GL(t){return VL(t)/255}function VL(t){return parseInt(t,16)}var WL={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",goldenrod:"#daa520",gold:"#ffd700",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavenderblush:"#fff0f5",lavender:"#e6e6fa",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};function zL(t){var e,n,r,i={r:0,g:0,b:0},o=1,a=null,s=null,l=null,c=!1,u=!1;return"string"==typeof t&&(t=function(t){if(t=t.trim().toLowerCase(),0===t.length)return!1;var e=!1;if(WL[t])t=WL[t],e=!0;else if("transparent"===t)return{r:0,g:0,b:0,a:0,format:"name"};var n=YL.rgb.exec(t);if(n)return{r:n[1],g:n[2],b:n[3]};if(n=YL.rgba.exec(t),n)return{r:n[1],g:n[2],b:n[3],a:n[4]};if(n=YL.hsl.exec(t),n)return{h:n[1],s:n[2],l:n[3]};if(n=YL.hsla.exec(t),n)return{h:n[1],s:n[2],l:n[3],a:n[4]};if(n=YL.hsv.exec(t),n)return{h:n[1],s:n[2],v:n[3]};if(n=YL.hsva.exec(t),n)return{h:n[1],s:n[2],v:n[3],a:n[4]};if(n=YL.hex8.exec(t),n)return{r:VL(n[1]),g:VL(n[2]),b:VL(n[3]),a:GL(n[4]),format:e?"name":"hex8"};if(n=YL.hex6.exec(t),n)return{r:VL(n[1]),g:VL(n[2]),b:VL(n[3]),format:e?"name":"hex"};if(n=YL.hex4.exec(t),n)return{r:VL(n[1]+n[1]),g:VL(n[2]+n[2]),b:VL(n[3]+n[3]),a:GL(n[4]+n[4]),format:e?"name":"hex8"};if(n=YL.hex3.exec(t),n)return{r:VL(n[1]+n[1]),g:VL(n[2]+n[2]),b:VL(n[3]+n[3]),format:e?"name":"hex"};return!1}(t)),"object"==typeof t&&(KL(t.r)&&KL(t.g)&&KL(t.b)?(e=t.r,n=t.g,r=t.b,i={r:255*kL(e,255),g:255*kL(n,255),b:255*kL(r,255)},c=!0,u="%"===String(t.r).substr(-1)?"prgb":"rgb"):KL(t.h)&&KL(t.s)&&KL(t.v)?(a=LL(t.s),s=LL(t.v),i=function(t,e,n){t=6*kL(t,360),e=kL(e,100),n=kL(n,100);var r=Math.floor(t),i=t-r,o=n*(1-e),a=n*(1-i*e),s=n*(1-(1-i)*e),l=r%6;return{r:255*[n,a,o,o,s,n][l],g:255*[s,n,n,a,o,o][l],b:255*[o,o,s,n,n,a][l]}}(t.h,a,s),c=!0,u="hsv"):KL(t.h)&&KL(t.s)&&KL(t.l)&&(a=LL(t.s),l=LL(t.l),i=function(t,e,n){var r,i,o;if(t=kL(t,360),e=kL(e,100),n=kL(n,100),0===e)i=n,o=n,r=n;else{var a=n<.5?n*(1+e):n+e-n*e,s=2*n-a;r=UL(s,a,t+1/3),i=UL(s,a,t),o=UL(s,a,t-1/3)}return{r:255*r,g:255*i,b:255*o}}(t.h,a,l),c=!0,u="hsl"),Object.prototype.hasOwnProperty.call(t,"a")&&(o=t.a)),o=function(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}(o),{ok:c,format:t.format||u,r:Math.min(255,Math.max(i.r,0)),g:Math.min(255,Math.max(i.g,0)),b:Math.min(255,Math.max(i.b,0)),a:o}}var HL="(?:".concat("[-\\+]?\\d*\\.\\d+%?",")|(?:").concat("[-\\+]?\\d+%?",")"),jL="[\\s|\\(]+(".concat(HL,")[,|\\s]+(").concat(HL,")[,|\\s]+(").concat(HL,")\\s*\\)?"),XL="[\\s|\\(]+(".concat(HL,")[,|\\s]+(").concat(HL,")[,|\\s]+(").concat(HL,")[,|\\s]+(").concat(HL,")\\s*\\)?"),YL={CSS_UNIT:new RegExp(HL),rgb:new RegExp("rgb"+jL),rgba:new RegExp("rgba"+XL),hsl:new RegExp("hsl"+jL),hsla:new RegExp("hsla"+XL),hsv:new RegExp("hsv"+jL),hsva:new RegExp("hsva"+XL),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/};function KL(t){return Boolean(YL.CSS_UNIT.exec(String(t)))}var qL=2,$L=.16,ZL=.05,QL=.05,JL=.15,tF=5,eF=4,nF=[{index:7,opacity:.15},{index:6,opacity:.25},{index:5,opacity:.3},{index:5,opacity:.45},{index:5,opacity:.65},{index:5,opacity:.85},{index:4,opacity:.9},{index:3,opacity:.95},{index:2,opacity:.97},{index:1,opacity:.98}];function rF(t){var e=function(t,e,n){t=kL(t,255),e=kL(e,255),n=kL(n,255);var r=Math.max(t,e,n),i=Math.min(t,e,n),o=0,a=r,s=r-i,l=0===r?0:s/r;if(r===i)o=0;else{switch(r){case t:o=(e-n)/s+(e<n?6:0);break;case e:o=(n-t)/s+2;break;case n:o=(t-e)/s+4}o/=6}return{h:o,s:l,v:a}}(t.r,t.g,t.b);return{h:360*e.h,s:e.s,v:e.v}}function iF(t){var e=t.r,n=t.g,r=t.b;return"#".concat(function(t,e,n,r){var i=[FL(Math.round(t).toString(16)),FL(Math.round(e).toString(16)),FL(Math.round(n).toString(16))];return r&&i[0].startsWith(i[0].charAt(1))&&i[1].startsWith(i[1].charAt(1))&&i[2].startsWith(i[2].charAt(1))?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}(e,n,r,!1))}function oF(t,e,n){var r;return(r=Math.round(t.h)>=60&&Math.round(t.h)<=240?n?Math.round(t.h)-qL*e:Math.round(t.h)+qL*e:n?Math.round(t.h)+qL*e:Math.round(t.h)-qL*e)<0?r+=360:r>=360&&(r-=360),r}function aF(t,e,n){return 0===t.h&&0===t.s?t.s:((r=n?t.s-$L*e:e===eF?t.s+$L:t.s+ZL*e)>1&&(r=1),n&&e===tF&&r>.1&&(r=.1),r<.06&&(r=.06),Number(r.toFixed(2)));var r}function sF(t,e,n){var r;return(r=n?t.v+QL*e:t.v-JL*e)>1&&(r=1),Number(r.toFixed(2))}function lF(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[],r=zL(t),i=tF;i>0;i-=1){var o=rF(r),a=iF(zL({h:oF(o,i,!0),s:aF(o,i,!0),v:sF(o,i,!0)}));n.push(a)}n.push(iF(r));for(var s=1;s<=eF;s+=1){var l=rF(r),c=iF(zL({h:oF(l,s),s:aF(l,s),v:sF(l,s)}));n.push(c)}return"dark"===e.theme?nF.map((function(t){var r,i,o,a=t.index,s=t.opacity;return iF((r=zL(e.backgroundColor||"#141414"),i=zL(n[a]),o=100*s/100,{r:(i.r-r.r)*o+r.r,g:(i.g-r.g)*o+r.g,b:(i.b-r.b)*o+r.b}))})):n}var cF={red:"#F5222D",volcano:"#FA541C",orange:"#FA8C16",gold:"#FAAD14",yellow:"#FADB14",lime:"#A0D911",green:"#52C41A",cyan:"#13C2C2",blue:"#1677FF",geekblue:"#2F54EB",purple:"#722ED1",magenta:"#EB2F96",grey:"#666666"},uF={},hF={};Object.keys(cF).forEach((function(t){uF[t]=lF(cF[t]),uF[t].primary=uF[t][5],hF[t]=lF(cF[t],{theme:"dark",backgroundColor:"#141414"}),hF[t].primary=hF[t][5]}));const dF=(t,e,n)=>{const r=BL(t),i=BL(e);return BL([(1-n)*r.red()+n*i.red(),(1-n)*r.green()+n*i.green(),(1-n)*r.blue()+n*i.blue()]).rgb()},pF=(t,e="#fff",n="light")=>"light"!==n?((t,e="#fff",n="#777")=>{const r=dF(e,t,.2).rgb().toString(),i=dF(e,t,.3).rgb().toString(),o=dF(e,t,.6).rgb().toString(),a=dF(e,t,.8).rgb().toString(),s=dF(e,n,.2).rgb().toString(),l=dF(e,n,.25).rgb().toString(),c=dF(e,n,.3).rgb().toString(),u=dF(e,n,.4).rgb().toString(),h=dF(e,n,.5).rgb().toString(),d=lF(t,{theme:"dark",backgroundColor:e}),p=BL(t).hex().toLowerCase(),f=d.indexOf(p);let g=t;return-1!==f&&(g=d[f+1]),{mainStroke:a,mainFill:r,activeStroke:t,activeFill:i,inactiveStroke:a,inactiveFill:r,selectedStroke:t,selectedFill:r,highlightStroke:t,highlightFill:o,disableStroke:h,disableFill:l,edgeMainStroke:a,edgeActiveStroke:t,edgeInactiveStroke:n,edgeSelectedStroke:t,edgeHighlightStroke:t,edgeDisableStroke:c,comboMainStroke:u,comboMainFill:l,comboActiveStroke:t,comboActiveFill:s,comboInactiveStroke:u,comboInactiveFill:l,comboSelectedStroke:t,comboSelectedFill:s,comboHighlightStroke:g,comboHighlightFill:l,comboDisableStroke:u,comboDisableFill:s}})(t,e,"#777"):((t,e="#fff",n="rgb(150, 150, 150)")=>{const r=dF(e,t,.05).rgb().toString(),i=dF(e,t,.1).rgb().toString(),o=dF(e,t,.2).rgb().toString(),a=dF(e,t,.4).rgb().toString(),s=dF(e,n,.02).rgb().toString(),l=dF(e,n,.05).rgb().toString(),c=dF(e,n,.1).rgb().toString(),u=dF(e,n,.2).rgb().toString(),h=dF(e,n,.3).rgb().toString(),d=lF(t,{theme:"default",backgroundColor:e}),p=BL(t).hex().toLowerCase(),f=d.indexOf(p);let g=t;return-1!==f&&(g=d[f+1]),{mainStroke:t,mainFill:i,activeStroke:t,activeFill:r,inactiveStroke:a,inactiveFill:r,selectedStroke:t,selectedFill:i,highlightStroke:g,highlightFill:o,disableStroke:h,disableFill:l,edgeMainStroke:a,edgeActiveStroke:t,edgeInactiveStroke:u,edgeSelectedStroke:t,edgeHighlightStroke:t,edgeDisableStroke:c,comboMainStroke:h,comboMainFill:s,comboActiveStroke:t,comboActiveFill:r,comboInactiveStroke:h,comboInactiveFill:s,comboSelectedStroke:t,comboSelectedFill:s,comboHighlightStroke:g,comboHighlightFill:s,comboDisableStroke:u,comboDisableFill:l}})(t,e,"rgb(150, 150, 150)");var fF=Object.freeze({__proto__:null,SpecThemeSolver:class extends fL{solver(t,e){const{base:n="light",specification:r}=t,i=e[n],o=Object.assign({},i);return r&&(["node","edge","combo"].forEach((t=>{if(!r[t])return;const{palette:e=o[t].palette,lodStrategy:n=o[t].lodStrategy,dataTypeField:a}=r[t];let{getStyleSets:s}=r[t];a&&!s&&(s=e=>e.map((e=>({default:{keyShape:"edge"===t?{stroke:e}:{fill:e}}}))));const{styles:[l]}=i[t],c=(null==s?void 0:s(e))||{};let u;Re(c)?u=c.map((t=>{const e=Object.assign({},l);return Object.keys(t).forEach((n=>{e[n]=zR([l[n],t[n]])})),e})):(u={others:l},Object.keys(c).forEach((t=>{const e=Object.assign({},l),n=c[t];Object.keys(n).forEach((t=>{e[t]=zR([l[t],n[t]])})),u[t]=e}))),o[t]={dataTypeField:a,palette:e,lodStrategy:n,styles:u}})),o.canvas=Object.assign(Object.assign({},i.canvas),r.canvas)),o}},BaseThemeSolver:fL,SubjectThemeSolver:class extends fL{solver(t,e){const{base:n="light",baseColor:r="#fff",specification:i}=t,o=e[n],a=Object.assign({},o);return i&&(["node","edge","combo"].forEach((t=>{if(!i[t])return;const{palette:e,dataTypeField:s}=i[t],{styles:[l]}=o[t];let c;Re(e)?c=e.map((e=>{const i=pF(e,r,n);return this.getMergeStylesFromColorSet(t,i,l)})):(c={others:l},Object.keys(e).forEach((i=>{const o=e[i],a=pF(o,r,n);c[i]=this.getMergeStylesFromColorSet(t,a,l)}))),a[t]={dataTypeField:s,palette:e,styles:c}})),a.canvas=Object.assign(Object.assign({},o.canvas),i.canvas)),a.canvas=Object.assign(Object.assign({},o.canvas),i.canvas),a}getMergeStylesFromColorSet(t,e,n){const r=Object.assign({},n);return"node"===t?(r.default=zR([n.default,{keyShape:{stroke:e.mainStroke,fill:e.mainFill}}]),r.selected=zR([n.selected,{keyShape:{fill:e.selectedFill,stroke:e.selectedStroke,shadowColor:e.selectedStroke}}]),r.active=zR([n.active,{keyShape:{fill:e.activeFill,stroke:e.activeStroke,shadowColor:e.mainStroke}}]),r.highlight=zR([n.highlight,{keyShape:{fill:e.highlightFill,stroke:e.highlightStroke}}]),r.inactive=zR([n.inactive,{keyShape:{fill:e.inactiveFill,stroke:e.inactiveStroke}}]),r.disable=zR([n.disable,{keyShape:{fill:e.disableFill,stroke:e.disableStroke}}])):"edge"===t?(r.default=zR([n.default,{keyShape:{stroke:e.edgeMainStroke}}]),r.selected=zR([n.selected,{keyShape:{stroke:e.edgeSelectedStroke,shadowColor:e.edgeSelectedStroke}}]),r.active=zR([n.active,{keyShape:{stroke:e.edgeActiveStroke}}]),r.highlight=zR([n.highlight,{keyShape:{stroke:e.edgeHighlightStroke}}]),r.inactive=zR([n.inactive,{keyShape:{stroke:e.edgeInactiveStroke}}]),r.disable=zR([n.disable,{keyShape:{stroke:e.edgeDisableStroke}}])):"combo"===t&&(r.default=zR([n.default,{keyShape:{fill:e.comboMainFill,stroke:e.comboMainStroke}}]),r.selected=zR([n.selected,{keyShape:{stroke:e.comboSelectedStroke,fill:e.comboSelectedFill,shadowColor:e.comboSelectedStroke}}]),r.active=zR([n.active,{keyShape:{stroke:e.comboActiveStroke,fill:e.comboActiveFill}}]),r.highlight=zR([n.highlight,{keyShape:{stroke:e.comboHighlightStroke,fill:e.comboHighlightFill}}]),r.inactive=zR([n.inactive,{keyShape:{stroke:e.comboInactiveStroke,fill:e.comboInactiveFill}}]),r.disable=zR([n.disable,{keyShape:{stroke:e.comboDisableStroke,fill:e.comboDisableFill}}])),r}},mixColor:dF});const gF={stroke:"#000",strokeOpacity:.8,lineWidth:2,fillOpacity:.1,fill:"#ccc"};const mF="url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PHBhdHRlcm4gaWQ9ImdyaWQiIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHBhdGggZD0iTSAwIDEwIEwgNDAgMTAgTSAxMCAwIEwgMTAgNDAgTSAwIDIwIEwgNDAgMjAgTSAyMCAwIEwgMjAgNDAgTSAwIDMwIEwgNDAgMzAgTSAzMCAwIEwgMzAgNDAiIGZpbGw9Im5vbmUiIHN0cm9rZT0iI2UwZTBlMCIgb3BhY2l0eT0iMC4yIiBzdHJva2Utd2lkdGg9IjEiLz48cGF0aCBkPSJNIDQwIDAgTCAwIDAgMCA0MCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZTBlMGUwIiBzdHJva2Utd2lkdGg9IjEiLz48L3BhdHRlcm4+PC9kZWZzPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JpZCkiLz48L3N2Zz4=)";var vF;!function(t){t.redo="redo",t.undo="undo"}(vF||(vF={}));class yF{constructor(t,e){this.action=t,this.ids=e}undo(t){t.executeWithNoStack((()=>{"front"===this.action?t.backItem(this.ids):t.frontItem(this.ids)}))}redo(t){t.executeWithNoStack((()=>{"front"===this.action?t.frontItem(this.ids):t.backItem(this.ids)}))}}class EF{constructor(t){this.changes=t}updateItemsStates(t,e){null==e||e.map((e=>{const{ids:n,states:r,value:i}=e;t.executeWithNoStack((()=>{t.setItemState(n,r,i)}))}))}undo(t){this.updateItemsStates(t,this.changes.oldValue)}redo(t){this.updateItemsStates(t,this.changes.newValue)}}class _F{constructor(t,e){this.changes=t,this.disableAnimate=e}toggleItemsVisible(t,e){t.pauseStack(),Ce(e,(e=>e.visible?t.showItem(e.ids,this.disableAnimate):t.hideItem(e.ids,this.disableAnimate))),t.resumeStack()}undo(t){const{oldValue:e}=this.changes;this.toggleItemsVisible(t,e)}redo(t){const{newValue:e}=this.changes;this.toggleItemsVisible(t,e)}}class bF{constructor(t,e,n,r){this.action=t,this.type=e,this.changes=n,this.upsertAncestors=r}removeChangedData(t){const e=this.changes.map((t=>{var e;return null===(e=t.value)||void 0===e?void 0:e.id})).filter(Boolean);t.executeWithNoStack((()=>{t.removeData(this.type,e)}))}addChangedData(t){const e=this.changes.map((t=>t.value)).filter(Boolean);t.executeWithNoStack((()=>{t.addData(this.type,e)}))}updateChangedData(t,e,n=!1){const r=new Map;"combo"!==this.type||n?this.changes.forEach((t=>{const n=e===vF.undo?t.oldValue:t.newValue;if("number"==typeof n&&isNaN(n)||["x","y"].includes(t.propertyName)&&void 0===n)return;const i=r.get(t.nodeId)||{};r.set(t.id,{id:t.id,data:Object.assign(Object.assign({},i.data),{[t.propertyName]:n})})})):this.changes.forEach((t=>{const e=r.get(t.nodeId)||{};r.set(t.nodeId,{id:t.nodeId,data:Object.assign(Object.assign({},e.data),{parentId:vF.undo?t.oldParentId:t.newParentId})})})),t.pauseStack();const i=Array.from(r.values());n?t.updateNodePosition(i,this.upsertAncestors):t.updateData(this.type,i),t.resumeStack()}undo(t){"add"===this.action&&this.removeChangedData(t),"remove"===this.action&&this.addChangedData(t),"update"===this.action&&this.updateChangedData(t,vF.undo),"updatePosition"===this.action&&this.updateChangedData(t,vF.undo,"updatePosition"===this.action)}redo(t){"remove"===this.action&&this.removeChangedData(t),"add"===this.action&&this.addChangedData(t),"update"===this.action&&this.updateChangedData(t,vF.redo),"updatePosition"===this.action&&this.updateChangedData(t,vF.redo,"updatePosition"===this.action)}}class SF{constructor(t,e){this.action=t,this.ids=e}undo(t){t.executeWithNoStack((()=>{"expandCombo"===this.action?t.collapseCombo(this.ids):t.expandCombo(this.ids)}))}redo(t){t.executeWithNoStack((()=>{"collapseCombo"===this.action?t.collapseCombo(this.ids):t.expandCombo(this.ids)}))}}class xF{static create(t){var{type:e,action:n,changes:r}=t,i=Nc(t,["type","action","changes"]);const o=[],a=Le(r,"type");for(const t in a){const r={NodeDataUpdated:"node",EdgeDataUpdated:"edge",NodeAdded:"node",EdgeAdded:"edge",NodeRemoved:"node",EdgeRemoved:"edge",TreeStructureChanged:"combo"};r[t]&&o.push(new bF(n,e||r[t],a[t],"NodeDataUpdated"===t?i.upsertAncestors:void 0))}const s={updateState:new EF(r),updateVisibility:new _F(r,i.disableAnimate),front:new yF("front",i.ids),back:new yF("back",i.ids),expandCombo:new SF("expandCombo",i.ids),collapseCombo:new SF("collapseCombo",i.ids)};return s[n]&&o.push(s[n]),o}}const TF={add:["addData","addCombo"],remove:["removeData"],update:["updateData","updateNodePosition","updateComboPosition","updatePosition","moveCombo","collapseCombo","expandCombo"],stateChange:["setItemState","clearItemState"],layerChange:["frontItem","backItem"],displayChange:["showItem","hideItem"]},AF=t=>{for(const[e,n]of Object.entries(TF))if(n.includes(t))return e;throw new Error(`Unknown apiName: ${t}. Unable to determine category.`)};class RF{constructor(t=0){this.items=[],this.maxStep=t}push(t){0!==this.maxStep&&this.items.length===this.maxStep&&this.items.shift(),this.items.push(t)}pop(){if(0!==this.items.length)return this.items.pop();throw new Error("Stack is empty")}size(){return this.items.length}clear(){this.items=[]}toArray(){return this.items}}function MF(t,e){e(t),t.children&&t.children.forEach((function(t){t&&MF(t,e)}))}function CF(t){wF(t,!0)}function PF(t){wF(t,!1)}function wF(t,e){var n=e?"visible":"hidden";MF(t,(function(t){t.attr("visibility",n)}))}var NF=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,kc([],Bc(e),!1))||this;return r.addEventListener(ms.INSERTED,(function(){PF(r)})),r}return Pc(e,t),e}(qs);function OF(t){var e=t.appendChild(new NF({class:"offscreen"}));return PF(e),e}var IF=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=Nc(e,["style"]);return t.call(this,wc({style:wc({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return Pc(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=OF(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(rl);function DF(t){return t*Math.PI/180}function BF(t){return Number((180*t/Math.PI).toPrecision(5))}var kF=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}();function LF(t,e){return Se(t)?t.apply(void 0,kc([],Bc(e),!1)):t}var FF,UF=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map((function(t){var e=Bc(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},GF=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach((function(i){var o=Bc(i,2),a=o[0],s=o[1],l=t;Object.prototype.hasOwnProperty.call(e,a)&&(s?we(s)?(we(t[a])||(l[a]={}),n<r?GF(t[a],s,n+1,r):l[a]=e[a]):Re(s)?(l[a]=[],l[a]=l[a].concat(s)):l[a]=s:l[a]=s)}))},VF=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)GF(t,e[r]);return t},WF=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},zF=nn((function(t,e){var n=De(t)?t:t.style.text.toString(),r=e||HF(t),i=r.fontSize,o=r.fontFamily,a=r.fontWeight,s=r.fontStyle,l=r.fontVariant;return FF||(FF=document.createElement("canvas").getContext("2d")),FF.font=[s,l,a,"".concat(i,"px"),o].join(" "),FF.measureText(n).width}),(function(t,e){return[De(t)?t:t.style.text.toString(),Object.values(e||HF(t)).join()].join("")})),HF=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 jF(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function XF(t,e){var n=jF(t);n&&n.attr(e)}function YF(t,e,n){void 0===n&&(n="..."),XF(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function KF(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 qF(t){return"function"==typeof t?t():De(t)||Ue(t)?new IF({style:{text:String(t)}}):t}function $F(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 ZF(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}var QF=function(t,e){return function(n){return t*(1-n)+e*n}};function JF(t,e){return"number"==typeof t&&"number"==typeof e?QF(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]=JF(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=Bc(e,2),o=i[0],a=i[1];o in t?n[o]=JF(t[o],a):r[o]=a})),function(t){return Object.entries(n).forEach((function(e){var n=Bc(e,2),i=n[0],o=n[1];return r[i]=o(t)})),r}}(t,e):function(e){return t}}function tU(t,e){return[t[0]*e,t[1]*e]}function eU(t,e){return[t[0]+e[0],t[1]+e[1]]}function nU(t,e){return[t[0]-e[0],t[1]-e[1]]}function rU(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function iU(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function oU(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function aU(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 sU(t,e){return+t.toPrecision(e)}function lU(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 cU(t,e,n){void 0===e&&(e=!1),void 0===n&&(n=[[0,0],[1,1]]);for(var r=!!e,i=[],o=0,a=t.length;o<a;o+=2)i.push([t[o],t[o+1]]);var s,l,c,u=function(t,e,n,r){var i,o,a,s,l,c,u=[],h=!!r,d=[1/0,1/0],p=[-1/0,-1/0];if(h){d=(i=Bc(r,2))[0],p=i[1];for(var f=0,g=t.length;f<g;f+=1)d=rU(d,v=t[f]),p=iU(p,v)}f=0;for(var m=t.length;f<m;f+=1){var v=t[f];if(0!==f||n)if(f!==m-1||n){o=t[[f?f-1:m-1,f-1][n?0:1]];var y=[0,0];y=tU(y=nU(a=t[n?(f+1)%m:f+1],o),e);var E=oU(v,o),_=oU(v,a),b=E+_;0!==b&&(E/=b,_/=b);var S=tU(y,-E),x=tU(y,_);l=eU(v,S),s=rU(s=eU(v,x),iU(a,v)),s=iU(s,rU(a,v)),l=rU(l=eU(v,S=tU(S=nU(s,v),-E/_)),iU(o,v)),s=eU(v,x=tU(x=nU(v,l=iU(l,rU(o,v))),_/E)),h&&(l=rU(l=iU(l,d),p),s=rU(s=iU(s,d),p)),u.push(c),u.push(l),c=s}else l=v,u.push(c),u.push(l);else c=v}return n&&u.push(u.shift()),u}(i,.4,r,n),h=i.length,d=[];for(o=0;o<h-1;o+=1)s=u[2*o],l=u[2*o+1],c=i[o+1],d.push(["C",s[0],s[1],l[0],l[1],c[0],c[1]]);return r&&(s=u[h],l=u[h+1],c=Bc(i,1)[0],d.push(["C",s[0],s[1],l[0],l[1],c[0],c[1]])),d}var uU=["$el","anchor","cx","cy","d","defX","defY","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 hU(t){return uU.includes(t)}function dU(t){var e={};for(var n in t)hU(n)&&(e[n]=t[n]);return e}function pU(t,e,n){void 0===n&&(n=!1);var r=t.getBBox(),i=r.width,o=r.height,a=e/Math.max(i,o);return n&&t.scale(a),a}var fU=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=Bc(Array.isArray(a)?a:[a,null],2),l=s[0],c=s[1];(h=r(l,o)).__data__=l,null!==c&&(h.__fromElements__=c),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 u=this._elements[o],h=r(l=u.__data__,o);u.appendChild(h),i.push(h)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=Lc(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=Lc(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=Lc(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,c=[],u=[],h=new Set(this._elements),d=[],p=new Set,f=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]}))),m=(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),v=0;v<t.length;v++){var y=t[v],E=e(y,v),_=r(y,v);if(f.has(E))(T=f.get(E)).__data__=y,T.__facet__=!1,u.push(T),h.delete(T),f.delete(E);else if(g.has(E)){(T=g.get(E)).__data__=y,T.__facet__=!0,u.push(T),g.delete(E)}else if(m.has(E)){var b=m.get(E);d.push([y,b]);try{for(var S=(i=void 0,Dc(b)),x=S.next();!x.done;x=S.next()){var T=x.value;h.delete(T)}}catch(t){i={error:t}}finally{try{x&&!x.done&&(o=S.return)&&o.call(S)}finally{if(i)throw i.error}}m.delete(E)}else if(f.has(_)){(T=f.get(_)).__toData__?T.__toData__.push(y):T.__toData__=[y],p.add(T),h.delete(T)}else c.push(y)}var A=[new n([],c,this._parent,this._document),new n(u,null,this._parent,this._document),new n(h,null,this._parent,this._document),new n([],d,this._parent,this._document),new n(p,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,A)},t.prototype.merge=function(t){var e=kc(kc([],Bc(this._elements),!1),Bc(t._elements),!1),r=kc(kc([],Bc(this._transitions),!1),Bc(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),c=i(this._split);return a.merge(o).merge(s).merge(l).merge(c)},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=Bc(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,kc([this._parent,this],Bc(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:qs,rect:nl,circle:Xs,path:Js,text:IF,ellipse:Ks,image:Zs,line:Qs,polygon:tl,polyline:el,html:$s},t}();function gU(t){return new fU([t],null,t,t.ownerDocument)}function mU(t){if(Ue(t))return[t,t,t,t];if(Re(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 vU(t){var e=t.getLocalBounds(),n=Bc([e.min,e.max],2),r=Bc(n[0],2),i=r[0],o=r[1],a=Bc(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 yU(t,e){var n=Bc(t,2),r=n[0],i=n[1],o=Bc(e,2),a=o[0],s=o[1];return r!==a&&i===s}function EU(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function _U(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 bU=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function SU(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach((function(t){var i=Bc(t,2),o=i[0],a=i[1];if("className"===o||"class"===o);else if(bU(o,"show")&&bU(_U(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(EU(t))}(e,"show")?r[o]=a:r[o.replace(new RegExp(EU(e)),"")]=a;else if(!bU(o,"show")&&bU(o,e)!==n){var s=_U(o,e);"filter"===s&&"function"==typeof a||(r[s]=a)}})),r}function xU(t,e){return Object.entries(t).reduce((function(t,n){var r=Bc(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(EU(i))]=o,t}),{})}function TU(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=Bc(t,2),a=o[0],s=o[1];e.includes(a)||(-1!==n.indexOf(a)?i[a]=s:r[a]=s)})),[r,i]}function AU(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 RU(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=Bc([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){}}function MU(){wF(this,"hidden"!==this.attributes.visibility)}var CU=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,VF({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return Pc(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=OF(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&&MU.call(this)},e.prototype.update=function(t,e){var n;return this.attr(VF({},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}(Ys),PU=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"]]},wU=PU,NU=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},OU=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},IU=OU;var DU=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function BU(t){var e=function(t){var e="default";if(Me(t)&&t instanceof Image)e="image";else if(Se(t))e="symbol";else if(De(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 kU=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e.prototype.render=function(t,n){var r=t.symbol,i=t.size,o=void 0===i?16:i,a=Nc(t,["symbol","size"]),s=BU(r);$F(!!s,gU(n),(function(t){t.maybeAppendByClassName("marker",s).attr("className","marker ".concat(s,"-marker")).call((function(t){if("image"===s){var n=2*o;t.styles({img:r,width:n,height:n,x:-o,y:-o})}else{n=o/2;var i=Se(r)?r:e.getSymbol(r);t.styles(wc({path:null==i?void 0:i(0,0,n)},a))}}))}))},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}(CU);function LU(t,...e){return e.reduce(((t,e)=>n=>t(e(n))),t)}function FU(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}kU.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]]})),kU.registerSymbol("hyphen",(function(t,e,n){return[["M",t-n,e],["L",t+n,e]]})),kU.registerSymbol("line",NU),kU.registerSymbol("plus",(function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]})),kU.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]]})),kU.registerSymbol("circle",PU),kU.registerSymbol("point",wU),kU.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"]]})),kU.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"]]})),kU.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"]]})),kU.registerSymbol("diamond",(function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]})),kU.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"]]})),kU.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"]]})),kU.registerSymbol("line",NU),kU.registerSymbol("dot",OU),kU.registerSymbol("dash",IU),kU.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]]})),kU.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]]})),kU.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]]})),kU.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]]})),kU.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 UU=Math.sqrt(50),GU=Math.sqrt(10),VU=Math.sqrt(2);function WU(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>=UU?10:o>=GU?5:o>=VU?2:1)*10**i:-(10**-i)/(o>=UU?10:o>=GU?5:o>=VU?2:1)}const zU=(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=WU(s,l,n),i>0?(s=Math.floor(s/i)*i,l=Math.ceil(l/i)*i,i=WU(s,l,n)):i<0&&(s=Math.ceil(s*i)/i,l=Math.floor(l*i)/i,i=WU(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 HU(t){return!WM(t)&&!UM(t)&&!Number.isNaN(t)}function jU(t,e){return n=>{n.prototype.rescale=function(){this.initRange(),this.nice();const[t]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t))},n.prototype.initRange=function(){const{interpolator:e}=this.options;this.options.range=t(e)},n.prototype.composeOutput=function(t,n){const{domain:r,interpolator:i,round:o}=this.getOptions(),a=e(r.map(t)),s=o?(t=>e=>{const n=t(e);return PM(n)?Math.round(n):n})(i):i;this.output=LU(s,a,n,t)},n.prototype.invert=void 0}}function XU(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 YU(t){const e=vL.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*XU(a,o,e+1/3),255*XU(a,o,e),255*XU(a,o,e-1/3),i]}(r):null}const KU=(t,e)=>n=>t*(1-n)+e*n,qU=(t,e)=>"number"==typeof t&&"number"==typeof e?KU(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=YU(t),r=YU(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,$U=(t,e)=>{const n=KU(t,e);return t=>Math.round(n(t))};function ZU({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function QU(t){return"object"==typeof t?t.valueOf():t}class JU extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=QU,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(ZU({map:this.map,initKey:this.initKey},t))}has(t){return super.has(ZU({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 tG{constructor(t){this.options=KM({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=KM({},this.options,t),this.rescale(t)}rescale(t){}}const eG=Symbol("defaultUnknown");function nG(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function rG(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let a=i.get(e);if(void 0===a){if(o!==eG)return o;a=n.push(e)-1,i.set(e,a)}return r[a%r.length]}function iG(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class oG extends tG{getDefaultOptions(){return{domain:[],range:[],unknown:eG}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&nG(this.domainIndexMap,this.getDomain(),this.domainKey),rG({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&nG(this.rangeIndexMap,this.getRange(),this.rangeKey),rG({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=iG(e),this.rangeKey=iG(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 oG(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 aG(t){return Math.round(1e12*t)/1e12}function sG(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:a,align:s}=t,l=e.length,c=function(t,e){const n=e-t.length;return n>0?[...t,...new Array(n).fill(1)]:n<0?t.slice(0,e):t}(o,l),[u,h]=n,d=h-u,p=d/(2/l*r+1-1/l*i),f=p*i/l,g=p-l*f,m=function(t){const e=Math.min(...t);return t.map((t=>t/e))}(c),v=g/m.reduce(((t,e)=>t+e)),y=new JU(e.map(((t,e)=>{const n=m[e]*v;return[t,a?Math.floor(n):n]}))),E=new JU(e.map(((t,e)=>{const n=m[e]*v+f;return[t,a?Math.floor(n):n]}))),_=Array.from(E.values()).reduce(((t,e)=>t+e)),b=u+(d-(_-_/l*i))*s;let S=a?Math.round(b):b;const x=new Array(l);for(let t=0;t<l;t+=1){x[t]=aG(S);const n=e[t];S+=E.get(n)}return{valueBandWidth:y,valueStep:E,adjustedRange:x}}class lG extends oG{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:eG,flex:[]}}constructor(t){super(t)}clone(){return new lG(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 sG(t);const{range:i,paddingOuter:o,paddingInner:a,round:s,align:l}=t;let c,u,h=i[0];const d=i[1]-h,p=2*o,f=r-a;c=d/Math.max(1,p+f),s&&(c=Math.floor(c)),h+=(d-c*(r-a))*l,u=c*(1-a),s&&(h=Math.round(h),u=Math.round(u));const g=new Array(r).fill(0).map(((t,e)=>h+e*c));return{valueStep:c,valueBandWidth:u,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 cG=(t,e,n)=>{let r,i,o=t,a=e;if(o===a&&n>0)return[o];let s=WU(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},uG=(t,e,n)=>{const[r,i]=t,[o,a]=e;let s,l;return r<i?(s=FU(r,i),l=n(o,a)):(s=FU(i,r),l=n(a,o)),LU(l,s)},hG=(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]=FU(s[t],s[t+1]),o[t]=n(l[t],l[t+1]);return e=>{const n=function(t,e,n,r,i){let o=n||0,a=r||t.length;const s=i||(t=>t);for(;o<a;){const n=Math.floor((o+a)/2);s(t[n])>e?a=n:o=n+1}return o}(t,e,1,r)-1,a=i[n];return LU(o[n],a)(e)}},dG=(t,e,n,r)=>(Math.min(t.length,e.length)>2?hG:uG)(t,e,r?$U:n);class pG extends tG{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:KU,tickCount:5}}map(t){return HU(t)?this.output(t):this.options.unknown}invert(t){return HU(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 zU}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]):eC}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,a=dG(n.map(t),r,o,i);this.output=LU(a,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=dG(i,r.map(t),KU);this.input=LU(e,n,o)}}class fG extends pG{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:qU,tickMethod:cG,tickCount:5}}chooseTransforms(){return[eC,eC]}clone(){return new fG(this.options)}}function gG(t,e){for(var n=[],r=0,i=t.length;r<i;r++)n.push(t[r].substr(0,e));return n}var mG=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],vG=["January","February","March","April","May","June","July","August","September","October","November","December"],yG=gG(vG,3);!function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0,i=e;r<i.length;r++){var o=i[r];for(var a in o)t[a]=o[a]}}({},{dayNamesShort:gG(mG,3),dayNames:mG,monthNamesShort:yG,monthNames:vG,amPm:["am","pm"],DoFn:function(t){return t+["th","st","nd","rd"][t%10>3?0:(t-t%10!=10?1:0)*t%10]}});var EG,_G=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};let bG=EG=class extends fG{getDefaultOptions(){return{domain:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolator:eC,tickMethod:cG,tickCount:5}}constructor(t){super(t)}clone(){return new EG(this.options)}};bG=EG=_G([jU((function(t){return[t(0),t(1)]}),(t=>{const[e,n]=t;return LU(KU(0,1),FU(e,n))}))],bG);var SG,xG=function(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a};let TG=SG=class extends fG{getDefaultOptions(){return{domain:[0,.5,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolator:eC,tickMethod:cG,tickCount:5}}constructor(t){super(t)}clone(){return new SG(this.options)}};TG=SG=xG([jU((function(t){return[t(0),t(.5),t(1)]}),(t=>{const[e,n,r]=t,i=LU(KU(0,.5),FU(e,n)),o=LU(KU(.5,1),FU(n,r));return t=>e>r?t<n?o(t):i(t):t<n?i(t):o(t)}))],TG);var AG=function(t){function e(e){var n=this,r=e.style,i=Nc(e,["style"]);return(n=t.call(this,an({},{type:"column"},wc({style:r},i)))||this).columnsGroup=new qs({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return Pc(e,t),e.prototype.render=function(){var t=this.attributes.columns;gU(this.columnsGroup).selectAll(".column").data(t.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(VF({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(js),RG=function(t){function e(e){var n=this,r=e.style,i=Nc(e,["style"]);return(n=t.call(this,an({},{type:"lines"},wc({style:r},i)))||this).linesGroup=n.appendChild(new qs),n.areasGroup=n.appendChild(new qs),n.render(),n}return Pc(e,t),e.prototype.render=function(){var t=this.attributes,e=t.lines,n=t.areas;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(VF({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){gU(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){gU(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}(js);function MG(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map((function(t,e){return kc([e===n?"M":"L"],Bc(t),!1)}));return e?r.reverse():r}function CG(t,e){if(void 0===e&&(e=!1),t.length<=2)return MG(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];un(o,n.slice(-2))||n.push.apply(n,kc([],Bc(o),!1))}var a=cU(n,!1);return e?a.unshift(kc(["M"],Bc(t[r-1]),!1)):a.unshift(kc(["M"],Bc(t[0]),!1)),a}function PG(t,e,n){var r=tn(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function wG(t){return 0===t.length?[0,0]:[Oe(ze(t,(function(t){return Oe(t)||0}))),Ne(We(t,(function(t){return Ne(t)||0})))]}function NG(t){for(var e=tn(t),n=e[0].length,r=Bc([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 OG=function(t){function e(e){return t.call(this,e,{type:"line",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 Pc(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=tn(t);return Ue(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?NG(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=Bc(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=SU(this.attributes,"area"),a=SU(this.attributes,"line"),s=this.containerShape.width,l=this.data;if(0===l[0].length)return{lines:[],areas:[]};var c=this.scales,u=function(t,e){var n,r=e.x,i=e.y,o=Bc(i.getOptions().range||[0,0],2),a=o[0],s=o[1];return s>a&&(n=Bc([a,s],2),s=n[0],a=n[1]),t.map((function(t){return t.map((function(t,e){return[r.map(e),Fe(i.map(t),s,a)]}))}))}(l,{type:"line",x:c.x,y:c.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=CG(o),s=void 0;if(0===i)s=PG(a,e,n);else{var l=CG(t[i-1],!0),c=o[0];l[0][0]="L",s=kc(kc(kc([],Bc(a),!1),Bc(l),!1),[kc(["M"],Bc(c),!1),["Z"]],!1)}r.push(s)}return r}(u,s,d):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=MG(t[i]),a=void 0;if(0===i)a=PG(o,e,n);else{var s=MG(t[i-1],!0);s[0][0]="L",a=kc(kc(kc([],Bc(o),!1),Bc(s),!1),[["Z"]],!1)}r.push(a)}return r}(u,s,d):function(t,e,n,r){return t.map((function(t){return PG(e?CG(t):MG(t),n,r)}))}(u,i,s,d)}return{lines:u.map((function(e,n){return wc({stroke:t.getColor(n),path:i?CG(e):MG(e)},a)})),areas:h.map((function(e,n){return wc({path:e,fill:t.getColor(n)},o)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=SU(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=NG(s));var l=this.createScales(s),c=l.x,u=l.y,h=Bc(wG(s),2),d=h[0],p=h[1],f=new fG({domain:[0,p-(d>0?0:d)],range:[0,a*o]}),g=c.getBandWidth(),m=this.rawData;return{columns:s.map((function(n,i){return n.map((function(n,o){var a=g/s.length;return wc(wc({fill:t.getColor(i)},e),r?{x:c.map(o),y:u.map(n),width:g,height:f.map(m[i][o])}:{x:c.map(o)+a*i,y:n>=0?u.map(n):u.map(0),width:a,height:f.map(Math.abs(n))})}))}))}},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){var n,r,i;(n=e,r=".container",i="rect",n.querySelector(r)?gU(n).select(r):gU(n).append(i)).attr("className","container").node();var o=t.type,a="spark".concat(o),s="line"===o?this.linesStyle:this.columnsStyle;gU(e).selectAll(".spark").data([o]).join((function(t){return t.append((function(t){return"line"===t?new RG({className:a,style:s}):new AG({className:a,style:s})})).attr("className","spark ".concat(a))}),(function(t){return t.update(s)}),(function(t){return t.remove()}))},e.prototype.getColor=function(t){var e=this.attributes.color;return Re(e)?e[t%e.length]:Se(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,c=this.containerShape,u=c.width,h=c.height,d=Bc(wG(t),2),p=d[0],f=d[1],g=new fG({domain:[null!==(e=s[0])&&void 0!==e?e:p,null!==(n=s[1])&&void 0!==n?n:f],range:[h,h*(1-o)]});return"line"===i?{type:i,x:new fG({domain:[0,t[0].length-1],range:[0,u]}),y:g}:{type:i,x:new lG({domain:t[0].map((function(t,e){return e})),range:[0,u],paddingInner:l,paddingOuter:l/2,align:.5}),y:g}},e.tag="sparkline",e}(CU);function IG(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=Bc(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,wc(wc({},t[e]),n)]:[e,n]})))}function DG(t,e){t?t.finished.then(e):e()}function BG(t,e){"update"in t?t.update(e):t.attr(e)}function kG(t,e,n){return 0===e.length?null:n?t.animate(e,n):(BG(t,{style:e.slice(-1)[0]}),null)}function LG(t,e,n){var r={},i={};return Object.entries(e).forEach((function(e){var n=Bc(e,2),o=n[0],a=n[1];if(!xe(a)){var s=t.style[o]||t.parsedStyle[o]||0;s!==a&&(r[o]=s,i[o]=a)}})),n?kG(t,[r,i],wc({fill:"both"},n)):(BG(t,i),null)}function FG(t,e){return t.style.opacity||(t.style.opacity=1),LG(t,{opacity:0},e)}var UG={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},GG={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},VG={orientation:"horizontal",showLabel:!0,type:"start"},WG=UF({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),zG=UF({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),HG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e.prototype.render=function(t,e){var n=t.size,r=void 0===n?10:n,i=t.radius,o=void 0===i?r/4:i,a=t.orientation,s=Nc(t,["size","radius","orientation"]),l=r,c=2.4*l,u=gU(e).maybeAppendByClassName(zG.iconRect,"rect").styles(wc(wc({},s),{width:l,height:c,radius:o,x:-l/2,y:-c/2})),h=1/3*l,d=2/3*l,p=1/4*c,f=3/4*c;u.maybeAppendByClassName("".concat(zG.iconLine,"-1"),"line").styles(wc({x1:h,x2:h,y1:p,y2:f},s)),u.maybeAppendByClassName("".concat(zG.iconLine,"-2"),"line").styles(wc({x1:d,x2:d,y1:p,y2:f},s)),u.node().setOrigin(l/2,c/2),"vertical"===a?e.setLocalEulerAngles(90):e.setLocalEulerAngles(0)},e}(CU),jG=function(t){function e(e){return t.call(this,e,VG)||this}return Pc(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes.showLabel,r=SU(this.attributes,"label"),i=r.transform,o=Bc(TU(Nc(r,["transform"]),[]),2),a=o[0],s=o[1],l=gU(t).maybeAppendByClassName(zG.labelGroup,"g").styles(s),c=wc(wc({},GG),a),u=c.text,h=Nc(c,["text"]);$F(!!n,l,(function(t){e.label=t.maybeAppendByClassName(zG.label,"text").styles(wc(wc({},h),{transform:i,text:"".concat(u)})),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.orientation,r=e.type,i=wc(wc({orientation:n},UG),SU(this.attributes,"icon")),o=this.attributes.iconShape,a=void 0===o?function(){return new HG({style:i})}:o;gU(t).maybeAppendByClassName(zG.iconGroup,"g").selectAll(zG.icon.class).data([a]).join((function(t){return t.append("string"==typeof a?a:function(){return a(r)}).attr("className",zG.icon.name)}),(function(t){return t.update(i)}),(function(t){return t.remove()}))},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(CU),XG=function(t){function e(e){var n=t.call(this,e,wc(wc(wc({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},xU(VG,"handle")),xU(UG,"handleIcon")),xU(GG,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(KF(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(KF(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 hs("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 Pc(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=SU(this.attributes,"sparkline");return wc(wc({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=Bc(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=Bc(mU(this.attributes.padding),4),e=t[0],n=t[1],r=t[2],i=t[3],o=this.shape;return{x:i,y:e,width:o.width-(i+n),height:o.height-(e+r)}},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(WG.selection.class).each((function(n,r){LG(this,e[r],t)}))},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&LG(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&LG(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=SU(this.attributes,"track");this.trackShape=gU(t).maybeAppendByClassName(WG.track,"rect").styles(wc(wc({},this.shape),e))},e.prototype.renderBrushArea=function(t){var e=this.attributes.brushable;this.brushArea=gU(t).maybeAppendByClassName(WG.brushArea,"rect").styles(wc({fill:"transparent",cursor:e?"crosshair":"default"},this.shape))},e.prototype.renderSparkline=function(t){var e=this;$F("horizontal"===this.attributes.orientation,gU(t).maybeAppendByClassName(WG.sparklineGroup,"g"),(function(t){var n=e.sparklineStyle;t.maybeAppendByClassName(WG.sparkline,(function(){return new OG({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(WG.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 jG({style:e.getHandleStyle(n)})})).each((function(t){var e=t.type;this.attr("class","".concat(WG.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.type,r=e.selectionType;this.foregroundGroup=gU(t).maybeAppendByClassName(WG.foreground,"g");var i=SU(this.attributes,"selection"),o=function(t){return t.style("visibility",(function(t){return t.show?"visible":"hidden"})).style("cursor",(function(t){return"select"===r?"grab":"invert"===r?"crosshair":"default"})).styles(i)},a=this;this.foregroundGroup.selectAll(WG.selection.class).data("value"===n?[]:this.calcSelectionArea().map((function(t,e){return{style:wc({},t),index:e,show:"select"===r?1===e:1!==e}})),(function(t){return t.index})).join((function(t){return t.append("rect").attr("className",WG.selection.name).call(o).each((function(t,e){var n=this;1===e?(a.selectionShape=gU(this),this.on("pointerdown",(function(t){n.attr("cursor","grabbing"),a.onDragStart("selection")(t)})),a.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),a.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),a.dispatchCustomEvent(this,"click","selectionClick"),this.addEventListener("pointerdown",(function(){n.attr("cursor","grabbing")})),this.addEventListener("pointerup",(function(){n.attr("cursor","grab")}))):this.on("pointerdown",a.onDragStart("track"))}))}),(function(t){return t.call(o)}),(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=Bc(this.range,2),i=r[0],o=r[1],a=Bc(this.getValues().map((function(t){return sU(t,e)})),2),s=a[0],l=a[1],c=Bc(((Array.isArray(t)?t:[s,null!=t?t:l])||[s,l]).map((function(t){return sU(t,e)})),2),u=c[0],h=c[1];if("value"===this.attributes.type)return[0,Fe(h,i,o)];u>h&&(u=(n=Bc([h,u],2))[0],h=n[1]);var d=h-u;return d>o-i?[i,o]:u<i?s===i&&l===h?[i,h]:[i,d+i]:h>o?l===o&&s===u?[u,o]:[o-d,o]:[u,h]},e.prototype.calcSelectionArea=function(t){var e=Bc(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=Bc(this.clampValues(),2),l=s[0],c=s[1],u="start"===t?-e:e,h=("start"===t?l:c)*this.getOrientVal([o,a])+u;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?{transform:"rotate(90)",textAlign:"start"}:"end"===t?{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=SU(this.attributes,"handle"),l=SU(s,"label"),c=s.spacing,u=this.getHandleSize(),h=this.clampValues(),d=o("start"===t?h[0]:h[1]),p=new IF({style:wc(wc(wc({},l),this.inferTextStyle(t)),{text:d})}),f=p.getBBox(),g=f.width,m=f.height;if(p.destroy(),!a){if("value"===r)return{text:d,x:0,y:-m-c};var v=c+u+("horizontal"===i?g/2:0);return(e={text:d})["horizontal"===i?"x":"y"]="start"===t?-v:v,e}var y=0,E=0,_=this.availableSpace,b=_.width,S=_.height,x=this.calcSelectionArea()[1],T=x.x,A=x.y,R=x.width,M=x.height,C=c+u;if("horizontal"===i){var P=C+g/2;if("start"===t)y=T-C-g>0?-P:P;else y=b-T-R-C>g?P:-P}else{var w=m+C;E="start"===t?A-u>m?-w:C:S-(A+M)-u>m?w:-C}return{x:y,y:E,text:d}},e.prototype.getHandleLabelStyle=function(t){var e=SU(this.attributes,"handleLabel");return wc(wc(wc({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=SU(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return wc({cursor:n,shape:t,size:r},e)},e.prototype.getHandleStyle=function(t){var e=this.attributes,n=e.showLabel,r=e.showLabelOnInteraction,i=e.orientation,o=this.calcHandlePosition(t),a=this.calcHandleText(t),s=n;return!n&&r&&(s=!!this.target),wc(wc(wc(wc({},xU(this.getHandleIconStyle(),"icon")),xU(wc(wc({},this.getHandleLabelStyle(t)),a),"label")),o),{orientation:i,showLabel:s,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=Bc(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=Bc(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 hs(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}(CU),YG={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 Js({style:{path:[["M",10,10],["L",-10,0],["L",10,-10],["L",0,0],["L",10,10],["Z"]],anchor:"0.5 0.5",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:[]};an({},YG,{style:{type:"arc"}}),an({},YG,{style:{}});var KG=UF({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"),qG=UF({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function $G(t){return t.reduce((function(t,e,n){return t.push(kc([0===n?"M":"L"],Bc(e),!1)),t}),[])}function ZG(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 $G(t);if(!o)return[];var a=oU(t[0],o),s=n?0:1;return t.reduce((function(t,e,n){return 0===n?t.push(kc(["M"],Bc(e),!1)):t.push(kc(["A",a,a,0,0,s],Bc(e),!1)),t}),[])}(t,e,n):$G(t)}function QG(t,e,n){var r=n.type,i=n.connect,o=n.center,a=n.closed?[["Z"]]:[],s=Bc([ZG(t,n),ZG(e.slice().reverse(),n,!0)],2),l=s[0],c=s[1],u=Bc([t[0],e.slice(-1)[0]],2),h=u[0],d=u[1],p=function(t,e){return[l,t,c,e,a].flat()};if("line"===i||"surround"===r)return p([kc(["L"],Bc(d),!1)],[kc(["L"],Bc(h),!1)]);if(!o)throw new Error("Arc grid need to specified center");var f=Bc([oU(d,o),oU(h,o)],2),g=f[0],m=f[1];return p([kc(["A",g,g,0,0,1],Bc(d),!1),kc(["L"],Bc(d),!1)],[kc(["A",m,m,0,0,0],Bc(h),!1),kc(["L"],Bc(h),!1)])}var JG=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Nc(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=Bc(e,1)[0];return wc(wc({},t),{points:kc(kc([],Bc(e),!1),[n],!1)})})):n}(t),i=gU(e).maybeAppendByClassName(qG.lineGroup,"g"),o=gU(e).maybeAppendByClassName(qG.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),path:ZG(t.points,n)}}));return t.selectAll(qG.line.class).data(a,(function(t){return t.id})).join((function(t){return t.append("path").each((function(t,e){var n=LF(dU(wc({path:t.path},r)),[t,e,a]);this.attr(wc({class:qG.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))}))}),(function(t){return t.transition((function(t,e){return LG(this,LF(dU(wc({path:t.path},r)),[t,e,a]),i.update)}))}),(function(t){return t.transition((function(){var t=this,e=FG(this,i.exit);return DG(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=[],c=0;c<e.length-1;c++){var u=Bc([e[c].points,e[c+1].points],2),h=QG(u[0],u[1],n);l.push({path:h,fill:s(c)})}return t.selectAll(qG.region.class).data(l,(function(t,e){return e})).join((function(t){return t.append("path").each((function(t,e){var n=LF(t,[t,e,l]);this.attr(n)})).attr("className",qG.region.name)}),(function(t){return t.transition((function(t,e){return LG(this,LF(t,[t,e,l]),r.update)}))}),(function(t){return t.transition((function(){var t=this,e=FG(this,r.exit);return DG(e,(function(){return t.remove()})),e}))})).transitions()}(o,r,t);return kc(kc([],Bc(a),!1),Bc(s),!1)},e}(CU);function tV(t,e){return Object.fromEntries(Object.entries(t).map((function(t){var n=Bc(t,2);return[n[0],LF(n[1],e)]})))}function eV(t,e){return e&&Se(e)?t.filter(e):t}var nV=nn((function(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}),(function(t,e){return[t,e.startAngle,e.endAngle].join()})),rV=nn((function(t,e){if("linear"===e.type){var n=Bc(e.startPos,2),r=n[0],i=n[1],o=Bc(e.endPos,2),a=Bc([o[0]-r,o[1]-i],2);return aU([a[0],a[1]])}var s=DF(nV(t,e));return[-Math.sin(s),Math.cos(s)]}),(function(t,e){var n=function(t){if("linear"===t.type){var e=t.startPos,n=t.endPos;return kc(kc([],Bc(e),!1),Bc(n),!1)}var r=t.startAngle,i=t.endAngle,o=t.center,a=t.radius;return kc(kc([r,i],Bc(o),!1),[a],!1)}(e);return"arc"===e.type&&n.push(t),n.join()}));function iV(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(rV(t,n),"positive"!==e)}function oV(t,e){return iV(t,e.labelDirection,e)}var aV=nn((function(t,e){var n=Bc(e.startPos,2),r=n[0],i=n[1],o=Bc(e.endPos,2),a=Bc([o[0]-r,o[1]-i],2);return[r+a[0]*t,i+a[1]*t]}),(function(t,e){return kc(kc([t],Bc(e.startPos),!1),Bc(e.endPos),!1).join()})),sV=nn((function(t,e){var n=e.radius,r=Bc(e.center,2),i=r[0],o=r[1],a=DF(nV(t,e));return[i+n*Math.cos(a),o+n*Math.sin(a)]}),(function(t,e){return kc([t,e.startAngle,e.endAngle,e.radius],Bc(e.center),!1).join()}));function lV(t,e){return"linear"===e.type?aV(t,e):sV(t,e)}function cV(t){return 0===rV(0,t)[1]}function uV(t){return 0===rV(0,t)[0]}function hV(t,e){return e-t==360}function dV(t,e,n,r,i){var o=e-t,a=Bc([i,i],2),s=a[0],l=a[1],c=Bc([DF(t),DF(e)],2),u=c[0],h=c[1],d=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},p=Bc(d(u),2),f=p[0],g=p[1],m=Bc(d(h),2),v=m[0],y=m[1];if(hV(t,e)){var E=Bc(d((h+u)/2),2);return[["M",f,g],["A",s,l,0,1,0,E[0],E[1]],["A",s,l,0,1,0,v,y]]}var _=o>180?1:0,b=t>e?0:1;return"M".concat(f,",").concat(g,",A").concat(s,",").concat(l,",0,").concat(_,",").concat(b,",").concat(v,",").concat(y)}function pV(t,e,n,r){var i=e.startAngle,o=e.endAngle,a=e.center,s=e.radius;return t.selectAll(KG.line.class).data([{path:dV.apply(void 0,kc(kc([i,o],Bc(a),!1),[s],!1))}],(function(t,e){return e})).join((function(t){return t.append("path").attr("className",KG.line.name).styles(e).styles({path:function(t){return t.path}})}),(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=JF(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,wc({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return kc(kc([n,r],Bc(i),!1),[o],!1)}(this),kc(kc([i,o],Bc(a),!1),[s],!1),r.update);if(e){var n=function(){var e=dn(t.attributes,"__keyframe_data__");t.style.path=dV.apply(void 0,kc([],Bc(e),!1))};e.onframe=n,e.onfinish=n}return e})).styles(e)}),(function(t){return t.remove()})).styles(n).transitions()}function fV(t){var e=Bc(t,2),n=Bc(e[0],2),r=n[0],i=n[1],o=Bc(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function gV(t,e,n,r){var i=e.showTrunc,o=e.startPos,a=e.endPos,s=e.truncRange,l=e.lineExtension,c=Bc([o,a],2),u=Bc(c[0],2),h=u[0],d=u[1],p=Bc(c[1],2),f=p[0],g=p[1],m=Bc(l?function(t,e,n){void 0===n&&(n=[0,0]);var r=Bc([t,e,n],3),i=Bc(r[0],2),o=i[0],a=i[1],s=Bc(r[1],2),l=s[0],c=s[1],u=Bc(r[2],2),h=u[0],d=u[1],p=Bc([l-o,c-a],2),f=p[0],g=p[1],m=Math.sqrt(Math.pow(f,2)+Math.pow(g,2)),v=Bc([-h/m,d/m],2),y=v[0],E=v[1];return[y*f,y*g,E*f,E*g]}(o,a,l):new Array(4).fill(0),4),v=m[0],y=m[1],E=m[2],_=m[3],b=function(e){return t.selectAll(KG.line.class).data(e,(function(t,e){return e})).join((function(t){return t.append("line").attr("className",(function(t){return"".concat(KG.line.name," ").concat(t.className)})).styles(n).transition((function(t){return LG(this,fV(t.line),!1)}))}),(function(t){return t.styles(n).transition((function(t){return LG(this,fV(t.line),r.update)}))}),(function(t){return t.remove()})).transitions()};if(!i||!s)return b([{line:[[h+v,d+y],[f+E,g+_]],className:KG.line.name}]);var S=Bc(s,2),x=S[0],T=S[1],A=f-h,R=g-d,M=Bc([h+A*x,d+R*x],2),C=M[0],P=M[1],w=Bc([h+A*T,d+R*T],2),N=w[0],O=w[1],I=b([{line:[[h+v,d+y],[C,P]],className:KG.lineFirst.name},{line:[[N,O],[f+E,g+_]],className:KG.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),I}function mV(t,e,n){var r,i=e.type,o=SU(e,"line");return r="linear"===i?gV(t,e,lU(o,"arrow"),n):pV(t,e,lU(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,a=n.showTrunc,s=n.lineArrow,l=n.lineArrowOffset,c=n.lineArrowSize;if(i="arc"===e?t.select(KG.line.class):a?t.select(KG.lineSecond.class):t.select(KG.line.class),!o||!s||"arc"===n.type&&hV(n.startAngle,n.endAngle)){var u=i.node();u&&(u.style.markerEnd=void 0)}else{var h=qF(s);h.attr(r),pU(h,c,!0),i.style("markerEnd",h).style("markerEndOffset",-l)}}(t,i,e,o),r}function vV(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function yV(t,e){var n=e.gridLength;return t.map((function(t,r){var i=t.value,o=Bc(lV(i,e),2),a=o[0],s=o[1],l=Bc(tU(function(t,e){return iV(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[a,s],[a+l[0],s+l[1]]]}}))}function EV(t,e,n,r){var i=SU(n,"grid"),o=i.type,a=i.areaFill,s=vV(n),l=eV(e,n.gridFilter),c="segment"===o?yV(l,n):function(t,e){var n=e.gridControlAngles,r=vV(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=Bc(r,2),o=i[0],a=i[1];return t.map((function(t,r){var i=Bc(lV(t.value,e),2),s=i[0],l=i[1],c=Bc([s-o,l-a],2),u=c[0],h=c[1],d=[];return n.forEach((function(t){var e=DF(t),n=Bc([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=u*r-h*i+o,l=u*i+h*r+a;d.push([s,l])})),{points:d,id:r}}))}(l,n),u=wc(wc({},i),{center:s,areaFill:Se(a)?l.map((function(t,e){return LF(a,[t,e,l])})):a,animate:r,data:c});return t.selectAll(KG.grid.class).data([1]).join((function(t){return t.append((function(){return new JG({style:u})})).attr("className",KG.grid.name)}),(function(t){return t.transition((function(){return this.update(u)}))}),(function(t){return t.remove()})).transitions()}var _V=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),c=Math.sin(t),u=e-e*l+n*c,h=n-e*c-n*l;return[[l*i-c*s+u,c*i+l*s+h],[l*a-c*s+u,c*a+l*s+h],[l*i-c*o+u,c*i+l*o+h],[l*a-c*o+u,c*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 bV(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getLocalBounds(),i=Bc(r.min,2),o=i[0],a=i[1],s=Bc(r.max,2),l=s[0],c=s[1],u=SV(t),h=u.width,d=u.height,p=0,f=0,g=o,m=a,v=jF(t);if(v){d-=1.5;var y=v.style.textAlign,E=v.style.textBaseline;"center"===y?g=(o+l)/2:"right"!==y&&"end"!==y||(g=l),"middle"===E?m=(a+c)/2:"bottom"===E&&(m=c)}var _=Bc(mU(e),4),b=_[0],S=void 0===b?0:b,x=_[1],T=void 0===x?0:x,A=_[2],R=void 0===A?S:A,M=_[3],C=new _V((p+=o)-(void 0===M?T:M),(f+=a)-S,p+h+T,f+d+R);return t.setEulerAngles(n),C.rotatedPoints(DF(n),g,m)}function SV(t){return t.__bbox__?t.__bbox__:t.getBBox()}function xV(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 TV(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 AV(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,c=[e,[9999,e[1]]],u=0,h=0;do{var d=[t[h],t[(h+1)%n]];if(i=c,o=void 0,a=void 0,s=void 0,l=void 0,o=TV((r=d)[0],r[1],i[0]),a=TV(r[0],r[1],i[1]),s=TV(i[0],i[1],r[0]),l=TV(i[0],i[1],r[1]),o!==a&&s!==l||0===o&&xV(r,i[0])||0===a&&xV(r,i[1])||0===s&&xV(i,r[0])||0===l&&xV(i,r[1])){if(0===TV(d[0],e,d[1]))return xV(d,e);u++}h=(h+1)%n}while(0!==h);return!!(1&u)}(t,e)}))}function RV(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=Bc(t,4),r=n[0],i=n[1],o=n[2],a=n[3],s=Bc(e,4),l=s[0],c=s[1],u=o-r,h=a-i,d=s[2]-l,p=s[3]-c,f=u*p-d*h;if(0===f)return!1;var g=f>0,m=r-l,v=i-c,y=u*v-h*m;if(y<0===g)return!1;var E=d*v-p*m;return E<0!==g&&y>f!==g&&E>f!==g}(e,t)}))}function MV(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=Bc(o,2),l=s[0],c=s[1],u="negative"===r?0:i,h=-a-u,d=a+u,p=Bc(mU(e),4),f=p[0],g=p[1],m=p[2],v=p[3];return new _V(l+h-v,c+h-f,l+d+g,c+d+m)}var y=Bc(t.startPos,2),E=y[0],_=y[1],b=Bc(t.endPos,2),S=b[0],x=b[1],T=Bc(uV(t)?[-e,0,e,0]:[0,e,0,-e],4),A=T[0],R=T[1],M=T[2],C=T[3],P=tU(oV(0,t),i),w=new _V(E,_,S,x);return w.x1+=C,w.y1+=A,w.x2+=R+P[0],w.y2+=M+P[1],w}(e,o),c=function(t){return!l||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,a=t.y2;return AV([[r,o],[i,o],[i,a],[r,a]],bV(e,n))}(l,t)},u=function(t,e){return!t||!function(t,e,n){var r,i,o=bV(t,n).flat(1),a=bV(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=Dc(s),c=l.next();!c.done;c=l.next())if(RV(a,c.value))return!0}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}return!1}(t,e,mU(n))};try{for(var h=Dc(t),d=h.next();!d.done;d=h.next()){var p=d.value;c(p)?!s||u(s,p)?s=p:(a.add(s),a.add(p)):a.add(p)}}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 CV(t,e){return void 0===e&&(e={}),xe(t)?0:"number"==typeof t?t:Math.floor(zF(t,e))}var PV=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter((function(t,e){return!(e%r)||(PF(t),!1)}))};var wV=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,c,u=PV,h=function(t){return t.forEach(r.show),t},d=2,p=t.slice(),f=t.slice(),g=Math.min.apply(Math,kc([1],Bc(t.map((function(t){return SV(t).width}))),!1));if("linear"===n.type&&(cV(n)||uV(n))){var m=vU(t[0]).left,v=vU(t[i-1]).right,y=Math.abs(v-m)||1;d=Math.max(Math.floor(i*g/y),d)}for(o&&(s=p.splice(0,1)[0]),a&&(l=p.splice(-1,1)[0],p.reverse()),h(p);d<t.length&&MV((c=l?kc(kc([l],Bc(f),!1),[s],!1):kc([s],Bc(f),!1),c.filter(WF)),n,null==e?void 0:e.margin).length;){if(l&&!s&&d%2==0)p.splice(0,1).forEach(r.hide);else if(l&&s){p.splice(0,1).forEach(r.hide)}f=u(h(p),{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,c=e.recoverWhenFailed,u=void 0===c||c,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 p=Dc(s),f=p.next();!f.done;f=p.next()){if(d(f.value),MV(t,n,l).length<1)return}}catch(t){i={error:t}}finally{try{f&&!f.done&&(o=p.return)&&o.call(p)}finally{if(i)throw i.error}}u&&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,c=e.step,u=void 0===c?" ":c,h=e.margin,d=void 0===h?[0,0,0,0]:h,p=HF(r.getTextShape(t[0])),f=CV(u,p),g=a?CV(a,p):f,m=CV(l,p);(xe(m)||m===1/0)&&(m=Math.max.apply(null,t.map((function(t){return SV(t).width}))));var v=t.slice(),y=Bc(d,4);y[0],y[1],y[2],y[3];for(var E=function(e){if(v.forEach((function(t){r.ellipsis(r.getTextShape(t),e,o)})),(v=MV(t,n,d)).length<1)return{value:void 0}},_=m;_>g+f;_-=f){var b=E(_);if("object"==typeof b)return b.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,c=void 0===l||l,u=e.margin,h=void 0===u?[0,0,0,0]:u,d=t.map((function(t){return t.attr("maxLines")||1})),p=Math.min.apply(Math,kc([],Bc(d),!1)),f=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&cV(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,f)}))};if(!(p>s)){for(var m=p;m<=s;m++)if(g(m),MV(t,n,h).length<1)return;c&&g(d)}}]]);function NV(){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)}var OV=function(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)},IV=nn((function(t,e){var n=Bc(t,2),r=n[0],i=n[1],o=Bc(e,2),a=o[0],s=o[1],l=Bc([r*a+i*s,r*s-i*a],2),c=l[0],u=l[1];return Math.atan2(u,c)}),(function(t,e){return kc(kc([],Bc(t),!1),Bc(e),!1).join()}));function DV(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=oV(t.value,n),a=rV(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return ZF(e,-90,90)||(e+=180),e}(BF("perpendicular"===i?IV([1,0],o):IV([a[0]<0?-1:1,0],a)))}function BV(t,e,n){var r=n.type,i=n.labelAlign,o=oV(t,n),a=OV(e),s=OV(BF(IV([1,0],o))),l="center",c="middle";return"linear"===r?[90,270].includes(s)&&0===a?(l="center",c=1===o[1]?"top":"bottom"):s%180||![90,270].includes(a)?0===s?(ZF(a,0,90,!1,!0)||ZF(a,0,90)||ZF(a,270,360))&&(l="start"):90===s?ZF(a,0,90,!1,!0)?l="start":(ZF(a,90,180)||ZF(a,270,360))&&(l="end"):270===s?ZF(a,0,90,!1,!0)?l="end":(ZF(a,90,180)||ZF(a,270,360))&&(l="start"):180===s&&(90===a?l="start":(ZF(a,0,90)||ZF(a,270,360))&&(l="end")):l="center":"parallel"===i?c=ZF(s,0,180,!0)?"top":"bottom":"horizontal"===i?ZF(s,90,270,!1)?l="end":(ZF(s,270,360,!1)||ZF(s,0,90))&&(l="start"):"perpendicular"===i&&(l=ZF(s,90,270)?"end":"start"),{textAlign:l,textBaseline:c}}function kV(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,a=n.labelDirection,s=n.labelSpacing,l=e.indexOf(t),c=LF(s,[t,l,e]),u=Bc([oV(t.value,n),NV(a,o)],2),h=Bc(eU(tU(u[0],c+(1===u[1]?LF(r?i:0,[t,l,e]):0)),lV(t.value,n)),2);return{x:h[0],y:h[1]}}function LV(t,e){"text"===t.nodeName&&t.attr(e)}function FV(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=wV.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:PF,show:CF,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=BV(e.__data__.value,t,n),i=e.querySelector(KG.labelItem.class);i&&LV(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&YF(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"),XF(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector("text")}})}function UV(t,e,n,r,i){var o=n.indexOf(e),a=gU(t).append(function(t,e,n,r){var i=r.labelFormatter;return Se(i)?function(){return qF(LF(i,[t,e,n,oV(t.value,r)]))}:function(){return qF(t.label||"")}}(e,o,n,i)).attr("className",KG.labelItem.name).node(),s=Bc(TU(tV(r,[e,o,n])),2),l=s[0],c=s[1],u=c.transform,h=Nc(c,["transform"]);RU(t,u);var d=DV(e,t,i);return t.setLocalEulerAngles(+d),LV(a,wc(wc({},BV(e.value,d,i)),l)),RU(t,u),t.attr(h),a}function GV(t,e,n,r){var i=eV(e,n.labelFilter),o=SU(n,"label");return t.selectAll(KG.label.class).data(i,(function(t,e){return e})).join((function(r){return r.append("g").attr("className",KG.label.name).transition((function(t){return UV(this,t,e,o,n),this.attr(kV(t,e,n)),this.__bbox__=t.bbox,null})).call((function(){return FV.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&&PF(t),e.isVisible()&&CF(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,c=Math.ceil(+a/2),u=+a/4,h=function(t){if("circle"===t.nodeName){var e=Bc(t.getLocalPosition(),2),n=e[0],r=e[1],i=t.attr("r");return[n-i,r-i]}return t.getLocalPosition()},d=Bc(h(t),2),p=d[0],f=d[1],g=Bc(h(e),2),m=Bc([(p+g[0])/2-p,(f+g[1])/2-f],2),v=m[0],y=m[1],E=t.style.opacity,_=void 0===E?1:E,b=e.style.opacity,S=void 0===b?1:b,x=t.animate([{opacity:_,transform:"translate(0, 0)"},{opacity:0,transform:"translate(".concat(v,", ").concat(y,")")}],wc(wc({fill:"both"},n),{duration:l+c+u})),T=e.animate([{opacity:0,transform:"translate(".concat(-v,", ").concat(-y,")"),offset:.01},{opacity:S,transform:"translate(0, 0)"}],wc(wc({fill:"both"},n),{duration:c+u,delay:l+c-u}));return DG(T,i),[x,T]}(this.querySelector(KG.labelItem.class),UV(this,t,e,o,n),r.update),a=LG(this,kV(t,e,n),r.update);return this.__bbox__=t.bbox,kc(kc([],Bc(i),!1),[a],!1)})).call((function(e){var r,i,o=dn(e,"_transitions").flat().filter(WF);i=function(){return FV.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=FG(this.childNodes[0],r.exit);return DG(e,(function(){return gU(t).remove()})),e}))})).transitions()}function VV(t,e){return iV(t,e.tickDirection,e)}var WV=nn((function(t,e){var n=Bc(t,2);return[[0,0],[n[0]*e,n[1]*e]]}),(function(t,e){return kc(kc([],Bc(t),!1),[e],!1).join()}));function zV(t,e,n,r,i,o,a){var s=VV(t.value,o),l=function(t,e,n,r,i){var o=i.tickLength,a=Bc(WV(r,LF(o,[t,e,n])),2),s=Bc(a[0],2),l=s[0],c=s[1],u=Bc(a[1],2);return{x1:l,x2:u[0],y1:c,y2:u[1]}}(t,e,n,s,o),c=l.x1,u=l.x2,h=l.y1,d=l.y2,p=Bc(TU(tV(a,[t,e,n,s])),2),f=p[0],g=p[1];"line"===r.node().nodeName&&r.styles(wc({x1:c,x2:u,y1:h,y2:d},f)),i.attr(g),r.styles(f)}function HV(t,e,n,r,i,o){var a=function(t,e,n,r,i){var o=i.tickFormatter,a=VV(e.value,i),s="line";return Se(o)&&(s=function(){return LF(o,[e,n,r,a])}),t.append(s).attr("className",KG.tickItem.name)}(gU(this),t,e,n,r);zV(t,e,n,a,this,r,i);var s=Bc(lV(t.value,r),2);return LG(this,{x:s[0],y:s[1]},o)}var jV=UF({text:"text"},"title");function XV(t){return/\S+-\S+/g.test(t)?t.split("-").map((function(t){return t[0]})):t.length>2?[t[0]]:t.split("")}function YV(t,e){var n=Object.entries(e).reduce((function(e,n){var r=Bc(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e}),{});t.styles(n)}var KV=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 Pc(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(jV.text.class);if(!a)return new kF(0,0,+e,+n);var s=a.getBBox(),l=s.width,c=s.height,u=Bc(mU(i),4),h=u[0],d=u[1],p=u[2],f=u[3],g=Bc([0,0,+e,+n],4),m=g[0],v=g[1],y=g[2],E=g[3],_=XV(r);if(_.includes("i"))return new kF(m,v,y,E);_.forEach((function(t,r){var i,o,a,s;"t"===t&&(i=Bc(0===r?[c+p,+n-c-p]:[0,+n],2),v=i[0],E=i[1]),"r"===t&&(o=Bc([+e-l-f],1),y=o[0]),"b"===t&&(a=Bc([+n-c-h],1),E=a[0]),"l"===t&&(s=Bc(0===r?[l+d,+e-l-d]:[0,+e],2),m=s[0],y=s[1])}));var b=Bc(mU(o),4),S=b[0],x=b[1],T=b[2],A=b[3],R=Bc([A+x,S+T],2),M=R[0],C=R[1];return new kF(m+A,v+S,y-M,E-C)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new kF(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=Nc(t,["width","height","position","spacing"]),i=Bc(TU(r),1)[0],o=function(t){var e,n,r,i,o=t,a=o.width,s=o.height,l=o.position,c=Bc([+a/2,+s/2],2),u=Bc([+c[0],+c[1],"center","middle"],4),h=u[0],d=u[1],p=u[2],f=u[3],g=XV(l);return g.includes("l")&&(h=(e=Bc([0,"start"],2))[0],p=e[1]),g.includes("r")&&(h=(n=Bc([+a,"end"],2))[0],p=n[1]),g.includes("t")&&(d=(r=Bc([0,"top"],2))[0],f=r[1]),g.includes("b")&&(d=(i=Bc([+s,"bottom"],2))[0],f=i[1]),{x:h,y:d,textAlign:p,textBaseline:f}}(t),a=o.x,s=o.y,l=o.textAlign,c=o.textBaseline;$F(!!r.text,gU(e),(function(t){n.title=t.maybeAppendByClassName(jV.text,"text").styles(i).call(YV,{x:a,y:s,textAlign:l,textBaseline:c}).node()}))},e}(CU);function qV(t,e,n,r,i){var o=Bc(TU(SU(r,"title")),2),a=o[0],s=o[1],l=s.transform,c=Nc(s,["transform"]);t.styles(a),e.styles(c);var u=l||function(t,e,n){var r=t.cloneNode(!0);r.style.transform="scale(1, 1)",r.style.transform="none";var i=r.getBBox().height;if("vertical"===e){if("left"===n)return"rotate(-90) translate(0, ".concat(i/2,")");if("right"===n)return"rotate(-90) translate(0, -".concat(i/2,")")}return""}(t.node(),a.direction,a.position);RU(t.node(),u);var h=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,a=XV(i),s=t.node().getLocalBounds(),l=Bc(s.min,2),c=l[0],u=l[1],h=Bc(s.halfExtents,2),d=h[0],p=h[1],f=Bc(e.node().getLocalBounds().halfExtents,2),g=f[0],m=f[1],v=Bc([c+d,u+p],2),y=v[0],E=v[1],_=Bc(mU(o),4),b=_[0],S=_[1],x=_[2],T=_[3];if(["start","end"].includes(i)&&"linear"===n.type){var A=n.startPos,R=n.endPos,M=Bc("start"===i?[A,R]:[R,A],2),C=M[0],P=M[1],w=Bc(tU(aU([-P[0]+C[0],-P[1]+C[1]]),b),2),N=w[0],O=w[1];return{x:C[0]+N,y:C[1]+O}}return a.includes("t")&&(E-=p+m+b),a.includes("r")&&(y+=d+g+S),a.includes("l")&&(y-=d+2*g+T),a.includes("b")&&(E+=p+2*m+x),{x:y,y:E}}(gU(n._offscreen||n.querySelector(KG.mainGroup.class)),e,r),d=h.x,p=h.y,f=LG(e.node(),{x:d,y:p},i);return RU(t.node(),u),f}function $V(t,e,n,r){var i=t.showLine,o=t.showTick,a=t.showLabel,s=$F(i,e.maybeAppendByClassName(KG.lineGroup,"g"),(function(e){return mV(e,t,r)}))||[],l=$F(o,e.maybeAppendByClassName(KG.tickGroup,"g"),(function(e){return function(t,e,n,r){var i=eV(e,n.tickFilter),o=SU(n,"tick");return t.selectAll(KG.tick.class).data(i,(function(t){return t.id||t.label})).join((function(t){return t.append("g").attr("className",KG.tick.name).transition((function(t,e){return HV.call(this,t,e,i,n,o,!1)}))}),(function(t){return t.transition((function(t,e){return this.removeChildren(),HV.call(this,t,e,i,n,o,r.update)}))}),(function(t){return t.transition((function(){var t=this,e=FG(this.childNodes[0],r.exit);return DG(e,(function(){return t.remove()})),e}))})).transitions()}(e,n,t,r)}))||[],c=$F(a,e.maybeAppendByClassName(KG.labelGroup,"g"),(function(e){return GV(e,n,t,r)}))||[];return kc(kc(kc([],Bc(s),!1),Bc(l),!1),Bc(c),!1).filter((function(t){return!!t}))}var ZV=function(t){function e(e){return t.call(this,e,YG)||this}return Pc(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,c=t.dataThreshold,u=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,c).filter((function(t){var e=t.value;return!(u&&e>u[0]&&e<u[1])})),d=IG(void 0===n?a:n),p=$F(l,gU(e).maybeAppendByClassName(KG.gridGroup,"g"),(function(e){return EV(e,h,t,d)}))||[],f=gU(e).maybeAppendByClassName(KG.mainGroup,"g");i&&(!this.initialized&&d.enter||this.initialized&&d.update)&&$V(t,gU(this.offscreenGroup),h,IG(!1));var g=$V(t,gU(f.node()),h,d),m=$F(s,gU(e).maybeAppendByClassName(KG.titleGroup,"g"),(function(e){return function(t,e,n,r){var i=n.titleText;return t.selectAll(KG.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 qF(i)})).attr("className",KG.title.name).transition((function(){return qV(gU(this),t,e,n,r.enter)}))}),(function(i){return i.transition((function(){return qV(gU(this),t,e,n,r.update)}))}),(function(t){return t.remove()})).transitions()}(e,r,t,d)}))||[];return kc(kc(kc([],Bc(p),!1),Bc(g),!1),Bc(m),!1).flat().filter((function(t){return!!t}))},e}(CU),QV=UF({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"),JV=function(t){function e(e){var n=t.call(this,e,{animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonPath:DU(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 qs({class:QV.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new qs({class:QV.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return Pc(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return Fe(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=Bc(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,kc([],Bc(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 kF(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=Bc(this.getFollowingPageDiff(t),2),c=l[0],u=l[1];this.playState="running";var h=kG(a,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-c,", ").concat(-u,")")}],n);return DG(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:Fe(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:Fe(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(QV.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)?CF(e):PF(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 c=Bc("horizontal"===o?[-180,0]:[-90,90],2),u=c[0],h=c[1];e.setLocalEulerAngles(u),n.setLocalEulerAngles(h);var d=e.getBBox(),p=d.width,f=d.height,g=n.getBBox(),m=g.width,v=g.height,y=Math.max(p,l,m),E="horizontal"===o?{offset:[[0,0],[p/2+a,0],[p+l+2*a,0]],textAlign:"start"}:{offset:[[y/2,-f-a],[y/2,0],[y/2,v+a]],textAlign:"center"},_=Bc(E.offset,3),b=Bc(_[0],2),S=b[0],x=b[1],T=Bc(_[1],2),A=T[0],R=T[1],M=Bc(_[2],2),C=M[0],P=M[1],w=E.textAlign,N=r.querySelector("text");N&&(N.style.textAlign=w),e.setLocalPosition(S,x),r.setLocalPosition(A,R),n.setLocalPosition(C,P)},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(QV.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=Bc(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(QV.controller,"g");if(wF(s.node(),a),a){var l=SU(this.attributes,"button"),c=SU(this.attributes,"pageNum"),u=Bc(TU(l),2),h=u[0],d=u[1],p=h.size,f=Nc(h,["size"]),g=!s.select(QV.prevBtnGroup.class).node(),m=s.maybeAppendByClassName(QV.prevBtnGroup,"g").styles(d);this.prevBtnGroup=m.node();var v=m.maybeAppendByClassName(QV.prevBtn,"path"),y=s.maybeAppendByClassName(QV.nextBtnGroup,"g").styles(d);this.nextBtnGroup=y.node(),[v,y.maybeAppendByClassName(QV.nextBtn,"path")].forEach((function(t){t.styles(wc(wc({},f),{transformOrigin:"center"})),pU(t.node(),p,!0)}));var E=s.maybeAppendByClassName(QV.pageInfoGroup,"g");this.pageInfoGroup=E.node(),E.maybeAppendByClassName(QV.pageInfo,"text").styles(c),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=gU(e);this.renderClipPath(n),this.renderController(n),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=en((function(){return t.render(t.attributes,t)}),50);this.playWindow.addEventListener(ms.INSERTED,e),this.playWindow.addEventListener(ms.REMOVED,e)},e}(CU);function tW(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}kU.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"]]})),kU.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]]})),kU.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 eW=UF({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 nW=function(t){function e(e){return t.call(this,e,{span:[1,1],marker:function(){return new Xs({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this}return Pc(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=Bc(mU(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,c=s.valueWidth,u=Bc(this.spacing,2),h=u[0],d=u[1];if(r){var p=r-n-h-d,f=Bc(this.span,2);l=(t=Bc([f[0]*p,f[1]*p],2))[0],c=t[1]}return{width:o+l+c+h+d,height:a,markerWidth:o,labelWidth:l,valueWidth:c}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes.spacing;if(!t)return[0,0];var e=Bc(mU(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=Bc(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(eW.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,c=+(i||a||(l?1:0))*Math.sqrt(2),u=this.markerGroup.node().getBBox(),h=u.width,d=u.height;return(1-c/Math.max(h,d))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes.marker,r=SU(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(eW.markerGroup,"g").style("zIndex",0),$F(!!n,this.markerGroup,(function(){var t=e.markerGroup.node(),i=t.getElementsByClassName(eW.marker.name)[0],o=n();i?o.nodeName===i.nodeName?(!function(t,e){var n,r,i=e.attributes;try{for(var o=Dc(Object.entries(i)),a=o.next();!a.done;a=o.next()){var s=Bc(a.value,2),l=s[0],c=s[1];"id"!==l&&"className"!==l&&t.attr(l,c)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(i,o),gU(i).styles(r)):(i.remove(),gU(o).attr("className",eW.marker.name).styles(r),t.appendChild(o)):(gU(o).attr("className",eW.marker.name).styles(r),t.appendChild(o)),e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]),pU(e.markerGroup.node(),e.scaleSize,!0)}))},e.prototype.renderLabel=function(t){var e=SU(this.attributes,"label"),n=e.text,r=Nc(e,["text"]);this.labelGroup=t.maybeAppendByClassName(eW.labelGroup,"g").style("zIndex",0),this.labelGroup.maybeAppendByClassName(eW.label,(function(){return qF(n)})).styles(r)},e.prototype.renderValue=function(t){var e=this,n=SU(this.attributes,"value"),r=n.text,i=Nc(n,["text"]);this.valueGroup=t.maybeAppendByClassName(eW.valueGroup,"g").style("zIndex",0),$F(this.showValue,this.valueGroup,(function(){e.valueGroup.maybeAppendByClassName(eW.value,(function(){return qF(r)})).styles(i)}))},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=SU(this.attributes,"background");this.background=t.maybeAppendByClassName(eW.backgroundGroup,"g").style("zIndex",-1),this.background.maybeAppendByClassName(eW.background,"rect").styles(wc({width:n,height:r},i))},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=Bc(t.position,3),o=i[0],a=i[1],s=i[2],l=r/2;this.markerGroup.styles({x:o,y:l}),this.labelGroup.styles({x:a,y:l}),YF(this.labelGroup.select(eW.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({x:s,y:l}),YF(this.valueGroup.select(eW.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=gU(e);this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.adjustLayout()},e}(CU),rW=UF({page:"item-page",navigator:"navigator",item:"item"},"items"),iW=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},oW=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:mn,mouseenter:mn,mouseleave:mn})||this;return n.navigatorShape=[0,0],n}return Pc(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=SU(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:wc({layout:n,labelText:s,valueText:l},Object.fromEntries(Object.entries(r).map((function(n){var r=Bc(n,2);return[r[0],LF(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=Bc(this.navigatorShape,1)[0],s=Bc(this.grid,2),l=s[0],c=s[1],u=c*l,h=0;return this.pageViews.children.map((function(e,s){var d,p,f=Math.floor(s/u),g=s%u,m=t.ifHorizontal(c,l),v=[Math.floor(g/m),g%m];"vertical"===n&&v.reverse();var y=Bc(v,2),E=y[0],_=y[1],b=(r-a-(c-1)*o)/c,S=e.getBBox().height,x=Bc([0,0],2),T=x[0],A=x[1];return"horizontal"===n?(T=(d=Bc([h,E*(S+i)],2))[0],A=d[1],h=_===c-1?0:h+b+o):(T=(p=Bc([_*(b+o),h],2))[0],A=p[1],h=E===l-1?0:h+S+i),{page:f,index:s,row:E,col:_,pageIndex:g,width:b,height:S,x:T,y:A}}))},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=Bc(this.navigatorShape,1)[0],a=Bc(this.grid,2),s=a[0],l=a[1],c=Bc([e-o,n],2),u=c[0],h=c[1],d=Bc([0,0,0,0,0,0,0,0],8),p=d[0],f=d[1],g=d[2],m=d[3],v=d[4],y=d[5],E=d[6],_=d[7];return this.pageViews.children.map((function(t,e){var n,o,a,c,d=t.getBBox(),b=d.width,S=d.height,x=0===E?0:i,T=E+x+b;return T<=u&&iW(v,(function(t){return t<l}))?(n=Bc([E+x,_,T],3),p=n[0],f=n[1],E=n[2],{width:b,height:S,x:p,y:f,page:g,index:e,pageIndex:m++,row:y,col:v++}):(o=Bc([y+1,0,0,_+S+r],4),y=o[0],v=o[1],E=o[2],(_=o[3])+S<=h&&iW(y,(function(t){return t<s}))?(a=Bc([E,_,b],3),p=a[0],f=a[1],E=a[2],{width:b,height:S,x:p,y:f,page:g,index:e,pageIndex:m++,row:y,col:v++}):(c=Bc([0,0,b,0,g+1,0,0,0],8),p=c[0],f=c[1],E=c[2],_=c[3],g=c[4],m=c[5],y=c[6],v=c[7],{width:b,height:S,x:p,y:f,page:g,index:e,pageIndex:m++,row:y,col:v++}))}))},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 tW(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(rW.item.class).forEach((function(e){t.appendChild(e)})),t.querySelectorAll(rW.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);gU(t).selectAll(rW.item.class).data(this.renderData,(function(t){return t.id})).join((function(t){return t.append((function(t){var e=t.style;return new nW({style:e})})).attr("className",rW.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=Bc(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=Bc(t,2);return{page:e[0],layouts:e[1]}})),i=kc([],Bc(this.navigator.getContainer().children),!1);r.forEach((function(t){var e=t.layouts,r=n.pageViews.appendChild(new qs({className:rW.page.name}));e.forEach((function(t){var e,n,o,a,s=t.x,l=t.y,c=t.index,u=t.width,h=t.height,d=i[c];r.appendChild(d),n=t,o=d,(a=De(e="__layout__")?e.split("."):e).forEach((function(t,e){e<a.length-1?(Me(o[t])||(o[t]=Ue(a[e+1])?[]:{}),o=o[t]):o[t]=n})),d.update({x:s,y:l,width:u,height:h})}))})),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes.orientation,n=SU(this.attributes,"nav"),r=VF({orientation:e},n),i=this;return t.selectAll(rW.navigator.class).data(["nav"]).join((function(t){return t.append((function(){return new JV({style:r})})).attr("className",rW.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(gU(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new hs(t,{detail:e});this.dispatchEvent(n)},e}(CU),aW=UF({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),sW={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,sW)||this}Pc(e,t),e.prototype.render=function(t,e){var n=gU(e).maybeAppendByClassName(aW.markerGroup,"g");this.renderMarker(n);var r=gU(e).maybeAppendByClassName(aW.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?tW(r,"horizontalHandle","verticalHandle"):i;$F(!!o,t,(function(t){var n=SU(e.attributes,"marker"),r=wc({symbol:o},n);e.marker=t.maybeAppendByClassName(aW.marker,(function(){return new kU({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;$F(r,t,(function(t){var n,r=SU(e.attributes,"label"),o=r.text,l=Nc(r,["text"]),c=(null===(n=t.select(aW.marker.class))||void 0===n?void 0:n.node().getBBox())||{},u=c.width,h=void 0===u?0:u,d=c.height,p=Bc(tW(i,[0,(void 0===d?0:d)+a,"center","top"],[h+a,0,"start","middle"]),4),f=p[0],g=p[1],m=p[2],v=p[3];t.maybeAppendByClassName(aW.label,"text").styles(wc(wc({},l),{x:f,y:g,text:s(o).toString(),textAlign:m,textBaseline:v}))}))}}(CU);var lW={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},cW=VF({},lW,{});VF({},lW,xU(sW,"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 uW=UF({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"),hW=function(t){function e(e){return t.call(this,e,cW)||this}return Pc(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,a=Bc(TU(SU(this.attributes,"title")),2),s=a[0],l=a[1];this.titleGroup=t.maybeAppendByClassName(uW.titleGroup,"g").styles(l);var c=wc(wc({width:e,height:n},s),{text:i?o:""});this.title=this.titleGroup.maybeAppendByClassName(uW.title,(function(){return new KV({style:c})})).update(c)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,a=Bc(TU(SU(this.attributes,"title",!0)),2),s=a[0],l=a[1],c=wc(wc({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(uW.itemsGroup,"g").styles(wc({x:n,y:r},l));var u=this;this.itemsGroup.selectAll(uW.items.class).data(["items"]).join((function(t){return t.append((function(){return new oW({style:c})})).attr("className",uW.items.name).each((function(){u.items=gU(this)}))}),(function(t){return t.update(c)}),(function(t){return t.remove()}))},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().setLocalPosition(e,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 kF(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(),c=XV(r),u=Bc(mU(a?i:0),4),h=u[0],d=u[1],p=u[2],f=u[3],g=Bc(mU(o),4),m=g[0],v=g[1],y=g[2],E=g[3],_=Bc([f+d,h+p],2),b=_[0],S=_[1],x=Bc([E+v,m+y],2),T=x[0],A=x[1];if("l"===c[0])return new kF(s.x,s.y,l.width+s.width+b+T,Math.max(l.height+A,s.height));if("t"===c[0])return new kF(s.x,s.y,Math.max(l.width+T,s.width),l.height+s.height+S+A);var R=Bc([e.attributes.width||l.width,e.attributes.height||l.height],2),M=R[0],C=R[1];return new kF(l.x,l.y,M+s.width+b+T,C+s.height+S+A)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=t.width,r=t.height,i=gU(e);this.renderTitle(i,n,r),this.renderItems(i,this.availableSpace),this.adjustLayout()},e}(CU),dW={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},pW=UF({background:"background",labelGroup:"label-group",label:"label"},"indicator"),fW=function(t){function e(e){var n=t.call(this,e,dW)||this;return n.point=[0,0],n.group=n.appendChild(new qs({})),n.isMutationObserved=!0,n}return Pc(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=Bc(mU(t.padding),4),r=n[0],i=n[1],o=n[2],a=n[3],s=this.label.node().getLocalBounds(),l=s.min,c=s.max,u=new kF(l[0]-a,l[1]-r,c[0]+i-l[0]+a,c[1]+o-l[1]+r),h=this.getPath(e,u),d=SU(this.attributes,"background");this.background=gU(this.group).maybeAppendByClassName(pW.background,"path").styles(wc(wc({},d),{path:h})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=Bc(TU(SU(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var a=Nc(i,["text"]);(this.label=gU(this.group).maybeAppendByClassName(pW.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(pW.label,(function(){return qF(e(n))})).style("text",e(n).toString()).selectAll("text").styles(a)},e.prototype.adjustLayout=function(){var t=Bc(this.point,2),e=t[0],n=t[1];this.group.attr("x",-e).attr("y",-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],c=this.createCorner([s[l].slice(-2),s[l+1].slice(-2)]);return s.splice.apply(s,kc([l+1,1],Bc(c),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=yU.apply(void 0,kc([],Bc(t),!1)),r=Bc(t,2),i=Bc(r[0],2),o=i[0],a=i[1],s=Bc(r[1],2),l=s[0],c=s[1],u=Bc(n?[l-o,[o,l]]:[c-a,[a,c]],2),h=u[0],d=Bc(u[1],2),p=d[0],f=d[1],g=h/2,m=e*(h/Math.abs(h)),v=m/2,y=m*Math.sqrt(3)/2*.8,E=Bc([p,p+g-v,p+g,p+g+v,f],5),_=E[0],b=E[1],S=E[2],x=E[3],T=E[4];return n?(this.point=[S,a-y],[["L",_,a],["L",b,a],["L",S,a-y],["L",x,a],["L",T,a]]):(this.point=[o+y,S],[["L",o,_],["L",o,b],["L",o+y,S],["L",o,x],["L",o,T]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?PF(this):CF(this)},e.prototype.bindEvents=function(){this.label.on(ms.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(CU),gW=function(t){function e(n){var r=t.call(this,VF({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new nl({})),r.label=r.background.appendChild(new qs({})),r}return Pc(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return mU(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=SU(this.attributes,"label");gU(this.label).maybeAppend(".label",(function(){return qF(e)})).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=Bc(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,c=s+n+i,u=SU(this.attributes,"background"),h=this.style,d=h.width,p=void 0===d?0:d,f=h.height,g=void 0===f?0:f,m=h.selected;this.background.attr(wc(wc({},u),{width:Math.max(l,p),height:Math.max(c,g),fill:m?this.selectedColor:"#fff"})),this.label.attr({x:o,y:(c-s)/2})},e.prototype.render=function(){this.renderLabel(),this.renderBackground()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("pointerenter",(function(){t.style.selected||t.background.attr("fill",t.hoverColor)})),this.addEventListener("pointerleave",(function(){t.style.selected||t.background.attr("fill",t.style.backgroundFill)}));var e=this;this.addEventListener("click",(function(){var n=t.style,r=n.label,i=n.value,o=n.onClick;null==o||o(i,{label:r,value:i},e)}))},e.defaultOptions={style:{value:"",label:"",cursor:"pointer"}},e}(CU),mW=function(t){function e(n){var r,i,o=t.call(this,VF({},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 nl({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new nl({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 Pc(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 mU(this.style.dropdownPadding)},enumerable:!1,configurable:!0}),e.prototype.renderSelect=function(){var t,e=this,n=this.style,r=n.width,i=n.height,o=n.bordered,a=n.showDropdownIcon,s=SU(this.attributes,"select"),l=SU(this.attributes,"placeholder");this.select.attr(wc(wc({width:r,height:i},s),{fill:"#fff",strokeWidth:o?1:0}));var c=this.dropdownPadding;a&&gU(this.select).maybeAppend(".dropdown-icon","path").style("d","M-5,-3.5 L0,3.5 L5,-3.5").style("transform","translate(".concat(r-10-c[1]-c[3],", ").concat(i/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var u=null===(t=this.style.options)||void 0===t?void 0:t.find((function(t){return t.value===e.currentValue})),h=wc({x:c[3]},l);gU(this.select).selectAll(".placeholder").data(u?[]:[1]).join((function(t){return t.append("text").attr("className","placeholder").styles(h).style("y",(function(){var t=this.getBBox();return(i-t.height)/2}))}),(function(t){return t.styles(h)}),(function(t){return t.remove()}));var d=SU(this.attributes,"optionLabel"),p=wc({x:c[3]},d);gU(this.select).selectAll(".value").data(u?[u]:[]).join((function(t){return t.append((function(t){return qF(t.label)})).attr("className","value").styles(p).style("y",(function(){var t=this.getBBox();return(i-t.height)/2}))}),(function(t){return t.styles(p)}),(function(t){return t.remove()}))},e.prototype.renderDropdown=function(){var t,e,n=this,r=this.style,i=r.width,o=r.height,a=r.options,s=r.onSelect,l=r.open,c=SU(this.attributes,"dropdown"),u=SU(this.attributes,"option"),h=this.dropdownPadding;gU(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(a,(function(t){return t.value})).join((function(t){return t.append((function(t){return new gW({className:"dropdown-item",style:wc(wc(wc({},t),u),{width:i-h[1]-h[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==s||s(t,e,r),n.dispatchEvent(new hs("change",{detail:{value:t,option:e,item:r}})),PF(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(h[3],", ").concat(h[0]+r,")"))}))}),(function(t){return t.update((function(t){return{selected:t.value===n.currentValue}}))}),(function(t){return t.remove()}));var d=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),p=c.spacing;this.dropdown.attr(wc({y:o+p,width:d.width+h[1]+h[3],height:d.height+h[0]+h[2]},c)),!l&&PF(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?PF(t.dropdown):CF(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||PF(t.dropdown)}))},e.defaultOptions={style:{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}(CU),vW=function(t){function e(n){var r=t.call(this,VF({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new nl({})),r.icon=r.appendChild(new qs({})),r}return Pc(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 mU(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=Bc(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.size,e=t/2,n=SU(this.attributes,"background");this.background.attr(wc({x:-e,y:-e,width:t,height:t},n))},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 fW({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}(CU),yW=function(t,e){return void 0===e&&(e="#565758"),new Js({style:{fill:e,anchor:"0.5 0.5",path:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},EW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),e.prototype.arcPath=function(t,e,n){var r=Bc([n,n],2),i=r[0],o=r[1],a=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=Bc(a(-5/4*Math.PI),2),l=s[0],c=s[1],u=Bc(a(1/4*Math.PI),2),h=u[0],d=u[1];return"M".concat(l,",").concat(c,",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.color,e=this.iconSize,n=this.lineWidth,r=n+.5;gU(this.icon).maybeAppend(".reset","path").styles({stroke:t,lineWidth:n,path:this.arcPath(0,0,e/2-n),markerStart:yW(r,t)})},e}(vW),_W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=e/2,r=e/2/Math.pow(3,.5),i=[[0,0],[0,-r],[-n,0],[0,r],[0,0],[n,-r],[n,r],[0,0]];gU(this.icon).maybeAppend(".backward","polygon").styles({points:i,fill:t})},e}(vW),bW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=e/2,r=e/2/Math.pow(3,.5),i=[[0,0],[0,-r],[n,0],[0,r],[0,0],[-n,-r],[-n,r],[0,0]];gU(this.icon).maybeAppend(".forward","polygon").styles({points:i,fill:t})},e}(vW),SW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=e/3*Math.pow(3,.5)*.8,r=[[n,0],[-n/2,-e/2*.8],[-n/2,e/2*.8],[n,0]];gU(this.icon).maybeAppend(".play","polygon").styles({points:r,fill:t})},e}(vW),xW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=e/3,r=[[-n,-e/2],[-n,e/2],[-n/2,e/2],[-n/2,-e/2],[-n,-e/2],[n/2,-e/2],[n/2,e/2],[n,e/2],[n,-e/2]];gU(this.icon).maybeAppend(".pause","polygon").styles({points:r,fill:t})},e}(vW),TW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=this.lineWidth,r=n;gU(this.icon).maybeAppend(".left-line","line").styles({x1:-e/2,y1:-e/2,x2:-e/2,y2:e/2,stroke:t,lineWidth:n}),gU(this.icon).maybeAppend(".right-line","line").styles({x1:e/2,y1:-e/2,x2:e/2,y2:e/2,stroke:t,lineWidth:n}),gU(this.icon).maybeAppend(".left-arrow","line").styles({x1:0,y1:0,x2:-e/2+2*r,y2:0,stroke:t,lineWidth:n,markerEnd:yW(2*n,t)}),gU(this.icon).maybeAppend(".right-arrow","line").styles({x1:0,y1:0,x2:e/2-2*r,y2:0,stroke:t,lineWidth:n,markerEnd:yW(2*n,t)})},e}(vW),AW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=this.lineWidth;gU(this.icon).maybeAppend(".line","line").styles({x1:0,y1:-e/2,x2:0,y2:e/2,stroke:t,lineWidth:n});var r=n;gU(this.icon).maybeAppend(".left-arrow","line").styles({x1:-e/2-2*r,y1:0,x2:2*-r,y2:0,stroke:t,lineWidth:n,markerEnd:yW(2*n,t)}),gU(this.icon).maybeAppend(".right-arrow","line").styles({x1:e/2+2*r,y1:0,x2:2*r,y2:0,stroke:t,lineWidth:n,markerEnd:yW(2*n,t)})},e}(vW),RW=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},MW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=this.lineWidth,r=(e-2*n-n)/4,i=(e-2*n-n)/2,o=Bc([-e/2+n,e/2-2*n],2),a=o[0],s=o[1];gU(this.icon).maybeAppend(".coordinate","polyline").styles({points:RW(e),stroke:t,lineWidth:n}),gU(this.icon).maybeAppend(".line","polyline").styles({points:[[a,s],[a+r,s-i],[a+2*r,s],[a+4*r,s-2*i]],stroke:t,lineWidth:n})},e}(vW),CW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Pc(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.color,n=this.iconSize,r=this.lineWidth,i=r,o=(n-i)/t.length,a=(n-2*i)/4,s=Bc([-n/2+2*i,n/2-i],2),l=s[0],c=s[1];gU(this.icon).maybeAppend(".coordinate","polyline").styles({points:RW(n),stroke:e,lineWidth:r}),gU(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 l+o*e})).style("y1",c).style("x2",(function(t){var e=t.index;return l+o*e})).style("y2",(function(t){var e=t.value;return c-a*e})).styles({y1:c,stroke:e,lineWidth:r})}))},e}(vW),PW=function(t){function e(e){var n=t.call(this,VF({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return Pc(e,t),e.prototype.renderIcon=function(){var t=this.attributes.color,e=this.iconSize,n=this.lineWidth;gU(this.icon).maybeAppend(".split","line").styles({x1:0,y1:-e/2,x2:0,y2:e/2,stroke:t,lineWidth:n})},e}(vW),wW=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.showBackground=!1,e}return Pc(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return mU(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes.speed,n=void 0===e?1:e,r=function(t,e){return Ie(t,(function(t,n,r){return e.includes(r)||(t[r]=n),t}),{})}(this.attributes,["x","y","width","height","size","color","speed"]),i=Fe(t,20,1/0),o=-i/2,a=wc(wc({},r),{x:o,y:-10,width:i,height:20,defaultValue:n,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}]});gU(this.icon).maybeAppend(".speed",(function(){return new mW({style:a})})).attr("className","speed").each((function(){this.update(a)}))},e.tag="SpeedSelect",e}(vW),NW=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new qs({})),n.currentType=n.attributes.type,n}return Pc(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.x,e.y,e.onChange;var n=Nc(e,["x","y","onChange"]);gU(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 Bc(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 Bc(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}(CU),OW=function(t){function e(e){var n=t.call(this,VF({},{style:{type:"play"}},e))||this;return n.toggles=[["play",SW],["pause",xW]],n}return Pc(e,t),e}(NW),IW=function(t){function e(e){var n=t.call(this,VF({},{style:{type:"range"}},e))||this;return n.toggles=[["range",TW],["value",AW]],n}return Pc(e,t),e}(NW),DW=function(t){function e(e){var n=t.call(this,VF({},{style:{type:"column"}},e))||this;return n.toggles=[["line",MW],["column",CW]],n}return Pc(e,t),e}(NW),BW={reset:EW,speed:wW,backward:_W,playPause:OW,forward:bW,selectionType:IW,chartType:DW,split:PW},kW=function(t){function e(n){var r=t.call(this,VF({},e.defaultOptions,n))||this;return r.background=r.appendChild(new nl({})),r.functions=r.appendChild(new qs({})),r}return Pc(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return mU(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.width,n=t.height,r=SU(this.attributes,"background");this.background.attr(wc({width:e,height:n},r))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,i=n.iconSize,o=n.iconSpacing,a=n.width,s=n.height,l=n.align,c=Bc(this.padding,4),u=c[1],h=c[3],d=r.reduce((function(t,e){return t.length&&e.length?t.concat.apply(t,kc(["split"],Bc(e),!1)):t.concat.apply(t,kc([],Bc(e),!1))}),[]),p=d.length*(i+o)-o,f={left:h+i/2,center:(a-p)/2+i/2,right:a-p-h-u+i/2}[l]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),d.forEach((function(t,n){var r,a=BW[t],l={x:n*(i+o)+f,y:s/2,size:i};if(a===wW?(l.speed=e.attributes.speed,l.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[OW,IW,DW].includes(a)?(l.onChange=function(n){return e.handleFunctionChange(t,{value:n})},a===OW&&(l.type="play"===e.attributes.state?"pause":"play"),a===IW&&(l.type="range"===e.attributes.selectionType?"value":"range"),a===DW&&(l.type="line"===e.attributes.chartType?"column":"line")):l.onClick=function(){return e.handleFunctionChange(t,{value:t})},a===wW){var c=e.getBBox(),u=c.x,h=c.y,d=l.x,p=l.y,g=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;g&&(e.speedSelect=new a({style:wc(wc({},l),{zIndex:100,x:u+d,y:h+p})}),g.appendChild(e.speedSelect))}else e.functions.appendChild(new a({style:l}))}))},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:{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}(CU),LW=function(t){function e(n){var r=t.call(this,VF({},e.defaultOptions,n))||this;return r.bindEvents(),r}return Pc(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}(Xs),FW=function(t){function e(n){return t.call(this,VF({},e.defaultOptions,n))||this}return Pc(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.width,n=t.height,r=SU(this.attributes,"background");gU(this).maybeAppend("background","rect").attr("className","background").styles(wc({x:-e/2,y:-n/2,width:e,height:n},r))},e.prototype.renderIcon=function(){var t=this.attributes.iconSize,e=SU(this.attributes,"icon"),n=t/2;gU(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(wc({x1:-1,y1:-n,x2:-1,y2:n},e)),gU(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(wc({x1:1,y1:-n,x2:1,y2:n},e))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.width,n=t.height,r=t.type,i=SU(this.attributes,"border"),o="start"===r?+e/2:-e/2;gU(this).maybeAppend("border","line").attr("className","border").styles(wc({x1:o,y1:-n/2,x2:o,y2:+n/2},i))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(CU);function UW(t,e){return"number"==typeof t?GW(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()?AU(n,"HH:mm\nYYYY-MM-DD"):AU(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(AU(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?AU(n,"DD\nYYYY-MM"):AU(n,"DD");case"week":return n.getDate()<=7?AU(n,"DD\nYYYY-MM"):AU(n,"DD");case"month":return[0,6].includes(n.getMonth())?AU(n,"MM月\nYYYY"):AU(n,"MM月");case"season":return[0].includes(n.getMonth())?AU(n,"MM月\nYYYY"):AU(n,"MM月");case"year":return AU(n,"YYYY");default:return AU(n,"YYYY-MM-DD HH:mm")}}(t,e)}function GW(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 VW=function(t){function e(n){var r=t.call(this,VF({},e.defaultOptions,n))||this;r.axis=r.appendChild(new ZV({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new XG({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new kW({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?kc([],Bc(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,c=i.playMode,u=i.values;return r.states={chartType:a,playMode:c,selectionType:o,speed:s,state:l},r.setByTimebarValues(u),r}return Pc(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.width,n=t.height,r=t.type,i=t.controllerHeight,o=Fe(+n-i,0,+n),a=new kF(0,+n-i,+e,i),s=0,l="time"===r?10:o;return{axisBBox:"chart"===r?new kF(0,o-(s=35),+e,s):new kF,controllerBBox:a,timelineBBox:new kF(0,"time"===r?o:o-l,+e,l-s)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=Bc(Array.isArray(t)?t:[0,t],2),o=i[0],a=i[1],s=r.length,l=r[Math.floor(o*s)],c=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==c?void 0:c.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=Bc(Array.isArray(t)?t:[void 0,t],2),a=o[0],s=o[1],l=i.find((function(t){return t.time===a})),c=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==c?void 0:c.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,a=Bc(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=Bc(Array.isArray(n)?n:[void 0,n],2),o=i[0],a=i[1],s=this.data,l=s.length,c="value"===r;return[(t=s.findIndex((function(t){return t.time===o})),c?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:c?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=Bc(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 FW({style:{type:t,height:e,iconSize:e/6}})}:function(){return new Qs({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,c=this.data,u=this.attributes,h=u.type,d=u.labelFormatter,p=SU(this.attributes,"chart");p.type;var f=Nc(p,["type"]),g="range"===s;if("time"===h)return wc({handleIconShape:function(){return new LW({})},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?GW(n):AU(n,"YYYY-MM-DD HH:mm:ss")},x:n,y:r,zIndex:1},f);var m="range"===s?5:0,v=c.map((function(t){return t.value}));return wc({handleIconOffset:m,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:v,sparklineType:l,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,x:n,y:r,zIndex:1},f)},e.prototype.renderChart=function(t){void 0===t&&(t=this.space.timelineBBox),this.timeline.update(this.getChartStyle(t))},e.prototype.updateSelection=function(){this.timeline.setValues(this.sliderValues,!0),this.handleSliderChange(this.sliderValues)},e.prototype.getAxisStyle=function(t){var e=this.data,n=this.attributes,r=n.interval,i=n.labelFormatter,o=SU(this.attributes,"axis"),a=t.x,s=t.y,l=t.width,c=kc(kc([],Bc(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}})),u=wc({startPos:[a,s],endPos:[a+l,s],data:c,labelFilter:function(t,e){return e<c.length-1},labelFormatter:function(t){var e=t.time;return i?i(e):UW(e,r)}},o);return u},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=SU(this.attributes,"controller"),l=this,c=wc(wc(wc({},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&&(c.functions=[["reset","speed"],["backward","playPause","forward"],["selectionType"]]),this.controller.update(c)},e.prototype.dispatchOnChange=function(t){var e=this.data,n=this.attributes.onChange,r=this.states,i=r.values,o=r.selectionType,a=Bc(i,2),s=a[0],l=a[1],c=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,c]:c)||null==n||n("range"===o?[s,c]:c)},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=Bc(o,2),c=l[0],u=l[1],h=n.findIndex((function(t){return t.time===c})),d=n.findIndex((function(t){return t.time===u}));-1===d&&(d=r);var p,f="backward"===t?-1:1;"range"===a?"acc"===s?(p=[h,d+f],-1===f&&h===d&&(p=[h,r])):p=[h+f,d+f]:p=[h,d+f];var g=function(t){var e=Bc(t.sort((function(t,e){return t-e})),2),n=e[0],i=e[1],o=function(t){return Fe(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)]}(p);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:{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}(CU);const WW=".legend-category-item-marker";const zW=t=>t?`${t.substring(0,1).toUpperCase()}${t.substring(1)}`:"";var HW=[],jW=[];function XW(t,e){if(e=e||{},void 0===t)throw new Error("insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).");var n,r=!0===e.prepend?"prepend":"append",i=void 0!==e.container?e.container:document.querySelector("head"),o=HW.indexOf(i);return-1===o&&(o=HW.push(i)-1,jW[o]={}),void 0!==jW[o]&&void 0!==jW[o][r]?n=jW[o][r]:(n=jW[o][r]=function(){var t=document.createElement("style");return t.setAttribute("type","text/css"),t}(),"prepend"===r?i.insertBefore(n,i.childNodes[0]):i.appendChild(n)),65279===t.charCodeAt(0)&&(t=t.substr(1,t.length)),n.styleSheet?n.styleSheet.cssText+=t:n.textContent+=t,n}var YW=XW,KW=XW;YW.insertCss=KW,"undefined"!=typeof document&&YW("\n .g6-component-contextmenu {\n border: 1px solid #e2e2e2;\n border-radius: 4px;\n font-size: 12px;\n color: #545454;\n background-color: rgba(255, 255, 255, 0.9);\n padding: 10px 8px;\n box-shadow: rgb(174, 174, 174) 0px 0px 10px;\n }\n .g6-contextmenu-ul {\n padding: 0;\n margin: 0;\n list-style: none;\n }\n .g6-loading-dom {\n border: 5px solid #e5e5e5;\n border-top: 5px solid #227EFF;\n border-radius: 50%;\n width: 25px;\n height: 25px;\n animation: turn-around 1.5s linear infinite;\n }\n @keyframes turn-around {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n");const qW=(t,e)=>{const n=t.getBoundingClientRect(),{clientX:r,clientY:i}=e;return Math.abs(r-n.x)<4&&Math.abs(i-n.y)<4?"left-top":Math.abs(r-n.x)<4&&Math.abs(i-n.y-n.height)<4?"left-bottom":Math.abs(r-n.x-n.width)<4&&Math.abs(i-n.y)<4?"right-top":Math.abs(r-n.x-n.width)<4&&Math.abs(i-n.y-n.height)<4?"right-bottom":Math.abs(r-n.x)<4?"left":Math.abs(i-n.y)<4?"top":Math.abs(i-n.y-n.height)<4&&"bottom"},$W={"left-top":"nwse-resize","right-bottom":"nwse-resize","right-top":"nesw-resize","left-bottom":"nesw-resize",left:"ew-resize",right:"ew-resize",top:"ns-resize",bottom:"ns-resize"};"undefined"!=typeof document&&YW("\n .g6-component-tooltip {\n border: 1px solid #e2e2e2;\n border-radius: 4px;\n font-size: 12px;\n color: #545454;\n background-color: rgba(255, 255, 255, 0.9);\n padding: 10px 8px;\n box-shadow: rgb(174, 174, 174) 0px 0px 10px;\n }\n .tooltip-type {\n padding: 0;\n margin: 0;\n }\n .tooltip-id {\n color: #531dab;\n }\n .g6-loading-dom {\n border: 5px solid #e5e5e5;\n border-top: 5px solid #227EFF;\n border-radius: 50%;\n width: 25px;\n height: 25px;\n animation: turn-around 1.5s linear infinite;\n }\n @keyframes turn-around {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n");const ZW=(t,e)=>{const n={};return Object.entries(t).forEach((([t,r])=>{const i=`${e}${t[0].toUpperCase()}${t.slice(1)}`;n[i]=r})),n},QW=["timestamp","time","date","datetime"],JW=["value","date"],tz=(t,e,n)=>{for(let n=0;n<e.length;n++){const r=e[n],i=null==t?void 0:t[r];if(i)return i}return n};const ez=.01,nz={stroke:"#000",strokeOpacity:.8,lineWidth:2,fillOpacity:1,fill:"#fff"};var rz=Object.freeze({__proto__:null,Fisheye:class extends zD{constructor(t){super(t),this.pointerDown=void 0,this.cacheCenter=void 0,this.dragPrePos=void 0,this.dragging=!1,this.cachedOriginPositions={},this.cachedTransientTexts={},this.initOriginPositions=()=>{const{graph:t}=this,e={};return t.getAllNodesData().forEach((t=>{e[t.id]={x:t.data.x,y:t.data.y,texts:[]}})),this.cachedOriginPositions=e,e},this.scaleRByDrag=pn(this.scaleRByDragMethod.bind(this),this.options.throttle,{leading:!0,trailing:!0}),this.scaleDByDrag=pn(this.scaleDByDragMethod.bind(this),this.options.throttle,{leading:!0,trailing:!0})}getDefaultCfgs(){return{key:`fisheye-${gn()}`,trigger:"mousemove",d:1.5,r:300,delegateStyle:tn(gF),showLabel:!0,maxD:5,minD:0,throttle:16,scaleRBy:"drag",scaleDBy:"drag",showDPercent:!0}}getEvents(){const t={pointerdown:this.onPointerDown,pointerup:this.onPointerUp,wheel:this.onWheel,afterlayout:this.initOriginPositions};switch(this.options.trigger){case"click":return Object.assign(Object.assign({},t),{click:this.magnify});case"drag":return Object.assign(Object.assign({},t),{pointermove:this.onPointerMove});default:return Object.assign(Object.assign({},t),{pointermove:this.magnify})}}init(t){super.init(t);const{r:e,d:n}=this.options;this.cachedTransientTexts={},this.initOriginPositions(),this.r2=e*e,this.molecularParam=(n+1)*e}isInLensDelegate(t,e){const{cx:n,cy:r,r:i}=t.style;return e.x>=n-i&&e.x<=n+i&&e.y>=r-i&&e.y<=r+i}onPointerUp(t){this.pointerDown=void 0,this.cacheCenter=void 0,this.dragging=!1}onPointerMove(t){!this.dragging&&this.pointerDown&&(this.dragging=!0),this.pointerDown&&this.moveDelegate(this.delegate,t)}onPointerDown(t){const{delegate:e}=this;!e||e.destroyed?(this.cacheCenter={x:t.canvas.x,y:t.canvas.y},this.magnify(t)):this.cacheCenter={x:e.attr("cx"),y:e.attr("cy")},this.pointerDown={x:t.canvas.x,y:t.canvas.y},this.dragging=!1,this.dragPrePos={x:t.canvas.x,y:t.canvas.y}}moveDelegate(t,e){this.isInLensDelegate(t,{x:e.canvas.x,y:e.canvas.y})&&(this.delegateCenterDiff={x:e.canvas.x-this.pointerDown.x,y:e.canvas.y-this.pointerDown.y},this.magnify(e,this.cacheCenter))}onWheel(t){const{delegate:e,options:n}=this,{scaleDBy:r,scaleRBy:i}=n;e&&!e.destroyed&&("wheel"!==r&&"wheel"!==i||this.isInLensDelegate(e,{x:t.canvas.x,y:t.canvas.y})&&("wheel"===i&&this.scaleRByWheel(t),"wheel"===r&&this.scaleDByWheel(t)))}scaleRByWheel(t){if(!t||!t.originalEvent)return;t.preventDefault&&t.preventDefault();const{graph:e,options:n}=this;let r;const{delegate:i,maxR:o,minR:a,d:s}=n;let{r:l}=n;const c=(i?{x:i.attr("cx"),y:i.attr("cy")}:void 0)||{x:t.canvas.x,y:t.canvas.y};r=t.originalEvent.deltaY<0?.95:1/.95;const u=e.canvas.context.config.canvas.height;(l>(o||u)&&r>1||l<(a||.05*u)&&r<1)&&(r=1),l*=r,this.options.r=l,this.r2=l*l,this.molecularParam=(s+1)*l,this.delegateCenterDiff=void 0,this.magnify(t,c)}scaleRByDragMethod(t){if(!t)return;const{dragPrePos:e,graph:n,options:r}=this,{maxR:i,minR:o,d:a}=r;let s,{r:l}=r;s=t.canvas.x-e.x<0?.95:1/.95;const c=n.canvas.context.config.canvas,[u=(null==c?void 0:c.width)||500,h=(null==c?void 0:c.height)||500]=n.getSize();(l>(i||h)&&s>1||l<(o||.05*h)&&s<1)&&(s=1),l*=s,this.options.r=l,this.r2=l*l,this.molecularParam=(a+1)*l,this.magnify(t),this.dragPrePos={x:t.canvas.x,y:t.canvas.y}}scaleDByWheel(t){if(!t&&!t.originalEvent)return;t.preventDefault&&t.preventDefault();let e=0;e=t.originalEvent.deltaY<0?-.1:.1;const{d:n,maxD:r,minD:i,r:o}=this.options,a=n+e;if(a<r&&a>i){this.options.d=a,this.molecularParam=(a+1)*o;const{delegate:e}=this,n=e?{x:e.attr("cx"),y:e.attr("cy")}:void 0;this.delegateCenterDiff=void 0,this.magnify(t,n)}}scaleDByDragMethod(t){const{d:e,maxD:n,minD:r,r:i}=this.options,o=e+(t.canvas.x-this.dragPrePos.x>0?.1:-.1);o<n&&o>r&&(this.options.d=o,this.molecularParam=(o+1)*i,this.magnify(t)),this.dragPrePos={x:t.canvas.x,y:t.canvas.y}}magnify(t,e){var n;this.restoreCache();const{r2:r,graph:i,cachedOriginPositions:o,cachedTransientTexts:a,molecularParam:s,delegateCenterDiff:l,options:c}=this,u=Object.keys(o).map((t=>({id:t,data:{x:o[t].x,y:o[t].y}}))),{r:h,d:d,showLabel:p,trigger:f}=c,g=i.getAllNodesData(),m=g.length,v=i.getCanvasByClient(t.client);let y=e?{x:e.x,y:e.y}:{x:v.x,y:v.y};!this.dragging||"mousemove"!==f&&"click"!==f||(y=this.cacheCenter),l&&(y.x+=l.x,y.y+=l.y),this.updateDelegate(y,h,t);for(let t=0;t<m;t++){const e=g[t],{x:l,y:c}=o[e.id];if(isNaN(l)||isNaN(c))continue;const f=(l-y.x)*(l-y.x)+(c-y.y)*(c-y.y);if(!isNaN(f)&&f<r&&0!==f){const t=Math.sqrt(f),r=s*t/(d*t+h),g=(l-y.x)/t,m=(c-y.y)/t,v=g*r+y.x,E=m*r+y.y,_={id:e.id,data:{x:v,y:E}},b=e.data.label||(null===(n=e.data.labelShape)||void 0===n?void 0:n.text);if(p&&2*t<h){const t=`node-text-${e.id}`,n=a[t];if(n)n.attr({x:_.data.x,y:_.data.y}),n.show(),o[e.id].texts.push(n);else if(b){const n=i.drawTransient("text",t,{style:{text:b,x:_.data.x,y:_.data.y,textAlign:"center",textBaseline:"middle",fill:"#000",lineWidth:1,fontSize:12,isBillboard:!0,lod:-1}});a[t]=n,o[e.id].texts.push(n)}}u[e.id]=_}else o[e.id]||(o[e.id]={x:l,y:c,texts:[]})}i.updateNodePosition(Object.values(u))}restoreCache(){const t=Object.assign({},this.cachedOriginPositions);return Object.values(this.cachedOriginPositions).forEach((t=>{var e;null===(e=t.texts)||void 0===e||e.forEach((t=>t.hide()))})),t}updateParams(t){const{r:e,d:n,trigger:r,minD:i,maxD:o,minR:a,maxR:s,scaleDBy:l,scaleRBy:c}=t;isNaN(t.r)||(this.options.r=e,this.r2=e*e),isNaN(n)||(this.options.d=n),isNaN(o)||(this.options.maxD=o),isNaN(i)||(this.options.minD=i),isNaN(s)||(this.options.maxR=s),isNaN(a)||(this.options.minR=a);const{graph:u,dPercentText:h,options:d}=this,{d:p,r:f}=d;this.molecularParam=(p+1)*f,"mousemove"!==r&&"click"!==r&&"drag"!==r||(this.options.trigger=r),"drag"!==l&&"wheel"!==l&&"unset"!==l||(this.options.scaleDBy=l,u.drawTransient("circle","lens-shape",{action:"remove"}),h&&u.drawTransient("text","lens-text-shape",{action:"remove"})),"drag"!==c&&"wheel"!==c&&"unset"!==c||(this.options.scaleRBy=c,u.drawTransient("circle","lens-shape",{action:"remove"}),h&&u.drawTransient("text","lens-text-shape",{action:"remove"}))}updateDelegate(t,e,n){const{graph:r,dPercentText:i}=this;let o=this.delegate;if(!o||o.destroyed){const n=this.options.delegateStyle||gF;o=r.drawTransient("circle","lens-shape",{style:Object.assign({r:e/1.5,cx:t.x,cy:t.y},n)})}else o.attr({cx:t.x,cy:t.y,r:e/1.5});const{d:a,minD:s,maxD:l,showDPercent:c}=this.options;if(c){const n=Math.round((a-s)/(l-s)*100),o=t.y+e/1.5+16;if(!i||i.destroyed){const e=r.drawTransient("text","lens-text-shape",{style:{text:`${n}%`,x:t.x,y:o,fill:"#aaa",stroke:"#fff",lineWidth:1,fontSize:12}});this.dPercentText=e}else i.attr({text:`${n}%`,x:t.x,y:o})}if(this.delegate=o,"drag"!==this.options.trigger){if("drag"===this.options.scaleRBy){if(!this.pointerDown)return;this.scaleRByDrag(n)}if("drag"===this.options.scaleDBy){if(!this.pointerDown)return;this.scaleDByDrag(n)}}}clear(){const{graph:t,delegate:e,cachedOriginPositions:n,dPercentText:r}=this;this.restoreCache(),t.updateNodePosition(Object.keys(n).map((t=>({id:t,data:{x:n[t].x,y:n[t].y}})))),e&&!e.destroyed&&t.drawTransient("circle","lens-shape",{action:"remove"}),r&&!r.destroyed&&t.drawTransient("text","lens-text-shape",{action:"remove"})}destroy(){this.clear()}},Grid:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`grid-${gn()}`,img:mF,follow:!0}}init(t){super.init(t);const e=t.getZoom(),n=t.container,r=this.canvas||n.firstChild.nextSibling,[i,o]=t.getSize(),a=this.options.img||mF,s=yP("<div class='g6-grid-container' style=\"position: absolute; left:0;top:0;right:0;bottom:0;overflow: hidden;\"></div>"),l=yP(`<div \n class='g6-grid' \n style='position:absolute;\n transform-origin: 0% 0% 0px;\n background-image: ${a};\n user-select: none\n '></div>`);s.appendChild(l),EP(s,{width:`${i}px`,height:`${o}px`,left:`${n.offsetLeft}px`,top:`${n.offsetTop}px`}),EP(l,{width:i/e+"px",height:o/e+"px",left:"0px",top:"0px"}),n.insertBefore(s,r),this.container=s}getEvents(){return{viewportchange:this.updateGrid}}updateGrid(t){const e=this.container;let{matrix:n}=t;n||(n=[1,0,0,0,1,0,0,0,1]);const r=this.options.follow;EP(e,{transform:`matrix(${n[0]}, ${n[1]}, ${n[3]}, ${n[4]}, ${r?n[6]:"0"}, ${r?n[7]:"0"})`})}getContainer(){return this.container}destroy(){var t;super.destroy(),null===(t=this.canvas)||void 0===t||t.destroy();const e=this.container;(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)}},getCategoryByApiName:AF,History:class extends zD{constructor(t){super(),this.stackSize=0,this.stackActive=!0,this.withoutStackingCounter=0;const{enableStack:e,stackCfg:n}=an(this.getDefaultCfgs(),t);this.enableStack=e,this.cfg=n,this.isBatching=!1,this.undoStack=new RF(this.cfg.stackSize),this.redoStack=new RF(this.cfg.stackSize),this.initBatchCommands()}getDefaultCfgs(){return{enableStack:!0,stackCfg:{stackSize:0,stackActive:!0,includes:[],excludes:[],ignoreAdd:!1,ignoreRemove:!1,ignoreUpdate:!1,ignoreStateChange:!1,ignoreLayerChange:!1,ignoreDisplayChange:!1}}}init(t){super.init(t),this.clear()}getUndoStack(){return this.undoStack.toArray()}getRedoStack(){return this.redoStack.toArray()}getStack(){return{redoStack:this.getRedoStack(),undoStack:this.getUndoStack()}}clear(){this.clearUndoStack(),this.clearRedoStack()}clearUndoStack(){this.undoStack.clear()}clearRedoStack(){this.redoStack.clear()}isEnable(){return this.enableStack}push(t,e=vF.undo,n=!0){if(this.stackActive){if(e===vF.undo){if(n&&this.clearRedoStack(),ln(t))return;this.undoStack.push(t),this.initBatchCommands()}else this.redoStack.push(t);this.graph.emit("history:change",t,e,n)}else console.error("Stacking operations are currently paused. Unable to push to the stack.")}pauseStack(){this.withoutStackingCounter++,1===this.withoutStackingCounter&&(this.stackActive=!1)}resumeStack(){this.withoutStackingCounter>0&&this.withoutStackingCounter--,0===this.withoutStackingCounter&&(this.stackActive=!0)}undo(){if(this.isEnable()){const t=this.undoStack.pop();if(t){this.push(t,vF.redo,!1);for(let e=t.length-1;e>=0;e--)t[e].undo(this.graph)}}return this}redo(){if(this.isEnable()){const t=this.redoStack.pop();t&&(this.push(t,vF.undo,!1),Ce(t,(t=>t.redo(this.graph))))}return this}canUndo(){return this.isEnable()&&this.undoStack.size()>0}canRedo(){return this.isEnable()&&this.redoStack.size()>0}initBatchCommands(){this.batchCommands=[]}startHistoryBatch(){if(this.isBatching)throw new Error("Ensure that historyBatch processing is stopped before starting.");this.initBatchCommands(),this.isBatching=!0}stopHistoryBatch(){if(!this.isBatching)throw new Error("Ensure that historyBatch processing is started before stopping.");this.push(this.batchCommands),this.isBatching=!1}historyBatch(t){this.startHistoryBatch(),t(),this.stopHistoryBatch()}getEvents(){return{afteritemchange:this.handleUpdateHistory,afteritemzindexchange:this.handleUpdateHistory,afteritemstatechange:this.handleUpdateHistory,afteritemvisibilitychange:this.handleUpdateHistory,aftercollapsecombo:this.handleUpdateHistory,afterexpandcombo:this.handleUpdateHistory}}handleUpdateHistory(t){const{apiName:e,changes:n}=t;if((!n||0!==n.length)&&this.shouldPushToStack(e)){if(this.batchCommands=[...this.batchCommands,...xF.create(t)],this.isBatching)return;this.push(this.batchCommands)}}shouldPushToStack(t){const{includes:e=[],excludes:n=[]}=this.cfg;if(!this.enableStack||!this.stackActive)return!1;if(e.includes(t))return!0;if(n.includes(t))return!1;let r=AF(t);return!r||(r="ignore"+je(r),!this.cfg[r])}notify(t,e,...n){t.emit(e,n)}},Legend:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`legend-${gn()}`,container:null,className:"g6-category-legend",orientation:"horizontal",selectedState:"selected",activeState:"active"}}getEvents(){return{afterrender:this.updateLegend}}init(t){super.init(t);const{size:e="fit-content",orientation:n}=this.options,r=t.getSize();if(this.size=e,this.selectedTypes={node:new Set,edge:new Set},this.activeType={node:void 0,edge:void 0},this.selectedIds={node:new Set,edge:new Set},this.activeIds={node:new Set,edge:new Set},this.styleCache={node:{},edge:{}},"fit-content"===e&&(this.size=["horizontal"===n?r[0]:"fit-content","horizontal"===n?"fit-content":r[1]]),"number"==typeof e[0])this.size[0]=e[0];else if(e[0].includes("%")){const t=Number(e[0].replace("%"))/100||1;this.size[0]=r[0]*t}if("number"==typeof e[1])this.size[1]=e[1];else if("100%"===e[1]){const t=Number(e[0].replace("%"))/100||1;this.size[1]=r[1]*t}}updateLegend(){const{size:t}=this;if(!this.canvas){const e=["fit-content"===t[0]?0:t[0],"fit-content"===t[1]?0:t[1]],{canvas:n,background:r,renderer:i="canvas"}=this.options;n?this.canvas=n:(this.wrapper||(this.wrapper=this.createWrapper()),this.canvas=fR(i,this.wrapper,e[0],e[1],void 0,{background:r})),this.canvas.addEventListener("click",(t=>{var e;if("document"!==(null===(e=t.target)||void 0===e?void 0:e.nodeName))return;const{graph:n,options:r}=this,{activeState:i,selectedState:o}=r;if(this.activeIds.node.size&&n.clearItemState(Array.from(this.activeIds.node),i),this.activeIds.edge.size&&n.clearItemState(Array.from(this.activeIds.edge),i),this.activeIds={node:new Set,edge:new Set},o){const{node:t,edge:e}=this.selectedIds;n.clearItemState(Array.from(t),o),n.clearItemState(Array.from(e),o),this.selectedIds={node:new Set,edge:new Set}}this.selectedTypes.node.forEach((t=>{const e=this.canvas.getRoot().querySelector(`#marker-node-${t}`);if(!e)return;const n=this.styleCache.node[t].lineWidth;e.style.lineWidth=n})),this.selectedTypes.edge.forEach((t=>{const e=this.canvas.getRoot().querySelector(`#marker-edge-${t}`);if(!e)return;const n=this.styleCache.edge[t].lineWidth;e.style.lineWidth=n})),this.selectedTypes={node:new Set,edge:new Set},this.activeType={node:void 0,edge:void 0}}))}this.canvas.ready.then((()=>{this.nodeLegend=this.upsertLegend("node"),this.edgeLegend=this.upsertLegend("edge"),this.updateLayout()}))}createWrapper(){const{options:t,graph:e,size:n}=this,{container:r,className:i}=t;let o;De(r)&&(o=document.getElementById(r)),o||(o=e.container);const a=["fit-content"===n[0]?0:n[0],"fit-content"===n[1]?0:n[1]],s=yP(`<div class='${i}' style='width: ${a[0]}px; height: ${a[1]}px; overflow: hidden;'></div>`);return o.appendChild(s),s}upsertLegend(t="node"){const{graph:e,options:n,canvas:r}=this,{node:i,edge:o,orientation:a}=n,s="node"===t?i:o;if(!(null==s?void 0:s.enable))return;const{title:l,typeField:c,labelFormatter:u,rows:h=1,cols:d=4,colPadding:p=5,rowPadding:f=8,padding:g=[0,0,0,0],labelStyle:m={},markerStyle:v}=s,y={shape:"node"===t?"circle":"line",size:10,color:"#ccc",fillOpacity:.3},E=WR(g),_={};Object.keys(m).forEach((t=>{_[`itemLabel${je(t)}`]=m[t]}));const b=_.itemLabelSpacing,{size:S,grid:x}=this.getLegendSize(h,d,E),T="node"===t?e.getAllNodesData():e.getAllEdgesData(),A=new Set,R={};T.map((t=>{if(t.data[c]){const e=t.data[c];A.add(e),R[e]||(R[e]=t)}}));const M=Array.from(A),C=M.map((t=>({typeValue:t,label:u?u(t):t}))),P=["fill","stroke","fillOpacity","opacity","lineWidth","shadow","shadowBlur","size"],w={};let N;if(v){const e=Object.assign({},y,v||{}),{shape:n}=e,r=Nc(e,["shape"]);N=this.getShapeConfig(t,n),Object.keys(r).forEach((t=>{const e=r[t];let n=e;"object"==typeof e?n=t=>e[t.typeValue]||e[t.typeValue].size||10:Se(e)&&(n=t=>e(t.typeValue)),"color"===t?(w.itemMarkerFill=w.itemMarkerFill||n,w.itemMarkerStroke=w.itemMarkerStroke||n):w[`itemMarker${zW(t)}`]=n}))}else{const n=e.canvas.getRoot(),r=n.getElementById(`${t}-group`)||n,i={},o={x1:-10,y1:0,x2:10,y2:0};M.forEach((t=>{const e=r.find((e=>e.getAttribute("data-item-id")===R[t].id)).querySelector("#keyShape");i[t]={shape:e.nodeName,style:Object.assign(Object.assign({},e.attributes),o)}})),P.forEach((t=>{w[`itemMarker${zW(t)}`]=e=>{const{typeValue:n}=e;let r=t;return"size"===t&&(i[n].style.r&&(r="r"),r="width"),i[n].style[r]||y[t]}})),N=t=>{const{typeValue:e}=t,n=i[e].shape||y.shape;return{Shape:BR[n],style:i[e].style}}}const O=new hW({style:Object.assign(Object.assign(Object.assign({x:E[3],y:E[0],data:C,layout:"flex",orientation:a,gridRow:x[0],gridCol:x[1],colPadding:p,rowPadding:f,width:S[0],height:S[1],titleText:l,itemSpacing:b},_),w),{itemMarker:e=>{const{Shape:n,style:r}=N(e),{typeValue:i}=e;return this.styleCache[t][i]=r,()=>new n({style:r,id:`marker-${t}-${i}`})},mouseenter:e=>this.handleMouseEnter(e,M,c,t,T),mouseleave:e=>this.handleMouseLeave(e,M,c,t),click:e=>this.handleClick(e,M,c,t,T)})});return r.appendChild(O),O}updateLayout(){const{nodeLegend:t,edgeLegend:e,options:n,size:r}=this;if(t&&e){const{node:r,edge:i,orientation:o}=n,{order:a=1,padding:s}=r,{order:l=2,padding:c}=i;let u,h;a<l?(u={padding:WR(s),legend:t},h={padding:WR(c),legend:e}):(h={padding:WR(s),legend:t},u={padding:WR(c),legend:e});const d=u.legend.getRenderBounds();if("horizontal"===o){u.legend.translateLocal([0,-d.min[1]+u.padding[0]]);const t=u.legend.childNodes[1].childNodes[0].childNodes[0].getRenderBounds();if(t){const e=t.max[1]+u.padding[2];h.legend.translateLocal([0,e])}}else{u.legend.translateLocal([-d.min[0]+u.padding[3],0]);const t=u.legend.childNodes[1].childNodes[0].childNodes[0].childNodes[1].getRenderBounds().max[0]+u.padding[1];h.legend.translateLocal([t,0])}}if("fit-content"===r[0]||"fit-content"===r[1]){const t=this.canvas.getRoot().getRenderBounds(),e=["fit-content"===r[0]?t.max[0]-t.min[0]:r[0],"fit-content"===r[1]?t.max[1]-t.min[1]:r[1]];this.canvas.resize(e[0],e[1]),this.wrapper&&(this.wrapper.style.width=`${e[0]}px`,this.wrapper.style.height=`${e[1]}px`)}}getShapeConfig(t,e){const n="node"===t?Xs:Qs,r="node"===t?{r:10,width:20,height:20,lineWidth:1}:{lineWidth:4,x1:-10,y1:0,x2:10,y2:0};if("string"==typeof e){const t=BR[e]||n;return()=>({Shape:t,style:r})}return t=>{const i=e[t.typeValue];if("string"==typeof i){return{Shape:BR[i],style:r}}{const{type:t,style:e}=i;return{Shape:BR[t]||n,style:Object.assign(Object.assign({},r),e)}}}}getLegendSize(t,e,n){const{graph:r,options:i,size:o}=this,{orientation:a}=i;let[s,l]=o,c=[t,e];const[u,h]=r.getSize();return"horizontal"===a?("fit-content"===o[0]&&(s=u),"fit-content"===o[1]&&(l=50)):("fit-content"===o[0]&&(s=50),"fit-content"===o[1]&&(l=h),c=[e,t]),s+=n[1]+n[3],l+=n[0]+n[2],{size:[s,l],grid:c}}handleMouseEnter(t,e,n,r,i){const{graph:o,options:a}=this,{activeState:s}=a;if(!s)return;const{index:l}=t.__data__,c=e[l];this.activeType[n]=c;const u=i.filter((t=>t.data[n]===c)).map((t=>t.id));o.setItemState(u,s,!0),u.forEach((t=>this.activeIds[r].add(t))),t.querySelector(WW).style.lineWidth=this.styleCache[r][c].lineWidth+2||4}handleMouseLeave(t,e,n,r){const{graph:i,options:o}=this,{activeState:a}=o;if(!a)return;this.activeType[n]=void 0;const s=i.findIdByState(r,a,!0),{index:l}=t.__data__,c=e[l];this.selectedTypes[r].has(c)?t.querySelector(WW).style.lineWidth=this.styleCache[r][c].lineWidth+4||6:t.querySelector(WW).style.lineWidth=this.styleCache[r][c].lineWidth||1,i.setItemState(s,a,!1),s.forEach((t=>this.activeIds[r].delete(t)))}handleClick(t,e,n,r,i){const{graph:o,options:a}=this,{selectedState:s}=a;if(!s)return;const{index:l}=t.__data__,c=e[l],u=i.filter((t=>t.data[n]===c)).map((t=>t.id));this.selectedTypes[r].has(c)?(this.selectedTypes[r].delete(c),u.forEach((t=>this.selectedIds[r].delete(t))),o.setItemState(u,s,!1),t.querySelector(WW).style.lineWidth=4):(this.selectedTypes[r].add(c),u.forEach((t=>this.selectedIds[r].add(t))),o.setItemState(u,s,!0),t.querySelector(WW).style.lineWidth=this.styleCache[r][c].lineWidth+4||6)}destroy(){var t;super.destroy(),null===(t=this.canvas)||void 0===t||t.destroy()}},Menu:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`menu-${gn()}`,offsetX:6,offsetY:6,handleMenuClick:void 0,getContent:t=>"\n <ul class='g6-contextmenu-ul'>\n <li class='g6-contextmenu-li'>菜单项1</li>\n <li class='g6-contextmenu-li'>菜单项2</li>\n </ul>\n ",shouldBegin:t=>!0,onHide:()=>!0,itemTypes:["node","edge","combo"],trigger:"click",container:null,loadingContent:"<div class='g6-loading-dom'></div>",liHoverStyle:{color:"white","background-color":"#227EFF"}}}getEvents(){return"click"===this.options.trigger?{click:this.onMenuShow,touchend:this.onMenuShow}:{contextmenu:this.onMenuShow}}init(t){super.init(t);const e=this.options.className;YW(`\n .g6-contextmenu-li:hover{\n ${Object.keys(this.options.liHoverStyle).map((t=>`${t}:${this.options.liHoverStyle[t]};`)).join("")}\n }\n `);const n=yP(`<div class=${e||"g6-component-contextmenu"}></div>`);EP(n,{top:"0px",position:"absolute",visibility:"hidden"});let r=this.options.container;r||(r=this.graph.container),De(r)&&(r=document.getElementById(r)),r.appendChild(n),this.menu=n}onMenuShow(t){return Oc(this,void 0,void 0,(function*(){const e=this;t.preventDefault(),e.onMenuHide();const n=this.options.itemTypes;if(t.itemId){if(t.itemId&&t.itemType&&-1===n.indexOf(t.itemType))return void e.onMenuHide()}else if(-1===n.indexOf("canvas"))return void e.onMenuHide();if(!(0,this.options.shouldBegin)(t))return;const r=this.menu,i=this.graph,o=this.options.getContent(t),a=i.getSize()[0],s=i.getSize()[1],l=r.getBoundingClientRect(),c=this.options.offsetX||0,u=this.options.offsetY||0,h=this.graph.container.offsetTop,d=this.graph.container.offsetLeft;let p=t.viewport.x+d+c,f=t.viewport.y+h+u-55;if(p+l.width>a&&(p-=l.width+d+c),f+l.height>s&&(f-=l.height+h+u),EP(r,{top:`${f}px`,left:`${p}px`,visibility:"visible"}),De(o))r.innerHTML=o;else if(o instanceof HTMLElement)r.innerHTML=o.outerHTML;else{if(De(this.options.loadingContent)?r.innerHTML=this.options.loadingContent:r.innerHTML=this.options.loadingContent.outerHTML,t.itemId==this.currentTarget&&this.asyncMenu||(this.currentTarget=t.itemId,this.asyncMenu=yield this.options.getContent(t)),t.itemId!=this.currentTarget)return;De(this.asyncMenu)?r.innerHTML=this.asyncMenu:r.innerHTML=this.asyncMenu.outerHTML}this.removeMenuEventListener();const g=this.options.handleMenuClick;g&&(this.handleMenuClickWrapper=e=>{g(e.target,t.itemId,i)},r.addEventListener("click",this.handleMenuClickWrapper));let m="click"===this.options.trigger;const v=t=>{m?m=!1:e.onMenuHide()};document.body.addEventListener("click",v),this.handler=v}))}removeMenuEventListener(){const t=this.handleMenuClickWrapper,e=this.handler;if(t){this.menu.removeEventListener("click",t),this.handleMenuClickWrapper=null}e&&document.body.removeEventListener("click",e)}onMenuHide(){const t=this.menu;t&&(EP(t,{visibility:"hidden"}),this.removeMenuEventListener())}destroy(){const t=this.menu;if(this.removeMenuEventListener(),t){let e=this.options.container;e||(e=this.graph.container),De(e)&&(e=document.getElementById(e)),e.removeChild(t)}}},Minimap:class extends zD{constructor(t){super(t),this.itemMap=new Map,this.visibleCache={},this.handleUpdateCanvas=en((t=>{this.destroyed||this.updateCanvas()}),100,!1),this.handleVisibilityChange=t=>{const{ids:e,value:n}=t;e.forEach((t=>{this.visibleCache[t]=n})),this.debounceCloneVisibility()},this.debounceCloneVisibility=en((()=>{const t=this.canvas.getRoot().getElementById("node-group"),e=this.canvas.getRoot().getElementById("edge-group");((null==t?void 0:t.childNodes)||[]).concat((null==e?void 0:e.childNodes)||[]).forEach((t=>{var e;const n=null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"data-item-id");this.visibleCache.hasOwnProperty(n)&&(this.visibleCache[n]?t.childNodes.forEach((t=>t.show())):!1===this.visibleCache[n]&&t.childNodes.forEach((t=>t.hide())))})),this.visibleCache={}}),50,!1)}getDefaultCfgs(){return{key:`minimap-${gn()}`,container:null,className:"g6-minimap",viewportClassName:"g6-minimap-viewport",mode:"default",padding:8,size:[200,120],delegateStyle:{fill:"#40a9ff",stroke:"#096dd9"},refresh:!0,hideEdge:!1}}getEvents(){return{afteritemstatechange:this.handleUpdateCanvas,afterlayout:this.handleUpdateCanvas,viewportchange:this.handleUpdateCanvas,afteritemchange:this.handleUpdateCanvas,afteritemvisibilitychange:this.handleVisibilityChange}}disableRefresh(){this.options.refresh=!1}enableRefresh(){this.options.refresh=!0,this.updateCanvas()}initViewport(){const{canvas:t,options:e,destroyed:n,graph:r}=this,{size:i,viewportClassName:o}=e;if(n)return;const a=t.context.config.container,s=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,l=navigator.userAgent.toLowerCase().indexOf("safari")>-1,c=yP(`\n <div\n class=${o}\n style='position:absolute;\n left:0;\n top:0;\n border: 2px solid #1980ff;\n box-sizing:border-box;\n background: rgba(0, 0, 255, 0.1);\n cursor:move'\n draggable=${!l&&!s}\n />`);let u=0,h=0,d=!1,p=!1;const f=l||s?"mousedown":"dragstart";this.container.addEventListener("mousemove",(t=>{const e=qW(c,t);e?(this.container.style.cursor=$W[e],c.style.cursor=$W[e]):(this.container.style.cursor="unset",c.style.cursor="move")})),c.addEventListener(f,(t=>{var e,n;if(p=qW(c,t),!p){if(t.dataTransfer){const r=new Image;r.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' %3E%3Cpath /%3E%3C/svg%3E",null===(n=(e=t.dataTransfer).setDragImage)||void 0===n||n.call(e,r,0,0);try{t.dataTransfer.setData("text/html","view-port-minimap")}catch(e){t.dataTransfer.setData("text","view-port-minimap")}}this.options.refresh=!1,t.target===c&&(d=!0,u=t.clientX,h=t.clientY)}}).bind(this),!1);const g=t=>{const{style:e}=c,n=parseInt(e.left,10),o=parseInt(e.top,10),a=parseInt(e.width,10),s=parseInt(e.height,10);if(p){const{clientX:e,clientY:r}=t,i={left:n,top:o,width:a,height:s};return p.includes("left")?(i.left=`${e}px`,i.width=n+a-e+"px"):p.includes("right")&&(i.width=e-n+"px"),p.includes("top")?(i.top=`${r}`,i.height=""+(o+s-r)):p.includes("bottom")&&(i.height=""+(r-o)),void EP(c,i)}if(!d||xe(t.clientX)||xe(t.clientY))return;const{ratio:l}=this,f=r.getZoom();let g=u-t.clientX,m=h-t.clientY;(n-g<0||n-g+a>=i[0])&&(g=0),(o-m<0||o-m+s>=i[1])&&(m=0),r.translate({dx:g*f/l,dy:m*f/l}).then((()=>{this.updateViewport()})),u=t.clientX,h=t.clientY};l||s||c.addEventListener("drag",g.bind(this),!1);const m=()=>{d=!1,p=!1,this.options.refresh=!0},v=l||s?"mouseup":"dragend";c.addEventListener(v,m.bind(this),!1);c.addEventListener("wheel",(t=>{}),!1),a.addEventListener("mouseleave",m.bind(this)),a.addEventListener("mouseup",m.bind(this)),(l||s)&&a.addEventListener("mousemove",g.bind(this),!1),this.viewport=c,a.appendChild(c)}updateViewport(){if(this.destroyed)return;this.viewport||this.initViewport();const{options:t,graph:e,dx:n,dy:r,ratio:i,viewport:o}=this,{size:a}=t,s=e.canvas.context.config.canvas,[l=(null==s?void 0:s.scrollWidth)||500,c=(null==s?void 0:s.scrollHeight)||500]=e.getSize(),u=e.getZoom(),h=e.canvas.getRoot().getRenderBounds(),d=e.getViewportByCanvas({x:h.min[0],y:h.min[1]}),p=e.getViewportByCanvas({x:h.max[0],y:h.max[1]});let f=l*i/u,g=c*i/u,m=0,v=0;d.x<0?(m=-d.x/l*f+n,p.x<l&&(f=a[0]-m)):f-=d.x/l*f-n,d.y<0?(v=-d.y/c*g+r,p.y<c&&(g=a[1]-v)):g-=d.y/c*g-r;const y=f+m;y>a[0]&&(f-=y-a[0]);const E=g+v;E>a[1]&&(g-=E-a[1]),EP(o,{left:`${m}px`,top:`${v}px`,width:`${f}px`,height:`${g}px`})}updateGraphShapes(){const{graph:t,options:e,canvas:n}=this,r=t.canvas.getRoot();if(r.destroyed)return;let i;n.removeChildren();const{hideEdge:o}=e;o?(i=new qs,n.appendChild(i),r.children.forEach((t=>{"edge-group"!==t.id&&i.appendChild(t.cloneNode(!0))}))):(i=r.cloneNode(!0),n.appendChild(i))}updateKeyShapes(){const{graph:t,options:e,canvas:n}=this,{hideEdge:r}=e,i=n.getRoot();r||Ce(t.getAllEdgesData(),(t=>{this.updateOneEdgeKeyShape(t,i)})),Ce(t.getAllNodesData(),(t=>{this.updateOneNodeKeyShape(t,i)}));const o=t.getAllCombosData();if(o&&o.length){let t=i.find((t=>"combo-group"===t.id));t||(t=new qs({id:"combo-group"}),i.appendChild(t)),setTimeout((()=>{this.destroyed||(Ce(o,(e=>{this.updateOneNodeKeyShape(e,t)})),null==t||t.sort(),null==t||t.toBack(),this.updateCanvas())}),250)}this.clearDestroyedShapes()}updateOneNodeKeyShape(t,e){var n;const{itemMap:r=new Map,graph:i}=this,o=i.canvas.getRoot().find((t=>"node-group"===t.id));if(!o)return;let{minimapItem:a,graphItem:s}=r.get(t.id)||{};a&&!a.destroyed||(s=null===(n=o.find((e=>e.getAttribute("data-item-id")===t.id)))||void 0===n?void 0:n.find((t=>"keyShape"===t.id)),a=s.cloneNode(),a.id=`minimap-keyShape-${t.id}`,e.appendChild(a),r.set(t.id,{graphItem:s,minimapItem:a}));const l=s.getRenderBounds();if(!l)return;const c=s.attributes,u=Object.assign(Object.assign({},c),{cx:l.center[0],cy:l.center[1]});a.toFront();const h=a.get("type");"rect"!==h&&"image"!==h&&"text"!==h||(u.x=l.min[0],u.y=l.min[1]),Object.keys(u).forEach((t=>{a.style[t]=u[t]})),i.getItemVisible(t.id)?a.show():a.hide();const d=t.data.depth;isNaN(d)||a.set("zIndex",d),this.itemMap=r}updateDelegateShapes(){const{graph:t,options:e,canvas:n}=this,{hideEdge:r}=e,i=n.getRoot();r||Ce(t.getAllEdgesData(),(t=>{this.updateOneEdgeKeyShape(t,i)})),Ce(t.getAllNodesData(),(t=>{this.updateOneNodeDelegateShape(t,i)}));const o=t.getAllCombosData();if(o&&o.length){const t=i.find((t=>"comboGroup"===t.get("name")))||i.addGroup({name:"comboGroup"});setTimeout((()=>{this.destroyed||(Ce(o,(e=>{this.updateOneNodeKeyShape(e,t)})),null==t||t.sort(),null==t||t.toBack(),this.updateCanvas())}),250)}this.clearDestroyedShapes()}clearDestroyedShapes(){const{itemMap:t=new Map}=this;t.forEach(((e,n)=>{const{minimapItem:r,graphItem:i}=e||{};i.destroyed&&r&&(r.remove(),t.delete(n))}))}updateOneEdgeKeyShape(t,e){var n;const{itemMap:r=new Map,graph:i}=this,o=i.canvas.getRoot().find((t=>"edge-group"===t.id));if(!o)return;let{minimapItem:a,graphItem:s}=r.get(t.id)||{};if(a&&!a.destroyed){const{path:t,x1:e,x2:n,y1:r,y2:i}=s.style;a.style.path=t,a.style.x1=e,a.style.x2=n,a.style.y1=r,a.style.y2=i}else s=null===(n=o.find((e=>e.getAttribute("data-item-id")===t.id)))||void 0===n?void 0:n.find((t=>"keyShape"===t.id)),a=s.cloneNode(),a.id=`minimap-keyShape-${t.id}`,e.appendChild(a);i.getItemVisible(t.id)?a.show():a.hide(),r.set(t.id,{graphItem:s,minimapItem:a}),this.itemMap=r}updateOneNodeDelegateShape(t,e){var n;const{itemMap:r=new Map,options:i,graph:o}=this,{delegateStyle:a}=i,s=o.canvas.getRoot().find((t=>"node-group"===t.id));if(!s)return;let{minimapItem:l,graphItem:c}=r.get(t.id)||{};c||(c=null===(n=s.find((e=>e.getAttribute("data-item-id")===t.id)))||void 0===n?void 0:n.find((t=>"keyShape"===t.id)));const u=c.getRenderBounds(),h=Object.assign({x:u.min[0],y:u.min[1],width:u.max[0]-u.min[0],height:u.max[1]-u.min[1]},a);!l||l.destroyed?(l=new nl({style:Object.assign(Object.assign(Object.assign({},c.attributes),h),a),id:`minimap-delegate-${t.id}`}),e.appendChild(l)):Object.keys(h).forEach((t=>l.style[t]=h[t])),l.toFront(),o.getItemVisible(t.id)?l.show():l.hide(),r.set(t.id,{graphItem:c,minimapItem:l}),this.itemMap=r}init(t){super.init(t);this.initContainer().then((()=>this.updateCanvas()))}initContainer(){var t,e;const{graph:n,options:r}=this,{size:i,className:o}=r;let a=r.container;const s=yP(`<div class='${o}' style='width: ${i[0]}px; height: ${i[1]}px; overflow: hidden;'></div>`);De(a)&&(a=document.getElementById(a)),a?a.appendChild(s):n.container.appendChild(s),this.container&&(this.container.remove(),null===(t=this.viewport)||void 0===t||t.remove(),this.viewport=void 0,null===(e=this.canvas)||void 0===e||e.destroy()),this.container=s;const l=createDom('<div class="g6-minimap-container" style="position: relative;"></div>');s.appendChild(l),l.addEventListener("dragenter",(t=>{t.preventDefault()})),l.addEventListener("dragover",(t=>{t.preventDefault()}));const c=n.canvas;return this.canvas=fR("canvas",l,i[0],i[1],c.devicePixelRatio),this.canvas.ready}updateCanvas(){if(this.destroyed)return;const{graph:t,canvas:e,options:n}=this,{refresh:r,size:i,padding:o,mode:a}=n;if(!r||t.destroyed||e.destroyed)return;switch(a){case"default":this.updateGraphShapes();break;case"keyShape":this.updateKeyShapes();break;case"delegate":this.updateDelegateShapes()}const s=e.getRoot();if(!s)return;const l=s.getRenderBounds(),c=t.canvas.getRoot().getRenderBounds(),u=c.max[0]-c.min[0],h=c.max[1]-c.min[1],d=Math.min((i[0]-2*o)/u,(i[1]-2*o)/h),p=e.viewport2Canvas({x:0,y:0});e.getCamera().setFocalPoint(p.x,p.y),e.getCamera().setPosition(p.x,p.y),e.getCamera().setZoom(d),e.getCamera().setPosition(l.center[0],l.center[1]),e.getCamera().setFocalPoint(l.center[0],l.center[1]);const{x:f,y:g}=e.canvas2Viewport({x:l.min[0],y:l.min[1]});this.ratio=d,this.dx=f,this.dy=g,this.updateViewport()}getCanvas(){return this.canvas}getViewport(){return this.viewport}getContainer(){return this.container}destroy(){var t;super.destroy(),null===(t=this.canvas)||void 0===t||t.destroy();const e=this.container;(null==e?void 0:e.parentNode)&&e.parentNode.removeChild(e)}},Toolbar:class extends zD{constructor(t){super(t),this.ToolbarDOM=yP("<div></div>"),this.ContainerDOM=yP("<div></div>")}getDefaultCfgs(){return{handleClick:void 0,getContent:t=>'\n <ul class=\'g6-component-toolbar\'>\n <li code=\'zoomIn\'>\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24">\n <path d="M658.432 428.736a33.216 33.216 0 0 1-33.152 33.152H525.824v99.456a33.216 33.216 0 0 1-66.304 0V461.888H360.064a33.152 33.152 0 0 1 0-66.304H459.52V296.128a33.152 33.152 0 0 1 66.304 0V395.52H625.28c18.24 0 33.152 14.848 33.152 33.152z m299.776 521.792a43.328 43.328 0 0 1-60.864-6.912l-189.248-220.992a362.368 362.368 0 0 1-215.36 70.848 364.8 364.8 0 1 1 364.8-364.736 363.072 363.072 0 0 1-86.912 235.968l192.384 224.64a43.392 43.392 0 0 1-4.8 61.184z m-465.536-223.36a298.816 298.816 0 0 0 298.432-298.432 298.816 298.816 0 0 0-298.432-298.432A298.816 298.816 0 0 0 194.24 428.8a298.816 298.816 0 0 0 298.432 298.432z"></path>\n </svg>\n </li>\n <li code=\'zoomOut\'>\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24">\n <path d="M639.936 416a32 32 0 0 1-32 32h-256a32 32 0 0 1 0-64h256a32 32 0 0 1 32 32z m289.28 503.552a41.792 41.792 0 0 1-58.752-6.656l-182.656-213.248A349.76 349.76 0 0 1 480 768 352 352 0 1 1 832 416a350.4 350.4 0 0 1-83.84 227.712l185.664 216.768a41.856 41.856 0 0 1-4.608 59.072zM479.936 704c158.784 0 288-129.216 288-288S638.72 128 479.936 128a288.32 288.32 0 0 0-288 288c0 158.784 129.216 288 288 288z" p-id="3853"></path>\n </svg>\n </li>\n <li code=\'realZoom\'>\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="24">\n <path d="M384 320v384H320V320h64z m256 0v384H576V320h64zM512 576v64H448V576h64z m0-192v64H448V384h64z m355.968 576H92.032A28.16 28.16 0 0 1 64 931.968V28.032C64 12.608 76.608 0 95.168 0h610.368L896 192v739.968a28.16 28.16 0 0 1-28.032 28.032zM704 64v128h128l-128-128z m128 192h-190.464V64H128v832h704V256z"></path>\n </svg>\n </li>\n <li code=\'autoZoom\'>\n <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="20" height="24">\n <path d="M684.288 305.28l0.128-0.64-0.128-0.64V99.712c0-19.84 15.552-35.904 34.496-35.712a35.072 35.072 0 0 1 34.56 35.776v171.008h170.944c19.648 0 35.84 15.488 35.712 34.432a35.072 35.072 0 0 1-35.84 34.496h-204.16l-0.64-0.128a32.768 32.768 0 0 1-20.864-7.552c-1.344-1.024-2.816-1.664-3.968-2.816-0.384-0.32-0.512-0.768-0.832-1.088a33.472 33.472 0 0 1-9.408-22.848zM305.28 64a35.072 35.072 0 0 0-34.56 35.776v171.008H99.776A35.072 35.072 0 0 0 64 305.216c0 18.944 15.872 34.496 35.84 34.496h204.16l0.64-0.128a32.896 32.896 0 0 0 20.864-7.552c1.344-1.024 2.816-1.664 3.904-2.816 0.384-0.32 0.512-0.768 0.768-1.088a33.024 33.024 0 0 0 9.536-22.848l-0.128-0.64 0.128-0.704V99.712A35.008 35.008 0 0 0 305.216 64z m618.944 620.288h-204.16l-0.64 0.128-0.512-0.128c-7.808 0-14.72 3.2-20.48 7.68-1.28 1.024-2.752 1.664-3.84 2.752-0.384 0.32-0.512 0.768-0.832 1.088a33.664 33.664 0 0 0-9.408 22.912l0.128 0.64-0.128 0.704v204.288c0 19.712 15.552 35.904 34.496 35.712a35.072 35.072 0 0 0 34.56-35.776V753.28h170.944c19.648 0 35.84-15.488 35.712-34.432a35.072 35.072 0 0 0-35.84-34.496z m-593.92 11.52c-0.256-0.32-0.384-0.768-0.768-1.088-1.088-1.088-2.56-1.728-3.84-2.688a33.088 33.088 0 0 0-20.48-7.68l-0.512 0.064-0.64-0.128H99.84a35.072 35.072 0 0 0-35.84 34.496 35.072 35.072 0 0 0 35.712 34.432H270.72v171.008c0 19.84 15.552 35.84 34.56 35.776a35.008 35.008 0 0 0 34.432-35.712V720l-0.128-0.64 0.128-0.704a33.344 33.344 0 0 0-9.472-22.848zM512 374.144a137.92 137.92 0 1 0 0.128 275.84A137.92 137.92 0 0 0 512 374.08z"></path>\n </svg>\n </li>\n </ul>\n ',zoomSensitivity:10,minZoom:1e-5,maxZoom:1e3}}getContainer(){const{container:t}=this.options;return this.ContainerDOM="string"==typeof t?document.getElementById(t):this.graph.container,this.ContainerDOM}init(t){super.init(t),this.getContainer(),this.insertStyle();const{getContent:e,className:n,handleClick:r,position:i}=this.options,o=e(t);this.ToolbarDOM="string"==typeof o?yP(o):o,this.ToolbarDOM.setAttribute("class",n||"g6-component-toolbar"),this.ContainerDOM.appendChild(this.ToolbarDOM),this.ToolbarDOM.addEventListener("click",(e=>{const n=(t=>{if(!t)return[];if(t.composedPath)return t.composedPath();const e=[];let n=t.target;for(;n;){if(e.push(n),"HTML"===n.tagName)return e.push(document,window),e;n=n.parentElement}return e})(e).filter((t=>"LI"===t.nodeName));if(0===n.length)return;const i=n[0].getAttribute("code");i&&(r?r(i,t):this.handleDefaultOperator(i))})),i&&EP(this.ToolbarDOM,{top:`${i.y}px`,left:`${i.x}px`})}insertStyle(){"undefined"!=typeof document&&YW("\n .g6-component-toolbar {\n position: absolute;\n list-style-type: none;\n padding: 6px;\n left: 0px;\n top: 0px;\n background-color: rgba(255, 255, 255, 0.9);\n border: 1px solid #e2e2e2;\n border-radius: 4px;\n font-size: 12px;\n color: #545454;\n margin: 0;\n }\n .g6-component-toolbar li {\n float: left;\n text-align: center;\n width: 35px;\n height: 24px;\n cursor: pointer;\n list-style-type:none;\n list-style: none;\n margin-left: 0px;\n }\n .g6-component-toolbar li .icon {\n opacity: 0.7;\n }\n .g6-component-toolbar li .icon:hover {\n opacity: 1;\n }\n ")}zoomOut(){const{zoomSensitivity:t}=this.options,e=100/(100+t);1!==e&&this.graph.zoom(e)}zoomIn(){const{zoomSensitivity:t}=this.options,e=(100+t)/100;1!==e&&this.graph.zoom(e)}realZoom(){this.graph.zoomTo(1)}autoZoom(){this.graph.fitView()}handleDefaultOperator(t){switch(t){case"zoomOut":this.zoomOut();break;case"zoomIn":this.zoomIn();break;case"realZoom":this.realZoom();break;case"autoZoom":this.autoZoom()}}destroy(){const{ToolbarDOM:t,ContainerDOM:e}=this,{handleClick:n}=this.options;t&&e.removeChild(t),n&&t.removeEventListener("click",n),super.destroy()}},Tooltip:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`tooltip-${gn()}`,offsetX:0,offsetY:0,getContent:t=>`\n <div>\n <h4 class='tooltip-type'>类型: ${t.itemType}</h4>\n <span class='tooltip-id'>ID: ${t.itemId}</span>\n </div>\n `,shouldBegin:t=>!0,itemTypes:["node","edge","combo"],trigger:"pointerenter",fixToNode:void 0,loadingContent:"<div class='g6-loading-dom'></div>"}}getEvents(){return"click"===this.options.trigger?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,afterremoveitem:this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerenter":this.onPointerEnter,"node:pointerleave":this.onPointerLeave,"node:pointermove":this.onPointerMove,"edge:pointerenter":this.onPointerEnter,"edge:pointerleave":this.onPointerLeave,"edge:pointermove":this.onPointerMove,"combo:pointerenter":this.onPointerEnter,"combo:pointerleave":this.onPointerLeave,"combo:pointermove":this.onPointerMove,afterremoveitem:this.onPointerLeave,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}init(t){super.init(t);const e=yP(`<div class='${this.options.className||"g6-component-tooltip"}'></div>`);EP(e,{position:"absolute",visibility:"hidden",display:"none"}),"click"!==this.options.trigger&&(e.addEventListener("pointerenter",(t=>{EP(e,{visibility:"visible",display:"unset"})})),e.addEventListener("pointerleave",(t=>{this.hideTooltip()})));let n=this.options.container;n||(n=this.graph.container),De(n)&&(n=document.getElementById(n)),n.appendChild(e),this.tooltip=e,this.container=n}onClick(t){if(t.itemId&&t.itemType&&-1===this.options.itemTypes.indexOf(t.itemType))return;const{itemId:e}=t;this.currentTarget===e?(this.currentTarget=null,this.hideTooltip(),this.graph.emit("tooltipchange",{itemId:e,action:"hide"})):(this.currentTarget=e,this.showTooltip(t))}onPointerEnter(t){if(t.itemId&&t.itemType&&-1===this.options.itemTypes.indexOf(t.itemType))return;const{itemId:e}=t;this.currentTarget=e,this.showTooltip(t),this.graph.emit("tooltipchange",{itemId:t.itemId,action:"show"})}onPointerMove(t){t.itemId&&t.itemType&&-1===this.options.itemTypes.indexOf(t.itemType)||this.currentTarget&&t.itemId!==this.currentTarget&&this.showTooltip(t)}onPointerLeave(){this.hideTooltip(),this.graph.emit("tooltipchange",{itemId:this.currentTarget,action:"hide"}),this.currentTarget=null}clearContainer(){this.container.innerHTML=""}showTooltip(t){return Oc(this,void 0,void 0,(function*(){if(clearTimeout(this.hidenTimer),!t.itemId)return;if(t.itemType&&-1===this.options.itemTypes.indexOf(t.itemType))return;const e=this.options.getContent(t),n=this.tooltip;EP(n,{display:"unset"});const r=this.updatePosition(t);if(EP(n,{visibility:"visible",left:`${r.x}px`,top:`${r.y}px`}),De(e))n.innerHTML=e;else if(e instanceof HTMLElement)this.clearContainer(),this.container.appendChild(e);else{if(this.asyncTooltip=null,De(this.options.loadingContent)?n.innerHTML=this.options.loadingContent:n.innerHTML=this.options.loadingContent.outerHTML,this.asyncTooltip&&t.itemId===this.currentAsyncTarget||(this.currentAsyncTarget=t.itemId,this.asyncTooltip=yield this.options.getContent(t)),t.itemId!=this.currentAsyncTarget)return;De(this.asyncTooltip)?n.innerHTML=this.asyncTooltip:(this.clearContainer(),this.container.appendChild(this.asyncTooltip))}}))}hideTooltip(){const t=this.tooltip;t&&(this.hidenTimer=setTimeout((()=>{EP(t,{visibility:"hidden",display:"none"})}),100),t.addEventListener("pointerenter",(t=>{clearTimeout(this.hidenTimer)})),t.addEventListener("pointerleave",(e=>{EP(t,{visibility:"hidden",display:"none"})})))}updatePosition(t){const e=this.options.shouldBegin,n=this.tooltip;if(!e(t))return void EP(n,{visibility:"hidden",display:"none"});const r=this.graph,i=r.getSize()[0],o=r.getSize()[1],a=this.options.offsetX||0,s=this.options.offsetY||0;let l={x:t.viewport.x,y:t.viewport.y};const c=this.options.fixToNode;if(t.itemType&&"node"===t.itemType&&c){const e=r.getRenderBBox(t.itemId),i=e.max[0]-e.min[0],o=e.max[1]-e.min[1];if(De(c))switch(c){case"right":l={x:e.min[0]+1*i,y:e.min[1]-.5*o};break;case"rightTop":case"topRight":l={x:e.min[0]+1*i,y:e.min[1]-1*o};break;case"rightBottom":case"bottomRight":l={x:e.min[0]+1*i,y:e.min[1]};break;case"bottom":l={x:e.min[0]+0*i,y:e.min[1]};break;case"top":{const t=n.getBoundingClientRect();l={x:e.min[0]+0*i,y:e.min[1]-t.height};break}case"left":{const t=n.getBoundingClientRect();l={x:e.min[0]-t.width,y:e.min[1]-.5*o};break}case"leftTop":case"topLeft":{const t=n.getBoundingClientRect();l={x:e.min[0]-t.width,y:e.min[1]-1*o};break}case"leftBottom":case"bottomLeft":{const t=n.getBoundingClientRect();l={x:e.min[0]-t.width,y:e.min[1]};break}default:l={x:e.min[0]+1*i,y:e.min[1]-.5*o},console.warn(`The '${this.options.fixToNode}' fixToNode position configuration is not supported, please use 'top'|'left'| 'right'| 'bottom'| 'topLeft'| 'leftTop'| 'topRight'| 'rightTop'| 'bottomLeft'| 'leftBottom'| 'bottomRight'| 'rightBottom', or use array to config, like: [0,5,1]`)}else Re(c)&&c.length>=2&&(l={x:e.min[0]+i*c[0],y:e.min[1]-o*(1-c[1])})}const{x:u,y:h}=this.graph.getViewportByCanvas(l),d=this.graph.container,p={x:u+d.offsetLeft+a,y:h+d.offsetTop+s},f=n.getBoundingClientRect();return u+f.width+a>i&&(p.x-=f.width+a),h+f.height+s>o&&(p.y-=f.height+s,p.y<0&&(p.y=0)),p}destroy(){this.container.removeChild(this.tooltip)}},Timebar:class extends zD{get padding(){return WR(this.options.padding)}get containerShape(){const{width:t,height:e}=this.options,[n,r,i,o]=this.padding;return{x:o,y:n,width:t+o+r,height:e+n+i+30}}get data(){const{graph:t}=this;return{nodes:t.getAllNodesData(),edges:t.getAllEdgesData()}}constructor(t){super(t),this.itemTypes=["node","edge"]}getDefaultCfgs(){return{axisStyle:{},className:"g6-component-timebar",controllerStyle:{},data:[],filterItemTypes:["node"],filterType:"modify",getTimeFromItem:t=>tz(t.data,QW,void 0),getTimeFromData:t=>tz(t,QW,void 0),getValueFromItem:t=>tz(t,JW,0),height:60,padding:10,position:"bottom",timebarType:"time",width:200}}getEvents(){return{afterrender:this.updateTimebar,afterchangedata:this.handleDataChange}}init(t){super.init(t)}reset(){this.timebar.reset()}backward(){this.timebar.backward()}play(){this.timebar.play()}pause(){this.timebar.pause()}forward(){this.timebar.forward()}destroy(){this.canvas.destroy(),super.destroy()}get container(){const{container:t}=this.options;if(t instanceof HTMLElement)return t;const e=document.getElementById(t);return e||this.graph.container}createWrapper(){const{options:t}=this,{className:e}=t,{width:n,height:r}=this.containerShape,i=yP(`<div class="${e}" style="width: ${n}px;height: ${r}"></div>`);return this.container.appendChild(i),i}createCanvas(){const{width:t,height:e}=this.containerShape;return fR("canvas",this.wrapper,t,e,void 0,{background:"#fff"})}updateTimebar(){this.wrapper||(this.wrapper=this.createWrapper()),this.canvas||(this.canvas=this.createCanvas()),this.canvas.ready.then((()=>{this.renderTimebar()}))}updatePosition(){const{graph:t}=this,{x:e,y:n}=this.options,{width:r}=this.containerShape,{position:i}=this.options,[o,a]=t.getSize();if(!e&&!n&&"bottom"===i)this.wrapper.style.top=a+"px",this.wrapper.style.left=(o-r)/2+"px"}renderTimebar(){const{x:t,y:e}=this.containerShape,n=this.options,{x:r,y:i,axisStyle:o={},chartStyle:a={},className:s,container:l,controllerStyle:c={},data:u,filter:h,filterItemTypes:d,filterType:p,getTimeFromData:f,getTimeFromItem:g,getValueFromData:m,onChange:v,padding:y,position:E,shouldIgnore:_,timebarType:b,type:S}=n,x=Nc(n,["x","y","axisStyle","chartStyle","className","container","controllerStyle","data","filter","filterItemTypes","filterType","getTimeFromData","getTimeFromItem","getValueFromData","onChange","padding","position","shouldIgnore","timebarType","type"]),T=u.map((t=>({time:(null==f?void 0:f(t))||(null==t?void 0:t.time),value:(null==m?void 0:m(t))||(null==t?void 0:t.value)}))),A=Object.assign(Object.assign(Object.assign(Object.assign({x:t,y:e,data:T,type:b,onChange:t=>{this.handleValuesChange(t),null==v||v(t)}},ZW(o,"axis")),ZW(c,"controller")),ZW(a,"chart")),x);this.timebar?this.timebar.update(A):this.timebar=this.canvas.appendChild(new VW({style:A})),this.updatePosition()}handleDataChange(){this.graphDataCache=an({},this.data),this.updateTimebar(),this.processValuesChange()}handleValuesChange(t){this.processValuesChange(t)}processValuesChange(t=this.timebar.values){const{filter:e}=this.options;e?e(t):this.filter(t)}filter(t){(!this.graphDataCache||0===this.graphDataCache.nodes.length&&0===this.graphDataCache.edges.length)&&(this.graphDataCache=an({},this.data));const{filterType:e,filterItemTypes:n,shouldIgnore:r,getTimeFromItem:i}=this.options,o={nodes:{enter:[],exit:[]},edges:{enter:[],exit:[]}},a=a=>{const s=`${a}s`;if(!(s in this.data))return;this.graphDataCache[s].forEach((l=>{const c="node"===a?this.graph.getNodeData(l.id):this.graph.getEdgeData(l.id),u=i(l,a),h=void 0!==c,d=c&&this.graph.getItemVisible(l.id),p=()=>{("modify"!==e||h)&&("visibility"!==e||d)||o[s].enter.push(l)};(()=>{if("edge"!==a)return!1;const{source:t,target:e}=l,n=[...o.nodes.enter,...this.data.nodes],r=n.find((e=>e.id===t)),i=n.find((t=>t.id===e));return!r||!i})()||(n.includes(a)?void 0===u||(null==r?void 0:r(l,a,t))||(e=>Array.isArray(t)?e>=t[0]&&e<=t[1]:e===t)(u)?p():this.data[s].find((({id:t})=>t===l.id))&&("modify"===e&&h||"visibility"===e&&d)&&o[s].exit.push(l):p())}))};this.itemTypes.forEach((t=>a(t))),this.mutateGraph(o)}mutateGraph(t){const{filterType:e}=this.options,n=n=>{const{enter:r,exit:i}=t[`${n}s`];"modify"===e?(this.graph.addData(n,r),this.graph.removeData(n,i.map((t=>t.id)))):(this.graph.showItem(r.map((t=>t.id))),this.graph.hideItem(i.map((t=>t.id))))};(t=>{const e=console.error;console.error=()=>{},null==t||t(),console.error=e})((()=>{this.itemTypes.forEach((t=>n(t)))}))}},Snapline:class extends zD{setTolerance(t){this.tolerance=t}getTolerance(){return this.tolerance}getDrawLineIdByDrawLine(t){if(t)return`${t.line[0].x}-${t.line[0].y}-${t.line[1].x}-${t.line[1].y}`}getDrawLineIdByPoints([t,e]){return`${t.x}-${t.y}-${e.x}-${e.y}`}addAlignLinesForChoose(){function t(t,e,n){return t>=e-n&&t<=e+n}this.vContrastPoints.forEach((e=>{t(this.draggingBBox.min[0],e.x,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:e.x,y:this.draggingBBox.center[1]}],lp:"left"},offset:{x:e.x-this.draggingBBox.min[0],y:0}}),t(this.draggingBBox.center[0],e.x,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:e.x,y:this.draggingBBox.center[1]}],lp:"vcenter"},offset:{x:e.x-this.draggingBBox.center[0],y:0}}),t(this.draggingBBox.max[0],e.x,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:e.x,y:this.draggingBBox.center[1]}],lp:"right"},offset:{x:e.x-this.draggingBBox.max[0],y:0}})})),this.hContrastPoints.forEach((e=>{t(this.draggingBBox.min[1],e.y,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:this.draggingBBox.min[0],y:e.y}],lp:"top"},offset:{x:0,y:e.y-this.draggingBBox.min[1]}}),t(this.draggingBBox.center[1],e.y,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:this.draggingBBox.center[0],y:e.y}],lp:"hcenter"},offset:{x:0,y:e.y-this.draggingBBox.center[1]}}),t(this.draggingBBox.max[1],e.y,this.tolerance)&&this.alignLinesForChoose.v.push({dl:{line:[e,{x:this.draggingBBox.max[0],y:e.y}],lp:"bottom"},offset:{x:0,y:e.y-this.draggingBBox.max[1]}})}))}initAlignLinesForChoose(){this.alignLinesForChoose.v=[],this.alignLinesForChoose.h=[];let t=[];this.graph.getAllCombosData().forEach((e=>{t.push(e.id)})),this.graph.getAllNodesData().forEach((e=>{t.push(e.id)})),t=t.filter((t=>t!==this.dragItemId)),t.forEach((t=>{const e=this.graph.getRenderBBox(t,!0);Math.abs(this.draggingBBox.min[0]-e.min[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.min[0],y:e.center[1]},{x:e.min[0],y:this.draggingBBox.center[1]}],lp:"left"},offset:{x:this.draggingBBox.min[0]-e.min[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.min[0]-e.center[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:e.center[0],y:this.draggingBBox.center[1]}],lp:"left"},offset:{x:this.draggingBBox.min[0]-e.center[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.min[0]-e.max[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.max[0],y:e.center[1]},{x:e.max[0],y:this.draggingBBox.center[1]}],lp:"left"},offset:{x:this.draggingBBox.min[0]-e.max[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.center[0]-e.min[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.min[0],y:e.center[1]},{x:e.min[0],y:this.draggingBBox.center[1]}],lp:"vcenter"},offset:{x:this.draggingBBox.center[0]-e.min[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.center[0]-e.center[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:e.center[0],y:this.draggingBBox.center[1]}],lp:"vcenter"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.center[0]-e.max[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.max[0],y:e.center[1]},{x:e.max[0],y:this.draggingBBox.center[1]}],lp:"vcenter"},offset:{x:this.draggingBBox.center[0]-e.max[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.max[0]-e.min[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.min[0],y:e.center[1]},{x:e.min[0],y:this.draggingBBox.center[1]}],lp:"right"},offset:{x:this.draggingBBox.max[0]-e.min[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.max[0]-e.center[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:e.center[0],y:this.draggingBBox.center[1]}],lp:"right"},offset:{x:this.draggingBBox.max[0]-e.center[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.max[0]-e.max[0])<=this.tolerance&&this.alignLinesForChoose.v.push({dl:{line:[{x:e.max[0],y:e.center[1]},{x:e.max[0],y:this.draggingBBox.center[1]}],lp:"right"},offset:{x:this.draggingBBox.max[0]-e.max[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.min[1]-e.max[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.max[1]},{x:this.draggingBBox.center[0],y:e.max[1]}],lp:"top"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.min[1]-e.max[1]}}),Math.abs(this.draggingBBox.min[1]-e.center[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:this.draggingBBox.center[0],y:e.center[1]}],lp:"top"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.min[1]-e.center[1]}}),Math.abs(this.draggingBBox.min[1]-e.min[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.max[1]},{x:this.draggingBBox.center[0],y:e.max[1]}],lp:"top"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.min[1]-e.min[1]}}),Math.abs(this.draggingBBox.center[1]-e.max[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.max[1]},{x:this.draggingBBox.center[0],y:e.max[1]}],lp:"hcenter"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.center[1]-e.max[1]}}),Math.abs(this.draggingBBox.center[1]-e.center[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:this.draggingBBox.center[0],y:e.center[1]}],lp:"hcenter"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.center[1]-e.center[1]}}),Math.abs(this.draggingBBox.center[1]-e.min[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.min[1]},{x:this.draggingBBox.center[0],y:e.min[1]}],lp:"hcenter"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.center[1]-e.min[1]}}),Math.abs(this.draggingBBox.max[1]-e.max[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.max[1]},{x:this.draggingBBox.center[0],y:e.max[1]}],lp:"bottom"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.max[1]-e.max[1]}}),Math.abs(this.draggingBBox.max[1]-e.center[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.center[1]},{x:this.draggingBBox.center[0],y:e.center[1]}],lp:"bottom"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.max[1]-e.center[1]}}),Math.abs(this.draggingBBox.max[1]-e.min[1])<=this.tolerance&&this.alignLinesForChoose.h.push({dl:{line:[{x:e.center[0],y:e.min[1]},{x:this.draggingBBox.center[0],y:e.min[1]}],lp:"bottom"},offset:{x:this.draggingBBox.center[0]-e.center[0],y:this.draggingBBox.max[1]-e.min[1]}})}))}chooseAlignLine(){if(this.alignLinesForChoose.v.length+this.alignLinesForChoose.h.length===0)return{v:void 0,h:void 0};let t=[],e=[];const n=Math.min(...this.alignLinesForChoose.v.map((t=>t.offset.x))),r=Math.min(...this.alignLinesForChoose.h.map((t=>t.offset.y)));t=this.alignLinesForChoose.v.filter((t=>t.offset.x===n)),e=this.alignLinesForChoose.h.filter((t=>t.offset.y===r));{const n=t.some((t=>"vcenter"===t.dl.lp)),r=t.some((t=>"left"===t.dl.lp));t=t.filter((t=>"vcenter"===t.dl.lp||("left"===t.dl.lp?!(n||!r):"right"===t.dl.lp&&(!n&&!r))));const i=e.some((t=>"hcenter"===t.dl.lp)),o=e.some((t=>"top"===t.dl.lp));e=e.filter((t=>"hcenter"===t.dl.lp||("top"===t.dl.lp?!(i||!o):"bottom"===t.dl.lp&&(!i&&!o))))}const i=Array.from(t.reduce(((t,e)=>{var n;return(!t.has(e.dl.lp)||Math.abs(e.offset.x)<Math.abs(null===(n=t.get(e.dl.lp))||void 0===n?void 0:n.offset.x))&&t.set(e.dl.lp,e),t}),new Map).values()),o=Array.from(e.reduce(((t,e)=>{var n;return(!t.has(e.dl.lp)||Math.abs(e.offset.y)<Math.abs(null===(n=t.get(e.dl.lp))||void 0===n?void 0:n.offset.y))&&t.set(e.dl.lp,e),t}),new Map).values()),a=i.length?i.reduce(((t,e)=>e.offset.x>t.offset.x?e:t)):void 0,s=o.length?o.reduce(((t,e)=>e.offset.y>t.offset.y?e:t)):void 0;return{v:a?a.dl:void 0,h:s?s.dl:void 0}}constructor(t){super(t),this.historyPoints=[void 0,void 0],this.initialOffset=[void 0,void 0],this.updateCache=new Map,this.getCurOffsetCompareToInitialOffset=t=>{if(void 0===this.initialOffset[0]||void 0===this.initialOffset[1])return[void 0,void 0];const e=[t.canvas.x-this.draggingBBox.center[0],t.canvas.y-this.draggingBBox.center[1]];return[e[0]-this.initialOffset[0],e[1]-this.initialOffset[1]]},this.dragging=!1,this.draggingBBox=void 0,this.getPointerOffsetWithItem=t=>({x:Math.abs(t.x-this.draggingBBox.center[0]),y:Math.abs(t.x-this.draggingBBox.center[1])}),this.tolerance=4,this.toleranceFactor=2,this.vContrastPoints=[],this.hContrastPoints=[],this.alignLinesForChoose={v:[],h:[]},this.isAdsorbed=[!1,!1],this.dragEvent=void 0,this.dragItemId=void 0,this.dragItemType=void 0,this.historyAbsorbArea=[void 0,void 0],this.canAdsorbCount=0,this.canAdsorbCountDown=()=>{if(this.canAdsorbCount>0){const t=setInterval((()=>{this.canAdsorbCount--,this.canAdsorbCount<=0&&clearTimeout(t)}),100)}},this.onDrag=pn((t=>{var e,n,r,i,o,a,s,l;let c,u,h,d;this.dragEvent=t,this.initAlignLinesForChoose(),this.historyPoints[0]=this.historyPoints[1],this.historyPoints[1]={x:t.canvas.x,y:t.canvas.y};const p=(e,n)=>{Math.abs(this.getCurOffsetCompareToInitialOffset(t)[0])<=this.tolerance*this.toleranceFactor?("left"===e?this.doUpdatePosition({x:n[0].x+this.draggingBBox.halfExtents[0]}):"vcenter"===e?this.doUpdatePosition({x:n[0].x}):"right"===e&&this.doUpdatePosition({fx:n[0].x-this.draggingBBox.halfExtents[0]}),this.updateAlignLineWhenAbsorb([!0,!1])):(this.doUpdatePosition({fx:void 0}),this.removeAlignLine([!0,void 0]),this.canAdsorbCount=10,this.canAdsorbCountDown())},f=(e,n)=>{Math.abs(this.getCurOffsetCompareToInitialOffset(t)[1])<=this.tolerance*this.toleranceFactor?("top"===e?this.doUpdatePosition({fy:n[0].y+this.draggingBBox.halfExtents[1]}):"hcenter"===e?this.doUpdatePosition({fy:n[0].y}):"bottom"===e&&this.doUpdatePosition({fy:n[0].y-this.draggingBBox.halfExtents[1]}),this.updateAlignLineWhenAbsorb([!1,!0])):(this.doUpdatePosition({fy:void 0}),this.removeAlignLine([void 0,!0]),this.canAdsorbCount=10,this.canAdsorbCountDown())},g=()=>{const t=this.canDrawLine();t&&(this.drawAlignLines({vdl:t.vdl,hdl:void 0}),this.absorb({vdl:t.vdl,hdl:void 0}))},m=()=>{const t=this.canDrawLine();t&&(this.drawAlignLines({vdl:void 0,hdl:t.hdl}),this.absorb({vdl:void 0,hdl:t.hdl}))};if(this.isAdsorbed[0]&&this.isAdsorbed[1])c=null===(e=this.drawedLines[0].dl)||void 0===e?void 0:e.lp,u=null===(n=this.drawedLines[0].dl)||void 0===n?void 0:n.line,h=null===(r=this.drawedLines[1].dl)||void 0===r?void 0:r.lp,d=null===(i=this.drawedLines[1].dl)||void 0===i?void 0:i.line,p(c,u),f(h,d);else if(this.isAdsorbed[0]&&!this.isAdsorbed[1])c=null===(o=this.drawedLines[0].dl)||void 0===o?void 0:o.lp,u=null===(a=this.drawedLines[0].dl)||void 0===a?void 0:a.line,p(c,u),m();else if(!this.isAdsorbed[0]&&this.isAdsorbed[1])h=null===(s=this.drawedLines[1].dl)||void 0===s?void 0:s.lp,d=null===(l=this.drawedLines[1].dl)||void 0===l?void 0:l.line,f(c,u),g();else if(!this.isAdsorbed[0]&&!this.isAdsorbed[1]){const t=this.canDrawLine();t&&(this.drawAlignLines(t),this.absorb(t))}}).bind(this),16,{leading:!1,trailing:!0}),this.drawedLines=[void 0,void 0],this.throttleUpdate=pn((()=>{this.graph.updateNodePosition(Array.from(this.updateCache.values()),!1,!0),this.updateCache.clear()}),16,{leading:!0,trailing:!0}),this.init(t.graph)}getEvents(){return{pointerdown:this.onPointerDown,pointermove:this.onPointerMove,pointerup:this.onPointerUp}}onPointerDown(t){this.historyPoints[1]={x:t.canvas.x,y:t.canvas.y},this.dragItemId=t.itemId,this.dragItemType=t.itemType}onPointerMove(t){this.historyPoints[1]&&"node"===this.dragItemType&&(this.dragging?this.onDrag(t):(this.onDragStart(t),this.dragging=!0))}onPointerUp(t){this.dragging?this.onDragEnd():(this.historyPoints=[void 0,void 0],this.dragging=!1,this.dragItemId=void 0,this.dragItemType=void 0)}getGraph(t){return t.currentTarget}onDragStart(t){this.draggingBBox=this.graph.getRenderBBox(t.itemId,!0),this.initialOffset=[t.canvas.x-this.draggingBBox.center[0],t.canvas.y-this.draggingBBox.center[1]]}onDragEnd(){this.dragEvent=void 0,this.historyPoints=[void 0,void 0],this.dragging=!1,this.dragItemId=void 0,this.dragItemType=void 0}drawAlignLines({vdl:t,hdl:e}){const n=t?this.getDrawLineIdByDrawLine(t):void 0,r=e?this.getDrawLineIdByDrawLine(e):void 0;let i,o;t&&(i=this.graph.drawTransient("line",n,{style:{stroke:"red",lineWidth:1,x1:t.line[0].x,y1:t.line[0].y,x2:t.line[1].x,y2:t.line[1].y}}),this.drawedLines[0]={do:i,dl:t}),e&&(o=this.graph.drawTransient("line",r,{style:{stroke:"red",lineWidth:1,x1:e.line[0].x,y1:e.line[0].y,x2:e.line[1].x,y2:e.line[1].y}}),this.drawedLines[1]={do:o,dl:e})}removeAlignLine([t,e]){if(t){const t=this.getDrawLineIdByDrawLine(this.drawedLines[0].dl);this.graph.drawTransient("line",t,{action:"remove"}),this.drawedLines[0]=void 0,this.isAdsorbed[0]=!1}if(e){const t=this.getDrawLineIdByDrawLine(this.drawedLines[1].dl);this.graph.drawTransient("line",t,{action:"remove"}),this.drawedLines[1]=void 0,this.isAdsorbed[1]=!1}}removeAlignLineByID(t){const[e,n]=this.drawedLines;this.drawedLines.forEach(((r,i)=>{if(r&&r.do){this.getDrawLineIdByPoints(r.dl.line)===t&&(0===i&&e?(e.dl=void 0,e.do=void 0):1===i&&n&&(n.dl=void 0,n.do=void 0),this.isAdsorbed[i]=!1)}})),this.drawedLines[0]=e,this.drawedLines[1]=n,this.graph.drawTransient("line",t,{action:"remove"})}getDraggingBBoxPointByLinePosition(t){if(this.draggingBBox)return"left"===t?{x:this.draggingBBox.min[0],y:this.draggingBBox.center[1]}:"vcenter"===t||"hcenter"===t?{x:this.draggingBBox.center[0],y:this.draggingBBox.center[1]}:"right"===t?{x:this.draggingBBox.max[0],y:this.draggingBBox.center[1]}:"top"===t?{x:this.draggingBBox.center[0],y:this.draggingBBox.min[1]}:"bottom"===t?{x:this.draggingBBox.center[0],y:this.draggingBBox.max[1]}:void 0}updateAlignLineWhenAbsorb([t,e]){if(t&&this.drawedLines[0]&&this.drawedLines[0].do){const t=this.getDraggingBBoxPointByLinePosition(this.drawedLines[0].dl.lp),e={line:[this.drawedLines[0].dl.line[0],{x:this.drawedLines[0].dl.line[0].x,y:t.y}],lp:this.drawedLines[0].dl.lp};this.removeAlignLineByID(this.drawedLines[0].do.id),this.drawAlignLines({vdl:e,hdl:void 0}),this.isAdsorbed[0]=!0}if(e&&this.drawedLines[1]&&this.drawedLines[1].do){const t=this.getDraggingBBoxPointByLinePosition(this.drawedLines[1].dl.lp),e={line:[this.drawedLines[1].dl.line[0],{x:t.x,y:this.drawedLines[1].dl.line[0].y}],lp:this.drawedLines[1].dl.lp};this.removeAlignLineByID(this.drawedLines[1].do.id),this.drawAlignLines({vdl:void 0,hdl:e}),this.isAdsorbed[1]=!0}}canDrawLine(){const{v:t,h:e}=this.chooseAlignLine();return!(!t&&!e)&&{vdl:t,hdl:e}}canCancelAbsorb(){let t=[void 0,void 0];const e=this.drawedLines[0].dl,n=this.drawedLines[1].dl,r=this.getPointerOffsetWithItem({x:this.dragEvent.canvas.x,y:this.dragEvent.canvas.y});return e&&Math.abs(r.x)>this.tolerance*this.toleranceFactor&&(t[0]=!0),n&&Math.abs(r.y)>this.tolerance*this.toleranceFactor&&(t[1]=!0),t}absorb(t){t.vdl&&(this.isAdsorbed[0]=!0,this.historyAbsorbArea[0]=[t.vdl.line[0].x-this.tolerance*this.toleranceFactor,t.vdl.line[0].x+this.tolerance*this.toleranceFactor],this.updateDraggingItemPosition(this.drawedLines[0].dl)),t.hdl&&(this.isAdsorbed[1]=!0,this.historyAbsorbArea[1]=[t.hdl.line[0].y-this.tolerance*this.toleranceFactor,t.hdl.line[0].y+this.tolerance*this.toleranceFactor],this.updateDraggingItemPosition(this.drawedLines[1].dl))}updateDraggingItemPosition(t,e){if(this.historyPoints[0]||this.historyPoints[1]){if(t){if("left"===t.lp){const e=t.line[0].x+this.draggingBBox.halfExtents[0];this.doUpdatePosition({fx:e})}"vcenter"===t.lp&&this.doUpdatePosition({fx:t.line[0].x}),"right"===t.lp&&this.doUpdatePosition({fx:t.line[0].x-this.draggingBBox.halfExtents[0]}),"top"===t.lp&&this.doUpdatePosition({fy:t.line[0].y+this.draggingBBox.halfExtents[1]}),"hcenter"===t.lp&&this.doUpdatePosition({fy:t.line[0].y}),"bottom"===t.lp&&this.doUpdatePosition({fy:t.line[0].y-this.draggingBBox.halfExtents[1]})}if(e){if(e.x){const t=this.draggingBBox.center[0]+e.x;this.doUpdatePosition({x:t,fx:void 0})}if(e.y){const t=this.draggingBBox.center[1]+e.y;this.doUpdatePosition({y:t,fy:void 0})}}}}doUpdatePosition(t){const e=this.updateCache.get(this.dragItemId);this.updateCache.set(this.dragItemId,{id:this.dragItemId,data:Object.assign(Object.assign({},null==e?void 0:e.data),t)}),this.throttleUpdate()}},EdgeFilterLens:class extends zD{constructor(t){super(t),this.cachedTransientNodes=new Set,this.cachedTransientEdges=new Set}getDefaultCfgs(){return{showType:"both",trigger:"mousemove",r:60,delegateStyle:tn(nz),showLabel:"edge",scaleRBy:"wheel"}}getEvents(){let t={pointerdown:this.onPointerDown,pointerup:this.onPointerUp,wheel:this.onWheel};switch(this.options.trigger){case"click":t=Object.assign(Object.assign({},t),{click:this.filter});break;case"drag":t=Object.assign(Object.assign({},t),{pointermove:this.onPointerMove});break;default:t=Object.assign(Object.assign({},t),{pointermove:this.filter})}return t}init(t){super.init(t);const e=this.options.showLabel,n="node"===e||"both"===e,r="edge"===e||"both"===e;this.showNodeLabel=n,this.showEdgeLabel=r;this.options.shouldShow||(this.options.shouldShow=()=>!0)}onPointerUp(t){this.dragging=!1}onPointerMove(t){this.dragging&&this.moveDelegate(t)}onPointerDown(t){const{delegate:e}=this;let n;!e||e.destroyed?(n={x:t.canvas.x,y:t.canvas.y},this.filter(t)):n={x:e.style.cx,y:e.style.cy},this.delegateCenterDiff={x:t.canvas.x-n.x,y:t.canvas.y-n.y},this.dragging=!0}isInLensDelegate(t,e){const{cx:n,cy:r,r:i}=t.style;return e.x>=n-i&&e.x<=n+i&&e.y>=r-i&&e.y<=r+i}moveDelegate(t){if(this.isInLensDelegate(this.delegate,{x:t.canvas.x,y:t.canvas.y})){const e={x:t.canvas.x-this.delegateCenterDiff.x,y:t.canvas.y-this.delegateCenterDiff.y};this.filter(t,e)}}onWheel(t){const{delegate:e,options:n}=this,{scaleRBy:r}=n;e&&!e.destroyed&&"wheel"===r&&this.isInLensDelegate(e,{x:t.canvas.x,y:t.canvas.y})&&"wheel"===r&&this.scaleRByWheel(t)}scaleRByWheel(t){if(!t||!t.originalEvent)return;t.preventDefault&&t.preventDefault();const{graph:e,options:n}=this,r=e.canvas.context.config.canvas,i=(null==r?void 0:r.height)||500,o=n.maxR?Math.min(n.maxR,i):i,a=n.minR?Math.max(n.minR,i*ez):i*ez,s=1+-1*t.originalEvent.deltaY*ez;let l=n.r*s;l=Math.min(l,o),l=Math.max(l,a),n.r=l,this.delegate.style.r=l,this.filter(t)}filter(t,e){const{graph:n,options:r,showNodeLabel:i,showEdgeLabel:o,cachedTransientNodes:a,cachedTransientEdges:s}=this,l=r.r,c=r.showType,u=r.shouldShow,h=e||{x:t.canvas.x,y:t.canvas.y};this.updateDelegate(h,l);const d=n.getAllNodesData(),p=new Map;d.forEach((t=>{const{data:e,id:n}=t;Sk({x:e.x,y:e.y},h)<l&&p.set(n,t)}));const f=n.getAllEdgesData(),g=[];f.forEach((t=>{const e=t.source,n=t.target;u(t)&&("only-source"===c||"one"===c?p.get(e)&&!p.get(n)&&g.push(t):"only-target"===c||"one"===c?p.get(n)&&!p.get(e)&&g.push(t):"both"===c&&p.get(e)&&p.get(n)&&g.push(t))}));const m=new Set,v=new Set;p.forEach((t=>{m.add(t.id),a.has(t.id)?a.delete(t.id):n.drawTransient("node",t.id,{shapeIds:i?["labelShape","labelBackgroundShape","keyShape"]:["keyShape"]})})),a.forEach((t=>{n.drawTransient("node",t,{action:"remove"})})),o&&(g.forEach((t=>{v.add(t.id),s.has(t.id)?s.delete(t.id):n.drawTransient("edge",t.id,{shapeIds:["labelShape","labelBackgroundShape","keyShape"],drawSource:!1,drawTarget:!1})})),s.forEach((t=>{n.drawTransient("edge",t,{action:"remove"})}))),this.cachedTransientNodes=m,this.cachedTransientEdges=v}updateParams(t){const e=this,{r:n,trigger:r,minR:i,maxR:o,scaleRBy:a,showLabel:s,shouldShow:l}=t;isNaN(t.r)||(e.options.r=n),isNaN(o)||(e.options.maxR=o),isNaN(i)||(e.options.minR=i),"mousemove"!==r&&"click"!==r&&"drag"!==r||(e.options.trigger=r),"wheel"!==a&&"unset"!==a||(e.options.scaleRBy=a,e.delegate.remove(),e.delegate.destroy()),"node"!==s&&"both"!==s||(e.showNodeLabel=!0),"edge"!==s&&"both"!==s||(e.showEdgeLabel=!0),l&&(e.options.shouldShow=l)}updateDelegate(t,e){const{graph:n,options:r,delegate:i}=this;let o=i;if(!o||o.destroyed){const i=r.delegateStyle||nz;o=n.drawTransient("circle","lens-shape",{style:Object.assign({r:e,cx:t.x,cy:t.y,zIndex:-1},i)}),o.toBack()}else o=n.drawTransient("circle","lens-shape",{style:{r:e,cx:t.x,cy:t.y}});this.delegate=o}clear(){const{graph:t,delegate:e,cachedTransientNodes:n,cachedTransientEdges:r}=this;e&&!e.destroyed&&t.drawTransient("circle","lens-shape",{action:"remove"}),n.forEach((e=>{t.drawTransient("node",e,{action:"remove"})})),r.forEach((e=>{t.drawTransient("edge",e,{action:"remove"})})),n.clear(),r.clear()}destroy(){this.clear()}}});const iz=(t,e,n)=>{const r=t.getRenderBBox(e);if(!r)return!1;const i=[[r.min[0],r.min[1]],[r.max[0],r.min[1]],[r.max[0],r.max[1]],[r.min[0],r.max[1]]];return jR(n,i)};const oz=(t,e,n,r,i,o)=>{const a=t.getRenderBBox(e);return!!a&&(a.center[0]>=n&&a.center[0]<=r&&a.center[1]>=i&&a.center[1]<=o)},az=t=>{if(t.length<2)throw new Error(`point length must largn than 2, now it's ${t.length}`);const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(r),t.unshift(i),t.push(e),t.push(n);const o=[];for(let e=1;e<t.length-2;e+=1){const n=t[e-1].x,r=t[e-1].y,i=t[e].x,a=t[e].y,s=t[e+1].x,l=t[e+1].y,c=i+(s-n)/6,u=a+(l-r)/6,h=s-((e!==t.length-2?t[e+2].x:s)-i)/6,d=l-((e!==t.length-2?t[e+2].y:l)-a)/6;o.push(["C",c,u,h,d,s,l])}return o.unshift(["M",r.x,r.y]),o};function sz(t,e){if(!t||t.length<1)return"";if(1===t.length)return(t=>{const n=[t[0][0],t[0][1]-e],r=[t[0][0],t[0][1]+e];return[["M",n],["A",e,e,0,0,0,r],["A",e,e,0,0,0,n]]})(t);if(2===t.length)return(t=>{const n=Ot([0,0],lz(t[0],t[1]),e),r=Ot([0,0],n,-1),i=Nt([0,0],t[0],n),o=Nt([0,0],t[1],n),a=Nt([0,0],t[1],r),s=Nt([0,0],t[0],r);return`M ${i} L ${o} A ${[e,e,"0,0,0",a].join(",")} L ${s} A ${[e,e,"0,0,0",i].join(",")}`})(t);let n=new Array(t.length);for(let r=0;r<n.length;++r){const i=0===r?t[t.length-1]:t[r-1],o=t[r],a=Ot([0,0],lz(i,o),e);n[r]=[Nt([0,0],i,a),Nt([0,0],o,a)]}const r=`A ${[e,e,"0,0,0,"].join(",")}`;return n=n.map(((t,e)=>{let i="";return 0===e&&(i=`M ${n[n.length-1][1]} `),i+=`${r+t[0]} L ${t[1]}`,i})),n.join(" ")}const lz=(t,e)=>{const n=[t[1]-e[1],e[0]-t[0]],r=Math.sqrt(n[0]*n[0]+n[1]*n[1]);if(0===r)throw new Error("p0 should not be equal to p1");return[n[0]/r,n[1]/r]},cz=(t,e)=>[e[0]-t[0],e[1]-t[1]],uz=(t,e)=>Ot([0,0],It([0,0],t),e),hz=(t,e)=>{const n=e.x1,r=e.y1,i=e.x2-n,o=e.y2-r;let a,s=t.x-n,l=t.y-r,c=s*i+l*o;c<=0?a=0:(s=i-s,l=o-l,c=s*i+l*o,a=c<=0?0:c*c/(i*i+o*o));let u=s*s+l*l-a;return u<0&&(u=0),u};class dz{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}getBBox(){const t=Math.min(this.x1,this.x2),e=Math.min(this.y1,this.y2),n=Math.max(this.x1,this.x2),r=Math.max(this.y1,this.y2);return{min:[t,e],max:[n,r],center:[(t+n)/2,(e+r)/2],halfExtents:[(n-t)/2,(r-e)/2]}}}const pz=(t,e)=>Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2),fz=(t,e,n)=>{const r=["top","left","bottom","right"],i=t.getRenderBBox(e);if(!i)return 1/0;let o=Number.POSITIVE_INFINITY,a=0;for(let t=0;t<4;t++){const[e,s,l,c]=gz(i,r[t]);let u=mz(n,new dz(e,s,l,c));u=Math.abs(u-.5),u>=0&&u<=1&&(a+=1,o=u<o?u:o)}return 0===a?-1:o},gz=(t,e)=>({top:[t.min[0],t.min[1],t.max[0],t.min[1]],left:[t.min[0],t.min[1],t.min[0],t.max[1]],bottom:[t.min[0],t.max[1],t.max[0],t.max[1]],right:[t.max[0],t.min[1],t.max[0],t.max[1]]}[e]),mz=(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(t>=0&&t<=1&&e>=0&&e<=1)return t}return Number.POSITIVE_INFINITY},vz=(t,e,n=.001)=>Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)<Math.pow(n,2),yz=(t,e,n)=>{const r=["top","left","bottom","right"],i=t.getRenderBBox(e);if(!i)return;let o=0;const a=[];for(let t=0;t<4;t++){const[e,s,l,c]=gz(i,r[t]);a[t]=$R({x:n.x1,y:n.y1},{x:n.x2,y:n.y2},{x:e,y:s},{x:l,y:c}),a[t]&&(o+=1)}return[a,o]},Ez=(t,e)=>{const n=t.x<e.x,r=t.x>e.x+e.width,i=t.y>e.y+e.height,o=t.y<e.y;if(!(n||r||i||o))return 0;if(i&&!n&&!r)return Math.pow(e.y+e.height-t.y,2);if(o&&!n&&!r)return Math.pow(t.y-e.y,2);if(n&&!i&&!o)return Math.pow(e.x-t.x,2);if(r&&!i&&!o)return Math.pow(e.x+e.width-t.x,2);const a=Math.min(Math.abs(e.x-t.x),Math.abs(e.x+e.width-t.x)),s=Math.min(Math.abs(e.y-t.y),Math.abs(e.y+e.height-t.y));return a*a+s*s},_z=(t,e,n)=>(t.y-n.y)*(e.x-n.x)-(t.x-n.x)*(e.y-n.y),bz=t=>{const e=t.map((t=>({x:t.data.x,y:t.data.y})));e.sort(((t,e)=>t.x===e.x?t.y-e.y:t.x-e.x));const n={};for(let t=e.length-1;t>=0;t--){const{x:r,y:i}=e[t];n[`${r}-${i}`]&&e.splice(t,1),n[`${r}-${i}`]=!0}if(1===e.length)return e;const r=[];for(let t=0;t<e.length;t++){for(;r.length>=2&&_z(r[r.length-2],r[r.length-1],e[t])<=0;)r.pop();r.push(e[t])}const i=[];for(let t=e.length-1;t>=0;t--){for(;i.length>=2&&_z(i[i.length-2],i[i.length-1],e[t])<=0;)i.pop();i.push(e[t])}i.pop(),r.pop();return r.concat(i)},Sz={maxRoutingIterations:100,maxMarchingIterations:100,pixelGroupSize:2,edgeR0:10,edgeR1:10,nodeR0:5,nodeR1:10,morphBuffer:5,threshold:.001,skip:16,nodeInfluenceFactor:1,edgeInfluenceFactor:1,negativeNodeInfluenceFactor:-.5};function xz(t,e,n){let r=!1;const i=(t,n)=>e.cells[t+n*e.width],o=(t,e)=>{let r=0;return i(t-1,e-1)>=n&&(r+=1),i(t,e-1)>n&&(r+=2),i(t-1,e)>n&&(r+=4),i(t,e)>n&&(r+=8),r},a=(n,r)=>{let i,a,s=n,l=r;for(let n=0;n<e.width*e.height;n++){if(i=s,a=l,t.findIndex((t=>t.x===s&&t.y===l))>-1){if(t[0].x===s&&t[0].y===l)return!0}else t.push({x:s,y:l});const e=o(s,l);switch(e){case-1:return console.warn("Marched out of bounds"),!0;case 0:case 3:case 2:case 7:s++;break;case 12:case 14:case 4:s--;break;case 6:0===i&&(-1===a?s-=1:s+=1);break;case 1:case 13:case 5:l--;break;case 9:1===i&&(0===a?l-=1:l+=1);break;case 10:case 8:case 11:l++;break;default:return console.warn(`Marching squares invalid state: ${e}`),!0}}};this.march=()=>{for(let t=0;t<e.width&&!r;t+=1)for(let s=0;s<e.height&&!r;s+=1)i(t,s)>n&&15!==o(t,s)&&(r=a(t,s));return r}}const Tz=(t,e,n)=>{let r=Number.POSITIVE_INFINITY,i=null;return e.forEach((e=>{const o=fz(t,e.id,n);o>=0&&o<r&&(i=e,r=o)})),i};function Az(t,e,n,r,i,o){const a=((t,e,n,r)=>{let i=null,o=Number.POSITIVE_INFINITY;return n.forEach((n=>{const a={x:e.data.x,y:e.data.y},s={x:n.data.x,y:n.data.y},l=pz(a,s),c=new dz(a.x,a.y,s.x,s.y),u=r.reduce(((e,n)=>fz(t,n.id,c)>0?e+1:e),0);l*Math.pow(u+1,2)<o&&(i=n,o=l*Math.pow(u+1,2))})),i})(t,e,r,n);if(null===a)return[];const s=new dz(e.data.x,e.data.y,a.data.x,a.data.y),l=((t,e,n,r,i)=>{const o=[],a=[];a.push(e);let s=!0,l=0;const c=(t,e)=>{let n=!1;return e.forEach((e=>{n||(vz(t,{x:e.x1,y:e.y1})||vz(t,{x:e.x2,y:e.y2}))&&(n=!0)})),n},u=(t,e,n)=>{for(const r of n){const n=t.getRenderBBox(r.id);if(!n)continue;const[i,o]=n.min,a=[[i,o],[n.max[0],o],[i,n.max[1]],[n.max[0],n.max[1]]];if(YR(a,e.x,e.y))return!0}return!1};for(;s&&l<r;)for(s=!1;!s&&a.length;){const e=a.pop(),r=Tz(t,n,e);if(r){const[l,h]=yz(t,r.id,e);if(2===h){const h=h=>{let d=i,p=Cz(r,d,l,h),f=c(p,a)||c(p,o),g=u(t,p,n);for(;!f&&g&&d>=1;)d/=1.5,p=Cz(r,d,l,h),f=c(p,a)||c(p,o),g=u(t,p,n);!p||f||h&&g||(a.push(new dz(e.x1,e.y1,p.x,p.y)),a.push(new dz(p.x,p.y,e.x2,e.y2)),s=!0)};h(!0),s||h(!1)}}s||o.push(e),l+=1}for(;a.length;)o.push(a.pop());return o})(t,s,n,i,o),c=(e=>{const r=[];for(;e.length>0;){const i=e.pop();if(0===e.length){r.push(i);break}const o=e.pop(),a=new dz(i.x1,i.y1,o.x2,o.y2);Tz(t,n,a)?(r.push(i),e.push(o)):e.push(a)}return r})(l);return c}const Rz=(t,e,n,r)=>{const i=Object.assign(Sz,r),o=(t=>{let e=0,n=0;if(t.length>0){for(const r of t)e+=r.x,n+=r.y;e/=t.length,n/=t.length}return{x:e,y:n}})(e.map((t=>({x:t.data.x,y:t.data.y}))));e=e.sort(((t,e)=>pz({x:t.data.x,y:t.data.y},o)-pz({x:e.data.x,y:e.data.y},o)));const a=[],s=[];e.forEach((e=>{Az(t,e,n,a,i.maxRoutingIterations,i.morphBuffer).forEach((t=>{s.push(t)})),a.push(e)}));const l=function(t,e,n,r){const i={min:[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,0],max:[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,0],halfExtents:[0,0,0]},o=[];e.forEach((e=>{o.push(t.getRenderBBox(e.id))})),n.forEach((t=>{o.push(t.getBBox())}));for(const t of o)i.min[0]=(t.min[0]<i.min[0]?t.min[0]:i.min[0])-r,i.min[1]=(t.min[1]<i.min[1]?t.min[1]:i.min[1])-r,i.max[0]=(t.max[0]>i.max[0]?t.max[0]:i.max[0])+r,i.max[1]=(t.max[1]>i.max[1]?t.max[1]:i.max[1])+r;return i.halfExtents=[(i.max[0]-i.min[0])/2,(i.max[1]-i.min[1])/2,0],i}(t,e,s,i.nodeR0),c=((t,e,n)=>{const r=Math.ceil(t/n),i=Math.ceil(e/n);return{cells:new Float32Array(Math.max(0,r*i)).fill(0),width:r,height:i}})(l.max[0]-l.min[0],l.max[1]-l.min[1],i.pixelGroupSize);let u=[],h=[];for(let r=0;r<i.maxMarchingIterations;r++){if(Mz(t,e,n,s,l,c,i),u=[],h=[],!new xz(u,c,i.threshold).march())continue;const o=u.map((t=>({x:Math.round(t.x*i.pixelGroupSize+l.min[0]),y:Math.round(t.y*i.pixelGroupSize+l.min[1])})));if(o){let t=o.length;if(i.skip>1)for(t=Math.floor(o.length/i.skip);t<3&&i.skip>1;)i.skip-=1,t=Math.floor(o.length/i.skip);for(let e=0,n=0;n<t;n+=1,e+=i.skip)h.push({x:o[e].x,y:o[e].y})}const a=()=>{for(const n of e){const e=h.map((t=>[t.x,t.y])),r=t.getRenderBBox(n.id);if(r&&!YR(e,r.center[0],r.center[1]))return!1}return!0};if(h&&a())return h;if(i.threshold*=.9,r<=.5*i.maxMarchingIterations)i.memberInfluenceFactor*=1.2,i.edgeInfluenceFactor*=1.2;else{if(!(0!==i.nonMemberInfluenceFactor&&n.length>0))break;i.nonMemberInfluenceFactor*=.8}}return h};function Mz(t,e,n,r,i,o,a){function s(t,e){const n=Math.floor((t-e)/a.pixelGroupSize);return n<0?0:n}function l(t,e){return t*a.pixelGroupSize+e}const c=(a.nodeR0-a.nodeR1)*(a.nodeR0-a.nodeR1),u=(a.edgeR0-a.edgeR1)*(a.edgeR0-a.edgeR1),h=(t,e)=>[Math.min(s(t.min[0],e+i.min[0]),o.width),Math.min(s(t.min[1],e+i.min[1]),o.height),Math.min(s(t.max[0],-e+i.min[0]),o.width),Math.min(s(t.max[1],-e+i.min[1]),o.height)],d=(t,e,n)=>{const r=t.getRenderBBox(e.id);if(!r)return;const[s,c,u,d]=h(r,a.nodeR1);for(let t=c;t<d;t+=1)for(let e=s;e<u;e+=1){if(n<0&&o[e+t*o.width]<=0)continue;const s=l(e,i.min[0]),c=l(t,i.min[1]),u=Ez({x:s,y:c},{x:r.min[0],y:r.min[1],width:r.max[0]-r.min[0],height:r.max[1]-r.min[1]});if(u<Math.pow(a.nodeR1,2)){const r=Math.sqrt(u)-a.nodeR1;o.cells[e+t*o.width]+=n*r*r}}};a.nodeInfluenceFactor&&e.forEach((e=>{d(t,e,a.nodeInfluenceFactor/c)})),a.edgeInfluenceFactor&&r.forEach((t=>{((t,e)=>{const n=t.getBBox(),[r,s,c,u]=h(n,a.edgeR1);for(let n=s;n<u;n+=1)for(let s=r;s<c;s+=1){if(e<0&&o.cells[s+n*o.width]<=0)continue;const r=l(s,i.min[0]),c=l(n,i.min[1]),u=hz({x:r,y:c},t);if(u<Math.pow(a.edgeR1,2)){const t=Math.sqrt(u)-a.edgeR1;o.cells[s+n*o.width]+=e*t*t}}})(t,a.edgeInfluenceFactor/u)})),a.negativeNodeInfluenceFactor&&n.forEach((e=>{d(t,e,a.negativeNodeInfluenceFactor/c)}))}function Cz(t,e,n,r){const i=t.getBBox(),[o,a,s,l]=n,c={topLeft:{x:i.minX-e,y:i.minY-e},topRight:{x:i.maxX+e,y:i.minY-e},bottomLeft:{x:i.minX-e,y:i.maxY+e},bottomRight:{x:i.maxX+e,y:i.maxY+e}},u=i.height*i.width;function h(t,e){return i.width*(.5*(t.y-i.minY+(e.y-i.minY)))}if(a){if(o)return r?c.topLeft:c.bottomRight;if(s)return r?c.bottomLeft:c.topRight;return h(a,l)<.5*u?a.y>l.y?r?c.topLeft:c.bottomRight:r?c.topRight:c.bottomLeft:a.y<l.y?r?c.bottomLeft:c.topRight:r?c.bottomRight:c.topLeft}if(l){if(o)return r?c.topRight:c.bottomLeft;if(s)return r?c.bottomRight:c.topLeft}return h(o,s)<.5*u?o.x>s.x?r?c.topLeft:c.bottomRight:r?c.bottomLeft:c.topRight:o.x<s.x?r?c.topRight:c.bottomLeft:r?c.bottomRight:c.topLeft}class Pz{constructor(t,e){const{members:n=[],nonMembers:r=[]}=e;this.options=e,this.graph=t,this.members=n.map((e=>t.getNodeData(e)||t.getComboData(e))),this.nonMembers=r.map((e=>t.getNodeData(e)||t.getComboData(e))),this.setPadding(),this.setType(),this.path=this.getPath(this.members,this.nonMembers),this.render()}getDefaultCfg(){return{id:"g6-hull",type:"round-convex",members:[],nonMembers:[]}}setPadding(){let t=30;if(this.members.length){const e=this.graph.getRenderBBox(this.members[0].id);e&&(t=e.halfExtents[0])}this.padding=this.options.padding>0?this.options.padding+t:10+t,this.bubbleCfg=Object.assign(Object.assign({},this.options.bubbleCfg),{nodeR0:this.padding-t,nodeR1:this.padding-t,morphBuffer:this.padding-t})}setType(){this.type=this.options.type,this.members.length<3&&(this.type="round-convex"),"round-convex"!==this.type&&"smooth-convex"!==this.type&&"bubble"!==this.type&&(console.warn("The hull type should be either round-convex, smooth-convex or bubble, round-convex is used by default."),this.type="round-convex")}getPath(t,e){let n,r,i;switch(this.type){case"round-convex":n=bz(t),i=sz(n.map((t=>[t.x,t.y])),this.padding),r=i;break;case"smooth-convex":n=bz(t),2===n.length?(i=sz(n.map((t=>[t.x,t.y])),this.padding),r=i):n.length>2&&(i=function(t,e){const n=t.length;if(!t||n<1)return"";if(1===n)return(t=>{const n=[t[0][0],t[0][1]-e],r=[t[0][0],t[0][1]+e];return`M ${n} A ${[e,e,"0,0,0",r].join(",")} A ${[e,e,"0,0,0",n].join(",")}`})(t);if(2===n)return(t=>{const n=cz(t[0],t[1]),r=uz(n,e),i=Nt([0,0],t[0],Ot([0,0],r,-1)),o=Nt([0,0],t[1],r),a=1.2*e,s=uz(It([0,0],n),a),l=Ot([0,0],s,-1),c=Nt([0,0],i,l),u=Nt([0,0],o,l),h=Nt([0,0],i,s);return`M ${i} C ${[c,u,o].join(",")} S ${[h,i].join(",")} Z`})(t);const r=t.map(((e,r)=>{const i=t[(r+1)%n];return{p:e,v:It([0,0],cz(e,i))}}));for(let t=0;t<r.length;++t){const i=It([0,0],Nt([0,0],r[t>0?t-1:n-1].v,Ot([0,0],r[t].v,-1)));r[t].p=Nt([0,0],r[t].p,Ot([0,0],i,e))}return r.map((t=>{const e=t.p;return{x:e[0],y:e[1]}}))}(n.map((t=>[t.x,t.y])),this.padding),r=az(i));break;case"bubble":n=Rz(this.graph,t,e,this.bubbleCfg),r=n.length>=2&&az(n)}return r}render(){if(!this.path)return;const t=this.graph.drawTransient("path",this.options.id,{style:Object.assign({path:this.path,pointerEvents:"none"},this.options.style)}),{labelShape:e}=this.options;if(null==e?void 0:e.text){const n=t.getRenderBounds(),r=Nc(e,["position","offsetX","offsetY"]),i=this.getLabelStyle(e,n);this.graph.drawTransient("text",`${this.options.id}-label`,{style:Object.assign(Object.assign({pointerEvents:"none"},r),i)})}t.toBack(),this.hullShape=t}getLabelStyle(t,e){const{position:n,offsetX:r=0,offsetY:i=0,autoRotate:o=!0}=t,{min:a,max:s,center:l}=e,c={x:0,y:0,textAlign:"center",textBaseline:"middle"},u={x:0,y:0};switch(n){case"bottom":case"outside-bottom":u.x=(a[0]+s[0])/2,u.y=s[1],c.textBaseline="bottom";break;case"left":case"outside-left":u.x=a[0],u.y=(a[1]+s[1])/2,c.textAlign="left";break;case"right":case"outside-right":u.x=s[0],u.y=(a[1]+s[1])/2,c.textAlign="right";break;default:u.x=(a[0]+s[0])/2,u.y=a[1],c.textBaseline="top"}let h;const d=ck(this.path);if("bubble"===this.type)switch(n){case"bottom":h={x:l[0],y:s[0]+10};break;case"left":h={x:s[0]+10,y:l[1]};break;case"right":h={x:a[0]-10,y:l[1]};break;default:h={x:l[0],y:s[1]-10}}else h={x:l[0],y:l[1]};const p=((t,e)=>{const n=t.length,r={};for(let i=0;i<n-1;i++){const n={x:t[i][0],y:t[i][1]},o={x:t[i+1][0],y:t[i+1][1]};if(n.x===o.x&&n.y===o.y)continue;const a=`${n.x}-${n.y}-${o.x}-${o.y}`;if(r[a])continue;r[a]=!0;const s=$R(n,o,e[0],e[1]);if(s)return{point:s,line:[n,o]}}})(d,[h,((t,e,n)=>{const r=(e.y-t.y)/(e.x-t.x);if(Math.abs(r)===1/0)return{x:t.x,y:e.y>t.y?t.y-n:t.y+n};if(0===r)return{x:e.x>t.x?t.x-n:t.x+n,y:e.y};const i=t.y-r*t.x,o=e.x>t.x?-1:1,a=t.x+o*n;return{x:a,y:r*a+i}})(u,h,100)]);if(p){const{point:t,line:e}=p;if(c.x=t.x+r,c.y=t.y+i,o){const t=Math.atan((e[0].y-e[1].y)/(e[0].x-e[1].x));c.transform=`rotate(${t/Math.PI*180}deg)`,c.textAlign="center","right"!==n&&"left"!==n||(c.textBaseline=t>0?"right"===n?"top":"bottom":"right"===n?"bottom":"top")}}else c.x=u.x+r,c.y=u.y+i;return"outside"===n.split("-")[0]&&(c.textBaseline=(t=>{switch(t){case"top":return"bottom";case"bottom":return"top";case"left":return"right";default:return"left"}})(c.textBaseline)),c}addMember(t){if(!t)return;const e=Re(t)?t:[t];let n=!1;return e.forEach((t=>{const e=this.graph.getNodeData(t)||this.graph.getComboData(t);-1===this.members.indexOf(e)&&(this.members.push(e),n=!0);const r=this.nonMembers.indexOf(e);r>-1&&(this.nonMembers.splice(r,1),n=!0)})),n&&this.updateMembers(this.members.map((t=>t.id)),this.nonMembers.map((t=>t.id))),!1}addNonMember(t){if(!t)return;const e=Re(t)?t:[t];let n=!1;return e.forEach((t=>{const e=this.graph.getNodeData(t)||this.graph.getComboData(t);-1===this.nonMembers.indexOf(e)&&(this.nonMembers.push(e),n=!0);const r=this.members.indexOf(e);r>-1&&(this.members.splice(r,1),n=!0)})),!!n&&(this.updateMembers(this.members.map((t=>t.id)),this.nonMembers.map((t=>t.id))),!0)}removeMember(t){if(!t)return;const e=Re(t)?t:[t];let n=!1;return e.forEach((t=>{const e=this.members.findIndex((e=>e.id===t));e>-1&&(this.members.splice(e,1),n=!0)})),!!n&&(this.updateMembers(this.members.map((t=>t.id)),this.nonMembers.map((t=>t.id))),!0)}removeNonMember(t){if(!t)return;const e=Re(t)?t:[t];let n=!1;return e.forEach((t=>{const e=this.graph.getNodeData(t)||this.graph.getComboData(t),r=this.nonMembers.indexOf(e);r>-1&&(this.nonMembers.splice(r,1),n=!0)})),!!n&&(this.updateMembers(this.members.map((t=>t.id)),this.nonMembers.map((t=>t.id))),!0)}updateMembers(t,e){t&&(this.options.members=t,this.members=t.map((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)))),e&&(this.options.nonMembers=e,this.nonMembers=e.map((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)))),this.path=this.getPath(this.members,this.nonMembers),this.render()}updateStyle(t){this.graph.drawTransient("path",this.options.id,{style:Object.assign(Object.assign({},t),{pointerEvents:"none"})})}updateOptions(t){const{members:e,nonMembers:n}=t;this.options=Object.assign(Object.assign(Object.assign({},this.options),t),{style:Object.assign(Object.assign({},this.options.style),t.style),labelShape:Object.assign(Object.assign({},this.options.labelShape),t.labelShape)}),e&&(this.members=e.map((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)))),n&&(this.nonMembers=n.map((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)))),this.setPadding(),this.setType(),this.path=this.getPath(this.members,this.nonMembers),this.render()}contain(t){let e;const n=this.graph.getRenderBBox(t);if(n)return e=[[n.min[0],n.min[1]],[n.max[0],n.min[1]],[n.max[0],n.max[1]],[n.min[0],n.max[1]]],e=e.map((t=>{const e=this.graph.getPointByCanvas(t[0],t[1]);return[e.x,e.y]})),jR(e,ck(this.path));console.warn(`The item with ${t} is not existed in the graph.`)}destroy(){this.graph.drawTransient("path",this.options.id,{action:"remove"})}}const{ValidateData:wz,TransformV4Data:Nz,MapNodeSize:Oz}=UB,{compactBox:Iz,dendrogram:Dz,indented:Bz,mindmap:kz}=ZC,{DarkTheme:Lz,LightTheme:Fz}=pL,{SpecThemeSolver:Uz,SubjectThemeSolver:Gz}=fF,{CircleNode:Vz,RectNode:Wz,DiamondNode:zz,DonutNode:Hz,SphereNode:jz,StarNode:Xz,HexagonNode:Yz,TriangleNode:Kz,EllipseNode:qz,ModelRectNode:$z,ImageNode:Zz,CubeNode:Qz,BaseNode:Jz,BaseNode3D:tH}=rk,{LineEdge:eH,CubicEdge:nH,CubicHorizontalEdge:rH,CubicVerticalEdge:iH,LoopEdge:oH,PolylineEdge:aH,QuadraticEdge:sH}=eL,{CircleCombo:lH,RectCombo:cH}=YB,{ActivateRelations:uH,BrushSelect:hH,HoverActivate:dH,LassoSelect:pH,OrbitCanvas3D:fH,RotateCanvas3D:gH,TrackCanvas3D:mH,ZoomCanvas3D:vH,ZoomCanvas:yH,DragCanvas:EH,CollapseExpandTree:_H,CollapseExpandCombo:bH,DragNode:SH,DragCombo:xH,ClickSelect:TH,CreateEdge:AH,ShortcutsCall:RH,ScrollCanvas:MH}=BB,{History:CH,Tooltip:PH,Minimap:wH,Grid:NH,Menu:OH,Fisheye:IH,Legend:DH,Toolbar:BH,Timebar:kH,Snapline:LH,EdgeFilterLens:FH}=rz,{ForceLayout:UH,GridLayout:GH,CircularLayout:VH,ConcentricLayout:WH,RandomLayout:zH,MDSLayout:HH,RadialLayout:jH,FruchtermanLayout:XH,D3ForceLayout:YH,ForceAtlas2Layout:KH,DagreLayout:qH,ComboCombinedLayout:$H}=VD,ZH={transforms:{"validate-data":wz,"transform-v4-data":Nz,"map-node-size":Oz},themes:{light:Fz,dark:Lz},themeSolvers:{spec:Uz,subject:Gz},layouts:Object.assign({force:UH,grid:GH,circular:VH,concentric:WH},ZC),behaviors:{"drag-canvas":EH,"zoom-canvas":yH,"drag-node":SH,"drag-combo":xH,"collapse-expand-combo":bH,"collapse-expand-tree":_H,"click-select":TH},plugins:{history:CH},nodes:{"circle-node":Vz,"rect-node":Wz,"image-node":Zz},edges:{"line-edge":eH,"loop-edge":oH},combos:{"circle-combo":lH,"rect-combo":cH},markers:{collapse:(t,e,n)=>[["M",t-n,e],["a",n,n,0,1,0,2*n,0],["a",n,n,0,1,0,2*-n,0],["M",t-n+4,e],["L",t+n-4,e]],expand:(t,e,n)=>[["M",t-n,e],["a",n,n,0,1,0,2*n,0],["a",n,n,0,1,0,2*-n,0],["M",t-n+4,e],["L",t-n+2*n-4,e],["M",t-n+n,e-n+4],["L",t,e+n-4]],upTriangle:(t,e,n)=>{const r=n*Math.cos(Math.PI/6),i=n*Math.sin(Math.PI/6);return[["M",t-r,e+i],["L",t+r,e+i],["L",t,e-n],["Z"]]},downTriangle:(t,e,n)=>{const r=n*Math.cos(Math.PI/6),i=n*Math.sin(Math.PI/6);return[["M",t-r,e-i],["L",t+r,e-i],["L",t,e+n],["Z"]]}}},QH={rectSelector:(t,e,n)=>{const[r,i]=e,o=Math.min(r.x,i.x),a=Math.max(r.x,i.x),s=Math.min(r.y,i.y),l=Math.max(r.y,i.y),c=[],u=[];let h=[];return n.includes("node")&&t.getAllNodesData().forEach((e=>{const{id:n}=e;t.getItemVisible(n)&&oz(t,n,o,a,s,l)&&c.push(n)})),n.includes("combo")&&t.getAllCombosData().forEach((e=>{const{id:n}=e;t.getItemVisible(n)&&oz(t,n,o,a,s,l)&&u.push(n)})),n.includes("edge")&&(h=YD(t,c.concat(u))),{nodes:c,edges:h,combos:u}},lassoSelector:(t,e,n)=>{const r=e.map((t=>[t.x,t.y])),i=[];let o=[];const a=[];return n.includes("node")&&t.getAllNodesData().forEach((e=>{const{id:n}=e;t.getItemVisible(n)&&iz(t,n,r)&&i.push(n)})),n.includes("combo")&&t.getAllCombosData().forEach((e=>{const{id:n}=e;t.getItemVisible(n)&&iz(t,n,r)&&a.push(n)})),n.includes("edge")&&(o=YD(t,i.concat(a))),{nodes:i,edges:o,combos:a}}},JH={useLib:{transforms:{},themes:{},layouts:{},behaviors:{},plugins:{},nodes:{},edges:{},combos:{}}},tj={ValidateData:wz,TransformV4Data:Nz,MapNodeSize:Oz,LightTheme:Fz,DarkTheme:Lz,SpecThemeSolver:Uz,SubjectThemeSolver:Gz,ForceLayout:UH,GridLayout:GH,CircularLayout:VH,ConcentricLayout:WH,RandomLayout:zH,MDSLayout:HH,RadialLayout:jH,FruchtermanLayout:XH,D3ForceLayout:YH,ForceAtlas2Layout:KH,DagreLayout:qH,ComboCombinedLayout:$H,compactBox:Iz,dendrogram:Dz,indented:Bz,mindmap:kz,CircleNode:Vz,RectNode:Wz,DiamondNode:zz,DonutNode:Hz,SphereNode:jz,StarNode:Xz,HexagonNode:Yz,TriangleNode:Kz,EllipseNode:qz,ModelRectNode:$z,CubeNode:Qz,BaseNode:Jz,BaseNode3D:tH,LineEdge:eH,CubicEdge:nH,CubicHorizontalEdge:rH,CubicVerticalEdge:iH,LoopEdge:oH,PolylineEdge:aH,QuadraticEdge:sH,CircleCombo:lH,RectCombo:cH,BaseBehavior:WD,ActivateRelations:uH,BrushSelect:hH,HoverActivate:dH,LassoSelect:pH,OrbitCanvas3D:fH,RotateCanvas3D:gH,TrackCanvas3D:mH,ZoomCanvas3D:vH,ZoomCanvas:yH,DragCanvas:EH,CollapseExpandTree:_H,CollapseExpandCombo:bH,DragNode:SH,DragCombo:xH,CreateEdge:AH,ShortcutsCall:RH,ScrollCanvas:MH,BasePlugin:zD,History:CH,Toolbar:BH,Tooltip:PH,Minimap:wH,Grid:NH,Menu:OH,Fisheye:IH,Legend:DH,Timebar:kH,Hull:class extends zD{constructor(t){super(t),this.hullMap={},this.cacheChanges={remove:[],update:[]},this.debounceUpdateMembers=pn((()=>{Object.keys(this.hullMap).forEach((t=>{const e=this.hullMap[t];if(this.cacheChanges.remove.length)_R(e.options.members,this.cacheChanges.remove)&&e.removeMember(this.cacheChanges.remove);else if(this.cacheChanges.update.length){const t=this.cacheChanges.update.map((t=>t.id));_R(e.options.members,t)&&e.updateMembers()}})),this.cacheChanges={update:[],remove:[]}}),50,{trailing:!0,leading:!0}),this.key=(null==t?void 0:t.key)||`hull-${Math.random()}`}getDefaultCfgs(){return{key:`hull-${gn()}`,padding:10,style:{fill:"lightblue",stroke:"blue",opacity:.2},labelShape:Object.assign(Object.assign({},ER),{position:"outside-top",offsetY:-2}),hulls:[]}}init(t){super.init(t)}getEvents(){return{afteritemchange:this.handleNodesChange,afterrender:this.handleAfterRender}}handleNodesChange(t){const{itemType:e,models:n,ids:r,action:i}=t;"edge"!==e&&"add"!==i&&("remove"===i?this.cacheChanges.remove=this.cacheChanges.remove.concat(r):this.cacheChanges.update=this.cacheChanges.update.concat(n),this.debounceUpdateMembers())}handleAfterRender(){this.addHull(this.options.hulls)}addHull(t){const{padding:e,style:n,bubbleCfg:r,labelShape:i}=this.options;(Re(t)?t:[t]).forEach((t=>{const{id:o,style:a,labelShape:s,members:l}=t,c=Nc(t,["id","style","labelShape","members"]),u=null==l?void 0:l.filter((t=>this.graph.getNodeData(t)||this.graph.getComboData(t)));if(!(null==u?void 0:u.length))return void console.warn("Create hull failed. There are no valid members.");u.length!==l.length&&console.warn(`Some member of hull ${o} is not exist in the graph. Hull ${o} is added without those invalid members.`);const h=Object.assign({id:`${this.key}-${o}`,padding:e,bubbleCfg:r,style:Object.assign(Object.assign({},n),a),labelShape:(null==s?void 0:s.text)?Object.assign(Object.assign({},i),s):void 0,members:u},c);this.hullMap[o]?this.updateHull(h):this.hullMap[o]=new Pz(this.graph,h)}))}updateHull(t){(Re(t)?t:[t]).forEach((t=>{const{id:e}=t,n=Nc(t,["id"]);this.hullMap[e]?this.hullMap[e].updateOptions(n):console.warn(`Update hull component failed. The bubble with id ${e} is not existed.`)}))}removeHull(t){(Re(t)?t:[t]).forEach((t=>{this.hullMap[t].destroy(),delete this.hullMap[t]}))}addHullMember(t,e){const n=this.hullMap[t];n?n.addMember(e):console.warn(`Add member to hull faield. The hull with id ${t} is not exist`)}removeHullMember(t,e){const n=this.hullMap[t];n?n.removeMember(e):console.warn(`Remove member from hull faield. The hull with id ${t} is not exist`)}addHullNonMember(t,e){const n=this.hullMap[t];n?n.addNonMember(e):console.warn(`Add non member to hull faield. The hull with id ${t} is not exist`)}removeHullNonMember(t,e){const n=this.hullMap[t];n?n.removeNonMember(e):console.warn(`Remove non member from hull faield. The hull with id ${t} is not exist`)}},Snapline:LH,EdgeFilterLens:FH,WaterMarker:class extends zD{constructor(t){super(t)}getDefaultCfgs(){return{key:`watermarker-${gn()}`,container:null,canvas:void 0,mode:"image",width:void 0,height:void 0,position:"bottom",begin:[0,0],seperation:[100,100],image:{imgURL:"https://gw.alipayobjects.com/os/s/prod/antv/assets/image/logo-with-text-73b8a.svg",width:94,height:28,rotate:0},text:{texts:"AntV",rotate:20,fontSize:14,fontFamily:"Microsoft YaHei",fill:"rgba(0, 0, 0, 0.1)",textBaseline:"top"}}}init(t){super.init(t);this.initCanvas().then((()=>{this.updateWaterMarker()}))}getEvents(){return{aftersetsize:this.onGraphSetSize}}initCanvas(){const{graph:t,options:e}=this,{width:n,height:r,position:i,canvas:o}=e;let a,s=e.container;const l=t.getSize();if(o)return this.canvas=o,this.canvasSize=[l[0],l[1]],this.followGraphSize=!0,this.container=t.container,o.ready;De(s)&&(s=document.getElementById(s)),a=s||t.container,a.style.position||(a.style.position="relative"),this.canvasSize=[void 0===n?l[0]:n,void 0===r?l[1]:r],this.followGraphSize=void 0===n||void 0===r,this.canvas=fR("canvas",a,this.canvasSize[0],this.canvasSize[1]);const c=this.canvas.getContextService().getDomElement();c.style.position="fixed",c.style.outline="none",c.style.pointerEvents="none",c.style.userSelect="none",this.container=a;const u=this.canvas.getContextService().getDomElement();this.container.removeChild(u);const h=t.canvas.getContextService().getDomElement(),d=t.transientCanvas.getContextService().getDomElement();switch(i){case"top":this.container.appendChild(u);break;case"middle":this.container.insertBefore(u,d);break;default:this.container.insertBefore(u,h)}return this.canvas.ready}onGraphSetSize(t){const{size:e}=t;this.followGraphSize&&(this.canvas.resize(e[0],e[1]),this.updateWaterMarker())}updateWaterMarker(){if("text"===this.options.mode)this.setTextWaterMarker();else this.setImageWaterMarker()}setImageWaterMarker(){const{canvas:t,options:e,canvasSize:n}=this,{image:r,begin:i,seperation:o}=e,{imgURL:a,rotate:s=0}=r,l=Nc(r,["imgURL","rotate"]),c=[...i];let u;const h=()=>{const t=new qs;for(;c[0]<n[0];){const e=new Zs({style:Object.assign(Object.assign({},l),{img:a,x:c[0],y:c[1]})});s&&(e.style.transformOrigin="center",e.style.transform=`rotate(${s}deg)`),u||(u=e.getLocalBounds()),t.appendChild(e),c[0]+=2*u.halfExtents[0]+o[0]}return t};for(;c[1]<n[1];)t.appendChild(h()),c[0]=i[0],c[1]+=2*u.halfExtents[1]+o[1]}setTextWaterMarker(){return Oc(this,void 0,void 0,(function*(){const{canvas:t,options:e,canvasSize:n}=this,{text:r,seperation:i,begin:o}=e,{texts:a,rotate:s}=r,l=Nc(r,["texts","rotate"]),c=[...o],u=(De(a)?[a]:a).join("\n");let h;const d=()=>{const t=new qs;for(;c[0]<n[0];){const e=new rl({style:Object.assign(Object.assign({},l),{text:u,x:c[0],y:c[1]})});s&&(e.style.transform=`rotate(${s}deg)`),h||(h=e.getLocalBounds()),t.appendChild(e),c[0]+=2*h.halfExtents[0]+i[0]}return t};for(;c[1]<n[1];)t.appendChild(d()),c[0]=o[0],c[1]+=2*h.halfExtents[1]+i[1]}))}destroy(){const{canvas:t,options:e}=this;let n;e.container||(n=this.graph.container),De(n)&&(n=document.getElementById(n)),n!==this.graph.container&&n.remove(),t.destroy()}}},ej=(t,e,n)=>{var r;const i=`${n}s`;if(Se(t))return t;const o="string"==typeof t?t:t.type;return null===(r=e[i])||void 0===r?void 0:r[o]},nj=["collapse-expand-tree"];function rj(t){if(!(null==t?void 0:t.length))return!1;const e=t.map((t=>De(t)?t:t.type)).filter(Boolean);return _R(nj,e)}class ij{constructor(t){this.extensions=[],this.graph=t,this.tap()}findData(t,e){const{graphCore:n}=this,r=typeof e,i=Re(e);if("string"===r||"number"===r||i){const r=i?e:[e];switch(t){case"node":return r.map((t=>{if(!n.hasNode(t))return;const e=n.getNode(t);return e.data._isCombo?void 0:e}));case"edge":return r.map((t=>n.hasEdge(t)?n.getEdge(t):void 0));case"combo":return r.map((t=>{if(!n.hasNode(t))return;const e=n.getNode(t);return e.data._isCombo?e:void 0}))}}else if("function"===r){return("node"===t?n.getAllNodes:n.getAllEdges)().filter((t=>e(t)))}}findAllData(t){if(!this.graphCore)return[];switch(t){case"node":return this.graphCore.getAllNodes();case"edge":return this.graphCore.getAllEdges();default:return[]}}findRelatedEdges(t,e="both"){return this.graphCore.getRelatedEdges(t,e)}findNeighborNodes(t,e="both"){return"in"===e?this.graphCore.getAncestors(t):"out"===e?this.graphCore.getSuccessors(t):this.graphCore.getNeighbors(t)}findChildren(t,e){if(this.graphCore.hasNode(t))return this.graphCore.getChildren(t,e)}tap(){this.extensions=this.getExtensions(),this.graph.hooks.datachange.tap(this.onDataChange.bind(this)),this.graph.hooks.treecollapseexpand.tap(this.onTreeCollapseExpand.bind(this)),this.graph.hooks.layout.tap(this.onLayout.bind(this)),this.graph.hooks.init.tap(this.onGraphInit.bind(this)),this.graph.hooks.behaviorchange.tap(this.onBehaviorChange.bind(this)),this.graph.hooks.modechange.tap(this.onModeChange.bind(this))}getExtensions(){const{transforms:t=[]}=this.graph.getSpecification();return[...t,"validate-data"].map((t=>({config:t,func:ej(t,JH.useLib,"transform")}))).filter((t=>!!t.func))}onDataChange(t){const{data:e,type:n}=t,{graphCore:r}=this,i=()=>{switch(n){case"remove":this.removeData(e);break;case"update":this.updateData(e);break;case"moveCombo":this.moveCombo(e);break;case"addCombo":this.addCombo(e);break;default:this.changeData(e,n)}};r?r.batch(i):i()}onTreeCollapseExpand(t){const{ids:e,action:n}=t;e.forEach((t=>{this.graphCore.mergeNodeData(t,{collapsed:"collapse"===n})}))}onLayout({options:t}){this.treeDirtyFlag&&mP(t)&&this.establishGraphCoreTree()}onGraphInit(){const{modes:t={}}=this.graph.getSpecification();rj(t[this.graph.getMode()||"default"])&&this.establishGraphCoreTree()}onBehaviorChange(t){const{action:e,modes:n,behaviors:r}=t,i=this.graph.getMode()||"default";"add"===e&&n.includes(i)&&rj(r)&&this.establishGraphCoreTree()}onModeChange(t){const{modes:e={}}=this.graph.getSpecification();rj(e[t.mode])&&this.establishGraphCoreTree()}establishGraphCoreTree(){if(!this.treeDirtyFlag)return;const t=this.graphCore.getAllNodes(),e=this.graphCore.getAllEdges(),n=t.filter((t=>t.data.isRoot)).map((t=>t.id));fP({},{nodes:t,edges:e},n).forEach((t=>{gP(t,(t=>{var e;null===(e=t.children)||void 0===e||e.forEach((e=>{this.graphCore.setParent(e.id,t.id,"tree")}))}))})),this.treeDirtyFlag=!1}changeData(t,e){var n;const{type:r,data:i}=this.formatData(t)||{};if(!r)return;this.dataType=r;const{nodes:o=[],edges:a=[],combos:s=[]}=this.transformData(i);if("replace"===e)this.graphCore=new TP(tn({nodes:o.concat((null==s?void 0:s.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),{_isCombo:!0})}))))||[]),edges:a})),(null==s?void 0:s.length)&&(this.graphCore.attachTreeStructure("combo"),o.forEach((t=>{t.data.parentId&&(dP(this.graph,t.id,t.data.parentId)?this.graphCore.setParent(t.id,t.data.parentId,"combo"):this.graphCore.mergeNodeData(t.id,{parentId:void 0}))})),s.forEach((t=>{t.data.parentId&&(dP(this.graph,t.id,t.data.parentId)?this.graphCore.setParent(t.id,t.data.parentId,"combo"):this.graphCore.mergeNodeData(t.id,{parentId:void 0}))})));else{const{graphCore:t}=this,n=oP({nodes:t.getAllNodes(),edges:[]}),r=o.concat(s.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),{_isCombo:!0})}))));if(n.nodes.length){if("mergeReplace"===e){const t=r.map((t=>t.id));n.nodes.forEach((e=>{t.includes(e.id)||this.removeNode(e)}))}r.forEach((e=>{t.hasNode(e.id)?t.mergeNodeData(e.id,e.data):t.addNode(e)}))}else t.addNodes(r);if(n.edges=t.getAllEdges(),n.edges.length){if("mergeReplace"===e){const e=a.map((t=>t.id));n.edges.forEach((n=>{e.includes(n.id)||t.removeEdge(n.id)}))}a.forEach((e=>{t.hasEdge(e.id)?t.mergeEdgeData(e.id,e.data):t.addEdge(e)}))}else t.addEdges(a)}if(null===(n=i.edges)||void 0===n?void 0:n.length){const{graphCore:t}=this;this.updateTreeGraph(r,{nodes:t.getAllNodes(),edges:t.getAllEdges()})}}removeNode(t){const{id:e,data:n}=t,{graphCore:r}=this;if(r.hasTreeStructure("combo")){r.setParent(e,void 0,"combo");const{parentId:t}=n;r.getChildren(e,"combo").forEach((e=>{r.setParent(e.id,t,"combo"),r.mergeNodeData(e.id,{parentId:t})}))}if(r.hasTreeStructure("tree")){const t=[];r.dfsTree(e,(e=>{t.push(e.id)}),"tree");const n=r.getAllEdges().filter((({source:e,target:n})=>t.includes(e)&&t.includes(n))).map((t=>t.id));this.graph.showItem(t.filter((t=>t!==e)).concat(n)),r.setParent(e,void 0,"tree"),r.getChildren(e,"tree").forEach((t=>r.setParent(t.id,void 0,"tree")))}r.removeNode(e)}removeData(t){const{graphCore:e}=this,{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.concat(i),a=e.getAllNodes(),s=e.getAllEdges();if(a.length&&o.length&&o.forEach((t=>{this.removeNode(t)})),s.length&&r.length){const t=r.map((t=>t.id)).filter((t=>e.hasEdge(t)));e.removeEdges(t)}}updateData(t){const{graphCore:e}=this,{type:n,data:r}=this.formatData(t);if(!n)return;const{nodes:i=[],edges:o=[],combos:a=[]}=r,{nodes:s,edges:l,combos:c}=oP({nodes:e.getAllNodes(),edges:e.getAllEdges()});if(s.length&&i.forEach((t=>{const{id:n,data:r}=t;if(r){const r=oj(e.getNode(n),t);e.mergeNodeData(n,r)}r.hasOwnProperty("parentId")&&e.setParent(n,r.parentId,"combo")})),l.length&&o.forEach((t=>{const n=e.getEdge(t.id);if(!n)return;const{id:r,source:i,target:o,data:a}=t;if(i&&n.source!==i&&e.updateEdgeSource(r,i),o&&n.target!==o&&e.updateEdgeTarget(r,o),a){const n=oj(e.getEdge(r),t);e.mergeEdgeData(r,n)}})),c.length){const t=[];a.forEach((n=>{const{id:r,data:i}=n;if(!i)return;const{x:o,y:a}=i,s=Nc(i,["x","y"]);if(void 0!==o||void 0!==a)if(this.graphCore.getChildren(r,"combo").length){const e=this.graph.getRenderBBox(r,!0);if(!e)return;const[i,s]=e.center,l=o-i,c=a-s;sP(this.graph,[n],(e=>{const{x:n,y:r,_isCombo:i}=e.data;i||t.push({id:e.id,data:{x:n+l,y:r+c}})}),"BT")}else t.push({id:r,data:{x:o,y:a}});if(Object.keys(s).length){const t=oj(e.getNode(r),{id:r,data:s});e.mergeNodeData(r,t),s.hasOwnProperty("parentId")&&e.setParent(r,s.parentId,"combo")}})),t.forEach((t=>{const{id:n,data:r}=t;e.mergeNodeData(n,r)}))}(null==o?void 0:o.filter((t=>t.hasOwnProperty("source")||t.hasOwnProperty("target"))).length)&&this.updateTreeGraph(n,{nodes:this.graphCore.getAllNodes(),edges:this.graphCore.getAllEdges()})}formatData(t){const{type:e,value:n}=t;let r=n;if(e){if("treeData"===e)r=pP(n);else if("fetch"===e);else if(!r.nodes)return void console.warn('Input data type is invalid, the type shuold be "graphData", "treeData", or "fetch".')}else r=t;return{type:e||this.dataType||"graphData",data:r}}moveCombo(t){const{combos:e=[]}=t,n=[];e.forEach((t=>{const{dx:e=0,dy:r=0}=t.data;if(e||r)if(this.graphCore.getChildren(t.id,"combo").length)sP(this.graph,[t],(t=>{const{x:i,y:o,_isCombo:a}=t.data;a&&this.graphCore.getChildren(t.id,"combo").length||n.push({id:t.id,data:{x:i+e,y:o+r}})}),"BT");else{const i=this.graphCore.getNode(t.id),{x:o=0,y:a=0}=i.data;n.push({id:t.id,data:{x:o+e,y:a+r}})}}));const{graphCore:r}=this;n.forEach((t=>{const{id:e,data:n}=t;if(n){const n=oj(r.getNode(e),t);r.mergeNodeData(e,n)}}))}addCombo(t){const{combos:e=[]}=t;if(!(null==e?void 0:e.length))return;const{graphCore:n}=this,{id:r,data:i}=e[0],{_children:o=[]}=i,a=Nc(i,["_children"]);n.hasTreeStructure("combo")||n.attachTreeStructure("combo"),n.hasNode(r)?n.mergeNodeData(r,Object.assign(Object.assign({},a),{_isCombo:!0})):n.addNode({id:r,data:Object.assign(Object.assign({},a),{_isCombo:!0})}),o.forEach((t=>{this.graphCore.hasNode(t)?(n.setParent(t,r,"combo"),n.mergeNodeData(t,{parentId:r})):console.warn(`Adding child ${t} to combo ${r} failed. The child ${t} does not exist`)}))}transformData(t){let e=tn(t);return this.extensions.forEach((({func:t,config:n})=>{e=t(e,n,this.graphCore)})),e}updateTreeGraph(t,e){this.graphCore.attachTreeStructure("tree"),"treeData"===t?e.edges.forEach((t=>{const{source:e,target:n}=t;this.graphCore.setParent(n,e,"tree")})):this.treeDirtyFlag=!0}}const oj=(t,e)=>{const{data:n}=e,{data:r}=t,i={};return Object.keys(n).forEach((t=>{Re(r[t])||Re(n[t])?i[t]=n[t]:"object"==typeof r[t]&&"object"==typeof n[t]?i[t]=Object.assign(Object.assign({},r[t]),n[t]):i[t]=n[t]})),i};var aj,sj;!function(t){t.pointerover="pointerover",t.pointerenter="pointerenter",t.pointerdown="pointerdown",t.pointermove="pointermove",t.pointerup="pointerup",t.pointerleave="pointerleave",t.click="click",t.wheel="wheel",t.dragstart="dragstart",t.drag="drag",t.dragend="dragend",t.dragenter="dragenter",t.dragleave="dragleave",t.dragover="dragover",t.dragout="dragout",t.drop="drop"}(aj||(aj={})),function(t){t.focus="focus",t.blur="blur",t.keyup="keyup",t.keydown="keydown",t.keypress="keypress"}(sj||(sj={}));const lj=t=>{var e;if("document"===t.nodeName)return{itemType:"canvas",itemId:void 0,groupElement:t};let n=t;for(;n&&!(null===(e=n.getAttribute)||void 0===e?void 0:e.call(n,"data-item-type"));)n=n.parentElement;return n?{itemType:n.getAttribute("data-item-type"),itemId:n.getAttribute("data-item-id"),groupElement:n}:null},cj=(t,e)=>Object.assign(Object.assign({},t),{type:"contextmenu",preventDefault:()=>{e.canvas.getContextService().getDomElement().addEventListener("contextmenu",(t=>{t.preventDefault()}),{once:!0})}});class uj{constructor(t){this.behaviorMap=new Map,this.listenersMap={},this.tap=()=>{this.graph.hooks.init.tap((()=>this.onModeChange({mode:"default"}))),this.onModeChange({mode:"default"}),this.graph.hooks.modechange.tap(this.onModeChange),this.graph.hooks.behaviorchange.tap(this.onBehaviorChange)},this.validateMode=t=>{if("default"===t)return!0;const e=this.graph.getSpecification().modes||{};return Object.keys(e).includes(t)},this.initBehavior=t=>{const e="string"==typeof t?t:t.key||t.type;if(this.behaviorMap.has(e))console.error(`G6: Failed to add behavior with key or type "${e}"! It was already added.`);else try{const n=ej(t,JH.useLib,"behavior"),r=new n("string"==typeof t?{}:t);return r.graph=this.graph,r&&this.behaviorMap.set(e,r),r}catch(t){return console.error(`G6: Failed to initialize behavior with key or type "${e}"!`,t),null}},this.destroyBehavior=(t,e)=>{try{e.destroy()}catch(e){console.error(`G6: Failed to destroy behavior with key or type "${t}"!`,e)}},this.addListeners=(t,e)=>{const n=e.getEvents();this.listenersMap[t]={},Object.keys(n).forEach((r=>{const i=((t,e,n)=>r=>{try{n(r)}catch(n){throw console.error(`G6: Error occurred in "${e}" phase of the behavior "${t}"!`),n}})(t,r,n[r].bind(e));this.graph.on(r,i),this.listenersMap[t][r]=i}))},this.removeListeners=t=>{Object.keys(this.listenersMap[t]||{}).forEach((e=>{const n=this.listenersMap[t][e];this.graph.off(e,n)}))},this.onModeChange=t=>{var e;const{mode:n}=t;if(this.mode===n)return;this.validateMode(n)||console.warn(`G6: Mode "${n}" was not specified in current graph.`),this.mode=n,this.behaviorMap.forEach(((t,e)=>{this.removeListeners(e),this.destroyBehavior(e,t)})),this.behaviorMap.clear();((null===(e=this.graph.getSpecification().modes)||void 0===e?void 0:e[n])||[]).forEach((t=>{this.initBehavior(t)})),this.listenersMap={},this.behaviorMap.forEach(((t,e)=>{this.addListeners(e,t)}))},this.onBehaviorChange=t=>{const{action:e,modes:n,behaviors:r}=t;n.forEach((t=>{t===this.mode&&("add"!==e?"remove"!==e?"update"===e&&r.forEach((t=>{const e="string"==typeof t?t:t.key||t.type,n=this.behaviorMap.get(e);n&&n.updateConfig(t)})):r.forEach((t=>{const e="string"==typeof t?t:t.key||t.type,n=this.behaviorMap.get(e);n&&(this.removeListeners(e),this.destroyBehavior(e,n))})):r.forEach((t=>{const e="string"==typeof t?t:t.key||t.type,n=this.initBehavior(t);n&&this.addListeners(e,n)})))}))},this.initEvents=()=>{Object.values(aj).forEach((t=>{this.graph.canvas.document.addEventListener(t,this.handleCanvasEvent)}));const t=this.graph.canvas.getContextService().getDomElement();Object.values(sj).forEach((e=>{t&&t.addEventListener&&t.addEventListener(e,this.handleDOMEvent)}))},this.handleCanvasEvent=t=>{const e=lj(t.target);if(!e)return;const{itemType:n,itemId:r}=e,i=Object.assign(Object.assign({},t),{itemType:n,itemId:r,gEvent:t,stopPropagation:t.stopPropagation,currentTarget:this.graph});"click"===i.type&&2===i.detail&&this.handleCanvasEvent(Object.assign(Object.assign({},t),{type:"dblclick"}));const o="click"===i.type&&2===i.button;if("canvas"!==i.itemType){if(("node"===n||"edge"===n||"combo"===n)&&("pointermove"!==i.type&&"pointerleave"!==i.type||this.handlePointerMove(i),o||(this.graph.emit(`${n}:${t.type}`,i),this.graph.emit(`${t.type}`,i)),"pointerdown"===i.type&&2===i.button)){const t=cj(i,this.graph);this.graph.emit(`${n}:contextmenu`,t),this.graph.emit("contextmenu",t)}}else if("pointermove"===i.type&&this.handlePointerMove(i),o||(this.graph.emit(`canvas:${t.type}`,i),this.graph.emit(`${t.type}`,i)),"pointerdown"===i.type&&2===i.button){const t=cj(i,this.graph);this.graph.emit("canvas:contextmenu",t),this.graph.emit("contextmenu",t)}},this.handlePointerMove=t=>{const e=this.prevItemInfo,n=lj(t.target);if((null==e?void 0:e.itemId)!==(null==n?void 0:n.itemId)){if(e){const n=e.itemType;this.graph.emit(`${n}:pointerleave`,Object.assign(Object.assign({},t),{itemId:e.itemId,itemType:e.itemType,type:"pointerleave",target:e.groupElement}))}if(n){const e=n.itemType;this.graph.emit(`${e}:pointerenter`,Object.assign(Object.assign({},t),{type:"pointerenter",target:n.groupElement}))}}this.prevItemInfo=n},this.handleDOMEvent=t=>{this.graph.emit(t.type,t)},this.graph=t,this.initEvents(),this.tap()}getMode(){return this.mode}}const hj={node:t=>{const{id:e,data:n}=t,{color:r,label:i,icon:o,badges:a,keyShape:s}=n,l=Object.assign(Object.assign({},n),{keyShape:Object.assign({},s)});return r&&(l.keyShape.fill=r),i&&(l.labelShape={text:i}),o&&(l.iconShape=o),a&&(l.badgeShapes=a),{id:e,data:l}},edge:t=>{const{id:e,source:n,target:r,data:i}=t,{color:o,label:a,icon:s,badge:l,keyShape:c}=i,u=Object.assign(Object.assign({},i),{keyShape:Object.assign({},c)});return o&&(u.keyShape.stroke=o),a&&(u.labelShape={text:a}),s&&(u.iconShape=s),l&&(u.badgeShape=l),{id:e,source:n,target:r,data:u}},combo:t=>t};class dj{constructor(t){this.destroyed=!1,this.visible=!0,this.states=[],this.shapeMap={keyShape:void 0},this.afterDrawShapeMap={},this.transient=!1,this.stateDirtyMap={},this.cacheStateStyles={},this.cacheNotHiddenByItem={},this.cacheHiddenByItem={},this.animateFrameListener=pn((t=>{var e;null===(e=this.onframe)||void 0===e||e.call(this,t)}),16,{trailing:!0,leading:!0}),this.device=t.device,this.onframe=t.onframe}init(t){var e;const{model:n,containerGroup:r,mapper:i,stateMapper:o,renderExtensions:a,zoom:s=1,theme:l={},type:c}=t;this.type=c,this.group=new qs({style:{zIndex:0}}),this.group.setAttribute("data-item-type",this.type),this.group.setAttribute("data-item-id",t.model.id),r.appendChild(this.group),this.model=n,this.mapper=i,this.zoom=s,this.stateMapper=o,this.displayModel=this.getDisplayModelAndChanges(n).model,this.renderExtensions=a;const{type:u=("edge"===this.type?"line-edge":`circle-${this.type}`),lodStrategy:h,enableBalanceShape:d}=this.displayModel.data,p=a.find((t=>t.type===u));this.themeStyles=l.styles;const f=h?HB(h):l.lodStrategy;if(!p)throw"node"===this.type?new Error(`TypeError: RenderExtension is not a constructor. The '${u}' in your data haven't been registered. You can use built-in node types like 'rect-node', 'circle-node' or create a custom node type as you like.`):"edge"==this.type?new Error(`TypeError: RenderExtension is not a constructor. The '${u}' in your data haven't been registered. You can use built-in edge types like 'line-edge', 'quadratic-edge','cubic-edge' or create a custom edge type as you like.`):new Error(`TypeError: RenderExtension is not a constructor. The '${u}' haven't been registered.`);this.renderExt=new p({themeStyles:null===(e=this.themeStyles)||void 0===e?void 0:e.default,lodStrategy:f,enableBalanceShape:d,device:this.device,zoom:this.zoom})}draw(t,e,n,r=!0,i=(()=>{})){var o,a;this.afterDrawShapeMap=(null===(a=(o=this.renderExt).afterDraw)||void 0===a?void 0:a.call(o,t,Object.assign(Object.assign({},this.shapeMap),this.afterDrawShapeMap)))||{},this.shapeMap=VR(this.shapeMap,this.afterDrawShapeMap,this.group,!1,(t=>!gR.includes(t)||(console.warn(`Shape with id ${t} is reserved and should be returned in draw function, if the shape with ${t} returned by afterDraw is a new one, it will not be added to the group.`),!1))),this.changedStates=[]}update(t,e,n,r,i,o=!0,a){var s;this.model=t,r&&(this.themeStyles=r.styles);const{model:l,typeChange:c}=this.getDisplayModelAndChanges(this.model,e,n);if(this.displayModel=l,this.lodStrategy=l.data.lodStrategy?HB(l.data.lodStrategy):(null==r?void 0:r.lodStrategy)||this.lodStrategy,i)this.updatePosition(l,e,o,a);else{if(c){Object.values(this.shapeMap).forEach((t=>t.destroy())),this.shapeMap={keyShape:void 0};const{type:t=("node"===this.type?"circle-node":"line-edge")}=l.data,e=this.renderExtensions.find((e=>e.type===t));this.renderExt=new e({themeStyles:this.themeStyles.default,lodStrategy:this.lodStrategy,device:this.device,zoom:this.zoom})}else this.renderExt.themeStyles=this.themeStyles.default,this.renderExt.lodStrategy=this.lodStrategy;(null===(s=this.states)||void 0===s?void 0:s.length)?this.drawWithStates(this.states,o,a):this.draw(this.displayModel,e,void 0,o,a),this.stateDirtyMap={},this.states.forEach((({name:t})=>this.stateDirtyMap[t]=!0))}}updatePosition(t,e,n,r){}getDisplayModelAndChanges(t,e,n){const{mapper:r,type:i}=this,o=hj[i],{data:a}=t,s=Nc(t,["data"]),{current:l=a}=e||{};if(!r){let e=!1;return l&&(e=Boolean(l.type)),{model:o(t),typeChange:e}}if(Se(r))return{model:Object.assign(Object.assign({},o(t)),r(t))};const c=n?void 0:Object.keys(l).concat(Object.keys(s));let u=!1;const h=Nc(t,["data"]),d=o(t).data;return Object.keys(r).forEach((e=>{let n=r[e];const i=gR.includes(e),o=i||e===mR;if(o&&zB(n)||!o)if(d.hasOwnProperty(e))"type"!==e||c&&!c.includes("type")||(u=!0);else{const{changed:i,value:a}=pj({innerModel:t,mapper:r,fieldName:e,dataChangedFields:c});if(o){if(!a)return;n=a}else d[e]=a;i&&"type"===e&&(u=!0)}i?(d[e]=d[e]||Me(t.data[e])?Object.assign({},t.data[e]):{},fj({innerModel:t,mapper:n,dataChangedFields:c,shapeConfig:d[e],fieldPath:[e]})):e===mR&&(d[e]=d[e]||Me(t.data[e])?Object.assign({},t.data[e]):{},Object.keys(n).forEach((r=>{var i;if(!(null===(i=d[e])||void 0===i?void 0:i.hasOwnProperty(r))){d[e][r]=d[e][r]||{};const i=n[r];fj({innerModel:t,mapper:i,dataChangedFields:c,shapeConfig:d[e][r],fieldPath:[e,r]})}})))})),{model:Object.assign(Object.assign({},h),{data:d}),typeChange:u}}getID(){return this.model.id}getType(){return this.type}show(t=!0){Promise.all(this.stopAnimations()).finally((()=>{var e;if(this.destroyed)return;const{animates:n={}}=this.displayModel.data;if(t&&(null===(e=n.show)||void 0===e?void 0:e.length)){const t={};Object.values(n.show).forEach((e=>{const{shapeId:n="group"}=e;t[n]=(t[n]||[]).concat(e.fields)}));const e={};Object.keys(this.shapeMap).forEach((n=>{const r=this.shapeMap[n];if(this.cacheHiddenByItem[n]){if(t[n]){e[n]=e[n]||{};const i=TR(r);t[n].forEach((t=>{i.hasOwnProperty(t)&&(e[n][t]=r.style[t],r.style[t]=i[t])}))}r.show()}})),t.group&&!this.shapeMap.keyShape.isVisible()&&t.group.forEach((t=>{const e="size"===t?"transform":t;AR[0].hasOwnProperty(e)&&(this.group.style[e]=AR[0][e])})),Object.keys(e).length&&(this.animations=this.runWithAnimates(n,"show",e))}else Object.keys(this.shapeMap).forEach((t=>{const e=this.shapeMap[t];this.cacheHiddenByItem[t]&&e.show()}));this.visible=!0,this.cacheHiddenByItem={}}))}hide(t=!0,e=!1){this.cacheNotHiddenByItem={};const n=()=>{Object.keys(this.shapeMap).forEach((t=>{if(e&&"keyShape"===t)return;const n=this.shapeMap[t];n.isVisible()?(n.hide(),this.cacheHiddenByItem[t]=!0):this.cacheNotHiddenByItem[t]=!0}))};Promise.all(this.stopAnimations()).then((()=>{var e;if(this.destroyed)return;const{animates:r={}}=this.displayModel.data;t&&(null===(e=r.hide)||void 0===e?void 0:e.length)?this.animations=this.runWithAnimates(r,"hide",void 0,n):n(),this.visible=!1}))}isVisible(){return this.visible}toFront(){this.group.toFront()}toBack(){this.group.toBack()}hasState(t){const e=this.states.find((e=>e.name===t));return(null==e?void 0:e.value)||!1}setState(t,e){const n=tn(this.states),r=this.states.find((e=>e.name===t));if(e)r?r.value=e:this.states.push({name:t,value:e});else{const t=this.states.indexOf(r);this.states.splice(t,1)}this.renderExt.constructor.prototype.hasOwnProperty("setState")?this.renderExt.setState(t,e,this.shapeMap):(this.changedStates=[t],this.drawWithStates(n))}clearStates(t){const e=tn(this.states),n=[];let r=[];t?this.states.filter((e=>{t.includes(e.name)?r.push(e):n.push(e)})):r=this.states.map((({name:t,value:e})=>({name:t,value:!1}))),this.states=n,this.changedStates=r.map((t=>t.name)),this.renderExt.constructor.prototype.hasOwnProperty("setState")?r.forEach((({name:t,value:e})=>this.renderExt.setState(t,e,this.shapeMap))):this.drawWithStates(e)}getStates(){return this.states}runWithAnimates(t,e,n,r=(()=>{})){let i={};return n?i=n:Object.keys(this.shapeMap).forEach((t=>{i[t]=TR(this.shapeMap[t])})),PR(t,i,this.shapeMap,this.group,e,[],(()=>{}),r)}drawWithStates(t,e=!0,n){const r=Nc(this.themeStyles,["default"]),{data:i}=this.displayModel;let o={};this.states.forEach((({name:t,value:e})=>{var n;const a=this.cacheStateStyles[t]||{},s=null===(n=this.stateMapper)||void 0===n?void 0:n[t];if(!s&&!(null==r?void 0:r[t]))return;s&&e&&(!this.stateDirtyMap.hasOwnProperty(t)||this.stateDirtyMap[t])&&(this.stateDirtyMap[t]=!1,Object.keys(s).forEach((t=>{a[t]=Object.assign({},i[t]),gR.includes(t)?fj({innerModel:this.model,mapper:s[t],dataChangedFields:void 0,shapeConfig:a[t],fieldPath:[t]}):t===mR&&s[t]&&Object.keys(s[t]).forEach((e=>{a[t]=a[t]||{},a[t][e]=a[t][e]||{},fj({innerModel:this.model,mapper:s[t][e],dataChangedFields:void 0,shapeConfig:a[t][e],fieldPath:[t,e]})}))}))),this.cacheStateStyles[t]=a;const l=zR([r[t],a]);o=zR([o,l])})),this.draw(Object.assign(Object.assign({},this.displayModel),{data:zR([i,o])}),void 0,{previous:t,current:this.states},e,n)}getKeyBBox(){const{keyShape:t}=this.shapeMap;return(null==t?void 0:t.getRenderBounds())||{center:[0,0,0]}}getLocalKeyBBox(){const{keyShape:t}=this.shapeMap;return(null==t?void 0:t.getLocalBounds())||{center:[0,0,0]}}getBBox(){var t;if(null===(t=this.animations)||void 0===t?void 0:t.length){const{keyShape:t,labelShape:e}=this.shapeMap,{x:n=0,y:r=0,z:i=0}=this.displayModel.data,{keyShape:o,labelShape:a}=this.renderExt.mergedStyles,s=e?(t=>{const e={center:[0,0,0],min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0],size:[0,0,0]};return t.forEach((t=>{const{min:n,max:r}=t;n.forEach(((t,n)=>{t<e.min[n]&&(e.min[n]=t)})),r.forEach(((t,n)=>{t>e.max[n]&&(e.max[n]=t)}))})),e.center=e.center.map(((t,n)=>(e.max[n]+e.min[n])/2)),e})([JR(t,o),JR(e,a)]):JR(t,o);return[n,r,i].forEach(((t,e)=>{s.max[e]+=t,s.min[e]+=t,s.center[e]+=t})),s}return this.group.getRenderBounds()}stopAnimations(){var t,e,n,r;const i=[];if(null===(t=this.animations)||void 0===t?void 0:t.length)for(;this.animations.length;){const t=this.animations.pop();if("running"!==t.playState)break;i.push(OR(t)),null===(e=t.onManualCancel)||void 0===e||e.call(t)}if(null===(n=this.groupAnimations)||void 0===n?void 0:n.length){for(;this.groupAnimations.length;){const t=this.groupAnimations.pop();if("running"!==t.playState)break;i.push(OR(t)),null===(r=t.onManualCancel)||void 0===r||r.call(t)}this.groupAnimations=[]}return i}updateZoom(t){this.zoom=t,this.renderExt.onZoom(this.shapeMap,t,this.cacheHiddenByItem)}destroy(){var t;const e=()=>{this.group.destroy(),this.model=null,this.displayModel=null,this.destroyed=!0};this.stopAnimations();const{animates:n}=this.displayModel.data;(null===(t=null==n?void 0:n.buildOut)||void 0===t?void 0:t.length)&&!this.transient?this.animations=this.runWithAnimates(n,"buildOut",void 0,e):e()}}const pj=({innerModel:t,fieldName:e,mapper:n,dataChangedFields:r})=>{const i=n[e]||"";if(zB(i)){const{fields:e,formatter:n}=i;if(!r||_R(r,e)){return{changed:!0,value:n(t)||""}}return{changed:!1}}return{changed:!0,value:i}},fj=({innerModel:t,mapper:e,dataChangedFields:n,shapeConfig:r,fieldPath:i})=>{if(!e)return;let o=t.data;null==i||i.forEach((t=>{o=o[t]||{}})),Object.keys(e).forEach((i=>{if(null==o?void 0:o.hasOwnProperty(i))return;const{value:a}=pj({innerModel:t,mapper:e,fieldName:i,dataChangedFields:n});r[i]=a}))};class gj extends dj{constructor(t){super(t),this.init(Object.assign(Object.assign({},t),{type:t.type||"node"})),t.delayFirstDraw||this.draw(this.displayModel,void 0,void 0,!this.displayModel.data.disableAnimate,t.onfinish)}draw(t,e,n,r=!0,i=(()=>{})){var o;const{group:a,renderExt:s,shapeMap:l,model:c}=this;s.mergeStyles(t);const u=!(null===(o=this.shapeMap)||void 0===o?void 0:o.keyShape),h=s.draw(t,this.shapeMap,e,n);this.shapeMap=VR(l,h,a);const{animates:d,disableAnimate:p,x:f=0,y:g=0,z:m=0}=t.data;u?(a.style.x=f,a.style.y=g,a.style.z=m):(this.stopAnimations(),this.updatePosition(t,e,r,i));const{haloShape:v}=this.shapeMap;if(null==v||v.toBack(),super.draw(t,e,n,r,i),s.updateCache(this.shapeMap),u&&s.onZoom(this.shapeMap,this.zoom),r&&!p&&d){const t=(t=>{if(!t.update)return t;const e=[];return t.update.forEach((t=>{const{shapeId:n,fields:r}=t,i=[...r];if(!(t=>!t||"group"===t)(n))return void e.push(Object.assign(Object.assign({},t),{fields:i}));let o=!1;if(r.includes("x")){const t=i.indexOf("x");i.splice(t,1),o=!0}if(r.includes("y")){const t=i.indexOf("y");i.splice(t,1),o=!0}o?0!==i.length&&e.push(Object.assign(Object.assign({},t),{fields:i})):e.push(Object.assign(Object.assign({},t),{fields:i}))})),Object.assign(Object.assign({},t),{update:e})})(d);this.animations=PR(t,s.mergedStyles,this.shapeMap,a,u?"buildIn":"update",this.changedStates,this.animateFrameListener,(t=>i(c.id,t)))}}updatePosition(t,e,n,r=(()=>{})){const{group:i}=this,{fx:o,fy:a,fz:s,x:l,y:c,z:u=0,animates:h,disableAnimate:d}=t.data,p={x:void 0===o?l:o,y:void 0===a?c:a,z:void 0===s?u:s};if(!(isNaN(p.x)||isNaN(p.y)||isNaN(p.z))){if(n&&!d&&(null==h?void 0:h.update)){const e=h.update.filter((({shapeId:t,fields:e=[]})=>(!t||"group"===t)&&(e.includes("x")||e.includes("y"))));if(e.length){const n=PR({update:e},{group:p},this.shapeMap,i,"update",[],this.animateFrameListener,(e=>r(t.id,e)));return void(this.groupAnimations=n)}}i.style.x=p.x,i.style.y=p.y,i.style.z=p.z,r(t.id,!n)}}clone(t,e,n){if(null==e?void 0:e.length){const n=new qs;return e.forEach((t=>{var e;if(!this.shapeMap[t]||this.shapeMap[t].destroyed)return;const r=this.shapeMap[t].cloneNode();r.style.opacity=(null===(e=this.renderExt.mergedStyles[t])||void 0===e?void 0:e.opacity)||1,n.appendChild(r)})),n.setPosition(this.group.getPosition()),t.appendChild(n),n}const r=tn(this.model);r.data.disableAnimate=n;const i=new gj({model:r,renderExtensions:this.renderExtensions,containerGroup:t,mapper:this.mapper,stateMapper:this.stateMapper,zoom:this.zoom,theme:{styles:this.themeStyles,lodStrategy:this.lodStrategy}});return Object.keys(this.shapeMap).forEach((t=>{this.shapeMap[t].isVisible()||i.shapeMap[t].hide()})),i}getAnchorPoint(t,e){const{anchorPoints:n=[]}=this.displayModel.data;return this.getIntersectPoint(t,this.getPosition(),n,e)}getIntersectPoint(t,e,n,r){const{keyShape:i}=this.shapeMap,o=i.nodeName,{x:a,y:s,z:l}=e,c=i.getRenderBounds(),u=c.max[0]-c.min[0],h=c.max[1]-c.min[1],d=n.map((t=>{const[e,n]=t;return{x:u*e+c.min[0],y:h*n+c.min[1]}}));if(void 0!==r&&d[r])return d[r];let p;switch(o){case"circle":p=Tk({x:a,y:s,r:i.attributes.r},t);break;case"ellipse":p=((t,e)=>{const{rx:n,ry:r,x:i,y:o}=t,a=e.x-i,s=e.y-o;let l=Math.atan2(s/r,a/n);return l<0&&(l+=2*Math.PI),{x:i+n*Math.cos(l),y:o+r*Math.sin(l)}})({x:a,y:s,rx:i.attributes.rx,ry:i.attributes.ry},t);break;case"mesh":p=e;break;default:p=Ak({x:c.min[0],y:c.min[1],width:u,height:h},t)}let f=p;return n.length&&(f||(f=t),f=_k(d,f).nearestPoint),f?(isNaN(l)||(f.z=l),f):{x:a,y:s,z:l}}getPosition(){if(this.shapeMap.keyShape&&void 0!==this.group.attributes.x&&3!==this.renderExt.dimensions){const{center:t}=this.shapeMap.keyShape.getRenderBounds();return{x:t[0],y:t[1],z:t[2]}}const{x:t=0,y:e=0,z:n=0,fx:r,fy:i,fz:o}=this.model.data;return{x:void 0===r?t:r,y:void 0===i?e:i,z:void 0===o?n:o}}}class mj extends dj{constructor(t){super(t),this.destroyed=!1,this.type="edge",this.cache={},this.init(Object.assign(Object.assign({},t),{type:"edge"}));const{sourceItem:e,targetItem:n,nodeMap:r}=t;this.sourceItem=e,this.targetItem=n,this.nodeMap=r,"node"===e.getType()&&this.nodeMap.set(e.getID(),e),"node"===e.getType()&&this.nodeMap.set(n.getID(),n),t.delayFirstDraw||this.draw(this.displayModel)}draw(t,e,n,r=!0,i=(()=>{})){var o,a;const{sourcePoint:s,targetPoint:l}=this.getEndPoints(t);this.renderExt.mergeStyles(t);const c=!(null===(o=this.shapeMap)||void 0===o?void 0:o.keyShape);this.renderExt.setSourcePoint(s),this.renderExt.setTargetPoint(l),this.renderExt.setNodeMap(this.nodeMap);const u=this.renderExt.draw(t,s,l,this.shapeMap,e,n);this.shapeMap=VR(this.shapeMap,Object.assign(Object.assign({},u),this.afterDrawShapeMap),this.group);const{animates:h,disableAnimate:d}=t.data,p=Object.assign({},h),f=this.renderExt.mergedStyles,{haloShape:g,labelShape:m}=this.shapeMap;null==g||g.toBack(),null==m||m.toFront(),super.draw(t,e,n),this.renderExt.updateCache(this.shapeMap),c?this.renderExt.onZoom(this.shapeMap,this.zoom):this.stopAnimations();r&&!d&&(null===(a=p[c?"buildIn":"update"])||void 0===a?void 0:a.length)&&(this.animations=PR(p,f,this.shapeMap,this.group,c?"buildIn":"update",this.changedStates,this.animateFrameListener,(e=>i(t.id,e)))),c&&!this.visible&&(this.visible=!0,this.hide(!1))}forceUpdate(){if(this.destroyed)return;const{sourcePoint:t,targetPoint:e,changed:n}=this.getEndPoints(this.displayModel);if(!n)return;this.renderExt.setSourcePoint(t),this.renderExt.setTargetPoint(e);const r=this.renderExt.draw(this.displayModel,t,e,this.shapeMap);this.shapeMap=VR(this.shapeMap,r,this.group)}updateEnd(t,e){"source"===t?this.sourceItem=e:"target"===t&&(this.targetItem=e),this.draw(this.displayModel)}getEndPoints(t){var e;const{sourceAnchor:n,targetAnchor:r,keyShape:i}=t.data,o=this.sourceItem.getPosition(),a=this.targetItem.getPosition();if(!this.shouldUpdatePoints(o,a,null==i?void 0:i.controlPoints))return{sourcePoint:this.cache.sourcePointCache,targetPoint:this.cache.targetPointCache,changed:!1};let s=o,l=a;if(null===(e=null==i?void 0:i.controlPoints)||void 0===e?void 0:e.length){const t=i.controlPoints.filter((t=>!xk(t,o)&&!xk(t,a)));l=_k(t,o).nearestPoint,s=_k(t,a).nearestPoint}return this.cache.sourcePointCache=this.sourceItem.getAnchorPoint(l,n),this.cache.targetPointCache=this.targetItem.getAnchorPoint(s,r),{sourcePoint:this.cache.sourcePointCache,targetPoint:this.cache.targetPointCache,changed:!0}}shouldUpdatePoints(t,e,n){const r="combo"===this.sourceItem.type||"combo"===this.targetItem.type,i=!(xk(t,this.cache.sourcePositionCache)&&xk(e,this.cache.targetPositionCache)&&n===this.cache.controlPointsCache)||r;return i&&(this.cache.sourcePositionCache=t,this.cache.targetPositionCache=e,this.cache.controlPointsCache=n),i}clone(t,e,n,r,i){if(null==r?void 0:r.length){const e=new qs;return r.forEach((t=>{var n;if(!this.shapeMap[t]||this.shapeMap[t].destroyed)return;const r=this.shapeMap[t].cloneNode();r.style.opacity=(null===(n=this.renderExt.mergedStyles[t])||void 0===n?void 0:n.opacity)||1,e.appendChild(r)})),t.appendChild(e),e}const o=tn(this.model);o.data.disableAnimate=i;const a=new mj({model:o,renderExtensions:this.renderExtensions,sourceItem:e,targetItem:n,nodeMap:this.nodeMap,containerGroup:t,mapper:this.mapper,stateMapper:this.stateMapper,zoom:this.zoom,theme:{styles:this.themeStyles,lodStrategy:this.lodStrategy}});return Object.keys(this.shapeMap).forEach((t=>{var e;this.shapeMap[t].isVisible()||null===(e=a.shapeMap[t])||void 0===e||e.hide()})),a}}class vj extends gj{constructor(t){super(Object.assign(Object.assign({},t),{type:"combo"})),this.forceUpdate=pn((()=>{this.updateModelByBounds(this.displayModel),this.destroyed||this.draw(this.displayModel)}),16,{leading:!0,trailing:!0})}init(t){this.getCombinedBounds=t.getCombinedBounds,this.getChildren=t.getChildren,super.init(t)}draw(t,e,n,r=!0,i=(()=>{})){t.data.collapsed&&Object.keys(this.themeStyles.collapsed).forEach((e=>{t.data[e]=t.data[e]||{},t.data[e]=Object.assign(Object.assign({},t.data[e]),this.themeStyles.collapsed[e]),"childCount"===this.themeStyles.collapsed[e].contentType&&(t.data[e].text=`${this.getChildren().length||0}`)})),super.draw(t,e,n,r,i)}getDisplayModelAndChanges(t,e,n){const r=super.getDisplayModelAndChanges(t,e,n),i=r.model;return{model:this.updateModelByBounds(i),typeChange:r.typeChange}}updateModelByBounds(t){const e=this.getCombinedBounds();if(this.cacheCombinedBounds=e,e){const{size:n,center:r}=e;if(t.data.x=r[0],t.data.y=r[1],t.data.z=r[2],!t.data.collapsed){t.data.keyShape=t.data.keyShape||{};const{padding:e=[0,0,0,0]}=t.data.keyShape,r=n[0]+e[1]+e[3],i=n[1]+e[0]+e[2];t.data.keyShape.width=r,t.data.keyShape.height=i,t.data.keyShape.r=Math.sqrt(r*r+i*i)/2}}return t}getPosition(){const{x:t=0,y:e=0,z:n=0}=this.model.data;this.cacheCombinedBounds=this.cacheCombinedBounds||this.getCombinedBounds();const{center:r}=this.cacheCombinedBounds||{};return r?{x:r[0],y:r[1],z:r[2]}:{x:t,y:e,z:n}}getIntersectPoint(t,e,n){var r,i;const{keyShape:o}=this.shapeMap,a=o.nodeName,{collapsed:s,keyShape:l}=this.displayModel.data,{x:c,y:u,z:h}=e;let d;if("circle"===a)d=Tk({x:c,y:u,r:(s?null==l?void 0:l.r:o.attributes.r)||o.attributes.r},t);else{const e=(null===(r=this.renderExt.boundsCache)||void 0===r?void 0:r.keyShapeLocal)||o.getLocalBounds();d=Ak(s?{x:c-l.width/2,y:u-l.height/2,width:l.width,height:l.height}:{x:c+e.min[0],y:u+e.min[1],width:e.max[0]-e.min[0],height:e.max[1]-e.min[1]},t)}let p=this.anchorPointsCache;if(!p){const t=(null===(i=this.renderExt.boundsCache)||void 0===i?void 0:i.keyShapeLocal)||this.shapeMap.keyShape.getLocalBounds(),e=t.max[0]-t.min[0],r=t.max[1]-t.min[1];p=n.map((t=>{const[n,i]=t;return{x:e*(n-.5)+c,y:r*(i-.5)+u}})),this.anchorPointsCache=p}let f=d;return n.length&&(f||(f=t),f=_k(p,f).nearestPoint),f||{x:c,y:u}}clone(t,e,n,r,i){if(null==e?void 0:e.length){const n=new qs;return e.forEach((t=>{var e;if(!this.shapeMap[t]||this.shapeMap[t].destroyed)return;const r=this.shapeMap[t].cloneNode();r.style.opacity=(null===(e=this.renderExt.mergedStyles[t])||void 0===e?void 0:e.opacity)||1,n.appendChild(r)})),n.setPosition(this.group.getPosition()),t.appendChild(n),n}const o=tn(this.model);o.data.disableAnimate=n;const a=new vj({model:o,renderExtensions:this.renderExtensions,containerGroup:t,mapper:this.mapper,stateMapper:this.stateMapper,zoom:this.zoom,theme:{styles:this.themeStyles,lodStrategy:this.lodStrategy},getCombinedBounds:r||this.getCombinedBounds,getChildren:i||this.getChildren});return Object.keys(this.shapeMap).forEach((t=>{this.shapeMap[t].isVisible()||a.shapeMap[t].hide()})),a}}class yj{constructor(t){this.nodeExtensions=[],this.edgeExtensions=[],this.comboExtensions=[],this.itemMap=new Map,this.nodeDataTypeSet=new Set,this.edgeDataTypeSet=new Set,this.comboDataTypeSet=new Set,this.transientObjectMap=new Map,this.transientItemMap=new Map,this.onViewportChange=en((({transform:t,effectTiming:e,tileLodSize:n=1e3})=>{const{zoom:r}=t;if(r){const t=this.graph.getZoom(),e=this.graph.getCanvasRange(),r=Array.from(this.itemMap,(([t,e])=>e)),i=[],o=[];r.forEach((t=>{const{keyShape:n}=t.shapeMap;if(!n)return;((t,e,n)=>n?t.min[0]>e.min[0]-e.halfExtents[0]*n&&t.max[0]<e.max[0]+e.halfExtents[0]*n&&t.min[1]>e.min[1]-e.halfExtents[1]*n&&t.max[1]<e.max[1]+e.halfExtents[1]*n:t.min[0]>e.min[0]&&t.max[0]<e.max[0]&&t.min[1]>e.min[1]&&t.max[1]<e.max[1])(n.getRenderBounds(),e,.4)?i.push(t):o.push(t)}));const a=i.concat(o),s=Math.ceil(r.length/n),l=Array.from({length:s},((t,e)=>a.slice(e*n,e*n+n)));let c;const u=()=>{l.length?(l.shift().forEach((e=>e.updateZoom(t))),c=requestAnimationFrame(u)):cancelAnimationFrame(c)};c=requestAnimationFrame(u),this.zoom=t}}),500,!1),this.onThemeChange=({theme:t})=>{if(!t)return;const{nodeDataTypeSet:e,edgeDataTypeSet:n}=this,{node:r,edge:i}=t;this.itemMap.forEach((t=>{const o=t.getType(),a="node"===o?r:i,s="node"===o?e:n,{dataTypeField:l}=a;let c;l&&(c=t.model.data[l]);const u=Ej(s,l,c,a);t.update(t.model,void 0,!1,u)}))},this.onMapperChange=({type:t,mapper:e})=>{e&&this.itemMap.forEach((n=>{n.getType()===t&&(n.mapper=e,n.update(n.model,void 0,!1))}))},this.onDestroy=()=>{Object.values(this.itemMap).forEach((t=>t.destroy())),this.itemMap.clear()},this.graph=t;const{node:e,edge:n,combo:r,nodeState:i={},edgeState:o={},comboState:a={}}=t.getSpecification();this.nodeMapper=e,this.edgeMapper=n,this.comboMapper=r,this.nodeStateMapper=i,this.edgeStateMapper=o,this.comboStateMapper=a,this.tap()}tap(){const t=this.getExtensions();this.nodeExtensions=t.node,this.edgeExtensions=t.edge,this.comboExtensions=t.combo,this.graph.hooks.render.tap(this.onRender.bind(this)),this.graph.hooks.itemchange.tap(this.onChange.bind(this)),this.graph.hooks.itemstatechange.tap(this.onItemStateChange.bind(this)),this.graph.hooks.itemvisibilitychange.tap(this.onItemVisibilityChange.bind(this)),this.graph.hooks.itemzindexchange.tap(this.onItemZIndexChange.bind(this)),this.graph.hooks.transientupdate.tap(this.onTransientUpdate.bind(this)),this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this)),this.graph.hooks.themechange.tap(this.onThemeChange.bind(this)),this.graph.hooks.mapperchange.tap(this.onMapperChange.bind(this)),this.graph.hooks.treecollapseexpand.tap(this.onTreeCollapseExpand.bind(this)),this.graph.hooks.destroy.tap(this.onDestroy.bind(this))}getExtensions(){this.graph.getSpecification();const t=Object.keys(JH.useLib.nodes||{}),e=Object.keys(JH.useLib.edges||{}),n=Object.keys(JH.useLib.combos||{});return{node:t.map((t=>ej(t,JH.useLib,"node"))).filter(Boolean),edge:e.map((t=>ej(t,JH.useLib,"edge"))).filter(Boolean),combo:n.map((t=>ej(t,JH.useLib,"combo"))).filter(Boolean)}}onRender(t){return Oc(this,void 0,void 0,(function*(){const{graphCore:e,theme:n={},transientCanvas:r,tileOptimize:i={}}=t,{graph:o}=this;o.canvas.removeChildren();const a=new qs({id:"combo-group",style:{zIndex:0}}),s=new qs({id:"edge-group",style:{zIndex:1}}),l=new qs({id:"node-group",style:{zIndex:2}});if(o.canvas.appendChild(a),o.canvas.appendChild(s),o.canvas.appendChild(l),this.nodeGroup=l,this.edgeGroup=s,this.comboGroup=a,r.removeChildren(),this.transientComboGroup=new qs({id:"combo-group",style:{zIndex:0}}),this.transientEdgeGroup=new qs({id:"edge-group",style:{zIndex:1}}),this.transientNodeGroup=new qs({id:"node-group",style:{zIndex:2}}),r.appendChild(this.transientComboGroup),r.appendChild(this.transientEdgeGroup),r.appendChild(this.transientNodeGroup),"webgl-3d"===o.rendererType){const t=new gg({style:{fill:"white",intensity:2*Math.PI}}),e=new mg({style:{fill:"white",direction:[-1,0,1],intensity:.7*Math.PI}});o.canvas.appendChild(t),o.canvas.appendChild(e);const{width:n,height:r}=o.canvas.getConfig();o.canvas.getCamera().setPerspective(.1,5e4,45,n/r)}const{nodes:c,edges:u,combos:h}=oP({nodes:e.getAllNodes(),edges:e.getAllEdges()}),d=this.renderNodes(c,n.node,i);let p;d&&(p=yield d),this.renderCombos(h,n.combo,e);const f=this.renderEdges(u,n.edge,i,p);if(f&&(yield f),this.sortByComboTree(e),e.hasTreeStructure("combo")&&aP(e,e.getRoots("combo"),(t=>{t.data.collapsed&&this.collapseCombo(e,t)}),"BT","combo"),e.hasTreeStructure("tree")){const t=[];aP(e,e.getRoots("tree"),(e=>{e.data.collapsed&&t.push(e)}),"BT","tree"),this.collapseSubTree(t,e,!1)}}))}onChange(t){const{changes:e,graphCore:n,action:r,animate:i=!0,upsertAncestors:o=!0,theme:a={},callback:s=(()=>{})}=t,l=((t,e)=>{const n={NodeRemoved:[],EdgeRemoved:[],NodeAdded:[],EdgeAdded:[],NodeDataUpdated:[],EdgeUpdated:[],EdgeDataUpdated:[],TreeStructureChanged:[],ComboStructureChanged:[],TreeStructureAttached:[],TreeStructureDetached:[]};return e.forEach((e=>{const{type:r}=e;if(["NodeDataUpdated","EdgeUpdated","EdgeDataUpdated"].includes(r)){const{id:i}=e;if(!t.hasNode(i)&&!t.hasEdge(i)){const o=Number(i);return void((!isNaN(o)&&t.hasNode(o)||t.hasEdge(o))&&n[r].push(Object.assign(Object.assign({},e),{id:o})))}}else{if("TreeStructureChanged"===r)return void("combo"===e.treeKey?n.ComboStructureChanged.push(e):"tree"===e.treeKey&&n.TreeStructureChanged.push(e));if(["NodeRemoved","EdgeRemoved","TreeStructureAttached","TreeStructureDetached"].includes(r))n[r].push(e);else{const{id:i}=e.value;if(!t.hasNode(i)&&!t.hasEdge(i)){const o=Number(i);return void((!isNaN(o)&&t.hasNode(o)||t.hasEdge(o))&&n[r].push(Object.assign(Object.assign({},e),{value:Object.assign(Object.assign({},e.value),{id:o})})))}}}n[r].push(e)})),n})(n,e),{itemMap:c}=this;[...l.EdgeRemoved,...l.NodeRemoved].forEach((({value:t})=>{const{id:e}=t,n=c.get(e);n&&(n.destroy(),c.delete(e))}));const{node:u={},edge:h={},combo:d={}}=a;if(l.NodeAdded.length){const t=[],e=[];l.NodeAdded.map((t=>t.value)).forEach((n=>{n.data._isCombo?e.push(n):t.push(n)})),t.length&&this.renderNodes(t,u),e.length&&this.renderCombos(e,d,n)}if(l.EdgeAdded.length&&this.renderEdges(l.EdgeAdded.map((t=>t.value)),h),l.NodeDataUpdated.length){const t={};l.NodeDataUpdated.forEach((e=>{const{id:n,propertyName:r,newValue:i,oldValue:o}=e;t[n]=t[n]||{id:n,previous:{},current:{}},r?(t[n].previous[r]=o,t[n].current[r]=i):t[n]={id:n,isReplace:!0,previous:o,current:i}}));const{dataTypeField:e}=u,a=new Set,h=new Set,d=t=>{(t?[...t]:[...h,...a]).forEach((t=>{const e=c.get(t);e&&!e.destroyed&&e.forceUpdate()}))},p=en(d,16,!1);Object.values(t).forEach((t=>{var l;const{isReplace:p,previous:f,current:g,id:m}=t;if(!n.hasNode(m))return;const v="updatePosition"===r,y=c.get(m);if(!y||y.destroyed)return;const E=y.getType(),_=n.getNode(m);if("node"===E&&v){const{x:t,y:e,fx:n,fy:r}=g;if(isNaN(t)&&isNaN(e)&&isNaN(n)&&isNaN(r))return void s(_,!0)}const b=new Set;if(n.hasTreeStructure("combo")){"combo"===E&&g.collapsed!==f.collapsed&&(g.collapsed?this.collapseCombo(n,_):!1===g.collapsed&&this.expandCombo(n,_));const t=y.displayModel.data.parentId;if(o){const e=[_];t&&t!==g.parentId&&n.hasNode(t)&&e.push(n.getNode(t)),lP(this.graph,n,e,(t=>{t.data._isCombo&&t.id!==_.id&&h.add(t.id);n.getRelatedEdges(t.id).forEach((t=>{a.add(t.id),b.add(t.id)}))}))}else"combo"===E&&sP(this.graph,[_],(t=>{n.getRelatedEdges(t.id).forEach((t=>{a.add(t.id),b.add(t.id)})),t.data._isCombo&&t.id!==_.id&&h.add(t.id)}))}let S;e&&f[e]!==g[e]&&(S=Ej(this.nodeDataTypeSet,e,g[e],u));let x;((null===(l=null==_?void 0:_.data)||void 0===l?void 0:l.preventPolylineEdgeOverlap)||!1?this.findNearEdgesByNode(m,n).concat(n.getRelatedEdges(m)):n.getRelatedEdges(m)).forEach((t=>{a.add(t.id),b.add(t.id)})),y.onframe=()=>d(b),_.data._isCombo&&f.collapsed!==g.collapsed&&(x=this.graph.getItemAllStates(m),this.graph.clearItemState(m)),y.update(_,{previous:f,current:g},p,S,v,i,pn(((t,e)=>{var n;null===(n=y.onframe)||void 0===n||n.call(y,!0),y.onframe=void 0,x&&x.forEach((t=>this.graph.setItemState(m,t,!0))),s(_,e)}),500,{leading:!0,trailing:!0}));const T=this.itemMap.get(g.parentId);g.parentId&&(null==T?void 0:T.model.data.collapsed)&&this.graph.executeWithNoStack((()=>{this.graph.hideItem(_.id,!1)}))})),p()}if(l.EdgeDataUpdated.length){const t={};l.EdgeDataUpdated.forEach((e=>{const{id:n,propertyName:r,newValue:i,oldValue:o}=e;t[n]=t[n]||{id:n,previous:{},current:{}},r?(t[n].previous[r]=o,t[n].current[r]=i):t[n]={id:n,isReplace:!0,previous:o,current:i}}));const{dataTypeField:e=""}=h;Object.values(t).forEach((t=>{const{isReplace:r,current:o,previous:a,id:l}=t;let u;a[e]!==o[e]&&(u=Ej(this.edgeDataTypeSet,e,o[e],h));const d=c.get(l),p=n.getEdge(l);d&&!d.destroyed&&d.update(p,{current:o,previous:a},r,u,void 0,i,((t,e)=>s(p,e)))}))}if(l.EdgeUpdated.length){const t={};l.EdgeUpdated.forEach((e=>{const{id:n,propertyName:r,newValue:i}=e;t[n]=t[n]||{id:n},t[n][r]=i})),Object.values(t).forEach((t=>{const{source:e,target:n,id:r}=t,i=c.get(r);void 0!==e&&i.updateEnd("source",this.itemMap.get(e)),void 0!==n&&i.updateEnd("target",this.itemMap.get(n))}))}l.ComboStructureChanged.length&&this.sortByComboTree(n),l.TreeStructureChanged.length&&l.TreeStructureChanged.forEach((t=>{const{nodeId:e}=t;let r=n.getParent(e,"tree");for(;r;){if(r.data.collapsed){this.graph.hideItem(e,!0);break}r=n.getParent(r.id,"tree")}}))}onItemStateChange(t){const{ids:e,states:n,value:r}=t;e.forEach((t=>{const e=this.itemMap.get(t);e?n&&r?n.forEach((t=>e.setState(t,r))):e.clearStates(n):console.warn(`Fail to set state for item ${t}, which is not exist.`)}))}onItemVisibilityChange(t){const{ids:e,value:n,graphCore:r,animate:i=!0,keepKeyShape:o=!1}=t;e.forEach((t=>{const e=this.itemMap.get(t);if(!e)return void console.warn(`Fail to set visibility for item ${t}, which is not exist.`);const a=e.getType();if(n)if("edge"===a)e.show(i);else{if(r.hasTreeStructure("combo")){let t=!1;if(uP(r,[e.model],(e=>(e.data.collapsed&&(t=!0),t))),t)return}const n=r.getRelatedEdges(t);e.show(i),n.forEach((({id:t,source:e,target:n})=>{var r;this.getItemVisible(e)&&this.getItemVisible(n)&&(null===(r=this.itemMap.get(t))||void 0===r||r.show(i))}))}else if(e.hide(i,o),"edge"!==a){r.getRelatedEdges(t).forEach((({id:t})=>{var e;null===(e=this.itemMap.get(t))||void 0===e||e.hide(i)}))}}))}onItemZIndexChange(t){const{ids:e=[],action:n,graphCore:r}=t;e.forEach((t=>{const e=this.itemMap.get(t);e&&("front"===n?(e.toFront(),r.hasTreeStructure("combo")&&sP(this.graph,[e.model],(t=>{if(t.data._isCombo){const e=this.itemMap.get(t.id);e&&e.toFront()}}),"TB")):(e.toBack(),r.hasTreeStructure("combo")&&cP(this.graph,[e.model],(t=>{var e;null===(e=this.itemMap.get(t.id))||void 0===e||e.toBack()}))))}))}onTransientUpdate(t){var e,n;const{transientObjectMap:r}=this,{type:i,id:o,config:a={},canvas:s,graphCore:l}=t,{style:c={},data:u={},capture:h,action:d,shapeIds:p,drawSource:f,drawTarget:g,upsertAncestors:m,visible:v=!0}=a,y="node"===i||"edge"===i||"combo"===i;if("remove"===d){if(y){const t=this.transientItemMap.get(o);return"combo"===i&&aP(l,[l.getNode(o)],(t=>{const e=this.transientItemMap.get(t.id);e&&!e.destroyed&&e.destroy(),this.transientItemMap.delete(t.id)}),"BT"),t&&!t.destroyed&&((null===(n=(e=t).getType)||void 0===n?void 0:n.call(e))||t.remove(),t.destroy()),void this.transientItemMap.delete(o)}{const t=r.get(o);return t&&!t.destroyed&&t.destroy(),void r.delete(o)}}if(y){const t=this.itemMap.get(o);if(!t)return void console.warn(`Fail to draw transient item of ${o}, which is not exist.`);const e=KD(t,this.transientNodeGroup,this.transientEdgeGroup,this.transientComboGroup,this.transientItemMap,this.itemMap,l,{shapeIds:p,drawSource:f,drawTarget:g,visible:v},m);if(p){if(("node"===i||"combo"===i)&&u.hasOwnProperty("x")&&u.hasOwnProperty("y")){const{x:t,y:n}=u;e.setPosition([t,n])}}else{const t=e,n=u.hasOwnProperty("x")&&u.hasOwnProperty("y");if("combo"===i&&n){const{x:e,y:n}=u,{x:r=e,y:i=n}=t.displayModel.data,o=e-r,a=n-i;aP(l,[t.model],(t=>{const e=this.transientItemMap.get(t.id);if(!e)return;const{x:n=0,y:r=0}=e.model.data;null==e||e.update(Object.assign(Object.assign({},e.model),{data:Object.assign(Object.assign({},e.model.data),{x:n+o,y:r+a})}))}),"BT")}if(l.hasTreeStructure("combo")&&"edge"!==i&&n){let e=l.getParent(t.model.id,"combo");for(;e;){const t=this.transientItemMap.get(e.id);t&&t.forceUpdate(),e=l.getParent(e.id,"combo")}}t.update(Object.assign(Object.assign({},t.model),{data:Object.assign(Object.assign({},t.model.data),u)}))}return}const E=String(o),_=GR(i,E,c,Object.fromEntries(r));r.set(E,_),_.style.pointerEvents=h?"auto":"none",s.getRoot().appendChild(_)}getTransient(t){return this.transientObjectMap.get(t)}getTransientItem(t){return this.transientItemMap[t]}findDisplayModel(t){var e;return null===(e=this.itemMap.get(t))||void 0===e?void 0:e.displayModel}renderNodes(t,e={},n){return Oc(this,void 0,void 0,(function*(){const{nodeExtensions:r,nodeGroup:i,nodeDataTypeSet:o,graph:a}=this,{dataTypeField:s=""}=e,{tileFirstRender:l,tileFirstRenderSize:c=1e3}=n||{},u=a.getZoom(),h=Ue(l)?t.length>l:l,d=[],p=[],f=this.graph.getCanvasRange();if(t.forEach((t=>{let n;s&&(n=t.data[s]);const l=Ej(o,s,n,e),c=new gj({delayFirstDraw:h,model:t,renderExtensions:r,containerGroup:i,mapper:this.nodeMapper,stateMapper:this.nodeStateMapper,zoom:u,theme:l,device:"webgl-3d"===a.rendererType?a.canvas.context.deviceRendererPlugin.getDevice():void 0});this.itemMap.set(t.id,c);const{x:g,y:m}=c.model.data;h&&((t,e)=>{const{x:n,y:r}=t;return n>e.min[0]&&n<e.max[0]&&r>e.min[1]&&r<e.max[1]})({x:g,y:m},f)?d.push(c):p.push(c)})),h){let t;const e=Math.ceil(p.length/c),n=Array.from({length:e},((t,e)=>p.slice(e*c,e*c+c)));n.unshift(d);const r=e=>{if(!n.length)return cancelAnimationFrame(t),e(d);n.shift().forEach((t=>t.draw(t.displayModel,void 0,void 0,!t.displayModel.data.disableAnimate))),t=requestAnimationFrame((()=>r(e)))};return new Promise((e=>{t=requestAnimationFrame((()=>r(e)))}))}}))}renderCombos(t,e={},n){return Oc(this,void 0,void 0,(function*(){const{comboExtensions:r,comboGroup:i,comboDataTypeSet:o,graph:a,itemMap:s}=this,{dataTypeField:l=""}=e,c=a.getZoom();t.forEach((t=>{let u;l&&(u=t.data[l]);const h=Ej(o,l,u,e),d=()=>((t,e)=>{if(!e.length)return!1;const n={center:[0,0,0],min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0],size:[0,0,0]};let r=0;return e.forEach((e=>{const i=t.getRenderBBox(e.model.id);if(i){if(e.model.data._isCombo){const{center:t}=e.getCombinedBounds()||{};t&&["min","max","center"].forEach((e=>{i[e]=i[e].map(((e,n)=>e-i.center[n]+t[n]))}))}r++;const{min:t,max:o}=i;t.forEach(((t,e)=>{t<n.min[e]&&(n.min[e]=t)})),o.forEach(((t,e)=>{t>n.max[e]&&(n.max[e]=t)}))}})),!!r&&(n.size=n.size.map(((t,e)=>n.max[e]-n.min[e])),n.center=n.center.map(((t,e)=>(n.max[e]+n.min[e])/2)),n)})(a,n.getChildren(t.id,"combo").map((({id:t})=>s.get(t))).filter(Boolean)),p=()=>n.getChildren(t.id,"combo").map((({id:t})=>s.get(t))),f=new vj({model:t,getCombinedBounds:d,getChildren:p,renderExtensions:r,containerGroup:i,mapper:this.comboMapper,stateMapper:this.comboStateMapper,zoom:c,theme:h,device:"webgl-3d"===a.rendererType?a.canvas.context.deviceRendererPlugin.getDevice():void 0});f.getCombinedBounds=d,f.getChildren=p,f.type="combo",s.set(t.id,f)}))}))}renderEdges(t,e={},n,r){const{edgeExtensions:i,edgeGroup:o,itemMap:a,edgeDataTypeSet:s,graph:l}=this,{dataTypeField:c=""}=e,{tileFirstRender:u,tileFirstRenderSize:h=1e3}=n||{},d=l.getZoom(),p=_j(a,"node"),f=Ue(u)?t.length>u:u,g=new Set(null==r?void 0:r.map((t=>t.getID()))),m=[],v=[];if(t.forEach((t=>{const{source:n,target:r,id:l}=t,u=a.get(n),h=a.get(r);if(!u)return void console.warn(`The source node ${n} is not exist in the graph for edge ${l}, please add the node first`);if(!h)return void console.warn(`The source node ${n} is not exist in the graph for edge ${l}, please add the node first`);let y;c&&(y=t.data[c]);const E=Ej(s,c,y,e),_=new mj({delayFirstDraw:f,model:t,renderExtensions:i,containerGroup:o,mapper:this.edgeMapper,stateMapper:this.edgeStateMapper,sourceItem:u,targetItem:h,nodeMap:p,zoom:d,theme:E});return a.set(l,_),g.has(n)||g.has(r)?m.push(_):v.push(_),_})),f){let t;const e=Math.ceil(v.length/h),n=Array.from({length:e},((t,e)=>v.slice(e*h,e*h+h)));n.unshift(m);const r=e=>{if(!n.length)return cancelAnimationFrame(t),e();n.shift().forEach((t=>t.draw(t.displayModel))),t=requestAnimationFrame((()=>r(e)))};return new Promise((e=>{t=requestAnimationFrame((()=>r(e)))}))}}findIdByState(t,e,n=!0){const r=[];return this.itemMap.forEach((i=>{i.getType()===t&&i.hasState(e)===n&&r.push(i.getID())})),r}getItemState(t,e){const n=this.itemMap.get(t);return n?n.hasState(e):(console.warn(`Fail to get item state, the item with id ${t} does not exist.`),!1)}getItemAllStates(t){const e=this.itemMap.get(t);return e?e.getStates().filter((({value:t})=>t)).map((({name:t})=>t)):(console.warn(`Fail to get item state, the item with id ${t} does not exist.`),[])}getItemById(t){return this.itemMap.get(t)}getItemBBox(t,e=!1,n=!1){const r=n?this.transientItemMap.get(t):this.itemMap.get(t);return r?r instanceof qs?r.getRenderBounds():e?r.getKeyBBox():r.getBBox():(console.warn(`Fail to get item bbox, the item with id ${t} does not exist.`),!1)}getItemVisible(t){const e=this.itemMap.get(t);return e?e.isVisible():(console.warn(`Fail to get item visible, the item with id ${t} does not exist.`),!1)}findNearEdgesByNode(t,e){var n;const r=e.getAllEdges(),i=this.graph.getRenderBBox(void 0),o=new Lk(i,4);Ce(r,(t=>{const{data:{x:n,y:r}}=e.getNode(t.source),{data:{x:i,y:a}}=e.getNode(t.target);o.insert({id:t.id,p1:{x:n,y:r},p2:{x:i,y:a},bbox:this.graph.getRenderBBox(t.id)})}));const a=this.getTransientItem(t)||this.getItemById(t),s=this.graph.getRenderBBox(t),l=null===(n=null==a?void 0:a.model)||void 0===n?void 0:n.data;l&&s.update([l.x,l.y,0],s.halfExtents);const c=new Fk(o).getCollidingEdges(s);return hn(c,(t=>e.getEdge(t.id)))}sortByComboTree(t){t.hasTreeStructure("combo")&&aP(t,t.getRoots("combo"),(t=>{const e=this.itemMap.get(t.id);t.data._isCombo&&e&&e.toFront()}))}collapseCombo(t,e){let n=[];const r=[];sP(this.graph,[e],(i=>{i.id!==e.id&&this.graph.executeWithNoStack((()=>{this.graph.hideItem(i.id,!1)})),n=n.concat(t.getRelatedEdges(i.id)),r.push(i.id)}));const i=[];Be(n).forEach((t=>{const{id:n,source:o,target:a}=t;if(!this.graph.getItemVisible(n))return;const s=r.includes(o),l=r.includes(a);if(s&&l)return;const c=s?e.id:o,u=l?e.id:a;i.push({source:c,target:u})})),this.graph.executeWithNoStack((()=>{this.graph.addData("edge",bj(i))}))}expandCombo(t,e){let n=!1;if(uP(t,[e],(t=>!!t.data.collapsed&&(n=!0,!0))),n)return;const r=[];let i=[];const o=[];sP(this.graph,[e],(n=>{t.getRelatedEdges(n.id).forEach((t=>{t.data._virtual?r.push(t.id):i.push(t.id)})),n.id!==e.id&&(t.getNode(n.data.parentId).data.collapsed||o.push(n.id),n.data._isCombo&&n.data.collapsed&&this.collapseCombo(t,n))}));const a=[],s=new Map;i=Be(i.filter((e=>{const{source:n,target:r}=t.getEdge(e),i={source:n,target:r},l={source:this.graph.getItemVisible(n)||o.includes(n),target:this.graph.getItemVisible(r)||o.includes(r)};if(l.source&&l.target)return!0;const c={source:void 0,target:void 0};return Object.keys(c).forEach((e=>{l[e]?c[e]=i[e]:(s.get(i[e])||uP(t,[t.getNode(i[e])],(t=>{s.has(i[e])||(this.graph.getItemVisible(t.id)||o.includes(t.id))&&s.set(i[e],t.id)})),c[e]=s.get(i[e]))})),void 0!==c.source&&void 0!==c.target&&a.push(c),!1}))),this.graph.executeWithNoStack((()=>{this.graph.removeData("edge",Be(r)),this.graph.showItem(i.concat(o)),this.graph.addData("edge",bj(a))}))}onTreeCollapseExpand(t){const{ids:e,animate:n,action:r,graphCore:i}=t,o=e.map((t=>i.getNode(t)));if("collapse"===r)this.collapseSubTree(o,i,n);else this.expandSubTree(o,i,n)}collapseSubTree(t,e,n=!0){let r=[];t.forEach((t=>{let n=!0;const i=[];aP(e,[t],(r=>{var o;if(r.id===t.id)return;const a=e.getNeighbors(r.id);!(null===(o=e.getChildren(r.id,"tree"))||void 0===o?void 0:o.length)&&a.length>1&&(n=!1),i.push(r)}),"TB","tree",{stopAllFn:()=>!n}),n&&(r=r.concat(i.map((e=>({id:e.id,data:{x:t.data.x,y:t.data.y}})))))})),r.length&&this.graph.updateNodePosition(r,void 0,!n,((t,e)=>{this.graph.hideItem(t.id,e)}),void 0)}expandSubTree(t,e,n=!0){return Oc(this,void 0,void 0,(function*(){let r=[],i=[];t.forEach((t=>{const n=[];aP(e,[t],(t=>n.push(t.id)),"TB","tree",{stopBranchFn:e=>{const r=e.id!==t.id&&e.data.collapsed;return r&&n.push(e.id),r}}),i=i.concat(e.getAllEdges().filter((t=>n.includes(t.source)&&n.includes(t.target))).map((t=>t.id))),r=r.concat(n.filter((e=>e!==t.id)))}));const o=Be(r.concat(i));this.graph.showItem(o,!n),yield this.graph.layout(void 0,!n)}))}}const Ej=(t,e,n,r)=>{const{styles:i=[],lodStrategy:o}=r,a=HB(o);if(!e){return{styles:Re(i)?i[0]:Object.values(i)[0],lodStrategy:a}}let s;if(t.add(n),Re(i)){const e=i.length;s=i[Array.from(t).indexOf(n)%e]}else Me(i)&&(s=i[n]||i.others);return{styles:s,lodStrategy:a}},_j=(t,e)=>{const n=new Map;return t.forEach(((t,r)=>{t.type===e&&n.set(r,t)})),n},bj=t=>{const e=new Map;t.forEach((t=>{const{source:n,target:r}=t,i=`${n}_${r}`,o=e.get(i)||{edges:[],source:n,target:r};o.edges.push(t),e.set(i,o)}));const n=[];return e.forEach((t=>{const{source:e,target:r,edges:i}=t;n.push({id:`virtual-${gn()}`,source:e,target:r,data:{_virtual:!0,keyShape:{lineWidth:i.length}}})})),n};function Sj(t){return!!t.execute}function xj(t){return["circular","random","grid","mds","concentric","radial","fruchterman","fruchtermanGPU","d3force","force","gforce","forceAtlas2"].indexOf(t.type)>-1}class Tj{constructor(t){this.extensions={},this.graph=t,this.animatedDisplayObject=new js({}),this.tap()}tap(){this.graph.hooks.layout.tap(this.onLayout.bind(this)),this.graph.hooks.destroy.tap(this.onDestroy.bind(this))}onLayout(t){return Oc(this,void 0,void 0,(function*(){let e;this.stopLayout();const{graphCore:n,options:r,animate:i=!0}=t;let o=n.getAllNodes();(t=>{const{type:e}=t;return!!["comboCombined","comboForce"].includes(e)||!("dagre"!==e||!t.sortByCombo)})(r)||(o=o.filter((t=>this.graph.getItemVisible(t.id)&&!t.data._isCombo)));const a={};o.forEach((t=>a[t.id]=!0));const s={nodes:o,edges:n.getAllEdges().filter((t=>a[t.source]&&a[t.target]))},l=new TP(s);n.hasTreeStructure("combo")&&(l.attachTreeStructure("combo"),o.forEach((t=>{const e=n.getParent(t.id,"combo");e&&l.hasNode(e.id)&&l.setParent(t.id,e.id,"combo")})));const[c,u]=this.graph.getSize(),h=[c/2,u/2],d=((t,e=32)=>t.nodeSize?t.nodeSize:t=>{const{size:n,keyShape:r}=t.data;if(Re(n))return Math.max(...n);if(Ue(n))return n;if(!r)return e;const{r:i,width:o,height:a}=r;if(!isNaN(i))return 2*i;const s=!isNaN(o),l=!isNaN(a);return s&&l?Math.max(o,a):s?o:l?a:e})(r,32);if(Sj(r)){const{animated:t=!1,animationEffectTiming:n={duration:1e3},execute:i}=r,o=Nc(r,["animated","animationEffectTiming","execute"]);e=yield i(l,Object.assign({nodeSize:d,width:c,height:u,center:h},o)),t&&(yield this.animateLayoutWithoutIterations(e,n))}else{const{type:t="grid",animated:o=!1,animationEffectTiming:a={duration:1e3},iterations:p=300}=r,f=Nc(r,["type","animated","animationEffectTiming","iterations"]);let{workerEnabled:g=!1}=r;const m=ZH.layouts[t]||JH.useLib.layouts[t];if(!m)throw new Error(`Unknown layout algorithm: ${t}`);if(mP(r))return void(yield this.handleTreeLayout(t,Object.assign({nodeSize:d,width:c,height:u,center:h},f),a,n,s,i));const v=new m(Object.assign({nodeSize:d,width:c,height:u,center:h},f));if(this.currentLayout=v,xj(r)||(g=!1),g){const t=new gw(l,v,{iterations:p});this.currentSupervisor=t,e=yield t.execute()}else GD(v)?o?e=yield v.execute(l,{onTick:t=>{this.updateNodesPosition(t),this.graph.emit("tick",t)}}):(v.execute(l),v.stop(),e=v.tick(p)):(e=yield v.execute(l),o&&(yield this.animateLayoutWithoutIterations(e,a)))}this.updateNodesPosition(e,i)}))}handleTreeLayout(t,e,n,r,i,o){return Oc(this,void 0,void 0,(function*(){const{animated:i=!1,rootIds:a=[],begin:s=[0,0],radial:l}=e,c=[],u=new Map;r.getRoots("tree").filter((t=>!t.data._isCombo)).map((t=>({id:t.id,children:[]}))).forEach((n=>{u.set(n.id,n),r.dfsTree(n.id,(t=>{u.get(t.id).children=r.getChildren(t.id,"tree").filter((t=>!t.data._isCombo)).map((t=>(u.set(t.id,{id:t.id,children:[]}),u.get(t.id))))}),"tree"),((t,e,n,r,i,o=[0,0])=>{const{treeGap:a=50}=n,s=((t,e)=>{const{direction:n}=e;switch(t){case"compactBox":case"dendrogram":return"TB"!==n&&" BT"!==n&&" V"!==n;case"indented":return!0;case"mindmap":return"V"!==n}})(e,n),l=ZC[e](t,n),c=[1/0,-1/0],u=[];gP(l,(t=>{const{id:e,x:n,y:i}=t;u.push(e);const o=s?"y":"x";c[0]>t[o]&&(c[0]=t[o]),c[1]<t[o]&&(c[1]=t[o]),r.get(e).data={x:n,y:i}}));const h=o[s?1:0]-c[0];u.forEach((t=>{const{x:e,y:n}=r.get(t).data;i.push({id:t,data:s?{x:e,y:n+h}:{x:e+h,y:n}})})),o[s?1:0]+=c[1]+h+a})(n,t,e,u,c,s),l&&(c.forEach((t=>u.set(t.id,t))),((t,e,n)=>{const r={x:1/0,y:1/0},i={x:-1/0,y:-1/0};let o="x",a="y";n&&["V","TB","BT"].indexOf(n)>=0&&(a="x",o="y");let s=0;gP(t,(t=>{s++;const{x:n,y:o}=e.get(t.id).data;n>i.x&&(i.x=n),n<r.x&&(r.x=n),o>i.y&&(i.y=o),o<r.y&&(r.y=o)}));const l=2*Math.PI/s,c=i[a]-r[a];if(0===c)return;const u=e.get(t.id);gP(t,(t=>{const n=e.get(t.id),i=(n.data[a]-r[a])/c*(2*Math.PI-l)+l,s=Math.abs(n.data[o]-u.data[o]);return n.data.x=s*Math.cos(i),n.data.y=s*Math.sin(i),!0}))})(n,u))})),i&&(yield this.animateLayoutWithoutIterations({nodes:c,edges:[]},n)),this.graph.emit("afterlayout"),this.updateNodesPosition({nodes:c,edges:[]},i||o)}))}stopLayout(){this.currentLayout&&GD(this.currentLayout)&&(this.currentLayout.stop(),this.currentLayout=null),this.currentSupervisor&&(this.currentSupervisor.stop(),this.currentSupervisor=null),this.currentAnimation&&(this.currentAnimation.finish(),this.currentAnimation=null)}getCurrentAnimation(){return this.currentAnimation}onDestroy(){this.stopLayout(),this.currentSupervisor&&this.currentSupervisor.kill()}updateNodesPosition(t,e=!0){const{nodes:n,edges:r}=t;this.graph.updateNodePosition(n,void 0,!e);const i=r.filter((t=>t.data.controlPoints)).map((t=>({id:t.id,data:{keyShape:{controlPoints:t.data.controlPoints}}})));i.length&&this.graph.updateData("edge",i)}animateLayoutWithoutIterations(t,e){return Oc(this,void 0,void 0,(function*(){e.iterations=1;const n=t.nodes.map((t=>Object.assign({},this.graph.getNodeData(`${t.id}`))));this.animatedDisplayObject.isConnected||(yield this.graph.canvas.ready,this.graph.canvas.appendChild(this.animatedDisplayObject)),this.currentAnimation=this.animatedDisplayObject.animate([{opacity:0},{opacity:1}],e),this.currentAnimation.onframe=e=>{const r=e.target.effect.getComputedTiming().progress,i=n.map((({id:e,data:n},i)=>{const{x:o=0,y:a=0}=n,{x:s,y:l}=t.nodes[i].data;return{id:e,data:{x:o+(s-o)*r,y:a+(l-a)*r}}}));this.updateNodesPosition({nodes:i,edges:[]})},yield this.currentAnimation.finished}))}}let Aj=0;class Rj{constructor(t){this.graph=t,this.tap()}tap(){this.graph.hooks.viewportchange.tap(this.onViewportChange.bind(this))}onViewportChange({transform:t,effectTiming:e}){return Oc(this,void 0,void 0,(function*(){const n=this.graph.canvas.getCamera(),r=this.graph.transientCanvas.getCamera(),{translate:i,rotate:o,zoom:a,origin:s=this.graph.getViewportCenter()}=t,l=n.getZoom();if(e){const{duration:t=1e3,easing:s="linear",easingFunction:c}=e,u={};if(i){const{dx:t=0,dy:e=0,dz:r=0}=i,[o,a,s]=n.getPosition(),[l,c,h]=n.getFocalPoint();u.position=[o-t,a-e,s-r],u.focalPoint=[l-t,c-e,h-r]}if(a){const{ratio:t}=a;u.zoom=l*t}if(o){const{angle:t}=o;u.roll=n.getRoll()+t}const h=n.createLandmark("mark"+Aj++,u),d=r.createLandmark(`mark${Aj}`,u);return new Promise((e=>{r.gotoLandmark(d,{duration:Number(t),easing:s,easingFunction:c}),n.gotoLandmark(h,{duration:Number(t),easing:s,easingFunction:c,onfinish:()=>{e(void 0)}})}))}if(i){const{dx:t=0,dy:e=0}=i;n.pan(-t/l,-e/l),r.pan(-t/l,-e/l)}if(o){const{angle:t}=o,[e,i]=n.getPosition();s&&(n.setPosition(s.x,s.y),n.setFocalPoint(s.x,s.y),r.setPosition(s.x,s.y),r.setFocalPoint(s.x,s.y)),n.rotate(0,0,t),r.rotate(0,0,t),s&&(n.pan(e-s.x,i-s.y),r.pan(e-s.x,i-s.y))}if(a){const{ratio:t}=a;n.setZoomByViewportPoint(l*t,[s.x,s.y]),r.setZoomByViewportPoint(l*t,[s.x,s.y])}}))}destroy(){}}class Mj{constructor(t){this.graph=t,this.tap()}tap(){this.extension=this.getExtension(),this.themes=this.getThemes(),this.graph.hooks.init.tap(this.onInit.bind(this)),this.graph.hooks.themechange.tap(this.onThemeChange.bind(this))}getExtension(){const{theme:t={}}=this.graph.getSpecification();return this.themeConfig=t,t?ej(t,JH.useLib,"themeSolver"):void 0}getThemes(){return((t,e)=>t[`${e}s`])(JH.useLib,"theme")}onInit({canvases:t}){if(this.extension&&(this.solver=new this.extension(this.themeConfig,this.themes),this.specification=this.solver.specification,this.specification)){const{canvas:e}=this.specification,n=t.background.getContextService().getDomElement();n&&n.style&&Object.keys(e).forEach((t=>n.style[t]=e[t]))}}onThemeChange({canvases:t}){t&&(this.extension=this.getExtension(),this.onInit({canvases:t}))}}class Cj{constructor(t){this.extensions={},this.graph=t}}class Pj{constructor(t){this.extensions=[],this.pluginMap=new Map,this.listenersMap={},this.addListeners=(t,e,n=!0)=>{const r=e.getEvents();this.listenersMap[t]={},Object.keys(r).forEach((i=>{const o=((t,e,n)=>r=>{try{n(r)}catch(n){throw console.error(`G6: Error occurred in "${e}" phase of the plugin "${t}"!`),n}})(t,i,r[i].bind(e));this.graph.on(i,o),this.listenersMap[t][i]=o,!n&&["afterrender","afterlayout"].includes(i)&&o({})}))},this.removeListeners=t=>{const e=this.listenersMap[t];Object.keys(e).forEach((t=>{const n=e[t];n&&this.graph.off(t,n)}))},this.graph=t,this.tap()}tap(){this.graph.hooks.init.tap(this.onPluginInit.bind(this)),this.graph.hooks.pluginchange.tap(this.onPluginChange.bind(this)),this.graph.hooks.destroy.tap(this.onDestroy.bind(this))}onPluginInit(){this.pluginMap.clear();const{graph:t}=this;(t.getSpecification().plugins||[]).forEach(this.initPlugin.bind(this)),this.listenersMap={},this.pluginMap.forEach(((t,e)=>{const{plugin:n}=t;this.addListeners(e,n)}))}initPlugin(t){var e,n;const{graph:r}=this;if(t instanceof zD){t.init(r);const n=t.key||(null===(e=t.options)||void 0===e?void 0:e.key)||`plugin-${gn()}`;return this.pluginMap.set(n,{type:n,plugin:t}),{key:n,plugin:t}}const i=ej(t,JH.useLib,"plugin"),o="string"==typeof t?{}:t,a="string"==typeof t?t:t.type,s="string"==typeof t?t:t.key||(null===(n=t.options)||void 0===n?void 0:n.key)||a;if(!i)throw new Error(`Plugin ${a} not found, please make sure you have registered it first`);const l=new i(Object.assign(Object.assign({},o),{key:s}));return l.init(r),this.pluginMap.set(s,{type:a,plugin:l}),{key:s,type:a,plugin:l}}onPluginChange(t){const{action:e,plugins:n}=t;"add"!==e?"remove"!==e?"update"!==e||n.forEach((t=>{if("string"==typeof t)return;const e=t.key||t.type,n=this.pluginMap.get(e);if(!n)return;const{plugin:r}=n;r.updateCfgs(t),this.removeListeners(e),this.addListeners(e,r,!1)})):n.forEach((t=>{var e;const n=("string"==typeof t?t:t.key)||(null===(e=t.options)||void 0===e?void 0:e.key)||t.type,r=this.pluginMap.get(n);if(!r)return;const{plugin:i}=r;this.removeListeners(n),i.destroy(),this.pluginMap.delete(n)})):n.forEach((t=>{const{key:e,plugin:n}=this.initPlugin(t);this.addListeners(e,n,!1)}))}hasPlugin(t){return this.pluginMap.has(t)}getPlugin(t){const{plugin:e}=this.pluginMap.get(t);if(!e)throw new Error("Plugin not found for key: "+t);return e}onDestroy(){this.pluginMap.forEach((t=>{const{plugin:e}=t;e.destroy()}))}destroy(){}}class wj{constructor(t){this.listeners=[];const{name:e}=t;this.name=e}tap(t){this.listeners.push(t)}unTap(t){const e=this.listeners.indexOf(t);e>-1&&this.listeners.splice(e,1)}emit(t){this.listeners.forEach((e=>e(t)))}emitLinearAsync(t){return Oc(this,void 0,void 0,(function*(){for(const e of this.listeners)yield e(t)}))}}const Nj=(t,e)=>(Object.keys(e).forEach((t=>{JH.useLib[t]=Object.assign({},JH.useLib[t],e[t]||{}),Object.keys(JH.useLib[t]).forEach((e=>{JH.useLib[t][e].type=e}))})),t);function Oj(t,e,n){const r=[0,0,0,0,0,0,0,0,0];return function(t,e){t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1}(r,n),y(t,r,e)}function Ij(t,e,n){const r=[0,0,0,0,0,0,0,0,0];return function(t,e){var n=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=n,t[2]=0,t[3]=-n,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1}(r,n),y(t,r,e)}function Dj(t,e,n){const r=[0,0,0,0,0,0,0,0,0];return function(t,e){t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1}(r,n),y(t,r,e)}function Bj(t,e,n){return y(t,n,e)}var kj=Object.freeze({__proto__:null,extend:Nj,mock:t=>{const e=[],n=Array.from({length:t}).map(((t,n)=>{const r=`node-${n}`;return e.push(r),{id:r,data:{}}})),r=[];for(let e=0;e<t;e+=1)for(let n=0;n<t-1;n+=1)r.push({source:`node-${e}`,target:`node-${n}`,id:gn("edge_id_"),data:{}});return{circle:(t="")=>{let i=t;-1===e.indexOf(i)&&(i="node-0");const o=r.filter((t=>t.source===i||t.target===i));return{nodes:n,edges:o}},random:(i=.5)=>{const o=parseInt(String(t*i)),a=e.sort((()=>Math.random()-.5)).slice(0,o),s=r.filter((t=>-1!==a.indexOf(t.target))).sort((()=>Math.random()-.5)).slice(0,o);return{nodes:n,edges:s}}}},isEncode:zB,getArrowPath:ik,graphCoreTreeDfs:aP,graphComboTreeDfs:sP,traverseAncestorsAndSucceeds:lP,traverseGraphAncestors:cP,traverseAncestors:uP,isSucceed:hP,treeData2GraphData:pP,graphData2TreeData:fP,traverse:gP,getEdgesBetween:YD,transform:function(t,e){const n=t?[].concat(t):[1,0,0,0,1,0,0,0,1];for(let t=0,r=e.length;t<r;t++){const r=e[t];switch(r[0]){case"t":Oj(n,n,[r[1],r[2]]);break;case"s":Dj(n,n,[r[1],r[2]]);break;case"r":Ij(n,n,r[1]);break;case"m":Bj(n,n,r[1])}}return n}});Ps.enableCSSParsing=!1;const Lj="5.0.0-beta.14",Fj=Nj(class extends Fc{constructor(t){super(),this.defaultSpecification={theme:{type:"spec",base:"light"},enableStack:!0},this.executeWithNoStack=t=>{const e=this.getHistoryPlugin();null==e||e.pauseStack();try{t()}finally{null==e||e.resumeStack()}},this.specification=Object.assign({},this.defaultSpecification,this.formatSpecification(t)),this.initHooks(),this.initCanvas(),this.initControllers(),this.initHistory(),this.hooks.init.emit({canvases:{background:this.backgroundCanvas,main:this.canvas,transient:this.transientCanvas}});const{data:e}=t;e&&this.read(e)}initControllers(){this.dataController=new ij(this),this.interactionController=new uj(this),this.layoutController=new Tj(this),this.themeController=new Mj(this),this.itemController=new yj(this),this.viewportController=new Rj(this),this.extensionController=new Cj(this),this.pluginController=new Pj(this)}initCanvas(){const{renderer:t,container:e,canvas:n,backgroundCanvas:r,transientCanvas:i,width:o,height:a}=this.specification;let s;if(t&&!De(t)?(this.rendererType=t.type||"canvas",s=t.pixelRatio):this.rendererType=t||"canvas",n)this.canvas=n,this.backgroundCanvas=r,this.transientCanvas=i,this.container=e;else{const t=De(e)?document.getElementById(e):e;if(!t)return console.error(`Create graph failed. The container for graph ${t} is not exist.`),void this.destroy();this.container=t;const n=[o,a];void 0===n[0]&&(n[0]=t.scrollWidth),void 0===n[1]&&(n[1]=t.scrollHeight),this.backgroundCanvas=fR(this.rendererType,t,n[0],n[1],s),this.canvas=fR(this.rendererType,t,n[0],n[1],s),this.transientCanvas=fR(this.rendererType,t,n[0],n[1],s)}Promise.all([this.backgroundCanvas,this.canvas,this.transientCanvas].map((t=>t.ready))).then((()=>{[this.backgroundCanvas,this.canvas,this.transientCanvas].forEach(((t,e)=>{const n=t.getContextService().getDomElement();n&&n.style&&(n.style.position="absolute",n.style.outline="none",n.tabIndex=1,2===e&&(n.style.pointerEvents="none"))})),this.canvasReady=!0}))}initHistory(){const{enableStack:t,stackCfg:e}=this.specification;if(t){const n={type:"history",key:"history",enableStack:t,stackCfg:e};this.specification.plugins||(this.specification.plugins=[]),this.specification.plugins.push(n)}}changeRenderer(t){this.rendererType=t||"canvas",((t,e)=>{let n;switch(t.toLowerCase()){case"svg":n=new Sb;break;case"webgl-3d":case"webgl":n=new pR,n.registerPlugin(new xg);break;default:n=new Lu}n.registerPlugin(new P_),e.setRenderer(n)})(this.rendererType,this.canvas)}initHooks(){this.hooks={init:new wj({name:"init"}),datachange:new wj({name:"datachange"}),itemchange:new wj({name:"itemchange"}),render:new wj({name:"render"}),layout:new wj({name:"layout"}),viewportchange:new wj({name:"viewport"}),modechange:new wj({name:"modechange"}),behaviorchange:new wj({name:"behaviorchange"}),itemstatechange:new wj({name:"itemstatechange"}),itemvisibilitychange:new wj({name:"itemvisibilitychange"}),itemzindexchange:new wj({name:"itemzindexchange"}),transientupdate:new wj({name:"transientupdate"}),pluginchange:new wj({name:"pluginchange"}),themechange:new wj({name:"themechange"}),mapperchange:new wj({name:"mapperchange"}),treecollapseexpand:new wj({name:"treecollapseexpand"}),destroy:new wj({name:"destroy"})}}formatSpecification(t){var e;return Object.assign(Object.assign(Object.assign({},this.specification),t),{optimize:Object.assign(Object.assign({tileBehavior:2e3,tileBehaviorSize:1e3,tileFirstRender:1e4,tileFirstRenderSize:1e3},null===(e=this.specification)||void 0===e?void 0:e.optimize),t.optimize)})}updateSpecification(t){return Object.assign(this.specification,this.formatSpecification(t))}updateTheme(t){this.specification.theme=t,this.hooks.themechange.emit({canvases:{background:this.backgroundCanvas,main:this.canvas,transient:this.transientCanvas}}),this.hooks.themechange.emit({theme:this.themeController.specification})}updateMapper(t,e){switch(t){case"node":this.specification.node=e;break;case"edge":this.specification.edge=e;break;case"combo":this.specification.combo=e}this.hooks.mapperchange.emit({type:t,mapper:e})}getSpecification(){return this.specification}read(t){return Oc(this,void 0,void 0,(function*(){const{tileFirstRender:e,tileFirstRenderSize:n}=this.specification.optimize||{};this.hooks.datachange.emit({data:t,type:"replace"});const r=()=>Oc(this,void 0,void 0,(function*(){yield this.hooks.render.emitLinearAsync({graphCore:this.dataController.graphCore,theme:this.themeController.specification,transientCanvas:this.transientCanvas,tileOptimize:{tileFirstRender:e,tileFirstRenderSize:n}}),this.emit("afterrender"),this.once("afterlayout",(()=>Oc(this,void 0,void 0,(function*(){const{autoFit:t}=this.specification;if(t)if("view"===t)yield this.fitView({rules:{boundsType:"layout"}});else if("center"===t)yield this.fitCenter("layout");else{const{type:e,effectTiming:n}=t,r=Nc(t,["type","effectTiming"]);if("view"===e){const{padding:t,rules:e}=r;yield this.fitView({padding:t,rules:Object.assign(Object.assign({},e),{boundsType:"layout"})},n)}else"center"===e?yield this.fitCenter("layout",n):"position"===e&&(yield this.translateTo(r.position,n))}})))),yield this.layout()}));this.canvasReady||(yield Promise.all([this.backgroundCanvas,this.canvas,this.transientCanvas].map((t=>t.ready)))),yield r()}))}changeData(t,e="mergeReplace"){return Oc(this,void 0,void 0,(function*(){const{tileFirstRender:n,tileFirstRenderSize:r}=this.specification.optimize||{};this.hooks.datachange.emit({data:t,type:e}),this.hooks.render.emit({graphCore:this.dataController.graphCore,theme:this.themeController.specification,transientCanvas:this.transientCanvas,tileOptimize:{tileFirstRender:n,tileFirstRenderSize:r}}),this.emit("afterrender"),yield this.layout()}))}clear(){this.startHistoryBatch(),this.removeData("edge",this.getAllEdgesData().map((t=>t.id))),this.removeData("node",this.getAllNodesData().map((t=>t.id))),this.removeData("combo",this.getAllCombosData().map((t=>t.id))),this.stopHistoryBatch()}getViewportCenter(){const{width:t,height:e}=this.canvas.getConfig();return{x:t/2,y:e/2}}transform(t,e){return Oc(this,void 0,void 0,(function*(){const{tileLodSize:n}=this.specification.optimize||{};yield this.hooks.viewportchange.emitLinearAsync({transform:t,effectTiming:e,tileLodSize:n}),this.emit("viewportchange",t)}))}stopTransformTransition(){this.canvas.getCamera().cancelLandmarkAnimation()}translate(t,e){return Oc(this,void 0,void 0,(function*(){yield this.transform({translate:t},e)}))}translateTo({x:t,y:e},n){return Oc(this,void 0,void 0,(function*(){const{x:r,y:i}=this.getViewportCenter();yield this.translate({dx:r-t,dy:i-e},n)}))}zoom(t,e,n){return Oc(this,void 0,void 0,(function*(){yield this.transform({zoom:{ratio:t},origin:e},n)}))}zoomTo(t,e,n){return Oc(this,void 0,void 0,(function*(){yield this.zoom(t/this.canvas.getCamera().getZoom(),e,n)}))}getZoom(){return this.canvas.getCamera().getZoom()}rotate(t,e,n){return Oc(this,void 0,void 0,(function*(){yield this.transform({rotate:{angle:t},origin:e},n)}))}rotateTo(t,e,n){return Oc(this,void 0,void 0,(function*(){yield this.rotate(t-this.canvas.getCamera().getRoll(),e,n)}))}fitView(t,e){return Oc(this,void 0,void 0,(function*(){const{padding:n,rules:r}=t||{},[i,o,a,s]=n?WR(n):[0,0,0,0],{direction:l="both",ratioRule:c="min",boundsType:u="render"}=r||{},{center:[h,d],halfExtents:p}="render"===u?this.canvas.document.documentElement.getBounds():vP(this),f=this.canvas.canvas2Viewport({x:h,y:d}),{width:g,height:m}=this.canvas.getConfig(),v=2*p[0],y=2*p[1],E=this.canvas.viewport2Canvas({x:s,y:i}),_=this.canvas.viewport2Canvas({x:g-o,y:m-a}),b=(_.x-E.x)/v,S=(_.y-E.y)/y;let x;x="x"===l?b:"y"===l?S:"max"===c?Math.max(b,S):Math.min(b,S),yield this.transform({translate:{dx:g/2-f.x,dy:m/2-f.y},zoom:{ratio:x}},e)}))}fitCenter(t="render",e){return Oc(this,void 0,void 0,(function*(){const{center:[n,r]}="render"===t?this.canvas.document.documentElement.getBounds():vP(this);yield this.translateTo(this.canvas.canvas2Viewport({x:n,y:r}),e)}))}focusItem(t,e){return Oc(this,void 0,void 0,(function*(){let n=null;for(const e of Re(t)?t:[t]){const t=this.getItemById(e);if(t){const e=t.group.getBounds();n?n.add(e):n=e}}if(n){const{center:[t,r]}=n;yield this.translateTo(this.canvas.canvas2Viewport({x:t,y:r}),e)}}))}getItemById(t){return this.itemController.getItemById(t)}getSize(){const{width:t=500,height:e=500}=this.specification;return[t,e]}setSize(t){if(!Re(t)||t.length<2)return void console.warn(`Failed to setSize. The parameter size: ${t} is invalid. It must be an array with 2 number elements.`);const e=[this.specification.width,this.specification.height];this.emit("beforesetsize",{oldSize:e,size:t}),this.specification.width=t[0],this.specification.height=t[1],this.canvas.resize(t[0],t[1]),this.transientCanvas.resize(t[0],t[1]),this.backgroundCanvas.resize(t[0],t[1]),this.emit("aftersetsize",{oldSize:e,size:t})}getCanvasRange(){const[t,e]=this.getSize(),n=this.getCanvasByViewport({x:0,y:0}),r=this.getCanvasByViewport({x:t,y:e});return{min:[n.x,n.y,n.z],max:[r.x,r.y,r.z],center:[(n.x+r.x)/2,(n.y+r.y)/2,(n.z+r.z)/2],halfExtents:[(r.x-n.x)/2,(r.y-n.y)/2,(r.z-n.z)/2]}}getCanvasByViewport(t){return this.canvas.viewport2Canvas(t)}getViewportByCanvas(t){return this.canvas.canvas2Viewport(t)}getClientByCanvas(t){const e=this.canvas.canvas2Viewport(t);return this.canvas.viewport2Client(e)}getCanvasByClient(t){const e=this.canvas.client2Viewport(t);return this.canvas.viewport2Canvas(e)}getNodeData(t){var e;const n=De(t)||Ue(t)?[t]:t;return null===(e=this.dataController.findData("node",n))||void 0===e?void 0:e[0]}getEdgeData(t){var e;const n=De(t)||Ue(t)||Ue(t)?[t]:t;return null===(e=this.dataController.findData("edge",n))||void 0===e?void 0:e[0]}getComboData(t){var e;const n=De(t)||Ue(t)?[t]:t;return null===(e=this.dataController.findData("combo",n))||void 0===e?void 0:e[0]}getAllNodesData(){return this.dataController.findAllData("node")}getAllEdgesData(){return this.dataController.findAllData("edge")}getAllCombosData(){return this.dataController.findAllData("combo")}getRelatedEdgesData(t,e="both"){return this.dataController.findRelatedEdges(t,e)}getNeighborNodesData(t,e="both"){return this.dataController.findNeighborNodes(t,e)}getComboChildrenData(t){return this.dataController.findChildren(t,"combo")}getDisplayModel(t){return this.itemController.findDisplayModel(t)}getNearEdgesForNode(t){const{graphCore:e}=this.dataController;return this.itemController.findNearEdgesByNode(t,e)}findIdByState(t,e,n=!0,r){let i=this.itemController.findIdByState(t,e,n);if(r){let e=this.getEdgeData;"node"===t?e=this.getNodeData:"combo"===t&&(e=this.getComboData),i=i.filter((t=>r(e(t))))}return i}addData(t,e){const{graphCore:n}=this.dataController,{specification:r}=this.themeController;n.once("changed",(i=>{if(!i.changes.length)return;const o=i.changes,a={type:t,action:"add",models:e,apiName:"addData",changes:o};this.emit("beforeitemchange",a),this.hooks.itemchange.emit({type:t,changes:n.reduceChanges(i.changes),graphCore:n,theme:r}),this.emit("afteritemchange",a)}));const i=Re(e)?e:[e],o={nodes:[],edges:[],combos:[]};o[`${t}s`]=i,this.hooks.datachange.emit({data:o,type:"union"});const a=this.dataController.findData(t,i.map((t=>t.id)));return Re(e)?a:a[0]}removeData(t,e){const n=Re(e)?e:[e],r={nodes:[],edges:[],combos:[]},{graphCore:i}=this.dataController,{specification:o}=this.themeController,a="edge"===t?i.getEdge:i.getNode,s="edge"===t?i.hasEdge:i.hasNode;r[`${t}s`]=n.map((e=>{if(s.bind(i)(e))return a.bind(i)(e);console.warn(`The ${t} data with id ${e} does not exist. It will be ignored`)})).filter(Boolean),i.once("changed",(e=>{if(!e.changes.length)return;const r=e.changes,a={type:t,action:"remove",ids:n,apiName:"removeData",changes:r};this.emit("beforeitemchange",a),this.hooks.itemchange.emit({type:t,changes:e.changes,graphCore:i,theme:o}),this.emit("afteritemchange",a)})),this.hooks.datachange.emit({data:r,type:"remove"})}extendChanges(t){return t.map((t=>{const{id:e,propertyName:n,oldValue:r,newValue:i}=t;if(!r||!i)return t;if(n)return r!==i&&t;const o=this.getItemById(e).displayModel.data,a=Object.keys(r),s=Object.keys(i);return[...new Set([...a,...s])].forEach((t=>{Object.prototype.hasOwnProperty.call(r,t)||(r[t]=o[t]),Object.prototype.hasOwnProperty.call(i,t)||(i[t]=o[t])})),void 0!==r.x&&!Number.isNaN(r.x)||r._isCombo||(r.x=0),void 0!==r.y&&!Number.isNaN(r.x)||r._isCombo||(r.y=0),Number.isNaN(i.x)&&delete i.x,Number.isNaN(i.y)&&delete i.y,!un(i,r)&&Object.assign(Object.assign({},t),{newValue:i,oldValue:r})})).filter(Boolean)}updateData(t,e){const n=Re(e)?e:[e],r={nodes:[],edges:[],combos:[]};r[`${t}s`]=n;const{graphCore:i}=this.dataController,{specification:o}=this.themeController;i.once("changed",(n=>{const r=this.extendChanges(tn(n.changes)),a={type:t,action:"update",models:e,apiName:"updateData",changes:r};this.emit("beforeitemchange",a),this.hooks.itemchange.emit({type:t,changes:n.changes,graphCore:i,theme:o}),this.emit("afteritemchange",a)})),this.hooks.datachange.emit({data:r,type:"update"});const a=this.dataController.findData(t,n.map((t=>t.id)));return Re(e)?a:a[0]}updateNodePosition(t,e,n=!1,r,i){return this.updatePosition("node",t,e,n,r,i)}updateComboPosition(t,e,n=!1,r,i){return this.updatePosition("combo",t,e,n,r,i)}getHistoryPlugin(){if(this.specification.enableStack&&this.pluginController.hasPlugin("history"))return this.pluginController.getPlugin("history");console.error("The history plugin is not loaded or initialized.")}updatePosition(t,e,n,r=!1,i,o){const a=Re(e)?e:[e],{graphCore:s}=this.dataController,{specification:l}=this.themeController;s.once("changed",(o=>{if(!o.changes.length)return;const a=o.changes.filter((t=>!un(t.newValue,t.oldValue))),c={type:t,action:"updatePosition",upsertAncestors:n,models:e,apiName:"updatePosition",changes:a};this.emit("beforeitemchange",c),this.hooks.itemchange.emit({type:t,changes:o.changes,graphCore:s,theme:l,upsertAncestors:n,action:"updatePosition",animate:!r,callback:i}),this.emit("afteritemchange",c)})),this.hooks.datachange.emit({data:{nodes:"node"===t?a:[],edges:[],combos:"combo"===t?a:[]},type:"update"});const c=this.dataController.findData(t,a.map((t=>t.id)));return Re(e)?c:c[0]}getItemPreviousVisibility(t){const e=t.map((t=>({id:t,visible:this.getItemVisible(t)}))),n=Le(e,"visible"),r=[];for(const t in n)r.push({ids:hn(n[t],(t=>t.id)),visible:"true"===t});return r}showItem(t,e=!1){const n=Re(t)?t:[t];if(ln(n))return;const r={newValue:[{ids:n,visible:!0}],oldValue:this.getItemPreviousVisibility(n)};this.hooks.itemvisibilitychange.emit({ids:n,value:!0,graphCore:this.dataController.graphCore,animate:!e}),this.emit("afteritemvisibilitychange",{ids:t,value:!0,animate:!e,action:"updateVisibility",apiName:"showItem",changes:r})}hideItem(t,e=!1,n=!1){const r=Re(t)?t:[t];if(ln(r))return;const i={newValue:[{ids:r,visible:!1}],oldValue:this.getItemPreviousVisibility(r)};this.hooks.itemvisibilitychange.emit({ids:r,value:!1,graphCore:this.dataController.graphCore,animate:!e,keepKeyShape:n}),this.emit("afteritemvisibilitychange",{ids:t,value:!1,animate:!e,action:"updateVisibility",apiName:"hideItem",keepKeyShape:n,changes:i})}frontItem(t){const e=Re(t)?t:[t];this.hooks.itemzindexchange.emit({ids:e,action:"front",graphCore:this.dataController.graphCore}),this.emit("afteritemzindexchange",{ids:e,action:"front",apiName:"frontItem"})}backItem(t){const e=Re(t)?t:[t];this.hooks.itemzindexchange.emit({ids:e,action:"back",graphCore:this.dataController.graphCore}),this.emit("afteritemzindexchange",{ids:e,action:"back",apiName:"backItem"})}getItemPreviousStates(t){const{ids:e,states:n}=t,r=Array.isArray(e)?e:[e],i=Array.isArray(n)?n:[n];if(!ln(r))return r.flatMap((t=>i.map((e=>({ids:t,states:e,value:this.getItemState(t,e)})))))}setItemState(t,e,n){const r=Re(t)?t:[t],i=Re(e)?e:[e],o={ids:r,states:i,value:n},a={newValue:[o],oldValue:this.getItemPreviousStates(o)};this.hooks.itemstatechange.emit({ids:r,states:i,value:n}),this.emit("afteritemstatechange",{ids:t,states:e,value:n,action:"updateState",apiName:"setItemState",changes:a})}getItemState(t,e){return this.itemController.getItemState(t,e)}getItemAllStates(t){return this.itemController.getItemAllStates(t)}clearItemState(t,e){const n=Re(t)?t:[t],r={ids:n,states:e,value:!1},i={newValue:[r],oldValue:this.getItemPreviousStates(r)};this.hooks.itemstatechange.emit({ids:n,states:e,value:!1}),this.emit("afteritemstatechange",{ids:t,states:e,value:!1,action:"updateState",apiName:"clearItemState",changes:i})}getRenderBBox(t,e=!1,n=!1){return t?this.itemController.getItemBBox(t,e,n):this.canvas.getRoot().getRenderBounds()}getItemVisible(t){return this.itemController.getItemVisible(t)}addCombo(t,e){const{graphCore:n}=this.dataController,{specification:r}=this.themeController;n.once("changed",(e=>{if(!e.changes.length)return;const i=e.changes,o={type:"combo",action:"add",models:[t],apiName:"addCombo",changes:i};this.emit("beforeitemchange",o),this.hooks.itemchange.emit({type:"combo",changes:n.reduceChanges(e.changes),graphCore:n,theme:r}),this.emit("afteritemchange",o)}));const i={nodes:[],edges:[],combos:[Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{_children:e})})]};return this.hooks.datachange.emit({data:i,type:"addCombo"}),this.dataController.findData("combo",[t.id])[0]}collapseCombo(t){const e=Re(t)?t:[t];this.executeWithNoStack((()=>{this.updateData("combo",e.map((t=>({id:t,data:{collapsed:!0}}))))})),this.emit("aftercollapsecombo",{type:"combo",action:"collapseCombo",ids:t,apiName:"collapseCombo"})}expandCombo(t){const e=Re(t)?t:[t];this.executeWithNoStack((()=>{this.updateData("combo",e.map((t=>({id:t,data:{collapsed:!1}}))))})),this.emit("afterexpandcombo",{type:"combo",action:"expandCombo",ids:t,apiName:"expandCombo"})}moveCombo(t,e,n,r,i){const o=Re(t)?t:[t],{graphCore:a}=this.dataController,{specification:s}=this.themeController;return a.once("changed",(t=>{if(!t.changes.length)return;const l=this.extendChanges(tn(t.changes)),c={type:"combo",ids:o,dx:e,dy:n,action:"updatePosition",upsertAncestors:r,apiName:"moveCombo",changes:l};this.emit("beforeitemchange",c),this.hooks.itemchange.emit({type:"combo",changes:t.changes,graphCore:a,theme:s,upsertAncestors:r,action:"updatePosition",callback:i}),this.emit("afteritemchange",c)})),this.hooks.datachange.emit({data:{nodes:[],edges:[],combos:o.map((t=>({id:t,data:{dx:e,dy:n}})))},type:"moveCombo"}),this.dataController.findData("combo",o)}layout(t,e=!1){return Oc(this,void 0,void 0,(function*(){this.emit("beforelayout");const{graphCore:n}=this.dataController,r=Object.assign(Object.assign({},this.getSpecification().layout),t);this.updateSpecification({layout:r});if(!t&&!this.getSpecification().layout||!Object.keys(r).length){n.getAllNodes().every((t=>xe(t.data.x)&&xe(t.data.y)))?r.type="grid":r.execute=t=>Oc(this,void 0,void 0,(function*(){return{nodes:t.getAllNodes().map((t=>({id:t.id,data:{x:Number(t.data.x)||0,y:Number(t.data.y)||0}}))),edges:[]}}))}yield this.hooks.layout.emitLinearAsync({graphCore:n,options:r,animate:!e}),this.emit("afterlayout")}))}stopLayout(){this.layoutController.stopLayout()}getLayoutCurrentAnimation(){return this.layoutController.getCurrentAnimation()}setMode(t){this.hooks.modechange.emit({mode:t})}getMode(){return this.interactionController.getMode()}setCursor(t){this.canvas.setCursor(t),this.transientCanvas.setCursor(t)}addBehaviors(t,e){const n=Re(e)?e:[e],r=Re(t)?t:[t];this.hooks.behaviorchange.emit({action:"add",modes:n,behaviors:r}),n.forEach((t=>{this.specification.modes[t]=this.specification.modes[t].concat(r)}))}removeBehaviors(t,e){const n=Re(e)?e:[e];this.hooks.behaviorchange.emit({action:"remove",modes:n,behaviors:t}),n.forEach((e=>{t.forEach((t=>{const n=this.specification.modes[e].find((e=>Me(e)&&e.key===t)),r=this.specification.modes[e].indexOf(n);this.specification.modes[e].splice(r,1)}))}))}updateBehavior(t,e){this.hooks.behaviorchange.emit({action:"update",modes:[e],behaviors:[t]})}addPlugins(t){const e=Re(t)?t:[t];this.specification.plugins||(this.specification.plugins=[]);const n=this.specification.plugins,r=[];e.forEach((t=>{n.find((e=>"string"!=typeof e&&"string"!=typeof t&&e.key===t.key))?console.warn(`Add plugin with key ${t.key} failed, the key is duplicated to the existing plugins on the graph.`):r.push(t)})),this.specification.plugins=n.concat(r),this.hooks.pluginchange.emit({action:"add",plugins:r})}removePlugins(t){const e=Re(t)?t:[t];this.hooks.pluginchange.emit({action:"remove",plugins:e});const{plugins:n}=this.specification;this.specification.plugins=null==n?void 0:n.filter((t=>Me(t)?!(e.includes(t.key)||e.includes(t)):!e.includes(t)))}updatePlugin(t){const{plugins:e}=this.specification,{key:n}=t;if(!n)return void console.warn("Update plugin failed, the key for the plugin to be updated should be assign.");if(!e)return void console.warn("Update plugin failed, the plugin to be updated does not exist.");const r=null==e?void 0:e.find((t=>"string"==typeof t?t===n:t.key===n));if(!r)return void console.warn("Update plugin failed, the key for the plugin to be updated should be assign.");const i=e.indexOf(r);e[i]=Object.assign(Object.assign({},r),t),this.hooks.pluginchange.emit({action:"update",plugins:[t]})}drawTransient(t,e,n,r){return this.hooks.transientupdate.emit({type:t,id:e,config:n,canvas:r||this.transientCanvas,graphCore:this.dataController.graphCore}),this.itemController.getTransient(String(e))}toDataURL(t){return Oc(this,void 0,void 0,(function*(){const e=this.backgroundCanvas,n=this.canvas,r=this.transientCanvas,i=this.rendererType,o="undefined"!=typeof window?window.devicePixelRatio:1,a=this.getSize()[0],s=this.getSize()[1],l=yP('<div id="virtual-image"></div>'),c=fR(i,l,a,s,o),u=c.getContextService();let h;"svg"!==i&&(h=new nl({style:{x:0,y:0,z:-1,width:u.getDomElement().width,height:u.getDomElement().height,fill:e.getContextService().getDomElement().style["background-color"]}}),c.appendChild(h));const d=e.getRoot().cloneNode(!0),p=n.getRoot().cloneNode(!0),f=r.getRoot().cloneNode(!0);c.appendChild(d),c.appendChild(p),c.appendChild(f),c.render(),t||(t="image/png");let g="";return yield u.toDataURL({type:t}).then((t=>{g=t})),g}))}toFullDataURL(t,e){return Oc(this,void 0,void 0,(function*(){const n=this.backgroundCanvas,r=this.canvas,i=this.transientCanvas,o=r.getRoot(),a=r.getRoot(),s=i.getRoot(),l=this.rendererType,c=o.getBBox(),u=a.getBBox(),h=s.getBBox();let d=e?e.padding:void 0;d?Ue(d)&&(d=[d,d,d,d]):d=[0,0,0,0];const p=(h.left?c.left?Math.min(c.left,u.left,h.left):Math.min(u.left,h.left):u.left)-d[3],f=(h.right?c.right?Math.max(c.right,u.right,h.right):Math.max(u.right,h.right):u.right)+d[1],g=(h.top?c.top?Math.min(c.top,u.top,h.top):Math.min(u.top,h.top):u.top)-d[0],m=(h.bottom?c.bottom?Math.max(c.bottom,u.bottom,h.bottom):Math.max(u.bottom,h.bottom):u.bottom)+d[2],v=(p+f)/2,y=(g+m)/2,E=(f-p)/2,_=(m-g)/2,b="undefined"!=typeof window?window.devicePixelRatio:1,S=2*E,x=2*_,T=yP('<div id="virtual-image"></div>'),A=fR(l,T,S,x,b),R=A.getContextService();if("svg"!==l){const t=new nl({style:{x:0,y:0,z:-1,width:R.getDomElement().width,height:R.getDomElement().height,fill:n.getContextService().getDomElement().style["background-color"]}});A.appendChild(t)}const M=o.cloneNode(!0),C=a.cloneNode(!0),P=s.cloneNode(!0),w=[-v+E,-y+_];M.setPosition(w),C.setPosition(w),P.setPosition(w),A.appendChild(M),A.appendChild(C),A.appendChild(P),A.render(),t||(t="image/png");let N="";return yield R.toDataURL({type:t}).then((t=>{N=t})),N}))}dataURLToImage(t,e,n,r){if(t&&"data:"!==t){if("undefined"!=typeof window)if(window.Blob&&window.URL&&"svg"!==e){const e=t.split(",");let i="";if(e&&e.length>0){const t=e[0].match(/:(.*?);/);t&&t.length>=2&&(i=t[1])}const o=atob(e[1]);let a=o.length;const s=new Uint8Array(a);for(;a--;)s[a]=o.charCodeAt(a);const l=new Blob([s],{type:i});window.navigator.msSaveBlob?window.navigator.msSaveBlob(l,r):n.addEventListener("click",(()=>{n.download=r,n.href=window.URL.createObjectURL(l)}))}else n.addEventListener("click",(()=>{n.download=r,n.href=t}))}else console.error("Download image failed. The graph is too large or there is invalid attribute values in graph items")}downloadImage(t,e){const n=this.rendererType;e||(e="image/png");const r=(t||"graph")+("svg"===n?".svg":e.split("/")[1]),i=document.createElement("a");this.asyncToDataUrl(e,(t=>{this.dataURLToImage(t,n,i,r);const e=document.createEvent("MouseEvents");e.initEvent("click",!1,!1),i.dispatchEvent(e)}))}downloadFullImage(t,e,n){const r=this.rendererType;e||(e="image/png");const i=(t||"graph")+("svg"===r?".svg":e.split("/")[1]),o=document.createElement("a");this.asyncToFullDataUrl(e,n,(t=>{this.dataURLToImage(t,r,o,i);const e=document.createEvent("MouseEvents");e.initEvent("click",!1,!1),o.dispatchEvent(e)}))}asyncToDataUrl(t,e){let n="";t||(t="image/png"),setTimeout((()=>Oc(this,void 0,void 0,(function*(){yield this.toDataURL(t).then((t=>{n=t})),e&&e(n)}))),16)}asyncToFullDataUrl(t,e,n){let r="";t||(t="image/png"),setTimeout((()=>Oc(this,void 0,void 0,(function*(){yield this.toFullDataURL(t,e).then((t=>{r=t})),n&&n(r)}))),16)}isHistoryEnabled(){const t=this.getHistoryPlugin();return null==t?void 0:t.isEnable()}pushStack(t,e,n){const r=this.getHistoryPlugin();return null==r?void 0:r.push(t,e,n)}pauseStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.pauseStack()}resumeStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.resumeStack()}getUndoStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.getUndoStack()}getRedoStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.getRedoStack()}getStack(){const t=this.getHistoryPlugin();return null==t?void 0:t.getStack()}undo(){const t=this.getHistoryPlugin();null==t||t.undo()}redo(){const t=this.getHistoryPlugin();null==t||t.redo()}canUndo(){const t=this.getHistoryPlugin();return null==t?void 0:t.canUndo()}canRedo(){const t=this.getHistoryPlugin();return null==t?void 0:t.canRedo()}startHistoryBatch(){const t=this.getHistoryPlugin();null==t||t.startHistoryBatch()}stopHistoryBatch(){const t=this.getHistoryPlugin();null==t||t.stopHistoryBatch()}historyBatch(t){const e=this.getHistoryPlugin();null==e||e.historyBatch(t)}cleanHistory(t){const e=this.getHistoryPlugin();return t?"undo"===t?null==e?void 0:e.clearUndoStack():null==e?void 0:e.clearRedoStack():null==e?void 0:e.clear()}collapse(t,e=!1,n){this.hooks.treecollapseexpand.emit({ids:Re(t)?t:[t],action:"collapse",animate:!e,graphCore:this.dataController.graphCore})}expand(t,e=!1,n){this.hooks.treecollapseexpand.emit({ids:Re(t)?t:[t],action:"expand",animate:!e,graphCore:this.dataController.graphCore})}destroy(t){this.canvas.destroy(),this.backgroundCanvas.destroy(),this.transientCanvas.destroy(),this.cleanHistory(),null==t||t(),this.hooks.destroy.emit({}),this.destroyed=!0}},ZH);var Uj={Graph:Fj,Util:kj,stdLib:ZH,Extensions:tj,extend:Nj,version:Lj};t.Extensions=tj,t.Graph=Fj,t.PluginBase=zD,t.Util=kj,t.default=Uj,t.extend=Nj,t.isImmediatelyInvokedLayoutOptions=Sj,t.isLayoutWorkerized=xj,t.stdLib=ZH,t.version=Lj,Object.defineProperty(t,"__esModule",{value:!0})}));