@antv/g6 5.0.47 → 5.0.48
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/README.md +8 -0
- package/README.zh-CN.md +6 -0
- package/dist/g6.min.js +5 -5
- package/dist/lib/behaviors/create-edge.d.ts +3 -3
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/create-edge.d.ts +3 -3
- package/esm/behaviors/create-edge.js +4 -2
- package/esm/behaviors/create-edge.js.map +1 -1
- package/esm/runtime/graph.js +7 -2
- package/esm/runtime/graph.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/create-edge.d.ts +3 -3
- package/lib/behaviors/create-edge.js +4 -2
- package/lib/behaviors/create-edge.js.map +1 -1
- package/lib/runtime/graph.js +7 -2
- package/lib/runtime/graph.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/behaviors/create-edge.ts +7 -5
- package/src/runtime/graph.ts +7 -1
- package/src/version.ts +1 -1
package/dist/g6.min.js
CHANGED
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
/*!
|
|
19
19
|
* @antv/g-web-animations-api
|
|
20
20
|
* @description A simple implementation of Web Animations API.
|
|
21
|
-
* @version 2.1.
|
|
22
|
-
* @date 5/
|
|
21
|
+
* @version 2.1.25
|
|
22
|
+
* @date 5/23/2025, 7:01:32 AM
|
|
23
23
|
* @author AntVis
|
|
24
24
|
* @docs https://g.antv.antgroup.com/
|
|
25
25
|
*/
|
|
26
|
-
var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return y(e,t),u(e)}(Ts),pu=0,gu=function(){return u((function t(e,n){var r;s(this,t),this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=e,e.animation=this,this.timeline=n,this.id="".concat(pu++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(r=this.effect)||void 0===r?void 0:r.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}),[{key:"pending",get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending}},{key:"playState",get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"}},{key:"ready",get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise((function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}})),this.pending||this.resolveReadyPromise()),this.readyPromise}},{key:"finished",get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise((function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}})),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise}},{key:"currentTime",get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){if(t=Number(t),!isNaN(t)){var e;if(this.timeline.restart(),!this._paused&&null!==this._startTime)this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate;this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this))}}},{key:"startTime",get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}}},{key:"_isFinished",get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)}},{key:"totalDuration",get:function(){return this._totalDuration}},{key:"_needsTick",get:function(){return this.pending||"running"===this.playState||!this._finishedFlag}},{key:"updatePromises",value:function(){var t=this.oldPlayState,e=this.pending?"pending":this.playState;return this.readyPromise&&e!==t&&("idle"===e?(this.rejectReadyPromise(),this.readyPromise=void 0):"pending"===t?this.resolveReadyPromise():"pending"===e&&(this.readyPromise=void 0)),this.finishedPromise&&e!==t&&("idle"===e?(this.rejectFinishedPromise(),this.finishedPromise=void 0):"finished"===e?this.resolveFinishedPromise():"finished"===t&&(this.finishedPromise=void 0)),this.oldPlayState=e,this.readyPromise||this.finishedPromise}},{key:"play",value:function(){this.updatePromises(),this._paused=!1,(this._isFinished||this._idle)&&(this.rewind(),this._startTime=null),this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this),-1===this.timeline.animations.indexOf(this)&&this.timeline.animations.push(this),this.updatePromises()}},{key:"pause",value:function(){this.updatePromises(),this.currentTime&&(this._holdTime=this.currentTime),this._isFinished||this._paused||this._idle?this._idle&&(this.rewind(),this._idle=!1):this.currentTimePending=!0,this._startTime=null,this._paused=!0,this.updatePromises()}},{key:"finish",value:function(){this.updatePromises(),this._idle||(this.currentTime=this._playbackRate>0?this._totalDuration:0,this._startTime=this._totalDuration-this.currentTime,this.currentTimePending=!1,this.timeline.applyDirtiedAnimation(this),this.updatePromises())}},{key:"cancel",value:function(){var t=this;if(this.updatePromises(),this._inEffect&&(this._inEffect=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new fu(null,this,this.currentTime,null);setTimeout((function(){t.oncancel(e)}))}}},{key:"reverse",value:function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()}},{key:"updatePlaybackRate",value:function(t){this.playbackRate=t}},{key:"targetAnimations",value:function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()}},{key:"markTarget",value:function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)}},{key:"unmarkTarget",value:function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)}},{key:"tick",value:function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))}},{key:"rewind",value:function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}}},{key:"persist",value:function(){throw new Error(br)}},{key:"addEventListener",value:function(t,e,n){throw new Error(br)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(br)}},{key:"dispatchEvent",value:function(t){throw new Error(br)}},{key:"commitStyles",value:function(){throw new Error(br)}},{key:"ensureAlive",value:function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!(null===(t=this.effect)||void 0===t||!t.update(-1)):this._inEffect=!(null===(e=this.effect)||void 0===e||!e.update(this.currentTime));this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))}},{key:"tickCurrentTime",value:function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())}},{key:"fireEvents",value:function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new fu(null,this,this.currentTime,t);setTimeout((function(){e.onfinish&&e.onfinish(n)}))}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new fu(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),vu=.1,mu="function"==typeof Float32Array,yu=function(t,e){return 1-3*e+3*t},bu=function(t,e){return 3*e-6*t},xu=function(t){return 3*t},Eu=function(t,e,n){return((yu(e,n)*t+bu(e,n))*t+xu(e))*t},wu=function(t,e,n){return 3*yu(e,n)*t*t+2*bu(e,n)*t+xu(e)},ku=function(t,e,n,r){if(!(t>=0&&t<=1&&n>=0&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=mu?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Eu(o*vu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=vu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*vu,s=wu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=wu(e,n,r);if(0===o)return e;e-=(Eu(e,n,r)-t)/o}return e}(e,a,t,n):0===s?a:function(t,e,n,r,i){var o,a,s=0;do{(o=Eu(a=e+(n-e)/2,r,i)-t)>0?n=a:e=a}while(Math.abs(o)>1e-7&&++s<10);return a}(e,r,r+vu,t,n)};return function(t){return 0===t||1===t?t:Eu(a(t),e,r)}},Mu=function(t){return Math.pow(t,2)},Su=function(t){return Math.pow(t,3)},Nu=function(t){return Math.pow(t,4)},Ou=function(t){return Math.pow(t,5)},Tu=function(t){return Math.pow(t,6)},Cu=function(t){return 1-Math.cos(t*Math.PI/2)},Au=function(t){return 1-Math.sqrt(1-t*t)},Pu=function(t){return t*t*(3*t-2)},Ru=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},Du=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?1:n,i=e[1],o=void 0===i?.5:i,a=oe(Number(r),1,10),s=oe(Number(o),.1,2);return 0===t||1===t?t:-a*Math.pow(2,10*(t-1))*Math.sin((t-1-s/(2*Math.PI)*Math.asin(1/a))*(2*Math.PI)/s)},Lu=function(t){var e=arguments.length>2?arguments[2]:void 0,n=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),r=n[0],i=void 0===r?1:r,o=n[1],a=void 0===o?100:o,s=n[2],l=void 0===s?10:s,u=n[3],c=void 0===u?0:u;i=oe(i,.1,1e3),a=oe(a,.1,1e3),l=oe(l,.1,1e3),c=oe(c,.1,1e3);var h=Math.sqrt(a/i),d=l/(2*Math.sqrt(a*i)),f=d<1?h*Math.sqrt(1-d*d):0,p=d<1?(d*h-c)/f:-c+h,g=e?e*t/1e3:t;return g=d<1?Math.exp(-g*d*h)*(1*Math.cos(f*g)+p*Math.sin(f*g)):(1+p*g)*Math.exp(-g*h),0===t||1===t?t:1-g},_u=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?10:n;return("start"===e[1]?Math.ceil:Math.floor)(oe(t,0,1)*r)/r},Iu=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return ku(n,r,i,o)(t)},ju=ku(.42,0,1,1),Bu=function(t){return function(e){return 1-t(1-e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],arguments.length>2?arguments[2]:void 0)}},Fu=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},zu=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Gu={steps:_u,"step-start":function(t){return _u(t,[1,"start"])},"step-end":function(t){return _u(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Iu,ease:function(t){return Iu(t,[.25,.1,.25,1])},in:ju,out:Bu(ju),"in-out":Fu(ju),"out-in":zu(ju),"in-quad":Mu,"out-quad":Bu(Mu),"in-out-quad":Fu(Mu),"out-in-quad":zu(Mu),"in-cubic":Su,"out-cubic":Bu(Su),"in-out-cubic":Fu(Su),"out-in-cubic":zu(Su),"in-quart":Nu,"out-quart":Bu(Nu),"in-out-quart":Fu(Nu),"out-in-quart":zu(Nu),"in-quint":Ou,"out-quint":Bu(Ou),"in-out-quint":Fu(Ou),"out-in-quint":zu(Ou),"in-expo":Tu,"out-expo":Bu(Tu),"in-out-expo":Fu(Tu),"out-in-expo":zu(Tu),"in-sine":Cu,"out-sine":Bu(Cu),"in-out-sine":Fu(Cu),"out-in-sine":zu(Cu),"in-circ":Au,"out-circ":Bu(Au),"in-out-circ":Fu(Au),"out-in-circ":zu(Au),"in-back":Pu,"out-back":Bu(Pu),"in-out-back":Fu(Pu),"out-in-back":zu(Pu),"in-bounce":Ru,"out-bounce":Bu(Ru),"in-out-bounce":Fu(Ru),"out-in-bounce":zu(Ru),"in-elastic":Du,"out-elastic":Bu(Du),"in-out-elastic":Fu(Du),"out-in-elastic":zu(Du),spring:Lu,"spring-in":Lu,"spring-out":Bu(Lu),"spring-in-out":Fu(Lu),"spring-out-in":zu(Lu)},Vu=function(t){return t};function Wu(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Hu="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",Uu=new RegExp("cubic-bezier\\(".concat(Hu,",").concat(Hu,",").concat(Hu,",").concat(Hu,"\\)")),$u=/steps\(\s*(\d+)\s*\)/,Yu=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function qu(t){var e=Uu.exec(t);if(e)return ku.apply(void 0,d(e.slice(1).map(Number)));var n=$u.exec(t);if(n)return Wu(Number(n[1]),0);var r=Yu.exec(t);return r?Wu(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Gu[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,(function(t){return"-".concat(t.toLowerCase())}))).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||Gu.linear}function Xu(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}function Ku(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e<Math.min(n.delay,r)?1:e>=Math.min(n.delay+t+n.endDelay,r)?2:3}(t,e,n),i=function(t,e,n,r,i){switch(r){case 1:return"backwards"===e||"both"===e?0:null;case 3:return n-i;case 2:return"forwards"===e||"both"===e?t:null;case 0:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,a=function(t,e,n,r,i){var o=i;return 0===t?1!==e&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var a=t===1/0?e%1:t%1;return 0!==a||2!==n||0===r||0===i&&0!==o||(a=1),a}(a,n.iterationStart,r,n.iterations,i,o),l=function(t,e,n,r){return 2===t&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,a),u=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,l,s);return n.currentIteration=l,n.progress=u,n.easingFunction(u)}function Zu(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Qu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:qu(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var a=o,s=o+1,l=i[a].computedOffset,u=i[s].computedOffset,c=l,h=u;0===o&&(c=-1/0,0===u&&(s=a)),o===i.length-2&&(h=1/0,1===l&&(a=s)),n.push({applyFrom:c,applyTo:h,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:tc(r,i[a].value,i[s].value,e)})}return n.sort((function(t,e){return t.startOffset-e.startOffset})),n}(r,n);return function(t,e){if(null!==e)i.filter((function(t){return e>=t.applyFrom&&e<t.applyTo})).forEach((function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Qu(n)&&t.setAttribute(n,null)}}function Qu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Ju=function(t,e,n){return function(r){var i=ec(t,e,r);return ae(i)?i:n(i)}};function tc(t,e,n,r){var i=ga[t];if(i&&i.syntax&&i.int){var o=bl.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=o.parser,s=a?a(e,r):e,l=a?a(n,r):n,u=o.mixer(s,l,r);if(u){var c=Ju.apply(void 0,d(u));return function(t){return 0===t?e:1===t?n:c(t)}}}}return Ju(!1,!0,(function(t){return t?n:e}))}function ec(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),a=[],s=0;s<o;s++)a.push(ec(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments ".concat(t,":").concat(e))}var nc=function(){return u((function t(){s(this,t),this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Vu,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}),[{key:"easing",get:function(){return this._easing},set:function(t){this.easingFunction=qu(t),this._easing=t}}])}();function rc(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var a={};"offset"in t&&(a.offset=Number(t.offset)),"easing"in t&&(a.easing=t.easing),"composite"in t&&(a.composite=t.composite),e[o]=a}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort((function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)})),e}(t));for(var n=t.map((function(t){var n={};for(var r in null!=e&&e.composite&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n})),r=!0,i=-1/0,o=0;o<n.length;o++){var a=n[o].offset;if($t(a))r=!1;else{if(a<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=a}}return n=n.filter((function(t){return Number(t.offset)>=0&&Number(t.offset)<=1})),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),a=1;a<r;a++){var s=n[a].computedOffset;if(!$t(s)&&!$t(o)){for(var l=1;l<a-i;l++)n[i+l].computedOffset=o+(Number(s)-o)*l/(a-i);i=a,o=Number(s)}}}(),n}var ic="backwards|forwards|both|none".split("|"),oc="reverse|alternate|alternate-reverse".split("|");function ac(t,e){return function(t){var e=new nc;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(n){if(void 0!==t[n]&&null!==t[n]&&"auto"!==t[n]){if(("number"==typeof e[n]||"duration"===n)&&("number"!=typeof t[n]||isNaN(t[n])))return;if("fill"===n&&-1===ic.indexOf(t[n]))return;if("direction"===n&&-1===oc.indexOf(t[n]))return;e[n]=t[n]}})):e.duration=t,e}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}))}var sc=function(){return u((function t(e,n,r){var i=this;s(this,t),this.composite="replace",this.iterationComposite="replace",this.target=e,this.timing=ac(r),this.timing.effect=this,this.timing.activeDuration=Xu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=rc(n,this.timing),this.interpolations=Zu(this.normalizedKeyframes,this.timing,this.target);var o=bl.globalThis.Proxy;this.computedTiming=o?new o(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?i.animation&&i.animation.currentTime||null:"currentIteration"===e?i.animation&&"running"===i.animation.playState?t.currentIteration||0:null:"progress"===e?i.animation&&"running"===i.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}),[{key:"applyInterpolations",value:function(){this.interpolations(this.target,Number(this.timeFraction))}},{key:"update",value:function(t){return null!==t&&(this.timeFraction=Ku(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)}},{key:"getKeyframes",value:function(){return this.normalizedKeyframes}},{key:"setKeyframes",value:function(t){this.normalizedKeyframes=rc(t)}},{key:"getComputedTiming",value:function(){return this.computedTiming}},{key:"getTiming",value:function(){return this.timing}},{key:"updateTiming",value:function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))}}])}();function lc(t,e){return Number(t.id)-Number(e.id)}var uc=function(){return u((function t(e){var n=this;s(this,t),this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){n.currentTime=t,n.discardAnimations(),0===n.animations.length?n.timelineTicking=!1:n.requestAnimationFrame(n.webAnimationsNextTick)},this.processRafCallbacks=function(t){var e=n.rafCallbacks;n.rafCallbacks=[],t<Number(n.currentTime)&&(t=Number(n.currentTime)),n.animations.sort(lc),n.animations=n.tick(t,!0,n.animations)[0],e.forEach((function(e){e[1](t)})),n.applyPendingEffects()},this.document=e}),[{key:"getAnimations",value:function(){return this.discardAnimations(),this.animations.slice()}},{key:"isTicking",value:function(){return this.inTick}},{key:"play",value:function(t,e,n){var r=new sc(t,e,n),i=new gu(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i}},{key:"applyDirtiedAnimation",value:function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(lc),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach((function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)})),this.applyPendingEffects()}}},{key:"restart",value:function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame}},{key:"destroy",value:function(){this.document.defaultView.cancelAnimationFrame(this.frameId)}},{key:"applyPendingEffects",value:function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]}},{key:"updateAnimationsPromises",value:function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))}},{key:"discardAnimations",value:function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))}},{key:"restartWebAnimationsNextTick",value:function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))}},{key:"rAF",value:function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e}},{key:"requestAnimationFrame",value:function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))}},{key:"tick",value:function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],l=[],u=[];return n.forEach((function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(a.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?l.push(n):u.push(n)})),(r=this.pendingEffects).push.apply(r,a),(i=this.pendingEffects).push.apply(i,s),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[l,u]}}])}();bl.EasingFunction=qu,bl.AnimationTimeline=uc;const cc={duration:500},hc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var dc,fc,pc,gc,vc,mc,yc,bc,xc;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(dc||(dc={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(fc||(fc={})),t.CanvasEvent=void 0,function(t){t.CLICK="canvas:click",t.DBLCLICK="canvas:dblclick",t.POINTER_OVER="canvas:pointerover",t.POINTER_LEAVE="canvas:pointerleave",t.POINTER_ENTER="canvas:pointerenter",t.POINTER_MOVE="canvas:pointermove",t.POINTER_OUT="canvas:pointerout",t.POINTER_DOWN="canvas:pointerdown",t.POINTER_UP="canvas:pointerup",t.CONTEXT_MENU="canvas:contextmenu",t.DRAG_START="canvas:dragstart",t.DRAG="canvas:drag",t.DRAG_END="canvas:dragend",t.DRAG_ENTER="canvas:dragenter",t.DRAG_OVER="canvas:dragover",t.DRAG_LEAVE="canvas:dragleave",t.DROP="canvas:drop",t.WHEEL="canvas:wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.ComboEvent=void 0,(pc=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",pc.DBLCLICK="combo:dblclick",pc.POINTER_OVER="combo:pointerover",pc.POINTER_LEAVE="combo:pointerleave",pc.POINTER_ENTER="combo:pointerenter",pc.POINTER_MOVE="combo:pointermove",pc.POINTER_OUT="combo:pointerout",pc.POINTER_DOWN="combo:pointerdown",pc.POINTER_UP="combo:pointerup",pc.CONTEXT_MENU="combo:contextmenu",pc.DRAG_START="combo:dragstart",pc.DRAG="combo:drag",pc.DRAG_END="combo:dragend",pc.DRAG_ENTER="combo:dragenter",pc.DRAG_OVER="combo:dragover",pc.DRAG_LEAVE="combo:dragleave",pc.DROP="combo:drop",t.CommonEvent=void 0,(gc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",gc.DBLCLICK="dblclick",gc.POINTER_OVER="pointerover",gc.POINTER_LEAVE="pointerleave",gc.POINTER_ENTER="pointerenter",gc.POINTER_MOVE="pointermove",gc.POINTER_OUT="pointerout",gc.POINTER_DOWN="pointerdown",gc.POINTER_UP="pointerup",gc.CONTEXT_MENU="contextmenu",gc.DRAG_START="dragstart",gc.DRAG="drag",gc.DRAG_END="dragend",gc.DRAG_ENTER="dragenter",gc.DRAG_OVER="dragover",gc.DRAG_LEAVE="dragleave",gc.DROP="drop",gc.KEY_DOWN="keydown",gc.KEY_UP="keyup",gc.WHEEL="wheel",gc.PINCH="pinch",t.ContainerEvent=void 0,(vc=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",vc.KEY_UP="keyup",t.EdgeEvent=void 0,(mc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",mc.DBLCLICK="edge:dblclick",mc.POINTER_OVER="edge:pointerover",mc.POINTER_LEAVE="edge:pointerleave",mc.POINTER_ENTER="edge:pointerenter",mc.POINTER_MOVE="edge:pointermove",mc.POINTER_OUT="edge:pointerout",mc.POINTER_DOWN="edge:pointerdown",mc.POINTER_UP="edge:pointerup",mc.CONTEXT_MENU="edge:contextmenu",mc.DRAG_ENTER="edge:dragenter",mc.DRAG_OVER="edge:dragover",mc.DRAG_LEAVE="edge:dragleave",mc.DROP="edge:drop",t.GraphEvent=void 0,(yc=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",yc.AFTER_CANVAS_INIT="aftercanvasinit",yc.BEFORE_SIZE_CHANGE="beforesizechange",yc.AFTER_SIZE_CHANGE="aftersizechange",yc.BEFORE_ELEMENT_CREATE="beforeelementcreate",yc.AFTER_ELEMENT_CREATE="afterelementcreate",yc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",yc.AFTER_ELEMENT_UPDATE="afterelementupdate",yc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",yc.AFTER_ELEMENT_DESTROY="afterelementdestroy",yc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",yc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",yc.BEFORE_DRAW="beforedraw",yc.AFTER_DRAW="afterdraw",yc.BEFORE_RENDER="beforerender",yc.AFTER_RENDER="afterrender",yc.BEFORE_ANIMATE="beforeanimate",yc.AFTER_ANIMATE="afteranimate",yc.BEFORE_LAYOUT="beforelayout",yc.AFTER_LAYOUT="afterlayout",yc.BEFORE_STAGE_LAYOUT="beforestagelayout",yc.AFTER_STAGE_LAYOUT="afterstagelayout",yc.BEFORE_TRANSFORM="beforetransform",yc.AFTER_TRANSFORM="aftertransform",yc.BATCH_START="batchstart",yc.BATCH_END="batchend",yc.BEFORE_DESTROY="beforedestroy",yc.AFTER_DESTROY="afterdestroy",yc.BEFORE_RENDERER_CHANGE="beforerendererchange",yc.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(bc=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",bc.REDO="redo",bc.CANCEL="cancel",bc.ADD="add",bc.CLEAR="clear",bc.CHANGE="change",t.NodeEvent=void 0,(xc=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",xc.DBLCLICK="node:dblclick",xc.POINTER_OVER="node:pointerover",xc.POINTER_LEAVE="node:pointerleave",xc.POINTER_ENTER="node:pointerenter",xc.POINTER_MOVE="node:pointermove",xc.POINTER_OUT="node:pointerout",xc.POINTER_DOWN="node:pointerdown",xc.POINTER_UP="node:pointerup",xc.CONTEXT_MENU="node:contextmenu",xc.DRAG_START="node:dragstart",xc.DRAG="node:drag",xc.DRAG_END="node:dragend",xc.DRAG_ENTER="node:dragenter",xc.DRAG_OVER="node:dragover",xc.DRAG_LEAVE="node:dragleave",xc.DROP="node:drop";const Ec="combo",wc="tree";var kc;t.ExtensionCategory=void 0,(kc=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",kc.EDGE="edge",kc.COMBO="combo",kc.THEME="theme",kc.PALETTE="palette",kc.LAYOUT="layout",kc.BEHAVIOR="behavior",kc.PLUGIN="plugin",kc.ANIMATION="animation",kc.TRANSFORM="transform",kc.SHAPE="shape";const Mc={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Sc(t,e){var n;const r=null===(n=Mc[t])||void 0===n?void 0:n[e];if(r)return r}const Nc="5.0.47";function Oc(t){return`[G6 v${Nc}] ${t}`}const Tc=t=>{console.warn(Oc(t))};function Cc(e){const{theme:n}=e;if(!n)return{};const r=Sc(t.ExtensionCategory.THEME,n);return r||(Tc(`The theme of ${n} is not registered.`),{})}function Ac(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map((t=>t.finished))]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach((t=>{var r;return null===(r=t[e])||void 0===r?void 0:r.call(t,...n)}))},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach((t=>{t[e]=n})),Reflect.set(t,e,n))})}function Pc(t){const e=t.reduce(((t,e)=>(Object.entries(e).forEach((([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)})),t)),{});Object.entries(e).forEach((([n,r])=>{(r.length!==t.length||r.some((t=>$t(t)))||r.every((t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&Ne(t,r[0]))))&&delete e[n]}));const n=Object.entries(e).reduce(((t,[e,n])=>(n.forEach(((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}})),t)),[]);return 0!==t.length&&0===n.length&&n.push({_:0},{_:0}),n}function Rc(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function Dc(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},cc);return qt(n)&&Object.assign(r,n),qt(e)&&Object.assign(r,e),r}function Lc(e,n,r,i){var o,a;const{animation:s}=e;if(!1===s||!1===i)return[];const l=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===l)return[];const u=null==l?void 0:l[r];if(!1===u)return[];const c=null===(a=Cc(e)[n])||void 0===a?void 0:a.animation,h=(e=[])=>function(e){if("string"==typeof e){return Sc(t.ExtensionCategory.ANIMATION,e)||(Tc(`The animation of ${e} is not registered.`),[])}return e}(e).map((t=>Object.assign(Object.assign(Object.assign(Object.assign({},hc),qt(s)&&s),t),qt(i)&&i)));if(u)return h(u);if(!c)return[];const d=c[r];return!1===d?[]:h(d)}function _c(t,e,n,r=[]){if(!r&&0===t&&0===e&&0===n)return null;if(Array.isArray(r)){let i=-1;const o=[];for(let a=0;a<r.length;a++){const s=r[a];if("translate"===s[0]){if(s[1]===t&&s[2]===e)return null;i=a,o.push(["translate",t,e])}else if("translate3d"===s[0]){if(s[1]===t&&s[2]===e&&s[3]===n)return null;i=a,o.push(["translate3d",t,e,null!=n?n:0])}else o.push(s)}return-1===i&&o.splice(0,0,ae(n)?["translate3d",t,e,null!=n?n:0]:["translate",t,e]),0===o.length?null:o}const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Ic=(t,e,n)=>{if(!n.length)return null;const[r,i]=e;let o;const a=n.map((e=>{var{fields:n,shape:a,states:s}=e,l=Fe(e,["fields","shape","states"]);const u=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const a=`get${de(e)}Style`,s=(null===(n=null==t?void 0:t[a])||void 0===n?void 0:n.bind(t))||(t=>t);return{shape:o,fromStyle:(null==s?void 0:s(r))||{},toStyle:(null==s?void 0:s(i))||{}}}return{shape:t,fromStyle:r,toStyle:i}})(a);if(!u)return null;const{shape:c,fromStyle:h,toStyle:d}=u,f=[{},{}];if(n.forEach((t=>{var e,n;Object.assign(f[0],{[t]:null!==(e=h[t])&&void 0!==e?e:Rc(t)}),Object.assign(f[1],{[t]:null!==(n=d[t])&&void 0!==n?n:Rc(t)})})),f.some((t=>Object.keys(t).some((t=>["x","y","z"].includes(t)))))){const{x:t=0,y:e=0,z:n,transform:r=""}=c.attributes||{};f.forEach((i=>{var o,a,s;i.transform=_c(null!==(o=i.x)&&void 0!==o?o:t,null!==(a=i.y)&&void 0!==a?a:e,null!==(s=i.z)&&void 0!==s?s:n,r)}))}const p=c.animate(Pc(f),l);return void 0===a&&(o=p),p})).filter(Boolean),s=o||(null==a?void 0:a[0]);return s?Ac(s,a.filter((t=>t!=t))):null},jc=[{fields:["x","y"]}],Bc=jc,Fc=[{fields:["sourceNode","targetNode"]}],zc=Fc,Gc=[{fields:["childrenNode","x","y"]}],Vc=Gc;function Wc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function Hc(t,e,n){return t>=e&&t<=n}function Uc(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function $c(t=0){const e=Uc(t);return e[0]+e[2]}function Yc(t){return t.max[0]-t.min[0]}function qc(t){return t.max[1]-t.min[1]}function Xc(t){return[Yc(t),qc(t)]}function Kc(t,e){const n=Wc(t)?Zc(t):t.getShape("key").getBounds();return e?Qc(n,e):n}function Zc(t){const[e,n,r=0]=t,i=new fr;return i.setMinMax([e,n,r],[e,n,r]),i}function Qc(t,e){const[n,r,i,o]=Uc(e),[a,s,l]=t.min,[u,c,h]=t.max,d=new fr;return d.setMinMax([a-o,s-n,l],[u+r,c+i,h]),d}function Jc(t){if(0===t.length)return new fr;if(1===t.length)return t[0];const e=new fr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function th(t,e){return Hc(t[0],e.min[0],e.max[0])&&Hc(t[1],e.min[1],e.max[1])}function eh(t,e,n=!1){const{min:[r,i],max:[o,a]}=e,s=(t[1]===i||t[1]===a)&&(n||Hc(t[0],r,o)),l=(t[0]===r||t[0]===o)&&(n||Hc(t[1],i,a));return s||l}function nh(t,e){const{center:n}=e;return t[0]===n[0]&&t[1]===n[1]}function rh(t,e){const[n,r]=t,[i,o]=e.min,[a,s]=e.max,l=n-i,u=a-n,c=r-o,h=s-r,d=Math.min(l,u,c,h);return d===l?"left":d===u?"right":d===c?"top":d===h?"bottom":"left"}function ih(t,e){const n=me(t);if(th(t,e)){switch(rh(t,e)){case"left":n[0]=e.min[0];break;case"right":n[0]=e.max[0];break;case"top":n[1]=e.min[1];break;case"bottom":n[1]=e.max[1]}}else{const[r,i]=t,[o,a]=e.min,[s,l]=e.max;n[0]=Hc(r,o,s)?r:r<o?o:s,n[1]=Hc(i,a,l)?i:i<a?a:l}return n}var oh=function(t,e){return t===e},ah=function(){function t(t,e){void 0===e&&(e=null),this.value=t,this.next=e}return t.prototype.toString=function(t){return t?t(this.value):"".concat(this.value)},t}(),sh=function(){function t(t){void 0===t&&(t=oh),this.head=null,this.tail=null,this.compare=t}return t.prototype.prepend=function(t){var e=new ah(t,this.head);return this.head=e,this.tail||(this.tail=e),this},t.prototype.append=function(t){var e=new ah(t);return this.head?(this.tail.next=e,this.tail=e,this):(this.head=e,this.tail=e,this)},t.prototype.delete=function(t){if(!this.head)return null;for(var e=null;this.head&&this.compare(this.head.value,t);)e=this.head,this.head=this.head.next;var n=this.head;if(null!==n)for(;n.next;)this.compare(n.next.value,t)?(e=n.next,n.next=n.next.next):n=n.next;return this.compare(this.tail.value,t)&&(this.tail=n),e},t.prototype.find=function(t){var e=t.value,n=void 0===e?void 0:e,r=t.callback,i=void 0===r?void 0:r;if(!this.head)return null;for(var o=this.head;o;){if(i&&i(o.value))return o;if(void 0!==n&&this.compare(o.value,n))return o;o=o.next}return null},t.prototype.deleteTail=function(){var t=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,t;for(var e=this.head;e.next;)e.next.next?e=e.next:e.next=null;return this.tail=e,t},t.prototype.deleteHead=function(){if(!this.head)return null;var t=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),t},t.prototype.fromArray=function(t){var e=this;return t.forEach((function(t){return e.append(t)})),this},t.prototype.toArray=function(){for(var t=[],e=this.head;e;)t.push(e),e=e.next;return t},t.prototype.reverse=function(){for(var t=this.head,e=null,n=null;t;)n=t.next,t.next=e,e=t,t=n;this.tail=this.head,this.head=e},t.prototype.toString=function(t){return void 0===t&&(t=void 0),this.toArray().map((function(e){return e.toString(t)})).toString()},t}(),lh=function(t,e,n){void 0===e&&(e=[]);var r=e.filter((function(e){return e.source===t||e.target===t}));if("target"===n){return r.filter((function(e){return e.source===t})).map((function(t){return t.target}))}if("source"===n){return r.filter((function(e){return e.target===t})).map((function(t){return t.source}))}return r.map((function(e){return e.source===t?e.target:e.source}))},uh={}.toString,ch=function(t,e){return uh.call(t)==="[object "+e+"]"},hh=function(t){return ch(t,"Function")},dh=function(t){return Array.isArray?Array.isArray(t):ch(t,"Array")};var fh,ph=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return function(t,e){var n,r;if(t)if(dh(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var a in t)if(t.hasOwnProperty(a)&&!1===e(t[a],a))break}(t,(function(n,r){hh(t)&&"prototype"===r||e.push(n)})),e};!function(t,e){if(!hh(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};n.cache=new Map}((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return fh||(fh=document.createElement("canvas").getContext("2d")),fh.font=[o,a,i,n+"px",r].join(" "),fh.measureText(function(t){return ch(t,"String")}(t)?t:"").width}),(function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}([t],ph(e)).join("")}));function gh(t,e,n,r){if(t===e)return[t];if(r[e])return r[e];for(var i=[],o=0,a=n[e];o<a.length;o++){var s=gh(t,a[o],n,r);if(!s)return;for(var l=0,u=s;l<u.length;l++){var c=u[l];dh(c)?i.push(We(We([],c,!0),[e],!1)):i.push([c,e])}}return r[e]=i,r[e]}var vh,mh=function(t,e,n,r,i){var o=function(t,e,n,r){var i=t.nodes,o=void 0===i?[]:i,a=t.edges,s=void 0===a?[]:a,l={},u={},c={};o.forEach((function(t,n){var r=t.id;u[r]=1/0,r===e&&(u[r]=0)}));for(var h=o.length,d=function(t){var e=function(t,e,n){for(var r,i=1/0,o=0;o<e.length;o++){var a=e[o].id;!n[a]&&t[a]<=i&&(i=t[a],r=e[o])}return r}(u,o,l),i=e.id;if(l[i]=!0,u[i]===1/0)return"continue";var a=[];a=n?function(t,e){return e.filter((function(e){return e.source===t}))}(i,s):function(t,e){return e.filter((function(e){return e.source===t||e.target===t}))}(i,s),a.forEach((function(t){var n=t.target,o=t.source,a=n===i?o:n,s=r&&t[r]?t[r]:1;u[a]>u[e.id]+s?(u[a]=u[e.id]+s,c[a]=[e.id]):u[a]===u[e.id]+s&&c[a].push(e.id)}))},f=0;f<h;f++)d();c[e]=[e];var p={};for(var g in u)u[g]!==1/0&&gh(e,g,c,p);var v={};for(var g in p)v[g]=p[g][0];return{length:u,path:v,allPath:p}}(t,e,r,i),a=o.length,s=o.path,l=o.allPath;return{length:a[n],path:s[n],allPath:l[n]}};!function(t){t.EuclideanDistance="euclideanDistance"}(vh||(vh={}));function yh(t){if(void 0!==t.id)return t.id;if(void 0!==t.source&&void 0!==t.target)return`${t.source}-${t.target}`;throw new Error(Oc("The datum does not have available id."))}function bh(t){return t.combo}function xh(t,e){const n={nodes:(t.nodes||[]).map(yh),edges:(t.edges||[]).map(yh),combos:(t.combos||[]).map(yh)};return e?Object.values(n).flat():n}!function(){function t(t){void 0===t&&(t=10),this.linkedList=new sh,this.maxStep=t}Object.defineProperty(t.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),t.prototype.isEmpty=function(){return!this.linkedList.head},t.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},t.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},t.prototype.push=function(t){this.linkedList.prepend(t),this.length>this.maxStep&&this.linkedList.deleteTail()},t.prototype.pop=function(){var t=this.linkedList.deleteHead();return t?t.value:null},t.prototype.toArray=function(){return this.linkedList.toArray().map((function(t){return t.value}))},t.prototype.clear=function(){for(;!this.isEmpty();)this.pop()}}();const Eh=(t,e,n)=>{var r;switch(n.type){case"degree":{const i=new Map;return null===(r=t.nodes)||void 0===r||r.forEach((t=>{const r=e(yh(t),n.direction).length;i.set(yh(t),r)})),i}case"betweenness":return kh(t,n.directed,n.weightPropertyName);case"closeness":return Mh(t,n.directed,n.weightPropertyName);case"eigenvector":return Nh(t,n.directed);case"pagerank":return Sh(t,n.epsilon,n.linkProb);default:return wh(t)}},wh=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach((t=>{n.set(yh(t),0)})),n},kh=(t,e,n)=>{const r=wh(t),{nodes:i=[]}=t;return i.forEach((o=>{i.forEach((i=>{if(o!==i){const{allPath:a}=mh(t,yh(o),yh(i),e,n),s=a.length;a.flat().forEach((t=>{t!==yh(o)&&t!==yh(i)&&r.set(t,r.get(t)+1/s)}))}}))})),r},Mh=(t,e,n)=>{const r=new Map,{nodes:i=[]}=t;return i.forEach((o=>{const a=i.reduce(((r,i)=>{if(o!==i){const{length:a}=mh(t,yh(o),yh(i),e,n);r+=a}return r}),0);r.set(yh(o),1/a)})),r},Sh=(t,e,n)=>{var r;const i=new Map,o=function(t,e,n){"number"!=typeof e&&(e=1e-6),"number"!=typeof n&&(n=.85);for(var r,i=1,o=0,a=1e3,s=t.nodes,l=void 0===s?[]:s,u=t.edges,c=void 0===u?[]:u,h=l.length,d={},f={},p=0;p<h;++p)d[v=(E=l[p]).id]=1/h,f[v]=1/h;for(var g=function(t){var e={},n=t.nodes,r=void 0===n?[]:n,i=t.edges,o=void 0===i?[]:i;return r.forEach((function(t){e[t.id]={degree:0,inDegree:0,outDegree:0}})),o.forEach((function(t){e[t.source].degree++,e[t.source].outDegree++,e[t.target].degree++,e[t.target].inDegree++})),e}(t);a>0&&i>e;){for(o=0,p=0;p<h;++p){var v=(E=l[p]).id;if(r=0,0===g[E.id].inDegree)d[v]=0;else{for(var m=lh(v,c,"source"),y=0;y<m.length;++y){var b=m[y],x=g[b].outDegree;x>0&&(r+=f[b]/x)}d[v]=n*r,o+=d[v]}}for(o=(1-o)/h,i=0,p=0;p<h;++p){var E;r=d[v=(E=l[p]).id]+o,i+=Math.abs(r-f[v]),f[v]=r}a-=1}return f}(t,e,n);return null===(r=t.nodes)||void 0===r||r.forEach((t=>{i.set(yh(t),o[yh(t)])})),i},Nh=(t,e)=>{const{nodes:n=[]}=t,r=Oh(t,e),i=Th(r,n.length),o=new Map;return n.forEach(((t,e)=>{o.set(yh(t),i[e])})),o},Oh=(t,e)=>{const{nodes:n=[],edges:r=[]}=t,i=Array(n.length).fill(null).map((()=>Array(n.length).fill(0)));return r.forEach((({source:t,target:r})=>{const o=n.findIndex((e=>yh(e)===t)),a=n.findIndex((t=>yh(t)===r));e?i[o][a]=1:(i[o][a]=1,i[a][o]=1)})),i},Th=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let a=0;a<n&&o>r;a++){const n=Array(e).fill(0);for(let r=0;r<e;r++)for(let o=0;o<e;o++)n[r]+=t[r][o]*i[o];const r=Math.sqrt(n.reduce(((t,e)=>t+e*e),0));for(let t=0;t<e;t++)n[t]/=r;o=Math.sqrt(n.reduce(((t,e,n)=>t+(e-i[n])*e),0)),i=n}return i};function Ch(t,e,n,r=Ne){const i=new Map(t.map((t=>[n(t),t]))),o=new Map(e.map((t=>[n(t),t]))),a=new Set(i.keys()),s=new Set(o.keys()),l=[],u=[],c=[],h=[];return s.forEach((t=>{a.has(t)?r(i.get(t),o.get(t))?h.push(o.get(t)):u.push(o.get(t)):l.push(o.get(t))})),a.forEach((t=>{s.has(t)||c.push(i.get(t))})),{enter:l,exit:c,keep:h,update:u}}function Ah(t,e,n){t.forEach((t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)}))}class Ph{constructor(t){this.extensions=[],this.extensionMap={},this.context=t}setExtensions(t){const e=function(t,e,n){const r={},i=t=>(t in r||(r[t]=0),`${e}-${t}-${r[t]++}`);return n.map((e=>"string"==typeof e?{type:e,key:i(e)}:"function"==typeof e?e.call(t):e.key?e:Object.assign(Object.assign({},e),{key:i(e.type)})))}(this.context.graph,this.category,t),{enter:n,update:r,exit:i,keep:o}=Ch(this.extensions,e,(t=>t.key));this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=Sc(e,r);if(!i)return Tc(`The extension ${r} of ${e} is not registered.`);const o=new i(this.context,t);this.extensionMap[n]=o}createExtensions(t){t.forEach((t=>this.createExtension(t)))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach((t=>this.updateExtension(t)))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach((({key:t})=>this.destroyExtension(t)))}destroy(){Object.values(this.extensionMap).forEach((t=>t.destroy())),this.context={},this.extensions=[],this.extensionMap={}}}class Rh{constructor(t,e){this.events=[],this.destroyed=!1,this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class Dh extends Rh{}class Lh extends Dh{constructor(t,e){super(t,Object.assign({},Lh.defaultOptions,e)),this.isOverlapping=(t,e)=>e.some((e=>t.intersects(e))),this.occupiedBounds=[],this.detectLabelCollision=t=>{const e=this.context.viewport,n={show:[],hide:[]};return this.occupiedBounds=[],t.forEach((t=>{const r=t.getShape("label").getRenderBounds();e.isInViewport(r,!0)&&!this.isOverlapping(r,this.occupiedBounds)?(n.show.push(t),this.occupiedBounds.push(Qc(r,this.options.padding))):n.hide.push(t)})),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=Ch(t,e,(t=>t.id));null==n||n.forEach(this.hideLabel)},this.nodeCentralities=new Map,this.sortNodesByCentrality=(t,e)=>{const{model:n}=this.context,r=n.getData(),i=n.getRelatedEdgesData.bind(n);return t.map((t=>(this.nodeCentralities.has(t.id)||(this.nodeCentralities=Eh(r,i,e)),{node:t,centrality:this.nodeCentralities.get(t.id)}))).sort(((t,e)=>e.centrality-t.centrality)).map((t=>t.node))},this.sortLabelElementsInView=t=>{const{sort:e,sortNode:n,sortCombo:r,sortEdge:i}=this.options,{model:o}=this.context;if(Ut(e))return t.sort(((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id))));const{node:a=[],edge:s=[],combo:l=[]}=ie(t,(t=>t.type)),u=Ut(r)?l.sort(((t,e)=>r(...o.getComboData([t.id,e.id])))):l,c=Ut(n)?a.sort(((t,e)=>n(...o.getNodeData([t.id,e.id])))):this.sortNodesByCentrality(a,n),h=Ut(i)?s.sort(((t,e)=>i(...o.getEdgeData([t.id,e.id])))):s;return[...u,...c,...h]},this.labelElementsInView=[],this.isFirstRender=!0,this.onToggleVisibility=t=>{var e;if("zIndex"===(null===(e=t.data)||void 0===e?void 0:e.stage))return;if(!this.validate(t))return void(this.hiddenElements.size>0&&(this.hiddenElements.forEach(this.showLabel),this.hiddenElements.clear()));const n=this.isFirstRender?this.getLabelElements():this.getLabelElementsInView();this.hideLabelIfExceedViewport(this.labelElementsInView,n),this.labelElementsInView=n;const r=this.sortLabelElementsInView(this.labelElementsInView),{show:i,hide:o}=this.detectLabelCollision(r);for(let t=i.length-1;t>=0;t--)this.showLabel(i[t]);o.forEach(this.hideLabel)},this.hiddenElements=new Map,this.hideLabel=t=>{const e=t.getShape("label");e&&Ah(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&Ah(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Re(this.onToggleVisibility,this.options.throttle,{leading:!0}),this.enableToggle=!0,this.toggle=t=>{this.enableToggle&&this.onToggleVisibility(t)},this.onBeforeRender=()=>{this.enableToggle=!1},this.onAfterRender=t=>{this.onToggleVisibility(t),this.enableToggle=!0},this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents(),this.onToggleVisibility({})}getLabelElements(){const{elementMap:t}=this.context.element,e=[];for(const n in t){const r=t[n];r.isVisible()&&r.getShape("label")&&e.push(r)}return e}getLabelElementsInView(){const t=this.context.viewport;return this.getLabelElements().filter((e=>t.isInViewport(e.getShape("key").getRenderBounds())))}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.on(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.on(t.GraphEvent.AFTER_DRAW,this.toggle),e.on(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.off(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.off(t.GraphEvent.AFTER_DRAW,this.toggle),e.off(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Lh.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const _h=[0,0,0];function Ih(t,e){return t.map(((t,n)=>t+e[n]))}function jh(t,e){return t.map(((t,n)=>t-e[n]))}function Bh(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Fh(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function zh(t,e){return t.map((t=>t*e))}function Gh(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+Math.pow(n-e[r]||0,2)),0))}function Vh(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function Wh(t){const e=t.reduce(((t,e)=>t+Math.pow(e,2)),0);return t.map((t=>t/Math.sqrt(e)))}function Hh(t,e,n=!1){const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(Bh(t,e).reduce(((t,e)=>t+e),0)/(Gh(t,_h)*Gh(e,_h)));return n&&r<0&&(i=2*Math.PI-i),i}function Uh(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function $h(t,e){return t.map((t=>t%e))}function Yh(t){return[t[0],t[1]]}function qh(t){return 2===t.length?[t[0],t[1],0]:t}function Xh(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function Kh(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=qh(t),r=qh(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(jh(n,r),jh(i,o)).every((t=>0===t))}function Zh(t,e,n=!1){if(Kh(t,e))return;const[r,i]=t,[o,a]=e,s=((r[0]-o[0])*(o[1]-a[1])-(r[1]-o[1])*(o[0]-a[0]))/((r[0]-i[0])*(o[1]-a[1])-(r[1]-i[1])*(o[0]-a[0])),l=a[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(a[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(a[1]-o[1]);return n||Hc(s,0,1)&&Hc(l,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Qh(t){if(Array.isArray(t))return Hc(t[0],0,1)&&Hc(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}function Jh(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function td(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function ed(t,e="center"){return function(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}(t,Qh(e))}function nd(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function rd(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function id(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function od(t,e,n,r=!1){if(Ne(t,e))return t;const i=Wh(r?jh(t,e):jh(e,t)),o=[i[0]*n,i[1]*n];return Ih(Yh(t),o)}function ad(t,e){return t[1]===e[1]}function sd(t,e,n){return Kh([t,e],[e,n])}function ld(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function ud(t,e,n,r=!0,i=!1){for(let o=0;o<n.length;o++){let a=n[o],s=n[(o+1)%n.length];r&&(a=Ih(e,a),s=Ih(e,s));const l=Zh([e,i?ld(t,e):t],[a,s]);if(l)return{point:l,line:[a,s]}}return{point:e,line:void 0}}function cd(t,e,n=!1){const r=e.center,i=jh(n?ld(t,r):t,e.center),o=Math.atan2(i[1],i[0]);if(isNaN(o))return r;const a=Yc(e)/2,s=qc(e)/2;return[r[0]+a*Math.cos(o),r[1]+s*Math.sin(o)]}function hd(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach((e=>{const i=function(t,e){const n=dd(t,e);return Gh(t,n)}(t,e);i<n&&(n=i,r=e)})),r}function dd(t,e){const[n,r]=e[0],[i,o]=e[1],[a,s]=t,l=i-n,u=o-r;if(0===l&&0===u)return[n,r];let c=((a-n)*l+(s-r)*u)/(l*l+u*u);c>1?c=1:c<0&&(c=0);return[n+c*l,r+c*u]}function fd(t,e=!0){const n=function(t){return Fh(t.reduce(((t,e)=>Ih(t,e)),[0,0]),t.length)}(t);return t.sort((([t,r],[i,o])=>{const a=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-a:a-s}))}function pd(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}class gd{constructor(t,e,n){if(this.phase=e,this.pointerByTouch=[],this.initialDistance=null,this.emitter=t,gd.instance)return gd.callbacks[this.phase].push(n),gd.instance;this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.bindEvents(),gd.instance=this,gd.callbacks[this.phase].push(n)}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp)}updatePointerPosition(t,e,n){const r=this.pointerByTouch.findIndex((e=>e.pointerId===t));r>=0&&(this.pointerByTouch[r]={x:e,y:n,pointerId:t})}onPointerDown(t){const{x:e,y:n}=t.client||{};if(void 0!==e&&void 0!==n&&(this.pointerByTouch.push({x:e,y:n,pointerId:t.pointerId}),"touch"===t.pointerType&&2===this.pointerByTouch.length)){gd.isPinching=!0;const e=this.pointerByTouch[0].x-this.pointerByTouch[1].x,n=this.pointerByTouch[0].y-this.pointerByTouch[1].y;this.initialDistance=Math.sqrt(e*e+n*n),gd.callbacks.pinchstart.forEach((e=>e(t,{scale:0})))}}onPointerMove(t){if(2!==this.pointerByTouch.length||null===this.initialDistance)return;const{x:e,y:n}=t.client||{};if(void 0===e||void 0===n)return;this.updatePointerPosition(t.pointerId,e,n);const r=this.pointerByTouch[0].x-this.pointerByTouch[1].x,i=this.pointerByTouch[0].y-this.pointerByTouch[1].y,o=Math.sqrt(r*r+i*i)/this.initialDistance;gd.callbacks.pinchmove.forEach((e=>e(t,{scale:5*(o-1)})))}onPointerUp(t){var e;gd.callbacks.pinchend.forEach((e=>e(t,{scale:0}))),gd.isPinching=!1,this.initialDistance=null,this.pointerByTouch=[],null===(e=gd.instance)||void 0===e||e.tryDestroy()}destroy(){this.emitter.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),this.emitter.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),this.emitter.off(t.CommonEvent.POINTER_UP,this.onPointerUp),gd.instance=null}off(t,e){const n=gd.callbacks[t].indexOf(e);n>-1&&gd.callbacks[t].splice(n,1),this.tryDestroy()}tryDestroy(){Object.values(gd.callbacks).every((t=>0===t.length))&&this.destroy()}}gd.isPinching=!1,gd.instance=null,gd.callbacks={pinchstart:[],pinchmove:[],pinchend:[]};const vd=t=>t.map((t=>ne(t)?t.toLocaleLowerCase():t));class md{constructor(e){this.map=new Map,this.boundHandlePinch=()=>{},this.recordKey=new Set,this.onKeyDown=t=>{(null==t?void 0:t.key)&&(this.recordKey.add(t.key),this.trigger(t))},this.onKeyUp=t=>{(null==t?void 0:t.key)&&this.recordKey.delete(t.key)},this.onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)},this.onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)},this.handlePinch=(e,n)=>{this.triggerExtendKey(t.CommonEvent.PINCH,Object.assign(Object.assign({},e),n))},this.onFocus=()=>{this.recordKey.clear()},this.emitter=e,this.bindEvents()}bind(e,n){0!==e.length&&(e.includes(t.CommonEvent.PINCH)&&!this.pinchHandler&&(this.boundHandlePinch=this.handlePinch.bind(this),this.pinchHandler=new gd(this.emitter,"pinchmove",this.boundHandlePinch)),this.map.set(e,n))}unbind(t,e){this.map.forEach(((n,r)=>{Ne(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}match(t){const e=vd(Array.from(this.recordKey)).sort(),n=vd(t).sort();return Ne(e,n)}bindEvents(){var e;const{emitter:n}=this;n.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),n.on(t.CommonEvent.KEY_UP,this.onKeyUp),n.on(t.CommonEvent.WHEEL,this.onWheel),n.on(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"focus",this.onFocus)}trigger(t){this.map.forEach(((e,n)=>{this.match(n)&&e(t)}))}triggerExtendKey(t,e){this.map.forEach(((n,r)=>{r.includes(t)&&Ne(Array.from(this.recordKey),r.filter((e=>e!==t)))&&n(e)}))}destroy(){var e,n;this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag),null===(e=this.pinchHandler)||void 0===e||e.off("pinchmove",this.boundHandlePinch),null===(n=globalThis.removeEventListener)||void 0===n||n.call(globalThis,"blur",this.onFocus)}}class yd extends Dh{constructor(t,e){super(t,ke({},yd.defaultOptions,e)),this.shortcut=new md(t.graph),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.clearStates=this.clearStates.bind(this),this.bindEvents()}onPointerDown(t){if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{canvas:e,graph:n}=this.context,r=Object.assign({},this.options.style);this.options.style.lineWidth&&(r.lineWidth=+this.options.style.lineWidth/n.getZoom()),this.rectShape=new Xl({id:"g6-brush-select",style:r}),e.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]}onPointerMove(t){var e;if(!this.startPoint)return;const{immediately:n,mode:r}=this.options;this.endPoint=bd(t),null===(e=this.rectShape)||void 0===e||e.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),n&&"default"===r&&this.updateElementsStates(pd(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=bd(t),this.updateElementsStates(pd(this.startPoint,this.endPoint)),this.clearBrush()):this.clearBrush())}clearStates(){this.endPoint||this.clearElementsStates()}clearElementsStates(){const{graph:t}=this.context,e=Object.values(t.getData()).reduce(((t,e)=>Object.assign({},t,e.reduce(((t,e)=>{var n;const r=null===(n=e.states||[])||void 0===n?void 0:n.filter((t=>t!==this.options.state));return t[yh(e)]=r,t}),{}))),{});t.setElementState(e,this.options.animation)}updateElementsStates(t){const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,a=this.selector(e,t,n);let s={};switch(i){case"union":a.forEach((t=>{s[t]=[...e.getElementState(t),r]}));break;case"diff":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?n.filter((t=>t!==r)):[...n,r]}));break;case"intersect":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?[r]:[]}));break;default:a.forEach((t=>{s[t]=[r]}))}Ut(o)&&(s=o(s)),e.setElementState(s,this.options.animation)}selector(t,e,n){if(!n||0===n.length)return[];const r=[],i=t.getData();if(n.forEach((n=>{i[`${n}s`].forEach((n=>{const i=yh(n);"hidden"!==t.getElementVisibility(i)&&function(t,e,n,r){const i=t[0],o=t[1];let a=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);const s=r-n;for(let t=0,r=s-1;t<s;r=t++){const s=e[t+n][0],l=e[t+n][1],u=e[r+n][0],c=e[r+n][1];l>o!=c>o&&i<(u-s)*(o-l)/(c-l)+s&&(a=!a)}return a}(t.getElementPosition(i),e)&&r.push(i)}))})),n.includes("edge")){const t=i.edges;null==t||t.forEach((t=>{const{source:e,target:n}=t;r.includes(e)&&r.includes(n)&&r.push(yh(t))}))}return r}clearBrush(){var t;null===(t=this.rectShape)||void 0===t||t.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0}isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return this.shortcut.match(e.filter((t=>"drag"!==t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp),e.on(t.CanvasEvent.CLICK,this.clearStates)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.off(t.CommonEvent.POINTER_UP,this.onPointerUp),e.off(t.CanvasEvent.CLICK,this.clearStates)}update(t){this.unbindEvents(),this.options=ke(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}yd.defaultOptions={animation:!1,enable:!0,enableElements:["node","combo","edge"],immediately:!1,mode:"default",state:"selected",trigger:["shift"],style:{width:0,height:0,lineWidth:1,fill:"#1677FF",stroke:"#1677FF",fillOpacity:.1,zIndex:2,pointerEvents:"none"}};const bd=t=>[t.canvas.x,t.canvas.y],xd=.8,Ed=["node","edge","combo"];function wd(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)wd(t,e,n,r,i+1);"BT"===r&&e(t,i)}function kd(t,e,n,r,i="both"){if("combo"===e||"node"===e)return Md(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const a=Md(t,o.source,r-1,i),s=Md(t,o.target,r-1,i);return Array.from(new Set([...a,...s,n]))}function Md(t,e,n,r="both"){const i=new Set,o=new Set,a=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,((e,i)=>{i>n||(a.add(e),t.getRelatedEdgesData(e,r).forEach((t=>{const e=yh(t);!o.has(e)&&i<n&&(a.add(e),o.add(e))})))}),(e=>t.getRelatedEdgesData(e,r).map((t=>t.source===e?t.target:t.source)).filter((t=>!i.has(t)&&(i.add(t),!0))))),Array.from(a)}function Sd(t){return t.states||[]}class Nd extends Dh{constructor(t,e){super(t,Object.assign({},Nd.defaultOptions,e)),this.onClickSelect=t=>ze(this,void 0,void 0,(function*(){var e,n;this.validate(t)&&(yield this.updateState(t),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))})),this.onClickCanvas=t=>ze(this,void 0,void 0,(function*(){var e,n;this.validate(t)&&(yield this.clearState(),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))})),this.shortcut=new md(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.on(t.CanvasEvent.CLICK,this.onClickCanvas)}get isMultipleSelect(){const{multiple:t,trigger:e}=this.options;return t&&this.shortcut.match(e)}getNeighborIds(t){const{target:e,targetType:n}=t,{graph:r}=this.context,{degree:i}=this.options;return kd(r,n,e.id,"function"==typeof i?i(t):i).filter((t=>t!==e.id))}updateState(t){return ze(this,void 0,void 0,(function*(){const{state:e,unselectedState:n,neighborState:r,animation:i}=this.options;if(!e&&!r&&!n)return;const{target:o}=t,{graph:a}=this.context,s=Sd(a.getElementData(o.id)).includes(e)?"unselect":"select",l={},u=this.isMultipleSelect,c=[o.id],h=this.getNeighborIds(t);if(u)if(Object.assign(l,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach((t=>{const r=new Set(a.getElementState(t));r.add(e),r.delete(n),l[t]=Array.from(r)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{const i=l[t];i.includes(e)||i.includes(r)||i.includes(n)||l[t].push(n)}))}else{const t=l[o.id];l[o.id]=t.filter((t=>t!==e&&t!==r)),t.includes(n)||l[o.id].push(n),h.forEach((t=>{l[t]=l[t].filter((t=>t!==r)),l[t].includes(e)||l[t].push(n)}))}else if("select"===s){Object.assign(l,this.getClearStates(!!n));const t=(t,e)=>{t.forEach((t=>{l[t]||(l[t]=a.getElementState(t)),l[t].push(e)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{c.includes(t)||h.includes(t)||l[t].push(n)}))}else Object.assign(l,this.getClearStates());yield a.setElementState(l,i)}))}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach((t=>{i[yh(t)]=Sd(t)})),i}getClearStates(t=!1){const{graph:e}=this.context,{state:n,unselectedState:r,neighborState:i}=this.options,o=new Set([n,r,i]),{nodes:a,edges:s,combos:l}=e.getData(),u={};return[...a,...s,...l].forEach((e=>{const n=Sd(e),r=n.filter((t=>!o.has(t)));(t||r.length!==n.length)&&(u[yh(e)]=r)})),u}clearState(){return ze(this,void 0,void 0,(function*(){const{graph:t}=this.context;yield t.setElementState(this.getClearStates(),this.options.animation)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function Od(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function Td(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function Cd(t,e,n=!0){if(!e)return t;if(!Td(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=he(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Ad(t,e){const n=Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Td(n,e)&&Object.assign(t,{[Cd(n,e)]:r}),t)),{});if("opacity"in t){const r=function(t,e){return`${e}${de(t)}`}("opacity",e),i=t.opacity;if(r in t){const e=t[r];Object.assign(n,{opacity:i*e})}else Object.assign(n,{opacity:i})}return n}function Pd(t,e){const n=e.length;return Object.keys(t).reduce(((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r}),{})}function Rd(t,e){const n="string"==typeof e?[e]:e,r={};return Object.keys(t).forEach((e=>{n.find((t=>e.startsWith(t)))||(r[e]=t[e])})),r}function Dd(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function Ld(t,e){const{datum:n,graph:r}=e;return"function"==typeof t?t.call(r,n):Object.fromEntries(Object.entries(t).map((([t,e])=>"function"==typeof e?[t,e.call(r,n)]:[t,e])))}function _d(t,e){const n=(null==t?void 0:t.style)||{},r=(null==e?void 0:e.style)||{};for(const t in n)t in r||(r[t]=n[t]);return Object.assign({},t,e,{style:r})}function Id(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function jd(t){const e="string"==typeof t?Sc("palette",t):t;if("function"!=typeof e)return e}function Bd(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function Fd(t,e,n=1,r=!1){const i=r?n:1;return Bd((t.max[0]-t.min[0])*i,e)}Nd.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class zd extends _l{constructor(t){Vd(t.style),super(t),this.shapeMap={},this.animateMap={},this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}upsert(e,n,r,i,o){var a,s,l,u,c,h,d,f;const p=this.shapeMap[e];if(!1===r)return void(p&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,p),i.removeChild(p),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,p)));const g="string"==typeof n?Sc(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error(Oc(`Shape ${n} not found`));if(!p||p.destroyed||!(p instanceof g)){p&&(null===(l=null==o?void 0:o.beforeDestroy)||void 0===l||l.call(o,p),null==p||p.destroy(),null===(u=null==o?void 0:o.afterDestroy)||void 0===u||u.call(o,p)),null===(c=null==o?void 0:o.beforeCreate)||void 0===c||c.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(h=null==o?void 0:o.afterCreate)||void 0===h||h.call(o,t),t}return null===(d=null==o?void 0:o.beforeUpdate)||void 0===d||d.call(o,p),_g(p,r),null===(f=null==o?void 0:o.afterUpdate)||void 0===f||f.call(o,p),p}update(t={}){const e=Object.assign({},this.attributes,t);Vd(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:a,clipPath:s,component:l}=e,u=Fe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,u),r&&t.setAttribute("transform",r);ae(n)&&t.setAttribute("zIndex",n);i&&t.setAttribute("transformOrigin",i);o&&t.setAttribute("visibility",o);a&&t.setAttribute("cursor",a);s&&t.setAttribute("clipPath",s);l&&t.setAttribute("component",l)}(this,e),this.render(e,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){return function(t){const{x:e,y:n,z:r,class:i,className:o,transform:a,transformOrigin:s,zIndex:l,visibility:u}=t;return Fe(t,["x","y","z","class","className","transform","transformOrigin","zIndex","visibility"])}(t)}get compositeShapes(){return[["badges","badge-"],["ports","port-"]]}animate(t,e){if(0===t.length)return null;const n=[];if(void 0!==t[0].x||void 0!==t[0].y||void 0!==t[0].z){const{x:e=0,y:n=0,z:r=0}=this.attributes;t.forEach((t=>{const{x:i=e,y:o=n,z:a=r}=t;Object.assign(t,{transform:a?[["translate3d",i,o,a]]:[["translate",i,o]]})}))}const r=super.animate(t,e);if(r&&(Gd(this,r),n.push(r)),Array.isArray(t)&&t.length>0){const r=["transform","transformOrigin","x","y","z","zIndex"];if(Object.keys(t[0]).some((t=>!r.includes(t)))){Object.entries(this.shapeMap).forEach((([r,i])=>{const o=this[`get${de(r)}Style`];if(Ut(o)){const r=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)))),a=i.animate(Pc(r),e);a&&(Gd(i,a),n.push(a))}}));const r=(r,i)=>{if(!Se(r)){const o=this[`get${de(i)}Style`];if(Ut(o)){const i=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t))));Object.entries(i[0]).map((([t])=>{const o=i.map((e=>e[t])),a=r[t];if(a){const t=a.animate(Pc(o),e);t&&(Gd(a,t),n.push(t))}}))}}};this.compositeShapes.forEach((([t,e])=>{const n=Pd(this.shapeMap,e);r(n,t)}))}}return Ac(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;Ah(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function Gd(t,e){null==e||e.finished.then((()=>{const n=t.activeAnimations.findIndex((t=>t===e));n>-1&&t.activeAnimations.splice(n,1)}))}function Vd(t){if(!t)return{};if("x"in t||"y"in t||"z"in t){const{x:e=0,y:n=0,z:r,transform:i}=t,o=_c(e,n,r,i);o&&(t.transform=o)}return t}class Wd extends zd{constructor(t){super(_d({style:Wd.defaultStyleProps},t))}isTextStyle(t){return Td(t,"label")}isBackgroundStyle(t){return Td(t,"background")}getTextStyle(t){const e=this.getGraphicStyle(t),{padding:n}=e;return Rd(Fe(e,["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Ad(e,"background"),{min:[a,s],center:[l,u],halfExtents:[c,h]}=this.shapeMap.text.getGeometryBounds(),[d,f,p,g]=Uc(i),v=2*c+g+f,{width:m,height:y}=o;m&&y?Object.assign(o,{x:l-Number(m)/2,y:u-Number(y)/2}):Object.assign(o,{x:a-g,y:s-d,width:n?Math.min(v,r+g+f):v,height:2*h+d+p});const{radius:b}=o;if("string"==typeof b&&b.endsWith("%")){const t=Number(b.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Zl,this.getTextStyle(t),e),this.upsert("background",Xl,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}Wd.defaultStyleProps={padding:0,fontSize:12,fontFamily:"system-ui, sans-serif",wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};class Hd extends zd{constructor(t){super(_d({style:Hd.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",Wd,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}Hd.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const Ud={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function $d(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in Ud?r=t:e.unshift(t),i={type:r},Ud[r].forEach((n=>{t=e.shift(),i[n]=t})),"M"===r?r="L":"m"===r&&(r="l");const[o,...a]=Object.values(i);n.push([o,...a.map(Number)])}return n}(t):t;return n.forEach((t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])})),e}const Yd=t=>{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e<t.length-2;e+=1){const[n,r]=t[e-1],[i,a]=t[e],[s,l]=t[e+1],[u,c]=e!==t.length-2?t[e+2]:[s,l],h=i+(s-n)/6,d=a+(l-r)/6,f=s-(u-i)/6,p=l-(c-a)/6;o.push(["C",h,d,f,p,s,l])}return o};class qd extends zd{constructor(t){super(_d({style:qd.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{maxWidth:n,offsetX:r,offsetY:i,autoRotate:o,placement:a,closeToPath:s}=e,l=Fe(e,["maxWidth","offsetX","offsetY","autoRotate","placement","closeToPath"]),u=this.shapeMap.key,c=null==u?void 0:u.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,a){const[s,l]=ed(t,e),u={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:[["translate",s+n,l+r]]};if("center"===e||!i)return u;const c=$d(o);if(!c||c.length<=3)return u;const h=c.map(((t,e)=>{const n=t,r=c[(e+1)%c.length];return Ne(n,r)?null:[n,r]})).filter(Boolean),d=hd([s,l],h),f=dd([s,l],d);if(f&&d&&(u.transform=[["translate",f[0]+n,f[1]+r]],a)){const t=Math.atan((d[0][1]-d[1][1])/(d[0][0]-d[1][0]));u.transform.push(["rotate",t/Math.PI*180]),u.textAlign="center","right"!==e&&"left"!==e||(u.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return u}(c,a,r,i,s,t.d,o),{wordWrapWidth:Fd(c,n)},l)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",Hl,this.getKeyStyle(t),e),this.upsert("label",Wd,this.getLabelStyle(t),e)}}qd.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let Xd=class extends zl{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Zd=this,this.isMutationObserved=!0,this.addEventListener(Vs.MOUNTED,this.onMounted),this.addEventListener(Vs.ATTR_MODIFIED,this.onAttrModified)}handleRadius(){const{radius:t,clipPath:e,width:n=0,height:r=0}=this.attributes;if(t&&n&&r){const[i,o]=this.getBounds().min,a={x:i,y:o,radius:t,width:n,height:r};if(e)Object.assign(this.parsedStyle.clipPath.style,a);else{const t=new Xl({style:a});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const Kd=new WeakMap;let Zd=null;const Qd=t=>{if(Zd&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Zd).includes(t)){const e=Kd.get(t);e?e.includes(Zd)||e.push(Zd):Kd.set(t,[Zd])}},Jd=t=>{const e=Kd.get(t);e&&e.forEach((t=>t.handleRadius()))};class tf extends zd{constructor(t){super(t)}isImage(){const{src:t}=this.attributes;return!!t}getIconStyle(t=this.attributes){const{width:e=0,height:n=0}=t,r=this.getGraphicStyle(t);return this.isImage()?Object.assign({x:-e/2,y:-n/2},r):Object.assign({textBaseline:"middle",textAlign:"center"},r)}render(t=this.attributes,e=this){this.upsert("icon",this.isImage()?Xd:Zl,this.getIconStyle(t),e)}}class ef extends zd{get context(){return this.config.context}get parsedAttributes(){return this.attributes}onframe(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>this.onframe(),n.finished.then((()=>this.onframe()))),n}}class nf extends ef{constructor(t){super(_d({style:nf.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return Dd(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(Rd(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,a=Fe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(Lg(s,n,i,o),{wordWrapWidth:Fd(s,r)},a)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Fe(e,["fill"]),i=Ad(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign(Object.assign({},r),{stroke:n}),i)}getIconStyle(t){if(!1===t.icon||!t.iconText&&!t.iconSrc)return!1;const e=Ad(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=Dd(t);let r={};return e.text&&!e.fontSize&&(r={fontSize:.5*Math.min(...n)}),!e.src||e.width&&e.height||(r={width:.5*n[0],height:.5*n[1]}),r}(t.size,e),e)}getBadgesStyle(t){var e;const n=Pd(this.shapeMap,"badge-"),r={};if(Object.keys(n).forEach((t=>{r[t]=!1})),!1===t.badge||!(null===(e=t.badges)||void 0===e?void 0:e.length))return r;const{badges:i=[],badgePalette:o,opacity:a=1}=t,s=Fe(t,["badges","badgePalette","opacity"]),l=jd(o),u=Ad(this.getGraphicStyle(s),"badge");return i.forEach(((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:l?l[e%(null==l?void 0:l.length)]:void 0,opacity:a},u),this.getBadgeStyle(t))})),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Fe(t,["placement","offsetX","offsetY"]),a=Lg(e.getLocalBounds(),n,r,i,!0);return Object.assign(Object.assign({},a),o)}getPortsStyle(t){var e;const n=this.getPorts(),r={};if(Object.keys(n).forEach((t=>{r[t]=!1})),!1===t.port||!(null===(e=t.ports)||void 0===e?void 0:e.length))return r;const i=Ad(this.getGraphicStyle(t),"port"),{ports:o=[]}=t;return o.forEach(((e,n)=>{const o=e.key||n,a=Object.assign(Object.assign({},i),e);if(Tg(a))r[o]=!1;else{const[n,i]=this.getPortXY(t,e);r[o]=Object.assign({transform:[["translate",n,i]]},a)}})),r}getPortXY(t,e){const{placement:n="left"}=e,r=this.getShape("key");return Ng(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();Ah(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return Pd(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return ud(t,ed(e,"center"),[ed(e,"left-top"),ed(e,"right-top"),ed(e,"right-bottom"),ed(e,"left-bottom")],!1,n).point}(t,this.getShape("key").getBounds(),e)}drawHaloShape(t,e){const n=this.getHaloStyle(t),r=this.getShape("key");this.upsert("halo",r.constructor,n,e)}drawIconShape(t,e){const n=this.getIconStyle(t);this.upsert("icon",tf,n,e),Qd(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{const r=n[t];this.upsert(`badge-${t}`,Hd,r,e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{const r=n[t],i=`port-${t}`;this.upsert(i,Dl,r,e)}))}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Wd,n,e)}_drawKeyShape(t,e){return this.drawKeyShape(t,e)}render(t=this.parsedAttributes,e=this){this._drawKeyShape(t,e),this.getShape("key")&&(this.drawHaloShape(t,e),this.drawIconShape(t,e),this.drawBadgeShapes(t,e),this.drawLabelShape(t,e),this.drawPortShapes(t,e))}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Jd(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}nf.defaultStyleProps={x:0,y:0,size:32,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};let rf=class t extends nf{constructor(e){super(_d({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",Dl,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{r:Math.min(...this.getSize(t))/2})}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getShape("key").attributes,r=2*n*xd;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}};rf.defaultStyleProps={size:32};class of extends nf{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",$l,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{points:this.getPoints(t)})}getIntersectPoint(t,e=!1){var n,r;const{points:i}=this.getShape("key").attributes;return ud(t,[+((null===(n=this.attributes)||void 0===n?void 0:n.x)||0),+((null===(r=this.attributes)||void 0===r?void 0:r.y)||0)],i,!0,e).point}}class af extends of{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}}class sf extends rf{constructor(t){super(_d({style:sf.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...Dd(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return ne(t)?parseInt(t)/100*this.parseOuterR():t}drawDonutShape(t,e){const{donuts:n}=t;if(!(null==n?void 0:n.length))return;const r=n.map((t=>ae(t)?{value:t}:t)),i=Ad(this.getGraphicStyle(t),"donut"),o=jd(t.donutPalette);if(!o)return;const a=r.reduce(((t,e)=>{var n;return t+(null!==(n=e.value)&&void 0!==n?n:0)}),0),s=this.parseOuterR(),l=this.parseInnerR();let u=0;r.forEach(((t,n)=>{const{value:c=0,color:h=o[n%o.length]}=t,d=Fe(t,["value","color"]),f=360*(0===a?1/r.length:c/a);this.upsert(`round${n}`,Hl,Object.assign(Object.assign(Object.assign({},i),{d:uf(s,l,u,u+f),fill:h}),d),e),u+=f}))}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}sf.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const lf=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],uf=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[a,s]=[i/360*2*Math.PI,o/360*2*Math.PI],l=[lf(t,e,r,a),lf(t,e,n,a),lf(t,e,n,s),lf(t,e,r,s)],u=s-a>Math.PI?1:0;return[["M",l[0][0],l[0][1]],["L",l[1][0],l[1][1]],["A",n,n,0,u,1,l[2][0],l[2][1]],["L",l[3][0],l[3][1]],["A",r,r,0,u,0,l[0][0],l[0][1]],["Z"]]})(i,o,t,e,n,r)};class cf extends nf{constructor(t){super(_d({style:cf.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Il,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return Object.assign(Object.assign({},e),{rx:n/2,ry:r/2})}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getShape("key").attributes,i=2*Math.min(+n,+r)*xd;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}}cf.defaultStyleProps={size:[45,35]};class hf extends of{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*xd;return!!e&&Object.assign({width:n,height:n},e)}}
|
|
26
|
+
var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).currentTime=r,o.timelineTime=i,o.target=n,o.type="finish",o.bubbles=!1,o.currentTarget=n,o.defaultPrevented=!1,o.eventPhase=o.AT_TARGET,o.timeStamp=Date.now(),o.currentTime=r,o.timelineTime=i,o}return y(e,t),u(e)}(Ts),pu=0,gu=function(){return u((function t(e,n){var r;s(this,t),this.currentTimePending=!1,this._idle=!0,this._paused=!1,this._finishedFlag=!0,this._currentTime=0,this._playbackRate=1,this._inTimeline=!0,this.effect=e,e.animation=this,this.timeline=n,this.id="".concat(pu++),this._inEffect=!!this.effect.update(0),this._totalDuration=Number(null===(r=this.effect)||void 0===r?void 0:r.getComputedTiming().endTime),this._holdTime=0,this._paused=!1,this.oldPlayState="idle",this.updatePromises()}),[{key:"pending",get:function(){return null===this._startTime&&!this._paused&&0!==this.playbackRate||this.currentTimePending}},{key:"playState",get:function(){return this._idle?"idle":this._isFinished?"finished":this._paused?"paused":"running"}},{key:"ready",get:function(){var t=this;return this.readyPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.readyPromise=new Promise((function(e,n){t.resolveReadyPromise=function(){e(t)},t.rejectReadyPromise=function(){n(new Error)}})),this.pending||this.resolveReadyPromise()),this.readyPromise}},{key:"finished",get:function(){var t=this;return this.finishedPromise||(-1===this.timeline.animationsWithPromises.indexOf(this)&&this.timeline.animationsWithPromises.push(this),this.finishedPromise=new Promise((function(e,n){t.resolveFinishedPromise=function(){e(t)},t.rejectFinishedPromise=function(){n(new Error)}})),"finished"===this.playState&&this.resolveFinishedPromise()),this.finishedPromise}},{key:"currentTime",get:function(){return this.updatePromises(),this._idle||this.currentTimePending?null:this._currentTime},set:function(t){if(t=Number(t),!isNaN(t)){var e;if(this.timeline.restart(),!this._paused&&null!==this._startTime)this._startTime=Number(null===(e=this.timeline)||void 0===e?void 0:e.currentTime)-t/this.playbackRate;this.currentTimePending=!1,this._currentTime!==t&&(this._idle&&(this._idle=!1,this._paused=!0),this.tickCurrentTime(t,!0),this.timeline.applyDirtiedAnimation(this))}}},{key:"startTime",get:function(){return this._startTime},set:function(t){if(null!==t){if(this.updatePromises(),t=Number(t),isNaN(t))return;if(this._paused||this._idle)return;this._startTime=t,this.tickCurrentTime((Number(this.timeline.currentTime)-this._startTime)*this.playbackRate),this.timeline.applyDirtiedAnimation(this),this.updatePromises()}}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(t){if(t!==this._playbackRate){this.updatePromises();var e=this.currentTime;this._playbackRate=t,this.startTime=null,"paused"!==this.playState&&"idle"!==this.playState&&(this._finishedFlag=!1,this._idle=!1,this.ensureAlive(),this.timeline.applyDirtiedAnimation(this)),null!==e&&(this.currentTime=e),this.updatePromises()}}},{key:"_isFinished",get:function(){return!this._idle&&(this._playbackRate>0&&Number(this._currentTime)>=this._totalDuration||this._playbackRate<0&&Number(this._currentTime)<=0)}},{key:"totalDuration",get:function(){return this._totalDuration}},{key:"_needsTick",get:function(){return this.pending||"running"===this.playState||!this._finishedFlag}},{key:"updatePromises",value:function(){var t;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=0,this._startTime=null,this.effect.update(null),this.timeline.applyDirtiedAnimation(this),this.updatePromises(),this.oncancel)){var e=new fu(null,this,this.currentTime,null);setTimeout((function(){t.oncancel(e)}))}}},{key:"reverse",value:function(){this.updatePromises();var t=this.currentTime;this.playbackRate*=-1,this.play(),null!==t&&(this.currentTime=t),this.updatePromises()}},{key:"updatePlaybackRate",value:function(t){this.playbackRate=t}},{key:"targetAnimations",value:function(){var t;return(null===(t=this.effect)||void 0===t?void 0:t.target).getAnimations()}},{key:"markTarget",value:function(){var t=this.targetAnimations();-1===t.indexOf(this)&&t.push(this)}},{key:"unmarkTarget",value:function(){var t=this.targetAnimations(),e=t.indexOf(this);-1!==e&&t.splice(e,1)}},{key:"tick",value:function(t,e){this._idle||this._paused||(null===this._startTime?e&&(this.startTime=t-this._currentTime/this.playbackRate):this._isFinished||this.tickCurrentTime((t-this._startTime)*this.playbackRate)),e&&(this.currentTimePending=!1,this.fireEvents(t))}},{key:"rewind",value:function(){if(this.playbackRate>=0)this.currentTime=0;else{if(!(this._totalDuration<1/0))throw new Error("Unable to rewind negative playback rate animation with infinite duration");this.currentTime=this._totalDuration}}},{key:"persist",value:function(){throw new Error(br)}},{key:"addEventListener",value:function(t,e,n){throw new Error(br)}},{key:"removeEventListener",value:function(t,e,n){throw new Error(br)}},{key:"dispatchEvent",value:function(t){throw new Error(br)}},{key:"commitStyles",value:function(){throw new Error(br)}},{key:"ensureAlive",value:function(){var t,e;this.playbackRate<0&&0===this.currentTime?this._inEffect=!(null===(t=this.effect)||void 0===t||!t.update(-1)):this._inEffect=!(null===(e=this.effect)||void 0===e||!e.update(this.currentTime));this._inTimeline||!this._inEffect&&this._finishedFlag||(this._inTimeline=!0,this.timeline.animations.push(this))}},{key:"tickCurrentTime",value:function(t,e){t!==this._currentTime&&(this._currentTime=t,this._isFinished&&!e&&(this._currentTime=this._playbackRate>0?this._totalDuration:0),this.ensureAlive())}},{key:"fireEvents",value:function(t){var e=this;if(this._isFinished){if(!this._finishedFlag){if(this.onfinish){var n=new fu(null,this,this.currentTime,t);setTimeout((function(){e.onfinish&&e.onfinish(n)}))}this._finishedFlag=!0}}else{if(this.onframe&&"running"===this.playState){var r=new fu(null,this,this.currentTime,t);this.onframe(r)}this._finishedFlag=!1}}}])}(),vu=.1,mu="function"==typeof Float32Array,yu=function(t,e){return 1-3*e+3*t},bu=function(t,e){return 3*e-6*t},xu=function(t){return 3*t},Eu=function(t,e,n){return((yu(e,n)*t+bu(e,n))*t+xu(e))*t},wu=function(t,e,n){return 3*yu(e,n)*t*t+2*bu(e,n)*t+xu(e)},ku=function(t,e,n,r){if(!(t>=0&&t<=1&&n>=0&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&n===r)return function(t){return t};for(var i=mu?new Float32Array(11):new Array(11),o=0;o<11;++o)i[o]=Eu(o*vu,t,n);var a=function(e){for(var r=0,o=1;10!==o&&i[o]<=e;++o)r+=vu;--o;var a=r+(e-i[o])/(i[o+1]-i[o])*vu,s=wu(a,t,n);return s>=.001?function(t,e,n,r){for(var i=0;i<4;++i){var o=wu(e,n,r);if(0===o)return e;e-=(Eu(e,n,r)-t)/o}return e}(e,a,t,n):0===s?a:function(t,e,n,r,i){var o,a,s=0;do{(o=Eu(a=e+(n-e)/2,r,i)-t)>0?n=a:e=a}while(Math.abs(o)>1e-7&&++s<10);return a}(e,r,r+vu,t,n)};return function(t){return 0===t||1===t?t:Eu(a(t),e,r)}},Mu=function(t){return Math.pow(t,2)},Su=function(t){return Math.pow(t,3)},Nu=function(t){return Math.pow(t,4)},Ou=function(t){return Math.pow(t,5)},Tu=function(t){return Math.pow(t,6)},Cu=function(t){return 1-Math.cos(t*Math.PI/2)},Au=function(t){return 1-Math.sqrt(1-t*t)},Pu=function(t){return t*t*(3*t-2)},Ru=function(t){for(var e,n=4;t<((e=Math.pow(2,--n))-1)/11;);return 1/Math.pow(4,3-n)-7.5625*Math.pow((3*e-2)/22-t,2)},Du=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?1:n,i=e[1],o=void 0===i?.5:i,a=oe(Number(r),1,10),s=oe(Number(o),.1,2);return 0===t||1===t?t:-a*Math.pow(2,10*(t-1))*Math.sin((t-1-s/(2*Math.PI)*Math.asin(1/a))*(2*Math.PI)/s)},Lu=function(t){var e=arguments.length>2?arguments[2]:void 0,n=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),r=n[0],i=void 0===r?1:r,o=n[1],a=void 0===o?100:o,s=n[2],l=void 0===s?10:s,u=n[3],c=void 0===u?0:u;i=oe(i,.1,1e3),a=oe(a,.1,1e3),l=oe(l,.1,1e3),c=oe(c,.1,1e3);var h=Math.sqrt(a/i),d=l/(2*Math.sqrt(a*i)),f=d<1?h*Math.sqrt(1-d*d):0,p=d<1?(d*h-c)/f:-c+h,g=e?e*t/1e3:t;return g=d<1?Math.exp(-g*d*h)*(1*Math.cos(f*g)+p*Math.sin(f*g)):(1+p*g)*Math.exp(-g*h),0===t||1===t?t:1-g},_u=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],2),n=e[0],r=void 0===n?10:n;return("start"===e[1]?Math.ceil:Math.floor)(oe(t,0,1)*r)/r},Iu=function(t){var e=b(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],4),n=e[0],r=e[1],i=e[2],o=e[3];return ku(n,r,i,o)(t)},ju=ku(.42,0,1,1),Bu=function(t){return function(e){return 1-t(1-e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],arguments.length>2?arguments[2]:void 0)}},Fu=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?t(2*e,n,r)/2:1-t(-2*e+2,n,r)/2}},zu=function(t){return function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0;return e<.5?(1-t(1-2*e,n,r))/2:(t(2*e-1,n,r)+1)/2}},Gu={steps:_u,"step-start":function(t){return _u(t,[1,"start"])},"step-end":function(t){return _u(t,[1,"end"])},linear:function(t){return t},"cubic-bezier":Iu,ease:function(t){return Iu(t,[.25,.1,.25,1])},in:ju,out:Bu(ju),"in-out":Fu(ju),"out-in":zu(ju),"in-quad":Mu,"out-quad":Bu(Mu),"in-out-quad":Fu(Mu),"out-in-quad":zu(Mu),"in-cubic":Su,"out-cubic":Bu(Su),"in-out-cubic":Fu(Su),"out-in-cubic":zu(Su),"in-quart":Nu,"out-quart":Bu(Nu),"in-out-quart":Fu(Nu),"out-in-quart":zu(Nu),"in-quint":Ou,"out-quint":Bu(Ou),"in-out-quint":Fu(Ou),"out-in-quint":zu(Ou),"in-expo":Tu,"out-expo":Bu(Tu),"in-out-expo":Fu(Tu),"out-in-expo":zu(Tu),"in-sine":Cu,"out-sine":Bu(Cu),"in-out-sine":Fu(Cu),"out-in-sine":zu(Cu),"in-circ":Au,"out-circ":Bu(Au),"in-out-circ":Fu(Au),"out-in-circ":zu(Au),"in-back":Pu,"out-back":Bu(Pu),"in-out-back":Fu(Pu),"out-in-back":zu(Pu),"in-bounce":Ru,"out-bounce":Bu(Ru),"in-out-bounce":Fu(Ru),"out-in-bounce":zu(Ru),"in-elastic":Du,"out-elastic":Bu(Du),"in-out-elastic":Fu(Du),"out-in-elastic":zu(Du),spring:Lu,"spring-in":Lu,"spring-out":Bu(Lu),"spring-in-out":Fu(Lu),"spring-out-in":zu(Lu)},Vu=function(t){return t};function Wu(t,e){return function(n){if(n>=1)return 1;var r=1/t;return(n+=e*r)-n%r}}var Hu="\\s*(-?\\d+\\.?\\d*|-?\\.\\d+)\\s*",Uu=new RegExp("cubic-bezier\\(".concat(Hu,",").concat(Hu,",").concat(Hu,",").concat(Hu,"\\)")),$u=/steps\(\s*(\d+)\s*\)/,Yu=/steps\(\s*(\d+)\s*,\s*(start|middle|end)\s*\)/;function qu(t){var e=Uu.exec(t);if(e)return ku.apply(void 0,d(e.slice(1).map(Number)));var n=$u.exec(t);if(n)return Wu(Number(n[1]),0);var r=Yu.exec(t);return r?Wu(Number(r[1]),{start:1,middle:.5,end:0}[r[2]]):Gu[function(t){return function(t){return"-"===(t=t.replace(/([A-Z])/g,(function(t){return"-".concat(t.toLowerCase())}))).charAt(0)?t.substring(1):t}(t).replace(/^ease-/,"").replace(/(\(|\s).+/,"").toLowerCase().trim()}(t)]||Gu.linear}function Xu(t){return Math.abs(function(t){var e;if(0===t.duration||0===t.iterations)return 0;return("auto"===t.duration?0:Number(t.duration))*(null!==(e=t.iterations)&&void 0!==e?e:1)}(t)/(t.playbackRate||1))}function Ku(t,e,n){var r=function(t,e,n){if(null===e)return 0;var r=n.endTime;return e<Math.min(n.delay,r)?1:e>=Math.min(n.delay+t+n.endDelay,r)?2:3}(t,e,n),i=function(t,e,n,r,i){switch(r){case 1:return"backwards"===e||"both"===e?0:null;case 3:return n-i;case 2:return"forwards"===e||"both"===e?t:null;case 0:return null}}(t,n.fill,e,r,n.delay);if(null===i)return null;var o="auto"===n.duration?0:n.duration,a=function(t,e,n,r,i){var o=i;return 0===t?1!==e&&(o+=n):o+=r/t,o}(o,r,n.iterations,i,n.iterationStart),s=function(t,e,n,r,i,o){var a=t===1/0?e%1:t%1;return 0!==a||2!==n||0===r||0===i&&0!==o||(a=1),a}(a,n.iterationStart,r,n.iterations,i,o),l=function(t,e,n,r){return 2===t&&e===1/0?1/0:1===n?Math.floor(r)-1:Math.floor(r)}(r,n.iterations,s,a),u=function(t,e,n){var r=t;if("normal"!==t&&"reverse"!==t){var i=e;"alternate-reverse"===t&&(i+=1),r="normal",i!==1/0&&i%2!=0&&(r="reverse")}return"normal"===r?n:1-n}(n.direction,l,s);return n.currentIteration=l,n.progress=u,n.easingFunction(u)}function Zu(t,e,n){var r=function(t,e){for(var n={},r=0;r<t.length;r++)for(var i in t[r])if(Qu(i)){var o={offset:t[r].offset,computedOffset:t[r].computedOffset,easing:t[r].easing,easingFunction:qu(t[r].easing)||e.easingFunction,value:t[r][i]};n[i]=n[i]||[],n[i].push(o)}return n}(t,e),i=function(t,e){var n=[];for(var r in t)for(var i=t[r],o=0;o<i.length-1;o++){var a=o,s=o+1,l=i[a].computedOffset,u=i[s].computedOffset,c=l,h=u;0===o&&(c=-1/0,0===u&&(s=a)),o===i.length-2&&(h=1/0,1===l&&(a=s)),n.push({applyFrom:c,applyTo:h,startOffset:i[a].computedOffset,endOffset:i[s].computedOffset,easingFunction:i[a].easingFunction,property:r,interpolation:tc(r,i[a].value,i[s].value,e)})}return n.sort((function(t,e){return t.startOffset-e.startOffset})),n}(r,n);return function(t,e){if(null!==e)i.filter((function(t){return e>=t.applyFrom&&e<t.applyTo})).forEach((function(n){var r=e-n.startOffset,i=n.endOffset-n.startOffset,o=0===i?0:r/i;t.setAttribute(n.property,n.interpolation(o),!1,!1)}));else for(var n in r)Qu(n)&&t.setAttribute(n,null)}}function Qu(t){return"offset"!==t&&"easing"!==t&&"composite"!==t&&"computedOffset"!==t}var Ju=function(t,e,n){return function(r){var i=ec(t,e,r);return ae(i)?i:n(i)}};function tc(t,e,n,r){var i=ga[t];if(i&&i.syntax&&i.int){var o=bl.styleValueRegistry.getPropertySyntax(i.syntax);if(o){var a=o.parser,s=a?a(e,r):e,l=a?a(n,r):n,u=o.mixer(s,l,r);if(u){var c=Ju.apply(void 0,d(u));return function(t){return 0===t?e:1===t?n:c(t)}}}}return Ju(!1,!0,(function(t){return t?n:e}))}function ec(t,e,n){if("number"==typeof t&&"number"==typeof e)return t*(1-n)+e*n;if("boolean"==typeof t&&"boolean"==typeof e||"string"==typeof t&&"string"==typeof e)return n<.5?t:e;if(Array.isArray(t)&&Array.isArray(e)){for(var r=t.length,i=e.length,o=Math.max(r,i),a=[],s=0;s<o;s++)a.push(ec(t[s<r?s:r-1],e[s<i?s:i-1],n));return a}throw new Error("Mismatched interpolation arguments ".concat(t,":").concat(e))}var nc=function(){return u((function t(){s(this,t),this.delay=0,this.direction="normal",this.duration="auto",this._easing="linear",this.easingFunction=Vu,this.endDelay=0,this.fill="auto",this.iterationStart=0,this.iterations=1,this.currentIteration=null,this.progress=null}),[{key:"easing",get:function(){return this._easing},set:function(t){this.easingFunction=qu(t),this._easing=t}}])}();function rc(t,e){if(null===t)return[];Array.isArray(t)||(t=function(t){var e=[];for(var n in t)if(!(n in["easing","offset","composite"])){var r=t[n];Array.isArray(r)||(r=[r]);for(var i=r.length,o=0;o<i;o++){if(!e[o]){var a={};"offset"in t&&(a.offset=Number(t.offset)),"easing"in t&&(a.easing=t.easing),"composite"in t&&(a.composite=t.composite),e[o]=a}void 0!==r[o]&&null!==r[o]&&(e[o][n]=r[o])}}return e.sort((function(t,e){return(t.computedOffset||0)-(e.computedOffset||0)})),e}(t));for(var n=t.map((function(t){var n={};for(var r in null!=e&&e.composite&&(n.composite="auto"),t){var i=t[r];if("offset"===r){if(null!==i){if(i=Number(i),!isFinite(i))throw new Error("Keyframe offsets must be numbers.");if(i<0||i>1)throw new Error("Keyframe offsets must be between 0 and 1.");n.computedOffset=i}}else if("composite"===r&&-1===["replace","add","accumulate","auto"].indexOf(i))throw new Error("".concat(i," compositing is not supported"));n[r]=i}return void 0===n.offset&&(n.offset=null),void 0===n.easing&&(n.easing=(null==e?void 0:e.easing)||"linear"),void 0===n.composite&&(n.composite="auto"),n})),r=!0,i=-1/0,o=0;o<n.length;o++){var a=n[o].offset;if($t(a))r=!1;else{if(a<i)throw new TypeError("Keyframes are not loosely sorted by offset. Sort or specify offsets.");i=a}}return n=n.filter((function(t){return Number(t.offset)>=0&&Number(t.offset)<=1})),r||function(){var t,e,r=n.length;n[r-1].computedOffset=Number(null!==(t=n[r-1].offset)&&void 0!==t?t:1),r>1&&(n[0].computedOffset=Number(null!==(e=n[0].offset)&&void 0!==e?e:0));for(var i=0,o=Number(n[0].computedOffset),a=1;a<r;a++){var s=n[a].computedOffset;if(!$t(s)&&!$t(o)){for(var l=1;l<a-i;l++)n[i+l].computedOffset=o+(Number(s)-o)*l/(a-i);i=a,o=Number(s)}}}(),n}var ic="backwards|forwards|both|none".split("|"),oc="reverse|alternate|alternate-reverse".split("|");function ac(t,e){return function(t){var e=new nc;return"number"!=typeof t||isNaN(t)?void 0!==t&&Object.keys(t).forEach((function(n){if(void 0!==t[n]&&null!==t[n]&&"auto"!==t[n]){if(("number"==typeof e[n]||"duration"===n)&&("number"!=typeof t[n]||isNaN(t[n])))return;if("fill"===n&&-1===ic.indexOf(t[n]))return;if("direction"===n&&-1===oc.indexOf(t[n]))return;e[n]=t[n]}})):e.duration=t,e}(t=function(t){"number"==typeof t&&(t=isNaN(t)?{duration:"auto"}:{duration:t});return t}(null!=t?t:{duration:"auto"}))}var sc=function(){return u((function t(e,n,r){var i=this;s(this,t),this.composite="replace",this.iterationComposite="replace",this.target=e,this.timing=ac(r),this.timing.effect=this,this.timing.activeDuration=Xu(this.timing),this.timing.endTime=Math.max(0,this.timing.delay+this.timing.activeDuration+this.timing.endDelay),this.normalizedKeyframes=rc(n,this.timing),this.interpolations=Zu(this.normalizedKeyframes,this.timing,this.target);var o=bl.globalThis.Proxy;this.computedTiming=o?new o(this.timing,{get:function(t,e){return"duration"===e?"auto"===t.duration?0:t.duration:"fill"===e?"auto"===t.fill?"none":t.fill:"localTime"===e?i.animation&&i.animation.currentTime||null:"currentIteration"===e?i.animation&&"running"===i.animation.playState?t.currentIteration||0:null:"progress"===e?i.animation&&"running"===i.animation.playState?t.progress||0:null:t[e]},set:function(){return!0}}):this.timing}),[{key:"applyInterpolations",value:function(){this.interpolations(this.target,Number(this.timeFraction))}},{key:"update",value:function(t){return null!==t&&(this.timeFraction=Ku(this.timing.activeDuration,t,this.timing),null!==this.timeFraction)}},{key:"getKeyframes",value:function(){return this.normalizedKeyframes}},{key:"setKeyframes",value:function(t){this.normalizedKeyframes=rc(t)}},{key:"getComputedTiming",value:function(){return this.computedTiming}},{key:"getTiming",value:function(){return this.timing}},{key:"updateTiming",value:function(t){var e=this;Object.keys(t||{}).forEach((function(n){e.timing[n]=t[n]}))}}])}();function lc(t,e){return Number(t.id)-Number(e.id)}var uc=function(){return u((function t(e){var n=this;s(this,t),this.animations=[],this.ticking=!1,this.timelineTicking=!1,this.hasRestartedThisFrame=!1,this.animationsWithPromises=[],this.inTick=!1,this.pendingEffects=[],this.currentTime=null,this.rafId=0,this.rafCallbacks=[],this.webAnimationsNextTick=function(t){n.currentTime=t,n.discardAnimations(),0===n.animations.length?n.timelineTicking=!1:n.requestAnimationFrame(n.webAnimationsNextTick)},this.processRafCallbacks=function(t){var e=n.rafCallbacks;n.rafCallbacks=[],t<Number(n.currentTime)&&(t=Number(n.currentTime)),n.animations.sort(lc),n.animations=n.tick(t,!0,n.animations)[0],e.forEach((function(e){e[1](t)})),n.applyPendingEffects()},this.document=e}),[{key:"getAnimations",value:function(){return this.discardAnimations(),this.animations.slice()}},{key:"isTicking",value:function(){return this.inTick}},{key:"play",value:function(t,e,n){var r=new sc(t,e,n),i=new gu(r,this);return this.animations.push(i),this.restartWebAnimationsNextTick(),i.updatePromises(),i.play(),i.updatePromises(),i}},{key:"applyDirtiedAnimation",value:function(t){var e=this;if(!this.inTick){t.markTarget();var n=t.targetAnimations();n.sort(lc),this.tick(Number(this.currentTime),!1,n.slice())[1].forEach((function(t){var n=e.animations.indexOf(t);-1!==n&&e.animations.splice(n,1)})),this.applyPendingEffects()}}},{key:"restart",value:function(){return this.ticking||(this.ticking=!0,this.requestAnimationFrame((function(){})),this.hasRestartedThisFrame=!0),this.hasRestartedThisFrame}},{key:"destroy",value:function(){this.document.defaultView.cancelAnimationFrame(this.frameId)}},{key:"applyPendingEffects",value:function(){this.pendingEffects.forEach((function(t){null==t||t.applyInterpolations()})),this.pendingEffects=[]}},{key:"updateAnimationsPromises",value:function(){this.animationsWithPromises=this.animationsWithPromises.filter((function(t){return t.updatePromises()}))}},{key:"discardAnimations",value:function(){this.updateAnimationsPromises(),this.animations=this.animations.filter((function(t){return"finished"!==t.playState&&"idle"!==t.playState}))}},{key:"restartWebAnimationsNextTick",value:function(){this.timelineTicking||(this.timelineTicking=!0,this.requestAnimationFrame(this.webAnimationsNextTick))}},{key:"rAF",value:function(t){var e=this.rafId++;return 0===this.rafCallbacks.length&&(this.frameId=this.document.defaultView.requestAnimationFrame(this.processRafCallbacks)),this.rafCallbacks.push([e,t]),e}},{key:"requestAnimationFrame",value:function(t){var e=this;return this.rAF((function(n){e.updateAnimationsPromises(),t(n),e.updateAnimationsPromises()}))}},{key:"tick",value:function(t,e,n){var r,i,o=this;this.inTick=!0,this.hasRestartedThisFrame=!1,this.currentTime=t,this.ticking=!1;var a=[],s=[],l=[],u=[];return n.forEach((function(n){n.tick(t,e),n._inEffect?(s.push(n.effect),n.markTarget()):(a.push(n.effect),n.unmarkTarget()),n._needsTick&&(o.ticking=!0);var r=n._inEffect||n._needsTick;n._inTimeline=r,r?l.push(n):u.push(n)})),(r=this.pendingEffects).push.apply(r,a),(i=this.pendingEffects).push.apply(i,s),this.ticking&&this.requestAnimationFrame((function(){})),this.inTick=!1,[l,u]}}])}();bl.EasingFunction=qu,bl.AnimationTimeline=uc;const cc={duration:500},hc={duration:1e3,easing:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",iterations:1,fill:"both"};var dc,fc,pc,gc,vc,mc,yc,bc,xc;!function(t){t.NodeAdded="NodeAdded",t.NodeUpdated="NodeUpdated",t.NodeRemoved="NodeRemoved",t.EdgeAdded="EdgeAdded",t.EdgeUpdated="EdgeUpdated",t.EdgeRemoved="EdgeRemoved",t.ComboAdded="ComboAdded",t.ComboUpdated="ComboUpdated",t.ComboRemoved="ComboRemoved"}(dc||(dc={})),function(t){t.DRAW="draw",t.COLLAPSE="collapse",t.EXPAND="expand",t.TRANSFORM="transform"}(fc||(fc={})),t.CanvasEvent=void 0,function(t){t.CLICK="canvas:click",t.DBLCLICK="canvas:dblclick",t.POINTER_OVER="canvas:pointerover",t.POINTER_LEAVE="canvas:pointerleave",t.POINTER_ENTER="canvas:pointerenter",t.POINTER_MOVE="canvas:pointermove",t.POINTER_OUT="canvas:pointerout",t.POINTER_DOWN="canvas:pointerdown",t.POINTER_UP="canvas:pointerup",t.CONTEXT_MENU="canvas:contextmenu",t.DRAG_START="canvas:dragstart",t.DRAG="canvas:drag",t.DRAG_END="canvas:dragend",t.DRAG_ENTER="canvas:dragenter",t.DRAG_OVER="canvas:dragover",t.DRAG_LEAVE="canvas:dragleave",t.DROP="canvas:drop",t.WHEEL="canvas:wheel"}(t.CanvasEvent||(t.CanvasEvent={})),t.ComboEvent=void 0,(pc=t.ComboEvent||(t.ComboEvent={})).CLICK="combo:click",pc.DBLCLICK="combo:dblclick",pc.POINTER_OVER="combo:pointerover",pc.POINTER_LEAVE="combo:pointerleave",pc.POINTER_ENTER="combo:pointerenter",pc.POINTER_MOVE="combo:pointermove",pc.POINTER_OUT="combo:pointerout",pc.POINTER_DOWN="combo:pointerdown",pc.POINTER_UP="combo:pointerup",pc.CONTEXT_MENU="combo:contextmenu",pc.DRAG_START="combo:dragstart",pc.DRAG="combo:drag",pc.DRAG_END="combo:dragend",pc.DRAG_ENTER="combo:dragenter",pc.DRAG_OVER="combo:dragover",pc.DRAG_LEAVE="combo:dragleave",pc.DROP="combo:drop",t.CommonEvent=void 0,(gc=t.CommonEvent||(t.CommonEvent={})).CLICK="click",gc.DBLCLICK="dblclick",gc.POINTER_OVER="pointerover",gc.POINTER_LEAVE="pointerleave",gc.POINTER_ENTER="pointerenter",gc.POINTER_MOVE="pointermove",gc.POINTER_OUT="pointerout",gc.POINTER_DOWN="pointerdown",gc.POINTER_UP="pointerup",gc.CONTEXT_MENU="contextmenu",gc.DRAG_START="dragstart",gc.DRAG="drag",gc.DRAG_END="dragend",gc.DRAG_ENTER="dragenter",gc.DRAG_OVER="dragover",gc.DRAG_LEAVE="dragleave",gc.DROP="drop",gc.KEY_DOWN="keydown",gc.KEY_UP="keyup",gc.WHEEL="wheel",gc.PINCH="pinch",t.ContainerEvent=void 0,(vc=t.ContainerEvent||(t.ContainerEvent={})).KEY_DOWN="keydown",vc.KEY_UP="keyup",t.EdgeEvent=void 0,(mc=t.EdgeEvent||(t.EdgeEvent={})).CLICK="edge:click",mc.DBLCLICK="edge:dblclick",mc.POINTER_OVER="edge:pointerover",mc.POINTER_LEAVE="edge:pointerleave",mc.POINTER_ENTER="edge:pointerenter",mc.POINTER_MOVE="edge:pointermove",mc.POINTER_OUT="edge:pointerout",mc.POINTER_DOWN="edge:pointerdown",mc.POINTER_UP="edge:pointerup",mc.CONTEXT_MENU="edge:contextmenu",mc.DRAG_ENTER="edge:dragenter",mc.DRAG_OVER="edge:dragover",mc.DRAG_LEAVE="edge:dragleave",mc.DROP="edge:drop",t.GraphEvent=void 0,(yc=t.GraphEvent||(t.GraphEvent={})).BEFORE_CANVAS_INIT="beforecanvasinit",yc.AFTER_CANVAS_INIT="aftercanvasinit",yc.BEFORE_SIZE_CHANGE="beforesizechange",yc.AFTER_SIZE_CHANGE="aftersizechange",yc.BEFORE_ELEMENT_CREATE="beforeelementcreate",yc.AFTER_ELEMENT_CREATE="afterelementcreate",yc.BEFORE_ELEMENT_UPDATE="beforeelementupdate",yc.AFTER_ELEMENT_UPDATE="afterelementupdate",yc.BEFORE_ELEMENT_DESTROY="beforeelementdestroy",yc.AFTER_ELEMENT_DESTROY="afterelementdestroy",yc.BEFORE_ELEMENT_TRANSLATE="beforeelementtranslate",yc.AFTER_ELEMENT_TRANSLATE="afterelementtranslate",yc.BEFORE_DRAW="beforedraw",yc.AFTER_DRAW="afterdraw",yc.BEFORE_RENDER="beforerender",yc.AFTER_RENDER="afterrender",yc.BEFORE_ANIMATE="beforeanimate",yc.AFTER_ANIMATE="afteranimate",yc.BEFORE_LAYOUT="beforelayout",yc.AFTER_LAYOUT="afterlayout",yc.BEFORE_STAGE_LAYOUT="beforestagelayout",yc.AFTER_STAGE_LAYOUT="afterstagelayout",yc.BEFORE_TRANSFORM="beforetransform",yc.AFTER_TRANSFORM="aftertransform",yc.BATCH_START="batchstart",yc.BATCH_END="batchend",yc.BEFORE_DESTROY="beforedestroy",yc.AFTER_DESTROY="afterdestroy",yc.BEFORE_RENDERER_CHANGE="beforerendererchange",yc.AFTER_RENDERER_CHANGE="afterrendererchange",t.HistoryEvent=void 0,(bc=t.HistoryEvent||(t.HistoryEvent={})).UNDO="undo",bc.REDO="redo",bc.CANCEL="cancel",bc.ADD="add",bc.CLEAR="clear",bc.CHANGE="change",t.NodeEvent=void 0,(xc=t.NodeEvent||(t.NodeEvent={})).CLICK="node:click",xc.DBLCLICK="node:dblclick",xc.POINTER_OVER="node:pointerover",xc.POINTER_LEAVE="node:pointerleave",xc.POINTER_ENTER="node:pointerenter",xc.POINTER_MOVE="node:pointermove",xc.POINTER_OUT="node:pointerout",xc.POINTER_DOWN="node:pointerdown",xc.POINTER_UP="node:pointerup",xc.CONTEXT_MENU="node:contextmenu",xc.DRAG_START="node:dragstart",xc.DRAG="node:drag",xc.DRAG_END="node:dragend",xc.DRAG_ENTER="node:dragenter",xc.DRAG_OVER="node:dragover",xc.DRAG_LEAVE="node:dragleave",xc.DROP="node:drop";const Ec="combo",wc="tree";var kc;t.ExtensionCategory=void 0,(kc=t.ExtensionCategory||(t.ExtensionCategory={})).NODE="node",kc.EDGE="edge",kc.COMBO="combo",kc.THEME="theme",kc.PALETTE="palette",kc.LAYOUT="layout",kc.BEHAVIOR="behavior",kc.PLUGIN="plugin",kc.ANIMATION="animation",kc.TRANSFORM="transform",kc.SHAPE="shape";const Mc={animation:{},behavior:{},combo:{},edge:{},layout:{},node:{},palette:{},theme:{},plugin:{},transform:{},shape:{}};function Sc(t,e){var n;const r=null===(n=Mc[t])||void 0===n?void 0:n[e];if(r)return r}const Nc="5.0.48";function Oc(t){return`[G6 v${Nc}] ${t}`}const Tc=t=>{console.warn(Oc(t))};function Cc(e){const{theme:n}=e;if(!n)return{};const r=Sc(t.ExtensionCategory.THEME,n);return r||(Tc(`The theme of ${n} is not registered.`),{})}function Ac(t,e){if(Array.isArray(t)&&0===t.length)return null;const n=Array.isArray(t)?t[0]:t,r=Array.isArray(t)?t.slice(1):e||[];return new Proxy(n,{get:(t,e)=>"function"!=typeof t[e]||["onframe","onfinish"].includes(e)?"finished"===e?Promise.all([n.finished,...r.map((t=>t.finished))]):Reflect.get(t,e):(...n)=>{t[e](...n),r.forEach((t=>{var r;return null===(r=t[e])||void 0===r?void 0:r.call(t,...n)}))},set:(t,e,n)=>(["onframe","onfinish"].includes(e)||r.forEach((t=>{t[e]=n})),Reflect.set(t,e,n))})}function Pc(t){const e=t.reduce(((t,e)=>(Object.entries(e).forEach((([e,n])=>{void 0===t[e]?t[e]=[n]:t[e].push(n)})),t)),{});Object.entries(e).forEach((([n,r])=>{(r.length!==t.length||r.some((t=>$t(t)))||r.every((t=>!["sourceNode","targetNode","childrenNode"].includes(n)&&Ne(t,r[0]))))&&delete e[n]}));const n=Object.entries(e).reduce(((t,[e,n])=>(n.forEach(((n,r)=>{t[r]?t[r][e]=n:t[r]={[e]:n}})),t)),[]);return 0!==t.length&&0===n.length&&n.push({_:0},{_:0}),n}function Rc(t){switch(t){case"opacity":return 1;case"x":case"y":case"z":case"zIndex":return 0;case"visibility":return"visible";case"collapsed":return!1;case"states":return[];default:return}}function Dc(t,e){const{animation:n}=t;if(!1===n||!1===e)return!1;const r=Object.assign({},cc);return qt(n)&&Object.assign(r,n),qt(e)&&Object.assign(r,e),r}function Lc(e,n,r,i){var o,a;const{animation:s}=e;if(!1===s||!1===i)return[];const l=null===(o=null==e?void 0:e[n])||void 0===o?void 0:o.animation;if(!1===l)return[];const u=null==l?void 0:l[r];if(!1===u)return[];const c=null===(a=Cc(e)[n])||void 0===a?void 0:a.animation,h=(e=[])=>function(e){if("string"==typeof e){return Sc(t.ExtensionCategory.ANIMATION,e)||(Tc(`The animation of ${e} is not registered.`),[])}return e}(e).map((t=>Object.assign(Object.assign(Object.assign(Object.assign({},hc),qt(s)&&s),t),qt(i)&&i)));if(u)return h(u);if(!c)return[];const d=c[r];return!1===d?[]:h(d)}function _c(t,e,n,r=[]){if(!r&&0===t&&0===e&&0===n)return null;if(Array.isArray(r)){let i=-1;const o=[];for(let a=0;a<r.length;a++){const s=r[a];if("translate"===s[0]){if(s[1]===t&&s[2]===e)return null;i=a,o.push(["translate",t,e])}else if("translate3d"===s[0]){if(s[1]===t&&s[2]===e&&s[3]===n)return null;i=a,o.push(["translate3d",t,e,null!=n?n:0])}else o.push(s)}return-1===i&&o.splice(0,0,ae(n)?["translate3d",t,e,null!=n?n:0]:["translate",t,e]),0===o.length?null:o}const i=r?r.replace(/translate(3d)?\([^)]*\)/g,""):"";return 0===n?`translate(${t}, ${e})${i}`:`translate3d(${t}, ${e}, ${n})${i}`}const Ic=(t,e,n)=>{if(!n.length)return null;const[r,i]=e;let o;const a=n.map((e=>{var{fields:n,shape:a,states:s}=e,l=Fe(e,["fields","shape","states"]);const u=(e=>{var n;if(e){const o=t.getShape(e);if(!o)return null;const a=`get${de(e)}Style`,s=(null===(n=null==t?void 0:t[a])||void 0===n?void 0:n.bind(t))||(t=>t);return{shape:o,fromStyle:(null==s?void 0:s(r))||{},toStyle:(null==s?void 0:s(i))||{}}}return{shape:t,fromStyle:r,toStyle:i}})(a);if(!u)return null;const{shape:c,fromStyle:h,toStyle:d}=u,f=[{},{}];if(n.forEach((t=>{var e,n;Object.assign(f[0],{[t]:null!==(e=h[t])&&void 0!==e?e:Rc(t)}),Object.assign(f[1],{[t]:null!==(n=d[t])&&void 0!==n?n:Rc(t)})})),f.some((t=>Object.keys(t).some((t=>["x","y","z"].includes(t)))))){const{x:t=0,y:e=0,z:n,transform:r=""}=c.attributes||{};f.forEach((i=>{var o,a,s;i.transform=_c(null!==(o=i.x)&&void 0!==o?o:t,null!==(a=i.y)&&void 0!==a?a:e,null!==(s=i.z)&&void 0!==s?s:n,r)}))}const p=c.animate(Pc(f),l);return void 0===a&&(o=p),p})).filter(Boolean),s=o||(null==a?void 0:a[0]);return s?Ac(s,a.filter((t=>t!=t))):null},jc=[{fields:["x","y"]}],Bc=jc,Fc=[{fields:["sourceNode","targetNode"]}],zc=Fc,Gc=[{fields:["childrenNode","x","y"]}],Vc=Gc;function Wc(t){return t instanceof Float32Array||!(!Array.isArray(t)||2!==t.length&&3!==t.length)&&t.every((t=>"number"==typeof t))}function Hc(t,e,n){return t>=e&&t<=n}function Uc(t=0){if(Array.isArray(t)){const[e=0,n=e,r=e,i=n]=t;return[e,n,r,i]}return[t,t,t,t]}function $c(t=0){const e=Uc(t);return e[0]+e[2]}function Yc(t){return t.max[0]-t.min[0]}function qc(t){return t.max[1]-t.min[1]}function Xc(t){return[Yc(t),qc(t)]}function Kc(t,e){const n=Wc(t)?Zc(t):t.getShape("key").getBounds();return e?Qc(n,e):n}function Zc(t){const[e,n,r=0]=t,i=new fr;return i.setMinMax([e,n,r],[e,n,r]),i}function Qc(t,e){const[n,r,i,o]=Uc(e),[a,s,l]=t.min,[u,c,h]=t.max,d=new fr;return d.setMinMax([a-o,s-n,l],[u+r,c+i,h]),d}function Jc(t){if(0===t.length)return new fr;if(1===t.length)return t[0];const e=new fr;e.setMinMax(t[0].min,t[0].max);for(let n=1;n<t.length;n++){const r=t[n];e.setMinMax([Math.min(e.min[0],r.min[0]),Math.min(e.min[1],r.min[1]),Math.min(e.min[2],r.min[2])],[Math.max(e.max[0],r.max[0]),Math.max(e.max[1],r.max[1]),Math.max(e.max[2],r.max[2])])}return e}function th(t,e){return Hc(t[0],e.min[0],e.max[0])&&Hc(t[1],e.min[1],e.max[1])}function eh(t,e,n=!1){const{min:[r,i],max:[o,a]}=e,s=(t[1]===i||t[1]===a)&&(n||Hc(t[0],r,o)),l=(t[0]===r||t[0]===o)&&(n||Hc(t[1],i,a));return s||l}function nh(t,e){const{center:n}=e;return t[0]===n[0]&&t[1]===n[1]}function rh(t,e){const[n,r]=t,[i,o]=e.min,[a,s]=e.max,l=n-i,u=a-n,c=r-o,h=s-r,d=Math.min(l,u,c,h);return d===l?"left":d===u?"right":d===c?"top":d===h?"bottom":"left"}function ih(t,e){const n=me(t);if(th(t,e)){switch(rh(t,e)){case"left":n[0]=e.min[0];break;case"right":n[0]=e.max[0];break;case"top":n[1]=e.min[1];break;case"bottom":n[1]=e.max[1]}}else{const[r,i]=t,[o,a]=e.min,[s,l]=e.max;n[0]=Hc(r,o,s)?r:r<o?o:s,n[1]=Hc(i,a,l)?i:i<a?a:l}return n}var oh=function(t,e){return t===e},ah=function(){function t(t,e){void 0===e&&(e=null),this.value=t,this.next=e}return t.prototype.toString=function(t){return t?t(this.value):"".concat(this.value)},t}(),sh=function(){function t(t){void 0===t&&(t=oh),this.head=null,this.tail=null,this.compare=t}return t.prototype.prepend=function(t){var e=new ah(t,this.head);return this.head=e,this.tail||(this.tail=e),this},t.prototype.append=function(t){var e=new ah(t);return this.head?(this.tail.next=e,this.tail=e,this):(this.head=e,this.tail=e,this)},t.prototype.delete=function(t){if(!this.head)return null;for(var e=null;this.head&&this.compare(this.head.value,t);)e=this.head,this.head=this.head.next;var n=this.head;if(null!==n)for(;n.next;)this.compare(n.next.value,t)?(e=n.next,n.next=n.next.next):n=n.next;return this.compare(this.tail.value,t)&&(this.tail=n),e},t.prototype.find=function(t){var e=t.value,n=void 0===e?void 0:e,r=t.callback,i=void 0===r?void 0:r;if(!this.head)return null;for(var o=this.head;o;){if(i&&i(o.value))return o;if(void 0!==n&&this.compare(o.value,n))return o;o=o.next}return null},t.prototype.deleteTail=function(){var t=this.tail;if(this.head===this.tail)return this.head=null,this.tail=null,t;for(var e=this.head;e.next;)e.next.next?e=e.next:e.next=null;return this.tail=e,t},t.prototype.deleteHead=function(){if(!this.head)return null;var t=this.head;return this.head.next?this.head=this.head.next:(this.head=null,this.tail=null),t},t.prototype.fromArray=function(t){var e=this;return t.forEach((function(t){return e.append(t)})),this},t.prototype.toArray=function(){for(var t=[],e=this.head;e;)t.push(e),e=e.next;return t},t.prototype.reverse=function(){for(var t=this.head,e=null,n=null;t;)n=t.next,t.next=e,e=t,t=n;this.tail=this.head,this.head=e},t.prototype.toString=function(t){return void 0===t&&(t=void 0),this.toArray().map((function(e){return e.toString(t)})).toString()},t}(),lh=function(t,e,n){void 0===e&&(e=[]);var r=e.filter((function(e){return e.source===t||e.target===t}));if("target"===n){return r.filter((function(e){return e.source===t})).map((function(t){return t.target}))}if("source"===n){return r.filter((function(e){return e.target===t})).map((function(t){return t.source}))}return r.map((function(e){return e.source===t?e.target:e.source}))},uh={}.toString,ch=function(t,e){return uh.call(t)==="[object "+e+"]"},hh=function(t){return ch(t,"Function")},dh=function(t){return Array.isArray?Array.isArray(t):ch(t,"Array")};var fh,ph=Object.values?function(t){return Object.values(t)}:function(t){var e=[];return function(t,e){var n,r;if(t)if(dh(t))for(var i=0,o=t.length;i<o&&!1!==e(t[i],i);i++);else if(r=typeof(n=t),null!==n&&"object"===r||"function"===r)for(var a in t)if(t.hasOwnProperty(a)&&!1===e(t[a],a))break}(t,(function(n,r){hh(t)&&"prototype"===r||e.push(n)})),e};!function(t,e){if(!hh(t))throw new TypeError("Expected a function");var n=function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=e?e.apply(this,r):r[0],a=n.cache;if(a.has(o))return a.get(o);var s=t.apply(this,r);return a.set(o,s),s};n.cache=new Map}((function(t,e){void 0===e&&(e={});var n=e.fontSize,r=e.fontFamily,i=e.fontWeight,o=e.fontStyle,a=e.fontVariant;return fh||(fh=document.createElement("canvas").getContext("2d")),fh.font=[o,a,i,n+"px",r].join(" "),fh.measureText(function(t){return ch(t,"String")}(t)?t:"").width}),(function(t,e){return void 0===e&&(e={}),function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),i=0;for(e=0;e<n;e++)for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++)r[i]=o[a];return r}([t],ph(e)).join("")}));function gh(t,e,n,r){if(t===e)return[t];if(r[e])return r[e];for(var i=[],o=0,a=n[e];o<a.length;o++){var s=gh(t,a[o],n,r);if(!s)return;for(var l=0,u=s;l<u.length;l++){var c=u[l];dh(c)?i.push(We(We([],c,!0),[e],!1)):i.push([c,e])}}return r[e]=i,r[e]}var vh,mh=function(t,e,n,r,i){var o=function(t,e,n,r){var i=t.nodes,o=void 0===i?[]:i,a=t.edges,s=void 0===a?[]:a,l={},u={},c={};o.forEach((function(t,n){var r=t.id;u[r]=1/0,r===e&&(u[r]=0)}));for(var h=o.length,d=function(t){var e=function(t,e,n){for(var r,i=1/0,o=0;o<e.length;o++){var a=e[o].id;!n[a]&&t[a]<=i&&(i=t[a],r=e[o])}return r}(u,o,l),i=e.id;if(l[i]=!0,u[i]===1/0)return"continue";var a=[];a=n?function(t,e){return e.filter((function(e){return e.source===t}))}(i,s):function(t,e){return e.filter((function(e){return e.source===t||e.target===t}))}(i,s),a.forEach((function(t){var n=t.target,o=t.source,a=n===i?o:n,s=r&&t[r]?t[r]:1;u[a]>u[e.id]+s?(u[a]=u[e.id]+s,c[a]=[e.id]):u[a]===u[e.id]+s&&c[a].push(e.id)}))},f=0;f<h;f++)d();c[e]=[e];var p={};for(var g in u)u[g]!==1/0&&gh(e,g,c,p);var v={};for(var g in p)v[g]=p[g][0];return{length:u,path:v,allPath:p}}(t,e,r,i),a=o.length,s=o.path,l=o.allPath;return{length:a[n],path:s[n],allPath:l[n]}};!function(t){t.EuclideanDistance="euclideanDistance"}(vh||(vh={}));function yh(t){if(void 0!==t.id)return t.id;if(void 0!==t.source&&void 0!==t.target)return`${t.source}-${t.target}`;throw new Error(Oc("The datum does not have available id."))}function bh(t){return t.combo}function xh(t,e){const n={nodes:(t.nodes||[]).map(yh),edges:(t.edges||[]).map(yh),combos:(t.combos||[]).map(yh)};return e?Object.values(n).flat():n}!function(){function t(t){void 0===t&&(t=10),this.linkedList=new sh,this.maxStep=t}Object.defineProperty(t.prototype,"length",{get:function(){return this.linkedList.toArray().length},enumerable:!1,configurable:!0}),t.prototype.isEmpty=function(){return!this.linkedList.head},t.prototype.isMaxStack=function(){return this.toArray().length>=this.maxStep},t.prototype.peek=function(){return this.isEmpty()?null:this.linkedList.head.value},t.prototype.push=function(t){this.linkedList.prepend(t),this.length>this.maxStep&&this.linkedList.deleteTail()},t.prototype.pop=function(){var t=this.linkedList.deleteHead();return t?t.value:null},t.prototype.toArray=function(){return this.linkedList.toArray().map((function(t){return t.value}))},t.prototype.clear=function(){for(;!this.isEmpty();)this.pop()}}();const Eh=(t,e,n)=>{var r;switch(n.type){case"degree":{const i=new Map;return null===(r=t.nodes)||void 0===r||r.forEach((t=>{const r=e(yh(t),n.direction).length;i.set(yh(t),r)})),i}case"betweenness":return kh(t,n.directed,n.weightPropertyName);case"closeness":return Mh(t,n.directed,n.weightPropertyName);case"eigenvector":return Nh(t,n.directed);case"pagerank":return Sh(t,n.epsilon,n.linkProb);default:return wh(t)}},wh=t=>{var e;const n=new Map;return null===(e=t.nodes)||void 0===e||e.forEach((t=>{n.set(yh(t),0)})),n},kh=(t,e,n)=>{const r=wh(t),{nodes:i=[]}=t;return i.forEach((o=>{i.forEach((i=>{if(o!==i){const{allPath:a}=mh(t,yh(o),yh(i),e,n),s=a.length;a.flat().forEach((t=>{t!==yh(o)&&t!==yh(i)&&r.set(t,r.get(t)+1/s)}))}}))})),r},Mh=(t,e,n)=>{const r=new Map,{nodes:i=[]}=t;return i.forEach((o=>{const a=i.reduce(((r,i)=>{if(o!==i){const{length:a}=mh(t,yh(o),yh(i),e,n);r+=a}return r}),0);r.set(yh(o),1/a)})),r},Sh=(t,e,n)=>{var r;const i=new Map,o=function(t,e,n){"number"!=typeof e&&(e=1e-6),"number"!=typeof n&&(n=.85);for(var r,i=1,o=0,a=1e3,s=t.nodes,l=void 0===s?[]:s,u=t.edges,c=void 0===u?[]:u,h=l.length,d={},f={},p=0;p<h;++p)d[v=(E=l[p]).id]=1/h,f[v]=1/h;for(var g=function(t){var e={},n=t.nodes,r=void 0===n?[]:n,i=t.edges,o=void 0===i?[]:i;return r.forEach((function(t){e[t.id]={degree:0,inDegree:0,outDegree:0}})),o.forEach((function(t){e[t.source].degree++,e[t.source].outDegree++,e[t.target].degree++,e[t.target].inDegree++})),e}(t);a>0&&i>e;){for(o=0,p=0;p<h;++p){var v=(E=l[p]).id;if(r=0,0===g[E.id].inDegree)d[v]=0;else{for(var m=lh(v,c,"source"),y=0;y<m.length;++y){var b=m[y],x=g[b].outDegree;x>0&&(r+=f[b]/x)}d[v]=n*r,o+=d[v]}}for(o=(1-o)/h,i=0,p=0;p<h;++p){var E;r=d[v=(E=l[p]).id]+o,i+=Math.abs(r-f[v]),f[v]=r}a-=1}return f}(t,e,n);return null===(r=t.nodes)||void 0===r||r.forEach((t=>{i.set(yh(t),o[yh(t)])})),i},Nh=(t,e)=>{const{nodes:n=[]}=t,r=Oh(t,e),i=Th(r,n.length),o=new Map;return n.forEach(((t,e)=>{o.set(yh(t),i[e])})),o},Oh=(t,e)=>{const{nodes:n=[],edges:r=[]}=t,i=Array(n.length).fill(null).map((()=>Array(n.length).fill(0)));return r.forEach((({source:t,target:r})=>{const o=n.findIndex((e=>yh(e)===t)),a=n.findIndex((t=>yh(t)===r));e?i[o][a]=1:(i[o][a]=1,i[a][o]=1)})),i},Th=(t,e,n=100,r=1e-6)=>{let i=Array(e).fill(1),o=1/0;for(let a=0;a<n&&o>r;a++){const n=Array(e).fill(0);for(let r=0;r<e;r++)for(let o=0;o<e;o++)n[r]+=t[r][o]*i[o];const r=Math.sqrt(n.reduce(((t,e)=>t+e*e),0));for(let t=0;t<e;t++)n[t]/=r;o=Math.sqrt(n.reduce(((t,e,n)=>t+(e-i[n])*e),0)),i=n}return i};function Ch(t,e,n,r=Ne){const i=new Map(t.map((t=>[n(t),t]))),o=new Map(e.map((t=>[n(t),t]))),a=new Set(i.keys()),s=new Set(o.keys()),l=[],u=[],c=[],h=[];return s.forEach((t=>{a.has(t)?r(i.get(t),o.get(t))?h.push(o.get(t)):u.push(o.get(t)):l.push(o.get(t))})),a.forEach((t=>{s.has(t)||c.push(i.get(t))})),{enter:l,exit:c,keep:h,update:u}}function Ah(t,e,n){t.forEach((t=>{(t=>{n&&!n(t)||(t.style.visibility=e)})(t)}))}class Ph{constructor(t){this.extensions=[],this.extensionMap={},this.context=t}setExtensions(t){const e=function(t,e,n){const r={},i=t=>(t in r||(r[t]=0),`${e}-${t}-${r[t]++}`);return n.map((e=>"string"==typeof e?{type:e,key:i(e)}:"function"==typeof e?e.call(t):e.key?e:Object.assign(Object.assign({},e),{key:i(e.type)})))}(this.context.graph,this.category,t),{enter:n,update:r,exit:i,keep:o}=Ch(this.extensions,e,(t=>t.key));this.createExtensions(n),this.updateExtensions([...r,...o]),this.destroyExtensions(i),this.extensions=e}createExtension(t){const{category:e}=this,{key:n,type:r}=t,i=Sc(e,r);if(!i)return Tc(`The extension ${r} of ${e} is not registered.`);const o=new i(this.context,t);this.extensionMap[n]=o}createExtensions(t){t.forEach((t=>this.createExtension(t)))}updateExtension(t){const{key:e}=t,n=this.extensionMap[e];n&&n.update(t)}updateExtensions(t){t.forEach((t=>this.updateExtension(t)))}destroyExtension(t){const e=this.extensionMap[t];e&&(e.destroy(),delete this.extensionMap[t])}destroyExtensions(t){t.forEach((({key:t})=>this.destroyExtension(t)))}destroy(){Object.values(this.extensionMap).forEach((t=>t.destroy())),this.context={},this.extensions=[],this.extensionMap={}}}class Rh{constructor(t,e){this.events=[],this.destroyed=!1,this.context=t,this.options=e}update(t){this.options=Object.assign(this.options,t)}destroy(){this.context={},this.options={},this.destroyed=!0}}class Dh extends Rh{}class Lh extends Dh{constructor(t,e){super(t,Object.assign({},Lh.defaultOptions,e)),this.isOverlapping=(t,e)=>e.some((e=>t.intersects(e))),this.occupiedBounds=[],this.detectLabelCollision=t=>{const e=this.context.viewport,n={show:[],hide:[]};return this.occupiedBounds=[],t.forEach((t=>{const r=t.getShape("label").getRenderBounds();e.isInViewport(r,!0)&&!this.isOverlapping(r,this.occupiedBounds)?(n.show.push(t),this.occupiedBounds.push(Qc(r,this.options.padding))):n.hide.push(t)})),n},this.hideLabelIfExceedViewport=(t,e)=>{const{exit:n}=Ch(t,e,(t=>t.id));null==n||n.forEach(this.hideLabel)},this.nodeCentralities=new Map,this.sortNodesByCentrality=(t,e)=>{const{model:n}=this.context,r=n.getData(),i=n.getRelatedEdgesData.bind(n);return t.map((t=>(this.nodeCentralities.has(t.id)||(this.nodeCentralities=Eh(r,i,e)),{node:t,centrality:this.nodeCentralities.get(t.id)}))).sort(((t,e)=>e.centrality-t.centrality)).map((t=>t.node))},this.sortLabelElementsInView=t=>{const{sort:e,sortNode:n,sortCombo:r,sortEdge:i}=this.options,{model:o}=this.context;if(Ut(e))return t.sort(((t,n)=>e(o.getElementDataById(t.id),o.getElementDataById(n.id))));const{node:a=[],edge:s=[],combo:l=[]}=ie(t,(t=>t.type)),u=Ut(r)?l.sort(((t,e)=>r(...o.getComboData([t.id,e.id])))):l,c=Ut(n)?a.sort(((t,e)=>n(...o.getNodeData([t.id,e.id])))):this.sortNodesByCentrality(a,n),h=Ut(i)?s.sort(((t,e)=>i(...o.getEdgeData([t.id,e.id])))):s;return[...u,...c,...h]},this.labelElementsInView=[],this.isFirstRender=!0,this.onToggleVisibility=t=>{var e;if("zIndex"===(null===(e=t.data)||void 0===e?void 0:e.stage))return;if(!this.validate(t))return void(this.hiddenElements.size>0&&(this.hiddenElements.forEach(this.showLabel),this.hiddenElements.clear()));const n=this.isFirstRender?this.getLabelElements():this.getLabelElementsInView();this.hideLabelIfExceedViewport(this.labelElementsInView,n),this.labelElementsInView=n;const r=this.sortLabelElementsInView(this.labelElementsInView),{show:i,hide:o}=this.detectLabelCollision(r);for(let t=i.length-1;t>=0;t--)this.showLabel(i[t]);o.forEach(this.hideLabel)},this.hiddenElements=new Map,this.hideLabel=t=>{const e=t.getShape("label");e&&Ah(e,"hidden"),this.hiddenElements.set(t.id,t)},this.showLabel=t=>{const e=t.getShape("label");e&&Ah(e,"visible"),t.toFront(),this.hiddenElements.delete(t.id)},this.onTransform=Re(this.onToggleVisibility,this.options.throttle,{leading:!0}),this.enableToggle=!0,this.toggle=t=>{this.enableToggle&&this.onToggleVisibility(t)},this.onBeforeRender=()=>{this.enableToggle=!1},this.onAfterRender=t=>{this.onToggleVisibility(t),this.enableToggle=!0},this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents(),this.onToggleVisibility({})}getLabelElements(){const{elementMap:t}=this.context.element,e=[];for(const n in t){const r=t[n];r.isVisible()&&r.getShape("label")&&e.push(r)}return e}getLabelElementsInView(){const t=this.context.viewport;return this.getLabelElements().filter((e=>t.isInViewport(e.getShape("key").getRenderBounds())))}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.on(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.on(t.GraphEvent.AFTER_DRAW,this.toggle),e.on(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.on(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_RENDER,this.onBeforeRender),e.off(t.GraphEvent.AFTER_RENDER,this.onAfterRender),e.off(t.GraphEvent.AFTER_DRAW,this.toggle),e.off(t.GraphEvent.AFTER_LAYOUT,this.toggle),e.off(t.GraphEvent.AFTER_TRANSFORM,this.onTransform)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Lh.defaultOptions={enable:!0,throttle:100,padding:0,sortNode:{type:"degree"}};const _h=[0,0,0];function Ih(t,e){return t.map(((t,n)=>t+e[n]))}function jh(t,e){return t.map(((t,n)=>t-e[n]))}function Bh(t,e){return"number"==typeof e?t.map((t=>t*e)):t.map(((t,n)=>t*e[n]))}function Fh(t,e){return"number"==typeof e?t.map((t=>t/e)):t.map(((t,n)=>t/e[n]))}function zh(t,e){return t.map((t=>t*e))}function Gh(t,e){return Math.sqrt(t.reduce(((t,n,r)=>t+Math.pow(n-e[r]||0,2)),0))}function Vh(t,e){return t.reduce(((t,n,r)=>t+Math.abs(n-e[r])),0)}function Wh(t){const e=t.reduce(((t,e)=>t+Math.pow(e,2)),0);return t.map((t=>t/Math.sqrt(e)))}function Hh(t,e,n=!1){const r=t[0]*e[1]-t[1]*e[0];let i=Math.acos(Bh(t,e).reduce(((t,e)=>t+e),0)/(Gh(t,_h)*Gh(e,_h)));return n&&r<0&&(i=2*Math.PI-i),i}function Uh(t,e=!0){return e?[-t[1],t[0]]:[t[1],-t[0]]}function $h(t,e){return t.map((t=>t%e))}function Yh(t){return[t[0],t[1]]}function qh(t){return 2===t.length?[t[0],t[1],0]:t}function Xh(t){const[e,n]=t;return e||n?Math.atan2(n,e):0}function Kh(t,e){const[n,r]=t,[i,o]=e;return function(t,e){const n=qh(t),r=qh(e);return[n[1]*r[2]-n[2]*r[1],n[2]*r[0]-n[0]*r[2],n[0]*r[1]-n[1]*r[0]]}(jh(n,r),jh(i,o)).every((t=>0===t))}function Zh(t,e,n=!1){if(Kh(t,e))return;const[r,i]=t,[o,a]=e,s=((r[0]-o[0])*(o[1]-a[1])-(r[1]-o[1])*(o[0]-a[0]))/((r[0]-i[0])*(o[1]-a[1])-(r[1]-i[1])*(o[0]-a[0])),l=a[0]-o[0]?(r[0]-o[0]+s*(i[0]-r[0]))/(a[0]-o[0]):(r[1]-o[1]+s*(i[1]-r[1]))/(a[1]-o[1]);return n||Hc(s,0,1)&&Hc(l,0,1)?[r[0]+s*(i[0]-r[0]),r[1]+s*(i[1]-r[1])]:void 0}function Qh(t){if(Array.isArray(t))return Hc(t[0],0,1)&&Hc(t[1],0,1)?t:[.5,.5];const e=t.split("-");return[e.includes("left")?0:e.includes("right")?1:.5,e.includes("top")?0:e.includes("bottom")?1:.5]}function Jh(t){const{x:e=0,y:n=0,z:r=0}=t.style||{};return[+e,+n,+r]}function td(t){const{x:e,y:n,z:r}=t.style||{};return void 0!==e||void 0!==n||void 0!==r}function ed(t,e="center"){return function(t,e){const[n,r]=e,{min:i,max:o}=t;return[i[0]+n*(o[0]-i[0]),i[1]+r*(o[1]-i[1])]}(t,Qh(e))}function nd(t){var e;return[t.x,t.y,null!==(e=t.z)&&void 0!==e?e:0]}function rd(t){var e;return{x:t[0],y:t[1],z:null!==(e=t[2])&&void 0!==e?e:0}}function id(t,e=0){return t.map((t=>parseFloat(t.toFixed(e))))}function od(t,e,n,r=!1){if(Ne(t,e))return t;const i=Wh(r?jh(t,e):jh(e,t)),o=[i[0]*n,i[1]*n];return Ih(Yh(t),o)}function ad(t,e){return t[1]===e[1]}function sd(t,e,n){return Kh([t,e],[e,n])}function ld(t,e){return[2*e[0]-t[0],2*e[1]-t[1]]}function ud(t,e,n,r=!0,i=!1){for(let o=0;o<n.length;o++){let a=n[o],s=n[(o+1)%n.length];r&&(a=Ih(e,a),s=Ih(e,s));const l=Zh([e,i?ld(t,e):t],[a,s]);if(l)return{point:l,line:[a,s]}}return{point:e,line:void 0}}function cd(t,e,n=!1){const r=e.center,i=jh(n?ld(t,r):t,e.center),o=Math.atan2(i[1],i[0]);if(isNaN(o))return r;const a=Yc(e)/2,s=qc(e)/2;return[r[0]+a*Math.cos(o),r[1]+s*Math.sin(o)]}function hd(t,e){let n=1/0,r=[[0,0],[0,0]];return e.forEach((e=>{const i=function(t,e){const n=dd(t,e);return Gh(t,n)}(t,e);i<n&&(n=i,r=e)})),r}function dd(t,e){const[n,r]=e[0],[i,o]=e[1],[a,s]=t,l=i-n,u=o-r;if(0===l&&0===u)return[n,r];let c=((a-n)*l+(s-r)*u)/(l*l+u*u);c>1?c=1:c<0&&(c=0);return[n+c*l,r+c*u]}function fd(t,e=!0){const n=function(t){return Fh(t.reduce(((t,e)=>Ih(t,e)),[0,0]),t.length)}(t);return t.sort((([t,r],[i,o])=>{const a=Math.atan2(r-n[1],t-n[0]),s=Math.atan2(o-n[1],i-n[0]);return e?s-a:a-s}))}function pd(t,e){return[t,[t[0],e[1]],e,[e[0],t[1]]]}class gd{constructor(t,e,n){if(this.phase=e,this.pointerByTouch=[],this.initialDistance=null,this.emitter=t,gd.instance)return gd.callbacks[this.phase].push(n),gd.instance;this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.bindEvents(),gd.instance=this,gd.callbacks[this.phase].push(n)}bindEvents(){const{emitter:e}=this;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp)}updatePointerPosition(t,e,n){const r=this.pointerByTouch.findIndex((e=>e.pointerId===t));r>=0&&(this.pointerByTouch[r]={x:e,y:n,pointerId:t})}onPointerDown(t){const{x:e,y:n}=t.client||{};if(void 0!==e&&void 0!==n&&(this.pointerByTouch.push({x:e,y:n,pointerId:t.pointerId}),"touch"===t.pointerType&&2===this.pointerByTouch.length)){gd.isPinching=!0;const e=this.pointerByTouch[0].x-this.pointerByTouch[1].x,n=this.pointerByTouch[0].y-this.pointerByTouch[1].y;this.initialDistance=Math.sqrt(e*e+n*n),gd.callbacks.pinchstart.forEach((e=>e(t,{scale:0})))}}onPointerMove(t){if(2!==this.pointerByTouch.length||null===this.initialDistance)return;const{x:e,y:n}=t.client||{};if(void 0===e||void 0===n)return;this.updatePointerPosition(t.pointerId,e,n);const r=this.pointerByTouch[0].x-this.pointerByTouch[1].x,i=this.pointerByTouch[0].y-this.pointerByTouch[1].y,o=Math.sqrt(r*r+i*i)/this.initialDistance;gd.callbacks.pinchmove.forEach((e=>e(t,{scale:5*(o-1)})))}onPointerUp(t){var e;gd.callbacks.pinchend.forEach((e=>e(t,{scale:0}))),gd.isPinching=!1,this.initialDistance=null,this.pointerByTouch=[],null===(e=gd.instance)||void 0===e||e.tryDestroy()}destroy(){this.emitter.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),this.emitter.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),this.emitter.off(t.CommonEvent.POINTER_UP,this.onPointerUp),gd.instance=null}off(t,e){const n=gd.callbacks[t].indexOf(e);n>-1&&gd.callbacks[t].splice(n,1),this.tryDestroy()}tryDestroy(){Object.values(gd.callbacks).every((t=>0===t.length))&&this.destroy()}}gd.isPinching=!1,gd.instance=null,gd.callbacks={pinchstart:[],pinchmove:[],pinchend:[]};const vd=t=>t.map((t=>ne(t)?t.toLocaleLowerCase():t));class md{constructor(e){this.map=new Map,this.boundHandlePinch=()=>{},this.recordKey=new Set,this.onKeyDown=t=>{(null==t?void 0:t.key)&&(this.recordKey.add(t.key),this.trigger(t))},this.onKeyUp=t=>{(null==t?void 0:t.key)&&this.recordKey.delete(t.key)},this.onWheel=e=>{this.triggerExtendKey(t.CommonEvent.WHEEL,e)},this.onDrag=e=>{this.triggerExtendKey(t.CommonEvent.DRAG,e)},this.handlePinch=(e,n)=>{this.triggerExtendKey(t.CommonEvent.PINCH,Object.assign(Object.assign({},e),n))},this.onFocus=()=>{this.recordKey.clear()},this.emitter=e,this.bindEvents()}bind(e,n){0!==e.length&&(e.includes(t.CommonEvent.PINCH)&&!this.pinchHandler&&(this.boundHandlePinch=this.handlePinch.bind(this),this.pinchHandler=new gd(this.emitter,"pinchmove",this.boundHandlePinch)),this.map.set(e,n))}unbind(t,e){this.map.forEach(((n,r)=>{Ne(r,t)&&(e&&e!==n||this.map.delete(r))}))}unbindAll(){this.map.clear()}match(t){const e=vd(Array.from(this.recordKey)).sort(),n=vd(t).sort();return Ne(e,n)}bindEvents(){var e;const{emitter:n}=this;n.on(t.CommonEvent.KEY_DOWN,this.onKeyDown),n.on(t.CommonEvent.KEY_UP,this.onKeyUp),n.on(t.CommonEvent.WHEEL,this.onWheel),n.on(t.CommonEvent.DRAG,this.onDrag),null===(e=globalThis.addEventListener)||void 0===e||e.call(globalThis,"focus",this.onFocus)}trigger(t){this.map.forEach(((e,n)=>{this.match(n)&&e(t)}))}triggerExtendKey(t,e){this.map.forEach(((n,r)=>{r.includes(t)&&Ne(Array.from(this.recordKey),r.filter((e=>e!==t)))&&n(e)}))}destroy(){var e,n;this.unbindAll(),this.emitter.off(t.CommonEvent.KEY_DOWN,this.onKeyDown),this.emitter.off(t.CommonEvent.KEY_UP,this.onKeyUp),this.emitter.off(t.CommonEvent.WHEEL,this.onWheel),this.emitter.off(t.CommonEvent.DRAG,this.onDrag),null===(e=this.pinchHandler)||void 0===e||e.off("pinchmove",this.boundHandlePinch),null===(n=globalThis.removeEventListener)||void 0===n||n.call(globalThis,"blur",this.onFocus)}}class yd extends Dh{constructor(t,e){super(t,ke({},yd.defaultOptions,e)),this.shortcut=new md(t.graph),this.onPointerDown=this.onPointerDown.bind(this),this.onPointerMove=this.onPointerMove.bind(this),this.onPointerUp=this.onPointerUp.bind(this),this.clearStates=this.clearStates.bind(this),this.bindEvents()}onPointerDown(t){if(!this.validate(t)||!this.isKeydown()||this.startPoint)return;const{canvas:e,graph:n}=this.context,r=Object.assign({},this.options.style);this.options.style.lineWidth&&(r.lineWidth=+this.options.style.lineWidth/n.getZoom()),this.rectShape=new Xl({id:"g6-brush-select",style:r}),e.appendChild(this.rectShape),this.startPoint=[t.canvas.x,t.canvas.y]}onPointerMove(t){var e;if(!this.startPoint)return;const{immediately:n,mode:r}=this.options;this.endPoint=bd(t),null===(e=this.rectShape)||void 0===e||e.attr({x:Math.min(this.endPoint[0],this.startPoint[0]),y:Math.min(this.endPoint[1],this.startPoint[1]),width:Math.abs(this.endPoint[0]-this.startPoint[0]),height:Math.abs(this.endPoint[1]-this.startPoint[1])}),n&&"default"===r&&this.updateElementsStates(pd(this.startPoint,this.endPoint))}onPointerUp(t){this.startPoint&&(this.endPoint?(this.endPoint=bd(t),this.updateElementsStates(pd(this.startPoint,this.endPoint)),this.clearBrush()):this.clearBrush())}clearStates(){this.endPoint||this.clearElementsStates()}clearElementsStates(){const{graph:t}=this.context,e=Object.values(t.getData()).reduce(((t,e)=>Object.assign({},t,e.reduce(((t,e)=>{var n;const r=null===(n=e.states||[])||void 0===n?void 0:n.filter((t=>t!==this.options.state));return t[yh(e)]=r,t}),{}))),{});t.setElementState(e,this.options.animation)}updateElementsStates(t){const{graph:e}=this.context,{enableElements:n,state:r,mode:i,onSelect:o}=this.options,a=this.selector(e,t,n);let s={};switch(i){case"union":a.forEach((t=>{s[t]=[...e.getElementState(t),r]}));break;case"diff":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?n.filter((t=>t!==r)):[...n,r]}));break;case"intersect":a.forEach((t=>{const n=e.getElementState(t);s[t]=n.includes(r)?[r]:[]}));break;default:a.forEach((t=>{s[t]=[r]}))}Ut(o)&&(s=o(s)),e.setElementState(s,this.options.animation)}selector(t,e,n){if(!n||0===n.length)return[];const r=[],i=t.getData();if(n.forEach((n=>{i[`${n}s`].forEach((n=>{const i=yh(n);"hidden"!==t.getElementVisibility(i)&&function(t,e,n,r){const i=t[0],o=t[1];let a=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);const s=r-n;for(let t=0,r=s-1;t<s;r=t++){const s=e[t+n][0],l=e[t+n][1],u=e[r+n][0],c=e[r+n][1];l>o!=c>o&&i<(u-s)*(o-l)/(c-l)+s&&(a=!a)}return a}(t.getElementPosition(i),e)&&r.push(i)}))})),n.includes("edge")){const t=i.edges;null==t||t.forEach((t=>{const{source:e,target:n}=t;r.includes(e)&&r.includes(n)&&r.push(yh(t))}))}return r}clearBrush(){var t;null===(t=this.rectShape)||void 0===t||t.remove(),this.rectShape=void 0,this.startPoint=void 0,this.endPoint=void 0}isKeydown(){const{trigger:t}=this.options,e=Array.isArray(t)?t:[t];return this.shortcut.match(e.filter((t=>"drag"!==t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}bindEvents(){const{graph:e}=this.context;e.on(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.on(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.on(t.CommonEvent.POINTER_UP,this.onPointerUp),e.on(t.CanvasEvent.CLICK,this.clearStates)}unbindEvents(){const{graph:e}=this.context;e.off(t.CommonEvent.POINTER_DOWN,this.onPointerDown),e.off(t.CommonEvent.POINTER_MOVE,this.onPointerMove),e.off(t.CommonEvent.POINTER_UP,this.onPointerUp),e.off(t.CanvasEvent.CLICK,this.clearStates)}update(t){this.unbindEvents(),this.options=ke(this.options,t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}yd.defaultOptions={animation:!1,enable:!0,enableElements:["node","combo","edge"],immediately:!1,mode:"default",state:"selected",trigger:["shift"],style:{width:0,height:0,lineWidth:1,fill:"#1677FF",stroke:"#1677FF",fillOpacity:.1,zIndex:2,pointerEvents:"none"}};const bd=t=>[t.canvas.x,t.canvas.y],xd=.8,Ed=["node","edge","combo"];function wd(t,e,n,r,i=0){"TB"===r&&e(t,i);const o=n(t);if(o)for(const t of o)wd(t,e,n,r,i+1);"BT"===r&&e(t,i)}function kd(t,e,n,r,i="both"){if("combo"===e||"node"===e)return Md(t,n,r,i);const o=t.getEdgeData(n);if(!o)return[];const a=Md(t,o.source,r-1,i),s=Md(t,o.target,r-1,i);return Array.from(new Set([...a,...s,n]))}function Md(t,e,n,r="both"){const i=new Set,o=new Set,a=new Set;return function(t,e,n){const r=[[t,0]];for(;r.length;){const[t,i]=r.shift();e(t,i);const o=n(t);if(o)for(const t of o)r.push([t,i+1])}}(e,((e,i)=>{i>n||(a.add(e),t.getRelatedEdgesData(e,r).forEach((t=>{const e=yh(t);!o.has(e)&&i<n&&(a.add(e),o.add(e))})))}),(e=>t.getRelatedEdgesData(e,r).map((t=>t.source===e?t.target:t.source)).filter((t=>!i.has(t)&&(i.add(t),!0))))),Array.from(a)}function Sd(t){return t.states||[]}class Nd extends Dh{constructor(t,e){super(t,Object.assign({},Nd.defaultOptions,e)),this.onClickSelect=t=>ze(this,void 0,void 0,(function*(){var e,n;this.validate(t)&&(yield this.updateState(t),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))})),this.onClickCanvas=t=>ze(this,void 0,void 0,(function*(){var e,n;this.validate(t)&&(yield this.clearState(),null===(n=(e=this.options).onClick)||void 0===n||n.call(e,t))})),this.shortcut=new md(t.graph),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.on(t.CanvasEvent.CLICK,this.onClickCanvas)}get isMultipleSelect(){const{multiple:t,trigger:e}=this.options;return t&&this.shortcut.match(e)}getNeighborIds(t){const{target:e,targetType:n}=t,{graph:r}=this.context,{degree:i}=this.options;return kd(r,n,e.id,"function"==typeof i?i(t):i).filter((t=>t!==e.id))}updateState(t){return ze(this,void 0,void 0,(function*(){const{state:e,unselectedState:n,neighborState:r,animation:i}=this.options;if(!e&&!r&&!n)return;const{target:o}=t,{graph:a}=this.context,s=Sd(a.getElementData(o.id)).includes(e)?"unselect":"select",l={},u=this.isMultipleSelect,c=[o.id],h=this.getNeighborIds(t);if(u)if(Object.assign(l,this.getDataStates()),"select"===s){const t=(t,e)=>{t.forEach((t=>{const r=new Set(a.getElementState(t));r.add(e),r.delete(n),l[t]=Array.from(r)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{const i=l[t];i.includes(e)||i.includes(r)||i.includes(n)||l[t].push(n)}))}else{const t=l[o.id];l[o.id]=t.filter((t=>t!==e&&t!==r)),t.includes(n)||l[o.id].push(n),h.forEach((t=>{l[t]=l[t].filter((t=>t!==r)),l[t].includes(e)||l[t].push(n)}))}else if("select"===s){Object.assign(l,this.getClearStates(!!n));const t=(t,e)=>{t.forEach((t=>{l[t]||(l[t]=a.getElementState(t)),l[t].push(e)}))};t(c,e),t(h,r),n&&Object.keys(l).forEach((t=>{c.includes(t)||h.includes(t)||l[t].push(n)}))}else Object.assign(l,this.getClearStates());yield a.setElementState(l,i)}))}getDataStates(){const{graph:t}=this.context,{nodes:e,edges:n,combos:r}=t.getData(),i={};return[...e,...n,...r].forEach((t=>{i[yh(t)]=Sd(t)})),i}getClearStates(t=!1){const{graph:e}=this.context,{state:n,unselectedState:r,neighborState:i}=this.options,o=new Set([n,r,i]),{nodes:a,edges:s,combos:l}=e.getData(),u={};return[...a,...s,...l].forEach((e=>{const n=Sd(e),r=n.filter((t=>!o.has(t)));(t||r.length!==n.length)&&(u[yh(e)]=r)})),u}clearState(){return ze(this,void 0,void 0,(function*(){const{graph:t}=this.context;yield t.setElementState(this.getClearStates(),this.options.animation)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.onClickSelect)})),e.off(t.CanvasEvent.CLICK,this.onClickCanvas)}destroy(){this.unbindEvents(),super.destroy()}}function Od(t){var e;return!!(null===(e=t.style)||void 0===e?void 0:e.collapsed)}function Td(t,e){if(!t.startsWith(e))return!1;const n=t[e.length];return n>="A"&&n<="Z"}function Cd(t,e,n=!0){if(!e)return t;if(!Td(t,e))return t;const r=t.slice(e.length);return n?function(t){var e=he(t);return e.charAt(0).toLowerCase()+e.substring(1)}(r):r}function Ad(t,e){const n=Object.entries(t).reduce(((t,[n,r])=>("className"===n||"class"===n||Td(n,e)&&Object.assign(t,{[Cd(n,e)]:r}),t)),{});if("opacity"in t){const r=function(t,e){return`${e}${de(t)}`}("opacity",e),i=t.opacity;if(r in t){const e=t[r];Object.assign(n,{opacity:i*e})}else Object.assign(n,{opacity:i})}return n}function Pd(t,e){const n=e.length;return Object.keys(t).reduce(((r,i)=>{if(i.startsWith(e)){r[i.slice(n)]=t[i]}return r}),{})}function Rd(t,e){const n="string"==typeof e?[e]:e,r={};return Object.keys(t).forEach((e=>{n.find((t=>e.startsWith(t)))||(r[e]=t[e])})),r}function Dd(t=0){if("number"==typeof t)return[t,t,t];const[e,n=e,r=e]=t;return[e,n,r]}function Ld(t,e){const{datum:n,graph:r}=e;return"function"==typeof t?t.call(r,n):Object.fromEntries(Object.entries(t).map((([t,e])=>"function"==typeof e?[t,e.call(r,n)]:[t,e])))}function _d(t,e){const n=(null==t?void 0:t.style)||{},r=(null==e?void 0:e.style)||{};for(const t in n)t in r||(r[t]=n[t]);return Object.assign({},t,e,{style:r})}function Id(t){if(t)return"string"==typeof t||"function"==typeof t||Array.isArray(t)?{type:"group",field:t=>t.id,color:t,invert:!1}:t}function jd(t){const e="string"==typeof t?Sc("palette",t):t;if("function"!=typeof e)return e}function Bd(t,e){let n=2*t;return"string"==typeof e?n=t*Number(e.replace("%",""))/100:"number"==typeof e&&(n=e),isNaN(n)&&(n=2*t),n}function Fd(t,e,n=1,r=!1){const i=r?n:1;return Bd((t.max[0]-t.min[0])*i,e)}Nd.defaultOptions={animation:!0,enable:!0,multiple:!1,trigger:["shift"],state:"selected",neighborState:"selected",unselectedState:void 0,degree:0};class zd extends _l{constructor(t){Vd(t.style),super(t),this.shapeMap={},this.animateMap={},this.render(this.attributes,this),this.setVisibility(),this.bindEvents()}get parsedAttributes(){return this.attributes}upsert(e,n,r,i,o){var a,s,l,u,c,h,d,f;const p=this.shapeMap[e];if(!1===r)return void(p&&(null===(a=null==o?void 0:o.beforeDestroy)||void 0===a||a.call(o,p),i.removeChild(p),delete this.shapeMap[e],null===(s=null==o?void 0:o.afterDestroy)||void 0===s||s.call(o,p)));const g="string"==typeof n?Sc(t.ExtensionCategory.SHAPE,n):n;if(!g)throw new Error(Oc(`Shape ${n} not found`));if(!p||p.destroyed||!(p instanceof g)){p&&(null===(l=null==o?void 0:o.beforeDestroy)||void 0===l||l.call(o,p),null==p||p.destroy(),null===(u=null==o?void 0:o.afterDestroy)||void 0===u||u.call(o,p)),null===(c=null==o?void 0:o.beforeCreate)||void 0===c||c.call(o);const t=new g({className:e,style:r});return i.appendChild(t),this.shapeMap[e]=t,null===(h=null==o?void 0:o.afterCreate)||void 0===h||h.call(o,t),t}return null===(d=null==o?void 0:o.beforeUpdate)||void 0===d||d.call(o,p),_g(p,r),null===(f=null==o?void 0:o.afterUpdate)||void 0===f||f.call(o,p),p}update(t={}){const e=Object.assign({},this.attributes,t);Vd(e),function(t,e){const{zIndex:n,transform:r,transformOrigin:i,visibility:o,cursor:a,clipPath:s,component:l}=e,u=Fe(e,["zIndex","transform","transformOrigin","visibility","cursor","clipPath","component"]);Object.assign(t.attributes,u),r&&t.setAttribute("transform",r);ae(n)&&t.setAttribute("zIndex",n);i&&t.setAttribute("transformOrigin",i);o&&t.setAttribute("visibility",o);a&&t.setAttribute("cursor",a);s&&t.setAttribute("clipPath",s);l&&t.setAttribute("component",l)}(this,e),this.render(e,this),this.setVisibility()}bindEvents(){}getGraphicStyle(t){return function(t){const{x:e,y:n,z:r,class:i,className:o,transform:a,transformOrigin:s,zIndex:l,visibility:u}=t;return Fe(t,["x","y","z","class","className","transform","transformOrigin","zIndex","visibility"])}(t)}get compositeShapes(){return[["badges","badge-"],["ports","port-"]]}animate(t,e){if(0===t.length)return null;const n=[];if(void 0!==t[0].x||void 0!==t[0].y||void 0!==t[0].z){const{x:e=0,y:n=0,z:r=0}=this.attributes;t.forEach((t=>{const{x:i=e,y:o=n,z:a=r}=t;Object.assign(t,{transform:a?[["translate3d",i,o,a]]:[["translate",i,o]]})}))}const r=super.animate(t,e);if(r&&(Gd(this,r),n.push(r)),Array.isArray(t)&&t.length>0){const r=["transform","transformOrigin","x","y","z","zIndex"];if(Object.keys(t[0]).some((t=>!r.includes(t)))){Object.entries(this.shapeMap).forEach((([r,i])=>{const o=this[`get${de(r)}Style`];if(Ut(o)){const r=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t)))),a=i.animate(Pc(r),e);a&&(Gd(i,a),n.push(a))}}));const r=(r,i)=>{if(!Se(r)){const o=this[`get${de(i)}Style`];if(Ut(o)){const i=t.map((t=>o.call(this,Object.assign(Object.assign({},this.attributes),t))));Object.entries(i[0]).map((([t])=>{const o=i.map((e=>e[t])),a=r[t];if(a){const t=a.animate(Pc(o),e);t&&(Gd(a,t),n.push(t))}}))}}};this.compositeShapes.forEach((([t,e])=>{const n=Pd(this.shapeMap,e);r(n,t)}))}}return Ac(n)}getShape(t){return this.shapeMap[t]}setVisibility(){const{visibility:t}=this.attributes;Ah(this,t)}destroy(){this.shapeMap={},this.animateMap={},super.destroy()}}function Gd(t,e){null==e||e.finished.then((()=>{const n=t.activeAnimations.findIndex((t=>t===e));n>-1&&t.activeAnimations.splice(n,1)}))}function Vd(t){if(!t)return{};if("x"in t||"y"in t||"z"in t){const{x:e=0,y:n=0,z:r,transform:i}=t,o=_c(e,n,r,i);o&&(t.transform=o)}return t}class Wd extends zd{constructor(t){super(_d({style:Wd.defaultStyleProps},t))}isTextStyle(t){return Td(t,"label")}isBackgroundStyle(t){return Td(t,"background")}getTextStyle(t){const e=this.getGraphicStyle(t),{padding:n}=e;return Rd(Fe(e,["padding"]),"background")}getBackgroundStyle(t){if(!1===t.background)return!1;const e=this.getGraphicStyle(t),{wordWrap:n,wordWrapWidth:r,padding:i}=e,o=Ad(e,"background"),{min:[a,s],center:[l,u],halfExtents:[c,h]}=this.shapeMap.text.getGeometryBounds(),[d,f,p,g]=Uc(i),v=2*c+g+f,{width:m,height:y}=o;m&&y?Object.assign(o,{x:l-Number(m)/2,y:u-Number(y)/2}):Object.assign(o,{x:a-g,y:s-d,width:n?Math.min(v,r+g+f):v,height:2*h+d+p});const{radius:b}=o;if("string"==typeof b&&b.endsWith("%")){const t=Number(b.replace("%",""))/100;o.radius=Math.min(+o.width,+o.height)*t}return o}render(t=this.parsedAttributes,e=this){this.upsert("text",Zl,this.getTextStyle(t),e),this.upsert("background",Xl,this.getBackgroundStyle(t),e)}getGeometryBounds(){return(this.getShape("background")||this.getShape("text")).getGeometryBounds()}}Wd.defaultStyleProps={padding:0,fontSize:12,fontFamily:"system-ui, sans-serif",wordWrap:!0,maxLines:1,wordWrapWidth:128,textOverflow:"...",textBaseline:"middle",backgroundOpacity:.75,backgroundZIndex:-1,backgroundLineWidth:0};class Hd extends zd{constructor(t){super(_d({style:Hd.defaultStyleProps},t))}getBadgeStyle(t){return this.getGraphicStyle(t)}render(t=this.parsedAttributes,e=this){this.upsert("label",Wd,this.getBadgeStyle(t),e)}getGeometryBounds(){const t=this.getShape("label");return(t.getShape("background")||t.getShape("text")).getGeometryBounds()}}Hd.defaultStyleProps={padding:[2,4,2,4],fontSize:10,wordWrap:!1,backgroundRadius:"50%",backgroundOpacity:1};const Ud={M:["x","y"],m:["dx","dy"],H:["x"],h:["dx"],V:["y"],v:["dy"],L:["x","y"],l:["dx","dy"],Z:[],z:[],C:["x1","y1","x2","y2","x","y"],c:["dx1","dy1","dx2","dy2","dx","dy"],S:["x2","y2","x","y"],s:["dx2","dy2","dx","dy"],Q:["x1","y1","x","y"],q:["dx1","dy1","dx","dy"],T:["x","y"],t:["dx","dy"],A:["rx","ry","rotation","large-arc","sweep","x","y"],a:["rx","ry","rotation","large-arc","sweep","dx","dy"]};function $d(t){const e=[],n="string"==typeof t?function(t){const e=t.replace(/[\n\r]/g,"").replace(/-/g," -").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ").trim().split(/\s*,|\s+/),n=[];let r="",i={};for(;e.length>0;){let t=e.shift();t in Ud?r=t:e.unshift(t),i={type:r},Ud[r].forEach((n=>{t=e.shift(),i[n]=t})),"M"===r?r="L":"m"===r&&(r="l");const[o,...a]=Object.values(i);n.push([o,...a.map(Number)])}return n}(t):t;return n.forEach((t=>{const n=t[0];if("Z"!==n)if("A"!==n)for(let n=1;n<t.length;n+=2)e.push([t[n],t[n+1],0]);else{const n=t.length;e.push([t[n-2],t[n-1],0])}else e.push(e[0])})),e}const Yd=t=>{if(t.length<2)return[["M",0,0],["L",0,0]];const e=t[0],n=t[1],r=t[t.length-1],i=t[t.length-2];t.unshift(i,r),t.push(e,n);const o=[["M",r[0],r[1]]];for(let e=1;e<t.length-2;e+=1){const[n,r]=t[e-1],[i,a]=t[e],[s,l]=t[e+1],[u,c]=e!==t.length-2?t[e+2]:[s,l],h=i+(s-n)/6,d=a+(l-r)/6,f=s-(u-i)/6,p=l-(c-a)/6;o.push(["C",h,d,f,p,s,l])}return o};class qd extends zd{constructor(t){super(_d({style:qd.defaultStyleProps},t))}getLabelStyle(t){if(!t.label||!t.d||0===t.d.length)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{maxWidth:n,offsetX:r,offsetY:i,autoRotate:o,placement:a,closeToPath:s}=e,l=Fe(e,["maxWidth","offsetX","offsetY","autoRotate","placement","closeToPath"]),u=this.shapeMap.key,c=null==u?void 0:u.getRenderBounds();return Object.assign(function(t,e,n,r,i,o,a){const[s,l]=ed(t,e),u={textAlign:"left"===e?"right":"right"===e?"left":"center",textBaseline:"top"===e?"bottom":"bottom"===e?"top":"middle",transform:[["translate",s+n,l+r]]};if("center"===e||!i)return u;const c=$d(o);if(!c||c.length<=3)return u;const h=c.map(((t,e)=>{const n=t,r=c[(e+1)%c.length];return Ne(n,r)?null:[n,r]})).filter(Boolean),d=hd([s,l],h),f=dd([s,l],d);if(f&&d&&(u.transform=[["translate",f[0]+n,f[1]+r]],a)){const t=Math.atan((d[0][1]-d[1][1])/(d[0][0]-d[1][0]));u.transform.push(["rotate",t/Math.PI*180]),u.textAlign="center","right"!==e&&"left"!==e||(u.textBaseline=t>0?"right"===e?"bottom":"top":"right"===e?"top":"bottom")}return u}(c,a,r,i,s,t.d,o),{wordWrapWidth:Fd(c,n)},l)}getKeyStyle(t){return this.getGraphicStyle(t)}render(t,e){this.upsert("key",Hl,this.getKeyStyle(t),e),this.upsert("label",Wd,this.getLabelStyle(t),e)}}qd.defaultStyleProps={label:!0,labelPlacement:"bottom",labelCloseToPath:!0,labelAutoRotate:!0,labelOffsetX:0,labelOffsetY:0};let Xd=class extends zl{constructor(t){super(t),this.onMounted=()=>{this.handleRadius()},this.onAttrModified=()=>{this.handleRadius()},Zd=this,this.isMutationObserved=!0,this.addEventListener(Vs.MOUNTED,this.onMounted),this.addEventListener(Vs.ATTR_MODIFIED,this.onAttrModified)}handleRadius(){const{radius:t,clipPath:e,width:n=0,height:r=0}=this.attributes;if(t&&n&&r){const[i,o]=this.getBounds().min,a={x:i,y:o,radius:t,width:n,height:r};if(e)Object.assign(this.parsedStyle.clipPath.style,a);else{const t=new Xl({style:a});this.style.clipPath=t}}else e&&(this.style.clipPath=null)}};const Kd=new WeakMap;let Zd=null;const Qd=t=>{if(Zd&&function(t){const e=[];let n=t.parentNode;for(;n;)e.push(n),n=n.parentNode;return e}(Zd).includes(t)){const e=Kd.get(t);e?e.includes(Zd)||e.push(Zd):Kd.set(t,[Zd])}},Jd=t=>{const e=Kd.get(t);e&&e.forEach((t=>t.handleRadius()))};class tf extends zd{constructor(t){super(t)}isImage(){const{src:t}=this.attributes;return!!t}getIconStyle(t=this.attributes){const{width:e=0,height:n=0}=t,r=this.getGraphicStyle(t);return this.isImage()?Object.assign({x:-e/2,y:-n/2},r):Object.assign({textBaseline:"middle",textAlign:"center"},r)}render(t=this.attributes,e=this){this.upsert("icon",this.isImage()?Xd:Zl,this.getIconStyle(t),e)}}class ef extends zd{get context(){return this.config.context}get parsedAttributes(){return this.attributes}onframe(){}animate(t,e){const n=super.animate(t,e);return n&&(n.onframe=()=>this.onframe(),n.finished.then((()=>this.onframe()))),n}}class nf extends ef{constructor(t){super(_d({style:nf.defaultStyleProps},t)),this.type="node"}getSize(t=this.attributes){const{size:e}=t;return Dd(e)}getKeyStyle(t){const e=this.getGraphicStyle(t);return Object.assign(Rd(e,["label","halo","icon","badge","port"]))}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{placement:n,maxWidth:r,offsetX:i,offsetY:o}=e,a=Fe(e,["placement","maxWidth","offsetX","offsetY"]),s=this.getShape("key").getLocalBounds();return Object.assign(Lg(s,n,i,o),{wordWrapWidth:Fd(s,r)},a)}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),{fill:n}=e,r=Fe(e,["fill"]),i=Ad(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign(Object.assign({},r),{stroke:n}),i)}getIconStyle(t){if(!1===t.icon||!t.iconText&&!t.iconSrc)return!1;const e=Ad(this.getGraphicStyle(t),"icon");return Object.assign(function(t,e){const n=Dd(t);let r={};return e.text&&!e.fontSize&&(r={fontSize:.5*Math.min(...n)}),!e.src||e.width&&e.height||(r={width:.5*n[0],height:.5*n[1]}),r}(t.size,e),e)}getBadgesStyle(t){var e;const n=Pd(this.shapeMap,"badge-"),r={};if(Object.keys(n).forEach((t=>{r[t]=!1})),!1===t.badge||!(null===(e=t.badges)||void 0===e?void 0:e.length))return r;const{badges:i=[],badgePalette:o,opacity:a=1}=t,s=Fe(t,["badges","badgePalette","opacity"]),l=jd(o),u=Ad(this.getGraphicStyle(s),"badge");return i.forEach(((t,e)=>{r[e]=Object.assign(Object.assign({backgroundFill:l?l[e%(null==l?void 0:l.length)]:void 0,opacity:a},u),this.getBadgeStyle(t))})),r}getBadgeStyle(t){const e=this.getShape("key"),{placement:n="top",offsetX:r,offsetY:i}=t,o=Fe(t,["placement","offsetX","offsetY"]),a=Lg(e.getLocalBounds(),n,r,i,!0);return Object.assign(Object.assign({},a),o)}getPortsStyle(t){var e;const n=this.getPorts(),r={};if(Object.keys(n).forEach((t=>{r[t]=!1})),!1===t.port||!(null===(e=t.ports)||void 0===e?void 0:e.length))return r;const i=Ad(this.getGraphicStyle(t),"port"),{ports:o=[]}=t;return o.forEach(((e,n)=>{const o=e.key||n,a=Object.assign(Object.assign({},i),e);if(Tg(a))r[o]=!1;else{const[n,i]=this.getPortXY(t,e);r[o]=Object.assign({transform:[["translate",n,i]]},a)}})),r}getPortXY(t,e){const{placement:n="left"}=e,r=this.getShape("key");return Ng(function(t,e){if(!t)return e.getLocalBounds();const n=t.canvas.getLayer(),r=e.cloneNode();Ah(r,"hidden"),n.appendChild(r);const i=r.getLocalBounds();return r.destroy(),i}(this.context,r),n)}getPorts(){return Pd(this.shapeMap,"port-")}getCenter(){return this.getShape("key").getBounds().center}getIntersectPoint(t,e=!1){return function(t,e,n=!1){return ud(t,ed(e,"center"),[ed(e,"left-top"),ed(e,"right-top"),ed(e,"right-bottom"),ed(e,"left-bottom")],!1,n).point}(t,this.getShape("key").getBounds(),e)}drawHaloShape(t,e){const n=this.getHaloStyle(t),r=this.getShape("key");this.upsert("halo",r.constructor,n,e)}drawIconShape(t,e){const n=this.getIconStyle(t);this.upsert("icon",tf,n,e),Qd(this)}drawBadgeShapes(t,e){const n=this.getBadgesStyle(t);Object.keys(n).forEach((t=>{const r=n[t];this.upsert(`badge-${t}`,Hd,r,e)}))}drawPortShapes(t,e){const n=this.getPortsStyle(t);Object.keys(n).forEach((t=>{const r=n[t],i=`port-${t}`;this.upsert(i,Dl,r,e)}))}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Wd,n,e)}_drawKeyShape(t,e){return this.drawKeyShape(t,e)}render(t=this.parsedAttributes,e=this){this._drawKeyShape(t,e),this.getShape("key")&&(this.drawHaloShape(t,e),this.drawIconShape(t,e),this.drawBadgeShapes(t,e),this.drawLabelShape(t,e),this.drawPortShapes(t,e))}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Jd(this)}onframe(){this.drawBadgeShapes(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this)}}nf.defaultStyleProps={x:0,y:0,size:32,droppable:!0,draggable:!0,port:!0,ports:[],portZIndex:2,portLinkToCenter:!1,badge:!0,badges:[],badgeZIndex:3,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloStrokeOpacity:.25,haloPointerEvents:"none",haloZIndex:-1,icon:!0,iconZIndex:1,label:!0,labelIsBillboard:!0,labelMaxWidth:"200%",labelPlacement:"bottom",labelWordWrap:!1,labelZIndex:0};let rf=class t extends nf{constructor(e){super(_d({style:t.defaultStyleProps},e))}drawKeyShape(t,e){return this.upsert("key",Dl,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{r:Math.min(...this.getSize(t))/2})}getIconStyle(t){const e=super.getIconStyle(t),{r:n}=this.getShape("key").attributes,r=2*n*xd;return!!e&&Object.assign({width:r,height:r},e)}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}};rf.defaultStyleProps={size:32};class of extends nf{constructor(t){super(t)}get parsedAttributes(){return this.attributes}drawKeyShape(t,e){return this.upsert("key",$l,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t);return Object.assign(Object.assign({},e),{points:this.getPoints(t)})}getIntersectPoint(t,e=!1){var n,r;const{points:i}=this.getShape("key").attributes;return ud(t,[+((null===(n=this.attributes)||void 0===n?void 0:n.x)||0),+((null===(r=this.attributes)||void 0===r?void 0:r.y)||0)],i,!0,e).point}}class af extends of{constructor(t){super(t)}getPoints(t){const[e,n]=this.getSize(t);return function(t,e){return[[0,-e/2],[t/2,0],[0,e/2],[-t/2,0]]}(e,n)}}class sf extends rf{constructor(t){super(_d({style:sf.defaultStyleProps},t))}parseOuterR(){const{size:t}=this.parsedAttributes;return Math.min(...Dd(t))/2}parseInnerR(){const{innerR:t}=this.parsedAttributes;return ne(t)?parseInt(t)/100*this.parseOuterR():t}drawDonutShape(t,e){const{donuts:n}=t;if(!(null==n?void 0:n.length))return;const r=n.map((t=>ae(t)?{value:t}:t)),i=Ad(this.getGraphicStyle(t),"donut"),o=jd(t.donutPalette);if(!o)return;const a=r.reduce(((t,e)=>{var n;return t+(null!==(n=e.value)&&void 0!==n?n:0)}),0),s=this.parseOuterR(),l=this.parseInnerR();let u=0;r.forEach(((t,n)=>{const{value:c=0,color:h=o[n%o.length]}=t,d=Fe(t,["value","color"]),f=360*(0===a?1/r.length:c/a);this.upsert(`round${n}`,Hl,Object.assign(Object.assign(Object.assign({},i),{d:uf(s,l,u,u+f),fill:h}),d),e),u+=f}))}render(t,e=this){super.render(t,e),this.drawDonutShape(t,e)}}sf.defaultStyleProps={innerR:"50%",donuts:[],donutPalette:"tableau"};const lf=(t,e,n,r)=>[t+Math.sin(r)*n,e-Math.cos(r)*n],uf=(t=0,e=0,n,r)=>{const[i,o]=[0,0];return Math.abs(n-r)%360<1e-6?((t,e,n,r)=>r<=0||n<=r?[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"]]:[["M",t-n,e],["A",n,n,0,1,1,t+n,e],["A",n,n,0,1,1,t-n,e],["Z"],["M",t+r,e],["A",r,r,0,1,0,t-r,e],["A",r,r,0,1,0,t+r,e],["Z"]])(i,o,t,e):((t,e,n,r,i,o)=>{const[a,s]=[i/360*2*Math.PI,o/360*2*Math.PI],l=[lf(t,e,r,a),lf(t,e,n,a),lf(t,e,n,s),lf(t,e,r,s)],u=s-a>Math.PI?1:0;return[["M",l[0][0],l[0][1]],["L",l[1][0],l[1][1]],["A",n,n,0,u,1,l[2][0],l[2][1]],["L",l[3][0],l[3][1]],["A",r,r,0,u,0,l[0][0],l[0][1]],["Z"]]})(i,o,t,e,n,r)};class cf extends nf{constructor(t){super(_d({style:cf.defaultStyleProps},t))}drawKeyShape(t,e){return this.upsert("key",Il,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getSize(t);return Object.assign(Object.assign({},e),{rx:n/2,ry:r/2})}getIconStyle(t){const e=super.getIconStyle(t),{rx:n,ry:r}=this.getShape("key").attributes,i=2*Math.min(+n,+r)*xd;return!!e&&Object.assign({width:i,height:i},e)}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}}cf.defaultStyleProps={size:[45,35]};class hf extends of{constructor(t){super(t)}getOuterR(t){return t.outerR||Math.min(...this.getSize(t))/2}getPoints(t){return[[0,e=this.getOuterR(t)],[e*Math.sqrt(3)/2,e/2],[e*Math.sqrt(3)/2,-e/2],[0,-e],[-e*Math.sqrt(3)/2,-e/2],[-e*Math.sqrt(3)/2,e/2]];var e}getIconStyle(t){const e=super.getIconStyle(t),n=this.getOuterR(t)*xd;return!!e&&Object.assign({width:n,height:n},e)}}
|
|
27
27
|
/*!
|
|
28
28
|
* @antv/g-plugin-canvas-path-generator
|
|
29
29
|
* @description A G plugin of path generator with Canvas2D API
|
|
@@ -71,7 +71,7 @@ var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).
|
|
|
71
71
|
* @date 5/9/2025, 8:22:49 AM
|
|
72
72
|
* @author AntVis
|
|
73
73
|
* @docs https://g.antv.antgroup.com/
|
|
74
|
-
*/class Np extends nf{constructor(t){super(Object.assign(Object.assign({},t),{style:Object.assign({},Np.defaultStyleProps,t.style)})),this.rootPointerEvent=new As(null),this.forwardEvents=t=>{const e=this.context.canvas,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach((r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);Te(e.context.eventService,"mappingTable.pointerupoutside",[]),e.context.eventService.mapEvent(i)}))}}get eventService(){return this.context.canvas.context.eventService}get events(){return[t.CommonEvent.CLICK,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_UP,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE]}getDomElement(){return this.getShape("key").getDomElement()}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.drawPortShapes(t,e)}getKeyStyle(t){const e=Ae(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Fe(e,["dx","dy"]),[o,a]=this.getSize(t);return Object.assign(Object.assign({x:n,y:r},i),{width:o,height:a})}drawKeyShape(t,e){const n=this.getKeyStyle(t),{x:r,y:i,width:o=0,height:a=0}=n,s=this.upsert("key-container",Xl,{x:r,y:i,width:o,height:a,opacity:0},e);return this.upsert("key",Fl,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof Sp))return;const t=this.getDomElement();this.events.forEach((e=>{t.addEventListener(e,this.forwardEvents)}))}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}destroy(){const t=this.getDomElement();this.events.forEach((e=>{t.removeEventListener(e,this.forwardEvents)})),super.destroy()}normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;e<t.changedTouches.length;e++){const r=t.changedTouches[e];ve(r.button)&&(r.button=0),ve(r.buttons)&&(r.buttons=1),ve(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),ve(r.width)&&(r.width=r.radiusX||1),ve(r.height)&&(r.height=r.radiusY||1),ve(r.tiltX)&&(r.tiltX=0),ve(r.tiltY)&&(r.tiltY=0),ve(r.pointerType)&&(r.pointerType="touch"),ve(r.pointerId)&&(r.pointerId=r.identifier||0),ve(r.pressure)&&(r.pressure=r.force||.5),ve(r.twist)&&(r.twist=0),ve(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;ve(e.isPrimary)&&(e.isPrimary=!0),ve(e.width)&&(e.width=1),ve(e.height)&&(e.height=1),ve(e.tiltX)&&(e.tiltX=0),ve(e.tiltY)&&(e.tiltY=0),ve(e.pointerType)&&(e.pointerType="mouse"),ve(e.pointerId)&&(e.pointerId=1),ve(e.pressure)&&(e.pressure=.5),ve(e.twist)&&(e.twist=0),ve(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}bootstrapEvent(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const[a,s]=this.context.canvas.getCanvasByViewport([i,o]);return t.canvas.x=a,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:a}=t;if($t(r)||$t(i)){const t=this.eventService.client2Viewport({x:o,y:a});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}onframe(){super.onframe();const{opacity:t}=this.attributes;this.getDomElement().style.opacity=`${t}`}}Np.defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};let Op=class t extends nf{constructor(e){super(_d({style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),r=super.getKeyStyle(t),{fillOpacity:i,opacity:o=i}=r,a=Fe(r,["fillOpacity","opacity"]);return Object.assign(Object.assign({opacity:o},a),{width:e,height:n,x:-e/2,y:-n/2})}getBounds(){return this.getShape("key").getBounds()}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getShape("key").attributes,{fill:n,stroke:r}=e;Fe(e,["fill","stroke"]);const i=Ad(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=Ih(this.getSize(t),[o,o]),{lineWidth:l}=i,u={fill:"transparent",lineWidth:l/2,width:a-l/2,height:s-l/2,x:-(a-l/2)/2,y:-(s-l/2)/2};return Object.assign(Object.assign({},i),u)}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&Object.assign({width:n*xd,height:r*xd},e)}drawKeyShape(t,e){const n=this.upsert("key",Xd,this.getKeyStyle(t),e);return Qd(this),n}drawHaloShape(t,e){this.upsert("halo",Xl,this.getHaloStyle(t),e)}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Jd(this)}};Op.defaultStyleProps={size:32};class Tp extends nf{constructor(t){super(t)}getKeyStyle(t){const[e,n]=this.getSize(t);return Object.assign(Object.assign({},super.getKeyStyle(t)),{width:e,height:n,x:-e/2,y:-n/2})}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getShape("key").attributes;return!!e&&Object.assign({width:n*xd,height:r*xd},e)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}}class Cp extends of{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*xd;return!!e&&Object.assign({width:n,height:n},e)}getPortXY(t,e){const{placement:n="top"}=e;return Ng(this.getShape("key").getLocalBounds(),n,function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t)),!1)}}class Ap extends of{constructor(t){super(_d({style:Ap.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getShape("key").getLocalBounds(),[o,a]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,a,n);return Ng(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||Se(n||r))return!1;const o=Ad(this.getGraphicStyle(t),"icon"),a=this.getShape("key").getLocalBounds(),[s,l]=function(t,e){const{center:n}=t,[r,i]=Xc(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(a,i),u=2*function(t,e){let[n,r]=Xc(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(Math.pow(r,2)-Math.pow(Math.sqrt(Math.pow(n/2,2)+Math.pow(r,2))-n/2,2))/(2*r)}(a,i)*xd;return Object.assign({x:s,y:l,width:u,height:u},o)}}Ap.defaultStyleProps={size:40,direction:"up"};class Pp extends nf{constructor(t){super(_d({style:Pp.defaultStyleProps},t)),this.type="combo",this.updateComboPosition(this.parsedAttributes)}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,a]=Uc(e);return Ih(Dd(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Dd(t.collapsedSize)}getExpandedKeySize(t){const e=this.getContentBBox(t);return[Yc(e),qc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=e.map((t=>this.context.element.getElement(t))).filter(Boolean);if(0===r.length){const e=new fr,{x:n=0,y:r=0,size:i}=t,[o,a]=Dd(i);return e.setMinMax([n-o/2,r-a/2,0],[n+o/2,r+a/2,0]),e}const i=Jc(r.map((t=>t.getBounds())));return n?Qc(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",tf,n,e),Qd(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Ad(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Fe(e,["type"]),i=this.getShape("key"),[o,a]=ed(i.getLocalBounds(),"center"),s=Object.assign(Object.assign({},r),{x:o,y:a});if(n){const e=this.getCollapsedMarkerText(n,t);Object.assign(s,{text:e})}return s}getCollapsedMarkerText(t,e){const{childrenData:n=[]}=e,{model:r}=this.context;return"descendant-count"===t?r.getDescendantsData(this.id).length.toString():"child-count"===t?n.length.toString():"node-count"===t?r.getDescendantsData(this.id).filter((t=>"node"===r.getElementType(yh(t)))).length.toString():Ut(t)?t(n):""}getComboPosition(t){const{x:e=0,y:n=0,collapsed:r,childrenData:i=[]}=t;if(0===i.length)return[+e,+n,0];if(r){const{model:t}=this.context,r=t.getDescendantsData(this.id).filter((e=>!t.isCombo(yh(e))));if(r.length>0&&r.some(td)){return Fh(r.reduce(((t,e)=>Ih(t,Jh(e))),[0,0,0]),r.length)}return[+e,+n,0]}return this.getContentBBox(t).center}getComboStyle(t){const[e,n]=this.getComboPosition(t);return{x:e,y:n,transform:[["translate",e,n]]}}updateComboPosition(t){const e=this.getComboStyle(t);Object.assign(this.style,e);const{x:n,y:r}=e;this.context.model.syncNodeLikeDatum({id:this.id,style:{x:n,y:r}}),Jd(this)}render(t,e=this){super.render(t,e),this.drawCollapsedMarkerShape(t,e)}update(t={}){super.update(t),this.updateComboPosition(this.parsedAttributes)}onframe(){super.onframe(),this.attributes.collapsed||this.updateComboPosition(this.parsedAttributes),this.drawKeyShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(this.attributes.collapsed?t:t.map((t=>{var{x:e,y:n,z:r,transform:i}=t;return Fe(t,["x","y","z","transform"])})),e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then((()=>this.onframe())),Reflect.set(t,e,n))}):n}}Pp.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Rp extends Pp{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Dl,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),[r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},n),e&&Ad(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=Dd(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=Xc(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}}class Dp extends Pp{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},e),t.collapsed&&Ad(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const Lp={padding:10};function _p(t,e,n,r,i,o){const{padding:a}=Object.assign(Lp,o),s=Kc(n,a),l=Kc(r,a),u=[t,...i,e];let c=null;const h=[];for(let t=0,e=u.length;t<e-1;t++){const n=t+1,r=u[t],i=u[n],o=ad(d=r,f=i)||function(t,e){return t[0]===e[0]}(d,f);let p=null;if(0===t)if(n===e-1)if(s.intersects(l))p=Hp(r,i,s,l);else if(nh(r,s)||nh(i,l))o||(p=Wp(r,i,s,l));else{const t=ih(r,s),e=ih(i,l);p=zp(t,e,Bp(t,e)),p.points.unshift(t),p.points.push(e)}else th(i,s)?p=Hp(r,i,s,Kc(i,a),c):o||(p=Gp(r,i,s));else n===e-1?th(r,l)?p=Hp(r,i,Kc(r,a),l,c):o||(p=Vp(r,i,l,c)):o||(p=zp(r,i,c));p?(h.push(...p.points),c=p.direction):c=Bp(r,i),n<e-1&&h.push(i)}var d,f;return h.map(Yh)}const Ip={N:"S",S:"N",W:"E",E:"W"},jp={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Bp(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function Fp(t,e){return"N"===e||"S"===e?qc(t):Yc(t)}function zp(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Bp(t,r),a=Bp(t,i),s=n?Ip[n]:null,l=o===n||o!==s&&a!==n?r:i;return{points:[l],direction:Bp(l,e)}}function Gp(t,e,n){if(nh(t,n)){const r=Up(t,e,n);return{points:[r],direction:Bp(r,e)}}{const r=ih(t,n),i=["left","right"].includes(rh(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:Bp(i,e)}}}function Vp(t,e,n,r){const i=nh(e,n)?e:ih(e,n),o=[[i[0],t[1]],[t[0],i[1]]],a=o.filter((t=>function(t,e){return!th(t,e)}(t,n)&&!eh(t,n,!0))),s=a.filter((e=>Bp(e,t)!==r));if(s.length>0){const n=s.find((e=>Bp(t,e)===r))||s[0];return{points:[n],direction:Bp(n,e)}}{const i=od(e,Ht(o,a)[0],Fp(n,r)/2);return{points:[Up(i,t,n),i],direction:Bp(i,e)}}}function Wp(t,e,n,r){let i=Gp(t,e,n);const o=qh(i.points[0]);if(th(o,r)){i=Gp(e,t,r);const a=qh(i.points[0]);if(th(a,n)){const s=od(t,o,Fp(n,Bp(t,o))/2),l=od(e,a,Fp(r,Bp(e,a))/2),u=[(s[0]+l[0])/2,(s[1]+l[1])/2],c=Gp(t,u,n),h=Vp(u,e,r,c.direction);i.points=[c.points[0],h.points[0]],i.direction=h.direction}}return i}function Hp(t,e,n,r,i){const o=Jc([n,r]),a=Gh(e,o.center)>Gh(t,o.center),[s,l]=a?[e,t]:[t,e],u=qc(o)+Yc(o);let c;if(i){const t=[s[0]+u*Math.cos(jp[i]),s[1]+u*Math.sin(jp[i])];c=od(ih(t,o),t,.01)}else c=od(ih(s,o),s,-.01);let h=Up(c,l,o),d=[id(c,2),id(h,2)];if(Ne(id(c),id(h))){const t=Hh(jh(c,s),[1,0,0])+Math.PI/2;h=[l[0]+u*Math.cos(t),l[1]+u*Math.sin(t),0],h=id(od(ih(h,o),l,-.01),2);d=[c,Up(c,h,o),h]}return{points:a?d.reverse():d,direction:Bp(a?c:h,e)}}function Up(t,e,n){let r=[t[0],e[1]];return th(r,n)&&(r=[e[0],t[1]]),r}function $p(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=nd(t.getPoint(o)),s=nd(t.getPoint(o+.01));let l="start"===e?"left":"end"===e?"right":"center";if(ad(a,s)||!n){const[e,n]=Yp(t,o,r,i);return{transform:[["translate",e,n]],textAlign:l}}let u=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(l="center"===l?l:"left"===l?"right":"left",r*=-1,u+=Math.PI);const[c,h]=Yp(t,o,r,i,u);return{textAlign:l,transform:[["translate",c,h],["rotate",u/Math.PI*180]]}}function Yp(t,e,n,r,i){const[o,a]=nd(t.getPoint(e));let s=n,l=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),l=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+l]}function qp(t,e,n,r){if(Ne(t,e))return t;const i=jh(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=Wh(Uh(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Xp(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function Kp(t,e=0,n=!1){const r=t.length-1,i=t[0],o=t[r],a=t.slice(1,r),s=[["M",i[0],i[1]]];return a.forEach(((t,n)=>{const r=a[n-1]||i,l=a[n+1]||o;if(!sd(r,t,l)&&e){const[n,i]=function(t,e,n,r){const i=Vh(t,e),o=Vh(n,e),a=Math.min(r,Math.min(i,o)/2),s=[e[0]-a/i*(e[0]-t[0]),e[1]-a/i*(e[1]-t[1])],l=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,l]}(r,t,l,e);s.push(["L",n[0],n[1]],["Q",t[0],t[1],i[0],i[1]],["L",i[0],i[1]])}else s.push(["L",t[0],t[1]])})),s.push(["L",o[0],o[1]]),n&&s.push(["Z"]),s}function Zp(t,e,n,r,i){const o=Kc(t),a=t.getCenter();let s=r&&Cg(r),l=i&&Cg(i);if(!s||!l){const r=(t=>{const e=Math.PI/2,n=qc(t)/2,r=Yc(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}})(o),i=r[e][0],u=r[e][1],[c,h]=Xc(o),d=Math.max(c,h),f=Ih(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Ih(a,[d*Math.cos(u),d*Math.sin(u),0]);s=Dg(t,f),l=Dg(t,p),n||([s,l]=[l,s])}return[s,l]}function Qp(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[l,u]=Zp(t,e,n,a,s);const c=function(t,e,n,r){const i=t.getCenter();if(Ne(e,n)){const t=jh(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Ih(e,o),Ih(n,Bh(o,[1,-1,1]))]}return[od(i,e,Gh(i,e)+r),od(i,n,Gh(i,n)+r)]}(t,l,u,r);return a&&(l=Rg(a,c[0])),s&&(u=Rg(s,c.at(-1))),Xp(l,u,c)}function Jp(t,e,n,r,i,o,a){const s=Og(t),l=s[o||a],u=s[a||o];let[c,h]=Zp(t,n,r,l,u);const d=function(t,e,n,r){const i=[],o=Kc(t);if(Ne(e,n)){switch(rh(e,o)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=rh(e,o),a=rh(n,o);if(t===a){let o,a;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":a=Math.min(e[1],n[1])-r,i.push([e[0],a]),i.push([n[0],a]);break;case"bottom":a=Math.max(e[1],n[1])+r,i.push([e[0],a]),i.push([n[0],a])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),l=s(t,e),u=s(a,n),c=Up(l,u,o);i.push(l,c,u)}}return i}(t,c,h,i);return l&&(c=Rg(l,d[0])),u&&(h=Rg(u,d.at(-1))),Kp([c,...d,h],e)}function tg(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach((o=>{e(o).forEach((e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)}))})),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}function eg(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(yh(r));if(!t)break;r=t}if(n.some((t=>{var e;return null===(e=t.style)||void 0===e?void 0:e.collapsed}))){const t=n.reverse().findIndex(Od);return n[t]||n.at(-1)}return t}const ng=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var rg=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",-t/2,0],["A",n,n,0,1,0,2*n-t/2,0],["A",n,n,0,1,0,-t/2,0],["Z"]]},diamond:(t,e)=>[["M",-t/2,0],["L",0,-e/2],["L",t/2,0],["L",0,e/2],["Z"]],rect:(t,e)=>[["M",-t/2,-e/2],["L",t/2,-e/2],["L",t/2,e/2],["L",-t/2,e/2],["Z"]],simple:(t,e)=>[["M",t/2,-e/2],["L",-t/2,0],["L",t/2,0],["L",-t/2,0],["L",t/2,e/2]],triangle:ng,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",-n,0],["L",0,-e/2],["L",0,e/2],["Z"],["M",i-n,-e/2],["L",i+r-n,-e/2],["L",i+r-n,e/2],["L",i-n,e/2],["Z"]]},vee:(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",4*t/5-t/2,0],["L",t/2,e/2],["Z"]]});class ig extends ef{constructor(t){super(_d({style:ig.defaultStyleProps},t)),this.type="edge"}get sourceNode(){const{sourceNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}get targetNode(){const{targetNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}getKeyStyle(t){const e=this.getGraphicStyle(t),{loop:n}=e,r=Fe(e,["loop"]),{sourceNode:i,targetNode:o}=this;var a,s;const l={d:n&&(s=o,(a=i)&&s&&a===s)?this.getLoopPath(t):this.getKeyPath(t)};return Hl.PARSED_STYLE_LIST.forEach((t=>{t in r&&(l[t]=r[t])})),l}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=Kc(r),o=Math.max(Yc(i),qc(i)),{placement:a,clockwise:s,dist:l=o}=Ad(this.getGraphicStyle(t),"loop");return Qp(r,a,s,l,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:a}=this,[s,l]=function(t,e,n,r){const i=Ag(t,e,n,r),o=Ag(e,t,r,n);return[i,o]}(o,a,r,i);if(!e){return[s?Cg(s):o.getCenter(),l?Cg(l):a.getCenter()]}const u="function"==typeof n?n():n;return[Pg(s||o,u[0]||l||a),Pg(l||a,u[u.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Ad(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a}=e,s=Fe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),l=$p(this.shapeMap.key,n,o,r,i),u=this.shapeMap.key.getLocalBounds(),c=function(t,e,n=1){return Bd(Gh(t[0],t[1])*n,e)}([u.min,u.max],a);return Object.assign({wordWrapWidth:c},l,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Ad(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Fe(e,["offsetX","offsetY","placement"]);return Object.assign(o,function(t,e,n,r,i){var o,a;const s=2*(null===(o=t.badge)||void 0===o?void 0:o.getGeometryBounds().halfExtents[0])||0,l=2*(null===(a=t.label)||void 0===a?void 0:a.getGeometryBounds().halfExtents[0])||0;return $p(t.key,n,!0,(l?(l/2+s/2)*("suffix"===e?1:-1):0)+r,i)}(this.shapeMap,i,t.labelPlacement,n,r))}drawArrow(t,e){var n;const r="start"===e,i=t["start"===e?"startArrow":"endArrow"],o=this.shapeMap.key;if(i){const e=this.getArrowStyle(t,r),[n,i,a]=r?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],s=o.parsedStyle[n];if(s)s.attr(e);else{const t=new(e.src?zl:Hl)({style:e});o.style[n]=t}o.style[i]=t[a]||e.width/2+ +e.lineWidth}else{const t=r?"markerStart":"markerEnd";null===(n=o.style[t])||void 0===n||n.destroy(),o.style[t]=null}}getArrowStyle(t,e){const n=this.getShape("key").attributes,r=e?"startArrow":"endArrow",i=Ad(this.getGraphicStyle(t),r),{size:o,type:a}=i,s=Fe(i,["size","type"]),[l,u]=Dd(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),c=(Ut(a)?a:rg[a]||ng)(l,u);return Object.assign(Ae(n,["stroke","strokeOpacity","fillOpacity"]),{width:l,height:u},Object.assign({},c&&{d:c,fill:"simple"===a?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Wd,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",Hl,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",Hd,n,e)}drawSourceArrow(t){this.drawArrow(t,"start")}drawTargetArrow(t){this.drawArrow(t,"end")}drawKeyShape(t,e){const n=this.getKeyStyle(t);return this.upsert("key",Hl,n,e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.getShape("key")&&(this.drawSourceArrow(t),this.drawTargetArrow(t),this.drawLabelShape(t,e),this.drawHaloShape(t,e),this.drawBadgeShape(t,e))}onframe(){this.drawKeyShape(this.parsedAttributes,this),this.drawSourceArrow(this.parsedAttributes),this.drawTargetArrow(this.parsedAttributes),this.drawHaloShape(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this),this.drawBadgeShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(t,e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then((()=>this.onframe())),Reflect.set(t,e,n))}):n}}ig.defaultStyleProps={badge:!0,badgeOffsetX:0,badgeOffsetY:0,badgePlacement:"suffix",isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,loop:!0,startArrow:!1,startArrowLineDash:0,startArrowLineJoin:"round",startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"vee",endArrow:!1,endArrowLineDash:0,endArrowLineJoin:"round",endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"vee",loopPlacement:"top",loopClockwise:!0};class og extends ig{constructor(t){super(_d({style:og.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,a=this.getControlPoints(e,n,function(t){return ae(t)?[t,1-t]:t}(i),function(t){return ae(t)?[t,-t]:t}(o),r);return Xp(e,n,a)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[qp(t,e,n[0],r[0]),qp(t,e,n[1],r[1])]}}og.defaultStyleProps={curvePosition:.5,curveOffset:20};class ag extends og{constructor(t){super(_d({style:ag.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}ag.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class sg extends og{constructor(t){super(_d({style:sg.defaultStyleProps},t))}get ref(){return this.context.model.getRootsData()[0]}getEndpoints(t){if(this.sourceNode.id===this.ref.id)return super.getEndpoints(t);const e=Jh(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=Jh(this.ref);return[Gh(t,e),Xh(jh(t,e))]}getControlPoints(t,e,n,r){const[i,o]=this.toRadialCoordinate(t),[a]=this.toRadialCoordinate(e),s=a-i;return[[t[0]+(s*n[0]+r[0])*Math.cos(o),t[1]+(s*n[0]+r[0])*Math.sin(o)],[e[0]-(s*n[1]-r[0])*Math.cos(o),e[1]-(s*n[1]-r[0])*Math.sin(o)]]}}sg.defaultStyleProps={curvePosition:.5,curveOffset:20};class lg extends og{constructor(t){super(_d({style:lg.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}lg.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let ug=class t extends ig{constructor(e){super(_d({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};ug.defaultStyleProps={};const cg={enableObstacleAvoidance:!1,offset:10,maxAllowedDirectionChange:Math.PI/2,maximumLoops:3e3,gridSize:5,startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{right:{stepX:1,stepY:0},left:{stepX:-1,stepY:0},bottom:{stepX:0,stepY:1},top:{stepX:0,stepY:-1}},penalties:{0:0,90:0},distFunc:Vh},hg=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function dg(t,e){const n=t=>Math.round(t/e);return ae(t)?n(t):t.map(n)}function fg(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function pg(t,e,n,r){const i=fg(t,e),o=n[hg(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(fg(o||r,t),i)}function gg(t,e,n){return Math.min(...e.map((e=>n(t,e))))}const vg=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,a=Qc(e.getRenderBounds(),o),s=Object.keys(i).reduce(((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=Xc(a),l=[t[0]+n.stepX*o,t[1]+n.stepY*s],u=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],a=[r,i],s=[r,n],l=[e,n];return[[o,a],[a,s],[s,l],[l,o]]}(a);for(let n=0;n<u.length;n++){const r=Zh([t,l],u[n]);r&&eh(r,a)&&e.push(r)}}return e}),[]);return th(t,a)||s.push(t),s.map((t=>dg(t,r.gridSize)))},mg=(t,e,n,r,i,o,a)=>{const s=[];let l=[o[0]===r[0]?r[0]:t[0]*a,o[1]===r[1]?r[1]:t[1]*a];s.unshift(l);let u=t,c=e[hg(u)];for(;c;){const t=c,r=u;pg(t,r,e,n)&&(l=[t[0]===r[0]?l[0]:t[0]*a,t[1]===r[1]?l[1]:t[1]*a],s.unshift(l)),c=e[hg(t)],u=t}const h=i.map((t=>[t[0]*a,t[1]*a])),d=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o<t.length;o++){const a=t[o],s=n(a,e);s<i&&(r=a,i=s)}return r}(h,l,Vh);return s.unshift(d),s};function yg(t,e,n,r){const i=Yh(t.getCenter()),o=Yh(e.getCenter()),a=Object.assign(cg,r),{gridSize:s}=a,l=((t,e)=>{const{offset:n,gridSize:r}=e,i={};return t.forEach((t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Qc(t.getRenderBounds(),n);for(let t=dg(e.min[0],r);t<=dg(e.max[0],r);t+=1)for(let n=dg(e.min[1],r);n<=dg(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0})),i})(a.enableObstacleAvoidance?n:[t,e],a),u=dg(i,s),c=dg(o,s),h=vg(i,t,a.startDirections,a),d=vg(o,e,a.endDirections,a);h.forEach((t=>delete l[hg(t)])),d.forEach((t=>delete l[hg(t)]));const f={},p={},g={},v={},m={},y=new bg;for(let t=0;t<h.length;t++){const e=h[t],n=hg(e);f[n]=e,v[n]=0,m[n]=gg(e,d,a.distFunc),y.add({id:n,value:m[n]})}const b=d.map((t=>hg(t)));let x,E=a.maximumLoops,w=1/0;for(const[t,e]of Object.entries(f))m[t]<=w&&(w=m[t],x=e);for(;Object.keys(f).length>0&&E>0;){const t=y.minId(!1);if(!t)break;x=f[t];const e=hg(x);if(b.includes(e))return mg(x,g,u,o,h,c,s);delete f[e],y.remove(e),p[e]=!0;for(const t of Object.values(a.directionMap)){const n=Ih(x,[t.stepX,t.stepY]),r=hg(n);if(p[r])continue;const i=pg(x,n,g,u);if(i>a.maxAllowedDirectionChange)continue;if(l[r])continue;f[r]||(f[r]=n);const o=a.penalties[i],c=a.distFunc(x,n)+(isNaN(o)?s:o),h=v[e]+c,b=v[r];b&&h>=b||(g[r]=x,v[r]=h,m[r]=h+gg(n,d,a.distFunc),y.add({id:r,value:m[r]}))}E-=1}return[]}class bg{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){let n=0,r=e-1;for(;r-n>1;){const e=Math.floor((n+r)/2);if(this.arr[e].value>t.value)r=e;else{if(!(this.arr[e].value<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n=e}}this.arr.splice(r,0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;if(!e||this.arr[e-1].value<t.value)return this.arr.push(t),void(this.map[t.id]=!0);this._innerAdd(t,e)}remove(t){this.map[t]&&delete this.map[t]}_clearAndGetMinId(){let t;for(let e=this.arr.length-1;e>=0;e--)this.map[this.arr[e].id]?t=this.arr[e].id:this.arr.splice(e,1);return t}_findFirstId(){for(;this.arr.length;){const t=this.arr.shift();if(this.map[t.id])return t.id}}minId(t){return t?this._clearAndGetMinId():this._findFirstId()}}class xg extends ig{constructor(t){super(_d({style:xg.defaultStyleProps},t))}getControlPoints(t){const{router:e}=t,{sourceNode:n,targetNode:r}=this,[i,o]=this.getEndpoints(t,!1);let a=[];if(e)if("shortest-path"===e.type){a=yg(n,r,this.context.element.getNodes(),e),a.length||(a=_p(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(a=_p(i,o,n,r,t.controlPoints,e));else a=t.controlPoints;return a}getPoints(t){const e=this.getControlPoints(t),[n,r]=this.getEndpoints(t,!0,e);return[n,...e,r]}getKeyPath(t){return Kp(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=Kc(i),a=Math.max(Yc(o),qc(o))/4,{placement:s,clockwise:l,dist:u=a}=Ad(this.getGraphicStyle(t),"loop");return Jp(i,r,s,l,u,e,n)}}xg.defaultStyleProps={radius:0,controlPoints:[],router:!1};class Eg extends ig{constructor(t){super(_d({style:Eg.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||qp(r,i,e,n))}}function wg(t){return t instanceof nf&&"node"===t.type}function kg(t){return t instanceof ig}function Mg(t){return t instanceof Pp}Eg.defaultStyleProps={curvePosition:.5,curveOffset:30};const Sg={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],"left-top":[0,0],"top-left":[0,0],"left-bottom":[0,1],"bottom-left":[0,1],"right-top":[1,0],"top-right":[1,0],"right-bottom":[1,1],"bottom-right":[1,1],default:[.5,.5]};function Ng(t,e,n=Sg,r=!0){const i=[.5,.5],o=ne(e)?Oe(n,e.toLocaleLowerCase(),i):e;if(!r&&ne(e))return o;const[a,s]=o||i;return[t.min[0]+Yc(t)*a,t.min[1]+qc(t)*s]}function Og(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{var i;const{key:o,placement:a}=n;Tg(n)&&(e[i=o||r]||(e[i]=ed(t.getShape("key").getBounds(),a)))})),e}function Tg(t){const{r:e}=t;return!e||0===Number(e)}function Cg(t){return Wc(t)?t:t.getPosition()}function Ag(t,e,n,r){const i=Og(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Cg(t))),s=function(t,e){const n=Og(t);if(e)return[Cg(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Cg(t))):[t.getCenter()]}(e,r),[l]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=Gh(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Cg(t)===l))}function Pg(t,e){return Mg(t)||wg(t)?Dg(t,e):Rg(t,e)}function Rg(t,e){if(!t||!e)return[0,0,0];if(Wc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return cd(Wc(e)?e:wg(e)?e.getCenter():e.getPosition(),t.getBounds())}function Dg(t,e){if(!t||!e)return[0,0,0];const n=Wc(e)?e:wg(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function Lg(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[a,s]=ed(t,e),[l,u]=i?["bottom","top"]:["top","bottom"];return{transform:[["translate",a+n,s+r]],textBaseline:o.includes("top")?u:o.includes("bottom")?l:"middle",textAlign:o.includes("left")?"right":o.includes("right")?"left":"center"}}function _g(t,e){"update"in t?t.update(e):t.attr(e)}function Ig(t){return Oe(t,"__to_be_destroyed__",!1)}class jg extends Dh{constructor(t,e){super(t,Object.assign({},jg.defaultOptions,e)),this.onCollapseExpand=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{target:e}=t;if(!(wg(n=e)||kg(n)||Mg(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,a=i.getElementDataById(r);if(!a)return!1;const{onCollapse:s,onExpand:l,animation:u,align:c}=this.options;Od(a)?(yield o.expandElement(r,{animation:u,align:c}),null==l||l(r)):(yield o.collapseElement(r,{animation:u,align:c}),null==s||s(r))})),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`node:${e}`,this.onCollapseExpand),t.on(`combo:${e}`,this.onCollapseExpand)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`node:${e}`,this.onCollapseExpand),t.off(`combo:${e}`,this.onCollapseExpand)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}jg.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const Bg="g6-create-edge-assist-node-id";class Fg extends Dh{constructor(t,e){super(t,Object.assign({},Fg.defaultOptions,e)),this.drop=t=>ze(this,void 0,void 0,(function*(){const{targetType:e}=t;["combo","node"].includes(e)&&this.source?yield this.handleCreateEdge(t):yield this.cancelEdge()})),this.handleCreateEdge=t=>ze(this,void 0,void 0,(function*(){var e,n,r;if(!this.validate(t))return;const{graph:i,canvas:o,batch:a,element:s}=this.context,{style:l}=this.options;if(this.source)return this.createEdge(t),void(yield this.cancelEdge());a.startBatch(),o.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0];const u=i.getElementData(this.source);i.addNodeData([{id:Bg,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=u.style)||void 0===e?void 0:e.x,y:null===(n=u.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:Bg,style:Object.assign({pointerEvents:"none"},l)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished})),this.updateAssistEdge=t=>ze(this,void 0,void 0,(function*(){var e;if(!this.source)return;const{model:n,element:r}=this.context;n.translateNodeTo(Bg,[t.canvas.x,t.canvas.y]),yield null===(e=r.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished})),this.createEdge=t=>{var e,n;const{graph:r}=this.context,{style:i,onFinish:o,onCreate:a}=this.options;if(void 0===(null===(e=t.target)||void 0===e?void 0:e.id)||void 0===this.source)return;const s=null===(n=this.getSelectedNodeIDs([t.target.id]))||void 0===n?void 0:n[0];var l;const u=a({id:`${this.source}-${s}-${De[l=l||"g"]?De[l]+=1:De[l]=1,l+De[l]}`,source:this.source,target:s,style:i});r.addEdgeData([u]),o(u)},this.cancelEdge=()=>ze(this,void 0,void 0,(function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([Bg]),this.source=void 0,yield null===(t=n.draw({animation:!1}))||void 0===t?void 0:t.finished,r.endBatch()})),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(t.NodeEvent.CLICK,this.handleCreateEdge),e.on(t.ComboEvent.CLICK,this.handleCreateEdge),e.on(t.CanvasEvent.CLICK,this.cancelEdge),e.on(t.EdgeEvent.CLICK,this.cancelEdge)):(e.on(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.on(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.CLICK,this.handleCreateEdge),e.off(t.ComboEvent.CLICK,this.handleCreateEdge),e.off(t.CanvasEvent.CLICK,this.cancelEdge),e.off(t.EdgeEvent.CLICK,this.cancelEdge),e.off(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.off(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}Fg.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class zg extends Dh{constructor(t,e){super(t,Object.assign({},zg.defaultOptions,e)),this.isDragging=!1,this.onDragStart=t=>{this.validate(t)&&(this.isDragging=!0,this.context.canvas.setCursor("grabbing"))},this.onDrag=t=>{var e,n,r,i;if(!this.isDragging||gd.isPinching)return;const o=null!==(n=null===(e=t.movement)||void 0===e?void 0:e.x)&&void 0!==n?n:t.dx,a=null!==(i=null===(r=t.movement)||void 0===r?void 0:r.y)&&void 0!==i?i:t.dy;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=ye((()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)}),300),this.shortcut=new md(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(qt(e)){const{up:t=[],down:n=[],left:r=[],right:i=[]}=e;this.shortcut.bind(t,(t=>this.onTranslate([0,1],t))),this.shortcut.bind(n,(t=>this.onTranslate([0,-1],t))),this.shortcut.bind(r,(t=>this.onTranslate([1,0],t))),this.shortcut.bind(i,(t=>this.onTranslate([-1,0],t)))}else{const{graph:e}=this.context;e.on(t.CommonEvent.DRAG_START,this.onDragStart),e.on(t.CommonEvent.DRAG,this.onDrag),e.on(t.CommonEvent.DRAG_END,this.onDragEnd)}}onTranslate(t,e){return ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(Bh(t,r),this.options.animation),this.invokeOnFinish()}))}translate(t,e){return ze(this,void 0,void 0,(function*(){t=this.clampByDirection(t),t=this.clampByRange(t),yield this.context.graph.translateBy(t,e)}))}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[a,s,l,u]=Uc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return"function"==typeof e?e(t):!!e}unbindEvents(){this.shortcut.unbindAll();const{graph:e}=this.context;e.off(t.CommonEvent.DRAG_START,this.onDragStart),e.off(t.CommonEvent.DRAG,this.onDrag),e.off(t.CommonEvent.DRAG_END,this.onDragEnd)}destroy(){this.shortcut.destroy(),this.unbindEvents(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}zg.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class Gg extends Dh{constructor(e,n){super(e,Object.assign({},Gg.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>ze(this,void 0,void 0,(function*(){var e;if("link"!==this.options.dropEffect)return;const{model:n,element:r}=this.context,i=t.target.id;this.target.forEach((t=>{const e=n.getParentData(t,Ec);e&&yh(e)===i&&n.refreshComboData(i),n.setParent(t,i,Ec)})),yield null===(e=null==r?void 0:r.draw({animation:!0}))||void 0===e?void 0:e.finished})),this.setCursor=e=>{if(this.isDragging)return;const{type:n}=e,{canvas:r}=this.context,{cursor:i}=this.options;n===t.CommonEvent.POINTER_ENTER?r.setCursor((null==i?void 0:i.grab)||"grab"):r.setCursor((null==i?void 0:i.default)||"default")},this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.addEventListener("blur",this.onDragEnd),r.addEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach((n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)})),["link"].includes(this.options.dropEffect)&&(e.on(t.ComboEvent.DROP,this.onDrop),e.on(t.CanvasEvent.DROP,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return Fh([t.dx,t.dy],e)}onDragStart(t){var e;if(this.enable=this.validate(t),!this.enable)return;const{batch:n,canvas:r,graph:i}=this.context;r.setCursor((null===(e=this.options.cursor)||void 0===e?void 0:e.grabbing)||"grabbing"),this.isDragging=!0,n.startBatch();const o=t.target.id;i.getElementState(o).includes(this.options.state)?this.target=this.getSelectedNodeIDs([o]):this.target=[o],this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target)}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){var t,e,n;if(!this.enable)return;if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=jh([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t,this.target);const{batch:r,canvas:i}=this.context;r.endBatch(),i.setCursor((null===(n=this.options.cursor)||void 0===n?void 0:n.grab)||"grab"),this.isDragging=!1,this.target=[]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}moveElement(t,e){return ze(this,void 0,void 0,(function*(){const{graph:n,model:r}=this.context,{dropEffect:i}=this.options;"move"===i&&t.forEach((t=>r.refreshComboData(t))),n.translateElementBy(Object.fromEntries(t.map((t=>[t,e]))),!1)}))}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=Ad(this.options,"shadow"),n=Jc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Xc(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr(Object.assign(Object.assign(Object.assign({},e),s),{visibility:"visible"})):(this.shadow=new Xl({style:Object.assign(Object.assign(Object.assign({$layer:"transient"},e),s),{pointerEvents:"none"})}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdge(){const{hideEdge:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(yh):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(yh))).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.removeEventListener("blur",this.onDragEnd),r.removeEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach((n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)})),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){var t;this.unbindEvents(),null===(t=this.shadow)||void 0===t||t.destroy(),super.destroy()}}Gg.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),dropEffect:"move",state:"selected",hideEdge:"none",shadow:!1,shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5],cursor:{default:"default",grab:"grab",grabbing:"grabbing"}};var Vg=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],a=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var a=r[o],s=a.callback;a.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};a(i),a(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function Wg(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach((n=>{e.has(n.id)||(e.add(n.id),t.push(n))}))}return!1}function Hg(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&Hg(i,e,n,r))return!0;return!1}const Ug=()=>!0;class $g{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||Ug,n=t.edgeFilter||Ug;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map((t=>t.id)))};updateCache=t=>{const e=new Set;t.forEach((t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach((t=>e.add(t.id))),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach((t=>e.add(t.id))),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)})),e.forEach((t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)}))};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach((n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}})),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Wg([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Hg(this.getNode(t),new Set,e,r)}}let Yg=class t extends Vg{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex((e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName))),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const n=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((n=>{n.childrenMap.get(t)?.forEach((t=>{n.parentMap.delete(t.id)}));const r=n.parentMap.get(t);r&&n.childrenMap.get(r.id)?.delete(e),n.parentMap.delete(t),n.childrenMap.delete(t)})),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateNodeDataProperty(t,e,n)}))}))}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})}))}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})}))}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateEdgeDataProperty(t,e,n)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach((t=>{t.children?.forEach((n=>{this.setParent(n.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n);if(!r)return;const i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(null==e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const a=this.getNode(e);r.parentMap.set(t,a),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(a.id);s||(s=new Set,r.childrenMap.set(a.id,s)),s.add(i),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:a.id})}))}dfsTree(t,e,n){return Hg(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Wg([this.getNode(t)],new Set,e,(t=>this.getChildren(t,n)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Wg([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Hg(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),n=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new t({nodes:e,edges:n});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach(((t,e)=>{i.set(e,r.getNode(t.id))}));const o=new Map;e.forEach(((t,e)=>{o.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:i,childrenMap:o})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new $g({graph:this,...t})}};class qg{constructor(t,e){this.context=t,this.options=e||{}}}function Xg(t){const{nodes:e,edges:n}=t,r={nodes:[],edges:[],combos:[]};return e.forEach((t=>{const e=t.data._isCombo?r.combos:r.nodes,{x:n,y:i,z:o=0}=t.data;null==e||e.push({id:t.id,style:{x:n,y:i,z:o}})})),n.forEach((t=>{const{id:e,source:n,target:i,data:{points:o=[],controlPoints:a=o.slice(1,o.length-1)}}=t;r.edges.push({id:e,source:n,target:i,style:Object.assign({},(null==a?void 0:a.length)?{controlPoints:a.map(nd)}:{})})})),r}function Kg(t,e,...n){if(e in t)return t[e](...n);if("instance"in t){const r=t.instance;if(e in r)return r[e](...n)}return null}function Zg(t,e){if(e in t)return t[e];if("instance"in t){const n=t.instance;if(e in n)return n[e]}return null}class Qg extends Gg{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find((t=>["d3-force","d3-force-3d"].includes(null==t?void 0:t.id)))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(Tc("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return ze(this,void 0,void 0,(function*(){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach(((r,i)=>{const{x:o=0,y:a=0}=r.style||{};n&&Kg(n,"setFixedPosition",t[i],[...Ih([+o,+a],e)])}))}))}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e&&Zg(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach((t=>{const{x:n=0,y:r=0}=t.style||{};e&&Kg(e,"setFixedPosition",yh(t),[+n,+r])}))}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t&&Zg(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach((e=>{t&&Kg(t,"setFixedPosition",yh(e),[null,null,null])}))}}class Jg extends Dh{constructor(t,e){super(t,Object.assign({},Jg.defaultOptions,e)),this.isZoomEvent=t=>Boolean(t.data&&"scale"in t.data),this.relatedEdgeToUpdate=new Set,this.zoom=this.context.graph.getZoom(),this.fixElementSize=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{graph:e}=this.context,{state:n,nodeFilter:r,edgeFilter:i,comboFilter:o}=this.options,a=(n?e.getElementDataByState("node",n):e.getNodeData()).filter(r),s=(n?e.getElementDataByState("edge",n):e.getEdgeData()).filter(i),l=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),u=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,c=[...a,...l];c.length>0&&c.forEach((t=>this.fixNodeLike(t,u))),this.updateRelatedEdges(),s.length>0&&s.forEach((t=>this.fixEdge(t,u)))})),this.cachedStyles=new Map,this.getOriginalFieldValue=(t,e,n)=>{var r;const i=this.cachedStyles.get(t)||[],o=(null===(r=i.find((t=>t.shape===e)))||void 0===r?void 0:r.style)||{};return n in o||(o[n]=e.attributes[n],this.cachedStyles.set(t,[...i.filter((t=>t.shape!==e)),{shape:e,style:o}])),o[n]},this.scaleEntireElement=(t,e,n)=>{e.setLocalScale(1/n);const r=this.cachedStyles.get(t)||[];r.push({shape:e}),this.cachedStyles.set(t,r)},this.scaleSpecificShapes=(t,e,n)=>{const r=function(t){const e=[],n=t=>{(null==t?void 0:t.children.length)&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}(t);(Array.isArray(n)?n:[n]).forEach((n=>{const{shape:i,fields:o}=n,a="function"==typeof i?i(r):t.getShape(i);a&&(o?o.forEach((n=>{const r=this.getOriginalFieldValue(t.id,a,n);ae(r)&&(a.style[n]=r/e)})):this.scaleEntireElement(t.id,a,e))}))},this.skipIfExceedViewport=t=>{const{viewport:e}=this.context;return!(null==e?void 0:e.isInViewport(t.getRenderBounds(),!1,30))},this.fixNodeLike=(t,e)=>{const n=yh(t),{element:r,model:i}=this.context,o=r.getElement(n);if(!o||this.skipIfExceedViewport(o))return;i.getRelatedEdgesData(n).forEach((t=>this.relatedEdgeToUpdate.add(yh(t))));const a=this.options[o.type];a?this.scaleSpecificShapes(o,e,a):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=yh(t),r=this.context.element.getElement(n);if(!r||this.skipIfExceedViewport(r))return;const i=this.options.edge;if(!i)return r.style.transformOrigin="center",void this.scaleEntireElement(n,r,e);this.scaleSpecificShapes(r,e,i)},this.updateRelatedEdges=()=>{const{element:t}=this.context;this.relatedEdgeToUpdate.size>0&&this.relatedEdgeToUpdate.forEach((e=>{const n=t.getElement(e);null==n||n.update({})})),this.relatedEdgeToUpdate.clear()},this.resetTransform=t=>ze(this,void 0,void 0,(function*(){var e;(null===(e=t.data)||void 0===e?void 0:e.firstRender)||(this.options.reset?this.restoreCachedStyles():this.fixElementSize({data:{scale:this.zoom}}))})),this.bindEvents()}restoreCachedStyles(){if(this.cachedStyles.size>0){this.cachedStyles.forEach((t=>{t.forEach((({shape:t,style:e})=>{if(Se(e))t.setLocalScale(1);else{if(this.options.state)return;Object.entries(e).forEach((([e,n])=>t.style[e]=n))}}))}));const{graph:t,element:e}=this.context,n=Object.keys(Object.fromEntries(this.cachedStyles)).filter((e=>e&&"node"===t.getElementType(e)));if(n.length>0){const r=new Set;n.forEach((e=>{t.getRelatedEdgesData(e).forEach((t=>r.add(yh(t))))})),r.forEach((t=>{const n=null==e?void 0:e.getElement(t);null==n||n.update({})}))}}}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.on(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.off(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Jg.defaultOptions={enable:t=>t.data.scale<1,nodeFilter:()=>!0,edgeFilter:()=>!0,comboFilter:()=>!0,edge:[{shape:"key",fields:["lineWidth"]},{shape:"halo",fields:["lineWidth"]},{shape:"label"}],reset:!1};class tv extends Dh{constructor(t,e){super(t,Object.assign({},tv.defaultOptions,e)),this.focus=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{graph:e}=this.context;yield e.focusElement(t.target.id,this.options.animation)})),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}destroy(){this.unbindEvents(),super.destroy()}}tv.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};class ev extends Dh{constructor(e,n){super(e,Object.assign({},ev.defaultOptions,n)),this.isFrozen=!1,this.toggleFrozen=t=>{this.isFrozen="dragstart"===t.type},this.hoverElement=e=>{if(!this.validate(e))return;const n=e.type===t.CommonEvent.POINTER_ENTER;this.updateElementsState(e,n);const{onHover:r,onHoverEnd:i}=this.options;n?null==r||r(e):null==i||i(e)},this.updateElementsState=(t,e)=>{if(!this.options.state&&!this.options.inactiveState)return;const{graph:n}=this.context,{state:r,animation:i,inactiveState:o}=this.options,a=this.getActiveIds(t),s={};if(r&&Object.assign(s,this.getElementsState(a,r,e)),o){const t=xh(n.getData(),!0).filter((t=>!a.includes(t)));Object.assign(s,this.getElementsState(t,o,e))}n.setElementState(s,i)},this.getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach((t=>{const o=r.getElementState(t);i[t]=n?o.includes(e)?o:[...o,e]:o.filter((t=>t!==e))})),i},this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.forEach((n=>{e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)}));const n=this.context.canvas.document;n.addEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.addEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}getActiveIds(t){const{graph:e}=this.context,{degree:n,direction:r}=this.options,i=t.target.id;return n?kd(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||Ig(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)}));const n=this.context.canvas.document;n.removeEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.removeEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}destroy(){this.unbindEvents(),super.destroy()}}ev.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class nv extends yd{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e}=this.context;this.pathShape=new Hl({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[bd(t)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(bd(t)),null===(e=this.pathShape)||void 0===e||e.setAttribute("d",function(t,e=!0){const n=[];return t.forEach(((t,e)=>{n.push([0===e?"M":"L",...t])})),e&&n.push(["Z"]),n}(this.points)),n&&"default"===r&&this.points.length>2&&super.updateElementsStates(this.points)}onPointerUp(){this.points&&(this.points.length<2||super.updateElementsStates(this.points),this.clearLasso())}clearLasso(){var t;null===(t=this.pathShape)||void 0===t||t.remove(),this.pathShape=void 0,this.points=void 0}}class rv extends Dh{constructor(t,e){super(t,Object.assign({},rv.defaultOptions,e)),this.hiddenShapes=[],this.isVisible=!0,this.setElementsVisibility=(t,e,n)=>{t.filter(Boolean).forEach((t=>{"hidden"!==e||t.isVisible()?"visible"===e&&this.hiddenShapes.includes(t)?this.hiddenShapes.splice(this.hiddenShapes.indexOf(t),1):Ah(t,e,n):this.hiddenShapes.push(t)}))},this.filterShapes=(t,e)=>{if(Ut(e))return n=>!e(t,n);const n=null==e?void 0:e[t];return t=>!t.className||!(null==n?void 0:n.includes(t.className))},this.hideShapes=t=>{if(!this.validate(t)||!this.isVisible)return;const{element:e}=this.context,{shapes:n={}}=this.options;this.setElementsVisibility(e.getNodes(),"hidden",this.filterShapes("node",n)),this.setElementsVisibility(e.getEdges(),"hidden",this.filterShapes("edge",n)),this.setElementsVisibility(e.getCombos(),"hidden",this.filterShapes("combo",n)),this.isVisible=!1},this.showShapes=ye((t=>{if(!this.validate(t)||this.isVisible)return;const{element:e}=this.context;this.setElementsVisibility(e.getNodes(),"visible"),this.setElementsVisibility(e.getEdges(),"visible"),this.setElementsVisibility(e.getCombos(),"visible"),this.isVisible=!0}),this.options.debounce),this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.on(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.off(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}rv.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class iv extends Dh{constructor(t,e){super(t,Object.assign({},iv.defaultOptions,e)),this.onWheel=t=>ze(this,void 0,void 0,(function*(){this.options.preventDefault&&t.preventDefault();const e=t.deltaX,n=t.deltaY;yield this.scroll([-e,-n],t)})),this.shortcut=new md(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),qt(r)){null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel);const{up:n=[],down:i=[],left:o=[],right:a=[]}=r;this.shortcut.bind(n,(t=>this.scroll([0,-10],t))),this.shortcut.bind(i,(t=>this.scroll([0,10],t))),this.shortcut.bind(o,(t=>this.scroll([-10,0],t))),this.shortcut.bind(a,(t=>this.scroll([10,0],t)))}else null===(n=this.graphDom)||void 0===n||n.addEventListener(t.CommonEvent.WHEEL,this.onWheel,{passive:!1})}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}formatDisplacement(t){const{sensitivity:e}=this.options;return t=Bh(t,e),t=this.clampByDirection(t),t=this.clampByRange(t)}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[a,s,l,u]=Uc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{onFinish:n}=this.options,r=this.context.graph,i=this.formatDisplacement(t);yield r.translateBy(i,!1),null==n||n()}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel),super.destroy()}}iv.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class ov extends Dh{constructor(t,e){super(t,Object.assign({},ov.defaultOptions,e)),this.zoom=(t,e,n)=>ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{graph:r}=this.context;let i=this.options.origin;!i&&"viewport"in e&&(i=nd(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+oe(t,-50,50)*o/100,l=r.getZoom();yield r.zoomTo(l*s,n,i),null==a||a()})),this.onReset=()=>ze(this,void 0,void 0,(function*(){yield this.context.graph.zoomTo(1,this.options.animation)})),this.preventDefault=t=>{this.options.preventDefault&&t.preventDefault()},this.shortcut=new md(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),Array.isArray(e))if(e.includes(t.CommonEvent.PINCH))this.shortcut.bind([t.CommonEvent.PINCH],(t=>{this.zoom(t.scale,t,!1)}));else{const n=this.context.canvas.getContainer();null==n||n.addEventListener(t.CommonEvent.WHEEL,this.preventDefault),this.shortcut.bind([...e,t.CommonEvent.WHEEL],(t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(null!=n?n:e),t,!1)}))}if("object"==typeof e){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,(t=>this.zoom(10,t,this.options.animation))),this.shortcut.bind(n,(t=>this.zoom(-10,t,this.options.animation))),this.shortcut.bind(r,this.onReset)}}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.context.canvas.getContainer())||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.preventDefault),super.destroy()}}ov.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};var av={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},sv=av,lv={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function uv(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof uv)return t;n.data=t;var r=e.getHGap(t),i=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,i),n}sv.assign(uv.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)})),t},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}});var cv=function(t,e,n){void 0===e&&(e={});var r,i=new uv(t,e=sv.assign({},lv,e)),o=[i];if(!n&&!t.collapsed)for(;r=o.shift();)if(!r.data.collapsed){var a=e.getChildren(r.data),s=a?a.length:0;if(r.children=new Array(s),a&&s)for(var l=0;l<s;l++){var u=new uv(a[l],e);r.children[l]=u,o.push(u),u.parent=r,u.depth=r.depth+1}}return i},hv=cv,dv=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=hv(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),fv=dv;function pv(t,e,n,r){void 0===r&&(r=[]);var i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function gv(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){gv(t,e,n)}))}function vv(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(vv(t,e),n)})),n}function mv(t,e){gv(t,-vv(t,e),e)}function yv(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){yv(t,e.children[r],n)}))}function bv(t,e,n){void 0===n&&(n=0),e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach((function(t){bv(t,e,n)}))}pv.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(pv.fromNode(t,e))})),e?new pv(t.height,t.width,t.x,n):new pv(t.width,t.height,t.y,n)};var xv=cv,Ev=function(t,e){for(var n=xv(t.data,e,!0),r=xv(t.data,e,!0),i=t.children.length,o=Math.round(i/2),a=e.getSide||function(t,e){return e<o?"right":"left"},s=0;s<i;s++){var l=t.children[s];"right"===a(l,s)?r.children.push(l):n.children.push(l)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},wv=Ev,kv=["LR","RL","TB","BT","H","V"],Mv=["LR","RL","H"],Sv=kv[0],Nv=function(t,e,n){var r=e.direction||Sv;if(e.isHorizontal=function(t){return Mv.indexOf(t)>-1}(r),-1===kv.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===kv[0])n(t,e);else if(r===kv[1])n(t,e),t.right2left();else if(r===kv[2])n(t,e);else if(r===kv[3])n(t,e),t.bottom2top();else if(r===kv[4]||r===kv[5]){var i=wv(t,e),o=i.left,a=i.right;n(o,e),n(a,e),e.isHorizontal?o.right2left():o.bottom2top(),a.translate(o.x-a.x,o.y-a.y),t.x=o.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var l=e.fixedRoot;return void 0===l&&(l=!0),l&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){var n=e.isHorizontal?["x","y"]:["y","x"],r=n[0],i=n[1],o={x:1/0,y:1/0},a={x:-1/0,y:-1/0},s=0;t.DFTraverse((function(t){s++;var e=t.x,n=t.y;o.x=Math.min(o.x,e),o.y=Math.min(o.y,n),a.x=Math.max(a.x,e),a.y=Math.max(a.y,n)}));var l=a[i]-o[i];if(0===l)return;var u=2*Math.PI/s;t.DFTraverse((function(e){var n=(e[i]-o[i])/l*(2*Math.PI-u)+u,a=e[r]-t[r];e.x=Math.cos(n)*a,e.y=Math.sin(n)*a}))}}(t,e),t};function Ov(t,e){return Ov=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ov(t,e)}var Tv=function(t,e){void 0===e&&(e={});var n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){for(var r=t.c[e-1],i=r.mod,u=t.c[e],c=u.mod;null!==r&&null!==u;){l(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(c+u.prelim);h>0&&(c+=h,o(t,e,n.index,h));var d=l(r),f=l(u);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(u=a(u))&&(c+=u.mod)}!r&&u?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,u,c):r&&!u&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function a(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function l(t){return t.y+t.h}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}bv(t,n);var c=pv.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=u(l(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=l(e.c[o].er);i(e,o,n),n=u(a,o,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}else r(e)}(c),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)n+=(e+=t.c[r].shift)+t.c[r].change,t.c[r].mod+=n}(e);for(var r=0;r<e.cs;r++)t(e.c[r],n)}(c,0),yv(c,t,n),mv(t,n),t},Cv=Nv,Av=av,Pv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Ov(n,r),e.prototype.execute=function(){return Cv(this.rootNode,this.options,Tv)},e}(fv),Rv={};var Dv=function(t,e){return e=Av.assign({},Rv,e),new Pv(t,e).execute()},Lv=av;function _v(t,e){void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}var Iv={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function jv(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((function(t,r){jv(t,e.children[r],n)}))}function Bv(t,e){return Bv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Bv(t,e)}var Fv=function(t,e){void 0===e&&(e={}),e=Lv.assign({},Iv,e);var n,r=0;var i=function t(e){if(!e)return null;e.width=0,e.depth&&e.depth>r&&(r=e.depth);var n=e.children,i=n.length,o=new _v(e.height,[]);return n.forEach((function(e,n){var r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)})),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{var n=e.children.map((function(e){return t(e)})),i=Math.min.apply(null,n);e.drawingDepth=i-1}return e.drawingDepth}(i),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(i),jv(i,t,e.isHorizontal),t},zv=Nv,Gv=av,Vv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Bv(n,r),e.prototype.execute=function(){var t=this;return t.rootNode.width=0,zv(t.rootNode,t.options,Fv)},e}(fv),Wv={};var Hv=function(t,e){return e=Gv.assign({},Wv,e),new Vv(t,e).execute()},Uv=av;function $v(t,e){return $v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$v(t,e)}var Yv=fv,qv=function(t,e,n,r){var i=null;t.eachNode((function(t){!function(t,e,n,r,i){var o=("function"==typeof n?n(t):n)*t.depth;if(!r)try{if(t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch(t){}if(t.x+=o,e){if(t.y=e.y+Uv.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+Uv.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},Xv=Ev,Kv=av,Zv=["LR","RL","H"],Qv=Zv[0],Jv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,$v(n,r),e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,o=void 0===i||i,a=t.direction,s=void 0===a?Qv:a,l=t.align;if(s&&-1===Zv.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Zv[0])qv(e,r,o,l);else if(s===Zv[1])qv(e,r,o,l),e.right2left();else if(s===Zv[2]){var u=Xv(e,t),c=u.left,h=u.right;qv(c,r,o,l),c.right2left(),qv(h,r,o,l);var d=c.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},e}(Yv),tm={};var em=function(t,e){return e=Kv.assign({},tm,e),new Jv(t,e).execute()},nm=av;function rm(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=rm(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function im(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){im(t)}));var r=e[0],i=e[n-1],o=i.y-r.y+i.height,a=0;if(e.forEach((function(t){a+=t.totalHeight})),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>a){var s=t.y+(t.height-o)/2-r.y;e.forEach((function(t){t.translate(0,s)}))}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}var om={getSubTreeSep:function(){return 0}};function am(t,e){return am=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},am(t,e)}var sm=function(t,e){void 0===e&&(e={}),e=nm.assign({},om,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,rm(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}})),im(t)},lm=Nv,um=av,cm=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,am(n,r),e.prototype.execute=function(){return lm(this.rootNode,this.options,sm)},e}(fv),hm={};var dm=function(t,e){return e=um.assign({},hm,e),new cm(t,e).execute()},fm={compactBox:Dv,dendrogram:Hv,indented:em,mindmap:dm};const pm=(t,e)=>{if("next"!==t&&"prev"!==t)return e},gm=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let vm=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return gm(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&gm(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let n=e.prev;for(;n!==e;)t.push(JSON.stringify(n,pm)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},mm=class extends vm{};const ym=()=>1,bm=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)xm(t,e,n,a);for(;a=i.dequeue();)xm(t,e,n,a);if(t.getAllNodes().length)for(let i=e.length-2;i>0;--i)if(a=e[i].dequeue(),a){r=r.concat(xm(t,e,n,a,!0));break}}return r},xm=(t,e,n,r,i)=>{var o,a;const s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach((r=>{const o=r.data.weight,a=t.getNode(r.source);i&&s.push({v:r.source,w:r.target,in:0,out:0}),void 0===a.data.out&&(a.data.out=0),a.data.out-=o,wm(e,n,Object.assign({v:a.id},a.data))})),null===(a=t.getRelatedEdges(r.v,"out"))||void 0===a||a.forEach((r=>{const i=r.data.weight,o=r.target,a=t.getNode(o);void 0===a.data.in&&(a.data.in=0),a.data.in-=i,wm(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},Em=(t,e)=>{const n=new Yg;let r=0,i=0;t.getAllNodes().forEach((t=>{n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((t=>{const o=n.getRelatedEdges(t.source,"out").find((e=>e.target===t.target)),a=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,Object.assign(Object.assign({},o.data),{weight:o.data.weight+a})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:a}}),i=Math.max(i,n.getNode(t.source).data.out+=a),r=Math.max(r,n.getNode(t.target).data.in+=a)}));const o=[],a=i+r+3;for(let t=0;t<a;t++)o.push(new mm);const s=r+1;return n.getAllNodes().forEach((t=>{wm(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},wm=(t,e,n)=>{n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)},km=(t,e)=>{const n=((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=Em(t,e||ym);return null===(n=bm(r.graph,r.buckets,r.zeroIdx).map((e=>t.getRelatedEdges(e.v,"out").filter((({target:t})=>t===e.w)))))||void 0===n?void 0:n.flat()})(t,(t=>t.data.weight||1));null==n||n.forEach((e=>{const n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},n)})}))},Mm=(t,e,n,r)=>{let i;do{i=`${r}${Math.random()}`}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},Sm=t=>{const e=new Yg;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},Nm=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,l=Number(t.width)/2,u=Number(t.height)/2;return i||o?(Math.abs(o)*l>Math.abs(i)*u?(o<0&&(u=-u),a=u*i/o,s=u):(i<0&&(l=-l),a=l,s=l*o/i),{x:n+a,y:r+s}):{x:0,y:0}},Om=t=>{const e=[],n=Cm(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(let r=0;r<n;r++)e[r]=e[r].sort(((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},Tm=(t,e,n,r)=>{const i={width:0,height:0};return ae(n)&&ae(r)&&(i.rank=n,i.order=r),Mm(t,"border",i,e)},Cm=t=>{let e;return t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)})),e||(e=0),e},Am=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),Pm=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>Pm(t,e,n,r,i,o))),n&&o.push(e.id))},Rm=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>t.getNeighbors(e),a=[],s=[];return i.forEach((e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);Pm(t,e,"post"===n,s,o,a)})),a},Dm=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],l=Mm(t,"border",a,n);i.data[e][o]=l,t.setParent(l,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:l,data:{weight:1}})},Lm=t=>{t.getAllNodes().forEach((t=>{_m(t)})),t.getAllEdges().forEach((t=>{_m(t)}))},_m=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Im=t=>{t.getAllNodes().forEach((t=>{jm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>jm(t))),t.data.hasOwnProperty("y")&&jm(t.data)}))},jm=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},Bm=t=>{t.getAllNodes().forEach((t=>{Fm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Fm(t))),t.data.hasOwnProperty("x")&&Fm(t.data)}))},Fm=t=>{const e=t.x;t.x=t.y,t.y=e},zm=(t,e,n,r,i,o,a)=>{const s=t.getChildren(a);if(!(null==s?void 0:s.length))return void(a!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:n}}));const l=Tm(t,"_bt"),u=Tm(t,"_bb"),c=t.getNode(a);t.setParent(l,a),c.data.borderTop=l,t.setParent(u,a),c.data.borderBottom=u,null==s||s.forEach((s=>{zm(t,e,n,r,i,o,s.id);const c=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=c!==h?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:h,target:u,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:l,data:{weight:0,minlen:i+o[a]}})},Gm=t=>{const e={},n=(r,i)=>{const o=t.getChildren(r);null==o||o.forEach((t=>n(t.id,i+1))),e[r]=i};return t.getRoots().forEach((t=>n(t.id,1))),e},Vm=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Wm="edge-label",Hm=(t,e,n)=>{let r=e.source,i=t.getNode(r).data.rank;const o=e.target,a=t.getNode(o).data.rank,s=e.data.labelRank;if(a===i+1)return;let l,u,c;for(t.removeEdge(e.id),c=0,++i;i<a;++c,++i)e.data.points=[],u={originalEdge:e,width:0,height:0,rank:i},l=Mm(t,"edge",u,"_d"),i===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=Wm,u.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:l,data:{weight:e.data.weight}}),0===c&&n.push(l),r=l;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},Um=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},$m=(t,e,n)=>{const r=((t,e)=>null==t?void 0:t.reduce(((t,n,r)=>(t[n]=e[r],t)),{}))(n,n.map(((t,e)=>e))),i=e.map((e=>{const n=t.getRelatedEdges(e,"out").map((t=>({pos:r[t.target]||0,weight:t.data.weight})));return null==n?void 0:n.sort(((t,e)=>t.pos-e.pos))})),o=i.flat().filter((t=>void 0!==t));let a=1;for(;a<n.length;)a<<=1;const s=2*a-1;a-=1;const l=Array(s).fill(0,0,s);let u=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;l[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=l[e+1]),e=e-1>>1,l[e]+=t.weight;u+=t.weight*n}})),u},Ym=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=$m(t,e[r-1],e[r]);return n},qm=t=>{const e={},n=t.getAllNodes(),r=n.map((t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o.push([]);const a=n.sort(((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank)),s=a.filter((e=>void 0!==t.getNode(e.id).data.fixorder)).sort(((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder));return null==s||s.forEach((n=>{isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0})),null==a||a.forEach((n=>t.dfsTree(n.id,(t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)})))),o},Xm=t=>{var e,n;const r=[];for(;null==t?void 0:t.length;){const i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach((t=>{return(e=i,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Km(e,t)})(t);var e})),null===(n=i.out)||void 0===n||n.forEach((e=>{return(n=i,e=>{e.in.push(n),0===--e.indegree&&t.push(e)})(e);var n}))}const i=r.filter((t=>!t.merged)),o=["vs","i","barycenter","weight"];return i.map((t=>{const e={};return null==o||o.forEach((n=>{void 0!==t[n]&&(e[n]=t[n])})),e}))},Km=(t,e)=>{var n;let r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},Zm=(t,e,n)=>{let r,i=n;for(;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},Qm=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i},Jm=(t,e,n,r,i,o)=>{var a,s,l,u;let c=t.getChildren(e).map((t=>t.id));const h=t.getNode(e),d=h?h.data.borderLeft:void 0,f=h?h.data.borderRight:void 0,p={};d&&(c=null==c?void 0:c.filter((t=>t!==d&&t!==f)));const g=((t,e)=>e.map((e=>{const n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};const r={sum:0,weight:0};return null==n||n.forEach((e=>{const n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight})),{v:e,barycenter:r.sum/r.weight,weight:r.weight}})))(t,c||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=Jm(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&ey(e,i)}}));const v=((t,e)=>{var n,r,i;const o={};null==t||t.forEach(((t,e)=>{o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)})),null===(n=e.getAllEdges())||void 0===n||n.forEach((t=>{const e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))}));const a=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,(t=>!t.indegree));return Xm(a)})(g,n);ty(v,p),null===(a=v.filter((t=>t.vs.length>0)))||void 0===a||a.forEach((e=>{const n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)}));const m=((t,e,n,r)=>{const i=((t,e)=>{const n={lhs:[],rhs:[]};return null==t||t.forEach((t=>{e(t)?n.lhs.push(t):n.rhs.push(t)})),n})(t,(t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),o=i.lhs,a=i.rhs.sort(((t,e)=>-t.i- -e.i)),s=[];let l=0,u=0,c=0;null==o||o.sort(Qm(!!e,!!n)),c=Zm(s,a,c),null==o||o.forEach((t=>{var e;c+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,c=Zm(s,a,c)}));const h={vs:s.flat()};return u&&(h.barycenter=l/u,h.weight=u),h})(v,r,i,o);if(d&&(m.vs=[d,m.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(l=t.getPredecessors(d))||void 0===l?void 0:l[0].id)||""),n=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||"");m.hasOwnProperty("barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+e.data.order+n.data.order)/(m.weight+2),m.weight+=2}return m},ty=(t,e)=>{null==t||t.forEach((t=>{var n;const r=null===(n=t.vs)||void 0===n?void 0:n.map((t=>e[t]?e[t].vs:t));t.vs=r.flat()}))},ey=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},ny=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Um(t),i=new Yg({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((o=>{const a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(Object.assign({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach((e=>{const n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(Object.assign({},t.getNode(n)));const r=i.getRelatedEdges(n,"out").find((({target:t})=>t===o.id)),a=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,Object.assign(Object.assign({},r.data),{weight:e.data.weight+a})):i.addEdge({id:e.id,source:n,target:o.id,data:{weight:e.data.weight+a}})})),o.data.hasOwnProperty("minRank")&&i.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i})(t,e,n))),ry=(t,e,n,r)=>{const i=new Yg;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Jm(t,a,i,e,n,r);for(let e=0;e<(null===(o=s.vs)||void 0===o?void 0:o.length);e++){const n=t.getNode(s.vs[e]);n&&(n.data.order=e)}((t,e,n)=>{const r={};let i;null==n||n.forEach((n=>{let o,a,s=t.getParent(n);for(;s;){if(o=t.getParent(s.id),o?(a=r[o.id],r[o.id]=s.id):(a=i,i=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${a}-${s.id}`)||e.addEdge({id:`e${a}-${s.id}`,source:a,target:s.id,data:{}}));s=o}}))})(t,i,s.vs)}))},iy=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},oy=(t,e)=>{const n=(t=>{const e={};let n=0;const r=i=>{const o=n;t.getChildren(i).forEach((t=>r(t.id))),e[i]={low:o,lim:n++}};return t.getRoots().forEach((t=>r(t.id))),e})(t);e.forEach((e=>{var r,i;let o=e,a=t.getNode(o);const s=a.data.originalEdge;if(!s)return;const l=((t,e,n,r)=>{var i,o;const a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);let c,h;c=n;do{c=null===(i=t.getParent(c))||void 0===i?void 0:i.id,a.push(c)}while(c&&(e[c].low>l||u>e[c].lim));for(h=c,c=r;c&&c!==h;)s.push(c),c=null===(o=t.getParent(c))||void 0===o?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}})(t,n,s.source,s.target),u=l.path,c=l.lca;let h=0,d=u[h],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==c&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)h++,d=u[h];d===c&&(f=!1)}if(!f){for(;h<u.length-1&&(null===(i=t.getNode(u[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=u[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},ay=(t,e)=>{const n={};function r(e,r){const i=function(t){return JSON.stringify(t.slice(1))}(e);r.get(i)||(!function(e,r,i,o,a){var s,l;let u;for(let c=r;c<i;c++)u=e[c],(null===(s=t.getNode(u))||void 0===s?void 0:s.data.dummy)&&(null===(l=t.getPredecessors(u))||void 0===l||l.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&ly(n,e.id,u)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((l,u)=>{var c;if("border"===(null===(c=t.getNode(l))||void 0===c?void 0:c.data.dummy)){const e=t.getPredecessors(l)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,u,o,i],s),a=u,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},sy=(t,e)=>{var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find((e=>t.getNode(e.id).data.dummy))},ly=(t,e,n)=>{let r=e,i=n;if(r>i){const t=r;r=i,i=t}let o=t[r];o||(t[r]=o={}),o[i]=!0},uy=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},cy=(t,e,n,r,i,o)=>{const a=new Yg,s=hy(r,i,o);return null==e||e.forEach((e=>{let r;null==e||e.forEach((e=>{const i=n[e];if(a.hasNode(i)||a.addNode({id:i,data:{}}),r){const o=n[r],l=a.getRelatedEdges(o,"out").find((t=>t.target===i));l?a.updateEdgeData(l.id,Object.assign(Object.assign({},l.data),{weight:Math.max(s(t,e,r),l.data.weight||0)})):a.addEdge({id:`e${Math.random()}`,source:o,target:i,data:{weight:Math.max(s(t,e,r),0)}})}r=e}))})),a};const hy=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let l=0,u=0;if(l+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":u=-a.data.width/2;break;case"r":u=a.data.width/2}if(u&&(l+=n?u:-u),u=0,l+=(a.data.dummy?e:t)/2,l+=(s.data.dummy?e:t)/2,l+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":u=s.data.width/2;break;case"r":u=-s.data.width/2}return u&&(l+=n?u:-u),u=0,l},dy=(t,e)=>t.getNode(e).data.width||0,fy=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=Om(t),a=Object.assign(((t,e)=>{const n={},r=(e,r)=>{let i=0,o=0;const a=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach(((e,l)=>{var u;const c=sy(t,e),h=c?t.getNode(c.id).data.order:a;(c||e===s)&&(null===(u=r.slice(o,l+1))||void 0===u||u.forEach((e=>{var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach((r=>{var o;const a=t.getNode(r.id),s=a.data.order;!(s<i||h<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||ly(n,r.id,e)}))})),o=l+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),ay(t,o)),s={};let l=[];["u","d"].forEach((e=>{l="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(l=l.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),u=((t,e,n,r)=>{const i={},o={},a={};return null==e||e.forEach((t=>{null==t||t.forEach(((t,e)=>{i[t]=t,o[t]=t,a[t]=e}))})),null==e||e.forEach((t=>{let e=-1;null==t||t.forEach((t=>{let s=r(t).map((t=>t.id));if(s.length){s=s.sort(((t,e)=>a[t]-a[e]));const r=(s.length-1)/2;for(let l=Math.floor(r),u=Math.ceil(r);l<=u;++l){const r=s[l];o[t]===t&&e<a[r]&&!uy(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,l,a,o),c=((t,e,n,r,i,o,a)=>{var s;const l={},u=cy(t,e,n,i,o,a),c=a?"borderLeft":"borderRight",h=(t,e)=>{let n=u.getAllNodes(),r=n.pop();const i={};for(;r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return h((t=>{l[t]=(u.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(l[e.source]||0)+e.data.weight)),0)}),u.getPredecessors.bind(u)),h((e=>{const n=(u.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(l[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==c&&(l[e]=Math.max(l[e],n))}),u.getSuccessors.bind(u)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{l[t]=l[n[t]]})),l})(t,l,u.root,u.align,r,i,"r"===n);"r"===n&&Object.keys(c).forEach((t=>c[t]=-c[t])),s[e+n]=c}))}));const u=((t,e)=>Am(Object.values(e),(e=>{var n;let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach((n=>{const o=e[n],a=dy(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return u&&function(t,e){const n=Object.values(e),r=Math.min(...n),i=Math.max(...n);["u","d"].forEach((n=>{["l","r"].forEach((o=>{const a=n+o,s=t[a];let l;if(s===e)return;const u=Object.values(s);l="l"===o?r-Math.min(...u):i-Math.max(...u),l&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+l})))}))}))}(s,u),((t,e)=>{const n={};return Object.keys(t.ul).forEach((r=>{if(e)n[r]=t[e.toLowerCase()][r];else{const e=Object.values(t).map((t=>t[r]));n[r]=(e[0]+e[1])/2}})),n})(s,n)},py=(t,e)=>{var n;const r=Sm(t);((t,e)=>{const{ranksep:n=0}=e||{},r=Om(t);let i=0;null==r||r.forEach((e=>{const r=e.map((e=>t.getNode(e).data.height)),o=Math.max(...r,0);null==e||e.forEach((e=>{t.getNode(e).data.y=i+o/2})),i+=o+n}))})(r,e);const i=fy(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},gy=t=>{const e={},n=r=>{var i;const o=t.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;let a;return e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach((t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),o.data.rank=a,a};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>n(t.id)))},vy=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,my=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||vy(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},yy=(t,e)=>{const n=r=>{var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||void 0===e.getNode(a).data.layer&&vy(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},by=(t,e)=>Am(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?vy(e,n):1/0)),xy=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},Ey=t=>{const e=(t=>{const e=new Yg;return t.getAllNodes().forEach((t=>{e.addNode(Object.assign({},t))})),t.getAllEdges().forEach((t=>{const n=e.getRelatedEdges(t.source,"out").find((e=>e.target===t.target));n?e.updateEdgeData(null==n?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e})(t);gy(e);const n=(t=>{const e=new Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);my(e,t)<r;)i=by(e,t),o=e.hasNode(i.source)?vy(t,i):-vy(t,i),xy(e,t,o);return e})(e);let r,i;for(Sy(n),wy(n,e);r=Oy(n);)i=Ty(n,e,r),Cy(n,e,r,i)},wy=(t,e)=>{let n=Rm(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{ky(t,e,n)}))},ky=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=My(t,e,n)},My=(t,e,n)=>{const r=t.getNode(n).data.parent;let i=!0,o=e.getRelatedEdges(n,"out").find((t=>t.target===r)),a=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find((t=>t.target===n))),a=o.data.weight,e.getRelatedEdges(n,"both").forEach((e=>{const o=e.source===n,s=o?e.target:e.source;if(s!==r){const r=o===i,l=e.data.weight;if(a+=r?l:-l,Py(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},Sy=(t,e=t.getAllNodes()[0].id)=>{Ny(t,{},1,e)},Ny=(t,e,n,r,i)=>{var o;const a=n;let s=n;const l=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=Ny(t,e,s,n.id,r))})),l.data.low=a,l.data.lim=s++,i?l.data.parent=i:delete l.data.parent,s},Oy=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),Ty=(t,e,n)=>{let r=n.source,i=n.target;e.getRelatedEdges(r,"out").find((t=>t.target===i))||(r=n.target,i=n.source);const o=t.getNode(r),a=t.getNode(i);let s=o,l=!1;o.data.lim>a.data.lim&&(s=a,l=!0);const u=e.getAllEdges().filter((e=>l===Ry(t.getNode(e.source),s)&&l!==Ry(t.getNode(e.target),s)));return Am(u,(t=>vy(e,t)))},Cy=(t,e,n,r)=>{const i=t.getRelatedEdges(n.source,"both").find((t=>t.source===n.target||t.target===n.target));i&&t.removeEdge(i.id),t.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),Sy(t),wy(t,e),Ay(t,e)},Ay=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=Rm(t,n,"pre");r=r.slice(1),r.forEach((n=>{const r=t.getNode(n).data.parent;let i=e.getRelatedEdges(n,"out").find((t=>t.target===r)),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find((t=>t.target===n)),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))}))},Py=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),Ry=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Dy=gy,Ly=t=>{(t=>{const e={};let n;const r=i=>{var o;const a=t.getNode(i);if(!a)return 0;if(e[i])return a.data.rank;let s;return e[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach((t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)})),s||(s=0),(void 0===n||s<n)&&(n=s),a.data.rank=s,s};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>{t&&r(t.id)})),void 0===n&&(n=0);const i={},o=(e,n)=>{var r;const a=t.getNode(e),s=isNaN(a.data.layer)?n:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach((t=>{o(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=n:o(t.id,e.layer))}))})(t),(t=>{const e=new Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);yy(e,t)<r;)i=by(e,t),o=e.hasNode(i.source)?vy(t,i):-vy(t,i),xy(e,t,o)})(t)},_y=t=>{Ey(t)},Iy=(t,e)=>{const{ranker:n,rankdir:r="tb",nodeOrder:i,keepNodeOrder:o,align:a,nodesep:s=50,edgesep:l=20,ranksep:u=50}=e;tb(t),km(t);const{nestingRoot:c,nodeRankFactor:h}=(t=>{const e=Mm(t,"root",{},"_root"),n=Gm(t);let r=Math.max(...Object.values(n));Math.abs(r)===1/0&&(r=1);const i=r-1,o=2*i+1;t.getAllEdges().forEach((t=>{t.data.minlen*=o}));const a=Vm(t)+1;return t.getRoots().forEach((r=>{zm(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":_y(t);break;case"tight-tree":default:Ly(t);break;case"longest-path":Dy(t)}})(Sm(t),n),$y(t),((t,e=0)=>{const n=t.getAllNodes(),r=n.filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),i=Math.min(...r),o=[];n.forEach((t=>{const e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)}));let a=0;for(let n=0;n<o.length;n++){const r=o[n];void 0===r?n%e!==0&&(a-=1):a&&(null==r||r.forEach((e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}})(t,h),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach((e=>{e.data.nestingEdge&&t.removeEdge(e.id)}))})(t,c),(t=>{const e=t.getAllNodes().filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),n=Math.min(...e);t.getAllNodes().forEach((t=>{t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)}))})(t),Yy(t),qy(t);const d=[];((t,e)=>{t.getAllEdges().forEach((n=>Hm(t,n,e)))})(t,d),oy(t,d),(t=>{const e=n=>{const r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach((t=>e(t.id))),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let e=i.data.minRank,r=i.data.maxRank+1;e<r;e+=1)Dm(t,"borderLeft","_bl",n,i,e),Dm(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach((t=>e(t.id)))})(t),o&&((t,e)=>{const n=t.getAllNodes().filter((e=>{var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)})).map((t=>t.data.rank)),r=Math.max(...n),i=[];for(let t=0;t<r+1;t++)i[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=i[n.data.rank].length,i[n.data.rank].push(e)))}))})(t,i),((t,e)=>{const n=Cm(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=ny(t,r,"in"),a=ny(t,i,"out");let s=qm(t);iy(t,s);let l,u=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){ry(n%2?o:a,n%4>=2,!1,e),s=Om(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}s=qm(t),iy(t,s);for(let n=0,r=0;r<4;++n,++r){ry(n%2?o:a,n%4>=2,!0,e),s=Om(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}iy(t,l)})(t,o),eb(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||Lm(t)})(t,r),py(t,{align:a,nodesep:s,edgesep:l,ranksep:u}),nb(t),Jy(t),((t,e)=>{e.forEach((e=>{let n=t.getNode(e);const{data:r}=n,i=r.originalEdge;let o;i&&t.addEdge(i);let a=e;for(;n.data.dummy;)o=t.getSuccessors(a)[0],t.removeNode(a),i.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Wm&&(i.data.x=n.data.x,i.data.y=n.data.y,i.data.width=n.data.width,i.data.height=n.data.height),a=o.id,n=t.getNode(a)}))})(t,d),Zy(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Im(t),"lr"!==n&&"rl"!==n||(Bm(t),Lm(t))})(t,r);const{width:f,height:p}=Xy(t);return Ky(t),Qy(t),(t=>{t.getAllEdges().forEach((e=>{const n=e.data;if(n.reversed){t.removeEdge(e.id);const r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},n),{forwardName:r})})}}))})(t),{width:f,height:p}},jy=(t,e)=>{t.getAllNodes().forEach((n=>{const r=t.getNode(n.id);if(e.hasNode(n.id)){const t=e.getNode(n.id);r.data.fixorder=t.data._order,delete t.data._order}else delete r.data.fixorder}))},By=(t,e)=>{t.getAllNodes().forEach((n=>{var r;const i=t.getNode(n.id);if(i){const t=e.getNode(n.id);i.data.x=t.data.x,i.data.y=t.data.y,i.data._order=t.data.order,i.data._rank=t.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=t.data.width,i.data.height=t.data.height)}})),t.getAllEdges().forEach((n=>{const r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)}))},Fy=["width","height","layer","fixorder"],zy={width:0,height:0},Gy=["minlen","weight","width","height","labeloffset"],Vy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Wy=["labelpos"],Hy=t=>{const e=new Yg({tree:[]});return t.getAllNodes().forEach((n=>{const r=ib(t.getNode(n.id).data),i=Object.assign(Object.assign({},zy),r),o=rb(i,Fy);e.hasNode(n.id)||e.addNode({id:n.id,data:Object.assign({},o)});const a=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);$t(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=ib(t.getEdge(n.id).data),i={};null==Wy||Wy.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},Vy,rb(r,Gy),i)})})),e},Uy=(t,e)=>{const{ranksep:n=0,rankdir:r}=e;return t.getAllNodes().forEach((t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===r||"BT"===r?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2},$y=t=>{t.getAllEdges().forEach((e=>{if(e.data.width&&e.data.height){const n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};Mm(t,"edge-proxy",r,"_ep")}}))},Yy=t=>{let e=0;return t.getAllNodes().forEach((n=>{var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))})),e},qy=t=>{t.getAllNodes().forEach((e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Xy=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}={},l=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,l=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(a)||isNaN(l)||(void 0===r&&(r=a-l/2),r=Math.min(r,a-l/2),o=Math.max(o,a+l/2))};return t.getAllNodes().forEach((t=>{l(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&l(t)})),n-=a,r-=s,t.getAllNodes().forEach((t=>{t.data.x-=n,t.data.y-=r})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>{t.x-=n,t.y-=r})),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)})),{width:i-n+a,height:o-r+s}},Ky=t=>{t.getAllEdges().forEach((e=>{const n=t.getNode(e.source),r=t.getNode(e.target);let i,o;e.data.points?(i=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],i={x:r.data.x,y:r.data.y},o={x:n.data.x,y:n.data.y}),e.data.points.unshift(Nm(n.data,i)),e.data.points.push(Nm(r.data,o))}))},Zy=t=>{t.getAllEdges().forEach((t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},Qy=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Jy=t=>{t.getAllNodes().forEach((e=>{var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){const n=t.getNode(e.id),o=t.getNode(n.data.borderTop),a=t.getNode(n.data.borderBottom),s=t.getNode(n.data.borderLeft[(null===(r=n.data.borderLeft)||void 0===r?void 0:r.length)-1]),l=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==l?void 0:l.data.x)-(null==s?void 0:s.data.x))||10,n.data.height=Math.abs((null==a?void 0:a.data.y)-(null==o?void 0:o.data.y))||10,n.data.x=((null==s?void 0:s.data.x)||0)+n.data.width/2,n.data.y=((null==o?void 0:o.data.y)||0)+n.data.height/2}})),t.getAllNodes().forEach((e=>{"border"===e.data.dummy&&t.removeNode(e.id)}))},tb=t=>{t.getAllEdges().forEach((e=>{if(e.source===e.target){const n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}}))},eb=t=>{const e=Om(t);null==e||e.forEach((e=>{let n=0;null==e||e.forEach(((e,r)=>{var i;const o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach((e=>{Mm(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},nb=t=>{t.getAllNodes().forEach((e=>{const n=t.getNode(e.id);if("selfedge"===n.data.dummy){const r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,a=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{y:o,x:i+a},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}}))},rb=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},ib=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},ob=Array.isArray,ab=t=>{const e=[],n=t.length;for(let r=0;r<n;r+=1){e[r]=[];for(let i=0;i<n;i+=1)r===i?e[r][i]=0:0!==t[r][i]&&t[r][i]?e[r][i]=t[r][i]:e[r][i]=1/0}for(let t=0;t<n;t+=1)for(let r=0;r<n;r+=1)for(let i=0;i<n;i+=1)e[r][i]>e[r][t]+e[t][i]&&(e[r][i]=e[r][t]+e[t][i]);return e},sb=(t,e)=>{const{nodes:n,edges:r}=t,i=[],o={};if(!n)throw new Error("invalid nodes data!");return n&&n.forEach(((t,e)=>{o[t.id]=e;i.push([])})),null==r||r.forEach((t=>{const{source:e,target:n}=t,r=o[e],a=o[n];void 0!==r&&void 0!==a&&(i[r][a]=1,i[a][r]=1)})),i},lb=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),ub=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let l=0;l<e.length;l++){const u=e[l];if(t.hasNode(u.id)&&!(null==a?void 0:a(u))){if(null==s?void 0:s(u))return;"TB"===r&&n(u),ub(t,t.getChildren(u.id,i),n,r,i,o),"TB"!==r&&n(u)}}},cb=t=>{if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){const e=[];return t.forEach((t=>{e.push(t)})),e.map((t=>cb(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=cb(t[n])})),e}return t},hb=(t,e)=>{const n=cb(t);return n.data=n.data||{},e&&(ae(n.data.x)||(n.data.x=Math.random()*e[0]),ae(n.data.y)||(n.data.y=Math.random()*e[1])),n};function db(t){if(!t)return[0,0,0];if(ae(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function fb(t,e){let n;return n=Ut(e)?e:ae(e)?()=>e:()=>t,n}function pb(t,e,n=!0){return e||0===e?Ut(e)?e:ae(e)?()=>e:Array.isArray(e)?()=>n?Math.max(...e)||t:e:qt(e)&&e.width&&e.height?()=>n?Math.max(e.width,e.height)||t:[e.width,e.height]:()=>t:e=>{const{size:r}=e.data||{};return r?Array.isArray(r)?n?Math.max(...r)||t:r:qt(r)&&r.width&&r.height?n?Math.max(r.width,r.height)||t:[r.width,r.height]:r:t}}const gb=(t,e,n=10)=>{let r;const i="function"==typeof e?e:()=>e||0;r=t?Array.isArray(t)?e=>t:Ut(t)?t:e=>t:t=>{var e,r,i;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return null===(r=t.data)||void 0===r?void 0:r.bboxSize;if(null===(i=t.data)||void 0===i?void 0:i.size){const e=t.data.size;return Array.isArray(e)?e:qt(e)?[e.width,e.height]:e}return n};return t=>{const e=r(t),n=i(t);return Math.max(...db(e))+n}},vb={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class mb{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},vb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{nodeSize:i,align:o,rankdir:a="TB",ranksep:s,nodesep:l,ranksepFunc:u,nodesepFunc:c,edgeLabelSpace:h,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:v,sortByCombo:m,preset:y}=r,b=new Yg({tree:[]}),x=fb(s||50,u),E=fb(l||50,c);let w=E,k=x;"LR"!==a&&"RL"!==a||(w=x,k=E);const M=pb(10,i,!1),S=e.getAllNodes(),N=e.getAllEdges();let O;S.forEach((t=>{const e=db(M(t)),n=k(t),r=w(t),i=e[0]+2*r,o=e[1]+2*n,a=t.data.layer;ae(a)?b.addNode({id:t.id,data:{width:i,height:o,layer:a}}):b.addNode({id:t.id,data:{width:i,height:o}})})),m&&(b.attachTreeStructure("combo"),S.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),N.forEach((t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),(null==y?void 0:y.length)&&(O=new Yg({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&jy(t,i);const s=Hy(t);let l;n&&(e.ranksep=Uy(s,{rankdir:o,ranksep:a}));try{l=Iy(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}By(t,s)})(b,{prevGraph:O,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:l,align:o});const T=[0,0];if(p){let t=1/0,e=1/0;b.getAllNodes().forEach((n=>{t>n.data.x&&(t=n.data.x),e>n.data.y&&(e=n.data.y)})),b.getAllEdges().forEach((n=>{var r;null===(r=n.data.points)||void 0===r||r.forEach((n=>{t>n.x&&(t=n.x),e>n.y&&(e=n.y)}))})),T[0]=p[0]-t,T[1]=p[1]-e}const C="LR"===a||"RL"===a;if(v);else{const t=new Set,e="BT"===a||"RL"===a?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach((e=>{e.data.x=e.data.x+T[0],e.data.y=e.data.y+T[1],t.add(C?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=C?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=C?(t,e,n)=>{const r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter((t=>t.y<=r&&t.y>=i))}:(t,e,n)=>{const r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter((t=>t.x<=r&&t.x>=i))};b.getAllEdges().forEach(((t,e)=>{var o;h&&g&&"loop"!==t.data.type&&(t.data.controlPoints=yb(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+T[0],y:e+T[1]}))),b.getNode(t.source),b.getNode(t.target),n,C,r,i))}))}let A=[];A=b.getAllNodes().map((t=>hb(t)));const P=b.getAllEdges();t&&(A.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),P.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:A,edges:P}}))}}const yb=(t,e,n,r,i,o,a)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){let{x:t,y:l}=e.data,{x:u,y:c}=n.data;if(i&&(t=e.data.y,l=e.data.x,u=n.data.y,c=n.data.x),c!==l&&t!==u){const h=r.indexOf(l),d=r[h+1];if(d){const t=s[0],e=i?{x:(l+d)/2,y:(null==t?void 0:t.y)||u}:{x:(null==t?void 0:t.x)||u,y:(l+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(c),p=Math.abs(f-h);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(l+c)/2,y:t}:{x:t,y:(l+c)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(c+e)/2,y:(null==n?void 0:n.y)||u}:{x:(null==n?void 0:n.x)||t,y:(c+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},bb=(t,e,n)=>{const r=t.getAllNodes(),i=t.getAllEdges();if(!(null==r?void 0:r.length)){return{nodes:[],edges:i}}if(1===r.length){e&&t.mergeNodeData(r[0].id,{x:n[0],y:n[1]});return{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:n[0],y:n[1]})})],edges:i}}},xb={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class Eb{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},xb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:l=0,endAngle:u=2*Math.PI,angleRatio:c,ordering:h,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),v=e.getAllEdges(),[m,y,b]=kb(i,o,a),x=null==g?void 0:g.length;if(!x||1===x)return bb(e,t,b);const E=(u-l)/x;let{radius:w,startRadius:k,endRadius:M}=r;if(f){const t=fb(10,f),e=pb(10,p);let n=-1/0;g.forEach((t=>{const r=e(t);n<r&&(n=r)}));let r=0;g.forEach(((e,i)=>{r+=0===i?n||10:(t(e)||0)+(n||10)})),w=r/(2*Math.PI)}else w||k||M?!k&&M?k=M:k&&!M&&(M=k):w=Math.min(y,m)/2;const S=E*c;let N=[];N="topology"===h?wb(e,g):"topology-directed"===h?wb(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(hb(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>hb(t)));const O=Math.ceil(x/s);for(let t=0;t<x;++t){let e=w;e||null===k||null===M||(e=k+t*(M-k)/(x-1)),e||(e=10+100*t/(x-1));let n=l+t%O*S+2*Math.PI/s*Math.floor(t/O);d||(n=u-t%O*S-2*Math.PI/s*Math.floor(t/O)),N[t].data.x=b[0]+Math.cos(n)*e,N[t].data.y=b[1]+Math.sin(n)*e}t&&N.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:N,edges:v}}))}}const wb=(t,e,n=!1)=>{const r=[hb(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,l)=>{if(0!==l)if(l!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[l+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const l=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let u=!1;for(let e=0;e<l.length;e++){const n=l[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(hb(n)),i[n.id]=!0,u=!0;break}}let c=0;for(;!u&&(i[e[c].id]||(r.push(hb(e[c])),i[e[c].id]=!0,u=!0),c++,c!==o););}else r.push(hb(s)),i[s.id]=!0,a++})),r};const kb=(t,e,n)=>{let r=t,i=e,o=n;return r||"undefined"==typeof window||(r=window.innerWidth),i||"undefined"==typeof window||(i=window.innerHeight),o||(o=[r/2,i/2]),[r,i,o]},Mb={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Sb{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Mb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:l,sweep:u,clockwise:c,equidistant:h,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,v=e.getAllNodes(),m=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,x=i||[y/2,b/2];if(!(null==v?void 0:v.length)||1===v.length)return bb(e,t,x);const E=[];let w,k=0;ob(p)?w=Math.max(p[0],p[1]):Ut(p)?(w=-1/0,v.forEach((t=>{const e=Math.max(...db(p(t)));e>w&&(w=e)}))):w=p,ob(g)?k=Math.max(g[0],g[1]):ae(g)&&(k=g),v.forEach((t=>{const e=hb(t);E.push(e);let n=w;const{data:r}=e;ob(r.size)?n=Math.max(r.size[0],r.size[1]):ae(r.size)?n=r.size:qt(r.size)&&(n=Math.max(r.size.width,r.size.height)),w=Math.max(w,n),Ut(g)&&(k=Math.max(g(t),k))}));const M={};E.forEach(((t,e)=>{M[t.id]=e}));let S=s;ne(S)&&void 0!==E[0].data[S]||(S="degree"),"degree"===S?E.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):E.sort(((t,e)=>e.data[S]-t.data[S]));const N=E[0],O=(l||("degree"===S?e.getDegree(N.id,"both"):N.data[S]))/4,T=[{nodes:[]}];let C=T[0];E.forEach((t=>{if(C.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(C.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(C.nodes[0].data[S]-t.data[S]);O&&n>=O&&(C={nodes:[]},T.push(C))}C.nodes.push(t)}));let A=w+k;if(!d){const t=T.length>0&&T[0].nodes.length>1,e=(Math.min(y,b)/2-A)/(T.length+(t?1:0));A=Math.min(A,e)}let P=0;if(T.forEach((t=>{const e=void 0===u?2*Math.PI-2*Math.PI/t.nodes.length:u;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){const e=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),r=Math.sqrt(A*A/(e*e+n*n));P=Math.max(r,P)}t.r=P,P+=A})),h){let t=0,e=0;for(let n=0;n<T.length;n++){const r=(T[n].r||0)-e;t=Math.max(t,r)}e=0,T.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}T.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(c?1:-1)*e*r;t.data.x=x[0]+n*Math.cos(i),t.data.y=x[1]+n*Math.sin(i)}))})),t&&E.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:E,edges:m}}))}}function Nb(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,l,u,c,h,d,f=t._root,p={data:r},g=t._x0,v=t._y0,m=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a,i=f,!(f=f[h=c<<1|u]))return i[h]=p,t;if(s=+t._x.call(null,f.data),l=+t._y.call(null,f.data),e===s&&n===l)return p.next=f,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a}while((h=c<<1|u)==(d=(l>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function Ob(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Tb(t){return t[0]}function Cb(t){return t[1]}function Ab(t,e,n){var r=new Pb(null==e?Tb:e,null==n?Cb:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Pb(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Rb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Db=Ab.prototype=Pb.prototype;function Lb(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,l,u,c,h,d,f,p,g,v,m=t._root,y={data:i},b=t._x0,x=t._y0,E=t._z0,w=t._x1,k=t._y1,M=t._z1;if(!m)return t._root=y,t;for(;m.length;)if((d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l,o=m,!(m=m[g=p<<2|f<<1|d]))return o[g]=y,t;if(u=+t._x.call(null,m.data),c=+t._y.call(null,m.data),h=+t._z.call(null,m.data),e===u&&n===c&&r===h)return y.next=m,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l}while((g=p<<2|f<<1|d)==(v=(h>=l)<<2|(c>=s)<<1|u>=a));return o[v]=m,o[g]=y,t}function _b(t,e,n,r,i,o,a){this.node=t,this.x0=e,this.y0=n,this.z0=r,this.x1=i,this.y1=o,this.z1=a}Db.copy=function(){var t,e,n=new Pb(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=Rb(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=Rb(e));return n},Db.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Nb(this.cover(e,n),e,n,t)},Db.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<o;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<l&&(l=r),r>c&&(c=r),i<u&&(u=i),i>h&&(h=i));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<o;++n)Nb(this,a[n],s[n],t[n]);return this},Db.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a,s,l=i-n||1,u=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=u,u=a,l*=2,s){case 0:i=n+l,o=r+l;break;case 1:n=i-l,o=r+l;break;case 2:i=n+l,r=o-l;break;case 3:n=i-l,r=o-l}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},Db.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Db.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},Db.find=function(t,e,n){var r,i,o,a,s,l,u,c=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new Ob(g,c,h,d,f)),null==n?n=1/0:(c=t-n,h=e-n,d=t+n,f=e+n,n*=n);l=p.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(o=l.y0)>f||(a=l.x1)<c||(s=l.y1)<h))if(g.length){var v=(i+a)/2,m=(o+s)/2;p.push(new Ob(g[3],v,m,a,s),new Ob(g[2],i,m,v,s),new Ob(g[1],v,o,a,m),new Ob(g[0],i,o,v,m)),(u=(e>=m)<<1|t>=v)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-u],p[p.length-1-u]=l)}else{var y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),x=y*y+b*b;if(x<n){var E=Math.sqrt(n=x);c=t-E,h=e-E,d=t+E,f=e+E,r=g.data}}return r},Db.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,l,u,c,h,d,f=this._root,p=this._x0,g=this._y0,v=this._x1,m=this._y1;if(!f)return this;if(f.length)for(;;){if((u=o>=(s=(p+v)/2))?p=s:v=s,(c=a>=(l=(g+m)/2))?g=l:m=l,e=f,!(f=f[h=c<<1|u]))return this;if(!f.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},Db.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Db.root=function(){return this._root},Db.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Db.visit=function(t){var e,n,r,i,o,a,s=[],l=this._root;for(l&&s.push(new Ob(l,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&l.length){var u=(r+o)/2,c=(i+a)/2;(n=l[3])&&s.push(new Ob(n,u,c,o,a)),(n=l[2])&&s.push(new Ob(n,r,c,u,a)),(n=l[1])&&s.push(new Ob(n,u,i,o,c)),(n=l[0])&&s.push(new Ob(n,r,i,u,c))}return this},Db.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Ob(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,l=e.x1,u=e.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&n.push(new Ob(o,a,s,c,h)),(o=i[1])&&n.push(new Ob(o,c,s,l,h)),(o=i[2])&&n.push(new Ob(o,a,h,c,u)),(o=i[3])&&n.push(new Ob(o,c,h,l,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Db.x=function(t){return arguments.length?(this._x=t,this):this._x},Db.y=function(t){return arguments.length?(this._y=t,this):this._y};const Ib=(t,e,n,r,i,o)=>Math.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function jb(t){return t[0]}function Bb(t){return t[1]}function Fb(t){return t[2]}function zb(t,e,n,r){var i=new Gb(null==e?jb:e,null==n?Bb:n,null==r?Fb:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Gb(t,e,n,r,i,o,a,s,l){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=l,this._root=void 0}function Vb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Wb=zb.prototype=Gb.prototype;Wb.copy=function(){var t,e,n=new Gb(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=Vb(r),n;for(t=[{source:r,target:n._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(8)}):r.target[i]=Vb(e));return n},Wb.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Lb(this.cover(e,n,r),e,n,r,t)},Wb.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let o=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(f=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>l&&(l=d),f<a&&(a=f),f>u&&(u=f),p<s&&(s=p),p>c&&(c=p));if(o>l||a>u||s>c)return this;this.cover(o,a,s).cover(l,u,c);for(let o=0;o<e;++o)Lb(this,n[o],r[o],i[o],t[o]);return this},Wb.cover=function(t,e,n){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,o=this._z0,a=this._x1,s=this._y1,l=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,l=(o=Math.floor(n))+1;else{for(var u,c,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=l;)switch(c=(n<o)<<2|(e<i)<<1|t<r,(u=new Array(8))[c]=d,d=u,h*=2,c){case 0:a=r+h,s=i+h,l=o+h;break;case 1:r=a-h,s=i+h,l=o+h;break;case 2:a=r+h,i=s-h,l=o+h;break;case 3:r=a-h,i=s-h,l=o+h;break;case 4:a=r+h,s=i+h,o=l-h;break;case 5:r=a-h,s=i+h,o=l-h;break;case 6:a=r+h,i=s-h,o=l-h;break;case 7:r=a-h,i=s-h,o=l-h}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=l,this},Wb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Wb.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Wb.find=function(t,e,n,r){var i,o,a,s,l,u,c,h,d,f=this._x0,p=this._y0,g=this._z0,v=this._x1,m=this._y1,y=this._z1,b=[],x=this._root;for(x&&b.push(new _b(x,f,p,g,v,m,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,v=t+r,m=e+r,y=n+r,r*=r);h=b.pop();)if(!(!(x=h.node)||(o=h.x0)>v||(a=h.y0)>m||(s=h.z0)>y||(l=h.x1)<f||(u=h.y1)<p||(c=h.z1)<g))if(x.length){var E=(o+l)/2,w=(a+u)/2,k=(s+c)/2;b.push(new _b(x[7],E,w,k,l,u,c),new _b(x[6],o,w,k,E,u,c),new _b(x[5],E,a,k,l,w,c),new _b(x[4],o,a,k,E,w,c),new _b(x[3],E,w,s,l,u,k),new _b(x[2],o,w,s,E,u,k),new _b(x[1],E,a,s,l,w,k),new _b(x[0],o,a,s,E,w,k)),(d=(n>=k)<<2|(e>=w)<<1|t>=E)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=h)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),N=n-+this._z.call(null,x.data),O=M*M+S*S+N*N;if(O<r){var T=Math.sqrt(r=O);f=t-T,p=e-T,g=n-T,v=t+T,m=e+T,y=n+T,i=x.data}}return i},Wb.findAllWithinRadius=function(t,e,n,r){const i=[],o=t-r,a=e-r,s=n-r,l=t+r,u=e+r,c=n+r;return this.visit(((h,d,f,p,g,v,m)=>{if(!h.length)do{const o=h.data;Ib(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(h=h.next);return d>l||f>u||p>c||g<o||v<a||m<s})),i},Wb.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,n,r,i,o,a,s,l,u,c,h,d,f,p,g,v=this._root,m=this._x0,y=this._y0,b=this._z0,x=this._x1,E=this._y1,w=this._z1;if(!v)return this;if(v.length)for(;;){if((h=o>=(l=(m+x)/2))?m=l:x=l,(d=a>=(u=(y+E)/2))?y=u:E=u,(f=s>=(c=(b+w)/2))?b=c:w=c,e=v,!(v=v[p=f<<2|d<<1|h]))return this;if(!v.length)break;(e[p+1&7]||e[p+2&7]||e[p+3&7]||e[p+4&7]||e[p+5&7]||e[p+6&7]||e[p+7&7])&&(n=e,g=p)}for(;v.data!==t;)if(r=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(n?n[g]=v:this._root=v),this):(this._root=i,this)},Wb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Wb.root=function(){return this._root},Wb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Wb.visit=function(t){var e,n,r,i,o,a,s,l,u=[],c=this._root;for(c&&u.push(new _b(c,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=u.pop();)if(!t(c=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,l=e.z1)&&c.length){var h=(r+a)/2,d=(i+s)/2,f=(o+l)/2;(n=c[7])&&u.push(new _b(n,h,d,f,a,s,l)),(n=c[6])&&u.push(new _b(n,r,d,f,h,s,l)),(n=c[5])&&u.push(new _b(n,h,i,f,a,d,l)),(n=c[4])&&u.push(new _b(n,r,i,f,h,d,l)),(n=c[3])&&u.push(new _b(n,h,d,o,a,s,f)),(n=c[2])&&u.push(new _b(n,r,d,o,h,s,f)),(n=c[1])&&u.push(new _b(n,h,i,o,a,d,f)),(n=c[0])&&u.push(new _b(n,r,i,o,h,d,f))}return this},Wb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new _b(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,l=e.z0,u=e.x1,c=e.y1,h=e.z1,d=(a+u)/2,f=(s+c)/2,p=(l+h)/2;(o=i[0])&&n.push(new _b(o,a,s,l,d,f,p)),(o=i[1])&&n.push(new _b(o,d,s,l,u,f,p)),(o=i[2])&&n.push(new _b(o,a,f,l,d,c,p)),(o=i[3])&&n.push(new _b(o,d,f,l,u,c,p)),(o=i[4])&&n.push(new _b(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new _b(o,d,s,p,u,f,h)),(o=i[6])&&n.push(new _b(o,a,f,p,d,c,h)),(o=i[7])&&n.push(new _b(o,d,f,p,u,c,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Wb.x=function(t){return arguments.length?(this._x=t,this):this._x},Wb.y=function(t){return arguments.length?(this._y=t,this):this._y},Wb.z=function(t){return arguments.length?(this._z=t,this):this._z};function Hb(t,e,n,r,i=2){const o=e/n,a=t.getAllNodes(),s=a.map(((t,e)=>{const{nodeStrength:n,x:r,y:i,z:a,size:s}=t.data;return{x:r,y:i,z:a,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n}})),l=(2===i?Ab(s,(t=>t.x),(t=>t.y)):zb(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Ub),u=new Map;return s.forEach((t=>{u.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>$b(e,r,i,o,a,t,n)))}(t,l,i)})),s.map(((t,e)=>{const{id:n,data:i}=a[e],{mass:o=1}=i;r[n]={x:t.vx/o,y:t.vy/o,z:t.vz/o}})),r}function Ub(t){let e=0,n=0,r=0,i=0,o=0;const a=t.length;if(a){for(let s=0;s<a;s++){const a=t[s];a&&a.weight&&(e+=a.weight,n+=a.x*a.weight,r+=a.y*a.weight,i+=a.z*a.weight,o+=a.size*a.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const $b=(t,e,n,r,i,o,a)=>{var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===o.id)return;const l=[n,r,i][a-1],u=o.x-t.x||.1,c=o.y-t.y||.1,h=o.z-t.z||.1,d=[u,c,h],f=l-e;let p=0;for(let t=0;t<a;t++)p+=d[t]*d[t];const g=Math.sqrt(p)*p;if(f*f*.81<p){const e=t.weight/g;return o.vx+=u*e,o.vy+=c*e,o.vz+=h*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=u*e,o.vy+=c*e,o.vz+=h*e}};const Yb={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"};class qb{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Yb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;(this.judgingDistance>this.lastOptions.minMovement||e<1)&&e<t;e++)this.runOneStep(this.lastCalcGraph,this.lastGraph,e,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericForceLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),{dimensions:s,width:l,height:u,nodeSize:c,getMass:h,nodeStrength:d,edgeStrength:f,linkDistance:p}=a,g=i.map(((t,e)=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{x:ae(t.data.x)?t.data.x:Math.random()*l,y:ae(t.data.y)?t.data.y:Math.random()*u,z:ae(t.data.z)?t.data.z:Math.random()*Math.sqrt(l*u),size:c(t)||30,mass:h(t),nodeStrength:d(t)})}))),v=o.map((t=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{edgeStrength:f(t),linkDistance:p(t,e.getNode(t.source),e.getNode(t.target))})})));if(!(null==i?void 0:i.length))return this.lastResult={nodes:[],edges:o},{nodes:[],edges:o};const m={};i.forEach(((t,e)=>{m[t.id]={x:0,y:0,z:0}}));const y=new Yg({nodes:g,edges:v});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:x,onTick:E}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=m,"undefined"==typeof window)return;let w=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Jb(e,g),edges:o}),this.runOneStep(y,e,w,m,a),this.updatePosition(e,y,m,a),t&&g.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0}))),null==E||E({nodes:Jb(e,g),edges:o}),w++,(w>=b||this.judgingDistance<x)&&(window.clearInterval(this.timeInterval),n({nodes:Jb(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o}=t;n.width=r||"undefined"==typeof window?r:window.innerWidth,n.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(n.center=[n.width/2,n.height/2]),o||(n.getMass=t=>{let n=1;ae(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);const r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n}),n.nodeSize=gb(t.nodeSize,t.nodeSpacing);const a=t.linkDistance?fb(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=a,n.nodeStrength=fb(1,t.nodeStrength),n.edgeStrength=fb(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:l}=t,u=e.getAllNodes(),c=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let h,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&l&&(h=Xb(e,l),d=Array.from(new Set(null==u?void 0:u.map((t=>t.data[l]))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=h[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==d?void 0:d.length)?1:t.clusterNodeStrength(e)},others:1,center:t=>{const n=e.getDegree(t.id,"both");if(!n)return{x:100,y:100,z:0};let r;if(1===n){const{sameTypeLeaves:e=[]}=h[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Qb(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),s&&l){h||(h=Xb(e,l)),d||(d=Array.from(new Set(u.map((t=>t.data[l]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=u.filter((e=>e.data[l]===t)).map((t=>e.getNode(t.id)));n[t]=Qb(r)})),t.centripetalOptions=Object.assign(c,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[l]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}const{leaf:f,single:p,others:g}=t.centripetalOptions||{};f&&"function"!=typeof f&&(t.centripetalOptions.leaf=()=>f),p&&"function"!=typeof p&&(t.centripetalOptions.single=()=>p),g&&"function"!=typeof g&&(t.centripetalOptions.others=()=>g)}runOneStep(t,e,n,r,i){const o={},a=t.getAllNodes(),s=t.getAllEdges();if(!(null==a?void 0:a.length))return;const{monitor:l}=i;if(this.calRepulsive(t,o,i),s&&this.calAttractive(t,o,i),this.calGravity(t,e,o,i),this.updateVelocity(t,o,r,i),l){l({energy:this.calTotalEnergy(o,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:n})}}calTotalEnergy(t,e){if(!(null==e?void 0:e.length))return 0;let n=0;return e.forEach(((e,r)=>{const i=t[e.id].x,o=t[e.id].y,a=3===this.options.dimensions?t[e.id].z:0,s=i*i+o*o+a*a,{mass:l=1}=e.data;n+=l*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;Hb(t,i,o*o,e,r)}calAttractive(t,e,n){const{dimensions:r,nodeSize:i}=n;t.getAllEdges().forEach(((n,o)=>{const{source:a,target:s}=n,l=t.getNode(a),u=t.getNode(s);if(!l||!u)return;let c=u.data.x-l.data.x,h=u.data.y-l.data.y,d=3===r?u.data.z-l.data.z:0;c||h||(c=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(c*c+h*h+d*d);if(f<i(l)+i(u))return;const p=c/f,g=h/f,v=d/f,{linkDistance:m=200,edgeStrength:y=200}=n.data||{},b=(m-f)*y,x=1/(l.data.mass||1),E=1/(u.data.mass||1),w=p*b,k=g*b,M=v*b;e[a].x-=w*x,e[a].y-=k*x,e[a].z-=M*x,e[s].x+=w*E,e[s].y+=k*E,e[s].z+=M*E}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:l,height:u,center:c,gravity:h,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:v,z:m}=f,y=e.getNode(o);let b=0,x=0,E=0,w=h;const k=t.getDegree(o,"in"),M=t.getDegree(o,"out"),S=t.getDegree(o,"both"),N=null==i?void 0:i(y,S);if(N){const[t,e,n]=N;b=g-t,x=v-e,w=n}else b=g-c[0],x=v-c[1],E=m-c[2];if(w&&(n[o].x-=w*b/p,n[o].y-=w*x/p,n[o].z-=w*E/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:c,y:h,z:f,centerStrength:b}=(null==i?void 0:i(y,a,s,l,u))||{x:0,y:0,z:0,centerStrength:0};if(!ae(c)||!ae(h))return;const x=(g-c)/p,E=(v-h)/p,w=(m-f)/p;if(b&&(n[o].x-=b*x,n[o].y-=b*E,n[o].z-=b*w),0===S){const t=e(y);if(!t)return;return n[o].x-=t*x,n[o].y-=t*E,void(n[o].z-=t*w)}if(0===k||0===M){const e=t(y,a,s);if(!e)return;return n[o].x-=e*x,n[o].y-=e*E,void(n[o].z-=e*w)}const N=r(y);if(!N)return;n[o].x-=N*x,n[o].y-=N*E,n[o].z-=N*w}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,l=t.getAllNodes();(null==l?void 0:l.length)&&l.forEach((t=>{const{id:r}=t;let l=(n[r].x+e[r].x*a)*i||.01,u=(n[r].y+e[r].y*a)*i||.01,c=3===s?(n[r].z+e[r].z*a)*i||.01:0;const h=Math.sqrt(l*l+u*u+c*c);if(h>o){const t=o/h;l*=t,u*=t,c*=t}n[r]={x:l,y:u,z:c}}))}updatePosition(t,e,n,r){const{distanceThresholdMode:i,interval:o,dimensions:a}=r,s=e.getAllNodes();if(!(null==s?void 0:s.length))return void(this.judgingDistance=0);let l=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,u=t.getNode(s);if(ae(u.data.fx)&&ae(u.data.fy))return void e.mergeNodeData(s,{x:u.data.fx,y:u.data.fy,z:3===a?u.data.fz:void 0});const c=n[s].x*o,h=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+c,y:r.data.y+h,z:r.data.z+d});const f=Math.sqrt(c*c+h*h+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:l+=f}})),i&&"mean"!==i||(this.judgingDistance=l/s.length)}}const Xb=(t,e)=>{const n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};const r={};return n.forEach(((n,i)=>{1===t.getDegree(n.id,"both")&&(r[n.id]=Kb(t,"leaf",n,e))})),r},Kb=(t,e,n,r)=>{const i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out");let a=n,s=[];0===i?(a=t.getSuccessors(n.id)[0],s=t.getNeighbors(a.id)):0===o&&(a=t.getPredecessors(n.id)[0],s=t.getNeighbors(a.id)),s=s.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")));return{coreNode:a,siblingLeaves:s,sameTypeLeaves:Zb(t,e,r,n,s)}},Zb=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out"))),a},Qb=t=>{const e={x:0,y:0};t.forEach((t=>{const{x:n,y:r}=t.data;e.x+=n||0,e.y+=r||0}));const n=t.length||1;return{x:e.x/n,y:e.y/n}},Jb=(t,e)=>e.map((e=>{const{id:n,data:r}=e,i=t.getNode(n);return Object.assign(Object.assign({},i),{data:Object.assign(Object.assign({},i.data),{x:r.x,y:r.y,z:r.z})})}));var tx={};const ex=Object.prototype.toString;function nx(t){const e=ex.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var rx=w(Object.freeze({__proto__:null,isAnyArray:nx}));var ix=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!nx(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]<a&&(a=t[s]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]>a&&(a=t[s]);return a}(t);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=n.min,a=void 0===o?n.autoMinMax?r:0:o,s=n.max,l=void 0===s?n.autoMinMax?i:1:s;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var u=(l-a)/(i-r),c=0;c<t.length;c++)e[c]=(t[c]-r)*u+a;return e}}),ox=w(ix);Object.defineProperty(tx,"__esModule",{value:!0});var ax=rx,sx=ox;const lx=" ".repeat(2),ux=" ".repeat(4);function cx(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${lx}[\n${ux}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),l=Math.min(a,n),u=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){i=!0;break t}}for(let e=0;e<s;e++){let n=[];for(let o=0;o<l;o++)n.push(hx(t.get(e,o),r,i));u.push(`${n.join(" ")}`)}l!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);s!==o&&u.push(`... ${o-e} more rows`);return u.join(`\n${ux}`)}(t,n,r,i,o)}\n${lx}]\n${lx}rows: ${t.rows}\n${lx}columns: ${t.columns}\n}`}function hx(t,e,n){return(t>=0&&n?` ${dx(t,e-1)}`:dx(t,e)).padEnd(e)}function dx(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function fx(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function px(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function gx(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function vx(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function mx(t,e){if(!ax.isAnyArray(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}function yx(t,e){if(!ax.isAnyArray(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}function bx(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(Ex("startRow",e),Ex("endRow",n),Ex("startColumn",r),Ex("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function xx(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function Ex(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function wx(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class kx{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new Sx(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.set(i,t,n[i*e+t]);return r}static rowVector(t){let e=new Sx(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new Sx(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new Sx(t,e)}static ones(t,e){return new Sx(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new Sx(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,r());return i}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:o=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let a=i-r,s=new Sx(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=r+Math.round(o()*a);s.set(n,t,e)}return s}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let r=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<r;t++)i.set(t,t,n);return i}static diag(t,e,n){let r=t.length;void 0===e&&(e=r),void 0===n&&(n=e);let i=Math.min(r,e,n),o=this.zeros(e,n);for(let e=0;e<i;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new Sx(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.min(t.get(o,n),e.get(o,n)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new this(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.max(t.get(o,n),e.get(o,n)));return i}static checkMatrix(t){return kx.isMatrix(t)?t:new Sx(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let a=i;a<e;a++){let e=t.get(n,a)-o*t.get(r,a);t.set(n,a,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new Sx(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)r.setSubMatrix(this,this.rows*t,this.columns*e);return r}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){fx(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return Sx.rowVector(this.getRow(t))}setRow(t,e){fx(this,t),e=gx(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){fx(this,t),fx(this,e);for(let n=0;n<this.columns;n++){let r=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,r)}return this}getColumn(t){px(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return Sx.columnVector(this.getColumn(t))}setColumn(t,e){px(this,t),e=vx(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){px(this,t),px(this,e);for(let n=0;n<this.rows;n++){let r=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,r)}return this}addRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){fx(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){px(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){wx(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){wx(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}maxRow(t){if(fx(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){fx(this,t),wx(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(fx(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){fx(this,t),wx(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r),n[1]=r);return n}maxColumn(t){if(px(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){px(this,t),wx(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(px(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){px(this,t),wx(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){kx.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}mmul(t){t=Sx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new Sx(e,r),o=new Float64Array(n);for(let a=0;a<r;a++){for(let e=0;e<n;e++)o[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,a,e)}}return i}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=Sx.eye(this.rows),n=this;for(let r=t;r>=1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=Sx.checkMatrix(t);let e=new Sx(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),a=this.get(1,0),s=t.get(1,0),l=this.get(1,1),u=t.get(1,1),c=(n+l)*(r+u),h=(a+l)*r,d=n*(o-u),f=l*(s-r),p=(n+i)*u,g=c+f-p+(i-l)*(s+u),v=d+p,m=h+f,y=c-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,v),e.set(1,0,m),e.set(1,1,y),e}strassen3x3(t){t=Sx.checkMatrix(t);let e=new Sx(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),a=this.get(1,1),s=this.get(1,2),l=this.get(2,0),u=this.get(2,1),c=this.get(2,2),h=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),v=t.get(1,2),m=t.get(2,0),y=t.get(2,1),b=t.get(2,2),x=(n-o)*(-d+g),E=(-n+o+a)*(h-d+g),w=(o+a)*(-h+d),k=n*h,M=(-n+l+u)*(h-f+v),S=(-n+l)*(f-v),N=(l+u)*(-h+f),O=(-i+u+c)*(g+m-y),T=(i-c)*(g-y),C=i*m,A=(u+c)*(-m+y),P=(-i+a+s)*(v+m-b),R=(i-s)*(v-b),D=(a+s)*(-m+b),L=k+C+r*p,_=(n+r+i-o-a-u-c)*g+E+w+k+O+C+A,I=k+M+N+(n+r+i-a-s-l-u)*v+C+P+D,j=x+a*(-h+d+p-g-v-m+b)+E+k+C+P+R,B=x+E+w+k+s*y,F=C+P+R+D+o*f,z=k+M+S+u*(-h+f+p-g-v-m+y)+O+T+C,G=O+T+C+A+l*d,V=k+M+S+N+c*b;return e.set(0,0,L),e.set(0,1,_),e.set(0,2,I),e.set(1,0,j),e.set(1,1,B),e.set(1,2,F),e.set(2,0,z),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=Sx.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function a(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=kx.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),l=Math.max(r,o);return e=a(e,s,l),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=a(e,r+1,i+1),n=a(n,r+1,i+1)):r%2==1?(e=a(e,r+1,i),n=a(n,r+1,i)):i%2==1&&(e=a(e,r,i+1),n=a(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),l=e.subMatrix(0,o-1,0,s-1),u=n.subMatrix(0,o-1,0,s-1),c=e.subMatrix(0,o-1,s,e.columns-1),h=n.subMatrix(0,o-1,s,n.columns-1),d=e.subMatrix(o,e.rows-1,0,s-1),f=n.subMatrix(o,n.rows-1,0,s-1),p=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),v=t(kx.add(l,p),kx.add(u,g),o,s),m=t(kx.add(d,p),u,o,s),y=t(l,kx.sub(h,g),o,s),b=t(p,kx.sub(f,u),o,s),x=t(kx.add(l,c),g,o,s),E=t(kx.sub(d,l),kx.add(u,h),o,s),w=t(kx.sub(c,p),kx.add(f,g),o,s),k=kx.add(v,b);k.sub(x),k.add(w);let M=kx.add(y,x),S=kx.add(m,b),N=kx.sub(v,m);N.add(y),N.add(E);let O=kx.zeros(2*k.rows,2*k.columns);return O=O.setSubMatrix(k,0,0),O=O.setSubMatrix(M,k.rows,0),O=O.setSubMatrix(S,0,k.columns),O=O.setSubMatrix(N,k.rows,k.columns),O.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,l),s,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Sx(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&sx(i,{min:e,max:n,output:i}),r.setRow(t,i)}return r}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Sx(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&sx(i,{min:e,max:n,output:i}),r.setColumn(t,i)}return r}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),r=this.get(e,this.columns-1-n);this.set(e,n,r),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),r=this.get(this.rows-1-n,e);this.set(n,e,r),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=Sx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new Sx(e*r,n*i);for(let a=0;a<e;a++)for(let e=0;e<n;e++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)o.set(r*a+n,i*e+s,this.get(a,e)*t.get(n,s));return o}kroneckerSum(t){if(t=Sx.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,r=this.kroneckerProduct(Sx.eye(n,n)),i=Sx.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new Sx(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=Mx){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Mx){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){bx(this,t,e,n,r);let i=new Sx(e-t+1,r-n+1);for(let o=t;o<=e;o++)for(let e=n;e<=r;e++)i.set(o-t,e-n,this.get(o,e));return i}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new Sx(t.length,n-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);r.set(i,o-e,this.get(t[i],o))}return r}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new Sx(n-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);r.set(o-e,i,this.get(o,t[i]))}return r}setSubMatrix(t,e,n){if((t=Sx.checkMatrix(t)).isEmpty())return this;bx(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r<t.rows;r++)for(let i=0;i<t.columns;i++)this.set(e+r,n+i,t.get(r,i));return this}selection(t,e){mx(this,t),yx(this,e);let n=new Sx(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new Sx(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=xx(t.rows);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]+=t.get(n,r);return e}(this);case"column":return function(t){let e=xx(t.columns);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]+=t.get(n,r);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e+=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=xx(t.rows,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]*=t.get(n,r);return e}(this);case"column":return function(t){let e=xx(t.columns,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]*=t.get(n,r);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e*=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!ax.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,l=0;for(let e=0;e<i;e++)l=t.get(a,e)-n[a],r+=l,s+=l*l;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!ax.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,l=0;for(let e=0;e<r;e++)l=t.get(e,a)-n[a],i+=l,s+=l*l;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return function(t,e,n){const r=t.rows,i=t.columns,o=r*i;let a=0,s=0,l=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)l=t.get(e,r)-n,a+=l,s+=l*l;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}(this,n,r);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!ax.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[n])}(this,n),this;case"column":if(!ax.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[r])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=t.get(n,e)**2/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!ax.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=t.get(e,n)**2/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!ax.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[r])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=t.get(i,r)**2/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return cx(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function Mx(t,e){return t-e}kx.prototype.klass="Matrix","undefined"!=typeof Symbol&&(kx.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return cx(this)}),kx.random=kx.rand,kx.randomInt=kx.randInt,kx.diagonal=kx.diag,kx.prototype.diagonal=kx.prototype.diag,kx.identity=kx.eye,kx.prototype.negate=kx.prototype.neg,kx.prototype.tensorProduct=kx.prototype.kroneckerProduct;let Sx=class t extends kx{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),t.isMatrix(e))this.#t(e.rows,e.columns),t.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!ax.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!t[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return fx(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),fx(this,t,!0),e=Float64Array.from(gx(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){px(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let r=0;r<t;r++)n[r]=this.data[e][r];for(let r=t+1;r<this.columns;r++)n[r-1]=this.data[e][r];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),px(this,t,!0),e=vx(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t);return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t.get(e,n));return this}}(kx,Sx);class Nx extends kx{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return Sx.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),Sx.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=Sx.copy(t,new Sx(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new Sx(t,t);else if(this.#e=new Sx(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new Nx(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new Sx(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const r=new Nx(n);for(let i=0,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}Nx.prototype.klassType="SymmetricMatrix";class Ox extends Nx{static isDistanceMatrix(t){return Nx.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new Nx(this)}clone(){const t=new Ox(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=1+ ++o);return r}}Ox.prototype.klassSubType="DistanceMatrix";class Tx extends kx{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class Cx extends Tx{constructor(t,e,n){mx(t,e),yx(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class Ax extends kx{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class Px extends kx{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class Rx{constructor(t){let e,n,r,i,o,a,s,l,u,c=(t=Px.checkMatrix(t)).clone(),h=c.rows,d=c.columns,f=new Float64Array(h),p=1;for(e=0;e<h;e++)f[e]=e;for(l=new Float64Array(h),n=0;n<d;n++){for(e=0;e<h;e++)l[e]=c.get(e,n);for(e=0;e<h;e++){for(u=Math.min(e,n),o=0,r=0;r<u;r++)o+=c.get(e,r)*l[r];l[e]-=o,c.set(e,n,l[e])}for(i=n,e=n+1;e<h;e++)Math.abs(l[e])>Math.abs(l[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=c.get(i,r),c.set(i,r,c.get(n,r)),c.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<h&&0!==c.get(n,n))for(e=n+1;e<h;e++)c.set(e,n,c.get(e,n)/c.get(n,n))}this.LU=c,this.pivotVector=f,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=Sx.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,a=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)a.set(i,r,a.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new Sx(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new Sx(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Dx(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class Lx{constructor(t){let e,n,r,i,o=(t=Px.checkMatrix(t)).clone(),a=t.rows,s=t.columns,l=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=Dx(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<a;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<a;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<a;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}l[r]=-t}this.QR=o,this.Rdiag=l}solve(t){t=Sx.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,a,s=t.columns,l=t.clone(),u=e.columns;for(o=0;o<u;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*l.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)l.set(r,i,l.get(r,i)+a*e.get(r,o))}for(o=u-1;o>=0;o--){for(i=0;i<s;i++)l.set(o,i,l.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)l.set(r,i,l.get(r,i)-l.get(o,i)*e.get(r,o))}return l.subMatrix(0,u-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new Sx(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,a=i.columns,s=new Sx(o,a);for(n=a-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<a;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}let _x=class{constructor(t,e={}){if((t=Px.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,r=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=e;let s,l=Boolean(i),u=Boolean(o),c=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,c=!0;let e=l;l=u,u=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let h=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new Sx(n,h),g=new Sx(r,r),v=new Float64Array(r),m=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),E=Math.max(b,x);for(let t=0;t<E;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=Dx(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<b&&0!==f[t]){let r=0;for(let i=t;i<n;i++)r+=s.get(i,t)*s.get(i,e);r=-r/s.get(t,t);for(let i=t;i<n;i++)s.set(i,e,s.get(i,e)+r*s.get(i,t))}v[e]=s.get(t,e)}if(l&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<r;e++)v[t]=Dx(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<r;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<n&&0!==v[t]){for(let e=t+1;e<n;e++)m[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)m[e]+=v[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-v[e]/v[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*m[i])}}if(u)for(let e=t+1;e<r;e++)g.set(e,t,v[e])}}let w=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<w&&(f[w-1]=0),x+1<w&&(v[x]=s.get(x,w-1)),v[w-1]=0,l){for(let t=b;t<h;t++){for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<h;e++){let r=0;for(let i=t;i<n;i++)r+=p.get(i,t)*p.get(i,e);r=-r/p.get(t,t);for(let i=t;i<n;i++)p.set(i,e,p.get(i,e)+r*p.get(i,t))}for(let e=t;e<n;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}}if(u)for(let t=r-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<r;e++){let n=0;for(let i=t+1;i<r;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t+1,t);for(let i=t+1;i<r;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}let k=w-1,M=Number.EPSILON;for(;w>0;){let t,e;for(t=w-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+M*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===w-2)e=4;else{let n;for(n=w-1;n>=t&&n!==t;n--){let e=(n!==w?Math.abs(v[n]):0)+(n!==t+1?Math.abs(v[n-1]):0);if(Math.abs(f[n])<=M*e){f[n]=0;break}}n===t?e=3:n===w-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=v[w-2];v[w-2]=0;for(let n=w-2;n>=t;n--){let i=Dx(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*v[n-1],v[n-1]=o*v[n-1]),u)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,w-1),g.set(t,w-1,-a*g.get(t,n)+o*g.get(t,w-1)),g.set(t,n,i)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let r=t;r<w;r++){let i=Dx(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*v[r],v[r]=o*v[r],l)for(let e=0;e<n;e++)i=o*p.get(e,r)+a*p.get(e,t-1),p.set(e,t-1,-a*p.get(e,r)+o*p.get(e,t-1)),p.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(f[w-1]),Math.abs(f[w-2]),Math.abs(v[w-2]),Math.abs(f[t]),Math.abs(v[t])),i=f[w-1]/e,o=f[w-2]/e,a=v[w-2]/e,s=f[t]/e,c=v[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let m=0;0===h&&0===d||(m=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),m=d/(h+m));let y=(s+i)*(s-i)+m,b=s*c;for(let e=t;e<w-1;e++){let i=Dx(y,b);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=b/i;if(e!==t&&(v[e-1]=i),y=o*f[e]+a*v[e],v[e]=o*v[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],u)for(let t=0;t<r;t++)i=o*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+o*g.get(t,e+1)),g.set(t,e,i);if(i=Dx(y,b),0===i&&(i=Number.MIN_VALUE),o=y/i,a=b/i,f[e]=i,y=o*v[e]+a*f[e+1],f[e+1]=-a*v[e]+o*f[e+1],b=a*v[e+1],v[e+1]=o*v[e+1],l&&e<n-1)for(let t=0;t<n;t++)i=o*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+o*p.get(t,e+1)),p.set(t,e,i)}v[w-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,u))for(let e=0;e<=k;e++)g.set(e,t,-g.get(e,t));for(;t<k&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(l&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);t++}w--}}if(c){let t=g;g=p,p=t}this.m=n,this.n=r,this.s=f,this.U=p,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=Sx.zeros(r,r);for(let t=0;t<r;t++)Math.abs(this.s[t])<=n?i.set(t,t,0):i.set(t,t,1/this.s[t]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(i),l=a.rows,u=o.rows,c=Sx.zeros(l,u);for(let t=0;t<l;t++)for(let e=0;e<u;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);c.set(t,e,n)}return c.mmul(e)}solveForDiagonal(t){return this.solve(Sx.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new Sx(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<r;n++)Math.abs(this.s[n])>e&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,l=new Sx(n,a);for(let t=0;t<n;t++)for(let e=0;e<a;e++){let n=0;for(let r=0;r<s;r++)n+=i.get(t,r)*o.get(e,r);l.set(t,e,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return Sx.diag(this.s)}};function Ix(t,e,n=!1){return t=Px.checkMatrix(t),e=Px.checkMatrix(e),n?new _x(t).solve(e):t.isSquare()?new Rx(t).solve(e):new Lx(t).solve(e)}function jx(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function Bx(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class Fx{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=Px.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,a=new Sx(o,o),s=new Float64Array(o),l=new Float64Array(o),u=t,c=!1;if(c=!!n||t.isSymmetric(),c){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h;for(l=0;l<t;l++)n[l]=r.get(t-1,l);for(s=t-1;s>0;s--){for(h=0,a=0,u=0;u<s;u++)h+=Math.abs(n[u]);if(0===h)for(e[s]=n[s-1],l=0;l<s;l++)n[l]=r.get(s-1,l),r.set(s,l,0),r.set(l,s,0);else{for(u=0;u<s;u++)n[u]/=h,a+=n[u]*n[u];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=h*o,a-=i*o,n[s-1]=i-o,l=0;l<s;l++)e[l]=0;for(l=0;l<s;l++){for(i=n[l],r.set(l,s,i),o=e[l]+r.get(l,l)*i,u=l+1;u<=s-1;u++)o+=r.get(u,l)*n[u],e[u]+=r.get(u,l)*i;e[l]=o}for(i=0,l=0;l<s;l++)e[l]/=a,i+=e[l]*n[l];for(c=i/(a+a),l=0;l<s;l++)e[l]-=c*n[l];for(l=0;l<s;l++){for(i=n[l],o=e[l],u=l;u<=s-1;u++)r.set(u,l,r.get(u,l)-(i*e[u]+o*n[u]));n[l]=r.get(s-1,l),r.set(s,l,0)}}n[s]=a}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),a=n[s+1],0!==a){for(u=0;u<=s;u++)n[u]=r.get(u,s+1)/a;for(l=0;l<=s;l++){for(o=0,u=0;u<=s;u++)o+=r.get(u,s+1)*r.get(u,l);for(u=0;u<=s;u++)r.set(u,l,r.get(u,l)-o*n[u])}}for(u=0;u<=s;u++)r.set(u,s+1,0)}for(l=0;l<t;l++)n[l]=r.get(t-1,l),r.set(t-1,l,0);r.set(t-1,t-1,1),e[0]=0}(o,l,s,a),function(t,e,n,r){let i,o,a,s,l,u,c,h,d,f,p,g,v,m,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,E=0,w=Number.EPSILON;for(u=0;u<t;u++){for(E=Math.max(E,Math.abs(n[u])+Math.abs(e[u])),c=u;c<t&&!(Math.abs(e[c])<=w*E);)c++;if(c>u)do{for(i=n[u],h=(n[u+1]-i)/(2*e[u]),d=Dx(h,1),h<0&&(d=-d),n[u]=e[u]/(h+d),n[u+1]=e[u]*(h+d),f=n[u+1],o=i-n[u],a=u+2;a<t;a++)n[a]-=o;for(x+=o,h=n[c],p=1,g=p,v=p,m=e[u+1],y=0,b=0,a=c-1;a>=u;a--)for(v=g,g=p,b=y,i=p*e[a],o=p*h,d=Dx(h,e[a]),e[a+1]=y*d,y=e[a]/d,p=h/d,h=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),l=0;l<t;l++)o=r.get(l,a+1),r.set(l,a+1,y*r.get(l,a)+p*o),r.set(l,a,p*r.get(l,a)-y*o);h=-y*b*v*m*e[u]/f,e[u]=y*h,n[u]=p*h}while(Math.abs(e[u])>w*E);n[u]=n[u]+x,e[u]=0}for(a=0;a<t-1;a++){for(l=a,h=n[a],s=a+1;s<t;s++)n[s]<h&&(l=s,h=n[s]);if(l!==a)for(n[l]=n[a],n[a]=h,s=0;s<t;s++)h=r.get(s,a),r.set(s,a,r.get(s,l)),r.set(s,l,h)}}(o,l,s,a)}else{let t=new Sx(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h=0,d=t-1;for(u=h+1;u<=d-1;u++){for(c=0,s=u;s<=d;s++)c+=Math.abs(e.get(s,u-1));if(0!==c){for(a=0,s=d;s>=u;s--)n[s]=e.get(s,u-1)/c,a+=n[s]*n[s];for(o=Math.sqrt(a),n[u]>0&&(o=-o),a-=n[u]*o,n[u]=n[u]-o,l=u;l<t;l++){for(i=0,s=d;s>=u;s--)i+=n[s]*e.get(s,l);for(i/=a,s=u;s<=d;s++)e.set(s,l,e.get(s,l)-i*n[s])}for(s=0;s<=d;s++){for(i=0,l=d;l>=u;l--)i+=n[l]*e.get(s,l);for(i/=a,l=u;l<=d;l++)e.set(s,l,e.get(s,l)-i*n[l])}n[u]=c*n[u],e.set(u,u-1,c*o)}}for(s=0;s<t;s++)for(l=0;l<t;l++)r.set(s,l,s===l?1:0);for(u=d-1;u>=h+1;u--)if(0!==e.get(u,u-1)){for(s=u+1;s<=d;s++)n[s]=e.get(s,u-1);for(l=u;l<=d;l++){for(o=0,s=u;s<=d;s++)o+=n[s]*r.get(s,l);for(o=o/n[u]/e.get(u,u-1),s=u;s<=d;s++)r.set(s,l,r.get(s,l)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,l,u,c,h,d,f,p,g,v,m,y,b,x=t-1,E=0,w=t-1,k=Number.EPSILON,M=0,S=0,N=0,O=0,T=0,C=0,A=0,P=0;for(o=0;o<t;o++)for((o<E||o>w)&&(n[o]=i.get(o,o),e[o]=0),a=Math.max(o-1,0);a<t;a++)S+=Math.abs(i.get(o,a));for(;x>=E;){for(l=x;l>E&&(C=Math.abs(i.get(l-1,l-1))+Math.abs(i.get(l,l)),0===C&&(C=S),!(Math.abs(i.get(l,l-1))<k*C));)l--;if(l===x)i.set(x,x,i.get(x,x)+M),n[x]=i.get(x,x),e[x]=0,x--,P=0;else if(l===x-1){if(h=i.get(x,x-1)*i.get(x-1,x),N=(i.get(x-1,x-1)-i.get(x,x))/2,O=N*N+h,A=Math.sqrt(Math.abs(O)),i.set(x,x,i.get(x,x)+M),i.set(x-1,x-1,i.get(x-1,x-1)+M),d=i.get(x,x),O>=0){for(A=N>=0?N+A:N-A,n[x-1]=d+A,n[x]=n[x-1],0!==A&&(n[x]=d-h/A),e[x-1]=0,e[x]=0,d=i.get(x,x-1),C=Math.abs(d)+Math.abs(A),N=d/C,O=A/C,T=Math.sqrt(N*N+O*O),N/=T,O/=T,a=x-1;a<t;a++)A=i.get(x-1,a),i.set(x-1,a,O*A+N*i.get(x,a)),i.set(x,a,O*i.get(x,a)-N*A);for(o=0;o<=x;o++)A=i.get(o,x-1),i.set(o,x-1,O*A+N*i.get(o,x)),i.set(o,x,O*i.get(o,x)-N*A);for(o=E;o<=w;o++)A=r.get(o,x-1),r.set(o,x-1,O*A+N*r.get(o,x)),r.set(o,x,O*r.get(o,x)-N*A)}else n[x-1]=d+N,n[x]=d+N,e[x-1]=A,e[x]=-A;x-=2,P=0}else{if(d=i.get(x,x),f=0,h=0,l<x&&(f=i.get(x-1,x-1),h=i.get(x,x-1)*i.get(x-1,x)),10===P){for(M+=d,o=E;o<=x;o++)i.set(o,o,i.get(o,o)-d);C=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*C,h=-.4375*C*C}if(30===P&&(C=(f-d)/2,C=C*C+h,C>0)){for(C=Math.sqrt(C),f<d&&(C=-C),C=d-h/((f-d)/2+C),o=E;o<=x;o++)i.set(o,o,i.get(o,o)-C);M+=C,d=f=h=.964}for(P+=1,u=x-2;u>=l&&(A=i.get(u,u),T=d-A,C=f-A,N=(T*C-h)/i.get(u+1,u)+i.get(u,u+1),O=i.get(u+1,u+1)-A-T-C,T=i.get(u+2,u+1),C=Math.abs(N)+Math.abs(O)+Math.abs(T),N/=C,O/=C,T/=C,u!==l)&&!(Math.abs(i.get(u,u-1))*(Math.abs(O)+Math.abs(T))<k*(Math.abs(N)*(Math.abs(i.get(u-1,u-1))+Math.abs(A)+Math.abs(i.get(u+1,u+1)))));)u--;for(o=u+2;o<=x;o++)i.set(o,o-2,0),o>u+2&&i.set(o,o-3,0);for(s=u;s<=x-1&&(y=s!==x-1,s!==u&&(N=i.get(s,s-1),O=i.get(s+1,s-1),T=y?i.get(s+2,s-1):0,d=Math.abs(N)+Math.abs(O)+Math.abs(T),0!==d&&(N/=d,O/=d,T/=d)),0!==d);s++)if(C=Math.sqrt(N*N+O*O+T*T),N<0&&(C=-C),0!==C){for(s!==u?i.set(s,s-1,-C*d):l!==u&&i.set(s,s-1,-i.get(s,s-1)),N+=C,d=N/C,f=O/C,A=T/C,O/=N,T/=N,a=s;a<t;a++)N=i.get(s,a)+O*i.get(s+1,a),y&&(N+=T*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-N*A)),i.set(s,a,i.get(s,a)-N*d),i.set(s+1,a,i.get(s+1,a)-N*f);for(o=0;o<=Math.min(x,s+3);o++)N=d*i.get(o,s)+f*i.get(o,s+1),y&&(N+=A*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-N*T)),i.set(o,s,i.get(o,s)-N),i.set(o,s+1,i.get(o,s+1)-N*O);for(o=E;o<=w;o++)N=d*r.get(o,s)+f*r.get(o,s+1),y&&(N+=A*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-N*T)),r.set(o,s,r.get(o,s)-N),r.set(o,s+1,r.get(o,s+1)-N*O)}}}if(0===S)return;for(x=t-1;x>=0;x--)if(N=n[x],O=e[x],0===O)for(l=x,i.set(x,x,1),o=x-1;o>=0;o--){for(h=i.get(o,o)-N,T=0,a=l;a<=x;a++)T+=i.get(o,a)*i.get(a,x);if(e[o]<0)A=h,C=T;else if(l=o,0===e[o]?i.set(o,x,0!==h?-T/h:-T/(k*S)):(d=i.get(o,o+1),f=i.get(o+1,o),O=(n[o]-N)*(n[o]-N)+e[o]*e[o],c=(d*C-A*T)/O,i.set(o,x,c),i.set(o+1,x,Math.abs(d)>Math.abs(A)?(-T-h*c)/d:(-C-f*c)/A)),c=Math.abs(i.get(o,x)),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/c)}else if(O<0)for(l=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,O/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-N)/i.get(x,x-1))):(b=zx(0,-i.get(x-1,x),i.get(x-1,x-1)-N,O),i.set(x-1,x-1,b[0]),i.set(x-1,x,b[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=l;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(h=i.get(o,o)-N,e[o]<0)A=h,T=p,C=g;else if(l=o,0===e[o]?(b=zx(-p,-g,h,O),i.set(o,x-1,b[0]),i.set(o,x,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),v=(n[o]-N)*(n[o]-N)+e[o]*e[o]-O*O,m=2*(n[o]-N)*O,0===v&&0===m&&(v=k*S*(Math.abs(h)+Math.abs(O)+Math.abs(d)+Math.abs(f)+Math.abs(A))),b=zx(d*T-A*p+O*g,d*C-A*g-O*p,v,m),i.set(o,x-1,b[0]),i.set(o,x,b[1]),Math.abs(d)>Math.abs(A)+Math.abs(O)?(i.set(o+1,x-1,(-p-h*i.get(o,x-1)+O*i.get(o,x))/d),i.set(o+1,x,(-g-h*i.get(o,x)-O*i.get(o,x-1))/d)):(b=zx(-T-f*i.get(o,x-1),-C-f*i.get(o,x),A,O),i.set(o+1,x-1,b[0]),i.set(o+1,x,b[1]))),c=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/c),i.set(a,x,i.get(a,x)/c)}for(o=0;o<t;o++)if(o<E||o>w)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=E;a--)for(o=E;o<=w;o++){for(A=0,s=E;s<=Math.min(a,w);s++)A+=r.get(o,s)*i.get(s,a);r.set(o,a,A)}}(o,l,s,a,t)}this.n=o,this.e=l,this.d=s,this.V=a}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new Sx(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function zx(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class Gx{constructor(t){if(!(t=Px.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new Sx(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=a.get(r,e)*a.get(n,e);o=(i.get(n,r)-o)/a.get(r,r),a.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&&=t>0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)a.set(n,r,0)}this.L=a,this.positiveDefinite=s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=Px.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,a=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<a;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<a;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class Vx{constructor(t,e={}){t=Px.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=ax.isAnyArray(n)&&"number"==typeof n[0]?Sx.columnVector(n):Px.checkMatrix(n),n.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=t.getColumnVector(0);let s,l,u,c,h=1;for(let e=0;e<i&&h>o;e++)u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),s=t.mmul(u).div(u.transpose().mmul(u).get(0,0)),e>0&&(h=s.clone().sub(c).pow(2).sum()),c=s.clone(),n?(l=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=n.mmul(l).div(l.transpose().mmul(l).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),i=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),o=n.clone().sub(s.clone().mulS(i.get(0,0)).mmul(l.transpose()));this.t=s,this.p=e.transpose(),this.w=u.transpose(),this.q=l,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=u.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(u.transpose()))}}tx.AbstractMatrix=kx,tx.CHO=Gx,tx.CholeskyDecomposition=Gx,tx.DistanceMatrix=Ox,tx.EVD=Fx,tx.EigenvalueDecomposition=Fx,tx.LU=Rx,tx.LuDecomposition=Rx;var Wx=tx.Matrix=Sx;tx.MatrixColumnSelectionView=class extends Tx{constructor(t,e){yx(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},tx.MatrixColumnView=class extends Tx{constructor(t,e){px(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},tx.MatrixFlipColumnView=class extends Tx{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},tx.MatrixFlipRowView=class extends Tx{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},tx.MatrixRowSelectionView=class extends Tx{constructor(t,e){mx(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},tx.MatrixRowView=class extends Tx{constructor(t,e){fx(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},tx.MatrixSelectionView=Cx,tx.MatrixSubView=class extends Tx{constructor(t,e,n,r,i){bx(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},tx.MatrixTransposeView=class extends Tx{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},tx.NIPALS=Vx,tx.Nipals=Vx,tx.QR=Lx,tx.QrDecomposition=Lx,tx.SVD=_x;var Hx=tx.SingularValueDecomposition=_x;tx.SymmetricMatrix=Nx,tx.WrapperMatrix1D=Ax,tx.WrapperMatrix2D=Px,tx.correlation=function(t,e=t,n={}){t=new Sx(t);let r=!1;if("object"!=typeof e||Sx.isMatrix(e)||ax.isAnyArray(e)?e=new Sx(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:o=!0}=n;i&&(t.center("column"),r||e.center("column")),o&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),l=t.transpose().mmul(e);for(let e=0;e<l.rows;e++)for(let n=0;n<l.columns;n++)l.set(e,n,l.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return l},tx.covariance=function(t,e=t,n={}){t=new Sx(t);let r=!1;if("object"!=typeof e||Sx.isMatrix(e)||ax.isAnyArray(e)?e=new Sx(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(t=t.center("column"),r||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e<o.rows;e++)for(let n=0;n<o.columns;n++)o.set(e,n,o.get(e,n)*(1/(t.rows-1)));return o};var Ux=tx.default=Sx;tx.determinant=function t(e){if((e=Sx.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,a,s;return o=new Cx(e,[1,2],[1,2]),a=new Cx(e,[1,2],[0,2]),s=new Cx(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(a)+i*t(s)}return new Rx(e).determinant}throw Error("determinant can only be calculated for a square matrix")},tx.inverse=function(t,e=!1){return t=Px.checkMatrix(t),e?new _x(t).inverse():Ix(t,Sx.eye(t.rows))},tx.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=Sx.checkMatrix(t)).rows,o=new Sx(i,i);for(let e=0;e<i;e++){let a=Sx.columnVector(t.getRow(e)),s=t.subMatrixRow(jx(i,e)).transpose(),l=new _x(s).solve(a),u=Sx.sub(a,s.mmul(l)).abs().max();o.setRow(e,Bx(u,l,e,n,r))}return o},tx.pseudoInverse=function(t,e=Number.EPSILON){if((t=Sx.checkMatrix(t)).isEmpty())return t.transpose();let n=new _x(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(Sx.diag(o).mmul(r.transpose()))},tx.solve=Ix,tx.wrap=function(t,e){if(ax.isAnyArray(t))return t[0]&&ax.isAnyArray(t[0])?new Px(t):new Ax(t,e);throw new Error("the argument is not an array")};const $x=Wx,Yx=Hx;Ux.Matrix&&Ux.Matrix;const qx={center:[0,0],linkDistance:50};class Xx{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},qx),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i=[0,0],linkDistance:o=50}=r,a=e.getAllNodes(),s=e.getAllEdges();if(!(null==a?void 0:a.length)||1===a.length)return bb(e,t,i);const l=sb({nodes:a,edges:s}),u=ab(l);Kx(u);const c=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(u,o),h=Zx(c),d=[];h.forEach(((t,e)=>{const n=hb(a[e]);n.data.x=t[0]+i[0],n.data.y=t[1]+i[1],d.push(n)})),t&&d.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:d,edges:s}}))}}const Kx=t=>{let e=-999999;t.forEach((t=>{t.forEach((t=>{t!==1/0&&e<t&&(e=t)}))})),t.forEach(((n,r)=>{n.forEach(((n,i)=>{n===1/0&&(t[r][i]=e)}))}))},Zx=t=>{const e=$x.mul($x.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);const o=new Yx(e),a=$x.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>$x.mul([t],[a]).toJSON()[0].splice(0,2)))};function Qx(t){return!!t.tick&&!!t.stop}const Jx={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},tE={center:[0,0],comboPadding:10,treeKey:"combo"};class eE{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},tE),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:i,treeKey:o,outerLayout:a}=r,s=e.getAllNodes().filter((t=>!t.data._isCombo)),l=e.getAllNodes().filter((t=>t.data._isCombo)),u=e.getAllEdges(),c=null==s?void 0:s.length;if(!c||1===c)return bb(e,t,i);const h=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;l.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,u,r,p);yield Promise.all(g);const v=new Map,m=[],y=new Map;let b=!0;e.getRoots(o).forEach((t=>{const n=p.get(t.id),r=f.get(t.id)||d.get(t.id),i={id:t.id,data:Object.assign(Object.assign({},t.data),{x:n.data.x||r.data.x,y:n.data.y||r.data.y,fx:n.data.fx||r.data.fx,fy:n.data.fy||r.data.fy,mass:n.data.mass||r.data.mass,size:n.data.size})};m.push(i),v.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):b=!1,ub(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const x=[];let E;if(u.forEach((t=>{const e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&v.has(e)&&v.has(n)&&x.push({id:t.id,source:e,target:n,data:{}})})),null==m?void 0:m.length){if(1===m.length)m[0].data.x=i[0],m[0].data.y=i[1];else{const t=new Yg({nodes:m,edges:x}),e=a||new qb;if(b&&Jx[e.id]){const e=m.length<100?new Xx:new Sb;yield e.assign(t)}const n=Object.assign({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===e.id?{gravity:1,factor:4,linkDistance:(t,e,n)=>(Math.max(...e.data.size)||32)/2+(Math.max(...n.data.size)||32)/2+200}:{});E=yield nE(e,t,n)}p.forEach((t=>{var e;const n=E.nodes.find((e=>e.id===t.id));if(n){const{x:e,y:r}=n.data;t.data.visited=!0,t.data.x=e,t.data.y=r,h.push({id:t.id,data:{x:e,y:r}})}const{x:r,y:i}=t.data;null===(e=t.data.nodes)||void 0===e||e.forEach((t=>{h.push({id:t.id,data:{x:t.data.x+r,y:t.data.y+i}})}))})),p.forEach((({data:t})=>{const{x:e,y:n,visited:r,nodes:i}=t;null==i||i.forEach((t=>{if(!r){const r=h.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&h.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:h,edges:u}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=ae(r)?()=>r:Ut(r)?r:()=>0,e.spacing=a,n)if(Ut(n))o=t=>{const e=n(t),r=a(t);if(ob(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(ob(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)/2}else{const t=n/2;o=e=>t+a(e)/2}else o=t=>{const e=a(t);if(t.size){if(ob(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(qt(t.size)){return((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2}return(t.size+e)/2}return 32+e/2};return e.nodeSize=o,s=ae(i)?()=>i:ob(i)?()=>Math.max.apply(null,i):Ut(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,a){const{nodeSize:s,comboPadding:l,spacing:u,innerLayout:c}=o,h=c||new Sb({}),d={center:[0,0],preventOverlap:!0,nodeSpacing:u},f=[],p=t=>{let e=(null==l?void 0:l(t))||10;return ob(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{a.set(o.id,{id:o.id,data:{nodes:[],size:p(o).size}});let l=Promise.resolve();ub(t,[o],(o=>{var u;if(!o.data._isCombo)return;const{size:c,padding:f}=p(o);if(null===(u=t.getChildren(o.id,e))||void 0===u?void 0:u.length){const u=a.get(o.id);a.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==u?void 0:u.data)});const c=new Map,p=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return a.has(t.id)||a.set(t.id,{id:t.id,data:Object.assign({},t.data)}),c.set(t.id,!0),a.get(t.id);const e=n.get(t.id)||r.get(t.id);return c.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),g={nodes:p,edges:i.filter((t=>c.has(t.source)&&c.has(t.target)))};let v=1/0;p.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=a.get(t.id))||void 0===e?void 0:e.data.size)||(null==s?void 0:s(t))||[30,30]),ae(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),l=l.then((()=>ze(this,void 0,void 0,(function*(){const t=new Yg(g);yield nE(h,t,d,!0);const{minX:e,minY:n,maxX:r,maxY:i}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;ob(o)?1===o.length&&(o=[o[0],o[0]]):ae(o)?o=[o,o]:(void 0===o||isNaN(o))&&(o=[30,30]);const a=[o[0]/2,o[1]/2],s=t.data.x-a[0],l=t.data.x+a[0],u=t.data.y-a[1],c=t.data.y+a[1];e>s&&(e=s),n>u&&(n=u),r<l&&(r=l),i<c&&(i=c)})),{minX:e,minY:n,maxX:r,maxY:i}})(p),s=(r+e)/2,l=(i+n)/2;g.nodes.forEach((t=>{t.data.x-=s,t.data.y-=l}));const u=[Math.max(r-e,v)+2*f,Math.max(i-n,v)+2*f];a.get(o.id).data.size=u,a.get(o.id).data.nodes=p}))))}else a.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:c})});return!0}),"BT",e),f.push(l)})),f}}function nE(t,e,n,r){var i;return ze(this,void 0,void 0,(function*(){return Qx(t)?(t.execute(e,n),t.stop(),t.tick(null!==(i=n.iterations)&&void 0!==i?i:300)):r?yield t.assign(e,n):yield t.execute(e,n)}))}function rE(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,l=0;for(i=0;i<a;++i)s+=(o=n[i]).x,l+=o.y;for(s=(s/a-t)*r,l=(l/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=l}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function iE(t){return function(){return t}}function oE(t){return 1e-6*(t()-.5)}function aE(t){return t.x+t.vx}function sE(t){return t.y+t.vy}function lE(t){var e,n,r,i=1,o=1;function a(){for(var t,a,l,u,c,h,d,f=e.length,p=0;p<o;++p)for(a=Ab(e,aE,sE).visitAfter(s),t=0;t<f;++t)l=e[t],h=n[l.index],d=h*h,u=l.x+l.vx,c=l.y+l.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=h+f;if(!s)return e>u+p||o<u-p||n>c+p||a<c-p;if(s.index>l.index){var g=u-s.x-s.vx,v=c-s.y-s.vy,m=g*g+v*v;m<p*p&&(0===g&&(m+=(g=oE(r))*g),0===v&&(m+=(v=oE(r))*v),m=(p-(m=Math.sqrt(m)))/m*i,l.vx+=(g*=m)*(p=(f*=f)/(d+f)),l.vy+=(v*=m)*p,s.vx-=g*(p=1-p),s.vy-=v*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function l(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=iE(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,l()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),l(),a):t},a}function uE(t){return t.index}function cE(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function hE(t){var e,n,r,i,o,a,s=uE,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},u=iE(30),c=1;function h(r){for(var i=0,s=t.length;i<c;++i)for(var l,u,h,d,f,p,g,v=0;v<s;++v)u=(l=t[v]).source,d=(h=l.target).x+h.vx-u.x-u.vx||oE(a),f=h.y+h.vy-u.y-u.vy||oE(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[v])/p*r*e[v],f*=p,h.vx-=d*(g=o[v]),h.vy-=f*g,u.vx+=d*(g=1-g),u.vy+=f*g}function d(){if(r){var a,l,u=r.length,c=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(u);a<c;++a)(l=t[a]).index=a,"object"!=typeof l.source&&(l.source=cE(h,l.source)),"object"!=typeof l.target&&(l.target=cE(h,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(a=0,o=new Array(c);a<c;++a)l=t[a],o[a]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(c),f(),n=new Array(c),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+u(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,a=e,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(c=+t,h):c},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:iE(+t),f(),h):l},h.distance=function(t){return arguments.length?(u="function"==typeof t?t:iE(+t),p(),h):u},h}var dE={value:()=>{}};function fE(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new pE(r)}function pE(t){this._=t}function gE(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function vE(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=dE,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}pE.prototype=fE.prototype={constructor:pE,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(n=(t=o[a]).type)i[n]=vE(i[n],t.name,e);else if(null==e)for(n in i)i[n]=vE(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=gE(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new pE(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var mE,yE,bE=0,xE=0,EE=0,wE=0,kE=0,ME=0,SE="object"==typeof performance&&performance.now?performance:Date,NE="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function OE(){return kE||(NE(TE),kE=SE.now()+ME)}function TE(){kE=0}function CE(){this._call=this._time=this._next=null}function AE(t,e,n){var r=new CE;return r.restart(t,e,n),r}function PE(){kE=(wE=SE.now())+ME,bE=xE=0;try{!function(){OE(),++bE;for(var t,e=mE;e;)(t=kE-e._time)>=0&&e._call.call(void 0,t),e=e._next;--bE}()}finally{bE=0,function(){var t,e,n=mE,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:mE=e);yE=t,DE(r)}(),kE=0}}function RE(){var t=SE.now(),e=t-wE;e>1e3&&(ME-=e,wE=t)}function DE(t){bE||(xE&&(xE=clearTimeout(xE)),t-kE>24?(t<1/0&&(xE=setTimeout(PE,t-SE.now()-ME)),EE&&(EE=clearInterval(EE))):(EE||(wE=SE.now(),EE=setInterval(RE,1e3)),bE=1,NE(PE)))}CE.prototype=AE.prototype={constructor:CE,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?OE():+n)+(null==e?0:+e),this._next||yE===this||(yE?yE._next=this:mE=this,yE=this),this._call=t,this._time=n,DE()},stop:function(){this._call&&(this._call=null,this._time=1/0,DE())}};const LE=4294967296;function _E(t){return t.x}function IE(t){return t.y}var jE=Math.PI*(3-Math.sqrt(5));function BE(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=AE(h),u=fE("tick","end"),c=function(){let t=1;return()=>(t=(1664525*t+1013904223)%LE)/LE}();function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(r){var l,u,c=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),l=0;l<c;++l)null==(u=t[l]).fx?u.x+=u.vx*=a:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=a:(u.y=u.fy,u.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),o=n*jE;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,c),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(o=+t,e):o},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(c=t,s.forEach(p),e):c},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,l,u=0,c=t.length;for(null==r?r=1/0:r*=r,u=0;u<c;++u)(a=(i=e-(s=t[u]).x)*i+(o=n-s.y)*o)<r&&(l=s,r=a);return l},on:function(t,n){return arguments.length>1?(u.on(t,n),e):u.on(t)}}}function FE(){var t,e,n,r,i,o=iE(-30),a=1,s=1/0,l=.81;function u(n){var i,o=t.length,a=Ab(t,_E,IE).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function c(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+o(n,e,t)}}function h(t){var e,n,r,o,a,s=0,l=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,l+=n,r+=n*e.x,o+=n*e.y);t.x=r/l,t.y=o/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index]}while(e=e.next)}t.value=s}function d(t,o,u,c){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,f=c-o,p=h*h+d*d;if(f*f/l<p)return p<s&&(0===h&&(p+=(h=oE(n))*h),0===d&&(p+=(d=oE(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=h*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=oE(n))*h),0===d&&(p+=(d=oE(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=h*f,e.vy+=d*f)}while(t=t.next)}}return u.initialize=function(e,r){t=e,n=r,c()},u.strength=function(t){return arguments.length?(o="function"==typeof t?t:iE(+t),c(),u):o},u.distanceMin=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.distanceMax=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.theta=function(t){return arguments.length?(l=t*t,u):Math.sqrt(l)},u}function zE(t,e,n){var r,i,o,a=iE(.1);function s(t){for(var a=0,s=r.length;a<s;++a){var l=r[a],u=l.x-e||1e-6,c=l.y-n||1e-6,h=Math.sqrt(u*u+c*c),d=(o[a]-h)*i[a]*t/h;l.vx+=u*d,l.vy+=c*d}}function l(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+a(r[e],e,r)}}return"function"!=typeof t&&(t=iE(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,l()},s.strength=function(t){return arguments.length?(a="function"==typeof t?t:iE(+t),l(),s):a},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),l(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function GE(t){var e,n,r,i=iE(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=iE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:iE(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),a(),o):t},o}function VE(t){var e,n,r,i=iE(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=iE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:iE(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),a(),o):t},o}class WE{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:hE,manyBody:FE,center:rE,collide:lE,radial:zE,x:GE,y:VE},this.options={link:{id:t=>t.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},ke(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,e)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const n=this.context.nodes.find((e=>e.id===t));n&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){n[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,n;const r=ke({},this.options,t);return r.collide&&void 0===(null===(e=r.collide)||void 0===e?void 0:e.radius)&&(r.collide=r.collide||{},r.collide.radius=null!==(n=r.nodeSize)&&void 0!==n?n:10),void 0===r.iterations&&(r.link&&void 0===r.link.iterations&&(r.iterations=r.link.iterations),r.collide&&void 0===r.collide.iterations&&(r.iterations=r.collide.iterations)),this.context.options=r,r}genericLayout(t,e,n){var r;return ze(this,void 0,void 0,(function*(){const i=this.getOptions(n),o=e.getAllNodes().map((({id:t,data:e})=>Object.assign(Object.assign({id:t},e),Ae(e.data,this.config.inputNodeAttrs)))),a=e.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const s=new Promise((t=>{this.resolver=t})),l=this.setSimulation(i);return l.nodes(o),null===(r=l.force("link"))||void 0===r||r.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:n,graph:r}=this.context,i=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),Ae(t,this.config.outputNodeAttrs))}))),o=n.map((({id:t,source:e,target:n,data:r})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof n?n.id:n,data:r})));return t&&i.forEach((t=>r.mergeNodeData(t.id,t.data))),{nodes:i,edges:o}}initSimulation(){return BE()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),HE(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([n,r])=>{const i=n;if(t[n]){let n=e.force(i);n||(n=r(),e.force(i,n)),HE(n,Object.entries(t[i]))}else e.force(i,null)})),e}}const HE=(t,e)=>e.reduce(((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e),t);var UE,$E,YE,qE,XE,KE,ZE,QE,JE,tw,ew,nw,rw,iw,ow,aw,sw,lw,uw,cw,hw,dw,fw,pw,gw,vw,mw,yw,bw,xw,Ew,ww,kw,Mw,Sw,Nw,Ow,Tw,Cw,Aw,Pw,Rw,Dw,Lw,_w,Iw,jw,Bw,Fw,zw,Gw,Vw,Ww,Hw,Uw,$w,Yw,qw,Xw,Kw,Zw,Qw,Jw,tk,ek,nk,rk,ik,ok,ak,sk,lk,uk,ck,hk,dk,fk,pk,gk,vk,mk,yk,bk,xk,Ek,wk,kk,Mk,Sk,Nk,Ok,Tk,Ck,Ak,Pk,Rk,Dk,Lk,_k,Ik,jk,Bk,Fk,zk,Gk,Vk,Wk,Hk;function Uk(){if(qE)return YE;return qE=1,YE=function(t,e){return t===e||t!=t&&e!=e}}function $k(){if(KE)return XE;KE=1;var t=Uk();return XE=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},XE}function Yk(){if(aw)return ow;aw=1;var t=$E?UE:($E=1,UE=function(){this.__data__=[],this.size=0}),e=function(){if(QE)return ZE;QE=1;var t=$k(),e=Array.prototype.splice;return ZE=function(n){var r=this.__data__,i=t(r,n);return!(i<0||(i==r.length-1?r.pop():e.call(r,i,1),--this.size,0))},ZE}(),n=function(){if(tw)return JE;tw=1;var t=$k();return JE=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},JE}(),r=function(){if(nw)return ew;nw=1;var t=$k();return ew=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(iw)return rw;iw=1;var t=$k();return rw=function(e,n){var r=this.__data__,i=t(r,e);return i<0?(++this.size,r.push([e,n])):r[i][1]=n,this},rw}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,ow=o}function qk(){if(vw)return gw;vw=1;var t="object"==typeof x&&x&&x.Object===Object&&x;return gw=t}function Xk(){if(yw)return mw;yw=1;var t=qk(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return mw=n}function Kk(){if(xw)return bw;xw=1;var t=Xk().Symbol;return bw=t}function Zk(){if(Nw)return Sw;Nw=1;var t=Kk(),e=function(){if(ww)return Ew;ww=1;var t=Kk(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return Ew=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var a=!0}catch(t){}var s=r.call(t);return a&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(Mw)return kw;Mw=1;var t=Object.prototype.toString;return kw=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return Sw=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function Qk(){if(Tw)return Ow;return Tw=1,Ow=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Jk(){if(Aw)return Cw;Aw=1;var t=Zk(),e=Qk();return Cw=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function tM(){if(Lw)return Dw;Lw=1;var t,e=function(){if(Rw)return Pw;Rw=1;var t=Xk()["__core-js_shared__"];return Pw=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Dw=function(t){return!!n&&n in t}}function eM(){if(Iw)return _w;Iw=1;var t=Function.prototype.toString;return _w=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function nM(){if(Vw)return Gw;Vw=1;var t=function(){if(Bw)return jw;Bw=1;var t=Jk(),e=tM(),n=Qk(),r=eM(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,u=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return jw=function(o){return!(!n(o)||e(o))&&(t(o)?u:i).test(r(o))}}(),e=zw?Fw:(zw=1,Fw=function(t,e){return null==t?void 0:t[e]});return Gw=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function rM(){if(Hw)return Ww;Hw=1;var t=nM()(Xk(),"Map");return Ww=t}function iM(){if($w)return Uw;$w=1;var t=nM()(Object,"create");return Uw=t}function oM(){if(ik)return rk;ik=1;var t=function(){if(qw)return Yw;qw=1;var t=iM();return Yw=function(){this.__data__=t?t(null):{},this.size=0}}(),e=Kw?Xw:(Kw=1,Xw=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Qw)return Zw;Qw=1;var t=iM(),e=Object.prototype.hasOwnProperty;return Zw=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},Zw}(),r=function(){if(tk)return Jw;tk=1;var t=iM(),e=Object.prototype.hasOwnProperty;return Jw=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},Jw}(),i=function(){if(nk)return ek;nk=1;var t=iM();return ek=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},ek}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,rk=o}function aM(){if(ck)return uk;ck=1;var t=lk?sk:(lk=1,sk=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return uk=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},uk}function sM(){if(xk)return bk;xk=1;var t=function(){if(ak)return ok;ak=1;var t=oM(),e=Yk(),n=rM();return ok=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(dk)return hk;dk=1;var t=aM();return hk=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(pk)return fk;pk=1;var t=aM();return fk=function(e){return t(this,e).get(e)}}(),r=function(){if(vk)return gk;vk=1;var t=aM();return gk=function(e){return t(this,e).has(e)}}(),i=function(){if(yk)return mk;yk=1;var t=aM();return mk=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},mk}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,bk=o}function lM(){if(Mk)return kk;Mk=1;var t=Yk(),e=function(){if(lw)return sw;lw=1;var t=Yk();return sw=function(){this.__data__=new t,this.size=0}}(),n=(cw||(cw=1,uw=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),uw),r=dw?hw:(dw=1,hw=function(t){return this.__data__.get(t)}),i=pw?fw:(pw=1,fw=function(t){return this.__data__.has(t)}),o=function(){if(wk)return Ek;wk=1;var t=Yk(),e=rM(),n=sM();return Ek=function(r,i){var o=this.__data__;if(o instanceof t){var a=o.__data__;if(!e||a.length<199)return a.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(a)}return o.set(r,i),this.size=o.size,this},Ek}();function a(e){var n=this.__data__=new t(e);this.size=n.size}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,kk=a}function uM(){if(Nk)return Sk;return Nk=1,Sk=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},Sk}function cM(){if(Tk)return Ok;Tk=1;var t=nM(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Ok=e}function hM(){if(Ak)return Ck;Ak=1;var t=cM();return Ck=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function dM(){if(Rk)return Pk;Rk=1;var t=hM(),e=Uk(),n=Object.prototype.hasOwnProperty;return Pk=function(r,i,o){var a=r[i];n.call(r,i)&&e(a,o)&&(void 0!==o||i in r)||t(r,i,o)}}function fM(){if(Lk)return Dk;Lk=1;var t=dM(),e=hM();return Dk=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,l=r.length;++s<l;){var u=r[s],c=o?o(i[u],n[u],u,i,n):void 0;void 0===c&&(c=n[u]),a?e(i,u,c):t(i,u,c)}return i},Dk}function pM(){if(Bk)return jk;return Bk=1,jk=function(t){return null!=t&&"object"==typeof t}}function gM(){if(Vk)return Gk;Vk=1;var t=function(){if(zk)return Fk;zk=1;var t=Zk(),e=pM();return Fk=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=pM(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return Gk=o}function vM(){if(Hk)return Wk;Hk=1;var t=Array.isArray;return Wk=t}var mM,yM,bM,xM,EM,wM,kM,MM,SM,NM,OM,TM={exports:{}};function CM(){return bM||(bM=1,function(t,e){var n=Xk(),r=yM?mM:(yM=1,mM=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,a=o&&o.exports===i?n.Buffer:void 0,s=(a?a.isBuffer:void 0)||r;t.exports=s}(TM,TM.exports)),TM.exports}function AM(){if(EM)return xM;EM=1;var t=/^(?:0|[1-9]\d*)$/;return xM=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},xM}function PM(){if(kM)return wM;kM=1;return wM=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function RM(){if(OM)return NM;return OM=1,NM=function(t){return function(e){return t(e)}}}var DM,LM,_M,IM,jM,BM,FM,zM,GM,VM,WM,HM,UM,$M,YM,qM,XM,KM,ZM,QM,JM,tS,eS,nS,rS,iS,oS,aS={exports:{}};function sS(){return DM||(DM=1,function(t,e){var n=qk(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r&&n.process,a=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=a}(aS,aS.exports)),aS.exports}function lS(){if(_M)return LM;_M=1;var t=function(){if(SM)return MM;SM=1;var t=Zk(),e=PM(),n=pM(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,MM=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=RM(),n=sS(),r=n&&n.isTypedArray,i=r?e(r):t;return LM=i}function uS(){if(jM)return IM;jM=1;var t=(Ik||(Ik=1,_k=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),_k),e=gM(),n=vM(),r=CM(),i=AM(),o=lS(),a=Object.prototype.hasOwnProperty;return IM=function(s,l){var u=n(s),c=!u&&e(s),h=!u&&!c&&r(s),d=!u&&!c&&!h&&o(s),f=u||c||h||d,p=f?t(s.length,String):[],g=p.length;for(var v in s)!l&&!a.call(s,v)||f&&("length"==v||h&&("offset"==v||"parent"==v)||d&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||i(v,g))||p.push(v);return p},IM}function cS(){if(FM)return BM;FM=1;var t=Object.prototype;return BM=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function hS(){if(GM)return zM;return GM=1,zM=function(t,e){return function(n){return t(e(n))}}}function dS(){if(UM)return HM;UM=1;var t=cS(),e=function(){if(WM)return VM;WM=1;var t=hS()(Object.keys,Object);return VM=t}(),n=Object.prototype.hasOwnProperty;return HM=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function fS(){if(YM)return $M;YM=1;var t=Jk(),e=PM();return $M=function(n){return null!=n&&e(n.length)&&!t(n)}}function pS(){if(XM)return qM;XM=1;var t=uS(),e=dS(),n=fS();return qM=function(r){return n(r)?t(r):e(r)}}function gS(){if(eS)return tS;eS=1;var t=Qk(),e=cS(),n=JM?QM:(JM=1,QM=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return tS=function(i){if(!t(i))return n(i);var o=e(i),a=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&a.push(s);return a}}function vS(){if(rS)return nS;rS=1;var t=uS(),e=gS(),n=fS();return nS=function(r){return n(r)?t(r,!0):e(r)}}var mS,yS,bS,xS,ES,wS,kS,MS,SS,NS,OS,TS,CS,AS,PS,RS,DS,LS,_S,IS,jS,BS,FS,zS,GS,VS,WS,HS,US,$S,YS,qS,XS,KS,ZS,QS,JS,tN,eN,nN,rN,iN,oN,aN,sN,lN,uN,cN,hN,dN,fN,pN,gN,vN,mN,yN,bN,xN,EN,wN,kN,MN,SN,NN,ON,TN,CN,AN,PN,RN,DN,LN,_N,IN,jN,BN,FN,zN,GN,VN,WN,HN,UN,$N,YN,qN,XN,KN,ZN,QN,JN,tO,eO,nO,rO,iO,oO,aO,sO,lO,uO,cO,hO,dO,fO,pO,gO,vO,mO,yO,bO,xO,EO,wO,kO,MO,SO,NO,OO,TO,CO,AO,PO,RO,DO,LO,_O,IO,jO,BO,FO,zO,GO,VO,WO,HO,UO,$O,YO,qO,XO,KO,ZO,QO,JO,tT,eT,nT,rT,iT,oT,aT,sT,lT,uT,cT,hT,dT,fT,pT,gT,vT,mT,yT,bT,xT,ET,wT,kT,MT,ST,NT,OT,TT,CT,AT,PT,RT,DT,LT,_T,IT,jT,BT,FT,zT,GT,VT,WT,HT,UT,$T,YT,qT,XT,KT,ZT,QT,JT,tC,eC,nC,rC,iC,oC,aC,sC,lC,uC,cC,hC,dC,fC,pC,gC,vC,mC,yC,bC,xC,EC,wC,kC,MC,SC,NC,OC,TC,CC,AC,PC,RC,DC,LC,_C,IC,jC,BC,FC,zC,GC,VC,WC,HC,UC,$C,YC,qC,XC,KC,ZC,QC,JC,tA,eA,nA,rA,iA,oA,aA,sA,lA,uA,cA,hA,dA,fA,pA,gA,vA,mA,yA,bA,xA,EA,wA,kA,MA,SA,NA,OA={exports:{}};function TA(){return mS||(mS=1,function(t,e){var n=Xk(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,a=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=a?a(n):new t.constructor(n);return t.copy(r),r}}(OA,OA.exports)),OA.exports}function CA(){if(bS)return yS;return bS=1,yS=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},yS}function AA(){if(ES)return xS;return ES=1,xS=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a,n,t)&&(o[i++]=a)}return o},xS}function PA(){if(kS)return wS;return kS=1,wS=function(){return[]}}function RA(){if(SS)return MS;SS=1;var t=AA(),e=PA(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return MS=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function DA(){if(CS)return TS;return CS=1,TS=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},TS}function LA(){if(PS)return AS;PS=1;var t=hS()(Object.getPrototypeOf,Object);return AS=t}function _A(){if(DS)return RS;DS=1;var t=DA(),e=LA(),n=RA(),r=PA(),i=Object.getOwnPropertySymbols;return RS=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function IA(){if(jS)return IS;jS=1;var t=DA(),e=vM();return IS=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function jA(){if(FS)return BS;FS=1;var t=IA(),e=RA(),n=pS();return BS=function(r){return t(r,n,e)}}function BA(){if(YS)return $S;YS=1;var t=nM()(Xk(),"Set");return $S=t}function FA(){if(ZS)return KS;ZS=1;var t=function(){if(WS)return VS;WS=1;var t=nM()(Xk(),"DataView");return VS=t}(),e=rM(),n=function(){if(US)return HS;US=1;var t=nM()(Xk(),"Promise");return HS=t}(),r=BA(),i=function(){if(XS)return qS;XS=1;var t=nM()(Xk(),"WeakMap");return qS=t}(),o=Zk(),a=eM(),s="[object Map]",l="[object Promise]",u="[object Set]",c="[object WeakMap]",h="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),v=a(i),m=o;return(t&&m(new t(new ArrayBuffer(1)))!=h||e&&m(new e)!=s||n&&m(n.resolve())!=l||r&&m(new r)!=u||i&&m(new i)!=c)&&(m=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?a(n):"";if(r)switch(r){case d:return h;case f:return s;case p:return l;case g:return u;case v:return c}return e}),KS=m}function zA(){if(eN)return tN;eN=1;var t=Xk().Uint8Array;return tN=t}function GA(){if(rN)return nN;rN=1;var t=zA();return nN=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function VA(){if(hN)return cN;hN=1;var t=GA();return cN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function WA(){if(fN)return dN;fN=1;var t=GA(),e=function(){if(oN)return iN;oN=1;var t=GA();return iN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(sN)return aN;sN=1;var t=/\w*$/;return aN=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(uN)return lN;uN=1;var t=Kk(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return lN=function(t){return n?Object(n.call(t)):{}}}(),i=VA();return dN=function(o,a,s){var l=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new l(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function HA(){if(gN)return pN;gN=1;var t=Qk(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return pN=n}function UA(){if(mN)return vN;mN=1;var t=HA(),e=LA(),n=cS();return vN=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function $A(){if(EN)return xN;EN=1;var t=function(){if(bN)return yN;bN=1;var t=FA(),e=pM();return yN=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=RM(),n=sS(),r=n&&n.isMap,i=r?e(r):t;return xN=i}function YA(){if(SN)return MN;SN=1;var t=function(){if(kN)return wN;kN=1;var t=FA(),e=pM();return wN=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=RM(),n=sS(),r=n&&n.isSet,i=r?e(r):t;return MN=i}function qA(){if(ON)return NN;ON=1;var t=lM(),e=uM(),n=dM(),r=function(){if(ZM)return KM;ZM=1;var t=fM(),e=pS();return KM=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(oS)return iS;oS=1;var t=fM(),e=vS();return iS=function(n,r){return n&&t(r,e(r),n)}}(),o=TA(),a=CA(),s=function(){if(OS)return NS;OS=1;var t=fM(),e=RA();return NS=function(n,r){return t(n,e(n),r)}}(),l=function(){if(_S)return LS;_S=1;var t=fM(),e=_A();return LS=function(n,r){return t(n,e(n),r)}}(),u=jA(),c=function(){if(GS)return zS;GS=1;var t=IA(),e=_A(),n=vS();return zS=function(r){return t(r,n,e)}}(),h=FA(),d=function(){if(JS)return QS;JS=1;var t=Object.prototype.hasOwnProperty;return QS=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},QS}(),f=WA(),p=UA(),g=vM(),v=CM(),m=$A(),y=Qk(),b=YA(),x=pS(),E=vS(),w="[object Arguments]",k="[object Function]",M="[object Object]",S={};return S[w]=S["[object Array]"]=S["[object ArrayBuffer]"]=S["[object DataView]"]=S["[object Boolean]"]=S["[object Date]"]=S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Map]"]=S["[object Number]"]=S[M]=S["[object RegExp]"]=S["[object Set]"]=S["[object String]"]=S["[object Symbol]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S["[object Error]"]=S[k]=S["[object WeakMap]"]=!1,NN=function N(O,T,C,A,P,R){var D,L=1&T,_=2&T,I=4&T;if(C&&(D=P?C(O,A,P,R):C(O)),void 0!==D)return D;if(!y(O))return O;var j=g(O);if(j){if(D=d(O),!L)return a(O,D)}else{var B=h(O),F=B==k||"[object GeneratorFunction]"==B;if(v(O))return o(O,L);if(B==M||B==w||F&&!P){if(D=_||F?{}:p(O),!L)return _?l(O,i(D,O)):s(O,r(D,O))}else{if(!S[B])return P?O:{};D=f(O,B,L)}}R||(R=new t);var z=R.get(O);if(z)return z;R.set(O,D),b(O)?O.forEach((function(t){D.add(N(t,T,C,t,O,R))})):m(O)&&O.forEach((function(t,e){D.set(e,N(t,T,C,e,O,R))}));var G=j?void 0:(I?_?c:u:_?E:x)(O);return e(G||O,(function(t,e){G&&(t=O[e=t]),n(D,e,N(t,T,C,e,O,R))})),D},NN}function XA(){if(CN)return TN;CN=1;var t=qA();return TN=function(e){return t(e,4)}}function KA(){if(PN)return AN;return PN=1,AN=function(t){return function(){return t}}}function ZA(){if(_N)return LN;_N=1;var t=(DN||(DN=1,RN=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var l=a[t?s:++i];if(!1===n(o[l],l,o))break}return e}}),RN),e=t();return LN=e}function QA(){if(jN)return IN;jN=1;var t=ZA(),e=pS();return IN=function(n,r){return n&&t(n,r,e)}}function JA(){if(GN)return zN;GN=1;var t=QA(),e=function(){if(FN)return BN;FN=1;var t=fS();return BN=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,a=n?o:-1,s=Object(r);(n?a--:++a<o)&&!1!==i(s[a],a,s););return r}},BN}(),n=e(t);return zN=n}function tP(){if(WN)return VN;return WN=1,VN=function(t){return t}}function eP(){if(UN)return HN;UN=1;var t=tP();return HN=function(e){return"function"==typeof e?e:t}}function nP(){if(YN)return $N;YN=1;var t=uM(),e=JA(),n=eP(),r=vM();return $N=function(i,o){return(r(i)?t:e)(i,n(o))}}function rP(){return XN?qN:(XN=1,qN=nP())}function iP(){if(rO)return nO;rO=1;var t=sM(),e=JN?QN:(JN=1,QN=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=eO?tO:(eO=1,tO=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,nO=r}function oP(){if(sO)return aO;return sO=1,aO=function(t,e){return t.has(e)}}function aP(){if(uO)return lO;uO=1;var t=iP(),e=(oO||(oO=1,iO=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),iO),n=oP();return lO=function(r,i,o,a,s,l){var u=1&o,c=r.length,h=i.length;if(c!=h&&!(u&&h>c))return!1;var d=l.get(r),f=l.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,v=2&o?new t:void 0;for(l.set(r,i),l.set(i,r);++p<c;){var m=r[p],y=i[p];if(a)var b=u?a(y,m,p,i,r,l):a(m,y,p,r,i,l);if(void 0!==b){if(b)continue;g=!1;break}if(v){if(!e(i,(function(t,e){if(!n(v,e)&&(m===t||s(m,t,o,a,l)))return v.push(e)}))){g=!1;break}}else if(m!==y&&!s(m,y,o,a,l)){g=!1;break}}return l.delete(r),l.delete(i),g},lO}function sP(){if(fO)return dO;return fO=1,dO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},dO}function lP(){if(gO)return pO;gO=1;var t=Kk(),e=zA(),n=Uk(),r=aP(),i=(hO||(hO=1,cO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),cO),o=sP(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return pO=function(t,a,l,u,c,h,d){switch(l){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!h(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var f=i;case"[object Set]":var p=1&u;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;u|=2,d.set(t,a);var v=r(f(t),f(a),u,c,h,d);return d.delete(t),v;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function uP(){if(bO)return yO;bO=1;var t=lM(),e=aP(),n=lP(),r=function(){if(mO)return vO;mO=1;var t=jA(),e=Object.prototype.hasOwnProperty;return vO=function(n,r,i,o,a,s){var l=1&i,u=t(n),c=u.length;if(c!=t(r).length&&!l)return!1;for(var h=c;h--;){var d=u[h];if(!(l?d in r:e.call(r,d)))return!1}var f=s.get(n),p=s.get(r);if(f&&p)return f==r&&p==n;var g=!0;s.set(n,r),s.set(r,n);for(var v=l;++h<c;){var m=n[d=u[h]],y=r[d];if(o)var b=l?o(y,m,d,r,n,s):o(m,y,d,n,r,s);if(!(void 0===b?m===y||a(m,y,i,o,s):b)){g=!1;break}v||(v="constructor"==d)}if(g&&!v){var x=n.constructor,E=r.constructor;x==E||!("constructor"in n)||!("constructor"in r)||"function"==typeof x&&x instanceof x&&"function"==typeof E&&E instanceof E||(g=!1)}return s.delete(n),s.delete(r),g},vO}(),i=FA(),o=vM(),a=CM(),s=lS(),l="[object Arguments]",u="[object Array]",c="[object Object]",h=Object.prototype.hasOwnProperty;return yO=function(d,f,p,g,v,m){var y=o(d),b=o(f),x=y?u:i(d),E=b?u:i(f),w=(x=x==l?c:x)==c,k=(E=E==l?c:E)==c,M=x==E;if(M&&a(d)){if(!a(f))return!1;y=!0,w=!1}if(M&&!w)return m||(m=new t),y||s(d)?e(d,f,p,g,v,m):n(d,f,x,p,g,v,m);if(!(1&p)){var S=w&&h.call(d,"__wrapped__"),N=k&&h.call(f,"__wrapped__");if(S||N){var O=S?d.value():d,T=N?f.value():f;return m||(m=new t),v(O,T,p,g,m)}}return!!M&&(m||(m=new t),r(d,f,p,g,v,m))}}function cP(){if(EO)return xO;EO=1;var t=uP(),e=pM();return xO=function n(r,i,o,a,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,a,n,s))},xO}function hP(){if(SO)return MO;SO=1;var t=Qk();return MO=function(e){return e==e&&!t(e)}}function dP(){if(CO)return TO;return CO=1,TO=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function fP(){if(PO)return AO;PO=1;var t=function(){if(kO)return wO;kO=1;var t=lM(),e=cP();return wO=function(n,r,i,o){var a=i.length,s=a,l=!o;if(null==n)return!s;for(n=Object(n);a--;){var u=i[a];if(l&&u[2]?u[1]!==n[u[0]]:!(u[0]in n))return!1}for(;++a<s;){var c=(u=i[a])[0],h=n[c],d=u[1];if(l&&u[2]){if(void 0===h&&!(c in n))return!1}else{var f=new t;if(o)var p=o(h,d,c,n,r,f);if(!(void 0===p?e(d,h,3,o,f):p))return!1}}return!0},wO}(),e=function(){if(OO)return NO;OO=1;var t=hP(),e=pS();return NO=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],a=n[o];r[i]=[o,a,t(a)]}return r},NO}(),n=dP();return AO=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function pP(){if(DO)return RO;DO=1;var t=Zk(),e=pM();return RO=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function gP(){if(_O)return LO;_O=1;var t=vM(),e=pP(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return LO=function(i,o){if(t(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function vP(){if(FO)return BO;FO=1;var t=function(){if(jO)return IO;jO=1;var t=sM();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var a=n.apply(this,t);return i.cache=o.set(e,a)||o,a};return i.cache=new(e.Cache||t),i}return e.Cache=t,IO=e}();return BO=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function mP(){if(WO)return VO;return WO=1,VO=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},VO}function yP(){if(YO)return $O;YO=1;var t=function(){if(UO)return HO;UO=1;var t=Kk(),e=mP(),n=vM(),r=pP(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return HO=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},HO}();return $O=function(e){return null==e?"":t(e)}}function bP(){if(XO)return qO;XO=1;var t=vM(),e=gP(),n=function(){if(GO)return zO;GO=1;var t=vP(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t((function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,(function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)})),r}));return zO=r}(),r=yP();return qO=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function xP(){if(ZO)return KO;ZO=1;var t=pP();return KO=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function EP(){if(JO)return QO;JO=1;var t=bP(),e=xP();return QO=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},QO}function wP(){if(oT)return iT;oT=1;var t=bP(),e=gM(),n=vM(),r=AM(),i=PM(),o=xP();return iT=function(a,s,l){for(var u=-1,c=(s=t(s,a)).length,h=!1;++u<c;){var d=o(s[u]);if(!(h=null!=a&&l(a,d)))break;a=a[d]}return h||++u!=c?h:!!(c=null==a?0:a.length)&&i(c)&&r(d,c)&&(n(a)||e(a))},iT}function kP(){if(sT)return aT;sT=1;var t=rT?nT:(rT=1,nT=function(t,e){return null!=t&&e in Object(t)}),e=wP();return aT=function(n,r){return null!=n&&e(n,r,t)}}function MP(){if(uT)return lT;uT=1;var t=cP(),e=function(){if(eT)return tT;eT=1;var t=EP();return tT=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=kP(),r=gP(),i=hP(),o=dP(),a=xP();return lT=function(s,l){return r(s)&&i(l)?o(a(s),l):function(r){var i=e(r,s);return void 0===i&&i===l?n(r,s):t(l,i,3)}}}function SP(){if(hT)return cT;return hT=1,cT=function(t){return function(e){return null==e?void 0:e[t]}}}function NP(){if(gT)return pT;gT=1;var t=SP(),e=function(){if(fT)return dT;fT=1;var t=EP();return dT=function(e){return function(n){return t(n,e)}}}(),n=gP(),r=xP();return pT=function(i){return n(i)?t(r(i)):e(i)}}function OP(){if(mT)return vT;mT=1;var t=fP(),e=MP(),n=tP(),r=vM(),i=NP();return vT=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function TP(){if(bT)return yT;bT=1;var t=AA(),e=function(){if(ZN)return KN;ZN=1;var t=JA();return KN=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},KN}(),n=OP(),r=vM();return yT=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function CP(){if(kT)return wT;kT=1;var t=function(){if(ET)return xT;ET=1;var t=Object.prototype.hasOwnProperty;return xT=function(e,n){return null!=e&&t.call(e,n)}}(),e=wP();return wT=function(n,r){return null!=n&&e(n,r,t)}}function AP(){if(ST)return MT;ST=1;var t=dS(),e=FA(),n=gM(),r=vM(),i=fS(),o=CM(),a=cS(),s=lS(),l=Object.prototype.hasOwnProperty;return MT=function(u){if(null==u)return!0;if(i(u)&&(r(u)||"string"==typeof u||"function"==typeof u.splice||o(u)||s(u)||n(u)))return!u.length;var c=e(u);if("[object Map]"==c||"[object Set]"==c)return!u.size;if(a(u))return!t(u).length;for(var h in u)if(l.call(u,h))return!1;return!0}}function PP(){if(OT)return NT;return OT=1,NT=function(t){return void 0===t}}function RP(){if(CT)return TT;CT=1;var t=JA(),e=fS();return TT=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,(function(t,e,n){o[++i]=r(t,e,n)})),o},TT}function DP(){if(PT)return AT;PT=1;var t=mP(),e=OP(),n=RP(),r=vM();return AT=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function LP(){if(jT)return IT;jT=1;var t=(DT||(DT=1,RT=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),RT),e=JA(),n=OP(),r=(_T||(_T=1,LT=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),LT),i=vM();return IT=function(o,a,s){var l=i(o)?t:r,u=arguments.length<3;return l(o,n(a,4),s,u,e)},IT}function _P(){if(YT)return $T;YT=1;var t=function(){if(GT)return zT;GT=1;var t=SP()("length");return zT=t}(),e=function(){if(WT)return VT;WT=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return VT=function(e){return t.test(e)}}(),n=function(){if(UT)return HT;UT=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",l="[\\ufe0e\\ufe0f]?",u=l+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+l+s+")*",c="(?:"+[i+n+"?",n,o,a,e].join("|")+")",h=RegExp(r+"(?="+r+")|"+c+u,"g");return HT=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return $T=function(r){return e(r)?n(r):t(r)}}function IP(){if(XT)return qT;XT=1;var t=dS(),e=FA(),n=fS(),r=function(){if(FT)return BT;FT=1;var t=Zk(),e=vM(),n=pM();return BT=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=_P();return qT=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var a=e(o);return"[object Map]"==a||"[object Set]"==a?o.size:t(o).length}}function jP(){if(ZT)return KT;ZT=1;var t=uM(),e=HA(),n=QA(),r=OP(),i=LA(),o=vM(),a=CM(),s=Jk(),l=Qk(),u=lS();return KT=function(c,h,d){var f=o(c),p=f||a(c)||u(c);if(h=r(h,4),null==d){var g=c&&c.constructor;d=p?f?new g:[]:l(c)&&s(g)?e(i(c)):{}}return(p?t:n)(c,(function(t,e,n){return h(d,t,e,n)})),d},KT}function BP(){if(eC)return tC;eC=1;var t=DA(),e=function(){if(JT)return QT;JT=1;var t=Kk(),e=gM(),n=vM(),r=t?t.isConcatSpreadable:void 0;return QT=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return tC=function n(r,i,o,a,s){var l=-1,u=r.length;for(o||(o=e),s||(s=[]);++l<u;){var c=r[l];i>0&&o(c)?i>1?n(c,i-1,o,a,s):t(s,c):a||(s[s.length]=c)}return s},tC}function FP(){if(oC)return iC;oC=1;var t=rC?nC:(rC=1,nC=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}),e=Math.max;return iC=function(n,r,i){return r=e(void 0===r?n.length-1:r,0),function(){for(var o=arguments,a=-1,s=e(o.length-r,0),l=Array(s);++a<s;)l[a]=o[r+a];a=-1;for(var u=Array(r+1);++a<r;)u[a]=o[a];return u[r]=i(l),t(n,this,u)}},iC}function zP(){if(hC)return cC;hC=1;var t=function(){if(sC)return aC;sC=1;var t=KA(),e=cM(),n=tP();return aC=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(uC)return lC;uC=1;var t=Date.now;return lC=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},lC}(),n=e(t);return cC=n}function GP(){if(fC)return dC;fC=1;var t=tP(),e=FP(),n=zP();return dC=function(r,i){return n(e(r,i,t),r+"")}}function VP(){if(gC)return pC;return gC=1,pC=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},pC}function WP(){if(EC)return xC;EC=1;var t=VP(),e=mC?vC:(mC=1,vC=function(t){return t!=t}),n=(bC||(bC=1,yC=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),yC);return xC=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function HP(){if(CC)return TC;CC=1;var t=BA(),e=OC?NC:(OC=1,NC=function(){}),n=sP(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return TC=r}function UP(){if(PC)return AC;PC=1;var t=iP(),e=function(){if(kC)return wC;kC=1;var t=WP();return wC=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(SC||(SC=1,MC=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),MC),r=oP(),i=HP(),o=sP();return AC=function(a,s,l){var u=-1,c=e,h=a.length,d=!0,f=[],p=f;if(l)d=!1,c=n;else if(h>=200){var g=s?null:i(a);if(g)return o(g);d=!1,c=r,p=new t}else p=s?[]:f;t:for(;++u<h;){var v=a[u],m=s?s(v):v;if(v=l||0!==v?v:0,d&&m==m){for(var y=p.length;y--;)if(p[y]===m)continue t;s&&p.push(m),f.push(v)}else c(p,m,l)||(p!==f&&p.push(m),f.push(v))}return f},AC}function $P(){if(DC)return RC;DC=1;var t=fS(),e=pM();return RC=function(n){return e(n)&&t(n)}}function YP(){if(_C)return LC;_C=1;var t=BP(),e=GP(),n=UP(),r=$P(),i=e((function(e){return n(t(e,1,r,!0))}));return LC=i}function qP(){if(FC)return BC;FC=1;var t=function(){if(jC)return IC;jC=1;var t=mP();return IC=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=pS();return BC=function(n){return null==n?[]:t(n,e(n))}}function XP(){if(GC)return zC;var t;GC=1;try{t={clone:XA(),constant:KA(),each:rP(),filter:TP(),has:CP(),isArray:vM(),isEmpty:AP(),isFunction:Jk(),isUndefined:PP(),keys:pS(),map:DP(),reduce:LP(),size:IP(),transform:jP(),union:YP(),values:qP()}}catch(t){}return t||(t=window._),zC=t}function KP(){if(WC)return VC;WC=1;var t=XP();VC=n;var e="\0";function n(n){this._isDirected=!t.has(n,"directed")||n.directed,this._isMultigraph=!!t.has(n,"multigraph")&&n.multigraph,this._isCompound=!!t.has(n,"compound")&&n.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function r(t,e){t[e]?t[e]++:t[e]=1}function i(t,e){--t[e]||delete t[e]}function o(e,n,r,i){var o=""+n,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}return o+""+a+""+(t.isUndefined(i)?"\0":i)}function a(t,e){return o(t,e.v,e.w,e.name)}return n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(t){return this._label=t,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return t.keys(this._nodes)},n.prototype.sources=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._in[n])}))},n.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._out[n])}))},n.prototype.setNodes=function(e,n){var r=arguments,i=this;return t.each(e,(function(t){r.length>1?i.setNode(t,n):i.setNode(t)})),this},n.prototype.setNode=function(n,r){return t.has(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=r),this):(this._nodes[n]=arguments.length>1?r:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=e,this._children[n]={},this._children[e][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)},n.prototype.node=function(t){return this._nodes[t]},n.prototype.hasNode=function(e){return t.has(this._nodes,e)},n.prototype.removeNode=function(e){var n=this;if(t.has(this._nodes,e)){var r=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),(function(t){n.setParent(t)})),delete this._children[e]),t.each(t.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},n.prototype.setParent=function(n,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=e;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===n)throw new Error("Setting "+r+" as parent of "+n+" would create a cycle");this.setNode(r)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=r,this._children[r][n]=!0,this},n.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},n.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==e)return n}},n.prototype.children=function(n){if(t.isUndefined(n)&&(n=e),this._isCompound){var r=this._children[n];if(r)return t.keys(r)}else{if(n===e)return this.nodes();if(this.hasNode(n))return[]}},n.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},n.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},n.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},n.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},n.prototype.filterNodes=function(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;t.each(this._nodes,(function(t,r){e(r)&&n.setNode(r,t)})),t.each(this._edgeObjs,(function(t){n.hasNode(t.v)&&n.hasNode(t.w)&&n.setEdge(t,r.edge(t))}));var i={};function o(t){var e=r.parent(t);return void 0===e||n.hasNode(e)?(i[t]=e,e):e in i?i[e]:o(e)}return this._isCompound&&t.each(n.nodes(),(function(t){n.setParent(t,o(t))})),n},n.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return t.values(this._edgeObjs)},n.prototype.setPath=function(e,n){var r=this,i=arguments;return t.reduce(e,(function(t,e){return i.length>1?r.setEdge(t,e,n):r.setEdge(t,e),e})),this},n.prototype.setEdge=function(){var e,n,i,a,s=!1,l=arguments[0];"object"==typeof l&&null!==l&&"v"in l?(e=l.v,n=l.w,i=l.name,2===arguments.length&&(a=arguments[1],s=!0)):(e=l,n=arguments[1],i=arguments[3],arguments.length>2&&(a=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var u=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,u))return s&&(this._edgeLabels[u]=a),this;if(!t.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[u]=s?a:this._defaultEdgeLabelFn(e,n,i);var c=function(t,e,n,r){var i=""+e,o=""+n;if(!t&&i>o){var a=i;i=o,o=a}var s={v:i,w:o};r&&(s.name=r);return s}(this._isDirected,e,n,i);return e=c.v,n=c.w,Object.freeze(c),this._edgeObjs[u]=c,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][u]=c,this._out[e][u]=c,this._edgeCount++,this},n.prototype.edge=function(t,e,n){var r=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,t,e,n);return this._edgeLabels[r]},n.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},n.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,t,e,n),s=this._edgeObjs[r];return s&&(t=s.v,e=s.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[e],t),i(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},n.prototype.inEdges=function(e,n){var r=this._in[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.v===n})):i}},n.prototype.outEdges=function(e,n){var r=this._out[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.w===n})):i}},n.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},VC}function ZP(){return YC?$C:(YC=1,$C={Graph:KP(),version:UC?HC:(UC=1,HC="2.1.8")})}function QP(){if(XC)return qC;XC=1;var t=XP(),e=KP();function n(e){return t.map(e.nodes(),(function(n){var r=e.node(n),i=e.parent(n),o={v:n};return t.isUndefined(r)||(o.value=r),t.isUndefined(i)||(o.parent=i),o}))}function r(e){return t.map(e.edges(),(function(n){var r=e.edge(n),i={v:n.v,w:n.w};return t.isUndefined(n.name)||(i.name=n.name),t.isUndefined(r)||(i.value=r),i}))}return qC={write:function(e){var i={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:n(e),edges:r(e)};t.isUndefined(e.graph())||(i.value=t.clone(e.graph()));return i},read:function(n){var r=new e(n.options).setGraph(n.value);return t.each(n.nodes,(function(t){r.setNode(t.v,t.value),t.parent&&r.setParent(t.v,t.parent)})),t.each(n.edges,(function(t){r.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),r}}}function JP(){if(ZC)return KC;ZC=1;var t=XP();return KC=function(e){var n,r={},i=[];function o(i){t.has(r,i)||(r[i]=!0,n.push(i),t.each(e.successors(i),o),t.each(e.predecessors(i),o))}return t.each(e.nodes(),(function(t){n=[],o(t),n.length&&i.push(n)})),i},KC}function tR(){if(JC)return QC;JC=1;var t=XP();function e(){this._arr=[],this._keyIndices={}}return QC=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,n){var r=this._keyIndices;if(e=String(e),!t.has(r,e)){var i=this._arr,o=i.length;return r[e]=o,i.push({key:e,priority:n}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)},e.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},QC}function eR(){if(eA)return tA;eA=1;var t=XP(),e=tR();tA=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},l=new e,u=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),u=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);u<n.distance&&(n.distance=u,n.predecessor=o,l.decrease(e,u))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},l.add(t,e)}));for(;l.size()>0&&(o=l.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(u);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return tA}function nR(){if(rA)return nA;rA=1;var t=eR(),e=XP();return nA=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function rR(){if(oA)return iA;oA=1;var t=XP();return iA=function(e){var n=0,r=[],i={},o=[];function a(s){var l=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),e.successors(s).forEach((function(e){t.has(i,e)?i[e].onStack&&(l.lowlink=Math.min(l.lowlink,i[e].index)):(a(e),l.lowlink=Math.min(l.lowlink,i[e].lowlink))})),l.lowlink===l.index){var u,c=[];do{u=r.pop(),i[u].onStack=!1,c.push(u)}while(s!==u);o.push(c)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},iA}function iR(){if(sA)return aA;sA=1;var t=XP(),e=rR();return aA=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function oR(){if(uA)return lA;uA=1;var t=XP();lA=function(t,n,r){return function(t,e,n){var r={},i=t.nodes();return i.forEach((function(t){r[t]={},r[t][t]={distance:0},i.forEach((function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})})),n(t).forEach((function(n){var i=n.v===t?n.w:n.v,o=e(n);r[t][i]={distance:o,predecessor:t}}))})),i.forEach((function(t){var e=r[t];i.forEach((function(n){var o=r[n];i.forEach((function(n){var r=o[t],i=e[n],a=o[n],s=r.distance+i.distance;s<a.distance&&(a.distance=s,a.predecessor=i.predecessor)}))}))})),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return lA}function aR(){if(hA)return cA;hA=1;var t=XP();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),(function a(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),a),delete i[s],o.push(s))})),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return cA=e,e.CycleException=n,n.prototype=new Error,cA}function sR(){if(fA)return dA;fA=1;var t=aR();return dA=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function lR(){if(gA)return pA;gA=1;var t=XP();function e(n,r,i,o,a,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(a(r),(function(t){e(n,t,i,o,a,s)})),i&&s.push(r))}return pA=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],s={};return t.each(r,(function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,a)})),a},pA}function uR(){if(mA)return vA;mA=1;var t=lR();return vA=function(e,n){return t(e,n,"post")}}function cR(){if(bA)return yA;bA=1;var t=lR();return yA=function(e,n){return t(e,n,"pre")}}function hR(){if(EA)return xA;EA=1;var t=XP(),e=KP(),n=tR();return xA=function(r,i){var o,a=new e,s={},l=new n;function u(t){var e=t.v===o?t.w:t.v,n=l.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,l.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){l.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),l.decrease(r.nodes()[0],0);var c=!1;for(;l.size()>0;){if(o=l.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(c)throw new Error("Input graph is not connected: "+r);c=!0}r.nodeEdges(o).forEach(u)}return a}}try{NA=function(){if(SA)return MA;SA=1;var t=ZP();return MA={Graph:t.Graph,json:QP(),alg:kA?wA:(kA=1,wA={components:JP(),dijkstra:eR(),dijkstraAll:nR(),findCycles:iR(),floydWarshall:oR(),isAcyclic:sR(),postorder:uR(),preorder:cR(),prim:hR(),tarjan:rR(),topsort:aR()}),version:t.version}}()}catch(t){}NA||(NA=window.graphlib);var dR,fR,pR,gR,vR,mR,yR,bR,xR,ER,wR,kR,MR,SR,NR,OR,TR,CR,AR,PR,RR,DR,LR,_R,IR,jR,BR,FR,zR,GR,VR,WR,HR,UR,$R,YR,qR,XR,KR,ZR,QR,JR,tD,eD,nD,rD,iD,oD,aD,sD,lD,uD,cD,hD,dD,fD,pD,gD,vD,mD,yD,bD,xD,ED,wD,kD,MD,SD,ND,OD,TD,CD,AD,PD,RD,DD,LD,_D,ID,jD,BD,FD,zD,GD,VD,WD,HD,UD,$D,YD,qD,XD,KD,ZD=NA;function QD(){if(gR)return pR;gR=1;var t=Uk(),e=fS(),n=AM(),r=Qk();return pR=function(i,o,a){if(!r(a))return!1;var s=typeof o;return!!("number"==s?e(a)&&n(o,a.length):"string"==s&&o in a)&&t(a[o],i)},pR}function JD(){if(kR)return wR;kR=1;var t=function(){if(ER)return xR;ER=1;var t=/\s/;return xR=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},xR}(),e=/^\s+/;return wR=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function tL(){if(OR)return NR;OR=1;var t=function(){if(SR)return MR;SR=1;var t=JD(),e=Qk(),n=pP(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return MR=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var l="function"==typeof s.valueOf?s.valueOf():s;s=e(l)?l+"":l}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var u=i.test(s);return u||o.test(s)?a(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),e=1/0;return NR=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function eL(){if(PR)return AR;PR=1;var t=VP(),e=OP(),n=function(){if(CR)return TR;CR=1;var t=tL();return TR=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return AR=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var l=null==a?0:n(a);return l<0&&(l=r(s+l,0)),t(i,e(o,3),l)},AR}function nL(){if(_R)return LR;_R=1;var t=BP();return LR=function(e){return(null==e?0:e.length)?t(e,1):[]}}function rL(){if(WR)return VR;WR=1;var t=pP();return VR=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=n(a);if(null!=s&&(void 0===l?s==s&&!t(s):r(s,l)))var l=s,u=a}return u},VR}function iL(){if(XR)return qR;XR=1;var t=hM(),e=Uk();return qR=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function oL(){if(JR)return QR;return JR=1,QR=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function aL(){if(rD)return nD;rD=1;var t=iL(),e=TA(),n=VA(),r=CA(),i=UA(),o=gM(),a=vM(),s=$P(),l=CM(),u=Jk(),c=Qk(),h=function(){if(ZR)return KR;ZR=1;var t=Zk(),e=LA(),n=pM(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return KR=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var l=a.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==s}}(),d=lS(),f=oL(),p=function(){if(eD)return tD;eD=1;var t=fM(),e=vS();return tD=function(n){return t(n,e(n))}}();return nD=function(g,v,m,y,b,x,E){var w=f(g,m),k=f(v,m),M=E.get(k);if(M)t(g,m,M);else{var S=x?x(w,k,m+"",g,v,E):void 0,N=void 0===S;if(N){var O=a(k),T=!O&&l(k),C=!O&&!T&&d(k);S=k,O||T||C?a(w)?S=w:s(w)?S=r(w):T?(N=!1,S=e(k,!0)):C?(N=!1,S=n(k,!0)):S=[]:h(k)||o(k)?(S=w,o(w)?S=p(w):c(w)&&!u(w)||(S=i(k))):N=!1}N&&(E.set(k,S),b(S,k,y,x,E),E.delete(k)),t(g,m,S)}}}function sL(){if(hD)return cD;return hD=1,cD=function(t,e){return t<e}}function lL(){if(ED)return xD;ED=1;var t=EP(),e=function(){if(bD)return yD;bD=1;var t=dM(),e=bP(),n=AM(),r=Qk(),i=xP();return yD=function(o,a,s,l){if(!r(o))return o;for(var u=-1,c=(a=e(a,o)).length,h=c-1,d=o;null!=d&&++u<c;){var f=i(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(u!=h){var g=d[f];void 0===(p=l?l(g,f,d):void 0)&&(p=r(g)?g:n(a[u+1])?[]:{})}t(d,f,p),d=d[f]}return o},yD}(),n=bP();return xD=function(r,i,o){for(var a=-1,s=i.length,l={};++a<s;){var u=i[a],c=t(r,u);o(c,u)&&e(l,n(u,r),c)}return l},xD}function uL(){if(PD)return AD;PD=1;var t=function(){if(CD)return TD;CD=1;var t=Math.ceil,e=Math.max;return TD=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),l=Array(s);s--;)l[o?s:++a]=n,n+=i;return l},TD}(),e=QD(),n=tL();return AD=function(r){return function(i,o,a){return a&&"number"!=typeof a&&e(i,o,a)&&(o=a=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),a=void 0===a?i<o?1:-1:n(a),t(i,o,a,r)}},AD}function cL(){if(FD)return BD;FD=1;var t=function(){if(jD)return ID;jD=1;var t=pP();return ID=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,l=null===n,u=n==n,c=t(n);if(!l&&!c&&!a&&e>n||a&&s&&u&&!l&&!c||i&&s&&u||!r&&u||!o)return 1;if(!i&&!a&&!c&&e<n||c&&r&&o&&!i&&!a||l&&r&&o||!s&&o||!u)return-1}return 0}}();return BD=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,l=r.length;++i<s;){var u=t(o[i],a[i]);if(u)return i>=l?u:u*("desc"==r[i]?-1:1)}return e.index-n.index},BD}function hL(){if(GD)return zD;GD=1;var t=mP(),e=EP(),n=OP(),r=RP(),i=(_D||(_D=1,LD=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),LD),o=RM(),a=cL(),s=tP(),l=vM();return zD=function(u,c,h){c=c.length?t(c,(function(t){return l(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;c=t(c,o(n));var f=r(u,(function(e,n,r){return{criteria:t(c,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,h)}))},zD}try{KD={cloneDeep:function(){if(fR)return dR;fR=1;var t=qA();return dR=function(e){return t(e,5)}}(),constant:KA(),defaults:function(){if(mR)return vR;mR=1;var t=GP(),e=Uk(),n=QD(),r=vS(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,l=a.length,u=l>2?a[2]:void 0;for(u&&n(a[0],a[1],u)&&(l=1);++s<l;)for(var c=a[s],h=r(c),d=-1,f=h.length;++d<f;){var p=h[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=c[p])}return t}));return vR=a}(),each:rP(),filter:TP(),find:function(){if(DR)return RR;DR=1;var t=function(){if(bR)return yR;bR=1;var t=OP(),e=fS(),n=pS();return yR=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var l=t(o,3);i=n(i),o=function(t){return l(s[t],t,s)}}var u=r(i,o,a);return u>-1?s[l?i[u]:u]:void 0}},yR}(),e=t(eL());return RR=e}(),flatten:nL(),forEach:nP(),forIn:function(){if(jR)return IR;jR=1;var t=ZA(),e=eP(),n=vS();return IR=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:CP(),isUndefined:PP(),last:(FR||(FR=1,BR=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),BR),map:DP(),mapValues:function(){if(GR)return zR;GR=1;var t=hM(),e=QA(),n=OP();return zR=function(r,i){var o={};return i=n(i,3),e(r,(function(e,n,r){t(o,n,i(e,n,r))})),o}}(),max:function(){if(YR)return $R;YR=1;var t=rL(),e=UR?HR:(UR=1,HR=function(t,e){return t>e}),n=tP();return $R=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(uD)return lD;uD=1;var t=function(){if(oD)return iD;oD=1;var t=lM(),e=iL(),n=ZA(),r=aL(),i=Qk(),o=vS(),a=oL();return iD=function s(l,u,c,h,d){l!==u&&n(u,(function(n,o){if(d||(d=new t),i(n))r(l,u,o,c,s,h,d);else{var f=h?h(a(l,o),n,o+"",l,u,d):void 0;void 0===f&&(f=n),e(l,o,f)}}),o)},iD}(),e=function(){if(sD)return aD;sD=1;var t=GP(),e=QD();return aD=function(n){return t((function(t,r){var i=-1,o=r.length,a=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(a=n.length>3&&"function"==typeof a?(o--,a):void 0,s&&e(r[0],r[1],s)&&(a=o<3?void 0:a,o=1),t=Object(t);++i<o;){var l=r[i];l&&n(t,l,i,a)}return t}))},aD}(),n=e((function(e,n,r){t(e,n,r)}));return lD=n}(),min:function(){if(fD)return dD;fD=1;var t=rL(),e=sL(),n=tP();return dD=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(gD)return pD;gD=1;var t=rL(),e=OP(),n=sL();return pD=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(mD)return vD;mD=1;var t=Xk();return vD=function(){return t.Date.now()}}(),pick:function(){if(OD)return ND;OD=1;var t=function(){if(kD)return wD;kD=1;var t=lL(),e=kP();return wD=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(SD)return MD;SD=1;var t=nL(),e=FP(),n=zP();return MD=function(r){return n(e(r,void 0,t),r+"")}}(),n=e((function(e,n){return null==e?{}:t(e,n)}));return ND=n}(),range:function(){if(DD)return RD;DD=1;var t=uL()();return RD=t}(),reduce:LP(),sortBy:function(){if(WD)return VD;WD=1;var t=BP(),e=hL(),n=GP(),r=QD(),i=n((function(n,i){if(null==n)return[];var o=i.length;return o>1&&r(n,i[0],i[1])?i=[]:o>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),e(n,t(i,1),[])}));return VD=i}(),uniqueId:function(){if(UD)return HD;UD=1;var t=yP(),e=0;return HD=function(n){var r=++e;return t(n)+r},HD}(),values:qP(),zipObject:function(){if(XD)return qD;XD=1;var t=dM(),e=(YD||(YD=1,$D=function(t,e,n){for(var r=-1,i=t.length,o=e.length,a={};++r<i;){var s=r<o?e[r]:void 0;n(a,t[r],s)}return a}),$D);return qD=function(n,r){return e(n||[],r||[],t)},qD}()}}catch(t){}KD||(KD=window._);var dL=KD,fL=pL;function pL(){var t={};t._next=t._prev=t,this._sentinel=t}function gL(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function vL(t,e){if("_next"!==t&&"_prev"!==t)return e}pL.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return gL(e),e},pL.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&gL(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},pL.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,vL)),n=n._prev;return"["+t.join(", ")+"]"};var mL=dL,yL=ZD.Graph,bL=fL,xL=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new yL,r=0,i=0;mL.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),mL.forEach(t.edges(),(function(t){var o=n.edge(t.v,t.w)||0,a=e(t),s=o+a;n.setEdge(t.v,t.w,s),i=Math.max(i,n.node(t.v).out+=a),r=Math.max(r,n.node(t.w).in+=a)}));var o=mL.range(i+r+3).map((function(){return new bL})),a=r+1;return mL.forEach(n.nodes(),(function(t){kL(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||EL),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)wL(t,e,n,r);for(;r=o.dequeue();)wL(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(wL(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return mL.flatten(mL.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},EL=mL.constant(1);function wL(t,e,n,r,i){var o=i?[]:void 0;return mL.forEach(t.inEdges(r.v),(function(r){var a=t.edge(r),s=t.node(r.v);i&&o.push({v:r.v,w:r.w}),s.out-=a,kL(e,n,s)})),mL.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,kL(e,n,a)})),t.removeNode(r.v),o}function kL(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}var ML=dL,SL=xL,NL={run:function(t){var e="greedy"===t.graph().acyclicer?SL(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){ML.has(r,o)||(r[o]=!0,n[o]=!0,ML.forEach(t.outEdges(o),(function(t){ML.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return ML.forEach(t.nodes(),i),e}(t);ML.forEach(e,(function(e){var n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,ML.uniqueId("rev"))}))},undo:function(t){ML.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}}))}};var OL=dL,TL=ZD.Graph,CL={addDummyNode:AL,simplify:function(t){var e=(new TL).setGraph(t.graph());return OL.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),OL.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})})),e},asNonCompoundGraph:function(t){var e=new TL({multigraph:t.isMultigraph()}).setGraph(t.graph());return OL.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),OL.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=OL.map(t.nodes(),(function(e){var n={};return OL.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return OL.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=OL.map(t.nodes(),(function(e){var n={};return OL.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return OL.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,a=e.x-i,s=e.y-o,l=t.width/2,u=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*l>Math.abs(a)*u?(s<0&&(u=-u),n=u*a/s,r=u):(a<0&&(l=-l),n=l,r=l*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=OL.map(OL.range(PL(t)+1),(function(){return[]}));return OL.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;OL.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=OL.min(OL.map(t.nodes(),(function(e){return t.node(e).rank})));OL.forEach(t.nodes(),(function(n){var r=t.node(n);OL.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=OL.min(OL.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];OL.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r)}));var r=0,i=t.graph().nodeRankFactor;OL.forEach(n,(function(e,n){OL.isUndefined(e)&&n%i!==0?--r:r&&OL.forEach(e,(function(e){t.node(e).rank+=r}))}))},addBorderNode:function(t,e,n,r){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return AL(t,"border",i,e)},maxRank:PL,partition:function(t,e){var n={lhs:[],rhs:[]};return OL.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=OL.now();try{return e()}finally{console.log(t+" time: "+(OL.now()-n)+"ms")}},notime:function(t,e){return e()}};function AL(t,e,n,r){var i;do{i=OL.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function PL(t){return OL.max(OL.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!OL.isUndefined(n))return n})))}var RL=dL,DL=CL,LL={run:function(t){t.graph().dummyChains=[],RL.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,l=t.node(s).rank,u=e.name,c=t.edge(e),h=c.labelRank;if(l===a+1)return;for(t.removeEdge(e),i=0,++a;a<l;++i,++a)c.points=[],r={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},n=DL.addDummyNode(t,"edge",r,"_d"),a===h&&(r.width=c.width,r.height=c.height,r.dummy="edge-label",r.labelpos=c.labelpos),t.setEdge(o,n,{weight:c.weight},u),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:c.weight},u)}(t,e)}))},undo:function(t){RL.forEach(t.graph().dummyChains,(function(e){var n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)}))}};var _L=dL,IL={longestPath:function(t){var e={};_L.forEach(t.sources(),(function n(r){var i=t.node(r);if(_L.has(e,r))return i.rank;e[r]=!0;var o=_L.min(_L.map(t.outEdges(r),(function(e){return n(e.w)-t.edge(e).minlen})));return o!==Number.POSITIVE_INFINITY&&null!=o||(o=0),i.rank=o}))},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var jL=dL,BL=ZD.Graph,FL=IL.slack,zL=function(t){var e,n,r=new BL({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;GL(r,t)<o;)e=VL(r,t),n=r.hasNode(e.v)?FL(t,e):-FL(t,e),WL(r,t,n);return r};function GL(t,e){return jL.forEach(t.nodes(),(function n(r){jL.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||FL(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function VL(t,e){return jL.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return FL(e,n)}))}function WL(t,e,n){jL.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var HL=dL,UL=zL,$L=IL.slack,YL=IL.longestPath,qL=ZD.alg.preorder,XL=ZD.alg.postorder,KL=CL.simplify,ZL=QL;function QL(t){t=KL(t),YL(t);var e,n=UL(t);for(e_(n),JL(n,t);e=r_(n);)o_(n,t,e,i_(n,t,e))}function JL(t,e){var n=XL(t,t.nodes());n=n.slice(0,n.length-1),HL.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=t_(t,e,n)}(t,e,n)}))}function t_(t,e,n){var r=t.node(n).parent,i=!0,o=e.edge(n,r),a=0;return o||(i=!1,o=e.edge(r,n)),a=o.weight,HL.forEach(e.nodeEdges(n),(function(o){var s,l,u=o.v===n,c=u?o.w:o.v;if(c!==r){var h=u===i,d=e.edge(o).weight;if(a+=h?d:-d,s=n,l=c,t.hasEdge(s,l)){var f=t.edge(n,c).cutvalue;a+=h?-f:f}}})),a}function e_(t,e){arguments.length<2&&(e=t.nodes()[0]),n_(t,{},1,e)}function n_(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,HL.forEach(t.neighbors(r),(function(i){HL.has(e,i)||(n=n_(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function r_(t){return HL.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function i_(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var o=t.node(r),a=t.node(i),s=o,l=!1;o.lim>a.lim&&(s=a,l=!0);var u=HL.filter(e.edges(),(function(e){return l===a_(t,t.node(e.v),s)&&l!==a_(t,t.node(e.w),s)}));return HL.minBy(u,(function(t){return $L(e,t)}))}function o_(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),e_(t),JL(t,e),function(t,e){var n=HL.find(t.nodes(),(function(t){return!e.node(t).parent})),r=qL(t,n);r=r.slice(1),HL.forEach(r,(function(n){var r=t.node(n).parent,i=e.edge(n,r),o=!1;i||(i=e.edge(r,n),o=!0),e.node(n).rank=e.node(r).rank+(o?i.minlen:-i.minlen)}))}(t,e)}function a_(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}QL.initLowLimValues=e_,QL.initCutValues=JL,QL.calcCutValue=t_,QL.leaveEdge=r_,QL.enterEdge=i_,QL.exchangeEdges=o_;var s_=IL.longestPath,l_=zL,u_=ZL,c_=function(t){switch(t.graph().ranker){case"network-simplex":default:d_(t);break;case"tight-tree":!function(t){s_(t),l_(t)}(t);break;case"longest-path":h_(t)}};var h_=s_;function d_(t){u_(t)}var f_=dL,p_=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;f_.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return f_.forEach(t.children(),r),e}(t);f_.forEach(t.graph().dummyChains,(function(n){for(var r=t.node(n),i=r.edgeObj,o=function(t,e,n,r){var i,o,a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>l||u>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:a.concat(s.reverse()),lca:o}}(t,e,i.v,i.w),a=o.path,s=o.lca,l=0,u=a[l],c=!0;n!==i.w;){if(r=t.node(n),c){for(;(u=a[l])!==s&&t.node(u).maxRank<r.rank;)l++;u===s&&(c=!1)}if(!c){for(;l<a.length-1&&t.node(u=a[l+1]).minRank<=r.rank;)l++;u=a[l]}t.setParent(n,u),n=t.successors(n)[0]}}))};var g_=dL,v_=CL,m_={run:function(t){var e=v_.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&g_.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return g_.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=g_.max(g_.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,g_.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return g_.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;g_.forEach(t.children(),(function(a){y_(t,e,i,o,r,n,a)})),t.graph().nodeRankFactor=i},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,g_.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function y_(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var l=v_.addBorderNode(t,"_bt"),u=v_.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(l,a),c.borderTop=l,t.setParent(u,a),c.borderBottom=u,g_.forEach(s,(function(s){y_(t,e,n,r,i,o,s);var c=t.node(s),h=c.borderTop?c.borderTop:s,d=c.borderBottom?c.borderBottom:s,f=c.borderTop?r:2*r,p=h!==d?1:i-o[a]+1;t.setEdge(l,h,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,l,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var b_=dL,x_=CL,E_=function(t){b_.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&b_.forEach(r,e),b_.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)w_(t,"borderLeft","_bl",n,i,o),w_(t,"borderRight","_br",n,i,o)}}))};function w_(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],l=x_.addDummyNode(t,"border",a,n);i[e][o]=l,t.setParent(l,r),s&&t.setEdge(s,l,{weight:1})}var k_=dL,M_={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||S_(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){k_.forEach(t.nodes(),(function(e){O_(t.node(e))})),k_.forEach(t.edges(),(function(e){var n=t.edge(e);k_.forEach(n.points,O_),k_.has(n,"y")&&O_(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){k_.forEach(t.nodes(),(function(e){T_(t.node(e))})),k_.forEach(t.edges(),(function(e){var n=t.edge(e);k_.forEach(n.points,T_),k_.has(n,"x")&&T_(n)}))}(t),S_(t))}};function S_(t){k_.forEach(t.nodes(),(function(e){N_(t.node(e))})),k_.forEach(t.edges(),(function(e){N_(t.edge(e))}))}function N_(t){var e=t.width;t.width=t.height,t.height=e}function O_(t){t.y=-t.y}function T_(t){var e=t.x;t.x=t.y,t.y=e}var C_=dL,A_=function(t){var e={},n=C_.filter(t.nodes(),(function(e){return!t.children(e).length})),r=C_.max(C_.map(n,(function(e){return t.node(e).rank}))),i=C_.map(C_.range(r+1),(function(){return[]}));function o(n){if(!C_.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),C_.forEach(t.successors(n),o)}}var a=C_.sortBy(n,(function(e){return t.node(e).rank}));return C_.forEach(a,o),i};var P_=dL,R_=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=D_(t,e[r-1],e[r]);return n};function D_(t,e,n){for(var r=P_.zipObject(n,P_.map(n,(function(t,e){return e}))),i=P_.flatten(P_.map(e,(function(e){return P_.sortBy(P_.map(t.outEdges(e),(function(e){return{pos:r[e.w],weight:t.edge(e).weight}})),"pos")})),!0),o=1;o<n.length;)o<<=1;var a=2*o-1;o-=1;var s=P_.map(new Array(a),(function(){return 0})),l=0;return P_.forEach(i.forEach((function(t){var e=t.pos+o;s[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=s[e+1]),s[e=e-1>>1]+=t.weight;l+=t.weight*n}))),l}var L_=dL;var __=dL,I_=function(t,e){var n={};return __.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};__.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),__.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];__.isUndefined(e)||__.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(__.isUndefined(e.barycenter)||__.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function r(e){return function(n){n.in.push(e),0===--n.indegree&&t.push(n)}}for(;t.length;){var i=t.pop();e.push(i),__.forEach(i.in.reverse(),n(i)),__.forEach(i.out,r(i))}return __.map(__.filter(e,(function(t){return!t.merged})),(function(t){return __.pick(t,["vs","i","barycenter","weight"])}))}(__.filter(n,(function(t){return!t.indegree})))};var j_=dL,B_=CL;function F_(t,e,n){for(var r;e.length&&(r=j_.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var z_=dL,G_=function(t,e){return L_.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=L_.reduce(n,(function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}}),{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}}))},V_=I_,W_=function(t,e){var n=B_.partition(t,(function(t){return j_.has(t,"barycenter")})),r=n.lhs,i=j_.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,l=0;r.sort((u=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:u?e.i-t.i:t.i-e.i})),l=F_(o,i,l),j_.forEach(r,(function(t){l+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,l=F_(o,i,l)}));var u;var c={vs:j_.flatten(o,!0)};s&&(c.barycenter=a/s,c.weight=s);return c},H_=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,u={};s&&(o=z_.filter(o,(function(t){return t!==s&&t!==l})));var c=G_(e,o);z_.forEach(c,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);u[n.v]=o,z_.has(o,"barycenter")&&(a=n,s=o,z_.isUndefined(a.barycenter)?(a.barycenter=s.barycenter,a.weight=s.weight):(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight))}var a,s}));var h=V_(c,r);!function(t,e){z_.forEach(t,(function(t){t.vs=z_.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,u);var d=W_(h,i);if(s&&(d.vs=z_.flatten([s,d.vs,l],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(l)[0]);z_.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var U_=dL,$_=ZD.Graph,Y_=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=U_.uniqueId("_root")););return e}(t),i=new $_({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return U_.forEach(t.nodes(),(function(o){var a=t.node(o),s=t.parent(o);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),U_.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=U_.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),U_.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var q_=dL;var X_=dL,K_=A_,Z_=R_,Q_=H_,J_=Y_,tI=function(t,e,n){var r,i={};q_.forEach(n,(function(n){for(var o,a,s=t.parent(n);s;){if((o=t.parent(s))?(a=i[o],i[o]=s):(a=r,r=s),a&&a!==s)return void e.setEdge(a,s);s=o}}))},eI=ZD.Graph,nI=CL,rI=function(t){var e=nI.maxRank(t),n=iI(t,X_.range(1,e+1),"inEdges"),r=iI(t,X_.range(e-1,-1,-1),"outEdges"),i=K_(t);aI(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,l=0;l<4;++s,++l){oI(s%2?n:r,s%4>=2),i=nI.buildLayerMatrix(t);var u=Z_(t,i);u<a&&(l=0,o=X_.cloneDeep(i),a=u)}aI(t,o)};function iI(t,e,n){return X_.map(e,(function(e){return J_(t,e,n)}))}function oI(t,e){var n=new eI;X_.forEach(t,(function(t){var r=t.graph().root,i=Q_(t,r,n,e);X_.forEach(i.vs,(function(e,n){t.node(e).order=n})),tI(t,n,i.vs)}))}function aI(t,e){X_.forEach(e,(function(e){X_.forEach(e,(function(e,n){t.node(e).order=n}))}))}var sI=dL,lI=ZD.Graph,uI=CL,cI=function(t){var e,n=uI.buildLayerMatrix(t),r=sI.merge(function(t,e){var n={};function r(e,r){var i=0,o=0,a=e.length,s=sI.last(r);return sI.forEach(r,(function(e,l){var u=function(t,e){if(t.node(e).dummy)return sI.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=u?t.node(u).order:a;(u||e===s)&&(sI.forEach(r.slice(o,l+1),(function(e){sI.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||c<a)||o.dummy&&t.node(e).dummy||hI(n,r,e)}))})),o=l+1,i=c)})),r}return sI.reduce(e,r),n}(t,n),function(t,e){var n={};function r(e,r,i,o,a){var s;sI.forEach(sI.range(r,i),(function(r){s=e[r],t.node(s).dummy&&sI.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&hI(n,e,s)}))}))}function i(e,n){var i,o=-1,a=0;return sI.forEach(n,(function(s,l){if("border"===t.node(s).dummy){var u=t.predecessors(s);u.length&&(i=t.node(u[0]).order,r(n,a,l,o,i),a=l,o=i)}r(n,a,n.length,i,e.length)})),n}return sI.reduce(e,i),n}(t,n)),i={};sI.forEach(["u","d"],(function(o){e="u"===o?n:sI.values(n).reverse(),sI.forEach(["l","r"],(function(n){"r"===n&&(e=sI.map(e,(function(t){return sI.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=function(t,e,n,r){var i={},o={},a={};return sI.forEach(e,(function(t){sI.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),sI.forEach(e,(function(t){var e=-1;sI.forEach(t,(function(t){var s=r(t);if(s.length){s=sI.sortBy(s,(function(t){return a[t]}));for(var l=(s.length-1)/2,u=Math.floor(l),c=Math.ceil(l);u<=c;++u){var h=s[u];o[t]===t&&e<a[h]&&!dI(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}(0,e,r,a),l=function(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new lI,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),l=r.node(o),u=0;if(u+=s.width/2,sI.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(u+=n?a:-a),a=0,u+=(s.dummy?e:t)/2,u+=(l.dummy?e:t)/2,u+=l.width/2,sI.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(u+=n?a:-a),a=0,u}}(o.nodesep,o.edgesep,r);return sI.forEach(e,(function(e){var r;sI.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],l=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),l||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function l(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}function u(t){o[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,o[e.v]+a.edge(e))}),0)}function c(e){var n=a.outEdges(e).reduce((function(t,e){return Math.min(t,o[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==s&&(o[e]=Math.max(o[e],n))}return l(u,a.predecessors.bind(a)),l(c,a.successors.bind(a)),sI.forEach(r,(function(t){o[t]=o[n[t]]})),o}(t,e,s.root,s.align,"r"===n);"r"===n&&(l=sI.mapValues(l,(function(t){return-t}))),i[o+n]=l}))}));var o=function(t,e){return sI.minBy(sI.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return sI.forIn(e,(function(e,i){var o=function(t,e){return t.node(e).width}(t,i)/2;n=Math.max(e+o,n),r=Math.min(e-o,r)})),n-r}))}(t,i);return function(t,e){var n=sI.values(e),r=sI.min(n),i=sI.max(n);sI.forEach(["u","d"],(function(n){sI.forEach(["l","r"],(function(o){var a,s=n+o,l=t[s];if(l!==e){var u=sI.values(l);(a="l"===o?r-sI.min(u):i-sI.max(u))&&(t[s]=sI.mapValues(l,(function(t){return t+a})))}}))}))}(i,o),function(t,e){return sI.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=sI.sortBy(sI.map(t,r));return(i[1]+i[2])/2}))}(i,t.graph().align)};function hI(t,e,n){if(e>n){var r=e;e=n,n=r}var i=t[e];i||(t[e]=i={}),i[n]=!0}function dI(t,e,n){if(e>n){var r=e;e=n,n=r}return sI.has(t[e],n)}var fI=dL,pI=CL,gI=cI,vI=function(t){(function(t){var e=pI.buildLayerMatrix(t),n=t.graph().ranksep,r=0;fI.forEach(e,(function(e){var i=fI.max(fI.map(e,(function(e){return t.node(e).height})));fI.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=pI.asNonCompoundGraph(t)),fI.forEach(gI(t),(function(e,n){t.node(n).x=e}))};var mI=dL,yI=NL,bI=LL,xI=c_,EI=CL.normalizeRanks,wI=p_,kI=CL.removeEmptyRanks,MI=m_,SI=E_,NI=M_,OI=rI,TI=vI,CI=CL,AI=ZD.Graph,PI=function(t,e){var n=e&&e.debugTiming?CI.time:CI.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new AI({multigraph:!0,compound:!0}),n=GI(t.graph());return e.setGraph(mI.merge({},DI,zI(n,RI),mI.pick(n,LI))),mI.forEach(t.nodes(),(function(n){var r=GI(t.node(n));e.setNode(n,mI.defaults(zI(r,_I),II)),e.setParent(n,t.parent(n))})),mI.forEach(t.edges(),(function(n){var r=GI(t.edge(n));e.setEdge(n,mI.merge({},BI,zI(r,jI),mI.pick(r,FI)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,mI.forEach(t.edges(),(function(n){var r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){mI.forEach(t.edges(),(function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){yI.run(t)})),e(" nestingGraph.run",(function(){MI.run(t)})),e(" rank",(function(){xI(CI.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};CI.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){kI(t)})),e(" nestingGraph.cleanup",(function(){MI.cleanup(t)})),e(" normalizeRanks",(function(){EI(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;mI.forEach(t.nodes(),(function(n){var r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=mI.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){mI.forEach(t.nodes(),(function(e){var n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){bI.run(t)})),e(" parentDummyChains",(function(){wI(t)})),e(" addBorderSegments",(function(){SI(t)})),e(" order",(function(){OI(t)})),e(" insertSelfEdges",(function(){!function(t){var e=CI.buildLayerMatrix(t);mI.forEach(e,(function(e){var n=0;mI.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,mI.forEach(i.selfEdges,(function(e){CI.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")})),delete i.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){NI.adjust(t)})),e(" position",(function(){TI(t)})),e(" positionSelfEdges",(function(){!function(t){mI.forEach(t.nodes(),(function(e){var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,o=r.y,a=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{x:i+a,y:o},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){mI.forEach(t.nodes(),(function(e){if(t.children(e).length){var n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),o=t.node(mI.last(n.borderLeft)),a=t.node(mI.last(n.borderRight));n.width=Math.abs(a.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}})),mI.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){bI.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);if(mI.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){NI.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=t.graph(),a=o.marginx||0,s=o.marginy||0;function l(t){var o=t.x,a=t.y,s=t.width,l=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-l/2),i=Math.max(i,a+l/2)}mI.forEach(t.nodes(),(function(e){l(t.node(e))})),mI.forEach(t.edges(),(function(e){var n=t.edge(e);mI.has(n,"x")&&l(n)})),e-=a,r-=s,mI.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),mI.forEach(t.edges(),(function(n){var i=t.edge(n);mI.forEach(i.points,(function(t){t.x-=e,t.y-=r})),mI.has(i,"x")&&(i.x-=e),mI.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n,r,i=t.edge(e),o=t.node(e.v),a=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=a,r=o),i.points.unshift(CI.intersectRect(o,n)),i.points.push(CI.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){yI.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){mI.forEach(t.nodes(),(function(n){var r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,e.children(n).length&&(r.width=i.width,r.height=i.height))})),mI.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,mI.has(i,"x")&&(r.x=i.x,r.y=i.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var RI=["nodesep","edgesep","ranksep","marginx","marginy"],DI={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},LI=["acyclicer","ranker","rankdir","align"],_I=["width","height"],II={width:0,height:0},jI=["minlen","weight","width","height","labeloffset"],BI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},FI=["labelpos"];function zI(t,e){return mI.mapValues(mI.pick(t,e),Number)}function GI(t){var e={};return mI.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var VI=dL,WI=CL,HI=ZD.Graph,UI={debugOrdering:function(t){var e=WI.buildLayerMatrix(t),n=new HI({compound:!0,multigraph:!0}).setGraph({});return VI.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),VI.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),VI.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),VI.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var $I={graphlib:ZD,layout:PI,debug:UI,util:{time:CL.time,notime:CL.notime},version:"0.8.5"},YI=E($I);class qI{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,qI.defaultOptions,t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new $I.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>ae(t)))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach((t=>{const{id:e}=t,n=Object.assign({},t.data);if(void 0!==r){const[e,i]=db(Ut(r)?r(t):r);Object.assign(n,{width:e,height:i})}i.setNode(e.toString(),n)})),e.getAllEdges().forEach((({id:t,source:e,target:n})=>{i.setEdge(e.toString(),n.toString(),{id:t})})),YI.layout(i);const o={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);o.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:a}=r,s=Fe(r,["id"]),{v:l,w:u}=n;o.edges.push({id:a,source:l,target:u,data:s}),t&&e.mergeEdgeData(a,s)})),o}))}}qI.defaultOptions={};class XI{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,n=t.ry-this.ry;let r=Math.hypot(e,n);r=r<1e-4?1e-4:r;const i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/e,r=(this.ry*this.mass+t.ry*t.mass)/e,i=this.degree+t.degree;return new XI({rx:n,ry:r,mass:e,degree:i})}}class KI{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new KI({xmid:t,ymid:e,length:n})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new KI({xmid:t,ymid:e,length:n})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new KI({xmid:t,ymid:e,length:n})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new KI({xmid:t,ymid:e,length:n})}}class ZI{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new ZI(this.quad.NW()),this.NE=new ZI(this.quad.NE()),this.SW=new ZI(this.quad.SW()),this.SE=new ZI(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}const QI={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class JI{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},QI),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:l,maxIteration:u,nodeSize:c,center:h}=o;if(!(null==i?void 0:i.length)||1===i.length)return bb(e,t,h);const d=i.map((t=>hb(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Yg({nodes:d,edges:f}),g=this.getSizes(p,c);if(this.run(p,e,u,g,t,o),l){for(let t=0;t<f.length;t+=1){const{source:e,target:n}=f[t],r=p.getDegree(e),i=p.getDegree(e);if(r<=1){const t=p.getNode(n);p.mergeNodeData(e,{x:t.data.x,y:t.data.y})}else if(i<=1){const t=p.getNode(e);p.mergeNodeData(n,{x:t.data.x,y:t.data.y})}}const n=Object.assign(Object.assign({},o),{prune:!1,barnesHut:!1});this.run(p,e,100,g,t,n)}return{nodes:d,edges:r}}))}getSizes(t,e){const n=t.getAllNodes(),r={};for(let t=0;t<n.length;t+=1){const i=n[t];r[i.id]=gb(e,void 0)(i)}return r}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:l,kr:u,kg:c}=n;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=o||"undefined"==typeof window?o:window.innerHeight,n.center=r||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===s&&e>100&&(n.prune=!0),0!==l||s?0===l&&s&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),u||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:l}=o,u=t.getAllNodes();let c=0,h=n;const d={},f={},p={};for(let e=0;e<u.length;e+=1){const{data:n,id:r}=u[e];if(d[r]=[0,0],s){const i={id:e,rx:n.x,ry:n.y,mass:1,g:a,degree:t.getDegree(r)};p[r]=new XI(i)}}for(;h>0;)c=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:c,forces:d,preForces:f,bodies:p,sizes:r},o),h--,null==l||l({nodes:u,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:l,sizes:u}=e;let{forces:c}=e;const{preventOverlap:h,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...c[e]],c[e]=[0,0]}return c=this.getAttrForces(t,r,i,u,c,n),c=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,c,l,n):this.getRepGraForces(t,r,i,c,o,u,n),this.updatePos(t,c,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:l,prune:u}=o,c=t.getAllEdges();for(let o=0;o<c.length;o+=1){const{source:h,target:d}=c[o],f=t.getNode(h),p=t.getNode(d),g=t.getDegree(h),v=t.getDegree(d);if(u&&(g<=1||v<=1))continue;const m=[p.data.x-f.data.x,p.data.y-f.data.y];let y=Math.hypot(m[0],m[1]);y=y<1e-4?1e-4:y,m[0]=m[0]/y,m[1]=m[1]/y,a&&e<n&&(y=y-r[h]-r[d]);let b=y,x=b;"linlog"===l&&(b=Math.log(1+y),x=b),s&&(b=y/g,x=y/v),a&&e<n&&y<=0?(b=0,x=0):a&&e<n&&y>0&&(b=y,x=y),i[h][0]+=b*m[0],i[d][0]-=x*m[0],i[h][1]+=b*m[1],i[d][1]-=x*m[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),l=s.length;let u=9e10,c=-9e10,h=9e10,d=-9e10;for(let e=0;e<l;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=c&&(c=i.x),i.x<=u&&(u=i.x),i.y>=d&&(d=i.y),i.y<=h&&(h=i.y))}const f=Math.max(c-u,d-h),p=new KI({xmid:(c+u)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:l}),g=new ZI(p);for(let e=0;e<l;e+=1){const{id:r}=s[e];a&&t.getDegree(r)<=1||n[r].in(p)&&g.insert(n[r])}for(let r=0;r<l;r+=1){const{id:l,data:u}=s[r],c=t.getDegree(l);if(a&&c<=1)continue;n[l].resetForce(),g.updateForce(n[l]),e[l][0]-=n[l].fx,e[l][1]-=n[l].fy;const h=[u.x-o[0],u.y-o[1]];let d=Math.hypot(h[0],h[1]);d=d<1e-4?1e-4:d,h[0]=h[0]/d,h[1]=h[1]/d;const f=i*(c+1);e[l][0]-=f*h[0],e[l][1]-=f*h[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:l,kg:u,center:c,prune:h}=a,d=t.getAllNodes(),f=d.length;for(let a=0;a<f;a+=1){const p=d[a],g=t.getDegree(p.id);for(let u=a+1;u<f;u+=1){const a=d[u],c=t.getDegree(a.id);if(h&&(g<=1||c<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let v=Math.hypot(f[0],f[1]);v=v<1e-4?1e-4:v,f[0]=f[0]/v,f[1]=f[1]/v,s&&e<n&&(v=v-o[p.id]-o[a.id]);let m=l*(g+1)*(c+1)/v;s&&e<n&&v<0?m=i*(g+1)*(c+1):s&&e<n&&0===v?m=0:s&&e<n&&v>0&&(m=l*(g+1)*(c+1)/v),r[p.id][0]-=m*f[0],r[a.id][0]+=m*f[0],r[p.id][1]-=m*f[1],r[a.id][1]+=m*f[1]}const v=[p.data.x-c[0],p.data.y-c[1]],m=Math.hypot(v[0],v[1]);v[0]=v[0]/m,v[1]=v[1]/m;const y=u*(g+1);r[p.id][0]-=y*v[0],r[p.id][1]-=y*v[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:l}=i,u=t.getAllNodes(),c=u.length,h=[],d=[];let f=0,p=0,g=r;for(let r=0;r<c;r+=1){const{id:i}=u[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],l=Math.hypot(a[0],a[1]),c=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(c[0],c[1]);h[r]=l,d[r]=g/2,f+=(o+1)*h[r],p+=(o+1)*d[r]}const v=g;g=a*p/f,0!==v&&(g=g>1.5*v?1.5*v:g);for(let n=0;n<c;n+=1){const{id:r,data:i}=u[n],a=t.getDegree(r);if(s&&a<=1)continue;if(ae(i.fx)&&ae(i.fy))continue;let c=o*g/(1+g*Math.sqrt(h[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=l/d;c=c>f?f:c;const p=c*e[r][0],v=c*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+v})}return g}}const tj={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};class ej{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},tj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericFruchtermanLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;e<t;e++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericFruchtermanLayout(t,e,n){return ze(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:l,nodeClusterBy:u,maxIteration:c,onTick:h}=r,d=e.getAllNodes(),f=e.getAllEdges();if(!(null==d?void 0:d.length)){const t={nodes:[],edges:f};return this.lastResult=t,t}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0});const n={nodes:[Object.assign(Object.assign({},d[0]),{data:Object.assign(Object.assign({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:f};return this.lastResult=n,n}const p=d.map((t=>hb(t,[o,a]))),g=new Yg({nodes:p,edges:f}),v={};if(l&&p.forEach((t=>{const e=t.data[u];v[e]||(v[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=p,this.lastLayoutEdges=f,this.lastAssign=t,this.lastGraph=g,this.lastOptions=r,this.lastClusterMap=v,"undefined"==typeof window)return;let m=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,v,r),t&&p.forEach((({id:t,data:n})=>e.mergeNodeData(t,{x:n.x,y:n.y,z:3===i?n.z:void 0}))),null==h||h({nodes:p,edges:f}),m++,m>=c&&(window.clearInterval(this.timeInterval),n({nodes:p,edges:f}))):n({nodes:p,edges:f})}),0),this.running=!0}))}))}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:n,nodeClusterBy:r}=e,{center:i,width:o,height:a}=e;return e.width=o||"undefined"==typeof window?o:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!r,e}runOneStep(t,e,n){const{dimensions:r,height:i,width:o,gravity:a,center:s,speed:l,clustering:u,nodeClusterBy:c,clusterGravity:h}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),v=Math.sqrt(g),m={};if(this.applyCalculate(t,m,v,g),u){for(const t in e)e[t].cx=0,e[t].cy=0,e[t].count=0;p.forEach((t=>{const{data:n}=t,r=e[n[c]];ae(n.x)&&(r.cx+=n.x),ae(n.y)&&(r.cy+=n.y),r.count++}));for(const t in e)e[t].cx/=e[t].count,e[t].cy/=e[t].count;const t=h||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!ae(o.x)||!ae(o.y))return;const a=e[o[c]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),l=v*t;m[i].x-=l*(o.x-a.cx)/s,m[i].y-=l*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!ae(i.x)||!ae(i.y))return;const o=.01*v*a;m[n].x-=o*(i.x-s[0]),m[n].y-=o*(i.y-s[1]),3===r&&(m[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if(ae(o.fx)&&ae(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!ae(o.x)||!ae(o.y))return;const a=Math.sqrt(m[i].x*m[i].x+m[i].y*m[i].y+(3===r?m[i].z*m[i].z:0));if(a>0){const e=Math.min(f*(l/800),a);t.mergeNodeData(i,{x:o.x+m[i].x/a*e,y:o.y+m[i].y/a*e,z:3===r?o.z+m[i].z/a*e:void 0})}}))}applyCalculate(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)}calRepulsive(t,e,n){const r=t.getAllNodes();r.forEach((({data:t,id:i},o)=>{e[i]={x:0,y:0,z:0},r.forEach((({data:r,id:a},s)=>{if(o<=s||!ae(t.x)||!ae(r.x)||!ae(t.y)||!ae(r.y))return;let l=t.x-r.x,u=t.y-r.y,c=3===this.options.dimensions?t.z-r.z:0,h=l*l+u*u+c*c;0===h&&(h=1,l=.01,u=.01,c=.01);const d=n/h,f=l*d,p=u*d,g=c*d;e[i].x+=f,e[i].y+=p,e[a].x-=f,e[a].y-=p,3===this.options.dimensions&&(e[i].z+=g,e[a].z-=g)}))}))}calAttractive(t,e,n){t.getAllEdges().forEach((r=>{const{source:i,target:o}=r;if(!i||!o||i===o)return;const{data:a}=t.getNode(i),{data:s}=t.getNode(o);if(!(ae(s.x)&&ae(a.x)&&ae(s.y)&&ae(a.y)))return;const l=s.x-a.x,u=s.y-a.y,c=3===this.options.dimensions?s.z-a.z:0,h=Math.sqrt(l*l+u*u+c*c)/n,d=l*h,f=u*h,p=c*h;e[i].x+=d,e[i].y+=f,e[o].x-=d,e[o].y-=f,3===this.options.dimensions&&(e[i].z+=p,e[o].z-=p)}))}}const nj={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300};class rj{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},nj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{begin:i=[0,0],condense:o,preventOverlapPadding:a,preventOverlap:s,rows:l,cols:u,nodeSpacing:c,nodeSize:h,width:d,height:f,position:p}=r;let{sortBy:g}=r;const v=e.getAllNodes(),m=e.getAllEdges(),y=null==v?void 0:v.length;if(!y||1===y)return bb(e,t,i);const b=v.map((t=>hb(t)));"id"===g||ne(g)&&void 0!==b[0].data[g]||(g="degree"),"degree"===g?b.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):"id"===g?b.sort(((t,e)=>ae(e.id)&&ae(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const x=d||"undefined"==typeof window?d:window.innerWidth,E=f||"undefined"==typeof window?f:window.innerHeight,w=y,k={rows:l,cols:u};if(null!=l&&null!=u)k.rows=l,k.cols=u;else if(null!=l&&null==u)k.rows=l,k.cols=Math.ceil(w/k.rows);else if(null==l&&null!=u)k.cols=u,k.rows=Math.ceil(w/k.cols);else{const t=Math.sqrt(w*E/x);k.rows=Math.round(t),k.cols=Math.round(x/E*t)}if(k.rows=Math.max(k.rows,1),k.cols=Math.max(k.cols,1),k.cols*k.rows>w){const t=ij(k),e=oj(k);(t-1)*e>=w?ij(k,t-1):(e-1)*t>=w&&oj(k,e-1)}else for(;k.cols*k.rows<w;){const t=ij(k),e=oj(k);(e+1)*t>=w?oj(k,e+1):ij(k,t+1)}let M=o?0:x/k.cols,S=o?0:E/k.rows;if(s||c){const t=fb(10,c),n=pb(30,h,!1);b.forEach((r=>{r.data.x&&r.data.y||(r.data.x=0,r.data.y=0);const i=e.getNode(r.id),[o,s]=db(n(i)||30),l=void 0!==t?t(r):a,u=o+l,c=s+l;M=Math.max(M,u),S=Math.max(S,c)}))}const N={},O={row:0,col:0},T={};for(let t=0;t<b.length;t++){const n=b[t];let r;if(p&&(r=p(e.getNode(n.id))),r&&(void 0!==r.row||void 0!==r.col)){const t={row:r.row,col:r.col};if(void 0===t.col)for(t.col=0;aj(N,t);)t.col++;else if(void 0===t.row)for(t.row=0;aj(N,t);)t.row++;T[n.id]=t,sj(N,t)}uj(n,i,M,S,T,k,O,N)}const C={nodes:b,edges:m};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),C}))}}const ij=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.min(r,i);else{Math.min(r,i)===t.rows?t.rows=e:t.cols=e}return n},oj=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.max(r,i);else{Math.max(r,i)===t.rows?t.rows=e:t.cols=e}return n},aj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,sj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,lj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},uj=(t,e,n,r,i,o,a,s)=>{let l,u;const c=i[t.id];if(c)l=c.col*n+n/2+e[0],u=c.row*r+r/2+e[1];else{for(;aj(s,a);)lj(o,a);l=a.col*n+n/2+e[0],u=a.row*r+r/2+e[1],sj(s,a),lj(o,a)}t.data.x=l,t.data.y=u},cj={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},hj=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,l)=>{if(s===l)return;if(i[s]!==i[l])return;let u=a.x-e.x,c=a.y-e.y,h=Math.sqrt(u*u+c*c);if(0===h){h=1;const t=s>l?1:-1;u=.01*t,c=.01*t}if(h<o(t[s])/2+o(t[l])/2){const t=r*r/h;n[s].x+=u/h*t,n[s].y+=c/h*t}}))}))},dj=(t,e,n,r,i,o,a,s)=>{const l=o||a/10;return r&&e.forEach(((e,n)=>{const r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o);let s=o/a,l=-r/a;const u=Math.sqrt(e.x*e.x+e.y*e.y);let c=Math.acos((s*e.x+l*e.y)/u);c>Math.PI/2&&(c-=Math.PI/2,s*=-1,l*=-1);const h=Math.cos(c)*u;e.x=s*h,e.y=l*h})),t.forEach(((o,a)=>{if(a===i)return;const u=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(u>0&&a!==i){const c=Math.min(l*(n/800),u);if(o.x+=e[a].x/u*c,o.y+=e[a].y/u*c,r){let e=o.x-t[i].x,n=o.y-t[i].y;const r=Math.sqrt(e*e+n*n);e=e/r*s[a],n=n/r*s[a],o.x=t[i].x+e,o.y=t[i].y+n}}})),t},fj={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class pj{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},fj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:l,nodeSize:u,nodeSpacing:c,strictRadial:h,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:v=10,maxIteration:m=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,E=o||"undefined"==typeof window?o:window.innerHeight,w=a||[x/2,E/2];if(!(null==y?void 0:y.length)||1===y.length)return bb(e,t,w);let k=y[0];if(ne(s)){for(let t=0;t<y.length;t++)if(y[t].id===s){k=y[t];break}}else k=s||y[0];const M=mj(y,k.id),S=sb({nodes:y,edges:b}),N=ab(S),O=bj(N,M);yj(N,M,O+1);const T=N[M];let C=x-w[0]>w[0]?w[0]:x-w[0],A=E-w[1]>w[1]?w[1]:E-w[1];0===C&&(C=x/2),0===A&&(A=E/2);const P=Math.min(C,A),R=Math.max(...T),D=[],L=l||P/R;T.forEach(((t,e)=>{D[e]=t*L}));const _=gj(y,N,g,D,L,p,v),I=vj(_),j=((t,e,n)=>{try{const n=$x.mul($x.pow(e,2),-.5),r=n.mean("row"),i=n.mean("column"),o=n.mean();n.add(o).subRowVector(r).subColumnVector(i);const a=new Yx(n),s=$x.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>$x.mul([e],[s]).toJSON()[0].splice(0,t)))}catch(t){const r=[];for(let t=0;t<e.length;t++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}})(g,_,g);let B,F=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[M][0],y:(isNaN(e)?Math.random()*g:e)-j[M][1]})));if(this.run(m,F,I,_,D,M),d){B=gb(u,c);const t={nodes:y,nodeSizeFunc:B,positions:F,radii:D,height:E,width:x,strictRadial:Boolean(h),focusIdx:M,iterations:f||200,k:F.length/4.5};F=((t,e)=>{const n=Object.assign(Object.assign({},cj),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:l,focusIdx:u,radii:c=[],nodeSizeFunc:h}=n,d=t.getAllNodes(),f=[],p=o/10;for(let t=0;t<i;t++)r.forEach(((t,e)=>{f[e]={x:0,y:0}})),hj(d,r,f,a,c,h),dj(r,f,s,l,u,p,o,c);return r})(e,t)}const z=[];F.forEach(((t,e)=>{const n=hb(y[e]);n.data.x=t.x+w[0],n.data.y=t.y+w[1],z.push(n)})),t&&z.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:z,edges:b}}))}run(t,e,n,r,i,o){for(let a=0;a<=t;a++){const s=a/t;this.oneIteration(s,e,i,r,n,o)}}oneIteration(t,e,n,r,i,o){const a=1-t;e.forEach(((s,l)=>{const u=lb(s,{x:0,y:0}),c=0===u?0:1/u;if(l===o)return;let h=0,d=0,f=0;e.forEach(((t,e)=>{if(l===e)return;const n=lb(s,t),o=0===n?0:1/n,a=r[e][l];f+=i[l][e],h+=i[l][e]*(t.x+a*(s.x-t.x)*o),d+=i[l][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[l]?0:1/n[l];f*=a,f+=t*p*p,h*=a,h+=t*p*s.x*c,s.x=h/f,d*=a,d+=t*p*s.y*c,s.y=d/f}))}}const gj=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];if(e){const l={};e.forEach(((e,u)=>{const c=[];e.forEach(((e,s)=>{var h,d;if(u===s)c.push(0);else if(r[u]===r[s])if("data"===o)c.push(e*(Math.abs(u-s)*a)/(r[u]/i));else if(o){let n,f;if(l[t[u].id])n=l[t[u].id];else{const e=("id"===o?t[u].id:null===(h=t[u].data)||void 0===h?void 0:h[o])||0;n=ne(e)?e.charCodeAt(0):e,l[t[u].id]=n}if(l[t[s].id])f=l[t[s].id];else{const e=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=ne(e)?e.charCodeAt(0):e,l[t[s].id]=f}c.push(e*(Math.abs(n-f)*a)/(r[u]/i))}else c.push(e*n/(r[u]/i));else{const t=(n+i)/2;c.push(e*t)}})),s.push(c)}))}return s},vj=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},mj=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},yj=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},bj=(t,e)=>{let n=0;for(let r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},xj={center:[0,0],width:300,height:300};class Ej{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},xj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a}=r,s=e.getAllNodes(),l=o||"undefined"==typeof window?o:window.innerWidth,u=a||"undefined"==typeof window?a:window.innerHeight,c=i||[l/2,u/2],h=[];s&&s.forEach((t=>{h.push({id:t.id,data:{x:.9*(Math.random()-.5)*l+c[0],y:.9*(Math.random()-.5)*u+c[1]}})})),t&&h.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:h,edges:e.getAllEdges()}}))}}
|
|
74
|
+
*/class Np extends nf{constructor(t){super(Object.assign(Object.assign({},t),{style:Object.assign({},Np.defaultStyleProps,t.style)})),this.rootPointerEvent=new As(null),this.forwardEvents=t=>{const e=this.context.canvas,n=e.context.renderingContext.root.ownerDocument.defaultView;this.normalizeToPointerEvent(t,n).forEach((r=>{const i=this.bootstrapEvent(this.rootPointerEvent,r,n,t);Te(e.context.eventService,"mappingTable.pointerupoutside",[]),e.context.eventService.mapEvent(i)}))}}get eventService(){return this.context.canvas.context.eventService}get events(){return[t.CommonEvent.CLICK,t.CommonEvent.POINTER_DOWN,t.CommonEvent.POINTER_MOVE,t.CommonEvent.POINTER_UP,t.CommonEvent.POINTER_OVER,t.CommonEvent.POINTER_LEAVE]}getDomElement(){return this.getShape("key").getDomElement()}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.drawPortShapes(t,e)}getKeyStyle(t){const e=Ae(t,["dx","dy","innerHTML","pointerEvents","cursor"]),{dx:n=0,dy:r=0}=e,i=Fe(e,["dx","dy"]),[o,a]=this.getSize(t);return Object.assign(Object.assign({x:n,y:r},i),{width:o,height:a})}drawKeyShape(t,e){const n=this.getKeyStyle(t),{x:r,y:i,width:o=0,height:a=0}=n,s=this.upsert("key-container",Xl,{x:r,y:i,width:o,height:a,opacity:0},e);return this.upsert("key",Fl,n,s)}connectedCallback(){if(!(this.context.canvas.getRenderer("main")instanceof Sp))return;const t=this.getDomElement();this.events.forEach((e=>{t.addEventListener(e,this.forwardEvents)}))}attributeChangedCallback(t,e,n){"zIndex"===t&&e!==n&&(this.getDomElement().style.zIndex=n)}destroy(){const t=this.getDomElement();this.events.forEach((e=>{t.removeEventListener(e,this.forwardEvents)})),super.destroy()}normalizeToPointerEvent(t,e){const n=[];if(e.isTouchEvent(t))for(let e=0;e<t.changedTouches.length;e++){const r=t.changedTouches[e];ve(r.button)&&(r.button=0),ve(r.buttons)&&(r.buttons=1),ve(r.isPrimary)&&(r.isPrimary=1===t.touches.length&&"touchstart"===t.type),ve(r.width)&&(r.width=r.radiusX||1),ve(r.height)&&(r.height=r.radiusY||1),ve(r.tiltX)&&(r.tiltX=0),ve(r.tiltY)&&(r.tiltY=0),ve(r.pointerType)&&(r.pointerType="touch"),ve(r.pointerId)&&(r.pointerId=r.identifier||0),ve(r.pressure)&&(r.pressure=r.force||.5),ve(r.twist)&&(r.twist=0),ve(r.tangentialPressure)&&(r.tangentialPressure=0),r.isNormalized=!0,r.type=t.type,n.push(r)}else if(e.isMouseEvent(t)){const e=t;ve(e.isPrimary)&&(e.isPrimary=!0),ve(e.width)&&(e.width=1),ve(e.height)&&(e.height=1),ve(e.tiltX)&&(e.tiltX=0),ve(e.tiltY)&&(e.tiltY=0),ve(e.pointerType)&&(e.pointerType="mouse"),ve(e.pointerId)&&(e.pointerId=1),ve(e.pressure)&&(e.pressure=.5),ve(e.twist)&&(e.twist=0),ve(e.tangentialPressure)&&(e.tangentialPressure=0),e.isNormalized=!0,n.push(e)}else n.push(t);return n}transferMouseData(t,e){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.altKey=e.altKey,t.metaKey=e.metaKey,t.shiftKey=e.shiftKey,t.ctrlKey=e.ctrlKey,t.button=e.button,t.buttons=e.buttons,t.client.x=e.clientX,t.client.y=e.clientY,t.movement.x=e.movementX,t.movement.y=e.movementY,t.page.x=e.pageX,t.page.y=e.pageY,t.screen.x=e.screenX,t.screen.y=e.screenY,t.relatedTarget=null}bootstrapEvent(t,e,n,r){t.view=n,t.originalEvent=null,t.nativeEvent=r,t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,this.transferMouseData(t,e);const{x:i,y:o}=this.getViewportXY(e);t.viewport.x=i,t.viewport.y=o;const[a,s]=this.context.canvas.getCanvasByViewport([i,o]);return t.canvas.x=a,t.canvas.y=s,t.global.copyFrom(t.canvas),t.offset.copyFrom(t.canvas),t.isTrusted=r.isTrusted,"pointerleave"===t.type&&(t.type="pointerout"),t}getViewportXY(t){let e,n;const{offsetX:r,offsetY:i,clientX:o,clientY:a}=t;if($t(r)||$t(i)){const t=this.eventService.client2Viewport({x:o,y:a});e=t.x,n=t.y}else e=r,n=i;return{x:e,y:n}}onframe(){super.onframe();const{opacity:t}=this.attributes;this.getDomElement().style.opacity=`${t}`}}Np.defaultStyleProps={size:[160,80],halo:!1,icon:!1,label:!1,pointerEvents:"auto"};let Op=class t extends nf{constructor(e){super(_d({style:t.defaultStyleProps},e))}getKeyStyle(t){const[e,n]=this.getSize(t),r=super.getKeyStyle(t),{fillOpacity:i,opacity:o=i}=r,a=Fe(r,["fillOpacity","opacity"]);return Object.assign(Object.assign({opacity:o},a),{width:e,height:n,x:-e/2,y:-n/2})}getBounds(){return this.getShape("key").getBounds()}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getShape("key").attributes,{fill:n,stroke:r}=e;Fe(e,["fill","stroke"]);const i=Ad(this.getGraphicStyle(t),"halo"),o=Number(i.lineWidth),[a,s]=Ih(this.getSize(t),[o,o]),{lineWidth:l}=i,u={fill:"transparent",lineWidth:l/2,width:a-l/2,height:s-l/2,x:-(a-l/2)/2,y:-(s-l/2)/2};return Object.assign(Object.assign({},i),u)}getIconStyle(t){const e=super.getIconStyle(t),[n,r]=this.getSize(t);return!!e&&Object.assign({width:n*xd,height:r*xd},e)}drawKeyShape(t,e){const n=this.upsert("key",Xd,this.getKeyStyle(t),e);return Qd(this),n}drawHaloShape(t,e){this.upsert("halo",Xl,this.getHaloStyle(t),e)}update(t){super.update(t),t&&("x"in t||"y"in t||"z"in t)&&Jd(this)}};Op.defaultStyleProps={size:32};class Tp extends nf{constructor(t){super(t)}getKeyStyle(t){const[e,n]=this.getSize(t);return Object.assign(Object.assign({},super.getKeyStyle(t)),{width:e,height:n,x:-e/2,y:-n/2})}getIconStyle(t){const e=super.getIconStyle(t),{width:n,height:r}=this.getShape("key").attributes;return!!e&&Object.assign({width:n*xd,height:r*xd},e)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}}class Cp extends of{constructor(t){super(t)}getInnerR(t){return t.innerR||3*this.getOuterR(t)/8}getOuterR(t){return Math.min(...this.getSize(t))/2}getPoints(t){return e=this.getOuterR(t),n=this.getInnerR(t),[[0,-e],[n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)],[e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[0,n],[-e*Math.cos(3*Math.PI/10),e*Math.sin(3*Math.PI/10)],[-n*Math.cos(Math.PI/10),n*Math.sin(Math.PI/10)],[-e*Math.cos(Math.PI/10),-e*Math.sin(Math.PI/10)],[-n*Math.cos(3*Math.PI/10),-n*Math.sin(3*Math.PI/10)]];var e,n}getIconStyle(t){const e=super.getIconStyle(t),n=2*this.getInnerR(t)*xd;return!!e&&Object.assign({width:n,height:n},e)}getPortXY(t,e){const{placement:n="top"}=e;return Ng(this.getShape("key").getLocalBounds(),n,function(t,e){const n={};return n.top=[0,-t],n.left=[-t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n["left-bottom"]=[-t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.bottom=[0,e],n["right-bottom"]=[t*Math.cos(3*Math.PI/10),t*Math.sin(3*Math.PI/10)],n.right=n.default=[t*Math.cos(Math.PI/10),-t*Math.sin(Math.PI/10)],n}(this.getOuterR(t),this.getInnerR(t)),!1)}}class Ap extends of{constructor(t){super(_d({style:Ap.defaultStyleProps},t))}getPoints(t){const{direction:e}=t,[n,r]=this.getSize(t);return function(t,e,n){const r=e/2,i=t/2,o={up:[[-i,r],[i,r],[0,-r]],left:[[-i,0],[i,r],[i,-r]],right:[[-i,r],[-i,-r],[i,0]],down:[[-i,-r],[i,-r],[0,r]]};return o[n]||o.up}(n,r,e)}getPortXY(t,e){const{direction:n}=t,{placement:r="top"}=e,i=this.getShape("key").getLocalBounds(),[o,a]=this.getSize(t),s=function(t,e,n){const r=e/2,i=t/2,o={};"down"===n?(o.bottom=o.default=[0,r],o.right=[i,-r],o.left=[-i,-r]):"left"===n?(o.top=[i,-r],o.bottom=[i,r],o.left=o.default=[-i,0]):"right"===n?(o.top=[-i,-r],o.bottom=[-i,r],o.right=o.default=[i,0]):(o.left=[-i,r],o.top=o.default=[0,-r],o.right=[i,r]);return o}(o,a,n);return Ng(i,r,s,!1)}getIconStyle(t){const{icon:e,iconText:n,iconSrc:r,direction:i}=t;if(!1===e||Se(n||r))return!1;const o=Ad(this.getGraphicStyle(t),"icon"),a=this.getShape("key").getLocalBounds(),[s,l]=function(t,e){const{center:n}=t,[r,i]=Xc(t);return["up"===e||"down"===e?n[0]:"right"===e?n[0]-r/6:n[0]+r/6,"left"===e||"right"===e?n[1]:"down"===e?n[1]-i/6:n[1]+i/6]}(a,i),u=2*function(t,e){let[n,r]=Xc(t);return[n,r]="up"===e||"down"===e?[n,r]:[r,n],(Math.pow(r,2)-Math.pow(Math.sqrt(Math.pow(n/2,2)+Math.pow(r,2))-n/2,2))/(2*r)}(a,i)*xd;return Object.assign({x:s,y:l,width:u,height:u},o)}}Ap.defaultStyleProps={size:40,direction:"up"};class Pp extends nf{constructor(t){super(_d({style:Pp.defaultStyleProps},t)),this.type="combo",this.updateComboPosition(this.parsedAttributes)}getKeySize(t){const{collapsed:e,childrenNode:n=[]}=t;return 0===n.length?this.getEmptyKeySize(t):e?this.getCollapsedKeySize(t):this.getExpandedKeySize(t)}getEmptyKeySize(t){const{padding:e,collapsedSize:n}=t,[r,i,o,a]=Uc(e);return Ih(Dd(n),[a+i,r+o,0])}getCollapsedKeySize(t){return Dd(t.collapsedSize)}getExpandedKeySize(t){const e=this.getContentBBox(t);return[Yc(e),qc(e),0]}getContentBBox(t){const{childrenNode:e=[],padding:n}=t,r=e.map((t=>this.context.element.getElement(t))).filter(Boolean);if(0===r.length){const e=new fr,{x:n=0,y:r=0,size:i}=t,[o,a]=Dd(i);return e.setMinMax([n-o/2,r-a/2,0],[n+o/2,r+a/2,0]),e}const i=Jc(r.map((t=>t.getBounds())));return n?Qc(i,n):i}drawCollapsedMarkerShape(t,e){const n=this.getCollapsedMarkerStyle(t);this.upsert("collapsed-marker",tf,n,e),Qd(this)}getCollapsedMarkerStyle(t){if(!t.collapsed||!t.collapsedMarker)return!1;const e=Ad(this.getGraphicStyle(t),"collapsedMarker"),{type:n}=e,r=Fe(e,["type"]),i=this.getShape("key"),[o,a]=ed(i.getLocalBounds(),"center"),s=Object.assign(Object.assign({},r),{x:o,y:a});if(n){const e=this.getCollapsedMarkerText(n,t);Object.assign(s,{text:e})}return s}getCollapsedMarkerText(t,e){const{childrenData:n=[]}=e,{model:r}=this.context;return"descendant-count"===t?r.getDescendantsData(this.id).length.toString():"child-count"===t?n.length.toString():"node-count"===t?r.getDescendantsData(this.id).filter((t=>"node"===r.getElementType(yh(t)))).length.toString():Ut(t)?t(n):""}getComboPosition(t){const{x:e=0,y:n=0,collapsed:r,childrenData:i=[]}=t;if(0===i.length)return[+e,+n,0];if(r){const{model:t}=this.context,r=t.getDescendantsData(this.id).filter((e=>!t.isCombo(yh(e))));if(r.length>0&&r.some(td)){return Fh(r.reduce(((t,e)=>Ih(t,Jh(e))),[0,0,0]),r.length)}return[+e,+n,0]}return this.getContentBBox(t).center}getComboStyle(t){const[e,n]=this.getComboPosition(t);return{x:e,y:n,transform:[["translate",e,n]]}}updateComboPosition(t){const e=this.getComboStyle(t);Object.assign(this.style,e);const{x:n,y:r}=e;this.context.model.syncNodeLikeDatum({id:this.id,style:{x:n,y:r}}),Jd(this)}render(t,e=this){super.render(t,e),this.drawCollapsedMarkerShape(t,e)}update(t={}){super.update(t),this.updateComboPosition(this.parsedAttributes)}onframe(){super.onframe(),this.attributes.collapsed||this.updateComboPosition(this.parsedAttributes),this.drawKeyShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(this.attributes.collapsed?t:t.map((t=>{var{x:e,y:n,z:r,transform:i}=t;return Fe(t,["x","y","z","transform"])})),e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then((()=>this.onframe())),Reflect.set(t,e,n))}):n}}Pp.defaultStyleProps={childrenNode:[],droppable:!0,draggable:!0,collapsed:!1,collapsedSize:32,collapsedMarker:!0,collapsedMarkerZIndex:1,collapsedMarkerFontSize:12,collapsedMarkerTextAlign:"center",collapsedMarkerTextBaseline:"middle",collapsedMarkerType:"child-count"};class Rp extends Pp{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Dl,this.getKeyStyle(t),e)}getKeyStyle(t){const{collapsed:e}=t,n=super.getKeyStyle(t),[r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},n),e&&Ad(n,"collapsed")),{r:r/2})}getCollapsedKeySize(t){const[e,n]=Dd(t.collapsedSize),r=Math.max(e,n)/2;return[2*r,2*r,0]}getExpandedKeySize(t){const e=this.getContentBBox(t),[n,r]=Xc(e),i=Math.sqrt(Math.pow(n,2)+Math.pow(r,2))/2;return[2*i,2*i,0]}getIntersectPoint(t,e=!1){return cd(t,this.getShape("key").getBounds(),e)}}class Dp extends Pp{constructor(t){super(t)}drawKeyShape(t,e){return this.upsert("key",Xl,this.getKeyStyle(t),e)}getKeyStyle(t){const e=super.getKeyStyle(t),[n,r]=this.getKeySize(t);return Object.assign(Object.assign(Object.assign({},e),t.collapsed&&Ad(e,"collapsed")),{width:n,height:r,x:-n/2,y:-r/2})}}const Lp={padding:10};function _p(t,e,n,r,i,o){const{padding:a}=Object.assign(Lp,o),s=Kc(n,a),l=Kc(r,a),u=[t,...i,e];let c=null;const h=[];for(let t=0,e=u.length;t<e-1;t++){const n=t+1,r=u[t],i=u[n],o=ad(d=r,f=i)||function(t,e){return t[0]===e[0]}(d,f);let p=null;if(0===t)if(n===e-1)if(s.intersects(l))p=Hp(r,i,s,l);else if(nh(r,s)||nh(i,l))o||(p=Wp(r,i,s,l));else{const t=ih(r,s),e=ih(i,l);p=zp(t,e,Bp(t,e)),p.points.unshift(t),p.points.push(e)}else th(i,s)?p=Hp(r,i,s,Kc(i,a),c):o||(p=Gp(r,i,s));else n===e-1?th(r,l)?p=Hp(r,i,Kc(r,a),l,c):o||(p=Vp(r,i,l,c)):o||(p=zp(r,i,c));p?(h.push(...p.points),c=p.direction):c=Bp(r,i),n<e-1&&h.push(i)}var d,f;return h.map(Yh)}const Ip={N:"S",S:"N",W:"E",E:"W"},jp={N:-Math.PI/2,S:Math.PI/2,E:0,W:Math.PI};function Bp(t,e){const[n,r]=t,[i,o]=e;return n===i?r>o?"N":"S":r===o?n>i?"W":"E":null}function Fp(t,e){return"N"===e||"S"===e?qc(t):Yc(t)}function zp(t,e,n){const r=[t[0],e[1]],i=[e[0],t[1]],o=Bp(t,r),a=Bp(t,i),s=n?Ip[n]:null,l=o===n||o!==s&&a!==n?r:i;return{points:[l],direction:Bp(l,e)}}function Gp(t,e,n){if(nh(t,n)){const r=Up(t,e,n);return{points:[r],direction:Bp(r,e)}}{const r=ih(t,n),i=["left","right"].includes(rh(t,n))?[e[0],r[1]]:[r[0],e[1]];return{points:[i],direction:Bp(i,e)}}}function Vp(t,e,n,r){const i=nh(e,n)?e:ih(e,n),o=[[i[0],t[1]],[t[0],i[1]]],a=o.filter((t=>function(t,e){return!th(t,e)}(t,n)&&!eh(t,n,!0))),s=a.filter((e=>Bp(e,t)!==r));if(s.length>0){const n=s.find((e=>Bp(t,e)===r))||s[0];return{points:[n],direction:Bp(n,e)}}{const i=od(e,Ht(o,a)[0],Fp(n,r)/2);return{points:[Up(i,t,n),i],direction:Bp(i,e)}}}function Wp(t,e,n,r){let i=Gp(t,e,n);const o=qh(i.points[0]);if(th(o,r)){i=Gp(e,t,r);const a=qh(i.points[0]);if(th(a,n)){const s=od(t,o,Fp(n,Bp(t,o))/2),l=od(e,a,Fp(r,Bp(e,a))/2),u=[(s[0]+l[0])/2,(s[1]+l[1])/2],c=Gp(t,u,n),h=Vp(u,e,r,c.direction);i.points=[c.points[0],h.points[0]],i.direction=h.direction}}return i}function Hp(t,e,n,r,i){const o=Jc([n,r]),a=Gh(e,o.center)>Gh(t,o.center),[s,l]=a?[e,t]:[t,e],u=qc(o)+Yc(o);let c;if(i){const t=[s[0]+u*Math.cos(jp[i]),s[1]+u*Math.sin(jp[i])];c=od(ih(t,o),t,.01)}else c=od(ih(s,o),s,-.01);let h=Up(c,l,o),d=[id(c,2),id(h,2)];if(Ne(id(c),id(h))){const t=Hh(jh(c,s),[1,0,0])+Math.PI/2;h=[l[0]+u*Math.cos(t),l[1]+u*Math.sin(t),0],h=id(od(ih(h,o),l,-.01),2);d=[c,Up(c,h,o),h]}return{points:a?d.reverse():d,direction:Bp(a?c:h,e)}}function Up(t,e,n){let r=[t[0],e[1]];return th(r,n)&&(r=[e[0],t[1]]),r}function $p(t,e,n,r,i){let o="number"==typeof e?e:.5;"start"===e&&(o=0),"end"===e&&(o=.99);const a=nd(t.getPoint(o)),s=nd(t.getPoint(o+.01));let l="start"===e?"left":"end"===e?"right":"center";if(ad(a,s)||!n){const[e,n]=Yp(t,o,r,i);return{transform:[["translate",e,n]],textAlign:l}}let u=Math.atan2(s[1]-a[1],s[0]-a[0]);s[0]<a[0]&&(l="center"===l?l:"left"===l?"right":"left",r*=-1,u+=Math.PI);const[c,h]=Yp(t,o,r,i,u);return{textAlign:l,transform:[["translate",c,h],["rotate",u/Math.PI*180]]}}function Yp(t,e,n,r,i){const[o,a]=nd(t.getPoint(e));let s=n,l=r;return i&&(s=n*Math.cos(i)-r*Math.sin(i),l=n*Math.sin(i)+r*Math.cos(i)),[o+s,a+l]}function qp(t,e,n,r){if(Ne(t,e))return t;const i=jh(e,t),o=[t[0]+n*i[0],t[1]+n*i[1]],a=Wh(Uh(i,!1));return o[0]+=r*a[0],o[1]+=r*a[1],o}function Xp(t,e,n){return[["M",t[0],t[1]],["C",n[0][0],n[0][1],n[1][0],n[1][1],e[0],e[1]]]}function Kp(t,e=0,n=!1){const r=t.length-1,i=t[0],o=t[r],a=t.slice(1,r),s=[["M",i[0],i[1]]];return a.forEach(((t,n)=>{const r=a[n-1]||i,l=a[n+1]||o;if(!sd(r,t,l)&&e){const[n,i]=function(t,e,n,r){const i=Vh(t,e),o=Vh(n,e),a=Math.min(r,Math.min(i,o)/2),s=[e[0]-a/i*(e[0]-t[0]),e[1]-a/i*(e[1]-t[1])],l=[e[0]-a/o*(e[0]-n[0]),e[1]-a/o*(e[1]-n[1])];return[s,l]}(r,t,l,e);s.push(["L",n[0],n[1]],["Q",t[0],t[1],i[0],i[1]],["L",i[0],i[1]])}else s.push(["L",t[0],t[1]])})),s.push(["L",o[0],o[1]]),n&&s.push(["Z"]),s}function Zp(t,e,n,r,i){const o=Kc(t),a=t.getCenter();let s=r&&Cg(r),l=i&&Cg(i);if(!s||!l){const r=(t=>{const e=Math.PI/2,n=qc(t)/2,r=Yc(t)/2,i=Math.atan2(n,r)/2,o=Math.atan2(r,n)/2;return{top:[-e-o,-e+o],"top-right":[-e+o,-i],"right-top":[-e+o,-i],right:[-i,i],"bottom-right":[i,e-o],"right-bottom":[i,e-o],bottom:[e-o,e+o],"bottom-left":[e+o,Math.PI-i],"left-bottom":[e+o,Math.PI-i],left:[Math.PI-i,Math.PI+i],"top-left":[Math.PI+i,-e-o],"left-top":[Math.PI+i,-e-o]}})(o),i=r[e][0],u=r[e][1],[c,h]=Xc(o),d=Math.max(c,h),f=Ih(a,[d*Math.cos(i),d*Math.sin(i),0]),p=Ih(a,[d*Math.cos(u),d*Math.sin(u),0]);s=Dg(t,f),l=Dg(t,p),n||([s,l]=[l,s])}return[s,l]}function Qp(t,e,n,r,i,o){const a=t.getPorts()[i||o],s=t.getPorts()[o||i];let[l,u]=Zp(t,e,n,a,s);const c=function(t,e,n,r){const i=t.getCenter();if(Ne(e,n)){const t=jh(e,i),o=[r*Math.sign(t[0])||r/2,r*Math.sign(t[1])||-r/2,0];return[Ih(e,o),Ih(n,Bh(o,[1,-1,1]))]}return[od(i,e,Gh(i,e)+r),od(i,n,Gh(i,n)+r)]}(t,l,u,r);return a&&(l=Rg(a,c[0])),s&&(u=Rg(s,c.at(-1))),Xp(l,u,c)}function Jp(t,e,n,r,i,o,a){const s=Og(t),l=s[o||a],u=s[a||o];let[c,h]=Zp(t,n,r,l,u);const d=function(t,e,n,r){const i=[],o=Kc(t);if(Ne(e,n)){switch(rh(e,o)){case"left":i.push([e[0]-r,e[1]]),i.push([e[0]-r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"right":i.push([e[0]+r,e[1]]),i.push([e[0]+r,e[1]+r]),i.push([e[0],e[1]+r]);break;case"top":i.push([e[0],e[1]-r]),i.push([e[0]+r,e[1]-r]),i.push([e[0]+r,e[1]]);break;case"bottom":i.push([e[0],e[1]+r]),i.push([e[0]+r,e[1]+r]),i.push([e[0]+r,e[1]])}}else{const t=rh(e,o),a=rh(n,o);if(t===a){let o,a;switch(t){case"left":o=Math.min(e[0],n[0])-r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"right":o=Math.max(e[0],n[0])+r,i.push([o,e[1]]),i.push([o,n[1]]);break;case"top":a=Math.min(e[1],n[1])-r,i.push([e[0],a]),i.push([n[0],a]);break;case"bottom":a=Math.max(e[1],n[1])+r,i.push([e[0],a]),i.push([n[0],a])}}else{const s=(t,e)=>({left:[e[0]-r,e[1]],right:[e[0]+r,e[1]],top:[e[0],e[1]-r],bottom:[e[0],e[1]+r]}[t]),l=s(t,e),u=s(a,n),c=Up(l,u,o);i.push(l,c,u)}}return i}(t,c,h,i);return l&&(c=Rg(l,d[0])),u&&(h=Rg(u,d.at(-1))),Kp([c,...d,h],e)}function tg(t,e){const n=new Set,r=new Set,i=new Set;return t.forEach((o=>{e(o).forEach((e=>{n.add(e),t.includes(e.source)&&t.includes(e.target)?r.add(e):i.add(e)}))})),{edges:Array.from(n),internal:Array.from(r),external:Array.from(i)}}function eg(t,e){const n=[];let r=t;for(;r;){n.push(r);const t=e(yh(r));if(!t)break;r=t}if(n.some((t=>{var e;return null===(e=t.style)||void 0===e?void 0:e.collapsed}))){const t=n.reverse().findIndex(Od);return n[t]||n.at(-1)}return t}const ng=(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",t/2,e/2],["Z"]];var rg=Object.freeze({__proto__:null,circle:(t,e)=>{const n=Math.max(t,e)/2;return[["M",-t/2,0],["A",n,n,0,1,0,2*n-t/2,0],["A",n,n,0,1,0,-t/2,0],["Z"]]},diamond:(t,e)=>[["M",-t/2,0],["L",0,-e/2],["L",t/2,0],["L",0,e/2],["Z"]],rect:(t,e)=>[["M",-t/2,-e/2],["L",t/2,-e/2],["L",t/2,e/2],["L",-t/2,e/2],["Z"]],simple:(t,e)=>[["M",t/2,-e/2],["L",-t/2,0],["L",t/2,0],["L",-t/2,0],["L",t/2,e/2]],triangle:ng,triangleRect:(t,e)=>{const n=t/2,r=t/7,i=t-r;return[["M",-n,0],["L",0,-e/2],["L",0,e/2],["Z"],["M",i-n,-e/2],["L",i+r-n,-e/2],["L",i+r-n,e/2],["L",i-n,e/2],["Z"]]},vee:(t,e)=>[["M",-t/2,0],["L",t/2,-e/2],["L",4*t/5-t/2,0],["L",t/2,e/2],["Z"]]});class ig extends ef{constructor(t){super(_d({style:ig.defaultStyleProps},t)),this.type="edge"}get sourceNode(){const{sourceNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}get targetNode(){const{targetNode:t}=this.parsedAttributes;return this.context.element.getElement(t)}getKeyStyle(t){const e=this.getGraphicStyle(t),{loop:n}=e,r=Fe(e,["loop"]),{sourceNode:i,targetNode:o}=this;var a,s;const l={d:n&&(s=o,(a=i)&&s&&a===s)?this.getLoopPath(t):this.getKeyPath(t)};return Hl.PARSED_STYLE_LIST.forEach((t=>{t in r&&(l[t]=r[t])})),l}getLoopPath(t){const{sourcePort:e,targetPort:n}=t,r=this.sourceNode,i=Kc(r),o=Math.max(Yc(i),qc(i)),{placement:a,clockwise:s,dist:l=o}=Ad(this.getGraphicStyle(t),"loop");return Qp(r,a,s,l,e,n)}getEndpoints(t,e=!0,n=[]){const{sourcePort:r,targetPort:i}=t,{sourceNode:o,targetNode:a}=this,[s,l]=function(t,e,n,r){const i=Ag(t,e,n,r),o=Ag(e,t,r,n);return[i,o]}(o,a,r,i);if(!e){return[s?Cg(s):o.getCenter(),l?Cg(l):a.getCenter()]}const u="function"==typeof n?n():n;return[Pg(s||o,u[0]||l||a),Pg(l||a,u[u.length-1]||s||o)]}getHaloStyle(t){if(!1===t.halo)return!1;const e=this.getKeyStyle(t),n=Ad(this.getGraphicStyle(t),"halo");return Object.assign(Object.assign({},e),n)}getLabelStyle(t){if(!1===t.label||!t.labelText)return!1;const e=Ad(this.getGraphicStyle(t),"label"),{placement:n,offsetX:r,offsetY:i,autoRotate:o,maxWidth:a}=e,s=Fe(e,["placement","offsetX","offsetY","autoRotate","maxWidth"]),l=$p(this.shapeMap.key,n,o,r,i),u=this.shapeMap.key.getLocalBounds(),c=function(t,e,n=1){return Bd(Gh(t[0],t[1])*n,e)}([u.min,u.max],a);return Object.assign({wordWrapWidth:c},l,s)}getBadgeStyle(t){if(!1===t.badge||!t.badgeText)return!1;const e=Ad(t,"badge"),{offsetX:n,offsetY:r,placement:i}=e,o=Fe(e,["offsetX","offsetY","placement"]);return Object.assign(o,function(t,e,n,r,i){var o,a;const s=2*(null===(o=t.badge)||void 0===o?void 0:o.getGeometryBounds().halfExtents[0])||0,l=2*(null===(a=t.label)||void 0===a?void 0:a.getGeometryBounds().halfExtents[0])||0;return $p(t.key,n,!0,(l?(l/2+s/2)*("suffix"===e?1:-1):0)+r,i)}(this.shapeMap,i,t.labelPlacement,n,r))}drawArrow(t,e){var n;const r="start"===e,i=t["start"===e?"startArrow":"endArrow"],o=this.shapeMap.key;if(i){const e=this.getArrowStyle(t,r),[n,i,a]=r?["markerStart","markerStartOffset","startArrowOffset"]:["markerEnd","markerEndOffset","endArrowOffset"],s=o.parsedStyle[n];if(s)s.attr(e);else{const t=new(e.src?zl:Hl)({style:e});o.style[n]=t}o.style[i]=t[a]||e.width/2+ +e.lineWidth}else{const t=r?"markerStart":"markerEnd";null===(n=o.style[t])||void 0===n||n.destroy(),o.style[t]=null}}getArrowStyle(t,e){const n=this.getShape("key").attributes,r=e?"startArrow":"endArrow",i=Ad(this.getGraphicStyle(t),r),{size:o,type:a}=i,s=Fe(i,["size","type"]),[l,u]=Dd(function(t,e){return e||(t<4?10:4===t?12:2.5*t)}(n.lineWidth,o)),c=(Ut(a)?a:rg[a]||ng)(l,u);return Object.assign(Ae(n,["stroke","strokeOpacity","fillOpacity"]),{width:l,height:u},Object.assign({},c&&{d:c,fill:"simple"===a?"":n.stroke}),s)}drawLabelShape(t,e){const n=this.getLabelStyle(t);this.upsert("label",Wd,n,e)}drawHaloShape(t,e){const n=this.getHaloStyle(t);this.upsert("halo",Hl,n,e)}drawBadgeShape(t,e){const n=this.getBadgeStyle(t);this.upsert("badge",Hd,n,e)}drawSourceArrow(t){this.drawArrow(t,"start")}drawTargetArrow(t){this.drawArrow(t,"end")}drawKeyShape(t,e){const n=this.getKeyStyle(t);return this.upsert("key",Hl,n,e)}render(t=this.parsedAttributes,e=this){this.drawKeyShape(t,e),this.getShape("key")&&(this.drawSourceArrow(t),this.drawTargetArrow(t),this.drawLabelShape(t,e),this.drawHaloShape(t,e),this.drawBadgeShape(t,e))}onframe(){this.drawKeyShape(this.parsedAttributes,this),this.drawSourceArrow(this.parsedAttributes),this.drawTargetArrow(this.parsedAttributes),this.drawHaloShape(this.parsedAttributes,this),this.drawLabelShape(this.parsedAttributes,this),this.drawBadgeShape(this.parsedAttributes,this)}animate(t,e){const n=super.animate(t,e);return n?new Proxy(n,{set:(t,e,n)=>("currentTime"===e&&Promise.resolve().then((()=>this.onframe())),Reflect.set(t,e,n))}):n}}ig.defaultStyleProps={badge:!0,badgeOffsetX:0,badgeOffsetY:0,badgePlacement:"suffix",isBillboard:!0,label:!0,labelAutoRotate:!0,labelIsBillboard:!0,labelMaxWidth:"80%",labelOffsetX:4,labelOffsetY:0,labelPlacement:"center",labelTextBaseline:"middle",labelWordWrap:!1,halo:!1,haloDroppable:!1,haloLineDash:0,haloLineWidth:12,haloPointerEvents:"none",haloStrokeOpacity:.25,haloZIndex:-1,loop:!0,startArrow:!1,startArrowLineDash:0,startArrowLineJoin:"round",startArrowLineWidth:1,startArrowTransformOrigin:"center",startArrowType:"vee",endArrow:!1,endArrowLineDash:0,endArrowLineJoin:"round",endArrowLineWidth:1,endArrowTransformOrigin:"center",endArrowType:"vee",loopPlacement:"top",loopClockwise:!0};class og extends ig{constructor(t){super(_d({style:og.defaultStyleProps},t))}getKeyPath(t){const[e,n]=this.getEndpoints(t),{controlPoints:r,curvePosition:i,curveOffset:o}=t,a=this.getControlPoints(e,n,function(t){return ae(t)?[t,1-t]:t}(i),function(t){return ae(t)?[t,-t]:t}(o),r);return Xp(e,n,a)}getControlPoints(t,e,n,r,i){return 2===(null==i?void 0:i.length)?i:[qp(t,e,n[0],r[0]),qp(t,e,n[1],r[1])]}}og.defaultStyleProps={curvePosition:.5,curveOffset:20};class ag extends og{constructor(t){super(_d({style:ag.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[0]-t[0];return[[t[0]+i*n[0]+r[0],t[1]],[e[0]-i*n[1]+r[1],e[1]]]}}ag.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};class sg extends og{constructor(t){super(_d({style:sg.defaultStyleProps},t))}get ref(){return this.context.model.getRootsData()[0]}getEndpoints(t){if(this.sourceNode.id===this.ref.id)return super.getEndpoints(t);const e=Jh(this.ref);return[this.sourceNode.getIntersectPoint(e,!0),this.targetNode.getIntersectPoint(e)]}toRadialCoordinate(t){const e=Jh(this.ref);return[Gh(t,e),Xh(jh(t,e))]}getControlPoints(t,e,n,r){const[i,o]=this.toRadialCoordinate(t),[a]=this.toRadialCoordinate(e),s=a-i;return[[t[0]+(s*n[0]+r[0])*Math.cos(o),t[1]+(s*n[0]+r[0])*Math.sin(o)],[e[0]-(s*n[1]-r[0])*Math.cos(o),e[1]-(s*n[1]-r[0])*Math.sin(o)]]}}sg.defaultStyleProps={curvePosition:.5,curveOffset:20};class lg extends og{constructor(t){super(_d({style:lg.defaultStyleProps},t))}getControlPoints(t,e,n,r){const i=e[1]-t[1];return[[t[0],t[1]+i*n[0]+r[0]],[e[0],e[1]-i*n[1]+r[1]]]}}lg.defaultStyleProps={curvePosition:[.5,.5],curveOffset:[0,0]};let ug=class t extends ig{constructor(e){super(_d({style:t.defaultStyleProps},e))}getKeyPath(t){const[e,n]=this.getEndpoints(t);return[["M",e[0],e[1]],["L",n[0],n[1]]]}};ug.defaultStyleProps={};const cg={enableObstacleAvoidance:!1,offset:10,maxAllowedDirectionChange:Math.PI/2,maximumLoops:3e3,gridSize:5,startDirections:["top","right","bottom","left"],endDirections:["top","right","bottom","left"],directionMap:{right:{stepX:1,stepY:0},left:{stepX:-1,stepY:0},bottom:{stepX:0,stepY:1},top:{stepX:0,stepY:-1}},penalties:{0:0,90:0},distFunc:Vh},hg=t=>`${Math.round(t[0])}|||${Math.round(t[1])}`;function dg(t,e){const n=t=>Math.round(t/e);return ae(t)?n(t):t.map(n)}function fg(t,e){const n=e[0]-t[0],r=e[1]-t[1];return n||r?Math.atan2(r,n):0}function pg(t,e,n,r){const i=fg(t,e),o=n[hg(t)];return function(t,e){const n=Math.abs(t-e);return n>Math.PI?2*Math.PI-n:n}(fg(o||r,t),i)}function gg(t,e,n){return Math.min(...e.map((e=>n(t,e))))}const vg=(t,e,n,r)=>{if(!e)return[t];const{directionMap:i,offset:o}=r,a=Qc(e.getRenderBounds(),o),s=Object.keys(i).reduce(((e,r)=>{if(n.includes(r)){const n=i[r],[o,s]=Xc(a),l=[t[0]+n.stepX*o,t[1]+n.stepY*s],u=function(t){const{min:[e,n],max:[r,i]}=t,o=[e,i],a=[r,i],s=[r,n],l=[e,n];return[[o,a],[a,s],[s,l],[l,o]]}(a);for(let n=0;n<u.length;n++){const r=Zh([t,l],u[n]);r&&eh(r,a)&&e.push(r)}}return e}),[]);return th(t,a)||s.push(t),s.map((t=>dg(t,r.gridSize)))},mg=(t,e,n,r,i,o,a)=>{const s=[];let l=[o[0]===r[0]?r[0]:t[0]*a,o[1]===r[1]?r[1]:t[1]*a];s.unshift(l);let u=t,c=e[hg(u)];for(;c;){const t=c,r=u;pg(t,r,e,n)&&(l=[t[0]===r[0]?l[0]:t[0]*a,t[1]===r[1]?l[1]:t[1]*a],s.unshift(l)),c=e[hg(t)],u=t}const h=i.map((t=>[t[0]*a,t[1]*a])),d=function(t,e,n){let r=t[0],i=n(t[0],e);for(let o=0;o<t.length;o++){const a=t[o],s=n(a,e);s<i&&(r=a,i=s)}return r}(h,l,Vh);return s.unshift(d),s};function yg(t,e,n,r){const i=Yh(t.getCenter()),o=Yh(e.getCenter()),a=Object.assign(cg,r),{gridSize:s}=a,l=((t,e)=>{const{offset:n,gridSize:r}=e,i={};return t.forEach((t=>{if(!t||t.destroyed||!t.isVisible())return;const e=Qc(t.getRenderBounds(),n);for(let t=dg(e.min[0],r);t<=dg(e.max[0],r);t+=1)for(let n=dg(e.min[1],r);n<=dg(e.max[1],r);n+=1)i[`${t}|||${n}`]=!0})),i})(a.enableObstacleAvoidance?n:[t,e],a),u=dg(i,s),c=dg(o,s),h=vg(i,t,a.startDirections,a),d=vg(o,e,a.endDirections,a);h.forEach((t=>delete l[hg(t)])),d.forEach((t=>delete l[hg(t)]));const f={},p={},g={},v={},m={},y=new bg;for(let t=0;t<h.length;t++){const e=h[t],n=hg(e);f[n]=e,v[n]=0,m[n]=gg(e,d,a.distFunc),y.add({id:n,value:m[n]})}const b=d.map((t=>hg(t)));let x,E=a.maximumLoops,w=1/0;for(const[t,e]of Object.entries(f))m[t]<=w&&(w=m[t],x=e);for(;Object.keys(f).length>0&&E>0;){const t=y.minId(!1);if(!t)break;x=f[t];const e=hg(x);if(b.includes(e))return mg(x,g,u,o,h,c,s);delete f[e],y.remove(e),p[e]=!0;for(const t of Object.values(a.directionMap)){const n=Ih(x,[t.stepX,t.stepY]),r=hg(n);if(p[r])continue;const i=pg(x,n,g,u);if(i>a.maxAllowedDirectionChange)continue;if(l[r])continue;f[r]||(f[r]=n);const o=a.penalties[i],c=a.distFunc(x,n)+(isNaN(o)?s:o),h=v[e]+c,b=v[r];b&&h>=b||(g[r]=x,v[r]=h,m[r]=h+gg(n,d,a.distFunc),y.add({id:r,value:m[r]}))}E-=1}return[]}class bg{constructor(){this.arr=[],this.map={},this.arr=[],this.map={}}_innerAdd(t,e){let n=0,r=e-1;for(;r-n>1;){const e=Math.floor((n+r)/2);if(this.arr[e].value>t.value)r=e;else{if(!(this.arr[e].value<t.value))return this.arr.splice(e,0,t),void(this.map[t.id]=!0);n=e}}this.arr.splice(r,0,t),this.map[t.id]=!0}add(t){delete this.map[t.id];const e=this.arr.length;if(!e||this.arr[e-1].value<t.value)return this.arr.push(t),void(this.map[t.id]=!0);this._innerAdd(t,e)}remove(t){this.map[t]&&delete this.map[t]}_clearAndGetMinId(){let t;for(let e=this.arr.length-1;e>=0;e--)this.map[this.arr[e].id]?t=this.arr[e].id:this.arr.splice(e,1);return t}_findFirstId(){for(;this.arr.length;){const t=this.arr.shift();if(this.map[t.id])return t.id}}minId(t){return t?this._clearAndGetMinId():this._findFirstId()}}class xg extends ig{constructor(t){super(_d({style:xg.defaultStyleProps},t))}getControlPoints(t){const{router:e}=t,{sourceNode:n,targetNode:r}=this,[i,o]=this.getEndpoints(t,!1);let a=[];if(e)if("shortest-path"===e.type){a=yg(n,r,this.context.element.getNodes(),e),a.length||(a=_p(i,o,n,r,t.controlPoints,{padding:e.offset}))}else"orth"===e.type&&(a=_p(i,o,n,r,t.controlPoints,e));else a=t.controlPoints;return a}getPoints(t){const e=this.getControlPoints(t),[n,r]=this.getEndpoints(t,!0,e);return[n,...e,r]}getKeyPath(t){return Kp(this.getPoints(t),t.radius)}getLoopPath(t){const{sourcePort:e,targetPort:n,radius:r}=t,i=this.sourceNode,o=Kc(i),a=Math.max(Yc(o),qc(o))/4,{placement:s,clockwise:l,dist:u=a}=Ad(this.getGraphicStyle(t),"loop");return Jp(i,r,s,l,u,e,n)}}xg.defaultStyleProps={radius:0,controlPoints:[],router:!1};class Eg extends ig{constructor(t){super(_d({style:Eg.defaultStyleProps},t))}getKeyPath(t){const{curvePosition:e,curveOffset:n}=t,[r,i]=this.getEndpoints(t);return function(t,e,n){return[["M",t[0],t[1]],["Q",n[0],n[1],e[0],e[1]]]}(r,i,t.controlPoint||qp(r,i,e,n))}}function wg(t){return t instanceof nf&&"node"===t.type}function kg(t){return t instanceof ig}function Mg(t){return t instanceof Pp}Eg.defaultStyleProps={curvePosition:.5,curveOffset:30};const Sg={top:[.5,0],right:[1,.5],bottom:[.5,1],left:[0,.5],"left-top":[0,0],"top-left":[0,0],"left-bottom":[0,1],"bottom-left":[0,1],"right-top":[1,0],"top-right":[1,0],"right-bottom":[1,1],"bottom-right":[1,1],default:[.5,.5]};function Ng(t,e,n=Sg,r=!0){const i=[.5,.5],o=ne(e)?Oe(n,e.toLocaleLowerCase(),i):e;if(!r&&ne(e))return o;const[a,s]=o||i;return[t.min[0]+Yc(t)*a,t.min[1]+qc(t)*s]}function Og(t){if(!t)return{};const e=t.getPorts();return(t.attributes.ports||[]).forEach(((n,r)=>{var i;const{key:o,placement:a}=n;Tg(n)&&(e[i=o||r]||(e[i]=ed(t.getShape("key").getBounds(),a)))})),e}function Tg(t){const{r:e}=t;return!e||0===Number(e)}function Cg(t){return Wc(t)?t:t.getPosition()}function Ag(t,e,n,r){const i=Og(t);if(n)return i[n];const o=Object.values(i);if(0===o.length)return;const a=o.map((t=>Cg(t))),s=function(t,e){const n=Og(t);if(e)return[Cg(n[e])];const r=Object.values(n);return r.length>0?r.map((t=>Cg(t))):[t.getCenter()]}(e,r),[l]=function(t,e){let n=1/0,r=[t[0],e[0]];return t.forEach((t=>{e.forEach((e=>{const i=Gh(t,e);i<n&&(n=i,r=[t,e])}))})),r}(a,s);return o.find((t=>Cg(t)===l))}function Pg(t,e){return Mg(t)||wg(t)?Dg(t,e):Rg(t,e)}function Rg(t,e){if(!t||!e)return[0,0,0];if(Wc(t))return t;if(t.attributes.linkToCenter)return t.getPosition();return cd(Wc(e)?e:wg(e)?e.getCenter():e.getPosition(),t.getBounds())}function Dg(t,e){if(!t||!e)return[0,0,0];const n=Wc(e)?e:wg(e)?e.getCenter():e.getPosition();return t.getIntersectPoint(n)||t.getCenter()}function Lg(t,e="bottom",n=0,r=0,i=!1){const o=e.split("-"),[a,s]=ed(t,e),[l,u]=i?["bottom","top"]:["top","bottom"];return{transform:[["translate",a+n,s+r]],textBaseline:o.includes("top")?u:o.includes("bottom")?l:"middle",textAlign:o.includes("left")?"right":o.includes("right")?"left":"center"}}function _g(t,e){"update"in t?t.update(e):t.attr(e)}function Ig(t){return Oe(t,"__to_be_destroyed__",!1)}class jg extends Dh{constructor(t,e){super(t,Object.assign({},jg.defaultOptions,e)),this.onCollapseExpand=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{target:e}=t;if(!(wg(n=e)||kg(n)||Mg(n)))return;var n;const r=e.id,{model:i,graph:o}=this.context,a=i.getElementDataById(r);if(!a)return!1;const{onCollapse:s,onExpand:l,animation:u,align:c}=this.options;Od(a)?(yield o.expandElement(r,{animation:u,align:c}),null==l||l(r)):(yield o.collapseElement(r,{animation:u,align:c}),null==s||s(r))})),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.on(`node:${e}`,this.onCollapseExpand),t.on(`combo:${e}`,this.onCollapseExpand)}unbindEvents(){const{graph:t}=this.context,{trigger:e}=this.options;t.off(`node:${e}`,this.onCollapseExpand),t.off(`combo:${e}`,this.onCollapseExpand)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}jg.defaultOptions={enable:!0,animation:!0,trigger:t.CommonEvent.DBLCLICK,align:!0};const Bg="g6-create-edge-assist-node-id";class Fg extends Dh{constructor(t,e){super(t,Object.assign({},Fg.defaultOptions,e)),this.drop=t=>ze(this,void 0,void 0,(function*(){const{targetType:e}=t;["combo","node"].includes(e)&&this.source?yield this.handleCreateEdge(t):yield this.cancelEdge()})),this.handleCreateEdge=t=>ze(this,void 0,void 0,(function*(){var e,n,r;if(!this.validate(t))return;const{graph:i,canvas:o,batch:a,element:s}=this.context,{style:l}=this.options;if(this.source)return this.createEdge(t),void(yield this.cancelEdge());a.startBatch(),o.setCursor("crosshair"),this.source=this.getSelectedNodeIDs([t.target.id])[0];const u=i.getElementData(this.source);i.addNodeData([{id:Bg,style:{visibility:"hidden",ports:[{key:"port-1",placement:[.5,.5]}],x:null===(e=u.style)||void 0===e?void 0:e.x,y:null===(n=u.style)||void 0===n?void 0:n.y}}]),i.addEdgeData([{id:"g6-create-edge-assist-edge-id",source:this.source,target:Bg,style:Object.assign({pointerEvents:"none"},l)}]),yield null===(r=s.draw({animation:!1}))||void 0===r?void 0:r.finished})),this.updateAssistEdge=t=>ze(this,void 0,void 0,(function*(){var e;if(!this.source)return;const{model:n,element:r}=this.context;n.translateNodeTo(Bg,[t.canvas.x,t.canvas.y]),yield null===(e=r.draw({animation:!1,silence:!0}))||void 0===e?void 0:e.finished})),this.createEdge=t=>{var e,n;const{graph:r}=this.context,{style:i,onFinish:o,onCreate:a}=this.options;if(void 0===(null===(e=t.target)||void 0===e?void 0:e.id)||void 0===this.source)return;const s=null===(n=this.getSelectedNodeIDs([t.target.id]))||void 0===n?void 0:n[0];var l;const u=a({id:`${this.source}-${s}-${De[l=l||"g"]?De[l]+=1:De[l]=1,l+De[l]}`,source:this.source,target:s,style:i});u&&(r.addEdgeData([u]),o(u))},this.cancelEdge=()=>ze(this,void 0,void 0,(function*(){var t;if(!this.source)return;const{graph:e,element:n,batch:r}=this.context;e.removeNodeData([Bg]),this.source=void 0,yield null===(t=n.draw({animation:!1}))||void 0===t?void 0:t.finished,r.endBatch()})),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{graph:e}=this.context,{trigger:n}=this.options;this.unbindEvents(),"click"===n?(e.on(t.NodeEvent.CLICK,this.handleCreateEdge),e.on(t.ComboEvent.CLICK,this.handleCreateEdge),e.on(t.CanvasEvent.CLICK,this.cancelEdge),e.on(t.EdgeEvent.CLICK,this.cancelEdge)):(e.on(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.on(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.on(t.CommonEvent.POINTER_UP,this.drop)),e.on(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;e.off(t.NodeEvent.CLICK,this.handleCreateEdge),e.off(t.ComboEvent.CLICK,this.handleCreateEdge),e.off(t.CanvasEvent.CLICK,this.cancelEdge),e.off(t.EdgeEvent.CLICK,this.cancelEdge),e.off(t.NodeEvent.DRAG_START,this.handleCreateEdge),e.off(t.ComboEvent.DRAG_START,this.handleCreateEdge),e.off(t.CommonEvent.POINTER_UP,this.drop),e.off(t.CommonEvent.POINTER_MOVE,this.updateAssistEdge)}destroy(){this.unbindEvents(),super.destroy()}}Fg.defaultOptions={animation:!0,enable:!0,style:{},trigger:"drag",onCreate:t=>t,onFinish:()=>{}};class zg extends Dh{constructor(t,e){super(t,Object.assign({},zg.defaultOptions,e)),this.isDragging=!1,this.onDragStart=t=>{this.validate(t)&&(this.isDragging=!0,this.context.canvas.setCursor("grabbing"))},this.onDrag=t=>{var e,n,r,i;if(!this.isDragging||gd.isPinching)return;const o=null!==(n=null===(e=t.movement)||void 0===e?void 0:e.x)&&void 0!==n?n:t.dx,a=null!==(i=null===(r=t.movement)||void 0===r?void 0:r.y)&&void 0!==i?i:t.dy;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=ye((()=>{var t,e;null===(e=(t=this.options).onFinish)||void 0===e||e.call(t)}),300),this.shortcut=new md(t.graph),this.bindEvents(),this.defaultCursor=this.context.canvas.getConfig().cursor||"default"}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(qt(e)){const{up:t=[],down:n=[],left:r=[],right:i=[]}=e;this.shortcut.bind(t,(t=>this.onTranslate([0,1],t))),this.shortcut.bind(n,(t=>this.onTranslate([0,-1],t))),this.shortcut.bind(r,(t=>this.onTranslate([1,0],t))),this.shortcut.bind(i,(t=>this.onTranslate([-1,0],t)))}else{const{graph:e}=this.context;e.on(t.CommonEvent.DRAG_START,this.onDragStart),e.on(t.CommonEvent.DRAG,this.onDrag),e.on(t.CommonEvent.DRAG_END,this.onDragEnd)}}onTranslate(t,e){return ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{sensitivity:n}=this.options,r=-1*n;yield this.translate(Bh(t,r),this.options.animation),this.invokeOnFinish()}))}translate(t,e){return ze(this,void 0,void 0,(function*(){t=this.clampByDirection(t),t=this.clampByRange(t),yield this.context.graph.translateBy(t,e)}))}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[a,s,l,u]=Uc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return"function"==typeof e?e(t):!!e}unbindEvents(){this.shortcut.unbindAll();const{graph:e}=this.context;e.off(t.CommonEvent.DRAG_START,this.onDragStart),e.off(t.CommonEvent.DRAG,this.onDrag),e.off(t.CommonEvent.DRAG_END,this.onDragEnd)}destroy(){this.shortcut.destroy(),this.unbindEvents(),this.context.canvas.setCursor(this.defaultCursor),super.destroy()}}zg.defaultOptions={enable:t=>!("targetType"in t)||"canvas"===t.targetType,sensitivity:10,direction:"both",range:1/0};class Gg extends Dh{constructor(e,n){super(e,Object.assign({},Gg.defaultOptions,n)),this.enable=!1,this.enableElements=["node","combo"],this.target=[],this.shadowOrigin=[0,0],this.hiddenEdges=[],this.isDragging=!1,this.onDrop=t=>ze(this,void 0,void 0,(function*(){var e;if("link"!==this.options.dropEffect)return;const{model:n,element:r}=this.context,i=t.target.id;this.target.forEach((t=>{const e=n.getParentData(t,Ec);e&&yh(e)===i&&n.refreshComboData(i),n.setParent(t,i,Ec)})),yield null===(e=null==r?void 0:r.draw({animation:!0}))||void 0===e?void 0:e.finished})),this.setCursor=e=>{if(this.isDragging)return;const{type:n}=e,{canvas:r}=this.context,{cursor:i}=this.options;n===t.CommonEvent.POINTER_ENTER?r.setCursor((null==i?void 0:i.grab)||"grab"):r.setCursor((null==i?void 0:i.default)||"default")},this.onDragStart=this.onDragStart.bind(this),this.onDrag=this.onDrag.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.onDrop=this.onDrop.bind(this),this.bindEvents()}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}bindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.addEventListener("blur",this.onDragEnd),r.addEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach((n=>{e.on(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.on(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.on(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)})),["link"].includes(this.options.dropEffect)&&(e.on(t.ComboEvent.DROP,this.onDrop),e.on(t.CanvasEvent.DROP,this.onDrop))}getSelectedNodeIDs(t){return Array.from(new Set(this.context.graph.getElementDataByState("node",this.options.state).map((t=>t.id)).concat(t)))}getDelta(t){const e=this.context.graph.getZoom();return Fh([t.dx,t.dy],e)}onDragStart(t){var e;if(this.enable=this.validate(t),!this.enable)return;const{batch:n,canvas:r,graph:i}=this.context;r.setCursor((null===(e=this.options.cursor)||void 0===e?void 0:e.grabbing)||"grabbing"),this.isDragging=!0,n.startBatch();const o=t.target.id;i.getElementState(o).includes(this.options.state)?this.target=this.getSelectedNodeIDs([o]):this.target=[o],this.hideEdge(),this.context.graph.frontElement(this.target),this.options.shadow&&this.createShadow(this.target)}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.options.shadow?this.moveShadow(e):this.moveElement(this.target,e)}onDragEnd(){var t,e,n;if(!this.enable)return;if(this.enable=!1,this.options.shadow){if(!this.shadow)return;this.shadow.style.visibility="hidden";const{x:t=0,y:e=0}=this.shadow.attributes,[n,r]=jh([+t,+e],this.shadowOrigin);this.moveElement(this.target,[n,r])}this.showEdges(),null===(e=(t=this.options).onFinish)||void 0===e||e.call(t,this.target);const{batch:r,canvas:i}=this.context;r.endBatch(),i.setCursor((null===(n=this.options.cursor)||void 0===n?void 0:n.grab)||"grab"),this.isDragging=!1,this.target=[]}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}moveElement(t,e){return ze(this,void 0,void 0,(function*(){const{graph:n,model:r}=this.context,{dropEffect:i}=this.options;"move"===i&&t.forEach((t=>r.refreshComboData(t))),n.translateElementBy(Object.fromEntries(t.map((t=>[t,e]))),!1)}))}moveShadow(t){if(!this.shadow)return;const{x:e=0,y:n=0}=this.shadow.attributes,[r,i]=t;this.shadow.attr({x:+e+r,y:+n+i})}createShadow(t){const e=Ad(this.options,"shadow"),n=Jc(t.map((t=>this.context.element.getElement(t).getBounds()))),[r,i]=n.min;this.shadowOrigin=[r,i];const[o,a]=Xc(n),s={width:o,height:a,x:r,y:i};this.shadow?this.shadow.attr(Object.assign(Object.assign(Object.assign({},e),s),{visibility:"visible"})):(this.shadow=new Xl({style:Object.assign(Object.assign(Object.assign({$layer:"transient"},e),s),{pointerEvents:"none"})}),this.context.canvas.appendChild(this.shadow))}showEdges(){this.options.shadow||0===this.hiddenEdges.length||(this.context.graph.showElement(this.hiddenEdges),this.hiddenEdges=[])}hideEdge(){const{hideEdge:t,shadow:e}=this.options;if("none"===t||e)return;const{graph:n}=this.context;this.hiddenEdges="all"===t?n.getEdgeData().map(yh):Array.from(new Set(this.target.map((e=>n.getRelatedEdgesData(e,t).map(yh))).flat())),n.hideElement(this.hiddenEdges)}unbindEvents(){const{graph:e,canvas:n}=this.context,r=n.getLayer().getContextService().$canvas;r&&(r.removeEventListener("blur",this.onDragEnd),r.removeEventListener("contextmenu",this.onDragEnd)),this.enableElements.forEach((n=>{e.off(`${n}:${t.CommonEvent.DRAG_START}`,this.onDragStart),e.off(`${n}:${t.CommonEvent.DRAG}`,this.onDrag),e.off(`${n}:${t.CommonEvent.DRAG_END}`,this.onDragEnd),e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.setCursor),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.setCursor)})),e.off(`combo:${t.CommonEvent.DROP}`,this.onDrop),e.off(`canvas:${t.CommonEvent.DROP}`,this.onDrop)}destroy(){var t;this.unbindEvents(),null===(t=this.shadow)||void 0===t||t.destroy(),super.destroy()}}Gg.defaultOptions={animation:!0,enable:t=>["node","combo"].includes(t.targetType),dropEffect:"move",state:"selected",hideEdge:"none",shadow:!1,shadowZIndex:100,shadowFill:"#F3F9FF",shadowFillOpacity:.5,shadowStroke:"#1890FF",shadowStrokeOpacity:.9,shadowLineDash:[5,5],cursor:{default:"default",grab:"grab",grabbing:"grabbing"}};var Vg=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this._events[t]||[],o=this._events["*"]||[],a=function(r){for(var i=r.length,o=0;o<i;o++)if(r[o]){var a=r[o],s=a.callback;a.once&&(r.splice(o,1),0===r.length&&delete e._events[t],i--,o--),s.apply(e,n)}};a(i),a(o)},t.prototype.off=function(t,e){if(t)if(e){for(var n=this._events[t]||[],r=n.length,i=0;i<r;i++)n[i].callback===e&&(n.splice(i,1),r--,i--);0===n.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function Wg(t,e,n,r){for(;t.length;){const i=t.shift();if(n(i))return!0;e.add(i.id),r(i.id).forEach((n=>{e.has(n.id)||(e.add(n.id),t.push(n))}))}return!1}function Hg(t,e,n,r){if(n(t))return!0;e.add(t.id);for(const i of r(t.id))if(!e.has(i.id)&&Hg(i,e,n,r))return!0;return!1}const Ug=()=>!0;class $g{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(t){this.graph=t.graph;const e=t.nodeFilter||Ug,n=t.edgeFilter||Ug;this.nodeFilter=e,this.edgeFilter=t=>{const{source:r,target:i}=this.graph.getEdgeDetail(t.id);return!(!e(r)||!e(i))&&n(t,r,i)},"auto"===t.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===t.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache=()=>{this.clearCache(),this.updateCache(this.graph.getAllNodes().map((t=>t.id)))};updateCache=t=>{const e=new Set;t.forEach((t=>{const n=this.bothEdgesMap.get(t);if(n&&n.forEach((t=>e.add(t.id))),this.hasNode(t)){const n=this.graph.getRelatedEdges(t,"in").filter(this.edgeFilter),r=this.graph.getRelatedEdges(t,"out").filter(this.edgeFilter),i=Array.from(new Set([...n,...r]));i.forEach((t=>e.add(t.id))),this.inEdgesMap.set(t,n),this.outEdgesMap.set(t,r),this.bothEdgesMap.set(t,i),this.allNodesMap.set(t,this.graph.getNode(t))}else this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.bothEdgesMap.delete(t),this.allNodesMap.delete(t)})),e.forEach((t=>{this.hasEdge(t)?this.allEdgesMap.set(t,this.graph.getEdge(t)):this.allEdgesMap.delete(t)}))};startAutoCache(){this.refreshCache(),this.graph.on("changed",this.handleGraphChanged)}stopAutoCache(){this.graph.off("changed",this.handleGraphChanged)}handleGraphChanged=t=>{const e=new Set;t.changes.forEach((n=>{switch(n.type){case"NodeAdded":case"NodeRemoved":e.add(n.value.id);break;case"NodeDataUpdated":e.add(n.id);break;case"EdgeAdded":case"EdgeRemoved":e.add(n.value.source),e.add(n.value.target);break;case"EdgeUpdated":"source"!==n.propertyName&&"target"!==n.propertyName||(e.add(n.oldValue),e.add(n.newValue));break;case"EdgeDataUpdated":if(t.graph.hasEdge(n.id)){const r=t.graph.getEdge(n.id);e.add(r.source),e.add(r.target)}}})),this.updateCache(e)};checkNodeExistence(t){this.getNode(t)}hasNode(t){if(!this.graph.hasNode(t))return!1;const e=this.graph.getNode(t);return this.nodeFilter(e)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.graph.getNode(t);if(!this.nodeFilter(e))throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),this.cacheEnabled)return"in"===e?this.inEdgesMap.get(t):"out"===e?this.outEdgesMap.get(t):this.bothEdgesMap.get(t);return this.graph.getRelatedEdges(t,e).filter(this.edgeFilter)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}hasEdge(t){if(!this.graph.hasEdge(t))return!1;const e=this.graph.getEdge(t);return this.edgeFilter(e)}getEdge(t){const e=this.graph.getEdge(t);if(!this.edgeFilter(e))throw new Error("Edge not found for id: "+t);return e}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}hasTreeStructure(t){return this.graph.hasTreeStructure(t)}getRoots(t){return this.graph.getRoots(t).filter(this.nodeFilter)}getChildren(t,e){return this.checkNodeExistence(t),this.graph.getChildren(t,e).filter(this.nodeFilter)}getParent(t,e){this.checkNodeExistence(t);const n=this.graph.getParent(t,e);return n&&this.nodeFilter(n)?n:null}getAllNodes(){return this.cacheEnabled?Array.from(this.allNodesMap.values()):this.graph.getAllNodes().filter(this.nodeFilter)}getAllEdges(){return this.cacheEnabled?Array.from(this.allEdgesMap.values()):this.graph.getAllEdges().filter(this.edgeFilter)}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Wg([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];Hg(this.getNode(t),new Set,e,r)}}let Yg=class t extends Vg{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let n=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),n||e.push(t);break}case"EdgeRemoved":{let n=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const r=e.value.id===t.value.id;return r&&(n=!0),!r}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),n||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const n=e.findIndex((e=>e.type===t.type&&e.id===t.id&&(void 0===t.propertyName||e.propertyName===t.propertyName))),r=e[n];r?void 0!==t.propertyName?r.newValue=t.newValue:(e.splice(n,1),e.push(t)):e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const n=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));n?n.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),n=this.getSuccessors(t);return Array.from(new Set([...e,...n]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),n=this.bothEdgesMap.get(t);n?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((n=>{n.childrenMap.get(t)?.forEach((t=>{n.parentMap.delete(t.id)}));const r=n.parentMap.get(t);r&&n.childrenMap.get(r.id)?.delete(e),n.parentMap.delete(t),n.childrenMap.delete(t)})),this.bothEdgesMap.delete(t),this.inEdgesMap.delete(t),this.outEdgesMap.delete(t),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,n){const r=this.getNode(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateNodeDataProperty(t,e,n)}))}))}updateNodeData(...t){const e=t[0],n=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:i})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),n=this.outEdgesMap.get(t.source),r=this.bothEdgesMap.get(t.source),i=this.bothEdgesMap.get(t.target);e.add(t),n.add(t),r.add(t),i.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),n=this.outEdgesMap.get(e.source),r=this.inEdgesMap.get(e.target),i=this.bothEdgesMap.get(e.source),o=this.bothEdgesMap.get(e.target);n.delete(e),r.delete(e),i.delete(e),o.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.source,i=e;this.outEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.outEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:r,newValue:i})}))}updateEdgeTarget(t,e){const n=this.getEdge(t);this.checkNodeExistence(e);const r=n.target,i=e;this.inEdgesMap.get(r).delete(n),this.bothEdgesMap.get(r).delete(n),this.inEdgesMap.get(i).add(n),this.bothEdgesMap.get(i).add(n),n.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:r,newValue:i})}))}updateEdgeDataProperty(t,e,n){const r=this.getEdge(t);this.batch((()=>{const i=r.data[e],o=n;r.data[e]=o,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:i,newValue:o})}))}updateEdgeData(...t){const e=t[0],n=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let r;if("function"==typeof t[1]){const e=t[1];r=e(n.data)}else"object"==typeof t[1]&&(r=t[1]);this.batch((()=>{const t=n.data,i=r;n.data=r,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:i})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,n])=>{this.updateEdgeDataProperty(t,e,n)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const n=[],r=Array.isArray(t)?t:[t];for(;r.length;){const t=r.shift();n.push(t),t.children&&r.push(...t.children)}this.addNodes(n),n.forEach((t=>{t.children?.forEach((n=>{this.setParent(n.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const n=this.treeIndices.get(e).childrenMap.get(t);return Array.from(n||[])}getParent(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);return this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const n=[];let r,i=this.getNode(t);for(;r=this.getParent(i.id,e);)n.push(r),i=r;return n}setParent(t,e,n){this.checkTreeExistence(n);const r=this.treeIndices.get(n);if(!r)return;const i=this.getNode(t),o=r.parentMap.get(t);if(o?.id===e)return;if(null==e)return o&&r.childrenMap.get(o.id)?.delete(i),void r.parentMap.delete(t);const a=this.getNode(e);r.parentMap.set(t,a),o&&r.childrenMap.get(o.id)?.delete(i);let s=r.childrenMap.get(a.id);s||(s=new Set,r.childrenMap.set(a.id,s)),s.add(i),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:n,nodeId:t,oldParentId:o?.id,newParentId:a.id})}))}dfsTree(t,e,n){return Hg(this.getNode(t),new Set,e,(t=>this.getChildren(t,n)))}bfsTree(t,e,n){return Wg([this.getNode(t)],new Set,e,(t=>this.getChildren(t,n)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Wg([this.getNode(t)],new Set,e,r)}dfs(t,e,n="out"){const r={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[n];return Hg(this.getNode(t),new Set,e,r)}clone(){const e=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),n=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new t({nodes:e,edges:n});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const i=new Map;t.forEach(((t,e)=>{i.set(e,r.getNode(t.id))}));const o=new Map;e.forEach(((t,e)=>{o.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:i,childrenMap:o})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}createView(t){return new $g({graph:this,...t})}};class qg{constructor(t,e){this.context=t,this.options=e||{}}}function Xg(t){const{nodes:e,edges:n}=t,r={nodes:[],edges:[],combos:[]};return e.forEach((t=>{const e=t.data._isCombo?r.combos:r.nodes,{x:n,y:i,z:o=0}=t.data;null==e||e.push({id:t.id,style:{x:n,y:i,z:o}})})),n.forEach((t=>{const{id:e,source:n,target:i,data:{points:o=[],controlPoints:a=o.slice(1,o.length-1)}}=t;r.edges.push({id:e,source:n,target:i,style:Object.assign({},(null==a?void 0:a.length)?{controlPoints:a.map(nd)}:{})})})),r}function Kg(t,e,...n){if(e in t)return t[e](...n);if("instance"in t){const r=t.instance;if(e in r)return r[e](...n)}return null}function Zg(t,e){if(e in t)return t[e];if("instance"in t){const n=t.instance;if(e in n)return n[e]}return null}class Qg extends Gg{get forceLayoutInstance(){return this.context.layout.getLayoutInstance().find((t=>["d3-force","d3-force-3d"].includes(null==t?void 0:t.id)))}validate(t){return!!this.context.layout&&(this.forceLayoutInstance?super.validate(t):(Tc("DragElementForce only works with d3-force or d3-force-3d layout"),!1))}moveElement(t,e){return ze(this,void 0,void 0,(function*(){const n=this.forceLayoutInstance;this.context.graph.getNodeData(t).forEach(((r,i)=>{const{x:o=0,y:a=0}=r.style||{};n&&Kg(n,"setFixedPosition",t[i],[...Ih([+o,+a],e)])}))}))}onDragStart(t){if(this.enable=this.validate(t),!this.enable)return;this.target=this.getSelectedNodeIDs([t.target.id]),this.hideEdge(),this.context.graph.frontElement(this.target);const e=this.forceLayoutInstance;e&&Zg(e,"simulation").alphaTarget(.3).restart(),this.context.graph.getNodeData(this.target).forEach((t=>{const{x:n=0,y:r=0}=t.style||{};e&&Kg(e,"setFixedPosition",yh(t),[+n,+r])}))}onDrag(t){if(!this.enable)return;const e=this.getDelta(t);this.moveElement(this.target,e)}onDragEnd(){const t=this.forceLayoutInstance;t&&Zg(t,"simulation").alphaTarget(0),this.options.fixed||this.context.graph.getNodeData(this.target).forEach((e=>{t&&Kg(t,"setFixedPosition",yh(e),[null,null,null])}))}}class Jg extends Dh{constructor(t,e){super(t,Object.assign({},Jg.defaultOptions,e)),this.isZoomEvent=t=>Boolean(t.data&&"scale"in t.data),this.relatedEdgeToUpdate=new Set,this.zoom=this.context.graph.getZoom(),this.fixElementSize=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{graph:e}=this.context,{state:n,nodeFilter:r,edgeFilter:i,comboFilter:o}=this.options,a=(n?e.getElementDataByState("node",n):e.getNodeData()).filter(r),s=(n?e.getElementDataByState("edge",n):e.getEdgeData()).filter(i),l=(n?e.getElementDataByState("combo",n):e.getComboData()).filter(o),u=this.isZoomEvent(t)?this.zoom=Math.max(.01,Math.min(t.data.scale,10)):this.zoom,c=[...a,...l];c.length>0&&c.forEach((t=>this.fixNodeLike(t,u))),this.updateRelatedEdges(),s.length>0&&s.forEach((t=>this.fixEdge(t,u)))})),this.cachedStyles=new Map,this.getOriginalFieldValue=(t,e,n)=>{var r;const i=this.cachedStyles.get(t)||[],o=(null===(r=i.find((t=>t.shape===e)))||void 0===r?void 0:r.style)||{};return n in o||(o[n]=e.attributes[n],this.cachedStyles.set(t,[...i.filter((t=>t.shape!==e)),{shape:e,style:o}])),o[n]},this.scaleEntireElement=(t,e,n)=>{e.setLocalScale(1/n);const r=this.cachedStyles.get(t)||[];r.push({shape:e}),this.cachedStyles.set(t,r)},this.scaleSpecificShapes=(t,e,n)=>{const r=function(t){const e=[],n=t=>{(null==t?void 0:t.children.length)&&t.children.forEach((t=>{e.push(t),n(t)}))};return n(t),e}(t);(Array.isArray(n)?n:[n]).forEach((n=>{const{shape:i,fields:o}=n,a="function"==typeof i?i(r):t.getShape(i);a&&(o?o.forEach((n=>{const r=this.getOriginalFieldValue(t.id,a,n);ae(r)&&(a.style[n]=r/e)})):this.scaleEntireElement(t.id,a,e))}))},this.skipIfExceedViewport=t=>{const{viewport:e}=this.context;return!(null==e?void 0:e.isInViewport(t.getRenderBounds(),!1,30))},this.fixNodeLike=(t,e)=>{const n=yh(t),{element:r,model:i}=this.context,o=r.getElement(n);if(!o||this.skipIfExceedViewport(o))return;i.getRelatedEdgesData(n).forEach((t=>this.relatedEdgeToUpdate.add(yh(t))));const a=this.options[o.type];a?this.scaleSpecificShapes(o,e,a):this.scaleEntireElement(n,o,e)},this.fixEdge=(t,e)=>{const n=yh(t),r=this.context.element.getElement(n);if(!r||this.skipIfExceedViewport(r))return;const i=this.options.edge;if(!i)return r.style.transformOrigin="center",void this.scaleEntireElement(n,r,e);this.scaleSpecificShapes(r,e,i)},this.updateRelatedEdges=()=>{const{element:t}=this.context;this.relatedEdgeToUpdate.size>0&&this.relatedEdgeToUpdate.forEach((e=>{const n=t.getElement(e);null==n||n.update({})})),this.relatedEdgeToUpdate.clear()},this.resetTransform=t=>ze(this,void 0,void 0,(function*(){var e;(null===(e=t.data)||void 0===e?void 0:e.firstRender)||(this.options.reset?this.restoreCachedStyles():this.fixElementSize({data:{scale:this.zoom}}))})),this.bindEvents()}restoreCachedStyles(){if(this.cachedStyles.size>0){this.cachedStyles.forEach((t=>{t.forEach((({shape:t,style:e})=>{if(Se(e))t.setLocalScale(1);else{if(this.options.state)return;Object.entries(e).forEach((([e,n])=>t.style[e]=n))}}))}));const{graph:t,element:e}=this.context,n=Object.keys(Object.fromEntries(this.cachedStyles)).filter((e=>e&&"node"===t.getElementType(e)));if(n.length>0){const r=new Set;n.forEach((e=>{t.getRelatedEdgesData(e).forEach((t=>r.add(yh(t))))})),r.forEach((t=>{const n=null==e?void 0:e.getElement(t);null==n||n.update({})}))}}}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.on(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.AFTER_DRAW,this.resetTransform),e.off(t.GraphEvent.AFTER_TRANSFORM,this.fixElementSize)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){this.unbindEvents(),super.destroy()}}Jg.defaultOptions={enable:t=>t.data.scale<1,nodeFilter:()=>!0,edgeFilter:()=>!0,comboFilter:()=>!0,edge:[{shape:"key",fields:["lineWidth"]},{shape:"halo",fields:["lineWidth"]},{shape:"label"}],reset:!1};class tv extends Dh{constructor(t,e){super(t,Object.assign({},tv.defaultOptions,e)),this.focus=t=>ze(this,void 0,void 0,(function*(){if(!this.validate(t))return;const{graph:e}=this.context;yield e.focusElement(t.target.id,this.options.animation)})),this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.forEach((n=>{e.on(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.CLICK}`,this.focus)}))}destroy(){this.unbindEvents(),super.destroy()}}tv.defaultOptions={animation:{easing:"ease-in",duration:500},enable:!0};class ev extends Dh{constructor(e,n){super(e,Object.assign({},ev.defaultOptions,n)),this.isFrozen=!1,this.toggleFrozen=t=>{this.isFrozen="dragstart"===t.type},this.hoverElement=e=>{if(!this.validate(e))return;const n=e.type===t.CommonEvent.POINTER_ENTER;this.updateElementsState(e,n);const{onHover:r,onHoverEnd:i}=this.options;n?null==r||r(e):null==i||i(e)},this.updateElementsState=(t,e)=>{if(!this.options.state&&!this.options.inactiveState)return;const{graph:n}=this.context,{state:r,animation:i,inactiveState:o}=this.options,a=this.getActiveIds(t),s={};if(r&&Object.assign(s,this.getElementsState(a,r,e)),o){const t=xh(n.getData(),!0).filter((t=>!a.includes(t)));Object.assign(s,this.getElementsState(t,o,e))}n.setElementState(s,i)},this.getElementsState=(t,e,n)=>{const{graph:r}=this.context,i={};return t.forEach((t=>{const o=r.getElementState(t);i[t]=n?o.includes(e)?o:[...o,e]:o.filter((t=>t!==e))})),i},this.bindEvents()}bindEvents(){const{graph:e}=this.context;this.unbindEvents(),Ed.forEach((n=>{e.on(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.on(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)}));const n=this.context.canvas.document;n.addEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.addEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}getActiveIds(t){const{graph:e}=this.context,{degree:n,direction:r}=this.options,i=t.target.id;return n?kd(e,t.targetType,i,"function"==typeof n?n(t):n,r):[i]}validate(t){if(this.destroyed||this.isFrozen||Ig(t.target)||this.context.graph.isCollapsingExpanding)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}unbindEvents(){const{graph:e}=this.context;Ed.forEach((n=>{e.off(`${n}:${t.CommonEvent.POINTER_ENTER}`,this.hoverElement),e.off(`${n}:${t.CommonEvent.POINTER_LEAVE}`,this.hoverElement)}));const n=this.context.canvas.document;n.removeEventListener(`${t.CommonEvent.DRAG_START}`,this.toggleFrozen),n.removeEventListener(`${t.CommonEvent.DRAG_END}`,this.toggleFrozen)}destroy(){this.unbindEvents(),super.destroy()}}ev.defaultOptions={animation:!1,enable:!0,degree:0,direction:"both",state:"active",inactiveState:void 0};class nv extends yd{onPointerDown(t){if(!super.validate(t)||!super.isKeydown()||this.points)return;const{canvas:e}=this.context;this.pathShape=new Hl({id:"g6-lasso-select",style:this.options.style}),e.appendChild(this.pathShape),this.points=[bd(t)]}onPointerMove(t){var e;if(!this.points)return;const{immediately:n,mode:r}=this.options;this.points.push(bd(t)),null===(e=this.pathShape)||void 0===e||e.setAttribute("d",function(t,e=!0){const n=[];return t.forEach(((t,e)=>{n.push([0===e?"M":"L",...t])})),e&&n.push(["Z"]),n}(this.points)),n&&"default"===r&&this.points.length>2&&super.updateElementsStates(this.points)}onPointerUp(){this.points&&(this.points.length<2||super.updateElementsStates(this.points),this.clearLasso())}clearLasso(){var t;null===(t=this.pathShape)||void 0===t||t.remove(),this.pathShape=void 0,this.points=void 0}}class rv extends Dh{constructor(t,e){super(t,Object.assign({},rv.defaultOptions,e)),this.hiddenShapes=[],this.isVisible=!0,this.setElementsVisibility=(t,e,n)=>{t.filter(Boolean).forEach((t=>{"hidden"!==e||t.isVisible()?"visible"===e&&this.hiddenShapes.includes(t)?this.hiddenShapes.splice(this.hiddenShapes.indexOf(t),1):Ah(t,e,n):this.hiddenShapes.push(t)}))},this.filterShapes=(t,e)=>{if(Ut(e))return n=>!e(t,n);const n=null==e?void 0:e[t];return t=>!t.className||!(null==n?void 0:n.includes(t.className))},this.hideShapes=t=>{if(!this.validate(t)||!this.isVisible)return;const{element:e}=this.context,{shapes:n={}}=this.options;this.setElementsVisibility(e.getNodes(),"hidden",this.filterShapes("node",n)),this.setElementsVisibility(e.getEdges(),"hidden",this.filterShapes("edge",n)),this.setElementsVisibility(e.getCombos(),"hidden",this.filterShapes("combo",n)),this.isVisible=!1},this.showShapes=ye((t=>{if(!this.validate(t)||this.isVisible)return;const{element:e}=this.context;this.setElementsVisibility(e.getNodes(),"visible"),this.setElementsVisibility(e.getEdges(),"visible"),this.setElementsVisibility(e.getCombos(),"visible"),this.isVisible=!0}),this.options.debounce),this.bindEvents()}bindEvents(){const{graph:e}=this.context;e.on(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.on(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}unbindEvents(){const{graph:e}=this.context;e.off(t.GraphEvent.BEFORE_TRANSFORM,this.hideShapes),e.off(t.GraphEvent.AFTER_TRANSFORM,this.showShapes)}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}update(t){this.unbindEvents(),super.update(t),this.bindEvents()}destroy(){this.unbindEvents(),super.destroy()}}rv.defaultOptions={enable:!0,debounce:200,shapes:t=>"node"===t};class iv extends Dh{constructor(t,e){super(t,Object.assign({},iv.defaultOptions,e)),this.onWheel=t=>ze(this,void 0,void 0,(function*(){this.options.preventDefault&&t.preventDefault();const e=t.deltaX,n=t.deltaY;yield this.scroll([-e,-n],t)})),this.shortcut=new md(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){var e,n;const{trigger:r}=this.options;if(this.shortcut.unbindAll(),qt(r)){null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel);const{up:n=[],down:i=[],left:o=[],right:a=[]}=r;this.shortcut.bind(n,(t=>this.scroll([0,-10],t))),this.shortcut.bind(i,(t=>this.scroll([0,10],t))),this.shortcut.bind(o,(t=>this.scroll([-10,0],t))),this.shortcut.bind(a,(t=>this.scroll([10,0],t)))}else null===(n=this.graphDom)||void 0===n||n.addEventListener(t.CommonEvent.WHEEL,this.onWheel,{passive:!1})}get graphDom(){return this.context.graph.getCanvas().getContextService().getDomElement()}formatDisplacement(t){const{sensitivity:e}=this.options;return t=Bh(t,e),t=this.clampByDirection(t),t=this.clampByRange(t)}clampByDirection([t,e]){const{direction:n}=this.options;return"x"===n?e=0:"y"===n&&(t=0),[t,e]}clampByRange([t,e]){const{viewport:n,canvas:r}=this.context,[i,o]=r.getSize(),[a,s,l,u]=Uc(this.options.range),c=[o*a,i*s,o*l,i*u],h=Qc(Zc(n.getCanvasCenter()),c),d=jh(n.getViewportCenter(),[t,e,0]);if(!th(d,h)){const{min:[n,r],max:[i,o]}=h;(d[0]<n&&t>0||d[0]>i&&t<0)&&(t=0),(d[1]<r&&e>0||d[1]>o&&e<0)&&(e=0)}return[t,e]}scroll(t,e){return ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{onFinish:n}=this.options,r=this.context.graph,i=this.formatDisplacement(t);yield r.translateBy(i,!1),null==n||n()}))}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.graphDom)||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.onWheel),super.destroy()}}iv.defaultOptions={enable:!0,sensitivity:1,preventDefault:!0,range:1/0};class ov extends Dh{constructor(t,e){super(t,Object.assign({},ov.defaultOptions,e)),this.zoom=(t,e,n)=>ze(this,void 0,void 0,(function*(){if(!this.validate(e))return;const{graph:r}=this.context;let i=this.options.origin;!i&&"viewport"in e&&(i=nd(e.viewport));const{sensitivity:o,onFinish:a}=this.options,s=1+oe(t,-50,50)*o/100,l=r.getZoom();yield r.zoomTo(l*s,n,i),null==a||a()})),this.onReset=()=>ze(this,void 0,void 0,(function*(){yield this.context.graph.zoomTo(1,this.options.animation)})),this.preventDefault=t=>{this.options.preventDefault&&t.preventDefault()},this.shortcut=new md(t.graph),this.bindEvents()}update(t){super.update(t),this.bindEvents()}bindEvents(){const{trigger:e}=this.options;if(this.shortcut.unbindAll(),Array.isArray(e))if(e.includes(t.CommonEvent.PINCH))this.shortcut.bind([t.CommonEvent.PINCH],(t=>{this.zoom(t.scale,t,!1)}));else{const n=this.context.canvas.getContainer();null==n||n.addEventListener(t.CommonEvent.WHEEL,this.preventDefault),this.shortcut.bind([...e,t.CommonEvent.WHEEL],(t=>{const{deltaX:e,deltaY:n}=t;this.zoom(-(null!=n?n:e),t,!1)}))}if("object"==typeof e){const{zoomIn:t=[],zoomOut:n=[],reset:r=[]}=e;this.shortcut.bind(t,(t=>this.zoom(10,t,this.options.animation))),this.shortcut.bind(n,(t=>this.zoom(-10,t,this.options.animation))),this.shortcut.bind(r,this.onReset)}}validate(t){if(this.destroyed)return!1;const{enable:e}=this.options;return Ut(e)?e(t):!!e}destroy(){var e;this.shortcut.destroy(),null===(e=this.context.canvas.getContainer())||void 0===e||e.removeEventListener(t.CommonEvent.WHEEL,this.preventDefault),super.destroy()}}ov.defaultOptions={animation:{duration:200},enable:!0,sensitivity:1,trigger:[],preventDefault:!0};var av={assign:Object.assign,getHeight:function(t,e,n,r){return void 0===r&&(r="height"),"center"===n?(t[r]+e[r])/2:t.height}},sv=av,lv={getId:function(t){return t.id||t.name},getPreH:function(t){return t.preH||0},getPreV:function(t){return t.preV||0},getHGap:function(t){return t.hgap||18},getVGap:function(t){return t.vgap||18},getChildren:function(t){return t.children},getHeight:function(t){return t.height||36},getWidth:function(t){var e=t.label||" ";return t.width||18*e.split("").length}};function uv(t,e){var n=this;if(n.vgap=n.hgap=0,t instanceof uv)return t;n.data=t;var r=e.getHGap(t),i=e.getVGap(t);return n.preH=e.getPreH(t),n.preV=e.getPreV(t),n.width=e.getWidth(t),n.height=e.getHeight(t),n.width+=n.preH,n.height+=n.preV,n.id=e.getId(t),n.x=n.y=0,n.depth=0,n.children||(n.children=[]),n.addGap(r,i),n}sv.assign(uv.prototype,{isRoot:function(){return 0===this.depth},isLeaf:function(){return 0===this.children.length},addGap:function(t,e){var n=this;n.hgap+=t,n.vgap+=e,n.width+=2*t,n.height+=2*e},eachNode:function(t){for(var e,n=[this];e=n.shift();)t(e),n=e.children.concat(n)},DFTraverse:function(t){this.eachNode(t)},BFTraverse:function(t){for(var e,n=[this];e=n.shift();)t(e),n=n.concat(e.children)},getBoundingBox:function(){var t={left:Number.MAX_VALUE,top:Number.MAX_VALUE,width:0,height:0};return this.eachNode((function(e){t.left=Math.min(t.left,e.x),t.top=Math.min(t.top,e.y),t.width=Math.max(t.width,e.x+e.width),t.height=Math.max(t.height,e.y+e.height)})),t},translate:function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.eachNode((function(n){n.x+=t,n.y+=e,n.x+=n.preH,n.y+=n.preV}))},right2left:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.x=t.x-2*(t.x-e.left)-t.width})),t.translate(e.width,0)},bottom2top:function(){var t=this,e=t.getBoundingBox();t.eachNode((function(t){t.y=t.y-2*(t.y-e.top)-t.height})),t.translate(0,e.height)}});var cv=function(t,e,n){void 0===e&&(e={});var r,i=new uv(t,e=sv.assign({},lv,e)),o=[i];if(!n&&!t.collapsed)for(;r=o.shift();)if(!r.data.collapsed){var a=e.getChildren(r.data),s=a?a.length:0;if(r.children=new Array(s),a&&s)for(var l=0;l<s;l++){var u=new uv(a[l],e);r.children[l]=u,o.push(u),u.parent=r,u.depth=r.depth+1}}return i},hv=cv,dv=function(){function t(t,e){void 0===e&&(e={});this.options=e,this.rootNode=hv(t,e)}return t.prototype.execute=function(){throw new Error("please override this method")},t}(),fv=dv;function pv(t,e,n,r){void 0===r&&(r=[]);var i=this;i.w=t||0,i.h=e||0,i.y=n||0,i.x=0,i.c=r||[],i.cs=r.length,i.prelim=0,i.mod=0,i.shift=0,i.change=0,i.tl=null,i.tr=null,i.el=null,i.er=null,i.msel=0,i.mser=0}function gv(t,e,n){n?t.y+=e:t.x+=e,t.children.forEach((function(t){gv(t,e,n)}))}function vv(t,e){var n=e?t.y:t.x;return t.children.forEach((function(t){n=Math.min(vv(t,e),n)})),n}function mv(t,e){gv(t,-vv(t,e),e)}function yv(t,e,n){n?e.y=t.x:e.x=t.x,t.c.forEach((function(t,r){yv(t,e.children[r],n)}))}function bv(t,e,n){void 0===n&&(n=0),e?(t.x=n,n+=t.width):(t.y=n,n+=t.height),t.children.forEach((function(t){bv(t,e,n)}))}pv.fromNode=function(t,e){if(!t)return null;var n=[];return t.children.forEach((function(t){n.push(pv.fromNode(t,e))})),e?new pv(t.height,t.width,t.x,n):new pv(t.width,t.height,t.y,n)};var xv=cv,Ev=function(t,e){for(var n=xv(t.data,e,!0),r=xv(t.data,e,!0),i=t.children.length,o=Math.round(i/2),a=e.getSide||function(t,e){return e<o?"right":"left"},s=0;s<i;s++){var l=t.children[s];"right"===a(l,s)?r.children.push(l):n.children.push(l)}return n.eachNode((function(t){t.isRoot()||(t.side="left")})),r.eachNode((function(t){t.isRoot()||(t.side="right")})),{left:n,right:r}},wv=Ev,kv=["LR","RL","TB","BT","H","V"],Mv=["LR","RL","H"],Sv=kv[0],Nv=function(t,e,n){var r=e.direction||Sv;if(e.isHorizontal=function(t){return Mv.indexOf(t)>-1}(r),-1===kv.indexOf(r))throw new TypeError("Invalid direction: "+r);if(r===kv[0])n(t,e);else if(r===kv[1])n(t,e),t.right2left();else if(r===kv[2])n(t,e);else if(r===kv[3])n(t,e),t.bottom2top();else if(r===kv[4]||r===kv[5]){var i=wv(t,e),o=i.left,a=i.right;n(o,e),n(a,e),e.isHorizontal?o.right2left():o.bottom2top(),a.translate(o.x-a.x,o.y-a.y),t.x=o.x,t.y=a.y;var s=t.getBoundingBox();e.isHorizontal?s.top<0&&t.translate(0,-s.top):s.left<0&&t.translate(-s.left,0)}var l=e.fixedRoot;return void 0===l&&(l=!0),l&&t.translate(-(t.x+t.width/2+t.hgap),-(t.y+t.height/2+t.vgap)),function(t,e){if(e.radial){var n=e.isHorizontal?["x","y"]:["y","x"],r=n[0],i=n[1],o={x:1/0,y:1/0},a={x:-1/0,y:-1/0},s=0;t.DFTraverse((function(t){s++;var e=t.x,n=t.y;o.x=Math.min(o.x,e),o.y=Math.min(o.y,n),a.x=Math.max(a.x,e),a.y=Math.max(a.y,n)}));var l=a[i]-o[i];if(0===l)return;var u=2*Math.PI/s;t.DFTraverse((function(e){var n=(e[i]-o[i])/l*(2*Math.PI-u)+u,a=e[r]-t[r];e.x=Math.cos(n)*a,e.y=Math.sin(n)*a}))}}(t,e),t};function Ov(t,e){return Ov=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ov(t,e)}var Tv=function(t,e){void 0===e&&(e={});var n=e.isHorizontal;function r(t){0===t.cs?(t.el=t,t.er=t,t.msel=t.mser=0):(t.el=t.c[0].el,t.msel=t.c[0].msel,t.er=t.c[t.cs-1].er,t.mser=t.c[t.cs-1].mser)}function i(t,e,n){for(var r=t.c[e-1],i=r.mod,u=t.c[e],c=u.mod;null!==r&&null!==u;){l(r)>n.low&&(n=n.nxt);var h=i+r.prelim+r.w-(c+u.prelim);h>0&&(c+=h,o(t,e,n.index,h));var d=l(r),f=l(u);d<=f&&null!==(r=s(r))&&(i+=r.mod),d>=f&&null!==(u=a(u))&&(c+=u.mod)}!r&&u?function(t,e,n,r){var i=t.c[0].el;i.tl=n;var o=r-n.mod-t.c[0].msel;i.mod+=o,i.prelim-=o,t.c[0].el=t.c[e].el,t.c[0].msel=t.c[e].msel}(t,e,u,c):r&&!u&&function(t,e,n,r){var i=t.c[e].er;i.tr=n;var o=r-n.mod-t.c[e].mser;i.mod+=o,i.prelim-=o,t.c[e].er=t.c[e-1].er,t.c[e].mser=t.c[e-1].mser}(t,e,r,i)}function o(t,e,n,r){t.c[e].mod+=r,t.c[e].msel+=r,t.c[e].mser+=r,function(t,e,n,r){if(n!==e-1){var i=e-n;t.c[n+1].shift+=r/i,t.c[e].shift-=r/i,t.c[e].change-=r-r/i}}(t,e,n,r)}function a(t){return 0===t.cs?t.tl:t.c[0]}function s(t){return 0===t.cs?t.tr:t.c[t.cs-1]}function l(t){return t.y+t.h}function u(t,e,n){for(;null!==n&&t>=n.low;)n=n.nxt;return{low:t,index:e,nxt:n}}bv(t,n);var c=pv.fromNode(t,n);return function t(e){if(0!==e.cs){t(e.c[0]);for(var n=u(l(e.c[0].el),0,null),o=1;o<e.cs;++o){t(e.c[o]);var a=l(e.c[o].er);i(e,o,n),n=u(a,o,n)}!function(t){t.prelim=(t.c[0].prelim+t.c[0].mod+t.c[t.cs-1].mod+t.c[t.cs-1].prelim+t.c[t.cs-1].w)/2-t.w/2}(e),r(e)}else r(e)}(c),function t(e,n){n+=e.mod,e.x=e.prelim+n,function(t){for(var e=0,n=0,r=0;r<t.cs;r++)n+=(e+=t.c[r].shift)+t.c[r].change,t.c[r].mod+=n}(e);for(var r=0;r<e.cs;r++)t(e.c[r],n)}(c,0),yv(c,t,n),mv(t,n),t},Cv=Nv,Av=av,Pv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Ov(n,r),e.prototype.execute=function(){return Cv(this.rootNode,this.options,Tv)},e}(fv),Rv={};var Dv=function(t,e){return e=Av.assign({},Rv,e),new Pv(t,e).execute()},Lv=av;function _v(t,e){void 0===e&&(e=[]);var n=this;n.x=n.y=0,n.leftChild=n.rightChild=null,n.height=0,n.children=e}var Iv={isHorizontal:!0,nodeSep:20,nodeSize:20,rankSep:200,subTreeSep:10};function jv(t,e,n){n?(e.x=t.x,e.y=t.y):(e.x=t.y,e.y=t.x),t.children.forEach((function(t,r){jv(t,e.children[r],n)}))}function Bv(t,e){return Bv=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Bv(t,e)}var Fv=function(t,e){void 0===e&&(e={}),e=Lv.assign({},Iv,e);var n,r=0;var i=function t(e){if(!e)return null;e.width=0,e.depth&&e.depth>r&&(r=e.depth);var n=e.children,i=n.length,o=new _v(e.height,[]);return n.forEach((function(e,n){var r=t(e);o.children.push(r),0===n&&(o.leftChild=r),n===i-1&&(o.rightChild=r)})),o.originNode=e,o.isLeaf=e.isLeaf(),o}(t);return function t(e){if(e.isLeaf||0===e.children.length)e.drawingDepth=r;else{var n=e.children.map((function(e){return t(e)})),i=Math.min.apply(null,n);e.drawingDepth=i-1}return e.drawingDepth}(i),function t(r){r.x=r.drawingDepth*e.rankSep,r.isLeaf?(r.y=0,n&&(r.y=n.y+n.height+e.nodeSep,r.originNode.parent!==n.originNode.parent&&(r.y+=e.subTreeSep)),n=r):(r.children.forEach((function(e){t(e)})),r.y=(r.leftChild.y+r.rightChild.y)/2)}(i),jv(i,t,e.isHorizontal),t},zv=Nv,Gv=av,Vv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,Bv(n,r),e.prototype.execute=function(){var t=this;return t.rootNode.width=0,zv(t.rootNode,t.options,Fv)},e}(fv),Wv={};var Hv=function(t,e){return e=Gv.assign({},Wv,e),new Vv(t,e).execute()},Uv=av;function $v(t,e){return $v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$v(t,e)}var Yv=fv,qv=function(t,e,n,r){var i=null;t.eachNode((function(t){!function(t,e,n,r,i){var o=("function"==typeof n?n(t):n)*t.depth;if(!r)try{if(t.id===t.parent.children[0].id)return t.x+=o,void(t.y=e?e.y:0)}catch(t){}if(t.x+=o,e){if(t.y=e.y+Uv.getHeight(e,t,i),e.parent&&t.parent.id!==e.parent.id){var a=e.parent,s=a.y+Uv.getHeight(a,t,i);t.y=s>t.y?s:t.y}}else t.y=0}(t,i,e,n,r),i=t}))},Xv=Ev,Kv=av,Zv=["LR","RL","H"],Qv=Zv[0],Jv=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,$v(n,r),e.prototype.execute=function(){var t=this.options,e=this.rootNode;t.isHorizontal=!0;var n=t.indent,r=void 0===n?20:n,i=t.dropCap,o=void 0===i||i,a=t.direction,s=void 0===a?Qv:a,l=t.align;if(s&&-1===Zv.indexOf(s))throw new TypeError("Invalid direction: "+s);if(s===Zv[0])qv(e,r,o,l);else if(s===Zv[1])qv(e,r,o,l),e.right2left();else if(s===Zv[2]){var u=Xv(e,t),c=u.left,h=u.right;qv(c,r,o,l),c.right2left(),qv(h,r,o,l);var d=c.getBoundingBox();h.translate(d.width,0),e.x=h.x-e.width/2}return e},e}(Yv),tm={};var em=function(t,e){return e=Kv.assign({},tm,e),new Jv(t,e).execute()},nm=av;function rm(t,e){var n=0;return t.children.length?t.children.forEach((function(t){n+=rm(t,e)})):n=t.height,t._subTreeSep=e.getSubTreeSep(t.data),t.totalHeight=Math.max(t.height,n)+2*t._subTreeSep,t.totalHeight}function im(t){var e=t.children,n=e.length;if(n){e.forEach((function(t){im(t)}));var r=e[0],i=e[n-1],o=i.y-r.y+i.height,a=0;if(e.forEach((function(t){a+=t.totalHeight})),o>t.height)t.y=r.y+o/2-t.height/2;else if(1!==e.length||t.height>a){var s=t.y+(t.height-o)/2-r.y;e.forEach((function(t){t.translate(0,s)}))}else t.y=(r.y+r.height/2+i.y+i.height/2)/2-t.height/2}}var om={getSubTreeSep:function(){return 0}};function am(t,e){return am=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},am(t,e)}var sm=function(t,e){void 0===e&&(e={}),e=nm.assign({},om,e),t.parent={x:0,width:0,height:0,y:0},t.BFTraverse((function(t){t.x=t.parent.x+t.parent.width})),t.parent=null,rm(t,e),t.startY=0,t.y=t.totalHeight/2-t.height/2,t.eachNode((function(t){var e=t.children,n=e.length;if(n){var r=e[0];if(r.startY=t.startY+t._subTreeSep,1===n)r.y=t.y+t.height/2-r.height/2;else{r.y=r.startY+r.totalHeight/2-r.height/2;for(var i=1;i<n;i++){var o=e[i];o.startY=e[i-1].startY+e[i-1].totalHeight,o.y=o.startY+o.totalHeight/2-o.height/2}}}})),im(t)},lm=Nv,um=av,cm=function(t){function e(){return t.apply(this,arguments)||this}var n,r;return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,am(n,r),e.prototype.execute=function(){return lm(this.rootNode,this.options,sm)},e}(fv),hm={};var dm=function(t,e){return e=um.assign({},hm,e),new cm(t,e).execute()},fm={compactBox:Dv,dendrogram:Hv,indented:em,mindmap:dm};const pm=(t,e)=>{if("next"!==t&&"prev"!==t)return e},gm=t=>{t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev};let vm=class{constructor(){const t={};t.prev=t,t.next=t.prev,this.shortcut=t}dequeue(){const t=this.shortcut,e=t.prev;if(e&&e!==t)return gm(e),e}enqueue(t){const e=this.shortcut;t.prev&&t.next&&gm(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e}toString(){const t=[],e=this.shortcut;let n=e.prev;for(;n!==e;)t.push(JSON.stringify(n,pm)),n=null==n?void 0:n.prev;return`[${t.join(", ")}]`}},mm=class extends vm{};const ym=()=>1,bm=(t,e,n)=>{let r=[];const i=e[e.length-1],o=e[0];let a;for(;t.getAllNodes().length;){for(;a=o.dequeue();)xm(t,e,n,a);for(;a=i.dequeue();)xm(t,e,n,a);if(t.getAllNodes().length)for(let i=e.length-2;i>0;--i)if(a=e[i].dequeue(),a){r=r.concat(xm(t,e,n,a,!0));break}}return r},xm=(t,e,n,r,i)=>{var o,a;const s=[];return t.hasNode(r.v)&&(null===(o=t.getRelatedEdges(r.v,"in"))||void 0===o||o.forEach((r=>{const o=r.data.weight,a=t.getNode(r.source);i&&s.push({v:r.source,w:r.target,in:0,out:0}),void 0===a.data.out&&(a.data.out=0),a.data.out-=o,wm(e,n,Object.assign({v:a.id},a.data))})),null===(a=t.getRelatedEdges(r.v,"out"))||void 0===a||a.forEach((r=>{const i=r.data.weight,o=r.target,a=t.getNode(o);void 0===a.data.in&&(a.data.in=0),a.data.in-=i,wm(e,n,Object.assign({v:a.id},a.data))})),t.removeNode(r.v)),i?s:void 0},Em=(t,e)=>{const n=new Yg;let r=0,i=0;t.getAllNodes().forEach((t=>{n.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((t=>{const o=n.getRelatedEdges(t.source,"out").find((e=>e.target===t.target)),a=(null==e?void 0:e(t))||1;o?n.updateEdgeData(null==o?void 0:o.id,Object.assign(Object.assign({},o.data),{weight:o.data.weight+a})):n.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:a}}),i=Math.max(i,n.getNode(t.source).data.out+=a),r=Math.max(r,n.getNode(t.target).data.in+=a)}));const o=[],a=i+r+3;for(let t=0;t<a;t++)o.push(new mm);const s=r+1;return n.getAllNodes().forEach((t=>{wm(o,s,Object.assign({v:t.id},n.getNode(t.id).data))})),{buckets:o,zeroIdx:s,graph:n}},wm=(t,e,n)=>{n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)},km=(t,e)=>{const n=((t,e)=>{var n;if(t.getAllNodes().length<=1)return[];const r=Em(t,e||ym);return null===(n=bm(r.graph,r.buckets,r.zeroIdx).map((e=>t.getRelatedEdges(e.v,"out").filter((({target:t})=>t===e.w)))))||void 0===n?void 0:n.flat()})(t,(t=>t.data.weight||1));null==n||n.forEach((e=>{const n=e.data;t.removeEdge(e.id),n.forwardName=e.data.name,n.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign({},n)})}))},Mm=(t,e,n,r)=>{let i;do{i=`${r}${Math.random()}`}while(t.hasNode(i));return n.dummy=e,t.addNode({id:i,data:n}),i},Sm=t=>{const e=new Yg;return t.getAllNodes().forEach((n=>{t.getChildren(n.id).length||e.addNode(Object.assign({},n))})),t.getAllEdges().forEach((t=>{e.addEdge(t)})),e},Nm=(t,e)=>{const n=Number(t.x),r=Number(t.y),i=Number(e.x)-n,o=Number(e.y)-r;let a,s,l=Number(t.width)/2,u=Number(t.height)/2;return i||o?(Math.abs(o)*l>Math.abs(i)*u?(o<0&&(u=-u),a=u*i/o,s=u):(i<0&&(l=-l),a=l,s=l*o/i),{x:n+a,y:r+s}):{x:0,y:0}},Om=t=>{const e=[],n=Cm(t)+1;for(let t=0;t<n;t++)e.push([]);t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&e[n]&&e[n].push(t.id)}));for(let r=0;r<n;r++)e[r]=e[r].sort(((e,n)=>{return r=t.getNode(e).data.order,i=t.getNode(n).data.order,Number(r)-Number(i);var r,i}));return e},Tm=(t,e,n,r)=>{const i={width:0,height:0};return ae(n)&&ae(r)&&(i.rank=n,i.order=r),Mm(t,"border",i,e)},Cm=t=>{let e;return t.getAllNodes().forEach((t=>{const n=t.data.rank;void 0!==n&&(void 0===e||n>e)&&(e=n)})),e||(e=0),e},Am=(t,e)=>t.reduce(((t,n)=>e(t)>e(n)?n:t)),Pm=(t,e,n,r,i,o)=>{r.includes(e.id)||(r.push(e.id),n||o.push(e.id),i(e.id).forEach((e=>Pm(t,e,n,r,i,o))),n&&o.push(e.id))},Rm=(t,e,n,r)=>{const i=Array.isArray(e)?e:[e],o=e=>t.getNeighbors(e),a=[],s=[];return i.forEach((e=>{if(!t.hasNode(e.id))throw new Error(`Graph does not have node: ${e}`);Pm(t,e,"post"===n,s,o,a)})),a},Dm=(t,e,n,r,i,o)=>{const a={rank:o,borderType:e,width:0,height:0},s=i.data[e][o-1],l=Mm(t,"border",a,n);i.data[e][o]=l,t.setParent(l,r),s&&t.addEdge({id:`e${Math.random()}`,source:s,target:l,data:{weight:1}})},Lm=t=>{t.getAllNodes().forEach((t=>{_m(t)})),t.getAllEdges().forEach((t=>{_m(t)}))},_m=t=>{const e=t.data.width;t.data.width=t.data.height,t.data.height=e},Im=t=>{t.getAllNodes().forEach((t=>{jm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>jm(t))),t.data.hasOwnProperty("y")&&jm(t.data)}))},jm=t=>{(null==t?void 0:t.y)&&(t.y=-t.y)},Bm=t=>{t.getAllNodes().forEach((t=>{Fm(t.data)})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>Fm(t))),t.data.hasOwnProperty("x")&&Fm(t.data)}))},Fm=t=>{const e=t.x;t.x=t.y,t.y=e},zm=(t,e,n,r,i,o,a)=>{const s=t.getChildren(a);if(!(null==s?void 0:s.length))return void(a!==e&&t.addEdge({id:`e${Math.random()}`,source:e,target:a,data:{weight:0,minlen:n}}));const l=Tm(t,"_bt"),u=Tm(t,"_bb"),c=t.getNode(a);t.setParent(l,a),c.data.borderTop=l,t.setParent(u,a),c.data.borderBottom=u,null==s||s.forEach((s=>{zm(t,e,n,r,i,o,s.id);const c=s.data.borderTop?s.data.borderTop:s.id,h=s.data.borderBottom?s.data.borderBottom:s.id,d=s.data.borderTop?r:2*r,f=c!==h?1:i-o[a]+1;t.addEdge({id:`e${Math.random()}`,source:l,target:c,data:{minlen:f,weight:d,nestingEdge:!0}}),t.addEdge({id:`e${Math.random()}`,source:h,target:u,data:{minlen:f,weight:d,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:`e${Math.random()}`,source:e,target:l,data:{weight:0,minlen:i+o[a]}})},Gm=t=>{const e={},n=(r,i)=>{const o=t.getChildren(r);null==o||o.forEach((t=>n(t.id,i+1))),e[r]=i};return t.getRoots().forEach((t=>n(t.id,1))),e},Vm=t=>{let e=0;return t.getAllEdges().forEach((t=>{e+=t.data.weight})),e},Wm="edge-label",Hm=(t,e,n)=>{let r=e.source,i=t.getNode(r).data.rank;const o=e.target,a=t.getNode(o).data.rank,s=e.data.labelRank;if(a===i+1)return;let l,u,c;for(t.removeEdge(e.id),c=0,++i;i<a;++c,++i)e.data.points=[],u={originalEdge:e,width:0,height:0,rank:i},l=Mm(t,"edge",u,"_d"),i===s&&(u.width=e.data.width,u.height=e.data.height,u.dummy=Wm,u.labelpos=e.data.labelpos),t.addEdge({id:`e${Math.random()}`,source:r,target:l,data:{weight:e.data.weight}}),0===c&&n.push(l),r=l;t.addEdge({id:`e${Math.random()}`,source:r,target:o,data:{weight:e.data.weight}})},Um=t=>{let e;for(;t.hasNode(e=`_root${Math.random()}`););return e},$m=(t,e,n)=>{const r=((t,e)=>null==t?void 0:t.reduce(((t,n,r)=>(t[n]=e[r],t)),{}))(n,n.map(((t,e)=>e))),i=e.map((e=>{const n=t.getRelatedEdges(e,"out").map((t=>({pos:r[t.target]||0,weight:t.data.weight})));return null==n?void 0:n.sort(((t,e)=>t.pos-e.pos))})),o=i.flat().filter((t=>void 0!==t));let a=1;for(;a<n.length;)a<<=1;const s=2*a-1;a-=1;const l=Array(s).fill(0,0,s);let u=0;return null==o||o.forEach((t=>{if(t){let e=t.pos+a;l[e]+=t.weight;let n=0;for(;e>0;)e%2&&(n+=l[e+1]),e=e-1>>1,l[e]+=t.weight;u+=t.weight*n}})),u},Ym=(t,e)=>{let n=0;for(let r=1;r<(null==e?void 0:e.length);r+=1)n+=$m(t,e[r-1],e[r]);return n},qm=t=>{const e={},n=t.getAllNodes(),r=n.map((t=>{var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),i=Math.max(...r),o=[];for(let t=0;t<i+1;t++)o.push([]);const a=n.sort(((e,n)=>t.getNode(e.id).data.rank-t.getNode(n.id).data.rank)),s=a.filter((e=>void 0!==t.getNode(e.id).data.fixorder)).sort(((e,n)=>t.getNode(e.id).data.fixorder-t.getNode(n.id).data.fixorder));return null==s||s.forEach((n=>{isNaN(t.getNode(n.id).data.rank)||o[t.getNode(n.id).data.rank].push(n.id),e[n.id]=!0})),null==a||a.forEach((n=>t.dfsTree(n.id,(t=>{if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||o[t.data.rank].push(t.id)})))),o},Xm=t=>{var e,n;const r=[];for(;null==t?void 0:t.length;){const i=t.pop();r.push(i),null===(e=i.in.reverse())||void 0===e||e.forEach((t=>{return(e=i,t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Km(e,t)})(t);var e})),null===(n=i.out)||void 0===n||n.forEach((e=>{return(n=i,e=>{e.in.push(n),0===--e.indegree&&t.push(e)})(e);var n}))}const i=r.filter((t=>!t.merged)),o=["vs","i","barycenter","weight"];return i.map((t=>{const e={};return null==o||o.forEach((n=>{void 0!==t[n]&&(e[n]=t[n])})),e}))},Km=(t,e)=>{var n;let r=0,i=0;t.weight&&(r+=t.barycenter*t.weight,i+=t.weight),e.weight&&(r+=e.barycenter*e.weight,i+=e.weight),t.vs=null===(n=e.vs)||void 0===n?void 0:n.concat(t.vs),t.barycenter=r/i,t.weight=i,t.i=Math.min(e.i,t.i),e.merged=!0},Zm=(t,e,n)=>{let r,i=n;for(;e.length&&(r=e[e.length-1]).i<=i;)e.pop(),null==t||t.push(r.vs),i++;return i},Qm=(t,e)=>(n,r)=>{if(void 0!==n.fixorder&&void 0!==r.fixorder)return n.fixorder-r.fixorder;if(n.barycenter<r.barycenter)return-1;if(n.barycenter>r.barycenter)return 1;if(e&&void 0!==n.order&&void 0!==r.order){if(n.order<r.order)return-1;if(n.order>r.order)return 1}return t?r.i-n.i:n.i-r.i},Jm=(t,e,n,r,i,o)=>{var a,s,l,u;let c=t.getChildren(e).map((t=>t.id));const h=t.getNode(e),d=h?h.data.borderLeft:void 0,f=h?h.data.borderRight:void 0,p={};d&&(c=null==c?void 0:c.filter((t=>t!==d&&t!==f)));const g=((t,e)=>e.map((e=>{const n=t.getRelatedEdges(e,"in");if(!(null==n?void 0:n.length))return{v:e};const r={sum:0,weight:0};return null==n||n.forEach((e=>{const n=t.getNode(e.source);r.sum+=e.data.weight*n.data.order,r.weight+=e.data.weight})),{v:e,barycenter:r.sum/r.weight,weight:r.weight}})))(t,c||[]);null==g||g.forEach((e=>{var i;if(null===(i=t.getChildren(e.v))||void 0===i?void 0:i.length){const i=Jm(t,e.v,n,r,o);p[e.v]=i,i.hasOwnProperty("barycenter")&&ey(e,i)}}));const v=((t,e)=>{var n,r,i;const o={};null==t||t.forEach(((t,e)=>{o[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};const n=o[t.v];void 0!==t.barycenter&&(n.barycenter=t.barycenter,n.weight=t.weight)})),null===(n=e.getAllEdges())||void 0===n||n.forEach((t=>{const e=o[t.source],n=o[t.target];void 0!==e&&void 0!==n&&(n.indegree++,e.out.push(o[t.target]))}));const a=null===(i=(r=Object.values(o)).filter)||void 0===i?void 0:i.call(r,(t=>!t.indegree));return Xm(a)})(g,n);ty(v,p),null===(a=v.filter((t=>t.vs.length>0)))||void 0===a||a.forEach((e=>{const n=t.getNode(e.vs[0]);n&&(e.fixorder=n.data.fixorder,e.order=n.data.order)}));const m=((t,e,n,r)=>{const i=((t,e)=>{const n={lhs:[],rhs:[]};return null==t||t.forEach((t=>{e(t)?n.lhs.push(t):n.rhs.push(t)})),n})(t,(t=>{const e=t.hasOwnProperty("fixorder")&&!isNaN(t.fixorder);return r?!e&&t.hasOwnProperty("barycenter"):e||t.hasOwnProperty("barycenter")})),o=i.lhs,a=i.rhs.sort(((t,e)=>-t.i- -e.i)),s=[];let l=0,u=0,c=0;null==o||o.sort(Qm(!!e,!!n)),c=Zm(s,a,c),null==o||o.forEach((t=>{var e;c+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),l+=t.barycenter*t.weight,u+=t.weight,c=Zm(s,a,c)}));const h={vs:s.flat()};return u&&(h.barycenter=l/u,h.weight=u),h})(v,r,i,o);if(d&&(m.vs=[d,m.vs,f].flat(),null===(s=t.getPredecessors(d))||void 0===s?void 0:s.length)){const e=t.getNode((null===(l=t.getPredecessors(d))||void 0===l?void 0:l[0].id)||""),n=t.getNode((null===(u=t.getPredecessors(f))||void 0===u?void 0:u[0].id)||"");m.hasOwnProperty("barycenter")||(m.barycenter=0,m.weight=0),m.barycenter=(m.barycenter*m.weight+e.data.order+n.data.order)/(m.weight+2),m.weight+=2}return m},ty=(t,e)=>{null==t||t.forEach((t=>{var n;const r=null===(n=t.vs)||void 0===n?void 0:n.map((t=>e[t]?e[t].vs:t));t.vs=r.flat()}))},ey=(t,e)=>{void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},ny=(t,e,n)=>e.map((e=>((t,e,n)=>{const r=Um(t),i=new Yg({tree:[{id:r,children:[],data:{}}]});return t.getAllNodes().forEach((o=>{const a=t.getParent(o.id);(o.data.rank===e||o.data.minRank<=e&&e<=o.data.maxRank)&&(i.hasNode(o.id)||i.addNode(Object.assign({},o)),(null==a?void 0:a.id)&&!i.hasNode(null==a?void 0:a.id)&&i.addNode(Object.assign({},a)),i.setParent(o.id,(null==a?void 0:a.id)||r),t.getRelatedEdges(o.id,n).forEach((e=>{const n=e.source===o.id?e.target:e.source;i.hasNode(n)||i.addNode(Object.assign({},t.getNode(n)));const r=i.getRelatedEdges(n,"out").find((({target:t})=>t===o.id)),a=void 0!==r?r.data.weight:0;r?i.updateEdgeData(r.id,Object.assign(Object.assign({},r.data),{weight:e.data.weight+a})):i.addEdge({id:e.id,source:n,target:o.id,data:{weight:e.data.weight+a}})})),o.data.hasOwnProperty("minRank")&&i.updateNodeData(o.id,Object.assign(Object.assign({},o.data),{borderLeft:o.data.borderLeft[e],borderRight:o.data.borderRight[e]})))})),i})(t,e,n))),ry=(t,e,n,r)=>{const i=new Yg;null==t||t.forEach((t=>{var o;const a=t.getRoots()[0].id,s=Jm(t,a,i,e,n,r);for(let e=0;e<(null===(o=s.vs)||void 0===o?void 0:o.length);e++){const n=t.getNode(s.vs[e]);n&&(n.data.order=e)}((t,e,n)=>{const r={};let i;null==n||n.forEach((n=>{let o,a,s=t.getParent(n);for(;s;){if(o=t.getParent(s.id),o?(a=r[o.id],r[o.id]=s.id):(a=i,i=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge(`e${a}-${s.id}`)||e.addEdge({id:`e${a}-${s.id}`,source:a,target:s.id,data:{}}));s=o}}))})(t,i,s.vs)}))},iy=(t,e)=>{null==e||e.forEach((e=>{null==e||e.forEach(((e,n)=>{t.getNode(e).data.order=n}))}))},oy=(t,e)=>{const n=(t=>{const e={};let n=0;const r=i=>{const o=n;t.getChildren(i).forEach((t=>r(t.id))),e[i]={low:o,lim:n++}};return t.getRoots().forEach((t=>r(t.id))),e})(t);e.forEach((e=>{var r,i;let o=e,a=t.getNode(o);const s=a.data.originalEdge;if(!s)return;const l=((t,e,n,r)=>{var i,o;const a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);let c,h;c=n;do{c=null===(i=t.getParent(c))||void 0===i?void 0:i.id,a.push(c)}while(c&&(e[c].low>l||u>e[c].lim));for(h=c,c=r;c&&c!==h;)s.push(c),c=null===(o=t.getParent(c))||void 0===o?void 0:o.id;return{lca:h,path:a.concat(s.reverse())}})(t,n,s.source,s.target),u=l.path,c=l.lca;let h=0,d=u[h],f=!0;for(;o!==s.target;){if(a=t.getNode(o),f){for(;d!==c&&(null===(r=t.getNode(d))||void 0===r?void 0:r.data.maxRank)<a.data.rank;)h++,d=u[h];d===c&&(f=!1)}if(!f){for(;h<u.length-1&&(null===(i=t.getNode(u[h+1]))||void 0===i?void 0:i.data.minRank)<=a.data.rank;)h++;d=u[h]}t.hasNode(d)&&t.setParent(o,d),o=t.getSuccessors(o)[0].id}}))},ay=(t,e)=>{const n={};function r(e,r){const i=function(t){return JSON.stringify(t.slice(1))}(e);r.get(i)||(!function(e,r,i,o,a){var s,l;let u;for(let c=r;c<i;c++)u=e[c],(null===(s=t.getNode(u))||void 0===s?void 0:s.data.dummy)&&(null===(l=t.getPredecessors(u))||void 0===l||l.forEach((e=>{const r=t.getNode(e.id);r.data.dummy&&(r.data.order<o||r.data.order>a)&&ly(n,e.id,u)})))}(...e),r.set(i,!0))}const i=(e,n)=>{let i,o=-1,a=0;const s=new Map;return null==n||n.forEach(((l,u)=>{var c;if("border"===(null===(c=t.getNode(l))||void 0===c?void 0:c.data.dummy)){const e=t.getPredecessors(l)||[];e.length&&(i=t.getNode(e[0].id).data.order,r([n,a,u,o,i],s),a=u,o=i)}r([n,a,n.length,i,e.length],s)})),n};return(null==e?void 0:e.length)&&e.reduce(i),n},sy=(t,e)=>{var n,r;if(null===(n=t.getNode(e))||void 0===n?void 0:n.data.dummy)return null===(r=t.getPredecessors(e))||void 0===r?void 0:r.find((e=>t.getNode(e.id).data.dummy))},ly=(t,e,n)=>{let r=e,i=n;if(r>i){const t=r;r=i,i=t}let o=t[r];o||(t[r]=o={}),o[i]=!0},uy=(t,e,n)=>{let r=e,i=n;if(r>n){r=n,i=e}return!!t[r]},cy=(t,e,n,r,i,o)=>{const a=new Yg,s=hy(r,i,o);return null==e||e.forEach((e=>{let r;null==e||e.forEach((e=>{const i=n[e];if(a.hasNode(i)||a.addNode({id:i,data:{}}),r){const o=n[r],l=a.getRelatedEdges(o,"out").find((t=>t.target===i));l?a.updateEdgeData(l.id,Object.assign(Object.assign({},l.data),{weight:Math.max(s(t,e,r),l.data.weight||0)})):a.addEdge({id:`e${Math.random()}`,source:o,target:i,data:{weight:Math.max(s(t,e,r),0)}})}r=e}))})),a};const hy=(t,e,n)=>(r,i,o)=>{const a=r.getNode(i),s=r.getNode(o);let l=0,u=0;if(l+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":u=-a.data.width/2;break;case"r":u=a.data.width/2}if(u&&(l+=n?u:-u),u=0,l+=(a.data.dummy?e:t)/2,l+=(s.data.dummy?e:t)/2,l+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":u=s.data.width/2;break;case"r":u=-s.data.width/2}return u&&(l+=n?u:-u),u=0,l},dy=(t,e)=>t.getNode(e).data.width||0,fy=(t,e)=>{const{align:n,nodesep:r=0,edgesep:i=0}=e||{},o=Om(t),a=Object.assign(((t,e)=>{const n={},r=(e,r)=>{let i=0,o=0;const a=e.length,s=null==r?void 0:r[(null==r?void 0:r.length)-1];return null==r||r.forEach(((e,l)=>{var u;const c=sy(t,e),h=c?t.getNode(c.id).data.order:a;(c||e===s)&&(null===(u=r.slice(o,l+1))||void 0===u||u.forEach((e=>{var r;null===(r=t.getPredecessors(e))||void 0===r||r.forEach((r=>{var o;const a=t.getNode(r.id),s=a.data.order;!(s<i||h<s)||a.data.dummy&&(null===(o=t.getNode(e))||void 0===o?void 0:o.data.dummy)||ly(n,r.id,e)}))})),o=l+1,i=h)})),r};return(null==e?void 0:e.length)&&e.reduce(r),n})(t,o),ay(t,o)),s={};let l=[];["u","d"].forEach((e=>{l="u"===e?o:Object.values(o).reverse(),["l","r"].forEach((n=>{"r"===n&&(l=l.map((t=>Object.values(t).reverse())));const o=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),u=((t,e,n,r)=>{const i={},o={},a={};return null==e||e.forEach((t=>{null==t||t.forEach(((t,e)=>{i[t]=t,o[t]=t,a[t]=e}))})),null==e||e.forEach((t=>{let e=-1;null==t||t.forEach((t=>{let s=r(t).map((t=>t.id));if(s.length){s=s.sort(((t,e)=>a[t]-a[e]));const r=(s.length-1)/2;for(let l=Math.floor(r),u=Math.ceil(r);l<=u;++l){const r=s[l];o[t]===t&&e<a[r]&&!uy(n,t,r)&&(o[r]=t,o[t]=i[t]=i[r],e=a[r])}}}))})),{root:i,align:o}})(0,l,a,o),c=((t,e,n,r,i,o,a)=>{var s;const l={},u=cy(t,e,n,i,o,a),c=a?"borderLeft":"borderRight",h=(t,e)=>{let n=u.getAllNodes(),r=n.pop();const i={};for(;r;)i[r.id]?t(r.id):(i[r.id]=!0,n.push(r),n=n.concat(e(r.id))),r=n.pop()};return h((t=>{l[t]=(u.getRelatedEdges(t,"in")||[]).reduce(((t,e)=>Math.max(t,(l[e.source]||0)+e.data.weight)),0)}),u.getPredecessors.bind(u)),h((e=>{const n=(u.getRelatedEdges(e,"out")||[]).reduce(((t,e)=>Math.min(t,(l[e.target]||0)-e.data.weight)),Number.POSITIVE_INFINITY),r=t.getNode(e);n!==Number.POSITIVE_INFINITY&&r.data.borderType!==c&&(l[e]=Math.max(l[e],n))}),u.getSuccessors.bind(u)),null===(s=Object.values(r))||void 0===s||s.forEach((t=>{l[t]=l[n[t]]})),l})(t,l,u.root,u.align,r,i,"r"===n);"r"===n&&Object.keys(c).forEach((t=>c[t]=-c[t])),s[e+n]=c}))}));const u=((t,e)=>Am(Object.values(e),(e=>{var n;let r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return null===(n=Object.keys(e))||void 0===n||n.forEach((n=>{const o=e[n],a=dy(t,n)/2;r=Math.max(o+a,r),i=Math.min(o-a,i)})),r-i})))(t,s);return u&&function(t,e){const n=Object.values(e),r=Math.min(...n),i=Math.max(...n);["u","d"].forEach((n=>{["l","r"].forEach((o=>{const a=n+o,s=t[a];let l;if(s===e)return;const u=Object.values(s);l="l"===o?r-Math.min(...u):i-Math.max(...u),l&&(t[a]={},Object.keys(s).forEach((e=>{t[a][e]=s[e]+l})))}))}))}(s,u),((t,e)=>{const n={};return Object.keys(t.ul).forEach((r=>{if(e)n[r]=t[e.toLowerCase()][r];else{const e=Object.values(t).map((t=>t[r]));n[r]=(e[0]+e[1])/2}})),n})(s,n)},py=(t,e)=>{var n;const r=Sm(t);((t,e)=>{const{ranksep:n=0}=e||{},r=Om(t);let i=0;null==r||r.forEach((e=>{const r=e.map((e=>t.getNode(e).data.height)),o=Math.max(...r,0);null==e||e.forEach((e=>{t.getNode(e).data.y=i+o/2})),i+=o+n}))})(r,e);const i=fy(r,e);null===(n=Object.keys(i))||void 0===n||n.forEach((t=>{r.getNode(t).data.x=i[t]}))},gy=t=>{const e={},n=r=>{var i;const o=t.getNode(r);if(!o)return 0;if(e[r])return o.data.rank;let a;return e[r]=!0,null===(i=t.getRelatedEdges(r,"out"))||void 0===i||i.forEach((t=>{const e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),o.data.rank=a,a};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>n(t.id)))},vy=(t,e)=>t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen,my=(t,e)=>{const n=r=>{e.getRelatedEdges(r,"both").forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||vy(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},yy=(t,e)=>{const n=r=>{var i;null===(i=e.getRelatedEdges(r,"both"))||void 0===i||i.forEach((i=>{const o=i.source,a=r===o?i.target:o;t.hasNode(a)||void 0===e.getNode(a).data.layer&&vy(e,i)||(t.addNode({id:a,data:{}}),t.addEdge({id:i.id,source:r,target:a,data:{}}),n(a))}))};return t.getAllNodes().forEach((t=>n(t.id))),t.getAllNodes().length},by=(t,e)=>Am(e.getAllEdges(),(n=>t.hasNode(n.source)!==t.hasNode(n.target)?vy(e,n):1/0)),xy=(t,e,n)=>{t.getAllNodes().forEach((t=>{const r=e.getNode(t.id);r.data.rank||(r.data.rank=0),r.data.rank+=n}))},Ey=t=>{const e=(t=>{const e=new Yg;return t.getAllNodes().forEach((t=>{e.addNode(Object.assign({},t))})),t.getAllEdges().forEach((t=>{const n=e.getRelatedEdges(t.source,"out").find((e=>e.target===t.target));n?e.updateEdgeData(null==n?void 0:n.id,Object.assign(Object.assign({},n.data),{weight:n.data.weight+t.data.weight||0,minlen:Math.max(n.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e})(t);gy(e);const n=(t=>{const e=new Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);my(e,t)<r;)i=by(e,t),o=e.hasNode(i.source)?vy(t,i):-vy(t,i),xy(e,t,o);return e})(e);let r,i;for(Sy(n),wy(n,e);r=Oy(n);)i=Ty(n,e,r),Cy(n,e,r,i)},wy=(t,e)=>{let n=Rm(t,t.getAllNodes(),"post");n=n.slice(0,(null==n?void 0:n.length)-1),n.forEach((n=>{ky(t,e,n)}))},ky=(t,e,n)=>{const r=t.getNode(n).data.parent;t.getRelatedEdges(n,"both").find((t=>t.target===r||t.source===r)).data.cutvalue=My(t,e,n)},My=(t,e,n)=>{const r=t.getNode(n).data.parent;let i=!0,o=e.getRelatedEdges(n,"out").find((t=>t.target===r)),a=0;return o||(i=!1,o=e.getRelatedEdges(r,"out").find((t=>t.target===n))),a=o.data.weight,e.getRelatedEdges(n,"both").forEach((e=>{const o=e.source===n,s=o?e.target:e.source;if(s!==r){const r=o===i,l=e.data.weight;if(a+=r?l:-l,Py(t,n,s)){const e=t.getRelatedEdges(n,"both").find((t=>t.source===s||t.target===s)).data.cutvalue;a+=r?-e:e}}})),a},Sy=(t,e=t.getAllNodes()[0].id)=>{Ny(t,{},1,e)},Ny=(t,e,n,r,i)=>{var o;const a=n;let s=n;const l=t.getNode(r);return e[r]=!0,null===(o=t.getNeighbors(r))||void 0===o||o.forEach((n=>{e[n.id]||(s=Ny(t,e,s,n.id,r))})),l.data.low=a,l.data.lim=s++,i?l.data.parent=i:delete l.data.parent,s},Oy=t=>t.getAllEdges().find((t=>t.data.cutvalue<0)),Ty=(t,e,n)=>{let r=n.source,i=n.target;e.getRelatedEdges(r,"out").find((t=>t.target===i))||(r=n.target,i=n.source);const o=t.getNode(r),a=t.getNode(i);let s=o,l=!1;o.data.lim>a.data.lim&&(s=a,l=!0);const u=e.getAllEdges().filter((e=>l===Ry(t.getNode(e.source),s)&&l!==Ry(t.getNode(e.target),s)));return Am(u,(t=>vy(e,t)))},Cy=(t,e,n,r)=>{const i=t.getRelatedEdges(n.source,"both").find((t=>t.source===n.target||t.target===n.target));i&&t.removeEdge(i.id),t.addEdge({id:`e${Math.random()}`,source:r.source,target:r.target,data:{}}),Sy(t),wy(t,e),Ay(t,e)},Ay=(t,e)=>{const n=t.getAllNodes().find((t=>!t.data.parent));let r=Rm(t,n,"pre");r=r.slice(1),r.forEach((n=>{const r=t.getNode(n).data.parent;let i=e.getRelatedEdges(n,"out").find((t=>t.target===r)),o=!1;!i&&e.hasNode(r)&&(i=e.getRelatedEdges(r,"out").find((t=>t.target===n)),o=!0),e.getNode(n).data.rank=(e.hasNode(r)&&e.getNode(r).data.rank||0)+(o?null==i?void 0:i.data.minlen:-(null==i?void 0:i.data.minlen))}))},Py=(t,e,n)=>t.getRelatedEdges(e,"both").find((t=>t.source===n||t.target===n)),Ry=(t,e)=>e.data.low<=t.data.lim&&t.data.lim<=e.data.lim,Dy=gy,Ly=t=>{(t=>{const e={};let n;const r=i=>{var o;const a=t.getNode(i);if(!a)return 0;if(e[i])return a.data.rank;let s;return e[i]=!0,null===(o=t.getRelatedEdges(i,"out"))||void 0===o||o.forEach((t=>{const e=r(t.target)-t.data.minlen;e&&(void 0===s||e<s)&&(s=e)})),s||(s=0),(void 0===n||s<n)&&(n=s),a.data.rank=s,s};t.getAllNodes().filter((e=>0===t.getRelatedEdges(e.id,"in").length)).forEach((t=>{t&&r(t.id)})),void 0===n&&(n=0);const i={},o=(e,n)=>{var r;const a=t.getNode(e),s=isNaN(a.data.layer)?n:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),i[e]||(i[e]=!0,null===(r=t.getRelatedEdges(e,"out"))||void 0===r||r.forEach((t=>{o(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((t=>{const e=t.data;e&&(isNaN(e.layer)?e.rank-=n:o(t.id,e.layer))}))})(t),(t=>{const e=new Yg({tree:[]}),n=t.getAllNodes()[0],r=t.getAllNodes().length;let i,o;for(e.addNode(n);yy(e,t)<r;)i=by(e,t),o=e.hasNode(i.source)?vy(t,i):-vy(t,i),xy(e,t,o)})(t)},_y=t=>{Ey(t)},Iy=(t,e)=>{const{ranker:n,rankdir:r="tb",nodeOrder:i,keepNodeOrder:o,align:a,nodesep:s=50,edgesep:l=20,ranksep:u=50}=e;tb(t),km(t);const{nestingRoot:c,nodeRankFactor:h}=(t=>{const e=Mm(t,"root",{},"_root"),n=Gm(t);let r=Math.max(...Object.values(n));Math.abs(r)===1/0&&(r=1);const i=r-1,o=2*i+1;t.getAllEdges().forEach((t=>{t.data.minlen*=o}));const a=Vm(t)+1;return t.getRoots().forEach((r=>{zm(t,e,o,a,i,n,r.id)})),{nestingRoot:e,nodeRankFactor:o}})(t);((t,e)=>{switch(e){case"network-simplex":_y(t);break;case"tight-tree":default:Ly(t);break;case"longest-path":Dy(t)}})(Sm(t),n),$y(t),((t,e=0)=>{const n=t.getAllNodes(),r=n.filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),i=Math.min(...r),o=[];n.forEach((t=>{const e=(t.data.rank||0)-i;o[e]||(o[e]=[]),o[e].push(t.id)}));let a=0;for(let n=0;n<o.length;n++){const r=o[n];void 0===r?n%e!==0&&(a-=1):a&&(null==r||r.forEach((e=>{const n=t.getNode(e);n&&(n.data.rank=n.data.rank||0,n.data.rank+=a)})))}})(t,h),((t,e)=>{e&&t.removeNode(e),t.getAllEdges().forEach((e=>{e.data.nestingEdge&&t.removeEdge(e.id)}))})(t,c),(t=>{const e=t.getAllNodes().filter((t=>void 0!==t.data.rank)).map((t=>t.data.rank)),n=Math.min(...e);t.getAllNodes().forEach((t=>{t.data.hasOwnProperty("rank")&&n!==1/0&&(t.data.rank-=n)}))})(t),Yy(t),qy(t);const d=[];((t,e)=>{t.getAllEdges().forEach((n=>Hm(t,n,e)))})(t,d),oy(t,d),(t=>{const e=n=>{const r=t.getChildren(n),i=t.getNode(n);if((null==r?void 0:r.length)&&r.forEach((t=>e(t.id))),i.data.hasOwnProperty("minRank")){i.data.borderLeft=[],i.data.borderRight=[];for(let e=i.data.minRank,r=i.data.maxRank+1;e<r;e+=1)Dm(t,"borderLeft","_bl",n,i,e),Dm(t,"borderRight","_br",n,i,e)}};t.getRoots().forEach((t=>e(t.id)))})(t),o&&((t,e)=>{const n=t.getAllNodes().filter((e=>{var n;return!(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length)})).map((t=>t.data.rank)),r=Math.max(...n),i=[];for(let t=0;t<r+1;t++)i[t]=[];null==e||e.forEach((e=>{const n=t.getNode(e);n&&!n.data.dummy&&(isNaN(n.data.rank)||(n.data.fixorder=i[n.data.rank].length,i[n.data.rank].push(e)))}))})(t,i),((t,e)=>{const n=Cm(t),r=[],i=[];for(let t=1;t<n+1;t++)r.push(t);for(let t=n-1;t>-1;t--)i.push(t);const o=ny(t,r,"in"),a=ny(t,i,"out");let s=qm(t);iy(t,s);let l,u=Number.POSITIVE_INFINITY;for(let n=0,r=0;r<4;++n,++r){ry(n%2?o:a,n%4>=2,!1,e),s=Om(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}s=qm(t),iy(t,s);for(let n=0,r=0;r<4;++n,++r){ry(n%2?o:a,n%4>=2,!0,e),s=Om(t);const i=Ym(t,s);i<u&&(r=0,l=me(s),u=i)}iy(t,l)})(t,o),eb(t),((t,e)=>{const n=e.toLowerCase();"lr"!==n&&"rl"!==n||Lm(t)})(t,r),py(t,{align:a,nodesep:s,edgesep:l,ranksep:u}),nb(t),Jy(t),((t,e)=>{e.forEach((e=>{let n=t.getNode(e);const{data:r}=n,i=r.originalEdge;let o;i&&t.addEdge(i);let a=e;for(;n.data.dummy;)o=t.getSuccessors(a)[0],t.removeNode(a),i.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Wm&&(i.data.x=n.data.x,i.data.y=n.data.y,i.data.width=n.data.width,i.data.height=n.data.height),a=o.id,n=t.getNode(a)}))})(t,d),Zy(t),((t,e)=>{const n=e.toLowerCase();"bt"!==n&&"rl"!==n||Im(t),"lr"!==n&&"rl"!==n||(Bm(t),Lm(t))})(t,r);const{width:f,height:p}=Xy(t);return Ky(t),Qy(t),(t=>{t.getAllEdges().forEach((e=>{const n=e.data;if(n.reversed){t.removeEdge(e.id);const r=n.forwardName;delete n.reversed,delete n.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:Object.assign(Object.assign({},n),{forwardName:r})})}}))})(t),{width:f,height:p}},jy=(t,e)=>{t.getAllNodes().forEach((n=>{const r=t.getNode(n.id);if(e.hasNode(n.id)){const t=e.getNode(n.id);r.data.fixorder=t.data._order,delete t.data._order}else delete r.data.fixorder}))},By=(t,e)=>{t.getAllNodes().forEach((n=>{var r;const i=t.getNode(n.id);if(i){const t=e.getNode(n.id);i.data.x=t.data.x,i.data.y=t.data.y,i.data._order=t.data.order,i.data._rank=t.data.rank,(null===(r=e.getChildren(n.id))||void 0===r?void 0:r.length)&&(i.data.width=t.data.width,i.data.height=t.data.height)}})),t.getAllEdges().forEach((n=>{const r=t.getEdge(n.id),i=e.getEdge(n.id);r.data.points=i?i.data.points:[],i&&i.data.hasOwnProperty("x")&&(r.data.x=i.data.x,r.data.y=i.data.y)}))},Fy=["width","height","layer","fixorder"],zy={width:0,height:0},Gy=["minlen","weight","width","height","labeloffset"],Vy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Wy=["labelpos"],Hy=t=>{const e=new Yg({tree:[]});return t.getAllNodes().forEach((n=>{const r=ib(t.getNode(n.id).data),i=Object.assign(Object.assign({},zy),r),o=rb(i,Fy);e.hasNode(n.id)||e.addNode({id:n.id,data:Object.assign({},o)});const a=t.hasTreeStructure("combo")?t.getParent(n.id,"combo"):t.getParent(n.id);$t(a)||(e.hasNode(a.id)||e.addNode(Object.assign({},a)),e.setParent(n.id,a.id))})),t.getAllEdges().forEach((n=>{const r=ib(t.getEdge(n.id).data),i={};null==Wy||Wy.forEach((t=>{void 0!==r[t]&&(i[t]=r[t])})),e.addEdge({id:n.id,source:n.source,target:n.target,data:Object.assign({},Vy,rb(r,Gy),i)})})),e},Uy=(t,e)=>{const{ranksep:n=0,rankdir:r}=e;return t.getAllNodes().forEach((t=>{isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((t=>{var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===r||"BT"===r?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2},$y=t=>{t.getAllEdges().forEach((e=>{if(e.data.width&&e.data.height){const n=t.getNode(e.source),r={e:e,rank:(t.getNode(e.target).data.rank-n.data.rank)/2+n.data.rank};Mm(t,"edge-proxy",r,"_ep")}}))},Yy=t=>{let e=0;return t.getAllNodes().forEach((n=>{var r,i;n.data.borderTop&&(n.data.minRank=null===(r=t.getNode(n.data.borderTop))||void 0===r?void 0:r.data.rank,n.data.maxRank=null===(i=t.getNode(n.data.borderBottom))||void 0===i?void 0:i.data.rank,e=Math.max(e,n.data.maxRank||-1/0))})),e},qy=t=>{t.getAllNodes().forEach((e=>{"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Xy=(t,e)=>{let n,r,i=0,o=0;const{marginx:a=0,marginy:s=0}={},l=t=>{if(!t.data)return;const e=t.data.x,a=t.data.y,s=t.data.width,l=t.data.height;isNaN(e)||isNaN(s)||(void 0===n&&(n=e-s/2),n=Math.min(n,e-s/2),i=Math.max(i,e+s/2)),isNaN(a)||isNaN(l)||(void 0===r&&(r=a-l/2),r=Math.min(r,a-l/2),o=Math.max(o,a+l/2))};return t.getAllNodes().forEach((t=>{l(t)})),t.getAllEdges().forEach((t=>{(null==t?void 0:t.data.hasOwnProperty("x"))&&l(t)})),n-=a,r-=s,t.getAllNodes().forEach((t=>{t.data.x-=n,t.data.y-=r})),t.getAllEdges().forEach((t=>{var e;null===(e=t.data.points)||void 0===e||e.forEach((t=>{t.x-=n,t.y-=r})),t.data.hasOwnProperty("x")&&(t.data.x-=n),t.data.hasOwnProperty("y")&&(t.data.y-=r)})),{width:i-n+a,height:o-r+s}},Ky=t=>{t.getAllEdges().forEach((e=>{const n=t.getNode(e.source),r=t.getNode(e.target);let i,o;e.data.points?(i=e.data.points[0],o=e.data.points[e.data.points.length-1]):(e.data.points=[],i={x:r.data.x,y:r.data.y},o={x:n.data.x,y:n.data.y}),e.data.points.unshift(Nm(n.data,i)),e.data.points.push(Nm(r.data,o))}))},Zy=t=>{t.getAllEdges().forEach((t=>{if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},Qy=t=>{t.getAllEdges().forEach((t=>{var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},Jy=t=>{t.getAllNodes().forEach((e=>{var n,r,i;if(null===(n=t.getChildren(e.id))||void 0===n?void 0:n.length){const n=t.getNode(e.id),o=t.getNode(n.data.borderTop),a=t.getNode(n.data.borderBottom),s=t.getNode(n.data.borderLeft[(null===(r=n.data.borderLeft)||void 0===r?void 0:r.length)-1]),l=t.getNode(n.data.borderRight[(null===(i=n.data.borderRight)||void 0===i?void 0:i.length)-1]);n.data.width=Math.abs((null==l?void 0:l.data.x)-(null==s?void 0:s.data.x))||10,n.data.height=Math.abs((null==a?void 0:a.data.y)-(null==o?void 0:o.data.y))||10,n.data.x=((null==s?void 0:s.data.x)||0)+n.data.width/2,n.data.y=((null==o?void 0:o.data.y)||0)+n.data.height/2}})),t.getAllNodes().forEach((e=>{"border"===e.data.dummy&&t.removeNode(e.id)}))},tb=t=>{t.getAllEdges().forEach((e=>{if(e.source===e.target){const n=t.getNode(e.source);n.data.selfEdges||(n.data.selfEdges=[]),n.data.selfEdges.push(e),t.removeEdge(e.id)}}))},eb=t=>{const e=Om(t);null==e||e.forEach((e=>{let n=0;null==e||e.forEach(((e,r)=>{var i;const o=t.getNode(e);o.data.order=r+n,null===(i=o.data.selfEdges)||void 0===i||i.forEach((e=>{Mm(t,"selfedge",{width:e.data.width,height:e.data.height,rank:o.data.rank,order:r+ ++n,e:e},"_se")})),delete o.data.selfEdges}))}))},nb=t=>{t.getAllNodes().forEach((e=>{const n=t.getNode(e.id);if("selfedge"===n.data.dummy){const r=t.getNode(n.data.e.source),i=r.data.x+r.data.width/2,o=r.data.y,a=n.data.x-i,s=r.data.height/2;t.hasEdge(n.data.e.id)?t.updateEdgeData(n.data.e.id,n.data.e.data):t.addEdge({id:n.data.e.id,source:n.data.e.source,target:n.data.e.target,data:n.data.e.data}),t.removeNode(e.id),n.data.e.data.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{y:o,x:i+a},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.data.e.data.x=n.data.x,n.data.e.data.y=n.data.y}}))},rb=(t,e)=>{const n={};return null==e||e.forEach((e=>{void 0!==t[e]&&(n[e]=+t[e])})),n},ib=(t={})=>{const e={};return Object.keys(t).forEach((n=>{e[n.toLowerCase()]=t[n]})),e},ob=Array.isArray,ab=t=>{const e=[],n=t.length;for(let r=0;r<n;r+=1){e[r]=[];for(let i=0;i<n;i+=1)r===i?e[r][i]=0:0!==t[r][i]&&t[r][i]?e[r][i]=t[r][i]:e[r][i]=1/0}for(let t=0;t<n;t+=1)for(let r=0;r<n;r+=1)for(let i=0;i<n;i+=1)e[r][i]>e[r][t]+e[t][i]&&(e[r][i]=e[r][t]+e[t][i]);return e},sb=(t,e)=>{const{nodes:n,edges:r}=t,i=[],o={};if(!n)throw new Error("invalid nodes data!");return n&&n.forEach(((t,e)=>{o[t.id]=e;i.push([])})),null==r||r.forEach((t=>{const{source:e,target:n}=t,r=o[e],a=o[n];void 0!==r&&void 0!==a&&(i[r][a]=1,i[a][r]=1)})),i},lb=(t,e)=>Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y)),ub=(t,e,n,r="TB",i,o={})=>{if(!(null==e?void 0:e.length))return;const{stopBranchFn:a,stopAllFn:s}=o;for(let l=0;l<e.length;l++){const u=e[l];if(t.hasNode(u.id)&&!(null==a?void 0:a(u))){if(null==s?void 0:s(u))return;"TB"===r&&n(u),ub(t,t.getChildren(u.id,i),n,r,i,o),"TB"!==r&&n(u)}}},cb=t=>{if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){const e=[];return t.forEach((t=>{e.push(t)})),e.map((t=>cb(t)))}if("object"==typeof t){const e={};return Object.keys(t).forEach((n=>{e[n]=cb(t[n])})),e}return t},hb=(t,e)=>{const n=cb(t);return n.data=n.data||{},e&&(ae(n.data.x)||(n.data.x=Math.random()*e[0]),ae(n.data.y)||(n.data.y=Math.random()*e[1])),n};function db(t){if(!t)return[0,0,0];if(ae(t))return[t,t,t];if(0===t.length)return[0,0,0];const[e,n=e,r=e]=t;return[e,n,r]}function fb(t,e){let n;return n=Ut(e)?e:ae(e)?()=>e:()=>t,n}function pb(t,e,n=!0){return e||0===e?Ut(e)?e:ae(e)?()=>e:Array.isArray(e)?()=>n?Math.max(...e)||t:e:qt(e)&&e.width&&e.height?()=>n?Math.max(e.width,e.height)||t:[e.width,e.height]:()=>t:e=>{const{size:r}=e.data||{};return r?Array.isArray(r)?n?Math.max(...r)||t:r:qt(r)&&r.width&&r.height?n?Math.max(r.width,r.height)||t:[r.width,r.height]:r:t}}const gb=(t,e,n=10)=>{let r;const i="function"==typeof e?e:()=>e||0;r=t?Array.isArray(t)?e=>t:Ut(t)?t:e=>t:t=>{var e,r,i;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return null===(r=t.data)||void 0===r?void 0:r.bboxSize;if(null===(i=t.data)||void 0===i?void 0:i.size){const e=t.data.size;return Array.isArray(e)?e:qt(e)?[e.width,e.height]:e}return n};return t=>{const e=r(t),n=i(t);return Math.max(...db(e))+n}},vb={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null};class mb{constructor(t={}){this.options=t,this.id="antv-dagre",this.options=Object.assign(Object.assign({},vb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,e)}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{nodeSize:i,align:o,rankdir:a="TB",ranksep:s,nodesep:l,ranksepFunc:u,nodesepFunc:c,edgeLabelSpace:h,ranker:d,nodeOrder:f,begin:p,controlPoints:g,radial:v,sortByCombo:m,preset:y}=r,b=new Yg({tree:[]}),x=fb(s||50,u),E=fb(l||50,c);let w=E,k=x;"LR"!==a&&"RL"!==a||(w=x,k=E);const M=pb(10,i,!1),S=e.getAllNodes(),N=e.getAllEdges();let O;S.forEach((t=>{const e=db(M(t)),n=k(t),r=w(t),i=e[0]+2*r,o=e[1]+2*n,a=t.data.layer;ae(a)?b.addNode({id:t.id,data:{width:i,height:o,layer:a}}):b.addNode({id:t.id,data:{width:i,height:o}})})),m&&(b.attachTreeStructure("combo"),S.forEach((t=>{const{parentId:e}=t.data;void 0!==e&&b.hasNode(e)&&b.setParent(t.id,e,"combo")}))),N.forEach((t=>{b.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),(null==y?void 0:y.length)&&(O=new Yg({nodes:y})),((t,e)=>{const{edgeLabelSpace:n,keepNodeOrder:r,prevGraph:i,rankdir:o,ranksep:a}=e;!r&&i&&jy(t,i);const s=Hy(t);let l;n&&(e.ranksep=Uy(s,{rankdir:o,ranksep:a}));try{l=Iy(s,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}By(t,s)})(b,{prevGraph:O,edgeLabelSpace:h,keepNodeOrder:!!f,nodeOrder:f||[],acyclicer:"greedy",ranker:d,rankdir:a,nodesep:l,align:o});const T=[0,0];if(p){let t=1/0,e=1/0;b.getAllNodes().forEach((n=>{t>n.data.x&&(t=n.data.x),e>n.data.y&&(e=n.data.y)})),b.getAllEdges().forEach((n=>{var r;null===(r=n.data.points)||void 0===r||r.forEach((n=>{t>n.x&&(t=n.x),e>n.y&&(e=n.y)}))})),T[0]=p[0]-t,T[1]=p[1]-e}const C="LR"===a||"RL"===a;if(v);else{const t=new Set,e="BT"===a||"RL"===a?(t,e)=>e-t:(t,e)=>t-e;b.getAllNodes().forEach((e=>{e.data.x=e.data.x+T[0],e.data.y=e.data.y+T[1],t.add(C?e.data.x:e.data.y)}));const n=Array.from(t).sort(e),r=C?(t,e)=>t.x!==e.x:(t,e)=>t.y!==e.y,i=C?(t,e,n)=>{const r=Math.max(e.y,n.y),i=Math.min(e.y,n.y);return t.filter((t=>t.y<=r&&t.y>=i))}:(t,e,n)=>{const r=Math.max(e.x,n.x),i=Math.min(e.x,n.x);return t.filter((t=>t.x<=r&&t.x>=i))};b.getAllEdges().forEach(((t,e)=>{var o;h&&g&&"loop"!==t.data.type&&(t.data.controlPoints=yb(null===(o=t.data.points)||void 0===o?void 0:o.map((({x:t,y:e})=>({x:t+T[0],y:e+T[1]}))),b.getNode(t.source),b.getNode(t.target),n,C,r,i))}))}let A=[];A=b.getAllNodes().map((t=>hb(t)));const P=b.getAllEdges();t&&(A.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),P.forEach((t=>{e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})})));return{nodes:A,edges:P}}))}}const yb=(t,e,n,r,i,o,a)=>{let s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&n){let{x:t,y:l}=e.data,{x:u,y:c}=n.data;if(i&&(t=e.data.y,l=e.data.x,u=n.data.y,c=n.data.x),c!==l&&t!==u){const h=r.indexOf(l),d=r[h+1];if(d){const t=s[0],e=i?{x:(l+d)/2,y:(null==t?void 0:t.y)||u}:{x:(null==t?void 0:t.x)||u,y:(l+d)/2};t&&!o(t,e)||s.unshift(e)}const f=r.indexOf(c),p=Math.abs(f-h);if(1===p)s=a(s,e.data,n.data),s.length||s.push(i?{x:(l+c)/2,y:t}:{x:t,y:(l+c)/2});else if(p>1){const e=r[f-1];if(e){const n=s[s.length-1],r=i?{x:(c+e)/2,y:(null==n?void 0:n.y)||u}:{x:(null==n?void 0:n.x)||t,y:(c+e)/2};n&&!o(n,r)||s.push(r)}}}}return s},bb=(t,e,n)=>{const r=t.getAllNodes(),i=t.getAllEdges();if(!(null==r?void 0:r.length)){return{nodes:[],edges:i}}if(1===r.length){e&&t.mergeNodeData(r[0].id,{x:n[0],y:n[1]});return{nodes:[Object.assign(Object.assign({},r[0]),{data:Object.assign(Object.assign({},r[0].data),{x:n[0],y:n[1]})})],edges:i}}},xb={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1};class Eb{constructor(t={}){this.options=t,this.id="circular",this.options=Object.assign(Object.assign({},xb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericCircularLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericCircularLayout(!0,t,e)}))}genericCircularLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,divisions:s,startAngle:l=0,endAngle:u=2*Math.PI,angleRatio:c,ordering:h,clockwise:d,nodeSpacing:f,nodeSize:p}=r,g=e.getAllNodes(),v=e.getAllEdges(),[m,y,b]=kb(i,o,a),x=null==g?void 0:g.length;if(!x||1===x)return bb(e,t,b);const E=(u-l)/x;let{radius:w,startRadius:k,endRadius:M}=r;if(f){const t=fb(10,f),e=pb(10,p);let n=-1/0;g.forEach((t=>{const r=e(t);n<r&&(n=r)}));let r=0;g.forEach(((e,i)=>{r+=0===i?n||10:(t(e)||0)+(n||10)})),w=r/(2*Math.PI)}else w||k||M?!k&&M?k=M:k&&!M&&(M=k):w=Math.min(y,m)/2;const S=E*c;let N=[];N="topology"===h?wb(e,g):"topology-directed"===h?wb(e,g,!0):"degree"===h?function(t,e){const n=[];return e.forEach(((t,e)=>{n.push(hb(t))})),n.sort(((e,n)=>t.getDegree(e.id,"both")-t.getDegree(n.id,"both"))),n}(e,g):g.map((t=>hb(t)));const O=Math.ceil(x/s);for(let t=0;t<x;++t){let e=w;e||null===k||null===M||(e=k+t*(M-k)/(x-1)),e||(e=10+100*t/(x-1));let n=l+t%O*S+2*Math.PI/s*Math.floor(t/O);d||(n=u-t%O*S-2*Math.PI/s*Math.floor(t/O)),N[t].data.x=b[0]+Math.cos(n)*e,N[t].data.y=b[1]+Math.sin(n)*e}t&&N.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:N,edges:v}}))}}const wb=(t,e,n=!1)=>{const r=[hb(e[0])],i={},o=e.length;i[e[0].id]=!0;let a=0;return e.forEach(((s,l)=>{if(0!==l)if(l!==o-1&&t.getDegree(s.id,"both")===t.getDegree(e[l+1].id,"both")&&!t.areNeighbors(r[a].id,s.id)||i[s.id]){const l=n?t.getSuccessors(r[a].id):t.getNeighbors(r[a].id);let u=!1;for(let e=0;e<l.length;e++){const n=l[e];if(t.getDegree(n.id)===t.getDegree(s.id)&&!i[n.id]){r.push(hb(n)),i[n.id]=!0,u=!0;break}}let c=0;for(;!u&&(i[e[c].id]||(r.push(hb(e[c])),i[e[c].id]=!0,u=!0),c++,c!==o););}else r.push(hb(s)),i[s.id]=!0,a++})),r};const kb=(t,e,n)=>{let r=t,i=e,o=n;return r||"undefined"==typeof window||(r=window.innerWidth),i||"undefined"==typeof window||(i=window.innerHeight),o||(o=[r/2,i/2]),[r,i,o]},Mb={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"};class Sb{constructor(t={}){this.options=t,this.id="concentric",this.options=Object.assign(Object.assign({},Mb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericConcentricLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericConcentricLayout(!0,t,e)}))}genericConcentricLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a,sortBy:s,maxLevelDiff:l,sweep:u,clockwise:c,equidistant:h,preventOverlap:d,startAngle:f=1.5*Math.PI,nodeSize:p,nodeSpacing:g}=r,v=e.getAllNodes(),m=e.getAllEdges(),y=o||"undefined"==typeof window?o:window.innerWidth,b=a||"undefined"==typeof window?a:window.innerHeight,x=i||[y/2,b/2];if(!(null==v?void 0:v.length)||1===v.length)return bb(e,t,x);const E=[];let w,k=0;ob(p)?w=Math.max(p[0],p[1]):Ut(p)?(w=-1/0,v.forEach((t=>{const e=Math.max(...db(p(t)));e>w&&(w=e)}))):w=p,ob(g)?k=Math.max(g[0],g[1]):ae(g)&&(k=g),v.forEach((t=>{const e=hb(t);E.push(e);let n=w;const{data:r}=e;ob(r.size)?n=Math.max(r.size[0],r.size[1]):ae(r.size)?n=r.size:qt(r.size)&&(n=Math.max(r.size.width,r.size.height)),w=Math.max(w,n),Ut(g)&&(k=Math.max(g(t),k))}));const M={};E.forEach(((t,e)=>{M[t.id]=e}));let S=s;ne(S)&&void 0!==E[0].data[S]||(S="degree"),"degree"===S?E.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):E.sort(((t,e)=>e.data[S]-t.data[S]));const N=E[0],O=(l||("degree"===S?e.getDegree(N.id,"both"):N.data[S]))/4,T=[{nodes:[]}];let C=T[0];E.forEach((t=>{if(C.nodes.length>0){const n="degree"===S?Math.abs(e.getDegree(C.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(C.nodes[0].data[S]-t.data[S]);O&&n>=O&&(C={nodes:[]},T.push(C))}C.nodes.push(t)}));let A=w+k;if(!d){const t=T.length>0&&T[0].nodes.length>1,e=(Math.min(y,b)/2-A)/(T.length+(t?1:0));A=Math.min(A,e)}let P=0;if(T.forEach((t=>{const e=void 0===u?2*Math.PI-2*Math.PI/t.nodes.length:u;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&d){const e=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),r=Math.sqrt(A*A/(e*e+n*n));P=Math.max(r,P)}t.r=P,P+=A})),h){let t=0,e=0;for(let n=0;n<T.length;n++){const r=(T[n].r||0)-e;t=Math.max(t,r)}e=0,T.forEach(((n,r)=>{0===r&&(e=n.r||0),n.r=e,e+=t}))}T.forEach((t=>{const e=t.dTheta||0,n=t.r||0;t.nodes.forEach(((t,r)=>{const i=f+(c?1:-1)*e*r;t.data.x=x[0]+n*Math.cos(i),t.data.y=x[1]+n*Math.sin(i)}))})),t&&E.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:E,edges:m}}))}}function Nb(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,l,u,c,h,d,f=t._root,p={data:r},g=t._x0,v=t._y0,m=t._x1,y=t._y1;if(!f)return t._root=p,t;for(;f.length;)if((u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a,i=f,!(f=f[h=c<<1|u]))return i[h]=p,t;if(s=+t._x.call(null,f.data),l=+t._y.call(null,f.data),e===s&&n===l)return p.next=f,i?i[h]=p:t._root=p,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(u=e>=(o=(g+m)/2))?g=o:m=o,(c=n>=(a=(v+y)/2))?v=a:y=a}while((h=c<<1|u)==(d=(l>=a)<<1|s>=o));return i[d]=f,i[h]=p,t}function Ob(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i}function Tb(t){return t[0]}function Cb(t){return t[1]}function Ab(t,e,n){var r=new Pb(null==e?Tb:e,null==n?Cb:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Pb(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Rb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Db=Ab.prototype=Pb.prototype;function Lb(t,e,n,r,i){if(isNaN(e)||isNaN(n)||isNaN(r))return t;var o,a,s,l,u,c,h,d,f,p,g,v,m=t._root,y={data:i},b=t._x0,x=t._y0,E=t._z0,w=t._x1,k=t._y1,M=t._z1;if(!m)return t._root=y,t;for(;m.length;)if((d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l,o=m,!(m=m[g=p<<2|f<<1|d]))return o[g]=y,t;if(u=+t._x.call(null,m.data),c=+t._y.call(null,m.data),h=+t._z.call(null,m.data),e===u&&n===c&&r===h)return y.next=m,o?o[g]=y:t._root=y,t;do{o=o?o[g]=new Array(8):t._root=new Array(8),(d=e>=(a=(b+w)/2))?b=a:w=a,(f=n>=(s=(x+k)/2))?x=s:k=s,(p=r>=(l=(E+M)/2))?E=l:M=l}while((g=p<<2|f<<1|d)==(v=(h>=l)<<2|(c>=s)<<1|u>=a));return o[v]=m,o[g]=y,t}function _b(t,e,n,r,i,o,a){this.node=t,this.x0=e,this.y0=n,this.z0=r,this.x1=i,this.y1=o,this.z1=a}Db.copy=function(){var t,e,n=new Pb(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=Rb(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=Rb(e));return n},Db.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t);return Nb(this.cover(e,n),e,n,t)},Db.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),l=1/0,u=1/0,c=-1/0,h=-1/0;for(n=0;n<o;++n)isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<l&&(l=r),r>c&&(c=r),i<u&&(u=i),i>h&&(h=i));if(l>c||u>h)return this;for(this.cover(l,u).cover(c,h),n=0;n<o;++n)Nb(this,a[n],s[n],t[n]);return this},Db.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else{for(var a,s,l=i-n||1,u=this._root;n>t||t>=i||r>e||e>=o;)switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=u,u=a,l*=2,s){case 0:i=n+l,o=r+l;break;case 1:n=i-l,o=r+l;break;case 2:i=n+l,r=o-l;break;case 3:n=i-l,r=o-l}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this},Db.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Db.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},Db.find=function(t,e,n){var r,i,o,a,s,l,u,c=this._x0,h=this._y0,d=this._x1,f=this._y1,p=[],g=this._root;for(g&&p.push(new Ob(g,c,h,d,f)),null==n?n=1/0:(c=t-n,h=e-n,d=t+n,f=e+n,n*=n);l=p.pop();)if(!(!(g=l.node)||(i=l.x0)>d||(o=l.y0)>f||(a=l.x1)<c||(s=l.y1)<h))if(g.length){var v=(i+a)/2,m=(o+s)/2;p.push(new Ob(g[3],v,m,a,s),new Ob(g[2],i,m,v,s),new Ob(g[1],v,o,a,m),new Ob(g[0],i,o,v,m)),(u=(e>=m)<<1|t>=v)&&(l=p[p.length-1],p[p.length-1]=p[p.length-1-u],p[p.length-1-u]=l)}else{var y=t-+this._x.call(null,g.data),b=e-+this._y.call(null,g.data),x=y*y+b*b;if(x<n){var E=Math.sqrt(n=x);c=t-E,h=e-E,d=t+E,f=e+E,r=g.data}}return r},Db.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,l,u,c,h,d,f=this._root,p=this._x0,g=this._y0,v=this._x1,m=this._y1;if(!f)return this;if(f.length)for(;;){if((u=o>=(s=(p+v)/2))?p=s:v=s,(c=a>=(l=(g+m)/2))?g=l:m=l,e=f,!(f=f[h=c<<1|u]))return this;if(!f.length)break;(e[h+1&3]||e[h+2&3]||e[h+3&3])&&(n=e,d=h)}for(;f.data!==t;)if(r=f,!(f=f.next))return this;return(i=f.next)&&delete f.next,r?(i?r.next=i:delete r.next,this):e?(i?e[h]=i:delete e[h],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(n?n[d]=f:this._root=f),this):(this._root=i,this)},Db.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Db.root=function(){return this._root},Db.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Db.visit=function(t){var e,n,r,i,o,a,s=[],l=this._root;for(l&&s.push(new Ob(l,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(l=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&l.length){var u=(r+o)/2,c=(i+a)/2;(n=l[3])&&s.push(new Ob(n,u,c,o,a)),(n=l[2])&&s.push(new Ob(n,r,c,u,a)),(n=l[1])&&s.push(new Ob(n,u,i,o,c)),(n=l[0])&&s.push(new Ob(n,r,i,u,c))}return this},Db.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new Ob(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,l=e.x1,u=e.y1,c=(a+l)/2,h=(s+u)/2;(o=i[0])&&n.push(new Ob(o,a,s,c,h)),(o=i[1])&&n.push(new Ob(o,c,s,l,h)),(o=i[2])&&n.push(new Ob(o,a,h,c,u)),(o=i[3])&&n.push(new Ob(o,c,h,l,u))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},Db.x=function(t){return arguments.length?(this._x=t,this):this._x},Db.y=function(t){return arguments.length?(this._y=t,this):this._y};const Ib=(t,e,n,r,i,o)=>Math.sqrt((t-r)**2+(e-i)**2+(n-o)**2);function jb(t){return t[0]}function Bb(t){return t[1]}function Fb(t){return t[2]}function zb(t,e,n,r){var i=new Gb(null==e?jb:e,null==n?Bb:n,null==r?Fb:r,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?i:i.addAll(t)}function Gb(t,e,n,r,i,o,a,s,l){this._x=t,this._y=e,this._z=n,this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=l,this._root=void 0}function Vb(t){for(var e={data:t.data},n=e;t=t.next;)n=n.next={data:t.data};return e}var Wb=zb.prototype=Gb.prototype;Wb.copy=function(){var t,e,n=new Gb(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),r=this._root;if(!r)return n;if(!r.length)return n._root=Vb(r),n;for(t=[{source:r,target:n._root=new Array(8)}];r=t.pop();)for(var i=0;i<8;++i)(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(8)}):r.target[i]=Vb(e));return n},Wb.add=function(t){const e=+this._x.call(null,t),n=+this._y.call(null,t),r=+this._z.call(null,t);return Lb(this.cover(e,n,r),e,n,r,t)},Wb.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,n=new Float64Array(e),r=new Float64Array(e),i=new Float64Array(e);let o=1/0,a=1/0,s=1/0,l=-1/0,u=-1/0,c=-1/0;for(let h,d,f,p,g=0;g<e;++g)isNaN(d=+this._x.call(null,h=t[g]))||isNaN(f=+this._y.call(null,h))||isNaN(p=+this._z.call(null,h))||(n[g]=d,r[g]=f,i[g]=p,d<o&&(o=d),d>l&&(l=d),f<a&&(a=f),f>u&&(u=f),p<s&&(s=p),p>c&&(c=p));if(o>l||a>u||s>c)return this;this.cover(o,a,s).cover(l,u,c);for(let o=0;o<e;++o)Lb(this,n[o],r[o],i[o],t[o]);return this},Wb.cover=function(t,e,n){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(n=+n))return this;var r=this._x0,i=this._y0,o=this._z0,a=this._x1,s=this._y1,l=this._z1;if(isNaN(r))a=(r=Math.floor(t))+1,s=(i=Math.floor(e))+1,l=(o=Math.floor(n))+1;else{for(var u,c,h=a-r||1,d=this._root;r>t||t>=a||i>e||e>=s||o>n||n>=l;)switch(c=(n<o)<<2|(e<i)<<1|t<r,(u=new Array(8))[c]=d,d=u,h*=2,c){case 0:a=r+h,s=i+h,l=o+h;break;case 1:r=a-h,s=i+h,l=o+h;break;case 2:a=r+h,i=s-h,l=o+h;break;case 3:r=a-h,i=s-h,l=o+h;break;case 4:a=r+h,s=i+h,o=l-h;break;case 5:r=a-h,s=i+h,o=l-h;break;case 6:a=r+h,i=s-h,o=l-h;break;case 7:r=a-h,i=s-h,o=l-h}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=i,this._z0=o,this._x1=a,this._y1=s,this._z1=l,this},Wb.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Wb.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Wb.find=function(t,e,n,r){var i,o,a,s,l,u,c,h,d,f=this._x0,p=this._y0,g=this._z0,v=this._x1,m=this._y1,y=this._z1,b=[],x=this._root;for(x&&b.push(new _b(x,f,p,g,v,m,y)),null==r?r=1/0:(f=t-r,p=e-r,g=n-r,v=t+r,m=e+r,y=n+r,r*=r);h=b.pop();)if(!(!(x=h.node)||(o=h.x0)>v||(a=h.y0)>m||(s=h.z0)>y||(l=h.x1)<f||(u=h.y1)<p||(c=h.z1)<g))if(x.length){var E=(o+l)/2,w=(a+u)/2,k=(s+c)/2;b.push(new _b(x[7],E,w,k,l,u,c),new _b(x[6],o,w,k,E,u,c),new _b(x[5],E,a,k,l,w,c),new _b(x[4],o,a,k,E,w,c),new _b(x[3],E,w,s,l,u,k),new _b(x[2],o,w,s,E,u,k),new _b(x[1],E,a,s,l,w,k),new _b(x[0],o,a,s,E,w,k)),(d=(n>=k)<<2|(e>=w)<<1|t>=E)&&(h=b[b.length-1],b[b.length-1]=b[b.length-1-d],b[b.length-1-d]=h)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),N=n-+this._z.call(null,x.data),O=M*M+S*S+N*N;if(O<r){var T=Math.sqrt(r=O);f=t-T,p=e-T,g=n-T,v=t+T,m=e+T,y=n+T,i=x.data}}return i},Wb.findAllWithinRadius=function(t,e,n,r){const i=[],o=t-r,a=e-r,s=n-r,l=t+r,u=e+r,c=n+r;return this.visit(((h,d,f,p,g,v,m)=>{if(!h.length)do{const o=h.data;Ib(t,e,n,this._x(o),this._y(o),this._z(o))<=r&&i.push(o)}while(h=h.next);return d>l||f>u||p>c||g<o||v<a||m<s})),i},Wb.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,n,r,i,o,a,s,l,u,c,h,d,f,p,g,v=this._root,m=this._x0,y=this._y0,b=this._z0,x=this._x1,E=this._y1,w=this._z1;if(!v)return this;if(v.length)for(;;){if((h=o>=(l=(m+x)/2))?m=l:x=l,(d=a>=(u=(y+E)/2))?y=u:E=u,(f=s>=(c=(b+w)/2))?b=c:w=c,e=v,!(v=v[p=f<<2|d<<1|h]))return this;if(!v.length)break;(e[p+1&7]||e[p+2&7]||e[p+3&7]||e[p+4&7]||e[p+5&7]||e[p+6&7]||e[p+7&7])&&(n=e,g=p)}for(;v.data!==t;)if(r=v,!(v=v.next))return this;return(i=v.next)&&delete v.next,r?(i?r.next=i:delete r.next,this):e?(i?e[p]=i:delete e[p],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(n?n[g]=v:this._root=v),this):(this._root=i,this)},Wb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e)this.remove(t[e]);return this},Wb.root=function(){return this._root},Wb.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Wb.visit=function(t){var e,n,r,i,o,a,s,l,u=[],c=this._root;for(c&&u.push(new _b(c,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=u.pop();)if(!t(c=e.node,r=e.x0,i=e.y0,o=e.z0,a=e.x1,s=e.y1,l=e.z1)&&c.length){var h=(r+a)/2,d=(i+s)/2,f=(o+l)/2;(n=c[7])&&u.push(new _b(n,h,d,f,a,s,l)),(n=c[6])&&u.push(new _b(n,r,d,f,h,s,l)),(n=c[5])&&u.push(new _b(n,h,i,f,a,d,l)),(n=c[4])&&u.push(new _b(n,r,i,f,h,d,l)),(n=c[3])&&u.push(new _b(n,h,d,o,a,s,f)),(n=c[2])&&u.push(new _b(n,r,d,o,h,s,f)),(n=c[1])&&u.push(new _b(n,h,i,o,a,d,f)),(n=c[0])&&u.push(new _b(n,r,i,o,h,d,f))}return this},Wb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new _b(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,l=e.z0,u=e.x1,c=e.y1,h=e.z1,d=(a+u)/2,f=(s+c)/2,p=(l+h)/2;(o=i[0])&&n.push(new _b(o,a,s,l,d,f,p)),(o=i[1])&&n.push(new _b(o,d,s,l,u,f,p)),(o=i[2])&&n.push(new _b(o,a,f,l,d,c,p)),(o=i[3])&&n.push(new _b(o,d,f,l,u,c,p)),(o=i[4])&&n.push(new _b(o,a,s,p,d,f,h)),(o=i[5])&&n.push(new _b(o,d,s,p,u,f,h)),(o=i[6])&&n.push(new _b(o,a,f,p,d,c,h)),(o=i[7])&&n.push(new _b(o,d,f,p,u,c,h))}r.push(e)}for(;e=r.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Wb.x=function(t){return arguments.length?(this._x=t,this):this._x},Wb.y=function(t){return arguments.length?(this._y=t,this):this._y},Wb.z=function(t){return arguments.length?(this._z=t,this):this._z};function Hb(t,e,n,r,i=2){const o=e/n,a=t.getAllNodes(),s=a.map(((t,e)=>{const{nodeStrength:n,x:r,y:i,z:a,size:s}=t.data;return{x:r,y:i,z:a,size:s,index:e,id:t.id,vx:0,vy:0,vz:0,weight:o*n}})),l=(2===i?Ab(s,(t=>t.x),(t=>t.y)):zb(s,(t=>t.x),(t=>t.y),(t=>t.z))).visitAfter(Ub),u=new Map;return s.forEach((t=>{u.set(t.id,t),function(t,e,n){e.visit(((e,r,i,o,a)=>$b(e,r,i,o,a,t,n)))}(t,l,i)})),s.map(((t,e)=>{const{id:n,data:i}=a[e],{mass:o=1}=i;r[n]={x:t.vx/o,y:t.vy/o,z:t.vz/o}})),r}function Ub(t){let e=0,n=0,r=0,i=0,o=0;const a=t.length;if(a){for(let s=0;s<a;s++){const a=t[s];a&&a.weight&&(e+=a.weight,n+=a.x*a.weight,r+=a.y*a.weight,i+=a.z*a.weight,o+=a.size*a.weight)}t.x=n/e,t.y=r/e,t.z=i/e,t.size=o/e,t.weight=e}else{const e=t;t.x=e.data.x,t.y=e.data.y,t.z=e.data.z,t.size=e.data.size,t.weight=e.data.weight}}const $b=(t,e,n,r,i,o,a)=>{var s;if((null===(s=t.data)||void 0===s?void 0:s.id)===o.id)return;const l=[n,r,i][a-1],u=o.x-t.x||.1,c=o.y-t.y||.1,h=o.z-t.z||.1,d=[u,c,h],f=l-e;let p=0;for(let t=0;t<a;t++)p+=d[t]*d[t];const g=Math.sqrt(p)*p;if(f*f*.81<p){const e=t.weight/g;return o.vx+=u*e,o.vy+=c*e,o.vz+=h*e,!0}if(t.length)return!1;if(t.data!==o){const e=t.data.weight/g;o.vx+=u*e,o.vy+=c*e,o.vz+=h*e}};const Yb={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"};class qb{constructor(t={}){this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=Object.assign(Object.assign({},Yb),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;(this.judgingDistance>this.lastOptions.minMovement||e<1)&&e<t;e++)this.runOneStep(this.lastCalcGraph,this.lastGraph,e,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericForceLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),i=e.getAllNodes(),o=e.getAllEdges(),a=this.formatOptions(r,e),{dimensions:s,width:l,height:u,nodeSize:c,getMass:h,nodeStrength:d,edgeStrength:f,linkDistance:p}=a,g=i.map(((t,e)=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{x:ae(t.data.x)?t.data.x:Math.random()*l,y:ae(t.data.y)?t.data.y:Math.random()*u,z:ae(t.data.z)?t.data.z:Math.random()*Math.sqrt(l*u),size:c(t)||30,mass:h(t),nodeStrength:d(t)})}))),v=o.map((t=>Object.assign(Object.assign({},t),{data:Object.assign(Object.assign({},t.data),{edgeStrength:f(t),linkDistance:p(t,e.getNode(t.source),e.getNode(t.target))})})));if(!(null==i?void 0:i.length))return this.lastResult={nodes:[],edges:o},{nodes:[],edges:o};const m={};i.forEach(((t,e)=>{m[t.id]={x:0,y:0,z:0}}));const y=new Yg({nodes:g,edges:v});this.formatCentripetal(a,y);const{maxIteration:b,minMovement:x,onTick:E}=a;if(this.lastLayoutNodes=g,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=y,this.lastOptions=a,this.lastVelMap=m,"undefined"==typeof window)return;let w=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{i&&this.running||n({nodes:Jb(e,g),edges:o}),this.runOneStep(y,e,w,m,a),this.updatePosition(e,y,m,a),t&&g.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===s?t.data.z:void 0}))),null==E||E({nodes:Jb(e,g),edges:o}),w++,(w>=b||this.judgingDistance<x)&&(window.clearInterval(this.timeInterval),n({nodes:Jb(e,g),edges:o}))}),0),this.running=!0}))}))}formatOptions(t,e){const n=Object.assign({},t),{width:r,height:i,getMass:o}=t;n.width=r||"undefined"==typeof window?r:window.innerWidth,n.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(n.center=[n.width/2,n.height/2]),o||(n.getMass=t=>{let n=1;ae(null==t?void 0:t.data.mass)&&(n=null==t?void 0:t.data.mass);const r=e.getDegree(t.id,"both");return!r||r<5?n:5*r*n}),n.nodeSize=gb(t.nodeSize,t.nodeSpacing);const a=t.linkDistance?fb(1,t.linkDistance):t=>1+n.nodeSize(e.getNode(t.source))+n.nodeSize(e.getNode(t.target));return n.linkDistance=a,n.nodeStrength=fb(1,t.nodeStrength),n.edgeStrength=fb(1,t.edgeStrength),n}formatCentripetal(t,e){const{dimensions:n,centripetalOptions:r,center:i,clusterNodeStrength:o,leafCluster:a,clustering:s,nodeClusterBy:l}=t,u=e.getAllNodes(),c=r||{leaf:2,single:2,others:1,center:t=>({x:i[0],y:i[1],z:3===n?i[2]:void 0})};let h,d;if("function"!=typeof o&&(t.clusterNodeStrength=t=>o),a&&l&&(h=Xb(e,l),d=Array.from(new Set(null==u?void 0:u.map((t=>t.data[l]))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:e=>{const{siblingLeaves:n,sameTypeLeaves:r}=h[e.id]||{};return(null==r?void 0:r.length)===(null==n?void 0:n.length)||1===(null==d?void 0:d.length)?1:t.clusterNodeStrength(e)},others:1,center:t=>{const n=e.getDegree(t.id,"both");if(!n)return{x:100,y:100,z:0};let r;if(1===n){const{sameTypeLeaves:e=[]}=h[t.id]||{};1===e.length?r=void 0:e.length>1&&(r=Qb(e))}else r=void 0;return{x:null==r?void 0:r.x,y:null==r?void 0:r.y,z:null==r?void 0:r.z}}})),s&&l){h||(h=Xb(e,l)),d||(d=Array.from(new Set(u.map((t=>t.data[l]))))),d=d.filter((t=>void 0!==t));const n={};d.forEach((t=>{const r=u.filter((e=>e.data[l]===t)).map((t=>e.getNode(t.id)));n[t]=Qb(r)})),t.centripetalOptions=Object.assign(c,{single:e=>t.clusterNodeStrength(e),leaf:e=>t.clusterNodeStrength(e),others:e=>t.clusterNodeStrength(e),center:t=>{const e=n[t.data[l]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}const{leaf:f,single:p,others:g}=t.centripetalOptions||{};f&&"function"!=typeof f&&(t.centripetalOptions.leaf=()=>f),p&&"function"!=typeof p&&(t.centripetalOptions.single=()=>p),g&&"function"!=typeof g&&(t.centripetalOptions.others=()=>g)}runOneStep(t,e,n,r,i){const o={},a=t.getAllNodes(),s=t.getAllEdges();if(!(null==a?void 0:a.length))return;const{monitor:l}=i;if(this.calRepulsive(t,o,i),s&&this.calAttractive(t,o,i),this.calGravity(t,e,o,i),this.updateVelocity(t,o,r,i),l){l({energy:this.calTotalEnergy(o,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:n})}}calTotalEnergy(t,e){if(!(null==e?void 0:e.length))return 0;let n=0;return e.forEach(((e,r)=>{const i=t[e.id].x,o=t[e.id].y,a=3===this.options.dimensions?t[e.id].z:0,s=i*i+o*o+a*a,{mass:l=1}=e.data;n+=l*s*.5})),n}calRepulsive(t,e,n){const{dimensions:r,factor:i,coulombDisScale:o}=n;Hb(t,i,o*o,e,r)}calAttractive(t,e,n){const{dimensions:r,nodeSize:i}=n;t.getAllEdges().forEach(((n,o)=>{const{source:a,target:s}=n,l=t.getNode(a),u=t.getNode(s);if(!l||!u)return;let c=u.data.x-l.data.x,h=u.data.y-l.data.y,d=3===r?u.data.z-l.data.z:0;c||h||(c=.01*Math.random(),h=.01*Math.random(),3!==r||d||(d=.01*Math.random()));const f=Math.sqrt(c*c+h*h+d*d);if(f<i(l)+i(u))return;const p=c/f,g=h/f,v=d/f,{linkDistance:m=200,edgeStrength:y=200}=n.data||{},b=(m-f)*y,x=1/(l.data.mass||1),E=1/(u.data.mass||1),w=p*b,k=g*b,M=v*b;e[a].x-=w*x,e[a].y-=k*x,e[a].z-=M*x,e[s].x+=w*E,e[s].y+=k*E,e[s].z+=M*E}))}calGravity(t,e,n,r){const{getCenter:i}=r,o=t.getAllNodes(),a=e.getAllNodes(),s=e.getAllEdges(),{width:l,height:u,center:c,gravity:h,centripetalOptions:d}=r;o&&o.forEach((r=>{const{id:o,data:f}=r,{mass:p,x:g,y:v,z:m}=f,y=e.getNode(o);let b=0,x=0,E=0,w=h;const k=t.getDegree(o,"in"),M=t.getDegree(o,"out"),S=t.getDegree(o,"both"),N=null==i?void 0:i(y,S);if(N){const[t,e,n]=N;b=g-t,x=v-e,w=n}else b=g-c[0],x=v-c[1],E=m-c[2];if(w&&(n[o].x-=w*b/p,n[o].y-=w*x/p,n[o].z-=w*E/p),d){const{leaf:t,single:e,others:r,center:i}=d,{x:c,y:h,z:f,centerStrength:b}=(null==i?void 0:i(y,a,s,l,u))||{x:0,y:0,z:0,centerStrength:0};if(!ae(c)||!ae(h))return;const x=(g-c)/p,E=(v-h)/p,w=(m-f)/p;if(b&&(n[o].x-=b*x,n[o].y-=b*E,n[o].z-=b*w),0===S){const t=e(y);if(!t)return;return n[o].x-=t*x,n[o].y-=t*E,void(n[o].z-=t*w)}if(0===k||0===M){const e=t(y,a,s);if(!e)return;return n[o].x-=e*x,n[o].y-=e*E,void(n[o].z-=e*w)}const N=r(y);if(!N)return;n[o].x-=N*x,n[o].y-=N*E,n[o].z-=N*w}}))}updateVelocity(t,e,n,r){const{damping:i,maxSpeed:o,interval:a,dimensions:s}=r,l=t.getAllNodes();(null==l?void 0:l.length)&&l.forEach((t=>{const{id:r}=t;let l=(n[r].x+e[r].x*a)*i||.01,u=(n[r].y+e[r].y*a)*i||.01,c=3===s?(n[r].z+e[r].z*a)*i||.01:0;const h=Math.sqrt(l*l+u*u+c*c);if(h>o){const t=o/h;l*=t,u*=t,c*=t}n[r]={x:l,y:u,z:c}}))}updatePosition(t,e,n,r){const{distanceThresholdMode:i,interval:o,dimensions:a}=r,s=e.getAllNodes();if(!(null==s?void 0:s.length))return void(this.judgingDistance=0);let l=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((r=>{const{id:s}=r,u=t.getNode(s);if(ae(u.data.fx)&&ae(u.data.fy))return void e.mergeNodeData(s,{x:u.data.fx,y:u.data.fy,z:3===a?u.data.fz:void 0});const c=n[s].x*o,h=n[s].y*o,d=3===a?n[s].z*o:0;e.mergeNodeData(s,{x:r.data.x+c,y:r.data.y+h,z:r.data.z+d});const f=Math.sqrt(c*c+h*h+d*d);switch(i){case"max":this.judgingDistance<f&&(this.judgingDistance=f);break;case"min":this.judgingDistance>f&&(this.judgingDistance=f);break;default:l+=f}})),i&&"mean"!==i||(this.judgingDistance=l/s.length)}}const Xb=(t,e)=>{const n=t.getAllNodes();if(!(null==n?void 0:n.length))return{};const r={};return n.forEach(((n,i)=>{1===t.getDegree(n.id,"both")&&(r[n.id]=Kb(t,"leaf",n,e))})),r},Kb=(t,e,n,r)=>{const i=t.getDegree(n.id,"in"),o=t.getDegree(n.id,"out");let a=n,s=[];0===i?(a=t.getSuccessors(n.id)[0],s=t.getNeighbors(a.id)):0===o&&(a=t.getPredecessors(n.id)[0],s=t.getNeighbors(a.id)),s=s.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")));return{coreNode:a,siblingLeaves:s,sameTypeLeaves:Zb(t,e,r,n,s)}},Zb=(t,e,n,r,i)=>{const o=r.data[n]||"";let a=(null==i?void 0:i.filter((t=>t.data[n]===o)))||[];return a=a.filter((e=>0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out"))),a},Qb=t=>{const e={x:0,y:0};t.forEach((t=>{const{x:n,y:r}=t.data;e.x+=n||0,e.y+=r||0}));const n=t.length||1;return{x:e.x/n,y:e.y/n}},Jb=(t,e)=>e.map((e=>{const{id:n,data:r}=e,i=t.getNode(n);return Object.assign(Object.assign({},i),{data:Object.assign(Object.assign({},i.data),{x:r.x,y:r.y,z:r.z})})}));var tx={};const ex=Object.prototype.toString;function nx(t){const e=ex.call(t);return e.endsWith("Array]")&&!e.includes("Big")}var rx=w(Object.freeze({__proto__:null,isAnyArray:nx}));var ix=Object.freeze({__proto__:null,default:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==n.output){if(!nx(n.output))throw new TypeError("output option must be an array if specified");e=n.output}else e=new Array(t.length);var r=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]<a&&(a=t[s]);return a}(t),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!nx(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var n=e.fromIndex,r=void 0===n?0:n,i=e.toIndex,o=void 0===i?t.length:i;if(r<0||r>=t.length||!Number.isInteger(r))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=r||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[r],s=r+1;s<o;s++)t[s]>a&&(a=t[s]);return a}(t);if(r===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=n.min,a=void 0===o?n.autoMinMax?r:0:o,s=n.max,l=void 0===s?n.autoMinMax?i:1:s;if(a>=l)throw new RangeError("min option must be smaller than max option");for(var u=(l-a)/(i-r),c=0;c<t.length;c++)e[c]=(t[c]-r)*u+a;return e}}),ox=w(ix);Object.defineProperty(tx,"__esModule",{value:!0});var ax=rx,sx=ox;const lx=" ".repeat(2),ux=" ".repeat(4);function cx(t,e={}){const{maxRows:n=15,maxColumns:r=10,maxNumSize:i=8,padMinus:o="auto"}=e;return`${t.constructor.name} {\n${lx}[\n${ux}${function(t,e,n,r,i){const{rows:o,columns:a}=t,s=Math.min(o,e),l=Math.min(a,n),u=[];if("auto"===i){i=!1;t:for(let e=0;e<s;e++)for(let n=0;n<l;n++)if(t.get(e,n)<0){i=!0;break t}}for(let e=0;e<s;e++){let n=[];for(let o=0;o<l;o++)n.push(hx(t.get(e,o),r,i));u.push(`${n.join(" ")}`)}l!==a&&(u[u.length-1]+=` ... ${a-n} more columns`);s!==o&&u.push(`... ${o-e} more rows`);return u.join(`\n${ux}`)}(t,n,r,i,o)}\n${lx}]\n${lx}rows: ${t.rows}\n${lx}columns: ${t.columns}\n}`}function hx(t,e,n){return(t>=0&&n?` ${dx(t,e-1)}`:dx(t,e)).padEnd(e)}function dx(t,e){let n=t.toString();if(n.length<=e)return n;let r=t.toFixed(e);if(r.length>e&&(r=t.toFixed(Math.max(0,e-(r.length-e)))),r.length<=e&&!r.startsWith("0.000")&&!r.startsWith("-0.000"))return r;let i=t.toExponential(e);return i.length>e&&(i=t.toExponential(Math.max(0,e-(i.length-e)))),i.slice(0)}function fx(t,e,n){let r=n?t.rows:t.rows-1;if(e<0||e>r)throw new RangeError("Row index out of range")}function px(t,e,n){let r=n?t.columns:t.columns-1;if(e<0||e>r)throw new RangeError("Column index out of range")}function gx(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function vx(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function mx(t,e){if(!ax.isAnyArray(e))throw new TypeError("row indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.rows)throw new RangeError("row indices are out of range")}function yx(t,e){if(!ax.isAnyArray(e))throw new TypeError("column indices must be an array");for(let n=0;n<e.length;n++)if(e[n]<0||e[n]>=t.columns)throw new RangeError("column indices are out of range")}function bx(t,e,n,r,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(Ex("startRow",e),Ex("endRow",n),Ex("startColumn",r),Ex("endColumn",i),e>n||r>i||e<0||e>=t.rows||n<0||n>=t.rows||r<0||r>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function xx(t,e=0){let n=[];for(let r=0;r<t;r++)n.push(e);return n}function Ex(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function wx(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class kx{static from1DArray(t,e,n){if(t*e!==n.length)throw new RangeError("data length does not match given dimensions");let r=new Sx(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.set(i,t,n[i*e+t]);return r}static rowVector(t){let e=new Sx(1,t.length);for(let n=0;n<t.length;n++)e.set(0,n,t[n]);return e}static columnVector(t){let e=new Sx(t.length,1);for(let n=0;n<t.length;n++)e.set(n,0,t[n]);return e}static zeros(t,e){return new Sx(t,e)}static ones(t,e){return new Sx(t,e).fill(1)}static rand(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{random:r=Math.random}=n;let i=new Sx(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.set(n,t,r());return i}static randInt(t,e,n={}){if("object"!=typeof n)throw new TypeError("options must be an object");const{min:r=0,max:i=1e3,random:o=Math.random}=n;if(!Number.isInteger(r))throw new TypeError("min must be an integer");if(!Number.isInteger(i))throw new TypeError("max must be an integer");if(r>=i)throw new RangeError("min must be smaller than max");let a=i-r,s=new Sx(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++){let e=r+Math.round(o()*a);s.set(n,t,e)}return s}static eye(t,e,n){void 0===e&&(e=t),void 0===n&&(n=1);let r=Math.min(t,e),i=this.zeros(t,e);for(let t=0;t<r;t++)i.set(t,t,n);return i}static diag(t,e,n){let r=t.length;void 0===e&&(e=r),void 0===n&&(n=e);let i=Math.min(r,e,n),o=this.zeros(e,n);for(let e=0;e<i;e++)o.set(e,e,t[e]);return o}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new Sx(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.min(t.get(o,n),e.get(o,n)));return i}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let n=t.rows,r=t.columns,i=new this(n,r);for(let o=0;o<n;o++)for(let n=0;n<r;n++)i.set(o,n,Math.max(t.get(o,n),e.get(o,n)));return i}static checkMatrix(t){return kx.isMatrix(t)?t:new Sx(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.call(this,e,n);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.push(this.get(e,n));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let n=0;n<this.columns;n++)t[e].push(this.get(e,n))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isDistance(){if(!this.isSymmetric())return!1;for(let t=0;t<this.rows;t++)if(0!==this.get(t,t))return!1;return!0}isEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);t++}return r}isReducedEchelonForm(){let t=0,e=0,n=-1,r=!0,i=!1;for(;t<this.rows&&r;){for(e=0,i=!1;e<this.columns&&!1===i;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>n?(i=!0,n=e):(r=!1,i=!0);for(let n=e+1;n<this.rows;n++)0!==this.get(t,n)&&(r=!1);t++}return r}echelonForm(){let t=this.clone(),e=0,n=0;for(;e<t.rows&&n<t.columns;){let r=e;for(let i=e;i<t.rows;i++)t.get(i,n)>t.get(r,n)&&(r=i);if(0===t.get(r,n))n++;else{t.swapRows(e,r);let i=t.get(e,n);for(let r=n;r<t.columns;r++)t.set(e,r,t.get(e,r)/i);for(let r=e+1;r<t.rows;r++){let i=t.get(r,n)/t.get(e,n);t.set(r,n,0);for(let o=n+1;o<t.columns;o++)t.set(r,o,t.get(r,o)-t.get(e,o)*i)}e++,n++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,n=t.rows,r=n-1;for(;r>=0;)if(0===t.maxRow(r))r--;else{let i=0,o=!1;for(;i<n&&!1===o;)1===t.get(r,i)?o=!0:i++;for(let n=0;n<r;n++){let o=t.get(n,i);for(let a=i;a<e;a++){let e=t.get(n,a)-o*t.get(r,a);t.set(n,a,e)}}r--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:n=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(n)||n<=0)throw new TypeError("columns must be a positive integer");let r=new Sx(this.rows*e,this.columns*n);for(let t=0;t<e;t++)for(let e=0;e<n;e++)r.setSubMatrix(this,this.rows*t,this.columns*e);return r}fill(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,t);return this}neg(){return this.mulS(-1)}getRow(t){fx(this,t);let e=[];for(let n=0;n<this.columns;n++)e.push(this.get(t,n));return e}getRowVector(t){return Sx.rowVector(this.getRow(t))}setRow(t,e){fx(this,t),e=gx(this,e);for(let n=0;n<this.columns;n++)this.set(t,n,e[n]);return this}swapRows(t,e){fx(this,t),fx(this,e);for(let n=0;n<this.columns;n++){let r=this.get(t,n);this.set(t,n,this.get(e,n)),this.set(e,n,r)}return this}getColumn(t){px(this,t);let e=[];for(let n=0;n<this.rows;n++)e.push(this.get(n,t));return e}getColumnVector(t){return Sx.columnVector(this.getColumn(t))}setColumn(t,e){px(this,t),e=vx(this,e);for(let n=0;n<this.rows;n++)this.set(n,t,e[n]);return this}swapColumns(t,e){px(this,t),px(this,e);for(let n=0;n<this.rows;n++){let r=this.get(n,t);this.set(n,t,this.get(n,e)),this.set(n,e,r)}return this}addRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[n]);return this}subRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[n]);return this}mulRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[n]);return this}divRowVector(t){t=gx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[n]);return this}addColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t[e]);return this}subColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t[e]);return this}mulColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t[e]);return this}divColumnVector(t){t=vx(this,t);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t[e]);return this}mulRow(t,e){fx(this,t);for(let n=0;n<this.columns;n++)this.set(t,n,this.get(t,n)*e);return this}mulColumn(t,e){px(this,t);for(let n=0;n<this.rows;n++)this.set(n,t,this.get(n,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)>t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){wx(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)>t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[e]&&(t[e]=this.get(e,n));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t[n]&&(t[n]=this.get(e,n));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.get(e,n)<t&&(t=this.get(e,n));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){wx(this);let t=this.get(0,0),e=[0,0];for(let n=0;n<this.rows;n++)for(let r=0;r<this.columns;r++)this.get(n,r)<t&&(t=this.get(n,r),e[0]=n,e[1]=r);return e}maxRow(t){if(fx(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n));return e}maxRowIndex(t){fx(this,t),wx(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r),n[1]=r);return n}minRow(t){if(fx(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n));return e}minRowIndex(t){fx(this,t),wx(this);let e=this.get(t,0),n=[t,0];for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r),n[1]=r);return n}maxColumn(t){if(px(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t));return e}maxColumnIndex(t){px(this,t),wx(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t),n[0]=r);return n}minColumn(t){if(px(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t));return e}minColumnIndex(t){px(this,t),wx(this);let e=this.get(0,t),n=[0,t];for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t),n[0]=r);return n}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let n=0;n<t;n++)e.push(this.get(n,n));return e}norm(t="frobenius"){switch(t){case"max":return this.max();case"frobenius":return Math.sqrt(this.dot(this));default:throw new RangeError(`unknown norm type: ${t}`)}}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t+=this.get(e,n),this.set(e,n,t);return this}dot(t){kx.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let n=0;for(let r=0;r<e.length;r++)n+=e[r]*t[r];return n}mmul(t){t=Sx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.columns,i=new Sx(e,r),o=new Float64Array(n);for(let a=0;a<r;a++){for(let e=0;e<n;e++)o[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let r=0;r<n;r++)e+=this.get(t,r)*o[r];i.set(t,a,e)}}return i}mpow(t){if(!this.isSquare())throw new RangeError("Matrix must be square");if(!Number.isInteger(t)||t<0)throw new RangeError("Exponent must be a non-negative integer");let e=Sx.eye(this.rows),n=this;for(let r=t;r>=1;r/=2)1&r&&(e=e.mmul(n)),n=n.mmul(n);return e}strassen2x2(t){t=Sx.checkMatrix(t);let e=new Sx(2,2);const n=this.get(0,0),r=t.get(0,0),i=this.get(0,1),o=t.get(0,1),a=this.get(1,0),s=t.get(1,0),l=this.get(1,1),u=t.get(1,1),c=(n+l)*(r+u),h=(a+l)*r,d=n*(o-u),f=l*(s-r),p=(n+i)*u,g=c+f-p+(i-l)*(s+u),v=d+p,m=h+f,y=c-h+d+(a-n)*(r+o);return e.set(0,0,g),e.set(0,1,v),e.set(1,0,m),e.set(1,1,y),e}strassen3x3(t){t=Sx.checkMatrix(t);let e=new Sx(3,3);const n=this.get(0,0),r=this.get(0,1),i=this.get(0,2),o=this.get(1,0),a=this.get(1,1),s=this.get(1,2),l=this.get(2,0),u=this.get(2,1),c=this.get(2,2),h=t.get(0,0),d=t.get(0,1),f=t.get(0,2),p=t.get(1,0),g=t.get(1,1),v=t.get(1,2),m=t.get(2,0),y=t.get(2,1),b=t.get(2,2),x=(n-o)*(-d+g),E=(-n+o+a)*(h-d+g),w=(o+a)*(-h+d),k=n*h,M=(-n+l+u)*(h-f+v),S=(-n+l)*(f-v),N=(l+u)*(-h+f),O=(-i+u+c)*(g+m-y),T=(i-c)*(g-y),C=i*m,A=(u+c)*(-m+y),P=(-i+a+s)*(v+m-b),R=(i-s)*(v-b),D=(a+s)*(-m+b),L=k+C+r*p,_=(n+r+i-o-a-u-c)*g+E+w+k+O+C+A,I=k+M+N+(n+r+i-a-s-l-u)*v+C+P+D,j=x+a*(-h+d+p-g-v-m+b)+E+k+C+P+R,B=x+E+w+k+s*y,F=C+P+R+D+o*f,z=k+M+S+u*(-h+f+p-g-v-m+y)+O+T+C,G=O+T+C+A+l*d,V=k+M+S+N+c*b;return e.set(0,0,L),e.set(0,1,_),e.set(0,2,I),e.set(1,0,j),e.set(1,1,B),e.set(1,2,F),e.set(2,0,z),e.set(2,1,G),e.set(2,2,V),e}mmulStrassen(t){t=Sx.checkMatrix(t);let e=this.clone(),n=e.rows,r=e.columns,i=t.rows,o=t.columns;function a(t,e,n){let r=t.rows,i=t.columns;if(r===e&&i===n)return t;{let r=kx.zeros(e,n);return r=r.setSubMatrix(t,0,0),r}}r!==i&&console.warn(`Multiplying ${n} x ${r} and ${i} x ${o} matrix: dimensions do not match.`);let s=Math.max(n,i),l=Math.max(r,o);return e=a(e,s,l),function t(e,n,r,i){if(r<=512||i<=512)return e.mmul(n);r%2==1&&i%2==1?(e=a(e,r+1,i+1),n=a(n,r+1,i+1)):r%2==1?(e=a(e,r+1,i),n=a(n,r+1,i)):i%2==1&&(e=a(e,r,i+1),n=a(n,r,i+1));let o=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),l=e.subMatrix(0,o-1,0,s-1),u=n.subMatrix(0,o-1,0,s-1),c=e.subMatrix(0,o-1,s,e.columns-1),h=n.subMatrix(0,o-1,s,n.columns-1),d=e.subMatrix(o,e.rows-1,0,s-1),f=n.subMatrix(o,n.rows-1,0,s-1),p=e.subMatrix(o,e.rows-1,s,e.columns-1),g=n.subMatrix(o,n.rows-1,s,n.columns-1),v=t(kx.add(l,p),kx.add(u,g),o,s),m=t(kx.add(d,p),u,o,s),y=t(l,kx.sub(h,g),o,s),b=t(p,kx.sub(f,u),o,s),x=t(kx.add(l,c),g,o,s),E=t(kx.sub(d,l),kx.add(u,h),o,s),w=t(kx.sub(c,p),kx.add(f,g),o,s),k=kx.add(v,b);k.sub(x),k.add(w);let M=kx.add(y,x),S=kx.add(m,b),N=kx.sub(v,m);N.add(y),N.add(E);let O=kx.zeros(2*k.rows,2*k.columns);return O=O.setSubMatrix(k,0,0),O=O.setSubMatrix(M,k.rows,0),O=O.setSubMatrix(S,0,k.columns),O=O.setSubMatrix(N,k.rows,k.columns),O.subMatrix(0,r-1,0,i-1)}(e,t=a(t,s,l),s,l)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Sx(this.rows,this.columns);for(let t=0;t<this.rows;t++){const i=this.getRow(t);i.length>0&&sx(i,{min:e,max:n,output:i}),r.setRow(t,i)}return r}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:n=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(n))throw new TypeError("max must be a number");if(e>=n)throw new RangeError("min must be smaller than max");let r=new Sx(this.rows,this.columns);for(let t=0;t<this.columns;t++){const i=this.getColumn(t);i.length&&sx(i,{min:e,max:n,output:i}),r.setColumn(t,i)}return r}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let n=0;n<t;n++){let t=this.get(e,n),r=this.get(e,this.columns-1-n);this.set(e,n,r),this.set(e,this.columns-1-n,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let n=0;n<t;n++){let t=this.get(n,e),r=this.get(this.rows-1-n,e);this.set(n,e,r),this.set(this.rows-1-n,e,t)}return this}kroneckerProduct(t){t=Sx.checkMatrix(t);let e=this.rows,n=this.columns,r=t.rows,i=t.columns,o=new Sx(e*r,n*i);for(let a=0;a<e;a++)for(let e=0;e<n;e++)for(let n=0;n<r;n++)for(let s=0;s<i;s++)o.set(r*a+n,i*e+s,this.get(a,e)*t.get(n,s));return o}kroneckerSum(t){if(t=Sx.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,n=t.rows,r=this.kroneckerProduct(Sx.eye(n,n)),i=Sx.eye(e,e).kroneckerProduct(t);return r.add(i)}transpose(){let t=new Sx(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)t.set(n,e,this.get(e,n));return t}sortRows(t=Mx){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Mx){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,n,r){bx(this,t,e,n,r);let i=new Sx(e-t+1,r-n+1);for(let o=t;o<=e;o++)for(let e=n;e<=r;e++)i.set(o-t,e-n,this.get(o,e));return i}subMatrixRow(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.columns-1),e>n||e<0||e>=this.columns||n<0||n>=this.columns)throw new RangeError("Argument out of range");let r=new Sx(t.length,n-e+1);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.rows)throw new RangeError(`Row index out of range: ${t[i]}`);r.set(i,o-e,this.get(t[i],o))}return r}subMatrixColumn(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=this.rows-1),e>n||e<0||e>=this.rows||n<0||n>=this.rows)throw new RangeError("Argument out of range");let r=new Sx(n-e+1,t.length);for(let i=0;i<t.length;i++)for(let o=e;o<=n;o++){if(t[i]<0||t[i]>=this.columns)throw new RangeError(`Column index out of range: ${t[i]}`);r.set(o-e,i,this.get(o,t[i]))}return r}setSubMatrix(t,e,n){if((t=Sx.checkMatrix(t)).isEmpty())return this;bx(this,e,e+t.rows-1,n,n+t.columns-1);for(let r=0;r<t.rows;r++)for(let i=0;i<t.columns;i++)this.set(e+r,n+i,t.get(r,i));return this}selection(t,e){mx(this,t),yx(this,e);let n=new Sx(t.length,e.length);for(let r=0;r<t.length;r++){let i=t[r];for(let t=0;t<e.length;t++){let o=e[t];n.set(r,t,this.get(i,o))}}return n}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let n=0;n<t;n++)e+=this.get(n,n);return e}clone(){return this.constructor.copy(this,new Sx(this.rows,this.columns))}static copy(t,e){for(const[n,r,i]of t.entries())e.set(n,r,i);return e}sum(t){switch(t){case"row":return function(t){let e=xx(t.rows);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]+=t.get(n,r);return e}(this);case"column":return function(t){let e=xx(t.columns);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]+=t.get(n,r);return e}(this);case void 0:return function(t){let e=0;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e+=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=xx(t.rows,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[n]*=t.get(n,r);return e}(this);case"column":return function(t){let e=xx(t.columns,1);for(let n=0;n<t.rows;++n)for(let r=0;r<t.columns;++r)e[r]*=t.get(n,r);return e}(this);case void 0:return function(t){let e=1;for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)e*=t.get(n,r);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:n=!0,mean:r=this.mean(t)}=e;if("boolean"!=typeof n)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!ax.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<r;a++){let r=0,s=0,l=0;for(let e=0;e<i;e++)l=t.get(a,e)-n[a],r+=l,s+=l*l;e?o.push((s-r*r/i)/(i-1)):o.push((s-r*r/i)/i)}return o}(this,n,r);case"column":if(!ax.isAnyArray(r))throw new TypeError("mean must be an array");return function(t,e,n){const r=t.rows,i=t.columns,o=[];for(let a=0;a<i;a++){let i=0,s=0,l=0;for(let e=0;e<r;e++)l=t.get(e,a)-n[a],i+=l,s+=l*l;e?o.push((s-i*i/r)/(r-1)):o.push((s-i*i/r)/r)}return o}(this,n,r);case void 0:if("number"!=typeof r)throw new TypeError("mean must be a number");return function(t,e,n){const r=t.rows,i=t.columns,o=r*i;let a=0,s=0,l=0;for(let e=0;e<r;e++)for(let r=0;r<i;r++)l=t.get(e,r)-n,a+=l,s+=l*l;return e?(s-a*a/o)/(o-1):(s-a*a/o)/o}(this,n,r);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const n=this.variance(t,e);if(void 0===t)return Math.sqrt(n);for(let t=0;t<n.length;t++)n[t]=Math.sqrt(n[t]);return n}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:n=this.mean(t)}=e;switch(t){case"row":if(!ax.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[n])}(this,n),this;case"column":if(!ax.isAnyArray(n))throw new TypeError("center must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e[r])}(this,n),this;case void 0:if("number"!=typeof n)throw new TypeError("center must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)-e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let n=e.scale;switch(t){case"row":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.rows;n++){let r=0;for(let e=0;e<t.columns;e++)r+=t.get(n,e)**2/(t.columns-1);e.push(Math.sqrt(r))}return e}(this);else if(!ax.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[n])}(this,n),this;case"column":if(void 0===n)n=function(t){const e=[];for(let n=0;n<t.columns;n++){let r=0;for(let e=0;e<t.rows;e++)r+=t.get(e,n)**2/(t.rows-1);e.push(Math.sqrt(r))}return e}(this);else if(!ax.isAnyArray(n))throw new TypeError("scale must be an array");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e[r])}(this,n),this;case void 0:if(void 0===n)n=function(t){const e=t.size-1;let n=0;for(let r=0;r<t.columns;r++)for(let i=0;i<t.rows;i++)n+=t.get(i,r)**2/e;return Math.sqrt(n)}(this);else if("number"!=typeof n)throw new TypeError("scale must be a number");return function(t,e){for(let n=0;n<t.rows;n++)for(let r=0;r<t.columns;r++)t.set(n,r,t.get(n,r)/e)}(this,n),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return cx(this,t)}[Symbol.iterator](){return this.entries()}*entries(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield[t,e,this.get(t,e)]}*values(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)yield this.get(t,e)}}function Mx(t,e){return t-e}kx.prototype.klass="Matrix","undefined"!=typeof Symbol&&(kx.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return cx(this)}),kx.random=kx.rand,kx.randomInt=kx.randInt,kx.diagonal=kx.diag,kx.prototype.diagonal=kx.prototype.diag,kx.identity=kx.eye,kx.prototype.negate=kx.prototype.neg,kx.prototype.tensorProduct=kx.prototype.kroneckerProduct;let Sx=class t extends kx{data;#t(t,e){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let n=0;n<t;n++)this.data.push(new Float64Array(e));this.rows=t,this.columns=e}constructor(e,n){if(super(),t.isMatrix(e))this.#t(e.rows,e.columns),t.copy(e,this);else if(Number.isInteger(e)&&e>=0)this.#t(e,n);else{if(!ax.isAnyArray(e))throw new TypeError("First argument must be a positive number or an array");{const t=e;if("number"!=typeof(n=(e=t.length)?t[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let r=0;r<e;r++){if(t[r].length!==n)throw new RangeError("Inconsistent array dimensions");if(!t[r].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(t[r]))}this.rows=e,this.columns=n}}}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}removeRow(t){return fx(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),fx(this,t,!0),e=Float64Array.from(gx(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){px(this,t);for(let e=0;e<this.rows;e++){const n=new Float64Array(this.columns-1);for(let r=0;r<t;r++)n[r]=this.data[e][r];for(let r=t+1;r<this.columns;r++)n[r-1]=this.data[e][r];this.data[e]=n}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),px(this,t,!0),e=vx(this,e);for(let n=0;n<this.rows;n++){const r=new Float64Array(this.columns+1);let i=0;for(;i<t;i++)r[i]=this.data[n][i];for(r[i++]=e[n];i<this.columns+1;i++)r[i]=this.data[n][i-1];this.data[n]=r}return this.columns+=1,this}};!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)+t.get(e,n));return this},t.add=function(t,n){return new e(t).add(n)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)-t.get(e,n));return this},t.sub=function(t,n){return new e(t).sub(n)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)*t.get(e,n));return this},t.mul=function(t,n){return new e(t).mul(n)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)/t.get(e,n));return this},t.div=function(t,n){return new e(t).div(n)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)%t.get(e,n));return this},t.mod=function(t,n){return new e(t).mod(n)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)&t.get(e,n));return this},t.and=function(t,n){return new e(t).and(n)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)|t.get(e,n));return this},t.or=function(t,n){return new e(t).or(n)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)^t.get(e,n));return this},t.xor=function(t,n){return new e(t).xor(n)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)<<t.get(e,n));return this},t.leftShift=function(t,n){return new e(t).leftShift(n)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>t.get(e,n));return this},t.signPropagatingRightShift=function(t,n){return new e(t).signPropagatingRightShift(n)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)>>>t.get(e,n));return this},t.rightShift=function(t,n){return new e(t).rightShift(n)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,n){return new e(t).pow(n)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t);return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let n=0;n<this.columns;n++)this.set(e,n,this.get(e,n)**t.get(e,n));return this}}(kx,Sx);class Nx extends kx{#e;get size(){return this.#e.size}get rows(){return this.#e.rows}get columns(){return this.#e.columns}get diagonalSize(){return this.rows}static isSymmetricMatrix(t){return Sx.isMatrix(t)&&"SymmetricMatrix"===t.klassType}static zeros(t){return new this(t)}static ones(t){return new this(t).fill(1)}constructor(t){if(super(),Sx.isMatrix(t)){if(!t.isSymmetric())throw new TypeError("not symmetric data");this.#e=Sx.copy(t,new Sx(t.rows,t.rows))}else if(Number.isInteger(t)&&t>=0)this.#e=new Sx(t,t);else if(this.#e=new Sx(t),!this.isSymmetric())throw new TypeError("not symmetric data")}clone(){const t=new Nx(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())t.set(e,n,r);return t}toMatrix(){return new Sx(this)}get(t,e){return this.#e.get(t,e)}set(t,e,n){return this.#e.set(t,e,n),this.#e.set(e,t,n),this}removeCross(t){return this.#e.removeRow(t),this.#e.removeColumn(t),this}addCross(t,e){void 0===e&&(e=t,t=this.diagonalSize);const n=e.slice();return n.splice(t,1),this.#e.addRow(t,n),this.#e.addColumn(t,e),this}applyMask(t){if(t.length!==this.diagonalSize)throw new RangeError("Mask size do not match with matrix size");const e=[];for(const[n,r]of t.entries())r||e.push(n);e.reverse();for(const t of e)this.removeCross(t);return this}toCompact(){const{diagonalSize:t}=this,e=new Array(t*(t+1)/2);for(let n=0,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=++r);return e}static fromCompact(t){const e=t.length,n=(Math.sqrt(8*e+1)-1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(t)}`);const r=new Nx(n);for(let i=0,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=++o);return r}*upperRightEntries(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield[t,e,n],++e>=this.diagonalSize&&(e=++t)}}*upperRightValues(){for(let t=0,e=0;t<this.diagonalSize;void 0){const n=this.get(t,e);yield n,++e>=this.diagonalSize&&(e=++t)}}}Nx.prototype.klassType="SymmetricMatrix";class Ox extends Nx{static isDistanceMatrix(t){return Nx.isSymmetricMatrix(t)&&"DistanceMatrix"===t.klassSubType}constructor(t){if(super(t),!this.isDistance())throw new TypeError("Provided arguments do no produce a distance matrix")}set(t,e,n){return t===e&&(n=0),super.set(t,e,n)}addCross(t,e){return void 0===e&&(e=t,t=this.diagonalSize),(e=e.slice())[t]=0,super.addCross(t,e)}toSymmetricMatrix(){return new Nx(this)}clone(){const t=new Ox(this.diagonalSize);for(const[e,n,r]of this.upperRightEntries())e!==n&&t.set(e,n,r);return t}toCompact(){const{diagonalSize:t}=this,e=new Array((t-1)*t/2);for(let n=1,r=0,i=0;i<e.length;i++)e[i]=this.get(r,n),++n>=t&&(n=1+ ++r);return e}static fromCompact(t){const e=t.length;if(0===e)return new this(0);const n=(Math.sqrt(8*e+1)+1)/2;if(!Number.isInteger(n))throw new TypeError(`This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(t)}`);const r=new this(n);for(let i=1,o=0,a=0;a<e;a++)r.set(i,o,t[a]),++i>=n&&(i=1+ ++o);return r}}Ox.prototype.klassSubType="DistanceMatrix";class Tx extends kx{constructor(t,e,n){super(),this.matrix=t,this.rows=e,this.columns=n}}class Cx extends Tx{constructor(t,e,n){mx(t,e),yx(t,n),super(t,e.length,n.length),this.rowIndices=e,this.columnIndices=n}set(t,e,n){return this.matrix.set(this.rowIndices[t],this.columnIndices[e],n),this}get(t,e){return this.matrix.get(this.rowIndices[t],this.columnIndices[e])}}class Ax extends kx{constructor(t,e={}){const{rows:n=1}=e;if(t.length%n!==0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=n,this.columns=t.length/n,this.data=t}set(t,e,n){let r=this._calculateIndex(t,e);return this.data[r]=n,this}get(t,e){let n=this._calculateIndex(t,e);return this.data[n]}_calculateIndex(t,e){return t*this.columns+e}}class Px extends kx{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,n){return this.data[t][e]=n,this}get(t,e){return this.data[t][e]}}class Rx{constructor(t){let e,n,r,i,o,a,s,l,u,c=(t=Px.checkMatrix(t)).clone(),h=c.rows,d=c.columns,f=new Float64Array(h),p=1;for(e=0;e<h;e++)f[e]=e;for(l=new Float64Array(h),n=0;n<d;n++){for(e=0;e<h;e++)l[e]=c.get(e,n);for(e=0;e<h;e++){for(u=Math.min(e,n),o=0,r=0;r<u;r++)o+=c.get(e,r)*l[r];l[e]-=o,c.set(e,n,l[e])}for(i=n,e=n+1;e<h;e++)Math.abs(l[e])>Math.abs(l[i])&&(i=e);if(i!==n){for(r=0;r<d;r++)a=c.get(i,r),c.set(i,r,c.get(n,r)),c.set(n,r,a);s=f[i],f[i]=f[n],f[n]=s,p=-p}if(n<h&&0!==c.get(n,n))for(e=n+1;e<h;e++)c.set(e,n,c.get(e,n)/c.get(n,n))}this.LU=c,this.pivotVector=f,this.pivotSign=p}isSingular(){let t=this.LU,e=t.columns;for(let n=0;n<e;n++)if(0===t.get(n,n))return!0;return!1}solve(t){t=Sx.checkMatrix(t);let e=this.LU;if(e.rows!==t.rows)throw new Error("Invalid matrix dimensions");if(this.isSingular())throw new Error("LU matrix is singular");let n,r,i,o=t.columns,a=t.subMatrixRow(this.pivotVector,0,o-1),s=e.columns;for(i=0;i<s;i++)for(n=i+1;n<s;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i));for(i=s-1;i>=0;i--){for(r=0;r<o;r++)a.set(i,r,a.get(i,r)/e.get(i,i));for(n=0;n<i;n++)for(r=0;r<o;r++)a.set(n,r,a.get(n,r)-a.get(i,r)*e.get(n,i))}return a}get determinant(){let t=this.LU;if(!t.isSquare())throw new Error("Matrix must be square");let e=this.pivotSign,n=t.columns;for(let r=0;r<n;r++)e*=t.get(r,r);return e}get lowerTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new Sx(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i>e?r.set(i,e,t.get(i,e)):i===e?r.set(i,e,1):r.set(i,e,0);return r}get upperTriangularMatrix(){let t=this.LU,e=t.rows,n=t.columns,r=new Sx(e,n);for(let i=0;i<e;i++)for(let e=0;e<n;e++)i<=e?r.set(i,e,t.get(i,e)):r.set(i,e,0);return r}get pivotPermutationVector(){return Array.from(this.pivotVector)}}function Dx(t,e){let n=0;return Math.abs(t)>Math.abs(e)?(n=e/t,Math.abs(t)*Math.sqrt(1+n*n)):0!==e?(n=t/e,Math.abs(e)*Math.sqrt(1+n*n)):0}class Lx{constructor(t){let e,n,r,i,o=(t=Px.checkMatrix(t)).clone(),a=t.rows,s=t.columns,l=new Float64Array(s);for(r=0;r<s;r++){let t=0;for(e=r;e<a;e++)t=Dx(t,o.get(e,r));if(0!==t){for(o.get(r,r)<0&&(t=-t),e=r;e<a;e++)o.set(e,r,o.get(e,r)/t);for(o.set(r,r,o.get(r,r)+1),n=r+1;n<s;n++){for(i=0,e=r;e<a;e++)i+=o.get(e,r)*o.get(e,n);for(i=-i/o.get(r,r),e=r;e<a;e++)o.set(e,n,o.get(e,n)+i*o.get(e,r))}}l[r]=-t}this.QR=o,this.Rdiag=l}solve(t){t=Sx.checkMatrix(t);let e=this.QR,n=e.rows;if(t.rows!==n)throw new Error("Matrix row dimensions must agree");if(!this.isFullRank())throw new Error("Matrix is rank deficient");let r,i,o,a,s=t.columns,l=t.clone(),u=e.columns;for(o=0;o<u;o++)for(i=0;i<s;i++){for(a=0,r=o;r<n;r++)a+=e.get(r,o)*l.get(r,i);for(a=-a/e.get(o,o),r=o;r<n;r++)l.set(r,i,l.get(r,i)+a*e.get(r,o))}for(o=u-1;o>=0;o--){for(i=0;i<s;i++)l.set(o,i,l.get(o,i)/this.Rdiag[o]);for(r=0;r<o;r++)for(i=0;i<s;i++)l.set(r,i,l.get(r,i)-l.get(o,i)*e.get(r,o))}return l.subMatrix(0,u-1,0,s-1)}isFullRank(){let t=this.QR.columns;for(let e=0;e<t;e++)if(0===this.Rdiag[e])return!1;return!0}get upperTriangularMatrix(){let t,e,n=this.QR,r=n.columns,i=new Sx(r,r);for(t=0;t<r;t++)for(e=0;e<r;e++)t<e?i.set(t,e,n.get(t,e)):t===e?i.set(t,e,this.Rdiag[t]):i.set(t,e,0);return i}get orthogonalMatrix(){let t,e,n,r,i=this.QR,o=i.rows,a=i.columns,s=new Sx(o,a);for(n=a-1;n>=0;n--){for(t=0;t<o;t++)s.set(t,n,0);for(s.set(n,n,1),e=n;e<a;e++)if(0!==i.get(n,n)){for(r=0,t=n;t<o;t++)r+=i.get(t,n)*s.get(t,e);for(r=-r/i.get(n,n),t=n;t<o;t++)s.set(t,e,s.get(t,e)+r*i.get(t,n))}}return s}}let _x=class{constructor(t,e={}){if((t=Px.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let n=t.rows,r=t.columns;const{computeLeftSingularVectors:i=!0,computeRightSingularVectors:o=!0,autoTranspose:a=!1}=e;let s,l=Boolean(i),u=Boolean(o),c=!1;if(n<r)if(a){s=t.transpose(),n=s.rows,r=s.columns,c=!0;let e=l;l=u,u=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let h=Math.min(n,r),d=Math.min(n+1,r),f=new Float64Array(d),p=new Sx(n,h),g=new Sx(r,r),v=new Float64Array(r),m=new Float64Array(n),y=new Float64Array(d);for(let t=0;t<d;t++)y[t]=t;let b=Math.min(n-1,r),x=Math.max(0,Math.min(r-2,n)),E=Math.max(b,x);for(let t=0;t<E;t++){if(t<b){f[t]=0;for(let e=t;e<n;e++)f[t]=Dx(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<n;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<r;e++){if(t<b&&0!==f[t]){let r=0;for(let i=t;i<n;i++)r+=s.get(i,t)*s.get(i,e);r=-r/s.get(t,t);for(let i=t;i<n;i++)s.set(i,e,s.get(i,e)+r*s.get(i,t))}v[e]=s.get(t,e)}if(l&&t<b)for(let e=t;e<n;e++)p.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<r;e++)v[t]=Dx(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<r;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<n&&0!==v[t]){for(let e=t+1;e<n;e++)m[e]=0;for(let e=t+1;e<n;e++)for(let n=t+1;n<r;n++)m[e]+=v[n]*s.get(e,n);for(let e=t+1;e<r;e++){let r=-v[e]/v[t+1];for(let i=t+1;i<n;i++)s.set(i,e,s.get(i,e)+r*m[i])}}if(u)for(let e=t+1;e<r;e++)g.set(e,t,v[e])}}let w=Math.min(r,n+1);if(b<r&&(f[b]=s.get(b,b)),n<w&&(f[w-1]=0),x+1<w&&(v[x]=s.get(x,w-1)),v[w-1]=0,l){for(let t=b;t<h;t++){for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}for(let t=b-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<h;e++){let r=0;for(let i=t;i<n;i++)r+=p.get(i,t)*p.get(i,e);r=-r/p.get(t,t);for(let i=t;i<n;i++)p.set(i,e,p.get(i,e)+r*p.get(i,t))}for(let e=t;e<n;e++)p.set(e,t,-p.get(e,t));p.set(t,t,1+p.get(t,t));for(let e=0;e<t-1;e++)p.set(e,t,0)}else{for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}}if(u)for(let t=r-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<r;e++){let n=0;for(let i=t+1;i<r;i++)n+=g.get(i,t)*g.get(i,e);n=-n/g.get(t+1,t);for(let i=t+1;i<r;i++)g.set(i,e,g.get(i,e)+n*g.get(i,t))}for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}let k=w-1,M=Number.EPSILON;for(;w>0;){let t,e;for(t=w-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+M*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===w-2)e=4;else{let n;for(n=w-1;n>=t&&n!==t;n--){let e=(n!==w?Math.abs(v[n]):0)+(n!==t+1?Math.abs(v[n-1]):0);if(Math.abs(f[n])<=M*e){f[n]=0;break}}n===t?e=3:n===w-1?e=1:(e=2,t=n)}switch(t++,e){case 1:{let e=v[w-2];v[w-2]=0;for(let n=w-2;n>=t;n--){let i=Dx(f[n],e),o=f[n]/i,a=e/i;if(f[n]=i,n!==t&&(e=-a*v[n-1],v[n-1]=o*v[n-1]),u)for(let t=0;t<r;t++)i=o*g.get(t,n)+a*g.get(t,w-1),g.set(t,w-1,-a*g.get(t,n)+o*g.get(t,w-1)),g.set(t,n,i)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let r=t;r<w;r++){let i=Dx(f[r],e),o=f[r]/i,a=e/i;if(f[r]=i,e=-a*v[r],v[r]=o*v[r],l)for(let e=0;e<n;e++)i=o*p.get(e,r)+a*p.get(e,t-1),p.set(e,t-1,-a*p.get(e,r)+o*p.get(e,t-1)),p.set(e,r,i)}break}case 3:{const e=Math.max(Math.abs(f[w-1]),Math.abs(f[w-2]),Math.abs(v[w-2]),Math.abs(f[t]),Math.abs(v[t])),i=f[w-1]/e,o=f[w-2]/e,a=v[w-2]/e,s=f[t]/e,c=v[t]/e,h=((o+i)*(o-i)+a*a)/2,d=i*a*(i*a);let m=0;0===h&&0===d||(m=h<0?0-Math.sqrt(h*h+d):Math.sqrt(h*h+d),m=d/(h+m));let y=(s+i)*(s-i)+m,b=s*c;for(let e=t;e<w-1;e++){let i=Dx(y,b);0===i&&(i=Number.MIN_VALUE);let o=y/i,a=b/i;if(e!==t&&(v[e-1]=i),y=o*f[e]+a*v[e],v[e]=o*v[e]-a*f[e],b=a*f[e+1],f[e+1]=o*f[e+1],u)for(let t=0;t<r;t++)i=o*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+o*g.get(t,e+1)),g.set(t,e,i);if(i=Dx(y,b),0===i&&(i=Number.MIN_VALUE),o=y/i,a=b/i,f[e]=i,y=o*v[e]+a*f[e+1],f[e+1]=-a*v[e]+o*f[e+1],b=a*v[e+1],v[e+1]=o*v[e+1],l&&e<n-1)for(let t=0;t<n;t++)i=o*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+o*p.get(t,e+1)),p.set(t,e,i)}v[w-2]=y;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,u))for(let e=0;e<=k;e++)g.set(e,t,-g.get(e,t));for(;t<k&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);if(l&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);t++}w--}}if(c){let t=g;g=p,p=t}this.m=n,this.n=r,this.s=f,this.U=p,this.V=g}solve(t){let e=t,n=this.threshold,r=this.s.length,i=Sx.zeros(r,r);for(let t=0;t<r;t++)Math.abs(this.s[t])<=n?i.set(t,t,0):i.set(t,t,1/this.s[t]);let o=this.U,a=this.rightSingularVectors,s=a.mmul(i),l=a.rows,u=o.rows,c=Sx.zeros(l,u);for(let t=0;t<l;t++)for(let e=0;e<u;e++){let n=0;for(let i=0;i<r;i++)n+=s.get(t,i)*o.get(e,i);c.set(t,e,n)}return c.mmul(e)}solveForDiagonal(t){return this.solve(Sx.diag(t))}inverse(){let t=this.V,e=this.threshold,n=t.rows,r=t.columns,i=new Sx(n,this.s.length);for(let o=0;o<n;o++)for(let n=0;n<r;n++)Math.abs(this.s[n])>e&&i.set(o,n,t.get(o,n)/this.s[n]);let o=this.U,a=o.rows,s=o.columns,l=new Sx(n,a);for(let t=0;t<n;t++)for(let e=0;e<a;e++){let n=0;for(let r=0;r<s;r++)n+=i.get(t,r)*o.get(e,r);l.set(t,e,n)}return l}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,n=this.s;for(let r=0,i=n.length;r<i;r++)n[r]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return Sx.diag(this.s)}};function Ix(t,e,n=!1){return t=Px.checkMatrix(t),e=Px.checkMatrix(e),n?new _x(t).solve(e):t.isSquare()?new Rx(t).solve(e):new Lx(t).solve(e)}function jx(t,e){let n=[];for(let r=0;r<t;r++)r!==e&&n.push(r);return n}function Bx(t,e,n,r=1e-9,i=1e-9){if(t>i)return new Array(e.rows+1).fill(0);{let t=e.addRow(n,[0]);for(let e=0;e<t.rows;e++)Math.abs(t.get(e,0))<r&&t.set(e,0,0);return t.to1DArray()}}class Fx{constructor(t,e={}){const{assumeSymmetric:n=!1}=e;if(!(t=Px.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let r,i,o=t.columns,a=new Sx(o,o),s=new Float64Array(o),l=new Float64Array(o),u=t,c=!1;if(c=!!n||t.isSymmetric(),c){for(r=0;r<o;r++)for(i=0;i<o;i++)a.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h;for(l=0;l<t;l++)n[l]=r.get(t-1,l);for(s=t-1;s>0;s--){for(h=0,a=0,u=0;u<s;u++)h+=Math.abs(n[u]);if(0===h)for(e[s]=n[s-1],l=0;l<s;l++)n[l]=r.get(s-1,l),r.set(s,l,0),r.set(l,s,0);else{for(u=0;u<s;u++)n[u]/=h,a+=n[u]*n[u];for(i=n[s-1],o=Math.sqrt(a),i>0&&(o=-o),e[s]=h*o,a-=i*o,n[s-1]=i-o,l=0;l<s;l++)e[l]=0;for(l=0;l<s;l++){for(i=n[l],r.set(l,s,i),o=e[l]+r.get(l,l)*i,u=l+1;u<=s-1;u++)o+=r.get(u,l)*n[u],e[u]+=r.get(u,l)*i;e[l]=o}for(i=0,l=0;l<s;l++)e[l]/=a,i+=e[l]*n[l];for(c=i/(a+a),l=0;l<s;l++)e[l]-=c*n[l];for(l=0;l<s;l++){for(i=n[l],o=e[l],u=l;u<=s-1;u++)r.set(u,l,r.get(u,l)-(i*e[u]+o*n[u]));n[l]=r.get(s-1,l),r.set(s,l,0)}}n[s]=a}for(s=0;s<t-1;s++){if(r.set(t-1,s,r.get(s,s)),r.set(s,s,1),a=n[s+1],0!==a){for(u=0;u<=s;u++)n[u]=r.get(u,s+1)/a;for(l=0;l<=s;l++){for(o=0,u=0;u<=s;u++)o+=r.get(u,s+1)*r.get(u,l);for(u=0;u<=s;u++)r.set(u,l,r.get(u,l)-o*n[u])}}for(u=0;u<=s;u++)r.set(u,s+1,0)}for(l=0;l<t;l++)n[l]=r.get(t-1,l),r.set(t-1,l,0);r.set(t-1,t-1,1),e[0]=0}(o,l,s,a),function(t,e,n,r){let i,o,a,s,l,u,c,h,d,f,p,g,v,m,y,b;for(a=1;a<t;a++)e[a-1]=e[a];e[t-1]=0;let x=0,E=0,w=Number.EPSILON;for(u=0;u<t;u++){for(E=Math.max(E,Math.abs(n[u])+Math.abs(e[u])),c=u;c<t&&!(Math.abs(e[c])<=w*E);)c++;if(c>u)do{for(i=n[u],h=(n[u+1]-i)/(2*e[u]),d=Dx(h,1),h<0&&(d=-d),n[u]=e[u]/(h+d),n[u+1]=e[u]*(h+d),f=n[u+1],o=i-n[u],a=u+2;a<t;a++)n[a]-=o;for(x+=o,h=n[c],p=1,g=p,v=p,m=e[u+1],y=0,b=0,a=c-1;a>=u;a--)for(v=g,g=p,b=y,i=p*e[a],o=p*h,d=Dx(h,e[a]),e[a+1]=y*d,y=e[a]/d,p=h/d,h=p*n[a]-y*i,n[a+1]=o+y*(p*i+y*n[a]),l=0;l<t;l++)o=r.get(l,a+1),r.set(l,a+1,y*r.get(l,a)+p*o),r.set(l,a,p*r.get(l,a)-y*o);h=-y*b*v*m*e[u]/f,e[u]=y*h,n[u]=p*h}while(Math.abs(e[u])>w*E);n[u]=n[u]+x,e[u]=0}for(a=0;a<t-1;a++){for(l=a,h=n[a],s=a+1;s<t;s++)n[s]<h&&(l=s,h=n[s]);if(l!==a)for(n[l]=n[a],n[a]=h,s=0;s<t;s++)h=r.get(s,a),r.set(s,a,r.get(s,l)),r.set(s,l,h)}}(o,l,s,a)}else{let t=new Sx(o,o),e=new Float64Array(o);for(i=0;i<o;i++)for(r=0;r<o;r++)t.set(r,i,u.get(r,i));!function(t,e,n,r){let i,o,a,s,l,u,c,h=0,d=t-1;for(u=h+1;u<=d-1;u++){for(c=0,s=u;s<=d;s++)c+=Math.abs(e.get(s,u-1));if(0!==c){for(a=0,s=d;s>=u;s--)n[s]=e.get(s,u-1)/c,a+=n[s]*n[s];for(o=Math.sqrt(a),n[u]>0&&(o=-o),a-=n[u]*o,n[u]=n[u]-o,l=u;l<t;l++){for(i=0,s=d;s>=u;s--)i+=n[s]*e.get(s,l);for(i/=a,s=u;s<=d;s++)e.set(s,l,e.get(s,l)-i*n[s])}for(s=0;s<=d;s++){for(i=0,l=d;l>=u;l--)i+=n[l]*e.get(s,l);for(i/=a,l=u;l<=d;l++)e.set(s,l,e.get(s,l)-i*n[l])}n[u]=c*n[u],e.set(u,u-1,c*o)}}for(s=0;s<t;s++)for(l=0;l<t;l++)r.set(s,l,s===l?1:0);for(u=d-1;u>=h+1;u--)if(0!==e.get(u,u-1)){for(s=u+1;s<=d;s++)n[s]=e.get(s,u-1);for(l=u;l<=d;l++){for(o=0,s=u;s<=d;s++)o+=n[s]*r.get(s,l);for(o=o/n[u]/e.get(u,u-1),s=u;s<=d;s++)r.set(s,l,r.get(s,l)+o*n[s])}}}(o,t,e,a),function(t,e,n,r,i){let o,a,s,l,u,c,h,d,f,p,g,v,m,y,b,x=t-1,E=0,w=t-1,k=Number.EPSILON,M=0,S=0,N=0,O=0,T=0,C=0,A=0,P=0;for(o=0;o<t;o++)for((o<E||o>w)&&(n[o]=i.get(o,o),e[o]=0),a=Math.max(o-1,0);a<t;a++)S+=Math.abs(i.get(o,a));for(;x>=E;){for(l=x;l>E&&(C=Math.abs(i.get(l-1,l-1))+Math.abs(i.get(l,l)),0===C&&(C=S),!(Math.abs(i.get(l,l-1))<k*C));)l--;if(l===x)i.set(x,x,i.get(x,x)+M),n[x]=i.get(x,x),e[x]=0,x--,P=0;else if(l===x-1){if(h=i.get(x,x-1)*i.get(x-1,x),N=(i.get(x-1,x-1)-i.get(x,x))/2,O=N*N+h,A=Math.sqrt(Math.abs(O)),i.set(x,x,i.get(x,x)+M),i.set(x-1,x-1,i.get(x-1,x-1)+M),d=i.get(x,x),O>=0){for(A=N>=0?N+A:N-A,n[x-1]=d+A,n[x]=n[x-1],0!==A&&(n[x]=d-h/A),e[x-1]=0,e[x]=0,d=i.get(x,x-1),C=Math.abs(d)+Math.abs(A),N=d/C,O=A/C,T=Math.sqrt(N*N+O*O),N/=T,O/=T,a=x-1;a<t;a++)A=i.get(x-1,a),i.set(x-1,a,O*A+N*i.get(x,a)),i.set(x,a,O*i.get(x,a)-N*A);for(o=0;o<=x;o++)A=i.get(o,x-1),i.set(o,x-1,O*A+N*i.get(o,x)),i.set(o,x,O*i.get(o,x)-N*A);for(o=E;o<=w;o++)A=r.get(o,x-1),r.set(o,x-1,O*A+N*r.get(o,x)),r.set(o,x,O*r.get(o,x)-N*A)}else n[x-1]=d+N,n[x]=d+N,e[x-1]=A,e[x]=-A;x-=2,P=0}else{if(d=i.get(x,x),f=0,h=0,l<x&&(f=i.get(x-1,x-1),h=i.get(x,x-1)*i.get(x-1,x)),10===P){for(M+=d,o=E;o<=x;o++)i.set(o,o,i.get(o,o)-d);C=Math.abs(i.get(x,x-1))+Math.abs(i.get(x-1,x-2)),d=f=.75*C,h=-.4375*C*C}if(30===P&&(C=(f-d)/2,C=C*C+h,C>0)){for(C=Math.sqrt(C),f<d&&(C=-C),C=d-h/((f-d)/2+C),o=E;o<=x;o++)i.set(o,o,i.get(o,o)-C);M+=C,d=f=h=.964}for(P+=1,u=x-2;u>=l&&(A=i.get(u,u),T=d-A,C=f-A,N=(T*C-h)/i.get(u+1,u)+i.get(u,u+1),O=i.get(u+1,u+1)-A-T-C,T=i.get(u+2,u+1),C=Math.abs(N)+Math.abs(O)+Math.abs(T),N/=C,O/=C,T/=C,u!==l)&&!(Math.abs(i.get(u,u-1))*(Math.abs(O)+Math.abs(T))<k*(Math.abs(N)*(Math.abs(i.get(u-1,u-1))+Math.abs(A)+Math.abs(i.get(u+1,u+1)))));)u--;for(o=u+2;o<=x;o++)i.set(o,o-2,0),o>u+2&&i.set(o,o-3,0);for(s=u;s<=x-1&&(y=s!==x-1,s!==u&&(N=i.get(s,s-1),O=i.get(s+1,s-1),T=y?i.get(s+2,s-1):0,d=Math.abs(N)+Math.abs(O)+Math.abs(T),0!==d&&(N/=d,O/=d,T/=d)),0!==d);s++)if(C=Math.sqrt(N*N+O*O+T*T),N<0&&(C=-C),0!==C){for(s!==u?i.set(s,s-1,-C*d):l!==u&&i.set(s,s-1,-i.get(s,s-1)),N+=C,d=N/C,f=O/C,A=T/C,O/=N,T/=N,a=s;a<t;a++)N=i.get(s,a)+O*i.get(s+1,a),y&&(N+=T*i.get(s+2,a),i.set(s+2,a,i.get(s+2,a)-N*A)),i.set(s,a,i.get(s,a)-N*d),i.set(s+1,a,i.get(s+1,a)-N*f);for(o=0;o<=Math.min(x,s+3);o++)N=d*i.get(o,s)+f*i.get(o,s+1),y&&(N+=A*i.get(o,s+2),i.set(o,s+2,i.get(o,s+2)-N*T)),i.set(o,s,i.get(o,s)-N),i.set(o,s+1,i.get(o,s+1)-N*O);for(o=E;o<=w;o++)N=d*r.get(o,s)+f*r.get(o,s+1),y&&(N+=A*r.get(o,s+2),r.set(o,s+2,r.get(o,s+2)-N*T)),r.set(o,s,r.get(o,s)-N),r.set(o,s+1,r.get(o,s+1)-N*O)}}}if(0===S)return;for(x=t-1;x>=0;x--)if(N=n[x],O=e[x],0===O)for(l=x,i.set(x,x,1),o=x-1;o>=0;o--){for(h=i.get(o,o)-N,T=0,a=l;a<=x;a++)T+=i.get(o,a)*i.get(a,x);if(e[o]<0)A=h,C=T;else if(l=o,0===e[o]?i.set(o,x,0!==h?-T/h:-T/(k*S)):(d=i.get(o,o+1),f=i.get(o+1,o),O=(n[o]-N)*(n[o]-N)+e[o]*e[o],c=(d*C-A*T)/O,i.set(o,x,c),i.set(o+1,x,Math.abs(d)>Math.abs(A)?(-T-h*c)/d:(-C-f*c)/A)),c=Math.abs(i.get(o,x)),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x,i.get(a,x)/c)}else if(O<0)for(l=x-1,Math.abs(i.get(x,x-1))>Math.abs(i.get(x-1,x))?(i.set(x-1,x-1,O/i.get(x,x-1)),i.set(x-1,x,-(i.get(x,x)-N)/i.get(x,x-1))):(b=zx(0,-i.get(x-1,x),i.get(x-1,x-1)-N,O),i.set(x-1,x-1,b[0]),i.set(x-1,x,b[1])),i.set(x,x-1,0),i.set(x,x,1),o=x-2;o>=0;o--){for(p=0,g=0,a=l;a<=x;a++)p+=i.get(o,a)*i.get(a,x-1),g+=i.get(o,a)*i.get(a,x);if(h=i.get(o,o)-N,e[o]<0)A=h,T=p,C=g;else if(l=o,0===e[o]?(b=zx(-p,-g,h,O),i.set(o,x-1,b[0]),i.set(o,x,b[1])):(d=i.get(o,o+1),f=i.get(o+1,o),v=(n[o]-N)*(n[o]-N)+e[o]*e[o]-O*O,m=2*(n[o]-N)*O,0===v&&0===m&&(v=k*S*(Math.abs(h)+Math.abs(O)+Math.abs(d)+Math.abs(f)+Math.abs(A))),b=zx(d*T-A*p+O*g,d*C-A*g-O*p,v,m),i.set(o,x-1,b[0]),i.set(o,x,b[1]),Math.abs(d)>Math.abs(A)+Math.abs(O)?(i.set(o+1,x-1,(-p-h*i.get(o,x-1)+O*i.get(o,x))/d),i.set(o+1,x,(-g-h*i.get(o,x)-O*i.get(o,x-1))/d)):(b=zx(-T-f*i.get(o,x-1),-C-f*i.get(o,x),A,O),i.set(o+1,x-1,b[0]),i.set(o+1,x,b[1]))),c=Math.max(Math.abs(i.get(o,x-1)),Math.abs(i.get(o,x))),k*c*c>1)for(a=o;a<=x;a++)i.set(a,x-1,i.get(a,x-1)/c),i.set(a,x,i.get(a,x)/c)}for(o=0;o<t;o++)if(o<E||o>w)for(a=o;a<t;a++)r.set(o,a,i.get(o,a));for(a=t-1;a>=E;a--)for(o=E;o<=w;o++){for(A=0,s=E;s<=Math.min(a,w);s++)A+=r.get(o,s)*i.get(s,a);r.set(o,a,A)}}(o,l,s,a,t)}this.n=o,this.e=l,this.d=s,this.V=a}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t,e,n=this.n,r=this.e,i=this.d,o=new Sx(n,n);for(t=0;t<n;t++){for(e=0;e<n;e++)o.set(t,e,0);o.set(t,t,i[t]),r[t]>0?o.set(t,t+1,r[t]):r[t]<0&&o.set(t,t-1,r[t])}return o}}function zx(t,e,n,r){let i,o;return Math.abs(n)>Math.abs(r)?(i=r/n,o=n+i*r,[(t+i*e)/o,(e-i*t)/o]):(i=n/r,o=r+i*n,[(i*t+e)/o,(i*e-t)/o])}class Gx{constructor(t){if(!(t=Px.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,n,r,i=t,o=i.rows,a=new Sx(o,o),s=!0;for(n=0;n<o;n++){let t=0;for(r=0;r<n;r++){let o=0;for(e=0;e<r;e++)o+=a.get(r,e)*a.get(n,e);o=(i.get(n,r)-o)/a.get(r,r),a.set(n,r,o),t+=o*o}for(t=i.get(n,n)-t,s&&=t>0,a.set(n,n,Math.sqrt(Math.max(t,0))),r=n+1;r<o;r++)a.set(n,r,0)}this.L=a,this.positiveDefinite=s}isPositiveDefinite(){return this.positiveDefinite}solve(t){t=Px.checkMatrix(t);let e=this.L,n=e.rows;if(t.rows!==n)throw new Error("Matrix dimensions do not match");if(!1===this.isPositiveDefinite())throw new Error("Matrix is not positive definite");let r,i,o,a=t.columns,s=t.clone();for(o=0;o<n;o++)for(i=0;i<a;i++){for(r=0;r<o;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(o,r));s.set(o,i,s.get(o,i)/e.get(o,o))}for(o=n-1;o>=0;o--)for(i=0;i<a;i++){for(r=o+1;r<n;r++)s.set(o,i,s.get(o,i)-s.get(r,i)*e.get(r,o));s.set(o,i,s.get(o,i)/e.get(o,o))}return s}get lowerTriangularMatrix(){return this.L}}class Vx{constructor(t,e={}){t=Px.checkMatrix(t);let{Y:n}=e;const{scaleScores:r=!1,maxIterations:i=1e3,terminationCriteria:o=1e-10}=e;let a;if(n){if(n=ax.isAnyArray(n)&&"number"==typeof n[0]?Sx.columnVector(n):Px.checkMatrix(n),n.rows!==t.rows)throw new Error("Y should have the same number of rows as X");a=n.getColumnVector(0)}else a=t.getColumnVector(0);let s,l,u,c,h=1;for(let e=0;e<i&&h>o;e++)u=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),u=u.div(u.norm()),s=t.mmul(u).div(u.transpose().mmul(u).get(0,0)),e>0&&(h=s.clone().sub(c).pow(2).sum()),c=s.clone(),n?(l=n.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),l=l.div(l.norm()),a=n.mmul(l).div(l.transpose().mmul(l).get(0,0))):a=s;if(n){let e=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0));e=e.div(e.norm());let r=t.clone().sub(s.clone().mmul(e.transpose())),i=a.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),o=n.clone().sub(s.clone().mulS(i.get(0,0)).mmul(l.transpose()));this.t=s,this.p=e.transpose(),this.w=u.transpose(),this.q=l,this.u=a,this.s=s.transpose().mmul(s),this.xResidual=r,this.yResidual=o,this.betas=i}else this.w=u.transpose(),this.s=s.transpose().mmul(s).sqrt(),this.t=r?s.clone().div(this.s.get(0,0)):s,this.xResidual=t.sub(s.mmul(u.transpose()))}}tx.AbstractMatrix=kx,tx.CHO=Gx,tx.CholeskyDecomposition=Gx,tx.DistanceMatrix=Ox,tx.EVD=Fx,tx.EigenvalueDecomposition=Fx,tx.LU=Rx,tx.LuDecomposition=Rx;var Wx=tx.Matrix=Sx;tx.MatrixColumnSelectionView=class extends Tx{constructor(t,e){yx(t,e),super(t,t.rows,e.length),this.columnIndices=e}set(t,e,n){return this.matrix.set(t,this.columnIndices[e],n),this}get(t,e){return this.matrix.get(t,this.columnIndices[e])}},tx.MatrixColumnView=class extends Tx{constructor(t,e){px(t,e),super(t,t.rows,1),this.column=e}set(t,e,n){return this.matrix.set(t,this.column,n),this}get(t){return this.matrix.get(t,this.column)}},tx.MatrixFlipColumnView=class extends Tx{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(t,this.columns-e-1,n),this}get(t,e){return this.matrix.get(t,this.columns-e-1)}},tx.MatrixFlipRowView=class extends Tx{constructor(t){super(t,t.rows,t.columns)}set(t,e,n){return this.matrix.set(this.rows-t-1,e,n),this}get(t,e){return this.matrix.get(this.rows-t-1,e)}},tx.MatrixRowSelectionView=class extends Tx{constructor(t,e){mx(t,e),super(t,e.length,t.columns),this.rowIndices=e}set(t,e,n){return this.matrix.set(this.rowIndices[t],e,n),this}get(t,e){return this.matrix.get(this.rowIndices[t],e)}},tx.MatrixRowView=class extends Tx{constructor(t,e){fx(t,e),super(t,1,t.columns),this.row=e}set(t,e,n){return this.matrix.set(this.row,e,n),this}get(t,e){return this.matrix.get(this.row,e)}},tx.MatrixSelectionView=Cx,tx.MatrixSubView=class extends Tx{constructor(t,e,n,r,i){bx(t,e,n,r,i),super(t,n-e+1,i-r+1),this.startRow=e,this.startColumn=r}set(t,e,n){return this.matrix.set(this.startRow+t,this.startColumn+e,n),this}get(t,e){return this.matrix.get(this.startRow+t,this.startColumn+e)}},tx.MatrixTransposeView=class extends Tx{constructor(t){super(t,t.columns,t.rows)}set(t,e,n){return this.matrix.set(e,t,n),this}get(t,e){return this.matrix.get(e,t)}},tx.NIPALS=Vx,tx.Nipals=Vx,tx.QR=Lx,tx.QrDecomposition=Lx,tx.SVD=_x;var Hx=tx.SingularValueDecomposition=_x;tx.SymmetricMatrix=Nx,tx.WrapperMatrix1D=Ax,tx.WrapperMatrix2D=Px,tx.correlation=function(t,e=t,n={}){t=new Sx(t);let r=!1;if("object"!=typeof e||Sx.isMatrix(e)||ax.isAnyArray(e)?e=new Sx(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0,scale:o=!0}=n;i&&(t.center("column"),r||e.center("column")),o&&(t.scale("column"),r||e.scale("column"));const a=t.standardDeviation("column",{unbiased:!0}),s=r?a:e.standardDeviation("column",{unbiased:!0}),l=t.transpose().mmul(e);for(let e=0;e<l.rows;e++)for(let n=0;n<l.columns;n++)l.set(e,n,l.get(e,n)*(1/(a[e]*s[n]))*(1/(t.rows-1)));return l},tx.covariance=function(t,e=t,n={}){t=new Sx(t);let r=!1;if("object"!=typeof e||Sx.isMatrix(e)||ax.isAnyArray(e)?e=new Sx(e):(n=e,e=t,r=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=n;i&&(t=t.center("column"),r||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e<o.rows;e++)for(let n=0;n<o.columns;n++)o.set(e,n,o.get(e,n)*(1/(t.rows-1)));return o};var Ux=tx.default=Sx;tx.determinant=function t(e){if((e=Sx.checkMatrix(e)).isSquare()){if(0===e.columns)return 1;let n,r,i,o;if(2===e.columns)return n=e.get(0,0),r=e.get(0,1),i=e.get(1,0),o=e.get(1,1),n*o-r*i;if(3===e.columns){let o,a,s;return o=new Cx(e,[1,2],[1,2]),a=new Cx(e,[1,2],[0,2]),s=new Cx(e,[1,2],[0,1]),n=e.get(0,0),r=e.get(0,1),i=e.get(0,2),n*t(o)-r*t(a)+i*t(s)}return new Rx(e).determinant}throw Error("determinant can only be calculated for a square matrix")},tx.inverse=function(t,e=!1){return t=Px.checkMatrix(t),e?new _x(t).inverse():Ix(t,Sx.eye(t.rows))},tx.linearDependencies=function(t,e={}){const{thresholdValue:n=1e-9,thresholdError:r=1e-9}=e;let i=(t=Sx.checkMatrix(t)).rows,o=new Sx(i,i);for(let e=0;e<i;e++){let a=Sx.columnVector(t.getRow(e)),s=t.subMatrixRow(jx(i,e)).transpose(),l=new _x(s).solve(a),u=Sx.sub(a,s.mmul(l)).abs().max();o.setRow(e,Bx(u,l,e,n,r))}return o},tx.pseudoInverse=function(t,e=Number.EPSILON){if((t=Sx.checkMatrix(t)).isEmpty())return t.transpose();let n=new _x(t,{autoTranspose:!0}),r=n.leftSingularVectors,i=n.rightSingularVectors,o=n.diagonal;for(let t=0;t<o.length;t++)Math.abs(o[t])>e?o[t]=1/o[t]:o[t]=0;return i.mmul(Sx.diag(o).mmul(r.transpose()))},tx.solve=Ix,tx.wrap=function(t,e){if(ax.isAnyArray(t))return t[0]&&ax.isAnyArray(t[0])?new Px(t):new Ax(t,e);throw new Error("the argument is not an array")};const $x=Wx,Yx=Hx;Ux.Matrix&&Ux.Matrix;const qx={center:[0,0],linkDistance:50};class Xx{constructor(t={}){this.options=t,this.id="mds",this.options=Object.assign(Object.assign({},qx),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericMDSLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericMDSLayout(!0,t,e)}))}genericMDSLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i=[0,0],linkDistance:o=50}=r,a=e.getAllNodes(),s=e.getAllEdges();if(!(null==a?void 0:a.length)||1===a.length)return bb(e,t,i);const l=sb({nodes:a,edges:s}),u=ab(l);Kx(u);const c=((t,e)=>{const n=[];return t.forEach((t=>{const r=[];t.forEach((t=>{r.push(t*e)})),n.push(r)})),n})(u,o),h=Zx(c),d=[];h.forEach(((t,e)=>{const n=hb(a[e]);n.data.x=t[0]+i[0],n.data.y=t[1]+i[1],d.push(n)})),t&&d.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:d,edges:s}}))}}const Kx=t=>{let e=-999999;t.forEach((t=>{t.forEach((t=>{t!==1/0&&e<t&&(e=t)}))})),t.forEach(((n,r)=>{n.forEach(((n,i)=>{n===1/0&&(t[r][i]=e)}))}))},Zx=t=>{const e=$x.mul($x.pow(t,2),-.5),n=e.mean("row"),r=e.mean("column"),i=e.mean();e.add(i).subRowVector(n).subColumnVector(r);const o=new Yx(e),a=$x.sqrt(o.diagonalMatrix).diagonal();return o.leftSingularVectors.toJSON().map((t=>$x.mul([t],[a]).toJSON()[0].splice(0,2)))};function Qx(t){return!!t.tick&&!!t.stop}const Jx={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},tE={center:[0,0],comboPadding:10,treeKey:"combo"};class eE{constructor(t={}){this.options=t,this.id="comboCombined",this.options=Object.assign(Object.assign({},tE),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericComboCombinedLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericComboCombinedLayout(!0,t,e)}))}genericComboCombinedLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=this.initVals(Object.assign(Object.assign({},this.options),n)),{center:i,treeKey:o,outerLayout:a}=r,s=e.getAllNodes().filter((t=>!t.data._isCombo)),l=e.getAllNodes().filter((t=>t.data._isCombo)),u=e.getAllEdges(),c=null==s?void 0:s.length;if(!c||1===c)return bb(e,t,i);const h=[],d=new Map;s.forEach((t=>{d.set(t.id,t)}));const f=new Map;l.forEach((t=>{f.set(t.id,t)}));const p=new Map,g=this.getInnerGraphs(e,o,d,f,u,r,p);yield Promise.all(g);const v=new Map,m=[],y=new Map;let b=!0;e.getRoots(o).forEach((t=>{const n=p.get(t.id),r=f.get(t.id)||d.get(t.id),i={id:t.id,data:Object.assign(Object.assign({},t.data),{x:n.data.x||r.data.x,y:n.data.y||r.data.y,fx:n.data.fx||r.data.fx,fy:n.data.fy||r.data.fy,mass:n.data.mass||r.data.mass,size:n.data.size})};m.push(i),v.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):b=!1,ub(e,[t],(e=>{e.id!==t.id&&y.set(e.id,t.id)}),"TB",o)}));const x=[];let E;if(u.forEach((t=>{const e=y.get(t.source)||t.source,n=y.get(t.target)||t.target;e!==n&&v.has(e)&&v.has(n)&&x.push({id:t.id,source:e,target:n,data:{}})})),null==m?void 0:m.length){if(1===m.length)m[0].data.x=i[0],m[0].data.y=i[1];else{const t=new Yg({nodes:m,edges:x}),e=a||new qb;if(b&&Jx[e.id]){const e=m.length<100?new Xx:new Sb;yield e.assign(t)}const n=Object.assign({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===e.id?{gravity:1,factor:4,linkDistance:(t,e,n)=>(Math.max(...e.data.size)||32)/2+(Math.max(...n.data.size)||32)/2+200}:{});E=yield nE(e,t,n)}p.forEach((t=>{var e;const n=E.nodes.find((e=>e.id===t.id));if(n){const{x:e,y:r}=n.data;t.data.visited=!0,t.data.x=e,t.data.y=r,h.push({id:t.id,data:{x:e,y:r}})}const{x:r,y:i}=t.data;null===(e=t.data.nodes)||void 0===e||e.forEach((t=>{h.push({id:t.id,data:{x:t.data.x+r,y:t.data.y+i}})}))})),p.forEach((({data:t})=>{const{x:e,y:n,visited:r,nodes:i}=t;null==i||i.forEach((t=>{if(!r){const r=h.find((e=>e.id===t.id));r.data.x+=e||0,r.data.y+=n||0}}))}))}t&&h.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));return{nodes:h,edges:u}}))}initVals(t){const e=Object.assign({},t),{nodeSize:n,spacing:r,comboPadding:i}=t;let o,a,s;if(a=ae(r)?()=>r:Ut(r)?r:()=>0,e.spacing=a,n)if(Ut(n))o=t=>{const e=n(t),r=a(t);if(ob(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+r)/2}return((e||32)+r)/2};else if(ob(n)){const t=(n[0]>n[1]?n[0]:n[1])/2;o=e=>t+a(e)/2}else{const t=n/2;o=e=>t+a(e)/2}else o=t=>{const e=a(t);if(t.size){if(ob(t.size)){return((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2}if(qt(t.size)){return((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2}return(t.size+e)/2}return 32+e/2};return e.nodeSize=o,s=ae(i)?()=>i:ob(i)?()=>Math.max.apply(null,i):Ut(i)?i:()=>0,e.comboPadding=s,e}getInnerGraphs(t,e,n,r,i,o,a){const{nodeSize:s,comboPadding:l,spacing:u,innerLayout:c}=o,h=c||new Sb({}),d={center:[0,0],preventOverlap:!0,nodeSpacing:u},f=[],p=t=>{let e=(null==l?void 0:l(t))||10;return ob(e)&&(e=Math.max(...e)),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((o=>{a.set(o.id,{id:o.id,data:{nodes:[],size:p(o).size}});let l=Promise.resolve();ub(t,[o],(o=>{var u;if(!o.data._isCombo)return;const{size:c,padding:f}=p(o);if(null===(u=t.getChildren(o.id,e))||void 0===u?void 0:u.length){const u=a.get(o.id);a.set(o.id,{id:o.id,data:Object.assign({nodes:[]},null==u?void 0:u.data)});const c=new Map,p=t.getChildren(o.id,e).map((t=>{if(t.data._isCombo)return a.has(t.id)||a.set(t.id,{id:t.id,data:Object.assign({},t.data)}),c.set(t.id,!0),a.get(t.id);const e=n.get(t.id)||r.get(t.id);return c.set(t.id,!0),{id:t.id,data:Object.assign(Object.assign({},e.data),t.data)}})),g={nodes:p,edges:i.filter((t=>c.has(t.source)&&c.has(t.target)))};let v=1/0;p.forEach((t=>{var e;let{size:n}=t.data;n||(n=(null===(e=a.get(t.id))||void 0===e?void 0:e.data.size)||(null==s?void 0:s(t))||[30,30]),ae(n)&&(n=[n,n]);const[r,i]=n;v>r&&(v=r),v>i&&(v=i),t.data.size=n})),l=l.then((()=>ze(this,void 0,void 0,(function*(){const t=new Yg(g);yield nE(h,t,d,!0);const{minX:e,minY:n,maxX:r,maxY:i}=(t=>{let e=1/0,n=1/0,r=-1/0,i=-1/0;return t.forEach((t=>{let o=t.data.size;ob(o)?1===o.length&&(o=[o[0],o[0]]):ae(o)?o=[o,o]:(void 0===o||isNaN(o))&&(o=[30,30]);const a=[o[0]/2,o[1]/2],s=t.data.x-a[0],l=t.data.x+a[0],u=t.data.y-a[1],c=t.data.y+a[1];e>s&&(e=s),n>u&&(n=u),r<l&&(r=l),i<c&&(i=c)})),{minX:e,minY:n,maxX:r,maxY:i}})(p),s=(r+e)/2,l=(i+n)/2;g.nodes.forEach((t=>{t.data.x-=s,t.data.y-=l}));const u=[Math.max(r-e,v)+2*f,Math.max(i-n,v)+2*f];a.get(o.id).data.size=u,a.get(o.id).data.nodes=p}))))}else a.set(o.id,{id:o.id,data:Object.assign(Object.assign({},o.data),{size:c})});return!0}),"BT",e),f.push(l)})),f}}function nE(t,e,n,r){var i;return ze(this,void 0,void 0,(function*(){return Qx(t)?(t.execute(e,n),t.stop(),t.tick(null!==(i=n.iterations)&&void 0!==i?i:300)):r?yield t.assign(e,n):yield t.execute(e,n)}))}function rE(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,l=0;for(i=0;i<a;++i)s+=(o=n[i]).x,l+=o.y;for(s=(s/a-t)*r,l=(l/a-e)*r,i=0;i<a;++i)(o=n[i]).x-=s,o.y-=l}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t},i.x=function(e){return arguments.length?(t=+e,i):t},i.y=function(t){return arguments.length?(e=+t,i):e},i.strength=function(t){return arguments.length?(r=+t,i):r},i}function iE(t){return function(){return t}}function oE(t){return 1e-6*(t()-.5)}function aE(t){return t.x+t.vx}function sE(t){return t.y+t.vy}function lE(t){var e,n,r,i=1,o=1;function a(){for(var t,a,l,u,c,h,d,f=e.length,p=0;p<o;++p)for(a=Ab(e,aE,sE).visitAfter(s),t=0;t<f;++t)l=e[t],h=n[l.index],d=h*h,u=l.x+l.vx,c=l.y+l.vy,a.visit(g);function g(t,e,n,o,a){var s=t.data,f=t.r,p=h+f;if(!s)return e>u+p||o<u-p||n>c+p||a<c-p;if(s.index>l.index){var g=u-s.x-s.vx,v=c-s.y-s.vy,m=g*g+v*v;m<p*p&&(0===g&&(m+=(g=oE(r))*g),0===v&&(m+=(v=oE(r))*v),m=(p-(m=Math.sqrt(m)))/m*i,l.vx+=(g*=m)*(p=(f*=f)/(d+f)),l.vy+=(v*=m)*p,s.vx-=g*(p=1-p),s.vy-=v*p)}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function l(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r)i=e[r],n[i.index]=+t(i,r,e)}}return"function"!=typeof t&&(t=iE(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,l()},a.iterations=function(t){return arguments.length?(o=+t,a):o},a.strength=function(t){return arguments.length?(i=+t,a):i},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),l(),a):t},a}function uE(t){return t.index}function cE(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n}function hE(t){var e,n,r,i,o,a,s=uE,l=function(t){return 1/Math.min(i[t.source.index],i[t.target.index])},u=iE(30),c=1;function h(r){for(var i=0,s=t.length;i<c;++i)for(var l,u,h,d,f,p,g,v=0;v<s;++v)u=(l=t[v]).source,d=(h=l.target).x+h.vx-u.x-u.vx||oE(a),f=h.y+h.vy-u.y-u.vy||oE(a),d*=p=((p=Math.sqrt(d*d+f*f))-n[v])/p*r*e[v],f*=p,h.vx-=d*(g=o[v]),h.vy-=f*g,u.vx+=d*(g=1-g),u.vy+=f*g}function d(){if(r){var a,l,u=r.length,c=t.length,h=new Map(r.map(((t,e)=>[s(t,e,r),t])));for(a=0,i=new Array(u);a<c;++a)(l=t[a]).index=a,"object"!=typeof l.source&&(l.source=cE(h,l.source)),"object"!=typeof l.target&&(l.target=cE(h,l.target)),i[l.source.index]=(i[l.source.index]||0)+1,i[l.target.index]=(i[l.target.index]||0)+1;for(a=0,o=new Array(c);a<c;++a)l=t[a],o[a]=i[l.source.index]/(i[l.source.index]+i[l.target.index]);e=new Array(c),f(),n=new Array(c),p()}}function f(){if(r)for(var n=0,i=t.length;n<i;++n)e[n]=+l(t[n],n,t)}function p(){if(r)for(var e=0,i=t.length;e<i;++e)n[e]=+u(t[e],e,t)}return null==t&&(t=[]),h.initialize=function(t,e){r=t,a=e,d()},h.links=function(e){return arguments.length?(t=e,d(),h):t},h.id=function(t){return arguments.length?(s=t,h):s},h.iterations=function(t){return arguments.length?(c=+t,h):c},h.strength=function(t){return arguments.length?(l="function"==typeof t?t:iE(+t),f(),h):l},h.distance=function(t){return arguments.length?(u="function"==typeof t?t:iE(+t),p(),h):u},h}var dE={value:()=>{}};function fE(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[]}return new pE(r)}function pE(t){this._=t}function gE(t,e){for(var n,r=0,i=t.length;r<i;++r)if((n=t[r]).name===e)return n.value}function vE(t,e,n){for(var r=0,i=t.length;r<i;++r)if(t[r].name===e){t[r]=dE,t=t.slice(0,r).concat(t.slice(r+1));break}return null!=n&&t.push({name:e,value:n}),t}pE.prototype=fE.prototype={constructor:pE,on:function(t,e){var n,r,i=this._,o=(r=i,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(n=(t=o[a]).type)i[n]=vE(i[n],t.name,e);else if(null==e)for(n in i)i[n]=vE(i[n],t.name,null);return this}for(;++a<s;)if((n=(t=o[a]).type)&&(n=gE(i[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new pE(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o)i[o]=arguments[o+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o)r[o].value.apply(e,i)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i)r[i].value.apply(e,n)}};var mE,yE,bE=0,xE=0,EE=0,wE=0,kE=0,ME=0,SE="object"==typeof performance&&performance.now?performance:Date,NE="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function OE(){return kE||(NE(TE),kE=SE.now()+ME)}function TE(){kE=0}function CE(){this._call=this._time=this._next=null}function AE(t,e,n){var r=new CE;return r.restart(t,e,n),r}function PE(){kE=(wE=SE.now())+ME,bE=xE=0;try{!function(){OE(),++bE;for(var t,e=mE;e;)(t=kE-e._time)>=0&&e._call.call(void 0,t),e=e._next;--bE}()}finally{bE=0,function(){var t,e,n=mE,r=1/0;for(;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:mE=e);yE=t,DE(r)}(),kE=0}}function RE(){var t=SE.now(),e=t-wE;e>1e3&&(ME-=e,wE=t)}function DE(t){bE||(xE&&(xE=clearTimeout(xE)),t-kE>24?(t<1/0&&(xE=setTimeout(PE,t-SE.now()-ME)),EE&&(EE=clearInterval(EE))):(EE||(wE=SE.now(),EE=setInterval(RE,1e3)),bE=1,NE(PE)))}CE.prototype=AE.prototype={constructor:CE,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?OE():+n)+(null==e?0:+e),this._next||yE===this||(yE?yE._next=this:mE=this,yE=this),this._call=t,this._time=n,DE()},stop:function(){this._call&&(this._call=null,this._time=1/0,DE())}};const LE=4294967296;function _E(t){return t.x}function IE(t){return t.y}var jE=Math.PI*(3-Math.sqrt(5));function BE(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map,l=AE(h),u=fE("tick","end"),c=function(){let t=1;return()=>(t=(1664525*t+1013904223)%LE)/LE}();function h(){d(),u.call("tick",e),n<r&&(l.stop(),u.call("end",e))}function d(r){var l,u,c=t.length;void 0===r&&(r=1);for(var h=0;h<r;++h)for(n+=(o-n)*i,s.forEach((function(t){t(n)})),l=0;l<c;++l)null==(u=t[l]).fx?u.x+=u.vx*=a:(u.x=u.fx,u.vx=0),null==u.fy?u.y+=u.vy*=a:(u.y=u.fy,u.vy=0);return e}function f(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=10*Math.sqrt(.5+n),o=n*jE;e.x=i*Math.cos(o),e.y=i*Math.sin(o)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function p(e){return e.initialize&&e.initialize(t,c),e}return null==t&&(t=[]),f(),e={tick:d,restart:function(){return l.restart(h),e},stop:function(){return l.stop(),e},nodes:function(n){return arguments.length?(t=n,f(),s.forEach(p),e):t},alpha:function(t){return arguments.length?(n=+t,e):n},alphaMin:function(t){return arguments.length?(r=+t,e):r},alphaDecay:function(t){return arguments.length?(i=+t,e):+i},alphaTarget:function(t){return arguments.length?(o=+t,e):o},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(c=t,s.forEach(p),e):c},force:function(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t)},find:function(e,n,r){var i,o,a,s,l,u=0,c=t.length;for(null==r?r=1/0:r*=r,u=0;u<c;++u)(a=(i=e-(s=t[u]).x)*i+(o=n-s.y)*o)<r&&(l=s,r=a);return l},on:function(t,n){return arguments.length>1?(u.on(t,n),e):u.on(t)}}}function FE(){var t,e,n,r,i,o=iE(-30),a=1,s=1/0,l=.81;function u(n){var i,o=t.length,a=Ab(t,_E,IE).visitAfter(h);for(r=n,i=0;i<o;++i)e=t[i],a.visit(d)}function c(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e)n=t[e],i[n.index]=+o(n,e,t)}}function h(t){var e,n,r,o,a,s=0,l=0;if(t.length){for(r=o=a=0;a<4;++a)(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,l+=n,r+=n*e.x,o+=n*e.y);t.x=r/l,t.y=o/l}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index]}while(e=e.next)}t.value=s}function d(t,o,u,c){if(!t.value)return!0;var h=t.x-e.x,d=t.y-e.y,f=c-o,p=h*h+d*d;if(f*f/l<p)return p<s&&(0===h&&(p+=(h=oE(n))*h),0===d&&(p+=(d=oE(n))*d),p<a&&(p=Math.sqrt(a*p)),e.vx+=h*t.value*r/p,e.vy+=d*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===h&&(p+=(h=oE(n))*h),0===d&&(p+=(d=oE(n))*d),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(f=i[t.data.index]*r/p,e.vx+=h*f,e.vy+=d*f)}while(t=t.next)}}return u.initialize=function(e,r){t=e,n=r,c()},u.strength=function(t){return arguments.length?(o="function"==typeof t?t:iE(+t),c(),u):o},u.distanceMin=function(t){return arguments.length?(a=t*t,u):Math.sqrt(a)},u.distanceMax=function(t){return arguments.length?(s=t*t,u):Math.sqrt(s)},u.theta=function(t){return arguments.length?(l=t*t,u):Math.sqrt(l)},u}function zE(t,e,n){var r,i,o,a=iE(.1);function s(t){for(var a=0,s=r.length;a<s;++a){var l=r[a],u=l.x-e||1e-6,c=l.y-n||1e-6,h=Math.sqrt(u*u+c*c),d=(o[a]-h)*i[a]*t/h;l.vx+=u*d,l.vy+=c*d}}function l(){if(r){var e,n=r.length;for(i=new Array(n),o=new Array(n),e=0;e<n;++e)o[e]=+t(r[e],e,r),i[e]=isNaN(o[e])?0:+a(r[e],e,r)}}return"function"!=typeof t&&(t=iE(+t)),null==e&&(e=0),null==n&&(n=0),s.initialize=function(t){r=t,l()},s.strength=function(t){return arguments.length?(a="function"==typeof t?t:iE(+t),l(),s):a},s.radius=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),l(),s):t},s.x=function(t){return arguments.length?(e=+t,s):e},s.y=function(t){return arguments.length?(n=+t,s):n},s}function GE(t){var e,n,r,i=iE(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vx+=(r[o]-i.x)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=iE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:iE(+t),a(),o):i},o.x=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),a(),o):t},o}function VE(t){var e,n,r,i=iE(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o)(i=e[o]).vy+=(r[o]-i.y)*n[o]*t}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o)n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e)}}return"function"!=typeof t&&(t=iE(null==t?0:+t)),o.initialize=function(t){e=t,a()},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:iE(+t),a(),o):i},o.y=function(e){return arguments.length?(t="function"==typeof e?e:iE(+e),a(),o):t},o}class WE{constructor(t){this.id="d3-force",this.config={inputNodeAttrs:["x","y","vx","vy","fx","fy"],outputNodeAttrs:["x","y","vx","vy"],simulationAttrs:["alpha","alphaMin","alphaDecay","alphaTarget","velocityDecay","randomSource"]},this.forceMap={link:hE,manyBody:FE,center:rE,collide:lE,radial:zE,x:GE,y:VE},this.options={link:{id:t=>t.id},manyBody:{},center:{x:0,y:0}},this.context={options:{},assign:!1,nodes:[],edges:[]},ke(this.options,t),this.options.forceSimulation&&(this.simulation=this.options.forceSimulation)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericLayout(!0,t,e)}))}stop(){this.simulation.stop()}tick(t){return this.simulation.tick(t),this.getResult()}restart(){this.simulation.restart()}setFixedPosition(t,e){const n=this.context.nodes.find((e=>e.id===t));n&&e.forEach(((t,e)=>{if("number"==typeof t||null===t){n[["fx","fy","fz"][e]]=t}}))}getOptions(t){var e,n;const r=ke({},this.options,t);return r.collide&&void 0===(null===(e=r.collide)||void 0===e?void 0:e.radius)&&(r.collide=r.collide||{},r.collide.radius=null!==(n=r.nodeSize)&&void 0!==n?n:10),void 0===r.iterations&&(r.link&&void 0===r.link.iterations&&(r.iterations=r.link.iterations),r.collide&&void 0===r.collide.iterations&&(r.iterations=r.collide.iterations)),this.context.options=r,r}genericLayout(t,e,n){var r;return ze(this,void 0,void 0,(function*(){const i=this.getOptions(n),o=e.getAllNodes().map((({id:t,data:e})=>Object.assign(Object.assign({id:t},e),Ae(e.data,this.config.inputNodeAttrs)))),a=e.getAllEdges().map((t=>Object.assign({},t)));Object.assign(this.context,{assign:t,nodes:o,edges:a,graph:e});const s=new Promise((t=>{this.resolver=t})),l=this.setSimulation(i);return l.nodes(o),null===(r=l.force("link"))||void 0===r||r.links(a),s}))}getResult(){const{assign:t,nodes:e,edges:n,graph:r}=this.context,i=e.map((t=>({id:t.id,data:Object.assign(Object.assign({},t.data),Ae(t,this.config.outputNodeAttrs))}))),o=n.map((({id:t,source:e,target:n,data:r})=>({id:t,source:"object"==typeof e?e.id:e,target:"object"==typeof n?n.id:n,data:r})));return t&&i.forEach((t=>r.mergeNodeData(t.id,t.data))),{nodes:i,edges:o}}initSimulation(){return BE()}setSimulation(t){const e=this.simulation||this.options.forceSimulation||this.initSimulation();return this.simulation||(this.simulation=e.on("tick",(()=>{var e;return null===(e=t.onTick)||void 0===e?void 0:e.call(t,this.getResult())})).on("end",(()=>{var t;return null===(t=this.resolver)||void 0===t?void 0:t.call(this,this.getResult())}))),HE(e,this.config.simulationAttrs.map((e=>[e,t[e]]))),Object.entries(this.forceMap).forEach((([n,r])=>{const i=n;if(t[n]){let n=e.force(i);n||(n=r(),e.force(i,n)),HE(n,Object.entries(t[i]))}else e.force(i,null)})),e}}const HE=(t,e)=>e.reduce(((e,[n,r])=>e[n]&&void 0!==r?e[n].call(t,r):e),t);var UE,$E,YE,qE,XE,KE,ZE,QE,JE,tw,ew,nw,rw,iw,ow,aw,sw,lw,uw,cw,hw,dw,fw,pw,gw,vw,mw,yw,bw,xw,Ew,ww,kw,Mw,Sw,Nw,Ow,Tw,Cw,Aw,Pw,Rw,Dw,Lw,_w,Iw,jw,Bw,Fw,zw,Gw,Vw,Ww,Hw,Uw,$w,Yw,qw,Xw,Kw,Zw,Qw,Jw,tk,ek,nk,rk,ik,ok,ak,sk,lk,uk,ck,hk,dk,fk,pk,gk,vk,mk,yk,bk,xk,Ek,wk,kk,Mk,Sk,Nk,Ok,Tk,Ck,Ak,Pk,Rk,Dk,Lk,_k,Ik,jk,Bk,Fk,zk,Gk,Vk,Wk,Hk;function Uk(){if(qE)return YE;return qE=1,YE=function(t,e){return t===e||t!=t&&e!=e}}function $k(){if(KE)return XE;KE=1;var t=Uk();return XE=function(e,n){for(var r=e.length;r--;)if(t(e[r][0],n))return r;return-1},XE}function Yk(){if(aw)return ow;aw=1;var t=$E?UE:($E=1,UE=function(){this.__data__=[],this.size=0}),e=function(){if(QE)return ZE;QE=1;var t=$k(),e=Array.prototype.splice;return ZE=function(n){var r=this.__data__,i=t(r,n);return!(i<0||(i==r.length-1?r.pop():e.call(r,i,1),--this.size,0))},ZE}(),n=function(){if(tw)return JE;tw=1;var t=$k();return JE=function(e){var n=this.__data__,r=t(n,e);return r<0?void 0:n[r][1]},JE}(),r=function(){if(nw)return ew;nw=1;var t=$k();return ew=function(e){return t(this.__data__,e)>-1}}(),i=function(){if(iw)return rw;iw=1;var t=$k();return rw=function(e,n){var r=this.__data__,i=t(r,e);return i<0?(++this.size,r.push([e,n])):r[i][1]=n,this},rw}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,ow=o}function qk(){if(vw)return gw;vw=1;var t="object"==typeof x&&x&&x.Object===Object&&x;return gw=t}function Xk(){if(yw)return mw;yw=1;var t=qk(),e="object"==typeof self&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return mw=n}function Kk(){if(xw)return bw;xw=1;var t=Xk().Symbol;return bw=t}function Zk(){if(Nw)return Sw;Nw=1;var t=Kk(),e=function(){if(ww)return Ew;ww=1;var t=Kk(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,i=t?t.toStringTag:void 0;return Ew=function(t){var e=n.call(t,i),o=t[i];try{t[i]=void 0;var a=!0}catch(t){}var s=r.call(t);return a&&(e?t[i]=o:delete t[i]),s}}(),n=function(){if(Mw)return kw;Mw=1;var t=Object.prototype.toString;return kw=function(e){return t.call(e)}}(),r=t?t.toStringTag:void 0;return Sw=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":r&&r in Object(t)?e(t):n(t)}}function Qk(){if(Tw)return Ow;return Tw=1,Ow=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function Jk(){if(Aw)return Cw;Aw=1;var t=Zk(),e=Qk();return Cw=function(n){if(!e(n))return!1;var r=t(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function tM(){if(Lw)return Dw;Lw=1;var t,e=function(){if(Rw)return Pw;Rw=1;var t=Xk()["__core-js_shared__"];return Pw=t}(),n=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return Dw=function(t){return!!n&&n in t}}function eM(){if(Iw)return _w;Iw=1;var t=Function.prototype.toString;return _w=function(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}function nM(){if(Vw)return Gw;Vw=1;var t=function(){if(Bw)return jw;Bw=1;var t=Jk(),e=tM(),n=Qk(),r=eM(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,a=Object.prototype,s=o.toString,l=a.hasOwnProperty,u=RegExp("^"+s.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return jw=function(o){return!(!n(o)||e(o))&&(t(o)?u:i).test(r(o))}}(),e=zw?Fw:(zw=1,Fw=function(t,e){return null==t?void 0:t[e]});return Gw=function(n,r){var i=e(n,r);return t(i)?i:void 0}}function rM(){if(Hw)return Ww;Hw=1;var t=nM()(Xk(),"Map");return Ww=t}function iM(){if($w)return Uw;$w=1;var t=nM()(Object,"create");return Uw=t}function oM(){if(ik)return rk;ik=1;var t=function(){if(qw)return Yw;qw=1;var t=iM();return Yw=function(){this.__data__=t?t(null):{},this.size=0}}(),e=Kw?Xw:(Kw=1,Xw=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}),n=function(){if(Qw)return Zw;Qw=1;var t=iM(),e=Object.prototype.hasOwnProperty;return Zw=function(n){var r=this.__data__;if(t){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return e.call(r,n)?r[n]:void 0},Zw}(),r=function(){if(tk)return Jw;tk=1;var t=iM(),e=Object.prototype.hasOwnProperty;return Jw=function(n){var r=this.__data__;return t?void 0!==r[n]:e.call(r,n)},Jw}(),i=function(){if(nk)return ek;nk=1;var t=iM();return ek=function(e,n){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=t&&void 0===n?"__lodash_hash_undefined__":n,this},ek}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,rk=o}function aM(){if(ck)return uk;ck=1;var t=lk?sk:(lk=1,sk=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t});return uk=function(e,n){var r=e.__data__;return t(n)?r["string"==typeof n?"string":"hash"]:r.map},uk}function sM(){if(xk)return bk;xk=1;var t=function(){if(ak)return ok;ak=1;var t=oM(),e=Yk(),n=rM();return ok=function(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}}(),e=function(){if(dk)return hk;dk=1;var t=aM();return hk=function(e){var n=t(this,e).delete(e);return this.size-=n?1:0,n}}(),n=function(){if(pk)return fk;pk=1;var t=aM();return fk=function(e){return t(this,e).get(e)}}(),r=function(){if(vk)return gk;vk=1;var t=aM();return gk=function(e){return t(this,e).has(e)}}(),i=function(){if(yk)return mk;yk=1;var t=aM();return mk=function(e,n){var r=t(this,e),i=r.size;return r.set(e,n),this.size+=r.size==i?0:1,this},mk}();function o(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}return o.prototype.clear=t,o.prototype.delete=e,o.prototype.get=n,o.prototype.has=r,o.prototype.set=i,bk=o}function lM(){if(Mk)return kk;Mk=1;var t=Yk(),e=function(){if(lw)return sw;lw=1;var t=Yk();return sw=function(){this.__data__=new t,this.size=0}}(),n=(cw||(cw=1,uw=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}),uw),r=dw?hw:(dw=1,hw=function(t){return this.__data__.get(t)}),i=pw?fw:(pw=1,fw=function(t){return this.__data__.has(t)}),o=function(){if(wk)return Ek;wk=1;var t=Yk(),e=rM(),n=sM();return Ek=function(r,i){var o=this.__data__;if(o instanceof t){var a=o.__data__;if(!e||a.length<199)return a.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(a)}return o.set(r,i),this.size=o.size,this},Ek}();function a(e){var n=this.__data__=new t(e);this.size=n.size}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=i,a.prototype.set=o,kk=a}function uM(){if(Nk)return Sk;return Nk=1,Sk=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t},Sk}function cM(){if(Tk)return Ok;Tk=1;var t=nM(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return Ok=e}function hM(){if(Ak)return Ck;Ak=1;var t=cM();return Ck=function(e,n,r){"__proto__"==n&&t?t(e,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[n]=r}}function dM(){if(Rk)return Pk;Rk=1;var t=hM(),e=Uk(),n=Object.prototype.hasOwnProperty;return Pk=function(r,i,o){var a=r[i];n.call(r,i)&&e(a,o)&&(void 0!==o||i in r)||t(r,i,o)}}function fM(){if(Lk)return Dk;Lk=1;var t=dM(),e=hM();return Dk=function(n,r,i,o){var a=!i;i||(i={});for(var s=-1,l=r.length;++s<l;){var u=r[s],c=o?o(i[u],n[u],u,i,n):void 0;void 0===c&&(c=n[u]),a?e(i,u,c):t(i,u,c)}return i},Dk}function pM(){if(Bk)return jk;return Bk=1,jk=function(t){return null!=t&&"object"==typeof t}}function gM(){if(Vk)return Gk;Vk=1;var t=function(){if(zk)return Fk;zk=1;var t=Zk(),e=pM();return Fk=function(n){return e(n)&&"[object Arguments]"==t(n)}}(),e=pM(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=t(function(){return arguments}())?t:function(t){return e(t)&&r.call(t,"callee")&&!i.call(t,"callee")};return Gk=o}function vM(){if(Hk)return Wk;Hk=1;var t=Array.isArray;return Wk=t}var mM,yM,bM,xM,EM,wM,kM,MM,SM,NM,OM,TM={exports:{}};function CM(){return bM||(bM=1,function(t,e){var n=Xk(),r=yM?mM:(yM=1,mM=function(){return!1}),i=e&&!e.nodeType&&e,o=i&&t&&!t.nodeType&&t,a=o&&o.exports===i?n.Buffer:void 0,s=(a?a.isBuffer:void 0)||r;t.exports=s}(TM,TM.exports)),TM.exports}function AM(){if(EM)return xM;EM=1;var t=/^(?:0|[1-9]\d*)$/;return xM=function(e,n){var r=typeof e;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n},xM}function PM(){if(kM)return wM;kM=1;return wM=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function RM(){if(OM)return NM;return OM=1,NM=function(t){return function(e){return t(e)}}}var DM,LM,_M,IM,jM,BM,FM,zM,GM,VM,WM,HM,UM,$M,YM,qM,XM,KM,ZM,QM,JM,tS,eS,nS,rS,iS,oS,aS={exports:{}};function sS(){return DM||(DM=1,function(t,e){var n=qk(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r&&n.process,a=function(){try{var t=i&&i.require&&i.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=a}(aS,aS.exports)),aS.exports}function lS(){if(_M)return LM;_M=1;var t=function(){if(SM)return MM;SM=1;var t=Zk(),e=PM(),n=pM(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,MM=function(i){return n(i)&&e(i.length)&&!!r[t(i)]}}(),e=RM(),n=sS(),r=n&&n.isTypedArray,i=r?e(r):t;return LM=i}function uS(){if(jM)return IM;jM=1;var t=(Ik||(Ik=1,_k=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}),_k),e=gM(),n=vM(),r=CM(),i=AM(),o=lS(),a=Object.prototype.hasOwnProperty;return IM=function(s,l){var u=n(s),c=!u&&e(s),h=!u&&!c&&r(s),d=!u&&!c&&!h&&o(s),f=u||c||h||d,p=f?t(s.length,String):[],g=p.length;for(var v in s)!l&&!a.call(s,v)||f&&("length"==v||h&&("offset"==v||"parent"==v)||d&&("buffer"==v||"byteLength"==v||"byteOffset"==v)||i(v,g))||p.push(v);return p},IM}function cS(){if(FM)return BM;FM=1;var t=Object.prototype;return BM=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}}function hS(){if(GM)return zM;return GM=1,zM=function(t,e){return function(n){return t(e(n))}}}function dS(){if(UM)return HM;UM=1;var t=cS(),e=function(){if(WM)return VM;WM=1;var t=hS()(Object.keys,Object);return VM=t}(),n=Object.prototype.hasOwnProperty;return HM=function(r){if(!t(r))return e(r);var i=[];for(var o in Object(r))n.call(r,o)&&"constructor"!=o&&i.push(o);return i}}function fS(){if(YM)return $M;YM=1;var t=Jk(),e=PM();return $M=function(n){return null!=n&&e(n.length)&&!t(n)}}function pS(){if(XM)return qM;XM=1;var t=uS(),e=dS(),n=fS();return qM=function(r){return n(r)?t(r):e(r)}}function gS(){if(eS)return tS;eS=1;var t=Qk(),e=cS(),n=JM?QM:(JM=1,QM=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}),r=Object.prototype.hasOwnProperty;return tS=function(i){if(!t(i))return n(i);var o=e(i),a=[];for(var s in i)("constructor"!=s||!o&&r.call(i,s))&&a.push(s);return a}}function vS(){if(rS)return nS;rS=1;var t=uS(),e=gS(),n=fS();return nS=function(r){return n(r)?t(r,!0):e(r)}}var mS,yS,bS,xS,ES,wS,kS,MS,SS,NS,OS,TS,CS,AS,PS,RS,DS,LS,_S,IS,jS,BS,FS,zS,GS,VS,WS,HS,US,$S,YS,qS,XS,KS,ZS,QS,JS,tN,eN,nN,rN,iN,oN,aN,sN,lN,uN,cN,hN,dN,fN,pN,gN,vN,mN,yN,bN,xN,EN,wN,kN,MN,SN,NN,ON,TN,CN,AN,PN,RN,DN,LN,_N,IN,jN,BN,FN,zN,GN,VN,WN,HN,UN,$N,YN,qN,XN,KN,ZN,QN,JN,tO,eO,nO,rO,iO,oO,aO,sO,lO,uO,cO,hO,dO,fO,pO,gO,vO,mO,yO,bO,xO,EO,wO,kO,MO,SO,NO,OO,TO,CO,AO,PO,RO,DO,LO,_O,IO,jO,BO,FO,zO,GO,VO,WO,HO,UO,$O,YO,qO,XO,KO,ZO,QO,JO,tT,eT,nT,rT,iT,oT,aT,sT,lT,uT,cT,hT,dT,fT,pT,gT,vT,mT,yT,bT,xT,ET,wT,kT,MT,ST,NT,OT,TT,CT,AT,PT,RT,DT,LT,_T,IT,jT,BT,FT,zT,GT,VT,WT,HT,UT,$T,YT,qT,XT,KT,ZT,QT,JT,tC,eC,nC,rC,iC,oC,aC,sC,lC,uC,cC,hC,dC,fC,pC,gC,vC,mC,yC,bC,xC,EC,wC,kC,MC,SC,NC,OC,TC,CC,AC,PC,RC,DC,LC,_C,IC,jC,BC,FC,zC,GC,VC,WC,HC,UC,$C,YC,qC,XC,KC,ZC,QC,JC,tA,eA,nA,rA,iA,oA,aA,sA,lA,uA,cA,hA,dA,fA,pA,gA,vA,mA,yA,bA,xA,EA,wA,kA,MA,SA,NA,OA={exports:{}};function TA(){return mS||(mS=1,function(t,e){var n=Xk(),r=e&&!e.nodeType&&e,i=r&&t&&!t.nodeType&&t,o=i&&i.exports===r?n.Buffer:void 0,a=o?o.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=a?a(n):new t.constructor(n);return t.copy(r),r}}(OA,OA.exports)),OA.exports}function CA(){if(bS)return yS;return bS=1,yS=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e},yS}function AA(){if(ES)return xS;return ES=1,xS=function(t,e){for(var n=-1,r=null==t?0:t.length,i=0,o=[];++n<r;){var a=t[n];e(a,n,t)&&(o[i++]=a)}return o},xS}function PA(){if(kS)return wS;return kS=1,wS=function(){return[]}}function RA(){if(SS)return MS;SS=1;var t=AA(),e=PA(),n=Object.prototype.propertyIsEnumerable,r=Object.getOwnPropertySymbols;return MS=r?function(e){return null==e?[]:(e=Object(e),t(r(e),(function(t){return n.call(e,t)})))}:e}function DA(){if(CS)return TS;return CS=1,TS=function(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t},TS}function LA(){if(PS)return AS;PS=1;var t=hS()(Object.getPrototypeOf,Object);return AS=t}function _A(){if(DS)return RS;DS=1;var t=DA(),e=LA(),n=RA(),r=PA(),i=Object.getOwnPropertySymbols;return RS=i?function(r){for(var i=[];r;)t(i,n(r)),r=e(r);return i}:r}function IA(){if(jS)return IS;jS=1;var t=DA(),e=vM();return IS=function(n,r,i){var o=r(n);return e(n)?o:t(o,i(n))}}function jA(){if(FS)return BS;FS=1;var t=IA(),e=RA(),n=pS();return BS=function(r){return t(r,n,e)}}function BA(){if(YS)return $S;YS=1;var t=nM()(Xk(),"Set");return $S=t}function FA(){if(ZS)return KS;ZS=1;var t=function(){if(WS)return VS;WS=1;var t=nM()(Xk(),"DataView");return VS=t}(),e=rM(),n=function(){if(US)return HS;US=1;var t=nM()(Xk(),"Promise");return HS=t}(),r=BA(),i=function(){if(XS)return qS;XS=1;var t=nM()(Xk(),"WeakMap");return qS=t}(),o=Zk(),a=eM(),s="[object Map]",l="[object Promise]",u="[object Set]",c="[object WeakMap]",h="[object DataView]",d=a(t),f=a(e),p=a(n),g=a(r),v=a(i),m=o;return(t&&m(new t(new ArrayBuffer(1)))!=h||e&&m(new e)!=s||n&&m(n.resolve())!=l||r&&m(new r)!=u||i&&m(new i)!=c)&&(m=function(t){var e=o(t),n="[object Object]"==e?t.constructor:void 0,r=n?a(n):"";if(r)switch(r){case d:return h;case f:return s;case p:return l;case g:return u;case v:return c}return e}),KS=m}function zA(){if(eN)return tN;eN=1;var t=Xk().Uint8Array;return tN=t}function GA(){if(rN)return nN;rN=1;var t=zA();return nN=function(e){var n=new e.constructor(e.byteLength);return new t(n).set(new t(e)),n}}function VA(){if(hN)return cN;hN=1;var t=GA();return cN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}}function WA(){if(fN)return dN;fN=1;var t=GA(),e=function(){if(oN)return iN;oN=1;var t=GA();return iN=function(e,n){var r=n?t(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}}(),n=function(){if(sN)return aN;sN=1;var t=/\w*$/;return aN=function(e){var n=new e.constructor(e.source,t.exec(e));return n.lastIndex=e.lastIndex,n}}(),r=function(){if(uN)return lN;uN=1;var t=Kk(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;return lN=function(t){return n?Object(n.call(t)):{}}}(),i=VA();return dN=function(o,a,s){var l=o.constructor;switch(a){case"[object ArrayBuffer]":return t(o);case"[object Boolean]":case"[object Date]":return new l(+o);case"[object DataView]":return e(o,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(o,s);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(o);case"[object RegExp]":return n(o);case"[object Symbol]":return r(o)}}}function HA(){if(gN)return pN;gN=1;var t=Qk(),e=Object.create,n=function(){function n(){}return function(r){if(!t(r))return{};if(e)return e(r);n.prototype=r;var i=new n;return n.prototype=void 0,i}}();return pN=n}function UA(){if(mN)return vN;mN=1;var t=HA(),e=LA(),n=cS();return vN=function(r){return"function"!=typeof r.constructor||n(r)?{}:t(e(r))}}function $A(){if(EN)return xN;EN=1;var t=function(){if(bN)return yN;bN=1;var t=FA(),e=pM();return yN=function(n){return e(n)&&"[object Map]"==t(n)}}(),e=RM(),n=sS(),r=n&&n.isMap,i=r?e(r):t;return xN=i}function YA(){if(SN)return MN;SN=1;var t=function(){if(kN)return wN;kN=1;var t=FA(),e=pM();return wN=function(n){return e(n)&&"[object Set]"==t(n)}}(),e=RM(),n=sS(),r=n&&n.isSet,i=r?e(r):t;return MN=i}function qA(){if(ON)return NN;ON=1;var t=lM(),e=uM(),n=dM(),r=function(){if(ZM)return KM;ZM=1;var t=fM(),e=pS();return KM=function(n,r){return n&&t(r,e(r),n)}}(),i=function(){if(oS)return iS;oS=1;var t=fM(),e=vS();return iS=function(n,r){return n&&t(r,e(r),n)}}(),o=TA(),a=CA(),s=function(){if(OS)return NS;OS=1;var t=fM(),e=RA();return NS=function(n,r){return t(n,e(n),r)}}(),l=function(){if(_S)return LS;_S=1;var t=fM(),e=_A();return LS=function(n,r){return t(n,e(n),r)}}(),u=jA(),c=function(){if(GS)return zS;GS=1;var t=IA(),e=_A(),n=vS();return zS=function(r){return t(r,n,e)}}(),h=FA(),d=function(){if(JS)return QS;JS=1;var t=Object.prototype.hasOwnProperty;return QS=function(e){var n=e.length,r=new e.constructor(n);return n&&"string"==typeof e[0]&&t.call(e,"index")&&(r.index=e.index,r.input=e.input),r},QS}(),f=WA(),p=UA(),g=vM(),v=CM(),m=$A(),y=Qk(),b=YA(),x=pS(),E=vS(),w="[object Arguments]",k="[object Function]",M="[object Object]",S={};return S[w]=S["[object Array]"]=S["[object ArrayBuffer]"]=S["[object DataView]"]=S["[object Boolean]"]=S["[object Date]"]=S["[object Float32Array]"]=S["[object Float64Array]"]=S["[object Int8Array]"]=S["[object Int16Array]"]=S["[object Int32Array]"]=S["[object Map]"]=S["[object Number]"]=S[M]=S["[object RegExp]"]=S["[object Set]"]=S["[object String]"]=S["[object Symbol]"]=S["[object Uint8Array]"]=S["[object Uint8ClampedArray]"]=S["[object Uint16Array]"]=S["[object Uint32Array]"]=!0,S["[object Error]"]=S[k]=S["[object WeakMap]"]=!1,NN=function N(O,T,C,A,P,R){var D,L=1&T,_=2&T,I=4&T;if(C&&(D=P?C(O,A,P,R):C(O)),void 0!==D)return D;if(!y(O))return O;var j=g(O);if(j){if(D=d(O),!L)return a(O,D)}else{var B=h(O),F=B==k||"[object GeneratorFunction]"==B;if(v(O))return o(O,L);if(B==M||B==w||F&&!P){if(D=_||F?{}:p(O),!L)return _?l(O,i(D,O)):s(O,r(D,O))}else{if(!S[B])return P?O:{};D=f(O,B,L)}}R||(R=new t);var z=R.get(O);if(z)return z;R.set(O,D),b(O)?O.forEach((function(t){D.add(N(t,T,C,t,O,R))})):m(O)&&O.forEach((function(t,e){D.set(e,N(t,T,C,e,O,R))}));var G=j?void 0:(I?_?c:u:_?E:x)(O);return e(G||O,(function(t,e){G&&(t=O[e=t]),n(D,e,N(t,T,C,e,O,R))})),D},NN}function XA(){if(CN)return TN;CN=1;var t=qA();return TN=function(e){return t(e,4)}}function KA(){if(PN)return AN;return PN=1,AN=function(t){return function(){return t}}}function ZA(){if(_N)return LN;_N=1;var t=(DN||(DN=1,RN=function(t){return function(e,n,r){for(var i=-1,o=Object(e),a=r(e),s=a.length;s--;){var l=a[t?s:++i];if(!1===n(o[l],l,o))break}return e}}),RN),e=t();return LN=e}function QA(){if(jN)return IN;jN=1;var t=ZA(),e=pS();return IN=function(n,r){return n&&t(n,r,e)}}function JA(){if(GN)return zN;GN=1;var t=QA(),e=function(){if(FN)return BN;FN=1;var t=fS();return BN=function(e,n){return function(r,i){if(null==r)return r;if(!t(r))return e(r,i);for(var o=r.length,a=n?o:-1,s=Object(r);(n?a--:++a<o)&&!1!==i(s[a],a,s););return r}},BN}(),n=e(t);return zN=n}function tP(){if(WN)return VN;return WN=1,VN=function(t){return t}}function eP(){if(UN)return HN;UN=1;var t=tP();return HN=function(e){return"function"==typeof e?e:t}}function nP(){if(YN)return $N;YN=1;var t=uM(),e=JA(),n=eP(),r=vM();return $N=function(i,o){return(r(i)?t:e)(i,n(o))}}function rP(){return XN?qN:(XN=1,qN=nP())}function iP(){if(rO)return nO;rO=1;var t=sM(),e=JN?QN:(JN=1,QN=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this}),n=eO?tO:(eO=1,tO=function(t){return this.__data__.has(t)});function r(e){var n=-1,r=null==e?0:e.length;for(this.__data__=new t;++n<r;)this.add(e[n])}return r.prototype.add=r.prototype.push=e,r.prototype.has=n,nO=r}function oP(){if(sO)return aO;return sO=1,aO=function(t,e){return t.has(e)}}function aP(){if(uO)return lO;uO=1;var t=iP(),e=(oO||(oO=1,iO=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}),iO),n=oP();return lO=function(r,i,o,a,s,l){var u=1&o,c=r.length,h=i.length;if(c!=h&&!(u&&h>c))return!1;var d=l.get(r),f=l.get(i);if(d&&f)return d==i&&f==r;var p=-1,g=!0,v=2&o?new t:void 0;for(l.set(r,i),l.set(i,r);++p<c;){var m=r[p],y=i[p];if(a)var b=u?a(y,m,p,i,r,l):a(m,y,p,r,i,l);if(void 0!==b){if(b)continue;g=!1;break}if(v){if(!e(i,(function(t,e){if(!n(v,e)&&(m===t||s(m,t,o,a,l)))return v.push(e)}))){g=!1;break}}else if(m!==y&&!s(m,y,o,a,l)){g=!1;break}}return l.delete(r),l.delete(i),g},lO}function sP(){if(fO)return dO;return fO=1,dO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t})),n},dO}function lP(){if(gO)return pO;gO=1;var t=Kk(),e=zA(),n=Uk(),r=aP(),i=(hO||(hO=1,cO=function(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t]})),n}),cO),o=sP(),a=t?t.prototype:void 0,s=a?a.valueOf:void 0;return pO=function(t,a,l,u,c,h,d){switch(l){case"[object DataView]":if(t.byteLength!=a.byteLength||t.byteOffset!=a.byteOffset)return!1;t=t.buffer,a=a.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=a.byteLength||!h(new e(t),new e(a)));case"[object Boolean]":case"[object Date]":case"[object Number]":return n(+t,+a);case"[object Error]":return t.name==a.name&&t.message==a.message;case"[object RegExp]":case"[object String]":return t==a+"";case"[object Map]":var f=i;case"[object Set]":var p=1&u;if(f||(f=o),t.size!=a.size&&!p)return!1;var g=d.get(t);if(g)return g==a;u|=2,d.set(t,a);var v=r(f(t),f(a),u,c,h,d);return d.delete(t),v;case"[object Symbol]":if(s)return s.call(t)==s.call(a)}return!1}}function uP(){if(bO)return yO;bO=1;var t=lM(),e=aP(),n=lP(),r=function(){if(mO)return vO;mO=1;var t=jA(),e=Object.prototype.hasOwnProperty;return vO=function(n,r,i,o,a,s){var l=1&i,u=t(n),c=u.length;if(c!=t(r).length&&!l)return!1;for(var h=c;h--;){var d=u[h];if(!(l?d in r:e.call(r,d)))return!1}var f=s.get(n),p=s.get(r);if(f&&p)return f==r&&p==n;var g=!0;s.set(n,r),s.set(r,n);for(var v=l;++h<c;){var m=n[d=u[h]],y=r[d];if(o)var b=l?o(y,m,d,r,n,s):o(m,y,d,n,r,s);if(!(void 0===b?m===y||a(m,y,i,o,s):b)){g=!1;break}v||(v="constructor"==d)}if(g&&!v){var x=n.constructor,E=r.constructor;x==E||!("constructor"in n)||!("constructor"in r)||"function"==typeof x&&x instanceof x&&"function"==typeof E&&E instanceof E||(g=!1)}return s.delete(n),s.delete(r),g},vO}(),i=FA(),o=vM(),a=CM(),s=lS(),l="[object Arguments]",u="[object Array]",c="[object Object]",h=Object.prototype.hasOwnProperty;return yO=function(d,f,p,g,v,m){var y=o(d),b=o(f),x=y?u:i(d),E=b?u:i(f),w=(x=x==l?c:x)==c,k=(E=E==l?c:E)==c,M=x==E;if(M&&a(d)){if(!a(f))return!1;y=!0,w=!1}if(M&&!w)return m||(m=new t),y||s(d)?e(d,f,p,g,v,m):n(d,f,x,p,g,v,m);if(!(1&p)){var S=w&&h.call(d,"__wrapped__"),N=k&&h.call(f,"__wrapped__");if(S||N){var O=S?d.value():d,T=N?f.value():f;return m||(m=new t),v(O,T,p,g,m)}}return!!M&&(m||(m=new t),r(d,f,p,g,v,m))}}function cP(){if(EO)return xO;EO=1;var t=uP(),e=pM();return xO=function n(r,i,o,a,s){return r===i||(null==r||null==i||!e(r)&&!e(i)?r!=r&&i!=i:t(r,i,o,a,n,s))},xO}function hP(){if(SO)return MO;SO=1;var t=Qk();return MO=function(e){return e==e&&!t(e)}}function dP(){if(CO)return TO;return CO=1,TO=function(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}}function fP(){if(PO)return AO;PO=1;var t=function(){if(kO)return wO;kO=1;var t=lM(),e=cP();return wO=function(n,r,i,o){var a=i.length,s=a,l=!o;if(null==n)return!s;for(n=Object(n);a--;){var u=i[a];if(l&&u[2]?u[1]!==n[u[0]]:!(u[0]in n))return!1}for(;++a<s;){var c=(u=i[a])[0],h=n[c],d=u[1];if(l&&u[2]){if(void 0===h&&!(c in n))return!1}else{var f=new t;if(o)var p=o(h,d,c,n,r,f);if(!(void 0===p?e(d,h,3,o,f):p))return!1}}return!0},wO}(),e=function(){if(OO)return NO;OO=1;var t=hP(),e=pS();return NO=function(n){for(var r=e(n),i=r.length;i--;){var o=r[i],a=n[o];r[i]=[o,a,t(a)]}return r},NO}(),n=dP();return AO=function(r){var i=e(r);return 1==i.length&&i[0][2]?n(i[0][0],i[0][1]):function(e){return e===r||t(e,r,i)}}}function pP(){if(DO)return RO;DO=1;var t=Zk(),e=pM();return RO=function(n){return"symbol"==typeof n||e(n)&&"[object Symbol]"==t(n)}}function gP(){if(_O)return LO;_O=1;var t=vM(),e=pP(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;return LO=function(i,o){if(t(i))return!1;var a=typeof i;return!("number"!=a&&"symbol"!=a&&"boolean"!=a&&null!=i&&!e(i))||(r.test(i)||!n.test(i)||null!=o&&i in Object(o))}}function vP(){if(FO)return BO;FO=1;var t=function(){if(jO)return IO;jO=1;var t=sM();function e(n,r){if("function"!=typeof n||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var i=function(){var t=arguments,e=r?r.apply(this,t):t[0],o=i.cache;if(o.has(e))return o.get(e);var a=n.apply(this,t);return i.cache=o.set(e,a)||o,a};return i.cache=new(e.Cache||t),i}return e.Cache=t,IO=e}();return BO=function(e){var n=t(e,(function(t){return 500===r.size&&r.clear(),t})),r=n.cache;return n}}function mP(){if(WO)return VO;return WO=1,VO=function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i},VO}function yP(){if(YO)return $O;YO=1;var t=function(){if(UO)return HO;UO=1;var t=Kk(),e=mP(),n=vM(),r=pP(),i=t?t.prototype:void 0,o=i?i.toString:void 0;return HO=function t(i){if("string"==typeof i)return i;if(n(i))return e(i,t)+"";if(r(i))return o?o.call(i):"";var a=i+"";return"0"==a&&1/i==-1/0?"-0":a},HO}();return $O=function(e){return null==e?"":t(e)}}function bP(){if(XO)return qO;XO=1;var t=vM(),e=gP(),n=function(){if(GO)return zO;GO=1;var t=vP(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=t((function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(e,(function(t,e,i,o){r.push(i?o.replace(n,"$1"):e||t)})),r}));return zO=r}(),r=yP();return qO=function(i,o){return t(i)?i:e(i,o)?[i]:n(r(i))}}function xP(){if(ZO)return KO;ZO=1;var t=pP();return KO=function(e){if("string"==typeof e||t(e))return e;var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}}function EP(){if(JO)return QO;JO=1;var t=bP(),e=xP();return QO=function(n,r){for(var i=0,o=(r=t(r,n)).length;null!=n&&i<o;)n=n[e(r[i++])];return i&&i==o?n:void 0},QO}function wP(){if(oT)return iT;oT=1;var t=bP(),e=gM(),n=vM(),r=AM(),i=PM(),o=xP();return iT=function(a,s,l){for(var u=-1,c=(s=t(s,a)).length,h=!1;++u<c;){var d=o(s[u]);if(!(h=null!=a&&l(a,d)))break;a=a[d]}return h||++u!=c?h:!!(c=null==a?0:a.length)&&i(c)&&r(d,c)&&(n(a)||e(a))},iT}function kP(){if(sT)return aT;sT=1;var t=rT?nT:(rT=1,nT=function(t,e){return null!=t&&e in Object(t)}),e=wP();return aT=function(n,r){return null!=n&&e(n,r,t)}}function MP(){if(uT)return lT;uT=1;var t=cP(),e=function(){if(eT)return tT;eT=1;var t=EP();return tT=function(e,n,r){var i=null==e?void 0:t(e,n);return void 0===i?r:i}}(),n=kP(),r=gP(),i=hP(),o=dP(),a=xP();return lT=function(s,l){return r(s)&&i(l)?o(a(s),l):function(r){var i=e(r,s);return void 0===i&&i===l?n(r,s):t(l,i,3)}}}function SP(){if(hT)return cT;return hT=1,cT=function(t){return function(e){return null==e?void 0:e[t]}}}function NP(){if(gT)return pT;gT=1;var t=SP(),e=function(){if(fT)return dT;fT=1;var t=EP();return dT=function(e){return function(n){return t(n,e)}}}(),n=gP(),r=xP();return pT=function(i){return n(i)?t(r(i)):e(i)}}function OP(){if(mT)return vT;mT=1;var t=fP(),e=MP(),n=tP(),r=vM(),i=NP();return vT=function(o){return"function"==typeof o?o:null==o?n:"object"==typeof o?r(o)?e(o[0],o[1]):t(o):i(o)}}function TP(){if(bT)return yT;bT=1;var t=AA(),e=function(){if(ZN)return KN;ZN=1;var t=JA();return KN=function(e,n){var r=[];return t(e,(function(t,e,i){n(t,e,i)&&r.push(t)})),r},KN}(),n=OP(),r=vM();return yT=function(i,o){return(r(i)?t:e)(i,n(o,3))}}function CP(){if(kT)return wT;kT=1;var t=function(){if(ET)return xT;ET=1;var t=Object.prototype.hasOwnProperty;return xT=function(e,n){return null!=e&&t.call(e,n)}}(),e=wP();return wT=function(n,r){return null!=n&&e(n,r,t)}}function AP(){if(ST)return MT;ST=1;var t=dS(),e=FA(),n=gM(),r=vM(),i=fS(),o=CM(),a=cS(),s=lS(),l=Object.prototype.hasOwnProperty;return MT=function(u){if(null==u)return!0;if(i(u)&&(r(u)||"string"==typeof u||"function"==typeof u.splice||o(u)||s(u)||n(u)))return!u.length;var c=e(u);if("[object Map]"==c||"[object Set]"==c)return!u.size;if(a(u))return!t(u).length;for(var h in u)if(l.call(u,h))return!1;return!0}}function PP(){if(OT)return NT;return OT=1,NT=function(t){return void 0===t}}function RP(){if(CT)return TT;CT=1;var t=JA(),e=fS();return TT=function(n,r){var i=-1,o=e(n)?Array(n.length):[];return t(n,(function(t,e,n){o[++i]=r(t,e,n)})),o},TT}function DP(){if(PT)return AT;PT=1;var t=mP(),e=OP(),n=RP(),r=vM();return AT=function(i,o){return(r(i)?t:n)(i,e(o,3))}}function LP(){if(jT)return IT;jT=1;var t=(DT||(DT=1,RT=function(t,e,n,r){var i=-1,o=null==t?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}),RT),e=JA(),n=OP(),r=(_T||(_T=1,LT=function(t,e,n,r,i){return i(t,(function(t,i,o){n=r?(r=!1,t):e(n,t,i,o)})),n}),LT),i=vM();return IT=function(o,a,s){var l=i(o)?t:r,u=arguments.length<3;return l(o,n(a,4),s,u,e)},IT}function _P(){if(YT)return $T;YT=1;var t=function(){if(GT)return zT;GT=1;var t=SP()("length");return zT=t}(),e=function(){if(WT)return VT;WT=1;var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return VT=function(e){return t.test(e)}}(),n=function(){if(UT)return HT;UT=1;var t="\\ud800-\\udfff",e="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",i="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",s="(?:"+n+"|"+r+")?",l="[\\ufe0e\\ufe0f]?",u=l+s+"(?:\\u200d(?:"+[i,o,a].join("|")+")"+l+s+")*",c="(?:"+[i+n+"?",n,o,a,e].join("|")+")",h=RegExp(r+"(?="+r+")|"+c+u,"g");return HT=function(t){for(var e=h.lastIndex=0;h.test(t);)++e;return e}}();return $T=function(r){return e(r)?n(r):t(r)}}function IP(){if(XT)return qT;XT=1;var t=dS(),e=FA(),n=fS(),r=function(){if(FT)return BT;FT=1;var t=Zk(),e=vM(),n=pM();return BT=function(r){return"string"==typeof r||!e(r)&&n(r)&&"[object String]"==t(r)}}(),i=_P();return qT=function(o){if(null==o)return 0;if(n(o))return r(o)?i(o):o.length;var a=e(o);return"[object Map]"==a||"[object Set]"==a?o.size:t(o).length}}function jP(){if(ZT)return KT;ZT=1;var t=uM(),e=HA(),n=QA(),r=OP(),i=LA(),o=vM(),a=CM(),s=Jk(),l=Qk(),u=lS();return KT=function(c,h,d){var f=o(c),p=f||a(c)||u(c);if(h=r(h,4),null==d){var g=c&&c.constructor;d=p?f?new g:[]:l(c)&&s(g)?e(i(c)):{}}return(p?t:n)(c,(function(t,e,n){return h(d,t,e,n)})),d},KT}function BP(){if(eC)return tC;eC=1;var t=DA(),e=function(){if(JT)return QT;JT=1;var t=Kk(),e=gM(),n=vM(),r=t?t.isConcatSpreadable:void 0;return QT=function(t){return n(t)||e(t)||!!(r&&t&&t[r])}}();return tC=function n(r,i,o,a,s){var l=-1,u=r.length;for(o||(o=e),s||(s=[]);++l<u;){var c=r[l];i>0&&o(c)?i>1?n(c,i-1,o,a,s):t(s,c):a||(s[s.length]=c)}return s},tC}function FP(){if(oC)return iC;oC=1;var t=rC?nC:(rC=1,nC=function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}),e=Math.max;return iC=function(n,r,i){return r=e(void 0===r?n.length-1:r,0),function(){for(var o=arguments,a=-1,s=e(o.length-r,0),l=Array(s);++a<s;)l[a]=o[r+a];a=-1;for(var u=Array(r+1);++a<r;)u[a]=o[a];return u[r]=i(l),t(n,this,u)}},iC}function zP(){if(hC)return cC;hC=1;var t=function(){if(sC)return aC;sC=1;var t=KA(),e=cM(),n=tP();return aC=e?function(n,r){return e(n,"toString",{configurable:!0,enumerable:!1,value:t(r),writable:!0})}:n}(),e=function(){if(uC)return lC;uC=1;var t=Date.now;return lC=function(e){var n=0,r=0;return function(){var i=t(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return e.apply(void 0,arguments)}},lC}(),n=e(t);return cC=n}function GP(){if(fC)return dC;fC=1;var t=tP(),e=FP(),n=zP();return dC=function(r,i){return n(e(r,i,t),r+"")}}function VP(){if(gC)return pC;return gC=1,pC=function(t,e,n,r){for(var i=t.length,o=n+(r?1:-1);r?o--:++o<i;)if(e(t[o],o,t))return o;return-1},pC}function WP(){if(EC)return xC;EC=1;var t=VP(),e=mC?vC:(mC=1,vC=function(t){return t!=t}),n=(bC||(bC=1,yC=function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}),yC);return xC=function(r,i,o){return i==i?n(r,i,o):t(r,e,o)}}function HP(){if(CC)return TC;CC=1;var t=BA(),e=OC?NC:(OC=1,NC=function(){}),n=sP(),r=t&&1/n(new t([,-0]))[1]==1/0?function(e){return new t(e)}:e;return TC=r}function UP(){if(PC)return AC;PC=1;var t=iP(),e=function(){if(kC)return wC;kC=1;var t=WP();return wC=function(e,n){return!(null==e||!e.length)&&t(e,n,0)>-1}}(),n=(SC||(SC=1,MC=function(t,e,n){for(var r=-1,i=null==t?0:t.length;++r<i;)if(n(e,t[r]))return!0;return!1}),MC),r=oP(),i=HP(),o=sP();return AC=function(a,s,l){var u=-1,c=e,h=a.length,d=!0,f=[],p=f;if(l)d=!1,c=n;else if(h>=200){var g=s?null:i(a);if(g)return o(g);d=!1,c=r,p=new t}else p=s?[]:f;t:for(;++u<h;){var v=a[u],m=s?s(v):v;if(v=l||0!==v?v:0,d&&m==m){for(var y=p.length;y--;)if(p[y]===m)continue t;s&&p.push(m),f.push(v)}else c(p,m,l)||(p!==f&&p.push(m),f.push(v))}return f},AC}function $P(){if(DC)return RC;DC=1;var t=fS(),e=pM();return RC=function(n){return e(n)&&t(n)}}function YP(){if(_C)return LC;_C=1;var t=BP(),e=GP(),n=UP(),r=$P(),i=e((function(e){return n(t(e,1,r,!0))}));return LC=i}function qP(){if(FC)return BC;FC=1;var t=function(){if(jC)return IC;jC=1;var t=mP();return IC=function(e,n){return t(n,(function(t){return e[t]}))}}(),e=pS();return BC=function(n){return null==n?[]:t(n,e(n))}}function XP(){if(GC)return zC;var t;GC=1;try{t={clone:XA(),constant:KA(),each:rP(),filter:TP(),has:CP(),isArray:vM(),isEmpty:AP(),isFunction:Jk(),isUndefined:PP(),keys:pS(),map:DP(),reduce:LP(),size:IP(),transform:jP(),union:YP(),values:qP()}}catch(t){}return t||(t=window._),zC=t}function KP(){if(WC)return VC;WC=1;var t=XP();VC=n;var e="\0";function n(n){this._isDirected=!t.has(n,"directed")||n.directed,this._isMultigraph=!!t.has(n,"multigraph")&&n.multigraph,this._isCompound=!!t.has(n,"compound")&&n.compound,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[e]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function r(t,e){t[e]?t[e]++:t[e]=1}function i(t,e){--t[e]||delete t[e]}function o(e,n,r,i){var o=""+n,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}return o+""+a+""+(t.isUndefined(i)?"\0":i)}function a(t,e){return o(t,e.v,e.w,e.name)}return n.prototype._nodeCount=0,n.prototype._edgeCount=0,n.prototype.isDirected=function(){return this._isDirected},n.prototype.isMultigraph=function(){return this._isMultigraph},n.prototype.isCompound=function(){return this._isCompound},n.prototype.setGraph=function(t){return this._label=t,this},n.prototype.graph=function(){return this._label},n.prototype.setDefaultNodeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultNodeLabelFn=e,this},n.prototype.nodeCount=function(){return this._nodeCount},n.prototype.nodes=function(){return t.keys(this._nodes)},n.prototype.sources=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._in[n])}))},n.prototype.sinks=function(){var e=this;return t.filter(this.nodes(),(function(n){return t.isEmpty(e._out[n])}))},n.prototype.setNodes=function(e,n){var r=arguments,i=this;return t.each(e,(function(t){r.length>1?i.setNode(t,n):i.setNode(t)})),this},n.prototype.setNode=function(n,r){return t.has(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=r),this):(this._nodes[n]=arguments.length>1?r:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=e,this._children[n]={},this._children[e][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)},n.prototype.node=function(t){return this._nodes[t]},n.prototype.hasNode=function(e){return t.has(this._nodes,e)},n.prototype.removeNode=function(e){var n=this;if(t.has(this._nodes,e)){var r=function(t){n.removeEdge(n._edgeObjs[t])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],t.each(this.children(e),(function(t){n.setParent(t)})),delete this._children[e]),t.each(t.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],t.each(t.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},n.prototype.setParent=function(n,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(r))r=e;else{for(var i=r+="";!t.isUndefined(i);i=this.parent(i))if(i===n)throw new Error("Setting "+r+" as parent of "+n+" would create a cycle");this.setNode(r)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=r,this._children[r][n]=!0,this},n.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},n.prototype.parent=function(t){if(this._isCompound){var n=this._parent[t];if(n!==e)return n}},n.prototype.children=function(n){if(t.isUndefined(n)&&(n=e),this._isCompound){var r=this._children[n];if(r)return t.keys(r)}else{if(n===e)return this.nodes();if(this.hasNode(n))return[]}},n.prototype.predecessors=function(e){var n=this._preds[e];if(n)return t.keys(n)},n.prototype.successors=function(e){var n=this._sucs[e];if(n)return t.keys(n)},n.prototype.neighbors=function(e){var n=this.predecessors(e);if(n)return t.union(n,this.successors(e))},n.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},n.prototype.filterNodes=function(e){var n=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});n.setGraph(this.graph());var r=this;t.each(this._nodes,(function(t,r){e(r)&&n.setNode(r,t)})),t.each(this._edgeObjs,(function(t){n.hasNode(t.v)&&n.hasNode(t.w)&&n.setEdge(t,r.edge(t))}));var i={};function o(t){var e=r.parent(t);return void 0===e||n.hasNode(e)?(i[t]=e,e):e in i?i[e]:o(e)}return this._isCompound&&t.each(n.nodes(),(function(t){n.setParent(t,o(t))})),n},n.prototype.setDefaultEdgeLabel=function(e){return t.isFunction(e)||(e=t.constant(e)),this._defaultEdgeLabelFn=e,this},n.prototype.edgeCount=function(){return this._edgeCount},n.prototype.edges=function(){return t.values(this._edgeObjs)},n.prototype.setPath=function(e,n){var r=this,i=arguments;return t.reduce(e,(function(t,e){return i.length>1?r.setEdge(t,e,n):r.setEdge(t,e),e})),this},n.prototype.setEdge=function(){var e,n,i,a,s=!1,l=arguments[0];"object"==typeof l&&null!==l&&"v"in l?(e=l.v,n=l.w,i=l.name,2===arguments.length&&(a=arguments[1],s=!0)):(e=l,n=arguments[1],i=arguments[3],arguments.length>2&&(a=arguments[2],s=!0)),e=""+e,n=""+n,t.isUndefined(i)||(i=""+i);var u=o(this._isDirected,e,n,i);if(t.has(this._edgeLabels,u))return s&&(this._edgeLabels[u]=a),this;if(!t.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[u]=s?a:this._defaultEdgeLabelFn(e,n,i);var c=function(t,e,n,r){var i=""+e,o=""+n;if(!t&&i>o){var a=i;i=o,o=a}var s={v:i,w:o};r&&(s.name=r);return s}(this._isDirected,e,n,i);return e=c.v,n=c.w,Object.freeze(c),this._edgeObjs[u]=c,r(this._preds[n],e),r(this._sucs[e],n),this._in[n][u]=c,this._out[e][u]=c,this._edgeCount++,this},n.prototype.edge=function(t,e,n){var r=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,t,e,n);return this._edgeLabels[r]},n.prototype.hasEdge=function(e,n,r){var i=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,e,n,r);return t.has(this._edgeLabels,i)},n.prototype.removeEdge=function(t,e,n){var r=1===arguments.length?a(this._isDirected,arguments[0]):o(this._isDirected,t,e,n),s=this._edgeObjs[r];return s&&(t=s.v,e=s.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[e],t),i(this._sucs[t],e),delete this._in[e][r],delete this._out[t][r],this._edgeCount--),this},n.prototype.inEdges=function(e,n){var r=this._in[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.v===n})):i}},n.prototype.outEdges=function(e,n){var r=this._out[e];if(r){var i=t.values(r);return n?t.filter(i,(function(t){return t.w===n})):i}},n.prototype.nodeEdges=function(t,e){var n=this.inEdges(t,e);if(n)return n.concat(this.outEdges(t,e))},VC}function ZP(){return YC?$C:(YC=1,$C={Graph:KP(),version:UC?HC:(UC=1,HC="2.1.8")})}function QP(){if(XC)return qC;XC=1;var t=XP(),e=KP();function n(e){return t.map(e.nodes(),(function(n){var r=e.node(n),i=e.parent(n),o={v:n};return t.isUndefined(r)||(o.value=r),t.isUndefined(i)||(o.parent=i),o}))}function r(e){return t.map(e.edges(),(function(n){var r=e.edge(n),i={v:n.v,w:n.w};return t.isUndefined(n.name)||(i.name=n.name),t.isUndefined(r)||(i.value=r),i}))}return qC={write:function(e){var i={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:n(e),edges:r(e)};t.isUndefined(e.graph())||(i.value=t.clone(e.graph()));return i},read:function(n){var r=new e(n.options).setGraph(n.value);return t.each(n.nodes,(function(t){r.setNode(t.v,t.value),t.parent&&r.setParent(t.v,t.parent)})),t.each(n.edges,(function(t){r.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),r}}}function JP(){if(ZC)return KC;ZC=1;var t=XP();return KC=function(e){var n,r={},i=[];function o(i){t.has(r,i)||(r[i]=!0,n.push(i),t.each(e.successors(i),o),t.each(e.predecessors(i),o))}return t.each(e.nodes(),(function(t){n=[],o(t),n.length&&i.push(n)})),i},KC}function tR(){if(JC)return QC;JC=1;var t=XP();function e(){this._arr=[],this._keyIndices={}}return QC=e,e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},e.prototype.has=function(e){return t.has(this._keyIndices,e)},e.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},e.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(e,n){var r=this._keyIndices;if(e=String(e),!t.has(r,e)){var i=this._arr,o=i.length;return r[e]=o,i.push({key:e,priority:n}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},e.prototype.decrease=function(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)},e.prototype._heapify=function(t){var e=this._arr,n=2*t,r=n+1,i=t;n<e.length&&(i=e[n].priority<e[i].priority?n:i,r<e.length&&(i=e[r].priority<e[i].priority?r:i),i!==t&&(this._swap(t,i),this._heapify(i)))},e.prototype._decrease=function(t){for(var e,n=this._arr,r=n[t].priority;0!==t&&!(n[e=t>>1].priority<r);)this._swap(t,e),t=e},e.prototype._swap=function(t,e){var n=this._arr,r=this._keyIndices,i=n[t],o=n[e];n[t]=o,n[e]=i,r[o.key]=t,r[i.key]=e},QC}function eR(){if(eA)return tA;eA=1;var t=XP(),e=tR();tA=function(t,r,i,o){return function(t,n,r,i){var o,a,s={},l=new e,u=function(t){var e=t.v!==o?t.v:t.w,n=s[e],i=r(t),u=a.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+i);u<n.distance&&(n.distance=u,n.predecessor=o,l.decrease(e,u))};t.nodes().forEach((function(t){var e=t===n?0:Number.POSITIVE_INFINITY;s[t]={distance:e},l.add(t,e)}));for(;l.size()>0&&(o=l.removeMin(),(a=s[o]).distance!==Number.POSITIVE_INFINITY);)i(o).forEach(u);return s}(t,String(r),i||n,o||function(e){return t.outEdges(e)})};var n=t.constant(1);return tA}function nR(){if(rA)return nA;rA=1;var t=eR(),e=XP();return nA=function(n,r,i){return e.transform(n.nodes(),(function(e,o){e[o]=t(n,o,r,i)}),{})}}function rR(){if(oA)return iA;oA=1;var t=XP();return iA=function(e){var n=0,r=[],i={},o=[];function a(s){var l=i[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),e.successors(s).forEach((function(e){t.has(i,e)?i[e].onStack&&(l.lowlink=Math.min(l.lowlink,i[e].index)):(a(e),l.lowlink=Math.min(l.lowlink,i[e].lowlink))})),l.lowlink===l.index){var u,c=[];do{u=r.pop(),i[u].onStack=!1,c.push(u)}while(s!==u);o.push(c)}}return e.nodes().forEach((function(e){t.has(i,e)||a(e)})),o},iA}function iR(){if(sA)return aA;sA=1;var t=XP(),e=rR();return aA=function(n){return t.filter(e(n),(function(t){return t.length>1||1===t.length&&n.hasEdge(t[0],t[0])}))}}function oR(){if(uA)return lA;uA=1;var t=XP();lA=function(t,n,r){return function(t,e,n){var r={},i=t.nodes();return i.forEach((function(t){r[t]={},r[t][t]={distance:0},i.forEach((function(e){t!==e&&(r[t][e]={distance:Number.POSITIVE_INFINITY})})),n(t).forEach((function(n){var i=n.v===t?n.w:n.v,o=e(n);r[t][i]={distance:o,predecessor:t}}))})),i.forEach((function(t){var e=r[t];i.forEach((function(n){var o=r[n];i.forEach((function(n){var r=o[t],i=e[n],a=o[n],s=r.distance+i.distance;s<a.distance&&(a.distance=s,a.predecessor=i.predecessor)}))}))})),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=t.constant(1);return lA}function aR(){if(hA)return cA;hA=1;var t=XP();function e(e){var r={},i={},o=[];if(t.each(e.sinks(),(function a(s){if(t.has(i,s))throw new n;t.has(r,s)||(i[s]=!0,r[s]=!0,t.each(e.predecessors(s),a),delete i[s],o.push(s))})),t.size(r)!==e.nodeCount())throw new n;return o}function n(){}return cA=e,e.CycleException=n,n.prototype=new Error,cA}function sR(){if(fA)return dA;fA=1;var t=aR();return dA=function(e){try{t(e)}catch(e){if(e instanceof t.CycleException)return!1;throw e}return!0}}function lR(){if(gA)return pA;gA=1;var t=XP();function e(n,r,i,o,a,s){t.has(o,r)||(o[r]=!0,i||s.push(r),t.each(a(r),(function(t){e(n,t,i,o,a,s)})),i&&s.push(r))}return pA=function(n,r,i){t.isArray(r)||(r=[r]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),a=[],s={};return t.each(r,(function(t){if(!n.hasNode(t))throw new Error("Graph does not have node: "+t);e(n,t,"post"===i,s,o,a)})),a},pA}function uR(){if(mA)return vA;mA=1;var t=lR();return vA=function(e,n){return t(e,n,"post")}}function cR(){if(bA)return yA;bA=1;var t=lR();return yA=function(e,n){return t(e,n,"pre")}}function hR(){if(EA)return xA;EA=1;var t=XP(),e=KP(),n=tR();return xA=function(r,i){var o,a=new e,s={},l=new n;function u(t){var e=t.v===o?t.w:t.v,n=l.priority(e);if(void 0!==n){var r=i(t);r<n&&(s[e]=o,l.decrease(e,r))}}if(0===r.nodeCount())return a;t.each(r.nodes(),(function(t){l.add(t,Number.POSITIVE_INFINITY),a.setNode(t)})),l.decrease(r.nodes()[0],0);var c=!1;for(;l.size()>0;){if(o=l.removeMin(),t.has(s,o))a.setEdge(o,s[o]);else{if(c)throw new Error("Input graph is not connected: "+r);c=!0}r.nodeEdges(o).forEach(u)}return a}}try{NA=function(){if(SA)return MA;SA=1;var t=ZP();return MA={Graph:t.Graph,json:QP(),alg:kA?wA:(kA=1,wA={components:JP(),dijkstra:eR(),dijkstraAll:nR(),findCycles:iR(),floydWarshall:oR(),isAcyclic:sR(),postorder:uR(),preorder:cR(),prim:hR(),tarjan:rR(),topsort:aR()}),version:t.version}}()}catch(t){}NA||(NA=window.graphlib);var dR,fR,pR,gR,vR,mR,yR,bR,xR,ER,wR,kR,MR,SR,NR,OR,TR,CR,AR,PR,RR,DR,LR,_R,IR,jR,BR,FR,zR,GR,VR,WR,HR,UR,$R,YR,qR,XR,KR,ZR,QR,JR,tD,eD,nD,rD,iD,oD,aD,sD,lD,uD,cD,hD,dD,fD,pD,gD,vD,mD,yD,bD,xD,ED,wD,kD,MD,SD,ND,OD,TD,CD,AD,PD,RD,DD,LD,_D,ID,jD,BD,FD,zD,GD,VD,WD,HD,UD,$D,YD,qD,XD,KD,ZD=NA;function QD(){if(gR)return pR;gR=1;var t=Uk(),e=fS(),n=AM(),r=Qk();return pR=function(i,o,a){if(!r(a))return!1;var s=typeof o;return!!("number"==s?e(a)&&n(o,a.length):"string"==s&&o in a)&&t(a[o],i)},pR}function JD(){if(kR)return wR;kR=1;var t=function(){if(ER)return xR;ER=1;var t=/\s/;return xR=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n},xR}(),e=/^\s+/;return wR=function(n){return n?n.slice(0,t(n)+1).replace(e,""):n}}function tL(){if(OR)return NR;OR=1;var t=function(){if(SR)return MR;SR=1;var t=JD(),e=Qk(),n=pP(),r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;return MR=function(s){if("number"==typeof s)return s;if(n(s))return NaN;if(e(s)){var l="function"==typeof s.valueOf?s.valueOf():s;s=e(l)?l+"":l}if("string"!=typeof s)return 0===s?s:+s;s=t(s);var u=i.test(s);return u||o.test(s)?a(s.slice(2),u?2:8):r.test(s)?NaN:+s}}(),e=1/0;return NR=function(n){return n?(n=t(n))===e||n===-1/0?17976931348623157e292*(n<0?-1:1):n==n?n:0:0===n?n:0}}function eL(){if(PR)return AR;PR=1;var t=VP(),e=OP(),n=function(){if(CR)return TR;CR=1;var t=tL();return TR=function(e){var n=t(e),r=n%1;return n==n?r?n-r:n:0}}(),r=Math.max;return AR=function(i,o,a){var s=null==i?0:i.length;if(!s)return-1;var l=null==a?0:n(a);return l<0&&(l=r(s+l,0)),t(i,e(o,3),l)},AR}function nL(){if(_R)return LR;_R=1;var t=BP();return LR=function(e){return(null==e?0:e.length)?t(e,1):[]}}function rL(){if(WR)return VR;WR=1;var t=pP();return VR=function(e,n,r){for(var i=-1,o=e.length;++i<o;){var a=e[i],s=n(a);if(null!=s&&(void 0===l?s==s&&!t(s):r(s,l)))var l=s,u=a}return u},VR}function iL(){if(XR)return qR;XR=1;var t=hM(),e=Uk();return qR=function(n,r,i){(void 0!==i&&!e(n[r],i)||void 0===i&&!(r in n))&&t(n,r,i)}}function oL(){if(JR)return QR;return JR=1,QR=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function aL(){if(rD)return nD;rD=1;var t=iL(),e=TA(),n=VA(),r=CA(),i=UA(),o=gM(),a=vM(),s=$P(),l=CM(),u=Jk(),c=Qk(),h=function(){if(ZR)return KR;ZR=1;var t=Zk(),e=LA(),n=pM(),r=Function.prototype,i=Object.prototype,o=r.toString,a=i.hasOwnProperty,s=o.call(Object);return KR=function(r){if(!n(r)||"[object Object]"!=t(r))return!1;var i=e(r);if(null===i)return!0;var l=a.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==s}}(),d=lS(),f=oL(),p=function(){if(eD)return tD;eD=1;var t=fM(),e=vS();return tD=function(n){return t(n,e(n))}}();return nD=function(g,v,m,y,b,x,E){var w=f(g,m),k=f(v,m),M=E.get(k);if(M)t(g,m,M);else{var S=x?x(w,k,m+"",g,v,E):void 0,N=void 0===S;if(N){var O=a(k),T=!O&&l(k),C=!O&&!T&&d(k);S=k,O||T||C?a(w)?S=w:s(w)?S=r(w):T?(N=!1,S=e(k,!0)):C?(N=!1,S=n(k,!0)):S=[]:h(k)||o(k)?(S=w,o(w)?S=p(w):c(w)&&!u(w)||(S=i(k))):N=!1}N&&(E.set(k,S),b(S,k,y,x,E),E.delete(k)),t(g,m,S)}}}function sL(){if(hD)return cD;return hD=1,cD=function(t,e){return t<e}}function lL(){if(ED)return xD;ED=1;var t=EP(),e=function(){if(bD)return yD;bD=1;var t=dM(),e=bP(),n=AM(),r=Qk(),i=xP();return yD=function(o,a,s,l){if(!r(o))return o;for(var u=-1,c=(a=e(a,o)).length,h=c-1,d=o;null!=d&&++u<c;){var f=i(a[u]),p=s;if("__proto__"===f||"constructor"===f||"prototype"===f)return o;if(u!=h){var g=d[f];void 0===(p=l?l(g,f,d):void 0)&&(p=r(g)?g:n(a[u+1])?[]:{})}t(d,f,p),d=d[f]}return o},yD}(),n=bP();return xD=function(r,i,o){for(var a=-1,s=i.length,l={};++a<s;){var u=i[a],c=t(r,u);o(c,u)&&e(l,n(u,r),c)}return l},xD}function uL(){if(PD)return AD;PD=1;var t=function(){if(CD)return TD;CD=1;var t=Math.ceil,e=Math.max;return TD=function(n,r,i,o){for(var a=-1,s=e(t((r-n)/(i||1)),0),l=Array(s);s--;)l[o?s:++a]=n,n+=i;return l},TD}(),e=QD(),n=tL();return AD=function(r){return function(i,o,a){return a&&"number"!=typeof a&&e(i,o,a)&&(o=a=void 0),i=n(i),void 0===o?(o=i,i=0):o=n(o),a=void 0===a?i<o?1:-1:n(a),t(i,o,a,r)}},AD}function cL(){if(FD)return BD;FD=1;var t=function(){if(jD)return ID;jD=1;var t=pP();return ID=function(e,n){if(e!==n){var r=void 0!==e,i=null===e,o=e==e,a=t(e),s=void 0!==n,l=null===n,u=n==n,c=t(n);if(!l&&!c&&!a&&e>n||a&&s&&u&&!l&&!c||i&&s&&u||!r&&u||!o)return 1;if(!i&&!a&&!c&&e<n||c&&r&&o&&!i&&!a||l&&r&&o||!s&&o||!u)return-1}return 0}}();return BD=function(e,n,r){for(var i=-1,o=e.criteria,a=n.criteria,s=o.length,l=r.length;++i<s;){var u=t(o[i],a[i]);if(u)return i>=l?u:u*("desc"==r[i]?-1:1)}return e.index-n.index},BD}function hL(){if(GD)return zD;GD=1;var t=mP(),e=EP(),n=OP(),r=RP(),i=(_D||(_D=1,LD=function(t,e){var n=t.length;for(t.sort(e);n--;)t[n]=t[n].value;return t}),LD),o=RM(),a=cL(),s=tP(),l=vM();return zD=function(u,c,h){c=c.length?t(c,(function(t){return l(t)?function(n){return e(n,1===t.length?t[0]:t)}:t})):[s];var d=-1;c=t(c,o(n));var f=r(u,(function(e,n,r){return{criteria:t(c,(function(t){return t(e)})),index:++d,value:e}}));return i(f,(function(t,e){return a(t,e,h)}))},zD}try{KD={cloneDeep:function(){if(fR)return dR;fR=1;var t=qA();return dR=function(e){return t(e,5)}}(),constant:KA(),defaults:function(){if(mR)return vR;mR=1;var t=GP(),e=Uk(),n=QD(),r=vS(),i=Object.prototype,o=i.hasOwnProperty,a=t((function(t,a){t=Object(t);var s=-1,l=a.length,u=l>2?a[2]:void 0;for(u&&n(a[0],a[1],u)&&(l=1);++s<l;)for(var c=a[s],h=r(c),d=-1,f=h.length;++d<f;){var p=h[d],g=t[p];(void 0===g||e(g,i[p])&&!o.call(t,p))&&(t[p]=c[p])}return t}));return vR=a}(),each:rP(),filter:TP(),find:function(){if(DR)return RR;DR=1;var t=function(){if(bR)return yR;bR=1;var t=OP(),e=fS(),n=pS();return yR=function(r){return function(i,o,a){var s=Object(i);if(!e(i)){var l=t(o,3);i=n(i),o=function(t){return l(s[t],t,s)}}var u=r(i,o,a);return u>-1?s[l?i[u]:u]:void 0}},yR}(),e=t(eL());return RR=e}(),flatten:nL(),forEach:nP(),forIn:function(){if(jR)return IR;jR=1;var t=ZA(),e=eP(),n=vS();return IR=function(r,i){return null==r?r:t(r,e(i),n)}}(),has:CP(),isUndefined:PP(),last:(FR||(FR=1,BR=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}),BR),map:DP(),mapValues:function(){if(GR)return zR;GR=1;var t=hM(),e=QA(),n=OP();return zR=function(r,i){var o={};return i=n(i,3),e(r,(function(e,n,r){t(o,n,i(e,n,r))})),o}}(),max:function(){if(YR)return $R;YR=1;var t=rL(),e=UR?HR:(UR=1,HR=function(t,e){return t>e}),n=tP();return $R=function(r){return r&&r.length?t(r,n,e):void 0}}(),merge:function(){if(uD)return lD;uD=1;var t=function(){if(oD)return iD;oD=1;var t=lM(),e=iL(),n=ZA(),r=aL(),i=Qk(),o=vS(),a=oL();return iD=function s(l,u,c,h,d){l!==u&&n(u,(function(n,o){if(d||(d=new t),i(n))r(l,u,o,c,s,h,d);else{var f=h?h(a(l,o),n,o+"",l,u,d):void 0;void 0===f&&(f=n),e(l,o,f)}}),o)},iD}(),e=function(){if(sD)return aD;sD=1;var t=GP(),e=QD();return aD=function(n){return t((function(t,r){var i=-1,o=r.length,a=o>1?r[o-1]:void 0,s=o>2?r[2]:void 0;for(a=n.length>3&&"function"==typeof a?(o--,a):void 0,s&&e(r[0],r[1],s)&&(a=o<3?void 0:a,o=1),t=Object(t);++i<o;){var l=r[i];l&&n(t,l,i,a)}return t}))},aD}(),n=e((function(e,n,r){t(e,n,r)}));return lD=n}(),min:function(){if(fD)return dD;fD=1;var t=rL(),e=sL(),n=tP();return dD=function(r){return r&&r.length?t(r,n,e):void 0}}(),minBy:function(){if(gD)return pD;gD=1;var t=rL(),e=OP(),n=sL();return pD=function(r,i){return r&&r.length?t(r,e(i,2),n):void 0}}(),now:function(){if(mD)return vD;mD=1;var t=Xk();return vD=function(){return t.Date.now()}}(),pick:function(){if(OD)return ND;OD=1;var t=function(){if(kD)return wD;kD=1;var t=lL(),e=kP();return wD=function(n,r){return t(n,r,(function(t,r){return e(n,r)}))}}(),e=function(){if(SD)return MD;SD=1;var t=nL(),e=FP(),n=zP();return MD=function(r){return n(e(r,void 0,t),r+"")}}(),n=e((function(e,n){return null==e?{}:t(e,n)}));return ND=n}(),range:function(){if(DD)return RD;DD=1;var t=uL()();return RD=t}(),reduce:LP(),sortBy:function(){if(WD)return VD;WD=1;var t=BP(),e=hL(),n=GP(),r=QD(),i=n((function(n,i){if(null==n)return[];var o=i.length;return o>1&&r(n,i[0],i[1])?i=[]:o>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),e(n,t(i,1),[])}));return VD=i}(),uniqueId:function(){if(UD)return HD;UD=1;var t=yP(),e=0;return HD=function(n){var r=++e;return t(n)+r},HD}(),values:qP(),zipObject:function(){if(XD)return qD;XD=1;var t=dM(),e=(YD||(YD=1,$D=function(t,e,n){for(var r=-1,i=t.length,o=e.length,a={};++r<i;){var s=r<o?e[r]:void 0;n(a,t[r],s)}return a}),$D);return qD=function(n,r){return e(n||[],r||[],t)},qD}()}}catch(t){}KD||(KD=window._);var dL=KD,fL=pL;function pL(){var t={};t._next=t._prev=t,this._sentinel=t}function gL(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function vL(t,e){if("_next"!==t&&"_prev"!==t)return e}pL.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return gL(e),e},pL.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&gL(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},pL.prototype.toString=function(){for(var t=[],e=this._sentinel,n=e._prev;n!==e;)t.push(JSON.stringify(n,vL)),n=n._prev;return"["+t.join(", ")+"]"};var mL=dL,yL=ZD.Graph,bL=fL,xL=function(t,e){if(t.nodeCount()<=1)return[];var n=function(t,e){var n=new yL,r=0,i=0;mL.forEach(t.nodes(),(function(t){n.setNode(t,{v:t,in:0,out:0})})),mL.forEach(t.edges(),(function(t){var o=n.edge(t.v,t.w)||0,a=e(t),s=o+a;n.setEdge(t.v,t.w,s),i=Math.max(i,n.node(t.v).out+=a),r=Math.max(r,n.node(t.w).in+=a)}));var o=mL.range(i+r+3).map((function(){return new bL})),a=r+1;return mL.forEach(n.nodes(),(function(t){kL(o,a,n.node(t))})),{graph:n,buckets:o,zeroIdx:a}}(t,e||EL),r=function(t,e,n){var r,i=[],o=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;r=a.dequeue();)wL(t,e,n,r);for(;r=o.dequeue();)wL(t,e,n,r);if(t.nodeCount())for(var s=e.length-2;s>0;--s)if(r=e[s].dequeue()){i=i.concat(wL(t,e,n,r,!0));break}}return i}(n.graph,n.buckets,n.zeroIdx);return mL.flatten(mL.map(r,(function(e){return t.outEdges(e.v,e.w)})),!0)},EL=mL.constant(1);function wL(t,e,n,r,i){var o=i?[]:void 0;return mL.forEach(t.inEdges(r.v),(function(r){var a=t.edge(r),s=t.node(r.v);i&&o.push({v:r.v,w:r.w}),s.out-=a,kL(e,n,s)})),mL.forEach(t.outEdges(r.v),(function(r){var i=t.edge(r),o=r.w,a=t.node(o);a.in-=i,kL(e,n,a)})),t.removeNode(r.v),o}function kL(t,e,n){n.out?n.in?t[n.out-n.in+e].enqueue(n):t[t.length-1].enqueue(n):t[0].enqueue(n)}var ML=dL,SL=xL,NL={run:function(t){var e="greedy"===t.graph().acyclicer?SL(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],n={},r={};function i(o){ML.has(r,o)||(r[o]=!0,n[o]=!0,ML.forEach(t.outEdges(o),(function(t){ML.has(n,t.w)?e.push(t):i(t.w)})),delete n[o])}return ML.forEach(t.nodes(),i),e}(t);ML.forEach(e,(function(e){var n=t.edge(e);t.removeEdge(e),n.forwardName=e.name,n.reversed=!0,t.setEdge(e.w,e.v,n,ML.uniqueId("rev"))}))},undo:function(t){ML.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.reversed){t.removeEdge(e);var r=n.forwardName;delete n.reversed,delete n.forwardName,t.setEdge(e.w,e.v,n,r)}}))}};var OL=dL,TL=ZD.Graph,CL={addDummyNode:AL,simplify:function(t){var e=(new TL).setGraph(t.graph());return OL.forEach(t.nodes(),(function(n){e.setNode(n,t.node(n))})),OL.forEach(t.edges(),(function(n){var r=e.edge(n.v,n.w)||{weight:0,minlen:1},i=t.edge(n);e.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})})),e},asNonCompoundGraph:function(t){var e=new TL({multigraph:t.isMultigraph()}).setGraph(t.graph());return OL.forEach(t.nodes(),(function(n){t.children(n).length||e.setNode(n,t.node(n))})),OL.forEach(t.edges(),(function(n){e.setEdge(n,t.edge(n))})),e},successorWeights:function(t){var e=OL.map(t.nodes(),(function(e){var n={};return OL.forEach(t.outEdges(e),(function(e){n[e.w]=(n[e.w]||0)+t.edge(e).weight})),n}));return OL.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=OL.map(t.nodes(),(function(e){var n={};return OL.forEach(t.inEdges(e),(function(e){n[e.v]=(n[e.v]||0)+t.edge(e).weight})),n}));return OL.zipObject(t.nodes(),e)},intersectRect:function(t,e){var n,r,i=t.x,o=t.y,a=e.x-i,s=e.y-o,l=t.width/2,u=t.height/2;if(!a&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*l>Math.abs(a)*u?(s<0&&(u=-u),n=u*a/s,r=u):(a<0&&(l=-l),n=l,r=l*s/a);return{x:i+n,y:o+r}},buildLayerMatrix:function(t){var e=OL.map(OL.range(PL(t)+1),(function(){return[]}));return OL.forEach(t.nodes(),(function(n){var r=t.node(n),i=r.rank;OL.isUndefined(i)||(e[i][r.order]=n)})),e},normalizeRanks:function(t){var e=OL.min(OL.map(t.nodes(),(function(e){return t.node(e).rank})));OL.forEach(t.nodes(),(function(n){var r=t.node(n);OL.has(r,"rank")&&(r.rank-=e)}))},removeEmptyRanks:function(t){var e=OL.min(OL.map(t.nodes(),(function(e){return t.node(e).rank}))),n=[];OL.forEach(t.nodes(),(function(r){var i=t.node(r).rank-e;n[i]||(n[i]=[]),n[i].push(r)}));var r=0,i=t.graph().nodeRankFactor;OL.forEach(n,(function(e,n){OL.isUndefined(e)&&n%i!==0?--r:r&&OL.forEach(e,(function(e){t.node(e).rank+=r}))}))},addBorderNode:function(t,e,n,r){var i={width:0,height:0};arguments.length>=4&&(i.rank=n,i.order=r);return AL(t,"border",i,e)},maxRank:PL,partition:function(t,e){var n={lhs:[],rhs:[]};return OL.forEach(t,(function(t){e(t)?n.lhs.push(t):n.rhs.push(t)})),n},time:function(t,e){var n=OL.now();try{return e()}finally{console.log(t+" time: "+(OL.now()-n)+"ms")}},notime:function(t,e){return e()}};function AL(t,e,n,r){var i;do{i=OL.uniqueId(r)}while(t.hasNode(i));return n.dummy=e,t.setNode(i,n),i}function PL(t){return OL.max(OL.map(t.nodes(),(function(e){var n=t.node(e).rank;if(!OL.isUndefined(n))return n})))}var RL=dL,DL=CL,LL={run:function(t){t.graph().dummyChains=[],RL.forEach(t.edges(),(function(e){!function(t,e){var n,r,i,o=e.v,a=t.node(o).rank,s=e.w,l=t.node(s).rank,u=e.name,c=t.edge(e),h=c.labelRank;if(l===a+1)return;for(t.removeEdge(e),i=0,++a;a<l;++i,++a)c.points=[],r={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},n=DL.addDummyNode(t,"edge",r,"_d"),a===h&&(r.width=c.width,r.height=c.height,r.dummy="edge-label",r.labelpos=c.labelpos),t.setEdge(o,n,{weight:c.weight},u),0===i&&t.graph().dummyChains.push(n),o=n;t.setEdge(o,s,{weight:c.weight},u)}(t,e)}))},undo:function(t){RL.forEach(t.graph().dummyChains,(function(e){var n,r=t.node(e),i=r.edgeLabel;for(t.setEdge(r.edgeObj,i);r.dummy;)n=t.successors(e)[0],t.removeNode(e),i.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(i.x=r.x,i.y=r.y,i.width=r.width,i.height=r.height),e=n,r=t.node(e)}))}};var _L=dL,IL={longestPath:function(t){var e={};_L.forEach(t.sources(),(function n(r){var i=t.node(r);if(_L.has(e,r))return i.rank;e[r]=!0;var o=_L.min(_L.map(t.outEdges(r),(function(e){return n(e.w)-t.edge(e).minlen})));return o!==Number.POSITIVE_INFINITY&&null!=o||(o=0),i.rank=o}))},slack:function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen}};var jL=dL,BL=ZD.Graph,FL=IL.slack,zL=function(t){var e,n,r=new BL({directed:!1}),i=t.nodes()[0],o=t.nodeCount();r.setNode(i,{});for(;GL(r,t)<o;)e=VL(r,t),n=r.hasNode(e.v)?FL(t,e):-FL(t,e),WL(r,t,n);return r};function GL(t,e){return jL.forEach(t.nodes(),(function n(r){jL.forEach(e.nodeEdges(r),(function(i){var o=i.v,a=r===o?i.w:o;t.hasNode(a)||FL(e,i)||(t.setNode(a,{}),t.setEdge(r,a,{}),n(a))}))})),t.nodeCount()}function VL(t,e){return jL.minBy(e.edges(),(function(n){if(t.hasNode(n.v)!==t.hasNode(n.w))return FL(e,n)}))}function WL(t,e,n){jL.forEach(t.nodes(),(function(t){e.node(t).rank+=n}))}var HL=dL,UL=zL,$L=IL.slack,YL=IL.longestPath,qL=ZD.alg.preorder,XL=ZD.alg.postorder,KL=CL.simplify,ZL=QL;function QL(t){t=KL(t),YL(t);var e,n=UL(t);for(e_(n),JL(n,t);e=r_(n);)o_(n,t,e,i_(n,t,e))}function JL(t,e){var n=XL(t,t.nodes());n=n.slice(0,n.length-1),HL.forEach(n,(function(n){!function(t,e,n){var r=t.node(n),i=r.parent;t.edge(n,i).cutvalue=t_(t,e,n)}(t,e,n)}))}function t_(t,e,n){var r=t.node(n).parent,i=!0,o=e.edge(n,r),a=0;return o||(i=!1,o=e.edge(r,n)),a=o.weight,HL.forEach(e.nodeEdges(n),(function(o){var s,l,u=o.v===n,c=u?o.w:o.v;if(c!==r){var h=u===i,d=e.edge(o).weight;if(a+=h?d:-d,s=n,l=c,t.hasEdge(s,l)){var f=t.edge(n,c).cutvalue;a+=h?-f:f}}})),a}function e_(t,e){arguments.length<2&&(e=t.nodes()[0]),n_(t,{},1,e)}function n_(t,e,n,r,i){var o=n,a=t.node(r);return e[r]=!0,HL.forEach(t.neighbors(r),(function(i){HL.has(e,i)||(n=n_(t,e,n,i,r))})),a.low=o,a.lim=n++,i?a.parent=i:delete a.parent,n}function r_(t){return HL.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function i_(t,e,n){var r=n.v,i=n.w;e.hasEdge(r,i)||(r=n.w,i=n.v);var o=t.node(r),a=t.node(i),s=o,l=!1;o.lim>a.lim&&(s=a,l=!0);var u=HL.filter(e.edges(),(function(e){return l===a_(t,t.node(e.v),s)&&l!==a_(t,t.node(e.w),s)}));return HL.minBy(u,(function(t){return $L(e,t)}))}function o_(t,e,n,r){var i=n.v,o=n.w;t.removeEdge(i,o),t.setEdge(r.v,r.w,{}),e_(t),JL(t,e),function(t,e){var n=HL.find(t.nodes(),(function(t){return!e.node(t).parent})),r=qL(t,n);r=r.slice(1),HL.forEach(r,(function(n){var r=t.node(n).parent,i=e.edge(n,r),o=!1;i||(i=e.edge(r,n),o=!0),e.node(n).rank=e.node(r).rank+(o?i.minlen:-i.minlen)}))}(t,e)}function a_(t,e,n){return n.low<=e.lim&&e.lim<=n.lim}QL.initLowLimValues=e_,QL.initCutValues=JL,QL.calcCutValue=t_,QL.leaveEdge=r_,QL.enterEdge=i_,QL.exchangeEdges=o_;var s_=IL.longestPath,l_=zL,u_=ZL,c_=function(t){switch(t.graph().ranker){case"network-simplex":default:d_(t);break;case"tight-tree":!function(t){s_(t),l_(t)}(t);break;case"longest-path":h_(t)}};var h_=s_;function d_(t){u_(t)}var f_=dL,p_=function(t){var e=function(t){var e={},n=0;function r(i){var o=n;f_.forEach(t.children(i),r),e[i]={low:o,lim:n++}}return f_.forEach(t.children(),r),e}(t);f_.forEach(t.graph().dummyChains,(function(n){for(var r=t.node(n),i=r.edgeObj,o=function(t,e,n,r){var i,o,a=[],s=[],l=Math.min(e[n].low,e[r].low),u=Math.max(e[n].lim,e[r].lim);i=n;do{i=t.parent(i),a.push(i)}while(i&&(e[i].low>l||u>e[i].lim));o=i,i=r;for(;(i=t.parent(i))!==o;)s.push(i);return{path:a.concat(s.reverse()),lca:o}}(t,e,i.v,i.w),a=o.path,s=o.lca,l=0,u=a[l],c=!0;n!==i.w;){if(r=t.node(n),c){for(;(u=a[l])!==s&&t.node(u).maxRank<r.rank;)l++;u===s&&(c=!1)}if(!c){for(;l<a.length-1&&t.node(u=a[l+1]).minRank<=r.rank;)l++;u=a[l]}t.setParent(n,u),n=t.successors(n)[0]}}))};var g_=dL,v_=CL,m_={run:function(t){var e=v_.addDummyNode(t,"root",{},"_root"),n=function(t){var e={};function n(r,i){var o=t.children(r);o&&o.length&&g_.forEach(o,(function(t){n(t,i+1)})),e[r]=i}return g_.forEach(t.children(),(function(t){n(t,1)})),e}(t),r=g_.max(g_.values(n))-1,i=2*r+1;t.graph().nestingRoot=e,g_.forEach(t.edges(),(function(e){t.edge(e).minlen*=i}));var o=function(t){return g_.reduce(t.edges(),(function(e,n){return e+t.edge(n).weight}),0)}(t)+1;g_.forEach(t.children(),(function(a){y_(t,e,i,o,r,n,a)})),t.graph().nodeRankFactor=i},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,g_.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function y_(t,e,n,r,i,o,a){var s=t.children(a);if(s.length){var l=v_.addBorderNode(t,"_bt"),u=v_.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(l,a),c.borderTop=l,t.setParent(u,a),c.borderBottom=u,g_.forEach(s,(function(s){y_(t,e,n,r,i,o,s);var c=t.node(s),h=c.borderTop?c.borderTop:s,d=c.borderBottom?c.borderBottom:s,f=c.borderTop?r:2*r,p=h!==d?1:i-o[a]+1;t.setEdge(l,h,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,l,{weight:0,minlen:i+o[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:n})}var b_=dL,x_=CL,E_=function(t){b_.forEach(t.children(),(function e(n){var r=t.children(n),i=t.node(n);if(r.length&&b_.forEach(r,e),b_.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o<a;++o)w_(t,"borderLeft","_bl",n,i,o),w_(t,"borderRight","_br",n,i,o)}}))};function w_(t,e,n,r,i,o){var a={width:0,height:0,rank:o,borderType:e},s=i[e][o-1],l=x_.addDummyNode(t,"border",a,n);i[e][o]=l,t.setParent(l,r),s&&t.setEdge(s,l,{weight:1})}var k_=dL,M_={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||S_(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){k_.forEach(t.nodes(),(function(e){O_(t.node(e))})),k_.forEach(t.edges(),(function(e){var n=t.edge(e);k_.forEach(n.points,O_),k_.has(n,"y")&&O_(n)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){k_.forEach(t.nodes(),(function(e){T_(t.node(e))})),k_.forEach(t.edges(),(function(e){var n=t.edge(e);k_.forEach(n.points,T_),k_.has(n,"x")&&T_(n)}))}(t),S_(t))}};function S_(t){k_.forEach(t.nodes(),(function(e){N_(t.node(e))})),k_.forEach(t.edges(),(function(e){N_(t.edge(e))}))}function N_(t){var e=t.width;t.width=t.height,t.height=e}function O_(t){t.y=-t.y}function T_(t){var e=t.x;t.x=t.y,t.y=e}var C_=dL,A_=function(t){var e={},n=C_.filter(t.nodes(),(function(e){return!t.children(e).length})),r=C_.max(C_.map(n,(function(e){return t.node(e).rank}))),i=C_.map(C_.range(r+1),(function(){return[]}));function o(n){if(!C_.has(e,n)){e[n]=!0;var r=t.node(n);i[r.rank].push(n),C_.forEach(t.successors(n),o)}}var a=C_.sortBy(n,(function(e){return t.node(e).rank}));return C_.forEach(a,o),i};var P_=dL,R_=function(t,e){for(var n=0,r=1;r<e.length;++r)n+=D_(t,e[r-1],e[r]);return n};function D_(t,e,n){for(var r=P_.zipObject(n,P_.map(n,(function(t,e){return e}))),i=P_.flatten(P_.map(e,(function(e){return P_.sortBy(P_.map(t.outEdges(e),(function(e){return{pos:r[e.w],weight:t.edge(e).weight}})),"pos")})),!0),o=1;o<n.length;)o<<=1;var a=2*o-1;o-=1;var s=P_.map(new Array(a),(function(){return 0})),l=0;return P_.forEach(i.forEach((function(t){var e=t.pos+o;s[e]+=t.weight;for(var n=0;e>0;)e%2&&(n+=s[e+1]),s[e=e-1>>1]+=t.weight;l+=t.weight*n}))),l}var L_=dL;var __=dL,I_=function(t,e){var n={};return __.forEach(t,(function(t,e){var r=n[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};__.isUndefined(t.barycenter)||(r.barycenter=t.barycenter,r.weight=t.weight)})),__.forEach(e.edges(),(function(t){var e=n[t.v],r=n[t.w];__.isUndefined(e)||__.isUndefined(r)||(r.indegree++,e.out.push(n[t.w]))})),function(t){var e=[];function n(t){return function(e){e.merged||(__.isUndefined(e.barycenter)||__.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var n=0,r=0;t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=n/r,t.weight=r,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function r(e){return function(n){n.in.push(e),0===--n.indegree&&t.push(n)}}for(;t.length;){var i=t.pop();e.push(i),__.forEach(i.in.reverse(),n(i)),__.forEach(i.out,r(i))}return __.map(__.filter(e,(function(t){return!t.merged})),(function(t){return __.pick(t,["vs","i","barycenter","weight"])}))}(__.filter(n,(function(t){return!t.indegree})))};var j_=dL,B_=CL;function F_(t,e,n){for(var r;e.length&&(r=j_.last(e)).i<=n;)e.pop(),t.push(r.vs),n++;return n}var z_=dL,G_=function(t,e){return L_.map(e,(function(e){var n=t.inEdges(e);if(n.length){var r=L_.reduce(n,(function(e,n){var r=t.edge(n),i=t.node(n.v);return{sum:e.sum+r.weight*i.order,weight:e.weight+r.weight}}),{sum:0,weight:0});return{v:e,barycenter:r.sum/r.weight,weight:r.weight}}return{v:e}}))},V_=I_,W_=function(t,e){var n=B_.partition(t,(function(t){return j_.has(t,"barycenter")})),r=n.lhs,i=j_.sortBy(n.rhs,(function(t){return-t.i})),o=[],a=0,s=0,l=0;r.sort((u=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:u?e.i-t.i:t.i-e.i})),l=F_(o,i,l),j_.forEach(r,(function(t){l+=t.vs.length,o.push(t.vs),a+=t.barycenter*t.weight,s+=t.weight,l=F_(o,i,l)}));var u;var c={vs:j_.flatten(o,!0)};s&&(c.barycenter=a/s,c.weight=s);return c},H_=function t(e,n,r,i){var o=e.children(n),a=e.node(n),s=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,u={};s&&(o=z_.filter(o,(function(t){return t!==s&&t!==l})));var c=G_(e,o);z_.forEach(c,(function(n){if(e.children(n.v).length){var o=t(e,n.v,r,i);u[n.v]=o,z_.has(o,"barycenter")&&(a=n,s=o,z_.isUndefined(a.barycenter)?(a.barycenter=s.barycenter,a.weight=s.weight):(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight))}var a,s}));var h=V_(c,r);!function(t,e){z_.forEach(t,(function(t){t.vs=z_.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(h,u);var d=W_(h,i);if(s&&(d.vs=z_.flatten([s,d.vs,l],!0),e.predecessors(s).length)){var f=e.node(e.predecessors(s)[0]),p=e.node(e.predecessors(l)[0]);z_.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var U_=dL,$_=ZD.Graph,Y_=function(t,e,n){var r=function(t){var e;for(;t.hasNode(e=U_.uniqueId("_root")););return e}(t),i=new $_({compound:!0}).setGraph({root:r}).setDefaultNodeLabel((function(e){return t.node(e)}));return U_.forEach(t.nodes(),(function(o){var a=t.node(o),s=t.parent(o);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),U_.forEach(t[n](o),(function(e){var n=e.v===o?e.w:e.v,r=i.edge(n,o),a=U_.isUndefined(r)?0:r.weight;i.setEdge(n,o,{weight:t.edge(e).weight+a})})),U_.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),i};var q_=dL;var X_=dL,K_=A_,Z_=R_,Q_=H_,J_=Y_,tI=function(t,e,n){var r,i={};q_.forEach(n,(function(n){for(var o,a,s=t.parent(n);s;){if((o=t.parent(s))?(a=i[o],i[o]=s):(a=r,r=s),a&&a!==s)return void e.setEdge(a,s);s=o}}))},eI=ZD.Graph,nI=CL,rI=function(t){var e=nI.maxRank(t),n=iI(t,X_.range(1,e+1),"inEdges"),r=iI(t,X_.range(e-1,-1,-1),"outEdges"),i=K_(t);aI(t,i);for(var o,a=Number.POSITIVE_INFINITY,s=0,l=0;l<4;++s,++l){oI(s%2?n:r,s%4>=2),i=nI.buildLayerMatrix(t);var u=Z_(t,i);u<a&&(l=0,o=X_.cloneDeep(i),a=u)}aI(t,o)};function iI(t,e,n){return X_.map(e,(function(e){return J_(t,e,n)}))}function oI(t,e){var n=new eI;X_.forEach(t,(function(t){var r=t.graph().root,i=Q_(t,r,n,e);X_.forEach(i.vs,(function(e,n){t.node(e).order=n})),tI(t,n,i.vs)}))}function aI(t,e){X_.forEach(e,(function(e){X_.forEach(e,(function(e,n){t.node(e).order=n}))}))}var sI=dL,lI=ZD.Graph,uI=CL,cI=function(t){var e,n=uI.buildLayerMatrix(t),r=sI.merge(function(t,e){var n={};function r(e,r){var i=0,o=0,a=e.length,s=sI.last(r);return sI.forEach(r,(function(e,l){var u=function(t,e){if(t.node(e).dummy)return sI.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=u?t.node(u).order:a;(u||e===s)&&(sI.forEach(r.slice(o,l+1),(function(e){sI.forEach(t.predecessors(e),(function(r){var o=t.node(r),a=o.order;!(a<i||c<a)||o.dummy&&t.node(e).dummy||hI(n,r,e)}))})),o=l+1,i=c)})),r}return sI.reduce(e,r),n}(t,n),function(t,e){var n={};function r(e,r,i,o,a){var s;sI.forEach(sI.range(r,i),(function(r){s=e[r],t.node(s).dummy&&sI.forEach(t.predecessors(s),(function(e){var r=t.node(e);r.dummy&&(r.order<o||r.order>a)&&hI(n,e,s)}))}))}function i(e,n){var i,o=-1,a=0;return sI.forEach(n,(function(s,l){if("border"===t.node(s).dummy){var u=t.predecessors(s);u.length&&(i=t.node(u[0]).order,r(n,a,l,o,i),a=l,o=i)}r(n,a,n.length,i,e.length)})),n}return sI.reduce(e,i),n}(t,n)),i={};sI.forEach(["u","d"],(function(o){e="u"===o?n:sI.values(n).reverse(),sI.forEach(["l","r"],(function(n){"r"===n&&(e=sI.map(e,(function(t){return sI.values(t).reverse()})));var a=("u"===o?t.predecessors:t.successors).bind(t),s=function(t,e,n,r){var i={},o={},a={};return sI.forEach(e,(function(t){sI.forEach(t,(function(t,e){i[t]=t,o[t]=t,a[t]=e}))})),sI.forEach(e,(function(t){var e=-1;sI.forEach(t,(function(t){var s=r(t);if(s.length){s=sI.sortBy(s,(function(t){return a[t]}));for(var l=(s.length-1)/2,u=Math.floor(l),c=Math.ceil(l);u<=c;++u){var h=s[u];o[t]===t&&e<a[h]&&!dI(n,t,h)&&(o[h]=t,o[t]=i[t]=i[h],e=a[h])}}}))})),{root:i,align:o}}(0,e,r,a),l=function(t,e,n,r,i){var o={},a=function(t,e,n,r){var i=new lI,o=t.graph(),a=function(t,e,n){return function(r,i,o){var a,s=r.node(i),l=r.node(o),u=0;if(u+=s.width/2,sI.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2}if(a&&(u+=n?a:-a),a=0,u+=(s.dummy?e:t)/2,u+=(l.dummy?e:t)/2,u+=l.width/2,sI.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(u+=n?a:-a),a=0,u}}(o.nodesep,o.edgesep,r);return sI.forEach(e,(function(e){var r;sI.forEach(e,(function(e){var o=n[e];if(i.setNode(o),r){var s=n[r],l=i.edge(s,o);i.setEdge(s,o,Math.max(a(t,e,r),l||0))}r=e}))})),i}(t,e,n,i),s=i?"borderLeft":"borderRight";function l(t,e){for(var n=a.nodes(),r=n.pop(),i={};r;)i[r]?t(r):(i[r]=!0,n.push(r),n=n.concat(e(r))),r=n.pop()}function u(t){o[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,o[e.v]+a.edge(e))}),0)}function c(e){var n=a.outEdges(e).reduce((function(t,e){return Math.min(t,o[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==s&&(o[e]=Math.max(o[e],n))}return l(u,a.predecessors.bind(a)),l(c,a.successors.bind(a)),sI.forEach(r,(function(t){o[t]=o[n[t]]})),o}(t,e,s.root,s.align,"r"===n);"r"===n&&(l=sI.mapValues(l,(function(t){return-t}))),i[o+n]=l}))}));var o=function(t,e){return sI.minBy(sI.values(e),(function(e){var n=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;return sI.forIn(e,(function(e,i){var o=function(t,e){return t.node(e).width}(t,i)/2;n=Math.max(e+o,n),r=Math.min(e-o,r)})),n-r}))}(t,i);return function(t,e){var n=sI.values(e),r=sI.min(n),i=sI.max(n);sI.forEach(["u","d"],(function(n){sI.forEach(["l","r"],(function(o){var a,s=n+o,l=t[s];if(l!==e){var u=sI.values(l);(a="l"===o?r-sI.min(u):i-sI.max(u))&&(t[s]=sI.mapValues(l,(function(t){return t+a})))}}))}))}(i,o),function(t,e){return sI.mapValues(t.ul,(function(n,r){if(e)return t[e.toLowerCase()][r];var i=sI.sortBy(sI.map(t,r));return(i[1]+i[2])/2}))}(i,t.graph().align)};function hI(t,e,n){if(e>n){var r=e;e=n,n=r}var i=t[e];i||(t[e]=i={}),i[n]=!0}function dI(t,e,n){if(e>n){var r=e;e=n,n=r}return sI.has(t[e],n)}var fI=dL,pI=CL,gI=cI,vI=function(t){(function(t){var e=pI.buildLayerMatrix(t),n=t.graph().ranksep,r=0;fI.forEach(e,(function(e){var i=fI.max(fI.map(e,(function(e){return t.node(e).height})));fI.forEach(e,(function(e){t.node(e).y=r+i/2})),r+=i+n}))})(t=pI.asNonCompoundGraph(t)),fI.forEach(gI(t),(function(e,n){t.node(n).x=e}))};var mI=dL,yI=NL,bI=LL,xI=c_,EI=CL.normalizeRanks,wI=p_,kI=CL.removeEmptyRanks,MI=m_,SI=E_,NI=M_,OI=rI,TI=vI,CI=CL,AI=ZD.Graph,PI=function(t,e){var n=e&&e.debugTiming?CI.time:CI.notime;n("layout",(function(){var e=n(" buildLayoutGraph",(function(){return function(t){var e=new AI({multigraph:!0,compound:!0}),n=GI(t.graph());return e.setGraph(mI.merge({},DI,zI(n,RI),mI.pick(n,LI))),mI.forEach(t.nodes(),(function(n){var r=GI(t.node(n));e.setNode(n,mI.defaults(zI(r,_I),II)),e.setParent(n,t.parent(n))})),mI.forEach(t.edges(),(function(n){var r=GI(t.edge(n));e.setEdge(n,mI.merge({},BI,zI(r,jI),mI.pick(r,FI)))})),e}(t)}));n(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,mI.forEach(t.edges(),(function(n){var r=t.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){mI.forEach(t.edges(),(function(e){if(e.v===e.w){var n=t.node(e.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){yI.run(t)})),e(" nestingGraph.run",(function(){MI.run(t)})),e(" rank",(function(){xI(CI.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);if(n.width&&n.height){var r=t.node(e.v),i={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};CI.addDummyNode(t,"edge-proxy",i,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){kI(t)})),e(" nestingGraph.cleanup",(function(){MI.cleanup(t)})),e(" normalizeRanks",(function(){EI(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;mI.forEach(t.nodes(),(function(n){var r=t.node(n);r.borderTop&&(r.minRank=t.node(r.borderTop).rank,r.maxRank=t.node(r.borderBottom).rank,e=mI.max(e,r.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){mI.forEach(t.nodes(),(function(e){var n=t.node(e);"edge-proxy"===n.dummy&&(t.edge(n.e).labelRank=n.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){bI.run(t)})),e(" parentDummyChains",(function(){wI(t)})),e(" addBorderSegments",(function(){SI(t)})),e(" order",(function(){OI(t)})),e(" insertSelfEdges",(function(){!function(t){var e=CI.buildLayerMatrix(t);mI.forEach(e,(function(e){var n=0;mI.forEach(e,(function(e,r){var i=t.node(e);i.order=r+n,mI.forEach(i.selfEdges,(function(e){CI.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:i.rank,order:r+ ++n,e:e.e,label:e.label},"_se")})),delete i.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){NI.adjust(t)})),e(" position",(function(){TI(t)})),e(" positionSelfEdges",(function(){!function(t){mI.forEach(t.nodes(),(function(e){var n=t.node(e);if("selfedge"===n.dummy){var r=t.node(n.e.v),i=r.x+r.width/2,o=r.y,a=n.x-i,s=r.height/2;t.setEdge(n.e,n.label),t.removeNode(e),n.label.points=[{x:i+2*a/3,y:o-s},{x:i+5*a/6,y:o-s},{x:i+a,y:o},{x:i+5*a/6,y:o+s},{x:i+2*a/3,y:o+s}],n.label.x=n.x,n.label.y=n.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){mI.forEach(t.nodes(),(function(e){if(t.children(e).length){var n=t.node(e),r=t.node(n.borderTop),i=t.node(n.borderBottom),o=t.node(mI.last(n.borderLeft)),a=t.node(mI.last(n.borderRight));n.width=Math.abs(a.x-o.x),n.height=Math.abs(i.y-r.y),n.x=o.x+n.width/2,n.y=r.y+n.height/2}})),mI.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){bI.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);if(mI.has(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){NI.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,o=t.graph(),a=o.marginx||0,s=o.marginy||0;function l(t){var o=t.x,a=t.y,s=t.width,l=t.height;e=Math.min(e,o-s/2),n=Math.max(n,o+s/2),r=Math.min(r,a-l/2),i=Math.max(i,a+l/2)}mI.forEach(t.nodes(),(function(e){l(t.node(e))})),mI.forEach(t.edges(),(function(e){var n=t.edge(e);mI.has(n,"x")&&l(n)})),e-=a,r-=s,mI.forEach(t.nodes(),(function(n){var i=t.node(n);i.x-=e,i.y-=r})),mI.forEach(t.edges(),(function(n){var i=t.edge(n);mI.forEach(i.points,(function(t){t.x-=e,t.y-=r})),mI.has(i,"x")&&(i.x-=e),mI.has(i,"y")&&(i.y-=r)})),o.width=n-e+a,o.height=i-r+s}(t)})),e(" assignNodeIntersects",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n,r,i=t.edge(e),o=t.node(e.v),a=t.node(e.w);i.points?(n=i.points[0],r=i.points[i.points.length-1]):(i.points=[],n=a,r=o),i.points.unshift(CI.intersectRect(o,n)),i.points.push(CI.intersectRect(a,r))}))}(t)})),e(" reversePoints",(function(){!function(t){mI.forEach(t.edges(),(function(e){var n=t.edge(e);n.reversed&&n.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){yI.undo(t)}))}(e,n)})),n(" updateInputGraph",(function(){!function(t,e){mI.forEach(t.nodes(),(function(n){var r=t.node(n),i=e.node(n);r&&(r.x=i.x,r.y=i.y,e.children(n).length&&(r.width=i.width,r.height=i.height))})),mI.forEach(t.edges(),(function(n){var r=t.edge(n),i=e.edge(n);r.points=i.points,mI.has(i,"x")&&(r.x=i.x,r.y=i.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var RI=["nodesep","edgesep","ranksep","marginx","marginy"],DI={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},LI=["acyclicer","ranker","rankdir","align"],_I=["width","height"],II={width:0,height:0},jI=["minlen","weight","width","height","labeloffset"],BI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},FI=["labelpos"];function zI(t,e){return mI.mapValues(mI.pick(t,e),Number)}function GI(t){var e={};return mI.forEach(t,(function(t,n){e[n.toLowerCase()]=t})),e}var VI=dL,WI=CL,HI=ZD.Graph,UI={debugOrdering:function(t){var e=WI.buildLayerMatrix(t),n=new HI({compound:!0,multigraph:!0}).setGraph({});return VI.forEach(t.nodes(),(function(e){n.setNode(e,{label:e}),n.setParent(e,"layer"+t.node(e).rank)})),VI.forEach(t.edges(),(function(t){n.setEdge(t.v,t.w,{},t.name)})),VI.forEach(e,(function(t,e){var r="layer"+e;n.setNode(r,{rank:"same"}),VI.reduce(t,(function(t,e){return n.setEdge(t,e,{style:"invis"}),e}))})),n}};var $I={graphlib:ZD,layout:PI,debug:UI,util:{time:CL.time,notime:CL.notime},version:"0.8.5"},YI=E($I);class qI{constructor(t){this.id="dagre",this.options={},Object.assign(this.options,qI.defaultOptions,t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericDagreLayout(!1,t,Object.assign(Object.assign({},this.options),e))}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericDagreLayout(!0,t,Object.assign(Object.assign({},this.options),e))}))}genericDagreLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{nodeSize:r}=n,i=new $I.graphlib.Graph;i.setGraph(n),i.setDefaultEdgeLabel((()=>({})));[...e.getAllNodes(),...e.getAllEdges()].some((({id:t})=>ae(t)))&&console.error("Dagre layout only support string id, it will convert number to string."),e.getAllNodes().forEach((t=>{const{id:e}=t,n=Object.assign({},t.data);if(void 0!==r){const[e,i]=db(Ut(r)?r(t):r);Object.assign(n,{width:e,height:i})}i.setNode(e.toString(),n)})),e.getAllEdges().forEach((({id:t,source:e,target:n})=>{i.setEdge(e.toString(),n.toString(),{id:t})})),YI.layout(i);const o={nodes:[],edges:[]};return i.nodes().forEach((n=>{const r=i.node(n);o.nodes.push({id:n,data:r}),t&&e.mergeNodeData(n,r)})),i.edges().forEach((n=>{const r=i.edge(n),{id:a}=r,s=Fe(r,["id"]),{v:l,w:u}=n;o.edges.push({id:a,source:l,target:u,data:s}),t&&e.mergeEdgeData(a,s)})),o}))}}qI.defaultOptions={};class XI{constructor(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}distanceTo(t){const e=this.rx-t.rx,n=this.ry-t.ry;return Math.hypot(e,n)}setPos(t,e){this.rx=t,this.ry=e}resetForce(){this.fx=0,this.fy=0}addForce(t){const e=t.rx-this.rx,n=t.ry-this.ry;let r=Math.hypot(e,n);r=r<1e-4?1e-4:r;const i=this.g*(this.degree+1)*(t.degree+1)/r;this.fx+=i*e/r,this.fy+=i*n/r}in(t){return t.contains(this.rx,this.ry)}add(t){const e=this.mass+t.mass,n=(this.rx*this.mass+t.rx*t.mass)/e,r=(this.ry*this.mass+t.ry*t.mass)/e,i=this.degree+t.degree;return new XI({rx:n,ry:r,mass:e,degree:i})}}class KI{constructor(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}getLength(){return this.length}contains(t,e){const n=this.length/2;return t<=this.xmid+n&&t>=this.xmid-n&&e<=this.ymid+n&&e>=this.ymid-n}NW(){const t=this.xmid-this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new KI({xmid:t,ymid:e,length:n})}NE(){const t=this.xmid+this.length/4,e=this.ymid+this.length/4,n=this.length/2;return new KI({xmid:t,ymid:e,length:n})}SW(){const t=this.xmid-this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new KI({xmid:t,ymid:e,length:n})}SE(){const t=this.xmid+this.length/4,e=this.ymid-this.length/4,n=this.length/2;return new KI({xmid:t,ymid:e,length:n})}}class ZI{constructor(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}insert(t){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new ZI(this.quad.NW()),this.NE=new ZI(this.quad.NE()),this.SW=new ZI(this.quad.SW()),this.SE=new ZI(this.quad.SE())),this._putBody(this.body),this._putBody(t),this.body=this.body.add(t)):(this.body=this.body.add(t),this._putBody(t)):this.body=t}_putBody(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))}_isExternal(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE}updateForce(t){if(null!=this.body&&t!==this.body)if(this._isExternal())t.addForce(this.body);else{(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t))}}}const QI={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1};class JI{constructor(t={}){this.options=t,this.id="forceAtlas2",this.options=Object.assign(Object.assign({},QI),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericForceAtlas2Layout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericForceAtlas2Layout(!0,t,e)}))}genericForceAtlas2Layout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=e.getAllEdges(),i=e.getAllNodes(),o=this.formatOptions(n,i.length),{width:a,height:s,prune:l,maxIteration:u,nodeSize:c,center:h}=o;if(!(null==i?void 0:i.length)||1===i.length)return bb(e,t,h);const d=i.map((t=>hb(t,[a,s]))),f=r.filter((t=>{const{source:e,target:n}=t;return e!==n})),p=new Yg({nodes:d,edges:f}),g=this.getSizes(p,c);if(this.run(p,e,u,g,t,o),l){for(let t=0;t<f.length;t+=1){const{source:e,target:n}=f[t],r=p.getDegree(e),i=p.getDegree(e);if(r<=1){const t=p.getNode(n);p.mergeNodeData(e,{x:t.data.x,y:t.data.y})}else if(i<=1){const t=p.getNode(e);p.mergeNodeData(n,{x:t.data.x,y:t.data.y})}}const n=Object.assign(Object.assign({},o),{prune:!1,barnesHut:!1});this.run(p,e,100,g,t,n)}return{nodes:d,edges:r}}))}getSizes(t,e){const n=t.getAllNodes(),r={};for(let t=0;t<n.length;t+=1){const i=n[t];r[i.id]=gb(e,void 0)(i)}return r}formatOptions(t={},e){const n=Object.assign(Object.assign({},this.options),t),{center:r,width:i,height:o,barnesHut:a,prune:s,maxIteration:l,kr:u,kg:c}=n;return n.width=i||"undefined"==typeof window?i:window.innerWidth,n.height=o||"undefined"==typeof window?o:window.innerHeight,n.center=r||[n.width/2,n.height/2],void 0===a&&e>250&&(n.barnesHut=!0),void 0===s&&e>100&&(n.prune=!0),0!==l||s?0===l&&s&&(n.maxIteration=100,e<=200&&e>100?n.maxIteration=500:e>200&&(n.maxIteration=950)):(n.maxIteration=250,e<=200&&e>100?n.maxIteration=1e3:e>200&&(n.maxIteration=1200)),u||(n.kr=50,e>100&&e<=500?n.kr=20:e>500&&(n.kr=1)),c||(n.kg=20,e>100&&e<=500?n.kg=10:e>500&&(n.kg=1)),n}run(t,e,n,r,i,o){const{kr:a,barnesHut:s,onTick:l}=o,u=t.getAllNodes();let c=0,h=n;const d={},f={},p={};for(let e=0;e<u.length;e+=1){const{data:n,id:r}=u[e];if(d[r]=[0,0],s){const i={id:e,rx:n.x,ry:n.y,mass:1,g:a,degree:t.getDegree(r)};p[r]=new XI(i)}}for(;h>0;)c=this.oneStep(t,{iter:h,preventOverlapIters:50,krPrime:100,sg:c,forces:d,preForces:f,bodies:p,sizes:r},o),h--,null==l||l({nodes:u,edges:e.getAllEdges()});return t}oneStep(t,e,n){const{iter:r,preventOverlapIters:i,krPrime:o,sg:a,preForces:s,bodies:l,sizes:u}=e;let{forces:c}=e;const{preventOverlap:h,barnesHut:d}=n,f=t.getAllNodes();for(let t=0;t<f.length;t+=1){const{id:e}=f[t];s[e]=[...c[e]],c[e]=[0,0]}return c=this.getAttrForces(t,r,i,u,c,n),c=d&&(h&&r>i||!h)?this.getOptRepGraForces(t,c,l,n):this.getRepGraForces(t,r,i,c,o,u,n),this.updatePos(t,c,s,a,n)}getAttrForces(t,e,n,r,i,o){const{preventOverlap:a,dissuadeHubs:s,mode:l,prune:u}=o,c=t.getAllEdges();for(let o=0;o<c.length;o+=1){const{source:h,target:d}=c[o],f=t.getNode(h),p=t.getNode(d),g=t.getDegree(h),v=t.getDegree(d);if(u&&(g<=1||v<=1))continue;const m=[p.data.x-f.data.x,p.data.y-f.data.y];let y=Math.hypot(m[0],m[1]);y=y<1e-4?1e-4:y,m[0]=m[0]/y,m[1]=m[1]/y,a&&e<n&&(y=y-r[h]-r[d]);let b=y,x=b;"linlog"===l&&(b=Math.log(1+y),x=b),s&&(b=y/g,x=y/v),a&&e<n&&y<=0?(b=0,x=0):a&&e<n&&y>0&&(b=y,x=y),i[h][0]+=b*m[0],i[d][0]-=x*m[0],i[h][1]+=b*m[1],i[d][1]-=x*m[1]}return i}getOptRepGraForces(t,e,n,r){const{kg:i,center:o,prune:a}=r,s=t.getAllNodes(),l=s.length;let u=9e10,c=-9e10,h=9e10,d=-9e10;for(let e=0;e<l;e+=1){const{id:r,data:i}=s[e];a&&t.getDegree(r)<=1||(n[r].setPos(i.x,i.y),i.x>=c&&(c=i.x),i.x<=u&&(u=i.x),i.y>=d&&(d=i.y),i.y<=h&&(h=i.y))}const f=Math.max(c-u,d-h),p=new KI({xmid:(c+u)/2,ymid:(d+h)/2,length:f,massCenter:o,mass:l}),g=new ZI(p);for(let e=0;e<l;e+=1){const{id:r}=s[e];a&&t.getDegree(r)<=1||n[r].in(p)&&g.insert(n[r])}for(let r=0;r<l;r+=1){const{id:l,data:u}=s[r],c=t.getDegree(l);if(a&&c<=1)continue;n[l].resetForce(),g.updateForce(n[l]),e[l][0]-=n[l].fx,e[l][1]-=n[l].fy;const h=[u.x-o[0],u.y-o[1]];let d=Math.hypot(h[0],h[1]);d=d<1e-4?1e-4:d,h[0]=h[0]/d,h[1]=h[1]/d;const f=i*(c+1);e[l][0]-=f*h[0],e[l][1]-=f*h[1]}return e}getRepGraForces(t,e,n,r,i,o,a){const{preventOverlap:s,kr:l,kg:u,center:c,prune:h}=a,d=t.getAllNodes(),f=d.length;for(let a=0;a<f;a+=1){const p=d[a],g=t.getDegree(p.id);for(let u=a+1;u<f;u+=1){const a=d[u],c=t.getDegree(a.id);if(h&&(g<=1||c<=1))continue;const f=[a.data.x-p.data.x,a.data.y-p.data.y];let v=Math.hypot(f[0],f[1]);v=v<1e-4?1e-4:v,f[0]=f[0]/v,f[1]=f[1]/v,s&&e<n&&(v=v-o[p.id]-o[a.id]);let m=l*(g+1)*(c+1)/v;s&&e<n&&v<0?m=i*(g+1)*(c+1):s&&e<n&&0===v?m=0:s&&e<n&&v>0&&(m=l*(g+1)*(c+1)/v),r[p.id][0]-=m*f[0],r[a.id][0]+=m*f[0],r[p.id][1]-=m*f[1],r[a.id][1]+=m*f[1]}const v=[p.data.x-c[0],p.data.y-c[1]],m=Math.hypot(v[0],v[1]);v[0]=v[0]/m,v[1]=v[1]/m;const y=u*(g+1);r[p.id][0]-=y*v[0],r[p.id][1]-=y*v[1]}return r}updatePos(t,e,n,r,i){const{ks:o,tao:a,prune:s,ksmax:l}=i,u=t.getAllNodes(),c=u.length,h=[],d=[];let f=0,p=0,g=r;for(let r=0;r<c;r+=1){const{id:i}=u[r],o=t.getDegree(i);if(s&&o<=1)continue;const a=[e[i][0]-n[i][0],e[i][1]-n[i][1]],l=Math.hypot(a[0],a[1]),c=[e[i][0]+n[i][0],e[i][1]+n[i][1]],g=Math.hypot(c[0],c[1]);h[r]=l,d[r]=g/2,f+=(o+1)*h[r],p+=(o+1)*d[r]}const v=g;g=a*p/f,0!==v&&(g=g>1.5*v?1.5*v:g);for(let n=0;n<c;n+=1){const{id:r,data:i}=u[n],a=t.getDegree(r);if(s&&a<=1)continue;if(ae(i.fx)&&ae(i.fy))continue;let c=o*g/(1+g*Math.sqrt(h[n])),d=Math.hypot(e[r][0],e[r][1]);d=d<1e-4?1e-4:d;const f=l/d;c=c>f?f:c;const p=c*e[r][0],v=c*e[r][1];t.mergeNodeData(r,{x:i.x+p,y:i.y+v})}return g}}const tj={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"};class ej{constructor(t={}){this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=Object.assign(Object.assign({},tj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericFruchtermanLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericFruchtermanLayout(!0,t,e)}))}stop(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1}tick(t=this.options.maxIteration||1){if(this.lastResult)return this.lastResult;for(let e=0;e<t;e++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);const e={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&e.nodes.forEach((t=>this.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===this.options.dimensions?t.data.z:void 0}))),e}genericFruchtermanLayout(t,e,n){return ze(this,void 0,void 0,(function*(){if(this.running)return;const r=this.formatOptions(n),{dimensions:i,width:o,height:a,center:s,clustering:l,nodeClusterBy:u,maxIteration:c,onTick:h}=r,d=e.getAllNodes(),f=e.getAllEdges();if(!(null==d?void 0:d.length)){const t={nodes:[],edges:f};return this.lastResult=t,t}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:s[0],y:s[1],z:3===i?s[2]:void 0});const n={nodes:[Object.assign(Object.assign({},d[0]),{data:Object.assign(Object.assign({},d[0].data),{x:s[0],y:s[1],z:3===i?s[2]:void 0})})],edges:f};return this.lastResult=n,n}const p=d.map((t=>hb(t,[o,a]))),g=new Yg({nodes:p,edges:f}),v={};if(l&&p.forEach((t=>{const e=t.data[u];v[e]||(v[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=p,this.lastLayoutEdges=f,this.lastAssign=t,this.lastGraph=g,this.lastOptions=r,this.lastClusterMap=v,"undefined"==typeof window)return;let m=0;return new Promise((n=>{this.timeInterval=window.setInterval((()=>{this.running?(this.runOneStep(g,v,r),t&&p.forEach((({id:t,data:n})=>e.mergeNodeData(t,{x:n.x,y:n.y,z:3===i?n.z:void 0}))),null==h||h({nodes:p,edges:f}),m++,m>=c&&(window.clearInterval(this.timeInterval),n({nodes:p,edges:f}))):n({nodes:p,edges:f})}),0),this.running=!0}))}))}formatOptions(t={}){const e=Object.assign(Object.assign({},this.options),t),{clustering:n,nodeClusterBy:r}=e,{center:i,width:o,height:a}=e;return e.width=o||"undefined"==typeof window?o:window.innerWidth,e.height=a||"undefined"==typeof window?a:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=n&&!!r,e}runOneStep(t,e,n){const{dimensions:r,height:i,width:o,gravity:a,center:s,speed:l,clustering:u,nodeClusterBy:c,clusterGravity:h}=n,d=i*o,f=Math.sqrt(d)/10,p=t.getAllNodes(),g=d/(p.length+1),v=Math.sqrt(g),m={};if(this.applyCalculate(t,m,v,g),u){for(const t in e)e[t].cx=0,e[t].cy=0,e[t].count=0;p.forEach((t=>{const{data:n}=t,r=e[n[c]];ae(n.x)&&(r.cx+=n.x),ae(n.y)&&(r.cy+=n.y),r.count++}));for(const t in e)e[t].cx/=e[t].count,e[t].cy/=e[t].count;const t=h||a;p.forEach(((n,r)=>{const{id:i,data:o}=n;if(!ae(o.x)||!ae(o.y))return;const a=e[o[c]],s=Math.sqrt((o.x-a.cx)*(o.x-a.cx)+(o.y-a.cy)*(o.y-a.cy)),l=v*t;m[i].x-=l*(o.x-a.cx)/s,m[i].y-=l*(o.y-a.cy)/s}))}p.forEach(((t,e)=>{const{id:n,data:i}=t;if(!ae(i.x)||!ae(i.y))return;const o=.01*v*a;m[n].x-=o*(i.x-s[0]),m[n].y-=o*(i.y-s[1]),3===r&&(m[n].z-=o*(i.z-s[2]))})),p.forEach(((e,n)=>{const{id:i,data:o}=e;if(ae(o.fx)&&ae(o.fy))return o.x=o.fx,o.y=o.fy,void(3===r&&(o.z=o.fz));if(!ae(o.x)||!ae(o.y))return;const a=Math.sqrt(m[i].x*m[i].x+m[i].y*m[i].y+(3===r?m[i].z*m[i].z:0));if(a>0){const e=Math.min(f*(l/800),a);t.mergeNodeData(i,{x:o.x+m[i].x/a*e,y:o.y+m[i].y/a*e,z:3===r?o.z+m[i].z/a*e:void 0})}}))}applyCalculate(t,e,n,r){this.calRepulsive(t,e,r),this.calAttractive(t,e,n)}calRepulsive(t,e,n){const r=t.getAllNodes();r.forEach((({data:t,id:i},o)=>{e[i]={x:0,y:0,z:0},r.forEach((({data:r,id:a},s)=>{if(o<=s||!ae(t.x)||!ae(r.x)||!ae(t.y)||!ae(r.y))return;let l=t.x-r.x,u=t.y-r.y,c=3===this.options.dimensions?t.z-r.z:0,h=l*l+u*u+c*c;0===h&&(h=1,l=.01,u=.01,c=.01);const d=n/h,f=l*d,p=u*d,g=c*d;e[i].x+=f,e[i].y+=p,e[a].x-=f,e[a].y-=p,3===this.options.dimensions&&(e[i].z+=g,e[a].z-=g)}))}))}calAttractive(t,e,n){t.getAllEdges().forEach((r=>{const{source:i,target:o}=r;if(!i||!o||i===o)return;const{data:a}=t.getNode(i),{data:s}=t.getNode(o);if(!(ae(s.x)&&ae(a.x)&&ae(s.y)&&ae(a.y)))return;const l=s.x-a.x,u=s.y-a.y,c=3===this.options.dimensions?s.z-a.z:0,h=Math.sqrt(l*l+u*u+c*c)/n,d=l*h,f=u*h,p=c*h;e[i].x+=d,e[i].y+=f,e[o].x-=d,e[o].y-=f,3===this.options.dimensions&&(e[i].z+=p,e[o].z-=p)}))}}const nj={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300};class rj{constructor(t={}){this.options=t,this.id="grid",this.options=Object.assign(Object.assign({},nj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericGridLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericGridLayout(!0,t,e)}))}genericGridLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{begin:i=[0,0],condense:o,preventOverlapPadding:a,preventOverlap:s,rows:l,cols:u,nodeSpacing:c,nodeSize:h,width:d,height:f,position:p}=r;let{sortBy:g}=r;const v=e.getAllNodes(),m=e.getAllEdges(),y=null==v?void 0:v.length;if(!y||1===y)return bb(e,t,i);const b=v.map((t=>hb(t)));"id"===g||ne(g)&&void 0!==b[0].data[g]||(g="degree"),"degree"===g?b.sort(((t,n)=>e.getDegree(n.id,"both")-e.getDegree(t.id,"both"))):"id"===g?b.sort(((t,e)=>ae(e.id)&&ae(t.id)?e.id-t.id:`${t.id}`.localeCompare(`${e.id}`))):b.sort(((t,e)=>e.data[g]-t.data[g]));const x=d||"undefined"==typeof window?d:window.innerWidth,E=f||"undefined"==typeof window?f:window.innerHeight,w=y,k={rows:l,cols:u};if(null!=l&&null!=u)k.rows=l,k.cols=u;else if(null!=l&&null==u)k.rows=l,k.cols=Math.ceil(w/k.rows);else if(null==l&&null!=u)k.cols=u,k.rows=Math.ceil(w/k.cols);else{const t=Math.sqrt(w*E/x);k.rows=Math.round(t),k.cols=Math.round(x/E*t)}if(k.rows=Math.max(k.rows,1),k.cols=Math.max(k.cols,1),k.cols*k.rows>w){const t=ij(k),e=oj(k);(t-1)*e>=w?ij(k,t-1):(e-1)*t>=w&&oj(k,e-1)}else for(;k.cols*k.rows<w;){const t=ij(k),e=oj(k);(e+1)*t>=w?oj(k,e+1):ij(k,t+1)}let M=o?0:x/k.cols,S=o?0:E/k.rows;if(s||c){const t=fb(10,c),n=pb(30,h,!1);b.forEach((r=>{r.data.x&&r.data.y||(r.data.x=0,r.data.y=0);const i=e.getNode(r.id),[o,s]=db(n(i)||30),l=void 0!==t?t(r):a,u=o+l,c=s+l;M=Math.max(M,u),S=Math.max(S,c)}))}const N={},O={row:0,col:0},T={};for(let t=0;t<b.length;t++){const n=b[t];let r;if(p&&(r=p(e.getNode(n.id))),r&&(void 0!==r.row||void 0!==r.col)){const t={row:r.row,col:r.col};if(void 0===t.col)for(t.col=0;aj(N,t);)t.col++;else if(void 0===t.row)for(t.row=0;aj(N,t);)t.row++;T[n.id]=t,sj(N,t)}uj(n,i,M,S,T,k,O,N)}const C={nodes:b,edges:m};return t&&b.forEach((t=>{e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),C}))}}const ij=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.min(r,i);else{Math.min(r,i)===t.rows?t.rows=e:t.cols=e}return n},oj=(t,e)=>{let n;const r=t.rows||5,i=t.cols||5;if(null==e)n=Math.max(r,i);else{Math.max(r,i)===t.rows?t.rows=e:t.cols=e}return n},aj=(t,e)=>t[`c-${e.row}-${e.col}`]||!1,sj=(t,e)=>t[`c-${e.row}-${e.col}`]=!0,lj=(t,e)=>{const n=t.cols||5;e.col++,e.col>=n&&(e.col=0,e.row++)},uj=(t,e,n,r,i,o,a,s)=>{let l,u;const c=i[t.id];if(c)l=c.col*n+n/2+e[0],u=c.row*r+r/2+e[1];else{for(;aj(s,a);)lj(o,a);l=a.col*n+n/2+e[0],u=a.row*r+r/2+e[1],sj(s,a),lj(o,a)}t.data.x=l,t.data.y=u},cj={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},hj=(t,e,n,r,i,o)=>{e.forEach(((a,s)=>{n[s]={x:0,y:0},e.forEach(((e,l)=>{if(s===l)return;if(i[s]!==i[l])return;let u=a.x-e.x,c=a.y-e.y,h=Math.sqrt(u*u+c*c);if(0===h){h=1;const t=s>l?1:-1;u=.01*t,c=.01*t}if(h<o(t[s])/2+o(t[l])/2){const t=r*r/h;n[s].x+=u/h*t,n[s].y+=c/h*t}}))}))},dj=(t,e,n,r,i,o,a,s)=>{const l=o||a/10;return r&&e.forEach(((e,n)=>{const r=t[n].x-t[i].x,o=t[n].y-t[i].y,a=Math.sqrt(r*r+o*o);let s=o/a,l=-r/a;const u=Math.sqrt(e.x*e.x+e.y*e.y);let c=Math.acos((s*e.x+l*e.y)/u);c>Math.PI/2&&(c-=Math.PI/2,s*=-1,l*=-1);const h=Math.cos(c)*u;e.x=s*h,e.y=l*h})),t.forEach(((o,a)=>{if(a===i)return;const u=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(u>0&&a!==i){const c=Math.min(l*(n/800),u);if(o.x+=e[a].x/u*c,o.y+=e[a].y/u*c,r){let e=o.x-t[i].x,n=o.y-t[i].y;const r=Math.sqrt(e*e+n*n);e=e/r*s[a],n=n/r*s[a],o.x=t[i].x+e,o.y=t[i].y+n}}})),t},fj={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10};class pj{constructor(t={}){this.options=t,this.id="radial",this.options=Object.assign(Object.assign({},fj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRadialLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRadialLayout(!0,t,e)}))}genericRadialLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{width:i,height:o,center:a,focusNode:s,unitRadius:l,nodeSize:u,nodeSpacing:c,strictRadial:h,preventOverlap:d,maxPreventOverlapIteration:f,sortBy:p,linkDistance:g=50,sortStrength:v=10,maxIteration:m=1e3}=r,y=e.getAllNodes(),b=e.getAllEdges(),x=i||"undefined"==typeof window?i:window.innerWidth,E=o||"undefined"==typeof window?o:window.innerHeight,w=a||[x/2,E/2];if(!(null==y?void 0:y.length)||1===y.length)return bb(e,t,w);let k=y[0];if(ne(s)){for(let t=0;t<y.length;t++)if(y[t].id===s){k=y[t];break}}else k=s||y[0];const M=mj(y,k.id),S=sb({nodes:y,edges:b}),N=ab(S),O=bj(N,M);yj(N,M,O+1);const T=N[M];let C=x-w[0]>w[0]?w[0]:x-w[0],A=E-w[1]>w[1]?w[1]:E-w[1];0===C&&(C=x/2),0===A&&(A=E/2);const P=Math.min(C,A),R=Math.max(...T),D=[],L=l||P/R;T.forEach(((t,e)=>{D[e]=t*L}));const _=gj(y,N,g,D,L,p,v),I=vj(_),j=((t,e,n)=>{try{const n=$x.mul($x.pow(e,2),-.5),r=n.mean("row"),i=n.mean("column"),o=n.mean();n.add(o).subRowVector(r).subColumnVector(i);const a=new Yx(n),s=$x.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((e=>$x.mul([e],[s]).toJSON()[0].splice(0,t)))}catch(t){const r=[];for(let t=0;t<e.length;t++){const t=Math.random()*n,e=Math.random()*n;r.push([t,e])}return r}})(g,_,g);let B,F=j.map((([t,e])=>({x:(isNaN(t)?Math.random()*g:t)-j[M][0],y:(isNaN(e)?Math.random()*g:e)-j[M][1]})));if(this.run(m,F,I,_,D,M),d){B=gb(u,c);const t={nodes:y,nodeSizeFunc:B,positions:F,radii:D,height:E,width:x,strictRadial:Boolean(h),focusIdx:M,iterations:f||200,k:F.length/4.5};F=((t,e)=>{const n=Object.assign(Object.assign({},cj),e),{positions:r,iterations:i,width:o,k:a,speed:s=100,strictRadial:l,focusIdx:u,radii:c=[],nodeSizeFunc:h}=n,d=t.getAllNodes(),f=[],p=o/10;for(let t=0;t<i;t++)r.forEach(((t,e)=>{f[e]={x:0,y:0}})),hj(d,r,f,a,c,h),dj(r,f,s,l,u,p,o,c);return r})(e,t)}const z=[];F.forEach(((t,e)=>{const n=hb(y[e]);n.data.x=t.x+w[0],n.data.y=t.y+w[1],z.push(n)})),t&&z.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:z,edges:b}}))}run(t,e,n,r,i,o){for(let a=0;a<=t;a++){const s=a/t;this.oneIteration(s,e,i,r,n,o)}}oneIteration(t,e,n,r,i,o){const a=1-t;e.forEach(((s,l)=>{const u=lb(s,{x:0,y:0}),c=0===u?0:1/u;if(l===o)return;let h=0,d=0,f=0;e.forEach(((t,e)=>{if(l===e)return;const n=lb(s,t),o=0===n?0:1/n,a=r[e][l];f+=i[l][e],h+=i[l][e]*(t.x+a*(s.x-t.x)*o),d+=i[l][e]*(t.y+a*(s.y-t.y)*o)}));const p=0===n[l]?0:1/n[l];f*=a,f+=t*p*p,h*=a,h+=t*p*s.x*c,s.x=h/f,d*=a,d+=t*p*s.y*c,s.y=d/f}))}}const gj=(t,e,n,r,i,o,a)=>{if(!t)return[];const s=[];if(e){const l={};e.forEach(((e,u)=>{const c=[];e.forEach(((e,s)=>{var h,d;if(u===s)c.push(0);else if(r[u]===r[s])if("data"===o)c.push(e*(Math.abs(u-s)*a)/(r[u]/i));else if(o){let n,f;if(l[t[u].id])n=l[t[u].id];else{const e=("id"===o?t[u].id:null===(h=t[u].data)||void 0===h?void 0:h[o])||0;n=ne(e)?e.charCodeAt(0):e,l[t[u].id]=n}if(l[t[s].id])f=l[t[s].id];else{const e=("id"===o?t[s].id:null===(d=t[s].data)||void 0===d?void 0:d[o])||0;f=ne(e)?e.charCodeAt(0):e,l[t[s].id]=f}c.push(e*(Math.abs(n-f)*a)/(r[u]/i))}else c.push(e*n/(r[u]/i));else{const t=(n+i)/2;c.push(e*t)}})),s.push(c)}))}return s},vj=t=>{const e=t.length,n=t[0].length,r=[];for(let i=0;i<e;i++){const e=[];for(let r=0;r<n;r++)0!==t[i][r]?e.push(1/(t[i][r]*t[i][r])):e.push(0);r.push(e)}return r},mj=(t,e)=>{let n=-1;return t.forEach(((t,r)=>{t.id===e&&(n=r)})),Math.max(n,0)},yj=(t,e,n)=>{const r=t.length;for(let i=0;i<r;i++)if(t[e][i]===1/0){t[e][i]=n,t[i][e]=n;for(let o=0;o<r;o++)t[i][o]!==1/0&&t[e][o]===1/0&&(t[e][o]=n+t[i][o],t[o][e]=n+t[i][o])}for(let n=0;n<r;n++)if(n!==e)for(let i=0;i<r;i++)if(t[n][i]===1/0){let r=Math.abs(t[e][n]-t[e][i]);r=0===r?1:r,t[n][i]=r}},bj=(t,e)=>{let n=0;for(let r=0;r<t[e].length;r++)t[e][r]!==1/0&&(n=t[e][r]>n?t[e][r]:n);return n},xj={center:[0,0],width:300,height:300};class Ej{constructor(t={}){this.options=t,this.id="random",this.options=Object.assign(Object.assign({},xj),t)}execute(t,e){return ze(this,void 0,void 0,(function*(){return this.genericRandomLayout(!1,t,e)}))}assign(t,e){return ze(this,void 0,void 0,(function*(){yield this.genericRandomLayout(!0,t,e)}))}genericRandomLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const r=Object.assign(Object.assign({},this.options),n),{center:i,width:o,height:a}=r,s=e.getAllNodes(),l=o||"undefined"==typeof window?o:window.innerWidth,u=a||"undefined"==typeof window?a:window.innerHeight,c=i||[l/2,u/2],h=[];s&&s.forEach((t=>{h.push({id:t.id,data:{x:.9*(Math.random()-.5)*l+c[0],y:.9*(Math.random()-.5)*u+c[1]}})})),t&&h.forEach((t=>e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})));return{nodes:h,edges:e.getAllEdges()}}))}}
|
|
75
75
|
/**
|
|
76
76
|
* @license
|
|
77
77
|
* Copyright 2019 Google LLC
|
|
@@ -84,4 +84,4 @@ var fu=function(t){function e(t,n,r,i){var o;return s(this,e),(o=v(this,e,[t])).
|
|
|
84
84
|
* @date 5/9/2025, 8:20:14 AM
|
|
85
85
|
* @author AntVis
|
|
86
86
|
* @docs https://g.antv.antgroup.com/
|
|
87
|
-
*/var _H=function(){function t(e){s(this,t),this.dragndropPluginOptions=e}return u(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,l=t.timeStamp,u=[t.clientX,t.clientY],c=null,h=[t.clientX,t.clientY],d=function(){var t=Qn(Kn().mark((function t(o){var d,f,p,g,v,m;return Kn().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=8;break}if(d=o.timeStamp-l,f=gn([o.clientX,o.clientY],u),!(d<=n.dragndropPluginOptions.dragstartTimeThreshold||f<=n.dragndropPluginOptions.dragstartDistanceThreshold)){t.next=5;break}return t.abrupt("return");case 5:o.type="dragstart",a.dispatchEvent(o),s=!0;case 8:if(o.type="drag",o.dx=o.clientX-h[0],o.dy=o.clientY-h[1],a.dispatchEvent(o),h=[o.clientX,o.clientY],r){t.next=21;break}return p="pointer"===n.dragndropPluginOptions.overlap?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=17,i.elementsFromPoint(p[0],p[1]);case 17:g=t.sent,v=g[g.indexOf(e)+1],m=(null==v?void 0:v.closest("[droppable=true]"))||(n.dragndropPluginOptions.isDocumentDroppable?i:null),c!==m&&(c&&(o.type="dragleave",o.target=c,c.dispatchEvent(o)),m&&(o.type="dragenter",o.target=m,m.dispatchEvent(o)),(c=m)&&(o.type="dragover",o.target=c,c.dispatchEvent(o)));case 21:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();o.addEventListener("pointermove",d);var f=function(t){if(s){t.detail={preventClick:!0};var e=t.clone();c&&(e.type="drop",e.target=c,c.dispatchEvent(e)),e.type="dragend",a.dispatchEvent(e),s=!1}o.removeEventListener("pointermove",d)};e.addEventListener("pointerup",f,{once:!0}),e.addEventListener("pointerupoutside",f,{once:!0})}};r.hooks.init.tap(t.tag,(function(){o.addEventListener("pointerdown",a)})),r.hooks.destroy.tap(t.tag,(function(){o.removeEventListener("pointerdown",a)}))}}])}();_H.tag="Dragndrop";var IH=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,e),(t=v(this,e)).name="dragndrop",t.options=n,t}return y(e,t),u(e,[{key:"init",value:function(){this.addRenderingPlugin(new _H(a({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)}}])}(or);const jH=["main"],BH=["background","main","label","transient"];class FH{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=Fe(e,["renderer","background","cursor","enableMultiLayer"]),s=o?BH:jH,l=zH(n,s),u=Object.fromEntries(s.map((t=>[t,new hu(Object.assign(Object.assign({},a),{supportsMutipleCanvasesInOneContainer:o,renderer:l[t],background:o?"background"===t?r:void 0:r}))])));GH(u),this.extends={config:this.config,renderer:n,renderers:l,layers:u}}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 Jc(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=zH(t,this.config.enableMultiLayer?BH:jH);this.extends.renderers=e,Object.entries(e).forEach((([t,e])=>this.getLayer(t).setRenderer(e))),GH(this.getLayers())}getCanvasByViewport(t){return nd(this.getLayer().viewport2Canvas(rd(t)))}getViewportByCanvas(t){return nd(this.getLayer().canvas2Viewport(rd(t)))}getViewportByClient(t){return nd(this.getLayer().client2Viewport(rd(t)))}getClientByViewport(t){return nd(this.getLayer().viewport2Client(rd(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),n=e.client2Viewport(rd(t));return nd(e.viewport2Canvas(n))}toDataURL(){return ze(this,arguments,void 0,(function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:n="viewport"}=t,r=Fe(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=Xc(t);[i,o]=t.min,[a,s]=e}const l=Cn('<div id="virtual-image"></div>'),u=new hu({width:a,height:s,renderer:new Sp,devicePixelRatio:e,container:l,background:this.extends.config.background});yield u.ready,u.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),u.appendChild(this.getRoot().cloneNode(!0));const c=this.getLayer("label").getRoot().cloneNode(!0),h=u.viewport2Canvas({x:0,y:0}),d=this.getCanvasByViewport([0,0]);c.translate([d[0]-h.x,d[1]-h.y]),c.scale(1/this.getCamera().getZoom()),u.appendChild(c),u.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const f=this.getCamera(),p=u.getCamera();if("viewport"===n)p.setZoom(f.getZoom()),p.setPosition(f.getPosition()),p.setFocalPoint(f.getFocalPoint());else if("overall"===n){const[t,e,n]=p.getPosition(),[r,a,s]=p.getFocalPoint();p.setPosition([t+i,e+o,n]),p.setFocalPoint([r+i,a+o,s])}const g=u.getContextService();return new Promise((t=>{u.addEventListener(ou.RERENDER,(()=>ze(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 zH(t,e){return Object.fromEntries(e.map((e=>{const n=(null==t?void 0:t(e))||new Sp;return n instanceof Sp&&n.setConfig({enableDirtyRectangleRendering:!1}),"main"===e?n.registerPlugin(new IH({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[e,n]})))}function GH(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")}))}const VH=t=>t?parseInt(t):0;function WH(t){if(!t)return[0,0];let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||VH(e.width),r=t.clientHeight||VH(e.height);return[n-(VH(e.paddingLeft)+VH(e.paddingRight)),r-(VH(e.paddingTop)+VH(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(ae(e)?e:1,1),Math.max(ae(n)?n:1,1)]}class HH{constructor(t){this.type=t}}class UH extends HH{constructor(t,e){super(t),this.data=e}}class $H extends HH{constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class YH extends HH{constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class qH extends HH{constructor(t,e){super(t),this.data=e}}function XH(t,e){t.emit(e.type,e)}function KH(t){var e;return(null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0}const ZH="cachedStyle",QH=t=>`__${t}__`;function JH(t,e){return Oe(t,[ZH,QH(e)])}class tU{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:l,stage:u}=e,c=Lc(this.context.options,l,u,t);null===(i=null==r?void 0:r.before)||void 0===i||i.call(r);const h=c.length?Ic(s,this.inferStyle(e,n),c):null;return h?(null===(o=null==r?void 0:r.beforeAnimate)||void 0===o||o.call(r,h),h.finished.then((()=>{var t,e;null===(t=null==r?void 0:r.afterAnimate)||void 0===t||t.call(r,h),null===(e=null==r?void 0:r.after)||void 0===e||e.call(r),this.animations.delete(h)}))):null===(a=null==r?void 0:r.after)||void 0===a||a.call(r),h})).filter(Boolean);a.forEach((t=>this.animations.add(t)));const s=Ac(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:l={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},s),l));const{modifiedStyle:u}=t,c={},h={};if("enter"===a)Object.assign(c,{opacity:0});else if("exit"===a)Object.assign(h,{opacity:0});else if("show"===a)Object.assign(c,{opacity:0}),Object.assign(h,{opacity:null!==(n=JH(i,"opacity"))&&void 0!==n?n:Rc("opacity")});else if("hide"===a)Object.assign(c,{opacity:null!==(r=JH(i,"opacity"))&&void 0!==r?r:Rc("opacity")}),Object.assign(h,{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(h,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e]=a;Object.assign(h,{x:t,y:e,childrenNode:s.childrenNode})}}else"edge"===o&&Object.assign(h,{sourceNode:u.sourceNode,targetNode:u.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(c,{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(c,{x:t,y:e,z:n,childrenNode:u.childrenNode})}}else"edge"===o&&Object.assign(c,{sourceNode:u.sourceNode,targetNode:u.targetNode})}return[Object.keys(c).length>0?Object.assign({},s,c):s,Object.keys(h).length>0?Object.assign({},u,h):u]}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 eU{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 UH(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new UH(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class nU extends Ph{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 Jl)return{type:"canvas",element:t};let e=t;for(;e;){if(wg(e))return{type:"node",element:e};if(kg(e))return{type:"edge",element:e};if(Mg(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&&(Ig(s)||s.destroyed))return;const{type:l,detail:u,button:c}=e,h=Object.assign(Object.assign({},e),{target:s,targetType:a,originalTarget:n});l===t.CommonEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${this.currentTargetType}:${t.CommonEvent.POINTER_LEAVE}`,Object.assign(Object.assign({},h),{type:t.CommonEvent.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),s&&(Object.assign(h,{type:t.CommonEvent.POINTER_ENTER}),i.emit(`${a}:${t.CommonEvent.POINTER_ENTER}`,h))),this.currentTarget=s,this.currentTargetType=a),l===t.CommonEvent.CLICK&&2===c||(i.emit(`${a}:${l}`,h),i.emit(l,h)),l===t.CommonEvent.CLICK&&2===u&&(Object.assign(h,{type:t.CommonEvent.DBLCLICK}),i.emit(`${a}:${t.CommonEvent.DBLCLICK}`,h),i.emit(t.CommonEvent.DBLCLICK,h)),l===t.CommonEvent.POINTER_DOWN&&2===c&&(Object.assign(h,{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}`,h),i.emit(t.CommonEvent.CONTEXT_MENU,h))},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 rU(t,e){const{data:n,style:r}=t,i=Fe(t,["data","style"]),{data:o,style:a}=e,s=Fe(e,["data","style"]),l=Object.assign(Object.assign({},i),s);return(n||o)&&Object.assign(l,{data:Object.assign(Object.assign({},n),o)}),(r||a)&&Object.assign(l,{style:Object.assign(Object.assign({},r),a)}),l}function iU(t){const{data:e,style:n}=t,r=Fe(t,["data","style"]);return e&&(r.data=Object.assign({},e)),n&&(r.style=Object.assign({},n)),r}function oU(t={},e={}){const{states:n=[],data:r={},style:i={},children:o=[]}=t,a=Fe(t,["states","data","style","children"]),{states:s=[],data:l={},style:u={},children:c=[]}=e,h=(t,e)=>t.length===e.length&&t.every(((t,n)=>t===e[n])),d=(t,e)=>{const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((n=>t[n]===e[n]))};return!!d(a,Fe(e,["states","data","style","children"]))&&(!!h(o,c)&&(!!h(n,s)&&(!!d(r,l)&&!!d(i,u))))}function aU(t){const{id:e=yh(t),style:n,data:r}=t,i=Fe(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 sU(t){return t.data}class lU{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new Yg}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===dc.NodeUpdated||e===dc.EdgeUpdated||e===dc.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:iU(n),original:iU(r),type:e})}else this.changes.push({value:iU(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=sU(n);return this.isCombo(yh(r))||(void 0===t||t.includes(yh(r)))&&e.push(r),e}),[])}getEdgeDatum(t){return sU(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=sU(n);return(void 0===t||t.includes(yh(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=sU(n);return this.isCombo(yh(r))?((void 0===t||t.includes(yh(r)))&&e.push(r),e):e}),[])}getRootsData(t=wc){return this.model.getRoots(t).map(sU)}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(sU):[]}getDescendantsData(t){const e=this.getElementDataById(t),n=[];return wd(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(yh(t))),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void Tc("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?sU(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?wc:Ec,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(sU):[]}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 sU(this.model.getNode(t))}getNodeLikeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=sU(n);return t?t.includes(yh(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(sU)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(sU)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i,edges:o,combos:a}=this.getData(),s=Ch(i,e,(t=>yh(t)),oU),l=Ch(o,n,(t=>yh(t)),oU),u=Ch(a,r,(t=>yh(t)),oU);this.batch((()=>{const t={nodes:s.enter,edges:l.enter,combos:u.enter};this.addData(t),this.computeZIndex(t,"add",!0);const e={nodes:s.update,edges:l.update,combos:u.update};this.updateData(e),this.computeZIndex(e,"update",!0);const n={nodes:s.exit.map(yh),edges:l.exit.map(yh),combos:u.exit.map(yh)};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:dc.NodeAdded}),aU(t))))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:dc.EdgeAdded}),aU(t))))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(Ec)||e.attachTreeStructure(Ec),e.addNodes(t.map((t=>(this.comboIds.add(yh(t)),this.pushChange({value:t,type:dc.ComboAdded}),aU(t))))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const n=this.getNodeLikeDatum(t),r=e.map(yh);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=yh(t);if("add"===e&&ae(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t))return;const a=this.getParentData(o,Ec),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=yh(t);if("add"===e&&ae(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,Ec);if(s)a=((null===(r=s.style)||void 0===r?void 0:r.zIndex)||0)+1;else{const t=this.getParentData(o,wc);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(ae(null===(e=t.style)||void 0===e?void 0:e.zIndex))return;let{id:a,source:s,target:l}=t;if(a){const t=this.getEdgeDatum(a);s=t.source,l=t.target}else a=yh(t);if(!s||!l)return;const u=(null===(r=null===(n=this.getNodeLikeDatum(s))||void 0===n?void 0:n.style)||void 0===r?void 0:r.zIndex)||0,c=(null===(o=null===(i=this.getNodeLikeDatum(l))||void 0===i?void 0:i.style)||void 0===o?void 0:o.zIndex)||0;this.updateEdgeData([{id:yh(t),style:{zIndex:Math.max(u,c)-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=>yh(e)!==t))}),"combo"===n&&!Od(r)){const e=new Set(this.getAncestorsData(t,Ec).map(yh));i.nodes=i.nodes.filter((t=>!e.has(yh(t)))),i.combos=i.combos.filter((t=>!e.has(yh(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=yh(t),r=bh(t);void 0!==r&&(e.hasTreeStructure(Ec)||e.attachTreeStructure(Ec),null===r&&this.refreshComboData(n),this.setParent(n,bh(t),Ec));const i=t.children||[];if(i.length){e.hasTreeStructure(wc)||e.attachTreeStructure(wc);const t=i.filter((t=>e.hasNode(t)));t.forEach((t=>this.setParent(t,n,wc))),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=yh(t),i=sU(e.getNode(r));if(oU(i,t))return;const o=rU(i,t);this.pushChange({value:o,original:i,type:dc.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:dc.NodeUpdated})})),e.forEach((t=>{this.pushChange({value:t,original:t,type:dc.EdgeUpdated})})),n.forEach((t=>{this.pushChange({value:t,original:t,type:dc.ComboUpdated})}))}syncNodeLikeDatum(t){const{model:e}=this,n=yh(t);if(!e.hasNode(n))return;const r=rU(sU(e.getNode(n)),t);e.mergeNodeData(n,r)}syncEdgeDatum(t){const{model:e}=this,n=yh(t);if(!e.hasEdge(n))return;const r=rU(sU(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=yh(t),r=sU(e.getEdge(n));if(oU(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=rU(r,t);this.pushChange({value:i,original:r,type:dc.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=yh(t),i=sU(e.getNode(r));if(oU(i,t))return;const o=rU(i,t);this.pushChange({value:o,original:i,type:dc.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=bh(this.getNodeLikeDatum(t));if(i!==e&&n===Ec){const n={id:t,combo:e};this.isCombo(t),this.syncNodeLikeDatum(n)}this.model.setParent(t,e,n),r&&n===Ec&&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,Ec);e&&this.pushChange({value:e,original:e,type:dc.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:dc.ComboUpdated})}))}getElementPosition(t){return Jh(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=Ih(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;wd(o,(t=>{const e=yh(t);if(a.has(e))return;a.add(e);const[o,s,l]=Jh(t),u=rU(t,{style:{x:o+n,y:s+r,z:l+i}});this.pushChange({value:u,original:t,type:this.isCombo(e)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(e,u)}),(t=>this.getChildrenData(yh(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,l,u]=Jh(a),c=r-s,h=i-l,d=o-u;wd(a,(t=>{const e=yh(t),[n,r,i]=Jh(t),o=rU(t,{style:{x:n+c,y:r+h,z:i+d}});this.pushChange({value:o,original:t,type:this.isCombo(e)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(yh(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(yh)),this.pushChange({value:this.getNodeData([t])[0],type:dc.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:dc.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:dc.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(Ec)){const e=bh(this.getNodeLikeDatum(t));this.setParent(t,void 0,Ec,!1),this.model.getChildren(t,Ec).forEach((t=>{const n=sU(t),r=yh(n);this.setParent(yh(n),e,Ec,!1);const i=rU(n,{id:yh(n),combo:e});this.pushChange({value:i,original:n,type:this.isCombo(r)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(yh(n),i)})),$t(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(Oc(`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 uU{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 jl({className:"elements"}))}}emit(t,e){e.silence||XH(this.context.graph,t)}forEachElementData(t){Ed.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=(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 Cc(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({},Id(null===(r=this.getTheme(e))||void 0===r?void 0:r.palette),Id(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?Sc("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=ie(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[yh(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(Oc(`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[yh(e.datum)]=Ld(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(yh(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 Ld((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[yh(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(yh(i))){const t=this.getElementState(yh(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[yh(t)]))}getCombos(){return this.context.model.getComboData().map((({id:t})=>this.elementMap[t]))}getElementComputedStyle(t,e){const n=yh(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(t,n),o=e.style||{},a=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),l=this.getStateStyle(n),u=Object.assign({},r,i,o,a,s,l);if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!u.collapsed?[]:t.map(yh).filter((t=>this.getElement(t)));Object.assign(u,{childrenNode:e,childrenData:t})}return u}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 ze(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:l}=n;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new UH(t.GraphEvent.BEFORE_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===l}),e),beforeAnimate:n=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.DRAW,n,a),e),afterAnimate:n=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.DRAW,n,a),e),after:()=>this.emit(new UH(t.GraphEvent.AFTER_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===l,firstRender:!1===this.context.graph.rendered}),e)})}computeChangesAndDrawData(t){const{model:e}=this.context,n=e.getChanges(),r=QB(n);if(0===r.length)return null;const{NodeAdded:i=[],NodeUpdated:o=[],NodeRemoved:a=[],EdgeAdded:s=[],EdgeUpdated:l=[],EdgeRemoved:u=[],ComboAdded:c=[],ComboUpdated:h=[],ComboRemoved:d=[]}=ie(r,(t=>t.type)),f=t=>new Map(t.map((t=>{const e=t.value;return[yh(e),e]}))),p={add:{nodes:f(i),edges:f(s),combos:f(c)},update:{nodes:f(o),edges:f(l),combos:f(h)},remove:{nodes:f(a),edges:f(u),combos:f(d)}},g=this.transformData(p,t);return e.clearChanges(),{dataChanges:n,drawData:g}}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=yh(n);if(this.getElement(o))return;const a=this.getElementType(e,n),s=this.getElementComputedStyle(e,n),l=Sc(e,a);if(!l)return Tc(`The element ${a} of ${e} is not registered.`);this.emit(new YH(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const u=this.container.appendChild(new l({id:o,context:this.context,style:s}));this.shapeTypeMap[o]=a,this.elementMap[o]=u;const{stage:c="enter"}=r;null===(i=this.context.animation)||void 0===i||i.add({element:u,elementType:e,stage:c,originalStyle:Object.assign({},u.attributes),updatedStyle:s},{after:()=>{var i;this.emit(new YH(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),null===(i=u.onCreate)||void 0===i||i.call(u)}})}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=yh(n),{stage:a="update"}=r,s=this.getElement(o);if(!s)return()=>null;this.emit(new YH(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const l=this.getElementType(e,n),u=this.getUpdateStageStyle(e,n,r);this.shapeTypeMap[o]!==l&&(s.destroy(),delete this.shapeTypeMap[o],delete this.elementMap[o],this.createElement(e,n,{animation:!1,silence:!0}));const c="visibility"!==a?a:"hidden"===u.visibility?"hide":"show";"hide"===c&&delete u.visibility,null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:c,originalStyle:Object.assign({},s.attributes),updatedStyle:u},{before:()=>{const t=this.elementMap[o];"collapse"!==a&&_g(t,u),"visibility"===a&&(function(t,e){return QH(e)in(Oe(t,ZH)||{})}(t,"opacity")||function(t,e){const n=Array.isArray(e)?e:[e];Oe(t,ZH)||Te(t,ZH,{}),n.forEach((e=>{Te(Oe(t,ZH),QH(e),t.attributes[e])}))}(t,"opacity"),this.visibilityCache.set(t,"show"===c?"visible":"hidden"),"show"===c&&Ah(t,"visible"))},after:()=>{var i;const s=this.elementMap[o];"collapse"===a&&_g(s,u),"hide"===c&&Ah(s,this.visibilityCache.get(s)),this.emit(new YH(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=yh(t),n=this.getElement(e);n&&function(t){Te(t,"__to_be_destroyed__",!0)}(n)}))}))}destroyElement(e,n,r){var i;const{stage:o="exit"}=r,a=yh(n),s=this.elementMap[a];if(!s)return()=>null;this.emit(new YH(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 YH(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=>yh(t)===e));if(i){const n=jh(Jh(this.context.model.getNodeLikeDatum(e)),Jh(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)}))}}collapseNode(e,n){return ze(this,void 0,void 0,(function*(){var r;const{animation:i,align:o}=n,{model:a,layout:s}=this.context,l=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!l)return;this.markDestroyElement(l.drawData);const u=yield s.simulate();o&&this.alignLayoutResultToElement(u,e),a.updateData(u);const c=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!c)return;const{drawData:h}=c,{add:d,remove:f,update:p}=h;this.markDestroyElement(h);const g={animation:i,stage:"collapse",data:h};this.destroyElements(f,g),this.createElements(d,g),this.updateElements(p,g),yield null===(r=this.context.animation.animate(i,{beforeAnimate:e=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.COLLAPSE,e,h),g),afterAnimate:e=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.COLLAPSE,e,h),g)},{collapse:{target:e,descendants:Array.from(f.nodes).map((([,t])=>yh(t))),position:Jh(p.nodes.get(e))}}))||void 0===r?void 0:r.finished}))}expandNode(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i,layout:o}=this.context,{animation:a,align:s}=n,l=Jh(i.getNodeData([e])[0]),u=this.computeChangesAndDrawData({stage:"expand",animation:a});if(!u)return;const{drawData:{add:c}}=u;this.createElements(c,{animation:!1,stage:"expand",target:e}),this.context.animation.clear();const h=yield o.simulate();s&&this.alignLayoutResultToElement(h,e),i.updateData(h),this.computeStyle("expand");const d=this.computeChangesAndDrawData({stage:"collapse",animation:a});if(!d)return;const{drawData:f}=d,{update:p}=f,g={animation:a,stage:"expand",data:f};c.edges.forEach((t=>p.edges.set(yh(t),t))),c.nodes.forEach((t=>p.nodes.set(yh(t),t))),this.updateElements(p,g),yield null===(r=this.context.animation.animate(a,{beforeAnimate:e=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.EXPAND,e,f),g),afterAnimate:e=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.EXPAND,e,f),g)},{expand:{target:e,descendants:Array.from(c.nodes).map((([,t])=>yh(t))),position:l}}))||void 0===r?void 0:r.finished}))}collapseCombo(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i,element:o}=this.context;if(i.getAncestorsData(e,Ec).some((t=>Od(t))))return;const a=o.getElement(e),s=a.getComboPosition(Object.assign(Object.assign({},a.attributes),{collapsed:!0})),l=this.computeChangesAndDrawData({stage:"collapse",animation:n});if(!l)return;const{dataChanges:u,drawData:c}=l;this.markDestroyElement(c);const{update:h,remove:d}=c,f={animation:n,stage:"collapse",data:c};this.destroyElements(d,f),this.updateElements(h,f);const p=t=>Array.from(t).map((([,t])=>yh(t)));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new UH(t.GraphEvent.BEFORE_DRAW,{dataChanges:u,animation:n}),f),beforeAnimate:e=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.COLLAPSE,e,c),f),afterAnimate:e=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.COLLAPSE,e,c),f),after:()=>this.emit(new UH(t.GraphEvent.AFTER_DRAW,{dataChanges:u,animation:n}),f)},{collapse:{target:e,descendants:[...p(d.nodes),...p(d.combos)],position:s}}))||void 0===r?void 0:r.finished}))}expandCombo(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i}=this.context,o=Jh(i.getComboData([e])[0]);this.computeStyle("expand");const a=this.computeChangesAndDrawData({stage:"expand",animation:n});if(!a)return;const{dataChanges:s,drawData:l}=a,{add:u,update:c}=l,h={animation:n,stage:"expand",data:l,target:e};this.createElements(u,h),this.updateElements(c,h);const d=t=>Array.from(t).map((([,t])=>yh(t)));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new UH(t.GraphEvent.BEFORE_DRAW,{dataChanges:s,animation:n}),h),beforeAnimate:e=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.EXPAND,e,l),h),afterAnimate:e=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.EXPAND,e,l),h),after:()=>this.emit(new UH(t.GraphEvent.AFTER_DRAW,{dataChanges:s,animation:n}),h)},{expand:{target:e,descendants:[...d(u.nodes),...d(u.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 cU{get presetOptions(){return{animation:!!Dc(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 ze(this,void 0,void 0,(function*(){var n,r,i,o;const{graph:a,model:s}=this.context,{add:l}=e;XH(a,new UH(t.GraphEvent.BEFORE_LAYOUT,{type:"pre"}));const u=yield null===(n=this.context.layout)||void 0===n?void 0:n.simulate();null===(r=null==u?void 0:u.nodes)||void 0===r||r.forEach((t=>{const e=yh(t),n=l.nodes.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)})),null===(i=null==u?void 0:u.edges)||void 0===i||i.forEach((t=>{const e=yh(t),n=l.edges.get(e);s.syncEdgeDatum(t),n&&Object.assign(n.style,t.style)})),null===(o=null==u?void 0:u.combos)||void 0===o||o.forEach((t=>{const e=yh(t),n=l.combos.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)})),XH(a,new UH(t.GraphEvent.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)}))}postLayout(){return ze(this,arguments,void 0,(function*(e=this.options){if(!e)return;const n=Array.isArray(e)?e:[e],{graph:r}=this.context;XH(r,new UH(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);XH(r,new UH(t.GraphEvent.BEFORE_STAGE_LAYOUT,{options:a,index:e}));const s=yield this.stepLayout(o,a,e);XH(r,new UH(t.GraphEvent.AFTER_STAGE_LAYOUT,{options:a,index:e})),i.animation||this.updateElementPosition(s,!1)}XH(r,new UH(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 ze(this,void 0,void 0,(function*(){if(!this.options)return{};const t=Array.isArray(this.options)?this.options:[this.options];let e={};for(let n=0;n<t.length;n++){const r=t[n],i=this.getLayoutData(r);e=yield this.stepLayout(i,Object.assign(Object.assign(Object.assign({},this.presetOptions),r),{animation:!1}),n)}return e}))}stepLayout(t,e,n){return ze(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 ze(this,void 0,void 0,(function*(){const{animation:r,enableWorker:i,iterations:o=300}=e,a=this.initGraphLayout(e);if(!a)return{};if(this.instances[n]=a,this.instance=a,i){const e=a;return this.supervisor=new Vj(e.graphData2LayoutModel(t),e.instance,{iterations:o}),Xg(yield this.supervisor.execute())}if(Qx(a))return r?yield a.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(a.execute(t),a.stop(),a.tick(o));const s=yield a.execute(t);if(r){const t=this.updateElementPosition(s,r);yield null==t?void 0:t.finished}return s}))}treeLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{type:n,animation:r}=e,i=Sc("layout",n);if(!i)return{};const{nodes:o=[],edges:a=[]}=t,s=new Yg({nodes:o.map((t=>({id:yh(t),data:t.data||{}}))),edges:a.map((t=>({id:yh(t),source:t.source,target:t.target,data:t.data||{}})))});!function(t){if(t.hasTreeStructure(wc))return;t.attachTreeStructure(wc);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,wc)}}(s);const l={nodes:[],edges:[]},u={nodes:[],edges:[]};s.getRoots(wc).forEach((t=>{wd(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;wd(n,(t=>{const{id:e,x:n,y:i,z:s=0}=t;l.nodes.push({id:e,style:{x:r,y:o,z:a}}),u.nodes.push({id:e,style:{x:n,y:i,z:s}})}),(t=>t.children),"TB")}));const c=this.inferTreeLayoutOffset(u);if(hU(u,c),r){hU(l,c),this.updateElementPosition(l,!1);const t=this.updateElementPosition(u,r);yield null==t?void 0:t.finished}return u}))}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(),[l,u]=a.getCanvasByViewport([0,0]),[c,h]=a.getCanvasByViewport(s);if(n>=l&&r<=c&&i>=u&&o<=h)return[0,0];return[(l+c)/2-(n+r)/2,(u+h)/2-(i+o)/2]}stopLayout(){this.instance&&Qx(this.instance)&&(this.instance.stop(),this.instance=void 0),this.supervisor&&(this.supervisor.stop(),this.supervisor=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutData(t){const{nodeFilter:e=()=>!0,preLayout:n=!1,isLayoutInvisibleNodes:r=!1}=t,{nodes:i,edges:o,combos:a}=this.context.model.getData(),{element:s,model:l}=this.context,u=t=>s.getElement(t),c=n?t=>{var n;if(!r){if("hidden"===(null===(n=t.style)||void 0===n?void 0:n.visibility))return!1;if(l.getAncestorsData(t.id,wc).some(Od))return!1;if(l.getAncestorsData(t.id,Ec).some(Od))return!1}return e(t)}:t=>{const n=yh(t),r=u(n);return!!r&&(!Ig(r)&&e(t))},h=i.filter(c),d=new Map(h.map((t=>[yh(t),t])));a.forEach((t=>d.set(yh(t),t)));return{nodes:h,edges:o.filter((({source:t,target:e})=>d.has(t)&&d.has(e))),combos:a}}initGraphLayout(t){var e;const{element:n,viewport:r}=this.context,{type:i,enableWorker:o,animation:a,iterations:s}=t,l=Fe(t,["type","enableWorker","animation","iterations"]),[u,c]=r.getCanvasSize(),h=[u/2,c/2],d=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},f=Sc("layout",i);if(!f)return Tc(`The layout of ${i} is not registered.`);const p=Object.getPrototypeOf(f.prototype)===qg.prototype?f:function(t,e){return class extends qg{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=>Xg(t.tick(e))}}execute(t,e){return ze(this,void 0,void 0,(function*(){return Xg(yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(ke({},this.options,e))))}))}transformOptions(t){const{onTick:e}=t;return e?(t.onTick=t=>e(Xg(t)),t):t}graphData2LayoutModel(t){const{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.map((t=>{const e=yh(t),{data:n,style:r,combo:i}=t,o=Fe(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:yh(t),source:e,target:n,data:Object.assign({},r),style:Object.assign({},i)}})),l=i.map((t=>({id:yh(t),data:Object.assign({_isCombo:!0},t.data),style:Object.assign({},t.style)}))),u=new Yg({nodes:[...o,...l],edges:s});return e.model.model.hasTreeStructure(Ec)&&(u.attachTreeStructure(Ec),o.forEach((t=>{const n=e.model.model.getParent(t.id,Ec);n&&u.hasNode(n.id)&&u.setParent(t.id,n.id,Ec)}))),u}}}(f,this.context),g=new p(this.context),v={nodeSize:d,width:u,height:c,center:h};switch(g.id){case"d3-force":case"d3-force-3d":Object.assign(v,{center:{x:u/2,y:c/2,z:0}})}return ke(g.options,v,l),g}updateElementPosition(t,e){const{model:n,element:r}=this.context;return r?(n.updateData(t),r.draw({animation:e,silence:!0})):null}destroy(){var t;this.stopLayout(),this.context={},null===(t=this.supervisor)||void 0===t||t.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const hU=(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 dU(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 fU extends Ph{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;Tc(`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 pU=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class gU extends Ph{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...pU.slice(0,pU.length-1),...t,pU[pU.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class vU{get padding(){return Uc(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=Dc(this.context.options,t);return!!e&&Ae(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,l]=this.getCanvasCenter(),[u=0,c=0,h=0]=r,d=Fh([-u,-c,-h],i);return"relative"===n?{position:Ih(o,d),focalPoint:Ih(a,d)}:{position:Ih([s,l,o[2]],d),focalPoint:Ih([s,l,a[2]],d)}}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 oe("relative"===r?n*i:i,...e)}transform(e,n){return ze(this,void 0,void 0,(function*(){const{graph:r}=this.context,{translate:i,rotate:o,scale:a,origin:s}=e;this.cancelAnimation();const l=this.getAnimation(n);if(XH(r,new qH(t.GraphEvent.BEFORE_TRANSFORM,e)),!o&&a&&!i&&s&&!l)return this.camera.setZoomByViewportPoint(this.getZoomOptions(e),s),void XH(r,new qH(t.GraphEvent.AFTER_TRANSFORM,e));const u={};if(i&&Object.assign(u,this.getTranslateOptions(e)),ae(o)&&Object.assign(u,this.getRotateOptions(e)),ae(a)&&Object.assign(u,{zoom:this.getZoomOptions(e)}),l)return XH(r,new $H(t.GraphEvent.BEFORE_ANIMATE,fc.TRANSFORM,null,e)),new Promise((n=>{this.transformResolver=n,this.camera.gotoLandmark(this.createLandmark(u),Object.assign(Object.assign({},l),{onfinish:()=>{XH(r,new $H(t.GraphEvent.AFTER_ANIMATE,fc.TRANSFORM,null,e)),XH(r,new qH(t.GraphEvent.AFTER_TRANSFORM,e)),this.transformResolver=void 0,n()}}))}));this.camera.gotoLandmark(this.createLandmark(u),{duration:0}),XH(r,new qH(t.GraphEvent.AFTER_TRANSFORM,e))}))}fitView(t,e){return ze(this,void 0,void 0,(function*(){const[n,r,i,o]=this.padding,{when:a="always",direction:s="both"}=t||{},[l,u]=this.context.canvas.getSize(),c=l-o-r,h=u-n-i,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[p,g]=Xc(f);if("overflow"===a&&!("x"===s&&p>=c||"y"===s&&g>=h||"both"===s&&p>=c&&g>=h))return yield this.fitCenter({animation:e});const v=c/p,m=h/g,y="x"===s?v:"y"===s?m:Math.min(v,m),b=this.getAnimation(e);yield this.transform({mode:"relative",scale:y,translate:Ih(jh(this.getCanvasCenter(),this.getBBoxInViewport(d).center),Fh(this.paddingOffset,y))},b)}))}fitCenter(t){return ze(this,void 0,void 0,(function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)}))}focusElements(t){return ze(this,arguments,void 0,(function*(t,e={}){const{element:n}=this.context;if(!n)return;const r=Jc(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 ze(this,void 0,void 0,(function*(){const n=this.context.graph.getViewportByCanvas(t.center),r=jh(e.position||this.getCanvasCenter(),n);yield this.transform({mode:"relative",translate:Ih(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),l=new fr;return l.setMinMax([i,o,0],[a,s,0]),l}isInViewport(t,e=!1,n=0){const{graph:r}=this.context,i=this.getCanvasSize(),[o,a]=r.getCanvasByViewport([0,0]),[s,l]=r.getCanvasByViewport(i);let u=new fr;return u.setMinMax([o,a,0],[s,l,0]),n&&(u=Qc(u,n)),Wc(t)?th(t,u):e?function(t,e){const[n,r]=t.min,[i,o]=t.max,[a,s]=e.min,[l,u]=e.max;return n>=a&&i<=l&&r>=s&&o<=u}(t,u):u.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 mU extends Vg{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new lU},this.isCollapsingExpanding=!1,this.onResize=ye((()=>{this.resize()}),300),this._setOptions(Object.assign({},mU.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[dU].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:l,theme:u,transforms:c}=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),u&&this.setTheme(u),l&&this.setPlugins(l),c&&this.setTransforms(c)}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=Ut(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=Ut(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=Ut(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=Ut(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=Ut(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()}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(Ut(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Ut(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Ut(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Ut(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Ut(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(Ut(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Ut(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Ut(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Ut(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Ut(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Ut(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Ut(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Ut(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 ze(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:l,devicePixelRatio:u=(null!==(e=globalThis.devicePixelRatio)&&void 0!==e?e:1)}=this.options;if(n instanceof FH)this.context.canvas=n,a&&n.setCursor(a),o&&n.setRenderer(o),yield n.ready;else{const e=ne(n)?document.getElementById(n):n,c=WH(e);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:e,width:r,height:i});const h=Object.assign(Object.assign({},l),{container:e,width:r||c[0],height:i||c[1],background:s,renderer:o,cursor:a,devicePixelRatio:u}),d=new FH(h);this.context.canvas=d,yield d.ready,this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:d})}}))}updateCanvas(e){var n,r;const{renderer:i,cursor:o,height:a,width:s}=e,l=this.context.canvas;l&&(i&&(this.emit(t.GraphEvent.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),l.setRenderer(i),this.emit(t.GraphEvent.AFTER_RENDERER_CHANGE,{renderer:i})),o&&l.setCursor(o),(ae(s)||ae(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 eU(this.context)),this.context.plugin||(this.context.plugin=new fU(this.context)),this.context.viewport||(this.context.viewport=new vU(this.context)),this.context.transform||(this.context.transform=new gU(this.context)),this.context.element||(this.context.element=new uU(this.context)),this.context.animation||(this.context.animation=new tU(this.context)),this.context.layout||(this.context.layout=new cU(this.context)),this.context.behavior||(this.context.behavior=new nU(this.context))}prepare(){return ze(this,void 0,void 0,(function*(){if(yield Promise.resolve(),this.destroyed)throw new Error(Oc("The graph instance has been destroyed"));yield this.initCanvas(),this.initRuntime()}))}render(){return ze(this,void 0,void 0,(function*(){if(yield this.prepare(),XH(this,new UH(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,XH(this,new UH(t.GraphEvent.AFTER_RENDER))}))}draw(){return ze(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 ze(this,void 0,void 0,(function*(){yield this.context.layout.postLayout(t)}))}stopLayout(){this.context.layout.stopLayout()}clear(){return ze(this,void 0,void 0,(function*(){const{model:t,element:e}=this.context;t.setData({}),t.clearChanges(),null==e||e.clear()}))}destroy(){var e;XH(this,new UH(t.GraphEvent.BEFORE_DESTROY));const{layout:n,animation:r,element:i,model:o,canvas:a,behavior:s,plugin:l}=this.context;null==l||l.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,XH(this,new UH(t.GraphEvent.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,n){var r;const i=WH(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();Ne(o,a)||(XH(this,new UH(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:o})),this.context.canvas.resize(...o),XH(this,new UH(t.GraphEvent.AFTER_SIZE_CHANGE,{size:o})))}fitView(t,e){return ze(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 ze(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 ze(this,void 0,void 0,(function*(){const{autoFit:t}=this.context.options;if(t)if(ne(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 ze(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 ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)}))}zoomTo(t,e,n){return ze(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 ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)}))}rotateTo(t,e,n){return ze(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 ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)}))}translateTo(t,e){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)}))}getPosition(){return jh([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(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 ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(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 Pe(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(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:l,element:u}=this.context;l.preventUpdateNodeLikeHierarchy((()=>{l.updateData(s)})),yield null===(i=u.draw({animation:a,stage:"visibility"}))||void 0===i?void 0:i.finished}))}showElement(t,e){return ze(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 ze(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 ze(this,void 0,void 0,(function*(){var n;const r={nodes:[],edges:[],combos:[]},i=qt(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 ze(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,Ec).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(yh(i))],a=e-KH(i);o.forEach((t=>{r[yh(t)]=this.getElementZIndex(yh(t))+a}));const{internal:s}=tg(o.map(yh),(t=>n.getRelatedEdgesData(t)));s.forEach((t=>{const e=yh(t);r[e]=this.getElementZIndex(e)+a}))}else r[t]=e})),yield this.setElementZIndex(r)}))}getElementZIndex(t){return KH(this.context.model.getElementDataById(t))}setElementState(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(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 ze(this,arguments,void 0,(function*(t,e=!0){const{model:n,element:r}=this.context;if(Od(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!0});const i=n.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,this.setElementCollapsibility(t,!0),"node"===i?yield r.collapseNode(t,e):"combo"===i&&(yield r.collapseCombo(t,!!e.animation)),this.isCollapsingExpanding=!1}))}expandElement(t){return ze(this,arguments,void 0,(function*(t,e=!0){const{model:n,element:r}=this.context;if(!Od(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!0});const i=n.getElementType(t);this.isCollapsingExpanding=!0,this.setElementCollapsibility(t,!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 ze(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)}}mU.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const yU=(t,e)=>{const{source:n,target:r}=e,i=t.getElementDataById(n),o=t.getElementDataById(r),a=eg(i,(e=>t.getParentData(e,Ec))),s=eg(o,(e=>t.getParentData(e,Ec))),l={sourceNode:yh(a),targetNode:yh(s)};return e.style?Object.assign(e.style,l):e.style=l,e};class bU extends TH{constructor(t,e){super(t,ke({},bU.defaultOptions,e)),this.assignSizeByCentrality=(t,e,n,r,i,o)=>{const a=[e,n],s=[r[0],i[0]],l=[r[1],i[1]],u=[r[2],i[2]],c=(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[c(t,s),c(t,l),c(t,u)]}}beforeDraw(t){const{model:e}=this.context,n=e.getNodeData(),r=Dd(this.options.maxSize),i=Dd(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 l=this.assignSizeByCentrality(o.get(yh(e))||0,s,a,i,r,this.options.scale),u=null===(n=this.context.element)||void 0===n?void 0:n.getElement(yh(e)),c={size:l};this.assignLabelStyle(c,l,e,u),u&&AH(c,u.attributes)||CH(t,u?"update":"add","node",ke(e,{style:c}),!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,Ae(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const n=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:n,labelLineHeight:n+$c(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 Eh(n,r,t)}}bU.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class xU extends TH{constructor(t,e){super(t,Object.assign({},xU.defaultOptions,e))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var t;const e=Jh(this.ref),{graph:n,model:r}=this.context;null===(t=r.getData().nodes)||void 0===t||t.forEach((t=>{var i;if(yh(t)===yh(this.ref))return;const o=Xh(jh(Jh(t),e)),a=Math.abs(o)>Math.PI/2,s=!t.children||0===t.children.length,l=yh(t),u=null===(i=this.context.element)||void 0===i?void 0:i.getElement(l);if(!u||!u.isVisible())return;const c=(s?1:-1)*(Dd(n.getElementRenderStyle(l).size)[0]/2+this.options.offset),h=[["translate",c*Math.cos(o),c*Math.sin(o)],["rotate",a?Or(o)+180:Or(o)]];r.updateNodeData([{id:yh(t),style:{labelTextAlign:a===s?"right":"left",labelTextBaseline:"middle",labelTransform:h}}])})),n.draw()}}xU.defaultOptions={offset:5};const EU=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class wU extends TH{constructor(t,e){super(t,Object.assign({},wU.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,l=(t,e)=>{a.getRelatedEdgesData(e).forEach((t=>!s.has(yh(t))&&s.set(yh(t),t)))};n.forEach(l),i.forEach(l);const u=t=>{const e=a.getEdgeData().map((t=>yU(a,t)));MU(t,e).forEach((t=>!s.has(yh(t))&&s.set(yh(t),t)))};if(o.size&&o.forEach(u),e.size&&e.forEach(u),r.size){const t=JB(QB(a.getChanges())).update.edges;r.forEach((e=>{var n;u(e);const r=null===(n=t.find((t=>yh(t.value)===yh(e))))||void 0===n?void 0:n.original;r&&!SU(e,r)&&u(r)}))}Se(this.options.edges)||s.forEach(((t,e)=>!this.options.edges.includes(e)&&s.delete(e)));const c=a.getEdgeData().map(yh);return new Map([...s].sort(((t,e)=>c.indexOf(t[0])-c.indexOf(e[0]))))},this.applyBundlingStyle=(t,e,n)=>{const{edgeMap:r,reverses:i}=kU(e);r.forEach((e=>{e.forEach(((e,r,o)=>{var a;const s=o.length,l=e.style||{};if(e.source===e.target){const t=EU.length;l.loopPlacement=EU[r%t],l.loopDist=Math.floor(r/t)*n+50}else if(1===s)l.curveOffset=0;else{const t=(r%2==0?1:-1)*(i[`${e.source}|${e.target}|${r}`]?-1:1);l.curveOffset=s%2==1?t*Math.ceil(r/2)*n*2:t*(Math.floor(r/2)*n*2+n)}const u=Object.assign(e,{type:"quadratic",style:l}),c=null===(a=this.context.element)||void 0===a?void 0:a.getElement(yh(e));c&&AH(u.style,c.attributes)||CH(t,c?"update":"add","edge",u,!0)}))}))},this.resetEdgeStyle=t=>{const e=t.style||{},n=this.cacheMergeStyle.get(yh(t))||{};return Object.keys(n).forEach((r=>{Ne(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}=kU(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(yh(r)),o=this.resetEdgeStyle(r);return void(i&&AH(o,i.attributes)||CH(t,i?"update":"add","edge",o))}const i=e.map((({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:a}=n,s={},[l,u]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return pe(o)&&(s[l]=o),pe(a)&&(s[u]=a),s})).reduce(((t,e)=>Object.assign(Object.assign({},t),e)),{});e.forEach(((e,n,r)=>{var o;if(0!==n)return void CH(t,"remove","edge",e);const a=Object.assign({},Ut(this.options.style)?this.options.style(r):this.options.style,{childrenData:r});this.cacheMergeStyle.set(yh(e),a);const s=Object.assign(Object.assign({},e),{type:"line",style:Object.assign(Object.assign(Object.assign({},e.style),i),a)}),l=null===(o=this.context.element)||void 0===o?void 0:o.getElement(yh(e));l&&AH(s.style,l.attributes)||CH(t,l?"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}}wU.defaultOptions={mode:"bundle",distance:15};const kU=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:l}=a,u=`${s}-${l}`;e.has(u)||(e.set(u,[]),i.set(u,new Set));const c=e.get(u),h=i.get(u);c&&h&&!h.has(o)&&(c.push(a),h.add(o),n.add(o));for(const[c,h]of t)if(!n.has(c)&&c!==o&&SU(a,h)){const t=e.get(u),o=i.get(u);t&&o&&!o.has(c)&&(t.push(h),o.add(c),s===h.target&&l===h.source&&(r[`${h.source}|${h.target}|${t.length-1}`]=!0),n.add(c))}}return{edgeMap:e,reverses:r}},MU=(t,e,n)=>e.filter((e=>SU(e,t))),SU=(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 NU={animation:{"combo-collapse":Gc,"combo-expand":Vc,"node-collapse":jc,"node-expand":Bc,"path-in":Fc,"path-out":zc,fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}]},behavior:{"brush-select":yd,"click-select":Nd,"collapse-expand":jg,"create-edge":Fg,"drag-canvas":zg,"drag-element-force":Qg,"drag-element":Gg,"fix-element-size":Jg,"focus-element":tv,"hover-activate":ev,"lasso-select":nv,"auto-adapt-label":Lh,"optimize-viewport-transform":rv,"scroll-canvas":iv,"zoom-canvas":ov},combo:{circle:Rp,rect:Dp},edge:{cubic:og,line:ug,polyline:xg,quadratic:Eg,"cubic-horizontal":ag,"cubic-radial":sg,"cubic-vertical":lg},layout:{"antv-dagre":mb,"combo-combined":eE,"compact-box":fm.compactBox,"d3-force":WE,"force-atlas2":JI,circular:Eb,concentric:Sb,dagre:qI,dendrogram:fm.dendrogram,fishbone:Wj,force:qb,fruchterman:ej,grid:rj,indented:fm.indented,mds:Xx,mindmap:fm.mindmap,radial:pj,random:Ej,snake:Yj},node:{circle:rf,diamond:af,ellipse:cf,hexagon:hf,html:Np,image:Op,rect:Tp,star:Cp,donut:sf,triangle:Ap},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:NH,light:OH},plugin:{"bubble-sets":LB,"edge-bundling":BB,"edge-filter-lens":YB,"grid-line":ZB,background:Zj,contextmenu:jB,fisheye:XB,fullscreen:KB,history:nF,hull:IF,legend:iH,minimap:oH,snapline:uH,timebar:fH,toolbar:mH,tooltip:yH,watermark:EH},transform:{"arrange-draw-order":class extends TH{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=>yh(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 TH{beforeDraw(t,e){if("visibility"===e.stage)return t;if(!this.context.model.model.hasTreeStructure(Ec))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(Od(a)){const a=n.getDescendantsData(e),s=a.map(yh),{internal:l,external:u}=tg(s,(t=>n.getRelatedEdgesData(t)));a.forEach((e=>{const r=yh(e),i=o.findIndex((([t])=>t===r));-1!==i&&o.splice(i,1);const a=n.getElementType(r);CH(t,"remove",a,e)})),l.forEach((e=>CH(t,"remove","edge",e))),u.forEach((t=>{var e;const n=yh(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(yh),{edges:a}=tg(i,(t=>n.getRelatedEdgesData(t)));[...r,...a].forEach((e=>{var r;const i=yh(e),a=n.getElementType(i),s=null===(r=this.context.element)||void 0===r?void 0:r.getElement(i);CH(t,s?"update":"add",a,e),"combo"===a&&o.push([i,e])}))}}return t}},"collapse-expand-node":class extends TH{getElement(t){return this.context.element.getElement(t)}handleExpand(t,e){if(PH(e,"add","node",t),Od(t))return;const n=yh(t);PH(e,"add","node",t);this.context.model.getRelatedEdgesData(n,"out").forEach((t=>{CH(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(wc))return t;const{add:{nodes:r,edges:i},update:{nodes:o}}=t,a=new Map,s=new Map;r.forEach(((t,e)=>{Od(t)&&a.set(e,t)})),i.forEach((t=>{if("node"!==e.getElementType(t.source))return;const n=e.getNodeData(t.source);Od(n)&&a.set(t.source,n)})),o.forEach(((t,e)=>{const n=this.getElement(e);if(!n)return;const r=n.attributes.collapsed;Od(t)?r||a.set(e,t):r&&s.set(e,t)}));const l=new Set;return a.forEach(((e,r)=>{n.getDescendantsData(r).forEach((e=>{const r=yh(e);if(l.has(r))return;CH(t,"remove","node",e);n.getRelatedEdgesData(r).forEach((e=>{CH(t,"remove","edge",e)})),l.add(r)}))})),s.forEach(((e,r)=>{n.getAncestorsData(r,wc).some(Od)?CH(t,"remove","node",e):this.handleExpand(e,t)})),t}},"get-edge-actual-ends":class extends TH{beforeDraw(t){const{add:e,update:n}=t,{model:r}=this.context;return[...e.edges.entries(),...n.edges.entries()].forEach((([,t])=>{yU(r,t)})),t}},"map-node-size":bU,"place-radial-labels":xU,"process-parallel-edges":wU,"update-related-edges":class extends TH{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(yh(t))&&o.set(yh(t),t)))};return i.forEach(s),a.forEach(s),t}}},shape:{circle:Dl,ellipse:Il,group:jl,html:Fl,image:Xd,line:Vl,path:Hl,polygon:$l,polyline:ql,rect:Xl,text:Zl,label:Wd,badge:Hd}};Object.entries(NU).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{LH(t,e,n)}))}));t.AntVDagreLayout=mb,t.AutoAdaptLabel=Lh,t.Background=Zj,t.Badge=Hd,t.BaseBehavior=Dh,t.BaseCombo=Pp,t.BaseEdge=ig,t.BaseLayout=qg,t.BaseNode=nf,t.BasePlugin=qj,t.BaseShape=zd,t.BaseTransform=TH,t.BrushSelect=yd,t.BubbleSets=LB,t.CameraSetting=class extends qj{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=FH,t.Circle=rf,t.CircleCombo=Rp,t.CircularLayout=Eb,t.ClickSelect=Nd,t.CollapseExpand=jg,t.ComboCombinedLayout=eE,t.CompactBoxLayout=fm.compactBox,t.ConcentricLayout=Sb,t.Contextmenu=jB,t.CreateEdge=Fg,t.Cubic=og,t.CubicHorizontal=ag,t.CubicRadial=sg,t.CubicVertical=lg,t.D3ForceLayout=WE,t.DagreLayout=qI,t.DendrogramLayout=fm.dendrogram,t.Diamond=af,t.Donut=sf,t.DragCanvas=zg,t.DragElement=Gg,t.DragElementForce=Qg,t.EdgeBundling=BB,t.EdgeFilterLens=YB,t.Ellipse=cf,t.FishboneLayout=Wj,t.Fisheye=XB,t.FixElementSize=Jg,t.FocusElement=tv,t.ForceAtlas2Layout=JI,t.ForceLayout=qb,t.FruchtermanLayout=ej,t.Fullscreen=KB,t.Graph=mU,t.GridLayout=rj,t.GridLine=ZB,t.HTML=Np,t.Hexagon=hf,t.History=nF,t.HoverActivate=ev,t.Hull=IF,t.Icon=tf,t.Image=Op,t.IndentedLayout=fm.indented,t.Label=Wd,t.LassoSelect=nv,t.Legend=iH,t.Line=ug,t.MDSLayout=Xx,t.MapNodeSize=bU,t.MindmapLayout=fm.mindmap,t.Minimap=oH,t.OptimizeViewportTransform=rv,t.PlaceRadialLabels=xU,t.Polyline=xg,t.ProcessParallelEdges=wU,t.Quadratic=Eg,t.RadialLayout=pj,t.RandomLayout=Ej,t.Rect=Tp,t.RectCombo=Dp,t.ScrollCanvas=iv,t.Shortcut=md,t.SnakeLayout=Yj,t.Snapline=uH,t.Star=Cp,t.Timebar=fH,t.Toolbar=mH,t.Tooltip=yH,t.Triangle=Ap,t.Watermark=EH,t.ZoomCanvas=ov,t.effect=function(t,e,n){RH.has(t)||RH.set(t,{});const r=RH.get(t);if(!r[e])return r[e]=n,!0;const i=r[e];return!DH(i,n)&&(r[e]=n,!0)},t.getExtension=Sc,t.getExtensions=function(t){return Mc[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=yh,t.invokeLayoutMethod=Kg,t.isCollapsed=Od,t.omitStyleProps=Rd,t.parseSize=Dd,t.positionOf=Jh,t.register=LH,t.setVisibility=Ah,t.subStyleProps=Ad,t.treeToGraphData=function(t,e){const{getNodeData:n=(t,e)=>{if(t.depth=e,!t.children)return t;const{children:n}=t,r=Fe(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 wd(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=Nc}));
|
|
87
|
+
*/var _H=function(){function t(e){s(this,t),this.dragndropPluginOptions=e}return u(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,l=t.timeStamp,u=[t.clientX,t.clientY],c=null,h=[t.clientX,t.clientY],d=function(){var t=Qn(Kn().mark((function t(o){var d,f,p,g,v,m;return Kn().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s){t.next=8;break}if(d=o.timeStamp-l,f=gn([o.clientX,o.clientY],u),!(d<=n.dragndropPluginOptions.dragstartTimeThreshold||f<=n.dragndropPluginOptions.dragstartDistanceThreshold)){t.next=5;break}return t.abrupt("return");case 5:o.type="dragstart",a.dispatchEvent(o),s=!0;case 8:if(o.type="drag",o.dx=o.clientX-h[0],o.dy=o.clientY-h[1],a.dispatchEvent(o),h=[o.clientX,o.clientY],r){t.next=21;break}return p="pointer"===n.dragndropPluginOptions.overlap?[o.canvasX,o.canvasY]:e.getBounds().center,t.next=17,i.elementsFromPoint(p[0],p[1]);case 17:g=t.sent,v=g[g.indexOf(e)+1],m=(null==v?void 0:v.closest("[droppable=true]"))||(n.dragndropPluginOptions.isDocumentDroppable?i:null),c!==m&&(c&&(o.type="dragleave",o.target=c,c.dispatchEvent(o)),m&&(o.type="dragenter",o.target=m,m.dispatchEvent(o)),(c=m)&&(o.type="dragover",o.target=c,c.dispatchEvent(o)));case 21:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();o.addEventListener("pointermove",d);var f=function(t){if(s){t.detail={preventClick:!0};var e=t.clone();c&&(e.type="drop",e.target=c,c.dispatchEvent(e)),e.type="dragend",a.dispatchEvent(e),s=!1}o.removeEventListener("pointermove",d)};e.addEventListener("pointerup",f,{once:!0}),e.addEventListener("pointerupoutside",f,{once:!0})}};r.hooks.init.tap(t.tag,(function(){o.addEventListener("pointerdown",a)})),r.hooks.destroy.tap(t.tag,(function(){o.removeEventListener("pointerdown",a)}))}}])}();_H.tag="Dragndrop";var IH=function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,e),(t=v(this,e)).name="dragndrop",t.options=n,t}return y(e,t),u(e,[{key:"init",value:function(){this.addRenderingPlugin(new _H(a({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)}}])}(or);const jH=["main"],BH=["background","main","label","transient"];class FH{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=Fe(e,["renderer","background","cursor","enableMultiLayer"]),s=o?BH:jH,l=zH(n,s),u=Object.fromEntries(s.map((t=>[t,new hu(Object.assign(Object.assign({},a),{supportsMutipleCanvasesInOneContainer:o,renderer:l[t],background:o?"background"===t?r:void 0:r}))])));GH(u),this.extends={config:this.config,renderer:n,renderers:l,layers:u}}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 Jc(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=zH(t,this.config.enableMultiLayer?BH:jH);this.extends.renderers=e,Object.entries(e).forEach((([t,e])=>this.getLayer(t).setRenderer(e))),GH(this.getLayers())}getCanvasByViewport(t){return nd(this.getLayer().viewport2Canvas(rd(t)))}getViewportByCanvas(t){return nd(this.getLayer().canvas2Viewport(rd(t)))}getViewportByClient(t){return nd(this.getLayer().client2Viewport(rd(t)))}getClientByViewport(t){return nd(this.getLayer().viewport2Client(rd(t)))}getClientByCanvas(t){return this.getClientByViewport(this.getViewportByCanvas(t))}getCanvasByClient(t){const e=this.getLayer(),n=e.client2Viewport(rd(t));return nd(e.viewport2Canvas(n))}toDataURL(){return ze(this,arguments,void 0,(function*(t={}){const e=globalThis.devicePixelRatio||1,{mode:n="viewport"}=t,r=Fe(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=Xc(t);[i,o]=t.min,[a,s]=e}const l=Cn('<div id="virtual-image"></div>'),u=new hu({width:a,height:s,renderer:new Sp,devicePixelRatio:e,container:l,background:this.extends.config.background});yield u.ready,u.appendChild(this.getLayer("background").getRoot().cloneNode(!0)),u.appendChild(this.getRoot().cloneNode(!0));const c=this.getLayer("label").getRoot().cloneNode(!0),h=u.viewport2Canvas({x:0,y:0}),d=this.getCanvasByViewport([0,0]);c.translate([d[0]-h.x,d[1]-h.y]),c.scale(1/this.getCamera().getZoom()),u.appendChild(c),u.appendChild(this.getLayer("transient").getRoot().cloneNode(!0));const f=this.getCamera(),p=u.getCamera();if("viewport"===n)p.setZoom(f.getZoom()),p.setPosition(f.getPosition()),p.setFocalPoint(f.getFocalPoint());else if("overall"===n){const[t,e,n]=p.getPosition(),[r,a,s]=p.getFocalPoint();p.setPosition([t+i,e+o,n]),p.setFocalPoint([r+i,a+o,s])}const g=u.getContextService();return new Promise((t=>{u.addEventListener(ou.RERENDER,(()=>ze(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 zH(t,e){return Object.fromEntries(e.map((e=>{const n=(null==t?void 0:t(e))||new Sp;return n instanceof Sp&&n.setConfig({enableDirtyRectangleRendering:!1}),"main"===e?n.registerPlugin(new IH({isDocumentDraggable:!0,isDocumentDroppable:!0,dragstartDistanceThreshold:10,dragstartTimeThreshold:100})):n.unregisterPlugin(n.getPlugin("dom-interaction")),[e,n]})))}function GH(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")}))}const VH=t=>t?parseInt(t):0;function WH(t){if(!t)return[0,0];let e=640,n=480;const[r,i]=function(t){const e=getComputedStyle(t),n=t.clientWidth||VH(e.width),r=t.clientHeight||VH(e.height);return[n-(VH(e.paddingLeft)+VH(e.paddingRight)),r-(VH(e.paddingTop)+VH(e.paddingBottom))]}(t);e=r||e,n=i||n;return[Math.max(ae(e)?e:1,1),Math.max(ae(n)?n:1,1)]}class HH{constructor(t){this.type=t}}class UH extends HH{constructor(t,e){super(t),this.data=e}}class $H extends HH{constructor(t,e,n,r){super(t),this.animationType=e,this.animation=n,this.data=r}}class YH extends HH{constructor(t,e,n){super(t),this.elementType=e,this.data=n}}class qH extends HH{constructor(t,e){super(t),this.data=e}}function XH(t,e){t.emit(e.type,e)}function KH(t){var e;return(null===(e=null==t?void 0:t.style)||void 0===e?void 0:e.zIndex)||0}const ZH="cachedStyle",QH=t=>`__${t}__`;function JH(t,e){return Oe(t,[ZH,QH(e)])}class tU{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:l,stage:u}=e,c=Lc(this.context.options,l,u,t);null===(i=null==r?void 0:r.before)||void 0===i||i.call(r);const h=c.length?Ic(s,this.inferStyle(e,n),c):null;return h?(null===(o=null==r?void 0:r.beforeAnimate)||void 0===o||o.call(r,h),h.finished.then((()=>{var t,e;null===(t=null==r?void 0:r.afterAnimate)||void 0===t||t.call(r,h),null===(e=null==r?void 0:r.after)||void 0===e||e.call(r),this.animations.delete(h)}))):null===(a=null==r?void 0:r.after)||void 0===a||a.call(r),h})).filter(Boolean);a.forEach((t=>this.animations.add(t)));const s=Ac(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:l={}}=t;t.modifiedStyle||(t.modifiedStyle=Object.assign(Object.assign({},s),l));const{modifiedStyle:u}=t,c={},h={};if("enter"===a)Object.assign(c,{opacity:0});else if("exit"===a)Object.assign(h,{opacity:0});else if("show"===a)Object.assign(c,{opacity:0}),Object.assign(h,{opacity:null!==(n=JH(i,"opacity"))&&void 0!==n?n:Rc("opacity")});else if("hide"===a)Object.assign(c,{opacity:null!==(r=JH(i,"opacity"))&&void 0!==r?r:Rc("opacity")}),Object.assign(h,{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(h,{x:t,y:e,z:n})}}else if("combo"===o){if(i.id===n||r.includes(i.id)){const[t,e]=a;Object.assign(h,{x:t,y:e,childrenNode:s.childrenNode})}}else"edge"===o&&Object.assign(h,{sourceNode:u.sourceNode,targetNode:u.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(c,{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(c,{x:t,y:e,z:n,childrenNode:u.childrenNode})}}else"edge"===o&&Object.assign(c,{sourceNode:u.sourceNode,targetNode:u.targetNode})}return[Object.keys(c).length>0?Object.assign({},s,c):s,Object.keys(h).length>0?Object.assign({},u,h):u]}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 eU{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 UH(t.GraphEvent.BATCH_START,{initiate:e}))}endBatch(){this.batchCount--,0===this.batchCount&&this.emit(new UH(t.GraphEvent.BATCH_END))}get isBatching(){return this.batchCount>0}destroy(){this.context=null}}class nU extends Ph{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 Jl)return{type:"canvas",element:t};let e=t;for(;e;){if(wg(e))return{type:"node",element:e};if(kg(e))return{type:"edge",element:e};if(Mg(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&&(Ig(s)||s.destroyed))return;const{type:l,detail:u,button:c}=e,h=Object.assign(Object.assign({},e),{target:s,targetType:a,originalTarget:n});l===t.CommonEvent.POINTER_MOVE&&(this.currentTarget!==s&&(this.currentTarget&&i.emit(`${this.currentTargetType}:${t.CommonEvent.POINTER_LEAVE}`,Object.assign(Object.assign({},h),{type:t.CommonEvent.POINTER_LEAVE,target:this.currentTarget,targetType:this.currentTargetType})),s&&(Object.assign(h,{type:t.CommonEvent.POINTER_ENTER}),i.emit(`${a}:${t.CommonEvent.POINTER_ENTER}`,h))),this.currentTarget=s,this.currentTargetType=a),l===t.CommonEvent.CLICK&&2===c||(i.emit(`${a}:${l}`,h),i.emit(l,h)),l===t.CommonEvent.CLICK&&2===u&&(Object.assign(h,{type:t.CommonEvent.DBLCLICK}),i.emit(`${a}:${t.CommonEvent.DBLCLICK}`,h),i.emit(t.CommonEvent.DBLCLICK,h)),l===t.CommonEvent.POINTER_DOWN&&2===c&&(Object.assign(h,{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}`,h),i.emit(t.CommonEvent.CONTEXT_MENU,h))},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 rU(t,e){const{data:n,style:r}=t,i=Fe(t,["data","style"]),{data:o,style:a}=e,s=Fe(e,["data","style"]),l=Object.assign(Object.assign({},i),s);return(n||o)&&Object.assign(l,{data:Object.assign(Object.assign({},n),o)}),(r||a)&&Object.assign(l,{style:Object.assign(Object.assign({},r),a)}),l}function iU(t){const{data:e,style:n}=t,r=Fe(t,["data","style"]);return e&&(r.data=Object.assign({},e)),n&&(r.style=Object.assign({},n)),r}function oU(t={},e={}){const{states:n=[],data:r={},style:i={},children:o=[]}=t,a=Fe(t,["states","data","style","children"]),{states:s=[],data:l={},style:u={},children:c=[]}=e,h=(t,e)=>t.length===e.length&&t.every(((t,n)=>t===e[n])),d=(t,e)=>{const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((n=>t[n]===e[n]))};return!!d(a,Fe(e,["states","data","style","children"]))&&(!!h(o,c)&&(!!h(n,s)&&(!!d(r,l)&&!!d(i,u))))}function aU(t){const{id:e=yh(t),style:n,data:r}=t,i=Fe(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 sU(t){return t.data}class lU{constructor(){this.latestRemovedComboIds=new Set,this.comboIds=new Set,this.changes=[],this.batchCount=0,this.isTraceless=!1,this.enableUpdateNodeLikeHierarchy=!0,this.model=new Yg}pushChange(t){if(this.isTraceless)return;const{type:e}=t;if(e===dc.NodeUpdated||e===dc.EdgeUpdated||e===dc.ComboUpdated){const{value:n,original:r}=t;this.changes.push({value:iU(n),original:iU(r),type:e})}else this.changes.push({value:iU(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=sU(n);return this.isCombo(yh(r))||(void 0===t||t.includes(yh(r)))&&e.push(r),e}),[])}getEdgeDatum(t){return sU(this.model.getEdge(t))}getEdgeData(t){return this.model.getAllEdges().reduce(((e,n)=>{const r=sU(n);return(void 0===t||t.includes(yh(r)))&&e.push(r),e}),[])}getComboData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=sU(n);return this.isCombo(yh(r))?((void 0===t||t.includes(yh(r)))&&e.push(r),e):e}),[])}getRootsData(t=wc){return this.model.getRoots(t).map(sU)}getAncestorsData(t,e){const{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getAncestors(t,e).map(sU):[]}getDescendantsData(t){const e=this.getElementDataById(t),n=[];return wd(e,(t=>{t!==e&&n.push(t)}),(t=>this.getChildrenData(yh(t))),"TB"),n}getParentData(t,e){const{model:n}=this;if(!e)return void Tc("The hierarchy structure key is not specified");if(!n.hasNode(t)||!n.hasTreeStructure(e))return;const r=n.getParent(t,e);return r?sU(r):void 0}getChildrenData(t){const e="node"===this.getElementType(t)?wc:Ec,{model:n}=this;return n.hasNode(t)&&n.hasTreeStructure(e)?n.getChildren(t,e).map(sU):[]}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 sU(this.model.getNode(t))}getNodeLikeData(t){return this.model.getAllNodes().reduce(((e,n)=>{const r=sU(n);return t?t.includes(yh(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(sU)}getNeighborNodesData(t){return this.model.getNeighbors(t).map(sU)}setData(t){const{nodes:e=[],edges:n=[],combos:r=[]}=t,{nodes:i,edges:o,combos:a}=this.getData(),s=Ch(i,e,(t=>yh(t)),oU),l=Ch(o,n,(t=>yh(t)),oU),u=Ch(a,r,(t=>yh(t)),oU);this.batch((()=>{const t={nodes:s.enter,edges:l.enter,combos:u.enter};this.addData(t),this.computeZIndex(t,"add",!0);const e={nodes:s.update,edges:l.update,combos:u.update};this.updateData(e),this.computeZIndex(e,"update",!0);const n={nodes:s.exit.map(yh),edges:l.exit.map(yh),combos:u.exit.map(yh)};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:dc.NodeAdded}),aU(t))))),this.updateNodeLikeHierarchy(t),this.computeZIndex({nodes:t},"add"))}addEdgeData(t=[]){t.length&&(this.model.addEdges(t.map((t=>(this.pushChange({value:t,type:dc.EdgeAdded}),aU(t))))),this.computeZIndex({edges:t},"add"))}addComboData(t=[]){if(!t.length)return;const{model:e}=this;e.hasTreeStructure(Ec)||e.attachTreeStructure(Ec),e.addNodes(t.map((t=>(this.comboIds.add(yh(t)),this.pushChange({value:t,type:dc.ComboAdded}),aU(t))))),this.updateNodeLikeHierarchy(t),this.computeZIndex({combos:t},"add")}addChildrenData(t,e){const n=this.getNodeLikeDatum(t),r=e.map(yh);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=yh(t);if("add"===e&&ae(null===(n=t.style)||void 0===n?void 0:n.zIndex))return;if("update"===e&&!("combo"in t))return;const a=this.getParentData(o,Ec),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=yh(t);if("add"===e&&ae(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,Ec);if(s)a=((null===(r=s.style)||void 0===r?void 0:r.zIndex)||0)+1;else{const t=this.getParentData(o,wc);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(ae(null===(e=t.style)||void 0===e?void 0:e.zIndex))return;let{id:a,source:s,target:l}=t;if(a){const t=this.getEdgeDatum(a);s=t.source,l=t.target}else a=yh(t);if(!s||!l)return;const u=(null===(r=null===(n=this.getNodeLikeDatum(s))||void 0===n?void 0:n.style)||void 0===r?void 0:r.zIndex)||0,c=(null===(o=null===(i=this.getNodeLikeDatum(l))||void 0===i?void 0:i.style)||void 0===o?void 0:o.zIndex)||0;this.updateEdgeData([{id:yh(t),style:{zIndex:Math.max(u,c)-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=>yh(e)!==t))}),"combo"===n&&!Od(r)){const e=new Set(this.getAncestorsData(t,Ec).map(yh));i.nodes=i.nodes.filter((t=>!e.has(yh(t)))),i.combos=i.combos.filter((t=>!e.has(yh(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=yh(t),r=bh(t);void 0!==r&&(e.hasTreeStructure(Ec)||e.attachTreeStructure(Ec),null===r&&this.refreshComboData(n),this.setParent(n,bh(t),Ec));const i=t.children||[];if(i.length){e.hasTreeStructure(wc)||e.attachTreeStructure(wc);const t=i.filter((t=>e.hasNode(t)));t.forEach((t=>this.setParent(t,n,wc))),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=yh(t),i=sU(e.getNode(r));if(oU(i,t))return;const o=rU(i,t);this.pushChange({value:o,original:i,type:dc.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:dc.NodeUpdated})})),e.forEach((t=>{this.pushChange({value:t,original:t,type:dc.EdgeUpdated})})),n.forEach((t=>{this.pushChange({value:t,original:t,type:dc.ComboUpdated})}))}syncNodeLikeDatum(t){const{model:e}=this,n=yh(t);if(!e.hasNode(n))return;const r=rU(sU(e.getNode(n)),t);e.mergeNodeData(n,r)}syncEdgeDatum(t){const{model:e}=this,n=yh(t);if(!e.hasEdge(n))return;const r=rU(sU(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=yh(t),r=sU(e.getEdge(n));if(oU(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=rU(r,t);this.pushChange({value:i,original:r,type:dc.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=yh(t),i=sU(e.getNode(r));if(oU(i,t))return;const o=rU(i,t);this.pushChange({value:o,original:i,type:dc.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=bh(this.getNodeLikeDatum(t));if(i!==e&&n===Ec){const n={id:t,combo:e};this.isCombo(t),this.syncNodeLikeDatum(n)}this.model.setParent(t,e,n),r&&n===Ec&&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,Ec);e&&this.pushChange({value:e,original:e,type:dc.ComboUpdated}),n.forEach((t=>{this.pushChange({value:t,original:t,type:dc.ComboUpdated})}))}getElementPosition(t){return Jh(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=Ih(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;wd(o,(t=>{const e=yh(t);if(a.has(e))return;a.add(e);const[o,s,l]=Jh(t),u=rU(t,{style:{x:o+n,y:s+r,z:l+i}});this.pushChange({value:u,original:t,type:this.isCombo(e)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(e,u)}),(t=>this.getChildrenData(yh(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,l,u]=Jh(a),c=r-s,h=i-l,d=o-u;wd(a,(t=>{const e=yh(t),[n,r,i]=Jh(t),o=rU(t,{style:{x:n+c,y:r+h,z:i+d}});this.pushChange({value:o,original:t,type:this.isCombo(e)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(e,o)}),(t=>this.getChildrenData(yh(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(yh)),this.pushChange({value:this.getNodeData([t])[0],type:dc.NodeRemoved}),this.removeNodeLikeHierarchy(t)})),this.model.removeNodes(t)}))}removeEdgeData(t=[]){t.length&&(t.forEach((t=>this.pushChange({value:this.getEdgeData([t])[0],type:dc.EdgeRemoved}))),this.model.removeEdges(t))}removeComboData(t=[]){t.length&&this.batch((()=>{t.forEach((t=>{this.pushChange({value:this.getComboData([t])[0],type:dc.ComboRemoved}),this.removeNodeLikeHierarchy(t),this.comboIds.delete(t)})),this.model.removeNodes(t)}))}removeNodeLikeHierarchy(t){if(this.model.hasTreeStructure(Ec)){const e=bh(this.getNodeLikeDatum(t));this.setParent(t,void 0,Ec,!1),this.model.getChildren(t,Ec).forEach((t=>{const n=sU(t),r=yh(n);this.setParent(yh(n),e,Ec,!1);const i=rU(n,{id:yh(n),combo:e});this.pushChange({value:i,original:n,type:this.isCombo(r)?dc.ComboUpdated:dc.NodeUpdated}),this.model.mergeNodeData(yh(n),i)})),$t(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(Oc(`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 uU{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 jl({className:"elements"}))}}emit(t,e){e.silence||XH(this.context.graph,t)}forEachElementData(t){Ed.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=(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 Cc(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({},Id(null===(r=this.getTheme(e))||void 0===r?void 0:r.palette),Id(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?Sc("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=ie(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[yh(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(Oc(`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[yh(e.datum)]=Ld(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(yh(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 Ld((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[yh(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(yh(i))){const t=this.getElementState(yh(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[yh(t)]))}getCombos(){return this.context.model.getComboData().map((({id:t})=>this.elementMap[t]))}getElementComputedStyle(t,e){const n=yh(e),r=this.getThemeStyle(t),i=this.getPaletteStyle(t,n),o=e.style||{},a=this.getDefaultStyle(n),s=this.getThemeStateStyle(t,this.getElementState(n)),l=this.getStateStyle(n),u=Object.assign({},r,i,o,a,s,l);if("combo"===t){const t=this.context.model.getChildrenData(n),e=!!u.collapsed?[]:t.map(yh).filter((t=>this.getElement(t)));Object.assign(u,{childrenNode:e,childrenData:t})}return u}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 ze(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:l}=n;return this.context.animation.animate(r,i?{}:{before:()=>this.emit(new UH(t.GraphEvent.BEFORE_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===l}),e),beforeAnimate:n=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.DRAW,n,a),e),afterAnimate:n=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.DRAW,n,a),e),after:()=>this.emit(new UH(t.GraphEvent.AFTER_DRAW,{dataChanges:o,animation:r,stage:s,render:"render"===l,firstRender:!1===this.context.graph.rendered}),e)})}computeChangesAndDrawData(t){const{model:e}=this.context,n=e.getChanges(),r=QB(n);if(0===r.length)return null;const{NodeAdded:i=[],NodeUpdated:o=[],NodeRemoved:a=[],EdgeAdded:s=[],EdgeUpdated:l=[],EdgeRemoved:u=[],ComboAdded:c=[],ComboUpdated:h=[],ComboRemoved:d=[]}=ie(r,(t=>t.type)),f=t=>new Map(t.map((t=>{const e=t.value;return[yh(e),e]}))),p={add:{nodes:f(i),edges:f(s),combos:f(c)},update:{nodes:f(o),edges:f(l),combos:f(h)},remove:{nodes:f(a),edges:f(u),combos:f(d)}},g=this.transformData(p,t);return e.clearChanges(),{dataChanges:n,drawData:g}}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=yh(n);if(this.getElement(o))return;const a=this.getElementType(e,n),s=this.getElementComputedStyle(e,n),l=Sc(e,a);if(!l)return Tc(`The element ${a} of ${e} is not registered.`);this.emit(new YH(t.GraphEvent.BEFORE_ELEMENT_CREATE,e,n),r);const u=this.container.appendChild(new l({id:o,context:this.context,style:s}));this.shapeTypeMap[o]=a,this.elementMap[o]=u;const{stage:c="enter"}=r;null===(i=this.context.animation)||void 0===i||i.add({element:u,elementType:e,stage:c,originalStyle:Object.assign({},u.attributes),updatedStyle:s},{after:()=>{var i;this.emit(new YH(t.GraphEvent.AFTER_ELEMENT_CREATE,e,n),r),null===(i=u.onCreate)||void 0===i||i.call(u)}})}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=yh(n),{stage:a="update"}=r,s=this.getElement(o);if(!s)return()=>null;this.emit(new YH(t.GraphEvent.BEFORE_ELEMENT_UPDATE,e,n),r);const l=this.getElementType(e,n),u=this.getUpdateStageStyle(e,n,r);this.shapeTypeMap[o]!==l&&(s.destroy(),delete this.shapeTypeMap[o],delete this.elementMap[o],this.createElement(e,n,{animation:!1,silence:!0}));const c="visibility"!==a?a:"hidden"===u.visibility?"hide":"show";"hide"===c&&delete u.visibility,null===(i=this.context.animation)||void 0===i||i.add({element:s,elementType:e,stage:c,originalStyle:Object.assign({},s.attributes),updatedStyle:u},{before:()=>{const t=this.elementMap[o];"collapse"!==a&&_g(t,u),"visibility"===a&&(function(t,e){return QH(e)in(Oe(t,ZH)||{})}(t,"opacity")||function(t,e){const n=Array.isArray(e)?e:[e];Oe(t,ZH)||Te(t,ZH,{}),n.forEach((e=>{Te(Oe(t,ZH),QH(e),t.attributes[e])}))}(t,"opacity"),this.visibilityCache.set(t,"show"===c?"visible":"hidden"),"show"===c&&Ah(t,"visible"))},after:()=>{var i;const s=this.elementMap[o];"collapse"===a&&_g(s,u),"hide"===c&&Ah(s,this.visibilityCache.get(s)),this.emit(new YH(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=yh(t),n=this.getElement(e);n&&function(t){Te(t,"__to_be_destroyed__",!0)}(n)}))}))}destroyElement(e,n,r){var i;const{stage:o="exit"}=r,a=yh(n),s=this.elementMap[a];if(!s)return()=>null;this.emit(new YH(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 YH(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=>yh(t)===e));if(i){const n=jh(Jh(this.context.model.getNodeLikeDatum(e)),Jh(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)}))}}collapseNode(e,n){return ze(this,void 0,void 0,(function*(){var r;const{animation:i,align:o}=n,{model:a,layout:s}=this.context,l=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!l)return;this.markDestroyElement(l.drawData);const u=yield s.simulate();o&&this.alignLayoutResultToElement(u,e),a.updateData(u);const c=this.computeChangesAndDrawData({stage:"collapse",animation:i});if(!c)return;const{drawData:h}=c,{add:d,remove:f,update:p}=h;this.markDestroyElement(h);const g={animation:i,stage:"collapse",data:h};this.destroyElements(f,g),this.createElements(d,g),this.updateElements(p,g),yield null===(r=this.context.animation.animate(i,{beforeAnimate:e=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.COLLAPSE,e,h),g),afterAnimate:e=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.COLLAPSE,e,h),g)},{collapse:{target:e,descendants:Array.from(f.nodes).map((([,t])=>yh(t))),position:Jh(p.nodes.get(e))}}))||void 0===r?void 0:r.finished}))}expandNode(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i,layout:o}=this.context,{animation:a,align:s}=n,l=Jh(i.getNodeData([e])[0]),u=this.computeChangesAndDrawData({stage:"expand",animation:a});if(!u)return;const{drawData:{add:c}}=u;this.createElements(c,{animation:!1,stage:"expand",target:e}),this.context.animation.clear();const h=yield o.simulate();s&&this.alignLayoutResultToElement(h,e),i.updateData(h),this.computeStyle("expand");const d=this.computeChangesAndDrawData({stage:"collapse",animation:a});if(!d)return;const{drawData:f}=d,{update:p}=f,g={animation:a,stage:"expand",data:f};c.edges.forEach((t=>p.edges.set(yh(t),t))),c.nodes.forEach((t=>p.nodes.set(yh(t),t))),this.updateElements(p,g),yield null===(r=this.context.animation.animate(a,{beforeAnimate:e=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.EXPAND,e,f),g),afterAnimate:e=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.EXPAND,e,f),g)},{expand:{target:e,descendants:Array.from(c.nodes).map((([,t])=>yh(t))),position:l}}))||void 0===r?void 0:r.finished}))}collapseCombo(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i,element:o}=this.context;if(i.getAncestorsData(e,Ec).some((t=>Od(t))))return;const a=o.getElement(e),s=a.getComboPosition(Object.assign(Object.assign({},a.attributes),{collapsed:!0})),l=this.computeChangesAndDrawData({stage:"collapse",animation:n});if(!l)return;const{dataChanges:u,drawData:c}=l;this.markDestroyElement(c);const{update:h,remove:d}=c,f={animation:n,stage:"collapse",data:c};this.destroyElements(d,f),this.updateElements(h,f);const p=t=>Array.from(t).map((([,t])=>yh(t)));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new UH(t.GraphEvent.BEFORE_DRAW,{dataChanges:u,animation:n}),f),beforeAnimate:e=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.COLLAPSE,e,c),f),afterAnimate:e=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.COLLAPSE,e,c),f),after:()=>this.emit(new UH(t.GraphEvent.AFTER_DRAW,{dataChanges:u,animation:n}),f)},{collapse:{target:e,descendants:[...p(d.nodes),...p(d.combos)],position:s}}))||void 0===r?void 0:r.finished}))}expandCombo(e,n){return ze(this,void 0,void 0,(function*(){var r;const{model:i}=this.context,o=Jh(i.getComboData([e])[0]);this.computeStyle("expand");const a=this.computeChangesAndDrawData({stage:"expand",animation:n});if(!a)return;const{dataChanges:s,drawData:l}=a,{add:u,update:c}=l,h={animation:n,stage:"expand",data:l,target:e};this.createElements(u,h),this.updateElements(c,h);const d=t=>Array.from(t).map((([,t])=>yh(t)));yield null===(r=this.context.animation.animate(n,{before:()=>this.emit(new UH(t.GraphEvent.BEFORE_DRAW,{dataChanges:s,animation:n}),h),beforeAnimate:e=>this.emit(new $H(t.GraphEvent.BEFORE_ANIMATE,fc.EXPAND,e,l),h),afterAnimate:e=>this.emit(new $H(t.GraphEvent.AFTER_ANIMATE,fc.EXPAND,e,l),h),after:()=>this.emit(new UH(t.GraphEvent.AFTER_DRAW,{dataChanges:s,animation:n}),h)},{expand:{target:e,descendants:[...d(u.nodes),...d(u.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 cU{get presetOptions(){return{animation:!!Dc(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 ze(this,void 0,void 0,(function*(){var n,r,i,o;const{graph:a,model:s}=this.context,{add:l}=e;XH(a,new UH(t.GraphEvent.BEFORE_LAYOUT,{type:"pre"}));const u=yield null===(n=this.context.layout)||void 0===n?void 0:n.simulate();null===(r=null==u?void 0:u.nodes)||void 0===r||r.forEach((t=>{const e=yh(t),n=l.nodes.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)})),null===(i=null==u?void 0:u.edges)||void 0===i||i.forEach((t=>{const e=yh(t),n=l.edges.get(e);s.syncEdgeDatum(t),n&&Object.assign(n.style,t.style)})),null===(o=null==u?void 0:u.combos)||void 0===o||o.forEach((t=>{const e=yh(t),n=l.combos.get(e);s.syncNodeLikeDatum(t),n&&Object.assign(n.style,t.style)})),XH(a,new UH(t.GraphEvent.AFTER_LAYOUT,{type:"pre"})),this.transformDataAfterLayout("pre",e)}))}postLayout(){return ze(this,arguments,void 0,(function*(e=this.options){if(!e)return;const n=Array.isArray(e)?e:[e],{graph:r}=this.context;XH(r,new UH(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);XH(r,new UH(t.GraphEvent.BEFORE_STAGE_LAYOUT,{options:a,index:e}));const s=yield this.stepLayout(o,a,e);XH(r,new UH(t.GraphEvent.AFTER_STAGE_LAYOUT,{options:a,index:e})),i.animation||this.updateElementPosition(s,!1)}XH(r,new UH(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 ze(this,void 0,void 0,(function*(){if(!this.options)return{};const t=Array.isArray(this.options)?this.options:[this.options];let e={};for(let n=0;n<t.length;n++){const r=t[n],i=this.getLayoutData(r);e=yield this.stepLayout(i,Object.assign(Object.assign(Object.assign({},this.presetOptions),r),{animation:!1}),n)}return e}))}stepLayout(t,e,n){return ze(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 ze(this,void 0,void 0,(function*(){const{animation:r,enableWorker:i,iterations:o=300}=e,a=this.initGraphLayout(e);if(!a)return{};if(this.instances[n]=a,this.instance=a,i){const e=a;return this.supervisor=new Vj(e.graphData2LayoutModel(t),e.instance,{iterations:o}),Xg(yield this.supervisor.execute())}if(Qx(a))return r?yield a.execute(t,{onTick:t=>{this.updateElementPosition(t,!1)}}):(a.execute(t),a.stop(),a.tick(o));const s=yield a.execute(t);if(r){const t=this.updateElementPosition(s,r);yield null==t?void 0:t.finished}return s}))}treeLayout(t,e,n){return ze(this,void 0,void 0,(function*(){const{type:n,animation:r}=e,i=Sc("layout",n);if(!i)return{};const{nodes:o=[],edges:a=[]}=t,s=new Yg({nodes:o.map((t=>({id:yh(t),data:t.data||{}}))),edges:a.map((t=>({id:yh(t),source:t.source,target:t.target,data:t.data||{}})))});!function(t){if(t.hasTreeStructure(wc))return;t.attachTreeStructure(wc);const e=t.getAllEdges();for(const n of e){const{source:e,target:r}=n;t.setParent(r,e,wc)}}(s);const l={nodes:[],edges:[]},u={nodes:[],edges:[]};s.getRoots(wc).forEach((t=>{wd(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;wd(n,(t=>{const{id:e,x:n,y:i,z:s=0}=t;l.nodes.push({id:e,style:{x:r,y:o,z:a}}),u.nodes.push({id:e,style:{x:n,y:i,z:s}})}),(t=>t.children),"TB")}));const c=this.inferTreeLayoutOffset(u);if(hU(u,c),r){hU(l,c),this.updateElementPosition(l,!1);const t=this.updateElementPosition(u,r);yield null==t?void 0:t.finished}return u}))}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(),[l,u]=a.getCanvasByViewport([0,0]),[c,h]=a.getCanvasByViewport(s);if(n>=l&&r<=c&&i>=u&&o<=h)return[0,0];return[(l+c)/2-(n+r)/2,(u+h)/2-(i+o)/2]}stopLayout(){this.instance&&Qx(this.instance)&&(this.instance.stop(),this.instance=void 0),this.supervisor&&(this.supervisor.stop(),this.supervisor=void 0),this.animationResult&&(this.animationResult.finish(),this.animationResult=void 0)}getLayoutData(t){const{nodeFilter:e=()=>!0,preLayout:n=!1,isLayoutInvisibleNodes:r=!1}=t,{nodes:i,edges:o,combos:a}=this.context.model.getData(),{element:s,model:l}=this.context,u=t=>s.getElement(t),c=n?t=>{var n;if(!r){if("hidden"===(null===(n=t.style)||void 0===n?void 0:n.visibility))return!1;if(l.getAncestorsData(t.id,wc).some(Od))return!1;if(l.getAncestorsData(t.id,Ec).some(Od))return!1}return e(t)}:t=>{const n=yh(t),r=u(n);return!!r&&(!Ig(r)&&e(t))},h=i.filter(c),d=new Map(h.map((t=>[yh(t),t])));a.forEach((t=>d.set(yh(t),t)));return{nodes:h,edges:o.filter((({source:t,target:e})=>d.has(t)&&d.has(e))),combos:a}}initGraphLayout(t){var e;const{element:n,viewport:r}=this.context,{type:i,enableWorker:o,animation:a,iterations:s}=t,l=Fe(t,["type","enableWorker","animation","iterations"]),[u,c]=r.getCanvasSize(),h=[u/2,c/2],d=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},f=Sc("layout",i);if(!f)return Tc(`The layout of ${i} is not registered.`);const p=Object.getPrototypeOf(f.prototype)===qg.prototype?f:function(t,e){return class extends qg{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=>Xg(t.tick(e))}}execute(t,e){return ze(this,void 0,void 0,(function*(){return Xg(yield this.instance.execute(this.graphData2LayoutModel(t),this.transformOptions(ke({},this.options,e))))}))}transformOptions(t){const{onTick:e}=t;return e?(t.onTick=t=>e(Xg(t)),t):t}graphData2LayoutModel(t){const{nodes:n=[],edges:r=[],combos:i=[]}=t,o=n.map((t=>{const e=yh(t),{data:n,style:r,combo:i}=t,o=Fe(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:yh(t),source:e,target:n,data:Object.assign({},r),style:Object.assign({},i)}})),l=i.map((t=>({id:yh(t),data:Object.assign({_isCombo:!0},t.data),style:Object.assign({},t.style)}))),u=new Yg({nodes:[...o,...l],edges:s});return e.model.model.hasTreeStructure(Ec)&&(u.attachTreeStructure(Ec),o.forEach((t=>{const n=e.model.model.getParent(t.id,Ec);n&&u.hasNode(n.id)&&u.setParent(t.id,n.id,Ec)}))),u}}}(f,this.context),g=new p(this.context),v={nodeSize:d,width:u,height:c,center:h};switch(g.id){case"d3-force":case"d3-force-3d":Object.assign(v,{center:{x:u/2,y:c/2,z:0}})}return ke(g.options,v,l),g}updateElementPosition(t,e){const{model:n,element:r}=this.context;return r?(n.updateData(t),r.draw({animation:e,silence:!0})):null}destroy(){var t;this.stopLayout(),this.context={},null===(t=this.supervisor)||void 0===t||t.kill(),this.supervisor=void 0,this.instance=void 0,this.instances=[],this.animationResult=void 0}}const hU=(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 dU(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 fU extends Ph{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;Tc(`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 pU=["update-related-edges","collapse-expand-node","collapse-expand-combo","get-edge-actual-ends","arrange-draw-order"];class gU extends Ph{constructor(t){super(t),this.category="transform",this.setTransforms(this.context.options.transforms||[])}getTransforms(){}setTransforms(t){this.setExtensions([...pU.slice(0,pU.length-1),...t,pU[pU.length-1]])}getTransformInstance(t){return t?this.extensionMap[t]:this.extensionMap}}class vU{get padding(){return Uc(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=Dc(this.context.options,t);return!!e&&Ae(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,l]=this.getCanvasCenter(),[u=0,c=0,h=0]=r,d=Fh([-u,-c,-h],i);return"relative"===n?{position:Ih(o,d),focalPoint:Ih(a,d)}:{position:Ih([s,l,o[2]],d),focalPoint:Ih([s,l,a[2]],d)}}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 oe("relative"===r?n*i:i,...e)}transform(e,n){return ze(this,void 0,void 0,(function*(){const{graph:r}=this.context,{translate:i,rotate:o,scale:a,origin:s}=e;this.cancelAnimation();const l=this.getAnimation(n);if(XH(r,new qH(t.GraphEvent.BEFORE_TRANSFORM,e)),!o&&a&&!i&&s&&!l)return this.camera.setZoomByViewportPoint(this.getZoomOptions(e),s),void XH(r,new qH(t.GraphEvent.AFTER_TRANSFORM,e));const u={};if(i&&Object.assign(u,this.getTranslateOptions(e)),ae(o)&&Object.assign(u,this.getRotateOptions(e)),ae(a)&&Object.assign(u,{zoom:this.getZoomOptions(e)}),l)return XH(r,new $H(t.GraphEvent.BEFORE_ANIMATE,fc.TRANSFORM,null,e)),new Promise((n=>{this.transformResolver=n,this.camera.gotoLandmark(this.createLandmark(u),Object.assign(Object.assign({},l),{onfinish:()=>{XH(r,new $H(t.GraphEvent.AFTER_ANIMATE,fc.TRANSFORM,null,e)),XH(r,new qH(t.GraphEvent.AFTER_TRANSFORM,e)),this.transformResolver=void 0,n()}}))}));this.camera.gotoLandmark(this.createLandmark(u),{duration:0}),XH(r,new qH(t.GraphEvent.AFTER_TRANSFORM,e))}))}fitView(t,e){return ze(this,void 0,void 0,(function*(){const[n,r,i,o]=this.padding,{when:a="always",direction:s="both"}=t||{},[l,u]=this.context.canvas.getSize(),c=l-o-r,h=u-n-i,d=this.context.canvas.getBounds(),f=this.getBBoxInViewport(d),[p,g]=Xc(f);if("overflow"===a&&!("x"===s&&p>=c||"y"===s&&g>=h||"both"===s&&p>=c&&g>=h))return yield this.fitCenter({animation:e});const v=c/p,m=h/g,y="x"===s?v:"y"===s?m:Math.min(v,m),b=this.getAnimation(e);yield this.transform({mode:"relative",scale:y,translate:Ih(jh(this.getCanvasCenter(),this.getBBoxInViewport(d).center),Fh(this.paddingOffset,y))},b)}))}fitCenter(t){return ze(this,void 0,void 0,(function*(){const e=this.context.canvas.getBounds();yield this.focus(e,t)}))}focusElements(t){return ze(this,arguments,void 0,(function*(t,e={}){const{element:n}=this.context;if(!n)return;const r=Jc(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 ze(this,void 0,void 0,(function*(){const n=this.context.graph.getViewportByCanvas(t.center),r=jh(e.position||this.getCanvasCenter(),n);yield this.transform({mode:"relative",translate:Ih(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),l=new fr;return l.setMinMax([i,o,0],[a,s,0]),l}isInViewport(t,e=!1,n=0){const{graph:r}=this.context,i=this.getCanvasSize(),[o,a]=r.getCanvasByViewport([0,0]),[s,l]=r.getCanvasByViewport(i);let u=new fr;return u.setMinMax([o,a,0],[s,l,0]),n&&(u=Qc(u,n)),Wc(t)?th(t,u):e?function(t,e){const[n,r]=t.min,[i,o]=t.max,[a,s]=e.min,[l,u]=e.max;return n>=a&&i<=l&&r>=s&&o<=u}(t,u):u.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 mU extends Vg{constructor(t){var e;super(),this.options={},this.rendered=!1,this.destroyed=!1,this.context={model:new lU},this.isCollapsingExpanding=!1,this.onResize=ye((()=>{this.resize()}),300),this._setOptions(Object.assign({},mU.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[dU].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:l,theme:u,transforms:c}=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),u&&this.setTheme(u),l&&this.setPlugins(l),c&&this.setTransforms(c)}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=Ut(t)?t(this.getTheme()):t}setLayout(t){this.options.layout=Ut(t)?t(this.getLayout()):t}getLayout(){return this.options.layout}setBehaviors(t){var e;this.options.behaviors=Ut(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=Ut(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=Ut(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()}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(Ut(t)?t(this.getData()):t)}addData(t){this.context.model.addData(Ut(t)?t(this.getData()):t)}addNodeData(t){this.context.model.addNodeData(Ut(t)?t(this.getNodeData()):t)}addEdgeData(t){this.context.model.addEdgeData(Ut(t)?t(this.getEdgeData()):t)}addComboData(t){this.context.model.addComboData(Ut(t)?t(this.getComboData()):t)}addChildrenData(t,e){this.context.model.addChildrenData(t,e)}updateData(t){this.context.model.updateData(Ut(t)?t(this.getData()):t)}updateNodeData(t){this.context.model.updateNodeData(Ut(t)?t(this.getNodeData()):t)}updateEdgeData(t){this.context.model.updateEdgeData(Ut(t)?t(this.getEdgeData()):t)}updateComboData(t){this.context.model.updateComboData(Ut(t)?t(this.getComboData()):t)}removeData(t){this.context.model.removeData(Ut(t)?t(this.getData()):t)}removeNodeData(t){this.context.model.removeNodeData(Ut(t)?t(this.getNodeData()):t)}removeEdgeData(t){this.context.model.removeEdgeData(Ut(t)?t(this.getEdgeData()):t)}removeComboData(t){this.context.model.removeComboData(Ut(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 ze(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:l,devicePixelRatio:u=(null!==(e=globalThis.devicePixelRatio)&&void 0!==e?e:1)}=this.options;if(n instanceof FH)this.context.canvas=n,a&&n.setCursor(a),o&&n.setRenderer(o),yield n.ready;else{const e=ne(n)?document.getElementById(n):n,c=WH(e);this.emit(t.GraphEvent.BEFORE_CANVAS_INIT,{container:e,width:r,height:i});const h=Object.assign(Object.assign({},l),{container:e,width:r||c[0],height:i||c[1],background:s,renderer:o,cursor:a,devicePixelRatio:u}),d=new FH(h);this.context.canvas=d,yield d.ready,this.emit(t.GraphEvent.AFTER_CANVAS_INIT,{canvas:d})}}))}updateCanvas(e){var n,r;const{renderer:i,cursor:o,height:a,width:s}=e,l=this.context.canvas;l&&(i&&(this.emit(t.GraphEvent.BEFORE_RENDERER_CHANGE,{renderer:this.options.renderer}),l.setRenderer(i),this.emit(t.GraphEvent.AFTER_RENDERER_CHANGE,{renderer:i})),o&&l.setCursor(o),(ae(s)||ae(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 eU(this.context)),this.context.plugin||(this.context.plugin=new fU(this.context)),this.context.viewport||(this.context.viewport=new vU(this.context)),this.context.transform||(this.context.transform=new gU(this.context)),this.context.element||(this.context.element=new uU(this.context)),this.context.animation||(this.context.animation=new tU(this.context)),this.context.layout||(this.context.layout=new cU(this.context)),this.context.behavior||(this.context.behavior=new nU(this.context))}prepare(){return ze(this,void 0,void 0,(function*(){yield Promise.resolve(),this.destroyed?console.error(Oc("The graph instance has been destroyed")):(yield this.initCanvas(),this.initRuntime())}))}render(){return ze(this,void 0,void 0,(function*(){if(yield this.prepare(),XH(this,new UH(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,XH(this,new UH(t.GraphEvent.AFTER_RENDER))}))}draw(){return ze(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 ze(this,void 0,void 0,(function*(){yield this.context.layout.postLayout(t)}))}stopLayout(){this.context.layout.stopLayout()}clear(){return ze(this,void 0,void 0,(function*(){const{model:t,element:e}=this.context;t.setData({}),t.clearChanges(),null==e||e.clear()}))}destroy(){var e;XH(this,new UH(t.GraphEvent.BEFORE_DESTROY));const{layout:n,animation:r,element:i,model:o,canvas:a,behavior:s,plugin:l}=this.context;null==l||l.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,XH(this,new UH(t.GraphEvent.AFTER_DESTROY))}getCanvas(){return this.context.canvas}resize(e,n){var r;const i=WH(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();Ne(o,a)||(XH(this,new UH(t.GraphEvent.BEFORE_SIZE_CHANGE,{size:o})),this.context.canvas.resize(...o),XH(this,new UH(t.GraphEvent.AFTER_SIZE_CHANGE,{size:o})))}fitView(t,e){return ze(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 ze(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 ze(this,void 0,void 0,(function*(){const{autoFit:t}=this.context.options;if(t)if(ne(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 ze(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 ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",scale:t,origin:n},e)}))}zoomTo(t,e,n){return ze(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 ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",rotate:t,origin:n},e)}))}rotateTo(t,e,n){return ze(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 ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"relative",translate:t},e)}))}translateTo(t,e){return ze(this,void 0,void 0,(function*(){yield this.context.viewport.transform({mode:"absolute",translate:t},e)}))}getPosition(){return jh([0,0],this.getCanvasByViewport([0,0]))}translateElementBy(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(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 ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(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 Pe(this.context.element.getElement(t).attributes,["context"])}setElementVisibility(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(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:l,element:u}=this.context;l.preventUpdateNodeLikeHierarchy((()=>{l.updateData(s)})),yield null===(i=u.draw({animation:a,stage:"visibility"}))||void 0===i?void 0:i.finished}))}showElement(t,e){return ze(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 ze(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 ze(this,void 0,void 0,(function*(){var n;const r={nodes:[],edges:[],combos:[]},i=qt(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 ze(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,Ec).at(-1)||this.getComboData(t),o=[i,...n.getDescendantsData(yh(i))],a=e-KH(i);o.forEach((t=>{r[yh(t)]=this.getElementZIndex(yh(t))+a}));const{internal:s}=tg(o.map(yh),(t=>n.getRelatedEdgesData(t)));s.forEach((t=>{const e=yh(t);r[e]=this.getElementZIndex(e)+a}))}else r[t]=e})),yield this.setElementZIndex(r)}))}getElementZIndex(t){return KH(this.context.model.getElementDataById(t))}setElementState(t,e){return ze(this,arguments,void 0,(function*(t,e,n=!0){var r,i;const[o,a]=qt(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 ze(this,arguments,void 0,(function*(t,e=!0){const{model:n,element:r}=this.context;if(Od(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!0});const i=n.getElementType(t);yield this.frontElement(t),this.isCollapsingExpanding=!0,this.setElementCollapsibility(t,!0),"node"===i?yield r.collapseNode(t,e):"combo"===i&&(yield r.collapseCombo(t,!!e.animation)),this.isCollapsingExpanding=!1}))}expandElement(t){return ze(this,arguments,void 0,(function*(t,e=!0){const{model:n,element:r}=this.context;if(!Od(n.getNodeLikeData([t])[0]))return;if(this.isCollapsingExpanding)return;"boolean"==typeof e&&(e={animation:e,align:!0});const i=n.getElementType(t);this.isCollapsingExpanding=!0,this.setElementCollapsibility(t,!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 ze(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)}}mU.defaultOptions={autoResize:!1,theme:"light",rotation:0,zoom:1,zoomRange:[.01,10]};const yU=(t,e)=>{const{source:n,target:r}=e,i=t.getElementDataById(n),o=t.getElementDataById(r),a=eg(i,(e=>t.getParentData(e,Ec))),s=eg(o,(e=>t.getParentData(e,Ec))),l={sourceNode:yh(a),targetNode:yh(s)};return e.style?Object.assign(e.style,l):e.style=l,e};class bU extends TH{constructor(t,e){super(t,ke({},bU.defaultOptions,e)),this.assignSizeByCentrality=(t,e,n,r,i,o)=>{const a=[e,n],s=[r[0],i[0]],l=[r[1],i[1]],u=[r[2],i[2]],c=(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[c(t,s),c(t,l),c(t,u)]}}beforeDraw(t){const{model:e}=this.context,n=e.getNodeData(),r=Dd(this.options.maxSize),i=Dd(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 l=this.assignSizeByCentrality(o.get(yh(e))||0,s,a,i,r,this.options.scale),u=null===(n=this.context.element)||void 0===n?void 0:n.getElement(yh(e)),c={size:l};this.assignLabelStyle(c,l,e,u),u&&AH(c,u.attributes)||CH(t,u?"update":"add","node",ke(e,{style:c}),!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,Ae(o,["labelFontSize","labelLineHeight"])),this.options.mapLabelSize){const n=this.getLabelSizeByNodeSize(e,1/0,Number(t.labelFontSize));Object.assign(t,{labelFontSize:n,labelLineHeight:n+$c(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 Eh(n,r,t)}}bU.defaultOptions={centrality:{type:"degree"},maxSize:80,minSize:20,scale:"linear",mapLabelSize:!1};class xU extends TH{constructor(t,e){super(t,Object.assign({},xU.defaultOptions,e))}get ref(){return this.context.model.getRootsData()[0]}afterLayout(){var t;const e=Jh(this.ref),{graph:n,model:r}=this.context;null===(t=r.getData().nodes)||void 0===t||t.forEach((t=>{var i;if(yh(t)===yh(this.ref))return;const o=Xh(jh(Jh(t),e)),a=Math.abs(o)>Math.PI/2,s=!t.children||0===t.children.length,l=yh(t),u=null===(i=this.context.element)||void 0===i?void 0:i.getElement(l);if(!u||!u.isVisible())return;const c=(s?1:-1)*(Dd(n.getElementRenderStyle(l).size)[0]/2+this.options.offset),h=[["translate",c*Math.cos(o),c*Math.sin(o)],["rotate",a?Or(o)+180:Or(o)]];r.updateNodeData([{id:yh(t),style:{labelTextAlign:a===s?"right":"left",labelTextBaseline:"middle",labelTransform:h}}])})),n.draw()}}xU.defaultOptions={offset:5};const EU=["top","top-right","right","right-bottom","bottom","bottom-left","left","left-top"];class wU extends TH{constructor(t,e){super(t,Object.assign({},wU.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,l=(t,e)=>{a.getRelatedEdgesData(e).forEach((t=>!s.has(yh(t))&&s.set(yh(t),t)))};n.forEach(l),i.forEach(l);const u=t=>{const e=a.getEdgeData().map((t=>yU(a,t)));MU(t,e).forEach((t=>!s.has(yh(t))&&s.set(yh(t),t)))};if(o.size&&o.forEach(u),e.size&&e.forEach(u),r.size){const t=JB(QB(a.getChanges())).update.edges;r.forEach((e=>{var n;u(e);const r=null===(n=t.find((t=>yh(t.value)===yh(e))))||void 0===n?void 0:n.original;r&&!SU(e,r)&&u(r)}))}Se(this.options.edges)||s.forEach(((t,e)=>!this.options.edges.includes(e)&&s.delete(e)));const c=a.getEdgeData().map(yh);return new Map([...s].sort(((t,e)=>c.indexOf(t[0])-c.indexOf(e[0]))))},this.applyBundlingStyle=(t,e,n)=>{const{edgeMap:r,reverses:i}=kU(e);r.forEach((e=>{e.forEach(((e,r,o)=>{var a;const s=o.length,l=e.style||{};if(e.source===e.target){const t=EU.length;l.loopPlacement=EU[r%t],l.loopDist=Math.floor(r/t)*n+50}else if(1===s)l.curveOffset=0;else{const t=(r%2==0?1:-1)*(i[`${e.source}|${e.target}|${r}`]?-1:1);l.curveOffset=s%2==1?t*Math.ceil(r/2)*n*2:t*(Math.floor(r/2)*n*2+n)}const u=Object.assign(e,{type:"quadratic",style:l}),c=null===(a=this.context.element)||void 0===a?void 0:a.getElement(yh(e));c&&AH(u.style,c.attributes)||CH(t,c?"update":"add","edge",u,!0)}))}))},this.resetEdgeStyle=t=>{const e=t.style||{},n=this.cacheMergeStyle.get(yh(t))||{};return Object.keys(n).forEach((r=>{Ne(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}=kU(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(yh(r)),o=this.resetEdgeStyle(r);return void(i&&AH(o,i.attributes)||CH(t,i?"update":"add","edge",o))}const i=e.map((({source:t,target:e,style:n={}},i)=>{const{startArrow:o,endArrow:a}=n,s={},[l,u]=r[`${t}|${e}|${i}`]?["endArrow","startArrow"]:["startArrow","endArrow"];return pe(o)&&(s[l]=o),pe(a)&&(s[u]=a),s})).reduce(((t,e)=>Object.assign(Object.assign({},t),e)),{});e.forEach(((e,n,r)=>{var o;if(0!==n)return void CH(t,"remove","edge",e);const a=Object.assign({},Ut(this.options.style)?this.options.style(r):this.options.style,{childrenData:r});this.cacheMergeStyle.set(yh(e),a);const s=Object.assign(Object.assign({},e),{type:"line",style:Object.assign(Object.assign(Object.assign({},e.style),i),a)}),l=null===(o=this.context.element)||void 0===o?void 0:o.getElement(yh(e));l&&AH(s.style,l.attributes)||CH(t,l?"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}}wU.defaultOptions={mode:"bundle",distance:15};const kU=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:l}=a,u=`${s}-${l}`;e.has(u)||(e.set(u,[]),i.set(u,new Set));const c=e.get(u),h=i.get(u);c&&h&&!h.has(o)&&(c.push(a),h.add(o),n.add(o));for(const[c,h]of t)if(!n.has(c)&&c!==o&&SU(a,h)){const t=e.get(u),o=i.get(u);t&&o&&!o.has(c)&&(t.push(h),o.add(c),s===h.target&&l===h.source&&(r[`${h.source}|${h.target}|${t.length-1}`]=!0),n.add(c))}}return{edgeMap:e,reverses:r}},MU=(t,e,n)=>e.filter((e=>SU(e,t))),SU=(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 NU={animation:{"combo-collapse":Gc,"combo-expand":Vc,"node-collapse":jc,"node-expand":Bc,"path-in":Fc,"path-out":zc,fade:[{fields:["opacity"]}],translate:[{fields:["x","y"]}]},behavior:{"brush-select":yd,"click-select":Nd,"collapse-expand":jg,"create-edge":Fg,"drag-canvas":zg,"drag-element-force":Qg,"drag-element":Gg,"fix-element-size":Jg,"focus-element":tv,"hover-activate":ev,"lasso-select":nv,"auto-adapt-label":Lh,"optimize-viewport-transform":rv,"scroll-canvas":iv,"zoom-canvas":ov},combo:{circle:Rp,rect:Dp},edge:{cubic:og,line:ug,polyline:xg,quadratic:Eg,"cubic-horizontal":ag,"cubic-radial":sg,"cubic-vertical":lg},layout:{"antv-dagre":mb,"combo-combined":eE,"compact-box":fm.compactBox,"d3-force":WE,"force-atlas2":JI,circular:Eb,concentric:Sb,dagre:qI,dendrogram:fm.dendrogram,fishbone:Wj,force:qb,fruchterman:ej,grid:rj,indented:fm.indented,mds:Xx,mindmap:fm.mindmap,radial:pj,random:Ej,snake:Yj},node:{circle:rf,diamond:af,ellipse:cf,hexagon:hf,html:Np,image:Op,rect:Tp,star:Cp,donut:sf,triangle:Ap},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:NH,light:OH},plugin:{"bubble-sets":LB,"edge-bundling":BB,"edge-filter-lens":YB,"grid-line":ZB,background:Zj,contextmenu:jB,fisheye:XB,fullscreen:KB,history:nF,hull:IF,legend:iH,minimap:oH,snapline:uH,timebar:fH,toolbar:mH,tooltip:yH,watermark:EH},transform:{"arrange-draw-order":class extends TH{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=>yh(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 TH{beforeDraw(t,e){if("visibility"===e.stage)return t;if(!this.context.model.model.hasTreeStructure(Ec))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(Od(a)){const a=n.getDescendantsData(e),s=a.map(yh),{internal:l,external:u}=tg(s,(t=>n.getRelatedEdgesData(t)));a.forEach((e=>{const r=yh(e),i=o.findIndex((([t])=>t===r));-1!==i&&o.splice(i,1);const a=n.getElementType(r);CH(t,"remove",a,e)})),l.forEach((e=>CH(t,"remove","edge",e))),u.forEach((t=>{var e;const n=yh(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(yh),{edges:a}=tg(i,(t=>n.getRelatedEdgesData(t)));[...r,...a].forEach((e=>{var r;const i=yh(e),a=n.getElementType(i),s=null===(r=this.context.element)||void 0===r?void 0:r.getElement(i);CH(t,s?"update":"add",a,e),"combo"===a&&o.push([i,e])}))}}return t}},"collapse-expand-node":class extends TH{getElement(t){return this.context.element.getElement(t)}handleExpand(t,e){if(PH(e,"add","node",t),Od(t))return;const n=yh(t);PH(e,"add","node",t);this.context.model.getRelatedEdgesData(n,"out").forEach((t=>{CH(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(wc))return t;const{add:{nodes:r,edges:i},update:{nodes:o}}=t,a=new Map,s=new Map;r.forEach(((t,e)=>{Od(t)&&a.set(e,t)})),i.forEach((t=>{if("node"!==e.getElementType(t.source))return;const n=e.getNodeData(t.source);Od(n)&&a.set(t.source,n)})),o.forEach(((t,e)=>{const n=this.getElement(e);if(!n)return;const r=n.attributes.collapsed;Od(t)?r||a.set(e,t):r&&s.set(e,t)}));const l=new Set;return a.forEach(((e,r)=>{n.getDescendantsData(r).forEach((e=>{const r=yh(e);if(l.has(r))return;CH(t,"remove","node",e);n.getRelatedEdgesData(r).forEach((e=>{CH(t,"remove","edge",e)})),l.add(r)}))})),s.forEach(((e,r)=>{n.getAncestorsData(r,wc).some(Od)?CH(t,"remove","node",e):this.handleExpand(e,t)})),t}},"get-edge-actual-ends":class extends TH{beforeDraw(t){const{add:e,update:n}=t,{model:r}=this.context;return[...e.edges.entries(),...n.edges.entries()].forEach((([,t])=>{yU(r,t)})),t}},"map-node-size":bU,"place-radial-labels":xU,"process-parallel-edges":wU,"update-related-edges":class extends TH{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(yh(t))&&o.set(yh(t),t)))};return i.forEach(s),a.forEach(s),t}}},shape:{circle:Dl,ellipse:Il,group:jl,html:Fl,image:Xd,line:Vl,path:Hl,polygon:$l,polyline:ql,rect:Xl,text:Zl,label:Wd,badge:Hd}};Object.entries(NU).forEach((([t,e])=>{Object.entries(e).forEach((([e,n])=>{LH(t,e,n)}))}));t.AntVDagreLayout=mb,t.AutoAdaptLabel=Lh,t.Background=Zj,t.Badge=Hd,t.BaseBehavior=Dh,t.BaseCombo=Pp,t.BaseEdge=ig,t.BaseLayout=qg,t.BaseNode=nf,t.BasePlugin=qj,t.BaseShape=zd,t.BaseTransform=TH,t.BrushSelect=yd,t.BubbleSets=LB,t.CameraSetting=class extends qj{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=FH,t.Circle=rf,t.CircleCombo=Rp,t.CircularLayout=Eb,t.ClickSelect=Nd,t.CollapseExpand=jg,t.ComboCombinedLayout=eE,t.CompactBoxLayout=fm.compactBox,t.ConcentricLayout=Sb,t.Contextmenu=jB,t.CreateEdge=Fg,t.Cubic=og,t.CubicHorizontal=ag,t.CubicRadial=sg,t.CubicVertical=lg,t.D3ForceLayout=WE,t.DagreLayout=qI,t.DendrogramLayout=fm.dendrogram,t.Diamond=af,t.Donut=sf,t.DragCanvas=zg,t.DragElement=Gg,t.DragElementForce=Qg,t.EdgeBundling=BB,t.EdgeFilterLens=YB,t.Ellipse=cf,t.FishboneLayout=Wj,t.Fisheye=XB,t.FixElementSize=Jg,t.FocusElement=tv,t.ForceAtlas2Layout=JI,t.ForceLayout=qb,t.FruchtermanLayout=ej,t.Fullscreen=KB,t.Graph=mU,t.GridLayout=rj,t.GridLine=ZB,t.HTML=Np,t.Hexagon=hf,t.History=nF,t.HoverActivate=ev,t.Hull=IF,t.Icon=tf,t.Image=Op,t.IndentedLayout=fm.indented,t.Label=Wd,t.LassoSelect=nv,t.Legend=iH,t.Line=ug,t.MDSLayout=Xx,t.MapNodeSize=bU,t.MindmapLayout=fm.mindmap,t.Minimap=oH,t.OptimizeViewportTransform=rv,t.PlaceRadialLabels=xU,t.Polyline=xg,t.ProcessParallelEdges=wU,t.Quadratic=Eg,t.RadialLayout=pj,t.RandomLayout=Ej,t.Rect=Tp,t.RectCombo=Dp,t.ScrollCanvas=iv,t.Shortcut=md,t.SnakeLayout=Yj,t.Snapline=uH,t.Star=Cp,t.Timebar=fH,t.Toolbar=mH,t.Tooltip=yH,t.Triangle=Ap,t.Watermark=EH,t.ZoomCanvas=ov,t.effect=function(t,e,n){RH.has(t)||RH.set(t,{});const r=RH.get(t);if(!r[e])return r[e]=n,!0;const i=r[e];return!DH(i,n)&&(r[e]=n,!0)},t.getExtension=Sc,t.getExtensions=function(t){return Mc[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=yh,t.invokeLayoutMethod=Kg,t.isCollapsed=Od,t.omitStyleProps=Rd,t.parseSize=Dd,t.positionOf=Jh,t.register=LH,t.setVisibility=Ah,t.subStyleProps=Ad,t.treeToGraphData=function(t,e){const{getNodeData:n=(t,e)=>{if(t.depth=e,!t.children)return t;const{children:n}=t,r=Fe(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 wd(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=Nc}));
|