@antv/g6 5.1.0 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g6.min.js +4 -4
- package/dist/lib/transforms/process-parallel-edges.d.ts +18 -0
- package/dist/lib/types/edge.d.ts +11 -0
- package/dist/lib/utils/edge.d.ts +16 -1
- package/dist/lib/version.d.ts +1 -1
- package/esm/elements/edges/base-edge.js +10 -4
- package/esm/elements/edges/base-edge.js.map +1 -1
- package/esm/transforms/process-parallel-edges.d.ts +18 -0
- package/esm/transforms/process-parallel-edges.js +29 -5
- package/esm/transforms/process-parallel-edges.js.map +1 -1
- package/esm/types/edge.d.ts +11 -0
- package/esm/utils/edge.d.ts +16 -1
- package/esm/utils/edge.js +110 -4
- package/esm/utils/edge.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/elements/edges/base-edge.js +9 -3
- package/lib/elements/edges/base-edge.js.map +1 -1
- package/lib/transforms/process-parallel-edges.d.ts +18 -0
- package/lib/transforms/process-parallel-edges.js +29 -5
- package/lib/transforms/process-parallel-edges.js.map +1 -1
- package/lib/types/edge.d.ts +11 -0
- package/lib/utils/edge.d.ts +16 -1
- package/lib/utils/edge.js +111 -4
- package/lib/utils/edge.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/elements/edges/base-edge.ts +23 -2
- package/src/transforms/process-parallel-edges.ts +47 -3
- package/src/types/edge.ts +11 -0
- package/src/utils/edge.ts +131 -3
- package/src/version.ts +1 -1
package/dist/g6.min.js
CHANGED
|
@@ -44,7 +44,7 @@ var _c=function(t,e){return _c=Object.setPrototypeOf||{__proto__:[]}instanceof A
|
|
|
44
44
|
* @date 12/24/2025, 11:55:39 AM
|
|
45
45
|
* @author AntVis
|
|
46
46
|
* @docs https://g.antv.antgroup.com/
|
|
47
|
-
*/var mp=function(t){function e(t,n,r,i){var o;return A(this,e),(o=g(this,e,[t])).currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return v(e,t),a(e)}(Gs),yp=0,wp=function(){return a(function t(e,n){var r;A(this,t),this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=e,e.animation=this,this.timeline=n,this.id="".concat(yp++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(r=this.effect)||void 0===r?void 0:r.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()},[{key:"pending",get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending}},{key:"playState",get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"}},{key:"ready",get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise(function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}}),this.pending||this.resolveReadyPromise()),this.readyPromise}},{key:"finished",get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise(function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}}),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise}},{key:"currentTime",get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){if(t=Number(t),!isNaN(t)){var e;if(this.timeline.restart(),!this._paused&&null!==this._startTime)this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate;this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this))}}},{key:"startTime",get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}}},{key:"_isFinished",get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)}},{key:"totalDuration",get:function(){return this._totalDuration}},{key:"_needsTick",get:function(){return this.pending||"running"===this.playState||!this._finishedFlag}},{key:"updatePromises",value:function(){var t;if(null!==(t=this.effect.target)&&void 0!==t&&t.destroyed)return this.readyPromise=void 0,this.finishedPromise=void 0,!1;var e=this.oldPlayState,n=this.pending?"pending":this.playState;return this.readyPromise&&n!==e&&("idle"===n?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===e?this.resolveReadyPromise():"pending"===n&&(this.readyPromise=void 0)),this.finishedPromise&&n!==e&&("idle"===n?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===n?this.resolveFinishedPromise():"finished"===e&&(this.finishedPromise=void 0)),this.oldPlayState=n,this.readyPromise||this.finishedPromise}},{key:"play",value:function(){this.updatePromises(),this._paused=!1,(this._isFinished||this._idle)&&(this.rewind(),this._startTime=null),this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this),-1===this.timeline.animations.indexOf(this)&&this.timeline.animations.push(this),this.updatePromises()}},{key:"pause",value:function(){this.updatePromises(),this.currentTime&&(this._holdTime=this.currentTime),this._isFinished||this._paused||this._idle?this._idle&&(this.rewind(),this._idle=!1):this.currentTimePending=!0,this._startTime=null,this._paused=!0,this.updatePromises()}},{key:"finish",value:function(){this.updatePromises(),this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this.currentTimePending=!1,this.timeline.applyDirtiedAnimation(this),this.updatePromises())}},{key:"cancel",value:function(){var t=this;if(this.updatePromises(),this._inEffect&&(this._inEffect=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=null,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new mp(null,this,this.currentTime,null);setTimeout(function(){t.oncancel(e)})}}},{key:"reverse",value:function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()}},{key:"updatePlaybackRate",value:function(t){this.playbackRate=t}},{key:"targetAnimations",value:function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()}},{key:"markTarget",value:function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)}},{key:"unmarkTarget",value:function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)}},{key:"tick",value:function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))}},{key:"rewind",value:function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}}},{key:"persist",value:function(){throw new Error(Cr)}},{key:"addEventListener",value:function(t,e,n){throw new Error(Cr)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(Cr)}},{key:"dispatchEvent",value:function(t){throw new Error(Cr)}},{key:"commitStyles",value:function(){throw new Error(Cr)}},{key:"ensureAlive",value:function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!(null===(t=this.effect)||void 0===t||!t.update(-1)):this._inEffect=!(null===(e=this.effect)||void 0===e||!e.update(this.currentTime));this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))}},{key:"tickCurrentTime",value:function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())}},{key:"fireEvents",value:function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new mp(null,this,this.currentTime,t);setTimeout(function(){e.onfinish&&e.onfinish(n)})}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new mp(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),bp=.1,Bp="function"==typeof Float32Array,Ep=function(t,e){return 1-3*e+3*t},xp=function(t,e){return 3*e-6*t},Cp=function(t){return 3*t},Mp=function(t,e,n){return((Ep(e,n)*t+xp(e,n))*t+Cp(e))*t},Fp=function(t,e,n){return 3*Ep(e,n)*t*t+2*xp(e,n)*t+Cp(e)},kp=function(t,e,n,r){if(!(t>=0&&t<=1&&n>=0&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=Bp?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Mp(o*bp,t,n);var A=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=bp;--o;var A=r+(e-i[o])/(i[o+1]-i[o])*bp,s=Fp(A,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=Fp(e,n,r);if(0===o)return e;e-=(Mp(e,n,r)-t)/o}return e}(e,A,t,n):0===s?A:function(t,e,n,r,i){var o,A,s=0;do{(o=Mp(A=e+(n-e)/2,r,i)-t)>0?n=A:e=A}while(Math.abs(o)>1e-7&&++s<10);return A}(e,r,r+bp,t,n)};return function(t){return 0===t||1===t?t:Mp(A(t),e,r)}},Sp=function(t){return Math.pow(t,2)},Qp=function(t){return Math.pow(t,3)},Up=function(t){return Math.pow(t,4)},Np=function(t){return Math.pow(t,5)},Tp=function(t){return Math.pow(t,6)},Op=function(t){return 1-Math.cos(t*Math.PI/2)},Ip=function(t){return 1-Math.sqrt(1-t*t)},Lp=function(t){return t*t*(3*t-2)},Pp=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},Dp=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?1:n,i=e[1],o=void 0===i?.5:i,A=ne(Number(r),1,10),s=ne(Number(o),.1,2);return 0===t||1===t?t:-A*Math.pow(2,10*(t-1))*Math.sin((t-1-s/(2*Math.PI)*Math.asin(1/A))*(2*Math.PI)/s)},Rp=function(t){var e=arguments.length>2?arguments[2]:void 0,n=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),r=n[0],i=void 0===r?1:r,o=n[1],A=void 0===o?100:o,s=n[2],a=void 0===s?10:s,c=n[3],l=void 0===c?0:c;i=ne(i,.1,1e3),A=ne(A,.1,1e3),a=ne(a,.1,1e3),l=ne(l,.1,1e3);var u=Math.sqrt(A/i),h=a/(2*Math.sqrt(A*i)),d=h<1?u*Math.sqrt(1-h*h):0,f=h<1?(h*u-l)/d:-l+u,g=e?e*t/1e3:t;return g=h<1?Math.exp(-g*h*u)*(1*Math.cos(d*g)+f*Math.sin(d*g)):(1+f*g)*Math.exp(-g*u),0===t||1===t?t:1-g},Hp=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?10:n;return("start"===e[1]?Math.ceil:Math.floor)(ne(t,0,1)*r)/r},_p=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return kp(n,r,i,o)(t)},Gp=kp(.42,0,1,1),Kp=function(t){return function(e){return 1-t(1-e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],arguments.length>2?arguments[2]:void 0)}},jp=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},zp=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Vp={steps:Hp,"step-start":function(t){return Hp(t,[1,"start"])},"step-end":function(t){return Hp(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":_p,ease:function(t){return _p(t,[.25,.1,.25,1])},in:Gp,out:Kp(Gp),"in-out":jp(Gp),"out-in":zp(Gp),"in-quad":Sp,"out-quad":Kp(Sp),"in-out-quad":jp(Sp),"out-in-quad":zp(Sp),"in-cubic":Qp,"out-cubic":Kp(Qp),"in-out-cubic":jp(Qp),"out-in-cubic":zp(Qp),"in-quart":Up,"out-quart":Kp(Up),"in-out-quart":jp(Up),"out-in-quart":zp(Up),"in-quint":Np,"out-quint":Kp(Np),"in-out-quint":jp(Np),"out-in-quint":zp(Np),"in-expo":Tp,"out-expo":Kp(Tp),"in-out-expo":jp(Tp),"out-in-expo":zp(Tp),"in-sine":Op,"out-sine":Kp(Op),"in-out-sine":jp(Op),"out-in-sine":zp(Op),"in-circ":Ip,"out-circ":Kp(Ip),"in-out-circ":jp(Ip),"out-in-circ":zp(Ip),"in-back":Lp,"out-back":Kp(Lp),"in-out-back":jp(Lp),"out-in-back":zp(Lp),"in-bounce":Pp,"out-bounce":Kp(Pp),"in-out-bounce":jp(Pp),"out-in-bounce":zp(Pp),"in-elastic":Dp,"out-elastic":Kp(Dp),"in-out-elastic":jp(Dp),"out-in-elastic":zp(Dp),spring:Rp,"spring-in":Rp,"spring-out":Kp(Rp),"spring-in-out":jp(Rp),"spring-out-in":zp(Rp)},Wp=function(t){return t};function Yp(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Xp="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",qp=new RegExp("cubic-bezier\\(".concat(Xp,",").concat(Xp,",").concat(Xp,",").concat(Xp,"\\)")),$p=/steps\(\s*(\d+)\s*\)/,Zp=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Jp(t){var e=qp.exec(t);if(e)return kp.apply(void 0,u(e.slice(1).map(Number)));var n=$p.exec(t);if(n)return Yp(Number(n[1]),0);var r=Zp.exec(t);return r?Yp(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Vp[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,function(t){return"-".concat(t.toLowerCase())})).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||Vp.linear}function tv(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}function ev(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e<Math.min(n.delay,r)?1:e>=Math.min(n.delay+t+n.endDelay,r)?2:3}(t,e,n),i=function(t,e,n,r,i){switch(r){case 1:return"backwards"===e||"both"===e?0:null;case 3:return n-i;case 2:return"forwards"===e||"both"===e?t:null;case 0:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,A=function(t,e,n,r,i){var o=i;return 0===t?1!==e&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var A=t===1/0?e%1:t%1;return 0!==A||2!==n||0===r||0===i&&0!==o||(A=1),A}(A,n.iterationStart,r,n.iterations,i,o),a=function(t,e,n,r){return 2===t&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,A),c=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,a,s);return n.currentIteration=a,n.progress=c,n.easingFunction(c)}function nv(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(rv(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:Jp(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var A=o,s=o+1,a=i[A].computedOffset,c=i[s].computedOffset,l=a,u=c;0===o&&(l=-1/0,0===c&&(s=A)),o===i.length-2&&(u=1/0,1===a&&(A=s)),n.push({applyFrom:l,applyTo:u,startOffset:i[A].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[A].easingFunction,property:r,interpolation:ov(r,i[A].value,i[s].value,e)})}return n.sort(function(t,e){return t.startOffset-e.startOffset}),n}(r,n);return function(t,e){if(null!==e)i.filter(function(t){return e>=t.applyFrom&&e<t.applyTo}).forEach(function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)});else for(var n in r)rv(n)&&t.setAttribute(n,null)}}function rv(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var iv=function(t,e,n){return function(r){var i=Av(t,e,r);return re(i)?i:n(i)}};function ov(t,e,n,r){var i=MA[t];if(i&&i.syntax&&i.int){var o=Ua.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var A=o.parser,s=A?A(e,r):e,a=A?A(n,r):n,c=o.mixer(s,a,r);if(c){var l=iv.apply(void 0,u(c));return function(t){return 0===t?e:1===t?n:l(t)}}}}return iv(!1,!0,function(t){return t?n:e})}function Av(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),A=[],s=0;s<o;s++)A.push(Av(t[s<r?s:r-1],e[s<i?s:i-1],n));return A}throw new Error("Mismatched interpolation arguments ".concat(t,":").concat(e))}var sv=function(){return a(function t(){A(this,t),this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Wp,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null},[{key:"easing",get:function(){return this._easing},set:function(t){this.easingFunction=Jp(t),this._easing=t}}])}();function av(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var A={};"offset"in t&&(A.offset=Number(t.offset)),"easing"in t&&(A.easing=t.easing),"composite"in t&&(A.composite=t.composite),e[o]=A}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort(function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)}),e}(t));for(var n=t.map(function(t){var n={};for(var r in null!=e&&e.composite&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n}),r=!0,i=-1/0,o=0;o<n.length;o++){var A=n[o].offset;if(Kt(A))r=!1;else{if(A<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=A}}return n=n.filter(function(t){return Number(t.offset)>=0&&Number(t.offset)<=1}),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),A=1;A<r;A++){var s=n[A].computedOffset;if(!Kt(s)&&!Kt(o)){for(var a=1;a<A-i;a++)n[i+a].computedOffset=o+(Number(s)-o)*a/(A-i);i=A,o=Number(s)}}}(),n}var cv="backwards|forwards|both|none".split("|"),lv="reverse|alternate|alternate-reverse".split("|");function uv(t,e){return function(t){var e=new sv;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach(function(n){if(void 0!==t[n]&&null!==t[n]&&"auto"!==t[n]){if(("number"==typeof e[n]||"duration"===n)&&("number"!=typeof t[n]||isNaN(t[n])))return;if("fill"===n&&-1===cv.indexOf(t[n]))return;if("direction"===n&&-1===lv.indexOf(t[n]))return;e[n]=t[n]}}):e.duration=t,e}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}))}var hv=function(){return a(function t(e,n,r){var i=this;A(this,t),this.composite="replace",this.iterationComposite="replace",this.target=e,this.timing=uv(r),this.timing.effect=this,this.timing.activeDuration=tv(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=av(n,this.timing),this.interpolations=nv(this.normalizedKeyframes,this.timing,this.target);var o=Ua.globalThis.Proxy;this.computedTiming=o?new o(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?i.animation&&i.animation.currentTime||null:"currentIteration"===e?i.animation&&"running"===i.animation.playState?t.currentIteration||0:null:"progress"===e?i.animation&&"running"===i.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing},[{key:"applyInterpolations",value:function(){this.interpolations(this.target,Number(this.timeFraction))}},{key:"update",value:function(t){return null!==t&&(this.timeFraction=ev(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)}},{key:"getKeyframes",value:function(){return this.normalizedKeyframes}},{key:"setKeyframes",value:function(t){this.normalizedKeyframes=av(t)}},{key:"getComputedTiming",value:function(){return this.computedTiming}},{key:"getTiming",value:function(){return this.timing}},{key:"updateTiming",value:function(t){var e=this;Object.keys(t||{}).forEach(function(n){e.timing[n]=t[n]})}}])}();function dv(t,e){return Number(t.id)-Number(e.id)}var fv=function(){return a(function t(e){var n=this;A(this,t),this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){n.currentTime=t,n.discardAnimations(),0===n.animations.length?n.timelineTicking=!1:n.requestAnimationFrame(n.webAnimationsNextTick)},this.processRafCallbacks=function(t){var e=n.rafCallbacks;n.rafCallbacks=[],t<Number(n.currentTime)&&(t=Number(n.currentTime)),n.animations.sort(dv),n.animations=n.tick(t,!0,n.animations)[0],e.forEach(function(e){e[1](t)}),n.applyPendingEffects()},this.document=e},[{key:"getAnimations",value:function(){return this.discardAnimations(),this.animations.slice()}},{key:"isTicking",value:function(){return this.inTick}},{key:"play",value:function(t,e,n){var r=new hv(t,e,n),i=new wp(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i}},{key:"applyDirtiedAnimation",value:function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(dv),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach(function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)}),this.applyPendingEffects()}}},{key:"restart",value:function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame(function(){}),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame}},{key:"destroy",value:function(){this.document.defaultView.cancelAnimationFrame(this.frameId)}},{key:"applyPendingEffects",value:function(){this.pendingEffects.forEach(function(t){null==t||t.applyInterpolations()}),this.pendingEffects=[]}},{key:"updateAnimationsPromises",value:function(){this.animationsWithPromises=this.animationsWithPromises.filter(function(t){return t.updatePromises()})}},{key:"discardAnimations",value:function(){this.updateAnimationsPromises(),this.animations=this.animations.filter(function(t){return"finished"!==t.playState&&"idle"!==t.playState})}},{key:"restartWebAnimationsNextTick",value:function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))}},{key:"rAF",value:function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e}},{key:"requestAnimationFrame",value:function(t){var e=this;return this.rAF(function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()})}},{key:"tick",value:function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var A=[],s=[],a=[],c=[];return n.forEach(function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(A.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?a.push(n):c.push(n)}),(r=this.pendingEffects).push.apply(r,A),(i=this.pendingEffects).push.apply(i,s),this.ticking&&this.requestAnimationFrame(function(){}),this.inTick=!1,[a,c]}}])}();Ua.EasingFunction=Jp,Ua.AnimationTimeline=fv;var gv=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=g(this,e,[].concat(r))).landmarks=[],t}return v(e,t),a(e,[{key:"rotate",value:function(t,e,n){if(this.relElevation=Fr(e),this.relAzimuth=Fr(t),this.relRoll=Fr(n),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===jr.EXPLORING){var r=Qt(St(),[1,0,0],Ur((this.rotateWorld?1:-1)*this.relElevation)),i=Qt(St(),[0,1,0],Ur((this.rotateWorld?1:-1)*this.relAzimuth)),o=Qt(St(),[0,0,1],Ur(this.relRoll)),A=Ut(St(),i,r);A=Ut(St(),A,o);var s=q(C(),A);I(this.matrix,this.matrix,[0,0,-this.distance]),O(this.matrix,this.matrix,s),I(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===jr.ORBITING||this.type===jr.EXPLORING?this._getPosition():this.type===jr.TRACKING&&this._getFocalPoint(),this._update(),this}},{key:"pan",value:function(t,e){var n=Sr(t,e,0),r=ct(this.position);return ft(r,r,pt(at(),this.right,n[0])),ft(r,r,pt(at(),this.up,n[1])),this._setPosition(r),this.triggerUpdate(),this}},{key:"dolly",value:function(t){var e=this.forward,n=ct(this.position),r=this.dollyingStep,i=this.distance+t*this.dollyingStep;return r=Math.max(Math.min(i,this.maxDistance),this.minDistance)-this.distance,n[0]+=r*e[0],n[1]+=r*e[1],n[2]+=r*e[2],this._setPosition(n),this.type===jr.ORBITING||this.type===jr.EXPLORING?this._getDistance():this.type===jr.TRACKING&&ft(this.focalPoint,n,this.distanceVector),this.triggerUpdate(),this}},{key:"cancelLandmarkAnimation",value:function(){void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID)}},{key:"createLandmark",value:function(t){var e,n,r,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},A=o.position,s=void 0===A?this.position:A,a=o.focalPoint,c=void 0===a?this.focalPoint:a,l=o.roll,u=o.zoom,h=new Ua.CameraContribution;h.setType(this.type,void 0),h.setPosition(s[0],null!==(e=s[1])&&void 0!==e?e:this.position[1],null!==(n=s[2])&&void 0!==n?n:this.position[2]),h.setFocalPoint(c[0],null!==(r=c[1])&&void 0!==r?r:this.focalPoint[1],null!==(i=c[2])&&void 0!==i?i:this.focalPoint[2]),h.setRoll(null!=l?l:this.roll),h.setZoom(null!=u?u:this.zoom);var d={name:t,matrix:M(h.getWorldTransform()),right:ct(h.right),up:ct(h.up),forward:ct(h.forward),position:ct(h.getPosition()),focalPoint:ct(h.getFocalPoint()),distanceVector:ct(h.getDistanceVector()),distance:h.getDistance(),dollyingStep:h.getDollyingStep(),azimuth:h.getAzimuth(),elevation:h.getElevation(),roll:h.getRoll(),relAzimuth:h.relAzimuth,relElevation:h.relElevation,relRoll:h.relRoll,zoom:h.getZoom()};return this.landmarks.push(d),d}},{key:"gotoLandmark",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Jt(t)?this.landmarks.find(function(e){return e.name===t}):t;if(r){var i=re(n)?{duration:n}:n,o=i.easing,A=void 0===o?"linear":o,s=i.duration,a=void 0===s?100:s,c=i.easingFunction,l=void 0===c?void 0:c,u=i.onfinish,h=void 0===u?void 0:u,d=i.onframe,f=void 0===d?void 0:d;this.cancelLandmarkAnimation();var g,p=r.position,v=r.focalPoint,m=r.zoom,y=r.roll,w=l||Ua.EasingFunction(A),b=function(){e.setFocalPoint(v),e.setPosition(p),e.setRoll(y),e.setZoom(m),e.computeMatrix(),e.triggerUpdate(),null==h||h()};if(0===a)return b();var B=function(t){void 0===g&&(g=t);var n=t-g;if(n>=a)b();else{var r,i,o=w(n/a),A=at(),s=at();if(wt(A,e.focalPoint,v,o),wt(s,e.position,p,o),i=e.roll*(1-o)+y*o,r=e.zoom*(1-o)+m*o,e.setFocalPoint(A),e.setPosition(s),e.setRoll(i),e.setZoom(r),xt(A,v)+xt(s,p)<=.01&&void 0===m&&void 0===y)return b();e.computeMatrix(),e.triggerUpdate(),n<a&&(null==f||f(o),e.landmarkAnimationID=e.canvas.requestAnimationFrame(B))}};this.canvas.requestAnimationFrame(B)}}}])}(Xr);Ua.CameraContribution=gv;var pv=["body","startHead","endHead","startHeadOffset","endHeadOffset"],vv=["body","startHead","endHead","startHeadOffset","endHeadOffset"],mv=["body","startHead","endHead","startHeadOffset","endHeadOffset"],yv=function(t){function e(t){var n;A(this,e);var r=(n=g(this,e,[o(o({},t),{},{type:e.tag})])).attributes,i=r.body,s=r.startHead,a=r.endHead;r.startHeadOffset,r.endHeadOffset;var c=ar(r,pv);if(!i)throw new Error("Arrow's body is required");return n.body=i,n.appendChild(n.body),n.handleBodyAttributeChanged(n.body),s&&n.appendArrowHead(n.getArrowHeadType(s),!0),a&&n.appendArrowHead(n.getArrowHeadType(a),!1),n.applyArrowStyle(c,[n.body,n.startHead,n.endHead]),n}return v(e,t),a(e,[{key:"handleBodyAttributeChanged",value:function(t){var e=this;t.addEventListener(ea.ATTR_MODIFIED,function(t){var n=t.attrName;"x1"===n||"y1"===n?e.startHead&&e.transformArrowHead(e.startHead,!0):"x2"!==n&&"y2"!==n||e.endHead&&e.transformArrowHead(e.endHead,!1)})}},{key:"getBody",value:function(){return this.body}},{key:"getStartHead",value:function(){return this.startHead}},{key:"getEndHead",value:function(){return this.endHead}},{key:"attributeChangedCallback",value:function(t,e,n){if("opacity"===t||"strokeOpacity"===t||"stroke"===t||"lineWidth"===t||"increasedLineWidthForHitTesting"===t)this.applyArrowStyle(r({},t,n),[this.body,this.startHead,this.endHead]);else if("startHead"===t||"endHead"===t){var i="startHead"===t;if(this.destroyArrowHead(i),n){var o=this.attributes;o.body,o.startHead,o.endHead,o.startHeadOffset,o.endHeadOffset;var A=ar(o,vv);this.appendArrowHead(this.getArrowHeadType(n),i),this.applyArrowStyle(A,[i?this.startHead:this.endHead])}}else if("body"===t){var s=this.attributes;s.body,s.startHead,s.endHead,s.startHeadOffset,s.endHeadOffset;var a=ar(s,mv);this.body.destroy(),this.body=n,this.appendChild(this.body),this.applyArrowStyle(a,[this.body])}else"startHeadOffset"===t?this.moveArrowHeadAlongTangent(n,!0):"endHeadOffset"===t&&this.moveArrowHeadAlongTangent(n,!1)}},{key:"getArrowHeadType",value:function(t){return"boolean"==typeof t?"default":"custom"}},{key:"appendArrowHead",value:function(t,e){var n;n="default"===t?this.createDefaultArrowHead():e?this.attributes.startHead:this.attributes.endHead,this.transformArrowHead(n,e),n.setAttribute("zIndex",1),e?this.startHead=n:this.endHead=n,this.appendChild(n);var r=e?this.attributes.startHeadOffset:this.attributes.endHeadOffset;r&&this.moveArrowHeadAlongTangent(r,e)}},{key:"transformArrowHead",value:function(t,e){var n,r=at(),i=0,o=0,A=0,s=0,a=this.body&&this.body.nodeName;if(a===cr.LINE){var c=this.body.attributes,l=c.x1,u=c.x2,h=c.y1,d=c.y2;i=e?u:l,o=e?l:u,A=e?d:h,s=e?h:d}else if(a===cr.POLYLINE){var f=this.body.attributes.points,g=f.length;i=e?f[1][0]:f[g-2][0],A=e?f[1][1]:f[g-2][1],o=e?f[0][0]:f[g-1][0],s=e?f[0][1]:f[g-1][1]}else if(a===cr.PATH){var p=m(this.getTangent(this.body,e),2),v=p[0],y=p[1];i=v[0],A=v[1],o=y[0],s=y[1]}var w=i-o,b=A-s;n=Math.atan2(b,w),r=ut(o,s,0),e?(this.startHeadPosition=r,this.startHeadRad=n):(this.endHeadPosition=r,this.endHeadRad=n),t.setLocalPosition(r),t.setLocalEulerAngles(180*n/Math.PI+t.getLocalEulerAngles())}},{key:"moveArrowHeadAlongTangent",value:function(t,e){var n=e?this.startHead:this.endHead;n&&n.setLocalPosition(Et(at(),e?this.startHeadPosition:this.endHeadPosition,ut(Math.cos(e?this.startHeadRad:this.endHeadRad)*t,Math.sin(e?this.startHeadRad:this.endHeadRad)*t,0))),this.body}},{key:"destroyArrowHead",value:function(t){t&&this.startHead&&(this.startHead.destroy(),this.startHead=void 0),!t&&this.endHead&&(this.endHead.destroy(),this.endHead=void 0)}},{key:"getTangent",value:function(t,e){return e?t.getStartTangent():t.getEndTangent()}},{key:"createDefaultArrowHead",value:function(){var t=this.attributes,e=t.stroke,n=t.lineWidth,r=Math.sin,i=Math.cos,o=Math.PI,A=10*i(o/6);return new nc({style:{d:"M".concat(A/2,",").concat(10*r(o/6)," L-").concat(A/2,",0 L").concat(A/2,",-").concat(10*r(o/6)),stroke:e,lineWidth:n,transformOrigin:"center"}})}},{key:"applyArrowStyle",value:function(t,e){var n=t.opacity,r=t.stroke,i=t.strokeOpacity,o=t.lineWidth,A=t.increasedLineWidthForHitTesting;e.forEach(function(t){t&&(Kt(n)||(t.style.opacity=n),Kt(r)||(t.style.stroke=r),Kt(i)||(t.style.strokeOpacity=i),Kt(o)||(t.style.lineWidth=o),Kt(A)||(t.style.increasedLineWidthForHitTesting=A))})}}])}(Wa);yv.tag="arrow",yv.PARSED_STYLE_LIST=new Set([].concat(u(Wa.PARSED_STYLE_LIST),["body","startHead","endHead","startHeadOffset","endHeadOffset","stroke","lineWidth","opacity","strokeOpacity"]));var wv=Math.PI,bv=2*wv,Bv=Math.sin,Ev=Math.cos,xv=Math.acos,Cv=Math.atan2,Mv=Math.sqrt,Fv=Math.max,kv=Math.min,Sv=1e-4;[{name:"sr",inherits:!1,interpolable:!0,syntax:ri.LENGTH_PERCENTAGE},{name:"sr0",inherits:!1,interpolable:!0,syntax:ri.LENGTH_PERCENTAGE},{name:"startAngle",inherits:!1,interpolable:!0,syntax:ri.ANGLE},{name:"endAngle",inherits:!1,interpolable:!0,syntax:ri.ANGLE}].forEach(function(t){uc(t)});var Qv=function(t,e,n,r){return{x:t+n*Math.cos(r),y:e+n*Math.sin(r)}};function Uv(t,e,n,r,i,o,A){var s=t-n,a=e-r,c=o/Mv(s*s+a*a),l=c*a,u=-c*s,h=t+l,d=e+u,f=n+l,g=r+u,p=(h+f)/2,v=(d+g)/2,m=f-h,y=g-d,w=m*m+y*y,b=i-o,B=h*g-f*d,E=(y<0?-1:1)*Mv(Fv(0,b*b*w-B*B)),x=(B*y-m*E)/w,C=(-B*m-y*E)/w,M=(B*y+m*E)/w,F=(-B*m+y*E)/w,k=x-p,S=C-v,Q=M-p,U=F-v;return k*k+S*S>Q*Q+U*U&&(x=M,C=F),{cx:x,cy:C,x0:-l,y0:-u,x1:x*(i/b-1),y1:C*(i/b-1)}}function Nv(t,e){return(e=e<0&&t>=0?e+bv:e)-t<=wv?0:1}var Tv=function(t){function e(t){var n;return A(this,e),(n=g(this,e,[t])).updatePath(),n}return v(e,t),a(e,[{key:"setAttribute",value:function(t,n,r){Un(e,"setAttribute",this)([t,n,r]),["startAngle","endAngle","sr","sr0","radius"].indexOf(t)>-1&&this.updatePath()}},{key:"updatePath",value:function(){var t=this.parsedStyle,n=t.x,r=t.y,i=t.startAngle,o=t.endAngle,A=t.sr,s=t.sr0,a=t.radius,c=this.createPath(n,r,i?Ur(i):0,o?Ur(o):2*Math.PI,A||0,s||0,a||[0,0,0,0]);Un(e,"setAttribute",this)(["d",c])}},{key:"createPath",value:function(t,e,n,r,i,o,A){if(!(i<=0)){var s=Qv(t,e,i,n),a=Qv(t,e,i,r),c=Qv(t,e,o,n),l=Qv(t,e,o,r);if(ie(r-n,2*Math.PI)){var u=Qv(t,e,i,n+Math.PI),h=Qv(t,e,o,n+Math.PI),d=[["M",s.x,s.y],["A",i,i,0,1,1,u.x,u.y],["A",i,i,0,1,1,a.x,a.y],["M",c.x,c.y]];return o&&(d.push(["A",o,o,0,1,0,h.x,h.y]),d.push(["A",o,o,0,1,0,l.x,l.y])),d.push(["M",s.x,s.y]),d.push(["Z"]),d}var f=r-n,g=i*Ev(n),p=i*Bv(n),v=o*Ev(r),y=o*Bv(r),w=i*Ev(r),b=i*Bv(r),B=o*Ev(n),E=o*Bv(n),x=m(A,4),C=x[0],M=x[1],F=x[2],k=x[3],S=(i-o)/2,Q=kv(S,C),U=kv(S,M),N=kv(S,F),T=kv(S,k),O=Fv(Q,U),I=Fv(N,T),L=O,P=I;if((O>Sv||I>Sv)&&f<wv){var D=function(t,e,n,r,i,o,A,s){var a=n-t,c=r-e,l=A-i,u=s-o,h=u*a-l*c;if(!(h*h<Sv))return[t+(h=(l*(e-o)-u*(t-i))/h)*a,e+h*c]}(g,p,B,E,w,b,v,y);if(D){var R=g-D[0],H=p-D[1],_=w-D[0],G=b-D[1],K=1/Bv(xv((R*_+H*G)/(Mv(R*R+H*H)*Mv(_*_+G*G)))/2),j=Mv(D[0]*D[0]+D[1]*D[1]);L=kv(O,(i-j)/(K+1)),P=kv(I,(o-j)/(K-1))}}var z=Nv(n,r),V=[];if(L>Sv){var W=kv(C,L),Y=kv(M,L),X=Uv(B,E,g,p,i,W),q=Uv(w,b,v,y,i,Y);if(V.push(["M",t+X.cx+X.x0,e+X.cy+X.y0]),L<O&&W===Y){var $=Cv(X.y0,X.x0),Z=Cv(q.y0,q.x0);V.push(["A",L,L,0,Nv($,Z),1,t+q.cx+q.x0,e+q.cy+q.y0])}else{if(W>0){var J=Cv(X.y0,X.x0),tt=Cv(X.y1,X.x1),et=Qv(t,e,i,tt);V.push(["A",W,W,0,Nv(J,tt),1,et.x,et.y])}var nt=Cv(X.cy+X.y1,X.cx+X.x1),rt=Cv(q.cy+q.y1,q.cx+q.x1),it=Qv(t,e,i,rt);if(V.push(["A",i,i,0,Nv(nt,rt),1,it.x,it.y]),Y>0){var ot=Cv(q.y1,q.x1),At=Cv(q.y0,q.x0);V.push(["A",Y,Y,0,Nv(ot,At),1,t+q.cx+q.x0,e+q.cy+q.y0])}}}else V.push(["M",s.x,s.y]),V.push(["A",i,i,0,z,1,a.x,a.y]);if(o<Sv)V.push(["L",l.x,l.y]);else if(P>Sv){var st=kv(k,P),at=kv(F,P),ct=Uv(v,y,0,0,o-i,at),lt=Uv(0,0,B,E,o-i,st);if(V.push(["L",t+ct.cx+ct.x0,e+ct.cy+ct.y0]),P<I&&st===at){var ut=Cv(ct.y0,ct.x0),ht=Cv(lt.y0,lt.x0),dt=Qv(t,e,o,ht);V.push(["A",L,L,0,Nv(ut,ht),1,dt.x,dt.y])}else{if(at>0){var ft=Cv(ct.y0,ct.x0),gt=Cv(ct.y1,ct.x1),pt=Qv(t,e,o-i,gt);V.push(["A",at,at,0,Nv(ft,gt),1,pt.x,pt.y])}var vt=Cv(ct.cy+ct.y1,ct.cx+ct.x1),mt=Cv(lt.cy+lt.y1,lt.cx+lt.x1),yt=Qv(t,e,o,mt);if(V.push(["A",o,o,0,Nv(mt,vt),0,yt.x,yt.y]),V.push(["L",yt.x,yt.y]),st>0){var wt=Cv(lt.y1,lt.x1),bt=Cv(lt.y0,lt.x0);V.push(["A",st,st,0,Nv(wt,bt),1,t+lt.cx+lt.x0,e+lt.cy+lt.y0])}}}else V.push(["L",l.x,l.y]),V.push(["A",o,o,0,z,0,c.x,c.y]);return V.push(["Z"]),V}}}])}(nc);Tv.PARSED_STYLE_LIST=new Set([].concat(u(nc.PARSED_STYLE_LIST),["x","y","sr","sr0","radius","startAngle","endAngle"]));const Ov={duration:500},Iv={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var Lv,Pv,Dv,Rv,Hv,_v,Gv,Kv,jv;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(Lv||(Lv={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(Pv||(Pv={})),t.CanvasEvent=void 0,function(t){t.CLICK="canvas:click",t.DBLCLICK="canvas:dblclick",t.POINTER_OVER="canvas:pointerover",t.POINTER_LEAVE="canvas:pointerleave",t.POINTER_ENTER="canvas:pointerenter",t.POINTER_MOVE="canvas:pointermove",t.POINTER_OUT="canvas:pointerout",t.POINTER_DOWN="canvas:pointerdown",t.POINTER_UP="canvas:pointerup",t.CONTEXT_MENU="canvas:contextmenu",t.DRAG_START="canvas:dragstart",t.DRAG="canvas:drag",t.DRAG_END="canvas:dragend",t.DRAG_ENTER="canvas:dragenter",t.DRAG_OVER="canvas:dragover",t.DRAG_LEAVE="canvas:dragleave",t.DROP="canvas:drop",t.WHEEL="canvas:wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.ComboEvent=void 0,(Dv=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",Dv.DBLCLICK="combo:dblclick",Dv.POINTER_OVER="combo:pointerover",Dv.POINTER_LEAVE="combo:pointerleave",Dv.POINTER_ENTER="combo:pointerenter",Dv.POINTER_MOVE="combo:pointermove",Dv.POINTER_OUT="combo:pointerout",Dv.POINTER_DOWN="combo:pointerdown",Dv.POINTER_UP="combo:pointerup",Dv.CONTEXT_MENU="combo:contextmenu",Dv.DRAG_START="combo:dragstart",Dv.DRAG="combo:drag",Dv.DRAG_END="combo:dragend",Dv.DRAG_ENTER="combo:dragenter",Dv.DRAG_OVER="combo:dragover",Dv.DRAG_LEAVE="combo:dragleave",Dv.DROP="combo:drop",t.CommonEvent=void 0,(Rv=t.CommonEvent||(t.CommonEvent={})).CLICK="click",Rv.DBLCLICK="dblclick",Rv.POINTER_OVER="pointerover",Rv.POINTER_LEAVE="pointerleave",Rv.POINTER_ENTER="pointerenter",Rv.POINTER_MOVE="pointermove",Rv.POINTER_OUT="pointerout",Rv.POINTER_DOWN="pointerdown",Rv.POINTER_UP="pointerup",Rv.CONTEXT_MENU="contextmenu",Rv.DRAG_START="dragstart",Rv.DRAG="drag",Rv.DRAG_END="dragend",Rv.DRAG_ENTER="dragenter",Rv.DRAG_OVER="dragover",Rv.DRAG_LEAVE="dragleave",Rv.DROP="drop",Rv.KEY_DOWN="keydown",Rv.KEY_UP="keyup",Rv.WHEEL="wheel",Rv.PINCH="pinch",t.ContainerEvent=void 0,(Hv=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",Hv.KEY_UP="keyup",t.EdgeEvent=void 0,(_v=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",_v.DBLCLICK="edge:dblclick",_v.POINTER_OVER="edge:pointerover",_v.POINTER_LEAVE="edge:pointerleave",_v.POINTER_ENTER="edge:pointerenter",_v.POINTER_MOVE="edge:pointermove",_v.POINTER_OUT="edge:pointerout",_v.POINTER_DOWN="edge:pointerdown",_v.POINTER_UP="edge:pointerup",_v.CONTEXT_MENU="edge:contextmenu",_v.DRAG_ENTER="edge:dragenter",_v.DRAG_OVER="edge:dragover",_v.DRAG_LEAVE="edge:dragleave",_v.DROP="edge:drop",t.GraphEvent=void 0,(Gv=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",Gv.AFTER_CANVAS_INIT="aftercanvasinit",Gv.BEFORE_SIZE_CHANGE="beforesizechange",Gv.AFTER_SIZE_CHANGE="aftersizechange",Gv.BEFORE_ELEMENT_CREATE="beforeelementcreate",Gv.AFTER_ELEMENT_CREATE="afterelementcreate",Gv.BEFORE_ELEMENT_UPDATE="beforeelementupdate",Gv.AFTER_ELEMENT_UPDATE="afterelementupdate",Gv.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",Gv.AFTER_ELEMENT_DESTROY="afterelementdestroy",Gv.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",Gv.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",Gv.BEFORE_DRAW="beforedraw",Gv.AFTER_DRAW="afterdraw",Gv.BEFORE_RENDER="beforerender",Gv.AFTER_RENDER="afterrender",Gv.BEFORE_ANIMATE="beforeanimate",Gv.AFTER_ANIMATE="afteranimate",Gv.BEFORE_LAYOUT="beforelayout",Gv.AFTER_LAYOUT="afterlayout",Gv.BEFORE_STAGE_LAYOUT="beforestagelayout",Gv.AFTER_STAGE_LAYOUT="afterstagelayout",Gv.BEFORE_TRANSFORM="beforetransform",Gv.AFTER_TRANSFORM="aftertransform",Gv.BATCH_START="batchstart",Gv.BATCH_END="batchend",Gv.BEFORE_DESTROY="beforedestroy",Gv.AFTER_DESTROY="afterdestroy",Gv.BEFORE_RENDERER_CHANGE="beforerendererchange",Gv.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(Kv=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",Kv.REDO="redo",Kv.CANCEL="cancel",Kv.ADD="add",Kv.CLEAR="clear",Kv.CHANGE="change",t.NodeEvent=void 0,(jv=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",jv.DBLCLICK="node:dblclick",jv.POINTER_OVER="node:pointerover",jv.POINTER_LEAVE="node:pointerleave",jv.POINTER_ENTER="node:pointerenter",jv.POINTER_MOVE="node:pointermove",jv.POINTER_OUT="node:pointerout",jv.POINTER_DOWN="node:pointerdown",jv.POINTER_UP="node:pointerup",jv.CONTEXT_MENU="node:contextmenu",jv.DRAG_START="node:dragstart",jv.DRAG="node:drag",jv.DRAG_END="node:dragend",jv.DRAG_ENTER="node:dragenter",jv.DRAG_OVER="node:dragover",jv.DRAG_LEAVE="node:dragleave",jv.DROP="node:drop";const zv="combo",Vv="tree";var Wv;t.ExtensionCategory=void 0,(Wv=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",Wv.EDGE="edge",Wv.COMBO="combo",Wv.THEME="theme",Wv.PALETTE="palette",Wv.LAYOUT="layout",Wv.BEHAVIOR="behavior",Wv.PLUGIN="plugin",Wv.ANIMATION="animation",Wv.TRANSFORM="transform",Wv.SHAPE="shape";const Yv={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Xv(t,e){var n;const r=null===(n=Yv[t])||void 0===n?void 0:n[e];if(r)return r}const qv="5.1.0";function $v(t){return`[G6 v${qv}] ${t}`}const Zv=t=>{console.warn($v(t))};function Jv(e){const{theme:n}=e;if(!n)return{};const r=Xv(t.ExtensionCategory.THEME,n);return r||(Zv(`The theme of ${n} is not registered.`),{})}function tm(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map(t=>t.finished)]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach(t=>{var r;return null===(r=t[e])||void 0===r?void 0:r.call(t,...n)})},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach(t=>{t[e]=n}),Reflect.set(t,e,n))})}function em(t){const e=t.reduce((t,e)=>(Object.entries(e).forEach(([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)}),t),{});Object.entries(e).forEach(([n,r])=>{(r.length!==t.length||r.some(t=>Kt(t))||r.every(t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&xe(t,r[0])))&&delete e[n]});const n=Object.entries(e).reduce((t,[e,n])=>(n.forEach((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}}),t),[]);return 0!==t.length&&0===n.length&&n.push({_:0},{_:0}),n}function nm(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function rm(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},Ov);return zt(n)&&Object.assign(r,n),zt(e)&&Object.assign(r,e),r}function im(e,n,r,i){var o,A;const{animation:s}=e;if(!1===s||!1===i)return[];const a=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===a)return[];const c=null==a?void 0:a[r];if(!1===c)return[];const l=null===(A=Jv(e)[n])||void 0===A?void 0:A.animation,u=(e=[])=>function(e){if("string"==typeof e){return Xv(t.ExtensionCategory.ANIMATION,e)||(Zv(`The animation of ${e} is not registered.`),[])}return e}(e).map(t=>Object.assign(Object.assign(Object.assign(Object.assign({},Iv),zt(s)&&s),t),zt(i)&&i));if(c)return u(c);if(!l)return[];const h=l[r];return!1===h?[]:u(h)}function om(t,e,n,r=[]){if(!r&&0===t&&0===e&&0===n)return null;if(Array.isArray(r)){let i=-1;const o=[];for(let A=0;A<r.length;A++){const s=r[A];if("translate"===s[0]){if(s[1]===t&&s[2]===e)return null;i=A,o.push(["translate",t,e])}else if("translate3d"===s[0]){if(s[1]===t&&s[2]===e&&s[3]===n)return null;i=A,o.push(["translate3d",t,e,null!=n?n:0])}else o.push(s)}return-1===i&&o.splice(0,0,re(n)?["translate3d",t,e,null!=n?n:0]:["translate",t,e]),0===o.length?null:o}const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Am=(t,e,n)=>{if(!n.length)return null;const[r,i]=e;let o;const A=n.map(e=>{var{fields:n,shape:A,states:s}=e,a=Pe(e,["fields","shape","states"]);const c=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const A=`get${ce(e)}Style`,s=(null===(n=null==t?void 0:t[A])||void 0===n?void 0:n.bind(t))||(t=>t);return{shape:o,fromStyle:(null==s?void 0:s(r))||{},toStyle:(null==s?void 0:s(i))||{}}}return{shape:t,fromStyle:r,toStyle:i}})(A);if(!c)return null;const{shape:l,fromStyle:u,toStyle:h}=c,d=[{},{}];if(n.forEach(t=>{var e,n;Object.assign(d[0],{[t]:null!==(e=u[t])&&void 0!==e?e:nm(t)}),Object.assign(d[1],{[t]:null!==(n=h[t])&&void 0!==n?n:nm(t)})}),d.some(t=>Object.keys(t).some(t=>["x","y","z"].includes(t)))){const{x:t=0,y:e=0,z:n,transform:r=""}=l.attributes||{};d.forEach(i=>{var o,A,s;i.transform=om(null!==(o=i.x)&&void 0!==o?o:t,null!==(A=i.y)&&void 0!==A?A:e,null!==(s=i.z)&&void 0!==s?s:n,r)})}const f=l.animate(em(d),a);return void 0===A&&(o=f),f}).filter(Boolean),s=o||(null==A?void 0:A[0]);return s?tm(s,A.filter(t=>t!=t)):null},sm=[{fields:["x","y"]}],am=sm,cm=[{fields:["sourceNode","targetNode"]}],lm=cm,um=[{fields:["childrenNode","x","y"]}],hm=um;function dm(t){return 3===t.length}function fm(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every(t=>"number"==typeof t)}function gm(t,e,n){return t>=e&&t<=n}function pm(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function vm(t=0){const e=pm(t);return e[0]+e[2]}function mm(t){return t.max[0]-t.min[0]}function ym(t){return t.max[1]-t.min[1]}function wm(t){return[mm(t),ym(t)]}function bm(t,e){const n=fm(t)?Bm(t):t.getShape("key").getBounds();return e?Em(n,e):n}function Bm(t){const[e,n,r=0]=t,i=new yr;return i.setMinMax([e,n,r],[e,n,r]),i}function Em(t,e){const[n,r,i,o]=pm(e),[A,s,a]=t.min,[c,l,u]=t.max,h=new yr;return h.setMinMax([A-o,s-n,a],[c+r,l+i,u]),h}function xm(t){if(0===t.length)return new yr;if(1===t.length)return t[0];const e=new yr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function Cm(t,e){return gm(t[0],e.min[0],e.max[0])&&gm(t[1],e.min[1],e.max[1])}function Mm(t,e,n=!1){const{min:[r,i],max:[o,A]}=e,s=(t[1]===i||t[1]===A)&&(n||gm(t[0],r,o)),a=(t[0]===r||t[0]===o)&&(n||gm(t[1],i,A));return s||a}function Fm(t,e){const{center:n}=e;return t[0]===n[0]&&t[1]===n[1]}function km(t,e){const[n,r]=t,[i,o]=e.min,[A,s]=e.max,a=n-i,c=A-n,l=r-o,u=s-r,h=Math.min(a,c,l,u);return h===a?"left":h===c?"right":h===l?"top":h===u?"bottom":"left"}function Sm(t,e){const n=ge(t);if(Cm(t,e)){switch(km(t,e)){case"left":n[0]=e.min[0];break;case"right":n[0]=e.max[0];break;case"top":n[1]=e.min[1];break;case"bottom":n[1]=e.max[1]}}else{const[r,i]=t,[o,A]=e.min,[s,a]=e.max;n[0]=gm(r,o,s)?r:r<o?o:s,n[1]=gm(i,A,a)?i:i<A?A:a}return n}var Qm=function(t,e){return t===e},Um=function(){function t(t,e){void 0===e&&(e=null),this.value=t,this.next=e}return t.prototype.toString=function(t){return t?t(this.value):"".concat(this.value)},t}(),Nm=function(){function t(t){void 0===t&&(t=Qm),this.head=null,this.tail=null,this.compare=t}return t.prototype.prepend=function(t){var e=new Um(t,this.head);return this.head=e,this.tail||(this.tail=e),this},t.prototype.append=function(t){var e=new Um(t);return this.head?(this.tail.next=e,this.tail=e,this):(this.head=e,this.tail=e,this)},t.prototype.delete=function(t){if(!this.head)return null;for(var e=null;this.head&&this.compare(this.head.value,t);)e=this.head,this.head=this.head.next;var n=this.head;if(null!==n)for(;n.next;)this.compare(n.next.value,t)?(e=n.next,n.next=n.next.next):n=n.next;return this.compare(this.tail.value,t)&&(this.tail=n),e},t.prototype.find=function(t){var e=t.value,n=void 0===e?void 0:e,r=t.callback,i=void 0===r?void 0:r;if(!this.head)return null;for(var o=this.head;o;){if(i&&i(o.value))return o;if(void 0!==n&&this.compare(o.value,n))return o;o=o.next}return null},t.prototype.deleteTail=function(){var t=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,t;for(var e=this.head;e.next;)e.next.next?e=e.next:e.next=null;return this.tail=e,t},t.prototype.deleteHead=function(){if(!this.head)return null;var t=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),t},t.prototype.fromArray=function(t){var e=this;return t.forEach(function(t){return e.append(t)}),this},t.prototype.toArray=function(){for(var t=[],e=this.head;e;)t.push(e),e=e.next;return t},t.prototype.reverse=function(){for(var t=this.head,e=null,n=null;t;)n=t.next,t.next=e,e=t,t=n;this.tail=this.head,this.head=e},t.prototype.toString=function(t){return void 0===t&&(t=void 0),this.toArray().map(function(e){return e.toString(t)}).toString()},t}(),Tm=function(t,e,n){void 0===e&&(e=[]);var r=e.filter(function(e){return e.source===t||e.target===t});if("target"===n){return r.filter(function(e){return e.source===t}).map(function(t){return t.target})}if("source"===n){return r.filter(function(e){return e.target===t}).map(function(t){return t.source})}return r.map(function(e){return e.source===t?e.target:e.source})},Om={}.toString,Im=function(t,e){return Om.call(t)==="[object "+e+"]"},Lm=function(t){return Im(t,"Function")},Pm=function(t){return Array.isArray?Array.isArray(t):Im(t,"Array")};var Dm,Rm=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return function(t,e){var n,r;if(t)if(Pm(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var A in t)if(t.hasOwnProperty(A)&&!1===e(t[A],A))break}(t,function(n,r){Lm(t)&&"prototype"===r||e.push(n)}),e};!function(t,e){if(!Lm(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],A=n.cache;if(A.has(o))return A.get(o);var s=t.apply(this,r);return A.set(o,s),s};n.cache=new Map}(function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,A=e.fontVariant;return Dm||(Dm=document.createElement("canvas").getContext("2d")),Dm.font=[o,A,i,n+"px",r].join(" "),Dm.measureText(function(t){return Im(t,"String")}(t)?t:"").width},function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],A=0,s=o.length;A<s;A++,i++)r[i]=o[A];return r}([t],Rm(e)).join("")});function Hm(t,e,n,r){if(t===e)return[t];if(r[e])return r[e];for(var i=[],o=0,A=n[e];o<A.length;o++){var s=Hm(t,A[o],n,r);if(!s)return;for(var a=0,c=s;a<c.length;a++){var l=c[a];Pm(l)?i.push(_e(_e([],l,!0),[e],!1)):i.push([l,e])}}return r[e]=i,r[e]}var _m,Gm=function(t,e,n,r,i){var o=function(t,e,n,r){var i=t.nodes,o=void 0===i?[]:i,A=t.edges,s=void 0===A?[]:A,a={},c={},l={};o.forEach(function(t,n){var r=t.id;c[r]=1/0,r===e&&(c[r]=0)});for(var u=o.length,h=function(t){var e=function(t,e,n){for(var r,i=1/0,o=0;o<e.length;o++){var A=e[o].id;!n[A]&&t[A]<=i&&(i=t[A],r=e[o])}return r}(c,o,a),i=e.id;if(a[i]=!0,c[i]===1/0)return"continue";var A=[];A=n?function(t,e){return e.filter(function(e){return e.source===t})}(i,s):function(t,e){return e.filter(function(e){return e.source===t||e.target===t})}(i,s),A.forEach(function(t){var n=t.target,o=t.source,A=n===i?o:n,s=r&&t[r]?t[r]:1;c[A]>c[e.id]+s?(c[A]=c[e.id]+s,l[A]=[e.id]):c[A]===c[e.id]+s&&l[A].push(e.id)})},d=0;d<u;d++)h();l[e]=[e];var f={};for(var g in c)c[g]!==1/0&&Hm(e,g,l,f);var p={};for(var g in f)p[g]=f[g][0];return{length:c,path:p,allPath:f}}(t,e,r,i),A=o.length,s=o.path,a=o.allPath;return{length:A[n],path:s[n],allPath:a[n]}};!function(t){t.EuclideanDistance="euclideanDistance"}(_m||(_m={}));function Km(t){if(void 0!==t.id)return t.id;if(void 0!==t.source&&void 0!==t.target)return`${t.source}-${t.target}`;throw new Error($v("The datum does not have available id."))}function jm(t){return t.combo}function zm(t,e){const n={nodes:(t.nodes||[]).map(Km),edges:(t.edges||[]).map(Km),combos:(t.combos||[]).map(Km)};return e?Object.values(n).flat():n}!function(){function t(t){void 0===t&&(t=10),this.linkedList=new Nm,this.maxStep=t}Object.defineProperty(t.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),t.prototype.isEmpty=function(){return!this.linkedList.head},t.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},t.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},t.prototype.push=function(t){this.linkedList.prepend(t),this.length>this.maxStep&&this.linkedList.deleteTail()},t.prototype.pop=function(){var t=this.linkedList.deleteHead();return t?t.value:null},t.prototype.toArray=function(){return this.linkedList.toArray().map(function(t){return t.value})},t.prototype.clear=function(){for(;!this.isEmpty();)this.pop()}}();const Vm=(t,e,n)=>{var r;switch(n.type){case"degree":{const i=new Map;return null===(r=t.nodes)||void 0===r||r.forEach(t=>{const r=e(Km(t),n.direction).length;i.set(Km(t),r)}),i}case"betweenness":return Ym(t,n.directed,n.weightPropertyName);case"closeness":return Xm(t,n.directed,n.weightPropertyName);case"eigenvector":return $m(t,n.directed);case"pagerank":return qm(t,n.epsilon,n.linkProb);default:return Wm(t)}},Wm=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach(t=>{n.set(Km(t),0)}),n},Ym=(t,e,n)=>{const r=Wm(t),{nodes:i=[]}=t;return i.forEach(o=>{i.forEach(i=>{if(o!==i){const{allPath:A}=Gm(t,Km(o),Km(i),e,n),s=A.length;A.flat().forEach(t=>{t!==Km(o)&&t!==Km(i)&&r.set(t,r.get(t)+1/s)})}})}),r},Xm=(t,e,n)=>{const r=new Map,{nodes:i=[]}=t;return i.forEach(o=>{const A=i.reduce((r,i)=>{if(o!==i){const{length:A}=Gm(t,Km(o),Km(i),e,n);r+=A}return r},0);r.set(Km(o),1/A)}),r},qm=(t,e,n)=>{var r;const i=new Map,o=function(t,e,n){"number"!=typeof e&&(e=1e-6),"number"!=typeof n&&(n=.85);for(var r,i=1,o=0,A=1e3,s=t.nodes,a=void 0===s?[]:s,c=t.edges,l=void 0===c?[]:c,u=a.length,h={},d={},f=0;f<u;++f)h[p=(b=a[f]).id]=1/u,d[p]=1/u;for(var g=function(t){var e={},n=t.nodes,r=void 0===n?[]:n,i=t.edges,o=void 0===i?[]:i;return r.forEach(function(t){e[t.id]={degree:0,inDegree:0,outDegree:0}}),o.forEach(function(t){e[t.source].degree++,e[t.source].outDegree++,e[t.target].degree++,e[t.target].inDegree++}),e}(t);A>0&&i>e;){for(o=0,f=0;f<u;++f){var p=(b=a[f]).id;if(r=0,0===g[b.id].inDegree)h[p]=0;else{for(var v=Tm(p,l,"source"),m=0;m<v.length;++m){var y=v[m],w=g[y].outDegree;w>0&&(r+=d[y]/w)}h[p]=n*r,o+=h[p]}}for(o=(1-o)/u,i=0,f=0;f<u;++f){var b;r=h[p=(b=a[f]).id]+o,i+=Math.abs(r-d[p]),d[p]=r}A-=1}return d}(t,e,n);return null===(r=t.nodes)||void 0===r||r.forEach(t=>{i.set(Km(t),o[Km(t)])}),i},$m=(t,e)=>{const{nodes:n=[]}=t,r=Zm(t,e),i=Jm(r,n.length),o=new Map;return n.forEach((t,e)=>{o.set(Km(t),i[e])}),o},Zm=(t,e)=>{const{nodes:n=[],edges:r=[]}=t,i=Array(n.length).fill(null).map(()=>Array(n.length).fill(0));return r.forEach(({source:t,target:r})=>{const o=n.findIndex(e=>Km(e)===t),A=n.findIndex(t=>Km(t)===r);e?i[o][A]=1:(i[o][A]=1,i[A][o]=1)}),i},Jm=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let A=0;A<n&&o>r;A++){const n=Array(e).fill(0);for(let r=0;r<e;r++)for(let o=0;o<e;o++)n[r]+=t[r][o]*i[o];const r=Math.sqrt(n.reduce((t,e)=>t+e*e,0));for(let t=0;t<e;t++)n[t]/=r;o=Math.sqrt(n.reduce((t,e,n)=>t+(e-i[n])*e,0)),i=n}return i};function ty(t,e,n,r=xe){const i=new Map(t.map(t=>[n(t),t])),o=new Map(e.map(t=>[n(t),t])),A=new Set(i.keys()),s=new Set(o.keys()),a=[],c=[],l=[],u=[];return s.forEach(t=>{A.has(t)?r(i.get(t),o.get(t))?u.push(o.get(t)):c.push(o.get(t)):a.push(o.get(t))}),A.forEach(t=>{s.has(t)||l.push(i.get(t))}),{enter:a,exit:l,keep:u,update:c}}function ey(t,e,n){t.forEach(t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)})}class ny{constructor(t){this.extensions=[],this.extensionMap={},this.context=t}setExtensions(t){const e=function(t,e,n){const r={},i=t=>(t in r||(r[t]=0),`${e}-${t}-${r[t]++}`);return n.map(e=>"string"==typeof e?{type:e,key:i(e)}:"function"==typeof e?e.call(t):e.key?e:Object.assign(Object.assign({},e),{key:i(e.type)}))}(this.context.graph,this.category,t),{enter:n,update:r,exit:i,keep:o}=ty(this.extensions,e,t=>t.key);this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=Xv(e,r);if(!i)return Zv(`The extension ${r} of ${e} is not registered.`);const o=new i(this.context,t);o.initialized=!0,this.extensionMap[n]=o}createExtensions(t){t.forEach(t=>this.createExtension(t))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach(t=>this.updateExtension(t))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.initialized&&!e.destroyed&&e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach(({key:t})=>this.destroyExtension(t))}destroy(){this.destroyExtensions(this.extensions),this.context={},this.extensions=[],this.extensionMap={}}}class ry{constructor(t,e){this.events=[],this.initialized=!1,this.destroyed=!1,this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class iy extends ry{}class oy extends iy{constructor(t,e){super(t,Object.assign({},oy.defaultOptions,e)),this.isOverlapping=(t,e)=>e.some(e=>t.intersects(e)),this.occupiedBounds=[],this.detectLabelCollision=t=>{const e=this.context.viewport,n={show:[],hide:[]};return this.occupiedBounds=[],t.forEach(t=>{const r=t.getShape("label").getRenderBounds();e.isInViewport(r,!0)&&!this.isOverlapping(r,this.occupiedBounds)?(n.show.push(t),this.occupiedBounds.push(Em(r,this.options.padding))):n.hide.push(t)}),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=ty(t,e,t=>t.id);null==n||n.forEach(this.hideLabel)},this.nodeCentralities=new Map,this.sortNodesByCentrality=(t,e)=>{const{model:n}=this.context,r=n.getData(),i=n.getRelatedEdgesData.bind(n);return t.map(t=>(this.nodeCentralities.has(t.id)||(this.nodeCentralities=Vm(r,i,e)),{node:t,centrality:this.nodeCentralities.get(t.id)})).sort((t,e)=>e.centrality-t.centrality).map(t=>t.node)},this.sortLabelElementsInView=t=>{const{sort:e,sortNode:n,sortCombo:r,sortEdge:i}=this.options,{model:o}=this.context;if(Gt(e))return t.sort((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id)));const{node:A=[],edge:s=[],combo:a=[]}=ee(t,t=>t.type),c=Gt(r)?a.sort((t,e)=>r(...o.getComboData([t.id,e.id]))):a,l=Gt(n)?A.sort((t,e)=>n(...o.getNodeData([t.id,e.id]))):this.sortNodesByCentrality(A,n),u=Gt(i)?s.sort((t,e)=>i(...o.getEdgeData([t.id,e.id]))):s;return[...c,...l,...u]},this.labelElementsInView=[],this.isFirstRender=!0,this.onToggleVisibility=t=>{var e;if("zIndex"===(null===(e=t.data)||void 0===e?void 0:e.stage))return;if(!this.validate(t))return void(this.hiddenElements.size>0&&(this.hiddenElements.forEach(this.showLabel),this.hiddenElements.clear()));const n=this.isFirstRender?this.getLabelElements():this.getLabelElementsInView();this.hideLabelIfExceedViewport(this.labelElementsInView,n),this.labelElementsInView=n;const r=this.sortLabelElementsInView(this.labelElementsInView),{show:i,hide:o}=this.detectLabelCollision(r);for(let t=i.length-1;t>=0;t--)this.showLabel(i[t]);o.forEach(this.hideLabel)},this.hiddenElements=new Map,this.hideLabel=t=>{const e=t.getShape("label");e&&ey(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&ey(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Qe(this.onToggleVisibility,this.options.throttle,{leading:!0}),this.enableToggle=!0,this.toggle=t=>{this.enableToggle&&this.onToggleVisibility(t)},this.onBeforeRender=()=>{this.enableToggle=!1},this.onAfterRender=t=>{this.onToggleVisibility(t),this.enableToggle=!0},this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents(),this.onToggleVisibility({})}getLabelElements(){const{elementMap:t}=this.context.element,e=[];for(const n in t){const r=t[n];r.isVisible()&&r.getShape("label")&&e.push(r)}return e}getLabelElementsInView(){const t=this.context.viewport;return this.getLabelElements().filter(e=>t.isInViewport(e.getShape("key").getRenderBounds()))}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.on(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.on(t.GraphEvent.AFTER_DRAW,this.toggle),e.on(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.off(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.off(t.GraphEvent.AFTER_DRAW,this.toggle),e.off(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}oy.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const Ay=[0,0,0];function sy(t,e){if(t.length==e.length)return[t,e];if(dm(t)&&0!==t[2]||dm(e)&&0!==e[2])throw new Error($v("Vectors could not operate due to different dimensions."));return[yy(t),yy(e)]}function ay(t,e){return[t,e]=sy(t,e),t.map((t,n)=>t+e[n])}function cy(t,e){return[t,e]=sy(t,e),t.map((t,n)=>t-e[n])}function ly(t,e){return"number"==typeof e?t.map(t=>t*e):([t,e]=sy(t,e),t.map((t,n)=>t*e[n]))}function uy(t,e){return"number"==typeof e?t.map(t=>t/e):([t,e]=sy(t,e),t.map((t,n)=>{if(0==e[n])throw new Error($v("Vector could not be divided by zero"));return t/e[n]}))}function hy(t,e){return t.map(t=>t*e)}function dy(t,e){return[t,e]=sy(t,e),Math.sqrt(t.reduce((t,n,r)=>t+Math.pow(n-e[r],2),0))}function fy(t,e){return[t,e]=sy(t,e),t.reduce((t,n,r)=>t+Math.abs(n-e[r]),0)}function gy(t){const e=t.reduce((t,e)=>t+Math.pow(e,2),0);return t.map(t=>t/Math.sqrt(e))}function py(t,e,n=!1){[t,e]=sy(t,e);const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(ly(t,e).reduce((t,e)=>t+e,0)/(dy(t,Ay)*dy(e,Ay)));return n&&r<0&&(i=2*Math.PI-i),i}function vy(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function my(t,e){return t.map(t=>t%e)}function yy(t){return[t[0],t[1]]}function wy(t){return 2===t.length?[t[0],t[1],0]:t}function by(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function By(t,e){const[n,r]=t;if(e%360==0)return[n,r];const i=e*Math.PI/180,o=Math.cos(i),A=Math.sin(i);return[n*o-r*A,n*A+r*o]}function Ey(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=wy(t),r=wy(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(cy(n,r),cy(i,o)).every(t=>0===t)}function xy(t,e,n=!1){if(Ey(t,e))return;const[r,i]=t,[o,A]=e,s=((r[0]-o[0])*(o[1]-A[1])-(r[1]-o[1])*(o[0]-A[0]))/((r[0]-i[0])*(o[1]-A[1])-(r[1]-i[1])*(o[0]-A[0])),a=A[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(A[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(A[1]-o[1]);return n||gm(s,0,1)&&gm(a,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Cy(t){if(Array.isArray(t))return gm(t[0],0,1)&&gm(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}function My(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Fy(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function ky(t,e="center"){return function(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}(t,Cy(e))}function Sy(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function Qy(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function Uy(t,e=0){return t.map(t=>parseFloat(t.toFixed(e)))}function Ny(t,e,n,r=!1){if(xe(t,e))return t;const i=gy(r?cy(t,e):cy(e,t)),o=[i[0]*n,i[1]*n];return ay(yy(t),o)}function Ty(t,e){return t[1]===e[1]}function Oy(t,e){return Ty(t,e)||function(t,e){return t[0]===e[0]}(t,e)}function Iy(t,e,n){return Ey([t,e],[e,n])}function Ly(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function Py(t,e,n,r=!0,i=!1){for(let o=0;o<n.length;o++){let A=n[o],s=n[(o+1)%n.length];r&&(A=ay(e,A),s=ay(e,s));const a=xy([e,i?Ly(t,e):t],[A,s]);if(a)return{point:a,line:[A,s]}}return{point:e,line:void 0}}function Dy(t,e,n=!1){const r=e.center,i=cy(n?Ly(t,r):t,e.center),o=Math.atan2(i[1],i[0]);if(isNaN(o))return r;const A=mm(e)/2,s=ym(e)/2;return[r[0]+A*Math.cos(o),r[1]+s*Math.sin(o)]}function Ry(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach(e=>{const i=function(t,e){const n=Hy(t,e);return dy(t,n)}(t,e);i<n&&(n=i,r=e)}),r}function Hy(t,e){const[n,r]=e[0],[i,o]=e[1],[A,s]=t,a=i-n,c=o-r;if(0===a&&0===c)return[n,r];let l=((A-n)*a+(s-r)*c)/(a*a+c*c);l>1?l=1:l<0&&(l=0);return[n+l*a,r+l*c]}function _y(t,e=!0){const n=function(t){const e=t.reduce((t,e)=>ay(t,e),[0,0]);return uy(e,t.length)}(t);return t.sort(([t,r],[i,o])=>{const A=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-A:A-s})}function Gy(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}class Ky{constructor(t,e,n){if(this.phase=e,this.pointerByTouch=[],this.initialDistance=null,this.emitter=t,Ky.instance)return Ky.callbacks[this.phase].push(n),Ky.instance;this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.bindEvents(),Ky.instance=this,Ky.callbacks[this.phase].push(n)}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp)}updatePointerPosition(t,e,n){const r=this.pointerByTouch.findIndex(e=>e.pointerId===t);r>=0&&(this.pointerByTouch[r]={x:e,y:n,pointerId:t})}onPointerDown(t){const{x:e,y:n}=t.client||{};if(void 0!==e&&void 0!==n&&(this.pointerByTouch.push({x:e,y:n,pointerId:t.pointerId}),"touch"===t.pointerType&&2===this.pointerByTouch.length)){Ky.isPinching=!0;const e=this.pointerByTouch[0].x-this.pointerByTouch[1].x,n=this.pointerByTouch[0].y-this.pointerByTouch[1].y;this.initialDistance=Math.sqrt(e*e+n*n),Ky.callbacks.pinchstart.forEach(e=>e(t,{scale:0}))}}onPointerMove(t){if(2!==this.pointerByTouch.length||null===this.initialDistance)return;const{x:e,y:n}=t.client||{};if(void 0===e||void 0===n)return;this.updatePointerPosition(t.pointerId,e,n);const r=this.pointerByTouch[0].x-this.pointerByTouch[1].x,i=this.pointerByTouch[0].y-this.pointerByTouch[1].y,o=Math.sqrt(r*r+i*i)/this.initialDistance;Ky.callbacks.pinchmove.forEach(e=>e(t,{scale:5*(o-1)}))}onPointerUp(t){var e;Ky.callbacks.pinchend.forEach(e=>e(t,{scale:0})),Ky.isPinching=!1,this.initialDistance=null,this.pointerByTouch=[],null===(e=Ky.instance)||void 0===e||e.tryDestroy()}destroy(){this.emitter.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),this.emitter.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),this.emitter.off(t.CommonEvent.POINTER_UP,this.onPointerUp),Ky.instance=null}off(t,e){const n=Ky.callbacks[t].indexOf(e);n>-1&&Ky.callbacks[t].splice(n,1),this.tryDestroy()}tryDestroy(){Object.values(Ky.callbacks).every(t=>0===t.length)&&this.destroy()}}Ky.isPinching=!1,Ky.instance=null,Ky.callbacks={pinchstart:[],pinchmove:[],pinchend:[]};const jy=new Set(["Control","Alt","Meta","Shift"]);function zy(t){return jy.has(t)}const Vy=t=>t.map(t=>Jt(t)?t.toLocaleLowerCase():t);class Wy{constructor(e){this.map=new Map,this.boundHandlePinch=()=>{},this.recordKey=new Set,this.onKeyDown=t=>{(null==t?void 0:t.key)&&(this.recordKey.add(t.key),this.trigger(t))},this.onKeyUp=t=>{(null==t?void 0:t.key)&&this.recordKey.delete(t.key)},this.onKeyDownWindow=t=>{zy(t.key)&&this.recordKey.add(t.key)},this.onKeyUpWindow=t=>{zy(t.key)&&this.recordKey.delete(t.key)},this.onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)},this.onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)},this.handlePinch=(e,n)=>{this.triggerExtendKey(t.CommonEvent.PINCH,Object.assign(Object.assign({},e),n))},this.onFocus=()=>{this.recordKey.clear()},this.emitter=e,this.bindEvents()}bind(e,n){0!==e.length&&(e.includes(t.CommonEvent.PINCH)&&!this.pinchHandler&&(this.boundHandlePinch=this.handlePinch.bind(this),this.pinchHandler=new Ky(this.emitter,"pinchmove",this.boundHandlePinch)),this.map.set(e,n))}unbind(t,e){this.map.forEach((n,r)=>{xe(r,t)&&(e&&e!==n||this.map.delete(r))})}unbindAll(){this.map.clear()}match(t){const e=Vy(Array.from(this.recordKey)).sort(),n=Vy(t).sort();return xe(e,n)}bindEvents(){var e;const{emitter:n}=this;window.addEventListener(t.CommonEvent.KEY_DOWN,this.onKeyDownWindow),window.addEventListener(t.CommonEvent.KEY_UP,this.onKeyUpWindow),n.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),n.on(t.CommonEvent.KEY_UP,this.onKeyUp),n.on(t.CommonEvent.WHEEL,this.onWheel),n.on(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"focus",this.onFocus)}trigger(t){this.map.forEach((e,n)=>{this.match(n)&&e(t)})}triggerExtendKey(t,e){this.map.forEach((n,r)=>{r.includes(t)&&xe(Array.from(this.recordKey),r.filter(e=>e!==t))&&n(e)})}destroy(){var e,n;this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),window.removeEventListener(t.CommonEvent.KEY_DOWN,this.onKeyDownWindow),window.removeEventListener(t.CommonEvent.KEY_UP,this.onKeyUpWindow),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag),null===(e=this.pinchHandler)||void 0===e||e.off("pinchmove",this.boundHandlePinch),null===(n=globalThis.removeEventListener)||void 0===n||n.call(globalThis,"focus",this.onFocus)}}class Yy extends iy{constructor(t,e){super(t,be({},Yy.defaultOptions,e)),this.shortcut=new Wy(t.graph),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.clearStates=this.clearStates.bind(this),this.bindEvents()}onPointerDown(t){if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{canvas:e,graph:n}=this.context,r=Object.assign({},this.options.style);this.options.style.lineWidth&&(r.lineWidth=+this.options.style.lineWidth/n.getZoom()),this.rectShape=new sc({id:"g6-brush-select",style:r}),e.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]}onPointerMove(t){var e;if(!this.startPoint)return;const{immediately:n,mode:r}=this.options;this.endPoint=Xy(t,this.context.graph),null===(e=this.rectShape)||void 0===e||e.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),n&&"default"===r&&this.updateElementsStates(Gy(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=Xy(t,this.context.graph),this.updateElementsStates(Gy(this.startPoint,this.endPoint)),this.clearBrush()):this.clearBrush())}clearStates(){this.endPoint||this.clearElementsStates()}clearElementsStates(){const{graph:t}=this.context,e=Object.values(t.getData()).reduce((t,e)=>Object.assign({},t,e.reduce((t,e)=>{var n;const r=null===(n=e.states||[])||void 0===n?void 0:n.filter(t=>t!==this.options.state);return t[Km(e)]=r,t},{})),{});t.setElementState(e,this.options.animation)}updateElementsStates(t){const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,A=this.selector(e,t,n),s={};switch(i){case"union":A.forEach(t=>{s[t]=[...e.getElementState(t),r]});break;case"diff":A.forEach(t=>{const n=e.getElementState(t);s[t]=n.includes(r)?n.filter(t=>t!==r):[...n,r]});break;case"intersect":A.forEach(t=>{const n=e.getElementState(t);s[t]=n.includes(r)?[r]:[]});break;default:A.forEach(t=>{s[t]=[r]})}Gt(o)&&o(s),e.setElementState(s,this.options.animation)}selector(t,e,n){if(!n||0===n.length)return[];const r=[],i=t.getData();if(n.forEach(n=>{i[`${n}s`].forEach(n=>{const i=Km(n);"hidden"!==t.getElementVisibility(i)&&function(t,e,n,r){const i=t[0],o=t[1];let A=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);const s=r-n;for(let t=0,r=s-1;t<s;r=t++){const s=e[t+n][0],a=e[t+n][1],c=e[r+n][0],l=e[r+n][1];a>o!=l>o&&i<(c-s)*(o-a)/(l-a)+s&&(A=!A)}return A}(t.getElementPosition(i),e)&&r.push(i)})}),n.includes("edge")){const t=i.edges;null==t||t.forEach(t=>{const{source:e,target:n}=t;r.includes(e)&&r.includes(n)&&r.push(Km(t))})}return r}clearBrush(){var t;null===(t=this.rectShape)||void 0===t||t.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0}isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return this.shortcut.match(e.filter(t=>"drag"!==t))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp),e.on(t.CanvasEvent.CLICK,this.clearStates)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.off(t.CommonEvent.POINTER_UP,this.onPointerUp),e.off(t.CanvasEvent.CLICK,this.clearStates)}update(t){this.unbindEvents(),this.options=be(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}Yy.defaultOptions={animation:!1,enable:!0,enableElements:["node","combo","edge"],immediately:!1,mode:"default",state:"selected",trigger:["shift"],style:{width:0,height:0,lineWidth:1,fill:"#1677FF",stroke:"#1677FF",fillOpacity:.1,zIndex:2,pointerEvents:"none"}};const Xy=(t,e)=>{if(!("node"!==t.targetType&&"combo"!==t.targetType||t.nativeEvent.target instanceof HTMLCanvasElement)){const[n,r]=e.getCanvasByClient([t.client.x,t.client.y]);return[n,r]}return[t.canvas.x,t.canvas.y]},qy=.8,$y=["node","edge","combo"];function Zy(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)Zy(t,e,n,r,i+1);"BT"===r&&e(t,i)}function Jy(t,e,n,r,i="both"){if("combo"===e||"node"===e)return tw(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const A=tw(t,o.source,r-1,i),s=tw(t,o.target,r-1,i);return Array.from(new Set([...A,...s,n]))}function tw(t,e,n,r="both"){const i=new Set,o=new Set,A=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,(e,i)=>{i>n||(A.add(e),t.getRelatedEdgesData(e,r).forEach(t=>{const e=Km(t);!o.has(e)&&i<n&&(A.add(e),o.add(e))}))},e=>t.getRelatedEdgesData(e,r).map(t=>t.source===e?t.target:t.source).filter(t=>!i.has(t)&&(i.add(t),!0))),Array.from(A)}function ew(t){return t.states||[]}class nw extends iy{constructor(t,e){super(t,Object.assign({},nw.defaultOptions,e)),this.onClickSelect=t=>De(this,void 0,void 0,function*(){var e,n;this.validate(t)&&(yield this.updateState(t),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))}),this.onClickCanvas=t=>De(this,void 0,void 0,function*(){var e,n;this.validate(t)&&(yield this.clearState(),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))}),this.shortcut=new Wy(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)}),e.on(t.CanvasEvent.CLICK,this.onClickCanvas)}get isMultipleSelect(){const{multiple:t,trigger:e}=this.options;return t&&this.shortcut.match(e)}getNeighborIds(t){const{target:e,targetType:n}=t,{graph:r}=this.context,{degree:i}=this.options;return Jy(r,n,e.id,"function"==typeof i?i(t):i).filter(t=>t!==e.id)}updateState(t){return De(this,void 0,void 0,function*(){const{state:e,unselectedState:n,neighborState:r,animation:i}=this.options;if(!e&&!r&&!n)return;const{target:o}=t,{graph:A}=this.context,s=ew(A.getElementData(o.id)).includes(e)?"unselect":"select",a={},c=this.isMultipleSelect,l=[o.id],u=this.getNeighborIds(t);if(c)if(Object.assign(a,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach(t=>{const r=new Set(A.getElementState(t));r.add(e),r.delete(n),a[t]=Array.from(r)})};t(l,e),t(u,r),n&&Object.keys(a).forEach(t=>{const i=a[t];i.includes(e)||i.includes(r)||i.includes(n)||a[t].push(n)})}else{const t=a[o.id];a[o.id]=t.filter(t=>t!==e&&t!==r),t.includes(n)||a[o.id].push(n),u.forEach(t=>{a[t]=a[t].filter(t=>t!==r),a[t].includes(e)||a[t].push(n)})}else if("select"===s){Object.assign(a,this.getClearStates(!!n));const t=(t,e)=>{t.forEach(t=>{a[t]||(a[t]=A.getElementState(t)),a[t].push(e)})};t(l,e),t(u,r),n&&Object.keys(a).forEach(t=>{l.includes(t)||u.includes(t)||a[t].push(n)})}else Object.assign(a,this.getClearStates());yield A.setElementState(a,i)})}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach(t=>{i[Km(t)]=ew(t)}),i}getClearStates(t=!1){const{graph:e}=this.context,{state:n,unselectedState:r,neighborState:i}=this.options,o=new Set([n,r,i]),{nodes:A,edges:s,combos:a}=e.getData(),c={};return[...A,...s,...a].forEach(e=>{const n=ew(e),r=n.filter(t=>!o.has(t));(t||r.length!==n.length)&&(c[Km(e)]=r)}),c}clearState(){return De(this,void 0,void 0,function*(){const{graph:t}=this.context;yield t.setElementState(this.getClearStates(),this.options.animation)})}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)}),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function rw(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function iw(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function ow(t,e,n=!0){if(!e)return t;if(!iw(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=ae(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Aw(t,e){const n=Object.entries(t).reduce((t,[n,r])=>("className"===n||"class"===n||iw(n,e)&&Object.assign(t,{[ow(n,e)]:r}),t),{});if("opacity"in t){const r=function(t,e){return`${e}${ce(t)}`}("opacity",e),i=t.opacity;if(r in t){const e=t[r];Object.assign(n,{opacity:i*e})}else Object.assign(n,{opacity:i})}return n}function sw(t,e){const n=e.length;return Object.keys(t).reduce((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r},{})}function aw(t,e){const n="string"==typeof e?[e]:e,r={};return Object.keys(t).forEach(e=>{n.find(t=>e.startsWith(t))||(r[e]=t[e])}),r}function cw(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function lw(t,e){const{datum:n,graph:r}=e;return"function"==typeof t?t.call(r,n):Object.fromEntries(Object.entries(t).map(([t,e])=>"function"==typeof e?[t,e.call(r,n)]:[t,e]))}function uw(t,e){const n=(null==t?void 0:t.style)||{},r=(null==e?void 0:e.style)||{};for(const t in n)t in r||(r[t]=n[t]);return Object.assign({},t,e,{style:r})}function hw(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function dw(t){const e="string"==typeof t?Xv("palette",t):t;if("function"!=typeof e)return e}function fw(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function gw(t,e,n=1,r=!1){const i=r?n:1;return fw((t.max[0]-t.min[0])*i,e)}nw.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class pw extends Wa{constructor(t){mw(t.style),super(t),this.shapeMap={},this.animateMap={},this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}upsert(e,n,r,i,o){var A,s,a,c,l,u,h,d;const f=this.shapeMap[e];if(!1===r)return void(f&&(null===(A=null==o?void 0:o.beforeDestroy)||void 0===A||A.call(o,f),i.removeChild(f),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,f)));const g="string"==typeof n?Xv(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error($v(`Shape ${n} not found`));if(!f||f.destroyed||!(f instanceof g)){f&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,f),null==f||f.destroy(),null===(c=null==o?void 0:o.afterDestroy)||void 0===c||c.call(o,f)),null===(l=null==o?void 0:o.beforeCreate)||void 0===l||l.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(u=null==o?void 0:o.afterCreate)||void 0===u||u.call(o,t),t}return null===(h=null==o?void 0:o.beforeUpdate)||void 0===h||h.call(o,f),ZB(f,r),null===(d=null==o?void 0:o.afterUpdate)||void 0===d||d.call(o,f),f}update(t={}){const e=Object.assign({},this.attributes,t);mw(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:A,clipPath:s,component:a}=e,c=Pe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,c),r&&t.setAttribute("transform",r);re(n)&&t.setAttribute("zIndex",n);i&&t.setAttribute("transformOrigin",i);o&&t.setAttribute("visibility",o);A&&t.setAttribute("cursor",A);s&&t.setAttribute("clipPath",s);a&&t.setAttribute("component",a)}(this,e),this.render(e,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){return function(t){const{x:e,y:n,z:r,class:i,className:o,transform:A,transformOrigin:s,zIndex:a,visibility:c}=t;return Pe(t,["x","y","z","class","className","transform","transformOrigin","zIndex","visibility"])}(t)}get compositeShapes(){return[["badges","badge-"],["ports","port-"]]}animate(t,e){if(0===t.length)return null;const n=[];if(void 0!==t[0].x||void 0!==t[0].y||void 0!==t[0].z){const{x:e=0,y:n=0,z:r=0}=this.attributes;t.forEach(t=>{const{x:i=e,y:o=n,z:A=r}=t;Object.assign(t,{transform:A?[["translate3d",i,o,A]]:[["translate",i,o]]})})}const r=super.animate(t,e);if(r&&(vw(this,r),n.push(r)),Array.isArray(t)&&t.length>0){const r=["transform","transformOrigin","x","y","z","zIndex"];if(Object.keys(t[0]).some(t=>!r.includes(t))){Object.entries(this.shapeMap).forEach(([r,i])=>{const o=this[`get${ce(r)}Style`];if(Gt(o)){const r=t.map(t=>o.call(this,Object.assign(Object.assign({},this.attributes),t))),A=i.animate(em(r),e);A&&(vw(i,A),n.push(A))}});const r=(r,i)=>{if(!Ee(r)){const o=this[`get${ce(i)}Style`];if(Gt(o)){const i=t.map(t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)));Object.entries(i[0]).map(([t])=>{const o=i.map(e=>e[t]),A=r[t];if(A){const t=A.animate(em(o),e);t&&(vw(A,t),n.push(t))}})}}};this.compositeShapes.forEach(([t,e])=>{const n=sw(this.shapeMap,e);r(n,t)})}}return tm(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;ey(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function vw(t,e){null==e||e.finished.then(()=>{const n=t.activeAnimations.findIndex(t=>t===e);n>-1&&t.activeAnimations.splice(n,1)})}function mw(t){if(!t)return{};if("x"in t||"y"in t||"z"in t){const{x:e=0,y:n=0,z:r,transform:i}=t,o=om(e,n,r,i);o&&(t.transform=o)}return t}class yw extends pw{constructor(t){super(uw({style:yw.defaultStyleProps},t))}isTextStyle(t){return iw(t,"label")}isBackgroundStyle(t){return iw(t,"background")}getTextStyle(t){const e=this.getGraphicStyle(t),{padding:n}=e;return aw(Pe(e,["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Aw(e,"background"),{min:[A,s],center:[a,c],halfExtents:[l,u]}=this.shapeMap.text.getGeometryBounds(),[h,d,f,g]=pm(i),p=2*l+g+d,{width:v,height:m}=o;v&&m?Object.assign(o,{x:a-Number(v)/2,y:c-Number(m)/2}):Object.assign(o,{x:A-g,y:s-h,width:n?Math.min(p,r+g+d):p,height:2*u+h+f});const{radius:y}=o;if("string"==typeof y&&y.endsWith("%")){const t=Number(y.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",cc,this.getTextStyle(t),e),this.upsert("background",sc,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}yw.defaultStyleProps={padding:0,fontSize:12,fontFamily:"system-ui, sans-serif",wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};class ww extends pw{constructor(t){super(uw({style:ww.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",yw,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}ww.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const bw={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function Bw(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in bw?r=t:e.unshift(t),i={type:r},bw[r].forEach(n=>{t=e.shift(),i[n]=t}),"M"===r?r="L":"m"===r&&(r="l");const[o,...A]=Object.values(i);n.push([o,...A.map(Number)])}return n}(t):t;return n.forEach(t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])}),e}const Ew=t=>{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e<t.length-2;e+=1){const[n,r]=t[e-1],[i,A]=t[e],[s,a]=t[e+1],[c,l]=e!==t.length-2?t[e+2]:[s,a],u=i+(s-n)/6,h=A+(a-r)/6,d=s-(c-i)/6,f=a-(l-A)/6;o.push(["C",u,h,d,f,s,a])}return o};class xw extends pw{constructor(t){super(uw({style:xw.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const e=Aw(this.getGraphicStyle(t),"label"),{maxWidth:n,offsetX:r,offsetY:i,autoRotate:o,placement:A,closeToPath:s}=e,a=Pe(e,["maxWidth","offsetX","offsetY","autoRotate","placement","closeToPath"]),c=this.shapeMap.key,l=null==c?void 0:c.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,A){const[s,a]=ky(t,e),c={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:[["translate",s+n,a+r]]};if("center"===e||!i)return c;const l=Bw(o);if(!l||l.length<=3)return c;const u=l.map((t,e)=>{const n=t,r=l[(e+1)%l.length];return xe(n,r)?null:[n,r]}).filter(Boolean),h=Ry([s,a],u),d=Hy([s,a],h);if(d&&h&&(c.transform=[["translate",d[0]+n,d[1]+r]],A)){const t=Math.atan((h[0][1]-h[1][1])/(h[0][0]-h[1][0]));c.transform.push(["rotate",t/Math.PI*180]),c.textAlign="center","right"!==e&&"left"!==e||(c.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return c}(l,A,r,i,s,t.d,o),{wordWrapWidth:gw(l,n)},a)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",nc,this.getKeyStyle(t),e),this.upsert("label",yw,this.getLabelStyle(t),e)}}xw.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let Cw=class extends Za{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Fw=this,this.isMutationObserved=!0,this.addEventListener(ea.MOUNTED,this.onMounted),this.addEventListener(ea.ATTR_MODIFIED,this.onAttrModified)}handleRadius(){const{radius:t,clipPath:e,width:n=0,height:r=0}=this.attributes;if(t&&n&&r){const[i,o]=this.getBounds().min,A={x:i,y:o,radius:t,width:n,height:r};if(e)Object.assign(this.parsedStyle.clipPath.style,A);else{const t=new sc({style:A});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const Mw=new WeakMap;let Fw=null;const kw=t=>{if(Fw&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Fw).includes(t)){const e=Mw.get(t);e?e.includes(Fw)||e.push(Fw):Mw.set(t,[Fw])}},Sw=t=>{const e=Mw.get(t);e&&e.forEach(t=>t.handleRadius())};class Qw extends pw{constructor(t){super(t)}isImage(){const{src:t}=this.attributes;return!!t}getIconStyle(t=this.attributes){const{width:e=0,height:n=0}=t,r=this.getGraphicStyle(t);return this.isImage()?Object.assign({x:-e/2,y:-n/2},r):Object.assign({textBaseline:"middle",textAlign:"center"},r)}render(t=this.attributes,e=this){this.upsert("icon",this.isImage()?Cw:cc,this.getIconStyle(t),e)}}class Uw extends pw{get context(){return this.config.context}get parsedAttributes(){return this.attributes}onframe(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>this.onframe(),n.finished.then(()=>this.onframe())),n}}class Nw extends Uw{constructor(t){super(uw({style:Nw.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return cw(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(aw(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Aw(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,A=Pe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(qB(s,n,i,o),{wordWrapWidth:gw(s,r)},A)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Pe(e,["fill"]),i=Aw(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign(Object.assign({},r),{stroke:n}),i)}getIconStyle(t){if(!1===t.icon||!t.iconText&&!t.iconSrc)return!1;const e=Aw(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=cw(t);let r={};return e.text&&!e.fontSize&&(r={fontSize:.5*Math.min(...n)}),!e.src||e.width&&e.height||(r={width:.5*n[0],height:.5*n[1]}),r}(t.size,e),e)}getBadgesStyle(t){var e;const n=sw(this.shapeMap,"badge-"),r={};if(Object.keys(n).forEach(t=>{r[t]=!1}),!1===t.badge||!(null===(e=t.badges)||void 0===e?void 0:e.length))return r;const{badges:i=[],badgePalette:o,opacity:A=1}=t,s=Pe(t,["badges","badgePalette","opacity"]),a=dw(o),c=Aw(this.getGraphicStyle(s),"badge");return i.forEach((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:a?a[e%(null==a?void 0:a.length)]:void 0,opacity:A},c),this.getBadgeStyle(t))}),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Pe(t,["placement","offsetX","offsetY"]),A=qB(e.getLocalBounds(),n,r,i,!0);return Object.assign(Object.assign({},A),o)}getPortsStyle(t){var e;const n=this.getPorts(),r={};if(Object.keys(n).forEach(t=>{r[t]=!1}),!1===t.port||!(null===(e=t.ports)||void 0===e?void 0:e.length))return r;const i=Aw(this.getGraphicStyle(t),"port"),{ports:o=[]}=t;return o.forEach((e,n)=>{const o=e.key||n,A=Object.assign(Object.assign({},i),e);if(jB(A))r[o]=!1;else{const[n,i]=this.getPortXY(t,e);r[o]=Object.assign({transform:[["translate",n,i]]},A)}}),r}getPortXY(t,e){const{placement:n="left"}=e,r=this.getShape("key");return GB(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();ey(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return sw(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return Py(t,ky(e,"center"),[ky(e,"left-top"),ky(e,"right-top"),ky(e,"right-bottom"),ky(e,"left-bottom")],!1,n).point}(t,this.getShape("key").getBounds(),e)}drawHaloShape(t,e){const n=this.getHaloStyle(t),r=this.getShape("key");this.upsert("halo",r.constructor,n,e)}drawIconShape(t,e){const n=this.getIconStyle(t);this.upsert("icon",Qw,n,e),kw(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach(t=>{const r=n[t];this.upsert(`badge-${t}`,ww,r,e)})}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach(t=>{const r=n[t],i=`port-${t}`;this.upsert(i,za,r,e)})}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",yw,n,e)}_drawKeyShape(t,e){return this.drawKeyShape(t,e)}render(t=this.parsedAttributes,e=this){this._drawKeyShape(t,e),this.getShape("key")&&(this.drawHaloShape(t,e),this.drawIconShape(t,e),this.drawBadgeShapes(t,e),this.drawLabelShape(t,e),this.drawPortShapes(t,e))}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Sw(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}Nw.defaultStyleProps={x:0,y:0,size:32,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};let Tw=class t extends Nw{constructor(e){super(uw({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",za,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{r:Math.min(...this.getSize(t))/2})}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getShape("key").attributes,r=2*n*qy;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}};Tw.defaultStyleProps={size:32};class Ow extends Nw{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",ic,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{points:this.getPoints(t)})}getIntersectPoint(t,e=!1){var n,r;const{points:i}=this.getShape("key").attributes;return Py(t,[+((null===(n=this.attributes)||void 0===n?void 0:n.x)||0),+((null===(r=this.attributes)||void 0===r?void 0:r.y)||0)],i,!0,e).point}}class Iw extends Ow{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}}class Lw extends Tw{constructor(t){super(uw({style:Lw.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...cw(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return Jt(t)?parseInt(t)/100*this.parseOuterR():t}drawDonutShape(t,e){const{donuts:n}=t;if(!(null==n?void 0:n.length))return;const r=n.map(t=>re(t)?{value:t}:t),i=Aw(this.getGraphicStyle(t),"donut"),o=dw(t.donutPalette);if(!o)return;const A=r.reduce((t,e)=>{var n;return t+(null!==(n=e.value)&&void 0!==n?n:0)},0),s=this.parseOuterR(),a=this.parseInnerR();let c=0;r.forEach((t,n)=>{const{value:l=0,color:u=o[n%o.length]}=t,h=Pe(t,["value","color"]),d=360*(0===A?1/r.length:l/A);this.upsert(`round${n}`,nc,Object.assign(Object.assign(Object.assign({},i),{d:Dw(s,a,c,c+d),fill:u}),h),e),c+=d})}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}Lw.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const Pw=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],Dw=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[A,s]=[i/360*2*Math.PI,o/360*2*Math.PI],a=[Pw(t,e,r,A),Pw(t,e,n,A),Pw(t,e,n,s),Pw(t,e,r,s)],c=s-A>Math.PI?1:0;return[["M",a[0][0],a[0][1]],["L",a[1][0],a[1][1]],["A",n,n,0,c,1,a[2][0],a[2][1]],["L",a[3][0],a[3][1]],["A",r,r,0,c,0,a[0][0],a[0][1]],["Z"]]})(i,o,t,e,n,r)};class Rw extends Nw{constructor(t){super(uw({style:Rw.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ya,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return Object.assign(Object.assign({},e),{rx:n/2,ry:r/2})}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getShape("key").attributes,i=2*Math.min(+n,+r)*qy;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}}Rw.defaultStyleProps={size:[45,35]};class Hw extends Ow{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*qy;return!!e&&Object.assign({width:n,height:n},e)}}function _w(t,e){if(!{}.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var Gw=0;function Kw(t){return"__private_"+Gw+++"_"+t}
|
|
47
|
+
*/var mp=function(t){function e(t,n,r,i){var o;return A(this,e),(o=g(this,e,[t])).currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return v(e,t),a(e)}(Gs),yp=0,wp=function(){return a(function t(e,n){var r;A(this,t),this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=e,e.animation=this,this.timeline=n,this.id="".concat(yp++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(r=this.effect)||void 0===r?void 0:r.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()},[{key:"pending",get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending}},{key:"playState",get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"}},{key:"ready",get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise(function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}}),this.pending||this.resolveReadyPromise()),this.readyPromise}},{key:"finished",get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise(function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}}),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise}},{key:"currentTime",get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){if(t=Number(t),!isNaN(t)){var e;if(this.timeline.restart(),!this._paused&&null!==this._startTime)this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate;this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this))}}},{key:"startTime",get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}}},{key:"_isFinished",get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)}},{key:"totalDuration",get:function(){return this._totalDuration}},{key:"_needsTick",get:function(){return this.pending||"running"===this.playState||!this._finishedFlag}},{key:"updatePromises",value:function(){var t;if(null!==(t=this.effect.target)&&void 0!==t&&t.destroyed)return this.readyPromise=void 0,this.finishedPromise=void 0,!1;var e=this.oldPlayState,n=this.pending?"pending":this.playState;return this.readyPromise&&n!==e&&("idle"===n?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===e?this.resolveReadyPromise():"pending"===n&&(this.readyPromise=void 0)),this.finishedPromise&&n!==e&&("idle"===n?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===n?this.resolveFinishedPromise():"finished"===e&&(this.finishedPromise=void 0)),this.oldPlayState=n,this.readyPromise||this.finishedPromise}},{key:"play",value:function(){this.updatePromises(),this._paused=!1,(this._isFinished||this._idle)&&(this.rewind(),this._startTime=null),this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this),-1===this.timeline.animations.indexOf(this)&&this.timeline.animations.push(this),this.updatePromises()}},{key:"pause",value:function(){this.updatePromises(),this.currentTime&&(this._holdTime=this.currentTime),this._isFinished||this._paused||this._idle?this._idle&&(this.rewind(),this._idle=!1):this.currentTimePending=!0,this._startTime=null,this._paused=!0,this.updatePromises()}},{key:"finish",value:function(){this.updatePromises(),this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this.currentTimePending=!1,this.timeline.applyDirtiedAnimation(this),this.updatePromises())}},{key:"cancel",value:function(){var t=this;if(this.updatePromises(),this._inEffect&&(this._inEffect=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=null,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new mp(null,this,this.currentTime,null);setTimeout(function(){t.oncancel(e)})}}},{key:"reverse",value:function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()}},{key:"updatePlaybackRate",value:function(t){this.playbackRate=t}},{key:"targetAnimations",value:function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()}},{key:"markTarget",value:function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)}},{key:"unmarkTarget",value:function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)}},{key:"tick",value:function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))}},{key:"rewind",value:function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}}},{key:"persist",value:function(){throw new Error(Cr)}},{key:"addEventListener",value:function(t,e,n){throw new Error(Cr)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(Cr)}},{key:"dispatchEvent",value:function(t){throw new Error(Cr)}},{key:"commitStyles",value:function(){throw new Error(Cr)}},{key:"ensureAlive",value:function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!(null===(t=this.effect)||void 0===t||!t.update(-1)):this._inEffect=!(null===(e=this.effect)||void 0===e||!e.update(this.currentTime));this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))}},{key:"tickCurrentTime",value:function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())}},{key:"fireEvents",value:function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new mp(null,this,this.currentTime,t);setTimeout(function(){e.onfinish&&e.onfinish(n)})}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new mp(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),bp=.1,Bp="function"==typeof Float32Array,Ep=function(t,e){return 1-3*e+3*t},xp=function(t,e){return 3*e-6*t},Cp=function(t){return 3*t},Mp=function(t,e,n){return((Ep(e,n)*t+xp(e,n))*t+Cp(e))*t},Fp=function(t,e,n){return 3*Ep(e,n)*t*t+2*xp(e,n)*t+Cp(e)},kp=function(t,e,n,r){if(!(t>=0&&t<=1&&n>=0&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=Bp?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Mp(o*bp,t,n);var A=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=bp;--o;var A=r+(e-i[o])/(i[o+1]-i[o])*bp,s=Fp(A,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=Fp(e,n,r);if(0===o)return e;e-=(Mp(e,n,r)-t)/o}return e}(e,A,t,n):0===s?A:function(t,e,n,r,i){var o,A,s=0;do{(o=Mp(A=e+(n-e)/2,r,i)-t)>0?n=A:e=A}while(Math.abs(o)>1e-7&&++s<10);return A}(e,r,r+bp,t,n)};return function(t){return 0===t||1===t?t:Mp(A(t),e,r)}},Sp=function(t){return Math.pow(t,2)},Qp=function(t){return Math.pow(t,3)},Up=function(t){return Math.pow(t,4)},Np=function(t){return Math.pow(t,5)},Tp=function(t){return Math.pow(t,6)},Op=function(t){return 1-Math.cos(t*Math.PI/2)},Ip=function(t){return 1-Math.sqrt(1-t*t)},Lp=function(t){return t*t*(3*t-2)},Pp=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},Dp=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?1:n,i=e[1],o=void 0===i?.5:i,A=ne(Number(r),1,10),s=ne(Number(o),.1,2);return 0===t||1===t?t:-A*Math.pow(2,10*(t-1))*Math.sin((t-1-s/(2*Math.PI)*Math.asin(1/A))*(2*Math.PI)/s)},Rp=function(t){var e=arguments.length>2?arguments[2]:void 0,n=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),r=n[0],i=void 0===r?1:r,o=n[1],A=void 0===o?100:o,s=n[2],a=void 0===s?10:s,c=n[3],l=void 0===c?0:c;i=ne(i,.1,1e3),A=ne(A,.1,1e3),a=ne(a,.1,1e3),l=ne(l,.1,1e3);var u=Math.sqrt(A/i),h=a/(2*Math.sqrt(A*i)),d=h<1?u*Math.sqrt(1-h*h):0,f=h<1?(h*u-l)/d:-l+u,g=e?e*t/1e3:t;return g=h<1?Math.exp(-g*h*u)*(1*Math.cos(d*g)+f*Math.sin(d*g)):(1+f*g)*Math.exp(-g*u),0===t||1===t?t:1-g},Hp=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?10:n;return("start"===e[1]?Math.ceil:Math.floor)(ne(t,0,1)*r)/r},_p=function(t){var e=m(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return kp(n,r,i,o)(t)},Gp=kp(.42,0,1,1),Kp=function(t){return function(e){return 1-t(1-e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],arguments.length>2?arguments[2]:void 0)}},jp=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},zp=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Vp={steps:Hp,"step-start":function(t){return Hp(t,[1,"start"])},"step-end":function(t){return Hp(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":_p,ease:function(t){return _p(t,[.25,.1,.25,1])},in:Gp,out:Kp(Gp),"in-out":jp(Gp),"out-in":zp(Gp),"in-quad":Sp,"out-quad":Kp(Sp),"in-out-quad":jp(Sp),"out-in-quad":zp(Sp),"in-cubic":Qp,"out-cubic":Kp(Qp),"in-out-cubic":jp(Qp),"out-in-cubic":zp(Qp),"in-quart":Up,"out-quart":Kp(Up),"in-out-quart":jp(Up),"out-in-quart":zp(Up),"in-quint":Np,"out-quint":Kp(Np),"in-out-quint":jp(Np),"out-in-quint":zp(Np),"in-expo":Tp,"out-expo":Kp(Tp),"in-out-expo":jp(Tp),"out-in-expo":zp(Tp),"in-sine":Op,"out-sine":Kp(Op),"in-out-sine":jp(Op),"out-in-sine":zp(Op),"in-circ":Ip,"out-circ":Kp(Ip),"in-out-circ":jp(Ip),"out-in-circ":zp(Ip),"in-back":Lp,"out-back":Kp(Lp),"in-out-back":jp(Lp),"out-in-back":zp(Lp),"in-bounce":Pp,"out-bounce":Kp(Pp),"in-out-bounce":jp(Pp),"out-in-bounce":zp(Pp),"in-elastic":Dp,"out-elastic":Kp(Dp),"in-out-elastic":jp(Dp),"out-in-elastic":zp(Dp),spring:Rp,"spring-in":Rp,"spring-out":Kp(Rp),"spring-in-out":jp(Rp),"spring-out-in":zp(Rp)},Wp=function(t){return t};function Yp(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Xp="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",qp=new RegExp("cubic-bezier\\(".concat(Xp,",").concat(Xp,",").concat(Xp,",").concat(Xp,"\\)")),$p=/steps\(\s*(\d+)\s*\)/,Zp=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function Jp(t){var e=qp.exec(t);if(e)return kp.apply(void 0,u(e.slice(1).map(Number)));var n=$p.exec(t);if(n)return Yp(Number(n[1]),0);var r=Zp.exec(t);return r?Yp(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Vp[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,function(t){return"-".concat(t.toLowerCase())})).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||Vp.linear}function tv(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}function ev(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e<Math.min(n.delay,r)?1:e>=Math.min(n.delay+t+n.endDelay,r)?2:3}(t,e,n),i=function(t,e,n,r,i){switch(r){case 1:return"backwards"===e||"both"===e?0:null;case 3:return n-i;case 2:return"forwards"===e||"both"===e?t:null;case 0:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,A=function(t,e,n,r,i){var o=i;return 0===t?1!==e&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var A=t===1/0?e%1:t%1;return 0!==A||2!==n||0===r||0===i&&0!==o||(A=1),A}(A,n.iterationStart,r,n.iterations,i,o),a=function(t,e,n,r){return 2===t&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,A),c=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,a,s);return n.currentIteration=a,n.progress=c,n.easingFunction(c)}function nv(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(rv(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:Jp(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var A=o,s=o+1,a=i[A].computedOffset,c=i[s].computedOffset,l=a,u=c;0===o&&(l=-1/0,0===c&&(s=A)),o===i.length-2&&(u=1/0,1===a&&(A=s)),n.push({applyFrom:l,applyTo:u,startOffset:i[A].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[A].easingFunction,property:r,interpolation:ov(r,i[A].value,i[s].value,e)})}return n.sort(function(t,e){return t.startOffset-e.startOffset}),n}(r,n);return function(t,e){if(null!==e)i.filter(function(t){return e>=t.applyFrom&&e<t.applyTo}).forEach(function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)});else for(var n in r)rv(n)&&t.setAttribute(n,null)}}function rv(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var iv=function(t,e,n){return function(r){var i=Av(t,e,r);return re(i)?i:n(i)}};function ov(t,e,n,r){var i=MA[t];if(i&&i.syntax&&i.int){var o=Ua.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var A=o.parser,s=A?A(e,r):e,a=A?A(n,r):n,c=o.mixer(s,a,r);if(c){var l=iv.apply(void 0,u(c));return function(t){return 0===t?e:1===t?n:l(t)}}}}return iv(!1,!0,function(t){return t?n:e})}function Av(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),A=[],s=0;s<o;s++)A.push(Av(t[s<r?s:r-1],e[s<i?s:i-1],n));return A}throw new Error("Mismatched interpolation arguments ".concat(t,":").concat(e))}var sv=function(){return a(function t(){A(this,t),this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Wp,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null},[{key:"easing",get:function(){return this._easing},set:function(t){this.easingFunction=Jp(t),this._easing=t}}])}();function av(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var A={};"offset"in t&&(A.offset=Number(t.offset)),"easing"in t&&(A.easing=t.easing),"composite"in t&&(A.composite=t.composite),e[o]=A}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort(function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)}),e}(t));for(var n=t.map(function(t){var n={};for(var r in null!=e&&e.composite&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n}),r=!0,i=-1/0,o=0;o<n.length;o++){var A=n[o].offset;if(Kt(A))r=!1;else{if(A<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=A}}return n=n.filter(function(t){return Number(t.offset)>=0&&Number(t.offset)<=1}),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),A=1;A<r;A++){var s=n[A].computedOffset;if(!Kt(s)&&!Kt(o)){for(var a=1;a<A-i;a++)n[i+a].computedOffset=o+(Number(s)-o)*a/(A-i);i=A,o=Number(s)}}}(),n}var cv="backwards|forwards|both|none".split("|"),lv="reverse|alternate|alternate-reverse".split("|");function uv(t,e){return function(t){var e=new sv;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach(function(n){if(void 0!==t[n]&&null!==t[n]&&"auto"!==t[n]){if(("number"==typeof e[n]||"duration"===n)&&("number"!=typeof t[n]||isNaN(t[n])))return;if("fill"===n&&-1===cv.indexOf(t[n]))return;if("direction"===n&&-1===lv.indexOf(t[n]))return;e[n]=t[n]}}):e.duration=t,e}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}))}var hv=function(){return a(function t(e,n,r){var i=this;A(this,t),this.composite="replace",this.iterationComposite="replace",this.target=e,this.timing=uv(r),this.timing.effect=this,this.timing.activeDuration=tv(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=av(n,this.timing),this.interpolations=nv(this.normalizedKeyframes,this.timing,this.target);var o=Ua.globalThis.Proxy;this.computedTiming=o?new o(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?i.animation&&i.animation.currentTime||null:"currentIteration"===e?i.animation&&"running"===i.animation.playState?t.currentIteration||0:null:"progress"===e?i.animation&&"running"===i.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing},[{key:"applyInterpolations",value:function(){this.interpolations(this.target,Number(this.timeFraction))}},{key:"update",value:function(t){return null!==t&&(this.timeFraction=ev(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)}},{key:"getKeyframes",value:function(){return this.normalizedKeyframes}},{key:"setKeyframes",value:function(t){this.normalizedKeyframes=av(t)}},{key:"getComputedTiming",value:function(){return this.computedTiming}},{key:"getTiming",value:function(){return this.timing}},{key:"updateTiming",value:function(t){var e=this;Object.keys(t||{}).forEach(function(n){e.timing[n]=t[n]})}}])}();function dv(t,e){return Number(t.id)-Number(e.id)}var fv=function(){return a(function t(e){var n=this;A(this,t),this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){n.currentTime=t,n.discardAnimations(),0===n.animations.length?n.timelineTicking=!1:n.requestAnimationFrame(n.webAnimationsNextTick)},this.processRafCallbacks=function(t){var e=n.rafCallbacks;n.rafCallbacks=[],t<Number(n.currentTime)&&(t=Number(n.currentTime)),n.animations.sort(dv),n.animations=n.tick(t,!0,n.animations)[0],e.forEach(function(e){e[1](t)}),n.applyPendingEffects()},this.document=e},[{key:"getAnimations",value:function(){return this.discardAnimations(),this.animations.slice()}},{key:"isTicking",value:function(){return this.inTick}},{key:"play",value:function(t,e,n){var r=new hv(t,e,n),i=new wp(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i}},{key:"applyDirtiedAnimation",value:function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(dv),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach(function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)}),this.applyPendingEffects()}}},{key:"restart",value:function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame(function(){}),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame}},{key:"destroy",value:function(){this.document.defaultView.cancelAnimationFrame(this.frameId)}},{key:"applyPendingEffects",value:function(){this.pendingEffects.forEach(function(t){null==t||t.applyInterpolations()}),this.pendingEffects=[]}},{key:"updateAnimationsPromises",value:function(){this.animationsWithPromises=this.animationsWithPromises.filter(function(t){return t.updatePromises()})}},{key:"discardAnimations",value:function(){this.updateAnimationsPromises(),this.animations=this.animations.filter(function(t){return"finished"!==t.playState&&"idle"!==t.playState})}},{key:"restartWebAnimationsNextTick",value:function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))}},{key:"rAF",value:function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e}},{key:"requestAnimationFrame",value:function(t){var e=this;return this.rAF(function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()})}},{key:"tick",value:function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var A=[],s=[],a=[],c=[];return n.forEach(function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(A.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?a.push(n):c.push(n)}),(r=this.pendingEffects).push.apply(r,A),(i=this.pendingEffects).push.apply(i,s),this.ticking&&this.requestAnimationFrame(function(){}),this.inTick=!1,[a,c]}}])}();Ua.EasingFunction=Jp,Ua.AnimationTimeline=fv;var gv=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=g(this,e,[].concat(r))).landmarks=[],t}return v(e,t),a(e,[{key:"rotate",value:function(t,e,n){if(this.relElevation=Fr(e),this.relAzimuth=Fr(t),this.relRoll=Fr(n),this.elevation+=this.relElevation,this.azimuth+=this.relAzimuth,this.roll+=this.relRoll,this.type===jr.EXPLORING){var r=Qt(St(),[1,0,0],Ur((this.rotateWorld?1:-1)*this.relElevation)),i=Qt(St(),[0,1,0],Ur((this.rotateWorld?1:-1)*this.relAzimuth)),o=Qt(St(),[0,0,1],Ur(this.relRoll)),A=Ut(St(),i,r);A=Ut(St(),A,o);var s=q(C(),A);I(this.matrix,this.matrix,[0,0,-this.distance]),O(this.matrix,this.matrix,s),I(this.matrix,this.matrix,[0,0,this.distance])}else{if(Math.abs(this.elevation)>90)return this;this.computeMatrix()}return this._getAxes(),this.type===jr.ORBITING||this.type===jr.EXPLORING?this._getPosition():this.type===jr.TRACKING&&this._getFocalPoint(),this._update(),this}},{key:"pan",value:function(t,e){var n=Sr(t,e,0),r=ct(this.position);return ft(r,r,pt(at(),this.right,n[0])),ft(r,r,pt(at(),this.up,n[1])),this._setPosition(r),this.triggerUpdate(),this}},{key:"dolly",value:function(t){var e=this.forward,n=ct(this.position),r=this.dollyingStep,i=this.distance+t*this.dollyingStep;return r=Math.max(Math.min(i,this.maxDistance),this.minDistance)-this.distance,n[0]+=r*e[0],n[1]+=r*e[1],n[2]+=r*e[2],this._setPosition(n),this.type===jr.ORBITING||this.type===jr.EXPLORING?this._getDistance():this.type===jr.TRACKING&&ft(this.focalPoint,n,this.distanceVector),this.triggerUpdate(),this}},{key:"cancelLandmarkAnimation",value:function(){void 0!==this.landmarkAnimationID&&this.canvas.cancelAnimationFrame(this.landmarkAnimationID)}},{key:"createLandmark",value:function(t){var e,n,r,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},A=o.position,s=void 0===A?this.position:A,a=o.focalPoint,c=void 0===a?this.focalPoint:a,l=o.roll,u=o.zoom,h=new Ua.CameraContribution;h.setType(this.type,void 0),h.setPosition(s[0],null!==(e=s[1])&&void 0!==e?e:this.position[1],null!==(n=s[2])&&void 0!==n?n:this.position[2]),h.setFocalPoint(c[0],null!==(r=c[1])&&void 0!==r?r:this.focalPoint[1],null!==(i=c[2])&&void 0!==i?i:this.focalPoint[2]),h.setRoll(null!=l?l:this.roll),h.setZoom(null!=u?u:this.zoom);var d={name:t,matrix:M(h.getWorldTransform()),right:ct(h.right),up:ct(h.up),forward:ct(h.forward),position:ct(h.getPosition()),focalPoint:ct(h.getFocalPoint()),distanceVector:ct(h.getDistanceVector()),distance:h.getDistance(),dollyingStep:h.getDollyingStep(),azimuth:h.getAzimuth(),elevation:h.getElevation(),roll:h.getRoll(),relAzimuth:h.relAzimuth,relElevation:h.relElevation,relRoll:h.relRoll,zoom:h.getZoom()};return this.landmarks.push(d),d}},{key:"gotoLandmark",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Jt(t)?this.landmarks.find(function(e){return e.name===t}):t;if(r){var i=re(n)?{duration:n}:n,o=i.easing,A=void 0===o?"linear":o,s=i.duration,a=void 0===s?100:s,c=i.easingFunction,l=void 0===c?void 0:c,u=i.onfinish,h=void 0===u?void 0:u,d=i.onframe,f=void 0===d?void 0:d;this.cancelLandmarkAnimation();var g,p=r.position,v=r.focalPoint,m=r.zoom,y=r.roll,w=l||Ua.EasingFunction(A),b=function(){e.setFocalPoint(v),e.setPosition(p),e.setRoll(y),e.setZoom(m),e.computeMatrix(),e.triggerUpdate(),null==h||h()};if(0===a)return b();var B=function(t){void 0===g&&(g=t);var n=t-g;if(n>=a)b();else{var r,i,o=w(n/a),A=at(),s=at();if(wt(A,e.focalPoint,v,o),wt(s,e.position,p,o),i=e.roll*(1-o)+y*o,r=e.zoom*(1-o)+m*o,e.setFocalPoint(A),e.setPosition(s),e.setRoll(i),e.setZoom(r),xt(A,v)+xt(s,p)<=.01&&void 0===m&&void 0===y)return b();e.computeMatrix(),e.triggerUpdate(),n<a&&(null==f||f(o),e.landmarkAnimationID=e.canvas.requestAnimationFrame(B))}};this.canvas.requestAnimationFrame(B)}}}])}(Xr);Ua.CameraContribution=gv;var pv=["body","startHead","endHead","startHeadOffset","endHeadOffset"],vv=["body","startHead","endHead","startHeadOffset","endHeadOffset"],mv=["body","startHead","endHead","startHeadOffset","endHeadOffset"],yv=function(t){function e(t){var n;A(this,e);var r=(n=g(this,e,[o(o({},t),{},{type:e.tag})])).attributes,i=r.body,s=r.startHead,a=r.endHead;r.startHeadOffset,r.endHeadOffset;var c=ar(r,pv);if(!i)throw new Error("Arrow's body is required");return n.body=i,n.appendChild(n.body),n.handleBodyAttributeChanged(n.body),s&&n.appendArrowHead(n.getArrowHeadType(s),!0),a&&n.appendArrowHead(n.getArrowHeadType(a),!1),n.applyArrowStyle(c,[n.body,n.startHead,n.endHead]),n}return v(e,t),a(e,[{key:"handleBodyAttributeChanged",value:function(t){var e=this;t.addEventListener(ea.ATTR_MODIFIED,function(t){var n=t.attrName;"x1"===n||"y1"===n?e.startHead&&e.transformArrowHead(e.startHead,!0):"x2"!==n&&"y2"!==n||e.endHead&&e.transformArrowHead(e.endHead,!1)})}},{key:"getBody",value:function(){return this.body}},{key:"getStartHead",value:function(){return this.startHead}},{key:"getEndHead",value:function(){return this.endHead}},{key:"attributeChangedCallback",value:function(t,e,n){if("opacity"===t||"strokeOpacity"===t||"stroke"===t||"lineWidth"===t||"increasedLineWidthForHitTesting"===t)this.applyArrowStyle(r({},t,n),[this.body,this.startHead,this.endHead]);else if("startHead"===t||"endHead"===t){var i="startHead"===t;if(this.destroyArrowHead(i),n){var o=this.attributes;o.body,o.startHead,o.endHead,o.startHeadOffset,o.endHeadOffset;var A=ar(o,vv);this.appendArrowHead(this.getArrowHeadType(n),i),this.applyArrowStyle(A,[i?this.startHead:this.endHead])}}else if("body"===t){var s=this.attributes;s.body,s.startHead,s.endHead,s.startHeadOffset,s.endHeadOffset;var a=ar(s,mv);this.body.destroy(),this.body=n,this.appendChild(this.body),this.applyArrowStyle(a,[this.body])}else"startHeadOffset"===t?this.moveArrowHeadAlongTangent(n,!0):"endHeadOffset"===t&&this.moveArrowHeadAlongTangent(n,!1)}},{key:"getArrowHeadType",value:function(t){return"boolean"==typeof t?"default":"custom"}},{key:"appendArrowHead",value:function(t,e){var n;n="default"===t?this.createDefaultArrowHead():e?this.attributes.startHead:this.attributes.endHead,this.transformArrowHead(n,e),n.setAttribute("zIndex",1),e?this.startHead=n:this.endHead=n,this.appendChild(n);var r=e?this.attributes.startHeadOffset:this.attributes.endHeadOffset;r&&this.moveArrowHeadAlongTangent(r,e)}},{key:"transformArrowHead",value:function(t,e){var n,r=at(),i=0,o=0,A=0,s=0,a=this.body&&this.body.nodeName;if(a===cr.LINE){var c=this.body.attributes,l=c.x1,u=c.x2,h=c.y1,d=c.y2;i=e?u:l,o=e?l:u,A=e?d:h,s=e?h:d}else if(a===cr.POLYLINE){var f=this.body.attributes.points,g=f.length;i=e?f[1][0]:f[g-2][0],A=e?f[1][1]:f[g-2][1],o=e?f[0][0]:f[g-1][0],s=e?f[0][1]:f[g-1][1]}else if(a===cr.PATH){var p=m(this.getTangent(this.body,e),2),v=p[0],y=p[1];i=v[0],A=v[1],o=y[0],s=y[1]}var w=i-o,b=A-s;n=Math.atan2(b,w),r=ut(o,s,0),e?(this.startHeadPosition=r,this.startHeadRad=n):(this.endHeadPosition=r,this.endHeadRad=n),t.setLocalPosition(r),t.setLocalEulerAngles(180*n/Math.PI+t.getLocalEulerAngles())}},{key:"moveArrowHeadAlongTangent",value:function(t,e){var n=e?this.startHead:this.endHead;n&&n.setLocalPosition(Et(at(),e?this.startHeadPosition:this.endHeadPosition,ut(Math.cos(e?this.startHeadRad:this.endHeadRad)*t,Math.sin(e?this.startHeadRad:this.endHeadRad)*t,0))),this.body}},{key:"destroyArrowHead",value:function(t){t&&this.startHead&&(this.startHead.destroy(),this.startHead=void 0),!t&&this.endHead&&(this.endHead.destroy(),this.endHead=void 0)}},{key:"getTangent",value:function(t,e){return e?t.getStartTangent():t.getEndTangent()}},{key:"createDefaultArrowHead",value:function(){var t=this.attributes,e=t.stroke,n=t.lineWidth,r=Math.sin,i=Math.cos,o=Math.PI,A=10*i(o/6);return new nc({style:{d:"M".concat(A/2,",").concat(10*r(o/6)," L-").concat(A/2,",0 L").concat(A/2,",-").concat(10*r(o/6)),stroke:e,lineWidth:n,transformOrigin:"center"}})}},{key:"applyArrowStyle",value:function(t,e){var n=t.opacity,r=t.stroke,i=t.strokeOpacity,o=t.lineWidth,A=t.increasedLineWidthForHitTesting;e.forEach(function(t){t&&(Kt(n)||(t.style.opacity=n),Kt(r)||(t.style.stroke=r),Kt(i)||(t.style.strokeOpacity=i),Kt(o)||(t.style.lineWidth=o),Kt(A)||(t.style.increasedLineWidthForHitTesting=A))})}}])}(Wa);yv.tag="arrow",yv.PARSED_STYLE_LIST=new Set([].concat(u(Wa.PARSED_STYLE_LIST),["body","startHead","endHead","startHeadOffset","endHeadOffset","stroke","lineWidth","opacity","strokeOpacity"]));var wv=Math.PI,bv=2*wv,Bv=Math.sin,Ev=Math.cos,xv=Math.acos,Cv=Math.atan2,Mv=Math.sqrt,Fv=Math.max,kv=Math.min,Sv=1e-4;[{name:"sr",inherits:!1,interpolable:!0,syntax:ri.LENGTH_PERCENTAGE},{name:"sr0",inherits:!1,interpolable:!0,syntax:ri.LENGTH_PERCENTAGE},{name:"startAngle",inherits:!1,interpolable:!0,syntax:ri.ANGLE},{name:"endAngle",inherits:!1,interpolable:!0,syntax:ri.ANGLE}].forEach(function(t){uc(t)});var Qv=function(t,e,n,r){return{x:t+n*Math.cos(r),y:e+n*Math.sin(r)}};function Uv(t,e,n,r,i,o,A){var s=t-n,a=e-r,c=o/Mv(s*s+a*a),l=c*a,u=-c*s,h=t+l,d=e+u,f=n+l,g=r+u,p=(h+f)/2,v=(d+g)/2,m=f-h,y=g-d,w=m*m+y*y,b=i-o,B=h*g-f*d,E=(y<0?-1:1)*Mv(Fv(0,b*b*w-B*B)),x=(B*y-m*E)/w,C=(-B*m-y*E)/w,M=(B*y+m*E)/w,F=(-B*m+y*E)/w,k=x-p,S=C-v,Q=M-p,U=F-v;return k*k+S*S>Q*Q+U*U&&(x=M,C=F),{cx:x,cy:C,x0:-l,y0:-u,x1:x*(i/b-1),y1:C*(i/b-1)}}function Nv(t,e){return(e=e<0&&t>=0?e+bv:e)-t<=wv?0:1}var Tv=function(t){function e(t){var n;return A(this,e),(n=g(this,e,[t])).updatePath(),n}return v(e,t),a(e,[{key:"setAttribute",value:function(t,n,r){Un(e,"setAttribute",this)([t,n,r]),["startAngle","endAngle","sr","sr0","radius"].indexOf(t)>-1&&this.updatePath()}},{key:"updatePath",value:function(){var t=this.parsedStyle,n=t.x,r=t.y,i=t.startAngle,o=t.endAngle,A=t.sr,s=t.sr0,a=t.radius,c=this.createPath(n,r,i?Ur(i):0,o?Ur(o):2*Math.PI,A||0,s||0,a||[0,0,0,0]);Un(e,"setAttribute",this)(["d",c])}},{key:"createPath",value:function(t,e,n,r,i,o,A){if(!(i<=0)){var s=Qv(t,e,i,n),a=Qv(t,e,i,r),c=Qv(t,e,o,n),l=Qv(t,e,o,r);if(ie(r-n,2*Math.PI)){var u=Qv(t,e,i,n+Math.PI),h=Qv(t,e,o,n+Math.PI),d=[["M",s.x,s.y],["A",i,i,0,1,1,u.x,u.y],["A",i,i,0,1,1,a.x,a.y],["M",c.x,c.y]];return o&&(d.push(["A",o,o,0,1,0,h.x,h.y]),d.push(["A",o,o,0,1,0,l.x,l.y])),d.push(["M",s.x,s.y]),d.push(["Z"]),d}var f=r-n,g=i*Ev(n),p=i*Bv(n),v=o*Ev(r),y=o*Bv(r),w=i*Ev(r),b=i*Bv(r),B=o*Ev(n),E=o*Bv(n),x=m(A,4),C=x[0],M=x[1],F=x[2],k=x[3],S=(i-o)/2,Q=kv(S,C),U=kv(S,M),N=kv(S,F),T=kv(S,k),O=Fv(Q,U),I=Fv(N,T),L=O,P=I;if((O>Sv||I>Sv)&&f<wv){var D=function(t,e,n,r,i,o,A,s){var a=n-t,c=r-e,l=A-i,u=s-o,h=u*a-l*c;if(!(h*h<Sv))return[t+(h=(l*(e-o)-u*(t-i))/h)*a,e+h*c]}(g,p,B,E,w,b,v,y);if(D){var R=g-D[0],H=p-D[1],_=w-D[0],G=b-D[1],K=1/Bv(xv((R*_+H*G)/(Mv(R*R+H*H)*Mv(_*_+G*G)))/2),j=Mv(D[0]*D[0]+D[1]*D[1]);L=kv(O,(i-j)/(K+1)),P=kv(I,(o-j)/(K-1))}}var z=Nv(n,r),V=[];if(L>Sv){var W=kv(C,L),Y=kv(M,L),X=Uv(B,E,g,p,i,W),q=Uv(w,b,v,y,i,Y);if(V.push(["M",t+X.cx+X.x0,e+X.cy+X.y0]),L<O&&W===Y){var $=Cv(X.y0,X.x0),Z=Cv(q.y0,q.x0);V.push(["A",L,L,0,Nv($,Z),1,t+q.cx+q.x0,e+q.cy+q.y0])}else{if(W>0){var J=Cv(X.y0,X.x0),tt=Cv(X.y1,X.x1),et=Qv(t,e,i,tt);V.push(["A",W,W,0,Nv(J,tt),1,et.x,et.y])}var nt=Cv(X.cy+X.y1,X.cx+X.x1),rt=Cv(q.cy+q.y1,q.cx+q.x1),it=Qv(t,e,i,rt);if(V.push(["A",i,i,0,Nv(nt,rt),1,it.x,it.y]),Y>0){var ot=Cv(q.y1,q.x1),At=Cv(q.y0,q.x0);V.push(["A",Y,Y,0,Nv(ot,At),1,t+q.cx+q.x0,e+q.cy+q.y0])}}}else V.push(["M",s.x,s.y]),V.push(["A",i,i,0,z,1,a.x,a.y]);if(o<Sv)V.push(["L",l.x,l.y]);else if(P>Sv){var st=kv(k,P),at=kv(F,P),ct=Uv(v,y,0,0,o-i,at),lt=Uv(0,0,B,E,o-i,st);if(V.push(["L",t+ct.cx+ct.x0,e+ct.cy+ct.y0]),P<I&&st===at){var ut=Cv(ct.y0,ct.x0),ht=Cv(lt.y0,lt.x0),dt=Qv(t,e,o,ht);V.push(["A",L,L,0,Nv(ut,ht),1,dt.x,dt.y])}else{if(at>0){var ft=Cv(ct.y0,ct.x0),gt=Cv(ct.y1,ct.x1),pt=Qv(t,e,o-i,gt);V.push(["A",at,at,0,Nv(ft,gt),1,pt.x,pt.y])}var vt=Cv(ct.cy+ct.y1,ct.cx+ct.x1),mt=Cv(lt.cy+lt.y1,lt.cx+lt.x1),yt=Qv(t,e,o,mt);if(V.push(["A",o,o,0,Nv(mt,vt),0,yt.x,yt.y]),V.push(["L",yt.x,yt.y]),st>0){var wt=Cv(lt.y1,lt.x1),bt=Cv(lt.y0,lt.x0);V.push(["A",st,st,0,Nv(wt,bt),1,t+lt.cx+lt.x0,e+lt.cy+lt.y0])}}}else V.push(["L",l.x,l.y]),V.push(["A",o,o,0,z,0,c.x,c.y]);return V.push(["Z"]),V}}}])}(nc);Tv.PARSED_STYLE_LIST=new Set([].concat(u(nc.PARSED_STYLE_LIST),["x","y","sr","sr0","radius","startAngle","endAngle"]));const Ov={duration:500},Iv={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var Lv,Pv,Dv,Rv,Hv,_v,Gv,Kv,jv;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(Lv||(Lv={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(Pv||(Pv={})),t.CanvasEvent=void 0,function(t){t.CLICK="canvas:click",t.DBLCLICK="canvas:dblclick",t.POINTER_OVER="canvas:pointerover",t.POINTER_LEAVE="canvas:pointerleave",t.POINTER_ENTER="canvas:pointerenter",t.POINTER_MOVE="canvas:pointermove",t.POINTER_OUT="canvas:pointerout",t.POINTER_DOWN="canvas:pointerdown",t.POINTER_UP="canvas:pointerup",t.CONTEXT_MENU="canvas:contextmenu",t.DRAG_START="canvas:dragstart",t.DRAG="canvas:drag",t.DRAG_END="canvas:dragend",t.DRAG_ENTER="canvas:dragenter",t.DRAG_OVER="canvas:dragover",t.DRAG_LEAVE="canvas:dragleave",t.DROP="canvas:drop",t.WHEEL="canvas:wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.ComboEvent=void 0,(Dv=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",Dv.DBLCLICK="combo:dblclick",Dv.POINTER_OVER="combo:pointerover",Dv.POINTER_LEAVE="combo:pointerleave",Dv.POINTER_ENTER="combo:pointerenter",Dv.POINTER_MOVE="combo:pointermove",Dv.POINTER_OUT="combo:pointerout",Dv.POINTER_DOWN="combo:pointerdown",Dv.POINTER_UP="combo:pointerup",Dv.CONTEXT_MENU="combo:contextmenu",Dv.DRAG_START="combo:dragstart",Dv.DRAG="combo:drag",Dv.DRAG_END="combo:dragend",Dv.DRAG_ENTER="combo:dragenter",Dv.DRAG_OVER="combo:dragover",Dv.DRAG_LEAVE="combo:dragleave",Dv.DROP="combo:drop",t.CommonEvent=void 0,(Rv=t.CommonEvent||(t.CommonEvent={})).CLICK="click",Rv.DBLCLICK="dblclick",Rv.POINTER_OVER="pointerover",Rv.POINTER_LEAVE="pointerleave",Rv.POINTER_ENTER="pointerenter",Rv.POINTER_MOVE="pointermove",Rv.POINTER_OUT="pointerout",Rv.POINTER_DOWN="pointerdown",Rv.POINTER_UP="pointerup",Rv.CONTEXT_MENU="contextmenu",Rv.DRAG_START="dragstart",Rv.DRAG="drag",Rv.DRAG_END="dragend",Rv.DRAG_ENTER="dragenter",Rv.DRAG_OVER="dragover",Rv.DRAG_LEAVE="dragleave",Rv.DROP="drop",Rv.KEY_DOWN="keydown",Rv.KEY_UP="keyup",Rv.WHEEL="wheel",Rv.PINCH="pinch",t.ContainerEvent=void 0,(Hv=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",Hv.KEY_UP="keyup",t.EdgeEvent=void 0,(_v=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",_v.DBLCLICK="edge:dblclick",_v.POINTER_OVER="edge:pointerover",_v.POINTER_LEAVE="edge:pointerleave",_v.POINTER_ENTER="edge:pointerenter",_v.POINTER_MOVE="edge:pointermove",_v.POINTER_OUT="edge:pointerout",_v.POINTER_DOWN="edge:pointerdown",_v.POINTER_UP="edge:pointerup",_v.CONTEXT_MENU="edge:contextmenu",_v.DRAG_ENTER="edge:dragenter",_v.DRAG_OVER="edge:dragover",_v.DRAG_LEAVE="edge:dragleave",_v.DROP="edge:drop",t.GraphEvent=void 0,(Gv=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",Gv.AFTER_CANVAS_INIT="aftercanvasinit",Gv.BEFORE_SIZE_CHANGE="beforesizechange",Gv.AFTER_SIZE_CHANGE="aftersizechange",Gv.BEFORE_ELEMENT_CREATE="beforeelementcreate",Gv.AFTER_ELEMENT_CREATE="afterelementcreate",Gv.BEFORE_ELEMENT_UPDATE="beforeelementupdate",Gv.AFTER_ELEMENT_UPDATE="afterelementupdate",Gv.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",Gv.AFTER_ELEMENT_DESTROY="afterelementdestroy",Gv.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",Gv.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",Gv.BEFORE_DRAW="beforedraw",Gv.AFTER_DRAW="afterdraw",Gv.BEFORE_RENDER="beforerender",Gv.AFTER_RENDER="afterrender",Gv.BEFORE_ANIMATE="beforeanimate",Gv.AFTER_ANIMATE="afteranimate",Gv.BEFORE_LAYOUT="beforelayout",Gv.AFTER_LAYOUT="afterlayout",Gv.BEFORE_STAGE_LAYOUT="beforestagelayout",Gv.AFTER_STAGE_LAYOUT="afterstagelayout",Gv.BEFORE_TRANSFORM="beforetransform",Gv.AFTER_TRANSFORM="aftertransform",Gv.BATCH_START="batchstart",Gv.BATCH_END="batchend",Gv.BEFORE_DESTROY="beforedestroy",Gv.AFTER_DESTROY="afterdestroy",Gv.BEFORE_RENDERER_CHANGE="beforerendererchange",Gv.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(Kv=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",Kv.REDO="redo",Kv.CANCEL="cancel",Kv.ADD="add",Kv.CLEAR="clear",Kv.CHANGE="change",t.NodeEvent=void 0,(jv=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",jv.DBLCLICK="node:dblclick",jv.POINTER_OVER="node:pointerover",jv.POINTER_LEAVE="node:pointerleave",jv.POINTER_ENTER="node:pointerenter",jv.POINTER_MOVE="node:pointermove",jv.POINTER_OUT="node:pointerout",jv.POINTER_DOWN="node:pointerdown",jv.POINTER_UP="node:pointerup",jv.CONTEXT_MENU="node:contextmenu",jv.DRAG_START="node:dragstart",jv.DRAG="node:drag",jv.DRAG_END="node:dragend",jv.DRAG_ENTER="node:dragenter",jv.DRAG_OVER="node:dragover",jv.DRAG_LEAVE="node:dragleave",jv.DROP="node:drop";const zv="combo",Vv="tree";var Wv;t.ExtensionCategory=void 0,(Wv=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",Wv.EDGE="edge",Wv.COMBO="combo",Wv.THEME="theme",Wv.PALETTE="palette",Wv.LAYOUT="layout",Wv.BEHAVIOR="behavior",Wv.PLUGIN="plugin",Wv.ANIMATION="animation",Wv.TRANSFORM="transform",Wv.SHAPE="shape";const Yv={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Xv(t,e){var n;const r=null===(n=Yv[t])||void 0===n?void 0:n[e];if(r)return r}const qv="5.1.1";function $v(t){return`[G6 v${qv}] ${t}`}const Zv=t=>{console.warn($v(t))};function Jv(e){const{theme:n}=e;if(!n)return{};const r=Xv(t.ExtensionCategory.THEME,n);return r||(Zv(`The theme of ${n} is not registered.`),{})}function tm(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map(t=>t.finished)]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach(t=>{var r;return null===(r=t[e])||void 0===r?void 0:r.call(t,...n)})},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach(t=>{t[e]=n}),Reflect.set(t,e,n))})}function em(t){const e=t.reduce((t,e)=>(Object.entries(e).forEach(([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)}),t),{});Object.entries(e).forEach(([n,r])=>{(r.length!==t.length||r.some(t=>Kt(t))||r.every(t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&xe(t,r[0])))&&delete e[n]});const n=Object.entries(e).reduce((t,[e,n])=>(n.forEach((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}}),t),[]);return 0!==t.length&&0===n.length&&n.push({_:0},{_:0}),n}function nm(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function rm(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},Ov);return zt(n)&&Object.assign(r,n),zt(e)&&Object.assign(r,e),r}function im(e,n,r,i){var o,A;const{animation:s}=e;if(!1===s||!1===i)return[];const a=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===a)return[];const c=null==a?void 0:a[r];if(!1===c)return[];const l=null===(A=Jv(e)[n])||void 0===A?void 0:A.animation,u=(e=[])=>function(e){if("string"==typeof e){return Xv(t.ExtensionCategory.ANIMATION,e)||(Zv(`The animation of ${e} is not registered.`),[])}return e}(e).map(t=>Object.assign(Object.assign(Object.assign(Object.assign({},Iv),zt(s)&&s),t),zt(i)&&i));if(c)return u(c);if(!l)return[];const h=l[r];return!1===h?[]:u(h)}function om(t,e,n,r=[]){if(!r&&0===t&&0===e&&0===n)return null;if(Array.isArray(r)){let i=-1;const o=[];for(let A=0;A<r.length;A++){const s=r[A];if("translate"===s[0]){if(s[1]===t&&s[2]===e)return null;i=A,o.push(["translate",t,e])}else if("translate3d"===s[0]){if(s[1]===t&&s[2]===e&&s[3]===n)return null;i=A,o.push(["translate3d",t,e,null!=n?n:0])}else o.push(s)}return-1===i&&o.splice(0,0,re(n)?["translate3d",t,e,null!=n?n:0]:["translate",t,e]),0===o.length?null:o}const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Am=(t,e,n)=>{if(!n.length)return null;const[r,i]=e;let o;const A=n.map(e=>{var{fields:n,shape:A,states:s}=e,a=Pe(e,["fields","shape","states"]);const c=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const A=`get${ce(e)}Style`,s=(null===(n=null==t?void 0:t[A])||void 0===n?void 0:n.bind(t))||(t=>t);return{shape:o,fromStyle:(null==s?void 0:s(r))||{},toStyle:(null==s?void 0:s(i))||{}}}return{shape:t,fromStyle:r,toStyle:i}})(A);if(!c)return null;const{shape:l,fromStyle:u,toStyle:h}=c,d=[{},{}];if(n.forEach(t=>{var e,n;Object.assign(d[0],{[t]:null!==(e=u[t])&&void 0!==e?e:nm(t)}),Object.assign(d[1],{[t]:null!==(n=h[t])&&void 0!==n?n:nm(t)})}),d.some(t=>Object.keys(t).some(t=>["x","y","z"].includes(t)))){const{x:t=0,y:e=0,z:n,transform:r=""}=l.attributes||{};d.forEach(i=>{var o,A,s;i.transform=om(null!==(o=i.x)&&void 0!==o?o:t,null!==(A=i.y)&&void 0!==A?A:e,null!==(s=i.z)&&void 0!==s?s:n,r)})}const f=l.animate(em(d),a);return void 0===A&&(o=f),f}).filter(Boolean),s=o||(null==A?void 0:A[0]);return s?tm(s,A.filter(t=>t!=t)):null},sm=[{fields:["x","y"]}],am=sm,cm=[{fields:["sourceNode","targetNode"]}],lm=cm,um=[{fields:["childrenNode","x","y"]}],hm=um;function dm(t){return 3===t.length}function fm(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every(t=>"number"==typeof t)}function gm(t,e,n){return t>=e&&t<=n}function pm(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function vm(t=0){const e=pm(t);return e[0]+e[2]}function mm(t){return t.max[0]-t.min[0]}function ym(t){return t.max[1]-t.min[1]}function wm(t){return[mm(t),ym(t)]}function bm(t,e){const n=fm(t)?Bm(t):t.getShape("key").getBounds();return e?Em(n,e):n}function Bm(t){const[e,n,r=0]=t,i=new yr;return i.setMinMax([e,n,r],[e,n,r]),i}function Em(t,e){const[n,r,i,o]=pm(e),[A,s,a]=t.min,[c,l,u]=t.max,h=new yr;return h.setMinMax([A-o,s-n,a],[c+r,l+i,u]),h}function xm(t){if(0===t.length)return new yr;if(1===t.length)return t[0];const e=new yr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function Cm(t,e){return gm(t[0],e.min[0],e.max[0])&&gm(t[1],e.min[1],e.max[1])}function Mm(t,e,n=!1){const{min:[r,i],max:[o,A]}=e,s=(t[1]===i||t[1]===A)&&(n||gm(t[0],r,o)),a=(t[0]===r||t[0]===o)&&(n||gm(t[1],i,A));return s||a}function Fm(t,e){const{center:n}=e;return t[0]===n[0]&&t[1]===n[1]}function km(t,e){const[n,r]=t,[i,o]=e.min,[A,s]=e.max,a=n-i,c=A-n,l=r-o,u=s-r,h=Math.min(a,c,l,u);return h===a?"left":h===c?"right":h===l?"top":h===u?"bottom":"left"}function Sm(t,e){const n=ge(t);if(Cm(t,e)){switch(km(t,e)){case"left":n[0]=e.min[0];break;case"right":n[0]=e.max[0];break;case"top":n[1]=e.min[1];break;case"bottom":n[1]=e.max[1]}}else{const[r,i]=t,[o,A]=e.min,[s,a]=e.max;n[0]=gm(r,o,s)?r:r<o?o:s,n[1]=gm(i,A,a)?i:i<A?A:a}return n}var Qm=function(t,e){return t===e},Um=function(){function t(t,e){void 0===e&&(e=null),this.value=t,this.next=e}return t.prototype.toString=function(t){return t?t(this.value):"".concat(this.value)},t}(),Nm=function(){function t(t){void 0===t&&(t=Qm),this.head=null,this.tail=null,this.compare=t}return t.prototype.prepend=function(t){var e=new Um(t,this.head);return this.head=e,this.tail||(this.tail=e),this},t.prototype.append=function(t){var e=new Um(t);return this.head?(this.tail.next=e,this.tail=e,this):(this.head=e,this.tail=e,this)},t.prototype.delete=function(t){if(!this.head)return null;for(var e=null;this.head&&this.compare(this.head.value,t);)e=this.head,this.head=this.head.next;var n=this.head;if(null!==n)for(;n.next;)this.compare(n.next.value,t)?(e=n.next,n.next=n.next.next):n=n.next;return this.compare(this.tail.value,t)&&(this.tail=n),e},t.prototype.find=function(t){var e=t.value,n=void 0===e?void 0:e,r=t.callback,i=void 0===r?void 0:r;if(!this.head)return null;for(var o=this.head;o;){if(i&&i(o.value))return o;if(void 0!==n&&this.compare(o.value,n))return o;o=o.next}return null},t.prototype.deleteTail=function(){var t=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,t;for(var e=this.head;e.next;)e.next.next?e=e.next:e.next=null;return this.tail=e,t},t.prototype.deleteHead=function(){if(!this.head)return null;var t=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),t},t.prototype.fromArray=function(t){var e=this;return t.forEach(function(t){return e.append(t)}),this},t.prototype.toArray=function(){for(var t=[],e=this.head;e;)t.push(e),e=e.next;return t},t.prototype.reverse=function(){for(var t=this.head,e=null,n=null;t;)n=t.next,t.next=e,e=t,t=n;this.tail=this.head,this.head=e},t.prototype.toString=function(t){return void 0===t&&(t=void 0),this.toArray().map(function(e){return e.toString(t)}).toString()},t}(),Tm=function(t,e,n){void 0===e&&(e=[]);var r=e.filter(function(e){return e.source===t||e.target===t});if("target"===n){return r.filter(function(e){return e.source===t}).map(function(t){return t.target})}if("source"===n){return r.filter(function(e){return e.target===t}).map(function(t){return t.source})}return r.map(function(e){return e.source===t?e.target:e.source})},Om={}.toString,Im=function(t,e){return Om.call(t)==="[object "+e+"]"},Lm=function(t){return Im(t,"Function")},Pm=function(t){return Array.isArray?Array.isArray(t):Im(t,"Array")};var Dm,Rm=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return function(t,e){var n,r;if(t)if(Pm(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var A in t)if(t.hasOwnProperty(A)&&!1===e(t[A],A))break}(t,function(n,r){Lm(t)&&"prototype"===r||e.push(n)}),e};!function(t,e){if(!Lm(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],A=n.cache;if(A.has(o))return A.get(o);var s=t.apply(this,r);return A.set(o,s),s};n.cache=new Map}(function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,A=e.fontVariant;return Dm||(Dm=document.createElement("canvas").getContext("2d")),Dm.font=[o,A,i,n+"px",r].join(" "),Dm.measureText(function(t){return Im(t,"String")}(t)?t:"").width},function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],A=0,s=o.length;A<s;A++,i++)r[i]=o[A];return r}([t],Rm(e)).join("")});function Hm(t,e,n,r){if(t===e)return[t];if(r[e])return r[e];for(var i=[],o=0,A=n[e];o<A.length;o++){var s=Hm(t,A[o],n,r);if(!s)return;for(var a=0,c=s;a<c.length;a++){var l=c[a];Pm(l)?i.push(_e(_e([],l,!0),[e],!1)):i.push([l,e])}}return r[e]=i,r[e]}var _m,Gm=function(t,e,n,r,i){var o=function(t,e,n,r){var i=t.nodes,o=void 0===i?[]:i,A=t.edges,s=void 0===A?[]:A,a={},c={},l={};o.forEach(function(t,n){var r=t.id;c[r]=1/0,r===e&&(c[r]=0)});for(var u=o.length,h=function(t){var e=function(t,e,n){for(var r,i=1/0,o=0;o<e.length;o++){var A=e[o].id;!n[A]&&t[A]<=i&&(i=t[A],r=e[o])}return r}(c,o,a),i=e.id;if(a[i]=!0,c[i]===1/0)return"continue";var A=[];A=n?function(t,e){return e.filter(function(e){return e.source===t})}(i,s):function(t,e){return e.filter(function(e){return e.source===t||e.target===t})}(i,s),A.forEach(function(t){var n=t.target,o=t.source,A=n===i?o:n,s=r&&t[r]?t[r]:1;c[A]>c[e.id]+s?(c[A]=c[e.id]+s,l[A]=[e.id]):c[A]===c[e.id]+s&&l[A].push(e.id)})},d=0;d<u;d++)h();l[e]=[e];var f={};for(var g in c)c[g]!==1/0&&Hm(e,g,l,f);var p={};for(var g in f)p[g]=f[g][0];return{length:c,path:p,allPath:f}}(t,e,r,i),A=o.length,s=o.path,a=o.allPath;return{length:A[n],path:s[n],allPath:a[n]}};!function(t){t.EuclideanDistance="euclideanDistance"}(_m||(_m={}));function Km(t){if(void 0!==t.id)return t.id;if(void 0!==t.source&&void 0!==t.target)return`${t.source}-${t.target}`;throw new Error($v("The datum does not have available id."))}function jm(t){return t.combo}function zm(t,e){const n={nodes:(t.nodes||[]).map(Km),edges:(t.edges||[]).map(Km),combos:(t.combos||[]).map(Km)};return e?Object.values(n).flat():n}!function(){function t(t){void 0===t&&(t=10),this.linkedList=new Nm,this.maxStep=t}Object.defineProperty(t.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),t.prototype.isEmpty=function(){return!this.linkedList.head},t.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},t.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},t.prototype.push=function(t){this.linkedList.prepend(t),this.length>this.maxStep&&this.linkedList.deleteTail()},t.prototype.pop=function(){var t=this.linkedList.deleteHead();return t?t.value:null},t.prototype.toArray=function(){return this.linkedList.toArray().map(function(t){return t.value})},t.prototype.clear=function(){for(;!this.isEmpty();)this.pop()}}();const Vm=(t,e,n)=>{var r;switch(n.type){case"degree":{const i=new Map;return null===(r=t.nodes)||void 0===r||r.forEach(t=>{const r=e(Km(t),n.direction).length;i.set(Km(t),r)}),i}case"betweenness":return Ym(t,n.directed,n.weightPropertyName);case"closeness":return Xm(t,n.directed,n.weightPropertyName);case"eigenvector":return $m(t,n.directed);case"pagerank":return qm(t,n.epsilon,n.linkProb);default:return Wm(t)}},Wm=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach(t=>{n.set(Km(t),0)}),n},Ym=(t,e,n)=>{const r=Wm(t),{nodes:i=[]}=t;return i.forEach(o=>{i.forEach(i=>{if(o!==i){const{allPath:A}=Gm(t,Km(o),Km(i),e,n),s=A.length;A.flat().forEach(t=>{t!==Km(o)&&t!==Km(i)&&r.set(t,r.get(t)+1/s)})}})}),r},Xm=(t,e,n)=>{const r=new Map,{nodes:i=[]}=t;return i.forEach(o=>{const A=i.reduce((r,i)=>{if(o!==i){const{length:A}=Gm(t,Km(o),Km(i),e,n);r+=A}return r},0);r.set(Km(o),1/A)}),r},qm=(t,e,n)=>{var r;const i=new Map,o=function(t,e,n){"number"!=typeof e&&(e=1e-6),"number"!=typeof n&&(n=.85);for(var r,i=1,o=0,A=1e3,s=t.nodes,a=void 0===s?[]:s,c=t.edges,l=void 0===c?[]:c,u=a.length,h={},d={},f=0;f<u;++f)h[p=(b=a[f]).id]=1/u,d[p]=1/u;for(var g=function(t){var e={},n=t.nodes,r=void 0===n?[]:n,i=t.edges,o=void 0===i?[]:i;return r.forEach(function(t){e[t.id]={degree:0,inDegree:0,outDegree:0}}),o.forEach(function(t){e[t.source].degree++,e[t.source].outDegree++,e[t.target].degree++,e[t.target].inDegree++}),e}(t);A>0&&i>e;){for(o=0,f=0;f<u;++f){var p=(b=a[f]).id;if(r=0,0===g[b.id].inDegree)h[p]=0;else{for(var v=Tm(p,l,"source"),m=0;m<v.length;++m){var y=v[m],w=g[y].outDegree;w>0&&(r+=d[y]/w)}h[p]=n*r,o+=h[p]}}for(o=(1-o)/u,i=0,f=0;f<u;++f){var b;r=h[p=(b=a[f]).id]+o,i+=Math.abs(r-d[p]),d[p]=r}A-=1}return d}(t,e,n);return null===(r=t.nodes)||void 0===r||r.forEach(t=>{i.set(Km(t),o[Km(t)])}),i},$m=(t,e)=>{const{nodes:n=[]}=t,r=Zm(t,e),i=Jm(r,n.length),o=new Map;return n.forEach((t,e)=>{o.set(Km(t),i[e])}),o},Zm=(t,e)=>{const{nodes:n=[],edges:r=[]}=t,i=Array(n.length).fill(null).map(()=>Array(n.length).fill(0));return r.forEach(({source:t,target:r})=>{const o=n.findIndex(e=>Km(e)===t),A=n.findIndex(t=>Km(t)===r);e?i[o][A]=1:(i[o][A]=1,i[A][o]=1)}),i},Jm=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let A=0;A<n&&o>r;A++){const n=Array(e).fill(0);for(let r=0;r<e;r++)for(let o=0;o<e;o++)n[r]+=t[r][o]*i[o];const r=Math.sqrt(n.reduce((t,e)=>t+e*e,0));for(let t=0;t<e;t++)n[t]/=r;o=Math.sqrt(n.reduce((t,e,n)=>t+(e-i[n])*e,0)),i=n}return i};function ty(t,e,n,r=xe){const i=new Map(t.map(t=>[n(t),t])),o=new Map(e.map(t=>[n(t),t])),A=new Set(i.keys()),s=new Set(o.keys()),a=[],c=[],l=[],u=[];return s.forEach(t=>{A.has(t)?r(i.get(t),o.get(t))?u.push(o.get(t)):c.push(o.get(t)):a.push(o.get(t))}),A.forEach(t=>{s.has(t)||l.push(i.get(t))}),{enter:a,exit:l,keep:u,update:c}}function ey(t,e,n){t.forEach(t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)})}class ny{constructor(t){this.extensions=[],this.extensionMap={},this.context=t}setExtensions(t){const e=function(t,e,n){const r={},i=t=>(t in r||(r[t]=0),`${e}-${t}-${r[t]++}`);return n.map(e=>"string"==typeof e?{type:e,key:i(e)}:"function"==typeof e?e.call(t):e.key?e:Object.assign(Object.assign({},e),{key:i(e.type)}))}(this.context.graph,this.category,t),{enter:n,update:r,exit:i,keep:o}=ty(this.extensions,e,t=>t.key);this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=Xv(e,r);if(!i)return Zv(`The extension ${r} of ${e} is not registered.`);const o=new i(this.context,t);o.initialized=!0,this.extensionMap[n]=o}createExtensions(t){t.forEach(t=>this.createExtension(t))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach(t=>this.updateExtension(t))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.initialized&&!e.destroyed&&e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach(({key:t})=>this.destroyExtension(t))}destroy(){this.destroyExtensions(this.extensions),this.context={},this.extensions=[],this.extensionMap={}}}class ry{constructor(t,e){this.events=[],this.initialized=!1,this.destroyed=!1,this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class iy extends ry{}class oy extends iy{constructor(t,e){super(t,Object.assign({},oy.defaultOptions,e)),this.isOverlapping=(t,e)=>e.some(e=>t.intersects(e)),this.occupiedBounds=[],this.detectLabelCollision=t=>{const e=this.context.viewport,n={show:[],hide:[]};return this.occupiedBounds=[],t.forEach(t=>{const r=t.getShape("label").getRenderBounds();e.isInViewport(r,!0)&&!this.isOverlapping(r,this.occupiedBounds)?(n.show.push(t),this.occupiedBounds.push(Em(r,this.options.padding))):n.hide.push(t)}),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=ty(t,e,t=>t.id);null==n||n.forEach(this.hideLabel)},this.nodeCentralities=new Map,this.sortNodesByCentrality=(t,e)=>{const{model:n}=this.context,r=n.getData(),i=n.getRelatedEdgesData.bind(n);return t.map(t=>(this.nodeCentralities.has(t.id)||(this.nodeCentralities=Vm(r,i,e)),{node:t,centrality:this.nodeCentralities.get(t.id)})).sort((t,e)=>e.centrality-t.centrality).map(t=>t.node)},this.sortLabelElementsInView=t=>{const{sort:e,sortNode:n,sortCombo:r,sortEdge:i}=this.options,{model:o}=this.context;if(Gt(e))return t.sort((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id)));const{node:A=[],edge:s=[],combo:a=[]}=ee(t,t=>t.type),c=Gt(r)?a.sort((t,e)=>r(...o.getComboData([t.id,e.id]))):a,l=Gt(n)?A.sort((t,e)=>n(...o.getNodeData([t.id,e.id]))):this.sortNodesByCentrality(A,n),u=Gt(i)?s.sort((t,e)=>i(...o.getEdgeData([t.id,e.id]))):s;return[...c,...l,...u]},this.labelElementsInView=[],this.isFirstRender=!0,this.onToggleVisibility=t=>{var e;if("zIndex"===(null===(e=t.data)||void 0===e?void 0:e.stage))return;if(!this.validate(t))return void(this.hiddenElements.size>0&&(this.hiddenElements.forEach(this.showLabel),this.hiddenElements.clear()));const n=this.isFirstRender?this.getLabelElements():this.getLabelElementsInView();this.hideLabelIfExceedViewport(this.labelElementsInView,n),this.labelElementsInView=n;const r=this.sortLabelElementsInView(this.labelElementsInView),{show:i,hide:o}=this.detectLabelCollision(r);for(let t=i.length-1;t>=0;t--)this.showLabel(i[t]);o.forEach(this.hideLabel)},this.hiddenElements=new Map,this.hideLabel=t=>{const e=t.getShape("label");e&&ey(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&ey(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Qe(this.onToggleVisibility,this.options.throttle,{leading:!0}),this.enableToggle=!0,this.toggle=t=>{this.enableToggle&&this.onToggleVisibility(t)},this.onBeforeRender=()=>{this.enableToggle=!1},this.onAfterRender=t=>{this.onToggleVisibility(t),this.enableToggle=!0},this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents(),this.onToggleVisibility({})}getLabelElements(){const{elementMap:t}=this.context.element,e=[];for(const n in t){const r=t[n];r.isVisible()&&r.getShape("label")&&e.push(r)}return e}getLabelElementsInView(){const t=this.context.viewport;return this.getLabelElements().filter(e=>t.isInViewport(e.getShape("key").getRenderBounds()))}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.on(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.on(t.GraphEvent.AFTER_DRAW,this.toggle),e.on(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.off(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.off(t.GraphEvent.AFTER_DRAW,this.toggle),e.off(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}oy.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const Ay=[0,0,0];function sy(t,e){if(t.length==e.length)return[t,e];if(dm(t)&&0!==t[2]||dm(e)&&0!==e[2])throw new Error($v("Vectors could not operate due to different dimensions."));return[yy(t),yy(e)]}function ay(t,e){return[t,e]=sy(t,e),t.map((t,n)=>t+e[n])}function cy(t,e){return[t,e]=sy(t,e),t.map((t,n)=>t-e[n])}function ly(t,e){return"number"==typeof e?t.map(t=>t*e):([t,e]=sy(t,e),t.map((t,n)=>t*e[n]))}function uy(t,e){return"number"==typeof e?t.map(t=>t/e):([t,e]=sy(t,e),t.map((t,n)=>{if(0==e[n])throw new Error($v("Vector could not be divided by zero"));return t/e[n]}))}function hy(t,e){return t.map(t=>t*e)}function dy(t,e){return[t,e]=sy(t,e),Math.sqrt(t.reduce((t,n,r)=>t+Math.pow(n-e[r],2),0))}function fy(t,e){return[t,e]=sy(t,e),t.reduce((t,n,r)=>t+Math.abs(n-e[r]),0)}function gy(t){const e=t.reduce((t,e)=>t+Math.pow(e,2),0);return t.map(t=>t/Math.sqrt(e))}function py(t,e,n=!1){[t,e]=sy(t,e);const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(ly(t,e).reduce((t,e)=>t+e,0)/(dy(t,Ay)*dy(e,Ay)));return n&&r<0&&(i=2*Math.PI-i),i}function vy(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function my(t,e){return t.map(t=>t%e)}function yy(t){return[t[0],t[1]]}function wy(t){return 2===t.length?[t[0],t[1],0]:t}function by(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function By(t,e){const[n,r]=t;if(e%360==0)return[n,r];const i=e*Math.PI/180,o=Math.cos(i),A=Math.sin(i);return[n*o-r*A,n*A+r*o]}function Ey(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=wy(t),r=wy(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(cy(n,r),cy(i,o)).every(t=>0===t)}function xy(t,e,n=!1){if(Ey(t,e))return;const[r,i]=t,[o,A]=e,s=((r[0]-o[0])*(o[1]-A[1])-(r[1]-o[1])*(o[0]-A[0]))/((r[0]-i[0])*(o[1]-A[1])-(r[1]-i[1])*(o[0]-A[0])),a=A[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(A[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(A[1]-o[1]);return n||gm(s,0,1)&&gm(a,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Cy(t){if(Array.isArray(t))return gm(t[0],0,1)&&gm(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}function My(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function Fy(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function ky(t,e="center"){return function(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}(t,Cy(e))}function Sy(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function Qy(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function Uy(t,e=0){return t.map(t=>parseFloat(t.toFixed(e)))}function Ny(t,e,n,r=!1){if(xe(t,e))return t;const i=gy(r?cy(t,e):cy(e,t)),o=[i[0]*n,i[1]*n];return ay(yy(t),o)}function Ty(t,e){return t[1]===e[1]}function Oy(t,e){return Ty(t,e)||function(t,e){return t[0]===e[0]}(t,e)}function Iy(t,e,n){return Ey([t,e],[e,n])}function Ly(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function Py(t,e,n,r=!0,i=!1){for(let o=0;o<n.length;o++){let A=n[o],s=n[(o+1)%n.length];r&&(A=ay(e,A),s=ay(e,s));const a=xy([e,i?Ly(t,e):t],[A,s]);if(a)return{point:a,line:[A,s]}}return{point:e,line:void 0}}function Dy(t,e,n=!1){const r=e.center,i=cy(n?Ly(t,r):t,e.center),o=Math.atan2(i[1],i[0]);if(isNaN(o))return r;const A=mm(e)/2,s=ym(e)/2;return[r[0]+A*Math.cos(o),r[1]+s*Math.sin(o)]}function Ry(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach(e=>{const i=function(t,e){const n=Hy(t,e);return dy(t,n)}(t,e);i<n&&(n=i,r=e)}),r}function Hy(t,e){const[n,r]=e[0],[i,o]=e[1],[A,s]=t,a=i-n,c=o-r;if(0===a&&0===c)return[n,r];let l=((A-n)*a+(s-r)*c)/(a*a+c*c);l>1?l=1:l<0&&(l=0);return[n+l*a,r+l*c]}function _y(t,e=!0){const n=function(t){const e=t.reduce((t,e)=>ay(t,e),[0,0]);return uy(e,t.length)}(t);return t.sort(([t,r],[i,o])=>{const A=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-A:A-s})}function Gy(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}class Ky{constructor(t,e,n){if(this.phase=e,this.pointerByTouch=[],this.initialDistance=null,this.emitter=t,Ky.instance)return Ky.callbacks[this.phase].push(n),Ky.instance;this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.bindEvents(),Ky.instance=this,Ky.callbacks[this.phase].push(n)}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp)}updatePointerPosition(t,e,n){const r=this.pointerByTouch.findIndex(e=>e.pointerId===t);r>=0&&(this.pointerByTouch[r]={x:e,y:n,pointerId:t})}onPointerDown(t){const{x:e,y:n}=t.client||{};if(void 0!==e&&void 0!==n&&(this.pointerByTouch.push({x:e,y:n,pointerId:t.pointerId}),"touch"===t.pointerType&&2===this.pointerByTouch.length)){Ky.isPinching=!0;const e=this.pointerByTouch[0].x-this.pointerByTouch[1].x,n=this.pointerByTouch[0].y-this.pointerByTouch[1].y;this.initialDistance=Math.sqrt(e*e+n*n),Ky.callbacks.pinchstart.forEach(e=>e(t,{scale:0}))}}onPointerMove(t){if(2!==this.pointerByTouch.length||null===this.initialDistance)return;const{x:e,y:n}=t.client||{};if(void 0===e||void 0===n)return;this.updatePointerPosition(t.pointerId,e,n);const r=this.pointerByTouch[0].x-this.pointerByTouch[1].x,i=this.pointerByTouch[0].y-this.pointerByTouch[1].y,o=Math.sqrt(r*r+i*i)/this.initialDistance;Ky.callbacks.pinchmove.forEach(e=>e(t,{scale:5*(o-1)}))}onPointerUp(t){var e;Ky.callbacks.pinchend.forEach(e=>e(t,{scale:0})),Ky.isPinching=!1,this.initialDistance=null,this.pointerByTouch=[],null===(e=Ky.instance)||void 0===e||e.tryDestroy()}destroy(){this.emitter.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),this.emitter.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),this.emitter.off(t.CommonEvent.POINTER_UP,this.onPointerUp),Ky.instance=null}off(t,e){const n=Ky.callbacks[t].indexOf(e);n>-1&&Ky.callbacks[t].splice(n,1),this.tryDestroy()}tryDestroy(){Object.values(Ky.callbacks).every(t=>0===t.length)&&this.destroy()}}Ky.isPinching=!1,Ky.instance=null,Ky.callbacks={pinchstart:[],pinchmove:[],pinchend:[]};const jy=new Set(["Control","Alt","Meta","Shift"]);function zy(t){return jy.has(t)}const Vy=t=>t.map(t=>Jt(t)?t.toLocaleLowerCase():t);class Wy{constructor(e){this.map=new Map,this.boundHandlePinch=()=>{},this.recordKey=new Set,this.onKeyDown=t=>{(null==t?void 0:t.key)&&(this.recordKey.add(t.key),this.trigger(t))},this.onKeyUp=t=>{(null==t?void 0:t.key)&&this.recordKey.delete(t.key)},this.onKeyDownWindow=t=>{zy(t.key)&&this.recordKey.add(t.key)},this.onKeyUpWindow=t=>{zy(t.key)&&this.recordKey.delete(t.key)},this.onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)},this.onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)},this.handlePinch=(e,n)=>{this.triggerExtendKey(t.CommonEvent.PINCH,Object.assign(Object.assign({},e),n))},this.onFocus=()=>{this.recordKey.clear()},this.emitter=e,this.bindEvents()}bind(e,n){0!==e.length&&(e.includes(t.CommonEvent.PINCH)&&!this.pinchHandler&&(this.boundHandlePinch=this.handlePinch.bind(this),this.pinchHandler=new Ky(this.emitter,"pinchmove",this.boundHandlePinch)),this.map.set(e,n))}unbind(t,e){this.map.forEach((n,r)=>{xe(r,t)&&(e&&e!==n||this.map.delete(r))})}unbindAll(){this.map.clear()}match(t){const e=Vy(Array.from(this.recordKey)).sort(),n=Vy(t).sort();return xe(e,n)}bindEvents(){var e;const{emitter:n}=this;window.addEventListener(t.CommonEvent.KEY_DOWN,this.onKeyDownWindow),window.addEventListener(t.CommonEvent.KEY_UP,this.onKeyUpWindow),n.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),n.on(t.CommonEvent.KEY_UP,this.onKeyUp),n.on(t.CommonEvent.WHEEL,this.onWheel),n.on(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"focus",this.onFocus)}trigger(t){this.map.forEach((e,n)=>{this.match(n)&&e(t)})}triggerExtendKey(t,e){this.map.forEach((n,r)=>{r.includes(t)&&xe(Array.from(this.recordKey),r.filter(e=>e!==t))&&n(e)})}destroy(){var e,n;this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),window.removeEventListener(t.CommonEvent.KEY_DOWN,this.onKeyDownWindow),window.removeEventListener(t.CommonEvent.KEY_UP,this.onKeyUpWindow),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag),null===(e=this.pinchHandler)||void 0===e||e.off("pinchmove",this.boundHandlePinch),null===(n=globalThis.removeEventListener)||void 0===n||n.call(globalThis,"focus",this.onFocus)}}class Yy extends iy{constructor(t,e){super(t,be({},Yy.defaultOptions,e)),this.shortcut=new Wy(t.graph),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.clearStates=this.clearStates.bind(this),this.bindEvents()}onPointerDown(t){if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{canvas:e,graph:n}=this.context,r=Object.assign({},this.options.style);this.options.style.lineWidth&&(r.lineWidth=+this.options.style.lineWidth/n.getZoom()),this.rectShape=new sc({id:"g6-brush-select",style:r}),e.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]}onPointerMove(t){var e;if(!this.startPoint)return;const{immediately:n,mode:r}=this.options;this.endPoint=Xy(t,this.context.graph),null===(e=this.rectShape)||void 0===e||e.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),n&&"default"===r&&this.updateElementsStates(Gy(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=Xy(t,this.context.graph),this.updateElementsStates(Gy(this.startPoint,this.endPoint)),this.clearBrush()):this.clearBrush())}clearStates(){this.endPoint||this.clearElementsStates()}clearElementsStates(){const{graph:t}=this.context,e=Object.values(t.getData()).reduce((t,e)=>Object.assign({},t,e.reduce((t,e)=>{var n;const r=null===(n=e.states||[])||void 0===n?void 0:n.filter(t=>t!==this.options.state);return t[Km(e)]=r,t},{})),{});t.setElementState(e,this.options.animation)}updateElementsStates(t){const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,A=this.selector(e,t,n),s={};switch(i){case"union":A.forEach(t=>{s[t]=[...e.getElementState(t),r]});break;case"diff":A.forEach(t=>{const n=e.getElementState(t);s[t]=n.includes(r)?n.filter(t=>t!==r):[...n,r]});break;case"intersect":A.forEach(t=>{const n=e.getElementState(t);s[t]=n.includes(r)?[r]:[]});break;default:A.forEach(t=>{s[t]=[r]})}Gt(o)&&o(s),e.setElementState(s,this.options.animation)}selector(t,e,n){if(!n||0===n.length)return[];const r=[],i=t.getData();if(n.forEach(n=>{i[`${n}s`].forEach(n=>{const i=Km(n);"hidden"!==t.getElementVisibility(i)&&function(t,e,n,r){const i=t[0],o=t[1];let A=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);const s=r-n;for(let t=0,r=s-1;t<s;r=t++){const s=e[t+n][0],a=e[t+n][1],c=e[r+n][0],l=e[r+n][1];a>o!=l>o&&i<(c-s)*(o-a)/(l-a)+s&&(A=!A)}return A}(t.getElementPosition(i),e)&&r.push(i)})}),n.includes("edge")){const t=i.edges;null==t||t.forEach(t=>{const{source:e,target:n}=t;r.includes(e)&&r.includes(n)&&r.push(Km(t))})}return r}clearBrush(){var t;null===(t=this.rectShape)||void 0===t||t.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0}isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return this.shortcut.match(e.filter(t=>"drag"!==t))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp),e.on(t.CanvasEvent.CLICK,this.clearStates)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.off(t.CommonEvent.POINTER_UP,this.onPointerUp),e.off(t.CanvasEvent.CLICK,this.clearStates)}update(t){this.unbindEvents(),this.options=be(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}Yy.defaultOptions={animation:!1,enable:!0,enableElements:["node","combo","edge"],immediately:!1,mode:"default",state:"selected",trigger:["shift"],style:{width:0,height:0,lineWidth:1,fill:"#1677FF",stroke:"#1677FF",fillOpacity:.1,zIndex:2,pointerEvents:"none"}};const Xy=(t,e)=>{if(!("node"!==t.targetType&&"combo"!==t.targetType||t.nativeEvent.target instanceof HTMLCanvasElement)){const[n,r]=e.getCanvasByClient([t.client.x,t.client.y]);return[n,r]}return[t.canvas.x,t.canvas.y]},qy=.8,$y=["node","edge","combo"];function Zy(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)Zy(t,e,n,r,i+1);"BT"===r&&e(t,i)}function Jy(t,e,n,r,i="both"){if("combo"===e||"node"===e)return tw(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const A=tw(t,o.source,r-1,i),s=tw(t,o.target,r-1,i);return Array.from(new Set([...A,...s,n]))}function tw(t,e,n,r="both"){const i=new Set,o=new Set,A=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,(e,i)=>{i>n||(A.add(e),t.getRelatedEdgesData(e,r).forEach(t=>{const e=Km(t);!o.has(e)&&i<n&&(A.add(e),o.add(e))}))},e=>t.getRelatedEdgesData(e,r).map(t=>t.source===e?t.target:t.source).filter(t=>!i.has(t)&&(i.add(t),!0))),Array.from(A)}function ew(t){return t.states||[]}class nw extends iy{constructor(t,e){super(t,Object.assign({},nw.defaultOptions,e)),this.onClickSelect=t=>De(this,void 0,void 0,function*(){var e,n;this.validate(t)&&(yield this.updateState(t),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))}),this.onClickCanvas=t=>De(this,void 0,void 0,function*(){var e,n;this.validate(t)&&(yield this.clearState(),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))}),this.shortcut=new Wy(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)}),e.on(t.CanvasEvent.CLICK,this.onClickCanvas)}get isMultipleSelect(){const{multiple:t,trigger:e}=this.options;return t&&this.shortcut.match(e)}getNeighborIds(t){const{target:e,targetType:n}=t,{graph:r}=this.context,{degree:i}=this.options;return Jy(r,n,e.id,"function"==typeof i?i(t):i).filter(t=>t!==e.id)}updateState(t){return De(this,void 0,void 0,function*(){const{state:e,unselectedState:n,neighborState:r,animation:i}=this.options;if(!e&&!r&&!n)return;const{target:o}=t,{graph:A}=this.context,s=ew(A.getElementData(o.id)).includes(e)?"unselect":"select",a={},c=this.isMultipleSelect,l=[o.id],u=this.getNeighborIds(t);if(c)if(Object.assign(a,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach(t=>{const r=new Set(A.getElementState(t));r.add(e),r.delete(n),a[t]=Array.from(r)})};t(l,e),t(u,r),n&&Object.keys(a).forEach(t=>{const i=a[t];i.includes(e)||i.includes(r)||i.includes(n)||a[t].push(n)})}else{const t=a[o.id];a[o.id]=t.filter(t=>t!==e&&t!==r),t.includes(n)||a[o.id].push(n),u.forEach(t=>{a[t]=a[t].filter(t=>t!==r),a[t].includes(e)||a[t].push(n)})}else if("select"===s){Object.assign(a,this.getClearStates(!!n));const t=(t,e)=>{t.forEach(t=>{a[t]||(a[t]=A.getElementState(t)),a[t].push(e)})};t(l,e),t(u,r),n&&Object.keys(a).forEach(t=>{l.includes(t)||u.includes(t)||a[t].push(n)})}else Object.assign(a,this.getClearStates());yield A.setElementState(a,i)})}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach(t=>{i[Km(t)]=ew(t)}),i}getClearStates(t=!1){const{graph:e}=this.context,{state:n,unselectedState:r,neighborState:i}=this.options,o=new Set([n,r,i]),{nodes:A,edges:s,combos:a}=e.getData(),c={};return[...A,...s,...a].forEach(e=>{const n=ew(e),r=n.filter(t=>!o.has(t));(t||r.length!==n.length)&&(c[Km(e)]=r)}),c}clearState(){return De(this,void 0,void 0,function*(){const{graph:t}=this.context;yield t.setElementState(this.getClearStates(),this.options.animation)})}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)}),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function rw(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function iw(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function ow(t,e,n=!0){if(!e)return t;if(!iw(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=ae(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Aw(t,e){const n=Object.entries(t).reduce((t,[n,r])=>("className"===n||"class"===n||iw(n,e)&&Object.assign(t,{[ow(n,e)]:r}),t),{});if("opacity"in t){const r=function(t,e){return`${e}${ce(t)}`}("opacity",e),i=t.opacity;if(r in t){const e=t[r];Object.assign(n,{opacity:i*e})}else Object.assign(n,{opacity:i})}return n}function sw(t,e){const n=e.length;return Object.keys(t).reduce((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r},{})}function aw(t,e){const n="string"==typeof e?[e]:e,r={};return Object.keys(t).forEach(e=>{n.find(t=>e.startsWith(t))||(r[e]=t[e])}),r}function cw(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function lw(t,e){const{datum:n,graph:r}=e;return"function"==typeof t?t.call(r,n):Object.fromEntries(Object.entries(t).map(([t,e])=>"function"==typeof e?[t,e.call(r,n)]:[t,e]))}function uw(t,e){const n=(null==t?void 0:t.style)||{},r=(null==e?void 0:e.style)||{};for(const t in n)t in r||(r[t]=n[t]);return Object.assign({},t,e,{style:r})}function hw(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function dw(t){const e="string"==typeof t?Xv("palette",t):t;if("function"!=typeof e)return e}function fw(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function gw(t,e,n=1,r=!1){const i=r?n:1;return fw((t.max[0]-t.min[0])*i,e)}nw.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class pw extends Wa{constructor(t){mw(t.style),super(t),this.shapeMap={},this.animateMap={},this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}upsert(e,n,r,i,o){var A,s,a,c,l,u,h,d;const f=this.shapeMap[e];if(!1===r)return void(f&&(null===(A=null==o?void 0:o.beforeDestroy)||void 0===A||A.call(o,f),i.removeChild(f),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,f)));const g="string"==typeof n?Xv(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error($v(`Shape ${n} not found`));if(!f||f.destroyed||!(f instanceof g)){f&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,f),null==f||f.destroy(),null===(c=null==o?void 0:o.afterDestroy)||void 0===c||c.call(o,f)),null===(l=null==o?void 0:o.beforeCreate)||void 0===l||l.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(u=null==o?void 0:o.afterCreate)||void 0===u||u.call(o,t),t}return null===(h=null==o?void 0:o.beforeUpdate)||void 0===h||h.call(o,f),tE(f,r),null===(d=null==o?void 0:o.afterUpdate)||void 0===d||d.call(o,f),f}update(t={}){const e=Object.assign({},this.attributes,t);mw(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:A,clipPath:s,component:a}=e,c=Pe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,c),r&&t.setAttribute("transform",r);re(n)&&t.setAttribute("zIndex",n);i&&t.setAttribute("transformOrigin",i);o&&t.setAttribute("visibility",o);A&&t.setAttribute("cursor",A);s&&t.setAttribute("clipPath",s);a&&t.setAttribute("component",a)}(this,e),this.render(e,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){return function(t){const{x:e,y:n,z:r,class:i,className:o,transform:A,transformOrigin:s,zIndex:a,visibility:c}=t;return Pe(t,["x","y","z","class","className","transform","transformOrigin","zIndex","visibility"])}(t)}get compositeShapes(){return[["badges","badge-"],["ports","port-"]]}animate(t,e){if(0===t.length)return null;const n=[];if(void 0!==t[0].x||void 0!==t[0].y||void 0!==t[0].z){const{x:e=0,y:n=0,z:r=0}=this.attributes;t.forEach(t=>{const{x:i=e,y:o=n,z:A=r}=t;Object.assign(t,{transform:A?[["translate3d",i,o,A]]:[["translate",i,o]]})})}const r=super.animate(t,e);if(r&&(vw(this,r),n.push(r)),Array.isArray(t)&&t.length>0){const r=["transform","transformOrigin","x","y","z","zIndex"];if(Object.keys(t[0]).some(t=>!r.includes(t))){Object.entries(this.shapeMap).forEach(([r,i])=>{const o=this[`get${ce(r)}Style`];if(Gt(o)){const r=t.map(t=>o.call(this,Object.assign(Object.assign({},this.attributes),t))),A=i.animate(em(r),e);A&&(vw(i,A),n.push(A))}});const r=(r,i)=>{if(!Ee(r)){const o=this[`get${ce(i)}Style`];if(Gt(o)){const i=t.map(t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)));Object.entries(i[0]).map(([t])=>{const o=i.map(e=>e[t]),A=r[t];if(A){const t=A.animate(em(o),e);t&&(vw(A,t),n.push(t))}})}}};this.compositeShapes.forEach(([t,e])=>{const n=sw(this.shapeMap,e);r(n,t)})}}return tm(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;ey(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function vw(t,e){null==e||e.finished.then(()=>{const n=t.activeAnimations.findIndex(t=>t===e);n>-1&&t.activeAnimations.splice(n,1)})}function mw(t){if(!t)return{};if("x"in t||"y"in t||"z"in t){const{x:e=0,y:n=0,z:r,transform:i}=t,o=om(e,n,r,i);o&&(t.transform=o)}return t}class yw extends pw{constructor(t){super(uw({style:yw.defaultStyleProps},t))}isTextStyle(t){return iw(t,"label")}isBackgroundStyle(t){return iw(t,"background")}getTextStyle(t){const e=this.getGraphicStyle(t),{padding:n}=e;return aw(Pe(e,["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Aw(e,"background"),{min:[A,s],center:[a,c],halfExtents:[l,u]}=this.shapeMap.text.getGeometryBounds(),[h,d,f,g]=pm(i),p=2*l+g+d,{width:v,height:m}=o;v&&m?Object.assign(o,{x:a-Number(v)/2,y:c-Number(m)/2}):Object.assign(o,{x:A-g,y:s-h,width:n?Math.min(p,r+g+d):p,height:2*u+h+f});const{radius:y}=o;if("string"==typeof y&&y.endsWith("%")){const t=Number(y.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",cc,this.getTextStyle(t),e),this.upsert("background",sc,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}yw.defaultStyleProps={padding:0,fontSize:12,fontFamily:"system-ui, sans-serif",wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};class ww extends pw{constructor(t){super(uw({style:ww.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",yw,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}ww.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const bw={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function Bw(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in bw?r=t:e.unshift(t),i={type:r},bw[r].forEach(n=>{t=e.shift(),i[n]=t}),"M"===r?r="L":"m"===r&&(r="l");const[o,...A]=Object.values(i);n.push([o,...A.map(Number)])}return n}(t):t;return n.forEach(t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])}),e}const Ew=t=>{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e<t.length-2;e+=1){const[n,r]=t[e-1],[i,A]=t[e],[s,a]=t[e+1],[c,l]=e!==t.length-2?t[e+2]:[s,a],u=i+(s-n)/6,h=A+(a-r)/6,d=s-(c-i)/6,f=a-(l-A)/6;o.push(["C",u,h,d,f,s,a])}return o};class xw extends pw{constructor(t){super(uw({style:xw.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const e=Aw(this.getGraphicStyle(t),"label"),{maxWidth:n,offsetX:r,offsetY:i,autoRotate:o,placement:A,closeToPath:s}=e,a=Pe(e,["maxWidth","offsetX","offsetY","autoRotate","placement","closeToPath"]),c=this.shapeMap.key,l=null==c?void 0:c.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,A){const[s,a]=ky(t,e),c={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:[["translate",s+n,a+r]]};if("center"===e||!i)return c;const l=Bw(o);if(!l||l.length<=3)return c;const u=l.map((t,e)=>{const n=t,r=l[(e+1)%l.length];return xe(n,r)?null:[n,r]}).filter(Boolean),h=Ry([s,a],u),d=Hy([s,a],h);if(d&&h&&(c.transform=[["translate",d[0]+n,d[1]+r]],A)){const t=Math.atan((h[0][1]-h[1][1])/(h[0][0]-h[1][0]));c.transform.push(["rotate",t/Math.PI*180]),c.textAlign="center","right"!==e&&"left"!==e||(c.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return c}(l,A,r,i,s,t.d,o),{wordWrapWidth:gw(l,n)},a)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",nc,this.getKeyStyle(t),e),this.upsert("label",yw,this.getLabelStyle(t),e)}}xw.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let Cw=class extends Za{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Fw=this,this.isMutationObserved=!0,this.addEventListener(ea.MOUNTED,this.onMounted),this.addEventListener(ea.ATTR_MODIFIED,this.onAttrModified)}handleRadius(){const{radius:t,clipPath:e,width:n=0,height:r=0}=this.attributes;if(t&&n&&r){const[i,o]=this.getBounds().min,A={x:i,y:o,radius:t,width:n,height:r};if(e)Object.assign(this.parsedStyle.clipPath.style,A);else{const t=new sc({style:A});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const Mw=new WeakMap;let Fw=null;const kw=t=>{if(Fw&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Fw).includes(t)){const e=Mw.get(t);e?e.includes(Fw)||e.push(Fw):Mw.set(t,[Fw])}},Sw=t=>{const e=Mw.get(t);e&&e.forEach(t=>t.handleRadius())};class Qw extends pw{constructor(t){super(t)}isImage(){const{src:t}=this.attributes;return!!t}getIconStyle(t=this.attributes){const{width:e=0,height:n=0}=t,r=this.getGraphicStyle(t);return this.isImage()?Object.assign({x:-e/2,y:-n/2},r):Object.assign({textBaseline:"middle",textAlign:"center"},r)}render(t=this.attributes,e=this){this.upsert("icon",this.isImage()?Cw:cc,this.getIconStyle(t),e)}}class Uw extends pw{get context(){return this.config.context}get parsedAttributes(){return this.attributes}onframe(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>this.onframe(),n.finished.then(()=>this.onframe())),n}}class Nw extends Uw{constructor(t){super(uw({style:Nw.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return cw(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(aw(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Aw(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,A=Pe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(ZB(s,n,i,o),{wordWrapWidth:gw(s,r)},A)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Pe(e,["fill"]),i=Aw(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign(Object.assign({},r),{stroke:n}),i)}getIconStyle(t){if(!1===t.icon||!t.iconText&&!t.iconSrc)return!1;const e=Aw(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=cw(t);let r={};return e.text&&!e.fontSize&&(r={fontSize:.5*Math.min(...n)}),!e.src||e.width&&e.height||(r={width:.5*n[0],height:.5*n[1]}),r}(t.size,e),e)}getBadgesStyle(t){var e;const n=sw(this.shapeMap,"badge-"),r={};if(Object.keys(n).forEach(t=>{r[t]=!1}),!1===t.badge||!(null===(e=t.badges)||void 0===e?void 0:e.length))return r;const{badges:i=[],badgePalette:o,opacity:A=1}=t,s=Pe(t,["badges","badgePalette","opacity"]),a=dw(o),c=Aw(this.getGraphicStyle(s),"badge");return i.forEach((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:a?a[e%(null==a?void 0:a.length)]:void 0,opacity:A},c),this.getBadgeStyle(t))}),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Pe(t,["placement","offsetX","offsetY"]),A=ZB(e.getLocalBounds(),n,r,i,!0);return Object.assign(Object.assign({},A),o)}getPortsStyle(t){var e;const n=this.getPorts(),r={};if(Object.keys(n).forEach(t=>{r[t]=!1}),!1===t.port||!(null===(e=t.ports)||void 0===e?void 0:e.length))return r;const i=Aw(this.getGraphicStyle(t),"port"),{ports:o=[]}=t;return o.forEach((e,n)=>{const o=e.key||n,A=Object.assign(Object.assign({},i),e);if(VB(A))r[o]=!1;else{const[n,i]=this.getPortXY(t,e);r[o]=Object.assign({transform:[["translate",n,i]]},A)}}),r}getPortXY(t,e){const{placement:n="left"}=e,r=this.getShape("key");return jB(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();ey(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return sw(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return Py(t,ky(e,"center"),[ky(e,"left-top"),ky(e,"right-top"),ky(e,"right-bottom"),ky(e,"left-bottom")],!1,n).point}(t,this.getShape("key").getBounds(),e)}drawHaloShape(t,e){const n=this.getHaloStyle(t),r=this.getShape("key");this.upsert("halo",r.constructor,n,e)}drawIconShape(t,e){const n=this.getIconStyle(t);this.upsert("icon",Qw,n,e),kw(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach(t=>{const r=n[t];this.upsert(`badge-${t}`,ww,r,e)})}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach(t=>{const r=n[t],i=`port-${t}`;this.upsert(i,za,r,e)})}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",yw,n,e)}_drawKeyShape(t,e){return this.drawKeyShape(t,e)}render(t=this.parsedAttributes,e=this){this._drawKeyShape(t,e),this.getShape("key")&&(this.drawHaloShape(t,e),this.drawIconShape(t,e),this.drawBadgeShapes(t,e),this.drawLabelShape(t,e),this.drawPortShapes(t,e))}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Sw(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}Nw.defaultStyleProps={x:0,y:0,size:32,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};let Tw=class t extends Nw{constructor(e){super(uw({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",za,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{r:Math.min(...this.getSize(t))/2})}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getShape("key").attributes,r=2*n*qy;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}};Tw.defaultStyleProps={size:32};class Ow extends Nw{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",ic,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{points:this.getPoints(t)})}getIntersectPoint(t,e=!1){var n,r;const{points:i}=this.getShape("key").attributes;return Py(t,[+((null===(n=this.attributes)||void 0===n?void 0:n.x)||0),+((null===(r=this.attributes)||void 0===r?void 0:r.y)||0)],i,!0,e).point}}class Iw extends Ow{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}}class Lw extends Tw{constructor(t){super(uw({style:Lw.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...cw(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return Jt(t)?parseInt(t)/100*this.parseOuterR():t}drawDonutShape(t,e){const{donuts:n}=t;if(!(null==n?void 0:n.length))return;const r=n.map(t=>re(t)?{value:t}:t),i=Aw(this.getGraphicStyle(t),"donut"),o=dw(t.donutPalette);if(!o)return;const A=r.reduce((t,e)=>{var n;return t+(null!==(n=e.value)&&void 0!==n?n:0)},0),s=this.parseOuterR(),a=this.parseInnerR();let c=0;r.forEach((t,n)=>{const{value:l=0,color:u=o[n%o.length]}=t,h=Pe(t,["value","color"]),d=360*(0===A?1/r.length:l/A);this.upsert(`round${n}`,nc,Object.assign(Object.assign(Object.assign({},i),{d:Dw(s,a,c,c+d),fill:u}),h),e),c+=d})}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}Lw.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const Pw=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],Dw=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[A,s]=[i/360*2*Math.PI,o/360*2*Math.PI],a=[Pw(t,e,r,A),Pw(t,e,n,A),Pw(t,e,n,s),Pw(t,e,r,s)],c=s-A>Math.PI?1:0;return[["M",a[0][0],a[0][1]],["L",a[1][0],a[1][1]],["A",n,n,0,c,1,a[2][0],a[2][1]],["L",a[3][0],a[3][1]],["A",r,r,0,c,0,a[0][0],a[0][1]],["Z"]]})(i,o,t,e,n,r)};class Rw extends Nw{constructor(t){super(uw({style:Rw.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Ya,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return Object.assign(Object.assign({},e),{rx:n/2,ry:r/2})}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getShape("key").attributes,i=2*Math.min(+n,+r)*qy;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}}Rw.defaultStyleProps={size:[45,35]};class Hw extends Ow{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*qy;return!!e&&Object.assign({width:n,height:n},e)}}function _w(t,e){if(!{}.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}var Gw=0;function Kw(t){return"__private_"+Gw+++"_"+t}
|
|
48
48
|
/*!
|
|
49
49
|
* @antv/g-canvas
|
|
50
50
|
* @description A renderer implemented by Canvas 2D API
|
|
@@ -52,12 +52,12 @@ var _c=function(t,e){return _c=Object.setPrototypeOf||{__proto__:[]}instanceof A
|
|
|
52
52
|
* @date 12/24/2025, 11:55:53 AM
|
|
53
53
|
* @author AntVis
|
|
54
54
|
* @docs https://g.antv.antgroup.com/
|
|
55
|
-
*/var jw=Kw("renderState"),zw=function(){function t(e){A(this,t),this.renderQueue=[],Object.defineProperty(this,jw,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=C(),this.dprMatrix=C(),this.tmpMat4=C(),this.vec3a=at(),this.vec3b=at(),this.vec3c=at(),this.vec3d=at(),this.canvasRendererPluginOptions=e}return a(t,[{key:"apply",value:function(e,n){var r=this;this.context=e;var i=this.context,o=i.config,A=i.camera,s=i.renderingService,a=i.renderingContext,c=i.pathGeneratorFactory,l=o.renderer.getConfig().enableRenderingOptimization;o.renderer.getConfig().enableDirtyCheck=!1,o.renderer.getConfig().enableDirtyRectangleRendering=!1,this.pathGeneratorFactory=c;var u=e.contextService,h=a.root.ownerDocument.defaultView;s.hooks.init.tap(t.tag,function(){var t=u.getDPR(),e=o.width,n=o.height,i=u.getContext();r.clearRect(i,0,0,e*t,n*t,o.background)}),s.hooks.destroy.tap(t.tag,function(){r.renderQueue=[],_w(r,jw)[jw]={restoreStack:[],prevObject:null,currentContext:null}});var d=function(t,e){for(var i=[t];i.length>0;){var o,A=i.pop();A.isVisible()&&!A.isCulled()&&(l?r.renderDisplayObjectOptimized(A,e,r.context,_w(r,jw)[jw],n):r.renderDisplayObject(A,e,r.context,_w(r,jw)[jw],n));for(var s=(null===(o=A.sortable)||void 0===o||null===(o=o.sorted)||void 0===o?void 0:o.length)>0?A.sortable.sorted:A.childNodes,a=s.length-1;a>=0;a--)i.push(s[a])}};s.hooks.endFrame.tap(t.tag,function(){if(function(){var t,e=u.getContext(),n=u.getDPR(),i=o.width,A=o.height,a=r.canvasRendererPluginOptions,c=a.dirtyObjectNumThreshold,l=a.dirtyObjectRatioThreshold,d=s.getStats(),f=d.total,g=d.rendered,p=g/f;r.clearFullScreen=r.clearFullScreenLastFrame||!(null!==(t=h.context.renderingPlugins[1])&&void 0!==t&&t.isFirstTimeRenderingFinished)||s.disableDirtyRectangleRendering()||g>c&&p>l,e&&("function"==typeof e.resetTransform?e.resetTransform():e.setTransform(1,0,0,1,0,0),r.clearFullScreen&&r.clearRect(e,0,0,i*n,A*n,o.background))}(),0!==a.root.childNodes.length){l=o.renderer.getConfig().enableRenderingOptimization,_w(r,jw)[jw]={restoreStack:[],prevObject:null,currentContext:_w(r,jw)[jw].currentContext},_w(r,jw)[jw].currentContext.clear(),r.clearFullScreenLastFrame=!1;var t=u.getContext(),e=u.getDPR();if(H(r.dprMatrix,[e,e,1]),O(r.vpMatrix,r.dprMatrix,A.getOrthoMatrix()),r.clearFullScreen)l?(t.save(),d(a.root,t),t.restore()):d(a.root,t);else{var i=r.safeMergeAABB(r.mergeDirtyAABBs(r.renderQueue));if(yr.isEmpty(i))return void(r.renderQueue=[]);var c=r.convertAABB2Rect(i),f=c.x,g=c.y,p=c.width,v=c.height,y=bt(r.vec3a,[f,g,0],r.vpMatrix),w=bt(r.vec3b,[f+p,g,0],r.vpMatrix),b=bt(r.vec3c,[f,g+v,0],r.vpMatrix),B=bt(r.vec3d,[f+p,g+v,0],r.vpMatrix),E=Math.min(y[0],w[0],B[0],b[0]),x=Math.min(y[1],w[1],B[1],b[1]),C=Math.max(y[0],w[0],B[0],b[0]),M=Math.max(y[1],w[1],B[1],b[1]),F=Math.floor(E),k=Math.floor(x),S=Math.ceil(C-E),Q=Math.ceil(M-x);t.save(),r.clearRect(t,F,k,S,Q,o.background),t.beginPath(),t.rect(F,k,S,Q),t.clip(),t.setTransform(r.vpMatrix[0],r.vpMatrix[1],r.vpMatrix[4],r.vpMatrix[5],r.vpMatrix[12],r.vpMatrix[13]),o.renderer.getConfig().enableDirtyRectangleRenderingDebug&&h.dispatchEvent(new Vs(mc.DIRTY_RECTANGLE,{dirtyRect:{x:F,y:k,width:S,height:Q}}));var U=m(i.getMin(),2),N=U[0],T=U[1],I=m(i.getMax(),2),L=I[0],P=I[1];a.root.ownerDocument.elementsFromBBox(N,T,L,P).sort(function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder}).forEach(function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t,r.context,_w(r,jw)[jw],n)}),t.restore(),r.renderQueue.forEach(function(t){r.saveDirtyAABB(t)}),r.renderQueue=[]}_w(r,jw)[jw].restoreStack.forEach(function(){t.restore()}),_w(r,jw)[jw].restoreStack=[]}else r.clearFullScreenLastFrame=!0}),s.hooks.render.tap(t.tag,function(t){r.clearFullScreen||r.renderQueue.push(t)})}},{key:"clearRect",value:function(t,e,n,r,i,o){t.clearRect(e,n,r,i),o&&(t.fillStyle=o,t.fillRect(e,n,r,i))}},{key:"renderDisplayObjectOptimized",value:function(t,e,n,r,i){var o=t.nodeName,A=!1,s=this.context.styleRendererFactory[o],a=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){(!r.prevObject||!it(c.getWorldTransform(),r.prevObject.getWorldTransform()))&&(this.applyWorldTransform(e,c),r.prevObject=null);var l=this.pathGeneratorFactory[c.nodeName];l&&(e.save(),A=!0,e.beginPath(),l(e,c.parsedStyle),e.closePath(),e.clip())}if(s){(!r.prevObject||!it(t.getWorldTransform(),r.prevObject.getWorldTransform()))&&this.applyWorldTransform(e,t);var u=!r.prevObject;if(!u){var h=r.prevObject.nodeName;u=o===cr.TEXT?h!==cr.TEXT:o===cr.IMAGE?h!==cr.IMAGE:h===cr.TEXT||h===cr.IMAGE}s.applyStyleToContext(e,t,u,r),r.prevObject=t}a&&(e.beginPath(),a(e,t.parsedStyle),o!==cr.LINE&&o!==cr.PATH&&o!==cr.POLYLINE&&e.closePath()),s&&s.drawToContext(e,t,_w(this,jw)[jw],this,i),A&&e.restore(),t.dirty(!1)}},{key:"renderDisplayObject",value:function(t,e,n,r,i){var o=t.nodeName,A=r.restoreStack[r.restoreStack.length-1];!A||t.compareDocumentPosition(A)&Ys.DOCUMENT_POSITION_CONTAINS||(e.restore(),r.restoreStack.pop());var s=this.context.styleRendererFactory[o],a=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){this.applyWorldTransform(e,c);var l=this.pathGeneratorFactory[c.nodeName];l&&(e.save(),r.restoreStack.push(t),e.beginPath(),l(e,c.parsedStyle),e.closePath(),e.clip())}s&&(this.applyWorldTransform(e,t),e.save(),this.applyAttributesToContext(e,t)),a&&(e.beginPath(),a(e,t.parsedStyle),o!==cr.LINE&&o!==cr.PATH&&o!==cr.POLYLINE&&e.closePath()),s&&(s.render(e,t.parsedStyle,t,n,this,i),e.restore()),t.dirty(!1)}},{key:"applyAttributesToContext",value:function(t,e){var n=e.parsedStyle,r=n.stroke,i=n.fill,o=n.opacity,A=n.lineDash,s=n.lineDashOffset;A&&t.setLineDash(A),Kt(s)||(t.lineDashOffset=s),Kt(o)||(t.globalAlpha*=o),Kt(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),Kt(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)}},{key:"convertAABB2Rect",value:function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}}},{key:"mergeDirtyAABBs",value:function(t){var e=new yr;return t.forEach(function(t){var n=t.getRenderBounds();e.add(n);var r=t.renderable.dirtyRenderBounds;r&&e.add(r)}),e}},{key:"saveDirtyAABB",value:function(t){var e=t.renderable;e.dirtyRenderBounds||(e.dirtyRenderBounds=new yr);var n=t.getRenderBounds();n&&e.dirtyRenderBounds.update(n.center,n.halfExtents)}},{key:"applyWorldTransform",value:function(t,e,n){n?(F(this.tmpMat4,e.getLocalTransform()),O(this.tmpMat4,n,this.tmpMat4),O(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(F(this.tmpMat4,e.getWorldTransform()),O(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])}},{key:"safeMergeAABB",value:function(){for(var t=new yr,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n.forEach(function(e){t.add(e)}),t}}])}();function Vw(t,e,n,r,i,o,A){var s,a;if("rect"===t.image.nodeName){var c=t.image.parsedStyle,l=c.width,u=c.height;a=r.contextService.getDPR();var h=r.config.offscreenCanvas;(s=o.offscreenCanvasCreator.getOrCreateCanvas(h)).width=l*a,s.height=u*a;var d=o.offscreenCanvasCreator.getOrCreateContext(h),f={restoreStack:[],prevObject:null,currentContext:new Map};t.image.forEach(function(t){i.renderDisplayObject(t,d,r,f,o)}),f.restoreStack.forEach(function(){d.restore()})}return A.getOrCreatePatternSync(e,t,n,s,a,e.getGeometryBounds().min,function(){e.dirty(),r.renderingService.dirty()})}function Ww(t,e,n,r){var i;if(t.type===Xi.LinearGradient||t.type===Xi.RadialGradient){var A=e.getGeometryBounds(),s=A&&2*A.halfExtents[0]||1,a=A&&2*A.halfExtents[1]||1,c=A&&A.min||[0,0];i=r.getOrCreateGradient(o(o({type:t.type},t.value),{},{min:c,width:s,height:a}),n)}return i}zw.tag="CanvasRenderer";var Yw=["shadowBlur","shadowOffsetX","shadowOffsetY"],Xw=["lineCap","lineJoin","miterLimit"],qw={globalAlpha:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",filter:"none",globalCompositeOperation:"source-over",strokeStyle:"#000",strokeOpacity:1,lineWidth:1,lineDash:[],lineDashOffset:0,lineCap:"butt",lineJoin:"miter",miterLimit:10,fillStyle:"#000",fillOpacity:1},$w={};function Zw(t,e,n,r){var i=r.has(e)?r.get(e):qw[e];return i!==n&&("lineDash"===e?t.setLineDash(n):t[e]=n,r.set(e,n)),i}var Jw=function(){return a(function t(e){A(this,t),this.imagePool=e},[{key:"applyAttributesToContext",value:function(t,e){}},{key:"render",value:function(t,e,n,r,i,o){}},{key:"applyCommonStyleToContext",value:function(t,e,n,r){var i=n?$w:r.prevObject.parsedStyle,o=e.parsedStyle;(n||o.opacity!==i.opacity)&&Zw(t,"globalAlpha",Kt(o.opacity)?qw.globalAlpha:o.opacity,r.currentContext),(n||o.blend!==i.blend)&&Zw(t,"globalCompositeOperation",Kt(o.blend)?qw.globalCompositeOperation:o.blend,r.currentContext)}},{key:"applyStrokeFillStyleToContext",value:function(t,e,n,r){var i=n?$w:r.prevObject.parsedStyle,o=e.parsedStyle,A=o.lineWidth,s=void 0===A?qw.lineWidth:A,a=o.fill&&!o.fill.isNone;if(o.stroke&&!o.stroke.isNone&&s>0){if(n||e.attributes.stroke!==r.prevObject.attributes.stroke)Zw(t,"strokeStyle",Kt(o.stroke)||Array.isArray(o.stroke)||o.stroke.isNone?qw.strokeStyle:e.attributes.stroke,r.currentContext);(n||o.lineWidth!==i.lineWidth)&&Zw(t,"lineWidth",Kt(o.lineWidth)?qw.lineWidth:o.lineWidth,r.currentContext),(n||o.lineDash!==i.lineDash)&&Zw(t,"lineDash",o.lineDash||qw.lineDash,r.currentContext),(n||o.lineDashOffset!==i.lineDashOffset)&&Zw(t,"lineDashOffset",Kt(o.lineDashOffset)?qw.lineDashOffset:o.lineDashOffset,r.currentContext);for(var c=0;c<Xw.length;c++){var l=Xw[c];(n||o[l]!==i[l])&&Zw(t,l,Kt(o[l])?qw[l]:o[l],r.currentContext)}}a&&(n||e.attributes.fill!==r.prevObject.attributes.fill)&&Zw(t,"fillStyle",Kt(o.fill)||Array.isArray(o.fill)||o.fill.isNone?qw.fillStyle:e.attributes.fill,r.currentContext)}},{key:"applyStyleToContext",value:function(t,e,n,r){var i=e.nodeName;this.applyCommonStyleToContext(t,e,n,r),i===cr.IMAGE||this.applyStrokeFillStyleToContext(t,e,n,r)}},{key:"applyShadowAndFilterStyleToContext",value:function(t,e,n,r){var i=e.parsedStyle;if(n){Zw(t,"shadowColor",i.shadowColor.toString(),r.currentContext);for(var o=0;o<Yw.length;o++){var A=Yw[o];Zw(t,A,i[A]||qw[A],r.currentContext)}}i.filter&&i.filter.length&&Zw(t,"filter",e.attributes.filter,r.currentContext)}},{key:"clearShadowAndFilterStyleForContext",value:function(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(e){Zw(t,"shadowColor",qw.shadowColor,r.currentContext);for(var o=0;o<Yw.length;o++){var A=Yw[o];Zw(t,A,qw[A],r.currentContext)}}if(n)if(e&&i){var s=t.filter;!Kt(s)&&s.indexOf("drop-shadow")>-1&&Zw(t,"filter",s.replace(/drop-shadow\([^)]*\)/,"").trim()||qw.filter,r.currentContext)}else Zw(t,"filter",qw.filter,r.currentContext)}},{key:"fillToContext",value:function(t,e,n,r,i){var o=this,A=e.parsedStyle,s=A.fill,a=A.fillRule,c=null;if(Array.isArray(s)&&s.length>0)s.forEach(function(r){var i=Zw(t,"fillStyle",Ww(r,e,t,o.imagePool),n.currentContext);c=null!=c?c:i,a?t.fill(a):t.fill()});else{if(wo(s)){var l=Vw(s,e,t,e.ownerDocument.defaultView.context,r,i,this.imagePool);l&&(t.fillStyle=l,c=!0)}a?t.fill(a):t.fill()}null!==c&&Zw(t,"fillStyle",c,n.currentContext)}},{key:"strokeToContext",value:function(t,e,n,r,i){var o=this,A=e.parsedStyle.stroke,s=null;if(Array.isArray(A)&&A.length>0)A.forEach(function(r){var i=Zw(t,"strokeStyle",Ww(r,e,t,o.imagePool),n.currentContext);s=null!=s?s:i,t.stroke()});else{if(wo(A)){var a=Vw(A,e,t,e.ownerDocument.defaultView.context,r,i,this.imagePool);if(a){var c=Zw(t,"strokeStyle",a,n.currentContext);s=null!=s?s:c}}t.stroke()}null!==s&&Zw(t,"strokeStyle",s,n.currentContext)}},{key:"drawToContext",value:function(t,e,n,r,i){var o,A=e.nodeName,s=e.parsedStyle,a=s.opacity,c=void 0===a?qw.globalAlpha:a,l=s.fillOpacity,u=void 0===l?qw.fillOpacity:l,h=s.strokeOpacity,d=void 0===h?qw.strokeOpacity:h,f=s.lineWidth,g=void 0===f?qw.lineWidth:f,p=s.fill&&!s.fill.isNone,v=s.stroke&&!s.stroke.isNone&&g>0;if(p||v){var m=!Kt(s.shadowColor)&&s.shadowBlur>0,y="inner"===s.shadowType,w=0===(null===(o=s.fill)||void 0===o?void 0:o.alpha),b=!(!s.filter||!s.filter.length),B=m&&v&&(A===cr.PATH||A===cr.LINE||A===cr.POLYLINE||w||y),E=null;if(p)B||this.applyShadowAndFilterStyleToContext(t,e,m,n),E=Zw(t,"globalAlpha",c*u,n.currentContext),this.fillToContext(t,e,n,r,i),B||this.clearShadowAndFilterStyleForContext(t,m,b,n);if(v){var x=!1,C=Zw(t,"globalAlpha",c*d,n.currentContext);if(E=p?E:C,B&&(this.applyShadowAndFilterStyleToContext(t,e,m,n),x=!0,y)){var M=t.globalCompositeOperation;t.globalCompositeOperation="source-atop",this.strokeToContext(t,e,n,r,i),t.globalCompositeOperation=M,this.clearShadowAndFilterStyleForContext(t,m,b,n,!0)}this.strokeToContext(t,e,n,r,i),x&&this.clearShadowAndFilterStyleForContext(t,m,b,n)}null!==E&&Zw(t,"globalAlpha",E,n.currentContext)}}}])}(),tb=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"render",value:function(t,e,n,r,i,o){var A=e.fill,s=e.fillRule,a=e.opacity,c=void 0===a?1:a,l=e.fillOpacity,u=void 0===l?1:l,h=e.stroke,d=e.strokeOpacity,f=void 0===d?1:d,g=e.lineWidth,p=void 0===g?1:g,v=e.lineCap,m=e.lineJoin,y=e.shadowType,w=e.shadowColor,b=e.shadowBlur,B=e.filter,E=e.miterLimit,x=A&&!A.isNone,C=h&&!h.isNone&&p>0,M=0===(null==A?void 0:A.alpha),F=!(!B||!B.length),k=!Kt(w)&&b>0,S=n.nodeName,Q="inner"===y,U=C&&k&&(S===cr.PATH||S===cr.LINE||S===cr.POLYLINE||M||Q);x&&(t.globalAlpha=c*u,U||eb(n,t,k),nb(t,n,A,s,r,i,o,this.imagePool),U||this.clearShadowAndFilter(t,F,k)),C&&(t.globalAlpha=c*f,t.lineWidth=p,Kt(E)||(t.miterLimit=E),Kt(v)||(t.lineCap=v),Kt(m)||(t.lineJoin=m),U&&(Q&&(t.globalCompositeOperation="source-atop"),eb(n,t,!0),Q&&(rb(t,n,h,r,i,o,this.imagePool),t.globalCompositeOperation=qw.globalCompositeOperation,this.clearShadowAndFilter(t,F,!0))),rb(t,n,h,r,i,o,this.imagePool))}},{key:"clearShadowAndFilter",value:function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!Kt(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}}}])}(Jw);function eb(t,e,n){var r=t.parsedStyle,i=r.filter,o=r.shadowColor,A=r.shadowBlur,s=r.shadowOffsetX,a=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=o.toString(),e.shadowBlur=A||0,e.shadowOffsetX=s||0,e.shadowOffsetY=a||0)}function nb(t,e,n,r,i,o,A,s){var a=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Array.isArray(n)?n.forEach(function(n){t.fillStyle=Ww(n,e,t,s),a||(r?t.fill(r):t.fill())}):(wo(n)&&(t.fillStyle=Vw(n,e,t,i,o,A,s)),a||(r?t.fill(r):t.fill()))}function rb(t,e,n,r,i,o,A){var s=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Array.isArray(n)?n.forEach(function(n){t.strokeStyle=Ww(n,e,t,A),s||t.stroke()}):(wo(n)&&(t.strokeStyle=Vw(n,e,t,r,i,o,A)),s||t.stroke())}var ib=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"renderDownSampled",value:function(t,e,n,r){var i=r.src,o=r.imageCache;o.downSampled?t.drawImage(o.downSampled,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3])):this.imagePool.createDownSampledImage(i,n).then(function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())}).catch(function(t){console.error(t)})}},{key:"renderTile",value:function(t,e,n,r){var i=r.src,o=r.imageCache,A=r.imageRect,s=r.drawRect,a=o.size,c=t.getTransform(),l=c.a,u=c.b,h=c.c,d=c.d,f=c.e,g=c.f;if(t.resetTransform(),null!=o&&o.gridSize){for(var p=[a[0]/A[2],a[1]/A[3]],v=[o.tileSize[0]/p[0],o.tileSize[1]/p[1]],m=[Math.floor((s[0]-A[0])/v[0]),Math.ceil((s[0]+s[2]-A[0])/v[0])],y=m[0],w=m[1],b=[Math.floor((s[1]-A[1])/v[1]),Math.ceil((s[1]+s[3]-A[1])/v[1])],B=b[1],E=b[0];E<=B;E++)for(var x=y;x<=w;x++){var C=o.tiles[E][x];if(C){var M=[Math.floor(A[0]+C.tileX*v[0]),Math.floor(A[1]+C.tileY*v[1]),Math.ceil(v[0]),Math.ceil(v[1])];t.drawImage(C.data,M[0],M[1],M[2],M[3])}}t.setTransform(l,u,h,d,f,g)}else this.imagePool.createImageTiles(i,[],function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())},n).catch(function(t){console.error(t)})}},{key:"render",value:function(t,n,r){var i=n.x,o=void 0===i?0:i,A=n.y,s=void 0===A?0:A,a=n.width,c=n.height,l=n.src,u=n.shadowColor,h=n.shadowBlur,d=this.imagePool.getImageSync(l,r),f=null==d?void 0:d.img,g=a,p=c;if(f){var v,y,w,b,B,E,x,C,M,F,S,Q,U,N,T;g||(g=f.width),p||(p=f.height),eb(r,t,!Kt(u)&&h>0);try{var O=r.ownerDocument.defaultView.getContextService().getDomElement(),I=O.width,L=O.height,P=t.getTransform(),D=P.a,R=P.b,H=function(t,e){var n=bt(at(),[t[0],t[1],0],e),r=bt(at(),[t[0]+t[2],t[1],0],e),i=bt(at(),[t[0],t[1]+t[3],0],e),o=bt(at(),[t[0]+t[2],t[1]+t[3],0],e);return[Math.min(n[0],r[0],i[0],o[0]),Math.min(n[1],r[1],i[1],o[1]),Math.max(n[0],r[0],i[0],o[0])-Math.min(n[0],r[0],i[0],o[0]),Math.max(n[1],r[1],i[1],o[1])-Math.min(n[1],r[1],i[1],o[1])]}([o,s,g,p],k(D,P.c,0,0,R,P.d,0,0,0,0,1,0,P.e,P.f,0,1)),_=(v=H,y=m([0,0,I,L],4),w=y[0],b=y[1],B=y[2],E=y[3],x=m(v,4),C=x[0],M=x[1],F=x[2],S=x[3],Q=Math.max(w,C),U=Math.max(b,M),N=Math.min(w+B,C+F),T=Math.min(b+E,M+S),N<=Q||T<=U?null:[Q,U,N-Q,T-U]);if(!_)return;if(!r.ownerDocument.defaultView.getConfig().enableLargeImageOptimization)return void e.renderFull(t,n,r,{image:f,drawRect:[o,s,g,p]});if(H[2]/d.size[0]<(d.downSamplingRate||.5))return void this.renderDownSampled(t,n,r,{src:l,imageCache:d,drawRect:[o,s,g,p]});if(!ImagePool.isSupportTile)return void e.renderFull(t,n,r,{image:f,drawRect:[o,s,g,p]});this.renderTile(t,n,r,{src:l,imageCache:d,imageRect:H,drawRect:_})}catch(t){}}}},{key:"drawToContext",value:function(t,e,n,r,i){this.render(t,e.parsedStyle,e)}}],[{key:"renderFull",value:function(t,e,n,r){t.drawImage(r.image,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3]))}}])}(tb),ob=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"render",value:function(t,e,n,r,i,o){n.getBounds();var A=e.lineWidth,s=void 0===A?1:A,a=e.textAlign,c=void 0===a?"start":a,l=e.textBaseline,u=void 0===l?"alphabetic":l,h=e.lineJoin,d=void 0===h?"miter":h,f=e.miterLimit,g=void 0===f?10:f,p=e.letterSpacing,v=void 0===p?0:p,m=e.stroke,y=e.fill,w=e.fillRule,b=e.fillOpacity,B=void 0===b?1:b,E=e.strokeOpacity,x=void 0===E?1:E,C=e.opacity,M=void 0===C?1:C,F=e.metrics,k=e.x,S=void 0===k?0:k,Q=e.y,U=void 0===Q?0:Q,N=e.dx,T=e.dy,O=e.shadowColor,I=e.shadowBlur,L=e.textDecorationLine,P=F.font,D=F.lines,R=F.height,H=F.lineHeight,_=F.lineMetrics;t.font=P,t.lineWidth=s,t.textAlign="middle"===c?"center":c;var G=u;"alphabetic"===G&&(G="bottom"),t.lineJoin=d,Kt(g)||(t.miterLimit=g);var K=U;"middle"===u?K+=-R/2-H/2:"bottom"===u||"alphabetic"===u||"ideographic"===u?K+=-R:"top"!==u&&"hanging"!==u||(K+=-H);var j=S+(N||0);K+=T||0,1===D.length&&("bottom"===G?(G="middle",K-=.5*R):"top"===G&&(G="middle",K+=.5*R)),t.textBaseline=G,eb(n,t,!Kt(O)&&I>0);for(var z=0;z<D.length;z++){var V=s/2+j;K+=H,Kt(m)||m.isNone||!s||this.drawLetterSpacing(t,n,D[z],_[z],c,V,K,v,y,w,B,m,x,M,!0,r,i,o),Kt(y)||this.drawLetterSpacing(t,n,D[z],_[z],c,V,K,v,y,w,B,m,x,M,!1,r,i,o)}L&&"none"!==L&&this.drawTextDecorations(t,e,n,D,H,j,U+(T||0),r,i,o)}},{key:"drawLetterSpacing",value:function(t,e,n,r,i,o,A,s,a,c,l,u,h,d,f,g,p,v){if(0!==s){var m=t.textAlign;t.textAlign="left";var y=o;"center"===i||"middle"===i?y=o-r.width/2:"right"!==i&&"end"!==i||(y=o-r.width);for(var w=Array.from(n),b=t.measureText(n).width,B=0,E=0;E<w.length;++E){var x=w[E];f?this.strokeText(t,e,x,y,A,u,h,g,p,v):this.fillText(t,e,x,y,A,a,c,l,d,g,p,v),y+=b-(B=t.measureText(n.substring(E+1)).width)+s,b=B}t.textAlign=m}else f?this.strokeText(t,e,n,o,A,u,h,g,p,v):this.fillText(t,e,n,o,A,a,c,l,d,g,p,v)}},{key:"fillText",value:function(t,e,n,r,i,o,A,s,a,c,l,u){var h;nb(t,e,o,A,c,l,u,this.imagePool,!0);var d=!Kt(s)&&1!==s;d&&(h=t.globalAlpha,t.globalAlpha=s*a),t.fillText(n,r,i),d&&(t.globalAlpha=h)}},{key:"strokeText",value:function(t,e,n,r,i,o,A,s,a,c){var l;rb(t,e,o,s,a,c,this.imagePool,!0);var u=!Kt(A)&&1!==A;u&&(l=t.globalAlpha,t.globalAlpha=A),t.strokeText(n,r,i),u&&(t.globalAlpha=l)}},{key:"drawTextDecorations",value:function(t,e,n,r,i,o,A,s,a,c){var l=e.textDecorationLine,u=e.textDecorationColor,h=e.textDecorationStyle,d=e.textDecorationThickness,f=void 0===d?1:d,g=e.textAlign,p=void 0===g?"start":g,v=e.lineWidth,m=void 0===v?1:v,y=e.metrics;if(l&&"none"!==l){var w=y.lineMetrics,b=l.split(" ");switch(t.lineWidth=f,u&&(t.strokeStyle="rgba(".concat(u.r,", ").concat(u.g,", ").concat(u.b,", ").concat(u.alpha,")")),h){case"dashed":t.setLineDash([5,5]);break;case"dotted":t.setLineDash([2,2]);break;default:t.setLineDash([])}var B=A,E=e.textBaseline,x=void 0===E?"alphabetic":E;"middle"===x?B+=-y.height/2-i/2:"bottom"===x||"alphabetic"===x||"ideographic"===x?B+=-y.height:"top"!==x&&"hanging"!==x||(B+=-i);for(var C=0;C<r.length;C++){B+=i;var M=w[C];if(M){var F=m/2,k=o,S=o+M.width;"center"===p||"middle"===p?(k=o-M.width/2,S=o+M.width/2):"right"!==p&&"end"!==p||(k=o-M.width,S=o),k+=F,S+=F;var Q,U=sr(b);try{for(U.s();!(Q=U.n()).done;){var N=Q.value,T=B;switch(N){case"underline":T+=2;break;case"overline":T-=i-2;break;case"line-through":T-=i/2;break;default:continue}"wavy"===h?this.drawWavyLine(t,k,S,T):(t.beginPath(),t.moveTo(k,T),t.lineTo(S,T),t.stroke())}}catch(t){U.e(t)}finally{U.f()}}}t.setLineDash([])}}},{key:"drawWavyLine",value:function(t,e,n,r){var i=10,o=Math.floor((n-e)/i);t.beginPath(),t.moveTo(e,r);for(var A=0;A<o;A++){var s=e+A*i+2.5,a=r+2,c=e+A*i+5,l=r;t.quadraticCurveTo(s,a,c,l);var u=e+A*i+7.5,h=r-2,d=e+(A+1)*i,f=r;t.quadraticCurveTo(u,h,d,f)}t.stroke()}},{key:"drawToContext",value:function(t,e,n,r,i){this.render(t,e.parsedStyle,e,e.ownerDocument.defaultView.context,r,i)}}])}(tb),Ab=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),(t=g(this,e)).name="canvas-renderer",t.options=n,t}return v(e,t),a(e,[{key:"init",value:function(){var t,e=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new tb(n),A=(r(r(r(r(r(r(r(r(r(r(t={},cr.CIRCLE,i),cr.ELLIPSE,i),cr.RECT,i),cr.IMAGE,new ib(n)),cr.TEXT,new ob(n)),cr.LINE,i),cr.POLYLINE,i),cr.POLYGON,i),cr.PATH,i),cr.GROUP,void 0),r(r(r(t,cr.HTML,void 0),cr.MESH,void 0),cr.FRAGMENT,void 0));this.context.defaultStyleRendererFactory=A,this.context.styleRendererFactory=A,this.addRenderingPlugin(new zw(e))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory}}])}(ur),sb=at(),ab=at(),cb=at(),lb=C(),ub=function(){function t(){var e=this;A(this,t),this.isHit=function(t,n,r,i){var o=e.context.pointInPathPickerFactory[t.nodeName];if(o){var A=N(lb,r),s=bt(ab,dt(cb,n[0],n[1],0),A);if(o(t,new Er(s[0],s[1]),i,e.isPointInPath,e.context,e.runtime))return!0}return!1},this.isPointInPath=function(t,n){var r=e.runtime.offscreenCanvasCreator.getOrCreateContext(e.context.config.offscreenCanvas),i=e.context.pathGeneratorFactory[t.nodeName];return i&&(r.beginPath(),i(r,t.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return a(t,[{key:"apply",value:function(e,n){var r,i=this,o=e.renderingService,A=e.renderingContext;this.context=e,this.runtime=n;var s=null===(r=A.root)||void 0===r?void 0:r.ownerDocument;o.hooks.pick.tapPromise(t.tag,function(){var t=Ar(ir().mark(function t(e){return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i.pick(s,e));case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),o.hooks.pickSync.tap(t.tag,function(t){return i.pick(s,t)})}},{key:"pick",value:function(t,e){var n,r=e.topmost,i=e.position,o=i.x,A=i.y,s=dt(sb,o,A,0),a=[],c=sr(t.elementsFromBBox(s[0],s[1],s[0],s[1]));try{for(c.s();!(n=c.n()).done;){var l=n.value,u=l.getWorldTransform();if(this.isHit(l,s,u,!1)){var h=qA(l);if(h){var d=h.parsedStyle.clipPath;if(this.isHit(d,s,d.getWorldTransform(),!0)){if(r)return e.picked=[l],e;a.push(l)}}else{if(r)return e.picked=[l],e;a.push(l)}}}}catch(t){c.e(t)}finally{c.f()}return e.picked=a,e}}])}();function hb(t,e,n){var r=t.parsedStyle,i=r.cx,o=void 0===i?0:i,A=r.cy,s=void 0===A?0:A,a=r.r,c=r.fill,l=r.stroke,u=r.lineWidth,h=void 0===u?1:u,d=r.increasedLineWidthForHitTesting,f=void 0===d?0:d,g=r.pointerEvents,p=void 0===g?"auto":g,v=(h+f)/2,y=Nn(o,s,e.x,e.y),w=m(es(p,c,l),2),b=w[0],B=w[1];return b&&B||n?y<=a+v:b?y<=a:!!B&&(y>=a-v&&y<=a+v)}function db(t,e,n,r){return t/(n*n)+e/(r*r)}function fb(t,e,n){var r=t.parsedStyle,i=r.cx,o=void 0===i?0:i,A=r.cy,s=void 0===A?0:A,a=r.rx,c=r.ry,l=r.fill,u=r.stroke,h=r.lineWidth,d=void 0===h?1:h,f=r.increasedLineWidthForHitTesting,g=void 0===f?0:f,p=r.pointerEvents,v=void 0===p?"auto":p,y=e.x,w=e.y,b=m(es(v,l,u),2),B=b[0],E=b[1],x=(d+g)/2,C=(y-o)*(y-o),M=(w-s)*(w-s);return B&&E||n?db(C,M,a+x,c+x)<=1:B?db(C,M,a,c)<=1:!!E&&(db(C,M,a-x,c-x)>=1&&db(C,M,a+x,c+x)<=1)}function gb(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function pb(t,e,n,r,i,o,A,s){var a=(Math.atan2(s-e,A-t)+2*Math.PI)%(2*Math.PI),c={x:t+n*Math.cos(a),y:e+n*Math.sin(a)};return Nn(c.x,c.y,A,s)<=o/2}function vb(t,e,n,r,i,o,A){var s=Math.min(t,n),a=Math.max(t,n),c=Math.min(e,r),l=Math.max(e,r),u=i/2;return o>=s-u&&o<=a+u&&A>=c-u&&A<=l+u&&Hn(t,e,n,r,o,A)<=i/2}function mb(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var A=0;A<o-1;A++){if(vb(t[A][0],t[A][1],t[A+1][0],t[A+1][1],e,n,r))return!0}if(i){var s=t[0],a=t[o-1];if(vb(s[0],s[1],a[0],a[1],e,n,r))return!0}return!1}ub.tag="CanvasPicker";function yb(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function wb(t,e,n){return(n[0]-t[0])*(e[1]-t[1])===(e[0]-t[0])*(n[1]-t[1])&&Math.min(t[0],e[0])<=n[0]&&n[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=n[1]&&n[1]<=Math.max(t[1],e[1])}function bb(t,e,n){var r=!1,i=t.length;if(i<=2)return!1;for(var o=0;o<i;o++){var A=t[o],s=t[(o+1)%i];if(wb(A,s,[e,n]))return!0;yb(A[1]-n)>0!=yb(s[1]-n)>0&&yb(e-(n-A[1])*(A[0]-s[0])/(A[1]-s[1])-A[0])<0&&(r=!r)}return r}function Bb(t,e,n){for(var r=!1,i=0;i<t.length;i++){if(r=bb(t[i],e,n))break}return r}function Eb(t,e,n){var r=t.parsedStyle,i=r.x1,o=r.y1,A=r.x2,s=r.y2,a=r.lineWidth,c=void 0===a?1:a,l=r.increasedLineWidthForHitTesting,u=void 0===l?0:l,h=r.pointerEvents;return!(!m(es(void 0===h?"auto":h,r.fill,r.stroke),2)[1]&&!n||!c)&&vb(i,o,A,s,c+u,e.x,e.y)}function xb(t,e,n,r,i,o){var A=t.parsedStyle,s=A.lineWidth,a=void 0===s?1:s,c=A.increasedLineWidthForHitTesting,l=void 0===c?0:c,u=A.stroke,h=A.fill,d=A.d,f=A.pointerEvents,g=void 0===f?"auto":f,p=d.segments,v=d.hasArc,y=d.polylines,w=d.polygons,b=m(es(g,(null==w?void 0:w.length)&&h,u),2),B=b[0],E=b[1],x=Go(t),C=!1;return B||n?C=v?r(t,e):Bb(w,e.x,e.y)||Bb(y,e.x,e.y):((E||n)&&(C=function(t,e,n,r,i){for(var o=!1,A=e/2,s=0;s<t.length;s++){var a=t[s],c=a.currentPoint,l=a.params,u=a.prePoint,h=a.box;if(!h||gb(h.x-A,h.y-A,h.width+e,h.height+e,n,r))switch(a.command){case"L":case"Z":if(o=vb(u[0],u[1],c[0],c[1],e,n,r))return!0;break;case"Q":if(o=Xn(u[0],u[1],l[1],l[2],l[3],l[4],n,r)<=e/2)return!0;break;case"C":if(o=jn(u[0],u[1],l[1],l[2],l[3],l[4],l[5],l[6],n,r,i)<=e/2)return!0;break;case"A":a.cubicParams||(a.cubicParams=ln(u[0],u[1],l[1],l[2],l[3],l[4],l[5],l[6],l[7],void 0));for(var d=a.cubicParams,f=u,g=0;g<d.length;g+=6){var p=jn(f[0],f[1],d[g],d[g+1],d[g+2],d[g+3],d[g+4],d[g+5],n,r,i);if(f=[d[g+4],d[g+5]],o=p<=e/2)return!0}}}return o}(p,a+l,e.x,e.y,x)),C)}function Cb(t,e,n){var r=t.parsedStyle,i=r.stroke,o=r.fill,A=r.lineWidth,s=void 0===A?1:A,a=r.increasedLineWidthForHitTesting,c=void 0===a?0:a,l=r.points,u=r.pointerEvents,h=m(es(void 0===u?"auto":u,o,i),2),d=h[0],f=!1;return(h[1]||n)&&(f=mb(l.points,s+c,e.x,e.y,!0)),f||!d&&!n||(f=bb(l.points,e.x,e.y)),f}function Mb(t,e,n){var r=t.parsedStyle,i=r.lineWidth,o=void 0===i?1:i,A=r.increasedLineWidthForHitTesting,s=void 0===A?0:A,a=r.points,c=r.pointerEvents;return!(!m(es(void 0===c?"auto":c,r.fill,r.stroke),2)[1]&&!n||!o)&&mb(a.points,o+s,e.x,e.y,!1)}function Fb(t,e,n,r,i){var o=t.parsedStyle,A=o.radius,s=o.fill,a=o.stroke,c=o.lineWidth,l=void 0===c?1:c,u=o.increasedLineWidthForHitTesting,h=void 0===u?0:u,d=o.x,f=void 0===d?0:d,g=o.y,p=void 0===g?0:g,v=o.width,y=o.height,w=o.pointerEvents,b=m(es(void 0===w?"auto":w,s,a),2),B=b[0],E=b[1],x=A&&A.some(function(t){return 0!==t}),C=l+h;if(x){var M=!1;return(E||n)&&(M=function(t,e,n,r,i,o,A,s){var a=m(i,4),c=a[0],l=a[1],u=a[2],h=a[3];return vb(t+c,e,t+n-l,e,o,A,s)||vb(t+n,e+l,t+n,e+r-u,o,A,s)||vb(t+n-u,e+r,t+h,e+r,o,A,s)||vb(t,e+r-h,t,e+c,o,A,s)||pb(t+n-l,e+l,l,Math.PI,Math.PI,o,A,s)||pb(t+n-u,e+r-u,u,0,Math.PI,o,A,s)||pb(t+h,e+r-h,h,Math.PI,Math.PI,o,A,s)||pb(t+c,e+c,c,Math.PI,Math.PI,o,A,s)}(f,p,v,y,A.map(function(t){return ne(t,0,Math.min(Math.abs(v)/2,Math.abs(y)/2))}),C,e.x,e.y)),M||!B&&!n||(M=r(t,e)),M}var F=C/2;return B&&E||n?gb(f-F,p-F,v+F,y+F,e.x,e.y):B?gb(f,p,v,y,e.x,e.y):!!E&&function(t,e,n,r,i,o,A){var s=i/2;return gb(t-s,e-s,n,i,o,A)||gb(t+n-s,e-s,i,r,o,A)||gb(t+s,e+r-s,n,i,o,A)||gb(t-s,e+s,i,r,o,A)}(f,p,v,y,C,e.x,e.y)}function kb(t,e,n,r,i,A){var s=t.parsedStyle,a=s.pointerEvents,c=void 0===a?"auto":a,l=s.x,u=void 0===l?0:l,h=s.y,d=void 0===h?0:h,f=s.width,g=s.height;if("non-transparent-pixel"===c){var p=i.config.offscreenCanvas,v=A.offscreenCanvasCreator.getOrCreateCanvas(p),m=A.offscreenCanvasCreator.getOrCreateContext(p,{willReadFrequently:!0});return v.width=f,v.height=g,i.defaultStyleRendererFactory[cr.IMAGE].render(m,o(o({},t.parsedStyle),{},{x:0,y:0}),t,void 0,void 0,void 0),m.getImageData(e.x-u,e.y-d,1,1).data.every(function(t){return 0!==t})}return!0}function Sb(t,e,n,r){var i=t.getGeometryBounds();return e.x>=i.min[0]&&e.y>=i.min[1]&&e.x<=i.max[0]&&e.y<=i.max[1]}var Qb=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=g(this,e,[].concat(r))).name="canvas-picker",t}return v(e,t),a(e,[{key:"init",value:function(){var t,e=(r(r(r(r(r(r(r(r(r(r(t={},cr.CIRCLE,hb),cr.ELLIPSE,fb),cr.RECT,Fb),cr.LINE,Eb),cr.POLYLINE,Mb),cr.POLYGON,Cb),cr.PATH,xb),cr.TEXT,Sb),cr.GROUP,null),cr.IMAGE,kb),r(r(t,cr.HTML,null),cr.MESH,null));this.context.pointInPathPickerFactory=e,this.addRenderingPlugin(new ub)}},{key:"destroy",value:function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()}}])}(ur);function Ub(t,e){var n=e.cx,r=void 0===n?0:n,i=e.cy,o=void 0===i?0:i,A=e.r;t.arc(r,o,A,0,2*Math.PI,!1)}function Nb(t,e){var n=e.cx,r=void 0===n?0:n,i=e.cy,o=void 0===i?0:i,A=e.rx,s=e.ry;if(t.ellipse)t.ellipse(r,o,A,s,0,0,2*Math.PI,!1);else{var a=A>s?A:s,c=A>s?1:A/s,l=A>s?s/A:1;t.save(),t.scale(c,l),t.arc(r,o,a,0,2*Math.PI)}}function Tb(t,e){var n,r,i=e.x1,o=e.y1,A=e.x2,s=e.y2,a=e.markerStart,c=e.markerEnd,l=e.markerStartOffset,u=e.markerEndOffset,h=0,d=0,f=0,g=0,p=0;a&&Ra(a)&&l&&(n=A-i,r=s-o,p=Math.atan2(r,n),h=Math.cos(p)*(l||0),d=Math.sin(p)*(l||0)),c&&Ra(c)&&u&&(n=i-A,r=o-s,p=Math.atan2(r,n),f=Math.cos(p)*(u||0),g=Math.sin(p)*(u||0)),t.moveTo(i+h,o+d),t.lineTo(A+f,s+g)}function Ob(t,e){var n,r,i=e.markerStart,o=e.markerEnd,A=e.markerStartOffset,s=e.markerEndOffset,a=e.d,c=a.absolutePath,l=a.segments,u=0,h=0,d=0,f=0,g=0;if(i&&Ra(i)&&A){var p=m(i.parentNode.getStartTangent(),2),v=p[0],y=p[1];n=v[0]-y[0],r=v[1]-y[1],g=Math.atan2(r,n),u=Math.cos(g)*(A||0),h=Math.sin(g)*(A||0)}if(o&&Ra(o)&&s){var w=m(o.parentNode.getEndTangent(),2),b=w[0],B=w[1];n=b[0]-B[0],r=b[1]-B[1],g=Math.atan2(r,n),d=Math.cos(g)*(s||0),f=Math.sin(g)*(s||0)}for(var E=0;E<c.length;E++){var x=c[E],C=x[0],M=c[E+1],F=0===E&&(0!==u||0!==h),k=(E===c.length-1||M&&("M"===M[0]||"Z"===M[0]))&&0!==d&&0!==f,S=m(F?[u,h]:[0,0],2),Q=S[0],U=S[1],N=m(k?[d,f]:[0,0],2),T=N[0],O=N[1];switch(C){case"M":t.moveTo(x[1]+Q,x[2]+U);break;case"L":t.lineTo(x[1]+T,x[2]+O);break;case"Q":t.quadraticCurveTo(x[1],x[2],x[3]+T,x[4]+O);break;case"C":t.bezierCurveTo(x[1],x[2],x[3],x[4],x[5]+T,x[6]+O);break;case"A":var I=l[E].arcParams,L=I.cx,P=I.cy,D=I.rx,R=I.ry,H=I.startAngle,_=I.endAngle,G=I.xRotation,K=I.sweepFlag;if(t.ellipse)t.ellipse(L,P,D,R,G,H,_,!!(1-K));else{var j=D>R?D:R,z=D>R?1:D/R,V=D>R?R/D:1;t.translate(L,P),t.rotate(G),t.scale(z,V),t.arc(0,0,j,H,_,!!(1-K)),t.scale(1/z,1/V),t.rotate(-G),t.translate(-L,-P)}k&&t.lineTo(x[6]+d,x[7]+f);break;case"Z":t.closePath()}}}function Ib(t,e){var n,r,i=e.markerStart,o=e.markerEnd,A=e.markerStartOffset,s=e.markerEndOffset,a=e.points.points,c=a.length,l=a[0][0],u=a[0][1],h=a[c-1][0],d=a[c-1][1],f=0,g=0,p=0,v=0,m=0;i&&Ra(i)&&A&&(n=a[1][0]-a[0][0],r=a[1][1]-a[0][1],m=Math.atan2(r,n),f=Math.cos(m)*(A||0),g=Math.sin(m)*(A||0)),o&&Ra(o)&&s&&(n=a[c-1][0]-a[0][0],r=a[c-1][1]-a[0][1],m=Math.atan2(r,n),p=Math.cos(m)*(s||0),v=Math.sin(m)*(s||0)),t.moveTo(l+(f||p),u+(g||v));for(var y=1;y<c-1;y++){var w=a[y];t.lineTo(w[0],w[1])}t.lineTo(h,d)}function Lb(t,e){var n,r,i=e.markerStart,o=e.markerEnd,A=e.markerStartOffset,s=e.markerEndOffset,a=e.points.points,c=a.length,l=a[0][0],u=a[0][1],h=a[c-1][0],d=a[c-1][1],f=0,g=0,p=0,v=0,m=0;i&&Ra(i)&&A&&(n=a[1][0]-a[0][0],r=a[1][1]-a[0][1],m=Math.atan2(r,n),f=Math.cos(m)*(A||0),g=Math.sin(m)*(A||0)),o&&Ra(o)&&s&&(n=a[c-2][0]-a[c-1][0],r=a[c-2][1]-a[c-1][1],m=Math.atan2(r,n),p=Math.cos(m)*(s||0),v=Math.sin(m)*(s||0)),t.moveTo(l+f,u+g);for(var y=1;y<c-1;y++){var w=a[y];t.lineTo(w[0],w[1])}t.lineTo(h+p,d+v)}function Pb(t,e){var n=e.x,r=void 0===n?0:n,i=e.y,o=void 0===i?0:i,A=e.radius,s=e.width,a=e.height,c=s,l=a,u=A&&A.some(function(t){return 0!==t});if(u){var h=s>0?1:-1,d=a>0?1:-1,f=h+d===0,g=A.map(function(t){return ne(t,0,Math.min(Math.abs(c)/2,Math.abs(l)/2))}),p=m(g,4),v=p[0],y=p[1],w=p[2],b=p[3];t.moveTo(h*v+r,o),t.lineTo(c-h*y+r,o),0!==y&&t.arc(c-h*y+r,d*y+o,y,-d*Math.PI/2,h>0?0:Math.PI,f),t.lineTo(c+r,l-d*w+o),0!==w&&t.arc(c-h*w+r,l-d*w+o,w,h>0?0:Math.PI,d>0?Math.PI/2:1.5*Math.PI,f),t.lineTo(h*b+r,l+o),0!==b&&t.arc(h*b+r,l-d*b+o,b,d>0?Math.PI/2:-Math.PI/2,h>0?Math.PI:0,f),t.lineTo(r,d*v+o),0!==v&&t.arc(h*v+r,d*v+o,v,h>0?Math.PI:0,d>0?1.5*Math.PI:Math.PI/2,f)}else t.rect(r,o,c,l)}var Db=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=g(this,e,[].concat(r))).name="canvas-path-generator",t}return v(e,t),a(e,[{key:"init",value:function(){var t,e=(r(r(r(r(r(r(r(r(r(r(t={},cr.CIRCLE,Ub),cr.ELLIPSE,Nb),cr.RECT,Pb),cr.LINE,Tb),cr.POLYLINE,Lb),cr.POLYGON,Ib),cr.PATH,Ob),cr.TEXT,void 0),cr.GROUP,void 0),cr.IMAGE,void 0),r(r(r(t,cr.HTML,void 0),cr.MESH,void 0),cr.FRAGMENT,void 0));this.context.pathGeneratorFactory=e}},{key:"destroy",value:function(){delete this.context.pathGeneratorFactory}}])}(ur),Rb=function(){return a(function t(e){A(this,t),this.renderingContext=e.renderingContext,this.canvasConfig=e.config},[{key:"init",value:function(){var t=this.canvasConfig,e=t.container,n=t.canvas;if(n)this.$canvas=n,e&&n.parentElement!==e&&e.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(e&&(this.$container=Jt(e)?document.getElementById(e):e,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)}},{key:"getContext",value:function(){return this.context}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getDPR",value:function(){return this.dpr}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(t,e){var n=this.canvasConfig.devicePixelRatio;this.dpr=n,this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*e,function(t,e,n){WA&&t.style&&(t.style.width=e+"px",t.style.height=n+"px")}(this.$canvas,t,e)),this.renderingContext.renderReasons.add($s.CAMERA_CHANGED)}},{key:"applyCursorStyle",value:function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)}},{key:"toDataURL",value:(t=Ar(ir().mark(function t(){var e,n,r,i=arguments;return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=(e=i.length>0&&void 0!==i[0]?i[0]:{}).type,r=e.encoderOptions,t.abrupt("return",this.context.canvas.toDataURL(n,r));case 1:case"end":return t.stop()}},t,this)})),function(){return t.apply(this,arguments)})}]);var t}(),Hb=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=g(this,e,[].concat(r))).name="canvas-context-register",t}return v(e,t),a(e,[{key:"init",value:function(){this.context.ContextService=Rb}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(ur),_b=function(t){function e(t){var n;return A(this,e),(n=g(this,e,[t])).registerPlugin(new Hb),n.registerPlugin(new Oc.Plugin),n.registerPlugin(new Db),n.registerPlugin(new Ab),n.registerPlugin(new Hc.Plugin),n.registerPlugin(new Qb),n.registerPlugin(new Pc.Plugin),n}return v(e,t),a(e)}(hr);class Gb extends Nw{constructor(t){super(Object.assign(Object.assign({},t),{style:Object.assign({},Gb.defaultStyleProps,t.style)})),this.rootPointerEvent=new js(null),this.forwardEvents=t=>{const e=this.context.canvas,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach(r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);Me(e.context.eventService,"mappingTable.pointerupoutside",[]),e.context.eventService.mapEvent(i)})}}get eventService(){return this.context.canvas.context.eventService}get events(){return[t.CommonEvent.CLICK,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_UP,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE]}getDomElement(){return this.getShape("key").getDomElement()}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.drawPortShapes(t,e)}getKeyStyle(t){const e=ke(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Pe(e,["dx","dy"]),[o,A]=this.getSize(t);return Object.assign(Object.assign({x:n,y:r},i),{width:o,height:A})}drawKeyShape(t,e){const n=this.getKeyStyle(t),{x:r,y:i,width:o=0,height:A=0}=n,s=this.upsert("key-container",sc,{x:r,y:i,width:o,height:A,opacity:0},e);return this.upsert("key",$a,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof _b))return;const t=this.getDomElement();this.events.forEach(e=>{t.addEventListener(e,this.forwardEvents)})}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}destroy(){const t=this.getDomElement();this.events.forEach(e=>{t.removeEventListener(e,this.forwardEvents)}),super.destroy()}normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;e<t.changedTouches.length;e++){const r=t.changedTouches[e];de(r.button)&&(r.button=0),de(r.buttons)&&(r.buttons=1),de(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),de(r.width)&&(r.width=r.radiusX||1),de(r.height)&&(r.height=r.radiusY||1),de(r.tiltX)&&(r.tiltX=0),de(r.tiltY)&&(r.tiltY=0),de(r.pointerType)&&(r.pointerType="touch"),de(r.pointerId)&&(r.pointerId=r.identifier||0),de(r.pressure)&&(r.pressure=r.force||.5),de(r.twist)&&(r.twist=0),de(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;de(e.isPrimary)&&(e.isPrimary=!0),de(e.width)&&(e.width=1),de(e.height)&&(e.height=1),de(e.tiltX)&&(e.tiltX=0),de(e.tiltY)&&(e.tiltY=0),de(e.pointerType)&&(e.pointerType="mouse"),de(e.pointerId)&&(e.pointerId=1),de(e.pressure)&&(e.pressure=.5),de(e.twist)&&(e.twist=0),de(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}bootstrapEvent(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const[A,s]=this.context.canvas.getCanvasByViewport([i,o]);return t.canvas.x=A,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:A}=t;if(Kt(r)||Kt(i)){const t=this.eventService.client2Viewport({x:o,y:A});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}onframe(){super.onframe();const{opacity:t}=this.attributes;this.getDomElement().style.opacity=`${t}`}}Gb.defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};let Kb=class t extends Nw{constructor(e){super(uw({style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),r=super.getKeyStyle(t),{fillOpacity:i,opacity:o=i}=r,A=Pe(r,["fillOpacity","opacity"]);return Object.assign(Object.assign({opacity:o},A),{width:e,height:n,x:-e/2,y:-n/2})}getBounds(){return this.getShape("key").getBounds()}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getShape("key").attributes,{fill:n,stroke:r}=e;Pe(e,["fill","stroke"]);const i=Aw(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[A,s]=ay(yy(this.getSize(t)),[o,o]),{lineWidth:a}=i,c={fill:"transparent",lineWidth:a/2,width:A-a/2,height:s-a/2,x:-(A-a/2)/2,y:-(s-a/2)/2};return Object.assign(Object.assign({},i),c)}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&Object.assign({width:n*qy,height:r*qy},e)}drawKeyShape(t,e){const n=this.upsert("key",Cw,this.getKeyStyle(t),e);return kw(this),n}drawHaloShape(t,e){this.upsert("halo",sc,this.getHaloStyle(t),e)}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Sw(this)}};Kb.defaultStyleProps={size:32};class jb extends Nw{constructor(t){super(t)}getKeyStyle(t){const[e,n]=this.getSize(t);return Object.assign(Object.assign({},super.getKeyStyle(t)),{width:e,height:n,x:-e/2,y:-n/2})}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getShape("key").attributes;return!!e&&Object.assign({width:n*qy,height:r*qy},e)}drawKeyShape(t,e){return this.upsert("key",sc,this.getKeyStyle(t),e)}}class zb extends Ow{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*qy;return!!e&&Object.assign({width:n,height:n},e)}getPortXY(t,e){const{placement:n="top"}=e,r=this.getShape("key").getLocalBounds(),i=function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t));return GB(r,n,i,!1)}}class Vb extends Ow{constructor(t){super(uw({style:Vb.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getShape("key").getLocalBounds(),[o,A]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,A,n);return GB(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||Ee(n||r))return!1;const o=Aw(this.getGraphicStyle(t),"icon"),A=this.getShape("key").getLocalBounds(),[s,a]=function(t,e){const{center:n}=t,[r,i]=wm(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(A,i),c=2*function(t,e){let[n,r]=wm(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(Math.pow(r,2)-Math.pow(Math.sqrt(Math.pow(n/2,2)+Math.pow(r,2))-n/2,2))/(2*r)}(A,i)*qy;return Object.assign({x:s,y:a,width:c,height:c},o)}}Vb.defaultStyleProps={size:40,direction:"up"};class Wb extends Nw{constructor(t){super(uw({style:Wb.defaultStyleProps},t)),this.type="combo",this.updateComboPosition(this.parsedAttributes)}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,A]=pm(e);return ay(cw(n),[A+i,r+o,0])}getCollapsedKeySize(t){return cw(t.collapsedSize)}getExpandedKeySize(t){const e=this.getContentBBox(t);return[mm(e),ym(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=e.map(t=>this.context.element.getElement(t)).filter(Boolean);if(0===r.length){const e=new yr,{x:n=0,y:r=0,size:i}=t,[o,A]=cw(i);return e.setMinMax([n-o/2,r-A/2,0],[n+o/2,r+A/2,0]),e}const i=xm(r.map(t=>t.getBounds()));return n?Em(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",Qw,n,e),kw(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Aw(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Pe(e,["type"]),i=this.getShape("key"),[o,A]=ky(i.getLocalBounds(),"center"),s=Object.assign(Object.assign({},r),{x:o,y:A});if(n){const e=this.getCollapsedMarkerText(n,t);Object.assign(s,{text:e})}return s}getCollapsedMarkerText(t,e){const{childrenData:n=[]}=e,{model:r}=this.context;return"descendant-count"===t?r.getDescendantsData(this.id).length.toString():"child-count"===t?n.length.toString():"node-count"===t?r.getDescendantsData(this.id).filter(t=>"node"===r.getElementType(Km(t))).length.toString():Gt(t)?t(n):""}getComboPosition(t){const{x:e=0,y:n=0,collapsed:r,childrenData:i=[]}=t;if(0===i.length)return[+e,+n,0];if(r){const{model:t}=this.context,r=t.getDescendantsData(this.id).filter(e=>!t.isCombo(Km(e)));if(r.length>0&&r.some(Fy)){return uy(r.reduce((t,e)=>ay(t,My(e)),[0,0,0]),r.length)}return[+e,+n,0]}return this.getContentBBox(t).center}getComboStyle(t){const[e,n]=this.getComboPosition(t);return{x:e,y:n,transform:[["translate",e,n]]}}updateComboPosition(t){const e=this.getComboStyle(t);Object.assign(this.style,e);const{x:n,y:r}=e;this.context.model.syncNodeLikeDatum({id:this.id,style:{x:n,y:r}}),Sw(this)}render(t,e=this){super.render(t,e),this.drawCollapsedMarkerShape(t,e)}update(t={}){super.update(t),this.updateComboPosition(this.parsedAttributes)}onframe(){super.onframe(),this.attributes.collapsed||this.updateComboPosition(this.parsedAttributes),this.drawKeyShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(this.attributes.collapsed?t:t.map(t=>{var{x:e,y:n,z:r,transform:i}=t;return Pe(t,["x","y","z","transform"])}),e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then(()=>this.onframe()),Reflect.set(t,e,n))}):n}}Wb.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Yb extends Wb{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",za,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),[r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},n),e&&Aw(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=cw(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=wm(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}}class Xb extends Wb{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",sc,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},e),t.collapsed&&Aw(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const qb={padding:10};function $b(t,e,n,r,i,o){const{padding:A}=Object.assign(qb,o),s=bm(n,A),a=bm(r,A),c=[t,...i,e];let l=null;const u=[];for(let t=0,e=c.length;t<e-1;t++){const n=t+1,r=c[t],i=c[n],o=Oy(r,i);let h=null;if(0===t)if(n===e-1)if(s.intersects(a))h=AB(r,i,s,a);else if(Fm(r,s)||Fm(i,a))o||(h=oB(r,i,s,a));else{const t=Sm(r,s),e=Sm(i,a);h=nB(t,e,tB(t,e)),h.points.unshift(t),h.points.push(e)}else Cm(i,s)?h=AB(r,i,s,bm(i,A),l):o||(h=rB(r,i,s));else n===e-1?Cm(r,a)?h=AB(r,i,bm(r,A),a,l):o||(h=iB(r,i,a,l)):o||(h=nB(r,i,l));h?(u.push(...h.points),l=h.direction):l=tB(r,i),n<e-1&&u.push(i)}return u.map(yy)}const Zb={N:"S",S:"N",W:"E",E:"W"},Jb={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function tB(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function eB(t,e){return"N"===e||"S"===e?ym(t):mm(t)}function nB(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=tB(t,r),A=tB(t,i),s=n?Zb[n]:null,a=o===n||o!==s&&A!==n?r:i;return{points:[a],direction:tB(a,e)}}function rB(t,e,n){if(Fm(t,n)){const r=sB(t,e,n);return{points:[r],direction:tB(r,e)}}{const r=Sm(t,n),i=["left","right"].includes(km(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:tB(i,e)}}}function iB(t,e,n,r){const i=Fm(e,n)?e:Sm(e,n),o=[[i[0],t[1]],[t[0],i[1]]],A=o.filter(t=>function(t,e){return!Cm(t,e)}(t,n)&&!Mm(t,n,!0)),s=A.filter(e=>tB(e,t)!==r);if(s.length>0){const n=s.find(e=>tB(t,e)===r)||s[0];return{points:[n],direction:tB(n,e)}}{const i=Ny(e,_t(o,A)[0],eB(n,r)/2);return{points:[sB(i,t,n),i],direction:tB(i,e)}}}function oB(t,e,n,r){let i=rB(t,e,n);const o=wy(i.points[0]);if(Cm(o,r)){i=rB(e,t,r);const A=wy(i.points[0]);if(Cm(A,n)){const s=Ny(t,o,eB(n,tB(t,o))/2),a=Ny(e,A,eB(r,tB(e,A))/2),c=[(s[0]+a[0])/2,(s[1]+a[1])/2],l=rB(t,c,n),u=iB(c,e,r,l.direction);i.points=[l.points[0],u.points[0]],i.direction=u.direction}}return i}function AB(t,e,n,r,i){const o=.01,A=xm([n,r]),s=dy(e,A.center)>dy(t,A.center),[a,c]=s?[e,t]:[t,e],l=ym(A)+mm(A);let u;if(i){const t=[a[0]+l*Math.cos(Jb[i]),a[1]+l*Math.sin(Jb[i])];u=Ny(Sm(t,A),t,o)}else u=Ny(Sm(a,A),a,-.01);let h=sB(u,c,A),d=[Uy(u,2),Uy(h,2)];if(xe(Uy(u),Uy(h))){const t=py(cy(u,a),[1,0,0])+Math.PI/2;h=[c[0]+l*Math.cos(t),c[1]+l*Math.sin(t),0],h=Uy(Ny(Sm(h,A),c,-.01),2);d=[u,sB(u,h,A),h]}return{points:s?d.reverse():d,direction:tB(s?u:h,e)}}function sB(t,e,n){let r=[t[0],e[1]];return Cm(r,n)&&(r=[e[0],t[1]]),r}function aB(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const A=Sy(t.getPoint(o)),s=Sy(t.getPoint(o+.01));let a="start"===e?"left":"end"===e?"right":"center";if(Ty(A,s)||!n){const[e,n]=cB(t,o,r,i);return{transform:[["translate",e,n]],textAlign:a}}let c=Math.atan2(s[1]-A[1],s[0]-A[0]);s[0]<A[0]&&(a="center"===a?a:"left"===a?"right":"left",r*=-1,c+=Math.PI);const[l,u]=cB(t,o,r,i,c);return{textAlign:a,transform:[["translate",l,u],["rotate",c/Math.PI*180]]}}function cB(t,e,n,r,i){const[o,A]=Sy(t.getPoint(e));let s=n,a=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),a=n*Math.sin(i)+r*Math.cos(i)),[o+s,A+a]}function lB(t,e,n,r){if(xe(t,e))return t;const i=cy(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],A=gy(vy(i,!1));return o[0]+=r*A[0],o[1]+=r*A[1],o}function uB(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function hB(t,e=0,n=!1){const r=t.length-1,i=t[0],o=t[r],A=t.slice(1,r),s=[["M",i[0],i[1]]];return A.forEach((t,n)=>{const r=A[n-1]||i,a=A[n+1]||o;if(!Iy(r,t,a)&&e){const[n,i]=function(t,e,n,r){const i=fy(t,e),o=fy(n,e),A=Math.min(r,Math.min(i,o)/2),s=[e[0]-A/i*(e[0]-t[0]),e[1]-A/i*(e[1]-t[1])],a=[e[0]-A/o*(e[0]-n[0]),e[1]-A/o*(e[1]-n[1])];return[s,a]}(r,t,a,e);s.push(["L",n[0],n[1]],["Q",t[0],t[1],i[0],i[1]],["L",i[0],i[1]])}else s.push(["L",t[0],t[1]])}),s.push(["L",o[0],o[1]]),n&&s.push(["Z"]),s}function dB(t,e,n,r,i){const o=bm(t),A=t.getCenter();let s=r&&zB(r),a=i&&zB(i);if(!s||!a){const r=(t=>{const e=Math.PI/2,n=ym(t)/2,r=mm(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}})(o),i=r[e][0],c=r[e][1],[l,u]=wm(o),h=Math.max(l,u),d=ay(A,[h*Math.cos(i),h*Math.sin(i),0]),f=ay(A,[h*Math.cos(c),h*Math.sin(c),0]);s=XB(t,d),a=XB(t,f),n||([s,a]=[a,s])}return[s,a]}function fB(t,e,n,r,i,o){const A=t.getPorts()[i||o],s=t.getPorts()[o||i];let[a,c]=dB(t,e,n,A,s);const l=function(t,e,n,r){const i=t.getCenter();if(xe(e,n)){const t=cy(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[ay(e,o),ay(n,ly(o,[1,-1,1]))]}return[Ny(i,e,dy(i,e)+r),Ny(i,n,dy(i,n)+r)]}(t,a,c,r);return A&&(a=YB(A,l[0])),s&&(c=YB(s,l.at(-1))),uB(a,c,l)}function gB(t,e,n,r,i,o,A){const s=KB(t),a=s[o||A],c=s[A||o];let[l,u]=dB(t,n,r,a,c);const h=function(t,e,n,r){const i=[],o=bm(t);if(xe(e,n)){switch(km(e,o)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=km(e,o),A=km(n,o);if(t===A){let o,A;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":A=Math.min(e[1],n[1])-r,i.push([e[0],A]),i.push([n[0],A]);break;case"bottom":A=Math.max(e[1],n[1])+r,i.push([e[0],A]),i.push([n[0],A])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),a=s(t,e),c=s(A,n),l=sB(a,c,o);i.push(a,l,c)}}return i}(t,l,u,i);return a&&(l=YB(a,h[0])),c&&(u=YB(c,h.at(-1))),hB([l,...h,u],e)}function pB(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach(o=>{e(o).forEach(e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)})}),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}function vB(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(Km(r));if(!t)break;r=t}if(n.some(t=>{var e;return null===(e=t.style)||void 0===e?void 0:e.collapsed})){const t=n.reverse().findIndex(rw);return n[t]||n.at(-1)}return t}const mB=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var yB=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",-t/2,0],["A",n,n,0,1,0,2*n-t/2,0],["A",n,n,0,1,0,-t/2,0],["Z"]]},diamond:(t,e)=>[["M",-t/2,0],["L",0,-e/2],["L",t/2,0],["L",0,e/2],["Z"]],rect:(t,e)=>[["M",-t/2,-e/2],["L",t/2,-e/2],["L",t/2,e/2],["L",-t/2,e/2],["Z"]],simple:(t,e)=>[["M",t/2,-e/2],["L",-t/2,0],["L",t/2,0],["L",-t/2,0],["L",t/2,e/2]],triangle:mB,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",-n,0],["L",0,-e/2],["L",0,e/2],["Z"],["M",i-n,-e/2],["L",i+r-n,-e/2],["L",i+r-n,e/2],["L",i-n,e/2],["Z"]]},vee:(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",4*t/5-t/2,0],["L",t/2,e/2],["Z"]]});class wB extends Uw{constructor(t){super(uw({style:wB.defaultStyleProps},t)),this.type="edge"}get sourceNode(){const{sourceNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}get targetNode(){const{targetNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}getKeyStyle(t){const e=this.getGraphicStyle(t),{loop:n}=e,r=Pe(e,["loop"]),{sourceNode:i,targetNode:o}=this;var A,s;const a={d:n&&(s=o,(A=i)&&s&&A===s)?this.getLoopPath(t):this.getKeyPath(t)};return nc.PARSED_STYLE_LIST.forEach(t=>{t in r&&(a[t]=r[t])}),a}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=bm(r),o=Math.max(mm(i),ym(i)),{placement:A,clockwise:s,dist:a=o}=Aw(this.getGraphicStyle(t),"loop");return fB(r,A,s,a,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:A}=this,[s,a]=function(t,e,n,r){const i=VB(t,e,n,r),o=VB(e,t,r,n);return[i,o]}(o,A,r,i);if(!e){return[s?zB(s):o.getCenter(),a?zB(a):A.getCenter()]}const c="function"==typeof n?n():n;return[WB(s||o,c[0]||a||A),WB(a||A,c[c.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Aw(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Aw(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:A}=e,s=Pe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),a=aB(this.shapeMap.key,n,o,r,i),c=this.shapeMap.key.getLocalBounds(),l=function(t,e,n=1){return fw(dy(t[0],t[1])*n,e)}([c.min,c.max],A);return Object.assign({wordWrapWidth:l},a,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Aw(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Pe(e,["offsetX","offsetY","placement"]);return Object.assign(o,function(t,e,n,r,i){var o,A;const s=2*(null===(o=t.badge)||void 0===o?void 0:o.getGeometryBounds().halfExtents[0])||0,a=2*(null===(A=t.label)||void 0===A?void 0:A.getGeometryBounds().halfExtents[0])||0;return aB(t.key,n,!0,(a?(a/2+s/2)*("suffix"===e?1:-1):0)+r,i)}(this.shapeMap,i,t.labelPlacement,n,r))}drawArrow(t,e){var n;const r="start"===e,i=t["start"===e?"startArrow":"endArrow"],o=this.shapeMap.key;if(i){const e=this.getArrowStyle(t,r),[n,i,A]=r?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],s=o.parsedStyle[n];if(s)s.attr(e);else{const t=new(e.src?Za:nc)({style:e});o.style[n]=t}o.style[i]=t[A]||e.width/2+ +e.lineWidth}else{const t=r?"markerStart":"markerEnd";null===(n=o.style[t])||void 0===n||n.destroy(),o.style[t]=null}}getArrowStyle(t,e){const n=this.getShape("key").attributes,r=e?"startArrow":"endArrow",i=Aw(this.getGraphicStyle(t),r),{size:o,type:A}=i,s=Pe(i,["size","type"]),[a,c]=cw(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),l=(Gt(A)?A:yB[A]||mB)(a,c);return Object.assign(ke(n,["stroke","strokeOpacity","fillOpacity"]),{width:a,height:c},Object.assign({},l&&{d:l,fill:"simple"===A?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",yw,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",nc,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",ww,n,e)}drawSourceArrow(t){this.drawArrow(t,"start")}drawTargetArrow(t){this.drawArrow(t,"end")}drawKeyShape(t,e){const n=this.getKeyStyle(t);return this.upsert("key",nc,n,e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.getShape("key")&&(this.drawSourceArrow(t),this.drawTargetArrow(t),this.drawLabelShape(t,e),this.drawHaloShape(t,e),this.drawBadgeShape(t,e))}onframe(){this.drawKeyShape(this.parsedAttributes,this),this.drawSourceArrow(this.parsedAttributes),this.drawTargetArrow(this.parsedAttributes),this.drawHaloShape(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this),this.drawBadgeShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(t,e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then(()=>this.onframe()),Reflect.set(t,e,n))}):n}}wB.defaultStyleProps={badge:!0,badgeOffsetX:0,badgeOffsetY:0,badgePlacement:"suffix",isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,loop:!0,startArrow:!1,startArrowLineDash:0,startArrowLineJoin:"round",startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"vee",endArrow:!1,endArrowLineDash:0,endArrowLineJoin:"round",endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"vee",loopPlacement:"top",loopClockwise:!0};class bB extends wB{constructor(t){super(uw({style:bB.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,A=this.getControlPoints(e,n,function(t){return re(t)?[t,1-t]:t}(i),function(t){return re(t)?[t,-t]:t}(o),r);return uB(e,n,A)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[lB(t,e,n[0],r[0]),lB(t,e,n[1],r[1])]}}bB.defaultStyleProps={curvePosition:.5,curveOffset:20};class BB extends bB{constructor(t){super(uw({style:BB.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}BB.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class EB extends bB{constructor(t){super(uw({style:EB.defaultStyleProps},t))}get ref(){return this.context.model.getRootsData()[0]}getEndpoints(t){if(this.sourceNode.id===this.ref.id)return super.getEndpoints(t);const e=My(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=My(this.ref);return[dy(t,e),by(cy(t,e))]}getControlPoints(t,e,n,r){const[i,o]=this.toRadialCoordinate(t),[A]=this.toRadialCoordinate(e),s=A-i;return[[t[0]+(s*n[0]+r[0])*Math.cos(o),t[1]+(s*n[0]+r[0])*Math.sin(o)],[e[0]-(s*n[1]-r[0])*Math.cos(o),e[1]-(s*n[1]-r[0])*Math.sin(o)]]}}EB.defaultStyleProps={curvePosition:.5,curveOffset:20};class xB extends bB{constructor(t){super(uw({style:xB.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}xB.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let CB=class t extends wB{constructor(e){super(uw({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};CB.defaultStyleProps={};const MB={enableObstacleAvoidance:!1,offset:10,maxAllowedDirectionChange:Math.PI/2,maximumLoops:3e3,gridSize:5,startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{right:{stepX:1,stepY:0},left:{stepX:-1,stepY:0},bottom:{stepX:0,stepY:1},top:{stepX:0,stepY:-1}},penalties:{0:0,90:0},distFunc:fy},FB=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function kB(t,e){const n=t=>Math.round(t/e);return re(t)?n(t):t.map(n)}function SB(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function QB(t,e,n,r){const i=SB(t,e),o=n[FB(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(SB(o||r,t),i)}function UB(t,e,n){return Math.min(...e.map(e=>n(t,e)))}const NB=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,A=Em(e.getRenderBounds(),o),s=Object.keys(i).reduce((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=wm(A),a=[t[0]+n.stepX*o,t[1]+n.stepY*s],c=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],A=[r,i],s=[r,n],a=[e,n];return[[o,A],[A,s],[s,a],[a,o]]}(A);for(let n=0;n<c.length;n++){const r=xy([t,a],c[n]);r&&Mm(r,A)&&e.push(r)}}return e},[]);return Cm(t,A)||s.push(t),s.map(t=>kB(t,r.gridSize))},TB=(t,e,n,r,i,o,A)=>{const s=[];let a=[o[0]===r[0]?r[0]:t[0]*A,o[1]===r[1]?r[1]:t[1]*A];s.unshift(a);let c=t,l=e[FB(c)];for(;l;){const t=l,r=c;QB(t,r,e,n)&&(a=[t[0]===r[0]?a[0]:t[0]*A,t[1]===r[1]?a[1]:t[1]*A],s.unshift(a)),l=e[FB(t)],c=t}const u=i.map(t=>[t[0]*A,t[1]*A]),h=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o<t.length;o++){const A=t[o],s=n(A,e);s<i&&(r=A,i=s)}return r}(u,a,fy);return s.unshift(h),s};function OB(t,e,n,r){const i=yy(t.getCenter()),o=yy(e.getCenter()),A=Object.assign(MB,r),{gridSize:s}=A,a=((t,e)=>{const{offset:n,gridSize:r}=e,i={};return t.forEach(t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Em(t.getRenderBounds(),n);for(let t=kB(e.min[0],r);t<=kB(e.max[0],r);t+=1)for(let n=kB(e.min[1],r);n<=kB(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0}),i})(A.enableObstacleAvoidance?n:[t,e],A),c=kB(i,s),l=kB(o,s),u=NB(i,t,A.startDirections,A),h=NB(o,e,A.endDirections,A);u.forEach(t=>delete a[FB(t)]),h.forEach(t=>delete a[FB(t)]);const d={},f={},g={},p={},v={},m=new IB;for(let t=0;t<u.length;t++){const e=u[t],n=FB(e);d[n]=e,p[n]=0,v[n]=UB(e,h,A.distFunc),m.add({id:n,value:v[n]})}const y=h.map(t=>FB(t));let w,b=A.maximumLoops,B=1/0;for(const[t,e]of Object.entries(d))v[t]<=B&&(B=v[t],w=e);for(;Object.keys(d).length>0&&b>0;){const t=m.minId(!1);if(!t)break;w=d[t];const e=FB(w);if(y.includes(e))return TB(w,g,c,o,u,l,s);delete d[e],m.remove(e),f[e]=!0;for(const t of Object.values(A.directionMap)){const n=ay(w,[t.stepX,t.stepY]),r=FB(n);if(f[r])continue;const i=QB(w,n,g,c);if(i>A.maxAllowedDirectionChange)continue;if(a[r])continue;d[r]||(d[r]=n);const o=A.penalties[i],l=A.distFunc(w,n)+(isNaN(o)?s:o),u=p[e]+l,y=p[r];y&&u>=y||(g[r]=w,p[r]=u,v[r]=u+UB(n,h,A.distFunc),m.add({id:r,value:v[r]}))}b-=1}return[]}class IB{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){let n=0,r=e-1;for(;r-n>1;){const e=Math.floor((n+r)/2);if(this.arr[e].value>t.value)r=e;else{if(!(this.arr[e].value<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n=e}}this.arr.splice(r,0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;if(!e||this.arr[e-1].value<t.value)return this.arr.push(t),void(this.map[t.id]=!0);this._innerAdd(t,e)}remove(t){this.map[t]&&delete this.map[t]}_clearAndGetMinId(){let t;for(let e=this.arr.length-1;e>=0;e--)this.map[this.arr[e].id]?t=this.arr[e].id:this.arr.splice(e,1);return t}_findFirstId(){for(;this.arr.length;){const t=this.arr.shift();if(this.map[t.id])return t.id}}minId(t){return t?this._clearAndGetMinId():this._findFirstId()}}class LB extends wB{constructor(t){super(uw({style:LB.defaultStyleProps},t))}getControlPoints(t){const{router:e}=t,{sourceNode:n,targetNode:r}=this,[i,o]=this.getEndpoints(t,!1);let A=[];if(e)if("shortest-path"===e.type){A=OB(n,r,this.context.element.getNodes(),e),A.length||(A=$b(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(A=$b(i,o,n,r,t.controlPoints,e));else A=t.controlPoints;return A}getPoints(t){const e=this.getControlPoints(t),[n,r]=this.getEndpoints(t,!0,e);return[n,...e,r]}getKeyPath(t){return hB(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=bm(i),A=Math.max(mm(o),ym(o))/4,{placement:s,clockwise:a,dist:c=A}=Aw(this.getGraphicStyle(t),"loop");return gB(i,r,s,a,c,e,n)}}LB.defaultStyleProps={radius:0,controlPoints:[],router:!1};class PB extends wB{constructor(t){super(uw({style:PB.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||lB(r,i,e,n))}}function DB(t){return t instanceof Nw&&"node"===t.type}function RB(t){return t instanceof wB}function HB(t){return t instanceof Wb}PB.defaultStyleProps={curvePosition:.5,curveOffset:30};const _B={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],"left-top":[0,0],"top-left":[0,0],"left-bottom":[0,1],"bottom-left":[0,1],"right-top":[1,0],"top-right":[1,0],"right-bottom":[1,1],"bottom-right":[1,1],default:[.5,.5]};function GB(t,e,n=_B,r=!0){const i=[.5,.5],o=Jt(e)?Ce(n,e.toLocaleLowerCase(),i):e;if(!r&&Jt(e))return o;const[A,s]=o||i;return[t.min[0]+mm(t)*A,t.min[1]+ym(t)*s]}function KB(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach((n,r)=>{var i;const{key:o,placement:A}=n;jB(n)&&(e[i=o||r]||(e[i]=ky(t.getShape("key").getBounds(),A)))}),e}function jB(t){const{r:e}=t;return!e||0===Number(e)}function zB(t){return fm(t)?t:t.getPosition()}function VB(t,e,n,r){const i=KB(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const A=o.map(t=>zB(t)),s=function(t,e){const n=KB(t);if(e)return[zB(n[e])];const r=Object.values(n);return r.length>0?r.map(t=>zB(t)):[t.getCenter()]}(e,r),[a]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach(t=>{e.forEach(e=>{const i=dy(t,e);i<n&&(n=i,r=[t,e])})}),r}(A,s);return o.find(t=>zB(t)===a)}function WB(t,e){return HB(t)||DB(t)?XB(t,e):YB(t,e)}function YB(t,e){if(!t||!e)return[0,0,0];if(fm(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return Dy(fm(e)?e:DB(e)?e.getCenter():e.getPosition(),t.getBounds())}function XB(t,e){if(!t||!e)return[0,0,0];const n=fm(e)?e:DB(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function qB(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[A,s]=ky(t,e),[a,c]=i?["bottom","top"]:["top","bottom"];return{transform:[["translate",A+n,s+r]],textBaseline:o.includes("top")?c:o.includes("bottom")?a:"middle",textAlign:o.includes("left")?"right":o.includes("right")?"left":"center"}}function $B(t){return"hidden"!==Ce(t,["style","visibility"])}function ZB(t,e){"update"in t?t.update(e):t.attr(e)}function JB(t){return Ce(t,"__to_be_destroyed__",!1)}class tE extends iy{constructor(t,e){super(t,Object.assign({},tE.defaultOptions,e)),this.onCollapseExpand=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{target:e}=t;if(!(DB(n=e)||RB(n)||HB(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,A=i.getElementDataById(r);if(!A)return!1;const{onCollapse:s,onExpand:a,animation:c,align:l}=this.options;rw(A)?(yield o.expandElement(r,{animation:c,align:l}),null==a||a(r)):(yield o.collapseElement(r,{animation:c,align:l}),null==s||s(r))}),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`node:${e}`,this.onCollapseExpand),t.on(`combo:${e}`,this.onCollapseExpand)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`node:${e}`,this.onCollapseExpand),t.off(`combo:${e}`,this.onCollapseExpand)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}function eE(t,e){const{data:n,style:r}=t,i=Pe(t,["data","style"]),{data:o,style:A}=e,s=Pe(e,["data","style"]),a=Object.assign(Object.assign({},i),s);return(n||o)&&Object.assign(a,{data:Object.assign(Object.assign({},n),o)}),(r||A)&&Object.assign(a,{style:Object.assign(Object.assign({},r),A)}),a}function nE(t){const{data:e,style:n}=t,r=Pe(t,["data","style"]);return e&&(r.data=Object.assign({},e)),n&&(r.style=Object.assign({},n)),r}function rE(t={},e={}){const{states:n=[],data:r={},style:i={},children:o=[]}=t,A=Pe(t,["states","data","style","children"]),{states:s=[],data:a={},style:c={},children:l=[]}=e,u=(t,e)=>t.length===e.length&&t.every((t,n)=>t===e[n]),h=(t,e)=>{const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(n=>t[n]===e[n])};return!!h(A,Pe(e,["states","data","style","children"]))&&(!!u(o,l)&&(!!u(n,s)&&(!!h(r,a)&&!!h(i,c))))}tE.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const iE="__internal_override__";function oE(t){return!1!==t[iE]}const AE="g6-create-edge-assist-node-id";class sE extends iy{constructor(t,e){super(t,Object.assign({},sE.defaultOptions,e)),this.drop=t=>De(this,void 0,void 0,function*(){const{targetType:e}=t;["combo","node"].includes(e)&&this.source?yield this.handleCreateEdge(t):yield this.cancelEdge()}),this.handleCreateEdge=t=>De(this,void 0,void 0,function*(){var e,n,r;if(!this.validate(t))return;const{graph:i,canvas:o,batch:A,element:s}=this.context,{style:a}=this.options;if(this.source)return this.createEdge(t),void(yield this.cancelEdge());A.startBatch(),o.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0];const c=i.getElementData(this.source);i.addNodeData([{id:AE,type:"circle",[iE]:!1,style:{size:1,visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=c.style)||void 0===e?void 0:e.x,y:null===(n=c.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:AE,style:Object.assign({pointerEvents:"none"},a)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished}),this.updateAssistEdge=t=>De(this,void 0,void 0,function*(){var e;if(!this.source)return;const{model:n,element:r,graph:i}=this.context,[o,A]=i.getCanvasByClient([t.client.x,t.client.y]);n.translateNodeTo(AE,[o,A]),yield null===(e=r.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished}),this.createEdge=t=>{var e,n;const{graph:r}=this.context,{style:i,onFinish:o,onCreate:A}=this.options;if(void 0===(null===(e=t.target)||void 0===e?void 0:e.id)||void 0===this.source)return;const s=null===(n=this.getSelectedNodeIDs([t.target.id]))||void 0===n?void 0:n[0];var a;const c=A({id:`${this.source}-${s}-${Ue[a=a||"g"]?Ue[a]+=1:Ue[a]=1,a+Ue[a]}`,source:this.source,target:s,style:i});c&&(r.addEdgeData([c]),o(c))},this.cancelEdge=()=>De(this,void 0,void 0,function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([AE]),this.source=void 0,yield null===(t=n.draw({animation:!1}))||void 0===t?void 0:t.finished,r.endBatch()}),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(t.NodeEvent.CLICK,this.handleCreateEdge),e.on(t.ComboEvent.CLICK,this.handleCreateEdge),e.on(t.CanvasEvent.CLICK,this.cancelEdge),e.on(t.EdgeEvent.CLICK,this.cancelEdge)):(e.on(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.on(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map(t=>t.id).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.CLICK,this.handleCreateEdge),e.off(t.ComboEvent.CLICK,this.handleCreateEdge),e.off(t.CanvasEvent.CLICK,this.cancelEdge),e.off(t.EdgeEvent.CLICK,this.cancelEdge),e.off(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.off(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}sE.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class aE extends iy{constructor(t,e){super(t,Object.assign({},aE.defaultOptions,e)),this.isDragging=!1,this.onDragStart=t=>{this.validate(t)&&(this.isDragging=!0,this.context.canvas.setCursor("grabbing"))},this.onDrag=t=>{var e,n,r,i;if(!this.isDragging||Ky.isPinching)return;const o=null!==(n=null===(e=t.movement)||void 0===e?void 0:e.x)&&void 0!==n?n:t.dx,A=null!==(i=null===(r=t.movement)||void 0===r?void 0:r.y)&&void 0!==i?i:t.dy;0!==(o|A)&&this.translate([o,A],!1)},this.onDragEnd=()=>{var t,e;this.isDragging=!1,this.context.canvas.setCursor(this.defaultCursor),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)},this.invokeOnFinish=pe(()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)},300),this.shortcut=new Wy(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(zt(e)){const{up:t=[],down:n=[],left:r=[],right:i=[]}=e;this.shortcut.bind(t,t=>this.onTranslate([0,1],t)),this.shortcut.bind(n,t=>this.onTranslate([0,-1],t)),this.shortcut.bind(r,t=>this.onTranslate([1,0],t)),this.shortcut.bind(i,t=>this.onTranslate([-1,0],t))}else{const{graph:e}=this.context;e.on(t.CommonEvent.DRAG_START,this.onDragStart),e.on(t.CommonEvent.DRAG,this.onDrag),e.on(t.CommonEvent.DRAG_END,this.onDragEnd)}}onTranslate(t,e){return De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(ly(t,r),this.options.animation),this.invokeOnFinish()})}translate(t,e){return De(this,void 0,void 0,function*(){t=this.clampByDirection(t),t=this.clampByRange(t),t=this.clampByRotation(t),yield this.context.graph.translateBy(t,e)})}clampByRotation([t,e]){return By([t,e],this.context.graph.getRotation())}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[A,s,a,c]=pm(this.options.range),l=[o*A,i*s,o*a,i*c],u=Em(Bm(n.getCanvasCenter()),l),h=cy(n.getViewportCenter(),[t,e,0]);if(!Cm(h,u)){const{min:[n,r],max:[i,o]}=u;(h[0]<n&&t>0||h[0]>i&&t<0)&&(t=0),(h[1]<r&&e>0||h[1]>o&&e<0)&&(e=0)}return[t,e]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return"function"==typeof e?e(t):!!e}unbindEvents(){this.shortcut.unbindAll();const{graph:e}=this.context;e.off(t.CommonEvent.DRAG_START,this.onDragStart),e.off(t.CommonEvent.DRAG,this.onDrag),e.off(t.CommonEvent.DRAG_END,this.onDragEnd)}destroy(){this.shortcut.destroy(),this.unbindEvents(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}aE.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class cE extends iy{constructor(e,n){super(e,Object.assign({},cE.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>De(this,void 0,void 0,function*(){var e;if("link"!==this.options.dropEffect)return;const{model:n,element:r}=this.context,i=t.target.id;this.target.forEach(t=>{const e=n.getParentData(t,zv);e&&Km(e)===i&&n.refreshComboData(i),n.setParent(t,i,zv)}),yield null===(e=null==r?void 0:r.draw({animation:!0}))||void 0===e?void 0:e.finished}),this.setCursor=e=>{if(this.isDragging)return;const{type:n}=e,{canvas:r}=this.context,{cursor:i}=this.options;n===t.CommonEvent.POINTER_ENTER?r.setCursor((null==i?void 0:i.grab)||"grab"):r.setCursor((null==i?void 0:i.default)||"default")},this.shortcut=new Wy(e.graph),this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.addEventListener("blur",this.onDragEnd),r.addEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach(n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)}),["link"].includes(this.options.dropEffect)&&(e.on(t.ComboEvent.DROP,this.onDrop),e.on(t.CanvasEvent.DROP,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map(t=>t.id).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return uy([t.dx,t.dy],e)}onDragStart(t){var e;if(this.enable=this.validate(t),!this.enable)return;const{batch:n,canvas:r,graph:i}=this.context;r.setCursor((null===(e=this.options.cursor)||void 0===e?void 0:e.grabbing)||"grabbing"),this.isDragging=!0,n.startBatch();const o=t.target.id;i.getElementState(o).includes(this.options.state)?this.target=this.getSelectedNodeIDs([o]):this.target=[o],this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target)}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){var t,e,n;if(!this.enable)return;if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=cy([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t,this.target);const{batch:r,canvas:i}=this.context;r.endBatch(),i.setCursor((null===(n=this.options.cursor)||void 0===n?void 0:n.grab)||"grab"),this.isDragging=!1,this.target=[]}isKeydown(){const{trigger:t}=this.options;return!(null==t?void 0:t.length)||this.shortcut.match(t)}validate(t){if(this.destroyed||JB(t.target)||this.context.graph.isCollapsingExpanding||!this.isKeydown())return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}clampByRotation([t,e]){return By([t,e],this.context.graph.getRotation())}moveElement(t,e){return De(this,void 0,void 0,function*(){const{graph:n,model:r}=this.context,{dropEffect:i}=this.options;"move"===i&&t.forEach(t=>r.refreshComboData(t)),n.translateElementBy(Object.fromEntries(t.map(t=>[t,this.clampByRotation(e)])),!1)})}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=Aw(this.options,"shadow"),n=xm(t.map(t=>this.context.element.getElement(t).getBounds())),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,A]=wm(n),s={width:o,height:A,x:r,y:i};this.shadow?this.shadow.attr(Object.assign(Object.assign(Object.assign({},e),s),{visibility:"visible"})):(this.shadow=new sc({style:Object.assign(Object.assign(Object.assign({$layer:"transient"},e),s),{pointerEvents:"none"})}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdge(){const{hideEdge:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(Km):Array.from(new Set(this.target.map(e=>n.getRelatedEdgesData(e,t).map(Km)).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.removeEventListener("blur",this.onDragEnd),r.removeEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach(n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)}),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){var t;this.unbindEvents(),null===(t=this.shadow)||void 0===t||t.destroy(),super.destroy()}}cE.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),trigger:[],dropEffect:"move",state:"selected",hideEdge:"none",shadow:!1,shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5],cursor:{default:"default",grab:"grab",grabbing:"grabbing"}};var lE=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],A=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var A=r[o],s=A.callback;A.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};A(i),A(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function uE(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach(n=>{e.has(n.id)||(e.add(n.id),t.push(n))})}return!1}function hE(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&hE(i,e,n,r))return!0;return!1}const dE=()=>!0;class fE{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||dE,n=t.edgeFilter||dE;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(t=>t.id))};updateCache=t=>{const e=new Set;t.forEach(t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach(t=>e.add(t.id)),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach(t=>e.add(t.id)),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)}),e.forEach(t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)})};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach(n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}}),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some(e=>e.id===t)}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map(t=>this.getNode(t.target));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map(t=>this.getNode(t.source));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];uE([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];hE(this.getNode(t),new Set,e,r)}}let gE=class t extends lE{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach(t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter(e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id}),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter(e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id}),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex(e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName)),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter(e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey),e.push(t);break;case"TreeStructureChanged":{const n=e.find(e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId);n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}}),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some(e=>e.id===t)}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map(t=>this.getNode(t.target));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map(t=>this.getNode(t.source));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach(e=>{e.childrenMap.set(t.id,new Set)}),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch(()=>{for(const e of t)this.doAddNode(e)})}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach(t=>this.doRemoveEdge(t.id)),this.nodeMap.delete(t),this.treeIndices.forEach(n=>{n.childrenMap.get(t)?.forEach(t=>{n.parentMap.delete(t.id)});const r=n.parentMap.get(t);r&&n.childrenMap.get(r.id)?.delete(e),n.parentMap.delete(t),n.childrenMap.delete(t)}),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch(()=>{t.forEach(t=>this.doRemoveNode(t))})}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch(()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})})}mergeNodeData(t,e){this.batch(()=>{Object.entries(e).forEach(([e,n])=>{this.updateNodeDataProperty(t,e,n)})})}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch(()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})})}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch(()=>{for(const e of t)this.doAddEdge(e)})}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch(()=>{t.forEach(t=>this.doRemoveEdge(t))})}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})})}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})})}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch(()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})})}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch(()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})})}mergeEdgeData(t,e){this.batch(()=>{Object.entries(e).forEach(([e,n])=>{this.updateEdgeDataProperty(t,e,n)})})}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})}))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})})}addTree(t,e){this.batch(()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach(t=>{t.children?.forEach(n=>{this.setParent(n.id,t.id,e)})})})}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter(e=>!this.getParent(e.id,t))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n);if(!r)return;const i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(null==e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const A=this.getNode(e);r.parentMap.set(t,A),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(A.id);s||(s=new Set,r.childrenMap.set(A.id,s)),s.add(i),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:A.id})})}dfsTree(t,e,n){return hE(this.getNode(t),new Set,e,t=>this.getChildren(t,n))}bfsTree(t,e,n){return uE([this.getNode(t)],new Set,e,t=>this.getChildren(t,n))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return uE([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return hE(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map(t=>({...t,data:{...t.data}})),n=this.getAllEdges().map(t=>({...t,data:{...t.data}})),r=new t({nodes:e,edges:n});return this.treeIndices.forEach(({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach((t,e)=>{i.set(e,r.getNode(t.id))});const o=new Map;e.forEach((t,e)=>{o.set(e,new Set(Array.from(t).map(t=>r.getNode(t.id))))}),r.treeIndices.set(n,{parentMap:i,childrenMap:o})}),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new fE({graph:this,...t})}},pE=class{constructor(t,e){this.context=t,this.options=e||{}}};function vE(t,e){return class extends pE{constructor(e,n){if(super(e,n),this.instance=new t({}),this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>(t.tick(e),this.getLayoutResult(t))}}execute(t,e){return De(this,void 0,void 0,function*(){return yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(be({},this.options,e))),this.getLayoutResult(this.instance)})}graphData2LayoutModel(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e,...r],edges:n}}transformOptions(t){if(t.node=t=>{var n;const{style:r}=t||{},i="combo"in(t||{})&&null!==(n=t.combo)&&void 0!==n?n:null,o=Km(t);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({id:o},re(null==r?void 0:r.x)?{x:r.x}:{}),re(null==r?void 0:r.y)?{y:r.y}:{}),re(null==r?void 0:r.z)?{z:r.z}:{}),{parentId:i}),(t=>e.model.isCombo(t))(o)?{isCombo:!0}:{})},t.edge=t=>({id:Km(t),source:t.source,target:t.target}),!("onTick"in t))return t;const n=t.onTick;return t.onTick=t=>n(this.getLayoutResult(t)),t}getLayoutResult(t){const{model:e}=this.context,n={nodes:[],edges:[],combos:[]};return t.forEachNode(t=>{var r;const i=String(t.id),o=e.isCombo(i)?n.combos:n.nodes,A=Object.assign({x:t.x,y:t.y,z:null!==(r=t.z)&&void 0!==r?r:0},t.size?{size:t.size}:{});null==o||o.push({id:i,style:A})}),t.forEachEdge(t=>{const e={controlPoints:t.points||[]};n.edges.push({id:String(t.id),source:String(t.source),target:String(t.target),style:e})}),n}}}function mE(t){const{nodes:e,edges:n=[]}=t,r={nodes:[],edges:[],combos:[]};return e.forEach(t=>{const e=t.data._isCombo?r.combos:r.nodes,{x:n,y:i,z:o=0}=t.data;null==e||e.push({id:t.id,style:{x:n,y:i,z:o}})}),n.forEach(t=>{const{id:e,source:n,target:i,data:{points:o=[],controlPoints:A=o.slice(1,o.length-1)}}=t;r.edges.push({id:e,source:n,target:i,style:Object.assign({},(null==A?void 0:A.length)?{controlPoints:A.map(Sy)}:{})})}),r}function yE(t,e,...n){if(e in t)return t[e](...n);if("instance"in t){const r=t.instance;if(e in r)return r[e](...n)}return null}function wE(t,e){if(e in t)return t[e];if("instance"in t){const n=t.instance;if(e in n)return n[e]}return null}class bE extends cE{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find(t=>["d3-force","d3-force-3d"].includes(null==t?void 0:t.id))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(Zv("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return De(this,void 0,void 0,function*(){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach((r,i)=>{const{x:o=0,y:A=0}=r.style||{};n&&yE(n,"setFixedPosition",t[i],[...ay([+o,+A],this.clampByRotation(e))])})})}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e&&wE(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach(t=>{const{x:n=0,y:r=0}=t.style||{};e&&yE(e,"setFixedPosition",Km(t),[+n,+r])})}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t&&wE(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach(e=>{t&&yE(t,"setFixedPosition",Km(e),[null,null,null])})}}class BE extends iy{constructor(t,e){super(t,Object.assign({},BE.defaultOptions,e)),this.isZoomEvent=t=>Boolean(t.data&&"scale"in t.data),this.relatedEdgeToUpdate=new Set,this.zoom=this.context.graph.getZoom(),this.fixElementSize=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{graph:e}=this.context,{state:n,nodeFilter:r,edgeFilter:i,comboFilter:o}=this.options,A=(n?e.getElementDataByState("node",n):e.getNodeData()).filter(r),s=(n?e.getElementDataByState("edge",n):e.getEdgeData()).filter(i),a=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),c=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,l=[...A,...a];l.length>0&&l.forEach(t=>this.fixNodeLike(t,c)),this.updateRelatedEdges(),s.length>0&&s.forEach(t=>this.fixEdge(t,c))}),this.cachedStyles=new Map,this.getOriginalFieldValue=(t,e,n)=>{var r;const i=this.cachedStyles.get(t)||[],o=(null===(r=i.find(t=>t.shape===e))||void 0===r?void 0:r.style)||{};return n in o||(o[n]=e.attributes[n],this.cachedStyles.set(t,[...i.filter(t=>t.shape!==e),{shape:e,style:o}])),o[n]},this.scaleEntireElement=(t,e,n)=>{e.setLocalScale(1/n);const r=this.cachedStyles.get(t)||[];r.push({shape:e}),this.cachedStyles.set(t,r)},this.scaleSpecificShapes=(t,e,n)=>{const r=function(t){const e=[],n=t=>{(null==t?void 0:t.children.length)&&t.children.forEach(t=>{e.push(t),n(t)})};return n(t),e}(t);(Array.isArray(n)?n:[n]).forEach(n=>{const{shape:i,fields:o}=n,A="function"==typeof i?i(r):t.getShape(i);A&&(o?o.forEach(n=>{const r=this.getOriginalFieldValue(t.id,A,n);re(r)&&(A.style[n]=r/e)}):this.scaleEntireElement(t.id,A,e))})},this.skipIfExceedViewport=t=>{const{viewport:e}=this.context;return!(null==e?void 0:e.isInViewport(t.getRenderBounds(),!1,30))},this.fixNodeLike=(t,e)=>{const n=Km(t),{element:r,model:i}=this.context,o=r.getElement(n);if(!o||this.skipIfExceedViewport(o))return;i.getRelatedEdgesData(n).forEach(t=>this.relatedEdgeToUpdate.add(Km(t)));const A=this.options[o.type];A?this.scaleSpecificShapes(o,e,A):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=Km(t),r=this.context.element.getElement(n);if(!r||this.skipIfExceedViewport(r))return;const i=this.options.edge;if(!i)return r.style.transformOrigin="center",void this.scaleEntireElement(n,r,e);this.scaleSpecificShapes(r,e,i)},this.updateRelatedEdges=()=>{const{element:t}=this.context;this.relatedEdgeToUpdate.size>0&&this.relatedEdgeToUpdate.forEach(e=>{const n=t.getElement(e);null==n||n.update({})}),this.relatedEdgeToUpdate.clear()},this.resetTransform=t=>De(this,void 0,void 0,function*(){var e;(null===(e=t.data)||void 0===e?void 0:e.firstRender)||(this.options.reset?this.restoreCachedStyles():this.fixElementSize({data:{scale:this.zoom}}))}),this.bindEvents()}restoreCachedStyles(){if(this.cachedStyles.size>0){this.cachedStyles.forEach(t=>{t.forEach(({shape:t,style:e})=>{if(Ee(e))t.setLocalScale(1);else{if(this.options.state)return;Object.entries(e).forEach(([e,n])=>t.style[e]=n)}})});const{graph:t,element:e}=this.context,n=Object.keys(Object.fromEntries(this.cachedStyles)).filter(e=>e&&"node"===t.getElementType(e));if(n.length>0){const r=new Set;n.forEach(e=>{t.getRelatedEdgesData(e).forEach(t=>r.add(Km(t)))}),r.forEach(t=>{const n=null==e?void 0:e.getElement(t);null==n||n.update({})})}}}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.on(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.off(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}BE.defaultOptions={enable:t=>t.data.scale<1,nodeFilter:()=>!0,edgeFilter:()=>!0,comboFilter:()=>!0,edge:[{shape:"key",fields:["lineWidth"]},{shape:"halo",fields:["lineWidth"]},{shape:"label"}],reset:!1};class EE extends iy{constructor(t,e){super(t,Object.assign({},EE.defaultOptions,e)),this.focus=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{graph:e}=this.context;yield e.focusElement(t.target.id,this.options.animation)}),this.shortcut=new Wy(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)})}validate(t){if(this.destroyed||!this.isKeydown())return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}isKeydown(){const{trigger:t}=this.options;return!(null==t?void 0:t.length)||this.shortcut.match(t)}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)})}destroy(){this.unbindEvents(),this.shortcut.destroy(),super.destroy()}}EE.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0,trigger:[]};class xE extends iy{constructor(e,n){super(e,Object.assign({},xE.defaultOptions,n)),this.isFrozen=!1,this.toggleFrozen=t=>{this.isFrozen="dragstart"===t.type},this.hoverElement=e=>{if(!this.validate(e))return;const n=e.type===t.CommonEvent.POINTER_ENTER;this.updateElementsState(e,n);const{onHover:r,onHoverEnd:i}=this.options;n?null==r||r(e):null==i||i(e)},this.updateElementsState=(t,e)=>{if(!this.options.state&&!this.options.inactiveState)return;const{graph:n}=this.context,{state:r,animation:i,inactiveState:o}=this.options,A=this.getActiveIds(t),s={};if(r&&Object.assign(s,this.getElementsState(A,r,e)),o){const t=zm(n.getData(),!0).filter(t=>!A.includes(t));Object.assign(s,this.getElementsState(t,o,e))}n.setElementState(s,i)},this.getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach(t=>{const o=r.getElementState(t);i[t]=n?o.includes(e)?o:[...o,e]:o.filter(t=>t!==e)}),i},this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)});const n=this.context.canvas.document;n.addEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.addEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}getActiveIds(t){const{graph:e}=this.context,{degree:n,direction:r}=this.options,i=t.target.id;return n?Jy(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||JB(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)});const n=this.context.canvas.document;n.removeEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.removeEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}destroy(){this.unbindEvents(),super.destroy()}}xE.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class CE extends Yy{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e,graph:n}=this.context;this.pathShape=new nc({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[Xy(t,n)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(Xy(t,this.context.graph)),null===(e=this.pathShape)||void 0===e||e.setAttribute("d",function(t,e=!0){const n=[];return t.forEach((t,e)=>{n.push([0===e?"M":"L",...t])}),e&&n.push(["Z"]),n}(this.points)),n&&"default"===r&&this.points.length>2&&super.updateElementsStates(this.points)}onPointerUp(){this.points&&(this.points.length<2||super.updateElementsStates(this.points),this.clearLasso())}clearLasso(){var t;null===(t=this.pathShape)||void 0===t||t.remove(),this.pathShape=void 0,this.points=void 0}}class ME extends iy{constructor(t,e){super(t,Object.assign({},ME.defaultOptions,e)),this.hiddenShapes=[],this.isVisible=!0,this.setElementsVisibility=(t,e,n)=>{t.filter(Boolean).forEach(t=>{"hidden"!==e||t.isVisible()?"visible"===e&&this.hiddenShapes.includes(t)?this.hiddenShapes.splice(this.hiddenShapes.indexOf(t),1):ey(t,e,n):this.hiddenShapes.push(t)})},this.filterShapes=(t,e)=>{if(Gt(e))return n=>!e(t,n);const n=null==e?void 0:e[t];return t=>!t.className||!(null==n?void 0:n.includes(t.className))},this.hideShapes=t=>{if(!this.validate(t)||!this.isVisible)return;const{element:e}=this.context,{shapes:n={}}=this.options;this.setElementsVisibility(e.getNodes(),"hidden",this.filterShapes("node",n)),this.setElementsVisibility(e.getEdges(),"hidden",this.filterShapes("edge",n)),this.setElementsVisibility(e.getCombos(),"hidden",this.filterShapes("combo",n)),this.isVisible=!1},this.showShapes=pe(t=>{if(!this.validate(t)||this.isVisible)return;const{element:e}=this.context;this.setElementsVisibility(e.getNodes(),"visible"),this.setElementsVisibility(e.getEdges(),"visible"),this.setElementsVisibility(e.getCombos(),"visible"),this.isVisible=!0},this.options.debounce),this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.on(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.off(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}ME.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class FE extends iy{constructor(t,e){super(t,Object.assign({},FE.defaultOptions,e)),this.onWheel=t=>De(this,void 0,void 0,function*(){this.options.preventDefault&&t.preventDefault();const e=t.deltaX,n=t.deltaY;yield this.scroll([-e,-n],t)}),this.shortcut=new Wy(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),zt(r)){null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel);const{up:n=[],down:i=[],left:o=[],right:A=[]}=r;this.shortcut.bind(n,t=>this.scroll([0,-10],t)),this.shortcut.bind(i,t=>this.scroll([0,10],t)),this.shortcut.bind(o,t=>this.scroll([-10,0],t)),this.shortcut.bind(A,t=>this.scroll([10,0],t))}else null===(n=this.graphDom)||void 0===n||n.addEventListener(t.CommonEvent.WHEEL,this.onWheel,{passive:!1})}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}formatDisplacement(t){const{sensitivity:e}=this.options;return t=ly(t,e),t=this.clampByDirection(t),t=this.clampByRange(t)}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[A,s,a,c]=pm(this.options.range),l=[o*A,i*s,o*a,i*c],u=Em(Bm(n.getCanvasCenter()),l),h=cy(n.getViewportCenter(),[t,e,0]);if(!Cm(h,u)){const{min:[n,r],max:[i,o]}=u;(h[0]<n&&t>0||h[0]>i&&t<0)&&(t=0),(h[1]<r&&e>0||h[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{onFinish:n}=this.options,r=this.context.graph,i=this.formatDisplacement(t);yield r.translateBy(i,!1),null==n||n()})}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel),super.destroy()}}FE.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class kE extends iy{constructor(t,e){super(t,Object.assign({},kE.defaultOptions,e)),this.zoom=(t,e,n)=>De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{graph:r}=this.context;let i=this.options.origin;!i&&"viewport"in e&&(i=Sy(e.viewport));const{sensitivity:o,onFinish:A}=this.options,s=1+ne(t,-50,50)*o/100,a=r.getZoom();yield r.zoomTo(a*s,n,i),null==A||A()}),this.onReset=()=>De(this,void 0,void 0,function*(){yield this.context.graph.zoomTo(1,this.options.animation)}),this.preventDefault=t=>{this.options.preventDefault&&t.preventDefault()},this.shortcut=new Wy(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),Array.isArray(e))if(e.includes(t.CommonEvent.PINCH))this.shortcut.bind([t.CommonEvent.PINCH],t=>{this.zoom(t.scale,t,!1)});else{const n=this.context.canvas.getContainer();null==n||n.addEventListener(t.CommonEvent.WHEEL,this.preventDefault),this.shortcut.bind([...e,t.CommonEvent.WHEEL],t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(null!=n?n:e),t,!1)})}if("object"==typeof e){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,t=>this.zoom(10,t,this.options.animation)),this.shortcut.bind(n,t=>this.zoom(-10,t,this.options.animation)),this.shortcut.bind(r,this.onReset)}}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.context.canvas.getContainer())||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.preventDefault),super.destroy()}}function SE(t,e,n,r="height"){const i=t[r],o=e[r];return"center"===n?(i+o)/2:t.height}kE.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};const QE=Object.assign,UE={getId:t=>t.id||t.name,getPreH:t=>t.preH||0,getPreV:t=>t.preV||0,getHGap:t=>t.hgap||18,getVGap:t=>t.vgap||18,getChildren:t=>t.children,getHeight:t=>t.height||36,getWidth(t){const e=t.label||" ";return t.width||18*e.split("").length}};let NE=class t{constructor(e,n){if(this.x=0,this.y=0,this.depth=0,this.children=[],this.hgap=0,this.vgap=0,e instanceof t||"x"in e&&"y"in e&&"children"in e){const t=e;return this.data=t.data,this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.depth=t.depth,this.children=t.children,this.parent=t.parent,this.hgap=t.hgap,this.vgap=t.vgap,this.preH=t.preH,void(this.preV=t.preV)}this.data=e;const r=n.getHGap(e),i=n.getVGap(e);this.preH=n.getPreH(e),this.preV=n.getPreV(e),this.width=n.getWidth(e),this.height=n.getHeight(e),this.width+=this.preH,this.height+=this.preV,this.id=n.getId(e),this.addGap(r,i)}isRoot(){return 0===this.depth}isLeaf(){return 0===this.children.length}addGap(t,e){this.hgap+=t,this.vgap+=e,this.width+=2*t,this.height+=2*e}eachNode(t){let e,n=[this];for(;e=n.shift();)t(e),n=e.children.concat(n)}DFTraverse(t){this.eachNode(t)}BFTraverse(t){let e,n=[this];for(;e=n.shift();)t(e),n=n.concat(e.children)}getBoundingBox(){const t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode(e=>{t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)}),t}translate(t=0,e=0){this.eachNode(n=>{n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV})}right2left(){const t=this.getBoundingBox();this.eachNode(e=>{e.x=e.x-2*(e.x-t.left)-e.width}),this.translate(t.width,0)}bottom2top(){const t=this.getBoundingBox();this.eachNode(e=>{e.y=e.y-2*(e.y-t.top)-e.height}),this.translate(0,t.height)}};function TE(t,e={},n){e=QE({},UE,e);const r=new NE(t,e),i=[r];let o;if(!n&&!t.collapsed)for(;o=i.shift();)if(!o.data.collapsed){const t=e.getChildren(o.data),n=t?t.length:0;if(o.children=new Array(n),t&&n)for(let r=0;r<n;r++){const n=new NE(t[r],e);o.children[r]=n,i.push(n),n.parent=o,n.depth=o.depth+1}}return r}let OE=class{constructor(t,e={}){this.options=e,this.rootNode=TE(t,e)}execute(){throw new Error("please override this method")}},IE=class t{constructor(t=0,e=0,n=0,r=[]){this.x=0,this.prelim=0,this.mod=0,this.shift=0,this.change=0,this.tl=null,this.tr=null,this.el=null,this.er=null,this.msel=0,this.mser=0,this.w=t||0,this.h=e||0,this.y=n||0,this.c=r||[],this.cs=r.length}static fromNode(e,n){if(!e)return null;const r=[];return e.children.forEach(e=>{const i=t.fromNode(e,n);i&&r.push(i)}),n?new t(e.height,e.width,e.x,r):new t(e.width,e.height,e.y,r)}};function LE(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach(t=>{LE(t,e,n)})}function PE(t,e){let n=e?t.y:t.x;return t.children.forEach(t=>{n=Math.min(PE(t,e),n)}),n}function DE(t,e){LE(t,-PE(t,e),e)}function RE(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((t,r)=>{RE(t,e.children[r],n)})}function HE(t,e,n=0){e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach(t=>{HE(t,e,n)})}function _E(t,e={}){const n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){let r=t.c[e-1],i=r.mod,c=t.c[e],l=c.mod;for(;null!==r&&null!==c;){n&&a(r)>n.low&&(n=n.nxt);const u=i+r.prelim+r.w-(l+c.prelim);u>0&&(l+=u,n&&o(t,e,n.index,u));const h=a(r),d=a(c);h<=d&&(r=s(r),null!==r&&(i+=r.mod)),h>=d&&(c=A(c),null!==c&&(l+=c.mod))}!r&&c?function(t,e,n,r){const i=t.c[0].el;i.tl=n;const o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,c,l):r&&!c&&function(t,e,n,r){const i=t.c[e].er;i.tr=n;const o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){const i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function A(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function a(t){return t.y+t.h}function c(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}HE(t,n);const l=IE.fromNode(t,n);return l&&(function t(e){if(0===e.cs)return void r(e);t(e.c[0]);let n=c(a(e.c[0].el),0,null);for(let r=1;r<e.cs;++r){t(e.c[r]);const o=a(e.c[r].er);i(e,r,n),n=c(o,r,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}(l),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){let e=0,n=0;for(let r=0;r<t.cs;r++)e+=t.c[r].shift,n+=e+t.c[r].change,t.c[r].mod+=n}(e);for(let r=0;r<e.cs;r++)t(e.c[r],n)}(l,0),RE(l,t,n),DE(t,n)),t}function GE(t,e){const n=TE(t.data,e,!0),r=TE(t.data,e,!0),i=t.children.length,o=Math.round(i/2),A=e.getSide||function(t,e){return e<o?"right":"left"};for(let e=0;e<i;e++){const i=t.children[e];"right"===A(i,e)?r.children.push(i):n.children.push(i)}return n.eachNode(t=>{t.isRoot()||(t.side="left")}),r.eachNode(t=>{t.isRoot()||(t.side="right")}),{left:n,right:r}}const KE=["LR","RL","TB","BT","H","V"],jE=["LR","RL","H"],zE=KE[0];function VE(t,e,n){const r=e.direction||zE;if(e.isHorizontal=(t=>jE.indexOf(t)>-1)(r),-1===KE.indexOf(r))throw new TypeError(`Invalid direction: ${r}`);if(r===KE[0])n(t,e);else if(r===KE[1])n(t,e),t.right2left();else if(r===KE[2])n(t,e);else if(r===KE[3])n(t,e),t.bottom2top();else if(r===KE[4]||r===KE[5]){const{left:r,right:i}=GE(t,e);n(r,e),n(i,e),e.isHorizontal?r.right2left():r.bottom2top(),i.translate(r.x-i.x,r.y-i.y),t.x=r.x,t.y=i.y;const o=t.getBoundingBox();e.isHorizontal?o.top<0&&t.translate(0,-o.top):o.left<0&&t.translate(-o.left,0)}let i=e.fixedRoot;return void 0===i&&(i=!0),i&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){const[n,r]=e.isHorizontal?["x","y"]:["y","x"],i={x:1/0,y:1/0},o={x:-1/0,y:-1/0};let A=0;t.DFTraverse(t=>{A++;const{x:e,y:n}=t;i.x=Math.min(i.x,e),i.y=Math.min(i.y,n),o.x=Math.max(o.x,e),o.y=Math.max(o.y,n)});const s=o[r]-i[r];if(0===s)return;const a=2*Math.PI/A;t.DFTraverse(e=>{const o=e[r],A=i[r],c=e[n],l=t[n],u=(o-A)/s*(2*Math.PI-a)+a,h=c-l;e.x=Math.cos(u)*h,e.y=Math.sin(u)*h})}}(t,e),t}let WE=class extends OE{execute(){return VE(this.rootNode,this.options,_E)}};const YE={};function XE(t,e){const n=QE({},YE,e);return new WE(t,n).execute()}let qE=class{constructor(t=0,e=[]){this.x=0,this.y=0,this.leftChild=null,this.rightChild=null,this.isLeaf=!1,this.height=t,this.children=e}};const $E={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function ZE(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((t,r)=>{ZE(t,e.children[r],n)})}function JE(t,e={}){const n=QE({},$E,e);let r=0,i=null;const o=function t(e){e.width=0,e.depth&&e.depth>r&&(r=e.depth);const n=e.children,i=n.length,o=new qE(0,[]);return n.forEach((e,n)=>{const r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)}),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{const n=e.children.map(e=>t(e)),r=Math.min(...n);e.drawingDepth=r-1}return e.drawingDepth}(o),function t(e){e.x=e.drawingDepth*n.rankSep,e.isLeaf?(e.y=0,i&&(e.y=i.y+i.height+n.nodeSep,e.originNode.parent!==i.originNode.parent&&(e.y+=n.subTreeSep)),i=e):(e.children.forEach(e=>{t(e)}),e.y=(e.leftChild.y+e.rightChild.y)/2)}(o),ZE(o,t,n.isHorizontal),t}class tx extends OE{execute(){return this.rootNode.width=0,VE(this.rootNode,this.options,JE)}}const ex={};function nx(t,e){const n=QE({},ex,e);return new tx(t,n).execute()}function rx(t,e,n,r){let i=null;t.eachNode(t=>{!function(t,e,n,r,i){const o=("function"==typeof n?n(t):n)*t.depth;if(!r)try{if(t.parent&&t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch{}if(t.x+=o,e){if(t.y=e.y+SE(e,t,i),e.parent&&t.parent&&t.parent.id!==e.parent.id){const n=e.parent,r=n.y+SE(n,t,i);t.y=r>t.y?r:t.y}}else t.y=0}(t,i,e,n,r),i=t})}const ix=["LR","RL","H"],ox=ix[0];let Ax=class extends OE{execute(){const t=this.options,e=this.rootNode;t.isHorizontal=!0;const{indent:n=20,dropCap:r=!0,direction:i=ox,align:o}=t;if(i&&-1===ix.indexOf(i))throw new TypeError(`Invalid direction: ${i}`);if(i===ix[0])rx(e,n,r,o);else if(i===ix[1])rx(e,n,r,o),e.right2left();else if(i===ix[2]){const{left:i,right:A}=GE(e,t);rx(i,n,r,o),i.right2left(),rx(A,n,r,o);const s=i.getBoundingBox();A.translate(s.width,0),e.x=A.x-e.width/2}return e}};const sx={};function ax(t,e){const n=QE({},sx,e);return new Ax(t,n).execute()}function cx(t,e){let n=0;return t.children.length?t.children.forEach(t=>{n+=cx(t,e)}):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function lx(t){const e=t.children,n=e.length;if(n){e.forEach(t=>{lx(t)});const r=e[0],i=e[n-1],o=i.y-r.y+i.height;let A=0;if(e.forEach(t=>{A+=t.totalHeight}),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>A){const n=t.y+(t.height-o)/2-r.y;e.forEach(t=>{t.translate(0,n)})}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}const ux={getSubTreeSep:()=>0};function hx(t,e={}){return e=QE({},ux,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse(t=>{t.x=t.parent.x+t.parent.width}),t.parent=void 0,cx(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode(t=>{const e=t.children,n=e.length;if(n){const r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(let t=1;t<n;t++){const n=e[t];n.startY=e[t-1].startY+e[t-1].totalHeight,n.y=n.startY+n.totalHeight/2-n.height/2}}}}),lx(t),t}class dx extends OE{execute(){return VE(this.rootNode,this.options,hx)}}const fx={};function gx(t,e){const n=QE({},fx,e);return new dx(t,n).execute()}function px(t,e,n,r){return new(n||(n=Promise))(function(e,i){function o(t){try{s(r.next(t))}catch(t){i(t)}}function A(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(t){t(r)})).then(o,A)}s((r=r.apply(t,[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const vx={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,pow:Math.pow};class mx extends Error{constructor(t,e,n){super(t),this.position=e,this.token=n,this.name="ExpressionError"}}var yx;!function(t){t[t.STRING=0]="STRING",t[t.NUMBER=1]="NUMBER",t[t.BOOLEAN=2]="BOOLEAN",t[t.NULL=3]="NULL",t[t.IDENTIFIER=4]="IDENTIFIER",t[t.OPERATOR=5]="OPERATOR",t[t.FUNCTION=6]="FUNCTION",t[t.DOT=7]="DOT",t[t.BRACKET_LEFT=8]="BRACKET_LEFT",t[t.BRACKET_RIGHT=9]="BRACKET_RIGHT",t[t.PAREN_LEFT=10]="PAREN_LEFT",t[t.PAREN_RIGHT=11]="PAREN_RIGHT",t[t.COMMA=12]="COMMA",t[t.QUESTION=13]="QUESTION",t[t.COLON=14]="COLON",t[t.DOLLAR=15]="DOLLAR"}(yx||(yx={}));const wx=new Set([32,9,10,13]),bx=new Set([43,45,42,47,37,33,38,124,61,60,62]),Bx=new Map([["true",yx.BOOLEAN],["false",yx.BOOLEAN],["null",yx.NULL]]),Ex=new Map([["===",!0],["!==",!0],["<=",!0],[">=",!0],["&&",!0],["||",!0],["+",!0],["-",!0],["*",!0],["/",!0],["%",!0],["!",!0],["<",!0],[">",!0]]),xx=new Map([[46,yx.DOT],[91,yx.BRACKET_LEFT],[93,yx.BRACKET_RIGHT],[40,yx.PAREN_LEFT],[41,yx.PAREN_RIGHT],[44,yx.COMMA],[63,yx.QUESTION],[58,yx.COLON],[36,yx.DOLLAR]]),Cx=new Map;for(const[t,e]of xx.entries())Cx.set(t,{type:e,value:String.fromCharCode(t)});function Mx(t){return t>=48&&t<=57}function Fx(t){return t>=97&&t<=122||t>=65&&t<=90||95===t}function kx(t){return Fx(t)||Mx(t)}function Sx(t){return bx.has(t)}var Qx;!function(t){t[t.Program=0]="Program",t[t.Literal=1]="Literal",t[t.Identifier=2]="Identifier",t[t.MemberExpression=3]="MemberExpression",t[t.CallExpression=4]="CallExpression",t[t.BinaryExpression=5]="BinaryExpression",t[t.UnaryExpression=6]="UnaryExpression",t[t.ConditionalExpression=7]="ConditionalExpression"}(Qx||(Qx={}));const Ux=new Map([["||",2],["&&",3],["===",4],["!==",4],[">",5],[">=",5],["<",5],["<=",5],["+",6],["-",6],["*",7],["/",7],["%",7],["!",8]]),Nx={type:Qx.Literal,value:null},Tx={type:Qx.Literal,value:!0},Ox={type:Qx.Literal,value:!1},Ix=t=>{let e=0;const n=t.length,r=()=>e>=n?null:t[e],i=()=>t[e++],o=t=>{const e=r();return null!==e&&e.type===t},A=t=>t.type===yx.OPERATOR?Ux.get(t.value)||-1:t.type===yx.DOT||t.type===yx.BRACKET_LEFT?9:t.type===yx.QUESTION?1:-1,s=t=>{let n,A;if(i().type===yx.DOT){if(!o(yx.IDENTIFIER)){const t=r();throw new mx("Expected property name",e,t?t.value:"<end of input>")}const t=i();n={type:Qx.Identifier,name:t.value},A=!1}else{if(n=c(0),!o(yx.BRACKET_RIGHT)){const t=r();throw new mx("Expected closing bracket",e,t?t.value:"<end of input>")}i(),A=!0}return{type:Qx.MemberExpression,object:t,property:n,computed:A}},a=()=>{const t=r();if(!t)throw new mx("Unexpected end of input",e,"<end of input>");if(t.type===yx.OPERATOR&&("!"===t.value||"-"===t.value)){i();const e=a();return{type:Qx.UnaryExpression,operator:t.value,argument:e,prefix:!0}}switch(t.type){case yx.NUMBER:return i(),{type:Qx.Literal,value:Number(t.value)};case yx.STRING:return i(),{type:Qx.Literal,value:t.value};case yx.BOOLEAN:return i(),"true"===t.value?Tx:Ox;case yx.NULL:return i(),Nx;case yx.IDENTIFIER:return i(),{type:Qx.Identifier,name:t.value};case yx.FUNCTION:return(()=>{const t=i(),n=[];if(!o(yx.PAREN_LEFT)){const t=r();throw new mx("Expected opening parenthesis after function name",e,t?t.value:"<end of input>")}for(i();;){if(o(yx.PAREN_RIGHT)){i();break}if(!r()){const t=r();throw new mx("Expected closing parenthesis",e,t?t.value:"<end of input>")}if(n.length>0){if(!o(yx.COMMA)){const t=r();throw new mx("Expected comma between function arguments",e,t?t.value:"<end of input>")}i()}const t=c(0);n.push(t)}return{type:Qx.CallExpression,callee:{type:Qx.Identifier,name:t.value},arguments:n}})();case yx.PAREN_LEFT:{i();const t=c(0);if(!o(yx.PAREN_RIGHT)){const t=r();throw new mx("Expected closing parenthesis",e,t?t.value:"<end of input>")}return i(),t}default:throw new mx(`Unexpected token: ${t.type}`,e,t.value)}},c=(l=0)=>{let u=a();for(;e<n;){const n=t[e],a=A(n);if(a<=l)break;if(n.type!==yx.QUESTION)if(n.type!==yx.OPERATOR){if(n.type!==yx.DOT&&n.type!==yx.BRACKET_LEFT)break;u=s(u)}else{i();const t=c(a);u={type:Qx.BinaryExpression,operator:n.value,left:u,right:t}}else{i();const t=c(0);if(!o(yx.COLON)){const t=r();throw new mx("Expected : in conditional expression",e,t?t.value:"<end of input>")}i();const n=c(0);u={type:Qx.ConditionalExpression,test:u,consequent:t,alternate:n}}}return u},l=c();return{type:Qx.Program,body:l}},Lx=(t,e,n)=>{let r=e;n&&(r={...e,context:{...e.context,...n}});const i=t=>{switch(t.type){case Qx.Literal:return(t=>t.value)(t);case Qx.Identifier:return(t=>{if(!(t.name in r.context))throw new mx(`Undefined variable: ${t.name}`);return r.context[t.name]})(t);case Qx.MemberExpression:return(t=>{const e=i(t.object);if(null==e)throw new mx("Cannot access property of null or undefined");return e[t.computed?i(t.property):t.property.name]})(t);case Qx.CallExpression:return(t=>{const e=r.functions[t.callee.name];if(!e)throw new mx(`Undefined function: ${t.callee.name}`);return e(...t.arguments.map(t=>i(t)))})(t);case Qx.BinaryExpression:return(t=>{if("&&"===t.operator){const e=i(t.left);return e?i(t.right):e}if("||"===t.operator)return i(t.left)||i(t.right);const e=i(t.left),n=i(t.right);switch(t.operator){case"+":return e+n;case"-":return e-n;case"*":return e*n;case"/":return e/n;case"%":return e%n;case"===":return e===n;case"!==":return e!==n;case">":return e>n;case">=":return e>=n;case"<":return e<n;case"<=":return e<=n;default:throw new mx(`Unknown operator: ${t.operator}`)}})(t);case Qx.UnaryExpression:return(t=>{const e=i(t.argument);if(t.prefix)switch(t.operator){case"!":return!e;case"-":if("number"!=typeof e)throw new mx(`Cannot apply unary - to non-number: ${e}`);return-e;default:throw new mx(`Unknown operator: ${t.operator}`)}throw new mx(`Postfix operators are not supported: ${t.operator}`)})(t);case Qx.ConditionalExpression:return(t=>{const e=i(t.test);return i(e?t.consequent:t.alternate)})(t);default:throw new mx(`Evaluation error: Unsupported node type: ${t.type}`)}};return i(t.body)};function Px(t){const e=(t=>{const e=t,n=e.length,r=new Array(Math.ceil(n/3));let i=0,o=0;function A(t){const r=o+1;o++;let i="",A=!1;for(;o<n;){const n=e.charCodeAt(o);if(n===t)return A||(i=e.substring(r,o)),o++,{type:yx.STRING,value:i};92===n?(A||(i=e.substring(r,o),A=!0),o++,i+=e[o]):A&&(i+=e[o]),o++}throw new mx(`Unterminated string starting with ${String.fromCharCode(t)}`,o,e.substring(Math.max(0,o-10),o))}function s(){const t=o;for(45===e.charCodeAt(o)&&o++;o<n&&Mx(e.charCodeAt(o));)o++;if(o<n&&46===e.charCodeAt(o))for(o++;o<n&&Mx(e.charCodeAt(o));)o++;const r=e.slice(t,o);return{type:yx.NUMBER,value:r}}function a(){o++;const t=o;if(o<n&&Fx(e.charCodeAt(o)))for(o++;o<n&&kx(e.charCodeAt(o));)o++;const r=e.slice(t,o);return{type:yx.FUNCTION,value:r}}function c(){const t=o++;for(;o<n&&kx(e.charCodeAt(o));)o++;const r=e.slice(t,o),i=Bx.get(r);return i?{type:i,value:r}:{type:yx.IDENTIFIER,value:r}}function l(){if(o+2<n){const t=e.substring(o,o+3);if(Ex.has(t))return o+=3,{type:yx.OPERATOR,value:t}}if(o+1<n){const t=e.substring(o,o+2);if(Ex.has(t))return o+=2,{type:yx.OPERATOR,value:t}}const t=e[o];if(Ex.has(t))return o++,{type:yx.OPERATOR,value:t};throw new mx(`Unknown operator at position ${o}: ${e.substring(o,o+1)}`,o,e.substring(Math.max(0,o-10),o))}for(;o<n;){const t=e.charCodeAt(o);if(u=t,wx.has(u)){o++;continue}const h=Cx.get(t);if(h)r[i++]=h,o++;else if(34!==t&&39!==t)if(Mx(t)||45===t&&o+1<n&&Mx(e.charCodeAt(o+1)))r[i++]=s();else if(64!==t)if(Fx(t))r[i++]=c();else{if(!Sx(t))throw new mx(`Unexpected character: ${e[o]}`,o,e.substring(Math.max(0,o-10),o));r[i++]=l()}else r[i++]=a();else r[i++]=A(t)}var u;return i===r.length?r:r.slice(0,i)})(t),n=Ix(e),r=((t={},e={})=>({context:t,functions:e}))({},vx);return(t={})=>Lx(n,r,t)}function Dx(t,e){if("string"!=typeof t)return;const n=t.trim();if(n)try{return Px(n),function(t,e={}){return Px(t)(e)}(n,e)}catch(t){return}}function Rx(t){return"number"==typeof t}function Hx(t){if(!t)return[0,0,0];if(Rx(t))return[t,t,t];if(Array.isArray(t)&&0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function _x(t){return null==t}function Gx(t){return"string"==typeof t}function Kx(t){return"function"==typeof t}function jx(t,e){if("function"==typeof t)return t;if("string"==typeof t){const n=t;return(...t)=>{const r={};for(let n=0;n<e.length;n++)r[e[n]]=t[n];return Dx(n,r)}}return()=>t}function zx(t,e,n="node"){if(_x(t))return()=>e;if(Gx(t)){const r=jx(t,[n]);return t=>{const n=r(t);return Rx(n)?n:e}}return Kx(t)?t:Rx(t)?()=>t:()=>e}function Vx(t,e=10,n="node"){if(_x(t))return()=>e;if(Gx(t)){const r=jx(t,[n]);return t=>{const n=r(t);return function(t){return!!Rx(t)||!!Array.isArray(t)&&t.every(t=>Rx(t))}(n)?n:e}}return Kx(t)?t:Rx(t)||Array.isArray(t)?()=>t:()=>e}const Wx=(t,e,n=10,r=0)=>{const i=Vx(e,r),o=Vx(t,n);return t=>{const[e,n,r]=Hx(o(t)),[A,s,a]=Hx(i(t));return[e+A,n+s,r+a]}};function Yx(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}class Xx{constructor(t,e={}){this.edgeIdCounter=new Map,this.nodeMap=function(t,e){if(!t)throw new Error("Data.nodes is required");const n=new Map;for(const r of t){const t={_original:r};for(const e of qx){const n=r[e];_x(n)||(t[e]=n)}if(e){const n=e(r);for(const e in n){const r=n[e];_x(r)||(t[e]=r)}}if(_x(t.id))throw new Error("Node is missing id field");n.set(t.id,t)}return n}(t.nodes,e.node),this.edgeMap=function(t,e,n){const r=new Map;for(const i of t){const t={_original:i};for(const e of $x){const n=i[e];_x(n)||(t[e]=n)}if(e){const n=e(i);for(const e in n){const r=n[e];_x(r)||(t[e]=r)}}if(_x(t.source)||_x(t.target))throw new Error("Edge is missing source or target field");_x(t.id)&&(t.id=null==n?void 0:n(i)),r.set(t.id,t)}return r}(t.edges||[],e.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(t){this.nodeMap=t.nodes,this.edgeMap=t.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(t){return this.nodeMap.get(t)}nodeAt(t){this.indexNodeCache||this.buildNodeIndexCache();const e=this.indexNodeCache.get(t);return e?this.nodeMap.get(e):void 0}nodeIndexOf(t){var e;return this.nodeIndexCache||this.buildNodeIndexCache(),null!==(e=this.nodeIndexCache.get(t))&&void 0!==e?e:-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(t){let e=0;this.nodeMap.forEach(n=>t(n,e++))}originalNode(t){const e=this.nodeMap.get(t);return null==e?void 0:e._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(t){return this.edgeMap.get(t)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(t){let e=0;this.edgeMap.forEach(n=>t(n,e++))}originalEdge(t){const e=this.edgeMap.get(t);return null==e?void 0:e._original}edgeCount(){return this.edgeMap.size}getEdgeId(t){if(t.id)return t.id;const e=`${t.source}-${t.target}`,n=this.edgeIdCounter.get(e)||0,r=0===n?e:`${e}-${n}`;return this.edgeIdCounter.set(e,n+1),r}degree(t,e="both"){this.degreeCache||this.buildDegreeCache();const n=this.degreeCache.get(t);return n?n[e]:0}neighbors(t,e="both"){if(this.outAdjacencyCache&&this.inAdjacencyCache||this.buildAdjacencyCache(),"out"===e)return Array.from(this.outAdjacencyCache.get(t)||[]);if("in"===e)return Array.from(this.inAdjacencyCache.get(t)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(t)||[]);const n=this.inAdjacencyCache.get(t),r=this.outAdjacencyCache.get(t);if(!n&&!r)return[];if(!n)return Array.from(r);if(!r)return Array.from(n);const i=new Set;return n.forEach(t=>i.add(t)),r.forEach(t=>i.add(t)),Array.from(i)}successors(t){return this.neighbors(t,"out")}predecessors(t){return this.neighbors(t,"in")}setNodeOrder(t){const e=new Map;for(const n of t)e.set(n.id,n);this.nodeMap=e,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(const t of this.edges()){const{source:e,target:n}=t;if(t.source===t.target)continue;this.degreeCache.has(e)||this.degreeCache.set(e,{in:0,out:0,both:0});const r=this.degreeCache.get(t.source);r&&(r.out++,r.both++),this.degreeCache.has(n)||this.degreeCache.set(n,{in:0,out:0,both:0});const i=this.degreeCache.get(t.target);i&&(i.in++,i.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(const t of this.edges())this.nodeMap.has(t.source)&&this.nodeMap.has(t.target)&&(this.outAdjacencyCache.has(t.source)||this.outAdjacencyCache.set(t.source,new Set),this.outAdjacencyCache.get(t.source).add(t.target),this.inAdjacencyCache.has(t.target)||this.inAdjacencyCache.set(t.target,new Set),this.inAdjacencyCache.get(t.target).add(t.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let t=0;this.nodeMap.forEach((e,n)=>{this.nodeIndexCache.set(n,t),this.indexNodeCache.set(t,n),t++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}}const qx=["id","x","y","z","vx","vy","vz","fx","fy","fz","parentId"],$x=["id","source","target","points"];function Zx(t,e,n,r=2){t.forEachNode(t=>{_x(t.x)&&(t.x=Math.random()*e),_x(t.y)&&(t.y=Math.random()*n),3===r&&_x(t.z)&&(t.z=Math.random()*Math.min(e,n))})}class Jx{constructor(t,e={}){this.graph=new Xx(t,e)}export(){return this.graph.data()}replace(t){this.graph.replace(t)}forEachNode(t){this.graph.forEachNode(t)}forEachEdge(t){this.graph.forEachEdge((e,n)=>{e.sourceNode=this.graph.node(e.source),e.targetNode=this.graph.node(e.target),t(e,n)})}destroy(){this.graph.destroy()}}
|
|
55
|
+
*/var jw=Kw("renderState"),zw=function(){function t(e){A(this,t),this.renderQueue=[],Object.defineProperty(this,jw,{writable:!0,value:{restoreStack:[],prevObject:null,currentContext:new Map}}),this.clearFullScreenLastFrame=!1,this.clearFullScreen=!1,this.vpMatrix=C(),this.dprMatrix=C(),this.tmpMat4=C(),this.vec3a=at(),this.vec3b=at(),this.vec3c=at(),this.vec3d=at(),this.canvasRendererPluginOptions=e}return a(t,[{key:"apply",value:function(e,n){var r=this;this.context=e;var i=this.context,o=i.config,A=i.camera,s=i.renderingService,a=i.renderingContext,c=i.pathGeneratorFactory,l=o.renderer.getConfig().enableRenderingOptimization;o.renderer.getConfig().enableDirtyCheck=!1,o.renderer.getConfig().enableDirtyRectangleRendering=!1,this.pathGeneratorFactory=c;var u=e.contextService,h=a.root.ownerDocument.defaultView;s.hooks.init.tap(t.tag,function(){var t=u.getDPR(),e=o.width,n=o.height,i=u.getContext();r.clearRect(i,0,0,e*t,n*t,o.background)}),s.hooks.destroy.tap(t.tag,function(){r.renderQueue=[],_w(r,jw)[jw]={restoreStack:[],prevObject:null,currentContext:null}});var d=function(t,e){for(var i=[t];i.length>0;){var o,A=i.pop();A.isVisible()&&!A.isCulled()&&(l?r.renderDisplayObjectOptimized(A,e,r.context,_w(r,jw)[jw],n):r.renderDisplayObject(A,e,r.context,_w(r,jw)[jw],n));for(var s=(null===(o=A.sortable)||void 0===o||null===(o=o.sorted)||void 0===o?void 0:o.length)>0?A.sortable.sorted:A.childNodes,a=s.length-1;a>=0;a--)i.push(s[a])}};s.hooks.endFrame.tap(t.tag,function(){if(function(){var t,e=u.getContext(),n=u.getDPR(),i=o.width,A=o.height,a=r.canvasRendererPluginOptions,c=a.dirtyObjectNumThreshold,l=a.dirtyObjectRatioThreshold,d=s.getStats(),f=d.total,g=d.rendered,p=g/f;r.clearFullScreen=r.clearFullScreenLastFrame||!(null!==(t=h.context.renderingPlugins[1])&&void 0!==t&&t.isFirstTimeRenderingFinished)||s.disableDirtyRectangleRendering()||g>c&&p>l,e&&("function"==typeof e.resetTransform?e.resetTransform():e.setTransform(1,0,0,1,0,0),r.clearFullScreen&&r.clearRect(e,0,0,i*n,A*n,o.background))}(),0!==a.root.childNodes.length){l=o.renderer.getConfig().enableRenderingOptimization,_w(r,jw)[jw]={restoreStack:[],prevObject:null,currentContext:_w(r,jw)[jw].currentContext},_w(r,jw)[jw].currentContext.clear(),r.clearFullScreenLastFrame=!1;var t=u.getContext(),e=u.getDPR();if(H(r.dprMatrix,[e,e,1]),O(r.vpMatrix,r.dprMatrix,A.getOrthoMatrix()),r.clearFullScreen)l?(t.save(),d(a.root,t),t.restore()):d(a.root,t);else{var i=r.safeMergeAABB(r.mergeDirtyAABBs(r.renderQueue));if(yr.isEmpty(i))return void(r.renderQueue=[]);var c=r.convertAABB2Rect(i),f=c.x,g=c.y,p=c.width,v=c.height,y=bt(r.vec3a,[f,g,0],r.vpMatrix),w=bt(r.vec3b,[f+p,g,0],r.vpMatrix),b=bt(r.vec3c,[f,g+v,0],r.vpMatrix),B=bt(r.vec3d,[f+p,g+v,0],r.vpMatrix),E=Math.min(y[0],w[0],B[0],b[0]),x=Math.min(y[1],w[1],B[1],b[1]),C=Math.max(y[0],w[0],B[0],b[0]),M=Math.max(y[1],w[1],B[1],b[1]),F=Math.floor(E),k=Math.floor(x),S=Math.ceil(C-E),Q=Math.ceil(M-x);t.save(),r.clearRect(t,F,k,S,Q,o.background),t.beginPath(),t.rect(F,k,S,Q),t.clip(),t.setTransform(r.vpMatrix[0],r.vpMatrix[1],r.vpMatrix[4],r.vpMatrix[5],r.vpMatrix[12],r.vpMatrix[13]),o.renderer.getConfig().enableDirtyRectangleRenderingDebug&&h.dispatchEvent(new Vs(mc.DIRTY_RECTANGLE,{dirtyRect:{x:F,y:k,width:S,height:Q}}));var U=m(i.getMin(),2),N=U[0],T=U[1],I=m(i.getMax(),2),L=I[0],P=I[1];a.root.ownerDocument.elementsFromBBox(N,T,L,P).sort(function(t,e){return t.sortable.renderOrder-e.sortable.renderOrder}).forEach(function(e){e&&e.isVisible()&&!e.isCulled()&&r.renderDisplayObject(e,t,r.context,_w(r,jw)[jw],n)}),t.restore(),r.renderQueue.forEach(function(t){r.saveDirtyAABB(t)}),r.renderQueue=[]}_w(r,jw)[jw].restoreStack.forEach(function(){t.restore()}),_w(r,jw)[jw].restoreStack=[]}else r.clearFullScreenLastFrame=!0}),s.hooks.render.tap(t.tag,function(t){r.clearFullScreen||r.renderQueue.push(t)})}},{key:"clearRect",value:function(t,e,n,r,i,o){t.clearRect(e,n,r,i),o&&(t.fillStyle=o,t.fillRect(e,n,r,i))}},{key:"renderDisplayObjectOptimized",value:function(t,e,n,r,i){var o=t.nodeName,A=!1,s=this.context.styleRendererFactory[o],a=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){(!r.prevObject||!it(c.getWorldTransform(),r.prevObject.getWorldTransform()))&&(this.applyWorldTransform(e,c),r.prevObject=null);var l=this.pathGeneratorFactory[c.nodeName];l&&(e.save(),A=!0,e.beginPath(),l(e,c.parsedStyle),e.closePath(),e.clip())}if(s){(!r.prevObject||!it(t.getWorldTransform(),r.prevObject.getWorldTransform()))&&this.applyWorldTransform(e,t);var u=!r.prevObject;if(!u){var h=r.prevObject.nodeName;u=o===cr.TEXT?h!==cr.TEXT:o===cr.IMAGE?h!==cr.IMAGE:h===cr.TEXT||h===cr.IMAGE}s.applyStyleToContext(e,t,u,r),r.prevObject=t}a&&(e.beginPath(),a(e,t.parsedStyle),o!==cr.LINE&&o!==cr.PATH&&o!==cr.POLYLINE&&e.closePath()),s&&s.drawToContext(e,t,_w(this,jw)[jw],this,i),A&&e.restore(),t.dirty(!1)}},{key:"renderDisplayObject",value:function(t,e,n,r,i){var o=t.nodeName,A=r.restoreStack[r.restoreStack.length-1];!A||t.compareDocumentPosition(A)&Ys.DOCUMENT_POSITION_CONTAINS||(e.restore(),r.restoreStack.pop());var s=this.context.styleRendererFactory[o],a=this.pathGeneratorFactory[o],c=t.parsedStyle.clipPath;if(c){this.applyWorldTransform(e,c);var l=this.pathGeneratorFactory[c.nodeName];l&&(e.save(),r.restoreStack.push(t),e.beginPath(),l(e,c.parsedStyle),e.closePath(),e.clip())}s&&(this.applyWorldTransform(e,t),e.save(),this.applyAttributesToContext(e,t)),a&&(e.beginPath(),a(e,t.parsedStyle),o!==cr.LINE&&o!==cr.PATH&&o!==cr.POLYLINE&&e.closePath()),s&&(s.render(e,t.parsedStyle,t,n,this,i),e.restore()),t.dirty(!1)}},{key:"applyAttributesToContext",value:function(t,e){var n=e.parsedStyle,r=n.stroke,i=n.fill,o=n.opacity,A=n.lineDash,s=n.lineDashOffset;A&&t.setLineDash(A),Kt(s)||(t.lineDashOffset=s),Kt(o)||(t.globalAlpha*=o),Kt(r)||Array.isArray(r)||r.isNone||(t.strokeStyle=e.attributes.stroke),Kt(i)||Array.isArray(i)||i.isNone||(t.fillStyle=e.attributes.fill)}},{key:"convertAABB2Rect",value:function(t){var e=t.getMin(),n=t.getMax(),r=Math.floor(e[0]),i=Math.floor(e[1]);return{x:r,y:i,width:Math.ceil(n[0])-r,height:Math.ceil(n[1])-i}}},{key:"mergeDirtyAABBs",value:function(t){var e=new yr;return t.forEach(function(t){var n=t.getRenderBounds();e.add(n);var r=t.renderable.dirtyRenderBounds;r&&e.add(r)}),e}},{key:"saveDirtyAABB",value:function(t){var e=t.renderable;e.dirtyRenderBounds||(e.dirtyRenderBounds=new yr);var n=t.getRenderBounds();n&&e.dirtyRenderBounds.update(n.center,n.halfExtents)}},{key:"applyWorldTransform",value:function(t,e,n){n?(F(this.tmpMat4,e.getLocalTransform()),O(this.tmpMat4,n,this.tmpMat4),O(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(F(this.tmpMat4,e.getWorldTransform()),O(this.tmpMat4,this.vpMatrix,this.tmpMat4)),t.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])}},{key:"safeMergeAABB",value:function(){for(var t=new yr,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return n.forEach(function(e){t.add(e)}),t}}])}();function Vw(t,e,n,r,i,o,A){var s,a;if("rect"===t.image.nodeName){var c=t.image.parsedStyle,l=c.width,u=c.height;a=r.contextService.getDPR();var h=r.config.offscreenCanvas;(s=o.offscreenCanvasCreator.getOrCreateCanvas(h)).width=l*a,s.height=u*a;var d=o.offscreenCanvasCreator.getOrCreateContext(h),f={restoreStack:[],prevObject:null,currentContext:new Map};t.image.forEach(function(t){i.renderDisplayObject(t,d,r,f,o)}),f.restoreStack.forEach(function(){d.restore()})}return A.getOrCreatePatternSync(e,t,n,s,a,e.getGeometryBounds().min,function(){e.dirty(),r.renderingService.dirty()})}function Ww(t,e,n,r){var i;if(t.type===Xi.LinearGradient||t.type===Xi.RadialGradient){var A=e.getGeometryBounds(),s=A&&2*A.halfExtents[0]||1,a=A&&2*A.halfExtents[1]||1,c=A&&A.min||[0,0];i=r.getOrCreateGradient(o(o({type:t.type},t.value),{},{min:c,width:s,height:a}),n)}return i}zw.tag="CanvasRenderer";var Yw=["shadowBlur","shadowOffsetX","shadowOffsetY"],Xw=["lineCap","lineJoin","miterLimit"],qw={globalAlpha:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",filter:"none",globalCompositeOperation:"source-over",strokeStyle:"#000",strokeOpacity:1,lineWidth:1,lineDash:[],lineDashOffset:0,lineCap:"butt",lineJoin:"miter",miterLimit:10,fillStyle:"#000",fillOpacity:1},$w={};function Zw(t,e,n,r){var i=r.has(e)?r.get(e):qw[e];return i!==n&&("lineDash"===e?t.setLineDash(n):t[e]=n,r.set(e,n)),i}var Jw=function(){return a(function t(e){A(this,t),this.imagePool=e},[{key:"applyAttributesToContext",value:function(t,e){}},{key:"render",value:function(t,e,n,r,i,o){}},{key:"applyCommonStyleToContext",value:function(t,e,n,r){var i=n?$w:r.prevObject.parsedStyle,o=e.parsedStyle;(n||o.opacity!==i.opacity)&&Zw(t,"globalAlpha",Kt(o.opacity)?qw.globalAlpha:o.opacity,r.currentContext),(n||o.blend!==i.blend)&&Zw(t,"globalCompositeOperation",Kt(o.blend)?qw.globalCompositeOperation:o.blend,r.currentContext)}},{key:"applyStrokeFillStyleToContext",value:function(t,e,n,r){var i=n?$w:r.prevObject.parsedStyle,o=e.parsedStyle,A=o.lineWidth,s=void 0===A?qw.lineWidth:A,a=o.fill&&!o.fill.isNone;if(o.stroke&&!o.stroke.isNone&&s>0){if(n||e.attributes.stroke!==r.prevObject.attributes.stroke)Zw(t,"strokeStyle",Kt(o.stroke)||Array.isArray(o.stroke)||o.stroke.isNone?qw.strokeStyle:e.attributes.stroke,r.currentContext);(n||o.lineWidth!==i.lineWidth)&&Zw(t,"lineWidth",Kt(o.lineWidth)?qw.lineWidth:o.lineWidth,r.currentContext),(n||o.lineDash!==i.lineDash)&&Zw(t,"lineDash",o.lineDash||qw.lineDash,r.currentContext),(n||o.lineDashOffset!==i.lineDashOffset)&&Zw(t,"lineDashOffset",Kt(o.lineDashOffset)?qw.lineDashOffset:o.lineDashOffset,r.currentContext);for(var c=0;c<Xw.length;c++){var l=Xw[c];(n||o[l]!==i[l])&&Zw(t,l,Kt(o[l])?qw[l]:o[l],r.currentContext)}}a&&(n||e.attributes.fill!==r.prevObject.attributes.fill)&&Zw(t,"fillStyle",Kt(o.fill)||Array.isArray(o.fill)||o.fill.isNone?qw.fillStyle:e.attributes.fill,r.currentContext)}},{key:"applyStyleToContext",value:function(t,e,n,r){var i=e.nodeName;this.applyCommonStyleToContext(t,e,n,r),i===cr.IMAGE||this.applyStrokeFillStyleToContext(t,e,n,r)}},{key:"applyShadowAndFilterStyleToContext",value:function(t,e,n,r){var i=e.parsedStyle;if(n){Zw(t,"shadowColor",i.shadowColor.toString(),r.currentContext);for(var o=0;o<Yw.length;o++){var A=Yw[o];Zw(t,A,i[A]||qw[A],r.currentContext)}}i.filter&&i.filter.length&&Zw(t,"filter",e.attributes.filter,r.currentContext)}},{key:"clearShadowAndFilterStyleForContext",value:function(t,e,n,r){var i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(e){Zw(t,"shadowColor",qw.shadowColor,r.currentContext);for(var o=0;o<Yw.length;o++){var A=Yw[o];Zw(t,A,qw[A],r.currentContext)}}if(n)if(e&&i){var s=t.filter;!Kt(s)&&s.indexOf("drop-shadow")>-1&&Zw(t,"filter",s.replace(/drop-shadow\([^)]*\)/,"").trim()||qw.filter,r.currentContext)}else Zw(t,"filter",qw.filter,r.currentContext)}},{key:"fillToContext",value:function(t,e,n,r,i){var o=this,A=e.parsedStyle,s=A.fill,a=A.fillRule,c=null;if(Array.isArray(s)&&s.length>0)s.forEach(function(r){var i=Zw(t,"fillStyle",Ww(r,e,t,o.imagePool),n.currentContext);c=null!=c?c:i,a?t.fill(a):t.fill()});else{if(wo(s)){var l=Vw(s,e,t,e.ownerDocument.defaultView.context,r,i,this.imagePool);l&&(t.fillStyle=l,c=!0)}a?t.fill(a):t.fill()}null!==c&&Zw(t,"fillStyle",c,n.currentContext)}},{key:"strokeToContext",value:function(t,e,n,r,i){var o=this,A=e.parsedStyle.stroke,s=null;if(Array.isArray(A)&&A.length>0)A.forEach(function(r){var i=Zw(t,"strokeStyle",Ww(r,e,t,o.imagePool),n.currentContext);s=null!=s?s:i,t.stroke()});else{if(wo(A)){var a=Vw(A,e,t,e.ownerDocument.defaultView.context,r,i,this.imagePool);if(a){var c=Zw(t,"strokeStyle",a,n.currentContext);s=null!=s?s:c}}t.stroke()}null!==s&&Zw(t,"strokeStyle",s,n.currentContext)}},{key:"drawToContext",value:function(t,e,n,r,i){var o,A=e.nodeName,s=e.parsedStyle,a=s.opacity,c=void 0===a?qw.globalAlpha:a,l=s.fillOpacity,u=void 0===l?qw.fillOpacity:l,h=s.strokeOpacity,d=void 0===h?qw.strokeOpacity:h,f=s.lineWidth,g=void 0===f?qw.lineWidth:f,p=s.fill&&!s.fill.isNone,v=s.stroke&&!s.stroke.isNone&&g>0;if(p||v){var m=!Kt(s.shadowColor)&&s.shadowBlur>0,y="inner"===s.shadowType,w=0===(null===(o=s.fill)||void 0===o?void 0:o.alpha),b=!(!s.filter||!s.filter.length),B=m&&v&&(A===cr.PATH||A===cr.LINE||A===cr.POLYLINE||w||y),E=null;if(p)B||this.applyShadowAndFilterStyleToContext(t,e,m,n),E=Zw(t,"globalAlpha",c*u,n.currentContext),this.fillToContext(t,e,n,r,i),B||this.clearShadowAndFilterStyleForContext(t,m,b,n);if(v){var x=!1,C=Zw(t,"globalAlpha",c*d,n.currentContext);if(E=p?E:C,B&&(this.applyShadowAndFilterStyleToContext(t,e,m,n),x=!0,y)){var M=t.globalCompositeOperation;t.globalCompositeOperation="source-atop",this.strokeToContext(t,e,n,r,i),t.globalCompositeOperation=M,this.clearShadowAndFilterStyleForContext(t,m,b,n,!0)}this.strokeToContext(t,e,n,r,i),x&&this.clearShadowAndFilterStyleForContext(t,m,b,n)}null!==E&&Zw(t,"globalAlpha",E,n.currentContext)}}}])}(),tb=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"render",value:function(t,e,n,r,i,o){var A=e.fill,s=e.fillRule,a=e.opacity,c=void 0===a?1:a,l=e.fillOpacity,u=void 0===l?1:l,h=e.stroke,d=e.strokeOpacity,f=void 0===d?1:d,g=e.lineWidth,p=void 0===g?1:g,v=e.lineCap,m=e.lineJoin,y=e.shadowType,w=e.shadowColor,b=e.shadowBlur,B=e.filter,E=e.miterLimit,x=A&&!A.isNone,C=h&&!h.isNone&&p>0,M=0===(null==A?void 0:A.alpha),F=!(!B||!B.length),k=!Kt(w)&&b>0,S=n.nodeName,Q="inner"===y,U=C&&k&&(S===cr.PATH||S===cr.LINE||S===cr.POLYLINE||M||Q);x&&(t.globalAlpha=c*u,U||eb(n,t,k),nb(t,n,A,s,r,i,o,this.imagePool),U||this.clearShadowAndFilter(t,F,k)),C&&(t.globalAlpha=c*f,t.lineWidth=p,Kt(E)||(t.miterLimit=E),Kt(v)||(t.lineCap=v),Kt(m)||(t.lineJoin=m),U&&(Q&&(t.globalCompositeOperation="source-atop"),eb(n,t,!0),Q&&(rb(t,n,h,r,i,o,this.imagePool),t.globalCompositeOperation=qw.globalCompositeOperation,this.clearShadowAndFilter(t,F,!0))),rb(t,n,h,r,i,o,this.imagePool))}},{key:"clearShadowAndFilter",value:function(t,e,n){if(n&&(t.shadowColor="transparent",t.shadowBlur=0),e){var r=t.filter;!Kt(r)&&r.indexOf("drop-shadow")>-1&&(t.filter=r.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}}}])}(Jw);function eb(t,e,n){var r=t.parsedStyle,i=r.filter,o=r.shadowColor,A=r.shadowBlur,s=r.shadowOffsetX,a=r.shadowOffsetY;i&&i.length&&(e.filter=t.style.filter),n&&(e.shadowColor=o.toString(),e.shadowBlur=A||0,e.shadowOffsetX=s||0,e.shadowOffsetY=a||0)}function nb(t,e,n,r,i,o,A,s){var a=arguments.length>8&&void 0!==arguments[8]&&arguments[8];Array.isArray(n)?n.forEach(function(n){t.fillStyle=Ww(n,e,t,s),a||(r?t.fill(r):t.fill())}):(wo(n)&&(t.fillStyle=Vw(n,e,t,i,o,A,s)),a||(r?t.fill(r):t.fill()))}function rb(t,e,n,r,i,o,A){var s=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Array.isArray(n)?n.forEach(function(n){t.strokeStyle=Ww(n,e,t,A),s||t.stroke()}):(wo(n)&&(t.strokeStyle=Vw(n,e,t,r,i,o,A)),s||t.stroke())}var ib=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"renderDownSampled",value:function(t,e,n,r){var i=r.src,o=r.imageCache;o.downSampled?t.drawImage(o.downSampled,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3])):this.imagePool.createDownSampledImage(i,n).then(function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())}).catch(function(t){console.error(t)})}},{key:"renderTile",value:function(t,e,n,r){var i=r.src,o=r.imageCache,A=r.imageRect,s=r.drawRect,a=o.size,c=t.getTransform(),l=c.a,u=c.b,h=c.c,d=c.d,f=c.e,g=c.f;if(t.resetTransform(),null!=o&&o.gridSize){for(var p=[a[0]/A[2],a[1]/A[3]],v=[o.tileSize[0]/p[0],o.tileSize[1]/p[1]],m=[Math.floor((s[0]-A[0])/v[0]),Math.ceil((s[0]+s[2]-A[0])/v[0])],y=m[0],w=m[1],b=[Math.floor((s[1]-A[1])/v[1]),Math.ceil((s[1]+s[3]-A[1])/v[1])],B=b[1],E=b[0];E<=B;E++)for(var x=y;x<=w;x++){var C=o.tiles[E][x];if(C){var M=[Math.floor(A[0]+C.tileX*v[0]),Math.floor(A[1]+C.tileY*v[1]),Math.ceil(v[0]),Math.ceil(v[1])];t.drawImage(C.data,M[0],M[1],M[2],M[3])}}t.setTransform(l,u,h,d,f,g)}else this.imagePool.createImageTiles(i,[],function(){n.ownerDocument&&(n.dirty(),n.ownerDocument.defaultView.context.renderingService.dirty())},n).catch(function(t){console.error(t)})}},{key:"render",value:function(t,n,r){var i=n.x,o=void 0===i?0:i,A=n.y,s=void 0===A?0:A,a=n.width,c=n.height,l=n.src,u=n.shadowColor,h=n.shadowBlur,d=this.imagePool.getImageSync(l,r),f=null==d?void 0:d.img,g=a,p=c;if(f){var v,y,w,b,B,E,x,C,M,F,S,Q,U,N,T;g||(g=f.width),p||(p=f.height),eb(r,t,!Kt(u)&&h>0);try{var O=r.ownerDocument.defaultView.getContextService().getDomElement(),I=O.width,L=O.height,P=t.getTransform(),D=P.a,R=P.b,H=function(t,e){var n=bt(at(),[t[0],t[1],0],e),r=bt(at(),[t[0]+t[2],t[1],0],e),i=bt(at(),[t[0],t[1]+t[3],0],e),o=bt(at(),[t[0]+t[2],t[1]+t[3],0],e);return[Math.min(n[0],r[0],i[0],o[0]),Math.min(n[1],r[1],i[1],o[1]),Math.max(n[0],r[0],i[0],o[0])-Math.min(n[0],r[0],i[0],o[0]),Math.max(n[1],r[1],i[1],o[1])-Math.min(n[1],r[1],i[1],o[1])]}([o,s,g,p],k(D,P.c,0,0,R,P.d,0,0,0,0,1,0,P.e,P.f,0,1)),_=(v=H,y=m([0,0,I,L],4),w=y[0],b=y[1],B=y[2],E=y[3],x=m(v,4),C=x[0],M=x[1],F=x[2],S=x[3],Q=Math.max(w,C),U=Math.max(b,M),N=Math.min(w+B,C+F),T=Math.min(b+E,M+S),N<=Q||T<=U?null:[Q,U,N-Q,T-U]);if(!_)return;if(!r.ownerDocument.defaultView.getConfig().enableLargeImageOptimization)return void e.renderFull(t,n,r,{image:f,drawRect:[o,s,g,p]});if(H[2]/d.size[0]<(d.downSamplingRate||.5))return void this.renderDownSampled(t,n,r,{src:l,imageCache:d,drawRect:[o,s,g,p]});if(!ImagePool.isSupportTile)return void e.renderFull(t,n,r,{image:f,drawRect:[o,s,g,p]});this.renderTile(t,n,r,{src:l,imageCache:d,imageRect:H,drawRect:_})}catch(t){}}}},{key:"drawToContext",value:function(t,e,n,r,i){this.render(t,e.parsedStyle,e)}}],[{key:"renderFull",value:function(t,e,n,r){t.drawImage(r.image,Math.floor(r.drawRect[0]),Math.floor(r.drawRect[1]),Math.ceil(r.drawRect[2]),Math.ceil(r.drawRect[3]))}}])}(tb),ob=function(t){function e(){return A(this,e),g(this,e,arguments)}return v(e,t),a(e,[{key:"render",value:function(t,e,n,r,i,o){n.getBounds();var A=e.lineWidth,s=void 0===A?1:A,a=e.textAlign,c=void 0===a?"start":a,l=e.textBaseline,u=void 0===l?"alphabetic":l,h=e.lineJoin,d=void 0===h?"miter":h,f=e.miterLimit,g=void 0===f?10:f,p=e.letterSpacing,v=void 0===p?0:p,m=e.stroke,y=e.fill,w=e.fillRule,b=e.fillOpacity,B=void 0===b?1:b,E=e.strokeOpacity,x=void 0===E?1:E,C=e.opacity,M=void 0===C?1:C,F=e.metrics,k=e.x,S=void 0===k?0:k,Q=e.y,U=void 0===Q?0:Q,N=e.dx,T=e.dy,O=e.shadowColor,I=e.shadowBlur,L=e.textDecorationLine,P=F.font,D=F.lines,R=F.height,H=F.lineHeight,_=F.lineMetrics;t.font=P,t.lineWidth=s,t.textAlign="middle"===c?"center":c;var G=u;"alphabetic"===G&&(G="bottom"),t.lineJoin=d,Kt(g)||(t.miterLimit=g);var K=U;"middle"===u?K+=-R/2-H/2:"bottom"===u||"alphabetic"===u||"ideographic"===u?K+=-R:"top"!==u&&"hanging"!==u||(K+=-H);var j=S+(N||0);K+=T||0,1===D.length&&("bottom"===G?(G="middle",K-=.5*R):"top"===G&&(G="middle",K+=.5*R)),t.textBaseline=G,eb(n,t,!Kt(O)&&I>0);for(var z=0;z<D.length;z++){var V=s/2+j;K+=H,Kt(m)||m.isNone||!s||this.drawLetterSpacing(t,n,D[z],_[z],c,V,K,v,y,w,B,m,x,M,!0,r,i,o),Kt(y)||this.drawLetterSpacing(t,n,D[z],_[z],c,V,K,v,y,w,B,m,x,M,!1,r,i,o)}L&&"none"!==L&&this.drawTextDecorations(t,e,n,D,H,j,U+(T||0),r,i,o)}},{key:"drawLetterSpacing",value:function(t,e,n,r,i,o,A,s,a,c,l,u,h,d,f,g,p,v){if(0!==s){var m=t.textAlign;t.textAlign="left";var y=o;"center"===i||"middle"===i?y=o-r.width/2:"right"!==i&&"end"!==i||(y=o-r.width);for(var w=Array.from(n),b=t.measureText(n).width,B=0,E=0;E<w.length;++E){var x=w[E];f?this.strokeText(t,e,x,y,A,u,h,g,p,v):this.fillText(t,e,x,y,A,a,c,l,d,g,p,v),y+=b-(B=t.measureText(n.substring(E+1)).width)+s,b=B}t.textAlign=m}else f?this.strokeText(t,e,n,o,A,u,h,g,p,v):this.fillText(t,e,n,o,A,a,c,l,d,g,p,v)}},{key:"fillText",value:function(t,e,n,r,i,o,A,s,a,c,l,u){var h;nb(t,e,o,A,c,l,u,this.imagePool,!0);var d=!Kt(s)&&1!==s;d&&(h=t.globalAlpha,t.globalAlpha=s*a),t.fillText(n,r,i),d&&(t.globalAlpha=h)}},{key:"strokeText",value:function(t,e,n,r,i,o,A,s,a,c){var l;rb(t,e,o,s,a,c,this.imagePool,!0);var u=!Kt(A)&&1!==A;u&&(l=t.globalAlpha,t.globalAlpha=A),t.strokeText(n,r,i),u&&(t.globalAlpha=l)}},{key:"drawTextDecorations",value:function(t,e,n,r,i,o,A,s,a,c){var l=e.textDecorationLine,u=e.textDecorationColor,h=e.textDecorationStyle,d=e.textDecorationThickness,f=void 0===d?1:d,g=e.textAlign,p=void 0===g?"start":g,v=e.lineWidth,m=void 0===v?1:v,y=e.metrics;if(l&&"none"!==l){var w=y.lineMetrics,b=l.split(" ");switch(t.lineWidth=f,u&&(t.strokeStyle="rgba(".concat(u.r,", ").concat(u.g,", ").concat(u.b,", ").concat(u.alpha,")")),h){case"dashed":t.setLineDash([5,5]);break;case"dotted":t.setLineDash([2,2]);break;default:t.setLineDash([])}var B=A,E=e.textBaseline,x=void 0===E?"alphabetic":E;"middle"===x?B+=-y.height/2-i/2:"bottom"===x||"alphabetic"===x||"ideographic"===x?B+=-y.height:"top"!==x&&"hanging"!==x||(B+=-i);for(var C=0;C<r.length;C++){B+=i;var M=w[C];if(M){var F=m/2,k=o,S=o+M.width;"center"===p||"middle"===p?(k=o-M.width/2,S=o+M.width/2):"right"!==p&&"end"!==p||(k=o-M.width,S=o),k+=F,S+=F;var Q,U=sr(b);try{for(U.s();!(Q=U.n()).done;){var N=Q.value,T=B;switch(N){case"underline":T+=2;break;case"overline":T-=i-2;break;case"line-through":T-=i/2;break;default:continue}"wavy"===h?this.drawWavyLine(t,k,S,T):(t.beginPath(),t.moveTo(k,T),t.lineTo(S,T),t.stroke())}}catch(t){U.e(t)}finally{U.f()}}}t.setLineDash([])}}},{key:"drawWavyLine",value:function(t,e,n,r){var i=10,o=Math.floor((n-e)/i);t.beginPath(),t.moveTo(e,r);for(var A=0;A<o;A++){var s=e+A*i+2.5,a=r+2,c=e+A*i+5,l=r;t.quadraticCurveTo(s,a,c,l);var u=e+A*i+7.5,h=r-2,d=e+(A+1)*i,f=r;t.quadraticCurveTo(u,h,d,f)}t.stroke()}},{key:"drawToContext",value:function(t,e,n,r,i){this.render(t,e.parsedStyle,e,e.ownerDocument.defaultView.context,r,i)}}])}(tb),Ab=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),(t=g(this,e)).name="canvas-renderer",t.options=n,t}return v(e,t),a(e,[{key:"init",value:function(){var t,e=o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options),n=this.context.imagePool,i=new tb(n),A=(r(r(r(r(r(r(r(r(r(r(t={},cr.CIRCLE,i),cr.ELLIPSE,i),cr.RECT,i),cr.IMAGE,new ib(n)),cr.TEXT,new ob(n)),cr.LINE,i),cr.POLYLINE,i),cr.POLYGON,i),cr.PATH,i),cr.GROUP,void 0),r(r(r(t,cr.HTML,void 0),cr.MESH,void 0),cr.FRAGMENT,void 0));this.context.defaultStyleRendererFactory=A,this.context.styleRendererFactory=A,this.addRenderingPlugin(new zw(e))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins(),delete this.context.defaultStyleRendererFactory,delete this.context.styleRendererFactory}}])}(ur),sb=at(),ab=at(),cb=at(),lb=C(),ub=function(){function t(){var e=this;A(this,t),this.isHit=function(t,n,r,i){var o=e.context.pointInPathPickerFactory[t.nodeName];if(o){var A=N(lb,r),s=bt(ab,dt(cb,n[0],n[1],0),A);if(o(t,new Er(s[0],s[1]),i,e.isPointInPath,e.context,e.runtime))return!0}return!1},this.isPointInPath=function(t,n){var r=e.runtime.offscreenCanvasCreator.getOrCreateContext(e.context.config.offscreenCanvas),i=e.context.pathGeneratorFactory[t.nodeName];return i&&(r.beginPath(),i(r,t.parsedStyle),r.closePath()),r.isPointInPath(n.x,n.y)}}return a(t,[{key:"apply",value:function(e,n){var r,i=this,o=e.renderingService,A=e.renderingContext;this.context=e,this.runtime=n;var s=null===(r=A.root)||void 0===r?void 0:r.ownerDocument;o.hooks.pick.tapPromise(t.tag,function(){var t=Ar(ir().mark(function t(e){return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i.pick(s,e));case 1:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),o.hooks.pickSync.tap(t.tag,function(t){return i.pick(s,t)})}},{key:"pick",value:function(t,e){var n,r=e.topmost,i=e.position,o=i.x,A=i.y,s=dt(sb,o,A,0),a=[],c=sr(t.elementsFromBBox(s[0],s[1],s[0],s[1]));try{for(c.s();!(n=c.n()).done;){var l=n.value,u=l.getWorldTransform();if(this.isHit(l,s,u,!1)){var h=qA(l);if(h){var d=h.parsedStyle.clipPath;if(this.isHit(d,s,d.getWorldTransform(),!0)){if(r)return e.picked=[l],e;a.push(l)}}else{if(r)return e.picked=[l],e;a.push(l)}}}}catch(t){c.e(t)}finally{c.f()}return e.picked=a,e}}])}();function hb(t,e,n){var r=t.parsedStyle,i=r.cx,o=void 0===i?0:i,A=r.cy,s=void 0===A?0:A,a=r.r,c=r.fill,l=r.stroke,u=r.lineWidth,h=void 0===u?1:u,d=r.increasedLineWidthForHitTesting,f=void 0===d?0:d,g=r.pointerEvents,p=void 0===g?"auto":g,v=(h+f)/2,y=Nn(o,s,e.x,e.y),w=m(es(p,c,l),2),b=w[0],B=w[1];return b&&B||n?y<=a+v:b?y<=a:!!B&&(y>=a-v&&y<=a+v)}function db(t,e,n,r){return t/(n*n)+e/(r*r)}function fb(t,e,n){var r=t.parsedStyle,i=r.cx,o=void 0===i?0:i,A=r.cy,s=void 0===A?0:A,a=r.rx,c=r.ry,l=r.fill,u=r.stroke,h=r.lineWidth,d=void 0===h?1:h,f=r.increasedLineWidthForHitTesting,g=void 0===f?0:f,p=r.pointerEvents,v=void 0===p?"auto":p,y=e.x,w=e.y,b=m(es(v,l,u),2),B=b[0],E=b[1],x=(d+g)/2,C=(y-o)*(y-o),M=(w-s)*(w-s);return B&&E||n?db(C,M,a+x,c+x)<=1:B?db(C,M,a,c)<=1:!!E&&(db(C,M,a-x,c-x)>=1&&db(C,M,a+x,c+x)<=1)}function gb(t,e,n,r,i,o){return i>=t&&i<=t+n&&o>=e&&o<=e+r}function pb(t,e,n,r,i,o,A,s){var a=(Math.atan2(s-e,A-t)+2*Math.PI)%(2*Math.PI),c={x:t+n*Math.cos(a),y:e+n*Math.sin(a)};return Nn(c.x,c.y,A,s)<=o/2}function vb(t,e,n,r,i,o,A){var s=Math.min(t,n),a=Math.max(t,n),c=Math.min(e,r),l=Math.max(e,r),u=i/2;return o>=s-u&&o<=a+u&&A>=c-u&&A<=l+u&&Hn(t,e,n,r,o,A)<=i/2}function mb(t,e,n,r,i){var o=t.length;if(o<2)return!1;for(var A=0;A<o-1;A++){if(vb(t[A][0],t[A][1],t[A+1][0],t[A+1][1],e,n,r))return!0}if(i){var s=t[0],a=t[o-1];if(vb(s[0],s[1],a[0],a[1],e,n,r))return!0}return!1}ub.tag="CanvasPicker";function yb(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function wb(t,e,n){return(n[0]-t[0])*(e[1]-t[1])===(e[0]-t[0])*(n[1]-t[1])&&Math.min(t[0],e[0])<=n[0]&&n[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=n[1]&&n[1]<=Math.max(t[1],e[1])}function bb(t,e,n){var r=!1,i=t.length;if(i<=2)return!1;for(var o=0;o<i;o++){var A=t[o],s=t[(o+1)%i];if(wb(A,s,[e,n]))return!0;yb(A[1]-n)>0!=yb(s[1]-n)>0&&yb(e-(n-A[1])*(A[0]-s[0])/(A[1]-s[1])-A[0])<0&&(r=!r)}return r}function Bb(t,e,n){for(var r=!1,i=0;i<t.length;i++){if(r=bb(t[i],e,n))break}return r}function Eb(t,e,n){var r=t.parsedStyle,i=r.x1,o=r.y1,A=r.x2,s=r.y2,a=r.lineWidth,c=void 0===a?1:a,l=r.increasedLineWidthForHitTesting,u=void 0===l?0:l,h=r.pointerEvents;return!(!m(es(void 0===h?"auto":h,r.fill,r.stroke),2)[1]&&!n||!c)&&vb(i,o,A,s,c+u,e.x,e.y)}function xb(t,e,n,r,i,o){var A=t.parsedStyle,s=A.lineWidth,a=void 0===s?1:s,c=A.increasedLineWidthForHitTesting,l=void 0===c?0:c,u=A.stroke,h=A.fill,d=A.d,f=A.pointerEvents,g=void 0===f?"auto":f,p=d.segments,v=d.hasArc,y=d.polylines,w=d.polygons,b=m(es(g,(null==w?void 0:w.length)&&h,u),2),B=b[0],E=b[1],x=Go(t),C=!1;return B||n?C=v?r(t,e):Bb(w,e.x,e.y)||Bb(y,e.x,e.y):((E||n)&&(C=function(t,e,n,r,i){for(var o=!1,A=e/2,s=0;s<t.length;s++){var a=t[s],c=a.currentPoint,l=a.params,u=a.prePoint,h=a.box;if(!h||gb(h.x-A,h.y-A,h.width+e,h.height+e,n,r))switch(a.command){case"L":case"Z":if(o=vb(u[0],u[1],c[0],c[1],e,n,r))return!0;break;case"Q":if(o=Xn(u[0],u[1],l[1],l[2],l[3],l[4],n,r)<=e/2)return!0;break;case"C":if(o=jn(u[0],u[1],l[1],l[2],l[3],l[4],l[5],l[6],n,r,i)<=e/2)return!0;break;case"A":a.cubicParams||(a.cubicParams=ln(u[0],u[1],l[1],l[2],l[3],l[4],l[5],l[6],l[7],void 0));for(var d=a.cubicParams,f=u,g=0;g<d.length;g+=6){var p=jn(f[0],f[1],d[g],d[g+1],d[g+2],d[g+3],d[g+4],d[g+5],n,r,i);if(f=[d[g+4],d[g+5]],o=p<=e/2)return!0}}}return o}(p,a+l,e.x,e.y,x)),C)}function Cb(t,e,n){var r=t.parsedStyle,i=r.stroke,o=r.fill,A=r.lineWidth,s=void 0===A?1:A,a=r.increasedLineWidthForHitTesting,c=void 0===a?0:a,l=r.points,u=r.pointerEvents,h=m(es(void 0===u?"auto":u,o,i),2),d=h[0],f=!1;return(h[1]||n)&&(f=mb(l.points,s+c,e.x,e.y,!0)),f||!d&&!n||(f=bb(l.points,e.x,e.y)),f}function Mb(t,e,n){var r=t.parsedStyle,i=r.lineWidth,o=void 0===i?1:i,A=r.increasedLineWidthForHitTesting,s=void 0===A?0:A,a=r.points,c=r.pointerEvents;return!(!m(es(void 0===c?"auto":c,r.fill,r.stroke),2)[1]&&!n||!o)&&mb(a.points,o+s,e.x,e.y,!1)}function Fb(t,e,n,r,i){var o=t.parsedStyle,A=o.radius,s=o.fill,a=o.stroke,c=o.lineWidth,l=void 0===c?1:c,u=o.increasedLineWidthForHitTesting,h=void 0===u?0:u,d=o.x,f=void 0===d?0:d,g=o.y,p=void 0===g?0:g,v=o.width,y=o.height,w=o.pointerEvents,b=m(es(void 0===w?"auto":w,s,a),2),B=b[0],E=b[1],x=A&&A.some(function(t){return 0!==t}),C=l+h;if(x){var M=!1;return(E||n)&&(M=function(t,e,n,r,i,o,A,s){var a=m(i,4),c=a[0],l=a[1],u=a[2],h=a[3];return vb(t+c,e,t+n-l,e,o,A,s)||vb(t+n,e+l,t+n,e+r-u,o,A,s)||vb(t+n-u,e+r,t+h,e+r,o,A,s)||vb(t,e+r-h,t,e+c,o,A,s)||pb(t+n-l,e+l,l,Math.PI,Math.PI,o,A,s)||pb(t+n-u,e+r-u,u,0,Math.PI,o,A,s)||pb(t+h,e+r-h,h,Math.PI,Math.PI,o,A,s)||pb(t+c,e+c,c,Math.PI,Math.PI,o,A,s)}(f,p,v,y,A.map(function(t){return ne(t,0,Math.min(Math.abs(v)/2,Math.abs(y)/2))}),C,e.x,e.y)),M||!B&&!n||(M=r(t,e)),M}var F=C/2;return B&&E||n?gb(f-F,p-F,v+F,y+F,e.x,e.y):B?gb(f,p,v,y,e.x,e.y):!!E&&function(t,e,n,r,i,o,A){var s=i/2;return gb(t-s,e-s,n,i,o,A)||gb(t+n-s,e-s,i,r,o,A)||gb(t+s,e+r-s,n,i,o,A)||gb(t-s,e+s,i,r,o,A)}(f,p,v,y,C,e.x,e.y)}function kb(t,e,n,r,i,A){var s=t.parsedStyle,a=s.pointerEvents,c=void 0===a?"auto":a,l=s.x,u=void 0===l?0:l,h=s.y,d=void 0===h?0:h,f=s.width,g=s.height;if("non-transparent-pixel"===c){var p=i.config.offscreenCanvas,v=A.offscreenCanvasCreator.getOrCreateCanvas(p),m=A.offscreenCanvasCreator.getOrCreateContext(p,{willReadFrequently:!0});return v.width=f,v.height=g,i.defaultStyleRendererFactory[cr.IMAGE].render(m,o(o({},t.parsedStyle),{},{x:0,y:0}),t,void 0,void 0,void 0),m.getImageData(e.x-u,e.y-d,1,1).data.every(function(t){return 0!==t})}return!0}function Sb(t,e,n,r){var i=t.getGeometryBounds();return e.x>=i.min[0]&&e.y>=i.min[1]&&e.x<=i.max[0]&&e.y<=i.max[1]}var Qb=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=g(this,e,[].concat(r))).name="canvas-picker",t}return v(e,t),a(e,[{key:"init",value:function(){var t,e=(r(r(r(r(r(r(r(r(r(r(t={},cr.CIRCLE,hb),cr.ELLIPSE,fb),cr.RECT,Fb),cr.LINE,Eb),cr.POLYLINE,Mb),cr.POLYGON,Cb),cr.PATH,xb),cr.TEXT,Sb),cr.GROUP,null),cr.IMAGE,kb),r(r(t,cr.HTML,null),cr.MESH,null));this.context.pointInPathPickerFactory=e,this.addRenderingPlugin(new ub)}},{key:"destroy",value:function(){delete this.context.pointInPathPickerFactory,this.removeAllRenderingPlugins()}}])}(ur);function Ub(t,e){var n=e.cx,r=void 0===n?0:n,i=e.cy,o=void 0===i?0:i,A=e.r;t.arc(r,o,A,0,2*Math.PI,!1)}function Nb(t,e){var n=e.cx,r=void 0===n?0:n,i=e.cy,o=void 0===i?0:i,A=e.rx,s=e.ry;if(t.ellipse)t.ellipse(r,o,A,s,0,0,2*Math.PI,!1);else{var a=A>s?A:s,c=A>s?1:A/s,l=A>s?s/A:1;t.save(),t.scale(c,l),t.arc(r,o,a,0,2*Math.PI)}}function Tb(t,e){var n,r,i=e.x1,o=e.y1,A=e.x2,s=e.y2,a=e.markerStart,c=e.markerEnd,l=e.markerStartOffset,u=e.markerEndOffset,h=0,d=0,f=0,g=0,p=0;a&&Ra(a)&&l&&(n=A-i,r=s-o,p=Math.atan2(r,n),h=Math.cos(p)*(l||0),d=Math.sin(p)*(l||0)),c&&Ra(c)&&u&&(n=i-A,r=o-s,p=Math.atan2(r,n),f=Math.cos(p)*(u||0),g=Math.sin(p)*(u||0)),t.moveTo(i+h,o+d),t.lineTo(A+f,s+g)}function Ob(t,e){var n,r,i=e.markerStart,o=e.markerEnd,A=e.markerStartOffset,s=e.markerEndOffset,a=e.d,c=a.absolutePath,l=a.segments,u=0,h=0,d=0,f=0,g=0;if(i&&Ra(i)&&A){var p=m(i.parentNode.getStartTangent(),2),v=p[0],y=p[1];n=v[0]-y[0],r=v[1]-y[1],g=Math.atan2(r,n),u=Math.cos(g)*(A||0),h=Math.sin(g)*(A||0)}if(o&&Ra(o)&&s){var w=m(o.parentNode.getEndTangent(),2),b=w[0],B=w[1];n=b[0]-B[0],r=b[1]-B[1],g=Math.atan2(r,n),d=Math.cos(g)*(s||0),f=Math.sin(g)*(s||0)}for(var E=0;E<c.length;E++){var x=c[E],C=x[0],M=c[E+1],F=0===E&&(0!==u||0!==h),k=(E===c.length-1||M&&("M"===M[0]||"Z"===M[0]))&&0!==d&&0!==f,S=m(F?[u,h]:[0,0],2),Q=S[0],U=S[1],N=m(k?[d,f]:[0,0],2),T=N[0],O=N[1];switch(C){case"M":t.moveTo(x[1]+Q,x[2]+U);break;case"L":t.lineTo(x[1]+T,x[2]+O);break;case"Q":t.quadraticCurveTo(x[1],x[2],x[3]+T,x[4]+O);break;case"C":t.bezierCurveTo(x[1],x[2],x[3],x[4],x[5]+T,x[6]+O);break;case"A":var I=l[E].arcParams,L=I.cx,P=I.cy,D=I.rx,R=I.ry,H=I.startAngle,_=I.endAngle,G=I.xRotation,K=I.sweepFlag;if(t.ellipse)t.ellipse(L,P,D,R,G,H,_,!!(1-K));else{var j=D>R?D:R,z=D>R?1:D/R,V=D>R?R/D:1;t.translate(L,P),t.rotate(G),t.scale(z,V),t.arc(0,0,j,H,_,!!(1-K)),t.scale(1/z,1/V),t.rotate(-G),t.translate(-L,-P)}k&&t.lineTo(x[6]+d,x[7]+f);break;case"Z":t.closePath()}}}function Ib(t,e){var n,r,i=e.markerStart,o=e.markerEnd,A=e.markerStartOffset,s=e.markerEndOffset,a=e.points.points,c=a.length,l=a[0][0],u=a[0][1],h=a[c-1][0],d=a[c-1][1],f=0,g=0,p=0,v=0,m=0;i&&Ra(i)&&A&&(n=a[1][0]-a[0][0],r=a[1][1]-a[0][1],m=Math.atan2(r,n),f=Math.cos(m)*(A||0),g=Math.sin(m)*(A||0)),o&&Ra(o)&&s&&(n=a[c-1][0]-a[0][0],r=a[c-1][1]-a[0][1],m=Math.atan2(r,n),p=Math.cos(m)*(s||0),v=Math.sin(m)*(s||0)),t.moveTo(l+(f||p),u+(g||v));for(var y=1;y<c-1;y++){var w=a[y];t.lineTo(w[0],w[1])}t.lineTo(h,d)}function Lb(t,e){var n,r,i=e.markerStart,o=e.markerEnd,A=e.markerStartOffset,s=e.markerEndOffset,a=e.points.points,c=a.length,l=a[0][0],u=a[0][1],h=a[c-1][0],d=a[c-1][1],f=0,g=0,p=0,v=0,m=0;i&&Ra(i)&&A&&(n=a[1][0]-a[0][0],r=a[1][1]-a[0][1],m=Math.atan2(r,n),f=Math.cos(m)*(A||0),g=Math.sin(m)*(A||0)),o&&Ra(o)&&s&&(n=a[c-2][0]-a[c-1][0],r=a[c-2][1]-a[c-1][1],m=Math.atan2(r,n),p=Math.cos(m)*(s||0),v=Math.sin(m)*(s||0)),t.moveTo(l+f,u+g);for(var y=1;y<c-1;y++){var w=a[y];t.lineTo(w[0],w[1])}t.lineTo(h+p,d+v)}function Pb(t,e){var n=e.x,r=void 0===n?0:n,i=e.y,o=void 0===i?0:i,A=e.radius,s=e.width,a=e.height,c=s,l=a,u=A&&A.some(function(t){return 0!==t});if(u){var h=s>0?1:-1,d=a>0?1:-1,f=h+d===0,g=A.map(function(t){return ne(t,0,Math.min(Math.abs(c)/2,Math.abs(l)/2))}),p=m(g,4),v=p[0],y=p[1],w=p[2],b=p[3];t.moveTo(h*v+r,o),t.lineTo(c-h*y+r,o),0!==y&&t.arc(c-h*y+r,d*y+o,y,-d*Math.PI/2,h>0?0:Math.PI,f),t.lineTo(c+r,l-d*w+o),0!==w&&t.arc(c-h*w+r,l-d*w+o,w,h>0?0:Math.PI,d>0?Math.PI/2:1.5*Math.PI,f),t.lineTo(h*b+r,l+o),0!==b&&t.arc(h*b+r,l-d*b+o,b,d>0?Math.PI/2:-Math.PI/2,h>0?Math.PI:0,f),t.lineTo(r,d*v+o),0!==v&&t.arc(h*v+r,d*v+o,v,h>0?Math.PI:0,d>0?1.5*Math.PI:Math.PI/2,f)}else t.rect(r,o,c,l)}var Db=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=g(this,e,[].concat(r))).name="canvas-path-generator",t}return v(e,t),a(e,[{key:"init",value:function(){var t,e=(r(r(r(r(r(r(r(r(r(r(t={},cr.CIRCLE,Ub),cr.ELLIPSE,Nb),cr.RECT,Pb),cr.LINE,Tb),cr.POLYLINE,Lb),cr.POLYGON,Ib),cr.PATH,Ob),cr.TEXT,void 0),cr.GROUP,void 0),cr.IMAGE,void 0),r(r(r(t,cr.HTML,void 0),cr.MESH,void 0),cr.FRAGMENT,void 0));this.context.pathGeneratorFactory=e}},{key:"destroy",value:function(){delete this.context.pathGeneratorFactory}}])}(ur),Rb=function(){return a(function t(e){A(this,t),this.renderingContext=e.renderingContext,this.canvasConfig=e.config},[{key:"init",value:function(){var t=this.canvasConfig,e=t.container,n=t.canvas;if(n)this.$canvas=n,e&&n.parentElement!==e&&e.appendChild(n),this.$container=n.parentElement,this.canvasConfig.container=this.$container;else if(e&&(this.$container=Jt(e)?document.getElementById(e):e,this.$container)){var r=document.createElement("canvas");this.$container.appendChild(r),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=r}this.context=this.$canvas.getContext("2d"),this.resize(this.canvasConfig.width,this.canvasConfig.height)}},{key:"getContext",value:function(){return this.context}},{key:"getDomElement",value:function(){return this.$canvas}},{key:"getDPR",value:function(){return this.dpr}},{key:"getBoundingClientRect",value:function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()}},{key:"destroy",value:function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)}},{key:"resize",value:function(t,e){var n=this.canvasConfig.devicePixelRatio;this.dpr=n,this.$canvas&&(this.$canvas.width=this.dpr*t,this.$canvas.height=this.dpr*e,function(t,e,n){WA&&t.style&&(t.style.width=e+"px",t.style.height=n+"px")}(this.$canvas,t,e)),this.renderingContext.renderReasons.add($s.CAMERA_CHANGED)}},{key:"applyCursorStyle",value:function(t){this.$container&&this.$container.style&&(this.$container.style.cursor=t)}},{key:"toDataURL",value:(t=Ar(ir().mark(function t(){var e,n,r,i=arguments;return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=(e=i.length>0&&void 0!==i[0]?i[0]:{}).type,r=e.encoderOptions,t.abrupt("return",this.context.canvas.toDataURL(n,r));case 1:case"end":return t.stop()}},t,this)})),function(){return t.apply(this,arguments)})}]);var t}(),Hb=function(t){function e(){var t;A(this,e);for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=g(this,e,[].concat(r))).name="canvas-context-register",t}return v(e,t),a(e,[{key:"init",value:function(){this.context.ContextService=Rb}},{key:"destroy",value:function(){delete this.context.ContextService}}])}(ur),_b=function(t){function e(t){var n;return A(this,e),(n=g(this,e,[t])).registerPlugin(new Hb),n.registerPlugin(new Oc.Plugin),n.registerPlugin(new Db),n.registerPlugin(new Ab),n.registerPlugin(new Hc.Plugin),n.registerPlugin(new Qb),n.registerPlugin(new Pc.Plugin),n}return v(e,t),a(e)}(hr);class Gb extends Nw{constructor(t){super(Object.assign(Object.assign({},t),{style:Object.assign({},Gb.defaultStyleProps,t.style)})),this.rootPointerEvent=new js(null),this.forwardEvents=t=>{const e=this.context.canvas,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach(r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);Me(e.context.eventService,"mappingTable.pointerupoutside",[]),e.context.eventService.mapEvent(i)})}}get eventService(){return this.context.canvas.context.eventService}get events(){return[t.CommonEvent.CLICK,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_UP,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE]}getDomElement(){return this.getShape("key").getDomElement()}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.drawPortShapes(t,e)}getKeyStyle(t){const e=ke(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Pe(e,["dx","dy"]),[o,A]=this.getSize(t);return Object.assign(Object.assign({x:n,y:r},i),{width:o,height:A})}drawKeyShape(t,e){const n=this.getKeyStyle(t),{x:r,y:i,width:o=0,height:A=0}=n,s=this.upsert("key-container",sc,{x:r,y:i,width:o,height:A,opacity:0},e);return this.upsert("key",$a,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof _b))return;const t=this.getDomElement();this.events.forEach(e=>{t.addEventListener(e,this.forwardEvents)})}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}destroy(){const t=this.getDomElement();this.events.forEach(e=>{t.removeEventListener(e,this.forwardEvents)}),super.destroy()}normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;e<t.changedTouches.length;e++){const r=t.changedTouches[e];de(r.button)&&(r.button=0),de(r.buttons)&&(r.buttons=1),de(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),de(r.width)&&(r.width=r.radiusX||1),de(r.height)&&(r.height=r.radiusY||1),de(r.tiltX)&&(r.tiltX=0),de(r.tiltY)&&(r.tiltY=0),de(r.pointerType)&&(r.pointerType="touch"),de(r.pointerId)&&(r.pointerId=r.identifier||0),de(r.pressure)&&(r.pressure=r.force||.5),de(r.twist)&&(r.twist=0),de(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;de(e.isPrimary)&&(e.isPrimary=!0),de(e.width)&&(e.width=1),de(e.height)&&(e.height=1),de(e.tiltX)&&(e.tiltX=0),de(e.tiltY)&&(e.tiltY=0),de(e.pointerType)&&(e.pointerType="mouse"),de(e.pointerId)&&(e.pointerId=1),de(e.pressure)&&(e.pressure=.5),de(e.twist)&&(e.twist=0),de(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}bootstrapEvent(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const[A,s]=this.context.canvas.getCanvasByViewport([i,o]);return t.canvas.x=A,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:A}=t;if(Kt(r)||Kt(i)){const t=this.eventService.client2Viewport({x:o,y:A});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}onframe(){super.onframe();const{opacity:t}=this.attributes;this.getDomElement().style.opacity=`${t}`}}Gb.defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};let Kb=class t extends Nw{constructor(e){super(uw({style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),r=super.getKeyStyle(t),{fillOpacity:i,opacity:o=i}=r,A=Pe(r,["fillOpacity","opacity"]);return Object.assign(Object.assign({opacity:o},A),{width:e,height:n,x:-e/2,y:-n/2})}getBounds(){return this.getShape("key").getBounds()}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getShape("key").attributes,{fill:n,stroke:r}=e;Pe(e,["fill","stroke"]);const i=Aw(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[A,s]=ay(yy(this.getSize(t)),[o,o]),{lineWidth:a}=i,c={fill:"transparent",lineWidth:a/2,width:A-a/2,height:s-a/2,x:-(A-a/2)/2,y:-(s-a/2)/2};return Object.assign(Object.assign({},i),c)}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&Object.assign({width:n*qy,height:r*qy},e)}drawKeyShape(t,e){const n=this.upsert("key",Cw,this.getKeyStyle(t),e);return kw(this),n}drawHaloShape(t,e){this.upsert("halo",sc,this.getHaloStyle(t),e)}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Sw(this)}};Kb.defaultStyleProps={size:32};class jb extends Nw{constructor(t){super(t)}getKeyStyle(t){const[e,n]=this.getSize(t);return Object.assign(Object.assign({},super.getKeyStyle(t)),{width:e,height:n,x:-e/2,y:-n/2})}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getShape("key").attributes;return!!e&&Object.assign({width:n*qy,height:r*qy},e)}drawKeyShape(t,e){return this.upsert("key",sc,this.getKeyStyle(t),e)}}class zb extends Ow{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*qy;return!!e&&Object.assign({width:n,height:n},e)}getPortXY(t,e){const{placement:n="top"}=e,r=this.getShape("key").getLocalBounds(),i=function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t));return jB(r,n,i,!1)}}class Vb extends Ow{constructor(t){super(uw({style:Vb.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getShape("key").getLocalBounds(),[o,A]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,A,n);return jB(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||Ee(n||r))return!1;const o=Aw(this.getGraphicStyle(t),"icon"),A=this.getShape("key").getLocalBounds(),[s,a]=function(t,e){const{center:n}=t,[r,i]=wm(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(A,i),c=2*function(t,e){let[n,r]=wm(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(Math.pow(r,2)-Math.pow(Math.sqrt(Math.pow(n/2,2)+Math.pow(r,2))-n/2,2))/(2*r)}(A,i)*qy;return Object.assign({x:s,y:a,width:c,height:c},o)}}Vb.defaultStyleProps={size:40,direction:"up"};class Wb extends Nw{constructor(t){super(uw({style:Wb.defaultStyleProps},t)),this.type="combo",this.updateComboPosition(this.parsedAttributes)}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,A]=pm(e);return ay(cw(n),[A+i,r+o,0])}getCollapsedKeySize(t){return cw(t.collapsedSize)}getExpandedKeySize(t){const e=this.getContentBBox(t);return[mm(e),ym(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=e.map(t=>this.context.element.getElement(t)).filter(Boolean);if(0===r.length){const e=new yr,{x:n=0,y:r=0,size:i}=t,[o,A]=cw(i);return e.setMinMax([n-o/2,r-A/2,0],[n+o/2,r+A/2,0]),e}const i=xm(r.map(t=>t.getBounds()));return n?Em(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",Qw,n,e),kw(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Aw(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Pe(e,["type"]),i=this.getShape("key"),[o,A]=ky(i.getLocalBounds(),"center"),s=Object.assign(Object.assign({},r),{x:o,y:A});if(n){const e=this.getCollapsedMarkerText(n,t);Object.assign(s,{text:e})}return s}getCollapsedMarkerText(t,e){const{childrenData:n=[]}=e,{model:r}=this.context;return"descendant-count"===t?r.getDescendantsData(this.id).length.toString():"child-count"===t?n.length.toString():"node-count"===t?r.getDescendantsData(this.id).filter(t=>"node"===r.getElementType(Km(t))).length.toString():Gt(t)?t(n):""}getComboPosition(t){const{x:e=0,y:n=0,collapsed:r,childrenData:i=[]}=t;if(0===i.length)return[+e,+n,0];if(r){const{model:t}=this.context,r=t.getDescendantsData(this.id).filter(e=>!t.isCombo(Km(e)));if(r.length>0&&r.some(Fy)){return uy(r.reduce((t,e)=>ay(t,My(e)),[0,0,0]),r.length)}return[+e,+n,0]}return this.getContentBBox(t).center}getComboStyle(t){const[e,n]=this.getComboPosition(t);return{x:e,y:n,transform:[["translate",e,n]]}}updateComboPosition(t){const e=this.getComboStyle(t);Object.assign(this.style,e);const{x:n,y:r}=e;this.context.model.syncNodeLikeDatum({id:this.id,style:{x:n,y:r}}),Sw(this)}render(t,e=this){super.render(t,e),this.drawCollapsedMarkerShape(t,e)}update(t={}){super.update(t),this.updateComboPosition(this.parsedAttributes)}onframe(){super.onframe(),this.attributes.collapsed||this.updateComboPosition(this.parsedAttributes),this.drawKeyShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(this.attributes.collapsed?t:t.map(t=>{var{x:e,y:n,z:r,transform:i}=t;return Pe(t,["x","y","z","transform"])}),e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then(()=>this.onframe()),Reflect.set(t,e,n))}):n}}Wb.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Yb extends Wb{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",za,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),[r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},n),e&&Aw(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=cw(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=wm(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return Dy(t,this.getShape("key").getBounds(),e)}}class Xb extends Wb{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",sc,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},e),t.collapsed&&Aw(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const qb={padding:10};function $b(t,e,n,r,i,o){const{padding:A}=Object.assign(qb,o),s=bm(n,A),a=bm(r,A),c=[t,...i,e];let l=null;const u=[];for(let t=0,e=c.length;t<e-1;t++){const n=t+1,r=c[t],i=c[n],o=Oy(r,i);let h=null;if(0===t)if(n===e-1)if(s.intersects(a))h=AB(r,i,s,a);else if(Fm(r,s)||Fm(i,a))o||(h=oB(r,i,s,a));else{const t=Sm(r,s),e=Sm(i,a);h=nB(t,e,tB(t,e)),h.points.unshift(t),h.points.push(e)}else Cm(i,s)?h=AB(r,i,s,bm(i,A),l):o||(h=rB(r,i,s));else n===e-1?Cm(r,a)?h=AB(r,i,bm(r,A),a,l):o||(h=iB(r,i,a,l)):o||(h=nB(r,i,l));h?(u.push(...h.points),l=h.direction):l=tB(r,i),n<e-1&&u.push(i)}return u.map(yy)}const Zb={N:"S",S:"N",W:"E",E:"W"},Jb={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function tB(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function eB(t,e){return"N"===e||"S"===e?ym(t):mm(t)}function nB(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=tB(t,r),A=tB(t,i),s=n?Zb[n]:null,a=o===n||o!==s&&A!==n?r:i;return{points:[a],direction:tB(a,e)}}function rB(t,e,n){if(Fm(t,n)){const r=sB(t,e,n);return{points:[r],direction:tB(r,e)}}{const r=Sm(t,n),i=["left","right"].includes(km(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:tB(i,e)}}}function iB(t,e,n,r){const i=Fm(e,n)?e:Sm(e,n),o=[[i[0],t[1]],[t[0],i[1]]],A=o.filter(t=>function(t,e){return!Cm(t,e)}(t,n)&&!Mm(t,n,!0)),s=A.filter(e=>tB(e,t)!==r);if(s.length>0){const n=s.find(e=>tB(t,e)===r)||s[0];return{points:[n],direction:tB(n,e)}}{const i=Ny(e,_t(o,A)[0],eB(n,r)/2);return{points:[sB(i,t,n),i],direction:tB(i,e)}}}function oB(t,e,n,r){let i=rB(t,e,n);const o=wy(i.points[0]);if(Cm(o,r)){i=rB(e,t,r);const A=wy(i.points[0]);if(Cm(A,n)){const s=Ny(t,o,eB(n,tB(t,o))/2),a=Ny(e,A,eB(r,tB(e,A))/2),c=[(s[0]+a[0])/2,(s[1]+a[1])/2],l=rB(t,c,n),u=iB(c,e,r,l.direction);i.points=[l.points[0],u.points[0]],i.direction=u.direction}}return i}function AB(t,e,n,r,i){const o=.01,A=xm([n,r]),s=dy(e,A.center)>dy(t,A.center),[a,c]=s?[e,t]:[t,e],l=ym(A)+mm(A);let u;if(i){const t=[a[0]+l*Math.cos(Jb[i]),a[1]+l*Math.sin(Jb[i])];u=Ny(Sm(t,A),t,o)}else u=Ny(Sm(a,A),a,-.01);let h=sB(u,c,A),d=[Uy(u,2),Uy(h,2)];if(xe(Uy(u),Uy(h))){const t=py(cy(u,a),[1,0,0])+Math.PI/2;h=[c[0]+l*Math.cos(t),c[1]+l*Math.sin(t),0],h=Uy(Ny(Sm(h,A),c,-.01),2);d=[u,sB(u,h,A),h]}return{points:s?d.reverse():d,direction:tB(s?u:h,e)}}function sB(t,e,n){let r=[t[0],e[1]];return Cm(r,n)&&(r=[e[0],t[1]]),r}const aB={top:0,bottom:0,left:Math.PI/2,right:Math.PI/2,"top-right":Math.PI/4,"right-top":Math.PI/4,"bottom-left":Math.PI/4,"left-bottom":Math.PI/4,"right-bottom":-Math.PI/4,"bottom-right":-Math.PI/4,"left-top":-Math.PI/4,"top-left":-Math.PI/4};function cB(t,e,n,r,i,o,A){var s;let a="number"==typeof e?e:.5;if("start"===e&&(a=0),"end"===e&&(a=.99),o&&A){a=.5,r=0,i=0;let e=null!==(s=aB[A])&&void 0!==s?s:0;Math.cos(e)<-1e-6&&(e+=Math.PI);const o=n&&0!==e,[c,l]=lB(t,a,r,i,o?e:void 0),u=[["translate",c,l]];return o&&u.push(["rotate",e/Math.PI*180]),{textAlign:"center",transform:u}}const c=Sy(t.getPoint(a)),l=Sy(t.getPoint(a+.01));let u="start"===e?"left":"end"===e?"right":"center";if(Ty(c,l)||!n){const[e,n]=lB(t,a,r,i);return{transform:[["translate",e,n]],textAlign:u}}let h=Math.atan2(l[1]-c[1],l[0]-c[0]);l[0]<c[0]&&(u="center"===u?u:"left"===u?"right":"left",r*=-1,h+=Math.PI);const[d,f]=lB(t,a,r,i,h);return{textAlign:u,transform:[["translate",d,f],["rotate",h/Math.PI*180]]}}function lB(t,e,n,r,i){const[o,A]=Sy(t.getPoint(e));let s=n,a=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),a=n*Math.sin(i)+r*Math.cos(i)),[o+s,A+a]}function uB(t,e,n,r){if(xe(t,e))return t;const i=cy(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],A=gy(vy(i,!1));return o[0]+=r*A[0],o[1]+=r*A[1],o}function hB(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function dB(t,e=0,n=!1){const r=t.length-1,i=t[0],o=t[r],A=t.slice(1,r),s=[["M",i[0],i[1]]];return A.forEach((t,n)=>{const r=A[n-1]||i,a=A[n+1]||o;if(!Iy(r,t,a)&&e){const[n,i]=function(t,e,n,r){const i=fy(t,e),o=fy(n,e),A=Math.min(r,Math.min(i,o)/2),s=[e[0]-A/i*(e[0]-t[0]),e[1]-A/i*(e[1]-t[1])],a=[e[0]-A/o*(e[0]-n[0]),e[1]-A/o*(e[1]-n[1])];return[s,a]}(r,t,a,e);s.push(["L",n[0],n[1]],["Q",t[0],t[1],i[0],i[1]],["L",i[0],i[1]])}else s.push(["L",t[0],t[1]])}),s.push(["L",o[0],o[1]]),n&&s.push(["Z"]),s}function fB(t,e,n,r,i){const o=bm(t),A=t.getCenter();let s=r&&WB(r),a=i&&WB(i);if(!s||!a){const r=(t=>{const e=Math.PI/2,n=ym(t)/2,r=mm(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}})(o),i=r[e][0],c=r[e][1],[l,u]=wm(o),h=Math.max(l,u),d=ay(A,[h*Math.cos(i),h*Math.sin(i),0]),f=ay(A,[h*Math.cos(c),h*Math.sin(c),0]);s=$B(t,d),a=$B(t,f),n||([s,a]=[a,s])}return[s,a]}function gB(t,e,n,r){const i=t.getCenter();if(xe(e,n)){const t=cy(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[ay(e,o),ay(n,ly(o,[1,-1,1]))]}return[Ny(i,e,dy(i,e)+r),Ny(i,n,dy(i,n)+r)]}function pB(t,e,n,r,i,o,A){const s=zB(t),a=s[o||A],c=s[A||o];let[l,u]=fB(t,n,r,a,c);const h=function(t,e,n,r){const i=[],o=bm(t);if(xe(e,n)){switch(km(e,o)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=km(e,o),A=km(n,o);if(t===A){let o,A;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":A=Math.min(e[1],n[1])-r,i.push([e[0],A]),i.push([n[0],A]);break;case"bottom":A=Math.max(e[1],n[1])+r,i.push([e[0],A]),i.push([n[0],A])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),a=s(t,e),c=s(A,n),l=sB(a,c,o);i.push(a,l,c)}}return i}(t,l,u,i);return a&&(l=qB(a,h[0])),c&&(u=qB(c,h.at(-1))),dB([l,...h,u],e)}function vB(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach(o=>{e(o).forEach(e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)})}),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}function mB(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(Km(r));if(!t)break;r=t}if(n.some(t=>{var e;return null===(e=t.style)||void 0===e?void 0:e.collapsed})){const t=n.reverse().findIndex(rw);return n[t]||n.at(-1)}return t}const yB=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var wB=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",-t/2,0],["A",n,n,0,1,0,2*n-t/2,0],["A",n,n,0,1,0,-t/2,0],["Z"]]},diamond:(t,e)=>[["M",-t/2,0],["L",0,-e/2],["L",t/2,0],["L",0,e/2],["Z"]],rect:(t,e)=>[["M",-t/2,-e/2],["L",t/2,-e/2],["L",t/2,e/2],["L",-t/2,e/2],["Z"]],simple:(t,e)=>[["M",t/2,-e/2],["L",-t/2,0],["L",t/2,0],["L",-t/2,0],["L",t/2,e/2]],triangle:yB,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",-n,0],["L",0,-e/2],["L",0,e/2],["Z"],["M",i-n,-e/2],["L",i+r-n,-e/2],["L",i+r-n,e/2],["L",i-n,e/2],["Z"]]},vee:(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",4*t/5-t/2,0],["L",t/2,e/2],["Z"]]});class bB extends Uw{constructor(t){super(uw({style:bB.defaultStyleProps},t)),this.type="edge"}get sourceNode(){const{sourceNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}get targetNode(){const{targetNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}getKeyStyle(t){const e=this.getGraphicStyle(t),{loop:n}=e,r=Pe(e,["loop"]),{sourceNode:i,targetNode:o}=this,A={d:n&&GB(i,o)?this.getLoopPath(t):this.getKeyPath(t)};return nc.PARSED_STYLE_LIST.forEach(t=>{t in r&&(A[t]=r[t])}),A}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=bm(r),o=Math.max(mm(i),ym(i)),{type:A,placement:s,clockwise:a,dist:c=o}=Aw(this.getGraphicStyle(t),"loop");return"arc"===A?function(t,e,n,r,i,o){const A=t.getPorts()[i||o],s=t.getPorts()[o||i];let[a,c]=fB(t,e,n,A,s);if(xe(a,c)){const e=gB(t,a,c,r);return A&&(a=qB(A,e[0])),s&&(c=qB(s,e.at(-1))),hB(a,c,e)}const l=t.getCenter(),u=[(a[0]+c[0])/2,(a[1]+c[1])/2,0],h=dy(l,u)>1e-6?gy(cy(u,l)):[0,-1,0],d=dy(a,c),f=Math.max(Math.abs(r),.01),g=(d*d+4*f*f)/(8*f),p=[u[0]+h[0]*f,u[1]+h[1]*f,0],v=[u[0]+h[0]*(f-g),u[1]+h[1]*(f-g),0],m=2*Math.PI,y=Math.atan2(a[1]-v[1],a[0]-v[0]),w=((Math.atan2(c[1]-v[1],c[0]-v[0])-y)%m+m)%m,b=((Math.atan2(p[1]-v[1],p[0]-v[0])-y)%m+m)%m<=w+1e-6,B=b?1:0,E=(b?w:m-w)>Math.PI?1:0;if(A){const t=[a[0]-v[0],a[1]-v[1],0];a=qB(A,ay(a,1===B?[-t[1],t[0],0]:[t[1],-t[0],0]))}if(s){const t=[c[0]-v[0],c[1]-v[1],0];c=qB(s,ay(c,1===B?[t[1],-t[0],0]:[-t[1],t[0],0]))}return[["M",a[0],a[1]],["A",g,g,0,E,B,c[0],c[1]]]}(r,s,a,c,e,n):function(t,e,n,r,i,o){const A=t.getPorts()[i||o],s=t.getPorts()[o||i];let[a,c]=fB(t,e,n,A,s);const l=gB(t,a,c,r);return A&&(a=qB(A,l[0])),s&&(c=qB(s,l.at(-1))),hB(a,c,l)}(r,s,a,c,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:A}=this,[s,a]=function(t,e,n,r){const i=YB(t,e,n,r),o=YB(e,t,r,n);return[i,o]}(o,A,r,i);if(!e){return[s?WB(s):o.getCenter(),a?WB(a):A.getCenter()]}const c="function"==typeof n?n():n;return[XB(s||o,c[0]||a||A),XB(a||A,c[c.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Aw(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Aw(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:A}=e,s=Pe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),a=t.loop&&GB(this.sourceNode,this.targetNode),{placement:c}=Aw(this.getGraphicStyle(t),"loop"),l=cB(this.shapeMap.key,n,o,r,i,a,c),u=this.shapeMap.key.getLocalBounds(),h=function(t,e,n=1){return fw(dy(t[0],t[1])*n,e)}([u.min,u.max],A);return Object.assign({wordWrapWidth:h},l,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Aw(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Pe(e,["offsetX","offsetY","placement"]);return Object.assign(o,function(t,e,n,r,i){var o,A;const s=2*(null===(o=t.badge)||void 0===o?void 0:o.getGeometryBounds().halfExtents[0])||0,a=2*(null===(A=t.label)||void 0===A?void 0:A.getGeometryBounds().halfExtents[0])||0;return cB(t.key,n,!0,(a?(a/2+s/2)*("suffix"===e?1:-1):0)+r,i)}(this.shapeMap,i,t.labelPlacement,n,r))}drawArrow(t,e){var n;const r="start"===e,i=t["start"===e?"startArrow":"endArrow"],o=this.shapeMap.key;if(i){const e=this.getArrowStyle(t,r),[n,i,A]=r?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],s=o.parsedStyle[n];if(s)s.attr(e);else{const t=new(e.src?Za:nc)({style:e});o.style[n]=t}o.style[i]=t[A]||e.width/2+ +e.lineWidth}else{const t=r?"markerStart":"markerEnd";null===(n=o.style[t])||void 0===n||n.destroy(),o.style[t]=null}}getArrowStyle(t,e){const n=this.getShape("key").attributes,r=e?"startArrow":"endArrow",i=Aw(this.getGraphicStyle(t),r),{size:o,type:A}=i,s=Pe(i,["size","type"]),[a,c]=cw(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),l=(Gt(A)?A:wB[A]||yB)(a,c);return Object.assign(ke(n,["stroke","strokeOpacity","fillOpacity"]),{width:a,height:c},Object.assign({},l&&{d:l,fill:"simple"===A?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",yw,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",nc,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",ww,n,e)}drawSourceArrow(t){this.drawArrow(t,"start")}drawTargetArrow(t){this.drawArrow(t,"end")}drawKeyShape(t,e){const n=this.getKeyStyle(t);return this.upsert("key",nc,n,e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.getShape("key")&&(this.drawSourceArrow(t),this.drawTargetArrow(t),this.drawLabelShape(t,e),this.drawHaloShape(t,e),this.drawBadgeShape(t,e))}onframe(){this.drawKeyShape(this.parsedAttributes,this),this.drawSourceArrow(this.parsedAttributes),this.drawTargetArrow(this.parsedAttributes),this.drawHaloShape(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this),this.drawBadgeShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(t,e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then(()=>this.onframe()),Reflect.set(t,e,n))}):n}}bB.defaultStyleProps={badge:!0,badgeOffsetX:0,badgeOffsetY:0,badgePlacement:"suffix",isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,loop:!0,startArrow:!1,startArrowLineDash:0,startArrowLineJoin:"round",startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"vee",endArrow:!1,endArrowLineDash:0,endArrowLineJoin:"round",endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"vee",loopPlacement:"top",loopClockwise:!0};class BB extends bB{constructor(t){super(uw({style:BB.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,A=this.getControlPoints(e,n,function(t){return re(t)?[t,1-t]:t}(i),function(t){return re(t)?[t,-t]:t}(o),r);return hB(e,n,A)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[uB(t,e,n[0],r[0]),uB(t,e,n[1],r[1])]}}BB.defaultStyleProps={curvePosition:.5,curveOffset:20};class EB extends BB{constructor(t){super(uw({style:EB.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}EB.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class xB extends BB{constructor(t){super(uw({style:xB.defaultStyleProps},t))}get ref(){return this.context.model.getRootsData()[0]}getEndpoints(t){if(this.sourceNode.id===this.ref.id)return super.getEndpoints(t);const e=My(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=My(this.ref);return[dy(t,e),by(cy(t,e))]}getControlPoints(t,e,n,r){const[i,o]=this.toRadialCoordinate(t),[A]=this.toRadialCoordinate(e),s=A-i;return[[t[0]+(s*n[0]+r[0])*Math.cos(o),t[1]+(s*n[0]+r[0])*Math.sin(o)],[e[0]-(s*n[1]-r[0])*Math.cos(o),e[1]-(s*n[1]-r[0])*Math.sin(o)]]}}xB.defaultStyleProps={curvePosition:.5,curveOffset:20};class CB extends BB{constructor(t){super(uw({style:CB.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}CB.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let MB=class t extends bB{constructor(e){super(uw({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};MB.defaultStyleProps={};const FB={enableObstacleAvoidance:!1,offset:10,maxAllowedDirectionChange:Math.PI/2,maximumLoops:3e3,gridSize:5,startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{right:{stepX:1,stepY:0},left:{stepX:-1,stepY:0},bottom:{stepX:0,stepY:1},top:{stepX:0,stepY:-1}},penalties:{0:0,90:0},distFunc:fy},kB=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function SB(t,e){const n=t=>Math.round(t/e);return re(t)?n(t):t.map(n)}function QB(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function UB(t,e,n,r){const i=QB(t,e),o=n[kB(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(QB(o||r,t),i)}function NB(t,e,n){return Math.min(...e.map(e=>n(t,e)))}const TB=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,A=Em(e.getRenderBounds(),o),s=Object.keys(i).reduce((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=wm(A),a=[t[0]+n.stepX*o,t[1]+n.stepY*s],c=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],A=[r,i],s=[r,n],a=[e,n];return[[o,A],[A,s],[s,a],[a,o]]}(A);for(let n=0;n<c.length;n++){const r=xy([t,a],c[n]);r&&Mm(r,A)&&e.push(r)}}return e},[]);return Cm(t,A)||s.push(t),s.map(t=>SB(t,r.gridSize))},OB=(t,e,n,r,i,o,A)=>{const s=[];let a=[o[0]===r[0]?r[0]:t[0]*A,o[1]===r[1]?r[1]:t[1]*A];s.unshift(a);let c=t,l=e[kB(c)];for(;l;){const t=l,r=c;UB(t,r,e,n)&&(a=[t[0]===r[0]?a[0]:t[0]*A,t[1]===r[1]?a[1]:t[1]*A],s.unshift(a)),l=e[kB(t)],c=t}const u=i.map(t=>[t[0]*A,t[1]*A]),h=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o<t.length;o++){const A=t[o],s=n(A,e);s<i&&(r=A,i=s)}return r}(u,a,fy);return s.unshift(h),s};function IB(t,e,n,r){const i=yy(t.getCenter()),o=yy(e.getCenter()),A=Object.assign(FB,r),{gridSize:s}=A,a=((t,e)=>{const{offset:n,gridSize:r}=e,i={};return t.forEach(t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Em(t.getRenderBounds(),n);for(let t=SB(e.min[0],r);t<=SB(e.max[0],r);t+=1)for(let n=SB(e.min[1],r);n<=SB(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0}),i})(A.enableObstacleAvoidance?n:[t,e],A),c=SB(i,s),l=SB(o,s),u=TB(i,t,A.startDirections,A),h=TB(o,e,A.endDirections,A);u.forEach(t=>delete a[kB(t)]),h.forEach(t=>delete a[kB(t)]);const d={},f={},g={},p={},v={},m=new LB;for(let t=0;t<u.length;t++){const e=u[t],n=kB(e);d[n]=e,p[n]=0,v[n]=NB(e,h,A.distFunc),m.add({id:n,value:v[n]})}const y=h.map(t=>kB(t));let w,b=A.maximumLoops,B=1/0;for(const[t,e]of Object.entries(d))v[t]<=B&&(B=v[t],w=e);for(;Object.keys(d).length>0&&b>0;){const t=m.minId(!1);if(!t)break;w=d[t];const e=kB(w);if(y.includes(e))return OB(w,g,c,o,u,l,s);delete d[e],m.remove(e),f[e]=!0;for(const t of Object.values(A.directionMap)){const n=ay(w,[t.stepX,t.stepY]),r=kB(n);if(f[r])continue;const i=UB(w,n,g,c);if(i>A.maxAllowedDirectionChange)continue;if(a[r])continue;d[r]||(d[r]=n);const o=A.penalties[i],l=A.distFunc(w,n)+(isNaN(o)?s:o),u=p[e]+l,y=p[r];y&&u>=y||(g[r]=w,p[r]=u,v[r]=u+NB(n,h,A.distFunc),m.add({id:r,value:v[r]}))}b-=1}return[]}class LB{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){let n=0,r=e-1;for(;r-n>1;){const e=Math.floor((n+r)/2);if(this.arr[e].value>t.value)r=e;else{if(!(this.arr[e].value<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n=e}}this.arr.splice(r,0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;if(!e||this.arr[e-1].value<t.value)return this.arr.push(t),void(this.map[t.id]=!0);this._innerAdd(t,e)}remove(t){this.map[t]&&delete this.map[t]}_clearAndGetMinId(){let t;for(let e=this.arr.length-1;e>=0;e--)this.map[this.arr[e].id]?t=this.arr[e].id:this.arr.splice(e,1);return t}_findFirstId(){for(;this.arr.length;){const t=this.arr.shift();if(this.map[t.id])return t.id}}minId(t){return t?this._clearAndGetMinId():this._findFirstId()}}class PB extends bB{constructor(t){super(uw({style:PB.defaultStyleProps},t))}getControlPoints(t){const{router:e}=t,{sourceNode:n,targetNode:r}=this,[i,o]=this.getEndpoints(t,!1);let A=[];if(e)if("shortest-path"===e.type){A=IB(n,r,this.context.element.getNodes(),e),A.length||(A=$b(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(A=$b(i,o,n,r,t.controlPoints,e));else A=t.controlPoints;return A}getPoints(t){const e=this.getControlPoints(t),[n,r]=this.getEndpoints(t,!0,e);return[n,...e,r]}getKeyPath(t){return dB(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=bm(i),A=Math.max(mm(o),ym(o))/4,{placement:s,clockwise:a,dist:c=A}=Aw(this.getGraphicStyle(t),"loop");return pB(i,r,s,a,c,e,n)}}PB.defaultStyleProps={radius:0,controlPoints:[],router:!1};class DB extends bB{constructor(t){super(uw({style:DB.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||uB(r,i,e,n))}}function RB(t){return t instanceof Nw&&"node"===t.type}function HB(t){return t instanceof bB}function _B(t){return t instanceof Wb}function GB(t,e){return!(!t||!e)&&t===e}DB.defaultStyleProps={curvePosition:.5,curveOffset:30};const KB={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],"left-top":[0,0],"top-left":[0,0],"left-bottom":[0,1],"bottom-left":[0,1],"right-top":[1,0],"top-right":[1,0],"right-bottom":[1,1],"bottom-right":[1,1],default:[.5,.5]};function jB(t,e,n=KB,r=!0){const i=[.5,.5],o=Jt(e)?Ce(n,e.toLocaleLowerCase(),i):e;if(!r&&Jt(e))return o;const[A,s]=o||i;return[t.min[0]+mm(t)*A,t.min[1]+ym(t)*s]}function zB(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach((n,r)=>{var i;const{key:o,placement:A}=n;VB(n)&&(e[i=o||r]||(e[i]=ky(t.getShape("key").getBounds(),A)))}),e}function VB(t){const{r:e}=t;return!e||0===Number(e)}function WB(t){return fm(t)?t:t.getPosition()}function YB(t,e,n,r){const i=zB(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const A=o.map(t=>WB(t)),s=function(t,e){const n=zB(t);if(e)return[WB(n[e])];const r=Object.values(n);return r.length>0?r.map(t=>WB(t)):[t.getCenter()]}(e,r),[a]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach(t=>{e.forEach(e=>{const i=dy(t,e);i<n&&(n=i,r=[t,e])})}),r}(A,s);return o.find(t=>WB(t)===a)}function XB(t,e){return _B(t)||RB(t)?$B(t,e):qB(t,e)}function qB(t,e){if(!t||!e)return[0,0,0];if(fm(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return Dy(fm(e)?e:RB(e)?e.getCenter():e.getPosition(),t.getBounds())}function $B(t,e){if(!t||!e)return[0,0,0];const n=fm(e)?e:RB(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function ZB(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[A,s]=ky(t,e),[a,c]=i?["bottom","top"]:["top","bottom"];return{transform:[["translate",A+n,s+r]],textBaseline:o.includes("top")?c:o.includes("bottom")?a:"middle",textAlign:o.includes("left")?"right":o.includes("right")?"left":"center"}}function JB(t){return"hidden"!==Ce(t,["style","visibility"])}function tE(t,e){"update"in t?t.update(e):t.attr(e)}function eE(t){return Ce(t,"__to_be_destroyed__",!1)}class nE extends iy{constructor(t,e){super(t,Object.assign({},nE.defaultOptions,e)),this.onCollapseExpand=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{target:e}=t;if(!(RB(n=e)||HB(n)||_B(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,A=i.getElementDataById(r);if(!A)return!1;const{onCollapse:s,onExpand:a,animation:c,align:l}=this.options;rw(A)?(yield o.expandElement(r,{animation:c,align:l}),null==a||a(r)):(yield o.collapseElement(r,{animation:c,align:l}),null==s||s(r))}),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`node:${e}`,this.onCollapseExpand),t.on(`combo:${e}`,this.onCollapseExpand)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`node:${e}`,this.onCollapseExpand),t.off(`combo:${e}`,this.onCollapseExpand)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}function rE(t,e){const{data:n,style:r}=t,i=Pe(t,["data","style"]),{data:o,style:A}=e,s=Pe(e,["data","style"]),a=Object.assign(Object.assign({},i),s);return(n||o)&&Object.assign(a,{data:Object.assign(Object.assign({},n),o)}),(r||A)&&Object.assign(a,{style:Object.assign(Object.assign({},r),A)}),a}function iE(t){const{data:e,style:n}=t,r=Pe(t,["data","style"]);return e&&(r.data=Object.assign({},e)),n&&(r.style=Object.assign({},n)),r}function oE(t={},e={}){const{states:n=[],data:r={},style:i={},children:o=[]}=t,A=Pe(t,["states","data","style","children"]),{states:s=[],data:a={},style:c={},children:l=[]}=e,u=(t,e)=>t.length===e.length&&t.every((t,n)=>t===e[n]),h=(t,e)=>{const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every(n=>t[n]===e[n])};return!!h(A,Pe(e,["states","data","style","children"]))&&(!!u(o,l)&&(!!u(n,s)&&(!!h(r,a)&&!!h(i,c))))}nE.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const AE="__internal_override__";function sE(t){return!1!==t[AE]}const aE="g6-create-edge-assist-node-id";class cE extends iy{constructor(t,e){super(t,Object.assign({},cE.defaultOptions,e)),this.drop=t=>De(this,void 0,void 0,function*(){const{targetType:e}=t;["combo","node"].includes(e)&&this.source?yield this.handleCreateEdge(t):yield this.cancelEdge()}),this.handleCreateEdge=t=>De(this,void 0,void 0,function*(){var e,n,r;if(!this.validate(t))return;const{graph:i,canvas:o,batch:A,element:s}=this.context,{style:a}=this.options;if(this.source)return this.createEdge(t),void(yield this.cancelEdge());A.startBatch(),o.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0];const c=i.getElementData(this.source);i.addNodeData([{id:aE,type:"circle",[AE]:!1,style:{size:1,visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=c.style)||void 0===e?void 0:e.x,y:null===(n=c.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:aE,style:Object.assign({pointerEvents:"none"},a)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished}),this.updateAssistEdge=t=>De(this,void 0,void 0,function*(){var e;if(!this.source)return;const{model:n,element:r,graph:i}=this.context,[o,A]=i.getCanvasByClient([t.client.x,t.client.y]);n.translateNodeTo(aE,[o,A]),yield null===(e=r.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished}),this.createEdge=t=>{var e,n;const{graph:r}=this.context,{style:i,onFinish:o,onCreate:A}=this.options;if(void 0===(null===(e=t.target)||void 0===e?void 0:e.id)||void 0===this.source)return;const s=null===(n=this.getSelectedNodeIDs([t.target.id]))||void 0===n?void 0:n[0];var a;const c=A({id:`${this.source}-${s}-${Ue[a=a||"g"]?Ue[a]+=1:Ue[a]=1,a+Ue[a]}`,source:this.source,target:s,style:i});c&&(r.addEdgeData([c]),o(c))},this.cancelEdge=()=>De(this,void 0,void 0,function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([aE]),this.source=void 0,yield null===(t=n.draw({animation:!1}))||void 0===t?void 0:t.finished,r.endBatch()}),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(t.NodeEvent.CLICK,this.handleCreateEdge),e.on(t.ComboEvent.CLICK,this.handleCreateEdge),e.on(t.CanvasEvent.CLICK,this.cancelEdge),e.on(t.EdgeEvent.CLICK,this.cancelEdge)):(e.on(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.on(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map(t=>t.id).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.CLICK,this.handleCreateEdge),e.off(t.ComboEvent.CLICK,this.handleCreateEdge),e.off(t.CanvasEvent.CLICK,this.cancelEdge),e.off(t.EdgeEvent.CLICK,this.cancelEdge),e.off(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.off(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}cE.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class lE extends iy{constructor(t,e){super(t,Object.assign({},lE.defaultOptions,e)),this.isDragging=!1,this.onDragStart=t=>{this.validate(t)&&(this.isDragging=!0,this.context.canvas.setCursor("grabbing"))},this.onDrag=t=>{var e,n,r,i;if(!this.isDragging||Ky.isPinching)return;const o=null!==(n=null===(e=t.movement)||void 0===e?void 0:e.x)&&void 0!==n?n:t.dx,A=null!==(i=null===(r=t.movement)||void 0===r?void 0:r.y)&&void 0!==i?i:t.dy;0!==(o|A)&&this.translate([o,A],!1)},this.onDragEnd=()=>{var t,e;this.isDragging=!1,this.context.canvas.setCursor(this.defaultCursor),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)},this.invokeOnFinish=pe(()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)},300),this.shortcut=new Wy(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(zt(e)){const{up:t=[],down:n=[],left:r=[],right:i=[]}=e;this.shortcut.bind(t,t=>this.onTranslate([0,1],t)),this.shortcut.bind(n,t=>this.onTranslate([0,-1],t)),this.shortcut.bind(r,t=>this.onTranslate([1,0],t)),this.shortcut.bind(i,t=>this.onTranslate([-1,0],t))}else{const{graph:e}=this.context;e.on(t.CommonEvent.DRAG_START,this.onDragStart),e.on(t.CommonEvent.DRAG,this.onDrag),e.on(t.CommonEvent.DRAG_END,this.onDragEnd)}}onTranslate(t,e){return De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(ly(t,r),this.options.animation),this.invokeOnFinish()})}translate(t,e){return De(this,void 0,void 0,function*(){t=this.clampByDirection(t),t=this.clampByRange(t),t=this.clampByRotation(t),yield this.context.graph.translateBy(t,e)})}clampByRotation([t,e]){return By([t,e],this.context.graph.getRotation())}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[A,s,a,c]=pm(this.options.range),l=[o*A,i*s,o*a,i*c],u=Em(Bm(n.getCanvasCenter()),l),h=cy(n.getViewportCenter(),[t,e,0]);if(!Cm(h,u)){const{min:[n,r],max:[i,o]}=u;(h[0]<n&&t>0||h[0]>i&&t<0)&&(t=0),(h[1]<r&&e>0||h[1]>o&&e<0)&&(e=0)}return[t,e]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return"function"==typeof e?e(t):!!e}unbindEvents(){this.shortcut.unbindAll();const{graph:e}=this.context;e.off(t.CommonEvent.DRAG_START,this.onDragStart),e.off(t.CommonEvent.DRAG,this.onDrag),e.off(t.CommonEvent.DRAG_END,this.onDragEnd)}destroy(){this.shortcut.destroy(),this.unbindEvents(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}lE.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class uE extends iy{constructor(e,n){super(e,Object.assign({},uE.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>De(this,void 0,void 0,function*(){var e;if("link"!==this.options.dropEffect)return;const{model:n,element:r}=this.context,i=t.target.id;this.target.forEach(t=>{const e=n.getParentData(t,zv);e&&Km(e)===i&&n.refreshComboData(i),n.setParent(t,i,zv)}),yield null===(e=null==r?void 0:r.draw({animation:!0}))||void 0===e?void 0:e.finished}),this.setCursor=e=>{if(this.isDragging)return;const{type:n}=e,{canvas:r}=this.context,{cursor:i}=this.options;n===t.CommonEvent.POINTER_ENTER?r.setCursor((null==i?void 0:i.grab)||"grab"):r.setCursor((null==i?void 0:i.default)||"default")},this.shortcut=new Wy(e.graph),this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.addEventListener("blur",this.onDragEnd),r.addEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach(n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)}),["link"].includes(this.options.dropEffect)&&(e.on(t.ComboEvent.DROP,this.onDrop),e.on(t.CanvasEvent.DROP,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map(t=>t.id).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return uy([t.dx,t.dy],e)}onDragStart(t){var e;if(this.enable=this.validate(t),!this.enable)return;const{batch:n,canvas:r,graph:i}=this.context;r.setCursor((null===(e=this.options.cursor)||void 0===e?void 0:e.grabbing)||"grabbing"),this.isDragging=!0,n.startBatch();const o=t.target.id;i.getElementState(o).includes(this.options.state)?this.target=this.getSelectedNodeIDs([o]):this.target=[o],this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target)}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){var t,e,n;if(!this.enable)return;if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=cy([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t,this.target);const{batch:r,canvas:i}=this.context;r.endBatch(),i.setCursor((null===(n=this.options.cursor)||void 0===n?void 0:n.grab)||"grab"),this.isDragging=!1,this.target=[]}isKeydown(){const{trigger:t}=this.options;return!(null==t?void 0:t.length)||this.shortcut.match(t)}validate(t){if(this.destroyed||eE(t.target)||this.context.graph.isCollapsingExpanding||!this.isKeydown())return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}clampByRotation([t,e]){return By([t,e],this.context.graph.getRotation())}moveElement(t,e){return De(this,void 0,void 0,function*(){const{graph:n,model:r}=this.context,{dropEffect:i}=this.options;"move"===i&&t.forEach(t=>r.refreshComboData(t)),n.translateElementBy(Object.fromEntries(t.map(t=>[t,this.clampByRotation(e)])),!1)})}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=Aw(this.options,"shadow"),n=xm(t.map(t=>this.context.element.getElement(t).getBounds())),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,A]=wm(n),s={width:o,height:A,x:r,y:i};this.shadow?this.shadow.attr(Object.assign(Object.assign(Object.assign({},e),s),{visibility:"visible"})):(this.shadow=new sc({style:Object.assign(Object.assign(Object.assign({$layer:"transient"},e),s),{pointerEvents:"none"})}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdge(){const{hideEdge:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(Km):Array.from(new Set(this.target.map(e=>n.getRelatedEdgesData(e,t).map(Km)).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.removeEventListener("blur",this.onDragEnd),r.removeEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach(n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)}),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){var t;this.unbindEvents(),null===(t=this.shadow)||void 0===t||t.destroy(),super.destroy()}}uE.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),trigger:[],dropEffect:"move",state:"selected",hideEdge:"none",shadow:!1,shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5],cursor:{default:"default",grab:"grab",grabbing:"grabbing"}};var hE=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],A=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var A=r[o],s=A.callback;A.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};A(i),A(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function dE(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach(n=>{e.has(n.id)||(e.add(n.id),t.push(n))})}return!1}function fE(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&fE(i,e,n,r))return!0;return!1}const gE=()=>!0;class pE{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||gE,n=t.edgeFilter||gE;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map(t=>t.id))};updateCache=t=>{const e=new Set;t.forEach(t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach(t=>e.add(t.id)),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach(t=>e.add(t.id)),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)}),e.forEach(t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)})};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach(n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}}),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some(e=>e.id===t)}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map(t=>this.getNode(t.target));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map(t=>this.getNode(t.source));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];dE([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];fE(this.getNode(t),new Set,e,r)}}let vE=class t extends hE{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach(t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter(e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id}),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter(e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id}),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex(e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName)),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter(e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey),e.push(t);break;case"TreeStructureChanged":{const n=e.find(e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId);n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}}),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some(e=>e.id===t)}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map(t=>this.getNode(t.target));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map(t=>this.getNode(t.source));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach(e=>{e.childrenMap.set(t.id,new Set)}),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch(()=>{for(const e of t)this.doAddNode(e)})}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach(t=>this.doRemoveEdge(t.id)),this.nodeMap.delete(t),this.treeIndices.forEach(n=>{n.childrenMap.get(t)?.forEach(t=>{n.parentMap.delete(t.id)});const r=n.parentMap.get(t);r&&n.childrenMap.get(r.id)?.delete(e),n.parentMap.delete(t),n.childrenMap.delete(t)}),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch(()=>{t.forEach(t=>this.doRemoveNode(t))})}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch(()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})})}mergeNodeData(t,e){this.batch(()=>{Object.entries(e).forEach(([e,n])=>{this.updateNodeDataProperty(t,e,n)})})}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch(()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})})}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch(()=>{for(const e of t)this.doAddEdge(e)})}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch(()=>{t.forEach(t=>this.doRemoveEdge(t))})}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})})}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch(()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})})}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch(()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})})}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch(()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})})}mergeEdgeData(t,e){this.batch(()=>{Object.entries(e).forEach(([e,n])=>{this.updateEdgeDataProperty(t,e,n)})})}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch(()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})}))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch(()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})})}addTree(t,e){this.batch(()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach(t=>{t.children?.forEach(n=>{this.setParent(n.id,t.id,e)})})})}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter(e=>!this.getParent(e.id,t))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n);if(!r)return;const i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(null==e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const A=this.getNode(e);r.parentMap.set(t,A),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(A.id);s||(s=new Set,r.childrenMap.set(A.id,s)),s.add(i),this.batch(()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:A.id})})}dfsTree(t,e,n){return fE(this.getNode(t),new Set,e,t=>this.getChildren(t,n))}bfsTree(t,e,n){return dE([this.getNode(t)],new Set,e,t=>this.getChildren(t,n))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return dE([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return fE(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map(t=>({...t,data:{...t.data}})),n=this.getAllEdges().map(t=>({...t,data:{...t.data}})),r=new t({nodes:e,edges:n});return this.treeIndices.forEach(({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach((t,e)=>{i.set(e,r.getNode(t.id))});const o=new Map;e.forEach((t,e)=>{o.set(e,new Set(Array.from(t).map(t=>r.getNode(t.id))))}),r.treeIndices.set(n,{parentMap:i,childrenMap:o})}),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new pE({graph:this,...t})}},mE=class{constructor(t,e){this.context=t,this.options=e||{}}};function yE(t,e){return class extends mE{constructor(e,n){if(super(e,n),this.instance=new t({}),this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>(t.tick(e),this.getLayoutResult(t))}}execute(t,e){return De(this,void 0,void 0,function*(){return yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(be({},this.options,e))),this.getLayoutResult(this.instance)})}graphData2LayoutModel(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e,...r],edges:n}}transformOptions(t){if(t.node=t=>{var n;const{style:r}=t||{},i="combo"in(t||{})&&null!==(n=t.combo)&&void 0!==n?n:null,o=Km(t);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({id:o},re(null==r?void 0:r.x)?{x:r.x}:{}),re(null==r?void 0:r.y)?{y:r.y}:{}),re(null==r?void 0:r.z)?{z:r.z}:{}),{parentId:i}),(t=>e.model.isCombo(t))(o)?{isCombo:!0}:{})},t.edge=t=>({id:Km(t),source:t.source,target:t.target}),!("onTick"in t))return t;const n=t.onTick;return t.onTick=t=>n(this.getLayoutResult(t)),t}getLayoutResult(t){const{model:e}=this.context,n={nodes:[],edges:[],combos:[]};return t.forEachNode(t=>{var r;const i=String(t.id),o=e.isCombo(i)?n.combos:n.nodes,A=Object.assign({x:t.x,y:t.y,z:null!==(r=t.z)&&void 0!==r?r:0},t.size?{size:t.size}:{});null==o||o.push({id:i,style:A})}),t.forEachEdge(t=>{const e={controlPoints:t.points||[]};n.edges.push({id:String(t.id),source:String(t.source),target:String(t.target),style:e})}),n}}}function wE(t){const{nodes:e,edges:n=[]}=t,r={nodes:[],edges:[],combos:[]};return e.forEach(t=>{const e=t.data._isCombo?r.combos:r.nodes,{x:n,y:i,z:o=0}=t.data;null==e||e.push({id:t.id,style:{x:n,y:i,z:o}})}),n.forEach(t=>{const{id:e,source:n,target:i,data:{points:o=[],controlPoints:A=o.slice(1,o.length-1)}}=t;r.edges.push({id:e,source:n,target:i,style:Object.assign({},(null==A?void 0:A.length)?{controlPoints:A.map(Sy)}:{})})}),r}function bE(t,e,...n){if(e in t)return t[e](...n);if("instance"in t){const r=t.instance;if(e in r)return r[e](...n)}return null}function BE(t,e){if(e in t)return t[e];if("instance"in t){const n=t.instance;if(e in n)return n[e]}return null}class EE extends uE{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find(t=>["d3-force","d3-force-3d"].includes(null==t?void 0:t.id))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(Zv("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return De(this,void 0,void 0,function*(){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach((r,i)=>{const{x:o=0,y:A=0}=r.style||{};n&&bE(n,"setFixedPosition",t[i],[...ay([+o,+A],this.clampByRotation(e))])})})}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e&&BE(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach(t=>{const{x:n=0,y:r=0}=t.style||{};e&&bE(e,"setFixedPosition",Km(t),[+n,+r])})}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t&&BE(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach(e=>{t&&bE(t,"setFixedPosition",Km(e),[null,null,null])})}}class xE extends iy{constructor(t,e){super(t,Object.assign({},xE.defaultOptions,e)),this.isZoomEvent=t=>Boolean(t.data&&"scale"in t.data),this.relatedEdgeToUpdate=new Set,this.zoom=this.context.graph.getZoom(),this.fixElementSize=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{graph:e}=this.context,{state:n,nodeFilter:r,edgeFilter:i,comboFilter:o}=this.options,A=(n?e.getElementDataByState("node",n):e.getNodeData()).filter(r),s=(n?e.getElementDataByState("edge",n):e.getEdgeData()).filter(i),a=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),c=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,l=[...A,...a];l.length>0&&l.forEach(t=>this.fixNodeLike(t,c)),this.updateRelatedEdges(),s.length>0&&s.forEach(t=>this.fixEdge(t,c))}),this.cachedStyles=new Map,this.getOriginalFieldValue=(t,e,n)=>{var r;const i=this.cachedStyles.get(t)||[],o=(null===(r=i.find(t=>t.shape===e))||void 0===r?void 0:r.style)||{};return n in o||(o[n]=e.attributes[n],this.cachedStyles.set(t,[...i.filter(t=>t.shape!==e),{shape:e,style:o}])),o[n]},this.scaleEntireElement=(t,e,n)=>{e.setLocalScale(1/n);const r=this.cachedStyles.get(t)||[];r.push({shape:e}),this.cachedStyles.set(t,r)},this.scaleSpecificShapes=(t,e,n)=>{const r=function(t){const e=[],n=t=>{(null==t?void 0:t.children.length)&&t.children.forEach(t=>{e.push(t),n(t)})};return n(t),e}(t);(Array.isArray(n)?n:[n]).forEach(n=>{const{shape:i,fields:o}=n,A="function"==typeof i?i(r):t.getShape(i);A&&(o?o.forEach(n=>{const r=this.getOriginalFieldValue(t.id,A,n);re(r)&&(A.style[n]=r/e)}):this.scaleEntireElement(t.id,A,e))})},this.skipIfExceedViewport=t=>{const{viewport:e}=this.context;return!(null==e?void 0:e.isInViewport(t.getRenderBounds(),!1,30))},this.fixNodeLike=(t,e)=>{const n=Km(t),{element:r,model:i}=this.context,o=r.getElement(n);if(!o||this.skipIfExceedViewport(o))return;i.getRelatedEdgesData(n).forEach(t=>this.relatedEdgeToUpdate.add(Km(t)));const A=this.options[o.type];A?this.scaleSpecificShapes(o,e,A):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=Km(t),r=this.context.element.getElement(n);if(!r||this.skipIfExceedViewport(r))return;const i=this.options.edge;if(!i)return r.style.transformOrigin="center",void this.scaleEntireElement(n,r,e);this.scaleSpecificShapes(r,e,i)},this.updateRelatedEdges=()=>{const{element:t}=this.context;this.relatedEdgeToUpdate.size>0&&this.relatedEdgeToUpdate.forEach(e=>{const n=t.getElement(e);null==n||n.update({})}),this.relatedEdgeToUpdate.clear()},this.resetTransform=t=>De(this,void 0,void 0,function*(){var e;(null===(e=t.data)||void 0===e?void 0:e.firstRender)||(this.options.reset?this.restoreCachedStyles():this.fixElementSize({data:{scale:this.zoom}}))}),this.bindEvents()}restoreCachedStyles(){if(this.cachedStyles.size>0){this.cachedStyles.forEach(t=>{t.forEach(({shape:t,style:e})=>{if(Ee(e))t.setLocalScale(1);else{if(this.options.state)return;Object.entries(e).forEach(([e,n])=>t.style[e]=n)}})});const{graph:t,element:e}=this.context,n=Object.keys(Object.fromEntries(this.cachedStyles)).filter(e=>e&&"node"===t.getElementType(e));if(n.length>0){const r=new Set;n.forEach(e=>{t.getRelatedEdgesData(e).forEach(t=>r.add(Km(t)))}),r.forEach(t=>{const n=null==e?void 0:e.getElement(t);null==n||n.update({})})}}}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.on(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.off(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}xE.defaultOptions={enable:t=>t.data.scale<1,nodeFilter:()=>!0,edgeFilter:()=>!0,comboFilter:()=>!0,edge:[{shape:"key",fields:["lineWidth"]},{shape:"halo",fields:["lineWidth"]},{shape:"label"}],reset:!1};class CE extends iy{constructor(t,e){super(t,Object.assign({},CE.defaultOptions,e)),this.focus=t=>De(this,void 0,void 0,function*(){if(!this.validate(t))return;const{graph:e}=this.context;yield e.focusElement(t.target.id,this.options.animation)}),this.shortcut=new Wy(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)})}validate(t){if(this.destroyed||!this.isKeydown())return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}isKeydown(){const{trigger:t}=this.options;return!(null==t?void 0:t.length)||this.shortcut.match(t)}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)})}destroy(){this.unbindEvents(),this.shortcut.destroy(),super.destroy()}}CE.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0,trigger:[]};class ME extends iy{constructor(e,n){super(e,Object.assign({},ME.defaultOptions,n)),this.isFrozen=!1,this.toggleFrozen=t=>{this.isFrozen="dragstart"===t.type},this.hoverElement=e=>{if(!this.validate(e))return;const n=e.type===t.CommonEvent.POINTER_ENTER;this.updateElementsState(e,n);const{onHover:r,onHoverEnd:i}=this.options;n?null==r||r(e):null==i||i(e)},this.updateElementsState=(t,e)=>{if(!this.options.state&&!this.options.inactiveState)return;const{graph:n}=this.context,{state:r,animation:i,inactiveState:o}=this.options,A=this.getActiveIds(t),s={};if(r&&Object.assign(s,this.getElementsState(A,r,e)),o){const t=zm(n.getData(),!0).filter(t=>!A.includes(t));Object.assign(s,this.getElementsState(t,o,e))}n.setElementState(s,i)},this.getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach(t=>{const o=r.getElementState(t);i[t]=n?o.includes(e)?o:[...o,e]:o.filter(t=>t!==e)}),i},this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),$y.forEach(n=>{e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)});const n=this.context.canvas.document;n.addEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.addEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}getActiveIds(t){const{graph:e}=this.context,{degree:n,direction:r}=this.options,i=t.target.id;return n?Jy(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||eE(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;$y.forEach(n=>{e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)});const n=this.context.canvas.document;n.removeEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.removeEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}destroy(){this.unbindEvents(),super.destroy()}}ME.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class FE extends Yy{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e,graph:n}=this.context;this.pathShape=new nc({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[Xy(t,n)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(Xy(t,this.context.graph)),null===(e=this.pathShape)||void 0===e||e.setAttribute("d",function(t,e=!0){const n=[];return t.forEach((t,e)=>{n.push([0===e?"M":"L",...t])}),e&&n.push(["Z"]),n}(this.points)),n&&"default"===r&&this.points.length>2&&super.updateElementsStates(this.points)}onPointerUp(){this.points&&(this.points.length<2||super.updateElementsStates(this.points),this.clearLasso())}clearLasso(){var t;null===(t=this.pathShape)||void 0===t||t.remove(),this.pathShape=void 0,this.points=void 0}}class kE extends iy{constructor(t,e){super(t,Object.assign({},kE.defaultOptions,e)),this.hiddenShapes=[],this.isVisible=!0,this.setElementsVisibility=(t,e,n)=>{t.filter(Boolean).forEach(t=>{"hidden"!==e||t.isVisible()?"visible"===e&&this.hiddenShapes.includes(t)?this.hiddenShapes.splice(this.hiddenShapes.indexOf(t),1):ey(t,e,n):this.hiddenShapes.push(t)})},this.filterShapes=(t,e)=>{if(Gt(e))return n=>!e(t,n);const n=null==e?void 0:e[t];return t=>!t.className||!(null==n?void 0:n.includes(t.className))},this.hideShapes=t=>{if(!this.validate(t)||!this.isVisible)return;const{element:e}=this.context,{shapes:n={}}=this.options;this.setElementsVisibility(e.getNodes(),"hidden",this.filterShapes("node",n)),this.setElementsVisibility(e.getEdges(),"hidden",this.filterShapes("edge",n)),this.setElementsVisibility(e.getCombos(),"hidden",this.filterShapes("combo",n)),this.isVisible=!1},this.showShapes=pe(t=>{if(!this.validate(t)||this.isVisible)return;const{element:e}=this.context;this.setElementsVisibility(e.getNodes(),"visible"),this.setElementsVisibility(e.getEdges(),"visible"),this.setElementsVisibility(e.getCombos(),"visible"),this.isVisible=!0},this.options.debounce),this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.on(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.off(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}kE.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class SE extends iy{constructor(t,e){super(t,Object.assign({},SE.defaultOptions,e)),this.onWheel=t=>De(this,void 0,void 0,function*(){this.options.preventDefault&&t.preventDefault();const e=t.deltaX,n=t.deltaY;yield this.scroll([-e,-n],t)}),this.shortcut=new Wy(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),zt(r)){null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel);const{up:n=[],down:i=[],left:o=[],right:A=[]}=r;this.shortcut.bind(n,t=>this.scroll([0,-10],t)),this.shortcut.bind(i,t=>this.scroll([0,10],t)),this.shortcut.bind(o,t=>this.scroll([-10,0],t)),this.shortcut.bind(A,t=>this.scroll([10,0],t))}else null===(n=this.graphDom)||void 0===n||n.addEventListener(t.CommonEvent.WHEEL,this.onWheel,{passive:!1})}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}formatDisplacement(t){const{sensitivity:e}=this.options;return t=ly(t,e),t=this.clampByDirection(t),t=this.clampByRange(t)}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[A,s,a,c]=pm(this.options.range),l=[o*A,i*s,o*a,i*c],u=Em(Bm(n.getCanvasCenter()),l),h=cy(n.getViewportCenter(),[t,e,0]);if(!Cm(h,u)){const{min:[n,r],max:[i,o]}=u;(h[0]<n&&t>0||h[0]>i&&t<0)&&(t=0),(h[1]<r&&e>0||h[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{onFinish:n}=this.options,r=this.context.graph,i=this.formatDisplacement(t);yield r.translateBy(i,!1),null==n||n()})}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel),super.destroy()}}SE.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class QE extends iy{constructor(t,e){super(t,Object.assign({},QE.defaultOptions,e)),this.zoom=(t,e,n)=>De(this,void 0,void 0,function*(){if(!this.validate(e))return;const{graph:r}=this.context;let i=this.options.origin;!i&&"viewport"in e&&(i=Sy(e.viewport));const{sensitivity:o,onFinish:A}=this.options,s=1+ne(t,-50,50)*o/100,a=r.getZoom();yield r.zoomTo(a*s,n,i),null==A||A()}),this.onReset=()=>De(this,void 0,void 0,function*(){yield this.context.graph.zoomTo(1,this.options.animation)}),this.preventDefault=t=>{this.options.preventDefault&&t.preventDefault()},this.shortcut=new Wy(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),Array.isArray(e))if(e.includes(t.CommonEvent.PINCH))this.shortcut.bind([t.CommonEvent.PINCH],t=>{this.zoom(t.scale,t,!1)});else{const n=this.context.canvas.getContainer();null==n||n.addEventListener(t.CommonEvent.WHEEL,this.preventDefault),this.shortcut.bind([...e,t.CommonEvent.WHEEL],t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(null!=n?n:e),t,!1)})}if("object"==typeof e){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,t=>this.zoom(10,t,this.options.animation)),this.shortcut.bind(n,t=>this.zoom(-10,t,this.options.animation)),this.shortcut.bind(r,this.onReset)}}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Gt(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.context.canvas.getContainer())||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.preventDefault),super.destroy()}}function UE(t,e,n,r="height"){const i=t[r],o=e[r];return"center"===n?(i+o)/2:t.height}QE.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};const NE=Object.assign,TE={getId:t=>t.id||t.name,getPreH:t=>t.preH||0,getPreV:t=>t.preV||0,getHGap:t=>t.hgap||18,getVGap:t=>t.vgap||18,getChildren:t=>t.children,getHeight:t=>t.height||36,getWidth(t){const e=t.label||" ";return t.width||18*e.split("").length}};let OE=class t{constructor(e,n){if(this.x=0,this.y=0,this.depth=0,this.children=[],this.hgap=0,this.vgap=0,e instanceof t||"x"in e&&"y"in e&&"children"in e){const t=e;return this.data=t.data,this.id=t.id,this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.depth=t.depth,this.children=t.children,this.parent=t.parent,this.hgap=t.hgap,this.vgap=t.vgap,this.preH=t.preH,void(this.preV=t.preV)}this.data=e;const r=n.getHGap(e),i=n.getVGap(e);this.preH=n.getPreH(e),this.preV=n.getPreV(e),this.width=n.getWidth(e),this.height=n.getHeight(e),this.width+=this.preH,this.height+=this.preV,this.id=n.getId(e),this.addGap(r,i)}isRoot(){return 0===this.depth}isLeaf(){return 0===this.children.length}addGap(t,e){this.hgap+=t,this.vgap+=e,this.width+=2*t,this.height+=2*e}eachNode(t){let e,n=[this];for(;e=n.shift();)t(e),n=e.children.concat(n)}DFTraverse(t){this.eachNode(t)}BFTraverse(t){let e,n=[this];for(;e=n.shift();)t(e),n=n.concat(e.children)}getBoundingBox(){const t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode(e=>{t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)}),t}translate(t=0,e=0){this.eachNode(n=>{n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV})}right2left(){const t=this.getBoundingBox();this.eachNode(e=>{e.x=e.x-2*(e.x-t.left)-e.width}),this.translate(t.width,0)}bottom2top(){const t=this.getBoundingBox();this.eachNode(e=>{e.y=e.y-2*(e.y-t.top)-e.height}),this.translate(0,t.height)}};function IE(t,e={},n){e=NE({},TE,e);const r=new OE(t,e),i=[r];let o;if(!n&&!t.collapsed)for(;o=i.shift();)if(!o.data.collapsed){const t=e.getChildren(o.data),n=t?t.length:0;if(o.children=new Array(n),t&&n)for(let r=0;r<n;r++){const n=new OE(t[r],e);o.children[r]=n,i.push(n),n.parent=o,n.depth=o.depth+1}}return r}let LE=class{constructor(t,e={}){this.options=e,this.rootNode=IE(t,e)}execute(){throw new Error("please override this method")}},PE=class t{constructor(t=0,e=0,n=0,r=[]){this.x=0,this.prelim=0,this.mod=0,this.shift=0,this.change=0,this.tl=null,this.tr=null,this.el=null,this.er=null,this.msel=0,this.mser=0,this.w=t||0,this.h=e||0,this.y=n||0,this.c=r||[],this.cs=r.length}static fromNode(e,n){if(!e)return null;const r=[];return e.children.forEach(e=>{const i=t.fromNode(e,n);i&&r.push(i)}),n?new t(e.height,e.width,e.x,r):new t(e.width,e.height,e.y,r)}};function DE(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach(t=>{DE(t,e,n)})}function RE(t,e){let n=e?t.y:t.x;return t.children.forEach(t=>{n=Math.min(RE(t,e),n)}),n}function HE(t,e){DE(t,-RE(t,e),e)}function _E(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((t,r)=>{_E(t,e.children[r],n)})}function GE(t,e,n=0){e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach(t=>{GE(t,e,n)})}function KE(t,e={}){const n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){let r=t.c[e-1],i=r.mod,c=t.c[e],l=c.mod;for(;null!==r&&null!==c;){n&&a(r)>n.low&&(n=n.nxt);const u=i+r.prelim+r.w-(l+c.prelim);u>0&&(l+=u,n&&o(t,e,n.index,u));const h=a(r),d=a(c);h<=d&&(r=s(r),null!==r&&(i+=r.mod)),h>=d&&(c=A(c),null!==c&&(l+=c.mod))}!r&&c?function(t,e,n,r){const i=t.c[0].el;i.tl=n;const o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,c,l):r&&!c&&function(t,e,n,r){const i=t.c[e].er;i.tr=n;const o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){const i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function A(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function a(t){return t.y+t.h}function c(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}GE(t,n);const l=PE.fromNode(t,n);return l&&(function t(e){if(0===e.cs)return void r(e);t(e.c[0]);let n=c(a(e.c[0].el),0,null);for(let r=1;r<e.cs;++r){t(e.c[r]);const o=a(e.c[r].er);i(e,r,n),n=c(o,r,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}(l),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){let e=0,n=0;for(let r=0;r<t.cs;r++)e+=t.c[r].shift,n+=e+t.c[r].change,t.c[r].mod+=n}(e);for(let r=0;r<e.cs;r++)t(e.c[r],n)}(l,0),_E(l,t,n),HE(t,n)),t}function jE(t,e){const n=IE(t.data,e,!0),r=IE(t.data,e,!0),i=t.children.length,o=Math.round(i/2),A=e.getSide||function(t,e){return e<o?"right":"left"};for(let e=0;e<i;e++){const i=t.children[e];"right"===A(i,e)?r.children.push(i):n.children.push(i)}return n.eachNode(t=>{t.isRoot()||(t.side="left")}),r.eachNode(t=>{t.isRoot()||(t.side="right")}),{left:n,right:r}}const zE=["LR","RL","TB","BT","H","V"],VE=["LR","RL","H"],WE=zE[0];function YE(t,e,n){const r=e.direction||WE;if(e.isHorizontal=(t=>VE.indexOf(t)>-1)(r),-1===zE.indexOf(r))throw new TypeError(`Invalid direction: ${r}`);if(r===zE[0])n(t,e);else if(r===zE[1])n(t,e),t.right2left();else if(r===zE[2])n(t,e);else if(r===zE[3])n(t,e),t.bottom2top();else if(r===zE[4]||r===zE[5]){const{left:r,right:i}=jE(t,e);n(r,e),n(i,e),e.isHorizontal?r.right2left():r.bottom2top(),i.translate(r.x-i.x,r.y-i.y),t.x=r.x,t.y=i.y;const o=t.getBoundingBox();e.isHorizontal?o.top<0&&t.translate(0,-o.top):o.left<0&&t.translate(-o.left,0)}let i=e.fixedRoot;return void 0===i&&(i=!0),i&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){const[n,r]=e.isHorizontal?["x","y"]:["y","x"],i={x:1/0,y:1/0},o={x:-1/0,y:-1/0};let A=0;t.DFTraverse(t=>{A++;const{x:e,y:n}=t;i.x=Math.min(i.x,e),i.y=Math.min(i.y,n),o.x=Math.max(o.x,e),o.y=Math.max(o.y,n)});const s=o[r]-i[r];if(0===s)return;const a=2*Math.PI/A;t.DFTraverse(e=>{const o=e[r],A=i[r],c=e[n],l=t[n],u=(o-A)/s*(2*Math.PI-a)+a,h=c-l;e.x=Math.cos(u)*h,e.y=Math.sin(u)*h})}}(t,e),t}let XE=class extends LE{execute(){return YE(this.rootNode,this.options,KE)}};const qE={};function $E(t,e){const n=NE({},qE,e);return new XE(t,n).execute()}let ZE=class{constructor(t=0,e=[]){this.x=0,this.y=0,this.leftChild=null,this.rightChild=null,this.isLeaf=!1,this.height=t,this.children=e}};const JE={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function tx(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((t,r)=>{tx(t,e.children[r],n)})}function ex(t,e={}){const n=NE({},JE,e);let r=0,i=null;const o=function t(e){e.width=0,e.depth&&e.depth>r&&(r=e.depth);const n=e.children,i=n.length,o=new ZE(0,[]);return n.forEach((e,n)=>{const r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)}),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{const n=e.children.map(e=>t(e)),r=Math.min(...n);e.drawingDepth=r-1}return e.drawingDepth}(o),function t(e){e.x=e.drawingDepth*n.rankSep,e.isLeaf?(e.y=0,i&&(e.y=i.y+i.height+n.nodeSep,e.originNode.parent!==i.originNode.parent&&(e.y+=n.subTreeSep)),i=e):(e.children.forEach(e=>{t(e)}),e.y=(e.leftChild.y+e.rightChild.y)/2)}(o),tx(o,t,n.isHorizontal),t}class nx extends LE{execute(){return this.rootNode.width=0,YE(this.rootNode,this.options,ex)}}const rx={};function ix(t,e){const n=NE({},rx,e);return new nx(t,n).execute()}function ox(t,e,n,r){let i=null;t.eachNode(t=>{!function(t,e,n,r,i){const o=("function"==typeof n?n(t):n)*t.depth;if(!r)try{if(t.parent&&t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch{}if(t.x+=o,e){if(t.y=e.y+UE(e,t,i),e.parent&&t.parent&&t.parent.id!==e.parent.id){const n=e.parent,r=n.y+UE(n,t,i);t.y=r>t.y?r:t.y}}else t.y=0}(t,i,e,n,r),i=t})}const Ax=["LR","RL","H"],sx=Ax[0];let ax=class extends LE{execute(){const t=this.options,e=this.rootNode;t.isHorizontal=!0;const{indent:n=20,dropCap:r=!0,direction:i=sx,align:o}=t;if(i&&-1===Ax.indexOf(i))throw new TypeError(`Invalid direction: ${i}`);if(i===Ax[0])ox(e,n,r,o);else if(i===Ax[1])ox(e,n,r,o),e.right2left();else if(i===Ax[2]){const{left:i,right:A}=jE(e,t);ox(i,n,r,o),i.right2left(),ox(A,n,r,o);const s=i.getBoundingBox();A.translate(s.width,0),e.x=A.x-e.width/2}return e}};const cx={};function lx(t,e){const n=NE({},cx,e);return new ax(t,n).execute()}function ux(t,e){let n=0;return t.children.length?t.children.forEach(t=>{n+=ux(t,e)}):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function hx(t){const e=t.children,n=e.length;if(n){e.forEach(t=>{hx(t)});const r=e[0],i=e[n-1],o=i.y-r.y+i.height;let A=0;if(e.forEach(t=>{A+=t.totalHeight}),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>A){const n=t.y+(t.height-o)/2-r.y;e.forEach(t=>{t.translate(0,n)})}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}const dx={getSubTreeSep:()=>0};function fx(t,e={}){return e=NE({},dx,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse(t=>{t.x=t.parent.x+t.parent.width}),t.parent=void 0,ux(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode(t=>{const e=t.children,n=e.length;if(n){const r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(let t=1;t<n;t++){const n=e[t];n.startY=e[t-1].startY+e[t-1].totalHeight,n.y=n.startY+n.totalHeight/2-n.height/2}}}}),hx(t),t}class gx extends LE{execute(){return YE(this.rootNode,this.options,fx)}}const px={};function vx(t,e){const n=NE({},px,e);return new gx(t,n).execute()}function mx(t,e,n,r){return new(n||(n=Promise))(function(e,i){function o(t){try{s(r.next(t))}catch(t){i(t)}}function A(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(t){t(r)})).then(o,A)}s((r=r.apply(t,[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const yx={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,pow:Math.pow};class wx extends Error{constructor(t,e,n){super(t),this.position=e,this.token=n,this.name="ExpressionError"}}var bx;!function(t){t[t.STRING=0]="STRING",t[t.NUMBER=1]="NUMBER",t[t.BOOLEAN=2]="BOOLEAN",t[t.NULL=3]="NULL",t[t.IDENTIFIER=4]="IDENTIFIER",t[t.OPERATOR=5]="OPERATOR",t[t.FUNCTION=6]="FUNCTION",t[t.DOT=7]="DOT",t[t.BRACKET_LEFT=8]="BRACKET_LEFT",t[t.BRACKET_RIGHT=9]="BRACKET_RIGHT",t[t.PAREN_LEFT=10]="PAREN_LEFT",t[t.PAREN_RIGHT=11]="PAREN_RIGHT",t[t.COMMA=12]="COMMA",t[t.QUESTION=13]="QUESTION",t[t.COLON=14]="COLON",t[t.DOLLAR=15]="DOLLAR"}(bx||(bx={}));const Bx=new Set([32,9,10,13]),Ex=new Set([43,45,42,47,37,33,38,124,61,60,62]),xx=new Map([["true",bx.BOOLEAN],["false",bx.BOOLEAN],["null",bx.NULL]]),Cx=new Map([["===",!0],["!==",!0],["<=",!0],[">=",!0],["&&",!0],["||",!0],["+",!0],["-",!0],["*",!0],["/",!0],["%",!0],["!",!0],["<",!0],[">",!0]]),Mx=new Map([[46,bx.DOT],[91,bx.BRACKET_LEFT],[93,bx.BRACKET_RIGHT],[40,bx.PAREN_LEFT],[41,bx.PAREN_RIGHT],[44,bx.COMMA],[63,bx.QUESTION],[58,bx.COLON],[36,bx.DOLLAR]]),Fx=new Map;for(const[t,e]of Mx.entries())Fx.set(t,{type:e,value:String.fromCharCode(t)});function kx(t){return t>=48&&t<=57}function Sx(t){return t>=97&&t<=122||t>=65&&t<=90||95===t}function Qx(t){return Sx(t)||kx(t)}function Ux(t){return Ex.has(t)}var Nx;!function(t){t[t.Program=0]="Program",t[t.Literal=1]="Literal",t[t.Identifier=2]="Identifier",t[t.MemberExpression=3]="MemberExpression",t[t.CallExpression=4]="CallExpression",t[t.BinaryExpression=5]="BinaryExpression",t[t.UnaryExpression=6]="UnaryExpression",t[t.ConditionalExpression=7]="ConditionalExpression"}(Nx||(Nx={}));const Tx=new Map([["||",2],["&&",3],["===",4],["!==",4],[">",5],[">=",5],["<",5],["<=",5],["+",6],["-",6],["*",7],["/",7],["%",7],["!",8]]),Ox={type:Nx.Literal,value:null},Ix={type:Nx.Literal,value:!0},Lx={type:Nx.Literal,value:!1},Px=t=>{let e=0;const n=t.length,r=()=>e>=n?null:t[e],i=()=>t[e++],o=t=>{const e=r();return null!==e&&e.type===t},A=t=>t.type===bx.OPERATOR?Tx.get(t.value)||-1:t.type===bx.DOT||t.type===bx.BRACKET_LEFT?9:t.type===bx.QUESTION?1:-1,s=t=>{let n,A;if(i().type===bx.DOT){if(!o(bx.IDENTIFIER)){const t=r();throw new wx("Expected property name",e,t?t.value:"<end of input>")}const t=i();n={type:Nx.Identifier,name:t.value},A=!1}else{if(n=c(0),!o(bx.BRACKET_RIGHT)){const t=r();throw new wx("Expected closing bracket",e,t?t.value:"<end of input>")}i(),A=!0}return{type:Nx.MemberExpression,object:t,property:n,computed:A}},a=()=>{const t=r();if(!t)throw new wx("Unexpected end of input",e,"<end of input>");if(t.type===bx.OPERATOR&&("!"===t.value||"-"===t.value)){i();const e=a();return{type:Nx.UnaryExpression,operator:t.value,argument:e,prefix:!0}}switch(t.type){case bx.NUMBER:return i(),{type:Nx.Literal,value:Number(t.value)};case bx.STRING:return i(),{type:Nx.Literal,value:t.value};case bx.BOOLEAN:return i(),"true"===t.value?Ix:Lx;case bx.NULL:return i(),Ox;case bx.IDENTIFIER:return i(),{type:Nx.Identifier,name:t.value};case bx.FUNCTION:return(()=>{const t=i(),n=[];if(!o(bx.PAREN_LEFT)){const t=r();throw new wx("Expected opening parenthesis after function name",e,t?t.value:"<end of input>")}for(i();;){if(o(bx.PAREN_RIGHT)){i();break}if(!r()){const t=r();throw new wx("Expected closing parenthesis",e,t?t.value:"<end of input>")}if(n.length>0){if(!o(bx.COMMA)){const t=r();throw new wx("Expected comma between function arguments",e,t?t.value:"<end of input>")}i()}const t=c(0);n.push(t)}return{type:Nx.CallExpression,callee:{type:Nx.Identifier,name:t.value},arguments:n}})();case bx.PAREN_LEFT:{i();const t=c(0);if(!o(bx.PAREN_RIGHT)){const t=r();throw new wx("Expected closing parenthesis",e,t?t.value:"<end of input>")}return i(),t}default:throw new wx(`Unexpected token: ${t.type}`,e,t.value)}},c=(l=0)=>{let u=a();for(;e<n;){const n=t[e],a=A(n);if(a<=l)break;if(n.type!==bx.QUESTION)if(n.type!==bx.OPERATOR){if(n.type!==bx.DOT&&n.type!==bx.BRACKET_LEFT)break;u=s(u)}else{i();const t=c(a);u={type:Nx.BinaryExpression,operator:n.value,left:u,right:t}}else{i();const t=c(0);if(!o(bx.COLON)){const t=r();throw new wx("Expected : in conditional expression",e,t?t.value:"<end of input>")}i();const n=c(0);u={type:Nx.ConditionalExpression,test:u,consequent:t,alternate:n}}}return u},l=c();return{type:Nx.Program,body:l}},Dx=(t,e,n)=>{let r=e;n&&(r={...e,context:{...e.context,...n}});const i=t=>{switch(t.type){case Nx.Literal:return(t=>t.value)(t);case Nx.Identifier:return(t=>{if(!(t.name in r.context))throw new wx(`Undefined variable: ${t.name}`);return r.context[t.name]})(t);case Nx.MemberExpression:return(t=>{const e=i(t.object);if(null==e)throw new wx("Cannot access property of null or undefined");return e[t.computed?i(t.property):t.property.name]})(t);case Nx.CallExpression:return(t=>{const e=r.functions[t.callee.name];if(!e)throw new wx(`Undefined function: ${t.callee.name}`);return e(...t.arguments.map(t=>i(t)))})(t);case Nx.BinaryExpression:return(t=>{if("&&"===t.operator){const e=i(t.left);return e?i(t.right):e}if("||"===t.operator)return i(t.left)||i(t.right);const e=i(t.left),n=i(t.right);switch(t.operator){case"+":return e+n;case"-":return e-n;case"*":return e*n;case"/":return e/n;case"%":return e%n;case"===":return e===n;case"!==":return e!==n;case">":return e>n;case">=":return e>=n;case"<":return e<n;case"<=":return e<=n;default:throw new wx(`Unknown operator: ${t.operator}`)}})(t);case Nx.UnaryExpression:return(t=>{const e=i(t.argument);if(t.prefix)switch(t.operator){case"!":return!e;case"-":if("number"!=typeof e)throw new wx(`Cannot apply unary - to non-number: ${e}`);return-e;default:throw new wx(`Unknown operator: ${t.operator}`)}throw new wx(`Postfix operators are not supported: ${t.operator}`)})(t);case Nx.ConditionalExpression:return(t=>{const e=i(t.test);return i(e?t.consequent:t.alternate)})(t);default:throw new wx(`Evaluation error: Unsupported node type: ${t.type}`)}};return i(t.body)};function Rx(t){const e=(t=>{const e=t,n=e.length,r=new Array(Math.ceil(n/3));let i=0,o=0;function A(t){const r=o+1;o++;let i="",A=!1;for(;o<n;){const n=e.charCodeAt(o);if(n===t)return A||(i=e.substring(r,o)),o++,{type:bx.STRING,value:i};92===n?(A||(i=e.substring(r,o),A=!0),o++,i+=e[o]):A&&(i+=e[o]),o++}throw new wx(`Unterminated string starting with ${String.fromCharCode(t)}`,o,e.substring(Math.max(0,o-10),o))}function s(){const t=o;for(45===e.charCodeAt(o)&&o++;o<n&&kx(e.charCodeAt(o));)o++;if(o<n&&46===e.charCodeAt(o))for(o++;o<n&&kx(e.charCodeAt(o));)o++;const r=e.slice(t,o);return{type:bx.NUMBER,value:r}}function a(){o++;const t=o;if(o<n&&Sx(e.charCodeAt(o)))for(o++;o<n&&Qx(e.charCodeAt(o));)o++;const r=e.slice(t,o);return{type:bx.FUNCTION,value:r}}function c(){const t=o++;for(;o<n&&Qx(e.charCodeAt(o));)o++;const r=e.slice(t,o),i=xx.get(r);return i?{type:i,value:r}:{type:bx.IDENTIFIER,value:r}}function l(){if(o+2<n){const t=e.substring(o,o+3);if(Cx.has(t))return o+=3,{type:bx.OPERATOR,value:t}}if(o+1<n){const t=e.substring(o,o+2);if(Cx.has(t))return o+=2,{type:bx.OPERATOR,value:t}}const t=e[o];if(Cx.has(t))return o++,{type:bx.OPERATOR,value:t};throw new wx(`Unknown operator at position ${o}: ${e.substring(o,o+1)}`,o,e.substring(Math.max(0,o-10),o))}for(;o<n;){const t=e.charCodeAt(o);if(u=t,Bx.has(u)){o++;continue}const h=Fx.get(t);if(h)r[i++]=h,o++;else if(34!==t&&39!==t)if(kx(t)||45===t&&o+1<n&&kx(e.charCodeAt(o+1)))r[i++]=s();else if(64!==t)if(Sx(t))r[i++]=c();else{if(!Ux(t))throw new wx(`Unexpected character: ${e[o]}`,o,e.substring(Math.max(0,o-10),o));r[i++]=l()}else r[i++]=a();else r[i++]=A(t)}var u;return i===r.length?r:r.slice(0,i)})(t),n=Px(e),r=((t={},e={})=>({context:t,functions:e}))({},yx);return(t={})=>Dx(n,r,t)}function Hx(t,e){if("string"!=typeof t)return;const n=t.trim();if(n)try{return Rx(n),function(t,e={}){return Rx(t)(e)}(n,e)}catch(t){return}}function _x(t){return"number"==typeof t}function Gx(t){if(!t)return[0,0,0];if(_x(t))return[t,t,t];if(Array.isArray(t)&&0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function Kx(t){return null==t}function jx(t){return"string"==typeof t}function zx(t){return"function"==typeof t}function Vx(t,e){if("function"==typeof t)return t;if("string"==typeof t){const n=t;return(...t)=>{const r={};for(let n=0;n<e.length;n++)r[e[n]]=t[n];return Hx(n,r)}}return()=>t}function Wx(t,e,n="node"){if(Kx(t))return()=>e;if(jx(t)){const r=Vx(t,[n]);return t=>{const n=r(t);return _x(n)?n:e}}return zx(t)?t:_x(t)?()=>t:()=>e}function Yx(t,e=10,n="node"){if(Kx(t))return()=>e;if(jx(t)){const r=Vx(t,[n]);return t=>{const n=r(t);return function(t){return!!_x(t)||!!Array.isArray(t)&&t.every(t=>_x(t))}(n)?n:e}}return zx(t)?t:_x(t)||Array.isArray(t)?()=>t:()=>e}const Xx=(t,e,n=10,r=0)=>{const i=Yx(e,r),o=Yx(t,n);return t=>{const[e,n,r]=Gx(o(t)),[A,s,a]=Gx(i(t));return[e+A,n+s,r+a]}};function qx(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}class $x{constructor(t,e={}){this.edgeIdCounter=new Map,this.nodeMap=function(t,e){if(!t)throw new Error("Data.nodes is required");const n=new Map;for(const r of t){const t={_original:r};for(const e of Zx){const n=r[e];Kx(n)||(t[e]=n)}if(e){const n=e(r);for(const e in n){const r=n[e];Kx(r)||(t[e]=r)}}if(Kx(t.id))throw new Error("Node is missing id field");n.set(t.id,t)}return n}(t.nodes,e.node),this.edgeMap=function(t,e,n){const r=new Map;for(const i of t){const t={_original:i};for(const e of Jx){const n=i[e];Kx(n)||(t[e]=n)}if(e){const n=e(i);for(const e in n){const r=n[e];Kx(r)||(t[e]=r)}}if(Kx(t.source)||Kx(t.target))throw new Error("Edge is missing source or target field");Kx(t.id)&&(t.id=null==n?void 0:n(i)),r.set(t.id,t)}return r}(t.edges||[],e.edge,this.getEdgeId.bind(this))}data(){return{nodes:this.nodeMap,edges:this.edgeMap}}replace(t){this.nodeMap=t.nodes,this.edgeMap=t.edges,this.clearCache()}nodes(){return Array.from(this.nodeMap.values())}node(t){return this.nodeMap.get(t)}nodeAt(t){this.indexNodeCache||this.buildNodeIndexCache();const e=this.indexNodeCache.get(t);return e?this.nodeMap.get(e):void 0}nodeIndexOf(t){var e;return this.nodeIndexCache||this.buildNodeIndexCache(),null!==(e=this.nodeIndexCache.get(t))&&void 0!==e?e:-1}firstNode(){return this.nodeMap.values().next().value}forEachNode(t){let e=0;this.nodeMap.forEach(n=>t(n,e++))}originalNode(t){const e=this.nodeMap.get(t);return null==e?void 0:e._original}nodeCount(){return this.nodeMap.size}edges(){return Array.from(this.edgeMap.values())}edge(t){return this.edgeMap.get(t)}firstEdge(){return this.edgeMap.values().next().value}forEachEdge(t){let e=0;this.edgeMap.forEach(n=>t(n,e++))}originalEdge(t){const e=this.edgeMap.get(t);return null==e?void 0:e._original}edgeCount(){return this.edgeMap.size}getEdgeId(t){if(t.id)return t.id;const e=`${t.source}-${t.target}`,n=this.edgeIdCounter.get(e)||0,r=0===n?e:`${e}-${n}`;return this.edgeIdCounter.set(e,n+1),r}degree(t,e="both"){this.degreeCache||this.buildDegreeCache();const n=this.degreeCache.get(t);return n?n[e]:0}neighbors(t,e="both"){if(this.outAdjacencyCache&&this.inAdjacencyCache||this.buildAdjacencyCache(),"out"===e)return Array.from(this.outAdjacencyCache.get(t)||[]);if("in"===e)return Array.from(this.inAdjacencyCache.get(t)||[]);if(this.bothAdjacencyCache)return Array.from(this.bothAdjacencyCache.get(t)||[]);const n=this.inAdjacencyCache.get(t),r=this.outAdjacencyCache.get(t);if(!n&&!r)return[];if(!n)return Array.from(r);if(!r)return Array.from(n);const i=new Set;return n.forEach(t=>i.add(t)),r.forEach(t=>i.add(t)),Array.from(i)}successors(t){return this.neighbors(t,"out")}predecessors(t){return this.neighbors(t,"in")}setNodeOrder(t){const e=new Map;for(const n of t)e.set(n.id,n);this.nodeMap=e,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}clearCache(){this.degreeCache=void 0,this.inAdjacencyCache=void 0,this.outAdjacencyCache=void 0,this.bothAdjacencyCache=void 0,this.nodeIndexCache=void 0,this.indexNodeCache=void 0}buildDegreeCache(){this.degreeCache=new Map;for(const t of this.edges()){const{source:e,target:n}=t;if(t.source===t.target)continue;this.degreeCache.has(e)||this.degreeCache.set(e,{in:0,out:0,both:0});const r=this.degreeCache.get(t.source);r&&(r.out++,r.both++),this.degreeCache.has(n)||this.degreeCache.set(n,{in:0,out:0,both:0});const i=this.degreeCache.get(t.target);i&&(i.in++,i.both++)}}buildAdjacencyCache(){this.inAdjacencyCache=new Map,this.outAdjacencyCache=new Map;for(const t of this.edges())this.nodeMap.has(t.source)&&this.nodeMap.has(t.target)&&(this.outAdjacencyCache.has(t.source)||this.outAdjacencyCache.set(t.source,new Set),this.outAdjacencyCache.get(t.source).add(t.target),this.inAdjacencyCache.has(t.target)||this.inAdjacencyCache.set(t.target,new Set),this.inAdjacencyCache.get(t.target).add(t.source))}buildNodeIndexCache(){this.nodeIndexCache=new Map,this.indexNodeCache=new Map;let t=0;this.nodeMap.forEach((e,n)=>{this.nodeIndexCache.set(n,t),this.indexNodeCache.set(t,n),t++})}destroy(){this.clearCache(),this.nodeMap.clear(),this.edgeMap.clear(),this.edgeIdCounter.clear()}}const Zx=["id","x","y","z","vx","vy","vz","fx","fy","fz","parentId"],Jx=["id","source","target","points"];function tC(t,e,n,r=2){t.forEachNode(t=>{Kx(t.x)&&(t.x=Math.random()*e),Kx(t.y)&&(t.y=Math.random()*n),3===r&&Kx(t.z)&&(t.z=Math.random()*Math.min(e,n))})}class eC{constructor(t,e={}){this.graph=new $x(t,e)}export(){return this.graph.data()}replace(t){this.graph.replace(t)}forEachNode(t){this.graph.forEachNode(t)}forEachEdge(t){this.graph.forEachEdge((e,n)=>{e.sourceNode=this.graph.node(e.source),e.targetNode=this.graph.node(e.target),t(e,n)})}destroy(){this.graph.destroy()}}
|
|
56
56
|
/**
|
|
57
57
|
* @license
|
|
58
58
|
* Copyright 2019 Google LLC
|
|
59
59
|
* SPDX-License-Identifier: Apache-2.0
|
|
60
|
-
*/const tC=Symbol("Comlink.proxy"),eC=Symbol("Comlink.endpoint"),nC=Symbol("Comlink.releaseProxy"),rC=Symbol("Comlink.finalizer"),iC=Symbol("Comlink.thrown"),oC=t=>"object"==typeof t&&null!==t||"function"==typeof t,AC=new Map([["proxy",{canHandle:t=>oC(t)&&t[tC],serialize(t){const{port1:e,port2:n}=new MessageChannel;return sC(t,e),[n,[n]]},deserialize:t=>(t.start(),cC(t))}],["throw",{canHandle:t=>oC(t)&&iC 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 sC(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(i){if(!i||!i.data)return;if(!function(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:o,type:A,path:s}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(mC);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]]=mC(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,a);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[tC]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;sC(t,n),c=function(t,e){return pC.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[iC]:0}}Promise.resolve(c).catch(t=>({value:t,[iC]:0})).then(n=>{const[i,s]=vC(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===A&&(e.removeEventListener("message",r),aC(e),rC in t&&"function"==typeof t[rC]&&t[rC]())}).catch(t=>{const[n,r]=vC({value:new TypeError("Unserializable return value"),[iC]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)})}),e.start&&e.start()}function aC(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function cC(t,e){const n=new Map;return t.addEventListener("message",function(t){const{data:e}=t;if(!e||!e.id)return;const r=n.get(e.id);if(r)try{r(e)}finally{n.delete(e.id)}}),fC(t,n,[],e)}function lC(t){if(t)throw new Error("Proxy has been released and is not useable")}function uC(t){return yC(t,new Map,{type:"RELEASE"}).then(()=>{aC(t)})}const hC=new WeakMap,dC="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(hC.get(t)||0)-1;hC.set(t,e),0===e&&uC(t)});function fC(t,e,n=[],r=function(){}){let i=!1;const o=new Proxy(r,{get(r,A){if(lC(i),A===nC)return()=>{!function(t){dC&&dC.unregister(t)}(o),uC(t),e.clear(),i=!0};if("then"===A){if(0===n.length)return{then:()=>o};const r=yC(t,e,{type:"GET",path:n.map(t=>t.toString())}).then(mC);return r.then.bind(r)}return fC(t,e,[...n,A])},set(r,o,A){lC(i);const[s,a]=vC(A);return yC(t,e,{type:"SET",path:[...n,o].map(t=>t.toString()),value:s},a).then(mC)},apply(r,o,A){lC(i);const s=n[n.length-1];if(s===eC)return yC(t,e,{type:"ENDPOINT"}).then(mC);if("bind"===s)return fC(t,e,n.slice(0,-1));const[a,c]=gC(A);return yC(t,e,{type:"APPLY",path:n.map(t=>t.toString()),argumentList:a},c).then(mC)},construct(r,o){lC(i);const[A,s]=gC(o);return yC(t,e,{type:"CONSTRUCT",path:n.map(t=>t.toString()),argumentList:A},s).then(mC)}});return function(t,e){const n=(hC.get(e)||0)+1;hC.set(e,n),dC&&dC.register(t,e,t)}(o,t),o}function gC(t){const e=t.map(vC);return[e.map(t=>t[0]),(n=e.map(t=>t[1]),Array.prototype.concat.apply([],n))];var n}const pC=new WeakMap;function vC(t){for(const[e,n]of AC)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},pC.get(t)||[]]}function mC(t){switch(t.type){case"HANDLER":return AC.get(t.name).deserialize(t.value);case"RAW":return t.value}}function yC(t,e,n,r){return new Promise(i=>{const o=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.set(o,i),t.start&&t.start(),t.postMessage(Object.assign({id:o},n),r)})}class wC{constructor(){this.worker=null,this.workerApi=null}execute(t,e,n){return px(this,0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw new Error("Worker API not initialized");return yield this.workerApi.execute(t,e,n)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return px(this,0,void 0,function*(){const t=this.resolveWorkerPath(),e=t.includes("/lib/")||t.endsWith(".mjs")?"module":"classic";this.worker=new Worker(t,{type:e}),this.workerApi=cC(this.worker)})}resolveWorkerPath(){const t=(()=>{if("undefined"==typeof document)return null;const t=document.currentScript;if(null==t?void 0:t.src)return t.src;const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t--){const n=e[t].src;if(n&&(n.includes("index.js")||n.includes("index.min.js")))return n}return null})();if(t){if(t.includes("index.js")||t.includes("index.min.js")){const e=t.replace(/index(\.min)?\.(m?js)(\?.*)?$/,"worker.js");if(e!==t)return e}const e=t.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(e!==t)return e;const n=t.replace(/\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(n!==t)return n}return"./worker.js"}}class bC{constructor(t){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),t)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(t,e){return Object.assign({},t,e||{})}execute(t,e){return px(this,0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,e);const{node:n,edge:r,enableWorker:i}=this.runtimeOptions;this.context=new Jx(t,{node:n,edge:r}),this.model=this.context.graph;i&&"undefined"!=typeof Worker?yield this.layoutInWorker(t,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(t,e){var n;return px(this,0,void 0,function*(){try{this.supervisor||(this.supervisor=new wC);const r=yield this.supervisor.execute(this.id,t,e);null===(n=this.context)||void 0===n||n.replace(r)}catch(t){console.error("Layout in worker failed, fallback to main thread layout.",t),yield this.layout(e)}})}forEachNode(t){this.context.forEachNode(t)}forEachEdge(t){this.context.forEachEdge(t)}destroy(){var t;null===(t=this.context)||void 0===t||t.destroy(),this.model=null,this.context=null,this.supervisor&&(this.supervisor.destroy(),this.supervisor=null)}}class BC extends bC{}function EC(t){return!!t.tick&&!!t.stop}class xC{constructor(t={}){this.options=t,this.nodes=new Map,this.edges=new Map,this.inEdges=new Map,this.outEdges=new Map,this.parentMap=new Map,this.childrenMap=new Map,t.tree&&Array.isArray(t.tree)&&t.tree.length>0&&("string"==typeof t.tree[0]?t.tree.forEach(t=>{this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map)}):(this.attachTreeStructure("default"),this.addTree(t.tree))),t.nodes&&t.nodes.forEach(t=>this.addNode(t)),t.edges&&t.edges.forEach(t=>this.addEdge(t))}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.inEdges.set(t.id,new Set),this.outEdges.set(t.id,new Set))}addNodes(t){t.forEach(t=>this.addNode(t))}getNode(t){return this.nodes.get(t)}hasNode(t){return this.nodes.has(t)}removeNode(t){if(!this.nodes.has(t))return;const e=Array.from(this.inEdges.get(t)||[]),n=Array.from(this.outEdges.get(t)||[]);e.forEach(t=>this.removeEdge(t)),n.forEach(t=>this.removeEdge(t)),this.nodes.delete(t),this.inEdges.delete(t),this.outEdges.delete(t),this.parentMap.forEach(e=>{e.delete(t)}),this.childrenMap.forEach(e=>{e.delete(t)})}getAllNodes(){return Array.from(this.nodes.values())}addEdge(t){if(!this.nodes.has(t.source)||!this.nodes.has(t.target))throw new Error(`Cannot add edge ${t.id}: source ${t.source} or target ${t.target} does not exist`);this.edges.set(t.id,t),this.outEdges.get(t.source).add(t.id),this.inEdges.get(t.target).add(t.id)}addEdges(t){t.forEach(t=>this.addEdge(t))}getEdge(t){return this.edges.get(t)}hasEdge(t){return this.edges.has(t)}removeEdge(t){var e,n;const r=this.edges.get(t);r&&(this.edges.delete(t),null===(e=this.outEdges.get(r.source))||void 0===e||e.delete(t),null===(n=this.inEdges.get(r.target))||void 0===n||n.delete(t))}getAllEdges(){return Array.from(this.edges.values())}updateEdgeData(t,e){const n=this.edges.get(t);n&&Object.assign(n.data,e)}updateNodeData(t,e){const n=this.nodes.get(t);n&&Object.assign(n.data,e)}getRelatedEdges(t,e="both"){const n=[];if("in"===e||"both"===e){const e=this.inEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&n.push(e)})}if("out"===e||"both"===e){const e=this.outEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&n.push(e)})}return n}getSuccessors(t){const e=this.outEdges.get(t);if(!e||0===e.size)return[];const n=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.target);t&&n.push(t)}}),n.length>0?n:[]}getPredecessors(t){const e=this.inEdges.get(t);if(!e||0===e.size)return[];const n=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.source);t&&n.push(t)}}),n.length>0?n:[]}getNeighbors(t){const e=[...this.getSuccessors(t)||[],...this.getPredecessors(t)||[]],n=Array.from(new Map(e.map(t=>[t.id,t])).values());return n.length>0?n:[]}attachTreeStructure(t){this.parentMap.has(t)||(this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map))}addTree(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default");this.hasTreeStructure(i)||this.attachTreeStructure(i);const o=Array.isArray(t)?t:[t],A=(t,e)=>{this.addNode({id:t.id,data:t.data}),void 0!==e&&this.setParent(t.id,e,i),t.children&&t.children.length>0&&t.children.forEach(e=>{A(e,t.id)})};o.forEach(t=>A(t))}hasTreeStructure(t){return this.parentMap.has(t)}setParent(t,e,n){var r,i,o;const A=n||(null!==(i=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==i?i:"default");this.parentMap.has(A)||this.attachTreeStructure(A);const s=this.parentMap.get(A),a=this.childrenMap.get(A),c=s.get(t);void 0!==c&&(null===(o=a.get(c))||void 0===o||o.delete(t)),s.set(t,e),a.has(e)||a.set(e,new Set),a.get(e).add(t)}getParent(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default");this.parentMap.has(i)||this.attachTreeStructure(i);const o=this.parentMap.get(i);if(!o)return;const A=o.get(t);return void 0===A?null:this.nodes.get(A)}getChildren(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default"),o=this.childrenMap.get(i);if(!o)return[];const A=o.get(t);return A?Array.from(A).map(t=>this.nodes.get(t)).filter(t=>void 0!==t):[]}getRoots(t){var e,n;const r=t||(null!==(n=null===(e=this.options.tree)||void 0===e?void 0:e[0])&&void 0!==n?n:"default"),i=this.parentMap.get(r),o=[];return this.nodes.forEach(t=>{i&&void 0!==i.get(t.id)||o.push(t)}),o}dfsTree(t,e){const n=[t],r=new Set;for(;n.length>0;){const t=n.pop();if(r.has(t))continue;const i=this.getNode(t);if(i){r.add(t);if(!0===e(i))continue;const o=this.getChildren(t);for(let t=o.length-1;t>=0;t--)r.has(o[t].id)||n.push(o[t].id)}}}}const CC=(t,e)=>{if("next"!==t&&"prev"!==t)return e},MC=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let FC=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return MC(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&MC(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let n=e.prev;for(;n!==e;)t.push(JSON.stringify(n,CC)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}};class kC extends FC{}const SC=()=>1,QC=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let A;for(;t.getAllNodes().length;){for(;A=o.dequeue();)UC(t,e,n,A);for(;A=i.dequeue();)UC(t,e,n,A);if(t.getAllNodes().length)for(let i=e.length-2;i>0;--i)if(A=e[i].dequeue(),A){r=r.concat(UC(t,e,n,A,!0));break}}return r},UC=(t,e,n,r,i)=>{var o,A;const s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach(r=>{const o=r.data.weight,A=t.getNode(r.source);i&&s.push({v:r.source,w:r.target,in:0,out:0}),void 0===A.data.out&&(A.data.out=0),A.data.out-=o,TC(e,n,Object.assign({v:A.id},A.data))}),null===(A=t.getRelatedEdges(r.v,"out"))||void 0===A||A.forEach(r=>{const i=r.data.weight,o=r.target,A=t.getNode(o);void 0===A.data.in&&(A.data.in=0),A.data.in-=i,TC(e,n,Object.assign({v:A.id},A.data))}),t.removeNode(r.v)),i?s:void 0},NC=(t,e)=>{const n=new xC;let r=0,i=0;t.getAllNodes().forEach(t=>{n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})}),t.getAllEdges().forEach(t=>{const o=n.getRelatedEdges(t.source,"out").find(e=>e.target===t.target),A=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,Object.assign(Object.assign({},o.data),{weight:o.data.weight+A})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:A}}),i=Math.max(i,n.getNode(t.source).data.out+=A),r=Math.max(r,n.getNode(t.target).data.in+=A)});const o=[],A=i+r+3;for(let t=0;t<A;t++)o.push(new kC);const s=r+1;return n.getAllNodes().forEach(t=>{TC(o,s,Object.assign({v:t.id},n.getNode(t.id).data))}),{buckets:o,zeroIdx:s,graph:n}},TC=(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)},OC=(t,e)=>{const n=((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=NC(t,e||SC);return null===(n=QC(r.graph,r.buckets,r.zeroIdx).map(e=>t.getRelatedEdges(e.v,"out").filter(({target:t})=>t===e.w)))||void 0===n?void 0:n.flat()})(t,t=>t.data.weight||1);null==n||n.forEach(e=>{const n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},n)})})},IC=(t,e,n,r)=>{let i;do{i=`${r}${Math.random()}`}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},LC=t=>{const e=new xC;return t.getAllNodes().forEach(n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))}),t.getAllEdges().forEach(t=>{e.addEdge(t)}),e},PC=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let A,s,a=Number(t.width)/2,c=Number(t.height)/2;return i||o?(Math.abs(o)*a>Math.abs(i)*c?(o<0&&(c=-c),A=c*i/o,s=c):(i<0&&(a=-a),A=a,s=a*o/i),{x:n+A,y:r+s}):{x:0,y:0}},DC=t=>{const e=[],n=HC(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach(t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)});for(let r=0;r<n;r++)e[r]=e[r].sort((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i});return e},RC=(t,e,n,r)=>{const i={width:0,height:0};return Rx(n)&&Rx(r)&&(i.rank=n,i.order=r),IC(t,"border",i,e)},HC=t=>{let e;return t.getAllNodes().forEach(t=>{const n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)}),e||(e=0),e},_C=(t,e)=>t.reduce((t,n)=>e(t)>e(n)?n:t),GC=(t,e,n,r,i,o)=>{if(!r.includes(e.id)){r.push(e.id),n||o.push(e.id);const A=i(e.id);A&&A.forEach(e=>GC(t,e,n,r,i,o)),n&&o.push(e.id)}},KC=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>t.getNeighbors(e),A=[],s=[];return i.forEach(e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);GC(t,e,"post"===n,s,o,A)}),A},jC=(t,e,n,r,i,o)=>{const A={rank:o,borderType:e,width:0,height:0},s=o-i.data.minRank,a=i.data[e][s-1],c=IC(t,"border",A,n);i.data[e][s]=c,t.setParent(c,r),a&&t.addEdge({id:`e${Math.random()}`,source:a,target:c,data:{weight:1}})},zC=t=>{t.getAllNodes().forEach(t=>{VC(t)}),t.getAllEdges().forEach(t=>{VC(t)})},VC=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},WC=t=>{t.getAllNodes().forEach(t=>{YC(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>YC(t)),t.data.hasOwnProperty("y")&&YC(t.data)})},YC=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},XC=t=>{t.getAllNodes().forEach(t=>{qC(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>qC(t)),t.data.hasOwnProperty("x")&&qC(t.data)})},qC=t=>{const e=t.x;t.x=t.y,t.y=e},$C=(t,e,n,r,i,o,A)=>{const s=t.getChildren(A);if(!(null==s?void 0:s.length))return void(A!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:A,data:{weight:0,minlen:n}}));const a=RC(t,"_bt"),c=RC(t,"_bb"),l=t.getNode(A);t.setParent(a,A),l.data.borderTop=a,t.setParent(c,A),l.data.borderBottom=c,null==s||s.forEach(s=>{$C(t,e,n,r,i,o,s.id);const l=s.data.borderTop?s.data.borderTop:s.id,u=s.data.borderBottom?s.data.borderBottom:s.id,h=s.data.borderTop?r:2*r,d=l!==u?1:i-o[A]+1;t.addEdge({id:`e${Math.random()}`,source:a,target:l,data:{minlen:d,weight:h,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:u,target:c,data:{minlen:d,weight:h,nestingEdge:!0}})}),t.getParent(A)||t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:i+o[A]}})},ZC=t=>{const e={},n=(r,i)=>{const o=t.getChildren(r);null==o||o.forEach(t=>n(t.id,i+1)),e[r]=i};return t.getRoots().forEach(t=>n(t.id,1)),e},JC=t=>{let e=0;return t.getAllEdges().forEach(t=>{e+=t.data.weight}),e},tM="edge-label",eM=(t,e,n)=>{let r=e.source,i=t.getNode(r).data.rank;const o=e.target,A=t.getNode(o).data.rank,s=e.data.labelRank;if(A===i+1)return;let a,c,l;for(t.removeEdge(e.id),l=0,++i;i<A;++l,++i)e.data.points=[],c={originalEdge:e,width:0,height:0,rank:i},a=IC(t,"edge",c,"_d"),i===s&&(c.width=e.data.width,c.height=e.data.height,c.dummy=tM,c.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:a,data:{weight:e.data.weight}}),0===l&&n.push(a),r=a;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},nM=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},rM=(t,e,n)=>{const r=((t,e)=>null==t?void 0:t.reduce((t,n,r)=>(t[n]=e[r],t),{}))(n,n.map((t,e)=>e)),i=e.map(e=>{const n=t.getRelatedEdges(e,"out").map(t=>({pos:r[t.target]||0,weight:t.data.weight}));return null==n?void 0:n.sort((t,e)=>t.pos-e.pos)}),o=i.flat().filter(t=>void 0!==t);let A=1;for(;A<n.length;)A<<=1;const s=2*A-1;A-=1;const a=Array(s).fill(0,0,s);let c=0;return null==o||o.forEach(t=>{if(t){let e=t.pos+A;a[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=a[e+1]),e=e-1>>1,a[e]+=t.weight;c+=t.weight*n}}),c},iM=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=rM(t,e[r-1],e[r]);return n},oM=t=>{const e={},n=t.getAllNodes(),r=n.map(t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0}),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o.push([]);const A=n.sort((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank),s=A.filter(e=>void 0!==t.getNode(e.id).data.fixorder),a=s.sort((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder);return null==a||a.forEach(n=>{isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0}),null==A||A.forEach(n=>t.dfsTree(n.id,t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)})),o},AM=t=>{var e,n;const r=[];for(;null==t?void 0:t.length;){const i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach(t=>{return(e=i,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&sM(e,t)})(t);var e}),null===(n=i.out)||void 0===n||n.forEach(e=>{return(n=i,e=>{e.in.push(n),0===--e.indegree&&t.push(e)})(e);var n})}const i=r.filter(t=>!t.merged),o=["vs","i","barycenter","weight"];return i.map(t=>{const e={};return null==o||o.forEach(n=>{void 0!==t[n]&&(e[n]=t[n])}),e})},sM=(t,e)=>{var n;let r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},aM=(t,e,n)=>{let r,i=n;for(;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},cM=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i},lM=(t,e,n,r,i,o)=>{var A,s,a,c;let l=t.getChildren(e).map(t=>t.id);const u=t.getNode(e),h=u?u.data.borderLeft:void 0,d=u?u.data.borderRight:void 0,f={};h&&(l=null==l?void 0:l.filter(t=>t!==h&&t!==d));const g=((t,e)=>e.map(e=>{const n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};const r={sum:0,weight:0};return null==n||n.forEach(e=>{const n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight}),{v:e,barycenter:r.sum/r.weight,weight:r.weight}}))(t,l||[]);null==g||g.forEach(e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=lM(t,e.v,n,r,o);f[e.v]=i,i.hasOwnProperty("barycenter")&&hM(e,i)}});const p=((t,e)=>{var n,r,i;const o={};null==t||t.forEach((t,e)=>{o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)}),null===(n=e.getAllEdges())||void 0===n||n.forEach(t=>{const e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))});const A=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,t=>!t.indegree);return AM(A)})(g,n);uM(p,f),null===(A=p.filter(t=>t.vs.length>0))||void 0===A||A.forEach(e=>{const n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)});const v=((t,e,n,r)=>{const i=((t,e)=>{const n={lhs:[],rhs:[]};return null==t||t.forEach(t=>{e(t)?n.lhs.push(t):n.rhs.push(t)}),n})(t,t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")}),o=i.lhs,A=i.rhs.sort((t,e)=>-t.i- -e.i),s=[];let a=0,c=0,l=0;null==o||o.sort(cM(!!e,!!n)),l=aM(s,A,l),null==o||o.forEach(t=>{var e;l+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),a+=t.barycenter*t.weight,c+=t.weight,l=aM(s,A,l)});const u={vs:s.flat()};return c&&(u.barycenter=a/c,u.weight=c),u})(p,r,i,o);if(h&&(v.vs=[h,v.vs,d].flat(),null===(s=t.getPredecessors(h))||void 0===s?void 0:s.length)){const e=t.getNode((null===(a=t.getPredecessors(h))||void 0===a?void 0:a[0].id)||""),n=t.getNode((null===(c=t.getPredecessors(d))||void 0===c?void 0:c[0].id)||"");v.hasOwnProperty("barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+e.data.order+n.data.order)/(v.weight+2),v.weight+=2}return v},uM=(t,e)=>{null==t||t.forEach(t=>{var n;const r=null===(n=t.vs)||void 0===n?void 0:n.map(t=>e[t]?e[t].vs:t);t.vs=r.flat()})},hM=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)};function dM(t){return Array.isArray(t)}var fM=function(t){if("object"!=typeof t||null===t)return t;var e;if(dM(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=fM(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=fM(t[i]):e[i]=t[i];return e};const gM=(t,e,n)=>e.map(e=>((t,e,n)=>{const r=nM(t),i=new xC;return i.addNode({id:r,data:{}}),t.getAllNodes().forEach(o=>{var A,s;const a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(Object.assign({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach(e=>{const n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(Object.assign({},t.getNode(n)));const r=i.getRelatedEdges(n,"out").find(({target:t})=>t===o.id),A=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,Object.assign(Object.assign({},r.data),{weight:e.data.weight+A})):i.addEdge({id:e.id,source:n,target:o.id,data:{weight:e.data.weight+A}})}),o.data.hasOwnProperty("minRank")&&i.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:[null===(A=o.data.borderLeft)||void 0===A?void 0:A[e-o.data.minRank]],borderRight:[null===(s=o.data.borderRight)||void 0===s?void 0:s[e-o.data.minRank]]})))}),i})(t,e,n)),pM=(t,e,n,r)=>{const i=new xC;null==t||t.forEach(t=>{var o;const A=t.getRoots()[0].id,s=lM(t,A,i,e,n,r);for(let e=0;e<(null===(o=s.vs)||void 0===o?void 0:o.length);e++){const n=t.getNode(s.vs[e]);n&&(n.data.order=e)}((t,e,n)=>{const r={};let i;null==n||n.forEach(n=>{let o,A,s=t.getParent(n);for(;s;){if(o=t.getParent(s.id),o?(A=r[o.id],r[o.id]=s.id):(A=i,i=s.id),A&&A!==s.id)return e.hasNode(A)||e.addNode({id:A,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${A}-${s.id}`)||e.addEdge({id:`e${A}-${s.id}`,source:A,target:s.id,data:{}}));s=o}})})(t,i,s.vs)})},vM=(t,e)=>{null==e||e.forEach(e=>{null==e||e.forEach((e,n)=>{t.getNode(e).data.order=n})})},mM=(t,e)=>{const n=(t=>{const e={};let n=0;const r=i=>{const o=n;t.getChildren(i).forEach(t=>r(t.id)),e[i]={low:o,lim:n++}};return t.getRoots().forEach(t=>r(t.id)),e})(t);e.forEach(e=>{var r,i;let o=e,A=t.getNode(o);const s=A.data.originalEdge;if(!s)return;const a=((t,e,n,r)=>{var i,o;const A=[],s=[],a=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);let l,u;l=n;do{l=null===(i=t.getParent(l))||void 0===i?void 0:i.id,A.push(l)}while(l&&(e[l].low>a||c>e[l].lim));for(u=l,l=r;l&&l!==u;)s.push(l),l=null===(o=t.getParent(l))||void 0===o?void 0:o.id;return{lca:u,path:A.concat(s.reverse())}})(t,n,s.source,s.target),c=a.path,l=a.lca;let u=0,h=c[u],d=!0;for(;o!==s.target;){if(A=t.getNode(o),d){for(;h!==l&&(null===(r=t.getNode(h))||void 0===r?void 0:r.data.maxRank)<A.data.rank;)u++,h=c[u];h===l&&(d=!1)}if(!d){for(;u<c.length-1&&(null===(i=t.getNode(c[u+1]))||void 0===i?void 0:i.data.minRank)<=A.data.rank;)u++;h=c[u]}t.hasNode(h)&&t.setParent(o,h),o=t.getSuccessors(o)[0].id}})},yM=(t,e)=>{const n={};function r(e,r){const i=function(t){return JSON.stringify(t.slice(1))}(e);r.get(i)||(!function(e,r,i,o,A){var s,a;let c;for(let l=r;l<i;l++)c=e[l],(null===(s=t.getNode(c))||void 0===s?void 0:s.data.dummy)&&(null===(a=t.getPredecessors(c))||void 0===a||a.forEach(e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>A)&&bM(n,e.id,c)}))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,A=0;const s=new Map;return null==n||n.forEach((a,c)=>{var l;if("border"===(null===(l=t.getNode(a))||void 0===l?void 0:l.data.dummy)){const e=t.getPredecessors(a)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,A,c,o,i],s),A=c,o=i)}r([n,A,n.length,i,e.length],s)}),n};return(null==e?void 0:e.length)&&e.reduce(i),n},wM=(t,e)=>{var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find(e=>t.getNode(e.id).data.dummy)},bM=(t,e,n)=>{let r=e,i=n;if(r>i){const t=r;r=i,i=t}let o=t[r];o||(t[r]=o={}),o[i]=!0},BM=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},EM=(t,e,n,r,i,o)=>{const A=new xC,s=xM(r,i,o);return null==e||e.forEach(e=>{let r;null==e||e.forEach(e=>{const i=n[e];if(A.hasNode(i)||A.addNode({id:i,data:{}}),r){const o=n[r],a=A.getRelatedEdges(o,"out").find(t=>t.target===i);a?A.updateEdgeData(a.id,Object.assign(Object.assign({},a.data),{weight:Math.max(s(t,e,r),a.data.weight||0)})):A.addEdge({id:`e${Math.random()}`,source:o,target:i,data:{weight:Math.max(s(t,e,r),0)}})}r=e})}),A};const xM=(t,e,n)=>(r,i,o)=>{const A=r.getNode(i),s=r.getNode(o);let a=0,c=0;if(a+=A.data.width/2,A.data.hasOwnProperty("labelpos"))switch((A.data.labelpos||"").toLowerCase()){case"l":c=-A.data.width/2;break;case"r":c=A.data.width/2}if(c&&(a+=n?c:-c),c=0,a+=(A.data.dummy?e:t)/2,a+=(s.data.dummy?e:t)/2,a+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(a+=n?c:-c),c=0,a},CM=(t,e)=>t.getNode(e).data.width||0,MM=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=DC(t),A=Object.assign(((t,e)=>{const n={},r=(e,r)=>{let i=0,o=0;const A=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach((e,a)=>{var c;const l=wM(t,e),u=l?t.getNode(l.id).data.order:A;(l||e===s)&&(null===(c=r.slice(o,a+1))||void 0===c||c.forEach(e=>{var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach(r=>{var o;const A=t.getNode(r.id),s=A.data.order;!(s<i||u<s)||A.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||bM(n,r.id,e)})}),o=a+1,i=u)}),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),yM(t,o)),s={};let a=[];["u","d"].forEach(e=>{a="u"===e?o:Object.values(o).reverse(),["l","r"].forEach(n=>{"r"===n&&(a=a.map(t=>Object.values(t).reverse()));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),c=((t,e,n,r)=>{const i={},o={},A={};return null==e||e.forEach(t=>{null==t||t.forEach((t,e)=>{i[t]=t,o[t]=t,A[t]=e})}),null==e||e.forEach(t=>{let e=-1;null==t||t.forEach(t=>{let s=r(t).map(t=>t.id);if(s.length){s=s.sort((t,e)=>A[t]-A[e]);const r=(s.length-1)/2;for(let a=Math.floor(r),c=Math.ceil(r);a<=c;++a){const r=s[a];o[t]===t&&e<A[r]&&!BM(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=A[r])}}})}),{root:i,align:o}})(0,a,A,o),l=((t,e,n,r,i,o,A)=>{var s;const a={},c=EM(t,e,n,i,o,A),l=A?"borderLeft":"borderRight",u=(t,e)=>{let n=c.getAllNodes(),r=n.pop();const i={};for(;r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return u(t=>{a[t]=(c.getRelatedEdges(t,"in")||[]).reduce((t,e)=>Math.max(t,(a[e.source]||0)+e.data.weight),0)},c.getPredecessors.bind(c)),u(e=>{const n=(c.getRelatedEdges(e,"out")||[]).reduce((t,e)=>Math.min(t,(a[e.target]||0)-e.data.weight),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==l&&(a[e]=Math.max(a[e],n))},c.getSuccessors.bind(c)),null===(s=Object.values(r))||void 0===s||s.forEach(t=>{a[t]=a[n[t]]}),a})(t,a,c.root,c.align,r,i,"r"===n);"r"===n&&Object.keys(l).forEach(t=>l[t]=-l[t]),s[e+n]=l})});const c=((t,e)=>_C(Object.values(e),e=>{var n;let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach(n=>{const o=e[n],A=CM(t,n)/2;r=Math.max(o+A,r),i=Math.min(o-A,i)}),r-i}))(t,s);return c&&function(t,e){const n=Object.values(e),r=Math.min(...n),i=Math.max(...n);["u","d"].forEach(n=>{["l","r"].forEach(o=>{const A=n+o,s=t[A];let a;if(s===e)return;const c=Object.values(s);a="l"===o?r-Math.min(...c):i-Math.max(...c),a&&(t[A]={},Object.keys(s).forEach(e=>{t[A][e]=s[e]+a}))})})}(s,c),((t,e)=>{const n={};return Object.keys(t.ul).forEach(r=>{if(e)n[r]=t[e.toLowerCase()][r];else{const e=Object.values(t).map(t=>t[r]);n[r]=(e[0]+e[1])/2}}),n})(s,n)},FM=(t,e)=>{var n;const r=LC(t);((t,e)=>{const{ranksep:n=0}=e||{},r=DC(t);let i=0;null==r||r.forEach(e=>{const r=e.map(e=>t.getNode(e).data.height),o=Math.max(...r,0);null==e||e.forEach(e=>{t.getNode(e).data.y=i+o/2}),i+=o+n})})(r,e);const i=MM(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach(t=>{r.getNode(t).data.x=i[t]})},kM=t=>{const e={},n=r=>{var i;const o=t.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;let A;return e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach(t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===A||e<A)&&(A=e)}),A||(A=0),o.data.rank=A,A};t.getAllNodes().filter(e=>0===t.getRelatedEdges(e.id,"in").length).forEach(t=>n(t.id))},SM=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,QM=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach(i=>{const o=i.source,A=r===o?i.target:o;t.hasNode(A)||SM(e,i)||(t.addNode({id:A,data:{}}),t.addEdge({id:i.id,source:r,target:A,data:{}}),n(A))})};return t.getAllNodes().forEach(t=>n(t.id)),t.getAllNodes().length},UM=(t,e)=>{const n=r=>{var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach(i=>{const o=i.source,A=r===o?i.target:o;t.hasNode(A)||void 0===e.getNode(A).data.layer&&SM(e,i)||(t.addNode({id:A,data:{}}),t.addEdge({id:i.id,source:r,target:A,data:{}}),n(A))})};return t.getAllNodes().forEach(t=>n(t.id)),t.getAllNodes().length},NM=(t,e)=>_C(e.getAllEdges(),n=>t.hasNode(n.source)!==t.hasNode(n.target)?SM(e,n):1/0),TM=(t,e,n)=>{t.getAllNodes().forEach(t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n})},OM=t=>{const e=(t=>{const e=new xC;return t.getAllNodes().forEach(t=>{e.addNode(Object.assign({},t))}),t.getAllEdges().forEach(t=>{const n=e.getRelatedEdges(t.source,"out").find(e=>e.target===t.target);n?e.updateEdgeData(null==n?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})}),e})(t);kM(e);const n=(t=>{const e=new xC({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);QM(e,t)<r;)i=NM(e,t),o=e.hasNode(i.source)?SM(t,i):-SM(t,i),TM(e,t,o);return e})(e);let r,i;for(DM(n),IM(n,e);r=HM(n);)i=_M(n,e,r),GM(n,e,r,i)},IM=(t,e)=>{let n=KC(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach(n=>{LM(t,e,n)})},LM=(t,e,n)=>{const r=t.getNode(n).data.parent,i=t.getRelatedEdges(n,"both").find(t=>t.target===r||t.source===r);i.data.cutvalue=PM(t,e,n)},PM=(t,e,n)=>{const r=t.getNode(n).data.parent;let i=!0,o=e.getRelatedEdges(n,"out").find(t=>t.target===r),A=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find(t=>t.target===n)),A=o.data.weight,e.getRelatedEdges(n,"both").forEach(e=>{const o=e.source===n,s=o?e.target:e.source;if(s!==r){const r=o===i,a=e.data.weight;if(A+=r?a:-a,jM(t,n,s)){const e=t.getRelatedEdges(n,"both").find(t=>t.source===s||t.target===s).data.cutvalue;A+=r?-e:e}}}),A},DM=(t,e=t.getAllNodes()[0].id)=>{RM(t,{},1,e)},RM=(t,e,n,r,i)=>{var o;const A=n;let s=n;const a=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach(n=>{e[n.id]||(s=RM(t,e,s,n.id,r))}),a.data.low=A,a.data.lim=s++,i?a.data.parent=i:delete a.data.parent,s},HM=t=>t.getAllEdges().find(t=>t.data.cutvalue<0),_M=(t,e,n)=>{let r=n.source,i=n.target;e.getRelatedEdges(r,"out").find(t=>t.target===i)||(r=n.target,i=n.source);const o=t.getNode(r),A=t.getNode(i);let s=o,a=!1;o.data.lim>A.data.lim&&(s=A,a=!0);const c=e.getAllEdges().filter(e=>a===zM(t.getNode(e.source),s)&&a!==zM(t.getNode(e.target),s));return _C(c,t=>SM(e,t))},GM=(t,e,n,r)=>{const i=t.getRelatedEdges(n.source,"both").find(t=>t.source===n.target||t.target===n.target);i&&t.removeEdge(i.id),t.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),DM(t),IM(t,e),KM(t,e)},KM=(t,e)=>{const n=t.getAllNodes().find(t=>!t.data.parent);let r=KC(t,n,"pre");r=r.slice(1),r.forEach(n=>{const r=t.getNode(n).data.parent;let i=e.getRelatedEdges(n,"out").find(t=>t.target===r),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find(t=>t.target===n),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))})},jM=(t,e,n)=>t.getRelatedEdges(e,"both").find(t=>t.source===n||t.target===n),zM=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,VM=kM,WM=t=>{(t=>{const e={};let n;const r=i=>{var o;const A=t.getNode(i);if(!A)return 0;if(e[i])return A.data.rank;let s;return e[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach(t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)}),s||(s=0),(void 0===n||s<n)&&(n=s),A.data.rank=s,s};t.getAllNodes().filter(e=>0===t.getRelatedEdges(e.id,"in").length).forEach(t=>{t&&r(t.id)}),void 0===n&&(n=0);const i={},o=(e,n)=>{var r;const A=t.getNode(e),s=isNaN(A.data.layer)?n:A.data.layer;(void 0===A.data.rank||A.data.rank<s)&&(A.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach(t=>{o(t.target,s+t.data.minlen)}))};t.getAllNodes().forEach(t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=n:o(t.id,e.layer))})})(t),(t=>{const e=new xC({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);UM(e,t)<r;)i=NM(e,t),o=e.hasNode(i.source)?SM(t,i):-SM(t,i),TM(e,t,o)})(t)},YM=t=>{OM(t)},XM=(t,e)=>{const{ranker:n,rankdir:r="tb",nodeOrder:i,keepNodeOrder:o,align:A,nodesep:s=50,edgesep:a=20,ranksep:c=50}=e;dF(t),OC(t);const{nestingRoot:l,nodeRankFactor:u}=(t=>{const e=IC(t,"root",{},"_root"),n=ZC(t);let r=Math.max(...Object.values(n));Math.abs(r)===1/0&&(r=1);const i=r-1,o=2*i+1;t.getAllEdges().forEach(t=>{t.data.minlen*=o});const A=JC(t)+1;return t.getRoots().forEach(r=>{$C(t,e,o,A,i,n,r.id)}),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":YM(t);break;case"tight-tree":default:WM(t);break;case"longest-path":VM(t)}})(LC(t),n),oF(t),((t,e=0)=>{const n=t.getAllNodes(),r=n.filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),i=Math.min(...r),o=[];n.forEach(t=>{const e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)});let A=0;for(let n=0;n<o.length;n++){const r=o[n];void 0===r?n%e!==0&&(A-=1):A&&(null==r||r.forEach(e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=A)}))}})(t,u),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach(e=>{e.data.nestingEdge&&t.removeEdge(e.id)})})(t,l),(t=>{const e=t.getAllNodes().filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),n=Math.min(...e);t.getAllNodes().forEach(t=>{t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)})})(t),AF(t),sF(t);const h=[];((t,e)=>{t.getAllEdges().forEach(n=>eM(t,n,e))})(t,h),mM(t,h),(t=>{const e=n=>{const r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach(t=>e(t.id)),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let e=i.data.minRank,r=i.data.maxRank+1;e<r;e+=1)jC(t,"borderLeft","_bl",n,i,e),jC(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach(t=>e(t.id))})(t),o&&((t,e)=>{const n=t.getAllNodes().filter(e=>{var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)}),r=n.map(t=>t.data.rank),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o[t]=[];null==e||e.forEach(e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))})})(t,i),((t,e)=>{const n=HC(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=gM(t,r,"in"),A=gM(t,i,"out");let s=oM(t);vM(t,s);let a,c=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){pM(n%2?o:A,n%4>=2,!1,e),s=DC(t);const i=iM(t,s);i<c&&(r=0,a=fM(s),c=i)}s=oM(t),vM(t,s);for(let n=0,r=0;r<4;++n,++r){pM(n%2?o:A,n%4>=2,!0,e),s=DC(t);const i=iM(t,s);i<c&&(r=0,a=fM(s),c=i)}vM(t,a)})(t,o),fF(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||zC(t)})(t,r),FM(t,{align:A,nodesep:s,edgesep:a,ranksep:c}),gF(t),hF(t),((t,e)=>{e.forEach(e=>{let n=t.getNode(e);const{data:r}=n,i=r.originalEdge;let o;i&&t.addEdge(i);let A=e;for(;n.data.dummy;)o=t.getSuccessors(A)[0],t.removeNode(A),i.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===tM&&(i.data.x=n.data.x,i.data.y=n.data.y,i.data.width=n.data.width,i.data.height=n.data.height),A=o.id,n=t.getNode(A)})})(t,h),lF(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||WC(t),"lr"!==n&&"rl"!==n||(XC(t),zC(t))})(t,r);const{width:d,height:f}=aF(t);return cF(t),uF(t),(t=>{t.getAllEdges().forEach(e=>{const n=e.data;if(n.reversed){t.removeEdge(e.id);const r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},n),{forwardName:r})})}})})(t),{width:d,height:f}},qM=(t,e)=>{t.getAllNodes().forEach(n=>{const r=t.getNode(n.id);if(e.hasNode(n.id)){const t=e.getNode(n.id);r.data.fixorder=t.data._order,delete t.data._order}else delete r.data.fixorder})},$M=(t,e)=>{t.getAllNodes().forEach(n=>{var r;const i=t.getNode(n.id);if(i){const t=e.getNode(n.id);i.data.x=t.data.x,i.data.y=t.data.y,i.data._order=t.data.order,i.data._rank=t.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=t.data.width,i.data.height=t.data.height)}}),t.getAllEdges().forEach(n=>{const r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)})},ZM=["width","height","layer","fixorder"],JM={width:0,height:0},tF=["minlen","weight","width","height","labeloffset"],eF={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},nF=["labelpos"],rF=t=>{const e=new xC({tree:[]});return t.getAllNodes().forEach(n=>{const r=vF(t.getNode(n.id).data),i=Object.assign(Object.assign({},JM),r),o=pF(i,ZM);e.hasNode(n.id)||e.addNode({id:n.id,data:Object.assign({},o)});const A=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);_x(A)||(e.hasNode(A.id)||e.addNode(Object.assign({},A)),e.setParent(n.id,A.id))}),t.getAllEdges().forEach(n=>{const r=vF(t.getEdge(n.id).data),i={};null==nF||nF.forEach(t=>{void 0!==r[t]&&(i[t]=r[t])}),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},eF,pF(r,tF),i)})}),e},iF=(t,e)=>{const{ranksep:n=0,rankdir:r}=e;return t.getAllNodes().forEach(t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)}),t.getAllEdges().forEach(t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===r||"BT"===r?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)}),n/2},oF=t=>{t.getAllEdges().forEach(e=>{if(e.data.width&&e.data.height){const n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};IC(t,"edge-proxy",r,"_ep")}})},AF=t=>{let e=0;return t.getAllNodes().forEach(n=>{var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))}),e},sF=t=>{t.getAllNodes().forEach(e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))})},aF=(t,e)=>{let n,r,i=0,o=0;const{marginx:A=0,marginy:s=0}={},a=t=>{if(!t.data)return;const e=t.data.x,A=t.data.y,s=t.data.width,a=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(A)||isNaN(a)||(void 0===r&&(r=A-a/2),r=Math.min(r,A-a/2),o=Math.max(o,A+a/2))};return t.getAllNodes().forEach(t=>{a(t)}),t.getAllEdges().forEach(t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&a(t)}),n-=A,r-=s,t.getAllNodes().forEach(t=>{t.data.x-=n,t.data.y-=r}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>{t.x-=n,t.y-=r}),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)}),{width:i-n+A,height:o-r+s}},cF=t=>{t.getAllEdges().forEach(e=>{const n=t.getNode(e.source),r=t.getNode(e.target);let i,o;e.data.points?(i=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],i={x:r.data.x,y:r.data.y},o={x:n.data.x,y:n.data.y}),e.data.points.unshift(PC(n.data,i)),e.data.points.push(PC(r.data,o))})},lF=t=>{t.getAllEdges().forEach(t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}})},uF=t=>{t.getAllEdges().forEach(t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())})},hF=t=>{t.getAllNodes().forEach(e=>{var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){const n=t.getNode(e.id),o=t.getNode(n.data.borderTop),A=t.getNode(n.data.borderBottom),s=t.getNode(n.data.borderLeft[(null===(r=n.data.borderLeft)||void 0===r?void 0:r.length)-1]),a=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==a?void 0:a.data.x)-(null==s?void 0:s.data.x))||10,n.data.height=Math.abs((null==A?void 0:A.data.y)-(null==o?void 0:o.data.y))||10,n.data.x=((null==s?void 0:s.data.x)||0)+n.data.width/2,n.data.y=((null==o?void 0:o.data.y)||0)+n.data.height/2}}),t.getAllNodes().forEach(e=>{"border"===e.data.dummy&&t.removeNode(e.id)})},dF=t=>{t.getAllEdges().forEach(e=>{if(e.source===e.target){const n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}})},fF=t=>{const e=DC(t);null==e||e.forEach(e=>{let n=0;null==e||e.forEach((e,r)=>{var i;const o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach(e=>{IC(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")}),delete o.data.selfEdges})})},gF=t=>{t.getAllNodes().forEach(e=>{const n=t.getNode(e.id);if("selfedge"===n.data.dummy){const r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,A=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*A/3,y:o-s},{x:i+5*A/6,y:o-s},{y:o,x:i+A},{x:i+5*A/6,y:o+s},{x:i+2*A/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}})},pF=(t,e)=>{const n={};return null==e||e.forEach(e=>{void 0!==t[e]&&(n[e]=+t[e])}),n},vF=(t={})=>{const e={};return Object.keys(t).forEach(n=>{e[n.toLowerCase()]=t[n]}),e},mF={nodeSize:10,nodeSpacing:0,rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class yF extends bC{constructor(){super(...arguments),this.id="antv-dagre"}getDefaultOptions(){return mF}layout(t){return px(this,0,void 0,function*(){const{nodeSize:e,nodeSpacing:n,align:r,rankdir:i="TB",ranksep:o,nodesep:A,edgeLabelSpace:s,ranker:a="tight-tree",nodeOrder:c,begin:l,controlPoints:u,radial:h,sortByCombo:d,preset:f,ranksepFunc:g,nodesepFunc:p}=t,v=zx(g,null!=o?o:50,"node"),m=zx(p,null!=A?A:50,"node");let y=m,w=v;"LR"!==i&&"RL"!==i||(y=v,w=m);const b=new xC({tree:[]}),B=this.model.nodes(),E=this.model.edges(),x=Wx(e,n,mF.nodeSize,mF.nodeSpacing);B.forEach(t=>{var e;const n=t._original,r=x(n),i=w(n),o=y(n),A=r[0]+2*o,s=r[1]+2*i,a=null===(e=t.data)||void 0===e?void 0:e.layer;Rx(a)?b.addNode({id:t.id,data:{width:A,height:s,layer:a,originalWidth:r[0],originalHeight:r[1]}}):b.addNode({id:t.id,data:{width:A,height:s,originalWidth:r[0],originalHeight:r[1]}})}),E.forEach(t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{}})}),d&&(b.attachTreeStructure("combo"),B.forEach(t=>{const e=null==t?void 0:t.parentId;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}));let C=null;(null==f?void 0:f.length)&&(C=new xC,f.forEach(t=>{C.addNode({id:t.id,data:t.data})})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:A}=e;!r&&i&&qM(t,i);const s=rF(t);let a;n&&(e.ranksep=iF(s,{rankdir:o,ranksep:A}));try{a=XM(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}$M(t,s)})(b,{prevGraph:C,edgeLabelSpace:s,keepNodeOrder:!!c,nodeOrder:c||[],acyclicer:"greedy",ranker:a,rankdir:i,nodesep:A,align:r});const M=[0,0];if(l){let t=1/0,e=1/0;b.getAllNodes().forEach(n=>{t>n.data.x&&(t=n.data.x),e>n.data.y&&(e=n.data.y)}),b.getAllEdges().forEach(n=>{var r;null===(r=n.data.points)||void 0===r||r.forEach(n=>{t>n.x&&(t=n.x),e>n.y&&(e=n.y)})}),M[0]=l[0]-t,M[1]=l[1]-e}const F="LR"===i||"RL"===i;if(h);else{const t=new Set,e="BT"===i||"RL"===i?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach(e=>{e.data.x=e.data.x+M[0],e.data.y=e.data.y+M[1],t.add(F?e.data.x:e.data.y)});const n=Array.from(t).sort(e),r=F?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,o=F?(t,e,n)=>{const r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter(t=>t.y<=r&&t.y>=i)}:(t,e,n)=>{const r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter(t=>t.x<=r&&t.x>=i)};b.getAllEdges().forEach((t,e)=>{var i;s&&u&&"loop"!==t.data.type&&(t.data.controlPoints=wF(null===(i=t.data.points)||void 0===i?void 0:i.map(({x:t,y:e})=>({x:t+M[0],y:e+M[1]})),b.getNode(t.source),b.getNode(t.target),n,F,r,o))})}this.model.forEachNode(t=>{const e=b.getNode(t.id);if(e){const{x:n,y:r,width:i,height:o,originalWidth:A,originalHeight:s}=e.data,a=d?b.getChildren(t.id,"combo"):b.getChildren(t.id);if(a.length>0){let e=1/0,n=-1/0,r=1/0,i=-1/0;a.forEach(t=>{const o=t.id,A=b.getNode(o);if(null==A?void 0:A.data){const t=A.data.x,o=A.data.y,s=A.data.originalWidth||A.data.width||0,a=A.data.originalHeight||A.data.height||0;e=Math.min(e,t-s/2),n=Math.max(n,t+s/2),r=Math.min(r,o-a/2),i=Math.max(i,o+a/2)}});const o=20,A=(n-e||0)+2*o,s=(i-r||0)+2*o;t.x=(e+n)/2,t.y=(r+i)/2,t.size=[A,s]}else t.x=n,t.y=r,t.size=[A,s]}}),this.model.forEachEdge(t=>{const e=b.getEdge(t.id);e&&e.data.controlPoints&&(t.points=e.data.controlPoints.map(Yx))})})}}const wF=(t,e,n,r,i,o,A)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){let{x:t,y:a}=e.data,{x:c,y:l}=n.data;if(i&&(t=e.data.y,a=e.data.x,c=n.data.y,l=n.data.x),l!==a&&t!==c){const u=r.indexOf(a),h=r[u+1];if(h){const t=s[0],e=i?{x:(a+h)/2,y:(null==t?void 0:t.y)||c}:{x:(null==t?void 0:t.x)||c,y:(a+h)/2};t&&!o(t,e)||s.unshift(e)}const d=r.indexOf(l),f=Math.abs(d-u);if(1===f)s=A(s,e.data,n.data),s.length||s.push(i?{x:(a+l)/2,y:t}:{x:t,y:(a+l)/2});else if(f>1){const e=r[d-1];if(e){const n=s[s.length-1],r=i?{x:(l+e)/2,y:(null==n?void 0:n.y)||c}:{x:(null==n?void 0:n.x)||t,y:(l+e)/2};n&&!o(n,r)||s.push(r)}}}}return s};function bF(t,e,n=2){if(1===t.nodeCount()){const r=t.firstNode();r.x=e[0],r.y=e[1],3===n&&(r.z=e[2]||0)}}function BF(t,e){const n=t.nodes();return n.sort(e),t.setNodeOrder(n),t}function EF(t,e="desc"){return BF(t,(n,r)=>{const i=t.degree(n.id),o=t.degree(r.id);return"asc"===e?i-o:o-i})}function xF(t,e){return BF(t,(n,r)=>{const i=t.originalNode(n.id),o=t.originalNode(r.id);return e(i,o)})}function CF(t,e=!1){const n=t.nodeCount();if(0===n)return t;const r=t.nodes(),i=[r[0]],o={};o[r[0].id]=!0;let A=0,s=0;return t.forEachNode(a=>{if(0!==s){const c=t.degree(a.id,"both"),l=s<n-1?t.degree(r[s+1].id,"both"):0,u=i[A].id,h=t.neighbors(u,"both").includes(a.id);if(s!==n-1&&c===l&&!h||o[a.id]){const A=e?t.successors(u):t.neighbors(u);let s=!1;for(let e=0;e<A.length;e++){const n=A[e],r=t.node(n);if(r&&t.degree(n)===t.degree(a.id)&&!o[n]){i.push(r),o[n]=!0,s=!0;break}}let c=0;for(;!s&&(o[r[c].id]||(i.push(r[c]),o[r[c].id]=!0,s=!0),c++,c!==n););}else i.push(a),o[a.id]=!0,A++}s++}),t.setNodeOrder(i),t}const MF=t=>{const{width:e,height:n,center:r}=t,i=null!=e?e:"undefined"!=typeof window?window.innerWidth:0,o=null!=n?n:"undefined"!=typeof window?window.innerHeight:0;return{width:i,height:o,center:null!=r?r:[i/2,o/2]}},FF={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1,nodeSize:10,nodeSpacing:0};class kF extends bC{constructor(){super(...arguments),this.id="circular"}getDefaultOptions(){return FF}layout(){return px(this,0,void 0,function*(){const{width:t,height:e,center:n}=MF(this.options),r=this.model.nodeCount();if(!r||1===r)return void bF(this.model,n);const{ordering:i,nodeSpacing:o,nodeSize:A,endAngle:s=2*Math.PI,startAngle:a=0,divisions:c,angleRatio:l,clockwise:u}=this.options;"topology"===i?CF(this.model,!1):"topology-directed"===i?CF(this.model,!0):"degree"===i&&EF(this.model,"asc");let{radius:h,startRadius:d,endRadius:f}=this.options;const g=this.model.nodes(),p=Wx(A,o,FF.nodeSize,FF.nodeSpacing);if(o){let t=0;for(const e of g)t+=Math.max(...p(e._original));h=t/(2*Math.PI)}else h||d||f?!d&&f?d=f:d&&!f&&(f=d):h=Math.min(e,t)/2;const v=(s-a)/r*l,m=Math.ceil(r/c),y=2*Math.PI/c;for(let t=0;t<r;){const e=g[t];let i=h;i||null===d||null===f||(i=d+t*(f-d)/(r-1)),i||(i=10+100*t/(r-1));const o=t%m*v+y*Math.floor(t/m);let A=a+o;u||(A=s-o),e.x=n[0]+Math.cos(A)*i,e.y=n[1]+Math.sin(A)*i,t++}})}}const SF={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class QF extends bC{constructor(){super(...arguments),this.id="concentric"}getDefaultOptions(){return SF}layout(){return px(this,0,void 0,function*(){const{width:t,height:e,center:n}=MF(this.options),r=this.model.nodeCount();if(!r||1===r)return void bF(this.model,n);const{sortBy:i,maxLevelDiff:o,sweep:A,clockwise:s,equidistant:a,preventOverlap:c,startAngle:l=SF.startAngle,nodeSize:u,nodeSpacing:h}=this.options,d=i&&"degree"!==i?jx(i,["node"]):"degree";if("degree"===d)EF(this.model);else{const t=(t,e)=>{const n=d(t),r=d(e);return n===r?0:n>r?-1:1};xF(this.model,t)}const f=this.model.nodes(),g=new Map;for(const t of f){const e="degree"===d?this.model.degree(t.id):d(t._original);g.set(t.id,e)}const p=this.model.firstNode(),v=o||g.get(p.id)/4,m=Wx(u,h,SF.nodeSize,SF.nodeSpacing),y=new Map;for(const t of f)y.set(t.id,Math.max(...m(t._original)));const w=[{nodes:[]}];let b=w[0];for(let t=0;t<r;t++){const e=f[t];if(b.nodes.length>0){const t=b.nodes[0],n=Math.abs(g.get(t.id)-g.get(e.id));v&&n>=v&&(b={nodes:[]},w.push(b))}b.nodes.push(e)}for(const t of w){const e=t.nodes.map(t=>y.get(t.id));t.nodeSizes=e,t.maxNodeSize=Math.max(...e)}if(w.forEach(t=>{const e=void 0===A?2*Math.PI-2*Math.PI/t.nodes.length:A;t.dTheta=e/Math.max(1,t.nodes.length-1)}),c){let t=0;for(let e=0;e<w.length;e++){const n=w[e];if(n.nodes.length>1){const e=n.nodeSizes||[];let r=0;for(let t=0;t<e.length-1;t++)r=Math.max(r,(e[t]+e[t+1])/2);const i=Math.cos(n.dTheta)-Math.cos(0),o=Math.sin(n.dTheta)-Math.sin(0),A=Math.sqrt(i*i+o*o),s=A>0?r/A:0;t=Math.max(s,t)}if(n.r=t,e<w.length-1){const r=w[e+1],i=((n.maxNodeSize||0)+(r.maxNodeSize||0))/2;t+=Math.max(0,i)}}}else{let n=0;w[0].r=0;for(let t=0;t<w.length-1;t++){const e=w[t],r=w[t+1],i=((e.maxNodeSize||0)+(r.maxNodeSize||0))/2;n+=Math.max(0,i),r.r=n}const r=Math.min(t,e)/2;let i=1;for(const t of w){const e=t.r||0;if(e<=0)continue;const n=r-(t.maxNodeSize||0);if(n<=0){i=0;break}i=Math.min(i,n/e)}if(i=Math.max(0,Math.min(1,i)),1!==i)for(const t of w)t.r=(t.r||0)*i}if(a){let t=0,e=0;for(let n=0;n<w.length;n++){const r=(w[n].r||0)-e;t=Math.max(t,r)}e=0,w.forEach((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t})}w.forEach(t=>{const e=t.dTheta||0,r=t.r||0;t.nodes.forEach((t,i)=>{const o=l+(s?1:-1)*e*i;t.x=n[0]+r*Math.cos(o),t.y=n[1]+r*Math.sin(o)})})})}}function UF(t,...e){return e.forEach(e=>{e&&Object.keys(e).forEach(n=>{const r=e[n];void 0!==r&&(t[n]=r)})}),t}const NF=4294967296;var TF,OF,IF=0,LF=0,PF=0,DF=0,RF=0,HF=0,_F="object"==typeof performance&&performance.now?performance:Date,GF="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function KF(){return RF||(GF(jF),RF=_F.now()+HF)}function jF(){RF=0}function zF(){this._call=this._time=this._next=null}function VF(t,e,n){var r=new zF;return r.restart(t,e,n),r}function WF(){RF=(DF=_F.now())+HF,IF=LF=0;try{!function(){KF(),++IF;for(var t,e=TF;e;)(t=RF-e._time)>=0&&e._call.call(void 0,t),e=e._next;--IF}()}finally{IF=0,function(){var t,e,n=TF,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:TF=e);OF=t,XF(r)}(),RF=0}}function YF(){var t=_F.now(),e=t-DF;e>1e3&&(HF-=e,DF=t)}function XF(t){IF||(LF&&(LF=clearTimeout(LF)),t-RF>24?(t<1/0&&(LF=setTimeout(WF,t-_F.now()-HF)),PF&&(PF=clearInterval(PF))):(PF||(DF=_F.now(),PF=setInterval(YF,1e3)),IF=1,GF(WF)))}zF.prototype=VF.prototype={constructor:zF,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?KF():+n)+(null==e?0:+e),this._next||OF===this||(OF?OF._next=this:TF=this,OF=this),this._call=t,this._time=n,XF()},stop:function(){this._call&&(this._call=null,this._time=1/0,XF())}};var qF={value:()=>{}};function $F(){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 ZF(r)}function ZF(t){this._=t}function JF(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function tk(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=qF,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function ek(t){return t.x}function nk(t){return t.y}ZF.prototype=$F.prototype={constructor:ZF,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]=tk(i[n],t.name,e);else if(null==e)for(n in i)i[n]=tk(i[n],t.name,null);return this}for(;++A<s;)if((n=(t=o[A]).type)&&(n=JF(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new ZF(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 rk=Math.PI*(3-Math.sqrt(5));function ik(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,A=.6,s=new Map,a=VF(u),c=$F("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%NF)/NF}();function u(){h(),c.call("tick",e),n<r&&(a.stop(),c.call("end",e))}function h(r){var a,c,l=t.length;void 0===r&&(r=1);for(var u=0;u<r;++u)for(n+=(o-n)*i,s.forEach(function(t){t(n)}),a=0;a<l;++a)null==(c=t[a]).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 d(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),o=n*rk;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,l),e}return null==t&&(t=[]),d(),e={tick:h,restart:function(){return a.restart(u),e},stop:function(){return a.stop(),e},nodes:function(n){return arguments.length?(t=n,d(),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?(l=t,s.forEach(f),e):l},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,a,c=0,l=t.length;for(null==r?r=1/0:r*=r,c=0;c<l;++c)(A=(i=e-(s=t[c]).x)*i+(o=n-s.y)*o)<r&&(a=s,r=A);return a},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function ok(t){return function(){return t}}function Ak(t){var e,n,r,i=ok(.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=ok(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:ok(+t),A(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:ok(+e),A(),o):t},o}function sk(t){var e,n,r,i=ok(.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=ok(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:ok(+t),A(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:ok(+e),A(),o):t},o}function ak(t){return 1e-6*(t()-.5)}function ck(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,A,s,a,c,l,u,h,d=t._root,f={data:r},g=t._x0,p=t._y0,v=t._x1,m=t._y1;if(!d)return t._root=f,t;for(;d.length;)if((c=e>=(o=(g+v)/2))?g=o:v=o,(l=n>=(A=(p+m)/2))?p=A:m=A,i=d,!(d=d[u=l<<1|c]))return i[u]=f,t;if(s=+t._x.call(null,d.data),a=+t._y.call(null,d.data),e===s&&n===a)return f.next=d,i?i[u]=f:t._root=f,t;do{i=i?i[u]=new Array(4):t._root=new Array(4),(c=e>=(o=(g+v)/2))?g=o:v=o,(l=n>=(A=(p+m)/2))?p=A:m=A}while((u=l<<1|c)==(h=(a>=A)<<1|s>=o));return i[h]=d,i[u]=f,t}function lk(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function uk(t){return t[0]}function hk(t){return t[1]}function dk(t,e,n){var r=new fk(null==e?uk:e,null==n?hk:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function fk(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 gk(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var pk=dk.prototype=fk.prototype;function vk(t){return t.x+t.vx}function mk(t){return t.y+t.vy}function yk(t){var e,n,r,i=1,o=1;function A(){for(var t,A,a,c,l,u,h,d=e.length,f=0;f<o;++f)for(A=dk(e,vk,mk).visitAfter(s),t=0;t<d;++t)a=e[t],u=n[a.index],h=u*u,c=a.x+a.vx,l=a.y+a.vy,A.visit(g);function g(t,e,n,o,A){var s=t.data,d=t.r,f=u+d;if(!s)return e>c+f||o<c-f||n>l+f||A<l-f;if(s.index>a.index){var g=c-s.x-s.vx,p=l-s.y-s.vy,v=g*g+p*p;v<f*f&&(0===g&&(v+=(g=ak(r))*g),0===p&&(v+=(p=ak(r))*p),v=(f-(v=Math.sqrt(v)))/v*i,a.vx+=(g*=v)*(f=(d*=d)/(h+d)),a.vy+=(p*=v)*f,s.vx-=g*(f=1-f),s.vy-=p*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 a(){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=ok(null==t?1:+t)),A.initialize=function(t,n){e=t,r=n,a()},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:ok(+e),a(),A):t},A}function wk(){var t,e,n,r,i,o=ok(-30),A=1,s=1/0,a=.81;function c(n){var i,o=t.length,A=dk(t,ek,nk).visitAfter(u);for(r=n,i=0;i<o;++i)e=t[i],A.visit(h)}function l(){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 u(t){var e,n,r,o,A,s=0,a=0;if(t.length){for(r=o=A=0;A<4;++A)(e=t[A])&&(n=Math.abs(e.value))&&(s+=e.value,a+=n,r+=n*e.x,o+=n*e.y);t.x=r/a,t.y=o/a}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 h(t,o,c,l){if(!t.value)return!0;var u=t.x-e.x,h=t.y-e.y,d=l-o,f=u*u+h*h;if(d*d/a<f)return f<s&&(0===u&&(f+=(u=ak(n))*u),0===h&&(f+=(h=ak(n))*h),f<A&&(f=Math.sqrt(A*f)),e.vx+=u*t.value*r/f,e.vy+=h*t.value*r/f),!0;if(!(t.length||f>=s)){(t.data!==e||t.next)&&(0===u&&(f+=(u=ak(n))*u),0===h&&(f+=(h=ak(n))*h),f<A&&(f=Math.sqrt(A*f)));do{t.data!==e&&(d=i[t.data.index]*r/f,e.vx+=u*d,e.vy+=h*d)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,l()},c.strength=function(t){return arguments.length?(o="function"==typeof t?t:ok(+t),l(),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?(a=t*t,c):Math.sqrt(a)},c}function bk(t){return t.index}function Bk(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Ek(t){var e,n,r,i,o,A,s=bk,a=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=ok(30),l=1;function u(r){for(var i=0,s=t.length;i<l;++i)for(var a,c,u,h,d,f,g,p=0;p<s;++p)c=(a=t[p]).source,h=(u=a.target).x+u.vx-c.x-c.vx||ak(A),d=u.y+u.vy-c.y-c.vy||ak(A),h*=f=((f=Math.sqrt(h*h+d*d))-n[p])/f*r*e[p],d*=f,u.vx-=h*(g=o[p]),u.vy-=d*g,c.vx+=h*(g=1-g),c.vy+=d*g}function h(){if(r){var A,a,c=r.length,l=t.length,u=new Map(r.map((t,e)=>[s(t,e,r),t]));for(A=0,i=new Array(c);A<l;++A)(a=t[A]).index=A,"object"!=typeof a.source&&(a.source=Bk(u,a.source)),"object"!=typeof a.target&&(a.target=Bk(u,a.target)),i[a.source.index]=(i[a.source.index]||0)+1,i[a.target.index]=(i[a.target.index]||0)+1;for(A=0,o=new Array(l);A<l;++A)a=t[A],o[A]=i[a.source.index]/(i[a.source.index]+i[a.target.index]);e=new Array(l),d(),n=new Array(l),f()}}function d(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+a(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=[]),u.initialize=function(t,e){r=t,A=e,h()},u.links=function(e){return arguments.length?(t=e,h(),u):t},u.id=function(t){return arguments.length?(s=t,u):s},u.iterations=function(t){return arguments.length?(l=+t,u):l},u.strength=function(t){return arguments.length?(a="function"==typeof t?t:ok(+t),d(),u):a},u.distance=function(t){return arguments.length?(c="function"==typeof t?t:ok(+t),f(),u):c},u}pk.copy=function(){var t,e,n=new fk(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=gk(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]=gk(e));return n},pk.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return ck(this.cover(e,n),e,n,t)},pk.addAll=function(t){var e,n,r,i,o=t.length,A=new Array(o),s=new Array(o),a=1/0,c=1/0,l=-1/0,u=-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<a&&(a=r),r>l&&(l=r),i<c&&(c=i),i>u&&(u=i));if(a>l||c>u)return this;for(this.cover(a,c).cover(l,u),n=0;n<o;++n)ck(this,A[n],s[n],t[n]);return this},pk.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,a=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,a*=2,s){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},pk.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},pk.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]]},pk.find=function(t,e,n){var r,i,o,A,s,a,c,l=this._x0,u=this._y0,h=this._x1,d=this._y1,f=[],g=this._root;for(g&&f.push(new lk(g,l,u,h,d)),null==n?n=1/0:(l=t-n,u=e-n,h=t+n,d=e+n,n*=n);a=f.pop();)if(!(!(g=a.node)||(i=a.x0)>h||(o=a.y0)>d||(A=a.x1)<l||(s=a.y1)<u))if(g.length){var p=(i+A)/2,v=(o+s)/2;f.push(new lk(g[3],p,v,A,s),new lk(g[2],i,v,p,s),new lk(g[1],p,o,A,v),new lk(g[0],i,o,p,v)),(c=(e>=v)<<1|t>=p)&&(a=f[f.length-1],f[f.length-1]=f[f.length-1-c],f[f.length-1-c]=a)}else{var m=t-+this._x.call(null,g.data),y=e-+this._y.call(null,g.data),w=m*m+y*y;if(w<n){var b=Math.sqrt(n=w);l=t-b,u=e-b,h=t+b,d=e+b,r=g.data}}return r},pk.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,a,c,l,u,h,d=this._root,f=this._x0,g=this._y0,p=this._x1,v=this._y1;if(!d)return this;if(d.length)for(;;){if((c=o>=(s=(f+p)/2))?f=s:p=s,(l=A>=(a=(g+v)/2))?g=a:v=a,e=d,!(d=d[u=l<<1|c]))return this;if(!d.length)break;(e[u+1&3]||e[u+2&3]||e[u+3&3])&&(n=e,h=u)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):e?(i?e[u]=i:delete e[u],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(n?n[h]=d:this._root=d),this):(this._root=i,this)},pk.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},pk.root=function(){return this._root},pk.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},pk.visit=function(t){var e,n,r,i,o,A,s=[],a=this._root;for(a&&s.push(new lk(a,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(a=e.node,r=e.x0,i=e.y0,o=e.x1,A=e.y1)&&a.length){var c=(r+o)/2,l=(i+A)/2;(n=a[3])&&s.push(new lk(n,c,l,o,A)),(n=a[2])&&s.push(new lk(n,r,l,c,A)),(n=a[1])&&s.push(new lk(n,c,i,o,l)),(n=a[0])&&s.push(new lk(n,r,i,c,l))}return this},pk.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new lk(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,a=e.x1,c=e.y1,l=(A+a)/2,u=(s+c)/2;(o=i[0])&&n.push(new lk(o,A,s,l,u)),(o=i[1])&&n.push(new lk(o,l,s,a,u)),(o=i[2])&&n.push(new lk(o,A,u,l,c)),(o=i[3])&&n.push(new lk(o,l,u,a,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},pk.x=function(t){return arguments.length?(this._x=t,this):this._x},pk.y=function(t){return arguments.length?(this._y=t,this):this._y};const xk=(t,e)=>t[e];function Ck(){function t(t){return()=>t}let e,n=t=>t.cluster,r=t(1),i=t(-1),o=t(100),A=t(.1),s=[0,0],a=[],c={},l=[],u=100,h=100,d={none:{x:0,y:0}},f=[],g="force",p=!0,v=.1;function m(t){if(!p)return m;e.tick(),w();for(let e,r=0,i=a.length,o=t*v;r<i;++r)e=a[r],e.vx||(e.vx=0),e.vy||(e.vy=0),e.vx+=(d[n(e._original)].x-e.x)*o,e.vy+=(d[n(e._original)].y-e.y)*o}function y(){a&&function(){if(!a||!a.length)return;const t=a[0];if(void 0===n(t._original))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInABox.groupBy('clusterAttr') before calling .links()");const s=function(){const t=[],e=[],i={};let o=[],A={},s=[];return A=function(t){const e={};return t.forEach(t=>{const r=n(t._original);e[r]||(e[r]={count:0,sumforceNodeSize:0})}),t.forEach(t=>{const i=n(t._original),o=r(t._original),A=e[i];A.count=A.count+1,A.sumforceNodeSize=A.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=A}),e}(a),s=function(t){const e={},r=[];t.forEach(t=>{const r=function(t){const e=xk(t,"source"),r=xk(t,"target"),i=n(c[e]._original),o=n(c[r]._original);return i<=o?`${i}~${o}`:`${o}~${i}`}(t);let i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i});return Object.entries(e).forEach(([t,e])=>{const n=t.split("~")[0],i=t.split("~")[1];void 0!==n&&void 0!==i&&r.push({source:n,target:i,count:e})}),r}(l),o=Object.keys(A),o.forEach((e,n)=>{const r=A[e];t.push({id:e,size:r.count,r:Math.sqrt(r.sumforceNodeSize/Math.PI)}),i[e]=n}),s.forEach(t=>{const n=xk(t,"source"),r=xk(t,"target"),o=i[n],A=i[r];void 0!==o&&void 0!==A&&e.push({source:o,target:A,count:t.count})}),{nodes:t,links:e}}();e=ik(s.nodes).force("x",Ak(u).strength(.1)).force("y",sk(h).strength(.1)).force("collide",yk(t=>t.r).iterations(4)).force("charge",wk().strength(i)).force("links",Ek(s.nodes.length?s.links:[]).distance(o).strength(A)),f=e.nodes(),w()}()}function w(){return d={none:{x:0,y:0}},f.forEach(t=>{d[t.id]={x:t.x-s[0],y:t.y-s[1]}}),d}return m.initialize=t=>{a=t,y()},m.template=function(t){return arguments.length?(g=t,y(),m):g},m.groupBy=function(t){return arguments.length?"string"==typeof t?(n=e=>e[t],m):(n=t,m):n},m.enableGrouping=function(t){return arguments.length?(p=t,m):p},m.strength=function(t){return arguments.length?(v=t,m):v},m.centerX=function(t){return arguments.length?(u=t,m):u},m.centerY=function(t){return arguments.length?(h=t,m):h},m.nodes=function(t){return arguments.length?(function(t){c={},t.forEach(t=>{c[t.id]=t})}(t||[]),a=t||[],m):a},m.links=function(t){return arguments.length?(l=t||[],y(),m):l},m.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),y(),m):r},m.nodeSize=m.forceNodeSize,m.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),y(),m):i},m.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),y(),m):o},m.forceLinkStrength=function(e){return arguments.length?(A="function"==typeof e?e:t(+e),y(),m):A},m.offset=function(t){return arguments.length?(s=t,m):s},m.getFocis=w,m}var Mk={}.toString,Fk=function(t,e){return Mk.call(t)==="[object "+e+"]"},kk=function(t){if(!function(t){return"object"==typeof t&&null!==t}(t)||!Fk(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};function Sk(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function Qk(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(Sk(e,i)){var o=e[i];null!==o&&kk(o)?(kk(t[i])||(t[i]={}),n<r?Qk(t[i],o,n+1,r):t[i]=e[i]):dM(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}const Uk={edgeId:"edge.id",manyBody:{strength:-30},preventOverlap:!1,nodeSize:10,nodeSpacing:0,x:!1,y:!1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10};class Nk extends BC{getDefaultOptions(){return Uk}mergeOptions(t,e){return 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)Qk(t,e[r]);return t}({},t,e)}constructor(t){super(t),this.id="d3-force",this.d3Nodes=[],this.d3Edges=[],this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}stop(){return this.simulation&&this.simulation.stop(),this}tick(t=1){var e,n;if(this.simulation){for(let e=0;e<t;e++)this.simulation.tick();this.syncPositionsFromD3(),null===(n=(e=this.options).onTick)||void 0===n||n.call(e,this)}return this}restart(t){return this.simulation&&(void 0!==t&&this.simulation.alpha(t),this.simulation.restart()),this}reheat(){return this.restart(1)}getAlpha(){var t,e;return null!==(e=null===(t=this.simulation)||void 0===t?void 0:t.alpha())&&void 0!==e?e:0}setAlpha(t){return this.simulation&&this.simulation.alpha(t),this}getForce(t){var e;return null===(e=this.simulation)||void 0===e?void 0:e.force(t)}force(t,e){return this.simulation&&this.simulation.force(t,e),this}nodes(){var t,e;return null!==(e=null===(t=this.simulation)||void 0===t?void 0:t.nodes())&&void 0!==e?e:[]}find(t,e,n){if(this.simulation)return this.simulation.find(t,e,n)}setFixedPosition(t,e){const n=this.d3Nodes.find(e=>e.id===t),r=this.model.node(t);if(!r||!n)return;const i=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<i.length&&("number"==typeof t||null===t)&&(r[i[e]]=t,n[i[e]]=t)}):i.forEach(t=>{delete r[t],delete n[t]})}parseOptions(t){const e=t;return void 0===e.iterations&&(e.link&&void 0===e.link.iterations&&(e.iterations=e.link.iterations),e.collide&&void 0===e.collide.iterations&&(e.iterations=e.collide.iterations)),e}layout(){var t;return px(this,0,void 0,function*(){const e=this.parseOptions(this.options||{});this.createD3Copies();const n=this.setSimulation(e);return n.nodes(this.d3Nodes),null===(t=n.force("link"))||void 0===t||t.links(this.d3Edges),new Promise(t=>{n.on("end",()=>{this.syncPositionsFromD3(),t()})})})}createD3Copies(){this.d3Nodes=[],this.d3Edges=[],this.model.forEachNode(t=>{this.d3Nodes.push(Object.assign({},t))}),this.model.forEachEdge(t=>{this.d3Edges.push(Object.assign({},t))})}syncPositionsFromD3(){this.d3Nodes.forEach(t=>{const e=this.model.node(t.id);e&&(e.x=t.x,e.y=t.y,void 0!==t.z&&(e.z=t.z),void 0!==t.fx&&(e.fx=t.fx),void 0!==t.fy&&(e.fy=t.fy),void 0!==t.fz&&(e.fz=t.fz),void 0!==t.vx&&(e.vx=t.vx),void 0!==t.vy&&(e.vy=t.vy),void 0!==t.vz&&(e.vz=t.vz))})}initSimulation(){return ik()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",()=>{var e;this.syncPositionsFromD3(),null===(e=t.onTick)||void 0===e||e.call(t,this)})),Tk(e,this.config.simulationAttrs.map(e=>[e,t[e]])),this.setupForces(e,t),e}setupForces(t,e){this.setupLinkForce(t,e),this.setupManyBodyForce(t,e),this.setupCenterForce(t,e),this.setupCollisionForce(t,e),this.setupXForce(t,e),this.setupYForce(t,e),this.setupRadialForce(t,e),this.setupClusterForce(t,e)}getCenterOptions(t){if(!1===t.center)return;const e=MF({width:t.width,height:t.height});return UF({},t.center||{},{x:e.width/2,y:e.height/2,strength:t.centerStrength})}setupCenterForce(t,e){const n=this.getCenterOptions(e);if(n){let e=t.force("center");e||(e=function(t,e){var n,r=1;function i(){var i,o,A=n.length,s=0,a=0;for(i=0;i<A;++i)s+=(o=n[i]).x,a+=o.y;for(s=(s/A-t)*r,a=(a/A-e)*r,i=0;i<A;++i)(o=n[i]).x-=s,o.y-=a}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}(n.x,n.y),t.force("center",e));const r=[];void 0!==n.x&&r.push(["x",n.x]),void 0!==n.y&&r.push(["y",n.y]),void 0!==n.strength&&r.push(["strength",n.strength]),Tk(e,r)}else t.force("center",null)}getManyBodyOptions(t){if(!1!==t.manyBody)return UF({},t.manyBody||{},{strength:t.nodeStrength?jx(t.nodeStrength,["node"]):void 0,distanceMin:t.distanceMin,distanceMax:t.distanceMax,theta:t.theta})}setupManyBodyForce(t,e){const n=this.getManyBodyOptions(e);if(n){let e=t.force("charge");e||(e=wk(),t.force("charge",e));const r=[];void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.distanceMin&&r.push(["distanceMin",n.distanceMin]),void 0!==n.distanceMax&&r.push(["distanceMax",n.distanceMax]),void 0!==n.theta&&r.push(["theta",n.theta]),Tk(e,r)}else t.force("charge",null)}getLinkOptions(t){if(!1!==t.link)return UF({},t.link||{},{id:t.edgeId?jx(t.edgeId,["edge"]):void 0,distance:t.linkDistance?jx(t.linkDistance,["edge"]):void 0,strength:t.edgeStrength?jx(t.edgeStrength,["edge"]):void 0,iterations:t.edgeIterations})}setupLinkForce(t,e){const n=this.model.edges(),r=this.getLinkOptions(e);if(n.length>0&&r){let e=t.force("link");e||(e=Ek(),t.force("link",e));const n=[];void 0!==r.id&&n.push(["id",r.id]),void 0!==r.distance&&n.push(["distance",r.distance]),void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.iterations&&n.push(["iterations",r.iterations]),Tk(e,n)}else t.force("link",null)}getCollisionOptions(t){if(!1===t.preventOverlap&&(!1===t.collide||void 0===t.collide))return;const e=Wx(t.nodeSize,t.nodeSpacing,Uk.nodeSize,Uk.nodeSpacing);return UF({},t.collide||{},{radius:t.collide&&t.collide.radius||(t=>Math.max(...e(t._original))/2),strength:t.collideStrength,iterations:t.collideIterations})}setupCollisionForce(t,e){const n=this.getCollisionOptions(e);if(n){let e=t.force("collide");e||(e=yk(),t.force("collide",e));const r=[];void 0!==n.radius&&r.push(["radius",n.radius]),void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.iterations&&r.push(["iterations",n.iterations]),Tk(e,r)}else t.force("collide",null)}getXForceOptions(t){var e;if(!1===t.x)return;const n=this.getCenterOptions(t);return UF({},t.x||{},{x:null!==(e=t.forceXPosition)&&void 0!==e?e:n&&n.x,strength:t.forceXStrength})}setupXForce(t,e){const n=this.getXForceOptions(e);if(n){let e=t.force("x");e||(e=Ak(),t.force("x",e));const r=[];void 0!==n.x&&r.push(["x",n.x]),void 0!==n.strength&&r.push(["strength",n.strength]),Tk(e,r)}else t.force("x",null)}getYForceOptions(t){var e;if(!1===t.y)return;const n=this.getCenterOptions(t);return UF({},t.y||{},{y:null!==(e=t.forceYPosition)&&void 0!==e?e:n&&n.y,strength:t.forceYStrength})}setupYForce(t,e){const n=this.getYForceOptions(e);if(n){let e=t.force("y");e||(e=sk(),t.force("y",e));const r=[];void 0!==n.y&&r.push(["y",n.y]),void 0!==n.strength&&r.push(["strength",n.strength]),Tk(e,r)}else t.force("y",null)}getRadialOptions(t){var e,n,r;if(void 0!==t.radial||void 0!==t.radialStrength||void 0!==t.radialRadius||void 0!==t.radialX||void 0!==t.radialY){const i=this.getCenterOptions(t);return UF({},t.radial||{},{strength:t.radialStrength,radius:null!==(e=t.radialRadius)&&void 0!==e?e:100,x:null!==(n=t.radialX)&&void 0!==n?n:i&&i.x,y:null!==(r=t.radialY)&&void 0!==r?r:i&&i.y})}}setupRadialForce(t,e){const n=this.getRadialOptions(e);if(n){let e=t.force("radial");e||(e=function(t,e,n){var r,i,o,A=ok(.1);function s(t){for(var A=0,s=r.length;A<s;++A){var a=r[A],c=a.x-e||1e-6,l=a.y-n||1e-6,u=Math.sqrt(c*c+l*l),h=(o[A]-u)*i[A]*t/u;a.vx+=c*h,a.vy+=l*h}}function a(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+A(r[e],e,r)}}return"function"!=typeof t&&(t=ok(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,a()},s.strength=function(t){return arguments.length?(A="function"==typeof t?t:ok(+t),a(),s):A},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:ok(+e),a(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}(n.radius||100,n.x,n.y),t.force("radial",e));const r=[];void 0!==n.radius&&r.push(["radius",n.radius]),void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.x&&r.push(["x",n.x]),void 0!==n.y&&r.push(["y",n.y]),Tk(e,r)}else t.force("radial",null)}setupClusterForce(t,e){const{clustering:n}=e;if(n){const{clusterFociStrength:n,clusterEdgeDistance:r,clusterEdgeStrength:i,clusterNodeStrength:o,clusterNodeSize:A,clusterBy:s}=e,a=this.getCenterOptions(e);let c=t.force("group");c||(c=Ck(),t.force("group",c)),Tk(c,[["centerX",a&&a.x],["centerY",a&&a.y],["template","force"],["strength",n],["groupBy",s?jx(s,["node"]):void 0],["nodes",this.model.nodes()],["links",this.model.edges()],["forceLinkDistance",r],["forceLinkStrength",i],["forceCharge",o],["forceNodeSize",A]])}else t.force("group",null)}}const Tk=(t,e)=>e.reduce((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e,t);function Ok(t){return function(){return t}}function Ik(t){var e,n,r,i=Ok(.1);function o(t){for(var i,o=0,A=e.length;o<A;++o)(i=e[o]).vz+=(r[o]-i.z)*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=Ok(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Ok(+t),A(),o):i},o.z=function(e){return arguments.length?(t="function"==typeof e?e:Ok(+e),A(),o):t},o}function Lk(t){var e,n,r,i=Ok(.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=Ok(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Ok(+t),A(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Ok(+e),A(),o):t},o}function Pk(t){var e,n,r,i=Ok(.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=Ok(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Ok(+t),A(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Ok(+e),A(),o):t},o}function Dk(t,e,n,r){var i,o,A,s,a=Ok(.1);function c(t){for(var a=0,c=i.length;a<c;++a){var l=i[a],u=l.x-e||1e-6,h=(l.y||0)-n||1e-6,d=(l.z||0)-r||1e-6,f=Math.sqrt(u*u+h*h+d*d),g=(s[a]-f)*A[a]*t/f;l.vx+=u*g,o>1&&(l.vy+=h*g),o>2&&(l.vz+=d*g)}}function l(){if(i){var e,n=i.length;for(A=new Array(n),s=new Array(n),e=0;e<n;++e)s[e]=+t(i[e],e,i),A[e]=isNaN(s[e])?0:+a(i[e],e,i)}}return"function"!=typeof t&&(t=Ok(+t)),null==e&&(e=0),null==n&&(n=0),null==r&&(r=0),c.initialize=function(t,...e){i=t,o=e.find(t=>[1,2,3].includes(t))||2,l()},c.strength=function(t){return arguments.length?(a="function"==typeof t?t:Ok(+t),l(),c):a},c.radius=function(e){return arguments.length?(t="function"==typeof e?e:Ok(+e),l(),c):t},c.x=function(t){return arguments.length?(e=+t,c):e},c.y=function(t){return arguments.length?(n=+t,c):n},c.z=function(t){return arguments.length?(r=+t,c):r},c}function Rk(t){return 1e-6*(t()-.5)}function Hk(t,e,n){if(isNaN(e))return t;var r,i,o,A,s,a,c=t._root,l={data:n},u=t._x0,h=t._x1;if(!c)return t._root=l,t;for(;c.length;)if((A=e>=(i=(u+h)/2))?u=i:h=i,r=c,!(c=c[s=+A]))return r[s]=l,t;if(e===(o=+t._x.call(null,c.data)))return l.next=c,r?r[s]=l:t._root=l,t;do{r=r?r[s]=new Array(2):t._root=new Array(2),(A=e>=(i=(u+h)/2))?u=i:h=i}while((s=+A)===(a=+(o>=i)));return r[a]=c,r[s]=l,t}function _k(t,e,n){this.node=t,this.x0=e,this.x1=n}function Gk(t){return t[0]}function Kk(t,e){var n=new jk(null==e?Gk:e,NaN,NaN);return null==t?n:n.addAll(t)}function jk(t,e,n){this._x=t,this._x0=e,this._x1=n,this._root=void 0}function zk(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Vk=Kk.prototype=jk.prototype;function Wk(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,A,s,a,c,l,u,h,d,f,g,p,v=t._root,m={data:i},y=t._x0,w=t._y0,b=t._z0,B=t._x1,E=t._y1,x=t._z1;if(!v)return t._root=m,t;for(;v.length;)if((h=e>=(A=(y+B)/2))?y=A:B=A,(d=n>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(b+x)/2))?b=a:x=a,o=v,!(v=v[g=f<<2|d<<1|h]))return o[g]=m,t;if(c=+t._x.call(null,v.data),l=+t._y.call(null,v.data),u=+t._z.call(null,v.data),e===c&&n===l&&r===u)return m.next=v,o?o[g]=m:t._root=m,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(h=e>=(A=(y+B)/2))?y=A:B=A,(d=n>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(b+x)/2))?b=a:x=a}while((g=f<<2|d<<1|h)==(p=(u>=a)<<2|(l>=s)<<1|c>=A));return o[p]=v,o[g]=m,t}function Yk(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}Vk.copy=function(){var t,e,n=new jk(this._x,this._x0,this._x1),r=this._root;if(!r)return n;if(!r.length)return n._root=zk(r),n;for(t=[{source:r,target:n._root=new Array(2)}];r=t.pop();)for(var i=0;i<2;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(2)}):r.target[i]=zk(e));return n},Vk.add=function(t){const e=+this._x.call(null,t);return Hk(this.cover(e),e,t)},Vk.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e);let r=1/0,i=-1/0;for(let o,A=0;A<e;++A)isNaN(o=+this._x.call(null,t[A]))||(n[A]=o,o<r&&(r=o),o>i&&(i=o));if(r>i)return this;this.cover(r).cover(i);for(let r=0;r<e;++r)Hk(this,n[r],t[r]);return this},Vk.cover=function(t){if(isNaN(t=+t))return this;var e=this._x0,n=this._x1;if(isNaN(e))n=(e=Math.floor(t))+1;else{for(var r,i,o=n-e||1,A=this._root;e>t||t>=n;)switch(i=+(t<e),(r=new Array(2))[i]=A,A=r,o*=2,i){case 0:n=e+o;break;case 1:e=n-o}this._root&&this._root.length&&(this._root=A)}return this._x0=e,this._x1=n,this},Vk.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},Vk.extent=function(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]},Vk.find=function(t,e){var n,r,i,o,A,s=this._x0,a=this._x1,c=[],l=this._root;for(l&&c.push(new _k(l,s,a)),null==e?e=1/0:(s=t-e,a=t+e);o=c.pop();)if(!(!(l=o.node)||(r=o.x0)>a||(i=o.x1)<s))if(l.length){var u=(r+i)/2;c.push(new _k(l[1],u,i),new _k(l[0],r,u)),(A=+(t>=u))&&(o=c[c.length-1],c[c.length-1]=c[c.length-1-A],c[c.length-1-A]=o)}else{var h=Math.abs(t-+this._x.call(null,l.data));h<e&&(e=h,s=t-h,a=t+h,n=l.data)}return n},Vk.remove=function(t){if(isNaN(o=+this._x.call(null,t)))return this;var e,n,r,i,o,A,s,a,c,l=this._root,u=this._x0,h=this._x1;if(!l)return this;if(l.length)for(;;){if((s=o>=(A=(u+h)/2))?u=A:h=A,e=l,!(l=l[a=+s]))return this;if(!l.length)break;e[a+1&1]&&(n=e,c=a)}for(;l.data!==t;)if(r=l,!(l=l.next))return this;return(i=l.next)&&delete l.next,r?(i?r.next=i:delete r.next,this):e?(i?e[a]=i:delete e[a],(l=e[0]||e[1])&&l===(e[1]||e[0])&&!l.length&&(n?n[c]=l:this._root=l),this):(this._root=i,this)},Vk.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Vk.root=function(){return this._root},Vk.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},Vk.visit=function(t){var e,n,r,i,o=[],A=this._root;for(A&&o.push(new _k(A,this._x0,this._x1));e=o.pop();)if(!t(A=e.node,r=e.x0,i=e.x1)&&A.length){var s=(r+i)/2;(n=A[1])&&o.push(new _k(n,s,i)),(n=A[0])&&o.push(new _k(n,r,s))}return this},Vk.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new _k(this._root,this._x0,this._x1));e=n.pop();){var i=e.node;if(i.length){var o,A=e.x0,s=e.x1,a=(A+s)/2;(o=i[0])&&n.push(new _k(o,A,a)),(o=i[1])&&n.push(new _k(o,a,s))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.x1);return this},Vk.x=function(t){return arguments.length?(this._x=t,this):this._x};const Xk=(t,e,n,r,i,o)=>Math.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function qk(t){return t[0]}function $k(t){return t[1]}function Zk(t){return t[2]}function Jk(t,e,n,r){var i=new tS(null==e?qk:e,null==n?$k:n,null==r?Zk:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function tS(t,e,n,r,i,o,A,s,a){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=A,this._y1=s,this._z1=a,this._root=void 0}function eS(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var nS=Jk.prototype=tS.prototype;function rS(t){return t.x+t.vx}function iS(t){return t.y+t.vy}function oS(t){return t.z+t.vz}function AS(t){var e,n,r,i,o=1,A=1;function s(){for(var t,s,c,l,u,h,d,f,g=e.length,p=0;p<A;++p)for(s=(1===n?Kk(e,rS):2===n?dk(e,rS,iS):3===n?Jk(e,rS,iS,oS):null).visitAfter(a),t=0;t<g;++t)c=e[t],d=r[c.index],f=d*d,l=c.x+c.vx,n>1&&(u=c.y+c.vy),n>2&&(h=c.z+c.vz),s.visit(v);function v(t,e,r,A,s,a,g){var p=[e,r,A,s,a,g],v=p[0],m=p[1],y=p[2],w=p[n],b=p[n+1],B=p[n+2],E=t.data,x=t.r,C=d+x;if(!E)return v>l+C||w<l-C||n>1&&(m>u+C||b<u-C)||n>2&&(y>h+C||B<h-C);if(E.index>c.index){var M=l-E.x-E.vx,F=n>1?u-E.y-E.vy:0,k=n>2?h-E.z-E.vz:0,S=M*M+F*F+k*k;S<C*C&&(0===M&&(S+=(M=Rk(i))*M),n>1&&0===F&&(S+=(F=Rk(i))*F),n>2&&0===k&&(S+=(k=Rk(i))*k),S=(C-(S=Math.sqrt(S)))/S*o,c.vx+=(M*=S)*(C=(x*=x)/(f+x)),n>1&&(c.vy+=(F*=S)*C),n>2&&(c.vz+=(k*=S)*C),E.vx-=M*(C=1-C),n>1&&(E.vy-=F*C),n>2&&(E.vz-=k*C))}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<Math.pow(2,n);++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function c(){if(e){var n,i,o=e.length;for(r=new Array(o),n=0;n<o;++n)i=e[n],r[i.index]=+t(i,n,e)}}return"function"!=typeof t&&(t=Ok(null==t?1:+t)),s.initialize=function(t,...r){e=t,i=r.find(t=>"function"==typeof t)||Math.random,n=r.find(t=>[1,2,3].includes(t))||2,c()},s.iterations=function(t){return arguments.length?(A=+t,s):A},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:Ok(+e),c(),s):t},s}function sS(t,e,n){var r,i=1;function o(){var o,A,s=r.length,a=0,c=0,l=0;for(o=0;o<s;++o)a+=(A=r[o]).x||0,c+=A.y||0,l+=A.z||0;for(a=(a/s-t)*i,c=(c/s-e)*i,l=(l/s-n)*i,o=0;o<s;++o)A=r[o],a&&(A.x-=a),c&&(A.y-=c),l&&(A.z-=l)}return null==t&&(t=0),null==e&&(e=0),null==n&&(n=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.z=function(t){return arguments.length?(n=+t,o):n},o.strength=function(t){return arguments.length?(i=+t,o):i},o}nS.copy=function(){var t,e,n=new tS(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=eS(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]=eS(e));return n},nS.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Wk(this.cover(e,n,r),e,n,r,t)},nS.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,a=-1/0,c=-1/0,l=-1/0;for(let u,h,d,f,g=0;g<e;++g)isNaN(h=+this._x.call(null,u=t[g]))||isNaN(d=+this._y.call(null,u))||isNaN(f=+this._z.call(null,u))||(n[g]=h,r[g]=d,i[g]=f,h<o&&(o=h),h>a&&(a=h),d<A&&(A=d),d>c&&(c=d),f<s&&(s=f),f>l&&(l=f));if(o>a||A>c||s>l)return this;this.cover(o,A,s).cover(a,c,l);for(let o=0;o<e;++o)Wk(this,n[o],r[o],i[o],t[o]);return this},nS.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,a=this._z1;if(isNaN(r))A=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,a=(o=Math.floor(n))+1;else{for(var c,l,u=A-r||1,h=this._root;r>t||t>=A||i>e||e>=s||o>n||n>=a;)switch(l=(n<o)<<2|(e<i)<<1|t<r,(c=new Array(8))[l]=h,h=c,u*=2,l){case 0:A=r+u,s=i+u,a=o+u;break;case 1:r=A-u,s=i+u,a=o+u;break;case 2:A=r+u,i=s-u,a=o+u;break;case 3:r=A-u,i=s-u,a=o+u;break;case 4:A=r+u,s=i+u,o=a-u;break;case 5:r=A-u,s=i+u,o=a-u;break;case 6:A=r+u,i=s-u,o=a-u;break;case 7:r=A-u,i=s-u,o=a-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=i,this._z0=o,this._x1=A,this._y1=s,this._z1=a,this},nS.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},nS.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]]},nS.find=function(t,e,n,r){var i,o,A,s,a,c,l,u,h,d=this._x0,f=this._y0,g=this._z0,p=this._x1,v=this._y1,m=this._z1,y=[],w=this._root;for(w&&y.push(new Yk(w,d,f,g,p,v,m)),null==r?r=1/0:(d=t-r,f=e-r,g=n-r,p=t+r,v=e+r,m=n+r,r*=r);u=y.pop();)if(!(!(w=u.node)||(o=u.x0)>p||(A=u.y0)>v||(s=u.z0)>m||(a=u.x1)<d||(c=u.y1)<f||(l=u.z1)<g))if(w.length){var b=(o+a)/2,B=(A+c)/2,E=(s+l)/2;y.push(new Yk(w[7],b,B,E,a,c,l),new Yk(w[6],o,B,E,b,c,l),new Yk(w[5],b,A,E,a,B,l),new Yk(w[4],o,A,E,b,B,l),new Yk(w[3],b,B,s,a,c,E),new Yk(w[2],o,B,s,b,c,E),new Yk(w[1],b,A,s,a,B,E),new Yk(w[0],o,A,s,b,B,E)),(h=(n>=E)<<2|(e>=B)<<1|t>=b)&&(u=y[y.length-1],y[y.length-1]=y[y.length-1-h],y[y.length-1-h]=u)}else{var x=t-+this._x.call(null,w.data),C=e-+this._y.call(null,w.data),M=n-+this._z.call(null,w.data),F=x*x+C*C+M*M;if(F<r){var k=Math.sqrt(r=F);d=t-k,f=e-k,g=n-k,p=t+k,v=e+k,m=n+k,i=w.data}}return i},nS.findAllWithinRadius=function(t,e,n,r){const i=[],o=t-r,A=e-r,s=n-r,a=t+r,c=e+r,l=n+r;return this.visit((u,h,d,f,g,p,v)=>{if(!u.length)do{const o=u.data;Xk(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(u=u.next);return h>a||d>c||f>l||g<o||p<A||v<s}),i},nS.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,a,c,l,u,h,d,f,g,p=this._root,v=this._x0,m=this._y0,y=this._z0,w=this._x1,b=this._y1,B=this._z1;if(!p)return this;if(p.length)for(;;){if((u=o>=(a=(v+w)/2))?v=a:w=a,(h=A>=(c=(m+b)/2))?m=c:b=c,(d=s>=(l=(y+B)/2))?y=l:B=l,e=p,!(p=p[f=d<<2|h<<1|u]))return this;if(!p.length)break;(e[f+1&7]||e[f+2&7]||e[f+3&7]||e[f+4&7]||e[f+5&7]||e[f+6&7]||e[f+7&7])&&(n=e,g=f)}for(;p.data!==t;)if(r=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,r?(i?r.next=i:delete r.next,this):e?(i?e[f]=i:delete e[f],(p=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&p===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!p.length&&(n?n[g]=p:this._root=p),this):(this._root=i,this)},nS.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},nS.root=function(){return this._root},nS.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},nS.visit=function(t){var e,n,r,i,o,A,s,a,c=[],l=this._root;for(l&&c.push(new Yk(l,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.z0,A=e.x1,s=e.y1,a=e.z1)&&l.length){var u=(r+A)/2,h=(i+s)/2,d=(o+a)/2;(n=l[7])&&c.push(new Yk(n,u,h,d,A,s,a)),(n=l[6])&&c.push(new Yk(n,r,h,d,u,s,a)),(n=l[5])&&c.push(new Yk(n,u,i,d,A,h,a)),(n=l[4])&&c.push(new Yk(n,r,i,d,u,h,a)),(n=l[3])&&c.push(new Yk(n,u,h,o,A,s,d)),(n=l[2])&&c.push(new Yk(n,r,h,o,u,s,d)),(n=l[1])&&c.push(new Yk(n,u,i,o,A,h,d)),(n=l[0])&&c.push(new Yk(n,r,i,o,u,h,d))}return this},nS.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Yk(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,a=e.z0,c=e.x1,l=e.y1,u=e.z1,h=(A+c)/2,d=(s+l)/2,f=(a+u)/2;(o=i[0])&&n.push(new Yk(o,A,s,a,h,d,f)),(o=i[1])&&n.push(new Yk(o,h,s,a,c,d,f)),(o=i[2])&&n.push(new Yk(o,A,d,a,h,l,f)),(o=i[3])&&n.push(new Yk(o,h,d,a,c,l,f)),(o=i[4])&&n.push(new Yk(o,A,s,f,h,d,u)),(o=i[5])&&n.push(new Yk(o,h,s,f,c,d,u)),(o=i[6])&&n.push(new Yk(o,A,d,f,h,l,u)),(o=i[7])&&n.push(new Yk(o,h,d,f,c,l,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},nS.x=function(t){return arguments.length?(this._x=t,this):this._x},nS.y=function(t){return arguments.length?(this._y=t,this):this._y},nS.z=function(t){return arguments.length?(this._z=t,this):this._z};const aS=4294967296;function cS(t){return t.x}function lS(t){return t.y}function uS(t){return t.z}var hS=Math.PI*(3-Math.sqrt(5)),dS=20*Math.PI/(9+Math.sqrt(221));function fS(t,e){e=e||2;var n,r=Math.min(3,Math.max(1,Math.round(e))),i=1,o=.001,A=1-Math.pow(o,1/300),s=0,a=.6,c=new Map,l=VF(d),u=$F("tick","end"),h=function(){let t=1;return()=>(t=(1664525*t+1013904223)%aS)/aS}();function d(){f(),u.call("tick",n),i<o&&(l.stop(),u.call("end",n))}function f(e){var o,l,u=t.length;void 0===e&&(e=1);for(var h=0;h<e;++h)for(i+=(s-i)*A,c.forEach(function(t){t(i)}),o=0;o<u;++o)null==(l=t[o]).fx?l.x+=l.vx*=a:(l.x=l.fx,l.vx=0),r>1&&(null==l.fy?l.y+=l.vy*=a:(l.y=l.fy,l.vy=0)),r>2&&(null==l.fz?l.z+=l.vz*=a:(l.z=l.fz,l.vz=0));return n}function g(){for(var e,n=0,i=t.length;n<i;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),null!=e.fz&&(e.z=e.fz),isNaN(e.x)||r>1&&isNaN(e.y)||r>2&&isNaN(e.z)){var o=10*(r>2?Math.cbrt(.5+n):r>1?Math.sqrt(.5+n):n),A=n*hS,s=n*dS;1===r?e.x=o:2===r?(e.x=o*Math.cos(A),e.y=o*Math.sin(A)):(e.x=o*Math.sin(A)*Math.cos(s),e.y=o*Math.cos(A),e.z=o*Math.sin(A)*Math.sin(s))}(isNaN(e.vx)||r>1&&isNaN(e.vy)||r>2&&isNaN(e.vz))&&(e.vx=0,r>1&&(e.vy=0),r>2&&(e.vz=0))}}function p(e){return e.initialize&&e.initialize(t,h,r),e}return null==t&&(t=[]),g(),n={tick:f,restart:function(){return l.restart(d),n},stop:function(){return l.stop(),n},numDimensions:function(t){return arguments.length?(r=Math.min(3,Math.max(1,Math.round(t))),c.forEach(p),n):r},nodes:function(e){return arguments.length?(t=e,g(),c.forEach(p),n):t},alpha:function(t){return arguments.length?(i=+t,n):i},alphaMin:function(t){return arguments.length?(o=+t,n):o},alphaDecay:function(t){return arguments.length?(A=+t,n):+A},alphaTarget:function(t){return arguments.length?(s=+t,n):s},velocityDecay:function(t){return arguments.length?(a=1-t,n):1-a},randomSource:function(t){return arguments.length?(h=t,c.forEach(p),n):h},force:function(t,e){return arguments.length>1?(null==e?c.delete(t):c.set(t,p(e)),n):c.get(t)},find:function(){var e,n,i,o,A,s,a=Array.prototype.slice.call(arguments),c=a.shift()||0,l=(r>1?a.shift():null)||0,u=(r>2?a.shift():null)||0,h=a.shift()||1/0,d=0,f=t.length;for(h*=h,d=0;d<f;++d)(o=(e=c-(A=t[d]).x)*e+(n=l-(A.y||0))*n+(i=u-(A.z||0))*i)<h&&(s=A,h=o);return s},on:function(t,e){return arguments.length>1?(u.on(t,e),n):u.on(t)}}}function gS(){var t,e,n,r,i,o,A=Ok(-30),s=1,a=1/0,c=.81;function l(r){var o,A=t.length,s=(1===e?Kk(t,cS):2===e?dk(t,cS,lS):3===e?Jk(t,cS,lS,uS):null).visitAfter(h);for(i=r,o=0;o<A;++o)n=t[o],s.visit(d)}function u(){if(t){var e,n,r=t.length;for(o=new Array(r),e=0;e<r;++e)n=t[e],o[n.index]=+A(n,e,t)}}function h(t){var n,r,i,A,s,a,c=0,l=0,u=t.length;if(u){for(i=A=s=a=0;a<u;++a)(n=t[a])&&(r=Math.abs(n.value))&&(c+=n.value,l+=r,i+=r*(n.x||0),A+=r*(n.y||0),s+=r*(n.z||0));c*=Math.sqrt(4/u),t.x=i/l,e>1&&(t.y=A/l),e>2&&(t.z=s/l)}else{(n=t).x=n.data.x,e>1&&(n.y=n.data.y),e>2&&(n.z=n.data.z);do{c+=o[n.data.index]}while(n=n.next)}t.value=c}function d(t,A,l,u,h){if(!t.value)return!0;var d=[l,u,h][e-1],f=t.x-n.x,g=e>1?t.y-n.y:0,p=e>2?t.z-n.z:0,v=d-A,m=f*f+g*g+p*p;if(v*v/c<m)return m<a&&(0===f&&(m+=(f=Rk(r))*f),e>1&&0===g&&(m+=(g=Rk(r))*g),e>2&&0===p&&(m+=(p=Rk(r))*p),m<s&&(m=Math.sqrt(s*m)),n.vx+=f*t.value*i/m,e>1&&(n.vy+=g*t.value*i/m),e>2&&(n.vz+=p*t.value*i/m)),!0;if(!(t.length||m>=a)){(t.data!==n||t.next)&&(0===f&&(m+=(f=Rk(r))*f),e>1&&0===g&&(m+=(g=Rk(r))*g),e>2&&0===p&&(m+=(p=Rk(r))*p),m<s&&(m=Math.sqrt(s*m)));do{t.data!==n&&(v=o[t.data.index]*i/m,n.vx+=f*v,e>1&&(n.vy+=g*v),e>2&&(n.vz+=p*v))}while(t=t.next)}}return l.initialize=function(n,...i){t=n,r=i.find(t=>"function"==typeof t)||Math.random,e=i.find(t=>[1,2,3].includes(t))||2,u()},l.strength=function(t){return arguments.length?(A="function"==typeof t?t:Ok(+t),u(),l):A},l.distanceMin=function(t){return arguments.length?(s=t*t,l):Math.sqrt(s)},l.distanceMax=function(t){return arguments.length?(a=t*t,l):Math.sqrt(a)},l.theta=function(t){return arguments.length?(c=t*t,l):Math.sqrt(c)},l}function pS(t){return t.index}function vS(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function mS(t){var e,n,r,i,o,A,s,a=pS,c=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},l=Ok(30),u=1;function h(r){for(var o=0,a=t.length;o<u;++o)for(var c,l,h,d,f,g=0,p=0,v=0,m=0;g<a;++g)l=(c=t[g]).source,p=(h=c.target).x+h.vx-l.x-l.vx||Rk(s),i>1&&(v=h.y+h.vy-l.y-l.vy||Rk(s)),i>2&&(m=h.z+h.vz-l.z-l.vz||Rk(s)),p*=d=((d=Math.sqrt(p*p+v*v+m*m))-n[g])/d*r*e[g],v*=d,m*=d,h.vx-=p*(f=A[g]),i>1&&(h.vy-=v*f),i>2&&(h.vz-=m*f),l.vx+=p*(f=1-f),i>1&&(l.vy+=v*f),i>2&&(l.vz+=m*f)}function d(){if(r){var i,s,c=r.length,l=t.length,u=new Map(r.map((t,e)=>[a(t,e,r),t]));for(i=0,o=new Array(c);i<l;++i)(s=t[i]).index=i,"object"!=typeof s.source&&(s.source=vS(u,s.source)),"object"!=typeof s.target&&(s.target=vS(u,s.target)),o[s.source.index]=(o[s.source.index]||0)+1,o[s.target.index]=(o[s.target.index]||0)+1;for(i=0,A=new Array(l);i<l;++i)s=t[i],A[i]=o[s.source.index]/(o[s.source.index]+o[s.target.index]);e=new Array(l),f(),n=new Array(l),g()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+c(t[n],n,t)}function g(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+l(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,...e){r=t,s=e.find(t=>"function"==typeof t)||Math.random,i=e.find(t=>[1,2,3].includes(t))||2,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(a=t,h):a},h.iterations=function(t){return arguments.length?(u=+t,h):u},h.strength=function(t){return arguments.length?(c="function"==typeof t?t:Ok(+t),f(),h):c},h.distance=function(t){return arguments.length?(l="function"==typeof t?t:Ok(+t),g(),h):l},h}var yS,wS,bS,BS,ES,xS,CS,MS,FS,kS,SS,QS,US,NS,TS,OS,IS,LS,PS,DS,RS,HS,_S,GS,KS,jS,zS,VS,WS,YS,XS,qS,$S,ZS,JS,tQ,eQ,nQ,rQ,iQ,oQ,AQ,sQ,aQ,cQ,lQ,uQ,hQ,dQ,fQ,gQ,pQ,vQ,mQ,yQ,wQ,bQ,BQ,EQ,xQ,CQ,MQ,FQ,kQ,SQ,QQ,UQ,NQ,TQ,OQ,IQ,LQ,PQ,DQ,RQ,HQ,_Q,GQ,KQ,jQ,zQ,VQ,WQ,YQ,XQ,qQ,$Q,ZQ,JQ,tU,eU,nU,rU,iU,oU,AU,sU,aU,cU,lU,uU,hU,dU,fU,gU,pU,vU,mU,yU="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function wU(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function bU(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){var n=!1;try{n=this instanceof t}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}),n}function BU(){if(BS)return bS;return BS=1,bS=function(t,e){return t===e||t!=t&&e!=e}}function EU(){if(xS)return ES;xS=1;var t=BU();return ES=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},ES}function xU(){if(OS)return TS;OS=1;var t=wS?yS:(wS=1,yS=function(){this.__data__=[],this.size=0}),e=function(){if(MS)return CS;MS=1;var t=EU(),e=Array.prototype.splice;return CS=function(n){var r=this.__data__,i=t(r,n);return!(i<0||(i==r.length-1?r.pop():e.call(r,i,1),--this.size,0))},CS}(),n=function(){if(kS)return FS;kS=1;var t=EU();return FS=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},FS}(),r=function(){if(QS)return SS;QS=1;var t=EU();return SS=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(NS)return US;NS=1;var t=EU();return US=function(e,n){var r=this.__data__,i=t(r,e);return i<0?(++this.size,r.push([e,n])):r[i][1]=n,this},US}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,TS=o}function CU(){if(jS)return KS;jS=1;var t="object"==typeof yU&&yU&&yU.Object===Object&&yU;return KS=t}function MU(){if(VS)return zS;VS=1;var t=CU(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return zS=n}function FU(){if(YS)return WS;YS=1;var t=MU().Symbol;return WS=t}function kU(){if(tQ)return JS;tQ=1;var t=FU(),e=function(){if(qS)return XS;qS=1;var t=FU(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return XS=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var A=!0}catch(t){}var s=r.call(t);return A&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(ZS)return $S;ZS=1;var t=Object.prototype.toString;return $S=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return JS=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function SU(){if(nQ)return eQ;return nQ=1,eQ=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function QU(){if(iQ)return rQ;iQ=1;var t=kU(),e=SU();return rQ=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function UU(){if(aQ)return sQ;aQ=1;var t,e=function(){if(AQ)return oQ;AQ=1;var t=MU()["__core-js_shared__"];return oQ=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return sQ=function(t){return!!n&&n in t}}function NU(){if(lQ)return cQ;lQ=1;var t=Function.prototype.toString;return cQ=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function TU(){if(pQ)return gQ;pQ=1;var t=function(){if(hQ)return uQ;hQ=1;var t=QU(),e=UU(),n=SU(),r=NU(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,A=Object.prototype,s=o.toString,a=A.hasOwnProperty,c=RegExp("^"+s.call(a).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return uQ=function(o){return!(!n(o)||e(o))&&(t(o)?c:i).test(r(o))}}(),e=fQ?dQ:(fQ=1,dQ=function(t,e){return null==t?void 0:t[e]});return gQ=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function OU(){if(mQ)return vQ;mQ=1;var t=TU()(MU(),"Map");return vQ=t}function IU(){if(wQ)return yQ;wQ=1;var t=TU()(Object,"create");return yQ=t}function LU(){if(NQ)return UQ;NQ=1;var t=function(){if(BQ)return bQ;BQ=1;var t=IU();return bQ=function(){this.__data__=t?t(null):{},this.size=0}}(),e=xQ?EQ:(xQ=1,EQ=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(MQ)return CQ;MQ=1;var t=IU(),e=Object.prototype.hasOwnProperty;return CQ=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},CQ}(),r=function(){if(kQ)return FQ;kQ=1;var t=IU(),e=Object.prototype.hasOwnProperty;return FQ=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},FQ}(),i=function(){if(QQ)return SQ;QQ=1;var t=IU();return SQ=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},SQ}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,UQ=o}function PU(){if(DQ)return PQ;DQ=1;var t=LQ?IQ:(LQ=1,IQ=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return PQ=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},PQ}function DU(){if(YQ)return WQ;YQ=1;var t=function(){if(OQ)return TQ;OQ=1;var t=LU(),e=xU(),n=OU();return TQ=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(HQ)return RQ;HQ=1;var t=PU();return RQ=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(GQ)return _Q;GQ=1;var t=PU();return _Q=function(e){return t(this,e).get(e)}}(),r=function(){if(jQ)return KQ;jQ=1;var t=PU();return KQ=function(e){return t(this,e).has(e)}}(),i=function(){if(VQ)return zQ;VQ=1;var t=PU();return zQ=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},zQ}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,WQ=o}function RU(){if(ZQ)return $Q;ZQ=1;var t=xU(),e=function(){if(LS)return IS;LS=1;var t=xU();return IS=function(){this.__data__=new t,this.size=0}}(),n=(DS||(DS=1,PS=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),PS),r=HS?RS:(HS=1,RS=function(t){return this.__data__.get(t)}),i=GS?_S:(GS=1,_S=function(t){return this.__data__.has(t)}),o=function(){if(qQ)return XQ;qQ=1;var t=xU(),e=OU(),n=DU();return XQ=function(r,i){var o=this.__data__;if(o instanceof t){var A=o.__data__;if(!e||A.length<199)return A.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(A)}return o.set(r,i),this.size=o.size,this},XQ}();function A(e){var n=this.__data__=new t(e);this.size=n.size}return A.prototype.clear=e,A.prototype.delete=n,A.prototype.get=r,A.prototype.has=i,A.prototype.set=o,$Q=A}function HU(){if(tU)return JQ;return tU=1,JQ=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},JQ}function _U(){if(nU)return eU;nU=1;var t=TU(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return eU=e}function GU(){if(iU)return rU;iU=1;var t=_U();return rU=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function KU(){if(AU)return oU;AU=1;var t=GU(),e=BU(),n=Object.prototype.hasOwnProperty;return oU=function(r,i,o){var A=r[i];n.call(r,i)&&e(A,o)&&(void 0!==o||i in r)||t(r,i,o)}}function jU(){if(aU)return sU;aU=1;var t=KU(),e=GU();return sU=function(n,r,i,o){var A=!i;i||(i={});for(var s=-1,a=r.length;++s<a;){var c=r[s],l=o?o(i[c],n[c],c,i,n):void 0;void 0===l&&(l=n[c]),A?e(i,c,l):t(i,c,l)}return i},sU}function zU(){if(hU)return uU;return hU=1,uU=function(t){return null!=t&&"object"==typeof t}}function VU(){if(pU)return gU;pU=1;var t=function(){if(fU)return dU;fU=1;var t=kU(),e=zU();return dU=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=zU(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return gU=o}function WU(){if(mU)return vU;mU=1;var t=Array.isArray;return vU=t}var YU,XU,qU,$U,ZU,JU,tN,eN,nN,rN,iN,oN={exports:{}};function AN(){return qU||(qU=1,function(t,e){var n=MU(),r=XU?YU:(XU=1,YU=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,A=o&&o.exports===i?n.Buffer:void 0,s=(A?A.isBuffer:void 0)||r;t.exports=s}(oN,oN.exports)),oN.exports}function sN(){if(ZU)return $U;ZU=1;var t=/^(?:0|[1-9]\d*)$/;return $U=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},$U}function aN(){if(tN)return JU;tN=1;return JU=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function cN(){if(iN)return rN;return iN=1,rN=function(t){return function(e){return t(e)}}}var lN,uN,hN,dN,fN,gN,pN,vN,mN,yN,wN,bN,BN,EN,xN,CN,MN,FN,kN,SN,QN,UN,NN,TN,ON,IN,LN,PN={exports:{}};function DN(){return lN||(lN=1,function(t,e){var n=CU(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r&&n.process,A=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=A}(PN,PN.exports)),PN.exports}function RN(){if(hN)return uN;hN=1;var t=function(){if(nN)return eN;nN=1;var t=kU(),e=aN(),n=zU(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,eN=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=cN(),n=DN(),r=n&&n.isTypedArray,i=r?e(r):t;return uN=i}function HN(){if(fN)return dN;fN=1;var t=(lU||(lU=1,cU=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),cU),e=VU(),n=WU(),r=AN(),i=sN(),o=RN(),A=Object.prototype.hasOwnProperty;return dN=function(s,a){var c=n(s),l=!c&&e(s),u=!c&&!l&&r(s),h=!c&&!l&&!u&&o(s),d=c||l||u||h,f=d?t(s.length,String):[],g=f.length;for(var p in s)!a&&!A.call(s,p)||d&&("length"==p||u&&("offset"==p||"parent"==p)||h&&("buffer"==p||"byteLength"==p||"byteOffset"==p)||i(p,g))||f.push(p);return f},dN}function _N(){if(pN)return gN;pN=1;var t=Object.prototype;return gN=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function GN(){if(mN)return vN;return mN=1,vN=function(t,e){return function(n){return t(e(n))}},vN}function KN(){if(BN)return bN;BN=1;var t=_N(),e=function(){if(wN)return yN;wN=1;var t=GN()(Object.keys,Object);return yN=t}(),n=Object.prototype.hasOwnProperty;return bN=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function jN(){if(xN)return EN;xN=1;var t=QU(),e=aN();return EN=function(n){return null!=n&&e(n.length)&&!t(n)}}function zN(){if(MN)return CN;MN=1;var t=HN(),e=KN(),n=jN();return CN=function(r){return n(r)?t(r):e(r)}}function VN(){if(NN)return UN;NN=1;var t=SU(),e=_N(),n=QN?SN:(QN=1,SN=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return UN=function(i){if(!t(i))return n(i);var o=e(i),A=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&A.push(s);return A}}function WN(){if(ON)return TN;ON=1;var t=HN(),e=VN(),n=jN();return TN=function(r){return n(r)?t(r,!0):e(r)}}var YN,XN,qN,$N,ZN,JN,tT,eT,nT,rT,iT,oT,AT,sT,aT,cT,lT,uT,hT,dT,fT,gT,pT,vT,mT,yT,wT,bT,BT,ET,xT,CT,MT,FT,kT,ST,QT,UT,NT,TT,OT,IT,LT,PT,DT,RT,HT,_T,GT,KT,jT,zT,VT,WT,YT,XT,qT,$T,ZT,JT,tO,eO,nO,rO,iO,oO,AO,sO,aO,cO,lO,uO,hO,dO,fO,gO,pO,vO,mO,yO,wO,bO,BO,EO,xO,CO,MO,FO,kO,SO,QO,UO,NO,TO,OO,IO,LO,PO,DO,RO,HO,_O,GO,KO,jO,zO,VO,WO,YO,XO,qO,$O,ZO,JO,tI,eI,nI,rI,iI,oI,AI,sI,aI,cI,lI,uI,hI,dI,fI,gI,pI,vI,mI,yI,wI,bI,BI,EI,xI,CI,MI,FI,kI,SI,QI,UI,NI,TI,OI,II,LI,PI,DI,RI,HI,_I,GI,KI,jI,zI,VI,WI,YI,XI,qI,$I,ZI,JI,tL,eL,nL,rL,iL,oL,AL,sL,aL,cL,lL,uL,hL,dL,fL,gL,pL,vL,mL,yL,wL,bL,BL,EL,xL,CL,ML,FL,kL,SL,QL,UL,NL,TL,OL,IL,LL,PL,DL,RL,HL,_L,GL,KL,jL,zL,VL,WL,YL,XL,qL,$L,ZL,JL,tP,eP,nP,rP,iP,oP,AP,sP,aP,cP,lP,uP,hP,dP,fP,gP,pP,vP,mP,yP,wP,bP,BP,EP,xP,CP,MP,FP,kP,SP,QP,UP,NP,TP,OP,IP,LP,PP,DP,RP,HP,_P,GP,KP,jP,zP,VP,WP,YP,XP,qP,$P,ZP,JP,tD,eD,nD,rD,iD,oD,AD,sD,aD,cD,lD,uD,hD,dD,fD,gD,pD,vD,mD,yD,wD,bD,BD,ED,xD,CD,MD,FD,kD,SD,QD,UD,ND,TD,OD,ID,LD,PD,DD,RD,HD,_D,GD,KD,jD,zD,VD,WD,YD,XD,qD,$D,ZD,JD,tR,eR,nR,rR,iR,oR,AR,sR,aR,cR,lR,uR,hR,dR,fR,gR,pR,vR,mR,yR,wR,bR,BR,ER,xR,CR,MR,FR,kR,SR,QR,UR,NR,TR,OR,IR,LR,PR,DR,RR,HR,_R,GR,KR,jR,zR,VR,WR,YR,XR,qR,$R,ZR,JR,tH,eH,nH,rH,iH,oH,AH,sH,aH,cH,lH,uH,hH,dH,fH,gH,pH,vH,mH,yH,wH,bH,BH,EH,xH,CH,MH,FH,kH,SH,QH,UH,NH,TH,OH,IH,LH,PH,DH,RH,HH,_H,GH,KH,jH,zH,VH,WH={exports:{}};function YH(){return YN||(YN=1,function(t,e){var n=MU(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,A=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=A?A(n):new t.constructor(n);return t.copy(r),r}}(WH,WH.exports)),WH.exports}function XH(){if(qN)return XN;return qN=1,XN=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},XN}function qH(){if(ZN)return $N;return ZN=1,$N=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var A=t[n];e(A,n,t)&&(o[i++]=A)}return o},$N}function $H(){if(tT)return JN;return tT=1,JN=function(){return[]}}function ZH(){if(nT)return eT;nT=1;var t=qH(),e=$H(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return eT=r?function(e){return null==e?[]:(e=Object(e),t(r(e),function(t){return n.call(e,t)}))}:e}function JH(){if(AT)return oT;return AT=1,oT=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},oT}function t_(){if(aT)return sT;aT=1;var t=GN()(Object.getPrototypeOf,Object);return sT=t}function e_(){if(lT)return cT;lT=1;var t=JH(),e=t_(),n=ZH(),r=$H(),i=Object.getOwnPropertySymbols;return cT=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function n_(){if(fT)return dT;fT=1;var t=JH(),e=WU();return dT=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function r_(){if(pT)return gT;pT=1;var t=n_(),e=ZH(),n=zN();return gT=function(r){return t(r,n,e)}}function i_(){if(xT)return ET;xT=1;var t=TU()(MU(),"Set");return ET=t}function o_(){if(kT)return FT;kT=1;var t=function(){if(wT)return yT;wT=1;var t=TU()(MU(),"DataView");return yT=t}(),e=OU(),n=function(){if(BT)return bT;BT=1;var t=TU()(MU(),"Promise");return bT=t}(),r=i_(),i=function(){if(MT)return CT;MT=1;var t=TU()(MU(),"WeakMap");return CT=t}(),o=kU(),A=NU(),s="[object Map]",a="[object Promise]",c="[object Set]",l="[object WeakMap]",u="[object DataView]",h=A(t),d=A(e),f=A(n),g=A(r),p=A(i),v=o;return(t&&v(new t(new ArrayBuffer(1)))!=u||e&&v(new e)!=s||n&&v(n.resolve())!=a||r&&v(new r)!=c||i&&v(new i)!=l)&&(v=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?A(n):"";if(r)switch(r){case h:return u;case d:return s;case f:return a;case g:return c;case p:return l}return e}),FT=v}function A_(){if(NT)return UT;NT=1;var t=MU().Uint8Array;return UT=t}function s_(){if(OT)return TT;OT=1;var t=A_();return TT=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function a_(){if(GT)return _T;GT=1;var t=s_();return _T=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function c_(){if(jT)return KT;jT=1;var t=s_(),e=function(){if(LT)return IT;LT=1;var t=s_();return IT=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(DT)return PT;DT=1;var t=/\w*$/;return PT=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(HT)return RT;HT=1;var t=FU(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return RT=function(t){return n?Object(n.call(t)):{}}}(),i=a_();return KT=function(o,A,s){var a=o.constructor;switch(A){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new a(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new a;case"[object Number]":case"[object String]":return new a(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function l_(){if(VT)return zT;VT=1;var t=SU(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return zT=n}function u_(){if(YT)return WT;YT=1;var t=l_(),e=t_(),n=_N();return WT=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function h_(){if(ZT)return $T;ZT=1;var t=function(){if(qT)return XT;qT=1;var t=o_(),e=zU();return XT=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=cN(),n=DN(),r=n&&n.isMap,i=r?e(r):t;return $T=i}function d_(){if(nO)return eO;nO=1;var t=function(){if(tO)return JT;tO=1;var t=o_(),e=zU();return JT=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=cN(),n=DN(),r=n&&n.isSet,i=r?e(r):t;return eO=i}function f_(){if(iO)return rO;iO=1;var t=RU(),e=HU(),n=KU(),r=function(){if(kN)return FN;kN=1;var t=jU(),e=zN();return FN=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(LN)return IN;LN=1;var t=jU(),e=WN();return IN=function(n,r){return n&&t(r,e(r),n)}}(),o=YH(),A=XH(),s=function(){if(iT)return rT;iT=1;var t=jU(),e=ZH();return rT=function(n,r){return t(n,e(n),r)}}(),a=function(){if(hT)return uT;hT=1;var t=jU(),e=e_();return uT=function(n,r){return t(n,e(n),r)}}(),c=r_(),l=function(){if(mT)return vT;mT=1;var t=n_(),e=e_(),n=WN();return vT=function(r){return t(r,n,e)}}(),u=o_(),h=function(){if(QT)return ST;QT=1;var t=Object.prototype.hasOwnProperty;return ST=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},ST}(),d=c_(),f=u_(),g=WU(),p=AN(),v=h_(),m=SU(),y=d_(),w=zN(),b=WN(),B="[object Arguments]",E="[object Function]",x="[object Object]",C={};return C[B]=C["[object Array]"]=C["[object ArrayBuffer]"]=C["[object DataView]"]=C["[object Boolean]"]=C["[object Date]"]=C["[object Float32Array]"]=C["[object Float64Array]"]=C["[object Int8Array]"]=C["[object Int16Array]"]=C["[object Int32Array]"]=C["[object Map]"]=C["[object Number]"]=C[x]=C["[object RegExp]"]=C["[object Set]"]=C["[object String]"]=C["[object Symbol]"]=C["[object Uint8Array]"]=C["[object Uint8ClampedArray]"]=C["[object Uint16Array]"]=C["[object Uint32Array]"]=!0,C["[object Error]"]=C[E]=C["[object WeakMap]"]=!1,rO=function M(F,k,S,Q,U,N){var T,O=1&k,I=2&k,L=4&k;if(S&&(T=U?S(F,Q,U,N):S(F)),void 0!==T)return T;if(!m(F))return F;var P=g(F);if(P){if(T=h(F),!O)return A(F,T)}else{var D=u(F),R=D==E||"[object GeneratorFunction]"==D;if(p(F))return o(F,O);if(D==x||D==B||R&&!U){if(T=I||R?{}:f(F),!O)return I?a(F,i(T,F)):s(F,r(T,F))}else{if(!C[D])return U?F:{};T=d(F,D,O)}}N||(N=new t);var H=N.get(F);if(H)return H;N.set(F,T),y(F)?F.forEach(function(t){T.add(M(t,k,S,t,F,N))}):v(F)&&F.forEach(function(t,e){T.set(e,M(t,k,S,e,F,N))});var _=P?void 0:(L?I?l:c:I?b:w)(F);return e(_||F,function(t,e){_&&(t=F[e=t]),n(T,e,M(t,k,S,e,F,N))}),T},rO}function g_(){if(AO)return oO;AO=1;var t=f_();return oO=function(e){return t(e,4)}}function p_(){if(aO)return sO;return aO=1,sO=function(t){return function(){return t}}}function v_(){if(hO)return uO;hO=1;var t=(lO||(lO=1,cO=function(t){return function(e,n,r){for(var i=-1,o=Object(e),A=r(e),s=A.length;s--;){var a=A[t?s:++i];if(!1===n(o[a],a,o))break}return e}}),cO),e=t();return uO=e}function m_(){if(fO)return dO;fO=1;var t=v_(),e=zN();return dO=function(n,r){return n&&t(n,r,e)}}function y_(){if(mO)return vO;mO=1;var t=m_(),e=function(){if(pO)return gO;pO=1;var t=jN();return gO=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,A=n?o:-1,s=Object(r);(n?A--:++A<o)&&!1!==i(s[A],A,s););return r}},gO}(),n=e(t);return vO=n}function w_(){if(wO)return yO;return wO=1,yO=function(t){return t}}function b_(){if(BO)return bO;BO=1;var t=w_();return bO=function(e){return"function"==typeof e?e:t}}function B_(){if(xO)return EO;xO=1;var t=HU(),e=y_(),n=b_(),r=WU();return EO=function(i,o){return(r(i)?t:e)(i,n(o))}}function E_(){return MO?CO:(MO=1,CO=B_())}function x_(){if(OO)return TO;OO=1;var t=DU(),e=QO?SO:(QO=1,SO=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=NO?UO:(NO=1,UO=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,TO=r}function C_(){if(DO)return PO;return DO=1,PO=function(t,e){return t.has(e)}}function M_(){if(HO)return RO;HO=1;var t=x_(),e=(LO||(LO=1,IO=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),IO),n=C_();return RO=function(r,i,o,A,s,a){var c=1&o,l=r.length,u=i.length;if(l!=u&&!(c&&u>l))return!1;var h=a.get(r),d=a.get(i);if(h&&d)return h==i&&d==r;var f=-1,g=!0,p=2&o?new t:void 0;for(a.set(r,i),a.set(i,r);++f<l;){var v=r[f],m=i[f];if(A)var y=c?A(m,v,f,i,r,a):A(v,m,f,r,i,a);if(void 0!==y){if(y)continue;g=!1;break}if(p){if(!e(i,function(t,e){if(!n(p,e)&&(v===t||s(v,t,o,A,a)))return p.push(e)})){g=!1;break}}else if(v!==m&&!s(v,m,o,A,a)){g=!1;break}}return a.delete(r),a.delete(i),g},RO}function F_(){if(jO)return KO;return jO=1,KO=function(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n},KO}function k_(){if(VO)return zO;VO=1;var t=FU(),e=A_(),n=BU(),r=M_(),i=(GO||(GO=1,_O=function(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}),_O),o=F_(),A=t?t.prototype:void 0,s=A?A.valueOf:void 0;return zO=function(t,A,a,c,l,u,h){switch(a){case"[object DataView]":if(t.byteLength!=A.byteLength||t.byteOffset!=A.byteOffset)return!1;t=t.buffer,A=A.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=A.byteLength||!u(new e(t),new e(A)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+A);case"[object Error]":return t.name==A.name&&t.message==A.message;case"[object RegExp]":case"[object String]":return t==A+"";case"[object Map]":var d=i;case"[object Set]":var f=1&c;if(d||(d=o),t.size!=A.size&&!f)return!1;var g=h.get(t);if(g)return g==A;c|=2,h.set(t,A);var p=r(d(t),d(A),c,l,u,h);return h.delete(t),p;case"[object Symbol]":if(s)return s.call(t)==s.call(A)}return!1}}function S_(){if(qO)return XO;qO=1;var t=RU(),e=M_(),n=k_(),r=function(){if(YO)return WO;YO=1;var t=r_(),e=Object.prototype.hasOwnProperty;return WO=function(n,r,i,o,A,s){var a=1&i,c=t(n),l=c.length;if(l!=t(r).length&&!a)return!1;for(var u=l;u--;){var h=c[u];if(!(a?h in r:e.call(r,h)))return!1}var d=s.get(n),f=s.get(r);if(d&&f)return d==r&&f==n;var g=!0;s.set(n,r),s.set(r,n);for(var p=a;++u<l;){var v=n[h=c[u]],m=r[h];if(o)var y=a?o(m,v,h,r,n,s):o(v,m,h,n,r,s);if(!(void 0===y?v===m||A(v,m,i,o,s):y)){g=!1;break}p||(p="constructor"==h)}if(g&&!p){var w=n.constructor,b=r.constructor;w==b||!("constructor"in n)||!("constructor"in r)||"function"==typeof w&&w instanceof w&&"function"==typeof b&&b instanceof b||(g=!1)}return s.delete(n),s.delete(r),g},WO}(),i=o_(),o=WU(),A=AN(),s=RN(),a="[object Arguments]",c="[object Array]",l="[object Object]",u=Object.prototype.hasOwnProperty;return XO=function(h,d,f,g,p,v){var m=o(h),y=o(d),w=m?c:i(h),b=y?c:i(d),B=(w=w==a?l:w)==l,E=(b=b==a?l:b)==l,x=w==b;if(x&&A(h)){if(!A(d))return!1;m=!0,B=!1}if(x&&!B)return v||(v=new t),m||s(h)?e(h,d,f,g,p,v):n(h,d,w,f,g,p,v);if(!(1&f)){var C=B&&u.call(h,"__wrapped__"),M=E&&u.call(d,"__wrapped__");if(C||M){var F=C?h.value():h,k=M?d.value():d;return v||(v=new t),p(F,k,f,g,v)}}return!!x&&(v||(v=new t),r(h,d,f,g,p,v))}}function Q_(){if(ZO)return $O;ZO=1;var t=S_(),e=zU();return $O=function n(r,i,o,A,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,A,n,s))},$O}function U_(){if(nI)return eI;nI=1;var t=SU();return eI=function(e){return e==e&&!t(e)}}function N_(){if(AI)return oI;return AI=1,oI=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function T_(){if(aI)return sI;aI=1;var t=function(){if(tI)return JO;tI=1;var t=RU(),e=Q_();return JO=function(n,r,i,o){var A=i.length,s=A,a=!o;if(null==n)return!s;for(n=Object(n);A--;){var c=i[A];if(a&&c[2]?c[1]!==n[c[0]]:!(c[0]in n))return!1}for(;++A<s;){var l=(c=i[A])[0],u=n[l],h=c[1];if(a&&c[2]){if(void 0===u&&!(l in n))return!1}else{var d=new t;if(o)var f=o(u,h,l,n,r,d);if(!(void 0===f?e(h,u,3,o,d):f))return!1}}return!0},JO}(),e=function(){if(iI)return rI;iI=1;var t=U_(),e=zN();return rI=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],A=n[o];r[i]=[o,A,t(A)]}return r},rI}(),n=N_();return sI=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function O_(){if(lI)return cI;lI=1;var t=kU(),e=zU();return cI=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function I_(){if(hI)return uI;hI=1;var t=WU(),e=O_(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return uI=function(i,o){if(t(i))return!1;var A=typeof i;return!("number"!=A&&"symbol"!=A&&"boolean"!=A&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function L_(){if(pI)return gI;pI=1;var t=function(){if(fI)return dI;fI=1;var t=DU();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var A=n.apply(this,t);return i.cache=o.set(e,A)||o,A};return i.cache=new(e.Cache||t),i}return e.Cache=t,dI=e}();return gI=function(e){var n=t(e,function(t){return 500===r.size&&r.clear(),t}),r=n.cache;return n}}function P_(){if(wI)return yI;return wI=1,yI=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},yI}function D_(){if(xI)return EI;xI=1;var t=function(){if(BI)return bI;BI=1;var t=FU(),e=P_(),n=WU(),r=O_(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return bI=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var A=i+"";return"0"==A&&1/i==-1/0?"-0":A},bI}();return EI=function(e){return null==e?"":t(e)}}function R_(){if(MI)return CI;MI=1;var t=WU(),e=I_(),n=function(){if(mI)return vI;mI=1;var t=L_(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t(function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)}),r});return vI=r}(),r=D_();return CI=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function H_(){if(kI)return FI;kI=1;var t=O_();return FI=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function __(){if(QI)return SI;QI=1;var t=R_(),e=H_();return SI=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},SI}function G_(){if(LI)return II;LI=1;var t=R_(),e=VU(),n=WU(),r=sN(),i=aN(),o=H_();return II=function(A,s,a){for(var c=-1,l=(s=t(s,A)).length,u=!1;++c<l;){var h=o(s[c]);if(!(u=null!=A&&a(A,h)))break;A=A[h]}return u||++c!=l?u:!!(l=null==A?0:A.length)&&i(l)&&r(h,l)&&(n(A)||e(A))},II}function K_(){if(DI)return PI;DI=1;var t=OI?TI:(OI=1,TI=function(t,e){return null!=t&&e in Object(t)}),e=G_();return PI=function(n,r){return null!=n&&e(n,r,t)}}function j_(){if(HI)return RI;HI=1;var t=Q_(),e=function(){if(NI)return UI;NI=1;var t=__();return UI=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=K_(),r=I_(),i=U_(),o=N_(),A=H_();return RI=function(s,a){return r(s)&&i(a)?o(A(s),a):function(r){var i=e(r,s);return void 0===i&&i===a?n(r,s):t(a,i,3)}}}function z_(){if(GI)return _I;return GI=1,_I=function(t){return function(e){return null==e?void 0:e[t]}}}function V_(){if(VI)return zI;VI=1;var t=z_(),e=function(){if(jI)return KI;jI=1;var t=__();return KI=function(e){return function(n){return t(n,e)}}}(),n=I_(),r=H_();return zI=function(i){return n(i)?t(r(i)):e(i)}}function W_(){if(YI)return WI;YI=1;var t=T_(),e=j_(),n=w_(),r=WU(),i=V_();return WI=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function Y_(){if(qI)return XI;qI=1;var t=qH(),e=function(){if(kO)return FO;kO=1;var t=y_();return FO=function(e,n){var r=[];return t(e,function(t,e,i){n(t,e,i)&&r.push(t)}),r},FO}(),n=W_(),r=WU();return XI=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function X_(){if(tL)return JI;tL=1;var t=function(){if(ZI)return $I;ZI=1;var t=Object.prototype.hasOwnProperty;return $I=function(e,n){return null!=e&&t.call(e,n)}}(),e=G_();return JI=function(n,r){return null!=n&&e(n,r,t)}}function q_(){if(nL)return eL;nL=1;var t=KN(),e=o_(),n=VU(),r=WU(),i=jN(),o=AN(),A=_N(),s=RN(),a=Object.prototype.hasOwnProperty;return eL=function(c){if(null==c)return!0;if(i(c)&&(r(c)||"string"==typeof c||"function"==typeof c.splice||o(c)||s(c)||n(c)))return!c.length;var l=e(c);if("[object Map]"==l||"[object Set]"==l)return!c.size;if(A(c))return!t(c).length;for(var u in c)if(a.call(c,u))return!1;return!0}}function $_(){if(iL)return rL;return iL=1,rL=function(t){return void 0===t}}function Z_(){if(AL)return oL;AL=1;var t=y_(),e=jN();return oL=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,function(t,e,n){o[++i]=r(t,e,n)}),o},oL}function J_(){if(aL)return sL;aL=1;var t=P_(),e=W_(),n=Z_(),r=WU();return sL=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function tG(){if(fL)return dL;fL=1;var t=(lL||(lL=1,cL=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),cL),e=y_(),n=W_(),r=(hL||(hL=1,uL=function(t,e,n,r,i){return i(t,function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)}),n}),uL),i=WU();return dL=function(o,A,s){var a=i(o)?t:r,c=arguments.length<3;return a(o,n(A,4),s,c,e)},dL}function eG(){if(xL)return EL;xL=1;var t=function(){if(mL)return vL;mL=1;var t=z_()("length");return vL=t}(),e=function(){if(wL)return yL;wL=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return yL=function(e){return t.test(e)}}(),n=function(){if(BL)return bL;BL=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",A="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",a="[\\ufe0e\\ufe0f]?",c=a+s+"(?:\\u200d(?:"+[i,o,A].join("|")+")"+a+s+")*",l="(?:"+[i+n+"?",n,o,A,e].join("|")+")",u=RegExp(r+"(?="+r+")|"+l+c,"g");return bL=function(t){for(var e=u.lastIndex=0;u.test(t);)++e;return e}}();return EL=function(r){return e(r)?n(r):t(r)}}function nG(){if(ML)return CL;ML=1;var t=KN(),e=o_(),n=jN(),r=function(){if(pL)return gL;pL=1;var t=kU(),e=WU(),n=zU();return gL=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=eG();return CL=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var A=e(o);return"[object Map]"==A||"[object Set]"==A?o.size:t(o).length}}function rG(){if(kL)return FL;kL=1;var t=HU(),e=l_(),n=m_(),r=W_(),i=t_(),o=WU(),A=AN(),s=QU(),a=SU(),c=RN();return FL=function(l,u,h){var d=o(l),f=d||A(l)||c(l);if(u=r(u,4),null==h){var g=l&&l.constructor;h=f?d?new g:[]:a(l)&&s(g)?e(i(l)):{}}return(f?t:n)(l,function(t,e,n){return u(h,t,e,n)}),h},FL}function iG(){if(NL)return UL;NL=1;var t=JH(),e=function(){if(QL)return SL;QL=1;var t=FU(),e=VU(),n=WU(),r=t?t.isConcatSpreadable:void 0;return SL=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return UL=function n(r,i,o,A,s){var a=-1,c=r.length;for(o||(o=e),s||(s=[]);++a<c;){var l=r[a];i>0&&o(l)?i>1?n(l,i-1,o,A,s):t(s,l):A||(s[s.length]=l)}return s},UL}function oG(){if(LL)return IL;LL=1;var t=OL?TL:(OL=1,TL=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}),e=Math.max;return IL=function(n,r,i){return r=e(void 0===r?n.length-1:r,0),function(){for(var o=arguments,A=-1,s=e(o.length-r,0),a=Array(s);++A<s;)a[A]=o[r+A];A=-1;for(var c=Array(r+1);++A<r;)c[A]=o[A];return c[r]=i(a),t(n,this,c)}},IL}function AG(){if(GL)return _L;GL=1;var t=function(){if(DL)return PL;DL=1;var t=p_(),e=_U(),n=w_();return PL=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(HL)return RL;HL=1;var t=Date.now;return RL=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},RL}(),n=e(t);return _L=n}function sG(){if(jL)return KL;jL=1;var t=w_(),e=oG(),n=AG();return KL=function(r,i){return n(e(r,i,t),r+"")}}function aG(){if(VL)return zL;return VL=1,zL=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},zL}function cG(){if(ZL)return $L;ZL=1;var t=aG(),e=YL?WL:(YL=1,WL=function(t){return t!=t}),n=(qL||(qL=1,XL=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),XL);return $L=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function lG(){if(AP)return oP;AP=1;var t=i_(),e=iP?rP:(iP=1,rP=function(){}),n=F_(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return oP=r}function uG(){if(aP)return sP;aP=1;var t=x_(),e=function(){if(tP)return JL;tP=1;var t=cG();return JL=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(nP||(nP=1,eP=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),eP),r=C_(),i=lG(),o=F_();return sP=function(A,s,a){var c=-1,l=e,u=A.length,h=!0,d=[],f=d;if(a)h=!1,l=n;else if(u>=200){var g=s?null:i(A);if(g)return o(g);h=!1,l=r,f=new t}else f=s?[]:d;t:for(;++c<u;){var p=A[c],v=s?s(p):p;if(p=a||0!==p?p:0,h&&v==v){for(var m=f.length;m--;)if(f[m]===v)continue t;s&&f.push(v),d.push(p)}else l(f,v,a)||(f!==d&&f.push(v),d.push(p))}return d},sP}function hG(){if(lP)return cP;lP=1;var t=jN(),e=zU();return cP=function(n){return e(n)&&t(n)}}function dG(){if(hP)return uP;hP=1;var t=iG(),e=sG(),n=uG(),r=hG(),i=e(function(e){return n(t(e,1,r,!0))});return uP=i}function fG(){if(pP)return gP;pP=1;var t=function(){if(fP)return dP;fP=1;var t=P_();return dP=function(e,n){return t(n,function(t){return e[t]})}}(),e=zN();return gP=function(n){return null==n?[]:t(n,e(n))}}function gG(){if(mP)return vP;var t;mP=1;try{t={clone:g_(),constant:p_(),each:E_(),filter:Y_(),has:X_(),isArray:WU(),isEmpty:q_(),isFunction:QU(),isUndefined:$_(),keys:zN(),map:J_(),reduce:tG(),size:nG(),transform:rG(),union:dG(),values:fG()}}catch(t){}return t||(t=window._),vP=t}function pG(){if(wP)return yP;wP=1;var t=gG();yP=n;var e="\0";function n(n){this._isDirected=!t.has(n,"directed")||n.directed,this._isMultigraph=!!t.has(n,"multigraph")&&n.multigraph,this._isCompound=!!t.has(n,"compound")&&n.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function r(t,e){t[e]?t[e]++:t[e]=1}function i(t,e){--t[e]||delete t[e]}function o(e,n,r,i){var o=""+n,A=""+r;if(!e&&o>A){var s=o;o=A,A=s}return o+""+A+""+(t.isUndefined(i)?"\0":i)}function A(t,e){return o(t,e.v,e.w,e.name)}return n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(t){return this._label=t,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return t.keys(this._nodes)},n.prototype.sources=function(){var e=this;return t.filter(this.nodes(),function(n){return t.isEmpty(e._in[n])})},n.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),function(n){return t.isEmpty(e._out[n])})},n.prototype.setNodes=function(e,n){var r=arguments,i=this;return t.each(e,function(t){r.length>1?i.setNode(t,n):i.setNode(t)}),this},n.prototype.setNode=function(n,r){return t.has(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=r),this):(this._nodes[n]=arguments.length>1?r:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=e,this._children[n]={},this._children[e][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)},n.prototype.node=function(t){return this._nodes[t]},n.prototype.hasNode=function(e){return t.has(this._nodes,e)},n.prototype.removeNode=function(e){var n=this;if(t.has(this._nodes,e)){var r=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),function(t){n.setParent(t)}),delete this._children[e]),t.each(t.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},n.prototype.setParent=function(n,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=e;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===n)throw new Error("Setting "+r+" as parent of "+n+" would create a cycle");this.setNode(r)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=r,this._children[r][n]=!0,this},n.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},n.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==e)return n}},n.prototype.children=function(n){if(t.isUndefined(n)&&(n=e),this._isCompound){var r=this._children[n];if(r)return t.keys(r)}else{if(n===e)return this.nodes();if(this.hasNode(n))return[]}},n.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},n.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},n.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},n.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},n.prototype.filterNodes=function(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;t.each(this._nodes,function(t,r){e(r)&&n.setNode(r,t)}),t.each(this._edgeObjs,function(t){n.hasNode(t.v)&&n.hasNode(t.w)&&n.setEdge(t,r.edge(t))});var i={};function o(t){var e=r.parent(t);return void 0===e||n.hasNode(e)?(i[t]=e,e):e in i?i[e]:o(e)}return this._isCompound&&t.each(n.nodes(),function(t){n.setParent(t,o(t))}),n},n.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return t.values(this._edgeObjs)},n.prototype.setPath=function(e,n){var r=this,i=arguments;return t.reduce(e,function(t,e){return i.length>1?r.setEdge(t,e,n):r.setEdge(t,e),e}),this},n.prototype.setEdge=function(){var e,n,i,A,s=!1,a=arguments[0];"object"==typeof a&&null!==a&&"v"in a?(e=a.v,n=a.w,i=a.name,2===arguments.length&&(A=arguments[1],s=!0)):(e=a,n=arguments[1],i=arguments[3],arguments.length>2&&(A=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var c=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,c))return s&&(this._edgeLabels[c]=A),this;if(!t.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[c]=s?A:this._defaultEdgeLabelFn(e,n,i);var l=function(t,e,n,r){var i=""+e,o=""+n;if(!t&&i>o){var A=i;i=o,o=A}var s={v:i,w:o};r&&(s.name=r);return s}(this._isDirected,e,n,i);return e=l.v,n=l.w,Object.freeze(l),this._edgeObjs[c]=l,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][c]=l,this._out[e][c]=l,this._edgeCount++,this},n.prototype.edge=function(t,e,n){var r=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,t,e,n);return this._edgeLabels[r]},n.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},n.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,t,e,n),s=this._edgeObjs[r];return s&&(t=s.v,e=s.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[e],t),i(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},n.prototype.inEdges=function(e,n){var r=this._in[e];if(r){var i=t.values(r);return n?t.filter(i,function(t){return t.v===n}):i}},n.prototype.outEdges=function(e,n){var r=this._out[e];if(r){var i=t.values(r);return n?t.filter(i,function(t){return t.w===n}):i}},n.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},yP}function vG(){return xP?EP:(xP=1,EP={Graph:pG(),version:BP?bP:(BP=1,bP="2.1.8")})}function mG(){if(MP)return CP;MP=1;var t=gG(),e=pG();function n(e){return t.map(e.nodes(),function(n){var r=e.node(n),i=e.parent(n),o={v:n};return t.isUndefined(r)||(o.value=r),t.isUndefined(i)||(o.parent=i),o})}function r(e){return t.map(e.edges(),function(n){var r=e.edge(n),i={v:n.v,w:n.w};return t.isUndefined(n.name)||(i.name=n.name),t.isUndefined(r)||(i.value=r),i})}return CP={write:function(e){var i={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:n(e),edges:r(e)};t.isUndefined(e.graph())||(i.value=t.clone(e.graph()));return i},read:function(n){var r=new e(n.options).setGraph(n.value);return t.each(n.nodes,function(t){r.setNode(t.v,t.value),t.parent&&r.setParent(t.v,t.parent)}),t.each(n.edges,function(t){r.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),r}},CP}function yG(){if(kP)return FP;kP=1;var t=gG();return FP=function(e){var n,r={},i=[];function o(i){t.has(r,i)||(r[i]=!0,n.push(i),t.each(e.successors(i),o),t.each(e.predecessors(i),o))}return t.each(e.nodes(),function(t){n=[],o(t),n.length&&i.push(n)}),i},FP}function wG(){if(QP)return SP;QP=1;var t=gG();function e(){this._arr=[],this._keyIndices={}}return SP=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(t){return t.key})},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,n){var r=this._keyIndices;if(e=String(e),!t.has(r,e)){var i=this._arr,o=i.length;return r[e]=o,i.push({key:e,priority:n}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)},e.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},SP}function bG(){if(NP)return UP;NP=1;var t=gG(),e=wG();UP=function(t,r,i,o){return function(t,n,r,i){var o,A,s={},a=new e,c=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),c=A.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);c<n.distance&&(n.distance=c,n.predecessor=o,a.decrease(e,c))};t.nodes().forEach(function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},a.add(t,e)});for(;a.size()>0&&(o=a.removeMin(),(A=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(c);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return UP}function BG(){if(OP)return TP;OP=1;var t=bG(),e=gG();return TP=function(n,r,i){return e.transform(n.nodes(),function(e,o){e[o]=t(n,o,r,i)},{})},TP}function EG(){if(LP)return IP;LP=1;var t=gG();return IP=function(e){var n=0,r=[],i={},o=[];function A(s){var a=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),e.successors(s).forEach(function(e){t.has(i,e)?i[e].onStack&&(a.lowlink=Math.min(a.lowlink,i[e].index)):(A(e),a.lowlink=Math.min(a.lowlink,i[e].lowlink))}),a.lowlink===a.index){var c,l=[];do{c=r.pop(),i[c].onStack=!1,l.push(c)}while(s!==c);o.push(l)}}return e.nodes().forEach(function(e){t.has(i,e)||A(e)}),o},IP}function xG(){if(DP)return PP;DP=1;var t=gG(),e=EG();return PP=function(n){return t.filter(e(n),function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])})},PP}function CG(){if(HP)return RP;HP=1;var t=gG();RP=function(t,n,r){return function(t,e,n){var r={},i=t.nodes();return i.forEach(function(t){r[t]={},r[t][t]={distance:0},i.forEach(function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})}),n(t).forEach(function(n){var i=n.v===t?n.w:n.v,o=e(n);r[t][i]={distance:o,predecessor:t}})}),i.forEach(function(t){var e=r[t];i.forEach(function(n){var o=r[n];i.forEach(function(n){var r=o[t],i=e[n],A=o[n],s=r.distance+i.distance;s<A.distance&&(A.distance=s,A.predecessor=i.predecessor)})})}),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return RP}function MG(){if(GP)return _P;GP=1;var t=gG();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),function A(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),A),delete i[s],o.push(s))}),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return _P=e,e.CycleException=n,n.prototype=new Error,_P}function FG(){if(jP)return KP;jP=1;var t=MG();return KP=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0},KP}function kG(){if(VP)return zP;VP=1;var t=gG();function e(n,r,i,o,A,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(A(r),function(t){e(n,t,i,o,A,s)}),i&&s.push(r))}return zP=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),A=[],s={};return t.each(r,function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,A)}),A},zP}function SG(){if(YP)return WP;YP=1;var t=kG();return WP=function(e,n){return t(e,n,"post")},WP}function QG(){if(qP)return XP;qP=1;var t=kG();return XP=function(e,n){return t(e,n,"pre")},XP}function UG(){if(ZP)return $P;ZP=1;var t=gG(),e=pG(),n=wG();return $P=function(r,i){var o,A=new e,s={},a=new n;function c(t){var e=t.v===o?t.w:t.v,n=a.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,a.decrease(e,r))}}if(0===r.nodeCount())return A;t.each(r.nodes(),function(t){a.add(t,Number.POSITIVE_INFINITY),A.setNode(t)}),a.decrease(r.nodes()[0],0);var l=!1;for(;a.size()>0;){if(o=a.removeMin(),t.has(s,o))A.setEdge(o,s[o]);else{if(l)throw new Error("Input graph is not connected: "+r);l=!0}r.nodeEdges(o).forEach(c)}return A},$P}function NG(){if(nD)return eD;nD=1;var t=vG();return eD={Graph:t.Graph,json:mG(),alg:tD?JP:(tD=1,JP={components:yG(),dijkstra:bG(),dijkstraAll:BG(),findCycles:xG(),floydWarshall:CG(),isAcyclic:FG(),postorder:SG(),preorder:QG(),prim:UG(),tarjan:EG(),topsort:MG()}),version:t.version}}function TG(){if(iD)return rD;var t;iD=1;try{t=NG()}catch(t){}return t||(t=window.graphlib),rD=t}function OG(){if(AD)return oD;AD=1;var t=f_();return oD=function(e){return t(e,5)}}function IG(){if(aD)return sD;aD=1;var t=BU(),e=jN(),n=sN(),r=SU();return sD=function(i,o,A){if(!r(A))return!1;var s=typeof o;return!!("number"==s?e(A)&&n(o,A.length):"string"==s&&o in A)&&t(A[o],i)},sD}function LG(){if(lD)return cD;lD=1;var t=sG(),e=BU(),n=IG(),r=WN(),i=Object.prototype,o=i.hasOwnProperty,A=t(function(t,A){t=Object(t);var s=-1,a=A.length,c=a>2?A[2]:void 0;for(c&&n(A[0],A[1],c)&&(a=1);++s<a;)for(var l=A[s],u=r(l),h=-1,d=u.length;++h<d;){var f=u[h],g=t[f];(void 0===g||e(g,i[f])&&!o.call(t,f))&&(t[f]=l[f])}return t});return cD=A}function PG(){if(pD)return gD;pD=1;var t=function(){if(fD)return dD;fD=1;var t=/\s/;return dD=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},dD}(),e=/^\s+/;return gD=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function DG(){if(wD)return yD;wD=1;var t=function(){if(mD)return vD;mD=1;var t=PG(),e=SU(),n=O_(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,A=parseInt;return vD=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var a="function"==typeof s.valueOf?s.valueOf():s;s=e(a)?a+"":a}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var c=i.test(s);return c||o.test(s)?A(s.slice(2),c?2:8):r.test(s)?NaN:+s}}(),e=1/0;return yD=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function RG(){if(xD)return ED;xD=1;var t=aG(),e=W_(),n=function(){if(BD)return bD;BD=1;var t=DG();return bD=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return ED=function(i,o,A){var s=null==i?0:i.length;if(!s)return-1;var a=null==A?0:n(A);return a<0&&(a=r(s+a,0)),t(i,e(o,3),a)},ED}function HG(){if(MD)return CD;MD=1;var t=function(){if(hD)return uD;hD=1;var t=W_(),e=jN(),n=zN();return uD=function(r){return function(i,o,A){var s=Object(i);if(!e(i)){var a=t(o,3);i=n(i),o=function(t){return a(s[t],t,s)}}var c=r(i,o,A);return c>-1?s[a?i[c]:c]:void 0}},uD}(),e=t(RG());return CD=e}function _G(){if(kD)return FD;kD=1;var t=iG();return FD=function(e){return(null==e?0:e.length)?t(e,1):[]}}function GG(){if(QD)return SD;QD=1;var t=v_(),e=b_(),n=WN();return SD=function(r,i){return null==r?r:t(r,e(i),n)}}function KG(){if(ND)return UD;return ND=1,UD=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0},UD}function jG(){if(OD)return TD;OD=1;var t=GU(),e=m_(),n=W_();return TD=function(r,i){var o={};return i=n(i,3),e(r,function(e,n,r){t(o,n,i(e,n,r))}),o}}function zG(){if(LD)return ID;LD=1;var t=O_();return ID=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var A=e[i],s=n(A);if(null!=s&&(void 0===a?s==s&&!t(s):r(s,a)))var a=s,c=A}return c},ID}function VG(){if(HD)return RD;HD=1;var t=zG(),e=DD?PD:(DD=1,PD=function(t,e){return t>e}),n=w_();return RD=function(r){return r&&r.length?t(r,n,e):void 0}}function WG(){if(GD)return _D;GD=1;var t=GU(),e=BU();return _D=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function YG(){if(VD)return zD;return VD=1,zD=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function XG(){if(qD)return XD;qD=1;var t=WG(),e=YH(),n=a_(),r=XH(),i=u_(),o=VU(),A=WU(),s=hG(),a=AN(),c=QU(),l=SU(),u=function(){if(jD)return KD;jD=1;var t=kU(),e=t_(),n=zU(),r=Function.prototype,i=Object.prototype,o=r.toString,A=i.hasOwnProperty,s=o.call(Object);return KD=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var a=A.call(i,"constructor")&&i.constructor;return"function"==typeof a&&a instanceof a&&o.call(a)==s}}(),h=RN(),d=YG(),f=function(){if(YD)return WD;YD=1;var t=jU(),e=WN();return WD=function(n){return t(n,e(n))}}();return XD=function(g,p,v,m,y,w,b){var B=d(g,v),E=d(p,v),x=b.get(E);if(x)t(g,v,x);else{var C=w?w(B,E,v+"",g,p,b):void 0,M=void 0===C;if(M){var F=A(E),k=!F&&a(E),S=!F&&!k&&h(E);C=E,F||k||S?A(B)?C=B:s(B)?C=r(B):k?(M=!1,C=e(E,!0)):S?(M=!1,C=n(E,!0)):C=[]:u(E)||o(E)?(C=B,o(B)?C=f(B):l(B)&&!c(B)||(C=i(E))):M=!1}M&&(b.set(E,C),y(C,E,m,w,b),b.delete(E)),t(g,v,C)}}}function qG(){if(nR)return eR;nR=1;var t=function(){if(ZD)return $D;ZD=1;var t=RU(),e=WG(),n=v_(),r=XG(),i=SU(),o=WN(),A=YG();return $D=function s(a,c,l,u,h){a!==c&&n(c,function(n,o){if(h||(h=new t),i(n))r(a,c,o,l,s,u,h);else{var d=u?u(A(a,o),n,o+"",a,c,h):void 0;void 0===d&&(d=n),e(a,o,d)}},o)},$D}(),e=function(){if(tR)return JD;tR=1;var t=sG(),e=IG();return JD=function(n){return t(function(t,r){var i=-1,o=r.length,A=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(A=n.length>3&&"function"==typeof A?(o--,A):void 0,s&&e(r[0],r[1],s)&&(A=o<3?void 0:A,o=1),t=Object(t);++i<o;){var a=r[i];a&&n(t,a,i,A)}return t})},JD}(),n=e(function(e,n,r){t(e,n,r)});return eR=n}function $G(){if(iR)return rR;return iR=1,rR=function(t,e){return t<e}}function ZG(){if(AR)return oR;AR=1;var t=zG(),e=$G(),n=w_();return oR=function(r){return r&&r.length?t(r,n,e):void 0}}function JG(){if(aR)return sR;aR=1;var t=zG(),e=W_(),n=$G();return sR=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}function tK(){if(lR)return cR;lR=1;var t=MU();return cR=function(){return t.Date.now()}}function eK(){if(fR)return dR;fR=1;var t=__(),e=function(){if(hR)return uR;hR=1;var t=KU(),e=R_(),n=sN(),r=SU(),i=H_();return uR=function(o,A,s,a){if(!r(o))return o;for(var c=-1,l=(A=e(A,o)).length,u=l-1,h=o;null!=h&&++c<l;){var d=i(A[c]),f=s;if("__proto__"===d||"constructor"===d||"prototype"===d)return o;if(c!=u){var g=h[d];void 0===(f=a?a(g,d,h):void 0)&&(f=r(g)?g:n(A[c+1])?[]:{})}t(h,d,f),h=h[d]}return o},uR}(),n=R_();return dR=function(r,i,o){for(var A=-1,s=i.length,a={};++A<s;){var c=i[A],l=t(r,c);o(l,c)&&e(a,n(c,r),l)}return a},dR}function nK(){if(wR)return yR;wR=1;var t=function(){if(pR)return gR;pR=1;var t=eK(),e=K_();return gR=function(n,r){return t(n,r,function(t,r){return e(n,r)})}}(),e=function(){if(mR)return vR;mR=1;var t=_G(),e=oG(),n=AG();return vR=function(r){return n(e(r,void 0,t),r+"")}}(),n=e(function(e,n){return null==e?{}:t(e,n)});return yR=n}function rK(){if(xR)return ER;xR=1;var t=function(){if(BR)return bR;BR=1;var t=Math.ceil,e=Math.max;return bR=function(n,r,i,o){for(var A=-1,s=e(t((r-n)/(i||1)),0),a=Array(s);s--;)a[o?s:++A]=n,n+=i;return a},bR}(),e=IG(),n=DG();return ER=function(r){return function(i,o,A){return A&&"number"!=typeof A&&e(i,o,A)&&(o=A=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),A=void 0===A?i<o?1:-1:n(A),t(i,o,A,r)}},ER}function iK(){if(MR)return CR;MR=1;var t=rK()();return CR=t}function oK(){if(NR)return UR;NR=1;var t=function(){if(QR)return SR;QR=1;var t=O_();return SR=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,A=t(e),s=void 0!==n,a=null===n,c=n==n,l=t(n);if(!a&&!l&&!A&&e>n||A&&s&&c&&!a&&!l||i&&s&&c||!r&&c||!o)return 1;if(!i&&!A&&!l&&e<n||l&&r&&o&&!i&&!A||a&&r&&o||!s&&o||!c)return-1}return 0}}();return UR=function(e,n,r){for(var i=-1,o=e.criteria,A=n.criteria,s=o.length,a=r.length;++i<s;){var c=t(o[i],A[i]);if(c)return i>=a?c:c*("desc"==r[i]?-1:1)}return e.index-n.index},UR}function AK(){if(OR)return TR;OR=1;var t=P_(),e=__(),n=W_(),r=Z_(),i=(kR||(kR=1,FR=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),FR),o=cN(),A=oK(),s=w_(),a=WU();return TR=function(c,l,u){l=l.length?t(l,function(t){return a(t)?function(n){return e(n,1===t.length?t[0]:t)}:t}):[s];var h=-1;l=t(l,o(n));var d=r(c,function(e,n,r){return{criteria:t(l,function(t){return t(e)}),index:++h,value:e}});return i(d,function(t,e){return A(t,e,u)})},TR}function sK(){if(LR)return IR;LR=1;var t=iG(),e=AK(),n=sG(),r=IG(),i=n(function(n,i){if(null==n)return[];var o=i.length;return o>1&&r(n,i[0],i[1])?i=[]:o>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),e(n,t(i,1),[])});return IR=i}function aK(){if(DR)return PR;DR=1;var t=D_(),e=0;return PR=function(n){var r=++e;return t(n)+r},PR}function cK(){if(GR)return _R;GR=1;var t=KU(),e=(HR||(HR=1,RR=function(t,e,n){for(var r=-1,i=t.length,o=e.length,A={};++r<i;){var s=r<o?e[r]:void 0;n(A,t[r],s)}return A}),RR);return _R=function(n,r){return e(n||[],r||[],t)},_R}function lK(){if(jR)return KR;var t;jR=1;try{t={cloneDeep:OG(),constant:p_(),defaults:LG(),each:E_(),filter:Y_(),find:HG(),flatten:_G(),forEach:B_(),forIn:GG(),has:X_(),isUndefined:$_(),last:KG(),map:J_(),mapValues:jG(),max:VG(),merge:qG(),min:ZG(),minBy:JG(),now:tK(),pick:nK(),range:iK(),reduce:tG(),sortBy:sK(),uniqueId:aK(),values:fG(),zipObject:cK()}}catch(t){}return t||(t=window._),KR=t}function uK(){if(YR)return WR;YR=1;var t=lK(),e=TG().Graph,n=function(){if(VR)return zR;function t(){var t={};t._next=t._prev=t,this._sentinel=t}function e(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function n(t,e){if("_next"!==t&&"_prev"!==t)return e}return VR=1,zR=t,t.prototype.dequeue=function(){var t=this._sentinel,n=t._prev;if(n!==t)return e(n),n},t.prototype.enqueue=function(t){var n=this._sentinel;t._prev&&t._next&&e(t),t._next=n._next,n._next._prev=t,n._next=t,t._prev=n},t.prototype.toString=function(){for(var t=[],e=this._sentinel,r=e._prev;r!==e;)t.push(JSON.stringify(r,n)),r=r._prev;return"["+t.join(", ")+"]"},zR}();WR=function(A,s){if(A.nodeCount()<=1)return[];var a=function(r,i){var A=new e,s=0,a=0;t.forEach(r.nodes(),function(t){A.setNode(t,{v:t,in:0,out:0})}),t.forEach(r.edges(),function(t){var e=A.edge(t.v,t.w)||0,n=i(t),r=e+n;A.setEdge(t.v,t.w,r),a=Math.max(a,A.node(t.v).out+=n),s=Math.max(s,A.node(t.w).in+=n)});var c=t.range(a+s+3).map(function(){return new n}),l=s+1;return t.forEach(A.nodes(),function(t){o(c,l,A.node(t))}),{graph:A,buckets:c,zeroIdx:l}}(A,s||r),c=function(t,e,n){var r,o=[],A=e[e.length-1],s=e[0];for(;t.nodeCount();){for(;r=s.dequeue();)i(t,e,n,r);for(;r=A.dequeue();)i(t,e,n,r);if(t.nodeCount())for(var a=e.length-2;a>0;--a)if(r=e[a].dequeue()){o=o.concat(i(t,e,n,r,!0));break}}return o}(a.graph,a.buckets,a.zeroIdx);return t.flatten(t.map(c,function(t){return A.outEdges(t.v,t.w)}),!0)};var r=t.constant(1);function i(e,n,r,i,A){var s=A?[]:void 0;return t.forEach(e.inEdges(i.v),function(t){var i=e.edge(t),a=e.node(t.v);A&&s.push({v:t.v,w:t.w}),a.out-=i,o(n,r,a)}),t.forEach(e.outEdges(i.v),function(t){var i=e.edge(t),A=t.w,s=e.node(A);s.in-=i,o(n,r,s)}),e.removeNode(i.v),s}function o(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}return WR}function hK(){if(qR)return XR;qR=1;var t=lK(),e=uK();return XR={run:function(n){var r="greedy"===n.graph().acyclicer?e(n,function(t){return function(e){return t.edge(e).weight}}(n)):function(e){var n=[],r={},i={};function o(A){t.has(i,A)||(i[A]=!0,r[A]=!0,t.forEach(e.outEdges(A),function(e){t.has(r,e.w)?n.push(e):o(e.w)}),delete r[A])}return t.forEach(e.nodes(),o),n}(n);t.forEach(r,function(e){var r=n.edge(e);n.removeEdge(e),r.forwardName=e.name,r.reversed=!0,n.setEdge(e.w,e.v,r,t.uniqueId("rev"))})},undo:function(e){t.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}},XR}function dK(){if(ZR)return $R;ZR=1;var t=lK(),e=TG().Graph;function n(e,n,r,i){var o;do{o=t.uniqueId(i)}while(e.hasNode(o));return r.dummy=n,e.setNode(o,r),o}function r(e){return t.max(t.map(e.nodes(),function(n){var r=e.node(n).rank;if(!t.isUndefined(r))return r}))}return $R={addDummyNode:n,simplify:function(n){var r=(new e).setGraph(n.graph());return t.forEach(n.nodes(),function(t){r.setNode(t,n.node(t))}),t.forEach(n.edges(),function(t){var e=r.edge(t.v,t.w)||{weight:0,minlen:1},i=n.edge(t);r.setEdge(t.v,t.w,{weight:e.weight+i.weight,minlen:Math.max(e.minlen,i.minlen)})}),r},asNonCompoundGraph:function(n){var r=new e({multigraph:n.isMultigraph()}).setGraph(n.graph());return t.forEach(n.nodes(),function(t){n.children(t).length||r.setNode(t,n.node(t))}),t.forEach(n.edges(),function(t){r.setEdge(t,n.edge(t))}),r},successorWeights:function(e){var n=t.map(e.nodes(),function(n){var r={};return t.forEach(e.outEdges(n),function(t){r[t.w]=(r[t.w]||0)+e.edge(t).weight}),r});return t.zipObject(e.nodes(),n)},predecessorWeights:function(e){var n=t.map(e.nodes(),function(n){var r={};return t.forEach(e.inEdges(n),function(t){r[t.v]=(r[t.v]||0)+e.edge(t).weight}),r});return t.zipObject(e.nodes(),n)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,A=e.x-i,s=e.y-o,a=t.width/2,c=t.height/2;if(!A&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*a>Math.abs(A)*c?(s<0&&(c=-c),n=c*A/s,r=c):(A<0&&(a=-a),n=a,r=a*s/A);return{x:i+n,y:o+r}},buildLayerMatrix:function(e){var n=t.map(t.range(r(e)+1),function(){return[]});return t.forEach(e.nodes(),function(r){var i=e.node(r),o=i.rank;t.isUndefined(o)||(n[o][i.order]=r)}),n},normalizeRanks:function(e){var n=t.min(t.map(e.nodes(),function(t){return e.node(t).rank}));t.forEach(e.nodes(),function(r){var i=e.node(r);t.has(i,"rank")&&(i.rank-=n)})},removeEmptyRanks:function(e){var n=t.min(t.map(e.nodes(),function(t){return e.node(t).rank})),r=[];t.forEach(e.nodes(),function(t){var i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});var i=0,o=e.graph().nodeRankFactor;t.forEach(r,function(n,r){t.isUndefined(n)&&r%o!==0?--i:i&&t.forEach(n,function(t){e.node(t).rank+=i})})},addBorderNode:function(t,e,r,i){var o={width:0,height:0};arguments.length>=4&&(o.rank=r,o.order=i);return n(t,"border",o,e)},maxRank:r,partition:function(e,n){var r={lhs:[],rhs:[]};return t.forEach(e,function(t){n(t)?r.lhs.push(t):r.rhs.push(t)}),r},time:function(e,n){var r=t.now();try{return n()}finally{console.log(e+" time: "+(t.now()-r)+"ms")}},notime:function(t,e){return e()}},$R}function fK(){if(tH)return JR;tH=1;var t=lK(),e=dK();return JR={run:function(n){n.graph().dummyChains=[],t.forEach(n.edges(),function(t){!function(t,n){var r,i,o,A=n.v,s=t.node(A).rank,a=n.w,c=t.node(a).rank,l=n.name,u=t.edge(n),h=u.labelRank;if(c===s+1)return;for(t.removeEdge(n),o=0,++s;s<c;++o,++s)u.points=[],i={width:0,height:0,edgeLabel:u,edgeObj:n,rank:s},r=e.addDummyNode(t,"edge",i,"_d"),s===h&&(i.width=u.width,i.height=u.height,i.dummy="edge-label",i.labelpos=u.labelpos),t.setEdge(A,r,{weight:u.weight},l),0===o&&t.graph().dummyChains.push(r),A=r;t.setEdge(A,a,{weight:u.weight},l)}(n,t)})},undo:function(e){t.forEach(e.graph().dummyChains,function(t){var n,r=e.node(t),i=r.edgeLabel;for(e.setEdge(r.edgeObj,i);r.dummy;)n=e.successors(t)[0],e.removeNode(t),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),t=n,r=e.node(t)})}},JR}function gK(){if(nH)return eH;nH=1;var t=lK();return eH={longestPath:function(e){var n={};t.forEach(e.sources(),function r(i){var o=e.node(i);if(t.has(n,i))return o.rank;n[i]=!0;var A=t.min(t.map(e.outEdges(i),function(t){return r(t.w)-e.edge(t).minlen}));return A!==Number.POSITIVE_INFINITY&&null!=A||(A=0),o.rank=A})},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}},eH}function pK(){if(iH)return rH;iH=1;var t=lK(),e=TG().Graph,n=gK().slack;function r(e,r){return t.forEach(e.nodes(),function i(o){t.forEach(r.nodeEdges(o),function(t){var A=t.v,s=o===A?t.w:A;e.hasNode(s)||n(r,t)||(e.setNode(s,{}),e.setEdge(o,s,{}),i(s))})}),e.nodeCount()}function i(e,r){return t.minBy(r.edges(),function(t){if(e.hasNode(t.v)!==e.hasNode(t.w))return n(r,t)})}function o(e,n,r){t.forEach(e.nodes(),function(t){n.node(t).rank+=r})}return rH=function(t){var A,s,a=new e({directed:!1}),c=t.nodes()[0],l=t.nodeCount();a.setNode(c,{});for(;r(a,t)<l;)A=i(a,t),s=a.hasNode(A.v)?n(t,A):-n(t,A),o(a,t,s);return a},rH}function vK(){if(AH)return oH;AH=1;var t=lK(),e=pK(),n=gK().slack,r=gK().longestPath,i=TG().alg.preorder,o=TG().alg.postorder,A=dK().simplify;function s(t){t=A(t),r(t);var n,i=e(t);for(l(i),a(i,t);n=h(i);)f(i,t,n,d(i,t,n))}function a(e,n){var r=o(e,e.nodes());r=r.slice(0,r.length-1),t.forEach(r,function(t){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=c(t,e,n)}(e,n,t)})}function c(e,n,r){var i=e.node(r).parent,o=!0,A=n.edge(r,i),s=0;return A||(o=!1,A=n.edge(i,r)),s=A.weight,t.forEach(n.nodeEdges(r),function(t){var A=t.v===r,a=A?t.w:t.v;if(a!==i){var c=A===o,l=n.edge(t).weight;if(s+=c?l:-l,function(t,e,n){return t.hasEdge(e,n)}(e,r,a)){var u=e.edge(r,a).cutvalue;s+=c?-u:u}}}),s}function l(t,e){arguments.length<2&&(e=t.nodes()[0]),u(t,{},1,e)}function u(e,n,r,i,o){var A=r,s=e.node(i);return n[i]=!0,t.forEach(e.neighbors(i),function(o){t.has(n,o)||(r=u(e,n,r,o,i))}),s.low=A,s.lim=r++,o?s.parent=o:delete s.parent,r}function h(e){return t.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function d(e,r,i){var o=i.v,A=i.w;r.hasEdge(o,A)||(o=i.w,A=i.v);var s=e.node(o),a=e.node(A),c=s,l=!1;s.lim>a.lim&&(c=a,l=!0);var u=t.filter(r.edges(),function(t){return l===g(e,e.node(t.v),c)&&l!==g(e,e.node(t.w),c)});return t.minBy(u,function(t){return n(r,t)})}function f(e,n,r,o){var A=r.v,s=r.w;e.removeEdge(A,s),e.setEdge(o.v,o.w,{}),l(e),a(e,n),function(e,n){var r=t.find(e.nodes(),function(t){return!n.node(t).parent}),o=i(e,r);o=o.slice(1),t.forEach(o,function(t){var r=e.node(t).parent,i=n.edge(t,r),o=!1;i||(i=n.edge(r,t),o=!0),n.node(t).rank=n.node(r).rank+(o?i.minlen:-i.minlen)})}(e,n)}function g(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}return oH=s,s.initLowLimValues=l,s.initCutValues=a,s.calcCutValue=c,s.leaveEdge=h,s.enterEdge=d,s.exchangeEdges=f,oH}function mK(){if(aH)return sH;aH=1;var t=gK().longestPath,e=pK(),n=vK();sH=function(n){switch(n.graph().ranker){case"network-simplex":default:i(n);break;case"tight-tree":!function(n){t(n),e(n)}(n);break;case"longest-path":r(n)}};var r=t;function i(t){n(t)}return sH}function yK(){if(lH)return cH;lH=1;var t=lK();return cH=function(e){var n=function(e){var n={},r=0;function i(o){var A=r;t.forEach(e.children(o),i),n[o]={low:A,lim:r++}}return t.forEach(e.children(),i),n}(e);t.forEach(e.graph().dummyChains,function(t){for(var r=e.node(t),i=r.edgeObj,o=function(t,e,n,r){var i,o,A=[],s=[],a=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),A.push(i)}while(i&&(e[i].low>a||c>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:A.concat(s.reverse()),lca:o}}(e,n,i.v,i.w),A=o.path,s=o.lca,a=0,c=A[a],l=!0;t!==i.w;){if(r=e.node(t),l){for(;(c=A[a])!==s&&e.node(c).maxRank<r.rank;)a++;c===s&&(l=!1)}if(!l){for(;a<A.length-1&&e.node(c=A[a+1]).minRank<=r.rank;)a++;c=A[a]}e.setParent(t,c),t=e.successors(t)[0]}})},cH}function wK(){if(hH)return uH;hH=1;var t=lK(),e=dK();function n(r,i,o,A,s,a,c){var l=r.children(c);if(l.length){var u=e.addBorderNode(r,"_bt"),h=e.addBorderNode(r,"_bb"),d=r.node(c);r.setParent(u,c),d.borderTop=u,r.setParent(h,c),d.borderBottom=h,t.forEach(l,function(t){n(r,i,o,A,s,a,t);var e=r.node(t),l=e.borderTop?e.borderTop:t,d=e.borderBottom?e.borderBottom:t,f=e.borderTop?A:2*A,g=l!==d?1:s-a[c]+1;r.setEdge(u,l,{weight:f,minlen:g,nestingEdge:!0}),r.setEdge(d,h,{weight:f,minlen:g,nestingEdge:!0})}),r.parent(c)||r.setEdge(i,u,{weight:0,minlen:s+a[c]})}else c!==i&&r.setEdge(i,c,{weight:0,minlen:o})}return uH={run:function(r){var i=e.addDummyNode(r,"root",{},"_root"),o=function(e){var n={};function r(i,o){var A=e.children(i);A&&A.length&&t.forEach(A,function(t){r(t,o+1)}),n[i]=o}return t.forEach(e.children(),function(t){r(t,1)}),n}(r),A=t.max(t.values(o))-1,s=2*A+1;r.graph().nestingRoot=i,t.forEach(r.edges(),function(t){r.edge(t).minlen*=s});var a=function(e){return t.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}(r)+1;t.forEach(r.children(),function(t){n(r,i,s,a,A,o,t)}),r.graph().nodeRankFactor=s},cleanup:function(e){var n=e.graph();e.removeNode(n.nestingRoot),delete n.nestingRoot,t.forEach(e.edges(),function(t){e.edge(t).nestingEdge&&e.removeEdge(t)})}},uH}function bK(){if(pH)return gH;pH=1;var t=lK();function e(e){t.forEach(e.nodes(),function(t){n(e.node(t))}),t.forEach(e.edges(),function(t){n(e.edge(t))})}function n(t){var e=t.width;t.width=t.height,t.height=e}function r(t){t.y=-t.y}function i(t){var e=t.x;t.x=t.y,t.y=e}return gH={adjust:function(t){var n=t.graph().rankdir.toLowerCase();"lr"!==n&&"rl"!==n||e(t)},undo:function(n){var o=n.graph().rankdir.toLowerCase();"bt"!==o&&"rl"!==o||function(e){t.forEach(e.nodes(),function(t){r(e.node(t))}),t.forEach(e.edges(),function(n){var i=e.edge(n);t.forEach(i.points,r),t.has(i,"y")&&r(i)})}(n);"lr"!==o&&"rl"!==o||(!function(e){t.forEach(e.nodes(),function(t){i(e.node(t))}),t.forEach(e.edges(),function(n){var r=e.edge(n);t.forEach(r.points,i),t.has(r,"x")&&i(r)})}(n),e(n))}},gH}function BK(){if(xH)return EH;xH=1;var t=lK();return EH=function(e,n){var r={};return t.forEach(e,function(e,n){var i=r[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:n};t.isUndefined(e.barycenter)||(i.barycenter=e.barycenter,i.weight=e.weight)}),t.forEach(n.edges(),function(e){var n=r[e.v],i=r[e.w];t.isUndefined(n)||t.isUndefined(i)||(i.indegree++,n.out.push(r[e.w]))}),function(e){var n=[];function r(e){return function(n){n.merged||(t.isUndefined(n.barycenter)||t.isUndefined(e.barycenter)||n.barycenter>=e.barycenter)&&function(t,e){var n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(e,n)}}function i(t){return function(n){n.in.push(t),0===--n.indegree&&e.push(n)}}for(;e.length;){var o=e.pop();n.push(o),t.forEach(o.in.reverse(),r(o)),t.forEach(o.out,i(o))}return t.map(t.filter(n,function(t){return!t.merged}),function(e){return t.pick(e,["vs","i","barycenter","weight"])})}(t.filter(r,function(t){return!t.indegree}))},EH}function EK(){if(kH)return FH;kH=1;var t=lK(),e=function(){if(BH)return bH;BH=1;var t=lK();return bH=function(e,n){return t.map(n,function(n){var r=e.inEdges(n);if(r.length){var i=t.reduce(r,function(t,n){var r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}return{v:n}})},bH}(),n=BK(),r=function(){if(MH)return CH;MH=1;var t=lK(),e=dK();function n(e,n,r){for(var i;n.length&&(i=t.last(n)).i<=r;)n.pop(),e.push(i.vs),r++;return r}return CH=function(r,i){var o,A=e.partition(r,function(e){return t.has(e,"barycenter")}),s=A.lhs,a=t.sortBy(A.rhs,function(t){return-t.i}),c=[],l=0,u=0,h=0;s.sort((o=!!i,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:o?e.i-t.i:t.i-e.i})),h=n(c,a,h),t.forEach(s,function(t){h+=t.vs.length,c.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,h=n(c,a,h)});var d={vs:t.flatten(c,!0)};return u&&(d.barycenter=l/u,d.weight=u),d}}();return FH=function i(o,A,s,a){var c=o.children(A),l=o.node(A),u=l?l.borderLeft:void 0,h=l?l.borderRight:void 0,d={};u&&(c=t.filter(c,function(t){return t!==u&&t!==h}));var f=e(o,c);t.forEach(f,function(e){if(o.children(e.v).length){var n=i(o,e.v,s,a);d[e.v]=n,t.has(n,"barycenter")&&(r=e,A=n,t.isUndefined(r.barycenter)?(r.barycenter=A.barycenter,r.weight=A.weight):(r.barycenter=(r.barycenter*r.weight+A.barycenter*A.weight)/(r.weight+A.weight),r.weight+=A.weight))}var r,A});var g=n(f,s);!function(e,n){t.forEach(e,function(e){e.vs=t.flatten(e.vs.map(function(t){return n[t]?n[t].vs:t}),!0)})}(g,d);var p=r(g,a);if(u&&(p.vs=t.flatten([u,p.vs,h],!0),o.predecessors(u).length)){var v=o.node(o.predecessors(u)[0]),m=o.node(o.predecessors(h)[0]);t.has(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+v.order+m.order)/(p.weight+2),p.weight+=2}return p},FH}function xK(){if(QH)return SH;QH=1;var t=lK(),e=TG().Graph;return SH=function(n,r,i){var o=function(e){var n;for(;e.hasNode(n=t.uniqueId("_root")););return n}(n),A=new e({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(t){return n.node(t)});return t.forEach(n.nodes(),function(e){var s=n.node(e),a=n.parent(e);(s.rank===r||s.minRank<=r&&r<=s.maxRank)&&(A.setNode(e),A.setParent(e,a||o),t.forEach(n[i](e),function(r){var i=r.v===e?r.w:r.v,o=A.edge(i,e),s=t.isUndefined(o)?0:o.weight;A.setEdge(i,e,{weight:n.edge(r).weight+s})}),t.has(s,"minRank")&&A.setNode(e,{borderLeft:s.borderLeft[r],borderRight:s.borderRight[r]}))}),A},SH}function CK(){if(OH)return TH;OH=1;var t=lK(),e=function(){if(mH)return vH;mH=1;var t=lK();return vH=function(e){var n={},r=t.filter(e.nodes(),function(t){return!e.children(t).length}),i=t.max(t.map(r,function(t){return e.node(t).rank})),o=t.map(t.range(i+1),function(){return[]});function A(r){if(!t.has(n,r)){n[r]=!0;var i=e.node(r);o[i.rank].push(r),t.forEach(e.successors(r),A)}}var s=t.sortBy(r,function(t){return e.node(t).rank});return t.forEach(s,A),o},vH}(),n=function(){if(wH)return yH;wH=1;var t=lK();function e(e,n,r){for(var i=t.zipObject(r,t.map(r,function(t,e){return e})),o=t.flatten(t.map(n,function(n){return t.sortBy(t.map(e.outEdges(n),function(t){return{pos:i[t.w],weight:e.edge(t).weight}}),"pos")}),!0),A=1;A<r.length;)A<<=1;var s=2*A-1;A-=1;var a=t.map(new Array(s),function(){return 0}),c=0;return t.forEach(o.forEach(function(t){var e=t.pos+A;a[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=a[e+1]),a[e=e-1>>1]+=t.weight;c+=t.weight*n})),c}return yH=function(t,n){for(var r=0,i=1;i<n.length;++i)r+=e(t,n[i-1],n[i]);return r},yH}(),r=EK(),i=xK(),o=function(){if(NH)return UH;NH=1;var t=lK();return UH=function(e,n,r){var i,o={};t.forEach(r,function(t){for(var r,A,s=e.parent(t);s;){if((r=e.parent(s))?(A=o[r],o[r]=s):(A=i,i=s),A&&A!==s)return void n.setEdge(A,s);s=r}})},UH}(),A=TG().Graph,s=dK();function a(e,n,r){return t.map(n,function(t){return i(e,t,r)})}function c(e,n){var i=new A;t.forEach(e,function(e){var A=e.graph().root,s=r(e,A,i,n);t.forEach(s.vs,function(t,n){e.node(t).order=n}),o(e,i,s.vs)})}function l(e,n){t.forEach(n,function(n){t.forEach(n,function(t,n){e.node(t).order=n})})}return TH=function(r){var i=s.maxRank(r),o=a(r,t.range(1,i+1),"inEdges"),A=a(r,t.range(i-1,-1,-1),"outEdges"),u=e(r);l(r,u);for(var h,d=Number.POSITIVE_INFINITY,f=0,g=0;g<4;++f,++g){c(f%2?o:A,f%4>=2),u=s.buildLayerMatrix(r);var p=n(r,u);p<d&&(g=0,h=t.cloneDeep(u),d=p)}l(r,h)},TH}function MK(){if(LH)return IH;LH=1;var t=lK(),e=TG().Graph,n=dK();function r(e,n){var r={};return t.reduce(n,function(n,i){var A=0,s=0,a=n.length,c=t.last(i);return t.forEach(i,function(n,l){var u=function(e,n){if(e.node(n).dummy)return t.find(e.predecessors(n),function(t){return e.node(t).dummy})}(e,n),h=u?e.node(u).order:a;(u||n===c)&&(t.forEach(i.slice(s,l+1),function(n){t.forEach(e.predecessors(n),function(t){var i=e.node(t),s=i.order;!(s<A||h<s)||i.dummy&&e.node(n).dummy||o(r,t,n)})}),s=l+1,A=h)}),i}),r}function i(e,n){var r={};function i(n,i,A,s,a){var c;t.forEach(t.range(i,A),function(i){c=n[i],e.node(c).dummy&&t.forEach(e.predecessors(c),function(t){var n=e.node(t);n.dummy&&(n.order<s||n.order>a)&&o(r,t,c)})})}return t.reduce(n,function(n,r){var o,A=-1,s=0;return t.forEach(r,function(t,a){if("border"===e.node(t).dummy){var c=e.predecessors(t);c.length&&(o=e.node(c[0]).order,i(r,s,a,A,o),s=a,A=o)}i(r,s,r.length,o,n.length)}),r}),r}function o(t,e,n){if(e>n){var r=e;e=n,n=r}var i=t[e];i||(t[e]=i={}),i[n]=!0}function A(e,n,r){if(n>r){var i=n;n=r,r=i}return t.has(e[n],r)}function s(e,n,r,i){var o={},s={},a={};return t.forEach(n,function(e){t.forEach(e,function(t,e){o[t]=t,s[t]=t,a[t]=e})}),t.forEach(n,function(e){var n=-1;t.forEach(e,function(e){var c=i(e);if(c.length){c=t.sortBy(c,function(t){return a[t]});for(var l=(c.length-1)/2,u=Math.floor(l),h=Math.ceil(l);u<=h;++u){var d=c[u];s[e]===e&&n<a[d]&&!A(r,e,d)&&(s[d]=e,s[e]=o[e]=o[d],n=a[d])}}})}),{root:o,align:s}}function a(n,r,i,o,A){var s={},a=function(n,r,i,o){var A=new e,s=n.graph(),a=function(e,n,r){return function(i,o,A){var s,a=i.node(o),c=i.node(A),l=0;if(l+=a.width/2,t.has(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":s=-a.width/2;break;case"r":s=a.width/2}if(s&&(l+=r?s:-s),s=0,l+=(a.dummy?n:e)/2,l+=(c.dummy?n:e)/2,l+=c.width/2,t.has(c,"labelpos"))switch(c.labelpos.toLowerCase()){case"l":s=c.width/2;break;case"r":s=-c.width/2}return s&&(l+=r?s:-s),s=0,l}}(s.nodesep,s.edgesep,o);return t.forEach(r,function(e){var r;t.forEach(e,function(t){var e=i[t];if(A.setNode(e),r){var o=i[r],s=A.edge(o,e);A.setEdge(o,e,Math.max(a(n,t,r),s||0))}r=t})}),A}(n,r,i,A),c=A?"borderLeft":"borderRight";function l(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}return l(function(t){s[t]=a.inEdges(t).reduce(function(t,e){return Math.max(t,s[e.v]+a.edge(e))},0)},a.predecessors.bind(a)),l(function(t){var e=a.outEdges(t).reduce(function(t,e){return Math.min(t,s[e.w]-a.edge(e))},Number.POSITIVE_INFINITY),r=n.node(t);e!==Number.POSITIVE_INFINITY&&r.borderType!==c&&(s[t]=Math.max(s[t],e))},a.successors.bind(a)),t.forEach(o,function(t){s[t]=s[i[t]]}),s}function c(e,n){return t.minBy(t.values(n),function(n){var r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return t.forIn(n,function(t,n){var o=function(t,e){return t.node(e).width}(e,n)/2;r=Math.max(t+o,r),i=Math.min(t-o,i)}),r-i})}function l(e,n){var r=t.values(n),i=t.min(r),o=t.max(r);t.forEach(["u","d"],function(r){t.forEach(["l","r"],function(A){var s,a=r+A,c=e[a];if(c!==n){var l=t.values(c);(s="l"===A?i-t.min(l):o-t.max(l))&&(e[a]=t.mapValues(c,function(t){return t+s}))}})})}function u(e,n){return t.mapValues(e.ul,function(r,i){if(n)return e[n.toLowerCase()][i];var o=t.sortBy(t.map(e,i));return(o[1]+o[2])/2})}return IH={positionX:function(e){var o,A=n.buildLayerMatrix(e),h=t.merge(r(e,A),i(e,A)),d={};t.forEach(["u","d"],function(n){o="u"===n?A:t.values(A).reverse(),t.forEach(["l","r"],function(r){"r"===r&&(o=t.map(o,function(e){return t.values(e).reverse()}));var i=("u"===n?e.predecessors:e.successors).bind(e),A=s(e,o,h,i),c=a(e,o,A.root,A.align,"r"===r);"r"===r&&(c=t.mapValues(c,function(t){return-t})),d[n+r]=c})});var f=c(e,d);return l(d,f),u(d,e.graph().align)},findType1Conflicts:r,findType2Conflicts:i,addConflict:o,hasConflict:A,verticalAlignment:s,horizontalCompaction:a,alignCoordinates:l,findSmallestWidthAlignment:c,balance:u},IH}function FK(){if(DH)return PH;DH=1;var t=lK(),e=dK(),n=MK().positionX;return PH=function(r){r=e.asNonCompoundGraph(r),function(n){var r=e.buildLayerMatrix(n),i=n.graph().ranksep,o=0;t.forEach(r,function(e){var r=t.max(t.map(e,function(t){return n.node(t).height}));t.forEach(e,function(t){n.node(t).y=o+r/2}),o+=r+i})}(r),t.forEach(n(r),function(t,e){r.node(e).x=t})},PH}function kK(){if(HH)return RH;HH=1;var t=lK(),e=hK(),n=fK(),r=mK(),i=dK().normalizeRanks,o=yK(),A=dK().removeEmptyRanks,s=wK(),a=function(){if(fH)return dH;fH=1;var t=lK(),e=dK();function n(t,n,r,i,o,A){var s={width:0,height:0,rank:A,borderType:n},a=o[n][A-1],c=e.addDummyNode(t,"border",s,r);o[n][A]=c,t.setParent(c,i),a&&t.setEdge(a,c,{weight:1})}return dH=function(e){t.forEach(e.children(),function r(i){var o=e.children(i),A=e.node(i);if(o.length&&t.forEach(o,r),t.has(A,"minRank")){A.borderLeft=[],A.borderRight=[];for(var s=A.minRank,a=A.maxRank+1;s<a;++s)n(e,"borderLeft","_bl",i,A,s),n(e,"borderRight","_br",i,A,s)}})},dH}(),c=bK(),l=CK(),u=FK(),h=dK(),d=TG().Graph;RH=function(x,C){var M=C&&C.debugTiming?h.time:h.notime;M("layout",function(){var C=M(" buildLayoutGraph",function(){return function(e){var n=new d({multigraph:!0,compound:!0}),r=E(e.graph());return n.setGraph(t.merge({},g,B(r,f),t.pick(r,p))),t.forEach(e.nodes(),function(r){var i=E(e.node(r));n.setNode(r,t.defaults(B(i,v),m)),n.setParent(r,e.parent(r))}),t.forEach(e.edges(),function(r){var i=E(e.edge(r));n.setEdge(r,t.merge({},w,B(i,y),t.pick(i,b)))}),n}(x)});M(" runLayout",function(){!function(d,f){f(" makeSpaceForEdgeLabels",function(){!function(e){var n=e.graph();n.ranksep/=2,t.forEach(e.edges(),function(t){var r=e.edge(t);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===n.rankdir||"BT"===n.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)})}(d)}),f(" removeSelfEdges",function(){!function(e){t.forEach(e.edges(),function(t){if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}(d)}),f(" acyclic",function(){e.run(d)}),f(" nestingGraph.run",function(){s.run(d)}),f(" rank",function(){r(h.asNonCompoundGraph(d))}),f(" injectEdgeLabelProxies",function(){!function(e){t.forEach(e.edges(),function(t){var n=e.edge(t);if(n.width&&n.height){var r=e.node(t.v),i={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};h.addDummyNode(e,"edge-proxy",i,"_ep")}})}(d)}),f(" removeEmptyRanks",function(){A(d)}),f(" nestingGraph.cleanup",function(){s.cleanup(d)}),f(" normalizeRanks",function(){i(d)}),f(" assignRankMinMax",function(){!function(e){var n=0;t.forEach(e.nodes(),function(r){var i=e.node(r);i.borderTop&&(i.minRank=e.node(i.borderTop).rank,i.maxRank=e.node(i.borderBottom).rank,n=t.max(n,i.maxRank))}),e.graph().maxRank=n}(d)}),f(" removeEdgeLabelProxies",function(){!function(e){t.forEach(e.nodes(),function(t){var n=e.node(t);"edge-proxy"===n.dummy&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}(d)}),f(" normalize.run",function(){n.run(d)}),f(" parentDummyChains",function(){o(d)}),f(" addBorderSegments",function(){a(d)}),f(" order",function(){l(d)}),f(" insertSelfEdges",function(){!function(e){var n=h.buildLayerMatrix(e);t.forEach(n,function(n){var r=0;t.forEach(n,function(n,i){var o=e.node(n);o.order=i+r,t.forEach(o.selfEdges,function(t){h.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:o.rank,order:i+ ++r,e:t.e,label:t.label},"_se")}),delete o.selfEdges})})}(d)}),f(" adjustCoordinateSystem",function(){c.adjust(d)}),f(" position",function(){u(d)}),f(" positionSelfEdges",function(){!function(e){t.forEach(e.nodes(),function(t){var n=e.node(t);if("selfedge"===n.dummy){var r=e.node(n.e.v),i=r.x+r.width/2,o=r.y,A=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*A/3,y:o-s},{x:i+5*A/6,y:o-s},{x:i+A,y:o},{x:i+5*A/6,y:o+s},{x:i+2*A/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}})}(d)}),f(" removeBorderNodes",function(){!function(e){t.forEach(e.nodes(),function(n){if(e.children(n).length){var r=e.node(n),i=e.node(r.borderTop),o=e.node(r.borderBottom),A=e.node(t.last(r.borderLeft)),s=e.node(t.last(r.borderRight));r.width=Math.abs(s.x-A.x),r.height=Math.abs(o.y-i.y),r.x=A.x+r.width/2,r.y=i.y+r.height/2}}),t.forEach(e.nodes(),function(t){"border"===e.node(t).dummy&&e.removeNode(t)})}(d)}),f(" normalize.undo",function(){n.undo(d)}),f(" fixupEdgeLabelCoords",function(){!function(e){t.forEach(e.edges(),function(n){var r=e.edge(n);if(t.has(r,"x"))switch("l"!==r.labelpos&&"r"!==r.labelpos||(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}})}(d)}),f(" undoCoordinateSystem",function(){c.undo(d)}),f(" translateGraph",function(){!function(e){var n=Number.POSITIVE_INFINITY,r=0,i=Number.POSITIVE_INFINITY,o=0,A=e.graph(),s=A.marginx||0,a=A.marginy||0;function c(t){var e=t.x,A=t.y,s=t.width,a=t.height;n=Math.min(n,e-s/2),r=Math.max(r,e+s/2),i=Math.min(i,A-a/2),o=Math.max(o,A+a/2)}t.forEach(e.nodes(),function(t){c(e.node(t))}),t.forEach(e.edges(),function(n){var r=e.edge(n);t.has(r,"x")&&c(r)}),n-=s,i-=a,t.forEach(e.nodes(),function(t){var r=e.node(t);r.x-=n,r.y-=i}),t.forEach(e.edges(),function(r){var o=e.edge(r);t.forEach(o.points,function(t){t.x-=n,t.y-=i}),t.has(o,"x")&&(o.x-=n),t.has(o,"y")&&(o.y-=i)}),A.width=r-n+s,A.height=o-i+a}(d)}),f(" assignNodeIntersects",function(){!function(e){t.forEach(e.edges(),function(t){var n,r,i=e.edge(t),o=e.node(t.v),A=e.node(t.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=A,r=o),i.points.unshift(h.intersectRect(o,n)),i.points.push(h.intersectRect(A,r))})}(d)}),f(" reversePoints",function(){!function(e){t.forEach(e.edges(),function(t){var n=e.edge(t);n.reversed&&n.points.reverse()})}(d)}),f(" acyclic.undo",function(){e.undo(d)})}(C,M)}),M(" updateInputGraph",function(){!function(e,n){t.forEach(e.nodes(),function(t){var r=e.node(t),i=n.node(t);r&&(r.x=i.x,r.y=i.y,n.children(t).length&&(r.width=i.width,r.height=i.height))}),t.forEach(e.edges(),function(r){var i=e.edge(r),o=n.edge(r);i.points=o.points,t.has(o,"x")&&(i.x=o.x,i.y=o.y)}),e.graph().width=n.graph().width,e.graph().height=n.graph().height}(x,C)})})};var f=["nodesep","edgesep","ranksep","marginx","marginy"],g={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},p=["acyclicer","ranker","rankdir","align"],v=["width","height"],m={width:0,height:0},y=["minlen","weight","width","height","labeloffset"],w={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},b=["labelpos"];function B(e,n){return t.mapValues(t.pick(e,n),Number)}function E(e){var n={};return t.forEach(e,function(t,e){n[e.toLowerCase()]=t}),n}return RH}function SK(){if(GH)return _H;GH=1;var t=lK(),e=dK(),n=TG().Graph;return _H={debugOrdering:function(r){var i=e.buildLayerMatrix(r),o=new n({compound:!0,multigraph:!0}).setGraph({});return t.forEach(r.nodes(),function(t){o.setNode(t,{label:t}),o.setParent(t,"layer"+r.node(t).rank)}),t.forEach(r.edges(),function(t){o.setEdge(t.v,t.w,{},t.name)}),t.forEach(i,function(e,n){var r="layer"+n;o.setNode(r,{rank:"same"}),t.reduce(e,function(t,e){return o.setEdge(t,e,{style:"invis"}),e})}),o}},_H}var QK=VH?zH:(VH=1,zH={graphlib:TG(),layout:kK(),debug:SK(),util:{time:dK().time,notime:dK().notime},version:jH?KH:(jH=1,KH="0.8.5")}),UK=wU(QK);var NK=Object.prototype.hasOwnProperty,TK=function(t,e){if(null===t||!kk(t))return{};var n={};return function(t,e){var n,r;if(t)if(dM(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var A in t)if(t.hasOwnProperty(A)&&!1===e(t[A],A))break}(e,function(e){NK.call(t,e)&&(n[e]=t[e])}),n};class OK extends bC{constructor(){super(...arguments),this.id="dagre",this.isCompoundGraph=null,this.config={graphAttributes:["rankdir","align","nodesep","edgesep","ranksep","marginx","marginy","acyclicer","ranker"],nodeAttributes:["width","height"],edgeAttributes:["minlen","weight","width","height","labelpos","labeloffset"]}}getDefaultOptions(){return{directed:!0,multigraph:!0,rankdir:"TB",align:void 0,nodesep:50,edgesep:10,ranksep:50,marginx:0,marginy:0,acyclicer:void 0,ranker:"network-simplex",nodeSize:[0,0],edgeMinLen:1,edgeWeight:1,edgeLabelSize:[0,0],edgeLabelPos:"r",edgeLabelOffset:10}}layout(){return px(this,0,void 0,function*(){const t=new QK.graphlib.Graph({directed:!!this.options.directed,multigraph:!!this.options.multigraph,compound:this.isCompound()});t.setGraph(TK(this.options,this.config.graphAttributes)),t.setDefaultEdgeLabel(()=>({}));const e=Vx(this.options.nodeSize,0);this.model.forEachNode(n=>{const r=n._original,[i,o]=Hx(e(r)),A={width:i,height:o};if(t.setNode(String(n.id),A),this.isCompound()){if(_x(n.parentId))return;t.setParent(String(n.id),String(n.parentId))}});const{edgeLabelSize:n,edgeLabelOffset:r,edgeLabelPos:i,edgeMinLen:o,edgeWeight:A}=this.options,s=Vx(n,0,"edge"),a=zx(r,10,"edge"),c="string"==typeof i?()=>i:jx(i,["edge"]),l=zx(o,1,"edge"),u=zx(A,1,"edge");this.model.forEachEdge(e=>{const n=e._original,[r,i]=Hx(s(n)),o={width:r,height:i,labelpos:c(n),labeloffset:a(n),minlen:l(n),weight:u(n)};t.setEdge(String(e.source),String(e.target),o,String(e.id))}),UK.layout(t),this.model.forEachNode(e=>{const n=t.node(String(e.id));n&&(e.x=n.x,e.y=n.y,e.size=[n.width,n.height])}),this.model.forEachEdge(e=>{const n=t.edge(String(e.source),String(e.target),String(e.id));if(!n)return;const{width:r,height:i,weight:o,minlen:A,labelpos:s,labeloffset:a,points:c}=n;e.labelSize=[r,i],e.weight=o,e.minLen=A,e.labelPos=s,e.labelOffset=a,e.points=c.map(Yx)})})}isCompound(){return null!==this.isCompoundGraph?this.isCompoundGraph:(t=this.options.compound,Fk(t,"Boolean")?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(t=>!_x(t.parentId)),this.isCompoundGraph));var t}}const IK=1e-6;function LK(t){var e;let n=0;if(t.length)for(let e=0;e<t.length;e++){const r=t[e];r&&r.r>n&&(n=r.r)}else if(t.data){n=t.data.r||0;let r=t.next;for(;r;)n=Math.max(n,(null===(e=r.data)||void 0===e?void 0:e.r)||0),r=r.next}t.r=n}function PK(t=1,e=.005,n=2){function r(r,i){!function(t,e,n,r,i=2){const o=e/n,A=t.nodes(),s=A.map((t,e)=>{const{nodeStrength:n,x:r,y:i,z:A,size:s,mass:a}=t;return{x:r,y:i,z:A,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n,mass:a||1}}),a=(2===i?dk(s,t=>t.x,t=>t.y):Jk(s,t=>t.x,t=>t.y,t=>t.z)).visitAfter(DK),c=new Map;s.forEach(t=>{c.set(t.id,t),function(t,e,n){e.visit((e,r,i,o,A,s,a)=>RK(e,r,i,o,A,s,a,t,n))}(t,a,i)}),s.map(t=>{const e=t.id;r[e]={x:t.vx/t.mass,y:t.vy/t.mass,z:t.vz/t.mass}})}(r,t,e*e,i,n)}return r.factor=function(e){return arguments.length?(t=e,r):t},r.coulombDisScale=function(t){return arguments.length?(e=t,r):e},r.dimensions=function(t){return arguments.length?(n=t,r):n},r}function DK(t){let e=0,n=0,r=0,i=0,o=0;const A=t.length;if(A){for(let s=0;s<A;s++){const A=t[s];A&&A.weight&&(e+=A.weight,n+=A.x*A.weight,r+=A.y*A.weight,i+=A.z*A.weight,o+=A.size*A.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const RK=(t,e,n,r,i,o,A,s,a)=>{var c;if((null===(c=t.data)||void 0===c?void 0:c.id)===s.id)return;const l=2===a?r:3===a?o:n,u=s.x-t.x||.1,h=s.y-t.y||.1,d=s.z-t.z||.1,f=[u,h,d],g=l-e;let p=0;for(let t=0;t<a;t++)p+=f[t]*f[t];const v=Math.sqrt(p)*p;if(g*g*.81<p){const e=t.weight/v;return s.vx+=u*e,s.vy+=h*e,s.vz+=d*e,!0}if(t.length)return!1;if(t.data!==s){const e=t.data.weight/v;s.vx+=u*e,s.vy+=h*e,s.vz+=d*e}};var HK=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],A=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var A=r[o],s=A.callback;A.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};A(i),A(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();class _K extends HK{constructor(){super(...arguments),this.iteration=0,this.judgingDistance=1/0,this.running=!1,this.tickCallback=null,this.endCallback=null,this.timer=0}initialize(t){this.options=t,this.iteration=0,this.judgingDistance=1/0}on(t,e){return"tick"===t&&(this.tickCallback=e),"end"===t&&(this.endCallback=e),this}tick(t=1){var e;for(let n=0;n<t;n++){const t=this.runOneStep();this.judgingDistance=t,this.iteration++,null===(e=this.tickCallback)||void 0===e||e.call(this)}return this}restart(){if(this.running)return this;const{maxIteration:t=500,minMovement:e=0,animate:n=!0}=this.options;if(!n||"undefined"==typeof window){for(;this.iteration<t&&(this.judgingDistance>e||this.iteration<1);)this.tick(1);return Promise.resolve().then(()=>{var t;null===(t=this.endCallback)||void 0===t||t.call(this)}),this}return this.running=!0,this.timer=window.setInterval(()=>{var n;this.tick(1),(this.iteration>=t||this.judgingDistance<e)&&(this.stop(),null===(n=this.endCallback)||void 0===n||n.call(this))},0),this}stop(){return this.running=!1,this.timer&&(clearInterval(this.timer),this.timer=0),this}}class GK extends _K{constructor(){super(...arguments),this.forces=new Map,this.velMap={}}data(t){return this.model=t,t.forEachNode(t=>{this.velMap[t.id]={x:0,y:0,z:0}}),this}force(t,e){return 1===arguments.length?this.forces.get(t)||null:(null===e?this.forces.delete(t):e&&this.forces.set(t,e),e||null)}runOneStep(){const t={},e=this.model.nodes();if(!e.length)return 0;e.forEach(e=>{t[e.id]={x:0,y:0,z:0}}),this.forces.forEach(e=>{e(this.model,t)}),this.updateVelocity(t);const n=this.updatePosition();return this.monitor(t,e),n}setFixedPosition(t,e){const n=this.model.node(t);if(!n)return;const r=["fx","fy","fz"];if(null===e)return void r.forEach(t=>delete n[t]);e.forEach((t,e)=>{e<r.length&&("number"==typeof t||null===t)&&(n[r[e]]=t)});const i=this.velMap[t];i&&(i.x=0,i.y=0,i.z=0)}updateVelocity(t){const{damping:e=.9,maxSpeed:n=100,interval:r=.02,dimensions:i=2}=this.options;this.model.nodes().forEach(o=>{const A=o.id;let s=(this.velMap[A].x+t[A].x*r)*e,a=(this.velMap[A].y+t[A].y*r)*e,c=3===i?(this.velMap[A].z+t[A].z*r)*e:0;const l=Math.sqrt(s*s+a*a+c*c);if(l>n){const t=n/l;s*=t,a*=t,c*=t}this.velMap[A]={x:s,y:a,z:c}})}updatePosition(){const{distanceThresholdMode:t="mean",interval:e=.02,dimensions:n=2}=this.options,r=this.model.nodes();let i=0,o="max"===t?-1/0:"min"===t?1/0:0;return r.forEach(r=>{const A=r.id;if(Rx(r.fx)&&Rx(r.fy))return r.x=r.fx,r.y=r.fy,void(3===n&&Rx(r.fz)&&(r.z=r.fz));const s=this.velMap[A].x*e,a=this.velMap[A].y*e,c=3===n?this.velMap[A].z*e:0;r.x+=s,r.y+=a,3===n&&(r.z=(r.z||0)+c);const l=Math.sqrt(s*s+a*a+c*c);"max"===t?o=Math.max(o,l):"min"===t?o=Math.min(o,l):i+=l}),"mean"===t?i/r.length:o}monitor(t,e){const{monitor:n,dimensions:r=2}=this.options;if(!n)return;let i=0;e.forEach(e=>{const n=t[e.id],o=n.x*n.x+n.y*n.y+(3===r?n.z*n.z:0);i+=(e.mass||1)*o*.5}),n({energy:i,nodes:e,edges:this.model.edges(),iterations:this.iteration})}}var KK={}.toString,jK=Object.prototype,zK=Object.prototype.hasOwnProperty;function VK(t){if(_x(t))return!0;if(function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)}(t))return!t.length;var e=function(t){return KK.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||jK)}(t))return!Object.keys(t).length;for(var n in t)if(zK.call(t,n))return!1;return!0}const WK={nodeSize:30,dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,collideStrength:1,preventOverlap:!0,distanceThresholdMode:"mean"};class YK extends BC{constructor(){super(...arguments),this.id="force",this.simulation=null}getDefaultOptions(){return WK}layout(){var t;return px(this,0,void 0,function*(){const e=this.parseOptions(this.options),{width:n,height:r,dimensions:i}=e;if(this.initializePhysicsData(this.model,e),Zx(this.model,n,r,i),!(null===(t=this.model.nodes())||void 0===t?void 0:t.length))return;const o=this.setSimulation(e);return o.data(this.model),o.initialize(e),o.restart(),new Promise(t=>{o.on("end",()=>t())})})}initializePhysicsData(t,e){const{nodeSize:n,getMass:r,nodeStrength:i,edgeStrength:o,linkDistance:A}=e;t.forEachNode(t=>{const e=t._original;t.size=n(e),t.mass=r(e),t.nodeStrength=i(e)}),t.forEachEdge(e=>{const n=e._original;e.edgeStrength=o(n),e.linkDistance=A(n,t.originalNode(e.source),t.originalNode(e.target))})}setSimulation(t){const e=this.simulation||new GK;return this.simulation||(this.simulation=e.on("tick",()=>{var e;null===(e=t.onTick)||void 0===e||e.call(t,this)})),this.setupRepulsiveForce(e,t),this.setupAttractiveForce(e,t),this.setupCollideForce(e,t),this.setupGravityForce(e,t),this.setupCentripetalForce(e,t),e}setupRepulsiveForce(t,e){const{factor:n,coulombDisScale:r,dimensions:i}=e;let o=t.force("repulsive");o||(o=PK(n,r,i),t.force("repulsive",o)),o.factor&&o.factor(n),o.coulombDisScale&&o.coulombDisScale(r),o.dimensions&&o.dimensions(i)}setupAttractiveForce(t,e){const{dimensions:n,preventOverlap:r}=e;if((this.model.edges()||[]).length>0){let e=t.force("attractive");e||(e=function(t=2){let e=!1;function n(e,n){e.forEachEdge(r=>{var i,o;const{source:A,target:s}=r,a=e.node(A),c=e.node(s);if(!a||!c)return;let l=c.x-a.x,u=c.y-a.y,h=3===t?(null!==(i=c.z)&&void 0!==i?i:0)-(null!==(o=a.z)&&void 0!==o?o:0):0;l||u||(l=.01,u=.01,3!==t||h||(h=.01));const d=Math.sqrt(l*l+u*u+h*h);if(d<Number(a.size)+Number(c.size))return;const f=l/d,g=u/d,p=h/d,{linkDistance:v=200,edgeStrength:m=200}=r,y=(v-d)*m,w=1/(a.mass||1),b=1/(c.mass||1),B=f*y,E=g*y,x=p*y;n[A].x-=B*w,n[A].y-=E*w,n[A].z-=x*w,n[s].x+=B*b,n[s].y+=E*b,n[s].z+=x*b})}return n.dimensions=function(e){return arguments.length?(t=e,n):t},n.preventOverlap=function(t){return arguments.length?(e=t,n):e},n}(n),t.force("attractive",e)),e.dimensions&&e.dimensions(n),e.preventOverlap&&e.preventOverlap(r)}else t.force("attractive",null)}setupGravityForce(t,e){const{center:n,gravity:r,getCenter:i}=e;if(r){let e=t.force("gravity");e||(e=function(t=[0,0,0],e=10){let n;function r(r,i){r.nodes()&&r.forEachNode(o=>{const{id:A,mass:s,x:a,y:c,z:l=0}=o;let u=0,h=0,d=0,f=e;const g=r.degree(A),p=null==n?void 0:n(o,g);if(p){const[t,e,n]=p;u=a-t,h=c-e,f=n}else u=a-t[0],h=c-t[1],d=l-(t[2]||0);f&&(i[A].x-=f*u/s,i[A].y-=f*h/s,i[A].z-=f*d/s)})}return r.center=function(e){return arguments.length?(t=e,r):t},r.gravity=function(t){return arguments.length?(e=t,r):e},r.getCenter=function(t){return arguments.length?(n=t,r):n},r}(n,r),t.force("gravity",e)),e.center&&e.center(n),e.gravity&&e.gravity(r),e.getCenter&&e.getCenter(i)}else t.force("gravity",null)}setupCollideForce(t,e){const{preventOverlap:n,collideStrength:r=1,dimensions:i}=e;if(n&&r){let e=t.force("collide");e||(e=function(t=2){let e=1;function n(n,r){const i=n.nodes();if(i.length<2||e<=0)return;if(2===t){const t=i.map((t,e)=>({id:t.id,index:e,x:t.x,y:t.y,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy})),e=dk(t,t=>t.x,t=>t.y).visitAfter(LK);for(const n of t)e.visit((t,e,i,A,s)=>{const a=t.r||0,c=n.r+a;if(e>n.x+c||A<n.x-c||i>n.y+c||s<n.y-c)return!0;if(!t.data)return!1;let l=t;do{const t=l.data;t&&t.index>n.index&&o(n,t,r),l=l.next}while(l);return!1});return}const s=i.map((t,e)=>{var n;return{id:t.id,index:e,x:t.x,y:t.y,z:null!==(n=t.z)&&void 0!==n?n:0,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy,fz:t.fz}});for(let t=0;t<s.length;t++)for(let e=t+1;e<s.length;e++)A(s[t],s[e],r)}function r(t){return Rx(t.fx)&&Rx(t.fy)?0:1/(t.mass||1)}function i(t){return Rx(t.fx)&&Rx(t.fy)&&Rx(t.fz)?0:1/(t.mass||1)}function o(t,n,i){let o=t.x-n.x,A=t.y-n.y,s=Math.hypot(o,A);const a=t.r+n.r;if(s>=a)return;s<IK&&(o=t.index<n.index?IK:-1e-6,A=0,s=Math.abs(o));const c=o/s,l=A/s,u=(a-s)*e*500,h=r(t),d=r(n);h&&(i[t.id].x+=c*u*h,i[t.id].y+=l*u*h),d&&(i[n.id].x-=c*u*d,i[n.id].y-=l*u*d)}function A(t,n,r){let o=t.x-n.x,A=t.y-n.y,s=t.z-n.z,a=Math.sqrt(o*o+A*A+s*s);const c=t.r+n.r;if(a>=c)return;a<IK&&(o=t.index<n.index?IK:-1e-6,A=0,s=0,a=Math.abs(o));const l=o/a,u=A/a,h=s/a,d=(c-a)*e*500,f=i(t),g=i(n);f&&(r[t.id].x+=l*d*f,r[t.id].y+=u*d*f,r[t.id].z+=h*d*f),g&&(r[n.id].x-=l*d*g,r[n.id].y-=u*d*g,r[n.id].z-=h*d*g)}return n.dimensions=function(e){return arguments.length?(t=e,n):t},n.strength=function(t){return arguments.length?(e=t,n):e},n}(i),t.force("collide",e)),e.strength&&e.strength(r),e.dimensions&&e.dimensions(i)}else t.force("collide",null)}setupCentripetalForce(t,e){const{centripetalOptions:n,width:r,height:i}=e;if(n){let e=t.force("centripetal");e||(e=function(){let t,e=800,n=600;function r(r,i){if(!t)return;const{leaf:o,single:A,others:s,center:a}=t,c=r.nodes(),l=r.edges(),u=c.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}})),h=l.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}}));r.forEachNode(t=>{const{id:c,mass:l,x:d,y:f,z:g=0,data:p}=t,v=r.degree(c,"in"),m=r.degree(c,"out"),y=r.degree(c,"both"),w=Object.assign(Object.assign({},t),{data:p||{}}),{x:b,y:B,z:E,centerStrength:x}=(null==a?void 0:a(w,u,h,e,n))||{x:0,y:0,z:0,centerStrength:0};if(!Rx(b)||!Rx(B))return;const C=(d-b)/l,M=(f-B)/l,F=(g-(E||0))/l;if(x&&(i[c].x-=x*C,i[c].y-=x*M,i[c].z-=x*F),0===y){const t=A(w);if(!t)return;return i[c].x-=t*C,i[c].y-=t*M,void(i[c].z-=t*F)}if(0===v||0===m){const t=o(w,u,h);if(!t)return;return i[c].x-=t*C,i[c].y-=t*M,void(i[c].z-=t*F)}const k=s(w);k&&(i[c].x-=k*C,i[c].y-=k*M,i[c].z-=k*F)})}return r.options=function(e){return arguments.length?(t=e,r):t},r.width=function(t){return arguments.length?(e=t,r):e},r.height=function(t){return arguments.length?(n=t,r):n},r}(),t.force("centripetal",e)),e.options&&e.options(n),e.width&&e.width(r),e.height&&e.height(i)}else t.force("centripetal",null)}parseOptions(t){const e=Object.assign(Object.assign({},t),MF(t));if(e.nodeClusterBy&&(e.nodeClusterBy=jx(e.nodeClusterBy,["node"])),t.getMass?e.getMass=zx(t.getMass,1):e.getMass=t=>{if(!t)return 1;const e=this.model.degree(t.id,"both");return!e||e<5?1:5*e*1},t.getCenter){const n=["node","degree"];e.getCenter=jx(t.getCenter,n)}const n=Wx(t.nodeSize,t.nodeSpacing);return e.nodeSize=t=>{if(!t)return 0;const[e,r,i]=n(t);return Math.max(e,r,i)},e.linkDistance=t.linkDistance?jx(t.linkDistance,["edge","source","target"]):(t,e,n)=>1+t.nodeSize(e)+t.nodeSize(n),e.nodeStrength=zx(t.nodeStrength,1),e.edgeStrength=zx(t.edgeStrength,1,"edge"),e.clusterNodeStrength=zx(t.clusterNodeStrength,1),this.formatCentripetal(e),e}formatCentripetal(t){var e,n;const{dimensions:r,centripetalOptions:i,center:o,leafCluster:A,clustering:s,nodeClusterBy:a}=t,c=jx(null==i?void 0:i.leaf,["node","nodes","edges"]),l=zx(null==i?void 0:i.single,2),u=zx(null==i?void 0:i.others,1),h=jx(null!==(e=null==i?void 0:i.center)&&void 0!==e?e:t=>({x:o[0],y:o[1],z:3===r?o[2]:void 0}),["node","nodes","edges","width","height"]),d=Object.assign(Object.assign({},i),{leaf:c,single:l,others:u,center:h});let f,g;if(i&&(t.centripetalOptions=d),A&&a&&(f=this.getSameTypeLeafMap(a),g=Array.from(new Set(null===(n=this.model.nodes())||void 0===n?void 0:n.map(t=>a(t._original))))||[],t.centripetalOptions=Object.assign({},d,{single:()=>100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=f[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==g?void 0:g.length)?1:t.clusterNodeStrength(e)},others:()=>1,center:t=>{const e=this.model.degree(t.id,"both");if(!e)return{x:100,y:100,z:0};let n;if(1===e){const{sameTypeLeaves:e=[]}=f[t.id]||{};1===e.length?n=void 0:e.length>1&&(n=this.getAvgNodePosition(e))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y,z:null==n?void 0:n.z}}})),s&&a){f||(f=this.getSameTypeLeafMap(a));let e=[];VK(e)&&this.model.forEachNode(t=>{const n=a(t._original);n&&!e.includes(n)&&e.push(n)});const n={};e.forEach(t=>{const e=this.model.nodes().filter(e=>a(e._original)===t);n[t]=this.getAvgNodePosition(e)}),t.centripetalOptions=Object.assign(d,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[a(t._original)];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}}getSameTypeLeafMap(t){const e={};return this.model.forEachNode(n=>{1===this.model.degree(n.id,"both")&&(e[n.id]=this.getCoreNodeAndSiblingLeaves(n,t))}),e}getCoreNodeAndSiblingLeaves(t,e){const n=this.model.degree(t.id,"in"),r=this.model.degree(t.id,"out");let i=t,o=[];if(0===n){const e=this.model.successors(t.id);i=this.model.node(e[0]),o=this.model.neighbors(i.id).map(t=>this.model.node(t))}else if(0===r){const e=this.model.predecessors(t.id);i=this.model.node(e[0]),o=this.model.neighbors(i.id).map(t=>this.model.node(t))}o=o.filter(t=>0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out"));const A=e(t._original)||"",s=o.filter(t=>e(t._original)===A&&(0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out")));return{coreNode:i,siblingLeaves:o,sameTypeLeaves:s}}getAvgNodePosition(t){const e={x:0,y:0};t.forEach(t=>{e.x+=t.x||0,e.y+=t.y||0});const n=t.length||1;return{x:e.x/n,y:e.y/n}}tick(t=1){return this.simulation&&this.simulation.tick(t),this}stop(){return this.simulation&&this.simulation.stop(),this}restart(){return this.simulation&&this.simulation.restart(),this}setFixedPosition(t,e){return this.simulation&&this.simulation.setFixedPosition(t,e),this}}class XK{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,n=t.ry-this.ry;let r=Math.hypot(e,n);r=r<1e-4?1e-4:r;const i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/e,r=(this.ry*this.mass+t.ry*t.mass)/e,i=this.degree+t.degree;return new XK({rx:n,ry:r,mass:e,degree:i})}}class qK{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new qK({xmid:t,ymid:e,length:n})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new qK({xmid:t,ymid:e,length:n})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new qK({xmid:t,ymid:e,length:n})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new qK({xmid:t,ymid:e,length:n})}}class $K{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new $K(this.quad.NW()),this.NE=new $K(this.quad.NE()),this.SW=new $K(this.quad.SW()),this.SE=new $K(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}let ZK=class extends _K{constructor(){super(...arguments),this.sg=0,this.forces={},this.preForces={},this.bodies={},this.sizes={},this.maxIteration=0}data(t,e){return this.model=t,this.sizes=e,this}initialize(t){super.initialize(t),this.maxIteration=t.maxIteration,this.sg=0,this.initForces()}initForces(){const{model:t,options:e}=this,{kr:n,barnesHut:r}=e,i=t.nodes();this.forces={},this.preForces={},this.bodies={};for(let e=0;e<i.length;e+=1){const o=i[e];if(this.forces[o.id]=[0,0],this.preForces[o.id]=[0,0],r){const r={id:e,rx:o.x,ry:o.y,mass:1,g:n,degree:t.degree(o.id)};this.bodies[o.id]=new XK(r)}}}setFixedPosition(t,e){const n=this.model.node(t);if(!n)return;const r=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<r.length&&("number"==typeof t||null===t)&&(n[r[e]]=t)}):r.forEach(t=>{delete n[t]})}isNodeFixed(t){return Rx(t.fx)&&Rx(t.fy)}syncFixedPositions(){this.model.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy)})}runOneStep(){const{model:t,options:e}=this,{preventOverlap:n,barnesHut:r}=e,i=this.maxIteration-this.iteration,o=t.nodes();for(let t=0;t<o.length;t+=1){const{id:e}=o[t];this.preForces[e]=[...this.forces[e]||[0,0]],this.forces[e]=[0,0]}return this.syncFixedPositions(),this.calculateAttractive(i),r&&!n?this.calculateOptRepulsiveGravity():this.calculateRepulsiveGravity(i,100),this.updatePositions()}calculateAttractive(t){const{model:e,options:n}=this,{preventOverlap:r,dissuadeHubs:i,mode:o,prune:A}=n,s=e.edges();for(let t=0;t<s.length;t+=1){const{source:n,target:a}=s[t],c=e.node(n),l=e.node(a),u=e.degree(n),h=e.degree(a);if(A&&(u<=1||h<=1))continue;const d=l.x-c.x,f=l.y-c.y;let g=Math.hypot(d,f);g=g<1e-4?1e-4:g;const p=d/g,v=f/g;let m=g;r&&(m=Math.max(0,g-this.sizes[n]-this.sizes[a]));let y=m,w=m;"linlog"===o&&(y=Math.log(1+m),w=y),i&&(y=m/u,w=m/h),this.forces[n][0]+=y*p,this.forces[n][1]+=y*v,this.forces[a][0]-=w*p,this.forces[a][1]-=w*v}}calculateOptRepulsiveGravity(){const{model:t,options:e}=this,{kg:n,center:r,prune:i,kr:o}=e,A=t.nodes(),s=A.length;let a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(let e=0;e<s;e+=1){const n=A[e],{id:r,x:o,y:s}=n;if(i&&t.degree(r)<=1)continue;const h=this.bodies[r];h&&(h.setPos(o,s),o<a&&(a=o),o>c&&(c=o),s<l&&(l=s),s>u&&(u=s))}let h=Math.max(c-a,u-l);(!isFinite(h)||h<=0)&&(h=1);const d=new qK({xmid:(c+a)/2,ymid:(u+l)/2,length:h,massCenter:r,mass:s}),f=new $K(d);for(let e=0;e<s;e+=1){const{id:n}=A[e];if(i&&t.degree(n)<=1)continue;const r=this.bodies[n];r&&r.in(d)&&f.insert(r)}for(let e=0;e<s;e+=1){const o=A[e],{id:s,x:a,y:c}=o,l=t.degree(s);if(i&&l<=1)continue;const u=this.bodies[s];if(!u)continue;u.resetForce(),f.updateForce(u),this.forces[s][0]-=u.fx,this.forces[s][1]-=u.fy;const h=a-r[0],d=c-r[1];let g=Math.hypot(h,d);g=g<1e-4?1e-4:g;const p=h/g,v=d/g,m=n*(l+1);this.forces[s][0]-=m*p,this.forces[s][1]-=m*v}}calculateRepulsiveGravity(t,e){const{model:n,options:r}=this,{preventOverlap:i,kr:o,kg:A,center:s,prune:a}=r,c=n.nodes(),l=c.length;for(let t=0;t<l;t+=1){const r=c[t],u=n.degree(r.id);for(let A=t+1;A<l;A+=1){const t=c[A],s=n.degree(t.id);if(a&&(u<=1||s<=1))continue;const l=t.x-r.x,h=t.y-r.y;let d=Math.hypot(l,h);d=d<1e-4?1e-4:d;const f=l/d,g=h/d;let p,v=d;if(i){const n=d-this.sizes[r.id]-this.sizes[t.id];n<0?p=e*(u+1)*(s+1):0===n?p=0:(v=n,p=o*(u+1)*(s+1)/v)}else p=o*(u+1)*(s+1)/v;this.forces[r.id][0]-=p*f,this.forces[r.id][1]-=p*g,this.forces[t.id][0]+=p*f,this.forces[t.id][1]+=p*g}const h=r.x-s[0],d=r.y-s[1];let f=Math.hypot(h,d);f=f<1e-4?1e-4:f;const g=h/f,p=d/f,v=A*(u+1);this.forces[r.id][0]-=v*g,this.forces[r.id][1]-=v*p}}updatePositions(){const{model:t,options:e}=this,{ks:n,tao:r,prune:i,ksmax:o,distanceThresholdMode:A="max"}=e,s=t.nodes(),a=s.length,c={},l={};let u=0,h=0;for(let e=0;e<a;e+=1){const{id:n}=s[e],r=t.degree(n);if(i&&r<=1)continue;const o=this.preForces[n]||[0,0],A=this.forces[n]||[0,0],a=A[0]-o[0],d=A[1]-o[1],f=Math.hypot(a,d),g=A[0]+o[0],p=A[1]+o[1],v=Math.hypot(g,p);c[n]=f,l[n]=v/2,u+=(r+1)*c[n],h+=(r+1)*l[n]}let d=this.sg;const f=this.sg;u<=0?d=f>0?f:1:(d=r*h/u,0!==f&&(d=d>1.5*f?1.5*f:d)),this.sg=d;let g=0,p=1/0,v=0,m=0;for(let e=0;e<a;e+=1){const r=s[e],A=r.id,a=t.degree(A);if(i&&a<=1)continue;if(this.isNodeFixed(r))continue;const l=c[A]||0;let u=n*d/(1+d*Math.sqrt(l)),h=Math.hypot(this.forces[A][0],this.forces[A][1]);h=h<1e-4?1e-4:h;const f=o/h;u>f&&(u=f);const y=u*this.forces[A][0],w=u*this.forces[A][1];r.x+=y,r.y+=w;const b=Math.hypot(y,w);b>0&&(m++,v+=b,b>g&&(g=b),b<p&&(p=b))}switch(A){case"min":return p;case"mean":return m>0?v/m:0;default:return g}}destroy(){this.stop(),this.forces={},this.preForces={},this.bodies={},this.sizes={},this.off()}};const JK={nodeSize:10,nodeSpacing:0,width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class tj extends BC{constructor(){super(...arguments),this.id="force-atlas2",this.simulation=null}getDefaultOptions(){return JK}layout(t){return px(this,0,void 0,function*(){const e=this.parseOptions(t),{width:n,height:r,prune:i,center:o}=e,A=this.model.nodeCount();if(!A||1===A)return bF(this.model,o);Zx(this.model,n,r);const s=this.getSizes(e.nodeSize,e.nodeSpacing),a=this.setSimulation();a.data(this.model,s),a.initialize(e),a.restart();const c=()=>new Promise(t=>{a.on("end",t)});if(!i)return c();if(yield c(),i){const t=this.model.edges();for(let e=0;e<t.length;e+=1){const{source:n,target:r}=t[e],i=this.model.degree(n),o=this.model.degree(r),A=this.model.node(n),s=this.model.node(r);i<=1?(A.x=s.x,A.y=s.y):o<=1&&(s.x=A.x,s.y=A.y)}a.initialize(Object.assign(Object.assign({},e),{prune:!1,barnesHut:!1})),a.tick(100)}})}getSizes(t,e){const n={},r=Wx(t,e,JK.nodeSize,JK.nodeSpacing);return this.model.forEachNode(t=>{n[t.id]=Math.max(...r(t._original))}),n}setSimulation(){const t=this.simulation||new ZK;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}parseOptions(t={}){const{barnesHut:e,prune:n,maxIteration:r,kr:i,kg:o}=t,A={},s=this.model.nodeCount();return void 0===e&&s>250&&(A.barnesHut=!0),void 0===n&&s>100&&(A.prune=!0),0!==r||n?0===r&&n&&(A.maxIteration=100,s<=200&&s>100?A.maxIteration=500:s>200&&(A.maxIteration=950)):(A.maxIteration=250,s<=200&&s>100?A.maxIteration=1e3:s>200&&(A.maxIteration=1200)),i||(A.kr=50,s>100&&s<=500?A.kr=20:s>500&&(A.kr=1)),o||(A.kg=20,s>100&&s<=500?A.kg=10:s>500&&(A.kg=1)),Object.assign(Object.assign(Object.assign({},t),A),MF(t))}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}setFixedPosition(t,e){var n;null===(n=this.simulation)||void 0===n||n.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}}class ej extends _K{constructor(){super(...arguments),this.displacements=null,this.clusterMap=null}data(t){return this.model=t,this}initialize(t){super.initialize(t),this.recomputeConstants(),this.displacements=null,this.clusterMap=null,this.initDisplacements()}recomputeConstants(){const{model:t,options:e}=this,{width:n,height:r}=MF(e),i=n*r;this.k2=i/(t.nodeCount()+1),this.k=Math.sqrt(this.k2),this.maxDisplace=Math.sqrt(i)/10}runOneStep(){return this.syncFixedPositions(),this.initDisplacements(),this.calculateRepulsive(),this.calculateAttractive(),this.applyClusterGravity(),this.applyGlobalGravity(),this.updatePositions()}setFixedPosition(t,e){const n=this.model.node(t);if(!n)return;const r=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<r.length&&("number"==typeof t||null===t)&&(n[r[e]]=t)}):r.forEach(t=>{delete n[t]})}isNodeFixed(t){return!_x(t.fx)&&!_x(t.fy)}syncFixedPositions(){const{model:t,options:e}=this,n=3===e.dimensions;t.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy,n&&void 0!==t.fz&&(t.z=t.fz))})}initDisplacements(){this.displacements||(this.displacements=new Map,this.model.forEachNode(t=>{this.displacements.set(t.id,{x:0,y:0,z:0})})),this.displacements.forEach(t=>{t.x=0,t.y=0,t.z=0})}calculateRepulsive(){const{model:t,options:e}=this,n=3===e.dimensions,r=t.nodes();for(let t=0;t<r.length;t++){const e=r[t],i=this.displacements.get(e.id),o=this.isNodeFixed(e);for(let A=t+1;A<r.length;A++){const t=r[A],s=this.displacements.get(t.id),a=this.isNodeFixed(t);let c=e.x-t.x,l=e.y-t.y,u=n?e.z-t.z:0,h=c*c+l*l+u*u;0===h&&(h=1,c=.01,l=.01,u=.01);const d=this.k2/h,f=c*d,g=l*d,p=u*d;o||a?o&&!a?(s.x-=2*f,s.y-=2*g,n&&(s.z-=2*p)):!o&&a&&(i.x+=2*f,i.y+=2*g,n&&(i.z+=2*p)):(i.x+=f,i.y+=g,s.x-=f,s.y-=g,n&&(i.z+=p,s.z-=p))}}}calculateAttractive(){const{model:t,options:e}=this,n=3===e.dimensions;t.forEachEdge(e=>{const{source:r,target:i}=e;if(!r||!i||r===i)return;const o=t.node(r),A=t.node(i),s=this.displacements.get(r),a=this.displacements.get(i),c=this.isNodeFixed(o),l=this.isNodeFixed(A),u=A.x-o.x,h=A.y-o.y,d=n?A.z-o.z:0,f=Math.sqrt(u*u+h*h+d*d);if(0===f)return;const g=f/this.k,p=u*g,v=h*g,m=d*g;c||l?c&&!l?(a.x-=2*p,a.y-=2*v,n&&(a.z-=2*m)):!c&&l&&(s.x+=2*p,s.y+=2*v,n&&(s.z+=2*m)):(s.x+=p,s.y+=v,a.x-=p,a.y-=v,n&&(s.z+=m,a.z-=m))})}applyClusterGravity(){const{model:t,options:e}=this,{nodeClusterBy:n,clusterGravity:r,dimensions:i,clustering:o}=e;if(!o)return;if(this.clusterMap||(this.clusterMap=new Map,t.forEachNode(e=>{const r=n(t.originalNode(e.id));this.clusterMap.has(r)||this.clusterMap.set(r,{name:r,cx:0,cy:0,cz:0,count:0})})),0===this.clusterMap.size)return;const A=3===i;this.clusterMap.forEach(t=>{t.cx=0,t.cy=0,t.cz=0,t.count=0}),t.forEachNode(e=>{const r=n(t.originalNode(e.id)),i=this.clusterMap.get(r);i&&(i.cx+=e.x,i.cy+=e.y,A&&(i.cz+=e.z),i.count++)}),this.clusterMap.forEach(t=>{t.count>0&&(t.cx/=t.count,t.cy/=t.count,t.cz/=t.count)}),t.forEachNode(e=>{const{id:i}=e;if(this.isNodeFixed(e))return;const o=n(t.originalNode(i)),s=this.clusterMap.get(o);if(!s)return;const a=this.displacements.get(i),c=e.x-s.cx,l=e.y-s.cy,u=A?e.z-s.cz:0,h=Math.sqrt(c*c+l*l+u*u);if(0===h)return;const d=this.k*r;a.x-=d*c/h,a.y-=d*l/h,A&&(a.z-=d*u/h)})}applyGlobalGravity(){const{model:t,options:e}=this,{gravity:n,center:r,dimensions:i}=e,o=3===i,A=.01*this.k*n;t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const n=this.displacements.get(e);n.x-=A*(t.x-r[0]),n.y-=A*(t.y-r[1]),o&&(n.z-=A*(t.z-(r[2]||0)))})}updatePositions(){const{model:t,options:e}=this,{speed:n,dimensions:r,distanceThresholdMode:i="max"}=e,o=3===r;let A=0,s=1/0,a=0,c=0;if(t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const r=this.displacements.get(e),i=Math.sqrt(r.x*r.x+r.y*r.y+(o?r.z*r.z:0));if(0===i)return;const l=Math.min(this.maxDisplace*(n/800),i),u=l/i;t.x+=r.x*u,t.y+=r.y*u,o&&(t.z=t.z+r.z*u),A=Math.max(A,l),s=Math.min(s,l),a+=l,c++}),0===c)return 0;switch(i){case"min":return s===1/0?0:s;case"mean":return a/c;default:return A}}destroy(){var t,e;this.stop(),null===(t=this.displacements)||void 0===t||t.clear(),null===(e=this.clusterMap)||void 0===e||e.clear()}}const nj={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"node.cluster",dimensions:2};class rj extends BC{constructor(){super(...arguments),this.id="fruchterman",this.simulation=null}getDefaultOptions(){return nj}parseOptions(t={}){const{clustering:e,nodeClusterBy:n}=this.options,r=e&&!!n;return Object.assign(t,MF(t),{clustering:r,nodeClusterBy:jx(n,["node"])}),t}layout(){return px(this,0,void 0,function*(){const t=this.parseOptions(this.options),{dimensions:e,center:n,width:r,height:i}=t,o=this.model.nodeCount();if(!o||1===o)return void bF(this.model,n,e);Zx(this.model,r,i,e);const A=this.setSimulation();return A.data(this.model),A.initialize(t),A.restart(),new Promise(t=>{A.on("end",()=>t())})})}setSimulation(){const t=this.simulation||new ej;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}setFixedPosition(t,e){var n;null===(n=this.simulation)||void 0===n||n.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}}const ij={begin:[0,0],preventOverlap:!0,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,nodeSpacing:10,width:300,height:300};class oj extends bC{constructor(){super(...arguments),this.id="grid"}getDefaultOptions(){return ij}parseOptions(t={},e){const{rows:n,cols:r,position:i,sortBy:o}=t,{width:A,height:s,center:a}=MF(t);let c=t.rows,l=t.cols;const u=e.nodeCount();if(null!=n&&null!=r)c=n,l=r;else if(null!=n&&null==r)c=n,l=Math.ceil(u/c);else if(null==n&&null!=r)l=r,c=Math.ceil(u/l);else{const t=Math.sqrt(u*s/A);c=Math.round(t),l=Math.round(A/s*t)}c=Math.max(c,1),l=Math.max(l,1);const h={rows:c,cols:l};if(h.cols*h.rows>u){const t=Aj(h),e=sj(h);(t-1)*e>=u?Aj(h,t-1):(e-1)*t>=u&&sj(h,e-1)}else for(;h.cols*h.rows<u;){const t=Aj(h),e=sj(h);(e+1)*t>=u?sj(h,e+1):Aj(h,t+1)}const d=o?"degree"===o||"id"===o?o:jx(o,["nodeA","nodeB"]):ij.sortBy;return Object.assign(Object.assign({},t),{sortBy:d,rcs:h,center:a,width:A,height:s,position:jx(i,["node"])})}layout(){return px(this,0,void 0,function*(){const{begin:t,rcs:e,sortBy:n,width:r,height:i,condense:o,preventOverlap:A,nodeSpacing:s,nodeSize:a,position:c}=this.parseOptions(this.options,this.model),l=this.model.nodeCount();if(!l||1===l)return void bF(this.model,t);"degree"===n?EF(this.model):"id"===n?BF(this.model,(t,e)=>{const n=t.id,r=e.id;return"number"==typeof n&&"number"==typeof r?n-r:String(n).localeCompare(String(r))}):xF(this.model,n);let u=o?0:r/e.cols,h=o?0:i/e.rows;if(A){const t=Wx(a,s,ij.nodeSize,ij.nodeSpacing);this.model.forEachNode(e=>{const[n,r]=t(e._original);u=Math.max(u,n),h=Math.max(h,r)})}const d={},f={row:0,col:0},g={};this.model.forEachNode(n=>{const r=n._original;let i;if(c&&(i=c(r)),i&&(void 0!==i.row||void 0!==i.col)){const t={row:i.row,col:i.col};if(void 0===t.col)for(t.col=0;aj(d,t);)t.col++;else if(void 0===t.row)for(t.row=0;aj(d,t);)t.row++;g[n.id]=t,cj(d,t)}uj(n,t,u,h,g,e,f,d)})})}}const Aj=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.min(r,i);else{Math.min(r,i)===t.rows?t.rows=e:t.cols=e}return n},sj=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.max(r,i);else{Math.max(r,i)===t.rows?t.rows=e:t.cols=e}return n},aj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,cj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,lj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},uj=(t,e,n,r,i,o,A,s)=>{let a,c;const l=i[t.id];if(l)a=l.col*n+n/2+e[0],c=l.row*r+r/2+e[1];else{for(;aj(s,A);)lj(o,A);a=A.col*n+n/2+e[0],c=A.row*r+r/2+e[1],cj(s,A),lj(o,A)}t.x=a,t.y=c};var hj={};const dj=Object.prototype.toString;function fj(t){const e=dj.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var gj=bU(Object.freeze({__proto__:null,isAnyArray:fj}));var pj,vj=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!fj(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(!fj(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(!fj(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(!fj(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,a=void 0===s?n.autoMinMax?i:1:s;if(A>=a)throw new RangeError("min option must be smaller than max option");for(var c=(a-A)/(i-r),l=0;l<t.length;l++)e[l]=(t[l]-r)*c+A;return e}}),mj=bU(vj);function yj(){if(pj)return hj;pj=1,Object.defineProperty(hj,"__esModule",{value:!0});var t=gj,e=mj;const n=" ".repeat(2),r=" ".repeat(4);function i(t,e={}){const{maxRows:i=15,maxColumns:A=10,maxNumSize:s=8,padMinus:a="auto"}=e;return`${t.constructor.name} {\n${n}[\n${r}${function(t,e,n,i,A){const{rows:s,columns:a}=t,c=Math.min(s,e),l=Math.min(a,n),u=[];if("auto"===A){A=!1;t:for(let e=0;e<c;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){A=!0;break t}}for(let e=0;e<c;e++){let n=[];for(let r=0;r<l;r++)n.push(o(t.get(e,r),i,A));u.push(`${n.join(" ")}`)}l!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);c!==s&&u.push(`... ${s-e} more rows`);return u.join(`\n${r}`)}(t,i,A,s,a)}\n${n}]\n${n}rows: ${t.rows}\n${n}columns: ${t.columns}\n}`}function o(t,e,n){return(t>=0&&n?` ${A(t,e-1)}`:A(t,e)).padEnd(e)}function A(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function s(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function a(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function c(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function l(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function u(e,n){if(!t.isAnyArray(n))throw new TypeError("row indices must be an array");for(let t=0;t<n.length;t++)if(n[t]<0||n[t]>=e.rows)throw new RangeError("row indices are out of range")}function h(e,n){if(!t.isAnyArray(n))throw new TypeError("column indices must be an array");for(let t=0;t<n.length;t++)if(n[t]<0||n[t]>=e.columns)throw new RangeError("column indices are out of range")}function d(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(g("startRow",e),g("endRow",n),g("startColumn",r),g("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function f(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function g(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function p(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class v{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new w(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 w(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 w(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 w(t,e)}static ones(t,e){return new w(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 w(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 w(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 w(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 v.isMatrix(t)?t:new w(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let A=i;A<e;A++){let e=t.get(n,A)-o*t.get(r,A);t.set(n,A,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new w(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){s(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return w.rowVector(this.getRow(t))}setRow(t,e){s(this,t),e=c(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){s(this,t),s(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){a(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return w.columnVector(this.getColumn(t))}setColumn(t,e){a(this,t),e=l(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){a(this,t),a(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=c(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=c(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=c(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=c(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=l(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=l(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=l(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=l(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){s(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){a(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(){p(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(){p(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(s(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){s(this,t),p(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(s(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){s(this,t),p(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(a(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){a(this,t),p(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(a(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){a(this,t),p(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){v.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=w.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new w(e,r),o=new Float64Array(n);for(let A=0;A<r;A++){for(let e=0;e<n;e++)o[e]=t.get(e,A);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,A,e)}}return i}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=w.eye(this.rows),n=this;for(let r=t;r>=1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=w.checkMatrix(t);let e=new w(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),A=this.get(1,0),s=t.get(1,0),a=this.get(1,1),c=t.get(1,1),l=(n+a)*(r+c),u=(A+a)*r,h=n*(o-c),d=a*(s-r),f=(n+i)*c,g=l+d-f+(i-a)*(s+c),p=h+f,v=u+d,m=l-u+h+(A-n)*(r+o);return e.set(0,0,g),e.set(0,1,p),e.set(1,0,v),e.set(1,1,m),e}strassen3x3(t){t=w.checkMatrix(t);let e=new w(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),A=this.get(1,1),s=this.get(1,2),a=this.get(2,0),c=this.get(2,1),l=this.get(2,2),u=t.get(0,0),h=t.get(0,1),d=t.get(0,2),f=t.get(1,0),g=t.get(1,1),p=t.get(1,2),v=t.get(2,0),m=t.get(2,1),y=t.get(2,2),b=(n-o)*(-h+g),B=(-n+o+A)*(u-h+g),E=(o+A)*(-u+h),x=n*u,C=(-n+a+c)*(u-d+p),M=(-n+a)*(d-p),F=(a+c)*(-u+d),k=(-i+c+l)*(g+v-m),S=(i-l)*(g-m),Q=i*v,U=(c+l)*(-v+m),N=(-i+A+s)*(p+v-y),T=(i-s)*(p-y),O=(A+s)*(-v+y),I=x+Q+r*f,L=(n+r+i-o-A-c-l)*g+B+E+x+k+Q+U,P=x+C+F+(n+r+i-A-s-a-c)*p+Q+N+O,D=b+A*(-u+h+f-g-p-v+y)+B+x+Q+N+T,R=b+B+E+x+s*m,H=Q+N+T+O+o*d,_=x+C+M+c*(-u+d+f-g-p-v+m)+k+S+Q,G=k+S+Q+U+a*h,K=x+C+M+F+l*y;return e.set(0,0,I),e.set(0,1,L),e.set(0,2,P),e.set(1,0,D),e.set(1,1,R),e.set(1,2,H),e.set(2,0,_),e.set(2,1,G),e.set(2,2,K),e}mmulStrassen(t){t=w.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function A(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=v.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),a=Math.max(r,o);return e=A(e,s,a),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=A(e,r+1,i+1),n=A(n,r+1,i+1)):r%2==1?(e=A(e,r+1,i),n=A(n,r+1,i)):i%2==1&&(e=A(e,r,i+1),n=A(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),a=e.subMatrix(0,o-1,0,s-1),c=n.subMatrix(0,o-1,0,s-1),l=e.subMatrix(0,o-1,s,e.columns-1),u=n.subMatrix(0,o-1,s,n.columns-1),h=e.subMatrix(o,e.rows-1,0,s-1),d=n.subMatrix(o,n.rows-1,0,s-1),f=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),p=t(v.add(a,f),v.add(c,g),o,s),m=t(v.add(h,f),c,o,s),y=t(a,v.sub(u,g),o,s),w=t(f,v.sub(d,c),o,s),b=t(v.add(a,l),g,o,s),B=t(v.sub(h,a),v.add(c,u),o,s),E=t(v.sub(l,f),v.add(d,g),o,s),x=v.add(p,w);x.sub(b),x.add(E);let C=v.add(y,b),M=v.add(m,w),F=v.sub(p,m);F.add(y),F.add(B);let k=v.zeros(2*x.rows,2*x.columns);return k=k.setSubMatrix(x,0,0),k=k.setSubMatrix(C,x.rows,0),k=k.setSubMatrix(M,0,x.columns),k=k.setSubMatrix(F,x.rows,x.columns),k.subMatrix(0,r-1,0,i-1)}(e,t=A(t,s,a),s,a)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:n=0,max:r=1}=t;if(!Number.isFinite(n))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(n>=r)throw new RangeError("min must be smaller than max");let i=new w(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&e(o,{min:n,max:r,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:n=0,max:r=1}=t;if(!Number.isFinite(n))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(n>=r)throw new RangeError("min must be smaller than max");let i=new w(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&e(o,{min:n,max:r,output:o}),i.setColumn(t,o)}return i}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=w.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new w(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=w.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(w.eye(n,n)),i=w.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new w(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=m){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=m){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){d(this,t,e,n,r);let i=new w(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 w(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 w(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=w.checkMatrix(t)).isEmpty())return this;d(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){u(this,t),h(this,e);let n=new w(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new w(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=f(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=f(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=f(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=f(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(e,n={}){if("object"==typeof e&&(n=e,e=void 0),"object"!=typeof n)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:i=this.mean(e)}=n;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(e){case"row":if(!t.isAnyArray(i))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,a=0;for(let e=0;e<i;e++)a=t.get(A,e)-n[A],r+=a,s+=a*a;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,r,i);case"column":if(!t.isAnyArray(i))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,a=0;for(let e=0;e<r;e++)a=t.get(e,A)-n[A],i+=a,s+=a*a;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,r,i);case void 0:if("number"!=typeof i)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,a=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)a=t.get(e,r)-n,A+=a,s+=a*a;return e?(s-A*A/o)/(o-1):(s-A*A/o)/o}(this,r,i);default:throw new Error(`invalid option: ${e}`)}}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(e,n={}){if("object"==typeof e&&(n=e,e=void 0),"object"!=typeof n)throw new TypeError("options must be an object");const{center:r=this.mean(e)}=n;switch(e){case"row":if(!t.isAnyArray(r))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,r),this;case"column":if(!t.isAnyArray(r))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,r),this;case void 0:if("number"!=typeof r)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,r),this;default:throw new Error(`invalid option: ${e}`)}}scale(e,n={}){if("object"==typeof e&&(n=e,e=void 0),"object"!=typeof n)throw new TypeError("options must be an object");let r=n.scale;switch(e){case"row":if(void 0===r)r=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=t.get(n,e)**2/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!t.isAnyArray(r))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,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=t.get(e,n)**2/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!t.isAnyArray(r))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,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=t.get(i,r)**2/e;return Math.sqrt(n)}(this);else if("number"!=typeof r)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,r),this;default:throw new Error(`invalid option: ${e}`)}}toString(t){return i(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function m(t,e){return t-e}function y(t){return t.every(t=>"number"==typeof t)}v.prototype.klass="Matrix","undefined"!=typeof Symbol&&(v.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return i(this)}),v.random=v.rand,v.randomInt=v.randInt,v.diagonal=v.diag,v.prototype.diagonal=v.prototype.diag,v.identity=v.eye,v.prototype.negate=v.prototype.neg,v.prototype.tensorProduct=v.prototype.kroneckerProduct;class w extends v{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),w.isMatrix(e))this.#t(e.rows,e.columns),w.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!t.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!y(t[r]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return s(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),s(this,t,!0),e=Float64Array.from(c(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){a(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),a(this,t,!0),e=l(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t);return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t.get(e,n));return this}}(v,w);class b extends v{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return w.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),w.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=w.copy(t,new w(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new w(t,t);else if(this.#e=new w(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new b(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new w(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const r=new b(n);for(let i=0,o=0,A=0;A<e;A++)r.set(i,o,t[A]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}b.prototype.klassType="SymmetricMatrix";class B extends b{static isDistanceMatrix(t){return b.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new b(this)}clone(){const t=new B(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,A=0;A<e;A++)r.set(i,o,t[A]),++i>=n&&(i=1+ ++o);return r}}B.prototype.klassSubType="DistanceMatrix";class E extends v{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class x extends E{constructor(t,e,n){u(t,e),h(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class C extends v{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class M extends v{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class F{constructor(t){let e,n,r,i,o,A,s,a,c,l=(t=M.checkMatrix(t)).clone(),u=l.rows,h=l.columns,d=new Float64Array(u),f=1;for(e=0;e<u;e++)d[e]=e;for(a=new Float64Array(u),n=0;n<h;n++){for(e=0;e<u;e++)a[e]=l.get(e,n);for(e=0;e<u;e++){for(c=Math.min(e,n),o=0,r=0;r<c;r++)o+=l.get(e,r)*a[r];a[e]-=o,l.set(e,n,a[e])}for(i=n,e=n+1;e<u;e++)Math.abs(a[e])>Math.abs(a[i])&&(i=e);if(i!==n){for(r=0;r<h;r++)A=l.get(i,r),l.set(i,r,l.get(n,r)),l.set(n,r,A);s=d[i],d[i]=d[n],d[n]=s,f=-f}if(n<u&&0!==l.get(n,n))for(e=n+1;e<u;e++)l.set(e,n,l.get(e,n)/l.get(n,n))}this.LU=l,this.pivotVector=d,this.pivotSign=f}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=w.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,A=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)A.set(n,r,A.get(n,r)-A.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)A.set(i,r,A.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)A.set(n,r,A.get(n,r)-A.get(i,r)*e.get(n,i))}return A}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new w(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new w(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function k(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 S{constructor(t){let e,n,r,i,o=(t=M.checkMatrix(t)).clone(),A=t.rows,s=t.columns,a=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<A;e++)t=k(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<A;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<A;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<A;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}a[r]=-t}this.QR=o,this.Rdiag=a}solve(t){t=w.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,A,s=t.columns,a=t.clone(),c=e.columns;for(o=0;o<c;o++)for(i=0;i<s;i++){for(A=0,r=o;r<n;r++)A+=e.get(r,o)*a.get(r,i);for(A=-A/e.get(o,o),r=o;r<n;r++)a.set(r,i,a.get(r,i)+A*e.get(r,o))}for(o=c-1;o>=0;o--){for(i=0;i<s;i++)a.set(o,i,a.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)a.set(r,i,a.get(r,i)-a.get(o,i)*e.get(r,o))}return a.subMatrix(0,c-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new w(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,A=i.columns,s=new w(o,A);for(n=A-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<A;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}class Q{constructor(t,e={}){if((t=M.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,a=Boolean(i),c=Boolean(o),l=!1;if(n<r)if(A){s=t.transpose(),n=s.rows,r=s.columns,l=!0;let e=a;a=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 u=Math.min(n,r),h=Math.min(n+1,r),d=new Float64Array(h),f=new w(n,u),g=new w(r,r),p=new Float64Array(r),v=new Float64Array(n),m=new Float64Array(h);for(let t=0;t<h;t++)m[t]=t;let y=Math.min(n-1,r),b=Math.max(0,Math.min(r-2,n)),B=Math.max(y,b);for(let t=0;t<B;t++){if(t<y){d[t]=0;for(let e=t;e<n;e++)d[t]=k(d[t],s.get(e,t));if(0!==d[t]){s.get(t,t)<0&&(d[t]=-d[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/d[t]);s.set(t,t,s.get(t,t)+1)}d[t]=-d[t]}for(let e=t+1;e<r;e++){if(t<y&&0!==d[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))}p[e]=s.get(t,e)}if(a&&t<y)for(let e=t;e<n;e++)f.set(e,t,s.get(e,t));if(t<b){p[t]=0;for(let e=t+1;e<r;e++)p[t]=k(p[t],p[e]);if(0!==p[t]){p[t+1]<0&&(p[t]=0-p[t]);for(let e=t+1;e<r;e++)p[e]/=p[t];p[t+1]+=1}if(p[t]=-p[t],t+1<n&&0!==p[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]+=p[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-p[e]/p[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,p[e])}}let E=Math.min(r,n+1);if(y<r&&(d[y]=s.get(y,y)),n<E&&(d[E-1]=0),b+1<E&&(p[b]=s.get(b,E-1)),p[E-1]=0,a){for(let t=y;t<u;t++){for(let e=0;e<n;e++)f.set(e,t,0);f.set(t,t,1)}for(let t=y-1;t>=0;t--)if(0!==d[t]){for(let e=t+1;e<u;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<b&&0!==p[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=E-1,C=Number.EPSILON;for(;E>0;){let t,e;for(t=E-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+C*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(p[t])<=e||Number.isNaN(p[t])){p[t]=0;break}}if(t===E-2)e=4;else{let n;for(n=E-1;n>=t&&n!==t;n--){let e=(n!==E?Math.abs(p[n]):0)+(n!==t+1?Math.abs(p[n-1]):0);if(Math.abs(d[n])<=C*e){d[n]=0;break}}n===t?e=3:n===E-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=p[E-2];p[E-2]=0;for(let n=E-2;n>=t;n--){let i=k(d[n],e),o=d[n]/i,A=e/i;if(d[n]=i,n!==t&&(e=-A*p[n-1],p[n-1]=o*p[n-1]),c)for(let t=0;t<r;t++)i=o*g.get(t,n)+A*g.get(t,E-1),g.set(t,E-1,-A*g.get(t,n)+o*g.get(t,E-1)),g.set(t,n,i)}break}case 2:{let e=p[t-1];p[t-1]=0;for(let r=t;r<E;r++){let i=k(d[r],e),o=d[r]/i,A=e/i;if(d[r]=i,e=-A*p[r],p[r]=o*p[r],a)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(d[E-1]),Math.abs(d[E-2]),Math.abs(p[E-2]),Math.abs(d[t]),Math.abs(p[t])),i=d[E-1]/e,o=d[E-2]/e,A=p[E-2]/e,s=d[t]/e,l=p[t]/e,u=((o+i)*(o-i)+A*A)/2,h=i*A*(i*A);let v=0;0===u&&0===h||(v=u<0?0-Math.sqrt(u*u+h):Math.sqrt(u*u+h),v=h/(u+v));let m=(s+i)*(s-i)+v,y=s*l;for(let e=t;e<E-1;e++){let i=k(m,y);0===i&&(i=Number.MIN_VALUE);let o=m/i,A=y/i;if(e!==t&&(p[e-1]=i),m=o*d[e]+A*p[e],p[e]=o*p[e]-A*d[e],y=A*d[e+1],d[e+1]=o*d[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=k(m,y),0===i&&(i=Number.MIN_VALUE),o=m/i,A=y/i,d[e]=i,m=o*p[e]+A*d[e+1],d[e+1]=-A*p[e]+o*d[e+1],y=A*p[e+1],p[e+1]=o*p[e+1],a&&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)}p[E-2]=m;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,c))for(let e=0;e<=x;e++)g.set(e,t,-g.get(e,t));for(;t<x&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[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(a&&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++}E--}}if(l){let t=g;g=f,f=t}this.m=n,this.n=r,this.s=d,this.U=f,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=w.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),a=A.rows,c=o.rows,l=w.zeros(a,c);for(let t=0;t<a;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);l.set(t,e,n)}return l.mmul(e)}solveForDiagonal(t){return this.solve(w.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new w(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,a=new w(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);a.set(t,e,n)}return a}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 w.diag(this.s)}}function U(t,e,n=!1){return t=M.checkMatrix(t),e=M.checkMatrix(e),n?new Q(t).solve(e):t.isSquare()?new F(t).solve(e):new S(t).solve(e)}function N(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function T(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class O{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=M.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,A=new w(o,o),s=new Float64Array(o),a=new Float64Array(o),c=t,l=!1;if(l=!!n||t.isSymmetric(),l){for(r=0;r<o;r++)for(i=0;i<o;i++)A.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,A,s,a,c,l,u;for(a=0;a<t;a++)n[a]=r.get(t-1,a);for(s=t-1;s>0;s--){for(u=0,A=0,c=0;c<s;c++)u+=Math.abs(n[c]);if(0===u)for(e[s]=n[s-1],a=0;a<s;a++)n[a]=r.get(s-1,a),r.set(s,a,0),r.set(a,s,0);else{for(c=0;c<s;c++)n[c]/=u,A+=n[c]*n[c];for(i=n[s-1],o=Math.sqrt(A),i>0&&(o=-o),e[s]=u*o,A-=i*o,n[s-1]=i-o,a=0;a<s;a++)e[a]=0;for(a=0;a<s;a++){for(i=n[a],r.set(a,s,i),o=e[a]+r.get(a,a)*i,c=a+1;c<=s-1;c++)o+=r.get(c,a)*n[c],e[c]+=r.get(c,a)*i;e[a]=o}for(i=0,a=0;a<s;a++)e[a]/=A,i+=e[a]*n[a];for(l=i/(A+A),a=0;a<s;a++)e[a]-=l*n[a];for(a=0;a<s;a++){for(i=n[a],o=e[a],c=a;c<=s-1;c++)r.set(c,a,r.get(c,a)-(i*e[c]+o*n[c]));n[a]=r.get(s-1,a),r.set(s,a,0)}}n[s]=A}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),A=n[s+1],0!==A){for(c=0;c<=s;c++)n[c]=r.get(c,s+1)/A;for(a=0;a<=s;a++){for(o=0,c=0;c<=s;c++)o+=r.get(c,s+1)*r.get(c,a);for(c=0;c<=s;c++)r.set(c,a,r.get(c,a)-o*n[c])}}for(c=0;c<=s;c++)r.set(c,s+1,0)}for(a=0;a<t;a++)n[a]=r.get(t-1,a),r.set(t-1,a,0);r.set(t-1,t-1,1),e[0]=0}(o,a,s,A),function(t,e,n,r){let i,o,A,s,a,c,l,u,h,d,f,g,p,v,m,y;for(A=1;A<t;A++)e[A-1]=e[A];e[t-1]=0;let w=0,b=0,B=Number.EPSILON;for(c=0;c<t;c++){for(b=Math.max(b,Math.abs(n[c])+Math.abs(e[c])),l=c;l<t&&!(Math.abs(e[l])<=B*b);)l++;if(l>c)do{for(i=n[c],u=(n[c+1]-i)/(2*e[c]),h=k(u,1),u<0&&(h=-h),n[c]=e[c]/(u+h),n[c+1]=e[c]*(u+h),d=n[c+1],o=i-n[c],A=c+2;A<t;A++)n[A]-=o;for(w+=o,u=n[l],f=1,g=f,p=f,v=e[c+1],m=0,y=0,A=l-1;A>=c;A--)for(p=g,g=f,y=m,i=f*e[A],o=f*u,h=k(u,e[A]),e[A+1]=m*h,m=e[A]/h,f=u/h,u=f*n[A]-m*i,n[A+1]=o+m*(f*i+m*n[A]),a=0;a<t;a++)o=r.get(a,A+1),r.set(a,A+1,m*r.get(a,A)+f*o),r.set(a,A,f*r.get(a,A)-m*o);u=-m*y*p*v*e[c]/d,e[c]=m*u,n[c]=f*u}while(Math.abs(e[c])>B*b);n[c]=n[c]+w,e[c]=0}for(A=0;A<t-1;A++){for(a=A,u=n[A],s=A+1;s<t;s++)n[s]<u&&(a=s,u=n[s]);if(a!==A)for(n[a]=n[A],n[A]=u,s=0;s<t;s++)u=r.get(s,A),r.set(s,A,r.get(s,a)),r.set(s,a,u)}}(o,a,s,A)}else{let t=new w(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,A,s,a,c,l,u=0,h=t-1;for(c=u+1;c<=h-1;c++){for(l=0,s=c;s<=h;s++)l+=Math.abs(e.get(s,c-1));if(0!==l){for(A=0,s=h;s>=c;s--)n[s]=e.get(s,c-1)/l,A+=n[s]*n[s];for(o=Math.sqrt(A),n[c]>0&&(o=-o),A-=n[c]*o,n[c]=n[c]-o,a=c;a<t;a++){for(i=0,s=h;s>=c;s--)i+=n[s]*e.get(s,a);for(i/=A,s=c;s<=h;s++)e.set(s,a,e.get(s,a)-i*n[s])}for(s=0;s<=h;s++){for(i=0,a=h;a>=c;a--)i+=n[a]*e.get(s,a);for(i/=A,a=c;a<=h;a++)e.set(s,a,e.get(s,a)-i*n[a])}n[c]=l*n[c],e.set(c,c-1,l*o)}}for(s=0;s<t;s++)for(a=0;a<t;a++)r.set(s,a,s===a?1:0);for(c=h-1;c>=u+1;c--)if(0!==e.get(c,c-1)){for(s=c+1;s<=h;s++)n[s]=e.get(s,c-1);for(a=c;a<=h;a++){for(o=0,s=c;s<=h;s++)o+=n[s]*r.get(s,a);for(o=o/n[c]/e.get(c,c-1),s=c;s<=h;s++)r.set(s,a,r.get(s,a)+o*n[s])}}}(o,t,e,A),function(t,e,n,r,i){let o,A,s,a,c,l,u,h,d,f,g,p,v,m,y,w=t-1,b=0,B=t-1,E=Number.EPSILON,x=0,C=0,M=0,F=0,k=0,S=0,Q=0,U=0;for(o=0;o<t;o++)for((o<b||o>B)&&(n[o]=i.get(o,o),e[o]=0),A=Math.max(o-1,0);A<t;A++)C+=Math.abs(i.get(o,A));for(;w>=b;){for(a=w;a>b&&(S=Math.abs(i.get(a-1,a-1))+Math.abs(i.get(a,a)),0===S&&(S=C),!(Math.abs(i.get(a,a-1))<E*S));)a--;if(a===w)i.set(w,w,i.get(w,w)+x),n[w]=i.get(w,w),e[w]=0,w--,U=0;else if(a===w-1){if(u=i.get(w,w-1)*i.get(w-1,w),M=(i.get(w-1,w-1)-i.get(w,w))/2,F=M*M+u,Q=Math.sqrt(Math.abs(F)),i.set(w,w,i.get(w,w)+x),i.set(w-1,w-1,i.get(w-1,w-1)+x),h=i.get(w,w),F>=0){for(Q=M>=0?M+Q:M-Q,n[w-1]=h+Q,n[w]=n[w-1],0!==Q&&(n[w]=h-u/Q),e[w-1]=0,e[w]=0,h=i.get(w,w-1),S=Math.abs(h)+Math.abs(Q),M=h/S,F=Q/S,k=Math.sqrt(M*M+F*F),M/=k,F/=k,A=w-1;A<t;A++)Q=i.get(w-1,A),i.set(w-1,A,F*Q+M*i.get(w,A)),i.set(w,A,F*i.get(w,A)-M*Q);for(o=0;o<=w;o++)Q=i.get(o,w-1),i.set(o,w-1,F*Q+M*i.get(o,w)),i.set(o,w,F*i.get(o,w)-M*Q);for(o=b;o<=B;o++)Q=r.get(o,w-1),r.set(o,w-1,F*Q+M*r.get(o,w)),r.set(o,w,F*r.get(o,w)-M*Q)}else n[w-1]=h+M,n[w]=h+M,e[w-1]=Q,e[w]=-Q;w-=2,U=0}else{if(h=i.get(w,w),d=0,u=0,a<w&&(d=i.get(w-1,w-1),u=i.get(w,w-1)*i.get(w-1,w)),10===U){for(x+=h,o=b;o<=w;o++)i.set(o,o,i.get(o,o)-h);S=Math.abs(i.get(w,w-1))+Math.abs(i.get(w-1,w-2)),h=d=.75*S,u=-.4375*S*S}if(30===U&&(S=(d-h)/2,S=S*S+u,S>0)){for(S=Math.sqrt(S),d<h&&(S=-S),S=h-u/((d-h)/2+S),o=b;o<=w;o++)i.set(o,o,i.get(o,o)-S);x+=S,h=d=u=.964}for(U+=1,c=w-2;c>=a&&(Q=i.get(c,c),k=h-Q,S=d-Q,M=(k*S-u)/i.get(c+1,c)+i.get(c,c+1),F=i.get(c+1,c+1)-Q-k-S,k=i.get(c+2,c+1),S=Math.abs(M)+Math.abs(F)+Math.abs(k),M/=S,F/=S,k/=S,c!==a)&&!(Math.abs(i.get(c,c-1))*(Math.abs(F)+Math.abs(k))<E*(Math.abs(M)*(Math.abs(i.get(c-1,c-1))+Math.abs(Q)+Math.abs(i.get(c+1,c+1)))));)c--;for(o=c+2;o<=w;o++)i.set(o,o-2,0),o>c+2&&i.set(o,o-3,0);for(s=c;s<=w-1&&(m=s!==w-1,s!==c&&(M=i.get(s,s-1),F=i.get(s+1,s-1),k=m?i.get(s+2,s-1):0,h=Math.abs(M)+Math.abs(F)+Math.abs(k),0!==h&&(M/=h,F/=h,k/=h)),0!==h);s++)if(S=Math.sqrt(M*M+F*F+k*k),M<0&&(S=-S),0!==S){for(s!==c?i.set(s,s-1,-S*h):a!==c&&i.set(s,s-1,-i.get(s,s-1)),M+=S,h=M/S,d=F/S,Q=k/S,F/=M,k/=M,A=s;A<t;A++)M=i.get(s,A)+F*i.get(s+1,A),m&&(M+=k*i.get(s+2,A),i.set(s+2,A,i.get(s+2,A)-M*Q)),i.set(s,A,i.get(s,A)-M*h),i.set(s+1,A,i.get(s+1,A)-M*d);for(o=0;o<=Math.min(w,s+3);o++)M=h*i.get(o,s)+d*i.get(o,s+1),m&&(M+=Q*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-M*k)),i.set(o,s,i.get(o,s)-M),i.set(o,s+1,i.get(o,s+1)-M*F);for(o=b;o<=B;o++)M=h*r.get(o,s)+d*r.get(o,s+1),m&&(M+=Q*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-M*k)),r.set(o,s,r.get(o,s)-M),r.set(o,s+1,r.get(o,s+1)-M*F)}}}if(0===C)return;for(w=t-1;w>=0;w--)if(M=n[w],F=e[w],0===F)for(a=w,i.set(w,w,1),o=w-1;o>=0;o--){for(u=i.get(o,o)-M,k=0,A=a;A<=w;A++)k+=i.get(o,A)*i.get(A,w);if(e[o]<0)Q=u,S=k;else if(a=o,0===e[o]?i.set(o,w,0!==u?-k/u:-k/(E*C)):(h=i.get(o,o+1),d=i.get(o+1,o),F=(n[o]-M)*(n[o]-M)+e[o]*e[o],l=(h*S-Q*k)/F,i.set(o,w,l),i.set(o+1,w,Math.abs(h)>Math.abs(Q)?(-k-u*l)/h:(-S-d*l)/Q)),l=Math.abs(i.get(o,w)),E*l*l>1)for(A=o;A<=w;A++)i.set(A,w,i.get(A,w)/l)}else if(F<0)for(a=w-1,Math.abs(i.get(w,w-1))>Math.abs(i.get(w-1,w))?(i.set(w-1,w-1,F/i.get(w,w-1)),i.set(w-1,w,-(i.get(w,w)-M)/i.get(w,w-1))):(y=I(0,-i.get(w-1,w),i.get(w-1,w-1)-M,F),i.set(w-1,w-1,y[0]),i.set(w-1,w,y[1])),i.set(w,w-1,0),i.set(w,w,1),o=w-2;o>=0;o--){for(f=0,g=0,A=a;A<=w;A++)f+=i.get(o,A)*i.get(A,w-1),g+=i.get(o,A)*i.get(A,w);if(u=i.get(o,o)-M,e[o]<0)Q=u,k=f,S=g;else if(a=o,0===e[o]?(y=I(-f,-g,u,F),i.set(o,w-1,y[0]),i.set(o,w,y[1])):(h=i.get(o,o+1),d=i.get(o+1,o),p=(n[o]-M)*(n[o]-M)+e[o]*e[o]-F*F,v=2*(n[o]-M)*F,0===p&&0===v&&(p=E*C*(Math.abs(u)+Math.abs(F)+Math.abs(h)+Math.abs(d)+Math.abs(Q))),y=I(h*k-Q*f+F*g,h*S-Q*g-F*f,p,v),i.set(o,w-1,y[0]),i.set(o,w,y[1]),Math.abs(h)>Math.abs(Q)+Math.abs(F)?(i.set(o+1,w-1,(-f-u*i.get(o,w-1)+F*i.get(o,w))/h),i.set(o+1,w,(-g-u*i.get(o,w)-F*i.get(o,w-1))/h)):(y=I(-k-d*i.get(o,w-1),-S-d*i.get(o,w),Q,F),i.set(o+1,w-1,y[0]),i.set(o+1,w,y[1]))),l=Math.max(Math.abs(i.get(o,w-1)),Math.abs(i.get(o,w))),E*l*l>1)for(A=o;A<=w;A++)i.set(A,w-1,i.get(A,w-1)/l),i.set(A,w,i.get(A,w)/l)}for(o=0;o<t;o++)if(o<b||o>B)for(A=o;A<t;A++)r.set(o,A,i.get(o,A));for(A=t-1;A>=b;A--)for(o=b;o<=B;o++){for(Q=0,s=b;s<=Math.min(A,B);s++)Q+=r.get(o,s)*i.get(s,A);r.set(o,A,Q)}}(o,a,s,A,t)}this.n=o,this.e=a,this.d=s,this.V=A}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new w(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function I(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class L{constructor(t){if(!(t=M.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,A=new w(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=A.get(r,e)*A.get(n,e);o=(i.get(n,r)-o)/A.get(r,r),A.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&&=t>0,A.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)A.set(n,r,0)}this.L=A,this.positiveDefinite=s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=M.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,A=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<A;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<A;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class P{constructor(e,n={}){e=M.checkMatrix(e);let{Y:r}=n;const{scaleScores:i=!1,maxIterations:o=1e3,terminationCriteria:A=1e-10}=n;let s;if(r){if(r=t.isAnyArray(r)&&"number"==typeof r[0]?w.columnVector(r):M.checkMatrix(r),r.rows!==e.rows)throw new Error("Y should have the same number of rows as X");s=r.getColumnVector(0)}else s=e.getColumnVector(0);let a,c,l,u,h=1;for(let t=0;t<o&&h>A;t++)l=e.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=e.mmul(l).div(l.transpose().mmul(l).get(0,0)),t>0&&(h=a.clone().sub(u).pow(2).sum()),u=a.clone(),r?(c=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),s=r.mmul(c).div(c.transpose().mmul(c).get(0,0))):s=a;if(r){let t=e.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));t=t.div(t.norm());let n=e.clone().sub(a.clone().mmul(t.transpose())),i=s.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),o=r.clone().sub(a.clone().mulS(i.get(0,0)).mmul(c.transpose()));this.t=a,this.p=t.transpose(),this.w=l.transpose(),this.q=c,this.u=s,this.s=a.transpose().mmul(a),this.xResidual=n,this.yResidual=o,this.betas=i}else this.w=l.transpose(),this.s=a.transpose().mmul(a).sqrt(),this.t=i?a.clone().div(this.s.get(0,0)):a,this.xResidual=e.sub(a.mmul(l.transpose()))}}return hj.AbstractMatrix=v,hj.CHO=L,hj.CholeskyDecomposition=L,hj.DistanceMatrix=B,hj.EVD=O,hj.EigenvalueDecomposition=O,hj.LU=F,hj.LuDecomposition=F,hj.Matrix=w,hj.MatrixColumnSelectionView=class extends E{constructor(t,e){h(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},hj.MatrixColumnView=class extends E{constructor(t,e){a(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},hj.MatrixFlipColumnView=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},hj.MatrixFlipRowView=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},hj.MatrixRowSelectionView=class extends E{constructor(t,e){u(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},hj.MatrixRowView=class extends E{constructor(t,e){s(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},hj.MatrixSelectionView=x,hj.MatrixSubView=class extends E{constructor(t,e,n,r,i){d(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},hj.MatrixTransposeView=class extends E{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},hj.NIPALS=P,hj.Nipals=P,hj.QR=S,hj.QrDecomposition=S,hj.SVD=Q,hj.SingularValueDecomposition=Q,hj.SymmetricMatrix=b,hj.WrapperMatrix1D=C,hj.WrapperMatrix2D=M,hj.correlation=function(e,n=e,r={}){e=new w(e);let i=!1;if("object"!=typeof n||w.isMatrix(n)||t.isAnyArray(n)?n=new w(n):(r=n,n=e,i=!0),e.rows!==n.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:o=!0,scale:A=!0}=r;o&&(e.center("column"),i||n.center("column")),A&&(e.scale("column"),i||n.scale("column"));const s=e.standardDeviation("column",{unbiased:!0}),a=i?s:n.standardDeviation("column",{unbiased:!0}),c=e.transpose().mmul(n);for(let t=0;t<c.rows;t++)for(let n=0;n<c.columns;n++)c.set(t,n,c.get(t,n)*(1/(s[t]*a[n]))*(1/(e.rows-1)));return c},hj.covariance=function(e,n=e,r={}){e=new w(e);let i=!1;if("object"!=typeof n||w.isMatrix(n)||t.isAnyArray(n)?n=new w(n):(r=n,n=e,i=!0),e.rows!==n.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:o=!0}=r;o&&(e=e.center("column"),i||(n=n.center("column")));const A=e.transpose().mmul(n);for(let t=0;t<A.rows;t++)for(let n=0;n<A.columns;n++)A.set(t,n,A.get(t,n)*(1/(e.rows-1)));return A},hj.default=w,hj.determinant=function t(e){if((e=w.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,A,s;return o=new x(e,[1,2],[1,2]),A=new x(e,[1,2],[0,2]),s=new x(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(A)+i*t(s)}return new F(e).determinant}throw Error("determinant can only be calculated for a square matrix")},hj.inverse=function(t,e=!1){return t=M.checkMatrix(t),e?new Q(t).inverse():U(t,w.eye(t.rows))},hj.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=w.checkMatrix(t)).rows,o=new w(i,i);for(let e=0;e<i;e++){let A=w.columnVector(t.getRow(e)),s=t.subMatrixRow(N(i,e)).transpose(),a=new Q(s).solve(A),c=w.sub(A,s.mmul(a)).abs().max();o.setRow(e,T(c,a,e,n,r))}return o},hj.pseudoInverse=function(t,e=Number.EPSILON){if((t=w.checkMatrix(t)).isEmpty())return t.transpose();let n=new Q(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(w.diag(o).mmul(r.transpose()))},hj.solve=U,hj.wrap=function(e,n){if(t.isAnyArray(e))return e[0]&&t.isAnyArray(e[0])?new M(e):new C(e,n);throw new Error("the argument is not an array")},hj}var wj=yj(),bj=wU(wj);const Bj=wj.Matrix,Ej=wj.SingularValueDecomposition;bj.Matrix?bj.Matrix:wj.Matrix;const xj=(t,e)=>{const n=t.nodeCount(),r=Array.from({length:n},()=>[]),i={};let o=0;return t.forEachNode(t=>{i[t.id]=o++}),t.forEachEdge(t=>{const e=i[t.source],n=i[t.target];null!=e&&null!=n&&(r[e].push(n),r[n].push(e))}),r};function Cj(t){const e=t.length;new Array(e).fill(0);const n=Array.from({length:e},()=>new Array(e).fill(1/0));for(let r=0;r<e;r++)n[r]=Mj(t,r);return n}function Mj(t,e){const n=t.length,r=new Array(n).fill(1/0);r[e]=0;const i=new Fj;for(i.push([0,e]);!i.empty();){const[e,n]=i.pop();if(e!==r[n])continue;const o=t[n];for(let t=0;t<o.length;t++){const n=o[t],A=e+1;A<r[n]&&(r[n]=A,i.push([A,n]))}}return r}class Fj{constructor(){this.data=[]}push(t){this.data.push(t),this.bubbleUp(this.data.length-1)}pop(){const t=this.data[0],e=this.data.pop();return this.data.length>0&&(this.data[0]=e,this.bubbleDown(0)),t}empty(){return 0===this.data.length}bubbleUp(t){const e=this.data;for(;t>0;){const n=t-1>>1;if(e[n][0]<=e[t][0])break;[e[n],e[t]]=[e[t],e[n]],t=n}}bubbleDown(t){const e=this.data,n=e.length;for(;;){const r=2*t+1,i=2*t+2;let o=t;if(r<n&&e[r][0]<e[o][0]&&(o=r),i<n&&e[i][0]<e[o][0]&&(o=i),o===t)break;[e[t],e[o]]=[e[o],e[t]],t=o}}}const kj={center:[0,0],linkDistance:50};class Sj extends bC{constructor(){super(...arguments),this.id="mds"}getDefaultOptions(){return kj}layout(){return px(this,0,void 0,function*(){const{linkDistance:t=kj.linkDistance}=this.options,{center:e}=MF(this.options),n=this.model.nodeCount();if(0===n||1===n)return void bF(this.model,e);const r=Cj(xj(this.model));Qj(r);const i=((t,e)=>{const n=t.length,r=new Array(n);for(let i=0;i<n;i++){const n=t[i],o=n.length,A=new Array(o);for(let t=0;t<o;t++)A[t]=n[t]*e;r[i]=A}return r})(r,t),o=Uj(i);let A=0;this.model.forEachNode(t=>{const n=o[A++];t.x=n[0]+e[0],t.y=n[1]+e[1]})})}}const Qj=t=>{let e=Number.NEGATIVE_INFINITY;const n=[],r=t.length;for(let i=0;i<r;i++){const r=t[i],o=r.length;for(let t=0;t<o;t++){const o=r[t];o===1/0?n.push([i,t]):e<o&&(e=o)}}for(let r=0;r<n.length;r++){const[i,o]=n[r];t[i][o]=e}},Uj=(t,e=2,n=kj.linkDistance)=>{try{const n=t.length,r=new Bj(n,n);for(let e=0;e<n;e++)for(let i=0;i<n;i++){const n=t[e][i];r.set(e,i,-.5*n*n)}const i=r.mean("row"),o=r.mean("column"),A=r.mean();r.add(A).subRowVector(i).subColumnVector(o);const s=new Ej(r),a=Bj.sqrt(s.diagonalMatrix).diagonal(),c=s.leftSingularVectors,l=a,u=[];for(let t=0;t<c.rows;t++){const n=[];for(let r=0;r<e;r++)n.push(c.get(t,r)*l[r]);u.push(n)}return u}catch(e){const r=[];for(let e=0;e<t.length;e++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}},Nj={maxIteration:10,width:10,speed:100,gravity:10,k:5},Tj=(t,e,n,r,i)=>{let o=0;t.forEachNode(A=>{let s=0;t.forEachNode(t=>{if(s<=o)return void s++;if(A.id===t.id)return;if(r.get(A.id)!==r.get(t.id))return;let a=A.x-t.x,c=A.y-t.y,l=Math.sqrt(a*a+c*c);if(0===l){l=1;const t=o>s?1:-1;a=.01*t,c=.01*t}const u=Math.max(...i(A._original));if(l<Math.max(...i(t._original))/2+u/2){const r=n*n/l,i=e.get(A.id),o=e.get(t.id),s=a/l*r,u=c/l*r;e.set(A.id,{x:i.x+s,y:i.y+u}),e.set(t.id,{x:o.x-s,y:o.y-u})}s++}),o++})},Oj=(t,e,n,r,i,o,A)=>{r&&t.forEachNode(t=>{const n=t.x-i.x,r=t.y-i.y,o=Math.sqrt(n*n+r*r);let A=r/o,s=-n/o;const a=e.get(t.id),c=Math.sqrt(a.x*a.x+a.y*a.y);let l=Math.acos((A*a.x+s*a.y)/c);l>Math.PI/2&&(l-=Math.PI/2,A*=-1,s*=-1);const u=Math.cos(l)*c;e.set(t.id,{x:A*u,y:s*u})});let s=0,a=0;return t.forEachNode(t=>{if(t.id===i.id)return;const c=e.get(t.id),l=Math.sqrt(c.x*c.x+c.y*c.y);if(l>0){const e=Math.min(o*(n/800),l);if(t.x+=c.x/l*e,t.y+=c.y/l*e,r){let e=t.x-i.x,n=t.y-i.y;const r=Math.sqrt(e*e+n*n);e=e/r*A.get(t.id),n=n/r*A.get(t.id),t.x=i.x+e,t.y=i.y+n}s+=e,a++}}),a>0?s/a:0},Ij={focusNode:null,linkDistance:50,maxIteration:1e3,maxPreventOverlapIteration:200,preventOverlap:!1,sortStrength:10,strictRadial:!0,unitRadius:null,nodeSize:10,nodeSpacing:0};class Lj extends bC{constructor(){super(...arguments),this.id="radial"}getDefaultOptions(){return Ij}layout(){return px(this,0,void 0,function*(){const{width:t,height:e,center:n}=MF(this.options),r=this.model.nodeCount();if(!r||1===r)return bF(this.model,n);const{focusNode:i,linkDistance:o=Ij.linkDistance,maxIteration:A=Ij.maxIteration,maxPreventOverlapIteration:s=Ij.maxPreventOverlapIteration,nodeSize:a,nodeSpacing:c,preventOverlap:l,sortBy:u,sortStrength:h=Ij.sortStrength,strictRadial:d,unitRadius:f}=this.options,g=i&&this.model.node(i)||this.model.firstNode(),p=this.model.nodeIndexOf(g.id),v=Cj(xj(this.model)),m=Hj(v,p);Rj(v,p,m+1);const y=v[p],w=(t-n[0]>n[0]?n[0]:t-n[0])||t/2,b=(e-n[1]>n[1]?n[1]:e-n[1])||e/2,B=Math.min(w,b),E=Math.max(...y),x=[],C=new Map,M=null!=f?f:B/E;y.forEach((t,e)=>{const n=t*M;x.push(n),C.set(this.model.nodeAt(e).id,n)});const F=Pj(this.model,v,o,x,M,u,h),k=Uj(F,2,o),S=k[p];let Q=0;if(this.model.forEachNode(t=>{const e=k[Q];t.x=e[0]-S[0],t.y=e[1]-S[1],Q++}),this.run(A,F,x,p),this.model.forEachNode(t=>{t.x+=n[0],t.y+=n[1]}),l){const e={nodeSizeFunc:Wx(a,c,Ij.nodeSize,Ij.nodeSpacing),radiiMap:C,width:t,strictRadial:Boolean(d),focusNode:g,maxIteration:s,k:r/4.5};((t,e)=>{const n=Object.assign(Object.assign({},Nj),e),{maxIteration:r,width:i,k:o,speed:A=Nj.speed,strictRadial:s,focusNode:a,radiiMap:c,nodeSizeFunc:l}=n,u=.002*o,h=new Map,d=i/10;for(let e=0;e<r&&(t.forEachNode(t=>{h.set(t.id,{x:0,y:0})}),Tj(t,h,o,c,l),!(Oj(t,h,A,s,a,d,c)<u));e++);})(this.model,e)}})}run(t,e,n,r){const i=Dj(e),o=this.model.nodeCount(),A=this.model.nodes(),s=new Float64Array(o),a=new Float64Array(o);for(let t=0;t<o;t++)s[t]=A[t].x,a[t]=A[t].y;for(let c=0;c<=t;c++){const l=c/t,u=1-l;for(let t=0;t<o;t++){if(t===r)continue;const c=s[t],h=a[t],d=Math.sqrt(c*c+h*h),f=0===d?0:1/d;let g=0,p=0,v=0;for(let n=0;n<o;n++){if(t===n)continue;const r=s[n],o=a[n],A=Math.sqrt((c-r)*(c-r)+(h-o)*(h-o)),l=0===A?0:1/A,u=e[n][t];v+=i[t][n],g+=i[t][n]*(r+u*(c-r)*l),p+=i[t][n]*(o+u*(h-o)*l)}const m=0===n[t]?0:1/n[t];v*=u,v+=l*m*m,g*=u,g+=l*m*c*f,p*=u,p+=l*m*h*f,s[t]=g/v,a[t]=p/v,A[t].x=s[t],A[t].y=a[t]}}}}const Pj=(t,e,n,r,i,o,A)=>{const s=e.length,a=new Array(s),c=new Array(s);for(let t=0;t<s;t++)c[t]=r[t]/i;const l=(n+i)/2,u=new Map,h=o&&"data"!==o?jx(o,["node"]):null,d="data"===o;for(let i=0;i<s;i++){const o=e[i],f=new Array(s);a[i]=f;const g=c[i]||1;for(let e=0;e<s;e++){if(i===e){f[e]=0;continue}const s=o[e];if(r[i]===r[e])if(d)f[e]=s*Math.abs(i-e)*A/g;else if(h){const n=t.nodeAt(i),r=t.nodeAt(e);let o=u.get(n.id);if(void 0===o){const t=h(n._original)||0;o="string"==typeof t?t.charCodeAt(0):Number(t||0),u.set(n.id,o)}let a=u.get(r.id);if(void 0===a){const t=h(r._original)||0;a="string"==typeof t?t.charCodeAt(0):Number(t||0),u.set(r.id,a)}f[e]=s*Math.abs(o-a)*A/g}else f[e]=s*n/g;else f[e]=s*l}}return a},Dj=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},Rj=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},Hj=(t,e)=>{const n=t[e];let r=0;for(let t=0;t<n.length;t++)n[t]!==1/0&&(r=Math.max(r,n[t]));return r};class _j extends bC{constructor(){super(...arguments),this.id="random"}getDefaultOptions(){return{center:[0,0],width:300,height:300}}layout(){return px(this,0,void 0,function*(){const{width:t,height:e,center:n}=MF(this.options);this.model.forEachNode(r=>{r.x=Gj(t)+n[0],r.y=Gj(e)+n[1]})})}}const Gj=t=>.9*(Math.random()-.5)*t,Kj={"antv-dagre":yF,"d3-force-3d":class extends Nk{constructor(){super(...arguments),this.id="d3-force-3d",this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:mS,manyBody:gS,center:sS,collide:AS,radial:Dk,x:Pk,y:Lk,z:Ik}}getDefaultOptions(){return{numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return fS()}setupForces(t,e){Object.entries(this.forceMap).forEach(([n,r])=>{const i=n;if(e[n]){let n=t.force(i);n||(n=r(),t.force(i,n)),Tk(n,Object.entries(e[i]))}else t.force(i,null)})}},"d3-force":Nk,"force-atlas2":tj,circular:kF,concentric:QF,dagre:OK,force:YK,fruchterman:rj,grid:oj,mds:Sj,radial:Lj,random:_j},jj={layout:t=>t?{type:"concentric",preventOverlap:!0}:{type:"force",preventOverlap:!0},nodeSize:20,nodeSpacing:0,comboPadding:10,comboSpacing:0},zj="root";class Vj extends bC{constructor(){super(...arguments),this.id="combo-combined",this.relativePositions=new Map,this.getParentId=t=>t.parentId||zj}getDefaultOptions(){return jj}layout(){return px(this,0,void 0,function*(){const{center:t}=MF(this.options);this.resetLayoutState();const e=this.buildHierarchyTree();yield this.layoutHierarchy(e),this.convertToGlobalPositions(e,t),this.applyPositionsToModel(e)})}isCombo(t){return Boolean(t.isCombo)}resetLayoutState(){this.relativePositions.clear()}layoutHierarchy(t){return px(this,0,void 0,function*(){for(const e of t.children||[])this.isCombo(e)&&(yield this.layoutHierarchy(e));const e=t.children||[];if(0===e.length)return t.size=[0,0,0],void(t.parentId=t.id===zj?null:t.parentId);const n=this.getLayoutConfig(t),{type:r}=n,i=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(n,["type"]),o=new(this.getLayoutClass(r))(i),A=this.createTemporaryGraphData(e);yield function(t,e,n={}){var r;return px(this,0,void 0,function*(){return EC(t)?(t.execute(e,n),t.stop(),t.tick(null!==(r=n.iterations)&&void 0!==r?r:300)):yield t.execute(e,n)})}(o,A,{});const s=o.model.nodes();this.recordRelativePositions(s,t);const{center:a,width:c,height:l}=this.calculateComboBounds(t);t.size=[c,l,0],(t.children||[]).forEach(t=>{const e=this.relativePositions.get(t.id);if(!e)return;const n=Object.assign(Object.assign({},e),{x:e.x-a[0],y:e.y-a[1]});this.relativePositions.set(t.id,n)})})}recordRelativePositions(t,e){const n=this.calculateComboCenter(t);t.forEach(t=>{this.relativePositions.set(t.id,{x:t.x-n[0],y:t.y-n[1],relativeTo:String(e.id)})})}buildHierarchyTree(){const t={id:zj,isCombo:!0,children:[],parentId:null},e=new Map;return e.set(zj,t),this.model.forEachNode(t=>{if(this.isCombo(t)){const n=Object.assign(Object.assign({},t),{children:[],parentId:this.getParentId(t)});e.set(String(t.id),n)}}),this.model.forEachNode(t=>{const n=e.get(this.getParentId(t));if(this.isCombo(t)){const r=e.get(String(t.id));n&&r&&(n.children.push(r),r.parentId=n.id)}else n&&n.children.push(Object.assign(Object.assign({},t),{children:[],parentId:this.getParentId(t)}))}),t}convertToGlobalPositions(t,e){var n,r;const i=t.id===zj?null:this.relativePositions.get(t.id),o=e[0]+(null!==(n=null==i?void 0:i.x)&&void 0!==n?n:0),A=e[1]+(null!==(r=null==i?void 0:i.y)&&void 0!==r?r:0);t.x=o,t.y=A,(t.children||[]).forEach(t=>{var e,n;const r=this.relativePositions.get(t.id);t.x=o+(null!==(e=null==r?void 0:r.x)&&void 0!==e?e:0),t.y=A+(null!==(n=null==r?void 0:r.y)&&void 0!==n?n:0),t.size=this.getNodeLikeSize(t,!1),this.isCombo(t)&&this.convertToGlobalPositions(t,[o,A])})}getLayoutConfig(t){const e="object"==typeof this.options.layout?this.options.layout:jx(this.options.layout,["comboId"]);if("function"==typeof e){const n=t.id===zj?null:t.id;return this.normalizeLayoutConfig(e(n))}return this.normalizeLayoutConfig(e)}normalizeLayoutConfig(t){const e=Object.assign(Object.assign({type:"concentric"},MF(this.options)),{nodeSize:"node.size",nodeSpacing:0});return t?"string"==typeof t?Object.assign(Object.assign({},e),{type:t}):Object.assign(Object.assign({},e),t):e}getLayoutClass(t){return Kj[t]||Kj.concentric}createTemporaryGraphData(t){const e=t.map(t=>Object.assign(Object.assign({},t),{size:this.getNodeLikeSize(t)})),n=new Set(t.map(t=>String(t.id))),r=[],i=t=>{let e=String(t);const r=new Set;for(;e&&!r.has(e);){if(n.has(e))return e;r.add(e);const t=this.model.node(e),i=null==t?void 0:t.parentId;e=null==i?null:String(i)}return null};return this.model.forEachEdge(t=>{const e=i(String(t.source)),n=i(String(t.target));e&&n&&e!==n&&r.push({source:e,target:n})}),{nodes:e,edges:r}}calculateComboCenter(t){if(0===t.length)return[0,0];const e=new Map;t.forEach(t=>{const n=this.getNodeLikeSize(t);e.set(t.id,n)});let n=1/0,r=1/0,i=-1/0,o=-1/0;return t.forEach(t=>{const[A=0,s=0]=e.get(t.id);n=Math.min(n,t.x-A/2),r=Math.min(r,t.y-s/2),i=Math.max(i,t.x+A/2),o=Math.max(o,t.y+s/2)}),Number.isFinite(n)&&Number.isFinite(r)?[(n+i)/2,(r+o)/2]:[0,0]}calculateComboBounds(t){const e=t.children||[];if(0===e.length)return{center:[0,0],width:0,height:0};let n=1/0,r=1/0,i=-1/0,o=-1/0;if(e.forEach(t=>{var e,A;const s=this.relativePositions.get(t.id),a=null!==(e=null==s?void 0:s.x)&&void 0!==e?e:0,c=null!==(A=null==s?void 0:s.y)&&void 0!==A?A:0,[l,u]=this.getNodeLikeSize(t);n=Math.min(n,a-l/2),r=Math.min(r,c-u/2),i=Math.max(i,a+l/2),o=Math.max(o,c+u/2)}),!Number.isFinite(n)||!Number.isFinite(r))return{center:[0,0],width:0,height:0};const A=zx(this.options.comboPadding,20,"combo")(t._original);return{center:[(n+i)/2,(r+o)/2],width:i-n+2*A,height:o-r+2*A}}getNodeLikeSize(t,e=!0){return this.isCombo(t)?this.getComboSize(t,e):this.getNodeSize(t,e)}getNodeSize(t,e=!0){const{nodeSize:n,nodeSpacing:r}=this.options;return Wx(n,e?r:0)(t._original)}getComboSize(t,e=!0){const n=zx(this.options.comboSpacing,0,"combo"),r=e?n(t._original):0,[i,o]=t.size;return[i+r/2,o+r/2,0]}applyPositionsToModel(t){const e=t=>{const e=this.model.node(t.id);e&&(e.x=t.x,e.y=t.y,t.size&&(e.size=t.size))},n=t=>{t.id!==zj&&e(t),(t.children||[]).forEach(t=>{this.isCombo(t)?n(t):e(t)})};n(t)}}class Wj extends pE{constructor(){super(...arguments),this.id="fishbone"}getRoot(){const t=this.context.model.getRootsData();if(!(Ee(t)||t.length>2))return t[0]}formatSize(t){const e="function"==typeof t?t:()=>t;return t=>cw(e(t))}doLayout(t,e){const{hGap:n,getRibSep:r,vGap:i,nodeSize:o,height:A}=e,{model:s}=this.context,a=this.formatSize(o);let c=a(t)[0]+r(t);const l=(t,e=0)=>{var r;return e+=n*((t.children||[]).length+1),null===(r=t.children)||void 0===r||r.forEach(t=>{var n;null===(n=s.getNodeLikeDatum(t).children)||void 0===n||n.forEach(t=>{const n=s.getNodeLikeDatum(t);e=l(n,e)})}),e},u=t=>{if(1===t.depth)return c;const e=s.getParentData(t.id,"tree");if(qj(t)){const r=s.getParentData(e.id,"tree"),o=f(t)-f(r);return u(e)+o*n/i}{const n=(e.children||[]).indexOf(t.id),r=s.getNodeData((e.children||[]).slice(n));return h(e)-r.reduce((t,e)=>t+l(e),0)-a(e)[0]/2}},h=me(t=>{if(Xj(t))return a(t)[0]/2;const e=s.getParentData(t.id,"tree");if(qj(t))return u(t)+l(t)+a(t)[0]/2;{const r=f(t)-f(e),o=n/i;return u(t)+r*o}},t=>t.id),d=t=>f(s.getParentData(t,"tree")),f=me(t=>{if(Xj(t))return A/2;if(qj(t)){const e=s.getParentData(t.id,"tree"),n=e.children.indexOf(t.id);if(0===n)return d(e.id)+i;const r=s.getNodeLikeDatum(e.children[n-1]);if(Ee(r.children))return f(r)+i;const o=s.getDescendantsData(r.id);return Math.max(...o.map(t=>qj(t)?d(t.id):f(t)))+i}{if(Ee(t.children))return d(t.id)+i;const e=s.getNodeLikeDatum(t.children.slice(-1)[0]);if(Ee(e.children))return f(e)+i;const n=s.getDescendantsData(t.id).slice(-1)[0];return(qj(n)?d(n.id):f(n))+i}},t=>t.id);let g=0;const p={nodes:[],edges:[]},v=t=>{var e;null===(e=t.children)||void 0===e||e.forEach(t=>v(s.getNodeLikeDatum(t)));const n=f(t),i=h(t);if(p.nodes.push({id:t.id,x:i,y:n}),Xj(t))return;const o=s.getRelatedEdgesData(t.id,"in")[0],A=[u(t),qj(t)?n:d(t.id)];p.edges.push({id:Km(o),controlPoints:[A],relatedNodeId:t.id}),g=Math.max(g,i+r(t)),1===t.depth&&(c=g)};return v(t),p}placeAlterative(t,e){const n=(e.children||[]).filter((t,e)=>e%2!=0);if(0===n.length)return t;const{model:r}=this.context,i=t.nodes.find(t=>t.id===e.id).y,o=t=>{const e=r.getAncestorsData(t,"tree");if(Ee(e))return!1;const i=1===e.length?t:e[e.length-2].id;return n.includes(i)};t.nodes.forEach(t=>{o(t.id)&&(t.y=2*i-t.y)}),t.edges.forEach(t=>{o(t.relatedNodeId)&&(t.controlPoints=t.controlPoints.map(t=>[t[0],2*i-t[1]]))})}rightToLeft(t,e){return t.nodes.forEach(t=>t.x=e.width-t.x),t.edges.forEach(t=>{t.controlPoints=t.controlPoints.map(t=>[e.width-t[0],t[1]])}),t}execute(t,e){return De(this,void 0,void 0,function*(){const n=Object.assign(Object.assign(Object.assign({},Wj.defaultOptions),this.options),e),{direction:r,nodeSize:i}=n,o=this.getRoot();if(!o)return t;const A=this.formatSize(i);n.vGap||(n.vGap=Math.max(...(t.nodes||[]).map(t=>A(t)[1]))),n.hGap||(n.hGap=Math.max(...(t.nodes||[]).map(t=>A(t)[0])));let s=this.doLayout(o,n);this.placeAlterative(s,o),"RL"===r&&(s=this.rightToLeft(s,n));const{model:a}=this.context,c=[],l=[];return s.nodes.forEach(t=>{const{id:e,x:n,y:r}=t,i=a.getNodeLikeDatum(e);c.push(Yj(i,{x:n,y:r}))}),s.edges.forEach(t=>{const{id:e,controlPoints:n}=t,r=a.getEdgeDatum(e);l.push(Yj(r,{controlPoints:n}))}),{nodes:c,edges:l}})}}Wj.defaultOptions={direction:"RL",getRibSep:()=>60};const Yj=(t,e)=>Object.assign(Object.assign({},t),{style:Object.assign(Object.assign({},t.style||{}),e)}),Xj=t=>0===t.depth,qj=t=>(t.depth||(t.depth=0))%2==0;class $j extends pE{constructor(){super(...arguments),this.id="snake"}formatSize(t,e){const n="function"==typeof e?e:()=>e;return t.reduce((t,e)=>{const[r,i]=cw(n(e))||[0,0];return[Math.max(t[0],r),Math.max(t[1],i)]},[0,0])}validate(t){const{nodes:e=[],edges:n=[]}=t,r={},i={},o={};e.forEach(t=>{r[t.id]=0,i[t.id]=0,o[t.id]=[]}),n.forEach(t=>{r[t.target]++,i[t.source]++,o[t.source].push(t.target)});const A=new Set,s=t=>{A.has(t)||(A.add(t),o[t].forEach(s))};if(s(e[0].id),A.size!==e.length)return!1;const a=e.filter(t=>0===r[t.id]),c=e.filter(t=>0===i[t.id]);if(1!==a.length||1!==c.length)return!1;return e.filter(t=>1===r[t.id]&&1===i[t.id]).length===e.length-2}execute(t,e){return De(this,void 0,void 0,function*(){var n;if(!this.validate(t))return t;const{nodeSize:r,padding:i,sortBy:o,cols:A,colGap:s,rowGap:a,clockwise:c,width:l,height:u}=Object.assign({},$j.defaultOptions,this.options,e),[h,d,f,g]=pm(i),p=this.formatSize(t.nodes||[],r),v=Math.ceil((t.nodes||[]).length/A);let m=s||(l-g-d-A*p[0])/(A-1),y=a||(u-h-f-v*p[1])/(v-1);(y===1/0||y<0)&&(y=0),(m===1/0||m<0)&&(m=0);const w=o?null===(n=t.nodes)||void 0===n?void 0:n.sort(o):function(t){const{nodes:e=[],edges:n=[]}=t,r={},i={};e.forEach(t=>{r[t.id]=0,i[t.id]=[]}),n.forEach(t=>{r[t.target]++,i[t.source].push(t.target)});const o=[],A=[];e.forEach(t=>{0===r[t.id]&&o.push(t.id)});for(;o.length>0;){const t=o.shift(),n=e.find(e=>e.id===t);A.push(n),i[t].forEach(t=>{r[t]--,0===r[t]&&o.push(t)})}return A}(t),b=(w||[]).map((t,e)=>{const n=Math.floor(e/A),r=e%A,i=g+(c?n%2==0?r:A-1-r:n%2==0?A-1-r:r)*(p[0]+m)+p[0]/2,o=h+n*(p[1]+y)+p[1]/2;return{id:t.id,style:{x:i,y:o}}});return{nodes:b}})}}$j.defaultOptions={padding:0,cols:5,clockwise:!0};class Zj extends ry{}function Jj(t,e=!0,n){const r=document.createElement("div");return r.setAttribute("class",`g6-${t}`),Object.assign(r.style,{position:"absolute",display:"block"}),e&&Object.assign(r.style,{position:"unset",gridArea:"1 / 1 / 2 / 2",inset:"0px",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none"}),n&&Object.assign(r.style,n),r}function tz(t,e="div",n={},r="",i=document.body){const o=document.getElementById(t);o&&o.remove();const A=document.createElement(e);return A.innerHTML=r,A.id=t,Object.assign(A.style,n),i.appendChild(A),A}class ez extends Zj{constructor(t,e){super(t,Object.assign({},ez.defaultOptions,e)),this.$element=Jj("background");this.context.canvas.getContainer().prepend(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t),Object.assign(this.$element.style,Se(this.options,["key","type"]))})}destroy(){super.destroy(),this.$element.remove()}}function nz(t,e,n,r,i,o){const A=n-t,s=r-e;let a=i-t,c=o-e,l=a*A+c*s,u=0;l<=0?u=0:(a=A-a,c=s-c,l=a*A+c*s,u=l<=0?0:l*l/(A*A+s*s));const h=a*a+c*c-u;return h<0?0:h}function rz(t,e,n,r){return(t-n)*(t-n)+(e-r)*(e-r)}function iz(t,e,n,r,i){return rz(t,e,n,r)<i*i}function oz(t){const e=Math.min(t.x1,t.x2),n=Math.max(t.x1,t.x2),r=Math.min(t.y1,t.y2),i=Math.max(t.y1,t.y2);return{x:e,y:r,x2:n,y2:i,width:n-e,height:i-r}}ez.defaultOptions={transition:"background 0.5s",backgroundSize:"cover",zIndex:"-1"};class Az{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}draw(t){t.moveTo(this.x1,this.y1),t.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(t){return new Az(t.x1,t.y1,t.x2,t.y2)}cuts(t,e){if(this.y1===this.y2)return!1;if(e<this.y1&&e<=this.y2||e>this.y1&&e>=this.y2)return!1;if(t>this.x1&&t>=this.x2)return!1;if(t<this.x1&&t<=this.x2)return!0;return t<=this.x1+(e-this.y1)*(this.x2-this.x1)/(this.y2-this.y1)}distSquare(t,e){return nz(this.x1,this.y1,this.x2,this.y2,t,e)}ptClose(t,e,n){if(this.x1<this.x2){if(t<this.x1-n||t>this.x2+n)return!1}else if(t<this.x2-n||t>this.x1+n)return!1;if(this.y1<this.y2){if(e<this.y1-n||e>this.y2+n)return!1}else if(e<this.y2-n||e>this.y1+n)return!1;return!0}}var sz,az;!function(t){t[t.POINT=1]="POINT",t[t.PARALLEL=2]="PARALLEL",t[t.COINCIDENT=3]="COINCIDENT",t[t.NONE=4]="NONE"}(sz||(sz={}));class cz{constructor(t,e=0,n=0){this.state=t,this.x=e,this.y=n}}function lz(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const e=n/i,o=r/i;return 0<=e&&e<=1&&0<=o&&o<=1?new cz(sz.POINT,t.x1+e*(t.x2-t.x1),t.y1+e*(t.y2-t.y1)):new cz(sz.NONE)}return new cz(0===n||0===r?sz.COINCIDENT:sz.PARALLEL)}function uz(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const t=n/i,e=r/i;if(0<=t&&t<=1&&0<=e&&e<=1)return t}return Number.POSITIVE_INFINITY}function hz(t,e,n){const r=new Set;return t.width<=0?(r.add(az.LEFT),r.add(az.RIGHT)):e<t.x?r.add(az.LEFT):e>t.x+t.width&&r.add(az.RIGHT),t.height<=0?(r.add(az.TOP),r.add(az.BOTTOM)):n<t.y?r.add(az.TOP):n>t.y+t.height&&r.add(az.BOTTOM),r}function dz(t,e){let n=e.x1,r=e.y1;const i=e.x2,o=e.y2,A=Array.from(hz(t,i,o));if(0===A.length)return!0;let s=hz(t,n,r);for(;0!==s.size;){for(const t of A)if(s.has(t))return!1;if(s.has(az.RIGHT)||s.has(az.LEFT)){let e=t.x;s.has(az.RIGHT)&&(e+=t.width),r+=(e-n)*(o-r)/(i-n),n=e}else{let e=t.y;s.has(az.BOTTOM)&&(e+=t.height),n+=(e-r)*(i-n)/(o-r),r=e}s=hz(t,n,r)}return!0}function fz(t,e){let n=Number.POSITIVE_INFINITY,r=0;function i(t,i,o,A){let s=uz(e,new Az(t,i,o,A));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s<n&&(n=s))}return i(t.x,t.y,t.x2,t.y),i(t.x,t.y,t.x,t.y2),r>1?n:(i(t.x,t.y2,t.x2,t.y2),r>1?n:(i(t.x2,t.y,t.x2,t.y2),0===r?-1:n))}function gz(t,e){let n=0;const r=lz(t,new Az(e.x,e.y,e.x2,e.y));n+=r.state===sz.POINT?1:0;const i=lz(t,new Az(e.x,e.y,e.x,e.y2));n+=i.state===sz.POINT?1:0;const o=lz(t,new Az(e.x,e.y2,e.x2,e.y2));n+=o.state===sz.POINT?1:0;const A=lz(t,new Az(e.x2,e.y,e.x2,e.y2));return n+=A.state===sz.POINT?1:0,{top:r,left:i,bottom:o,right:A,count:n}}!function(t){t[t.LEFT=0]="LEFT",t[t.TOP=1]="TOP",t[t.RIGHT=2]="RIGHT",t[t.BOTTOM=3]="BOTTOM"}(az||(az={}));class pz{constructor(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(t){return new pz(t.x,t.y,t.width,t.height)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new pz(this.x,this.y,this.width,this.height)}add(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x+t.width),i=Math.max(this.y2,t.y+t.height);this.x=e,this.y=n,this.width=r-e,this.height=i-n}addPoint(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x),i=Math.max(this.y2,t.y);this.x=e,this.y=n,this.width=r-e,this.height=i-n}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(t){t.rect(this.x,this.y,this.width,this.height)}containsPt(t,e){return t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}get area(){return this.width*this.height}intersects(t){return!(this.area<=0||t.width<=0||t.height<=0)&&(t.x+t.width>this.x&&t.y+t.height>this.y&&t.x<this.x2&&t.y<this.y2)}distSquare(t,e){if(this.containsPt(t,e))return 0;const n=hz(this,t,e);return n.has(az.TOP)?n.has(az.LEFT)?rz(t,e,this.x,this.y):n.has(az.RIGHT)?rz(t,e,this.x2,this.y):(this.y-e)*(this.y-e):n.has(az.BOTTOM)?n.has(az.LEFT)?rz(t,e,this.x,this.y2):n.has(az.RIGHT)?rz(t,e,this.x2,this.y2):(e-this.y2)*(e-this.y2):n.has(az.LEFT)?(this.x-t)*(this.x-t):n.has(az.RIGHT)?(t-this.x2)*(t-this.x2):0}}class vz{constructor(t,e,n){this.cx=t,this.cy=e,this.radius=n}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return 2*this.radius}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return 2*this.radius}static from(t){return new vz(t.cx,t.cy,t.radius)}containsPt(t,e){return rz(this.cx,this.cy,t,e)<this.radius*this.radius}distSquare(t,e){const n=rz(this.cx,this.cy,t,e);if(n<this.radius*this.radius)return 0;const r=Math.sqrt(n)-this.radius;return r*r}draw(t){t.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,2*Math.PI)}}class mz{constructor(t,e=0,n=0,r=0,i=0,o=10,A=10,s=new Float32Array(Math.max(0,o*A)).fill(0)){this.pixelGroup=t,this.i=e,this.j=n,this.pixelX=r,this.pixelY=i,this.width=o,this.height=A,this.area=s}createSub(t,e){return new mz(this.pixelGroup,t.x,t.y,e.x,e.y,t.width,t.height)}static fromPixelRegion(t,e){return new mz(e,0,0,t.x,t.y,Math.ceil(t.width/e),Math.ceil(t.height/e))}copy(t,e){return new mz(this.pixelGroup,this.scaleX(e.x),this.scaleY(e.y),e.x,e.y,t.width,t.height,t.area)}boundX(t){return t<this.i?this.i:t>=this.width?this.width-1:t}boundY(t){return t<this.j?this.j:t>=this.height?this.height-1:t}scaleX(t){return this.boundX(Math.floor((t-this.pixelX)/this.pixelGroup))}scaleY(t){return this.boundY(Math.floor((t-this.pixelY)/this.pixelGroup))}scale(t){const e=this.scaleX(t.x),n=this.scaleY(t.y),r=this.boundX(Math.ceil((t.x+t.width-this.pixelX)/this.pixelGroup)),i=this.boundY(Math.ceil((t.y+t.height-this.pixelY)/this.pixelGroup));return new pz(e,n,r-e,i-n)}invertScaleX(t){return Math.round(t*this.pixelGroup+this.pixelX)}invertScaleY(t){return Math.round(t*this.pixelGroup+this.pixelY)}addPadding(t,e){const n=Math.ceil(e/this.pixelGroup),r=this.boundX(t.x-n),i=this.boundY(t.y-n),o=this.boundX(t.x2+n),A=this.boundY(t.y2+n);return new pz(r,i,o-r,A-i)}get(t,e){return t<0||e<0||t>=this.width||e>=this.height?Number.NaN:this.area[t+e*this.width]}inc(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]+=n)}set(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]=n)}incArea(t,e){if(t.width<=0||t.height<=0||0===e)return;const n=this.width,r=t.width,i=Math.max(0,t.i),o=Math.max(0,t.j),A=Math.min(t.i+t.width,n),s=Math.min(t.j+t.height,this.height);if(!(s<=0||A<=0||i>=n||s>=this.height))for(let a=o;a<s;a++){const o=(a-t.j)*r,s=a*n;for(let n=i;n<A;n++){const r=t.area[n-t.i+o];0!==r&&(this.area[n+s]+=e*r)}}}fill(t){this.area.fill(t)}fillArea(t,e){const n=t.x+t.y*this.width;for(let r=0;r<t.height;r++){const i=n+r*this.width;this.area.fill(e,i,i+t.width)}}fillHorizontalLine(t,e,n,r){const i=t+e*this.width;this.area.fill(r,i,i+n)}fillVerticalLine(t,e,n,r){const i=t+e*this.width;for(let t=0;t<n;t++)this.area[i+t*this.width]=r}clear(){this.area.fill(0)}toString(){let t="";for(let e=0;e<this.height;e++){const n=e*this.width;for(let e=0;e<this.width;e++){t+=this.area[n+e].toFixed(1).padStart(6),t+=" "}t+="\n"}return t}draw(t,e=!0){if(this.width<=0||this.height<=0)return;t.save(),e&&t.translate(this.pixelX,this.pixelY);const n=this.area.reduce((t,e)=>Math.min(t,e),Number.POSITIVE_INFINITY),r=this.area.reduce((t,e)=>Math.max(t,e),Number.NEGATIVE_INFINITY),i=t=>(t-n)/(r-n);t.scale(this.pixelGroup,this.pixelGroup);for(let e=0;e<this.width;e++)for(let n=0;n<this.height;n++){const r=this.area[e+n*this.width];t.fillStyle=`rgba(0, 0, 0, ${i(r)})`,t.fillRect(e,n,1,1)}t.restore()}drawThreshold(t,e,n=!0){if(!(this.width<=0||this.height<=0)){t.save(),n&&t.translate(this.pixelX,this.pixelY),t.scale(this.pixelGroup,this.pixelGroup);for(let n=0;n<this.width;n++)for(let r=0;r<this.height;r++){const i=this.area[n+r*this.width];t.fillStyle=i>e?"black":"white",t.fillRect(n,r,1,1)}t.restore()}}}function yz(t,e){const n=t=>({x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e});return Array.isArray(t)?t.map(n):n(t)}function wz(t,e,n){return bz(Object.assign(oz(t),{distSquare:(e,n)=>nz(t.x1,t.y1,t.x2,t.y2,e,n)}),e,n)}function bz(t,e,n){const r=yz(t,n),i=e.scale(r),o=e.createSub(i,r);return function(t,e,n,r){const i=n*n;for(let o=0;o<t.height;o++)for(let A=0;A<t.width;A++){const s=r(e.invertScaleX(t.i+A),e.invertScaleY(t.j+o));if(0!==s){if(s<i){const e=n-Math.sqrt(s);t.set(A,o,e*e)}}else t.set(A,o,i)}}(o,e,n,(e,n)=>t.distSquare(e,n)),o}function Bz(t,e){return{x:t,y:e}}function Ez(t,e,n,r){if(0===t.length)return[];const i=function(t){if(t.length<2)return t;let e=0,n=0;return t.forEach(t=>{e+=t.cx,n+=t.cy}),e/=t.length,n/=t.length,t.map(t=>{const r=e-t.cx,i=n-t.cy;return[t,r*r+i*i]}).sort((t,e)=>t[1]-e[1]).map(t=>t[0])}(t);return i.map((t,o)=>{const A=i.slice(0,o);return function(t,e,n,r,i){const o=Bz(e.cx,e.cy),A=function(t,e,n){let r=Number.POSITIVE_INFINITY;return e.reduce((e,i)=>{const o=rz(t.x,t.y,i.cx,i.cy);if(o>r)return e;const A=new Az(t.x,t.y,i.cx,i.cy),s=function(t,e){return t.reduce((t,n)=>dz(n,e)&&function(t,e){function n(t,n,r,i){let o=uz(e,new Az(t,n,r,i));return o=Math.abs(o-.5),o>=0&&o<=1?1:0}let r=n(t.x,t.y,t.x2,t.y);return r+=n(t.x,t.y,t.x,t.y2),r>1||(r+=n(t.x,t.y2,t.x2,t.y2),r>1||(r+=n(t.x2,t.y,t.x2,t.y2),r>0))}(n,e)?t+1:t,0)}(n,A);return o*(s+1)*(s+1)<r&&(e=i,r=o*(s+1)*(s+1)),e},null)}(o,n,t);if(null==A)return[];const s=function(t,e,n,r){const i=[],o=[];o.push(t);let A=!0;for(let t=0;t<n&&A;t++)for(A=!1;!A&&o.length>0;){const t=o.pop(),n=Mz(e,t),s=n?gz(t,n):null;if(!n||!s||2!==s.count){A||i.push(t);continue}let a=r,c=Fz(n,a,s,!0),l=Cz(c,o)||Cz(c,i),u=xz(c,e);for(;!l&&u&&a>=1;)a/=1.5,c=Fz(n,a,s,!0),l=Cz(c,o)||Cz(c,i),u=xz(c,e);if(!c||l||u||(o.push(new Az(t.x1,t.y1,c.x,c.y)),o.push(new Az(c.x,c.y,t.x2,t.y2)),A=!0),A)continue;a=r,c=Fz(n,a,s,!1);let h=Cz(c,o)||Cz(c,i);for(u=xz(c,e);!h&&u&&a>=1;)a/=1.5,c=Fz(n,a,s,!1),h=Cz(c,o)||Cz(c,i),u=xz(c,e);c&&!h&&(o.push(new Az(t.x1,t.y1,c.x,c.y)),o.push(new Az(c.x,c.y,t.x2,t.y2)),A=!0),A||i.push(t)}for(;o.length>0;)i.push(o.pop());return i}(new Az(o.x,o.y,A.cx,A.cy),t,r,i);return function(t,e){const n=[];for(;t.length>0;){const r=t.pop();if(0===t.length){n.push(r);break}const i=t.pop(),o=new Az(r.x1,r.y1,i.x2,i.y2);Mz(e,o)?(n.push(r),t.push(i)):t.push(o)}return n}(s,t)}(e,t,A,n,r)}).flat()}function xz(t,e){return e.some(e=>e.containsPt(t.x,t.y))}function Cz(t,e){return e.some(e=>!!iz(e.x1,e.y1,t.x,t.y,.001)||!!iz(e.x2,e.y2,t.x,t.y,.001))}function Mz(t,e){let n=Number.POSITIVE_INFINITY,r=null;for(const i of t){if(!dz(i,e))continue;const t=fz(i,e);t>=0&&t<n&&(r=i,n=t)}return r}function Fz(t,e,n,r){const i=n.top,o=n.left,A=n.bottom,s=n.right;if(r){if(o.state===sz.POINT){if(i.state===sz.POINT)return Bz(t.x-e,t.y-e);if(A.state===sz.POINT)return Bz(t.x-e,t.y2+e);const n=t.width*t.height;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?Bz(t.x-e,t.y-e):Bz(t.x2+e,t.y-e):o.y<s.y?Bz(t.x-e,t.y2+e):Bz(t.x2+e,t.y2+e)}if(s.state===sz.POINT){if(i.state===sz.POINT)return Bz(t.x2+e,t.y-e);if(A.state===sz.POINT)return Bz(t.x2+e,t.y2+e)}const n=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*n?i.x>A.x?Bz(t.x-e,t.y-e):Bz(t.x-e,t.y2+e):i.x<A.x?Bz(t.x2+e,t.y-e):Bz(t.x2+e,t.y2+e)}if(o.state===sz.POINT){if(i.state===sz.POINT)return Bz(t.x2+e,t.y2+e);if(A.state===sz.POINT)return Bz(t.x2+e,t.y-e);const n=t.height*t.width;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?Bz(t.x2+e,t.y2+e):Bz(t.x-e,t.y2+e):o.y<s.y?Bz(t.x2+e,t.y-e):Bz(t.x-e,t.y-e)}if(s.state===sz.POINT){if(i.state===sz.POINT)return Bz(t.x-e,t.y2+e);if(A.state===sz.POINT)return Bz(t.x-e,t.y-e)}const a=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*a?i.x>A.x?Bz(t.x2+e,t.y2+e):Bz(t.x2+e,t.y-e):i.x<A.x?Bz(t.x-e,t.y2+e):Bz(t.x-e,t.y-e)}function kz(t,e,n,r){if(!(t.closed?n<t.length:n<t.length-1))return!1;const i=t.get(e),o=t.get(n+1);for(let A=e+1;A<=n;A++){const e=t.get(A);if(nz(i.x,i.y,o.x,o.y,e.x,e.y)>r)return!1}return!0}function Sz(t,e){switch(t){case-2:return(((3-e)*e-3)*e+1)/6;case-1:return((3*e-6)*e*e+4)/6;case 0:return(((-3*e+3)*e+3)*e+1)/6;case 1:return e*e*e/6;default:throw new Error("unknown error")}}class Qz{constructor(t=[],e=!0){this.points=t,this.closed=e}get(t){const e=t,n=this.points.length;return t<0?this.closed?this.get(t+n):this.points[0]:t>=n?this.closed?this.get(t-n):this.points[n-1]:this.points[e]}get length(){return this.points.length}toString(t=1/0){const e=this.points;if(0===e.length)return"";const n="function"==typeof t?t:function(t){if(!Number.isFinite(t))return t=>t;if(0===t)return Math.round;const e=Math.pow(10,t);return t=>Math.round(t*e)/e}(t);let r="M";for(const t of e)r+=`${n(t.x)},${n(t.y)} L`;return r=r.slice(0,-1),this.closed&&(r+=" Z"),r}draw(t){const e=this.points;if(0!==e.length){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const n of e)t.lineTo(n.x,n.y);this.closed&&t.closePath()}}sample(t){return function(t=8){return e=>{let n=t,r=e.length;if(n>1)for(r=Math.floor(e.length/n);r<3&&n>1;)n-=1,r=Math.floor(e.length/n);const i=[];for(let t=0,o=0;o<r;o++,t+=n)i.push(e.get(t));return new Qz(i)}}(t)(this)}simplify(t){return function(t=0){return e=>{if(t<0||e.length<3)return e;const n=[];let r=0;const i=t*t;for(;r<e.length;){let t=r+1;for(;kz(e,r,t,i);)t++;n.push(e.get(r)),r=t}return new Qz(n)}}(t)(this)}bSplines(t){return function(t=6){function e(t,e,n){let r=0,i=0;for(let o=-2;o<=1;o++){const A=t.get(e+o),s=Sz(o,n);r+=s*A.x,i+=s*A.y}return{x:r,y:i}}return n=>{if(n.length<3)return n;const r=[],i=n.closed,o=n.length+3-1+(i?0:2);r.push(e(n,2-(i?0:2),0));for(let A=2-(i?0:2);A<o;A++)for(let i=1;i<=t;i++)r.push(e(n,A,i/t));return new Qz(r)}}(t)(this)}apply(t){return t(this)}containsElements(t){const e=function(t){if(0===t.length)return null;const e=t[0],n=new pz(e.x,e.y,0,0);for(const e of t)n.addPoint(e);return n}(this.points);return!!e&&t.every(t=>e.containsPt(t.cx,t.cy)&&this.withinArea(t.cx,t.cy))}withinArea(t,e){if(0===this.length)return!1;let n=0;const r=this.points[0],i=new Az(r.x,r.y,r.x,r.y);for(let r=1;r<this.points.length;r++){const o=this.points[r];i.x1=i.x2,i.y1=i.y2,i.x2=o.x,i.y2=o.y,i.cuts(t,e)&&n++}return i.x1=i.x2,i.y1=i.y2,i.x2=r.x,i.y2=r.y,i.cuts(t,e)&&n++,n%2==1}}class Uz{constructor(t=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=t}add(t){this.set.add(`${t.x}x${t.y}`),this.arr[this.count++]=t}contains(t){return this.set.has(`${t.x}x${t.y}`)}isFirst(t){if(0===this.count)return!1;const e=this.arr[0];return null!=e&&e.x===t.x&&e.y===t.y}path(){return new Qz(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(t){return this.arr[t]}get length(){return this.count}}function Nz(t,e){const n=2*(Math.floor(t.width)+Math.floor(t.height)),r=new Uz(n);function i(n,r,i,o){const A=t.get(n,r);return Number.isNaN(A)?Number.NaN:A>e?i+o:i}function o(t,e){let n=0;return n=i(t,e,n,1),n=i(t+1,e,n,2),n=i(t,e+1,n,4),n=i(t+1,e+1,n,8),Number.isNaN(n)?-1:n}let A=1;function s(e,n){let i=e,s=n,a=t.invertScaleX(i),c=t.invertScaleY(s);for(let e=0;e<t.width*t.height;e++){const e={x:a,y:c};if(r.contains(e)){if(r.isFirst(e))return!0}else r.add(e);const n=o(i,s);switch(n){case-1:return!0;case 0:case 3:case 2:case 7:A=2;break;case 12:case 14:case 4:A=3;break;case 6:A=0===A?3:2;break;case 1:case 13:case 5:A=0;break;case 9:A=2===A?0:1;break;case 10:case 8:case 11:A=1;break;default:return console.warn("Marching squares invalid state: "+n),!0}switch(A){case 0:s--,c-=t.pixelGroup;break;case 1:s++,c+=t.pixelGroup;break;case 3:i--,a-=t.pixelGroup;break;case 2:i++,a+=t.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+n),!0}}return!0}for(let n=0;n<t.width;n++)for(let i=0;i<t.height;i++){if(t.get(n,i)<=e)continue;const A=o(n,i);if(!(A<0||15===A)&&s(n,i))return r.path()}return null}const Tz={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};function Oz(t){return null!=t&&"number"==typeof t.radius}function Iz(t,e){if(Oz(t)!==Oz(e))return!1;if(Oz(t)){const n=e;return t.cx===n.cx&&t.cy===n.cy&&t.radius===n.radius}const n=e;return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}var Lz;!function(t){t[t.MEMBERS=0]="MEMBERS",t[t.NON_MEMBERS=1]="NON_MEMBERS",t[t.EDGES=2]="EDGES"}(Lz||(Lz={}));let Pz=class{constructor(t={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new pz(0,0,0,0),this.potentialArea=new mz(1,0,0,0,0,0,0),this.o=Object.assign({},Tz,t)}pushMember(...t){if(0!==t.length){this.dirty.add(Lz.MEMBERS);for(const e of t)this.members.push({raw:e,obj:Oz(e)?vz.from(e):pz.from(e),area:null})}}removeMember(t){const e=this.members.findIndex(e=>Iz(e.raw,t));return!(e<0)&&(this.members.splice(e,1),this.dirty.add(Lz.MEMBERS),!0)}removeNonMember(t){const e=this.nonMembers.findIndex(e=>Iz(e.raw,t));return!(e<0)&&(this.nonMembers.splice(e,1),this.dirty.add(Lz.NON_MEMBERS),!0)}removeEdge(t){const e=this.edges.findIndex(e=>e.obj.equals(t));return!(e<0)&&(this.edges.splice(e,1),this.dirty.add(Lz.NON_MEMBERS),!0)}pushNonMember(...t){if(0!==t.length){this.dirty.add(Lz.NON_MEMBERS);for(const e of t)this.nonMembers.push({raw:e,obj:Oz(e)?vz.from(e):pz.from(e),area:null})}}pushEdge(...t){if(0!==t.length){this.dirty.add(Lz.EDGES);for(const e of t)this.edges.push({raw:e,obj:Az.from(e),area:null})}}update(){const t=this.dirty.has(Lz.MEMBERS),e=this.dirty.has(Lz.NON_MEMBERS);let n=this.dirty.has(Lz.EDGES);this.dirty.clear();const r=this.members.map(t=>t.obj);if(this.o.virtualEdges&&(t||e)){const t=this.nonMembers.map(t=>t.obj),e=Ez(r,t,this.o.maxRoutingIterations,this.o.morphBuffer),i=new Map(this.virtualEdges.map(t=>[t.obj.toString(),t.area]));this.virtualEdges=e.map(t=>{var e;return{raw:t,obj:t,area:null!==(e=i.get(t.toString()))&&void 0!==e?e:null}}),n=!0}let i=!1;if(t||n){const t=this.virtualEdges.concat(this.edges).map(t=>t.obj),e=function(t,e){if(0===t.length)return new pz(0,0,0,0);const n=pz.from(t[0]);for(const e of t)n.add(e);for(const t of e)n.add(oz(t));return n}(r,t),n=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,o=pz.from(yz(e,n));o.equals(this.activeRegion)||(i=!0,this.activeRegion=o)}if(i){const t=Math.ceil(this.activeRegion.width/this.o.pixelGroup),e=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=mz.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach(t=>t.area=null),this.nonMembers.forEach(t=>t.area=null),this.edges.forEach(t=>t.area=null),this.virtualEdges.forEach(t=>t.area=null)):t===this.potentialArea.width&&e===this.potentialArea.height||(this.potentialArea=mz.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const o=new Map,A=t=>{if(t.area){const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof pz?"R":"C"}`;o.set(e,t.area)}},s=t=>{if(t.area)return;const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof pz?"R":"C"}`;if(o.has(e)){const n=o.get(e);return void(t.area=this.potentialArea.copy(n,{x:t.obj.x-this.o.nodeR1,y:t.obj.y-this.o.nodeR1}))}const n=t.obj instanceof pz?function(t,e,n){const r=e.scale(t),i=e.addPadding(r,n),o=e.createSub(i,{x:t.x-n,y:t.y-n}),A=r.x-i.x,s=r.y-i.y,a=i.x2-r.x2,c=i.y2-r.y2,l=i.width-A-a,u=i.height-s-c,h=n*n;o.fillArea({x:A,y:s,width:l+1,height:u+1},h);const d=[0],f=Math.max(s,A,a,c);{const i=e.invertScaleX(r.x+r.width/2);for(let o=1;o<f;o++){const A=e.invertScaleY(r.y-o),s=t.distSquare(i,A);if(!(s<h))break;{const t=n-Math.sqrt(s);d.push(t*t)}}}const g=[],p=Math.max(A,a),v=Math.max(s,a);for(let i=1;i<p;i++){const o=e.invertScaleX(r.x-i),A=[];for(let i=1;i<v;i++){const s=e.invertScaleY(r.y-i),a=t.distSquare(o,s);if(a<h){const t=n-Math.sqrt(a);A.push(t*t)}else A.push(0)}g.push(A)}for(let t=1;t<Math.min(s,d.length);t++){const e=d[t];o.fillHorizontalLine(A,s-t,l+1,e)}for(let t=1;t<Math.min(c,d.length);t++){const e=d[t];o.fillHorizontalLine(A,s+u+t,l+1,e)}for(let t=1;t<Math.min(A,d.length);t++){const e=d[t];o.fillVerticalLine(A-t,s,u+1,e)}for(let t=1;t<Math.min(c,d.length);t++){const e=d[t];o.fillVerticalLine(A+l+t,s,u+1,e)}for(let t=1;t<A;t++){const e=g[t-1],n=A-t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<c;t++)o.set(n,s+u+t,e[t-1])}for(let t=1;t<a;t++){const e=g[t-1],n=A+l+t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<c;t++)o.set(n,s+u+t,e[t-1])}return o}(t.obj,this.potentialArea,this.o.nodeR1):bz(t.obj,this.potentialArea,this.o.nodeR1);t.area=n,o.set(e,n)};this.members.forEach(A),this.nonMembers.forEach(A),this.members.forEach(s),this.nonMembers.forEach(t=>{this.activeRegion.intersects(t.obj)?s(t):t.area=null}),this.edges.forEach(t=>{t.area||(t.area=wz(t.obj,this.potentialArea,this.o.edgeR1))}),this.virtualEdges.forEach(t=>{t.area||(t.area=wz(t.obj,this.potentialArea,this.o.edgeR1))})}drawMembers(t){for(const e of this.members)e.obj.draw(t)}drawNonMembers(t){for(const e of this.nonMembers)e.obj.draw(t)}drawEdges(t){for(const e of this.edges)e.obj.draw(t)}drawPotentialArea(t,e=!0){this.potentialArea.draw(t,e)}compute(){if(0===this.members.length)return new Qz([]);this.dirty.size>0&&this.update();const{o:t,potentialArea:e}=this,n=this.members.map(t=>t.area),r=this.virtualEdges.concat(this.edges).map(t=>t.area),i=this.nonMembers.filter(t=>null!=t.area).map(t=>t.area),o=this.members.map(t=>t.obj);return function(t,e,n,r,i,o={}){const A=Object.assign({},Tz,o);let s=A.threshold,a=A.memberInfluenceFactor,c=A.edgeInfluenceFactor,l=A.nonMemberInfluenceFactor;const u=(A.nodeR0-A.nodeR1)*(A.nodeR0-A.nodeR1),h=(A.edgeR0-A.edgeR1)*(A.edgeR0-A.edgeR1);for(let o=0;o<A.maxMarchingIterations;o++){if(t.clear(),0!==a){const n=a/u;for(const r of e)t.incArea(r,n)}if(0!==c){const e=c/h;for(const r of n)t.incArea(r,e)}if(0!==l){const e=l/u;for(const n of r)t.incArea(n,e)}const d=Nz(t,s);if(d&&i(d))return d;if(s*=.95,o<=.5*A.maxMarchingIterations)a*=1.2,c*=1.2;else{if(!(0!==l&&r.length>0))break;l*=.8}}return new Qz([])}(e,n,r,i,t=>t.containsElements(o),t)}};class Dz extends Zj{constructor(t,e){super(t,be({},Dz.defaultOptions,e)),this.path=null,this.members=new Map,this.avoidMembers=new Map,this.bubbleSetOptions={},this.drawBubbleSets=()=>{const{style:t,bubbleSetOptions:e}=this.parseOptions();xe(this.bubbleSetOptions,e)||this.init(),this.bubbleSetOptions=Object.assign({},e);const n=Object.assign(Object.assign({},t),{d:this.getPath()});this.shape?this.shape.update(n):(this.shape=new xw({style:n}),this.context.canvas.appendChild(this.shape))},this.updateBubbleSetsPath=t=>{if(!this.shape)return;const e=Km(t.data);[...this.options.members,...this.options.avoidMembers].includes(e)&&this.shape.update(Object.assign(Object.assign({},this.parseOptions().style),{d:this.getPath(e)}))},this.getPath=t=>{const{graph:e}=this.context,n=this.options.members,r=[...this.members.keys()],i=this.options.avoidMembers,o=[...this.avoidMembers.keys()];if(0===n.length&&0===i.length)return this.members.clear(),this.avoidMembers.clear(),this.path=[],this.path;if(!t&&this.path&&xe(n,r)&&xe(i,o))return this.path;const{enter:A=[],exit:s=[]}=ty(r,n,t=>t),{enter:a=[],exit:c=[]}=ty(o,i,t=>t);if(t){const e=n.includes(t),r=i.includes(t);e&&(s.push(t),A.push(t)),r&&(c.push(t),a.push(t))}const l=(t,n,r)=>{t.forEach(t=>{const i=r?this.members:this.avoidMembers,o=r?"pushMember":"pushNonMember",A=r?"removeMember":"removeNonMember";if(n){let n;"edge"===e.getElementType(t)?([n]=Hz(e,t),this.bubbleSets.pushEdge(n)):([n]=Rz(e,t),this.bubbleSets[o](n)),i.set(t,n)}else{const n=i.get(t);n&&("edge"===e.getElementType(t)?this.bubbleSets.removeEdge(n):this.bubbleSets[A](n),i.delete(t))}})};l(s,!1,!0),l(A,!0,!0),l(c,!1,!1),l(a,!0,!1);const u=this.bubbleSets.compute().sample(8).simplify(0).bSplines().simplify(0);return this.path=Ew(u.points.map(Sy)),this.path},this.bindEvents(),this.bubbleSets=new Pz(this.options)}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath)}init(){this.bubbleSets=new Pz(this.options),this.members.clear(),this.avoidMembers.clear(),this.path=null}parseOptions(){const t=this.options,{type:e,key:n,members:r,avoidMembers:i}=t,o=Pe(t,["type","key","members","avoidMembers"]),A=Object.keys(o).reduce((t,e)=>(e in Tz?t.bubbleSetOptions[e]=o[e]:t.style[e]=o[e],t),{style:{},bubbleSetOptions:{}});return Object.assign({type:e,key:n,members:r,avoidMembers:i},A)}addMember(t){const e=Array.isArray(t)?t:[t];e.some(t=>this.options.avoidMembers.includes(t))&&(this.options.avoidMembers=this.options.avoidMembers.filter(t=>!e.includes(t))),this.options.members=[...new Set([...this.options.members,...e])],this.drawBubbleSets()}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter(t=>!e.includes(t)),this.drawBubbleSets()}updateMember(t){this.options.members=Gt(t)?t(this.options.members):t,this.drawBubbleSets()}getMember(){return this.options.members}addAvoidMember(t){const e=Array.isArray(t)?t:[t];e.some(t=>this.options.members.includes(t))&&(this.options.members=this.options.members.filter(t=>!e.includes(t))),this.options.avoidMembers=[...new Set([...this.options.avoidMembers,...e])],this.drawBubbleSets()}removeAvoidMember(t){const e=Array.isArray(t)?t:[t];this.options.avoidMembers.some(t=>e.includes(t))&&(this.options.avoidMembers=this.options.avoidMembers.filter(t=>!e.includes(t)),this.drawBubbleSets())}updateAvoidMember(t){this.options.avoidMembers=Array.isArray(t)?t:[t],this.drawBubbleSets()}getAvoidMember(){return this.options.avoidMembers}destroy(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath),this.shape&&(this.shape.destroy(),this.shape=void 0),super.destroy()}}Dz.defaultOptions=Object.assign({members:[],avoidMembers:[],fill:"lightblue",fillOpacity:.2,stroke:"blue",strokeOpacity:.2},Tz);const Rz=(t,e)=>(Array.isArray(e)?e:[e]).map(e=>{const n=t.getElementRenderBounds(e);return new pz(n.min[0],n.min[1],mm(n),ym(n))}),Hz=(t,e)=>(Array.isArray(e)?e:[e]).map(e=>{const n=t.getEdgeData(e),r=t.getElementPosition(n.source),i=t.getElementPosition(n.target);return Az.from({x1:r[0],y1:r[1],x2:i[0],y2:i[1]})});class _z extends Zj{constructor(t,e){super(t,Object.assign({},_z.defaultOptions,e)),this.targetElement=null,this.wheelHandler=t=>{t.stopPropagation()},this.onTriggerEvent=t=>{var e;null===(e=t.preventDefault)||void 0===e||e.call(t),this.show(t)},this.onMenuItemClick=t=>{const{onClick:e,trigger:n}=this.options;if(t.target instanceof HTMLElement&&t.target.className.includes("g6-contextmenu-li")){const n=t.target.getAttribute("value");null==e||e(n,t.target,this.targetElement),this.hide()}"click"!==n&&this.hide()},this.initElement(),this.update(e)}initElement(){this.$element=Jj("contextmenu",!1,{zIndex:"99"});const{className:t}=this.options;t&&this.$element.classList.add(t),this.$element.addEventListener("wheel",this.wheelHandler);this.context.canvas.getContainer().appendChild(this.$element),tz("g6-contextmenu-css","style",{},"\n .g6-contextmenu {\n font-size: 12px;\n background-color: rgba(255, 255, 255, 0.96);\n border-radius: 4px;\n overflow-x: hidden;\n overflow-y: auto;\n max-height: calc(100% - 8px);\n box-shadow: rgba(0, 0, 0, 0.12) 0px 6px 12px 0px;\n transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, left 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s, top 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s;\n }\n\n .g6-contextmenu::-webkit-scrollbar {\n width: 6px;\n }\n\n .g6-contextmenu::-webkit-scrollbar-thumb {\n background-color: rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n }\n\n .g6-contextmenu::-webkit-scrollbar-thumb:hover {\n background-color: rgba(0, 0, 0, 0.3);\n }\n\n .g6-contextmenu-ul {\n max-width: 256px;\n min-width: 96px;\n list-style: none;\n padding: 0;\n margin: 0;\n }\n\n .g6-contextmenu-li {\n padding: 8px 12px;\n cursor: pointer;\n user-select: none;\n }\n\n .g6-contextmenu-li:hover {\n background-color: #f5f5f5;\n cursor: pointer;\n }\n",document.head)}show(t){return De(this,void 0,void 0,function*(){const{enable:e,offset:n}=this.options;if("function"==typeof e&&!e(t)||!e)return void this.hide();const r=yield this.getDOMContent(t);r instanceof HTMLElement?(this.$element.innerHTML="",this.$element.appendChild(r)):this.$element.innerHTML=r;const i=this.context.graph.getCanvas().getContainer().getBoundingClientRect();let o=t.client.x-i.left+n[0],A=t.client.y-i.top+n[1];this.$element.style.display="block";const s=this.$element.offsetWidth,a=this.$element.offsetHeight,c=i.width,l=i.height;o=Math.max(4,Math.min(o,c-s-4)),A=Math.max(4,Math.min(A,l-a-4)),this.$element.style.left=`${o}px`,this.$element.style.top=`${A}px`,this.targetElement=t.target})}hide(){this.$element.style.display="none",this.targetElement=null}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy(),this.$element.remove()}getDOMContent(t){return De(this,void 0,void 0,function*(){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(yield n(t)).map(t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`).join("")}\n </ul>\n `:yield e(t)})}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`canvas:${e}`,this.onTriggerEvent),t.on(`node:${e}`,this.onTriggerEvent),t.on(`edge:${e}`,this.onTriggerEvent),t.on(`combo:${e}`,this.onTriggerEvent),document.addEventListener("click",this.onMenuItemClick)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`canvas:${e}`,this.onTriggerEvent),t.off(`node:${e}`,this.onTriggerEvent),t.off(`edge:${e}`,this.onTriggerEvent),t.off(`combo:${e}`,this.onTriggerEvent),document.removeEventListener("click",this.onMenuItemClick),this.$element.removeEventListener("wheel",this.wheelHandler)}}_z.defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};class Gz extends Zj{constructor(t,e){super(t,Object.assign({},Gz.defaultOptions,e)),this.edgeBundles={},this.edgePoints={},this.onBundle=()=>{const{model:t,element:e}=this.context,n=t.getEdgeData();this.divideEdges(this.options.divisions);const{cycles:r,iterRate:i,divRate:o}=this.options;let{lambda:A,divisions:s,iterations:a}=this.options;for(let t=0;t<r;t++){for(let t=0;t<a;t++){const t={};n.forEach(e=>{var n;if(e.source===e.target)return;const r=Km(e);t[r]=this.getEdgeForces(e,s,A);for(let e=0;e<s+1;e++)(n=this.edgePoints)[r]||(n[r]=[]),this.edgePoints[r][e]=ay(this.edgePoints[r][e],t[r][e])})}A/=2,s*=o,a*=i,this.divideEdges(s)}n.forEach(t=>{const n=Km(t),r=e.getElement(n);null==r||r.update({d:hB(this.edgePoints[n])})})},this.bindEvents()}get nodeMap(){const t=this.context.model.getNodeData();return Object.fromEntries(t.map(t=>[Km(t),yy(My(t))]))}divideEdges(t){this.context.model.getEdgeData().forEach(e=>{var n;const r=Km(e);(n=this.edgePoints)[r]||(n[r]=[]);const i=this.nodeMap[e.source],o=this.nodeMap[e.target];if(1===t)this.edgePoints[r].push(i),this.edgePoints[r].push(uy(ay(i,o),2)),this.edgePoints[r].push(o);else{const e=(0===this.edgePoints[r].length?dy(i,o):Xz(this.edgePoints[r]))/(t+1);let n=e;const A=[i];for(let t=1;t<this.edgePoints[r].length;t++){const i=this.edgePoints[r][t-1],o=this.edgePoints[r][t];let s=dy(o,i);for(;s>n;){const t=n/s,r=ay(i,ly(cy(o,i),t));A.push(r),s-=n,n=e}n-=s}A.push(o),this.edgePoints[r]=A}})}getVectorPosition(t){const e=this.nodeMap[t.source],n=this.nodeMap[t.target],[r,i]=cy(n,e);return{source:e,target:n,vx:r,vy:i,length:dy(e,n)}}measureEdgeCompatibility(t,e){const n=this.getVectorPosition(t),r=this.getVectorPosition(e);return Kz(n,r)*jz(n,r)*zz(n,r)*Yz(n,r)}getEdgeBundles(){const t={},e=this.options.bundleThreshold,n=this.context.model.getEdgeData();return n.forEach((r,i)=>{n.forEach((n,o)=>{var A,s;if(o<=i)return;this.measureEdgeCompatibility(r,n)>=e&&(t[A=Km(r)]||(t[A]=[]),t[Km(r)].push(n),t[s=Km(n)]||(t[s]=[]),t[Km(n)].push(r))})}),t}getSpringForce(t,e){const{pre:n,cur:r,next:i}=t;return ly(cy(ay(n,i),ly(r,2)),e)}getElectrostaticForce(t,e){Ee(this.edgeBundles)&&(this.edgeBundles=this.getEdgeBundles());const n=this.edgeBundles[Km(e)];let r=[0,0];return null==n||n.forEach(n=>{const i=this.edgePoints[Km(n)][t],o=this.edgePoints[Km(e)][t],A=cy(i,o),s=dy(i,o);r=ay(r,ly(A,1/s))}),r}getEdgeForces(t,e,n){const r=this.nodeMap[t.source],i=this.nodeMap[t.target],o=this.options.K/(dy(r,i)*(e+1)),A=[[0,0]],s=Km(t);for(let r=1;r<e;r++){const e=this.getSpringForce({pre:this.edgePoints[s][r-1],cur:this.edgePoints[s][r],next:this.edgePoints[s][r+1]||[0,0]},o),i=this.getElectrostaticForce(r,t);A.push(ly(ay(e,i),n))}return A.push([0,0]),A}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onBundle)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onBundle)}destroy(){this.unbindEvents(),super.destroy()}}Gz.defaultOptions={K:.1,lambda:.1,divisions:1,divRate:2,cycles:6,iterations:90,iterRate:2/3,bundleThreshold:.6};const Kz=(t,e)=>Math.abs(function(t,e){return[t,e]=sy(t,e),t.reduce((t,n,r)=>t+n*e[r],0)}([t.vx,t.vy],[e.vx,e.vy])/(t.length*e.length)),jz=(t,e)=>{const n=(t.length+e.length)/2;return 2/(n/Math.min(t.length,e.length)+Math.max(t.length,e.length)/n)},zz=(t,e)=>{const n=(t.length+e.length)/2;return n/(n+dy(uy(ay(t.source,t.target),2),uy(ay(e.source,e.target),2)))},Vz=(t,e)=>{if(e.source[0]===e.target[0])return[e.source[0],t[1]];if(e.source[1]===e.target[1])return[t[0],e.source[1]];const n=(e.source[1]-e.target[1])/(e.source[0]-e.target[0]),r=(n*n*e.source[0]+n*(t[1]-e.source[1])+t[0])/(n*n+1);return[r,n*(r-e.source[0])+e.source[1]]},Wz=(t,e)=>{const n=Vz(e.source,t),r=Vz(e.target,t),i=uy(ay(n,r),2),o=uy(ay(t.source,t.target),2);return 0===dy(n,r)?0:Math.max(0,1-2*dy(o,i)/dy(n,r))},Yz=(t,e)=>Math.min(Wz(t,e),Wz(e,t)),Xz=t=>{let e=0;for(let n=1;n<t.length;n++)e+=dy(t[n],t[n-1]);return e},qz={fill:"#fff",fillOpacity:1,lineWidth:1,stroke:"#000",strokeOpacity:.8,zIndex:-1/0};class $z extends Zj{constructor(t,e){super(t,Object.assign({},$z.defaultOptions,e)),this.shapes=new Map,this.r=this.options.r,this.onEdgeFilter=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=Sy(t.canvas);this.renderLens(e),this.renderFocusElements()},this.renderLens=t=>{const e=Object.assign({},qz,this.options.style);this.isLensOn||(this.lens=new Tw({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,Qy(t),{size:2*this.r}),this.lens.update(e)},this.getFilterData=()=>{const{filter:t}=this.options,{model:e}=this.context,n=e.getData();if(!t)return n;const{nodes:r,edges:i,combos:o}=n;return{nodes:r.filter(e=>t(Km(e),"node")),edges:i.filter(e=>t(Km(e),"edge")),combos:o.filter(e=>t(Km(e),"combo"))}},this.getFocusElements=t=>{const{nodes:e,edges:n}=this.getFilterData(),r=e.filter(e=>dy(My(e),t)<this.r),i=r.map(t=>Km(t));return{nodes:r,edges:n.filter(t=>{const{source:e,target:n}=t,r=i.includes(e),o=i.includes(n);switch(this.options.nodeType){case"both":return r&&o;case"either":return r!==o;case"source":return r&&!o;case"target":return!r&&o;default:return!1}})}},this.renderFocusElements=()=>{const{element:t,graph:e}=this.context;if(!this.isLensOn)return;const n=this.lens.getCenter(),{nodes:r,edges:i}=this.getFocusElements(n),o=new Set,A=n=>{const r=Km(n);o.add(r);const i=t.getElement(r);if(!i)return;const A=this.shapes.get(r)||i.cloneNode();A.setPosition(i.getPosition()),A.id=i.id,this.shapes.has(r)?Object.entries(i.attributes).forEach(([t,e])=>{A.style[t]!==e&&(A.style[t]=e)}):(this.canvas.appendChild(A),this.shapes.set(r,A));const s=e.getElementType(r),a=this.getElementStyle(s,n);A.update(a)};r.forEach(A),i.forEach(A),this.shapes.forEach((t,e)=>{o.has(e)||(t.destroy(),this.shapes.delete(e))})},this.scaleRByWheel=t=>{var e;this.options.preventDefault&&t.preventDefault();const{clientX:n,clientY:r,deltaX:i,deltaY:o}=t,{graph:A,canvas:s}=this.context,a=A.getCanvasByClient([n,r]),c=null===(e=this.lens)||void 0===e?void 0:e.getCenter();if(!this.isLensOn||dy(a,c)>this.r)return;const{maxR:l,minR:u}=this.options,h=i+o>0?1/.95:.95,d=Math.min(...s.getSize())/2;this.r=Math.max(u||0,Math.min(l||d,this.r*h)),this.renderLens(c),this.renderFocusElements()},this.isLensDragging=!1,this.onDragStart=t=>{var e;const n=Sy(t.canvas),r=null===(e=this.lens)||void 0===e?void 0:e.getCenter();!this.isLensOn||dy(n,r)>this.r||(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=Sy(t.canvas);this.renderLens(e),this.renderFocusElements()},this.onDragEnd=()=>{this.isLensDragging=!1},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}getElementStyle(t,e){const n="node"===t?this.options.nodeStyle:this.options.edgeStyle;return"function"==typeof n?n(e):n}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.addEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.addEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.addEventListener(t.CommonEvent.DRAG,this.onDrag),o.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel,{passive:!1}))}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.removeEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.removeEventListener(t.CommonEvent.DRAG,this.onDrag),o.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel))}update(t){var e;this.unbindEvents(),super.update(t),this.r=null!==(e=t.r)&&void 0!==e?e:this.r,this.bindEvents()}destroy(){this.unbindEvents(),this.isLensOn&&this.lens.destroy(),this.shapes.forEach((t,e)=>{t.destroy(),this.shapes.delete(e)}),super.destroy()}}$z.defaultOptions={trigger:"pointermove",r:60,nodeType:"both",filter:()=>!0,style:{lineWidth:2},nodeStyle:{label:!1},edgeStyle:{label:!0},scaleRBy:"wheel",preventDefault:!0};const Zz={fill:"#ccc",fillOpacity:.1,lineWidth:2,stroke:"#000",strokeOpacity:.8,labelFontSize:12};class Jz extends Zj{constructor(t,e){super(t,Object.assign({},Jz.defaultOptions,e)),this.r=this.options.r,this.d=this.options.d,this.onCreateFisheye=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=Sy(t.canvas);this.onMagnify(e)},this.onMagnify=t=>{t.some(isNaN)||(this.renderLens(t),this.renderFocusElements())},this.renderLens=t=>{const e=Object.assign({},Zz,this.options.style);this.isLensOn||(this.lens=new Tw({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,Qy(t),{size:2*this.r,label:this.options.showDPercent,labelText:this.getDPercent()}),this.lens.update(e)},this.getDPercent=()=>{const{minD:t,maxD:e}=this.options;return`${Math.round((this.d-t)/(e-t)*100)}%`},this.prevMagnifiedStyleMap=new Map,this.prevOriginStyleMap=new Map,this.renderFocusElements=()=>{if(!this.isLensOn)return;const{graph:t}=this.context,e=this.lens.getCenter(),n=(this.d+1)*this.r,r=new Map,i=new Map;t.getNodeData().forEach(o=>{const A=My(o),s=dy(A,e);if(s>this.r)return;const a=n*s/(this.d*s+this.r),[c,l]=A,[u,h]=e,d=[u+a*((c-u)/s),h+a*((l-h)/s)],f=Km(o),g=this.getNodeStyle(o),p=ke(t.getElementRenderStyle(f),Object.keys(g));r.set(f,Object.assign(Object.assign({},Qy(d)),g)),i.set(f,Object.assign(Object.assign({},Qy(A)),p))}),this.updateStyle(r,i)},this.getNodeStyle=t=>{const{nodeStyle:e}=this.options;return"function"==typeof e?e(t):e},this.updateStyle=(t,e)=>{const{graph:n,element:r}=this.context,{enter:i,exit:o,keep:A}=ty(Array.from(this.prevMagnifiedStyleMap.keys()),Array.from(t.keys()),t=>t),s=new Set,a=(t,e)=>{const i=r.getElement(t);null==i||i.update(e),n.getRelatedEdgesData(t).forEach(t=>{s.add(Km(t))})};[...i,...A].forEach(e=>{a(e,t.get(e))}),o.forEach(t=>{a(t,this.prevOriginStyleMap.get(t)),this.prevOriginStyleMap.delete(t)}),s.forEach(t=>{const e=r.getElement(t);null==e||e.update({})}),this.prevMagnifiedStyleMap=t,e.forEach((t,e)=>{this.prevOriginStyleMap.has(e)||this.prevOriginStyleMap.set(e,t)})},this.isWheelValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;const{clientX:e,clientY:n}=t;return!(dy(this.context.graph.getCanvasByClient([e,n]),this.lens.getCenter())>this.r)},this.scaleR=t=>{const{maxR:e,minR:n}=this.options,r=t?1/.95:.95,i=Math.min(...this.context.canvas.getSize())/2;this.r=Math.max(n||0,Math.min(e||i,this.r*r))},this.scaleD=t=>{const{maxD:e,minD:n}=this.options,r=t?this.d+.1:this.d-.1;this.d=Math.max(n,Math.min(e,r))},this.scaleRByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleR(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleD(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.isDragValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;return!(dy(Sy(t.canvas),this.lens.getCenter())>this.r)},this.isLensDragging=!1,this.onDragStart=t=>{this.isDragValid(t)&&(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=Sy(t.canvas);this.onMagnify(e)},this.onDragEnd=()=>{this.isLensDragging=!1},this.scaleRByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleR(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleD(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,A=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&A.addEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&A.addEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){A.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),A.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;A.addEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,n,{passive:!1})}}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,A=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&A.removeEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&A.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){A.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),A.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;A.removeEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,n)}}update(t){var e,n;this.unbindEvents(),super.update(t),this.r=null!==(e=t.r)&&void 0!==e?e:this.r,this.d=null!==(n=t.d)&&void 0!==n?n:this.d,this.bindEvents()}destroy(){var t;this.unbindEvents(),this.isLensOn&&(null===(t=this.lens)||void 0===t||t.destroy()),this.prevMagnifiedStyleMap.clear(),this.prevOriginStyleMap.clear(),super.destroy()}}Jz.defaultOptions={trigger:"pointermove",r:120,d:1.5,maxD:5,minD:0,showDPercent:!0,style:{},nodeStyle:{label:!0},preventDefault:!0};class tV extends Zj{constructor(t,e){super(t,Object.assign({},tV.defaultOptions,e)),this.$el=this.context.canvas.getContainer(),this.graphSize=[0,0],this.onFullscreenChange=()=>{var t,e,n,r;const i=!!document.fullscreenElement;this.options.autoFit&&this.setGraphSize(i),i?null===(e=(t=this.options).onEnter)||void 0===e||e.call(t):null===(r=(n=this.options).onExit)||void 0===r||r.call(n)},this.shortcut=new Wy(t.graph),this.bindEvents(),this.style=document.createElement("style"),document.head.appendChild(this.style),this.style.innerHTML="\n :not(:root):fullscreen::backdrop {\n background: transparent;\n }\n "}bindEvents(){this.unbindEvents(),this.shortcut.unbindAll();const{request:t=[],exit:e=[]}=this.options.trigger;this.shortcut.bind(t,this.request),this.shortcut.bind(e,this.exit);["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach(t=>{document.addEventListener(t,this.onFullscreenChange,!1)})}unbindEvents(){this.shortcut.unbindAll();["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach(t=>{document.removeEventListener(t,this.onFullscreenChange,!1)})}setGraphSize(t=!0){var e,n;let r,i;t?(r=(null===(e=globalThis.screen)||void 0===e?void 0:e.width)||0,i=(null===(n=globalThis.screen)||void 0===n?void 0:n.height)||0,this.graphSize=this.context.graph.getSize()):[r,i]=this.graphSize,this.context.graph.setSize(r,i),this.context.graph.render()}request(){!document.fullscreenElement&&(document.fullscreenEnabled||Reflect.get(document,"webkitFullscreenEnabled")||Reflect.get(document,"mozFullscreenEnabled")||Reflect.get(document,"msFullscreenEnabled"))&&this.$el.requestFullscreen().catch(t=>{Zv(`Error attempting to enable full-screen: ${t.message} (${t.name})`)})}exit(){document.fullscreenElement&&document.exitFullscreen()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.exit(),this.style.remove(),super.destroy()}}tV.defaultOptions={trigger:{},autoFit:!0};class eV extends Zj{constructor(t,e){super(t,Object.assign({},eV.defaultOptions,e)),this.$element=Jj("grid-line",!0),this.offset=[0,0],this.currentScale=1,this.followZoom=t=>{const{data:{scale:e,origin:n}}=t;if(!e||void 0===n&&void 0===this.context.viewport)return;const r=this.currentScale;this.currentScale=e;const i=e/r,o=ly(n||this.context.graph.getCanvasCenter(),1-i),A=this.baseSize*e,s=ay(my(ly(this.offset,i),A),o);this.$element.style.backgroundSize=`${A}px ${A}px`,this.$element.style.backgroundPosition=`${s[0]}px ${s[1]}px`,this.offset=my(s,A)},this.followTranslate=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)},this.onTransform=t=>{const e=this.parseFollow(this.options.follow);e.zoom&&this.followZoom(t),e.translate&&this.followTranslate(t)};this.context.canvas.getContainer().prepend(this.$element),this.baseSize=this.options.size,this.updateStyle(),this.bindEvents()}update(t){super.update(t),void 0!==t.size&&(this.baseSize=t.size),this.updateStyle()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}updateStyle(){const{stroke:t,lineWidth:e,border:n,borderLineWidth:r,borderStroke:i,borderStyle:o}=this.options,A=this.baseSize*this.currentScale;Object.assign(this.$element.style,{border:n?`${r}px ${o} ${i}`:"none",backgroundImage:`linear-gradient(${t} ${e}px, transparent ${e}px), linear-gradient(90deg, ${t} ${e}px, transparent ${e}px)`,backgroundSize:`${A}px ${A}px`,backgroundRepeat:"repeat"})}updateOffset(t){const e=this.baseSize*this.currentScale;this.offset=my(ay(this.offset,t),e),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}parseFollow(t){var e,n;return ue(t)?{translate:t,zoom:t}:{translate:null!==(e=null==t?void 0:t.translate)&&void 0!==e&&e,zoom:null!==(n=null==t?void 0:t.zoom)&&void 0!==n&&n}}destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}function nV(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach(t=>{const{type:n,value:r}=t,i=Km(r);if("NodeAdded"===n||"EdgeAdded"===n||"ComboAdded"===n)e.Added.set(i,t);else if("NodeUpdated"===n||"EdgeUpdated"===n||"ComboUpdated"===n)if(e.Added.has(i))e.Added.set(i,{type:n.replace("Updated","Added"),value:r});else if(e.Updated.has(i)){const{original:t}=e.Updated.get(i);e.Updated.set(i,{type:n,value:r,original:t})}else e.Removed.has(i)||e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)?e.Added.delete(i):e.Updated.has(i)?(e.Updated.delete(i),e.Removed.set(i,t)):e.Removed.set(i,t))}),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}function rV(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:A=[],ComboAdded:s=[],ComboUpdated:a=[],ComboRemoved:c=[]}=ee(t,t=>t.type);return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:a},remove:{nodes:r,edges:A,combos:c}}}function iV(t,e){for(const n in t)zt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),iV(t[n],e[n])):void 0===e[n]&&(e[n]=nm(n))}function oV(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:A}=rV(nV(t));return["nodes","edges","combos"].forEach(t=>{o[t]&&o[t].forEach(e=>{var i,o;const A=Object.assign({},e.value);let s=Object.assign({},e.original);if(n){const t=n.graph.getElementType(Km(e.original)),r="edge"===t?"stroke":"fill",i=n.element.getElementComputedStyle(t,e.original);s=Object.assign(Object.assign({},e.original),{style:Object.assign({[r]:i[r]},e.original.style)})}iV(A,s),(i=r.current.update)[t]||(i[t]=[]),r.current.update[t].push(A),(o=r.original.update)[t]||(o[t]=[]),r.original.update[t].push(s)}),i[t]&&i[t].forEach(e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.add)[t]||(n[t]=[]),r.current.add[t].push(o),(i=r.original.remove)[t]||(i[t]=[]),r.original.remove[t].push(o)}),A[t]&&A[t].forEach(e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.remove)[t]||(n[t]=[]),r.current.remove[t].push(o),(i=r.original.add)[t]||(i[t]=[]),r.original.add[t].push(o)})}),r}eV.defaultOptions={border:!0,borderLineWidth:1,borderStroke:"#eee",borderStyle:"solid",lineWidth:1,size:20,stroke:"#eee"};class AV extends Zj{constructor(e,n){super(e,Object.assign({},AV.defaultOptions,n)),this.batchChanges=null,this.batchAnimation=!1,this.undoStack=[],this.redoStack=[],this.freezed=!1,this.executeCommand=(t,e=!0)=>{var n,r,i;this.freezed=!0,null===(r=(n=this.options).executeCommand)||void 0===r||r.call(n,t);const o=e?t.original:t.current;this.context.graph.addData(o.add),this.context.graph.updateData(o.update),this.context.graph.removeData(zm(o.remove,!1)),null===(i=this.context.element)||void 0===i||i.draw({silence:!0,animation:t.animation}),this.freezed=!1},this.addCommand=e=>{var n;if(!this.freezed){if(e.type===t.GraphEvent.AFTER_DRAW){const{dataChanges:t=[],animation:r=!0}=e.data;if(null===(n=this.context.batch)||void 0===n?void 0:n.isBatching){if(!this.batchChanges)return;return this.batchChanges.push(t),void(this.batchAnimation&&(this.batchAnimation=r))}this.batchChanges=[t],this.batchAnimation=r}this.undoStackPush(oV(this.batchChanges.flat(),this.batchAnimation,this.context)),this.notify(t.HistoryEvent.ADD,this.undoStack[this.undoStack.length-1])}},this.initBatchCommand=t=>{const{initiate:e}=t.data;if(this.batchAnimation=!1,e)this.batchChanges=[];else{this.undoStack.pop()||(this.batchChanges=null)}},this.emitter=new lE;const{graph:r}=this.context;r.on(t.GraphEvent.AFTER_DRAW,this.addCommand),r.on(t.GraphEvent.BATCH_START,this.initBatchCommand),r.on(t.GraphEvent.BATCH_END,this.addCommand)}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}undo(){var e,n,r,i;const o=this.undoStack.pop();if(o){this.executeCommand(o);if(!1===(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,o,!1)))return;this.redoStack.push(o),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,o,!1),this.notify(t.HistoryEvent.UNDO,o)}return this}redo(){const e=this.redoStack.pop();return e&&(this.executeCommand(e,!1),this.undoStackPush(e),this.notify(t.HistoryEvent.REDO,e)),this}undoAndCancel(){const e=this.undoStack.pop();return e&&(this.executeCommand(e,!1),this.redoStack=[],this.notify(t.HistoryEvent.CANCEL,e)),this}undoStackPush(t){var e,n,r,i;const{stackSize:o}=this.options;0!==o&&this.undoStack.length>=o&&this.undoStack.shift();!1!==(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,t,!0))&&(this.undoStack.push(t),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,t,!0))}clear(){this.undoStack=[],this.redoStack=[],this.batchChanges=null,this.batchAnimation=!1,this.notify(t.HistoryEvent.CLEAR,null)}notify(e,n){this.emitter.emit(e,{cmd:n}),this.emitter.emit(t.HistoryEvent.CHANGE,{cmd:n})}on(t,e){this.emitter.on(t,e)}destroy(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.addCommand),e.off(t.GraphEvent.BATCH_START,this.initBatchCommand),e.off(t.GraphEvent.BATCH_END,this.addCommand),this.emitter.off(),super.destroy(),this.undoStack=[],this.redoStack=[]}}AV.defaultOptions={stackSize:0};const sV={toXy(t,e){if(!e)return[...t];const n=e[0].slice(1),r=e[1].slice(1);return t.map(t=>[t[n],t[r]])},fromXy(t,e){if(!e)return[...t];const n=e[0].slice(1),r=e[1].slice(1);return t.map(([t,e])=>({[n]:t,[r]:e}))}};let aV=class{constructor(t,e){this._cells=[],this._cellSize=e,this._reverseCellSize=1/e;for(const e of t){const t=this.coordToCellNum(e[0]),n=this.coordToCellNum(e[1]);this._cells[t]||(this._cells[t]=[]),this._cells[t][n]||(this._cells[t][n]=[]),this._cells[t][n].push(e)}}cellPoints(t,e){var n;return(null===(n=this._cells[t])||void 0===n?void 0:n[e])||[]}rangePoints(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this.coordToCellNum(t[2]),i=this.coordToCellNum(t[3]),o=[];for(let t=e;t<=r;t++)for(let e=n;e<=i;e++){const n=this.cellPoints(t,e);for(const t of n)o.push(t)}return o}removePoint(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this._cells[e][n],i=r.findIndex(([e,n])=>e===t[0]&&n===t[1]);return i>-1&&r.splice(i,1),r}trunc(t){return Math.trunc(t)}coordToCellNum(t){return this.trunc(t*this._reverseCellSize)}extendBbox(t,e){return[t[0]-e*this._cellSize,t[1]-e*this._cellSize,t[2]+e*this._cellSize,t[3]+e*this._cellSize]}};const cV=+(Math.pow(2,27)+1);function lV(t,e,n){const r=t*e,i=cV*t,o=i-(i-t),A=t-o,s=cV*e,a=s-(s-e),c=e-a,l=A*c-(r-o*a-A*a-o*c);return n?(n[0]=l,n[1]=r,n):[l,r]}function uV(t,e,n){const r=t+e,i=r-t,o=e-i,A=t-(r-i);return n?(n[0]=A+o,n[1]=r,n):[A+o,r]}function hV(t,e){const n=t.length;if(1===n){const n=lV(t[0],e);return n[0]?n:[n[1]]}const r=new Array(2*n),i=[.1,.1],o=[.1,.1];let A=0;lV(t[0],e,i),i[0]&&(r[A++]=i[0]);for(let s=1;s<n;++s){lV(t[s],e,o);uV(i[1],o[0],i),i[0]&&(r[A++]=i[0]);const n=o[1],a=i[1],c=n+a,l=a-(c-n);i[1]=c,l&&(r[A++]=l)}return i[1]&&(r[A++]=i[1]),0===A&&(r[A++]=0),r.length=A,r}function dV(t,e){const n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){const n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],-e[0]);const i=new Array(n+r);let o=0,A=0,s=0;const a=Math.abs;let c,l,u=t[A],h=a(u),d=-e[s],f=a(d);h<f?(l=u,A+=1,A<n&&(u=t[A],h=a(u))):(l=d,s+=1,s<r&&(d=-e[s],f=a(d))),A<n&&h<f||s>=r?(c=u,A+=1,A<n&&(u=t[A],h=a(u))):(c=d,s+=1,s<r&&(d=-e[s],f=a(d)));let g,p,v,m,y,w=c+l,b=w-c,B=l-b,E=B,x=w;for(;A<n&&s<r;)h<f?(c=u,A+=1,A<n&&(u=t[A],h=a(u))):(c=d,s+=1,s<r&&(d=-e[s],f=a(d))),l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g;for(;A<n;)c=u,l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g,A+=1,A<n&&(u=t[A]);for(;s<r;)c=d,l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g,s+=1,s<r&&(d=-e[s]);return E&&(i[o++]=E),x&&(i[o++]=x),o||(i[o++]=0),i.length=o,i}function fV(t,e){const n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){const n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],e[0]);const i=new Array(n+r);let o=0,A=0,s=0;const a=Math.abs;let c,l,u=t[A],h=a(u),d=e[s],f=a(d);h<f?(l=u,A+=1,A<n&&(u=t[A],h=a(u))):(l=d,s+=1,s<r&&(d=e[s],f=a(d))),A<n&&h<f||s>=r?(c=u,A+=1,A<n&&(u=t[A],h=a(u))):(c=d,s+=1,s<r&&(d=e[s],f=a(d)));let g,p,v,m,y,w=c+l,b=w-c,B=l-b,E=B,x=w;for(;A<n&&s<r;)h<f?(c=u,A+=1,A<n&&(u=t[A],h=a(u))):(c=d,s+=1,s<r&&(d=e[s],f=a(d))),l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g;for(;A<n;)c=u,l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g,A+=1,A<n&&(u=t[A]);for(;s<r;)c=d,l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g,s+=1,s<r&&(d=e[s]);return E&&(i[o++]=E),x&&(i[o++]=x),o||(i[o++]=0),i.length=o,i}function gV(t,e,n,r){return function(n,i,o){const A=t(t(e(i[1],o[0]),e(-o[1],i[0])),t(e(n[1],i[0]),e(-i[1],n[0]))),s=t(e(n[1],o[0]),e(-o[1],n[0])),a=r(A,s);return a[a.length-1]}}function pV(t,e,n,r){return function(i,o,A,s){const a=t(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),s[2]))),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2])))),c=t(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),s[2]))),t(n(t(e(o[1],A[0]),e(-A[1],o[0])),i[2]),t(n(t(e(i[1],A[0]),e(-A[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),A[2])))),l=r(a,c);return l[l.length-1]}}function vV(t,e,n,r){return function(i,o,A,s,a){const c=t(t(t(n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),A[2]),t(n(t(e(A[1],a[0]),e(-a[1],A[0])),-s[2]),n(t(e(A[1],s[0]),e(-s[1],A[0])),a[2]))),o[3]),t(n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),o[2]),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),-s[2]),n(t(e(o[1],s[0]),e(-s[1],o[0])),a[2]))),-A[3]),n(t(n(t(e(A[1],a[0]),e(-a[1],A[0])),o[2]),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),a[2]))),s[3]))),t(n(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),s[2]))),-a[3]),t(n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),o[2]),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),-s[2]),n(t(e(o[1],s[0]),e(-s[1],o[0])),a[2]))),i[3]),n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-s[2]),n(t(e(i[1],s[0]),e(-s[1],i[0])),a[2]))),-o[3])))),t(t(n(t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2]))),s[3]),t(n(t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2]))),-a[3]),n(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),s[2]))),i[3]))),t(n(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),s[2]))),-o[3]),t(n(t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2]))),A[3]),n(t(n(t(e(o[1],A[0]),e(-A[1],o[0])),i[2]),t(n(t(e(i[1],A[0]),e(-A[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),A[2]))),-s[3]))))),l=t(t(t(n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),A[2]),t(n(t(e(A[1],a[0]),e(-a[1],A[0])),-s[2]),n(t(e(A[1],s[0]),e(-s[1],A[0])),a[2]))),i[3]),n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-s[2]),n(t(e(i[1],s[0]),e(-s[1],i[0])),a[2]))),-A[3])),t(n(t(n(t(e(A[1],a[0]),e(-a[1],A[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),a[2]))),s[3]),n(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),s[2]))),-a[3]))),t(t(n(t(n(t(e(A[1],a[0]),e(-a[1],A[0])),o[2]),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),a[2]))),i[3]),n(t(n(t(e(A[1],a[0]),e(-a[1],A[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),a[2]))),-o[3])),t(n(t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2]))),A[3]),n(t(n(t(e(o[1],A[0]),e(-A[1],o[0])),i[2]),t(n(t(e(i[1],A[0]),e(-A[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),A[2]))),-a[3])))),u=r(c,l);return u[u.length-1]}}function mV(t){return(3===t?gV:4===t?pV:vV)(fV,lV,hV,dV)}const yV=mV(3),wV=mV(4),bV=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,n){const r=(t[1]-n[1])*(e[0]-n[0]),i=(t[0]-n[0])*(e[1]-n[1]),o=r-i;let A;if(r>0){if(i<=0)return o;A=r+i}else{if(!(r<0))return o;if(i>=0)return o;A=-(r+i)}const s=33306690738754716e-32*A;return o>=s||o<=-s?o:yV(t,e,n)},function(t,e,n,r){const i=t[0]-r[0],o=e[0]-r[0],A=n[0]-r[0],s=t[1]-r[1],a=e[1]-r[1],c=n[1]-r[1],l=t[2]-r[2],u=e[2]-r[2],h=n[2]-r[2],d=o*c,f=A*a,g=A*s,p=i*c,v=i*a,m=o*s,y=l*(d-f)+u*(g-p)+h*(v-m),w=7771561172376103e-31*((Math.abs(d)+Math.abs(f))*Math.abs(l)+(Math.abs(g)+Math.abs(p))*Math.abs(u)+(Math.abs(v)+Math.abs(m))*Math.abs(h));return y>w||-y>w?y:wV(t,e,n,r)}];function BV(t){let e=bV[t.length];return e||(e=bV[t.length]=mV(t.length)),e.apply(void 0,...t)}var EV=function(){for(;bV.length<=5;)bV.push(mV(bV.length));const t=function(t,e,n,r,i,o,A){return function(...e){switch(e.length){case 0:case 1:return 0;case 2:return r(e[0],e[1]);case 3:return i(e[0],e[1],e[2]);case 4:return o(e[0],e[1],e[2],e[3]);case 5:return A(e[0],e[1],e[2],e[3],e[4])}return t(e)}}(void 0,BV,...bV);for(let e=0;e<=5;++e)t[e]=bV[e];return t}();const xV=EV[3];function CV(t,e,n,r){const i=EV(t,n,r),o=EV(e,n,r);if(i>0&&o>0||i<0&&o<0)return!1;const A=EV(n,t,e),s=EV(r,t,e);return!(A>0&&s>0||A<0&&s<0)&&(0!==i||0!==o||0!==A||0!==s||function(t,e,n,r){for(let i=0;i<2;++i){const o=t[i],A=e[i],[s,a]=[Math.min(o,A),Math.max(o,A)],c=n[i],l=r[i],[u,h]=[Math.min(c,l),Math.max(c,l)];if(h<s||a<u)return!1}return!0}(t,e,n,r))}function MV(t,e){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function FV(t,e,n){const r=[e[0]-t[0],e[1]-t[1]],i=[n[0]-t[0],n[1]-t[1]],o=MV(t,e),A=MV(t,n);return(r[0]*i[0]+r[1]*i[1])/Math.sqrt(o*A)}function kV(t,e){for(let n=0;n<e.length-1;n++){const r=[e[n],e[n+1]];if(!(t[0][0]===r[0][0]&&t[0][1]===r[0][1]||t[0][0]===r[1][0]&&t[0][1]===r[1][1])&&CV(t[0],t[1],r[0],r[1]))return!0}return!1}function SV(t){return[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]}function QV(t,e,n){let r,i,o=null,A=TV,s=TV;for(let a=0;a<e.length;a++)r=FV(t[0],t[1],e[a]),i=FV(t[1],t[0],e[a]),r>A&&i>s&&!kV([t[0],e[a]],n)&&!kV([t[1],e[a]],n)&&(A=r,s=i,o=e[a]);return o}function UV(t,e,n,r,i){let o=!1;for(let A=0;A<t.length-1;A++){const s=[t[A],t[A+1]],a=s[0][0]+","+s[0][1]+","+s[1][0]+","+s[1][1];if(MV(s[0],s[1])<e||i.has(a))continue;let c,l,u,h=0,d=SV(s);do{d=r.extendBbox(d,h),c=d[2]-d[0],l=d[3]-d[1],u=QV(s,r.rangePoints(d),t),h++}while(null===u&&(n[0]>c||n[1]>l));c>=n[0]&&l>=n[1]&&i.add(a),null!==u&&(t.splice(A+1,0,u),r.removePoint(u),o=!0)}return o?UV(t,e,n,r,i):t}function NV(t,e,n){const r=e||20,i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];n[0]===i[0]&&n[1]===i[1]||e.push(i),n=i}return e}(function(t){return t.sort(function(t,e){return t[0]-e[0]||t[1]-e[1]})}(sV.toXy(t,n)));if(i.length<4){const t=i.concat([i[0]]);return n?sV.fromXy(t,n):t}const o=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=t.length-1;o>=0;o--)t[o][0]<e&&(e=t[o][0]),t[o][1]<n&&(n=t[o][1]),t[o][0]>r&&(r=t[o][0]),t[o][1]>i&&(i=t[o][1]);return[r-e,i-n]}(i),A=[o[0]*OV,o[1]*OV],s=function(t){const e=t.length;if(e<3){const n=new Array(e);for(let t=0;t<e;++t)n[t]=t;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:n}const n=new Array(e);for(let t=0;t<e;++t)n[t]=t;n.sort((e,n)=>t[e][0]-t[n][0]||t[e][1]-t[n][1]);const r=[n[0],n[1]],i=[n[0],n[1]];for(let o=2;o<e;++o){const e=n[o],A=t[e];let s=r.length;for(;s>1&&xV(t[r[s-2]],t[r[s-1]],A)<=0;)s-=1,r.pop();for(r.push(e),s=i.length;s>1&&xV(t[i[s-2]],t[i[s-1]],A)>=0;)s-=1,i.pop();i.push(e)}const o=new Array(i.length+r.length-2);let A=0;for(let t=0,e=r.length;t<e;++t)o[A++]=r[t];for(let t=i.length-2;t>0;--t)o[A++]=i[t];return o}(i).reverse().map(t=>i[t]);s.push(s[0]);const a=i.filter(function(t){return s.indexOf(t)<0}),c=Math.ceil(1/(i.length/(o[0]*o[1]))),l=UV(s,Math.pow(r,2),A,function(t,e){return new aV(t,e)}(a,c),new Set);return n?sV.fromXy(l,n):l}const TV=Math.cos(90/(180/Math.PI)),OV=.6;const IV=(t,e,n)=>{if("sharp"===n)return[["M",t[0]-e,t[1]-e],["L",t[0]+e,t[1]-e],["L",t[0]+e,t[1]+e],["L",t[0]-e,t[1]+e],["Z"]];const r=[e,e,0,0,0];return[["M",t[0],t[1]-e],["A",...r,t[0],t[1]+e],["A",...r,t[0],t[1]-e]]},LV=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?ay(t[0],hy(gy(cy(t[0],t[1])),e)):t[0],o="sharp"===n?ay(t[1],hy(gy(cy(t[1],t[0])),e)):t[1],A=hy(gy(vy(cy(i,o),!1)),e),s=hy(A,-1),a=ay(i,A),c=ay(o,A),l=ay(o,s),u=ay(i,s);return"sharp"===n?[["M",a[0],a[1]],["L",c[0],c[1]],["L",l[0],l[1]],["L",u[0],u[1]],["Z"]]:[["M",a[0],a[1]],["L",c[0],c[1]],["A",...r,l[0],l[1]],["L",u[0],u[1]],["A",...r,a[0],a[1]]]},PV=(t,e)=>{const n=_y(t).map((n,r)=>{const i=(r-2+t.length)%t.length,o=(r-1+t.length)%t.length,A=(r+1)%t.length,s=t[i],a=t[o],c=t[A],l=cy(s,a),u=cy(a,n),h=cy(n,c),d=(t,e)=>py(t,e,!0)<Math.PI,f=d(l,u),g=d(u,h),p=t=>hy(gy(vy(t,!1)),e),v=p(u);return[{p:yy(ay(a,f?p(l):v)),concave:f&&a},{p:yy(ay(n,g?p(h):v)),concave:g&&n}]}),r=[e,e,0,0,0],i=n.findIndex((t,e)=>!(n[(e-1+n.length)%n.length][0].concave||n[(e-1+n.length)%n.length][1].concave||t[0].concave||t[0].concave||t[1].concave)),o=n.slice(i).concat(n.slice(0,i));let A=[];return o.flatMap((t,e)=>{const i=[],s=o[n.length-1];return 0===e&&i.push(["M",...s[1].p]),t[0].concave?A.push(t[0].p,t[1].p):i.push(["A",...r,...t[0].p]),t[1].concave?A.unshift(t[1].p):i.push(["L",...t[1].p]),3===A.length&&(i.pop(),i.push(["C",...A.flat()]),A=[]),i})},DV=(t,e)=>{const n=_y(t).map((e,n)=>({p:e,v:gy(cy(t[(n+1)%t.length],e))}));return n.forEach((r,i)=>{const o=i>0?i-1:t.length-1,A=n[o].v,s=gy(ay(A,hy(r.v,py(A,r.v,!0)<Math.PI?1:-1)));r.p=ay(r.p,hy(s,e))}),Ew(n.map(t=>t.p))},RV=(t,e)=>{const n=t.map((n,r)=>{const i=t[0===r?t.length-1:r-1],o=wy(hy(gy(vy(cy(i,n),!1)),e));return[ay(i,o),ay(n,o)]}),r=n.flat(),i=r.map((t,e)=>{if(e%2==0)return null;return xy([r[(e-1)%r.length],r[e%r.length]],[r[(e+1)%r.length],r[(e+2)%r.length]],!0)}).filter(Boolean);return i.map((t,e)=>[0===e?"M":"L",t[0],t[1]]).concat([["Z"]])};class HV extends Zj{constructor(t,e){super(t,Object.assign({},HV.defaultOptions,e)),this.hullMemberIds=[],this.drawHull=()=>{if(this.shape){const t=!xe(this.optionsCache,this.options);this.shape.update(this.getHullStyle(t))}else this.shape=new xw({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape);this.optionsCache=Object.assign({},this.options)},this.updateHullPath=t=>{this.shape&&this.options.members.includes(Km(t.data))&&this.shape.update({d:this.getHullPath(!0)})},this.getHullPath=(t=!1)=>{const{graph:e}=this.context,n=this.getMember();if(0===n.length)return"";const r=n.map(t=>e.getNodeData(t)),i=NV(r.map(My),this.options.concavity).slice(1).reverse(),o=i.flatMap(t=>r.filter(e=>xe(My(e),t)).map(Km));return xe(o,this.hullMemberIds)&&!t||(this.hullMemberIds=o,this.path=function(t,e,n){if(1===t.length)return IV(t[0],e,n);if(2===t.length)return LV(t,e,n);if(3===t.length){const[r,i,o]=_y(t);if(Iy(r,i,o))return LV([r,o],e,n)}switch(n){case"smooth":return DV(t,e);case"sharp":return RV(t,e);default:return PV(t,e)}}(i,this.getPadding(),this.options.corner)),this.path},this.bindEvents()}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}unbindEvents(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}getHullStyle(t){const e=this.options,{members:n,padding:r,corner:i}=e,o=Pe(e,["members","padding","corner"]);return Object.assign(Object.assign({},o),{d:this.getHullPath(t)})}getPadding(){const{graph:t}=this.context,e=this.hullMemberIds.reduce((e,n)=>{const{halfExtents:r}=t.getElementRenderBounds(n),i=Math.max(r[0],r[1]);return Math.max(e,i)},0);return e+this.options.padding}addMember(t){const e=Array.isArray(t)?t:[t];this.options.members=[...new Set([...this.options.members,...e])],this.shape.update({d:this.getHullPath()})}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter(t=>!e.includes(t)),e.some(t=>this.hullMemberIds.includes(t))&&this.shape.update({d:this.getHullPath()})}updateMember(t){this.options.members=Gt(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}getMember(){return this.options.members}destroy(){this.unbindEvents(),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function _V(t,e){e(t),t.children&&t.children.forEach(function(t){t&&_V(t,e)})}function GV(t){jV(t,!0)}function KV(t){jV(t,!1)}function jV(t,e){var n=e?"visible":"hidden";_V(t,function(t){t.attr("visibility",n)})}HV.defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",fillOpacity:.2,labelOpacity:1,stroke:"blue",strokeOpacity:.2};var zV=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,_e([],He(e),!1))||this;return r.isMutationObserved=!0,r.addEventListener(ea.INSERTED,function(){KV(r)}),r}return Ie(e,t),e}(Xa);function VV(t){var e=t.appendChild(new zV({class:"offscreen"}));return KV(e),e}var WV=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=Pe(e,["style"]);return t.call(this,Le({style:Le({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return Ie(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=VV(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(cc);function YV(t){return t*Math.PI/180}function XV(t){return Number((180*t/Math.PI).toPrecision(5))}var qV=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=n,this.height=r}return Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y},enumerable:!1,configurable:!0}),t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t.prototype.toJSON=function(){return{x:this.x,y:this.y,width:this.width,height:this.height,top:this.top,right:this.right,bottom:this.bottom,left:this.left}},t.prototype.isPointIn=function(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom},t}();function $V(t,e){return Gt(t)?t.apply(void 0,_e([],He(e),!1)):t}var ZV,JV=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map(function(t){var e=He(t,2),r=e[0],i=e[1],o=n(i);return[r,{name:o,class:".".concat(o),id:"#".concat(o),toString:function(){return o}}]}));return Object.assign(r,{prefix:n}),r},tW=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach(function(i){var o=He(i,2),A=o[0],s=o[1],a=t;Object.prototype.hasOwnProperty.call(e,A)&&(s?qt(s)?(qt(t[A])||(a[A]={}),n<r?tW(t[A],s,n+1,r):a[A]=e[A]):jt(s)?(a[A]=[],a[A]=a[A].concat(s)):a[A]=s:a[A]=s)})},eW=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)tW(t,e[r]);return t},nW=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},rW=me(function(t,e){var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,A=e.fontVariant;return ZV||(ZV=Ua.offscreenCanvasCreator.getOrCreateContext(void 0)),ZV.font=[o,A,i,"".concat(n,"px"),r].join(" "),ZV.measureText(t).width},function(t,e){return[t,Object.values(e||iW(t)).join()].join("")},4096),iW=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 oW(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function AW(t,e){var n=oW(t);n&&n.attr(e)}function sW(t,e,n){void 0===n&&(n="..."),AW(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function aW(t){var e=t.nativeEvent,n=t.touches,r=t.clientX,i=t.clientY;if(e)return[e.clientX,e.clientY];if(n){var o=n[0];return[o.clientX,o.clientY]}return"number"==typeof r&&"number"==typeof i?[r,i]:[0,0]}function cW(t){return"function"==typeof t?t():Jt(t)||re(t)?new WV({style:{text:String(t)}}):t}function lW(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 uW(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=!1),!!(r&&t===e||i&&t===n)||t>e&&t<n}function hW(t,e){return"number"==typeof t&&"number"==typeof e?function(t,e){return function(n){return t*(1-n)+e*n}}(t,e):Array.isArray(t)&&Array.isArray(e)?function(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0;return function(i){var o=new Array(r),A=new Array(n),s=0;for(s=0;s<r;++s)o[s]=hW(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=He(e,2),o=i[0],A=i[1];o in t?n[o]=hW(t[o],A):r[o]=A}),function(t){return Object.entries(n).forEach(function(e){var n=He(e,2),i=n[0],o=n[1];return r[i]=o(t)}),r}}(t,e):function(e){return t}}function dW(t,e){return[t[0]*e,t[1]*e]}function fW(t,e){return[t[0]+e[0],t[1]+e[1]]}function gW(t,e){return[t[0]-e[0],t[1]-e[1]]}function pW(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function vW(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function mW(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function yW(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 wW(t,e){return+t.toPrecision(e)}function bW(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 BW(t,e,n){void 0===n&&(n=[[0,0],[1,1]]);for(var r=[],i=0,o=t.length;i<o;i+=2)r.push([t[i],t[i+1]]);var A,s,a,c=function(t,e,n,r){var i,o,A,s,a,c,l=[],u=!!r,h=[1/0,1/0],d=[-1/0,-1/0];if(u){h=(i=He(r,2))[0],d=i[1];for(var f=0,g=t.length;f<g;f+=1)h=pW(h,v=t[f]),d=vW(d,v)}f=0;for(var p=t.length;f<p;f+=1){var v=t[f];if(0===f)c=v;else if(f===p-1)a=v,l.push(c),l.push(a);else{o=t[f-1];var m=[0,0];m=dW(m=gW(A=t[f+1],o),e);var y=mW(v,o),w=mW(v,A),b=y+w;0!==b&&(y/=b,w/=b);var B=dW(m,-y),E=dW(m,w);a=fW(v,B),s=pW(s=fW(v,E),vW(A,v)),s=vW(s,pW(A,v)),a=pW(a=fW(v,B=dW(B=gW(s,v),-y/w)),vW(o,v)),s=fW(v,E=dW(E=gW(v,a=vW(a,pW(o,v))),w/y)),u&&(a=pW(a=vW(a,h),d),s=pW(s=vW(s,h),d)),l.push(c),l.push(a),c=s}}return l}(r,.4,0,n),l=r.length,u=[];for(i=0;i<l-1;i+=1)A=c[2*i],s=c[2*i+1],a=r[i+1],u.push(["C",A[0],A[1],s[0],s[1],a[0],a[1]]);return u}var EW=["$el","cx","cy","d","dx","dy","fill","fillOpacity","filter","fontFamily","fontSize","fontStyle","fontVariant","fontWeight","height","img","increasedLineWidthForHitTesting","innerHTML","isBillboard","billboardRotation","isSizeAttenuation","isClosed","isOverflowing","leading","letterSpacing","lineDash","lineHeight","lineWidth","markerEnd","markerEndOffset","markerMid","markerStart","markerStartOffset","maxLines","metrics","miterLimit","offsetX","offsetY","opacity","path","points","r","radius","rx","ry","shadowColor","src","stroke","strokeOpacity","text","textAlign","textBaseline","textDecorationColor","textDecorationLine","textDecorationStyle","textOverflow","textPath","textPathSide","textPathStartOffset","transform","transformOrigin","visibility","width","wordWrap","wordWrapWidth","x","x1","x2","y","y1","y2","z1","z2","zIndex"];function xW(t){return EW.includes(t)}function CW(t){var e={};for(var n in t)xW(n)&&(e[n]=t[n]);return e}function MW(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,A=e/Math.max(i,o);return t.style.transform="scale(".concat(A,")"),A}var FW=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=He(Array.isArray(A)?A:[A,null],2),a=s[0],c=s[1];(u=r(a,o)).__data__=a,null!==c&&(u.__fromElements__=c),this._parent.appendChild(u),i.push(u)}return new n(i,null,this._parent,this._document)}for(o=0;o<this._elements.length;o++){var l=this._elements[o],u=r(a=l.__data__,o);l.appendChild(u),i.push(u)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=Ge(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=Ge(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=Ge(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,a,c=[],l=[],u=new Set(this._elements),h=[],d=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]})),p=(A=this._elements,s=function(t){return r(t.__data__)},a=new Map,A.forEach(function(t){var e=s(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}),a),v=0;v<t.length;v++){var m=t[v],y=e(m,v),w=r(m,v);if(f.has(y))(x=f.get(y)).__data__=m,x.__facet__=!1,l.push(x),u.delete(x),f.delete(y);else if(g.has(y)){(x=g.get(y)).__data__=m,x.__facet__=!0,l.push(x),g.delete(y)}else if(p.has(y)){var b=p.get(y);h.push([m,b]);try{for(var B=(i=void 0,Re(b)),E=B.next();!E.done;E=B.next()){var x=E.value;u.delete(x)}}catch(t){i={error:t}}finally{try{E&&!E.done&&(o=B.return)&&o.call(B)}finally{if(i)throw i.error}}p.delete(y)}else if(f.has(w)){(x=f.get(w)).__toData__?x.__toData__.push(m):x.__toData__=[m],d.add(x),u.delete(x)}else c.push(m)}var C=[new n([],c,this._parent,this._document),new n(l,null,this._parent,this._document),new n(u,null,this._parent,this._document),new n([],h,this._parent,this._document),new n(d,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,C)},t.prototype.merge=function(t){var e=_e(_e([],He(this._elements),!1),He(t._elements),!1),r=_e(_e([],He(this._transitions),!1),He(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),a=r(this._merge),c=i(this._split);return A.merge(o).merge(s).merge(a).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=He(t,2),A=o[0],s=o[1],a="function"==typeof s&&e?s:function(){return s};void 0!==s&&i.attr(A,a.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){this._transitions;var e=new Array(this._elements.length);return this.each(function(n,r){e[r]=t.call(this,n,r)}),this._transitions=function(t){if(!jt(t))return[];for(var e=[],n=0;n<t.length;n++)e=e.concat(t[n]);return e}(e),this},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,_e([this._parent,this],He(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:Xa,rect:sc,circle:za,path:nc,text:WV,ellipse:Ya,image:Za,line:tc,polygon:ic,polyline:Ac,html:$a},t}();function kW(t){return new FW([t],null,t,t.ownerDocument)}function SW(t){if(re(t))return[t,t,t,t];if(jt(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 QW(t){var e=t.getLocalBounds(),n=He([e.min,e.max],2),r=He(n[0],2),i=r[0],o=r[1],A=He(n[1],2),s=A[0],a=A[1];return{x:i,y:o,width:s-i,height:a-o,left:i,bottom:a,top:o,right:s}}function UW(t,e){var n=He(t,2),r=n[0],i=n[1],o=He(e,2),A=o[0],s=o[1];return r!==A&&i===s}function NW(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function TW(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 OW=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function IW(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach(function(t){var i=He(t,2),o=i[0],A=i[1];if("className"===o||"class"===o);else if(OW(o,"show")&&OW(TW(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(NW(t))}(e,"show")?r[o]=A:r[o.replace(new RegExp(NW(e)),"")]=A;else if(!OW(o,"show")&&OW(o,e)!==n){var s=TW(o,e);"filter"===s&&"function"==typeof A||(r[s]=A)}}),r}function LW(t,e){return Object.entries(t).reduce(function(t,n){var r=He(n,2),i=r[0],o=r[1];return i.startsWith("show")?t["show".concat(e).concat(i.slice(4))]=o:t["".concat(e).concat(NW(i))]=o,t},{})}function PW(t,e){void 0===e&&(e=["x","y","class","className"]);var n=["transform","transformOrigin","anchor","visibility","pointerEvents","zIndex","cursor","clipPath","clipPathTargets","offsetPath","offsetPathTargets","offsetDistance","draggable","droppable"],r={},i={};return Object.entries(t).forEach(function(t){var o=He(t,2),A=o[0],s=o[1];e.includes(A)||(-1!==n.indexOf(A)?i[A]=s:r[A]=s)}),[r,i]}function DW(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 RW(t,e){if(e)try{var n=e.replace(/translate\(([+-]*[\d]+[%]*),[ ]*([+-]*[\d]+[%]*)\)/g,function(e,n,r){return"translate(".concat(function(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,A=He([e,n].map(function(t,e){var n;return t.includes("%")?parseFloat((null===(n=t.match(/[+-]?([0-9]*[.])?[0-9]+/))||void 0===n?void 0:n[0])||"0")/100*(0===e?i:o):t}),2);return[A[0],A[1]]}(t,n,r),")")});t.attr("transform",n)}catch(t){}}var HW=function(t,e){null!=e?t.replaceChildren?Array.isArray(e)?t.replaceChildren.apply(t,_e([],He(e),!1)):t.replaceChildren(e):(t.innerHTML="",Array.isArray(e)?e.forEach(function(e){return t.appendChild(e)}):t.appendChild(e)):t.innerHTML=""};function _W(t){return/\S+-\S+/g.test(t)?t.split("-").map(function(t){return t[0]}):t.length>2?[t[0]]:t.split("")}function GW(){jV(this,"hidden"!==this.attributes.visibility)}var KW=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,eW({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return Ie(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=VV(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&&GW.call(this)},e.prototype.update=function(t,e){var n;return this.attr(eW({},this.attributes,t||{})),null===(n=this.render)||void 0===n?void 0:n.call(this,this.attributes,this,e)},e.prototype.clear=function(){this.removeChildren()},e.prototype.bindEvents=function(t,e){},e.prototype.getSubShapeStyle=function(t){return t.x,t.y,t.transform,t.transformOrigin,t.class,t.className,t.zIndex,Pe(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(Wa),jW=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"]]},zW=jW,VW=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},WW=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},YW=WW;var XW=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function qW(t){var e=function(t){var e="default";if(zt(t)&&t instanceof Image)e="image";else if(Gt(t))e="symbol";else if(Jt(t)){var n=new RegExp("data:(image|text)");e=t.match(n)?"base64":/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(t)?"url":"symbol"}return e}(t);return["base64","url","image"].includes(e)?"image":t&&"symbol"===e?"path":null}var $W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,n){var r=t.x,i=void 0===r?0:r,o=t.y,A=void 0===o?0:o,s=this.getSubShapeStyle(t),a=s.symbol,c=s.size,l=void 0===c?16:c,u=Pe(s,["symbol","size"]),h=qW(a);lW(!!h,kW(n),function(t){t.maybeAppendByClassName("marker",h).attr("className","marker ".concat(h,"-marker")).call(function(t){if("image"===h){var n=2*l;t.styles({img:a,width:n,height:n,x:i-l,y:A-l})}else{n=l/2;var r=Gt(a)?a:e.getSymbol(a);t.styles(Le({d:null==r?void 0:r(i,A,n)},u))}})})},e.MARKER_SYMBOL_MAP=new Map,e.registerSymbol=function(t,n){e.MARKER_SYMBOL_MAP.set(t,n)},e.getSymbol=function(t){return e.MARKER_SYMBOL_MAP.get(t)},e.getSymbols=function(){return Array.from(e.MARKER_SYMBOL_MAP.keys())},e}(KW);function ZW(t,...e){return e.reduce((t,e)=>n=>t(e(n)),t)}function JW(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}$W.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]]}),$W.registerSymbol("hyphen",function(t,e,n){return[["M",t-n,e],["L",t+n,e]]}),$W.registerSymbol("line",VW),$W.registerSymbol("plus",function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]}),$W.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]]}),$W.registerSymbol("circle",jW),$W.registerSymbol("point",zW),$W.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"]]}),$W.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"]]}),$W.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"]]}),$W.registerSymbol("diamond",function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]}),$W.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"]]}),$W.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"]]}),$W.registerSymbol("line",VW),$W.registerSymbol("dot",WW),$W.registerSymbol("dash",YW),$W.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]]}),$W.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]]}),$W.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]]}),$W.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]]}),$W.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]]}),$W.registerSymbol("focus",function(t,e,n){var r=.2*n,i=.7*n;return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"],["M",t-i,e],["L",t-r,e],["M",t+r,e],["L",t+i,e],["M",t,e-i],["L",t,e-r],["M",t,e+r],["L",t,e+i]]});const tY=Math.sqrt(50),eY=Math.sqrt(10),nY=Math.sqrt(2);function rY(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>=tY?10:o>=eY?5:o>=nY?2:1)*10**i:-(10**-i)/(o>=tY?10:o>=eY?5:o>=nY?2:1)}const iY=(t,e,n=5)=>{const r=[t,e];let i,o=0,A=r.length-1,s=r[o],a=r[A];return a<s&&([s,a]=[a,s],[o,A]=[A,o]),i=rY(s,a,n),i>0?(s=Math.floor(s/i)*i,a=Math.ceil(a/i)*i,i=rY(s,a,n)):i<0&&(s=Math.ceil(s*i)/i,a=Math.floor(a*i)/i,i=rY(s,a,n)),i>0?(r[o]=Math.floor(s/i)*i,r[A]=Math.ceil(a/i)*i):i<0&&(r[o]=Math.ceil(s*i)/i,r[A]=Math.floor(a*i)/i),r};function oY(t){return!(de(t)||(e=t,null===e)||Number.isNaN(t));var e}var AY={exports:{}},sY={exports:{}},aY=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},cY=Array.prototype.concat,lY=Array.prototype.slice,uY=sY.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];aY(i)?e=cY.call(e,lY.call(i)):e.push(i)}return e};uY.wrap=function(t){return function(){return t(uY(arguments))}};var hY=sY.exports,dY={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]},fY=hY,gY=Object.hasOwnProperty,pY=Object.create(null);for(var vY in dY)gY.call(dY,vY)&&(pY[dY[vY]]=vY);var mY=AY.exports={to:{},get:{}};function yY(t,e,n){return Math.min(Math.max(e,t),n)}function wY(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}mY.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=mY.get.hsl(t),n="hsl";break;case"hwb":e=mY.get.hwb(t),n="hwb";break;default:e=mY.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},mY.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;i[n]=parseInt(e.slice(o,o+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:gY.call(dY,e[1])?((i=dY[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=yY(i[n],0,255);return i[3]=yY(i[3],0,1),i},mY.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,yY(parseFloat(e[2]),0,100),yY(parseFloat(e[3]),0,100),yY(isNaN(n)?1:n,0,1)]}return null},mY.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,yY(parseFloat(e[2]),0,100),yY(parseFloat(e[3]),0,100),yY(isNaN(n)?1:n,0,1)]}return null},mY.to.hex=function(){var t=fY(arguments);return"#"+wY(t[0])+wY(t[1])+wY(t[2])+(t[3]<1?wY(Math.round(255*t[3])):"")},mY.to.rgb=function(){var t=fY(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]+")"},mY.to.rgb.percent=function(){var t=fY(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]+")"},mY.to.hsl=function(){var t=fY(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},mY.to.hwb=function(){var t=fY(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},mY.to.keyword=function(t){return pY[t.slice(0,3)]};var bY=y(AY.exports);function BY(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 EY(t){const e=bY.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*BY(A,o,e+1/3),255*BY(A,o,e),255*BY(A,o,e-1/3),i]}(r):null}const xY=(t,e)=>n=>t*(1-n)+e*n,CY=(t,e)=>"number"==typeof t&&"number"==typeof e?xY(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=EY(t),r=EY(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,MY=(t,e)=>{const n=xY(t,e);return t=>Math.round(n(t))};function FY({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function kY(t){return"object"==typeof t?t.valueOf():t}class SY extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=kY,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(FY({map:this.map,initKey:this.initKey},t))}has(t){return super.has(FY({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 QY{constructor(t){this.options=be({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=be({},this.options,t),this.rescale(t)}rescale(t){}}const UY=Symbol("defaultUnknown");function NY(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function TY(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let A=i.get(e);if(void 0===A){if(o!==UY)return o;A=n.push(e)-1,i.set(e,A)}return r[A%r.length]}function OY(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class IY extends QY{getDefaultOptions(){return{domain:[],range:[],unknown:UY}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&NY(this.domainIndexMap,this.getDomain(),this.domainKey),TY({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&NY(this.rangeIndexMap,this.getRange(),this.rangeKey),TY({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=OY(e),this.rangeKey=OY(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 IY(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 LY(t){return Math.round(1e12*t)/1e12}function PY(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:A,align:s}=t,a=e.length,c=function(t,e){const n=e-t.length;return n>0?[...t,...new Array(n).fill(1)]:n<0?t.slice(0,e):t}(o,a),[l,u]=n,h=u-l,d=h/(2/a*r+1-1/a*i),f=d*i/a,g=d-a*f,p=function(t){const e=Math.min(...t);return t.map(t=>t/e)}(c),v=g/p.reduce((t,e)=>t+e),m=new SY(e.map((t,e)=>{const n=p[e]*v;return[t,A?Math.floor(n):n]})),y=new SY(e.map((t,e)=>{const n=p[e]*v+f;return[t,A?Math.floor(n):n]})),w=Array.from(y.values()).reduce((t,e)=>t+e),b=l+(h-(w-w/a*i))*s;let B=A?Math.round(b):b;const E=new Array(a);for(let t=0;t<a;t+=1){E[t]=LY(B);const n=e[t];B+=y.get(n)}return{valueBandWidth:m,valueStep:y,adjustedRange:E}}class DY extends IY{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:UY,flex:[]}}constructor(t){super(t)}clone(){return new DY(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 PY(t);const{range:i,paddingOuter:o,paddingInner:A,round:s,align:a}=t;let c,l,u=i[0];const h=i[1]-u,d=2*o,f=r-A;c=h/Math.max(1,d+f),s&&(c=Math.floor(c)),u+=(h-c*(r-A))*a,l=c*(1-A),s&&(u=Math.round(u),l=Math.round(l));const g=new Array(r).fill(0).map((t,e)=>u+e*c);return{valueStep:c,valueBandWidth:l,adjustedRange:g}}({align:t,range:n,round:r,flex:i,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:e});this.valueStep=s,this.valueBandWidth=A,this.adjustedRange=o}}const RY=(t,e,n)=>{let r,i,o=t,A=e;if(o===A&&n>0)return[o];let s=rY(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},HY=(t,e,n)=>{const[r,i]=t,[o,A]=e;let s,a;return r<i?(s=JW(r,i),a=n(o,A)):(s=JW(i,r),a=n(A,o)),ZW(a,s)},_Y=(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,a=A?[...e].reverse():e;for(let t=0;t<r;t+=1)i[t]=JW(s[t],s[t+1]),o[t]=n(a[t],a[t+1]);return e=>{const n=function(t,e,n,r){let i=n,o=r||t.length;const A=t=>t;for(;i<o;){const n=Math.floor((i+o)/2);A(t[n])>e?o=n:i=n+1}return i}(t,e,1,r)-1,A=i[n];return ZW(o[n],A)(e)}},GY=(t,e,n,r)=>(Math.min(t.length,e.length)>2?_Y:HY)(t,e,r?MY:n);class KY extends QY{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:xY,tickCount:5}}map(t){return oY(t)?this.output(t):this.options.unknown}invert(t){return oY(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 iY}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]):Te}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,A=GY(n.map(t),r,o,i);this.output=ZW(A,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=GY(i,r.map(t),xY);this.input=ZW(e,n,o)}}class jY extends KY{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:CY,tickMethod:RY,tickCount:5}}chooseTransforms(){return[Te,Te]}clone(){return new jY(this.options)}}var zY=function(t){function e(e){var n=this,r=e.style,i=Pe(e,["style"]);return(n=t.call(this,be({},{type:"column"},Le({style:r},i)))||this).columnsGroup=new Xa({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return Ie(e,t),e.prototype.render=function(){var t=this.attributes,e=t.columns,n=t.x,r=t.y;this.columnsGroup.style.transform="translate(".concat(n,", ").concat(r,")"),kW(this.columnsGroup).selectAll(".column").data(e.flat()).join(function(t){return t.append("rect").attr("className","column").each(function(t){this.attr(t)})},function(t){return t.each(function(t){this.attr(t)})},function(t){return t.remove()})},e.prototype.update=function(t){this.attr(eW({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(ja),VY=function(t){function e(e){var n=this,r=e.style,i=Pe(e,["style"]);return(n=t.call(this,be({},{type:"lines"},Le({style:r},i)))||this).linesGroup=n.appendChild(new Xa),n.areasGroup=n.appendChild(new Xa),n.render(),n}return Ie(e,t),e.prototype.render=function(){var t=this.attributes,e=t.lines,n=t.areas,r=t.x,i=t.y;this.style.transform="translate(".concat(r,", ").concat(i,")"),e&&this.renderLines(e),n&&this.renderAreas(n)},e.prototype.clear=function(){this.linesGroup.removeChildren(),this.areasGroup.removeChildren()},e.prototype.update=function(t){this.attr(eW({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){kW(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){kW(this.linesGroup).selectAll(".area").data(t).join(function(t){return t.append("path").attr("className","area").each(function(t){this.attr(t)})},function(t){return t.each(function(t){this.style(t)})},function(t){return t.remove()})},e}(ja);function WY(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map(function(t,e){return _e([e===n?"M":"L"],He(t),!1)});return e?r.reverse():r}function YY(t,e){if(void 0===e&&(e=!1),t.length<=2)return WY(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];xe(o,n.slice(-2))||n.push.apply(n,_e([],He(o),!1))}var A=BW(n);return e?A.unshift(_e(["M"],He(t[r-1]),!1)):A.unshift(_e(["M"],He(t[0]),!1)),A}function XY(t,e,n){var r=ge(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function qY(t){return 0===t.length?[0,0]:[Zt(Ae(t,function(t){return Zt(t)||0})),$t(oe(t,function(t){return $t(t)||0}))]}function $Y(t){for(var e=ge(t),n=e[0].length,r=He([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],a=0;a<n;a+=1)s[a]>=0?(s[a]+=i[a],i[a]=s[a]):(s[a]+=o[a],o[a]=s[a]);return e}var ZY=function(t){function e(e){return t.call(this,e,{type:"line",x:0,y:0,width:200,height:20,isStack:!1,color:["#83daad","#edbf45","#d2cef9","#e290b3","#6f63f4"],smooth:!0,lineLineWidth:1,areaOpacity:0,isGroup:!1,columnLineWidth:1,columnStroke:"#fff",scale:1,spacing:0})||this}return Ie(e,t),Object.defineProperty(e.prototype,"rawData",{get:function(){var t=this.attributes.data;if(!t||0===(null==t?void 0:t.length))return[[]];var e=ge(t);return re(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?$Y(this.rawData):this.rawData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scales",{get:function(){return this.createScales(this.data)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseline",{get:function(){var t=this.scales.y,e=He(t.getOptions().domain||[0,0],2),n=e[0],r=e[1];return r<0?t.map(r):t.map(n<0?0:n)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"containerShape",{get:function(){var t=this.attributes;return{width:t.width,height:t.height}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesStyle",{get:function(){var t=this,e=this.attributes,n=e.type,r=e.isStack,i=e.smooth;if("line"!==n)throw new Error("linesStyle can only be used in line type");var o=IW(this.attributes,"area"),A=IW(this.attributes,"line"),s=this.containerShape.width,a=this.data;if(0===a[0].length)return{lines:[],areas:[]};var c=this.scales,l=function(t,e){var n,r=e.x,i=e.y,o=He(i.getOptions().range||[0,0],2),A=o[0],s=o[1];return s>A&&(n=He([A,s],2),s=n[0],A=n[1]),t.map(function(t){return t.map(function(t,e){return[r.map(e),ne(i.map(t),s,A)]})})}(a,{x:c.x,y:c.y}),u=[];if(o){var h=this.baseline;u=r?i?function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=t[i],A=YY(o),s=void 0;if(0===i)s=XY(A,e,n);else{var a=YY(t[i-1],!0),c=o[0];a[0][0]="L",s=_e(_e(_e([],He(A),!1),He(a),!1),[_e(["M"],He(c),!1),["Z"]],!1)}r.push(s)}return r}(l,s,h):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=WY(t[i]),A=void 0;if(0===i)A=XY(o,e,n);else{var s=WY(t[i-1],!0);s[0][0]="L",A=_e(_e(_e([],He(o),!1),He(s),!1),[["Z"]],!1)}r.push(A)}return r}(l,s,h):function(t,e,n,r){return t.map(function(t){return XY(e?YY(t):WY(t),n,r)})}(l,i,s,h)}return{lines:l.map(function(e,n){return Le({stroke:t.getColor(n),d:i?YY(e):WY(e)},A)}),areas:u.map(function(e,n){return Le({d:e,fill:t.getColor(n)},o)})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=IW(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=$Y(s));var a=this.createScales(s),c=a.x,l=a.y,u=He(qY(s),2),h=u[0],d=u[1],f=new jY({domain:[0,d-(h>0?0:h)],range:[0,A*o]}),g=c.getBandWidth(),p=this.rawData;return{columns:s.map(function(n,i){return n.map(function(n,o){var A=g/s.length;return Le(Le({fill:t.getColor(i)},e),r?{x:c.map(o),y:l.map(n),width:g,height:f.map(p[i][o])}:{x:c.map(o)+A*i,y:n>=0?l.map(n):l.map(0),width:A,height:f.map(Math.abs(n))})})})}},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){var n,r,i;(n=e,r=".container",i="rect",n.querySelector(r)?kW(n).select(r):kW(n).append(i)).attr("className","container").node();var o=t.type,A=t.x,s=t.y,a="spark".concat(o),c=Le({x:A,y:s},"line"===o?this.linesStyle:this.columnsStyle);kW(e).selectAll(".spark").data([o]).join(function(t){return t.append(function(t){return"line"===t?new VY({className:a,style:c}):new zY({className:a,style:c})}).attr("className","spark ".concat(a))},function(t){return t.update(c)},function(t){return t.remove()})},e.prototype.getColor=function(t){var e=this.attributes.color;return jt(e)?e[t%e.length]:Gt(e)?e.call(null,t):e},e.prototype.createScales=function(t){var e,n,r=this.attributes,i=r.type,o=r.scale,A=r.range,s=void 0===A?[]:A,a=r.spacing,c=this.containerShape,l=c.width,u=c.height,h=He(qY(t),2),d=h[0],f=h[1],g=new jY({domain:[null!==(e=s[0])&&void 0!==e?e:d,null!==(n=s[1])&&void 0!==n?n:f],range:[u,u*(1-o)]});return"line"===i?{type:i,x:new jY({domain:[0,t[0].length-1],range:[0,l]}),y:g}:{type:i,x:new DY({domain:t[0].map(function(t,e){return e}),range:[0,l],paddingInner:a,paddingOuter:a/2,align:.5}),y:g}},e.tag="sparkline",e}(KW);function JY(t){if(!t)return{enter:!1,update:!1,exit:!1};var e=["enter","update","exit"],n=Object.fromEntries(Object.entries(t).filter(function(t){var n=He(t,1)[0];return!e.includes(n)}));return Object.fromEntries(e.map(function(e){return function(t){return"boolean"!=typeof t&&"enter"in t&&"update"in t&&"exit"in t}(t)?!1===t[e]?[e,!1]:[e,Le(Le({},t[e]),n)]:[e,n]}))}function tX(t,e){t?t.finished.then(e):e()}function eX(t,e){"update"in t?t.update(e):t.attr(e)}function nX(t,e,n){return 0===e.length?null:n?t.animate(e,n):(eX(t,{style:e.slice(-1)[0]}),null)}function rX(t,e,n){var r={},i={};return Object.entries(e).forEach(function(e){var n=He(e,2),o=n[0],A=n[1];if(!Kt(A)){var s=t.style[o]||t.parsedStyle[o]||0;s!==A&&(r[o]=s,i[o]=A)}}),n?nX(t,[r,i],Le({fill:"both"},n)):(eX(t,i),null)}function iX(t,e){return t.style.opacity||(t.style.opacity=1),rX(t,{opacity:0},e)}var oX={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},AX={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},sX={x:0,y:0,orientation:"horizontal",showLabel:!0,type:"start"},aX=JV({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),cX=JV({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),lX=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,e){var n=t.x,r=t.y,i=t.size,o=void 0===i?10:i,A=t.radius,s=void 0===A?o/4:A,a=t.orientation,c=t.classNamePrefix,l=Pe(t,["x","y","size","radius","orientation","classNamePrefix"]),u=o,h=2.4*u,d=c?"".concat(cX.iconRect.name," ").concat(c,"handle-icon-rect"):cX.iconRect.name,f=function(t){return c?"".concat(cX.iconLine,"-").concat(t," ").concat(c,"handle-icon-line"):"".concat(cX.iconLine,"-").concat(t)},g=kW(e).maybeAppendByClassName(cX.iconRect,"rect").attr("className",d).styles(Le(Le({},l),{width:u,height:h,radius:s,x:n-u/2,y:r-h/2,transformOrigin:"center"})),p=n+1/3*u-u/2,v=n+2/3*u-u/2,m=r+1/4*h-h/2,y=r+3/4*h-h/2;g.maybeAppendByClassName("".concat(cX.iconLine,"-1"),"line").attr("className",f(1)).styles(Le({x1:p,x2:p,y1:m,y2:y},l)),g.maybeAppendByClassName("".concat(cX.iconLine,"-2"),"line").attr("className",f(2)).styles(Le({x1:v,x2:v,y1:m,y2:y},l)),"vertical"===a&&(g.node().style.transform="rotate(90)")},e}(KW),uX=function(t){function e(e){return t.call(this,e,sX)||this}return Ie(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.x,i=n.y,o=n.showLabel,A=IW(this.attributes,"label"),s=A.x,a=void 0===s?0:s,c=A.y,l=void 0===c?0:c,u=A.transform,h=A.transformOrigin,d=He(PW(Pe(A,["x","y","transform","transformOrigin"]),[]),2),f=d[0],g=d[1],p=kW(t).maybeAppendByClassName(cX.labelGroup,"g").styles(g),v=Le(Le({},AX),f),m=v.text,y=Pe(v,["text"]);lW(!!o,p,function(t){e.label=t.maybeAppendByClassName(cX.label,"text").styles(Le(Le({},y),{x:r+a,y:i+l,transform:u,transformOrigin:h,text:"".concat(m)})),e.label.on("mousedown",function(t){t.stopPropagation()}),e.label.on("touchstart",function(t){t.stopPropagation()})})},e.prototype.renderIcon=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.orientation,o=e.type,A=e.classNamePrefix,s=Le(Le({x:n,y:r,orientation:i,classNamePrefix:A},oX),IW(this.attributes,"icon")),a=this.attributes.iconShape,c=void 0===a?function(){return new lX({style:s})}:a;kW(t).maybeAppendByClassName(cX.iconGroup,"g").selectAll(cX.icon.class).data([c]).join(function(t){return t.append("string"==typeof c?c:function(){return c(o)}).attr("className",cX.icon.name)},function(t){return t.update(s)},function(t){return t.remove()})},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(KW),hX=function(t){function e(e){var n=t.call(this,e,Le(Le(Le({x:0,y:0,animate:{duration:100,fill:"both"},brushable:!0,formatter:function(t){return t.toString()},handleSpacing:2,orientation:"horizontal",padding:0,autoFitLabel:!0,scrollable:!0,selectionFill:"#5B8FF9",selectionFillOpacity:.45,selectionZIndex:2,showHandle:!0,showLabel:!0,slidable:!0,trackFill:"#416180",trackLength:200,trackOpacity:.05,trackSize:20,trackZIndex:-1,values:[0,1],type:"range",selectionType:"select",handleIconOffset:0},LW(sX,"handle")),LW(oX,"handleIcon")),LW(AX,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(aW(e));var r=n.availableSpace,i=r.x,o=r.y,A=n.getBBox(),s=A.x,a=A.y;n.selectionStartPos=n.getRatio(n.prevPos-n.getOrientVal([i,o])-n.getOrientVal([+s,+a])),n.selectionWidth=0,document.addEventListener("pointermove",n.onDragging),document.addEventListener("pointerup",n.onDragEnd)}},n.onDragging=function(t){var e=n.attributes,r=e.slidable,i=e.brushable,o=e.type;t.stopPropagation();var A=n.getOrientVal(aW(t)),s=A-n.prevPos;if(s){var a=n.getRatio(s);switch(n.target){case"start":r&&n.setValuesOffset(a);break;case"end":r&&n.setValuesOffset(0,a);break;case"selection":r&&n.setValuesOffset(a,a);break;case"track":if(!i)return;n.selectionWidth+=a,"range"===o?n.innerSetValues([n.selectionStartPos,n.selectionStartPos+n.selectionWidth].sort(),!0):n.innerSetValues([0,n.selectionStartPos+n.selectionWidth],!0)}n.prevPos=A}},n.onDragEnd=function(){document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointerup",n.onDragEnd),n.target="",n.updateHandlesPosition(!1)},n.onValueChange=function(t){var e=n.attributes,r=e.onChange,i=e.type,o="range"===i?t:t[1],A="range"===i?n.getValues():n.getValues()[1],s=new Vs("valuechange",{detail:{oldValue:o,value:A}});n.dispatchEvent(s),null==r||r(A)},n.selectionStartPos=0,n.selectionWidth=0,n.prevPos=0,n.target="",n}return Ie(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return this.attributes.values},set:function(t){this.attributes.values=this.clampValues(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sparklineStyle",{get:function(){if("horizontal"!==this.attributes.orientation)return null;var t=IW(this.attributes,"sparkline");return Le(Le({zIndex:0},this.availableSpace),t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t=this.attributes,e=t.trackLength,n=t.trackSize,r=He(this.getOrientVal([[e,n],[n,e]]),2);return{width:r[0],height:r[1]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes;t.x,t.y;var e=He(SW(t.padding),4),n=e[0],r=e[1],i=e[2],o=e[3],A=this.shape;return{x:o,y:n,width:A.width-(o+r),height:A.height-(n+i)}},enumerable:!1,configurable:!0}),e.prototype.getValues=function(){return this.values},e.prototype.setValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1),this.attributes.values=t;var n=!1!==e&&this.attributes.animate;this.updateSelectionArea(n),this.updateHandlesPosition(n)},e.prototype.updateSelectionArea=function(t){var e=this.calcSelectionArea();this.foregroundGroup.selectAll(aX.selection.class).each(function(n,r){rX(this,e[r],t)})},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&rX(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&rX(this.endHandle,this.getHandleStyle("end"),t))},e.prototype.innerSetValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1);var n=this.values,r=this.clampValues(t);this.attributes.values=r,this.setValues(r),e&&this.onValueChange(n)},e.prototype.renderTrack=function(t){var e=this.attributes,n=e.x,r=e.y,i=IW(this.attributes,"track");this.trackShape=kW(t).maybeAppendByClassName(aX.track,"rect").styles(Le(Le({x:n,y:r},this.shape),i))},e.prototype.renderBrushArea=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.brushable;this.brushArea=kW(t).maybeAppendByClassName(aX.brushArea,"rect").styles(Le({x:n,y:r,fill:"transparent",cursor:i?"crosshair":"default"},this.shape))},e.prototype.renderSparkline=function(t){var e=this,n=this.attributes,r=n.x,i=n.y;lW("horizontal"===n.orientation,kW(t).maybeAppendByClassName(aX.sparklineGroup,"g"),function(t){var n=Le(Le({},e.sparklineStyle),{x:r,y:i});t.maybeAppendByClassName(aX.sparkline,function(){return new ZY({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(aX.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 uX({style:e.getHandleStyle(n)})}).each(function(t){var e=t.type;this.attr("class","".concat(aX.handle.name," ").concat(e,"-handle"));var n="".concat(e,"Handle");A[n]=this,this.addEventListener("pointerdown",A.onDragStart(e))})},function(t){return t.each(function(t){var e=t.type;this.update(A.getHandleStyle(e))})},function(t){return t.each(function(t){var e=t.type,n="".concat(e,"Handle");A[n]=void 0}).remove()})},e.prototype.renderSelection=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.type,o=e.selectionType;this.foregroundGroup=kW(t).maybeAppendByClassName(aX.foreground,"g");var A=IW(this.attributes,"selection"),s=function(t){return t.style("visibility",function(t){return t.show?"visible":"hidden"}).style("cursor",function(t){return"select"===o?"grab":"invert"===o?"crosshair":"default"}).styles(Le(Le({},A),{transform:"translate(".concat(n,", ").concat(r,")")}))},a=this;this.foregroundGroup.selectAll(aX.selection.class).data("value"===i?[]:this.calcSelectionArea().map(function(t,e){return{style:Le({},t),index:e,show:"select"===o?1===e:1!==e}}),function(t){return t.index}).join(function(t){return t.append("rect").attr("className",aX.selection.name).call(s).each(function(t,e){var n=this;1===e?(a.selectionShape=kW(this),this.on("pointerdown",function(t){n.attr("cursor","grabbing"),a.onDragStart("selection")(t)}),a.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),a.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),a.dispatchCustomEvent(this,"click","selectionClick"),this.addEventListener("pointerdown",function(){n.attr("cursor","grabbing")}),this.addEventListener("pointerup",function(){n.attr("cursor","pointer")}),this.addEventListener("pointerover",function(){n.attr("cursor","pointer")})):this.on("pointerdown",a.onDragStart("track"))})},function(t){return t.call(s)},function(t){return t.remove()}),this.updateSelectionArea(!1),this.renderHandles()},e.prototype.render=function(t,e){this.renderTrack(e),this.renderSparkline(e),this.renderBrushArea(e),this.renderSelection(e)},e.prototype.clampValues=function(t,e){var n;void 0===e&&(e=4);var r=He(this.range,2),i=r[0],o=r[1],A=He(this.getValues().map(function(t){return wW(t,e)}),2),s=A[0],a=A[1],c=He(((Array.isArray(t)?t:[s,null!=t?t:a])||[s,a]).map(function(t){return wW(t,e)}),2),l=c[0],u=c[1];if("value"===this.attributes.type)return[0,ne(u,i,o)];l>u&&(l=(n=He([u,l],2))[0],u=n[1]);var h=u-l;return h>o-i?[i,o]:l<i?s===i&&a===u?[i,u]:[i,h+i]:u>o?a===o&&s===l?[l,o]:[o-h,o]:[l,u]},e.prototype.calcSelectionArea=function(t){var e=He(this.clampValues(t),2),n=e[0],r=e[1],i=this.availableSpace,o=i.x,A=i.y,s=i.width,a=i.height;return this.getOrientVal([[{y:A,height:a,x:o,width:n*s},{y:A,height:a,x:n*s+o,width:(r-n)*s},{y:A,height:a,x:r*s,width:(1-r)*s}],[{x:o,width:s,y:A,height:n*a},{x:o,width:s,y:n*a+A,height:(r-n)*a},{x:o,width:s,y:r*a,height:(1-r)*a}]])},e.prototype.calcHandlePosition=function(t){var e=this.attributes.handleIconOffset,n=this.availableSpace,r=n.x,i=n.y,o=n.width,A=n.height,s=He(this.clampValues(),2),a=s[0],c=s[1],l="start"===t?-e:e,u=("start"===t?a:c)*this.getOrientVal([o,A])+l;return{x:r+this.getOrientVal([u,o/2]),y:i+this.getOrientVal([A/2,u])}},e.prototype.inferTextStyle=function(t){return"horizontal"===this.attributes.orientation?{}:"start"===t?{transformOrigin:"left center",transform:"rotate(90)",textAlign:"start"}:"end"===t?{transformOrigin:"right center",transform:"rotate(90)",textAlign:"end"}:{}},e.prototype.calcHandleText=function(t){var e,n=this.attributes,r=n.type,i=n.orientation,o=n.formatter,A=n.autoFitLabel,s=IW(this.attributes,"handle"),a=IW(s,"label"),c=s.spacing,l=this.getHandleSize(),u=this.clampValues(),h=o("start"===t?u[0]:u[1]),d=new WV({style:Le(Le(Le({},a),this.inferTextStyle(t)),{text:h})}),f=d.getBBox(),g=f.width,p=f.height;if(d.destroy(),!A){if("value"===r)return{text:h,x:0,y:-p-c};var v=c+l+("horizontal"===i?g/2:0);return(e={text:h})["horizontal"===i?"x":"y"]="start"===t?-v:v,e}var m=0,y=0,w=this.availableSpace,b=w.width,B=w.height,E=this.calcSelectionArea()[1],x=E.x,C=E.y,M=E.width,F=E.height,k=c+l;if("horizontal"===i){var S=k+g/2;if("start"===t)m=x-k-g>0?-S:S;else m=b-x-M-k>g?S:-S}else{var Q=p+k;y="start"===t?C-l>p?-Q:k:B-(C+F)-l>p?Q:-k}return{x:m,y:y,text:h}},e.prototype.getHandleLabelStyle=function(t){var e=IW(this.attributes,"handleLabel");return Le(Le(Le({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=IW(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return Le({cursor:n,shape:t,size:r},e)},e.prototype.getHandleStyle=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.showLabel,o=e.showLabelOnInteraction,A=e.orientation,s=this.calcHandlePosition(t),a=s.x,c=s.y,l=this.calcHandleText(t),u=i;return!i&&o&&(u=!!this.target),Le(Le(Le({},LW(this.getHandleIconStyle(),"icon")),LW(Le(Le({},this.getHandleLabelStyle(t)),l),"label")),{transform:"translate(".concat(a+n,", ").concat(c+r,")"),orientation:A,showLabel:u,type:t,zIndex:3})},e.prototype.getHandleSize=function(){var t=this.attributes,e=t.handleIconSize,n=t.width,r=t.height;return e||Math.floor((this.getOrientVal([+r,+n])+4)/2.4)},e.prototype.getOrientVal=function(t){var e=He(t,2),n=e[0],r=e[1];return"horizontal"===this.attributes.orientation?n:r},e.prototype.setValuesOffset=function(t,e){void 0===e&&(e=0);var n=this.attributes.type,r=He(this.getValues(),2),i=[r[0]+("range"===n?t:0),r[1]+e].sort();this.innerSetValues(i,!0)},e.prototype.getRatio=function(t){var e=this.availableSpace,n=e.width,r=e.height;return t/this.getOrientVal([n,r])},e.prototype.dispatchCustomEvent=function(t,e,n){var r=this;t.on(e,function(t){t.stopPropagation(),r.dispatchEvent(new Vs(n,{detail:t}))})},e.prototype.bindEvents=function(){this.addEventListener("wheel",this.onScroll);var t=this.brushArea;this.dispatchCustomEvent(t,"click","trackClick"),this.dispatchCustomEvent(t,"pointerenter","trackMouseenter"),this.dispatchCustomEvent(t,"pointerleave","trackMouseleave"),t.on("pointerdown",this.onDragStart("track"))},e.prototype.onScroll=function(t){if(this.attributes.scrollable){var e=t.deltaX,n=t.deltaY||e,r=this.getRatio(n);this.setValuesOffset(r,r)}},e.tag="slider",e}(KW),dX="grid-group",fX="main-group",gX="line-group",pX="tick-group",vX="label-group",mX="title-group",yX="grid",wX="line",bX="line-first",BX="line-second",EX="tick",xX="tick-item",CX="label",MX="label-item",FX="title",kX={data:[],animate:{enter:!1,update:{duration:100,easing:"ease-in-out-sine",fill:"both"},exit:{duration:100,fill:"both"}},showArrow:!0,showGrid:!0,showLabel:!0,showLine:!0,showTick:!0,showTitle:!0,showTrunc:!1,dataThreshold:100,lineLineWidth:1,lineStroke:"black",crossPadding:10,titleFill:"black",titleFontSize:12,titlePosition:"lb",titleSpacing:0,titleTextAlign:"center",titleTextBaseline:"middle",lineArrow:function(){return new nc({style:{d:[["M",10,10],["L",-10,0],["L",10,-10],["L",0,0],["L",10,10],["Z"]],fill:"black",transformOrigin:"center"}})},labelAlign:"parallel",labelDirection:"positive",labelFontSize:12,labelSpacing:0,gridConnect:"line",gridControlAngles:[],gridDirection:"positive",gridLength:0,gridType:"segment",lineArrowOffset:15,lineArrowSize:10,tickDirection:"positive",tickLength:5,tickLineWidth:1,tickStroke:"black",labelOverlap:[]};be({},kX,{style:{type:"arc"}}),be({},kX,{style:{}});var SX=JV({mainGroup:fX,gridGroup:dX,grid:yX,lineGroup:gX,line:wX,tickGroup:pX,tick:EX,tickItem:xX,labelGroup:vX,label:CX,labelItem:MX,titleGroup:mX,title:FX,lineFirst:bX,lineSecond:BX},"axis"),QX=JV({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function UX(t){return t.reduce(function(t,e,n){return t.push(_e([0===n?"M":"L"],He(e),!1)),t},[])}function NX(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 UX(t);if(!o)return[];var A=mW(t[0],o),s=n?0:1;return t.reduce(function(t,e,n){return 0===n?t.push(_e(["M"],He(e),!1)):t.push(_e(["A",A,A,0,0,s],He(e),!1)),t},[])}(t,e,n):UX(t)}function TX(t,e,n){var r=n.type,i=n.connect,o=n.center,A=n.closed?[["Z"]]:[],s=He([NX(t,n),NX(e.slice().reverse(),n,!0)],2),a=s[0],c=s[1],l=He([t[0],e.slice(-1)[0]],2),u=l[0],h=l[1],d=function(t,e){return[a,t,c,e,A].flat()};if("line"===i||"surround"===r)return d([_e(["L"],He(h),!1)],[_e(["L"],He(u),!1)]);if(!o)throw new Error("Arc grid need to specified center");var f=He([mW(h,o),mW(u,o)],2),g=f[0],p=f[1];return d([_e(["A",g,g,0,0,1],He(h),!1),_e(["L"],He(h),!1)],[_e(["A",p,p,0,0,0],He(u),!1),_e(["L"],He(u),!1)])}var OX=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Pe(t,["type","center","areaFill","closed"]),r=function(t){var e=t.data,n=void 0===e?[]:e;return t.closed?n.map(function(t){var e=t.points,n=He(e,1)[0];return Le(Le({},t),{points:_e(_e([],He(e),!1),[n],!1)})}):n}(t),i=kW(e).maybeAppendByClassName(QX.lineGroup,"g"),o=kW(e).maybeAppendByClassName(QX.regionGroup,"g"),A=function(t,e,n,r){var i=n.animate,o=n.isBillboard,A=e.map(function(t,e){return{id:t.id||"grid-line-".concat(e),d:NX(t.points,n)}});return t.selectAll(QX.line.class).data(A,function(t){return t.id}).join(function(t){return t.append("path").each(function(t,e){var n=$V(CW(Le({d:t.d},r)),[t,e,A]);this.attr(Le({class:QX.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))})},function(t){return t.transition(function(t,e){return rX(this,$V(CW(Le({d:t.d},r)),[t,e,A]),i.update)})},function(t){return t.transition(function(){var t=this,e=iX(this,i.exit);return tX(e,function(){return t.remove()}),e})}).transitions()}(i,r,t,n),s=function(t,e,n){var r=n.animate,i=n.connect,o=n.areaFill;if(e.length<2||!o||!i)return[];for(var A=Array.isArray(o)?o:[o,"transparent"],s=function(t){return A[t%A.length]},a=[],c=0;c<e.length-1;c++){var l=He([e[c].points,e[c+1].points],2),u=TX(l[0],l[1],n);a.push({d:u,fill:s(c)})}return t.selectAll(QX.region.class).data(a,function(t,e){return e}).join(function(t){return t.append("path").each(function(t,e){var n=$V(t,[t,e,a]);this.attr(n)}).attr("className",QX.region.name)},function(t){return t.transition(function(t,e){return rX(this,$V(t,[t,e,a]),r.update)})},function(t){return t.transition(function(){var t=this,e=iX(this,r.exit);return tX(e,function(){return t.remove()}),e})}).transitions()}(o,r,t);return _e(_e([],He(A),!1),He(s),!1)},e}(KW);function IX(t,e){return Object.fromEntries(Object.entries(t).map(function(t){var n=He(t,2);return[n[0],$V(n[1],e)]}))}function LX(t,e){return e&&Gt(e)?t.filter(e):t}function PX(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}function DX(t,e){if("linear"===e.type){var n=He(e.startPos,2),r=n[0],i=n[1],o=He(e.endPos,2),A=He([o[0]-r,o[1]-i],2);return yW([A[0],A[1]])}var s=YV(PX(t,e));return[-Math.sin(s),Math.cos(s)]}function RX(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(DX(t,n),"positive"!==e)}function HX(t,e){return RX(t,e.labelDirection,e)}function _X(t,e,n){return n?"".concat(t," ").concat(n,"axis-").concat(e):t}function GX(t,e,n,r){return r&&t.attr("className",_X(e.name,n,r)),t}function KX(t,e){return"linear"===e.type?function(t,e){var n=He(e.startPos,2),r=n[0],i=n[1],o=He(e.endPos,2),A=He([o[0]-r,o[1]-i],2);return[r+A[0]*t,i+A[1]*t]}(t,e):function(t,e){var n=e.radius,r=He(e.center,2),i=r[0],o=r[1],A=YV(PX(t,e));return[i+n*Math.cos(A),o+n*Math.sin(A)]}(t,e)}function jX(t){return 0===DX(0,t)[1]}function zX(t){return 0===DX(0,t)[0]}function VX(t,e){return e-t===360}function WX(t,e,n,r,i){var o=e-t,A=He([i,i],2),s=A[0],a=A[1],c=He([YV(t),YV(e)],2),l=c[0],u=c[1],h=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},d=He(h(l),2),f=d[0],g=d[1],p=He(h(u),2),v=p[0],m=p[1];if(VX(t,e)){var y=He(h((u+l)/2),2);return[["M",f,g],["A",s,a,0,1,0,y[0],y[1]],["A",s,a,0,1,0,v,m]]}var w=o>180?1:0,b=t>e?0:1;return"M".concat(f,",").concat(g,",A").concat(s,",").concat(a,",0,").concat(w,",").concat(b,",").concat(v,",").concat(m)}function YX(t,e,n,r){var i=e.startAngle,o=e.endAngle,A=e.center,s=e.radius,a=e.classNamePrefix;return t.selectAll(SX.line.class).data([{d:WX.apply(void 0,_e(_e([i,o],He(A),!1),[s],!1))}],function(t,e){return e}).join(function(t){var n=t.append("path").attr("className",SX.line.name).styles(e).styles({d:function(t){return t.d}});return GX(n,SX.line,wX,a),n},function(t){return t.transition(function(){var t=this,e=function(t,e,n,r){if(!r)return t.attr("__keyframe_data__",n),null;var i=r.duration,o=void 0===i?0:i,A=hW(e,n),s=Math.ceil(+o/16),a=new Array(s).fill(0).map(function(t,e,n){return{__keyframe_data__:A(e/(n.length-1))}});return t.animate(a,Le({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return _e(_e([n,r],He(i),!1),[o],!1)}(this),_e(_e([i,o],He(A),!1),[s],!1),r.update);if(e){var n=function(){var e=Ce(t.attributes,"__keyframe_data__");t.style.d=WX.apply(void 0,_e([],He(e),!1))};e.onframe=n,e.onfinish=n}return e}).styles(e)},function(t){return t.remove()}).styles(n).transitions()}function XX(t){var e=He(t,2),n=He(e[0],2),r=n[0],i=n[1],o=He(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function qX(t,e,n,r){var i=e.showTrunc,o=e.startPos,A=e.endPos,s=e.truncRange,a=e.lineExtension,c=e.classNamePrefix,l=He([o,A],2),u=He(l[0],2),h=u[0],d=u[1],f=He(l[1],2),g=f[0],p=f[1],v=He(a?function(t,e,n){void 0===n&&(n=[0,0]);var r=He([t,e,n],3),i=He(r[0],2),o=i[0],A=i[1],s=He(r[1],2),a=s[0],c=s[1],l=He(r[2],2),u=l[0],h=l[1],d=He([a-o,c-A],2),f=d[0],g=d[1],p=Math.sqrt(Math.pow(f,2)+Math.pow(g,2)),v=He([-u/p,h/p],2),m=v[0],y=v[1];return[m*f,m*g,y*f,y*g]}(o,A,a):new Array(4).fill(0),4),m=v[0],y=v[1],w=v[2],b=v[3],B=function(e){return t.selectAll(SX.line.class).data(e,function(t,e){return e}).join(function(t){var e=t.append("line").styles(n).transition(function(t){return rX(this,XX(t.line),!1)});return e.attr("className",function(t){if(!c)return"".concat(SX.line.name," ").concat(t.className);var e=_X(SX.line.name,wX,c);if(t.className===SX.lineFirst.name){var n=_X(SX.lineFirst.name,bX,c);return"".concat(e," ").concat(n)}if(t.className===SX.lineSecond.name){n=_X(SX.lineSecond.name,BX,c);return"".concat(e," ").concat(n)}return e}),e},function(t){return t.styles(n).transition(function(t){return rX(this,XX(t.line),r.update)})},function(t){return t.remove()}).transitions()};if(!i||!s)return B([{line:[[h+m,d+y],[g+w,p+b]],className:SX.line.name}]);var E=He(s,2),x=E[0],C=E[1],M=g-h,F=p-d,k=He([h+M*x,d+F*x],2),S=k[0],Q=k[1],U=He([h+M*C,d+F*C],2),N=U[0],T=U[1],O=B([{line:[[h+m,d+y],[S,Q]],className:SX.lineFirst.name},{line:[[N,T],[g+w,p+b]],className:SX.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),O}function $X(t,e,n){var r,i=e.type,o=IW(e,"line");return r="linear"===i?qX(t,e,bW(o,"arrow"),n):YX(t,e,bW(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,A=n.showTrunc,s=n.lineArrow,a=n.lineArrowOffset,c=n.lineArrowSize;if(i="arc"===e?t.select(SX.line.class):A?t.select(SX.lineSecond.class):t.select(SX.line.class),!o||!s||"arc"===n.type&&VX(n.startAngle,n.endAngle)){var l=i.node();l&&(l.style.markerEnd=void 0)}else{var u=cW(s);u.attr(r),MW(u,c),i.style("markerEnd",u).style("markerEndOffset",-a)}}(t,i,e,o),r}function ZX(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function JX(t,e){var n=e.gridLength;return t.map(function(t,r){var i=t.value,o=He(KX(i,e),2),A=o[0],s=o[1],a=He(dW(function(t,e){return RX(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[A,s],[A+a[0],s+a[1]]]}})}function tq(t,e,n,r){var i=n.classNamePrefix,o=IW(n,"grid"),A=o.type,s=o.areaFill,a=ZX(n),c=LX(e,n.gridFilter),l="segment"===A?JX(c,n):function(t,e){var n=e.gridControlAngles,r=ZX(e);if(!r)throw new Error("grid center is not provide");if(t.length<2)throw new Error("Invalid grid data");if(!n||0===n.length)throw new Error("Invalid gridControlAngles");var i=He(r,2),o=i[0],A=i[1];return t.map(function(t,r){var i=He(KX(t.value,e),2),s=i[0],a=i[1],c=He([s-o,a-A],2),l=c[0],u=c[1],h=[];return n.forEach(function(t){var e=YV(t),n=He([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=l*r-u*i+o,a=l*i+u*r+A;h.push([s,a])}),{points:h,id:r}})}(c,n),u=Le(Le({},o),{center:a,areaFill:Gt(s)?c.map(function(t,e){return $V(s,[t,e,c])}):s,animate:r,data:l});return t.selectAll(SX.grid.class).data([1]).join(function(t){var e=t.append(function(){return new OX({style:u})}).attr("className",SX.grid.name);return GX(e,SX.grid,yX,i),e},function(t){return t.transition(function(){return this.update(u)})},function(t){return t.remove()}).transitions()}var eq=function(){function t(t,e,n,r){this.set(t,e,n,r)}return Object.defineProperty(t.prototype,"left",{get:function(){return this.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this.defined("x2")&&this.defined("x1")?this.x2-this.x1:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.defined("y2")&&this.defined("y1")?this.y2-this.y1:void 0},enumerable:!1,configurable:!0}),t.prototype.rotatedPoints=function(t,e,n){var r=this,i=r.x1,o=r.y1,A=r.x2,s=r.y2,a=Math.cos(t),c=Math.sin(t),l=e-e*a+n*c,u=n-e*c-n*a;return[[a*i-c*s+l,c*i+a*s+u],[a*A-c*s+l,c*A+a*s+u],[a*i-c*o+l,c*i+a*o+u],[a*A-c*o+l,c*A+a*o+u]]},t.prototype.set=function(t,e,n,r){return 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 nq(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getBounds(),i=He(r.min,2),o=i[0],A=i[1],s=He(r.max,2),a=s[0],c=s[1],l=t.getBBox(),u=l.width,h=l.height,d=0,f=0,g=o,p=A,v=oW(t);if(v){h-=1.5;var m=v.style.textAlign,y=v.style.textBaseline;"center"===m?g=(o+a)/2:"right"!==m&&"end"!==m||(g=a),"middle"===y?p=(A+c)/2:"bottom"===y&&(p=c)}var w=He(SW(e),4),b=w[0],B=void 0===b?0:b,E=w[1],x=void 0===E?0:E,C=w[2],M=void 0===C?B:C,F=w[3],k=new eq((d+=o)-(void 0===F?x:F),(f+=A)-B,d+u+x,f+h+M);return t.setEulerAngles(n),k.rotatedPoints(YV(n),g,p)}function rq(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 iq(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 oq(t,e){var n=iq(t[0],t[1],e[0]),r=iq(t[0],t[1],e[1]),i=iq(e[0],e[1],t[0]),o=iq(e[0],e[1],t[1]);return n!==r&&i!==o||(!(0!==n||!rq(t,e[0]))||(!(0!==r||!rq(t,e[1]))||(!(0!==i||!rq(e,t[0]))||!(0!==o||!rq(e,t[1])))))}function Aq(t,e){return e.every(function(e){return function(t,e){var n=t.length;if(n<3)return!1;var r=[e,[9999,e[1]]],i=0,o=0;do{var A=[t[o],t[(o+1)%n]];if(oq(A,r)){if(0===iq(A[0],e,A[1]))return rq(A,e);i++}o=(o+1)%n}while(0!==o);return!!(1&i)}(t,e)})}function sq(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=He(t,4),r=n[0],i=n[1],o=n[2],A=n[3],s=He(e,4),a=s[0],c=s[1],l=o-r,u=A-i,h=s[2]-a,d=s[3]-c,f=l*d-h*u;if(0===f)return!1;var g=f>0,p=r-a,v=i-c,m=l*v-u*p;if(m<0===g)return!1;var y=h*v-d*p;return y<0!==g&&m>f!==g&&y>f!==g}(e,t)})}function aq(t,e,n){var r,i,o=e.crossPadding,A=new Set,s=null,a=function(t,e){var n=t.type,r=t.labelDirection,i=t.crossSize;if(!i)return!1;if("arc"===n){var o=t.center,A=t.radius,s=He(o,2),a=s[0],c=s[1],l="negative"===r?0:i,u=-A-l,h=A+l,d=He(SW(e),4),f=d[0],g=d[1],p=d[2],v=d[3];return new eq(a+u-v,c+u-f,a+h+g,c+h+p)}var m=He(t.startPos,2),y=m[0],w=m[1],b=He(t.endPos,2),B=b[0],E=b[1],x=He(zX(t)?[-e,0,e,0]:[0,e,0,-e],4),C=x[0],M=x[1],F=x[2],k=x[3],S=dW(HX(0,t),i),Q=new eq(y,w,B,E);return Q.x1+=k,Q.y1+=C,Q.x2+=M+S[0],Q.y2+=F+S[1],Q}(e,o),c=function(t){return!a||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,A=t.y2;return Aq([[r,o],[i,o],[i,A],[r,A]],nq(e,n))}(a,t)},l=function(t,e){return!t||!t.firstChild||!function(t,e,n){var r,i,o=nq(t,n).flat(1),A=nq(e,n).flat(1),s=[[o[0],o[1],o[2],o[3]],[o[0],o[1],o[4],o[5]],[o[4],o[5],o[6],o[7]],[o[2],o[3],o[6],o[7]]];try{for(var a=Re(s),c=a.next();!c.done;c=a.next())if(sq(A,c.value))return!0}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return!1}(t.firstChild,e.firstChild,SW(n))};try{for(var u=Re(t),h=u.next();!h.done;h=u.next()){var d=h.value;c(d)?!s||l(s,d)?s=d:(A.add(s),A.add(d)):A.add(d)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}return Array.from(A)}function cq(t,e){return void 0===e&&(e={}),Kt(t)?0:"number"==typeof t?t:Math.floor(rW(t,e))}var lq=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter(function(t,e){return!(e%r)||(KV(t),!1)})},uq=function(t){return t.filter(nW)};var hq=new Map([["hide",function(t,e,n,r){var i=t.length,o=e.keepHeader,A=e.keepTail;if(!(i<=1||2===i&&o&&A)){var s,a,c=lq,l=function(t){return t.forEach(r.show),t},u=2,h=t.slice(),d=t.slice(),f=Math.min.apply(Math,_e([1],He(t.map(function(t){return t.getBBox().width})),!1));if("linear"===n.type&&(jX(n)||zX(n))){var g=QW(t[0]).left,p=QW(t[i-1]).right,v=Math.abs(p-g)||1;u=Math.max(Math.floor(i*f/v),u)}for(o&&(s=h.splice(0,1)[0]),A&&(a=h.splice(-1,1)[0],h.reverse()),l(h);u<t.length&&aq(uq(a?_e(_e([a],He(d),!1),[s],!1):_e([s],He(d),!1)),n,null==e?void 0:e.margin).length;){if(a&&!s&&u%2==0)h.splice(0,1).forEach(r.hide);else if(a&&s){h.splice(0,1).forEach(r.hide)}d=c(l(h),{seq:u}),u++}}}],["rotate",function(t,e,n,r){var i,o,A=e.optionalAngles,s=void 0===A?[0,45,90]:A,a=e.margin,c=e.recoverWhenFailed,l=void 0===c||c,u=t.map(function(t){return t.getLocalEulerAngles()}),h=function(){return aq(t,n,a).length<1},d=function(e){return t.forEach(function(t,n){var i=Array.isArray(e)?e[n]:e;r.rotate(t,+i)})};try{for(var f=Re(s),g=f.next();!g.done;g=f.next()){if(d(g.value),h())return}}catch(t){i={error:t}}finally{try{g&&!g.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}l&&d(u)}],["ellipsis",function(t,e,n,r){if(!(t.length<=0)){var i=e.suffix,o=void 0===i?"...":i,A=e.minLength,s=e.maxLength,a=void 0===s?1/0:s,c=e.step,l=void 0===c?" ":c,u=e.margin,h=void 0===u?[0,0,0,0]:u,d=iW(r.getTextShape(t[0])),f=cq(l,d),g=A?cq(A,d):f,p=cq(a,d);(Kt(p)||p===1/0)&&(p=Math.max.apply(null,t.map(function(t){return t.getBBox().width})));var v=t.slice(),m=He(h,4);m[0],m[1],m[2],m[3];for(var y=function(e){if(v.forEach(function(t){r.ellipsis(r.getTextShape(t),e,o)}),(v=aq(t,n,h)).length<1)return{value:void 0}},w=p;w>g+f;w-=f){var b=y(w);if("object"==typeof b)return b.value}}}],["wrap",function(t,e,n,r,i){var o,A=e.maxLines,s=void 0===A?3:A,a=e.recoverWhenFailed,c=void 0===a||a,l=e.margin,u=void 0===l?[0,0,0,0]:l,h=$V(null!==(o=e.wordWrapWidth)&&void 0!==o?o:50,[i]),d=t.map(function(t){return t.attr("maxLines")||1}),f=Math.min.apply(Math,_e([],He(d),!1)),g=function(){return aq(t,n,u).length<1},p=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&jX(t)?"negative"===n?"bottom":"top":"middle"}(n),v=function(e){return t.forEach(function(t,n){var i=Array.isArray(e)?e[n]:e;r.wrap(t,h,i,p)})};if(!(f>s)){if("linear"===n.type&&jX(n)){if(v(s),g())return}else for(var m=f;m<=s;m++)if(v(m),g())return;c&&v(d)}}]]);function dq(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce(function(t,e){return t*function(t){return"positive"===t?-1:1}(e)},1)}function fq(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)}function gq(t,e){var n=He(t,2),r=n[0],i=n[1],o=He(e,2),A=o[0],s=o[1],a=He([r*A+i*s,r*s-i*A],2),c=a[0],l=a[1];return Math.atan2(l,c)}function pq(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=HX(t.value,n),A=DX(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return uW(e,-90,90)||(e+=180),e}(XV("perpendicular"===i?gq([1,0],o):gq([A[0]<0?-1:1,0],A)))}function vq(t,e,n){var r=n.type,i=n.labelAlign,o=HX(t,n),A=fq(e),s=fq(XV(gq([1,0],o))),a="center",c="middle";return"linear"===r?[90,270].includes(s)&&0===A?(a="center",c=1===o[1]?"top":"bottom"):s%180||![90,270].includes(A)?0===s?(uW(A,0,90,!1,!0)||uW(A,0,90)||uW(A,270,360))&&(a="start"):90===s?uW(A,0,90,!1,!0)?a="start":(uW(A,90,180)||uW(A,270,360))&&(a="end"):270===s?uW(A,0,90,!1,!0)?a="end":(uW(A,90,180)||uW(A,270,360))&&(a="start"):180===s&&(90===A?a="start":(uW(A,0,90)||uW(A,270,360))&&(a="end")):a="center":"parallel"===i?c=uW(s,0,180,!0)?"top":"bottom":"horizontal"===i?uW(s,90,270,!1)?a="end":(uW(s,270,360,!1)||uW(s,0,90))&&(a="start"):"perpendicular"===i&&(a=uW(s,90,270)?"end":"start"),{textAlign:a,textBaseline:c}}function mq(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,A=n.labelDirection,s=n.labelSpacing,a=e.indexOf(t),c=$V(s,[t,a,e]),l=He([HX(t.value,n),dq(A,o)],2),u=He(fW(dW(l[0],c+(1===l[1]?$V(r?i:0,[t,a,e]):0)),KX(t.value,n)),2);return{x:u[0],y:u[1]}}function yq(t,e,n,r){var i=r.labelRender,o=(Ce(r,"endPos.0",400)-Ce(r,"startPos.0",0))/n.length,A=Gt(i)?$V(i,[t,e,n,HX(t.value,r)]):t.label||"",s=function(t){var e=(new DOMParser).parseFromString(t,"text/html").body.firstElementChild;if(console.log(null==e?void 0:e.getClientRects(),11),!e)return 0;var n=e.getAttribute("style")||"",r=Object.fromEntries(n.split(";").map(function(t){return t.trim()}).filter(function(t){return t.includes(":")}).map(function(t){var e=He(t.split(":").map(function(t){return t.trim()}),2),n=e[0],r=e[1];return[n.toLowerCase(),r]})),i=function(t){if(!t)return 0;var e=t.match(/([\d.]+)px/);return e?parseFloat(e[1]):0};if(r.height)return i(r.height);var o,A=i(r["font-size"])||16,s=r["line-height"];o=s&&"normal"!==s?s.endsWith("px")?i(s):/^[\d.]+$/.test(s)?parseFloat(s)*A:A:1.2*A;var a=i(r["padding-top"]),c=i(r["padding-bottom"]);r.padding&&(1===(l=r.padding.split(/\s+/).map(i)).length||2===l.length?(a=l[0],c=l[0]):(3===l.length||4===l.length)&&(a=l[0],c=l[2]));var l,u=i(r["border-top-width"]),h=i(r["border-bottom-width"]);if(r.border){var d=r.border.match(/([\d.]+)px/);d&&(u=parseFloat(d[1]),h=parseFloat(d[1]))}return r["border-width"]&&(1===(l=r["border-width"].split(/\s+/).map(i)).length||2===l.length?(u=l[0],h=l[0]):(3===l.length||4===l.length)&&(u=l[0],h=l[2])),o+a+c+u+h}(A)||30;return function(){return e={width:o,height:s},"function"==typeof(t=A)?t():Jt(t)||re(t)?new $a({style:Le(Le({pointerEvents:"auto"},e),{innerHTML:t})}):t;var t,e}}var wq={html:["fill"],text:[]};function bq(t,e){["text","html"].includes(t.nodeName)&&t.attr(bW(e,wq[t.nodeName]))}function Bq(t,e){!function(t,e,n,r){var i=e.labelOverlap,o=void 0===i?[]:i;o.length&&o.forEach(function(i){var o=i.type,A=hq.get(o);(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,o)&&(null==A||A(t,i,e,r,n))})}(this.node().childNodes,t,e,{hide:KV,show:GV,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=vq(e.__data__.value,t,n),i=e.querySelector(SX.labelItem.class);i&&bq(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&sW(t,e||1/0,n)},wrap:function(t,e,n){var r,i;t&&(void 0===(r=n)&&(r=2),void 0===i&&(i="top"),AW(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector(SX.labelItem.class)}})}function Eq(t,e,n,r,i){var o=n.indexOf(e),A=i.labelRender,s=i.classNamePrefix,a=kW(t).append(A?yq(e,o,n,i):function(t,e,n,r){var i=r.labelFormatter;return Gt(i)?function(){return cW($V(i,[t,e,n,HX(t.value,r)]))}:function(){return cW(t.label||"")}}(e,o,n,i)).attr("className",SX.labelItem.name).node();GX(kW(a),SX.labelItem,MX,s);var c=He(PW(IX(r,[e,o,n])),2),l=c[0],u=c[1],h=u.transform,d=Pe(u,["transform"]);RW(a,h);var f=pq(e,a,i);if(a.getLocalEulerAngles()||a.setLocalEulerAngles(f),bq(a,Le(Le({},vq(e.value,f,i)),l)),"html"===a.nodeName){var g=a.getBBox(),p=a.style.x||0;a.attr("x",p-g.width/2)}return t.attr(d),a}function xq(t,e,n,r,i){var o,A,s,a=n.classNamePrefix,c=LX(e,n.labelFilter),l=IW(n,"label"),u=t.selectAll(SX.label.class).data(c,function(t,e){return e}).join(function(t){var r=t.append("g").attr("className",SX.label.name).transition(function(t){Eq(this,t,e,l,n);var r=mq(t,e,n),i=r.x,o=r.y;return this.style.transform="translate(".concat(i,", ").concat(o,")"),null});return GX(r,SX.label,CX,a),r},function(t){return t.transition(function(t){var i=function(t,e,n,r){if(void 0===r&&(r="destroy"),function(t,e){return"text"===t.nodeName&&"text"===e.nodeName&&t.attributes.text===e.attributes.text}(t,e))return t.remove(),[null];var i=function(){"destroy"===r?t.destroy():"hide"===r&&KV(t),e.isVisible()&&GV(e)};if(!n)return i(),[null];var o=n.duration,A=void 0===o?0:o,s=n.delay,a=void 0===s?0:s,c=Math.ceil(+A/2),l=+A/4,u=He(t.getGeometryBounds().center,2),h=u[0],d=u[1],f=He(e.getGeometryBounds().center,2),g=He([(h+f[0])/2-h,(d+f[1])/2-d],2),p=g[0],v=g[1],m=t.style.opacity,y=void 0===m?1:m,w=e.style.opacity,b=void 0===w?1:w,B=t.style.transform||"",E=e.style.transform||"",x=t.animate([{opacity:y,transform:"translate(0, 0) ".concat(B)},{opacity:0,transform:"translate(".concat(p,", ").concat(v,") ").concat(B)}],Le(Le({fill:"both"},n),{duration:a+c+l})),C=e.animate([{opacity:0,transform:"translate(".concat(-p,", ").concat(-v,") ").concat(E),offset:.01},{opacity:b,transform:"translate(0, 0) ".concat(E)}],Le(Le({fill:"both"},n),{duration:c+l,delay:a+c-l}));return tX(C,i),[x,C]}(this.querySelector(SX.labelItem.class),Eq(this,t,e,l,n),r.update),o=mq(t,e,n),A=o.x,s=o.y,a=rX(this,{transform:"translate(".concat(A,", ").concat(s,")")},r.update);return _e(_e([],He(i),!1),[a],!1)})},function(t){return o=t,t.transition(function(){var t=this,e=iX(this.childNodes[0],r.exit);return tX(e,function(){return kW(t).remove()}),e}),o}).transitions();return s=function(){Bq.call(t,n,i)},0===(A=u).length?s():Promise.all(A.map(function(t){return null==t?void 0:t.finished})).then(s),u}function Cq(t,e){return RX(t,e.tickDirection,e)}function Mq(t,e,n,r,i){var o=He(function(t,e){var n=He(t,2);return[[0,0],[n[0]*e,n[1]*e]]}(r,$V(i.tickLength,[t,e,n])),2),A=He(o[0],2),s=A[0],a=A[1],c=He(o[1],2);return{x1:s,x2:c[0],y1:a,y2:c[1]}}function Fq(t,e,n,r,i,o){var A=function(t,e,n,r,i){var o=i.tickFormatter,A=i.classNamePrefix,s=Cq(e.value,i),a="line";Gt(o)&&(a=function(){return $V(o,[e,n,r,s])});var c=t.append(a).attr("className",SX.tickItem.name);return GX(c,SX.tickItem,xX,A),c}(kW(this),t,e,n,r);!function(t,e,n,r,i,o,A){var s=Cq(t.value,o),a=Mq(t,e,n,s,o),c=a.x1,l=a.x2,u=a.y1,h=a.y2,d=He(PW(IX(A,[t,e,n,s])),2),f=d[0],g=d[1];"line"===r.node().nodeName&&r.styles(Le({x1:c,x2:l,y1:u,y2:h},f)),i.attr(g),r.styles(f)}(t,e,n,A,this,r,i);var s=He(KX(t.value,r),2),a=s[0],c=s[1];return rX(this,{transform:"translate(".concat(a,", ").concat(c,")")},o)}function kq(t,e,n,r,i){var o=He(PW(IW(r,"title")),2),A=o[0],s=o[1],a=s.transform,c=s.transformOrigin,l=Pe(s,["transform","transformOrigin"]);e.styles(l);var u=a||function(t,e,n){var r=2*t.getGeometryBounds().halfExtents[1];if("vertical"===e){if("left"===n)return"rotate(-90) translate(0, ".concat(r/2,")");if("right"===n)return"rotate(-90) translate(0, -".concat(r/2,")")}return""}(t.node(),A.direction,A.position);t.styles(Le(Le({},A),{transformOrigin:c})),RW(t.node(),u);var h=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,A=_W(i),s=t.node().getLocalBounds(),a=He(s.min,2),c=a[0],l=a[1],u=He(s.halfExtents,2),h=u[0],d=u[1],f=He(e.node().getLocalBounds().halfExtents,2),g=f[0],p=f[1],v=He([c+h,l+d],2),m=v[0],y=v[1],w=He(SW(o),4),b=w[0],B=w[1],E=w[2],x=w[3];if(["start","end"].includes(i)&&"linear"===n.type){var C=n.startPos,M=n.endPos,F=He("start"===i?[C,M]:[M,C],2),k=F[0],S=F[1],Q=He(dW(yW([-S[0]+k[0],-S[1]+k[1]]),b),2),U=Q[0],N=Q[1];return{x:k[0]+U,y:k[1]+N}}return A.includes("t")&&(y-=d+p+b),A.includes("r")&&(m+=h+g+B),A.includes("l")&&(m-=h+g+x),A.includes("b")&&(y+=d+p+E),{x:m,y:y}}(kW(n._offscreen||n.querySelector(SX.mainGroup.class)),e,r),d=h.x,f=h.y;return rX(e.node(),{transform:"translate(".concat(d,", ").concat(f,")")},i)}function Sq(t,e,n,r){var i=t.showLine,o=t.showTick,A=t.showLabel,s=t.classNamePrefix,a=e.maybeAppendByClassName(SX.lineGroup,"g");GX(a,SX.lineGroup,gX,s);var c=lW(i,a,function(e){return $X(e,t,r)})||[],l=e.maybeAppendByClassName(SX.tickGroup,"g");GX(l,SX.tickGroup,pX,s);var u=lW(o,l,function(e){return function(t,e,n,r){var i=n.classNamePrefix,o=LX(e,n.tickFilter),A=IW(n,"tick");return t.selectAll(SX.tick.class).data(o,function(t){return t.id||t.label}).join(function(t){var e=t.append("g").attr("className",SX.tick.name).transition(function(t,e){return Fq.call(this,t,e,o,n,A,!1)});return GX(e,SX.tick,EX,i),e},function(t){return t.transition(function(t,e){return this.removeChildren(),Fq.call(this,t,e,o,n,A,r.update)})},function(t){return t.transition(function(){var t=this,e=iX(this.childNodes[0],r.exit);return tX(e,function(){return t.remove()}),e})}).transitions()}(e,n,t,r)})||[],h=e.maybeAppendByClassName(SX.labelGroup,"g");GX(h,SX.labelGroup,vX,s);var d=lW(A,h,function(i){return xq(i,n,t,r,e.node())})||[];return _e(_e(_e([],He(c),!1),He(u),!1),He(d),!1).filter(function(t){return!!t})}var Qq=function(t){function e(e){return t.call(this,e,kX)||this}return Ie(e,t),e.prototype.render=function(t,e,n){var r=this,i=t.titleText,o=t.data,A=t.animate,s=t.showTitle,a=t.showGrid,c=t.dataThreshold,l=t.truncRange,u=t.classNamePrefix,h=e.className||"axis";u?e.attr("className","".concat(h," ").concat(u,"axis")):e.className||e.attr("className","axis");var d=function(t,e){if(t.length<=e)return t;for(var n=Math.floor(t.length/e),r=[],i=0;i<t.length;i+=n)r.push(t[i]);return r}(o,c).filter(function(t){var e=t.value;return!(l&&e>l[0]&&e<l[1])}),f=JY(void 0===n?A:n),g=kW(e).maybeAppendByClassName(SX.gridGroup,"g");GX(g,SX.gridGroup,dX,u);var p=lW(a,g,function(e){return tq(e,d,t,f)})||[],v=kW(e).maybeAppendByClassName(SX.mainGroup,"g");GX(v,SX.mainGroup,fX,u),i&&(!this.initialized&&f.enter||this.initialized&&f.update)&&Sq(t,kW(this.offscreenGroup),d,JY(!1));var m=Sq(t,kW(v.node()),d,f),y=kW(e).maybeAppendByClassName(SX.titleGroup,"g");GX(y,SX.titleGroup,mX,u);var w=lW(s,y,function(e){return function(t,e,n,r){var i=n.titleText,o=n.classNamePrefix;return t.selectAll(SX.title.class).data([{title:i}].filter(function(t){return!!t.title}),function(t,e){return t.title}).join(function(A){var s=A.append(function(){return cW(i)}).attr("className",SX.title.name).transition(function(){return kq(kW(this),t,e,n,r.enter)});return GX(s,SX.title,FX,o),s},function(i){return i.transition(function(){return kq(kW(this),t,e,n,r.update)})},function(t){return t.remove()}).transitions()}(e,r,t,f)})||[];return _e(_e(_e([],He(p),!1),He(m),!1),He(w),!1).flat().filter(function(t){return!!t})},e}(KW);function Uq(t,e,n){return n?"".concat(t," ").concat(n,"legend-").concat(e):t}function Nq(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}$W.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"]]}),$W.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]]}),$W.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 Tq="title",Oq="item",Iq="marker",Lq="label",Pq="value",Dq="focus-icon",Rq="background",Hq="handle-marker",_q="handle-label",Gq="prev-btn",Kq="next-btn",jq="page-info",zq=JV({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),Vq={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,Vq)||this}Ie(e,t),e.prototype.render=function(t,e){var n=kW(e).maybeAppendByClassName(zq.markerGroup,"g");this.renderMarker(n);var r=kW(e).maybeAppendByClassName(zq.labelGroup,"g");this.renderLabel(r)},e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.orientation,i=n.classNamePrefix,o=n.markerSymbol,A=void 0===o?Nq(r,"horizontalHandle","verticalHandle"):o;lW(!!A,t,function(t){var n=IW(e.attributes,"marker"),r=Le({symbol:A},n),o=Uq(zq.marker.name,Hq,i);if(e.marker=t.maybeAppendByClassName(zq.marker,function(){return new $W({style:r,className:o})}).update(r),i){var s=e.marker.node().querySelector(".marker");if(s){var a=Uq((s.getAttribute("class")||"").split(" ")[0],Hq,i);s.setAttribute("class",a)}}})},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,a=n.classNamePrefix;lW(r,t,function(t){var n,r=IW(e.attributes,"label"),o=r.text,c=Pe(r,["text"]),l=(null===(n=t.select(zq.marker.class))||void 0===n?void 0:n.node().getBBox())||{},u=l.width,h=void 0===u?0:u,d=l.height,f=He(Nq(i,[0,(void 0===d?0:d)+A,"center","top"],[h+A,0,"start","middle"]),4),g=f[0],p=f[1],v=f[2],m=f[3],y=Uq(zq.label.name,_q,a);t.maybeAppendByClassName(zq.label,"text").attr("className",y).styles(Le(Le({},c),{x:g,y:p,text:s(o).toString(),textAlign:v,textBaseline:m}))})}}(KW);var Wq={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},Yq=eW({},Wq,{});eW({},Wq,LW(Vq,"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 Xq=JV({title:"title",html:"html",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"),qq=JV({text:"text"},"title");function $q(t,e){var n=Object.entries(e).reduce(function(e,n){var r=He(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e},{});t.styles(n)}var Zq,Jq=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 Ie(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(qq.text.class);if(!A)return new qV(0,0,+e,+n);var s=A.getBBox(),a=s.width,c=s.height,l=He(SW(i),4),u=l[0],h=l[1],d=l[2],f=l[3],g=He([0,0,+e,+n],4),p=g[0],v=g[1],m=g[2],y=g[3],w=_W(r);if(w.includes("i"))return new qV(p,v,m,y);w.forEach(function(t,r){var i,o,A,s;"t"===t&&(i=He(0===r?[c+d,+n-c-d]:[0,+n],2),v=i[0],y=i[1]),"r"===t&&(o=He([+e-a-f],1),m=o[0]),"b"===t&&(A=He([+n-c-u],1),y=A[0]),"l"===t&&(s=He(0===r?[a+h,+e-a-h]:[0,+e],2),p=s[0],m=s[1])});var b=He(SW(o),4),B=b[0],E=b[1],x=b[2],C=b[3],M=He([C+E,B+x],2),F=M[0],k=M[1];return new qV(p+C,v+B,m-F,y-k)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new qV(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=t.classNamePrefix,i=Pe(t,["width","height","position","spacing","classNamePrefix"]),o=He(PW(i),1)[0],A=function(t){var e,n,r,i,o=t,A=o.width,s=o.height,a=o.position,c=He([+A/2,+s/2],2),l=He([+c[0],+c[1],"center","middle"],4),u=l[0],h=l[1],d=l[2],f=l[3],g=_W(a);return g.includes("l")&&(u=(e=He([0,"start"],2))[0],d=e[1]),g.includes("r")&&(u=(n=He([+A,"end"],2))[0],d=n[1]),g.includes("t")&&(h=(r=He([0,"top"],2))[0],f=r[1]),g.includes("b")&&(h=(i=He([+s,"bottom"],2))[0],f=i[1]),{x:u,y:h,textAlign:d,textBaseline:f}}(t),s=A.x,a=A.y,c=A.textAlign,l=A.textBaseline;lW(!!i.text,kW(e),function(t){var e=Uq(qq.text.name,Tq,r);n.title=t.maybeAppendByClassName(qq.text,"text").attr("className",e).styles(o).call($q,{x:s,y:a,textAlign:c,textBaseline:l}).node()})},e}(KW),t$=JV({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"),e$=function(t){function e(e){var n=t.call(this,e,{x:0,y:0,animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonD:XW(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 Xa({class:t$.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new Xa({class:t$.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return Ie(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return ne(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=He(function(t){var e;return(null===(e=t[0])||void 0===e?void 0:e.map(function(e,n){return t.map(function(t){return t[n]})}))||[]}(this.pageViews.map(function(t){var e=t.getBBox();return[e.width,e.height]})).map(function(t){return Math.max.apply(Math,_e([],He(t),!1))}),2),e=t[0],n=t[1],r=this.attributes,i=r.pageWidth,o=void 0===i?e:i,A=r.pageHeight;return{pageWidth:o,pageHeight:void 0===A?n:A}},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.playWindow},Object.defineProperty(e.prototype,"totalPages",{get:function(){return this.pageViews.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currPage",{get:function(){return this.innerCurrPage},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e=t.prototype.getBBox.call(this),n=e.x,r=e.y,i=this.controllerShape,o=this.pageShape,A=o.pageWidth,s=o.pageHeight;return new qV(n,r,A+i.width,s)},e.prototype.goTo=function(t){var e=this,n=this.attributes.animate,r=this,i=r.currPage,o=r.playState,A=r.playWindow,s=r.pageViews;if("idle"!==o||t<0||s.length<=0||t>=s.length)return null;s[i].setLocalPosition(0,0),this.prepareFollowingPage(t);var a=He(this.getFollowingPageDiff(t),2),c=a[0],l=a[1];this.playState="running";var u=nX(A,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-c,", ").concat(-l,")")}],n);return tX(u,function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()}),u},e.prototype.prev=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n<=0)return null;var r=t?(n-1+e)%e:ne(n-1,0,e);return this.goTo(r)},e.prototype.next=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n>=e-1)return null;var r=t?(n+1)%e:ne(n+1,0,e);return this.goTo(r)},e.prototype.renderClipPath=function(t){var e=this.pageShape,n=e.pageWidth,r=e.pageHeight;n&&r?(this.clipPath=t.maybeAppendByClassName(t$.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)?GV(e):KV(e)})},e.prototype.adjustControllerLayout=function(){var t=this,e=t.prevBtnGroup,n=t.nextBtnGroup,r=t.pageInfoGroup,i=this.attributes,o=i.orientation,A=i.controllerPadding,s=r.getBBox(),a=s.width;s.height;var c=He("horizontal"===o?[-180,0]:[-90,90],2),l=c[0],u=c[1];e.setLocalEulerAngles(l),n.setLocalEulerAngles(u);var h=e.getBBox(),d=h.width,f=h.height,g=n.getBBox(),p=g.width,v=g.height,m=Math.max(d,a,p),y="horizontal"===o?{offset:[[0,0],[d/2+A,0],[d+a+2*A,0]],textAlign:"start"}:{offset:[[m/2,-f-A],[m/2,0],[m/2,v+A]],textAlign:"center"},w=He(y.offset,3),b=He(w[0],2),B=b[0],E=b[1],x=He(w[1],2),C=x[0],M=x[1],F=He(w[2],2),k=F[0],S=F[1],Q=y.textAlign,U=r.querySelector("text");U&&(U.style.textAlign=Q),e.setLocalPosition(B,E),r.setLocalPosition(C,M),n.setLocalPosition(k,S)},e.prototype.updatePageInfo=function(){var t,e=this,n=e.currPage,r=e.pageViews,i=e.attributes.formatter;r.length<2||(null===(t=this.pageInfoGroup.querySelector(t$.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=He(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,r=n.controllerSpacing,i=n.classNamePrefix,o=void 0===i?"":i,A=this.pageShape,s=A.pageWidth,a=A.pageHeight,c=this.pageViews.length>=2,l=t.maybeAppendByClassName(t$.controller,"g");if(jV(l.node(),c),c){var u=IW(this.attributes,"button"),h=IW(this.attributes,"pageNum"),d=He(PW(u),2),f=d[0],g=d[1],p=f.size,v=Pe(f,["size"]),m=!l.select(t$.prevBtnGroup.class).node(),y=l.maybeAppendByClassName(t$.prevBtnGroup,"g").styles(g);this.prevBtnGroup=y.node();var w=y.maybeAppendByClassName(t$.prevBtn,"path");if(o){var b=Uq(t$.prevBtn.name,Gq,o);w.node().setAttribute("class",b)}var B=l.maybeAppendByClassName(t$.nextBtnGroup,"g").styles(g);this.nextBtnGroup=B.node();var E=B.maybeAppendByClassName(t$.nextBtn,"path");if(o){var x=Uq(t$.nextBtn.name,Kq,o);E.node().setAttribute("class",x)}[w,E].forEach(function(t){t.styles(Le(Le({},v),{transformOrigin:"center"})),MW(t.node(),p)});var C=l.maybeAppendByClassName(t$.pageInfoGroup,"g");this.pageInfoGroup=C.node();var M=C.maybeAppendByClassName(t$.pageInfo,"text");if(M.styles(h),o){var F=Uq(t$.pageInfo.name,jq,o);M.node().setAttribute("class",F)}this.updatePageInfo(),l.node().setLocalPosition(s+r,a/2),m&&(this.prevBtnGroup.addEventListener("click",function(){e.prev()}),this.nextBtnGroup.addEventListener("click",function(){e.next()}))}},e.prototype.render=function(t,e){var n=t.x,r=void 0===n?0:n,i=t.y,o=void 0===i?0:i;this.attr("transform","translate(".concat(r,", ").concat(o,")"));var A=kW(e);this.renderClipPath(A),this.renderController(A),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=pe(function(){return t.render(t.attributes,t)},50);this.playWindow.addEventListener(ea.INSERTED,e),this.playWindow.addEventListener(ea.REMOVED,e)},e}(KW),n$="component-poptip",r$="component-poptip-arrow",i$="component-poptip-text",o$=((Zq={})[".".concat(n$)]={visibility:"visible",position:"absolute","background-color":"rgba(0, 0, 0)","box-shadow":"0px 0px 10px #aeaeae","border-radius":"3px",color:"#fff",opacity:.8,"font-size":"12px",padding:"4px 6px",display:"flex","justify-content":"center","align-items":"center","z-index":8,transition:"visibility 50ms"},Zq[".".concat(i$)]={"text-align":"center"},Zq[".".concat(n$,"[data-position='top']")]={transform:"translate(-50%, -100%)"},Zq[".".concat(n$,"[data-position='left']")]={transform:"translate(-100%, -50%)"},Zq[".".concat(n$,"[data-position='right']")]={transform:"translate(0, -50%)"},Zq[".".concat(n$,"[data-position='bottom']")]={transform:"translate(-50%, 0)"},Zq[".".concat(n$,"[data-position='top-left']")]={transform:"translate(0,-100%)"},Zq[".".concat(n$,"[data-position='top-right']")]={transform:"translate(-100%,-100%)"},Zq[".".concat(n$,"[data-position='left-top']")]={transform:"translate(-100%, 0)"},Zq[".".concat(n$,"[data-position='left-bottom']")]={transform:"translate(-100%, -100%)"},Zq[".".concat(n$,"[data-position='right-top']")]={transform:"translate(0, 0)"},Zq[".".concat(n$,"[data-position='right-bottom']")]={transform:"translate(0, -100%)"},Zq[".".concat(n$,"[data-position='bottom-left']")]={transform:"translate(0, 0)"},Zq[".".concat(n$,"[data-position='bottom-right']")]={transform:"translate(-100%, 0)"},Zq[".".concat(r$)]={width:"4px",height:"4px",transform:"rotate(45deg)","background-color":"rgba(0, 0, 0)",position:"absolute","z-index":-1},Zq[".".concat(n$,"[data-position='top']")]={transform:"translate(-50%, calc(-100% - 5px))"},Zq["[data-position='top'] .".concat(r$)]={bottom:"-2px"},Zq[".".concat(n$,"[data-position='left']")]={transform:"translate(calc(-100% - 5px), -50%)"},Zq["[data-position='left'] .".concat(r$)]={right:"-2px"},Zq[".".concat(n$,"[data-position='right']")]={transform:"translate(5px, -50%)"},Zq["[data-position='right'] .".concat(r$)]={left:"-2px"},Zq[".".concat(n$,"[data-position='bottom']")]={transform:"translate(-50%, 5px)"},Zq["[data-position='bottom'] .".concat(r$)]={top:"-2px"},Zq[".".concat(n$,"[data-position='top-left']")]={transform:"translate(0, calc(-100% - 5px))"},Zq["[data-position='top-left'] .".concat(r$)]={left:"10px",bottom:"-2px"},Zq[".".concat(n$,"[data-position='top-right']")]={transform:"translate(-100%, calc(-100% - 5px))"},Zq["[data-position='top-right'] .".concat(r$)]={right:"10px",bottom:"-2px"},Zq[".".concat(n$,"[data-position='left-top']")]={transform:"translate(calc(-100% - 5px), 0)"},Zq["[data-position='left-top'] .".concat(r$)]={right:"-2px",top:"8px"},Zq[".".concat(n$,"[data-position='left-bottom']")]={transform:"translate(calc(-100% - 5px), -100%)"},Zq["[data-position='left-bottom'] .".concat(r$)]={right:"-2px",bottom:"8px"},Zq[".".concat(n$,"[data-position='right-top']")]={transform:"translate(5px, 0)"},Zq["[data-position='right-top'] .".concat(r$)]={left:"-2px",top:"8px"},Zq[".".concat(n$,"[data-position='right-bottom']")]={transform:"translate(5px, -100%)"},Zq["[data-position='right-bottom'] .".concat(r$)]={left:"-2px",bottom:"8px"},Zq[".".concat(n$,"[data-position='bottom-left']")]={transform:"translate(0, 5px)"},Zq["[data-position='bottom-left'] .".concat(r$)]={top:"-2px",left:"8px"},Zq[".".concat(n$,"[data-position='bottom-right']")]={transform:"translate(-100%, 5px)"},Zq["[data-position='bottom-right'] .".concat(r$)]={top:"-2px",right:"8px"},Zq);function A$(t){var e=t&&document.getElementById(t);return e||((e=document.createElement("div")).setAttribute("id",t),document.body.appendChild(e)),e}var s$=function(t){function e(n){var r=t.call(this,be({style:{id:"component-poptip"}},e.defaultOptions,n))||this;return r.visibility="visible",r.map=new Map,r.domStyles="",r.initShape(),r.render(r.attributes,r),r}return Ie(e,t),Object.defineProperty(e.prototype,"visible",{get:function(){return"visible"===this.visibility},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.visibility=this.style.visibility,this.updatePoptipElement()},e.prototype.update=function(t){this.attr(be({},this.style,t)),this.render(this.attributes,this)},e.prototype.bind=function(t,e){var n=this;if(t){var r=this.style.text,i=function(i){var o=t,A=n.style,s=r;if(e){var a="function"==typeof e?e.call(null,i):e,c=a.html,l=a.target,u=Pe(a,["html","target"]);A=function(t,e,n){return e&&fe(t,e),n&&fe(t,n),t}({},n.style,u),(l||!1===l)&&(o=l),"string"==typeof c&&(s=c)}var h=A.position,d=A.arrowPointAtCenter,f=A.follow,g=A.offset;if(o){var p=i,v=He(function(t,e,n,r,i,o){if(void 0===i&&(i=!1),void 0===o&&(o=!1),o)return[t,e];var A=n.getBoundingClientRect(),s=A.x,a=A.y,c=A.width,l=A.height;switch(r){case"top":return i?[s+c/2,a]:[t,a];case"left":return i?[s,a+l/2]:[s,e];case"bottom":return i?[s+c/2,a+l]:[t,a+l];case"right":return i?[s+c,a+l/2]:[s+c,e];case"top-right":case"right-top":return[s+c,a];case"left-bottom":case"bottom-left":return[s,a+l];case"right-bottom":case"bottom-right":return[s+c,a+l];default:return[s,a]}}(p.clientX,p.clientY,o,h,d,f),2),m=v[0],y=v[1];n.showTip(m,y,{text:s,position:h,offset:g})}else n.hideTip()},o=function(){n.hideTip()};t.addEventListener("mousemove",i),t.addEventListener("mouseleave",o),this.map.set(t,[i,o])}},e.prototype.unbind=function(t){if(this.map.has(t)){var e=He(this.map.get(t)||[],2),n=e[0],r=e[1];n&&t.removeEventListener("mousemove",n),r&&t.removeEventListener("mouseleave",r),this.map.delete(t)}},e.prototype.clear=function(){this.container.innerHTML=""},e.prototype.destroy=function(){var e,n=this;_e([],He(this.map.keys()),!1).forEach(function(t){return n.unbind(t)}),null===(e=this.container)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.showTip=function(t,e,n){var r=Ce(n,"text");if((!r||"string"==typeof r)&&(this.applyStyles(),t&&e&&n)){var i=n.offset,o=n.position;if(o&&this.container.setAttribute("data-position",o),this.setOffsetPosition(t,e,i),"string"==typeof r){var A=this.container.querySelector(".".concat(i$));A&&(A.innerHTML=r)}this.visibility="visible",this.container.style.visibility="visible"}},e.prototype.hideTip=function(){this.visibility="hidden",this.container.style.visibility="hidden"},e.prototype.getContainer=function(){return this.container},e.prototype.getClassName=function(){var t=this.style.containerClassName;return"".concat(n$).concat(t?" ".concat(t):"")},e.prototype.initShape=function(){var t=this,e=this.style.id;this.container=function(t){var e,n,r=(e=A$,function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n||(n=e.apply(void 0,t)),n})(t);return r}(e),this.container.className=this.getClassName(),this.container.addEventListener("mousemove",function(){return t.showTip()}),this.container.addEventListener("mouseleave",function(){return t.hideTip()})},e.prototype.updatePoptipElement=function(){var t=this.container;this.clear();var e=this.style,n=e.id,r=e.template,i=e.text;this.container.setAttribute("id",n),this.container.className=this.getClassName();var o,A='<span class="'.concat(r$,'"></span>');t.innerHTML=A,Jt(r)?t.innerHTML+=r:r&&((o=r)instanceof Element||o instanceof Document)&&t.appendChild(r),i&&(t.getElementsByClassName(i$)[0].textContent=i),this.applyStyles(),this.container.style.visibility=this.visibility},e.prototype.applyStyles=function(){var t=eW({},o$,this.style.domStyles),e=Object.entries(t).reduce(function(t,e){var n=He(e,2),r=n[0],i=n[1],o=Object.entries(i).reduce(function(t,e){var n=He(e,2),r=n[0],i=n[1];return"".concat(t).concat(r,": ").concat(i,";")},"");return"".concat(t).concat(r,"{").concat(o,"}")},"");if(this.domStyles!==e){this.domStyles=e;var n=this.container.querySelector("style");n&&this.container.removeChild(n),(n=document.createElement("style")).innerHTML=e,this.container.appendChild(n)}},e.prototype.setOffsetPosition=function(t,e,n){void 0===n&&(n=this.style.offset);var r=He(n,2),i=r[0],o=void 0===i?0:i,A=r[1],s=void 0===A?0:A;this.container.style.left="".concat(t+o,"px"),this.container.style.top="".concat(e+s,"px")},e.tag="poptip",e.defaultOptions={style:{x:0,y:0,width:0,height:0,target:null,visibility:"hidden",text:"",position:"top",follow:!1,offset:[0,0],domStyles:o$,template:'<div class="'.concat(i$,'"></div>')}},e}(KW),a$=JV({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",focusGroup:"focus-group",focus:"focus",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item"),c$={offset:[0,20],domStyles:{".component-poptip":{opacity:"1",padding:"8px 12px",background:"#fff",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)"},".component-poptip-arrow":{display:"none"},".component-poptip-text":{color:"#000",lineHeight:"20px"}}};var l$=function(t){function e(e,n){var r=t.call(this,e,{span:[1,1],marker:function(){return new za({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this;return r.keyFields={},r.keyFields=n||{},r}return Ie(e,t),Object.defineProperty(e.prototype,"showValue",{get:function(){var t=this.attributes.valueText;return!!t&&("string"==typeof t||"number"==typeof t?""!==t:"function"==typeof t||""!==t.attr("text"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"actualSpace",{get:function(){var t=this.labelGroup,e=this.valueGroup,n=this.attributes,r=n.markerSize,i=n.focus,o=n.focusMarkerSize,A=t.node().getBBox(),s=A.width,a=A.height,c=e.node().getBBox(),l=c.width,u=c.height;return{markerWidth:r,labelWidth:s,valueWidth:l,focusWidth:i?null!=o?o:12:0,height:Math.max(r,a,u)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=He(SW(t),2),n=e[0],r=e[1],i=this.showValue?r:0,o=n+i;return[n/o,i/o]},enumerable:!1,configurable:!0}),e.prototype.setAttribute=function(e,n){t.prototype.setAttribute.call(this,e,n)},Object.defineProperty(e.prototype,"shape",{get:function(){var t,e=this.attributes,n=e.markerSize,r=e.width,i=this.actualSpace,o=i.markerWidth,A=i.focusWidth,s=i.height,a=this.actualSpace,c=a.labelWidth,l=a.valueWidth,u=He(this.spacing,3),h=u[0],d=u[1],f=u[2];if(r){var g=r-n-h-d-A-f,p=He(this.span,2);c=(t=He([p[0]*g,p[1]*g],2))[0],l=t[1]}return{width:o+c+l+h+d+A+f,height:s,markerWidth:o,labelWidth:c,valueWidth:l,focusWidth:A}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes,e=t.spacing,n=t.focus;if(!e)return[0,0,0];var r=He(SW(e),3),i=r[0],o=r[1],A=r[2];return[i,this.showValue?o:0,n?A:0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layout",{get:function(){var t=this.shape,e=t.markerWidth,n=t.labelWidth,r=t.valueWidth,i=t.focusWidth,o=t.width,A=t.height,s=He(this.spacing,3),a=s[0],c=s[1];return{height:A,width:o,markerWidth:e,labelWidth:n,valueWidth:r,focusWidth:i,position:[e/2,e+a,e+n+a+c,e+n+r+a+c+s[2]+i/2]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(a$.marker.class);return e?e.style:{}}(this.markerGroup.node()),e=this.attributes,n=e.markerSize,r=e.markerStrokeWidth,i=void 0===r?t.strokeWidth:r,o=e.markerLineWidth,A=void 0===o?t.lineWidth:o,s=e.markerStroke,a=void 0===s?t.stroke:s,c=+(i||A||(a?1:0))*Math.sqrt(2),l=this.markerGroup.node().getBBox(),u=l.width,h=l.height;return(1-c/Math.max(u,h))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.marker,i=n.classNamePrefix,o=IW(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(a$.markerGroup,"g").style("zIndex",0),lW(!!r,this.markerGroup,function(){var t,n=e.markerGroup.node(),A=null===(t=n.childNodes)||void 0===t?void 0:t[0],s=Uq(a$.marker.name,Iq,i),a="string"==typeof r?new $W({style:{symbol:r},className:s}):r();if(A)if(a.nodeName===A.nodeName)A instanceof $W?A.update(Le(Le({},o),{symbol:r})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=Re(Object.entries(i)),A=o.next();!A.done;A=o.next()){var s=He(A.value,2),a=s[0],c=s[1];"id"!==a&&"className"!==a&&t.attr(a,c)}}catch(t){n={error:t}}finally{try{A&&!A.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(A,a),kW(A).styles(o));else{if(A.remove(),!(a instanceof $W)){var c=Uq(a$.marker.name,Iq,i);a.className=c}kW(a).styles(o),n.appendChild(a)}else{if(!(a instanceof $W)){var l=Uq(a$.marker.name,Iq,i);a.className=l,kW(a).styles(o)}n.appendChild(a)}e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]);var u=MW(e.markerGroup.node(),e.scaleSize);e.markerGroup.node().style._transform="scale(".concat(u,")")})},e.prototype.renderLabel=function(t){var e=IW(this.attributes,"label"),n=e.text,r=Pe(e,["text"]),i=this.attributes.classNamePrefix;this.labelGroup=t.maybeAppendByClassName(a$.labelGroup,"g").style("zIndex",0);var o=Uq(a$.label.name,Lq,i),A=this.labelGroup.maybeAppendByClassName(a$.label,function(){return cW(n)});A.node().setAttribute("class",o),A.styles(r)},e.prototype.renderValue=function(t){var e=this,n=IW(this.attributes,"value"),r=n.text,i=Pe(n,["text"]),o=this.attributes.classNamePrefix;this.valueGroup=t.maybeAppendByClassName(a$.valueGroup,"g").style("zIndex",0),lW(this.showValue,this.valueGroup,function(){var t=Uq(a$.value.name,Pq,o),n=e.valueGroup.maybeAppendByClassName(a$.value,function(){return cW(r)});n.node().setAttribute("class",t),n.styles(i)})},e.prototype.createPoptip=function(){var t=this.attributes.poptip||{};t.render;var e=Pe(t,["render"]),n=new s$({style:eW(c$,e)});return this.poptipGroup=n,n},e.prototype.bindPoptip=function(t){var e=this,n=this.attributes.poptip;n&&(this.poptipGroup||this.createPoptip()).bind(t,function(){var t=e.attributes,r=t.labelText,i=t.valueText,o=t.markerFill,A="string"==typeof r?r:null==r?void 0:r.attr("text"),s="string"==typeof i?i:null==i?void 0:i.attr("text");if("function"==typeof n.render)return{html:n.render(Le(Le({},e.keyFields),{label:A,value:s,color:o}))};var a="";return"string"!=typeof A&&"number"!=typeof A||(a+='<div class="component-poptip-label">'.concat(A,"</div>")),"string"!=typeof s&&"number"!=typeof s||(a+='<div class="component-poptip-value">'.concat(s,"</div>")),{html:a}})},e.prototype.renderFocus=function(t){var e=this,n=this.attributes,r=n.focus,i=n.focusMarkerSize,o=n.classNamePrefix,A={x:0,y:0,size:i,opacity:.6,symbol:"focus",stroke:"#aaaaaa",lineWidth:1};de(r)||(this.focusGroup=t.maybeAppendByClassName(a$.focusGroup,"g").style("zIndex",0),lW(r,this.focusGroup,function(){var n=Uq(a$.focus.name,Dq,o),r=new $W({style:Le(Le({},A),{symbol:"focus"}),className:n}),i=new za({style:{r:A.size/2,fill:"transparent"}}),s=e.focusGroup.node();s.appendChild(i),s.appendChild(r),r.update({opacity:0}),t.node().addEventListener("pointerenter",function(){r.update({opacity:1})}),t.node().addEventListener("pointerleave",function(){r.update({opacity:0})})}))},e.prototype.renderPoptip=function(t){var e=this;this.attributes.poptip&&[t.maybeAppendByClassName(a$.value,"g").node(),t.maybeAppendByClassName(a$.label,"g").node()].forEach(function(t){t&&e.bindPoptip(t)})},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=IW(this.attributes,"background");this.background=t.maybeAppendByClassName(a$.backgroundGroup,"g").style("zIndex",-1);var o=this.background.maybeAppendByClassName(a$.background,"rect");o.styles(Le({width:n,height:r},i));var A=this.attributes.classNamePrefix,s=void 0===A?"":A;if(s){var a=Uq(a$.background.name,Rq,s);o.node().setAttribute("class",a)}},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=He(t.position,4),o=i[0],A=i[1],s=i[2],a=i[3],c=r/2;this.markerGroup.styles({transform:"translate(".concat(o,", ").concat(c,")").concat(this.markerGroup.node().style._transform)}),this.labelGroup.styles({transform:"translate(".concat(A,", ").concat(c,")")}),this.focusGroup&&this.focusGroup.styles({transform:"translate(".concat(a,", ").concat(c,")")}),sW(this.labelGroup.select(a$.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({transform:"translate(".concat(s,", ").concat(c,")")}),sW(this.valueGroup.select(a$.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=kW(e),r=t.x,i=void 0===r?0:r,o=t.y,A=void 0===o?0:o;n.styles({transform:"translate(".concat(i,", ").concat(A,")")}),this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.renderPoptip(n),this.renderFocus(n),this.adjustLayout()},e}(KW),u$=JV({page:"item-page",navigator:"navigator",item:"item"},"items"),h$=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},d$=function(t){function e(e){var n=t.call(this,e,{data:[],gridRow:1/0,gridCol:void 0,padding:0,width:1e3,height:100,rowPadding:0,colPadding:0,layout:"flex",orientation:"horizontal",click:Ne,mouseenter:Ne,mouseleave:Ne})||this;return n.navigatorShape=[0,0],n}return Ie(e,t),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.navigator.getContainer()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){var t=this.attributes,e=t.gridRow,n=t.gridCol,r=t.data;if(!e&&!n)throw new Error("gridRow and gridCol can not be set null at the same time");return e&&n?[e,n]:e?[e,r.length]:[r.length,n]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderData",{get:function(){var t=this.attributes,e=t.data,n=t.layout,r=t.poptip,i=t.focus,o=t.focusMarkerSize,A=t.classNamePrefix,s=IW(this.attributes,"item"),a=e.map(function(t,a){var c=t.id,l=void 0===c?a:c,u=t.label,h=t.value;return{id:"".concat(l),index:a,style:Le({layout:n,labelText:u,valueText:h,poptip:r,focus:i,focusMarkerSize:o,classNamePrefix:A},Object.fromEntries(Object.entries(s).map(function(n){var r=He(n,2);return[r[0],$V(r[1],[t,a,e])]})))}});return a},enumerable:!1,configurable:!0}),e.prototype.getGridLayout=function(){var t=this,e=this.attributes,n=e.orientation,r=e.width,i=e.rowPadding,o=e.colPadding,A=He(this.navigatorShape,1)[0],s=He(this.grid,2),a=s[0],c=s[1],l=c*a,u=0;return this.pageViews.children.map(function(e,s){var h,d,f=Math.floor(s/l),g=s%l,p=t.ifHorizontal(c,a),v=[Math.floor(g/p),g%p];"vertical"===n&&v.reverse();var m=He(v,2),y=m[0],w=m[1],b=(r-A-(c-1)*o)/c,B=e.getBBox().height,E=He([0,0],2),x=E[0],C=E[1];return"horizontal"===n?(x=(h=He([u,y*(B+i)],2))[0],C=h[1],u=w===c-1?0:u+b+o):(x=(d=He([w*(b+o),u],2))[0],C=d[1],u=y===a-1?0:u+B+i),{page:f,index:s,row:y,col:w,pageIndex:g,width:b,height:B,x:x,y:C}})},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=He(this.navigatorShape,1)[0],A=He(this.grid,2),s=A[0],a=A[1],c=He([e-o,n],2),l=c[0],u=c[1],h=He([0,0,0,0,0,0,0,0],8),d=h[0],f=h[1],g=h[2],p=h[3],v=h[4],m=h[5],y=h[6],w=h[7];return this.pageViews.children.map(function(t,e){var n,o,A,c,h=t.getBBox(),b=h.width,B=h.height,E=0===y?0:i,x=y+E+b;return x<=l&&h$(v,function(t){return t<a})?(n=He([y+E,w,x],3),d=n[0],f=n[1],y=n[2],{width:b,height:B,x:d,y:f,page:g,index:e,pageIndex:p++,row:m,col:v++}):(o=He([m+1,0,0,w+B+r],4),m=o[0],v=o[1],y=o[2],(w=o[3])+B<=u&&h$(m,function(t){return t<s})?(A=He([y,w,b],3),d=A[0],f=A[1],y=A[2],{width:b,height:B,x:d,y:f,page:g,index:e,pageIndex:p++,row:m,col:v++}):(c=He([0,0,b,0,g+1,0,0,0],8),d=c[0],f=c[1],y=c[2],w=c[3],g=c[4],p=c[5],m=c[6],v=c[7],{width:b,height:B,x:d,y:f,page:g,index:e,pageIndex:p++,row:m,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 Nq(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(u$.item.class).forEach(function(e){t.appendChild(e)}),t.querySelectorAll(u$.page.class).forEach(function(e){t.removeChild(e).destroy()})},e.prototype.renderItems=function(t){var e=this.attributes,n=e.click,r=e.mouseenter,i=e.mouseleave,o=e.classNamePrefix;this.flattenPage(t);var A=this.dispatchCustomEvent.bind(this),s=Uq(u$.item.name,Oq,o);kW(t).selectAll(u$.item.class).data(this.renderData,function(t){return t.id}).join(function(t){return t.append(function(t){var e=t.style,n=Pe(t,["style"]);return new l$({style:e},n)}).attr("className",s).on("click",function(){null==n||n(this),A("itemClick",{item:this})}).on("pointerenter",function(){null==r||r(this),A("itemMouseenter",{item:this})}).on("pointerleave",function(){null==i||i(this),A("itemMouseleave",{item:this})})},function(t){return t.each(function(t){var e=t.style;this.update(e)})},function(t){return t.remove()})},e.prototype.relayoutNavigator=function(){var t,e=this.attributes,n=e.layout,r=e.width,i=(null===(t=this.pageViews.children[0])||void 0===t?void 0:t.getBBox().height)||0,o=He(this.navigatorShape,2),A=o[0],s=o[1];this.navigator.update("grid"===n?{pageWidth:r-A,pageHeight:i-s}:{})},e.prototype.adjustLayout=function(){var t,e,n=this,r=Object.entries((t=this.itemsLayout,e="page",t.reduce(function(t,n){return(t[n[e]]=t[n[e]]||[]).push(n),t},{}))).map(function(t){var e=He(t,2);return{page:e[0],layouts:e[1]}}),i=_e([],He(this.navigator.getContainer().children),!1);r.forEach(function(t){var e=t.layouts,r=n.pageViews.appendChild(new Xa({className:u$.page.name}));e.forEach(function(t){var e=t.x,n=t.y,o=t.index,A=t.width,s=t.height,a=i[o];r.appendChild(a),Me(a,"__layout__",t),a.update({x:e,y:n,width:A,height:s})})}),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes,n=e.orientation,r=e.classNamePrefix,i=IW(this.attributes,"nav"),o=eW({orientation:n,classNamePrefix:r},i),A=this;return t.selectAll(u$.navigator.class).data(["nav"]).join(function(t){return t.append(function(){return new e$({style:o})}).attr("className",u$.navigator.name).each(function(){A.navigator=this})},function(t){return t.each(function(){this.update(o)})},function(t){return t.remove()}),this.navigator},e.prototype.getBBox=function(){return this.navigator.getBBox()},e.prototype.render=function(t,e){var n=this.attributes.data;if(n&&0!==n.length){var r=this.renderNavigator(kW(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new Vs(t,{detail:e});this.dispatchEvent(n)},e}(KW),f$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.update=function(t){this.attr(t)},e}($a),g$=function(t){function e(e){return t.call(this,e,Yq)||this}return Ie(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,A=r.classNamePrefix,s=He(PW(IW(this.attributes,"title")),2),a=s[0],c=s[1];this.titleGroup=t.maybeAppendByClassName(Xq.titleGroup,"g").styles(c);var l=Le(Le({width:e,height:n},a),{text:i?o:"",classNamePrefix:A});this.title=this.titleGroup.maybeAppendByClassName(Xq.title,function(){return new Jq({style:l})}).update(l)},e.prototype.renderCustom=function(t){var e=this.attributes.data,n={innerHTML:this.attributes.render(e),pointerEvents:"auto"};t.maybeAppendByClassName(Xq.html,function(){return new f$({className:Xq.html.name,style:n})}).update(n)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,A=He(PW(IW(this.attributes,"title",!0)),2),s=A[0],a=A[1],c=Le(Le({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName(Xq.itemsGroup,"g").styles(Le(Le({},a),{transform:"translate(".concat(n,", ").concat(r,")")}));var l=this;this.itemsGroup.selectAll(Xq.items.class).data(["items"]).join(function(t){return t.append(function(){return new d$({style:c})}).attr("className",Xq.items.name).each(function(){l.items=kW(this)})},function(t){return t.update(c)},function(t){return t.remove()})},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().style.transform="translate(".concat(e,", ").concat(n,")")}},Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes,e=t.showTitle,n=t.width,r=t.height;return e?this.title.node().getAvailableSpace():new qV(0,0,n,r)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e,n,r=null===(e=this.title)||void 0===e?void 0:e.node(),i=null===(n=this.items)||void 0===n?void 0:n.node();return r&&i?function(t,e){var n=t.attributes,r=n.position,i=n.spacing,o=n.inset,A=n.text,s=t.getBBox(),a=e.getBBox(),c=_W(r),l=He(SW(A?i:0),4),u=l[0],h=l[1],d=l[2],f=l[3],g=He(SW(o),4),p=g[0],v=g[1],m=g[2],y=g[3],w=He([f+h,u+d],2),b=w[0],B=w[1],E=He([y+v,p+m],2),x=E[0],C=E[1];if("l"===c[0])return new qV(s.x,s.y,a.width+s.width+b+x,Math.max(a.height+C,s.height));if("t"===c[0])return new qV(s.x,s.y,Math.max(a.width+x,s.width),a.height+s.height+B+C);var M=He([e.attributes.width||a.width,e.attributes.height||a.height],2),F=M[0],k=M[1];return new qV(a.x,a.y,F+s.width+b+x,k+s.height+B+C)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=this.attributes,r=n.width,i=n.height,o=n.x,A=void 0===o?0:o,s=n.y,a=void 0===s?0:s,c=n.classNamePrefix,l=n.render,u=kW(e),h=e.className||"legend-category";c?e.attr("className","".concat(h," ").concat(c,"legend")):e.className||e.attr("className","legend-category"),e.style.transform="translate(".concat(A,", ").concat(a,")"),l?this.renderCustom(u):(this.renderTitle(u,r,i),this.renderItems(u,this.availableSpace),this.adjustLayout())},e}(KW),p$={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},v$=JV({background:"background",labelGroup:"label-group",label:"label"},"indicator"),m$=function(t){function e(e){var n=t.call(this,e,p$)||this;return n.point=[0,0],n.group=n.appendChild(new Xa({})),n.isMutationObserved=!0,n}return Ie(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=He(SW(t.padding),4),r=n[0],i=n[1],o=n[2],A=n[3],s=this.label.node().getLocalBounds(),a=s.min,c=s.max,l=new qV(a[0]-A,a[1]-r,c[0]+i-a[0]+A,c[1]+o-a[1]+r),u=this.getPath(e,l),h=IW(this.attributes,"background");this.background=kW(this.group).maybeAppendByClassName(v$.background,"path").styles(Le(Le({},h),{d:u})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=He(PW(IW(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var A=Pe(i,["text"]);(this.label=kW(this.group).maybeAppendByClassName(v$.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(v$.label,function(){return cW(e(n))}).style("text",e(n).toString()).selectAll("text").styles(A)},e.prototype.adjustLayout=function(){var t=He(this.point,2),e=t[0],n=t[1],r=this.attributes,i=r.x,o=r.y;this.group.attr("transform","translate(".concat(i-e,", ").concat(o-n,")"))},e.prototype.getPath=function(t,e){var n=this.attributes.radius,r=e.x,i=e.y,o=e.width,A=e.height,s=[["M",r+n,i],["L",r+o-n,i],["A",n,n,0,0,1,r+o,i+n],["L",r+o,i+A-n],["A",n,n,0,0,1,r+o-n,i+A],["L",r+n,i+A],["A",n,n,0,0,1,r,i+A-n],["L",r,i+n],["A",n,n,0,0,1,r+n,i],["Z"]],a={top:4,right:6,bottom:0,left:2}[t],c=this.createCorner([s[a].slice(-2),s[a+1].slice(-2)]);return s.splice.apply(s,_e([a+1,1],He(c),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=UW.apply(void 0,_e([],He(t),!1)),r=He(t,2),i=He(r[0],2),o=i[0],A=i[1],s=He(r[1],2),a=s[0],c=s[1],l=He(n?[a-o,[o,a]]:[c-A,[A,c]],2),u=l[0],h=He(l[1],2),d=h[0],f=h[1],g=u/2,p=e*(u/Math.abs(u)),v=p/2,m=p*Math.sqrt(3)/2*.8,y=He([d,d+g-v,d+g,d+g+v,f],5),w=y[0],b=y[1],B=y[2],E=y[3],x=y[4];return n?(this.point=[B,A-m],[["L",w,A],["L",b,A],["L",B,A-m],["L",E,A],["L",x,A]]):(this.point=[o+m,B],[["L",o,w],["L",o,b],["L",o+m,B],["L",o,E],["L",o,x]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?KV(this):GV(this)},e.prototype.bindEvents=function(){this.label.on(ea.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(KW);function y$(t){return void 0===t&&(t=""),{CONTAINER:"".concat(t,"tooltip"),TITLE:"".concat(t,"tooltip-title"),LIST:"".concat(t,"tooltip-list"),LIST_ITEM:"".concat(t,"tooltip-list-item"),NAME:"".concat(t,"tooltip-list-item-name"),MARKER:"".concat(t,"tooltip-list-item-marker"),NAME_LABEL:"".concat(t,"tooltip-list-item-name-label"),VALUE:"".concat(t,"tooltip-list-item-value"),CROSSHAIR_X:"".concat(t,"tooltip-crosshair-x"),CROSSHAIR_Y:"".concat(t,"tooltip-crosshair-y")}}var w$={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function b$(t){var e;void 0===t&&(t="");var n=y$(t);return(e={})[".".concat(n.CONTAINER)]={position:"absolute",visibility:"visible","z-index":8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)","background-color":"rgba(255, 255, 255, 0.96)","box-shadow":"0 6px 12px 0 rgba(0, 0, 0, 0.12)","border-radius":"4px",color:"rgba(0, 0, 0, 0.65)","font-size":"12px","line-height":"20px",padding:"12px","min-width":"120px","max-width":"360px","font-family":"Roboto-Regular"},e[".".concat(n.TITLE)]={color:"rgba(0, 0, 0, 0.45)"},e[".".concat(n.LIST)]={margin:"0px","list-style-type":"none",padding:"0px"},e[".".concat(n.LIST_ITEM)]={"list-style-type":"none",display:"flex","line-height":"2em","align-items":"center","justify-content":"space-between","white-space":"nowrap"},e[".".concat(n.MARKER)]={width:"8px",height:"8px","border-radius":"50%",display:"inline-block","margin-right":"4px"},e[".".concat(n.NAME)]={display:"flex","align-items":"center","max-width":"216px"},e[".".concat(n.NAME_LABEL)]=Le({flex:1},w$),e[".".concat(n.VALUE)]=Le({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},w$),e[".".concat(n.CROSSHAIR_X)]={position:"absolute",width:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e[".".concat(n.CROSSHAIR_Y)]={position:"absolute",height:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e}var B$=function(t){function e(e){var n,r,i=this,o=null===(r=null===(n=e.style)||void 0===n?void 0:n.template)||void 0===r?void 0:r.prefixCls,A=y$(o);return(i=t.call(this,e,{data:[],x:0,y:0,visibility:"visible",title:"",position:"bottom-right",offset:[5,5],enterable:!1,container:{x:0,y:0},bounding:null,template:{prefixCls:"",container:'<div class="'.concat(A.CONTAINER,'"></div>'),title:'<div class="'.concat(A.TITLE,'"></div>'),item:'<li class="'.concat(A.LIST_ITEM,'" data-index={index}>\n <span class="').concat(A.NAME,'">\n <span class="').concat(A.MARKER,'" style="background:{color}"></span>\n <span class="').concat(A.NAME_LABEL,'" title="{name}">{name}</span>\n </span>\n <span class="').concat(A.VALUE,'" title="{value}">{value}</span>\n </li>')},style:b$(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return Ie(e,t),Object.defineProperty(e.prototype,"HTMLTooltipElement",{get:function(){return this.element},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.element},Object.defineProperty(e.prototype,"elementSize",{get:function(){return{width:this.element.offsetWidth,height:this.element.offsetHeight}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"HTMLTooltipItemsElements",{get:function(){var t=this.attributes,e=t.data,n=t.template;return e.map(function(t,e){var r=t.name,i=void 0===r?"":r,o=t.color,A=void 0===o?"black":o,s=t.index,a=Pe(t,["name","color","index"]),c=Le({name:i,color:A,index:null!=s?s:e},a);return Sn(function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]}):t}(n.item,c))})},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.renderHTMLTooltipElement(),this.updatePosition()},e.prototype.destroy=function(){var e;null===(e=this.element)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.show=function(t,e){var n=this;if(void 0!==t&&void 0!==e){var r=function(){n.attributes.x=null!=t?t:n.attributes.x,n.attributes.y=null!=e?e:n.attributes.y,n.updatePosition()};"hidden"===this.element.style.visibility?this.closeTransition(r):r()}this.element.style.visibility="visible"},e.prototype.hide=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.attributes.enterable&&this.isCursorEntered(t,e)||(this.element.style.visibility="hidden")},e.prototype.initShape=function(){var t=this.attributes.template;this.element=Sn(t.container),this.id&&this.element.setAttribute("id",this.id)},e.prototype.renderCustomContent=function(){if(void 0===this.prevCustomContentKey||this.prevCustomContentKey!==this.attributes.contentKey){this.prevCustomContentKey=this.attributes.contentKey;var t=this.attributes.content;t&&("string"==typeof t?this.element.innerHTML=t:HW(this.element,t))}},e.prototype.renderHTMLTooltipElement=function(){var t,e,n=this.attributes,r=n.template,i=n.title,o=n.enterable,A=n.style,s=n.content,a=y$(r.prefixCls),c=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(c.innerHTML=r.title,c.getElementsByClassName(a.TITLE)[0].innerHTML=i):null===(e=null===(t=c.getElementsByClassName(a.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var l=this.HTMLTooltipItemsElements,u=document.createElement("ul");u.className=a.LIST,HW(u,l);var h=this.element.querySelector(".".concat(a.LIST));h?h.replaceWith(u):c.appendChild(u)}!function(t,e){Object.entries(e).forEach(function(e){var n=He(e,2),r=n[0],i=n[1];_e([t],He(t.querySelectorAll(r)),!1).filter(function(t){return t.matches(r)}).forEach(function(t){t&&(t.style.cssText+=Object.entries(i).reduce(function(t,e){return"".concat(t).concat(e.join(":"),";")},""))})})}(c,A)},e.prototype.getRelativeOffsetFromCursor=function(t){var e=this.attributes,n=e.position,r=e.offset,i=(t||n).split("-"),o={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]},A=this.elementSize,s=A.width,a=A.height,c=[-s/2,-a/2];return i.forEach(function(t){var e=He(c,2),n=e[0],i=e[1],A=He(o[t],2),l=A[0],u=A[1];c=[n+(s/2+r[0])*l,i+(a/2+r[1])*u]}),c},e.prototype.setOffsetPosition=function(t){var e=He(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,A=void 0===o?0:o,s=i.y,a=void 0===s?0:s,c=i.container,l=c.x,u=c.y;this.element.style.left="".concat(+A+l+n,"px"),this.element.style.top="".concat(+a+u+r,"px")},e.prototype.updatePosition=function(){var t=this.attributes.showDelay,e=void 0===t?60:t,n=Date.now();this.timestamp>0&&n-this.timestamp<e||(this.timestamp=n,this.setOffsetPosition(this.autoPosition(this.getRelativeOffsetFromCursor())))},e.prototype.autoPosition=function(t){var e=He(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,A=i.y,s=i.bounding,a=i.position;if(!s)return[n,r];var c=this.element,l=c.offsetWidth,u=c.offsetHeight,h=He([+o+n,+A+r],2),d=h[0],f=h[1],g={left:"right",right:"left",top:"bottom",bottom:"top"},p=s.x,v=s.y,m={left:d<p,right:d+l>p+s.width,top:f<v,bottom:f+u>v+s.height},y=[];a.split("-").forEach(function(t){m[t]?y.push(g[t]):y.push(t)});var w=y.join("-");return this.getRelativeOffsetFromCursor(w)},e.prototype.isCursorEntered=function(t,e){if(this.element){var n=this.element.getBoundingClientRect(),r=n.x,i=n.y,o=n.width,A=n.height;return new qV(r,i,o,A).isPointIn(t,e)}return!1},e.prototype.closeTransition=function(t){var e=this,n=this.element.style.transition;this.element.style.transition="none",t(),setTimeout(function(){e.element.style.transition=n},10)},e.tag="tooltip",e}(KW),E$=function(t){function e(n){var r=t.call(this,eW({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new sc({})),r.label=r.background.appendChild(new Xa({})),r}return Ie(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return SW(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=IW(this.attributes,"label");kW(this.label).maybeAppend(".label",function(){return cW(e)}).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=He(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3],A=t.width,s=t.height,a=A+o+r,c=s+n+i,l=IW(this.attributes,"background"),u=this.style,h=u.width,d=void 0===h?0:h,f=u.height,g=void 0===f?0:f,p=u.selected;this.background.attr(Le(Le({},l),{width:Math.max(a,d),height:Math.max(c,g),fill:p?this.selectedColor:"#fff"})),this.label.attr({transform:"translate(".concat(o,", ").concat((c-s)/2,")")})},e.prototype.render=function(){this.renderLabel(),this.renderBackground()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("pointerenter",function(){t.style.selected||t.background.attr("fill",t.hoverColor)}),this.addEventListener("pointerleave",function(){t.style.selected||t.background.attr("fill",t.style.backgroundFill)});var e=this;this.addEventListener("click",function(){var n=t.style,r=n.label,i=n.value,o=n.onClick;null==o||o(i,{label:r,value:i},e)})},e.defaultOptions={style:{value:"",label:"",cursor:"pointer"}},e}(KW),x$=function(t){function e(n){var r,i,o=t.call(this,eW({},e.defaultOptions,n))||this;o.currentValue=null===(r=e.defaultOptions.style)||void 0===r?void 0:r.defaultValue,o.isPointerInSelect=!1,o.select=o.appendChild(new sc({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new sc({className:"dropdown"}));var A=o.style.defaultValue;return A&&(null===(i=o.style.options)||void 0===i?void 0:i.some(function(t){return t.value===A}))&&(o.currentValue=A),o}return Ie(e,t),e.prototype.setValue=function(t){this.currentValue=t,this.render()},e.prototype.getValue=function(){return this.currentValue},Object.defineProperty(e.prototype,"dropdownPadding",{get:function(){return SW(this.style.dropdownPadding)},enumerable:!1,configurable:!0}),e.prototype.renderSelect=function(){var t,e=this,n=this.style,r=n.x,i=n.y,o=n.width,A=n.height,s=n.bordered,a=n.showDropdownIcon,c=IW(this.attributes,"select"),l=IW(this.attributes,"placeholder");this.select.attr(Le(Le({x:r,y:i,width:o,height:A},c),{fill:"#fff",strokeWidth:s?1:0}));var u=this.dropdownPadding;a&&kW(this.select).maybeAppend(".dropdown-icon","path").style("d","M-5,-3.5 L0,3.5 L5,-3.5").style("transform","translate(".concat(r+o-10-u[1]-u[3],", ").concat(i+A/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var h=null===(t=this.style.options)||void 0===t?void 0:t.find(function(t){return t.value===e.currentValue}),d=Le({x:r+u[3]},l);kW(this.select).selectAll(".placeholder").data(h?[]:[1]).join(function(t){return t.append("text").attr("className","placeholder").styles(d).style("y",function(){var t=this.getBBox();return i+(A-t.height)/2})},function(t){return t.styles(d)},function(t){return t.remove()});var f=IW(this.attributes,"optionLabel"),g=Le({x:r+u[3]},f);kW(this.select).selectAll(".value").data(h?[h]:[]).join(function(t){return t.append(function(t){return cW(t.label)}).attr("className","value").styles(g).style("y",function(){var t=this.getBBox();return i+(A-t.height)/2})},function(t){return t.styles(g)},function(t){return t.remove()})},e.prototype.renderDropdown=function(){var t,e,n=this,r=this.style,i=r.x,o=r.y,A=r.width,s=r.height,a=r.options,c=r.onSelect,l=r.open,u=IW(this.attributes,"dropdown"),h=IW(this.attributes,"option"),d=this.dropdownPadding;kW(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 E$({className:"dropdown-item",style:Le(Le(Le({},t),h),{width:A-d[1]-d[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==c||c(t,e,r),n.dispatchEvent(new Vs("change",{detail:{value:t,option:e,item:r}})),KV(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(d[3],", ").concat(d[0]+r,")"))})},function(t){return t.update(function(t){return{selected:t.value===n.currentValue}})},function(t){return t.remove()});var f=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),g=u.spacing;this.dropdown.attr(Le({transform:"translate(".concat(i,", ").concat(o+s+g,")"),width:f.width+d[1]+d[3],height:f.height+d[0]+d[2]},u)),!l&&KV(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?KV(t.dropdown):GV(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||KV(t.dropdown)})},e.defaultOptions={style:{x:0,y:0,width:140,height:32,options:[],bordered:!0,defaultValue:"",selectRadius:8,selectStroke:"#d9d9d9",showDropdownIcon:!0,placeholderText:"请选择",placeholderFontSize:12,placeholderTextBaseline:"top",placeholderFill:"#c2c2c2",dropdownFill:"#fff",dropdownStroke:"#d9d9d9",dropdownRadius:8,dropdownShadowBlur:4,dropdownShadowColor:"rgba(0, 0, 0, 0.08)",dropdownPadding:8,dropdownSpacing:10,optionPadding:[8,12],optionFontSize:12,optionTextBaseline:"top",optionBackgroundFill:"#fff",optionBackgroundRadius:4,optionLabelFontSize:12,optionLabelTextBaseline:"top"}},e}(KW),C$=function(t){function e(n){var r=t.call(this,eW({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new sc({})),r.icon=r.appendChild(new Xa({})),r}return Ie(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 SW(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=He(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3];return Math.max(t-Math.max(o+r,n+i),2*this.lineWidth+1)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.size,i=r/2,o=IW(this.attributes,"background");this.background.attr(Le({x:e-i,y:n-i,width:r,height:r},o))},e.prototype.showIndicator=function(){if(this.label){var t=this.attributes.size,e=this.background.getBBox(),n=e.x,r=e.y;this.indicator.update({x:n+t/2,y:r-5,labelText:this.label,visibility:"visible"})}},e.prototype.hideIndicator=function(){this.indicator.update({visibility:"hidden"})},e.prototype.connectedCallback=function(){var e;t.prototype.connectedCallback.call(this);var n=this.attributes.size,r=this.background.getBBox(),i=r.x,o=r.y,A=null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView;A&&(this.indicator=A.appendChild(new m$({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}(KW),M$=function(t,e){return void 0===e&&(e="#565758"),new nc({style:{fill:e,d:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},F$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.arcPath=function(t,e,n){var r=He([n,n],2),i=r[0],o=r[1],A=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=He(A(-5/4*Math.PI),2),a=s[0],c=s[1],l=He(A(1/4*Math.PI),2),u=l[0],h=l[1];return"M".concat(a,",").concat(c,",A").concat(i,",").concat(o,",0,1,1,").concat(u,",").concat(h)},Object.defineProperty(e.prototype,"label",{get:function(){return"重置"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,A=o+.5;kW(this.icon).maybeAppend(".reset","path").styles({stroke:r,lineWidth:o,d:this.arcPath(e,n,i/2-o),markerStart:M$(A,r)})},e}(C$),k$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,A=i/2/Math.pow(3,.5),s=[[e,n],[e,n-A],[e-o,n],[e,n+A],[e,n],[e+o,n-A],[e+o,n+A],[e,n]];kW(this.icon).maybeAppend(".backward","polygon").styles({points:s,fill:r})},e}(C$),S$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,A=i/2/Math.pow(3,.5),s=[[e,n],[e,n-A],[e+o,n],[e,n+A],[e,n],[e-o,n-A],[e-o,n+A],[e,n]];kW(this.icon).maybeAppend(".forward","polygon").styles({points:s,fill:r})},e}(C$),Q$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3*Math.pow(3,.5)*.8,A=[[e+o,n],[e-o/2,n-i/2*.8],[e-o/2,n+i/2*.8],[e+o,n]];kW(this.icon).maybeAppend(".play","polygon").styles({points:A,fill:r})},e}(C$),U$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3,A=[[e-o,n-i/2],[e-o,n+i/2],[e-o/2,n+i/2],[e-o/2,n-i/2],[e-o,n-i/2],[e+o/2,n-i/2],[e+o/2,n+i/2],[e+o,n+i/2],[e+o,n-i/2]];kW(this.icon).maybeAppend(".pause","polygon").styles({points:A,fill:r})},e}(C$),N$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,A=o;kW(this.icon).maybeAppend(".left-line","line").styles({x1:e-i/2,y1:n-i/2,x2:e-i/2,y2:n+i/2,stroke:r,lineWidth:o}),kW(this.icon).maybeAppend(".right-line","line").styles({x1:e+i/2,y1:n-i/2,x2:e+i/2,y2:n+i/2,stroke:r,lineWidth:o}),kW(this.icon).maybeAppend(".left-arrow","line").styles({x1:e,y1:n,x2:e-i/2+2*A,y2:n,stroke:r,lineWidth:o,markerEnd:M$(2*o,r)}),kW(this.icon).maybeAppend(".right-arrow","line").styles({x1:e,y1:n,x2:e+i/2-2*A,y2:n,stroke:r,lineWidth:o,markerEnd:M$(2*o,r)})},e}(C$),T$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;kW(this.icon).maybeAppend(".line","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o});var A=o;kW(this.icon).maybeAppend(".left-arrow","line").styles({x1:e-i/2-2*A,y1:n,x2:e-2*A,y2:n,stroke:r,lineWidth:o,markerEnd:M$(2*o,r)}),kW(this.icon).maybeAppend(".right-arrow","line").styles({x1:e+i/2+2*A,y1:n,x2:e+2*A,y2:n,stroke:r,lineWidth:o,markerEnd:M$(2*o,r)})},e}(C$),O$=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},I$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,A=(i-2*o-o)/4,s=(i-2*o-o)/2,a=He([e-i/2+o,n+i/2-2*o],2),c=a[0],l=a[1];kW(this.icon).maybeAppend(".coordinate","polyline").styles({points:O$(i).map(function(t){var r=He(t,2),i=r[0],o=r[1];return[i+e,o+n]}),stroke:r,lineWidth:o}),kW(this.icon).maybeAppend(".line","polyline").styles({points:[[c,l],[c+A,l-s],[c+2*A,l],[c+4*A,l-2*s]],stroke:r,lineWidth:o})},e}(C$),L$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"条形图"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return[1,4,2,4,3]},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.data,e=this.attributes,n=e.x,r=e.y,i=e.color,o=this.iconSize,A=this.lineWidth,s=A,a=(o-s)/t.length,c=(o-2*s)/4,l=He([n-o/2+2*s,r+o/2-s],2),u=l[0],h=l[1];kW(this.icon).maybeAppend(".coordinate","polyline").styles({points:O$(o).map(function(t){var e=He(t,2),i=e[0],o=e[1];return[i+n,o+r]}),stroke:i,lineWidth:A}),kW(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 u+a*e}).style("y1",h).style("x2",function(t){var e=t.index;return u+a*e}).style("y2",function(t){var e=t.value;return h-c*e}).styles({y1:h,stroke:i,lineWidth:A})})},e}(C$),P$=function(t){function e(e){var n=t.call(this,eW({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return Ie(e,t),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;kW(this.icon).maybeAppend(".split","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o})},e}(C$),D$=function(t){function e(){var e=t.apply(this,_e([],He(arguments),!1))||this;return e.showBackground=!1,e}return Ie(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return SW(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes,n=e.x,r=e.y,i=e.speed,o=void 0===i?1:i,A=Se(this.attributes,["x","y","transform","transformOrigin","width","height","size","color","speed"]),s=ne(t,20,1/0),a=Le(Le({},A),{x:n-s/2,y:r-10,width:s,height:20,defaultValue:o,bordered:!1,showDropdownIcon:!1,selectRadius:2,dropdownPadding:this.padding,dropdownRadius:2,dropdownSpacing:t/5,placeholderFontSize:t/2,optionPadding:0,optionLabelFontSize:t/2,optionBackgroundRadius:1,options:[{label:"1x",value:1},{label:"1.5x",value:1.5},{label:"2x",value:2}]});kW(this.icon).maybeAppend(".speed",function(){return new x$({style:a})}).attr("className","speed").each(function(){this.update(a)})},e.tag="SpeedSelect",e}(C$),R$=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new Xa({})),n.currentType=n.attributes.type,n}return Ie(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.onChange;var n=Pe(e,["onChange"]);kW(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 He(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 He(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}(KW),H$=function(t){function e(e){var n=t.call(this,eW({},{style:{type:"play"}},e))||this;return n.toggles=[["play",Q$],["pause",U$]],n}return Ie(e,t),e}(R$),_$=function(t){function e(e){var n=t.call(this,eW({},{style:{type:"range"}},e))||this;return n.toggles=[["range",N$],["value",T$]],n}return Ie(e,t),e}(R$),G$=function(t){function e(e){var n=t.call(this,eW({},{style:{type:"column"}},e))||this;return n.toggles=[["line",I$],["column",L$]],n}return Ie(e,t),e}(R$),K$={reset:F$,speed:D$,backward:k$,playPause:H$,forward:S$,selectionType:_$,chartType:G$,split:P$},j$=function(t){function e(n){var r=t.call(this,eW({},e.defaultOptions,n))||this;return r.background=r.appendChild(new sc({})),r.functions=r.appendChild(new Xa({})),r}return Ie(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return SW(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.x,n=t.y,r=t.width,i=t.height,o=IW(this.attributes,"background");this.background.attr(Le({x:e,y:n,width:r,height:i},o))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,i=n.iconSize,o=n.iconSpacing,A=n.x,s=n.y,a=n.width,c=n.height,l=n.align,u=He(this.padding,4),h=u[1],d=u[3],f=r.reduce(function(t,e){return t.length&&e.length?t.concat.apply(t,_e(["split"],He(e),!1)):t.concat.apply(t,_e([],He(e),!1))},[]),g=f.length*(i+o)-o,p={left:d+i/2,center:(a-g)/2+i/2,right:a-g-d-h+i/2}[l]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),f.forEach(function(t,n){var r,a=K$[t],l={x:A+n*(i+o)+p,y:s+c/2,size:i};if(a===D$?(l.speed=e.attributes.speed,l.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[H$,_$,G$].includes(a)?(l.onChange=function(n){return e.handleFunctionChange(t,{value:n})},a===H$&&(l.type="play"===e.attributes.state?"pause":"play"),a===_$&&(l.type="range"===e.attributes.selectionType?"value":"range"),a===G$&&(l.type="line"===e.attributes.chartType?"column":"line")):l.onClick=function(){return e.handleFunctionChange(t,{value:t})},a===D$){var u=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;u&&(e.speedSelect=new a({style:Le(Le({},l),{zIndex:100})}),u.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:{x:0,y:0,width:300,height:40,padding:0,align:"center",iconSize:25,iconSpacing:0,speed:1,state:"pause",chartType:"line",selectionType:"range",backgroundFill:"#fbfdff",backgroundStroke:"#ebedf0",functions:[["reset","speed"],["backward","playPause","forward"],["selectionType","chartType"]]}},e}(KW),z$=function(t){function e(n){var r=t.call(this,eW({},e.defaultOptions,n))||this;return r.bindEvents(),r}return Ie(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}(za),V$=function(t){function e(n){return t.call(this,eW({},e.defaultOptions,n))||this}return Ie(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=IW(this.attributes,"background");kW(this).maybeAppend("background","rect").attr("className","background").styles(Le({x:e-r/2,y:n-i/2,width:r,height:i},o))},e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.iconSize,i=IW(this.attributes,"icon"),o=r/2;kW(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(Le({x1:e-1,y1:n-o,x2:e-1,y2:n+o},i)),kW(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(Le({x1:e+1,y1:n-o,x2:e+1,y2:n+o},i))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,A=IW(this.attributes,"border"),s="start"===o?+r/2:-r/2;kW(this).maybeAppend("border","line").attr("className","border").styles(Le({x1:s+e,y1:n-i/2,x2:s+e,y2:n+i/2},A))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{x:0,y:0,width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(KW);function W$(t,e){return"number"==typeof t?Y$(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()?DW(n,"HH:mm\nYYYY-MM-DD"):DW(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(DW(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?DW(n,"DD\nYYYY-MM"):DW(n,"DD");case"week":return n.getDate()<=7?DW(n,"DD\nYYYY-MM"):DW(n,"DD");case"month":return[0,6].includes(n.getMonth())?DW(n,"MM月\nYYYY"):DW(n,"MM月");case"season":return[0].includes(n.getMonth())?DW(n,"MM月\nYYYY"):DW(n,"MM月");case"year":return DW(n,"YYYY");default:return DW(n,"YYYY-MM-DD HH:mm")}}(t,e)}function Y$(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 X$=function(t){function e(n){var r=t.call(this,eW({},e.defaultOptions,n))||this;r.axis=r.appendChild(new Qq({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new hX({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new j$({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?_e([],He(e),!1):e);r.setBySliderValues(t),r.dispatchOnChange(n)};var i=r.attributes,o=i.selectionType,A=i.chartType,s=i.speed,a=i.state,c=i.playMode,l=i.values;return r.states={chartType:A,playMode:c,selectionType:o,speed:s,state:a},r.setByTimebarValues(l),r}return Ie(e,t),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.data.sort(function(t,e){return t.time<e.time?-1:t.time>e.time?1:0})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"space",{get:function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,A=t.controllerHeight,s=ne(+i-A,0,+i),a=new qV(e,n+ +i-A,+r,A),c=0,l="time"===o?10:s;return{axisBBox:"chart"===o?new qV(e,n+s-(c=35),+r,c):new qV,controllerBBox:a,timelineBBox:new qV(e,n+("time"===o?s:s-l),+r,l-c)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=He(Array.isArray(t)?t:[0,t],2),o=i[0],A=i[1],s=r.length,a=r[Math.floor(o*s)],c=r[Math.ceil(A*s)-(Array.isArray(t)?0:1)];this.states.values=[null!==(e=null==a?void 0:a.time)&&void 0!==e?e:r[0].time,null!==(n=null==c?void 0:c.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=He(Array.isArray(t)?t:[void 0,t],2),A=o[0],s=o[1],a=i.find(function(t){return t.time===A}),c=i.find(function(t){return t.time===s});this.states.values=[null!==(e=null==a?void 0:a.time)&&void 0!==e?e:null===(n=i[0])||void 0===n?void 0:n.time,null!==(r=null==c?void 0:c.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,A=He(t,2),s=A[0],a=A[1];this.states.values=[null!==(n=null===(e=o[s])||void 0===e?void 0:e.time)&&void 0!==n?n:o[0].time,null!==(i=null===(r=this.data[a])||void 0===r?void 0:r.time)&&void 0!==i?i:1/0]},Object.defineProperty(e.prototype,"sliderValues",{get:function(){var t,e=this.states,n=e.values,r=e.selectionType,i=He(Array.isArray(n)?n:[void 0,n],2),o=i[0],A=i[1],s=this.data,a=s.length,c="value"===r;return[(t=s.findIndex(function(t){return t.time===o}),c?0:t>-1?t/a:0),function(){if(A===1/0)return 1;var t=s.findIndex(function(t){return t.time===A});return t>-1?t/a:c?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=He(Array.isArray(e)?e:[this.data[0].time,e],2),i=r[0],o=r[1];return"value"===n?o:[i,o]},enumerable:!1,configurable:!0}),e.prototype.getDatumByRatio=function(t){var e=this.data,n=e.length;return e[Math.floor(t*(n-1))]},Object.defineProperty(e.prototype,"chartHandleIconShape",{get:function(){var t=this.states.selectionType,e=this.space.timelineBBox.height;return"range"===t?function(t){return new V$({style:{type:t,height:e,iconSize:e/6}})}:function(){return new tc({style:{x1:0,y1:-e/2,x2:0,y2:e/2,lineWidth:2,stroke:"#c8c8c8"}})}},enumerable:!1,configurable:!0}),e.prototype.getChartStyle=function(t){var e=this,n=t.x,r=t.y,i=t.width,o=t.height,A=this.states,s=A.selectionType,a=A.chartType,c=this.data,l=this.attributes,u=l.type,h=l.labelFormatter,d=IW(this.attributes,"chart");d.type;var f=Pe(d,["type"]),g="range"===s;if("time"===u)return Le({handleIconShape:function(){return new z$({})},selectionFill:"#2e7ff8",selectionFillOpacity:1,showLabelOnInteraction:!0,handleLabelDy:g?-15:0,autoFitLabel:g,handleSpacing:g?-15:0,trackFill:"#edeeef",trackLength:i,trackOpacity:.5,trackRadius:o/2,trackSize:o/2,type:s,values:this.sliderValues,formatter:function(t){if(h)return h(t);var n=e.getDatumByRatio(t).time;return"number"==typeof n?Y$(n):DW(n,"YYYY-MM-DD HH:mm:ss")},transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},f);var p="range"===s?5:0,v=c.map(function(t){return t.value});return Le({handleIconOffset:p,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:v,sparklineType:a,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},f)},e.prototype.renderChart=function(t){void 0===t&&(t=this.space.timelineBBox),this.timeline.update(this.getChartStyle(t))},e.prototype.updateSelection=function(){this.timeline.setValues(this.sliderValues,!0),this.handleSliderChange(this.sliderValues)},e.prototype.getAxisStyle=function(t){var e=this.data,n=this.attributes,r=n.interval,i=n.labelFormatter,o=IW(this.attributes,"axis"),A=t.x,s=t.y,a=t.width,c=_e(_e([],He(e),!1),[{time:0}],!1).map(function(t,e,n){var r=t.time;return{label:"".concat(r),value:e/(n.length-1),time:r}}),l=Le({startPos:[A,s],endPos:[A+a,s],data:c,labelFilter:function(t,e){return e<c.length-1},labelFormatter:function(t){var e=t.time;return i?i(e):W$(e,r)}},o);return l},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=IW(this.attributes,"controller"),a=this,c=Le(Le(Le({},t),{iconSize:20,speed:i,state:r,selectionType:o,chartType:A,onChange:function(t,e){var n=e.value;switch(t){case"reset":a.internalReset();break;case"speed":a.handleSpeedChange(n);break;case"backward":a.internalBackward();break;case"playPause":"play"===n?a.internalPlay():a.internalPause();break;case"forward":a.internalForward();break;case"selectionType":a.handleSelectionTypeChange(n);break;case"chartType":a.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=He(i,2),s=A[0],a=A[1],c=a===1/0?e.at(-1).time:a;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,a=He(o,2),c=a[0],l=a[1],u=n.findIndex(function(t){return t.time===c}),h=n.findIndex(function(t){return t.time===l});-1===h&&(h=r);var d,f="backward"===t?-1:1;"range"===A?"acc"===s?(d=[u,h+f],-1===f&&u===h&&(d=[u,r])):d=[u+f,h+f]:d=[u,h+f];var g=function(t){var e=He(t.sort(function(t,e){return t-e}),2),n=e[0],i=e[1],o=function(t){return ne(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)]}(d);return this.setByIndex(g),this.updateSelection(),g},e.prototype.internalBackward=function(t){var e,n,r=this.moveSelection("backward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onBackward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.backward=function(){this.internalBackward()},e.prototype.internalPlay=function(t){var e,n,r=this,i=this.data,o=this.attributes.loop,A=this.states.speed,s=void 0===A?1:A;this.playInterval=window.setInterval(function(){r.internalForward()[1]!==i.length||o||(r.internalPause(),r.renderController())},1e3/s),this.states.state="play",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPlay)||void 0===n||n.call(e))},e.prototype.play=function(){this.internalPlay()},e.prototype.internalPause=function(t){var e,n;clearInterval(this.playInterval),this.states.state="pause",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPause)||void 0===n||n.call(e))},e.prototype.pause=function(){this.internalPause()},e.prototype.internalForward=function(t){var e,n,r=this.moveSelection("forward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onForward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.forward=function(){this.internalForward()},e.prototype.handleSpeedChange=function(t){var e,n;this.states.speed=t,"play"===this.states.state&&(this.internalPause(!0),this.internalPlay(!0)),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSpeedChange)||void 0===n||n.call(e,t)},e.prototype.handleSelectionTypeChange=function(t){var e,n;this.states.selectionType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSelectionTypeChange)||void 0===n||n.call(e,t)},e.prototype.handleChartTypeChange=function(t){var e,n;this.states.chartType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onChartTypeChange)||void 0===n||n.call(e,t)},e.prototype.render=function(){var t=this.space,e=t.axisBBox,n=t.controllerBBox,r=t.timelineBBox;this.renderController(n),this.renderAxis(e),this.renderChart(r),"play"===this.states.state&&this.internalPlay()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.internalPause(!0)},e.defaultOptions={style:{x:0,y:0,axisLabelFill:"#6e6e6e",axisLabelTextAlign:"left",axisLabelTextBaseline:"top",axisLabelTransform:"translate(5, -12)",axisLineLineWidth:1,axisLineStroke:"#cacdd1",axisTickLength:15,axisTickLineWidth:1,axisTickStroke:"#cacdd1",chartShowLabel:!1,chartType:"line",controllerAlign:"center",controllerHeight:40,data:[],interval:"day",loop:!1,playMode:"acc",selectionType:"range",type:"time"}},e}(KW);function q$(t){const{width:e,height:n,renderer:r}=t,i=function(t){var e;const{container:n,className:r,graphCanvas:i}=t;if(n)return"string"==typeof n?document.getElementById(n):n;const o=Jj(r,!1),{width:A,height:s,containerStyle:a}=t,[c,l]=function(t){const{width:e,height:n,placement:r,graphCanvas:i}=t,[o,A]=i.getSize(),[s,a]=Cy(r);return[s*(o-e),a*(A-n)]}(t);return Object.assign(o.style,Object.assign({position:"absolute",left:c+"px",top:l+"px",width:A+"px",height:s+"px"},a)),null===(e=i.getContainer())||void 0===e||e.appendChild(o),o}(t);return[i,new xc({width:e,height:n,container:i,renderer:r||new _b})]}class $$ extends Zj{constructor(e,n){super(e,Object.assign({},$$.defaultOptions,n)),this.typePrefix="__data__",this.draw=!1,this.fieldMap={node:new Map,edge:new Map,combo:new Map},this.selectedItems=[],this.bindEvents=()=>{const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.createElement)},this.changeState=(t,e)=>{const{graph:n}=this.context,{typePrefix:r}=this,i=Ce(t,[r,"id"]),o=Ce(t,[r,"style","labelText"]),[A]=i.split("__"),s=this.fieldMap[A].get(o)||[];n.setElementState(Object.fromEntries(null==s?void 0:s.map(t=>[t,e])))},this.click=t=>{if("hover"===this.options.trigger)return;const e=Ce(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?(this.selectedItems=this.selectedItems.filter(t=>t!==e),this.changeState(t,[])):(this.selectedItems.push(e),this.changeState(t,"selected"))},this.mouseleave=t=>{"click"!==this.options.trigger&&(this.selectedItems=[],this.changeState(t,[]))},this.mouseenter=t=>{if("click"===this.options.trigger)return;const e=Ce(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?this.selectedItems=this.selectedItems.filter(t=>t!==e):(this.selectedItems.push(e),this.changeState(t,"active"))},this.setFieldMap=(t,e,n)=>{if(!t)return;const r=this.fieldMap[n];if(r)if(r.has(t)){const n=r.get(t);n&&(n.push(e),r.set(t,n))}else r.set(t,[e])},this.getEvents=()=>({mouseenter:this.mouseenter,mouseleave:this.mouseleave,click:this.click}),this.getMarkerData=(t,e)=>{if(!t)return[];const{model:n,element:r}=this.context,{nodes:i,edges:o,combos:A}=n.getData(),s={},a=e=>Gt(t)?t(e):t,c={node:"circle",edge:"line",combo:"rect"},l={circle:"circle",ellipse:"circle",image:"bowtie",rect:"square",star:"cross",triangle:"triangle",diamond:"diamond",cubic:"dot",line:"hyphen",polyline:"hyphen",quadratic:"hv","cubic-horizontal":"hyphen","cubic-vertical":"line"},u=(t,e)=>{t.forEach(t=>{const{id:n}=t,i=Ce(t,["data",a(t)]),o=(null==r?void 0:r.getElementType(e,t))||"circle",A=((t,e)=>null==r?void 0:r.getElementComputedStyle(t,e))(e,t),u=("edge"===e?null==A?void 0:A.stroke:null==A?void 0:A.fill)||"#1783ff";n&&i&&i.replace(/\s+/g,"")&&(this.setFieldMap(i,n,e),s[i]||(s[i]={id:`${e}__${n}`,label:i,marker:l[o]||c[e],elementType:e,lineWidth:1,stroke:u,fill:u}))})};switch(e){case"node":u(i,"node");break;case"edge":u(o,"edge");break;case"combo":u(A,"combo");break;default:return[]}return Object.values(s)},this.createElement=()=>{if(this.draw)return void this.updateElement();const t=this.options,{width:e,height:n,nodeField:r,edgeField:i,comboField:o,trigger:A,position:s,container:a,containerStyle:c,className:l}=t,u=Pe(t,["width","height","nodeField","edgeField","comboField","trigger","position","container","containerStyle","className"]),h=this.getMarkerData(r,"node"),d=this.getMarkerData(i,"edge"),f=this.getMarkerData(o,"combo"),g=[...h,...f,...d],p=Object.assign({width:e,height:n,data:g,itemMarkerLineWidth:({lineWidth:t})=>t,itemMarker:({marker:t})=>t,itemMarkerStroke:({stroke:t})=>t,itemMarkerFill:({fill:t})=>t,gridCol:h.length},u,this.getEvents()),v=new g$({className:"legend",style:p});this.category=v;this.upsertCanvas().appendChild(v),this.draw=!0},this.bindEvents()}update(t){super.update(t),this.clear(),this.createElement()}clear(){var t,e;null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.container)||void 0===e||e.remove(),this.canvas=void 0,this.container=void 0,this.draw=!1}updateElement(){this.category&&this.category.update({itemMarkerOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5,itemLabelOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5})}upsertCanvas(){if(this.canvas)return this.canvas;const t=this.context.canvas,[e,n]=t.getSize(),{width:r=e,height:i=n,position:o,container:A,containerStyle:s,className:a}=this.options,[c,l]=q$({width:r,height:i,graphCanvas:t,container:A,containerStyle:s,placement:o,className:"legend"});return this.container=c,a&&c.classList.add(a),this.canvas=l,this.canvas}destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}$$.defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16,width:240,height:160};class Z$ extends Zj{constructor(t,e){super(t,Object.assign({},Z$.defaultOptions,e)),this.onDraw=t=>{var e;(null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.render)||this.onRender()},this.landmarkMap=new Map,this.mask=null,this.isMaskDragging=!1,this.onMaskDragStart=t=>{this.mask&&(this.isMaskDragging=!0,this.mask.setPointerCapture(t.pointerId),this.mask.addEventListener("pointermove",this.onMaskDrag),this.mask.addEventListener("pointerup",this.onMaskDragEnd),this.mask.addEventListener("pointercancel",this.onMaskDragEnd))},this.onMaskDrag=t=>{if(!this.mask||!this.isMaskDragging)return;const{size:[e,n]}=this.options,{movementX:r,movementY:i}=t,{left:o,top:A,width:s,height:a}=this.mask.style,[,,c,l]=this.maskBBox;let u=parseInt(o)+r,h=parseInt(A)+i,d=parseInt(s),f=parseInt(a);u<0&&(u=0),h<0&&(h=0),u+d>e&&(u=tZ(e-d,0)),h+f>n&&(h=tZ(n-f,0)),d<c&&(r>0?(u=tZ(u-r,0),d=J$(d+r,e)):r<0&&(d=J$(d-r,e))),f<l&&(i>0?(h=tZ(h-i,0),f=J$(f+i,n)):i<0&&(f=J$(f-i,n))),Object.assign(this.mask.style,{left:u+"px",top:h+"px",width:d+"px",height:f+"px"});const g=parseInt(o)-u,p=parseInt(A)-h;if(0===g&&0===p)return;const v=this.context.canvas.getCamera().getZoom()/this.canvas.getCamera().getZoom();this.context.graph.translateBy([g*v,p*v],!1)},this.onMaskDragEnd=t=>{this.mask&&(this.isMaskDragging=!1,this.mask.releasePointerCapture(t.pointerId),this.mask.removeEventListener("pointermove",this.onMaskDrag),this.mask.removeEventListener("pointerup",this.onMaskDragEnd),this.mask.removeEventListener("pointercancel",this.onMaskDragEnd))},this.onTransform=Qe(()=>{this.isMaskDragging||(this.updateMask(),this.setCamera())},32,{leading:!0}),this.setOnRender(),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),"delay"in t&&this.setOnRender(),this.bindEvents()}setOnRender(){this.onRender=pe(()=>{this.renderMinimap(),this.renderMask()},this.options.delay)}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.onDraw),e.on(t.GraphEvent.AFTER_RENDER,this.onRender),e.on(t.GraphEvent.AFTER_ANIMATE,this.onRender),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.onDraw),e.off(t.GraphEvent.AFTER_RENDER,this.onRender),e.off(t.GraphEvent.AFTER_ANIMATE,this.onRender),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}renderMinimap(){const t=this.getElements(),e=this.initCanvas();this.setShapes(e,t)}getElements(){const{filter:t}=this.options,{model:e,element:n}=this.context,r=e.getData(),i={nodes:r.nodes.filter(t=>null==n?void 0:n.getElement(Km(t))),edges:r.edges.filter(t=>{const e=null==n?void 0:n.getElement(Km(t));return e&&$B(e)}),combos:r.combos.filter(t=>null==n?void 0:n.getElement(Km(t)))};if(!t)return i;const{nodes:o,edges:A,combos:s}=i;return{nodes:o.filter(e=>t(Km(e),"node")),edges:A.filter(e=>t(Km(e),"edge")),combos:s.filter(e=>t(Km(e),"combo"))}}setShapes(t,e){const{nodes:n,edges:r,combos:i}=e,{shape:o}=this.options,{element:A}=this.context,s=(e,n)=>{const r=Km(e),i=null==A?void 0:A.getElement(r);if(!i)return;const s=i.getShape("key");let a;if("string"==typeof o){const t=o;a=i.getShape(t).cloneNode()}else{const t=o(r,n,i);a=t===i?t.cloneNode(!0):t}a.setPosition(s.getPosition()),i.style.zIndex&&(a.style.zIndex=i.style.zIndex),a.id=i.id,t.appendChild(a)};t.removeChildren(),r.forEach(t=>s(t,"edge")),i.forEach(t=>s(t,"combo")),n.forEach(t=>s(t,"node"))}initCanvas(){const{renderer:t,size:[e,n]}=this.options;if(this.canvas){const{width:r,height:i}=this.canvas.getConfig();e===r&&n===i||this.canvas.resize(e,n),t&&this.canvas.setRenderer(t)}else{const{className:r,position:i,container:o,containerStyle:A}=this.options,[s,a]=q$({renderer:t,width:e,height:n,placement:i,className:"minimap",container:o,containerStyle:A,graphCanvas:this.context.canvas});r&&s.classList.add(r),this.container=s,this.canvas=a}return this.setCamera(),this.canvas}createLandmark(t,e,n){const r=`${t.join(",")}-${e.join(",")}-${n}`;if(this.landmarkMap.has(r))return this.landmarkMap.get(r);const i=this.canvas.getCamera().createLandmark(r,{position:t,focalPoint:e,zoom:n});return this.landmarkMap.set(r,i),i}setCamera(){var t;const{canvas:e}=this.context,n=null===(t=this.canvas)||void 0===t?void 0:t.getCamera();if(!n)return;const{size:[r,i],padding:o}=this.options,[A,s,a,c]=pm(o),{min:l,max:u,center:h}=e.getBounds("elements"),d=(r-c-s)/(u[0]-l[0]),f=(i-A-a)/(u[1]-l[1]),g=Math.min(d,f),p=this.createLandmark(h,h,g);n.gotoLandmark(p,0)}get maskBBox(){const{canvas:t}=this.context,e=t.getSize(),n=t.getCanvasByViewport([0,0]),r=t.getCanvasByViewport(e),i=this.canvas.canvas2Viewport(Qy(n)),o=this.canvas.canvas2Viewport(Qy(r)),A=o.x-i.x,s=o.y-i.y;return[i.x,i.y,A,s]}calculateMaskBBox(){const{size:[t,e]}=this.options;let[n,r,i,o]=this.maskBBox;return n<0&&(i=J$(i+n,t),n=0),r<0&&(o=J$(o+r,e),r=0),n+i>t&&(i=tZ(t-n,0)),r+o>e&&(o=tZ(e-r,0)),[J$(n,t),J$(r,e),tZ(i,0),tZ(o,0)]}renderMask(){const{maskStyle:t}=this.options;this.mask||(this.mask=document.createElement("div"),this.mask.addEventListener("pointerdown",this.onMaskDragStart),this.mask.draggable=!0,this.mask.addEventListener("dragstart",t=>t.preventDefault&&t.preventDefault())),this.container.appendChild(this.mask),Object.assign(this.mask.style,Object.assign(Object.assign({},t),{cursor:"move",position:"absolute",pointerEvents:"auto"})),this.updateMask()}updateMask(){if(!this.mask)return;const[t,e,n,r]=this.calculateMaskBBox();Object.assign(this.mask.style,{top:e+"px",left:t+"px",width:n+"px",height:r+"px"})}destroy(){var t,e,n;this.unbindEvents(),null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.mask)||void 0===e||e.remove(),null===(n=this.container)||void 0===n||n.remove(),super.destroy()}}Z$.defaultOptions={size:[240,160],shape:"key",padding:10,position:"right-bottom",maskStyle:{border:"1px solid #ddd",background:"rgba(0, 0, 0, 0.1)"},containerStyle:{border:"1px solid #ddd",background:"#fff"},delay:128};const J$=(t,e)=>Math.min(t,e),tZ=(t,e)=>Math.max(t,e),eZ={x1:0,y1:0,x2:0,y2:0,visibility:"hidden"};class nZ extends Zj{constructor(t,e){super(t,Object.assign({},nZ.defaultOptions,e)),this.initSnapline=()=>{const t=this.context.canvas.getLayer("transient");this.horizontalLine||(this.horizontalLine=t.appendChild(new tc({style:Object.assign(Object.assign({},eZ),this.options.horizontalLineStyle)}))),this.verticalLine||(this.verticalLine=t.appendChild(new tc({style:Object.assign(Object.assign({},eZ),this.options.verticalLineStyle)})))},this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!0,this.autoSnapToLine=(t,e,n)=>De(this,void 0,void 0,function*(){const{verticalX:r,horizontalY:i}=n,{tolerance:o}=this.options,{min:[A,s],max:[a,c],center:[l,u]}=e;let h=0,d=0;null!==r&&(rZ(a,r)<o&&(h=r-a),rZ(A,r)<o&&(h=r-A),rZ(l,r)<o&&(h=r-l),0!==h&&(this.isVerticalSticking=!0)),null!==i&&(rZ(c,i)<o&&(d=i-c),rZ(s,i)<o&&(d=i-s),rZ(u,i)<o&&(d=i-u),0!==d&&(this.isHorizontalSticking=!0)),0===h&&0===d||(yield this.context.graph.translateElementBy({[t]:[h,d]},!1))}),this.enableSnap=t=>{const{target:e}=t,n=.5;if(this.isHorizontalSticking||this.isVerticalSticking){const[r,i]=this.getDelta(t);if(this.isHorizontalSticking&&this.isVerticalSticking&&Math.abs(r)<=n&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,-i]},!1),!1;if(this.isHorizontalSticking&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[0,-i]},!1),!1;if(this.isVerticalSticking&&Math.abs(r)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,0]},!1),!1;this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!1,setTimeout(()=>{this.enableStick=!0},200)}return this.enableStick},this.calcSnaplineMetadata=(t,e)=>{const{tolerance:n,shape:r}=this.options,{min:[i,o],max:[A,s],center:[a,c]}=e;let l=null,u=null,h=null,d=null,f=null,g=null;return this.getNodes().some(e=>{if(xe(t.id,e.id))return!1;const p=iZ(e,r).getRenderBounds(),{min:[v,m],max:[y,w],center:[b,B]}=p;return null===l&&(rZ(b,a)<n?l=b:rZ(v,i)<n||rZ(v,A)<n?l=v:(rZ(y,A)<n||rZ(y,i)<n)&&(l=y),null!==l&&(u=Math.min(m,o),h=Math.max(w,s))),null===d&&(rZ(B,c)<n?d=B:rZ(m,o)<n||rZ(m,s)<n?d=m:(rZ(w,s)<n||rZ(w,o)<n)&&(d=w),null!==d&&(f=Math.min(v,i),g=Math.max(y,A))),null!==l&&null!==d}),{verticalX:l,verticalMinY:u,verticalMaxY:h,horizontalY:d,horizontalMinX:f,horizontalMaxX:g}},this.onDragStart=()=>{this.initSnapline()},this.onDrag=t=>De(this,void 0,void 0,function*(){const{target:e}=t;if(this.options.autoSnap){if(!this.enableSnap(t))return}const n=iZ(e,this.options.shape).getRenderBounds(),r=this.calcSnaplineMetadata(e,n);this.hideSnapline(),null===r.verticalX&&null===r.horizontalY||this.updateSnapline(r),this.options.autoSnap&&(yield this.autoSnapToLine(e.id,n,r))}),this.onDragEnd=()=>{this.hideSnapline()},this.bindEvents()}getNodes(){var t;const{filter:e}=this.options,n=((null===(t=this.context.element)||void 0===t?void 0:t.getNodes())||[]).filter(t=>{var e;return $B(t)&&(null===(e=this.context.viewport)||void 0===e?void 0:e.isInViewport(t.getRenderBounds()))});return e?n.filter(t=>e(t)):n}hideSnapline(){this.horizontalLine.style.visibility="hidden",this.verticalLine.style.visibility="hidden"}getLineWidth(t){const{lineWidth:e}=this.options[`${t}LineStyle`];return+(e||eZ.lineWidth||1)/this.context.graph.getZoom()}updateSnapline(t){const{verticalX:e,verticalMinY:n,verticalMaxY:r,horizontalY:i,horizontalMinX:o,horizontalMaxX:A}=t,[s,a]=this.context.canvas.getSize(),{offset:c}=this.options;null!==i?Object.assign(this.horizontalLine.style,{x1:c===1/0?0:o-c,y1:i,x2:c===1/0?s:A+c,y2:i,visibility:"visible",lineWidth:this.getLineWidth("horizontal")}):this.horizontalLine.style.visibility="hidden",null!==e?Object.assign(this.verticalLine.style,{x1:e,y1:c===1/0?0:n-c,x2:e,y2:c===1/0?a:r+c,visibility:"visible",lineWidth:this.getLineWidth("vertical")}):this.verticalLine.style.visibility="hidden"}getDelta(t){const e=this.context.graph.getZoom();return uy([t.dx,t.dy],e)}bindEvents(){return De(this,void 0,void 0,function*(){const{graph:e}=this.context;e.on(t.NodeEvent.DRAG_START,this.onDragStart),e.on(t.NodeEvent.DRAG,this.onDrag),e.on(t.NodeEvent.DRAG_END,this.onDragEnd)})}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.DRAG_START,this.onDragStart),e.off(t.NodeEvent.DRAG,this.onDrag),e.off(t.NodeEvent.DRAG_END,this.onDragEnd)}destroyElements(){var t,e;null===(t=this.horizontalLine)||void 0===t||t.destroy(),null===(e=this.verticalLine)||void 0===e||e.destroy()}destroy(){this.destroyElements(),this.unbindEvents(),super.destroy()}}nZ.defaultOptions={tolerance:5,offset:20,autoSnap:!0,shape:"key",verticalLineStyle:{stroke:"#1783FF"},horizontalLineStyle:{stroke:"#1783FF"},filter:()=>!0};const rZ=(t,e)=>Math.abs(t-e),iZ=(t,e)=>"function"==typeof e?e(t):t.getShape(e),oZ=["timestamp","time","date","datetime"];class AZ extends Zj{get padding(){return pm(this.options.padding)}constructor(t,e){super(t,Object.assign({},AZ.defaultOptions,e)),this.backup(),this.upsertTimebar()}play(){var t;null===(t=this.timebar)||void 0===t||t.play()}pause(){var t;null===(t=this.timebar)||void 0===t||t.pause()}forward(){var t;null===(t=this.timebar)||void 0===t||t.forward()}backward(){var t;null===(t=this.timebar)||void 0===t||t.backward()}reset(){var t;null===(t=this.timebar)||void 0===t||t.reset()}update(t){super.update(t),this.backup(),this.upsertTimebar()}backup(){this.originalData=sZ(this.context.graph.getData())}upsertTimebar(){const{canvas:t}=this.context,e=this.options,{onChange:n,timebarType:r,data:i,x:o,y:A,width:s,height:a,mode:c}=e,l=Pe(e,["onChange","timebarType","data","x","y","width","height","mode"]),u=t.getSize(),[h]=this.padding;this.upsertCanvas().ready.then(()=>{var t;const e=Object.assign(Object.assign({x:u[0]/2-s/2,y:h,onChange:t=>{const e=(jt(t)?t:[t,t]).map(t=>function(t){return t instanceof Date}(t)?t.getTime():t);"modify"===this.options.mode?this.filterElements(e):this.hiddenElements(e),null==n||n(e)}},l),{data:i.map(t=>re(t)?{time:t,value:0}:t),width:s,height:a,type:r});this.timebar?this.timebar.update(e):(this.timebar=new X$({style:e}),null===(t=this.canvas)||void 0===t||t.appendChild(this.timebar))})}upsertCanvas(){if(this.canvas)return this.canvas;const{className:t,height:e,position:n}=this.options,r=this.context.canvas,[i]=r.getSize(),[o,,A]=this.padding,[s,a]=q$({width:i,height:e+o+A,graphCanvas:r,className:"timebar",placement:n});return this.container=s,t&&s.classList.add(t),this.canvas=a,this.canvas}filterElements(t){return De(this,void 0,void 0,function*(){var e;if(!this.originalData)return;const{elementTypes:n,getTime:r}=this.options,{graph:i,element:o}=this.context,A=sZ(this.originalData);n.forEach(e=>{const n=`${e}s`;A[n]=(this.originalData[n]||[]).filter(e=>{const n=r(e);return!!aZ(n,t)})});const s=[...A.nodes,...A.combos].map(t=>Km(t));A.edges=A.edges.filter(t=>{const e=t.source,n=t.target;return s.includes(e)&&s.includes(n)}),i.setData(A),yield null===(e=o.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished})}hiddenElements(t){const{graph:e}=this.context,{elementTypes:n,getTime:r}=this.options,i=[],o=[];n.forEach(e=>{var n;const A=`${e}s`;((null===(n=this.originalData)||void 0===n?void 0:n[A])||[]).forEach(e=>{const n=Km(e),A=r(e);aZ(A,t)?o.push(n):i.push(n)})}),e.hideElement(i,!1),e.showElement(o,!1)}destroy(){var t,e,n;const{graph:r}=this.context;this.originalData&&r.setData(Object.assign({},this.originalData)),null===(t=this.timebar)||void 0===t||t.destroy(),null===(e=this.canvas)||void 0===e||e.destroy(),null===(n=this.container)||void 0===n||n.remove(),this.originalData=void 0,this.container=void 0,this.timebar=void 0,this.canvas=void 0,super.destroy()}}AZ.defaultOptions={position:"bottom",enable:!0,timebarType:"time",className:"g6-timebar",width:450,height:60,zIndex:3,elementTypes:["node"],padding:10,mode:"modify",getTime:t=>cZ(t,oZ,void 0),loop:!1};const sZ=t=>{const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e],edges:[...n],combos:[...r]}},aZ=(t,e)=>{if(re(e))return t===e;const[n,r]=e;return t>=n&&t<=r},cZ=(t,e,n)=>{var r;for(let n=0;n<e.length;n++){const i=e[n],o=null===(r=t.data)||void 0===r?void 0:r[i];if(o)return o}return n},lZ={fill:"#1D2129",wordWrap:!0,maxLines:1,textOverflow:"ellipsis",textBaseline:"top",textAlign:"start",x:0},uZ=Object.assign(Object.assign({},lZ),{fillOpacity:.9,fontSize:16,fontWeight:"bold"}),hZ=Object.assign(Object.assign({},lZ),{fillOpacity:.65,fontSize:12,fontWeight:"normal"}),dZ={align:"left",spacing:8,size:44,padding:[16,24,0,24]},fZ="title",gZ="subtitle";class pZ extends Zj{get padding(){return pm(this.options.padding)}constructor(t,e){super(t,Object.assign({},dZ,e)),this.onRender=()=>{const t=this.updateCanvas();this.renderTitle(t)},this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onRender),e.on(t.GraphEvent.AFTER_ANIMATE,this.onRender)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onRender),e.off(t.GraphEvent.AFTER_ANIMATE,this.onRender)}destroy(){var t,e;this.unbindEvents(),null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.container)||void 0===e||e.remove(),super.destroy()}updateCanvas(){const{size:t,className:e,align:n}=this.options,[r]=this.context.canvas.getSize(),[i=0,,o=0]=this.padding,A=t+i+o;if(this.canvas){const{width:t,height:e}=this.canvas.getConfig();r===t&&A===e||this.canvas.resize(r,A)}else{const t={left:"left-top",center:"top",right:"right-top"},[i,o]=q$({width:r,height:A,placement:t[n]||t.left,className:"title-canvas",graphCanvas:this.context.canvas});e&&i.classList.add(e),this.container=i,this.canvas=o}return this.canvas}renderTitle(t){const e=new vZ({options:this.options,ctx:this.context});t.removeChildren(),e.getTitle().forEach(e=>{e&&t.appendChild(e)})}}class vZ{get padding(){return pm(this.options.padding)}constructor(t){const{options:e,ctx:n}=t;this.options=e,this.context=n}getTitle(){const t=this.options,e=fZ,n=t[e],r=gZ,i=t[r],{spacing:o=44,padding:A,align:s}=t,a=Pe(t,[e+"",r+"","spacing","padding","align"]),c=n,l=i,u=Aw(a,fZ),h=Aw(a,gZ),[d]=this.context.graph.getSize(),[f=0,g=0,,p=0]=this.padding,v=d,m=v-p-g;let y=null,w=p,b="left";switch(s){case"left":default:w=p,b="left";break;case"center":w=v/2,b="center";break;case"right":w=v-g,b="right"}const B=new yw({className:fZ,style:Object.assign(Object.assign(Object.assign(Object.assign({},uZ),{wordWrapWidth:m-5,x:w,y:f,textAlign:b}),u),{text:c})}),E=B.getBBox();return l&&(y=new yw({className:"subTitle",style:Object.assign(Object.assign(Object.assign(Object.assign({},hZ),{wordWrapWidth:m-5,x:w,y:E.height+o+f,textAlign:b}),h),{text:l})})),[B,y]}}class mZ extends Zj{constructor(t,e){super(t,Object.assign({},mZ.defaultOptions,e)),this.$element=Jj("toolbar",!1),this.onToolbarItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof Element&&t.target.className.includes("g6-toolbar-item")){const n=t.target.getAttribute("value");null==e||e(n,t.target)}};const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),tz("g6-toolbar-css","style",{},"\n .g6-toolbar {\n position: absolute;\n z-index: 100;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);\n opacity: 0.65;\n }\n .g6-toolbar .g6-toolbar-item {\n display: inline-block;\n width: 16px;\n height: 16px;\n padding: 4px;\n cursor: pointer;\n box-sizing: content-box;\n }\n\n .g6-toolbar .g6-toolbar-item:hover {\n background-color: #f0f0f0;\n }\n\n .g6-toolbar .g6-toolbar-item svg {\n display: inline-block;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n",document.head),tz("g6-toolbar-svgicon","div",{display:"none"},'\n <svg>\n <symbol id="zoom-in" viewBox="64 64 896 896">\n <path d="M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="zoom-out" viewBox="64 64 896 896">\n <path d="M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="edit" viewBox="64 64 896 896">\n <path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>\n </symbol>\n <symbol id="delete" viewBox="64 64 896 896">\n <path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"></path>\n </symbol>\n <symbol id="redo" viewBox="64 64 896 896">\n <path d="M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"></path>\n </symbol>\n <symbol id="undo" viewBox="64 64 896 896">\n <path d="M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z"></path>\n </symbol>\n <symbol id="export" viewBox="64 64 896 896">\n <path d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"></path>\n </symbol>\n <symbol id="auto-fit" viewBox="64 64 896 896">\n <path d="M952 474H829.8C812.5 327.6 696.4 211.5 550 194.2V72c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v122.2C327.6 211.5 211.5 327.6 194.2 474H72c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h122.2C211.5 696.4 327.6 812.5 474 829.8V952c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V829.8C696.4 812.5 812.5 696.4 829.8 550H952c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM512 756c-134.8 0-244-109.2-244-244s109.2-244 244-244 244 109.2 244 244-109.2 244-244 244z"></path>\n <path d="M512 392c-32.1 0-62.1 12.4-84.8 35.2-22.7 22.7-35.2 52.7-35.2 84.8s12.5 62.1 35.2 84.8C449.9 619.4 480 632 512 632s62.1-12.5 84.8-35.2C619.4 574.1 632 544 632 512s-12.5-62.1-35.2-84.8A118.57 118.57 0 00512 392z"></path>\n </symbol>\n <symbol id="reset" viewBox="64 64 896 896">\n <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path>\n </symbol>\n <symbol id="exit-fullscreen" viewBox="0 0 1024 1024">\n <path d="M418.13333333 361.43786666c0 0.2048-0.13653333 0.4096-0.13653334 0.68266667C417.99679999 362.32533333 418.13333333 362.53013333 418.13333333 362.73493333 418.13333333 371.54133333 414.44693333 379.392 408.78079999 385.39946666 408.43946666 385.7408 408.30293333 386.21866666 408.02986666 386.49173333c-1.09226667 1.09226667-2.59413333 1.77493333-3.82293333 2.73066667C398.40426666 393.65973333 391.64586666 396.8 383.93173333 396.8 383.72693333 396.8 383.59039999 396.73173333 383.38559999 396.73173333S382.97599999 396.8 382.77119999 396.8L112.29866666 396.8C92.50133333 396.8 76.79999999 381.50826666 76.79999999 362.66666666 76.66346666 343.89333333 92.63786666 328.53333333 112.16213333 328.53333333l189.44 0L87.44959999 114.51733333C73.59146666 100.59093333 73.25013333 78.5408 86.63039999 65.29706666c13.17546667-13.44853333 35.36213333-12.97066667 49.152 0.88746667l214.08426667 214.08426667L349.86666666 90.89706666C349.79839999 71.23626666 365.22666666 55.46666666 383.99999999 55.46666666 402.77333333 55.33013333 418.13333333 71.30453333 418.13333333 90.8288L418.13333333 361.43786666zM928.90453333 328.53333333l-189.44 0 214.15253333-214.08426667c13.85813333-13.9264 14.19946667-35.90826667 0.88746667-49.22026666-13.17546667-13.44853333-35.36213333-12.97066667-49.152 0.88746666l-214.08426667 214.08426667L691.26826666 90.89706666C691.26826666 71.23626666 675.83999999 55.46666666 657.06666666 55.46666666 638.29333333 55.33013333 622.93333333 71.30453333 622.93333333 90.8288l0 270.60906666c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 362.32533333 622.93333333 362.53013333 622.93333333 362.73493333 622.93333333 371.54133333 626.61973333 379.392 632.28586666 385.39946666c0.34133333 0.34133333 0.47786667 0.8192 0.8192 1.09226667 1.09226667 1.09226667 2.59413333 1.77493333 3.8912 2.73066667C642.66239999 393.65973333 649.42079999 396.8 657.13493333 396.8c0.2048 0 0.34133333-0.06826667 0.54613333-0.06826667S658.09066666 396.8 658.29546666 396.8l270.5408 0C948.56533333 396.8 964.26666666 381.50826666 964.26666666 362.66666666 964.40319999 343.89333333 948.42879999 328.53333333 928.90453333 328.53333333zM418.13333333 635.73333333c0-8.8064-3.6864-16.5888-9.35253334-22.66453333C408.43946666 612.72746666 408.30293333 612.2496 408.02986666 611.90826666 406.86933333 610.88426666 405.43573333 610.2016 404.20693333 609.24586666 398.47253333 604.80853333 391.64586666 601.6 383.93173333 601.6 383.72693333 601.6 383.59039999 601.73653333 383.38559999 601.73653333S382.97599999 601.6 382.77119999 601.6L112.29866666 601.6C92.50133333 601.6 76.79999999 616.96 76.79999999 635.73333333 76.66346666 654.50666666 92.63786666 669.86666666 112.16213333 669.86666666l189.44 0-214.15253334 214.15253334c-13.85813333 13.85813333-14.19946667 35.84-0.88746666 49.22026666 13.17546667 13.44853333 35.36213333 12.9024 49.152-0.95573333l214.08426666-214.08426667 0 189.37173334c0 19.59253333 15.42826667 35.49866667 34.2016 35.36213333C402.77333333 943.2064 418.13333333 927.232 418.13333333 907.5712L418.13333333 637.09866666c0-0.27306667-0.13653333-0.47786667-0.13653334-0.68266666C417.99679999 636.14293333 418.13333333 635.93813333 418.13333333 635.73333333zM739.46453333 669.86666666l189.44 0c19.456 0 35.49866667-15.36 35.36213333-34.13333333C964.26666666 616.96 948.56533333 601.6 928.76799999 601.6L658.29546666 601.6C658.09066666 601.6 657.88586666 601.73653333 657.68106666 601.73653333S657.33973333 601.6 657.13493333 601.6C649.42079999 601.6 642.59413333 604.80853333 636.85973333 609.24586666 635.63093333 610.2016 634.19733333 610.88426666 633.03679999 611.90826666 632.76373333 612.2496 632.62719999 612.72746666 632.28586666 613.0688 626.61973333 619.14453333 622.93333333 626.92693333 622.93333333 635.73333333c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 636.6208 622.93333333 636.8256 622.93333333 637.09866666l0 270.5408C622.93333333 927.232 638.29333333 943.2064 657.06666666 942.93333333c18.77333333 0.13653333 34.2016-15.70133333 34.2016-35.36213333l0-189.37173334 214.08426667 214.08426667c13.78986667 13.85813333 35.90826667 14.40426667 49.152 0.95573333 13.312-13.312 12.97066667-35.36213333-0.88746667-49.22026666L739.46453333 669.86666666z" ></path></symbol>\n <symbol id="request-fullscreen" viewBox="0 0 1024 1024">\n <path d="M69.818182 87.598545v273.128728a34.909091 34.909091 0 0 0 69.818182 0V163.653818l221.928727 222.021818a33.512727 33.512727 0 0 0 47.383273-47.383272L186.926545 116.363636h197.073455a34.909091 34.909091 0 0 0 0-69.818181H110.871273C85.364364 46.545455 69.818182 59.671273 69.818182 87.598545zM938.542545 46.545455H665.413818a34.909091 34.909091 0 0 0 0 69.818181h197.073455L640.465455 338.292364a33.512727 33.512727 0 0 0 47.383272 47.383272l221.928728-222.021818v197.073455a34.909091 34.909091 0 0 0 69.818181 0V87.598545c0-27.927273-15.453091-41.053091-40.96-41.05309z m-827.671272 907.636363h273.128727a34.909091 34.909091 0 0 0 0-69.818182H186.926545l222.021819-221.928727a33.512727 33.512727 0 0 0-47.383273-47.383273L139.636364 837.073455V640a34.909091 34.909091 0 0 0-69.818182 0v273.128727c0 27.927273 15.546182 41.053091 41.053091 41.053091z m868.724363-41.053091V640a34.909091 34.909091 0 0 0-69.818181 0v197.073455L687.941818 615.051636a33.512727 33.512727 0 0 0-47.383273 47.383273L862.487273 884.363636H665.413818a34.909091 34.909091 0 0 0 0 69.818182h273.128727c25.6 0 41.053091-13.125818 41.053091-41.053091z" ></path></symbol>\n </svg>\n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t);const{className:n,position:r,style:i}=this.options;this.$element.className=`g6-toolbar ${n||""}`,Object.assign(this.$element.style,i,function(t){const e={top:"unset",right:"unset",bottom:"unset",left:"unset"};return t.split("-").forEach(t=>{e[t]="8px"}),e.flexDirection=t.startsWith("top")||t.startsWith("bottom")?"row":"column",e}(r)),this.$element.innerHTML=yield this.getDOMContent()})}destroy(){this.$element.removeEventListener("click",this.onToolbarItemClick),this.$element.remove(),super.destroy()}getDOMContent(){return De(this,void 0,void 0,function*(){return(yield this.options.getItems()).map(t=>{var e;return`\n <div class="g6-toolbar-item" value="${t.value}" title="${null!==(e=t.title)&&void 0!==e?e:""}">\n <svg aria-hidden="true" focusable="false">\n <use xlink:href="#${t.id}"></use>\n </svg>\n </div>`}).join("")})}}mZ.defaultOptions={position:"top-left"};class yZ extends Zj{constructor(t,e){super(t,Object.assign({},yZ.defaultOptions,e)),this.currentTarget=null,this.tooltipElement=null,this.container=null,this.isEnable=(t,e)=>{const{enable:n}=this.options;return"function"==typeof n?n(t,e):n},this.onClick=t=>{const{target:{id:e}}=t;this.currentTarget===e?this.hide(t):this.show(t)},this.onPointerMove=t=>{const{target:e}=t;this.currentTarget&&e.id!==this.currentTarget&&this.show(t)},this.onPointerLeave=t=>{this.hide(t)},this.onCanvasMove=t=>{this.hide(t)},this.onPointerOver=t=>{this.show(t)},this.showById=t=>De(this,void 0,void 0,function*(){const e={target:{id:t}};yield this.show(e)}),this.getElementData=(t,e)=>{const{model:n}=this.context;switch(e){case"node":return n.getNodeData([t]);case"edge":return n.getEdgeData([t]);case"combo":return n.getComboData([t]);default:return[]}},this.show=t=>De(this,void 0,void 0,function*(){var e,n;const{client:r,target:{id:i}}=t;if(JB(t.target))return;const o=this.context.graph.getElementType(i),{getContent:A,title:s}=this.options,a=this.getElementData(i,o);if(!this.tooltipElement)return;if(!this.isEnable(t,a))return void this.hide(t);let c,l,u={};if(A){if(u.content=yield A(t,a),!u.content)return}else{const t=this.context.graph.getElementRenderStyle(i),e="node"===o?t.fill:t.stroke;u={title:s||o,data:a.map(t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:e}))}}if(this.currentTarget=i,r)c=r.x,l=r.y;else{const t=Ce(a,"0.style",{x:0,y:0});c=t.x,l=t.y}null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!0),this.tooltipElement.update(Object.assign(Object.assign(Object.assign({},this.tooltipStyleProps),{x:c,y:l,style:{".tooltip":{visibility:"visible"}}}),u))}),this.hide=t=>{var e,n,r,i,o;if(!t)return null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!1),null===(r=this.tooltipElement)||void 0===r||r.hide(),void(this.currentTarget=null);if(!this.tooltipElement)return;if(!this.currentTarget)return;const{client:{x:A,y:s}}=t;null===(o=(i=this.options).onOpenChange)||void 0===o||o.call(i,!1),this.tooltipElement.hide(A,s),this.currentTarget=null},this.initTooltip=()=>{var t;const e=new B$({className:"tooltip",style:this.tooltipStyleProps});return null===(t=this.container)||void 0===t||t.appendChild(e.HTMLTooltipElement),e},this.render(),this.bindEvents()}getEvents(){return"click"===this.options.trigger?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerover":this.onPointerOver,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerover":this.onPointerOver,"edge:pointermove":this.onPointerMove,"combo:pointerover":this.onPointerOver,"combo:pointermove":this.onPointerMove,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}update(t){var e;this.unbindEvents(),super.update(t),this.tooltipElement&&(null===(e=this.container)||void 0===e||e.removeChild(this.tooltipElement.HTMLTooltipElement)),this.tooltipElement=this.initTooltip(),this.bindEvents()}render(){const{canvas:t}=this.context,e=t.getContainer();e&&(this.container=e,this.tooltipElement=this.initTooltip())}unbindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach(n=>{t.off(n,e[n])})}bindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach(n=>{t.on(n,e[n])})}get tooltipStyleProps(){const{canvas:t}=this.context,{center:e}=t.getBounds(),n=t.getContainer(),{top:r,left:i}=n.getBoundingClientRect(),{style:o,position:A,enterable:s,container:a={x:-i,y:-r},title:c,offset:l}=this.options,[u,h]=e,[d,f]=t.getSize();return{x:u,y:h,container:a,title:c,bounding:{x:0,y:0,width:d,height:f},position:A,enterable:s,offset:l,style:o}}destroy(){var t;this.unbindEvents(),this.tooltipElement&&(null===(t=this.container)||void 0===t||t.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}let wZ;function bZ(t,e){wZ||(wZ=document.createElement("canvas")),wZ.width=t,wZ.height=e;return wZ.getContext("2d").clearRect(0,0,t,e),wZ}yZ.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};class BZ extends Zj{constructor(t,e){super(t,Object.assign({},BZ.defaultOptions,e)),this.$element=Jj("watermark");this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t);const n=this.options,{width:r,height:i,text:o,imageURL:A}=n,s=Pe(n,["width","height","text","imageURL"]);Object.keys(s).forEach(e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])});const a=A?yield function(t,e,n,r){return De(this,void 0,void 0,function*(){const i=bZ(t,e),o=i.getContext("2d"),{rotate:A,opacity:s}=r;A&&o.rotate(A),s&&(o.globalAlpha=s);const a=new Image;return a.crossOrigin="anonymous",a.src=n,new Promise(n=>{a.onload=function(){const r=t>a.width?(t-a.width)/2:0,A=e>a.height?(e-a.height)/2:0;o.drawImage(a,0,0,a.width,a.height,r,A,t-2*r,e-2*A),n(i.toDataURL())}})})}(r,i,A,s):yield function(t,e,n,r){return De(this,void 0,void 0,function*(){const i=bZ(t,e),o=i.getContext("2d"),{rotate:A,opacity:s,textFill:a,textFontSize:c,textFontFamily:l,textFontVariant:u,textFontWeight:h,textAlign:d,textBaseline:f}=r;return o.textAlign=d,o.textBaseline=f,o.translate(t/2,e/2),o.font=`${c}px ${l} ${u} ${h}`,A&&o.rotate(A),s&&(o.globalAlpha=s),a&&(o.fillStyle=a,o.fillText(`${n}`,0,0)),i.toDataURL()})}(r,i,o,s);this.$element.style.backgroundImage=`url(${a})`})}destroy(){super.destroy(),this.$element.remove()}}BZ.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const EZ=["#7E92B5","#F4664A","#FFBE3A"],xZ={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},CZ={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function MZ(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeHaloStrokeOpacityActive:A=.15,nodeHaloStrokeOpacitySelected:s=.25,nodeOpacityDisabled:a=.06,nodeIconOpacityInactive:c=.85,nodeOpacityInactive:l=.25,nodeBadgePalette:u=EZ,nodePaletteOptions:h=xZ,edgeColor:d,edgeColorDisabled:f,edgePaletteOptions:g=CZ,comboColor:p,comboColorDisabled:v,comboStroke:m,comboStrokeDisabled:y,edgeColorInactive:w}=t;return{background:e,node:{palette:h,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:u,fill:r,fillOpacity:1,halo:!1,iconFill:"#fff",iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelFill:n,labelFillOpacity:.85,labelLineHeight:16,labelPadding:[0,2],labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelOffsetY:2,lineWidth:0,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65,size:32,stroke:o,strokeOpacity:1,zIndex:2},state:{selected:{halo:!0,haloLineWidth:24,haloStrokeOpacity:s,labelFontSize:12,labelFontWeight:"bold",lineWidth:4,stroke:o},active:{halo:!0,haloLineWidth:12,haloStrokeOpacity:A},highlight:{labelFontWeight:"bold",lineWidth:4,stroke:o,strokeOpacity:.85},inactive:{badgeBackgroundOpacity:l,donutOpacity:l,fillOpacity:l,iconOpacity:c,labelFill:n,labelFillOpacity:l,strokeOpacity:l},disabled:{badgeBackgroundOpacity:.25,donutOpacity:a,fill:i,fillOpacity:a,iconFill:i,iconOpacity:.25,labelFill:n,labelFillOpacity:.25,strokeOpacity:a}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"node-expand",collapse:"node-collapse",update:[{fields:["x","y","fill","stroke"]}],translate:[{fields:["x","y"]}]}},edge:{palette:g,style:{badgeBackgroundFill:d,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,badgeBackgroundOpacity:1,fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:1,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,stroke:d,strokeOpacity:1,zIndex:1},state:{selected:{halo:!0,haloStrokeOpacity:.25,labelFontSize:14,labelFontWeight:"bold",lineWidth:3},active:{halo:!0,haloStrokeOpacity:.15},highlight:{labelFontWeight:"bold",lineWidth:3},inactive:{stroke:w,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:f,fillOpacity:.45,strokeOpacity:.45,labelOpacity:.25,badgeBackgroundOpacity:.45}},animation:{enter:"fade",exit:"fade",expand:"path-in",collapse:"path-out",show:"fade",hide:"fade",update:[{fields:["sourceNode","targetNode"]},{fields:["stroke"],shape:"key"}],translate:[{fields:["sourceNode","targetNode"]}]}},combo:{style:{collapsedMarkerFill:e,collapsedMarkerFontSize:12,collapsedMarkerFillOpacity:1,collapsedSize:32,collapsedFillOpacity:1,fill:p,halo:!1,haloLineWidth:12,haloStroke:m,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,fillOpacity:.04,strokeOpacity:1,padding:10,stroke:m},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{fillOpacity:.65,labelOpacity:.25,strokeOpacity:.65},disabled:{fill:v,fillOpacity:.25,labelOpacity:.25,stroke:y,strokeOpacity:.25}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"combo-expand",collapse:"combo-collapse",update:[{fields:["x","y"]},{fields:["fill","stroke","lineWidth"],shape:"key"}],translate:[{fields:["x","y"]}]}}}}const FZ=MZ({bgColor:"#000000",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696",edgeColor:"#637088",edgeColorDisabled:"#637088",edgeColorInactive:"#D0E4FF",edgePaletteOptions:{type:"group",color:["#637088","#0F55A6","#008383","#9C5D38","#8B53A6","#4E40A6","#8F6608","#3E801D","#A65383","#175E75","#0F8248"]},nodeColor:"#1783ff",nodeColorDisabled:"#D0E4FF",nodeHaloStrokeOpacityActive:.25,nodeHaloStrokeOpacitySelected:.45,nodeIconOpacityInactive:.45,nodeOpacityDisabled:.25,nodeOpacityInactive:.45,nodeStroke:"#d0e4ff",textColor:"#ffffff"}),kZ=MZ({bgColor:"#ffffff",comboColor:"#99ADD1",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",edgeColorInactive:"#1B324F",nodeColor:"#1783ff",nodeColorDisabled:"#1B324F",nodeHaloStrokeOpacityActive:.15,nodeHaloStrokeOpacitySelected:.25,nodeIconOpacityInactive:.85,nodeOpacityDisabled:.06,nodeOpacityInactive:.25,nodeStroke:"#000000",textColor:"#000000"});class SZ extends ry{beforeDraw(t,e){return t}afterLayout(t,e){}}function QZ(t,e,n,r,i){const o=Km(r),A=`${n}s`,s=i?r:t.add[A].get(o)||t.update[A].get(o)||t.remove[A].get(o)||r;Object.entries(t).forEach(([t,n])=>{e===t?n[A].set(o,s):n[A].delete(o)})}function UZ(t,e){return Object.keys(t).every(n=>t[n]===e[n])}const NZ=(t,e,n,r)=>{const i=`${n}s`,o=Km(r);t.add[i].has(o)||t.update[i].has(o)||t[e][i].set(Km(r),r)};const TZ=new WeakMap;const OZ=(t,e,n=2)=>{if("object"!=typeof t||"object"!=typeof e)return t===e;const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r){const r=t[i],o=e[i];if(n>1&&"object"==typeof r&&"object"==typeof o){if(!OZ(r,o,n-1))return!1}else if(r!==o)return!1}return!0};function IZ(t,e,n){Yv[t][e]&&Zv(`The extension ${e} of ${t} has been registered before, and will be overridden.`),Object.assign(Yv[t],{[e]:n})}
|
|
60
|
+
*/const nC=Symbol("Comlink.proxy"),rC=Symbol("Comlink.endpoint"),iC=Symbol("Comlink.releaseProxy"),oC=Symbol("Comlink.finalizer"),AC=Symbol("Comlink.thrown"),sC=t=>"object"==typeof t&&null!==t||"function"==typeof t,aC=new Map([["proxy",{canHandle:t=>sC(t)&&t[nC],serialize(t){const{port1:e,port2:n}=new MessageChannel;return cC(t,e),[n,[n]]},deserialize:t=>(t.start(),uC(t))}],["throw",{canHandle:t=>sC(t)&&AC in t,serialize({value:t}){let e;return e=t instanceof Error?{isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:{isError:!1,value:t},[e,[]]},deserialize(t){if(t.isError)throw Object.assign(new Error(t.value.message),t.value);throw t.value}}]]);function cC(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(i){if(!i||!i.data)return;if(!function(t,e){for(const n of t){if(e===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(e))return!0}return!1}(n,i.origin))return void console.warn(`Invalid origin '${i.origin}' for comlink proxy`);const{id:o,type:A,path:s}=Object.assign({path:[]},i.data),a=(i.data.argumentList||[]).map(wC);let c;try{const e=s.slice(0,-1).reduce((t,e)=>t[e],t),n=s.reduce((t,e)=>t[e],t);switch(A){case"GET":c=n;break;case"SET":e[s.slice(-1)[0]]=wC(i.data.value),c=!0;break;case"APPLY":c=n.apply(e,a);break;case"CONSTRUCT":c=function(t){return Object.assign(t,{[nC]:!0})}(new n(...a));break;case"ENDPOINT":{const{port1:e,port2:n}=new MessageChannel;cC(t,n),c=function(t,e){return mC.set(t,e),t}(e,[e])}break;case"RELEASE":c=void 0;break;default:return}}catch(t){c={value:t,[AC]:0}}Promise.resolve(c).catch(t=>({value:t,[AC]:0})).then(n=>{const[i,s]=yC(n);e.postMessage(Object.assign(Object.assign({},i),{id:o}),s),"RELEASE"===A&&(e.removeEventListener("message",r),lC(e),oC in t&&"function"==typeof t[oC]&&t[oC]())}).catch(t=>{const[n,r]=yC({value:new TypeError("Unserializable return value"),[AC]:0});e.postMessage(Object.assign(Object.assign({},n),{id:o}),r)})}),e.start&&e.start()}function lC(t){(function(t){return"MessagePort"===t.constructor.name})(t)&&t.close()}function uC(t,e){const n=new Map;return t.addEventListener("message",function(t){const{data:e}=t;if(!e||!e.id)return;const r=n.get(e.id);if(r)try{r(e)}finally{n.delete(e.id)}}),pC(t,n,[],e)}function hC(t){if(t)throw new Error("Proxy has been released and is not useable")}function dC(t){return bC(t,new Map,{type:"RELEASE"}).then(()=>{lC(t)})}const fC=new WeakMap,gC="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(fC.get(t)||0)-1;fC.set(t,e),0===e&&dC(t)});function pC(t,e,n=[],r=function(){}){let i=!1;const o=new Proxy(r,{get(r,A){if(hC(i),A===iC)return()=>{!function(t){gC&&gC.unregister(t)}(o),dC(t),e.clear(),i=!0};if("then"===A){if(0===n.length)return{then:()=>o};const r=bC(t,e,{type:"GET",path:n.map(t=>t.toString())}).then(wC);return r.then.bind(r)}return pC(t,e,[...n,A])},set(r,o,A){hC(i);const[s,a]=yC(A);return bC(t,e,{type:"SET",path:[...n,o].map(t=>t.toString()),value:s},a).then(wC)},apply(r,o,A){hC(i);const s=n[n.length-1];if(s===rC)return bC(t,e,{type:"ENDPOINT"}).then(wC);if("bind"===s)return pC(t,e,n.slice(0,-1));const[a,c]=vC(A);return bC(t,e,{type:"APPLY",path:n.map(t=>t.toString()),argumentList:a},c).then(wC)},construct(r,o){hC(i);const[A,s]=vC(o);return bC(t,e,{type:"CONSTRUCT",path:n.map(t=>t.toString()),argumentList:A},s).then(wC)}});return function(t,e){const n=(fC.get(e)||0)+1;fC.set(e,n),gC&&gC.register(t,e,t)}(o,t),o}function vC(t){const e=t.map(yC);return[e.map(t=>t[0]),(n=e.map(t=>t[1]),Array.prototype.concat.apply([],n))];var n}const mC=new WeakMap;function yC(t){for(const[e,n]of aC)if(n.canHandle(t)){const[r,i]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},i]}return[{type:"RAW",value:t},mC.get(t)||[]]}function wC(t){switch(t.type){case"HANDLER":return aC.get(t.name).deserialize(t.value);case"RAW":return t.value}}function bC(t,e,n,r){return new Promise(i=>{const o=new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-");e.set(o,i),t.start&&t.start(),t.postMessage(Object.assign({id:o},n),r)})}class BC{constructor(){this.worker=null,this.workerApi=null}execute(t,e,n){return mx(this,0,void 0,function*(){if(this.worker||(yield this.initWorker()),!this.workerApi)throw new Error("Worker API not initialized");return yield this.workerApi.execute(t,e,n)})}destroy(){this.workerApi&&this.workerApi.destroy(),this.worker&&(this.worker.terminate(),this.worker=null,this.workerApi=null)}initWorker(){return mx(this,0,void 0,function*(){const t=this.resolveWorkerPath(),e=t.includes("/lib/")||t.endsWith(".mjs")?"module":"classic";this.worker=new Worker(t,{type:e}),this.workerApi=uC(this.worker)})}resolveWorkerPath(){const t=(()=>{if("undefined"==typeof document)return null;const t=document.currentScript;if(null==t?void 0:t.src)return t.src;const e=document.getElementsByTagName("script");for(let t=e.length-1;t>=0;t--){const n=e[t].src;if(n&&(n.includes("index.js")||n.includes("index.min.js")))return n}return null})();if(t){if(t.includes("index.js")||t.includes("index.min.js")){const e=t.replace(/index(\.min)?\.(m?js)(\?.*)?$/,"worker.js");if(e!==t)return e}const e=t.replace(/\/runtime\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(e!==t)return e;const n=t.replace(/\/[^/]+\.(m?js)(\?.*)?$/,"/worker.js");if(n!==t)return n}return"./worker.js"}}class EC{constructor(t){this.supervisor=null,this.initialOptions=this.mergeOptions(this.getDefaultOptions(),t)}get options(){return this.runtimeOptions||this.initialOptions}mergeOptions(t,e){return Object.assign({},t,e||{})}execute(t,e){return mx(this,0,void 0,function*(){this.runtimeOptions=this.mergeOptions(this.initialOptions,e);const{node:n,edge:r,enableWorker:i}=this.runtimeOptions;this.context=new eC(t,{node:n,edge:r}),this.model=this.context.graph;i&&"undefined"!=typeof Worker?yield this.layoutInWorker(t,this.runtimeOptions):yield this.layout(this.runtimeOptions)})}layoutInWorker(t,e){var n;return mx(this,0,void 0,function*(){try{this.supervisor||(this.supervisor=new BC);const r=yield this.supervisor.execute(this.id,t,e);null===(n=this.context)||void 0===n||n.replace(r)}catch(t){console.error("Layout in worker failed, fallback to main thread layout.",t),yield this.layout(e)}})}forEachNode(t){this.context.forEachNode(t)}forEachEdge(t){this.context.forEachEdge(t)}destroy(){var t;null===(t=this.context)||void 0===t||t.destroy(),this.model=null,this.context=null,this.supervisor&&(this.supervisor.destroy(),this.supervisor=null)}}class xC extends EC{}function CC(t){return!!t.tick&&!!t.stop}class MC{constructor(t={}){this.options=t,this.nodes=new Map,this.edges=new Map,this.inEdges=new Map,this.outEdges=new Map,this.parentMap=new Map,this.childrenMap=new Map,t.tree&&Array.isArray(t.tree)&&t.tree.length>0&&("string"==typeof t.tree[0]?t.tree.forEach(t=>{this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map)}):(this.attachTreeStructure("default"),this.addTree(t.tree))),t.nodes&&t.nodes.forEach(t=>this.addNode(t)),t.edges&&t.edges.forEach(t=>this.addEdge(t))}addNode(t){this.nodes.has(t.id)||(this.nodes.set(t.id,t),this.inEdges.set(t.id,new Set),this.outEdges.set(t.id,new Set))}addNodes(t){t.forEach(t=>this.addNode(t))}getNode(t){return this.nodes.get(t)}hasNode(t){return this.nodes.has(t)}removeNode(t){if(!this.nodes.has(t))return;const e=Array.from(this.inEdges.get(t)||[]),n=Array.from(this.outEdges.get(t)||[]);e.forEach(t=>this.removeEdge(t)),n.forEach(t=>this.removeEdge(t)),this.nodes.delete(t),this.inEdges.delete(t),this.outEdges.delete(t),this.parentMap.forEach(e=>{e.delete(t)}),this.childrenMap.forEach(e=>{e.delete(t)})}getAllNodes(){return Array.from(this.nodes.values())}addEdge(t){if(!this.nodes.has(t.source)||!this.nodes.has(t.target))throw new Error(`Cannot add edge ${t.id}: source ${t.source} or target ${t.target} does not exist`);this.edges.set(t.id,t),this.outEdges.get(t.source).add(t.id),this.inEdges.get(t.target).add(t.id)}addEdges(t){t.forEach(t=>this.addEdge(t))}getEdge(t){return this.edges.get(t)}hasEdge(t){return this.edges.has(t)}removeEdge(t){var e,n;const r=this.edges.get(t);r&&(this.edges.delete(t),null===(e=this.outEdges.get(r.source))||void 0===e||e.delete(t),null===(n=this.inEdges.get(r.target))||void 0===n||n.delete(t))}getAllEdges(){return Array.from(this.edges.values())}updateEdgeData(t,e){const n=this.edges.get(t);n&&Object.assign(n.data,e)}updateNodeData(t,e){const n=this.nodes.get(t);n&&Object.assign(n.data,e)}getRelatedEdges(t,e="both"){const n=[];if("in"===e||"both"===e){const e=this.inEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&n.push(e)})}if("out"===e||"both"===e){const e=this.outEdges.get(t);e&&e.forEach(t=>{const e=this.edges.get(t);e&&n.push(e)})}return n}getSuccessors(t){const e=this.outEdges.get(t);if(!e||0===e.size)return[];const n=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.target);t&&n.push(t)}}),n.length>0?n:[]}getPredecessors(t){const e=this.inEdges.get(t);if(!e||0===e.size)return[];const n=[];return e.forEach(t=>{const e=this.edges.get(t);if(e){const t=this.nodes.get(e.source);t&&n.push(t)}}),n.length>0?n:[]}getNeighbors(t){const e=[...this.getSuccessors(t)||[],...this.getPredecessors(t)||[]],n=Array.from(new Map(e.map(t=>[t.id,t])).values());return n.length>0?n:[]}attachTreeStructure(t){this.parentMap.has(t)||(this.parentMap.set(t,new Map),this.childrenMap.set(t,new Map))}addTree(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default");this.hasTreeStructure(i)||this.attachTreeStructure(i);const o=Array.isArray(t)?t:[t],A=(t,e)=>{this.addNode({id:t.id,data:t.data}),void 0!==e&&this.setParent(t.id,e,i),t.children&&t.children.length>0&&t.children.forEach(e=>{A(e,t.id)})};o.forEach(t=>A(t))}hasTreeStructure(t){return this.parentMap.has(t)}setParent(t,e,n){var r,i,o;const A=n||(null!==(i=null===(r=this.options.tree)||void 0===r?void 0:r[0])&&void 0!==i?i:"default");this.parentMap.has(A)||this.attachTreeStructure(A);const s=this.parentMap.get(A),a=this.childrenMap.get(A),c=s.get(t);void 0!==c&&(null===(o=a.get(c))||void 0===o||o.delete(t)),s.set(t,e),a.has(e)||a.set(e,new Set),a.get(e).add(t)}getParent(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default");this.parentMap.has(i)||this.attachTreeStructure(i);const o=this.parentMap.get(i);if(!o)return;const A=o.get(t);return void 0===A?null:this.nodes.get(A)}getChildren(t,e){var n,r;const i=e||(null!==(r=null===(n=this.options.tree)||void 0===n?void 0:n[0])&&void 0!==r?r:"default"),o=this.childrenMap.get(i);if(!o)return[];const A=o.get(t);return A?Array.from(A).map(t=>this.nodes.get(t)).filter(t=>void 0!==t):[]}getRoots(t){var e,n;const r=t||(null!==(n=null===(e=this.options.tree)||void 0===e?void 0:e[0])&&void 0!==n?n:"default"),i=this.parentMap.get(r),o=[];return this.nodes.forEach(t=>{i&&void 0!==i.get(t.id)||o.push(t)}),o}dfsTree(t,e){const n=[t],r=new Set;for(;n.length>0;){const t=n.pop();if(r.has(t))continue;const i=this.getNode(t);if(i){r.add(t);if(!0===e(i))continue;const o=this.getChildren(t);for(let t=o.length-1;t>=0;t--)r.has(o[t].id)||n.push(o[t].id)}}}}const FC=(t,e)=>{if("next"!==t&&"prev"!==t)return e},kC=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let SC=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return kC(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&kC(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let n=e.prev;for(;n!==e;)t.push(JSON.stringify(n,FC)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}};class QC extends SC{}const UC=()=>1,NC=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let A;for(;t.getAllNodes().length;){for(;A=o.dequeue();)TC(t,e,n,A);for(;A=i.dequeue();)TC(t,e,n,A);if(t.getAllNodes().length)for(let i=e.length-2;i>0;--i)if(A=e[i].dequeue(),A){r=r.concat(TC(t,e,n,A,!0));break}}return r},TC=(t,e,n,r,i)=>{var o,A;const s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach(r=>{const o=r.data.weight,A=t.getNode(r.source);i&&s.push({v:r.source,w:r.target,in:0,out:0}),void 0===A.data.out&&(A.data.out=0),A.data.out-=o,IC(e,n,Object.assign({v:A.id},A.data))}),null===(A=t.getRelatedEdges(r.v,"out"))||void 0===A||A.forEach(r=>{const i=r.data.weight,o=r.target,A=t.getNode(o);void 0===A.data.in&&(A.data.in=0),A.data.in-=i,IC(e,n,Object.assign({v:A.id},A.data))}),t.removeNode(r.v)),i?s:void 0},OC=(t,e)=>{const n=new MC;let r=0,i=0;t.getAllNodes().forEach(t=>{n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})}),t.getAllEdges().forEach(t=>{const o=n.getRelatedEdges(t.source,"out").find(e=>e.target===t.target),A=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,Object.assign(Object.assign({},o.data),{weight:o.data.weight+A})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:A}}),i=Math.max(i,n.getNode(t.source).data.out+=A),r=Math.max(r,n.getNode(t.target).data.in+=A)});const o=[],A=i+r+3;for(let t=0;t<A;t++)o.push(new QC);const s=r+1;return n.getAllNodes().forEach(t=>{IC(o,s,Object.assign({v:t.id},n.getNode(t.id).data))}),{buckets:o,zeroIdx:s,graph:n}},IC=(t,e,n)=>{n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)},LC=(t,e)=>{const n=((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=OC(t,e||UC);return null===(n=NC(r.graph,r.buckets,r.zeroIdx).map(e=>t.getRelatedEdges(e.v,"out").filter(({target:t})=>t===e.w)))||void 0===n?void 0:n.flat()})(t,t=>t.data.weight||1);null==n||n.forEach(e=>{const n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},n)})})},PC=(t,e,n,r)=>{let i;do{i=`${r}${Math.random()}`}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},DC=t=>{const e=new MC;return t.getAllNodes().forEach(n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))}),t.getAllEdges().forEach(t=>{e.addEdge(t)}),e},RC=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let A,s,a=Number(t.width)/2,c=Number(t.height)/2;return i||o?(Math.abs(o)*a>Math.abs(i)*c?(o<0&&(c=-c),A=c*i/o,s=c):(i<0&&(a=-a),A=a,s=a*o/i),{x:n+A,y:r+s}):{x:0,y:0}},HC=t=>{const e=[],n=GC(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach(t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)});for(let r=0;r<n;r++)e[r]=e[r].sort((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i});return e},_C=(t,e,n,r)=>{const i={width:0,height:0};return _x(n)&&_x(r)&&(i.rank=n,i.order=r),PC(t,"border",i,e)},GC=t=>{let e;return t.getAllNodes().forEach(t=>{const n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)}),e||(e=0),e},KC=(t,e)=>t.reduce((t,n)=>e(t)>e(n)?n:t),jC=(t,e,n,r,i,o)=>{if(!r.includes(e.id)){r.push(e.id),n||o.push(e.id);const A=i(e.id);A&&A.forEach(e=>jC(t,e,n,r,i,o)),n&&o.push(e.id)}},zC=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>t.getNeighbors(e),A=[],s=[];return i.forEach(e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);jC(t,e,"post"===n,s,o,A)}),A},VC=(t,e,n,r,i,o)=>{const A={rank:o,borderType:e,width:0,height:0},s=o-i.data.minRank,a=i.data[e][s-1],c=PC(t,"border",A,n);i.data[e][s]=c,t.setParent(c,r),a&&t.addEdge({id:`e${Math.random()}`,source:a,target:c,data:{weight:1}})},WC=t=>{t.getAllNodes().forEach(t=>{YC(t)}),t.getAllEdges().forEach(t=>{YC(t)})},YC=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},XC=t=>{t.getAllNodes().forEach(t=>{qC(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>qC(t)),t.data.hasOwnProperty("y")&&qC(t.data)})},qC=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},$C=t=>{t.getAllNodes().forEach(t=>{ZC(t.data)}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>ZC(t)),t.data.hasOwnProperty("x")&&ZC(t.data)})},ZC=t=>{const e=t.x;t.x=t.y,t.y=e},JC=(t,e,n,r,i,o,A)=>{const s=t.getChildren(A);if(!(null==s?void 0:s.length))return void(A!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:A,data:{weight:0,minlen:n}}));const a=_C(t,"_bt"),c=_C(t,"_bb"),l=t.getNode(A);t.setParent(a,A),l.data.borderTop=a,t.setParent(c,A),l.data.borderBottom=c,null==s||s.forEach(s=>{JC(t,e,n,r,i,o,s.id);const l=s.data.borderTop?s.data.borderTop:s.id,u=s.data.borderBottom?s.data.borderBottom:s.id,h=s.data.borderTop?r:2*r,d=l!==u?1:i-o[A]+1;t.addEdge({id:`e${Math.random()}`,source:a,target:l,data:{minlen:d,weight:h,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:u,target:c,data:{minlen:d,weight:h,nestingEdge:!0}})}),t.getParent(A)||t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:i+o[A]}})},tM=t=>{const e={},n=(r,i)=>{const o=t.getChildren(r);null==o||o.forEach(t=>n(t.id,i+1)),e[r]=i};return t.getRoots().forEach(t=>n(t.id,1)),e},eM=t=>{let e=0;return t.getAllEdges().forEach(t=>{e+=t.data.weight}),e},nM="edge-label",rM=(t,e,n)=>{let r=e.source,i=t.getNode(r).data.rank;const o=e.target,A=t.getNode(o).data.rank,s=e.data.labelRank;if(A===i+1)return;let a,c,l;for(t.removeEdge(e.id),l=0,++i;i<A;++l,++i)e.data.points=[],c={originalEdge:e,width:0,height:0,rank:i},a=PC(t,"edge",c,"_d"),i===s&&(c.width=e.data.width,c.height=e.data.height,c.dummy=nM,c.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:a,data:{weight:e.data.weight}}),0===l&&n.push(a),r=a;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},iM=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},oM=(t,e,n)=>{const r=((t,e)=>null==t?void 0:t.reduce((t,n,r)=>(t[n]=e[r],t),{}))(n,n.map((t,e)=>e)),i=e.map(e=>{const n=t.getRelatedEdges(e,"out").map(t=>({pos:r[t.target]||0,weight:t.data.weight}));return null==n?void 0:n.sort((t,e)=>t.pos-e.pos)}),o=i.flat().filter(t=>void 0!==t);let A=1;for(;A<n.length;)A<<=1;const s=2*A-1;A-=1;const a=Array(s).fill(0,0,s);let c=0;return null==o||o.forEach(t=>{if(t){let e=t.pos+A;a[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=a[e+1]),e=e-1>>1,a[e]+=t.weight;c+=t.weight*n}}),c},AM=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=oM(t,e[r-1],e[r]);return n},sM=t=>{const e={},n=t.getAllNodes(),r=n.map(t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0}),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o.push([]);const A=n.sort((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank),s=A.filter(e=>void 0!==t.getNode(e.id).data.fixorder),a=s.sort((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder);return null==a||a.forEach(n=>{isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0}),null==A||A.forEach(n=>t.dfsTree(n.id,t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)})),o},aM=t=>{var e,n;const r=[];for(;null==t?void 0:t.length;){const i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach(t=>{return(e=i,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&cM(e,t)})(t);var e}),null===(n=i.out)||void 0===n||n.forEach(e=>{return(n=i,e=>{e.in.push(n),0===--e.indegree&&t.push(e)})(e);var n})}const i=r.filter(t=>!t.merged),o=["vs","i","barycenter","weight"];return i.map(t=>{const e={};return null==o||o.forEach(n=>{void 0!==t[n]&&(e[n]=t[n])}),e})},cM=(t,e)=>{var n;let r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},lM=(t,e,n)=>{let r,i=n;for(;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},uM=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.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},hM=(t,e,n,r,i,o)=>{var A,s,a,c;let l=t.getChildren(e).map(t=>t.id);const u=t.getNode(e),h=u?u.data.borderLeft:void 0,d=u?u.data.borderRight:void 0,f={};h&&(l=null==l?void 0:l.filter(t=>t!==h&&t!==d));const g=((t,e)=>e.map(e=>{const n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};const r={sum:0,weight:0};return null==n||n.forEach(e=>{const n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight}),{v:e,barycenter:r.sum/r.weight,weight:r.weight}}))(t,l||[]);null==g||g.forEach(e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=hM(t,e.v,n,r,o);f[e.v]=i,i.hasOwnProperty("barycenter")&&fM(e,i)}});const p=((t,e)=>{var n,r,i;const o={};null==t||t.forEach((t,e)=>{o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)}),null===(n=e.getAllEdges())||void 0===n||n.forEach(t=>{const e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))});const A=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,t=>!t.indegree);return aM(A)})(g,n);dM(p,f),null===(A=p.filter(t=>t.vs.length>0))||void 0===A||A.forEach(e=>{const n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)});const v=((t,e,n,r)=>{const i=((t,e)=>{const n={lhs:[],rhs:[]};return null==t||t.forEach(t=>{e(t)?n.lhs.push(t):n.rhs.push(t)}),n})(t,t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")}),o=i.lhs,A=i.rhs.sort((t,e)=>-t.i- -e.i),s=[];let a=0,c=0,l=0;null==o||o.sort(uM(!!e,!!n)),l=lM(s,A,l),null==o||o.forEach(t=>{var e;l+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),a+=t.barycenter*t.weight,c+=t.weight,l=lM(s,A,l)});const u={vs:s.flat()};return c&&(u.barycenter=a/c,u.weight=c),u})(p,r,i,o);if(h&&(v.vs=[h,v.vs,d].flat(),null===(s=t.getPredecessors(h))||void 0===s?void 0:s.length)){const e=t.getNode((null===(a=t.getPredecessors(h))||void 0===a?void 0:a[0].id)||""),n=t.getNode((null===(c=t.getPredecessors(d))||void 0===c?void 0:c[0].id)||"");v.hasOwnProperty("barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+e.data.order+n.data.order)/(v.weight+2),v.weight+=2}return v},dM=(t,e)=>{null==t||t.forEach(t=>{var n;const r=null===(n=t.vs)||void 0===n?void 0:n.map(t=>e[t]?e[t].vs:t);t.vs=r.flat()})},fM=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)};function gM(t){return Array.isArray(t)}var pM=function(t){if("object"!=typeof t||null===t)return t;var e;if(gM(t)){e=[];for(var n=0,r=t.length;n<r;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=pM(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=pM(t[i]):e[i]=t[i];return e};const vM=(t,e,n)=>e.map(e=>((t,e,n)=>{const r=iM(t),i=new MC;return i.addNode({id:r,data:{}}),t.getAllNodes().forEach(o=>{var A,s;const a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(Object.assign({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach(e=>{const n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(Object.assign({},t.getNode(n)));const r=i.getRelatedEdges(n,"out").find(({target:t})=>t===o.id),A=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,Object.assign(Object.assign({},r.data),{weight:e.data.weight+A})):i.addEdge({id:e.id,source:n,target:o.id,data:{weight:e.data.weight+A}})}),o.data.hasOwnProperty("minRank")&&i.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:[null===(A=o.data.borderLeft)||void 0===A?void 0:A[e-o.data.minRank]],borderRight:[null===(s=o.data.borderRight)||void 0===s?void 0:s[e-o.data.minRank]]})))}),i})(t,e,n)),mM=(t,e,n,r)=>{const i=new MC;null==t||t.forEach(t=>{var o;const A=t.getRoots()[0].id,s=hM(t,A,i,e,n,r);for(let e=0;e<(null===(o=s.vs)||void 0===o?void 0:o.length);e++){const n=t.getNode(s.vs[e]);n&&(n.data.order=e)}((t,e,n)=>{const r={};let i;null==n||n.forEach(n=>{let o,A,s=t.getParent(n);for(;s;){if(o=t.getParent(s.id),o?(A=r[o.id],r[o.id]=s.id):(A=i,i=s.id),A&&A!==s.id)return e.hasNode(A)||e.addNode({id:A,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${A}-${s.id}`)||e.addEdge({id:`e${A}-${s.id}`,source:A,target:s.id,data:{}}));s=o}})})(t,i,s.vs)})},yM=(t,e)=>{null==e||e.forEach(e=>{null==e||e.forEach((e,n)=>{t.getNode(e).data.order=n})})},wM=(t,e)=>{const n=(t=>{const e={};let n=0;const r=i=>{const o=n;t.getChildren(i).forEach(t=>r(t.id)),e[i]={low:o,lim:n++}};return t.getRoots().forEach(t=>r(t.id)),e})(t);e.forEach(e=>{var r,i;let o=e,A=t.getNode(o);const s=A.data.originalEdge;if(!s)return;const a=((t,e,n,r)=>{var i,o;const A=[],s=[],a=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);let l,u;l=n;do{l=null===(i=t.getParent(l))||void 0===i?void 0:i.id,A.push(l)}while(l&&(e[l].low>a||c>e[l].lim));for(u=l,l=r;l&&l!==u;)s.push(l),l=null===(o=t.getParent(l))||void 0===o?void 0:o.id;return{lca:u,path:A.concat(s.reverse())}})(t,n,s.source,s.target),c=a.path,l=a.lca;let u=0,h=c[u],d=!0;for(;o!==s.target;){if(A=t.getNode(o),d){for(;h!==l&&(null===(r=t.getNode(h))||void 0===r?void 0:r.data.maxRank)<A.data.rank;)u++,h=c[u];h===l&&(d=!1)}if(!d){for(;u<c.length-1&&(null===(i=t.getNode(c[u+1]))||void 0===i?void 0:i.data.minRank)<=A.data.rank;)u++;h=c[u]}t.hasNode(h)&&t.setParent(o,h),o=t.getSuccessors(o)[0].id}})},bM=(t,e)=>{const n={};function r(e,r){const i=function(t){return JSON.stringify(t.slice(1))}(e);r.get(i)||(!function(e,r,i,o,A){var s,a;let c;for(let l=r;l<i;l++)c=e[l],(null===(s=t.getNode(c))||void 0===s?void 0:s.data.dummy)&&(null===(a=t.getPredecessors(c))||void 0===a||a.forEach(e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>A)&&EM(n,e.id,c)}))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,A=0;const s=new Map;return null==n||n.forEach((a,c)=>{var l;if("border"===(null===(l=t.getNode(a))||void 0===l?void 0:l.data.dummy)){const e=t.getPredecessors(a)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,A,c,o,i],s),A=c,o=i)}r([n,A,n.length,i,e.length],s)}),n};return(null==e?void 0:e.length)&&e.reduce(i),n},BM=(t,e)=>{var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find(e=>t.getNode(e.id).data.dummy)},EM=(t,e,n)=>{let r=e,i=n;if(r>i){const t=r;r=i,i=t}let o=t[r];o||(t[r]=o={}),o[i]=!0},xM=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},CM=(t,e,n,r,i,o)=>{const A=new MC,s=MM(r,i,o);return null==e||e.forEach(e=>{let r;null==e||e.forEach(e=>{const i=n[e];if(A.hasNode(i)||A.addNode({id:i,data:{}}),r){const o=n[r],a=A.getRelatedEdges(o,"out").find(t=>t.target===i);a?A.updateEdgeData(a.id,Object.assign(Object.assign({},a.data),{weight:Math.max(s(t,e,r),a.data.weight||0)})):A.addEdge({id:`e${Math.random()}`,source:o,target:i,data:{weight:Math.max(s(t,e,r),0)}})}r=e})}),A};const MM=(t,e,n)=>(r,i,o)=>{const A=r.getNode(i),s=r.getNode(o);let a=0,c=0;if(a+=A.data.width/2,A.data.hasOwnProperty("labelpos"))switch((A.data.labelpos||"").toLowerCase()){case"l":c=-A.data.width/2;break;case"r":c=A.data.width/2}if(c&&(a+=n?c:-c),c=0,a+=(A.data.dummy?e:t)/2,a+=(s.data.dummy?e:t)/2,a+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":c=s.data.width/2;break;case"r":c=-s.data.width/2}return c&&(a+=n?c:-c),c=0,a},FM=(t,e)=>t.getNode(e).data.width||0,kM=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=HC(t),A=Object.assign(((t,e)=>{const n={},r=(e,r)=>{let i=0,o=0;const A=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach((e,a)=>{var c;const l=BM(t,e),u=l?t.getNode(l.id).data.order:A;(l||e===s)&&(null===(c=r.slice(o,a+1))||void 0===c||c.forEach(e=>{var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach(r=>{var o;const A=t.getNode(r.id),s=A.data.order;!(s<i||u<s)||A.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||EM(n,r.id,e)})}),o=a+1,i=u)}),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),bM(t,o)),s={};let a=[];["u","d"].forEach(e=>{a="u"===e?o:Object.values(o).reverse(),["l","r"].forEach(n=>{"r"===n&&(a=a.map(t=>Object.values(t).reverse()));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),c=((t,e,n,r)=>{const i={},o={},A={};return null==e||e.forEach(t=>{null==t||t.forEach((t,e)=>{i[t]=t,o[t]=t,A[t]=e})}),null==e||e.forEach(t=>{let e=-1;null==t||t.forEach(t=>{let s=r(t).map(t=>t.id);if(s.length){s=s.sort((t,e)=>A[t]-A[e]);const r=(s.length-1)/2;for(let a=Math.floor(r),c=Math.ceil(r);a<=c;++a){const r=s[a];o[t]===t&&e<A[r]&&!xM(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=A[r])}}})}),{root:i,align:o}})(0,a,A,o),l=((t,e,n,r,i,o,A)=>{var s;const a={},c=CM(t,e,n,i,o,A),l=A?"borderLeft":"borderRight",u=(t,e)=>{let n=c.getAllNodes(),r=n.pop();const i={};for(;r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return u(t=>{a[t]=(c.getRelatedEdges(t,"in")||[]).reduce((t,e)=>Math.max(t,(a[e.source]||0)+e.data.weight),0)},c.getPredecessors.bind(c)),u(e=>{const n=(c.getRelatedEdges(e,"out")||[]).reduce((t,e)=>Math.min(t,(a[e.target]||0)-e.data.weight),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==l&&(a[e]=Math.max(a[e],n))},c.getSuccessors.bind(c)),null===(s=Object.values(r))||void 0===s||s.forEach(t=>{a[t]=a[n[t]]}),a})(t,a,c.root,c.align,r,i,"r"===n);"r"===n&&Object.keys(l).forEach(t=>l[t]=-l[t]),s[e+n]=l})});const c=((t,e)=>KC(Object.values(e),e=>{var n;let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach(n=>{const o=e[n],A=FM(t,n)/2;r=Math.max(o+A,r),i=Math.min(o-A,i)}),r-i}))(t,s);return c&&function(t,e){const n=Object.values(e),r=Math.min(...n),i=Math.max(...n);["u","d"].forEach(n=>{["l","r"].forEach(o=>{const A=n+o,s=t[A];let a;if(s===e)return;const c=Object.values(s);a="l"===o?r-Math.min(...c):i-Math.max(...c),a&&(t[A]={},Object.keys(s).forEach(e=>{t[A][e]=s[e]+a}))})})}(s,c),((t,e)=>{const n={};return Object.keys(t.ul).forEach(r=>{if(e)n[r]=t[e.toLowerCase()][r];else{const e=Object.values(t).map(t=>t[r]);n[r]=(e[0]+e[1])/2}}),n})(s,n)},SM=(t,e)=>{var n;const r=DC(t);((t,e)=>{const{ranksep:n=0}=e||{},r=HC(t);let i=0;null==r||r.forEach(e=>{const r=e.map(e=>t.getNode(e).data.height),o=Math.max(...r,0);null==e||e.forEach(e=>{t.getNode(e).data.y=i+o/2}),i+=o+n})})(r,e);const i=kM(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach(t=>{r.getNode(t).data.x=i[t]})},QM=t=>{const e={},n=r=>{var i;const o=t.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;let A;return e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach(t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===A||e<A)&&(A=e)}),A||(A=0),o.data.rank=A,A};t.getAllNodes().filter(e=>0===t.getRelatedEdges(e.id,"in").length).forEach(t=>n(t.id))},UM=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,NM=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach(i=>{const o=i.source,A=r===o?i.target:o;t.hasNode(A)||UM(e,i)||(t.addNode({id:A,data:{}}),t.addEdge({id:i.id,source:r,target:A,data:{}}),n(A))})};return t.getAllNodes().forEach(t=>n(t.id)),t.getAllNodes().length},TM=(t,e)=>{const n=r=>{var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach(i=>{const o=i.source,A=r===o?i.target:o;t.hasNode(A)||void 0===e.getNode(A).data.layer&&UM(e,i)||(t.addNode({id:A,data:{}}),t.addEdge({id:i.id,source:r,target:A,data:{}}),n(A))})};return t.getAllNodes().forEach(t=>n(t.id)),t.getAllNodes().length},OM=(t,e)=>KC(e.getAllEdges(),n=>t.hasNode(n.source)!==t.hasNode(n.target)?UM(e,n):1/0),IM=(t,e,n)=>{t.getAllNodes().forEach(t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n})},LM=t=>{const e=(t=>{const e=new MC;return t.getAllNodes().forEach(t=>{e.addNode(Object.assign({},t))}),t.getAllEdges().forEach(t=>{const n=e.getRelatedEdges(t.source,"out").find(e=>e.target===t.target);n?e.updateEdgeData(null==n?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})}),e})(t);QM(e);const n=(t=>{const e=new MC({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);NM(e,t)<r;)i=OM(e,t),o=e.hasNode(i.source)?UM(t,i):-UM(t,i),IM(e,t,o);return e})(e);let r,i;for(HM(n),PM(n,e);r=GM(n);)i=KM(n,e,r),jM(n,e,r,i)},PM=(t,e)=>{let n=zC(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach(n=>{DM(t,e,n)})},DM=(t,e,n)=>{const r=t.getNode(n).data.parent,i=t.getRelatedEdges(n,"both").find(t=>t.target===r||t.source===r);i.data.cutvalue=RM(t,e,n)},RM=(t,e,n)=>{const r=t.getNode(n).data.parent;let i=!0,o=e.getRelatedEdges(n,"out").find(t=>t.target===r),A=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find(t=>t.target===n)),A=o.data.weight,e.getRelatedEdges(n,"both").forEach(e=>{const o=e.source===n,s=o?e.target:e.source;if(s!==r){const r=o===i,a=e.data.weight;if(A+=r?a:-a,VM(t,n,s)){const e=t.getRelatedEdges(n,"both").find(t=>t.source===s||t.target===s).data.cutvalue;A+=r?-e:e}}}),A},HM=(t,e=t.getAllNodes()[0].id)=>{_M(t,{},1,e)},_M=(t,e,n,r,i)=>{var o;const A=n;let s=n;const a=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach(n=>{e[n.id]||(s=_M(t,e,s,n.id,r))}),a.data.low=A,a.data.lim=s++,i?a.data.parent=i:delete a.data.parent,s},GM=t=>t.getAllEdges().find(t=>t.data.cutvalue<0),KM=(t,e,n)=>{let r=n.source,i=n.target;e.getRelatedEdges(r,"out").find(t=>t.target===i)||(r=n.target,i=n.source);const o=t.getNode(r),A=t.getNode(i);let s=o,a=!1;o.data.lim>A.data.lim&&(s=A,a=!0);const c=e.getAllEdges().filter(e=>a===WM(t.getNode(e.source),s)&&a!==WM(t.getNode(e.target),s));return KC(c,t=>UM(e,t))},jM=(t,e,n,r)=>{const i=t.getRelatedEdges(n.source,"both").find(t=>t.source===n.target||t.target===n.target);i&&t.removeEdge(i.id),t.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),HM(t),PM(t,e),zM(t,e)},zM=(t,e)=>{const n=t.getAllNodes().find(t=>!t.data.parent);let r=zC(t,n,"pre");r=r.slice(1),r.forEach(n=>{const r=t.getNode(n).data.parent;let i=e.getRelatedEdges(n,"out").find(t=>t.target===r),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find(t=>t.target===n),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))})},VM=(t,e,n)=>t.getRelatedEdges(e,"both").find(t=>t.source===n||t.target===n),WM=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,YM=QM,XM=t=>{(t=>{const e={};let n;const r=i=>{var o;const A=t.getNode(i);if(!A)return 0;if(e[i])return A.data.rank;let s;return e[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach(t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)}),s||(s=0),(void 0===n||s<n)&&(n=s),A.data.rank=s,s};t.getAllNodes().filter(e=>0===t.getRelatedEdges(e.id,"in").length).forEach(t=>{t&&r(t.id)}),void 0===n&&(n=0);const i={},o=(e,n)=>{var r;const A=t.getNode(e),s=isNaN(A.data.layer)?n:A.data.layer;(void 0===A.data.rank||A.data.rank<s)&&(A.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach(t=>{o(t.target,s+t.data.minlen)}))};t.getAllNodes().forEach(t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=n:o(t.id,e.layer))})})(t),(t=>{const e=new MC({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);TM(e,t)<r;)i=OM(e,t),o=e.hasNode(i.source)?UM(t,i):-UM(t,i),IM(e,t,o)})(t)},qM=t=>{LM(t)},$M=(t,e)=>{const{ranker:n,rankdir:r="tb",nodeOrder:i,keepNodeOrder:o,align:A,nodesep:s=50,edgesep:a=20,ranksep:c=50}=e;gF(t),LC(t);const{nestingRoot:l,nodeRankFactor:u}=(t=>{const e=PC(t,"root",{},"_root"),n=tM(t);let r=Math.max(...Object.values(n));Math.abs(r)===1/0&&(r=1);const i=r-1,o=2*i+1;t.getAllEdges().forEach(t=>{t.data.minlen*=o});const A=eM(t)+1;return t.getRoots().forEach(r=>{JC(t,e,o,A,i,n,r.id)}),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":qM(t);break;case"tight-tree":default:XM(t);break;case"longest-path":YM(t)}})(DC(t),n),sF(t),((t,e=0)=>{const n=t.getAllNodes(),r=n.filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),i=Math.min(...r),o=[];n.forEach(t=>{const e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)});let A=0;for(let n=0;n<o.length;n++){const r=o[n];void 0===r?n%e!==0&&(A-=1):A&&(null==r||r.forEach(e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=A)}))}})(t,u),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach(e=>{e.data.nestingEdge&&t.removeEdge(e.id)})})(t,l),(t=>{const e=t.getAllNodes().filter(t=>void 0!==t.data.rank).map(t=>t.data.rank),n=Math.min(...e);t.getAllNodes().forEach(t=>{t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)})})(t),aF(t),cF(t);const h=[];((t,e)=>{t.getAllEdges().forEach(n=>rM(t,n,e))})(t,h),wM(t,h),(t=>{const e=n=>{const r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach(t=>e(t.id)),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let e=i.data.minRank,r=i.data.maxRank+1;e<r;e+=1)VC(t,"borderLeft","_bl",n,i,e),VC(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach(t=>e(t.id))})(t),o&&((t,e)=>{const n=t.getAllNodes().filter(e=>{var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)}),r=n.map(t=>t.data.rank),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o[t]=[];null==e||e.forEach(e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=o[n.data.rank].length,o[n.data.rank].push(e)))})})(t,i),((t,e)=>{const n=GC(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=vM(t,r,"in"),A=vM(t,i,"out");let s=sM(t);yM(t,s);let a,c=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){mM(n%2?o:A,n%4>=2,!1,e),s=HC(t);const i=AM(t,s);i<c&&(r=0,a=pM(s),c=i)}s=sM(t),yM(t,s);for(let n=0,r=0;r<4;++n,++r){mM(n%2?o:A,n%4>=2,!0,e),s=HC(t);const i=AM(t,s);i<c&&(r=0,a=pM(s),c=i)}yM(t,a)})(t,o),pF(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||WC(t)})(t,r),SM(t,{align:A,nodesep:s,edgesep:a,ranksep:c}),vF(t),fF(t),((t,e)=>{e.forEach(e=>{let n=t.getNode(e);const{data:r}=n,i=r.originalEdge;let o;i&&t.addEdge(i);let A=e;for(;n.data.dummy;)o=t.getSuccessors(A)[0],t.removeNode(A),i.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===nM&&(i.data.x=n.data.x,i.data.y=n.data.y,i.data.width=n.data.width,i.data.height=n.data.height),A=o.id,n=t.getNode(A)})})(t,h),hF(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||XC(t),"lr"!==n&&"rl"!==n||($C(t),WC(t))})(t,r);const{width:d,height:f}=lF(t);return uF(t),dF(t),(t=>{t.getAllEdges().forEach(e=>{const n=e.data;if(n.reversed){t.removeEdge(e.id);const r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},n),{forwardName:r})})}})})(t),{width:d,height:f}},ZM=(t,e)=>{t.getAllNodes().forEach(n=>{const r=t.getNode(n.id);if(e.hasNode(n.id)){const t=e.getNode(n.id);r.data.fixorder=t.data._order,delete t.data._order}else delete r.data.fixorder})},JM=(t,e)=>{t.getAllNodes().forEach(n=>{var r;const i=t.getNode(n.id);if(i){const t=e.getNode(n.id);i.data.x=t.data.x,i.data.y=t.data.y,i.data._order=t.data.order,i.data._rank=t.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=t.data.width,i.data.height=t.data.height)}}),t.getAllEdges().forEach(n=>{const r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)})},tF=["width","height","layer","fixorder"],eF={width:0,height:0},nF=["minlen","weight","width","height","labeloffset"],rF={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},iF=["labelpos"],oF=t=>{const e=new MC({tree:[]});return t.getAllNodes().forEach(n=>{const r=yF(t.getNode(n.id).data),i=Object.assign(Object.assign({},eF),r),o=mF(i,tF);e.hasNode(n.id)||e.addNode({id:n.id,data:Object.assign({},o)});const A=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);Kx(A)||(e.hasNode(A.id)||e.addNode(Object.assign({},A)),e.setParent(n.id,A.id))}),t.getAllEdges().forEach(n=>{const r=yF(t.getEdge(n.id).data),i={};null==iF||iF.forEach(t=>{void 0!==r[t]&&(i[t]=r[t])}),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},rF,mF(r,nF),i)})}),e},AF=(t,e)=>{const{ranksep:n=0,rankdir:r}=e;return t.getAllNodes().forEach(t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)}),t.getAllEdges().forEach(t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===r||"BT"===r?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)}),n/2},sF=t=>{t.getAllEdges().forEach(e=>{if(e.data.width&&e.data.height){const n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};PC(t,"edge-proxy",r,"_ep")}})},aF=t=>{let e=0;return t.getAllNodes().forEach(n=>{var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))}),e},cF=t=>{t.getAllNodes().forEach(e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))})},lF=(t,e)=>{let n,r,i=0,o=0;const{marginx:A=0,marginy:s=0}={},a=t=>{if(!t.data)return;const e=t.data.x,A=t.data.y,s=t.data.width,a=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(A)||isNaN(a)||(void 0===r&&(r=A-a/2),r=Math.min(r,A-a/2),o=Math.max(o,A+a/2))};return t.getAllNodes().forEach(t=>{a(t)}),t.getAllEdges().forEach(t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&a(t)}),n-=A,r-=s,t.getAllNodes().forEach(t=>{t.data.x-=n,t.data.y-=r}),t.getAllEdges().forEach(t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach(t=>{t.x-=n,t.y-=r}),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)}),{width:i-n+A,height:o-r+s}},uF=t=>{t.getAllEdges().forEach(e=>{const n=t.getNode(e.source),r=t.getNode(e.target);let i,o;e.data.points?(i=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],i={x:r.data.x,y:r.data.y},o={x:n.data.x,y:n.data.y}),e.data.points.unshift(RC(n.data,i)),e.data.points.push(RC(r.data,o))})},hF=t=>{t.getAllEdges().forEach(t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}})},dF=t=>{t.getAllEdges().forEach(t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())})},fF=t=>{t.getAllNodes().forEach(e=>{var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){const n=t.getNode(e.id),o=t.getNode(n.data.borderTop),A=t.getNode(n.data.borderBottom),s=t.getNode(n.data.borderLeft[(null===(r=n.data.borderLeft)||void 0===r?void 0:r.length)-1]),a=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==a?void 0:a.data.x)-(null==s?void 0:s.data.x))||10,n.data.height=Math.abs((null==A?void 0:A.data.y)-(null==o?void 0:o.data.y))||10,n.data.x=((null==s?void 0:s.data.x)||0)+n.data.width/2,n.data.y=((null==o?void 0:o.data.y)||0)+n.data.height/2}}),t.getAllNodes().forEach(e=>{"border"===e.data.dummy&&t.removeNode(e.id)})},gF=t=>{t.getAllEdges().forEach(e=>{if(e.source===e.target){const n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}})},pF=t=>{const e=HC(t);null==e||e.forEach(e=>{let n=0;null==e||e.forEach((e,r)=>{var i;const o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach(e=>{PC(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")}),delete o.data.selfEdges})})},vF=t=>{t.getAllNodes().forEach(e=>{const n=t.getNode(e.id);if("selfedge"===n.data.dummy){const r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,A=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*A/3,y:o-s},{x:i+5*A/6,y:o-s},{y:o,x:i+A},{x:i+5*A/6,y:o+s},{x:i+2*A/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}})},mF=(t,e)=>{const n={};return null==e||e.forEach(e=>{void 0!==t[e]&&(n[e]=+t[e])}),n},yF=(t={})=>{const e={};return Object.keys(t).forEach(n=>{e[n.toLowerCase()]=t[n]}),e},wF={nodeSize:10,nodeSpacing:0,rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class bF extends EC{constructor(){super(...arguments),this.id="antv-dagre"}getDefaultOptions(){return wF}layout(t){return mx(this,0,void 0,function*(){const{nodeSize:e,nodeSpacing:n,align:r,rankdir:i="TB",ranksep:o,nodesep:A,edgeLabelSpace:s,ranker:a="tight-tree",nodeOrder:c,begin:l,controlPoints:u,radial:h,sortByCombo:d,preset:f,ranksepFunc:g,nodesepFunc:p}=t,v=Wx(g,null!=o?o:50,"node"),m=Wx(p,null!=A?A:50,"node");let y=m,w=v;"LR"!==i&&"RL"!==i||(y=v,w=m);const b=new MC({tree:[]}),B=this.model.nodes(),E=this.model.edges(),x=Xx(e,n,wF.nodeSize,wF.nodeSpacing);B.forEach(t=>{var e;const n=t._original,r=x(n),i=w(n),o=y(n),A=r[0]+2*o,s=r[1]+2*i,a=null===(e=t.data)||void 0===e?void 0:e.layer;_x(a)?b.addNode({id:t.id,data:{width:A,height:s,layer:a,originalWidth:r[0],originalHeight:r[1]}}):b.addNode({id:t.id,data:{width:A,height:s,originalWidth:r[0],originalHeight:r[1]}})}),E.forEach(t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{}})}),d&&(b.attachTreeStructure("combo"),B.forEach(t=>{const e=null==t?void 0:t.parentId;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}));let C=null;(null==f?void 0:f.length)&&(C=new MC,f.forEach(t=>{C.addNode({id:t.id,data:t.data})})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:A}=e;!r&&i&&ZM(t,i);const s=oF(t);let a;n&&(e.ranksep=AF(s,{rankdir:o,ranksep:A}));try{a=$M(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}JM(t,s)})(b,{prevGraph:C,edgeLabelSpace:s,keepNodeOrder:!!c,nodeOrder:c||[],acyclicer:"greedy",ranker:a,rankdir:i,nodesep:A,align:r});const M=[0,0];if(l){let t=1/0,e=1/0;b.getAllNodes().forEach(n=>{t>n.data.x&&(t=n.data.x),e>n.data.y&&(e=n.data.y)}),b.getAllEdges().forEach(n=>{var r;null===(r=n.data.points)||void 0===r||r.forEach(n=>{t>n.x&&(t=n.x),e>n.y&&(e=n.y)})}),M[0]=l[0]-t,M[1]=l[1]-e}const F="LR"===i||"RL"===i;if(h);else{const t=new Set,e="BT"===i||"RL"===i?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach(e=>{e.data.x=e.data.x+M[0],e.data.y=e.data.y+M[1],t.add(F?e.data.x:e.data.y)});const n=Array.from(t).sort(e),r=F?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,o=F?(t,e,n)=>{const r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter(t=>t.y<=r&&t.y>=i)}:(t,e,n)=>{const r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter(t=>t.x<=r&&t.x>=i)};b.getAllEdges().forEach((t,e)=>{var i;s&&u&&"loop"!==t.data.type&&(t.data.controlPoints=BF(null===(i=t.data.points)||void 0===i?void 0:i.map(({x:t,y:e})=>({x:t+M[0],y:e+M[1]})),b.getNode(t.source),b.getNode(t.target),n,F,r,o))})}this.model.forEachNode(t=>{const e=b.getNode(t.id);if(e){const{x:n,y:r,width:i,height:o,originalWidth:A,originalHeight:s}=e.data,a=d?b.getChildren(t.id,"combo"):b.getChildren(t.id);if(a.length>0){let e=1/0,n=-1/0,r=1/0,i=-1/0;a.forEach(t=>{const o=t.id,A=b.getNode(o);if(null==A?void 0:A.data){const t=A.data.x,o=A.data.y,s=A.data.originalWidth||A.data.width||0,a=A.data.originalHeight||A.data.height||0;e=Math.min(e,t-s/2),n=Math.max(n,t+s/2),r=Math.min(r,o-a/2),i=Math.max(i,o+a/2)}});const o=20,A=(n-e||0)+2*o,s=(i-r||0)+2*o;t.x=(e+n)/2,t.y=(r+i)/2,t.size=[A,s]}else t.x=n,t.y=r,t.size=[A,s]}}),this.model.forEachEdge(t=>{const e=b.getEdge(t.id);e&&e.data.controlPoints&&(t.points=e.data.controlPoints.map(qx))})})}}const BF=(t,e,n,r,i,o,A)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){let{x:t,y:a}=e.data,{x:c,y:l}=n.data;if(i&&(t=e.data.y,a=e.data.x,c=n.data.y,l=n.data.x),l!==a&&t!==c){const u=r.indexOf(a),h=r[u+1];if(h){const t=s[0],e=i?{x:(a+h)/2,y:(null==t?void 0:t.y)||c}:{x:(null==t?void 0:t.x)||c,y:(a+h)/2};t&&!o(t,e)||s.unshift(e)}const d=r.indexOf(l),f=Math.abs(d-u);if(1===f)s=A(s,e.data,n.data),s.length||s.push(i?{x:(a+l)/2,y:t}:{x:t,y:(a+l)/2});else if(f>1){const e=r[d-1];if(e){const n=s[s.length-1],r=i?{x:(l+e)/2,y:(null==n?void 0:n.y)||c}:{x:(null==n?void 0:n.x)||t,y:(l+e)/2};n&&!o(n,r)||s.push(r)}}}}return s};function EF(t,e,n=2){if(1===t.nodeCount()){const r=t.firstNode();r.x=e[0],r.y=e[1],3===n&&(r.z=e[2]||0)}}function xF(t,e){const n=t.nodes();return n.sort(e),t.setNodeOrder(n),t}function CF(t,e="desc"){return xF(t,(n,r)=>{const i=t.degree(n.id),o=t.degree(r.id);return"asc"===e?i-o:o-i})}function MF(t,e){return xF(t,(n,r)=>{const i=t.originalNode(n.id),o=t.originalNode(r.id);return e(i,o)})}function FF(t,e=!1){const n=t.nodeCount();if(0===n)return t;const r=t.nodes(),i=[r[0]],o={};o[r[0].id]=!0;let A=0,s=0;return t.forEachNode(a=>{if(0!==s){const c=t.degree(a.id,"both"),l=s<n-1?t.degree(r[s+1].id,"both"):0,u=i[A].id,h=t.neighbors(u,"both").includes(a.id);if(s!==n-1&&c===l&&!h||o[a.id]){const A=e?t.successors(u):t.neighbors(u);let s=!1;for(let e=0;e<A.length;e++){const n=A[e],r=t.node(n);if(r&&t.degree(n)===t.degree(a.id)&&!o[n]){i.push(r),o[n]=!0,s=!0;break}}let c=0;for(;!s&&(o[r[c].id]||(i.push(r[c]),o[r[c].id]=!0,s=!0),c++,c!==n););}else i.push(a),o[a.id]=!0,A++}s++}),t.setNodeOrder(i),t}const kF=t=>{const{width:e,height:n,center:r}=t,i=null!=e?e:"undefined"!=typeof window?window.innerWidth:0,o=null!=n?n:"undefined"!=typeof window?window.innerHeight:0;return{width:i,height:o,center:null!=r?r:[i/2,o/2]}},SF={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1,nodeSize:10,nodeSpacing:0};class QF extends EC{constructor(){super(...arguments),this.id="circular"}getDefaultOptions(){return SF}layout(){return mx(this,0,void 0,function*(){const{width:t,height:e,center:n}=kF(this.options),r=this.model.nodeCount();if(!r||1===r)return void EF(this.model,n);const{ordering:i,nodeSpacing:o,nodeSize:A,endAngle:s=2*Math.PI,startAngle:a=0,divisions:c,angleRatio:l,clockwise:u}=this.options;"topology"===i?FF(this.model,!1):"topology-directed"===i?FF(this.model,!0):"degree"===i&&CF(this.model,"asc");let{radius:h,startRadius:d,endRadius:f}=this.options;const g=this.model.nodes(),p=Xx(A,o,SF.nodeSize,SF.nodeSpacing);if(o){let t=0;for(const e of g)t+=Math.max(...p(e._original));h=t/(2*Math.PI)}else h||d||f?!d&&f?d=f:d&&!f&&(f=d):h=Math.min(e,t)/2;const v=(s-a)/r*l,m=Math.ceil(r/c),y=2*Math.PI/c;for(let t=0;t<r;){const e=g[t];let i=h;i||null===d||null===f||(i=d+t*(f-d)/(r-1)),i||(i=10+100*t/(r-1));const o=t%m*v+y*Math.floor(t/m);let A=a+o;u||(A=s-o),e.x=n[0]+Math.cos(A)*i,e.y=n[1]+Math.sin(A)*i,t++}})}}const UF={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class NF extends EC{constructor(){super(...arguments),this.id="concentric"}getDefaultOptions(){return UF}layout(){return mx(this,0,void 0,function*(){const{width:t,height:e,center:n}=kF(this.options),r=this.model.nodeCount();if(!r||1===r)return void EF(this.model,n);const{sortBy:i,maxLevelDiff:o,sweep:A,clockwise:s,equidistant:a,preventOverlap:c,startAngle:l=UF.startAngle,nodeSize:u,nodeSpacing:h}=this.options,d=i&&"degree"!==i?Vx(i,["node"]):"degree";if("degree"===d)CF(this.model);else{const t=(t,e)=>{const n=d(t),r=d(e);return n===r?0:n>r?-1:1};MF(this.model,t)}const f=this.model.nodes(),g=new Map;for(const t of f){const e="degree"===d?this.model.degree(t.id):d(t._original);g.set(t.id,e)}const p=this.model.firstNode(),v=o||g.get(p.id)/4,m=Xx(u,h,UF.nodeSize,UF.nodeSpacing),y=new Map;for(const t of f)y.set(t.id,Math.max(...m(t._original)));const w=[{nodes:[]}];let b=w[0];for(let t=0;t<r;t++){const e=f[t];if(b.nodes.length>0){const t=b.nodes[0],n=Math.abs(g.get(t.id)-g.get(e.id));v&&n>=v&&(b={nodes:[]},w.push(b))}b.nodes.push(e)}for(const t of w){const e=t.nodes.map(t=>y.get(t.id));t.nodeSizes=e,t.maxNodeSize=Math.max(...e)}if(w.forEach(t=>{const e=void 0===A?2*Math.PI-2*Math.PI/t.nodes.length:A;t.dTheta=e/Math.max(1,t.nodes.length-1)}),c){let t=0;for(let e=0;e<w.length;e++){const n=w[e];if(n.nodes.length>1){const e=n.nodeSizes||[];let r=0;for(let t=0;t<e.length-1;t++)r=Math.max(r,(e[t]+e[t+1])/2);const i=Math.cos(n.dTheta)-Math.cos(0),o=Math.sin(n.dTheta)-Math.sin(0),A=Math.sqrt(i*i+o*o),s=A>0?r/A:0;t=Math.max(s,t)}if(n.r=t,e<w.length-1){const r=w[e+1],i=((n.maxNodeSize||0)+(r.maxNodeSize||0))/2;t+=Math.max(0,i)}}}else{let n=0;w[0].r=0;for(let t=0;t<w.length-1;t++){const e=w[t],r=w[t+1],i=((e.maxNodeSize||0)+(r.maxNodeSize||0))/2;n+=Math.max(0,i),r.r=n}const r=Math.min(t,e)/2;let i=1;for(const t of w){const e=t.r||0;if(e<=0)continue;const n=r-(t.maxNodeSize||0);if(n<=0){i=0;break}i=Math.min(i,n/e)}if(i=Math.max(0,Math.min(1,i)),1!==i)for(const t of w)t.r=(t.r||0)*i}if(a){let t=0,e=0;for(let n=0;n<w.length;n++){const r=(w[n].r||0)-e;t=Math.max(t,r)}e=0,w.forEach((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t})}w.forEach(t=>{const e=t.dTheta||0,r=t.r||0;t.nodes.forEach((t,i)=>{const o=l+(s?1:-1)*e*i;t.x=n[0]+r*Math.cos(o),t.y=n[1]+r*Math.sin(o)})})})}}function TF(t,...e){return e.forEach(e=>{e&&Object.keys(e).forEach(n=>{const r=e[n];void 0!==r&&(t[n]=r)})}),t}const OF=4294967296;var IF,LF,PF=0,DF=0,RF=0,HF=0,_F=0,GF=0,KF="object"==typeof performance&&performance.now?performance:Date,jF="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function zF(){return _F||(jF(VF),_F=KF.now()+GF)}function VF(){_F=0}function WF(){this._call=this._time=this._next=null}function YF(t,e,n){var r=new WF;return r.restart(t,e,n),r}function XF(){_F=(HF=KF.now())+GF,PF=DF=0;try{!function(){zF(),++PF;for(var t,e=IF;e;)(t=_F-e._time)>=0&&e._call.call(void 0,t),e=e._next;--PF}()}finally{PF=0,function(){var t,e,n=IF,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:IF=e);LF=t,$F(r)}(),_F=0}}function qF(){var t=KF.now(),e=t-HF;e>1e3&&(GF-=e,HF=t)}function $F(t){PF||(DF&&(DF=clearTimeout(DF)),t-_F>24?(t<1/0&&(DF=setTimeout(XF,t-KF.now()-GF)),RF&&(RF=clearInterval(RF))):(RF||(HF=KF.now(),RF=setInterval(qF,1e3)),PF=1,jF(XF)))}WF.prototype=YF.prototype={constructor:WF,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?zF():+n)+(null==e?0:+e),this._next||LF===this||(LF?LF._next=this:IF=this,LF=this),this._call=t,this._time=n,$F()},stop:function(){this._call&&(this._call=null,this._time=1/0,$F())}};var ZF={value:()=>{}};function JF(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new tk(r)}function tk(t){this._=t}function ek(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function nk(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=ZF,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}function rk(t){return t.x}function ik(t){return t.y}tk.prototype=JF.prototype={constructor:tk,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]=nk(i[n],t.name,e);else if(null==e)for(n in i)i[n]=nk(i[n],t.name,null);return this}for(;++A<s;)if((n=(t=o[A]).type)&&(n=ek(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new tk(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 ok=Math.PI*(3-Math.sqrt(5));function Ak(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,A=.6,s=new Map,a=YF(u),c=JF("tick","end"),l=function(){let t=1;return()=>(t=(1664525*t+1013904223)%OF)/OF}();function u(){h(),c.call("tick",e),n<r&&(a.stop(),c.call("end",e))}function h(r){var a,c,l=t.length;void 0===r&&(r=1);for(var u=0;u<r;++u)for(n+=(o-n)*i,s.forEach(function(t){t(n)}),a=0;a<l;++a)null==(c=t[a]).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 d(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),o=n*ok;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,l),e}return null==t&&(t=[]),d(),e={tick:h,restart:function(){return a.restart(u),e},stop:function(){return a.stop(),e},nodes:function(n){return arguments.length?(t=n,d(),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?(l=t,s.forEach(f),e):l},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,a,c=0,l=t.length;for(null==r?r=1/0:r*=r,c=0;c<l;++c)(A=(i=e-(s=t[c]).x)*i+(o=n-s.y)*o)<r&&(a=s,r=A);return a},on:function(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t)}}}function sk(t){return function(){return t}}function ak(t){var e,n,r,i=sk(.1);function o(t){for(var i,o=0,A=e.length;o<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=sk(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:sk(+t),A(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:sk(+e),A(),o):t},o}function ck(t){var e,n,r,i=sk(.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=sk(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:sk(+t),A(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:sk(+e),A(),o):t},o}function lk(t){return 1e-6*(t()-.5)}function uk(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,A,s,a,c,l,u,h,d=t._root,f={data:r},g=t._x0,p=t._y0,v=t._x1,m=t._y1;if(!d)return t._root=f,t;for(;d.length;)if((c=e>=(o=(g+v)/2))?g=o:v=o,(l=n>=(A=(p+m)/2))?p=A:m=A,i=d,!(d=d[u=l<<1|c]))return i[u]=f,t;if(s=+t._x.call(null,d.data),a=+t._y.call(null,d.data),e===s&&n===a)return f.next=d,i?i[u]=f:t._root=f,t;do{i=i?i[u]=new Array(4):t._root=new Array(4),(c=e>=(o=(g+v)/2))?g=o:v=o,(l=n>=(A=(p+m)/2))?p=A:m=A}while((u=l<<1|c)==(h=(a>=A)<<1|s>=o));return i[h]=d,i[u]=f,t}function hk(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function dk(t){return t[0]}function fk(t){return t[1]}function gk(t,e,n){var r=new pk(null==e?dk:e,null==n?fk:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function pk(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function vk(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var mk=gk.prototype=pk.prototype;function yk(t){return t.x+t.vx}function wk(t){return t.y+t.vy}function bk(t){var e,n,r,i=1,o=1;function A(){for(var t,A,a,c,l,u,h,d=e.length,f=0;f<o;++f)for(A=gk(e,yk,wk).visitAfter(s),t=0;t<d;++t)a=e[t],u=n[a.index],h=u*u,c=a.x+a.vx,l=a.y+a.vy,A.visit(g);function g(t,e,n,o,A){var s=t.data,d=t.r,f=u+d;if(!s)return e>c+f||o<c-f||n>l+f||A<l-f;if(s.index>a.index){var g=c-s.x-s.vx,p=l-s.y-s.vy,v=g*g+p*p;v<f*f&&(0===g&&(v+=(g=lk(r))*g),0===p&&(v+=(p=lk(r))*p),v=(f-(v=Math.sqrt(v)))/v*i,a.vx+=(g*=v)*(f=(d*=d)/(h+d)),a.vy+=(p*=v)*f,s.vx-=g*(f=1-f),s.vy-=p*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 a(){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=sk(null==t?1:+t)),A.initialize=function(t,n){e=t,r=n,a()},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:sk(+e),a(),A):t},A}function Bk(){var t,e,n,r,i,o=sk(-30),A=1,s=1/0,a=.81;function c(n){var i,o=t.length,A=gk(t,rk,ik).visitAfter(u);for(r=n,i=0;i<o;++i)e=t[i],A.visit(h)}function l(){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 u(t){var e,n,r,o,A,s=0,a=0;if(t.length){for(r=o=A=0;A<4;++A)(e=t[A])&&(n=Math.abs(e.value))&&(s+=e.value,a+=n,r+=n*e.x,o+=n*e.y);t.x=r/a,t.y=o/a}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 h(t,o,c,l){if(!t.value)return!0;var u=t.x-e.x,h=t.y-e.y,d=l-o,f=u*u+h*h;if(d*d/a<f)return f<s&&(0===u&&(f+=(u=lk(n))*u),0===h&&(f+=(h=lk(n))*h),f<A&&(f=Math.sqrt(A*f)),e.vx+=u*t.value*r/f,e.vy+=h*t.value*r/f),!0;if(!(t.length||f>=s)){(t.data!==e||t.next)&&(0===u&&(f+=(u=lk(n))*u),0===h&&(f+=(h=lk(n))*h),f<A&&(f=Math.sqrt(A*f)));do{t.data!==e&&(d=i[t.data.index]*r/f,e.vx+=u*d,e.vy+=h*d)}while(t=t.next)}}return c.initialize=function(e,r){t=e,n=r,l()},c.strength=function(t){return arguments.length?(o="function"==typeof t?t:sk(+t),l(),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?(a=t*t,c):Math.sqrt(a)},c}function Ek(t){return t.index}function xk(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function Ck(t){var e,n,r,i,o,A,s=Ek,a=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},c=sk(30),l=1;function u(r){for(var i=0,s=t.length;i<l;++i)for(var a,c,u,h,d,f,g,p=0;p<s;++p)c=(a=t[p]).source,h=(u=a.target).x+u.vx-c.x-c.vx||lk(A),d=u.y+u.vy-c.y-c.vy||lk(A),h*=f=((f=Math.sqrt(h*h+d*d))-n[p])/f*r*e[p],d*=f,u.vx-=h*(g=o[p]),u.vy-=d*g,c.vx+=h*(g=1-g),c.vy+=d*g}function h(){if(r){var A,a,c=r.length,l=t.length,u=new Map(r.map((t,e)=>[s(t,e,r),t]));for(A=0,i=new Array(c);A<l;++A)(a=t[A]).index=A,"object"!=typeof a.source&&(a.source=xk(u,a.source)),"object"!=typeof a.target&&(a.target=xk(u,a.target)),i[a.source.index]=(i[a.source.index]||0)+1,i[a.target.index]=(i[a.target.index]||0)+1;for(A=0,o=new Array(l);A<l;++A)a=t[A],o[A]=i[a.source.index]/(i[a.source.index]+i[a.target.index]);e=new Array(l),d(),n=new Array(l),f()}}function d(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+a(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=[]),u.initialize=function(t,e){r=t,A=e,h()},u.links=function(e){return arguments.length?(t=e,h(),u):t},u.id=function(t){return arguments.length?(s=t,u):s},u.iterations=function(t){return arguments.length?(l=+t,u):l},u.strength=function(t){return arguments.length?(a="function"==typeof t?t:sk(+t),d(),u):a},u.distance=function(t){return arguments.length?(c="function"==typeof t?t:sk(+t),f(),u):c},u}mk.copy=function(){var t,e,n=new pk(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=vk(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]=vk(e));return n},mk.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return uk(this.cover(e,n),e,n,t)},mk.addAll=function(t){var e,n,r,i,o=t.length,A=new Array(o),s=new Array(o),a=1/0,c=1/0,l=-1/0,u=-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<a&&(a=r),r>l&&(l=r),i<c&&(c=i),i>u&&(u=i));if(a>l||c>u)return this;for(this.cover(a,c).cover(l,u),n=0;n<o;++n)uk(this,A[n],s[n],t[n]);return this},mk.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,a=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,a*=2,s){case 0:i=n+a,o=r+a;break;case 1:n=i-a,o=r+a;break;case 2:i=n+a,r=o-a;break;case 3:n=i-a,r=o-a}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},mk.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},mk.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]]},mk.find=function(t,e,n){var r,i,o,A,s,a,c,l=this._x0,u=this._y0,h=this._x1,d=this._y1,f=[],g=this._root;for(g&&f.push(new hk(g,l,u,h,d)),null==n?n=1/0:(l=t-n,u=e-n,h=t+n,d=e+n,n*=n);a=f.pop();)if(!(!(g=a.node)||(i=a.x0)>h||(o=a.y0)>d||(A=a.x1)<l||(s=a.y1)<u))if(g.length){var p=(i+A)/2,v=(o+s)/2;f.push(new hk(g[3],p,v,A,s),new hk(g[2],i,v,p,s),new hk(g[1],p,o,A,v),new hk(g[0],i,o,p,v)),(c=(e>=v)<<1|t>=p)&&(a=f[f.length-1],f[f.length-1]=f[f.length-1-c],f[f.length-1-c]=a)}else{var m=t-+this._x.call(null,g.data),y=e-+this._y.call(null,g.data),w=m*m+y*y;if(w<n){var b=Math.sqrt(n=w);l=t-b,u=e-b,h=t+b,d=e+b,r=g.data}}return r},mk.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,a,c,l,u,h,d=this._root,f=this._x0,g=this._y0,p=this._x1,v=this._y1;if(!d)return this;if(d.length)for(;;){if((c=o>=(s=(f+p)/2))?f=s:p=s,(l=A>=(a=(g+v)/2))?g=a:v=a,e=d,!(d=d[u=l<<1|c]))return this;if(!d.length)break;(e[u+1&3]||e[u+2&3]||e[u+3&3])&&(n=e,h=u)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):e?(i?e[u]=i:delete e[u],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(n?n[h]=d:this._root=d),this):(this._root=i,this)},mk.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},mk.root=function(){return this._root},mk.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},mk.visit=function(t){var e,n,r,i,o,A,s=[],a=this._root;for(a&&s.push(new hk(a,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(a=e.node,r=e.x0,i=e.y0,o=e.x1,A=e.y1)&&a.length){var c=(r+o)/2,l=(i+A)/2;(n=a[3])&&s.push(new hk(n,c,l,o,A)),(n=a[2])&&s.push(new hk(n,r,l,c,A)),(n=a[1])&&s.push(new hk(n,c,i,o,l)),(n=a[0])&&s.push(new hk(n,r,i,c,l))}return this},mk.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new hk(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,a=e.x1,c=e.y1,l=(A+a)/2,u=(s+c)/2;(o=i[0])&&n.push(new hk(o,A,s,l,u)),(o=i[1])&&n.push(new hk(o,l,s,a,u)),(o=i[2])&&n.push(new hk(o,A,u,l,c)),(o=i[3])&&n.push(new hk(o,l,u,a,c))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},mk.x=function(t){return arguments.length?(this._x=t,this):this._x},mk.y=function(t){return arguments.length?(this._y=t,this):this._y};const Mk=(t,e)=>t[e];function Fk(){function t(t){return()=>t}let e,n=t=>t.cluster,r=t(1),i=t(-1),o=t(100),A=t(.1),s=[0,0],a=[],c={},l=[],u=100,h=100,d={none:{x:0,y:0}},f=[],g="force",p=!0,v=.1;function m(t){if(!p)return m;e.tick(),w();for(let e,r=0,i=a.length,o=t*v;r<i;++r)e=a[r],e.vx||(e.vx=0),e.vy||(e.vy=0),e.vx+=(d[n(e._original)].x-e.x)*o,e.vy+=(d[n(e._original)].y-e.y)*o}function y(){a&&function(){if(!a||!a.length)return;const t=a[0];if(void 0===n(t._original))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInABox.groupBy('clusterAttr') before calling .links()");const s=function(){const t=[],e=[],i={};let o=[],A={},s=[];return A=function(t){const e={};return t.forEach(t=>{const r=n(t._original);e[r]||(e[r]={count:0,sumforceNodeSize:0})}),t.forEach(t=>{const i=n(t._original),o=r(t._original),A=e[i];A.count=A.count+1,A.sumforceNodeSize=A.sumforceNodeSize+Math.PI*(o*o)*1.3,e[i]=A}),e}(a),s=function(t){const e={},r=[];t.forEach(t=>{const r=function(t){const e=Mk(t,"source"),r=Mk(t,"target"),i=n(c[e]._original),o=n(c[r]._original);return i<=o?`${i}~${o}`:`${o}~${i}`}(t);let i=0;void 0!==e[r]&&(i=e[r]),i+=1,e[r]=i});return Object.entries(e).forEach(([t,e])=>{const n=t.split("~")[0],i=t.split("~")[1];void 0!==n&&void 0!==i&&r.push({source:n,target:i,count:e})}),r}(l),o=Object.keys(A),o.forEach((e,n)=>{const r=A[e];t.push({id:e,size:r.count,r:Math.sqrt(r.sumforceNodeSize/Math.PI)}),i[e]=n}),s.forEach(t=>{const n=Mk(t,"source"),r=Mk(t,"target"),o=i[n],A=i[r];void 0!==o&&void 0!==A&&e.push({source:o,target:A,count:t.count})}),{nodes:t,links:e}}();e=Ak(s.nodes).force("x",ak(u).strength(.1)).force("y",ck(h).strength(.1)).force("collide",bk(t=>t.r).iterations(4)).force("charge",Bk().strength(i)).force("links",Ck(s.nodes.length?s.links:[]).distance(o).strength(A)),f=e.nodes(),w()}()}function w(){return d={none:{x:0,y:0}},f.forEach(t=>{d[t.id]={x:t.x-s[0],y:t.y-s[1]}}),d}return m.initialize=t=>{a=t,y()},m.template=function(t){return arguments.length?(g=t,y(),m):g},m.groupBy=function(t){return arguments.length?"string"==typeof t?(n=e=>e[t],m):(n=t,m):n},m.enableGrouping=function(t){return arguments.length?(p=t,m):p},m.strength=function(t){return arguments.length?(v=t,m):v},m.centerX=function(t){return arguments.length?(u=t,m):u},m.centerY=function(t){return arguments.length?(h=t,m):h},m.nodes=function(t){return arguments.length?(function(t){c={},t.forEach(t=>{c[t.id]=t})}(t||[]),a=t||[],m):a},m.links=function(t){return arguments.length?(l=t||[],y(),m):l},m.forceNodeSize=function(e){return arguments.length?(r="function"==typeof e?e:t(+e),y(),m):r},m.nodeSize=m.forceNodeSize,m.forceCharge=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),y(),m):i},m.forceLinkDistance=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),y(),m):o},m.forceLinkStrength=function(e){return arguments.length?(A="function"==typeof e?e:t(+e),y(),m):A},m.offset=function(t){return arguments.length?(s=t,m):s},m.getFocis=w,m}var kk={}.toString,Sk=function(t,e){return kk.call(t)==="[object "+e+"]"},Qk=function(t){if(!function(t){return"object"==typeof t&&null!==t}(t)||!Sk(t,"Object"))return!1;if(null===Object.getPrototypeOf(t))return!0;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e};function Uk(t,e){if(Object.hasOwn)return Object.hasOwn(t,e);if(null==t)throw new TypeError("Cannot convert undefined or null to object");return Object.prototype.hasOwnProperty.call(Object(t),e)}function Nk(t,e,n,r){for(var i in n=n||0,r=r||5,e)if(Uk(e,i)){var o=e[i];null!==o&&Qk(o)?(Qk(t[i])||(t[i]={}),n<r?Nk(t[i],o,n+1,r):t[i]=e[i]):gM(o)?(t[i]=[],t[i]=t[i].concat(o)):void 0!==o&&(t[i]=o)}}const Tk={edgeId:"edge.id",manyBody:{strength:-30},preventOverlap:!1,nodeSize:10,nodeSpacing:0,x:!1,y:!1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10};class Ok extends xC{getDefaultOptions(){return Tk}mergeOptions(t,e){return 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)Nk(t,e[r]);return t}({},t,e)}constructor(t){super(t),this.id="d3-force",this.d3Nodes=[],this.d3Edges=[],this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}stop(){return this.simulation&&this.simulation.stop(),this}tick(t=1){var e,n;if(this.simulation){for(let e=0;e<t;e++)this.simulation.tick();this.syncPositionsFromD3(),null===(n=(e=this.options).onTick)||void 0===n||n.call(e,this)}return this}restart(t){return this.simulation&&(void 0!==t&&this.simulation.alpha(t),this.simulation.restart()),this}reheat(){return this.restart(1)}getAlpha(){var t,e;return null!==(e=null===(t=this.simulation)||void 0===t?void 0:t.alpha())&&void 0!==e?e:0}setAlpha(t){return this.simulation&&this.simulation.alpha(t),this}getForce(t){var e;return null===(e=this.simulation)||void 0===e?void 0:e.force(t)}force(t,e){return this.simulation&&this.simulation.force(t,e),this}nodes(){var t,e;return null!==(e=null===(t=this.simulation)||void 0===t?void 0:t.nodes())&&void 0!==e?e:[]}find(t,e,n){if(this.simulation)return this.simulation.find(t,e,n)}setFixedPosition(t,e){const n=this.d3Nodes.find(e=>e.id===t),r=this.model.node(t);if(!r||!n)return;const i=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<i.length&&("number"==typeof t||null===t)&&(r[i[e]]=t,n[i[e]]=t)}):i.forEach(t=>{delete r[t],delete n[t]})}parseOptions(t){const e=t;return void 0===e.iterations&&(e.link&&void 0===e.link.iterations&&(e.iterations=e.link.iterations),e.collide&&void 0===e.collide.iterations&&(e.iterations=e.collide.iterations)),e}layout(){var t;return mx(this,0,void 0,function*(){const e=this.parseOptions(this.options||{});this.createD3Copies();const n=this.setSimulation(e);return n.nodes(this.d3Nodes),null===(t=n.force("link"))||void 0===t||t.links(this.d3Edges),new Promise(t=>{n.on("end",()=>{this.syncPositionsFromD3(),t()})})})}createD3Copies(){this.d3Nodes=[],this.d3Edges=[],this.model.forEachNode(t=>{this.d3Nodes.push(Object.assign({},t))}),this.model.forEachEdge(t=>{this.d3Edges.push(Object.assign({},t))})}syncPositionsFromD3(){this.d3Nodes.forEach(t=>{const e=this.model.node(t.id);e&&(e.x=t.x,e.y=t.y,void 0!==t.z&&(e.z=t.z),void 0!==t.fx&&(e.fx=t.fx),void 0!==t.fy&&(e.fy=t.fy),void 0!==t.fz&&(e.fz=t.fz),void 0!==t.vx&&(e.vx=t.vx),void 0!==t.vy&&(e.vy=t.vy),void 0!==t.vz&&(e.vz=t.vz))})}initSimulation(){return Ak()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",()=>{var e;this.syncPositionsFromD3(),null===(e=t.onTick)||void 0===e||e.call(t,this)})),Ik(e,this.config.simulationAttrs.map(e=>[e,t[e]])),this.setupForces(e,t),e}setupForces(t,e){this.setupLinkForce(t,e),this.setupManyBodyForce(t,e),this.setupCenterForce(t,e),this.setupCollisionForce(t,e),this.setupXForce(t,e),this.setupYForce(t,e),this.setupRadialForce(t,e),this.setupClusterForce(t,e)}getCenterOptions(t){if(!1===t.center)return;const e=kF({width:t.width,height:t.height});return TF({},t.center||{},{x:e.width/2,y:e.height/2,strength:t.centerStrength})}setupCenterForce(t,e){const n=this.getCenterOptions(e);if(n){let e=t.force("center");e||(e=function(t,e){var n,r=1;function i(){var i,o,A=n.length,s=0,a=0;for(i=0;i<A;++i)s+=(o=n[i]).x,a+=o.y;for(s=(s/A-t)*r,a=(a/A-e)*r,i=0;i<A;++i)(o=n[i]).x-=s,o.y-=a}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}(n.x,n.y),t.force("center",e));const r=[];void 0!==n.x&&r.push(["x",n.x]),void 0!==n.y&&r.push(["y",n.y]),void 0!==n.strength&&r.push(["strength",n.strength]),Ik(e,r)}else t.force("center",null)}getManyBodyOptions(t){if(!1!==t.manyBody)return TF({},t.manyBody||{},{strength:t.nodeStrength?Vx(t.nodeStrength,["node"]):void 0,distanceMin:t.distanceMin,distanceMax:t.distanceMax,theta:t.theta})}setupManyBodyForce(t,e){const n=this.getManyBodyOptions(e);if(n){let e=t.force("charge");e||(e=Bk(),t.force("charge",e));const r=[];void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.distanceMin&&r.push(["distanceMin",n.distanceMin]),void 0!==n.distanceMax&&r.push(["distanceMax",n.distanceMax]),void 0!==n.theta&&r.push(["theta",n.theta]),Ik(e,r)}else t.force("charge",null)}getLinkOptions(t){if(!1!==t.link)return TF({},t.link||{},{id:t.edgeId?Vx(t.edgeId,["edge"]):void 0,distance:t.linkDistance?Vx(t.linkDistance,["edge"]):void 0,strength:t.edgeStrength?Vx(t.edgeStrength,["edge"]):void 0,iterations:t.edgeIterations})}setupLinkForce(t,e){const n=this.model.edges(),r=this.getLinkOptions(e);if(n.length>0&&r){let e=t.force("link");e||(e=Ck(),t.force("link",e));const n=[];void 0!==r.id&&n.push(["id",r.id]),void 0!==r.distance&&n.push(["distance",r.distance]),void 0!==r.strength&&n.push(["strength",r.strength]),void 0!==r.iterations&&n.push(["iterations",r.iterations]),Ik(e,n)}else t.force("link",null)}getCollisionOptions(t){if(!1===t.preventOverlap&&(!1===t.collide||void 0===t.collide))return;const e=Xx(t.nodeSize,t.nodeSpacing,Tk.nodeSize,Tk.nodeSpacing);return TF({},t.collide||{},{radius:t.collide&&t.collide.radius||(t=>Math.max(...e(t._original))/2),strength:t.collideStrength,iterations:t.collideIterations})}setupCollisionForce(t,e){const n=this.getCollisionOptions(e);if(n){let e=t.force("collide");e||(e=bk(),t.force("collide",e));const r=[];void 0!==n.radius&&r.push(["radius",n.radius]),void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.iterations&&r.push(["iterations",n.iterations]),Ik(e,r)}else t.force("collide",null)}getXForceOptions(t){var e;if(!1===t.x)return;const n=this.getCenterOptions(t);return TF({},t.x||{},{x:null!==(e=t.forceXPosition)&&void 0!==e?e:n&&n.x,strength:t.forceXStrength})}setupXForce(t,e){const n=this.getXForceOptions(e);if(n){let e=t.force("x");e||(e=ak(),t.force("x",e));const r=[];void 0!==n.x&&r.push(["x",n.x]),void 0!==n.strength&&r.push(["strength",n.strength]),Ik(e,r)}else t.force("x",null)}getYForceOptions(t){var e;if(!1===t.y)return;const n=this.getCenterOptions(t);return TF({},t.y||{},{y:null!==(e=t.forceYPosition)&&void 0!==e?e:n&&n.y,strength:t.forceYStrength})}setupYForce(t,e){const n=this.getYForceOptions(e);if(n){let e=t.force("y");e||(e=ck(),t.force("y",e));const r=[];void 0!==n.y&&r.push(["y",n.y]),void 0!==n.strength&&r.push(["strength",n.strength]),Ik(e,r)}else t.force("y",null)}getRadialOptions(t){var e,n,r;if(void 0!==t.radial||void 0!==t.radialStrength||void 0!==t.radialRadius||void 0!==t.radialX||void 0!==t.radialY){const i=this.getCenterOptions(t);return TF({},t.radial||{},{strength:t.radialStrength,radius:null!==(e=t.radialRadius)&&void 0!==e?e:100,x:null!==(n=t.radialX)&&void 0!==n?n:i&&i.x,y:null!==(r=t.radialY)&&void 0!==r?r:i&&i.y})}}setupRadialForce(t,e){const n=this.getRadialOptions(e);if(n){let e=t.force("radial");e||(e=function(t,e,n){var r,i,o,A=sk(.1);function s(t){for(var A=0,s=r.length;A<s;++A){var a=r[A],c=a.x-e||1e-6,l=a.y-n||1e-6,u=Math.sqrt(c*c+l*l),h=(o[A]-u)*i[A]*t/u;a.vx+=c*h,a.vy+=l*h}}function a(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+A(r[e],e,r)}}return"function"!=typeof t&&(t=sk(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,a()},s.strength=function(t){return arguments.length?(A="function"==typeof t?t:sk(+t),a(),s):A},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:sk(+e),a(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}(n.radius||100,n.x,n.y),t.force("radial",e));const r=[];void 0!==n.radius&&r.push(["radius",n.radius]),void 0!==n.strength&&r.push(["strength",n.strength]),void 0!==n.x&&r.push(["x",n.x]),void 0!==n.y&&r.push(["y",n.y]),Ik(e,r)}else t.force("radial",null)}setupClusterForce(t,e){const{clustering:n}=e;if(n){const{clusterFociStrength:n,clusterEdgeDistance:r,clusterEdgeStrength:i,clusterNodeStrength:o,clusterNodeSize:A,clusterBy:s}=e,a=this.getCenterOptions(e);let c=t.force("group");c||(c=Fk(),t.force("group",c)),Ik(c,[["centerX",a&&a.x],["centerY",a&&a.y],["template","force"],["strength",n],["groupBy",s?Vx(s,["node"]):void 0],["nodes",this.model.nodes()],["links",this.model.edges()],["forceLinkDistance",r],["forceLinkStrength",i],["forceCharge",o],["forceNodeSize",A]])}else t.force("group",null)}}const Ik=(t,e)=>e.reduce((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e,t);function Lk(t){return function(){return t}}function Pk(t){var e,n,r,i=Lk(.1);function o(t){for(var i,o=0,A=e.length;o<A;++o)(i=e[o]).vz+=(r[o]-i.z)*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=Lk(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Lk(+t),A(),o):i},o.z=function(e){return arguments.length?(t="function"==typeof e?e:Lk(+e),A(),o):t},o}function Dk(t){var e,n,r,i=Lk(.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=Lk(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Lk(+t),A(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Lk(+e),A(),o):t},o}function Rk(t){var e,n,r,i=Lk(.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=Lk(null==t?0:+t)),o.initialize=function(t){e=t,A()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Lk(+t),A(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Lk(+e),A(),o):t},o}function Hk(t,e,n,r){var i,o,A,s,a=Lk(.1);function c(t){for(var a=0,c=i.length;a<c;++a){var l=i[a],u=l.x-e||1e-6,h=(l.y||0)-n||1e-6,d=(l.z||0)-r||1e-6,f=Math.sqrt(u*u+h*h+d*d),g=(s[a]-f)*A[a]*t/f;l.vx+=u*g,o>1&&(l.vy+=h*g),o>2&&(l.vz+=d*g)}}function l(){if(i){var e,n=i.length;for(A=new Array(n),s=new Array(n),e=0;e<n;++e)s[e]=+t(i[e],e,i),A[e]=isNaN(s[e])?0:+a(i[e],e,i)}}return"function"!=typeof t&&(t=Lk(+t)),null==e&&(e=0),null==n&&(n=0),null==r&&(r=0),c.initialize=function(t,...e){i=t,o=e.find(t=>[1,2,3].includes(t))||2,l()},c.strength=function(t){return arguments.length?(a="function"==typeof t?t:Lk(+t),l(),c):a},c.radius=function(e){return arguments.length?(t="function"==typeof e?e:Lk(+e),l(),c):t},c.x=function(t){return arguments.length?(e=+t,c):e},c.y=function(t){return arguments.length?(n=+t,c):n},c.z=function(t){return arguments.length?(r=+t,c):r},c}function _k(t){return 1e-6*(t()-.5)}function Gk(t,e,n){if(isNaN(e))return t;var r,i,o,A,s,a,c=t._root,l={data:n},u=t._x0,h=t._x1;if(!c)return t._root=l,t;for(;c.length;)if((A=e>=(i=(u+h)/2))?u=i:h=i,r=c,!(c=c[s=+A]))return r[s]=l,t;if(e===(o=+t._x.call(null,c.data)))return l.next=c,r?r[s]=l:t._root=l,t;do{r=r?r[s]=new Array(2):t._root=new Array(2),(A=e>=(i=(u+h)/2))?u=i:h=i}while((s=+A)===(a=+(o>=i)));return r[a]=c,r[s]=l,t}function Kk(t,e,n){this.node=t,this.x0=e,this.x1=n}function jk(t){return t[0]}function zk(t,e){var n=new Vk(null==e?jk:e,NaN,NaN);return null==t?n:n.addAll(t)}function Vk(t,e,n){this._x=t,this._x0=e,this._x1=n,this._root=void 0}function Wk(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Yk=zk.prototype=Vk.prototype;function Xk(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,A,s,a,c,l,u,h,d,f,g,p,v=t._root,m={data:i},y=t._x0,w=t._y0,b=t._z0,B=t._x1,E=t._y1,x=t._z1;if(!v)return t._root=m,t;for(;v.length;)if((h=e>=(A=(y+B)/2))?y=A:B=A,(d=n>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(b+x)/2))?b=a:x=a,o=v,!(v=v[g=f<<2|d<<1|h]))return o[g]=m,t;if(c=+t._x.call(null,v.data),l=+t._y.call(null,v.data),u=+t._z.call(null,v.data),e===c&&n===l&&r===u)return m.next=v,o?o[g]=m:t._root=m,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(h=e>=(A=(y+B)/2))?y=A:B=A,(d=n>=(s=(w+E)/2))?w=s:E=s,(f=r>=(a=(b+x)/2))?b=a:x=a}while((g=f<<2|d<<1|h)==(p=(u>=a)<<2|(l>=s)<<1|c>=A));return o[p]=v,o[g]=m,t}function qk(t,e,n,r,i,o,A){this.node=t,this.x0=e,this.y0=n,this.z0=r,this.x1=i,this.y1=o,this.z1=A}Yk.copy=function(){var t,e,n=new Vk(this._x,this._x0,this._x1),r=this._root;if(!r)return n;if(!r.length)return n._root=Wk(r),n;for(t=[{source:r,target:n._root=new Array(2)}];r=t.pop();)for(var i=0;i<2;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(2)}):r.target[i]=Wk(e));return n},Yk.add=function(t){const e=+this._x.call(null,t);return Gk(this.cover(e),e,t)},Yk.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e);let r=1/0,i=-1/0;for(let o,A=0;A<e;++A)isNaN(o=+this._x.call(null,t[A]))||(n[A]=o,o<r&&(r=o),o>i&&(i=o));if(r>i)return this;this.cover(r).cover(i);for(let r=0;r<e;++r)Gk(this,n[r],t[r]);return this},Yk.cover=function(t){if(isNaN(t=+t))return this;var e=this._x0,n=this._x1;if(isNaN(e))n=(e=Math.floor(t))+1;else{for(var r,i,o=n-e||1,A=this._root;e>t||t>=n;)switch(i=+(t<e),(r=new Array(2))[i]=A,A=r,o*=2,i){case 0:n=e+o;break;case 1:e=n-o}this._root&&this._root.length&&(this._root=A)}return this._x0=e,this._x1=n,this},Yk.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},Yk.extent=function(t){return arguments.length?this.cover(+t[0][0]).cover(+t[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]},Yk.find=function(t,e){var n,r,i,o,A,s=this._x0,a=this._x1,c=[],l=this._root;for(l&&c.push(new Kk(l,s,a)),null==e?e=1/0:(s=t-e,a=t+e);o=c.pop();)if(!(!(l=o.node)||(r=o.x0)>a||(i=o.x1)<s))if(l.length){var u=(r+i)/2;c.push(new Kk(l[1],u,i),new Kk(l[0],r,u)),(A=+(t>=u))&&(o=c[c.length-1],c[c.length-1]=c[c.length-1-A],c[c.length-1-A]=o)}else{var h=Math.abs(t-+this._x.call(null,l.data));h<e&&(e=h,s=t-h,a=t+h,n=l.data)}return n},Yk.remove=function(t){if(isNaN(o=+this._x.call(null,t)))return this;var e,n,r,i,o,A,s,a,c,l=this._root,u=this._x0,h=this._x1;if(!l)return this;if(l.length)for(;;){if((s=o>=(A=(u+h)/2))?u=A:h=A,e=l,!(l=l[a=+s]))return this;if(!l.length)break;e[a+1&1]&&(n=e,c=a)}for(;l.data!==t;)if(r=l,!(l=l.next))return this;return(i=l.next)&&delete l.next,r?(i?r.next=i:delete r.next,this):e?(i?e[a]=i:delete e[a],(l=e[0]||e[1])&&l===(e[1]||e[0])&&!l.length&&(n?n[c]=l:this._root=l),this):(this._root=i,this)},Yk.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Yk.root=function(){return this._root},Yk.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},Yk.visit=function(t){var e,n,r,i,o=[],A=this._root;for(A&&o.push(new Kk(A,this._x0,this._x1));e=o.pop();)if(!t(A=e.node,r=e.x0,i=e.x1)&&A.length){var s=(r+i)/2;(n=A[1])&&o.push(new Kk(n,s,i)),(n=A[0])&&o.push(new Kk(n,r,s))}return this},Yk.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Kk(this._root,this._x0,this._x1));e=n.pop();){var i=e.node;if(i.length){var o,A=e.x0,s=e.x1,a=(A+s)/2;(o=i[0])&&n.push(new Kk(o,A,a)),(o=i[1])&&n.push(new Kk(o,a,s))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.x1);return this},Yk.x=function(t){return arguments.length?(this._x=t,this):this._x};const $k=(t,e,n,r,i,o)=>Math.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function Zk(t){return t[0]}function Jk(t){return t[1]}function tS(t){return t[2]}function eS(t,e,n,r){var i=new nS(null==e?Zk:e,null==n?Jk:n,null==r?tS:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function nS(t,e,n,r,i,o,A,s,a){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=A,this._y1=s,this._z1=a,this._root=void 0}function rS(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var iS=eS.prototype=nS.prototype;function oS(t){return t.x+t.vx}function AS(t){return t.y+t.vy}function sS(t){return t.z+t.vz}function aS(t){var e,n,r,i,o=1,A=1;function s(){for(var t,s,c,l,u,h,d,f,g=e.length,p=0;p<A;++p)for(s=(1===n?zk(e,oS):2===n?gk(e,oS,AS):3===n?eS(e,oS,AS,sS):null).visitAfter(a),t=0;t<g;++t)c=e[t],d=r[c.index],f=d*d,l=c.x+c.vx,n>1&&(u=c.y+c.vy),n>2&&(h=c.z+c.vz),s.visit(v);function v(t,e,r,A,s,a,g){var p=[e,r,A,s,a,g],v=p[0],m=p[1],y=p[2],w=p[n],b=p[n+1],B=p[n+2],E=t.data,x=t.r,C=d+x;if(!E)return v>l+C||w<l-C||n>1&&(m>u+C||b<u-C)||n>2&&(y>h+C||B<h-C);if(E.index>c.index){var M=l-E.x-E.vx,F=n>1?u-E.y-E.vy:0,k=n>2?h-E.z-E.vz:0,S=M*M+F*F+k*k;S<C*C&&(0===M&&(S+=(M=_k(i))*M),n>1&&0===F&&(S+=(F=_k(i))*F),n>2&&0===k&&(S+=(k=_k(i))*k),S=(C-(S=Math.sqrt(S)))/S*o,c.vx+=(M*=S)*(C=(x*=x)/(f+x)),n>1&&(c.vy+=(F*=S)*C),n>2&&(c.vz+=(k*=S)*C),E.vx-=M*(C=1-C),n>1&&(E.vy-=F*C),n>2&&(E.vz-=k*C))}}}function a(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<Math.pow(2,n);++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function c(){if(e){var n,i,o=e.length;for(r=new Array(o),n=0;n<o;++n)i=e[n],r[i.index]=+t(i,n,e)}}return"function"!=typeof t&&(t=Lk(null==t?1:+t)),s.initialize=function(t,...r){e=t,i=r.find(t=>"function"==typeof t)||Math.random,n=r.find(t=>[1,2,3].includes(t))||2,c()},s.iterations=function(t){return arguments.length?(A=+t,s):A},s.strength=function(t){return arguments.length?(o=+t,s):o},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:Lk(+e),c(),s):t},s}function cS(t,e,n){var r,i=1;function o(){var o,A,s=r.length,a=0,c=0,l=0;for(o=0;o<s;++o)a+=(A=r[o]).x||0,c+=A.y||0,l+=A.z||0;for(a=(a/s-t)*i,c=(c/s-e)*i,l=(l/s-n)*i,o=0;o<s;++o)A=r[o],a&&(A.x-=a),c&&(A.y-=c),l&&(A.z-=l)}return null==t&&(t=0),null==e&&(e=0),null==n&&(n=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.z=function(t){return arguments.length?(n=+t,o):n},o.strength=function(t){return arguments.length?(i=+t,o):i},o}iS.copy=function(){var t,e,n=new nS(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=rS(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]=rS(e));return n},iS.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Xk(this.cover(e,n,r),e,n,r,t)},iS.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,a=-1/0,c=-1/0,l=-1/0;for(let u,h,d,f,g=0;g<e;++g)isNaN(h=+this._x.call(null,u=t[g]))||isNaN(d=+this._y.call(null,u))||isNaN(f=+this._z.call(null,u))||(n[g]=h,r[g]=d,i[g]=f,h<o&&(o=h),h>a&&(a=h),d<A&&(A=d),d>c&&(c=d),f<s&&(s=f),f>l&&(l=f));if(o>a||A>c||s>l)return this;this.cover(o,A,s).cover(a,c,l);for(let o=0;o<e;++o)Xk(this,n[o],r[o],i[o],t[o]);return this},iS.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,a=this._z1;if(isNaN(r))A=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,a=(o=Math.floor(n))+1;else{for(var c,l,u=A-r||1,h=this._root;r>t||t>=A||i>e||e>=s||o>n||n>=a;)switch(l=(n<o)<<2|(e<i)<<1|t<r,(c=new Array(8))[l]=h,h=c,u*=2,l){case 0:A=r+u,s=i+u,a=o+u;break;case 1:r=A-u,s=i+u,a=o+u;break;case 2:A=r+u,i=s-u,a=o+u;break;case 3:r=A-u,i=s-u,a=o+u;break;case 4:A=r+u,s=i+u,o=a-u;break;case 5:r=A-u,s=i+u,o=a-u;break;case 6:A=r+u,i=s-u,o=a-u;break;case 7:r=A-u,i=s-u,o=a-u}this._root&&this._root.length&&(this._root=h)}return this._x0=r,this._y0=i,this._z0=o,this._x1=A,this._y1=s,this._z1=a,this},iS.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)}),t},iS.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]]},iS.find=function(t,e,n,r){var i,o,A,s,a,c,l,u,h,d=this._x0,f=this._y0,g=this._z0,p=this._x1,v=this._y1,m=this._z1,y=[],w=this._root;for(w&&y.push(new qk(w,d,f,g,p,v,m)),null==r?r=1/0:(d=t-r,f=e-r,g=n-r,p=t+r,v=e+r,m=n+r,r*=r);u=y.pop();)if(!(!(w=u.node)||(o=u.x0)>p||(A=u.y0)>v||(s=u.z0)>m||(a=u.x1)<d||(c=u.y1)<f||(l=u.z1)<g))if(w.length){var b=(o+a)/2,B=(A+c)/2,E=(s+l)/2;y.push(new qk(w[7],b,B,E,a,c,l),new qk(w[6],o,B,E,b,c,l),new qk(w[5],b,A,E,a,B,l),new qk(w[4],o,A,E,b,B,l),new qk(w[3],b,B,s,a,c,E),new qk(w[2],o,B,s,b,c,E),new qk(w[1],b,A,s,a,B,E),new qk(w[0],o,A,s,b,B,E)),(h=(n>=E)<<2|(e>=B)<<1|t>=b)&&(u=y[y.length-1],y[y.length-1]=y[y.length-1-h],y[y.length-1-h]=u)}else{var x=t-+this._x.call(null,w.data),C=e-+this._y.call(null,w.data),M=n-+this._z.call(null,w.data),F=x*x+C*C+M*M;if(F<r){var k=Math.sqrt(r=F);d=t-k,f=e-k,g=n-k,p=t+k,v=e+k,m=n+k,i=w.data}}return i},iS.findAllWithinRadius=function(t,e,n,r){const i=[],o=t-r,A=e-r,s=n-r,a=t+r,c=e+r,l=n+r;return this.visit((u,h,d,f,g,p,v)=>{if(!u.length)do{const o=u.data;$k(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(u=u.next);return h>a||d>c||f>l||g<o||p<A||v<s}),i},iS.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,a,c,l,u,h,d,f,g,p=this._root,v=this._x0,m=this._y0,y=this._z0,w=this._x1,b=this._y1,B=this._z1;if(!p)return this;if(p.length)for(;;){if((u=o>=(a=(v+w)/2))?v=a:w=a,(h=A>=(c=(m+b)/2))?m=c:b=c,(d=s>=(l=(y+B)/2))?y=l:B=l,e=p,!(p=p[f=d<<2|h<<1|u]))return this;if(!p.length)break;(e[f+1&7]||e[f+2&7]||e[f+3&7]||e[f+4&7]||e[f+5&7]||e[f+6&7]||e[f+7&7])&&(n=e,g=f)}for(;p.data!==t;)if(r=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,r?(i?r.next=i:delete r.next,this):e?(i?e[f]=i:delete e[f],(p=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&p===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!p.length&&(n?n[g]=p:this._root=p),this):(this._root=i,this)},iS.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},iS.root=function(){return this._root},iS.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t}while(e=e.next)}),t},iS.visit=function(t){var e,n,r,i,o,A,s,a,c=[],l=this._root;for(l&&c.push(new qk(l,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=c.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.z0,A=e.x1,s=e.y1,a=e.z1)&&l.length){var u=(r+A)/2,h=(i+s)/2,d=(o+a)/2;(n=l[7])&&c.push(new qk(n,u,h,d,A,s,a)),(n=l[6])&&c.push(new qk(n,r,h,d,u,s,a)),(n=l[5])&&c.push(new qk(n,u,i,d,A,h,a)),(n=l[4])&&c.push(new qk(n,r,i,d,u,h,a)),(n=l[3])&&c.push(new qk(n,u,h,o,A,s,d)),(n=l[2])&&c.push(new qk(n,r,h,o,u,s,d)),(n=l[1])&&c.push(new qk(n,u,i,o,A,h,d)),(n=l[0])&&c.push(new qk(n,r,i,o,u,h,d))}return this},iS.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new qk(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,a=e.z0,c=e.x1,l=e.y1,u=e.z1,h=(A+c)/2,d=(s+l)/2,f=(a+u)/2;(o=i[0])&&n.push(new qk(o,A,s,a,h,d,f)),(o=i[1])&&n.push(new qk(o,h,s,a,c,d,f)),(o=i[2])&&n.push(new qk(o,A,d,a,h,l,f)),(o=i[3])&&n.push(new qk(o,h,d,a,c,l,f)),(o=i[4])&&n.push(new qk(o,A,s,f,h,d,u)),(o=i[5])&&n.push(new qk(o,h,s,f,c,d,u)),(o=i[6])&&n.push(new qk(o,A,d,f,h,l,u)),(o=i[7])&&n.push(new qk(o,h,d,f,c,l,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},iS.x=function(t){return arguments.length?(this._x=t,this):this._x},iS.y=function(t){return arguments.length?(this._y=t,this):this._y},iS.z=function(t){return arguments.length?(this._z=t,this):this._z};const lS=4294967296;function uS(t){return t.x}function hS(t){return t.y}function dS(t){return t.z}var fS=Math.PI*(3-Math.sqrt(5)),gS=20*Math.PI/(9+Math.sqrt(221));function pS(t,e){e=e||2;var n,r=Math.min(3,Math.max(1,Math.round(e))),i=1,o=.001,A=1-Math.pow(o,1/300),s=0,a=.6,c=new Map,l=YF(d),u=JF("tick","end"),h=function(){let t=1;return()=>(t=(1664525*t+1013904223)%lS)/lS}();function d(){f(),u.call("tick",n),i<o&&(l.stop(),u.call("end",n))}function f(e){var o,l,u=t.length;void 0===e&&(e=1);for(var h=0;h<e;++h)for(i+=(s-i)*A,c.forEach(function(t){t(i)}),o=0;o<u;++o)null==(l=t[o]).fx?l.x+=l.vx*=a:(l.x=l.fx,l.vx=0),r>1&&(null==l.fy?l.y+=l.vy*=a:(l.y=l.fy,l.vy=0)),r>2&&(null==l.fz?l.z+=l.vz*=a:(l.z=l.fz,l.vz=0));return n}function g(){for(var e,n=0,i=t.length;n<i;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),null!=e.fz&&(e.z=e.fz),isNaN(e.x)||r>1&&isNaN(e.y)||r>2&&isNaN(e.z)){var o=10*(r>2?Math.cbrt(.5+n):r>1?Math.sqrt(.5+n):n),A=n*fS,s=n*gS;1===r?e.x=o:2===r?(e.x=o*Math.cos(A),e.y=o*Math.sin(A)):(e.x=o*Math.sin(A)*Math.cos(s),e.y=o*Math.cos(A),e.z=o*Math.sin(A)*Math.sin(s))}(isNaN(e.vx)||r>1&&isNaN(e.vy)||r>2&&isNaN(e.vz))&&(e.vx=0,r>1&&(e.vy=0),r>2&&(e.vz=0))}}function p(e){return e.initialize&&e.initialize(t,h,r),e}return null==t&&(t=[]),g(),n={tick:f,restart:function(){return l.restart(d),n},stop:function(){return l.stop(),n},numDimensions:function(t){return arguments.length?(r=Math.min(3,Math.max(1,Math.round(t))),c.forEach(p),n):r},nodes:function(e){return arguments.length?(t=e,g(),c.forEach(p),n):t},alpha:function(t){return arguments.length?(i=+t,n):i},alphaMin:function(t){return arguments.length?(o=+t,n):o},alphaDecay:function(t){return arguments.length?(A=+t,n):+A},alphaTarget:function(t){return arguments.length?(s=+t,n):s},velocityDecay:function(t){return arguments.length?(a=1-t,n):1-a},randomSource:function(t){return arguments.length?(h=t,c.forEach(p),n):h},force:function(t,e){return arguments.length>1?(null==e?c.delete(t):c.set(t,p(e)),n):c.get(t)},find:function(){var e,n,i,o,A,s,a=Array.prototype.slice.call(arguments),c=a.shift()||0,l=(r>1?a.shift():null)||0,u=(r>2?a.shift():null)||0,h=a.shift()||1/0,d=0,f=t.length;for(h*=h,d=0;d<f;++d)(o=(e=c-(A=t[d]).x)*e+(n=l-(A.y||0))*n+(i=u-(A.z||0))*i)<h&&(s=A,h=o);return s},on:function(t,e){return arguments.length>1?(u.on(t,e),n):u.on(t)}}}function vS(){var t,e,n,r,i,o,A=Lk(-30),s=1,a=1/0,c=.81;function l(r){var o,A=t.length,s=(1===e?zk(t,uS):2===e?gk(t,uS,hS):3===e?eS(t,uS,hS,dS):null).visitAfter(h);for(i=r,o=0;o<A;++o)n=t[o],s.visit(d)}function u(){if(t){var e,n,r=t.length;for(o=new Array(r),e=0;e<r;++e)n=t[e],o[n.index]=+A(n,e,t)}}function h(t){var n,r,i,A,s,a,c=0,l=0,u=t.length;if(u){for(i=A=s=a=0;a<u;++a)(n=t[a])&&(r=Math.abs(n.value))&&(c+=n.value,l+=r,i+=r*(n.x||0),A+=r*(n.y||0),s+=r*(n.z||0));c*=Math.sqrt(4/u),t.x=i/l,e>1&&(t.y=A/l),e>2&&(t.z=s/l)}else{(n=t).x=n.data.x,e>1&&(n.y=n.data.y),e>2&&(n.z=n.data.z);do{c+=o[n.data.index]}while(n=n.next)}t.value=c}function d(t,A,l,u,h){if(!t.value)return!0;var d=[l,u,h][e-1],f=t.x-n.x,g=e>1?t.y-n.y:0,p=e>2?t.z-n.z:0,v=d-A,m=f*f+g*g+p*p;if(v*v/c<m)return m<a&&(0===f&&(m+=(f=_k(r))*f),e>1&&0===g&&(m+=(g=_k(r))*g),e>2&&0===p&&(m+=(p=_k(r))*p),m<s&&(m=Math.sqrt(s*m)),n.vx+=f*t.value*i/m,e>1&&(n.vy+=g*t.value*i/m),e>2&&(n.vz+=p*t.value*i/m)),!0;if(!(t.length||m>=a)){(t.data!==n||t.next)&&(0===f&&(m+=(f=_k(r))*f),e>1&&0===g&&(m+=(g=_k(r))*g),e>2&&0===p&&(m+=(p=_k(r))*p),m<s&&(m=Math.sqrt(s*m)));do{t.data!==n&&(v=o[t.data.index]*i/m,n.vx+=f*v,e>1&&(n.vy+=g*v),e>2&&(n.vz+=p*v))}while(t=t.next)}}return l.initialize=function(n,...i){t=n,r=i.find(t=>"function"==typeof t)||Math.random,e=i.find(t=>[1,2,3].includes(t))||2,u()},l.strength=function(t){return arguments.length?(A="function"==typeof t?t:Lk(+t),u(),l):A},l.distanceMin=function(t){return arguments.length?(s=t*t,l):Math.sqrt(s)},l.distanceMax=function(t){return arguments.length?(a=t*t,l):Math.sqrt(a)},l.theta=function(t){return arguments.length?(c=t*t,l):Math.sqrt(c)},l}function mS(t){return t.index}function yS(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function wS(t){var e,n,r,i,o,A,s,a=mS,c=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},l=Lk(30),u=1;function h(r){for(var o=0,a=t.length;o<u;++o)for(var c,l,h,d,f,g=0,p=0,v=0,m=0;g<a;++g)l=(c=t[g]).source,p=(h=c.target).x+h.vx-l.x-l.vx||_k(s),i>1&&(v=h.y+h.vy-l.y-l.vy||_k(s)),i>2&&(m=h.z+h.vz-l.z-l.vz||_k(s)),p*=d=((d=Math.sqrt(p*p+v*v+m*m))-n[g])/d*r*e[g],v*=d,m*=d,h.vx-=p*(f=A[g]),i>1&&(h.vy-=v*f),i>2&&(h.vz-=m*f),l.vx+=p*(f=1-f),i>1&&(l.vy+=v*f),i>2&&(l.vz+=m*f)}function d(){if(r){var i,s,c=r.length,l=t.length,u=new Map(r.map((t,e)=>[a(t,e,r),t]));for(i=0,o=new Array(c);i<l;++i)(s=t[i]).index=i,"object"!=typeof s.source&&(s.source=yS(u,s.source)),"object"!=typeof s.target&&(s.target=yS(u,s.target)),o[s.source.index]=(o[s.source.index]||0)+1,o[s.target.index]=(o[s.target.index]||0)+1;for(i=0,A=new Array(l);i<l;++i)s=t[i],A[i]=o[s.source.index]/(o[s.source.index]+o[s.target.index]);e=new Array(l),f(),n=new Array(l),g()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+c(t[n],n,t)}function g(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+l(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,...e){r=t,s=e.find(t=>"function"==typeof t)||Math.random,i=e.find(t=>[1,2,3].includes(t))||2,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(a=t,h):a},h.iterations=function(t){return arguments.length?(u=+t,h):u},h.strength=function(t){return arguments.length?(c="function"==typeof t?t:Lk(+t),f(),h):c},h.distance=function(t){return arguments.length?(l="function"==typeof t?t:Lk(+t),g(),h):l},h}var bS,BS,ES,xS,CS,MS,FS,kS,SS,QS,US,NS,TS,OS,IS,LS,PS,DS,RS,HS,_S,GS,KS,jS,zS,VS,WS,YS,XS,qS,$S,ZS,JS,tQ,eQ,nQ,rQ,iQ,oQ,AQ,sQ,aQ,cQ,lQ,uQ,hQ,dQ,fQ,gQ,pQ,vQ,mQ,yQ,wQ,bQ,BQ,EQ,xQ,CQ,MQ,FQ,kQ,SQ,QQ,UQ,NQ,TQ,OQ,IQ,LQ,PQ,DQ,RQ,HQ,_Q,GQ,KQ,jQ,zQ,VQ,WQ,YQ,XQ,qQ,$Q,ZQ,JQ,tU,eU,nU,rU,iU,oU,AU,sU,aU,cU,lU,uU,hU,dU,fU,gU,pU,vU,mU,yU,wU,bU="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function BU(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function EU(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var n=function t(){var n=!1;try{n=this instanceof t}catch{}return n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})}),n}function xU(){if(xS)return ES;return xS=1,ES=function(t,e){return t===e||t!=t&&e!=e}}function CU(){if(MS)return CS;MS=1;var t=xU();return CS=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},CS}function MU(){if(LS)return IS;LS=1;var t=BS?bS:(BS=1,bS=function(){this.__data__=[],this.size=0}),e=function(){if(kS)return FS;kS=1;var t=CU(),e=Array.prototype.splice;return FS=function(n){var r=this.__data__,i=t(r,n);return!(i<0||(i==r.length-1?r.pop():e.call(r,i,1),--this.size,0))},FS}(),n=function(){if(QS)return SS;QS=1;var t=CU();return SS=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},SS}(),r=function(){if(NS)return US;NS=1;var t=CU();return US=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(OS)return TS;OS=1;var t=CU();return TS=function(e,n){var r=this.__data__,i=t(r,e);return i<0?(++this.size,r.push([e,n])):r[i][1]=n,this},TS}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,IS=o}function FU(){if(VS)return zS;VS=1;var t="object"==typeof bU&&bU&&bU.Object===Object&&bU;return zS=t}function kU(){if(YS)return WS;YS=1;var t=FU(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return WS=n}function SU(){if(qS)return XS;qS=1;var t=kU().Symbol;return XS=t}function QU(){if(nQ)return eQ;nQ=1;var t=SU(),e=function(){if(ZS)return $S;ZS=1;var t=SU(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return $S=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var A=!0}catch(t){}var s=r.call(t);return A&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(tQ)return JS;tQ=1;var t=Object.prototype.toString;return JS=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return eQ=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function UU(){if(iQ)return rQ;return iQ=1,rQ=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function NU(){if(AQ)return oQ;AQ=1;var t=QU(),e=UU();return oQ=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function TU(){if(lQ)return cQ;lQ=1;var t,e=function(){if(aQ)return sQ;aQ=1;var t=kU()["__core-js_shared__"];return sQ=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return cQ=function(t){return!!n&&n in t}}function OU(){if(hQ)return uQ;hQ=1;var t=Function.prototype.toString;return uQ=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function IU(){if(mQ)return vQ;mQ=1;var t=function(){if(fQ)return dQ;fQ=1;var t=NU(),e=TU(),n=UU(),r=OU(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,A=Object.prototype,s=o.toString,a=A.hasOwnProperty,c=RegExp("^"+s.call(a).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return dQ=function(o){return!(!n(o)||e(o))&&(t(o)?c:i).test(r(o))}}(),e=pQ?gQ:(pQ=1,gQ=function(t,e){return null==t?void 0:t[e]});return vQ=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function LU(){if(wQ)return yQ;wQ=1;var t=IU()(kU(),"Map");return yQ=t}function PU(){if(BQ)return bQ;BQ=1;var t=IU()(Object,"create");return bQ=t}function DU(){if(OQ)return TQ;OQ=1;var t=function(){if(xQ)return EQ;xQ=1;var t=PU();return EQ=function(){this.__data__=t?t(null):{},this.size=0}}(),e=MQ?CQ:(MQ=1,CQ=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(kQ)return FQ;kQ=1;var t=PU(),e=Object.prototype.hasOwnProperty;return FQ=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},FQ}(),r=function(){if(QQ)return SQ;QQ=1;var t=PU(),e=Object.prototype.hasOwnProperty;return SQ=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},SQ}(),i=function(){if(NQ)return UQ;NQ=1;var t=PU();return UQ=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},UQ}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,TQ=o}function RU(){if(HQ)return RQ;HQ=1;var t=DQ?PQ:(DQ=1,PQ=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return RQ=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},RQ}function HU(){if(qQ)return XQ;qQ=1;var t=function(){if(LQ)return IQ;LQ=1;var t=DU(),e=MU(),n=LU();return IQ=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(GQ)return _Q;GQ=1;var t=RU();return _Q=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(jQ)return KQ;jQ=1;var t=RU();return KQ=function(e){return t(this,e).get(e)}}(),r=function(){if(VQ)return zQ;VQ=1;var t=RU();return zQ=function(e){return t(this,e).has(e)}}(),i=function(){if(YQ)return WQ;YQ=1;var t=RU();return WQ=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},WQ}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,XQ=o}function _U(){if(tU)return JQ;tU=1;var t=MU(),e=function(){if(DS)return PS;DS=1;var t=MU();return PS=function(){this.__data__=new t,this.size=0}}(),n=(HS||(HS=1,RS=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),RS),r=GS?_S:(GS=1,_S=function(t){return this.__data__.get(t)}),i=jS?KS:(jS=1,KS=function(t){return this.__data__.has(t)}),o=function(){if(ZQ)return $Q;ZQ=1;var t=MU(),e=LU(),n=HU();return $Q=function(r,i){var o=this.__data__;if(o instanceof t){var A=o.__data__;if(!e||A.length<199)return A.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(A)}return o.set(r,i),this.size=o.size,this},$Q}();function A(e){var n=this.__data__=new t(e);this.size=n.size}return A.prototype.clear=e,A.prototype.delete=n,A.prototype.get=r,A.prototype.has=i,A.prototype.set=o,JQ=A}function GU(){if(nU)return eU;return nU=1,eU=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},eU}function KU(){if(iU)return rU;iU=1;var t=IU(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return rU=e}function jU(){if(AU)return oU;AU=1;var t=KU();return oU=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function zU(){if(aU)return sU;aU=1;var t=jU(),e=xU(),n=Object.prototype.hasOwnProperty;return sU=function(r,i,o){var A=r[i];n.call(r,i)&&e(A,o)&&(void 0!==o||i in r)||t(r,i,o)}}function VU(){if(lU)return cU;lU=1;var t=zU(),e=jU();return cU=function(n,r,i,o){var A=!i;i||(i={});for(var s=-1,a=r.length;++s<a;){var c=r[s],l=o?o(i[c],n[c],c,i,n):void 0;void 0===l&&(l=n[c]),A?e(i,c,l):t(i,c,l)}return i},cU}function WU(){if(fU)return dU;return fU=1,dU=function(t){return null!=t&&"object"==typeof t}}function YU(){if(mU)return vU;mU=1;var t=function(){if(pU)return gU;pU=1;var t=QU(),e=WU();return gU=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=WU(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return vU=o}function XU(){if(wU)return yU;wU=1;var t=Array.isArray;return yU=t}var qU,$U,ZU,JU,tN,eN,nN,rN,iN,oN,AN,sN={exports:{}};function aN(){return ZU||(ZU=1,function(t,e){var n=kU(),r=$U?qU:($U=1,qU=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,A=o&&o.exports===i?n.Buffer:void 0,s=(A?A.isBuffer:void 0)||r;t.exports=s}(sN,sN.exports)),sN.exports}function cN(){if(tN)return JU;tN=1;var t=/^(?:0|[1-9]\d*)$/;return JU=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},JU}function lN(){if(nN)return eN;nN=1;return eN=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function uN(){if(AN)return oN;return AN=1,oN=function(t){return function(e){return t(e)}}}var hN,dN,fN,gN,pN,vN,mN,yN,wN,bN,BN,EN,xN,CN,MN,FN,kN,SN,QN,UN,NN,TN,ON,IN,LN,PN,DN,RN={exports:{}};function HN(){return hN||(hN=1,function(t,e){var n=FU(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r&&n.process,A=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=A}(RN,RN.exports)),RN.exports}function _N(){if(fN)return dN;fN=1;var t=function(){if(iN)return rN;iN=1;var t=QU(),e=lN(),n=WU(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,rN=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=uN(),n=HN(),r=n&&n.isTypedArray,i=r?e(r):t;return dN=i}function GN(){if(pN)return gN;pN=1;var t=(hU||(hU=1,uU=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),uU),e=YU(),n=XU(),r=aN(),i=cN(),o=_N(),A=Object.prototype.hasOwnProperty;return gN=function(s,a){var c=n(s),l=!c&&e(s),u=!c&&!l&&r(s),h=!c&&!l&&!u&&o(s),d=c||l||u||h,f=d?t(s.length,String):[],g=f.length;for(var p in s)!a&&!A.call(s,p)||d&&("length"==p||u&&("offset"==p||"parent"==p)||h&&("buffer"==p||"byteLength"==p||"byteOffset"==p)||i(p,g))||f.push(p);return f},gN}function KN(){if(mN)return vN;mN=1;var t=Object.prototype;return vN=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function jN(){if(wN)return yN;return wN=1,yN=function(t,e){return function(n){return t(e(n))}},yN}function zN(){if(xN)return EN;xN=1;var t=KN(),e=function(){if(BN)return bN;BN=1;var t=jN()(Object.keys,Object);return bN=t}(),n=Object.prototype.hasOwnProperty;return EN=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function VN(){if(MN)return CN;MN=1;var t=NU(),e=lN();return CN=function(n){return null!=n&&e(n.length)&&!t(n)}}function WN(){if(kN)return FN;kN=1;var t=GN(),e=zN(),n=VN();return FN=function(r){return n(r)?t(r):e(r)}}function YN(){if(ON)return TN;ON=1;var t=UU(),e=KN(),n=NN?UN:(NN=1,UN=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return TN=function(i){if(!t(i))return n(i);var o=e(i),A=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&A.push(s);return A}}function XN(){if(LN)return IN;LN=1;var t=GN(),e=YN(),n=VN();return IN=function(r){return n(r)?t(r,!0):e(r)}}var qN,$N,ZN,JN,tT,eT,nT,rT,iT,oT,AT,sT,aT,cT,lT,uT,hT,dT,fT,gT,pT,vT,mT,yT,wT,bT,BT,ET,xT,CT,MT,FT,kT,ST,QT,UT,NT,TT,OT,IT,LT,PT,DT,RT,HT,_T,GT,KT,jT,zT,VT,WT,YT,XT,qT,$T,ZT,JT,tO,eO,nO,rO,iO,oO,AO,sO,aO,cO,lO,uO,hO,dO,fO,gO,pO,vO,mO,yO,wO,bO,BO,EO,xO,CO,MO,FO,kO,SO,QO,UO,NO,TO,OO,IO,LO,PO,DO,RO,HO,_O,GO,KO,jO,zO,VO,WO,YO,XO,qO,$O,ZO,JO,tI,eI,nI,rI,iI,oI,AI,sI,aI,cI,lI,uI,hI,dI,fI,gI,pI,vI,mI,yI,wI,bI,BI,EI,xI,CI,MI,FI,kI,SI,QI,UI,NI,TI,OI,II,LI,PI,DI,RI,HI,_I,GI,KI,jI,zI,VI,WI,YI,XI,qI,$I,ZI,JI,tL,eL,nL,rL,iL,oL,AL,sL,aL,cL,lL,uL,hL,dL,fL,gL,pL,vL,mL,yL,wL,bL,BL,EL,xL,CL,ML,FL,kL,SL,QL,UL,NL,TL,OL,IL,LL,PL,DL,RL,HL,_L,GL,KL,jL,zL,VL,WL,YL,XL,qL,$L,ZL,JL,tP,eP,nP,rP,iP,oP,AP,sP,aP,cP,lP,uP,hP,dP,fP,gP,pP,vP,mP,yP,wP,bP,BP,EP,xP,CP,MP,FP,kP,SP,QP,UP,NP,TP,OP,IP,LP,PP,DP,RP,HP,_P,GP,KP,jP,zP,VP,WP,YP,XP,qP,$P,ZP,JP,tD,eD,nD,rD,iD,oD,AD,sD,aD,cD,lD,uD,hD,dD,fD,gD,pD,vD,mD,yD,wD,bD,BD,ED,xD,CD,MD,FD,kD,SD,QD,UD,ND,TD,OD,ID,LD,PD,DD,RD,HD,_D,GD,KD,jD,zD,VD,WD,YD,XD,qD,$D,ZD,JD,tR,eR,nR,rR,iR,oR,AR,sR,aR,cR,lR,uR,hR,dR,fR,gR,pR,vR,mR,yR,wR,bR,BR,ER,xR,CR,MR,FR,kR,SR,QR,UR,NR,TR,OR,IR,LR,PR,DR,RR,HR,_R,GR,KR,jR,zR,VR,WR,YR,XR,qR,$R,ZR,JR,tH,eH,nH,rH,iH,oH,AH,sH,aH,cH,lH,uH,hH,dH,fH,gH,pH,vH,mH,yH,wH,bH,BH,EH,xH,CH,MH,FH,kH,SH,QH,UH,NH,TH,OH,IH,LH,PH,DH,RH,HH,_H,GH,KH,jH,zH,VH,WH,YH,XH={exports:{}};function qH(){return qN||(qN=1,function(t,e){var n=kU(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,A=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=A?A(n):new t.constructor(n);return t.copy(r),r}}(XH,XH.exports)),XH.exports}function $H(){if(ZN)return $N;return ZN=1,$N=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},$N}function ZH(){if(tT)return JN;return tT=1,JN=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var A=t[n];e(A,n,t)&&(o[i++]=A)}return o},JN}function JH(){if(nT)return eT;return nT=1,eT=function(){return[]}}function t_(){if(iT)return rT;iT=1;var t=ZH(),e=JH(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return rT=r?function(e){return null==e?[]:(e=Object(e),t(r(e),function(t){return n.call(e,t)}))}:e}function e_(){if(aT)return sT;return aT=1,sT=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},sT}function n_(){if(lT)return cT;lT=1;var t=jN()(Object.getPrototypeOf,Object);return cT=t}function r_(){if(hT)return uT;hT=1;var t=e_(),e=n_(),n=t_(),r=JH(),i=Object.getOwnPropertySymbols;return uT=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function i_(){if(pT)return gT;pT=1;var t=e_(),e=XU();return gT=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function o_(){if(mT)return vT;mT=1;var t=i_(),e=t_(),n=WN();return vT=function(r){return t(r,n,e)}}function A_(){if(MT)return CT;MT=1;var t=IU()(kU(),"Set");return CT=t}function s_(){if(QT)return ST;QT=1;var t=function(){if(BT)return bT;BT=1;var t=IU()(kU(),"DataView");return bT=t}(),e=LU(),n=function(){if(xT)return ET;xT=1;var t=IU()(kU(),"Promise");return ET=t}(),r=A_(),i=function(){if(kT)return FT;kT=1;var t=IU()(kU(),"WeakMap");return FT=t}(),o=QU(),A=OU(),s="[object Map]",a="[object Promise]",c="[object Set]",l="[object WeakMap]",u="[object DataView]",h=A(t),d=A(e),f=A(n),g=A(r),p=A(i),v=o;return(t&&v(new t(new ArrayBuffer(1)))!=u||e&&v(new e)!=s||n&&v(n.resolve())!=a||r&&v(new r)!=c||i&&v(new i)!=l)&&(v=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?A(n):"";if(r)switch(r){case h:return u;case d:return s;case f:return a;case g:return c;case p:return l}return e}),ST=v}function a_(){if(OT)return TT;OT=1;var t=kU().Uint8Array;return TT=t}function c_(){if(LT)return IT;LT=1;var t=a_();return IT=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function l_(){if(jT)return KT;jT=1;var t=c_();return KT=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function u_(){if(VT)return zT;VT=1;var t=c_(),e=function(){if(DT)return PT;DT=1;var t=c_();return PT=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(HT)return RT;HT=1;var t=/\w*$/;return RT=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(GT)return _T;GT=1;var t=SU(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return _T=function(t){return n?Object(n.call(t)):{}}}(),i=l_();return zT=function(o,A,s){var a=o.constructor;switch(A){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new a(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new a;case"[object Number]":case"[object String]":return new a(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function h_(){if(YT)return WT;YT=1;var t=UU(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return WT=n}function d_(){if(qT)return XT;qT=1;var t=h_(),e=n_(),n=KN();return XT=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function f_(){if(tO)return JT;tO=1;var t=function(){if(ZT)return $T;ZT=1;var t=s_(),e=WU();return $T=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=uN(),n=HN(),r=n&&n.isMap,i=r?e(r):t;return JT=i}function g_(){if(iO)return rO;iO=1;var t=function(){if(nO)return eO;nO=1;var t=s_(),e=WU();return eO=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=uN(),n=HN(),r=n&&n.isSet,i=r?e(r):t;return rO=i}function p_(){if(AO)return oO;AO=1;var t=_U(),e=GU(),n=zU(),r=function(){if(QN)return SN;QN=1;var t=VU(),e=WN();return SN=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(DN)return PN;DN=1;var t=VU(),e=XN();return PN=function(n,r){return n&&t(r,e(r),n)}}(),o=qH(),A=$H(),s=function(){if(AT)return oT;AT=1;var t=VU(),e=t_();return oT=function(n,r){return t(n,e(n),r)}}(),a=function(){if(fT)return dT;fT=1;var t=VU(),e=r_();return dT=function(n,r){return t(n,e(n),r)}}(),c=o_(),l=function(){if(wT)return yT;wT=1;var t=i_(),e=r_(),n=XN();return yT=function(r){return t(r,n,e)}}(),u=s_(),h=function(){if(NT)return UT;NT=1;var t=Object.prototype.hasOwnProperty;return UT=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},UT}(),d=u_(),f=d_(),g=XU(),p=aN(),v=f_(),m=UU(),y=g_(),w=WN(),b=XN(),B="[object Arguments]",E="[object Function]",x="[object Object]",C={};return C[B]=C["[object Array]"]=C["[object ArrayBuffer]"]=C["[object DataView]"]=C["[object Boolean]"]=C["[object Date]"]=C["[object Float32Array]"]=C["[object Float64Array]"]=C["[object Int8Array]"]=C["[object Int16Array]"]=C["[object Int32Array]"]=C["[object Map]"]=C["[object Number]"]=C[x]=C["[object RegExp]"]=C["[object Set]"]=C["[object String]"]=C["[object Symbol]"]=C["[object Uint8Array]"]=C["[object Uint8ClampedArray]"]=C["[object Uint16Array]"]=C["[object Uint32Array]"]=!0,C["[object Error]"]=C[E]=C["[object WeakMap]"]=!1,oO=function M(F,k,S,Q,U,N){var T,O=1&k,I=2&k,L=4&k;if(S&&(T=U?S(F,Q,U,N):S(F)),void 0!==T)return T;if(!m(F))return F;var P=g(F);if(P){if(T=h(F),!O)return A(F,T)}else{var D=u(F),R=D==E||"[object GeneratorFunction]"==D;if(p(F))return o(F,O);if(D==x||D==B||R&&!U){if(T=I||R?{}:f(F),!O)return I?a(F,i(T,F)):s(F,r(T,F))}else{if(!C[D])return U?F:{};T=d(F,D,O)}}N||(N=new t);var H=N.get(F);if(H)return H;N.set(F,T),y(F)?F.forEach(function(t){T.add(M(t,k,S,t,F,N))}):v(F)&&F.forEach(function(t,e){T.set(e,M(t,k,S,e,F,N))});var _=P?void 0:(L?I?l:c:I?b:w)(F);return e(_||F,function(t,e){_&&(t=F[e=t]),n(T,e,M(t,k,S,e,F,N))}),T},oO}function v_(){if(aO)return sO;aO=1;var t=p_();return sO=function(e){return t(e,4)}}function m_(){if(lO)return cO;return lO=1,cO=function(t){return function(){return t}}}function y_(){if(fO)return dO;fO=1;var t=(hO||(hO=1,uO=function(t){return function(e,n,r){for(var i=-1,o=Object(e),A=r(e),s=A.length;s--;){var a=A[t?s:++i];if(!1===n(o[a],a,o))break}return e}}),uO),e=t();return dO=e}function w_(){if(pO)return gO;pO=1;var t=y_(),e=WN();return gO=function(n,r){return n&&t(n,r,e)}}function b_(){if(wO)return yO;wO=1;var t=w_(),e=function(){if(mO)return vO;mO=1;var t=VN();return vO=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,A=n?o:-1,s=Object(r);(n?A--:++A<o)&&!1!==i(s[A],A,s););return r}},vO}(),n=e(t);return yO=n}function B_(){if(BO)return bO;return BO=1,bO=function(t){return t}}function E_(){if(xO)return EO;xO=1;var t=B_();return EO=function(e){return"function"==typeof e?e:t}}function x_(){if(MO)return CO;MO=1;var t=GU(),e=b_(),n=E_(),r=XU();return CO=function(i,o){return(r(i)?t:e)(i,n(o))}}function C_(){return kO?FO:(kO=1,FO=x_())}function M_(){if(LO)return IO;LO=1;var t=HU(),e=NO?UO:(NO=1,UO=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=OO?TO:(OO=1,TO=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,IO=r}function F_(){if(HO)return RO;return HO=1,RO=function(t,e){return t.has(e)}}function k_(){if(GO)return _O;GO=1;var t=M_(),e=(DO||(DO=1,PO=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),PO),n=F_();return _O=function(r,i,o,A,s,a){var c=1&o,l=r.length,u=i.length;if(l!=u&&!(c&&u>l))return!1;var h=a.get(r),d=a.get(i);if(h&&d)return h==i&&d==r;var f=-1,g=!0,p=2&o?new t:void 0;for(a.set(r,i),a.set(i,r);++f<l;){var v=r[f],m=i[f];if(A)var y=c?A(m,v,f,i,r,a):A(v,m,f,r,i,a);if(void 0!==y){if(y)continue;g=!1;break}if(p){if(!e(i,function(t,e){if(!n(p,e)&&(v===t||s(v,t,o,A,a)))return p.push(e)})){g=!1;break}}else if(v!==m&&!s(v,m,o,A,a)){g=!1;break}}return a.delete(r),a.delete(i),g},_O}function S_(){if(VO)return zO;return VO=1,zO=function(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n},zO}function Q_(){if(YO)return WO;YO=1;var t=SU(),e=a_(),n=xU(),r=k_(),i=(jO||(jO=1,KO=function(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}),KO),o=S_(),A=t?t.prototype:void 0,s=A?A.valueOf:void 0;return WO=function(t,A,a,c,l,u,h){switch(a){case"[object DataView]":if(t.byteLength!=A.byteLength||t.byteOffset!=A.byteOffset)return!1;t=t.buffer,A=A.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=A.byteLength||!u(new e(t),new e(A)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+A);case"[object Error]":return t.name==A.name&&t.message==A.message;case"[object RegExp]":case"[object String]":return t==A+"";case"[object Map]":var d=i;case"[object Set]":var f=1&c;if(d||(d=o),t.size!=A.size&&!f)return!1;var g=h.get(t);if(g)return g==A;c|=2,h.set(t,A);var p=r(d(t),d(A),c,l,u,h);return h.delete(t),p;case"[object Symbol]":if(s)return s.call(t)==s.call(A)}return!1}}function U_(){if(ZO)return $O;ZO=1;var t=_U(),e=k_(),n=Q_(),r=function(){if(qO)return XO;qO=1;var t=o_(),e=Object.prototype.hasOwnProperty;return XO=function(n,r,i,o,A,s){var a=1&i,c=t(n),l=c.length;if(l!=t(r).length&&!a)return!1;for(var u=l;u--;){var h=c[u];if(!(a?h in r:e.call(r,h)))return!1}var d=s.get(n),f=s.get(r);if(d&&f)return d==r&&f==n;var g=!0;s.set(n,r),s.set(r,n);for(var p=a;++u<l;){var v=n[h=c[u]],m=r[h];if(o)var y=a?o(m,v,h,r,n,s):o(v,m,h,n,r,s);if(!(void 0===y?v===m||A(v,m,i,o,s):y)){g=!1;break}p||(p="constructor"==h)}if(g&&!p){var w=n.constructor,b=r.constructor;w==b||!("constructor"in n)||!("constructor"in r)||"function"==typeof w&&w instanceof w&&"function"==typeof b&&b instanceof b||(g=!1)}return s.delete(n),s.delete(r),g},XO}(),i=s_(),o=XU(),A=aN(),s=_N(),a="[object Arguments]",c="[object Array]",l="[object Object]",u=Object.prototype.hasOwnProperty;return $O=function(h,d,f,g,p,v){var m=o(h),y=o(d),w=m?c:i(h),b=y?c:i(d),B=(w=w==a?l:w)==l,E=(b=b==a?l:b)==l,x=w==b;if(x&&A(h)){if(!A(d))return!1;m=!0,B=!1}if(x&&!B)return v||(v=new t),m||s(h)?e(h,d,f,g,p,v):n(h,d,w,f,g,p,v);if(!(1&f)){var C=B&&u.call(h,"__wrapped__"),M=E&&u.call(d,"__wrapped__");if(C||M){var F=C?h.value():h,k=M?d.value():d;return v||(v=new t),p(F,k,f,g,v)}}return!!x&&(v||(v=new t),r(h,d,f,g,p,v))}}function N_(){if(tI)return JO;tI=1;var t=U_(),e=WU();return JO=function n(r,i,o,A,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,A,n,s))},JO}function T_(){if(iI)return rI;iI=1;var t=UU();return rI=function(e){return e==e&&!t(e)}}function O_(){if(aI)return sI;return aI=1,sI=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function I_(){if(lI)return cI;lI=1;var t=function(){if(nI)return eI;nI=1;var t=_U(),e=N_();return eI=function(n,r,i,o){var A=i.length,s=A,a=!o;if(null==n)return!s;for(n=Object(n);A--;){var c=i[A];if(a&&c[2]?c[1]!==n[c[0]]:!(c[0]in n))return!1}for(;++A<s;){var l=(c=i[A])[0],u=n[l],h=c[1];if(a&&c[2]){if(void 0===u&&!(l in n))return!1}else{var d=new t;if(o)var f=o(u,h,l,n,r,d);if(!(void 0===f?e(h,u,3,o,d):f))return!1}}return!0},eI}(),e=function(){if(AI)return oI;AI=1;var t=T_(),e=WN();return oI=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],A=n[o];r[i]=[o,A,t(A)]}return r},oI}(),n=O_();return cI=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function L_(){if(hI)return uI;hI=1;var t=QU(),e=WU();return uI=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function P_(){if(fI)return dI;fI=1;var t=XU(),e=L_(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return dI=function(i,o){if(t(i))return!1;var A=typeof i;return!("number"!=A&&"symbol"!=A&&"boolean"!=A&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function D_(){if(mI)return vI;mI=1;var t=function(){if(pI)return gI;pI=1;var t=HU();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var A=n.apply(this,t);return i.cache=o.set(e,A)||o,A};return i.cache=new(e.Cache||t),i}return e.Cache=t,gI=e}();return vI=function(e){var n=t(e,function(t){return 500===r.size&&r.clear(),t}),r=n.cache;return n}}function R_(){if(BI)return bI;return BI=1,bI=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},bI}function H_(){if(MI)return CI;MI=1;var t=function(){if(xI)return EI;xI=1;var t=SU(),e=R_(),n=XU(),r=L_(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return EI=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var A=i+"";return"0"==A&&1/i==-1/0?"-0":A},EI}();return CI=function(e){return null==e?"":t(e)}}function __(){if(kI)return FI;kI=1;var t=XU(),e=P_(),n=function(){if(wI)return yI;wI=1;var t=D_(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t(function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)}),r});return yI=r}(),r=H_();return FI=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function G_(){if(QI)return SI;QI=1;var t=L_();return SI=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function K_(){if(NI)return UI;NI=1;var t=__(),e=G_();return UI=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},UI}function j_(){if(DI)return PI;DI=1;var t=__(),e=YU(),n=XU(),r=cN(),i=lN(),o=G_();return PI=function(A,s,a){for(var c=-1,l=(s=t(s,A)).length,u=!1;++c<l;){var h=o(s[c]);if(!(u=null!=A&&a(A,h)))break;A=A[h]}return u||++c!=l?u:!!(l=null==A?0:A.length)&&i(l)&&r(h,l)&&(n(A)||e(A))},PI}function z_(){if(HI)return RI;HI=1;var t=LI?II:(LI=1,II=function(t,e){return null!=t&&e in Object(t)}),e=j_();return RI=function(n,r){return null!=n&&e(n,r,t)}}function V_(){if(GI)return _I;GI=1;var t=N_(),e=function(){if(OI)return TI;OI=1;var t=K_();return TI=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=z_(),r=P_(),i=T_(),o=O_(),A=G_();return _I=function(s,a){return r(s)&&i(a)?o(A(s),a):function(r){var i=e(r,s);return void 0===i&&i===a?n(r,s):t(a,i,3)}}}function W_(){if(jI)return KI;return jI=1,KI=function(t){return function(e){return null==e?void 0:e[t]}}}function Y_(){if(YI)return WI;YI=1;var t=W_(),e=function(){if(VI)return zI;VI=1;var t=K_();return zI=function(e){return function(n){return t(n,e)}}}(),n=P_(),r=G_();return WI=function(i){return n(i)?t(r(i)):e(i)}}function X_(){if(qI)return XI;qI=1;var t=I_(),e=V_(),n=B_(),r=XU(),i=Y_();return XI=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function q_(){if(ZI)return $I;ZI=1;var t=ZH(),e=function(){if(QO)return SO;QO=1;var t=b_();return SO=function(e,n){var r=[];return t(e,function(t,e,i){n(t,e,i)&&r.push(t)}),r},SO}(),n=X_(),r=XU();return $I=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function $_(){if(nL)return eL;nL=1;var t=function(){if(tL)return JI;tL=1;var t=Object.prototype.hasOwnProperty;return JI=function(e,n){return null!=e&&t.call(e,n)}}(),e=j_();return eL=function(n,r){return null!=n&&e(n,r,t)}}function Z_(){if(iL)return rL;iL=1;var t=zN(),e=s_(),n=YU(),r=XU(),i=VN(),o=aN(),A=KN(),s=_N(),a=Object.prototype.hasOwnProperty;return rL=function(c){if(null==c)return!0;if(i(c)&&(r(c)||"string"==typeof c||"function"==typeof c.splice||o(c)||s(c)||n(c)))return!c.length;var l=e(c);if("[object Map]"==l||"[object Set]"==l)return!c.size;if(A(c))return!t(c).length;for(var u in c)if(a.call(c,u))return!1;return!0}}function J_(){if(AL)return oL;return AL=1,oL=function(t){return void 0===t}}function tG(){if(aL)return sL;aL=1;var t=b_(),e=VN();return sL=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,function(t,e,n){o[++i]=r(t,e,n)}),o},sL}function eG(){if(lL)return cL;lL=1;var t=R_(),e=X_(),n=tG(),r=XU();return cL=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function nG(){if(pL)return gL;pL=1;var t=(hL||(hL=1,uL=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),uL),e=b_(),n=X_(),r=(fL||(fL=1,dL=function(t,e,n,r,i){return i(t,function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)}),n}),dL),i=XU();return gL=function(o,A,s){var a=i(o)?t:r,c=arguments.length<3;return a(o,n(A,4),s,c,e)},gL}function rG(){if(ML)return CL;ML=1;var t=function(){if(wL)return yL;wL=1;var t=W_()("length");return yL=t}(),e=function(){if(BL)return bL;BL=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return bL=function(e){return t.test(e)}}(),n=function(){if(xL)return EL;xL=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",A="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",a="[\\ufe0e\\ufe0f]?",c=a+s+"(?:\\u200d(?:"+[i,o,A].join("|")+")"+a+s+")*",l="(?:"+[i+n+"?",n,o,A,e].join("|")+")",u=RegExp(r+"(?="+r+")|"+l+c,"g");return EL=function(t){for(var e=u.lastIndex=0;u.test(t);)++e;return e}}();return CL=function(r){return e(r)?n(r):t(r)}}function iG(){if(kL)return FL;kL=1;var t=zN(),e=s_(),n=VN(),r=function(){if(mL)return vL;mL=1;var t=QU(),e=XU(),n=WU();return vL=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=rG();return FL=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var A=e(o);return"[object Map]"==A||"[object Set]"==A?o.size:t(o).length}}function oG(){if(QL)return SL;QL=1;var t=GU(),e=h_(),n=w_(),r=X_(),i=n_(),o=XU(),A=aN(),s=NU(),a=UU(),c=_N();return SL=function(l,u,h){var d=o(l),f=d||A(l)||c(l);if(u=r(u,4),null==h){var g=l&&l.constructor;h=f?d?new g:[]:a(l)&&s(g)?e(i(l)):{}}return(f?t:n)(l,function(t,e,n){return u(h,t,e,n)}),h},SL}function AG(){if(OL)return TL;OL=1;var t=e_(),e=function(){if(NL)return UL;NL=1;var t=SU(),e=YU(),n=XU(),r=t?t.isConcatSpreadable:void 0;return UL=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return TL=function n(r,i,o,A,s){var a=-1,c=r.length;for(o||(o=e),s||(s=[]);++a<c;){var l=r[a];i>0&&o(l)?i>1?n(l,i-1,o,A,s):t(s,l):A||(s[s.length]=l)}return s},TL}function sG(){if(DL)return PL;DL=1;var t=LL?IL:(LL=1,IL=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}),e=Math.max;return PL=function(n,r,i){return r=e(void 0===r?n.length-1:r,0),function(){for(var o=arguments,A=-1,s=e(o.length-r,0),a=Array(s);++A<s;)a[A]=o[r+A];A=-1;for(var c=Array(r+1);++A<r;)c[A]=o[A];return c[r]=i(a),t(n,this,c)}},PL}function aG(){if(jL)return KL;jL=1;var t=function(){if(HL)return RL;HL=1;var t=m_(),e=KU(),n=B_();return RL=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(GL)return _L;GL=1;var t=Date.now;return _L=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},_L}(),n=e(t);return KL=n}function cG(){if(VL)return zL;VL=1;var t=B_(),e=sG(),n=aG();return zL=function(r,i){return n(e(r,i,t),r+"")}}function lG(){if(YL)return WL;return YL=1,WL=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},WL}function uG(){if(tP)return JL;tP=1;var t=lG(),e=qL?XL:(qL=1,XL=function(t){return t!=t}),n=(ZL||(ZL=1,$L=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),$L);return JL=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function hG(){if(aP)return sP;aP=1;var t=A_(),e=AP?oP:(AP=1,oP=function(){}),n=S_(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return sP=r}function dG(){if(lP)return cP;lP=1;var t=M_(),e=function(){if(nP)return eP;nP=1;var t=uG();return eP=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(iP||(iP=1,rP=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),rP),r=F_(),i=hG(),o=S_();return cP=function(A,s,a){var c=-1,l=e,u=A.length,h=!0,d=[],f=d;if(a)h=!1,l=n;else if(u>=200){var g=s?null:i(A);if(g)return o(g);h=!1,l=r,f=new t}else f=s?[]:d;t:for(;++c<u;){var p=A[c],v=s?s(p):p;if(p=a||0!==p?p:0,h&&v==v){for(var m=f.length;m--;)if(f[m]===v)continue t;s&&f.push(v),d.push(p)}else l(f,v,a)||(f!==d&&f.push(v),d.push(p))}return d},cP}function fG(){if(hP)return uP;hP=1;var t=VN(),e=WU();return uP=function(n){return e(n)&&t(n)}}function gG(){if(fP)return dP;fP=1;var t=AG(),e=cG(),n=dG(),r=fG(),i=e(function(e){return n(t(e,1,r,!0))});return dP=i}function pG(){if(mP)return vP;mP=1;var t=function(){if(pP)return gP;pP=1;var t=R_();return gP=function(e,n){return t(n,function(t){return e[t]})}}(),e=WN();return vP=function(n){return null==n?[]:t(n,e(n))}}function vG(){if(wP)return yP;var t;wP=1;try{t={clone:v_(),constant:m_(),each:C_(),filter:q_(),has:$_(),isArray:XU(),isEmpty:Z_(),isFunction:NU(),isUndefined:J_(),keys:WN(),map:eG(),reduce:nG(),size:iG(),transform:oG(),union:gG(),values:pG()}}catch(t){}return t||(t=window._),yP=t}function mG(){if(BP)return bP;BP=1;var t=vG();bP=n;var e="\0";function n(n){this._isDirected=!t.has(n,"directed")||n.directed,this._isMultigraph=!!t.has(n,"multigraph")&&n.multigraph,this._isCompound=!!t.has(n,"compound")&&n.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function r(t,e){t[e]?t[e]++:t[e]=1}function i(t,e){--t[e]||delete t[e]}function o(e,n,r,i){var o=""+n,A=""+r;if(!e&&o>A){var s=o;o=A,A=s}return o+""+A+""+(t.isUndefined(i)?"\0":i)}function A(t,e){return o(t,e.v,e.w,e.name)}return n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(t){return this._label=t,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return t.keys(this._nodes)},n.prototype.sources=function(){var e=this;return t.filter(this.nodes(),function(n){return t.isEmpty(e._in[n])})},n.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),function(n){return t.isEmpty(e._out[n])})},n.prototype.setNodes=function(e,n){var r=arguments,i=this;return t.each(e,function(t){r.length>1?i.setNode(t,n):i.setNode(t)}),this},n.prototype.setNode=function(n,r){return t.has(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=r),this):(this._nodes[n]=arguments.length>1?r:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=e,this._children[n]={},this._children[e][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)},n.prototype.node=function(t){return this._nodes[t]},n.prototype.hasNode=function(e){return t.has(this._nodes,e)},n.prototype.removeNode=function(e){var n=this;if(t.has(this._nodes,e)){var r=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),function(t){n.setParent(t)}),delete this._children[e]),t.each(t.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},n.prototype.setParent=function(n,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=e;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===n)throw new Error("Setting "+r+" as parent of "+n+" would create a cycle");this.setNode(r)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=r,this._children[r][n]=!0,this},n.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},n.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==e)return n}},n.prototype.children=function(n){if(t.isUndefined(n)&&(n=e),this._isCompound){var r=this._children[n];if(r)return t.keys(r)}else{if(n===e)return this.nodes();if(this.hasNode(n))return[]}},n.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},n.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},n.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},n.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},n.prototype.filterNodes=function(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;t.each(this._nodes,function(t,r){e(r)&&n.setNode(r,t)}),t.each(this._edgeObjs,function(t){n.hasNode(t.v)&&n.hasNode(t.w)&&n.setEdge(t,r.edge(t))});var i={};function o(t){var e=r.parent(t);return void 0===e||n.hasNode(e)?(i[t]=e,e):e in i?i[e]:o(e)}return this._isCompound&&t.each(n.nodes(),function(t){n.setParent(t,o(t))}),n},n.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return t.values(this._edgeObjs)},n.prototype.setPath=function(e,n){var r=this,i=arguments;return t.reduce(e,function(t,e){return i.length>1?r.setEdge(t,e,n):r.setEdge(t,e),e}),this},n.prototype.setEdge=function(){var e,n,i,A,s=!1,a=arguments[0];"object"==typeof a&&null!==a&&"v"in a?(e=a.v,n=a.w,i=a.name,2===arguments.length&&(A=arguments[1],s=!0)):(e=a,n=arguments[1],i=arguments[3],arguments.length>2&&(A=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var c=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,c))return s&&(this._edgeLabels[c]=A),this;if(!t.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[c]=s?A:this._defaultEdgeLabelFn(e,n,i);var l=function(t,e,n,r){var i=""+e,o=""+n;if(!t&&i>o){var A=i;i=o,o=A}var s={v:i,w:o};r&&(s.name=r);return s}(this._isDirected,e,n,i);return e=l.v,n=l.w,Object.freeze(l),this._edgeObjs[c]=l,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][c]=l,this._out[e][c]=l,this._edgeCount++,this},n.prototype.edge=function(t,e,n){var r=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,t,e,n);return this._edgeLabels[r]},n.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},n.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?A(this._isDirected,arguments[0]):o(this._isDirected,t,e,n),s=this._edgeObjs[r];return s&&(t=s.v,e=s.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[e],t),i(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},n.prototype.inEdges=function(e,n){var r=this._in[e];if(r){var i=t.values(r);return n?t.filter(i,function(t){return t.v===n}):i}},n.prototype.outEdges=function(e,n){var r=this._out[e];if(r){var i=t.values(r);return n?t.filter(i,function(t){return t.w===n}):i}},n.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},bP}function yG(){return MP?CP:(MP=1,CP={Graph:mG(),version:xP?EP:(xP=1,EP="2.1.8")})}function wG(){if(kP)return FP;kP=1;var t=vG(),e=mG();function n(e){return t.map(e.nodes(),function(n){var r=e.node(n),i=e.parent(n),o={v:n};return t.isUndefined(r)||(o.value=r),t.isUndefined(i)||(o.parent=i),o})}function r(e){return t.map(e.edges(),function(n){var r=e.edge(n),i={v:n.v,w:n.w};return t.isUndefined(n.name)||(i.name=n.name),t.isUndefined(r)||(i.value=r),i})}return FP={write:function(e){var i={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:n(e),edges:r(e)};t.isUndefined(e.graph())||(i.value=t.clone(e.graph()));return i},read:function(n){var r=new e(n.options).setGraph(n.value);return t.each(n.nodes,function(t){r.setNode(t.v,t.value),t.parent&&r.setParent(t.v,t.parent)}),t.each(n.edges,function(t){r.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),r}},FP}function bG(){if(QP)return SP;QP=1;var t=vG();return SP=function(e){var n,r={},i=[];function o(i){t.has(r,i)||(r[i]=!0,n.push(i),t.each(e.successors(i),o),t.each(e.predecessors(i),o))}return t.each(e.nodes(),function(t){n=[],o(t),n.length&&i.push(n)}),i},SP}function BG(){if(NP)return UP;NP=1;var t=vG();function e(){this._arr=[],this._keyIndices={}}return UP=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(t){return t.key})},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,n){var r=this._keyIndices;if(e=String(e),!t.has(r,e)){var i=this._arr,o=i.length;return r[e]=o,i.push({key:e,priority:n}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)},e.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},UP}function EG(){if(OP)return TP;OP=1;var t=vG(),e=BG();TP=function(t,r,i,o){return function(t,n,r,i){var o,A,s={},a=new e,c=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),c=A.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);c<n.distance&&(n.distance=c,n.predecessor=o,a.decrease(e,c))};t.nodes().forEach(function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},a.add(t,e)});for(;a.size()>0&&(o=a.removeMin(),(A=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(c);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return TP}function xG(){if(LP)return IP;LP=1;var t=EG(),e=vG();return IP=function(n,r,i){return e.transform(n.nodes(),function(e,o){e[o]=t(n,o,r,i)},{})},IP}function CG(){if(DP)return PP;DP=1;var t=vG();return PP=function(e){var n=0,r=[],i={},o=[];function A(s){var a=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),e.successors(s).forEach(function(e){t.has(i,e)?i[e].onStack&&(a.lowlink=Math.min(a.lowlink,i[e].index)):(A(e),a.lowlink=Math.min(a.lowlink,i[e].lowlink))}),a.lowlink===a.index){var c,l=[];do{c=r.pop(),i[c].onStack=!1,l.push(c)}while(s!==c);o.push(l)}}return e.nodes().forEach(function(e){t.has(i,e)||A(e)}),o},PP}function MG(){if(HP)return RP;HP=1;var t=vG(),e=CG();return RP=function(n){return t.filter(e(n),function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])})},RP}function FG(){if(GP)return _P;GP=1;var t=vG();_P=function(t,n,r){return function(t,e,n){var r={},i=t.nodes();return i.forEach(function(t){r[t]={},r[t][t]={distance:0},i.forEach(function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})}),n(t).forEach(function(n){var i=n.v===t?n.w:n.v,o=e(n);r[t][i]={distance:o,predecessor:t}})}),i.forEach(function(t){var e=r[t];i.forEach(function(n){var o=r[n];i.forEach(function(n){var r=o[t],i=e[n],A=o[n],s=r.distance+i.distance;s<A.distance&&(A.distance=s,A.predecessor=i.predecessor)})})}),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return _P}function kG(){if(jP)return KP;jP=1;var t=vG();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),function A(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),A),delete i[s],o.push(s))}),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return KP=e,e.CycleException=n,n.prototype=new Error,KP}function SG(){if(VP)return zP;VP=1;var t=kG();return zP=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0},zP}function QG(){if(YP)return WP;YP=1;var t=vG();function e(n,r,i,o,A,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(A(r),function(t){e(n,t,i,o,A,s)}),i&&s.push(r))}return WP=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),A=[],s={};return t.each(r,function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,A)}),A},WP}function UG(){if(qP)return XP;qP=1;var t=QG();return XP=function(e,n){return t(e,n,"post")},XP}function NG(){if(ZP)return $P;ZP=1;var t=QG();return $P=function(e,n){return t(e,n,"pre")},$P}function TG(){if(tD)return JP;tD=1;var t=vG(),e=mG(),n=BG();return JP=function(r,i){var o,A=new e,s={},a=new n;function c(t){var e=t.v===o?t.w:t.v,n=a.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,a.decrease(e,r))}}if(0===r.nodeCount())return A;t.each(r.nodes(),function(t){a.add(t,Number.POSITIVE_INFINITY),A.setNode(t)}),a.decrease(r.nodes()[0],0);var l=!1;for(;a.size()>0;){if(o=a.removeMin(),t.has(s,o))A.setEdge(o,s[o]);else{if(l)throw new Error("Input graph is not connected: "+r);l=!0}r.nodeEdges(o).forEach(c)}return A},JP}function OG(){if(iD)return rD;iD=1;var t=yG();return rD={Graph:t.Graph,json:wG(),alg:nD?eD:(nD=1,eD={components:bG(),dijkstra:EG(),dijkstraAll:xG(),findCycles:MG(),floydWarshall:FG(),isAcyclic:SG(),postorder:UG(),preorder:NG(),prim:TG(),tarjan:CG(),topsort:kG()}),version:t.version}}function IG(){if(AD)return oD;var t;AD=1;try{t=OG()}catch(t){}return t||(t=window.graphlib),oD=t}function LG(){if(aD)return sD;aD=1;var t=p_();return sD=function(e){return t(e,5)}}function PG(){if(lD)return cD;lD=1;var t=xU(),e=VN(),n=cN(),r=UU();return cD=function(i,o,A){if(!r(A))return!1;var s=typeof o;return!!("number"==s?e(A)&&n(o,A.length):"string"==s&&o in A)&&t(A[o],i)},cD}function DG(){if(hD)return uD;hD=1;var t=cG(),e=xU(),n=PG(),r=XN(),i=Object.prototype,o=i.hasOwnProperty,A=t(function(t,A){t=Object(t);var s=-1,a=A.length,c=a>2?A[2]:void 0;for(c&&n(A[0],A[1],c)&&(a=1);++s<a;)for(var l=A[s],u=r(l),h=-1,d=u.length;++h<d;){var f=u[h],g=t[f];(void 0===g||e(g,i[f])&&!o.call(t,f))&&(t[f]=l[f])}return t});return uD=A}function RG(){if(mD)return vD;mD=1;var t=function(){if(pD)return gD;pD=1;var t=/\s/;return gD=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},gD}(),e=/^\s+/;return vD=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function HG(){if(BD)return bD;BD=1;var t=function(){if(wD)return yD;wD=1;var t=RG(),e=UU(),n=L_(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,A=parseInt;return yD=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var a="function"==typeof s.valueOf?s.valueOf():s;s=e(a)?a+"":a}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var c=i.test(s);return c||o.test(s)?A(s.slice(2),c?2:8):r.test(s)?NaN:+s}}(),e=1/0;return bD=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function _G(){if(MD)return CD;MD=1;var t=lG(),e=X_(),n=function(){if(xD)return ED;xD=1;var t=HG();return ED=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return CD=function(i,o,A){var s=null==i?0:i.length;if(!s)return-1;var a=null==A?0:n(A);return a<0&&(a=r(s+a,0)),t(i,e(o,3),a)},CD}function GG(){if(kD)return FD;kD=1;var t=function(){if(fD)return dD;fD=1;var t=X_(),e=VN(),n=WN();return dD=function(r){return function(i,o,A){var s=Object(i);if(!e(i)){var a=t(o,3);i=n(i),o=function(t){return a(s[t],t,s)}}var c=r(i,o,A);return c>-1?s[a?i[c]:c]:void 0}},dD}(),e=t(_G());return FD=e}function KG(){if(QD)return SD;QD=1;var t=AG();return SD=function(e){return(null==e?0:e.length)?t(e,1):[]}}function jG(){if(ND)return UD;ND=1;var t=y_(),e=E_(),n=XN();return UD=function(r,i){return null==r?r:t(r,e(i),n)}}function zG(){if(OD)return TD;return OD=1,TD=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0},TD}function VG(){if(LD)return ID;LD=1;var t=jU(),e=w_(),n=X_();return ID=function(r,i){var o={};return i=n(i,3),e(r,function(e,n,r){t(o,n,i(e,n,r))}),o}}function WG(){if(DD)return PD;DD=1;var t=L_();return PD=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var A=e[i],s=n(A);if(null!=s&&(void 0===a?s==s&&!t(s):r(s,a)))var a=s,c=A}return c},PD}function YG(){if(GD)return _D;GD=1;var t=WG(),e=HD?RD:(HD=1,RD=function(t,e){return t>e}),n=B_();return _D=function(r){return r&&r.length?t(r,n,e):void 0}}function XG(){if(jD)return KD;jD=1;var t=jU(),e=xU();return KD=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function qG(){if(YD)return WD;return YD=1,WD=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function $G(){if(ZD)return $D;ZD=1;var t=XG(),e=qH(),n=l_(),r=$H(),i=d_(),o=YU(),A=XU(),s=fG(),a=aN(),c=NU(),l=UU(),u=function(){if(VD)return zD;VD=1;var t=QU(),e=n_(),n=WU(),r=Function.prototype,i=Object.prototype,o=r.toString,A=i.hasOwnProperty,s=o.call(Object);return zD=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var a=A.call(i,"constructor")&&i.constructor;return"function"==typeof a&&a instanceof a&&o.call(a)==s}}(),h=_N(),d=qG(),f=function(){if(qD)return XD;qD=1;var t=VU(),e=XN();return XD=function(n){return t(n,e(n))}}();return $D=function(g,p,v,m,y,w,b){var B=d(g,v),E=d(p,v),x=b.get(E);if(x)t(g,v,x);else{var C=w?w(B,E,v+"",g,p,b):void 0,M=void 0===C;if(M){var F=A(E),k=!F&&a(E),S=!F&&!k&&h(E);C=E,F||k||S?A(B)?C=B:s(B)?C=r(B):k?(M=!1,C=e(E,!0)):S?(M=!1,C=n(E,!0)):C=[]:u(E)||o(E)?(C=B,o(B)?C=f(B):l(B)&&!c(B)||(C=i(E))):M=!1}M&&(b.set(E,C),y(C,E,m,w,b),b.delete(E)),t(g,v,C)}}}function ZG(){if(iR)return rR;iR=1;var t=function(){if(tR)return JD;tR=1;var t=_U(),e=XG(),n=y_(),r=$G(),i=UU(),o=XN(),A=qG();return JD=function s(a,c,l,u,h){a!==c&&n(c,function(n,o){if(h||(h=new t),i(n))r(a,c,o,l,s,u,h);else{var d=u?u(A(a,o),n,o+"",a,c,h):void 0;void 0===d&&(d=n),e(a,o,d)}},o)},JD}(),e=function(){if(nR)return eR;nR=1;var t=cG(),e=PG();return eR=function(n){return t(function(t,r){var i=-1,o=r.length,A=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(A=n.length>3&&"function"==typeof A?(o--,A):void 0,s&&e(r[0],r[1],s)&&(A=o<3?void 0:A,o=1),t=Object(t);++i<o;){var a=r[i];a&&n(t,a,i,A)}return t})},eR}(),n=e(function(e,n,r){t(e,n,r)});return rR=n}function JG(){if(AR)return oR;return AR=1,oR=function(t,e){return t<e}}function tK(){if(aR)return sR;aR=1;var t=WG(),e=JG(),n=B_();return sR=function(r){return r&&r.length?t(r,n,e):void 0}}function eK(){if(lR)return cR;lR=1;var t=WG(),e=X_(),n=JG();return cR=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}function nK(){if(hR)return uR;hR=1;var t=kU();return uR=function(){return t.Date.now()}}function rK(){if(pR)return gR;pR=1;var t=K_(),e=function(){if(fR)return dR;fR=1;var t=zU(),e=__(),n=cN(),r=UU(),i=G_();return dR=function(o,A,s,a){if(!r(o))return o;for(var c=-1,l=(A=e(A,o)).length,u=l-1,h=o;null!=h&&++c<l;){var d=i(A[c]),f=s;if("__proto__"===d||"constructor"===d||"prototype"===d)return o;if(c!=u){var g=h[d];void 0===(f=a?a(g,d,h):void 0)&&(f=r(g)?g:n(A[c+1])?[]:{})}t(h,d,f),h=h[d]}return o},dR}(),n=__();return gR=function(r,i,o){for(var A=-1,s=i.length,a={};++A<s;){var c=i[A],l=t(r,c);o(l,c)&&e(a,n(c,r),l)}return a},gR}function iK(){if(BR)return bR;BR=1;var t=function(){if(mR)return vR;mR=1;var t=rK(),e=z_();return vR=function(n,r){return t(n,r,function(t,r){return e(n,r)})}}(),e=function(){if(wR)return yR;wR=1;var t=KG(),e=sG(),n=aG();return yR=function(r){return n(e(r,void 0,t),r+"")}}(),n=e(function(e,n){return null==e?{}:t(e,n)});return bR=n}function oK(){if(MR)return CR;MR=1;var t=function(){if(xR)return ER;xR=1;var t=Math.ceil,e=Math.max;return ER=function(n,r,i,o){for(var A=-1,s=e(t((r-n)/(i||1)),0),a=Array(s);s--;)a[o?s:++A]=n,n+=i;return a},ER}(),e=PG(),n=HG();return CR=function(r){return function(i,o,A){return A&&"number"!=typeof A&&e(i,o,A)&&(o=A=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),A=void 0===A?i<o?1:-1:n(A),t(i,o,A,r)}},CR}function AK(){if(kR)return FR;kR=1;var t=oK()();return FR=t}function sK(){if(OR)return TR;OR=1;var t=function(){if(NR)return UR;NR=1;var t=L_();return UR=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,A=t(e),s=void 0!==n,a=null===n,c=n==n,l=t(n);if(!a&&!l&&!A&&e>n||A&&s&&c&&!a&&!l||i&&s&&c||!r&&c||!o)return 1;if(!i&&!A&&!l&&e<n||l&&r&&o&&!i&&!A||a&&r&&o||!s&&o||!c)return-1}return 0}}();return TR=function(e,n,r){for(var i=-1,o=e.criteria,A=n.criteria,s=o.length,a=r.length;++i<s;){var c=t(o[i],A[i]);if(c)return i>=a?c:c*("desc"==r[i]?-1:1)}return e.index-n.index},TR}function aK(){if(LR)return IR;LR=1;var t=R_(),e=K_(),n=X_(),r=tG(),i=(QR||(QR=1,SR=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),SR),o=uN(),A=sK(),s=B_(),a=XU();return IR=function(c,l,u){l=l.length?t(l,function(t){return a(t)?function(n){return e(n,1===t.length?t[0]:t)}:t}):[s];var h=-1;l=t(l,o(n));var d=r(c,function(e,n,r){return{criteria:t(l,function(t){return t(e)}),index:++h,value:e}});return i(d,function(t,e){return A(t,e,u)})},IR}function cK(){if(DR)return PR;DR=1;var t=AG(),e=aK(),n=cG(),r=PG(),i=n(function(n,i){if(null==n)return[];var o=i.length;return o>1&&r(n,i[0],i[1])?i=[]:o>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),e(n,t(i,1),[])});return PR=i}function lK(){if(HR)return RR;HR=1;var t=H_(),e=0;return RR=function(n){var r=++e;return t(n)+r},RR}function uK(){if(jR)return KR;jR=1;var t=zU(),e=(GR||(GR=1,_R=function(t,e,n){for(var r=-1,i=t.length,o=e.length,A={};++r<i;){var s=r<o?e[r]:void 0;n(A,t[r],s)}return A}),_R);return KR=function(n,r){return e(n||[],r||[],t)},KR}function hK(){if(VR)return zR;var t;VR=1;try{t={cloneDeep:LG(),constant:m_(),defaults:DG(),each:C_(),filter:q_(),find:GG(),flatten:KG(),forEach:x_(),forIn:jG(),has:$_(),isUndefined:J_(),last:zG(),map:eG(),mapValues:VG(),max:YG(),merge:ZG(),min:tK(),minBy:eK(),now:nK(),pick:iK(),range:AK(),reduce:nG(),sortBy:cK(),uniqueId:lK(),values:pG(),zipObject:uK()}}catch(t){}return t||(t=window._),zR=t}function dK(){if(qR)return XR;qR=1;var t=hK(),e=IG().Graph,n=function(){if(YR)return WR;function t(){var t={};t._next=t._prev=t,this._sentinel=t}function e(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function n(t,e){if("_next"!==t&&"_prev"!==t)return e}return YR=1,WR=t,t.prototype.dequeue=function(){var t=this._sentinel,n=t._prev;if(n!==t)return e(n),n},t.prototype.enqueue=function(t){var n=this._sentinel;t._prev&&t._next&&e(t),t._next=n._next,n._next._prev=t,n._next=t,t._prev=n},t.prototype.toString=function(){for(var t=[],e=this._sentinel,r=e._prev;r!==e;)t.push(JSON.stringify(r,n)),r=r._prev;return"["+t.join(", ")+"]"},WR}();XR=function(A,s){if(A.nodeCount()<=1)return[];var a=function(r,i){var A=new e,s=0,a=0;t.forEach(r.nodes(),function(t){A.setNode(t,{v:t,in:0,out:0})}),t.forEach(r.edges(),function(t){var e=A.edge(t.v,t.w)||0,n=i(t),r=e+n;A.setEdge(t.v,t.w,r),a=Math.max(a,A.node(t.v).out+=n),s=Math.max(s,A.node(t.w).in+=n)});var c=t.range(a+s+3).map(function(){return new n}),l=s+1;return t.forEach(A.nodes(),function(t){o(c,l,A.node(t))}),{graph:A,buckets:c,zeroIdx:l}}(A,s||r),c=function(t,e,n){var r,o=[],A=e[e.length-1],s=e[0];for(;t.nodeCount();){for(;r=s.dequeue();)i(t,e,n,r);for(;r=A.dequeue();)i(t,e,n,r);if(t.nodeCount())for(var a=e.length-2;a>0;--a)if(r=e[a].dequeue()){o=o.concat(i(t,e,n,r,!0));break}}return o}(a.graph,a.buckets,a.zeroIdx);return t.flatten(t.map(c,function(t){return A.outEdges(t.v,t.w)}),!0)};var r=t.constant(1);function i(e,n,r,i,A){var s=A?[]:void 0;return t.forEach(e.inEdges(i.v),function(t){var i=e.edge(t),a=e.node(t.v);A&&s.push({v:t.v,w:t.w}),a.out-=i,o(n,r,a)}),t.forEach(e.outEdges(i.v),function(t){var i=e.edge(t),A=t.w,s=e.node(A);s.in-=i,o(n,r,s)}),e.removeNode(i.v),s}function o(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}return XR}function fK(){if(ZR)return $R;ZR=1;var t=hK(),e=dK();return $R={run:function(n){var r="greedy"===n.graph().acyclicer?e(n,function(t){return function(e){return t.edge(e).weight}}(n)):function(e){var n=[],r={},i={};function o(A){t.has(i,A)||(i[A]=!0,r[A]=!0,t.forEach(e.outEdges(A),function(e){t.has(r,e.w)?n.push(e):o(e.w)}),delete r[A])}return t.forEach(e.nodes(),o),n}(n);t.forEach(r,function(e){var r=n.edge(e);n.removeEdge(e),r.forwardName=e.name,r.reversed=!0,n.setEdge(e.w,e.v,r,t.uniqueId("rev"))})},undo:function(e){t.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}},$R}function gK(){if(tH)return JR;tH=1;var t=hK(),e=IG().Graph;function n(e,n,r,i){var o;do{o=t.uniqueId(i)}while(e.hasNode(o));return r.dummy=n,e.setNode(o,r),o}function r(e){return t.max(t.map(e.nodes(),function(n){var r=e.node(n).rank;if(!t.isUndefined(r))return r}))}return JR={addDummyNode:n,simplify:function(n){var r=(new e).setGraph(n.graph());return t.forEach(n.nodes(),function(t){r.setNode(t,n.node(t))}),t.forEach(n.edges(),function(t){var e=r.edge(t.v,t.w)||{weight:0,minlen:1},i=n.edge(t);r.setEdge(t.v,t.w,{weight:e.weight+i.weight,minlen:Math.max(e.minlen,i.minlen)})}),r},asNonCompoundGraph:function(n){var r=new e({multigraph:n.isMultigraph()}).setGraph(n.graph());return t.forEach(n.nodes(),function(t){n.children(t).length||r.setNode(t,n.node(t))}),t.forEach(n.edges(),function(t){r.setEdge(t,n.edge(t))}),r},successorWeights:function(e){var n=t.map(e.nodes(),function(n){var r={};return t.forEach(e.outEdges(n),function(t){r[t.w]=(r[t.w]||0)+e.edge(t).weight}),r});return t.zipObject(e.nodes(),n)},predecessorWeights:function(e){var n=t.map(e.nodes(),function(n){var r={};return t.forEach(e.inEdges(n),function(t){r[t.v]=(r[t.v]||0)+e.edge(t).weight}),r});return t.zipObject(e.nodes(),n)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,A=e.x-i,s=e.y-o,a=t.width/2,c=t.height/2;if(!A&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*a>Math.abs(A)*c?(s<0&&(c=-c),n=c*A/s,r=c):(A<0&&(a=-a),n=a,r=a*s/A);return{x:i+n,y:o+r}},buildLayerMatrix:function(e){var n=t.map(t.range(r(e)+1),function(){return[]});return t.forEach(e.nodes(),function(r){var i=e.node(r),o=i.rank;t.isUndefined(o)||(n[o][i.order]=r)}),n},normalizeRanks:function(e){var n=t.min(t.map(e.nodes(),function(t){return e.node(t).rank}));t.forEach(e.nodes(),function(r){var i=e.node(r);t.has(i,"rank")&&(i.rank-=n)})},removeEmptyRanks:function(e){var n=t.min(t.map(e.nodes(),function(t){return e.node(t).rank})),r=[];t.forEach(e.nodes(),function(t){var i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});var i=0,o=e.graph().nodeRankFactor;t.forEach(r,function(n,r){t.isUndefined(n)&&r%o!==0?--i:i&&t.forEach(n,function(t){e.node(t).rank+=i})})},addBorderNode:function(t,e,r,i){var o={width:0,height:0};arguments.length>=4&&(o.rank=r,o.order=i);return n(t,"border",o,e)},maxRank:r,partition:function(e,n){var r={lhs:[],rhs:[]};return t.forEach(e,function(t){n(t)?r.lhs.push(t):r.rhs.push(t)}),r},time:function(e,n){var r=t.now();try{return n()}finally{console.log(e+" time: "+(t.now()-r)+"ms")}},notime:function(t,e){return e()}},JR}function pK(){if(nH)return eH;nH=1;var t=hK(),e=gK();return eH={run:function(n){n.graph().dummyChains=[],t.forEach(n.edges(),function(t){!function(t,n){var r,i,o,A=n.v,s=t.node(A).rank,a=n.w,c=t.node(a).rank,l=n.name,u=t.edge(n),h=u.labelRank;if(c===s+1)return;for(t.removeEdge(n),o=0,++s;s<c;++o,++s)u.points=[],i={width:0,height:0,edgeLabel:u,edgeObj:n,rank:s},r=e.addDummyNode(t,"edge",i,"_d"),s===h&&(i.width=u.width,i.height=u.height,i.dummy="edge-label",i.labelpos=u.labelpos),t.setEdge(A,r,{weight:u.weight},l),0===o&&t.graph().dummyChains.push(r),A=r;t.setEdge(A,a,{weight:u.weight},l)}(n,t)})},undo:function(e){t.forEach(e.graph().dummyChains,function(t){var n,r=e.node(t),i=r.edgeLabel;for(e.setEdge(r.edgeObj,i);r.dummy;)n=e.successors(t)[0],e.removeNode(t),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),t=n,r=e.node(t)})}},eH}function vK(){if(iH)return rH;iH=1;var t=hK();return rH={longestPath:function(e){var n={};t.forEach(e.sources(),function r(i){var o=e.node(i);if(t.has(n,i))return o.rank;n[i]=!0;var A=t.min(t.map(e.outEdges(i),function(t){return r(t.w)-e.edge(t).minlen}));return A!==Number.POSITIVE_INFINITY&&null!=A||(A=0),o.rank=A})},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}},rH}function mK(){if(AH)return oH;AH=1;var t=hK(),e=IG().Graph,n=vK().slack;function r(e,r){return t.forEach(e.nodes(),function i(o){t.forEach(r.nodeEdges(o),function(t){var A=t.v,s=o===A?t.w:A;e.hasNode(s)||n(r,t)||(e.setNode(s,{}),e.setEdge(o,s,{}),i(s))})}),e.nodeCount()}function i(e,r){return t.minBy(r.edges(),function(t){if(e.hasNode(t.v)!==e.hasNode(t.w))return n(r,t)})}function o(e,n,r){t.forEach(e.nodes(),function(t){n.node(t).rank+=r})}return oH=function(t){var A,s,a=new e({directed:!1}),c=t.nodes()[0],l=t.nodeCount();a.setNode(c,{});for(;r(a,t)<l;)A=i(a,t),s=a.hasNode(A.v)?n(t,A):-n(t,A),o(a,t,s);return a},oH}function yK(){if(aH)return sH;aH=1;var t=hK(),e=mK(),n=vK().slack,r=vK().longestPath,i=IG().alg.preorder,o=IG().alg.postorder,A=gK().simplify;function s(t){t=A(t),r(t);var n,i=e(t);for(l(i),a(i,t);n=h(i);)f(i,t,n,d(i,t,n))}function a(e,n){var r=o(e,e.nodes());r=r.slice(0,r.length-1),t.forEach(r,function(t){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=c(t,e,n)}(e,n,t)})}function c(e,n,r){var i=e.node(r).parent,o=!0,A=n.edge(r,i),s=0;return A||(o=!1,A=n.edge(i,r)),s=A.weight,t.forEach(n.nodeEdges(r),function(t){var A=t.v===r,a=A?t.w:t.v;if(a!==i){var c=A===o,l=n.edge(t).weight;if(s+=c?l:-l,function(t,e,n){return t.hasEdge(e,n)}(e,r,a)){var u=e.edge(r,a).cutvalue;s+=c?-u:u}}}),s}function l(t,e){arguments.length<2&&(e=t.nodes()[0]),u(t,{},1,e)}function u(e,n,r,i,o){var A=r,s=e.node(i);return n[i]=!0,t.forEach(e.neighbors(i),function(o){t.has(n,o)||(r=u(e,n,r,o,i))}),s.low=A,s.lim=r++,o?s.parent=o:delete s.parent,r}function h(e){return t.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function d(e,r,i){var o=i.v,A=i.w;r.hasEdge(o,A)||(o=i.w,A=i.v);var s=e.node(o),a=e.node(A),c=s,l=!1;s.lim>a.lim&&(c=a,l=!0);var u=t.filter(r.edges(),function(t){return l===g(e,e.node(t.v),c)&&l!==g(e,e.node(t.w),c)});return t.minBy(u,function(t){return n(r,t)})}function f(e,n,r,o){var A=r.v,s=r.w;e.removeEdge(A,s),e.setEdge(o.v,o.w,{}),l(e),a(e,n),function(e,n){var r=t.find(e.nodes(),function(t){return!n.node(t).parent}),o=i(e,r);o=o.slice(1),t.forEach(o,function(t){var r=e.node(t).parent,i=n.edge(t,r),o=!1;i||(i=n.edge(r,t),o=!0),n.node(t).rank=n.node(r).rank+(o?i.minlen:-i.minlen)})}(e,n)}function g(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}return sH=s,s.initLowLimValues=l,s.initCutValues=a,s.calcCutValue=c,s.leaveEdge=h,s.enterEdge=d,s.exchangeEdges=f,sH}function wK(){if(lH)return cH;lH=1;var t=vK().longestPath,e=mK(),n=yK();cH=function(n){switch(n.graph().ranker){case"network-simplex":default:i(n);break;case"tight-tree":!function(n){t(n),e(n)}(n);break;case"longest-path":r(n)}};var r=t;function i(t){n(t)}return cH}function bK(){if(hH)return uH;hH=1;var t=hK();return uH=function(e){var n=function(e){var n={},r=0;function i(o){var A=r;t.forEach(e.children(o),i),n[o]={low:A,lim:r++}}return t.forEach(e.children(),i),n}(e);t.forEach(e.graph().dummyChains,function(t){for(var r=e.node(t),i=r.edgeObj,o=function(t,e,n,r){var i,o,A=[],s=[],a=Math.min(e[n].low,e[r].low),c=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),A.push(i)}while(i&&(e[i].low>a||c>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:A.concat(s.reverse()),lca:o}}(e,n,i.v,i.w),A=o.path,s=o.lca,a=0,c=A[a],l=!0;t!==i.w;){if(r=e.node(t),l){for(;(c=A[a])!==s&&e.node(c).maxRank<r.rank;)a++;c===s&&(l=!1)}if(!l){for(;a<A.length-1&&e.node(c=A[a+1]).minRank<=r.rank;)a++;c=A[a]}e.setParent(t,c),t=e.successors(t)[0]}})},uH}function BK(){if(fH)return dH;fH=1;var t=hK(),e=gK();function n(r,i,o,A,s,a,c){var l=r.children(c);if(l.length){var u=e.addBorderNode(r,"_bt"),h=e.addBorderNode(r,"_bb"),d=r.node(c);r.setParent(u,c),d.borderTop=u,r.setParent(h,c),d.borderBottom=h,t.forEach(l,function(t){n(r,i,o,A,s,a,t);var e=r.node(t),l=e.borderTop?e.borderTop:t,d=e.borderBottom?e.borderBottom:t,f=e.borderTop?A:2*A,g=l!==d?1:s-a[c]+1;r.setEdge(u,l,{weight:f,minlen:g,nestingEdge:!0}),r.setEdge(d,h,{weight:f,minlen:g,nestingEdge:!0})}),r.parent(c)||r.setEdge(i,u,{weight:0,minlen:s+a[c]})}else c!==i&&r.setEdge(i,c,{weight:0,minlen:o})}return dH={run:function(r){var i=e.addDummyNode(r,"root",{},"_root"),o=function(e){var n={};function r(i,o){var A=e.children(i);A&&A.length&&t.forEach(A,function(t){r(t,o+1)}),n[i]=o}return t.forEach(e.children(),function(t){r(t,1)}),n}(r),A=t.max(t.values(o))-1,s=2*A+1;r.graph().nestingRoot=i,t.forEach(r.edges(),function(t){r.edge(t).minlen*=s});var a=function(e){return t.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}(r)+1;t.forEach(r.children(),function(t){n(r,i,s,a,A,o,t)}),r.graph().nodeRankFactor=s},cleanup:function(e){var n=e.graph();e.removeNode(n.nestingRoot),delete n.nestingRoot,t.forEach(e.edges(),function(t){e.edge(t).nestingEdge&&e.removeEdge(t)})}},dH}function EK(){if(mH)return vH;mH=1;var t=hK();function e(e){t.forEach(e.nodes(),function(t){n(e.node(t))}),t.forEach(e.edges(),function(t){n(e.edge(t))})}function n(t){var e=t.width;t.width=t.height,t.height=e}function r(t){t.y=-t.y}function i(t){var e=t.x;t.x=t.y,t.y=e}return vH={adjust:function(t){var n=t.graph().rankdir.toLowerCase();"lr"!==n&&"rl"!==n||e(t)},undo:function(n){var o=n.graph().rankdir.toLowerCase();"bt"!==o&&"rl"!==o||function(e){t.forEach(e.nodes(),function(t){r(e.node(t))}),t.forEach(e.edges(),function(n){var i=e.edge(n);t.forEach(i.points,r),t.has(i,"y")&&r(i)})}(n);"lr"!==o&&"rl"!==o||(!function(e){t.forEach(e.nodes(),function(t){i(e.node(t))}),t.forEach(e.edges(),function(n){var r=e.edge(n);t.forEach(r.points,i),t.has(r,"x")&&i(r)})}(n),e(n))}},vH}function xK(){if(MH)return CH;MH=1;var t=hK();return CH=function(e,n){var r={};return t.forEach(e,function(e,n){var i=r[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:n};t.isUndefined(e.barycenter)||(i.barycenter=e.barycenter,i.weight=e.weight)}),t.forEach(n.edges(),function(e){var n=r[e.v],i=r[e.w];t.isUndefined(n)||t.isUndefined(i)||(i.indegree++,n.out.push(r[e.w]))}),function(e){var n=[];function r(e){return function(n){n.merged||(t.isUndefined(n.barycenter)||t.isUndefined(e.barycenter)||n.barycenter>=e.barycenter)&&function(t,e){var n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(e,n)}}function i(t){return function(n){n.in.push(t),0===--n.indegree&&e.push(n)}}for(;e.length;){var o=e.pop();n.push(o),t.forEach(o.in.reverse(),r(o)),t.forEach(o.out,i(o))}return t.map(t.filter(n,function(t){return!t.merged}),function(e){return t.pick(e,["vs","i","barycenter","weight"])})}(t.filter(r,function(t){return!t.indegree}))},CH}function CK(){if(QH)return SH;QH=1;var t=hK(),e=function(){if(xH)return EH;xH=1;var t=hK();return EH=function(e,n){return t.map(n,function(n){var r=e.inEdges(n);if(r.length){var i=t.reduce(r,function(t,n){var r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}return{v:n}})},EH}(),n=xK(),r=function(){if(kH)return FH;kH=1;var t=hK(),e=gK();function n(e,n,r){for(var i;n.length&&(i=t.last(n)).i<=r;)n.pop(),e.push(i.vs),r++;return r}return FH=function(r,i){var o,A=e.partition(r,function(e){return t.has(e,"barycenter")}),s=A.lhs,a=t.sortBy(A.rhs,function(t){return-t.i}),c=[],l=0,u=0,h=0;s.sort((o=!!i,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:o?e.i-t.i:t.i-e.i})),h=n(c,a,h),t.forEach(s,function(t){h+=t.vs.length,c.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,h=n(c,a,h)});var d={vs:t.flatten(c,!0)};return u&&(d.barycenter=l/u,d.weight=u),d}}();return SH=function i(o,A,s,a){var c=o.children(A),l=o.node(A),u=l?l.borderLeft:void 0,h=l?l.borderRight:void 0,d={};u&&(c=t.filter(c,function(t){return t!==u&&t!==h}));var f=e(o,c);t.forEach(f,function(e){if(o.children(e.v).length){var n=i(o,e.v,s,a);d[e.v]=n,t.has(n,"barycenter")&&(r=e,A=n,t.isUndefined(r.barycenter)?(r.barycenter=A.barycenter,r.weight=A.weight):(r.barycenter=(r.barycenter*r.weight+A.barycenter*A.weight)/(r.weight+A.weight),r.weight+=A.weight))}var r,A});var g=n(f,s);!function(e,n){t.forEach(e,function(e){e.vs=t.flatten(e.vs.map(function(t){return n[t]?n[t].vs:t}),!0)})}(g,d);var p=r(g,a);if(u&&(p.vs=t.flatten([u,p.vs,h],!0),o.predecessors(u).length)){var v=o.node(o.predecessors(u)[0]),m=o.node(o.predecessors(h)[0]);t.has(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+v.order+m.order)/(p.weight+2),p.weight+=2}return p},SH}function MK(){if(NH)return UH;NH=1;var t=hK(),e=IG().Graph;return UH=function(n,r,i){var o=function(e){var n;for(;e.hasNode(n=t.uniqueId("_root")););return n}(n),A=new e({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(t){return n.node(t)});return t.forEach(n.nodes(),function(e){var s=n.node(e),a=n.parent(e);(s.rank===r||s.minRank<=r&&r<=s.maxRank)&&(A.setNode(e),A.setParent(e,a||o),t.forEach(n[i](e),function(r){var i=r.v===e?r.w:r.v,o=A.edge(i,e),s=t.isUndefined(o)?0:o.weight;A.setEdge(i,e,{weight:n.edge(r).weight+s})}),t.has(s,"minRank")&&A.setNode(e,{borderLeft:s.borderLeft[r],borderRight:s.borderRight[r]}))}),A},UH}function FK(){if(LH)return IH;LH=1;var t=hK(),e=function(){if(wH)return yH;wH=1;var t=hK();return yH=function(e){var n={},r=t.filter(e.nodes(),function(t){return!e.children(t).length}),i=t.max(t.map(r,function(t){return e.node(t).rank})),o=t.map(t.range(i+1),function(){return[]});function A(r){if(!t.has(n,r)){n[r]=!0;var i=e.node(r);o[i.rank].push(r),t.forEach(e.successors(r),A)}}var s=t.sortBy(r,function(t){return e.node(t).rank});return t.forEach(s,A),o},yH}(),n=function(){if(BH)return bH;BH=1;var t=hK();function e(e,n,r){for(var i=t.zipObject(r,t.map(r,function(t,e){return e})),o=t.flatten(t.map(n,function(n){return t.sortBy(t.map(e.outEdges(n),function(t){return{pos:i[t.w],weight:e.edge(t).weight}}),"pos")}),!0),A=1;A<r.length;)A<<=1;var s=2*A-1;A-=1;var a=t.map(new Array(s),function(){return 0}),c=0;return t.forEach(o.forEach(function(t){var e=t.pos+A;a[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=a[e+1]),a[e=e-1>>1]+=t.weight;c+=t.weight*n})),c}return bH=function(t,n){for(var r=0,i=1;i<n.length;++i)r+=e(t,n[i-1],n[i]);return r},bH}(),r=CK(),i=MK(),o=function(){if(OH)return TH;OH=1;var t=hK();return TH=function(e,n,r){var i,o={};t.forEach(r,function(t){for(var r,A,s=e.parent(t);s;){if((r=e.parent(s))?(A=o[r],o[r]=s):(A=i,i=s),A&&A!==s)return void n.setEdge(A,s);s=r}})},TH}(),A=IG().Graph,s=gK();function a(e,n,r){return t.map(n,function(t){return i(e,t,r)})}function c(e,n){var i=new A;t.forEach(e,function(e){var A=e.graph().root,s=r(e,A,i,n);t.forEach(s.vs,function(t,n){e.node(t).order=n}),o(e,i,s.vs)})}function l(e,n){t.forEach(n,function(n){t.forEach(n,function(t,n){e.node(t).order=n})})}return IH=function(r){var i=s.maxRank(r),o=a(r,t.range(1,i+1),"inEdges"),A=a(r,t.range(i-1,-1,-1),"outEdges"),u=e(r);l(r,u);for(var h,d=Number.POSITIVE_INFINITY,f=0,g=0;g<4;++f,++g){c(f%2?o:A,f%4>=2),u=s.buildLayerMatrix(r);var p=n(r,u);p<d&&(g=0,h=t.cloneDeep(u),d=p)}l(r,h)},IH}function kK(){if(DH)return PH;DH=1;var t=hK(),e=IG().Graph,n=gK();function r(e,n){var r={};return t.reduce(n,function(n,i){var A=0,s=0,a=n.length,c=t.last(i);return t.forEach(i,function(n,l){var u=function(e,n){if(e.node(n).dummy)return t.find(e.predecessors(n),function(t){return e.node(t).dummy})}(e,n),h=u?e.node(u).order:a;(u||n===c)&&(t.forEach(i.slice(s,l+1),function(n){t.forEach(e.predecessors(n),function(t){var i=e.node(t),s=i.order;!(s<A||h<s)||i.dummy&&e.node(n).dummy||o(r,t,n)})}),s=l+1,A=h)}),i}),r}function i(e,n){var r={};function i(n,i,A,s,a){var c;t.forEach(t.range(i,A),function(i){c=n[i],e.node(c).dummy&&t.forEach(e.predecessors(c),function(t){var n=e.node(t);n.dummy&&(n.order<s||n.order>a)&&o(r,t,c)})})}return t.reduce(n,function(n,r){var o,A=-1,s=0;return t.forEach(r,function(t,a){if("border"===e.node(t).dummy){var c=e.predecessors(t);c.length&&(o=e.node(c[0]).order,i(r,s,a,A,o),s=a,A=o)}i(r,s,r.length,o,n.length)}),r}),r}function o(t,e,n){if(e>n){var r=e;e=n,n=r}var i=t[e];i||(t[e]=i={}),i[n]=!0}function A(e,n,r){if(n>r){var i=n;n=r,r=i}return t.has(e[n],r)}function s(e,n,r,i){var o={},s={},a={};return t.forEach(n,function(e){t.forEach(e,function(t,e){o[t]=t,s[t]=t,a[t]=e})}),t.forEach(n,function(e){var n=-1;t.forEach(e,function(e){var c=i(e);if(c.length){c=t.sortBy(c,function(t){return a[t]});for(var l=(c.length-1)/2,u=Math.floor(l),h=Math.ceil(l);u<=h;++u){var d=c[u];s[e]===e&&n<a[d]&&!A(r,e,d)&&(s[d]=e,s[e]=o[e]=o[d],n=a[d])}}})}),{root:o,align:s}}function a(n,r,i,o,A){var s={},a=function(n,r,i,o){var A=new e,s=n.graph(),a=function(e,n,r){return function(i,o,A){var s,a=i.node(o),c=i.node(A),l=0;if(l+=a.width/2,t.has(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":s=-a.width/2;break;case"r":s=a.width/2}if(s&&(l+=r?s:-s),s=0,l+=(a.dummy?n:e)/2,l+=(c.dummy?n:e)/2,l+=c.width/2,t.has(c,"labelpos"))switch(c.labelpos.toLowerCase()){case"l":s=c.width/2;break;case"r":s=-c.width/2}return s&&(l+=r?s:-s),s=0,l}}(s.nodesep,s.edgesep,o);return t.forEach(r,function(e){var r;t.forEach(e,function(t){var e=i[t];if(A.setNode(e),r){var o=i[r],s=A.edge(o,e);A.setEdge(o,e,Math.max(a(n,t,r),s||0))}r=t})}),A}(n,r,i,A),c=A?"borderLeft":"borderRight";function l(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}return l(function(t){s[t]=a.inEdges(t).reduce(function(t,e){return Math.max(t,s[e.v]+a.edge(e))},0)},a.predecessors.bind(a)),l(function(t){var e=a.outEdges(t).reduce(function(t,e){return Math.min(t,s[e.w]-a.edge(e))},Number.POSITIVE_INFINITY),r=n.node(t);e!==Number.POSITIVE_INFINITY&&r.borderType!==c&&(s[t]=Math.max(s[t],e))},a.successors.bind(a)),t.forEach(o,function(t){s[t]=s[i[t]]}),s}function c(e,n){return t.minBy(t.values(n),function(n){var r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return t.forIn(n,function(t,n){var o=function(t,e){return t.node(e).width}(e,n)/2;r=Math.max(t+o,r),i=Math.min(t-o,i)}),r-i})}function l(e,n){var r=t.values(n),i=t.min(r),o=t.max(r);t.forEach(["u","d"],function(r){t.forEach(["l","r"],function(A){var s,a=r+A,c=e[a];if(c!==n){var l=t.values(c);(s="l"===A?i-t.min(l):o-t.max(l))&&(e[a]=t.mapValues(c,function(t){return t+s}))}})})}function u(e,n){return t.mapValues(e.ul,function(r,i){if(n)return e[n.toLowerCase()][i];var o=t.sortBy(t.map(e,i));return(o[1]+o[2])/2})}return PH={positionX:function(e){var o,A=n.buildLayerMatrix(e),h=t.merge(r(e,A),i(e,A)),d={};t.forEach(["u","d"],function(n){o="u"===n?A:t.values(A).reverse(),t.forEach(["l","r"],function(r){"r"===r&&(o=t.map(o,function(e){return t.values(e).reverse()}));var i=("u"===n?e.predecessors:e.successors).bind(e),A=s(e,o,h,i),c=a(e,o,A.root,A.align,"r"===r);"r"===r&&(c=t.mapValues(c,function(t){return-t})),d[n+r]=c})});var f=c(e,d);return l(d,f),u(d,e.graph().align)},findType1Conflicts:r,findType2Conflicts:i,addConflict:o,hasConflict:A,verticalAlignment:s,horizontalCompaction:a,alignCoordinates:l,findSmallestWidthAlignment:c,balance:u},PH}function SK(){if(HH)return RH;HH=1;var t=hK(),e=gK(),n=kK().positionX;return RH=function(r){r=e.asNonCompoundGraph(r),function(n){var r=e.buildLayerMatrix(n),i=n.graph().ranksep,o=0;t.forEach(r,function(e){var r=t.max(t.map(e,function(t){return n.node(t).height}));t.forEach(e,function(t){n.node(t).y=o+r/2}),o+=r+i})}(r),t.forEach(n(r),function(t,e){r.node(e).x=t})},RH}function QK(){if(GH)return _H;GH=1;var t=hK(),e=fK(),n=pK(),r=wK(),i=gK().normalizeRanks,o=bK(),A=gK().removeEmptyRanks,s=BK(),a=function(){if(pH)return gH;pH=1;var t=hK(),e=gK();function n(t,n,r,i,o,A){var s={width:0,height:0,rank:A,borderType:n},a=o[n][A-1],c=e.addDummyNode(t,"border",s,r);o[n][A]=c,t.setParent(c,i),a&&t.setEdge(a,c,{weight:1})}return gH=function(e){t.forEach(e.children(),function r(i){var o=e.children(i),A=e.node(i);if(o.length&&t.forEach(o,r),t.has(A,"minRank")){A.borderLeft=[],A.borderRight=[];for(var s=A.minRank,a=A.maxRank+1;s<a;++s)n(e,"borderLeft","_bl",i,A,s),n(e,"borderRight","_br",i,A,s)}})},gH}(),c=EK(),l=FK(),u=SK(),h=gK(),d=IG().Graph;_H=function(x,C){var M=C&&C.debugTiming?h.time:h.notime;M("layout",function(){var C=M(" buildLayoutGraph",function(){return function(e){var n=new d({multigraph:!0,compound:!0}),r=E(e.graph());return n.setGraph(t.merge({},g,B(r,f),t.pick(r,p))),t.forEach(e.nodes(),function(r){var i=E(e.node(r));n.setNode(r,t.defaults(B(i,v),m)),n.setParent(r,e.parent(r))}),t.forEach(e.edges(),function(r){var i=E(e.edge(r));n.setEdge(r,t.merge({},w,B(i,y),t.pick(i,b)))}),n}(x)});M(" runLayout",function(){!function(d,f){f(" makeSpaceForEdgeLabels",function(){!function(e){var n=e.graph();n.ranksep/=2,t.forEach(e.edges(),function(t){var r=e.edge(t);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===n.rankdir||"BT"===n.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)})}(d)}),f(" removeSelfEdges",function(){!function(e){t.forEach(e.edges(),function(t){if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}(d)}),f(" acyclic",function(){e.run(d)}),f(" nestingGraph.run",function(){s.run(d)}),f(" rank",function(){r(h.asNonCompoundGraph(d))}),f(" injectEdgeLabelProxies",function(){!function(e){t.forEach(e.edges(),function(t){var n=e.edge(t);if(n.width&&n.height){var r=e.node(t.v),i={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};h.addDummyNode(e,"edge-proxy",i,"_ep")}})}(d)}),f(" removeEmptyRanks",function(){A(d)}),f(" nestingGraph.cleanup",function(){s.cleanup(d)}),f(" normalizeRanks",function(){i(d)}),f(" assignRankMinMax",function(){!function(e){var n=0;t.forEach(e.nodes(),function(r){var i=e.node(r);i.borderTop&&(i.minRank=e.node(i.borderTop).rank,i.maxRank=e.node(i.borderBottom).rank,n=t.max(n,i.maxRank))}),e.graph().maxRank=n}(d)}),f(" removeEdgeLabelProxies",function(){!function(e){t.forEach(e.nodes(),function(t){var n=e.node(t);"edge-proxy"===n.dummy&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}(d)}),f(" normalize.run",function(){n.run(d)}),f(" parentDummyChains",function(){o(d)}),f(" addBorderSegments",function(){a(d)}),f(" order",function(){l(d)}),f(" insertSelfEdges",function(){!function(e){var n=h.buildLayerMatrix(e);t.forEach(n,function(n){var r=0;t.forEach(n,function(n,i){var o=e.node(n);o.order=i+r,t.forEach(o.selfEdges,function(t){h.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:o.rank,order:i+ ++r,e:t.e,label:t.label},"_se")}),delete o.selfEdges})})}(d)}),f(" adjustCoordinateSystem",function(){c.adjust(d)}),f(" position",function(){u(d)}),f(" positionSelfEdges",function(){!function(e){t.forEach(e.nodes(),function(t){var n=e.node(t);if("selfedge"===n.dummy){var r=e.node(n.e.v),i=r.x+r.width/2,o=r.y,A=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*A/3,y:o-s},{x:i+5*A/6,y:o-s},{x:i+A,y:o},{x:i+5*A/6,y:o+s},{x:i+2*A/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}})}(d)}),f(" removeBorderNodes",function(){!function(e){t.forEach(e.nodes(),function(n){if(e.children(n).length){var r=e.node(n),i=e.node(r.borderTop),o=e.node(r.borderBottom),A=e.node(t.last(r.borderLeft)),s=e.node(t.last(r.borderRight));r.width=Math.abs(s.x-A.x),r.height=Math.abs(o.y-i.y),r.x=A.x+r.width/2,r.y=i.y+r.height/2}}),t.forEach(e.nodes(),function(t){"border"===e.node(t).dummy&&e.removeNode(t)})}(d)}),f(" normalize.undo",function(){n.undo(d)}),f(" fixupEdgeLabelCoords",function(){!function(e){t.forEach(e.edges(),function(n){var r=e.edge(n);if(t.has(r,"x"))switch("l"!==r.labelpos&&"r"!==r.labelpos||(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}})}(d)}),f(" undoCoordinateSystem",function(){c.undo(d)}),f(" translateGraph",function(){!function(e){var n=Number.POSITIVE_INFINITY,r=0,i=Number.POSITIVE_INFINITY,o=0,A=e.graph(),s=A.marginx||0,a=A.marginy||0;function c(t){var e=t.x,A=t.y,s=t.width,a=t.height;n=Math.min(n,e-s/2),r=Math.max(r,e+s/2),i=Math.min(i,A-a/2),o=Math.max(o,A+a/2)}t.forEach(e.nodes(),function(t){c(e.node(t))}),t.forEach(e.edges(),function(n){var r=e.edge(n);t.has(r,"x")&&c(r)}),n-=s,i-=a,t.forEach(e.nodes(),function(t){var r=e.node(t);r.x-=n,r.y-=i}),t.forEach(e.edges(),function(r){var o=e.edge(r);t.forEach(o.points,function(t){t.x-=n,t.y-=i}),t.has(o,"x")&&(o.x-=n),t.has(o,"y")&&(o.y-=i)}),A.width=r-n+s,A.height=o-i+a}(d)}),f(" assignNodeIntersects",function(){!function(e){t.forEach(e.edges(),function(t){var n,r,i=e.edge(t),o=e.node(t.v),A=e.node(t.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=A,r=o),i.points.unshift(h.intersectRect(o,n)),i.points.push(h.intersectRect(A,r))})}(d)}),f(" reversePoints",function(){!function(e){t.forEach(e.edges(),function(t){var n=e.edge(t);n.reversed&&n.points.reverse()})}(d)}),f(" acyclic.undo",function(){e.undo(d)})}(C,M)}),M(" updateInputGraph",function(){!function(e,n){t.forEach(e.nodes(),function(t){var r=e.node(t),i=n.node(t);r&&(r.x=i.x,r.y=i.y,n.children(t).length&&(r.width=i.width,r.height=i.height))}),t.forEach(e.edges(),function(r){var i=e.edge(r),o=n.edge(r);i.points=o.points,t.has(o,"x")&&(i.x=o.x,i.y=o.y)}),e.graph().width=n.graph().width,e.graph().height=n.graph().height}(x,C)})})};var f=["nodesep","edgesep","ranksep","marginx","marginy"],g={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},p=["acyclicer","ranker","rankdir","align"],v=["width","height"],m={width:0,height:0},y=["minlen","weight","width","height","labeloffset"],w={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},b=["labelpos"];function B(e,n){return t.mapValues(t.pick(e,n),Number)}function E(e){var n={};return t.forEach(e,function(t,e){n[e.toLowerCase()]=t}),n}return _H}function UK(){if(jH)return KH;jH=1;var t=hK(),e=gK(),n=IG().Graph;return KH={debugOrdering:function(r){var i=e.buildLayerMatrix(r),o=new n({compound:!0,multigraph:!0}).setGraph({});return t.forEach(r.nodes(),function(t){o.setNode(t,{label:t}),o.setParent(t,"layer"+r.node(t).rank)}),t.forEach(r.edges(),function(t){o.setEdge(t.v,t.w,{},t.name)}),t.forEach(i,function(e,n){var r="layer"+n;o.setNode(r,{rank:"same"}),t.reduce(e,function(t,e){return o.setEdge(t,e,{style:"invis"}),e})}),o}},KH}var NK=YH?WH:(YH=1,WH={graphlib:IG(),layout:QK(),debug:UK(),util:{time:gK().time,notime:gK().notime},version:VH?zH:(VH=1,zH="0.8.5")}),TK=BU(NK);var OK=Object.prototype.hasOwnProperty,IK=function(t,e){if(null===t||!Qk(t))return{};var n={};return function(t,e){var n,r;if(t)if(gM(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var A in t)if(t.hasOwnProperty(A)&&!1===e(t[A],A))break}(e,function(e){OK.call(t,e)&&(n[e]=t[e])}),n};class LK extends EC{constructor(){super(...arguments),this.id="dagre",this.isCompoundGraph=null,this.config={graphAttributes:["rankdir","align","nodesep","edgesep","ranksep","marginx","marginy","acyclicer","ranker"],nodeAttributes:["width","height"],edgeAttributes:["minlen","weight","width","height","labelpos","labeloffset"]}}getDefaultOptions(){return{directed:!0,multigraph:!0,rankdir:"TB",align:void 0,nodesep:50,edgesep:10,ranksep:50,marginx:0,marginy:0,acyclicer:void 0,ranker:"network-simplex",nodeSize:[0,0],edgeMinLen:1,edgeWeight:1,edgeLabelSize:[0,0],edgeLabelPos:"r",edgeLabelOffset:10}}layout(){return mx(this,0,void 0,function*(){const t=new NK.graphlib.Graph({directed:!!this.options.directed,multigraph:!!this.options.multigraph,compound:this.isCompound()});t.setGraph(IK(this.options,this.config.graphAttributes)),t.setDefaultEdgeLabel(()=>({}));const e=Yx(this.options.nodeSize,0);this.model.forEachNode(n=>{const r=n._original,[i,o]=Gx(e(r)),A={width:i,height:o};if(t.setNode(String(n.id),A),this.isCompound()){if(Kx(n.parentId))return;t.setParent(String(n.id),String(n.parentId))}});const{edgeLabelSize:n,edgeLabelOffset:r,edgeLabelPos:i,edgeMinLen:o,edgeWeight:A}=this.options,s=Yx(n,0,"edge"),a=Wx(r,10,"edge"),c="string"==typeof i?()=>i:Vx(i,["edge"]),l=Wx(o,1,"edge"),u=Wx(A,1,"edge");this.model.forEachEdge(e=>{const n=e._original,[r,i]=Gx(s(n)),o={width:r,height:i,labelpos:c(n),labeloffset:a(n),minlen:l(n),weight:u(n)};t.setEdge(String(e.source),String(e.target),o,String(e.id))}),TK.layout(t),this.model.forEachNode(e=>{const n=t.node(String(e.id));n&&(e.x=n.x,e.y=n.y,e.size=[n.width,n.height])}),this.model.forEachEdge(e=>{const n=t.edge(String(e.source),String(e.target),String(e.id));if(!n)return;const{width:r,height:i,weight:o,minlen:A,labelpos:s,labeloffset:a,points:c}=n;e.labelSize=[r,i],e.weight=o,e.minLen=A,e.labelPos=s,e.labelOffset=a,e.points=c.map(qx)})})}isCompound(){return null!==this.isCompoundGraph?this.isCompoundGraph:(t=this.options.compound,Sk(t,"Boolean")?this.isCompoundGraph=this.options.compound:(this.isCompoundGraph=this.model.nodes().some(t=>!Kx(t.parentId)),this.isCompoundGraph));var t}}const PK=1e-6;function DK(t){var e;let n=0;if(t.length)for(let e=0;e<t.length;e++){const r=t[e];r&&r.r>n&&(n=r.r)}else if(t.data){n=t.data.r||0;let r=t.next;for(;r;)n=Math.max(n,(null===(e=r.data)||void 0===e?void 0:e.r)||0),r=r.next}t.r=n}function RK(t=1,e=.005,n=2){function r(r,i){!function(t,e,n,r,i=2){const o=e/n,A=t.nodes(),s=A.map((t,e)=>{const{nodeStrength:n,x:r,y:i,z:A,size:s,mass:a}=t;return{x:r,y:i,z:A,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n,mass:a||1}}),a=(2===i?gk(s,t=>t.x,t=>t.y):eS(s,t=>t.x,t=>t.y,t=>t.z)).visitAfter(HK),c=new Map;s.forEach(t=>{c.set(t.id,t),function(t,e,n){e.visit((e,r,i,o,A,s,a)=>_K(e,r,i,o,A,s,a,t,n))}(t,a,i)}),s.map(t=>{const e=t.id;r[e]={x:t.vx/t.mass,y:t.vy/t.mass,z:t.vz/t.mass}})}(r,t,e*e,i,n)}return r.factor=function(e){return arguments.length?(t=e,r):t},r.coulombDisScale=function(t){return arguments.length?(e=t,r):e},r.dimensions=function(t){return arguments.length?(n=t,r):n},r}function HK(t){let e=0,n=0,r=0,i=0,o=0;const A=t.length;if(A){for(let s=0;s<A;s++){const A=t[s];A&&A.weight&&(e+=A.weight,n+=A.x*A.weight,r+=A.y*A.weight,i+=A.z*A.weight,o+=A.size*A.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const _K=(t,e,n,r,i,o,A,s,a)=>{var c;if((null===(c=t.data)||void 0===c?void 0:c.id)===s.id)return;const l=2===a?r:3===a?o:n,u=s.x-t.x||.1,h=s.y-t.y||.1,d=s.z-t.z||.1,f=[u,h,d],g=l-e;let p=0;for(let t=0;t<a;t++)p+=f[t]*f[t];const v=Math.sqrt(p)*p;if(g*g*.81<p){const e=t.weight/v;return s.vx+=u*e,s.vy+=h*e,s.vz+=d*e,!0}if(t.length)return!1;if(t.data!==s){const e=t.data.weight/v;s.vx+=u*e,s.vy+=h*e,s.vz+=d*e}};var GK=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],A=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var A=r[o],s=A.callback;A.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};A(i),A(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();class KK extends GK{constructor(){super(...arguments),this.iteration=0,this.judgingDistance=1/0,this.running=!1,this.tickCallback=null,this.endCallback=null,this.timer=0}initialize(t){this.options=t,this.iteration=0,this.judgingDistance=1/0}on(t,e){return"tick"===t&&(this.tickCallback=e),"end"===t&&(this.endCallback=e),this}tick(t=1){var e;for(let n=0;n<t;n++){const t=this.runOneStep();this.judgingDistance=t,this.iteration++,null===(e=this.tickCallback)||void 0===e||e.call(this)}return this}restart(){if(this.running)return this;const{maxIteration:t=500,minMovement:e=0,animate:n=!0}=this.options;if(!n||"undefined"==typeof window){for(;this.iteration<t&&(this.judgingDistance>e||this.iteration<1);)this.tick(1);return Promise.resolve().then(()=>{var t;null===(t=this.endCallback)||void 0===t||t.call(this)}),this}return this.running=!0,this.timer=window.setInterval(()=>{var n;this.tick(1),(this.iteration>=t||this.judgingDistance<e)&&(this.stop(),null===(n=this.endCallback)||void 0===n||n.call(this))},0),this}stop(){return this.running=!1,this.timer&&(clearInterval(this.timer),this.timer=0),this}}class jK extends KK{constructor(){super(...arguments),this.forces=new Map,this.velMap={}}data(t){return this.model=t,t.forEachNode(t=>{this.velMap[t.id]={x:0,y:0,z:0}}),this}force(t,e){return 1===arguments.length?this.forces.get(t)||null:(null===e?this.forces.delete(t):e&&this.forces.set(t,e),e||null)}runOneStep(){const t={},e=this.model.nodes();if(!e.length)return 0;e.forEach(e=>{t[e.id]={x:0,y:0,z:0}}),this.forces.forEach(e=>{e(this.model,t)}),this.updateVelocity(t);const n=this.updatePosition();return this.monitor(t,e),n}setFixedPosition(t,e){const n=this.model.node(t);if(!n)return;const r=["fx","fy","fz"];if(null===e)return void r.forEach(t=>delete n[t]);e.forEach((t,e)=>{e<r.length&&("number"==typeof t||null===t)&&(n[r[e]]=t)});const i=this.velMap[t];i&&(i.x=0,i.y=0,i.z=0)}updateVelocity(t){const{damping:e=.9,maxSpeed:n=100,interval:r=.02,dimensions:i=2}=this.options;this.model.nodes().forEach(o=>{const A=o.id;let s=(this.velMap[A].x+t[A].x*r)*e,a=(this.velMap[A].y+t[A].y*r)*e,c=3===i?(this.velMap[A].z+t[A].z*r)*e:0;const l=Math.sqrt(s*s+a*a+c*c);if(l>n){const t=n/l;s*=t,a*=t,c*=t}this.velMap[A]={x:s,y:a,z:c}})}updatePosition(){const{distanceThresholdMode:t="mean",interval:e=.02,dimensions:n=2}=this.options,r=this.model.nodes();let i=0,o="max"===t?-1/0:"min"===t?1/0:0;return r.forEach(r=>{const A=r.id;if(_x(r.fx)&&_x(r.fy))return r.x=r.fx,r.y=r.fy,void(3===n&&_x(r.fz)&&(r.z=r.fz));const s=this.velMap[A].x*e,a=this.velMap[A].y*e,c=3===n?this.velMap[A].z*e:0;r.x+=s,r.y+=a,3===n&&(r.z=(r.z||0)+c);const l=Math.sqrt(s*s+a*a+c*c);"max"===t?o=Math.max(o,l):"min"===t?o=Math.min(o,l):i+=l}),"mean"===t?i/r.length:o}monitor(t,e){const{monitor:n,dimensions:r=2}=this.options;if(!n)return;let i=0;e.forEach(e=>{const n=t[e.id],o=n.x*n.x+n.y*n.y+(3===r?n.z*n.z:0);i+=(e.mass||1)*o*.5}),n({energy:i,nodes:e,edges:this.model.edges(),iterations:this.iteration})}}var zK={}.toString,VK=Object.prototype,WK=Object.prototype.hasOwnProperty;function YK(t){if(Kx(t))return!0;if(function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)}(t))return!t.length;var e=function(t){return zK.call(t).replace(/^\[object /,"").replace(/]$/,"")}(t);if("Map"===e||"Set"===e)return!t.size;if(function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||VK)}(t))return!Object.keys(t).length;for(var n in t)if(WK.call(t,n))return!1;return!0}const XK={nodeSize:30,dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,collideStrength:1,preventOverlap:!0,distanceThresholdMode:"mean"};class qK extends xC{constructor(){super(...arguments),this.id="force",this.simulation=null}getDefaultOptions(){return XK}layout(){var t;return mx(this,0,void 0,function*(){const e=this.parseOptions(this.options),{width:n,height:r,dimensions:i}=e;if(this.initializePhysicsData(this.model,e),tC(this.model,n,r,i),!(null===(t=this.model.nodes())||void 0===t?void 0:t.length))return;const o=this.setSimulation(e);return o.data(this.model),o.initialize(e),o.restart(),new Promise(t=>{o.on("end",()=>t())})})}initializePhysicsData(t,e){const{nodeSize:n,getMass:r,nodeStrength:i,edgeStrength:o,linkDistance:A}=e;t.forEachNode(t=>{const e=t._original;t.size=n(e),t.mass=r(e),t.nodeStrength=i(e)}),t.forEachEdge(e=>{const n=e._original;e.edgeStrength=o(n),e.linkDistance=A(n,t.originalNode(e.source),t.originalNode(e.target))})}setSimulation(t){const e=this.simulation||new jK;return this.simulation||(this.simulation=e.on("tick",()=>{var e;null===(e=t.onTick)||void 0===e||e.call(t,this)})),this.setupRepulsiveForce(e,t),this.setupAttractiveForce(e,t),this.setupCollideForce(e,t),this.setupGravityForce(e,t),this.setupCentripetalForce(e,t),e}setupRepulsiveForce(t,e){const{factor:n,coulombDisScale:r,dimensions:i}=e;let o=t.force("repulsive");o||(o=RK(n,r,i),t.force("repulsive",o)),o.factor&&o.factor(n),o.coulombDisScale&&o.coulombDisScale(r),o.dimensions&&o.dimensions(i)}setupAttractiveForce(t,e){const{dimensions:n,preventOverlap:r}=e;if((this.model.edges()||[]).length>0){let e=t.force("attractive");e||(e=function(t=2){let e=!1;function n(e,n){e.forEachEdge(r=>{var i,o;const{source:A,target:s}=r,a=e.node(A),c=e.node(s);if(!a||!c)return;let l=c.x-a.x,u=c.y-a.y,h=3===t?(null!==(i=c.z)&&void 0!==i?i:0)-(null!==(o=a.z)&&void 0!==o?o:0):0;l||u||(l=.01,u=.01,3!==t||h||(h=.01));const d=Math.sqrt(l*l+u*u+h*h);if(d<Number(a.size)+Number(c.size))return;const f=l/d,g=u/d,p=h/d,{linkDistance:v=200,edgeStrength:m=200}=r,y=(v-d)*m,w=1/(a.mass||1),b=1/(c.mass||1),B=f*y,E=g*y,x=p*y;n[A].x-=B*w,n[A].y-=E*w,n[A].z-=x*w,n[s].x+=B*b,n[s].y+=E*b,n[s].z+=x*b})}return n.dimensions=function(e){return arguments.length?(t=e,n):t},n.preventOverlap=function(t){return arguments.length?(e=t,n):e},n}(n),t.force("attractive",e)),e.dimensions&&e.dimensions(n),e.preventOverlap&&e.preventOverlap(r)}else t.force("attractive",null)}setupGravityForce(t,e){const{center:n,gravity:r,getCenter:i}=e;if(r){let e=t.force("gravity");e||(e=function(t=[0,0,0],e=10){let n;function r(r,i){r.nodes()&&r.forEachNode(o=>{const{id:A,mass:s,x:a,y:c,z:l=0}=o;let u=0,h=0,d=0,f=e;const g=r.degree(A),p=null==n?void 0:n(o,g);if(p){const[t,e,n]=p;u=a-t,h=c-e,f=n}else u=a-t[0],h=c-t[1],d=l-(t[2]||0);f&&(i[A].x-=f*u/s,i[A].y-=f*h/s,i[A].z-=f*d/s)})}return r.center=function(e){return arguments.length?(t=e,r):t},r.gravity=function(t){return arguments.length?(e=t,r):e},r.getCenter=function(t){return arguments.length?(n=t,r):n},r}(n,r),t.force("gravity",e)),e.center&&e.center(n),e.gravity&&e.gravity(r),e.getCenter&&e.getCenter(i)}else t.force("gravity",null)}setupCollideForce(t,e){const{preventOverlap:n,collideStrength:r=1,dimensions:i}=e;if(n&&r){let e=t.force("collide");e||(e=function(t=2){let e=1;function n(n,r){const i=n.nodes();if(i.length<2||e<=0)return;if(2===t){const t=i.map((t,e)=>({id:t.id,index:e,x:t.x,y:t.y,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy})),e=gk(t,t=>t.x,t=>t.y).visitAfter(DK);for(const n of t)e.visit((t,e,i,A,s)=>{const a=t.r||0,c=n.r+a;if(e>n.x+c||A<n.x-c||i>n.y+c||s<n.y-c)return!0;if(!t.data)return!1;let l=t;do{const t=l.data;t&&t.index>n.index&&o(n,t,r),l=l.next}while(l);return!1});return}const s=i.map((t,e)=>{var n;return{id:t.id,index:e,x:t.x,y:t.y,z:null!==(n=t.z)&&void 0!==n?n:0,r:Number(t.size)/2,mass:t.mass||1,fx:t.fx,fy:t.fy,fz:t.fz}});for(let t=0;t<s.length;t++)for(let e=t+1;e<s.length;e++)A(s[t],s[e],r)}function r(t){return _x(t.fx)&&_x(t.fy)?0:1/(t.mass||1)}function i(t){return _x(t.fx)&&_x(t.fy)&&_x(t.fz)?0:1/(t.mass||1)}function o(t,n,i){let o=t.x-n.x,A=t.y-n.y,s=Math.hypot(o,A);const a=t.r+n.r;if(s>=a)return;s<PK&&(o=t.index<n.index?PK:-1e-6,A=0,s=Math.abs(o));const c=o/s,l=A/s,u=(a-s)*e*500,h=r(t),d=r(n);h&&(i[t.id].x+=c*u*h,i[t.id].y+=l*u*h),d&&(i[n.id].x-=c*u*d,i[n.id].y-=l*u*d)}function A(t,n,r){let o=t.x-n.x,A=t.y-n.y,s=t.z-n.z,a=Math.sqrt(o*o+A*A+s*s);const c=t.r+n.r;if(a>=c)return;a<PK&&(o=t.index<n.index?PK:-1e-6,A=0,s=0,a=Math.abs(o));const l=o/a,u=A/a,h=s/a,d=(c-a)*e*500,f=i(t),g=i(n);f&&(r[t.id].x+=l*d*f,r[t.id].y+=u*d*f,r[t.id].z+=h*d*f),g&&(r[n.id].x-=l*d*g,r[n.id].y-=u*d*g,r[n.id].z-=h*d*g)}return n.dimensions=function(e){return arguments.length?(t=e,n):t},n.strength=function(t){return arguments.length?(e=t,n):e},n}(i),t.force("collide",e)),e.strength&&e.strength(r),e.dimensions&&e.dimensions(i)}else t.force("collide",null)}setupCentripetalForce(t,e){const{centripetalOptions:n,width:r,height:i}=e;if(n){let e=t.force("centripetal");e||(e=function(){let t,e=800,n=600;function r(r,i){if(!t)return;const{leaf:o,single:A,others:s,center:a}=t,c=r.nodes(),l=r.edges(),u=c.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}})),h=l.map(t=>Object.assign(Object.assign({},t),{data:t.data||{}}));r.forEachNode(t=>{const{id:c,mass:l,x:d,y:f,z:g=0,data:p}=t,v=r.degree(c,"in"),m=r.degree(c,"out"),y=r.degree(c,"both"),w=Object.assign(Object.assign({},t),{data:p||{}}),{x:b,y:B,z:E,centerStrength:x}=(null==a?void 0:a(w,u,h,e,n))||{x:0,y:0,z:0,centerStrength:0};if(!_x(b)||!_x(B))return;const C=(d-b)/l,M=(f-B)/l,F=(g-(E||0))/l;if(x&&(i[c].x-=x*C,i[c].y-=x*M,i[c].z-=x*F),0===y){const t=A(w);if(!t)return;return i[c].x-=t*C,i[c].y-=t*M,void(i[c].z-=t*F)}if(0===v||0===m){const t=o(w,u,h);if(!t)return;return i[c].x-=t*C,i[c].y-=t*M,void(i[c].z-=t*F)}const k=s(w);k&&(i[c].x-=k*C,i[c].y-=k*M,i[c].z-=k*F)})}return r.options=function(e){return arguments.length?(t=e,r):t},r.width=function(t){return arguments.length?(e=t,r):e},r.height=function(t){return arguments.length?(n=t,r):n},r}(),t.force("centripetal",e)),e.options&&e.options(n),e.width&&e.width(r),e.height&&e.height(i)}else t.force("centripetal",null)}parseOptions(t){const e=Object.assign(Object.assign({},t),kF(t));if(e.nodeClusterBy&&(e.nodeClusterBy=Vx(e.nodeClusterBy,["node"])),t.getMass?e.getMass=Wx(t.getMass,1):e.getMass=t=>{if(!t)return 1;const e=this.model.degree(t.id,"both");return!e||e<5?1:5*e*1},t.getCenter){const n=["node","degree"];e.getCenter=Vx(t.getCenter,n)}const n=Xx(t.nodeSize,t.nodeSpacing);return e.nodeSize=t=>{if(!t)return 0;const[e,r,i]=n(t);return Math.max(e,r,i)},e.linkDistance=t.linkDistance?Vx(t.linkDistance,["edge","source","target"]):(t,e,n)=>1+t.nodeSize(e)+t.nodeSize(n),e.nodeStrength=Wx(t.nodeStrength,1),e.edgeStrength=Wx(t.edgeStrength,1,"edge"),e.clusterNodeStrength=Wx(t.clusterNodeStrength,1),this.formatCentripetal(e),e}formatCentripetal(t){var e,n;const{dimensions:r,centripetalOptions:i,center:o,leafCluster:A,clustering:s,nodeClusterBy:a}=t,c=Vx(null==i?void 0:i.leaf,["node","nodes","edges"]),l=Wx(null==i?void 0:i.single,2),u=Wx(null==i?void 0:i.others,1),h=Vx(null!==(e=null==i?void 0:i.center)&&void 0!==e?e:t=>({x:o[0],y:o[1],z:3===r?o[2]:void 0}),["node","nodes","edges","width","height"]),d=Object.assign(Object.assign({},i),{leaf:c,single:l,others:u,center:h});let f,g;if(i&&(t.centripetalOptions=d),A&&a&&(f=this.getSameTypeLeafMap(a),g=Array.from(new Set(null===(n=this.model.nodes())||void 0===n?void 0:n.map(t=>a(t._original))))||[],t.centripetalOptions=Object.assign({},d,{single:()=>100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=f[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==g?void 0:g.length)?1:t.clusterNodeStrength(e)},others:()=>1,center:t=>{const e=this.model.degree(t.id,"both");if(!e)return{x:100,y:100,z:0};let n;if(1===e){const{sameTypeLeaves:e=[]}=f[t.id]||{};1===e.length?n=void 0:e.length>1&&(n=this.getAvgNodePosition(e))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y,z:null==n?void 0:n.z}}})),s&&a){f||(f=this.getSameTypeLeafMap(a));let e=[];YK(e)&&this.model.forEachNode(t=>{const n=a(t._original);n&&!e.includes(n)&&e.push(n)});const n={};e.forEach(t=>{const e=this.model.nodes().filter(e=>a(e._original)===t);n[t]=this.getAvgNodePosition(e)}),t.centripetalOptions=Object.assign(d,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[a(t._original)];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}}getSameTypeLeafMap(t){const e={};return this.model.forEachNode(n=>{1===this.model.degree(n.id,"both")&&(e[n.id]=this.getCoreNodeAndSiblingLeaves(n,t))}),e}getCoreNodeAndSiblingLeaves(t,e){const n=this.model.degree(t.id,"in"),r=this.model.degree(t.id,"out");let i=t,o=[];if(0===n){const e=this.model.successors(t.id);i=this.model.node(e[0]),o=this.model.neighbors(i.id).map(t=>this.model.node(t))}else if(0===r){const e=this.model.predecessors(t.id);i=this.model.node(e[0]),o=this.model.neighbors(i.id).map(t=>this.model.node(t))}o=o.filter(t=>0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out"));const A=e(t._original)||"",s=o.filter(t=>e(t._original)===A&&(0===this.model.degree(t.id,"in")||0===this.model.degree(t.id,"out")));return{coreNode:i,siblingLeaves:o,sameTypeLeaves:s}}getAvgNodePosition(t){const e={x:0,y:0};t.forEach(t=>{e.x+=t.x||0,e.y+=t.y||0});const n=t.length||1;return{x:e.x/n,y:e.y/n}}tick(t=1){return this.simulation&&this.simulation.tick(t),this}stop(){return this.simulation&&this.simulation.stop(),this}restart(){return this.simulation&&this.simulation.restart(),this}setFixedPosition(t,e){return this.simulation&&this.simulation.setFixedPosition(t,e),this}}class $K{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,n=t.ry-this.ry;let r=Math.hypot(e,n);r=r<1e-4?1e-4:r;const i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/e,r=(this.ry*this.mass+t.ry*t.mass)/e,i=this.degree+t.degree;return new $K({rx:n,ry:r,mass:e,degree:i})}}class ZK{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new ZK({xmid:t,ymid:e,length:n})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new ZK({xmid:t,ymid:e,length:n})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new ZK({xmid:t,ymid:e,length:n})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new ZK({xmid:t,ymid:e,length:n})}}class JK{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new JK(this.quad.NW()),this.NE=new JK(this.quad.NE()),this.SW=new JK(this.quad.SW()),this.SE=new JK(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<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))}}}let tj=class extends KK{constructor(){super(...arguments),this.sg=0,this.forces={},this.preForces={},this.bodies={},this.sizes={},this.maxIteration=0}data(t,e){return this.model=t,this.sizes=e,this}initialize(t){super.initialize(t),this.maxIteration=t.maxIteration,this.sg=0,this.initForces()}initForces(){const{model:t,options:e}=this,{kr:n,barnesHut:r}=e,i=t.nodes();this.forces={},this.preForces={},this.bodies={};for(let e=0;e<i.length;e+=1){const o=i[e];if(this.forces[o.id]=[0,0],this.preForces[o.id]=[0,0],r){const r={id:e,rx:o.x,ry:o.y,mass:1,g:n,degree:t.degree(o.id)};this.bodies[o.id]=new $K(r)}}}setFixedPosition(t,e){const n=this.model.node(t);if(!n)return;const r=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<r.length&&("number"==typeof t||null===t)&&(n[r[e]]=t)}):r.forEach(t=>{delete n[t]})}isNodeFixed(t){return _x(t.fx)&&_x(t.fy)}syncFixedPositions(){this.model.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy)})}runOneStep(){const{model:t,options:e}=this,{preventOverlap:n,barnesHut:r}=e,i=this.maxIteration-this.iteration,o=t.nodes();for(let t=0;t<o.length;t+=1){const{id:e}=o[t];this.preForces[e]=[...this.forces[e]||[0,0]],this.forces[e]=[0,0]}return this.syncFixedPositions(),this.calculateAttractive(i),r&&!n?this.calculateOptRepulsiveGravity():this.calculateRepulsiveGravity(i,100),this.updatePositions()}calculateAttractive(t){const{model:e,options:n}=this,{preventOverlap:r,dissuadeHubs:i,mode:o,prune:A}=n,s=e.edges();for(let t=0;t<s.length;t+=1){const{source:n,target:a}=s[t],c=e.node(n),l=e.node(a),u=e.degree(n),h=e.degree(a);if(A&&(u<=1||h<=1))continue;const d=l.x-c.x,f=l.y-c.y;let g=Math.hypot(d,f);g=g<1e-4?1e-4:g;const p=d/g,v=f/g;let m=g;r&&(m=Math.max(0,g-this.sizes[n]-this.sizes[a]));let y=m,w=m;"linlog"===o&&(y=Math.log(1+m),w=y),i&&(y=m/u,w=m/h),this.forces[n][0]+=y*p,this.forces[n][1]+=y*v,this.forces[a][0]-=w*p,this.forces[a][1]-=w*v}}calculateOptRepulsiveGravity(){const{model:t,options:e}=this,{kg:n,center:r,prune:i,kr:o}=e,A=t.nodes(),s=A.length;let a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY;for(let e=0;e<s;e+=1){const n=A[e],{id:r,x:o,y:s}=n;if(i&&t.degree(r)<=1)continue;const h=this.bodies[r];h&&(h.setPos(o,s),o<a&&(a=o),o>c&&(c=o),s<l&&(l=s),s>u&&(u=s))}let h=Math.max(c-a,u-l);(!isFinite(h)||h<=0)&&(h=1);const d=new ZK({xmid:(c+a)/2,ymid:(u+l)/2,length:h,massCenter:r,mass:s}),f=new JK(d);for(let e=0;e<s;e+=1){const{id:n}=A[e];if(i&&t.degree(n)<=1)continue;const r=this.bodies[n];r&&r.in(d)&&f.insert(r)}for(let e=0;e<s;e+=1){const o=A[e],{id:s,x:a,y:c}=o,l=t.degree(s);if(i&&l<=1)continue;const u=this.bodies[s];if(!u)continue;u.resetForce(),f.updateForce(u),this.forces[s][0]-=u.fx,this.forces[s][1]-=u.fy;const h=a-r[0],d=c-r[1];let g=Math.hypot(h,d);g=g<1e-4?1e-4:g;const p=h/g,v=d/g,m=n*(l+1);this.forces[s][0]-=m*p,this.forces[s][1]-=m*v}}calculateRepulsiveGravity(t,e){const{model:n,options:r}=this,{preventOverlap:i,kr:o,kg:A,center:s,prune:a}=r,c=n.nodes(),l=c.length;for(let t=0;t<l;t+=1){const r=c[t],u=n.degree(r.id);for(let A=t+1;A<l;A+=1){const t=c[A],s=n.degree(t.id);if(a&&(u<=1||s<=1))continue;const l=t.x-r.x,h=t.y-r.y;let d=Math.hypot(l,h);d=d<1e-4?1e-4:d;const f=l/d,g=h/d;let p,v=d;if(i){const n=d-this.sizes[r.id]-this.sizes[t.id];n<0?p=e*(u+1)*(s+1):0===n?p=0:(v=n,p=o*(u+1)*(s+1)/v)}else p=o*(u+1)*(s+1)/v;this.forces[r.id][0]-=p*f,this.forces[r.id][1]-=p*g,this.forces[t.id][0]+=p*f,this.forces[t.id][1]+=p*g}const h=r.x-s[0],d=r.y-s[1];let f=Math.hypot(h,d);f=f<1e-4?1e-4:f;const g=h/f,p=d/f,v=A*(u+1);this.forces[r.id][0]-=v*g,this.forces[r.id][1]-=v*p}}updatePositions(){const{model:t,options:e}=this,{ks:n,tao:r,prune:i,ksmax:o,distanceThresholdMode:A="max"}=e,s=t.nodes(),a=s.length,c={},l={};let u=0,h=0;for(let e=0;e<a;e+=1){const{id:n}=s[e],r=t.degree(n);if(i&&r<=1)continue;const o=this.preForces[n]||[0,0],A=this.forces[n]||[0,0],a=A[0]-o[0],d=A[1]-o[1],f=Math.hypot(a,d),g=A[0]+o[0],p=A[1]+o[1],v=Math.hypot(g,p);c[n]=f,l[n]=v/2,u+=(r+1)*c[n],h+=(r+1)*l[n]}let d=this.sg;const f=this.sg;u<=0?d=f>0?f:1:(d=r*h/u,0!==f&&(d=d>1.5*f?1.5*f:d)),this.sg=d;let g=0,p=1/0,v=0,m=0;for(let e=0;e<a;e+=1){const r=s[e],A=r.id,a=t.degree(A);if(i&&a<=1)continue;if(this.isNodeFixed(r))continue;const l=c[A]||0;let u=n*d/(1+d*Math.sqrt(l)),h=Math.hypot(this.forces[A][0],this.forces[A][1]);h=h<1e-4?1e-4:h;const f=o/h;u>f&&(u=f);const y=u*this.forces[A][0],w=u*this.forces[A][1];r.x+=y,r.y+=w;const b=Math.hypot(y,w);b>0&&(m++,v+=b,b>g&&(g=b),b<p&&(p=b))}switch(A){case"min":return p;case"mean":return m>0?v/m:0;default:return g}}destroy(){this.stop(),this.forces={},this.preForces={},this.bodies={},this.sizes={},this.off()}};const ej={nodeSize:10,nodeSpacing:0,width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class nj extends xC{constructor(){super(...arguments),this.id="force-atlas2",this.simulation=null}getDefaultOptions(){return ej}layout(t){return mx(this,0,void 0,function*(){const e=this.parseOptions(t),{width:n,height:r,prune:i,center:o}=e,A=this.model.nodeCount();if(!A||1===A)return EF(this.model,o);tC(this.model,n,r);const s=this.getSizes(e.nodeSize,e.nodeSpacing),a=this.setSimulation();a.data(this.model,s),a.initialize(e),a.restart();const c=()=>new Promise(t=>{a.on("end",t)});if(!i)return c();if(yield c(),i){const t=this.model.edges();for(let e=0;e<t.length;e+=1){const{source:n,target:r}=t[e],i=this.model.degree(n),o=this.model.degree(r),A=this.model.node(n),s=this.model.node(r);i<=1?(A.x=s.x,A.y=s.y):o<=1&&(s.x=A.x,s.y=A.y)}a.initialize(Object.assign(Object.assign({},e),{prune:!1,barnesHut:!1})),a.tick(100)}})}getSizes(t,e){const n={},r=Xx(t,e,ej.nodeSize,ej.nodeSpacing);return this.model.forEachNode(t=>{n[t.id]=Math.max(...r(t._original))}),n}setSimulation(){const t=this.simulation||new tj;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}parseOptions(t={}){const{barnesHut:e,prune:n,maxIteration:r,kr:i,kg:o}=t,A={},s=this.model.nodeCount();return void 0===e&&s>250&&(A.barnesHut=!0),void 0===n&&s>100&&(A.prune=!0),0!==r||n?0===r&&n&&(A.maxIteration=100,s<=200&&s>100?A.maxIteration=500:s>200&&(A.maxIteration=950)):(A.maxIteration=250,s<=200&&s>100?A.maxIteration=1e3:s>200&&(A.maxIteration=1200)),i||(A.kr=50,s>100&&s<=500?A.kr=20:s>500&&(A.kr=1)),o||(A.kg=20,s>100&&s<=500?A.kg=10:s>500&&(A.kg=1)),Object.assign(Object.assign(Object.assign({},t),A),kF(t))}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}setFixedPosition(t,e){var n;null===(n=this.simulation)||void 0===n||n.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}}class rj extends KK{constructor(){super(...arguments),this.displacements=null,this.clusterMap=null}data(t){return this.model=t,this}initialize(t){super.initialize(t),this.recomputeConstants(),this.displacements=null,this.clusterMap=null,this.initDisplacements()}recomputeConstants(){const{model:t,options:e}=this,{width:n,height:r}=kF(e),i=n*r;this.k2=i/(t.nodeCount()+1),this.k=Math.sqrt(this.k2),this.maxDisplace=Math.sqrt(i)/10}runOneStep(){return this.syncFixedPositions(),this.initDisplacements(),this.calculateRepulsive(),this.calculateAttractive(),this.applyClusterGravity(),this.applyGlobalGravity(),this.updatePositions()}setFixedPosition(t,e){const n=this.model.node(t);if(!n)return;const r=["fx","fy","fz"];null!==e?e.forEach((t,e)=>{e<r.length&&("number"==typeof t||null===t)&&(n[r[e]]=t)}):r.forEach(t=>{delete n[t]})}isNodeFixed(t){return!Kx(t.fx)&&!Kx(t.fy)}syncFixedPositions(){const{model:t,options:e}=this,n=3===e.dimensions;t.forEachNode(t=>{this.isNodeFixed(t)&&(t.x=t.fx,t.y=t.fy,n&&void 0!==t.fz&&(t.z=t.fz))})}initDisplacements(){this.displacements||(this.displacements=new Map,this.model.forEachNode(t=>{this.displacements.set(t.id,{x:0,y:0,z:0})})),this.displacements.forEach(t=>{t.x=0,t.y=0,t.z=0})}calculateRepulsive(){const{model:t,options:e}=this,n=3===e.dimensions,r=t.nodes();for(let t=0;t<r.length;t++){const e=r[t],i=this.displacements.get(e.id),o=this.isNodeFixed(e);for(let A=t+1;A<r.length;A++){const t=r[A],s=this.displacements.get(t.id),a=this.isNodeFixed(t);let c=e.x-t.x,l=e.y-t.y,u=n?e.z-t.z:0,h=c*c+l*l+u*u;0===h&&(h=1,c=.01,l=.01,u=.01);const d=this.k2/h,f=c*d,g=l*d,p=u*d;o||a?o&&!a?(s.x-=2*f,s.y-=2*g,n&&(s.z-=2*p)):!o&&a&&(i.x+=2*f,i.y+=2*g,n&&(i.z+=2*p)):(i.x+=f,i.y+=g,s.x-=f,s.y-=g,n&&(i.z+=p,s.z-=p))}}}calculateAttractive(){const{model:t,options:e}=this,n=3===e.dimensions;t.forEachEdge(e=>{const{source:r,target:i}=e;if(!r||!i||r===i)return;const o=t.node(r),A=t.node(i),s=this.displacements.get(r),a=this.displacements.get(i),c=this.isNodeFixed(o),l=this.isNodeFixed(A),u=A.x-o.x,h=A.y-o.y,d=n?A.z-o.z:0,f=Math.sqrt(u*u+h*h+d*d);if(0===f)return;const g=f/this.k,p=u*g,v=h*g,m=d*g;c||l?c&&!l?(a.x-=2*p,a.y-=2*v,n&&(a.z-=2*m)):!c&&l&&(s.x+=2*p,s.y+=2*v,n&&(s.z+=2*m)):(s.x+=p,s.y+=v,a.x-=p,a.y-=v,n&&(s.z+=m,a.z-=m))})}applyClusterGravity(){const{model:t,options:e}=this,{nodeClusterBy:n,clusterGravity:r,dimensions:i,clustering:o}=e;if(!o)return;if(this.clusterMap||(this.clusterMap=new Map,t.forEachNode(e=>{const r=n(t.originalNode(e.id));this.clusterMap.has(r)||this.clusterMap.set(r,{name:r,cx:0,cy:0,cz:0,count:0})})),0===this.clusterMap.size)return;const A=3===i;this.clusterMap.forEach(t=>{t.cx=0,t.cy=0,t.cz=0,t.count=0}),t.forEachNode(e=>{const r=n(t.originalNode(e.id)),i=this.clusterMap.get(r);i&&(i.cx+=e.x,i.cy+=e.y,A&&(i.cz+=e.z),i.count++)}),this.clusterMap.forEach(t=>{t.count>0&&(t.cx/=t.count,t.cy/=t.count,t.cz/=t.count)}),t.forEachNode(e=>{const{id:i}=e;if(this.isNodeFixed(e))return;const o=n(t.originalNode(i)),s=this.clusterMap.get(o);if(!s)return;const a=this.displacements.get(i),c=e.x-s.cx,l=e.y-s.cy,u=A?e.z-s.cz:0,h=Math.sqrt(c*c+l*l+u*u);if(0===h)return;const d=this.k*r;a.x-=d*c/h,a.y-=d*l/h,A&&(a.z-=d*u/h)})}applyGlobalGravity(){const{model:t,options:e}=this,{gravity:n,center:r,dimensions:i}=e,o=3===i,A=.01*this.k*n;t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const n=this.displacements.get(e);n.x-=A*(t.x-r[0]),n.y-=A*(t.y-r[1]),o&&(n.z-=A*(t.z-(r[2]||0)))})}updatePositions(){const{model:t,options:e}=this,{speed:n,dimensions:r,distanceThresholdMode:i="max"}=e,o=3===r;let A=0,s=1/0,a=0,c=0;if(t.forEachNode(t=>{const{id:e}=t;if(this.isNodeFixed(t))return;const r=this.displacements.get(e),i=Math.sqrt(r.x*r.x+r.y*r.y+(o?r.z*r.z:0));if(0===i)return;const l=Math.min(this.maxDisplace*(n/800),i),u=l/i;t.x+=r.x*u,t.y+=r.y*u,o&&(t.z=t.z+r.z*u),A=Math.max(A,l),s=Math.min(s,l),a+=l,c++}),0===c)return 0;switch(i){case"min":return s===1/0?0:s;case"mean":return a/c;default:return A}}destroy(){var t,e;this.stop(),null===(t=this.displacements)||void 0===t||t.clear(),null===(e=this.clusterMap)||void 0===e||e.clear()}}const ij={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"node.cluster",dimensions:2};class oj extends xC{constructor(){super(...arguments),this.id="fruchterman",this.simulation=null}getDefaultOptions(){return ij}parseOptions(t={}){const{clustering:e,nodeClusterBy:n}=this.options,r=e&&!!n;return Object.assign(t,kF(t),{clustering:r,nodeClusterBy:Vx(n,["node"])}),t}layout(){return mx(this,0,void 0,function*(){const t=this.parseOptions(this.options),{dimensions:e,center:n,width:r,height:i}=t,o=this.model.nodeCount();if(!o||1===o)return void EF(this.model,n,e);tC(this.model,r,i,e);const A=this.setSimulation();return A.data(this.model),A.initialize(t),A.restart(),new Promise(t=>{A.on("end",()=>t())})})}setSimulation(){const t=this.simulation||new rj;return this.simulation||(this.simulation=t.on("tick",()=>{var t,e;return null===(e=(t=this.options).onTick)||void 0===e?void 0:e.call(t,this)})),this.simulation}restart(){var t;null===(t=this.simulation)||void 0===t||t.restart()}stop(){var t;null===(t=this.simulation)||void 0===t||t.stop()}tick(t=1){var e;null===(e=this.simulation)||void 0===e||e.tick(t)}setFixedPosition(t,e){var n;null===(n=this.simulation)||void 0===n||n.setFixedPosition(t,e)}destroy(){var t;super.destroy(),this.stop(),null===(t=this.simulation)||void 0===t||t.destroy(),this.simulation=null}}const Aj={begin:[0,0],preventOverlap:!0,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,nodeSpacing:10,width:300,height:300};class sj extends EC{constructor(){super(...arguments),this.id="grid"}getDefaultOptions(){return Aj}parseOptions(t={},e){const{rows:n,cols:r,position:i,sortBy:o}=t,{width:A,height:s,center:a}=kF(t);let c=t.rows,l=t.cols;const u=e.nodeCount();if(null!=n&&null!=r)c=n,l=r;else if(null!=n&&null==r)c=n,l=Math.ceil(u/c);else if(null==n&&null!=r)l=r,c=Math.ceil(u/l);else{const t=Math.sqrt(u*s/A);c=Math.round(t),l=Math.round(A/s*t)}c=Math.max(c,1),l=Math.max(l,1);const h={rows:c,cols:l};if(h.cols*h.rows>u){const t=aj(h),e=cj(h);(t-1)*e>=u?aj(h,t-1):(e-1)*t>=u&&cj(h,e-1)}else for(;h.cols*h.rows<u;){const t=aj(h),e=cj(h);(e+1)*t>=u?cj(h,e+1):aj(h,t+1)}const d=o?"degree"===o||"id"===o?o:Vx(o,["nodeA","nodeB"]):Aj.sortBy;return Object.assign(Object.assign({},t),{sortBy:d,rcs:h,center:a,width:A,height:s,position:Vx(i,["node"])})}layout(){return mx(this,0,void 0,function*(){const{begin:t,rcs:e,sortBy:n,width:r,height:i,condense:o,preventOverlap:A,nodeSpacing:s,nodeSize:a,position:c}=this.parseOptions(this.options,this.model),l=this.model.nodeCount();if(!l||1===l)return void EF(this.model,t);"degree"===n?CF(this.model):"id"===n?xF(this.model,(t,e)=>{const n=t.id,r=e.id;return"number"==typeof n&&"number"==typeof r?n-r:String(n).localeCompare(String(r))}):MF(this.model,n);let u=o?0:r/e.cols,h=o?0:i/e.rows;if(A){const t=Xx(a,s,Aj.nodeSize,Aj.nodeSpacing);this.model.forEachNode(e=>{const[n,r]=t(e._original);u=Math.max(u,n),h=Math.max(h,r)})}const d={},f={row:0,col:0},g={};this.model.forEachNode(n=>{const r=n._original;let i;if(c&&(i=c(r)),i&&(void 0!==i.row||void 0!==i.col)){const t={row:i.row,col:i.col};if(void 0===t.col)for(t.col=0;lj(d,t);)t.col++;else if(void 0===t.row)for(t.row=0;lj(d,t);)t.row++;g[n.id]=t,uj(d,t)}dj(n,t,u,h,g,e,f,d)})})}}const aj=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.min(r,i);else{Math.min(r,i)===t.rows?t.rows=e:t.cols=e}return n},cj=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.max(r,i);else{Math.max(r,i)===t.rows?t.rows=e:t.cols=e}return n},lj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,uj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,hj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},dj=(t,e,n,r,i,o,A,s)=>{let a,c;const l=i[t.id];if(l)a=l.col*n+n/2+e[0],c=l.row*r+r/2+e[1];else{for(;lj(s,A);)hj(o,A);a=A.col*n+n/2+e[0],c=A.row*r+r/2+e[1],uj(s,A),hj(o,A)}t.x=a,t.y=c};var fj={};const gj=Object.prototype.toString;function pj(t){const e=gj.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var vj=EU(Object.freeze({__proto__:null,isAnyArray:pj}));var mj,yj=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!pj(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!pj(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!pj(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var A=t[r],s=r+1;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(!pj(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var A=t[r],s=r+1;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,a=void 0===s?n.autoMinMax?i:1:s;if(A>=a)throw new RangeError("min option must be smaller than max option");for(var c=(a-A)/(i-r),l=0;l<t.length;l++)e[l]=(t[l]-r)*c+A;return e}}),wj=EU(yj);function bj(){if(mj)return fj;mj=1,Object.defineProperty(fj,"__esModule",{value:!0});var t=vj,e=wj;const n=" ".repeat(2),r=" ".repeat(4);function i(t,e={}){const{maxRows:i=15,maxColumns:A=10,maxNumSize:s=8,padMinus:a="auto"}=e;return`${t.constructor.name} {\n${n}[\n${r}${function(t,e,n,i,A){const{rows:s,columns:a}=t,c=Math.min(s,e),l=Math.min(a,n),u=[];if("auto"===A){A=!1;t:for(let e=0;e<c;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){A=!0;break t}}for(let e=0;e<c;e++){let n=[];for(let r=0;r<l;r++)n.push(o(t.get(e,r),i,A));u.push(`${n.join(" ")}`)}l!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);c!==s&&u.push(`... ${s-e} more rows`);return u.join(`\n${r}`)}(t,i,A,s,a)}\n${n}]\n${n}rows: ${t.rows}\n${n}columns: ${t.columns}\n}`}function o(t,e,n){return(t>=0&&n?` ${A(t,e-1)}`:A(t,e)).padEnd(e)}function A(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function s(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function a(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function c(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function l(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function u(e,n){if(!t.isAnyArray(n))throw new TypeError("row indices must be an array");for(let t=0;t<n.length;t++)if(n[t]<0||n[t]>=e.rows)throw new RangeError("row indices are out of range")}function h(e,n){if(!t.isAnyArray(n))throw new TypeError("column indices must be an array");for(let t=0;t<n.length;t++)if(n[t]<0||n[t]>=e.columns)throw new RangeError("column indices are out of range")}function d(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(g("startRow",e),g("endRow",n),g("startColumn",r),g("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function f(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function g(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function p(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class v{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new w(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 w(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 w(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 w(t,e)}static ones(t,e){return new w(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 w(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 w(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 w(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 v.isMatrix(t)?t:new w(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let A=i;A<e;A++){let e=t.get(n,A)-o*t.get(r,A);t.set(n,A,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new w(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){s(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return w.rowVector(this.getRow(t))}setRow(t,e){s(this,t),e=c(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){s(this,t),s(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){a(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return w.columnVector(this.getColumn(t))}setColumn(t,e){a(this,t),e=l(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){a(this,t),a(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=c(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=c(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=c(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=c(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=l(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=l(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=l(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=l(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){s(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){a(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(){p(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(){p(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(s(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){s(this,t),p(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(s(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){s(this,t),p(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(a(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){a(this,t),p(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(a(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){a(this,t),p(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){v.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=w.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new w(e,r),o=new Float64Array(n);for(let A=0;A<r;A++){for(let e=0;e<n;e++)o[e]=t.get(e,A);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,A,e)}}return i}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=w.eye(this.rows),n=this;for(let r=t;r>=1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=w.checkMatrix(t);let e=new w(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),A=this.get(1,0),s=t.get(1,0),a=this.get(1,1),c=t.get(1,1),l=(n+a)*(r+c),u=(A+a)*r,h=n*(o-c),d=a*(s-r),f=(n+i)*c,g=l+d-f+(i-a)*(s+c),p=h+f,v=u+d,m=l-u+h+(A-n)*(r+o);return e.set(0,0,g),e.set(0,1,p),e.set(1,0,v),e.set(1,1,m),e}strassen3x3(t){t=w.checkMatrix(t);let e=new w(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),A=this.get(1,1),s=this.get(1,2),a=this.get(2,0),c=this.get(2,1),l=this.get(2,2),u=t.get(0,0),h=t.get(0,1),d=t.get(0,2),f=t.get(1,0),g=t.get(1,1),p=t.get(1,2),v=t.get(2,0),m=t.get(2,1),y=t.get(2,2),b=(n-o)*(-h+g),B=(-n+o+A)*(u-h+g),E=(o+A)*(-u+h),x=n*u,C=(-n+a+c)*(u-d+p),M=(-n+a)*(d-p),F=(a+c)*(-u+d),k=(-i+c+l)*(g+v-m),S=(i-l)*(g-m),Q=i*v,U=(c+l)*(-v+m),N=(-i+A+s)*(p+v-y),T=(i-s)*(p-y),O=(A+s)*(-v+y),I=x+Q+r*f,L=(n+r+i-o-A-c-l)*g+B+E+x+k+Q+U,P=x+C+F+(n+r+i-A-s-a-c)*p+Q+N+O,D=b+A*(-u+h+f-g-p-v+y)+B+x+Q+N+T,R=b+B+E+x+s*m,H=Q+N+T+O+o*d,_=x+C+M+c*(-u+d+f-g-p-v+m)+k+S+Q,G=k+S+Q+U+a*h,K=x+C+M+F+l*y;return e.set(0,0,I),e.set(0,1,L),e.set(0,2,P),e.set(1,0,D),e.set(1,1,R),e.set(1,2,H),e.set(2,0,_),e.set(2,1,G),e.set(2,2,K),e}mmulStrassen(t){t=w.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function A(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=v.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),a=Math.max(r,o);return e=A(e,s,a),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=A(e,r+1,i+1),n=A(n,r+1,i+1)):r%2==1?(e=A(e,r+1,i),n=A(n,r+1,i)):i%2==1&&(e=A(e,r,i+1),n=A(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),a=e.subMatrix(0,o-1,0,s-1),c=n.subMatrix(0,o-1,0,s-1),l=e.subMatrix(0,o-1,s,e.columns-1),u=n.subMatrix(0,o-1,s,n.columns-1),h=e.subMatrix(o,e.rows-1,0,s-1),d=n.subMatrix(o,n.rows-1,0,s-1),f=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),p=t(v.add(a,f),v.add(c,g),o,s),m=t(v.add(h,f),c,o,s),y=t(a,v.sub(u,g),o,s),w=t(f,v.sub(d,c),o,s),b=t(v.add(a,l),g,o,s),B=t(v.sub(h,a),v.add(c,u),o,s),E=t(v.sub(l,f),v.add(d,g),o,s),x=v.add(p,w);x.sub(b),x.add(E);let C=v.add(y,b),M=v.add(m,w),F=v.sub(p,m);F.add(y),F.add(B);let k=v.zeros(2*x.rows,2*x.columns);return k=k.setSubMatrix(x,0,0),k=k.setSubMatrix(C,x.rows,0),k=k.setSubMatrix(M,0,x.columns),k=k.setSubMatrix(F,x.rows,x.columns),k.subMatrix(0,r-1,0,i-1)}(e,t=A(t,s,a),s,a)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:n=0,max:r=1}=t;if(!Number.isFinite(n))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(n>=r)throw new RangeError("min must be smaller than max");let i=new w(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&e(o,{min:n,max:r,output:o}),i.setRow(t,o)}return i}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:n=0,max:r=1}=t;if(!Number.isFinite(n))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(n>=r)throw new RangeError("min must be smaller than max");let i=new w(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&e(o,{min:n,max:r,output:o}),i.setColumn(t,o)}return i}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=w.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new w(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=w.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(w.eye(n,n)),i=w.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new w(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=m){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=m){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){d(this,t,e,n,r);let i=new w(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 w(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 w(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=w.checkMatrix(t)).isEmpty())return this;d(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){u(this,t),h(this,e);let n=new w(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new w(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=f(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=f(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=f(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=f(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(e,n={}){if("object"==typeof e&&(n=e,e=void 0),"object"!=typeof n)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:i=this.mean(e)}=n;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(e){case"row":if(!t.isAnyArray(i))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,a=0;for(let e=0;e<i;e++)a=t.get(A,e)-n[A],r+=a,s+=a*a;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,r,i);case"column":if(!t.isAnyArray(i))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,a=0;for(let e=0;e<r;e++)a=t.get(e,A)-n[A],i+=a,s+=a*a;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,r,i);case void 0:if("number"!=typeof i)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,a=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)a=t.get(e,r)-n,A+=a,s+=a*a;return e?(s-A*A/o)/(o-1):(s-A*A/o)/o}(this,r,i);default:throw new Error(`invalid option: ${e}`)}}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(e,n={}){if("object"==typeof e&&(n=e,e=void 0),"object"!=typeof n)throw new TypeError("options must be an object");const{center:r=this.mean(e)}=n;switch(e){case"row":if(!t.isAnyArray(r))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,r),this;case"column":if(!t.isAnyArray(r))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,r),this;case void 0:if("number"!=typeof r)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,r),this;default:throw new Error(`invalid option: ${e}`)}}scale(e,n={}){if("object"==typeof e&&(n=e,e=void 0),"object"!=typeof n)throw new TypeError("options must be an object");let r=n.scale;switch(e){case"row":if(void 0===r)r=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=t.get(n,e)**2/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!t.isAnyArray(r))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,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=t.get(e,n)**2/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!t.isAnyArray(r))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,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=t.get(i,r)**2/e;return Math.sqrt(n)}(this);else if("number"!=typeof r)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,r),this;default:throw new Error(`invalid option: ${e}`)}}toString(t){return i(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function m(t,e){return t-e}function y(t){return t.every(t=>"number"==typeof t)}v.prototype.klass="Matrix","undefined"!=typeof Symbol&&(v.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return i(this)}),v.random=v.rand,v.randomInt=v.randInt,v.diagonal=v.diag,v.prototype.diagonal=v.prototype.diag,v.identity=v.eye,v.prototype.negate=v.prototype.neg,v.prototype.tensorProduct=v.prototype.kroneckerProduct;class w extends v{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),w.isMatrix(e))this.#t(e.rows,e.columns),w.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!t.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!y(t[r]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return s(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),s(this,t,!0),e=Float64Array.from(c(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){a(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),a(this,t,!0),e=l(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t);return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t.get(e,n));return this}}(v,w);class b extends v{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return w.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),w.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=w.copy(t,new w(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new w(t,t);else if(this.#e=new w(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new b(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new w(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const r=new b(n);for(let i=0,o=0,A=0;A<e;A++)r.set(i,o,t[A]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}b.prototype.klassType="SymmetricMatrix";class B extends b{static isDistanceMatrix(t){return b.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new b(this)}clone(){const t=new B(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,A=0;A<e;A++)r.set(i,o,t[A]),++i>=n&&(i=1+ ++o);return r}}B.prototype.klassSubType="DistanceMatrix";class E extends v{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class x extends E{constructor(t,e,n){u(t,e),h(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class C extends v{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class M extends v{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class F{constructor(t){let e,n,r,i,o,A,s,a,c,l=(t=M.checkMatrix(t)).clone(),u=l.rows,h=l.columns,d=new Float64Array(u),f=1;for(e=0;e<u;e++)d[e]=e;for(a=new Float64Array(u),n=0;n<h;n++){for(e=0;e<u;e++)a[e]=l.get(e,n);for(e=0;e<u;e++){for(c=Math.min(e,n),o=0,r=0;r<c;r++)o+=l.get(e,r)*a[r];a[e]-=o,l.set(e,n,a[e])}for(i=n,e=n+1;e<u;e++)Math.abs(a[e])>Math.abs(a[i])&&(i=e);if(i!==n){for(r=0;r<h;r++)A=l.get(i,r),l.set(i,r,l.get(n,r)),l.set(n,r,A);s=d[i],d[i]=d[n],d[n]=s,f=-f}if(n<u&&0!==l.get(n,n))for(e=n+1;e<u;e++)l.set(e,n,l.get(e,n)/l.get(n,n))}this.LU=l,this.pivotVector=d,this.pivotSign=f}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=w.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,A=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)A.set(n,r,A.get(n,r)-A.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)A.set(i,r,A.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)A.set(n,r,A.get(n,r)-A.get(i,r)*e.get(n,i))}return A}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new w(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new w(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function k(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 S{constructor(t){let e,n,r,i,o=(t=M.checkMatrix(t)).clone(),A=t.rows,s=t.columns,a=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<A;e++)t=k(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<A;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<A;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<A;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}a[r]=-t}this.QR=o,this.Rdiag=a}solve(t){t=w.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,A,s=t.columns,a=t.clone(),c=e.columns;for(o=0;o<c;o++)for(i=0;i<s;i++){for(A=0,r=o;r<n;r++)A+=e.get(r,o)*a.get(r,i);for(A=-A/e.get(o,o),r=o;r<n;r++)a.set(r,i,a.get(r,i)+A*e.get(r,o))}for(o=c-1;o>=0;o--){for(i=0;i<s;i++)a.set(o,i,a.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)a.set(r,i,a.get(r,i)-a.get(o,i)*e.get(r,o))}return a.subMatrix(0,c-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new w(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,A=i.columns,s=new w(o,A);for(n=A-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<A;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}class Q{constructor(t,e={}){if((t=M.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,a=Boolean(i),c=Boolean(o),l=!1;if(n<r)if(A){s=t.transpose(),n=s.rows,r=s.columns,l=!0;let e=a;a=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 u=Math.min(n,r),h=Math.min(n+1,r),d=new Float64Array(h),f=new w(n,u),g=new w(r,r),p=new Float64Array(r),v=new Float64Array(n),m=new Float64Array(h);for(let t=0;t<h;t++)m[t]=t;let y=Math.min(n-1,r),b=Math.max(0,Math.min(r-2,n)),B=Math.max(y,b);for(let t=0;t<B;t++){if(t<y){d[t]=0;for(let e=t;e<n;e++)d[t]=k(d[t],s.get(e,t));if(0!==d[t]){s.get(t,t)<0&&(d[t]=-d[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/d[t]);s.set(t,t,s.get(t,t)+1)}d[t]=-d[t]}for(let e=t+1;e<r;e++){if(t<y&&0!==d[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))}p[e]=s.get(t,e)}if(a&&t<y)for(let e=t;e<n;e++)f.set(e,t,s.get(e,t));if(t<b){p[t]=0;for(let e=t+1;e<r;e++)p[t]=k(p[t],p[e]);if(0!==p[t]){p[t+1]<0&&(p[t]=0-p[t]);for(let e=t+1;e<r;e++)p[e]/=p[t];p[t+1]+=1}if(p[t]=-p[t],t+1<n&&0!==p[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]+=p[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-p[e]/p[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,p[e])}}let E=Math.min(r,n+1);if(y<r&&(d[y]=s.get(y,y)),n<E&&(d[E-1]=0),b+1<E&&(p[b]=s.get(b,E-1)),p[E-1]=0,a){for(let t=y;t<u;t++){for(let e=0;e<n;e++)f.set(e,t,0);f.set(t,t,1)}for(let t=y-1;t>=0;t--)if(0!==d[t]){for(let e=t+1;e<u;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<b&&0!==p[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=E-1,C=Number.EPSILON;for(;E>0;){let t,e;for(t=E-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+C*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(p[t])<=e||Number.isNaN(p[t])){p[t]=0;break}}if(t===E-2)e=4;else{let n;for(n=E-1;n>=t&&n!==t;n--){let e=(n!==E?Math.abs(p[n]):0)+(n!==t+1?Math.abs(p[n-1]):0);if(Math.abs(d[n])<=C*e){d[n]=0;break}}n===t?e=3:n===E-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=p[E-2];p[E-2]=0;for(let n=E-2;n>=t;n--){let i=k(d[n],e),o=d[n]/i,A=e/i;if(d[n]=i,n!==t&&(e=-A*p[n-1],p[n-1]=o*p[n-1]),c)for(let t=0;t<r;t++)i=o*g.get(t,n)+A*g.get(t,E-1),g.set(t,E-1,-A*g.get(t,n)+o*g.get(t,E-1)),g.set(t,n,i)}break}case 2:{let e=p[t-1];p[t-1]=0;for(let r=t;r<E;r++){let i=k(d[r],e),o=d[r]/i,A=e/i;if(d[r]=i,e=-A*p[r],p[r]=o*p[r],a)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(d[E-1]),Math.abs(d[E-2]),Math.abs(p[E-2]),Math.abs(d[t]),Math.abs(p[t])),i=d[E-1]/e,o=d[E-2]/e,A=p[E-2]/e,s=d[t]/e,l=p[t]/e,u=((o+i)*(o-i)+A*A)/2,h=i*A*(i*A);let v=0;0===u&&0===h||(v=u<0?0-Math.sqrt(u*u+h):Math.sqrt(u*u+h),v=h/(u+v));let m=(s+i)*(s-i)+v,y=s*l;for(let e=t;e<E-1;e++){let i=k(m,y);0===i&&(i=Number.MIN_VALUE);let o=m/i,A=y/i;if(e!==t&&(p[e-1]=i),m=o*d[e]+A*p[e],p[e]=o*p[e]-A*d[e],y=A*d[e+1],d[e+1]=o*d[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=k(m,y),0===i&&(i=Number.MIN_VALUE),o=m/i,A=y/i,d[e]=i,m=o*p[e]+A*d[e+1],d[e+1]=-A*p[e]+o*d[e+1],y=A*p[e+1],p[e+1]=o*p[e+1],a&&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)}p[E-2]=m;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,c))for(let e=0;e<=x;e++)g.set(e,t,-g.get(e,t));for(;t<x&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[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(a&&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++}E--}}if(l){let t=g;g=f,f=t}this.m=n,this.n=r,this.s=d,this.U=f,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=w.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),a=A.rows,c=o.rows,l=w.zeros(a,c);for(let t=0;t<a;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);l.set(t,e,n)}return l.mmul(e)}solveForDiagonal(t){return this.solve(w.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new w(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,a=new w(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);a.set(t,e,n)}return a}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 w.diag(this.s)}}function U(t,e,n=!1){return t=M.checkMatrix(t),e=M.checkMatrix(e),n?new Q(t).solve(e):t.isSquare()?new F(t).solve(e):new S(t).solve(e)}function N(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function T(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class O{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=M.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,A=new w(o,o),s=new Float64Array(o),a=new Float64Array(o),c=t,l=!1;if(l=!!n||t.isSymmetric(),l){for(r=0;r<o;r++)for(i=0;i<o;i++)A.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,A,s,a,c,l,u;for(a=0;a<t;a++)n[a]=r.get(t-1,a);for(s=t-1;s>0;s--){for(u=0,A=0,c=0;c<s;c++)u+=Math.abs(n[c]);if(0===u)for(e[s]=n[s-1],a=0;a<s;a++)n[a]=r.get(s-1,a),r.set(s,a,0),r.set(a,s,0);else{for(c=0;c<s;c++)n[c]/=u,A+=n[c]*n[c];for(i=n[s-1],o=Math.sqrt(A),i>0&&(o=-o),e[s]=u*o,A-=i*o,n[s-1]=i-o,a=0;a<s;a++)e[a]=0;for(a=0;a<s;a++){for(i=n[a],r.set(a,s,i),o=e[a]+r.get(a,a)*i,c=a+1;c<=s-1;c++)o+=r.get(c,a)*n[c],e[c]+=r.get(c,a)*i;e[a]=o}for(i=0,a=0;a<s;a++)e[a]/=A,i+=e[a]*n[a];for(l=i/(A+A),a=0;a<s;a++)e[a]-=l*n[a];for(a=0;a<s;a++){for(i=n[a],o=e[a],c=a;c<=s-1;c++)r.set(c,a,r.get(c,a)-(i*e[c]+o*n[c]));n[a]=r.get(s-1,a),r.set(s,a,0)}}n[s]=A}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),A=n[s+1],0!==A){for(c=0;c<=s;c++)n[c]=r.get(c,s+1)/A;for(a=0;a<=s;a++){for(o=0,c=0;c<=s;c++)o+=r.get(c,s+1)*r.get(c,a);for(c=0;c<=s;c++)r.set(c,a,r.get(c,a)-o*n[c])}}for(c=0;c<=s;c++)r.set(c,s+1,0)}for(a=0;a<t;a++)n[a]=r.get(t-1,a),r.set(t-1,a,0);r.set(t-1,t-1,1),e[0]=0}(o,a,s,A),function(t,e,n,r){let i,o,A,s,a,c,l,u,h,d,f,g,p,v,m,y;for(A=1;A<t;A++)e[A-1]=e[A];e[t-1]=0;let w=0,b=0,B=Number.EPSILON;for(c=0;c<t;c++){for(b=Math.max(b,Math.abs(n[c])+Math.abs(e[c])),l=c;l<t&&!(Math.abs(e[l])<=B*b);)l++;if(l>c)do{for(i=n[c],u=(n[c+1]-i)/(2*e[c]),h=k(u,1),u<0&&(h=-h),n[c]=e[c]/(u+h),n[c+1]=e[c]*(u+h),d=n[c+1],o=i-n[c],A=c+2;A<t;A++)n[A]-=o;for(w+=o,u=n[l],f=1,g=f,p=f,v=e[c+1],m=0,y=0,A=l-1;A>=c;A--)for(p=g,g=f,y=m,i=f*e[A],o=f*u,h=k(u,e[A]),e[A+1]=m*h,m=e[A]/h,f=u/h,u=f*n[A]-m*i,n[A+1]=o+m*(f*i+m*n[A]),a=0;a<t;a++)o=r.get(a,A+1),r.set(a,A+1,m*r.get(a,A)+f*o),r.set(a,A,f*r.get(a,A)-m*o);u=-m*y*p*v*e[c]/d,e[c]=m*u,n[c]=f*u}while(Math.abs(e[c])>B*b);n[c]=n[c]+w,e[c]=0}for(A=0;A<t-1;A++){for(a=A,u=n[A],s=A+1;s<t;s++)n[s]<u&&(a=s,u=n[s]);if(a!==A)for(n[a]=n[A],n[A]=u,s=0;s<t;s++)u=r.get(s,A),r.set(s,A,r.get(s,a)),r.set(s,a,u)}}(o,a,s,A)}else{let t=new w(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,c.get(r,i));!function(t,e,n,r){let i,o,A,s,a,c,l,u=0,h=t-1;for(c=u+1;c<=h-1;c++){for(l=0,s=c;s<=h;s++)l+=Math.abs(e.get(s,c-1));if(0!==l){for(A=0,s=h;s>=c;s--)n[s]=e.get(s,c-1)/l,A+=n[s]*n[s];for(o=Math.sqrt(A),n[c]>0&&(o=-o),A-=n[c]*o,n[c]=n[c]-o,a=c;a<t;a++){for(i=0,s=h;s>=c;s--)i+=n[s]*e.get(s,a);for(i/=A,s=c;s<=h;s++)e.set(s,a,e.get(s,a)-i*n[s])}for(s=0;s<=h;s++){for(i=0,a=h;a>=c;a--)i+=n[a]*e.get(s,a);for(i/=A,a=c;a<=h;a++)e.set(s,a,e.get(s,a)-i*n[a])}n[c]=l*n[c],e.set(c,c-1,l*o)}}for(s=0;s<t;s++)for(a=0;a<t;a++)r.set(s,a,s===a?1:0);for(c=h-1;c>=u+1;c--)if(0!==e.get(c,c-1)){for(s=c+1;s<=h;s++)n[s]=e.get(s,c-1);for(a=c;a<=h;a++){for(o=0,s=c;s<=h;s++)o+=n[s]*r.get(s,a);for(o=o/n[c]/e.get(c,c-1),s=c;s<=h;s++)r.set(s,a,r.get(s,a)+o*n[s])}}}(o,t,e,A),function(t,e,n,r,i){let o,A,s,a,c,l,u,h,d,f,g,p,v,m,y,w=t-1,b=0,B=t-1,E=Number.EPSILON,x=0,C=0,M=0,F=0,k=0,S=0,Q=0,U=0;for(o=0;o<t;o++)for((o<b||o>B)&&(n[o]=i.get(o,o),e[o]=0),A=Math.max(o-1,0);A<t;A++)C+=Math.abs(i.get(o,A));for(;w>=b;){for(a=w;a>b&&(S=Math.abs(i.get(a-1,a-1))+Math.abs(i.get(a,a)),0===S&&(S=C),!(Math.abs(i.get(a,a-1))<E*S));)a--;if(a===w)i.set(w,w,i.get(w,w)+x),n[w]=i.get(w,w),e[w]=0,w--,U=0;else if(a===w-1){if(u=i.get(w,w-1)*i.get(w-1,w),M=(i.get(w-1,w-1)-i.get(w,w))/2,F=M*M+u,Q=Math.sqrt(Math.abs(F)),i.set(w,w,i.get(w,w)+x),i.set(w-1,w-1,i.get(w-1,w-1)+x),h=i.get(w,w),F>=0){for(Q=M>=0?M+Q:M-Q,n[w-1]=h+Q,n[w]=n[w-1],0!==Q&&(n[w]=h-u/Q),e[w-1]=0,e[w]=0,h=i.get(w,w-1),S=Math.abs(h)+Math.abs(Q),M=h/S,F=Q/S,k=Math.sqrt(M*M+F*F),M/=k,F/=k,A=w-1;A<t;A++)Q=i.get(w-1,A),i.set(w-1,A,F*Q+M*i.get(w,A)),i.set(w,A,F*i.get(w,A)-M*Q);for(o=0;o<=w;o++)Q=i.get(o,w-1),i.set(o,w-1,F*Q+M*i.get(o,w)),i.set(o,w,F*i.get(o,w)-M*Q);for(o=b;o<=B;o++)Q=r.get(o,w-1),r.set(o,w-1,F*Q+M*r.get(o,w)),r.set(o,w,F*r.get(o,w)-M*Q)}else n[w-1]=h+M,n[w]=h+M,e[w-1]=Q,e[w]=-Q;w-=2,U=0}else{if(h=i.get(w,w),d=0,u=0,a<w&&(d=i.get(w-1,w-1),u=i.get(w,w-1)*i.get(w-1,w)),10===U){for(x+=h,o=b;o<=w;o++)i.set(o,o,i.get(o,o)-h);S=Math.abs(i.get(w,w-1))+Math.abs(i.get(w-1,w-2)),h=d=.75*S,u=-.4375*S*S}if(30===U&&(S=(d-h)/2,S=S*S+u,S>0)){for(S=Math.sqrt(S),d<h&&(S=-S),S=h-u/((d-h)/2+S),o=b;o<=w;o++)i.set(o,o,i.get(o,o)-S);x+=S,h=d=u=.964}for(U+=1,c=w-2;c>=a&&(Q=i.get(c,c),k=h-Q,S=d-Q,M=(k*S-u)/i.get(c+1,c)+i.get(c,c+1),F=i.get(c+1,c+1)-Q-k-S,k=i.get(c+2,c+1),S=Math.abs(M)+Math.abs(F)+Math.abs(k),M/=S,F/=S,k/=S,c!==a)&&!(Math.abs(i.get(c,c-1))*(Math.abs(F)+Math.abs(k))<E*(Math.abs(M)*(Math.abs(i.get(c-1,c-1))+Math.abs(Q)+Math.abs(i.get(c+1,c+1)))));)c--;for(o=c+2;o<=w;o++)i.set(o,o-2,0),o>c+2&&i.set(o,o-3,0);for(s=c;s<=w-1&&(m=s!==w-1,s!==c&&(M=i.get(s,s-1),F=i.get(s+1,s-1),k=m?i.get(s+2,s-1):0,h=Math.abs(M)+Math.abs(F)+Math.abs(k),0!==h&&(M/=h,F/=h,k/=h)),0!==h);s++)if(S=Math.sqrt(M*M+F*F+k*k),M<0&&(S=-S),0!==S){for(s!==c?i.set(s,s-1,-S*h):a!==c&&i.set(s,s-1,-i.get(s,s-1)),M+=S,h=M/S,d=F/S,Q=k/S,F/=M,k/=M,A=s;A<t;A++)M=i.get(s,A)+F*i.get(s+1,A),m&&(M+=k*i.get(s+2,A),i.set(s+2,A,i.get(s+2,A)-M*Q)),i.set(s,A,i.get(s,A)-M*h),i.set(s+1,A,i.get(s+1,A)-M*d);for(o=0;o<=Math.min(w,s+3);o++)M=h*i.get(o,s)+d*i.get(o,s+1),m&&(M+=Q*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-M*k)),i.set(o,s,i.get(o,s)-M),i.set(o,s+1,i.get(o,s+1)-M*F);for(o=b;o<=B;o++)M=h*r.get(o,s)+d*r.get(o,s+1),m&&(M+=Q*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-M*k)),r.set(o,s,r.get(o,s)-M),r.set(o,s+1,r.get(o,s+1)-M*F)}}}if(0===C)return;for(w=t-1;w>=0;w--)if(M=n[w],F=e[w],0===F)for(a=w,i.set(w,w,1),o=w-1;o>=0;o--){for(u=i.get(o,o)-M,k=0,A=a;A<=w;A++)k+=i.get(o,A)*i.get(A,w);if(e[o]<0)Q=u,S=k;else if(a=o,0===e[o]?i.set(o,w,0!==u?-k/u:-k/(E*C)):(h=i.get(o,o+1),d=i.get(o+1,o),F=(n[o]-M)*(n[o]-M)+e[o]*e[o],l=(h*S-Q*k)/F,i.set(o,w,l),i.set(o+1,w,Math.abs(h)>Math.abs(Q)?(-k-u*l)/h:(-S-d*l)/Q)),l=Math.abs(i.get(o,w)),E*l*l>1)for(A=o;A<=w;A++)i.set(A,w,i.get(A,w)/l)}else if(F<0)for(a=w-1,Math.abs(i.get(w,w-1))>Math.abs(i.get(w-1,w))?(i.set(w-1,w-1,F/i.get(w,w-1)),i.set(w-1,w,-(i.get(w,w)-M)/i.get(w,w-1))):(y=I(0,-i.get(w-1,w),i.get(w-1,w-1)-M,F),i.set(w-1,w-1,y[0]),i.set(w-1,w,y[1])),i.set(w,w-1,0),i.set(w,w,1),o=w-2;o>=0;o--){for(f=0,g=0,A=a;A<=w;A++)f+=i.get(o,A)*i.get(A,w-1),g+=i.get(o,A)*i.get(A,w);if(u=i.get(o,o)-M,e[o]<0)Q=u,k=f,S=g;else if(a=o,0===e[o]?(y=I(-f,-g,u,F),i.set(o,w-1,y[0]),i.set(o,w,y[1])):(h=i.get(o,o+1),d=i.get(o+1,o),p=(n[o]-M)*(n[o]-M)+e[o]*e[o]-F*F,v=2*(n[o]-M)*F,0===p&&0===v&&(p=E*C*(Math.abs(u)+Math.abs(F)+Math.abs(h)+Math.abs(d)+Math.abs(Q))),y=I(h*k-Q*f+F*g,h*S-Q*g-F*f,p,v),i.set(o,w-1,y[0]),i.set(o,w,y[1]),Math.abs(h)>Math.abs(Q)+Math.abs(F)?(i.set(o+1,w-1,(-f-u*i.get(o,w-1)+F*i.get(o,w))/h),i.set(o+1,w,(-g-u*i.get(o,w)-F*i.get(o,w-1))/h)):(y=I(-k-d*i.get(o,w-1),-S-d*i.get(o,w),Q,F),i.set(o+1,w-1,y[0]),i.set(o+1,w,y[1]))),l=Math.max(Math.abs(i.get(o,w-1)),Math.abs(i.get(o,w))),E*l*l>1)for(A=o;A<=w;A++)i.set(A,w-1,i.get(A,w-1)/l),i.set(A,w,i.get(A,w)/l)}for(o=0;o<t;o++)if(o<b||o>B)for(A=o;A<t;A++)r.set(o,A,i.get(o,A));for(A=t-1;A>=b;A--)for(o=b;o<=B;o++){for(Q=0,s=b;s<=Math.min(A,B);s++)Q+=r.get(o,s)*i.get(s,A);r.set(o,A,Q)}}(o,a,s,A,t)}this.n=o,this.e=a,this.d=s,this.V=A}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new w(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function I(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class L{constructor(t){if(!(t=M.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,A=new w(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=A.get(r,e)*A.get(n,e);o=(i.get(n,r)-o)/A.get(r,r),A.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&&=t>0,A.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)A.set(n,r,0)}this.L=A,this.positiveDefinite=s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=M.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,A=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<A;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<A;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class P{constructor(e,n={}){e=M.checkMatrix(e);let{Y:r}=n;const{scaleScores:i=!1,maxIterations:o=1e3,terminationCriteria:A=1e-10}=n;let s;if(r){if(r=t.isAnyArray(r)&&"number"==typeof r[0]?w.columnVector(r):M.checkMatrix(r),r.rows!==e.rows)throw new Error("Y should have the same number of rows as X");s=r.getColumnVector(0)}else s=e.getColumnVector(0);let a,c,l,u,h=1;for(let t=0;t<o&&h>A;t++)l=e.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=e.mmul(l).div(l.transpose().mmul(l).get(0,0)),t>0&&(h=a.clone().sub(u).pow(2).sum()),u=a.clone(),r?(c=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),c=c.div(c.norm()),s=r.mmul(c).div(c.transpose().mmul(c).get(0,0))):s=a;if(r){let t=e.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));t=t.div(t.norm());let n=e.clone().sub(a.clone().mmul(t.transpose())),i=s.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),o=r.clone().sub(a.clone().mulS(i.get(0,0)).mmul(c.transpose()));this.t=a,this.p=t.transpose(),this.w=l.transpose(),this.q=c,this.u=s,this.s=a.transpose().mmul(a),this.xResidual=n,this.yResidual=o,this.betas=i}else this.w=l.transpose(),this.s=a.transpose().mmul(a).sqrt(),this.t=i?a.clone().div(this.s.get(0,0)):a,this.xResidual=e.sub(a.mmul(l.transpose()))}}return fj.AbstractMatrix=v,fj.CHO=L,fj.CholeskyDecomposition=L,fj.DistanceMatrix=B,fj.EVD=O,fj.EigenvalueDecomposition=O,fj.LU=F,fj.LuDecomposition=F,fj.Matrix=w,fj.MatrixColumnSelectionView=class extends E{constructor(t,e){h(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},fj.MatrixColumnView=class extends E{constructor(t,e){a(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},fj.MatrixFlipColumnView=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},fj.MatrixFlipRowView=class extends E{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},fj.MatrixRowSelectionView=class extends E{constructor(t,e){u(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},fj.MatrixRowView=class extends E{constructor(t,e){s(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},fj.MatrixSelectionView=x,fj.MatrixSubView=class extends E{constructor(t,e,n,r,i){d(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},fj.MatrixTransposeView=class extends E{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},fj.NIPALS=P,fj.Nipals=P,fj.QR=S,fj.QrDecomposition=S,fj.SVD=Q,fj.SingularValueDecomposition=Q,fj.SymmetricMatrix=b,fj.WrapperMatrix1D=C,fj.WrapperMatrix2D=M,fj.correlation=function(e,n=e,r={}){e=new w(e);let i=!1;if("object"!=typeof n||w.isMatrix(n)||t.isAnyArray(n)?n=new w(n):(r=n,n=e,i=!0),e.rows!==n.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:o=!0,scale:A=!0}=r;o&&(e.center("column"),i||n.center("column")),A&&(e.scale("column"),i||n.scale("column"));const s=e.standardDeviation("column",{unbiased:!0}),a=i?s:n.standardDeviation("column",{unbiased:!0}),c=e.transpose().mmul(n);for(let t=0;t<c.rows;t++)for(let n=0;n<c.columns;n++)c.set(t,n,c.get(t,n)*(1/(s[t]*a[n]))*(1/(e.rows-1)));return c},fj.covariance=function(e,n=e,r={}){e=new w(e);let i=!1;if("object"!=typeof n||w.isMatrix(n)||t.isAnyArray(n)?n=new w(n):(r=n,n=e,i=!0),e.rows!==n.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:o=!0}=r;o&&(e=e.center("column"),i||(n=n.center("column")));const A=e.transpose().mmul(n);for(let t=0;t<A.rows;t++)for(let n=0;n<A.columns;n++)A.set(t,n,A.get(t,n)*(1/(e.rows-1)));return A},fj.default=w,fj.determinant=function t(e){if((e=w.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,A,s;return o=new x(e,[1,2],[1,2]),A=new x(e,[1,2],[0,2]),s=new x(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(A)+i*t(s)}return new F(e).determinant}throw Error("determinant can only be calculated for a square matrix")},fj.inverse=function(t,e=!1){return t=M.checkMatrix(t),e?new Q(t).inverse():U(t,w.eye(t.rows))},fj.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=w.checkMatrix(t)).rows,o=new w(i,i);for(let e=0;e<i;e++){let A=w.columnVector(t.getRow(e)),s=t.subMatrixRow(N(i,e)).transpose(),a=new Q(s).solve(A),c=w.sub(A,s.mmul(a)).abs().max();o.setRow(e,T(c,a,e,n,r))}return o},fj.pseudoInverse=function(t,e=Number.EPSILON){if((t=w.checkMatrix(t)).isEmpty())return t.transpose();let n=new Q(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(w.diag(o).mmul(r.transpose()))},fj.solve=U,fj.wrap=function(e,n){if(t.isAnyArray(e))return e[0]&&t.isAnyArray(e[0])?new M(e):new C(e,n);throw new Error("the argument is not an array")},fj}var Bj=bj(),Ej=BU(Bj);const xj=Bj.Matrix,Cj=Bj.SingularValueDecomposition;Ej.Matrix?Ej.Matrix:Bj.Matrix;const Mj=(t,e)=>{const n=t.nodeCount(),r=Array.from({length:n},()=>[]),i={};let o=0;return t.forEachNode(t=>{i[t.id]=o++}),t.forEachEdge(t=>{const e=i[t.source],n=i[t.target];null!=e&&null!=n&&(r[e].push(n),r[n].push(e))}),r};function Fj(t){const e=t.length;new Array(e).fill(0);const n=Array.from({length:e},()=>new Array(e).fill(1/0));for(let r=0;r<e;r++)n[r]=kj(t,r);return n}function kj(t,e){const n=t.length,r=new Array(n).fill(1/0);r[e]=0;const i=new Sj;for(i.push([0,e]);!i.empty();){const[e,n]=i.pop();if(e!==r[n])continue;const o=t[n];for(let t=0;t<o.length;t++){const n=o[t],A=e+1;A<r[n]&&(r[n]=A,i.push([A,n]))}}return r}class Sj{constructor(){this.data=[]}push(t){this.data.push(t),this.bubbleUp(this.data.length-1)}pop(){const t=this.data[0],e=this.data.pop();return this.data.length>0&&(this.data[0]=e,this.bubbleDown(0)),t}empty(){return 0===this.data.length}bubbleUp(t){const e=this.data;for(;t>0;){const n=t-1>>1;if(e[n][0]<=e[t][0])break;[e[n],e[t]]=[e[t],e[n]],t=n}}bubbleDown(t){const e=this.data,n=e.length;for(;;){const r=2*t+1,i=2*t+2;let o=t;if(r<n&&e[r][0]<e[o][0]&&(o=r),i<n&&e[i][0]<e[o][0]&&(o=i),o===t)break;[e[t],e[o]]=[e[o],e[t]],t=o}}}const Qj={center:[0,0],linkDistance:50};class Uj extends EC{constructor(){super(...arguments),this.id="mds"}getDefaultOptions(){return Qj}layout(){return mx(this,0,void 0,function*(){const{linkDistance:t=Qj.linkDistance}=this.options,{center:e}=kF(this.options),n=this.model.nodeCount();if(0===n||1===n)return void EF(this.model,e);const r=Fj(Mj(this.model));Nj(r);const i=((t,e)=>{const n=t.length,r=new Array(n);for(let i=0;i<n;i++){const n=t[i],o=n.length,A=new Array(o);for(let t=0;t<o;t++)A[t]=n[t]*e;r[i]=A}return r})(r,t),o=Tj(i);let A=0;this.model.forEachNode(t=>{const n=o[A++];t.x=n[0]+e[0],t.y=n[1]+e[1]})})}}const Nj=t=>{let e=Number.NEGATIVE_INFINITY;const n=[],r=t.length;for(let i=0;i<r;i++){const r=t[i],o=r.length;for(let t=0;t<o;t++){const o=r[t];o===1/0?n.push([i,t]):e<o&&(e=o)}}for(let r=0;r<n.length;r++){const[i,o]=n[r];t[i][o]=e}},Tj=(t,e=2,n=Qj.linkDistance)=>{try{const n=t.length,r=new xj(n,n);for(let e=0;e<n;e++)for(let i=0;i<n;i++){const n=t[e][i];r.set(e,i,-.5*n*n)}const i=r.mean("row"),o=r.mean("column"),A=r.mean();r.add(A).subRowVector(i).subColumnVector(o);const s=new Cj(r),a=xj.sqrt(s.diagonalMatrix).diagonal(),c=s.leftSingularVectors,l=a,u=[];for(let t=0;t<c.rows;t++){const n=[];for(let r=0;r<e;r++)n.push(c.get(t,r)*l[r]);u.push(n)}return u}catch(e){const r=[];for(let e=0;e<t.length;e++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}},Oj={maxIteration:10,width:10,speed:100,gravity:10,k:5},Ij=(t,e,n,r,i)=>{let o=0;t.forEachNode(A=>{let s=0;t.forEachNode(t=>{if(s<=o)return void s++;if(A.id===t.id)return;if(r.get(A.id)!==r.get(t.id))return;let a=A.x-t.x,c=A.y-t.y,l=Math.sqrt(a*a+c*c);if(0===l){l=1;const t=o>s?1:-1;a=.01*t,c=.01*t}const u=Math.max(...i(A._original));if(l<Math.max(...i(t._original))/2+u/2){const r=n*n/l,i=e.get(A.id),o=e.get(t.id),s=a/l*r,u=c/l*r;e.set(A.id,{x:i.x+s,y:i.y+u}),e.set(t.id,{x:o.x-s,y:o.y-u})}s++}),o++})},Lj=(t,e,n,r,i,o,A)=>{r&&t.forEachNode(t=>{const n=t.x-i.x,r=t.y-i.y,o=Math.sqrt(n*n+r*r);let A=r/o,s=-n/o;const a=e.get(t.id),c=Math.sqrt(a.x*a.x+a.y*a.y);let l=Math.acos((A*a.x+s*a.y)/c);l>Math.PI/2&&(l-=Math.PI/2,A*=-1,s*=-1);const u=Math.cos(l)*c;e.set(t.id,{x:A*u,y:s*u})});let s=0,a=0;return t.forEachNode(t=>{if(t.id===i.id)return;const c=e.get(t.id),l=Math.sqrt(c.x*c.x+c.y*c.y);if(l>0){const e=Math.min(o*(n/800),l);if(t.x+=c.x/l*e,t.y+=c.y/l*e,r){let e=t.x-i.x,n=t.y-i.y;const r=Math.sqrt(e*e+n*n);e=e/r*A.get(t.id),n=n/r*A.get(t.id),t.x=i.x+e,t.y=i.y+n}s+=e,a++}}),a>0?s/a:0},Pj={focusNode:null,linkDistance:50,maxIteration:1e3,maxPreventOverlapIteration:200,preventOverlap:!1,sortStrength:10,strictRadial:!0,unitRadius:null,nodeSize:10,nodeSpacing:0};class Dj extends EC{constructor(){super(...arguments),this.id="radial"}getDefaultOptions(){return Pj}layout(){return mx(this,0,void 0,function*(){const{width:t,height:e,center:n}=kF(this.options),r=this.model.nodeCount();if(!r||1===r)return EF(this.model,n);const{focusNode:i,linkDistance:o=Pj.linkDistance,maxIteration:A=Pj.maxIteration,maxPreventOverlapIteration:s=Pj.maxPreventOverlapIteration,nodeSize:a,nodeSpacing:c,preventOverlap:l,sortBy:u,sortStrength:h=Pj.sortStrength,strictRadial:d,unitRadius:f}=this.options,g=i&&this.model.node(i)||this.model.firstNode(),p=this.model.nodeIndexOf(g.id),v=Fj(Mj(this.model)),m=Gj(v,p);_j(v,p,m+1);const y=v[p],w=(t-n[0]>n[0]?n[0]:t-n[0])||t/2,b=(e-n[1]>n[1]?n[1]:e-n[1])||e/2,B=Math.min(w,b),E=Math.max(...y),x=[],C=new Map,M=null!=f?f:B/E;y.forEach((t,e)=>{const n=t*M;x.push(n),C.set(this.model.nodeAt(e).id,n)});const F=Rj(this.model,v,o,x,M,u,h),k=Tj(F,2,o),S=k[p];let Q=0;if(this.model.forEachNode(t=>{const e=k[Q];t.x=e[0]-S[0],t.y=e[1]-S[1],Q++}),this.run(A,F,x,p),this.model.forEachNode(t=>{t.x+=n[0],t.y+=n[1]}),l){const e={nodeSizeFunc:Xx(a,c,Pj.nodeSize,Pj.nodeSpacing),radiiMap:C,width:t,strictRadial:Boolean(d),focusNode:g,maxIteration:s,k:r/4.5};((t,e)=>{const n=Object.assign(Object.assign({},Oj),e),{maxIteration:r,width:i,k:o,speed:A=Oj.speed,strictRadial:s,focusNode:a,radiiMap:c,nodeSizeFunc:l}=n,u=.002*o,h=new Map,d=i/10;for(let e=0;e<r&&(t.forEachNode(t=>{h.set(t.id,{x:0,y:0})}),Ij(t,h,o,c,l),!(Lj(t,h,A,s,a,d,c)<u));e++);})(this.model,e)}})}run(t,e,n,r){const i=Hj(e),o=this.model.nodeCount(),A=this.model.nodes(),s=new Float64Array(o),a=new Float64Array(o);for(let t=0;t<o;t++)s[t]=A[t].x,a[t]=A[t].y;for(let c=0;c<=t;c++){const l=c/t,u=1-l;for(let t=0;t<o;t++){if(t===r)continue;const c=s[t],h=a[t],d=Math.sqrt(c*c+h*h),f=0===d?0:1/d;let g=0,p=0,v=0;for(let n=0;n<o;n++){if(t===n)continue;const r=s[n],o=a[n],A=Math.sqrt((c-r)*(c-r)+(h-o)*(h-o)),l=0===A?0:1/A,u=e[n][t];v+=i[t][n],g+=i[t][n]*(r+u*(c-r)*l),p+=i[t][n]*(o+u*(h-o)*l)}const m=0===n[t]?0:1/n[t];v*=u,v+=l*m*m,g*=u,g+=l*m*c*f,p*=u,p+=l*m*h*f,s[t]=g/v,a[t]=p/v,A[t].x=s[t],A[t].y=a[t]}}}}const Rj=(t,e,n,r,i,o,A)=>{const s=e.length,a=new Array(s),c=new Array(s);for(let t=0;t<s;t++)c[t]=r[t]/i;const l=(n+i)/2,u=new Map,h=o&&"data"!==o?Vx(o,["node"]):null,d="data"===o;for(let i=0;i<s;i++){const o=e[i],f=new Array(s);a[i]=f;const g=c[i]||1;for(let e=0;e<s;e++){if(i===e){f[e]=0;continue}const s=o[e];if(r[i]===r[e])if(d)f[e]=s*Math.abs(i-e)*A/g;else if(h){const n=t.nodeAt(i),r=t.nodeAt(e);let o=u.get(n.id);if(void 0===o){const t=h(n._original)||0;o="string"==typeof t?t.charCodeAt(0):Number(t||0),u.set(n.id,o)}let a=u.get(r.id);if(void 0===a){const t=h(r._original)||0;a="string"==typeof t?t.charCodeAt(0):Number(t||0),u.set(r.id,a)}f[e]=s*Math.abs(o-a)*A/g}else f[e]=s*n/g;else f[e]=s*l}}return a},Hj=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},_j=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},Gj=(t,e)=>{const n=t[e];let r=0;for(let t=0;t<n.length;t++)n[t]!==1/0&&(r=Math.max(r,n[t]));return r};class Kj extends EC{constructor(){super(...arguments),this.id="random"}getDefaultOptions(){return{center:[0,0],width:300,height:300}}layout(){return mx(this,0,void 0,function*(){const{width:t,height:e,center:n}=kF(this.options);this.model.forEachNode(r=>{r.x=jj(t)+n[0],r.y=jj(e)+n[1]})})}}const jj=t=>.9*(Math.random()-.5)*t,zj={"antv-dagre":bF,"d3-force-3d":class extends Ok{constructor(){super(...arguments),this.id="d3-force-3d",this.config={simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource","numDimensions"]},this.forceMap={link:wS,manyBody:vS,center:cS,collide:aS,radial:Hk,x:Rk,y:Dk,z:Pk}}getDefaultOptions(){return{numDimensions:3,link:{id:t=>t.id},manyBody:{},center:{x:0,y:0,z:0}}}initSimulation(){return pS()}setupForces(t,e){Object.entries(this.forceMap).forEach(([n,r])=>{const i=n;if(e[n]){let n=t.force(i);n||(n=r(),t.force(i,n)),Ik(n,Object.entries(e[i]))}else t.force(i,null)})}},"d3-force":Ok,"force-atlas2":nj,circular:QF,concentric:NF,dagre:LK,force:qK,fruchterman:oj,grid:sj,mds:Uj,radial:Dj,random:Kj},Vj={layout:t=>t?{type:"concentric",preventOverlap:!0}:{type:"force",preventOverlap:!0},nodeSize:20,nodeSpacing:0,comboPadding:10,comboSpacing:0},Wj="root";class Yj extends EC{constructor(){super(...arguments),this.id="combo-combined",this.relativePositions=new Map,this.getParentId=t=>t.parentId||Wj}getDefaultOptions(){return Vj}layout(){return mx(this,0,void 0,function*(){const{center:t}=kF(this.options);this.resetLayoutState();const e=this.buildHierarchyTree();yield this.layoutHierarchy(e),this.convertToGlobalPositions(e,t),this.applyPositionsToModel(e)})}isCombo(t){return Boolean(t.isCombo)}resetLayoutState(){this.relativePositions.clear()}layoutHierarchy(t){return mx(this,0,void 0,function*(){for(const e of t.children||[])this.isCombo(e)&&(yield this.layoutHierarchy(e));const e=t.children||[];if(0===e.length)return t.size=[0,0,0],void(t.parentId=t.id===Wj?null:t.parentId);const n=this.getLayoutConfig(t),{type:r}=n,i=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(n,["type"]),o=new(this.getLayoutClass(r))(i),A=this.createTemporaryGraphData(e);yield function(t,e,n={}){var r;return mx(this,0,void 0,function*(){return CC(t)?(t.execute(e,n),t.stop(),t.tick(null!==(r=n.iterations)&&void 0!==r?r:300)):yield t.execute(e,n)})}(o,A,{});const s=o.model.nodes();this.recordRelativePositions(s,t);const{center:a,width:c,height:l}=this.calculateComboBounds(t);t.size=[c,l,0],(t.children||[]).forEach(t=>{const e=this.relativePositions.get(t.id);if(!e)return;const n=Object.assign(Object.assign({},e),{x:e.x-a[0],y:e.y-a[1]});this.relativePositions.set(t.id,n)})})}recordRelativePositions(t,e){const n=this.calculateComboCenter(t);t.forEach(t=>{this.relativePositions.set(t.id,{x:t.x-n[0],y:t.y-n[1],relativeTo:String(e.id)})})}buildHierarchyTree(){const t={id:Wj,isCombo:!0,children:[],parentId:null},e=new Map;return e.set(Wj,t),this.model.forEachNode(t=>{if(this.isCombo(t)){const n=Object.assign(Object.assign({},t),{children:[],parentId:this.getParentId(t)});e.set(String(t.id),n)}}),this.model.forEachNode(t=>{const n=e.get(this.getParentId(t));if(this.isCombo(t)){const r=e.get(String(t.id));n&&r&&(n.children.push(r),r.parentId=n.id)}else n&&n.children.push(Object.assign(Object.assign({},t),{children:[],parentId:this.getParentId(t)}))}),t}convertToGlobalPositions(t,e){var n,r;const i=t.id===Wj?null:this.relativePositions.get(t.id),o=e[0]+(null!==(n=null==i?void 0:i.x)&&void 0!==n?n:0),A=e[1]+(null!==(r=null==i?void 0:i.y)&&void 0!==r?r:0);t.x=o,t.y=A,(t.children||[]).forEach(t=>{var e,n;const r=this.relativePositions.get(t.id);t.x=o+(null!==(e=null==r?void 0:r.x)&&void 0!==e?e:0),t.y=A+(null!==(n=null==r?void 0:r.y)&&void 0!==n?n:0),t.size=this.getNodeLikeSize(t,!1),this.isCombo(t)&&this.convertToGlobalPositions(t,[o,A])})}getLayoutConfig(t){const e="object"==typeof this.options.layout?this.options.layout:Vx(this.options.layout,["comboId"]);if("function"==typeof e){const n=t.id===Wj?null:t.id;return this.normalizeLayoutConfig(e(n))}return this.normalizeLayoutConfig(e)}normalizeLayoutConfig(t){const e=Object.assign(Object.assign({type:"concentric"},kF(this.options)),{nodeSize:"node.size",nodeSpacing:0});return t?"string"==typeof t?Object.assign(Object.assign({},e),{type:t}):Object.assign(Object.assign({},e),t):e}getLayoutClass(t){return zj[t]||zj.concentric}createTemporaryGraphData(t){const e=t.map(t=>Object.assign(Object.assign({},t),{size:this.getNodeLikeSize(t)})),n=new Set(t.map(t=>String(t.id))),r=[],i=t=>{let e=String(t);const r=new Set;for(;e&&!r.has(e);){if(n.has(e))return e;r.add(e);const t=this.model.node(e),i=null==t?void 0:t.parentId;e=null==i?null:String(i)}return null};return this.model.forEachEdge(t=>{const e=i(String(t.source)),n=i(String(t.target));e&&n&&e!==n&&r.push({source:e,target:n})}),{nodes:e,edges:r}}calculateComboCenter(t){if(0===t.length)return[0,0];const e=new Map;t.forEach(t=>{const n=this.getNodeLikeSize(t);e.set(t.id,n)});let n=1/0,r=1/0,i=-1/0,o=-1/0;return t.forEach(t=>{const[A=0,s=0]=e.get(t.id);n=Math.min(n,t.x-A/2),r=Math.min(r,t.y-s/2),i=Math.max(i,t.x+A/2),o=Math.max(o,t.y+s/2)}),Number.isFinite(n)&&Number.isFinite(r)?[(n+i)/2,(r+o)/2]:[0,0]}calculateComboBounds(t){const e=t.children||[];if(0===e.length)return{center:[0,0],width:0,height:0};let n=1/0,r=1/0,i=-1/0,o=-1/0;if(e.forEach(t=>{var e,A;const s=this.relativePositions.get(t.id),a=null!==(e=null==s?void 0:s.x)&&void 0!==e?e:0,c=null!==(A=null==s?void 0:s.y)&&void 0!==A?A:0,[l,u]=this.getNodeLikeSize(t);n=Math.min(n,a-l/2),r=Math.min(r,c-u/2),i=Math.max(i,a+l/2),o=Math.max(o,c+u/2)}),!Number.isFinite(n)||!Number.isFinite(r))return{center:[0,0],width:0,height:0};const A=Wx(this.options.comboPadding,20,"combo")(t._original);return{center:[(n+i)/2,(r+o)/2],width:i-n+2*A,height:o-r+2*A}}getNodeLikeSize(t,e=!0){return this.isCombo(t)?this.getComboSize(t,e):this.getNodeSize(t,e)}getNodeSize(t,e=!0){const{nodeSize:n,nodeSpacing:r}=this.options;return Xx(n,e?r:0)(t._original)}getComboSize(t,e=!0){const n=Wx(this.options.comboSpacing,0,"combo"),r=e?n(t._original):0,[i,o]=t.size;return[i+r/2,o+r/2,0]}applyPositionsToModel(t){const e=t=>{const e=this.model.node(t.id);e&&(e.x=t.x,e.y=t.y,t.size&&(e.size=t.size))},n=t=>{t.id!==Wj&&e(t),(t.children||[]).forEach(t=>{this.isCombo(t)?n(t):e(t)})};n(t)}}class Xj extends mE{constructor(){super(...arguments),this.id="fishbone"}getRoot(){const t=this.context.model.getRootsData();if(!(Ee(t)||t.length>2))return t[0]}formatSize(t){const e="function"==typeof t?t:()=>t;return t=>cw(e(t))}doLayout(t,e){const{hGap:n,getRibSep:r,vGap:i,nodeSize:o,height:A}=e,{model:s}=this.context,a=this.formatSize(o);let c=a(t)[0]+r(t);const l=(t,e=0)=>{var r;return e+=n*((t.children||[]).length+1),null===(r=t.children)||void 0===r||r.forEach(t=>{var n;null===(n=s.getNodeLikeDatum(t).children)||void 0===n||n.forEach(t=>{const n=s.getNodeLikeDatum(t);e=l(n,e)})}),e},u=t=>{if(1===t.depth)return c;const e=s.getParentData(t.id,"tree");if(Zj(t)){const r=s.getParentData(e.id,"tree"),o=f(t)-f(r);return u(e)+o*n/i}{const n=(e.children||[]).indexOf(t.id),r=s.getNodeData((e.children||[]).slice(n));return h(e)-r.reduce((t,e)=>t+l(e),0)-a(e)[0]/2}},h=me(t=>{if($j(t))return a(t)[0]/2;const e=s.getParentData(t.id,"tree");if(Zj(t))return u(t)+l(t)+a(t)[0]/2;{const r=f(t)-f(e),o=n/i;return u(t)+r*o}},t=>t.id),d=t=>f(s.getParentData(t,"tree")),f=me(t=>{if($j(t))return A/2;if(Zj(t)){const e=s.getParentData(t.id,"tree"),n=e.children.indexOf(t.id);if(0===n)return d(e.id)+i;const r=s.getNodeLikeDatum(e.children[n-1]);if(Ee(r.children))return f(r)+i;const o=s.getDescendantsData(r.id);return Math.max(...o.map(t=>Zj(t)?d(t.id):f(t)))+i}{if(Ee(t.children))return d(t.id)+i;const e=s.getNodeLikeDatum(t.children.slice(-1)[0]);if(Ee(e.children))return f(e)+i;const n=s.getDescendantsData(t.id).slice(-1)[0];return(Zj(n)?d(n.id):f(n))+i}},t=>t.id);let g=0;const p={nodes:[],edges:[]},v=t=>{var e;null===(e=t.children)||void 0===e||e.forEach(t=>v(s.getNodeLikeDatum(t)));const n=f(t),i=h(t);if(p.nodes.push({id:t.id,x:i,y:n}),$j(t))return;const o=s.getRelatedEdgesData(t.id,"in")[0],A=[u(t),Zj(t)?n:d(t.id)];p.edges.push({id:Km(o),controlPoints:[A],relatedNodeId:t.id}),g=Math.max(g,i+r(t)),1===t.depth&&(c=g)};return v(t),p}placeAlterative(t,e){const n=(e.children||[]).filter((t,e)=>e%2!=0);if(0===n.length)return t;const{model:r}=this.context,i=t.nodes.find(t=>t.id===e.id).y,o=t=>{const e=r.getAncestorsData(t,"tree");if(Ee(e))return!1;const i=1===e.length?t:e[e.length-2].id;return n.includes(i)};t.nodes.forEach(t=>{o(t.id)&&(t.y=2*i-t.y)}),t.edges.forEach(t=>{o(t.relatedNodeId)&&(t.controlPoints=t.controlPoints.map(t=>[t[0],2*i-t[1]]))})}rightToLeft(t,e){return t.nodes.forEach(t=>t.x=e.width-t.x),t.edges.forEach(t=>{t.controlPoints=t.controlPoints.map(t=>[e.width-t[0],t[1]])}),t}execute(t,e){return De(this,void 0,void 0,function*(){const n=Object.assign(Object.assign(Object.assign({},Xj.defaultOptions),this.options),e),{direction:r,nodeSize:i}=n,o=this.getRoot();if(!o)return t;const A=this.formatSize(i);n.vGap||(n.vGap=Math.max(...(t.nodes||[]).map(t=>A(t)[1]))),n.hGap||(n.hGap=Math.max(...(t.nodes||[]).map(t=>A(t)[0])));let s=this.doLayout(o,n);this.placeAlterative(s,o),"RL"===r&&(s=this.rightToLeft(s,n));const{model:a}=this.context,c=[],l=[];return s.nodes.forEach(t=>{const{id:e,x:n,y:r}=t,i=a.getNodeLikeDatum(e);c.push(qj(i,{x:n,y:r}))}),s.edges.forEach(t=>{const{id:e,controlPoints:n}=t,r=a.getEdgeDatum(e);l.push(qj(r,{controlPoints:n}))}),{nodes:c,edges:l}})}}Xj.defaultOptions={direction:"RL",getRibSep:()=>60};const qj=(t,e)=>Object.assign(Object.assign({},t),{style:Object.assign(Object.assign({},t.style||{}),e)}),$j=t=>0===t.depth,Zj=t=>(t.depth||(t.depth=0))%2==0;class Jj extends mE{constructor(){super(...arguments),this.id="snake"}formatSize(t,e){const n="function"==typeof e?e:()=>e;return t.reduce((t,e)=>{const[r,i]=cw(n(e))||[0,0];return[Math.max(t[0],r),Math.max(t[1],i)]},[0,0])}validate(t){const{nodes:e=[],edges:n=[]}=t,r={},i={},o={};e.forEach(t=>{r[t.id]=0,i[t.id]=0,o[t.id]=[]}),n.forEach(t=>{r[t.target]++,i[t.source]++,o[t.source].push(t.target)});const A=new Set,s=t=>{A.has(t)||(A.add(t),o[t].forEach(s))};if(s(e[0].id),A.size!==e.length)return!1;const a=e.filter(t=>0===r[t.id]),c=e.filter(t=>0===i[t.id]);if(1!==a.length||1!==c.length)return!1;return e.filter(t=>1===r[t.id]&&1===i[t.id]).length===e.length-2}execute(t,e){return De(this,void 0,void 0,function*(){var n;if(!this.validate(t))return t;const{nodeSize:r,padding:i,sortBy:o,cols:A,colGap:s,rowGap:a,clockwise:c,width:l,height:u}=Object.assign({},Jj.defaultOptions,this.options,e),[h,d,f,g]=pm(i),p=this.formatSize(t.nodes||[],r),v=Math.ceil((t.nodes||[]).length/A);let m=s||(l-g-d-A*p[0])/(A-1),y=a||(u-h-f-v*p[1])/(v-1);(y===1/0||y<0)&&(y=0),(m===1/0||m<0)&&(m=0);const w=o?null===(n=t.nodes)||void 0===n?void 0:n.sort(o):function(t){const{nodes:e=[],edges:n=[]}=t,r={},i={};e.forEach(t=>{r[t.id]=0,i[t.id]=[]}),n.forEach(t=>{r[t.target]++,i[t.source].push(t.target)});const o=[],A=[];e.forEach(t=>{0===r[t.id]&&o.push(t.id)});for(;o.length>0;){const t=o.shift(),n=e.find(e=>e.id===t);A.push(n),i[t].forEach(t=>{r[t]--,0===r[t]&&o.push(t)})}return A}(t),b=(w||[]).map((t,e)=>{const n=Math.floor(e/A),r=e%A,i=g+(c?n%2==0?r:A-1-r:n%2==0?A-1-r:r)*(p[0]+m)+p[0]/2,o=h+n*(p[1]+y)+p[1]/2;return{id:t.id,style:{x:i,y:o}}});return{nodes:b}})}}Jj.defaultOptions={padding:0,cols:5,clockwise:!0};class tz extends ry{}function ez(t,e=!0,n){const r=document.createElement("div");return r.setAttribute("class",`g6-${t}`),Object.assign(r.style,{position:"absolute",display:"block"}),e&&Object.assign(r.style,{position:"unset",gridArea:"1 / 1 / 2 / 2",inset:"0px",height:"100%",width:"100%",overflow:"hidden",pointerEvents:"none"}),n&&Object.assign(r.style,n),r}function nz(t,e="div",n={},r="",i=document.body){const o=document.getElementById(t);o&&o.remove();const A=document.createElement(e);return A.innerHTML=r,A.id=t,Object.assign(A.style,n),i.appendChild(A),A}class rz extends tz{constructor(t,e){super(t,Object.assign({},rz.defaultOptions,e)),this.$element=ez("background");this.context.canvas.getContainer().prepend(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t),Object.assign(this.$element.style,Se(this.options,["key","type"]))})}destroy(){super.destroy(),this.$element.remove()}}function iz(t,e,n,r,i,o){const A=n-t,s=r-e;let a=i-t,c=o-e,l=a*A+c*s,u=0;l<=0?u=0:(a=A-a,c=s-c,l=a*A+c*s,u=l<=0?0:l*l/(A*A+s*s));const h=a*a+c*c-u;return h<0?0:h}function oz(t,e,n,r){return(t-n)*(t-n)+(e-r)*(e-r)}function Az(t,e,n,r,i){return oz(t,e,n,r)<i*i}function sz(t){const e=Math.min(t.x1,t.x2),n=Math.max(t.x1,t.x2),r=Math.min(t.y1,t.y2),i=Math.max(t.y1,t.y2);return{x:e,y:r,x2:n,y2:i,width:n-e,height:i-r}}rz.defaultOptions={transition:"background 0.5s",backgroundSize:"cover",zIndex:"-1"};class az{constructor(t,e,n,r){this.x1=t,this.y1=e,this.x2=n,this.y2=r}equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2}draw(t){t.moveTo(this.x1,this.y1),t.lineTo(this.x2,this.y2)}toString(){return`Line(from=(${this.x1},${this.y1}),to=(${this.x2},${this.y2}))`}static from(t){return new az(t.x1,t.y1,t.x2,t.y2)}cuts(t,e){if(this.y1===this.y2)return!1;if(e<this.y1&&e<=this.y2||e>this.y1&&e>=this.y2)return!1;if(t>this.x1&&t>=this.x2)return!1;if(t<this.x1&&t<=this.x2)return!0;return t<=this.x1+(e-this.y1)*(this.x2-this.x1)/(this.y2-this.y1)}distSquare(t,e){return iz(this.x1,this.y1,this.x2,this.y2,t,e)}ptClose(t,e,n){if(this.x1<this.x2){if(t<this.x1-n||t>this.x2+n)return!1}else if(t<this.x2-n||t>this.x1+n)return!1;if(this.y1<this.y2){if(e<this.y1-n||e>this.y2+n)return!1}else if(e<this.y2-n||e>this.y1+n)return!1;return!0}}var cz,lz;!function(t){t[t.POINT=1]="POINT",t[t.PARALLEL=2]="PARALLEL",t[t.COINCIDENT=3]="COINCIDENT",t[t.NONE=4]="NONE"}(cz||(cz={}));class uz{constructor(t,e=0,n=0){this.state=t,this.x=e,this.y=n}}function hz(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const e=n/i,o=r/i;return 0<=e&&e<=1&&0<=o&&o<=1?new uz(cz.POINT,t.x1+e*(t.x2-t.x1),t.y1+e*(t.y2-t.y1)):new uz(cz.NONE)}return new uz(0===n||0===r?cz.COINCIDENT:cz.PARALLEL)}function dz(t,e){const n=(e.x2-e.x1)*(t.y1-e.y1)-(e.y2-e.y1)*(t.x1-e.x1),r=(t.x2-t.x1)*(t.y1-e.y1)-(t.y2-t.y1)*(t.x1-e.x1),i=(e.y2-e.y1)*(t.x2-t.x1)-(e.x2-e.x1)*(t.y2-t.y1);if(i){const t=n/i,e=r/i;if(0<=t&&t<=1&&0<=e&&e<=1)return t}return Number.POSITIVE_INFINITY}function fz(t,e,n){const r=new Set;return t.width<=0?(r.add(lz.LEFT),r.add(lz.RIGHT)):e<t.x?r.add(lz.LEFT):e>t.x+t.width&&r.add(lz.RIGHT),t.height<=0?(r.add(lz.TOP),r.add(lz.BOTTOM)):n<t.y?r.add(lz.TOP):n>t.y+t.height&&r.add(lz.BOTTOM),r}function gz(t,e){let n=e.x1,r=e.y1;const i=e.x2,o=e.y2,A=Array.from(fz(t,i,o));if(0===A.length)return!0;let s=fz(t,n,r);for(;0!==s.size;){for(const t of A)if(s.has(t))return!1;if(s.has(lz.RIGHT)||s.has(lz.LEFT)){let e=t.x;s.has(lz.RIGHT)&&(e+=t.width),r+=(e-n)*(o-r)/(i-n),n=e}else{let e=t.y;s.has(lz.BOTTOM)&&(e+=t.height),n+=(e-r)*(i-n)/(o-r),r=e}s=fz(t,n,r)}return!0}function pz(t,e){let n=Number.POSITIVE_INFINITY,r=0;function i(t,i,o,A){let s=dz(e,new az(t,i,o,A));s=Math.abs(s-.5),s>=0&&s<=1&&(r++,s<n&&(n=s))}return i(t.x,t.y,t.x2,t.y),i(t.x,t.y,t.x,t.y2),r>1?n:(i(t.x,t.y2,t.x2,t.y2),r>1?n:(i(t.x2,t.y,t.x2,t.y2),0===r?-1:n))}function vz(t,e){let n=0;const r=hz(t,new az(e.x,e.y,e.x2,e.y));n+=r.state===cz.POINT?1:0;const i=hz(t,new az(e.x,e.y,e.x,e.y2));n+=i.state===cz.POINT?1:0;const o=hz(t,new az(e.x,e.y2,e.x2,e.y2));n+=o.state===cz.POINT?1:0;const A=hz(t,new az(e.x2,e.y,e.x2,e.y2));return n+=A.state===cz.POINT?1:0,{top:r,left:i,bottom:o,right:A,count:n}}!function(t){t[t.LEFT=0]="LEFT",t[t.TOP=1]="TOP",t[t.RIGHT=2]="RIGHT",t[t.BOTTOM=3]="BOTTOM"}(lz||(lz={}));class mz{constructor(t,e,n,r){this.x=t,this.y=e,this.width=n,this.height=r}get x2(){return this.x+this.width}get y2(){return this.y+this.height}get cx(){return this.x+this.width/2}get cy(){return this.y+this.height/2}get radius(){return Math.max(this.width,this.height)/2}static from(t){return new mz(t.x,t.y,t.width,t.height)}equals(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}clone(){return new mz(this.x,this.y,this.width,this.height)}add(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x+t.width),i=Math.max(this.y2,t.y+t.height);this.x=e,this.y=n,this.width=r-e,this.height=i-n}addPoint(t){const e=Math.min(this.x,t.x),n=Math.min(this.y,t.y),r=Math.max(this.x2,t.x),i=Math.max(this.y2,t.y);this.x=e,this.y=n,this.width=r-e,this.height=i-n}toString(){return`Rectangle[x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height}]`}draw(t){t.rect(this.x,this.y,this.width,this.height)}containsPt(t,e){return t>=this.x&&t<=this.x2&&e>=this.y&&e<=this.y2}get area(){return this.width*this.height}intersects(t){return!(this.area<=0||t.width<=0||t.height<=0)&&(t.x+t.width>this.x&&t.y+t.height>this.y&&t.x<this.x2&&t.y<this.y2)}distSquare(t,e){if(this.containsPt(t,e))return 0;const n=fz(this,t,e);return n.has(lz.TOP)?n.has(lz.LEFT)?oz(t,e,this.x,this.y):n.has(lz.RIGHT)?oz(t,e,this.x2,this.y):(this.y-e)*(this.y-e):n.has(lz.BOTTOM)?n.has(lz.LEFT)?oz(t,e,this.x,this.y2):n.has(lz.RIGHT)?oz(t,e,this.x2,this.y2):(e-this.y2)*(e-this.y2):n.has(lz.LEFT)?(this.x-t)*(this.x-t):n.has(lz.RIGHT)?(t-this.x2)*(t-this.x2):0}}class yz{constructor(t,e,n){this.cx=t,this.cy=e,this.radius=n}get x(){return this.cx-this.radius}get x2(){return this.cx+this.radius}get width(){return 2*this.radius}get y(){return this.cy-this.radius}get y2(){return this.cy+this.radius}get height(){return 2*this.radius}static from(t){return new yz(t.cx,t.cy,t.radius)}containsPt(t,e){return oz(this.cx,this.cy,t,e)<this.radius*this.radius}distSquare(t,e){const n=oz(this.cx,this.cy,t,e);if(n<this.radius*this.radius)return 0;const r=Math.sqrt(n)-this.radius;return r*r}draw(t){t.ellipse(this.cx,this.cy,this.radius,this.radius,0,0,2*Math.PI)}}class wz{constructor(t,e=0,n=0,r=0,i=0,o=10,A=10,s=new Float32Array(Math.max(0,o*A)).fill(0)){this.pixelGroup=t,this.i=e,this.j=n,this.pixelX=r,this.pixelY=i,this.width=o,this.height=A,this.area=s}createSub(t,e){return new wz(this.pixelGroup,t.x,t.y,e.x,e.y,t.width,t.height)}static fromPixelRegion(t,e){return new wz(e,0,0,t.x,t.y,Math.ceil(t.width/e),Math.ceil(t.height/e))}copy(t,e){return new wz(this.pixelGroup,this.scaleX(e.x),this.scaleY(e.y),e.x,e.y,t.width,t.height,t.area)}boundX(t){return t<this.i?this.i:t>=this.width?this.width-1:t}boundY(t){return t<this.j?this.j:t>=this.height?this.height-1:t}scaleX(t){return this.boundX(Math.floor((t-this.pixelX)/this.pixelGroup))}scaleY(t){return this.boundY(Math.floor((t-this.pixelY)/this.pixelGroup))}scale(t){const e=this.scaleX(t.x),n=this.scaleY(t.y),r=this.boundX(Math.ceil((t.x+t.width-this.pixelX)/this.pixelGroup)),i=this.boundY(Math.ceil((t.y+t.height-this.pixelY)/this.pixelGroup));return new mz(e,n,r-e,i-n)}invertScaleX(t){return Math.round(t*this.pixelGroup+this.pixelX)}invertScaleY(t){return Math.round(t*this.pixelGroup+this.pixelY)}addPadding(t,e){const n=Math.ceil(e/this.pixelGroup),r=this.boundX(t.x-n),i=this.boundY(t.y-n),o=this.boundX(t.x2+n),A=this.boundY(t.y2+n);return new mz(r,i,o-r,A-i)}get(t,e){return t<0||e<0||t>=this.width||e>=this.height?Number.NaN:this.area[t+e*this.width]}inc(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]+=n)}set(t,e,n){t<0||e<0||t>=this.width||e>=this.height||(this.area[t+e*this.width]=n)}incArea(t,e){if(t.width<=0||t.height<=0||0===e)return;const n=this.width,r=t.width,i=Math.max(0,t.i),o=Math.max(0,t.j),A=Math.min(t.i+t.width,n),s=Math.min(t.j+t.height,this.height);if(!(s<=0||A<=0||i>=n||s>=this.height))for(let a=o;a<s;a++){const o=(a-t.j)*r,s=a*n;for(let n=i;n<A;n++){const r=t.area[n-t.i+o];0!==r&&(this.area[n+s]+=e*r)}}}fill(t){this.area.fill(t)}fillArea(t,e){const n=t.x+t.y*this.width;for(let r=0;r<t.height;r++){const i=n+r*this.width;this.area.fill(e,i,i+t.width)}}fillHorizontalLine(t,e,n,r){const i=t+e*this.width;this.area.fill(r,i,i+n)}fillVerticalLine(t,e,n,r){const i=t+e*this.width;for(let t=0;t<n;t++)this.area[i+t*this.width]=r}clear(){this.area.fill(0)}toString(){let t="";for(let e=0;e<this.height;e++){const n=e*this.width;for(let e=0;e<this.width;e++){t+=this.area[n+e].toFixed(1).padStart(6),t+=" "}t+="\n"}return t}draw(t,e=!0){if(this.width<=0||this.height<=0)return;t.save(),e&&t.translate(this.pixelX,this.pixelY);const n=this.area.reduce((t,e)=>Math.min(t,e),Number.POSITIVE_INFINITY),r=this.area.reduce((t,e)=>Math.max(t,e),Number.NEGATIVE_INFINITY),i=t=>(t-n)/(r-n);t.scale(this.pixelGroup,this.pixelGroup);for(let e=0;e<this.width;e++)for(let n=0;n<this.height;n++){const r=this.area[e+n*this.width];t.fillStyle=`rgba(0, 0, 0, ${i(r)})`,t.fillRect(e,n,1,1)}t.restore()}drawThreshold(t,e,n=!0){if(!(this.width<=0||this.height<=0)){t.save(),n&&t.translate(this.pixelX,this.pixelY),t.scale(this.pixelGroup,this.pixelGroup);for(let n=0;n<this.width;n++)for(let r=0;r<this.height;r++){const i=this.area[n+r*this.width];t.fillStyle=i>e?"black":"white",t.fillRect(n,r,1,1)}t.restore()}}}function bz(t,e){const n=t=>({x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e});return Array.isArray(t)?t.map(n):n(t)}function Bz(t,e,n){return Ez(Object.assign(sz(t),{distSquare:(e,n)=>iz(t.x1,t.y1,t.x2,t.y2,e,n)}),e,n)}function Ez(t,e,n){const r=bz(t,n),i=e.scale(r),o=e.createSub(i,r);return function(t,e,n,r){const i=n*n;for(let o=0;o<t.height;o++)for(let A=0;A<t.width;A++){const s=r(e.invertScaleX(t.i+A),e.invertScaleY(t.j+o));if(0!==s){if(s<i){const e=n-Math.sqrt(s);t.set(A,o,e*e)}}else t.set(A,o,i)}}(o,e,n,(e,n)=>t.distSquare(e,n)),o}function xz(t,e){return{x:t,y:e}}function Cz(t,e,n,r){if(0===t.length)return[];const i=function(t){if(t.length<2)return t;let e=0,n=0;return t.forEach(t=>{e+=t.cx,n+=t.cy}),e/=t.length,n/=t.length,t.map(t=>{const r=e-t.cx,i=n-t.cy;return[t,r*r+i*i]}).sort((t,e)=>t[1]-e[1]).map(t=>t[0])}(t);return i.map((t,o)=>{const A=i.slice(0,o);return function(t,e,n,r,i){const o=xz(e.cx,e.cy),A=function(t,e,n){let r=Number.POSITIVE_INFINITY;return e.reduce((e,i)=>{const o=oz(t.x,t.y,i.cx,i.cy);if(o>r)return e;const A=new az(t.x,t.y,i.cx,i.cy),s=function(t,e){return t.reduce((t,n)=>gz(n,e)&&function(t,e){function n(t,n,r,i){let o=dz(e,new az(t,n,r,i));return o=Math.abs(o-.5),o>=0&&o<=1?1:0}let r=n(t.x,t.y,t.x2,t.y);return r+=n(t.x,t.y,t.x,t.y2),r>1||(r+=n(t.x,t.y2,t.x2,t.y2),r>1||(r+=n(t.x2,t.y,t.x2,t.y2),r>0))}(n,e)?t+1:t,0)}(n,A);return o*(s+1)*(s+1)<r&&(e=i,r=o*(s+1)*(s+1)),e},null)}(o,n,t);if(null==A)return[];const s=function(t,e,n,r){const i=[],o=[];o.push(t);let A=!0;for(let t=0;t<n&&A;t++)for(A=!1;!A&&o.length>0;){const t=o.pop(),n=kz(e,t),s=n?vz(t,n):null;if(!n||!s||2!==s.count){A||i.push(t);continue}let a=r,c=Sz(n,a,s,!0),l=Fz(c,o)||Fz(c,i),u=Mz(c,e);for(;!l&&u&&a>=1;)a/=1.5,c=Sz(n,a,s,!0),l=Fz(c,o)||Fz(c,i),u=Mz(c,e);if(!c||l||u||(o.push(new az(t.x1,t.y1,c.x,c.y)),o.push(new az(c.x,c.y,t.x2,t.y2)),A=!0),A)continue;a=r,c=Sz(n,a,s,!1);let h=Fz(c,o)||Fz(c,i);for(u=Mz(c,e);!h&&u&&a>=1;)a/=1.5,c=Sz(n,a,s,!1),h=Fz(c,o)||Fz(c,i),u=Mz(c,e);c&&!h&&(o.push(new az(t.x1,t.y1,c.x,c.y)),o.push(new az(c.x,c.y,t.x2,t.y2)),A=!0),A||i.push(t)}for(;o.length>0;)i.push(o.pop());return i}(new az(o.x,o.y,A.cx,A.cy),t,r,i);return function(t,e){const n=[];for(;t.length>0;){const r=t.pop();if(0===t.length){n.push(r);break}const i=t.pop(),o=new az(r.x1,r.y1,i.x2,i.y2);kz(e,o)?(n.push(r),t.push(i)):t.push(o)}return n}(s,t)}(e,t,A,n,r)}).flat()}function Mz(t,e){return e.some(e=>e.containsPt(t.x,t.y))}function Fz(t,e){return e.some(e=>!!Az(e.x1,e.y1,t.x,t.y,.001)||!!Az(e.x2,e.y2,t.x,t.y,.001))}function kz(t,e){let n=Number.POSITIVE_INFINITY,r=null;for(const i of t){if(!gz(i,e))continue;const t=pz(i,e);t>=0&&t<n&&(r=i,n=t)}return r}function Sz(t,e,n,r){const i=n.top,o=n.left,A=n.bottom,s=n.right;if(r){if(o.state===cz.POINT){if(i.state===cz.POINT)return xz(t.x-e,t.y-e);if(A.state===cz.POINT)return xz(t.x-e,t.y2+e);const n=t.width*t.height;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?xz(t.x-e,t.y-e):xz(t.x2+e,t.y-e):o.y<s.y?xz(t.x-e,t.y2+e):xz(t.x2+e,t.y2+e)}if(s.state===cz.POINT){if(i.state===cz.POINT)return xz(t.x2+e,t.y-e);if(A.state===cz.POINT)return xz(t.x2+e,t.y2+e)}const n=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*n?i.x>A.x?xz(t.x-e,t.y-e):xz(t.x-e,t.y2+e):i.x<A.x?xz(t.x2+e,t.y-e):xz(t.x2+e,t.y2+e)}if(o.state===cz.POINT){if(i.state===cz.POINT)return xz(t.x2+e,t.y2+e);if(A.state===cz.POINT)return xz(t.x2+e,t.y-e);const n=t.height*t.width;return t.width*(.5*(o.y-t.y+(s.y-t.y)))<.5*n?o.y>s.y?xz(t.x2+e,t.y2+e):xz(t.x-e,t.y2+e):o.y<s.y?xz(t.x2+e,t.y-e):xz(t.x-e,t.y-e)}if(s.state===cz.POINT){if(i.state===cz.POINT)return xz(t.x-e,t.y2+e);if(A.state===cz.POINT)return xz(t.x-e,t.y-e)}const a=t.height*t.width;return t.height*(.5*(i.x-t.x+(s.x-t.x)))<.5*a?i.x>A.x?xz(t.x2+e,t.y2+e):xz(t.x2+e,t.y-e):i.x<A.x?xz(t.x-e,t.y2+e):xz(t.x-e,t.y-e)}function Qz(t,e,n,r){if(!(t.closed?n<t.length:n<t.length-1))return!1;const i=t.get(e),o=t.get(n+1);for(let A=e+1;A<=n;A++){const e=t.get(A);if(iz(i.x,i.y,o.x,o.y,e.x,e.y)>r)return!1}return!0}function Uz(t,e){switch(t){case-2:return(((3-e)*e-3)*e+1)/6;case-1:return((3*e-6)*e*e+4)/6;case 0:return(((-3*e+3)*e+3)*e+1)/6;case 1:return e*e*e/6;default:throw new Error("unknown error")}}class Nz{constructor(t=[],e=!0){this.points=t,this.closed=e}get(t){const e=t,n=this.points.length;return t<0?this.closed?this.get(t+n):this.points[0]:t>=n?this.closed?this.get(t-n):this.points[n-1]:this.points[e]}get length(){return this.points.length}toString(t=1/0){const e=this.points;if(0===e.length)return"";const n="function"==typeof t?t:function(t){if(!Number.isFinite(t))return t=>t;if(0===t)return Math.round;const e=Math.pow(10,t);return t=>Math.round(t*e)/e}(t);let r="M";for(const t of e)r+=`${n(t.x)},${n(t.y)} L`;return r=r.slice(0,-1),this.closed&&(r+=" Z"),r}draw(t){const e=this.points;if(0!==e.length){t.beginPath(),t.moveTo(e[0].x,e[0].y);for(const n of e)t.lineTo(n.x,n.y);this.closed&&t.closePath()}}sample(t){return function(t=8){return e=>{let n=t,r=e.length;if(n>1)for(r=Math.floor(e.length/n);r<3&&n>1;)n-=1,r=Math.floor(e.length/n);const i=[];for(let t=0,o=0;o<r;o++,t+=n)i.push(e.get(t));return new Nz(i)}}(t)(this)}simplify(t){return function(t=0){return e=>{if(t<0||e.length<3)return e;const n=[];let r=0;const i=t*t;for(;r<e.length;){let t=r+1;for(;Qz(e,r,t,i);)t++;n.push(e.get(r)),r=t}return new Nz(n)}}(t)(this)}bSplines(t){return function(t=6){function e(t,e,n){let r=0,i=0;for(let o=-2;o<=1;o++){const A=t.get(e+o),s=Uz(o,n);r+=s*A.x,i+=s*A.y}return{x:r,y:i}}return n=>{if(n.length<3)return n;const r=[],i=n.closed,o=n.length+3-1+(i?0:2);r.push(e(n,2-(i?0:2),0));for(let A=2-(i?0:2);A<o;A++)for(let i=1;i<=t;i++)r.push(e(n,A,i/t));return new Nz(r)}}(t)(this)}apply(t){return t(this)}containsElements(t){const e=function(t){if(0===t.length)return null;const e=t[0],n=new mz(e.x,e.y,0,0);for(const e of t)n.addPoint(e);return n}(this.points);return!!e&&t.every(t=>e.containsPt(t.cx,t.cy)&&this.withinArea(t.cx,t.cy))}withinArea(t,e){if(0===this.length)return!1;let n=0;const r=this.points[0],i=new az(r.x,r.y,r.x,r.y);for(let r=1;r<this.points.length;r++){const o=this.points[r];i.x1=i.x2,i.y1=i.y2,i.x2=o.x,i.y2=o.y,i.cuts(t,e)&&n++}return i.x1=i.x2,i.y1=i.y2,i.x2=r.x,i.y2=r.y,i.cuts(t,e)&&n++,n%2==1}}class Tz{constructor(t=0){this.count=0,this.arr=[],this.set=new Set,this.arr.length=t}add(t){this.set.add(`${t.x}x${t.y}`),this.arr[this.count++]=t}contains(t){return this.set.has(`${t.x}x${t.y}`)}isFirst(t){if(0===this.count)return!1;const e=this.arr[0];return null!=e&&e.x===t.x&&e.y===t.y}path(){return new Nz(this.arr.slice(0,this.count))}clear(){this.set.clear(),this.count=0}get(t){return this.arr[t]}get length(){return this.count}}function Oz(t,e){const n=2*(Math.floor(t.width)+Math.floor(t.height)),r=new Tz(n);function i(n,r,i,o){const A=t.get(n,r);return Number.isNaN(A)?Number.NaN:A>e?i+o:i}function o(t,e){let n=0;return n=i(t,e,n,1),n=i(t+1,e,n,2),n=i(t,e+1,n,4),n=i(t+1,e+1,n,8),Number.isNaN(n)?-1:n}let A=1;function s(e,n){let i=e,s=n,a=t.invertScaleX(i),c=t.invertScaleY(s);for(let e=0;e<t.width*t.height;e++){const e={x:a,y:c};if(r.contains(e)){if(r.isFirst(e))return!0}else r.add(e);const n=o(i,s);switch(n){case-1:return!0;case 0:case 3:case 2:case 7:A=2;break;case 12:case 14:case 4:A=3;break;case 6:A=0===A?3:2;break;case 1:case 13:case 5:A=0;break;case 9:A=2===A?0:1;break;case 10:case 8:case 11:A=1;break;default:return console.warn("Marching squares invalid state: "+n),!0}switch(A){case 0:s--,c-=t.pixelGroup;break;case 1:s++,c+=t.pixelGroup;break;case 3:i--,a-=t.pixelGroup;break;case 2:i++,a+=t.pixelGroup;break;default:return console.warn("Marching squares invalid state: "+n),!0}}return!0}for(let n=0;n<t.width;n++)for(let i=0;i<t.height;i++){if(t.get(n,i)<=e)continue;const A=o(n,i);if(!(A<0||15===A)&&s(n,i))return r.path()}return null}const Iz={maxRoutingIterations:100,maxMarchingIterations:20,pixelGroup:4,edgeR0:10,edgeR1:20,nodeR0:15,nodeR1:50,morphBuffer:10,threshold:1,memberInfluenceFactor:1,edgeInfluenceFactor:1,nonMemberInfluenceFactor:-.8,virtualEdges:!0};function Lz(t){return null!=t&&"number"==typeof t.radius}function Pz(t,e){if(Lz(t)!==Lz(e))return!1;if(Lz(t)){const n=e;return t.cx===n.cx&&t.cy===n.cy&&t.radius===n.radius}const n=e;return t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height}var Dz;!function(t){t[t.MEMBERS=0]="MEMBERS",t[t.NON_MEMBERS=1]="NON_MEMBERS",t[t.EDGES=2]="EDGES"}(Dz||(Dz={}));let Rz=class{constructor(t={}){this.dirty=new Set,this.members=[],this.nonMembers=[],this.virtualEdges=[],this.edges=[],this.activeRegion=new mz(0,0,0,0),this.potentialArea=new wz(1,0,0,0,0,0,0),this.o=Object.assign({},Iz,t)}pushMember(...t){if(0!==t.length){this.dirty.add(Dz.MEMBERS);for(const e of t)this.members.push({raw:e,obj:Lz(e)?yz.from(e):mz.from(e),area:null})}}removeMember(t){const e=this.members.findIndex(e=>Pz(e.raw,t));return!(e<0)&&(this.members.splice(e,1),this.dirty.add(Dz.MEMBERS),!0)}removeNonMember(t){const e=this.nonMembers.findIndex(e=>Pz(e.raw,t));return!(e<0)&&(this.nonMembers.splice(e,1),this.dirty.add(Dz.NON_MEMBERS),!0)}removeEdge(t){const e=this.edges.findIndex(e=>e.obj.equals(t));return!(e<0)&&(this.edges.splice(e,1),this.dirty.add(Dz.NON_MEMBERS),!0)}pushNonMember(...t){if(0!==t.length){this.dirty.add(Dz.NON_MEMBERS);for(const e of t)this.nonMembers.push({raw:e,obj:Lz(e)?yz.from(e):mz.from(e),area:null})}}pushEdge(...t){if(0!==t.length){this.dirty.add(Dz.EDGES);for(const e of t)this.edges.push({raw:e,obj:az.from(e),area:null})}}update(){const t=this.dirty.has(Dz.MEMBERS),e=this.dirty.has(Dz.NON_MEMBERS);let n=this.dirty.has(Dz.EDGES);this.dirty.clear();const r=this.members.map(t=>t.obj);if(this.o.virtualEdges&&(t||e)){const t=this.nonMembers.map(t=>t.obj),e=Cz(r,t,this.o.maxRoutingIterations,this.o.morphBuffer),i=new Map(this.virtualEdges.map(t=>[t.obj.toString(),t.area]));this.virtualEdges=e.map(t=>{var e;return{raw:t,obj:t,area:null!==(e=i.get(t.toString()))&&void 0!==e?e:null}}),n=!0}let i=!1;if(t||n){const t=this.virtualEdges.concat(this.edges).map(t=>t.obj),e=function(t,e){if(0===t.length)return new mz(0,0,0,0);const n=mz.from(t[0]);for(const e of t)n.add(e);for(const t of e)n.add(sz(t));return n}(r,t),n=Math.max(this.o.edgeR1,this.o.nodeR1)+this.o.morphBuffer,o=mz.from(bz(e,n));o.equals(this.activeRegion)||(i=!0,this.activeRegion=o)}if(i){const t=Math.ceil(this.activeRegion.width/this.o.pixelGroup),e=Math.ceil(this.activeRegion.height/this.o.pixelGroup);this.activeRegion.x!==this.potentialArea.pixelX||this.activeRegion.y!==this.potentialArea.pixelY?(this.potentialArea=wz.fromPixelRegion(this.activeRegion,this.o.pixelGroup),this.members.forEach(t=>t.area=null),this.nonMembers.forEach(t=>t.area=null),this.edges.forEach(t=>t.area=null),this.virtualEdges.forEach(t=>t.area=null)):t===this.potentialArea.width&&e===this.potentialArea.height||(this.potentialArea=wz.fromPixelRegion(this.activeRegion,this.o.pixelGroup))}const o=new Map,A=t=>{if(t.area){const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof mz?"R":"C"}`;o.set(e,t.area)}},s=t=>{if(t.area)return;const e=`${t.obj.width}x${t.obj.height}x${t.obj instanceof mz?"R":"C"}`;if(o.has(e)){const n=o.get(e);return void(t.area=this.potentialArea.copy(n,{x:t.obj.x-this.o.nodeR1,y:t.obj.y-this.o.nodeR1}))}const n=t.obj instanceof mz?function(t,e,n){const r=e.scale(t),i=e.addPadding(r,n),o=e.createSub(i,{x:t.x-n,y:t.y-n}),A=r.x-i.x,s=r.y-i.y,a=i.x2-r.x2,c=i.y2-r.y2,l=i.width-A-a,u=i.height-s-c,h=n*n;o.fillArea({x:A,y:s,width:l+1,height:u+1},h);const d=[0],f=Math.max(s,A,a,c);{const i=e.invertScaleX(r.x+r.width/2);for(let o=1;o<f;o++){const A=e.invertScaleY(r.y-o),s=t.distSquare(i,A);if(!(s<h))break;{const t=n-Math.sqrt(s);d.push(t*t)}}}const g=[],p=Math.max(A,a),v=Math.max(s,a);for(let i=1;i<p;i++){const o=e.invertScaleX(r.x-i),A=[];for(let i=1;i<v;i++){const s=e.invertScaleY(r.y-i),a=t.distSquare(o,s);if(a<h){const t=n-Math.sqrt(a);A.push(t*t)}else A.push(0)}g.push(A)}for(let t=1;t<Math.min(s,d.length);t++){const e=d[t];o.fillHorizontalLine(A,s-t,l+1,e)}for(let t=1;t<Math.min(c,d.length);t++){const e=d[t];o.fillHorizontalLine(A,s+u+t,l+1,e)}for(let t=1;t<Math.min(A,d.length);t++){const e=d[t];o.fillVerticalLine(A-t,s,u+1,e)}for(let t=1;t<Math.min(c,d.length);t++){const e=d[t];o.fillVerticalLine(A+l+t,s,u+1,e)}for(let t=1;t<A;t++){const e=g[t-1],n=A-t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<c;t++)o.set(n,s+u+t,e[t-1])}for(let t=1;t<a;t++){const e=g[t-1],n=A+l+t;for(let t=1;t<s;t++)o.set(n,s-t,e[t-1]);for(let t=1;t<c;t++)o.set(n,s+u+t,e[t-1])}return o}(t.obj,this.potentialArea,this.o.nodeR1):Ez(t.obj,this.potentialArea,this.o.nodeR1);t.area=n,o.set(e,n)};this.members.forEach(A),this.nonMembers.forEach(A),this.members.forEach(s),this.nonMembers.forEach(t=>{this.activeRegion.intersects(t.obj)?s(t):t.area=null}),this.edges.forEach(t=>{t.area||(t.area=Bz(t.obj,this.potentialArea,this.o.edgeR1))}),this.virtualEdges.forEach(t=>{t.area||(t.area=Bz(t.obj,this.potentialArea,this.o.edgeR1))})}drawMembers(t){for(const e of this.members)e.obj.draw(t)}drawNonMembers(t){for(const e of this.nonMembers)e.obj.draw(t)}drawEdges(t){for(const e of this.edges)e.obj.draw(t)}drawPotentialArea(t,e=!0){this.potentialArea.draw(t,e)}compute(){if(0===this.members.length)return new Nz([]);this.dirty.size>0&&this.update();const{o:t,potentialArea:e}=this,n=this.members.map(t=>t.area),r=this.virtualEdges.concat(this.edges).map(t=>t.area),i=this.nonMembers.filter(t=>null!=t.area).map(t=>t.area),o=this.members.map(t=>t.obj);return function(t,e,n,r,i,o={}){const A=Object.assign({},Iz,o);let s=A.threshold,a=A.memberInfluenceFactor,c=A.edgeInfluenceFactor,l=A.nonMemberInfluenceFactor;const u=(A.nodeR0-A.nodeR1)*(A.nodeR0-A.nodeR1),h=(A.edgeR0-A.edgeR1)*(A.edgeR0-A.edgeR1);for(let o=0;o<A.maxMarchingIterations;o++){if(t.clear(),0!==a){const n=a/u;for(const r of e)t.incArea(r,n)}if(0!==c){const e=c/h;for(const r of n)t.incArea(r,e)}if(0!==l){const e=l/u;for(const n of r)t.incArea(n,e)}const d=Oz(t,s);if(d&&i(d))return d;if(s*=.95,o<=.5*A.maxMarchingIterations)a*=1.2,c*=1.2;else{if(!(0!==l&&r.length>0))break;l*=.8}}return new Nz([])}(e,n,r,i,t=>t.containsElements(o),t)}};class Hz extends tz{constructor(t,e){super(t,be({},Hz.defaultOptions,e)),this.path=null,this.members=new Map,this.avoidMembers=new Map,this.bubbleSetOptions={},this.drawBubbleSets=()=>{const{style:t,bubbleSetOptions:e}=this.parseOptions();xe(this.bubbleSetOptions,e)||this.init(),this.bubbleSetOptions=Object.assign({},e);const n=Object.assign(Object.assign({},t),{d:this.getPath()});this.shape?this.shape.update(n):(this.shape=new xw({style:n}),this.context.canvas.appendChild(this.shape))},this.updateBubbleSetsPath=t=>{if(!this.shape)return;const e=Km(t.data);[...this.options.members,...this.options.avoidMembers].includes(e)&&this.shape.update(Object.assign(Object.assign({},this.parseOptions().style),{d:this.getPath(e)}))},this.getPath=t=>{const{graph:e}=this.context,n=this.options.members,r=[...this.members.keys()],i=this.options.avoidMembers,o=[...this.avoidMembers.keys()];if(0===n.length&&0===i.length)return this.members.clear(),this.avoidMembers.clear(),this.path=[],this.path;if(!t&&this.path&&xe(n,r)&&xe(i,o))return this.path;const{enter:A=[],exit:s=[]}=ty(r,n,t=>t),{enter:a=[],exit:c=[]}=ty(o,i,t=>t);if(t){const e=n.includes(t),r=i.includes(t);e&&(s.push(t),A.push(t)),r&&(c.push(t),a.push(t))}const l=(t,n,r)=>{t.forEach(t=>{const i=r?this.members:this.avoidMembers,o=r?"pushMember":"pushNonMember",A=r?"removeMember":"removeNonMember";if(n){let n;"edge"===e.getElementType(t)?([n]=Gz(e,t),this.bubbleSets.pushEdge(n)):([n]=_z(e,t),this.bubbleSets[o](n)),i.set(t,n)}else{const n=i.get(t);n&&("edge"===e.getElementType(t)?this.bubbleSets.removeEdge(n):this.bubbleSets[A](n),i.delete(t))}})};l(s,!1,!0),l(A,!0,!0),l(c,!1,!1),l(a,!0,!1);const u=this.bubbleSets.compute().sample(8).simplify(0).bSplines().simplify(0);return this.path=Ew(u.points.map(Sy)),this.path},this.bindEvents(),this.bubbleSets=new Rz(this.options)}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath)}init(){this.bubbleSets=new Rz(this.options),this.members.clear(),this.avoidMembers.clear(),this.path=null}parseOptions(){const t=this.options,{type:e,key:n,members:r,avoidMembers:i}=t,o=Pe(t,["type","key","members","avoidMembers"]),A=Object.keys(o).reduce((t,e)=>(e in Iz?t.bubbleSetOptions[e]=o[e]:t.style[e]=o[e],t),{style:{},bubbleSetOptions:{}});return Object.assign({type:e,key:n,members:r,avoidMembers:i},A)}addMember(t){const e=Array.isArray(t)?t:[t];e.some(t=>this.options.avoidMembers.includes(t))&&(this.options.avoidMembers=this.options.avoidMembers.filter(t=>!e.includes(t))),this.options.members=[...new Set([...this.options.members,...e])],this.drawBubbleSets()}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter(t=>!e.includes(t)),this.drawBubbleSets()}updateMember(t){this.options.members=Gt(t)?t(this.options.members):t,this.drawBubbleSets()}getMember(){return this.options.members}addAvoidMember(t){const e=Array.isArray(t)?t:[t];e.some(t=>this.options.members.includes(t))&&(this.options.members=this.options.members.filter(t=>!e.includes(t))),this.options.avoidMembers=[...new Set([...this.options.avoidMembers,...e])],this.drawBubbleSets()}removeAvoidMember(t){const e=Array.isArray(t)?t:[t];this.options.avoidMembers.some(t=>e.includes(t))&&(this.options.avoidMembers=this.options.avoidMembers.filter(t=>!e.includes(t)),this.drawBubbleSets())}updateAvoidMember(t){this.options.avoidMembers=Array.isArray(t)?t:[t],this.drawBubbleSets()}getAvoidMember(){return this.options.avoidMembers}destroy(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawBubbleSets),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateBubbleSetsPath),this.shape&&(this.shape.destroy(),this.shape=void 0),super.destroy()}}Hz.defaultOptions=Object.assign({members:[],avoidMembers:[],fill:"lightblue",fillOpacity:.2,stroke:"blue",strokeOpacity:.2},Iz);const _z=(t,e)=>(Array.isArray(e)?e:[e]).map(e=>{const n=t.getElementRenderBounds(e);return new mz(n.min[0],n.min[1],mm(n),ym(n))}),Gz=(t,e)=>(Array.isArray(e)?e:[e]).map(e=>{const n=t.getEdgeData(e),r=t.getElementPosition(n.source),i=t.getElementPosition(n.target);return az.from({x1:r[0],y1:r[1],x2:i[0],y2:i[1]})});class Kz extends tz{constructor(t,e){super(t,Object.assign({},Kz.defaultOptions,e)),this.targetElement=null,this.wheelHandler=t=>{t.stopPropagation()},this.onTriggerEvent=t=>{var e;null===(e=t.preventDefault)||void 0===e||e.call(t),this.show(t)},this.onMenuItemClick=t=>{const{onClick:e,trigger:n}=this.options;if(t.target instanceof HTMLElement&&t.target.className.includes("g6-contextmenu-li")){const n=t.target.getAttribute("value");null==e||e(n,t.target,this.targetElement),this.hide()}"click"!==n&&this.hide()},this.initElement(),this.update(e)}initElement(){this.$element=ez("contextmenu",!1,{zIndex:"99"});const{className:t}=this.options;t&&this.$element.classList.add(t),this.$element.addEventListener("wheel",this.wheelHandler);this.context.canvas.getContainer().appendChild(this.$element),nz("g6-contextmenu-css","style",{},"\n .g6-contextmenu {\n font-size: 12px;\n background-color: rgba(255, 255, 255, 0.96);\n border-radius: 4px;\n overflow-x: hidden;\n overflow-y: auto;\n max-height: calc(100% - 8px);\n box-shadow: rgba(0, 0, 0, 0.12) 0px 6px 12px 0px;\n transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, left 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s, top 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s;\n }\n\n .g6-contextmenu::-webkit-scrollbar {\n width: 6px;\n }\n\n .g6-contextmenu::-webkit-scrollbar-thumb {\n background-color: rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n }\n\n .g6-contextmenu::-webkit-scrollbar-thumb:hover {\n background-color: rgba(0, 0, 0, 0.3);\n }\n\n .g6-contextmenu-ul {\n max-width: 256px;\n min-width: 96px;\n list-style: none;\n padding: 0;\n margin: 0;\n }\n\n .g6-contextmenu-li {\n padding: 8px 12px;\n cursor: pointer;\n user-select: none;\n }\n\n .g6-contextmenu-li:hover {\n background-color: #f5f5f5;\n cursor: pointer;\n }\n",document.head)}show(t){return De(this,void 0,void 0,function*(){const{enable:e,offset:n}=this.options;if("function"==typeof e&&!e(t)||!e)return void this.hide();const r=yield this.getDOMContent(t);r instanceof HTMLElement?(this.$element.innerHTML="",this.$element.appendChild(r)):this.$element.innerHTML=r;const i=this.context.graph.getCanvas().getContainer().getBoundingClientRect();let o=t.client.x-i.left+n[0],A=t.client.y-i.top+n[1];this.$element.style.display="block";const s=this.$element.offsetWidth,a=this.$element.offsetHeight,c=i.width,l=i.height;o=Math.max(4,Math.min(o,c-s-4)),A=Math.max(4,Math.min(A,l-a-4)),this.$element.style.left=`${o}px`,this.$element.style.top=`${A}px`,this.targetElement=t.target})}hide(){this.$element.style.display="none",this.targetElement=null}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy(),this.$element.remove()}getDOMContent(t){return De(this,void 0,void 0,function*(){const{getContent:e,getItems:n}=this.options;return n?`\n <ul class="g6-contextmenu-ul">\n ${(yield n(t)).map(t=>`<li class="g6-contextmenu-li" value="${t.value}">${t.name}</li>`).join("")}\n </ul>\n `:yield e(t)})}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`canvas:${e}`,this.onTriggerEvent),t.on(`node:${e}`,this.onTriggerEvent),t.on(`edge:${e}`,this.onTriggerEvent),t.on(`combo:${e}`,this.onTriggerEvent),document.addEventListener("click",this.onMenuItemClick)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`canvas:${e}`,this.onTriggerEvent),t.off(`node:${e}`,this.onTriggerEvent),t.off(`edge:${e}`,this.onTriggerEvent),t.off(`combo:${e}`,this.onTriggerEvent),document.removeEventListener("click",this.onMenuItemClick),this.$element.removeEventListener("wheel",this.wheelHandler)}}Kz.defaultOptions={trigger:"contextmenu",offset:[4,4],loadingContent:'<div class="g6-contextmenu-loading">Loading...</div>',getContent:()=>"It is a empty context menu.",enable:()=>!0};class jz extends tz{constructor(t,e){super(t,Object.assign({},jz.defaultOptions,e)),this.edgeBundles={},this.edgePoints={},this.onBundle=()=>{const{model:t,element:e}=this.context,n=t.getEdgeData();this.divideEdges(this.options.divisions);const{cycles:r,iterRate:i,divRate:o}=this.options;let{lambda:A,divisions:s,iterations:a}=this.options;for(let t=0;t<r;t++){for(let t=0;t<a;t++){const t={};n.forEach(e=>{var n;if(e.source===e.target)return;const r=Km(e);t[r]=this.getEdgeForces(e,s,A);for(let e=0;e<s+1;e++)(n=this.edgePoints)[r]||(n[r]=[]),this.edgePoints[r][e]=ay(this.edgePoints[r][e],t[r][e])})}A/=2,s*=o,a*=i,this.divideEdges(s)}n.forEach(t=>{const n=Km(t),r=e.getElement(n);null==r||r.update({d:dB(this.edgePoints[n])})})},this.bindEvents()}get nodeMap(){const t=this.context.model.getNodeData();return Object.fromEntries(t.map(t=>[Km(t),yy(My(t))]))}divideEdges(t){this.context.model.getEdgeData().forEach(e=>{var n;const r=Km(e);(n=this.edgePoints)[r]||(n[r]=[]);const i=this.nodeMap[e.source],o=this.nodeMap[e.target];if(1===t)this.edgePoints[r].push(i),this.edgePoints[r].push(uy(ay(i,o),2)),this.edgePoints[r].push(o);else{const e=(0===this.edgePoints[r].length?dy(i,o):$z(this.edgePoints[r]))/(t+1);let n=e;const A=[i];for(let t=1;t<this.edgePoints[r].length;t++){const i=this.edgePoints[r][t-1],o=this.edgePoints[r][t];let s=dy(o,i);for(;s>n;){const t=n/s,r=ay(i,ly(cy(o,i),t));A.push(r),s-=n,n=e}n-=s}A.push(o),this.edgePoints[r]=A}})}getVectorPosition(t){const e=this.nodeMap[t.source],n=this.nodeMap[t.target],[r,i]=cy(n,e);return{source:e,target:n,vx:r,vy:i,length:dy(e,n)}}measureEdgeCompatibility(t,e){const n=this.getVectorPosition(t),r=this.getVectorPosition(e);return zz(n,r)*Vz(n,r)*Wz(n,r)*qz(n,r)}getEdgeBundles(){const t={},e=this.options.bundleThreshold,n=this.context.model.getEdgeData();return n.forEach((r,i)=>{n.forEach((n,o)=>{var A,s;if(o<=i)return;this.measureEdgeCompatibility(r,n)>=e&&(t[A=Km(r)]||(t[A]=[]),t[Km(r)].push(n),t[s=Km(n)]||(t[s]=[]),t[Km(n)].push(r))})}),t}getSpringForce(t,e){const{pre:n,cur:r,next:i}=t;return ly(cy(ay(n,i),ly(r,2)),e)}getElectrostaticForce(t,e){Ee(this.edgeBundles)&&(this.edgeBundles=this.getEdgeBundles());const n=this.edgeBundles[Km(e)];let r=[0,0];return null==n||n.forEach(n=>{const i=this.edgePoints[Km(n)][t],o=this.edgePoints[Km(e)][t],A=cy(i,o),s=dy(i,o);r=ay(r,ly(A,1/s))}),r}getEdgeForces(t,e,n){const r=this.nodeMap[t.source],i=this.nodeMap[t.target],o=this.options.K/(dy(r,i)*(e+1)),A=[[0,0]],s=Km(t);for(let r=1;r<e;r++){const e=this.getSpringForce({pre:this.edgePoints[s][r-1],cur:this.edgePoints[s][r],next:this.edgePoints[s][r+1]||[0,0]},o),i=this.getElectrostaticForce(r,t);A.push(ly(ay(e,i),n))}return A.push([0,0]),A}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onBundle)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onBundle)}destroy(){this.unbindEvents(),super.destroy()}}jz.defaultOptions={K:.1,lambda:.1,divisions:1,divRate:2,cycles:6,iterations:90,iterRate:2/3,bundleThreshold:.6};const zz=(t,e)=>Math.abs(function(t,e){return[t,e]=sy(t,e),t.reduce((t,n,r)=>t+n*e[r],0)}([t.vx,t.vy],[e.vx,e.vy])/(t.length*e.length)),Vz=(t,e)=>{const n=(t.length+e.length)/2;return 2/(n/Math.min(t.length,e.length)+Math.max(t.length,e.length)/n)},Wz=(t,e)=>{const n=(t.length+e.length)/2;return n/(n+dy(uy(ay(t.source,t.target),2),uy(ay(e.source,e.target),2)))},Yz=(t,e)=>{if(e.source[0]===e.target[0])return[e.source[0],t[1]];if(e.source[1]===e.target[1])return[t[0],e.source[1]];const n=(e.source[1]-e.target[1])/(e.source[0]-e.target[0]),r=(n*n*e.source[0]+n*(t[1]-e.source[1])+t[0])/(n*n+1);return[r,n*(r-e.source[0])+e.source[1]]},Xz=(t,e)=>{const n=Yz(e.source,t),r=Yz(e.target,t),i=uy(ay(n,r),2),o=uy(ay(t.source,t.target),2);return 0===dy(n,r)?0:Math.max(0,1-2*dy(o,i)/dy(n,r))},qz=(t,e)=>Math.min(Xz(t,e),Xz(e,t)),$z=t=>{let e=0;for(let n=1;n<t.length;n++)e+=dy(t[n],t[n-1]);return e},Zz={fill:"#fff",fillOpacity:1,lineWidth:1,stroke:"#000",strokeOpacity:.8,zIndex:-1/0};class Jz extends tz{constructor(t,e){super(t,Object.assign({},Jz.defaultOptions,e)),this.shapes=new Map,this.r=this.options.r,this.onEdgeFilter=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=Sy(t.canvas);this.renderLens(e),this.renderFocusElements()},this.renderLens=t=>{const e=Object.assign({},Zz,this.options.style);this.isLensOn||(this.lens=new Tw({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,Qy(t),{size:2*this.r}),this.lens.update(e)},this.getFilterData=()=>{const{filter:t}=this.options,{model:e}=this.context,n=e.getData();if(!t)return n;const{nodes:r,edges:i,combos:o}=n;return{nodes:r.filter(e=>t(Km(e),"node")),edges:i.filter(e=>t(Km(e),"edge")),combos:o.filter(e=>t(Km(e),"combo"))}},this.getFocusElements=t=>{const{nodes:e,edges:n}=this.getFilterData(),r=e.filter(e=>dy(My(e),t)<this.r),i=r.map(t=>Km(t));return{nodes:r,edges:n.filter(t=>{const{source:e,target:n}=t,r=i.includes(e),o=i.includes(n);switch(this.options.nodeType){case"both":return r&&o;case"either":return r!==o;case"source":return r&&!o;case"target":return!r&&o;default:return!1}})}},this.renderFocusElements=()=>{const{element:t,graph:e}=this.context;if(!this.isLensOn)return;const n=this.lens.getCenter(),{nodes:r,edges:i}=this.getFocusElements(n),o=new Set,A=n=>{const r=Km(n);o.add(r);const i=t.getElement(r);if(!i)return;const A=this.shapes.get(r)||i.cloneNode();A.setPosition(i.getPosition()),A.id=i.id,this.shapes.has(r)?Object.entries(i.attributes).forEach(([t,e])=>{A.style[t]!==e&&(A.style[t]=e)}):(this.canvas.appendChild(A),this.shapes.set(r,A));const s=e.getElementType(r),a=this.getElementStyle(s,n);A.update(a)};r.forEach(A),i.forEach(A),this.shapes.forEach((t,e)=>{o.has(e)||(t.destroy(),this.shapes.delete(e))})},this.scaleRByWheel=t=>{var e;this.options.preventDefault&&t.preventDefault();const{clientX:n,clientY:r,deltaX:i,deltaY:o}=t,{graph:A,canvas:s}=this.context,a=A.getCanvasByClient([n,r]),c=null===(e=this.lens)||void 0===e?void 0:e.getCenter();if(!this.isLensOn||dy(a,c)>this.r)return;const{maxR:l,minR:u}=this.options,h=i+o>0?1/.95:.95,d=Math.min(...s.getSize())/2;this.r=Math.max(u||0,Math.min(l||d,this.r*h)),this.renderLens(c),this.renderFocusElements()},this.isLensDragging=!1,this.onDragStart=t=>{var e;const n=Sy(t.canvas),r=null===(e=this.lens)||void 0===e?void 0:e.getCenter();!this.isLensOn||dy(n,r)>this.r||(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=Sy(t.canvas);this.renderLens(e),this.renderFocusElements()},this.onDragEnd=()=>{this.isLensDragging=!1},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}getElementStyle(t,e){const n="node"===t?this.options.nodeStyle:this.options.edgeStyle;return"function"==typeof n?n(e):n}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.addEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.addEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.addEventListener(t.CommonEvent.DRAG,this.onDrag),o.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel,{passive:!1}))}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i}=this.options,o=n.getCanvas().getLayer();["click","drag"].includes(r)&&o.removeEventListener(t.CommonEvent.CLICK,this.onEdgeFilter),"pointermove"===r?o.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onEdgeFilter):"drag"===r&&(o.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),o.removeEventListener(t.CommonEvent.DRAG,this.onDrag),o.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd)),"wheel"===i&&(null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.scaleRByWheel))}update(t){var e;this.unbindEvents(),super.update(t),this.r=null!==(e=t.r)&&void 0!==e?e:this.r,this.bindEvents()}destroy(){this.unbindEvents(),this.isLensOn&&this.lens.destroy(),this.shapes.forEach((t,e)=>{t.destroy(),this.shapes.delete(e)}),super.destroy()}}Jz.defaultOptions={trigger:"pointermove",r:60,nodeType:"both",filter:()=>!0,style:{lineWidth:2},nodeStyle:{label:!1},edgeStyle:{label:!0},scaleRBy:"wheel",preventDefault:!0};const tV={fill:"#ccc",fillOpacity:.1,lineWidth:2,stroke:"#000",strokeOpacity:.8,labelFontSize:12};class eV extends tz{constructor(t,e){super(t,Object.assign({},eV.defaultOptions,e)),this.r=this.options.r,this.d=this.options.d,this.onCreateFisheye=t=>{if("drag"===this.options.trigger&&this.isLensOn)return;const e=Sy(t.canvas);this.onMagnify(e)},this.onMagnify=t=>{t.some(isNaN)||(this.renderLens(t),this.renderFocusElements())},this.renderLens=t=>{const e=Object.assign({},tV,this.options.style);this.isLensOn||(this.lens=new Tw({style:e}),this.canvas.appendChild(this.lens)),Object.assign(e,Qy(t),{size:2*this.r,label:this.options.showDPercent,labelText:this.getDPercent()}),this.lens.update(e)},this.getDPercent=()=>{const{minD:t,maxD:e}=this.options;return`${Math.round((this.d-t)/(e-t)*100)}%`},this.prevMagnifiedStyleMap=new Map,this.prevOriginStyleMap=new Map,this.renderFocusElements=()=>{if(!this.isLensOn)return;const{graph:t}=this.context,e=this.lens.getCenter(),n=(this.d+1)*this.r,r=new Map,i=new Map;t.getNodeData().forEach(o=>{const A=My(o),s=dy(A,e);if(s>this.r)return;const a=n*s/(this.d*s+this.r),[c,l]=A,[u,h]=e,d=[u+a*((c-u)/s),h+a*((l-h)/s)],f=Km(o),g=this.getNodeStyle(o),p=ke(t.getElementRenderStyle(f),Object.keys(g));r.set(f,Object.assign(Object.assign({},Qy(d)),g)),i.set(f,Object.assign(Object.assign({},Qy(A)),p))}),this.updateStyle(r,i)},this.getNodeStyle=t=>{const{nodeStyle:e}=this.options;return"function"==typeof e?e(t):e},this.updateStyle=(t,e)=>{const{graph:n,element:r}=this.context,{enter:i,exit:o,keep:A}=ty(Array.from(this.prevMagnifiedStyleMap.keys()),Array.from(t.keys()),t=>t),s=new Set,a=(t,e)=>{const i=r.getElement(t);null==i||i.update(e),n.getRelatedEdgesData(t).forEach(t=>{s.add(Km(t))})};[...i,...A].forEach(e=>{a(e,t.get(e))}),o.forEach(t=>{a(t,this.prevOriginStyleMap.get(t)),this.prevOriginStyleMap.delete(t)}),s.forEach(t=>{const e=r.getElement(t);null==e||e.update({})}),this.prevMagnifiedStyleMap=t,e.forEach((t,e)=>{this.prevOriginStyleMap.has(e)||this.prevOriginStyleMap.set(e,t)})},this.isWheelValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;const{clientX:e,clientY:n}=t;return!(dy(this.context.graph.getCanvasByClient([e,n]),this.lens.getCenter())>this.r)},this.scaleR=t=>{const{maxR:e,minR:n}=this.options,r=t?1/.95:.95,i=Math.min(...this.context.canvas.getSize())/2;this.r=Math.max(n||0,Math.min(e||i,this.r*r))},this.scaleD=t=>{const{maxD:e,minD:n}=this.options,r=t?this.d+.1:this.d-.1;this.d=Math.max(n,Math.min(e,r))},this.scaleRByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleR(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByWheel=t=>{if(!this.isWheelValid(t))return;const{deltaX:e,deltaY:n}=t;this.scaleD(e+n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.isDragValid=t=>{if(this.options.preventDefault&&t.preventDefault(),!this.isLensOn)return!1;return!(dy(Sy(t.canvas),this.lens.getCenter())>this.r)},this.isLensDragging=!1,this.onDragStart=t=>{this.isDragValid(t)&&(this.isLensDragging=!0)},this.onDrag=t=>{if(!this.isLensDragging)return;const e=Sy(t.canvas);this.onMagnify(e)},this.onDragEnd=()=>{this.isLensDragging=!1},this.scaleRByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleR(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.scaleDByDrag=t=>{if(!this.isLensDragging)return;const{dx:e,dy:n}=t;this.scaleD(e-n>0);const r=this.lens.getCenter();this.onMagnify(r)},this.bindEvents()}get canvas(){return this.context.canvas.getLayer("transient")}get isLensOn(){return this.lens&&!this.lens.destroyed}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}bindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,A=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&A.addEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&A.addEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){A.addEventListener(t.CommonEvent.DRAG_START,this.onDragStart),A.addEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;A.addEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.addEventListener(t.CommonEvent.WHEEL,n,{passive:!1})}}unbindEvents(){var e;const{graph:n}=this.context,{trigger:r,scaleRBy:i,scaleDBy:o}=this.options,A=n.getCanvas().getLayer();if(["click","drag"].includes(r)&&A.removeEventListener(t.CommonEvent.CLICK,this.onCreateFisheye),"pointermove"===r&&A.removeEventListener(t.CommonEvent.POINTER_MOVE,this.onCreateFisheye),"drag"===r||"drag"===i||"drag"===o){A.removeEventListener(t.CommonEvent.DRAG_START,this.onDragStart),A.removeEventListener(t.CommonEvent.DRAG_END,this.onDragEnd);const e="drag"===r?this.onDrag:"drag"===i?this.scaleRByDrag:this.scaleDByDrag;A.removeEventListener(t.CommonEvent.DRAG,e)}if("wheel"===i||"wheel"===o){const n="wheel"===i?this.scaleRByWheel:this.scaleDByWheel;null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,n)}}update(t){var e,n;this.unbindEvents(),super.update(t),this.r=null!==(e=t.r)&&void 0!==e?e:this.r,this.d=null!==(n=t.d)&&void 0!==n?n:this.d,this.bindEvents()}destroy(){var t;this.unbindEvents(),this.isLensOn&&(null===(t=this.lens)||void 0===t||t.destroy()),this.prevMagnifiedStyleMap.clear(),this.prevOriginStyleMap.clear(),super.destroy()}}eV.defaultOptions={trigger:"pointermove",r:120,d:1.5,maxD:5,minD:0,showDPercent:!0,style:{},nodeStyle:{label:!0},preventDefault:!0};class nV extends tz{constructor(t,e){super(t,Object.assign({},nV.defaultOptions,e)),this.$el=this.context.canvas.getContainer(),this.graphSize=[0,0],this.onFullscreenChange=()=>{var t,e,n,r;const i=!!document.fullscreenElement;this.options.autoFit&&this.setGraphSize(i),i?null===(e=(t=this.options).onEnter)||void 0===e||e.call(t):null===(r=(n=this.options).onExit)||void 0===r||r.call(n)},this.shortcut=new Wy(t.graph),this.bindEvents(),this.style=document.createElement("style"),document.head.appendChild(this.style),this.style.innerHTML="\n :not(:root):fullscreen::backdrop {\n background: transparent;\n }\n "}bindEvents(){this.unbindEvents(),this.shortcut.unbindAll();const{request:t=[],exit:e=[]}=this.options.trigger;this.shortcut.bind(t,this.request),this.shortcut.bind(e,this.exit);["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach(t=>{document.addEventListener(t,this.onFullscreenChange,!1)})}unbindEvents(){this.shortcut.unbindAll();["webkitfullscreenchange","mozfullscreenchange","fullscreenchange","MSFullscreenChange"].forEach(t=>{document.removeEventListener(t,this.onFullscreenChange,!1)})}setGraphSize(t=!0){var e,n;let r,i;t?(r=(null===(e=globalThis.screen)||void 0===e?void 0:e.width)||0,i=(null===(n=globalThis.screen)||void 0===n?void 0:n.height)||0,this.graphSize=this.context.graph.getSize()):[r,i]=this.graphSize,this.context.graph.setSize(r,i),this.context.graph.render()}request(){!document.fullscreenElement&&(document.fullscreenEnabled||Reflect.get(document,"webkitFullscreenEnabled")||Reflect.get(document,"mozFullscreenEnabled")||Reflect.get(document,"msFullscreenEnabled"))&&this.$el.requestFullscreen().catch(t=>{Zv(`Error attempting to enable full-screen: ${t.message} (${t.name})`)})}exit(){document.fullscreenElement&&document.exitFullscreen()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.exit(),this.style.remove(),super.destroy()}}nV.defaultOptions={trigger:{},autoFit:!0};class rV extends tz{constructor(t,e){super(t,Object.assign({},rV.defaultOptions,e)),this.$element=ez("grid-line",!0),this.offset=[0,0],this.currentScale=1,this.followZoom=t=>{const{data:{scale:e,origin:n}}=t;if(!e||void 0===n&&void 0===this.context.viewport)return;const r=this.currentScale;this.currentScale=e;const i=e/r,o=ly(n||this.context.graph.getCanvasCenter(),1-i),A=this.baseSize*e,s=ay(my(ly(this.offset,i),A),o);this.$element.style.backgroundSize=`${A}px ${A}px`,this.$element.style.backgroundPosition=`${s[0]}px ${s[1]}px`,this.offset=my(s,A)},this.followTranslate=t=>{if(!this.options.follow)return;const{data:{translate:e}}=t;e&&this.updateOffset(e)},this.onTransform=t=>{const e=this.parseFollow(this.options.follow);e.zoom&&this.followZoom(t),e.translate&&this.followTranslate(t)};this.context.canvas.getContainer().prepend(this.$element),this.baseSize=this.options.size,this.updateStyle(),this.bindEvents()}update(t){super.update(t),void 0!==t.size&&(this.baseSize=t.size),this.updateStyle()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}updateStyle(){const{stroke:t,lineWidth:e,border:n,borderLineWidth:r,borderStroke:i,borderStyle:o}=this.options,A=this.baseSize*this.currentScale;Object.assign(this.$element.style,{border:n?`${r}px ${o} ${i}`:"none",backgroundImage:`linear-gradient(${t} ${e}px, transparent ${e}px), linear-gradient(90deg, ${t} ${e}px, transparent ${e}px)`,backgroundSize:`${A}px ${A}px`,backgroundRepeat:"repeat"})}updateOffset(t){const e=this.baseSize*this.currentScale;this.offset=my(ay(this.offset,t),e),this.$element.style.backgroundPosition=`${this.offset[0]}px ${this.offset[1]}px`}parseFollow(t){var e,n;return ue(t)?{translate:t,zoom:t}:{translate:null!==(e=null==t?void 0:t.translate)&&void 0!==e&&e,zoom:null!==(n=null==t?void 0:t.zoom)&&void 0!==n&&n}}destroy(){this.context.graph.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform),this.$element.remove(),super.destroy()}}function iV(t){const e={Added:new Map,Updated:new Map,Removed:new Map};return t.forEach(t=>{const{type:n,value:r}=t,i=Km(r);if("NodeAdded"===n||"EdgeAdded"===n||"ComboAdded"===n)e.Added.set(i,t);else if("NodeUpdated"===n||"EdgeUpdated"===n||"ComboUpdated"===n)if(e.Added.has(i))e.Added.set(i,{type:n.replace("Updated","Added"),value:r});else if(e.Updated.has(i)){const{original:t}=e.Updated.get(i);e.Updated.set(i,{type:n,value:r,original:t})}else e.Removed.has(i)||e.Updated.set(i,t);else"NodeRemoved"!==n&&"EdgeRemoved"!==n&&"ComboRemoved"!==n||(e.Added.has(i)?e.Added.delete(i):e.Updated.has(i)?(e.Updated.delete(i),e.Removed.set(i,t)):e.Removed.set(i,t))}),[...Array.from(e.Added.values()),...Array.from(e.Updated.values()),...Array.from(e.Removed.values())]}function oV(t){const{NodeAdded:e=[],NodeUpdated:n=[],NodeRemoved:r=[],EdgeAdded:i=[],EdgeUpdated:o=[],EdgeRemoved:A=[],ComboAdded:s=[],ComboUpdated:a=[],ComboRemoved:c=[]}=ee(t,t=>t.type);return{add:{nodes:e,edges:i,combos:s},update:{nodes:n,edges:o,combos:a},remove:{nodes:r,edges:A,combos:c}}}function AV(t,e){for(const n in t)zt(t[n])&&!Array.isArray(t[n])&&null!==t[n]?(e[n]||(e[n]={}),AV(t[n],e[n])):void 0===e[n]&&(e[n]=nm(n))}function sV(t,e=!1,n){const r={animation:e,current:{add:{},update:{},remove:{}},original:{add:{},update:{},remove:{}}},{add:i,update:o,remove:A}=oV(iV(t));return["nodes","edges","combos"].forEach(t=>{o[t]&&o[t].forEach(e=>{var i,o;const A=Object.assign({},e.value);let s=Object.assign({},e.original);if(n){const t=n.graph.getElementType(Km(e.original)),r="edge"===t?"stroke":"fill",i=n.element.getElementComputedStyle(t,e.original);s=Object.assign(Object.assign({},e.original),{style:Object.assign({[r]:i[r]},e.original.style)})}AV(A,s),(i=r.current.update)[t]||(i[t]=[]),r.current.update[t].push(A),(o=r.original.update)[t]||(o[t]=[]),r.original.update[t].push(s)}),i[t]&&i[t].forEach(e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.add)[t]||(n[t]=[]),r.current.add[t].push(o),(i=r.original.remove)[t]||(i[t]=[]),r.original.remove[t].push(o)}),A[t]&&A[t].forEach(e=>{var n,i;const o=Object.assign({},e.value);(n=r.current.remove)[t]||(n[t]=[]),r.current.remove[t].push(o),(i=r.original.add)[t]||(i[t]=[]),r.original.add[t].push(o)})}),r}rV.defaultOptions={border:!0,borderLineWidth:1,borderStroke:"#eee",borderStyle:"solid",lineWidth:1,size:20,stroke:"#eee"};class aV extends tz{constructor(e,n){super(e,Object.assign({},aV.defaultOptions,n)),this.batchChanges=null,this.batchAnimation=!1,this.undoStack=[],this.redoStack=[],this.freezed=!1,this.executeCommand=(t,e=!0)=>{var n,r,i;this.freezed=!0,null===(r=(n=this.options).executeCommand)||void 0===r||r.call(n,t);const o=e?t.original:t.current;this.context.graph.addData(o.add),this.context.graph.updateData(o.update),this.context.graph.removeData(zm(o.remove,!1)),null===(i=this.context.element)||void 0===i||i.draw({silence:!0,animation:t.animation}),this.freezed=!1},this.addCommand=e=>{var n;if(!this.freezed){if(e.type===t.GraphEvent.AFTER_DRAW){const{dataChanges:t=[],animation:r=!0}=e.data;if(null===(n=this.context.batch)||void 0===n?void 0:n.isBatching){if(!this.batchChanges)return;return this.batchChanges.push(t),void(this.batchAnimation&&(this.batchAnimation=r))}this.batchChanges=[t],this.batchAnimation=r}this.undoStackPush(sV(this.batchChanges.flat(),this.batchAnimation,this.context)),this.notify(t.HistoryEvent.ADD,this.undoStack[this.undoStack.length-1])}},this.initBatchCommand=t=>{const{initiate:e}=t.data;if(this.batchAnimation=!1,e)this.batchChanges=[];else{this.undoStack.pop()||(this.batchChanges=null)}},this.emitter=new hE;const{graph:r}=this.context;r.on(t.GraphEvent.AFTER_DRAW,this.addCommand),r.on(t.GraphEvent.BATCH_START,this.initBatchCommand),r.on(t.GraphEvent.BATCH_END,this.addCommand)}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}undo(){var e,n,r,i;const o=this.undoStack.pop();if(o){this.executeCommand(o);if(!1===(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,o,!1)))return;this.redoStack.push(o),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,o,!1),this.notify(t.HistoryEvent.UNDO,o)}return this}redo(){const e=this.redoStack.pop();return e&&(this.executeCommand(e,!1),this.undoStackPush(e),this.notify(t.HistoryEvent.REDO,e)),this}undoAndCancel(){const e=this.undoStack.pop();return e&&(this.executeCommand(e,!1),this.redoStack=[],this.notify(t.HistoryEvent.CANCEL,e)),this}undoStackPush(t){var e,n,r,i;const{stackSize:o}=this.options;0!==o&&this.undoStack.length>=o&&this.undoStack.shift();!1!==(null===(n=(e=this.options).beforeAddCommand)||void 0===n?void 0:n.call(e,t,!0))&&(this.undoStack.push(t),null===(i=(r=this.options).afterAddCommand)||void 0===i||i.call(r,t,!0))}clear(){this.undoStack=[],this.redoStack=[],this.batchChanges=null,this.batchAnimation=!1,this.notify(t.HistoryEvent.CLEAR,null)}notify(e,n){this.emitter.emit(e,{cmd:n}),this.emitter.emit(t.HistoryEvent.CHANGE,{cmd:n})}on(t,e){this.emitter.on(t,e)}destroy(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.addCommand),e.off(t.GraphEvent.BATCH_START,this.initBatchCommand),e.off(t.GraphEvent.BATCH_END,this.addCommand),this.emitter.off(),super.destroy(),this.undoStack=[],this.redoStack=[]}}aV.defaultOptions={stackSize:0};const cV={toXy(t,e){if(!e)return[...t];const n=e[0].slice(1),r=e[1].slice(1);return t.map(t=>[t[n],t[r]])},fromXy(t,e){if(!e)return[...t];const n=e[0].slice(1),r=e[1].slice(1);return t.map(([t,e])=>({[n]:t,[r]:e}))}};let lV=class{constructor(t,e){this._cells=[],this._cellSize=e,this._reverseCellSize=1/e;for(const e of t){const t=this.coordToCellNum(e[0]),n=this.coordToCellNum(e[1]);this._cells[t]||(this._cells[t]=[]),this._cells[t][n]||(this._cells[t][n]=[]),this._cells[t][n].push(e)}}cellPoints(t,e){var n;return(null===(n=this._cells[t])||void 0===n?void 0:n[e])||[]}rangePoints(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this.coordToCellNum(t[2]),i=this.coordToCellNum(t[3]),o=[];for(let t=e;t<=r;t++)for(let e=n;e<=i;e++){const n=this.cellPoints(t,e);for(const t of n)o.push(t)}return o}removePoint(t){const e=this.coordToCellNum(t[0]),n=this.coordToCellNum(t[1]),r=this._cells[e][n],i=r.findIndex(([e,n])=>e===t[0]&&n===t[1]);return i>-1&&r.splice(i,1),r}trunc(t){return Math.trunc(t)}coordToCellNum(t){return this.trunc(t*this._reverseCellSize)}extendBbox(t,e){return[t[0]-e*this._cellSize,t[1]-e*this._cellSize,t[2]+e*this._cellSize,t[3]+e*this._cellSize]}};const uV=+(Math.pow(2,27)+1);function hV(t,e,n){const r=t*e,i=uV*t,o=i-(i-t),A=t-o,s=uV*e,a=s-(s-e),c=e-a,l=A*c-(r-o*a-A*a-o*c);return n?(n[0]=l,n[1]=r,n):[l,r]}function dV(t,e,n){const r=t+e,i=r-t,o=e-i,A=t-(r-i);return n?(n[0]=A+o,n[1]=r,n):[A+o,r]}function fV(t,e){const n=t.length;if(1===n){const n=hV(t[0],e);return n[0]?n:[n[1]]}const r=new Array(2*n),i=[.1,.1],o=[.1,.1];let A=0;hV(t[0],e,i),i[0]&&(r[A++]=i[0]);for(let s=1;s<n;++s){hV(t[s],e,o);dV(i[1],o[0],i),i[0]&&(r[A++]=i[0]);const n=o[1],a=i[1],c=n+a,l=a-(c-n);i[1]=c,l&&(r[A++]=l)}return i[1]&&(r[A++]=i[1]),0===A&&(r[A++]=0),r.length=A,r}function gV(t,e){const n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){const n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],-e[0]);const i=new Array(n+r);let o=0,A=0,s=0;const a=Math.abs;let c,l,u=t[A],h=a(u),d=-e[s],f=a(d);h<f?(l=u,A+=1,A<n&&(u=t[A],h=a(u))):(l=d,s+=1,s<r&&(d=-e[s],f=a(d))),A<n&&h<f||s>=r?(c=u,A+=1,A<n&&(u=t[A],h=a(u))):(c=d,s+=1,s<r&&(d=-e[s],f=a(d)));let g,p,v,m,y,w=c+l,b=w-c,B=l-b,E=B,x=w;for(;A<n&&s<r;)h<f?(c=u,A+=1,A<n&&(u=t[A],h=a(u))):(c=d,s+=1,s<r&&(d=-e[s],f=a(d))),l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g;for(;A<n;)c=u,l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g,A+=1,A<n&&(u=t[A]);for(;s<r;)c=d,l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g,s+=1,s<r&&(d=-e[s]);return E&&(i[o++]=E),x&&(i[o++]=x),o||(i[o++]=0),i.length=o,i}function pV(t,e){const n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){const n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],e[0]);const i=new Array(n+r);let o=0,A=0,s=0;const a=Math.abs;let c,l,u=t[A],h=a(u),d=e[s],f=a(d);h<f?(l=u,A+=1,A<n&&(u=t[A],h=a(u))):(l=d,s+=1,s<r&&(d=e[s],f=a(d))),A<n&&h<f||s>=r?(c=u,A+=1,A<n&&(u=t[A],h=a(u))):(c=d,s+=1,s<r&&(d=e[s],f=a(d)));let g,p,v,m,y,w=c+l,b=w-c,B=l-b,E=B,x=w;for(;A<n&&s<r;)h<f?(c=u,A+=1,A<n&&(u=t[A],h=a(u))):(c=d,s+=1,s<r&&(d=e[s],f=a(d))),l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g;for(;A<n;)c=u,l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g,A+=1,A<n&&(u=t[A]);for(;s<r;)c=d,l=E,w=c+l,b=w-c,B=l-b,B&&(i[o++]=B),g=x+w,p=g-x,v=g-p,m=w-p,y=x-v,E=y+m,x=g,s+=1,s<r&&(d=e[s]);return E&&(i[o++]=E),x&&(i[o++]=x),o||(i[o++]=0),i.length=o,i}function vV(t,e,n,r){return function(n,i,o){const A=t(t(e(i[1],o[0]),e(-o[1],i[0])),t(e(n[1],i[0]),e(-i[1],n[0]))),s=t(e(n[1],o[0]),e(-o[1],n[0])),a=r(A,s);return a[a.length-1]}}function mV(t,e,n,r){return function(i,o,A,s){const a=t(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),s[2]))),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2])))),c=t(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),s[2]))),t(n(t(e(o[1],A[0]),e(-A[1],o[0])),i[2]),t(n(t(e(i[1],A[0]),e(-A[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),A[2])))),l=r(a,c);return l[l.length-1]}}function yV(t,e,n,r){return function(i,o,A,s,a){const c=t(t(t(n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),A[2]),t(n(t(e(A[1],a[0]),e(-a[1],A[0])),-s[2]),n(t(e(A[1],s[0]),e(-s[1],A[0])),a[2]))),o[3]),t(n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),o[2]),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),-s[2]),n(t(e(o[1],s[0]),e(-s[1],o[0])),a[2]))),-A[3]),n(t(n(t(e(A[1],a[0]),e(-a[1],A[0])),o[2]),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),a[2]))),s[3]))),t(n(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),s[2]))),-a[3]),t(n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),o[2]),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),-s[2]),n(t(e(o[1],s[0]),e(-s[1],o[0])),a[2]))),i[3]),n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-s[2]),n(t(e(i[1],s[0]),e(-s[1],i[0])),a[2]))),-o[3])))),t(t(n(t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2]))),s[3]),t(n(t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2]))),-a[3]),n(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),o[2]),t(n(t(e(o[1],s[0]),e(-s[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),s[2]))),i[3]))),t(n(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),s[2]))),-o[3]),t(n(t(n(t(e(o[1],s[0]),e(-s[1],o[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),s[2]))),A[3]),n(t(n(t(e(o[1],A[0]),e(-A[1],o[0])),i[2]),t(n(t(e(i[1],A[0]),e(-A[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),A[2]))),-s[3]))))),l=t(t(t(n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),A[2]),t(n(t(e(A[1],a[0]),e(-a[1],A[0])),-s[2]),n(t(e(A[1],s[0]),e(-s[1],A[0])),a[2]))),i[3]),n(t(n(t(e(s[1],a[0]),e(-a[1],s[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-s[2]),n(t(e(i[1],s[0]),e(-s[1],i[0])),a[2]))),-A[3])),t(n(t(n(t(e(A[1],a[0]),e(-a[1],A[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),a[2]))),s[3]),n(t(n(t(e(A[1],s[0]),e(-s[1],A[0])),i[2]),t(n(t(e(i[1],s[0]),e(-s[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),s[2]))),-a[3]))),t(t(n(t(n(t(e(A[1],a[0]),e(-a[1],A[0])),o[2]),t(n(t(e(o[1],a[0]),e(-a[1],o[0])),-A[2]),n(t(e(o[1],A[0]),e(-A[1],o[0])),a[2]))),i[3]),n(t(n(t(e(A[1],a[0]),e(-a[1],A[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-A[2]),n(t(e(i[1],A[0]),e(-A[1],i[0])),a[2]))),-o[3])),t(n(t(n(t(e(o[1],a[0]),e(-a[1],o[0])),i[2]),t(n(t(e(i[1],a[0]),e(-a[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),a[2]))),A[3]),n(t(n(t(e(o[1],A[0]),e(-A[1],o[0])),i[2]),t(n(t(e(i[1],A[0]),e(-A[1],i[0])),-o[2]),n(t(e(i[1],o[0]),e(-o[1],i[0])),A[2]))),-a[3])))),u=r(c,l);return u[u.length-1]}}function wV(t){return(3===t?vV:4===t?mV:yV)(pV,hV,fV,gV)}const bV=wV(3),BV=wV(4),EV=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,n){const r=(t[1]-n[1])*(e[0]-n[0]),i=(t[0]-n[0])*(e[1]-n[1]),o=r-i;let A;if(r>0){if(i<=0)return o;A=r+i}else{if(!(r<0))return o;if(i>=0)return o;A=-(r+i)}const s=33306690738754716e-32*A;return o>=s||o<=-s?o:bV(t,e,n)},function(t,e,n,r){const i=t[0]-r[0],o=e[0]-r[0],A=n[0]-r[0],s=t[1]-r[1],a=e[1]-r[1],c=n[1]-r[1],l=t[2]-r[2],u=e[2]-r[2],h=n[2]-r[2],d=o*c,f=A*a,g=A*s,p=i*c,v=i*a,m=o*s,y=l*(d-f)+u*(g-p)+h*(v-m),w=7771561172376103e-31*((Math.abs(d)+Math.abs(f))*Math.abs(l)+(Math.abs(g)+Math.abs(p))*Math.abs(u)+(Math.abs(v)+Math.abs(m))*Math.abs(h));return y>w||-y>w?y:BV(t,e,n,r)}];function xV(t){let e=EV[t.length];return e||(e=EV[t.length]=wV(t.length)),e.apply(void 0,...t)}var CV=function(){for(;EV.length<=5;)EV.push(wV(EV.length));const t=function(t,e,n,r,i,o,A){return function(...e){switch(e.length){case 0:case 1:return 0;case 2:return r(e[0],e[1]);case 3:return i(e[0],e[1],e[2]);case 4:return o(e[0],e[1],e[2],e[3]);case 5:return A(e[0],e[1],e[2],e[3],e[4])}return t(e)}}(void 0,xV,...EV);for(let e=0;e<=5;++e)t[e]=EV[e];return t}();const MV=CV[3];function FV(t,e,n,r){const i=CV(t,n,r),o=CV(e,n,r);if(i>0&&o>0||i<0&&o<0)return!1;const A=CV(n,t,e),s=CV(r,t,e);return!(A>0&&s>0||A<0&&s<0)&&(0!==i||0!==o||0!==A||0!==s||function(t,e,n,r){for(let i=0;i<2;++i){const o=t[i],A=e[i],[s,a]=[Math.min(o,A),Math.max(o,A)],c=n[i],l=r[i],[u,h]=[Math.min(c,l),Math.max(c,l)];if(h<s||a<u)return!1}return!0}(t,e,n,r))}function kV(t,e){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)}function SV(t,e,n){const r=[e[0]-t[0],e[1]-t[1]],i=[n[0]-t[0],n[1]-t[1]],o=kV(t,e),A=kV(t,n);return(r[0]*i[0]+r[1]*i[1])/Math.sqrt(o*A)}function QV(t,e){for(let n=0;n<e.length-1;n++){const r=[e[n],e[n+1]];if(!(t[0][0]===r[0][0]&&t[0][1]===r[0][1]||t[0][0]===r[1][0]&&t[0][1]===r[1][1])&&FV(t[0],t[1],r[0],r[1]))return!0}return!1}function UV(t){return[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])]}function NV(t,e,n){let r,i,o=null,A=IV,s=IV;for(let a=0;a<e.length;a++)r=SV(t[0],t[1],e[a]),i=SV(t[1],t[0],e[a]),r>A&&i>s&&!QV([t[0],e[a]],n)&&!QV([t[1],e[a]],n)&&(A=r,s=i,o=e[a]);return o}function TV(t,e,n,r,i){let o=!1;for(let A=0;A<t.length-1;A++){const s=[t[A],t[A+1]],a=s[0][0]+","+s[0][1]+","+s[1][0]+","+s[1][1];if(kV(s[0],s[1])<e||i.has(a))continue;let c,l,u,h=0,d=UV(s);do{d=r.extendBbox(d,h),c=d[2]-d[0],l=d[3]-d[1],u=NV(s,r.rangePoints(d),t),h++}while(null===u&&(n[0]>c||n[1]>l));c>=n[0]&&l>=n[1]&&i.add(a),null!==u&&(t.splice(A+1,0,u),r.removePoint(u),o=!0)}return o?TV(t,e,n,r,i):t}function OV(t,e,n){const r=e||20,i=function(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++){const i=t[r];n[0]===i[0]&&n[1]===i[1]||e.push(i),n=i}return e}(function(t){return t.sort(function(t,e){return t[0]-e[0]||t[1]-e[1]})}(cV.toXy(t,n)));if(i.length<4){const t=i.concat([i[0]]);return n?cV.fromXy(t,n):t}const o=function(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let o=t.length-1;o>=0;o--)t[o][0]<e&&(e=t[o][0]),t[o][1]<n&&(n=t[o][1]),t[o][0]>r&&(r=t[o][0]),t[o][1]>i&&(i=t[o][1]);return[r-e,i-n]}(i),A=[o[0]*LV,o[1]*LV],s=function(t){const e=t.length;if(e<3){const n=new Array(e);for(let t=0;t<e;++t)n[t]=t;return 2===e&&t[0][0]===t[1][0]&&t[0][1]===t[1][1]?[0]:n}const n=new Array(e);for(let t=0;t<e;++t)n[t]=t;n.sort((e,n)=>t[e][0]-t[n][0]||t[e][1]-t[n][1]);const r=[n[0],n[1]],i=[n[0],n[1]];for(let o=2;o<e;++o){const e=n[o],A=t[e];let s=r.length;for(;s>1&&MV(t[r[s-2]],t[r[s-1]],A)<=0;)s-=1,r.pop();for(r.push(e),s=i.length;s>1&&MV(t[i[s-2]],t[i[s-1]],A)>=0;)s-=1,i.pop();i.push(e)}const o=new Array(i.length+r.length-2);let A=0;for(let t=0,e=r.length;t<e;++t)o[A++]=r[t];for(let t=i.length-2;t>0;--t)o[A++]=i[t];return o}(i).reverse().map(t=>i[t]);s.push(s[0]);const a=i.filter(function(t){return s.indexOf(t)<0}),c=Math.ceil(1/(i.length/(o[0]*o[1]))),l=TV(s,Math.pow(r,2),A,function(t,e){return new lV(t,e)}(a,c),new Set);return n?cV.fromXy(l,n):l}const IV=Math.cos(90/(180/Math.PI)),LV=.6;const PV=(t,e,n)=>{if("sharp"===n)return[["M",t[0]-e,t[1]-e],["L",t[0]+e,t[1]-e],["L",t[0]+e,t[1]+e],["L",t[0]-e,t[1]+e],["Z"]];const r=[e,e,0,0,0];return[["M",t[0],t[1]-e],["A",...r,t[0],t[1]+e],["A",...r,t[0],t[1]-e]]},DV=(t,e,n)=>{const r=[e,e,0,0,0],i="sharp"===n?ay(t[0],hy(gy(cy(t[0],t[1])),e)):t[0],o="sharp"===n?ay(t[1],hy(gy(cy(t[1],t[0])),e)):t[1],A=hy(gy(vy(cy(i,o),!1)),e),s=hy(A,-1),a=ay(i,A),c=ay(o,A),l=ay(o,s),u=ay(i,s);return"sharp"===n?[["M",a[0],a[1]],["L",c[0],c[1]],["L",l[0],l[1]],["L",u[0],u[1]],["Z"]]:[["M",a[0],a[1]],["L",c[0],c[1]],["A",...r,l[0],l[1]],["L",u[0],u[1]],["A",...r,a[0],a[1]]]},RV=(t,e)=>{const n=_y(t).map((n,r)=>{const i=(r-2+t.length)%t.length,o=(r-1+t.length)%t.length,A=(r+1)%t.length,s=t[i],a=t[o],c=t[A],l=cy(s,a),u=cy(a,n),h=cy(n,c),d=(t,e)=>py(t,e,!0)<Math.PI,f=d(l,u),g=d(u,h),p=t=>hy(gy(vy(t,!1)),e),v=p(u);return[{p:yy(ay(a,f?p(l):v)),concave:f&&a},{p:yy(ay(n,g?p(h):v)),concave:g&&n}]}),r=[e,e,0,0,0],i=n.findIndex((t,e)=>!(n[(e-1+n.length)%n.length][0].concave||n[(e-1+n.length)%n.length][1].concave||t[0].concave||t[0].concave||t[1].concave)),o=n.slice(i).concat(n.slice(0,i));let A=[];return o.flatMap((t,e)=>{const i=[],s=o[n.length-1];return 0===e&&i.push(["M",...s[1].p]),t[0].concave?A.push(t[0].p,t[1].p):i.push(["A",...r,...t[0].p]),t[1].concave?A.unshift(t[1].p):i.push(["L",...t[1].p]),3===A.length&&(i.pop(),i.push(["C",...A.flat()]),A=[]),i})},HV=(t,e)=>{const n=_y(t).map((e,n)=>({p:e,v:gy(cy(t[(n+1)%t.length],e))}));return n.forEach((r,i)=>{const o=i>0?i-1:t.length-1,A=n[o].v,s=gy(ay(A,hy(r.v,py(A,r.v,!0)<Math.PI?1:-1)));r.p=ay(r.p,hy(s,e))}),Ew(n.map(t=>t.p))},_V=(t,e)=>{const n=t.map((n,r)=>{const i=t[0===r?t.length-1:r-1],o=wy(hy(gy(vy(cy(i,n),!1)),e));return[ay(i,o),ay(n,o)]}),r=n.flat(),i=r.map((t,e)=>{if(e%2==0)return null;return xy([r[(e-1)%r.length],r[e%r.length]],[r[(e+1)%r.length],r[(e+2)%r.length]],!0)}).filter(Boolean);return i.map((t,e)=>[0===e?"M":"L",t[0],t[1]]).concat([["Z"]])};class GV extends tz{constructor(t,e){super(t,Object.assign({},GV.defaultOptions,e)),this.hullMemberIds=[],this.drawHull=()=>{if(this.shape){const t=!xe(this.optionsCache,this.options);this.shape.update(this.getHullStyle(t))}else this.shape=new xw({style:this.getHullStyle()}),this.context.canvas.appendChild(this.shape);this.optionsCache=Object.assign({},this.options)},this.updateHullPath=t=>{this.shape&&this.options.members.includes(Km(t.data))&&this.shape.update({d:this.getHullPath(!0)})},this.getHullPath=(t=!1)=>{const{graph:e}=this.context,n=this.getMember();if(0===n.length)return"";const r=n.map(t=>e.getNodeData(t)),i=OV(r.map(My),this.options.concavity).slice(1).reverse(),o=i.flatMap(t=>r.filter(e=>xe(My(e),t)).map(Km));return xe(o,this.hullMemberIds)&&!t||(this.hullMemberIds=o,this.path=function(t,e,n){if(1===t.length)return PV(t[0],e,n);if(2===t.length)return DV(t,e,n);if(3===t.length){const[r,i,o]=_y(t);if(Iy(r,i,o))return DV([r,o],e,n)}switch(n){case"smooth":return HV(t,e);case"sharp":return _V(t,e);default:return RV(t,e)}}(i,this.getPadding(),this.options.corner)),this.path},this.bindEvents()}bindEvents(){this.context.graph.on(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.on(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}unbindEvents(){this.context.graph.off(t.GraphEvent.AFTER_RENDER,this.drawHull),this.context.graph.off(t.GraphEvent.AFTER_ELEMENT_UPDATE,this.updateHullPath)}getHullStyle(t){const e=this.options,{members:n,padding:r,corner:i}=e,o=Pe(e,["members","padding","corner"]);return Object.assign(Object.assign({},o),{d:this.getHullPath(t)})}getPadding(){const{graph:t}=this.context,e=this.hullMemberIds.reduce((e,n)=>{const{halfExtents:r}=t.getElementRenderBounds(n),i=Math.max(r[0],r[1]);return Math.max(e,i)},0);return e+this.options.padding}addMember(t){const e=Array.isArray(t)?t:[t];this.options.members=[...new Set([...this.options.members,...e])],this.shape.update({d:this.getHullPath()})}removeMember(t){const e=Array.isArray(t)?t:[t];this.options.members=this.options.members.filter(t=>!e.includes(t)),e.some(t=>this.hullMemberIds.includes(t))&&this.shape.update({d:this.getHullPath()})}updateMember(t){this.options.members=Gt(t)?t(this.options.members):t,this.shape.update(this.getHullStyle(!0))}getMember(){return this.options.members}destroy(){this.unbindEvents(),this.shape.destroy(),this.hullMemberIds=[],super.destroy()}}function KV(t,e){e(t),t.children&&t.children.forEach(function(t){t&&KV(t,e)})}function jV(t){VV(t,!0)}function zV(t){VV(t,!1)}function VV(t,e){var n=e?"visible":"hidden";KV(t,function(t){t.attr("visibility",n)})}GV.defaultOptions={members:[],padding:10,corner:"rounded",concavity:1/0,fill:"lightblue",fillOpacity:.2,labelOpacity:1,stroke:"blue",strokeOpacity:.2};var WV=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=t.apply(this,_e([],He(e),!1))||this;return r.isMutationObserved=!0,r.addEventListener(ea.INSERTED,function(){zV(r)}),r}return Ie(e,t),e}(Xa);function YV(t){var e=t.appendChild(new WV({class:"offscreen"}));return zV(e),e}var XV=function(t){function e(e){void 0===e&&(e={});var n=e.style,r=Pe(e,["style"]);return t.call(this,Le({style:Le({text:"",fill:"black",fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineWidth:1,textAlign:"start",textBaseline:"middle"},n)},r))||this}return Ie(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=YV(this)),this._offscreen},enumerable:!1,configurable:!0}),e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e}(cc);function qV(t){return t*Math.PI/180}function $V(t){return Number((180*t/Math.PI).toPrecision(5))}var ZV=function(){function t(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=n,this.height=r}return Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y},enumerable:!1,configurable:!0}),t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t.prototype.toJSON=function(){return{x:this.x,y:this.y,width:this.width,height:this.height,top:this.top,right:this.right,bottom:this.bottom,left:this.left}},t.prototype.isPointIn=function(t,e){return t>=this.left&&t<=this.right&&e>=this.top&&e<=this.bottom},t}();function JV(t,e){return Gt(t)?t.apply(void 0,_e([],He(e),!1)):t}var tW,eW=function(t,e){var n=function(t){return"".concat(e,"-").concat(t)},r=Object.fromEntries(Object.entries(t).map(function(t){var e=He(t,2),r=e[0],i=e[1],o=n(i);return[r,{name:o,class:".".concat(o),id:"#".concat(o),toString:function(){return o}}]}));return Object.assign(r,{prefix:n}),r},nW=function(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=5),Object.entries(e).forEach(function(i){var o=He(i,2),A=o[0],s=o[1],a=t;Object.prototype.hasOwnProperty.call(e,A)&&(s?qt(s)?(qt(t[A])||(a[A]={}),n<r?nW(t[A],s,n+1,r):a[A]=e[A]):jt(s)?(a[A]=[],a[A]=a[A].concat(s)):a[A]=s:a[A]=s)})},rW=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)nW(t,e[r]);return t},iW=function(t){return void 0!==t&&null!=t&&!Number.isNaN(t)},oW=me(function(t,e){var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,A=e.fontVariant;return tW||(tW=Ua.offscreenCanvasCreator.getOrCreateContext(void 0)),tW.font=[o,A,i,"".concat(n,"px"),r].join(" "),tW.measureText(t).width},function(t,e){return[t,Object.values(e||AW(t)).join()].join("")},4096),AW=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 sW(t){return"text"===t.nodeName?t:"g"===t.nodeName&&1===t.children.length&&"text"===t.children[0].nodeName?t.children[0]:null}function aW(t,e){var n=sW(t);n&&n.attr(e)}function cW(t,e,n){void 0===n&&(n="..."),aW(t,{wordWrap:!0,wordWrapWidth:e,maxLines:1,textOverflow:n})}function lW(t){var e=t.nativeEvent,n=t.touches,r=t.clientX,i=t.clientY;if(e)return[e.clientX,e.clientY];if(n){var o=n[0];return[o.clientX,o.clientY]}return"number"==typeof r&&"number"==typeof i?[r,i]:[0,0]}function uW(t){return"function"==typeof t?t():Jt(t)||re(t)?new XV({style:{text:String(t)}}):t}function hW(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 dW(t,e,n,r,i){return void 0===r&&(r=!0),void 0===i&&(i=!1),!!(r&&t===e||i&&t===n)||t>e&&t<n}function fW(t,e){return"number"==typeof t&&"number"==typeof e?function(t,e){return function(n){return t*(1-n)+e*n}}(t,e):Array.isArray(t)&&Array.isArray(e)?function(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0;return function(i){var o=new Array(r),A=new Array(n),s=0;for(s=0;s<r;++s)o[s]=fW(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=He(e,2),o=i[0],A=i[1];o in t?n[o]=fW(t[o],A):r[o]=A}),function(t){return Object.entries(n).forEach(function(e){var n=He(e,2),i=n[0],o=n[1];return r[i]=o(t)}),r}}(t,e):function(e){return t}}function gW(t,e){return[t[0]*e,t[1]*e]}function pW(t,e){return[t[0]+e[0],t[1]+e[1]]}function vW(t,e){return[t[0]-e[0],t[1]-e[1]]}function mW(t,e){return[Math.min(t[0],e[0]),Math.min(t[1],e[1])]}function yW(t,e){return[Math.max(t[0],e[0]),Math.max(t[1],e[1])]}function wW(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function bW(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 BW(t,e){return+t.toPrecision(e)}function EW(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 xW(t,e,n){void 0===n&&(n=[[0,0],[1,1]]);for(var r=[],i=0,o=t.length;i<o;i+=2)r.push([t[i],t[i+1]]);var A,s,a,c=function(t,e,n,r){var i,o,A,s,a,c,l=[],u=!!r,h=[1/0,1/0],d=[-1/0,-1/0];if(u){h=(i=He(r,2))[0],d=i[1];for(var f=0,g=t.length;f<g;f+=1)h=mW(h,v=t[f]),d=yW(d,v)}f=0;for(var p=t.length;f<p;f+=1){var v=t[f];if(0===f)c=v;else if(f===p-1)a=v,l.push(c),l.push(a);else{o=t[f-1];var m=[0,0];m=gW(m=vW(A=t[f+1],o),e);var y=wW(v,o),w=wW(v,A),b=y+w;0!==b&&(y/=b,w/=b);var B=gW(m,-y),E=gW(m,w);a=pW(v,B),s=mW(s=pW(v,E),yW(A,v)),s=yW(s,mW(A,v)),a=mW(a=pW(v,B=gW(B=vW(s,v),-y/w)),yW(o,v)),s=pW(v,E=gW(E=vW(v,a=yW(a,mW(o,v))),w/y)),u&&(a=mW(a=yW(a,h),d),s=mW(s=yW(s,h),d)),l.push(c),l.push(a),c=s}}return l}(r,.4,0,n),l=r.length,u=[];for(i=0;i<l-1;i+=1)A=c[2*i],s=c[2*i+1],a=r[i+1],u.push(["C",A[0],A[1],s[0],s[1],a[0],a[1]]);return u}var CW=["$el","cx","cy","d","dx","dy","fill","fillOpacity","filter","fontFamily","fontSize","fontStyle","fontVariant","fontWeight","height","img","increasedLineWidthForHitTesting","innerHTML","isBillboard","billboardRotation","isSizeAttenuation","isClosed","isOverflowing","leading","letterSpacing","lineDash","lineHeight","lineWidth","markerEnd","markerEndOffset","markerMid","markerStart","markerStartOffset","maxLines","metrics","miterLimit","offsetX","offsetY","opacity","path","points","r","radius","rx","ry","shadowColor","src","stroke","strokeOpacity","text","textAlign","textBaseline","textDecorationColor","textDecorationLine","textDecorationStyle","textOverflow","textPath","textPathSide","textPathStartOffset","transform","transformOrigin","visibility","width","wordWrap","wordWrapWidth","x","x1","x2","y","y1","y2","z1","z2","zIndex"];function MW(t){return CW.includes(t)}function FW(t){var e={};for(var n in t)MW(n)&&(e[n]=t[n]);return e}function kW(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,A=e/Math.max(i,o);return t.style.transform="scale(".concat(A,")"),A}var SW=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=He(Array.isArray(A)?A:[A,null],2),a=s[0],c=s[1];(u=r(a,o)).__data__=a,null!==c&&(u.__fromElements__=c),this._parent.appendChild(u),i.push(u)}return new n(i,null,this._parent,this._document)}for(o=0;o<this._elements.length;o++){var l=this._elements[o],u=r(a=l.__data__,o);l.appendChild(u),i.push(u)}return new n(i,null,i[0],this._document)},t.prototype.maybeAppend=function(t,n){var i=Ge(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=Ge(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=Ge(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,a,c=[],l=[],u=new Set(this._elements),h=[],d=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]})),p=(A=this._elements,s=function(t){return r(t.__data__)},a=new Map,A.forEach(function(t){var e=s(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}),a),v=0;v<t.length;v++){var m=t[v],y=e(m,v),w=r(m,v);if(f.has(y))(x=f.get(y)).__data__=m,x.__facet__=!1,l.push(x),u.delete(x),f.delete(y);else if(g.has(y)){(x=g.get(y)).__data__=m,x.__facet__=!0,l.push(x),g.delete(y)}else if(p.has(y)){var b=p.get(y);h.push([m,b]);try{for(var B=(i=void 0,Re(b)),E=B.next();!E.done;E=B.next()){var x=E.value;u.delete(x)}}catch(t){i={error:t}}finally{try{E&&!E.done&&(o=B.return)&&o.call(B)}finally{if(i)throw i.error}}p.delete(y)}else if(f.has(w)){(x=f.get(w)).__toData__?x.__toData__.push(m):x.__toData__=[m],d.add(x),u.delete(x)}else c.push(m)}var C=[new n([],c,this._parent,this._document),new n(l,null,this._parent,this._document),new n(u,null,this._parent,this._document),new n([],h,this._parent,this._document),new n(d,null,this._parent,this._document)];return new n(this._elements,null,this._parent,this._document,C)},t.prototype.merge=function(t){var e=_e(_e([],He(this._elements),!1),He(t._elements),!1),r=_e(_e([],He(this._transitions),!1),He(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),a=r(this._merge),c=i(this._split);return A.merge(o).merge(s).merge(a).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=He(t,2),A=o[0],s=o[1],a="function"==typeof s&&e?s:function(){return s};void 0!==s&&i.attr(A,a.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){this._transitions;var e=new Array(this._elements.length);return this.each(function(n,r){e[r]=t.call(this,n,r)}),this._transitions=function(t){if(!jt(t))return[];for(var e=[],n=0;n<t.length;n++)e=e.concat(t[n]);return e}(e),this},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,_e([this._parent,this],He(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:Xa,rect:sc,circle:za,path:nc,text:XV,ellipse:Ya,image:Za,line:tc,polygon:ic,polyline:Ac,html:$a},t}();function QW(t){return new SW([t],null,t,t.ownerDocument)}function UW(t){if(re(t))return[t,t,t,t];if(jt(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 NW(t){var e=t.getLocalBounds(),n=He([e.min,e.max],2),r=He(n[0],2),i=r[0],o=r[1],A=He(n[1],2),s=A[0],a=A[1];return{x:i,y:o,width:s-i,height:a-o,left:i,bottom:a,top:o,right:s}}function TW(t,e){var n=He(t,2),r=n[0],i=n[1],o=He(e,2),A=o[0],s=o[1];return r!==A&&i===s}function OW(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function IW(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 LW=function(t,e){if(!(null==t?void 0:t.startsWith(e)))return!1;var n=t[e.length];return n>="A"&&n<="Z"};function PW(t,e,n){void 0===n&&(n=!1);var r={};return Object.entries(t).forEach(function(t){var i=He(t,2),o=i[0],A=i[1];if("className"===o||"class"===o);else if(LW(o,"show")&&LW(IW(o,"show"),e)!==n)o===function(t,e){return"".concat(e).concat(OW(t))}(e,"show")?r[o]=A:r[o.replace(new RegExp(OW(e)),"")]=A;else if(!LW(o,"show")&&LW(o,e)!==n){var s=IW(o,e);"filter"===s&&"function"==typeof A||(r[s]=A)}}),r}function DW(t,e){return Object.entries(t).reduce(function(t,n){var r=He(n,2),i=r[0],o=r[1];return i.startsWith("show")?t["show".concat(e).concat(i.slice(4))]=o:t["".concat(e).concat(OW(i))]=o,t},{})}function RW(t,e){void 0===e&&(e=["x","y","class","className"]);var n=["transform","transformOrigin","anchor","visibility","pointerEvents","zIndex","cursor","clipPath","clipPathTargets","offsetPath","offsetPathTargets","offsetDistance","draggable","droppable"],r={},i={};return Object.entries(t).forEach(function(t){var o=He(t,2),A=o[0],s=o[1];e.includes(A)||(-1!==n.indexOf(A)?i[A]=s:r[A]=s)}),[r,i]}function HW(t,e){var n={YYYY:t.getFullYear(),MM:t.getMonth()+1,DD:t.getDate(),HH:t.getHours(),mm:t.getMinutes(),ss:t.getSeconds()},r=e;return Object.keys(n).forEach(function(t){var e=n[t];r=r.replace(t,"YYYY"===t?"".concat(e):"".concat(e).padStart(2,"0"))}),r}function _W(t,e){if(e)try{var n=e.replace(/translate\(([+-]*[\d]+[%]*),[ ]*([+-]*[\d]+[%]*)\)/g,function(e,n,r){return"translate(".concat(function(t,e,n){var r=t.getBBox(),i=r.width,o=r.height,A=He([e,n].map(function(t,e){var n;return t.includes("%")?parseFloat((null===(n=t.match(/[+-]?([0-9]*[.])?[0-9]+/))||void 0===n?void 0:n[0])||"0")/100*(0===e?i:o):t}),2);return[A[0],A[1]]}(t,n,r),")")});t.attr("transform",n)}catch(t){}}var GW=function(t,e){null!=e?t.replaceChildren?Array.isArray(e)?t.replaceChildren.apply(t,_e([],He(e),!1)):t.replaceChildren(e):(t.innerHTML="",Array.isArray(e)?e.forEach(function(e){return t.appendChild(e)}):t.appendChild(e)):t.innerHTML=""};function KW(t){return/\S+-\S+/g.test(t)?t.split("-").map(function(t){return t[0]}):t.length>2?[t[0]]:t.split("")}function jW(){VV(this,"hidden"!==this.attributes.visibility)}var zW=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this,rW({},{style:n},e))||this;return r.initialized=!1,r._defaultOptions=n,r}return Ie(e,t),Object.defineProperty(e.prototype,"offscreenGroup",{get:function(){return this._offscreen||(this._offscreen=YV(this)),this._offscreen},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultOptions",{get:function(){return this._defaultOptions},enumerable:!1,configurable:!0}),e.prototype.connectedCallback=function(){this.render(this.attributes,this),this.bindEvents(this.attributes,this),this.initialized=!0},e.prototype.disconnectedCallback=function(){var t;null===(t=this._offscreen)||void 0===t||t.destroy()},e.prototype.attributeChangedCallback=function(t){"visibility"===t&&jW.call(this)},e.prototype.update=function(t,e){var n;return this.attr(rW({},this.attributes,t||{})),null===(n=this.render)||void 0===n?void 0:n.call(this,this.attributes,this,e)},e.prototype.clear=function(){this.removeChildren()},e.prototype.bindEvents=function(t,e){},e.prototype.getSubShapeStyle=function(t){return t.x,t.y,t.transform,t.transformOrigin,t.class,t.className,t.zIndex,Pe(t,["x","y","transform","transformOrigin","class","className","zIndex"])},e}(Wa),VW=function(t,e,n){return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"]]},WW=VW,YW=function(t,e,n){return[["M",t,e+n],["L",t,e-n]]},XW=function(t,e,n){return[["M",t-n,e],["L",t+n,e]]},qW=XW;var $W=function(t,e,n){return[["M",t-n,e-n],["L",t+n,e],["L",t-n,e+n],["Z"]]};function ZW(t){var e=function(t){var e="default";if(zt(t)&&t instanceof Image)e="image";else if(Gt(t))e="symbol";else if(Jt(t)){var n=new RegExp("data:(image|text)");e=t.match(n)?"base64":/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(t)?"url":"symbol"}return e}(t);return["base64","url","image"].includes(e)?"image":t&&"symbol"===e?"path":null}var JW=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,n){var r=t.x,i=void 0===r?0:r,o=t.y,A=void 0===o?0:o,s=this.getSubShapeStyle(t),a=s.symbol,c=s.size,l=void 0===c?16:c,u=Pe(s,["symbol","size"]),h=ZW(a);hW(!!h,QW(n),function(t){t.maybeAppendByClassName("marker",h).attr("className","marker ".concat(h,"-marker")).call(function(t){if("image"===h){var n=2*l;t.styles({img:a,width:n,height:n,x:i-l,y:A-l})}else{n=l/2;var r=Gt(a)?a:e.getSymbol(a);t.styles(Le({d:null==r?void 0:r(i,A,n)},u))}})})},e.MARKER_SYMBOL_MAP=new Map,e.registerSymbol=function(t,n){e.MARKER_SYMBOL_MAP.set(t,n)},e.getSymbol=function(t){return e.MARKER_SYMBOL_MAP.get(t)},e.getSymbols=function(){return Array.from(e.MARKER_SYMBOL_MAP.keys())},e}(zW);function tY(t,...e){return e.reduce((t,e)=>n=>t(e(n)),t)}function eY(t,e){return e-t?n=>(n-t)/(e-t):t=>.5}JW.registerSymbol("cross",function(t,e,n){return[["M",t-n,e-n],["L",t+n,e+n],["M",t+n,e-n],["L",t-n,e+n]]}),JW.registerSymbol("hyphen",function(t,e,n){return[["M",t-n,e],["L",t+n,e]]}),JW.registerSymbol("line",YW),JW.registerSymbol("plus",function(t,e,n){return[["M",t-n,e],["L",t+n,e],["M",t,e-n],["L",t,e+n]]}),JW.registerSymbol("tick",function(t,e,n){return[["M",t-n/2,e-n],["L",t+n/2,e-n],["M",t,e-n],["L",t,e+n],["M",t-n/2,e+n],["L",t+n/2,e+n]]}),JW.registerSymbol("circle",VW),JW.registerSymbol("point",WW),JW.registerSymbol("bowtie",function(t,e,n){var r=n-1.5;return[["M",t-n,e-r],["L",t+n,e+r],["L",t+n,e-r],["L",t-n,e+r],["Z"]]}),JW.registerSymbol("hexagon",function(t,e,n){var r=n/2*Math.sqrt(3);return[["M",t,e-n],["L",t+r,e-n/2],["L",t+r,e+n/2],["L",t,e+n],["L",t-r,e+n/2],["L",t-r,e-n/2],["Z"]]}),JW.registerSymbol("square",function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]}),JW.registerSymbol("diamond",function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]}),JW.registerSymbol("triangle",function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+r],["L",t,e-r],["L",t+n,e+r],["Z"]]}),JW.registerSymbol("triangle-down",function(t,e,n){var r=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-r],["L",t+n,e-r],["L",t,e+r],["Z"]]}),JW.registerSymbol("line",YW),JW.registerSymbol("dot",XW),JW.registerSymbol("dash",qW),JW.registerSymbol("smooth",function(t,e,n){return[["M",t-n,e],["A",n/2,n/2,0,1,1,t,e],["A",n/2,n/2,0,1,0,t+n,e]]}),JW.registerSymbol("hv",function(t,e,n){return[["M",t-n-1,e-2.5],["L",t,e-2.5],["L",t,e+2.5],["L",t+n+1,e+2.5]]}),JW.registerSymbol("vh",function(t,e,n){return[["M",t-n-1,e+2.5],["L",t,e+2.5],["L",t,e-2.5],["L",t+n+1,e-2.5]]}),JW.registerSymbol("hvh",function(t,e,n){return[["M",t-(n+1),e+2.5],["L",t-n/2,e+2.5],["L",t-n/2,e-2.5],["L",t+n/2,e-2.5],["L",t+n/2,e+2.5],["L",t+n+1,e+2.5]]}),JW.registerSymbol("vhv",function(t,e){return[["M",t-5,e+2.5],["L",t-5,e],["L",t,e],["L",t,e-3],["L",t,e+3],["L",t+6.5,e+3]]}),JW.registerSymbol("focus",function(t,e,n){var r=.2*n,i=.7*n;return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e],["Z"],["M",t-i,e],["L",t-r,e],["M",t+r,e],["L",t+i,e],["M",t,e-i],["L",t,e-r],["M",t,e+r],["L",t,e+i]]});const nY=Math.sqrt(50),rY=Math.sqrt(10),iY=Math.sqrt(2);function oY(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),o=r/10**i;return i>=0?(o>=nY?10:o>=rY?5:o>=iY?2:1)*10**i:-(10**-i)/(o>=nY?10:o>=rY?5:o>=iY?2:1)}const AY=(t,e,n=5)=>{const r=[t,e];let i,o=0,A=r.length-1,s=r[o],a=r[A];return a<s&&([s,a]=[a,s],[o,A]=[A,o]),i=oY(s,a,n),i>0?(s=Math.floor(s/i)*i,a=Math.ceil(a/i)*i,i=oY(s,a,n)):i<0&&(s=Math.ceil(s*i)/i,a=Math.floor(a*i)/i,i=oY(s,a,n)),i>0?(r[o]=Math.floor(s/i)*i,r[A]=Math.ceil(a/i)*i):i<0&&(r[o]=Math.ceil(s*i)/i,r[A]=Math.floor(a*i)/i),r};function sY(t){return!(de(t)||(e=t,null===e)||Number.isNaN(t));var e}var aY={exports:{}},cY={exports:{}},lY=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},uY=Array.prototype.concat,hY=Array.prototype.slice,dY=cY.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];lY(i)?e=uY.call(e,hY.call(i)):e.push(i)}return e};dY.wrap=function(t){return function(){return t(dY(arguments))}};var fY=cY.exports,gY={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]},pY=fY,vY=Object.hasOwnProperty,mY=Object.create(null);for(var yY in gY)vY.call(gY,yY)&&(mY[gY[yY]]=yY);var wY=aY.exports={to:{},get:{}};function bY(t,e,n){return Math.min(Math.max(e,t),n)}function BY(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}wY.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=wY.get.hsl(t),n="hsl";break;case"hwb":e=wY.get.hwb(t),n="hwb";break;default:e=wY.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},wY.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;i[n]=parseInt(e.slice(o,o+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:vY.call(gY,e[1])?((i=gY[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=bY(i[n],0,255);return i[3]=bY(i[3],0,1),i},wY.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,bY(parseFloat(e[2]),0,100),bY(parseFloat(e[3]),0,100),bY(isNaN(n)?1:n,0,1)]}return null},wY.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,bY(parseFloat(e[2]),0,100),bY(parseFloat(e[3]),0,100),bY(isNaN(n)?1:n,0,1)]}return null},wY.to.hex=function(){var t=pY(arguments);return"#"+BY(t[0])+BY(t[1])+BY(t[2])+(t[3]<1?BY(Math.round(255*t[3])):"")},wY.to.rgb=function(){var t=pY(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]+")"},wY.to.rgb.percent=function(){var t=pY(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]+")"},wY.to.hsl=function(){var t=pY(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},wY.to.hwb=function(){var t=pY(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},wY.to.keyword=function(t){return mY[t.slice(0,3)]};var EY=y(aY.exports);function xY(t,e,n){let r=n;return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function CY(t){const e=EY.get(t);if(!e)return null;const{model:n,value:r}=e;return"rgb"===n?r:"hsl"===n?function(t){const e=t[0]/360,n=t[1]/100,r=t[2]/100,i=t[3];if(0===n)return[255*r,255*r,255*r,i];const o=r<.5?r*(1+n):r+n-r*n,A=2*r-o;return[255*xY(A,o,e+1/3),255*xY(A,o,e),255*xY(A,o,e-1/3),i]}(r):null}const MY=(t,e)=>n=>t*(1-n)+e*n,FY=(t,e)=>"number"==typeof t&&"number"==typeof e?MY(t,e):"string"==typeof t&&"string"==typeof e?((t,e)=>{const n=CY(t),r=CY(e);return null===n||null===r?n?()=>t:()=>e:t=>{const e=new Array(4);for(let i=0;i<4;i+=1){const o=n[i],A=r[i];e[i]=o*(1-t)+A*t}const[i,o,A,s]=e;return`rgba(${Math.round(i)}, ${Math.round(o)}, ${Math.round(A)}, ${s})`}})(t,e):()=>t,kY=(t,e)=>{const n=MY(t,e);return t=>Math.round(n(t))};function SY({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):n}function QY(t){return"object"==typeof t?t.valueOf():t}class UY extends Map{constructor(t){if(super(),this.map=new Map,this.initKey=QY,null!==t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(SY({map:this.map,initKey:this.initKey},t))}has(t){return super.has(SY({map:this.map,initKey:this.initKey},t))}set(t,e){return super.set(function({map:t,initKey:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}({map:this.map,initKey:this.initKey},t),e)}delete(t){return super.delete(function({map:t,initKey:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}({map:this.map,initKey:this.initKey},t))}}class NY{constructor(t){this.options=be({},this.getDefaultOptions()),this.update(t)}getOptions(){return this.options}update(t={}){this.options=be({},this.options,t),this.rescale(t)}rescale(t){}}const TY=Symbol("defaultUnknown");function OY(t,e,n){for(let r=0;r<e.length;r+=1)t.has(e[r])||t.set(n(e[r]),r)}function IY(t){const{value:e,from:n,to:r,mapper:i,notFoundReturn:o}=t;let A=i.get(e);if(void 0===A){if(o!==TY)return o;A=n.push(e)-1,i.set(e,A)}return r[A%r.length]}function LY(t){return t instanceof Date?t=>`${t}`:"object"==typeof t?t=>JSON.stringify(t):t=>t}class PY extends NY{getDefaultOptions(){return{domain:[],range:[],unknown:TY}}constructor(t){super(t)}map(t){return 0===this.domainIndexMap.size&&OY(this.domainIndexMap,this.getDomain(),this.domainKey),IY({value:this.domainKey(t),mapper:this.domainIndexMap,from:this.getDomain(),to:this.getRange(),notFoundReturn:this.options.unknown})}invert(t){return 0===this.rangeIndexMap.size&&OY(this.rangeIndexMap,this.getRange(),this.rangeKey),IY({value:this.rangeKey(t),mapper:this.rangeIndexMap,from:this.getRange(),to:this.getDomain(),notFoundReturn:this.options.unknown})}rescale(t){const[e]=this.options.domain,[n]=this.options.range;if(this.domainKey=LY(e),this.rangeKey=LY(n),!this.rangeIndexMap)return this.rangeIndexMap=new Map,void(this.domainIndexMap=new Map);t&&!t.range||this.rangeIndexMap.clear(),(!t||t.domain||t.compare)&&(this.domainIndexMap.clear(),this.sortedDomain=void 0)}clone(){return new PY(this.options)}getRange(){return this.options.range}getDomain(){if(this.sortedDomain)return this.sortedDomain;const{domain:t,compare:e}=this.options;return this.sortedDomain=e?[...t].sort(e):t,this.sortedDomain}}function DY(t){return Math.round(1e12*t)/1e12}function RY(t){const{domain:e,range:n,paddingOuter:r,paddingInner:i,flex:o,round:A,align:s}=t,a=e.length,c=function(t,e){const n=e-t.length;return n>0?[...t,...new Array(n).fill(1)]:n<0?t.slice(0,e):t}(o,a),[l,u]=n,h=u-l,d=h/(2/a*r+1-1/a*i),f=d*i/a,g=d-a*f,p=function(t){const e=Math.min(...t);return t.map(t=>t/e)}(c),v=g/p.reduce((t,e)=>t+e),m=new UY(e.map((t,e)=>{const n=p[e]*v;return[t,A?Math.floor(n):n]})),y=new UY(e.map((t,e)=>{const n=p[e]*v+f;return[t,A?Math.floor(n):n]})),w=Array.from(y.values()).reduce((t,e)=>t+e),b=l+(h-(w-w/a*i))*s;let B=A?Math.round(b):b;const E=new Array(a);for(let t=0;t<a;t+=1){E[t]=DY(B);const n=e[t];B+=y.get(n)}return{valueBandWidth:m,valueStep:y,adjustedRange:E}}class HY extends PY{getDefaultOptions(){return{domain:[],range:[0,1],align:.5,round:!1,paddingInner:0,paddingOuter:0,padding:0,unknown:TY,flex:[]}}constructor(t){super(t)}clone(){return new HY(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 RY(t);const{range:i,paddingOuter:o,paddingInner:A,round:s,align:a}=t;let c,l,u=i[0];const h=i[1]-u,d=2*o,f=r-A;c=h/Math.max(1,d+f),s&&(c=Math.floor(c)),u+=(h-c*(r-A))*a,l=c*(1-A),s&&(u=Math.round(u),l=Math.round(l));const g=new Array(r).fill(0).map((t,e)=>u+e*c);return{valueStep:c,valueBandWidth:l,adjustedRange:g}}({align:t,range:n,round:r,flex:i,paddingInner:this.getPaddingInner(),paddingOuter:this.getPaddingOuter(),domain:e});this.valueStep=s,this.valueBandWidth=A,this.adjustedRange=o}}const _Y=(t,e,n)=>{let r,i,o=t,A=e;if(o===A&&n>0)return[o];let s=oY(o,A,n);if(0===s||!Number.isFinite(s))return[];if(s>0){o=Math.ceil(o/s),A=Math.floor(A/s),i=new Array(r=Math.ceil(A-o+1));for(let t=0;t<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},GY=(t,e,n)=>{const[r,i]=t,[o,A]=e;let s,a;return r<i?(s=eY(r,i),a=n(o,A)):(s=eY(i,r),a=n(A,o)),tY(a,s)},KY=(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,a=A?[...e].reverse():e;for(let t=0;t<r;t+=1)i[t]=eY(s[t],s[t+1]),o[t]=n(a[t],a[t+1]);return e=>{const n=function(t,e,n,r){let i=n,o=r||t.length;const A=t=>t;for(;i<o;){const n=Math.floor((i+o)/2);A(t[n])>e?o=n:i=n+1}return i}(t,e,1,r)-1,A=i[n];return tY(o[n],A)(e)}},jY=(t,e,n,r)=>(Math.min(t.length,e.length)>2?KY:GY)(t,e,r?kY:n);class zY extends NY{getDefaultOptions(){return{domain:[0,1],range:[0,1],nice:!1,clamp:!1,round:!1,interpolate:MY,tickCount:5}}map(t){return sY(t)?this.output(t):this.options.unknown}invert(t){return sY(t)?this.input(t):this.options.unknown}nice(){if(!this.options.nice)return;const[t,e,n,...r]=this.getTickMethodOptions();this.options.domain=this.chooseNice()(t,e,n,...r)}getTicks(){const{tickMethod:t}=this.options,[e,n,r,...i]=this.getTickMethodOptions();return t(e,n,r,...i)}getTickMethodOptions(){const{domain:t,tickCount:e}=this.options;return[t[0],t[t.length-1],e]}chooseNice(){return AY}rescale(){this.nice();const[t,e]=this.chooseTransforms();this.composeOutput(t,this.chooseClamp(t)),this.composeInput(t,e,this.chooseClamp(e))}chooseClamp(t){const{clamp:e,range:n}=this.options,r=this.options.domain.map(t),i=Math.min(r.length,n.length);return e?function(t,e){const n=e<t?e:t,r=t>e?t:e;return t=>Math.min(Math.max(n,t),r)}(r[0],r[i-1]):Te}composeOutput(t,e){const{domain:n,range:r,round:i,interpolate:o}=this.options,A=jY(n.map(t),r,o,i);this.output=tY(A,e,t)}composeInput(t,e,n){const{domain:r,range:i}=this.options,o=jY(i,r.map(t),MY);this.input=tY(e,n,o)}}class VY extends zY{getDefaultOptions(){return{domain:[0,1],range:[0,1],unknown:void 0,nice:!1,clamp:!1,round:!1,interpolate:FY,tickMethod:_Y,tickCount:5}}chooseTransforms(){return[Te,Te]}clone(){return new VY(this.options)}}var WY=function(t){function e(e){var n=this,r=e.style,i=Pe(e,["style"]);return(n=t.call(this,be({},{type:"column"},Le({style:r},i)))||this).columnsGroup=new Xa({name:"columns"}),n.appendChild(n.columnsGroup),n.render(),n}return Ie(e,t),e.prototype.render=function(){var t=this.attributes,e=t.columns,n=t.x,r=t.y;this.columnsGroup.style.transform="translate(".concat(n,", ").concat(r,")"),QW(this.columnsGroup).selectAll(".column").data(e.flat()).join(function(t){return t.append("rect").attr("className","column").each(function(t){this.attr(t)})},function(t){return t.each(function(t){this.attr(t)})},function(t){return t.remove()})},e.prototype.update=function(t){this.attr(rW({},this.attributes,t)),this.render()},e.prototype.clear=function(){this.removeChildren()},e}(ja),YY=function(t){function e(e){var n=this,r=e.style,i=Pe(e,["style"]);return(n=t.call(this,be({},{type:"lines"},Le({style:r},i)))||this).linesGroup=n.appendChild(new Xa),n.areasGroup=n.appendChild(new Xa),n.render(),n}return Ie(e,t),e.prototype.render=function(){var t=this.attributes,e=t.lines,n=t.areas,r=t.x,i=t.y;this.style.transform="translate(".concat(r,", ").concat(i,")"),e&&this.renderLines(e),n&&this.renderAreas(n)},e.prototype.clear=function(){this.linesGroup.removeChildren(),this.areasGroup.removeChildren()},e.prototype.update=function(t){this.attr(rW({},this.attributes,t)),this.render()},e.prototype.renderLines=function(t){QW(this.linesGroup).selectAll(".line").data(t).join(function(t){return t.append("path").attr("className","line").each(function(t){this.attr(t)})},function(t){return t.each(function(t){this.attr(t)})},function(t){return t.remove()})},e.prototype.renderAreas=function(t){QW(this.linesGroup).selectAll(".area").data(t).join(function(t){return t.append("path").attr("className","area").each(function(t){this.attr(t)})},function(t){return t.each(function(t){this.style(t)})},function(t){return t.remove()})},e}(ja);function XY(t,e){void 0===e&&(e=!1);var n=e?t.length-1:0,r=t.map(function(t,e){return _e([e===n?"M":"L"],He(t),!1)});return e?r.reverse():r}function qY(t,e){if(void 0===e&&(e=!1),t.length<=2)return XY(t);for(var n=[],r=t.length,i=0;i<r;i+=1){var o=e?t[r-i-1]:t[i];xe(o,n.slice(-2))||n.push.apply(n,_e([],He(o),!1))}var A=xW(n);return e?A.unshift(_e(["M"],He(t[r-1]),!1)):A.unshift(_e(["M"],He(t[0]),!1)),A}function $Y(t,e,n){var r=ge(t);return r.push(["L",e,n],["L",0,n],["Z"]),r}function ZY(t){return 0===t.length?[0,0]:[Zt(Ae(t,function(t){return Zt(t)||0})),$t(oe(t,function(t){return $t(t)||0}))]}function JY(t){for(var e=ge(t),n=e[0].length,r=He([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],a=0;a<n;a+=1)s[a]>=0?(s[a]+=i[a],i[a]=s[a]):(s[a]+=o[a],o[a]=s[a]);return e}var tX=function(t){function e(e){return t.call(this,e,{type:"line",x:0,y:0,width:200,height:20,isStack:!1,color:["#83daad","#edbf45","#d2cef9","#e290b3","#6f63f4"],smooth:!0,lineLineWidth:1,areaOpacity:0,isGroup:!1,columnLineWidth:1,columnStroke:"#fff",scale:1,spacing:0})||this}return Ie(e,t),Object.defineProperty(e.prototype,"rawData",{get:function(){var t=this.attributes.data;if(!t||0===(null==t?void 0:t.length))return[[]];var e=ge(t);return re(e[0])?[e]:e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.isStack?JY(this.rawData):this.rawData},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scales",{get:function(){return this.createScales(this.data)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseline",{get:function(){var t=this.scales.y,e=He(t.getOptions().domain||[0,0],2),n=e[0],r=e[1];return r<0?t.map(r):t.map(n<0?0:n)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"containerShape",{get:function(){var t=this.attributes;return{width:t.width,height:t.height}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesStyle",{get:function(){var t=this,e=this.attributes,n=e.type,r=e.isStack,i=e.smooth;if("line"!==n)throw new Error("linesStyle can only be used in line type");var o=PW(this.attributes,"area"),A=PW(this.attributes,"line"),s=this.containerShape.width,a=this.data;if(0===a[0].length)return{lines:[],areas:[]};var c=this.scales,l=function(t,e){var n,r=e.x,i=e.y,o=He(i.getOptions().range||[0,0],2),A=o[0],s=o[1];return s>A&&(n=He([A,s],2),s=n[0],A=n[1]),t.map(function(t){return t.map(function(t,e){return[r.map(e),ne(i.map(t),s,A)]})})}(a,{x:c.x,y:c.y}),u=[];if(o){var h=this.baseline;u=r?i?function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=t[i],A=qY(o),s=void 0;if(0===i)s=$Y(A,e,n);else{var a=qY(t[i-1],!0),c=o[0];a[0][0]="L",s=_e(_e(_e([],He(A),!1),He(a),!1),[_e(["M"],He(c),!1),["Z"]],!1)}r.push(s)}return r}(l,s,h):function(t,e,n){for(var r=[],i=t.length-1;i>=0;i-=1){var o=XY(t[i]),A=void 0;if(0===i)A=$Y(o,e,n);else{var s=XY(t[i-1],!0);s[0][0]="L",A=_e(_e(_e([],He(o),!1),He(s),!1),[["Z"]],!1)}r.push(A)}return r}(l,s,h):function(t,e,n,r){return t.map(function(t){return $Y(e?qY(t):XY(t),n,r)})}(l,i,s,h)}return{lines:l.map(function(e,n){return Le({stroke:t.getColor(n),d:i?qY(e):XY(e)},A)}),areas:u.map(function(e,n){return Le({d:e,fill:t.getColor(n)},o)})}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columnsStyle",{get:function(){var t=this,e=PW(this.attributes,"column"),n=this.attributes,r=n.isStack,i=n.type,o=n.scale;if("column"!==i)throw new Error("columnsStyle can only be used in column type");var A=this.containerShape.height,s=this.rawData;if(!s)return{columns:[]};r&&(s=JY(s));var a=this.createScales(s),c=a.x,l=a.y,u=He(ZY(s),2),h=u[0],d=u[1],f=new VY({domain:[0,d-(h>0?0:h)],range:[0,A*o]}),g=c.getBandWidth(),p=this.rawData;return{columns:s.map(function(n,i){return n.map(function(n,o){var A=g/s.length;return Le(Le({fill:t.getColor(i)},e),r?{x:c.map(o),y:l.map(n),width:g,height:f.map(p[i][o])}:{x:c.map(o)+A*i,y:n>=0?l.map(n):l.map(0),width:A,height:f.map(Math.abs(n))})})})}},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){var n,r,i;(n=e,r=".container",i="rect",n.querySelector(r)?QW(n).select(r):QW(n).append(i)).attr("className","container").node();var o=t.type,A=t.x,s=t.y,a="spark".concat(o),c=Le({x:A,y:s},"line"===o?this.linesStyle:this.columnsStyle);QW(e).selectAll(".spark").data([o]).join(function(t){return t.append(function(t){return"line"===t?new YY({className:a,style:c}):new WY({className:a,style:c})}).attr("className","spark ".concat(a))},function(t){return t.update(c)},function(t){return t.remove()})},e.prototype.getColor=function(t){var e=this.attributes.color;return jt(e)?e[t%e.length]:Gt(e)?e.call(null,t):e},e.prototype.createScales=function(t){var e,n,r=this.attributes,i=r.type,o=r.scale,A=r.range,s=void 0===A?[]:A,a=r.spacing,c=this.containerShape,l=c.width,u=c.height,h=He(ZY(t),2),d=h[0],f=h[1],g=new VY({domain:[null!==(e=s[0])&&void 0!==e?e:d,null!==(n=s[1])&&void 0!==n?n:f],range:[u,u*(1-o)]});return"line"===i?{type:i,x:new VY({domain:[0,t[0].length-1],range:[0,l]}),y:g}:{type:i,x:new HY({domain:t[0].map(function(t,e){return e}),range:[0,l],paddingInner:a,paddingOuter:a/2,align:.5}),y:g}},e.tag="sparkline",e}(zW);function eX(t){if(!t)return{enter:!1,update:!1,exit:!1};var e=["enter","update","exit"],n=Object.fromEntries(Object.entries(t).filter(function(t){var n=He(t,1)[0];return!e.includes(n)}));return Object.fromEntries(e.map(function(e){return function(t){return"boolean"!=typeof t&&"enter"in t&&"update"in t&&"exit"in t}(t)?!1===t[e]?[e,!1]:[e,Le(Le({},t[e]),n)]:[e,n]}))}function nX(t,e){t?t.finished.then(e):e()}function rX(t,e){"update"in t?t.update(e):t.attr(e)}function iX(t,e,n){return 0===e.length?null:n?t.animate(e,n):(rX(t,{style:e.slice(-1)[0]}),null)}function oX(t,e,n){var r={},i={};return Object.entries(e).forEach(function(e){var n=He(e,2),o=n[0],A=n[1];if(!Kt(A)){var s=t.style[o]||t.parsedStyle[o]||0;s!==A&&(r[o]=s,i[o]=A)}}),n?iX(t,[r,i],Le({fill:"both"},n)):(rX(t,i),null)}function AX(t,e){return t.style.opacity||(t.style.opacity=1),oX(t,{opacity:0},e)}var sX={fill:"#fff",lineWidth:1,radius:2,size:10,stroke:"#bfbfbf",strokeOpacity:1,zIndex:0},aX={fill:"#000",fillOpacity:.45,fontSize:12,textAlign:"center",textBaseline:"middle",zIndex:1},cX={x:0,y:0,orientation:"horizontal",showLabel:!0,type:"start"},lX=eW({foreground:"foreground",handle:"handle",selection:"selection",sparkline:"sparkline",sparklineGroup:"sparkline-group",track:"track",brushArea:"brush-area"},"slider"),uX=eW({labelGroup:"label-group",label:"label",iconGroup:"icon-group",icon:"icon",iconRect:"icon-rect",iconLine:"icon-line"},"handle"),hX=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,e){var n=t.x,r=t.y,i=t.size,o=void 0===i?10:i,A=t.radius,s=void 0===A?o/4:A,a=t.orientation,c=t.classNamePrefix,l=Pe(t,["x","y","size","radius","orientation","classNamePrefix"]),u=o,h=2.4*u,d=c?"".concat(uX.iconRect.name," ").concat(c,"handle-icon-rect"):uX.iconRect.name,f=function(t){return c?"".concat(uX.iconLine,"-").concat(t," ").concat(c,"handle-icon-line"):"".concat(uX.iconLine,"-").concat(t)},g=QW(e).maybeAppendByClassName(uX.iconRect,"rect").attr("className",d).styles(Le(Le({},l),{width:u,height:h,radius:s,x:n-u/2,y:r-h/2,transformOrigin:"center"})),p=n+1/3*u-u/2,v=n+2/3*u-u/2,m=r+1/4*h-h/2,y=r+3/4*h-h/2;g.maybeAppendByClassName("".concat(uX.iconLine,"-1"),"line").attr("className",f(1)).styles(Le({x1:p,x2:p,y1:m,y2:y},l)),g.maybeAppendByClassName("".concat(uX.iconLine,"-2"),"line").attr("className",f(2)).styles(Le({x1:v,x2:v,y1:m,y2:y},l)),"vertical"===a&&(g.node().style.transform="rotate(90)")},e}(zW),dX=function(t){function e(e){return t.call(this,e,cX)||this}return Ie(e,t),e.prototype.renderLabel=function(t){var e=this,n=this.attributes,r=n.x,i=n.y,o=n.showLabel,A=PW(this.attributes,"label"),s=A.x,a=void 0===s?0:s,c=A.y,l=void 0===c?0:c,u=A.transform,h=A.transformOrigin,d=He(RW(Pe(A,["x","y","transform","transformOrigin"]),[]),2),f=d[0],g=d[1],p=QW(t).maybeAppendByClassName(uX.labelGroup,"g").styles(g),v=Le(Le({},aX),f),m=v.text,y=Pe(v,["text"]);hW(!!o,p,function(t){e.label=t.maybeAppendByClassName(uX.label,"text").styles(Le(Le({},y),{x:r+a,y:i+l,transform:u,transformOrigin:h,text:"".concat(m)})),e.label.on("mousedown",function(t){t.stopPropagation()}),e.label.on("touchstart",function(t){t.stopPropagation()})})},e.prototype.renderIcon=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.orientation,o=e.type,A=e.classNamePrefix,s=Le(Le({x:n,y:r,orientation:i,classNamePrefix:A},sX),PW(this.attributes,"icon")),a=this.attributes.iconShape,c=void 0===a?function(){return new hX({style:s})}:a;QW(t).maybeAppendByClassName(uX.iconGroup,"g").selectAll(uX.icon.class).data([c]).join(function(t){return t.append("string"==typeof c?c:function(){return c(o)}).attr("className",uX.icon.name)},function(t){return t.update(s)},function(t){return t.remove()})},e.prototype.render=function(t,e){this.renderIcon(e),this.renderLabel(e)},e}(zW),fX=function(t){function e(e){var n=t.call(this,e,Le(Le(Le({x:0,y:0,animate:{duration:100,fill:"both"},brushable:!0,formatter:function(t){return t.toString()},handleSpacing:2,orientation:"horizontal",padding:0,autoFitLabel:!0,scrollable:!0,selectionFill:"#5B8FF9",selectionFillOpacity:.45,selectionZIndex:2,showHandle:!0,showLabel:!0,slidable:!0,trackFill:"#416180",trackLength:200,trackOpacity:.05,trackSize:20,trackZIndex:-1,values:[0,1],type:"range",selectionType:"select",handleIconOffset:0},DW(cX,"handle")),DW(sX,"handleIcon")),DW(aX,"handleLabel")))||this;return n.range=[0,1],n.onDragStart=function(t){return function(e){e.stopPropagation(),n.target=t,n.prevPos=n.getOrientVal(lW(e));var r=n.availableSpace,i=r.x,o=r.y,A=n.getBBox(),s=A.x,a=A.y;n.selectionStartPos=n.getRatio(n.prevPos-n.getOrientVal([i,o])-n.getOrientVal([+s,+a])),n.selectionWidth=0,document.addEventListener("pointermove",n.onDragging),document.addEventListener("pointerup",n.onDragEnd)}},n.onDragging=function(t){var e=n.attributes,r=e.slidable,i=e.brushable,o=e.type;t.stopPropagation();var A=n.getOrientVal(lW(t)),s=A-n.prevPos;if(s){var a=n.getRatio(s);switch(n.target){case"start":r&&n.setValuesOffset(a);break;case"end":r&&n.setValuesOffset(0,a);break;case"selection":r&&n.setValuesOffset(a,a);break;case"track":if(!i)return;n.selectionWidth+=a,"range"===o?n.innerSetValues([n.selectionStartPos,n.selectionStartPos+n.selectionWidth].sort(),!0):n.innerSetValues([0,n.selectionStartPos+n.selectionWidth],!0)}n.prevPos=A}},n.onDragEnd=function(){document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointermove",n.onDragging),document.removeEventListener("pointerup",n.onDragEnd),n.target="",n.updateHandlesPosition(!1)},n.onValueChange=function(t){var e=n.attributes,r=e.onChange,i=e.type,o="range"===i?t:t[1],A="range"===i?n.getValues():n.getValues()[1],s=new Vs("valuechange",{detail:{oldValue:o,value:A}});n.dispatchEvent(s),null==r||r(A)},n.selectionStartPos=0,n.selectionWidth=0,n.prevPos=0,n.target="",n}return Ie(e,t),Object.defineProperty(e.prototype,"values",{get:function(){return this.attributes.values},set:function(t){this.attributes.values=this.clampValues(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sparklineStyle",{get:function(){if("horizontal"!==this.attributes.orientation)return null;var t=PW(this.attributes,"sparkline");return Le(Le({zIndex:0},this.availableSpace),t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shape",{get:function(){var t=this.attributes,e=t.trackLength,n=t.trackSize,r=He(this.getOrientVal([[e,n],[n,e]]),2);return{width:r[0],height:r[1]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes;t.x,t.y;var e=He(UW(t.padding),4),n=e[0],r=e[1],i=e[2],o=e[3],A=this.shape;return{x:o,y:n,width:A.width-(o+r),height:A.height-(n+i)}},enumerable:!1,configurable:!0}),e.prototype.getValues=function(){return this.values},e.prototype.setValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1),this.attributes.values=t;var n=!1!==e&&this.attributes.animate;this.updateSelectionArea(n),this.updateHandlesPosition(n)},e.prototype.updateSelectionArea=function(t){var e=this.calcSelectionArea();this.foregroundGroup.selectAll(lX.selection.class).each(function(n,r){oX(this,e[r],t)})},e.prototype.updateHandlesPosition=function(t){this.attributes.showHandle&&(this.startHandle&&oX(this.startHandle,this.getHandleStyle("start"),t),this.endHandle&&oX(this.endHandle,this.getHandleStyle("end"),t))},e.prototype.innerSetValues=function(t,e){void 0===t&&(t=[0,0]),void 0===e&&(e=!1);var n=this.values,r=this.clampValues(t);this.attributes.values=r,this.setValues(r),e&&this.onValueChange(n)},e.prototype.renderTrack=function(t){var e=this.attributes,n=e.x,r=e.y,i=PW(this.attributes,"track");this.trackShape=QW(t).maybeAppendByClassName(lX.track,"rect").styles(Le(Le({x:n,y:r},this.shape),i))},e.prototype.renderBrushArea=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.brushable;this.brushArea=QW(t).maybeAppendByClassName(lX.brushArea,"rect").styles(Le({x:n,y:r,fill:"transparent",cursor:i?"crosshair":"default"},this.shape))},e.prototype.renderSparkline=function(t){var e=this,n=this.attributes,r=n.x,i=n.y;hW("horizontal"===n.orientation,QW(t).maybeAppendByClassName(lX.sparklineGroup,"g"),function(t){var n=Le(Le({},e.sparklineStyle),{x:r,y:i});t.maybeAppendByClassName(lX.sparkline,function(){return new tX({style:n})}).update(n)})},e.prototype.renderHandles=function(){var t,e=this,n=this.attributes,r=n.showHandle,i=n.type,o=r?"range"===i?["start","end"]:["end"]:[],A=this;null===(t=this.foregroundGroup)||void 0===t||t.selectAll(lX.handle.class).data(o.map(function(t){return{type:t}}),function(t){return t.type}).join(function(t){return t.append(function(t){var n=t.type;return new dX({style:e.getHandleStyle(n)})}).each(function(t){var e=t.type;this.attr("class","".concat(lX.handle.name," ").concat(e,"-handle"));var n="".concat(e,"Handle");A[n]=this,this.addEventListener("pointerdown",A.onDragStart(e))})},function(t){return t.each(function(t){var e=t.type;this.update(A.getHandleStyle(e))})},function(t){return t.each(function(t){var e=t.type,n="".concat(e,"Handle");A[n]=void 0}).remove()})},e.prototype.renderSelection=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.type,o=e.selectionType;this.foregroundGroup=QW(t).maybeAppendByClassName(lX.foreground,"g");var A=PW(this.attributes,"selection"),s=function(t){return t.style("visibility",function(t){return t.show?"visible":"hidden"}).style("cursor",function(t){return"select"===o?"grab":"invert"===o?"crosshair":"default"}).styles(Le(Le({},A),{transform:"translate(".concat(n,", ").concat(r,")")}))},a=this;this.foregroundGroup.selectAll(lX.selection.class).data("value"===i?[]:this.calcSelectionArea().map(function(t,e){return{style:Le({},t),index:e,show:"select"===o?1===e:1!==e}}),function(t){return t.index}).join(function(t){return t.append("rect").attr("className",lX.selection.name).call(s).each(function(t,e){var n=this;1===e?(a.selectionShape=QW(this),this.on("pointerdown",function(t){n.attr("cursor","grabbing"),a.onDragStart("selection")(t)}),a.dispatchCustomEvent(this,"pointerenter","selectionMouseenter"),a.dispatchCustomEvent(this,"pointerleave","selectionMouseleave"),a.dispatchCustomEvent(this,"click","selectionClick"),this.addEventListener("pointerdown",function(){n.attr("cursor","grabbing")}),this.addEventListener("pointerup",function(){n.attr("cursor","pointer")}),this.addEventListener("pointerover",function(){n.attr("cursor","pointer")})):this.on("pointerdown",a.onDragStart("track"))})},function(t){return t.call(s)},function(t){return t.remove()}),this.updateSelectionArea(!1),this.renderHandles()},e.prototype.render=function(t,e){this.renderTrack(e),this.renderSparkline(e),this.renderBrushArea(e),this.renderSelection(e)},e.prototype.clampValues=function(t,e){var n;void 0===e&&(e=4);var r=He(this.range,2),i=r[0],o=r[1],A=He(this.getValues().map(function(t){return BW(t,e)}),2),s=A[0],a=A[1],c=He(((Array.isArray(t)?t:[s,null!=t?t:a])||[s,a]).map(function(t){return BW(t,e)}),2),l=c[0],u=c[1];if("value"===this.attributes.type)return[0,ne(u,i,o)];l>u&&(l=(n=He([u,l],2))[0],u=n[1]);var h=u-l;return h>o-i?[i,o]:l<i?s===i&&a===u?[i,u]:[i,h+i]:u>o?a===o&&s===l?[l,o]:[o-h,o]:[l,u]},e.prototype.calcSelectionArea=function(t){var e=He(this.clampValues(t),2),n=e[0],r=e[1],i=this.availableSpace,o=i.x,A=i.y,s=i.width,a=i.height;return this.getOrientVal([[{y:A,height:a,x:o,width:n*s},{y:A,height:a,x:n*s+o,width:(r-n)*s},{y:A,height:a,x:r*s,width:(1-r)*s}],[{x:o,width:s,y:A,height:n*a},{x:o,width:s,y:n*a+A,height:(r-n)*a},{x:o,width:s,y:r*a,height:(1-r)*a}]])},e.prototype.calcHandlePosition=function(t){var e=this.attributes.handleIconOffset,n=this.availableSpace,r=n.x,i=n.y,o=n.width,A=n.height,s=He(this.clampValues(),2),a=s[0],c=s[1],l="start"===t?-e:e,u=("start"===t?a:c)*this.getOrientVal([o,A])+l;return{x:r+this.getOrientVal([u,o/2]),y:i+this.getOrientVal([A/2,u])}},e.prototype.inferTextStyle=function(t){return"horizontal"===this.attributes.orientation?{}:"start"===t?{transformOrigin:"left center",transform:"rotate(90)",textAlign:"start"}:"end"===t?{transformOrigin:"right center",transform:"rotate(90)",textAlign:"end"}:{}},e.prototype.calcHandleText=function(t){var e,n=this.attributes,r=n.type,i=n.orientation,o=n.formatter,A=n.autoFitLabel,s=PW(this.attributes,"handle"),a=PW(s,"label"),c=s.spacing,l=this.getHandleSize(),u=this.clampValues(),h=o("start"===t?u[0]:u[1]),d=new XV({style:Le(Le(Le({},a),this.inferTextStyle(t)),{text:h})}),f=d.getBBox(),g=f.width,p=f.height;if(d.destroy(),!A){if("value"===r)return{text:h,x:0,y:-p-c};var v=c+l+("horizontal"===i?g/2:0);return(e={text:h})["horizontal"===i?"x":"y"]="start"===t?-v:v,e}var m=0,y=0,w=this.availableSpace,b=w.width,B=w.height,E=this.calcSelectionArea()[1],x=E.x,C=E.y,M=E.width,F=E.height,k=c+l;if("horizontal"===i){var S=k+g/2;if("start"===t)m=x-k-g>0?-S:S;else m=b-x-M-k>g?S:-S}else{var Q=p+k;y="start"===t?C-l>p?-Q:k:B-(C+F)-l>p?Q:-k}return{x:m,y:y,text:h}},e.prototype.getHandleLabelStyle=function(t){var e=PW(this.attributes,"handleLabel");return Le(Le(Le({},e),this.calcHandleText(t)),this.inferTextStyle(t))},e.prototype.getHandleIconStyle=function(){var t=this.attributes.handleIconShape,e=PW(this.attributes,"handleIcon"),n=this.getOrientVal(["ew-resize","ns-resize"]),r=this.getHandleSize();return Le({cursor:n,shape:t,size:r},e)},e.prototype.getHandleStyle=function(t){var e=this.attributes,n=e.x,r=e.y,i=e.showLabel,o=e.showLabelOnInteraction,A=e.orientation,s=this.calcHandlePosition(t),a=s.x,c=s.y,l=this.calcHandleText(t),u=i;return!i&&o&&(u=!!this.target),Le(Le(Le({},DW(this.getHandleIconStyle(),"icon")),DW(Le(Le({},this.getHandleLabelStyle(t)),l),"label")),{transform:"translate(".concat(a+n,", ").concat(c+r,")"),orientation:A,showLabel:u,type:t,zIndex:3})},e.prototype.getHandleSize=function(){var t=this.attributes,e=t.handleIconSize,n=t.width,r=t.height;return e||Math.floor((this.getOrientVal([+r,+n])+4)/2.4)},e.prototype.getOrientVal=function(t){var e=He(t,2),n=e[0],r=e[1];return"horizontal"===this.attributes.orientation?n:r},e.prototype.setValuesOffset=function(t,e){void 0===e&&(e=0);var n=this.attributes.type,r=He(this.getValues(),2),i=[r[0]+("range"===n?t:0),r[1]+e].sort();this.innerSetValues(i,!0)},e.prototype.getRatio=function(t){var e=this.availableSpace,n=e.width,r=e.height;return t/this.getOrientVal([n,r])},e.prototype.dispatchCustomEvent=function(t,e,n){var r=this;t.on(e,function(t){t.stopPropagation(),r.dispatchEvent(new Vs(n,{detail:t}))})},e.prototype.bindEvents=function(){this.addEventListener("wheel",this.onScroll);var t=this.brushArea;this.dispatchCustomEvent(t,"click","trackClick"),this.dispatchCustomEvent(t,"pointerenter","trackMouseenter"),this.dispatchCustomEvent(t,"pointerleave","trackMouseleave"),t.on("pointerdown",this.onDragStart("track"))},e.prototype.onScroll=function(t){if(this.attributes.scrollable){var e=t.deltaX,n=t.deltaY||e,r=this.getRatio(n);this.setValuesOffset(r,r)}},e.tag="slider",e}(zW),gX="grid-group",pX="main-group",vX="line-group",mX="tick-group",yX="label-group",wX="title-group",bX="grid",BX="line",EX="line-first",xX="line-second",CX="tick",MX="tick-item",FX="label",kX="label-item",SX="title",QX={data:[],animate:{enter:!1,update:{duration:100,easing:"ease-in-out-sine",fill:"both"},exit:{duration:100,fill:"both"}},showArrow:!0,showGrid:!0,showLabel:!0,showLine:!0,showTick:!0,showTitle:!0,showTrunc:!1,dataThreshold:100,lineLineWidth:1,lineStroke:"black",crossPadding:10,titleFill:"black",titleFontSize:12,titlePosition:"lb",titleSpacing:0,titleTextAlign:"center",titleTextBaseline:"middle",lineArrow:function(){return new nc({style:{d:[["M",10,10],["L",-10,0],["L",10,-10],["L",0,0],["L",10,10],["Z"]],fill:"black",transformOrigin:"center"}})},labelAlign:"parallel",labelDirection:"positive",labelFontSize:12,labelSpacing:0,gridConnect:"line",gridControlAngles:[],gridDirection:"positive",gridLength:0,gridType:"segment",lineArrowOffset:15,lineArrowSize:10,tickDirection:"positive",tickLength:5,tickLineWidth:1,tickStroke:"black",labelOverlap:[]};be({},QX,{style:{type:"arc"}}),be({},QX,{style:{}});var UX=eW({mainGroup:pX,gridGroup:gX,grid:bX,lineGroup:vX,line:BX,tickGroup:mX,tick:CX,tickItem:MX,labelGroup:yX,label:FX,labelItem:kX,titleGroup:wX,title:SX,lineFirst:EX,lineSecond:xX},"axis"),NX=eW({lineGroup:"line-group",line:"line",regionGroup:"region-group",region:"region"},"grid");function TX(t){return t.reduce(function(t,e,n){return t.push(_e([0===n?"M":"L"],He(e),!1)),t},[])}function OX(t,e,n){return"surround"===e.type?function(t,e,n){var r=e.connect,i=void 0===r?"line":r,o=e.center;if("line"===i)return TX(t);if(!o)return[];var A=wW(t[0],o),s=n?0:1;return t.reduce(function(t,e,n){return 0===n?t.push(_e(["M"],He(e),!1)):t.push(_e(["A",A,A,0,0,s],He(e),!1)),t},[])}(t,e,n):TX(t)}function IX(t,e,n){var r=n.type,i=n.connect,o=n.center,A=n.closed?[["Z"]]:[],s=He([OX(t,n),OX(e.slice().reverse(),n,!0)],2),a=s[0],c=s[1],l=He([t[0],e.slice(-1)[0]],2),u=l[0],h=l[1],d=function(t,e){return[a,t,c,e,A].flat()};if("line"===i||"surround"===r)return d([_e(["L"],He(h),!1)],[_e(["L"],He(u),!1)]);if(!o)throw new Error("Arc grid need to specified center");var f=He([wW(h,o),wW(u,o)],2),g=f[0],p=f[1];return d([_e(["A",g,g,0,0,1],He(h),!1),_e(["L"],He(h),!1)],[_e(["A",p,p,0,0,0],He(u),!1),_e(["L"],He(u),!1)])}var LX=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.render=function(t,e){t.type,t.center,t.areaFill,t.closed;var n=Pe(t,["type","center","areaFill","closed"]),r=function(t){var e=t.data,n=void 0===e?[]:e;return t.closed?n.map(function(t){var e=t.points,n=He(e,1)[0];return Le(Le({},t),{points:_e(_e([],He(e),!1),[n],!1)})}):n}(t),i=QW(e).maybeAppendByClassName(NX.lineGroup,"g"),o=QW(e).maybeAppendByClassName(NX.regionGroup,"g"),A=function(t,e,n,r){var i=n.animate,o=n.isBillboard,A=e.map(function(t,e){return{id:t.id||"grid-line-".concat(e),d:OX(t.points,n)}});return t.selectAll(NX.line.class).data(A,function(t){return t.id}).join(function(t){return t.append("path").each(function(t,e){var n=JV(FW(Le({d:t.d},r)),[t,e,A]);this.attr(Le({class:NX.line.name,stroke:"#D9D9D9",lineWidth:1,lineDash:[4,4],isBillboard:o},n))})},function(t){return t.transition(function(t,e){return oX(this,JV(FW(Le({d:t.d},r)),[t,e,A]),i.update)})},function(t){return t.transition(function(){var t=this,e=AX(this,i.exit);return nX(e,function(){return t.remove()}),e})}).transitions()}(i,r,t,n),s=function(t,e,n){var r=n.animate,i=n.connect,o=n.areaFill;if(e.length<2||!o||!i)return[];for(var A=Array.isArray(o)?o:[o,"transparent"],s=function(t){return A[t%A.length]},a=[],c=0;c<e.length-1;c++){var l=He([e[c].points,e[c+1].points],2),u=IX(l[0],l[1],n);a.push({d:u,fill:s(c)})}return t.selectAll(NX.region.class).data(a,function(t,e){return e}).join(function(t){return t.append("path").each(function(t,e){var n=JV(t,[t,e,a]);this.attr(n)}).attr("className",NX.region.name)},function(t){return t.transition(function(t,e){return oX(this,JV(t,[t,e,a]),r.update)})},function(t){return t.transition(function(){var t=this,e=AX(this,r.exit);return nX(e,function(){return t.remove()}),e})}).transitions()}(o,r,t);return _e(_e([],He(A),!1),He(s),!1)},e}(zW);function PX(t,e){return Object.fromEntries(Object.entries(t).map(function(t){var n=He(t,2);return[n[0],JV(n[1],e)]}))}function DX(t,e){return e&&Gt(e)?t.filter(e):t}function RX(t,e){var n=e.startAngle;return(e.endAngle-n)*t+n}function HX(t,e){if("linear"===e.type){var n=He(e.startPos,2),r=n[0],i=n[1],o=He(e.endPos,2),A=He([o[0]-r,o[1]-i],2);return bW([A[0],A[1]])}var s=qV(RX(t,e));return[-Math.sin(s),Math.cos(s)]}function _X(t,e,n){return function(t,e){return e?[t[1],-t[0]]:[-t[1],t[0]]}(HX(t,n),"positive"!==e)}function GX(t,e){return _X(t,e.labelDirection,e)}function KX(t,e,n){return n?"".concat(t," ").concat(n,"axis-").concat(e):t}function jX(t,e,n,r){return r&&t.attr("className",KX(e.name,n,r)),t}function zX(t,e){return"linear"===e.type?function(t,e){var n=He(e.startPos,2),r=n[0],i=n[1],o=He(e.endPos,2),A=He([o[0]-r,o[1]-i],2);return[r+A[0]*t,i+A[1]*t]}(t,e):function(t,e){var n=e.radius,r=He(e.center,2),i=r[0],o=r[1],A=qV(RX(t,e));return[i+n*Math.cos(A),o+n*Math.sin(A)]}(t,e)}function VX(t){return 0===HX(0,t)[1]}function WX(t){return 0===HX(0,t)[0]}function YX(t,e){return e-t===360}function XX(t,e,n,r,i){var o=e-t,A=He([i,i],2),s=A[0],a=A[1],c=He([qV(t),qV(e)],2),l=c[0],u=c[1],h=function(t){return[n+i*Math.cos(t),r+i*Math.sin(t)]},d=He(h(l),2),f=d[0],g=d[1],p=He(h(u),2),v=p[0],m=p[1];if(YX(t,e)){var y=He(h((u+l)/2),2);return[["M",f,g],["A",s,a,0,1,0,y[0],y[1]],["A",s,a,0,1,0,v,m]]}var w=o>180?1:0,b=t>e?0:1;return"M".concat(f,",").concat(g,",A").concat(s,",").concat(a,",0,").concat(w,",").concat(b,",").concat(v,",").concat(m)}function qX(t,e,n,r){var i=e.startAngle,o=e.endAngle,A=e.center,s=e.radius,a=e.classNamePrefix;return t.selectAll(UX.line.class).data([{d:XX.apply(void 0,_e(_e([i,o],He(A),!1),[s],!1))}],function(t,e){return e}).join(function(t){var n=t.append("path").attr("className",UX.line.name).styles(e).styles({d:function(t){return t.d}});return jX(n,UX.line,BX,a),n},function(t){return t.transition(function(){var t=this,e=function(t,e,n,r){if(!r)return t.attr("__keyframe_data__",n),null;var i=r.duration,o=void 0===i?0:i,A=fW(e,n),s=Math.ceil(+o/16),a=new Array(s).fill(0).map(function(t,e,n){return{__keyframe_data__:A(e/(n.length-1))}});return t.animate(a,Le({fill:"both"},r))}(this,function(t){var e=t.attributes,n=e.startAngle,r=e.endAngle,i=e.center,o=e.radius;return _e(_e([n,r],He(i),!1),[o],!1)}(this),_e(_e([i,o],He(A),!1),[s],!1),r.update);if(e){var n=function(){var e=Ce(t.attributes,"__keyframe_data__");t.style.d=XX.apply(void 0,_e([],He(e),!1))};e.onframe=n,e.onfinish=n}return e}).styles(e)},function(t){return t.remove()}).styles(n).transitions()}function $X(t){var e=He(t,2),n=He(e[0],2),r=n[0],i=n[1],o=He(e[1],2);return{x1:r,y1:i,x2:o[0],y2:o[1]}}function ZX(t,e,n,r){var i=e.showTrunc,o=e.startPos,A=e.endPos,s=e.truncRange,a=e.lineExtension,c=e.classNamePrefix,l=He([o,A],2),u=He(l[0],2),h=u[0],d=u[1],f=He(l[1],2),g=f[0],p=f[1],v=He(a?function(t,e,n){void 0===n&&(n=[0,0]);var r=He([t,e,n],3),i=He(r[0],2),o=i[0],A=i[1],s=He(r[1],2),a=s[0],c=s[1],l=He(r[2],2),u=l[0],h=l[1],d=He([a-o,c-A],2),f=d[0],g=d[1],p=Math.sqrt(Math.pow(f,2)+Math.pow(g,2)),v=He([-u/p,h/p],2),m=v[0],y=v[1];return[m*f,m*g,y*f,y*g]}(o,A,a):new Array(4).fill(0),4),m=v[0],y=v[1],w=v[2],b=v[3],B=function(e){return t.selectAll(UX.line.class).data(e,function(t,e){return e}).join(function(t){var e=t.append("line").styles(n).transition(function(t){return oX(this,$X(t.line),!1)});return e.attr("className",function(t){if(!c)return"".concat(UX.line.name," ").concat(t.className);var e=KX(UX.line.name,BX,c);if(t.className===UX.lineFirst.name){var n=KX(UX.lineFirst.name,EX,c);return"".concat(e," ").concat(n)}if(t.className===UX.lineSecond.name){n=KX(UX.lineSecond.name,xX,c);return"".concat(e," ").concat(n)}return e}),e},function(t){return t.styles(n).transition(function(t){return oX(this,$X(t.line),r.update)})},function(t){return t.remove()}).transitions()};if(!i||!s)return B([{line:[[h+m,d+y],[g+w,p+b]],className:UX.line.name}]);var E=He(s,2),x=E[0],C=E[1],M=g-h,F=p-d,k=He([h+M*x,d+F*x],2),S=k[0],Q=k[1],U=He([h+M*C,d+F*C],2),N=U[0],T=U[1],O=B([{line:[[h+m,d+y],[S,Q]],className:UX.lineFirst.name},{line:[[N,T],[g+w,p+b]],className:UX.lineSecond.name}]);return function(t,e){e.truncRange,e.truncShape,e.lineExtension}(0,e),O}function JX(t,e,n){var r,i=e.type,o=PW(e,"line");return r="linear"===i?ZX(t,e,EW(o,"arrow"),n):qX(t,e,EW(o,"arrow"),n),function(t,e,n,r){var i,o=n.showArrow,A=n.showTrunc,s=n.lineArrow,a=n.lineArrowOffset,c=n.lineArrowSize;if(i="arc"===e?t.select(UX.line.class):A?t.select(UX.lineSecond.class):t.select(UX.line.class),!o||!s||"arc"===n.type&&YX(n.startAngle,n.endAngle)){var l=i.node();l&&(l.style.markerEnd=void 0)}else{var u=uW(s);u.attr(r),kW(u,c),i.style("markerEnd",u).style("markerEndOffset",-a)}}(t,i,e,o),r}function tq(t){var e=t.type,n=t.gridCenter;return"linear"===e?n:n||t.center}function eq(t,e){var n=e.gridLength;return t.map(function(t,r){var i=t.value,o=He(zX(i,e),2),A=o[0],s=o[1],a=He(gW(function(t,e){return _X(t,e.gridDirection,e)}(i,e),n),2);return{id:r,points:[[A,s],[A+a[0],s+a[1]]]}})}function nq(t,e,n,r){var i=n.classNamePrefix,o=PW(n,"grid"),A=o.type,s=o.areaFill,a=tq(n),c=DX(e,n.gridFilter),l="segment"===A?eq(c,n):function(t,e){var n=e.gridControlAngles,r=tq(e);if(!r)throw new Error("grid center is not provide");if(t.length<2)throw new Error("Invalid grid data");if(!n||0===n.length)throw new Error("Invalid gridControlAngles");var i=He(r,2),o=i[0],A=i[1];return t.map(function(t,r){var i=He(zX(t.value,e),2),s=i[0],a=i[1],c=He([s-o,a-A],2),l=c[0],u=c[1],h=[];return n.forEach(function(t){var e=qV(t),n=He([Math.cos(e),Math.sin(e)],2),r=n[0],i=n[1],s=l*r-u*i+o,a=l*i+u*r+A;h.push([s,a])}),{points:h,id:r}})}(c,n),u=Le(Le({},o),{center:a,areaFill:Gt(s)?c.map(function(t,e){return JV(s,[t,e,c])}):s,animate:r,data:l});return t.selectAll(UX.grid.class).data([1]).join(function(t){var e=t.append(function(){return new LX({style:u})}).attr("className",UX.grid.name);return jX(e,UX.grid,bX,i),e},function(t){return t.transition(function(){return this.update(u)})},function(t){return t.remove()}).transitions()}var rq=function(){function t(t,e,n,r){this.set(t,e,n,r)}return Object.defineProperty(t.prototype,"left",{get:function(){return this.x1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this.y1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this.x2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return this.y2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this.defined("x2")&&this.defined("x1")?this.x2-this.x1:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.defined("y2")&&this.defined("y1")?this.y2-this.y1:void 0},enumerable:!1,configurable:!0}),t.prototype.rotatedPoints=function(t,e,n){var r=this,i=r.x1,o=r.y1,A=r.x2,s=r.y2,a=Math.cos(t),c=Math.sin(t),l=e-e*a+n*c,u=n-e*c-n*a;return[[a*i-c*s+l,c*i+a*s+u],[a*A-c*s+l,c*A+a*s+u],[a*i-c*o+l,c*i+a*o+u],[a*A-c*o+l,c*A+a*o+u]]},t.prototype.set=function(t,e,n,r){return 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 iq(t,e){var n=t.getEulerAngles()||0;t.setEulerAngles(0);var r=t.getBounds(),i=He(r.min,2),o=i[0],A=i[1],s=He(r.max,2),a=s[0],c=s[1],l=t.getBBox(),u=l.width,h=l.height,d=0,f=0,g=o,p=A,v=sW(t);if(v){h-=1.5;var m=v.style.textAlign,y=v.style.textBaseline;"center"===m?g=(o+a)/2:"right"!==m&&"end"!==m||(g=a),"middle"===y?p=(A+c)/2:"bottom"===y&&(p=c)}var w=He(UW(e),4),b=w[0],B=void 0===b?0:b,E=w[1],x=void 0===E?0:E,C=w[2],M=void 0===C?B:C,F=w[3],k=new rq((d+=o)-(void 0===F?x:F),(f+=A)-B,d+u+x,f+h+M);return t.setEulerAngles(n),k.rotatedPoints(qV(n),g,p)}function oq(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 Aq(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 sq(t,e){var n=Aq(t[0],t[1],e[0]),r=Aq(t[0],t[1],e[1]),i=Aq(e[0],e[1],t[0]),o=Aq(e[0],e[1],t[1]);return n!==r&&i!==o||(!(0!==n||!oq(t,e[0]))||(!(0!==r||!oq(t,e[1]))||(!(0!==i||!oq(e,t[0]))||!(0!==o||!oq(e,t[1])))))}function aq(t,e){return e.every(function(e){return function(t,e){var n=t.length;if(n<3)return!1;var r=[e,[9999,e[1]]],i=0,o=0;do{var A=[t[o],t[(o+1)%n]];if(sq(A,r)){if(0===Aq(A[0],e,A[1]))return oq(A,e);i++}o=(o+1)%n}while(0!==o);return!!(1&i)}(t,e)})}function cq(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=He(t,4),r=n[0],i=n[1],o=n[2],A=n[3],s=He(e,4),a=s[0],c=s[1],l=o-r,u=A-i,h=s[2]-a,d=s[3]-c,f=l*d-h*u;if(0===f)return!1;var g=f>0,p=r-a,v=i-c,m=l*v-u*p;if(m<0===g)return!1;var y=h*v-d*p;return y<0!==g&&m>f!==g&&y>f!==g}(e,t)})}function lq(t,e,n){var r,i,o=e.crossPadding,A=new Set,s=null,a=function(t,e){var n=t.type,r=t.labelDirection,i=t.crossSize;if(!i)return!1;if("arc"===n){var o=t.center,A=t.radius,s=He(o,2),a=s[0],c=s[1],l="negative"===r?0:i,u=-A-l,h=A+l,d=He(UW(e),4),f=d[0],g=d[1],p=d[2],v=d[3];return new rq(a+u-v,c+u-f,a+h+g,c+h+p)}var m=He(t.startPos,2),y=m[0],w=m[1],b=He(t.endPos,2),B=b[0],E=b[1],x=He(WX(t)?[-e,0,e,0]:[0,e,0,-e],4),C=x[0],M=x[1],F=x[2],k=x[3],S=gW(GX(0,t),i),Q=new rq(y,w,B,E);return Q.x1+=k,Q.y1+=C,Q.x2+=M+S[0],Q.y2+=F+S[1],Q}(e,o),c=function(t){return!a||function(t,e,n){var r=t.x1,i=t.x2,o=t.y1,A=t.y2;return aq([[r,o],[i,o],[i,A],[r,A]],iq(e,n))}(a,t)},l=function(t,e){return!t||!t.firstChild||!function(t,e,n){var r,i,o=iq(t,n).flat(1),A=iq(e,n).flat(1),s=[[o[0],o[1],o[2],o[3]],[o[0],o[1],o[4],o[5]],[o[4],o[5],o[6],o[7]],[o[2],o[3],o[6],o[7]]];try{for(var a=Re(s),c=a.next();!c.done;c=a.next())if(cq(A,c.value))return!0}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return!1}(t.firstChild,e.firstChild,UW(n))};try{for(var u=Re(t),h=u.next();!h.done;h=u.next()){var d=h.value;c(d)?!s||l(s,d)?s=d:(A.add(s),A.add(d)):A.add(d)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}return Array.from(A)}function uq(t,e){return void 0===e&&(e={}),Kt(t)?0:"number"==typeof t?t:Math.floor(oW(t,e))}var hq=function(t,e){var n=e.seq,r=void 0===n?2:n;return t.filter(function(t,e){return!(e%r)||(zV(t),!1)})},dq=function(t){return t.filter(iW)};var fq=new Map([["hide",function(t,e,n,r){var i=t.length,o=e.keepHeader,A=e.keepTail;if(!(i<=1||2===i&&o&&A)){var s,a,c=hq,l=function(t){return t.forEach(r.show),t},u=2,h=t.slice(),d=t.slice(),f=Math.min.apply(Math,_e([1],He(t.map(function(t){return t.getBBox().width})),!1));if("linear"===n.type&&(VX(n)||WX(n))){var g=NW(t[0]).left,p=NW(t[i-1]).right,v=Math.abs(p-g)||1;u=Math.max(Math.floor(i*f/v),u)}for(o&&(s=h.splice(0,1)[0]),A&&(a=h.splice(-1,1)[0],h.reverse()),l(h);u<t.length&&lq(dq(a?_e(_e([a],He(d),!1),[s],!1):_e([s],He(d),!1)),n,null==e?void 0:e.margin).length;){if(a&&!s&&u%2==0)h.splice(0,1).forEach(r.hide);else if(a&&s){h.splice(0,1).forEach(r.hide)}d=c(l(h),{seq:u}),u++}}}],["rotate",function(t,e,n,r){var i,o,A=e.optionalAngles,s=void 0===A?[0,45,90]:A,a=e.margin,c=e.recoverWhenFailed,l=void 0===c||c,u=t.map(function(t){return t.getLocalEulerAngles()}),h=function(){return lq(t,n,a).length<1},d=function(e){return t.forEach(function(t,n){var i=Array.isArray(e)?e[n]:e;r.rotate(t,+i)})};try{for(var f=Re(s),g=f.next();!g.done;g=f.next()){if(d(g.value),h())return}}catch(t){i={error:t}}finally{try{g&&!g.done&&(o=f.return)&&o.call(f)}finally{if(i)throw i.error}}l&&d(u)}],["ellipsis",function(t,e,n,r){if(!(t.length<=0)){var i=e.suffix,o=void 0===i?"...":i,A=e.minLength,s=e.maxLength,a=void 0===s?1/0:s,c=e.step,l=void 0===c?" ":c,u=e.margin,h=void 0===u?[0,0,0,0]:u,d=AW(r.getTextShape(t[0])),f=uq(l,d),g=A?uq(A,d):f,p=uq(a,d);(Kt(p)||p===1/0)&&(p=Math.max.apply(null,t.map(function(t){return t.getBBox().width})));var v=t.slice(),m=He(h,4);m[0],m[1],m[2],m[3];for(var y=function(e){if(v.forEach(function(t){r.ellipsis(r.getTextShape(t),e,o)}),(v=lq(t,n,h)).length<1)return{value:void 0}},w=p;w>g+f;w-=f){var b=y(w);if("object"==typeof b)return b.value}}}],["wrap",function(t,e,n,r,i){var o,A=e.maxLines,s=void 0===A?3:A,a=e.recoverWhenFailed,c=void 0===a||a,l=e.margin,u=void 0===l?[0,0,0,0]:l,h=JV(null!==(o=e.wordWrapWidth)&&void 0!==o?o:50,[i]),d=t.map(function(t){return t.attr("maxLines")||1}),f=Math.min.apply(Math,_e([],He(d),!1)),g=function(){return lq(t,n,u).length<1},p=function(t){var e=t.type,n=t.labelDirection;return"linear"===e&&VX(t)?"negative"===n?"bottom":"top":"middle"}(n),v=function(e){return t.forEach(function(t,n){var i=Array.isArray(e)?e[n]:e;r.wrap(t,h,i,p)})};if(!(f>s)){if("linear"===n.type&&VX(n)){if(v(s),g())return}else for(var m=f;m<=s;m++)if(v(m),g())return;c&&v(d)}}]]);function gq(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce(function(t,e){return t*function(t){return"positive"===t?-1:1}(e)},1)}function pq(t){for(var e=t;e<0;)e+=360;return Math.round(e%360)}function vq(t,e){var n=He(t,2),r=n[0],i=n[1],o=He(e,2),A=o[0],s=o[1],a=He([r*A+i*s,r*s-i*A],2),c=a[0],l=a[1];return Math.atan2(l,c)}function mq(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=GX(t.value,n),A=HX(t.value,n);return"horizontal"===i?0:function(t){var e=(t+360)%180;return dW(e,-90,90)||(e+=180),e}($V("perpendicular"===i?vq([1,0],o):vq([A[0]<0?-1:1,0],A)))}function yq(t,e,n){var r=n.type,i=n.labelAlign,o=GX(t,n),A=pq(e),s=pq($V(vq([1,0],o))),a="center",c="middle";return"linear"===r?[90,270].includes(s)&&0===A?(a="center",c=1===o[1]?"top":"bottom"):s%180||![90,270].includes(A)?0===s?(dW(A,0,90,!1,!0)||dW(A,0,90)||dW(A,270,360))&&(a="start"):90===s?dW(A,0,90,!1,!0)?a="start":(dW(A,90,180)||dW(A,270,360))&&(a="end"):270===s?dW(A,0,90,!1,!0)?a="end":(dW(A,90,180)||dW(A,270,360))&&(a="start"):180===s&&(90===A?a="start":(dW(A,0,90)||dW(A,270,360))&&(a="end")):a="center":"parallel"===i?c=dW(s,0,180,!0)?"top":"bottom":"horizontal"===i?dW(s,90,270,!1)?a="end":(dW(s,270,360,!1)||dW(s,0,90))&&(a="start"):"perpendicular"===i&&(a=dW(s,90,270)?"end":"start"),{textAlign:a,textBaseline:c}}function wq(t,e,n){var r=n.showTick,i=n.tickLength,o=n.tickDirection,A=n.labelDirection,s=n.labelSpacing,a=e.indexOf(t),c=JV(s,[t,a,e]),l=He([GX(t.value,n),gq(A,o)],2),u=He(pW(gW(l[0],c+(1===l[1]?JV(r?i:0,[t,a,e]):0)),zX(t.value,n)),2);return{x:u[0],y:u[1]}}function bq(t,e,n,r){var i=r.labelRender,o=(Ce(r,"endPos.0",400)-Ce(r,"startPos.0",0))/n.length,A=Gt(i)?JV(i,[t,e,n,GX(t.value,r)]):t.label||"",s=function(t){var e=(new DOMParser).parseFromString(t,"text/html").body.firstElementChild;if(console.log(null==e?void 0:e.getClientRects(),11),!e)return 0;var n=e.getAttribute("style")||"",r=Object.fromEntries(n.split(";").map(function(t){return t.trim()}).filter(function(t){return t.includes(":")}).map(function(t){var e=He(t.split(":").map(function(t){return t.trim()}),2),n=e[0],r=e[1];return[n.toLowerCase(),r]})),i=function(t){if(!t)return 0;var e=t.match(/([\d.]+)px/);return e?parseFloat(e[1]):0};if(r.height)return i(r.height);var o,A=i(r["font-size"])||16,s=r["line-height"];o=s&&"normal"!==s?s.endsWith("px")?i(s):/^[\d.]+$/.test(s)?parseFloat(s)*A:A:1.2*A;var a=i(r["padding-top"]),c=i(r["padding-bottom"]);r.padding&&(1===(l=r.padding.split(/\s+/).map(i)).length||2===l.length?(a=l[0],c=l[0]):(3===l.length||4===l.length)&&(a=l[0],c=l[2]));var l,u=i(r["border-top-width"]),h=i(r["border-bottom-width"]);if(r.border){var d=r.border.match(/([\d.]+)px/);d&&(u=parseFloat(d[1]),h=parseFloat(d[1]))}return r["border-width"]&&(1===(l=r["border-width"].split(/\s+/).map(i)).length||2===l.length?(u=l[0],h=l[0]):(3===l.length||4===l.length)&&(u=l[0],h=l[2])),o+a+c+u+h}(A)||30;return function(){return e={width:o,height:s},"function"==typeof(t=A)?t():Jt(t)||re(t)?new $a({style:Le(Le({pointerEvents:"auto"},e),{innerHTML:t})}):t;var t,e}}var Bq={html:["fill"],text:[]};function Eq(t,e){["text","html"].includes(t.nodeName)&&t.attr(EW(e,Bq[t.nodeName]))}function xq(t,e){!function(t,e,n,r){var i=e.labelOverlap,o=void 0===i?[]:i;o.length&&o.forEach(function(i){var o=i.type,A=fq.get(o);(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,o)&&(null==A||A(t,i,e,r,n))})}(this.node().childNodes,t,e,{hide:zV,show:jV,rotate:function(e,n){!function(t,e,n){e.setLocalEulerAngles(t);var r=yq(e.__data__.value,t,n),i=e.querySelector(UX.labelItem.class);i&&Eq(i,r)}(+n,e,t)},ellipsis:function(t,e,n){t&&cW(t,e||1/0,n)},wrap:function(t,e,n){var r,i;t&&(void 0===(r=n)&&(r=2),void 0===i&&(i="top"),aW(t,{wordWrap:!0,wordWrapWidth:e,maxLines:r,textBaseline:i}))},getTextShape:function(t){return t.querySelector(UX.labelItem.class)}})}function Cq(t,e,n,r,i){var o=n.indexOf(e),A=i.labelRender,s=i.classNamePrefix,a=QW(t).append(A?bq(e,o,n,i):function(t,e,n,r){var i=r.labelFormatter;return Gt(i)?function(){return uW(JV(i,[t,e,n,GX(t.value,r)]))}:function(){return uW(t.label||"")}}(e,o,n,i)).attr("className",UX.labelItem.name).node();jX(QW(a),UX.labelItem,kX,s);var c=He(RW(PX(r,[e,o,n])),2),l=c[0],u=c[1],h=u.transform,d=Pe(u,["transform"]);_W(a,h);var f=mq(e,a,i);if(a.getLocalEulerAngles()||a.setLocalEulerAngles(f),Eq(a,Le(Le({},yq(e.value,f,i)),l)),"html"===a.nodeName){var g=a.getBBox(),p=a.style.x||0;a.attr("x",p-g.width/2)}return t.attr(d),a}function Mq(t,e,n,r,i){var o,A,s,a=n.classNamePrefix,c=DX(e,n.labelFilter),l=PW(n,"label"),u=t.selectAll(UX.label.class).data(c,function(t,e){return e}).join(function(t){var r=t.append("g").attr("className",UX.label.name).transition(function(t){Cq(this,t,e,l,n);var r=wq(t,e,n),i=r.x,o=r.y;return this.style.transform="translate(".concat(i,", ").concat(o,")"),null});return jX(r,UX.label,FX,a),r},function(t){return t.transition(function(t){var i=function(t,e,n,r){if(void 0===r&&(r="destroy"),function(t,e){return"text"===t.nodeName&&"text"===e.nodeName&&t.attributes.text===e.attributes.text}(t,e))return t.remove(),[null];var i=function(){"destroy"===r?t.destroy():"hide"===r&&zV(t),e.isVisible()&&jV(e)};if(!n)return i(),[null];var o=n.duration,A=void 0===o?0:o,s=n.delay,a=void 0===s?0:s,c=Math.ceil(+A/2),l=+A/4,u=He(t.getGeometryBounds().center,2),h=u[0],d=u[1],f=He(e.getGeometryBounds().center,2),g=He([(h+f[0])/2-h,(d+f[1])/2-d],2),p=g[0],v=g[1],m=t.style.opacity,y=void 0===m?1:m,w=e.style.opacity,b=void 0===w?1:w,B=t.style.transform||"",E=e.style.transform||"",x=t.animate([{opacity:y,transform:"translate(0, 0) ".concat(B)},{opacity:0,transform:"translate(".concat(p,", ").concat(v,") ").concat(B)}],Le(Le({fill:"both"},n),{duration:a+c+l})),C=e.animate([{opacity:0,transform:"translate(".concat(-p,", ").concat(-v,") ").concat(E),offset:.01},{opacity:b,transform:"translate(0, 0) ".concat(E)}],Le(Le({fill:"both"},n),{duration:c+l,delay:a+c-l}));return nX(C,i),[x,C]}(this.querySelector(UX.labelItem.class),Cq(this,t,e,l,n),r.update),o=wq(t,e,n),A=o.x,s=o.y,a=oX(this,{transform:"translate(".concat(A,", ").concat(s,")")},r.update);return _e(_e([],He(i),!1),[a],!1)})},function(t){return o=t,t.transition(function(){var t=this,e=AX(this.childNodes[0],r.exit);return nX(e,function(){return QW(t).remove()}),e}),o}).transitions();return s=function(){xq.call(t,n,i)},0===(A=u).length?s():Promise.all(A.map(function(t){return null==t?void 0:t.finished})).then(s),u}function Fq(t,e){return _X(t,e.tickDirection,e)}function kq(t,e,n,r,i){var o=He(function(t,e){var n=He(t,2);return[[0,0],[n[0]*e,n[1]*e]]}(r,JV(i.tickLength,[t,e,n])),2),A=He(o[0],2),s=A[0],a=A[1],c=He(o[1],2);return{x1:s,x2:c[0],y1:a,y2:c[1]}}function Sq(t,e,n,r,i,o){var A=function(t,e,n,r,i){var o=i.tickFormatter,A=i.classNamePrefix,s=Fq(e.value,i),a="line";Gt(o)&&(a=function(){return JV(o,[e,n,r,s])});var c=t.append(a).attr("className",UX.tickItem.name);return jX(c,UX.tickItem,MX,A),c}(QW(this),t,e,n,r);!function(t,e,n,r,i,o,A){var s=Fq(t.value,o),a=kq(t,e,n,s,o),c=a.x1,l=a.x2,u=a.y1,h=a.y2,d=He(RW(PX(A,[t,e,n,s])),2),f=d[0],g=d[1];"line"===r.node().nodeName&&r.styles(Le({x1:c,x2:l,y1:u,y2:h},f)),i.attr(g),r.styles(f)}(t,e,n,A,this,r,i);var s=He(zX(t.value,r),2),a=s[0],c=s[1];return oX(this,{transform:"translate(".concat(a,", ").concat(c,")")},o)}function Qq(t,e,n,r,i){var o=He(RW(PW(r,"title")),2),A=o[0],s=o[1],a=s.transform,c=s.transformOrigin,l=Pe(s,["transform","transformOrigin"]);e.styles(l);var u=a||function(t,e,n){var r=2*t.getGeometryBounds().halfExtents[1];if("vertical"===e){if("left"===n)return"rotate(-90) translate(0, ".concat(r/2,")");if("right"===n)return"rotate(-90) translate(0, -".concat(r/2,")")}return""}(t.node(),A.direction,A.position);t.styles(Le(Le({},A),{transformOrigin:c})),_W(t.node(),u);var h=function(t,e,n){var r=n.titlePosition,i=void 0===r?"lb":r,o=n.titleSpacing,A=KW(i),s=t.node().getLocalBounds(),a=He(s.min,2),c=a[0],l=a[1],u=He(s.halfExtents,2),h=u[0],d=u[1],f=He(e.node().getLocalBounds().halfExtents,2),g=f[0],p=f[1],v=He([c+h,l+d],2),m=v[0],y=v[1],w=He(UW(o),4),b=w[0],B=w[1],E=w[2],x=w[3];if(["start","end"].includes(i)&&"linear"===n.type){var C=n.startPos,M=n.endPos,F=He("start"===i?[C,M]:[M,C],2),k=F[0],S=F[1],Q=He(gW(bW([-S[0]+k[0],-S[1]+k[1]]),b),2),U=Q[0],N=Q[1];return{x:k[0]+U,y:k[1]+N}}return A.includes("t")&&(y-=d+p+b),A.includes("r")&&(m+=h+g+B),A.includes("l")&&(m-=h+g+x),A.includes("b")&&(y+=d+p+E),{x:m,y:y}}(QW(n._offscreen||n.querySelector(UX.mainGroup.class)),e,r),d=h.x,f=h.y;return oX(e.node(),{transform:"translate(".concat(d,", ").concat(f,")")},i)}function Uq(t,e,n,r){var i=t.showLine,o=t.showTick,A=t.showLabel,s=t.classNamePrefix,a=e.maybeAppendByClassName(UX.lineGroup,"g");jX(a,UX.lineGroup,vX,s);var c=hW(i,a,function(e){return JX(e,t,r)})||[],l=e.maybeAppendByClassName(UX.tickGroup,"g");jX(l,UX.tickGroup,mX,s);var u=hW(o,l,function(e){return function(t,e,n,r){var i=n.classNamePrefix,o=DX(e,n.tickFilter),A=PW(n,"tick");return t.selectAll(UX.tick.class).data(o,function(t){return t.id||t.label}).join(function(t){var e=t.append("g").attr("className",UX.tick.name).transition(function(t,e){return Sq.call(this,t,e,o,n,A,!1)});return jX(e,UX.tick,CX,i),e},function(t){return t.transition(function(t,e){return this.removeChildren(),Sq.call(this,t,e,o,n,A,r.update)})},function(t){return t.transition(function(){var t=this,e=AX(this.childNodes[0],r.exit);return nX(e,function(){return t.remove()}),e})}).transitions()}(e,n,t,r)})||[],h=e.maybeAppendByClassName(UX.labelGroup,"g");jX(h,UX.labelGroup,yX,s);var d=hW(A,h,function(i){return Mq(i,n,t,r,e.node())})||[];return _e(_e(_e([],He(c),!1),He(u),!1),He(d),!1).filter(function(t){return!!t})}var Nq=function(t){function e(e){return t.call(this,e,QX)||this}return Ie(e,t),e.prototype.render=function(t,e,n){var r=this,i=t.titleText,o=t.data,A=t.animate,s=t.showTitle,a=t.showGrid,c=t.dataThreshold,l=t.truncRange,u=t.classNamePrefix,h=e.className||"axis";u?e.attr("className","".concat(h," ").concat(u,"axis")):e.className||e.attr("className","axis");var d=function(t,e){if(t.length<=e)return t;for(var n=Math.floor(t.length/e),r=[],i=0;i<t.length;i+=n)r.push(t[i]);return r}(o,c).filter(function(t){var e=t.value;return!(l&&e>l[0]&&e<l[1])}),f=eX(void 0===n?A:n),g=QW(e).maybeAppendByClassName(UX.gridGroup,"g");jX(g,UX.gridGroup,gX,u);var p=hW(a,g,function(e){return nq(e,d,t,f)})||[],v=QW(e).maybeAppendByClassName(UX.mainGroup,"g");jX(v,UX.mainGroup,pX,u),i&&(!this.initialized&&f.enter||this.initialized&&f.update)&&Uq(t,QW(this.offscreenGroup),d,eX(!1));var m=Uq(t,QW(v.node()),d,f),y=QW(e).maybeAppendByClassName(UX.titleGroup,"g");jX(y,UX.titleGroup,wX,u);var w=hW(s,y,function(e){return function(t,e,n,r){var i=n.titleText,o=n.classNamePrefix;return t.selectAll(UX.title.class).data([{title:i}].filter(function(t){return!!t.title}),function(t,e){return t.title}).join(function(A){var s=A.append(function(){return uW(i)}).attr("className",UX.title.name).transition(function(){return Qq(QW(this),t,e,n,r.enter)});return jX(s,UX.title,SX,o),s},function(i){return i.transition(function(){return Qq(QW(this),t,e,n,r.update)})},function(t){return t.remove()}).transitions()}(e,r,t,f)})||[];return _e(_e(_e([],He(p),!1),He(m),!1),He(w),!1).flat().filter(function(t){return!!t})},e}(zW);function Tq(t,e,n){return n?"".concat(t," ").concat(n,"legend-").concat(e):t}function Oq(t,e,n){return void 0===t&&(t="horizontal"),"horizontal"===t?e:n}JW.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"]]}),JW.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]]}),JW.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 Iq="title",Lq="item",Pq="marker",Dq="label",Rq="value",Hq="focus-icon",_q="background",Gq="handle-marker",Kq="handle-label",jq="prev-btn",zq="next-btn",Vq="page-info",Wq=eW({markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label"},"handle"),Yq={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,Yq)||this}Ie(e,t),e.prototype.render=function(t,e){var n=QW(e).maybeAppendByClassName(Wq.markerGroup,"g");this.renderMarker(n);var r=QW(e).maybeAppendByClassName(Wq.labelGroup,"g");this.renderLabel(r)},e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.orientation,i=n.classNamePrefix,o=n.markerSymbol,A=void 0===o?Oq(r,"horizontalHandle","verticalHandle"):o;hW(!!A,t,function(t){var n=PW(e.attributes,"marker"),r=Le({symbol:A},n),o=Tq(Wq.marker.name,Gq,i);if(e.marker=t.maybeAppendByClassName(Wq.marker,function(){return new JW({style:r,className:o})}).update(r),i){var s=e.marker.node().querySelector(".marker");if(s){var a=Tq((s.getAttribute("class")||"").split(" ")[0],Gq,i);s.setAttribute("class",a)}}})},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,a=n.classNamePrefix;hW(r,t,function(t){var n,r=PW(e.attributes,"label"),o=r.text,c=Pe(r,["text"]),l=(null===(n=t.select(Wq.marker.class))||void 0===n?void 0:n.node().getBBox())||{},u=l.width,h=void 0===u?0:u,d=l.height,f=He(Oq(i,[0,(void 0===d?0:d)+A,"center","top"],[h+A,0,"start","middle"]),4),g=f[0],p=f[1],v=f[2],m=f[3],y=Tq(Wq.label.name,Kq,a);t.maybeAppendByClassName(Wq.label,"text").attr("className",y).styles(Le(Le({},c),{x:g,y:p,text:s(o).toString(),textAlign:v,textBaseline:m}))})}}(zW);var Xq={showTitle:!0,padding:0,orientation:"horizontal",backgroundFill:"transparent",titleText:"",titleSpacing:4,titlePosition:"top-left",titleFill:"#2C3542",titleFontWeight:"bold",titleFontFamily:"sans-serif",titleFontSize:12},qq=rW({},Xq,{});rW({},Xq,DW(Yq,"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 $q=eW({title:"title",html:"html",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"),Zq=eW({text:"text"},"title");function Jq(t,e){var n=Object.entries(e).reduce(function(e,n){var r=He(n,2),i=r[0],o=r[1];return t.node().attr(i)||(e[i]=o),e},{});t.styles(n)}var t$,e$=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 Ie(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(Zq.text.class);if(!A)return new ZV(0,0,+e,+n);var s=A.getBBox(),a=s.width,c=s.height,l=He(UW(i),4),u=l[0],h=l[1],d=l[2],f=l[3],g=He([0,0,+e,+n],4),p=g[0],v=g[1],m=g[2],y=g[3],w=KW(r);if(w.includes("i"))return new ZV(p,v,m,y);w.forEach(function(t,r){var i,o,A,s;"t"===t&&(i=He(0===r?[c+d,+n-c-d]:[0,+n],2),v=i[0],y=i[1]),"r"===t&&(o=He([+e-a-f],1),m=o[0]),"b"===t&&(A=He([+n-c-u],1),y=A[0]),"l"===t&&(s=He(0===r?[a+h,+e-a-h]:[0,+e],2),p=s[0],m=s[1])});var b=He(UW(o),4),B=b[0],E=b[1],x=b[2],C=b[3],M=He([C+E,B+x],2),F=M[0],k=M[1];return new ZV(p+C,v+B,m-F,y-k)},e.prototype.getBBox=function(){return this.title?this.title.getBBox():new ZV(0,0,0,0)},e.prototype.render=function(t,e){var n=this;t.width,t.height,t.position,t.spacing;var r=t.classNamePrefix,i=Pe(t,["width","height","position","spacing","classNamePrefix"]),o=He(RW(i),1)[0],A=function(t){var e,n,r,i,o=t,A=o.width,s=o.height,a=o.position,c=He([+A/2,+s/2],2),l=He([+c[0],+c[1],"center","middle"],4),u=l[0],h=l[1],d=l[2],f=l[3],g=KW(a);return g.includes("l")&&(u=(e=He([0,"start"],2))[0],d=e[1]),g.includes("r")&&(u=(n=He([+A,"end"],2))[0],d=n[1]),g.includes("t")&&(h=(r=He([0,"top"],2))[0],f=r[1]),g.includes("b")&&(h=(i=He([+s,"bottom"],2))[0],f=i[1]),{x:u,y:h,textAlign:d,textBaseline:f}}(t),s=A.x,a=A.y,c=A.textAlign,l=A.textBaseline;hW(!!i.text,QW(e),function(t){var e=Tq(Zq.text.name,Iq,r);n.title=t.maybeAppendByClassName(Zq.text,"text").attr("className",e).styles(o).call(Jq,{x:s,y:a,textAlign:c,textBaseline:l}).node()})},e}(zW),n$=eW({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"),r$=function(t){function e(e){var n=t.call(this,e,{x:0,y:0,animate:{easing:"linear",duration:200,fill:"both"},buttonCursor:"pointer",buttonFill:"black",buttonD:$W(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 Xa({class:n$.contentGroup.name})),n.playWindow=n.contentGroup.appendChild(new Xa({class:n$.playWindow.name})),n.innerCurrPage=n.defaultPage,n}return Ie(e,t),Object.defineProperty(e.prototype,"defaultPage",{get:function(){var t=this.attributes.defaultPage;return ne(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=He(function(t){var e;return(null===(e=t[0])||void 0===e?void 0:e.map(function(e,n){return t.map(function(t){return t[n]})}))||[]}(this.pageViews.map(function(t){var e=t.getBBox();return[e.width,e.height]})).map(function(t){return Math.max.apply(Math,_e([],He(t),!1))}),2),e=t[0],n=t[1],r=this.attributes,i=r.pageWidth,o=void 0===i?e:i,A=r.pageHeight;return{pageWidth:o,pageHeight:void 0===A?n:A}},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.playWindow},Object.defineProperty(e.prototype,"totalPages",{get:function(){return this.pageViews.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currPage",{get:function(){return this.innerCurrPage},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e=t.prototype.getBBox.call(this),n=e.x,r=e.y,i=this.controllerShape,o=this.pageShape,A=o.pageWidth,s=o.pageHeight;return new ZV(n,r,A+i.width,s)},e.prototype.goTo=function(t){var e=this,n=this.attributes.animate,r=this,i=r.currPage,o=r.playState,A=r.playWindow,s=r.pageViews;if("idle"!==o||t<0||s.length<=0||t>=s.length)return null;s[i].setLocalPosition(0,0),this.prepareFollowingPage(t);var a=He(this.getFollowingPageDiff(t),2),c=a[0],l=a[1];this.playState="running";var u=iX(A,[{transform:"translate(0, 0)"},{transform:"translate(".concat(-c,", ").concat(-l,")")}],n);return nX(u,function(){e.innerCurrPage=t,e.playState="idle",e.setVisiblePages([t]),e.updatePageInfo()}),u},e.prototype.prev=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n<=0)return null;var r=t?(n-1+e)%e:ne(n-1,0,e);return this.goTo(r)},e.prototype.next=function(){var t=this.attributes.loop,e=this.pageViews.length,n=this.currPage;if(!t&&n>=e-1)return null;var r=t?(n+1)%e:ne(n+1,0,e);return this.goTo(r)},e.prototype.renderClipPath=function(t){var e=this.pageShape,n=e.pageWidth,r=e.pageHeight;n&&r?(this.clipPath=t.maybeAppendByClassName(n$.clipPath,"rect").styles({width:n,height:r}),this.contentGroup.attr("clipPath",this.clipPath.node())):this.contentGroup.style.clipPath=void 0},e.prototype.setVisiblePages=function(t){this.playWindow.children.forEach(function(e,n){t.includes(n)?jV(e):zV(e)})},e.prototype.adjustControllerLayout=function(){var t=this,e=t.prevBtnGroup,n=t.nextBtnGroup,r=t.pageInfoGroup,i=this.attributes,o=i.orientation,A=i.controllerPadding,s=r.getBBox(),a=s.width;s.height;var c=He("horizontal"===o?[-180,0]:[-90,90],2),l=c[0],u=c[1];e.setLocalEulerAngles(l),n.setLocalEulerAngles(u);var h=e.getBBox(),d=h.width,f=h.height,g=n.getBBox(),p=g.width,v=g.height,m=Math.max(d,a,p),y="horizontal"===o?{offset:[[0,0],[d/2+A,0],[d+a+2*A,0]],textAlign:"start"}:{offset:[[m/2,-f-A],[m/2,0],[m/2,v+A]],textAlign:"center"},w=He(y.offset,3),b=He(w[0],2),B=b[0],E=b[1],x=He(w[1],2),C=x[0],M=x[1],F=He(w[2],2),k=F[0],S=F[1],Q=y.textAlign,U=r.querySelector("text");U&&(U.style.textAlign=Q),e.setLocalPosition(B,E),r.setLocalPosition(C,M),n.setLocalPosition(k,S)},e.prototype.updatePageInfo=function(){var t,e=this,n=e.currPage,r=e.pageViews,i=e.attributes.formatter;r.length<2||(null===(t=this.pageInfoGroup.querySelector(n$.pageInfo.class))||void 0===t||t.attr("text",i(n+1,r.length)),this.adjustControllerLayout())},e.prototype.getFollowingPageDiff=function(t){var e=this.currPage;if(e===t)return[0,0];var n=this.attributes.orientation,r=this.pageShape,i=r.pageWidth,o=r.pageHeight,A=t<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=He(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,r=n.controllerSpacing,i=n.classNamePrefix,o=void 0===i?"":i,A=this.pageShape,s=A.pageWidth,a=A.pageHeight,c=this.pageViews.length>=2,l=t.maybeAppendByClassName(n$.controller,"g");if(VV(l.node(),c),c){var u=PW(this.attributes,"button"),h=PW(this.attributes,"pageNum"),d=He(RW(u),2),f=d[0],g=d[1],p=f.size,v=Pe(f,["size"]),m=!l.select(n$.prevBtnGroup.class).node(),y=l.maybeAppendByClassName(n$.prevBtnGroup,"g").styles(g);this.prevBtnGroup=y.node();var w=y.maybeAppendByClassName(n$.prevBtn,"path");if(o){var b=Tq(n$.prevBtn.name,jq,o);w.node().setAttribute("class",b)}var B=l.maybeAppendByClassName(n$.nextBtnGroup,"g").styles(g);this.nextBtnGroup=B.node();var E=B.maybeAppendByClassName(n$.nextBtn,"path");if(o){var x=Tq(n$.nextBtn.name,zq,o);E.node().setAttribute("class",x)}[w,E].forEach(function(t){t.styles(Le(Le({},v),{transformOrigin:"center"})),kW(t.node(),p)});var C=l.maybeAppendByClassName(n$.pageInfoGroup,"g");this.pageInfoGroup=C.node();var M=C.maybeAppendByClassName(n$.pageInfo,"text");if(M.styles(h),o){var F=Tq(n$.pageInfo.name,Vq,o);M.node().setAttribute("class",F)}this.updatePageInfo(),l.node().setLocalPosition(s+r,a/2),m&&(this.prevBtnGroup.addEventListener("click",function(){e.prev()}),this.nextBtnGroup.addEventListener("click",function(){e.next()}))}},e.prototype.render=function(t,e){var n=t.x,r=void 0===n?0:n,i=t.y,o=void 0===i?0:i;this.attr("transform","translate(".concat(r,", ").concat(o,")"));var A=QW(e);this.renderClipPath(A),this.renderController(A),this.setVisiblePages([this.defaultPage]),this.goTo(this.defaultPage)},e.prototype.bindEvents=function(){var t=this,e=pe(function(){return t.render(t.attributes,t)},50);this.playWindow.addEventListener(ea.INSERTED,e),this.playWindow.addEventListener(ea.REMOVED,e)},e}(zW),i$="component-poptip",o$="component-poptip-arrow",A$="component-poptip-text",s$=((t$={})[".".concat(i$)]={visibility:"visible",position:"absolute","background-color":"rgba(0, 0, 0)","box-shadow":"0px 0px 10px #aeaeae","border-radius":"3px",color:"#fff",opacity:.8,"font-size":"12px",padding:"4px 6px",display:"flex","justify-content":"center","align-items":"center","z-index":8,transition:"visibility 50ms"},t$[".".concat(A$)]={"text-align":"center"},t$[".".concat(i$,"[data-position='top']")]={transform:"translate(-50%, -100%)"},t$[".".concat(i$,"[data-position='left']")]={transform:"translate(-100%, -50%)"},t$[".".concat(i$,"[data-position='right']")]={transform:"translate(0, -50%)"},t$[".".concat(i$,"[data-position='bottom']")]={transform:"translate(-50%, 0)"},t$[".".concat(i$,"[data-position='top-left']")]={transform:"translate(0,-100%)"},t$[".".concat(i$,"[data-position='top-right']")]={transform:"translate(-100%,-100%)"},t$[".".concat(i$,"[data-position='left-top']")]={transform:"translate(-100%, 0)"},t$[".".concat(i$,"[data-position='left-bottom']")]={transform:"translate(-100%, -100%)"},t$[".".concat(i$,"[data-position='right-top']")]={transform:"translate(0, 0)"},t$[".".concat(i$,"[data-position='right-bottom']")]={transform:"translate(0, -100%)"},t$[".".concat(i$,"[data-position='bottom-left']")]={transform:"translate(0, 0)"},t$[".".concat(i$,"[data-position='bottom-right']")]={transform:"translate(-100%, 0)"},t$[".".concat(o$)]={width:"4px",height:"4px",transform:"rotate(45deg)","background-color":"rgba(0, 0, 0)",position:"absolute","z-index":-1},t$[".".concat(i$,"[data-position='top']")]={transform:"translate(-50%, calc(-100% - 5px))"},t$["[data-position='top'] .".concat(o$)]={bottom:"-2px"},t$[".".concat(i$,"[data-position='left']")]={transform:"translate(calc(-100% - 5px), -50%)"},t$["[data-position='left'] .".concat(o$)]={right:"-2px"},t$[".".concat(i$,"[data-position='right']")]={transform:"translate(5px, -50%)"},t$["[data-position='right'] .".concat(o$)]={left:"-2px"},t$[".".concat(i$,"[data-position='bottom']")]={transform:"translate(-50%, 5px)"},t$["[data-position='bottom'] .".concat(o$)]={top:"-2px"},t$[".".concat(i$,"[data-position='top-left']")]={transform:"translate(0, calc(-100% - 5px))"},t$["[data-position='top-left'] .".concat(o$)]={left:"10px",bottom:"-2px"},t$[".".concat(i$,"[data-position='top-right']")]={transform:"translate(-100%, calc(-100% - 5px))"},t$["[data-position='top-right'] .".concat(o$)]={right:"10px",bottom:"-2px"},t$[".".concat(i$,"[data-position='left-top']")]={transform:"translate(calc(-100% - 5px), 0)"},t$["[data-position='left-top'] .".concat(o$)]={right:"-2px",top:"8px"},t$[".".concat(i$,"[data-position='left-bottom']")]={transform:"translate(calc(-100% - 5px), -100%)"},t$["[data-position='left-bottom'] .".concat(o$)]={right:"-2px",bottom:"8px"},t$[".".concat(i$,"[data-position='right-top']")]={transform:"translate(5px, 0)"},t$["[data-position='right-top'] .".concat(o$)]={left:"-2px",top:"8px"},t$[".".concat(i$,"[data-position='right-bottom']")]={transform:"translate(5px, -100%)"},t$["[data-position='right-bottom'] .".concat(o$)]={left:"-2px",bottom:"8px"},t$[".".concat(i$,"[data-position='bottom-left']")]={transform:"translate(0, 5px)"},t$["[data-position='bottom-left'] .".concat(o$)]={top:"-2px",left:"8px"},t$[".".concat(i$,"[data-position='bottom-right']")]={transform:"translate(-100%, 5px)"},t$["[data-position='bottom-right'] .".concat(o$)]={top:"-2px",right:"8px"},t$);function a$(t){var e=t&&document.getElementById(t);return e||((e=document.createElement("div")).setAttribute("id",t),document.body.appendChild(e)),e}var c$=function(t){function e(n){var r=t.call(this,be({style:{id:"component-poptip"}},e.defaultOptions,n))||this;return r.visibility="visible",r.map=new Map,r.domStyles="",r.initShape(),r.render(r.attributes,r),r}return Ie(e,t),Object.defineProperty(e.prototype,"visible",{get:function(){return"visible"===this.visibility},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.visibility=this.style.visibility,this.updatePoptipElement()},e.prototype.update=function(t){this.attr(be({},this.style,t)),this.render(this.attributes,this)},e.prototype.bind=function(t,e){var n=this;if(t){var r=this.style.text,i=function(i){var o=t,A=n.style,s=r;if(e){var a="function"==typeof e?e.call(null,i):e,c=a.html,l=a.target,u=Pe(a,["html","target"]);A=function(t,e,n){return e&&fe(t,e),n&&fe(t,n),t}({},n.style,u),(l||!1===l)&&(o=l),"string"==typeof c&&(s=c)}var h=A.position,d=A.arrowPointAtCenter,f=A.follow,g=A.offset;if(o){var p=i,v=He(function(t,e,n,r,i,o){if(void 0===i&&(i=!1),void 0===o&&(o=!1),o)return[t,e];var A=n.getBoundingClientRect(),s=A.x,a=A.y,c=A.width,l=A.height;switch(r){case"top":return i?[s+c/2,a]:[t,a];case"left":return i?[s,a+l/2]:[s,e];case"bottom":return i?[s+c/2,a+l]:[t,a+l];case"right":return i?[s+c,a+l/2]:[s+c,e];case"top-right":case"right-top":return[s+c,a];case"left-bottom":case"bottom-left":return[s,a+l];case"right-bottom":case"bottom-right":return[s+c,a+l];default:return[s,a]}}(p.clientX,p.clientY,o,h,d,f),2),m=v[0],y=v[1];n.showTip(m,y,{text:s,position:h,offset:g})}else n.hideTip()},o=function(){n.hideTip()};t.addEventListener("mousemove",i),t.addEventListener("mouseleave",o),this.map.set(t,[i,o])}},e.prototype.unbind=function(t){if(this.map.has(t)){var e=He(this.map.get(t)||[],2),n=e[0],r=e[1];n&&t.removeEventListener("mousemove",n),r&&t.removeEventListener("mouseleave",r),this.map.delete(t)}},e.prototype.clear=function(){this.container.innerHTML=""},e.prototype.destroy=function(){var e,n=this;_e([],He(this.map.keys()),!1).forEach(function(t){return n.unbind(t)}),null===(e=this.container)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.showTip=function(t,e,n){var r=Ce(n,"text");if((!r||"string"==typeof r)&&(this.applyStyles(),t&&e&&n)){var i=n.offset,o=n.position;if(o&&this.container.setAttribute("data-position",o),this.setOffsetPosition(t,e,i),"string"==typeof r){var A=this.container.querySelector(".".concat(A$));A&&(A.innerHTML=r)}this.visibility="visible",this.container.style.visibility="visible"}},e.prototype.hideTip=function(){this.visibility="hidden",this.container.style.visibility="hidden"},e.prototype.getContainer=function(){return this.container},e.prototype.getClassName=function(){var t=this.style.containerClassName;return"".concat(i$).concat(t?" ".concat(t):"")},e.prototype.initShape=function(){var t=this,e=this.style.id;this.container=function(t){var e,n,r=(e=a$,function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return n||(n=e.apply(void 0,t)),n})(t);return r}(e),this.container.className=this.getClassName(),this.container.addEventListener("mousemove",function(){return t.showTip()}),this.container.addEventListener("mouseleave",function(){return t.hideTip()})},e.prototype.updatePoptipElement=function(){var t=this.container;this.clear();var e=this.style,n=e.id,r=e.template,i=e.text;this.container.setAttribute("id",n),this.container.className=this.getClassName();var o,A='<span class="'.concat(o$,'"></span>');t.innerHTML=A,Jt(r)?t.innerHTML+=r:r&&((o=r)instanceof Element||o instanceof Document)&&t.appendChild(r),i&&(t.getElementsByClassName(A$)[0].textContent=i),this.applyStyles(),this.container.style.visibility=this.visibility},e.prototype.applyStyles=function(){var t=rW({},s$,this.style.domStyles),e=Object.entries(t).reduce(function(t,e){var n=He(e,2),r=n[0],i=n[1],o=Object.entries(i).reduce(function(t,e){var n=He(e,2),r=n[0],i=n[1];return"".concat(t).concat(r,": ").concat(i,";")},"");return"".concat(t).concat(r,"{").concat(o,"}")},"");if(this.domStyles!==e){this.domStyles=e;var n=this.container.querySelector("style");n&&this.container.removeChild(n),(n=document.createElement("style")).innerHTML=e,this.container.appendChild(n)}},e.prototype.setOffsetPosition=function(t,e,n){void 0===n&&(n=this.style.offset);var r=He(n,2),i=r[0],o=void 0===i?0:i,A=r[1],s=void 0===A?0:A;this.container.style.left="".concat(t+o,"px"),this.container.style.top="".concat(e+s,"px")},e.tag="poptip",e.defaultOptions={style:{x:0,y:0,width:0,height:0,target:null,visibility:"hidden",text:"",position:"top",follow:!1,offset:[0,0],domStyles:s$,template:'<div class="'.concat(A$,'"></div>')}},e}(zW),l$=eW({layout:"flex",markerGroup:"marker-group",marker:"marker",labelGroup:"label-group",label:"label",valueGroup:"value-group",focusGroup:"focus-group",focus:"focus",value:"value",backgroundGroup:"background-group",background:"background"},"legend-category-item"),u$={offset:[0,20],domStyles:{".component-poptip":{opacity:"1",padding:"8px 12px",background:"#fff",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)"},".component-poptip-arrow":{display:"none"},".component-poptip-text":{color:"#000",lineHeight:"20px"}}};var h$=function(t){function e(e,n){var r=t.call(this,e,{span:[1,1],marker:function(){return new za({style:{r:6}})},markerSize:10,labelFill:"#646464",valueFill:"#646464",labelFontSize:12,valueFontSize:12,labelTextBaseline:"middle",valueTextBaseline:"middle"})||this;return r.keyFields={},r.keyFields=n||{},r}return Ie(e,t),Object.defineProperty(e.prototype,"showValue",{get:function(){var t=this.attributes.valueText;return!!t&&("string"==typeof t||"number"==typeof t?""!==t:"function"==typeof t||""!==t.attr("text"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"actualSpace",{get:function(){var t=this.labelGroup,e=this.valueGroup,n=this.attributes,r=n.markerSize,i=n.focus,o=n.focusMarkerSize,A=t.node().getBBox(),s=A.width,a=A.height,c=e.node().getBBox(),l=c.width,u=c.height;return{markerWidth:r,labelWidth:s,valueWidth:l,focusWidth:i?null!=o?o:12:0,height:Math.max(r,a,u)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"span",{get:function(){var t=this.attributes.span;if(!t)return[1,1];var e=He(UW(t),2),n=e[0],r=e[1],i=this.showValue?r:0,o=n+i;return[n/o,i/o]},enumerable:!1,configurable:!0}),e.prototype.setAttribute=function(e,n){t.prototype.setAttribute.call(this,e,n)},Object.defineProperty(e.prototype,"shape",{get:function(){var t,e=this.attributes,n=e.markerSize,r=e.width,i=this.actualSpace,o=i.markerWidth,A=i.focusWidth,s=i.height,a=this.actualSpace,c=a.labelWidth,l=a.valueWidth,u=He(this.spacing,3),h=u[0],d=u[1],f=u[2];if(r){var g=r-n-h-d-A-f,p=He(this.span,2);c=(t=He([p[0]*g,p[1]*g],2))[0],l=t[1]}return{width:o+c+l+h+d+A+f,height:s,markerWidth:o,labelWidth:c,valueWidth:l,focusWidth:A}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){var t=this.attributes,e=t.spacing,n=t.focus;if(!e)return[0,0,0];var r=He(UW(e),3),i=r[0],o=r[1],A=r[2];return[i,this.showValue?o:0,n?A:0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layout",{get:function(){var t=this.shape,e=t.markerWidth,n=t.labelWidth,r=t.valueWidth,i=t.focusWidth,o=t.width,A=t.height,s=He(this.spacing,3),a=s[0],c=s[1];return{height:A,width:o,markerWidth:e,labelWidth:n,valueWidth:r,focusWidth:i,position:[e/2,e+a,e+n+a+c,e+n+r+a+c+s[2]+i/2]}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleSize",{get:function(){var t=function(t){var e=t.querySelector(l$.marker.class);return e?e.style:{}}(this.markerGroup.node()),e=this.attributes,n=e.markerSize,r=e.markerStrokeWidth,i=void 0===r?t.strokeWidth:r,o=e.markerLineWidth,A=void 0===o?t.lineWidth:o,s=e.markerStroke,a=void 0===s?t.stroke:s,c=+(i||A||(a?1:0))*Math.sqrt(2),l=this.markerGroup.node().getBBox(),u=l.width,h=l.height;return(1-c/Math.max(u,h))*n},enumerable:!1,configurable:!0}),e.prototype.renderMarker=function(t){var e=this,n=this.attributes,r=n.marker,i=n.classNamePrefix,o=PW(this.attributes,"marker");this.markerGroup=t.maybeAppendByClassName(l$.markerGroup,"g").style("zIndex",0),hW(!!r,this.markerGroup,function(){var t,n=e.markerGroup.node(),A=null===(t=n.childNodes)||void 0===t?void 0:t[0],s=Tq(l$.marker.name,Pq,i),a="string"==typeof r?new JW({style:{symbol:r},className:s}):r();if(A)if(a.nodeName===A.nodeName)A instanceof JW?A.update(Le(Le({},o),{symbol:r})):(!function(t,e){var n,r,i=e.attributes;try{for(var o=Re(Object.entries(i)),A=o.next();!A.done;A=o.next()){var s=He(A.value,2),a=s[0],c=s[1];"id"!==a&&"className"!==a&&t.attr(a,c)}}catch(t){n={error:t}}finally{try{A&&!A.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}(A,a),QW(A).styles(o));else{if(A.remove(),!(a instanceof JW)){var c=Tq(l$.marker.name,Pq,i);a.className=c}QW(a).styles(o),n.appendChild(a)}else{if(!(a instanceof JW)){var l=Tq(l$.marker.name,Pq,i);a.className=l,QW(a).styles(o)}n.appendChild(a)}e.markerGroup.node().scale(1/e.markerGroup.node().getScale()[0]);var u=kW(e.markerGroup.node(),e.scaleSize);e.markerGroup.node().style._transform="scale(".concat(u,")")})},e.prototype.renderLabel=function(t){var e=PW(this.attributes,"label"),n=e.text,r=Pe(e,["text"]),i=this.attributes.classNamePrefix;this.labelGroup=t.maybeAppendByClassName(l$.labelGroup,"g").style("zIndex",0);var o=Tq(l$.label.name,Dq,i),A=this.labelGroup.maybeAppendByClassName(l$.label,function(){return uW(n)});A.node().setAttribute("class",o),A.styles(r)},e.prototype.renderValue=function(t){var e=this,n=PW(this.attributes,"value"),r=n.text,i=Pe(n,["text"]),o=this.attributes.classNamePrefix;this.valueGroup=t.maybeAppendByClassName(l$.valueGroup,"g").style("zIndex",0),hW(this.showValue,this.valueGroup,function(){var t=Tq(l$.value.name,Rq,o),n=e.valueGroup.maybeAppendByClassName(l$.value,function(){return uW(r)});n.node().setAttribute("class",t),n.styles(i)})},e.prototype.createPoptip=function(){var t=this.attributes.poptip||{};t.render;var e=Pe(t,["render"]),n=new c$({style:rW(u$,e)});return this.poptipGroup=n,n},e.prototype.bindPoptip=function(t){var e=this,n=this.attributes.poptip;n&&(this.poptipGroup||this.createPoptip()).bind(t,function(){var t=e.attributes,r=t.labelText,i=t.valueText,o=t.markerFill,A="string"==typeof r?r:null==r?void 0:r.attr("text"),s="string"==typeof i?i:null==i?void 0:i.attr("text");if("function"==typeof n.render)return{html:n.render(Le(Le({},e.keyFields),{label:A,value:s,color:o}))};var a="";return"string"!=typeof A&&"number"!=typeof A||(a+='<div class="component-poptip-label">'.concat(A,"</div>")),"string"!=typeof s&&"number"!=typeof s||(a+='<div class="component-poptip-value">'.concat(s,"</div>")),{html:a}})},e.prototype.renderFocus=function(t){var e=this,n=this.attributes,r=n.focus,i=n.focusMarkerSize,o=n.classNamePrefix,A={x:0,y:0,size:i,opacity:.6,symbol:"focus",stroke:"#aaaaaa",lineWidth:1};de(r)||(this.focusGroup=t.maybeAppendByClassName(l$.focusGroup,"g").style("zIndex",0),hW(r,this.focusGroup,function(){var n=Tq(l$.focus.name,Hq,o),r=new JW({style:Le(Le({},A),{symbol:"focus"}),className:n}),i=new za({style:{r:A.size/2,fill:"transparent"}}),s=e.focusGroup.node();s.appendChild(i),s.appendChild(r),r.update({opacity:0}),t.node().addEventListener("pointerenter",function(){r.update({opacity:1})}),t.node().addEventListener("pointerleave",function(){r.update({opacity:0})})}))},e.prototype.renderPoptip=function(t){var e=this;this.attributes.poptip&&[t.maybeAppendByClassName(l$.value,"g").node(),t.maybeAppendByClassName(l$.label,"g").node()].forEach(function(t){t&&e.bindPoptip(t)})},e.prototype.renderBackground=function(t){var e=this.shape,n=e.width,r=e.height,i=PW(this.attributes,"background");this.background=t.maybeAppendByClassName(l$.backgroundGroup,"g").style("zIndex",-1);var o=this.background.maybeAppendByClassName(l$.background,"rect");o.styles(Le({width:n,height:r},i));var A=this.attributes.classNamePrefix,s=void 0===A?"":A;if(s){var a=Tq(l$.background.name,_q,s);o.node().setAttribute("class",a)}},e.prototype.adjustLayout=function(){var t=this.layout,e=t.labelWidth,n=t.valueWidth,r=t.height,i=He(t.position,4),o=i[0],A=i[1],s=i[2],a=i[3],c=r/2;this.markerGroup.styles({transform:"translate(".concat(o,", ").concat(c,")").concat(this.markerGroup.node().style._transform)}),this.labelGroup.styles({transform:"translate(".concat(A,", ").concat(c,")")}),this.focusGroup&&this.focusGroup.styles({transform:"translate(".concat(a,", ").concat(c,")")}),cW(this.labelGroup.select(l$.label.class).node(),Math.ceil(e)),this.showValue&&(this.valueGroup.styles({transform:"translate(".concat(s,", ").concat(c,")")}),cW(this.valueGroup.select(l$.value.class).node(),Math.ceil(n)))},e.prototype.render=function(t,e){var n=QW(e),r=t.x,i=void 0===r?0:r,o=t.y,A=void 0===o?0:o;n.styles({transform:"translate(".concat(i,", ").concat(A,")")}),this.renderMarker(n),this.renderLabel(n),this.renderValue(n),this.renderBackground(n),this.renderPoptip(n),this.renderFocus(n),this.adjustLayout()},e}(zW),d$=eW({page:"item-page",navigator:"navigator",item:"item"},"items"),f$=function(t,e,n){return void 0===n&&(n=!0),t?e(t):n},g$=function(t){function e(e){var n=t.call(this,e,{data:[],gridRow:1/0,gridCol:void 0,padding:0,width:1e3,height:100,rowPadding:0,colPadding:0,layout:"flex",orientation:"horizontal",click:Ne,mouseenter:Ne,mouseleave:Ne})||this;return n.navigatorShape=[0,0],n}return Ie(e,t),Object.defineProperty(e.prototype,"pageViews",{get:function(){return this.navigator.getContainer()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){var t=this.attributes,e=t.gridRow,n=t.gridCol,r=t.data;if(!e&&!n)throw new Error("gridRow and gridCol can not be set null at the same time");return e&&n?[e,n]:e?[e,r.length]:[r.length,n]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderData",{get:function(){var t=this.attributes,e=t.data,n=t.layout,r=t.poptip,i=t.focus,o=t.focusMarkerSize,A=t.classNamePrefix,s=PW(this.attributes,"item"),a=e.map(function(t,a){var c=t.id,l=void 0===c?a:c,u=t.label,h=t.value;return{id:"".concat(l),index:a,style:Le({layout:n,labelText:u,valueText:h,poptip:r,focus:i,focusMarkerSize:o,classNamePrefix:A},Object.fromEntries(Object.entries(s).map(function(n){var r=He(n,2);return[r[0],JV(r[1],[t,a,e])]})))}});return a},enumerable:!1,configurable:!0}),e.prototype.getGridLayout=function(){var t=this,e=this.attributes,n=e.orientation,r=e.width,i=e.rowPadding,o=e.colPadding,A=He(this.navigatorShape,1)[0],s=He(this.grid,2),a=s[0],c=s[1],l=c*a,u=0;return this.pageViews.children.map(function(e,s){var h,d,f=Math.floor(s/l),g=s%l,p=t.ifHorizontal(c,a),v=[Math.floor(g/p),g%p];"vertical"===n&&v.reverse();var m=He(v,2),y=m[0],w=m[1],b=(r-A-(c-1)*o)/c,B=e.getBBox().height,E=He([0,0],2),x=E[0],C=E[1];return"horizontal"===n?(x=(h=He([u,y*(B+i)],2))[0],C=h[1],u=w===c-1?0:u+b+o):(x=(d=He([w*(b+o),u],2))[0],C=d[1],u=y===a-1?0:u+B+i),{page:f,index:s,row:y,col:w,pageIndex:g,width:b,height:B,x:x,y:C}})},e.prototype.getFlexLayout=function(){var t=this.attributes,e=t.width,n=t.height,r=t.rowPadding,i=t.colPadding,o=He(this.navigatorShape,1)[0],A=He(this.grid,2),s=A[0],a=A[1],c=He([e-o,n],2),l=c[0],u=c[1],h=He([0,0,0,0,0,0,0,0],8),d=h[0],f=h[1],g=h[2],p=h[3],v=h[4],m=h[5],y=h[6],w=h[7];return this.pageViews.children.map(function(t,e){var n,o,A,c,h=t.getBBox(),b=h.width,B=h.height,E=0===y?0:i,x=y+E+b;return x<=l&&f$(v,function(t){return t<a})?(n=He([y+E,w,x],3),d=n[0],f=n[1],y=n[2],{width:b,height:B,x:d,y:f,page:g,index:e,pageIndex:p++,row:m,col:v++}):(o=He([m+1,0,0,w+B+r],4),m=o[0],v=o[1],y=o[2],(w=o[3])+B<=u&&f$(m,function(t){return t<s})?(A=He([y,w,b],3),d=A[0],f=A[1],y=A[2],{width:b,height:B,x:d,y:f,page:g,index:e,pageIndex:p++,row:m,col:v++}):(c=He([0,0,b,0,g+1,0,0,0],8),d=c[0],f=c[1],y=c[2],w=c[3],g=c[4],p=c[5],m=c[6],v=c[7],{width:b,height:B,x:d,y:f,page:g,index:e,pageIndex:p++,row:m,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 Oq(this.attributes.orientation,t,e)},e.prototype.flattenPage=function(t){t.querySelectorAll(d$.item.class).forEach(function(e){t.appendChild(e)}),t.querySelectorAll(d$.page.class).forEach(function(e){t.removeChild(e).destroy()})},e.prototype.renderItems=function(t){var e=this.attributes,n=e.click,r=e.mouseenter,i=e.mouseleave,o=e.classNamePrefix;this.flattenPage(t);var A=this.dispatchCustomEvent.bind(this),s=Tq(d$.item.name,Lq,o);QW(t).selectAll(d$.item.class).data(this.renderData,function(t){return t.id}).join(function(t){return t.append(function(t){var e=t.style,n=Pe(t,["style"]);return new h$({style:e},n)}).attr("className",s).on("click",function(){null==n||n(this),A("itemClick",{item:this})}).on("pointerenter",function(){null==r||r(this),A("itemMouseenter",{item:this})}).on("pointerleave",function(){null==i||i(this),A("itemMouseleave",{item:this})})},function(t){return t.each(function(t){var e=t.style;this.update(e)})},function(t){return t.remove()})},e.prototype.relayoutNavigator=function(){var t,e=this.attributes,n=e.layout,r=e.width,i=(null===(t=this.pageViews.children[0])||void 0===t?void 0:t.getBBox().height)||0,o=He(this.navigatorShape,2),A=o[0],s=o[1];this.navigator.update("grid"===n?{pageWidth:r-A,pageHeight:i-s}:{})},e.prototype.adjustLayout=function(){var t,e,n=this,r=Object.entries((t=this.itemsLayout,e="page",t.reduce(function(t,n){return(t[n[e]]=t[n[e]]||[]).push(n),t},{}))).map(function(t){var e=He(t,2);return{page:e[0],layouts:e[1]}}),i=_e([],He(this.navigator.getContainer().children),!1);r.forEach(function(t){var e=t.layouts,r=n.pageViews.appendChild(new Xa({className:d$.page.name}));e.forEach(function(t){var e=t.x,n=t.y,o=t.index,A=t.width,s=t.height,a=i[o];r.appendChild(a),Me(a,"__layout__",t),a.update({x:e,y:n,width:A,height:s})})}),this.relayoutNavigator()},e.prototype.renderNavigator=function(t){var e=this.attributes,n=e.orientation,r=e.classNamePrefix,i=PW(this.attributes,"nav"),o=rW({orientation:n,classNamePrefix:r},i),A=this;return t.selectAll(d$.navigator.class).data(["nav"]).join(function(t){return t.append(function(){return new r$({style:o})}).attr("className",d$.navigator.name).each(function(){A.navigator=this})},function(t){return t.each(function(){this.update(o)})},function(t){return t.remove()}),this.navigator},e.prototype.getBBox=function(){return this.navigator.getBBox()},e.prototype.render=function(t,e){var n=this.attributes.data;if(n&&0!==n.length){var r=this.renderNavigator(QW(e));this.renderItems(r.getContainer()),this.adjustLayout()}},e.prototype.dispatchCustomEvent=function(t,e){var n=new Vs(t,{detail:e});this.dispatchEvent(n)},e}(zW),p$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.update=function(t){this.attr(t)},e}($a),v$=function(t){function e(e){return t.call(this,e,qq)||this}return Ie(e,t),e.prototype.renderTitle=function(t,e,n){var r=this.attributes,i=r.showTitle,o=r.titleText,A=r.classNamePrefix,s=He(RW(PW(this.attributes,"title")),2),a=s[0],c=s[1];this.titleGroup=t.maybeAppendByClassName($q.titleGroup,"g").styles(c);var l=Le(Le({width:e,height:n},a),{text:i?o:"",classNamePrefix:A});this.title=this.titleGroup.maybeAppendByClassName($q.title,function(){return new e$({style:l})}).update(l)},e.prototype.renderCustom=function(t){var e=this.attributes.data,n={innerHTML:this.attributes.render(e),pointerEvents:"auto"};t.maybeAppendByClassName($q.html,function(){return new p$({className:$q.html.name,style:n})}).update(n)},e.prototype.renderItems=function(t,e){var n=e.x,r=e.y,i=e.width,o=e.height,A=He(RW(PW(this.attributes,"title",!0)),2),s=A[0],a=A[1],c=Le(Le({},s),{width:i,height:o,x:0,y:0});this.itemsGroup=t.maybeAppendByClassName($q.itemsGroup,"g").styles(Le(Le({},a),{transform:"translate(".concat(n,", ").concat(r,")")}));var l=this;this.itemsGroup.selectAll($q.items.class).data(["items"]).join(function(t){return t.append(function(){return new g$({style:c})}).attr("className",$q.items.name).each(function(){l.items=QW(this)})},function(t){return t.update(c)},function(t){return t.remove()})},e.prototype.adjustLayout=function(){if(this.attributes.showTitle){var t=this.title.node().getAvailableSpace(),e=t.x,n=t.y;this.itemsGroup.node().style.transform="translate(".concat(e,", ").concat(n,")")}},Object.defineProperty(e.prototype,"availableSpace",{get:function(){var t=this.attributes,e=t.showTitle,n=t.width,r=t.height;return e?this.title.node().getAvailableSpace():new ZV(0,0,n,r)},enumerable:!1,configurable:!0}),e.prototype.getBBox=function(){var e,n,r=null===(e=this.title)||void 0===e?void 0:e.node(),i=null===(n=this.items)||void 0===n?void 0:n.node();return r&&i?function(t,e){var n=t.attributes,r=n.position,i=n.spacing,o=n.inset,A=n.text,s=t.getBBox(),a=e.getBBox(),c=KW(r),l=He(UW(A?i:0),4),u=l[0],h=l[1],d=l[2],f=l[3],g=He(UW(o),4),p=g[0],v=g[1],m=g[2],y=g[3],w=He([f+h,u+d],2),b=w[0],B=w[1],E=He([y+v,p+m],2),x=E[0],C=E[1];if("l"===c[0])return new ZV(s.x,s.y,a.width+s.width+b+x,Math.max(a.height+C,s.height));if("t"===c[0])return new ZV(s.x,s.y,Math.max(a.width+x,s.width),a.height+s.height+B+C);var M=He([e.attributes.width||a.width,e.attributes.height||a.height],2),F=M[0],k=M[1];return new ZV(a.x,a.y,F+s.width+b+x,k+s.height+B+C)}(r,i):t.prototype.getBBox.call(this)},e.prototype.render=function(t,e){var n=this.attributes,r=n.width,i=n.height,o=n.x,A=void 0===o?0:o,s=n.y,a=void 0===s?0:s,c=n.classNamePrefix,l=n.render,u=QW(e),h=e.className||"legend-category";c?e.attr("className","".concat(h," ").concat(c,"legend")):e.className||e.attr("className","legend-category"),e.style.transform="translate(".concat(A,", ").concat(a,")"),l?this.renderCustom(u):(this.renderTitle(u,r,i),this.renderItems(u,this.availableSpace),this.adjustLayout())},e}(zW),m$={backgroundFill:"#262626",backgroundLineCap:"round",backgroundLineWidth:1,backgroundStroke:"#333",backgroundZIndex:-1,formatter:function(t){return t.toString()},labelFill:"#fff",labelFontSize:12,labelTextBaseline:"middle",padding:[2,4],position:"right",radius:0,zIndex:999},y$=eW({background:"background",labelGroup:"label-group",label:"label"},"indicator"),w$=function(t){function e(e){var n=t.call(this,e,m$)||this;return n.point=[0,0],n.group=n.appendChild(new Xa({})),n.isMutationObserved=!0,n}return Ie(e,t),e.prototype.renderBackground=function(){if(this.label){var t=this.attributes,e=t.position,n=He(UW(t.padding),4),r=n[0],i=n[1],o=n[2],A=n[3],s=this.label.node().getLocalBounds(),a=s.min,c=s.max,l=new ZV(a[0]-A,a[1]-r,c[0]+i-a[0]+A,c[1]+o-a[1]+r),u=this.getPath(e,l),h=PW(this.attributes,"background");this.background=QW(this.group).maybeAppendByClassName(y$.background,"path").styles(Le(Le({},h),{d:u})),this.group.appendChild(this.label.node())}},e.prototype.renderLabel=function(){var t=this.attributes,e=t.formatter,n=t.labelText,r=He(RW(PW(this.attributes,"label")),2),i=r[0],o=r[1];i.text;var A=Pe(i,["text"]);(this.label=QW(this.group).maybeAppendByClassName(y$.labelGroup,"g").styles(o),n)&&this.label.maybeAppendByClassName(y$.label,function(){return uW(e(n))}).style("text",e(n).toString()).selectAll("text").styles(A)},e.prototype.adjustLayout=function(){var t=He(this.point,2),e=t[0],n=t[1],r=this.attributes,i=r.x,o=r.y;this.group.attr("transform","translate(".concat(i-e,", ").concat(o-n,")"))},e.prototype.getPath=function(t,e){var n=this.attributes.radius,r=e.x,i=e.y,o=e.width,A=e.height,s=[["M",r+n,i],["L",r+o-n,i],["A",n,n,0,0,1,r+o,i+n],["L",r+o,i+A-n],["A",n,n,0,0,1,r+o-n,i+A],["L",r+n,i+A],["A",n,n,0,0,1,r,i+A-n],["L",r,i+n],["A",n,n,0,0,1,r+n,i],["Z"]],a={top:4,right:6,bottom:0,left:2}[t],c=this.createCorner([s[a].slice(-2),s[a+1].slice(-2)]);return s.splice.apply(s,_e([a+1,1],He(c),!1)),s[0][0]="M",s},e.prototype.createCorner=function(t,e){void 0===e&&(e=10);var n=TW.apply(void 0,_e([],He(t),!1)),r=He(t,2),i=He(r[0],2),o=i[0],A=i[1],s=He(r[1],2),a=s[0],c=s[1],l=He(n?[a-o,[o,a]]:[c-A,[A,c]],2),u=l[0],h=He(l[1],2),d=h[0],f=h[1],g=u/2,p=e*(u/Math.abs(u)),v=p/2,m=p*Math.sqrt(3)/2*.8,y=He([d,d+g-v,d+g,d+g+v,f],5),w=y[0],b=y[1],B=y[2],E=y[3],x=y[4];return n?(this.point=[B,A-m],[["L",w,A],["L",b,A],["L",B,A-m],["L",E,A],["L",x,A]]):(this.point=[o+m,B],[["L",o,w],["L",o,b],["L",o+m,B],["L",o,E],["L",o,x]])},e.prototype.applyVisibility=function(){"hidden"===this.attributes.visibility?zV(this):jV(this)},e.prototype.bindEvents=function(){this.label.on(ea.BOUNDS_CHANGED,this.renderBackground)},e.prototype.render=function(){this.renderLabel(),this.renderBackground(),this.adjustLayout(),this.applyVisibility()},e}(zW);function b$(t){return void 0===t&&(t=""),{CONTAINER:"".concat(t,"tooltip"),TITLE:"".concat(t,"tooltip-title"),LIST:"".concat(t,"tooltip-list"),LIST_ITEM:"".concat(t,"tooltip-list-item"),NAME:"".concat(t,"tooltip-list-item-name"),MARKER:"".concat(t,"tooltip-list-item-marker"),NAME_LABEL:"".concat(t,"tooltip-list-item-name-label"),VALUE:"".concat(t,"tooltip-list-item-value"),CROSSHAIR_X:"".concat(t,"tooltip-crosshair-x"),CROSSHAIR_Y:"".concat(t,"tooltip-crosshair-y")}}var B$={overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis"};function E$(t){var e;void 0===t&&(t="");var n=b$(t);return(e={})[".".concat(n.CONTAINER)]={position:"absolute",visibility:"visible","z-index":8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)","background-color":"rgba(255, 255, 255, 0.96)","box-shadow":"0 6px 12px 0 rgba(0, 0, 0, 0.12)","border-radius":"4px",color:"rgba(0, 0, 0, 0.65)","font-size":"12px","line-height":"20px",padding:"12px","min-width":"120px","max-width":"360px","font-family":"Roboto-Regular"},e[".".concat(n.TITLE)]={color:"rgba(0, 0, 0, 0.45)"},e[".".concat(n.LIST)]={margin:"0px","list-style-type":"none",padding:"0px"},e[".".concat(n.LIST_ITEM)]={"list-style-type":"none",display:"flex","line-height":"2em","align-items":"center","justify-content":"space-between","white-space":"nowrap"},e[".".concat(n.MARKER)]={width:"8px",height:"8px","border-radius":"50%",display:"inline-block","margin-right":"4px"},e[".".concat(n.NAME)]={display:"flex","align-items":"center","max-width":"216px"},e[".".concat(n.NAME_LABEL)]=Le({flex:1},B$),e[".".concat(n.VALUE)]=Le({display:"inline-block",float:"right",flex:1,"text-align":"right","min-width":"28px","margin-left":"30px",color:"rgba(0, 0, 0, 0.85)"},B$),e[".".concat(n.CROSSHAIR_X)]={position:"absolute",width:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e[".".concat(n.CROSSHAIR_Y)]={position:"absolute",height:"1px","background-color":"rgba(0, 0, 0, 0.25)"},e}var x$=function(t){function e(e){var n,r,i=this,o=null===(r=null===(n=e.style)||void 0===n?void 0:n.template)||void 0===r?void 0:r.prefixCls,A=b$(o);return(i=t.call(this,e,{data:[],x:0,y:0,visibility:"visible",title:"",position:"bottom-right",offset:[5,5],enterable:!1,container:{x:0,y:0},bounding:null,template:{prefixCls:"",container:'<div class="'.concat(A.CONTAINER,'"></div>'),title:'<div class="'.concat(A.TITLE,'"></div>'),item:'<li class="'.concat(A.LIST_ITEM,'" data-index={index}>\n <span class="').concat(A.NAME,'">\n <span class="').concat(A.MARKER,'" style="background:{color}"></span>\n <span class="').concat(A.NAME_LABEL,'" title="{name}">{name}</span>\n </span>\n <span class="').concat(A.VALUE,'" title="{value}">{value}</span>\n </li>')},style:E$(o)})||this).timestamp=-1,i.prevCustomContentKey=i.attributes.contentKey,i.initShape(),i.render(i.attributes,i),i}return Ie(e,t),Object.defineProperty(e.prototype,"HTMLTooltipElement",{get:function(){return this.element},enumerable:!1,configurable:!0}),e.prototype.getContainer=function(){return this.element},Object.defineProperty(e.prototype,"elementSize",{get:function(){return{width:this.element.offsetWidth,height:this.element.offsetHeight}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"HTMLTooltipItemsElements",{get:function(){var t=this.attributes,e=t.data,n=t.template;return e.map(function(t,e){var r=t.name,i=void 0===r?"":r,o=t.color,A=void 0===o?"black":o,s=t.index,a=Pe(t,["name","color","index"]),c=Le({name:i,color:A,index:null!=s?s:e},a);return Sn(function(t,e){return t&&e?t.replace(/\\?\{([^{}]+)\}/g,function(t,n){return"\\"===t.charAt(0)?t.slice(1):void 0===e[n]?"":e[n]}):t}(n.item,c))})},enumerable:!1,configurable:!0}),e.prototype.render=function(t,e){this.renderHTMLTooltipElement(),this.updatePosition()},e.prototype.destroy=function(){var e;null===(e=this.element)||void 0===e||e.remove(),t.prototype.destroy.call(this)},e.prototype.show=function(t,e){var n=this;if(void 0!==t&&void 0!==e){var r=function(){n.attributes.x=null!=t?t:n.attributes.x,n.attributes.y=null!=e?e:n.attributes.y,n.updatePosition()};"hidden"===this.element.style.visibility?this.closeTransition(r):r()}this.element.style.visibility="visible"},e.prototype.hide=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.attributes.enterable&&this.isCursorEntered(t,e)||(this.element.style.visibility="hidden")},e.prototype.initShape=function(){var t=this.attributes.template;this.element=Sn(t.container),this.id&&this.element.setAttribute("id",this.id)},e.prototype.renderCustomContent=function(){if(void 0===this.prevCustomContentKey||this.prevCustomContentKey!==this.attributes.contentKey){this.prevCustomContentKey=this.attributes.contentKey;var t=this.attributes.content;t&&("string"==typeof t?this.element.innerHTML=t:GW(this.element,t))}},e.prototype.renderHTMLTooltipElement=function(){var t,e,n=this.attributes,r=n.template,i=n.title,o=n.enterable,A=n.style,s=n.content,a=b$(r.prefixCls),c=this.element;if(this.element.style.pointerEvents=o?"auto":"none",s)this.renderCustomContent();else{i?(c.innerHTML=r.title,c.getElementsByClassName(a.TITLE)[0].innerHTML=i):null===(e=null===(t=c.getElementsByClassName(a.TITLE))||void 0===t?void 0:t[0])||void 0===e||e.remove();var l=this.HTMLTooltipItemsElements,u=document.createElement("ul");u.className=a.LIST,GW(u,l);var h=this.element.querySelector(".".concat(a.LIST));h?h.replaceWith(u):c.appendChild(u)}!function(t,e){Object.entries(e).forEach(function(e){var n=He(e,2),r=n[0],i=n[1];_e([t],He(t.querySelectorAll(r)),!1).filter(function(t){return t.matches(r)}).forEach(function(t){t&&(t.style.cssText+=Object.entries(i).reduce(function(t,e){return"".concat(t).concat(e.join(":"),";")},""))})})}(c,A)},e.prototype.getRelativeOffsetFromCursor=function(t){var e=this.attributes,n=e.position,r=e.offset,i=(t||n).split("-"),o={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]},A=this.elementSize,s=A.width,a=A.height,c=[-s/2,-a/2];return i.forEach(function(t){var e=He(c,2),n=e[0],i=e[1],A=He(o[t],2),l=A[0],u=A[1];c=[n+(s/2+r[0])*l,i+(a/2+r[1])*u]}),c},e.prototype.setOffsetPosition=function(t){var e=He(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,A=void 0===o?0:o,s=i.y,a=void 0===s?0:s,c=i.container,l=c.x,u=c.y;this.element.style.left="".concat(+A+l+n,"px"),this.element.style.top="".concat(+a+u+r,"px")},e.prototype.updatePosition=function(){var t=this.attributes.showDelay,e=void 0===t?60:t,n=Date.now();this.timestamp>0&&n-this.timestamp<e||(this.timestamp=n,this.setOffsetPosition(this.autoPosition(this.getRelativeOffsetFromCursor())))},e.prototype.autoPosition=function(t){var e=He(t,2),n=e[0],r=e[1],i=this.attributes,o=i.x,A=i.y,s=i.bounding,a=i.position;if(!s)return[n,r];var c=this.element,l=c.offsetWidth,u=c.offsetHeight,h=He([+o+n,+A+r],2),d=h[0],f=h[1],g={left:"right",right:"left",top:"bottom",bottom:"top"},p=s.x,v=s.y,m={left:d<p,right:d+l>p+s.width,top:f<v,bottom:f+u>v+s.height},y=[];a.split("-").forEach(function(t){m[t]?y.push(g[t]):y.push(t)});var w=y.join("-");return this.getRelativeOffsetFromCursor(w)},e.prototype.isCursorEntered=function(t,e){if(this.element){var n=this.element.getBoundingClientRect(),r=n.x,i=n.y,o=n.width,A=n.height;return new ZV(r,i,o,A).isPointIn(t,e)}return!1},e.prototype.closeTransition=function(t){var e=this,n=this.element.style.transition;this.element.style.transition="none",t(),setTimeout(function(){e.element.style.transition=n},10)},e.tag="tooltip",e}(zW),C$=function(t){function e(n){var r=t.call(this,rW({},e.defaultOptions,n))||this;return r.hoverColor="#f5f5f5",r.selectedColor="#e6f7ff",r.background=r.appendChild(new sc({})),r.label=r.background.appendChild(new Xa({})),r}return Ie(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return UW(this.style.padding)},enumerable:!1,configurable:!0}),e.prototype.renderLabel=function(){var t=this.style,e=t.label,n=t.value,r=PW(this.attributes,"label");QW(this.label).maybeAppend(".label",function(){return uW(e)}).attr("className","label").styles(r),this.label.attr("__data__",n)},e.prototype.renderBackground=function(){var t=this.label.getBBox(),e=He(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3],A=t.width,s=t.height,a=A+o+r,c=s+n+i,l=PW(this.attributes,"background"),u=this.style,h=u.width,d=void 0===h?0:h,f=u.height,g=void 0===f?0:f,p=u.selected;this.background.attr(Le(Le({},l),{width:Math.max(a,d),height:Math.max(c,g),fill:p?this.selectedColor:"#fff"})),this.label.attr({transform:"translate(".concat(o,", ").concat((c-s)/2,")")})},e.prototype.render=function(){this.renderLabel(),this.renderBackground()},e.prototype.bindEvents=function(){var t=this;this.addEventListener("pointerenter",function(){t.style.selected||t.background.attr("fill",t.hoverColor)}),this.addEventListener("pointerleave",function(){t.style.selected||t.background.attr("fill",t.style.backgroundFill)});var e=this;this.addEventListener("click",function(){var n=t.style,r=n.label,i=n.value,o=n.onClick;null==o||o(i,{label:r,value:i},e)})},e.defaultOptions={style:{value:"",label:"",cursor:"pointer"}},e}(zW),M$=function(t){function e(n){var r,i,o=t.call(this,rW({},e.defaultOptions,n))||this;o.currentValue=null===(r=e.defaultOptions.style)||void 0===r?void 0:r.defaultValue,o.isPointerInSelect=!1,o.select=o.appendChild(new sc({className:"select",style:{cursor:"pointer",width:0,height:0}})),o.dropdown=o.appendChild(new sc({className:"dropdown"}));var A=o.style.defaultValue;return A&&(null===(i=o.style.options)||void 0===i?void 0:i.some(function(t){return t.value===A}))&&(o.currentValue=A),o}return Ie(e,t),e.prototype.setValue=function(t){this.currentValue=t,this.render()},e.prototype.getValue=function(){return this.currentValue},Object.defineProperty(e.prototype,"dropdownPadding",{get:function(){return UW(this.style.dropdownPadding)},enumerable:!1,configurable:!0}),e.prototype.renderSelect=function(){var t,e=this,n=this.style,r=n.x,i=n.y,o=n.width,A=n.height,s=n.bordered,a=n.showDropdownIcon,c=PW(this.attributes,"select"),l=PW(this.attributes,"placeholder");this.select.attr(Le(Le({x:r,y:i,width:o,height:A},c),{fill:"#fff",strokeWidth:s?1:0}));var u=this.dropdownPadding;a&&QW(this.select).maybeAppend(".dropdown-icon","path").style("d","M-5,-3.5 L0,3.5 L5,-3.5").style("transform","translate(".concat(r+o-10-u[1]-u[3],", ").concat(i+A/2,")")).style("lineWidth",1).style("stroke",this.select.style.stroke);var h=null===(t=this.style.options)||void 0===t?void 0:t.find(function(t){return t.value===e.currentValue}),d=Le({x:r+u[3]},l);QW(this.select).selectAll(".placeholder").data(h?[]:[1]).join(function(t){return t.append("text").attr("className","placeholder").styles(d).style("y",function(){var t=this.getBBox();return i+(A-t.height)/2})},function(t){return t.styles(d)},function(t){return t.remove()});var f=PW(this.attributes,"optionLabel"),g=Le({x:r+u[3]},f);QW(this.select).selectAll(".value").data(h?[h]:[]).join(function(t){return t.append(function(t){return uW(t.label)}).attr("className","value").styles(g).style("y",function(){var t=this.getBBox();return i+(A-t.height)/2})},function(t){return t.styles(g)},function(t){return t.remove()})},e.prototype.renderDropdown=function(){var t,e,n=this,r=this.style,i=r.x,o=r.y,A=r.width,s=r.height,a=r.options,c=r.onSelect,l=r.open,u=PW(this.attributes,"dropdown"),h=PW(this.attributes,"option"),d=this.dropdownPadding;QW(this.dropdown).maybeAppend(".dropdown-container","g").attr("className","dropdown-container").selectAll(".dropdown-item").data(a,function(t){return t.value}).join(function(t){return t.append(function(t){return new C$({className:"dropdown-item",style:Le(Le(Le({},t),h),{width:A-d[1]-d[3],selected:t.value===n.currentValue,onClick:function(t,e,r){n.setValue(t),null==c||c(t,e,r),n.dispatchEvent(new Vs("change",{detail:{value:t,option:e,item:r}})),zV(n.dropdown)}})})}).each(function(t,e){var n,r=(null===(n=this.parentNode)||void 0===n?void 0:n.children).reduce(function(t,n,r){return r<e&&(t+=n.getBBox().height),t},0);this.attr("transform","translate(".concat(d[3],", ").concat(d[0]+r,")"))})},function(t){return t.update(function(t){return{selected:t.value===n.currentValue}})},function(t){return t.remove()});var f=null===(e=null===(t=this.dropdown.getElementsByClassName("dropdown-container"))||void 0===t?void 0:t[0])||void 0===e?void 0:e.getBBox(),g=u.spacing;this.dropdown.attr(Le({transform:"translate(".concat(i,", ").concat(o+s+g,")"),width:f.width+d[1]+d[3],height:f.height+d[0]+d[2]},u)),!l&&zV(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?zV(t.dropdown):jV(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||zV(t.dropdown)})},e.defaultOptions={style:{x:0,y:0,width:140,height:32,options:[],bordered:!0,defaultValue:"",selectRadius:8,selectStroke:"#d9d9d9",showDropdownIcon:!0,placeholderText:"请选择",placeholderFontSize:12,placeholderTextBaseline:"top",placeholderFill:"#c2c2c2",dropdownFill:"#fff",dropdownStroke:"#d9d9d9",dropdownRadius:8,dropdownShadowBlur:4,dropdownShadowColor:"rgba(0, 0, 0, 0.08)",dropdownPadding:8,dropdownSpacing:10,optionPadding:[8,12],optionFontSize:12,optionTextBaseline:"top",optionBackgroundFill:"#fff",optionBackgroundRadius:4,optionLabelFontSize:12,optionLabelTextBaseline:"top"}},e}(zW),F$=function(t){function e(n){var r=t.call(this,rW({},{style:{backgroundOpacity:e.backgroundOpacities.default}},e.defaultOptions,n))||this;return r.showBackground=!0,r.background=r.appendChild(new sc({})),r.icon=r.appendChild(new Xa({})),r}return Ie(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 UW(this.attributes.size/5)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"iconSize",{get:function(){var t=this.attributes.size,e=He(this.padding,4),n=e[0],r=e[1],i=e[2],o=e[3];return Math.max(t-Math.max(o+r,n+i),2*this.lineWidth+1)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.size,i=r/2,o=PW(this.attributes,"background");this.background.attr(Le({x:e-i,y:n-i,width:r,height:r},o))},e.prototype.showIndicator=function(){if(this.label){var t=this.attributes.size,e=this.background.getBBox(),n=e.x,r=e.y;this.indicator.update({x:n+t/2,y:r-5,labelText:this.label,visibility:"visible"})}},e.prototype.hideIndicator=function(){this.indicator.update({visibility:"hidden"})},e.prototype.connectedCallback=function(){var e;t.prototype.connectedCallback.call(this);var n=this.attributes.size,r=this.background.getBBox(),i=r.x,o=r.y,A=null===(e=this.ownerDocument)||void 0===e?void 0:e.defaultView;A&&(this.indicator=A.appendChild(new w$({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}(zW),k$=function(t,e){return void 0===e&&(e="#565758"),new nc({style:{fill:e,d:"M ".concat(t,",").concat(t," L -").concat(t,",0 L ").concat(t,",-").concat(t," Z"),transformOrigin:"center"}})},S$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),e.prototype.arcPath=function(t,e,n){var r=He([n,n],2),i=r[0],o=r[1],A=function(r){return[t+n*Math.cos(r),e+n*Math.sin(r)]},s=He(A(-5/4*Math.PI),2),a=s[0],c=s[1],l=He(A(1/4*Math.PI),2),u=l[0],h=l[1];return"M".concat(a,",").concat(c,",A").concat(i,",").concat(o,",0,1,1,").concat(u,",").concat(h)},Object.defineProperty(e.prototype,"label",{get:function(){return"重置"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,A=o+.5;QW(this.icon).maybeAppend(".reset","path").styles({stroke:r,lineWidth:o,d:this.arcPath(e,n,i/2-o),markerStart:k$(A,r)})},e}(F$),Q$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快退"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,A=i/2/Math.pow(3,.5),s=[[e,n],[e,n-A],[e-o,n],[e,n+A],[e,n],[e+o,n-A],[e+o,n+A],[e,n]];QW(this.icon).maybeAppend(".backward","polygon").styles({points:s,fill:r})},e}(F$),U$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"快进"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/2,A=i/2/Math.pow(3,.5),s=[[e,n],[e,n-A],[e+o,n],[e,n+A],[e,n],[e-o,n-A],[e-o,n+A],[e,n]];QW(this.icon).maybeAppend(".forward","polygon").styles({points:s,fill:r})},e}(F$),N$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"播放"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3*Math.pow(3,.5)*.8,A=[[e+o,n],[e-o/2,n-i/2*.8],[e-o/2,n+i/2*.8],[e+o,n]];QW(this.icon).maybeAppend(".play","polygon").styles({points:A,fill:r})},e}(F$),T$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"暂停"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=i/3,A=[[e-o,n-i/2],[e-o,n+i/2],[e-o/2,n+i/2],[e-o/2,n-i/2],[e-o,n-i/2],[e+o/2,n-i/2],[e+o/2,n+i/2],[e+o,n+i/2],[e+o,n-i/2]];QW(this.icon).maybeAppend(".pause","polygon").styles({points:A,fill:r})},e}(F$),O$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"范围时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,A=o;QW(this.icon).maybeAppend(".left-line","line").styles({x1:e-i/2,y1:n-i/2,x2:e-i/2,y2:n+i/2,stroke:r,lineWidth:o}),QW(this.icon).maybeAppend(".right-line","line").styles({x1:e+i/2,y1:n-i/2,x2:e+i/2,y2:n+i/2,stroke:r,lineWidth:o}),QW(this.icon).maybeAppend(".left-arrow","line").styles({x1:e,y1:n,x2:e-i/2+2*A,y2:n,stroke:r,lineWidth:o,markerEnd:k$(2*o,r)}),QW(this.icon).maybeAppend(".right-arrow","line").styles({x1:e,y1:n,x2:e+i/2-2*A,y2:n,stroke:r,lineWidth:o,markerEnd:k$(2*o,r)})},e}(F$),I$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"单一时间"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;QW(this.icon).maybeAppend(".line","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o});var A=o;QW(this.icon).maybeAppend(".left-arrow","line").styles({x1:e-i/2-2*A,y1:n,x2:e-2*A,y2:n,stroke:r,lineWidth:o,markerEnd:k$(2*o,r)}),QW(this.icon).maybeAppend(".right-arrow","line").styles({x1:e+i/2+2*A,y1:n,x2:e+2*A,y2:n,stroke:r,lineWidth:o,markerEnd:k$(2*o,r)})},e}(F$),L$=function(t){return[[-t/2,-t/2],[-t/2,t/2],[t/2,t/2]]},P$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"折线图"},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth,A=(i-2*o-o)/4,s=(i-2*o-o)/2,a=He([e-i/2+o,n+i/2-2*o],2),c=a[0],l=a[1];QW(this.icon).maybeAppend(".coordinate","polyline").styles({points:L$(i).map(function(t){var r=He(t,2),i=r[0],o=r[1];return[i+e,o+n]}),stroke:r,lineWidth:o}),QW(this.icon).maybeAppend(".line","polyline").styles({points:[[c,l],[c+A,l-s],[c+2*A,l],[c+4*A,l-2*s]],stroke:r,lineWidth:o})},e}(F$),D$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Ie(e,t),Object.defineProperty(e.prototype,"label",{get:function(){return"条形图"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"data",{get:function(){return[1,4,2,4,3]},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.data,e=this.attributes,n=e.x,r=e.y,i=e.color,o=this.iconSize,A=this.lineWidth,s=A,a=(o-s)/t.length,c=(o-2*s)/4,l=He([n-o/2+2*s,r+o/2-s],2),u=l[0],h=l[1];QW(this.icon).maybeAppend(".coordinate","polyline").styles({points:L$(o).map(function(t){var e=He(t,2),i=e[0],o=e[1];return[i+n,o+r]}),stroke:i,lineWidth:A}),QW(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 u+a*e}).style("y1",h).style("x2",function(t){var e=t.index;return u+a*e}).style("y2",function(t){var e=t.value;return h-c*e}).styles({y1:h,stroke:i,lineWidth:A})})},e}(F$),R$=function(t){function e(e){var n=t.call(this,rW({},{style:{color:"#d8d9d9"}},e))||this;return n.showBackground=!1,n}return Ie(e,t),e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.color,i=this.iconSize,o=this.lineWidth;QW(this.icon).maybeAppend(".split","line").styles({x1:e,y1:n-i/2,x2:e,y2:n+i/2,stroke:r,lineWidth:o})},e}(F$),H$=function(t){function e(){var e=t.apply(this,_e([],He(arguments),!1))||this;return e.showBackground=!1,e}return Ie(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return UW(0)},enumerable:!1,configurable:!0}),e.prototype.renderIcon=function(){var t=this.iconSize,e=this.attributes,n=e.x,r=e.y,i=e.speed,o=void 0===i?1:i,A=Se(this.attributes,["x","y","transform","transformOrigin","width","height","size","color","speed"]),s=ne(t,20,1/0),a=Le(Le({},A),{x:n-s/2,y:r-10,width:s,height:20,defaultValue:o,bordered:!1,showDropdownIcon:!1,selectRadius:2,dropdownPadding:this.padding,dropdownRadius:2,dropdownSpacing:t/5,placeholderFontSize:t/2,optionPadding:0,optionLabelFontSize:t/2,optionBackgroundRadius:1,options:[{label:"1x",value:1},{label:"1.5x",value:1.5},{label:"2x",value:2}]});QW(this.icon).maybeAppend(".speed",function(){return new M$({style:a})}).attr("className","speed").each(function(){this.update(a)})},e.tag="SpeedSelect",e}(F$),_$=function(t){function e(e){var n=t.call(this,e)||this;return n.icon=n.appendChild(new Xa({})),n.currentType=n.attributes.type,n}return Ie(e,t),e.prototype.getType=function(){return this.currentType},e.prototype.render=function(){var t=this,e=this.attributes;e.onChange;var n=Pe(e,["onChange"]);QW(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 He(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 He(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}(zW),G$=function(t){function e(e){var n=t.call(this,rW({},{style:{type:"play"}},e))||this;return n.toggles=[["play",N$],["pause",T$]],n}return Ie(e,t),e}(_$),K$=function(t){function e(e){var n=t.call(this,rW({},{style:{type:"range"}},e))||this;return n.toggles=[["range",O$],["value",I$]],n}return Ie(e,t),e}(_$),j$=function(t){function e(e){var n=t.call(this,rW({},{style:{type:"column"}},e))||this;return n.toggles=[["line",P$],["column",D$]],n}return Ie(e,t),e}(_$),z$={reset:S$,speed:H$,backward:Q$,playPause:G$,forward:U$,selectionType:K$,chartType:j$,split:R$},V$=function(t){function e(n){var r=t.call(this,rW({},e.defaultOptions,n))||this;return r.background=r.appendChild(new sc({})),r.functions=r.appendChild(new Xa({})),r}return Ie(e,t),Object.defineProperty(e.prototype,"padding",{get:function(){return UW(this.attributes.padding)},enumerable:!1,configurable:!0}),e.prototype.renderBackground=function(){var t=this.style,e=t.x,n=t.y,r=t.width,i=t.height,o=PW(this.attributes,"background");this.background.attr(Le({x:e,y:n,width:r,height:i},o))},e.prototype.renderFunctions=function(){var t,e=this,n=this.attributes,r=n.functions,i=n.iconSize,o=n.iconSpacing,A=n.x,s=n.y,a=n.width,c=n.height,l=n.align,u=He(this.padding,4),h=u[1],d=u[3],f=r.reduce(function(t,e){return t.length&&e.length?t.concat.apply(t,_e(["split"],He(e),!1)):t.concat.apply(t,_e([],He(e),!1))},[]),g=f.length*(i+o)-o,p={left:d+i/2,center:(a-g)/2+i/2,right:a-g-d-h+i/2}[l]||0;null===(t=this.speedSelect)||void 0===t||t.destroy(),this.functions.removeChildren(),f.forEach(function(t,n){var r,a=z$[t],l={x:A+n*(i+o)+p,y:s+c/2,size:i};if(a===H$?(l.speed=e.attributes.speed,l.onSelect=function(n){return e.handleFunctionChange(t,{value:n})}):[G$,K$,j$].includes(a)?(l.onChange=function(n){return e.handleFunctionChange(t,{value:n})},a===G$&&(l.type="play"===e.attributes.state?"pause":"play"),a===K$&&(l.type="range"===e.attributes.selectionType?"value":"range"),a===j$&&(l.type="line"===e.attributes.chartType?"column":"line")):l.onClick=function(){return e.handleFunctionChange(t,{value:t})},a===H$){var u=null===(r=e.ownerDocument)||void 0===r?void 0:r.defaultView;u&&(e.speedSelect=new a({style:Le(Le({},l),{zIndex:100})}),u.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:{x:0,y:0,width:300,height:40,padding:0,align:"center",iconSize:25,iconSpacing:0,speed:1,state:"pause",chartType:"line",selectionType:"range",backgroundFill:"#fbfdff",backgroundStroke:"#ebedf0",functions:[["reset","speed"],["backward","playPause","forward"],["selectionType","chartType"]]}},e}(zW),W$=function(t){function e(n){var r=t.call(this,rW({},e.defaultOptions,n))||this;return r.bindEvents(),r}return Ie(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}(za),Y$=function(t){function e(n){return t.call(this,rW({},e.defaultOptions,n))||this}return Ie(e,t),e.prototype.renderBackground=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=PW(this.attributes,"background");QW(this).maybeAppend("background","rect").attr("className","background").styles(Le({x:e-r/2,y:n-i/2,width:r,height:i},o))},e.prototype.renderIcon=function(){var t=this.attributes,e=t.x,n=t.y,r=t.iconSize,i=PW(this.attributes,"icon"),o=r/2;QW(this).maybeAppend("icon-left-line","line").attr("className","icon-left-line").styles(Le({x1:e-1,y1:n-o,x2:e-1,y2:n+o},i)),QW(this).maybeAppend("icon-right-line","line").attr("className","icon-right-line").styles(Le({x1:e+1,y1:n-o,x2:e+1,y2:n+o},i))},e.prototype.renderBorder=function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,A=PW(this.attributes,"border"),s="start"===o?+r/2:-r/2;QW(this).maybeAppend("border","line").attr("className","border").styles(Le({x1:s+e,y1:n-i/2,x2:s+e,y2:n+i/2},A))},e.prototype.render=function(){this.renderBackground(),this.renderIcon(),this.renderBorder()},e.defaultOptions={style:{x:0,y:0,width:10,height:50,iconSize:10,type:"start",backgroundFill:"#fff",backgroundFillOpacity:.5,iconStroke:"#9a9a9a",iconLineWidth:1,borderStroke:"#e8e8e8",borderLineWidth:1}},e}(zW);function X$(t,e){return"number"==typeof t?q$(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()?HW(n,"HH:mm\nYYYY-MM-DD"):HW(n,"HH:mm");case"half-day":return n.getHours()<12?"AM\n".concat(HW(n,"YYYY-MM-DD")):"PM";case"day":return[1,10,20].includes(n.getDate())?HW(n,"DD\nYYYY-MM"):HW(n,"DD");case"week":return n.getDate()<=7?HW(n,"DD\nYYYY-MM"):HW(n,"DD");case"month":return[0,6].includes(n.getMonth())?HW(n,"MM月\nYYYY"):HW(n,"MM月");case"season":return[0].includes(n.getMonth())?HW(n,"MM月\nYYYY"):HW(n,"MM月");case"year":return HW(n,"YYYY");default:return HW(n,"YYYY-MM-DD HH:mm")}}(t,e)}function q$(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 $$=function(t){function e(n){var r=t.call(this,rW({},e.defaultOptions,n))||this;r.axis=r.appendChild(new Nq({style:{type:"linear",startPos:[0,0],endPos:[0,0],data:[],showArrow:!1,animate:!1}})),r.timeline=r.appendChild(new fX({style:{onChange:function(t){r.handleSliderChange(t)}}})),r.controller=r.appendChild(new V$({})),r.states={},r.handleSliderChange=function(t){var e,n=(e=r.states.values,Array.isArray(e)?_e([],He(e),!1):e);r.setBySliderValues(t),r.dispatchOnChange(n)};var i=r.attributes,o=i.selectionType,A=i.chartType,s=i.speed,a=i.state,c=i.playMode,l=i.values;return r.states={chartType:A,playMode:c,selectionType:o,speed:s,state:a},r.setByTimebarValues(l),r}return Ie(e,t),Object.defineProperty(e.prototype,"data",{get:function(){return this.attributes.data.sort(function(t,e){return t.time<e.time?-1:t.time>e.time?1:0})},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"space",{get:function(){var t=this.attributes,e=t.x,n=t.y,r=t.width,i=t.height,o=t.type,A=t.controllerHeight,s=ne(+i-A,0,+i),a=new ZV(e,n+ +i-A,+r,A),c=0,l="time"===o?10:s;return{axisBBox:"chart"===o?new ZV(e,n+s-(c=35),+r,c):new ZV,controllerBBox:a,timelineBBox:new ZV(e,n+("time"===o?s:s-l),+r,l-c)}},enumerable:!1,configurable:!0}),e.prototype.setBySliderValues=function(t){var e,n,r=this.data,i=He(Array.isArray(t)?t:[0,t],2),o=i[0],A=i[1],s=r.length,a=r[Math.floor(o*s)],c=r[Math.ceil(A*s)-(Array.isArray(t)?0:1)];this.states.values=[null!==(e=null==a?void 0:a.time)&&void 0!==e?e:r[0].time,null!==(n=null==c?void 0:c.time)&&void 0!==n?n:1/0]},e.prototype.setByTimebarValues=function(t){var e,n,r,i=this.data,o=He(Array.isArray(t)?t:[void 0,t],2),A=o[0],s=o[1],a=i.find(function(t){return t.time===A}),c=i.find(function(t){return t.time===s});this.states.values=[null!==(e=null==a?void 0:a.time)&&void 0!==e?e:null===(n=i[0])||void 0===n?void 0:n.time,null!==(r=null==c?void 0:c.time)&&void 0!==r?r:1/0]},e.prototype.setByIndex=function(t){var e,n,r,i,o=this.data,A=He(t,2),s=A[0],a=A[1];this.states.values=[null!==(n=null===(e=o[s])||void 0===e?void 0:e.time)&&void 0!==n?n:o[0].time,null!==(i=null===(r=this.data[a])||void 0===r?void 0:r.time)&&void 0!==i?i:1/0]},Object.defineProperty(e.prototype,"sliderValues",{get:function(){var t,e=this.states,n=e.values,r=e.selectionType,i=He(Array.isArray(n)?n:[void 0,n],2),o=i[0],A=i[1],s=this.data,a=s.length,c="value"===r;return[(t=s.findIndex(function(t){return t.time===o}),c?0:t>-1?t/a:0),function(){if(A===1/0)return 1;var t=s.findIndex(function(t){return t.time===A});return t>-1?t/a:c?.5:1}()]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"values",{get:function(){var t=this.states,e=t.values,n=t.selectionType,r=He(Array.isArray(e)?e:[this.data[0].time,e],2),i=r[0],o=r[1];return"value"===n?o:[i,o]},enumerable:!1,configurable:!0}),e.prototype.getDatumByRatio=function(t){var e=this.data,n=e.length;return e[Math.floor(t*(n-1))]},Object.defineProperty(e.prototype,"chartHandleIconShape",{get:function(){var t=this.states.selectionType,e=this.space.timelineBBox.height;return"range"===t?function(t){return new Y$({style:{type:t,height:e,iconSize:e/6}})}:function(){return new tc({style:{x1:0,y1:-e/2,x2:0,y2:e/2,lineWidth:2,stroke:"#c8c8c8"}})}},enumerable:!1,configurable:!0}),e.prototype.getChartStyle=function(t){var e=this,n=t.x,r=t.y,i=t.width,o=t.height,A=this.states,s=A.selectionType,a=A.chartType,c=this.data,l=this.attributes,u=l.type,h=l.labelFormatter,d=PW(this.attributes,"chart");d.type;var f=Pe(d,["type"]),g="range"===s;if("time"===u)return Le({handleIconShape:function(){return new W$({})},selectionFill:"#2e7ff8",selectionFillOpacity:1,showLabelOnInteraction:!0,handleLabelDy:g?-15:0,autoFitLabel:g,handleSpacing:g?-15:0,trackFill:"#edeeef",trackLength:i,trackOpacity:.5,trackRadius:o/2,trackSize:o/2,type:s,values:this.sliderValues,formatter:function(t){if(h)return h(t);var n=e.getDatumByRatio(t).time;return"number"==typeof n?q$(n):HW(n,"YYYY-MM-DD HH:mm:ss")},transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},f);var p="range"===s?5:0,v=c.map(function(t){return t.value});return Le({handleIconOffset:p,handleIconShape:this.chartHandleIconShape,selectionFill:"#fff",selectionFillOpacity:.5,selectionType:"invert",sparklineSpacing:.1,sparklineColumnLineWidth:0,sparklineColor:"#d4e5fd",sparklineAreaOpacity:1,sparklineAreaLineWidth:0,sparklineData:v,sparklineType:a,sparklineScale:.8,trackLength:i,trackSize:o,type:s,values:this.sliderValues,transform:"translate(".concat(n,", ").concat(r,")"),zIndex:1},f)},e.prototype.renderChart=function(t){void 0===t&&(t=this.space.timelineBBox),this.timeline.update(this.getChartStyle(t))},e.prototype.updateSelection=function(){this.timeline.setValues(this.sliderValues,!0),this.handleSliderChange(this.sliderValues)},e.prototype.getAxisStyle=function(t){var e=this.data,n=this.attributes,r=n.interval,i=n.labelFormatter,o=PW(this.attributes,"axis"),A=t.x,s=t.y,a=t.width,c=_e(_e([],He(e),!1),[{time:0}],!1).map(function(t,e,n){var r=t.time;return{label:"".concat(r),value:e/(n.length-1),time:r}}),l=Le({startPos:[A,s],endPos:[A+a,s],data:c,labelFilter:function(t,e){return e<c.length-1},labelFormatter:function(t){var e=t.time;return i?i(e):X$(e,r)}},o);return l},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=PW(this.attributes,"controller"),a=this,c=Le(Le(Le({},t),{iconSize:20,speed:i,state:r,selectionType:o,chartType:A,onChange:function(t,e){var n=e.value;switch(t){case"reset":a.internalReset();break;case"speed":a.handleSpeedChange(n);break;case"backward":a.internalBackward();break;case"playPause":"play"===n?a.internalPlay():a.internalPause();break;case"forward":a.internalForward();break;case"selectionType":a.handleSelectionTypeChange(n);break;case"chartType":a.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=He(i,2),s=A[0],a=A[1],c=a===1/0?e.at(-1).time:a;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,a=He(o,2),c=a[0],l=a[1],u=n.findIndex(function(t){return t.time===c}),h=n.findIndex(function(t){return t.time===l});-1===h&&(h=r);var d,f="backward"===t?-1:1;"range"===A?"acc"===s?(d=[u,h+f],-1===f&&u===h&&(d=[u,r])):d=[u+f,h+f]:d=[u,h+f];var g=function(t){var e=He(t.sort(function(t,e){return t-e}),2),n=e[0],i=e[1],o=function(t){return ne(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)]}(d);return this.setByIndex(g),this.updateSelection(),g},e.prototype.internalBackward=function(t){var e,n,r=this.moveSelection("backward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onBackward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.backward=function(){this.internalBackward()},e.prototype.internalPlay=function(t){var e,n,r=this,i=this.data,o=this.attributes.loop,A=this.states.speed,s=void 0===A?1:A;this.playInterval=window.setInterval(function(){r.internalForward()[1]!==i.length||o||(r.internalPause(),r.renderController())},1e3/s),this.states.state="play",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPlay)||void 0===n||n.call(e))},e.prototype.play=function(){this.internalPlay()},e.prototype.internalPause=function(t){var e,n;clearInterval(this.playInterval),this.states.state="pause",!t&&(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onPause)||void 0===n||n.call(e))},e.prototype.pause=function(){this.internalPause()},e.prototype.internalForward=function(t){var e,n,r=this.moveSelection("forward",t);return t||(null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onForward)||void 0===n||n.call(e),this.dispatchOnChange()),r},e.prototype.forward=function(){this.internalForward()},e.prototype.handleSpeedChange=function(t){var e,n;this.states.speed=t,"play"===this.states.state&&(this.internalPause(!0),this.internalPlay(!0)),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSpeedChange)||void 0===n||n.call(e,t)},e.prototype.handleSelectionTypeChange=function(t){var e,n;this.states.selectionType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onSelectionTypeChange)||void 0===n||n.call(e,t)},e.prototype.handleChartTypeChange=function(t){var e,n;this.states.chartType=t,this.renderChart(),null===(n=null===(e=this.attributes)||void 0===e?void 0:e.onChartTypeChange)||void 0===n||n.call(e,t)},e.prototype.render=function(){var t=this.space,e=t.axisBBox,n=t.controllerBBox,r=t.timelineBBox;this.renderController(n),this.renderAxis(e),this.renderChart(r),"play"===this.states.state&&this.internalPlay()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.internalPause(!0)},e.defaultOptions={style:{x:0,y:0,axisLabelFill:"#6e6e6e",axisLabelTextAlign:"left",axisLabelTextBaseline:"top",axisLabelTransform:"translate(5, -12)",axisLineLineWidth:1,axisLineStroke:"#cacdd1",axisTickLength:15,axisTickLineWidth:1,axisTickStroke:"#cacdd1",chartShowLabel:!1,chartType:"line",controllerAlign:"center",controllerHeight:40,data:[],interval:"day",loop:!1,playMode:"acc",selectionType:"range",type:"time"}},e}(zW);function Z$(t){const{width:e,height:n,renderer:r}=t,i=function(t){var e;const{container:n,className:r,graphCanvas:i}=t;if(n)return"string"==typeof n?document.getElementById(n):n;const o=ez(r,!1),{width:A,height:s,containerStyle:a}=t,[c,l]=function(t){const{width:e,height:n,placement:r,graphCanvas:i}=t,[o,A]=i.getSize(),[s,a]=Cy(r);return[s*(o-e),a*(A-n)]}(t);return Object.assign(o.style,Object.assign({position:"absolute",left:c+"px",top:l+"px",width:A+"px",height:s+"px"},a)),null===(e=i.getContainer())||void 0===e||e.appendChild(o),o}(t);return[i,new xc({width:e,height:n,container:i,renderer:r||new _b})]}class J$ extends tz{constructor(e,n){super(e,Object.assign({},J$.defaultOptions,n)),this.typePrefix="__data__",this.draw=!1,this.fieldMap={node:new Map,edge:new Map,combo:new Map},this.selectedItems=[],this.bindEvents=()=>{const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.createElement)},this.changeState=(t,e)=>{const{graph:n}=this.context,{typePrefix:r}=this,i=Ce(t,[r,"id"]),o=Ce(t,[r,"style","labelText"]),[A]=i.split("__"),s=this.fieldMap[A].get(o)||[];n.setElementState(Object.fromEntries(null==s?void 0:s.map(t=>[t,e])))},this.click=t=>{if("hover"===this.options.trigger)return;const e=Ce(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?(this.selectedItems=this.selectedItems.filter(t=>t!==e),this.changeState(t,[])):(this.selectedItems.push(e),this.changeState(t,"selected"))},this.mouseleave=t=>{"click"!==this.options.trigger&&(this.selectedItems=[],this.changeState(t,[]))},this.mouseenter=t=>{if("click"===this.options.trigger)return;const e=Ce(t,[this.typePrefix,"id"]);this.selectedItems.includes(e)?this.selectedItems=this.selectedItems.filter(t=>t!==e):(this.selectedItems.push(e),this.changeState(t,"active"))},this.setFieldMap=(t,e,n)=>{if(!t)return;const r=this.fieldMap[n];if(r)if(r.has(t)){const n=r.get(t);n&&(n.push(e),r.set(t,n))}else r.set(t,[e])},this.getEvents=()=>({mouseenter:this.mouseenter,mouseleave:this.mouseleave,click:this.click}),this.getMarkerData=(t,e)=>{if(!t)return[];const{model:n,element:r}=this.context,{nodes:i,edges:o,combos:A}=n.getData(),s={},a=e=>Gt(t)?t(e):t,c={node:"circle",edge:"line",combo:"rect"},l={circle:"circle",ellipse:"circle",image:"bowtie",rect:"square",star:"cross",triangle:"triangle",diamond:"diamond",cubic:"dot",line:"hyphen",polyline:"hyphen",quadratic:"hv","cubic-horizontal":"hyphen","cubic-vertical":"line"},u=(t,e)=>{t.forEach(t=>{const{id:n}=t,i=Ce(t,["data",a(t)]),o=(null==r?void 0:r.getElementType(e,t))||"circle",A=((t,e)=>null==r?void 0:r.getElementComputedStyle(t,e))(e,t),u=("edge"===e?null==A?void 0:A.stroke:null==A?void 0:A.fill)||"#1783ff";n&&i&&i.replace(/\s+/g,"")&&(this.setFieldMap(i,n,e),s[i]||(s[i]={id:`${e}__${n}`,label:i,marker:l[o]||c[e],elementType:e,lineWidth:1,stroke:u,fill:u}))})};switch(e){case"node":u(i,"node");break;case"edge":u(o,"edge");break;case"combo":u(A,"combo");break;default:return[]}return Object.values(s)},this.createElement=()=>{if(this.draw)return void this.updateElement();const t=this.options,{width:e,height:n,nodeField:r,edgeField:i,comboField:o,trigger:A,position:s,container:a,containerStyle:c,className:l}=t,u=Pe(t,["width","height","nodeField","edgeField","comboField","trigger","position","container","containerStyle","className"]),h=this.getMarkerData(r,"node"),d=this.getMarkerData(i,"edge"),f=this.getMarkerData(o,"combo"),g=[...h,...f,...d],p=Object.assign({width:e,height:n,data:g,itemMarkerLineWidth:({lineWidth:t})=>t,itemMarker:({marker:t})=>t,itemMarkerStroke:({stroke:t})=>t,itemMarkerFill:({fill:t})=>t,gridCol:h.length},u,this.getEvents()),v=new v$({className:"legend",style:p});this.category=v;this.upsertCanvas().appendChild(v),this.draw=!0},this.bindEvents()}update(t){super.update(t),this.clear(),this.createElement()}clear(){var t,e;null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.container)||void 0===e||e.remove(),this.canvas=void 0,this.container=void 0,this.draw=!1}updateElement(){this.category&&this.category.update({itemMarkerOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5,itemLabelOpacity:({id:t})=>!this.selectedItems.length||this.selectedItems.includes(t)?1:.5})}upsertCanvas(){if(this.canvas)return this.canvas;const t=this.context.canvas,[e,n]=t.getSize(),{width:r=e,height:i=n,position:o,container:A,containerStyle:s,className:a}=this.options,[c,l]=Z$({width:r,height:i,graphCanvas:t,container:A,containerStyle:s,placement:o,className:"legend"});return this.container=c,a&&c.classList.add(a),this.canvas=l,this.canvas}destroy(){this.clear(),this.context.graph.off(t.GraphEvent.AFTER_DRAW,this.createElement),super.destroy()}}J$.defaultOptions={position:"bottom",trigger:"hover",orientation:"horizontal",layout:"flex",itemSpacing:4,rowPadding:10,colPadding:10,itemMarkerSize:16,itemLabelFontSize:16,width:240,height:160};class tZ extends tz{constructor(t,e){super(t,Object.assign({},tZ.defaultOptions,e)),this.onDraw=t=>{var e;(null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.render)||this.onRender()},this.landmarkMap=new Map,this.mask=null,this.isMaskDragging=!1,this.onMaskDragStart=t=>{this.mask&&(this.isMaskDragging=!0,this.mask.setPointerCapture(t.pointerId),this.mask.addEventListener("pointermove",this.onMaskDrag),this.mask.addEventListener("pointerup",this.onMaskDragEnd),this.mask.addEventListener("pointercancel",this.onMaskDragEnd))},this.onMaskDrag=t=>{if(!this.mask||!this.isMaskDragging)return;const{size:[e,n]}=this.options,{movementX:r,movementY:i}=t,{left:o,top:A,width:s,height:a}=this.mask.style,[,,c,l]=this.maskBBox;let u=parseInt(o)+r,h=parseInt(A)+i,d=parseInt(s),f=parseInt(a);u<0&&(u=0),h<0&&(h=0),u+d>e&&(u=nZ(e-d,0)),h+f>n&&(h=nZ(n-f,0)),d<c&&(r>0?(u=nZ(u-r,0),d=eZ(d+r,e)):r<0&&(d=eZ(d-r,e))),f<l&&(i>0?(h=nZ(h-i,0),f=eZ(f+i,n)):i<0&&(f=eZ(f-i,n))),Object.assign(this.mask.style,{left:u+"px",top:h+"px",width:d+"px",height:f+"px"});const g=parseInt(o)-u,p=parseInt(A)-h;if(0===g&&0===p)return;const v=this.context.canvas.getCamera().getZoom()/this.canvas.getCamera().getZoom();this.context.graph.translateBy([g*v,p*v],!1)},this.onMaskDragEnd=t=>{this.mask&&(this.isMaskDragging=!1,this.mask.releasePointerCapture(t.pointerId),this.mask.removeEventListener("pointermove",this.onMaskDrag),this.mask.removeEventListener("pointerup",this.onMaskDragEnd),this.mask.removeEventListener("pointercancel",this.onMaskDragEnd))},this.onTransform=Qe(()=>{this.isMaskDragging||(this.updateMask(),this.setCamera())},32,{leading:!0}),this.setOnRender(),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),"delay"in t&&this.setOnRender(),this.bindEvents()}setOnRender(){this.onRender=pe(()=>{this.renderMinimap(),this.renderMask()},this.options.delay)}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.onDraw),e.on(t.GraphEvent.AFTER_RENDER,this.onRender),e.on(t.GraphEvent.AFTER_ANIMATE,this.onRender),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.onDraw),e.off(t.GraphEvent.AFTER_RENDER,this.onRender),e.off(t.GraphEvent.AFTER_ANIMATE,this.onRender),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}renderMinimap(){const t=this.getElements(),e=this.initCanvas();this.setShapes(e,t)}getElements(){const{filter:t}=this.options,{model:e,element:n}=this.context,r=e.getData(),i={nodes:r.nodes.filter(t=>null==n?void 0:n.getElement(Km(t))),edges:r.edges.filter(t=>{const e=null==n?void 0:n.getElement(Km(t));return e&&JB(e)}),combos:r.combos.filter(t=>null==n?void 0:n.getElement(Km(t)))};if(!t)return i;const{nodes:o,edges:A,combos:s}=i;return{nodes:o.filter(e=>t(Km(e),"node")),edges:A.filter(e=>t(Km(e),"edge")),combos:s.filter(e=>t(Km(e),"combo"))}}setShapes(t,e){const{nodes:n,edges:r,combos:i}=e,{shape:o}=this.options,{element:A}=this.context,s=(e,n)=>{const r=Km(e),i=null==A?void 0:A.getElement(r);if(!i)return;const s=i.getShape("key");let a;if("string"==typeof o){const t=o;a=i.getShape(t).cloneNode()}else{const t=o(r,n,i);a=t===i?t.cloneNode(!0):t}a.setPosition(s.getPosition()),i.style.zIndex&&(a.style.zIndex=i.style.zIndex),a.id=i.id,t.appendChild(a)};t.removeChildren(),r.forEach(t=>s(t,"edge")),i.forEach(t=>s(t,"combo")),n.forEach(t=>s(t,"node"))}initCanvas(){const{renderer:t,size:[e,n]}=this.options;if(this.canvas){const{width:r,height:i}=this.canvas.getConfig();e===r&&n===i||this.canvas.resize(e,n),t&&this.canvas.setRenderer(t)}else{const{className:r,position:i,container:o,containerStyle:A}=this.options,[s,a]=Z$({renderer:t,width:e,height:n,placement:i,className:"minimap",container:o,containerStyle:A,graphCanvas:this.context.canvas});r&&s.classList.add(r),this.container=s,this.canvas=a}return this.setCamera(),this.canvas}createLandmark(t,e,n){const r=`${t.join(",")}-${e.join(",")}-${n}`;if(this.landmarkMap.has(r))return this.landmarkMap.get(r);const i=this.canvas.getCamera().createLandmark(r,{position:t,focalPoint:e,zoom:n});return this.landmarkMap.set(r,i),i}setCamera(){var t;const{canvas:e}=this.context,n=null===(t=this.canvas)||void 0===t?void 0:t.getCamera();if(!n)return;const{size:[r,i],padding:o}=this.options,[A,s,a,c]=pm(o),{min:l,max:u,center:h}=e.getBounds("elements"),d=(r-c-s)/(u[0]-l[0]),f=(i-A-a)/(u[1]-l[1]),g=Math.min(d,f),p=this.createLandmark(h,h,g);n.gotoLandmark(p,0)}get maskBBox(){const{canvas:t}=this.context,e=t.getSize(),n=t.getCanvasByViewport([0,0]),r=t.getCanvasByViewport(e),i=this.canvas.canvas2Viewport(Qy(n)),o=this.canvas.canvas2Viewport(Qy(r)),A=o.x-i.x,s=o.y-i.y;return[i.x,i.y,A,s]}calculateMaskBBox(){const{size:[t,e]}=this.options;let[n,r,i,o]=this.maskBBox;return n<0&&(i=eZ(i+n,t),n=0),r<0&&(o=eZ(o+r,e),r=0),n+i>t&&(i=nZ(t-n,0)),r+o>e&&(o=nZ(e-r,0)),[eZ(n,t),eZ(r,e),nZ(i,0),nZ(o,0)]}renderMask(){const{maskStyle:t}=this.options;this.mask||(this.mask=document.createElement("div"),this.mask.addEventListener("pointerdown",this.onMaskDragStart),this.mask.draggable=!0,this.mask.addEventListener("dragstart",t=>t.preventDefault&&t.preventDefault())),this.container.appendChild(this.mask),Object.assign(this.mask.style,Object.assign(Object.assign({},t),{cursor:"move",position:"absolute",pointerEvents:"auto"})),this.updateMask()}updateMask(){if(!this.mask)return;const[t,e,n,r]=this.calculateMaskBBox();Object.assign(this.mask.style,{top:e+"px",left:t+"px",width:n+"px",height:r+"px"})}destroy(){var t,e,n;this.unbindEvents(),null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.mask)||void 0===e||e.remove(),null===(n=this.container)||void 0===n||n.remove(),super.destroy()}}tZ.defaultOptions={size:[240,160],shape:"key",padding:10,position:"right-bottom",maskStyle:{border:"1px solid #ddd",background:"rgba(0, 0, 0, 0.1)"},containerStyle:{border:"1px solid #ddd",background:"#fff"},delay:128};const eZ=(t,e)=>Math.min(t,e),nZ=(t,e)=>Math.max(t,e),rZ={x1:0,y1:0,x2:0,y2:0,visibility:"hidden"};class iZ extends tz{constructor(t,e){super(t,Object.assign({},iZ.defaultOptions,e)),this.initSnapline=()=>{const t=this.context.canvas.getLayer("transient");this.horizontalLine||(this.horizontalLine=t.appendChild(new tc({style:Object.assign(Object.assign({},rZ),this.options.horizontalLineStyle)}))),this.verticalLine||(this.verticalLine=t.appendChild(new tc({style:Object.assign(Object.assign({},rZ),this.options.verticalLineStyle)})))},this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!0,this.autoSnapToLine=(t,e,n)=>De(this,void 0,void 0,function*(){const{verticalX:r,horizontalY:i}=n,{tolerance:o}=this.options,{min:[A,s],max:[a,c],center:[l,u]}=e;let h=0,d=0;null!==r&&(oZ(a,r)<o&&(h=r-a),oZ(A,r)<o&&(h=r-A),oZ(l,r)<o&&(h=r-l),0!==h&&(this.isVerticalSticking=!0)),null!==i&&(oZ(c,i)<o&&(d=i-c),oZ(s,i)<o&&(d=i-s),oZ(u,i)<o&&(d=i-u),0!==d&&(this.isHorizontalSticking=!0)),0===h&&0===d||(yield this.context.graph.translateElementBy({[t]:[h,d]},!1))}),this.enableSnap=t=>{const{target:e}=t,n=.5;if(this.isHorizontalSticking||this.isVerticalSticking){const[r,i]=this.getDelta(t);if(this.isHorizontalSticking&&this.isVerticalSticking&&Math.abs(r)<=n&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,-i]},!1),!1;if(this.isHorizontalSticking&&Math.abs(i)<=n)return this.context.graph.translateElementBy({[e.id]:[0,-i]},!1),!1;if(this.isVerticalSticking&&Math.abs(r)<=n)return this.context.graph.translateElementBy({[e.id]:[-r,0]},!1),!1;this.isHorizontalSticking=!1,this.isVerticalSticking=!1,this.enableStick=!1,setTimeout(()=>{this.enableStick=!0},200)}return this.enableStick},this.calcSnaplineMetadata=(t,e)=>{const{tolerance:n,shape:r}=this.options,{min:[i,o],max:[A,s],center:[a,c]}=e;let l=null,u=null,h=null,d=null,f=null,g=null;return this.getNodes().some(e=>{if(xe(t.id,e.id))return!1;const p=AZ(e,r).getRenderBounds(),{min:[v,m],max:[y,w],center:[b,B]}=p;return null===l&&(oZ(b,a)<n?l=b:oZ(v,i)<n||oZ(v,A)<n?l=v:(oZ(y,A)<n||oZ(y,i)<n)&&(l=y),null!==l&&(u=Math.min(m,o),h=Math.max(w,s))),null===d&&(oZ(B,c)<n?d=B:oZ(m,o)<n||oZ(m,s)<n?d=m:(oZ(w,s)<n||oZ(w,o)<n)&&(d=w),null!==d&&(f=Math.min(v,i),g=Math.max(y,A))),null!==l&&null!==d}),{verticalX:l,verticalMinY:u,verticalMaxY:h,horizontalY:d,horizontalMinX:f,horizontalMaxX:g}},this.onDragStart=()=>{this.initSnapline()},this.onDrag=t=>De(this,void 0,void 0,function*(){const{target:e}=t;if(this.options.autoSnap){if(!this.enableSnap(t))return}const n=AZ(e,this.options.shape).getRenderBounds(),r=this.calcSnaplineMetadata(e,n);this.hideSnapline(),null===r.verticalX&&null===r.horizontalY||this.updateSnapline(r),this.options.autoSnap&&(yield this.autoSnapToLine(e.id,n,r))}),this.onDragEnd=()=>{this.hideSnapline()},this.bindEvents()}getNodes(){var t;const{filter:e}=this.options,n=((null===(t=this.context.element)||void 0===t?void 0:t.getNodes())||[]).filter(t=>{var e;return JB(t)&&(null===(e=this.context.viewport)||void 0===e?void 0:e.isInViewport(t.getRenderBounds()))});return e?n.filter(t=>e(t)):n}hideSnapline(){this.horizontalLine.style.visibility="hidden",this.verticalLine.style.visibility="hidden"}getLineWidth(t){const{lineWidth:e}=this.options[`${t}LineStyle`];return+(e||rZ.lineWidth||1)/this.context.graph.getZoom()}updateSnapline(t){const{verticalX:e,verticalMinY:n,verticalMaxY:r,horizontalY:i,horizontalMinX:o,horizontalMaxX:A}=t,[s,a]=this.context.canvas.getSize(),{offset:c}=this.options;null!==i?Object.assign(this.horizontalLine.style,{x1:c===1/0?0:o-c,y1:i,x2:c===1/0?s:A+c,y2:i,visibility:"visible",lineWidth:this.getLineWidth("horizontal")}):this.horizontalLine.style.visibility="hidden",null!==e?Object.assign(this.verticalLine.style,{x1:e,y1:c===1/0?0:n-c,x2:e,y2:c===1/0?a:r+c,visibility:"visible",lineWidth:this.getLineWidth("vertical")}):this.verticalLine.style.visibility="hidden"}getDelta(t){const e=this.context.graph.getZoom();return uy([t.dx,t.dy],e)}bindEvents(){return De(this,void 0,void 0,function*(){const{graph:e}=this.context;e.on(t.NodeEvent.DRAG_START,this.onDragStart),e.on(t.NodeEvent.DRAG,this.onDrag),e.on(t.NodeEvent.DRAG_END,this.onDragEnd)})}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.DRAG_START,this.onDragStart),e.off(t.NodeEvent.DRAG,this.onDrag),e.off(t.NodeEvent.DRAG_END,this.onDragEnd)}destroyElements(){var t,e;null===(t=this.horizontalLine)||void 0===t||t.destroy(),null===(e=this.verticalLine)||void 0===e||e.destroy()}destroy(){this.destroyElements(),this.unbindEvents(),super.destroy()}}iZ.defaultOptions={tolerance:5,offset:20,autoSnap:!0,shape:"key",verticalLineStyle:{stroke:"#1783FF"},horizontalLineStyle:{stroke:"#1783FF"},filter:()=>!0};const oZ=(t,e)=>Math.abs(t-e),AZ=(t,e)=>"function"==typeof e?e(t):t.getShape(e),sZ=["timestamp","time","date","datetime"];class aZ extends tz{get padding(){return pm(this.options.padding)}constructor(t,e){super(t,Object.assign({},aZ.defaultOptions,e)),this.backup(),this.upsertTimebar()}play(){var t;null===(t=this.timebar)||void 0===t||t.play()}pause(){var t;null===(t=this.timebar)||void 0===t||t.pause()}forward(){var t;null===(t=this.timebar)||void 0===t||t.forward()}backward(){var t;null===(t=this.timebar)||void 0===t||t.backward()}reset(){var t;null===(t=this.timebar)||void 0===t||t.reset()}update(t){super.update(t),this.backup(),this.upsertTimebar()}backup(){this.originalData=cZ(this.context.graph.getData())}upsertTimebar(){const{canvas:t}=this.context,e=this.options,{onChange:n,timebarType:r,data:i,x:o,y:A,width:s,height:a,mode:c}=e,l=Pe(e,["onChange","timebarType","data","x","y","width","height","mode"]),u=t.getSize(),[h]=this.padding;this.upsertCanvas().ready.then(()=>{var t;const e=Object.assign(Object.assign({x:u[0]/2-s/2,y:h,onChange:t=>{const e=(jt(t)?t:[t,t]).map(t=>function(t){return t instanceof Date}(t)?t.getTime():t);"modify"===this.options.mode?this.filterElements(e):this.hiddenElements(e),null==n||n(e)}},l),{data:i.map(t=>re(t)?{time:t,value:0}:t),width:s,height:a,type:r});this.timebar?this.timebar.update(e):(this.timebar=new $$({style:e}),null===(t=this.canvas)||void 0===t||t.appendChild(this.timebar))})}upsertCanvas(){if(this.canvas)return this.canvas;const{className:t,height:e,position:n}=this.options,r=this.context.canvas,[i]=r.getSize(),[o,,A]=this.padding,[s,a]=Z$({width:i,height:e+o+A,graphCanvas:r,className:"timebar",placement:n});return this.container=s,t&&s.classList.add(t),this.canvas=a,this.canvas}filterElements(t){return De(this,void 0,void 0,function*(){var e;if(!this.originalData)return;const{elementTypes:n,getTime:r}=this.options,{graph:i,element:o}=this.context,A=cZ(this.originalData);n.forEach(e=>{const n=`${e}s`;A[n]=(this.originalData[n]||[]).filter(e=>{const n=r(e);return!!lZ(n,t)})});const s=[...A.nodes,...A.combos].map(t=>Km(t));A.edges=A.edges.filter(t=>{const e=t.source,n=t.target;return s.includes(e)&&s.includes(n)}),i.setData(A),yield null===(e=o.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished})}hiddenElements(t){const{graph:e}=this.context,{elementTypes:n,getTime:r}=this.options,i=[],o=[];n.forEach(e=>{var n;const A=`${e}s`;((null===(n=this.originalData)||void 0===n?void 0:n[A])||[]).forEach(e=>{const n=Km(e),A=r(e);lZ(A,t)?o.push(n):i.push(n)})}),e.hideElement(i,!1),e.showElement(o,!1)}destroy(){var t,e,n;const{graph:r}=this.context;this.originalData&&r.setData(Object.assign({},this.originalData)),null===(t=this.timebar)||void 0===t||t.destroy(),null===(e=this.canvas)||void 0===e||e.destroy(),null===(n=this.container)||void 0===n||n.remove(),this.originalData=void 0,this.container=void 0,this.timebar=void 0,this.canvas=void 0,super.destroy()}}aZ.defaultOptions={position:"bottom",enable:!0,timebarType:"time",className:"g6-timebar",width:450,height:60,zIndex:3,elementTypes:["node"],padding:10,mode:"modify",getTime:t=>uZ(t,sZ,void 0),loop:!1};const cZ=t=>{const{nodes:e=[],edges:n=[],combos:r=[]}=t;return{nodes:[...e],edges:[...n],combos:[...r]}},lZ=(t,e)=>{if(re(e))return t===e;const[n,r]=e;return t>=n&&t<=r},uZ=(t,e,n)=>{var r;for(let n=0;n<e.length;n++){const i=e[n],o=null===(r=t.data)||void 0===r?void 0:r[i];if(o)return o}return n},hZ={fill:"#1D2129",wordWrap:!0,maxLines:1,textOverflow:"ellipsis",textBaseline:"top",textAlign:"start",x:0},dZ=Object.assign(Object.assign({},hZ),{fillOpacity:.9,fontSize:16,fontWeight:"bold"}),fZ=Object.assign(Object.assign({},hZ),{fillOpacity:.65,fontSize:12,fontWeight:"normal"}),gZ={align:"left",spacing:8,size:44,padding:[16,24,0,24]},pZ="title",vZ="subtitle";class mZ extends tz{get padding(){return pm(this.options.padding)}constructor(t,e){super(t,Object.assign({},gZ,e)),this.onRender=()=>{const t=this.updateCanvas();this.renderTitle(t)},this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_RENDER,this.onRender),e.on(t.GraphEvent.AFTER_ANIMATE,this.onRender)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_RENDER,this.onRender),e.off(t.GraphEvent.AFTER_ANIMATE,this.onRender)}destroy(){var t,e;this.unbindEvents(),null===(t=this.canvas)||void 0===t||t.destroy(),null===(e=this.container)||void 0===e||e.remove(),super.destroy()}updateCanvas(){const{size:t,className:e,align:n}=this.options,[r]=this.context.canvas.getSize(),[i=0,,o=0]=this.padding,A=t+i+o;if(this.canvas){const{width:t,height:e}=this.canvas.getConfig();r===t&&A===e||this.canvas.resize(r,A)}else{const t={left:"left-top",center:"top",right:"right-top"},[i,o]=Z$({width:r,height:A,placement:t[n]||t.left,className:"title-canvas",graphCanvas:this.context.canvas});e&&i.classList.add(e),this.container=i,this.canvas=o}return this.canvas}renderTitle(t){const e=new yZ({options:this.options,ctx:this.context});t.removeChildren(),e.getTitle().forEach(e=>{e&&t.appendChild(e)})}}class yZ{get padding(){return pm(this.options.padding)}constructor(t){const{options:e,ctx:n}=t;this.options=e,this.context=n}getTitle(){const t=this.options,e=pZ,n=t[e],r=vZ,i=t[r],{spacing:o=44,padding:A,align:s}=t,a=Pe(t,[e+"",r+"","spacing","padding","align"]),c=n,l=i,u=Aw(a,pZ),h=Aw(a,vZ),[d]=this.context.graph.getSize(),[f=0,g=0,,p=0]=this.padding,v=d,m=v-p-g;let y=null,w=p,b="left";switch(s){case"left":default:w=p,b="left";break;case"center":w=v/2,b="center";break;case"right":w=v-g,b="right"}const B=new yw({className:pZ,style:Object.assign(Object.assign(Object.assign(Object.assign({},dZ),{wordWrapWidth:m-5,x:w,y:f,textAlign:b}),u),{text:c})}),E=B.getBBox();return l&&(y=new yw({className:"subTitle",style:Object.assign(Object.assign(Object.assign(Object.assign({},fZ),{wordWrapWidth:m-5,x:w,y:E.height+o+f,textAlign:b}),h),{text:l})})),[B,y]}}class wZ extends tz{constructor(t,e){super(t,Object.assign({},wZ.defaultOptions,e)),this.$element=ez("toolbar",!1),this.onToolbarItemClick=t=>{const{onClick:e}=this.options;if(t.target instanceof Element&&t.target.className.includes("g6-toolbar-item")){const n=t.target.getAttribute("value");null==e||e(n,t.target)}};const n=this.context.canvas.getContainer();this.$element.style.display="flex",n.appendChild(this.$element),nz("g6-toolbar-css","style",{},"\n .g6-toolbar {\n position: absolute;\n z-index: 100;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: center;\n border-radius: 4px;\n box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1);\n opacity: 0.65;\n }\n .g6-toolbar .g6-toolbar-item {\n display: inline-block;\n width: 16px;\n height: 16px;\n padding: 4px;\n cursor: pointer;\n box-sizing: content-box;\n }\n\n .g6-toolbar .g6-toolbar-item:hover {\n background-color: #f0f0f0;\n }\n\n .g6-toolbar .g6-toolbar-item svg {\n display: inline-block;\n width: 100%;\n height: 100%;\n pointer-events: none;\n }\n",document.head),nz("g6-toolbar-svgicon","div",{display:"none"},'\n <svg>\n <symbol id="zoom-in" viewBox="64 64 896 896">\n <path d="M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="zoom-out" viewBox="64 64 896 896">\n <path d="M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"></path>\n </symbol>\n <symbol id="edit" viewBox="64 64 896 896">\n <path d="M257.7 752c2 0 4-.2 6-.5L431.9 722c2-.4 3.9-1.3 5.3-2.8l423.9-423.9a9.96 9.96 0 000-14.1L694.9 114.9c-1.9-1.9-4.4-2.9-7.1-2.9s-5.2 1-7.1 2.9L256.8 538.8c-1.5 1.5-2.4 3.3-2.8 5.3l-29.5 168.2a33.5 33.5 0 009.4 29.8c6.6 6.4 14.9 9.9 23.8 9.9zm67.4-174.4L687.8 215l73.3 73.3-362.7 362.6-88.9 15.7 15.6-89zM880 836H144c-17.7 0-32 14.3-32 32v36c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-36c0-17.7-14.3-32-32-32z"></path>\n </symbol>\n <symbol id="delete" viewBox="64 64 896 896">\n <path d="M360 184h-8c4.4 0 8-3.6 8-8v8h304v-8c0 4.4 3.6 8 8 8h-8v72h72v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80h72v-72zm504 72H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zM731.3 840H292.7l-24.2-512h487l-24.2 512z"></path>\n </symbol>\n <symbol id="redo" viewBox="64 64 896 896">\n <path d="M758.2 839.1C851.8 765.9 912 651.9 912 523.9 912 303 733.5 124.3 512.6 124 291.4 123.7 112 302.8 112 523.9c0 125.2 57.5 236.9 147.6 310.2 3.5 2.8 8.6 2.2 11.4-1.3l39.4-50.5c2.7-3.4 2.1-8.3-1.2-11.1-8.1-6.6-15.9-13.7-23.4-21.2a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-9.3 9.3-19.1 18-29.3 26L668.2 724a8 8 0 00-14.1 3l-39.6 162.2c-1.2 5 2.6 9.9 7.7 9.9l167 .8c6.7 0 10.5-7.7 6.3-12.9l-37.3-47.9z"></path>\n </symbol>\n <symbol id="undo" viewBox="64 64 896 896">\n <path d="M511.4 124C290.5 124.3 112 303 112 523.9c0 128 60.2 242 153.8 315.2l-37.5 48c-4.1 5.3-.3 13 6.3 12.9l167-.8c5.2 0 9-4.9 7.7-9.9L369.8 727a8 8 0 00-14.1-3L315 776.1c-10.2-8-20-16.7-29.3-26a318.64 318.64 0 01-68.6-101.7C200.4 609 192 567.1 192 523.9s8.4-85.1 25.1-124.5c16.1-38.1 39.2-72.3 68.6-101.7 29.4-29.4 63.6-52.5 101.7-68.6C426.9 212.4 468.8 204 512 204s85.1 8.4 124.5 25.1c38.1 16.1 72.3 39.2 101.7 68.6 29.4 29.4 52.5 63.6 68.6 101.7 16.7 39.4 25.1 81.3 25.1 124.5s-8.4 85.1-25.1 124.5a318.64 318.64 0 01-68.6 101.7c-7.5 7.5-15.3 14.5-23.4 21.2a7.93 7.93 0 00-1.2 11.1l39.4 50.5c2.8 3.5 7.9 4.1 11.4 1.3C854.5 760.8 912 649.1 912 523.9c0-221.1-179.4-400.2-400.6-399.9z"></path>\n </symbol>\n <symbol id="export" viewBox="64 64 896 896">\n <path d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"></path>\n </symbol>\n <symbol id="auto-fit" viewBox="64 64 896 896">\n <path d="M952 474H829.8C812.5 327.6 696.4 211.5 550 194.2V72c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v122.2C327.6 211.5 211.5 327.6 194.2 474H72c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h122.2C211.5 696.4 327.6 812.5 474 829.8V952c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V829.8C696.4 812.5 812.5 696.4 829.8 550H952c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zM512 756c-134.8 0-244-109.2-244-244s109.2-244 244-244 244 109.2 244 244-109.2 244-244 244z"></path>\n <path d="M512 392c-32.1 0-62.1 12.4-84.8 35.2-22.7 22.7-35.2 52.7-35.2 84.8s12.5 62.1 35.2 84.8C449.9 619.4 480 632 512 632s62.1-12.5 84.8-35.2C619.4 574.1 632 544 632 512s-12.5-62.1-35.2-84.8A118.57 118.57 0 00512 392z"></path>\n </symbol>\n <symbol id="reset" viewBox="64 64 896 896">\n <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path>\n </symbol>\n <symbol id="exit-fullscreen" viewBox="0 0 1024 1024">\n <path d="M418.13333333 361.43786666c0 0.2048-0.13653333 0.4096-0.13653334 0.68266667C417.99679999 362.32533333 418.13333333 362.53013333 418.13333333 362.73493333 418.13333333 371.54133333 414.44693333 379.392 408.78079999 385.39946666 408.43946666 385.7408 408.30293333 386.21866666 408.02986666 386.49173333c-1.09226667 1.09226667-2.59413333 1.77493333-3.82293333 2.73066667C398.40426666 393.65973333 391.64586666 396.8 383.93173333 396.8 383.72693333 396.8 383.59039999 396.73173333 383.38559999 396.73173333S382.97599999 396.8 382.77119999 396.8L112.29866666 396.8C92.50133333 396.8 76.79999999 381.50826666 76.79999999 362.66666666 76.66346666 343.89333333 92.63786666 328.53333333 112.16213333 328.53333333l189.44 0L87.44959999 114.51733333C73.59146666 100.59093333 73.25013333 78.5408 86.63039999 65.29706666c13.17546667-13.44853333 35.36213333-12.97066667 49.152 0.88746667l214.08426667 214.08426667L349.86666666 90.89706666C349.79839999 71.23626666 365.22666666 55.46666666 383.99999999 55.46666666 402.77333333 55.33013333 418.13333333 71.30453333 418.13333333 90.8288L418.13333333 361.43786666zM928.90453333 328.53333333l-189.44 0 214.15253333-214.08426667c13.85813333-13.9264 14.19946667-35.90826667 0.88746667-49.22026666-13.17546667-13.44853333-35.36213333-12.97066667-49.152 0.88746666l-214.08426667 214.08426667L691.26826666 90.89706666C691.26826666 71.23626666 675.83999999 55.46666666 657.06666666 55.46666666 638.29333333 55.33013333 622.93333333 71.30453333 622.93333333 90.8288l0 270.60906666c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 362.32533333 622.93333333 362.53013333 622.93333333 362.73493333 622.93333333 371.54133333 626.61973333 379.392 632.28586666 385.39946666c0.34133333 0.34133333 0.47786667 0.8192 0.8192 1.09226667 1.09226667 1.09226667 2.59413333 1.77493333 3.8912 2.73066667C642.66239999 393.65973333 649.42079999 396.8 657.13493333 396.8c0.2048 0 0.34133333-0.06826667 0.54613333-0.06826667S658.09066666 396.8 658.29546666 396.8l270.5408 0C948.56533333 396.8 964.26666666 381.50826666 964.26666666 362.66666666 964.40319999 343.89333333 948.42879999 328.53333333 928.90453333 328.53333333zM418.13333333 635.73333333c0-8.8064-3.6864-16.5888-9.35253334-22.66453333C408.43946666 612.72746666 408.30293333 612.2496 408.02986666 611.90826666 406.86933333 610.88426666 405.43573333 610.2016 404.20693333 609.24586666 398.47253333 604.80853333 391.64586666 601.6 383.93173333 601.6 383.72693333 601.6 383.59039999 601.73653333 383.38559999 601.73653333S382.97599999 601.6 382.77119999 601.6L112.29866666 601.6C92.50133333 601.6 76.79999999 616.96 76.79999999 635.73333333 76.66346666 654.50666666 92.63786666 669.86666666 112.16213333 669.86666666l189.44 0-214.15253334 214.15253334c-13.85813333 13.85813333-14.19946667 35.84-0.88746666 49.22026666 13.17546667 13.44853333 35.36213333 12.9024 49.152-0.95573333l214.08426666-214.08426667 0 189.37173334c0 19.59253333 15.42826667 35.49866667 34.2016 35.36213333C402.77333333 943.2064 418.13333333 927.232 418.13333333 907.5712L418.13333333 637.09866666c0-0.27306667-0.13653333-0.47786667-0.13653334-0.68266666C417.99679999 636.14293333 418.13333333 635.93813333 418.13333333 635.73333333zM739.46453333 669.86666666l189.44 0c19.456 0 35.49866667-15.36 35.36213333-34.13333333C964.26666666 616.96 948.56533333 601.6 928.76799999 601.6L658.29546666 601.6C658.09066666 601.6 657.88586666 601.73653333 657.68106666 601.73653333S657.33973333 601.6 657.13493333 601.6C649.42079999 601.6 642.59413333 604.80853333 636.85973333 609.24586666 635.63093333 610.2016 634.19733333 610.88426666 633.03679999 611.90826666 632.76373333 612.2496 632.62719999 612.72746666 632.28586666 613.0688 626.61973333 619.14453333 622.93333333 626.92693333 622.93333333 635.73333333c0 0.2048 0.13653333 0.4096 0.13653333 0.68266667C623.06986666 636.6208 622.93333333 636.8256 622.93333333 637.09866666l0 270.5408C622.93333333 927.232 638.29333333 943.2064 657.06666666 942.93333333c18.77333333 0.13653333 34.2016-15.70133333 34.2016-35.36213333l0-189.37173334 214.08426667 214.08426667c13.78986667 13.85813333 35.90826667 14.40426667 49.152 0.95573333 13.312-13.312 12.97066667-35.36213333-0.88746667-49.22026666L739.46453333 669.86666666z" ></path></symbol>\n <symbol id="request-fullscreen" viewBox="0 0 1024 1024">\n <path d="M69.818182 87.598545v273.128728a34.909091 34.909091 0 0 0 69.818182 0V163.653818l221.928727 222.021818a33.512727 33.512727 0 0 0 47.383273-47.383272L186.926545 116.363636h197.073455a34.909091 34.909091 0 0 0 0-69.818181H110.871273C85.364364 46.545455 69.818182 59.671273 69.818182 87.598545zM938.542545 46.545455H665.413818a34.909091 34.909091 0 0 0 0 69.818181h197.073455L640.465455 338.292364a33.512727 33.512727 0 0 0 47.383272 47.383272l221.928728-222.021818v197.073455a34.909091 34.909091 0 0 0 69.818181 0V87.598545c0-27.927273-15.453091-41.053091-40.96-41.05309z m-827.671272 907.636363h273.128727a34.909091 34.909091 0 0 0 0-69.818182H186.926545l222.021819-221.928727a33.512727 33.512727 0 0 0-47.383273-47.383273L139.636364 837.073455V640a34.909091 34.909091 0 0 0-69.818182 0v273.128727c0 27.927273 15.546182 41.053091 41.053091 41.053091z m868.724363-41.053091V640a34.909091 34.909091 0 0 0-69.818181 0v197.073455L687.941818 615.051636a33.512727 33.512727 0 0 0-47.383273 47.383273L862.487273 884.363636H665.413818a34.909091 34.909091 0 0 0 0 69.818182h273.128727c25.6 0 41.053091-13.125818 41.053091-41.053091z" ></path></symbol>\n </svg>\n'),this.$element.addEventListener("click",this.onToolbarItemClick),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t);const{className:n,position:r,style:i}=this.options;this.$element.className=`g6-toolbar ${n||""}`,Object.assign(this.$element.style,i,function(t){const e={top:"unset",right:"unset",bottom:"unset",left:"unset"};return t.split("-").forEach(t=>{e[t]="8px"}),e.flexDirection=t.startsWith("top")||t.startsWith("bottom")?"row":"column",e}(r)),this.$element.innerHTML=yield this.getDOMContent()})}destroy(){this.$element.removeEventListener("click",this.onToolbarItemClick),this.$element.remove(),super.destroy()}getDOMContent(){return De(this,void 0,void 0,function*(){return(yield this.options.getItems()).map(t=>{var e;return`\n <div class="g6-toolbar-item" value="${t.value}" title="${null!==(e=t.title)&&void 0!==e?e:""}">\n <svg aria-hidden="true" focusable="false">\n <use xlink:href="#${t.id}"></use>\n </svg>\n </div>`}).join("")})}}wZ.defaultOptions={position:"top-left"};class bZ extends tz{constructor(t,e){super(t,Object.assign({},bZ.defaultOptions,e)),this.currentTarget=null,this.tooltipElement=null,this.container=null,this.isEnable=(t,e)=>{const{enable:n}=this.options;return"function"==typeof n?n(t,e):n},this.onClick=t=>{const{target:{id:e}}=t;this.currentTarget===e?this.hide(t):this.show(t)},this.onPointerMove=t=>{const{target:e}=t;this.currentTarget&&e.id!==this.currentTarget&&this.show(t)},this.onPointerLeave=t=>{this.hide(t)},this.onCanvasMove=t=>{this.hide(t)},this.onPointerOver=t=>{this.show(t)},this.showById=t=>De(this,void 0,void 0,function*(){const e={target:{id:t}};yield this.show(e)}),this.getElementData=(t,e)=>{const{model:n}=this.context;switch(e){case"node":return n.getNodeData([t]);case"edge":return n.getEdgeData([t]);case"combo":return n.getComboData([t]);default:return[]}},this.show=t=>De(this,void 0,void 0,function*(){var e,n;const{client:r,target:{id:i}}=t;if(eE(t.target))return;const o=this.context.graph.getElementType(i),{getContent:A,title:s}=this.options,a=this.getElementData(i,o);if(!this.tooltipElement)return;if(!this.isEnable(t,a))return void this.hide(t);let c,l,u={};if(A){if(u.content=yield A(t,a),!u.content)return}else{const t=this.context.graph.getElementRenderStyle(i),e="node"===o?t.fill:t.stroke;u={title:s||o,data:a.map(t=>({name:"ID",value:t.id||`${t.source} -> ${t.target}`,color:e}))}}if(this.currentTarget=i,r)c=r.x,l=r.y;else{const t=Ce(a,"0.style",{x:0,y:0});c=t.x,l=t.y}null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!0),this.tooltipElement.update(Object.assign(Object.assign(Object.assign({},this.tooltipStyleProps),{x:c,y:l,style:{".tooltip":{visibility:"visible"}}}),u))}),this.hide=t=>{var e,n,r,i,o;if(!t)return null===(n=(e=this.options).onOpenChange)||void 0===n||n.call(e,!1),null===(r=this.tooltipElement)||void 0===r||r.hide(),void(this.currentTarget=null);if(!this.tooltipElement)return;if(!this.currentTarget)return;const{client:{x:A,y:s}}=t;null===(o=(i=this.options).onOpenChange)||void 0===o||o.call(i,!1),this.tooltipElement.hide(A,s),this.currentTarget=null},this.initTooltip=()=>{var t;const e=new x$({className:"tooltip",style:this.tooltipStyleProps});return null===(t=this.container)||void 0===t||t.appendChild(e.HTMLTooltipElement),e},this.render(),this.bindEvents()}getEvents(){return"click"===this.options.trigger?{"node:click":this.onClick,"edge:click":this.onClick,"combo:click":this.onClick,"canvas:click":this.onPointerLeave,contextmenu:this.onPointerLeave,drag:this.onPointerLeave}:{"node:pointerover":this.onPointerOver,"node:pointermove":this.onPointerMove,"canvas:pointermove":this.onCanvasMove,"edge:pointerover":this.onPointerOver,"edge:pointermove":this.onPointerMove,"combo:pointerover":this.onPointerOver,"combo:pointermove":this.onPointerMove,contextmenu:this.onPointerLeave,"node:drag":this.onPointerLeave}}update(t){var e;this.unbindEvents(),super.update(t),this.tooltipElement&&(null===(e=this.container)||void 0===e||e.removeChild(this.tooltipElement.HTMLTooltipElement)),this.tooltipElement=this.initTooltip(),this.bindEvents()}render(){const{canvas:t}=this.context,e=t.getContainer();e&&(this.container=e,this.tooltipElement=this.initTooltip())}unbindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach(n=>{t.off(n,e[n])})}bindEvents(){const{graph:t}=this.context,e=this.getEvents();Object.keys(e).forEach(n=>{t.on(n,e[n])})}get tooltipStyleProps(){const{canvas:t}=this.context,{center:e}=t.getBounds(),n=t.getContainer(),{top:r,left:i}=n.getBoundingClientRect(),{style:o,position:A,enterable:s,container:a={x:-i,y:-r},title:c,offset:l}=this.options,[u,h]=e,[d,f]=t.getSize();return{x:u,y:h,container:a,title:c,bounding:{x:0,y:0,width:d,height:f},position:A,enterable:s,offset:l,style:o}}destroy(){var t;this.unbindEvents(),this.tooltipElement&&(null===(t=this.container)||void 0===t||t.removeChild(this.tooltipElement.HTMLTooltipElement)),super.destroy()}}let BZ;function EZ(t,e){BZ||(BZ=document.createElement("canvas")),BZ.width=t,BZ.height=e;return BZ.getContext("2d").clearRect(0,0,t,e),BZ}bZ.defaultOptions={trigger:"hover",position:"top-right",enterable:!1,enable:!0,offset:[10,10],style:{".tooltip":{visibility:"hidden"}}};class xZ extends tz{constructor(t,e){super(t,Object.assign({},xZ.defaultOptions,e)),this.$element=ez("watermark");this.context.canvas.getContainer().appendChild(this.$element),this.update(e)}update(t){const e=Object.create(null,{update:{get:()=>super.update}});return De(this,void 0,void 0,function*(){e.update.call(this,t);const n=this.options,{width:r,height:i,text:o,imageURL:A}=n,s=Pe(n,["width","height","text","imageURL"]);Object.keys(s).forEach(e=>{e.startsWith("background")&&(this.$element.style[e]=t[e])});const a=A?yield function(t,e,n,r){return De(this,void 0,void 0,function*(){const i=EZ(t,e),o=i.getContext("2d"),{rotate:A,opacity:s}=r;A&&o.rotate(A),s&&(o.globalAlpha=s);const a=new Image;return a.crossOrigin="anonymous",a.src=n,new Promise(n=>{a.onload=function(){const r=t>a.width?(t-a.width)/2:0,A=e>a.height?(e-a.height)/2:0;o.drawImage(a,0,0,a.width,a.height,r,A,t-2*r,e-2*A),n(i.toDataURL())}})})}(r,i,A,s):yield function(t,e,n,r){return De(this,void 0,void 0,function*(){const i=EZ(t,e),o=i.getContext("2d"),{rotate:A,opacity:s,textFill:a,textFontSize:c,textFontFamily:l,textFontVariant:u,textFontWeight:h,textAlign:d,textBaseline:f}=r;return o.textAlign=d,o.textBaseline=f,o.translate(t/2,e/2),o.font=`${c}px ${l} ${u} ${h}`,A&&o.rotate(A),s&&(o.globalAlpha=s),a&&(o.fillStyle=a,o.fillText(`${n}`,0,0)),i.toDataURL()})}(r,i,o,s);this.$element.style.backgroundImage=`url(${a})`})}destroy(){super.destroy(),this.$element.remove()}}xZ.defaultOptions={width:200,height:100,opacity:.2,rotate:Math.PI/12,text:"",textFill:"#000",textFontSize:16,textAlign:"center",textBaseline:"middle",backgroundRepeat:"repeat"};const CZ=["#7E92B5","#F4664A","#FFBE3A"],MZ={type:"group",color:["#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]},FZ={type:"group",color:["#99ADD1","#1783FF","#00C9C9","#F08F56","#D580FF","#7863FF","#DB9D0D","#60C42D","#FF80CA","#2491B3","#17C76F"]};function kZ(t){const{bgColor:e,textColor:n,nodeColor:r,nodeColorDisabled:i,nodeStroke:o,nodeHaloStrokeOpacityActive:A=.15,nodeHaloStrokeOpacitySelected:s=.25,nodeOpacityDisabled:a=.06,nodeIconOpacityInactive:c=.85,nodeOpacityInactive:l=.25,nodeBadgePalette:u=CZ,nodePaletteOptions:h=MZ,edgeColor:d,edgeColorDisabled:f,edgePaletteOptions:g=FZ,comboColor:p,comboColorDisabled:v,comboStroke:m,comboStrokeDisabled:y,edgeColorInactive:w}=t;return{background:e,node:{palette:h,style:{donutOpacity:1,badgeBackgroundOpacity:1,badgeFill:"#fff",badgeFontSize:8,badgePadding:[0,4],badgePalette:u,fill:r,fillOpacity:1,halo:!1,iconFill:"#fff",iconOpacity:1,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelFill:n,labelFillOpacity:.85,labelLineHeight:16,labelPadding:[0,2],labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelOffsetY:2,lineWidth:0,portFill:r,portLineWidth:1,portStroke:o,portStrokeOpacity:.65,size:32,stroke:o,strokeOpacity:1,zIndex:2},state:{selected:{halo:!0,haloLineWidth:24,haloStrokeOpacity:s,labelFontSize:12,labelFontWeight:"bold",lineWidth:4,stroke:o},active:{halo:!0,haloLineWidth:12,haloStrokeOpacity:A},highlight:{labelFontWeight:"bold",lineWidth:4,stroke:o,strokeOpacity:.85},inactive:{badgeBackgroundOpacity:l,donutOpacity:l,fillOpacity:l,iconOpacity:c,labelFill:n,labelFillOpacity:l,strokeOpacity:l},disabled:{badgeBackgroundOpacity:.25,donutOpacity:a,fill:i,fillOpacity:a,iconFill:i,iconOpacity:.25,labelFill:n,labelFillOpacity:.25,strokeOpacity:a}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"node-expand",collapse:"node-collapse",update:[{fields:["x","y","fill","stroke"]}],translate:[{fields:["x","y"]}]}},edge:{palette:g,style:{badgeBackgroundFill:d,badgeFill:"#fff",badgeFontSize:8,badgeOffsetX:10,badgeBackgroundOpacity:1,fillOpacity:1,halo:!1,haloLineWidth:12,haloStrokeOpacity:1,increasedLineWidthForHitTesting:2,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[4,4,4,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,labelPlacement:"center",labelTextBaseline:"middle",lineWidth:1,stroke:d,strokeOpacity:1,zIndex:1},state:{selected:{halo:!0,haloStrokeOpacity:.25,labelFontSize:14,labelFontWeight:"bold",lineWidth:3},active:{halo:!0,haloStrokeOpacity:.15},highlight:{labelFontWeight:"bold",lineWidth:3},inactive:{stroke:w,fillOpacity:.08,labelOpacity:.25,strokeOpacity:.08,badgeBackgroundOpacity:.25},disabled:{stroke:f,fillOpacity:.45,strokeOpacity:.45,labelOpacity:.25,badgeBackgroundOpacity:.45}},animation:{enter:"fade",exit:"fade",expand:"path-in",collapse:"path-out",show:"fade",hide:"fade",update:[{fields:["sourceNode","targetNode"]},{fields:["stroke"],shape:"key"}],translate:[{fields:["sourceNode","targetNode"]}]}},combo:{style:{collapsedMarkerFill:e,collapsedMarkerFontSize:12,collapsedMarkerFillOpacity:1,collapsedSize:32,collapsedFillOpacity:1,fill:p,halo:!1,haloLineWidth:12,haloStroke:m,haloStrokeOpacity:.25,labelBackground:!1,labelBackgroundFill:e,labelBackgroundLineWidth:0,labelBackgroundOpacity:.75,labelBackgroundPadding:[2,4,2,4],labelFill:n,labelFontSize:12,labelFontWeight:400,labelOpacity:1,lineDash:0,lineWidth:1,fillOpacity:.04,strokeOpacity:1,padding:10,stroke:m},state:{selected:{halo:!0,labelFontSize:14,labelFontWeight:700,lineWidth:4},active:{halo:!0},highlight:{labelFontWeight:700,lineWidth:4},inactive:{fillOpacity:.65,labelOpacity:.25,strokeOpacity:.65},disabled:{fill:v,fillOpacity:.25,labelOpacity:.25,stroke:y,strokeOpacity:.25}},animation:{enter:"fade",exit:"fade",show:"fade",hide:"fade",expand:"combo-expand",collapse:"combo-collapse",update:[{fields:["x","y"]},{fields:["fill","stroke","lineWidth"],shape:"key"}],translate:[{fields:["x","y"]}]}}}}const SZ=kZ({bgColor:"#000000",comboColor:"#fdfdfd",comboColorDisabled:"#d0e4ff",comboStroke:"#99add1",comboStrokeDisabled:"#969696",edgeColor:"#637088",edgeColorDisabled:"#637088",edgeColorInactive:"#D0E4FF",edgePaletteOptions:{type:"group",color:["#637088","#0F55A6","#008383","#9C5D38","#8B53A6","#4E40A6","#8F6608","#3E801D","#A65383","#175E75","#0F8248"]},nodeColor:"#1783ff",nodeColorDisabled:"#D0E4FF",nodeHaloStrokeOpacityActive:.25,nodeHaloStrokeOpacitySelected:.45,nodeIconOpacityInactive:.45,nodeOpacityDisabled:.25,nodeOpacityInactive:.45,nodeStroke:"#d0e4ff",textColor:"#ffffff"}),QZ=kZ({bgColor:"#ffffff",comboColor:"#99ADD1",comboColorDisabled:"#f0f0f0",comboStroke:"#99add1",comboStrokeDisabled:"#d9d9d9",edgeColor:"#99add1",edgeColorDisabled:"#d9d9d9",edgeColorInactive:"#1B324F",nodeColor:"#1783ff",nodeColorDisabled:"#1B324F",nodeHaloStrokeOpacityActive:.15,nodeHaloStrokeOpacitySelected:.25,nodeIconOpacityInactive:.85,nodeOpacityDisabled:.06,nodeOpacityInactive:.25,nodeStroke:"#000000",textColor:"#000000"});class UZ extends ry{beforeDraw(t,e){return t}afterLayout(t,e){}}function NZ(t,e,n,r,i){const o=Km(r),A=`${n}s`,s=i?r:t.add[A].get(o)||t.update[A].get(o)||t.remove[A].get(o)||r;Object.entries(t).forEach(([t,n])=>{e===t?n[A].set(o,s):n[A].delete(o)})}function TZ(t,e){return Object.keys(t).every(n=>t[n]===e[n])}const OZ=(t,e,n,r)=>{const i=`${n}s`,o=Km(r);t.add[i].has(o)||t.update[i].has(o)||t[e][i].set(Km(r),r)};const IZ=new WeakMap;const LZ=(t,e,n=2)=>{if("object"!=typeof t||"object"!=typeof e)return t===e;const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const i of r){const r=t[i],o=e[i];if(n>1&&"object"==typeof r&&"object"==typeof o){if(!LZ(r,o,n-1))return!1}else if(r!==o)return!1}return!0};function PZ(t,e,n){Yv[t][e]&&Zv(`The extension ${e} of ${t} has been registered before, and will be overridden.`),Object.assign(Yv[t],{[e]:n})}
|
|
61
61
|
/*!
|
|
62
62
|
* @antv/g-plugin-dragndrop
|
|
63
63
|
* @description A G plugin for Drag n Drop implemented with PointerEvents
|
|
@@ -65,4 +65,4 @@ var _c=function(t,e){return _c=Object.setPrototypeOf||{__proto__:[]}instanceof A
|
|
|
65
65
|
* @date 12/24/2025, 11:56:44 AM
|
|
66
66
|
* @author AntVis
|
|
67
67
|
* @docs https://g.antv.antgroup.com/
|
|
68
|
-
*/var LZ=function(){function t(e){A(this,t),this.dragndropPluginOptions=e}return a(t,[{key:"apply",value:function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,A=function(t){var e=t.target,r=e===i,A=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(A){var s=!1,a=t.timeStamp,c=[t.clientX,t.clientY],l=null,u=[t.clientX,t.clientY],h=function(){var t=Ar(ir().mark(function t(o){var h,d,f,g,p,v;return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=2;break}if(h=o.timeStamp-a,d=gn([o.clientX,o.clientY],c),!(h<=n.dragndropPluginOptions.dragstartTimeThreshold||d<=n.dragndropPluginOptions.dragstartDistanceThreshold)){t.next=1;break}return t.abrupt("return");case 1:o.type="dragstart",A.dispatchEvent(o),s=!0;case 2:if(o.type="drag",o.dx=o.clientX-u[0],o.dy=o.clientY-u[1],A.dispatchEvent(o),u=[o.clientX,o.clientY],r){t.next=4;break}return f="pointer"===n.dragndropPluginOptions.overlap?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=3,i.elementsFromPoint(f[0],f[1]);case 3:g=t.sent,p=g[g.indexOf(e)+1],v=(null==p?void 0:p.closest("[droppable=true]"))||(n.dragndropPluginOptions.isDocumentDroppable?i:null),l!==v&&(l&&(o.type="dragleave",o.target=l,l.dispatchEvent(o)),v&&(o.type="dragenter",o.target=v,v.dispatchEvent(o)),(l=v)&&(o.type="dragover",o.target=l,l.dispatchEvent(o)));case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}();o.addEventListener("pointermove",h);var d=function(t){if(s){t.detail={preventClick:!0};var e=t.clone();l&&(e.type="drop",e.target=l,l.dispatchEvent(e)),e.type="dragend",A.dispatchEvent(e),s=!1}o.removeEventListener("pointermove",h)};e.addEventListener("pointerup",d,{once:!0}),e.addEventListener("pointerupoutside",d,{once:!0})}};r.hooks.init.tap(t.tag,function(){o.addEventListener("pointerdown",A)}),r.hooks.destroy.tap(t.tag,function(){o.removeEventListener("pointerdown",A)})}}])}();LZ.tag="Dragndrop";var PZ=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),(t=g(this,e)).name="dragndrop",t.options=n,t}return v(e,t),a(e,[{key:"init",value:function(){this.addRenderingPlugin(new LZ(o({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)}}])}(ur);const DZ=["main"],RZ=["background","main","label","transient"];class HZ{getConfig(){return this.config}getLayer(t="main"){return this.extends.layers[t]||this.getLayers().main}getLayers(){return this.extends.layers}getRenderer(t){return this.extends.renderers[t]}getCamera(t="main"){return this.getLayer(t).getCamera()}getRoot(t="main"){return this.getLayer(t).getRoot()}getContextService(t="main"){return this.getLayer(t).getContextService()}setCursor(t){this.config.cursor=t,this.getLayer().setCursor(t)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(t){this.config={enableMultiLayer:!0},Object.assign(this.config,t);const e=this.config,{renderer:n,background:r,cursor:i,enableMultiLayer:o}=e,A=Pe(e,["renderer","background","cursor","enableMultiLayer"]),s=o?RZ:DZ,a=_Z(n,s),c=Object.fromEntries(s.map(t=>[t,new xc(Object.assign(Object.assign({},A),{supportsMutipleCanvasesInOneContainer:o,renderer:a[t],background:o?"background"===t?r:void 0:r}))]));GZ(c),this.extends={config:this.config,renderer:n,renderers:a,layers:c}}get ready(){return Promise.all(Object.entries(this.getLayers()).map(([,t])=>t.ready))}resize(t,e){Object.assign(this.extends.config,{width:t,height:e}),Object.values(this.getLayers()).forEach(n=>{const r=n.getCamera(),i=r.getPosition(),o=r.getFocalPoint();n.resize(t,e),r.setPosition(i),r.setFocalPoint(o)})}getBounds(t){return xm(Object.values(this.getLayers()).map(e=>t?e.getRoot().childNodes.find(e=>e.classList.includes(t)):e.getRoot()).filter(t=>(null==t?void 0:t.childNodes.length)>0).map(t=>t.getBounds()))}getContainer(){const t=this.extends.config.container;return"string"==typeof t?document.getElementById(t):t}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(t,e){var n;const r=(null===(n=t.style)||void 0===n?void 0:n.$layer)||"main";return this.getLayer(r).appendChild(t,e)}setRenderer(t){if(t===this.extends.renderer)return;const e=_Z(t,this.config.enableMultiLayer?RZ:DZ);this.extends.renderers=e,Object.entries(e).forEach(([t,e])=>this.getLayer(t).setRenderer(e)),GZ(this.getLayers())}getCanvasByViewport(t){return Sy(this.getLayer().viewport2Canvas(Qy(t)))}getViewportByCanvas(t){return Sy(this.getLayer().canvas2Viewport(Qy(t)))}getViewportByClient(t){return Sy(this.getLayer().client2Viewport(Qy(t)))}getClientByViewport(t){return Sy(this.getLayer().viewport2Client(Qy(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),n=e.client2Viewport(Qy(t));return Sy(e.viewport2Canvas(n))}toDataURL(){return De(this,arguments,void 0,function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:n="viewport"}=t,r=Pe(t,["mode"]);let[i,o,A,s]=[0,0,0,0];if("viewport"===n)[A,s]=this.getSize();else if("overall"===n){const t=this.getBounds(),e=wm(t);[i,o]=t.min,[A,s]=e}const a=Sn('<div id="virtual-image"></div>'),c=new xc({width:A,height:s,renderer:new _b,devicePixelRatio:e,container:a,background:this.extends.config.background});yield c.ready,c.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),c.appendChild(this.getRoot().cloneNode(!0));const l=this.getLayer("label").getRoot().cloneNode(!0),u=c.viewport2Canvas({x:0,y:0}),h=this.getCanvasByViewport([0,0]);l.translate([h[0]-u.x,h[1]-u.y]),l.scale(1/this.getCamera().getZoom()),c.appendChild(l),c.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const d=this.getCamera(),f=c.getCamera();if("viewport"===n)f.setZoom(d.getZoom()),f.setPosition(d.getPosition()),f.setFocalPoint(d.getFocalPoint());else if("overall"===n){const[t,e,n]=f.getPosition(),[r,A,s]=f.getFocalPoint();f.setPosition([t+i,e+o,n]),f.setFocalPoint([r+i,A+o,s])}const g=c.getContextService();return new Promise(t=>{c.addEventListener(mc.RERENDER,()=>De(this,void 0,void 0,function*(){yield new Promise(t=>setTimeout(t,300));const e=yield g.toDataURL(r);t(e)}))})})}destroy(){Object.values(this.getLayers()).forEach(t=>{t.getCamera().cancelLandmarkAnimation(),t.destroy()})}}function _Z(t,e){return Object.fromEntries(e.map(e=>{const n=(null==t?void 0:t(e))||new _b;return n instanceof _b&&n.setConfig({enableDirtyRectangleRendering:!1}),"main"===e?n.registerPlugin(new PZ({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[e,n]}))}function GZ(t){Object.entries(t).forEach(([t,e])=>{const n=e.getContextService().getDomElement();(null==n?void 0:n.style)&&(n.style.gridArea="1 / 1 / 2 / 2",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")),(null==n?void 0:n.parentElement)&&(n.parentElement.style.display="grid",n.parentElement.style.isolation="isolate")})}const KZ=t=>t?parseInt(t):0;function jZ(t){if(!t)return[0,0];let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||KZ(e.width),r=t.clientHeight||KZ(e.height);return[n-(KZ(e.paddingLeft)+KZ(e.paddingRight)),r-(KZ(e.paddingTop)+KZ(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(re(e)?e:1,1),Math.max(re(n)?n:1,1)]}class zZ{constructor(t){this.type=t}}class VZ extends zZ{constructor(t,e){super(t),this.data=e}}class WZ extends zZ{constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class YZ extends zZ{constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class XZ extends zZ{constructor(t,e){super(t),this.data=e}}function qZ(t,e){t.emit(e.type,e)}function $Z(t){var e;return(null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0}const ZZ="cachedStyle",JZ=t=>`__${t}__`;function tJ(t,e){return Ce(t,[ZZ,JZ(e)])}class eJ{constructor(t){this.tasks=[],this.animations=new Set,this.context=t}getTasks(){const t=[...this.tasks];return this.tasks=[],t}add(t,e){this.tasks.push([t,e])}animate(t,e,n){var r,i,o;null===(r=null==e?void 0:e.before)||void 0===r||r.call(e);const A=this.getTasks().map(([e,r])=>{var i,o,A;const{element:s,elementType:a,stage:c}=e,l=im(this.context.options,a,c,t);null===(i=null==r?void 0:r.before)||void 0===i||i.call(r);const u=l.length?Am(s,this.inferStyle(e,n),l):null;return u?(null===(o=null==r?void 0:r.beforeAnimate)||void 0===o||o.call(r,u),u.finished.then(()=>{var t,e;null===(t=null==r?void 0:r.afterAnimate)||void 0===t||t.call(r,u),null===(e=null==r?void 0:r.after)||void 0===e||e.call(r),this.animations.delete(u)})):null===(A=null==r?void 0:r.after)||void 0===A||A.call(r),u}).filter(Boolean);A.forEach(t=>this.animations.add(t));const s=tm(A);return s?(null===(i=null==e?void 0:e.beforeAnimate)||void 0===i||i.call(e,s),s.finished.then(()=>{var t,n;null===(t=null==e?void 0:e.afterAnimate)||void 0===t||t.call(e,s),null===(n=null==e?void 0:e.after)||void 0===n||n.call(e),this.release()})):null===(o=null==e?void 0:e.after)||void 0===o||o.call(e),s}inferStyle(t,e){var n,r;const{element:i,elementType:o,stage:A,originalStyle:s,updatedStyle:a={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},s),a));const{modifiedStyle:c}=t,l={},u={};if("enter"===A)Object.assign(l,{opacity:0});else if("exit"===A)Object.assign(u,{opacity:0});else if("show"===A)Object.assign(l,{opacity:0}),Object.assign(u,{opacity:null!==(n=tJ(i,"opacity"))&&void 0!==n?n:nm("opacity")});else if("hide"===A)Object.assign(l,{opacity:null!==(r=tJ(i,"opacity"))&&void 0!==r?r:nm("opacity")}),Object.assign(u,{opacity:0});else if("collapse"===A){const{collapse:t}=e||{},{target:n,descendants:r,position:A}=t;if("node"===o){if(r.includes(i.id)){const[t,e,n]=A;Object.assign(u,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e]=A;Object.assign(u,{x:t,y:e,childrenNode:s.childrenNode})}}else"edge"===o&&Object.assign(u,{sourceNode:c.sourceNode,targetNode:c.targetNode})}else if("expand"===A){const{expand:t}=e||{},{target:n,descendants:r,position:A}=t;if("node"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=A;Object.assign(l,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=A;Object.assign(l,{x:t,y:e,z:n,childrenNode:c.childrenNode})}}else"edge"===o&&Object.assign(l,{sourceNode:c.sourceNode,targetNode:c.targetNode})}return[Object.keys(l).length>0?Object.assign({},s,l):s,Object.keys(u).length>0?Object.assign({},c,u):c]}stop(){this.animations.forEach(t=>t.cancel())}clear(){this.tasks=[]}release(){var t,e;const{canvas:n}=this.context,r=null===(e=null===(t=n.document)||void 0===t?void 0:t.timeline)||void 0===e?void 0:e.animationsWithPromises;r&&(n.document.timeline.animationsWithPromises=r.filter(t=>"finished"!==t.playState))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class nJ{constructor(t){this.batchCount=0,this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(e=!0){this.batchCount++,1===this.batchCount&&this.emit(new VZ(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new VZ(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class rJ extends ny{constructor(e){super(e),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=e=>{const{target:n}=e,r=function(t){if(!t)return null;if(t instanceof hc)return{type:"canvas",element:t};let e=t;for(;e;){if(DB(e))return{type:"node",element:e};if(RB(e))return{type:"edge",element:e};if(HB(e))return{type:"combo",element:e};e=e.parentElement}return null}(n);if(!r)return;const{graph:i,canvas:o}=this.context,{type:A,element:s}=r;if("destroyed"in s&&(JB(s)||s.destroyed))return;const{type:a,detail:c,button:l}=e,u=Object.assign(Object.assign({},e),{target:s,targetType:A,originalTarget:n});a===t.CommonEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${this.currentTargetType}:${t.CommonEvent.POINTER_LEAVE}`,Object.assign(Object.assign({},u),{type:t.CommonEvent.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),s&&(Object.assign(u,{type:t.CommonEvent.POINTER_ENTER}),i.emit(`${A}:${t.CommonEvent.POINTER_ENTER}`,u))),this.currentTarget=s,this.currentTargetType=A),a===t.CommonEvent.CLICK&&2===l||(i.emit(`${A}:${a}`,u),i.emit(a,u)),a===t.CommonEvent.CLICK&&2===c&&(Object.assign(u,{type:t.CommonEvent.DBLCLICK}),i.emit(`${A}:${t.CommonEvent.DBLCLICK}`,u),i.emit(t.CommonEvent.DBLCLICK,u)),a===t.CommonEvent.POINTER_DOWN&&2===l&&(Object.assign(u,{type:t.CommonEvent.CONTEXT_MENU,preventDefault:()=>{var e;null===(e=o.getContainer())||void 0===e||e.addEventListener(t.CommonEvent.CONTEXT_MENU,t=>t.preventDefault(),{once:!0})}}),i.emit(`${A}:${t.CommonEvent.CONTEXT_MENU}`,u),i.emit(t.CommonEvent.CONTEXT_MENU,u))},this.forwardContainerEvents=t=>{this.context.graph.emit(t.type,t)},this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach(t=>{e.addEventListener(t,this.forwardContainerEvents)});const n=this.context.canvas.document;n&&[t.CommonEvent.CLICK,t.CommonEvent.DBLCLICK,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE,t.CommonEvent.POINTER_ENTER,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_OUT,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_UP,t.CommonEvent.CONTEXT_MENU,t.CommonEvent.DRAG_START,t.CommonEvent.DRAG,t.CommonEvent.DRAG_END,t.CommonEvent.DRAG_ENTER,t.CommonEvent.DRAG_OVER,t.CommonEvent.DRAG_LEAVE,t.CommonEvent.DROP,t.CommonEvent.WHEEL].forEach(t=>{n.addEventListener(t,this.forwardCanvasEvents)})}destroy(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach(t=>{e.removeEventListener(t,this.forwardContainerEvents)}),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}function iJ(t){const{id:e=Km(t),style:n,data:r}=t,i=Pe(t,["id","style","data"]),o=Object.assign(Object.assign({},t),{style:Object.assign({},n),data:Object.assign({},r)});return function(t){return"source"in t&&"target"in t}(t)?Object.assign({id:e,data:o},i):{id:e,data:o}}function oJ(t){return t.data}class AJ{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new gE}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===Lv.NodeUpdated||e===Lv.EdgeUpdated||e===Lv.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:nE(n),original:nE(r),type:e})}else this.changes.push({value:nE(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}isBatching(){return this.batchCount>0}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=oJ(n);return this.isCombo(Km(r))||(void 0===t||t.includes(Km(r)))&&e.push(r),e},[])}getEdgeDatum(t){return oJ(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce((e,n)=>{const r=oJ(n);return(void 0===t||t.includes(Km(r)))&&e.push(r),e},[])}getComboData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=oJ(n);return this.isCombo(Km(r))?((void 0===t||t.includes(Km(r)))&&e.push(r),e):e},[])}getRootsData(t=Vv){return this.model.getRoots(t).map(oJ)}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(oJ):[]}getDescendantsData(t){const e=this.getElementDataById(t),n=[];return Zy(e,t=>{t!==e&&n.push(t)},t=>this.getChildrenData(Km(t)),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void Zv("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?oJ(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?Vv:zv,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(oJ):[]}getElementsDataByType(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementDataById(t){return"edge"===this.getElementType(t)?this.getEdgeDatum(t):this.getNodeLikeDatum(t)}getNodeLikeDatum(t){return oJ(this.model.getNode(t))}getNodeLikeData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=oJ(n);return t?t.includes(Km(r))&&e.push(r):e.push(r),e},[])}getElementDataByState(t,e){return this.getElementsDataByType(t).filter(t=>{var n;return null===(n=t.states)||void 0===n?void 0:n.includes(e)})}getElementState(t){var e;return(null===(e=this.getElementDataById(t))||void 0===e?void 0:e.states)||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(oJ)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(oJ)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i,edges:o,combos:A}=this.getData(),s=ty(i,e,t=>Km(t),rE),a=ty(o,n,t=>Km(t),rE),c=ty(A,r,t=>Km(t),rE);this.batch(()=>{const t={nodes:s.enter,edges:a.enter,combos:c.enter};this.addData(t),this.computeZIndex(t,"add",!0);const e={nodes:s.update,edges:a.update,combos:c.update};this.updateData(e),this.computeZIndex(e,"update",!0);const n={nodes:s.exit.map(Km),edges:a.exit.map(Km),combos:c.exit.map(Km)};this.removeData(n)})}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)}),this.computeZIndex(t,"add")}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map(t=>(this.pushChange({value:t,type:Lv.NodeAdded}),iJ(t)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map(t=>(this.pushChange({value:t,type:Lv.EdgeAdded}),iJ(t)))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(zv)||e.attachTreeStructure(zv),e.addNodes(t.map(t=>(this.comboIds.add(Km(t)),this.pushChange({value:t,type:Lv.ComboAdded}),iJ(t)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const n=this.getNodeLikeDatum(t),r=e.map(Km);this.addNodeData(e),this.updateNodeData([{id:t,children:[...n.children||[],...r]}]),this.addEdgeData(r.map(e=>({source:t,target:e})))}computeZIndex(t,e,n=!1){!n&&this.isBatching()||this.batch(()=>{const{nodes:n=[],edges:r=[],combos:i=[]}=t;i.forEach(t=>{var n,r,i;const o=Km(t);if("add"===e&&re(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t))return;const A=this.getParentData(o,zv),s=A?(null!==(i=null===(r=A.style)||void 0===r?void 0:r.zIndex)&&void 0!==i?i:0)+1:0;this.preventUpdateNodeLikeHierarchy(()=>{this.updateComboData([{id:o,style:{zIndex:s}}])})}),n.forEach(t=>{var n,r,i;const o=Km(t);if("add"===e&&re(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t)&&!("children"in t))return;let A=0;const s=this.getParentData(o,zv);if(s)A=((null===(r=s.style)||void 0===r?void 0:r.zIndex)||0)+1;else{const t=this.getParentData(o,Vv);t&&(A=(null===(i=null==t?void 0:t.style)||void 0===i?void 0:i.zIndex)||0)}this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:o,style:{zIndex:A}}])})}),r.forEach(t=>{var e,n,r,i,o;if(re(null===(e=t.style)||void 0===e?void 0:e.zIndex))return;let{id:A,source:s,target:a}=t;if(A){const t=this.getEdgeDatum(A);s=t.source,a=t.target}else A=Km(t);if(!s||!a)return;const c=(null===(r=null===(n=this.getNodeLikeDatum(s))||void 0===n?void 0:n.style)||void 0===r?void 0:r.zIndex)||0,l=(null===(o=null===(i=this.getNodeLikeDatum(a))||void 0===i?void 0:i.style)||void 0===o?void 0:o.zIndex)||0;this.updateEdgeData([{id:Km(t),style:{zIndex:Math.max(c,l)-1}}])})})}getFrontZIndex(t){var e;const n=this.getElementType(t),r=this.getElementDataById(t),i=this.getData();if(Object.assign(i,{[`${n}s`]:i[`${n}s`].filter(e=>Km(e)!==t)}),"combo"===n&&!rw(r)){const e=new Set(this.getAncestorsData(t,zv).map(Km));i.nodes=i.nodes.filter(t=>!e.has(Km(t))),i.combos=i.combos.filter(t=>!e.has(Km(t))),i.edges=i.edges.filter(({source:t,target:n})=>!e.has(t)&&!e.has(n))}return Math.max((null===(e=r.style)||void 0===e?void 0:e.zIndex)||0,0,...Object.values(i).flat().map(t=>{var e;return((null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0)+1}))}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach(t=>{const n=Km(t),r=jm(t);void 0!==r&&(e.hasTreeStructure(zv)||e.attachTreeStructure(zv),null===r&&this.refreshComboData(n),this.setParent(n,jm(t),zv));const i=t.children||[];if(i.length){e.hasTreeStructure(Vv)||e.attachTreeStructure(Vv);const t=i.filter(t=>e.hasNode(t));t.forEach(t=>this.setParent(t,n,Vv)),t.length!==i.length&&this.updateNodeData([{id:n,children:t}])}})}preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.updateNodeData(e),this.updateComboData(r),this.updateEdgeData(n)}),this.computeZIndex(t,"update")}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{const n=[];t.forEach(t=>{const r=Km(t),i=oJ(e.getNode(r));if(rE(i,t))return;const o=eE(i,t);this.pushChange({value:o,original:i,type:Lv.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({nodes:t},"update")}refreshData(){const{nodes:t,edges:e,combos:n}=this.getData();t.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.NodeUpdated})}),e.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.EdgeUpdated})}),n.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.ComboUpdated})})}syncNodeLikeDatum(t){const{model:e}=this,n=Km(t);if(!e.hasNode(n))return;const r=eE(oJ(e.getNode(n)),t);e.mergeNodeData(n,r)}syncEdgeDatum(t){const{model:e}=this,n=Km(t);if(!e.hasEdge(n))return;const r=eE(oJ(e.getEdge(n)),t);e.mergeEdgeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{t.forEach(t=>{const n=Km(t),r=oJ(e.getEdge(n));if(rE(r,t))return;t.source&&r.source!==t.source&&e.updateEdgeSource(n,t.source),t.target&&r.target!==t.target&&e.updateEdgeTarget(n,t.target);const i=eE(r,t);this.pushChange({value:i,original:r,type:Lv.EdgeUpdated}),e.mergeEdgeData(n,i)})}),this.computeZIndex({edges:t},"update")}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch(()=>{const n=[];t.forEach(t=>{const r=Km(t),i=oJ(e.getNode(r));if(rE(i,t))return;const o=eE(i,t);this.pushChange({value:o,original:i,type:Lv.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({combos:t},"update")}setParent(t,e,n,r=!0){if(t===e)return;const i=jm(this.getNodeLikeDatum(t));if(i!==e&&n===zv){const n={id:t,combo:e};this.isCombo(t),this.syncNodeLikeDatum(n)}this.model.setParent(t,e,n),r&&n===zv&&function(t,e){void 0===e&&(e=new Map);var n=[];if(Array.isArray(t))for(var r=0,i=t.length;r<i;r++){var o=t[r];e.has(o)||(n.push(o),e.set(o,!0))}return n}([i,e]).forEach(t=>{void 0!==t&&this.refreshComboData(t)})}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,zv);e&&this.pushChange({value:e,original:e,type:Lv.ComboUpdated}),n.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.ComboUpdated})})}getElementPosition(t){return My(this.getElementDataById(t))}translateNodeLikeBy(t,e){this.isCombo(t)?this.translateComboBy(t,e):this.translateNodeBy(t,e)}translateNodeLikeTo(t,e){this.isCombo(t)?this.translateComboTo(t,e):this.translateNodeTo(t,e)}translateNodeBy(t,e){const n=ay(this.getElementPosition(t),[...e,0].slice(0,3));this.translateNodeTo(t,n)}translateNodeTo(t,e){const[n=0,r=0,i=0]=e;this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:t,style:{x:n,y:r,z:i}}])})}translateComboBy(t,e){const[n=0,r=0,i=0]=e;if([n,r,i].some(isNaN)||[n,r,i].every(t=>0===t))return;const o=this.getComboData([t])[0];if(!o)return;const A=new Set;Zy(o,t=>{const e=Km(t);if(A.has(e))return;A.add(e);const[o,s,a]=My(t),c=eE(t,{style:{x:o+n,y:s+r,z:a+i}});this.pushChange({value:c,original:t,type:this.isCombo(e)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(e,c)},t=>this.getChildrenData(Km(t)),"BT")}translateComboTo(t,e){var n;if(e.some(isNaN))return;const[r=0,i=0,o=0]=e,A=null===(n=this.getComboData([t]))||void 0===n?void 0:n[0];if(!A)return;const[s,a,c]=My(A),l=r-s,u=i-a,h=o-c;Zy(A,t=>{const e=Km(t),[n,r,i]=My(t),o=eE(t,{style:{x:n+l,y:r+u,z:i+h}});this.pushChange({value:o,original:t,type:this.isCombo(e)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(e,o)},t=>this.getChildrenData(Km(t)),"BT")}removeData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.removeEdgeData(n),this.removeNodeData(e),this.removeComboData(r),this.latestRemovedComboIds=new Set(r)})}removeNodeData(t=[]){t.length&&this.batch(()=>{t.forEach(t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Km)),this.pushChange({value:this.getNodeData([t])[0],type:Lv.NodeRemoved}),this.removeNodeLikeHierarchy(t)}),this.model.removeNodes(t)})}removeEdgeData(t=[]){t.length&&(t.forEach(t=>this.pushChange({value:this.getEdgeData([t])[0],type:Lv.EdgeRemoved})),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch(()=>{t.forEach(t=>{this.pushChange({value:this.getComboData([t])[0],type:Lv.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)}),this.model.removeNodes(t)})}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(zv)){const e=jm(this.getNodeLikeDatum(t));this.setParent(t,void 0,zv,!1),this.model.getChildren(t,zv).forEach(t=>{const n=oJ(t),r=Km(n);this.setParent(Km(n),e,zv,!1);const i=eE(n,{id:Km(n),combo:e});this.pushChange({value:i,original:n,type:this.isCombo(r)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(Km(n),i)}),Kt(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error($v(`Unknown element type of id: ${t}`))}destroy(){const{model:t}=this,e=t.getAllNodes(),n=t.getAllEdges();t.removeEdges(n.map(t=>t.id)),t.removeNodes(e.map(t=>t.id)),this.context={}}}class sJ{constructor(t){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=t}init(){this.initContainer()}initContainer(){if(!this.container||this.container.destroyed){const{canvas:t}=this.context;this.container=t.appendChild(new Xa({className:"elements"}))}}emit(t,e){e.silence||qZ(this.context.graph,t)}forEachElementData(t){$y.forEach(e=>{const n=this.context.model.getElementsDataByType(e);t(e,n)})}getElementType(t,e){var n;const{options:r,graph:i}=this.context,o=oE(e)&&(null===(n=r[t])||void 0===n?void 0:n.type)||e.type;return o?"string"==typeof o?o:o.call(i,e):"edge"===t?"line":"circle"}getTheme(t){return Jv(this.context.options)[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:n={}}=this.getTheme(t);return Object.assign({},...e.map(t=>n[t]||{}))}computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData((e,n)=>{var r,i;const o=Object.assign({},hw(null===(r=this.getTheme(e))||void 0===r?void 0:r.palette),hw(null===(i=t[e])||void 0===i?void 0:i.palette));(null==o?void 0:o.field)&&Object.assign(this.paletteStyle,function(t,e){if(!e)return{};const{type:n,color:r,field:i,invert:o}=e,A=t=>{const e="string"==typeof r?Xv("palette",r):r;if("function"==typeof e){const n={};return t.forEach(([t,r])=>{n[t]=e(o?1-r:r)}),n}if(Array.isArray(e)){const n=o?[...e].reverse():e,r={};return t.forEach(([t,i])=>{r[t]=n[i%e.length]}),r}return{}},s=(t,e)=>{var n;return"string"==typeof t?null===(n=e.data)||void 0===n?void 0:n[t]:null==t?void 0:t(e)};if("group"===n){const e=ee(t,t=>{if(!i)return"default";const e=s(i,t);return e?String(e):"default"}),n=A(Object.keys(e).map((t,e)=>[t,e])),r={};return Object.entries(e).forEach(([t,e])=>{e.forEach(e=>{r[Km(e)]=n[t]})}),r}if("value"===n){const[e,n]=t.reduce(([t,e],n)=>{const r=s(i,n);if("number"!=typeof r)throw new Error($v(`Palette field ${i} is not a number`));return[Math.min(t,r),Math.max(e,r)]},[1/0,-1/0]),r=n-e;return A(t.map(t=>[t.id,(s(i,t)-e)/r]))}}(n,o))})}getPaletteStyle(t,e){const n=this.paletteStyle[e];return n?"edge"===t?{stroke:n}:{fill:n}:{}}computeElementDefaultStyle(t,e){var n;const{options:r}=this.context,i=(null===(n=r[t])||void 0===n?void 0:n.style)||{};"transform"in i&&Array.isArray(i.transform)&&(i.transform=[...i.transform]),this.defaultStyle[Km(e.datum)]=lw(i,e)}computeElementsDefaultStyle(t){const{graph:e}=this.context;this.forEachElementData((n,r)=>{const i=r.length;for(let o=0;o<i;o++){const i=r[o];(void 0===t||t.includes(Km(i)))&&this.computeElementDefaultStyle(n,{datum:i,graph:e})}})}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch(t){return[]}}getElementStateStyle(t,e,n){var r,i;const{options:o}=this.context;return lw((null===(i=null===(r=o[t])||void 0===r?void 0:r.state)||void 0===i?void 0:i[e])||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[Km(n.datum)]=Object.assign({},...e.map(e=>this.getElementStateStyle(t,e,n)))}computeElementsStatesStyle(t){const{graph:e}=this.context;this.forEachElementData((n,r)=>{const i=r.length;for(let o=0;o<i;o++){const i=r[o];if(void 0===t||t.includes(Km(i))){const t=this.getElementState(Km(i));this.computeElementStatesStyle(n,t,{datum:i,graph:e})}}})}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t,e){t&&["translate","zIndex"].includes(t)||(this.computePaletteStyle(),this.computeElementsDefaultStyle(e),this.computeElementsStatesStyle(e))}getElement(t){return this.elementMap[t]}getNodes(){return this.context.model.getNodeData().map(({id:t})=>this.elementMap[t])}getEdges(){return this.context.model.getEdgeData().map(t=>this.elementMap[Km(t)])}getCombos(){return this.context.model.getComboData().map(({id:t})=>this.elementMap[t])}getElementComputedStyle(t,e){const n=Km(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(t,n),o=e.style||{},A=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),a=this.getStateStyle(n),c=oE(e)?Object.assign({},r,i,o,A,s,a):Object.assign({},o);if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!c.collapsed?[]:t.map(Km).filter(t=>this.getElement(t));Object.assign(c,{childrenNode:e,childrenData:t})}return c}getDrawData(t){this.init();const e=this.computeChangesAndDrawData(t);if(!e)return null;const{type:n="draw",stage:r=n}=t;return this.markDestroyElement(e.drawData),this.computeStyle(r),{type:n,stage:r,data:e}}draw(t={animation:!0}){const e=this.getDrawData(t);if(!e)return;const{data:{drawData:{add:n,update:r,remove:i}}}=e;return this.destroyElements(i,t),this.createElements(n,t),this.updateElements(r,t),this.setAnimationTask(t,e)}preLayoutDraw(){return De(this,arguments,void 0,function*(t={animation:!0}){var e,n;const r=this.getDrawData(t);if(!r)return;const{data:{drawData:i}}=r;yield null===(n=null===(e=this.context.layout)||void 0===e?void 0:e.preLayout)||void 0===n?void 0:n.call(e,i);const{add:o,update:A,remove:s}=i;return this.destroyElements(s,t),this.createElements(o,t),this.updateElements(A,t),this.setAnimationTask(t,r)})}setAnimationTask(e,n){const{animation:r,silence:i}=e,{data:{dataChanges:o,drawData:A},stage:s,type:a}=n;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new VZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===a}),e),beforeAnimate:n=>this.emit(new WZ(t.GraphEvent.BEFORE_ANIMATE,Pv.DRAW,n,A),e),afterAnimate:n=>this.emit(new WZ(t.GraphEvent.AFTER_ANIMATE,Pv.DRAW,n,A),e),after:()=>this.emit(new VZ(t.GraphEvent.AFTER_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===a,firstRender:!1===this.context.graph.rendered}),e)})}computeChangesAndDrawData(t){const{model:e}=this.context,n=e.getChanges(),r=nV(n);if(0===r.length)return null;const{NodeAdded:i=[],NodeUpdated:o=[],NodeRemoved:A=[],EdgeAdded:s=[],EdgeUpdated:a=[],EdgeRemoved:c=[],ComboAdded:l=[],ComboUpdated:u=[],ComboRemoved:h=[]}=ee(r,t=>t.type),d=(t,e)=>{const n=[];return t.forEach(t=>{const r=Km(t.value);this.getElement(r)?n.push(t):e.push(t)}),n},f=d(o,i),g=d(a,s),p=d(u,l),v=t=>new Map(t.map(t=>{const e=t.value;return[Km(e),e]})),m={add:{nodes:v(i),edges:v(s),combos:v(l)},update:{nodes:v(f),edges:v(g),combos:v(p)},remove:{nodes:v(A),edges:v(c),combos:v(h)}},y=this.transformData(m,t);return e.clearChanges(),{dataChanges:n,drawData:y}}transformData(t,e){const n=this.context.transform.getTransformInstance();return Object.values(n).reduce((t,n)=>n.beforeDraw(t,e),t)}createElement(e,n,r){var i;const o=Km(n);if(this.getElement(o))return;const A=this.getElementType(e,n),s=this.getElementComputedStyle(e,n),a=Xv(e,A);if(!a)return Zv(`The element ${A} of ${e} is not registered.`);this.emit(new YZ(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const c=this.container.appendChild(new a({id:o,context:this.context,style:s}));this.shapeTypeMap[o]=A,this.elementMap[o]=c;const{stage:l="enter"}=r;null===(i=this.context.animation)||void 0===i||i.add({element:c,elementType:e,stage:l,originalStyle:Object.assign({},c.attributes),updatedStyle:s},{after:()=>{var i;this.emit(new YZ(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),null===(i=c.onCreate)||void 0===i||i.call(c)}})}createElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach(([t,n])=>{n.forEach(n=>this.createElement(t,n,e))})}getUpdateStageStyle(t,e,n){const{stage:r="update"}=n;if("translate"===r){if("node"===t||"combo"===t){const{style:{x:t=0,y:n=0,z:r=0}={}}=e;return{x:t,y:n,z:r}}return{}}return this.getElementComputedStyle(t,e)}updateElement(e,n,r){var i;const o=Km(n),{stage:A="update"}=r,s=this.getElement(o);if(!s)return()=>null;this.emit(new YZ(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const a=this.getElementType(e,n),c=this.getUpdateStageStyle(e,n,r);this.shapeTypeMap[o]!==a&&(s.destroy(),delete this.shapeTypeMap[o],delete this.elementMap[o],this.createElement(e,n,{animation:!1,silence:!0}));const l="visibility"!==A?A:"hidden"===c.visibility?"hide":"show";"hide"===l&&delete c.visibility,null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:l,originalStyle:Object.assign({},s.attributes),updatedStyle:c},{before:()=>{const t=this.elementMap[o];"collapse"!==A&&ZB(t,c),"visibility"===A&&(function(t,e){return JZ(e)in(Ce(t,ZZ)||{})}(t,"opacity")||function(t,e){const n=Array.isArray(e)?e:[e];Ce(t,ZZ)||Me(t,ZZ,{}),n.forEach(e=>{Me(Ce(t,ZZ),JZ(e),t.attributes[e])})}(t,"opacity"),this.visibilityCache.set(t,"show"===l?"visible":"hidden"),"show"===l&&ey(t,"visible"))},after:()=>{var i;const s=this.elementMap[o];"collapse"===A&&ZB(s,c),"hide"===l&&ey(s,this.visibilityCache.get(s)),this.emit(new YZ(t.GraphEvent.AFTER_ELEMENT_UPDATE,e,n),r),null===(i=s.onUpdate)||void 0===i||i.call(s)}})}updateElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach(([t,n])=>{n.forEach(n=>this.updateElement(t,n,e))})}markDestroyElement(t){Object.values(t.remove).forEach(t=>{t.forEach(t=>{const e=Km(t),n=this.getElement(e);n&&function(t){Me(t,"__to_be_destroyed__",!0)}(n)})})}destroyElement(e,n,r){var i;const{stage:o="exit"}=r,A=Km(n),s=this.elementMap[A];if(!s)return()=>null;this.emit(new YZ(t.GraphEvent.BEFORE_ELEMENT_DESTROY,e,n),r),null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:o,originalStyle:Object.assign({},s.attributes),updatedStyle:{}},{after:()=>{var i;this.clearElement(A),s.destroy(),null===(i=s.onDestroy)||void 0===i||i.call(s),this.emit(new YZ(t.GraphEvent.AFTER_ELEMENT_DESTROY,e,n),r)}})}destroyElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["combo",i],["edge",r],["node",n]].forEach(([t,n])=>{n.forEach(n=>this.destroyElement(t,n,e))})}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}alignLayoutResultToElement(t,e){var n,r;const i=null===(n=t.nodes)||void 0===n?void 0:n.find(t=>Km(t)===e);if(i){const n=cy(My(this.context.model.getNodeLikeDatum(e)),My(i));null===(r=t.nodes)||void 0===r||r.forEach(t=>{var e,r,i;(null===(e=t.style)||void 0===e?void 0:e.x)&&(t.style.x+=n[0]),(null===(r=t.style)||void 0===r?void 0:r.y)&&(t.style.y+=n[1]),(null===(i=t.style)||void 0===i?void 0:i.z)&&(t.style.z+=n[2]||0)})}}syncLayoutResult(t,e){return De(this,void 0,void 0,function*(){const{layout:n,model:r}=this.context;if(!n)return;const i=this.context.options.layout,o=yield n.simulate(i?(A=i,Array.isArray(A)?A.map(t=>Object.assign(Object.assign({},t),{preLayout:!0})):Object.assign(Object.assign({},A),{preLayout:!0})):void 0);var A;e&&this.alignLayoutResultToElement(o,t),r.updateData(o)})}collapseNode(e,n){return De(this,void 0,void 0,function*(){var r;const{animation:i,align:o}=n;yield this.syncLayoutResult(e,o);const A=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(this.context.animation.clear(),this.computeStyle("collapse"),!A)return;const{drawData:s}=A,{add:a,remove:c,update:l}=s;this.markDestroyElement(s);const u={animation:i,stage:"collapse",data:s};this.destroyElements(c,u),this.createElements(a,u),this.updateElements(l,u),yield null===(r=this.context.animation.animate(i,{beforeAnimate:e=>this.emit(new WZ(t.GraphEvent.BEFORE_ANIMATE,Pv.COLLAPSE,e,s),u),afterAnimate:e=>this.emit(new WZ(t.GraphEvent.AFTER_ANIMATE,Pv.COLLAPSE,e,s),u)},{collapse:{target:e,descendants:Array.from(c.nodes).map(([,t])=>Km(t)),position:My(l.nodes.get(e))}}))||void 0===r?void 0:r.finished})}expandNode(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i}=this.context,{animation:o,align:A}=n,s=My(i.getNodeData([e])[0]);yield this.syncLayoutResult(e,A);const a=this.computeChangesAndDrawData({stage:"expand",animation:o});if(this.createElements(a.drawData.add,{animation:!1,stage:"expand",target:e}),this.context.animation.clear(),this.computeStyle("expand"),!a)return;const{drawData:c}=a,{update:l,add:u}=c,h={animation:o,stage:"expand",data:c};u.edges.forEach(t=>l.edges.set(Km(t),t)),u.nodes.forEach(t=>l.nodes.set(Km(t),t)),this.updateElements(l,h),yield null===(r=this.context.animation.animate(o,{beforeAnimate:e=>this.emit(new WZ(t.GraphEvent.BEFORE_ANIMATE,Pv.EXPAND,e,c),h),afterAnimate:e=>this.emit(new WZ(t.GraphEvent.AFTER_ANIMATE,Pv.EXPAND,e,c),h)},{expand:{target:e,descendants:Array.from(u.nodes).map(([,t])=>Km(t)),position:s}}))||void 0===r?void 0:r.finished})}collapseCombo(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i,element:o}=this.context;if(i.getAncestorsData(e,zv).some(t=>rw(t)))return;const A=o.getElement(e),s=A.getComboPosition(Object.assign(Object.assign({},A.attributes),{collapsed:!0})),a=this.computeChangesAndDrawData({stage:"collapse",animation:n});if(!a)return;const{dataChanges:c,drawData:l}=a;this.markDestroyElement(l);const{update:u,remove:h}=l,d={animation:n,stage:"collapse",data:l};this.destroyElements(h,d),this.updateElements(u,d);const f=t=>Array.from(t).map(([,t])=>Km(t));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new VZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:c,animation:n}),d),beforeAnimate:e=>this.emit(new WZ(t.GraphEvent.BEFORE_ANIMATE,Pv.COLLAPSE,e,l),d),afterAnimate:e=>this.emit(new WZ(t.GraphEvent.AFTER_ANIMATE,Pv.COLLAPSE,e,l),d),after:()=>this.emit(new VZ(t.GraphEvent.AFTER_DRAW,{dataChanges:c,animation:n}),d)},{collapse:{target:e,descendants:[...f(h.nodes),...f(h.combos)],position:s}}))||void 0===r?void 0:r.finished})}expandCombo(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i}=this.context,o=My(i.getComboData([e])[0]);this.computeStyle("expand");const A=this.computeChangesAndDrawData({stage:"expand",animation:n});if(!A)return;const{dataChanges:s,drawData:a}=A,{add:c,update:l}=a,u={animation:n,stage:"expand",data:a,target:e};this.createElements(c,u),this.updateElements(l,u);const h=t=>Array.from(t).map(([,t])=>Km(t));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new VZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:s,animation:n}),u),beforeAnimate:e=>this.emit(new WZ(t.GraphEvent.BEFORE_ANIMATE,Pv.EXPAND,e,a),u),afterAnimate:e=>this.emit(new WZ(t.GraphEvent.AFTER_ANIMATE,Pv.EXPAND,e,a),u),after:()=>this.emit(new VZ(t.GraphEvent.AFTER_DRAW,{dataChanges:s,animation:n}),u)},{expand:{target:e,descendants:[...h(c.nodes),...h(c.combos)],position:o}}))||void 0===r?void 0:r.finished})}clear(){this.container.destroy(),this.initContainer(),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={}}destroy(){this.clear(),this.container.destroy(),this.context={}}}class aJ{get presetOptions(){return{animation:!!rm(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.instances=[],this.context=t}getLayoutInstance(){return this.instances}preLayout(e){return De(this,void 0,void 0,function*(){var n,r,i,o;const{graph:A,model:s}=this.context,{add:a}=e;qZ(A,new VZ(t.GraphEvent.BEFORE_LAYOUT,{type:"pre"}));const c=yield null===(n=this.context.layout)||void 0===n?void 0:n.simulate();null===(r=null==c?void 0:c.nodes)||void 0===r||r.forEach(t=>{const e=Km(t),n=a.nodes.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)}),null===(i=null==c?void 0:c.edges)||void 0===i||i.forEach(t=>{const e=Km(t),n=a.edges.get(e);s.syncEdgeDatum(t),n&&Object.assign(n.style,t.style)}),null===(o=null==c?void 0:c.combos)||void 0===o||o.forEach(t=>{const e=Km(t),n=a.combos.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)}),qZ(A,new VZ(t.GraphEvent.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)})}postLayout(){return De(this,arguments,void 0,function*(e=this.options){if(!e)return;const n=Array.isArray(e)?e:[e],{graph:r}=this.context;qZ(r,new VZ(t.GraphEvent.BEFORE_LAYOUT,{type:"post"}));for(let e=0;e<n.length;e++){const i=n[e],o=this.getLayoutData(i),A=Object.assign(Object.assign({},this.presetOptions),i);qZ(r,new VZ(t.GraphEvent.BEFORE_STAGE_LAYOUT,{options:A,index:e}));const s=yield this.stepLayout(o,A,e);qZ(r,new VZ(t.GraphEvent.AFTER_STAGE_LAYOUT,{options:A,index:e})),i.animation||this.updateElementPosition(s,!1)}qZ(r,new VZ(t.GraphEvent.AFTER_LAYOUT,{type:"post"})),this.transformDataAfterLayout("post")})}transformDataAfterLayout(t,e){const n=this.context.transform.getTransformInstance();Object.values(n).forEach(n=>n.afterLayout(t,e))}simulate(){return De(this,arguments,void 0,function*(t=this.options){if(!t)return{};const e=Array.isArray(t)?t:[t];let n={};for(let t=0;t<e.length;t++){const r=e[t],i=this.getLayoutData(r);n=yield this.stepLayout(i,Object.assign(Object.assign(Object.assign({},this.presetOptions),r),{animation:!1}),t)}return n})}stepLayout(t,e,n){return De(this,void 0,void 0,function*(){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?yield this.treeLayout(t,e,n):yield this.graphLayout(t,e,n)})}graphLayout(t,e,n){return De(this,void 0,void 0,function*(){const{animation:r,iterations:i=300}=e,o=this.initGraphLayout(e);if(!o)return{};if(this.instances[n]=o,this.instance=o,EC(o))return r?yield o.execute(t,{animate:!0,maxIteration:i,onTick:t=>this.updateElementPosition(t,!1)}):(o.execute(t),o.stop(),o.tick(i));const A=yield o.execute(t);if(r){const t=this.updateElementPosition(A,r);yield null==t?void 0:t.finished}return A})}treeLayout(t,e,n){return De(this,void 0,void 0,function*(){const{type:n,animation:r}=e,i=Xv("layout",n);if(!i)return{};const{nodes:o=[],edges:A=[]}=t,s=new gE({nodes:o.map(t=>({id:Km(t),data:t.data||{}})),edges:A.map(t=>({id:Km(t),source:t.source,target:t.target,data:t.data||{}}))});!function(t){if(t.hasTreeStructure(Vv))return;t.attachTreeStructure(Vv);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,Vv)}}(s);const a={nodes:[],edges:[]},c={nodes:[],edges:[]};s.getRoots(Vv).forEach(t=>{Zy(t,t=>{t.children=s.getSuccessors(t.id)},t=>s.getSuccessors(t.id),"TB");const n=i(t,e),{x:r,y:o,z:A=0}=n;Zy(n,t=>{const{id:e,x:n,y:i,z:s=0}=t;a.nodes.push({id:e,style:{x:r,y:o,z:A}}),c.nodes.push({id:e,style:{x:n,y:i,z:s}})},t=>t.children,"TB")});const l=this.inferTreeLayoutOffset(c);if(cJ(c,l),r){cJ(a,l),this.updateElementPosition(a,!1);const t=this.updateElementPosition(c,r);yield null==t?void 0:t.finished}return c})}inferTreeLayoutOffset(t){var e;let[n,r]=[1/0,-1/0],[i,o]=[1/0,-1/0];null===(e=t.nodes)||void 0===e||e.forEach(t=>{const{x:e=0,y:A=0}=t.style||{};n=Math.min(n,e),r=Math.max(r,e),i=Math.min(i,A),o=Math.max(o,A)});const{canvas:A}=this.context,s=A.getSize(),[a,c]=A.getCanvasByViewport([0,0]),[l,u]=A.getCanvasByViewport(s);if(n>=a&&r<=l&&i>=c&&o<=u)return[0,0];return[(a+l)/2-(n+r)/2,(c+u)/2-(i+o)/2]}stopLayout(){this.instance&&EC(this.instance)&&(this.instance.stop(),this.instance=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutData(t){const{nodeFilter:e=()=>!0,comboFilter:n=()=>!0,preLayout:r=!1,isLayoutInvisibleNodes:i=!1}=t,{nodes:o,edges:A,combos:s}=this.context.model.getData(),{element:a,model:c}=this.context,l=t=>a.getElement(t),u=r?t=>{var n;if(!i){if("hidden"===(null===(n=t.style)||void 0===n?void 0:n.visibility))return!1;if(c.getAncestorsData(t.id,Vv).some(rw))return!1;if(c.getAncestorsData(t.id,zv).some(rw))return!1}return e(t)}:t=>{const n=Km(t),r=l(n);return!!r&&(!JB(r)&&e(t))},h=o.filter(u),d=s.filter(n),f=new Map(h.map(t=>[Km(t),t]));d.forEach(t=>f.set(Km(t),t));return{nodes:h,edges:A.filter(({source:t,target:e})=>f.has(t)&&f.has(e)),combos:d}}initGraphLayout(t){var e;const{element:n,viewport:r}=this.context,{type:i,animation:o,iterations:A}=t,s=Pe(t,["type","animation","iterations"]),[a,c]=r.getCanvasSize(),l=[a/2,c/2],u=null!==(e=null==t?void 0:t.nodeSize)&&void 0!==e?e:t=>{const e=null==n?void 0:n.getElement(t.id);return e?e.attributes.size:null==n?void 0:n.getElementComputedStyle("node",t).size},h=Xv("layout",i);if(!h)return Zv(`The layout of ${i} is not registered.`);const d=Object.getPrototypeOf(h.prototype)===pE.prototype?h:function(t){return!("forEachNode"in t.prototype)&&!("forEachEdge"in t.prototype)}(h)?function(t,e){return class extends pE{constructor(e,n){if(super(e,n),this.instance=new t({}),this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>{var n;return mE(null===(n=t.tick)||void 0===n?void 0:n.call(t,e))}}}execute(t,e){return De(this,void 0,void 0,function*(){return mE(yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(be({},this.options,e))))})}transformOptions(t){if(!("onTick"in t))return t;const e=t.onTick;return t.onTick=t=>e(mE(t)),t}graphData2LayoutModel(t){const{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.map(t=>{const e=Km(t),{data:n,style:r,combo:i}=t,o=Pe(t,["data","style","combo"]),A={id:e,data:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n),{data:n}),i?{parentId:i}:{}),{style:r}),o)};return(null==r?void 0:r.x)&&Object.assign(A.data,{x:r.x}),(null==r?void 0:r.y)&&Object.assign(A.data,{y:r.y}),(null==r?void 0:r.z)&&Object.assign(A.data,{z:r.z}),A}),A=new Map(o.map(t=>[t.id,t])),s=r.filter(t=>{const{source:e,target:n}=t;return A.has(e)&&A.has(n)}).map(t=>{const{source:e,target:n,data:r,style:i}=t;return{id:Km(t),source:e,target:n,data:Object.assign({},r),style:Object.assign({},i)}}),a=i.map(t=>({id:Km(t),data:Object.assign({_isCombo:!0},t.data),style:Object.assign({},t.style)})),c=new gE({nodes:[...o,...a],edges:s});return e.model.model.hasTreeStructure(zv)&&(c.attachTreeStructure(zv),o.forEach(t=>{const n=e.model.model.getParent(t.id,zv);n&&c.hasNode(n.id)&&c.setParent(t.id,n.id,zv)})),c}}}(h,this.context):vE(h,this.context),f=new d(this.context),g={nodeSize:u,width:a,height:c,center:l};switch(f.id){case"d3-force":case"d3-force-3d":Object.assign(g,{center:{x:a/2,y:c/2,z:0}})}return be(f.options,g,s),f}updateElementPosition(t,e){const{model:n,element:r}=this.context;return r?(n.updateData(t),r.draw({animation:e,silence:!0})):null}destroy(){this.stopLayout(),this.context={},this.instance=void 0,this.instances=[],this.animationResult=void 0}}const cJ=(t,e)=>{var n;const[r,i]=e;null===(n=t.nodes)||void 0===n||n.forEach(t=>{if(t.style){const{x:e=0,y:n=0}=t.style;t.style.x=e+r,t.style.y=n+i}else t.style={x:r,y:i}})};function lJ(t){return t.layout?(Array.isArray(t.layout)||"preLayout"in t.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(t.layout.type)&&(t.layout.preLayout=!0),t):t}class uJ extends ny{constructor(t){super(t),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){const e=this.extensionMap[t];if(e)return e;Zv(`Cannot find the plugin ${t}, will try to find it by type.`);const n=this.extensions.find(e=>e.type===t);return n?this.extensionMap[n.key]:void 0}}const hJ=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class dJ extends ny{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...hJ.slice(0,hJ.length-1),...t,hJ[hJ.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class fJ{get padding(){return pm(this.context.options.padding)}get paddingOffset(){const[t,e,n,r]=this.padding,[i,o,A]=[(r-e)/2,(t-n)/2,0];return[i,o,A]}constructor(t){this.landmarkCounter=0,this.context=t;const[e,n]=this.paddingOffset,{zoom:r,rotation:i,x:o=e,y:A=n}=t.options;this.transform({mode:"absolute",scale:r,translate:[o,A],rotate:i},!1)}get camera(){const{canvas:t}=this.context;return new Proxy(t.getCamera(),{get:(e,n)=>{const r=Object.entries(t.getLayers()).filter(([t])=>!["main"].includes(t)),i=r.map(([,t])=>t.getCamera()),o=e[n];if("function"==typeof o)return(...t)=>{const r=o.apply(e,t);return i.forEach(e=>{e[n].apply(e,t)}),r}}})}createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=rm(this.context.options,t);return!!e&&ke(Object.assign({},e),["easing","duration"])}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e,n]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e/2,n/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateOptions(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),A=e.getFocalPoint(),[s,a]=this.getCanvasCenter(),[c=0,l=0,u=0]=r,h=uy([-c,-l,-u],i);return"relative"===n?{position:ay(o,h),focalPoint:ay(A,h)}:{position:ay([s,a,o[2]],h),focalPoint:ay([s,a,A[2]],h)}}getRotateOptions(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomOptions(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return ne("relative"===r?n*i:i,...e)}transform(e,n){return De(this,void 0,void 0,function*(){const{graph:r}=this.context,{translate:i,rotate:o,scale:A,origin:s}=e;this.cancelAnimation();const a=this.getAnimation(n);if(qZ(r,new XZ(t.GraphEvent.BEFORE_TRANSFORM,e)),!o&&A&&!i&&s&&!a)return this.camera.setZoomByViewportPoint(this.getZoomOptions(e),s),void qZ(r,new XZ(t.GraphEvent.AFTER_TRANSFORM,e));const c={};if(i&&Object.assign(c,this.getTranslateOptions(e)),re(o)&&Object.assign(c,this.getRotateOptions(e)),re(A)&&Object.assign(c,{zoom:this.getZoomOptions(e)}),a)return qZ(r,new WZ(t.GraphEvent.BEFORE_ANIMATE,Pv.TRANSFORM,null,e)),new Promise(n=>{this.transformResolver=n,this.camera.gotoLandmark(this.createLandmark(c),Object.assign(Object.assign({},a),{onfinish:()=>{qZ(r,new WZ(t.GraphEvent.AFTER_ANIMATE,Pv.TRANSFORM,null,e)),qZ(r,new XZ(t.GraphEvent.AFTER_TRANSFORM,e)),this.transformResolver=void 0,n()}}))});this.camera.gotoLandmark(this.createLandmark(c),{duration:0}),qZ(r,new XZ(t.GraphEvent.AFTER_TRANSFORM,e))})}fitView(t,e){return De(this,void 0,void 0,function*(){const[n,r,i,o]=this.padding,{when:A="always",direction:s="both"}=t||{},[a,c]=this.context.canvas.getSize(),l=a-o-r,u=c-n-i,h=this.context.canvas.getBounds(),d=this.getBBoxInViewport(h),[f,g]=wm(d);if("overflow"===A&&!("x"===s&&f>=l||"y"===s&&g>=u||"both"===s&&f>=l&&g>=u))return yield this.fitCenter({animation:e});const p=l/f,v=u/g,m="x"===s?p:"y"===s?v:Math.min(p,v),y=this.getAnimation(e);Number.isFinite(m)&&(yield this.transform({mode:"relative",scale:m,translate:ay(cy(this.getCanvasCenter(),this.getBBoxInViewport(h).center),uy(this.paddingOffset,m))},y))})}fitCenter(t){return De(this,void 0,void 0,function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)})}focusElements(t){return De(this,arguments,void 0,function*(t,e={}){const{element:n}=this.context;if(!n)return;const r=xm(t.map(t=>{return r=n.getElement(t),e.shapes?r.getShape(e.shapes).getRenderBounds():r.getRenderBounds();var r}));yield this.focus(r,e)})}focus(t,e){return De(this,void 0,void 0,function*(){const n=this.context.graph.getViewportByCanvas(t.center),r=cy(e.position||this.getCanvasCenter(),n);yield this.transform({mode:"relative",translate:ay(r,this.paddingOffset)},e.animation)})}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[A,s]=r.getViewportByCanvas(n),a=new yr;return a.setMinMax([i,o,0],[A,s,0]),a}isInViewport(t,e=!1,n=0){const{graph:r}=this.context,i=this.getCanvasSize(),[o,A]=r.getCanvasByViewport([0,0]),[s,a]=r.getCanvasByViewport(i);let c=new yr;return c.setMinMax([o,A,0],[s,a,0]),n&&(c=Em(c,n)),fm(t)?Cm(t,c):e?function(t,e){const[n,r]=t.min,[i,o]=t.max,[A,s]=e.min,[a,c]=e.max;return n>=A&&i<=a&&r>=s&&o<=c}(t,c):c.intersects(t)}cancelAnimation(){var t,e;(null===(t=this.camera.landmarks)||void 0===t?void 0:t.length)&&this.camera.cancelLandmarkAnimation(),null===(e=this.transformResolver)||void 0===e||e.call(this)}}class gJ extends lE{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new AJ},this.isCollapsingExpanding=!1,this.onResize=pe(()=>{this.resize()},300),this._setOptions(Object.assign({},gJ.defaultOptions,t),!0),this.context.graph=this,this.options.autoResize&&(null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(t){this._setOptions(t,!1)}_setOptions(t,e){if(this.updateCanvas(t),Object.assign(this.options,function(t){return[lJ].reduce((t,e)=>e(t),t)}(t)),e){const{data:e}=t;return void(e&&this.addData(e))}const{behaviors:n,combo:r,data:i,edge:o,layout:A,node:s,plugins:a,theme:c,transforms:l}=t;n&&this.setBehaviors(n),i&&this.setData(i),s&&this.setNode(s),o&&this.setEdge(o),r&&this.setCombo(r),A&&this.setLayout(A),c&&this.setTheme(c),a&&this.setPlugins(a),l&&this.setTransforms(l)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){t&&(this.options.width=t),e&&(this.options.height=e),this.resize(t,e)}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t,this.context.model.refreshData()}setEdge(t){this.options.edge=t,this.context.model.refreshData()}setCombo(t){this.options.combo=t,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(t){this.options.theme=Gt(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=Gt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=Gt(t)?t(this.getBehaviors()):t,null===(e=this.context.behavior)||void 0===e||e.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){var e;this.options.plugins=Gt(t)?t(this.getPlugins()):t,null===(e=this.context.plugin)||void 0===e||e.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){var e;this.options.transforms=Gt(t)?t(this.getTransforms()):t,null===(e=this.context.transform)||void 0===e||e.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e)),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}hasNode(t){return this.context.model.hasNode(t)}hasEdge(t){return this.context.model.hasEdge(t)}hasCombo(t){return this.context.model.hasCombo(t)}getElementData(t){return Array.isArray(t)?t.map(t=>this.context.model.getElementDataById(t)):this.context.model.getElementDataById(t)}getNodeData(t){return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeLikeDatum(t)}getEdgeData(t){return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeDatum(t)}getComboData(t){return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getNodeLikeDatum(t)}setData(t){this.context.model.setData(Gt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Gt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Gt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Gt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Gt(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(Gt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Gt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Gt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Gt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Gt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Gt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Gt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Gt(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getDescendantsData(t){return this.context.model.getDescendantsData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}initCanvas(){return De(this,void 0,void 0,function*(){var e;if(this.context.canvas)return yield this.context.canvas.ready;const{container:n="container",width:r,height:i,renderer:o,cursor:A,background:s,canvas:a,devicePixelRatio:c=(null!==(e=globalThis.devicePixelRatio)&&void 0!==e?e:1)}=this.options;if(n instanceof HZ)this.context.canvas=n,A&&n.setCursor(A),o&&n.setRenderer(o),yield n.ready;else{const e=Jt(n)?document.getElementById(n):n,l=jZ(e);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:e,width:r,height:i});const u=Object.assign(Object.assign({},a),{container:e,width:r||l[0],height:i||l[1],background:s,renderer:o,cursor:A,devicePixelRatio:c}),h=new HZ(u);this.context.canvas=h,yield h.ready,this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:h})}})}updateCanvas(e){var n,r;const{renderer:i,cursor:o,height:A,width:s}=e,a=this.context.canvas;a&&(i&&(this.emit(t.GraphEvent.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),a.setRenderer(i),this.emit(t.GraphEvent.AFTER_RENDERER_CHANGE,{renderer:i})),o&&a.setCursor(o),(re(s)||re(A))&&this.setSize(null!==(n=null!=s?s:this.options.width)&&void 0!==n?n:0,null!==(r=null!=A?A:this.options.height)&&void 0!==r?r:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new nJ(this.context)),this.context.plugin||(this.context.plugin=new uJ(this.context)),this.context.viewport||(this.context.viewport=new fJ(this.context)),this.context.transform||(this.context.transform=new dJ(this.context)),this.context.element||(this.context.element=new sJ(this.context)),this.context.animation||(this.context.animation=new eJ(this.context)),this.context.layout||(this.context.layout=new aJ(this.context)),this.context.behavior||(this.context.behavior=new rJ(this.context))}prepare(){return De(this,void 0,void 0,function*(){yield Promise.resolve(),this.destroyed?console.error($v("The graph instance has been destroyed")):(yield this.initCanvas(),this.initRuntime())})}render(){return De(this,void 0,void 0,function*(){if(yield this.prepare(),qZ(this,new VZ(t.GraphEvent.BEFORE_RENDER)),this.options.layout)if(this.rendered||(e=this.options.layout,Array.isArray(e)||!(null==e?void 0:e.preLayout))){const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const t=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}else{const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}var e;this.rendered=!0,qZ(this,new VZ(t.GraphEvent.AFTER_RENDER))})}draw(){return De(this,void 0,void 0,function*(){var t;yield this.prepare(),yield null===(t=this.context.element.draw())||void 0===t?void 0:t.finished})}layout(t){return De(this,void 0,void 0,function*(){yield this.context.layout.postLayout(t)})}stopLayout(){this.context.layout.stopLayout()}clear(){return De(this,void 0,void 0,function*(){const{model:t,element:e}=this.context;t.setData({}),t.clearChanges(),null==e||e.clear()})}destroy(){var e;qZ(this,new VZ(t.GraphEvent.BEFORE_DESTROY));const{layout:n,animation:r,element:i,model:o,canvas:A,behavior:s,plugin:a}=this.context;null==a||a.destroy(),null==s||s.destroy(),null==n||n.destroy(),null==r||r.destroy(),null==i||i.destroy(),o.destroy(),null==A||A.destroy(),this.options={},this.context={},this.off(),null===(e=globalThis.removeEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize),this.destroyed=!0,qZ(this,new VZ(t.GraphEvent.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,n){var r;const i=jZ(null===(r=this.context.canvas)||void 0===r?void 0:r.getContainer()),o=[e||i[0],n||i[1]];if(!this.context.canvas)return;const A=this.context.canvas.getSize();xe(o,A)||(qZ(this,new VZ(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:o})),this.context.canvas.resize(...o),qZ(this,new VZ(t.GraphEvent.AFTER_SIZE_CHANGE,{size:o})))}fitView(t,e){return De(this,void 0,void 0,function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.fitView(t,e)})}fitCenter(t){return De(this,void 0,void 0,function*(){var e;yield null===(e=this.context.viewport)||void 0===e?void 0:e.fitCenter({animation:t})})}autoFit(){return De(this,void 0,void 0,function*(){const{autoFit:t}=this.context.options;if(t)if(Jt(t))"view"===t?yield this.fitView():"center"===t&&(yield this.fitCenter());else{const{type:e,animation:n}=t;"view"===e?yield this.fitView(t.options,n):"center"===e&&(yield this.fitCenter(n))}})}focusElement(t,e){return De(this,void 0,void 0,function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.focusElements(Array.isArray(t)?t:[t],{animation:e})})}zoomBy(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)})}zoomTo(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)})}getZoom(){return this.context.viewport.getZoom()}rotateBy(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)})}rotateTo(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)})}getRotation(){return this.context.viewport.getRotation()}translateBy(t,e){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)})}translateTo(t,e){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)})}getPosition(){return cy([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach(([t,e])=>this.context.model.translateNodeLikeBy(t,e)),yield null===(i=this.context.element.draw({animation:A,stage:"translate"}))||void 0===i?void 0:i.finished})}translateElementTo(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach(([t,e])=>this.context.model.translateNodeLikeTo(t,e)),yield null===(i=this.context.element.draw({animation:A,stage:"translate"}))||void 0===i?void 0:i.finished})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return Se(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach(([t,e])=>{const n=this.getElementType(t);s[`${n}s`].push({id:t,style:{visibility:e}})});const{model:a,element:c}=this.context;a.preventUpdateNodeLikeHierarchy(()=>{a.updateData(s)}),yield null===(i=c.draw({animation:A,stage:"visibility"}))||void 0===i?void 0:i.finished})}showElement(t,e){return De(this,void 0,void 0,function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map(t=>[t,"visible"])),e)})}hideElement(t,e){return De(this,void 0,void 0,function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map(t=>[t,"hidden"])),e)})}getElementVisibility(t){var e,n;const r=this.context.element.getElement(t);return null!==(n=null===(e=null==r?void 0:r.style)||void 0===e?void 0:e.visibility)&&void 0!==n?n:"visible"}setElementZIndex(t,e){return De(this,void 0,void 0,function*(){var n;const r={nodes:[],edges:[],combos:[]},i=zt(t)?t:{[t]:e};Object.entries(i).forEach(([t,e])=>{const n=this.getElementType(t);r[`${n}s`].push({id:t,style:{zIndex:e}})});const{model:o,element:A}=this.context;o.preventUpdateNodeLikeHierarchy(()=>o.updateData(r)),yield null===(n=A.draw({animation:!1,stage:"zIndex"}))||void 0===n?void 0:n.finished})}frontElement(t){return De(this,void 0,void 0,function*(){const e=Array.isArray(t)?t:[t],{model:n}=this.context,r={};e.map(t=>{const e=n.getFrontZIndex(t);if("combo"===n.getElementType(t)){const i=n.getAncestorsData(t,zv).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Km(i))],A=e-$Z(i);o.forEach(t=>{r[Km(t)]=this.getElementZIndex(Km(t))+A});const{internal:s}=pB(o.map(Km),t=>n.getRelatedEdgesData(t));s.forEach(t=>{const e=Km(t);r[e]=this.getElementZIndex(e)+A})}else r[t]=e}),yield this.setElementZIndex(r)})}getElementZIndex(t){return $Z(this.context.model.getElementDataById(t))}setElementState(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach(([t,e])=>{const n=this.getElementType(t);var r;s[`${n}s`].push({id:t,states:(r=e,r?Array.isArray(r)?r:[r]:[])})}),this.updateData(s),yield null===(i=this.context.element.draw({animation:A,stage:"state"}))||void 0===i?void 0:i.finished})}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}collapseElement(t){return De(this,arguments,void 0,function*(t,e=!0){const{model:n,element:r}=this.context;if(rw(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!1});const i=n.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,n.updateData("node"===i?{nodes:[{id:t,style:{collapsed:!0}}]}:{combos:[{id:t,style:{collapsed:!0}}]}),"node"===i?yield r.collapseNode(t,e):"combo"===i&&(yield r.collapseCombo(t,!!e.animation)),this.isCollapsingExpanding=!1})}expandElement(t){return De(this,arguments,void 0,function*(t,e=!0){const{model:n,element:r}=this.context;if(!rw(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!1});const i=n.getElementType(t);this.isCollapsingExpanding=!0,n.updateData("node"===i?{nodes:[{id:t,style:{collapsed:!1}}]}:{combos:[{id:t,style:{collapsed:!1}}]}),"node"===i?yield r.expandNode(t,e):"combo"===i&&(yield r.expandCombo(t,!!e.animation)),this.isCollapsingExpanding=!1})}setElementCollapsibility(t,e){const n=this.getElementType(t);"node"===n?this.updateNodeData([{id:t,style:{collapsed:e}}]):"combo"===n&&this.updateComboData([{id:t,style:{collapsed:e}}])}toDataURL(){return De(this,arguments,void 0,function*(t={}){return this.context.canvas.toDataURL(t)})}getCanvasByViewport(t){return this.context.canvas.getCanvasByViewport(t)}getViewportByCanvas(t){return this.context.canvas.getViewportByCanvas(t)}getClientByCanvas(t){return this.context.canvas.getClientByCanvas(t)}getCanvasByClient(t){return this.context.canvas.getCanvasByClient(t)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(t,e,n){return super.on(t,e,n)}once(t,e){return super.once(t,e)}off(t,e){return super.off(t,e)}}gJ.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const pJ=(t,e)=>{const{source:n,target:r}=e,i=t.getElementDataById(n),o=t.getElementDataById(r),A=vB(i,e=>t.getParentData(e,zv)),s=vB(o,e=>t.getParentData(e,zv)),a={sourceNode:Km(A),targetNode:Km(s)};return e.style?Object.assign(e.style,a):e.style=a,e};class vJ extends SZ{constructor(t,e){super(t,be({},vJ.defaultOptions,e)),this.assignSizeByCentrality=(t,e,n,r,i,o)=>{const A=[e,n],s=[r[0],i[0]],a=[r[1],i[1]],c=[r[2],i[2]],l=(t,e)=>{if("function"==typeof o)return o(t,A,e);switch(o){case"linear":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return i===r?o:o+(t-r)/(i-r)*(A-o)})(t,A,e);case"log":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return o+Math.log(t-r+1)/Math.log(i-r+1)*(A-o)})(t,A,e);case"pow":return((t,e,n,r=2)=>{const[i,o]=e,[A,s]=n;return A+Math.pow((t-i)/(o-i),r)*(s-A)})(t,A,e,2);case"sqrt":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return o+Math.sqrt((t-r)/(i-r))*(A-o)})(t,A,e);default:return e[0]}};return[l(t,s),l(t,a),l(t,c)]}}beforeDraw(t){const{model:e}=this.context,n=e.getNodeData(),r=cw(this.options.maxSize),i=cw(this.options.minSize),o=this.getCentralities(this.options.centrality),A=o.size>0?Math.max(...o.values()):0,s=o.size>0?Math.min(...o.values()):0;return n.forEach(e=>{var n;const a=this.assignSizeByCentrality(o.get(Km(e))||0,s,A,i,r,this.options.scale),c=null===(n=this.context.element)||void 0===n?void 0:n.getElement(Km(e)),l={size:a};this.assignLabelStyle(l,a,e,c),c&&UZ(l,c.attributes)||QZ(t,c?"update":"add","node",be(e,{style:l}),!0)}),t}assignLabelStyle(t,e,n,r){var i;const o=r?r.config.style:null===(i=this.context.element)||void 0===i?void 0:i.getElementComputedStyle("node",n);if(Object.assign(t,ke(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const n=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:n,labelLineHeight:n+vm(t.labelPadding)})}return t}getLabelSizeByNodeSize(t,e,n){const r=Math.min(...t)/2,[i,o]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[n,e];return Math.min(o,Math.max(r,i))}getCentralities(t){const{model:e}=this.context,n=e.getData();if("function"==typeof t)return t(n);const r=e.getRelatedEdgesData.bind(e);return Vm(n,r,t)}}vJ.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class mJ extends SZ{constructor(t,e){super(t,Object.assign({},mJ.defaultOptions,e))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var t;const e=My(this.ref),{graph:n,model:r}=this.context;null===(t=r.getData().nodes)||void 0===t||t.forEach(t=>{var i;if(Km(t)===Km(this.ref))return;const o=by(cy(My(t),e)),A=Math.abs(o)>Math.PI/2,s=!t.children||0===t.children.length,a=Km(t),c=null===(i=this.context.element)||void 0===i?void 0:i.getElement(a);if(!c||!c.isVisible())return;const l=(s?1:-1)*(cw(n.getElementRenderStyle(a).size)[0]/2+this.options.offset),u=[["translate",l*Math.cos(o),l*Math.sin(o)],["rotate",A?Tr(o)+180:Tr(o)]];r.updateNodeData([{id:Km(t),style:{labelTextAlign:A===s?"right":"left",labelTextBaseline:"middle",labelTransform:u}}])}),n.draw()}}mJ.defaultOptions={offset:5};const yJ=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class wJ extends SZ{constructor(t,e){super(t,Object.assign({},wJ.defaultOptions,e)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=t=>{const{add:{edges:e},update:{nodes:n,edges:r,combos:i},remove:{edges:o}}=t,{model:A}=this.context,s=new Map,a=(t,e)=>{A.getRelatedEdgesData(e).forEach(t=>!s.has(Km(t))&&s.set(Km(t),t))};n.forEach(a),i.forEach(a);const c=e=>{const n=new Set(t.remove.edges.keys()),r=A.getEdgeData().filter(t=>!n.has(Km(t))).map(t=>pJ(A,t));BJ(e,r).forEach(t=>{const e=Km(t);s.has(e)||s.set(e,t)})};if(o.size&&o.forEach(c),e.size&&e.forEach(c),r.size){const t=rV(nV(A.getChanges())).update.edges;r.forEach(e=>{var n;c(e);const r=null===(n=t.find(t=>Km(t.value)===Km(e)))||void 0===n?void 0:n.original;r&&!EJ(e,r)&&c(r)})}Ee(this.options.edges)||s.forEach((t,e)=>!this.options.edges.includes(e)&&s.delete(e));const l=A.getEdgeData().map(Km);return new Map([...s].sort((t,e)=>l.indexOf(t[0])-l.indexOf(e[0])))},this.applyBundlingStyle=(t,e,n)=>{const{edgeMap:r,reverses:i}=bJ(e);r.forEach(e=>{e.forEach((e,r,o)=>{var A;const s=o.length,a=e.style||{};if(e.source===e.target){const t=yJ.length;a.loopPlacement=yJ[r%t],a.loopDist=Math.floor(r/t)*n+50}else if(1===s)a.curveOffset=0;else{const t=(r%2==0?1:-1)*(i[`${e.source}|${e.target}|${r}`]?-1:1);a.curveOffset=s%2==1?t*Math.ceil(r/2)*n*2:t*(Math.floor(r/2)*n*2+n)}const c=Object.assign(e,{type:"quadratic",style:a}),l=null===(A=this.context.element)||void 0===A?void 0:A.getElement(Km(e));l&&UZ(c.style,l.attributes)||QZ(t,l?"update":"add","edge",c,!0)})})},this.resetEdgeStyle=t=>{const e=t.style||{},n=this.cacheMergeStyle.get(Km(t))||{};return Object.keys(n).forEach(r=>{xe(e[r],n[r])&&(t[r]?e[r]=t[r]:delete e[r])}),Object.assign(t,{style:e})},this.applyMergingStyle=(t,e)=>{const{edgeMap:n,reverses:r}=bJ(e);n.forEach(e=>{var n;if(1===e.length){const r=e[0],i=null===(n=this.context.element)||void 0===n?void 0:n.getElement(Km(r)),o=this.resetEdgeStyle(r);return void(i&&UZ(o,i.attributes)||QZ(t,i?"update":"add","edge",o))}const i=e.map(({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:A}=n,s={},[a,c]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return ue(o)&&(s[a]=o),ue(A)&&(s[c]=A),s}).reduce((t,e)=>Object.assign(Object.assign({},t),e),{});e.forEach((e,n,r)=>{var o;if(0!==n)return void QZ(t,"remove","edge",e);const A=Object.assign({},Gt(this.options.style)?this.options.style(r):this.options.style,{childrenData:r});this.cacheMergeStyle.set(Km(e),A);const s=Object.assign(Object.assign({},e),{type:"line",style:Object.assign(Object.assign(Object.assign({},e.style),i),A)}),a=null===(o=this.context.element)||void 0===o?void 0:o.getElement(Km(e));a&&UZ(s.style,a.attributes)||QZ(t,a?"update":"add","edge",s,!0)})})}}beforeDraw(t){const e=this.getAffectedParallelEdges(t);return 0===e.size||("bundle"===this.options.mode?this.applyBundlingStyle(t,e,this.options.distance):this.applyMergingStyle(t,e)),t}}wJ.defaultOptions={mode:"bundle",distance:15};const bJ=t=>{const e=new Map,n=new Set,r={},i=new Map;for(const[o,A]of t){if(n.has(o))continue;const{source:s,target:a}=A,c=`${s}-${a}`;e.has(c)||(e.set(c,[]),i.set(c,new Set));const l=e.get(c),u=i.get(c);l&&u&&!u.has(o)&&(l.push(A),u.add(o),n.add(o));for(const[l,u]of t)if(!n.has(l)&&l!==o&&EJ(A,u)){const t=e.get(c),o=i.get(c);t&&o&&!o.has(l)&&(t.push(u),o.add(l),s===u.target&&a===u.source&&(r[`${u.source}|${u.target}|${t.length-1}`]=!0),n.add(l))}}return{edgeMap:e,reverses:r}},BJ=(t,e,n)=>e.filter(e=>EJ(e,t)),EJ=(t,e)=>{const{sourceNode:n,targetNode:r}=t.style||{},{sourceNode:i,targetNode:o}=e.style||{};return n===i&&r===o||n===o&&r===i};const xJ={animation:{"combo-collapse":um,"combo-expand":hm,"node-collapse":sm,"node-expand":am,"path-in":cm,"path-out":lm,fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}]},behavior:{"brush-select":Yy,"click-select":nw,"collapse-expand":tE,"create-edge":sE,"drag-canvas":aE,"drag-element-force":bE,"drag-element":cE,"fix-element-size":BE,"focus-element":EE,"hover-activate":xE,"lasso-select":CE,"auto-adapt-label":oy,"optimize-viewport-transform":ME,"scroll-canvas":FE,"zoom-canvas":kE},combo:{circle:Yb,rect:Xb},edge:{cubic:bB,line:CB,polyline:LB,quadratic:PB,"cubic-horizontal":BB,"cubic-radial":EB,"cubic-vertical":xB},layout:{"antv-dagre":yF,"combo-combined":Vj,"compact-box":XE,"d3-force":Nk,"force-atlas2":tj,circular:kF,concentric:QF,dagre:OK,dendrogram:nx,fishbone:Wj,force:YK,fruchterman:rj,grid:oj,indented:ax,mds:Sj,mindmap:gx,radial:Lj,random:_j,snake:$j},node:{circle:Tw,diamond:Iw,ellipse:Rw,hexagon:Hw,html:Gb,image:Kb,rect:jb,star:zb,donut:Lw,triangle:Vb},palette:{spectral:["rgb(158, 1, 66)","rgb(213, 62, 79)","rgb(244, 109, 67)","rgb(253, 174, 97)","rgb(254, 224, 139)","rgb(255, 255, 191)","rgb(230, 245, 152)","rgb(171, 221, 164)","rgb(102, 194, 165)","rgb(50, 136, 189)","rgb(94, 79, 162)"],tableau:["rgb(78, 121, 167)","rgb(242, 142, 44)","rgb(225, 87, 89)","rgb(118, 183, 178)","rgb(89, 161, 79)","rgb(237, 201, 73)","rgb(175, 122, 161)","rgb(255, 157, 167)","rgb(156, 117, 95)","rgb(186, 176, 171)"],oranges:["rgb(255, 245, 235)","rgb(254, 230, 206)","rgb(253, 208, 162)","rgb(253, 174, 107)","rgb(253, 141, 60)","rgb(241, 105, 19)","rgb(217, 72, 1)","rgb(166, 54, 3)","rgb(127, 39, 4)"],greens:["rgb(247, 252, 245)","rgb(229, 245, 224)","rgb(199, 233, 192)","rgb(161, 217, 155)","rgb(116, 196, 118)","rgb(65, 171, 93)","rgb(35, 139, 69)","rgb(0, 109, 44)","rgb(0, 68, 27)"],blues:["rgb(247, 251, 255)","rgb(222, 235, 247)","rgb(198, 219, 239)","rgb(158, 202, 225)","rgb(107, 174, 214)","rgb(66, 146, 198)","rgb(33, 113, 181)","rgb(8, 81, 156)","rgb(8, 48, 107)"]},theme:{dark:FZ,light:kZ},plugin:{"bubble-sets":Dz,"edge-bundling":Gz,"edge-filter-lens":$z,"grid-line":eV,background:ez,contextmenu:_z,fisheye:Jz,fullscreen:tV,history:AV,hull:HV,legend:$$,minimap:Z$,snapline:nZ,timebar:AZ,title:pZ,toolbar:mZ,tooltip:yZ,watermark:BZ},transform:{"arrange-draw-order":class extends SZ{beforeDraw(t){const{model:e}=this.context,n=t.add.combos,r=t=>{const n=[];return t.forEach((t,r)=>{const i=e.getAncestorsData(r,"combo").map(t=>Km(t)).reverse();n.push([r,t,i.length])}),new Map(n.sort(([,,t],[,,e])=>e-t).map(([t,e])=>[t,e]))};return t.add.combos=r(n),t.update.combos=r(t.update.combos),t}},"collapse-expand-combo":class extends SZ{beforeDraw(t,e){if("visibility"===e.stage)return t;if(!this.context.model.model.hasTreeStructure(zv))return t;const{model:n}=this.context,{add:r,update:i}=t,o=[...t.update.combos.entries(),...t.add.combos.entries()];for(;o.length;){const[e,A]=o.pop();if(rw(A)){const A=n.getDescendantsData(e),s=A.map(Km),{internal:a,external:c}=pB(s,t=>n.getRelatedEdgesData(t));A.forEach(e=>{const r=Km(e),i=o.findIndex(([t])=>t===r);-1!==i&&o.splice(i,1);const A=n.getElementType(r);QZ(t,"remove",A,e)}),a.forEach(e=>QZ(t,"remove","edge",e)),c.forEach(t=>{var e;const n=Km(t);(null===(e=this.context.element)||void 0===e?void 0:e.getElement(n))?i.edges.set(n,t):r.edges.set(n,t)})}else{const r=n.getChildrenData(e),i=r.map(Km),{edges:A}=pB(i,t=>n.getRelatedEdgesData(t));[...r,...A].forEach(e=>{var r;const i=Km(e),A=n.getElementType(i),s=null===(r=this.context.element)||void 0===r?void 0:r.getElement(i);QZ(t,s?"update":"add",A,e),"combo"===A&&o.push([i,e])})}}return t}},"collapse-expand-node":class extends SZ{getElement(t){return this.context.element.getElement(t)}handleExpand(t,e){if(NZ(e,"add","node",t),rw(t))return;const n=Km(t);NZ(e,"add","node",t);this.context.model.getRelatedEdgesData(n).forEach(t=>{QZ(e,"add","edge",t)});this.context.model.getChildrenData(n).forEach(t=>{this.handleExpand(t,e)})}beforeDraw(t){const{graph:e,model:n}=this.context;if(!n.model.hasTreeStructure(Vv))return t;const{add:{nodes:r,edges:i},update:{nodes:o}}=t,A=new Map,s=new Map;r.forEach((t,e)=>{rw(t)&&A.set(e,t)}),i.forEach(t=>{if("node"!==e.getElementType(t.source))return;const n=e.getNodeData(t.source);rw(n)&&A.set(t.source,n)}),o.forEach((t,e)=>{const n=this.getElement(e);if(!n)return;const r=n.attributes.collapsed;rw(t)?r||A.set(e,t):r&&s.set(e,t)});const a=new Set;return A.forEach((e,r)=>{n.getDescendantsData(r).forEach(e=>{const r=Km(e);if(a.has(r))return;QZ(t,"remove","node",e);n.getRelatedEdgesData(r).forEach(e=>{QZ(t,"remove","edge",e)}),a.add(r)})}),s.forEach((e,r)=>{n.getAncestorsData(r,Vv).some(rw)?QZ(t,"remove","node",e):this.handleExpand(e,t)}),t}},"get-edge-actual-ends":class extends SZ{beforeDraw(t){const{add:e,update:n}=t,{model:r}=this.context;return[...e.edges.entries(),...n.edges.entries()].forEach(([,t])=>{pJ(r,t)}),t}},"map-node-size":vJ,"place-radial-labels":mJ,"process-parallel-edges":wJ,"update-related-edges":class extends SZ{beforeDraw(t,e){const{stage:n}=e;if("visibility"===n)return t;const{model:r}=this.context,{update:{nodes:i,edges:o,combos:A}}=t,s=(t,e)=>{r.getRelatedEdgesData(e).forEach(t=>!o.has(Km(t))&&o.set(Km(t),t))};return i.forEach(s),A.forEach(s),t}}},shape:{circle:za,ellipse:Ya,group:Xa,html:$a,image:Cw,line:tc,path:nc,polygon:ic,polyline:Ac,rect:sc,text:cc,label:yw,badge:ww}};Object.entries(xJ).forEach(([t,e])=>{Object.entries(e).forEach(([e,n])=>{IZ(t,e,n)})});t.AntVDagreLayout=yF,t.AutoAdaptLabel=oy,t.Background=ez,t.Badge=ww,t.BaseBehavior=iy,t.BaseCombo=Wb,t.BaseEdge=wB,t.BaseLayout=pE,t.BaseNode=Nw,t.BasePlugin=Zj,t.BaseShape=pw,t.BaseTransform=SZ,t.BrushSelect=Yy,t.BubbleSets=Dz,t.CameraSetting=class extends Zj{constructor(t,e){super(t,e),this.setOptions=t=>{const e=(t,e)=>{switch(t){case"projectionMode":return"perspective"===e?1:0;case"cameraType":return{orbiting:0,exploring:1,tracking:2}[e];case"aspect":return"number"==typeof e?e:this.getCanvasAspect();default:return e}};Object.entries({cameraType:"setType",near:"setNear",far:"setFar",fov:"setFov",aspect:"setAspect",projectionMode:"setProjectionMode",distance:"setDistance",minDistance:"setMinDistance",maxDistance:"setMaxDistance",roll:"setRoll",elevation:"setElevation",azimuth:"setAzimuth"}).forEach(([n,r])=>{const i=t[n];if(void 0!==i){const t=e(n,i);this.context.canvas.getCamera()[r](t)}})},this.bindEvents()}update(t){this.setOptions(t),super.update(t)}bindEvents(){this.context.graph.once(t.GraphEvent.BEFORE_DRAW,()=>this.setOptions(this.options))}getCanvasAspect(){const[t,e]=this.context.viewport.getCanvasSize();return t/e}},t.Canvas=HZ,t.Circle=Tw,t.CircleCombo=Yb,t.CircularLayout=kF,t.ClickSelect=nw,t.CollapseExpand=tE,t.ComboCombinedLayout=Vj,t.CompactBoxLayout=XE,t.ConcentricLayout=QF,t.Contextmenu=_z,t.CreateEdge=sE,t.Cubic=bB,t.CubicHorizontal=BB,t.CubicRadial=EB,t.CubicVertical=xB,t.D3ForceLayout=Nk,t.DagreLayout=OK,t.DendrogramLayout=nx,t.Diamond=Iw,t.Donut=Lw,t.DragCanvas=aE,t.DragElement=cE,t.DragElementForce=bE,t.EdgeBundling=Gz,t.EdgeFilterLens=$z,t.Ellipse=Rw,t.FishboneLayout=Wj,t.Fisheye=Jz,t.FixElementSize=BE,t.FocusElement=EE,t.ForceAtlas2Layout=tj,t.ForceLayout=YK,t.FruchtermanLayout=rj,t.Fullscreen=tV,t.Graph=gJ,t.GridLayout=oj,t.GridLine=eV,t.HTML=Gb,t.Hexagon=Hw,t.History=AV,t.HoverActivate=xE,t.Hull=HV,t.Icon=Qw,t.Image=Kb,t.IndentedLayout=ax,t.Label=yw,t.LassoSelect=CE,t.Legend=$$,t.Line=CB,t.MDSLayout=Sj,t.MapNodeSize=vJ,t.MindmapLayout=gx,t.Minimap=Z$,t.OptimizeViewportTransform=ME,t.PlaceRadialLabels=mJ,t.Polyline=LB,t.ProcessParallelEdges=wJ,t.Quadratic=PB,t.RadialLayout=Lj,t.RandomLayout=_j,t.Rect=jb,t.RectCombo=Xb,t.ScrollCanvas=FE,t.Shortcut=Wy,t.SnakeLayout=$j,t.Snapline=nZ,t.Star=zb,t.Timebar=AZ,t.Title=pZ,t.Toolbar=mZ,t.Tooltip=yZ,t.Triangle=Vb,t.Watermark=BZ,t.ZoomCanvas=kE,t.effect=function(t,e,n){TZ.has(t)||TZ.set(t,{});const r=TZ.get(t);if(!r[e])return r[e]=n,!0;const i=r[e];return!OZ(i,n)&&(r[e]=n,!0)},t.getExtension=Xv,t.getExtensions=function(t){return Yv[t]},t.iconfont={css:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.css",js:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.js"},t.idOf=Km,t.invokeLayoutMethod=yE,t.isCollapsed=rw,t.omitStyleProps=aw,t.parseSize=cw,t.positionOf=My,t.register=IZ,t.setVisibility=ey,t.subStyleProps=Aw,t.treeToGraphData=function(t,e){const{getNodeData:n=(t,e)=>{if(t.depth=e,!t.children)return t;const{children:n}=t,r=Pe(t,["children"]);return Object.assign(Object.assign({},r),{children:n.map(t=>t.id)})},getEdgeData:r=(t,e)=>({source:t.id,target:e.id}),getChildren:i=t=>t.children||[]}=e||{},o=[],A=[];return Zy(t,(t,e)=>{o.push(n(t,e));const s=i(t);for(const e of s)A.push(r(t,e))},t=>i(t),"TB"),{nodes:o,edges:A}},t.version=qv});
|
|
68
|
+
*/var DZ=function(){function t(e){A(this,t),this.dragndropPluginOptions=e}return a(t,[{key:"apply",value:function(e){var n=this,r=e.renderingService,i=e.renderingContext.root.ownerDocument,o=i.defaultView,A=function(t){var e=t.target,r=e===i,A=r&&n.dragndropPluginOptions.isDocumentDraggable?i:e.closest&&e.closest("[draggable=true]");if(A){var s=!1,a=t.timeStamp,c=[t.clientX,t.clientY],l=null,u=[t.clientX,t.clientY],h=function(){var t=Ar(ir().mark(function t(o){var h,d,f,g,p,v;return ir().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=2;break}if(h=o.timeStamp-a,d=gn([o.clientX,o.clientY],c),!(h<=n.dragndropPluginOptions.dragstartTimeThreshold||d<=n.dragndropPluginOptions.dragstartDistanceThreshold)){t.next=1;break}return t.abrupt("return");case 1:o.type="dragstart",A.dispatchEvent(o),s=!0;case 2:if(o.type="drag",o.dx=o.clientX-u[0],o.dy=o.clientY-u[1],A.dispatchEvent(o),u=[o.clientX,o.clientY],r){t.next=4;break}return f="pointer"===n.dragndropPluginOptions.overlap?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=3,i.elementsFromPoint(f[0],f[1]);case 3:g=t.sent,p=g[g.indexOf(e)+1],v=(null==p?void 0:p.closest("[droppable=true]"))||(n.dragndropPluginOptions.isDocumentDroppable?i:null),l!==v&&(l&&(o.type="dragleave",o.target=l,l.dispatchEvent(o)),v&&(o.type="dragenter",o.target=v,v.dispatchEvent(o)),(l=v)&&(o.type="dragover",o.target=l,l.dispatchEvent(o)));case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}();o.addEventListener("pointermove",h);var d=function(t){if(s){t.detail={preventClick:!0};var e=t.clone();l&&(e.type="drop",e.target=l,l.dispatchEvent(e)),e.type="dragend",A.dispatchEvent(e),s=!1}o.removeEventListener("pointermove",h)};e.addEventListener("pointerup",d,{once:!0}),e.addEventListener("pointerupoutside",d,{once:!0})}};r.hooks.init.tap(t.tag,function(){o.addEventListener("pointerdown",A)}),r.hooks.destroy.tap(t.tag,function(){o.removeEventListener("pointerdown",A)})}}])}();DZ.tag="Dragndrop";var RZ=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return A(this,e),(t=g(this,e)).name="dragndrop",t.options=n,t}return v(e,t),a(e,[{key:"init",value:function(){this.addRenderingPlugin(new DZ(o({overlap:"pointer",isDocumentDraggable:!1,isDocumentDroppable:!1,dragstartDistanceThreshold:0,dragstartTimeThreshold:0},this.options)))}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}},{key:"setOptions",value:function(t){Object.assign(this.plugins[0].dragndropPluginOptions,t)}}])}(ur);const HZ=["main"],_Z=["background","main","label","transient"];class GZ{getConfig(){return this.config}getLayer(t="main"){return this.extends.layers[t]||this.getLayers().main}getLayers(){return this.extends.layers}getRenderer(t){return this.extends.renderers[t]}getCamera(t="main"){return this.getLayer(t).getCamera()}getRoot(t="main"){return this.getLayer(t).getRoot()}getContextService(t="main"){return this.getLayer(t).getContextService()}setCursor(t){this.config.cursor=t,this.getLayer().setCursor(t)}get document(){return this.getLayer().document}get context(){return this.getLayer().context}constructor(t){this.config={enableMultiLayer:!0},Object.assign(this.config,t);const e=this.config,{renderer:n,background:r,cursor:i,enableMultiLayer:o}=e,A=Pe(e,["renderer","background","cursor","enableMultiLayer"]),s=o?_Z:HZ,a=KZ(n,s),c=Object.fromEntries(s.map(t=>[t,new xc(Object.assign(Object.assign({},A),{supportsMutipleCanvasesInOneContainer:o,renderer:a[t],background:o?"background"===t?r:void 0:r}))]));jZ(c),this.extends={config:this.config,renderer:n,renderers:a,layers:c}}get ready(){return Promise.all(Object.entries(this.getLayers()).map(([,t])=>t.ready))}resize(t,e){Object.assign(this.extends.config,{width:t,height:e}),Object.values(this.getLayers()).forEach(n=>{const r=n.getCamera(),i=r.getPosition(),o=r.getFocalPoint();n.resize(t,e),r.setPosition(i),r.setFocalPoint(o)})}getBounds(t){return xm(Object.values(this.getLayers()).map(e=>t?e.getRoot().childNodes.find(e=>e.classList.includes(t)):e.getRoot()).filter(t=>(null==t?void 0:t.childNodes.length)>0).map(t=>t.getBounds()))}getContainer(){const t=this.extends.config.container;return"string"==typeof t?document.getElementById(t):t}getSize(){return[this.extends.config.width||0,this.extends.config.height||0]}appendChild(t,e){var n;const r=(null===(n=t.style)||void 0===n?void 0:n.$layer)||"main";return this.getLayer(r).appendChild(t,e)}setRenderer(t){if(t===this.extends.renderer)return;const e=KZ(t,this.config.enableMultiLayer?_Z:HZ);this.extends.renderers=e,Object.entries(e).forEach(([t,e])=>this.getLayer(t).setRenderer(e)),jZ(this.getLayers())}getCanvasByViewport(t){return Sy(this.getLayer().viewport2Canvas(Qy(t)))}getViewportByCanvas(t){return Sy(this.getLayer().canvas2Viewport(Qy(t)))}getViewportByClient(t){return Sy(this.getLayer().client2Viewport(Qy(t)))}getClientByViewport(t){return Sy(this.getLayer().viewport2Client(Qy(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),n=e.client2Viewport(Qy(t));return Sy(e.viewport2Canvas(n))}toDataURL(){return De(this,arguments,void 0,function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:n="viewport"}=t,r=Pe(t,["mode"]);let[i,o,A,s]=[0,0,0,0];if("viewport"===n)[A,s]=this.getSize();else if("overall"===n){const t=this.getBounds(),e=wm(t);[i,o]=t.min,[A,s]=e}const a=Sn('<div id="virtual-image"></div>'),c=new xc({width:A,height:s,renderer:new _b,devicePixelRatio:e,container:a,background:this.extends.config.background});yield c.ready,c.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),c.appendChild(this.getRoot().cloneNode(!0));const l=this.getLayer("label").getRoot().cloneNode(!0),u=c.viewport2Canvas({x:0,y:0}),h=this.getCanvasByViewport([0,0]);l.translate([h[0]-u.x,h[1]-u.y]),l.scale(1/this.getCamera().getZoom()),c.appendChild(l),c.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const d=this.getCamera(),f=c.getCamera();if("viewport"===n)f.setZoom(d.getZoom()),f.setPosition(d.getPosition()),f.setFocalPoint(d.getFocalPoint());else if("overall"===n){const[t,e,n]=f.getPosition(),[r,A,s]=f.getFocalPoint();f.setPosition([t+i,e+o,n]),f.setFocalPoint([r+i,A+o,s])}const g=c.getContextService();return new Promise(t=>{c.addEventListener(mc.RERENDER,()=>De(this,void 0,void 0,function*(){yield new Promise(t=>setTimeout(t,300));const e=yield g.toDataURL(r);t(e)}))})})}destroy(){Object.values(this.getLayers()).forEach(t=>{t.getCamera().cancelLandmarkAnimation(),t.destroy()})}}function KZ(t,e){return Object.fromEntries(e.map(e=>{const n=(null==t?void 0:t(e))||new _b;return n instanceof _b&&n.setConfig({enableDirtyRectangleRendering:!1}),"main"===e?n.registerPlugin(new RZ({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[e,n]}))}function jZ(t){Object.entries(t).forEach(([t,e])=>{const n=e.getContextService().getDomElement();(null==n?void 0:n.style)&&(n.style.gridArea="1 / 1 / 2 / 2",n.style.outline="none",n.tabIndex=1,"main"!==t&&(n.style.pointerEvents="none")),(null==n?void 0:n.parentElement)&&(n.parentElement.style.display="grid",n.parentElement.style.isolation="isolate")})}const zZ=t=>t?parseInt(t):0;function VZ(t){if(!t)return[0,0];let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||zZ(e.width),r=t.clientHeight||zZ(e.height);return[n-(zZ(e.paddingLeft)+zZ(e.paddingRight)),r-(zZ(e.paddingTop)+zZ(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(re(e)?e:1,1),Math.max(re(n)?n:1,1)]}class WZ{constructor(t){this.type=t}}class YZ extends WZ{constructor(t,e){super(t),this.data=e}}class XZ extends WZ{constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class qZ extends WZ{constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class $Z extends WZ{constructor(t,e){super(t),this.data=e}}function ZZ(t,e){t.emit(e.type,e)}function JZ(t){var e;return(null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0}const tJ="cachedStyle",eJ=t=>`__${t}__`;function nJ(t,e){return Ce(t,[tJ,eJ(e)])}class rJ{constructor(t){this.tasks=[],this.animations=new Set,this.context=t}getTasks(){const t=[...this.tasks];return this.tasks=[],t}add(t,e){this.tasks.push([t,e])}animate(t,e,n){var r,i,o;null===(r=null==e?void 0:e.before)||void 0===r||r.call(e);const A=this.getTasks().map(([e,r])=>{var i,o,A;const{element:s,elementType:a,stage:c}=e,l=im(this.context.options,a,c,t);null===(i=null==r?void 0:r.before)||void 0===i||i.call(r);const u=l.length?Am(s,this.inferStyle(e,n),l):null;return u?(null===(o=null==r?void 0:r.beforeAnimate)||void 0===o||o.call(r,u),u.finished.then(()=>{var t,e;null===(t=null==r?void 0:r.afterAnimate)||void 0===t||t.call(r,u),null===(e=null==r?void 0:r.after)||void 0===e||e.call(r),this.animations.delete(u)})):null===(A=null==r?void 0:r.after)||void 0===A||A.call(r),u}).filter(Boolean);A.forEach(t=>this.animations.add(t));const s=tm(A);return s?(null===(i=null==e?void 0:e.beforeAnimate)||void 0===i||i.call(e,s),s.finished.then(()=>{var t,n;null===(t=null==e?void 0:e.afterAnimate)||void 0===t||t.call(e,s),null===(n=null==e?void 0:e.after)||void 0===n||n.call(e),this.release()})):null===(o=null==e?void 0:e.after)||void 0===o||o.call(e),s}inferStyle(t,e){var n,r;const{element:i,elementType:o,stage:A,originalStyle:s,updatedStyle:a={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},s),a));const{modifiedStyle:c}=t,l={},u={};if("enter"===A)Object.assign(l,{opacity:0});else if("exit"===A)Object.assign(u,{opacity:0});else if("show"===A)Object.assign(l,{opacity:0}),Object.assign(u,{opacity:null!==(n=nJ(i,"opacity"))&&void 0!==n?n:nm("opacity")});else if("hide"===A)Object.assign(l,{opacity:null!==(r=nJ(i,"opacity"))&&void 0!==r?r:nm("opacity")}),Object.assign(u,{opacity:0});else if("collapse"===A){const{collapse:t}=e||{},{target:n,descendants:r,position:A}=t;if("node"===o){if(r.includes(i.id)){const[t,e,n]=A;Object.assign(u,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e]=A;Object.assign(u,{x:t,y:e,childrenNode:s.childrenNode})}}else"edge"===o&&Object.assign(u,{sourceNode:c.sourceNode,targetNode:c.targetNode})}else if("expand"===A){const{expand:t}=e||{},{target:n,descendants:r,position:A}=t;if("node"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=A;Object.assign(l,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e,n]=A;Object.assign(l,{x:t,y:e,z:n,childrenNode:c.childrenNode})}}else"edge"===o&&Object.assign(l,{sourceNode:c.sourceNode,targetNode:c.targetNode})}return[Object.keys(l).length>0?Object.assign({},s,l):s,Object.keys(u).length>0?Object.assign({},c,u):c]}stop(){this.animations.forEach(t=>t.cancel())}clear(){this.tasks=[]}release(){var t,e;const{canvas:n}=this.context,r=null===(e=null===(t=n.document)||void 0===t?void 0:t.timeline)||void 0===e?void 0:e.animationsWithPromises;r&&(n.document.timeline.animationsWithPromises=r.filter(t=>"finished"!==t.playState))}destroy(){this.stop(),this.animations.clear(),this.tasks=[]}}class iJ{constructor(t){this.batchCount=0,this.context=t}emit(t){const{graph:e}=this.context;e.emit(t.type,t)}startBatch(e=!0){this.batchCount++,1===this.batchCount&&this.emit(new YZ(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new YZ(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class oJ extends ny{constructor(e){super(e),this.currentTarget=null,this.currentTargetType=null,this.category="behavior",this.forwardCanvasEvents=e=>{const{target:n}=e,r=function(t){if(!t)return null;if(t instanceof hc)return{type:"canvas",element:t};let e=t;for(;e;){if(RB(e))return{type:"node",element:e};if(HB(e))return{type:"edge",element:e};if(_B(e))return{type:"combo",element:e};e=e.parentElement}return null}(n);if(!r)return;const{graph:i,canvas:o}=this.context,{type:A,element:s}=r;if("destroyed"in s&&(eE(s)||s.destroyed))return;const{type:a,detail:c,button:l}=e,u=Object.assign(Object.assign({},e),{target:s,targetType:A,originalTarget:n});a===t.CommonEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${this.currentTargetType}:${t.CommonEvent.POINTER_LEAVE}`,Object.assign(Object.assign({},u),{type:t.CommonEvent.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),s&&(Object.assign(u,{type:t.CommonEvent.POINTER_ENTER}),i.emit(`${A}:${t.CommonEvent.POINTER_ENTER}`,u))),this.currentTarget=s,this.currentTargetType=A),a===t.CommonEvent.CLICK&&2===l||(i.emit(`${A}:${a}`,u),i.emit(a,u)),a===t.CommonEvent.CLICK&&2===c&&(Object.assign(u,{type:t.CommonEvent.DBLCLICK}),i.emit(`${A}:${t.CommonEvent.DBLCLICK}`,u),i.emit(t.CommonEvent.DBLCLICK,u)),a===t.CommonEvent.POINTER_DOWN&&2===l&&(Object.assign(u,{type:t.CommonEvent.CONTEXT_MENU,preventDefault:()=>{var e;null===(e=o.getContainer())||void 0===e||e.addEventListener(t.CommonEvent.CONTEXT_MENU,t=>t.preventDefault(),{once:!0})}}),i.emit(`${A}:${t.CommonEvent.CONTEXT_MENU}`,u),i.emit(t.CommonEvent.CONTEXT_MENU,u))},this.forwardContainerEvents=t=>{this.context.graph.emit(t.type,t)},this.forwardEvents(),this.setBehaviors(this.context.options.behaviors||[])}setBehaviors(t){this.setExtensions(t)}forwardEvents(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach(t=>{e.addEventListener(t,this.forwardContainerEvents)});const n=this.context.canvas.document;n&&[t.CommonEvent.CLICK,t.CommonEvent.DBLCLICK,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE,t.CommonEvent.POINTER_ENTER,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_OUT,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_UP,t.CommonEvent.CONTEXT_MENU,t.CommonEvent.DRAG_START,t.CommonEvent.DRAG,t.CommonEvent.DRAG_END,t.CommonEvent.DRAG_ENTER,t.CommonEvent.DRAG_OVER,t.CommonEvent.DRAG_LEAVE,t.CommonEvent.DROP,t.CommonEvent.WHEEL].forEach(t=>{n.addEventListener(t,this.forwardCanvasEvents)})}destroy(){const e=this.context.canvas.getContainer();e&&[t.ContainerEvent.KEY_DOWN,t.ContainerEvent.KEY_UP].forEach(t=>{e.removeEventListener(t,this.forwardContainerEvents)}),this.context.canvas.document.removeAllEventListeners(),super.destroy()}}function AJ(t){const{id:e=Km(t),style:n,data:r}=t,i=Pe(t,["id","style","data"]),o=Object.assign(Object.assign({},t),{style:Object.assign({},n),data:Object.assign({},r)});return function(t){return"source"in t&&"target"in t}(t)?Object.assign({id:e,data:o},i):{id:e,data:o}}function sJ(t){return t.data}class aJ{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new vE}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===Lv.NodeUpdated||e===Lv.EdgeUpdated||e===Lv.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:iE(n),original:iE(r),type:e})}else this.changes.push({value:iE(t.value),type:e})}getChanges(){return this.changes}clearChanges(){this.changes=[]}batch(t){this.batchCount++,this.model.batch(t),this.batchCount--}isBatching(){return this.batchCount>0}silence(t){this.isTraceless=!0,t(),this.isTraceless=!1}isCombo(t){return this.comboIds.has(t)||this.latestRemovedComboIds.has(t)}getData(){return{nodes:this.getNodeData(),edges:this.getEdgeData(),combos:this.getComboData()}}getNodeData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=sJ(n);return this.isCombo(Km(r))||(void 0===t||t.includes(Km(r)))&&e.push(r),e},[])}getEdgeDatum(t){return sJ(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce((e,n)=>{const r=sJ(n);return(void 0===t||t.includes(Km(r)))&&e.push(r),e},[])}getComboData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=sJ(n);return this.isCombo(Km(r))?((void 0===t||t.includes(Km(r)))&&e.push(r),e):e},[])}getRootsData(t=Vv){return this.model.getRoots(t).map(sJ)}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(sJ):[]}getDescendantsData(t){const e=this.getElementDataById(t),n=[];return Zy(e,t=>{t!==e&&n.push(t)},t=>this.getChildrenData(Km(t)),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void Zv("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?sJ(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?Vv:zv,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(sJ):[]}getElementsDataByType(t){return"node"===t?this.getNodeData():"edge"===t?this.getEdgeData():"combo"===t?this.getComboData():[]}getElementDataById(t){return"edge"===this.getElementType(t)?this.getEdgeDatum(t):this.getNodeLikeDatum(t)}getNodeLikeDatum(t){return sJ(this.model.getNode(t))}getNodeLikeData(t){return this.model.getAllNodes().reduce((e,n)=>{const r=sJ(n);return t?t.includes(Km(r))&&e.push(r):e.push(r),e},[])}getElementDataByState(t,e){return this.getElementsDataByType(t).filter(t=>{var n;return null===(n=t.states)||void 0===n?void 0:n.includes(e)})}getElementState(t){var e;return(null===(e=this.getElementDataById(t))||void 0===e?void 0:e.states)||[]}hasNode(t){return this.model.hasNode(t)&&!this.isCombo(t)}hasEdge(t){return this.model.hasEdge(t)}hasCombo(t){return this.model.hasNode(t)&&this.isCombo(t)}getRelatedEdgesData(t,e="both"){return this.model.getRelatedEdges(t,e).map(sJ)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(sJ)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i,edges:o,combos:A}=this.getData(),s=ty(i,e,t=>Km(t),oE),a=ty(o,n,t=>Km(t),oE),c=ty(A,r,t=>Km(t),oE);this.batch(()=>{const t={nodes:s.enter,edges:a.enter,combos:c.enter};this.addData(t),this.computeZIndex(t,"add",!0);const e={nodes:s.update,edges:a.update,combos:c.update};this.updateData(e),this.computeZIndex(e,"update",!0);const n={nodes:s.exit.map(Km),edges:a.exit.map(Km),combos:c.exit.map(Km)};this.removeData(n)})}addData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.addComboData(r),this.addNodeData(e),this.addEdgeData(n)}),this.computeZIndex(t,"add")}addNodeData(t=[]){t.length&&(this.model.addNodes(t.map(t=>(this.pushChange({value:t,type:Lv.NodeAdded}),AJ(t)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map(t=>(this.pushChange({value:t,type:Lv.EdgeAdded}),AJ(t)))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(zv)||e.attachTreeStructure(zv),e.addNodes(t.map(t=>(this.comboIds.add(Km(t)),this.pushChange({value:t,type:Lv.ComboAdded}),AJ(t)))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const n=this.getNodeLikeDatum(t),r=e.map(Km);this.addNodeData(e),this.updateNodeData([{id:t,children:[...n.children||[],...r]}]),this.addEdgeData(r.map(e=>({source:t,target:e})))}computeZIndex(t,e,n=!1){!n&&this.isBatching()||this.batch(()=>{const{nodes:n=[],edges:r=[],combos:i=[]}=t;i.forEach(t=>{var n,r,i;const o=Km(t);if("add"===e&&re(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t))return;const A=this.getParentData(o,zv),s=A?(null!==(i=null===(r=A.style)||void 0===r?void 0:r.zIndex)&&void 0!==i?i:0)+1:0;this.preventUpdateNodeLikeHierarchy(()=>{this.updateComboData([{id:o,style:{zIndex:s}}])})}),n.forEach(t=>{var n,r,i;const o=Km(t);if("add"===e&&re(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t)&&!("children"in t))return;let A=0;const s=this.getParentData(o,zv);if(s)A=((null===(r=s.style)||void 0===r?void 0:r.zIndex)||0)+1;else{const t=this.getParentData(o,Vv);t&&(A=(null===(i=null==t?void 0:t.style)||void 0===i?void 0:i.zIndex)||0)}this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:o,style:{zIndex:A}}])})}),r.forEach(t=>{var e,n,r,i,o;if(re(null===(e=t.style)||void 0===e?void 0:e.zIndex))return;let{id:A,source:s,target:a}=t;if(A){const t=this.getEdgeDatum(A);s=t.source,a=t.target}else A=Km(t);if(!s||!a)return;const c=(null===(r=null===(n=this.getNodeLikeDatum(s))||void 0===n?void 0:n.style)||void 0===r?void 0:r.zIndex)||0,l=(null===(o=null===(i=this.getNodeLikeDatum(a))||void 0===i?void 0:i.style)||void 0===o?void 0:o.zIndex)||0;this.updateEdgeData([{id:Km(t),style:{zIndex:Math.max(c,l)-1}}])})})}getFrontZIndex(t){var e;const n=this.getElementType(t),r=this.getElementDataById(t),i=this.getData();if(Object.assign(i,{[`${n}s`]:i[`${n}s`].filter(e=>Km(e)!==t)}),"combo"===n&&!rw(r)){const e=new Set(this.getAncestorsData(t,zv).map(Km));i.nodes=i.nodes.filter(t=>!e.has(Km(t))),i.combos=i.combos.filter(t=>!e.has(Km(t))),i.edges=i.edges.filter(({source:t,target:n})=>!e.has(t)&&!e.has(n))}return Math.max((null===(e=r.style)||void 0===e?void 0:e.zIndex)||0,0,...Object.values(i).flat().map(t=>{var e;return((null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0)+1}))}updateNodeLikeHierarchy(t){if(!this.enableUpdateNodeLikeHierarchy)return;const{model:e}=this;t.forEach(t=>{const n=Km(t),r=jm(t);void 0!==r&&(e.hasTreeStructure(zv)||e.attachTreeStructure(zv),null===r&&this.refreshComboData(n),this.setParent(n,jm(t),zv));const i=t.children||[];if(i.length){e.hasTreeStructure(Vv)||e.attachTreeStructure(Vv);const t=i.filter(t=>e.hasNode(t));t.forEach(t=>this.setParent(t,n,Vv)),t.length!==i.length&&this.updateNodeData([{id:n,children:t}])}})}preventUpdateNodeLikeHierarchy(t){this.enableUpdateNodeLikeHierarchy=!1,t(),this.enableUpdateNodeLikeHierarchy=!0}updateData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.updateNodeData(e),this.updateComboData(r),this.updateEdgeData(n)}),this.computeZIndex(t,"update")}updateNodeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{const n=[];t.forEach(t=>{const r=Km(t),i=sJ(e.getNode(r));if(oE(i,t))return;const o=rE(i,t);this.pushChange({value:o,original:i,type:Lv.NodeUpdated}),e.mergeNodeData(r,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({nodes:t},"update")}refreshData(){const{nodes:t,edges:e,combos:n}=this.getData();t.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.NodeUpdated})}),e.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.EdgeUpdated})}),n.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.ComboUpdated})})}syncNodeLikeDatum(t){const{model:e}=this,n=Km(t);if(!e.hasNode(n))return;const r=rE(sJ(e.getNode(n)),t);e.mergeNodeData(n,r)}syncEdgeDatum(t){const{model:e}=this,n=Km(t);if(!e.hasEdge(n))return;const r=rE(sJ(e.getEdge(n)),t);e.mergeEdgeData(n,r)}updateEdgeData(t=[]){if(!t.length)return;const{model:e}=this;this.batch(()=>{t.forEach(t=>{const n=Km(t),r=sJ(e.getEdge(n));if(oE(r,t))return;t.source&&r.source!==t.source&&e.updateEdgeSource(n,t.source),t.target&&r.target!==t.target&&e.updateEdgeTarget(n,t.target);const i=rE(r,t);this.pushChange({value:i,original:r,type:Lv.EdgeUpdated}),e.mergeEdgeData(n,i)})}),this.computeZIndex({edges:t},"update")}updateComboData(t=[]){if(!t.length)return;const{model:e}=this;e.batch(()=>{const n=[];t.forEach(t=>{const r=Km(t),i=sJ(e.getNode(r));if(oE(i,t))return;const o=rE(i,t);this.pushChange({value:o,original:i,type:Lv.ComboUpdated}),e.mergeNodeData(r,o),n.push(o)}),this.updateNodeLikeHierarchy(n)}),this.computeZIndex({combos:t},"update")}setParent(t,e,n,r=!0){if(t===e)return;const i=jm(this.getNodeLikeDatum(t));if(i!==e&&n===zv){const n={id:t,combo:e};this.isCombo(t),this.syncNodeLikeDatum(n)}this.model.setParent(t,e,n),r&&n===zv&&function(t,e){void 0===e&&(e=new Map);var n=[];if(Array.isArray(t))for(var r=0,i=t.length;r<i;r++){var o=t[r];e.has(o)||(n.push(o),e.set(o,!0))}return n}([i,e]).forEach(t=>{void 0!==t&&this.refreshComboData(t)})}refreshComboData(t){const e=this.getComboData([t])[0],n=this.getAncestorsData(t,zv);e&&this.pushChange({value:e,original:e,type:Lv.ComboUpdated}),n.forEach(t=>{this.pushChange({value:t,original:t,type:Lv.ComboUpdated})})}getElementPosition(t){return My(this.getElementDataById(t))}translateNodeLikeBy(t,e){this.isCombo(t)?this.translateComboBy(t,e):this.translateNodeBy(t,e)}translateNodeLikeTo(t,e){this.isCombo(t)?this.translateComboTo(t,e):this.translateNodeTo(t,e)}translateNodeBy(t,e){const n=ay(this.getElementPosition(t),[...e,0].slice(0,3));this.translateNodeTo(t,n)}translateNodeTo(t,e){const[n=0,r=0,i=0]=e;this.preventUpdateNodeLikeHierarchy(()=>{this.updateNodeData([{id:t,style:{x:n,y:r,z:i}}])})}translateComboBy(t,e){const[n=0,r=0,i=0]=e;if([n,r,i].some(isNaN)||[n,r,i].every(t=>0===t))return;const o=this.getComboData([t])[0];if(!o)return;const A=new Set;Zy(o,t=>{const e=Km(t);if(A.has(e))return;A.add(e);const[o,s,a]=My(t),c=rE(t,{style:{x:o+n,y:s+r,z:a+i}});this.pushChange({value:c,original:t,type:this.isCombo(e)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(e,c)},t=>this.getChildrenData(Km(t)),"BT")}translateComboTo(t,e){var n;if(e.some(isNaN))return;const[r=0,i=0,o=0]=e,A=null===(n=this.getComboData([t]))||void 0===n?void 0:n[0];if(!A)return;const[s,a,c]=My(A),l=r-s,u=i-a,h=o-c;Zy(A,t=>{const e=Km(t),[n,r,i]=My(t),o=rE(t,{style:{x:n+l,y:r+u,z:i+h}});this.pushChange({value:o,original:t,type:this.isCombo(e)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(e,o)},t=>this.getChildrenData(Km(t)),"BT")}removeData(t){const{nodes:e,edges:n,combos:r}=t;this.batch(()=>{this.removeEdgeData(n),this.removeNodeData(e),this.removeComboData(r),this.latestRemovedComboIds=new Set(r)})}removeNodeData(t=[]){t.length&&this.batch(()=>{t.forEach(t=>{this.removeEdgeData(this.getRelatedEdgesData(t).map(Km)),this.pushChange({value:this.getNodeData([t])[0],type:Lv.NodeRemoved}),this.removeNodeLikeHierarchy(t)}),this.model.removeNodes(t)})}removeEdgeData(t=[]){t.length&&(t.forEach(t=>this.pushChange({value:this.getEdgeData([t])[0],type:Lv.EdgeRemoved})),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch(()=>{t.forEach(t=>{this.pushChange({value:this.getComboData([t])[0],type:Lv.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)}),this.model.removeNodes(t)})}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(zv)){const e=jm(this.getNodeLikeDatum(t));this.setParent(t,void 0,zv,!1),this.model.getChildren(t,zv).forEach(t=>{const n=sJ(t),r=Km(n);this.setParent(Km(n),e,zv,!1);const i=rE(n,{id:Km(n),combo:e});this.pushChange({value:i,original:n,type:this.isCombo(r)?Lv.ComboUpdated:Lv.NodeUpdated}),this.model.mergeNodeData(Km(n),i)}),Kt(e)||this.refreshComboData(e)}}getElementType(t){if(this.model.hasNode(t))return this.isCombo(t)?"combo":"node";if(this.model.hasEdge(t))return"edge";throw new Error($v(`Unknown element type of id: ${t}`))}destroy(){const{model:t}=this,e=t.getAllNodes(),n=t.getAllEdges();t.removeEdges(n.map(t=>t.id)),t.removeNodes(e.map(t=>t.id)),this.context={}}}class cJ{constructor(t){this.elementMap={},this.shapeTypeMap={},this.paletteStyle={},this.defaultStyle={},this.stateStyle={},this.visibilityCache=new WeakMap,this.context=t}init(){this.initContainer()}initContainer(){if(!this.container||this.container.destroyed){const{canvas:t}=this.context;this.container=t.appendChild(new Xa({className:"elements"}))}}emit(t,e){e.silence||ZZ(this.context.graph,t)}forEachElementData(t){$y.forEach(e=>{const n=this.context.model.getElementsDataByType(e);t(e,n)})}getElementType(t,e){var n;const{options:r,graph:i}=this.context,o=sE(e)&&(null===(n=r[t])||void 0===n?void 0:n.type)||e.type;return o?"string"==typeof o?o:o.call(i,e):"edge"===t?"line":"circle"}getTheme(t){return Jv(this.context.options)[t]||{}}getThemeStyle(t){return this.getTheme(t).style||{}}getThemeStateStyle(t,e){const{state:n={}}=this.getTheme(t);return Object.assign({},...e.map(t=>n[t]||{}))}computePaletteStyle(){const{options:t}=this.context;this.paletteStyle={},this.forEachElementData((e,n)=>{var r,i;const o=Object.assign({},hw(null===(r=this.getTheme(e))||void 0===r?void 0:r.palette),hw(null===(i=t[e])||void 0===i?void 0:i.palette));(null==o?void 0:o.field)&&Object.assign(this.paletteStyle,function(t,e){if(!e)return{};const{type:n,color:r,field:i,invert:o}=e,A=t=>{const e="string"==typeof r?Xv("palette",r):r;if("function"==typeof e){const n={};return t.forEach(([t,r])=>{n[t]=e(o?1-r:r)}),n}if(Array.isArray(e)){const n=o?[...e].reverse():e,r={};return t.forEach(([t,i])=>{r[t]=n[i%e.length]}),r}return{}},s=(t,e)=>{var n;return"string"==typeof t?null===(n=e.data)||void 0===n?void 0:n[t]:null==t?void 0:t(e)};if("group"===n){const e=ee(t,t=>{if(!i)return"default";const e=s(i,t);return e?String(e):"default"}),n=A(Object.keys(e).map((t,e)=>[t,e])),r={};return Object.entries(e).forEach(([t,e])=>{e.forEach(e=>{r[Km(e)]=n[t]})}),r}if("value"===n){const[e,n]=t.reduce(([t,e],n)=>{const r=s(i,n);if("number"!=typeof r)throw new Error($v(`Palette field ${i} is not a number`));return[Math.min(t,r),Math.max(e,r)]},[1/0,-1/0]),r=n-e;return A(t.map(t=>[t.id,(s(i,t)-e)/r]))}}(n,o))})}getPaletteStyle(t,e){const n=this.paletteStyle[e];return n?"edge"===t?{stroke:n}:{fill:n}:{}}computeElementDefaultStyle(t,e){var n;const{options:r}=this.context,i=(null===(n=r[t])||void 0===n?void 0:n.style)||{};"transform"in i&&Array.isArray(i.transform)&&(i.transform=[...i.transform]),this.defaultStyle[Km(e.datum)]=lw(i,e)}computeElementsDefaultStyle(t){const{graph:e}=this.context;this.forEachElementData((n,r)=>{const i=r.length;for(let o=0;o<i;o++){const i=r[o];(void 0===t||t.includes(Km(i)))&&this.computeElementDefaultStyle(n,{datum:i,graph:e})}})}getDefaultStyle(t){return this.defaultStyle[t]||{}}getElementState(t){try{const{model:e}=this.context;return e.getElementState(t)}catch(t){return[]}}getElementStateStyle(t,e,n){var r,i;const{options:o}=this.context;return lw((null===(i=null===(r=o[t])||void 0===r?void 0:r.state)||void 0===i?void 0:i[e])||{},n)}computeElementStatesStyle(t,e,n){this.stateStyle[Km(n.datum)]=Object.assign({},...e.map(e=>this.getElementStateStyle(t,e,n)))}computeElementsStatesStyle(t){const{graph:e}=this.context;this.forEachElementData((n,r)=>{const i=r.length;for(let o=0;o<i;o++){const i=r[o];if(void 0===t||t.includes(Km(i))){const t=this.getElementState(Km(i));this.computeElementStatesStyle(n,t,{datum:i,graph:e})}}})}getStateStyle(t){return this.stateStyle[t]||{}}computeStyle(t,e){t&&["translate","zIndex"].includes(t)||(this.computePaletteStyle(),this.computeElementsDefaultStyle(e),this.computeElementsStatesStyle(e))}getElement(t){return this.elementMap[t]}getNodes(){return this.context.model.getNodeData().map(({id:t})=>this.elementMap[t])}getEdges(){return this.context.model.getEdgeData().map(t=>this.elementMap[Km(t)])}getCombos(){return this.context.model.getComboData().map(({id:t})=>this.elementMap[t])}getElementComputedStyle(t,e){const n=Km(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(t,n),o=e.style||{},A=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),a=this.getStateStyle(n),c=sE(e)?Object.assign({},r,i,o,A,s,a):Object.assign({},o);if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!c.collapsed?[]:t.map(Km).filter(t=>this.getElement(t));Object.assign(c,{childrenNode:e,childrenData:t})}return c}getDrawData(t){this.init();const e=this.computeChangesAndDrawData(t);if(!e)return null;const{type:n="draw",stage:r=n}=t;return this.markDestroyElement(e.drawData),this.computeStyle(r),{type:n,stage:r,data:e}}draw(t={animation:!0}){const e=this.getDrawData(t);if(!e)return;const{data:{drawData:{add:n,update:r,remove:i}}}=e;return this.destroyElements(i,t),this.createElements(n,t),this.updateElements(r,t),this.setAnimationTask(t,e)}preLayoutDraw(){return De(this,arguments,void 0,function*(t={animation:!0}){var e,n;const r=this.getDrawData(t);if(!r)return;const{data:{drawData:i}}=r;yield null===(n=null===(e=this.context.layout)||void 0===e?void 0:e.preLayout)||void 0===n?void 0:n.call(e,i);const{add:o,update:A,remove:s}=i;return this.destroyElements(s,t),this.createElements(o,t),this.updateElements(A,t),this.setAnimationTask(t,r)})}setAnimationTask(e,n){const{animation:r,silence:i}=e,{data:{dataChanges:o,drawData:A},stage:s,type:a}=n;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new YZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===a}),e),beforeAnimate:n=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.DRAW,n,A),e),afterAnimate:n=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.DRAW,n,A),e),after:()=>this.emit(new YZ(t.GraphEvent.AFTER_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===a,firstRender:!1===this.context.graph.rendered}),e)})}computeChangesAndDrawData(t){const{model:e}=this.context,n=e.getChanges(),r=iV(n);if(0===r.length)return null;const{NodeAdded:i=[],NodeUpdated:o=[],NodeRemoved:A=[],EdgeAdded:s=[],EdgeUpdated:a=[],EdgeRemoved:c=[],ComboAdded:l=[],ComboUpdated:u=[],ComboRemoved:h=[]}=ee(r,t=>t.type),d=(t,e)=>{const n=[];return t.forEach(t=>{const r=Km(t.value);this.getElement(r)?n.push(t):e.push(t)}),n},f=d(o,i),g=d(a,s),p=d(u,l),v=t=>new Map(t.map(t=>{const e=t.value;return[Km(e),e]})),m={add:{nodes:v(i),edges:v(s),combos:v(l)},update:{nodes:v(f),edges:v(g),combos:v(p)},remove:{nodes:v(A),edges:v(c),combos:v(h)}},y=this.transformData(m,t);return e.clearChanges(),{dataChanges:n,drawData:y}}transformData(t,e){const n=this.context.transform.getTransformInstance();return Object.values(n).reduce((t,n)=>n.beforeDraw(t,e),t)}createElement(e,n,r){var i;const o=Km(n);if(this.getElement(o))return;const A=this.getElementType(e,n),s=this.getElementComputedStyle(e,n),a=Xv(e,A);if(!a)return Zv(`The element ${A} of ${e} is not registered.`);this.emit(new qZ(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const c=this.container.appendChild(new a({id:o,context:this.context,style:s}));this.shapeTypeMap[o]=A,this.elementMap[o]=c;const{stage:l="enter"}=r;null===(i=this.context.animation)||void 0===i||i.add({element:c,elementType:e,stage:l,originalStyle:Object.assign({},c.attributes),updatedStyle:s},{after:()=>{var i;this.emit(new qZ(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),null===(i=c.onCreate)||void 0===i||i.call(c)}})}createElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach(([t,n])=>{n.forEach(n=>this.createElement(t,n,e))})}getUpdateStageStyle(t,e,n){const{stage:r="update"}=n;if("translate"===r){if("node"===t||"combo"===t){const{style:{x:t=0,y:n=0,z:r=0}={}}=e;return{x:t,y:n,z:r}}return{}}return this.getElementComputedStyle(t,e)}updateElement(e,n,r){var i;const o=Km(n),{stage:A="update"}=r,s=this.getElement(o);if(!s)return()=>null;this.emit(new qZ(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const a=this.getElementType(e,n),c=this.getUpdateStageStyle(e,n,r);this.shapeTypeMap[o]!==a&&(s.destroy(),delete this.shapeTypeMap[o],delete this.elementMap[o],this.createElement(e,n,{animation:!1,silence:!0}));const l="visibility"!==A?A:"hidden"===c.visibility?"hide":"show";"hide"===l&&delete c.visibility,null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:l,originalStyle:Object.assign({},s.attributes),updatedStyle:c},{before:()=>{const t=this.elementMap[o];"collapse"!==A&&tE(t,c),"visibility"===A&&(function(t,e){return eJ(e)in(Ce(t,tJ)||{})}(t,"opacity")||function(t,e){const n=Array.isArray(e)?e:[e];Ce(t,tJ)||Me(t,tJ,{}),n.forEach(e=>{Me(Ce(t,tJ),eJ(e),t.attributes[e])})}(t,"opacity"),this.visibilityCache.set(t,"show"===l?"visible":"hidden"),"show"===l&&ey(t,"visible"))},after:()=>{var i;const s=this.elementMap[o];"collapse"===A&&tE(s,c),"hide"===l&&ey(s,this.visibilityCache.get(s)),this.emit(new qZ(t.GraphEvent.AFTER_ELEMENT_UPDATE,e,n),r),null===(i=s.onUpdate)||void 0===i||i.call(s)}})}updateElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["node",n],["combo",i],["edge",r]].forEach(([t,n])=>{n.forEach(n=>this.updateElement(t,n,e))})}markDestroyElement(t){Object.values(t.remove).forEach(t=>{t.forEach(t=>{const e=Km(t),n=this.getElement(e);n&&function(t){Me(t,"__to_be_destroyed__",!0)}(n)})})}destroyElement(e,n,r){var i;const{stage:o="exit"}=r,A=Km(n),s=this.elementMap[A];if(!s)return()=>null;this.emit(new qZ(t.GraphEvent.BEFORE_ELEMENT_DESTROY,e,n),r),null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:o,originalStyle:Object.assign({},s.attributes),updatedStyle:{}},{after:()=>{var i;this.clearElement(A),s.destroy(),null===(i=s.onDestroy)||void 0===i||i.call(s),this.emit(new qZ(t.GraphEvent.AFTER_ELEMENT_DESTROY,e,n),r)}})}destroyElements(t,e){const{nodes:n,edges:r,combos:i}=t;[["combo",i],["edge",r],["node",n]].forEach(([t,n])=>{n.forEach(n=>this.destroyElement(t,n,e))})}clearElement(t){delete this.paletteStyle[t],delete this.defaultStyle[t],delete this.stateStyle[t],delete this.elementMap[t],delete this.shapeTypeMap[t]}alignLayoutResultToElement(t,e){var n,r;const i=null===(n=t.nodes)||void 0===n?void 0:n.find(t=>Km(t)===e);if(i){const n=cy(My(this.context.model.getNodeLikeDatum(e)),My(i));null===(r=t.nodes)||void 0===r||r.forEach(t=>{var e,r,i;(null===(e=t.style)||void 0===e?void 0:e.x)&&(t.style.x+=n[0]),(null===(r=t.style)||void 0===r?void 0:r.y)&&(t.style.y+=n[1]),(null===(i=t.style)||void 0===i?void 0:i.z)&&(t.style.z+=n[2]||0)})}}syncLayoutResult(t,e){return De(this,void 0,void 0,function*(){const{layout:n,model:r}=this.context;if(!n)return;const i=this.context.options.layout,o=yield n.simulate(i?(A=i,Array.isArray(A)?A.map(t=>Object.assign(Object.assign({},t),{preLayout:!0})):Object.assign(Object.assign({},A),{preLayout:!0})):void 0);var A;e&&this.alignLayoutResultToElement(o,t),r.updateData(o)})}collapseNode(e,n){return De(this,void 0,void 0,function*(){var r;const{animation:i,align:o}=n;yield this.syncLayoutResult(e,o);const A=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(this.context.animation.clear(),this.computeStyle("collapse"),!A)return;const{drawData:s}=A,{add:a,remove:c,update:l}=s;this.markDestroyElement(s);const u={animation:i,stage:"collapse",data:s};this.destroyElements(c,u),this.createElements(a,u),this.updateElements(l,u),yield null===(r=this.context.animation.animate(i,{beforeAnimate:e=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.COLLAPSE,e,s),u),afterAnimate:e=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.COLLAPSE,e,s),u)},{collapse:{target:e,descendants:Array.from(c.nodes).map(([,t])=>Km(t)),position:My(l.nodes.get(e))}}))||void 0===r?void 0:r.finished})}expandNode(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i}=this.context,{animation:o,align:A}=n,s=My(i.getNodeData([e])[0]);yield this.syncLayoutResult(e,A);const a=this.computeChangesAndDrawData({stage:"expand",animation:o});if(this.createElements(a.drawData.add,{animation:!1,stage:"expand",target:e}),this.context.animation.clear(),this.computeStyle("expand"),!a)return;const{drawData:c}=a,{update:l,add:u}=c,h={animation:o,stage:"expand",data:c};u.edges.forEach(t=>l.edges.set(Km(t),t)),u.nodes.forEach(t=>l.nodes.set(Km(t),t)),this.updateElements(l,h),yield null===(r=this.context.animation.animate(o,{beforeAnimate:e=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.EXPAND,e,c),h),afterAnimate:e=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.EXPAND,e,c),h)},{expand:{target:e,descendants:Array.from(u.nodes).map(([,t])=>Km(t)),position:s}}))||void 0===r?void 0:r.finished})}collapseCombo(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i,element:o}=this.context;if(i.getAncestorsData(e,zv).some(t=>rw(t)))return;const A=o.getElement(e),s=A.getComboPosition(Object.assign(Object.assign({},A.attributes),{collapsed:!0})),a=this.computeChangesAndDrawData({stage:"collapse",animation:n});if(!a)return;const{dataChanges:c,drawData:l}=a;this.markDestroyElement(l);const{update:u,remove:h}=l,d={animation:n,stage:"collapse",data:l};this.destroyElements(h,d),this.updateElements(u,d);const f=t=>Array.from(t).map(([,t])=>Km(t));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new YZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:c,animation:n}),d),beforeAnimate:e=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.COLLAPSE,e,l),d),afterAnimate:e=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.COLLAPSE,e,l),d),after:()=>this.emit(new YZ(t.GraphEvent.AFTER_DRAW,{dataChanges:c,animation:n}),d)},{collapse:{target:e,descendants:[...f(h.nodes),...f(h.combos)],position:s}}))||void 0===r?void 0:r.finished})}expandCombo(e,n){return De(this,void 0,void 0,function*(){var r;const{model:i}=this.context,o=My(i.getComboData([e])[0]);this.computeStyle("expand");const A=this.computeChangesAndDrawData({stage:"expand",animation:n});if(!A)return;const{dataChanges:s,drawData:a}=A,{add:c,update:l}=a,u={animation:n,stage:"expand",data:a,target:e};this.createElements(c,u),this.updateElements(l,u);const h=t=>Array.from(t).map(([,t])=>Km(t));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new YZ(t.GraphEvent.BEFORE_DRAW,{dataChanges:s,animation:n}),u),beforeAnimate:e=>this.emit(new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.EXPAND,e,a),u),afterAnimate:e=>this.emit(new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.EXPAND,e,a),u),after:()=>this.emit(new YZ(t.GraphEvent.AFTER_DRAW,{dataChanges:s,animation:n}),u)},{expand:{target:e,descendants:[...h(c.nodes),...h(c.combos)],position:o}}))||void 0===r?void 0:r.finished})}clear(){this.container.destroy(),this.initContainer(),this.elementMap={},this.shapeTypeMap={},this.defaultStyle={},this.stateStyle={},this.paletteStyle={}}destroy(){this.clear(),this.container.destroy(),this.context={}}}class lJ{get presetOptions(){return{animation:!!rm(this.context.options,!0)}}get options(){const{options:t}=this.context;return t.layout}constructor(t){this.instances=[],this.context=t}getLayoutInstance(){return this.instances}preLayout(e){return De(this,void 0,void 0,function*(){var n,r,i,o;const{graph:A,model:s}=this.context,{add:a}=e;ZZ(A,new YZ(t.GraphEvent.BEFORE_LAYOUT,{type:"pre"}));const c=yield null===(n=this.context.layout)||void 0===n?void 0:n.simulate();null===(r=null==c?void 0:c.nodes)||void 0===r||r.forEach(t=>{const e=Km(t),n=a.nodes.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)}),null===(i=null==c?void 0:c.edges)||void 0===i||i.forEach(t=>{const e=Km(t),n=a.edges.get(e);s.syncEdgeDatum(t),n&&Object.assign(n.style,t.style)}),null===(o=null==c?void 0:c.combos)||void 0===o||o.forEach(t=>{const e=Km(t),n=a.combos.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)}),ZZ(A,new YZ(t.GraphEvent.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)})}postLayout(){return De(this,arguments,void 0,function*(e=this.options){if(!e)return;const n=Array.isArray(e)?e:[e],{graph:r}=this.context;ZZ(r,new YZ(t.GraphEvent.BEFORE_LAYOUT,{type:"post"}));for(let e=0;e<n.length;e++){const i=n[e],o=this.getLayoutData(i),A=Object.assign(Object.assign({},this.presetOptions),i);ZZ(r,new YZ(t.GraphEvent.BEFORE_STAGE_LAYOUT,{options:A,index:e}));const s=yield this.stepLayout(o,A,e);ZZ(r,new YZ(t.GraphEvent.AFTER_STAGE_LAYOUT,{options:A,index:e})),i.animation||this.updateElementPosition(s,!1)}ZZ(r,new YZ(t.GraphEvent.AFTER_LAYOUT,{type:"post"})),this.transformDataAfterLayout("post")})}transformDataAfterLayout(t,e){const n=this.context.transform.getTransformInstance();Object.values(n).forEach(n=>n.afterLayout(t,e))}simulate(){return De(this,arguments,void 0,function*(t=this.options){if(!t)return{};const e=Array.isArray(t)?t:[t];let n={};for(let t=0;t<e.length;t++){const r=e[t],i=this.getLayoutData(r);n=yield this.stepLayout(i,Object.assign(Object.assign(Object.assign({},this.presetOptions),r),{animation:!1}),t)}return n})}stepLayout(t,e,n){return De(this,void 0,void 0,function*(){return function(t){const{type:e}=t;return["compact-box","mindmap","dendrogram","indented"].includes(e)}(e)?yield this.treeLayout(t,e,n):yield this.graphLayout(t,e,n)})}graphLayout(t,e,n){return De(this,void 0,void 0,function*(){const{animation:r,iterations:i=300}=e,o=this.initGraphLayout(e);if(!o)return{};if(this.instances[n]=o,this.instance=o,CC(o))return r?yield o.execute(t,{animate:!0,maxIteration:i,onTick:t=>this.updateElementPosition(t,!1)}):(o.execute(t),o.stop(),o.tick(i));const A=yield o.execute(t);if(r){const t=this.updateElementPosition(A,r);yield null==t?void 0:t.finished}return A})}treeLayout(t,e,n){return De(this,void 0,void 0,function*(){const{type:n,animation:r}=e,i=Xv("layout",n);if(!i)return{};const{nodes:o=[],edges:A=[]}=t,s=new vE({nodes:o.map(t=>({id:Km(t),data:t.data||{}})),edges:A.map(t=>({id:Km(t),source:t.source,target:t.target,data:t.data||{}}))});!function(t){if(t.hasTreeStructure(Vv))return;t.attachTreeStructure(Vv);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,Vv)}}(s);const a={nodes:[],edges:[]},c={nodes:[],edges:[]};s.getRoots(Vv).forEach(t=>{Zy(t,t=>{t.children=s.getSuccessors(t.id)},t=>s.getSuccessors(t.id),"TB");const n=i(t,e),{x:r,y:o,z:A=0}=n;Zy(n,t=>{const{id:e,x:n,y:i,z:s=0}=t;a.nodes.push({id:e,style:{x:r,y:o,z:A}}),c.nodes.push({id:e,style:{x:n,y:i,z:s}})},t=>t.children,"TB")});const l=this.inferTreeLayoutOffset(c);if(uJ(c,l),r){uJ(a,l),this.updateElementPosition(a,!1);const t=this.updateElementPosition(c,r);yield null==t?void 0:t.finished}return c})}inferTreeLayoutOffset(t){var e;let[n,r]=[1/0,-1/0],[i,o]=[1/0,-1/0];null===(e=t.nodes)||void 0===e||e.forEach(t=>{const{x:e=0,y:A=0}=t.style||{};n=Math.min(n,e),r=Math.max(r,e),i=Math.min(i,A),o=Math.max(o,A)});const{canvas:A}=this.context,s=A.getSize(),[a,c]=A.getCanvasByViewport([0,0]),[l,u]=A.getCanvasByViewport(s);if(n>=a&&r<=l&&i>=c&&o<=u)return[0,0];return[(a+l)/2-(n+r)/2,(c+u)/2-(i+o)/2]}stopLayout(){this.instance&&CC(this.instance)&&(this.instance.stop(),this.instance=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutData(t){const{nodeFilter:e=()=>!0,comboFilter:n=()=>!0,preLayout:r=!1,isLayoutInvisibleNodes:i=!1}=t,{nodes:o,edges:A,combos:s}=this.context.model.getData(),{element:a,model:c}=this.context,l=t=>a.getElement(t),u=r?t=>{var n;if(!i){if("hidden"===(null===(n=t.style)||void 0===n?void 0:n.visibility))return!1;if(c.getAncestorsData(t.id,Vv).some(rw))return!1;if(c.getAncestorsData(t.id,zv).some(rw))return!1}return e(t)}:t=>{const n=Km(t),r=l(n);return!!r&&(!eE(r)&&e(t))},h=o.filter(u),d=s.filter(n),f=new Map(h.map(t=>[Km(t),t]));d.forEach(t=>f.set(Km(t),t));return{nodes:h,edges:A.filter(({source:t,target:e})=>f.has(t)&&f.has(e)),combos:d}}initGraphLayout(t){var e;const{element:n,viewport:r}=this.context,{type:i,animation:o,iterations:A}=t,s=Pe(t,["type","animation","iterations"]),[a,c]=r.getCanvasSize(),l=[a/2,c/2],u=null!==(e=null==t?void 0:t.nodeSize)&&void 0!==e?e:t=>{const e=null==n?void 0:n.getElement(t.id);return e?e.attributes.size:null==n?void 0:n.getElementComputedStyle("node",t).size},h=Xv("layout",i);if(!h)return Zv(`The layout of ${i} is not registered.`);const d=Object.getPrototypeOf(h.prototype)===mE.prototype?h:function(t){return!("forEachNode"in t.prototype)&&!("forEachEdge"in t.prototype)}(h)?function(t,e){return class extends mE{constructor(e,n){if(super(e,n),this.instance=new t({}),this.id=this.instance.id,"stop"in this.instance&&"tick"in this.instance){const t=this.instance;this.stop=t.stop.bind(t),this.tick=e=>{var n;return wE(null===(n=t.tick)||void 0===n?void 0:n.call(t,e))}}}execute(t,e){return De(this,void 0,void 0,function*(){return wE(yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(be({},this.options,e))))})}transformOptions(t){if(!("onTick"in t))return t;const e=t.onTick;return t.onTick=t=>e(wE(t)),t}graphData2LayoutModel(t){const{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.map(t=>{const e=Km(t),{data:n,style:r,combo:i}=t,o=Pe(t,["data","style","combo"]),A={id:e,data:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n),{data:n}),i?{parentId:i}:{}),{style:r}),o)};return(null==r?void 0:r.x)&&Object.assign(A.data,{x:r.x}),(null==r?void 0:r.y)&&Object.assign(A.data,{y:r.y}),(null==r?void 0:r.z)&&Object.assign(A.data,{z:r.z}),A}),A=new Map(o.map(t=>[t.id,t])),s=r.filter(t=>{const{source:e,target:n}=t;return A.has(e)&&A.has(n)}).map(t=>{const{source:e,target:n,data:r,style:i}=t;return{id:Km(t),source:e,target:n,data:Object.assign({},r),style:Object.assign({},i)}}),a=i.map(t=>({id:Km(t),data:Object.assign({_isCombo:!0},t.data),style:Object.assign({},t.style)})),c=new vE({nodes:[...o,...a],edges:s});return e.model.model.hasTreeStructure(zv)&&(c.attachTreeStructure(zv),o.forEach(t=>{const n=e.model.model.getParent(t.id,zv);n&&c.hasNode(n.id)&&c.setParent(t.id,n.id,zv)})),c}}}(h,this.context):yE(h,this.context),f=new d(this.context),g={nodeSize:u,width:a,height:c,center:l};switch(f.id){case"d3-force":case"d3-force-3d":Object.assign(g,{center:{x:a/2,y:c/2,z:0}})}return be(f.options,g,s),f}updateElementPosition(t,e){const{model:n,element:r}=this.context;return r?(n.updateData(t),r.draw({animation:e,silence:!0})):null}destroy(){this.stopLayout(),this.context={},this.instance=void 0,this.instances=[],this.animationResult=void 0}}const uJ=(t,e)=>{var n;const[r,i]=e;null===(n=t.nodes)||void 0===n||n.forEach(t=>{if(t.style){const{x:e=0,y:n=0}=t.style;t.style.x=e+r,t.style.y=n+i}else t.style={x:r,y:i}})};function hJ(t){return t.layout?(Array.isArray(t.layout)||"preLayout"in t.layout||["antv-dagre","combo-combined","compact-box","circular","concentric","dagre","fishbone","grid","indented","mds","radial","random","snake","dendrogram","mindmap"].includes(t.layout.type)&&(t.layout.preLayout=!0),t):t}class dJ extends ny{constructor(t){super(t),this.category="plugin",this.setPlugins(this.context.options.plugins||[])}setPlugins(t){this.setExtensions(t)}getPluginInstance(t){const e=this.extensionMap[t];if(e)return e;Zv(`Cannot find the plugin ${t}, will try to find it by type.`);const n=this.extensions.find(e=>e.type===t);return n?this.extensionMap[n.key]:void 0}}const fJ=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class gJ extends ny{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...fJ.slice(0,fJ.length-1),...t,fJ[fJ.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class pJ{get padding(){return pm(this.context.options.padding)}get paddingOffset(){const[t,e,n,r]=this.padding,[i,o,A]=[(r-e)/2,(t-n)/2,0];return[i,o,A]}constructor(t){this.landmarkCounter=0,this.context=t;const[e,n]=this.paddingOffset,{zoom:r,rotation:i,x:o=e,y:A=n}=t.options;this.transform({mode:"absolute",scale:r,translate:[o,A],rotate:i},!1)}get camera(){const{canvas:t}=this.context;return new Proxy(t.getCamera(),{get:(e,n)=>{const r=Object.entries(t.getLayers()).filter(([t])=>!["main"].includes(t)),i=r.map(([,t])=>t.getCamera()),o=e[n];if("function"==typeof o)return(...t)=>{const r=o.apply(e,t);return i.forEach(e=>{e[n].apply(e,t)}),r}}})}createLandmark(t){return this.camera.createLandmark("landmark-"+this.landmarkCounter++,t)}getAnimation(t){const e=rm(this.context.options,t);return!!e&&ke(Object.assign({},e),["easing","duration"])}getCanvasSize(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e,n]}getCanvasCenter(){const{canvas:t}=this.context,{width:e=0,height:n=0}=t.getConfig();return[e/2,n/2,0]}getViewportCenter(){const[t,e]=this.camera.getPosition();return[t,e,0]}getGraphCenter(){return this.context.graph.getViewportByCanvas(this.getCanvasCenter())}getZoom(){return this.camera.getZoom()}getRotation(){return this.camera.getRoll()}getTranslateOptions(t){const{camera:e}=this,{mode:n,translate:r=[]}=t,i=this.getZoom(),o=e.getPosition(),A=e.getFocalPoint(),[s,a]=this.getCanvasCenter(),[c=0,l=0,u=0]=r,h=uy([-c,-l,-u],i);return"relative"===n?{position:ay(o,h),focalPoint:ay(A,h)}:{position:ay([s,a,o[2]],h),focalPoint:ay([s,a,A[2]],h)}}getRotateOptions(t){const{mode:e,rotate:n=0}=t;return{roll:"relative"===e?this.camera.getRoll()+n:n}}getZoomOptions(t){const{zoomRange:e}=this.context.options,n=this.camera.getZoom(),{mode:r,scale:i=1}=t;return ne("relative"===r?n*i:i,...e)}transform(e,n){return De(this,void 0,void 0,function*(){const{graph:r}=this.context,{translate:i,rotate:o,scale:A,origin:s}=e;this.cancelAnimation();const a=this.getAnimation(n);if(ZZ(r,new $Z(t.GraphEvent.BEFORE_TRANSFORM,e)),!o&&A&&!i&&s&&!a)return this.camera.setZoomByViewportPoint(this.getZoomOptions(e),s),void ZZ(r,new $Z(t.GraphEvent.AFTER_TRANSFORM,e));const c={};if(i&&Object.assign(c,this.getTranslateOptions(e)),re(o)&&Object.assign(c,this.getRotateOptions(e)),re(A)&&Object.assign(c,{zoom:this.getZoomOptions(e)}),a)return ZZ(r,new XZ(t.GraphEvent.BEFORE_ANIMATE,Pv.TRANSFORM,null,e)),new Promise(n=>{this.transformResolver=n,this.camera.gotoLandmark(this.createLandmark(c),Object.assign(Object.assign({},a),{onfinish:()=>{ZZ(r,new XZ(t.GraphEvent.AFTER_ANIMATE,Pv.TRANSFORM,null,e)),ZZ(r,new $Z(t.GraphEvent.AFTER_TRANSFORM,e)),this.transformResolver=void 0,n()}}))});this.camera.gotoLandmark(this.createLandmark(c),{duration:0}),ZZ(r,new $Z(t.GraphEvent.AFTER_TRANSFORM,e))})}fitView(t,e){return De(this,void 0,void 0,function*(){const[n,r,i,o]=this.padding,{when:A="always",direction:s="both"}=t||{},[a,c]=this.context.canvas.getSize(),l=a-o-r,u=c-n-i,h=this.context.canvas.getBounds(),d=this.getBBoxInViewport(h),[f,g]=wm(d);if("overflow"===A&&!("x"===s&&f>=l||"y"===s&&g>=u||"both"===s&&f>=l&&g>=u))return yield this.fitCenter({animation:e});const p=l/f,v=u/g,m="x"===s?p:"y"===s?v:Math.min(p,v),y=this.getAnimation(e);Number.isFinite(m)&&(yield this.transform({mode:"relative",scale:m,translate:ay(cy(this.getCanvasCenter(),this.getBBoxInViewport(h).center),uy(this.paddingOffset,m))},y))})}fitCenter(t){return De(this,void 0,void 0,function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)})}focusElements(t){return De(this,arguments,void 0,function*(t,e={}){const{element:n}=this.context;if(!n)return;const r=xm(t.map(t=>{return r=n.getElement(t),e.shapes?r.getShape(e.shapes).getRenderBounds():r.getRenderBounds();var r}));yield this.focus(r,e)})}focus(t,e){return De(this,void 0,void 0,function*(){const n=this.context.graph.getViewportByCanvas(t.center),r=cy(e.position||this.getCanvasCenter(),n);yield this.transform({mode:"relative",translate:ay(r,this.paddingOffset)},e.animation)})}getBBoxInViewport(t){const{min:e,max:n}=t,{graph:r}=this.context,[i,o]=r.getViewportByCanvas(e),[A,s]=r.getViewportByCanvas(n),a=new yr;return a.setMinMax([i,o,0],[A,s,0]),a}isInViewport(t,e=!1,n=0){const{graph:r}=this.context,i=this.getCanvasSize(),[o,A]=r.getCanvasByViewport([0,0]),[s,a]=r.getCanvasByViewport(i);let c=new yr;return c.setMinMax([o,A,0],[s,a,0]),n&&(c=Em(c,n)),fm(t)?Cm(t,c):e?function(t,e){const[n,r]=t.min,[i,o]=t.max,[A,s]=e.min,[a,c]=e.max;return n>=A&&i<=a&&r>=s&&o<=c}(t,c):c.intersects(t)}cancelAnimation(){var t,e;(null===(t=this.camera.landmarks)||void 0===t?void 0:t.length)&&this.camera.cancelLandmarkAnimation(),null===(e=this.transformResolver)||void 0===e||e.call(this)}}class vJ extends hE{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new aJ},this.isCollapsingExpanding=!1,this.onResize=pe(()=>{this.resize()},300),this._setOptions(Object.assign({},vJ.defaultOptions,t),!0),this.context.graph=this,this.options.autoResize&&(null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize))}getOptions(){return this.options}setOptions(t){this._setOptions(t,!1)}_setOptions(t,e){if(this.updateCanvas(t),Object.assign(this.options,function(t){return[hJ].reduce((t,e)=>e(t),t)}(t)),e){const{data:e}=t;return void(e&&this.addData(e))}const{behaviors:n,combo:r,data:i,edge:o,layout:A,node:s,plugins:a,theme:c,transforms:l}=t;n&&this.setBehaviors(n),i&&this.setData(i),s&&this.setNode(s),o&&this.setEdge(o),r&&this.setCombo(r),A&&this.setLayout(A),c&&this.setTheme(c),a&&this.setPlugins(a),l&&this.setTransforms(l)}getSize(){return this.context.canvas?this.context.canvas.getSize():[this.options.width||0,this.options.height||0]}setSize(t,e){t&&(this.options.width=t),e&&(this.options.height=e),this.resize(t,e)}setZoomRange(t){this.options.zoomRange=t}getZoomRange(){return this.options.zoomRange}setNode(t){this.options.node=t,this.context.model.refreshData()}setEdge(t){this.options.edge=t,this.context.model.refreshData()}setCombo(t){this.options.combo=t,this.context.model.refreshData()}getTheme(){return this.options.theme}setTheme(t){this.options.theme=Gt(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=Gt(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=Gt(t)?t(this.getBehaviors()):t,null===(e=this.context.behavior)||void 0===e||e.setBehaviors(this.options.behaviors)}updateBehavior(t){this.setBehaviors(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))}getBehaviors(){return this.options.behaviors||[]}setPlugins(t){var e;this.options.plugins=Gt(t)?t(this.getPlugins()):t,null===(e=this.context.plugin)||void 0===e||e.setPlugins(this.options.plugins)}updatePlugin(t){this.setPlugins(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e))}getPlugins(){return this.options.plugins||[]}getPluginInstance(t){return this.context.plugin.getPluginInstance(t)}setTransforms(t){var e;this.options.transforms=Gt(t)?t(this.getTransforms()):t,null===(e=this.context.transform)||void 0===e||e.setTransforms(this.options.transforms)}updateTransform(t){this.setTransforms(e=>e.map(e=>"object"==typeof e&&e.key===t.key?Object.assign(Object.assign({},e),t):e)),this.context.model.refreshData()}getTransforms(){return this.options.transforms||[]}getData(){return this.context.model.getData()}hasNode(t){return this.context.model.hasNode(t)}hasEdge(t){return this.context.model.hasEdge(t)}hasCombo(t){return this.context.model.hasCombo(t)}getElementData(t){return Array.isArray(t)?t.map(t=>this.context.model.getElementDataById(t)):this.context.model.getElementDataById(t)}getNodeData(t){return void 0===t?this.context.model.getNodeData():Array.isArray(t)?this.context.model.getNodeData(t):this.context.model.getNodeLikeDatum(t)}getEdgeData(t){return void 0===t?this.context.model.getEdgeData():Array.isArray(t)?this.context.model.getEdgeData(t):this.context.model.getEdgeDatum(t)}getComboData(t){return void 0===t?this.context.model.getComboData():Array.isArray(t)?this.context.model.getComboData(t):this.context.model.getNodeLikeDatum(t)}setData(t){this.context.model.setData(Gt(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Gt(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Gt(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Gt(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Gt(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(Gt(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Gt(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Gt(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Gt(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Gt(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Gt(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Gt(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Gt(t)?t(this.getComboData()):t)}getElementType(t){return this.context.model.getElementType(t)}getRelatedEdgesData(t,e="both"){return this.context.model.getRelatedEdgesData(t,e)}getNeighborNodesData(t){return this.context.model.getNeighborNodesData(t)}getAncestorsData(t,e){return this.context.model.getAncestorsData(t,e)}getParentData(t,e){return this.context.model.getParentData(t,e)}getChildrenData(t){return this.context.model.getChildrenData(t)}getDescendantsData(t){return this.context.model.getDescendantsData(t)}getElementDataByState(t,e){return this.context.model.getElementDataByState(t,e)}initCanvas(){return De(this,void 0,void 0,function*(){var e;if(this.context.canvas)return yield this.context.canvas.ready;const{container:n="container",width:r,height:i,renderer:o,cursor:A,background:s,canvas:a,devicePixelRatio:c=(null!==(e=globalThis.devicePixelRatio)&&void 0!==e?e:1)}=this.options;if(n instanceof GZ)this.context.canvas=n,A&&n.setCursor(A),o&&n.setRenderer(o),yield n.ready;else{const e=Jt(n)?document.getElementById(n):n,l=VZ(e);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:e,width:r,height:i});const u=Object.assign(Object.assign({},a),{container:e,width:r||l[0],height:i||l[1],background:s,renderer:o,cursor:A,devicePixelRatio:c}),h=new GZ(u);this.context.canvas=h,yield h.ready,this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:h})}})}updateCanvas(e){var n,r;const{renderer:i,cursor:o,height:A,width:s}=e,a=this.context.canvas;a&&(i&&(this.emit(t.GraphEvent.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),a.setRenderer(i),this.emit(t.GraphEvent.AFTER_RENDERER_CHANGE,{renderer:i})),o&&a.setCursor(o),(re(s)||re(A))&&this.setSize(null!==(n=null!=s?s:this.options.width)&&void 0!==n?n:0,null!==(r=null!=A?A:this.options.height)&&void 0!==r?r:0))}initRuntime(){this.context.options=this.options,this.context.batch||(this.context.batch=new iJ(this.context)),this.context.plugin||(this.context.plugin=new dJ(this.context)),this.context.viewport||(this.context.viewport=new pJ(this.context)),this.context.transform||(this.context.transform=new gJ(this.context)),this.context.element||(this.context.element=new cJ(this.context)),this.context.animation||(this.context.animation=new rJ(this.context)),this.context.layout||(this.context.layout=new lJ(this.context)),this.context.behavior||(this.context.behavior=new oJ(this.context))}prepare(){return De(this,void 0,void 0,function*(){yield Promise.resolve(),this.destroyed?console.error($v("The graph instance has been destroyed")):(yield this.initCanvas(),this.initRuntime())})}render(){return De(this,void 0,void 0,function*(){if(yield this.prepare(),ZZ(this,new YZ(t.GraphEvent.BEFORE_RENDER)),this.options.layout)if(this.rendered||(e=this.options.layout,Array.isArray(e)||!(null==e?void 0:e.preLayout))){const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.context.layout.postLayout()]),yield this.autoFit()}else{const t=yield this.context.element.preLayoutDraw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}else{const t=this.context.element.draw({type:"render"});yield Promise.all([null==t?void 0:t.finished,this.autoFit()])}var e;this.rendered=!0,ZZ(this,new YZ(t.GraphEvent.AFTER_RENDER))})}draw(){return De(this,void 0,void 0,function*(){var t;yield this.prepare(),yield null===(t=this.context.element.draw())||void 0===t?void 0:t.finished})}layout(t){return De(this,void 0,void 0,function*(){yield this.context.layout.postLayout(t)})}stopLayout(){this.context.layout.stopLayout()}clear(){return De(this,void 0,void 0,function*(){const{model:t,element:e}=this.context;t.setData({}),t.clearChanges(),null==e||e.clear()})}destroy(){var e;ZZ(this,new YZ(t.GraphEvent.BEFORE_DESTROY));const{layout:n,animation:r,element:i,model:o,canvas:A,behavior:s,plugin:a}=this.context;null==a||a.destroy(),null==s||s.destroy(),null==n||n.destroy(),null==r||r.destroy(),null==i||i.destroy(),o.destroy(),null==A||A.destroy(),this.options={},this.context={},this.off(),null===(e=globalThis.removeEventListener)||void 0===e||e.call(globalThis,"resize",this.onResize),this.destroyed=!0,ZZ(this,new YZ(t.GraphEvent.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,n){var r;const i=VZ(null===(r=this.context.canvas)||void 0===r?void 0:r.getContainer()),o=[e||i[0],n||i[1]];if(!this.context.canvas)return;const A=this.context.canvas.getSize();xe(o,A)||(ZZ(this,new YZ(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:o})),this.context.canvas.resize(...o),ZZ(this,new YZ(t.GraphEvent.AFTER_SIZE_CHANGE,{size:o})))}fitView(t,e){return De(this,void 0,void 0,function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.fitView(t,e)})}fitCenter(t){return De(this,void 0,void 0,function*(){var e;yield null===(e=this.context.viewport)||void 0===e?void 0:e.fitCenter({animation:t})})}autoFit(){return De(this,void 0,void 0,function*(){const{autoFit:t}=this.context.options;if(t)if(Jt(t))"view"===t?yield this.fitView():"center"===t&&(yield this.fitCenter());else{const{type:e,animation:n}=t;"view"===e?yield this.fitView(t.options,n):"center"===e&&(yield this.fitCenter(n))}})}focusElement(t,e){return De(this,void 0,void 0,function*(){var n;yield null===(n=this.context.viewport)||void 0===n?void 0:n.focusElements(Array.isArray(t)?t:[t],{animation:e})})}zoomBy(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)})}zoomTo(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",scale:t,origin:n},e)})}getZoom(){return this.context.viewport.getZoom()}rotateBy(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)})}rotateTo(t,e,n){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",rotate:t,origin:n},e)})}getRotation(){return this.context.viewport.getRotation()}translateBy(t,e){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)})}translateTo(t,e){return De(this,void 0,void 0,function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)})}getPosition(){return cy([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach(([t,e])=>this.context.model.translateNodeLikeBy(t,e)),yield null===(i=this.context.element.draw({animation:A,stage:"translate"}))||void 0===i?void 0:i.finished})}translateElementTo(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n];Object.entries(o).forEach(([t,e])=>this.context.model.translateNodeLikeTo(t,e)),yield null===(i=this.context.element.draw({animation:A,stage:"translate"}))||void 0===i?void 0:i.finished})}getElementPosition(t){return this.context.model.getElementPosition(t)}getElementRenderStyle(t){return Se(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach(([t,e])=>{const n=this.getElementType(t);s[`${n}s`].push({id:t,style:{visibility:e}})});const{model:a,element:c}=this.context;a.preventUpdateNodeLikeHierarchy(()=>{a.updateData(s)}),yield null===(i=c.draw({animation:A,stage:"visibility"}))||void 0===i?void 0:i.finished})}showElement(t,e){return De(this,void 0,void 0,function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map(t=>[t,"visible"])),e)})}hideElement(t,e){return De(this,void 0,void 0,function*(){const n=Array.isArray(t)?t:[t];yield this.setElementVisibility(Object.fromEntries(n.map(t=>[t,"hidden"])),e)})}getElementVisibility(t){var e,n;const r=this.context.element.getElement(t);return null!==(n=null===(e=null==r?void 0:r.style)||void 0===e?void 0:e.visibility)&&void 0!==n?n:"visible"}setElementZIndex(t,e){return De(this,void 0,void 0,function*(){var n;const r={nodes:[],edges:[],combos:[]},i=zt(t)?t:{[t]:e};Object.entries(i).forEach(([t,e])=>{const n=this.getElementType(t);r[`${n}s`].push({id:t,style:{zIndex:e}})});const{model:o,element:A}=this.context;o.preventUpdateNodeLikeHierarchy(()=>o.updateData(r)),yield null===(n=A.draw({animation:!1,stage:"zIndex"}))||void 0===n?void 0:n.finished})}frontElement(t){return De(this,void 0,void 0,function*(){const e=Array.isArray(t)?t:[t],{model:n}=this.context,r={};e.map(t=>{const e=n.getFrontZIndex(t);if("combo"===n.getElementType(t)){const i=n.getAncestorsData(t,zv).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(Km(i))],A=e-JZ(i);o.forEach(t=>{r[Km(t)]=this.getElementZIndex(Km(t))+A});const{internal:s}=vB(o.map(Km),t=>n.getRelatedEdgesData(t));s.forEach(t=>{const e=Km(t);r[e]=this.getElementZIndex(e)+A})}else r[t]=e}),yield this.setElementZIndex(r)})}getElementZIndex(t){return JZ(this.context.model.getElementDataById(t))}setElementState(t,e){return De(this,arguments,void 0,function*(t,e,n=!0){var r,i;const[o,A]=zt(t)?[t,null===(r=e)||void 0===r||r]:[{[t]:e},n],s={nodes:[],edges:[],combos:[]};Object.entries(o).forEach(([t,e])=>{const n=this.getElementType(t);var r;s[`${n}s`].push({id:t,states:(r=e,r?Array.isArray(r)?r:[r]:[])})}),this.updateData(s),yield null===(i=this.context.element.draw({animation:A,stage:"state"}))||void 0===i?void 0:i.finished})}getElementState(t){return this.context.model.getElementState(t)}getElementRenderBounds(t){return this.context.element.getElement(t).getRenderBounds()}collapseElement(t){return De(this,arguments,void 0,function*(t,e=!0){const{model:n,element:r}=this.context;if(rw(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!1});const i=n.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,n.updateData("node"===i?{nodes:[{id:t,style:{collapsed:!0}}]}:{combos:[{id:t,style:{collapsed:!0}}]}),"node"===i?yield r.collapseNode(t,e):"combo"===i&&(yield r.collapseCombo(t,!!e.animation)),this.isCollapsingExpanding=!1})}expandElement(t){return De(this,arguments,void 0,function*(t,e=!0){const{model:n,element:r}=this.context;if(!rw(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!1});const i=n.getElementType(t);this.isCollapsingExpanding=!0,n.updateData("node"===i?{nodes:[{id:t,style:{collapsed:!1}}]}:{combos:[{id:t,style:{collapsed:!1}}]}),"node"===i?yield r.expandNode(t,e):"combo"===i&&(yield r.expandCombo(t,!!e.animation)),this.isCollapsingExpanding=!1})}setElementCollapsibility(t,e){const n=this.getElementType(t);"node"===n?this.updateNodeData([{id:t,style:{collapsed:e}}]):"combo"===n&&this.updateComboData([{id:t,style:{collapsed:e}}])}toDataURL(){return De(this,arguments,void 0,function*(t={}){return this.context.canvas.toDataURL(t)})}getCanvasByViewport(t){return this.context.canvas.getCanvasByViewport(t)}getViewportByCanvas(t){return this.context.canvas.getViewportByCanvas(t)}getClientByCanvas(t){return this.context.canvas.getClientByCanvas(t)}getCanvasByClient(t){return this.context.canvas.getCanvasByClient(t)}getViewportCenter(){return this.context.viewport.getViewportCenter()}getCanvasCenter(){return this.context.viewport.getCanvasCenter()}on(t,e,n){return super.on(t,e,n)}once(t,e){return super.once(t,e)}off(t,e){return super.off(t,e)}}vJ.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const mJ=(t,e)=>{const{source:n,target:r}=e,i=t.getElementDataById(n),o=t.getElementDataById(r),A=mB(i,e=>t.getParentData(e,zv)),s=mB(o,e=>t.getParentData(e,zv)),a={sourceNode:Km(A),targetNode:Km(s)};return e.style?Object.assign(e.style,a):e.style=a,e};class yJ extends UZ{constructor(t,e){super(t,be({},yJ.defaultOptions,e)),this.assignSizeByCentrality=(t,e,n,r,i,o)=>{const A=[e,n],s=[r[0],i[0]],a=[r[1],i[1]],c=[r[2],i[2]],l=(t,e)=>{if("function"==typeof o)return o(t,A,e);switch(o){case"linear":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return i===r?o:o+(t-r)/(i-r)*(A-o)})(t,A,e);case"log":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return o+Math.log(t-r+1)/Math.log(i-r+1)*(A-o)})(t,A,e);case"pow":return((t,e,n,r=2)=>{const[i,o]=e,[A,s]=n;return A+Math.pow((t-i)/(o-i),r)*(s-A)})(t,A,e,2);case"sqrt":return((t,e,n)=>{const[r,i]=e,[o,A]=n;return o+Math.sqrt((t-r)/(i-r))*(A-o)})(t,A,e);default:return e[0]}};return[l(t,s),l(t,a),l(t,c)]}}beforeDraw(t){const{model:e}=this.context,n=e.getNodeData(),r=cw(this.options.maxSize),i=cw(this.options.minSize),o=this.getCentralities(this.options.centrality),A=o.size>0?Math.max(...o.values()):0,s=o.size>0?Math.min(...o.values()):0;return n.forEach(e=>{var n;const a=this.assignSizeByCentrality(o.get(Km(e))||0,s,A,i,r,this.options.scale),c=null===(n=this.context.element)||void 0===n?void 0:n.getElement(Km(e)),l={size:a};this.assignLabelStyle(l,a,e,c),c&&TZ(l,c.attributes)||NZ(t,c?"update":"add","node",be(e,{style:l}),!0)}),t}assignLabelStyle(t,e,n,r){var i;const o=r?r.config.style:null===(i=this.context.element)||void 0===i?void 0:i.getElementComputedStyle("node",n);if(Object.assign(t,ke(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const n=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:n,labelLineHeight:n+vm(t.labelPadding)})}return t}getLabelSizeByNodeSize(t,e,n){const r=Math.min(...t)/2,[i,o]=Array.isArray(this.options.mapLabelSize)?this.options.mapLabelSize:[n,e];return Math.min(o,Math.max(r,i))}getCentralities(t){const{model:e}=this.context,n=e.getData();if("function"==typeof t)return t(n);const r=e.getRelatedEdgesData.bind(e);return Vm(n,r,t)}}yJ.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class wJ extends UZ{constructor(t,e){super(t,Object.assign({},wJ.defaultOptions,e))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var t;const e=My(this.ref),{graph:n,model:r}=this.context;null===(t=r.getData().nodes)||void 0===t||t.forEach(t=>{var i;if(Km(t)===Km(this.ref))return;const o=by(cy(My(t),e)),A=Math.abs(o)>Math.PI/2,s=!t.children||0===t.children.length,a=Km(t),c=null===(i=this.context.element)||void 0===i?void 0:i.getElement(a);if(!c||!c.isVisible())return;const l=(s?1:-1)*(cw(n.getElementRenderStyle(a).size)[0]/2+this.options.offset),u=[["translate",l*Math.cos(o),l*Math.sin(o)],["rotate",A?Tr(o)+180:Tr(o)]];r.updateNodeData([{id:Km(t),style:{labelTextAlign:A===s?"right":"left",labelTextBaseline:"middle",labelTransform:u}}])}),n.draw()}}wJ.defaultOptions={offset:5};const bJ=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class BJ extends UZ{constructor(t,e){super(t,Object.assign({},BJ.defaultOptions,e)),this.cacheMergeStyle=new Map,this.getAffectedParallelEdges=t=>{const{add:{edges:e},update:{nodes:n,edges:r,combos:i},remove:{edges:o}}=t,{model:A}=this.context,s=new Map,a=(t,e)=>{A.getRelatedEdgesData(e).forEach(t=>!s.has(Km(t))&&s.set(Km(t),t))};n.forEach(a),i.forEach(a);const c=e=>{const n=new Set(t.remove.edges.keys()),r=A.getEdgeData().filter(t=>!n.has(Km(t))).map(t=>mJ(A,t));xJ(e,r).forEach(t=>{const e=Km(t);s.has(e)||s.set(e,t)})};if(o.size&&o.forEach(c),e.size&&e.forEach(c),r.size){const t=oV(iV(A.getChanges())).update.edges;r.forEach(e=>{var n;c(e);const r=null===(n=t.find(t=>Km(t.value)===Km(e)))||void 0===n?void 0:n.original;r&&!CJ(e,r)&&c(r)})}Ee(this.options.edges)||s.forEach((t,e)=>!this.options.edges.includes(e)&&s.delete(e));const l=A.getEdgeData().map(Km);return new Map([...s].sort((t,e)=>l.indexOf(t[0])-l.indexOf(e[0])))},this.applyBundlingStyle=(t,e,n)=>{var r,i;const{edgeMap:o,reverses:A}=EJ(e),s=null!==(r=this.options.loopMode)&&void 0!==r?r:"spread",a=null!==(i=this.options.loopDistance)&&void 0!==i?i:n,c=new Map;o.forEach(e=>{e.forEach((e,r,i)=>{var o,l;const u=i.length,h=e.style||{};if(e.source===e.target)if("nested"===s){const t=h.loopPlacement||"top",n=`${e.source}-${t}`;if(h.loopPlacement=t,void 0===h.loopDist){const t=null!==(o=c.get(n))&&void 0!==o?o:0;h.loopDist=35+t*a,c.set(n,t+1)}}else{const t=bJ.length;h.loopPlacement=bJ[r%t],h.loopDist=Math.floor(r/t)*n+50}else if(1===u)h.curveOffset=0;else{const t=(r%2==0?1:-1)*(A[`${e.source}|${e.target}|${r}`]?-1:1);h.curveOffset=u%2==1?t*Math.ceil(r/2)*n*2:t*(Math.floor(r/2)*n*2+n)}const d=Object.assign(e,{type:"quadratic",style:h}),f=null===(l=this.context.element)||void 0===l?void 0:l.getElement(Km(e));f&&TZ(d.style,f.attributes)||NZ(t,f?"update":"add","edge",d,!0)})})},this.resetEdgeStyle=t=>{const e=t.style||{},n=this.cacheMergeStyle.get(Km(t))||{};return Object.keys(n).forEach(r=>{xe(e[r],n[r])&&(t[r]?e[r]=t[r]:delete e[r])}),Object.assign(t,{style:e})},this.applyMergingStyle=(t,e)=>{const{edgeMap:n,reverses:r}=EJ(e);n.forEach(e=>{var n;if(1===e.length){const r=e[0],i=null===(n=this.context.element)||void 0===n?void 0:n.getElement(Km(r)),o=this.resetEdgeStyle(r);return void(i&&TZ(o,i.attributes)||NZ(t,i?"update":"add","edge",o))}const i=e.map(({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:A}=n,s={},[a,c]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return ue(o)&&(s[a]=o),ue(A)&&(s[c]=A),s}).reduce((t,e)=>Object.assign(Object.assign({},t),e),{});e.forEach((e,n,r)=>{var o;if(0!==n)return void NZ(t,"remove","edge",e);const A=Object.assign({},Gt(this.options.style)?this.options.style(r):this.options.style,{childrenData:r});this.cacheMergeStyle.set(Km(e),A);const s=Object.assign(Object.assign({},e),{type:"line",style:Object.assign(Object.assign(Object.assign({},e.style),i),A)}),a=null===(o=this.context.element)||void 0===o?void 0:o.getElement(Km(e));a&&TZ(s.style,a.attributes)||NZ(t,a?"update":"add","edge",s,!0)})})}}beforeDraw(t){const e=this.getAffectedParallelEdges(t);return 0===e.size||("bundle"===this.options.mode?this.applyBundlingStyle(t,e,this.options.distance):this.applyMergingStyle(t,e)),t}}BJ.defaultOptions={mode:"bundle",distance:15,loopMode:"spread",loopDistance:15};const EJ=t=>{const e=new Map,n=new Set,r={},i=new Map;for(const[o,A]of t){if(n.has(o))continue;const{source:s,target:a}=A,c=`${s}-${a}`;e.has(c)||(e.set(c,[]),i.set(c,new Set));const l=e.get(c),u=i.get(c);l&&u&&!u.has(o)&&(l.push(A),u.add(o),n.add(o));for(const[l,u]of t)if(!n.has(l)&&l!==o&&CJ(A,u)){const t=e.get(c),o=i.get(c);t&&o&&!o.has(l)&&(t.push(u),o.add(l),s===u.target&&a===u.source&&(r[`${u.source}|${u.target}|${t.length-1}`]=!0),n.add(l))}}return{edgeMap:e,reverses:r}},xJ=(t,e,n)=>e.filter(e=>CJ(e,t)),CJ=(t,e)=>{const{sourceNode:n,targetNode:r}=t.style||{},{sourceNode:i,targetNode:o}=e.style||{};return n===i&&r===o||n===o&&r===i};const MJ={animation:{"combo-collapse":um,"combo-expand":hm,"node-collapse":sm,"node-expand":am,"path-in":cm,"path-out":lm,fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}]},behavior:{"brush-select":Yy,"click-select":nw,"collapse-expand":nE,"create-edge":cE,"drag-canvas":lE,"drag-element-force":EE,"drag-element":uE,"fix-element-size":xE,"focus-element":CE,"hover-activate":ME,"lasso-select":FE,"auto-adapt-label":oy,"optimize-viewport-transform":kE,"scroll-canvas":SE,"zoom-canvas":QE},combo:{circle:Yb,rect:Xb},edge:{cubic:BB,line:MB,polyline:PB,quadratic:DB,"cubic-horizontal":EB,"cubic-radial":xB,"cubic-vertical":CB},layout:{"antv-dagre":bF,"combo-combined":Yj,"compact-box":$E,"d3-force":Ok,"force-atlas2":nj,circular:QF,concentric:NF,dagre:LK,dendrogram:ix,fishbone:Xj,force:qK,fruchterman:oj,grid:sj,indented:lx,mds:Uj,mindmap:vx,radial:Dj,random:Kj,snake:Jj},node:{circle:Tw,diamond:Iw,ellipse:Rw,hexagon:Hw,html:Gb,image:Kb,rect:jb,star:zb,donut:Lw,triangle:Vb},palette:{spectral:["rgb(158, 1, 66)","rgb(213, 62, 79)","rgb(244, 109, 67)","rgb(253, 174, 97)","rgb(254, 224, 139)","rgb(255, 255, 191)","rgb(230, 245, 152)","rgb(171, 221, 164)","rgb(102, 194, 165)","rgb(50, 136, 189)","rgb(94, 79, 162)"],tableau:["rgb(78, 121, 167)","rgb(242, 142, 44)","rgb(225, 87, 89)","rgb(118, 183, 178)","rgb(89, 161, 79)","rgb(237, 201, 73)","rgb(175, 122, 161)","rgb(255, 157, 167)","rgb(156, 117, 95)","rgb(186, 176, 171)"],oranges:["rgb(255, 245, 235)","rgb(254, 230, 206)","rgb(253, 208, 162)","rgb(253, 174, 107)","rgb(253, 141, 60)","rgb(241, 105, 19)","rgb(217, 72, 1)","rgb(166, 54, 3)","rgb(127, 39, 4)"],greens:["rgb(247, 252, 245)","rgb(229, 245, 224)","rgb(199, 233, 192)","rgb(161, 217, 155)","rgb(116, 196, 118)","rgb(65, 171, 93)","rgb(35, 139, 69)","rgb(0, 109, 44)","rgb(0, 68, 27)"],blues:["rgb(247, 251, 255)","rgb(222, 235, 247)","rgb(198, 219, 239)","rgb(158, 202, 225)","rgb(107, 174, 214)","rgb(66, 146, 198)","rgb(33, 113, 181)","rgb(8, 81, 156)","rgb(8, 48, 107)"]},theme:{dark:SZ,light:QZ},plugin:{"bubble-sets":Hz,"edge-bundling":jz,"edge-filter-lens":Jz,"grid-line":rV,background:rz,contextmenu:Kz,fisheye:eV,fullscreen:nV,history:aV,hull:GV,legend:J$,minimap:tZ,snapline:iZ,timebar:aZ,title:mZ,toolbar:wZ,tooltip:bZ,watermark:xZ},transform:{"arrange-draw-order":class extends UZ{beforeDraw(t){const{model:e}=this.context,n=t.add.combos,r=t=>{const n=[];return t.forEach((t,r)=>{const i=e.getAncestorsData(r,"combo").map(t=>Km(t)).reverse();n.push([r,t,i.length])}),new Map(n.sort(([,,t],[,,e])=>e-t).map(([t,e])=>[t,e]))};return t.add.combos=r(n),t.update.combos=r(t.update.combos),t}},"collapse-expand-combo":class extends UZ{beforeDraw(t,e){if("visibility"===e.stage)return t;if(!this.context.model.model.hasTreeStructure(zv))return t;const{model:n}=this.context,{add:r,update:i}=t,o=[...t.update.combos.entries(),...t.add.combos.entries()];for(;o.length;){const[e,A]=o.pop();if(rw(A)){const A=n.getDescendantsData(e),s=A.map(Km),{internal:a,external:c}=vB(s,t=>n.getRelatedEdgesData(t));A.forEach(e=>{const r=Km(e),i=o.findIndex(([t])=>t===r);-1!==i&&o.splice(i,1);const A=n.getElementType(r);NZ(t,"remove",A,e)}),a.forEach(e=>NZ(t,"remove","edge",e)),c.forEach(t=>{var e;const n=Km(t);(null===(e=this.context.element)||void 0===e?void 0:e.getElement(n))?i.edges.set(n,t):r.edges.set(n,t)})}else{const r=n.getChildrenData(e),i=r.map(Km),{edges:A}=vB(i,t=>n.getRelatedEdgesData(t));[...r,...A].forEach(e=>{var r;const i=Km(e),A=n.getElementType(i),s=null===(r=this.context.element)||void 0===r?void 0:r.getElement(i);NZ(t,s?"update":"add",A,e),"combo"===A&&o.push([i,e])})}}return t}},"collapse-expand-node":class extends UZ{getElement(t){return this.context.element.getElement(t)}handleExpand(t,e){if(OZ(e,"add","node",t),rw(t))return;const n=Km(t);OZ(e,"add","node",t);this.context.model.getRelatedEdgesData(n).forEach(t=>{NZ(e,"add","edge",t)});this.context.model.getChildrenData(n).forEach(t=>{this.handleExpand(t,e)})}beforeDraw(t){const{graph:e,model:n}=this.context;if(!n.model.hasTreeStructure(Vv))return t;const{add:{nodes:r,edges:i},update:{nodes:o}}=t,A=new Map,s=new Map;r.forEach((t,e)=>{rw(t)&&A.set(e,t)}),i.forEach(t=>{if("node"!==e.getElementType(t.source))return;const n=e.getNodeData(t.source);rw(n)&&A.set(t.source,n)}),o.forEach((t,e)=>{const n=this.getElement(e);if(!n)return;const r=n.attributes.collapsed;rw(t)?r||A.set(e,t):r&&s.set(e,t)});const a=new Set;return A.forEach((e,r)=>{n.getDescendantsData(r).forEach(e=>{const r=Km(e);if(a.has(r))return;NZ(t,"remove","node",e);n.getRelatedEdgesData(r).forEach(e=>{NZ(t,"remove","edge",e)}),a.add(r)})}),s.forEach((e,r)=>{n.getAncestorsData(r,Vv).some(rw)?NZ(t,"remove","node",e):this.handleExpand(e,t)}),t}},"get-edge-actual-ends":class extends UZ{beforeDraw(t){const{add:e,update:n}=t,{model:r}=this.context;return[...e.edges.entries(),...n.edges.entries()].forEach(([,t])=>{mJ(r,t)}),t}},"map-node-size":yJ,"place-radial-labels":wJ,"process-parallel-edges":BJ,"update-related-edges":class extends UZ{beforeDraw(t,e){const{stage:n}=e;if("visibility"===n)return t;const{model:r}=this.context,{update:{nodes:i,edges:o,combos:A}}=t,s=(t,e)=>{r.getRelatedEdgesData(e).forEach(t=>!o.has(Km(t))&&o.set(Km(t),t))};return i.forEach(s),A.forEach(s),t}}},shape:{circle:za,ellipse:Ya,group:Xa,html:$a,image:Cw,line:tc,path:nc,polygon:ic,polyline:Ac,rect:sc,text:cc,label:yw,badge:ww}};Object.entries(MJ).forEach(([t,e])=>{Object.entries(e).forEach(([e,n])=>{PZ(t,e,n)})});t.AntVDagreLayout=bF,t.AutoAdaptLabel=oy,t.Background=rz,t.Badge=ww,t.BaseBehavior=iy,t.BaseCombo=Wb,t.BaseEdge=bB,t.BaseLayout=mE,t.BaseNode=Nw,t.BasePlugin=tz,t.BaseShape=pw,t.BaseTransform=UZ,t.BrushSelect=Yy,t.BubbleSets=Hz,t.CameraSetting=class extends tz{constructor(t,e){super(t,e),this.setOptions=t=>{const e=(t,e)=>{switch(t){case"projectionMode":return"perspective"===e?1:0;case"cameraType":return{orbiting:0,exploring:1,tracking:2}[e];case"aspect":return"number"==typeof e?e:this.getCanvasAspect();default:return e}};Object.entries({cameraType:"setType",near:"setNear",far:"setFar",fov:"setFov",aspect:"setAspect",projectionMode:"setProjectionMode",distance:"setDistance",minDistance:"setMinDistance",maxDistance:"setMaxDistance",roll:"setRoll",elevation:"setElevation",azimuth:"setAzimuth"}).forEach(([n,r])=>{const i=t[n];if(void 0!==i){const t=e(n,i);this.context.canvas.getCamera()[r](t)}})},this.bindEvents()}update(t){this.setOptions(t),super.update(t)}bindEvents(){this.context.graph.once(t.GraphEvent.BEFORE_DRAW,()=>this.setOptions(this.options))}getCanvasAspect(){const[t,e]=this.context.viewport.getCanvasSize();return t/e}},t.Canvas=GZ,t.Circle=Tw,t.CircleCombo=Yb,t.CircularLayout=QF,t.ClickSelect=nw,t.CollapseExpand=nE,t.ComboCombinedLayout=Yj,t.CompactBoxLayout=$E,t.ConcentricLayout=NF,t.Contextmenu=Kz,t.CreateEdge=cE,t.Cubic=BB,t.CubicHorizontal=EB,t.CubicRadial=xB,t.CubicVertical=CB,t.D3ForceLayout=Ok,t.DagreLayout=LK,t.DendrogramLayout=ix,t.Diamond=Iw,t.Donut=Lw,t.DragCanvas=lE,t.DragElement=uE,t.DragElementForce=EE,t.EdgeBundling=jz,t.EdgeFilterLens=Jz,t.Ellipse=Rw,t.FishboneLayout=Xj,t.Fisheye=eV,t.FixElementSize=xE,t.FocusElement=CE,t.ForceAtlas2Layout=nj,t.ForceLayout=qK,t.FruchtermanLayout=oj,t.Fullscreen=nV,t.Graph=vJ,t.GridLayout=sj,t.GridLine=rV,t.HTML=Gb,t.Hexagon=Hw,t.History=aV,t.HoverActivate=ME,t.Hull=GV,t.Icon=Qw,t.Image=Kb,t.IndentedLayout=lx,t.Label=yw,t.LassoSelect=FE,t.Legend=J$,t.Line=MB,t.MDSLayout=Uj,t.MapNodeSize=yJ,t.MindmapLayout=vx,t.Minimap=tZ,t.OptimizeViewportTransform=kE,t.PlaceRadialLabels=wJ,t.Polyline=PB,t.ProcessParallelEdges=BJ,t.Quadratic=DB,t.RadialLayout=Dj,t.RandomLayout=Kj,t.Rect=jb,t.RectCombo=Xb,t.ScrollCanvas=SE,t.Shortcut=Wy,t.SnakeLayout=Jj,t.Snapline=iZ,t.Star=zb,t.Timebar=aZ,t.Title=mZ,t.Toolbar=wZ,t.Tooltip=bZ,t.Triangle=Vb,t.Watermark=xZ,t.ZoomCanvas=QE,t.effect=function(t,e,n){IZ.has(t)||IZ.set(t,{});const r=IZ.get(t);if(!r[e])return r[e]=n,!0;const i=r[e];return!LZ(i,n)&&(r[e]=n,!0)},t.getExtension=Xv,t.getExtensions=function(t){return Yv[t]},t.iconfont={css:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.css",js:"//at.alicdn.com/t/a/font_470089_8hnbbf8n4u8.js"},t.idOf=Km,t.invokeLayoutMethod=bE,t.isCollapsed=rw,t.omitStyleProps=aw,t.parseSize=cw,t.positionOf=My,t.register=PZ,t.setVisibility=ey,t.subStyleProps=Aw,t.treeToGraphData=function(t,e){const{getNodeData:n=(t,e)=>{if(t.depth=e,!t.children)return t;const{children:n}=t,r=Pe(t,["children"]);return Object.assign(Object.assign({},r),{children:n.map(t=>t.id)})},getEdgeData:r=(t,e)=>({source:t.id,target:e.id}),getChildren:i=t=>t.children||[]}=e||{},o=[],A=[];return Zy(t,(t,e)=>{o.push(n(t,e));const s=i(t);for(const e of s)A.push(r(t,e))},t=>i(t),"TB"),{nodes:o,edges:A}},t.version=qv});
|